- Fixed cedserver to compile again (using generics now)
- Added multilog dependency to cedserver for easier debugging - Several code cleanups
This commit is contained in:
parent
2fedab62cc
commit
b223f44721
|
@ -295,13 +295,12 @@
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
<SmartLinkUnit Value="True"/>
|
<SmartLinkUnit Value="True"/>
|
||||||
<Optimizations>
|
<Optimizations>
|
||||||
<OptimizationLevel Value="0"/>
|
<OptimizationLevel Value="3"/>
|
||||||
</Optimizations>
|
</Optimizations>
|
||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
<Linking>
|
<Linking>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<GenerateDebugInfo Value="True"/>
|
<UseLineInfoUnit Value="False"/>
|
||||||
<UseHeaptrc Value="True"/>
|
|
||||||
</Debugging>
|
</Debugging>
|
||||||
<LinkSmart Value="True"/>
|
<LinkSmart Value="True"/>
|
||||||
<Options>
|
<Options>
|
||||||
|
|
|
@ -72,7 +72,7 @@ var
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
UClientHandling;
|
Logging, UClientHandling;
|
||||||
|
|
||||||
{$I version.inc}
|
{$I version.inc}
|
||||||
|
|
||||||
|
@ -250,8 +250,12 @@ begin
|
||||||
end;
|
end;
|
||||||
ANetState.LastAction := Now;
|
ANetState.LastAction := Now;
|
||||||
except
|
except
|
||||||
|
on E: Exception do
|
||||||
|
begin
|
||||||
|
Logger.SendException([lcServer], 'Error processing buffer', E);
|
||||||
Writeln(TimeStamp, 'Error processing buffer of client: ', ANetState.Socket.PeerAddress);
|
Writeln(TimeStamp, 'Error processing buffer of client: ', ANetState.Socket.PeerAddress);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEDServer.CheckNetStates;
|
procedure TCEDServer.CheckNetStates;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Portions Copyright 2008 Andreas Schneider
|
* Portions Copyright 2009 Andreas Schneider
|
||||||
*)
|
*)
|
||||||
unit ULandscape;
|
unit ULandscape;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ type
|
||||||
FTiledataProvider: TTiledataProvider;
|
FTiledataProvider: TTiledataProvider;
|
||||||
public
|
public
|
||||||
{ Fields }
|
{ Fields }
|
||||||
Cells: array[0..63] of TList;
|
Cells: array[0..63] of TStaticItemList;
|
||||||
property TiledataProvider: TTiledataProvider read FTiledataProvider write FTiledataProvider;
|
property TiledataProvider: TTiledataProvider read FTiledataProvider write FTiledataProvider;
|
||||||
|
|
||||||
{ Methods }
|
{ Methods }
|
||||||
|
@ -98,7 +98,7 @@ type
|
||||||
procedure OnBlockChanged(ABlock: TMulBlock);
|
procedure OnBlockChanged(ABlock: TMulBlock);
|
||||||
procedure OnRemoveCachedObject(AObject: TObject);
|
procedure OnRemoveCachedObject(AObject: TObject);
|
||||||
function GetMapCell(AX, AY: Word): TMapCell;
|
function GetMapCell(AX, AY: Word): TMapCell;
|
||||||
function GetStaticList(AX, AY: Word): TList;
|
function GetStaticList(AX, AY: Word): TStaticItemList;
|
||||||
function GetBlockSubscriptions(AX, AY: Word): TLinkedList;
|
function GetBlockSubscriptions(AX, AY: Word): TLinkedList;
|
||||||
|
|
||||||
procedure OnDrawMapPacket(ABuffer: TEnhancedMemoryStream;
|
procedure OnDrawMapPacket(ABuffer: TEnhancedMemoryStream;
|
||||||
|
@ -121,7 +121,7 @@ type
|
||||||
property CellWidth: Word read FCellWidth;
|
property CellWidth: Word read FCellWidth;
|
||||||
property CellHeight: Word read FCellHeight;
|
property CellHeight: Word read FCellHeight;
|
||||||
property MapCell[X, Y: Word]: TMapCell read GetMapCell;
|
property MapCell[X, Y: Word]: TMapCell read GetMapCell;
|
||||||
property StaticList[X, Y: Word]: TList read GetStaticList;
|
property StaticList[X, Y: Word]: TStaticItemList read GetStaticList;
|
||||||
property BlockSubscriptions[X, Y: Word]: TLinkedList read GetBlockSubscriptions;
|
property BlockSubscriptions[X, Y: Word]: TLinkedList read GetBlockSubscriptions;
|
||||||
property TiledataProvider: TTiledataProvider read FTiledataProvider;
|
property TiledataProvider: TTiledataProvider read FTiledataProvider;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ type
|
||||||
procedure UpdateRadar(AX, AY: Word);
|
procedure UpdateRadar(AX, AY: Word);
|
||||||
function GetEffectiveAltitude(ATile: TMapCell): ShortInt;
|
function GetEffectiveAltitude(ATile: TMapCell): ShortInt;
|
||||||
function GetLandAlt(AX, AY: Word; ADefault: ShortInt): ShortInt;
|
function GetLandAlt(AX, AY: Word; ADefault: ShortInt): ShortInt;
|
||||||
procedure SortStaticsList(AStatics: TList);
|
procedure SortStaticsList(AStatics: TStaticItemList);
|
||||||
|
|
||||||
procedure Flush;
|
procedure Flush;
|
||||||
procedure SaveBlock(AWorldBlock: TWorldBlock);
|
procedure SaveBlock(AWorldBlock: TWorldBlock);
|
||||||
|
@ -185,13 +185,13 @@ var
|
||||||
block: TMemoryStream;
|
block: TMemoryStream;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FItems := TList.Create;
|
FItems := TStaticItemList.Create(False);
|
||||||
|
|
||||||
FX := AX;
|
FX := AX;
|
||||||
FY := AY;
|
FY := AY;
|
||||||
|
|
||||||
for i := 0 to 63 do
|
for i := 0 to 63 do
|
||||||
Cells[i] := TList.Create;
|
Cells[i] := TStaticItemList.Create(True);
|
||||||
|
|
||||||
if (AData <> nil) and (AIndex.Lookup > 0) and (AIndex.Size > 0) then
|
if (AData <> nil) and (AIndex.Lookup > 0) and (AIndex.Size > 0) then
|
||||||
begin
|
begin
|
||||||
|
@ -220,21 +220,7 @@ begin
|
||||||
FreeAndNil(FItems);
|
FreeAndNil(FItems);
|
||||||
|
|
||||||
for i := 0 to 63 do
|
for i := 0 to 63 do
|
||||||
begin
|
FreeAndNil(Cells[i]);
|
||||||
if Cells[i] <> nil then
|
|
||||||
begin
|
|
||||||
for j := 0 to Cells[i].Count - 1 do
|
|
||||||
begin
|
|
||||||
if Cells[i][j] <> nil then
|
|
||||||
begin
|
|
||||||
TStaticItem(Cells[i][j]).Free;
|
|
||||||
Cells[i][j] := nil;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Cells[i].Free;
|
|
||||||
Cells[i] := nil;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
@ -263,9 +249,8 @@ begin
|
||||||
for j := 0 to Cells[i].Count - 1 do
|
for j := 0 to Cells[i].Count - 1 do
|
||||||
begin
|
begin
|
||||||
FItems.Add(Cells[i].Items[j]);
|
FItems.Add(Cells[i].Items[j]);
|
||||||
TStaticItem(Cells[i].Items[j]).UpdatePriorities(
|
Cells[i].Items[j].UpdatePriorities(
|
||||||
FTiledataProvider.StaticTiles[TStaticItem(Cells[i].Items[j]).TileID],
|
FTiledataProvider.StaticTiles[Cells[i].Items[j].TileID], solver);
|
||||||
solver);
|
|
||||||
Inc(solver);
|
Inc(solver);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -355,16 +340,16 @@ var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i := 0 to Length(FBlockSubscriptions) - 1 do
|
for i := 0 to Length(FBlockSubscriptions) - 1 do
|
||||||
if FBlockSubscriptions[i] <> nil then FreeAndNil(FBlockSubscriptions[i]);
|
FreeAndNil(FBlockSubscriptions[i]);
|
||||||
if FBlockCache <> nil then FreeAndNil(FBlockCache);
|
FreeAndNil(FBlockCache);
|
||||||
if FTiledataProvider <> nil then FreeAndNil(FTiledataProvider);
|
FreeAndNil(FTiledataProvider);
|
||||||
if FRadarMap <> nil then FreeAndNil(FRadarMap);
|
FreeAndNil(FRadarMap);
|
||||||
if FOwnsStreams then
|
if FOwnsStreams then
|
||||||
begin
|
begin
|
||||||
if FMap <> nil then FreeAndNil(FMap);
|
FreeAndNil(FMap);
|
||||||
if FStatics <> nil then FreeAndNil(FStatics);
|
FreeAndNil(FStatics);
|
||||||
if FStaIdx <> nil then FreeAndNil(FStaIdx);
|
FreeAndNil(FStaIdx);
|
||||||
if FTiledata <> nil then FreeAndNil(FTiledata);
|
FreeAndNil(FTiledata);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
RegisterPacketHandler($06, nil);
|
RegisterPacketHandler($06, nil);
|
||||||
|
@ -407,7 +392,7 @@ begin
|
||||||
Result := ADefault;
|
Result := ADefault;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLandscape.GetStaticList(AX, AY: Word): TList;
|
function TLandscape.GetStaticList(AX, AY: Word): TStaticItemList;
|
||||||
var
|
var
|
||||||
block: TSeperatedStaticBlock;
|
block: TSeperatedStaticBlock;
|
||||||
begin
|
begin
|
||||||
|
@ -424,7 +409,8 @@ procedure TLandscape.UpdateRadar(AX, AY: Word);
|
||||||
var
|
var
|
||||||
mapTile: TMapCell;
|
mapTile: TMapCell;
|
||||||
tile: TWorldItem;
|
tile: TWorldItem;
|
||||||
staticItems, tiles: TList;
|
staticItems: TStaticItemList;
|
||||||
|
tiles: TWorldItemList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if (AX mod 8 = 0) and (AY mod 8 = 0) then
|
if (AX mod 8 = 0) and (AY mod 8 = 0) then
|
||||||
|
@ -432,7 +418,7 @@ begin
|
||||||
staticItems := GetStaticList(AX, AY);
|
staticItems := GetStaticList(AX, AY);
|
||||||
if staticItems <> nil then
|
if staticItems <> nil then
|
||||||
begin
|
begin
|
||||||
tiles := TList.Create;
|
tiles := TWorldItemList.Create(False);
|
||||||
mapTile := GetMapCell(AX, AY);
|
mapTile := GetMapCell(AX, AY);
|
||||||
if mapTile <> nil then
|
if mapTile <> nil then
|
||||||
begin
|
begin
|
||||||
|
@ -443,16 +429,16 @@ begin
|
||||||
end;
|
end;
|
||||||
for i := 0 to staticItems.Count - 1 do
|
for i := 0 to staticItems.Count - 1 do
|
||||||
begin
|
begin
|
||||||
TStaticItem(staticItems.Items[i]).UpdatePriorities(
|
staticItems[i].UpdatePriorities(
|
||||||
FTiledataProvider.StaticTiles[TStaticItem(staticItems.Items[i]).TileID],
|
FTiledataProvider.StaticTiles[staticItems[i].TileID],
|
||||||
i + 1);
|
i + 1);
|
||||||
tiles.Add(staticItems.Items[i]);
|
tiles.Add(staticItems[i]);
|
||||||
end;
|
end;
|
||||||
tiles.Sort(@CompareWorldItems);
|
tiles.Sort(@CompareWorldItems);
|
||||||
|
|
||||||
if tiles.Count > 0 then
|
if tiles.Count > 0 then
|
||||||
begin
|
begin
|
||||||
tile := TWorldItem(tiles.Items[tiles.Count - 1]);
|
tile := tiles[tiles.Count - 1];
|
||||||
if tile is TStaticItem then
|
if tile is TStaticItem then
|
||||||
FRadarMap.Update(AX div 8, AY div 8, tile.TileID + $4000)
|
FRadarMap.Update(AX div 8, AY div 8, tile.TileID + $4000)
|
||||||
else
|
else
|
||||||
|
@ -464,15 +450,15 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLandscape.SortStaticsList(AStatics: TList);
|
procedure TLandscape.SortStaticsList(AStatics: TStaticItemList);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i := 0 to AStatics.Count - 1 do
|
for i := 0 to AStatics.Count - 1 do
|
||||||
TStaticItem(AStatics.Items[i]).UpdatePriorities(
|
AStatics[i].UpdatePriorities(
|
||||||
FTiledataProvider.StaticTiles[TStaticItem(AStatics.Items[i]).TileID],
|
FTiledataProvider.StaticTiles[AStatics[i].TileID],
|
||||||
i + 1);
|
i + 1);
|
||||||
AStatics.Sort(@CompareWorldItems);
|
AStatics.Sort(@CompareStaticItems);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLandscape.GetEffectiveAltitude(ATile: TMapCell): ShortInt;
|
function TLandscape.GetEffectiveAltitude(ATile: TMapCell): ShortInt;
|
||||||
|
@ -649,7 +635,7 @@ var
|
||||||
x, y: Word;
|
x, y: Word;
|
||||||
block: TSeperatedStaticBlock;
|
block: TSeperatedStaticBlock;
|
||||||
staticItem: TStaticItem;
|
staticItem: TStaticItem;
|
||||||
targetStaticList: TList;
|
targetStaticList: TStaticItemList;
|
||||||
subscriptions: TLinkedList;
|
subscriptions: TLinkedList;
|
||||||
subscriptionItem: PLinkedItem;
|
subscriptionItem: PLinkedItem;
|
||||||
packet: TInsertStaticPacket;
|
packet: TInsertStaticPacket;
|
||||||
|
@ -689,7 +675,7 @@ procedure TLandscape.OnDeleteStaticPacket(ABuffer: TEnhancedMemoryStream;
|
||||||
var
|
var
|
||||||
block: TSeperatedStaticBlock;
|
block: TSeperatedStaticBlock;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
statics: TList;
|
statics: TStaticItemList;
|
||||||
staticInfo: TStaticInfo;
|
staticInfo: TStaticInfo;
|
||||||
staticItem: TStaticItem;
|
staticItem: TStaticItem;
|
||||||
subscriptions: TLinkedList;
|
subscriptions: TLinkedList;
|
||||||
|
@ -706,20 +692,22 @@ begin
|
||||||
statics := block.Cells[(staticInfo.Y mod 8) * 8 + staticInfo.X mod 8];
|
statics := block.Cells[(staticInfo.Y mod 8) * 8 + staticInfo.X mod 8];
|
||||||
for i := 0 to statics.Count - 1 do
|
for i := 0 to statics.Count - 1 do
|
||||||
begin
|
begin
|
||||||
staticItem := TStaticItem(statics.Items[i]);
|
staticItem := statics[i];
|
||||||
if (staticItem.Z = staticInfo.Z) and
|
if (staticItem.Z = staticInfo.Z) and
|
||||||
(staticItem.TileID = staticInfo.TileID) and
|
(staticItem.TileID = staticInfo.TileID) and
|
||||||
(staticItem.Hue = staticInfo.Hue) then
|
(staticItem.Hue = staticInfo.Hue) then
|
||||||
begin
|
begin
|
||||||
packet := TDeleteStaticPacket.Create(staticItem);
|
packet := TDeleteStaticPacket.Create(staticItem);
|
||||||
|
|
||||||
statics.Delete(i);
|
|
||||||
staticItem.Delete;
|
staticItem.Delete;
|
||||||
|
statics.Delete(i);
|
||||||
|
|
||||||
subscriptions := FBlockSubscriptions[(staticInfo.Y div 8) * FWidth + (staticInfo.X div 8)];
|
subscriptions := FBlockSubscriptions[(staticInfo.Y div 8) * FWidth +
|
||||||
|
(staticInfo.X div 8)];
|
||||||
subscriptionItem := nil;
|
subscriptionItem := nil;
|
||||||
while subscriptions.Iterate(subscriptionItem) do
|
while subscriptions.Iterate(subscriptionItem) do
|
||||||
CEDServerInstance.SendPacket(TNetState(subscriptionItem^.Data), packet, False);
|
CEDServerInstance.SendPacket(TNetState(subscriptionItem^.Data),
|
||||||
|
packet, False);
|
||||||
packet.Free;
|
packet.Free;
|
||||||
|
|
||||||
UpdateRadar(staticInfo.X, staticInfo.Y);
|
UpdateRadar(staticInfo.X, staticInfo.Y);
|
||||||
|
@ -735,7 +723,7 @@ procedure TLandscape.OnElevateStaticPacket(ABuffer: TEnhancedMemoryStream;
|
||||||
var
|
var
|
||||||
block: TSeperatedStaticBlock;
|
block: TSeperatedStaticBlock;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
statics: TList;
|
statics: TStaticItemList;
|
||||||
staticInfo: TStaticInfo;
|
staticInfo: TStaticInfo;
|
||||||
staticItem: TStaticItem;
|
staticItem: TStaticItem;
|
||||||
newZ: ShortInt;
|
newZ: ShortInt;
|
||||||
|
@ -753,7 +741,7 @@ begin
|
||||||
statics := block.Cells[(staticInfo.Y mod 8) * 8 + staticInfo.X mod 8];
|
statics := block.Cells[(staticInfo.Y mod 8) * 8 + staticInfo.X mod 8];
|
||||||
for i := 0 to statics.Count - 1 do
|
for i := 0 to statics.Count - 1 do
|
||||||
begin
|
begin
|
||||||
staticItem := TStaticItem(statics.Items[i]);
|
staticItem := statics[i];
|
||||||
if (staticItem.Z = staticInfo.Z) and
|
if (staticItem.Z = staticInfo.Z) and
|
||||||
(staticItem.TileID = staticInfo.TileID) and
|
(staticItem.TileID = staticInfo.TileID) and
|
||||||
(staticItem.Hue = staticInfo.Hue) then
|
(staticItem.Hue = staticInfo.Hue) then
|
||||||
|
@ -764,10 +752,12 @@ begin
|
||||||
staticItem.Z := newZ;
|
staticItem.Z := newZ;
|
||||||
SortStaticsList(statics);
|
SortStaticsList(statics);
|
||||||
|
|
||||||
subscriptions := FBlockSubscriptions[(staticInfo.Y div 8) * FWidth + (staticInfo.X div 8)];
|
subscriptions := FBlockSubscriptions[(staticInfo.Y div 8) * FWidth +
|
||||||
|
(staticInfo.X div 8)];
|
||||||
subscriptionItem := nil;
|
subscriptionItem := nil;
|
||||||
while subscriptions.Iterate(subscriptionItem) do
|
while subscriptions.Iterate(subscriptionItem) do
|
||||||
CEDServerInstance.SendPacket(TNetState(subscriptionItem^.Data), packet, False);
|
CEDServerInstance.SendPacket(TNetState(subscriptionItem^.Data),
|
||||||
|
packet, False);
|
||||||
packet.Free;
|
packet.Free;
|
||||||
|
|
||||||
UpdateRadar(staticInfo.X, staticInfo.Y);
|
UpdateRadar(staticInfo.X, staticInfo.Y);
|
||||||
|
@ -784,7 +774,7 @@ var
|
||||||
sourceBlock, targetBlock: TSeperatedStaticBlock;
|
sourceBlock, targetBlock: TSeperatedStaticBlock;
|
||||||
sourceSubscriptions, targetSubscriptions: TList;
|
sourceSubscriptions, targetSubscriptions: TList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
statics: TList;
|
statics: TStaticItemList;
|
||||||
staticInfo: TStaticInfo;
|
staticInfo: TStaticInfo;
|
||||||
staticItem: TStaticItem;
|
staticItem: TStaticItem;
|
||||||
newX, newY: Word;
|
newX, newY: Word;
|
||||||
|
@ -816,7 +806,7 @@ begin
|
||||||
i := 0;
|
i := 0;
|
||||||
while (i < statics.Count) and (staticItem = nil) do
|
while (i < statics.Count) and (staticItem = nil) do
|
||||||
begin
|
begin
|
||||||
staticItem := TStaticItem(statics.Items[i]);
|
staticItem := statics[i];
|
||||||
if (staticItem.Z <> staticInfo.Z) or
|
if (staticItem.Z <> staticInfo.Z) or
|
||||||
(staticItem.TileID <> staticInfo.TileID) or
|
(staticItem.TileID <> staticInfo.TileID) or
|
||||||
(staticItem.Hue <> staticInfo.Hue) then
|
(staticItem.Hue <> staticInfo.Hue) then
|
||||||
|
@ -831,7 +821,10 @@ begin
|
||||||
deletePacket := TDeleteStaticPacket.Create(staticItem);
|
deletePacket := TDeleteStaticPacket.Create(staticItem);
|
||||||
movePacket := TMoveStaticPacket.Create(staticItem, newX, newY);
|
movePacket := TMoveStaticPacket.Create(staticItem, newX, newY);
|
||||||
|
|
||||||
statics.Remove(staticItem);
|
i := statics.IndexOf(staticItem);
|
||||||
|
statics[i] := nil;
|
||||||
|
statics.Delete(i);
|
||||||
|
|
||||||
statics := targetBlock.Cells[(newY mod 8) * 8 + newX mod 8];
|
statics := targetBlock.Cells[(newY mod 8) * 8 + newX mod 8];
|
||||||
statics.Add(staticItem);
|
statics.Add(staticItem);
|
||||||
staticItem.UpdatePos(newX, newY, staticItem.Z);
|
staticItem.UpdatePos(newX, newY, staticItem.Z);
|
||||||
|
@ -882,7 +875,7 @@ procedure TLandscape.OnHueStaticPacket(ABuffer: TEnhancedMemoryStream;
|
||||||
var
|
var
|
||||||
block: TSeperatedStaticBlock;
|
block: TSeperatedStaticBlock;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
statics: TList;
|
statics: TStaticItemList;
|
||||||
staticInfo: TStaticInfo;
|
staticInfo: TStaticInfo;
|
||||||
staticItem: TStaticItem;
|
staticItem: TStaticItem;
|
||||||
newHue: Word;
|
newHue: Word;
|
||||||
|
@ -900,7 +893,7 @@ begin
|
||||||
statics := block.Cells[(staticInfo.Y mod 8) * 8 + staticInfo.X mod 8];
|
statics := block.Cells[(staticInfo.Y mod 8) * 8 + staticInfo.X mod 8];
|
||||||
for i := 0 to statics.Count - 1 do
|
for i := 0 to statics.Count - 1 do
|
||||||
begin
|
begin
|
||||||
staticItem := TStaticItem(statics.Items[i]);
|
staticItem := statics[i];
|
||||||
if (staticItem.Z = staticInfo.Z) and
|
if (staticItem.Z = staticInfo.Z) and
|
||||||
(staticItem.TileID = staticInfo.TileID) and
|
(staticItem.TileID = staticInfo.TileID) and
|
||||||
(staticItem.Hue = staticInfo.Hue) then
|
(staticItem.Hue = staticInfo.Hue) then
|
||||||
|
@ -935,7 +928,7 @@ var
|
||||||
emptyBits: TBits;
|
emptyBits: TBits;
|
||||||
bitMask: array of TBits;
|
bitMask: array of TBits;
|
||||||
mapTile: TMapCell;
|
mapTile: TMapCell;
|
||||||
statics: TList;
|
statics: TStaticItemList;
|
||||||
operations: TList;
|
operations: TList;
|
||||||
clients: array of record
|
clients: array of record
|
||||||
NetState: TNetState;
|
NetState: TNetState;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Portions Copyright 2007 Andreas Schneider
|
* Portions Copyright 2009 Andreas Schneider
|
||||||
*)
|
*)
|
||||||
unit ULargeScaleOperations;
|
unit ULargeScaleOperations;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ type
|
||||||
protected
|
protected
|
||||||
FLandscape: TLandscape;
|
FLandscape: TLandscape;
|
||||||
public
|
public
|
||||||
procedure Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits); virtual; abstract;
|
AAdditionalAffectedBlocks: TBits); virtual; abstract;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ type
|
||||||
public
|
public
|
||||||
property OffsetX: Integer read FOffsetX;
|
property OffsetX: Integer read FOffsetX;
|
||||||
property OffsetY: Integer read FOffsetY;
|
property OffsetY: Integer read FOffsetY;
|
||||||
procedure Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits); override;
|
AAdditionalAffectedBlocks: TBits); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ type
|
||||||
FMaxZ: ShortInt;
|
FMaxZ: ShortInt;
|
||||||
FRelativeZ: ShortInt;
|
FRelativeZ: ShortInt;
|
||||||
public
|
public
|
||||||
procedure Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits); override;
|
AAdditionalAffectedBlocks: TBits); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ type
|
||||||
protected
|
protected
|
||||||
FTileIDs: array of Word;
|
FTileIDs: array of Word;
|
||||||
public
|
public
|
||||||
procedure Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits); override;
|
AAdditionalAffectedBlocks: TBits); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ type
|
||||||
FMinZ: ShortInt;
|
FMinZ: ShortInt;
|
||||||
FMaxZ: ShortInt;
|
FMaxZ: ShortInt;
|
||||||
public
|
public
|
||||||
procedure Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits); override;
|
AAdditionalAffectedBlocks: TBits); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ type
|
||||||
FPlacementType: TStaticsPlacement;
|
FPlacementType: TStaticsPlacement;
|
||||||
FFixZ: ShortInt;
|
FFixZ: ShortInt;
|
||||||
public
|
public
|
||||||
procedure Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits); override;
|
AAdditionalAffectedBlocks: TBits); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -145,12 +145,12 @@ begin
|
||||||
FErase := AData.ReadBoolean;
|
FErase := AData.ReadBoolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLSCopyMove.Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure TLSCopyMove.Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits);
|
AAdditionalAffectedBlocks: TBits);
|
||||||
var
|
var
|
||||||
x, y: Word;
|
x, y: Word;
|
||||||
targetCell: TMapCell;
|
targetCell: TMapCell;
|
||||||
targetStatics: TList;
|
targetStatics: TStaticItemList;
|
||||||
targetStaticsBlock: TSeperatedStaticBlock;
|
targetStaticsBlock: TSeperatedStaticBlock;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
staticItem: TStaticItem;
|
staticItem: TStaticItem;
|
||||||
|
@ -164,9 +164,7 @@ begin
|
||||||
if FErase then
|
if FErase then
|
||||||
begin
|
begin
|
||||||
for i := 0 to targetStatics.Count - 1 do
|
for i := 0 to targetStatics.Count - 1 do
|
||||||
begin
|
targetStatics[i].Delete;
|
||||||
TStaticItem(targetStatics.Items[i]).Delete;
|
|
||||||
end;
|
|
||||||
targetStatics.Clear;
|
targetStatics.Clear;
|
||||||
end;
|
end;
|
||||||
targetCell.TileID := AMapCell.TileID;
|
targetCell.TileID := AMapCell.TileID;
|
||||||
|
@ -179,23 +177,22 @@ begin
|
||||||
staticItem := TStaticItem.Create(nil, nil, 0, 0);
|
staticItem := TStaticItem.Create(nil, nil, 0, 0);
|
||||||
staticItem.X := x;
|
staticItem.X := x;
|
||||||
staticItem.Y := y;
|
staticItem.Y := y;
|
||||||
staticItem.Z := TStaticItem(AStatics.Items[i]).Z;
|
staticItem.Z := AStatics[i].Z;
|
||||||
staticItem.TileID := TStaticItem(AStatics.Items[i]).TileID;
|
staticItem.TileID := AStatics[i].TileID;
|
||||||
staticItem.Hue := TStaticItem(AStatics.Items[i]).Hue;
|
staticItem.Hue := AStatics[i].Hue;
|
||||||
staticItem.Owner := targetStaticsBlock;
|
staticItem.Owner := targetStaticsBlock;
|
||||||
targetStatics.Add(staticItem);
|
targetStatics.Add(staticItem);
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
{for i := 0 to AStatics.Count - 1 do}
|
for i := 0 to AStatics.Count - 1 do
|
||||||
while AStatics.Count > 0 do
|
|
||||||
begin
|
begin
|
||||||
targetStatics.Add(AStatics.Items[0]);
|
targetStatics.Add(AStatics[i]);
|
||||||
TStaticItem(AStatics.Items[0]).UpdatePos(x, y, TStaticItem(AStatics.Items[0]).Z);
|
AStatics[i].UpdatePos(x, y, AStatics[i].Z);
|
||||||
TStaticItem(AStatics.Items[0]).Owner := targetStaticsBlock;
|
AStatics[i].Owner := targetStaticsBlock;
|
||||||
AStatics.Delete(0);
|
AStatics[i] := nil;
|
||||||
end;
|
end;
|
||||||
//AStatics.Clear;
|
AStatics.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FLandscape.SortStaticsList(targetStatics);
|
FLandscape.SortStaticsList(targetStatics);
|
||||||
|
@ -222,7 +219,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLSSetAltitude.Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure TLSSetAltitude.Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits);
|
AAdditionalAffectedBlocks: TBits);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
@ -243,7 +240,7 @@ begin
|
||||||
|
|
||||||
for i := 0 to AStatics.Count - 1 do
|
for i := 0 to AStatics.Count - 1 do
|
||||||
begin
|
begin
|
||||||
static := TStaticItem(AStatics.Items[i]);
|
static := AStatics[i];
|
||||||
static.Z := EnsureRange(static.Z + diff, -128, 127);
|
static.Z := EnsureRange(static.Z + diff, -128, 127);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -261,7 +258,7 @@ begin
|
||||||
AData.Read(FTileIDs[0], count * SizeOf(Word));
|
AData.Read(FTileIDs[0], count * SizeOf(Word));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLSDrawTerrain.Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure TLSDrawTerrain.Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits);
|
AAdditionalAffectedBlocks: TBits);
|
||||||
begin
|
begin
|
||||||
if Length(FTileIDs) > 0 then
|
if Length(FTileIDs) > 0 then
|
||||||
|
@ -283,7 +280,7 @@ begin
|
||||||
FMaxZ := AData.ReadShortInt;
|
FMaxZ := AData.ReadShortInt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLSDeleteStatics.Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure TLSDeleteStatics.Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits);
|
AAdditionalAffectedBlocks: TBits);
|
||||||
var
|
var
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
|
@ -292,7 +289,7 @@ begin
|
||||||
i := 0;
|
i := 0;
|
||||||
while i < AStatics.Count do
|
while i < AStatics.Count do
|
||||||
begin
|
begin
|
||||||
static := TStaticItem(AStatics.Items[i]);
|
static := AStatics[i];
|
||||||
if InRange(static.Z, FMinZ, FMaxZ) then
|
if InRange(static.Z, FMinZ, FMaxZ) then
|
||||||
begin
|
begin
|
||||||
if Length(FTileIDs) > 0 then
|
if Length(FTileIDs) > 0 then
|
||||||
|
@ -301,8 +298,8 @@ begin
|
||||||
begin
|
begin
|
||||||
if static.TileID = FTileIDs[j] - $4000 then
|
if static.TileID = FTileIDs[j] - $4000 then
|
||||||
begin
|
begin
|
||||||
AStatics.Delete(i);
|
|
||||||
static.Delete;
|
static.Delete;
|
||||||
|
AStatics.Delete(i);
|
||||||
Dec(i);
|
Dec(i);
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
|
@ -310,8 +307,8 @@ begin
|
||||||
Inc(i);
|
Inc(i);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
AStatics.Delete(i);
|
|
||||||
static.Delete;
|
static.Delete;
|
||||||
|
AStatics.Delete(i);
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
Inc(i);
|
Inc(i);
|
||||||
|
@ -335,7 +332,7 @@ begin
|
||||||
FFixZ := AData.ReadShortInt;
|
FFixZ := AData.ReadShortInt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLSInsertStatics.Apply(AMapCell: TMapCell; AStatics: TList;
|
procedure TLSInsertStatics.Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
|
||||||
AAdditionalAffectedBlocks: TBits);
|
AAdditionalAffectedBlocks: TBits);
|
||||||
var
|
var
|
||||||
staticItem, static: TStaticItem;
|
staticItem, static: TStaticItem;
|
||||||
|
@ -360,8 +357,10 @@ begin
|
||||||
topZ := AMapCell.Z;
|
topZ := AMapCell.Z;
|
||||||
for i := 0 to AStatics.Count - 1 do
|
for i := 0 to AStatics.Count - 1 do
|
||||||
begin
|
begin
|
||||||
static := TStaticItem(AStatics.Items[i]);
|
static := AStatics[i];
|
||||||
staticTop := EnsureRange(static.Z + CEDServerInstance.Landscape.TiledataProvider.StaticTiles[static.TileID].Height, -128, 127);
|
staticTop := EnsureRange(static.Z +
|
||||||
|
CEDServerInstance.Landscape.TiledataProvider.StaticTiles[static.TileID].Height,
|
||||||
|
-128, 127);
|
||||||
if staticTop > topZ then topZ := staticTop;
|
if staticTop > topZ then topZ := staticTop;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -372,8 +371,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AStatics.Add(staticItem);
|
AStatics.Add(staticItem);
|
||||||
staticItem.Owner := CEDServerInstance.Landscape.GetStaticBlock(staticItem.X div 8,
|
staticItem.Owner := CEDServerInstance.Landscape.GetStaticBlock(
|
||||||
staticItem.Y div 8);
|
staticItem.X div 8, staticItem.Y div 8);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -21,13 +21,16 @@
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<LaunchingApplication Use="True" PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="2">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="lnetbase"/>
|
<PackageName Value="multiloglaz"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<PackageName Value="lnetbase"/>
|
||||||
|
</Item2>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="15">
|
<Units Count="15">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
|
@ -126,19 +129,18 @@
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
<SmartLinkUnit Value="True"/>
|
<SmartLinkUnit Value="True"/>
|
||||||
<Optimizations>
|
<Optimizations>
|
||||||
<OptimizationLevel Value="3"/>
|
<OptimizationLevel Value="0"/>
|
||||||
</Optimizations>
|
</Optimizations>
|
||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
<Linking>
|
<Linking>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<UseLineInfoUnit Value="False"/>
|
<GenerateDebugInfo Value="True"/>
|
||||||
<StripSymbols Value="True"/>
|
<UseHeaptrc Value="True"/>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
<LinkSmart Value="True"/>
|
<LinkSmart Value="True"/>
|
||||||
</Linking>
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
<CustomOptions Value="-FE..\bin\
|
<CustomOptions Value="-FE../bin/
"/>
|
||||||
"/>
|
|
||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
|
|
|
@ -33,7 +33,7 @@ uses
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
SysUtils, Classes, lnetbase, UConfig, UCEDServer, URadarMap,
|
SysUtils, Classes, lnetbase, UConfig, UCEDServer, URadarMap,
|
||||||
ULargeScaleOperations, UPackets, UAdminHandling, UClientHandling, ULandscape,
|
ULargeScaleOperations, UPackets, UAdminHandling, UClientHandling, ULandscape,
|
||||||
UPacketHandlers, URegions, UStatics;
|
UPacketHandlers, URegions, UStatics, Logging;
|
||||||
|
|
||||||
{$I version.inc}
|
{$I version.inc}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue