From: Ketmar Dark Date: Thu, 21 Sep 2017 10:52:18 +0000 (+0300) Subject: fixed map loading bug: panel texture internal id was incorrect (and worked only by... X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=717e99e0ebd065bbc8f0c253cce7f5ee7df9c77b fixed map loading bug: panel texture internal id was incorrect (and worked only by accident) --- diff --git a/src/game/g_map.pas b/src/game/g_map.pas index cf60d78..46db3fa 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -900,7 +900,7 @@ begin if TextNameHash.get(RecName, result) then begin // i found her! - //e_LogWritefln('texture ''%s'' already loaded', [RecName]); + //e_LogWritefln('texture ''%s'' already loaded (%s)', [RecName, result]); exit; end; @@ -968,7 +968,9 @@ begin SetLength(Textures, Length(Textures)+1); if not e_CreateTextureMem(TextureData, ResLength, Textures[High(Textures)].TextureID) then begin + e_WriteLog(Format('Error loading texture %s', [RecName]), TMsgType.Warning); SetLength(Textures, Length(Textures)-1); + result := -1; Exit; end; e_GetTextureSize(Textures[High(Textures)].TextureID, @Textures[High(Textures)].Width, @Textures[High(Textures)].Height); @@ -1016,7 +1018,7 @@ begin if TextNameHash.get(RecName, result) then begin // i found her! - //e_LogWritefln('animated texture ''%s'' already loaded', [RecName]); + //e_LogWritefln('animated texture ''%s'' already loaded (%s)', [RecName, result]); exit; end; @@ -1996,6 +1998,7 @@ begin //e_LogWritefln('PANADD: pannum=%s', [pannum]); // Ñîçäàåì ïàíåëü è çàïîìèíàåì åå GUID + //e_LogWritefln('new panel; tcount=%s; curtex=%s', [Length(AddTextures), CurTex]); PanelID := CreatePanel(rec, AddTextures, CurTex); //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 diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index f5a6bdd..226515a 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -223,6 +223,7 @@ constructor TPanel.Create(PanelRec: TDynRecord; var Textures: TLevelTextureArray; aguid: Integer); var i: Integer; + tnum: Integer; begin X := PanelRec.X; Y := PanelRec.Y; @@ -337,19 +338,22 @@ begin // Òåêñòóð íåñêîëüêî - íóæíî ñîõðàíÿòü òåêóùóþ: //if Length(FTextureIDs) > 1 then SaveIt := True; + if (PanelRec.TextureRec = nil) then tnum := -1 else tnum := PanelRec.tagInt; + if (tnum < 0) then tnum := Length(Textures); + // Åñëè íå ñïåöòåêñòóðà, òî çàäàåì ðàçìåðû: - if PanelRec.TextureNum > High(Textures) then + if ({PanelRec.TextureNum}tnum > High(Textures)) then begin - e_WriteLog(Format('WTF?! PanelRec.TextureNum is out of limits! (%d : %d)', [PanelRec.TextureNum, High(Textures)]), TMsgType.Fatal); + e_WriteLog(Format('WTF?! tnum is out of limits! (%d : %d)', [tnum, High(Textures)]), TMsgType.Warning); FTextureWidth := 2; FTextureHeight := 2; FAlpha := 0; FBlending := ByteBool(0); end - else if not g_Map_IsSpecialTexture(Textures[PanelRec.TextureNum].TextureName) then + else if not g_Map_IsSpecialTexture(Textures[{PanelRec.TextureNum}tnum].TextureName) then begin - FTextureWidth := Textures[PanelRec.TextureNum].Width; - FTextureHeight := Textures[PanelRec.TextureNum].Height; + FTextureWidth := Textures[{PanelRec.TextureNum}tnum].Width; + FTextureHeight := Textures[{PanelRec.TextureNum}tnum].Height; FAlpha := PanelRec.Alpha; FBlending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING); end;