Changeset 319


Ignore:
Timestamp:
Mar 19, 2021, 3:31:53 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Optimized drawing of Wonders window.
  • Modified: Used named constants for Wonders CitiID special cases.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/AI/StdAI/AI.pas

    r289 r319  
    25962596          if (iix >= 0) and (((Imp[iix].Kind in [ikNatLocal, ikNatGlobal]) and
    25972597            (RO.NatBuilt[iix] > 0)) or ((Imp[iix].Kind = ikWonder) and
    2598             (RO.Wonder[iix].CityID <> -1))) then
     2598            (RO.Wonder[iix].CityID <> WonderNotBuiltYet))) then
    25992599            CheckProd := True;
    26002600        end;
  • trunk/AI/StdAI/Barbarina.pas

    r289 r319  
    13281328  for iix := 0 to 27 do
    13291329    if (Imp[iix].Preq <> preNA) and ((Imp[iix].Preq = preNone) or
    1330       IsResearched(Imp[iix].Preq)) and (RO.Wonder[iix].CityID = -1) then
     1330      IsResearched(Imp[iix].Preq)) and (RO.Wonder[iix].CityID = WonderNotBuiltYet) then
    13311331      Inc(WonderAvailable, 1 shl iix);
    13321332  for cix := 0 to RO.nCity - 1 do
     
    15001500              if ((RO.Government <> gDespotism) or (RO.nUn >= RO.nCity * 4)) and
    15011501                not IsResearched(adMassProduction) and (Built[imPalace] > 0) and
    1502                 (RO.Wonder[woZeus].CityID = -1) and City_Improvable(cix, woZeus) then
     1502                (RO.Wonder[woZeus].CityID = WonderNotBuiltYet) and City_Improvable(cix, woZeus) then
    15031503                City_StartImprovement(cix, woZeus)
    15041504              else if (City_CurrentImprovementProject(cix) >= 0) and
  • trunk/AI/StdAI/Protocol.pas

    r289 r319  
    12651265mcHospital = mcSupplyShip;
    12661266
     1267// Wonders CityID constants
     1268WonderNotBuiltYet = -1;
     1269WonderDestroyed = -2;
     1270
    12671271type
    12681272  TServerCall = function (Command, Player, Subject: Integer; var Data)
     
    17681772procedure DelphiRandomize;
    17691773
     1774
    17701775implementation
    17711776
  • trunk/CityProcessing.pas

    r205 r319  
    972972    // check if wonder already built
    973973    if (Project and cpImp <> 0) and (Project and cpIndex < 28) and
    974       (GWonder[Project and cpIndex].CityID <> -1) then
     974      (GWonder[Project and cpIndex].CityID <> WonderNotBuiltYet) then
    975975    begin
    976976      inc(Flags, chOldWonder);
  • trunk/Database.pas

    r290 r319  
    31953195    for i := 0 to 27 do
    31963196      if Built[i] > 0 then
    3197         GWonder[i].CityID := -2; // wonder destroyed
     3197        GWonder[i].CityID := WonderDestroyed;
    31983198    V21_to_Loc(Loc, Radius);
    31993199    for V21 := 1 to 26 do
  • trunk/GameServer.pas

    r290 r319  
    42184218                  result := eInvalid
    42194219                else if (NewProject and cpIndex < 28) and
    4220                   (GWonder[NewProject and cpIndex].CityID <> -1) then
     4220                  (GWonder[NewProject and cpIndex].CityID <> WonderNotBuiltYet) then
    42214221                  result := eViolation // wonder already exists
    42224222                else if (NewProject and cpIndex = imSpacePort) and
  • trunk/LocalPlayer/Term.pas

    r318 r319  
    13621362    need := false;
    13631363    for i := 0 to 27 do
    1364       if MyRO.Wonder[i].CityID <> -1 then
     1364      if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then
    13651365        need := true;
    13661366    if need then
     
    20242024      if MyRO.Wonder[i].CityID <> MyData.ToldWonders[i].CityID then
    20252025      begin
    2026         if MyRO.Wonder[i].CityID = -2 then
     2026        if MyRO.Wonder[i].CityID = WonderDestroyed then
    20272027          with MessgExDlg do
    20282028          begin { tell about destroyed wonders }
     
    20762076      end
    20772077      else if (MyRO.Wonder[i].EffectiveOwner <> MyData.ToldWonders[i]
    2078         .EffectiveOwner) and (MyRO.Wonder[i].CityID > -2) then
     2078        .EffectiveOwner) and (MyRO.Wonder[i].CityID > WonderDestroyed) then
    20792079        if MyRO.Wonder[i].EffectiveOwner < 0 then
    20802080        begin
     
    59075907    begin // city destroyed
    59085908      for i := 0 to 27 do { tell about destroyed wonders }
    5909         if (MyRO.Wonder[i].CityID = -2) and (MyData.ToldWonders[i].CityID <> -2)
     5909        if (MyRO.Wonder[i].CityID = WonderDestroyed) and (MyData.ToldWonders[i].CityID <> WonderDestroyed)
    59105910        then
    59115911          with MessgExDlg do
     
    73167316    mEUnitStat.Enabled := MyRO.nEnemyModel > 0;
    73177317    { mWonders.Enabled:= false;
    7318       for i:=0 to 27 do if MyRO.Wonder[i].CityID<>-1 then
     7318      for i:=0 to 27 do if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then
    73197319      mWonders.Enabled:=true; }
    73207320    mDiagram.Enabled := MyRO.Turn >= 2;
  • trunk/LocalPlayer/Wonders.pas

    r245 r319  
    100100  ax: Integer;
    101101  R: Integer;
    102   I: Integer;
    103102  C: Integer;
    104103  Ch: Integer;
     
    223222  PaintBackgroundShape;
    224223
    225   for I := 0 to 20 do
    226     if Imp[I].Preq <> preNA then
    227     begin
     224  // Draw all bitmaps first
     225  HaveWonder := False;
     226  for I := 0 to 20 do begin
     227    if Imp[I].Preq <> preNA then begin
    228228      case MyRO.Wonder[I].CityID of
    229         - 1: // not built yet
    230           begin
    231             Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3,
    232               Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6,
    233               ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
    234               (hMaintexture - ClientHeight) div 2);
    235             DarkIcon(I);
    236           end;
    237         -2: // destroyed
    238           begin
    239             Glow(I, $000000);
    240           end;
    241       else
    242         begin
    243           if MyRO.Wonder[I].EffectiveOwner >= 0 then
    244             Glow(I, Tribe[MyRO.Wonder[I].EffectiveOwner].Color)
    245           else
    246             Glow(I, $000000);
    247         end;
    248       end;
    249     end;
    250 
    251   HaveWonder := False;
    252   for I := 0 to 20 do
    253     if Imp[I].Preq <> preNA then
    254     begin
    255       case MyRO.Wonder[I].CityID of
    256         -1: // not built yet
    257           begin
    258             Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3,
    259               Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6,
    260               ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
    261               (hMaintexture - ClientHeight) div 2);
    262             DarkIcon(I);
    263           end;
    264         -2: // destroyed
    265           begin
    266             HaveWonder := True;
    267             BitBltCanvas(Offscreen.Canvas,
    268               Center.X - xSizeBig div 2 + RingPosition[I].X,
    269               Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig,
    270               ySizeBig, BigImp.Canvas, 0, (SystemIconLines + 3) *
    271               ySizeBig);
    272           end;
    273       else
    274         begin
     229        WonderNotBuiltYet: begin
     230          Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3,
     231            Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6,
     232            ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
     233            (hMaintexture - ClientHeight) div 2);
     234        end;
     235        WonderDestroyed: begin
     236          HaveWonder := True;
     237          BitBltCanvas(Offscreen.Canvas,
     238            Center.X - xSizeBig div 2 + RingPosition[I].X,
     239            Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig,
     240            ySizeBig, BigImp.Canvas, 0, (SystemIconLines + 3) *
     241            ySizeBig);
     242        end;
     243        else begin
    275244          HaveWonder := True;
    276245          BitBltCanvas(Offscreen.Canvas,
     
    282251      end;
    283252    end;
     253  end;
     254
     255  // Do direct pixel postprocessing separately to avoid bitmap copying in memory
     256  Offscreen.Canvas.FillRect(0, 0, 0, 0);
     257  Offscreen.BeginUpdate;
     258  for I := 0 to 20 do begin
     259    if Imp[I].Preq <> preNA then begin
     260      case MyRO.Wonder[I].CityID of
     261        WonderNotBuiltYet: DarkIcon(I);
     262        WonderDestroyed: Glow(I, $000000);
     263        else begin
     264          if MyRO.Wonder[I].EffectiveOwner >= 0 then
     265            Glow(I, Tribe[MyRO.Wonder[I].EffectiveOwner].Color)
     266          else Glow(I, $000000);
     267        end;
     268      end;
     269    end;
     270  end;
     271  Offscreen.EndUpdate;
    284272
    285273  if not HaveWonder then
     
    323311    if Selection >= 0 then
    324312    begin
    325       if MyRO.Wonder[Selection].CityID = -1 then
     313      if MyRO.Wonder[Selection].CityID = WonderNotBuiltYet then
    326314      begin // not built yet
    327315        { S:=Phrases.Lookup('IMPROVEMENTS',Selection);
     
    338326      begin
    339327        S := Phrases.Lookup('IMPROVEMENTS', Selection);
    340         if MyRO.Wonder[Selection].CityID <> -2 then
     328        if MyRO.Wonder[Selection].CityID <> WonderDestroyed then
    341329          S := Format(Phrases.Lookup('WONDEROF'),
    342330            [S, CityName(MyRO.Wonder[Selection].CityID)]);
     
    344332          (ClientWidth - BiColorTextWidth(Canvas, S)) div 2,
    345333          ClientHeight - 3 - 36 - 10, S);
    346         if MyRO.Wonder[Selection].CityID = -2 then
     334        if MyRO.Wonder[Selection].CityID = WonderDestroyed then
    347335          S := Phrases.Lookup('DESTROYED')
    348336        else if MyRO.Wonder[Selection].EffectiveOwner < 0 then
  • trunk/Protocol.pas

    r187 r319  
    12651265mcHospital = mcSupplyShip;
    12661266
     1267// Wonders CityID constants
     1268WonderNotBuiltYet = -1;
     1269WonderDestroyed = -2;
     1270
    12671271type
    12681272  TServerCall = function (Command, Player, Subject: Integer; var Data)
     
    17681772procedure DelphiRandomize;
    17691773
     1774
    17701775implementation
    17711776
Note: See TracChangeset for help on using the changeset viewer.