Changeset 367 for trunk


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.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Direct.pas

    r364 r367  
    186186  BrainTerm.Client := LocalPlayer.Client;
    187187  BrainTerm.Name := Phrases.Lookup('HUMAN');
    188   BrainNetworkServer.Client := UNetworkServer.Client;
    189   BrainNetworkServer.Name := Phrases.Lookup('NETWORK_SERVER');
    190   BrainNetworkClient.Client := UNetworkClient.Client;
    191   BrainNetworkClient.Name := Phrases.Lookup('NETWORK_CLIENT');
     188  if NetworkEnabled then begin
     189    BrainNetworkServer.Client := UNetworkServer.Client;
     190    BrainNetworkServer.Name := Phrases.Lookup('NETWORK_SERVER');
     191    BrainNetworkClient.Client := UNetworkClient.Client;
     192    BrainNetworkClient.Name := Phrases.Lookup('NETWORK_CLIENT');
     193  end;
    192194  BrainRandom.Name := Phrases.Lookup('RANDOMAI');
    193195  Canvas.Font.Assign(UniFont[ftNormal]);
  • 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);
  • trunk/Network/UNetworkServer.pas

    r365 r367  
    237237  InitModuleData: TInitModuleData;
    238238begin
    239   NewConnection := TNetworkServerConnection.Create;;
     239  NewConnection := TNetworkServerConnection.Create;
    240240  NewConnection.Socket := AStream;
    241241  NewConnection.NetworkServer := Self;
  • trunk/Protocol.pas

    r365 r367  
    19951995    cmShowCancelTreatyByAlliance: Result := SizeOf(Integer);
    19961996    cmShowEndContact: Result := 0;
     1997    cmShowGame: Result := 0;
    19971998    //sIntCancelTreaty: Result := SizeOf(Integer);
    19981999    else begin
  • trunk/Start.pas

    r364 r367  
    360360  I: Integer;
    361361  S: string;
     362  {$IFDEF WINDOWS}
    362363  ResolutionX, ResolutionY, ResolutionBPP, ResolutionFreq: Integer;
     364  {$ENDIF}
    363365  ScreenMode: Integer;
    364366begin
     
    398400    if ValueExists('LastGame') then LastGame := Reg.ReadString('LastGame')
    399401       else LastGame := '';
     402    if ValueExists('NetworkEnabled') then NetworkEnabled := Reg.ReadBool('NetworkEnabled')
     403       else NetworkEnabled := False;
    400404
    401405    if ValueExists('ScreenMode') then
     
    403407      else ScreenMode := 1;
    404408    FullScreen := ScreenMode > 0;
     409    if ValueExists('MultiControl') then
     410      MultiControl := ReadInteger('MultiControl')
     411      else MultiControl := 0;
     412    {$IFDEF WINDOWS}
    405413    if ValueExists('ResolutionX') then
    406414      ResolutionX := ReadInteger('ResolutionX');
     
    411419    if ValueExists('ResolutionFreq') then
    412420      ResolutionFreq := ReadInteger('ResolutionFreq');
    413     if ValueExists('MultiControl') then
    414       MultiControl := ReadInteger('MultiControl')
    415       else MultiControl := 0;
    416     {$IFDEF WINDOWS}
    417421    if ScreenMode = 2 then
    418422      ChangeResolution(ResolutionX, ResolutionY, ResolutionBPP,
     
    440444    WriteInteger('StartTab', Integer(ShowTab));
    441445    WriteString('LastGame', LastGame);
     446    WriteBool('NetworkEnabled', NetworkEnabled);
    442447  finally
    443448    Free;
     
    924929    FormerGames.Delete(I);
    925930    if ListIndex[tbNew] = I then
    926       ListIndex[tbNew] := 0
     931      ListIndex[tbNew] := 0;
    927932  end;
    928933end;
     
    11831188  EmptyMenu(PopupMenu1.Items);
    11841189  if PlayerPopupIndex < 0 then begin // select default AI
    1185     OfferBrain(BrainNetworkClient, FixedLines);
    1186     Inc(FixedLines);
     1190    if NetworkEnabled then begin
     1191      OfferBrain(BrainNetworkClient, FixedLines);
     1192      Inc(FixedLines);
     1193    end;
    11871194
    11881195    MenuItem := TMenuItem.Create(PopupMenu1);
     
    12131220      end;
    12141221    if PlayerPopupIndex > 0 then begin
    1215       OfferBrain(BrainNetworkServer, FixedLines);
    1216       Inc(FixedLines);
     1222      if NetworkEnabled then begin
     1223        OfferBrain(BrainNetworkServer, FixedLines);
     1224        Inc(FixedLines);
     1225      end;
    12171226
    12181227      MenuItem := TMenuItem.Create(PopupMenu1);
Note: See TracChangeset for help on using the changeset viewer.