DEADSOFTWARE

manager: remove flag 0x8000 from resource handle id
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 21 Apr 2020 08:03:30 +0000 (12:03 +0400)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 21 Apr 2020 08:03:30 +0000 (12:03 +0400)
src/files.c
src/files.h
src/gl/render.c
src/memory.c
src/render.h
src/soft/render.c
src/view.c

index 1b470913c6c4aaf56958889ddfe5c55f43dc730e..dc897ed23cb0fd1daa2c2fd96dc19cc890dc0c3c 100644 (file)
@@ -351,21 +351,24 @@ void F_getresname (char n[8], int r) {
 }
 
 // get sprite id
 }
 
 // get sprite id
-int F_getsprid (const char n[4], int s, int d) {
+int F_getsprid (const char n[4], int s, int d, char *dir) {
   int i;
   int i;
-  byte a,b;
-
-  s+='A';d+='0';
-  for(i=s_start+1;i<s_end;++i)
-    if(cp866_strncasecmp(wad[i].n,n,4)==0 && (wad[i].n[4]==s || wad[i].n[6]==s)) {
-      if(wad[i].n[4]==s) a=wad[i].n[5]; else a=0;
-      if(wad[i].n[6]==s) b=wad[i].n[7]; else b=0;
-      if(a=='0') return i;
-      if(b=='0') return(i|0x8000);
-      if(a==d) return i;
-      if(b==d) return(i|0x8000);
+  byte a, b;
+  s += 'A';
+  d += '0';
+  for (i = s_start + 1; i < s_end; i++) {
+    if (cp866_strncasecmp(wad[i].n, n, 4) == 0 && (wad[i].n[4] == s || wad[i].n[6] == s)) {
+      a = wad[i].n[4] == s ? wad[i].n[5] : 0;
+      b = wad[i].n[6] == s ? wad[i].n[7] : 0;
+      if (a == '0' || b == '0' || a == d || b == d) {
+        if (dir != NULL) {
+          *dir = a != '0' && b == '0' || a != d && b == d;
+        }
+        return i;
+      }
     }
     }
-  ERR_fatal("F_getsprid: изображение %.4s%c%c не найдено",n,(byte)s,(byte)d);
+  }
+  ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
   return -1;
 }
 
   return -1;
 }
 
index dbd99d4b934a79ce4a9308123a4389abf6664c5c..01f2087968a1862f9cad1642a4d4faf00c98bf83 100644 (file)
@@ -59,7 +59,7 @@ void F_loadres (int r, void *p, dword o, dword l);
 int F_findres (const char n[8]);
 int F_getresid (const char n[8]);
 void F_getresname (char n[8], int r);
 int F_findres (const char n[8]);
 int F_getresid (const char n[8]);
 void F_getresname (char n[8], int r);
-int F_getsprid (const char n[4], int s, int d);
+int F_getsprid (const char n[4], int s, int d, char *dir);
 int F_getreslen (int r);
 void F_nextmus (char *s);
 void F_randmus (char *s);
 int F_getreslen (int r);
 void F_nextmus (char *s);
 void F_randmus (char *s);
index 28c5b86976ccb1cb97f6cf464698034798d88587..c4da0dc3844e8644cb14ecdadf740ca49d989e9d 100644 (file)
@@ -542,7 +542,7 @@ static image R_gl_loadimage (const char name[8]) {
 }
 
 static image R_gl_get_special_spr (const char n[4], int s, int d, rgba *(*fn)(vgaimg*)) {
 }
 
 static image R_gl_get_special_spr (const char n[4], int s, int d, rgba *(*fn)(vgaimg*)) {
-  return R_gl_get_special_image(F_getsprid(n, s, d), fn);
+  return R_gl_get_special_image(F_getsprid(n, s, d, NULL), fn);
 }
 
 static void R_gl_free_image (image *img) {
 }
 
 static void R_gl_free_image (image *img) {
@@ -636,10 +636,7 @@ static void R_gl_setmatrix (void) {
 /* --- Misc --- */
 
 static image Z_getspr (const char n[4], int s, int d, char *dir) {
 /* --- Misc --- */
 
 static image Z_getspr (const char n[4], int s, int d, char *dir) {
-  int h = F_getsprid(n, s, d);
-  if (dir != NULL) {
-    *dir = (h & 0x8000) ? 1 : 0;
-  }
+  int h = F_getsprid(n, s, d, dir);
   return R_gl_getimage(h);
 }
 
   return R_gl_getimage(h);
 }
 
@@ -2040,7 +2037,7 @@ void R_begin_load (void) {
   max_textures = 1;
 }
 
   max_textures = 1;
 }
 
-void R_load (char s[8], int f) {
+void R_load (char s[8]) {
   assert(max_textures < 256);
   if (!s[0]) {
     walp[max_textures] = (image) {
   assert(max_textures < 256);
   if (!s[0]) {
     walp[max_textures] = (image) {
@@ -2062,9 +2059,6 @@ void R_load (char s[8], int f) {
     };
   } else {
     walp[max_textures] = R_gl_loadimage(s);
     };
   } else {
     walp[max_textures] = R_gl_loadimage(s);
-    if (f) {
-      walp[max_textures].res |= 0x8000;
-    }
     if (s[0] == 'S' && s[1] == 'W' && s[4] == '_') {
       walswp[max_textures] = 0;
     }
     if (s[0] == 'S' && s[1] == 'W' && s[4] == '_') {
       walswp[max_textures] = 0;
     }
@@ -2083,7 +2077,7 @@ void R_end_load (void) {
     if (walswp[i] == 0) {
       R_get_name(i, s);
       s[5] ^= 1;
     if (walswp[i] == 0) {
       R_get_name(i, s);
       s[5] ^= 1;
-      g = F_getresid(s) | (walp[i].res & 0x8000);
+      g = F_getresid(s);
       k = 1;
       while (k < 256 && walp[k].res != g) {
         k += 1;
       k = 1;
       while (k < 256 && walp[k].res != g) {
         k += 1;
@@ -2093,7 +2087,7 @@ void R_end_load (void) {
         j += 1;
         max_textures += 1;
         walp[k] = R_gl_getimage(g);
         j += 1;
         max_textures += 1;
         walp[k] = R_gl_getimage(g);
-        walf[k] = g & 0x8000 ? 1 : 0;
+        walf[k] = walf[i];
       }
       walswp[i] = k;
       walswp[k] = i;
       }
       walswp[i] = k;
       walswp[k] = i;
index 5be719f55d45d1741146a21e3341a5a1d97be3b1..7089cc5cadb64d31aec69a2ecd8dccc6b518821d 100644 (file)
@@ -66,7 +66,6 @@ static void allocres (int h) {
 
 void *M_lock (int h) {
   if(h==-1 || h==0xFFFF) return NULL;
 
 void *M_lock (int h) {
   if(h==-1 || h==0xFFFF) return NULL;
-  h&=-1-0x8000;
   if(h>=MAX_WAD) ERR_fatal("M_lock: странный номер ресурса");
   if(!resl[h]) if(!resp[h]) allocres(h);
   ++resl[h];
   if(h>=MAX_WAD) ERR_fatal("M_lock: странный номер ресурса");
   if(!resl[h]) if(!resp[h]) allocres(h);
   ++resl[h];
@@ -84,9 +83,9 @@ void M_unlock (void *p) {
 }
 
 int M_locked (int h) {
 }
 
 int M_locked (int h) {
-  return (h != -1) && (h != 0xFFFF) && (resl[h & (-1 - 0x8000)] != 0);
+  return (h != -1) && (h != 0xFFFF) && (resl[h] != 0);
 }
 
 int M_was_locked (int h) {
 }
 
 int M_was_locked (int h) {
-  return (h != -1) && (h != 0xFFFF) && (resp[h & (-1 - 0x8000)] != NULL);
+  return (h != -1) && (h != 0xFFFF) && (resp[h] != NULL);
 }
 }
index f9a4cfb91a9d44970efc3c5a2b9ab9a454c2c17c..7f1b2314df120e65b79b52098c4412d9de03842d 100644 (file)
@@ -20,7 +20,7 @@ void R_get_name (int n, char s[8]);
 int R_get_special_id (int n);
 int R_get_swp (int n);
 void R_begin_load (void);
 int R_get_special_id (int n);
 int R_get_swp (int n);
 void R_begin_load (void);
-void R_load (char s[8], int f);
+void R_load (char s[8]);
 void R_end_load (void);
 void R_loadsky (int sky);
 
 void R_end_load (void);
 void R_loadsky (int sky);
 
index e2cb9bf660cc9a4167a33df9168cba13b8b6383b..25c387226367fae0404daf53cd2c05876549e5be 100644 (file)
@@ -87,10 +87,7 @@ static int init_screen_gammaa = -1;
 /* --- misc --- */
 
 static void *Z_getspr (char n[4], int s, int d, char *dir) {
 /* --- misc --- */
 
 static void *Z_getspr (char n[4], int s, int d, char *dir) {
-  int h = F_getsprid(n, s, d);
-  if (dir) {
-    *dir = (h & 0x8000) ? 1 : 0;
-  }
+  int h = F_getsprid(n, s, d, dir);
   return V_getvgaimg(h);
 }
 
   return V_getvgaimg(h);
 }
 
@@ -1412,7 +1409,7 @@ void R_begin_load (void) {
   max_textures = 1;
 }
 
   max_textures = 1;
 }
 
-void R_load (char s[8], int f) {
+void R_load (char s[8]) {
   assert(max_textures < 256);
   if (!s[0]) {
     walh[max_textures] = -1;
   assert(max_textures < 256);
   if (!s[0]) {
     walh[max_textures] = -1;
@@ -1424,9 +1421,6 @@ void R_load (char s[8], int f) {
     } else {
       walh[max_textures] = F_getresid(s);
       walp[max_textures] = V_getvgaimg(walh[max_textures]);
     } else {
       walh[max_textures] = F_getresid(s);
       walp[max_textures] = V_getvgaimg(walh[max_textures]);
-      if (f) {
-        walh[max_textures] |= 0x8000;
-      }
       if (s[0] == 'S' && s[1] == 'W' && s[4] == '_') {
         walswp[max_textures] = 0;
       }
       if (s[0] == 'S' && s[1] == 'W' && s[4] == '_') {
         walswp[max_textures] = 0;
       }
@@ -1444,7 +1438,7 @@ void R_end_load (void) {
     if (walswp[i] == 0) {
       R_get_name(i, s);
       s[5] ^= 1;
     if (walswp[i] == 0) {
       R_get_name(i, s);
       s[5] ^= 1;
-      g = F_getresid(s) | (walh[i] & 0x8000);
+      g = F_getresid(s);
       k = 1;
       while (k < 256 && walh[k] != g) {
         k += 1;
       k = 1;
       while (k < 256 && walh[k] != g) {
         k += 1;
@@ -1454,7 +1448,7 @@ void R_end_load (void) {
         j += 1;
         walh[k] = g;
         walp[k] = V_getvgaimg(g);
         j += 1;
         walh[k] = g;
         walp[k] = V_getvgaimg(g);
-        walf[k] = g & 0x8000 ? 1 : 0;
+        walf[k] = walf[i];
       }
       walswp[i] = k;
       walswp[k] = i;
       }
       walswp[i] = k;
       walswp[k] = i;
index 043ac7839b459fd6aa0c3c96d5398bf5111f45ba..f902e23648dbe7727678f94a702feda84f22d4d9 100644 (file)
@@ -68,26 +68,26 @@ void W_savegame (FILE* h) {
 
 void W_loadgame (FILE* h) {
   int i;
 
 void W_loadgame (FILE* h) {
   int i;
-  char s[256][8];
+  char s[8];
   sky_type = myfread32(h);
   R_loadsky(sky_type);
   sky_type = myfread32(h);
   R_loadsky(sky_type);
+  R_begin_load();
   for (i = 1; i < 256; ++i) {
   for (i = 1; i < 256; ++i) {
-    myfread(s[i], 8, 1, h);
+    myfread(s, 8, 1, h);
+    if (s[0]) {
+      R_load(s);
+    }
   }
   }
-  R_begin_load();
-  i = myfread32(h); // ignore
-  for (i = 1; i < 256; i++) {
-    walf[i] = myfread32(h);
-    R_load(s[i], walf[i] & 1);
+  R_end_load();
+  for (i = 0; i < 256; i++) {
+    myfread32(h); // useless
   }
   for (i = 0; i < 256; i++) {
   }
   for (i = 0; i < 256; i++) {
-    //walswp[i] = myfread8(h);
-    (void)myfread8(h); // useless in new code
+    walf[i] = myfread8(h);
   }
   myfread(fldb, FLDW*FLDH, 1, h);
   myfread(fld, FLDW*FLDH, 1, h);
   myfread(fldf, FLDW*FLDH, 1, h);
   }
   myfread(fldb, FLDW*FLDH, 1, h);
   myfread(fld, FLDW*FLDH, 1, h);
   myfread(fldf, FLDW*FLDH, 1, h);
-  R_end_load();
 }
 
 void W_init (void) {
 }
 
 void W_init (void) {
@@ -122,16 +122,17 @@ static void unpack (void *buf, int len, void *obuf) {
 }
 
 int W_load (FILE *h) {
 }
 
 int W_load (FILE *h) {
+  int i;
   char s[8];
   char s[8];
-  int i, j, t;
   void *p, *buf;
   switch (blk.t) {
   case MB_WALLNAMES:
     R_begin_load();
   void *p, *buf;
   switch (blk.t) {
   case MB_WALLNAMES:
     R_begin_load();
+    memset(walf, 0, sizeof(walf));
     for (i = 1; i < 256 && blk.sz > 0; i++, blk.sz -= 9) {
       myfread(s, 8, 1, h);
     for (i = 1; i < 256 && blk.sz > 0; i++, blk.sz -= 9) {
       myfread(s, 8, 1, h);
-      t = myfread8(h);
-      R_load(s, t);
+      walf[i] = myfread8(h) ? 1 : 0; // ???
+      R_load(s);
       if (strncasecmp(s, "VTRAP01", 8) == 0) {
         walf[i] |= 2;
       }
       if (strncasecmp(s, "VTRAP01", 8) == 0) {
         walf[i] |= 2;
       }