Changeset 367 for trunk/GameServer.pas


Ignore:
Timestamp:
Apr 14, 2021, 9:12:03 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Enable in development network game only if NetworkEnabled registry value is activated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GameServer.pas

    r365 r367  
    6464  BrainNetworkClient: TBrain;
    6565  BrainNetworkServer: TBrain;
     66
     67  NetworkEnabled: Boolean;
    6668
    6769procedure Init(NotifyFunction: TNotifyFunction);
     
    157159end;
    158160
     161procedure CallAllPlayers(Command: Integer; var Data);
     162var
     163  I: Integer;
     164begin
     165  for I := 0 to nPl - 1 do
     166    if Assigned(bix[I]) then
     167      CallPlayer(Command, I, Data);
     168end;
     169
    159170procedure CallClient(bix, Command: integer; var Data);
    160171begin
     
    208219  BrainSuperVirtual.Initialized := False;
    209220  BrainSuperVirtual.Kind := btSuperVirtual;
    210   BrainNetworkClient := Brains.AddNew;
    211   BrainNetworkClient.FileName := ':NetworkClient';
    212   BrainNetworkClient.Flags := fMultiple;
    213   BrainNetworkClient.Initialized := False;
    214   BrainNetworkClient.ServerVersion := Version;
    215   BrainNetworkClient.Kind := btNetworkClient;
     221  if NetworkEnabled then begin
     222    BrainNetworkClient := Brains.AddNew;
     223    BrainNetworkClient.FileName := ':NetworkClient';
     224    BrainNetworkClient.Flags := fMultiple;
     225    BrainNetworkClient.Initialized := False;
     226    BrainNetworkClient.ServerVersion := Version;
     227    BrainNetworkClient.Kind := btNetworkClient;
     228  end;
    216229  BrainTerm := Brains.AddNew;
    217230  BrainTerm.FileName := ':StdIntf';
     
    225238  BrainRandom.Initialized := False;
    226239  BrainRandom.Kind := btRandom;
    227   BrainNetworkServer := Brains.AddNew;
    228   BrainNetworkServer.FileName := ':NetworkServer';
    229   BrainNetworkServer.Flags := fMultiple;
    230   BrainNetworkServer.Initialized := False;
    231   BrainNetworkServer.ServerVersion := Version;
    232   BrainNetworkServer.Kind := btNetworkServer;
     240  if NetworkEnabled then begin
     241    BrainNetworkServer := Brains.AddNew;
     242    BrainNetworkServer.FileName := ':NetworkServer';
     243    BrainNetworkServer.Flags := fMultiple;
     244    BrainNetworkServer.Initialized := False;
     245    BrainNetworkServer.ServerVersion := Version;
     246    BrainNetworkServer.Kind := btNetworkServer;
     247  end;
    233248
    234249  if FindFirst(GetAiDir + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
     
    13301345    begin
    13311346      CL.State := FormerCLState;
    1332       Break
    1333     end
     1347      Break;
     1348    end;
    13341349  end;
    13351350{$IFOPT O-}InvalidTreatyMap := 0; {$ENDIF}
     
    13391354  Newlx, Newly, NewLandMass, NewMaxTurn: integer);
    13401355var
    1341   p: integer;
     1356  I: Integer;
    13421357begin
    13431358  Notify(ntStartDone);
     
    13641379  StartGame;
    13651380  NoLogChanges;
    1366   for p := 0 to nPl - 1 do
    1367     if Assigned(bix[p]) then
    1368       CallPlayer(cGetReady, p, nil^);
     1381  CallAllPlayers(cGetReady, nil^);
    13691382  LogChanges;
    13701383  CL.Put(sTurn, 0, 0, nil);
     
    13741387  nLogOpened := -1;
    13751388  LastEndClientCommand := -1;
    1376   bix[0].Client(cShowGame, 0, nil^);
     1389  CallPlayer(cShowGame, 0, nil^);
     1390  for I := 0 to nPl - 1 do
     1391    if Assigned(bix[I]) and (bix[I].Kind = btNetworkServer) then
     1392      CallPlayer(cShowGame, I, nil^);
    13771393  Notify(ntBackOff);
    13781394  Inform(pTurn);
Note: See TracChangeset for help on using the changeset viewer.