- Added generic tiledata access to TTileDataProvider (to avoid cloning)

- Fixed TfrmMain.BuildTileList to use that non-cloning tiledata access to remove a memory leak
- Convert the filter text to ISO8859-1 first
This commit is contained in:
Andreas Schneider 2009-12-10 22:18:25 +01:00
parent 34765f7235
commit 908bddda07
2 changed files with 16 additions and 3 deletions

View File

@ -2297,7 +2297,7 @@ var
begin
if cbTerrain.Checked then minID := $0 else minID := $4000;
if cbStatics.Checked then maxID := $7FFF else maxID := $3FFF;
filter := AnsiLowerCase(edFilter.Text);
filter := AnsiLowerCase(UTF8ToISO_8859_1(edFilter.Text));
node := vdtTiles.GetFirstSelected;
if node <> nil then
@ -2314,8 +2314,8 @@ begin
begin
if ResMan.Art.Exists(i) then
begin
if (filter <> '') and (Pos(filter, AnsiLowerCase(TTileData(
ResMan.Tiledata.Block[i]).TileName)) = 0) then Continue;
if (filter <> '') and (Pos(filter, AnsiLowerCase(
ResMan.Tiledata.TileData[i].TileName)) = 0) then Continue;
node := vdtTiles.AddChild(nil);
tileInfo := vdtTiles.GetNodeData(node);
tileInfo^.ID := i;

View File

@ -35,6 +35,9 @@ uses
type
TLandTileDataArray = array[$0..$3FFF] of TLandTileData;
TStaticTileDataArray = array[$0..$3FFF] of TStaticTileData;
{ TTiledataProvider }
TTiledataProvider = class(TMulProvider)
constructor Create(AData: TStream; AReadOnly: Boolean = False); overload; override;
constructor Create(AData: string; AReadOnly: Boolean = False); overload; override;
@ -46,10 +49,12 @@ type
function CalculateOffset(AID: Integer): Integer; override;
function GetData(AID, AOffset: Integer): TMulBlock; override;
procedure SetData(AID, AOffset: Integer; ABlock: TMulBlock); override;
function GetTileData(AID: Integer): TTiledata;
public
function GetBlock(AID: Integer): TMulBlock; override;
property LandTiles: TLandTileDataArray read FLandTiles;
property StaticTiles: TStaticTileDataArray read FStaticTiles;
property TileData[AID: Integer]: TTiledata read GetTileData; //all tiles, no cloning
end;
implementation
@ -139,5 +144,13 @@ begin
end;
end;
function TTiledataProvider.GetTileData(AID: Integer): TTiledata;
begin
if AID < $4000 then
Result := FLandTiles[AID]
else
Result := FStaticTiles[AID - $4000];
end;
end.