Changeset 661


Ignore:
Timestamp:
Jul 4, 2025, 9:36:29 PM (5 hours ago)
Author:
chronos
Message:
  • Modified: Tribes PictureList changed to generic object list.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Tribes.pas

    r532 r661  
    66uses
    77  Protocol, ScreenTools, LazFileUtils, Classes, SysUtils, Global, GraphicSet,
     8  Generics.Collections,
    89  {$IFDEF DPI}Dpi.Graphics{$ELSE}Graphics{$ENDIF};
    910
     
    8485
    8586type
    86   TChosenModelPictureInfo = record
     87  TChosenModelPictureInfo = class
    8788    Hash: Integer;
    8889    HGr: TGraphicSet;
    8990    pix: Integer;
    90     ModelName: ShortString;
    91   end;
    92 
    93   TPictureList = array [0 .. 99999] of TChosenModelPictureInfo;
     91    ModelName: string;
     92  end;
    9493
    9594var
    9695  StdUnitScript: TStringList;
    97   PictureList: ^TPictureList;
    98   nPictureList: Integer;
     96  PictureList: TObjectList<TChosenModelPictureInfo>;
    9997
    10098procedure Init;
     
    103101  StdUnitScript.LoadFromFile(LocalizedFilePath('Tribes' +
    104102    DirectorySeparator + 'StdUnits.txt'));
    105   nPictureList := 0;
    106   PictureList := nil;
     103  PictureList := TObjectList<TChosenModelPictureInfo>.Create;
    107104end;
    108105
    109106procedure Done;
    110107begin
    111   ReallocMem(PictureList, 0);
     108  FreeAndNil(PictureList);
    112109  FreeAndNil(StdUnitScript);
    113110end;
     
    486483  I: Integer;
    487484  Ok: Boolean;
     485  NewPictureInfo: TChosenModelPictureInfo;
    488486begin
    489487  with Info do
     
    491489    if not IsNew then
    492490    begin
    493       I := nPictureList - 1;
     491      I := PictureList.Count - 1;
    494492      while (I >= 0) and (PictureList[I].Hash <> Info.Hash) do
    495493        Dec(I);
     
    540538      end;
    541539
    542       if Hash <> 0 then
    543       begin
    544         if nPictureList = 0 then
    545           ReallocMem(PictureList, 64 * SizeOf(TChosenModelPictureInfo))
    546         else if (nPictureList >= 64) and (nPictureList and
    547           (nPictureList - 1) = 0) then
    548           ReallocMem(PictureList,
    549             nPictureList * (2 * SizeOf(TChosenModelPictureInfo)));
    550         PictureList[nPictureList].Hash := Info.Hash;
    551         PictureList[nPictureList].HGr := ModelPicture[mix].HGr;
    552         PictureList[nPictureList].pix := Info.pix;
    553         PictureList[nPictureList].ModelName := ModelName[mix];
    554         Inc(nPictureList);
     540      if Hash <> 0 then begin
     541        NewPictureInfo := TChosenModelPictureInfo.Create;
     542        NewPictureInfo.Hash := Info.Hash;
     543        NewPictureInfo.HGr := ModelPicture[mix].HGr;
     544        NewPictureInfo.pix := Info.pix;
     545        NewPictureInfo.ModelName := ModelName[mix];
     546        PictureList.Add(NewPictureInfo);
    555547      end;
    556548    end;
     
    604596  if not ForceNew and (Picture.Hash > 0) then
    605597  begin
    606     for I := 0 to nPictureList - 1 do
     598    for I := 0 to PictureList.Count - 1 do
    607599      if PictureList[I].Hash = Picture.Hash then
    608600      begin
Note: See TracChangeset for help on using the changeset viewer.