From 3d2215798aaab87db7ae5265d21e359864e1f1c2 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 14 Mar 2020 21:43:05 +0300 Subject: [PATCH] fix texture drawing --- src/miscc.c | 2 +- src/render.c | 19 ++++++++++--------- src/view.c | 5 ++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/miscc.c b/src/miscc.c index 2ece443..90cfecb 100644 --- a/src/miscc.c +++ b/src/miscc.c @@ -392,7 +392,7 @@ int Z_moveobj(obj_t *p) { void Z_splash (obj_t *p, int n) { Z_sound(bulsnd[0], 128); - DOT_water(p->x, p->y-p->h / 2, p->xv + p->vx, p->yv + p->vy, n, R_get_special_id(wfront)); + DOT_water(p->x, p->y-p->h / 2, p->xv + p->vx, p->yv + p->vy, n, R_get_special_id(wfront) - 1); } void Z_calc_time(dword t,word *h,word *m,word *s) diff --git a/src/render.c b/src/render.c index 55ec317..254b87e 100644 --- a/src/render.c +++ b/src/render.c @@ -304,9 +304,10 @@ static void Z_drawfld (byte *fld, int bg) { int sx = x * CELW - w_x + WD / 2; int sy = y * CELH - w_y + HT / 2 + 1 + w_o; int id = *p; - if (id != 0) { + if (id) { + //intptr_t spc = (intptr_t) walp[id]; int spc = R_get_special_id(id); - if (spc <= 3) { + if (spc >= 0 && spc <= 3) { if (!bg) { byte *cmap = clrmap + (spc + 7) * 256; V_remap_rect(sx, sy, CELW, CELH, cmap); @@ -1263,23 +1264,23 @@ static short getani (char n[8]) { int R_get_special_id (int n) { assert(n >= 0 && n < 256); - intptr_t x = (intptr_t)walp[n] - 1; - return x > 0 && x <= 3 ? x : 0; + intptr_t x = (intptr_t)walp[n]; + return x >= 0 && x <= 3 ? x : -1; } void R_begin_load (void) { int i; - for (i = 0; i < max_textures; i++) { -// if (walp[i] != NULL && walh[i] >= 0) { -// M_unlock(walp[i]); -// } + for (i = 0; i < 256; i++) { + if (walp[i] != NULL && walh[i] >= 0) { + M_unlock(walp[i]); + } walh[i] = -1; walp[i] = NULL; walswp[i] = i; walani[i] = 0; } memset(anic, 0, sizeof(anic)); - max_textures = 0; + max_textures = 1; } void R_load (char s[8], int f) { diff --git a/src/view.c b/src/view.c index 73953d7..4e1fce7 100644 --- a/src/view.c +++ b/src/view.c @@ -86,14 +86,14 @@ void W_loadgame (FILE* h) { myfread(s[i], 8, 1, h); } R_begin_load(); - R_load("", 0); // empty i = myfread32(h); // ignore for (i = 1; i < 256; i++) { walf[i] = myfread32(h); R_load(s[i], walf[i] & 1); } for (i = 0; i < 256; i++) { - walswp[i] = myfread8(h); + //walswp[i] = myfread8(h); + (void)myfread8(h); // useless in new code } myfread(fldb, FLDW*FLDH, 1, h); myfread(fld, FLDW*FLDH, 1, h); @@ -140,7 +140,6 @@ int W_load (FILE *h) { switch (blk.t) { case MB_WALLNAMES: R_begin_load(); - R_load("", 0); // empty for (i = 1; i < 256 && blk.sz > 0; i++, blk.sz -= 9) { myfread(s, 8, 1, h); t = myfread8(h); -- 2.29.2