Changeset 661 for trunk/LocalPlayer/Tribes.pas
- Timestamp:
- Jul 4, 2025, 9:36:29 PM (9 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Tribes.pas
r532 r661 6 6 uses 7 7 Protocol, ScreenTools, LazFileUtils, Classes, SysUtils, Global, GraphicSet, 8 Generics.Collections, 8 9 {$IFDEF DPI}Dpi.Graphics{$ELSE}Graphics{$ENDIF}; 9 10 … … 84 85 85 86 type 86 TChosenModelPictureInfo = record87 TChosenModelPictureInfo = class 87 88 Hash: Integer; 88 89 HGr: TGraphicSet; 89 90 pix: Integer; 90 ModelName: ShortString; 91 end; 92 93 TPictureList = array [0 .. 99999] of TChosenModelPictureInfo; 91 ModelName: string; 92 end; 94 93 95 94 var 96 95 StdUnitScript: TStringList; 97 PictureList: ^TPictureList; 98 nPictureList: Integer; 96 PictureList: TObjectList<TChosenModelPictureInfo>; 99 97 100 98 procedure Init; … … 103 101 StdUnitScript.LoadFromFile(LocalizedFilePath('Tribes' + 104 102 DirectorySeparator + 'StdUnits.txt')); 105 nPictureList := 0; 106 PictureList := nil; 103 PictureList := TObjectList<TChosenModelPictureInfo>.Create; 107 104 end; 108 105 109 106 procedure Done; 110 107 begin 111 ReallocMem(PictureList, 0);108 FreeAndNil(PictureList); 112 109 FreeAndNil(StdUnitScript); 113 110 end; … … 486 483 I: Integer; 487 484 Ok: Boolean; 485 NewPictureInfo: TChosenModelPictureInfo; 488 486 begin 489 487 with Info do … … 491 489 if not IsNew then 492 490 begin 493 I := nPictureList - 1;491 I := PictureList.Count - 1; 494 492 while (I >= 0) and (PictureList[I].Hash <> Info.Hash) do 495 493 Dec(I); … … 540 538 end; 541 539 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); 555 547 end; 556 548 end; … … 604 596 if not ForceNew and (Picture.Hash > 0) then 605 597 begin 606 for I := 0 to nPictureList - 1 do598 for I := 0 to PictureList.Count - 1 do 607 599 if PictureList[I].Hash = Picture.Hash then 608 600 begin
Note:
See TracChangeset
for help on using the changeset viewer.