- Fixed Art and TexMap to no longer get loaded if their Size is <= 0

This commit is contained in:
Andreas Schneider 2009-12-10 22:05:38 +01:00
parent 5c3de09d10
commit 34765f7235
6 changed files with 553 additions and 534 deletions

View File

@ -56,7 +56,7 @@
<MinVersion Major="4" Minor="5" Release="1" Valid="True"/>
</Item5>
</RequiredPackages>
<Units Count="40">
<Units Count="42">
<Unit0>
<Filename Value="CentrED.lpr"/>
<IsPartOfProject Value="True"/>
@ -298,6 +298,16 @@
<IsPartOfProject Value="True"/>
<UnitName Value="UMulManager"/>
</Unit39>
<Unit40>
<Filename Value="../MulProvider/UArtProvider.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UArtProvider"/>
</Unit40>
<Unit41>
<Filename Value="../MulProvider/UTexmapProvider.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UTexmapProvider"/>
</Unit41>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

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

View File

@ -37,7 +37,7 @@ type
{ TGameResourceManager }
TGameResourceManager = class(TObject)
TGameResourceManager = class
constructor Create(ADataDir: string);
destructor Destroy; override;
protected

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2007 Andreas Schneider
* Portions Copyright 2009 Andreas Schneider
*)
unit UArtProvider;
@ -54,7 +54,7 @@ end;
function TArtProvider.GetArtData(AID: Integer; AIndex: TGenericIndex;
AColor: Word; AHue: THue; APartialHue: Boolean): TArt;
begin
if AIndex.Lookup <> LongInt($FFFFFFFF) then
if (AIndex.Lookup > -1) and (AIndex.Size > 0) then
begin
if AID < $4000 then
Result := TArt.Create(FData, AIndex, atLand, AColor, AHue, APartialHue)

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2007 Andreas Schneider
* Portions Copyright 2009 Andreas Schneider
*)
unit UMulProvider;
@ -34,7 +34,10 @@ uses
type
TOnProgressEvent = procedure(Total, Current: Integer) of object;
TMulEventHandler = class(TObject)
{ TMulEventHandler }
TMulEventHandler = class
constructor Create;
destructor Destroy; override;
protected
@ -44,7 +47,10 @@ type
procedure UnregisterEvent(AEvent: TMulBlockChanged);
procedure FireEvents(ABlock: TMulBlock);
end;
TMulProvider = class(TObject)
{ TMulProvider }
TMulProvider = class
constructor Create; overload; virtual;
constructor Create(AData: TStream; AReadOnly: Boolean = False); overload; virtual;
constructor Create(AData: string; AReadOnly: Boolean = False); overload; virtual;
@ -70,6 +76,9 @@ type
property Block[ID: Integer]: TMulBlock read GetBlock write SetBlock;
property Data: TStream read FData;
end;
{ TIndexedMulProvider }
TIndexedMulProvider = class(TMulProvider)
constructor Create(AData, AIndex: TStream; AReadOnly: Boolean = False); overload; virtual;
constructor Create(AData, AIndex: string; AReadOnly: Boolean = False); overload; virtual;
@ -308,7 +317,7 @@ var
begin
FIndex.Position := CalculateIndexOffset(AID);
genericIndex := TGenericIndex.Create(FIndex);
Result := genericIndex.Lookup <> LongInt($FFFFFFFF);
Result := (genericIndex.Lookup > -1) and (genericIndex.Size > 0);
genericIndex.Free;
end;

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2007 Andreas Schneider
* Portions Copyright 2009 Andreas Schneider
*)
unit UTexmapProvider;
@ -44,7 +44,7 @@ implementation
function TTexmapProvider.GetData(AID: Integer; AIndex: TGenericIndex): TMulBlock;
begin
if AIndex.Lookup <> LongInt($FFFFFFFF) then
if (AIndex.Lookup > -1) and (AIndex.Size > 0) then
Result := TTexture.Create(FData, AIndex)
else
Result := TTexture.Create(-1);