- Fixed typo in UMulManager

- Added array initialization to TAnimDataProvider
- Adjusted frmLogin
- Some code cleanups
This commit is contained in:
Andreas Schneider 2009-12-08 22:17:39 +01:00
parent 06c9c2c507
commit 1759e0763c
8 changed files with 288 additions and 118 deletions

View File

@ -31,7 +31,7 @@ interface
uses uses
Classes, SysUtils, UArtProvider, UTileDataProvider, UTexmapProvider, Classes, SysUtils, UArtProvider, UTileDataProvider, UTexmapProvider,
ULandscape, UHueProvider; ULandscape, UHueProvider, UAnimDataProvider;
type type
@ -45,6 +45,7 @@ type
FDataDir: string; FDataDir: string;
FArtProvider: TArtProvider; FArtProvider: TArtProvider;
FTiledataProvider: TTiledataProvider; FTiledataProvider: TTiledataProvider;
FAnimdataProvider: TAnimdataProvider;
FTexmapProvider: TTexmapProvider; FTexmapProvider: TTexmapProvider;
FHueProvider: THueProvider; FHueProvider: THueProvider;
FLandscape: TLandscape; FLandscape: TLandscape;
@ -54,6 +55,7 @@ type
property Hue: THueProvider read FHueProvider; property Hue: THueProvider read FHueProvider;
property Landscape: TLandscape read FLandscape; property Landscape: TLandscape read FLandscape;
property Tiledata: TTiledataProvider read FTiledataProvider; property Tiledata: TTiledataProvider read FTiledataProvider;
property Animdata: TAnimDataProvider read FAnimdataProvider;
property Texmaps: TTexmapProvider read FTexmapProvider; property Texmaps: TTexmapProvider read FTexmapProvider;
{ Methods } { Methods }
@ -84,6 +86,7 @@ begin
FArtProvider := TArtProvider.Create(GetFile('art.mul'), GetFile('artidx.mul'), True); FArtProvider := TArtProvider.Create(GetFile('art.mul'), GetFile('artidx.mul'), True);
FTiledataProvider := TTiledataProvider.Create(GetFile('tiledata.mul'), True); FTiledataProvider := TTiledataProvider.Create(GetFile('tiledata.mul'), True);
FAnimdataProvider := TAnimDataProvider.Create(GetFile('animdata.mul'), True);
FTexmapProvider := TTexmapProvider.Create(GetFile('texmaps.mul'), GetFile('texidx.mul'), True); FTexmapProvider := TTexmapProvider.Create(GetFile('texmaps.mul'), GetFile('texidx.mul'), True);
FHueProvider := THueProvider.Create(GetFile('hues.mul'), True); FHueProvider := THueProvider.Create(GetFile('hues.mul'), True);
end; end;
@ -92,6 +95,7 @@ destructor TGameResourceManager.Destroy;
begin begin
FreeAndNil(FArtProvider); FreeAndNil(FArtProvider);
FreeAndNil(FTiledataProvider); FreeAndNil(FTiledataProvider);
FreeAndNil(FAnimdataProvider);
FreeAndNil(FTexmapProvider); FreeAndNil(FTexmapProvider);
FreeAndNil(FHueProvider); FreeAndNil(FHueProvider);
FreeAndNil(FLandscape); FreeAndNil(FLandscape);

View File

@ -22,7 +22,7 @@ object dmNetwork: TdmNetwork
Interval = 30000 Interval = 30000
OnTimer = tmNoOpTimer OnTimer = tmNoOpTimer
OnStartTimer = tmNoOpStartTimer OnStartTimer = tmNoOpStartTimer
left = 72 left = 112
top = 24 top = 24
end end
end end

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2009 Andreas Schneider
*) *)
unit UdmNetwork; unit UdmNetwork;
@ -95,9 +95,9 @@ end;
procedure TdmNetwork.DataModuleDestroy(Sender: TObject); procedure TdmNetwork.DataModuleDestroy(Sender: TObject);
begin begin
if FSendQueue <> nil then FreeAndNil(FSendQueue); FreeAndNil(FSendQueue);
if FReceiveQueue <> nil then FreeAndNil(FReceiveQueue); FreeAndNil(FReceiveQueue);
if PacketHandlers[$02] <> nil then FreeAndNil(PacketHandlers[$02]); FreeAndNil(PacketHandlers[$02]);
end; end;
procedure TdmNetwork.TCPClientConnect(aSocket: TLSocket); procedure TdmNetwork.TCPClientConnect(aSocket: TLSocket);
@ -290,28 +290,33 @@ procedure TdmNetwork.DoLogin;
begin begin
tmNoOp.Enabled := False; tmNoOp.Enabled := False;
frmLogin := TfrmLogin.Create(dmNetwork); frmLogin := TfrmLogin.Create(dmNetwork);
if frmInitialize = nil then frmInitialize := TfrmInitialize.Create(dmNetwork); if frmInitialize = nil then
if frmTileInfo <> nil then FreeAndNil(frmTileInfo); frmInitialize := TfrmInitialize.Create(dmNetwork);
if frmEditAccount <> nil then FreeAndNil(frmEditAccount);
if frmAccountControl <> nil then FreeAndNil(frmAccountControl); FreeAndNil(frmTileInfo);
if frmConfirmation <> nil then FreeAndNil(frmConfirmation); FreeAndNil(frmEditAccount);
if frmDrawSettings <> nil then FreeAndNil(frmDrawSettings); FreeAndNil(frmAccountControl);
if frmMoveSettings <> nil then FreeAndNil(frmMoveSettings); FreeAndNil(frmConfirmation);
if frmElevateSettings <> nil then FreeAndNil(frmElevateSettings); FreeAndNil(frmDrawSettings);
if frmHueSettings <> nil then FreeAndNil(frmHueSettings); FreeAndNil(frmMoveSettings);
if frmBoundaries <> nil then FreeAndNil(frmBoundaries); FreeAndNil(frmElevateSettings);
if frmFilter <> nil then FreeAndNil(frmFilter); FreeAndNil(frmHueSettings);
if frmVirtualLayer <> nil then FreeAndNil(frmVirtualLayer); FreeAndNil(frmBoundaries);
if frmAbout <> nil then FreeAndNil(frmAbout); FreeAndNil(frmFilter);
if frmRegionControl <> nil then FreeAndNil(frmRegionControl); FreeAndNil(frmVirtualLayer);
if frmLargeScaleCommand <> nil then FreeAndNil(frmLargeScaleCommand); FreeAndNil(frmAbout);
if frmRadarMap <> nil then FreeAndNil(frmRadarMap); FreeAndNil(frmRegionControl);
FreeAndNil(frmLargeScaleCommand);
FreeAndNil(frmRadarMap);
if frmMain <> nil then if frmMain <> nil then
begin begin
frmMain.ApplicationProperties1.OnIdle := nil; frmMain.ApplicationProperties1.OnIdle := nil;
FreeAndNil(frmMain); FreeAndNil(frmMain);
end; end;
if GameResourceManager <> nil then FreeAndNil(GameResourceManager);
FreeAndNil(GameResourceManager);
frmInitialize.Hide; frmInitialize.Hide;
while frmLogin.ShowModal = mrOK do while frmLogin.ShowModal = mrOK do
begin begin

View File

@ -1,14 +1,14 @@
object frmLogin: TfrmLogin object frmLogin: TfrmLogin
Left = 290 Left = 290
Height = 265 Height = 246
Top = 171 Top = 171
Width = 489 Width = 481
ActiveControl = edHost ActiveControl = btnOK
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'UO CentrED' Caption = 'UO CentrED'
ClientHeight = 265 ClientHeight = 246
ClientWidth = 489 ClientWidth = 481
Font.Height = -11 Font.Height = -11
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
@ -16,53 +16,85 @@ object frmLogin: TfrmLogin
ShowInTaskBar = stAlways ShowInTaskBar = stAlways
LCLVersion = '0.9.29' LCLVersion = '0.9.29'
object lblCopyright: TLabel object lblCopyright: TLabel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 14 Height = 15
Top = 251 Top = 231
Width = 489 Width = 481
Align = alBottom
Alignment = taCenter Alignment = taCenter
Anchors = [akLeft, akRight, akBottom]
ParentColor = False ParentColor = False
end end
object gbConnection: TGroupBox object gbConnection: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = gbActions
AnchorSideBottom.Side = asrCenter
Left = 8 Left = 8
Height = 128 Height = 128
Top = 8 Top = 4
Width = 321 Width = 314
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 4
Caption = 'Connection' Caption = 'Connection'
ClientHeight = 110 ClientHeight = 114
ClientWidth = 317 ClientWidth = 312
TabOrder = 0 TabOrder = 0
object lblHost: TLabel object lblHost: TLabel
Left = 30 AnchorSideLeft.Control = imgHost
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edHost
AnchorSideTop.Side = asrCenter
Left = 32
Height = 14 Height = 14
Top = 9 Top = 10
Width = 28 Width = 28
BorderSpacing.Left = 8
Caption = 'Host:' Caption = 'Host:'
ParentColor = False ParentColor = False
end end
object lblUsername: TLabel object lblUsername: TLabel
Left = 30 AnchorSideLeft.Control = imgUsername
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edUsername
AnchorSideTop.Side = asrCenter
Left = 32
Height = 14 Height = 14
Top = 43 Top = 46
Width = 55 Width = 58
BorderSpacing.Left = 8
Caption = 'Username:' Caption = 'Username:'
ParentColor = False ParentColor = False
end end
object lblPassword: TLabel object lblPassword: TLabel
Left = 30 AnchorSideLeft.Control = imgPassword
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edPassword
AnchorSideTop.Side = asrCenter
Left = 32
Height = 14 Height = 14
Top = 77 Top = 81
Width = 53 Width = 54
BorderSpacing.Left = 8
Caption = 'Password:' Caption = 'Password:'
ParentColor = False ParentColor = False
end end
object imgHost: TImage object imgHost: TImage
Left = 6 AnchorSideLeft.Control = gbConnection
AnchorSideTop.Control = lblHost
AnchorSideTop.Side = asrCenter
Left = 8
Height = 16 Height = 16
Top = 9 Top = 9
Width = 16 Width = 16
AutoSize = True AutoSize = True
BorderSpacing.Left = 8
Picture.Data = { Picture.Data = {
07545069786D61702E0A00002F2A2058504D202A2F0A73746174696320636861 07545069786D61702E0A00002F2A2058504D202A2F0A73746174696320636861
72202A64756D6D795B5D3D7B0A223136203136203132342032222C0A22517420 72202A64756D6D795B5D3D7B0A223136203136203132342032222C0A22517420
@ -150,9 +182,12 @@ object frmLogin: TfrmLogin
Transparent = True Transparent = True
end end
object imgUsername: TImage object imgUsername: TImage
Left = 6 AnchorSideLeft.Control = imgHost
AnchorSideTop.Control = lblUsername
AnchorSideTop.Side = asrCenter
Left = 8
Height = 16 Height = 16
Top = 43 Top = 45
Width = 16 Width = 16
AutoSize = True AutoSize = True
Picture.Data = { Picture.Data = {
@ -242,9 +277,12 @@ object frmLogin: TfrmLogin
Transparent = True Transparent = True
end end
object imgPassword: TImage object imgPassword: TImage
Left = 6 AnchorSideLeft.Control = imgUsername
AnchorSideTop.Control = lblPassword
AnchorSideTop.Side = asrCenter
Left = 8
Height = 16 Height = 16
Top = 77 Top = 80
Width = 16 Width = 16
AutoSize = True AutoSize = True
Picture.Data = { Picture.Data = {
@ -324,34 +362,66 @@ object frmLogin: TfrmLogin
Transparent = True Transparent = True
end end
object edHost: TEdit object edHost: TEdit
Left = 101 AnchorSideLeft.Control = lblUsername
Height = 21 AnchorSideLeft.Side = asrBottom
Top = 5 AnchorSideTop.Control = gbConnection
Width = 137 AnchorSideRight.Control = edPort
Left = 98
Height = 19
Top = 8
Width = 143
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 0 TabOrder = 0
Text = 'localhost' Text = 'localhost'
end end
object edUsername: TEdit object edUsername: TEdit
Left = 101 AnchorSideLeft.Control = edHost
Height = 21 AnchorSideTop.Control = edHost
Top = 39 AnchorSideTop.Side = asrBottom
Width = 201 AnchorSideRight.Control = edPort
AnchorSideRight.Side = asrBottom
Left = 98
Height = 19
Top = 44
Width = 206
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 17
TabOrder = 2 TabOrder = 2
end end
object edPassword: TEdit object edPassword: TEdit
Left = 101 AnchorSideLeft.Control = edUsername
Height = 21 AnchorSideTop.Control = edUsername
Top = 73 AnchorSideTop.Side = asrBottom
Width = 201 AnchorSideRight.Control = edUsername
AnchorSideRight.Side = asrBottom
Left = 98
Height = 19
Top = 79
Width = 206
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 16
BorderSpacing.Bottom = 16
EchoMode = emPassword EchoMode = emPassword
PasswordChar = '*' PasswordChar = '*'
TabOrder = 3 TabOrder = 3
end end
object edPort: TSpinEdit object edPort: TSpinEdit
Left = 246 AnchorSideLeft.Control = edHost
Height = 21 AnchorSideLeft.Side = asrBottom
Top = 5 AnchorSideTop.Control = edHost
Width = 56 AnchorSideRight.Control = gbConnection
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edHost
AnchorSideBottom.Side = asrBottom
Left = 249
Height = 19
Top = 8
Width = 55
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
MaxValue = 65565 MaxValue = 65565
MinValue = 1024 MinValue = 1024
TabOrder = 1 TabOrder = 1
@ -359,18 +429,33 @@ object frmLogin: TfrmLogin
end end
end end
object gbActions: TGroupBox object gbActions: TGroupBox
Left = 336 AnchorSideLeft.Control = gbConnection
Height = 96 AnchorSideLeft.Side = asrBottom
Top = 8 AnchorSideTop.Control = gbConnection
Width = 145 AnchorSideRight.Control = Owner
ClientHeight = 78 AnchorSideRight.Side = asrBottom
Left = 330
Height = 76
Top = 12
Width = 143
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
ClientHeight = 74
ClientWidth = 141 ClientWidth = 141
TabOrder = 2 TabOrder = 2
object btnOK: TButton object btnOK: TButton
Left = 6 AnchorSideLeft.Control = gbActions
AnchorSideTop.Control = gbActions
AnchorSideRight.Control = gbActions
AnchorSideRight.Side = asrBottom
Left = 8
Height = 25 Height = 25
Top = 5 Top = 8
Width = 128 Width = 125
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 8
BorderSpacing.InnerBorder = 4 BorderSpacing.InnerBorder = 4
Caption = '&OK' Caption = '&OK'
Default = True Default = True
@ -378,10 +463,17 @@ object frmLogin: TfrmLogin
TabOrder = 0 TabOrder = 0
end end
object btnCancel: TButton object btnCancel: TButton
Left = 6 AnchorSideLeft.Control = btnOK
AnchorSideTop.Control = btnOK
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnOK
AnchorSideRight.Side = asrBottom
Left = 8
Height = 25 Height = 25
Top = 39 Top = 41
Width = 128 Width = 125
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Bottom = 8
BorderSpacing.InnerBorder = 4 BorderSpacing.InnerBorder = 4
Caption = '&Cancel' Caption = '&Cancel'
ModalResult = 2 ModalResult = 2
@ -390,51 +482,83 @@ object frmLogin: TfrmLogin
end end
end end
object gbData: TGroupBox object gbData: TGroupBox
AnchorSideLeft.Control = gbConnection
AnchorSideTop.Control = gbConnection
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbConnection
AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 97 Height = 95
Top = 144 Top = 136
Width = 321 Width = 314
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 4
Caption = 'Data files' Caption = 'Data files'
ClientHeight = 79 ClientHeight = 81
ClientWidth = 317 ClientWidth = 312
TabOrder = 1 TabOrder = 1
object lblData: TLabel object lblData: TLabel
Left = 7 AnchorSideLeft.Control = gbData
Height = 32 AnchorSideTop.Control = gbData
Top = 8 AnchorSideRight.Control = gbData
Width = 304 AnchorSideRight.Side = asrBottom
AutoSize = False Left = 8
Caption = 'Select the directory containing art.mul, artidx.mul, hues.mul, tiledata.mul, texmaps.mul and texidx.mul.' Height = 46
Top = 4
Width = 296
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 8
Caption = 'Select the directory containing art.mul, artidx.mul, hues.mul, tiledata.mul, animdata.mul, texmaps.mul and texidx.mul.'
ParentColor = False ParentColor = False
WordWrap = True WordWrap = True
end end
object edData: TDirectoryEdit object edData: TDirectoryEdit
Left = 7 AnchorSideLeft.Control = lblData
Height = 21 AnchorSideTop.Control = lblData
Top = 48 AnchorSideTop.Side = asrBottom
Width = 280 Left = 8
Height = 19
Top = 54
Width = 272
ShowHidden = False ShowHidden = False
ButtonWidth = 23 ButtonWidth = 23
NumGlyphs = 1 NumGlyphs = 1
BorderSpacing.Top = 4
BorderSpacing.Bottom = 8
MaxLength = 0 MaxLength = 0
TabOrder = 0 TabOrder = 0
end end
end end
object GroupBox1: TGroupBox object gbProfiles: TGroupBox
Left = 336 AnchorSideLeft.Control = gbActions
Height = 88 AnchorSideTop.Control = gbActions
Top = 112 AnchorSideTop.Side = asrBottom
Width = 145 AnchorSideRight.Control = gbActions
AnchorSideRight.Side = asrBottom
Left = 330
Height = 85
Top = 96
Width = 143
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Profiles' Caption = 'Profiles'
ClientHeight = 70 ClientHeight = 71
ClientWidth = 141 ClientWidth = 141
TabOrder = 3 TabOrder = 3
object btnSaveProfile: TSpeedButton object btnSaveProfile: TSpeedButton
Left = 86 AnchorSideTop.Control = btnDeleteProfile
AnchorSideRight.Control = btnDeleteProfile
Left = 81
Height = 22 Height = 22
Hint = 'Save profile' Hint = 'Save profile'
Top = 40 Top = 41
Width = 23 Width = 22
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Color = clBtnFace Color = clBtnFace
Glyph.Data = { Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100 36040000424D3604000000000000360000002800000010000000100000000100
@ -479,11 +603,18 @@ object frmLogin: TfrmLogin
ParentShowHint = False ParentShowHint = False
end end
object btnDeleteProfile: TSpeedButton object btnDeleteProfile: TSpeedButton
AnchorSideTop.Control = cbProfile
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = cbProfile
AnchorSideRight.Side = asrBottom
Left = 111 Left = 111
Height = 22 Height = 22
Hint = 'Delete profile' Hint = 'Delete profile'
Top = 40 Top = 41
Width = 23 Width = 22
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
Color = clBtnFace Color = clBtnFace
Glyph.Data = { Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100 36040000424D3604000000000000360000002800000010000000100000000100
@ -528,11 +659,19 @@ object frmLogin: TfrmLogin
ParentShowHint = False ParentShowHint = False
end end
object cbProfile: TComboBox object cbProfile: TComboBox
Left = 6 AnchorSideLeft.Control = gbProfiles
Height = 21 AnchorSideTop.Control = gbProfiles
Top = 8 AnchorSideRight.Control = gbProfiles
Width = 128 AnchorSideRight.Side = asrBottom
ItemHeight = 13 Left = 8
Height = 29
Top = 4
Width = 125
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 8
ItemHeight = 0
OnChange = cbProfileChange OnChange = cbProfileChange
Style = csDropDownList Style = csDropDownList
TabOrder = 0 TabOrder = 0

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2009 Andreas Schneider
*) *)
unit UfrmLogin; unit UfrmLogin;
@ -48,7 +48,7 @@ type
gbConnection: TGroupBox; gbConnection: TGroupBox;
gbData: TGroupBox; gbData: TGroupBox;
gbActions: TGroupBox; gbActions: TGroupBox;
GroupBox1: TGroupBox; gbProfiles: TGroupBox;
imgHost: TImage; imgHost: TImage;
imgUsername: TImage; imgUsername: TImage;
imgPassword: TImage; imgPassword: TImage;
@ -108,12 +108,13 @@ begin
(not FileExists(path + 'artidx.mul')) or (not FileExists(path + 'artidx.mul')) or
(not FileExists(path + 'hues.mul')) or (not FileExists(path + 'hues.mul')) or
(not FileExists(path + 'tiledata.mul')) or (not FileExists(path + 'tiledata.mul')) or
(not FileExists(path + 'animdata.mul')) or
(not FileExists(path + 'texmaps.mul')) or (not FileExists(path + 'texmaps.mul')) or
(not FileExists(path + 'texidx.mul')) then (not FileExists(path + 'texidx.mul')) then
begin begin
MessageDlg('Incorrect directory', 'The data path you specified does not seem to be correct.', mtWarning, [mbOK], 0); MessageDlg('Incorrect directory', 'The data path you specified does not '
+ 'seem to be correct.', mtWarning, [mbOK], 0);
edData.SetFocus; edData.SetFocus;
Exit;
end else end else
ModalResult := mrOK; ModalResult := mrOK;
end; end;
@ -168,9 +169,11 @@ procedure TfrmLogin.FormCreate(Sender: TObject);
var var
searchRec: TSearchRec; searchRec: TSearchRec;
begin begin
lblCopyright.Caption := Format('UO CentrED Client Version %s (c) %s', [ProductVersion, Copyright]); lblCopyright.Caption := Format('UO CentrED Client Version %s (c) %s',
[ProductVersion, Copyright]);
FProfilePath := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName)) + 'Profiles' + PathDelim; FProfilePath := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName))
+ 'Profiles' + PathDelim;
ForceDirectories(FProfilePath); ForceDirectories(FProfilePath);
if FindFirst(FProfilePath + '*.ini', faAnyFile, searchRec) = 0 then if FindFirst(FProfilePath + '*.ini', faAnyFile, searchRec) = 0 then
begin begin

View File

@ -48,6 +48,7 @@ type
FAnimData: TAnimDataArray; FAnimData: TAnimDataArray;
function CalculateOffset(AID: Integer): Integer; override; function CalculateOffset(AID: Integer): Integer; override;
function GetData(AID, AOffset: Integer): TAnimData; override; function GetData(AID, AOffset: Integer): TAnimData; override;
procedure InitArray;
procedure SetData(AID, AOffset: Integer; ABlock: TMulBlock); override; procedure SetData(AID, AOffset: Integer; ABlock: TMulBlock); override;
public public
property AnimData: TAnimDataArray read FAnimData; property AnimData: TAnimDataArray read FAnimData;
@ -61,15 +62,22 @@ implementation
constructor TAnimDataProvider.Create(AData: TStream; AReadOnly: Boolean); constructor TAnimDataProvider.Create(AData: TStream; AReadOnly: Boolean);
begin begin
inherited Create(AData, AReadOnly); inherited Create(AData, AReadOnly);
InitArray;
end; end;
constructor TAnimDataProvider.Create(AData: string; AReadOnly: Boolean); constructor TAnimDataProvider.Create(AData: string; AReadOnly: Boolean);
begin begin
inherited Create(AData, AReadOnly); inherited Create(AData, AReadOnly);
InitArray;
end; end;
destructor TAnimDataProvider.Destroy; destructor TAnimDataProvider.Destroy;
var
i: Integer;
begin begin
for i := 0 to Length(FAnimData) - 1 do
FreeAndNil(FAnimData[i]);
inherited Destroy; inherited Destroy;
end; end;
@ -83,6 +91,17 @@ begin
Result := FAnimData[AID]; Result := FAnimData[AID];
end; end;
procedure TAnimDataProvider.InitArray;
var
i: Integer;
begin
for i := 0 to Length(FAnimData) - 1 do
begin
FData.Position := GetAnimDataOffset(i);
FAnimData[i] := TAnimData.Create(FData);
end;
end;
procedure TAnimDataProvider.SetData(AID, AOffset: Integer; ABlock: TMulBlock); procedure TAnimDataProvider.SetData(AID, AOffset: Integer; ABlock: TMulBlock);
begin begin
FreeAndNil(FAnimData[AID]); FreeAndNil(FAnimData[AID]);

View File

@ -123,7 +123,7 @@ procedure TMulManager.RegisterAnimDataProvider(
AAnimDataProvider: TAnimDataProvider); AAnimDataProvider: TAnimDataProvider);
begin begin
FreeAndNil(FAnimDataProvider); FreeAndNil(FAnimDataProvider);
FTileDataProvider := AAnimDataProvider; FAnimDataProvider := AAnimDataProvider;
end; end;
end. end.

View File

@ -69,16 +69,16 @@ type
property Unknown: LongInt read FUnknown write FUnknown; property Unknown: LongInt read FUnknown write FUnknown;
end; end;
function GetAnimDataOffset(Block: Integer): Integer; function GetAnimDataOffset(AID: Integer): Integer;
implementation implementation
function GetAnimDataOffset(Block: Integer): Integer; function GetAnimDataOffset(AID: Integer): Integer;
var var
group, tile: Integer; group, tile: Integer;
begin begin
group := Block div 8; group := AID div 8;
tile := Block mod 8; tile := AID mod 8;
Result := group * AnimDataGroupSize + 4 + tile * AnimDataSize; Result := group * AnimDataGroupSize + 4 + tile * AnimDataSize;
end; end;