From 1e84b76c63aadeeb31a9fe60f7c7b17cdad81444 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 18 Dec 2009 01:53:09 +0100 Subject: [PATCH] - Added external nodraw definition --- Client/ULandscape.pas | 44 ++++++++++++++++++++++++++++++++++++++----- Client/UfrmMain.pas | 7 +++++++ bin/nodraw.txt | 17 +++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 bin/nodraw.txt diff --git a/Client/ULandscape.pas b/Client/ULandscape.pas index 33868bf..272ca19 100644 --- a/Client/ULandscape.pas +++ b/Client/ULandscape.pas @@ -183,6 +183,7 @@ type FOnStaticHued: TStaticChangedEvent; FOpenRequests: TBits; FWriteMap: TBits; + FDrawMap: TBits; FMaxStaticID: Cardinal; { Methods } function GetMapBlock(AX, AY: Word): TMapBlock; @@ -228,6 +229,7 @@ type function GetEffectiveAltitude(ATile: TMapCell): ShortInt; function GetLandAlt(AX, AY: Word; ADefault: ShortInt): ShortInt; procedure GetNormals(AX, AY: Word; var ANormals: TNormals); + procedure LoadNoDrawMap(AFileName: String); procedure MoveStatic(AStatic: TStaticItem; AX, AY: Word); procedure PrepareBlocks(AX1, AY1, AX2, AY2: Word); procedure UpdateBlockAccess; @@ -601,6 +603,10 @@ begin Logger.Send([lcClient, lcInfo], 'Landscape recognizes $%x StaticTile IDs.', [FMaxStaticId]); + FDrawMap := TBits.Create($4000 + FMaxStaticID); + for i := 0 to FDrawMap.Size - 1 do + FDrawMap[i] := True; + RegisterPacketHandler($04, TPacketHandler.Create(0, @OnBlocksPacket)); RegisterPacketHandler($06, TPacketHandler.Create(8, @OnDrawMapPacket)); RegisterPacketHandler($07, TPacketHandler.Create(10, @OnInsertStaticPacket)); @@ -620,6 +626,7 @@ begin FreeAndNil(FOpenRequests); FreeAndNil(FWriteMap); + FreeAndNil(FDrawMap); RegisterPacketHandler($04, nil); RegisterPacketHandler($06, nil); @@ -947,6 +954,7 @@ var drawStatics: TStaticItemList; i, x, y: Integer; tempDrawList: TWorldItemList; + staticTileData: TStaticTiledata; begin ADrawList.Clear; tempDrawList := TWorldItemList.Create(False);; @@ -957,7 +965,7 @@ begin if AMap then begin drawMapCell := GetMapCell(x, y); - if (drawMapCell <> nil) and (ANoDraw or (drawMapCell.TileID > 2)) then + if (drawMapCell <> nil) and (ANoDraw or FDrawMap[drawMapCell.TileID]) then begin drawMapCell.Priority := GetEffectiveAltitude(drawMapCell); drawMapCell.PriorityBonus := 0; @@ -972,10 +980,13 @@ begin if drawStatics <> nil then for i := 0 to drawStatics.Count - 1 do begin - drawStatics[i].UpdatePriorities( - ResMan.Tiledata.StaticTiles[drawStatics[i].TileID], - ADrawList.GetSerial); - tempDrawList.Add(drawStatics[i]); + staticTileData := ResMan.Tiledata.StaticTiles[drawStatics[i].TileID]; + if ANoDraw or FDrawMap[drawStatics[i].TileID + $4000] then + begin + drawStatics[i].UpdatePriorities(staticTileData, + ADrawList.GetSerial); + tempDrawList.Add(drawStatics[i]); + end; end; end; end; @@ -1098,6 +1109,29 @@ begin ANormals[3] := VectorNorm(VectorAdd(VectorAdd(VectorAdd(north, west), east), south)); end; +procedure TLandscape.LoadNoDrawMap(AFileName: String); +var + noDrawFile: TextFile; + line: String; + id: Integer; +begin + AssignFile(noDrawFile, AFileName); + Reset(noDrawFile); + while not EOF(noDrawFile) do + begin + ReadLn(noDrawFile, line); + if TryStrToInt(Copy(line, 2, Length(line)), id) then + begin + if line[1] = 'S' then + Inc(id, $4000); + + if id < FDrawMap.Size then + FDrawMap[id] := False; + end; + end; + CloseFile(noDrawFile); +end; + procedure TLandscape.MoveStatic(AStatic: TStaticItem; AX, AY: Word); var sourceBlock, targetBlock: TSeperatedStaticBlock; diff --git a/Client/UfrmMain.pas b/Client/UfrmMain.pas index 7a1d11c..9d07dec 100644 --- a/Client/UfrmMain.pas +++ b/Client/UfrmMain.pas @@ -857,6 +857,13 @@ begin FLandscape.OnStaticHued := @OnStaticHued; FLandscape.OnStaticInserted := @OnStaticInserted; + if FileExists(FAppDir + 'nodraw.txt') then + begin + acNoDraw.Enabled := True; + FLandscape.LoadNoDrawMap(FAppDir + 'nodraw.txt'); + end else + acNoDraw.Enabled := False; + FTextureManager := TLandTextureManager.Create; FScreenBuffer := TScreenBuffer.Create; FScreenBufferState := []; diff --git a/bin/nodraw.txt b/bin/nodraw.txt new file mode 100644 index 0000000..ae9264d --- /dev/null +++ b/bin/nodraw.txt @@ -0,0 +1,17 @@ +T$2 +S$1 +S$2198 +S$2199 +S$219A +S$219B +S$219C +S$219D +S$219E +S$219F +S$21A0 +S$21A1 +S$21A2 +S$21A3 +S$21A4 +S$21BC +S$5690