- Added more checks to statics loading and saving and replaced unnecessary LongInt casts

This commit is contained in:
Andreas Schneider 2009-03-09 17:24:53 +01:00
parent 114c218ca6
commit 7e86c7400c
3 changed files with 383 additions and 384 deletions

View File

@ -479,14 +479,14 @@ begin
FStaIdx.Position := ((AWorldBlock.X * FHeight) + AWorldBlock.Y) * 12;
index := TGenericIndex.Create(FStaIdx);
size := AWorldBlock.GetSize;
if (size > index.Size) or (index.Lookup = LongInt($FFFFFFFF)) then
if (size > index.Size) or (index.Lookup < 0) then
begin
FStatics.Position := FStatics.Size;
index.Lookup := FStatics.Position;
end;
index.Size := size;
if size = 0 then
index.Lookup := LongInt($FFFFFFFF)
index.Lookup := -1
else
begin
FStatics.Position := index.Lookup;

View File

@ -1,12 +1,13 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
<Version Value="6"/>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>

View File

@ -165,7 +165,7 @@ begin
FY := AY;
FItems := TList.Create;
if assigned(AData) and (AIndex.Lookup <> LongInt($FFFFFFFF)) then
if assigned(AData) and (AIndex.Lookup > 0) and (AIndex.Size > 0) then
begin
AData.Position := AIndex.Lookup;
block := TMemoryStream.Create;
@ -219,10 +219,8 @@ var
i: Integer;
begin
for i := 0 to FItems.Count - 1 do
begin
TStaticItem(FItems[i]).Write(AData);
end;
end;
procedure TStaticBlock.ReverseWrite(AData: TStream);
var
@ -297,7 +295,7 @@ begin
for i := 0 to 63 do
Cells[i] := TList.Create;
if (AData <> nil) and (AIndex.Lookup <> LongInt($FFFFFFFF)) then
if (AData <> nil) and (AIndex.Lookup > 0) and (AIndex.Size > 0) then
begin
AData.Position := AIndex.Lookup;
block := TMemoryStream.Create;