- 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"/> <MinVersion Major="4" Minor="5" Release="1" Valid="True"/>
</Item5> </Item5>
</RequiredPackages> </RequiredPackages>
<Units Count="40"> <Units Count="42">
<Unit0> <Unit0>
<Filename Value="CentrED.lpr"/> <Filename Value="CentrED.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -298,6 +298,16 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="UMulManager"/> <UnitName Value="UMulManager"/>
</Unit39> </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> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

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

View File

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

View File

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

View File

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