Changeset 364 for trunk/GameServer.pas


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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.