diff --git a/src/p_floor.c b/src/p_floor.c index e81dce5bc..887385035 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -327,7 +327,7 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case bounceFloorCrush: // Graue 03-27-2004 if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight) @@ -343,14 +343,14 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = -1; movefloor->sector->soundorg.z = movefloor->sector->floorheight; S_StartSound(&movefloor->sector->soundorg,sfx_pstop); - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; default: break; @@ -376,7 +376,7 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case bounceFloorCrush: // Graue 03-27-2004 if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight) @@ -392,13 +392,13 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it P_RemoveThinker(&movefloor->thinker); movefloor->sector->floorspeed = 0; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; default: break; @@ -415,7 +415,7 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->sector->floorspeed = 0; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; } // @@ -817,7 +817,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) bouncer->sector->floorheight = bouncer->sector->ceilingheight - (halfheight*2); T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor - P_RecalcPrecipInSector(actionsector); bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; bouncer->sector->floorspeed = 0; @@ -833,7 +832,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) bouncer->sector->floorheight = floorheight; T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor - P_RecalcPrecipInSector(actionsector); bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; bouncer->sector->floorspeed = 0; @@ -913,9 +911,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) if (bouncer->distance > 0) bouncer->distance--; - - if (actionsector) - P_RecalcPrecipInSector(actionsector); } #undef speed #undef distance @@ -1102,7 +1097,6 @@ void T_StartCrumble(elevator_t *elevator) { sector = §ors[i]; sector->moved = true; - P_RecalcPrecipInSector(sector); } } @@ -1156,7 +1150,7 @@ void T_MarioBlock(levelspecthink_t *block) } for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) - P_RecalcPrecipInSector(§ors[i]); + sectors[i].moved = true; #undef speed #undef direction @@ -1272,7 +1266,7 @@ void T_FloatSector(levelspecthink_t *floater) else if (floater->sector->crumblestate == 0 || floater->sector->crumblestate >= 3/* || floatanyway*/) EV_BounceSector(floater->sector, FRACUNIT, floater->sourceline); - P_RecalcPrecipInSector(actionsector); + actionsector->moved = true; } } @@ -1974,7 +1968,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) thwomp->sector->floorspeed = 0; } - P_RecalcPrecipInSector(actionsector); + actionsector->moved = true; #undef speed #undef direction #undef distance @@ -2503,7 +2497,7 @@ void T_RaiseSector(levelspecthink_t *raise) raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) - P_RecalcPrecipInSector(§ors[i]); + sectors[i].moved = true; } void T_CameraScanner(elevator_t *elevator) diff --git a/src/p_local.h b/src/p_local.h index 6f61d9cd7..6043f794f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -258,7 +258,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); mobj_t *P_SpawnShadowMobj(mobj_t * caster); -void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); void P_RemoveMobj(mobj_t *th); @@ -373,8 +372,6 @@ extern line_t *ceilingline; extern line_t *blockingline; extern msecnode_t *sector_list; -extern mprecipsecnode_t *precipsector_list; - void P_UnsetThingPosition(mobj_t *thing); void P_SetThingPosition(mobj_t *thing); void P_SetUnderlayPosition(mobj_t *thing); @@ -398,7 +395,6 @@ void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fix boolean P_CheckSector(sector_t *sector, boolean crunch); void P_DelSeclist(msecnode_t *node); -void P_DelPrecipSeclist(mprecipsecnode_t *node); void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y); void P_Initsecnode(void); diff --git a/src/p_map.c b/src/p_map.c index 4793b4fa3..3d588a98d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -47,9 +47,6 @@ static INT32 tmflags; fixed_t tmx; fixed_t tmy; -static precipmobj_t *tmprecipthing; -static fixed_t preciptmbbox[4]; - // If "floatok" true, move would be ok // if within "tmfloorz - tmceilingz". boolean floatok; @@ -69,7 +66,6 @@ line_t *ceilingline; line_t *blockingline; msecnode_t *sector_list = NULL; -mprecipsecnode_t *precipsector_list = NULL; camera_t *mapcampointer; // @@ -3727,8 +3723,6 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) sec->moved = true; - P_RecalcPrecipInSector(sec); - if (!sector->attachedsolid[i]) continue; @@ -3789,8 +3783,6 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) sec->moved = true; - P_RecalcPrecipInSector(sec); - if (!sector->attachedsolid[i]) continue; @@ -3841,12 +3833,10 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) */ static msecnode_t *headsecnode = NULL; -static mprecipsecnode_t *headprecipsecnode = NULL; void P_Initsecnode(void) { headsecnode = NULL; - headprecipsecnode = NULL; } // P_GetSecnode() retrieves a node from the freelist. The calling routine @@ -3866,20 +3856,6 @@ static msecnode_t *P_GetSecnode(void) return node; } -static mprecipsecnode_t *P_GetPrecipSecnode(void) -{ - mprecipsecnode_t *node; - - if (headprecipsecnode) - { - node = headprecipsecnode; - headprecipsecnode = headprecipsecnode->m_thinglist_next; - } - else - node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); - return node; -} - // P_PutSecnode() returns a node to the freelist. static inline void P_PutSecnode(msecnode_t *node) @@ -3888,13 +3864,6 @@ static inline void P_PutSecnode(msecnode_t *node) headsecnode = node; } -// Tails 08-25-2002 -static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) -{ - node->m_thinglist_next = headprecipsecnode; - headprecipsecnode = node; -} - // P_AddSecnode() searches the current list to see if this sector is // already there. If not, it adds a sector node at the head of the list of // sectors this object appears in. This is called when creating a list of @@ -3940,47 +3909,6 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode return node; } -// More crazy crap Tails 08-25-2002 -static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mprecipsecnode_t *nextnode) -{ - mprecipsecnode_t *node; - - node = nextnode; - while (node) - { - if (node->m_sector == s) // Already have a node for this sector? - { - node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. - return nextnode; - } - node = node->m_sectorlist_next; - } - - // Couldn't find an existing node for this sector. Add one at the head - // of the list. - - node = P_GetPrecipSecnode(); - - // mark new nodes unvisited. - node->visited = 0; - - node->m_sector = s; // sector - node->m_thing = thing; // mobj - node->m_sectorlist_prev = NULL; // prev node on Thing thread - node->m_sectorlist_next = nextnode; // next node on Thing thread - if (nextnode) - nextnode->m_sectorlist_prev = node; // set back link on Thing - - // Add new node at head of sector thread starting at s->touching_thinglist - - node->m_thinglist_prev = NULL; // prev node on sector thread - node->m_thinglist_next = s->touching_preciplist; // next node on sector thread - if (s->touching_preciplist) - node->m_thinglist_next->m_thinglist_prev = node; - s->touching_preciplist = node; - return node; -} - // P_DelSecnode() deletes a sector node from the list of // sectors this object appears in. Returns a pointer to the next node // on the linked list, or NULL. @@ -4023,45 +3951,6 @@ static msecnode_t *P_DelSecnode(msecnode_t *node) return tn; } -// Tails 08-25-2002 -static mprecipsecnode_t *P_DelPrecipSecnode(mprecipsecnode_t *node) -{ - mprecipsecnode_t *tp; // prev node on thing thread - mprecipsecnode_t *tn; // next node on thing thread - mprecipsecnode_t *sp; // prev node on sector thread - mprecipsecnode_t *sn; // next node on sector thread - - if (!node) - return NULL; - - // Unlink from the Thing thread. The Thing thread begins at - // sector_list and not from mobj_t->touching_sectorlist. - - tp = node->m_sectorlist_prev; - tn = node->m_sectorlist_next; - if (tp) - tp->m_sectorlist_next = tn; - if (tn) - tn->m_sectorlist_prev = tp; - - // Unlink from the sector thread. This thread begins at - // sector_t->touching_thinglist. - - sp = node->m_thinglist_prev; - sn = node->m_thinglist_next; - if (sp) - sp->m_thinglist_next = sn; - else - node->m_sector->touching_preciplist = sn; - if (sn) - sn->m_thinglist_prev = sp; - - // Return this node to the freelist - - P_PutPrecipSecnode(node); - return tn; -} - // Delete an entire sector list void P_DelSeclist(msecnode_t *node) { @@ -4069,13 +3958,6 @@ void P_DelSeclist(msecnode_t *node) node = P_DelSecnode(node); } -// Tails 08-25-2002 -void P_DelPrecipSeclist(mprecipsecnode_t *node) -{ - while (node) - node = P_DelPrecipSecnode(node); -} - // PIT_GetSectors // Locates all the sectors the object is in by looking at the lines that // cross through it. You have already decided that the object is allowed @@ -4116,41 +3998,6 @@ static inline boolean PIT_GetSectors(line_t *ld) return true; } -// Tails 08-25-2002 -static inline boolean PIT_GetPrecipSectors(line_t *ld) -{ - if (preciptmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || - preciptmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || - preciptmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || - preciptmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; - - if (P_BoxOnLineSide(preciptmbbox, ld) != -1) - return true; - - if (ld->polyobj) // line belongs to a polyobject, don't add it - return true; - - // This line crosses through the object. - - // Collect the sector(s) from the line and add to the - // sector_list you're examining. If the Thing ends up being - // allowed to move to this position, then the sector_list - // will be attached to the Thing's mobj_t at touching_sectorlist. - - precipsector_list = P_AddPrecipSecnode(ld->frontsector, tmprecipthing, precipsector_list); - - // Don't assume all lines are 2-sided, since some Things - // like MT_TFOG are allowed regardless of whether their radius takes - // them beyond an impassable linedef. - - // Use sidedefs instead of 2s flag to determine two-sidedness. - if (ld->backsector) - precipsector_list = P_AddPrecipSecnode(ld->backsector, tmprecipthing, precipsector_list); - - return true; -} - // P_CreateSecNodeList alters/creates the sector_list that shows what sectors // the object resides in. @@ -4237,73 +4084,6 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) } } -// More crazy crap Tails 08-25-2002 -void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) -{ - INT32 xl, xh, yl, yh, bx, by; - mprecipsecnode_t *node = precipsector_list; - precipmobj_t *saved_tmthing = tmprecipthing; /* cph - see comment at func end */ - - // First, clear out the existing m_thing fields. As each node is - // added or verified as needed, m_thing will be set properly. When - // finished, delete all nodes where m_thing is still NULL. These - // represent the sectors the Thing has vacated. - - while (node) - { - node->m_thing = NULL; - node = node->m_sectorlist_next; - } - - tmprecipthing = thing; - - preciptmbbox[BOXTOP] = y + 2*FRACUNIT; - preciptmbbox[BOXBOTTOM] = y - 2*FRACUNIT; - preciptmbbox[BOXRIGHT] = x + 2*FRACUNIT; - preciptmbbox[BOXLEFT] = x - 2*FRACUNIT; - - validcount++; // used to make sure we only process a line once - - xl = (unsigned)(preciptmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(preciptmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(preciptmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(preciptmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - for (bx = xl; bx <= xh; bx++) - for (by = yl; by <= yh; by++) - P_BlockLinesIterator(bx, by, PIT_GetPrecipSectors); - - // Add the sector of the (x, y) point to sector_list. - precipsector_list = P_AddPrecipSecnode(thing->subsector->sector, thing, precipsector_list); - - // Now delete any nodes that won't be used. These are the ones where - // m_thing is still NULL. - node = precipsector_list; - while (node) - { - if (!node->m_thing) - { - if (node == precipsector_list) - precipsector_list = node->m_sectorlist_next; - node = P_DelPrecipSecnode(node); - } - else - node = node->m_sectorlist_next; - } - - /* cph - - * This is the strife we get into for using global variables. tmthing - * is being used by several different functions calling - * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tmthing is not reentrant. - * OTOH for Boom/MBF demos we have to preserve the buggy behavior. - * Fun. We restore its previous value unless we're in a Boom/MBF demo. - */ - tmprecipthing = saved_tmthing; -} - /* cphipps 2004/08/30 - * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) diff --git a/src/p_maputl.c b/src/p_maputl.c index 13dd85592..a88545135 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -782,9 +782,6 @@ void P_UnsetPrecipThingPosition(precipmobj_t *thing) if (bprev && (*bprev = bnext) != NULL) // unlink from block map bnext->bprev = bprev; - - precipsector_list = thing->touching_sectorlist; - thing->touching_sectorlist = NULL; //to be restored by P_SetPrecipThingPosition } static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap) @@ -929,10 +926,6 @@ void P_SetPrecipitationThingPosition(precipmobj_t *thing) { thing->subsector = R_PointInSubsector(thing->x, thing->y); - P_CreatePrecipSecNodeList(thing, thing->x, thing->y); - thing->touching_sectorlist = precipsector_list; // Attach to Thing's precipmobj_t - precipsector_list = NULL; // clear for next time - // NOTE: this works because bnext/bprev are at the same // offsets in precipmobj_t and mobj_t P_LinkToBlockMap((mobj_t*)thing, (mobj_t**)precipblocklinks); diff --git a/src/p_mobj.c b/src/p_mobj.c index a731bd366..d140b2303 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3572,7 +3572,7 @@ animonly: } } -static void CalculatePrecipFloor(precipmobj_t *mobj) +static void P_CalculatePrecipFloor(precipmobj_t *mobj) { // recalculate floorz each time const sector_t *mobjsecsubsec; @@ -3606,19 +3606,6 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) } } -void P_RecalcPrecipInSector(sector_t *sector) -{ - mprecipsecnode_t *psecnode; - - if (!sector) - return; - - sector->moved = true; // Recalc lighting and things too, maybe - - for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_thinglist_next) - CalculatePrecipFloor(psecnode->m_thing); -} - // // P_NullPrecipThinker // @@ -3685,6 +3672,8 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if (mobj->precipflags & PCF_SPLASH) return true; + P_CalculatePrecipFloor(mobj); + // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) { @@ -10046,7 +10035,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; P_AddPrecipThinker(&mobj->thinker); - CalculatePrecipFloor(mobj); + P_CalculatePrecipFloor(mobj); if (mobj->floorz != starting_floorz) mobj->precipflags |= PCF_FOF; @@ -10206,12 +10195,6 @@ void P_FreePrecipMobj(precipmobj_t *mobj) // unlink from sector and block lists P_UnsetPrecipThingPosition(mobj); - if (precipsector_list) - { - P_DelPrecipSeclist(precipsector_list); - precipsector_list = NULL; - } - // free block // Precipmobjs don't actually think using their thinker, // so the free cannot be delayed. @@ -10225,12 +10208,6 @@ void P_RemoveSavegameMobj(mobj_t *mobj) if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker) { P_UnsetPrecipThingPosition((precipmobj_t *)mobj); - - if (precipsector_list) - { - P_DelPrecipSeclist(precipsector_list); - precipsector_list = NULL; - } } else { diff --git a/src/r_defs.h b/src/r_defs.h index bc95649bb..4931eb2fb 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -354,9 +354,6 @@ typedef struct sector_s // Current speed of ceiling/floor. For Knuckles to hold onto stuff. fixed_t floorspeed, ceilspeed; - // list of precipitation mobjs in sector - struct mprecipsecnode_s *touching_preciplist; - // Eternity engine slope pslope_t *f_slope; // floor slope pslope_t *c_slope; // ceiling slope @@ -492,17 +489,6 @@ typedef struct msecnode_s boolean visited; // used in search algorithms } msecnode_t; -typedef struct mprecipsecnode_s -{ - sector_t *m_sector; // a sector containing this object - struct precipmobj_s *m_thing; // this object - struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing - struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing - struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector - struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector - boolean visited; // used in search algorithms -} mprecipsecnode_t; - // // The lineseg. //