DEADSOFTWARE

fixed map loading bug: panel texture internal id was incorrect (and worked only by...
authorKetmar Dark <ketmar@ketmar.no-ip.org>
Thu, 21 Sep 2017 10:52:18 +0000 (13:52 +0300)
committerKetmar Dark <ketmar@ketmar.no-ip.org>
Thu, 21 Sep 2017 10:53:30 +0000 (13:53 +0300)
src/game/g_map.pas
src/game/g_panel.pas

index cf60d78b958b52376470cb7450ee71bd66b16283..46db3faae77a9079d5a1fd43b3af92f77f9e90e1 100644 (file)
@@ -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
index f5a6bddcc70c0b38640f1e1153679eb815ca3519..226515a5dc6a6381ba1d080f0e1f3bf3ac58e775 100644 (file)
@@ -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;