Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
Show changes
......@@ -17,7 +17,7 @@
#include "console.h"
#include "m_easing.h" // For Easing_InOutSine, used in R_UpdatePlaneRipple
#include "g_game.h"
#include "p_setup.h" // levelflats
#include "p_world.h" // levelflats
#include "p_slopes.h"
#include "r_data.h"
#include "r_textures.h"
......@@ -436,7 +436,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
// This appears to fix the Nimbus Ruins sky bug.
if (picnum == skyflatnum && pfloor)
if (picnum == viewworld->skyflatnum && pfloor)
{
height = 0; // all skies map together
lightlevel = 0;
......@@ -657,8 +657,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
// by sector colormaps (INVUL inverse mapping is not implemented in SRB2 so is irrelevant).
dc_colormap = colormaps;
dc_texturemid = skytexturemid;
dc_texheight = textureheight[skytexture]
>>FRACBITS;
dc_texheight = textureheight[viewworld->skytexture]>>FRACBITS;
for (x = pl->minx; x <= pl->maxx; x++)
{
dc_yl = pl->top[x];
......@@ -669,9 +668,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
dc_x = x;
dc_source =
R_GetColumn(texturetranslation[skytexture],
-angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
dc_source = R_GetColumn(texturetranslation[viewworld->skytexture], -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
colfunc();
}
}
......@@ -864,7 +861,7 @@ void R_DrawSinglePlane(visplane_t *pl)
return;
// sky flat
if (pl->picnum == skyflatnum)
if (pl->picnum == viewworld->skyflatnum)
{
R_DrawSkyPlane(pl);
return;
......@@ -978,7 +975,7 @@ void R_DrawSinglePlane(visplane_t *pl)
}
else
{
levelflat_t *levelflat = &levelflats[pl->picnum];
levelflat_t *levelflat = &viewworld->flats[pl->picnum];
/* :james: */
switch (levelflat->type)
......
......@@ -155,8 +155,8 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con
portal_t* portal = Portal_Add(x1, x2);
// Offset the portal view by the linedef centers
line_t* start = &lines[line1];
line_t* dest = &lines[line2];
line_t* start = &viewworld->lines[line1];
line_t* dest = &viewworld->lines[line2];
angle_t dangle = R_PointToAngle2(0,0,dest->dx,dest->dy) - R_PointToAngle2(start->dx,start->dy,0,0);
......@@ -270,28 +270,28 @@ void Portal_AddSkybox (const visplane_t* plane)
Portal_ClipVisplane(plane, portal);
portal->viewx = skyboxmo[0]->x;
portal->viewy = skyboxmo[0]->y;
portal->viewz = skyboxmo[0]->z;
portal->viewangle = viewangle + skyboxmo[0]->angle;
portal->viewx = viewworld->skyboxmo[0]->x;
portal->viewy = viewworld->skyboxmo[0]->y;
portal->viewz = viewworld->skyboxmo[0]->z;
portal->viewangle = viewangle + viewworld->skyboxmo[0]->angle;
mh = mapheaderinfo[gamemap-1];
mh = viewworld->header;
// If a relative viewpoint exists, offset the viewpoint.
if (skyboxmo[1])
if (viewworld->skyboxmo[1])
{
fixed_t x = 0, y = 0;
angle_t ang = skyboxmo[0]->angle>>ANGLETOFINESHIFT;
angle_t ang = viewworld->skyboxmo[0]->angle>>ANGLETOFINESHIFT;
if (mh->skybox_scalex > 0)
x = (viewx - skyboxmo[1]->x) / mh->skybox_scalex;
x = (viewx - viewworld->skyboxmo[1]->x) / mh->skybox_scalex;
else if (mh->skybox_scalex < 0)
x = (viewx - skyboxmo[1]->x) * -mh->skybox_scalex;
x = (viewx - viewworld->skyboxmo[1]->x) * -mh->skybox_scalex;
if (mh->skybox_scaley > 0)
y = (viewy - skyboxmo[1]->y) / mh->skybox_scaley;
y = (viewy - viewworld->skyboxmo[1]->y) / mh->skybox_scaley;
else if (mh->skybox_scaley < 0)
y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley;
y = (viewy - viewworld->skyboxmo[1]->y) * -mh->skybox_scaley;
// Apply transform to account for the skybox viewport angle.
portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
......@@ -319,7 +319,7 @@ void Portal_AddSkyboxPortals (void)
{
for (pl = visplanes[i]; pl; pl = pl->next)
{
if (pl->picnum == skyflatnum)
if (pl->picnum == viewworld->skyflatnum)
{
Portal_AddSkybox(pl);
......
......@@ -24,6 +24,7 @@
#include "m_misc.h"
#include "p_local.h" // Camera...
#include "p_slopes.h"
#include "p_world.h"
#include "console.h" // con_clipviewtop
#include "taglist.h"
......@@ -290,12 +291,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
mceilingclip = ds->sprtopclip;
if (frontsector->heightsec != -1)
front = &sectors[frontsector->heightsec];
front = &viewworld->sectors[frontsector->heightsec];
else
front = frontsector;
if (backsector->heightsec != -1)
back = &sectors[backsector->heightsec];
back = &viewworld->sectors[backsector->heightsec];
else
back = backsector;
......@@ -591,7 +592,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
curline = ds->curline;
backsector = pfloor->target;
frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector;
texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture);
texnum = R_GetTextureNum(viewworld->sides[pfloor->master->sidenum[0]].midtexture);
colfunc = colfuncs[BASEDRAWFUNC];
......@@ -599,7 +600,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
size_t linenum = curline->linedef-backsector->lines[0];
newline = pfloor->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture);
texnum = R_GetTextureNum(viewworld->sides[newline->sidenum[0]].midtexture);
}
if (pfloor->fofflags & FOF_TRANSLUCENT)
......@@ -778,7 +779,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (newline)
{
offsetvalue = sides[newline->sidenum[0]].rowoffset;
offsetvalue = viewworld->sides[newline->sidenum[0]].rowoffset;
if (newline->flags & ML_DONTPEGBOTTOM)
{
skewslope = *pfloor->b_slope; // skew using bottom slope
......@@ -790,7 +791,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
}
else
{
offsetvalue = sides[pfloor->master->sidenum[0]].rowoffset;
offsetvalue = viewworld->sides[pfloor->master->sidenum[0]].rowoffset;
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{
skewslope = *pfloor->b_slope; // skew using bottom slope
......@@ -1806,15 +1807,15 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// hack to allow height changes in outdoor areas
// This is what gets rid of the upper textures if there should be sky
if (frontsector->ceilingpic == skyflatnum
&& backsector->ceilingpic == skyflatnum)
if (frontsector->ceilingpic == viewworld->skyflatnum
&& backsector->ceilingpic == viewworld->skyflatnum)
{
bothceilingssky = true;
}
// likewise, but for floors and upper textures
if (frontsector->floorpic == skyflatnum
&& backsector->floorpic == skyflatnum)
if (frontsector->floorpic == viewworld->skyflatnum
&& backsector->floorpic == viewworld->skyflatnum)
{
bothfloorssky = true;
}
......@@ -1910,7 +1911,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| backsector->floor_yoffs != frontsector->floor_yoffs
|| backsector->floorpic_angle != frontsector->floorpic_angle
//SoM: 3/22/2000: Prevents bleeding.
|| (frontsector->heightsec != -1 && frontsector->floorpic != skyflatnum)
|| (frontsector->heightsec != -1 && frontsector->floorpic != viewworld->skyflatnum)
|| backsector->floorlightlevel != frontsector->floorlightlevel
|| backsector->floorlightabsolute != frontsector->floorlightabsolute
|| backsector->floorlightsec != frontsector->floorlightsec
......@@ -1943,7 +1944,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| backsector->ceiling_yoffs != frontsector->ceiling_yoffs
|| backsector->ceilingpic_angle != frontsector->ceilingpic_angle
//SoM: 3/22/2000: Prevents bleeding.
|| (frontsector->heightsec != -1 && frontsector->ceilingpic != skyflatnum)
|| (frontsector->heightsec != -1 && frontsector->ceilingpic != viewworld->skyflatnum)
|| backsector->ceilinglightlevel != frontsector->ceilinglightlevel
|| backsector->ceilinglightabsolute != frontsector->ceilinglightabsolute
|| backsector->ceilinglightsec != frontsector->ceilinglightsec
......@@ -2331,13 +2332,13 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// and doesn't need to be marked.
if (frontsector->heightsec == -1)
{
if (frontsector->floorpic != skyflatnum && P_GetSectorFloorZAt(frontsector, viewx, viewy) >= viewz)
if (frontsector->floorpic != viewworld->skyflatnum && P_GetSectorFloorZAt(frontsector, viewx, viewy) >= viewz)
{
// above view plane
markfloor = false;
}
if (frontsector->ceilingpic != skyflatnum && P_GetSectorCeilingZAt(frontsector, viewx, viewy) <= viewz)
if (frontsector->ceilingpic != viewworld->skyflatnum && P_GetSectorCeilingZAt(frontsector, viewx, viewy) <= viewz)
{
// below view plane
markceiling = false;
......
......@@ -225,7 +225,7 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum)
return true;
}
if (Playing() && mapheaderinfo[gamemap-1] && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum))
if (Playing() && worldmapheader && (R_SkinAvailable(worldmapheader->forcecharacter) == skinnum))
{
// Force 1.
return true;
......
......@@ -28,14 +28,9 @@
// sky mapping
//
/** \brief Needed to store the number of the dummy sky flat.
Used for rendering, as well as tracking projectiles etc.
*/
INT32 skyflatnum;
/** \brief the lump number of the sky texture
/** \brief used for keeping track of the current sky
*/
INT32 skytexture;
INT32 levelskynum;
/** \brief the horizon line in a 256x128 sky texture
*/
......@@ -45,11 +40,6 @@ INT32 skytexturemid;
*/
fixed_t skyscale;
/** \brief used for keeping track of the current sky
*/
INT32 levelskynum;
INT32 globallevelskynum;
/** \brief The R_SetupSkyDraw function
Called at loadlevel after skytexture is set, or when sky texture changes.
......@@ -62,8 +52,7 @@ INT32 globallevelskynum;
void R_SetupSkyDraw(void)
{
// the horizon line in a 256x128 sky texture
skytexturemid = (textures[skytexture]->height/2)<<FRACBITS;
skytexturemid = (textures[viewworld->skytexture]->height/2)<<FRACBITS;
R_SetSkyScale();
}
......
......@@ -15,6 +15,7 @@
#define __R_SKY__
#include "m_fixed.h"
#include "p_world.h"
#ifdef __GNUG__
#pragma interface
......@@ -26,16 +27,13 @@
/// \brief The sky map is 256*128*4 maps.
#define ANGLETOSKYSHIFT 22
extern INT32 skytexture, skytexturemid;
extern INT32 skytexturemid;
extern fixed_t skyscale;
extern INT32 skyflatnum;
extern INT32 levelskynum;
extern INT32 globallevelskynum;
// call after skytexture is set to adapt for old/new skies
void R_SetupSkyDraw(void);
void R_SetSkyScale(void);
#endif
......@@ -34,6 +34,7 @@
#include "p_tick.h"
#include "p_local.h"
#include "p_slopes.h"
#include "p_world.h"
#include "d_netfil.h" // blargh. for nameonly().
#include "m_cheat.h" // objectplace
#ifdef HWRENDER
......@@ -1170,7 +1171,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
slope = sector->heightsec != -1 ? NULL : (isflipped ? sector->c_slope : sector->f_slope);
if (sector->heightsec != -1)
z = isflipped ? sectors[sector->heightsec].ceilingheight : sectors[sector->heightsec].floorheight;
z = isflipped ? viewworld->sectors[sector->heightsec].ceilingheight : viewworld->sectors[sector->heightsec].floorheight;
else
z = isflipped ? P_GetSectorCeilingZAt(sector, interp.x, interp.y) : P_GetSectorFloorZAt(sector, interp.x, interp.y);
......@@ -2379,9 +2380,6 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
INT32 lightnum;
fixed_t limit_dist, hoop_limit_dist;
if (rendermode != render_soft)
return;
// BSP is traversed by subsector.
// A sector might have been split into several
// subsectors during BSP building.
......@@ -2678,22 +2676,22 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
// find all the remaining polyobject planes and add them on the end of the list
// probably this is a terrible idea if we wanted them to be sorted properly
// but it works getting them in for now
for (i = 0; i < numPolyObjects; i++)
for (i = 0; i < viewworld->numPolyObjects; i++)
{
if (!PolyObjects[i].visplane)
if (!viewworld->PolyObjects[i].visplane)
continue;
plane = PolyObjects[i].visplane;
plane = viewworld->PolyObjects[i].visplane;
R_PlaneBounds(plane);
if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low)
{
PolyObjects[i].visplane = NULL;
viewworld->PolyObjects[i].visplane = NULL;
continue;
}
entry = R_CreateDrawNode(head);
entry->plane = plane;
// note: no seg is set, for what should be obvious reasons
PolyObjects[i].visplane = NULL;
viewworld->PolyObjects[i].visplane = NULL;
}
// No vissprites in this mask?
......@@ -2969,11 +2967,11 @@ static void R_HeightSecClip(vissprite_t *spr, INT32 x1, INT32 x2)
phs = viewplayer->mo->subsector->sector->heightsec;
if ((mh = sectors[spr->heightsec].floorheight) > spr->gz &&
if ((mh = viewworld->sectors[spr->heightsec].floorheight) > spr->gz &&
(h = centeryfrac - FixedMul(mh -= viewz, spr->sortscale)) >= 0 &&
(h >>= FRACBITS) < viewheight)
{
if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight))
if (mh <= 0 || (phs != -1 && viewz > viewworld->sectors[phs].floorheight))
{ // clip bottom
for (x = x1; x <= x2; x++)
if (spr->clipbot[x] == -2 || h < spr->clipbot[x])
......@@ -2987,11 +2985,11 @@ static void R_HeightSecClip(vissprite_t *spr, INT32 x1, INT32 x2)
}
}
if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt &&
if ((mh = viewworld->sectors[spr->heightsec].ceilingheight) < spr->gzt &&
(h = centeryfrac - FixedMul(mh-viewz, spr->sortscale)) >= 0 &&
(h >>= FRACBITS) < viewheight)
{
if (phs != -1 && viewz >= sectors[phs].ceilingheight)
if (phs != -1 && viewz >= viewworld->sectors[phs].ceilingheight)
{ // clip bottom
for (x = x1; x <= x2; x++)
if (spr->clipbot[x] == -2 || h < spr->clipbot[x])
......
......@@ -24,7 +24,7 @@
#include "w_wad.h"
#include "z_zone.h"
#include "d_main.h"
#include "r_sky.h" // skyflatnum
#include "p_world.h" // world->skyflatnum
#include "p_local.h" // camera info
#include "fastcmp.h"
#include "m_misc.h" // for tunes command
......@@ -1128,7 +1128,7 @@ INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *v
{
fixed_t x, y, yl, yh, xl, xh, newdist;
if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == world->skyflatnum)
approx_dist = 0;
else
{
......@@ -1141,7 +1141,7 @@ INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *v
for (y = yl; y <= yh; y += FRACUNIT*64)
for (x = xl; x <= xh; x += FRACUNIT*64)
{
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)
if (R_PointInSubsector(x, y)->sector->ceilingpic == world->skyflatnum)
{
// Found the outdoors!
newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0);
......@@ -1783,6 +1783,20 @@ boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
);
}
INT32 S_ShouldResetMusic(mapheader_t *mapheader)
{
if (modeattacking)
return 0;
if (cv_resetmusicbyheader.value && mapheader)
{
if (mapheader->musforcereset != -1)
return mapheader->musforcereset;
}
return cv_resetmusic.value;
}
/// ------------------------
/// Music Effects
/// ------------------------
......@@ -2424,25 +2438,32 @@ boolean S_FadeOutStopMusic(UINT32 ms)
/// Init & Others
/// ------------------------
//
// Per level startup code.
// Kills playing sounds at start of level,
// determines music if any, changes music.
//
void S_StartEx(boolean reset)
void S_SetMapMusic(mapheader_t *mapheader)
{
strncpy(mapmusname, mapheader->musname, 7);
mapmusname[6] = 0;
mapmusflags = (mapheader->mustrack & MUSIC_TRACKMASK);
mapmusposition = mapheader->muspos;
}
void S_PlayMapMusic(mapheader_t *mapheader, boolean reset)
{
if (mapmusflags & MUSIC_RELOADRESET)
{
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7);
mapmusname[6] = 0;
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
mapmusposition = mapheaderinfo[gamemap-1]->muspos;
}
S_SetMapMusic(mapheader);
if (RESETMUSIC || reset)
if (S_ShouldResetMusic(mapheader) || reset)
S_StopMusic();
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
}
//
// Per level startup code.
// Kills playing sounds at start of level,
// determines music if any, changes music.
//
void S_StartEx(mapheader_t *mapheader, boolean reset)
{
S_PlayMapMusic(mapheader, reset);
S_ResetMusicStack();
music_stack_noposition = false;
music_stack_fadeout = 0;
......@@ -2483,8 +2504,8 @@ static void Command_Tunes_f(void)
}
else if (!strcasecmp(tunearg, "-default"))
{
tunearg = mapheaderinfo[gamemap-1]->musname;
track = mapheaderinfo[gamemap-1]->mustrack;
tunearg = worldmapheader->musname;
track = worldmapheader->mustrack;
}
if (strlen(tunearg) > 6) // This is automatic -- just show the error just in case
......
......@@ -18,6 +18,7 @@
#include "sounds.h"
#include "m_fixed.h"
#include "command.h"
#include "doomstat.h"
#include "tables.h" // angle_t
#ifdef HAVE_OPENMPT
......@@ -37,11 +38,7 @@ extern consvar_t cv_resetmusicbyheader;
extern consvar_t cv_1upsound;
#define RESETMUSIC (!modeattacking && \
(cv_resetmusicbyheader.value ? \
(mapheaderinfo[gamemap-1]->musforcereset != -1 ? mapheaderinfo[gamemap-1]->musforcereset : cv_resetmusic.value) \
: cv_resetmusic.value) \
)
INT32 S_ShouldResetMusic(mapheader_t *mapheader);
extern consvar_t cv_gamedigimusic;
extern consvar_t cv_gamemidimusic;
......@@ -125,8 +122,10 @@ void S_InitSfxChannels(INT32 sfxVolume);
//
void S_StopSounds(void);
void S_ClearSfx(void);
void S_StartEx(boolean reset);
#define S_Start() S_StartEx(false)
void S_SetMapMusic(mapheader_t *mapheader);
void S_PlayMapMusic(mapheader_t *mapheader, boolean reset);
void S_StartEx(mapheader_t *mapheader, boolean reset);
#define S_Start(mapheader) S_StartEx(mapheader, false)
//
// Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum.
......
......@@ -150,7 +150,7 @@ static void Midiplayer_Onchange(void)
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
if (restart)
S_StartEx(true);
S_StartEx(worldmapheader, true);
}
static void MidiSoundfontPath_Onchange(void)
......@@ -188,7 +188,7 @@ static void MidiSoundfontPath_Onchange(void)
if (!Mix_SetSoundFonts(cv_midisoundfontpath.string))
CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError());
else
S_StartEx(true);
S_StartEx(worldmapheader, true);
}
}
}
......
......@@ -739,7 +739,7 @@ static void ST_drawTime(void)
// right now before the island blows up with you on it!"
// "Blows up??" *awkward silence* "I've got to get outta
// here and find Amy and Tails right away!"
else if (mapheaderinfo[gamemap-1]->countdown)
else if (worldmapheader->countdown)
{
tics = countdowntimer;
downwards = true;
......@@ -1232,15 +1232,15 @@ static void ST_cacheLevelTitle(void)
#define SETPATCH(default, warning, custom, idx) \
{ \
lumpnum_t patlumpnum = LUMPERROR; \
if (mapheaderinfo[gamemap-1]->custom[0] != '\0') \
if (worldmapheader->custom[0] != '\0') \
{ \
patlumpnum = W_CheckNumForName(mapheaderinfo[gamemap-1]->custom); \
patlumpnum = W_CheckNumForName(worldmapheader->custom); \
if (patlumpnum != LUMPERROR) \
lt_patches[idx] = (patch_t *)W_CachePatchNum(patlumpnum, PU_HUDGFX); \
} \
if (patlumpnum == LUMPERROR) \
{ \
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_WARNINGTITLE)) \
if (!(worldmapheader->levelflags & LF_WARNINGTITLE)) \
lt_patches[idx] = (patch_t *)W_CachePatchName(default, PU_HUDGFX); \
else \
lt_patches[idx] = (patch_t *)W_CachePatchName(warning, PU_HUDGFX); \
......@@ -1343,9 +1343,9 @@ void ST_runTitleCard(void)
//
void ST_drawTitleCard(void)
{
char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl;
char *subttl = mapheaderinfo[gamemap-1]->subttl;
UINT8 actnum = mapheaderinfo[gamemap-1]->actnum;
char *lvlttl = worldmapheader->lvlttl;
char *subttl = worldmapheader->subttl;
UINT8 actnum = worldmapheader->actnum;
INT32 lvlttlxpos, ttlnumxpos, zonexpos;
INT32 subttlxpos = BASEVIDWIDTH/2;
INT32 ttlscroll = FixedInt(lt_scroll);
......@@ -1412,7 +1412,7 @@ void ST_drawTitleCard(void)
}
V_DrawLevelTitle(lvlttlxpos - ttlscroll, 80, V_PERPLAYER, lvlttl);
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE))
if (!(worldmapheader->levelflags & LF_NOZONE))
V_DrawLevelTitle(zonexpos + ttlscroll, 104, V_PERPLAYER, M_GetText("Zone"));
V_DrawCenteredString(subttlxpos - ttlscroll, 135, V_PERPLAYER|V_ALLOWLOWERCASE, subttl);
......@@ -2558,20 +2558,21 @@ static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offse
static void ST_doHuntIconsAndSound(void)
{
INT32 interval = 0, newinterval = 0;
mobj_t **hunt = world->emerald_hunt_locations;
if (hunt1 && hunt1->health)
interval = ST_drawEmeraldHuntIcon(hunt1, hunthoming, -20);
if (hunt[0] && hunt[0]->health)
interval = ST_drawEmeraldHuntIcon(hunt[0], hunthoming, -20);
if (hunt2 && hunt2->health)
if (hunt[1] && hunt[1]->health)
{
newinterval = ST_drawEmeraldHuntIcon(hunt2, hunthoming, 0);
newinterval = ST_drawEmeraldHuntIcon(hunt[1], hunthoming, 0);
if (newinterval && (!interval || newinterval < interval))
interval = newinterval;
}
if (hunt3 && hunt3->health)
if (hunt[2] && hunt[2]->health)
{
newinterval = ST_drawEmeraldHuntIcon(hunt3, hunthoming, 20);
newinterval = ST_drawEmeraldHuntIcon(hunt[2], hunthoming, 20);
if (newinterval && (!interval || newinterval < interval))
interval = newinterval;
}
......@@ -2671,7 +2672,7 @@ static void ST_overlayDrawer(void)
// Check for a valid level title
// If the HUD is enabled
// And, if Lua is running, if the HUD library has the stage title enabled
if (G_IsTitleCardAvailable() && *mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)))
if (G_IsTitleCardAvailable() && *worldmapheader->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)))
{
stagetitle = true;
ST_preDrawTitleCard();
......
......@@ -16,17 +16,9 @@
#include "r_data.h"
#include "p_spec.h"
// Bit array of whether a tag exists for sectors/lines/things.
bitarray_t tags_available[BIT_ARRAY_SIZE (MAXTAGS)];
size_t num_tags;
// Taggroups are used to list elements of the same tag, for iteration.
// Since elements can now have multiple tags, it means an element may appear
// in several taggroups at the same time. These are built on level load.
taggroup_t* tags_sectors[MAXTAGS + 1];
taggroup_t* tags_lines[MAXTAGS + 1];
taggroup_t* tags_mapthings[MAXTAGS + 1];
taggroup_t** tags_sectors;
taggroup_t** tags_lines;
taggroup_t** tags_mapthings;
/// Adds a tag to a given element's taglist. It will not add a duplicate.
/// \warning This does not rebuild the global taggroups, which are used for iteration.
......@@ -180,10 +172,10 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id)
if (Taggroup_Find(group, id) != (size_t)-1)
return;
if (! in_bit_array(tags_available, tag))
if (! in_bit_array(world->tags_available, tag))
{
num_tags++;
set_bit_array(tags_available, tag);
world->num_tags++;
set_bit_array(world->tags_available, tag);
}
// Create group if empty.
......@@ -220,10 +212,10 @@ static void Taggroup_Add_Init(taggroup_t *garray[], const mtag_t tag, size_t id)
group = garray[(UINT16)tag];
if (! in_bit_array(tags_available, tag))
if (! in_bit_array(world->tags_available, tag))
{
num_tags++;
set_bit_array(tags_available, tag);
world->num_tags++;
set_bit_array(world->tags_available, tag);
}
// Create group if empty.
......@@ -247,9 +239,9 @@ static size_t total_elements_with_tag (const mtag_t tag)
{
return
(
Taggroup_Count(tags_sectors[tag]) +
Taggroup_Count(tags_lines[tag]) +
Taggroup_Count(tags_mapthings[tag])
Taggroup_Count(world->tags_sectors[tag]) +
Taggroup_Count(world->tags_lines[tag]) +
Taggroup_Count(world->tags_mapthings[tag])
);
}
......@@ -270,8 +262,8 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id)
if (group->count == 1 && total_elements_with_tag(tag) == 1)
{
num_tags--;
unset_bit_array(tags_available, tag);
world->num_tags--;
unset_bit_array(world->tags_available, tag);
}
// Strip away taggroup if no elements left.
......@@ -302,17 +294,17 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id)
static void Taglist_AddToSectors (const mtag_t tag, const size_t itemid)
{
Taggroup_Add_Init(tags_sectors, tag, itemid);
Taggroup_Add_Init(world->tags_sectors, tag, itemid);
}
static void Taglist_AddToLines (const mtag_t tag, const size_t itemid)
{
Taggroup_Add_Init(tags_lines, tag, itemid);
Taggroup_Add_Init(world->tags_lines, tag, itemid);
}
static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid)
{
Taggroup_Add_Init(tags_mapthings, tag, itemid);
Taggroup_Add_Init(world->tags_mapthings, tag, itemid);
}
/// After all taglists have been built for each element (sectors, lines, things),
......@@ -321,29 +313,29 @@ void Taglist_InitGlobalTables(void)
{
size_t i, j;
memset(tags_available, 0, sizeof tags_available);
num_tags = 0;
memset(world->tags_available, 0, sizeof world->tags_available);
world->num_tags = 0;
for (i = 0; i < MAXTAGS; i++)
{
tags_sectors[i] = NULL;
tags_lines[i] = NULL;
tags_mapthings[i] = NULL;
world->tags_sectors[i] = NULL;
world->tags_lines[i] = NULL;
world->tags_mapthings[i] = NULL;
}
for (i = 0; i < numsectors; i++)
for (i = 0; i < world->numsectors; i++)
{
for (j = 0; j < sectors[i].tags.count; j++)
Taglist_AddToSectors(sectors[i].tags.tags[j], i);
for (j = 0; j < world->sectors[i].tags.count; j++)
Taglist_AddToSectors(world->sectors[i].tags.tags[j], i);
}
for (i = 0; i < numlines; i++)
for (i = 0; i < world->numlines; i++)
{
for (j = 0; j < lines[i].tags.count; j++)
Taglist_AddToLines(lines[i].tags.tags[j], i);
for (j = 0; j < world->lines[i].tags.count; j++)
Taglist_AddToLines(world->lines[i].tags.tags[j], i);
}
for (i = 0; i < nummapthings; i++)
for (i = 0; i < world->nummapthings; i++)
{
for (j = 0; j < mapthings[i].tags.count; j++)
Taglist_AddToMapthings(mapthings[i].tags.tags[j], i);
for (j = 0; j < world->mapthings[i].tags.count; j++)
Taglist_AddToMapthings(world->mapthings[i].tags.tags[j], i);
}
}
......@@ -351,17 +343,17 @@ void Taglist_InitGlobalTables(void)
INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p)
{
return Taggroup_Iterate(tags_sectors, numsectors, tag, p);
return Taggroup_Iterate(world->tags_sectors, world->numsectors, tag, p);
}
INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p)
{
return Taggroup_Iterate(tags_lines, numlines, tag, p);
return Taggroup_Iterate(world->tags_lines, world->numlines, tag, p);
}
INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p)
{
return Taggroup_Iterate(tags_mapthings, nummapthings, tag, p);
return Taggroup_Iterate(world->tags_mapthings, world->nummapthings, tag, p);
}
INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag)
......@@ -370,15 +362,15 @@ INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag)
if (tag == MTAG_GLOBAL)
{
for (i = 0; i < numlines; i++)
if (lines[i].special == special)
for (i = 0; i < world->numlines; i++)
if (world->lines[i].special == special)
return i;
}
else if (tags_lines[(UINT16)tag])
else if (world->tags_lines[(UINT16)tag])
{
taggroup_t *tagged = tags_lines[(UINT16)tag];
taggroup_t *tagged = world->tags_lines[(UINT16)tag];
for (i = 0; i < tagged->count; i++)
if (lines[tagged->elements[i]].special == special)
if (world->lines[tagged->elements[i]].special == special)
return tagged->elements[i];
}
return -1;
......@@ -391,10 +383,10 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
{
start++;
if (start >= (INT32)numlines)
if (start >= (INT32)world->numlines)
return -1;
while (start < (INT32)numlines && lines[start].special != special)
while (start < (INT32)world->numlines && world->lines[start].special != special)
start++;
return start;
......@@ -418,7 +410,7 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
}
for (; (id = Tag_Iterate_Lines(tag, p)) >= 0; p++)
if (lines[id].special == special)
if (world->lines[id].special == special)
return id;
return -1;
......@@ -447,13 +439,13 @@ void Tag_SectorRemove (const size_t id, const mtag_t tag)
/// Changes the first tag for a given sector, and updates the global taggroups.
void Tag_SectorFSet (const size_t id, const mtag_t tag)
{
sector_t* sec = &sectors[id];
sector_t* sec = &world->sectors[id];
mtag_t curtag = Tag_FGet(&sec->tags);
if (curtag == tag)
return;
Taggroup_Remove(tags_sectors, curtag, id);
Taggroup_Add(tags_sectors, tag, id);
Taggroup_Remove(world->tags_sectors, curtag, id);
Taggroup_Add(world->tags_sectors, tag, id);
Tag_FSet(&sec->tags, tag);
// Sectors with linedef trigger effects need to have their trigger tag updated too
......@@ -466,7 +458,7 @@ mtag_t Tag_NextUnused(mtag_t start)
{
while ((UINT16)start < MAXTAGS)
{
if (!in_bit_array(tags_available, (UINT16)start))
if (!in_bit_array(world->tags_available, (UINT16)start))
return start;
start++;
......
......@@ -53,9 +53,9 @@ extern mtag_t Tag_NextUnused(mtag_t start);
extern size_t num_tags;
extern taggroup_t* tags_sectors[];
extern taggroup_t* tags_lines[];
extern taggroup_t* tags_mapthings[];
extern taggroup_t** tags_sectors;
extern taggroup_t** tags_lines;
extern taggroup_t** tags_mapthings;
void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id);
void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id);
......
......@@ -316,8 +316,10 @@ static void LoadPalette(const char *lumpname)
Cubeapply = InitCube();
Z_Free(pLocalPalette);
Z_Free(pMasterPalette);
if (pLocalPalette)
Z_Free(pLocalPalette);
if (pMasterPalette)
Z_Free(pMasterPalette);
pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL);
pMasterPalette = Z_Malloc(sizeof (*pMasterPalette)*palsize, PU_STATIC, NULL);
......@@ -397,7 +399,7 @@ const char *R_GetPalname(UINT16 num)
const char *GetPalette(void)
{
if (gamestate == GS_LEVEL)
return R_GetPalname(mapheaderinfo[gamemap-1]->palette);
return R_GetPalname(worldmapheader->palette);
return "PLAYPAL";
}
......
......@@ -248,8 +248,8 @@ void Y_LoadIntermissionData(void)
// grab an interscreen if appropriate
if (mapheaderinfo[gamemap-1]->interscreen[0] != '#')
interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH);
if (worldmapheader->interscreen[0] != '#')
interpic = W_CachePatchName(worldmapheader->interscreen, PU_PATCH);
else // no interscreen? use default background
bgpatch = W_CachePatchName("INTERSCR", PU_PATCH);
break;
......@@ -263,8 +263,8 @@ void Y_LoadIntermissionData(void)
data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_PATCH);
// grab an interscreen if appropriate
if (mapheaderinfo[gamemap-1]->interscreen[0] != '#')
interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH);
if (worldmapheader->interscreen[0] != '#')
interpic = W_CachePatchName(worldmapheader->interscreen, PU_PATCH);
else // no interscreen? use default background
bgtile = W_CachePatchName("SPECTILE", PU_PATCH);
break;
......@@ -1043,15 +1043,15 @@ void Y_Ticker(void)
if (!intertic) // first time only
{
if (mapheaderinfo[gamemap-1]->musinterfadeout
if (worldmapheader->musinterfadeout
#ifdef _WIN32
// can't fade midi due to win32 volume hack
&& S_MusicType() != MU_MID
#endif
)
S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout);
else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled))
S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it
S_FadeOutStopMusic(worldmapheader->musinterfadeout);
else if (worldmapheader->musintername[0] && S_MusicExists(worldmapheader->musintername, !midi_disabled, !digital_disabled))
S_ChangeMusicInternal(worldmapheader->musintername, false); // don't loop it
else
S_ChangeMusicInternal("_clear", false); // don't loop it
tallydonetic = -1;
......@@ -1120,15 +1120,15 @@ void Y_Ticker(void)
if (!intertic) // first time only
{
if (mapheaderinfo[gamemap-1]->musinterfadeout
if (worldmapheader->musinterfadeout
#ifdef _WIN32
// can't fade midi due to win32 volume hack
&& S_MusicType() != MU_MID
#endif
)
S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout);
else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled))
S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it
S_FadeOutStopMusic(worldmapheader->musinterfadeout);
else if (worldmapheader->musintername[0] && S_MusicExists(worldmapheader->musintername, !midi_disabled, !digital_disabled))
S_ChangeMusicInternal(worldmapheader->musintername, false); // don't loop it
else
S_ChangeMusicInternal("_clear", false); // don't loop it
tallydonetic = -1;
......@@ -1348,10 +1348,10 @@ void Y_StartIntermission(void)
data.coop.tics = players[consoleplayer].realtime;
// get act number
data.coop.actnum = mapheaderinfo[gamemap-1]->actnum;
data.coop.actnum = worldmapheader->actnum;
// grab an interscreen if appropriate
if (mapheaderinfo[gamemap-1]->interscreen[0] != '#')
if (worldmapheader->interscreen[0] != '#')
{
useinterpic = true;
usebuffer = false;
......@@ -1369,9 +1369,9 @@ void Y_StartIntermission(void)
// set up the "got through act" message according to skin name
if (stagefailed)
{
strcpy(data.coop.passed1, mapheaderinfo[gamemap-1]->lvlttl);
strcpy(data.coop.passed1, worldmapheader->lvlttl);
if (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)
if (worldmapheader->levelflags & LF_NOZONE)
{
data.spec.passed2[0] = '\0';
}
......@@ -1386,25 +1386,25 @@ void Y_StartIntermission(void)
if (strlen(skins[players[consoleplayer].skin].realname) > 13)
{
strcpy(data.coop.passed1, "you got");
strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act");
strcpy(data.coop.passed2, (worldmapheader->actnum) ? "through act" : "through the act");
}
// long enough that "X GOT" won't fit so use "X PASSED THE ACT"
else if (strlen(skins[players[consoleplayer].skin].realname) > 8)
{
strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname);
strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "passed act" : "passed the act");
strcpy(data.coop.passed2, (worldmapheader->actnum) ? "passed act" : "passed the act");
}
// length is okay for normal use
else
{
snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s got",
skins[players[consoleplayer].skin].realname);
strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act");
strcpy(data.coop.passed2, (worldmapheader->actnum) ? "through act" : "through the act");
}
}
// set X positions
if (mapheaderinfo[gamemap-1]->actnum)
if (worldmapheader->actnum)
{
data.coop.passedx1 = 62 + (176 - V_LevelNameWidth(data.coop.passed1))/2;
data.coop.passedx2 = 62 + (176 - V_LevelNameWidth(data.coop.passed2))/2;
......@@ -1418,7 +1418,7 @@ void Y_StartIntermission(void)
// at the start of intermission, and precalculating it would preclude mods
// changing the font to one of a slightly different width.
if ((stagefailed) && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE))
if ((stagefailed) && !(worldmapheader->levelflags & LF_NOZONE))
{
// Bit of a hack, offset so that the "Zone" text is right aligned like title cards.
data.coop.passedx2 = (data.coop.passedx1 + V_LevelNameWidth(data.coop.passed1)) - V_LevelNameWidth(data.coop.passed2);
......@@ -1433,7 +1433,7 @@ void Y_StartIntermission(void)
Y_AwardSpecialStageBonus();
// grab an interscreen if appropriate
if (mapheaderinfo[gamemap-1]->interscreen[0] != '#')
if (worldmapheader->interscreen[0] != '#')
useinterpic = true;
else
useinterpic = false;
......