Commit e91bd904ee6aa39acea675f2b0d0b721c24518cc

Authored by Carlos Picanco
1 parent 282baa7e
Exists in master

runner: fix server crash

- occuring when a consequence style set does not have gscG.
experiment_runner/units/game_actors.pas
@@ -732,8 +732,10 @@ procedure TConsequence.PresentPoints(APlayerBox: TPlayerBox; G: TLabel); @@ -732,8 +732,10 @@ procedure TConsequence.PresentPoints(APlayerBox: TPlayerBox; G: TLabel);
732 begin 732 begin
733 if gscG in FStyle then 733 if gscG in FStyle then
734 G.Caption:= IntToStr(StrToInt(G.Caption) + FP.ResultAsInteger) 734 G.Caption:= IntToStr(StrToInt(G.Caption) + FP.ResultAsInteger)
735 - else  
736 - APlayerBox.LabelPointsCount.Caption := IntToStr(StrToInt(APlayerBox.LabelPointsCount.Caption) + FP.ResultAsInteger); 735 +
  736 + if (gscI in FStyle) or (gscA in FStyle) or (gscB in FStyle) then
  737 + if Assigned(APlayerBox) then
  738 + APlayerBox.LabelPointsCount.Caption := IntToStr(StrToInt(APlayerBox.LabelPointsCount.Caption) + FP.ResultAsInteger);
737 end; 739 end;
738 740
739 function TConsequence.GetShouldPublishMessage: Boolean; // for players only 741 function TConsequence.GetShouldPublishMessage: Boolean; // for players only
experiment_runner/units/game_control.pas
@@ -306,6 +306,7 @@ end; @@ -306,6 +306,7 @@ end;
306 function TGameControl.GetPlayerBox(AID: UTF8string): TPlayerBox; 306 function TGameControl.GetPlayerBox(AID: UTF8string): TPlayerBox;
307 var i : integer; 307 var i : integer;
308 begin 308 begin
  309 + Result := nil;
309 for i := 0 to FormMatrixGame.GBLastChoice.ComponentCount-1 do 310 for i := 0 to FormMatrixGame.GBLastChoice.ComponentCount-1 do
310 if TPlayerBox(FormMatrixGame.GBLastChoice.Components[i]).ID = AID then 311 if TPlayerBox(FormMatrixGame.GBLastChoice.Components[i]).ID = AID then
311 begin 312 begin
@@ -536,6 +537,8 @@ begin @@ -536,6 +537,8 @@ begin
536 {$IFDEF DEBUG} 537 {$IFDEF DEBUG}
537 WriteLn(S); 538 WriteLn(S);
538 {$ENDIF} 539 {$ENDIF}
  540 + // player box is ignored for group points
  541 + // LabelGroupCount is ignored for player points
539 LConsequence.PresentPoints(GetPlayerBox(AID), FormMatrixGame.LabelGroupCount); 542 LConsequence.PresentPoints(GetPlayerBox(AID), FormMatrixGame.LabelGroupCount);
540 end; 543 end;
541 end; 544 end;
@@ -644,7 +647,6 @@ begin @@ -644,7 +647,6 @@ begin
644 gaPlayer:FExperiment := TExperiment.Create(FZMQActor.Owner); 647 gaPlayer:FExperiment := TExperiment.Create(FZMQActor.Owner);
645 gaWatcher:FExperiment := TExperiment.Create(FZMQActor.Owner); 648 gaWatcher:FExperiment := TExperiment.Create(FZMQActor.Owner);
646 end; 649 end;
647 - FExperiment.State:=xsWaiting;  
648 FExperiment.OnEndTurn := @NextTurn; 650 FExperiment.OnEndTurn := @NextTurn;
649 FExperiment.OnEndCycle := @NextCycle; 651 FExperiment.OnEndCycle := @NextCycle;
650 FExperiment.OnEndCondition:= @NextCondition; 652 FExperiment.OnEndCondition:= @NextCondition;