From 9973478a9db11a895ff3c9dbda9a14a5aa408d28 Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 8 Jun 2009 00:31:53 +0000 Subject: [PATCH] Fix rendmode != 4 SE light crashes git-svn-id: https://svn.eduke32.com/eduke32@1423 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/polymer.h | 2 +- polymer/eduke32/build/src/polymer.c | 22 +-- polymer/eduke32/source/actors.c | 185 ++++++++++++------------ 3 files changed, 104 insertions(+), 105 deletions(-) diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index a114119a7..41981e790 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -338,7 +338,7 @@ static void polymer_compileprogram(int32_t programbits); static void polymer_removelight(int16_t lighti); static void polymer_updatelights(void); static void polymer_resetlights(void); -static void polymer_resetplanelights(_prplane* plane); +static inline void polymer_resetplanelights(_prplane* plane); static void polymer_addplanelight(_prplane* plane, int16_t lighti); static inline void polymer_deleteplanelight(_prplane* plane, int16_t lighti); static int32_t polymer_planeinlight(_prplane* plane, _prlight* light); diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index dd4ae3f99..ca196b27f 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -4275,17 +4275,9 @@ static void polymer_resetlights(void) lightcount = 0; } -static void polymer_resetplanelights(_prplane* plane) +static inline void polymer_resetplanelights(_prplane* plane) { - int32_t i; - - i = 0; - while (i < PR_MAXLIGHTS) - { - plane->lights[i] = -1; - i++; - } - + Bmemset(&plane->lights[0], -1, sizeof(plane->lights[0]) * PR_MAXLIGHTS); plane->lightcount = 0; } @@ -4327,8 +4319,8 @@ static inline void polymer_deleteplanelight(_prplane* plane, int16_t lighti) { int16_t i; - i = 0; - while (i < plane->lightcount) + i = plane->lightcount-1; + while (i >= 0) { if (plane->lights[i] == lighti) { @@ -4338,7 +4330,7 @@ static inline void polymer_deleteplanelight(_prplane* plane, int16_t lighti) plane->lightcount--; return; } - i++; + i--; } } @@ -4517,7 +4509,7 @@ static inline void polymer_culllight(int16_t lighti) zdiff = -zdiff; zdiff >>= 4; - if (!light->radius && !sec->floorheinum) { + if (!light->radius && !(sec->floorstat & 1)) { if (zdiff < light->range) polymer_addplanelight(&s->floor, lighti); } else if (polymer_planeinlight(&s->floor, light)) @@ -4528,7 +4520,7 @@ static inline void polymer_culllight(int16_t lighti) zdiff = -zdiff; zdiff >>= 4; - if (!light->radius && !sec->ceilingheinum) { + if (!light->radius && !(sec->ceilingstat & 1)) { if (zdiff < light->range) polymer_addplanelight(&s->ceil, lighti); } else if (polymer_planeinlight(&s->ceil, light)) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 2387b769d..722dbfc3c 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -588,10 +588,11 @@ static void ms(int32_t i) inline void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority) { #ifdef POLYMER - if (rendmode != 4) + spritetype *s = &sprite[srcsprite]; + + if (getrendermode() != 4) return; - spritetype *s = &sprite[srcsprite]; if (ActorExtra[srcsprite].lightptr == NULL) { _prlight mylight; @@ -7602,108 +7603,114 @@ static void G_MoveEffectors(void) //STATNUM 3 #ifdef POLYMER case 49: { - if (ActorExtra[i].lightptr == NULL) + if (getrendermode() == 4) { - _prlight mylight; + if (ActorExtra[i].lightptr == NULL) + { + _prlight mylight; - mylight.sector = SECT; - mylight.x = SX; - mylight.y = SY; - mylight.z = SZ; - mylight.range = SHT; - if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0) - { - mylight.color[0] = sprite[i].xvel; - mylight.color[1] = sprite[i].yvel; - mylight.color[2] = sprite[i].zvel; - } - else - { - mylight.color[0] = hictinting[PL].r; - mylight.color[1] = hictinting[PL].g; - mylight.color[2] = hictinting[PL].b; - } - mylight.radius = 0; - mylight.angle = SA; - mylight.horiz = SH; - mylight.minshade = sprite[i].xoffset; - mylight.maxshade = sprite[i].yoffset; - - if (CS & 2) - { - if (CS & 512) - mylight.priority = PR_LIGHT_PRIO_LOW; + mylight.sector = SECT; + mylight.x = SX; + mylight.y = SY; + mylight.z = SZ; + mylight.range = SHT; + if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0) + { + mylight.color[0] = sprite[i].xvel; + mylight.color[1] = sprite[i].yvel; + mylight.color[2] = sprite[i].zvel; + } else - mylight.priority = PR_LIGHT_PRIO_HIGH; + { + mylight.color[0] = hictinting[PL].r; + mylight.color[1] = hictinting[PL].g; + mylight.color[2] = hictinting[PL].b; + } + mylight.radius = 0; + mylight.angle = SA; + mylight.horiz = SH; + mylight.minshade = sprite[i].xoffset; + mylight.maxshade = sprite[i].yoffset; + + if (CS & 2) + { + if (CS & 512) + mylight.priority = PR_LIGHT_PRIO_LOW; + else + mylight.priority = PR_LIGHT_PRIO_HIGH; + } + else + mylight.priority = PR_LIGHT_PRIO_MAX; + + ActorExtra[i].lightId = polymer_addlight(&mylight); + if (ActorExtra[i].lightId >= 0) + ActorExtra[i].lightptr = &prlights[ActorExtra[i].lightId]; + break; } - else - mylight.priority = PR_LIGHT_PRIO_MAX; - ActorExtra[i].lightId = polymer_addlight(&mylight); - if (ActorExtra[i].lightId >= 0) - ActorExtra[i].lightptr = &prlights[ActorExtra[i].lightId]; - break; - } - - if (Bmemcmp(&sprite[i], ActorExtra[i].lightptr, sizeof(int32_t) * 3)) - { - Bmemcpy(ActorExtra[i].lightptr, &sprite[i], sizeof(int32_t) * 3); - ActorExtra[i].lightptr->sector = sprite[i].sectnum; - ActorExtra[i].lightptr->flags.invalidate = 1; + if (Bmemcmp(&sprite[i], ActorExtra[i].lightptr, sizeof(int32_t) * 3)) + { + Bmemcpy(ActorExtra[i].lightptr, &sprite[i], sizeof(int32_t) * 3); + ActorExtra[i].lightptr->sector = sprite[i].sectnum; + ActorExtra[i].lightptr->flags.invalidate = 1; + } } break; } case 50: { - if (ActorExtra[i].lightptr == NULL) + if (getrendermode() == 4) { - _prlight mylight; + if (ActorExtra[i].lightptr == NULL) + { + _prlight mylight; - mylight.sector = SECT; - mylight.x = SX; - mylight.y = SY; - mylight.z = SZ; - mylight.range = SHT; - if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0) - { - mylight.color[0] = sprite[i].xvel; - mylight.color[1] = sprite[i].yvel; - mylight.color[2] = sprite[i].zvel; - } - else - { - mylight.color[0] = hictinting[PL].r; - mylight.color[1] = hictinting[PL].g; - mylight.color[2] = hictinting[PL].b; - } - mylight.radius = (256-(SS+128))<<1; - mylight.faderadius = (int16_t)(mylight.radius * 0.75); - mylight.angle = SA; - mylight.horiz = SH; - mylight.minshade = sprite[i].xoffset; - mylight.maxshade = sprite[i].yoffset; - - if (CS & 2) - { - if (CS & 512) - mylight.priority = PR_LIGHT_PRIO_LOW; + mylight.sector = SECT; + mylight.x = SX; + mylight.y = SY; + mylight.z = SZ; + mylight.range = SHT; + if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0) + { + mylight.color[0] = sprite[i].xvel; + mylight.color[1] = sprite[i].yvel; + mylight.color[2] = sprite[i].zvel; + } else - mylight.priority = PR_LIGHT_PRIO_HIGH; + { + mylight.color[0] = hictinting[PL].r; + mylight.color[1] = hictinting[PL].g; + mylight.color[2] = hictinting[PL].b; + } + mylight.radius = (256-(SS+128))<<1; + mylight.faderadius = (int16_t)(mylight.radius * 0.75); + mylight.angle = SA; + mylight.horiz = SH; + mylight.minshade = sprite[i].xoffset; + mylight.maxshade = sprite[i].yoffset; + + if (CS & 2) + { + if (CS & 512) + mylight.priority = PR_LIGHT_PRIO_LOW; + else + mylight.priority = PR_LIGHT_PRIO_HIGH; + } + else + mylight.priority = PR_LIGHT_PRIO_MAX; + + ActorExtra[i].lightId = polymer_addlight(&mylight); + if (ActorExtra[i].lightId >= 0) + ActorExtra[i].lightptr = &prlights[ActorExtra[i].lightId]; + break; } - else - mylight.priority = PR_LIGHT_PRIO_MAX; - ActorExtra[i].lightId = polymer_addlight(&mylight); - if (ActorExtra[i].lightId >= 0) - ActorExtra[i].lightptr = &prlights[ActorExtra[i].lightId]; - break; - } - - if (Bmemcmp(&sprite[i], ActorExtra[i].lightptr, sizeof(int32_t) * 3)) - { - Bmemcpy(ActorExtra[i].lightptr, &sprite[i], sizeof(int32_t) * 3); - ActorExtra[i].lightptr->sector = sprite[i].sectnum; - ActorExtra[i].lightptr->flags.invalidate = 1; + if (Bmemcmp(&sprite[i], ActorExtra[i].lightptr, sizeof(int32_t) * 3)) + { + Bmemcpy(ActorExtra[i].lightptr, &sprite[i], sizeof(int32_t) * 3); + ActorExtra[i].lightptr->sector = sprite[i].sectnum; + ActorExtra[i].lightptr->flags.invalidate = 1; + } } break;