Changeset 364


Ignore:
Timestamp:
Apr 12, 2021, 11:55:20 PM (3 years ago)
Author:
chronos
Message:
  • Added: Partial network game play implementation.
  • Modified: Code cleanup.
Location:
trunk
Files:
3 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Direct.pas

    r354 r364  
    4343
    4444uses
    45   ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back, Global;
     45  ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back, Global, UNetworkServer,
     46  UNetworkClient;
    4647
    4748{$R *.lfm}
     
    185186  BrainTerm.Client := LocalPlayer.Client;
    186187  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');
    187192  BrainRandom.Name := Phrases.Lookup('RANDOMAI');
    188193  Canvas.Font.Assign(UniFont[ftNormal]);
  • trunk/GameServer.pas

    r363 r364  
    4949var
    5050  // PARAMETERS
    51   PlayersBrain: TBrains; { brain of the players }
     51  PlayersBrain: TBrains; { brain of the players view }
    5252  Difficulty: array [0 .. nPl - 1] of integer absolute Database.Difficulty;
    5353  { difficulty }
     
    6262  BrainTerm: TBrain;
    6363  BrainRandom: TBrain;
     64  BrainNetworkClient: TBrain;
     65  BrainNetworkServer: TBrain;
    6466
    6567procedure Init(NotifyFunction: TNotifyFunction);
     
    147149{$ELSE}
    148150    try
    149       Brain[bix[p]].Client(Command, p, Data);
     151      bix[p].Client(Command, p, Data);
    150152    except
    151153      Notify(ntException + bix[p]);
     
    199201  BrainNoTerm.FileName := ':AIT';
    200202  BrainNoTerm.Flags := 0;
    201   BrainNoTerm.Initialized := false;
     203  BrainNoTerm.Initialized := False;
    202204  BrainNoTerm.Kind := btNoTerm;
    203205  BrainSuperVirtual := Brains.AddNew;
    204206  BrainSuperVirtual.FileName := ':Supervisor';
    205207  BrainSuperVirtual.Flags := 0;
    206   BrainSuperVirtual.Initialized := false;
     208  BrainSuperVirtual.Initialized := False;
    207209  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;
    208216  BrainTerm := Brains.AddNew;
    209217  BrainTerm.FileName := ':StdIntf';
    210218  BrainTerm.Flags := fMultiple;
    211   BrainTerm.Initialized := false;
     219  BrainTerm.Initialized := False;
    212220  BrainTerm.ServerVersion := Version;
    213221  BrainTerm.Kind := btTerm;
     
    215223  BrainRandom.FileName := ':Random';
    216224  BrainRandom.Flags := fMultiple;
    217   BrainRandom.Initialized := false;
     225  BrainRandom.Initialized := False;
    218226  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;
    219233
    220234  if FindFirst(GetAiDir + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
     
    330344    Notify(ntDeactivationMissing, p);
    331345    ForceClientDeactivation;
    332   end
     346  end;
    333347end;
    334348
     
    23862400      if PModel.Attack = 0 then
    23872401        Flags := Flags and not unBombsLoaded;
    2388       dec(Movement, 100)
     2402      dec(Movement, 100);
    23892403    end
    23902404    else if MoveInfo.MoveType = mtExpel then
     
    23932407      Job := jNone;
    23942408      Flags := Flags and not unFortified;
    2395       dec(Movement, 100)
     2409      dec(Movement, 100);
    23962410    end
    23972411    else
     
    24432457          inc(nUpdateLoc);
    24442458          Flags := Flags or unWithdrawn;
    2445         end
     2459        end;
    24462460      end
    24472461    else if (MoveInfo.MoveType = mtAttack) and (MoveInfo.EndHealthDef > 0) then
     
    24812495              begin
    24822496                UpdateLoc[nUpdateLoc] := Loc;
    2483                 inc(nUpdateLoc)
     2497                inc(nUpdateLoc);
    24842498              end;
    24852499          // unit will be removed -- remember position and update for all players
     
    25292543            CallPlayer(cShowUnitChanged, p1, ExpelToLoc);
    25302544        end;
    2531     end
    2532   end
     2545    end;
     2546  end;
    25332547end; // ExecuteAttack
    25342548
     
    25462560    begin
    25472561      result := eInvalid;
    2548       exit
     2562      exit;
    25492563    end;
    25502564    result := CalculateMove(p, uix, ToLoc, 3 - dy and 1, TestOnly, MoveInfo);
     
    25802594          result := ExecuteMove(p, uix, ToLoc, MoveInfo, ShowMove) or result;
    25812595        mtAttack, mtBombard, mtExpel:
    2582           result := ExecuteAttack(p, uix, ToLoc, MoveInfo, ShowMove) or result
    2583       end;
    2584     end
     2596          result := ExecuteAttack(p, uix, ToLoc, MoveInfo, ShowMove) or result;
     2597      end;
     2598    end;
    25852599  end; // with
    25862600end; { MoveUnit }
     
    26562670      result := ptShip
    26572671    else
    2658       result := ptImp
     2672      result := ptImp;
    26592673  end;
    26602674
     
    26872701  begin
    26882702    result := eUnknown;
    2689     exit
     2703    exit;
    26902704  end;
    26912705
     
    26952709  begin
    26962710    result := eInvalid;
    2697     exit
     2711    exit;
    26982712  end;
    26992713
     
    27052719    PutMessage(1 shl 16 + 1, Format('NOT Alive: %d', [Player]));
    27062720    result := eNoTurn;
    2707     exit
     2721    exit;
    27082722  end;
    27092723
     
    27322746      [Player, Command shr 4]));
    27332747    result := eNoTurn;
    2734     exit
     2748    exit;
    27352749  end;
    27362750
     
    28582872        else
    28592873          result := GetTileInfo(Player, TTileInfo(Data).ExplCity, Subject,
    2860             TTileInfo(Data))
     2874            TTileInfo(Data));
    28612875      end
    28622876      else
     
    28692883          result := eNoPreq
    28702884        else
    2871           result := GetJobProgress(Player, Subject, TJobProgressData(Data))
     2885          result := GetJobProgress(Player, Subject, TJobProgressData(Data));
    28722886      end
    28732887      else
     
    29182932            end;
    29192933            if result = eOK then
    2920               result := eInvalid // no enemy unit there!
     2934              result := eInvalid; // no enemy unit there!
    29212935          end
    29222936          else
     
    29492963          result := eOK
    29502964        else
    2951           result := eNoWay
     2965          result := eNoWay;
    29522966      end;
    29532967
     
    30013015        TCityReport(Data).HypoTax := -1;
    30023016        TCityReport(Data).HypoLux := -1;
    3003         GetCityReport(p1, cix1, TCityReport(Data))
     3017        GetCityReport(p1, cix1, TCityReport(Data));
    30043018      end
    30053019      else
     
    30323046          p1 := 1;
    30333047        SearchCity(Subject, p1, cix1);
    3034         GetCityAreaInfo(p1, Subject, TCityAreaInfo(Data))
     3048        GetCityAreaInfo(p1, Subject, TCityAreaInfo(Data));
    30353049      end
    30363050      else
     
    30963110              LogChanges;
    30973111              SaveGame('~' + LogFileName, true);
    3098             end
     3112            end;
    30993113{$ENDIF}
    31003114          end
     
    31253139          begin
    31263140            if CheckSum <> Subject then
    3127               LoadOK := false
     3141              LoadOK := false;
    31283142          end
    31293143          else // save checksum
     
    31713185            CCCommand := cTurn;
    31723186            CCPlayer := pTurn;
    3173             Notify(ntNextPlayer)
     3187            Notify(ntNextPlayer);
    31743188          end
    31753189          else
     
    32353249            sReload:
    32363250              LoadGame(SavePath, LogFileName, integer(Data), false);
    3237           end
     3251          end;
    32383252        end
    32393253        else
     
    32523266          Notify(ntStartGoRefreshMaps)
    32533267        else
    3254           Notify(ntStartGo)
     3268          Notify(ntStartGo);
    32553269      end
    32563270      else
     
    32923306          assert(Mode = moPlaying);
    32933307          ChangeClientWhenDone(cContinue, pTurn, nil^, 0);
    3294         end
     3308        end;
    32953309      end
    32963310      else
     
    33093323          IntServer(sIntHaveContact, pTurn, pContacted, nil^);
    33103324          ChangeClientWhenDone(scDipStart, pDipActive, nil^, 0);
    3311         end
     3325        end;
    33123326      end
    33133327      else
     
    33683382                    ShowShipChange.Ship2Change[Price[i] shr 16 and 3] :=
    33693383                      +integer(Price[i] and $FFFF);
    3370                   end
     3384                  end;
    33713385                end;
    33723386              if HasShipChanged then
     
    33823396                    if 1 shl p2 and GWatching <> 0 then
    33833397                      CallPlayer(cShowShipChange, p2, ShowShipChange);
    3384                   end
    3385               end
     3398                  end;
     3399              end;
    33863400            end;
    33873401          end
     
    34083422                CallPlayer(cShowCancelTreatyByAlliance, pDipActive, i);
    34093423              end;
    3410           end
     3424          end;
    34113425        end
    34123426        else
     
    34313445            pDipActive := p1;
    34323446            ChangeClientWhenDone(Command, pDipActive, nil^, 0);
    3433           end
     3447          end;
    34343448      end
    34353449      else
     
    34493463            assert(Mode = moPlaying);
    34503464            ChangeClientWhenDone(cContinue, pTurn, nil^, 0);
    3451           end
     3465          end;
    34523466        end
    34533467        else
  • trunk/Global.pas

    r339 r364  
    1212  CevoContact = 'https://' + CevoContactShort;
    1313  CevoContactBug = 'https://app.zdechov.net/c-evo/report/1';
     14  CevoNetworkPort = 41363;
    1415  AppRegistryKey = '\SOFTWARE\C-evo';
    1516  AITemplateManual = 'AI development manual';
  • trunk/Integrated.lpi

    r363 r364  
    3636          <SearchPaths>
    3737            <IncludeFiles Value="LocalPlayer;$(ProjOutDir)"/>
    38             <OtherUnitFiles Value="LocalPlayer"/>
     38            <OtherUnitFiles Value="LocalPlayer;Network"/>
    3939            <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    4040          </SearchPaths>
     
    9595      </Item2>
    9696    </RequiredPackages>
    97     <Units Count="44">
     97    <Units Count="47">
    9898      <Unit0>
    9999        <Filename Value="Integrated.lpr"/>
     
    344344        <IsPartOfProject Value="True"/>
    345345      </Unit43>
     346      <Unit44>
     347        <Filename Value="Network\UNetworkServer.pas"/>
     348        <IsPartOfProject Value="True"/>
     349      </Unit44>
     350      <Unit45>
     351        <Filename Value="Network\UNetworkClient.pas"/>
     352        <IsPartOfProject Value="True"/>
     353      </Unit45>
     354      <Unit46>
     355        <Filename Value="UTCPServer.pas"/>
     356        <IsPartOfProject Value="True"/>
     357      </Unit46>
    346358    </Units>
    347359  </ProjectOptions>
     
    354366    <SearchPaths>
    355367      <IncludeFiles Value="LocalPlayer;$(ProjOutDir)"/>
    356       <OtherUnitFiles Value="LocalPlayer"/>
     368      <OtherUnitFiles Value="LocalPlayer;Network"/>
    357369      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    358370    </SearchPaths>
  • trunk/Integrated.lpr

    r207 r364  
    33
    44uses
     5  {$IFDEF UNIX}
     6  cthreads, clocale,
     7  {$ENDIF}
    58  Forms, Interfaces, SysUtils, Protocol, GameServer, Direct, Start, Messg, Inp,
    69  Back, Log, LocalPlayer, ClientTools, Tribes, IsoEngine, Term, CityScreen, Nego,
  • trunk/Language.txt

    r321 r364  
    405405#UTILIZE Utilize
    406406#INTEGRATE Integrate
     407#NETWORK_SERVER Network Server
     408#NETWORK_CLIENT Network Client
    407409
    408410'Busy Messages
  • trunk/LocalPlayer/LocalPlayer.pas

    r358 r364  
    1616  FormsCreated: boolean;
    1717
    18 procedure Client;
     18procedure Client(Command, Player: integer; var Data);
    1919begin
    2020  if not FormsCreated then
  • trunk/LocalPlayer/Term.pas

    r352 r364  
    29102910        FormResize(nil); // calculate geometrics and paint all
    29112911        SetTroopLoc(-1);
    2912         idle := true
     2912        idle := true;
    29132913      end;
    29142914
     
    29432943              DipMem[me].DeliveredPrices := [];
    29442944              DipMem[me].ReceivedPrices := [];
    2945               DipCall(scDipStart)
     2945              DipCall(scDipStart);
    29462946            end
    29472947            else
    29482948            begin
    29492949              DipCall(scReject);
    2950               EndNego
     2950              EndNego;
    29512951            end;
    29522952          end;
     
    29872987        end;
    29882988        NegoDlg.Start;
    2989         idle := true
     2989        idle := true;
    29902990      end;
    29912991
     
    30393039            CurrentMoveInfo.DoShow := not mAlNoMoves.Checked
    30403040          else
    3041             CurrentMoveInfo.DoShow := not mEnNoMoves.Checked
     3041            CurrentMoveInfo.DoShow := not mEnNoMoves.Checked;
    30423042        end
    30433043        else if Command = cShowUnitChanged then
     
    30513051          else
    30523052            CurrentMoveInfo.DoShow :=
    3053               not(mEnNoMoves.Checked or mEnAttacks.Checked)
     3053              not(mEnNoMoves.Checked or mEnAttacks.Checked);
    30543054        end;
    30553055        // else keep DoShow from cShowMove/cShowAttack
     
    31453145                ShowMoveDomain := Domain;
    31463146                IsAlpine := Cap[mcAlpine] > 0;
    3147               end
    3148             end
     3147              end;
     3148            end;
    31493149          end
    31503150          else
     
    31983198                    CurrentMoveInfo.AfterMovePaintRadius := 2
    31993199                  else
    3200                     CurrentMoveInfo.AfterMovePaintRadius := 1
     3200                    CurrentMoveInfo.AfterMovePaintRadius := 1;
    32013201              end
    32023202              else
     
    32653265          else
    32663266            MapValid := false;
    3267         end
     3267        end;
    32683268      end;
    32693269
     
    33503350          else
    33513351            MapValid := false;
    3352         end
     3352        end;
    33533353      end;
    33543354
     
    33623362          if 3 shl (p1 * 2) and Cardinal(Data) <> 0 then
    33633363            s := s + '\' + Tribe[p1].TPhrase('SHORTNAME');
    3364         SoundMessageEx(s, '')
     3364        SoundMessageEx(s, '');
    33653365      end;
    33663366
  • trunk/Localization/cs/Language.txt

    r321 r364  
    405405#UTILIZE Využít
    406406#INTEGRATE Sloučit
     407#NETWORK_SERVER Síťový server
     408#NETWORK_CLIENT Síťový klient
    407409
    408410'Busy Messages
  • trunk/Localization/de/Language.txt

    r321 r364  
    414414#UTILIZE Anwenden
    415415#INTEGRATE Integrieren
     416#NETWORK_SERVER Network Server
     417#NETWORK_CLIENT Network Client
    416418
    417419'Busy Messages
  • trunk/Localization/it/Language.txt

    r321 r364  
    395395#UTILIZE Ricicla
    396396#INTEGRATE Integra
     397#NETWORK_SERVER Network Server
     398#NETWORK_CLIENT Network Client
    397399
    398400'Busy Messages
  • trunk/Localization/ru/Language.txt

    r321 r364  
    421421#UTILIZE Использовать
    422422#INTEGRATE Внедрить
     423#NETWORK_SERVER Network Server
     424#NETWORK_CLIENT Network Client
    423425
    424426'Сообщения паузы
  • trunk/Localization/zh-Hans/language.txt

    r321 r364  
    413413#UTILIZE ²Î½¨
    414414#INTEGRATE Õû±à
     415#NETWORK_SERVER Network Server
     416#NETWORK_CLIENT Network Client
    415417
    416418'Busy Messages
  • trunk/Localization/zh-Hant/language.txt

    r321 r364  
    413413#UTILIZE °Ñ«Ø
    414414#INTEGRATE ¾ã½s
     415#NETWORK_SERVER Network Server
     416#NETWORK_CLIENT Network Client
    415417
    416418'Busy Messages
  • trunk/NoTerm.pas

    r352 r364  
    99
    1010type
     11  TRunMode = (rmStop, rmStopped, rmRunning, rmQuit);
     12
    1113  TNoTermDlg = class(TDrawDlg)
    1214    QuitBtn: TButtonB;
     
    2022    procedure Client(Command, Player: integer; var Data);
    2123  private
    22     me, Active, ToldAlive, Round: integer;
    23     LastShowYearTime, LastShowTurnChange, LastNewTurn: TDateTime;
    24     TurnTime, TotalStatTime: extended;
     24    Me: Integer;
     25    Active: Integer;
     26    ToldAlive: Integer;
     27    Round: Integer;
     28    LastShowYearTime: TDateTime;
     29    LastShowTurnChange: TDateTime;
     30    LastNewTurn: TDateTime;
     31    TurnTime: Extended;
     32    TotalStatTime: Extended;
    2533    G: TNewGameData;
    2634    Server: TServerCall;
    2735    Shade: TBitmap;
    2836    State: TBitmap;
    29     WinStat, ExtStat, AloneStat: array [0 .. nPl - 1] of integer;
    30     DisallowShowActive: array [0 .. nPl - 1] of boolean;
    31     TimeStat: array [0 .. nPl - 1] of extended;
    32     Mode: (Stop, Stopped, Running, Quit);
     37    WinStat: array [0 .. nPl - 1] of Integer;
     38    ExtStat: array [0 .. nPl - 1] of Integer;
     39    AloneStat: array [0 .. nPl - 1] of Integer;
     40    DisallowShowActive: array [0 .. nPl - 1] of Boolean;
     41    TimeStat: array [0 .. nPl - 1] of Extended;
     42    Mode: TRunMode;
    3343    procedure NewStat;
    3444    procedure EndPlaying;
     
    92102  FillChar(TimeStat, SizeOf(TimeStat), 0);
    93103  TotalStatTime := 0;
    94   Mode := Stop;
     104  Mode := rmStop;
    95105end;
    96106
     
    109119        EndCommand := sResign
    110120      else
    111         EndCommand := sBreak
     121        EndCommand := sBreak;
    112122    end
    113123  else
     
    171181      begin
    172182        inc(Round);
    173         if Mode = Running then
     183        if Mode = rmRunning then
    174184        begin
    175185          Invalidate;
    176           Update
     186          Update;
    177187        end
    178188        else
     
    192202      begin
    193203        LogDlg.List.Clear;
    194         if Mode <> Running then
     204        if Mode <> rmRunning then
    195205        begin
    196206          if LogDlg.Visible then
    197207            LogDlg.Close;
    198208          Close;
    199         end
     209        end;
    200210      end;
    201211
     
    206216        begin
    207217          ShowActive(Active, false);
    208           Active := -1
     218          Active := -1;
    209219        end; // should not happen
    210220
     
    229239        end;
    230240        Application.ProcessMessages;
    231         if Mode = Quit then
     241        if Mode = rmQuit then
    232242          EndPlaying
    233243        else if G.RO[me].Happened and phGameEnd <> 0 then
     
    248258                  inc(WinStat[p]);
    249259              end;
    250           if Mode = Running then
    251             Server(sNextRound, me, 0, nil^)
     260          if Mode = rmRunning then
     261            Server(sNextRound, me, 0, nil^);
    252262        end
    253         else if Mode = Running then
     263        else if Mode = rmRunning then
    254264          Server(sTurn, me, 0, nil^);
    255         if Mode = Stop then
     265        if Mode = rmStop then
    256266        begin
    257267          GoBtn.ButtonIndex := 22;
    258           Mode := Stopped;
     268          Mode := rmStopped;
    259269        end;
    260270      end;
     
    284294procedure TNoTermDlg.GoBtnClick(Sender: TObject);
    285295begin
    286   if Mode = Running then
    287     Mode := Stop
    288   else if Mode = Stopped then
     296  if Mode = rmRunning then
     297    Mode := rmStop
     298  else if Mode = rmStopped then
    289299  begin
    290     Mode := Running;
     300    Mode := rmRunning;
    291301    GoBtn.ButtonIndex := 23;
    292302    GoBtn.Update;
     
    297307procedure TNoTermDlg.QuitBtnClick(Sender: TObject);
    298308begin
    299   if Mode = Stopped then
    300     EndPlaying
    301   else
    302     Mode := Quit;
     309  if Mode = rmStopped then EndPlaying
     310    else Mode := rmQuit;
    303311end;
    304312
     
    362370end;
    363371
    364 procedure Client;
     372procedure Client(Command, Player: integer; var Data);
    365373begin
    366374  if not FormsCreated then
     
    384392initialization
    385393
    386 FormsCreated := false;
     394FormsCreated := False;
    387395
    388396end.
  • trunk/Protocol.pas

    r334 r364  
    12751275  TClientCall = procedure (Command, Player: Integer; var Data); stdcall;
    12761276
     1277  TCommand = (
     1278    cmInitModule = $0000,
     1279    cmReleaseModule = $0100,
     1280    cmBroadcast = $0200,
     1281    cmHelpOnly = $0700,
     1282    cmStartHelp = $0710,
     1283    cmStartCredits = $0720,
     1284
     1285    cmNewGame = $0800,
     1286    cmLoadGame = $0810,
     1287    cmMovie = $0820,
     1288    cmNewGameEx = $0840,
     1289    cmLoadGameEx = $0850,
     1290    cmNewMap = $0880,
     1291    cmReplay = $08E0,
     1292    cmGetReady = $08F0,
     1293    cmBreakGame = $0900,
     1294
     1295    cmTurn = $2000,
     1296    cmResume = $2010,
     1297    cmContinue = $2080,
     1298    cmMovieTurn = $2100,
     1299    cmMovieEndTurn = $2110,
     1300    cmEditMap = $2800,
     1301
     1302    // cShowTileM=$3000;cShowTileA=$3010;cShowFoundCity=$3020;
     1303    cmShowUnitChanged = $3030,
     1304    cmShowAfterMove = $3040,
     1305    cmShowAfterAttack = $3050,
     1306    cmShowCityChanged = $3090,
     1307    // cShowMove=$3100;cShowCapture=$3110;
     1308    // cShowAttackBegin=$3200;cShowAttackWon=$3210;cShowAttackLost=$3220;
     1309    cmShowMoving = $3140,
     1310    cmShowCapturing = $3150,
     1311    cmShowAttacking = $3240,
     1312    cmShowMissionResult = $3300,
     1313    cmShowShipChange = $3400,
     1314    cmShowGreatLibTech = $3500,
     1315    cmShowTurnChange = $3700,
     1316    cmShowCancelTreaty = $3800,
     1317    cmShowEndContact = $3810,
     1318    cmShowCancelTreatyByAlliance = $3820,
     1319    cmShowSupportAllianceAgainst = $3830,
     1320    cmShowPeaceViolation = $3880,
     1321    cmShowGame = $3F00, { cShowSuperView=$3F80; }
     1322    cmRefreshDebugMap = $3F90,
     1323
     1324    // diplomacy commands equal to server, see below
     1325
     1326    cmDebugMessage = $7000,
     1327    cmShowNego = $7010
     1328  );
     1329
    12771330  TUn = packed record
    12781331    Loc: LongInt; { location }
     
    17771830function DelphiRandom: Extended; overload;
    17781831procedure DelphiRandomize;
     1832function GetCommandDataSize(Command: TCommand): Integer;
    17791833
    17801834
     
    19191973end;
    19201974
     1975function GetCommandDataSize(Command: TCommand): Integer;
     1976begin
     1977  case Command of
     1978    cmInitModule: Result := SizeOf(TInitModuleData);
     1979    cmGetReady: Result := 0;
     1980    cmTurn: Result := 0;
     1981    cmShowTurnChange: Result := SizeOf(Integer);
     1982    cmShowNego: Result := SizeOf(TShowNegoData);
     1983    cmNewGame, cmLoadGame, cmMovie, cmNewMap: Result := SizeOf(TNewGameData);
     1984    else begin
     1985      Result := 0;
     1986    end;
     1987  end;
     1988end;
     1989
     1990
    19211991initialization
    19221992
  • trunk/Start.pas

    r363 r364  
    1010
    1111type
     12
     13  { TPlayerSlot }
     14
    1215  TPlayerSlot = class
    1316    DiffUpBtn: TButtonC;
     
    8487    procedure AutoEnemyDownBtnClick(Sender: TObject);
    8588    procedure ReplayBtnClick(Sender: TObject);
    86   public
    87     EmptyPicture: TBitmap;
    88     procedure UpdateFormerGames;
    89     procedure UpdateMaps;
    9089  private
    9190    WorldSize: Integer;
     
    134133    procedure LoadAiBrainsPictures;
    135134    procedure UpdateInterface;
     135    procedure ShowSettings;
     136  public
     137    EmptyPicture: TBitmap;
     138    procedure UpdateFormerGames;
     139    procedure UpdateMaps;
    136140  end;
    137141
     
    492496      (Screen.Height - Height) div 2, Width, Height)
    493497  end;
     498end;
     499
     500procedure TStartDlg.ShowSettings;
     501begin
     502  SettingsDlg := TSettingsDlg.Create(nil);
     503  if SettingsDlg.ShowModal = mrOk then begin
     504    LoadAssets;
     505    Invalidate;
     506    UpdateInterface;
     507    Background.UpdateInterface;
     508  end;
     509  FreeAndNil(SettingsDlg);
    494510end;
    495511
     
    968984
    969985          OpenKey(AppRegistryKey, True);
    970           if AutoDiff > 0 then
    971           begin
    972             WriteString('DefaultAI', BrainDefault.FileName);
    973             SlotAvailable := 0; // PlayerSlot will be invalid hereafter
    974             PlayersBrain[0] := BrainTerm;
    975             Difficulty[0] := PlayerAutoDiff[AutoDiff];
    976             for I := 1 to nPl - 1 do
    977               if (Page = pgStartRandom) and (I <= AutoEnemies) or
    978                 (Page = pgStartMap) and (I < nMapStartPositions) then begin
    979                 if AutoDiff = 1 then PlayersBrain[I] := Brains.GetBeginner
    980                   else PlayersBrain[I] := BrainDefault;
    981                 Difficulty[I] := EnemyAutoDiff[AutoDiff];
    982               end  else PlayersBrain[I] := nil;
    983           end else begin
    984             for I := 6 to 8 do
    985               if (PlayersBrain[0].Kind <> btNoTerm) and (MultiControl and (1 shl I) <> 0)
    986               then begin
    987                 PlayersBrain[I + 3] := PlayersBrain[I];
    988                 Difficulty[I + 3] := Difficulty[I];
    989                 PlayersBrain[I + 6] := PlayersBrain[I];
    990                 Difficulty[I + 6] := Difficulty[I];
    991               end else begin
    992                 PlayersBrain[I + 3] := nil;
    993                 PlayersBrain[I + 6] := nil;
    994               end;
     986          if BrainDefault.Kind <> btNetworkClient then begin
     987            if AutoDiff > 0 then begin
     988              WriteString('DefaultAI', BrainDefault.FileName);
     989              SlotAvailable := 0; // PlayerSlot will be invalid hereafter
     990              PlayersBrain[0] := BrainTerm;
     991              Difficulty[0] := PlayerAutoDiff[AutoDiff];
     992              for I := 1 to nPl - 1 do
     993                if (Page = pgStartRandom) and (I <= AutoEnemies) or
     994                  (Page = pgStartMap) and (I < nMapStartPositions) then begin
     995                  if AutoDiff = 1 then PlayersBrain[I] := Brains.GetBeginner
     996                    else PlayersBrain[I] := BrainDefault;
     997                  Difficulty[I] := EnemyAutoDiff[AutoDiff];
     998                end else PlayersBrain[I] := nil;
     999            end else begin
     1000              for I := 6 to 8 do
     1001                if (PlayersBrain[0].Kind <> btNoTerm) and (MultiControl and (1 shl I) <> 0)
     1002                then begin
     1003                  PlayersBrain[I + 3] := PlayersBrain[I];
     1004                  Difficulty[I + 3] := Difficulty[I];
     1005                  PlayersBrain[I + 6] := PlayersBrain[I];
     1006                  Difficulty[I + 6] := Difficulty[I];
     1007                end else begin
     1008                  PlayersBrain[I + 3] := nil;
     1009                  PlayersBrain[I + 6] := nil;
     1010                end;
     1011            end;
    9951012          end;
    9961013
     
    11621179  AIBrains: TBrains;
    11631180begin
     1181  FixedLines := 0;
    11641182  PlayerPopupIndex := PlayerIndex;
    11651183  EmptyMenu(PopupMenu1.Items);
    11661184  if PlayerPopupIndex < 0 then begin // select default AI
    1167     FixedLines := 0;
     1185    OfferBrain(BrainNetworkClient, FixedLines);
     1186    Inc(FixedLines);
     1187
     1188    MenuItem := TMenuItem.Create(PopupMenu1);
     1189    MenuItem.Caption := '-';
     1190    PopupMenu1.Items.Add(MenuItem);
     1191
     1192    Inc(FixedLines);
    11681193    if Brains.GetKindCount(btAI) >= 2 then begin
    11691194      OfferBrain(BrainRandom, FixedLines);
     
    11771202    FreeAndNil(AIBrains);
    11781203  end else begin
    1179     FixedLines := 0;
    11801204    if PlayerPopupIndex > 0 then begin
    11811205      OfferBrain(nil, FixedLines);
     
    11891213      end;
    11901214    if PlayerPopupIndex > 0 then begin
     1215      OfferBrain(BrainNetworkServer, FixedLines);
     1216      Inc(FixedLines);
     1217
    11911218      MenuItem := TMenuItem.Create(PopupMenu1);
    11921219      MenuItem.Caption := '-';
     
    12671294          begin
    12681295            PlayersBrain[0] := BrainSuperVirtual;
    1269             Difficulty[0] := 0
     1296            Difficulty[0] := 0;
    12701297          end;
    12711298          if PlayersBrain[0].Kind in [btNoTerm, btSuperVirtual] then
     
    14241451    ChangeTab(TStartTab((x - TabOffset) div TabSize));
    14251452  end
    1426   else if Page = pgMain then
    1427   begin
     1453  else if Page = pgMain then begin
    14281454    case SelectedAction of
    1429       maConfig:
    1430         begin
    1431           SettingsDlg := TSettingsDlg.Create(nil);
    1432           if SettingsDlg.ShowModal = mrOk then begin
    1433             LoadAssets;
    1434             Invalidate;
    1435             UpdateInterface;
    1436             Background.UpdateInterface;
    1437           end;
    1438           FreeAndNil(SettingsDlg);
    1439         end;
    1440       maManual:
    1441         DirectHelp(cStartHelp);
    1442       maCredits:
    1443         DirectHelp(cStartCredits);
    1444       maAIDev:
    1445         OpenDocument(HomeDir + AITemplateFileName);
    1446       maWeb:
    1447         OpenURL(CevoHomepage);
     1455      maConfig: ShowSettings;
     1456      maManual: DirectHelp(cStartHelp);
     1457      maCredits: DirectHelp(cStartCredits);
     1458      maAIDev: OpenDocument(HomeDir + AITemplateFileName);
     1459      maWeb: OpenURL(CevoHomepage);
    14481460    end;
    14491461  end
     
    14601472        else
    14611473          PopupMenu1.Popup(left + xBrain[I] + 4, top + yBrain[I] + 4);
    1462       end
     1474      end;
    14631475  end
    14641476  else if (AutoDiff > 1) and ((Page = pgStartRandom) or (Page = pgStartMap)) and
  • trunk/UBrain.pas

    r363 r364  
    1515
    1616type
    17   TBrainType = (btNoTerm, btSuperVirtual, btTerm, btRandom, btAI);
     17  TBrainType = (btNoTerm, btSuperVirtual, btTerm, btRandom, btAI, btNetworkServer,
     18    btNetworkClient);
    1819
    1920  { TBrain }
Note: See TracChangeset for help on using the changeset viewer.