diff --git a/Client/ULandscape.pas b/Client/ULandscape.pas index a95b37a..20e2e03 100644 --- a/Client/ULandscape.pas +++ b/Client/ULandscape.pas @@ -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); diff --git a/Client/UfrmMain.pas b/Client/UfrmMain.pas index 0aad479..39a78f9 100644 --- a/Client/UfrmMain.pas +++ b/Client/UfrmMain.pas @@ -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;