- Added fpdoc paths

- Started some documenting
- Added TScreenBuffer.UpdateSortOrder to handle elevations
This commit is contained in:
2009-08-03 18:40:31 +02:00
parent 1bc9ad3fe1
commit a71c1bd570
4 changed files with 122 additions and 6 deletions

View File

@@ -10,6 +10,7 @@
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
</General>
<LazDoc Paths="../doc"/>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>

View File

@@ -223,6 +223,7 @@ type
function Iterate(var ABlockInfo: PBlockInfo): Boolean;
procedure Sort;
procedure UpdateShortcuts;
function UpdateSortOrder(AItem: TWorldItem): PBlockInfo;
{ Events }
procedure OnTileRemoved(ATile: TMulBlock);
end;
@@ -1380,6 +1381,55 @@ begin
FShortCutsValid := True;
end;
function TScreenBuffer.UpdateSortOrder(AItem: TWorldItem): PBlockInfo;
var
newNodePosition, oldNode, oldNodePrev, current: PBlockInfo;
begin
newNodePosition := nil;
oldNode := nil;
oldNodePrev := nil;
current := FShortCuts[0];
while (current <> nil) and ((oldNode = nil) or (newNodePosition = nil)) do
begin
if current^.Item = AItem then
oldNode := current
else if oldNode = nil then
oldNodePrev := current;
if newNodePosition = nil then
begin
if (current^.Next = nil) or (CompareWorldItems(AItem, current^.Next^.Item) < 0) then
newNodePosition := current;
end;
current := current^.Next;
end;
if oldNode <> newNodePosition then
begin
if oldNodePrev <> oldNode then
begin
if oldNodePrev = nil then
FShortCuts[0] := oldNode^.Next
else
oldNodePrev^.Next := oldNode^.Next;
end;
if (newNodePosition = FShortCuts[0]) and (CompareWorldItems(AItem, FShortCuts[0]^.Item) < 0) then
begin
oldNode^.Next := FShortCuts[0];
FShortCuts[0] := oldNode;
end else
begin
oldNode^.Next := newNodePosition^.Next;
newNodePosition^.Next := oldNode;
end;
end;
Result := oldNode;
end;
procedure TScreenBuffer.OnTileRemoved(ATile: TMulBlock);
begin
Delete(TWorldItem(ATile));

View File

@@ -275,7 +275,7 @@ type
FTextureManager: TLandTextureManager;
FScreenBuffer: TScreenBuffer;
FScreenBufferValid: Boolean;
FScreenBufferSorted: Boolean;
FScreenBufferIndexed: Boolean;
FCurrentTile: TWorldItem;
FSelectedTile: TWorldItem;
FGhostTile: TWorldItem;
@@ -1773,10 +1773,10 @@ begin
if not FScreenBufferValid then
RebuildScreenBuffer;
if not FScreenBufferSorted then
if not FScreenBufferIndexed then
begin
FScreenBuffer.Sort;
FScreenBufferSorted := True;
FScreenBuffer.UpdateShortcuts;
FScreenBufferIndexed := True;
end;
{if acFilter.Checked then
@@ -2039,7 +2039,9 @@ end;
procedure TfrmMain.OnStaticElevated(AStaticItem: TStaticItem);
begin
FScreenBufferSorted := False;
AStaticItem.PrioritySolver := FScreenBuffer.GetSerial;
PrepareScreenBlock(FScreenBuffer.UpdateSortOrder(AStaticItem));
FScreenBufferIndexed := False;
end;
procedure TfrmMain.OnStaticInserted(AStaticItem: TStaticItem);
@@ -2200,7 +2202,7 @@ begin
FScreenBuffer.UpdateShortcuts;
FScreenBufferValid := True;
FScreenBufferSorted := True;
FScreenBufferIndexed := True;
end;
procedure TfrmMain.UpdateCurrentTile;