parent
392bd3db14
commit
06c9c2c507
|
@ -56,7 +56,7 @@
|
|||
<MinVersion Major="4" Minor="5" Release="1" Valid="True"/>
|
||||
</Item5>
|
||||
</RequiredPackages>
|
||||
<Units Count="36">
|
||||
<Units Count="40">
|
||||
<Unit0>
|
||||
<Filename Value="CentrED.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -278,6 +278,26 @@
|
|||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="UGLFont"/>
|
||||
</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>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -40,7 +40,8 @@ uses
|
|||
UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter, UfrmTileInfo,
|
||||
UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets,
|
||||
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}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2007 Andreas Schneider
|
||||
* Portions Copyright 2009 Andreas Schneider
|
||||
*)
|
||||
unit UMulManager;
|
||||
|
||||
|
@ -29,16 +29,20 @@ interface
|
|||
|
||||
uses
|
||||
SysUtils, UMulProvider, UTileDataProvider, UArtProvider, UGumpProvider,
|
||||
UTexmapProvider, UHueProvider, URadarProvider;
|
||||
UTexmapProvider, UHueProvider, URadarProvider, UAnimDataProvider;
|
||||
|
||||
type
|
||||
TMulManager = class(TObject)
|
||||
|
||||
{ TMulManager }
|
||||
|
||||
TMulManager = class
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FArtProvider: TArtProvider;
|
||||
FGumpProvider: TGumpProvider;
|
||||
FTexmapProvider: TTexmapProvider;
|
||||
FTileDataProvider: TTileDataProvider;
|
||||
FAnimDataProvider: TAnimDataProvider;
|
||||
FHueProvider: THueProvider;
|
||||
FRadarProvider: TRadarProvider;
|
||||
public
|
||||
|
@ -46,12 +50,14 @@ type
|
|||
procedure RegisterGumpProvider(AGumpProvider: TGumpProvider);
|
||||
procedure RegisterTexmapProvider(ATexmapProvider: TTexmapProvider);
|
||||
procedure RegisterTileDataProvider(ATileDataProvider: TTileDataProvider);
|
||||
procedure RegisterAnimDataProvider(AAnimDataProvider: TAnimDataProvider);
|
||||
procedure RegisterHueProvider(AHueProvider: THueProvider);
|
||||
procedure RegisterRadarProvider(ARadarProvider: TRadarProvider);
|
||||
property ArtProvider: TArtProvider read FArtProvider;
|
||||
property GumpProvider: TGumpProvider read FGumpProvider;
|
||||
property TexmapProvider: TTexmapProvider read FTexmapProvider;
|
||||
property TileDataProvider: TTileDataProvider read FTileDataProvider;
|
||||
property AnimDataProvider: TAnimDataProvider read FAnimDataProvider;
|
||||
property HueProvider: THueProvider read FHueProvider;
|
||||
property RadarProvider: TRadarPRovider read FRadarProvider;
|
||||
end;
|
||||
|
@ -68,44 +74,56 @@ begin
|
|||
RegisterTileDataProvider(nil);
|
||||
RegisterHueProvider(nil);
|
||||
RegisterRadarProvider(nil);
|
||||
inherited;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterArtProvider(AArtProvider: TArtProvider);
|
||||
procedure TMulManager.RegisterArtProvider(
|
||||
AArtProvider: TArtProvider);
|
||||
begin
|
||||
if Assigned(FArtProvider) then FreeAndNil(FArtProvider);
|
||||
FreeAndNil(FArtProvider);
|
||||
FArtProvider := AArtProvider;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterGumpProvider(AGumpProvider: TGumpProvider);
|
||||
procedure TMulManager.RegisterGumpProvider(
|
||||
AGumpProvider: TGumpProvider);
|
||||
begin
|
||||
if Assigned(FGumpProvider) then FreeAndNil(FGumpProvider);
|
||||
FreeAndNil(FGumpProvider);
|
||||
FGumpProvider := AGumpProvider;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterHueProvider(AHueProvider: THueProvider);
|
||||
procedure TMulManager.RegisterHueProvider(
|
||||
AHueProvider: THueProvider);
|
||||
begin
|
||||
if Assigned(FHueProvider) then FreeAndNil(FHueProvider);
|
||||
FreeAndNil(FHueProvider);
|
||||
FHueProvider := AHueProvider;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterRadarProvider(ARadarProvider: TRadarProvider);
|
||||
procedure TMulManager.RegisterRadarProvider(
|
||||
ARadarProvider: TRadarProvider);
|
||||
begin
|
||||
if Assigned(FRadarProvider) then FreeAndNil(FRadarProvider);
|
||||
FreeAndNil(FRadarProvider);
|
||||
FRadarProvider := ARadarProvider;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterTexmapProvider(ATexmapProvider: TTexmapProvider);
|
||||
procedure TMulManager.RegisterTexmapProvider(
|
||||
ATexmapProvider: TTexmapProvider);
|
||||
begin
|
||||
if Assigned(FTexmapProvider) then FreeAndNil(FTexmapProvider);
|
||||
FreeAndNil(FTexmapProvider);
|
||||
FTexmapProvider := ATexmapProvider;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterTileDataProvider(
|
||||
ATileDataProvider: TTileDataProvider);
|
||||
begin
|
||||
if Assigned(FTileDataProvider) then FreeAndNil(FTileDataProvider);
|
||||
FreeAndNil(FTileDataProvider);
|
||||
FTileDataProvider := ATileDataProvider;
|
||||
end;
|
||||
|
||||
procedure TMulManager.RegisterAnimDataProvider(
|
||||
AAnimDataProvider: TAnimDataProvider);
|
||||
begin
|
||||
FreeAndNil(FAnimDataProvider);
|
||||
FTileDataProvider := AAnimDataProvider;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2007 Andreas Schneider
|
||||
* Portions Copyright 2009 Andreas Schneider
|
||||
*)
|
||||
unit UTileDataProvider;
|
||||
|
||||
|
@ -79,8 +79,8 @@ var
|
|||
begin
|
||||
for i := $0 to $3FFF do
|
||||
begin
|
||||
if Assigned(FLandTiles[i]) then FreeAndNil(FLandTiles[i]);
|
||||
if Assigned(FStaticTiles[i]) then FreeAndNil(FStaticTiles[i]);
|
||||
FreeAndNil(FLandTiles[i]);
|
||||
FreeAndNil(FStaticTiles[i]);
|
||||
end;
|
||||
|
||||
inherited;
|
||||
|
@ -124,11 +124,11 @@ procedure TTiledataProvider.SetData(AID, AOffset: Integer;
|
|||
begin
|
||||
if AID < $4000 then
|
||||
begin
|
||||
if Assigned(FLandTiles[AID]) then FreeAndNil(FLandTiles[AID]);
|
||||
FreeAndNil(FLandTiles[AID]);
|
||||
FLandTiles[AID] := TLandTileData(ABlock.Clone);
|
||||
end else
|
||||
begin
|
||||
if Assigned(FStaticTiles[AID - $4000]) then FreeAndNil(FStaticTiles[AID - $4000]);
|
||||
FreeAndNil(FStaticTiles[AID - $4000]);
|
||||
FStaticTiles[AID - $4000] := TStaticTileData(ABlock.Clone);
|
||||
end;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2007 Andreas Schneider
|
||||
* Portions Copyright 2009 Andreas Schneider
|
||||
*)
|
||||
unit UAnimData;
|
||||
|
||||
|
@ -35,37 +35,37 @@ const
|
|||
AnimDataGroupSize = 4 + (8 * AnimDataSize);
|
||||
|
||||
type
|
||||
|
||||
{ TAnimData }
|
||||
|
||||
TAnimData = class(TMulBlock)
|
||||
constructor Create(Data: TStream);
|
||||
constructor Create(AData: TStream);
|
||||
function GetSize: Integer; override;
|
||||
procedure Write(Data: TStream); override;
|
||||
private
|
||||
FOffset: Int64;
|
||||
procedure Write(AData: TStream); override;
|
||||
function Clone: TAnimData; override;
|
||||
protected
|
||||
FUnknown: Byte;
|
||||
FFrameCount: Byte;
|
||||
FFrameInterval: Byte;
|
||||
FFrameStart: Byte;
|
||||
public
|
||||
FrameData: array[0..63] of ShortInt;
|
||||
published
|
||||
property Offset: Int64 read FOffset write FOffset;
|
||||
FrameData: array[0..63] of Byte;
|
||||
property Unknown: Byte read FUnknown write FUnknown;
|
||||
property FrameCount: Byte read FFrameCount write FFrameCount;
|
||||
property FrameInterval: Byte read FFrameInterval write FFrameInterval;
|
||||
property FrameStart: Byte read FFrameStart write FFrameStart;
|
||||
end;
|
||||
|
||||
{ TAnimDataGroup }
|
||||
|
||||
TAnimDataGroup = class(TMulBlock)
|
||||
constructor Create(Data: TStream);
|
||||
constructor Create(AData: TStream);
|
||||
destructor Destroy; override;
|
||||
function GetSize: Integer; override;
|
||||
procedure Write(Data: TStream); override;
|
||||
private
|
||||
FOffset: Int64;
|
||||
procedure Write(AData: TStream); override;
|
||||
protected
|
||||
FUnknown: LongInt;
|
||||
public
|
||||
AnimData: array[0..7] of TAnimData;
|
||||
published
|
||||
property Offset: Int64 read FOffset write FOffset;
|
||||
property Unknown: LongInt read FUnknown write FUnknown;
|
||||
end;
|
||||
|
||||
|
@ -73,7 +73,7 @@ function GetAnimDataOffset(Block: Integer): Integer;
|
|||
|
||||
implementation
|
||||
|
||||
function GetAnimDataOffset;
|
||||
function GetAnimDataOffset(Block: Integer): Integer;
|
||||
var
|
||||
group, tile: Integer;
|
||||
begin
|
||||
|
@ -83,44 +83,59 @@ begin
|
|||
Result := group * AnimDataGroupSize + 4 + tile * AnimDataSize;
|
||||
end;
|
||||
|
||||
constructor TAnimData.Create;
|
||||
{ TAnimData }
|
||||
|
||||
constructor TAnimData.Create(AData: TStream);
|
||||
begin
|
||||
if assigned(Data) then
|
||||
if AData <> nil then
|
||||
begin
|
||||
FOffset := Data.Position;
|
||||
Data.Read(FrameData, 64);
|
||||
Data.Read(FUnknown, SizeOf(Byte));
|
||||
Data.Read(FFrameCount, SizeOf(Byte));
|
||||
Data.Read(FFrameInterval, SizeOf(Byte));
|
||||
Data.Read(FFrameStart, SizeOf(Byte));
|
||||
AData.Read(FrameData, SizeOf(FrameData[0]) * Length(FrameData));
|
||||
AData.Read(FUnknown, SizeOf(FUnknown));
|
||||
AData.Read(FFrameCount, SizeOf(FFrameCount));
|
||||
AData.Read(FFrameInterval, SizeOf(FFrameInterval));
|
||||
AData.Read(FFrameStart, SizeOf(FFrameStart));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAnimData.Write;
|
||||
procedure TAnimData.Write(AData: TStream);
|
||||
begin
|
||||
Data.Write(FrameData, 64);
|
||||
Data.Write(FUnknown, SizeOf(Byte));
|
||||
Data.Write(FFrameCount, SizeOf(Byte));
|
||||
Data.Write(FFrameInterval, SizeOf(Byte));
|
||||
Data.Write(FFrameStart, SizeOf(Byte));
|
||||
AData.Write(FrameData, SizeOf(FrameData[0]) * Length(FrameData));
|
||||
AData.Write(FUnknown, SizeOf(FUnknown));
|
||||
AData.Write(FFrameCount, SizeOf(FFrameCount));
|
||||
AData.Write(FFrameInterval, SizeOf(FFrameInterval));
|
||||
AData.Write(FFrameStart, SizeOf(FFrameStart));
|
||||
end;
|
||||
|
||||
function TAnimData.GetSize;
|
||||
begin
|
||||
GetSize := AnimDataSize;
|
||||
end;
|
||||
|
||||
constructor TAnimDataGroup.Create;
|
||||
function TAnimData.Clone: TAnimData;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if assigned(Data) then
|
||||
Result := TAnimData.Create(nil);
|
||||
Result.FUnknown := FUnknown;
|
||||
Result.FFrameCount := FFrameCount;
|
||||
Result.FFrameInterval := FFrameInterval;
|
||||
Result.FFrameStart := FFrameStart;
|
||||
for i := 0 to 63 do
|
||||
Result.FrameData[i] := FrameData[i];
|
||||
end;
|
||||
|
||||
function TAnimData.GetSize: Integer;
|
||||
begin
|
||||
Result := AnimDataSize;
|
||||
end;
|
||||
|
||||
{ TAnimDataGroup }
|
||||
|
||||
constructor TAnimDataGroup.Create(AData: TStream);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if AData <> nil then
|
||||
begin
|
||||
FOffset := Data.Position;
|
||||
Data.Read(FUnknown, SizeOf(LongInt));
|
||||
AData.Read(FUnknown, SizeOf(FUnknown));
|
||||
end;
|
||||
for i := 0 to 7 do
|
||||
AnimData[i] := TAnimData.Create(Data);
|
||||
AnimData[i] := TAnimData.Create(AData);
|
||||
end;
|
||||
|
||||
destructor TAnimDataGroup.Destroy;
|
||||
|
@ -131,18 +146,18 @@ begin
|
|||
AnimData[i].Free;
|
||||
end;
|
||||
|
||||
procedure TAnimDataGroup.Write;
|
||||
procedure TAnimDataGroup.Write(AData: TStream);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Data.Write(FUnknown, SizeOf(LongInt));
|
||||
AData.Write(FUnknown, SizeOf(FUnknown));
|
||||
for i := 0 to 7 do
|
||||
AnimData[i].Write(Data);
|
||||
AnimData[i].Write(AData);
|
||||
end;
|
||||
|
||||
function TAnimDataGroup.GetSize;
|
||||
function TAnimDataGroup.GetSize: Integer;
|
||||
begin
|
||||
GetSize := AnimDataGroupSize;
|
||||
Result := AnimDataGroupSize;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
@ -150,7 +150,8 @@ begin
|
|||
group := ABlock div 32;
|
||||
tile := ABlock mod 32;
|
||||
|
||||
Result := 512 * LandTileGroupSize + group * StaticTileGroupSize + 4 + tile * StaticTileDataSize;
|
||||
Result := 512 * LandTileGroupSize + group * StaticTileGroupSize + 4
|
||||
+ tile * StaticTileDataSize;
|
||||
end else
|
||||
begin
|
||||
group := ABlock div 32;
|
||||
|
|
Loading…
Reference in New Issue