From 2b481ae25adcf3bebf37be182eafc8bfa0acb4c1 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Tue, 21 Apr 2020 12:03:30 +0400 Subject: [PATCH] manager: remove flag 0x8000 from resource handle id --- src/files.c | 29 ++++++++++++++++------------- src/files.h | 2 +- src/gl/render.c | 16 +++++----------- src/memory.c | 5 ++--- src/render.h | 2 +- src/soft/render.c | 14 ++++---------- src/view.c | 27 ++++++++++++++------------- 7 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/files.c b/src/files.c index 1b47091..dc897ed 100644 --- a/src/files.c +++ b/src/files.c @@ -351,21 +351,24 @@ void F_getresname (char n[8], int r) { } // 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; - byte a,b; - - s+='A';d+='0'; - for(i=s_start+1;i=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) { - return (h != -1) && (h != 0xFFFF) && (resl[h & (-1 - 0x8000)] != 0); + return (h != -1) && (h != 0xFFFF) && (resl[h] != 0); } int M_was_locked (int h) { - return (h != -1) && (h != 0xFFFF) && (resp[h & (-1 - 0x8000)] != NULL); + return (h != -1) && (h != 0xFFFF) && (resp[h] != NULL); } diff --git a/src/render.h b/src/render.h index f9a4cfb..7f1b231 100644 --- a/src/render.h +++ b/src/render.h @@ -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); -void R_load (char s[8], int f); +void R_load (char s[8]); void R_end_load (void); void R_loadsky (int sky); diff --git a/src/soft/render.c b/src/soft/render.c index e2cb9bf..25c3872 100644 --- a/src/soft/render.c +++ b/src/soft/render.c @@ -87,10 +87,7 @@ static int init_screen_gammaa = -1; /* --- 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); } @@ -1412,7 +1409,7 @@ void R_begin_load (void) { 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; @@ -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]); - if (f) { - walh[max_textures] |= 0x8000; - } 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; - g = F_getresid(s) | (walh[i] & 0x8000); + g = F_getresid(s); 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); - walf[k] = g & 0x8000 ? 1 : 0; + walf[k] = walf[i]; } walswp[i] = k; walswp[k] = i; diff --git a/src/view.c b/src/view.c index 043ac78..f902e23 100644 --- a/src/view.c +++ b/src/view.c @@ -68,26 +68,26 @@ void W_savegame (FILE* h) { void W_loadgame (FILE* h) { int i; - char s[256][8]; + char s[8]; sky_type = myfread32(h); R_loadsky(sky_type); + R_begin_load(); 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++) { - //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); - R_end_load(); } void W_init (void) { @@ -122,16 +122,17 @@ static void unpack (void *buf, int len, void *obuf) { } int W_load (FILE *h) { + int i; char s[8]; - int i, j, t; 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); - 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; } -- 2.29.2