Changeset 144 for trunk/GameServer.pas
- Timestamp:
- May 11, 2018, 11:57:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GameServer.pas
r143 r144 87 87 var 88 88 // PARAMETERS 89 bixView: array [0 .. nPl - 1] of integer; { brain index of the players }89 PlayersBrain: TBrains; { brain index of the players } 90 90 Difficulty: array [0 .. nPl - 1] of integer absolute Database.Difficulty; 91 91 { difficulty } … … 124 124 125 125 var 126 MaxTurn, LoadTurn, { turn where to stop loading } 127 nLogOpened, { nLog of opened book } 126 MaxTurn: Integer; 127 LoadTurn: Integer; { turn where to stop loading } 128 nLogOpened: Integer; { nLog of opened book } 128 129 {$IFOPT O-}nHandoverStack, {$ENDIF} 129 LastEndClientCommand, pContacted, // player contacted for negotiation 130 pDipActive, // player who's to speak in a negotiation 131 pTurn, { player who's turn it is } 132 GWinner, GColdWarStart, GStealFrom, SpyMission, ZOCTile, CCCommand, 133 CCPlayer: integer; 134 DebugMap: array [0 .. nPl - 1] of pointer; 130 LastEndClientCommand: Integer; 131 pContacted: Integer; // player contacted for negotiation 132 pDipActive: Integer; // player who's to speak in a negotiation 133 pTurn: Integer; { player who's turn it is } 134 GWinner: Integer; 135 GColdWarStart: Integer; 136 GStealFrom: Integer; 137 SpyMission: Integer; 138 ZOCTile: Integer; 139 CCCommand: Integer; 140 CCPlayer: Integer; 141 DebugMap: array [0 .. nPl - 1] of Pointer; 135 142 ExeInfo: TSearchRec; 136 143 Stat: array [0 .. nStat - 1, 0 .. nPl - 1] of ^TChart; … … 144 151 SavedTiles { , SavedResourceWeights } : array [0 .. ncmax - 1] of Cardinal; 145 152 SavedData: array [0 .. nPl - 1] of pointer; 146 LogFileName, SavePath, { name of file for saving the current game } 147 MapFileName, // name of map to use, empty for random 153 LogFileName: string; 154 SavePath: string; { name of file for saving the current game } 155 MapFileName: string; // name of map to use, empty for random 148 156 AICredits: string; 149 157 AIInfo: array [0 .. nPl - 1] of string; … … 151 159 LastClientTime: TDateTime; 152 160 {$IFOPT O-}HandoverStack: array [0 .. 31] of Cardinal; {$ENDIF} 153 AutoSaveExists, LoadOK, WinOnAlone, PreviewElevation, MovieStopped: boolean; 161 AutoSaveExists: Boolean; 162 LoadOK: Boolean; 163 WinOnAlone: Boolean; 164 PreviewElevation: Boolean; 165 MovieStopped: Boolean; 154 166 155 167 const … … 204 216 BasePath: string; 205 217 NewBrain: TBrain; 218 I: Integer; 206 219 begin 207 220 Notify := NotifyFunction; 208 221 PreviewElevation := false; 222 PlayersBrain := TBrains.Create(False); 223 PlayersBrain.Count := nPl; 224 for I := 0 to nPl - 1 do 225 PlayersBrain[I] := nil; 209 226 210 227 { get available brains } … … 264 281 FreeLibrary(hm); 265 282 end; 283 PlayersBrain.Free; 266 284 Brains.Free; 267 285 end; … … 650 668 else 651 669 begin 652 if Brains[bixView[i]].Kind in [btRandom, btAI] then670 if PlayersBrain[i].Kind in [btRandom, btAI] then 653 671 s := Brains[bix[i]].FileName 654 672 else 655 s := Brains[bixView[i]].FileName;673 s := PlayersBrain[i].FileName; 656 674 move(zero, s[Length(s) + 1], 4); 657 675 LogFile.write(s, (Length(s) div 4 + 1) * 4); … … 685 703 begin 686 704 for p1 := 0 to nPl - 1 do begin 687 if (bixView[p1] <> -1) and (Brains[bixView[p1]].Kind = btSuperVirtual) then705 if Assigned(PlayersBrain[p1]) and (PlayersBrain[p1].Kind = btSuperVirtual) then 688 706 bix[p1] := Brains.IndexOf(BrainTerm) // supervisor and local human use same module 689 else if (bixView[p1] <> -1) and (Brains[bixView[p1]].Kind = btRandom) then707 else if Assigned(PlayersBrain[p1]) and (PlayersBrain[p1].Kind = btRandom) then 690 708 if Brains.GetKindCount(btAI) = 0 then 691 709 bix[p1] := -1 692 710 else begin 693 711 AIBrains := TBrains.Create(False); 712 Brains.GetByKind(btAI, AIBrains); 694 713 bix[p1] := Brains.IndexOf(AIBrains[DelphiRandom(AIBrains.Count)]); 695 714 AIBrains.Free; 696 715 end 697 716 else 698 bix[p1] := bixView[p1];699 if bixView[p1] < 0then717 bix[p1] := Brains.IndexOf(PlayersBrain[p1]); 718 if not Assigned(PlayersBrain[p1]) then 700 719 Difficulty[p1] := -1; 701 720 end; … … 1086 1105 MovieMode: boolean): boolean; 1087 1106 var 1088 i, j, ix, d, p1, Command, Subject: integer; 1107 j: TBrain; 1108 i, ix, d, p1, Command, Subject: integer; 1089 1109 {$IFDEF TEXTLOG}LoadPos0: integer; {$ENDIF} 1090 1110 Data: pointer; … … 1124 1144 LogFile.read(s[0], 4); 1125 1145 if s[0] = #0 then 1126 bixView[p1] := -11146 PlayersBrain[p1] := nil 1127 1147 else 1128 1148 begin … … 1131 1151 LogFile.read(d, 4); { behavior } 1132 1152 LogFile.read(Difficulty[p1], 4); 1133 j := Brains. Count - 1;1134 while (j >= 0) and (AnsiCompareFileName(Brains[j].FileName, s) <> 0) do1135 dec(j);1136 if j < 0then1153 j := Brains.Last; 1154 while Assigned(J) and (AnsiCompareFileName(j.FileName, s) <> 0) do 1155 J := PlayersBrain[PlayersBrain.IndexOf(J) - 1]; 1156 if not Assigned(j) then 1137 1157 begin // ai not found -- replace by local player 1138 1158 ProcessClientData[p1] := false; 1139 1159 NotifyMessage := s; 1140 1160 Notify(ntAIError); 1141 j := Brain s.IndexOf(BrainTerm);1161 j := BrainTerm; 1142 1162 end 1143 1163 else 1144 1164 ProcessClientData[p1] := true; 1145 if Brains[j].Kind = btNoTerm then1146 j := Brain s.IndexOf(BrainSuperVirtual);1165 if j.Kind = btNoTerm then 1166 j := BrainSuperVirtual; 1147 1167 // crashed tournament -- load as supervisor 1148 bixView[p1] := j;1168 PlayersBrain[p1] := j; 1149 1169 end; 1150 1170 end;
Note:
See TracChangeset
for help on using the changeset viewer.