- Added AnimDataProvider

- Some code cleanups
This commit is contained in:
Andreas Schneider 2009-12-08 20:22:45 +01:00
parent 392bd3db14
commit 06c9c2c507
7 changed files with 565 additions and 406 deletions

View File

@ -56,7 +56,7 @@
<MinVersion Major="4" Minor="5" Release="1" Valid="True"/> <MinVersion Major="4" Minor="5" Release="1" Valid="True"/>
</Item5> </Item5>
</RequiredPackages> </RequiredPackages>
<Units Count="36"> <Units Count="40">
<Unit0> <Unit0>
<Filename Value="CentrED.lpr"/> <Filename Value="CentrED.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -278,6 +278,26 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="UGLFont"/> <UnitName Value="UGLFont"/>
</Unit35> </Unit35>
<Unit36>
<Filename Value="../UOLib/UAnimData.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UAnimData"/>
</Unit36>
<Unit37>
<Filename Value="../MulProvider/UTileDataProvider.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UTileDataProvider"/>
</Unit37>
<Unit38>
<Filename Value="../MulProvider/UAnimDataProvider.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UAnimDataProvider"/>
</Unit38>
<Unit39>
<Filename Value="../MulProvider/UMulManager.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UMulManager"/>
</Unit39>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -40,7 +40,8 @@ uses
UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter, UfrmTileInfo, UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter, UfrmTileInfo,
UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets, UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets,
UPacketHandlers, UAdminHandling, UGameResources, ULandscape, UfrmToolWindow, UPacketHandlers, UAdminHandling, UGameResources, ULandscape, UfrmToolWindow,
Logging, UMap, UWorldItem, UStatics, UTiledata, UGLFont; Logging, UTileDataProvider, UMap, UWorldItem, UStatics, UTiledata, UAnimData,
UGLFont, UAnimDataProvider, UMulManager;
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF} {$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}

View File

@ -0,0 +1,104 @@
(*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2009 Andreas Schneider
*)
unit UAnimDataProvider;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, UMulProvider, UMulBlock, UAnimData;
type
TAnimDataArray = array[$0..$3FFF] of TAnimData;
{ TAnimDataProvider }
TAnimDataProvider = class(TMulProvider)
constructor Create(AData: TStream; AReadOnly: Boolean = False); overload;
override;
constructor Create(AData: string; AReadOnly: Boolean = False); overload;
override;
destructor Destroy; override;
protected
FAnimData: TAnimDataArray;
function CalculateOffset(AID: Integer): Integer; override;
function GetData(AID, AOffset: Integer): TAnimData; override;
procedure SetData(AID, AOffset: Integer; ABlock: TMulBlock); override;
public
property AnimData: TAnimDataArray read FAnimData;
function GetBlock(AID: Integer): TAnimData; override;
end;
implementation
{ TAnimDataProvider }
constructor TAnimDataProvider.Create(AData: TStream; AReadOnly: Boolean);
begin
inherited Create(AData, AReadOnly);
end;
constructor TAnimDataProvider.Create(AData: string; AReadOnly: Boolean);
begin
inherited Create(AData, AReadOnly);
end;
destructor TAnimDataProvider.Destroy;
begin
inherited Destroy;
end;
function TAnimDataProvider.CalculateOffset(AID: Integer): Integer;
begin
Result := GetAnimDataOffset(AID);
end;
function TAnimDataProvider.GetData(AID, AOffset: Integer): TAnimData;
begin
Result := FAnimData[AID];
end;
procedure TAnimDataProvider.SetData(AID, AOffset: Integer; ABlock: TMulBlock);
begin
FreeAndNil(FAnimData[AID]);
FAnimData[AID] := TAnimData(ABlock.Clone);
if not FReadOnly then
begin
FData.Position := AOffset;
ABlock.Write(FData);
end;
end;
function TAnimDataProvider.GetBlock(AID: Integer): TAnimData;
begin
Result := FAnimData[AID].Clone;
end;
end.

View File

@ -1,111 +1,129 @@
(* (*
* CDDL HEADER START * CDDL HEADER START
* *
* The contents of this file are subject to the terms of the * The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only * Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance * (the "License"). You may not use this file except in compliance
* with the License. * with the License.
* *
* You can obtain a copy of the license at * You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php. * http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions * See the License for the specific language governing permissions
* and limitations under the License. * and limitations under the License.
* *
* When distributing Covered Code, include this CDDL HEADER in each * When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at * file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable, * http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed * add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information: * by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner] * Portions Copyright [yyyy] [name of copyright owner]
* *
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2009 Andreas Schneider
*) *)
unit UMulManager; unit UMulManager;
interface interface
uses uses
SysUtils, UMulProvider, UTileDataProvider, UArtProvider, UGumpProvider, SysUtils, UMulProvider, UTileDataProvider, UArtProvider, UGumpProvider,
UTexmapProvider, UHueProvider, URadarProvider; UTexmapProvider, UHueProvider, URadarProvider, UAnimDataProvider;
type type
TMulManager = class(TObject)
destructor Destroy; override; { TMulManager }
protected
FArtProvider: TArtProvider; TMulManager = class
FGumpProvider: TGumpProvider; destructor Destroy; override;
FTexmapProvider: TTexmapProvider; protected
FTileDataProvider: TTileDataProvider; FArtProvider: TArtProvider;
FHueProvider: THueProvider; FGumpProvider: TGumpProvider;
FRadarProvider: TRadarProvider; FTexmapProvider: TTexmapProvider;
public FTileDataProvider: TTileDataProvider;
procedure RegisterArtProvider(AArtProvider: TArtProvider); FAnimDataProvider: TAnimDataProvider;
procedure RegisterGumpProvider(AGumpProvider: TGumpProvider); FHueProvider: THueProvider;
procedure RegisterTexmapProvider(ATexmapProvider: TTexmapProvider); FRadarProvider: TRadarProvider;
procedure RegisterTileDataProvider(ATileDataProvider: TTileDataProvider); public
procedure RegisterHueProvider(AHueProvider: THueProvider); procedure RegisterArtProvider(AArtProvider: TArtProvider);
procedure RegisterRadarProvider(ARadarProvider: TRadarProvider); procedure RegisterGumpProvider(AGumpProvider: TGumpProvider);
property ArtProvider: TArtProvider read FArtProvider; procedure RegisterTexmapProvider(ATexmapProvider: TTexmapProvider);
property GumpProvider: TGumpProvider read FGumpProvider; procedure RegisterTileDataProvider(ATileDataProvider: TTileDataProvider);
property TexmapProvider: TTexmapProvider read FTexmapProvider; procedure RegisterAnimDataProvider(AAnimDataProvider: TAnimDataProvider);
property TileDataProvider: TTileDataProvider read FTileDataProvider; procedure RegisterHueProvider(AHueProvider: THueProvider);
property HueProvider: THueProvider read FHueProvider; procedure RegisterRadarProvider(ARadarProvider: TRadarProvider);
property RadarProvider: TRadarPRovider read FRadarProvider; property ArtProvider: TArtProvider read FArtProvider;
end; property GumpProvider: TGumpProvider read FGumpProvider;
property TexmapProvider: TTexmapProvider read FTexmapProvider;
implementation property TileDataProvider: TTileDataProvider read FTileDataProvider;
property AnimDataProvider: TAnimDataProvider read FAnimDataProvider;
{ TMulManager } property HueProvider: THueProvider read FHueProvider;
property RadarProvider: TRadarPRovider read FRadarProvider;
destructor TMulManager.Destroy; end;
begin
RegisterArtProvider(nil); implementation
RegisterGumpProvider(nil);
RegisterTexmapProvider(nil); { TMulManager }
RegisterTileDataProvider(nil);
RegisterHueProvider(nil); destructor TMulManager.Destroy;
RegisterRadarProvider(nil); begin
inherited; RegisterArtProvider(nil);
end; RegisterGumpProvider(nil);
RegisterTexmapProvider(nil);
procedure TMulManager.RegisterArtProvider(AArtProvider: TArtProvider); RegisterTileDataProvider(nil);
begin RegisterHueProvider(nil);
if Assigned(FArtProvider) then FreeAndNil(FArtProvider); RegisterRadarProvider(nil);
FArtProvider := AArtProvider; inherited Destroy;
end; end;
procedure TMulManager.RegisterGumpProvider(AGumpProvider: TGumpProvider); procedure TMulManager.RegisterArtProvider(
begin AArtProvider: TArtProvider);
if Assigned(FGumpProvider) then FreeAndNil(FGumpProvider); begin
FGumpProvider := AGumpProvider; FreeAndNil(FArtProvider);
end; FArtProvider := AArtProvider;
end;
procedure TMulManager.RegisterHueProvider(AHueProvider: THueProvider);
begin procedure TMulManager.RegisterGumpProvider(
if Assigned(FHueProvider) then FreeAndNil(FHueProvider); AGumpProvider: TGumpProvider);
FHueProvider := AHueProvider; begin
end; FreeAndNil(FGumpProvider);
FGumpProvider := AGumpProvider;
procedure TMulManager.RegisterRadarProvider(ARadarProvider: TRadarProvider); end;
begin
if Assigned(FRadarProvider) then FreeAndNil(FRadarProvider); procedure TMulManager.RegisterHueProvider(
FRadarProvider := ARadarProvider; AHueProvider: THueProvider);
end; begin
FreeAndNil(FHueProvider);
procedure TMulManager.RegisterTexmapProvider(ATexmapProvider: TTexmapProvider); FHueProvider := AHueProvider;
begin end;
if Assigned(FTexmapProvider) then FreeAndNil(FTexmapProvider);
FTexmapProvider := ATexmapProvider; procedure TMulManager.RegisterRadarProvider(
end; ARadarProvider: TRadarProvider);
begin
procedure TMulManager.RegisterTileDataProvider( FreeAndNil(FRadarProvider);
ATileDataProvider: TTileDataProvider); FRadarProvider := ARadarProvider;
begin end;
if Assigned(FTileDataProvider) then FreeAndNil(FTileDataProvider);
FTileDataProvider := ATileDataProvider; procedure TMulManager.RegisterTexmapProvider(
end; ATexmapProvider: TTexmapProvider);
begin
end. FreeAndNil(FTexmapProvider);
FTexmapProvider := ATexmapProvider;
end;
procedure TMulManager.RegisterTileDataProvider(
ATileDataProvider: TTileDataProvider);
begin
FreeAndNil(FTileDataProvider);
FTileDataProvider := ATileDataProvider;
end;
procedure TMulManager.RegisterAnimDataProvider(
AAnimDataProvider: TAnimDataProvider);
begin
FreeAndNil(FAnimDataProvider);
FTileDataProvider := AAnimDataProvider;
end;
end.

View File

@ -1,143 +1,143 @@
(* (*
* CDDL HEADER START * CDDL HEADER START
* *
* The contents of this file are subject to the terms of the * The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only * Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance * (the "License"). You may not use this file except in compliance
* with the License. * with the License.
* *
* You can obtain a copy of the license at * You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php. * http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions * See the License for the specific language governing permissions
* and limitations under the License. * and limitations under the License.
* *
* When distributing Covered Code, include this CDDL HEADER in each * When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at * file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable, * http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed * add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information: * by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner] * Portions Copyright [yyyy] [name of copyright owner]
* *
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2009 Andreas Schneider
*) *)
unit UTileDataProvider; unit UTileDataProvider;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
SysUtils, Classes, UMulProvider, UMulBlock, UTiledata; SysUtils, Classes, UMulProvider, UMulBlock, UTiledata;
type type
TLandTileDataArray = array[$0..$3FFF] of TLandTileData; TLandTileDataArray = array[$0..$3FFF] of TLandTileData;
TStaticTileDataArray = array[$0..$3FFF] of TStaticTileData; TStaticTileDataArray = array[$0..$3FFF] of TStaticTileData;
TTiledataProvider = class(TMulProvider) TTiledataProvider = class(TMulProvider)
constructor Create(AData: TStream; AReadOnly: Boolean = False); overload; override; constructor Create(AData: TStream; AReadOnly: Boolean = False); overload; override;
constructor Create(AData: string; AReadOnly: Boolean = False); overload; override; constructor Create(AData: string; AReadOnly: Boolean = False); overload; override;
destructor Destroy; override; destructor Destroy; override;
protected protected
FLandTiles: TLandTileDataArray; FLandTiles: TLandTileDataArray;
FStaticTiles: TStaticTileDataArray; FStaticTiles: TStaticTileDataArray;
procedure InitArray; procedure InitArray;
function CalculateOffset(AID: Integer): Integer; override; function CalculateOffset(AID: Integer): Integer; override;
function GetData(AID, AOffset: Integer): TMulBlock; override; function GetData(AID, AOffset: Integer): TMulBlock; override;
procedure SetData(AID, AOffset: Integer; ABlock: TMulBlock); override; procedure SetData(AID, AOffset: Integer; ABlock: TMulBlock); override;
public public
function GetBlock(AID: Integer): TMulBlock; override; function GetBlock(AID: Integer): TMulBlock; override;
property LandTiles: TLandTileDataArray read FLandTiles; property LandTiles: TLandTileDataArray read FLandTiles;
property StaticTiles: TStaticTileDataArray read FStaticTiles; property StaticTiles: TStaticTileDataArray read FStaticTiles;
end; end;
implementation implementation
{ TTiledataProvider } { TTiledataProvider }
function TTiledataProvider.CalculateOffset(AID: Integer): Integer; function TTiledataProvider.CalculateOffset(AID: Integer): Integer;
begin begin
Result := GetTileDataOffset(AID); Result := GetTileDataOffset(AID);
end; end;
constructor TTiledataProvider.Create(AData: TStream; AReadOnly: Boolean = False); constructor TTiledataProvider.Create(AData: TStream; AReadOnly: Boolean = False);
begin begin
inherited; inherited;
InitArray; InitArray;
end; end;
constructor TTiledataProvider.Create(AData: string; AReadOnly: Boolean = False); constructor TTiledataProvider.Create(AData: string; AReadOnly: Boolean = False);
begin begin
inherited; inherited;
InitArray; InitArray;
end; end;
destructor TTiledataProvider.Destroy; destructor TTiledataProvider.Destroy;
var var
i: Integer; i: Integer;
begin begin
for i := $0 to $3FFF do for i := $0 to $3FFF do
begin begin
if Assigned(FLandTiles[i]) then FreeAndNil(FLandTiles[i]); FreeAndNil(FLandTiles[i]);
if Assigned(FStaticTiles[i]) then FreeAndNil(FStaticTiles[i]); FreeAndNil(FStaticTiles[i]);
end; end;
inherited; inherited;
end; end;
function TTiledataProvider.GetBlock(AID: Integer): TMulBlock; function TTiledataProvider.GetBlock(AID: Integer): TMulBlock;
begin begin
Result := GetData(AID, 0); Result := GetData(AID, 0);
end; end;
function TTiledataProvider.GetData(AID, AOffset: Integer): TMulBlock; function TTiledataProvider.GetData(AID, AOffset: Integer): TMulBlock;
begin begin
if AID < $4000 then if AID < $4000 then
Result := TMulBlock(FLandTiles[AID].Clone) Result := TMulBlock(FLandTiles[AID].Clone)
else else
Result := TMulBlock(FStaticTiles[AID - $4000].Clone); Result := TMulBlock(FStaticTiles[AID - $4000].Clone);
Result.ID := AID; Result.ID := AID;
Result.OnChanged := @OnChanged; Result.OnChanged := @OnChanged;
Result.OnFinished := @OnFinished; Result.OnFinished := @OnFinished;
end; end;
procedure TTiledataProvider.InitArray; procedure TTiledataProvider.InitArray;
var var
i: Integer; i: Integer;
begin begin
for i := $0 to $3FFF do for i := $0 to $3FFF do
begin begin
FData.Position := GetTileDataOffset(i); FData.Position := GetTileDataOffset(i);
FLandTiles[i] := TLandTileData.Create(FData); FLandTiles[i] := TLandTileData.Create(FData);
end; end;
for i := $0 to $3FFF do for i := $0 to $3FFF do
begin begin
FData.Position := GetTileDataOffset($4000 + i); FData.Position := GetTileDataOffset($4000 + i);
FStaticTiles[i] := TStaticTileData.Create(FData); FStaticTiles[i] := TStaticTileData.Create(FData);
end; end;
end; end;
procedure TTiledataProvider.SetData(AID, AOffset: Integer; procedure TTiledataProvider.SetData(AID, AOffset: Integer;
ABlock: TMulBlock); ABlock: TMulBlock);
begin begin
if AID < $4000 then if AID < $4000 then
begin begin
if Assigned(FLandTiles[AID]) then FreeAndNil(FLandTiles[AID]); FreeAndNil(FLandTiles[AID]);
FLandTiles[AID] := TLandTileData(ABlock.Clone); FLandTiles[AID] := TLandTileData(ABlock.Clone);
end else end else
begin begin
if Assigned(FStaticTiles[AID - $4000]) then FreeAndNil(FStaticTiles[AID - $4000]); FreeAndNil(FStaticTiles[AID - $4000]);
FStaticTiles[AID - $4000] := TStaticTileData(ABlock.Clone); FStaticTiles[AID - $4000] := TStaticTileData(ABlock.Clone);
end; end;
if not FReadOnly then if not FReadOnly then
begin begin
FData.Position := AOffset; FData.Position := AOffset;
ABlock.Write(FData); ABlock.Write(FData);
end; end;
end; end;
end. end.

View File

@ -1,149 +1,164 @@
(* (*
* CDDL HEADER START * CDDL HEADER START
* *
* The contents of this file are subject to the terms of the * The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only * Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance * (the "License"). You may not use this file except in compliance
* with the License. * with the License.
* *
* You can obtain a copy of the license at * You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php. * http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions * See the License for the specific language governing permissions
* and limitations under the License. * and limitations under the License.
* *
* When distributing Covered Code, include this CDDL HEADER in each * When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at * file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable, * http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed * add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information: * by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner] * Portions Copyright [yyyy] [name of copyright owner]
* *
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2009 Andreas Schneider
*) *)
unit UAnimData; unit UAnimData;
interface interface
uses uses
Classes, UMulBlock; Classes, UMulBlock;
const const
AnimDataSize = 68; AnimDataSize = 68;
AnimDataGroupSize = 4 + (8 * AnimDataSize); AnimDataGroupSize = 4 + (8 * AnimDataSize);
type type
TAnimData = class(TMulBlock)
constructor Create(Data: TStream); { TAnimData }
function GetSize: Integer; override;
procedure Write(Data: TStream); override; TAnimData = class(TMulBlock)
private constructor Create(AData: TStream);
FOffset: Int64; function GetSize: Integer; override;
FUnknown: Byte; procedure Write(AData: TStream); override;
FFrameCount: Byte; function Clone: TAnimData; override;
FFrameInterval: Byte; protected
FFrameStart: Byte; FUnknown: Byte;
public FFrameCount: Byte;
FrameData: array[0..63] of ShortInt; FFrameInterval: Byte;
published FFrameStart: Byte;
property Offset: Int64 read FOffset write FOffset; public
property Unknown: Byte read FUnknown write FUnknown; FrameData: array[0..63] of Byte;
property FrameCount: Byte read FFrameCount write FFrameCount; property Unknown: Byte read FUnknown write FUnknown;
property FrameInterval: Byte read FFrameInterval write FFrameInterval; property FrameCount: Byte read FFrameCount write FFrameCount;
property FrameStart: Byte read FFrameStart write FFrameStart; property FrameInterval: Byte read FFrameInterval write FFrameInterval;
end; property FrameStart: Byte read FFrameStart write FFrameStart;
TAnimDataGroup = class(TMulBlock) end;
constructor Create(Data: TStream);
destructor Destroy; override; { TAnimDataGroup }
function GetSize: Integer; override;
procedure Write(Data: TStream); override; TAnimDataGroup = class(TMulBlock)
private constructor Create(AData: TStream);
FOffset: Int64; destructor Destroy; override;
FUnknown: LongInt; function GetSize: Integer; override;
public procedure Write(AData: TStream); override;
AnimData: array[0..7] of TAnimData; protected
published FUnknown: LongInt;
property Offset: Int64 read FOffset write FOffset; AnimData: array[0..7] of TAnimData;
property Unknown: LongInt read FUnknown write FUnknown; property Unknown: LongInt read FUnknown write FUnknown;
end; end;
function GetAnimDataOffset(Block: Integer): Integer; function GetAnimDataOffset(Block: Integer): Integer;
implementation implementation
function GetAnimDataOffset; function GetAnimDataOffset(Block: Integer): Integer;
var var
group, tile: Integer; group, tile: Integer;
begin begin
group := Block div 8; group := Block div 8;
tile := Block mod 8; tile := Block mod 8;
Result := group * AnimDataGroupSize + 4 + tile * AnimDataSize; Result := group * AnimDataGroupSize + 4 + tile * AnimDataSize;
end; end;
constructor TAnimData.Create; { TAnimData }
begin
if assigned(Data) then constructor TAnimData.Create(AData: TStream);
begin begin
FOffset := Data.Position; if AData <> nil then
Data.Read(FrameData, 64); begin
Data.Read(FUnknown, SizeOf(Byte)); AData.Read(FrameData, SizeOf(FrameData[0]) * Length(FrameData));
Data.Read(FFrameCount, SizeOf(Byte)); AData.Read(FUnknown, SizeOf(FUnknown));
Data.Read(FFrameInterval, SizeOf(Byte)); AData.Read(FFrameCount, SizeOf(FFrameCount));
Data.Read(FFrameStart, SizeOf(Byte)); AData.Read(FFrameInterval, SizeOf(FFrameInterval));
end; AData.Read(FFrameStart, SizeOf(FFrameStart));
end; end;
end;
procedure TAnimData.Write;
begin procedure TAnimData.Write(AData: TStream);
Data.Write(FrameData, 64); begin
Data.Write(FUnknown, SizeOf(Byte)); AData.Write(FrameData, SizeOf(FrameData[0]) * Length(FrameData));
Data.Write(FFrameCount, SizeOf(Byte)); AData.Write(FUnknown, SizeOf(FUnknown));
Data.Write(FFrameInterval, SizeOf(Byte)); AData.Write(FFrameCount, SizeOf(FFrameCount));
Data.Write(FFrameStart, SizeOf(Byte)); AData.Write(FFrameInterval, SizeOf(FFrameInterval));
end; AData.Write(FFrameStart, SizeOf(FFrameStart));
end;
function TAnimData.GetSize;
begin function TAnimData.Clone: TAnimData;
GetSize := AnimDataSize; var
end; i: Integer;
begin
constructor TAnimDataGroup.Create; Result := TAnimData.Create(nil);
var Result.FUnknown := FUnknown;
i: Integer; Result.FFrameCount := FFrameCount;
begin Result.FFrameInterval := FFrameInterval;
if assigned(Data) then Result.FFrameStart := FFrameStart;
begin for i := 0 to 63 do
FOffset := Data.Position; Result.FrameData[i] := FrameData[i];
Data.Read(FUnknown, SizeOf(LongInt)); end;
end;
for i := 0 to 7 do function TAnimData.GetSize: Integer;
AnimData[i] := TAnimData.Create(Data); begin
end; Result := AnimDataSize;
end;
destructor TAnimDataGroup.Destroy;
var { TAnimDataGroup }
i: Integer;
begin constructor TAnimDataGroup.Create(AData: TStream);
for i := 0 to 7 do var
AnimData[i].Free; i: Integer;
end; begin
if AData <> nil then
procedure TAnimDataGroup.Write; begin
var AData.Read(FUnknown, SizeOf(FUnknown));
i: Integer; end;
begin for i := 0 to 7 do
Data.Write(FUnknown, SizeOf(LongInt)); AnimData[i] := TAnimData.Create(AData);
for i := 0 to 7 do end;
AnimData[i].Write(Data);
end; destructor TAnimDataGroup.Destroy;
var
function TAnimDataGroup.GetSize; i: Integer;
begin begin
GetSize := AnimDataGroupSize; for i := 0 to 7 do
end; AnimData[i].Free;
end;
end.
procedure TAnimDataGroup.Write(AData: TStream);
var
i: Integer;
begin
AData.Write(FUnknown, SizeOf(FUnknown));
for i := 0 to 7 do
AnimData[i].Write(AData);
end;
function TAnimDataGroup.GetSize: Integer;
begin
Result := AnimDataGroupSize;
end;
end.

View File

@ -150,7 +150,8 @@ begin
group := ABlock div 32; group := ABlock div 32;
tile := ABlock mod 32; tile := ABlock mod 32;
Result := 512 * LandTileGroupSize + group * StaticTileGroupSize + 4 + tile * StaticTileDataSize; Result := 512 * LandTileGroupSize + group * StaticTileGroupSize + 4
+ tile * StaticTileDataSize;
end else end else
begin begin
group := ABlock div 32; group := ABlock div 32;