From c1304e019d9744c3877efa0ee59795df16681663 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 09:15:34 +0200 Subject: [PATCH 1/2] Clean up Thwomp spawning code --- src/p_spec.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index cebab0902..937015253 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6988,14 +6988,8 @@ void P_SpawnSpecials(boolean fromnetsave) fixed_t crushspeed = (lines[i].flags & ML_EFFECT5) ? lines[i].dy >> 3 : 10*FRACUNIT; fixed_t retractspeed = (lines[i].flags & ML_EFFECT5) ? lines[i].dx >> 3 : 2*FRACUNIT; UINT16 sound = (lines[i].flags & ML_EFFECT4) ? sides[lines[i].sidenum[0]].textureoffset >> FRACBITS : sfx_thwomp; - - sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromTag(lines[i].tag, s)) >= 0 ;) - { - P_AddThwompThinker(§ors[sec], lines[i].tag, &lines[i], crushspeed, retractspeed, sound); - P_AddFakeFloor(§ors[s], §ors[sec], lines + i, - FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - } + P_AddThwompThinker(lines[i].frontsector, lines[i].tag, &lines[i], crushspeed, retractspeed, sound); + P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); break; } From 2a392651564981c88f6eaac5110a97165a083022 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 2 May 2020 10:03:16 +0200 Subject: [PATCH 2/2] Make the laser thinker find the FOF itself instead of storing it in the thinker struct --- src/p_saveg.c | 11 +---- src/p_spec.c | 120 +++++++++++++++++++++++--------------------------- src/p_spec.h | 4 +- 3 files changed, 57 insertions(+), 78 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index e8c6593fa..54ffc7cbb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1890,8 +1890,7 @@ static void SaveLaserThinker(const thinker_t *th, const UINT8 type) { const laserthink_t *ht = (const void *)th; WRITEUINT8(save_p, type); - WRITEUINT32(save_p, SaveSector(ht->sector)); - WRITEUINT32(save_p, SaveSector(ht->sec)); + WRITEINT16(save_p, ht->tag); WRITEUINT32(save_p, SaveLine(ht->sourceline)); WRITEUINT8(save_p, ht->nobosses); } @@ -3001,16 +3000,10 @@ static thinker_t* LoadPusherThinker(actionf_p1 thinker) static inline thinker_t* LoadLaserThinker(actionf_p1 thinker) { laserthink_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); - ffloor_t *rover = NULL; ht->thinker.function.acp1 = thinker; - ht->sector = LoadSector(READUINT32(save_p)); - ht->sec = LoadSector(READUINT32(save_p)); + ht->tag = READINT16(save_p); ht->sourceline = LoadLine(READUINT32(save_p)); ht->nobosses = READUINT8(save_p); - for (rover = ht->sector->ffloors; rover; rover = rover->next) - if (rover->secnum == (size_t)(ht->sec - sectors) - && rover->master == ht->sourceline) - ht->ffloor = rover; return &ht->thinker; } diff --git a/src/p_spec.c b/src/p_spec.c index 937015253..0ce3df57b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6136,92 +6136,83 @@ static inline void P_AddCameraScanner(sector_t *sourcesec, sector_t *actionsecto elevator->distance = FixedInt(AngleFixed(angle)); } -static const ffloortype_e laserflags = FF_EXISTS|FF_RENDERALL|FF_NOSHADE|FF_EXTRA|FF_CUTEXTRA|FF_TRANSLUCENT; - /** Flashes a laser block. * * \param flash Thinker structure for this laser. - * \sa EV_AddLaserThinker + * \sa P_AddLaserThinker * \author SSNTails */ void T_LaserFlash(laserthink_t *flash) { msecnode_t *node; mobj_t *thing; - sector_t *sourcesec; - ffloor_t *fflr = flash->ffloor; - sector_t *sector = flash->sector; + INT32 s; + ffloor_t *fflr; + sector_t *sector; + sector_t *sourcesec = flash->sourceline->frontsector; fixed_t top, bottom; - if (!fflr || !(fflr->flags & FF_EXISTS)) - return; - - if (leveltime & 2) - //fflr->flags |= FF_RENDERALL; - fflr->alpha = 0xB0; - else - //fflr->flags &= ~FF_RENDERALL; - fflr->alpha = 0x90; - - sourcesec = fflr->master->frontsector; // Less to type! - - top = (*fflr->t_slope) ? P_GetZAt(*fflr->t_slope, sector->soundorg.x, sector->soundorg.y) - : *fflr->topheight; - bottom = (*fflr->b_slope) ? P_GetZAt(*fflr->b_slope, sector->soundorg.x, sector->soundorg.y) - : *fflr->bottomheight; - sector->soundorg.z = (top + bottom)/2; - S_StartSound(§or->soundorg, sfx_laser); - - // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* - for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_thinglist_next) + for (s = -1; (s = P_FindSectorFromTag(flash->tag, s)) >= 0 ;) { - thing = node->m_thing; + sector = §ors[s]; + for (fflr = sector->ffloors; fflr; fflr = fflr->next) + { + if (fflr->master != flash->sourceline) + continue; - if (flash->nobosses && thing->flags & MF_BOSS) - continue; // Don't hurt bosses + if (!(fflr->flags & FF_EXISTS)) + break; - // Don't endlessly kill egg guard shields (or anything else for that matter) - if (thing->health <= 0) - continue; + if (leveltime & 2) + //fflr->flags |= FF_RENDERALL; + fflr->alpha = 0xB0; + else + //fflr->flags &= ~FF_RENDERALL; + fflr->alpha = 0x90; - top = P_GetSpecialTopZ(thing, sourcesec, sector); - bottom = P_GetSpecialBottomZ(thing, sourcesec, sector); + top = (*fflr->t_slope) ? P_GetZAt(*fflr->t_slope, sector->soundorg.x, sector->soundorg.y) : *fflr->topheight; + bottom = (*fflr->b_slope) ? P_GetZAt(*fflr->b_slope, sector->soundorg.x, sector->soundorg.y) : *fflr->bottomheight; + sector->soundorg.z = (top + bottom)/2; + S_StartSound(§or->soundorg, sfx_laser); - if (thing->z >= top - || thing->z + thing->height <= bottom) - continue; + // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* + for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_thinglist_next) + { + thing = node->m_thing; - if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, NULL, NULL, 1, 0); - else if (thing->type == MT_EGGSHIELD) - P_KillMobj(thing, NULL, NULL, 0); + if (flash->nobosses && thing->flags & MF_BOSS) + continue; // Don't hurt bosses + + // Don't endlessly kill egg guard shields (or anything else for that matter) + if (thing->health <= 0) + continue; + + top = P_GetSpecialTopZ(thing, sourcesec, sector); + bottom = P_GetSpecialBottomZ(thing, sourcesec, sector); + + if (thing->z >= top + || thing->z + thing->height <= bottom) + continue; + + if (thing->flags & MF_SHOOTABLE) + P_DamageMobj(thing, NULL, NULL, 1, 0); + else if (thing->type == MT_EGGSHIELD) + P_KillMobj(thing, NULL, NULL, 0); + } + + break; + } } } -/** Adds a laser thinker to a 3Dfloor. - * - * \param fflr 3Dfloor to turn into a laser block. - * \param sector Target sector. - * \param secthkiners Lists of thinkers sorted by sector. May be NULL. - * \sa T_LaserFlash - * \author SSNTails - */ -static inline void EV_AddLaserThinker(sector_t *sec, sector_t *sec2, line_t *line, thinkerlist_t *secthinkers, boolean nobosses) +static inline void P_AddLaserThinker(INT16 tag, line_t *line, boolean nobosses) { - laserthink_t *flash; - ffloor_t *fflr = P_AddFakeFloor(sec, sec2, line, laserflags, secthinkers); - - if (!fflr) - return; - - flash = Z_Calloc(sizeof (*flash), PU_LEVSPEC, NULL); + laserthink_t *flash = Z_Calloc(sizeof (*flash), PU_LEVSPEC, NULL); P_AddThinker(THINK_MAIN, &flash->thinker); flash->thinker.function.acp1 = (actionf_p1)T_LaserFlash; - flash->ffloor = fflr; - flash->sector = sec; // For finding mobjs - flash->sec = sec2; + flash->tag = tag; flash->sourceline = line; flash->nobosses = nobosses; } @@ -7030,11 +7021,8 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 258: // Laser block - sec = sides[*lines[i].sidenum].sector - sectors; - - // No longer totally disrupts netgames - for (s = -1; (s = P_FindSectorFromTag(lines[i].tag, s)) >= 0 ;) - EV_AddLaserThinker(§ors[s], §ors[sec], lines + i, secthinkers, !!(lines[i].flags & ML_EFFECT1)); + P_AddLaserThinker(lines[i].tag, lines + i, !!(lines[i].flags & ML_EFFECT1)); + P_AddFakeFloorsByLine(i, FF_EXISTS|FF_RENDERALL|FF_NOSHADE|FF_EXTRA|FF_CUTEXTRA|FF_TRANSLUCENT, secthinkers); break; case 259: // Custom FOF diff --git a/src/p_spec.h b/src/p_spec.h index 0228f8a02..596d8171d 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -104,9 +104,7 @@ typedef struct typedef struct { thinker_t thinker; ///< Thinker structure for laser. - ffloor_t *ffloor; ///< 3Dfloor that is a laser. - sector_t *sector; ///< Sector in which the effect takes place. - sector_t *sec; + INT16 tag; line_t *sourceline; UINT8 nobosses; } laserthink_t;