DEADSOFTWARE

Game: Use the animation flags in the map texture list only as a hint, not a prescription mob
authorDmitry D. Chernov <blackdoomer@yandex.ru>
Wed, 8 Nov 2023 05:34:53 +0000 (15:34 +1000)
committerDmitry D. Chernov <blackdoomer@yandex.ru>
Wed, 8 Nov 2023 06:50:14 +0000 (16:50 +1000)
This allows to change the panel texture from static to animated without manually reassigning it in the map editor first.
The opposite case - changing from animated to static - was already implicitly supported, since such textures were simply loaded as single-frame animations.

src/game/g_map.pas

index 2b8e9ff34d5875ab0042b71f15b9936bfb680e97..f87e6b7ef8f42454a0e464d07f18adbb738a08d9 100644 (file)
@@ -1847,7 +1847,7 @@ begin
         cnt := -1;
         for rec in mapTextureList do
         begin
-          Inc(cnt);
+          cnt += 1;
           if not usedTextures.has(toLowerCase1251(rec.Resource)) then
           begin
             rec.tagInt := -1; // just in case
@@ -1859,17 +1859,39 @@ begin
             e_LogWritefln('    Loading texture #%d: %s', [cnt, rec.Resource]);
             {$ENDIF}
             //if g_Map_IsSpecialTexture(s) then e_WriteLog('      SPECIAL!', MSG_NOTIFY);
+            // TODO: Unify the texture reader - static textures are a special case of dynamic ones, just with only one frame.
             if rec.Anim then
             begin
               // Àíèìèðîâàííàÿ òåêñòóðà
               ntn := CreateAnimTexture(rec.Resource, FileName, True);
-              if (ntn < 0) then g_SimpleError(Format(_lc[I_GAME_ERROR_TEXTURE_ANIM], [rec.Resource]));
+              if (ntn < 0) then
+              begin
+                // FIXME: I think, CreateAnimTexture() will load static textures too, just as animated ones with one frame.
+                ntn := CreateTexture(rec.Resource, FileName, False);
+                if (ntn < 0) then
+                  g_SimpleError(Format(_lc[I_GAME_ERROR_TEXTURE_ANIM], [rec.Resource]))
+                else
+                begin
+                  rec.user['animated'] := False;
+                  e_LogWritefln('    wrong (outdated?) anim flag hint - texture #%d is actually static: %s', [cnt, rec.Resource]);
+                end;
+              end;
             end
             else
             begin
               // Îáû÷íàÿ òåêñòóðà
               ntn := CreateTexture(rec.Resource, FileName, True);
-              if (ntn < 0) then g_SimpleError(Format(_lc[I_GAME_ERROR_TEXTURE_SIMPLE], [rec.Resource]));
+              if (ntn < 0) then
+              begin
+                ntn := CreateAnimTexture(rec.Resource, FileName, False);
+                if (ntn < 0) then
+                  g_SimpleError(Format(_lc[I_GAME_ERROR_TEXTURE_SIMPLE], [rec.Resource]))
+                else
+                begin
+                  rec.user['animated'] := True;
+                  e_LogWritefln('    wrong (outdated?) anim flag hint - texture #%d is actually animated: %s', [cnt, rec.Resource]);
+                end;
+              end;
             end;
             if (ntn < 0) then ntn := CreateNullTexture(rec.Resource);