Merge branch 'public_next'

# Conflicts:
#	src/Makefile
#	src/lua_script.c
#	src/p_user.c
#	src/sdl/i_system.c
#	src/v_video.c
#	src/w_wad.c
This commit is contained in:
Monster Iestyn 2018-10-10 14:51:34 +01:00
commit 291ebf302c
15 changed files with 249 additions and 149 deletions

View file

@ -64,6 +64,7 @@
# Compile without 3D sound support, add 'NOHS=1' # Compile without 3D sound support, add 'NOHS=1'
# Compile with GDBstubs, add 'RDB=1' # Compile with GDBstubs, add 'RDB=1'
# Compile without PNG, add 'NOPNG=1' # Compile without PNG, add 'NOPNG=1'
# Compile without zlib, add 'NOZLIB=1'
# #
# Addon for SDL: # Addon for SDL:
# To Cross-Compile, add 'SDL_CONFIG=/usr/*/bin/sdl-config' # To Cross-Compile, add 'SDL_CONFIG=/usr/*/bin/sdl-config'
@ -107,6 +108,7 @@ include Makefile.cfg
ifdef DUMMY ifdef DUMMY
NOPNG=1 NOPNG=1
NOZLIB=1
NONET=1 NONET=1
NOHW=1 NOHW=1
NOHS=1 NOHS=1
@ -269,13 +271,6 @@ LIBS+=$(PNG_LDFLAGS)
CFLAGS+=$(PNG_CFLAGS) CFLAGS+=$(PNG_CFLAGS)
endif endif
ZLIB_PKGCONFIG?=zlib
ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags)
ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs)
LIBS+=$(ZLIB_LDFLAGS)
CFLAGS+=$(ZLIB_CFLAGS)
ifdef HAVE_LIBGME ifdef HAVE_LIBGME
OPTS+=-DHAVE_LIBGME OPTS+=-DHAVE_LIBGME
@ -287,6 +282,18 @@ LIBS+=$(LIBGME_LDFLAGS)
CFLAGS+=$(LIBGME_CFLAGS) CFLAGS+=$(LIBGME_CFLAGS)
endif endif
ifndef NOZLIB
OPTS+=-DHAVE_ZLIB
ZLIB_PKGCONFIG?=zlib
ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags)
ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs)
LIBS+=$(ZLIB_LDFLAGS)
CFLAGS+=$(ZLIB_CFLAGS)
else
NOPNG=1
endif
ifdef STATIC ifdef STATIC
LIBS:=-static $(LIBS) LIBS:=-static $(LIBS)
endif endif

View file

@ -5270,7 +5270,9 @@ static void HWR_AddSprites(sector_t *sec)
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
if (approx_dist <= limit_dist) if (approx_dist > limit_dist)
continue;
HWR_ProjectSprite(thing); HWR_ProjectSprite(thing);
} }
} }
@ -5293,7 +5295,9 @@ static void HWR_AddSprites(sector_t *sec)
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
if (approx_dist <= limit_dist) if (approx_dist > limit_dist)
continue;
HWR_ProjectPrecipitationSprite(precipthing); HWR_ProjectPrecipitationSprite(precipthing);
} }
} }
@ -5624,6 +5628,16 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
x1 = tr_x + x1 * rightcos; x1 = tr_x + x1 * rightcos;
x2 = tr_x - x2 * rightcos; x2 = tr_x - x2 * rightcos;
// okay, we can't return now... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
// //
// store information in a vissprite // store information in a vissprite
// //

View file

@ -193,25 +193,27 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump)
{ {
MYFILE f; MYFILE f;
char *name; char *name;
size_t len;
f.wad = wad; f.wad = wad;
f.size = W_LumpLengthPwad(wad, lump); f.size = W_LumpLengthPwad(wad, lump);
f.data = Z_Malloc(f.size, PU_LUA, NULL); f.data = Z_Malloc(f.size, PU_LUA, NULL);
W_ReadLumpPwad(wad, lump, f.data); W_ReadLumpPwad(wad, lump, f.data);
f.curpos = f.data; f.curpos = f.data;
len = strlen(wadfiles[wad]->filename); // length of file name
if (wadfiles[wad]->type == RET_LUA) if (wadfiles[wad]->type == RET_LUA)
{ {
name = malloc(strlen(wadfiles[wad]->filename)+1); name = malloc(len+1);
strcpy(name, wadfiles[wad]->filename); strcpy(name, wadfiles[wad]->filename);
} }
else // If it's not a .lua file, copy the lump name in too. else // If it's not a .lua file, copy the lump name in too.
{ {
lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump]; lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump];
size_t length = strlen(wadfiles[wad]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name len += 1 + strlen(lump_p->name2); // length of file name, '|', and lump name
name = malloc(length + 1); name = malloc(len+1);
sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->name2); sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->name2);
name[length] = '\0'; name[len] = '\0';
} }
LUA_LoadFile(&f, name); // actually load file! LUA_LoadFile(&f, name); // actually load file!

View file

@ -4059,7 +4059,8 @@ void P_RecalcPrecipInSector(sector_t *sector)
// //
void P_NullPrecipThinker(precipmobj_t *mobj) void P_NullPrecipThinker(precipmobj_t *mobj)
{ {
(void)mobj; //(void)mobj;
mobj->precipflags &= ~PCF_THUNK;
} }
void P_SnowThinker(precipmobj_t *mobj) void P_SnowThinker(precipmobj_t *mobj)
@ -4079,25 +4080,26 @@ void P_RainThinker(precipmobj_t *mobj)
{ {
// cycle through states, // cycle through states,
// calling action functions at transitions // calling action functions at transitions
if (mobj->tics > 0 && --mobj->tics == 0) if (mobj->tics <= 0)
{ return;
// you can cycle through multiple states in a tic
if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) if (--mobj->tics)
return; // freed itself return;
}
if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate))
return;
if (mobj->state != &states[S_RAINRETURN])
return;
if (mobj->state == &states[S_RAINRETURN])
{
mobj->z = mobj->ceilingz; mobj->z = mobj->ceilingz;
P_SetPrecipMobjState(mobj, S_RAIN1); P_SetPrecipMobjState(mobj, S_RAIN1);
}
return; return;
} }
// adjust height // adjust height
mobj->z += mobj->momz; if ((mobj->z += mobj->momz) <= mobj->floorz)
if (mobj->z <= mobj->floorz)
{ {
// no splashes on sky or bottomless pits // no splashes on sky or bottomless pits
if (mobj->precipflags & PCF_PIT) if (mobj->precipflags & PCF_PIT)
@ -8921,14 +8923,15 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{ {
precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type);
mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; mo->precipflags |= PCF_RAIN;
//mo->thinker.function.acp1 = (actionf_p1)P_RainThinker;
return mo; return mo;
} }
static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{ {
precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type);
mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; //mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker;
return mo; return mo;
} }

View file

@ -254,6 +254,10 @@ typedef enum {
PCF_FOF = 4, PCF_FOF = 4,
// Above MOVING FOF (this means we need to keep floorz up to date...) // Above MOVING FOF (this means we need to keep floorz up to date...)
PCF_MOVINGFOF = 8, PCF_MOVINGFOF = 8,
// Is rain.
PCF_RAIN = 16,
// Ran the thinker this tic.
PCF_THUNK = 32,
} precipflag_t; } precipflag_t;
// Map Object definition. // Map Object definition.
typedef struct mobj_s typedef struct mobj_s

View file

@ -2121,8 +2121,7 @@ static void P_NetArchiveThinkers(void)
for (th = thinkercap.next; th != &thinkercap; th = th->next) for (th = thinkercap.next; th != &thinkercap; th = th->next)
{ {
if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed
|| th->function.acp1 == (actionf_p1)P_RainThinker || th->function.acp1 == (actionf_p1)P_NullPrecipThinker))
|| th->function.acp1 == (actionf_p1)P_SnowThinker))
numsaved++; numsaved++;
if (th->function.acp1 == (actionf_p1)P_MobjThinker) if (th->function.acp1 == (actionf_p1)P_MobjThinker)
@ -2131,8 +2130,7 @@ static void P_NetArchiveThinkers(void)
continue; continue;
} }
#ifdef PARANOIA #ifdef PARANOIA
else if (th->function.acp1 == (actionf_p1)P_RainThinker else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker);
|| th->function.acp1 == (actionf_p1)P_SnowThinker);
#endif #endif
else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) else if (th->function.acp1 == (actionf_p1)T_MoveCeiling)
{ {

View file

@ -2226,8 +2226,7 @@ void P_SwitchWeather(INT32 weathernum)
for (think = thinkercap.next; think != &thinkercap; think = think->next) for (think = thinkercap.next; think != &thinkercap; think = think->next)
{ {
if ((think->function.acp1 != (actionf_p1)P_SnowThinker) if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
&& (think->function.acp1 != (actionf_p1)P_RainThinker))
continue; // not a precipmobj thinker continue; // not a precipmobj thinker
precipmobj = (precipmobj_t *)think; precipmobj = (precipmobj_t *)think;
@ -2243,14 +2242,12 @@ void P_SwitchWeather(INT32 weathernum)
for (think = thinkercap.next; think != &thinkercap; think = think->next) for (think = thinkercap.next; think != &thinkercap; think = think->next)
{ {
if (swap == PRECIP_RAIN) // Snow To Rain if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
{
if (!(think->function.acp1 == (actionf_p1)P_SnowThinker
|| think->function.acp1 == (actionf_p1)P_NullPrecipThinker))
continue; // not a precipmobj thinker continue; // not a precipmobj thinker
precipmobj = (precipmobj_t *)think; precipmobj = (precipmobj_t *)think;
if (swap == PRECIP_RAIN) // Snow To Rain
{
precipmobj->flags = mobjinfo[MT_RAIN].flags; precipmobj->flags = mobjinfo[MT_RAIN].flags;
st = &states[mobjinfo[MT_RAIN].spawnstate]; st = &states[mobjinfo[MT_RAIN].spawnstate];
precipmobj->state = st; precipmobj->state = st;
@ -2261,18 +2258,13 @@ void P_SwitchWeather(INT32 weathernum)
precipmobj->precipflags &= ~PCF_INVISIBLE; precipmobj->precipflags &= ~PCF_INVISIBLE;
think->function.acp1 = (actionf_p1)P_RainThinker; precipmobj->precipflags |= PCF_RAIN;
//think->function.acp1 = (actionf_p1)P_RainThinker;
} }
else if (swap == PRECIP_SNOW) // Rain To Snow else if (swap == PRECIP_SNOW) // Rain To Snow
{ {
INT32 z; INT32 z;
if (!(think->function.acp1 == (actionf_p1)P_RainThinker
|| think->function.acp1 == (actionf_p1)P_NullPrecipThinker))
continue; // not a precipmobj thinker
precipmobj = (precipmobj_t *)think;
precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags;
z = M_RandomByte(); z = M_RandomByte();
@ -2290,19 +2282,13 @@ void P_SwitchWeather(INT32 weathernum)
precipmobj->frame = st->frame; precipmobj->frame = st->frame;
precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed;
precipmobj->precipflags &= ~PCF_INVISIBLE; precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_RAIN);
think->function.acp1 = (actionf_p1)P_SnowThinker; //think->function.acp1 = (actionf_p1)P_SnowThinker;
} }
else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
{ {
if (!(think->function.acp1 == (actionf_p1)P_RainThinker //think->function.acp1 = (actionf_p1)P_NullPrecipThinker;
|| think->function.acp1 == (actionf_p1)P_SnowThinker))
continue;
precipmobj = (precipmobj_t *)think;
think->function.acp1 = (actionf_p1)P_NullPrecipThinker;
precipmobj->precipflags |= PCF_INVISIBLE; precipmobj->precipflags |= PCF_INVISIBLE;
} }

View file

@ -56,12 +56,12 @@ void Command_Numthinkers_f(void)
CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n")); CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n"));
CONS_Printf( CONS_Printf(
"\t1: P_MobjThinker\n" "\t1: P_MobjThinker\n"
"\t2: P_RainThinker\n" /*"\t2: P_RainThinker\n"
"\t3: P_SnowThinker\n" "\t3: P_SnowThinker\n"*/
"\t4: P_NullPrecipThinker\n" "\t2: P_NullPrecipThinker\n"
"\t5: T_Friction\n" "\t3: T_Friction\n"
"\t6: T_Pusher\n" "\t4: T_Pusher\n"
"\t7: P_RemoveThinkerDelayed\n"); "\t5: P_RemoveThinkerDelayed\n");
return; return;
} }
@ -73,27 +73,27 @@ void Command_Numthinkers_f(void)
action = (actionf_p1)P_MobjThinker; action = (actionf_p1)P_MobjThinker;
CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker"); CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker");
break; break;
case 2: /*case 2:
action = (actionf_p1)P_RainThinker; action = (actionf_p1)P_RainThinker;
CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker"); CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker");
break; break;
case 3: case 3:
action = (actionf_p1)P_SnowThinker; action = (actionf_p1)P_SnowThinker;
CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker"); CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker");
break; break;*/
case 4: case 2:
action = (actionf_p1)P_NullPrecipThinker; action = (actionf_p1)P_NullPrecipThinker;
CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker"); CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker");
break; break;
case 5: case 3:
action = (actionf_p1)T_Friction; action = (actionf_p1)T_Friction;
CONS_Printf(M_GetText("Number of %s: "), "T_Friction"); CONS_Printf(M_GetText("Number of %s: "), "T_Friction");
break; break;
case 6: case 4:
action = (actionf_p1)T_Pusher; action = (actionf_p1)T_Pusher;
CONS_Printf(M_GetText("Number of %s: "), "T_Pusher"); CONS_Printf(M_GetText("Number of %s: "), "T_Pusher");
break; break;
case 7: case 5:
action = (actionf_p1)P_RemoveThinkerDelayed; action = (actionf_p1)P_RemoveThinkerDelayed;
CONS_Printf(M_GetText("Number of %s: "), "P_RemoveThinkerDelayed"); CONS_Printf(M_GetText("Number of %s: "), "P_RemoveThinkerDelayed");
break; break;

View file

@ -8777,7 +8777,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
subsector_t *newsubsec; subsector_t *newsubsec;
fixed_t f1, f2; fixed_t f1, f2;
cameranoclip = (player->powers[pw_carry] == CR_NIGHTSMODE || player->pflags & PF_NOCLIP) || (player->mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! // We probably shouldn't move the camera if there is no player or player mobj somehow
if (!player || !player->mo)
return true;
mo = player->mo;
cameranoclip = (player->powers[pw_carry] == CR_NIGHTSMODE || player->pflags & PF_NOCLIP) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!!
if (!(player->climbing || (player->powers[pw_carry] == CR_NIGHTSMODE) || player->playerstate == PST_DEAD)) if (!(player->climbing || (player->powers[pw_carry] == CR_NIGHTSMODE) || player->playerstate == PST_DEAD))
{ {
@ -8798,7 +8804,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
else if (player == &players[secondarydisplayplayer]) else if (player == &players[secondarydisplayplayer])
focusangle = localangle2; focusangle = localangle2;
else else
focusangle = player->mo->angle; focusangle = mo->angle;
if (thiscam == &camera) if (thiscam == &camera)
camrotate = cv_cam_rotate.value; camrotate = cv_cam_rotate.value;
else if (thiscam == &camera2) else if (thiscam == &camera2)
@ -8810,17 +8816,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
return true; return true;
} }
if (!player || !player->mo)
return true;
mo = player->mo;
thiscam->radius = FixedMul(20*FRACUNIT, mo->scale); thiscam->radius = FixedMul(20*FRACUNIT, mo->scale);
thiscam->height = FixedMul(16*FRACUNIT, mo->scale); thiscam->height = FixedMul(16*FRACUNIT, mo->scale);
if (!mo)
return true;
// Don't run while respawning from a starpost // Don't run while respawning from a starpost
// Inu 4/8/13 Why not?! // Inu 4/8/13 Why not?!
// if (leveltime > 0 && timeinmap <= 0) // if (leveltime > 0 && timeinmap <= 0)
@ -8828,7 +8826,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->powers[pw_carry] == CR_NIGHTSMODE) if (player->powers[pw_carry] == CR_NIGHTSMODE)
{ {
focusangle = player->mo->angle; focusangle = mo->angle;
focusaiming = 0; focusaiming = 0;
} }
else if (player == &players[consoleplayer]) else if (player == &players[consoleplayer])
@ -8843,7 +8841,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
} }
else else
{ {
focusangle = player->mo->angle; focusangle = mo->angle;
focusaiming = player->aiming; focusaiming = player->aiming;
} }
@ -8890,12 +8888,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
angle = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y); angle = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y);
angle += ANGLE_90; angle += ANGLE_90;
} }
else if (player->mo->target) else if (mo->target)
{ {
if (player->mo->target->flags2 & MF2_AMBUSH) if (mo->target->flags2 & MF2_AMBUSH)
angle = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); angle = R_PointToAngle2(mo->target->x, mo->target->y, mo->x, mo->y);
else else
angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y);
} }
} }
else if (P_AnalogMove(player)) // Analog else if (P_AnalogMove(player)) // Analog
@ -8984,7 +8982,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (twodlevel || (mo->flags2 & MF2_TWOD)) if (twodlevel || (mo->flags2 & MF2_TWOD))
{ {
// Camera doesn't ALWAYS need to move, only when running... // Camera doesn't ALWAYS need to move, only when running...
if (abs(player->mo->momx) > 10) if (abs(mo->momx) > 10)
{ {
// Move the camera all smooth-like, not jerk it around... // Move the camera all smooth-like, not jerk it around...
if (mo->momx > 0) if (mo->momx > 0)
@ -9302,13 +9300,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
vy = thiscam->y; vy = thiscam->y;
} }
if (P_AproxDistance(vx - player->mo->x, vy - player->mo->y) < FixedMul(48*FRACUNIT, mo->scale)) if (P_AproxDistance(vx - mo->x, vy - mo->y) < FixedMul(48*FRACUNIT, mo->scale))
player->mo->flags2 |= MF2_SHADOW; mo->flags2 |= MF2_SHADOW;
else else
player->mo->flags2 &= ~MF2_SHADOW; mo->flags2 &= ~MF2_SHADOW;
} }
else else
player->mo->flags2 &= ~MF2_SHADOW; mo->flags2 &= ~MF2_SHADOW;
/* if (!resetcalled && (player->powers[pw_carry] == CR_NIGHTSMODE && player->exiting)) /* if (!resetcalled && (player->powers[pw_carry] == CR_NIGHTSMODE && player->exiting))
{ {

View file

@ -1525,6 +1525,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
return; return;
} }
// okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
//SoM: 3/17/2000: Disregard sprites that are out of view.. //SoM: 3/17/2000: Disregard sprites that are out of view..
gzt = thing->z + spritecachedinfo[lump].topoffset; gzt = thing->z + spritecachedinfo[lump].topoffset;
gz = gzt - spritecachedinfo[lump].height; gz = gzt - spritecachedinfo[lump].height;
@ -1642,7 +1653,9 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
if (approx_dist <= limit_dist) if (approx_dist > limit_dist)
continue;
R_ProjectSprite(thing); R_ProjectSprite(thing);
} }
} }
@ -1664,7 +1677,9 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
if (approx_dist <= limit_dist) if (approx_dist > limit_dist)
continue;
R_ProjectPrecipitationSprite(precipthing); R_ProjectPrecipitationSprite(precipthing);
} }
} }

View file

@ -124,6 +124,10 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include "macosx/mac_resources.h" #include "macosx/mac_resources.h"
#endif #endif
#ifndef errno
#include <errno.h>
#endif
// Locations for searching the srb2.pk3 // Locations for searching the srb2.pk3
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2"
@ -1149,6 +1153,7 @@ static void I_ShutdownJoystick2(void)
D_PostEvent(&event); D_PostEvent(&event);
} }
joystick2_started = 0;
JoyReset(&JoyInfo2); JoyReset(&JoyInfo2);
if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
{ {
@ -2090,7 +2095,6 @@ INT32 I_StartupSystem(void)
return 0; return 0;
} }
// //
// I_Quit // I_Quit
// //
@ -2696,7 +2700,30 @@ const char *I_LocateWad(void)
#ifdef __linux__ #ifdef __linux__
#define MEMINFO_FILE "/proc/meminfo" #define MEMINFO_FILE "/proc/meminfo"
#define MEMTOTAL "MemTotal:" #define MEMTOTAL "MemTotal:"
#define MEMAVAILABLE "MemAvailable:"
#define MEMFREE "MemFree:" #define MEMFREE "MemFree:"
#define CACHED "Cached:"
#define BUFFERS "Buffers:"
#define SHMEM "Shmem:"
/* Parse the contents of /proc/meminfo (in buf), return value of "name"
* (example: MemTotal) */
static long get_entry(const char* name, const char* buf)
{
long val;
char* hit = strstr(buf, name);
if (hit == NULL) {
return -1;
}
errno = 0;
val = strtol(hit + strlen(name), NULL, 10);
if (errno != 0) {
CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno));
return -1;
}
return val;
}
#endif #endif
// quick fix for compil // quick fix for compil
@ -2758,6 +2785,11 @@ UINT32 I_GetFreeMem(UINT32 *total)
UINT32 totalKBytes; UINT32 totalKBytes;
INT32 n; INT32 n;
INT32 meminfo_fd = -1; INT32 meminfo_fd = -1;
long Cached;
long MemFree;
long Buffers;
long Shmem;
long MemAvailable = -1;
meminfo_fd = open(MEMINFO_FILE, O_RDONLY); meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
n = read(meminfo_fd, buf, 1023); n = read(meminfo_fd, buf, 1023);
@ -2783,16 +2815,28 @@ UINT32 I_GetFreeMem(UINT32 *total)
memTag += sizeof (MEMTOTAL); memTag += sizeof (MEMTOTAL);
totalKBytes = atoi(memTag); totalKBytes = atoi(memTag);
if ((memTag = strstr(buf, MEMFREE)) == NULL) if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL)
{
Cached = get_entry(CACHED, buf);
MemFree = get_entry(MEMFREE, buf);
Buffers = get_entry(BUFFERS, buf);
Shmem = get_entry(SHMEM, buf);
MemAvailable = Cached + MemFree + Buffers - Shmem;
if (MemAvailable == -1)
{ {
// Error // Error
if (total) if (total)
*total = 0L; *total = 0L;
return 0; return 0;
} }
freeKBytes = MemAvailable;
memTag += sizeof (MEMFREE); }
else
{
memTag += sizeof (MEMAVAILABLE);
freeKBytes = atoi(memTag); freeKBytes = atoi(memTag);
}
if (total) if (total)
*total = totalKBytes << 10; *total = totalKBytes << 10;

View file

@ -38,10 +38,8 @@
#include "gme/gme.h" #include "gme/gme.h"
#define GME_TREBLE 5.0 #define GME_TREBLE 5.0
#define GME_BASS 1.0 #define GME_BASS 1.0
#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng
#define HAVE_ZLIB
#ifdef HAVE_ZLIB
#ifndef _MSC_VER #ifndef _MSC_VER
#ifndef _LARGEFILE64_SOURCE #ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE
@ -57,8 +55,8 @@
#endif #endif
#include "zlib.h" #include "zlib.h"
#endif #endif // HAVE_ZLIB
#endif #endif // HAVE_LIBGME
UINT8 sound_started = false; UINT8 sound_started = false;
@ -178,7 +176,7 @@ static Mix_Chunk *ds2chunk(void *stream)
return NULL; // would and/or did wrap, can't store. return NULL; // would and/or did wrap, can't store.
break; break;
} }
sound = malloc(newsamples<<2); // samples * frequency shift * bytes per sample * channels sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels
s = (SINT8 *)stream; s = (SINT8 *)stream;
d = (INT16 *)sound; d = (INT16 *)sound;
@ -246,6 +244,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
{ {
void *lump; void *lump;
Mix_Chunk *chunk; Mix_Chunk *chunk;
SDL_RWops *rw;
#ifdef HAVE_LIBGME #ifdef HAVE_LIBGME
Music_Emu *emu; Music_Emu *emu;
gme_info_t *info; gme_info_t *info;
@ -361,7 +360,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
} }
Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up
#else #else
//CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); return NULL; // No zlib support
#endif #endif
} }
// Try to read it as a GME sound // Try to read it as a GME sound
@ -387,13 +386,35 @@ void *I_GetSfx(sfxinfo_t *sfx)
#endif #endif
// Try to load it as a WAVE or OGG using Mixer. // Try to load it as a WAVE or OGG using Mixer.
return Mix_LoadWAV_RW(SDL_RWFromMem(lump, sfx->length), 1); rw = SDL_RWFromMem(lump, sfx->length);
if (rw != NULL)
{
chunk = Mix_LoadWAV_RW(rw, 1);
return chunk;
}
return NULL; // haven't been able to get anything
} }
void I_FreeSfx(sfxinfo_t *sfx) void I_FreeSfx(sfxinfo_t *sfx)
{ {
if (sfx->data) if (sfx->data)
{
Mix_Chunk *chunk = (Mix_Chunk*)sfx->data;
UINT8 *abufdata = NULL;
if (chunk->allocated == 0)
{
// We allocated the data in this chunk, so get the abuf from mixer, then let it free the chunk, THEN we free the data
// I believe this should ensure the sound is not playing when we free it
abufdata = chunk->abuf;
}
Mix_FreeChunk(sfx->data); Mix_FreeChunk(sfx->data);
if (abufdata)
{
// I'm going to assume we used Z_Malloc to allocate this data.
Z_Free(abufdata);
}
}
sfx->data = NULL; sfx->data = NULL;
sfx->lumpnum = LUMPERROR; sfx->lumpnum = LUMPERROR;
} }
@ -524,6 +545,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
char *data; char *data;
size_t len; size_t len;
lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname)); lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname));
SDL_RWops *rw;
I_Assert(!music); I_Assert(!music);
#ifdef HAVE_LIBGME #ifdef HAVE_LIBGME
@ -621,7 +643,8 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
} }
Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up
#else #else
//CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n");
return true;
#endif #endif
} }
else if (!gme_open_data(data, len, &gme, 44100)) else if (!gme_open_data(data, len, &gme, 44100))
@ -635,7 +658,11 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
} }
#endif #endif
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); rw = SDL_RWFromMem(data, len);
if (rw != NULL)
{
music = Mix_LoadMUS_RW(rw, 1);
}
if (!music) if (!music)
{ {
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
@ -798,7 +825,11 @@ void I_SetMIDIMusicVolume(UINT8 volume)
INT32 I_RegisterSong(void *data, size_t len) INT32 I_RegisterSong(void *data, size_t len)
{ {
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE); SDL_RWops *rw = SDL_RWFromMem(data, len);
if (rw != NULL)
{
music = Mix_LoadMUS_RW(rw, 1);
}
if (!music) if (!music)
{ {
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());

View file

@ -1045,7 +1045,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
// //
void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor) void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor)
{ {
if (skins[skinnum].flags & SF_HIRES) if (skinnum < 0 || skinnum >= numskins || (skins[skinnum].flags & SF_HIRES))
V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE));
else else
{ {

View file

@ -234,10 +234,10 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum)
for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++)
if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump
{ // shameless copy+paste of code from LUA_LoadLump { // shameless copy+paste of code from LUA_LoadLump
size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name size_t len = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name
char *name = malloc(length + 1); char *name = malloc(len+1);
sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2); sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2);
name[length] = '\0'; name[len] = '\0';
CONS_Printf(M_GetText("Loading SOC from %s\n"), name); CONS_Printf(M_GetText("Loading SOC from %s\n"), name);
DEH_LoadDehackedLumpPwad(wadnum, lump); DEH_LoadDehackedLumpPwad(wadnum, lump);

View file

@ -17,10 +17,8 @@
#include "gme/gme.h" #include "gme/gme.h"
#define GME_TREBLE 5.0 #define GME_TREBLE 5.0
#define GME_BASS 1.0 #define GME_BASS 1.0
#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng
#define HAVE_ZLIB
#ifdef HAVE_ZLIB
#ifndef _MSC_VER #ifndef _MSC_VER
#ifndef _LARGEFILE64_SOURCE #ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE
@ -36,8 +34,8 @@
#endif #endif
#include "zlib.h" #include "zlib.h"
#endif #endif // HAVE_ZLIB
#endif #endif // HAVE_LIBGME
static FMOD_SYSTEM *fsys; static FMOD_SYSTEM *fsys;
static FMOD_SOUND *music_stream; static FMOD_SOUND *music_stream;