From: Ketmar Dark Date: Sat, 2 Sep 2017 00:08:14 +0000 (+0300) Subject: migrating from PanelIDs to panel GUIDs; part two X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=b39f879ac1eb4bf4b7782c4b2fc3f83bd5f99816;p=d2df-sdl.git migrating from PanelIDs to panel GUIDs; part two --- diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 00f39a1..642beaa 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -241,21 +241,8 @@ const FLAG_SIGNATURE = $47414C46; // 'FLAG' -{ -type - THashIntPanel = specialize THashBase; - -function hashNewIntPanel (): THashIntPanel; -begin - result := THashIntPanel.Create(hiihash, hiiequ); -end; -} - - var - //panByGUID: THashIntPanel = nil; panByGUID: array of TPanel = nil; - //panLastGUID: Integer = 0; // ////////////////////////////////////////////////////////////////////////// // @@ -769,8 +756,7 @@ begin PanelArray := nil; end; -function CreatePanel(PanelRec: TDynRecord; AddTextures: TAddTextureArray; - CurTex: Integer; sav: Boolean): Integer; +function CreatePanel (PanelRec: TDynRecord; AddTextures: TAddTextureArray; CurTex: Integer; sav: Boolean): Integer; var len: Integer; panels: ^TPanelArray; @@ -795,20 +781,22 @@ begin len := Length(panels^); SetLength(panels^, len+1); - //Inc(panLastGUID); pguid := Length(panByGUID); SetLength(panByGUID, pguid+1); //FIXME! pan := TPanel.Create(PanelRec, AddTextures, CurTex, Textures, pguid); + assert(pguid >= 0); + assert(pguid < Length(panByGUID)); + panByGUID[pguid] := pan; panels^[len] := pan; pan.arrIdx := len; pan.proxyId := -1; pan.tag := panelTypeToTag(PanelRec.PanelType); if sav then pan.SaveIt := True; - PanelRec.user['panel_guid'] := pan.guid; - //panByGUID.put(pan.guid, pan); + PanelRec.user['panel_guid'] := pguid; - result := len; + //result := len; + result := pguid; end; @@ -1601,9 +1589,6 @@ begin gCurrentMap.Free(); gCurrentMap := nil; - //panByGUID.Free(); - //panByGUID := hashNewIntPanel(); - //panLastGUID := 0; panByGUID := nil; Result := False; @@ -1979,10 +1964,9 @@ begin //e_LogWritefln('PANADD: pannum=%s', [pannum]); - // Ñîçäàåì ïàíåëü è çàïîìèíàåì åå íîìåð + // Ñîçäàåì ïàíåëü è çàïîìèíàåì åå GUID PanelID := CreatePanel(rec, AddTextures, CurTex, trigRef); - //e_LogWritefln('panel #%s of type %s got id #%s', [pannum, rec.PanelType, PanelID]); - // set 'gamePanelId' field to panel id + //e_LogWritefln('panel #%s of type %s got guid #%s', [pannum, rec.PanelType, PanelID]); rec.userPanelId := PanelID; // remember game panel id, we'll fix triggers later // setup lifts @@ -2363,9 +2347,6 @@ begin BadTextNameHash := nil; end; - //panByGUID.Free(); - //panByGUID := nil; - //panLastGUID := 0; panByGUID := nil; FreePanelArray(gWalls); @@ -2427,21 +2408,21 @@ begin if gGameSettings.GameMode = GM_CTF then begin for a := FLAG_RED to FLAG_BLUE do + begin if not (gFlags[a].State in [FLAG_STATE_NONE, FLAG_STATE_CAPTURED]) then + begin with gFlags[a] do begin - if gFlags[a].Animation <> nil then - gFlags[a].Animation.Update(); + if gFlags[a].Animation <> nil then gFlags[a].Animation.Update(); m := g_Obj_Move(@Obj, True, True); - if gTime mod (GAME_TICK*2) <> 0 then - Continue; + if gTime mod (GAME_TICK*2) <> 0 then Continue; - // Ñîïðîòèâëåíèå âîçäóõà: + // Ñîïðîòèâëåíèå âîçäóõà Obj.Vel.X := z_dec(Obj.Vel.X, 1); - // Òàéìàóò ïîòåðÿííîãî ôëàãà, ëèáî îí âûïàë çà êàðòó: + // Òàéìàóò ïîòåðÿííîãî ôëàãà, ëèáî îí âûïàë çà êàðòó if ((Count = 0) or ByteBool(m and MOVE_FALLOUT)) and g_Game_IsServer then begin g_Map_ResetFlag(a); @@ -2457,30 +2438,28 @@ begin Continue; end; - if Count > 0 then - Count := Count - 1; + if Count > 0 then Count -= 1; - // Èãðîê áåðåò ôëàã: + // Èãðîê áåðåò ôëàã if gPlayers <> nil then begin j := Random(Length(gPlayers)) - 1; - for d := 0 to High(gPlayers) do begin Inc(j); - if j > High(gPlayers) then - j := 0; - + if j > High(gPlayers) then j := 0; if gPlayers[j] <> nil then - if gPlayers[j].Live and - g_Obj_Collide(@Obj, @gPlayers[j].Obj) then + begin + if gPlayers[j].Live and g_Obj_Collide(@Obj, @gPlayers[j].Obj) then begin - if gPlayers[j].GetFlag(a) then - Break; + if gPlayers[j].GetFlag(a) then Break; end; + end; end; end; end; + end; + end; end; end; diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index 437d1f6..1b52a64 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.pas @@ -89,20 +89,6 @@ procedure g_Triggers_Free(); procedure g_Triggers_SaveState(var Mem: TBinMemoryWriter); procedure g_Triggers_LoadState(var Mem: TBinMemoryReader); -function tr_Message(MKind: Integer; MText: string; MSendTo: Integer; MTime: Integer; ActivateUID: Integer): Boolean; - -{ -function tr_CloseDoor (PanelGUID: Integer; NoSound: Boolean; d2d: Boolean): Boolean; -function tr_OpenDoor (PanelGUID: Integer; NoSound: Boolean; d2d: Boolean): Boolean; -procedure tr_CloseTrap (PanelGUID: Integer; NoSound: Boolean; d2d: Boolean); -function tr_SetLift (PanelGUID: Integer; d: Integer; NoSound: Boolean; d2d: Boolean): Boolean; - -function tr_Teleport (ActivateUID: Integer; TX, TY: Integer; TDir: Integer; Silent: Boolean; D2D: Boolean): Boolean; -function tr_Push (ActivateUID: Integer; VX, VY: Integer; ResetVel: Boolean): Boolean; - -procedure tr_MakeEffect (X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean); -function tr_SpawnShot (ShotType: Integer; wx, wy, dx, dy: Integer; ShotSound: Boolean; ShotTarget: Word): Integer; -} var gTriggerClientID: Integer = 0; @@ -110,6 +96,7 @@ var gSecretsCount: Integer = 0; gMonstersSpawned: array of LongInt = nil; + implementation uses @@ -251,6 +238,16 @@ var begin pan := g_Map_PanelByGUID(PanelGUID); + { + if (pan = nil) then + begin + e_LogWritefln('tr_CloseTrap: pguid=%s; NO PANEL!', [PanelGUID], MSG_WARNING); + end + else + begin + e_LogWritefln('tr_CloseTrap: pguid=%s; isGWall=%s; arrIdx=%s', [PanelGUID, pan.isGWall, pan.arrIdx]); + end; + } if (pan = nil) or not pan.isGWall then exit; //!FIXME!TRIGANY! PanelID := pan.arrIdx;