From: fgsfds Date: Tue, 6 Feb 2018 20:35:42 +0000 (+0300) Subject: fixed texture trigger bug X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=785fe3df9d3c82df346034780156cb63bae43ff7;p=d2df-sdl.git fixed texture trigger bug --- diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 1ddbffd..c4e818f 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -1338,6 +1338,7 @@ end; function CreateTrigger (amapIdx: Integer; Trigger: TDynRecord; atpanid, atrigpanid: Integer): Integer; var _trigger: TTrigger; + tp: TPanel; begin result := -1; if g_Game_IsClient and not (Trigger.TriggerType in [TRIGGER_SOUND, TRIGGER_MUSIC]) then Exit; @@ -1356,6 +1357,12 @@ begin ActivateType := Trigger.ActivateType; Keys := Trigger.Keys; trigPanelGUID := atrigpanid; + // HACK: used in TPanel.CanChangeTexture. maybe there's a better way? + if TexturePanelGUID <> -1 then + begin + tp := g_Map_PanelByGUID(TexturePanelGUID); + if (tp <> nil) then tp.hasTexTrigger := True; + end; end; result := Integer(g_Triggers_Create(_trigger, Trigger)); diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 29e9223..ce4238a 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -644,7 +644,7 @@ procedure MH_SEND_Everything(CreatePlayers: Boolean = False; ID: Integer = NET_E begin result := false; // don't stop MH_SEND_PanelState(pan.guid, ID); // anyway, to sync mplats - if (pan.GetTextureCount > 1) then MH_SEND_PanelTexture(pan.guid, pan.LastAnimLoop, ID); + if (pan.CanChangeTexture) then MH_SEND_PanelTexture(pan.guid, pan.LastAnimLoop, ID); end; var diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index e88db6b..d0eb1ce 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -110,6 +110,7 @@ type tag: Integer; // used in coldets and such; sorry; see g_map.GridTagXXX proxyId: Integer; // proxy id in map grid (DO NOT USE!) mapId: AnsiString; // taken directly from map file; dunno why it is here + hasTexTrigger: Boolean; // HACK: true when there's a trigger than can change my texture constructor Create(PanelRec: TDynRecord; AddTextures: TAddTextureArray; @@ -125,6 +126,7 @@ type procedure SetTexture(ID: Integer; AnimLoop: Byte = 0); function GetTextureID(): Cardinal; function GetTextureCount(): Integer; + function CanChangeTexture(): Boolean; procedure SaveState (st: TStream); procedure LoadState (st: TStream); @@ -259,6 +261,7 @@ begin Enabled := True; Door := False; LiftType := 0; + hasTexTrigger := False; case PanelType of PANEL_OPENDOOR: begin Enabled := False; Door := True; end; @@ -1015,6 +1018,10 @@ begin Result := Result + 100; end; +function TPanel.CanChangeTexture(): Boolean; +begin + Result := (GetTextureCount() > 1) or hasTexTrigger; +end; const PAN_SAVE_VERSION = 1;