- Added handling of new blocks (OnNewBlock event)

This commit is contained in:
Andreas Schneider 2009-08-03 00:29:55 +02:00
parent 2e16269397
commit 1bc9ad3fe1
2 changed files with 15 additions and 3 deletions

View File

@ -497,6 +497,7 @@ begin
FBlockCache.OnRemoveObject := @OnRemoveCachedObject;
FOnChange := nil;
FOnNewBlock := nil;
FOnStaticDeleted := nil;
FOnStaticElevated := nil;
FOnStaticHued := nil;
@ -606,6 +607,7 @@ var
coords: TBlockCoords;
count: Word;
id: Integer;
block: TBlock;
begin
index := TGenericIndex.Create(nil);
while ABuffer.Position < ABuffer.Size do
@ -623,12 +625,14 @@ begin
statics := TSeperatedStaticBlock.Create(ABuffer, index, coords.X, coords.Y);
FBlockCache.RemoveID(id);
FBlockCache.StoreID(id, TBlock.Create(map, statics));
block := TBlock.Create(map, statics);
FBlockCache.StoreID(id, block);
FOpenRequests[coords.Y * FWidth + coords.X] := False;
if Assigned(FOnNewBlock) then FOnNewBlock(block);
end;
index.Free;
if Assigned(FOnChange) then FOnChange;
end;
procedure TLandscape.OnDrawMapPacket(ABuffer: TEnhancedMemoryStream);

View File

@ -316,6 +316,7 @@ type
{ Events }
procedure OnClientHandlingPacket(ABuffer: TEnhancedMemoryStream);
procedure OnLandscapeChanged;
procedure OnNewBlock(ABlock: TBlock);
procedure OnStaticDeleted(AStaticItem: TStaticItem);
procedure OnStaticElevated(AStaticItem: TStaticItem);
procedure OnStaticInserted(AStaticItem: TStaticItem);
@ -722,6 +723,7 @@ var
begin
FLandscape := ResMan.Landscape;
FLandscape.OnChange := @OnLandscapeChanged;
FLandscape.OnNewBlock := @OnNewBlock;
FLandscape.OnStaticDeleted := @OnStaticDeleted;
FLandscape.OnStaticElevated := @OnStaticElevated;
FLandscape.OnStaticInserted := @OnStaticInserted;
@ -1790,7 +1792,6 @@ begin
item := blockInfo^.Item;
//TODO : implement CanBeEdited handling (dmNetwork.CanWrite.....)
if acSelect.Checked or item.CanBeEdited then
begin
intensity := 1.0;
@ -2025,9 +2026,15 @@ begin
UpdateCurrentTile;
end;
procedure TfrmMain.OnNewBlock(ABlock: TBlock);
begin
InvalidateScreenBuffer;
end;
procedure TfrmMain.OnStaticDeleted(AStaticItem: TStaticItem);
begin
FScreenBuffer.Delete(AStaticItem);
UpdateCurrentTile;
end;
procedure TfrmMain.OnStaticElevated(AStaticItem: TStaticItem);
@ -2042,6 +2049,7 @@ begin
begin
AStaticItem.PrioritySolver := FScreenBuffer.GetSerial;
PrepareScreenBlock(FScreenBuffer.Insert(AStaticItem));
UpdateCurrentTile;
end;
end;