diff --git a/Client/CentrED.lpi b/Client/CentrED.lpi
index 4fd906f..c15bcf4 100644
--- a/Client/CentrED.lpi
+++ b/Client/CentrED.lpi
@@ -10,6 +10,7 @@
+
diff --git a/Client/ULandscape.pas b/Client/ULandscape.pas
index 20e2e03..fa9b56d 100644
--- a/Client/ULandscape.pas
+++ b/Client/ULandscape.pas
@@ -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));
diff --git a/Client/UfrmMain.pas b/Client/UfrmMain.pas
index 39a78f9..97331a4 100644
--- a/Client/UfrmMain.pas
+++ b/Client/UfrmMain.pas
@@ -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;
diff --git a/doc/ulandscape.xml b/doc/ulandscape.xml
new file mode 100644
index 0000000..855c9a8
--- /dev/null
+++ b/doc/ulandscape.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ Moves the BlockInfo up or down depending on the new sort order
+ The function iterates through the list of blocks to find the new position where the item should be stored and to find the item's block.
+Afterwards it moves this block to its new position and returns the block for further usage.
+
+
+ Stores all items that are (visible) on the screen.
+ TScreenBuffer contains a linked list of all items that should be visible on the screen, stored in .
+
+
+ Contains the necessary information to identify and draw items on the screen.
+
+
+ The coordinates on the screen. (as rectangle)
+
+
+ The coordinates for the OpenGL drawing function.
+
+
+ A reference to the item to be drawn.
+
+
+ Contains the high resolution (TexMap) texture if available and necessary.
+
+
+ Contains the default "normal" resolution graphic (Art).
+
+
+ The normals used for lighting on map tiles.
+
+
+ Holds the current state of the tile. This can be used for filtering.
+
+
+ If enabled, the tile is drawn as highlighted.
+
+
+ A reference to the next block (linked list).
+
+
+ Defines the state for screen blocks (see ).
+
+
+ The normal state of an item.
+
+
+ Specifies that the item should be "hidden". A fast way to remove it from the screen while keeping the sort order.
+
+
+ Defines the item as being a ghost item.
+ A ghost item is ignored in the hit test but still drawn as a normal (highlighted) tile.
+They are used to visualize an insert/map draw operation to the user.
+
+
+ A reference to TBlockInfo.
+
+
+
+