Merge branch 'master' of git@git.magicalgirl.moe:STJr/SRB2Internal.git

This commit is contained in:
Monster Iestyn 2016-04-27 21:55:24 +01:00
commit fb7741a380
39 changed files with 1107 additions and 559 deletions

View file

@ -15,6 +15,7 @@
#include "am_map.h" #include "am_map.h"
#include "g_input.h" #include "g_input.h"
#include "p_local.h" #include "p_local.h"
#include "p_slopes.h"
#include "v_video.h" #include "v_video.h"
#include "i_video.h" #include "i_video.h"
#include "r_state.h" #include "r_state.h"
@ -996,6 +997,10 @@ static inline void AM_drawWalls(void)
{ {
size_t i; size_t i;
static mline_t l; static mline_t l;
#ifdef ESLOPE
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends
#endif
for (i = 0; i < numlines; i++) for (i = 0; i < numlines; i++)
{ {
@ -1003,6 +1008,22 @@ static inline void AM_drawWalls(void)
l.a.y = lines[i].v1->y; l.a.y = lines[i].v1->y;
l.b.x = lines[i].v2->x; l.b.x = lines[i].v2->x;
l.b.y = lines[i].v2->y; l.b.y = lines[i].v2->y;
#ifdef ESLOPE
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = P_GetZAt(slope, l.a.x, l.a.y); \
end2 = P_GetZAt(slope, l.b.x, l.b.y); \
} else \
end1 = end2 = normalheight;
SLOPEPARAMS(lines[i].frontsector->f_slope, frontf1, frontf2, lines[i].frontsector->floorheight)
SLOPEPARAMS(lines[i].frontsector->c_slope, frontc1, frontc2, lines[i].frontsector->ceilingheight)
if (lines[i].backsector) {
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
}
#undef SLOPEPARAMS
#endif
// AM_drawMline(&l, GRAYS + 3); // Old, everything-is-gray automap // AM_drawMline(&l, GRAYS + 3); // Old, everything-is-gray automap
if (!lines[i].backsector) // 1-sided if (!lines[i].backsector) // 1-sided
@ -1016,11 +1037,19 @@ static inline void AM_drawWalls(void)
AM_drawMline(&l, WALLCOLORS+lightlev); AM_drawMline(&l, WALLCOLORS+lightlev);
} }
} }
#ifdef ESLOPE
else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
|| (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier
{
if (backf1 == backc1 && backf2 == backc2
&& frontf1 == frontc1 && frontf2 == frontc2) // BOTH are thok barriers
#else
else if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight // Back is thok barrier else if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight // Back is thok barrier
|| lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // Front is thok barrier || lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // Front is thok barrier
{ {
if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight
&& lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // BOTH are thok barriers && lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // BOTH are thok barriers
#endif
{ {
if (lines[i].flags & ML_NOCLIMB) if (lines[i].flags & ML_NOCLIMB)
{ {
@ -1046,12 +1075,20 @@ static inline void AM_drawWalls(void)
else else
{ {
if (lines[i].flags & ML_NOCLIMB) { if (lines[i].flags & ML_NOCLIMB) {
#ifdef ESLOPE
if (backf1 != frontf1 || backf2 != frontf2) {
#else
if (lines[i].backsector->floorheight if (lines[i].backsector->floorheight
!= lines[i].frontsector->floorheight) { != lines[i].frontsector->floorheight) {
#endif
AM_drawMline(&l, NOCLIMBFDWALLCOLORS + lightlev); // floor level change AM_drawMline(&l, NOCLIMBFDWALLCOLORS + lightlev); // floor level change
} }
#ifdef ESLOPE
else if (backc1 != frontc1 || backc2 != frontc2) {
#else
else if (lines[i].backsector->ceilingheight else if (lines[i].backsector->ceilingheight
!= lines[i].frontsector->ceilingheight) { != lines[i].frontsector->ceilingheight) {
#endif
AM_drawMline(&l, NOCLIMBCDWALLCOLORS+lightlev); // ceiling level change AM_drawMline(&l, NOCLIMBCDWALLCOLORS+lightlev); // ceiling level change
} }
else { else {
@ -1060,12 +1097,20 @@ static inline void AM_drawWalls(void)
} }
else else
{ {
#ifdef ESLOPE
if (backf1 != frontf1 || backf2 != frontf2) {
#else
if (lines[i].backsector->floorheight if (lines[i].backsector->floorheight
!= lines[i].frontsector->floorheight) { != lines[i].frontsector->floorheight) {
#endif
AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change
} }
#ifdef ESLOPE
else if (backc1 != frontc1 || backc2 != frontc2) {
#else
else if (lines[i].backsector->ceilingheight else if (lines[i].backsector->ceilingheight
!= lines[i].frontsector->ceilingheight) { != lines[i].frontsector->ceilingheight) {
#endif
AM_drawMline(&l, CDWALLCOLORS+lightlev); // ceiling level change AM_drawMline(&l, CDWALLCOLORS+lightlev); // ceiling level change
} }
else { else {

View file

@ -517,9 +517,9 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i)
rsp->thokitem = (UINT32)LONG(players[i].thokitem); //mobjtype_t rsp->thokitem = (UINT32)LONG(players[i].thokitem); //mobjtype_t
rsp->spinitem = (UINT32)LONG(players[i].spinitem); //mobjtype_t rsp->spinitem = (UINT32)LONG(players[i].spinitem); //mobjtype_t
rsp->revitem = (UINT32)LONG(players[i].revitem); //mobjtype_t rsp->revitem = (UINT32)LONG(players[i].revitem); //mobjtype_t
rsp->actionspd = LONG(players[i].actionspd); rsp->actionspd = (fixed_t)LONG(players[i].actionspd);
rsp->mindash = LONG(players[i].mindash); rsp->mindash = (fixed_t)LONG(players[i].mindash);
rsp->maxdash = LONG(players[i].maxdash); rsp->maxdash = (fixed_t)LONG(players[i].maxdash);
rsp->jumpfactor = (fixed_t)LONG(players[i].jumpfactor); rsp->jumpfactor = (fixed_t)LONG(players[i].jumpfactor);
rsp->speed = (fixed_t)LONG(players[i].speed); rsp->speed = (fixed_t)LONG(players[i].speed);
@ -531,6 +531,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i)
rsp->deadtimer = players[i].deadtimer; rsp->deadtimer = players[i].deadtimer;
rsp->exiting = (tic_t)LONG(players[i].exiting); rsp->exiting = (tic_t)LONG(players[i].exiting);
rsp->homing = players[i].homing; rsp->homing = players[i].homing;
rsp->skidtime = (tic_t)LONG(players[i].skidtime);
rsp->cmomx = (fixed_t)LONG(players[i].cmomx); rsp->cmomx = (fixed_t)LONG(players[i].cmomx);
rsp->cmomy = (fixed_t)LONG(players[i].cmomy); rsp->cmomy = (fixed_t)LONG(players[i].cmomy);
rsp->rmomx = (fixed_t)LONG(players[i].rmomx); rsp->rmomx = (fixed_t)LONG(players[i].rmomx);
@ -590,7 +591,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i)
rsp->tics = LONG(players[i].mo->tics); rsp->tics = LONG(players[i].mo->tics);
rsp->statenum = (statenum_t)LONG(players[i].mo->state-states); // :( rsp->statenum = (statenum_t)LONG(players[i].mo->state-states); // :(
rsp->eflags = (UINT32)LONG(players[i].mo->eflags); rsp->eflags = (UINT16)SHORT(players[i].mo->eflags);
rsp->flags = LONG(players[i].mo->flags); rsp->flags = LONG(players[i].mo->flags);
rsp->flags2 = LONG(players[i].mo->flags2); rsp->flags2 = LONG(players[i].mo->flags2);
@ -642,9 +643,9 @@ static void resynch_read_player(resynch_pak *rsp)
players[i].thokitem = (UINT32)LONG(rsp->thokitem); //mobjtype_t players[i].thokitem = (UINT32)LONG(rsp->thokitem); //mobjtype_t
players[i].spinitem = (UINT32)LONG(rsp->spinitem); //mobjtype_t players[i].spinitem = (UINT32)LONG(rsp->spinitem); //mobjtype_t
players[i].revitem = (UINT32)LONG(rsp->revitem); //mobjtype_t players[i].revitem = (UINT32)LONG(rsp->revitem); //mobjtype_t
players[i].actionspd = LONG(rsp->actionspd); players[i].actionspd = (fixed_t)LONG(rsp->actionspd);
players[i].mindash = LONG(rsp->mindash); players[i].mindash = (fixed_t)LONG(rsp->mindash);
players[i].maxdash = LONG(rsp->maxdash); players[i].maxdash = (fixed_t)LONG(rsp->maxdash);
players[i].jumpfactor = (fixed_t)LONG(rsp->jumpfactor); players[i].jumpfactor = (fixed_t)LONG(rsp->jumpfactor);
players[i].speed = (fixed_t)LONG(rsp->speed); players[i].speed = (fixed_t)LONG(rsp->speed);
@ -656,6 +657,7 @@ static void resynch_read_player(resynch_pak *rsp)
players[i].deadtimer = rsp->deadtimer; players[i].deadtimer = rsp->deadtimer;
players[i].exiting = (tic_t)LONG(rsp->exiting); players[i].exiting = (tic_t)LONG(rsp->exiting);
players[i].homing = rsp->homing; players[i].homing = rsp->homing;
players[i].skidtime = (tic_t)LONG(rsp->skidtime);
players[i].cmomx = (fixed_t)LONG(rsp->cmomx); players[i].cmomx = (fixed_t)LONG(rsp->cmomx);
players[i].cmomy = (fixed_t)LONG(rsp->cmomy); players[i].cmomy = (fixed_t)LONG(rsp->cmomy);
players[i].rmomx = (fixed_t)LONG(rsp->rmomx); players[i].rmomx = (fixed_t)LONG(rsp->rmomx);
@ -713,7 +715,7 @@ static void resynch_read_player(resynch_pak *rsp)
//At this point, the player should have a body, whether they were respawned or not. //At this point, the player should have a body, whether they were respawned or not.
P_UnsetThingPosition(players[i].mo); P_UnsetThingPosition(players[i].mo);
players[i].mo->angle = (angle_t)LONG(rsp->angle); players[i].mo->angle = (angle_t)LONG(rsp->angle);
players[i].mo->eflags = (UINT32)LONG(rsp->eflags); players[i].mo->eflags = (UINT16)SHORT(rsp->eflags);
players[i].mo->flags = LONG(rsp->flags); players[i].mo->flags = LONG(rsp->flags);
players[i].mo->flags2 = LONG(rsp->flags2); players[i].mo->flags2 = LONG(rsp->flags2);
players[i].mo->friction = LONG(rsp->friction); players[i].mo->friction = LONG(rsp->friction);
@ -2935,9 +2937,9 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (botingame) if (botingame)
players[newplayernum].bot = 1; players[newplayernum].bot = 1;
// Same goes for player 2 when relevant // Same goes for player 2 when relevant
players[newplayernum].pflags &= ~(/*PF_FLIPCAM|*/PF_ANALOGMODE); players[newplayernum].pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE);
//if (cv_flipcam2.value) if (cv_flipcam2.value)
//players[newplayernum].pflags |= PF_FLIPCAM; players[newplayernum].pflags |= PF_FLIPCAM;
if (cv_analog2.value) if (cv_analog2.value)
players[newplayernum].pflags |= PF_ANALOGMODE; players[newplayernum].pflags |= PF_ANALOGMODE;
} }

View file

@ -177,9 +177,9 @@ typedef struct
UINT32 thokitem; //mobjtype_t UINT32 thokitem; //mobjtype_t
UINT32 spinitem; //mobjtype_t UINT32 spinitem; //mobjtype_t
UINT32 revitem; //mobjtype_t UINT32 revitem; //mobjtype_t
INT32 actionspd; fixed_t actionspd;
INT32 mindash; fixed_t mindash;
INT32 maxdash; fixed_t maxdash;
fixed_t jumpfactor; fixed_t jumpfactor;
fixed_t speed; fixed_t speed;
@ -191,6 +191,7 @@ typedef struct
INT32 deadtimer; INT32 deadtimer;
tic_t exiting; tic_t exiting;
UINT8 homing; UINT8 homing;
tic_t skidtime;
fixed_t cmomx; fixed_t cmomx;
fixed_t cmomy; fixed_t cmomy;
fixed_t rmomx; fixed_t rmomx;
@ -241,11 +242,11 @@ typedef struct
fixed_t friction; fixed_t friction;
fixed_t movefactor; fixed_t movefactor;
INT16 tics; INT32 tics;
statenum_t statenum; statenum_t statenum;
UINT32 flags; UINT32 flags;
UINT32 flags2; UINT32 flags2;
UINT8 eflags; UINT16 eflags;
fixed_t radius; fixed_t radius;
fixed_t height; fixed_t height;

View file

@ -221,10 +221,7 @@ gamestate_t wipegamestate = GS_LEVEL;
static void D_Display(void) static void D_Display(void)
{ {
static boolean menuactivestate = false; boolean forcerefresh = false;
static gamestate_t oldgamestate = -1;
boolean redrawsbar = false;
static boolean wipe = false; static boolean wipe = false;
INT32 wipedefindex = 0; INT32 wipedefindex = 0;
@ -245,23 +242,15 @@ static void D_Display(void)
if (setsizeneeded) if (setsizeneeded)
{ {
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
oldgamestate = -1; // force background redraw forcerefresh = true; // force background redraw
redrawsbar = true;
} }
// save the current screen if about to wipe
if (gamestate != wipegamestate)
{
wipe = true;
F_WipeStartScreen();
}
else
wipe = false;
// draw buffered stuff to screen // draw buffered stuff to screen
// Used only by linux GGI version // Used only by linux GGI version
I_UpdateNoBlit(); I_UpdateNoBlit();
// save the current screen if about to wipe
wipe = (gamestate != wipegamestate);
if (wipe) if (wipe)
{ {
// set for all later // set for all later
@ -280,6 +269,7 @@ static void D_Display(void)
if (gamestate != GS_LEVEL // fades to black on its own timing, always if (gamestate != GS_LEVEL // fades to black on its own timing, always
&& wipedefs[wipedefindex] != UINT8_MAX) && wipedefs[wipedefindex] != UINT8_MAX)
{ {
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
@ -298,8 +288,6 @@ static void D_Display(void)
HU_Erase(); HU_Erase();
if (automapactive) if (automapactive)
AM_Drawer(); AM_Drawer();
if (wipe || menuactivestate || (rendermode != render_soft && rendermode != render_none) || vid.recalc)
redrawsbar = true;
break; break;
case GS_INTERMISSION: case GS_INTERMISSION:
@ -357,11 +345,6 @@ static void D_Display(void)
// see if the border needs to be initially drawn // see if the border needs to be initially drawn
if (gamestate == GS_LEVEL) if (gamestate == GS_LEVEL)
{ {
#if 0
if (oldgamestate != GS_LEVEL)
R_FillBackScreen(); // draw the pattern into the back screen
#endif
// draw the view directly // draw the view directly
if (!automapactive && !dedicated && cv_renderview.value) if (!automapactive && !dedicated && cv_renderview.value)
{ {
@ -417,17 +400,17 @@ static void D_Display(void)
lastdraw = false; lastdraw = false;
} }
ST_Drawer(redrawsbar); ST_Drawer();
HU_Drawer(); HU_Drawer();
} }
// change gamma if needed // change gamma if needed
if (gamestate != oldgamestate && gamestate != GS_LEVEL) // (GS_LEVEL handles this already due to level-specific palettes)
if (forcerefresh && gamestate != GS_LEVEL)
V_SetPalette(0); V_SetPalette(0);
menuactivestate = menuactive; wipegamestate = gamestate;
oldgamestate = wipegamestate = gamestate;
// draw pause pic // draw pause pic
if (paused && cv_showhud.value && (!menuactive || netgame)) if (paused && cv_showhud.value && (!menuactive || netgame))
@ -450,15 +433,22 @@ static void D_Display(void)
CON_Drawer(); CON_Drawer();
M_Drawer(); // menu is drawn even on top of everything M_Drawer(); // menu is drawn even on top of everything
// focus lost moved to M_Drawer
// focus lost notification goes on top of everything, even the former everything //
if (window_notinfocus) // wipe update
//
if (wipe)
{ {
M_DrawTextBox((BASEVIDWIDTH/2) - (60), (BASEVIDHEIGHT/2) - (16), 13, 2); // note: moved up here because NetUpdate does input changes
if (gamestate == GS_LEVEL && (P_AutoPause() || paused)) // and input during wipe tends to mess things up
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2) - (4), V_YELLOWMAP, "Game Paused"); wipedefindex += WIPEFINALSHIFT;
else
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2) - (4), V_YELLOWMAP, "Focus Lost"); if (rendermode != render_none)
{
F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
}
} }
NetUpdate(); // send out any new accumulation NetUpdate(); // send out any new accumulation
@ -493,18 +483,6 @@ static void D_Display(void)
} }
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer
return;
}
//
// wipe update
//
wipedefindex += WIPEFINALSHIFT;
if (rendermode != render_none)
{
F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
} }
} }

View file

@ -808,7 +808,7 @@ static boolean IsNameGood(char *name, INT32 playernum)
else if (len == 1) // Agh! else if (len == 1) // Agh!
{ {
// Last ditch effort... // Last ditch effort...
sprintf(name, "%d", M_Random() & 7); sprintf(name, "%d", M_RandomKey(10));
if (!IsNameGood (name, playernum)) if (!IsNameGood (name, playernum))
return false; return false;
} }
@ -3583,7 +3583,7 @@ retryscramble:
for (i = 0; i < playercount; i++) for (i = 0; i < playercount; i++)
{ {
if (repick) if (repick)
newteam = (INT16)((M_Random() % 2) + 1); newteam = (INT16)((M_RandomByte() % 2) + 1);
// One team has the most players they can get, assign the rest to the other team. // One team has the most players they can get, assign the rest to the other team.
if (red == maxcomposition || blue == maxcomposition) if (red == maxcomposition || blue == maxcomposition)
@ -3628,7 +3628,7 @@ retryscramble:
{ {
if (repick) if (repick)
{ {
newteam = (INT16)((M_Random() % 2) + 1); newteam = (INT16)((M_RandomByte() % 2) + 1);
repick = false; repick = false;
} }
else else

View file

@ -101,6 +101,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio
#include <math.h> #include <math.h>
#ifdef GETTEXT #ifdef GETTEXT
@ -431,10 +432,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
// None of these that are disabled in the normal build are guaranteed to work perfectly // None of these that are disabled in the normal build are guaranteed to work perfectly
// Compile them at your own risk! // Compile them at your own risk!
/// Max recursive portal renders
/// \note obsoleted by cv_maxportals
//#define PORTAL_LIMIT 8
/// Kalaron/Eternity Engine slope code (SRB2CB ported) /// Kalaron/Eternity Engine slope code (SRB2CB ported)
#define ESLOPE #define ESLOPE

View file

@ -2331,8 +2331,8 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost)
} }
} }
P_MovePlayerToSpawn(playernum, spawnpoint); P_MovePlayerToSpawn(playernum, spawnpoint);
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :)
#endif #endif
@ -2349,7 +2349,7 @@ mapthing_t *G_FindCTFStart(INT32 playernum)
return NULL; return NULL;
} }
if ((!players[playernum].ctfteam && numredctfstarts && (!numbluectfstarts || P_Random() & 1)) || players[playernum].ctfteam == 1) //red if ((!players[playernum].ctfteam && numredctfstarts && (!numbluectfstarts || P_RandomChance(FRACUNIT/2))) || players[playernum].ctfteam == 1) //red
{ {
if (!numredctfstarts) if (!numredctfstarts)
{ {
@ -5499,7 +5499,7 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void)
UINT8 i; UINT8 i;
WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker
for (i = 0; i < 16; i++, p++) for (i = 0; i < 16; i++, p++)
*p = P_Random(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. *p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct.
#else #else
WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker
md5_buffer((char *)p+16, demo_p - (p+16), (void *)p); // make a checksum of everything after the checksum in the file. md5_buffer((char *)p+16, demo_p - (p+16), (void *)p); // make a checksum of everything after the checksum in the file.
@ -5581,7 +5581,7 @@ boolean G_CheckDemoStatus(void)
UINT8 i; UINT8 i;
WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker
for (i = 0; i < 16; i++, p++) for (i = 0; i < 16; i++, p++)
*p = P_Random(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. *p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct.
#else #else
WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker
md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file. md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file.

View file

@ -384,12 +384,12 @@ INT32 HW3S_I_StartSound(const void *origin_p, source3D_data_t *source_parm, chan
/*if (gamemode != heretic) /*if (gamemode != heretic)
{ {
if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit) if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit)
pitch += 8 - (M_Random()&15); pitch += 8 - (M_RandomByte()&15);
else if (sfx_id != sfx_itemup && sfx_id != sfx_tink) else if (sfx_id != sfx_itemup && sfx_id != sfx_tink)
pitch += 16 - (M_Random()&31); pitch += 16 - (M_RandomByte()&31);
} }
else*/ else*/
pitch = 128 + (M_Random() & 7) - (M_Random() & 7); pitch = 128 + (M_RandomByte() & 7) - (M_RandomByte() & 7);
} }
#endif #endif

View file

@ -657,6 +657,9 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf; FSurfaceInfo Surf;
if (w < 0 || h < 0)
return; // consistency w/ software
// 3--2 // 3--2
// | /| // | /|
// |/ | // |/ |

View file

@ -871,7 +871,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr)
size = p_lspr->corona_radius * ((outVerts[0].z+120.0f)/950.0f); // d'ou vienne ces constante ? size = p_lspr->corona_radius * ((outVerts[0].z+120.0f)/950.0f); // d'ou vienne ces constante ?
break; break;
case ROCKET_SPR: case ROCKET_SPR:
p_lspr->corona_color = (((M_Random()>>1)&0xff)<<24)|0x0040ff; p_lspr->corona_color = (((M_RandomByte()>>1)&0xff)<<24)|0x0040ff;
// don't need a break // don't need a break
case CORONA_SPR: case CORONA_SPR:
size = p_lspr->corona_radius * ((outVerts[0].z+60.0f)/100.0f); // d'ou vienne ces constante ? size = p_lspr->corona_radius * ((outVerts[0].z+60.0f)/100.0f); // d'ou vienne ces constante ?
@ -974,7 +974,7 @@ void HWR_DrawCoronas(void)
size = p_lspr->corona_radius * ((cz+120.0f)/950.0f); // d'ou vienne ces constante ? size = p_lspr->corona_radius * ((cz+120.0f)/950.0f); // d'ou vienne ces constante ?
break; break;
case ROCKET_SPR: case ROCKET_SPR:
Surf.FlatColor.s.alpha = (UINT8)((M_Random()>>1)&0xff); Surf.FlatColor.s.alpha = (UINT8)((M_RandomByte()>>1)&0xff);
// don't need a break // don't need a break
case CORONA_SPR: case CORONA_SPR:
size = p_lspr->corona_radius * ((cz+60.0f)/100.0f); // d'ou vienne ces constante ? size = p_lspr->corona_radius * ((cz+60.0f)/100.0f); // d'ou vienne ces constante ?

View file

@ -74,10 +74,12 @@ FUNCMATH UINT8 LightLevelToLum(INT32 l);
extern CV_PossibleValue_t granisotropicmode_cons_t[]; extern CV_PossibleValue_t granisotropicmode_cons_t[];
#ifdef ALAM_LIGHTING
extern consvar_t cv_grdynamiclighting; extern consvar_t cv_grdynamiclighting;
extern consvar_t cv_grstaticlighting; extern consvar_t cv_grstaticlighting;
extern consvar_t cv_grcoronas; extern consvar_t cv_grcoronas;
extern consvar_t cv_grcoronasize; extern consvar_t cv_grcoronasize;
#endif
extern consvar_t cv_grfov; extern consvar_t cv_grfov;
extern consvar_t cv_grmd2; extern consvar_t cv_grmd2;
extern consvar_t cv_grfog; extern consvar_t cv_grfog;

View file

@ -88,17 +88,17 @@ static int lib_print(lua_State *L)
// M_RANDOM // M_RANDOM
////////////// //////////////
static int lib_pRandom(lua_State *L) static int lib_pRandomFixed(lua_State *L)
{ {
NOHUD NOHUD
lua_pushinteger(L, P_Random()); lua_pushfixed(L, P_RandomFixed());
return 1; return 1;
} }
static int lib_pSignedRandom(lua_State *L) static int lib_pRandomByte(lua_State *L)
{ {
NOHUD NOHUD
lua_pushinteger(L, P_SignedRandom()); lua_pushinteger(L, P_RandomByte());
return 1; return 1;
} }
@ -126,6 +126,30 @@ static int lib_pRandomRange(lua_State *L)
return 1; return 1;
} }
// Deprecated, macros, etc.
static int lib_pRandom(lua_State *L)
{
NOHUD
LUA_Deprecated(L, "P_Random", "P_RandomByte");
lua_pushinteger(L, P_RandomByte());
return 1;
}
static int lib_pSignedRandom(lua_State *L)
{
NOHUD
lua_pushinteger(L, P_SignedRandom());
return 1;
}
static int lib_pRandomChance(lua_State *L)
{
fixed_t p = luaL_checkfixed(L, 1);
NOHUD
lua_pushboolean(L, P_RandomChance(p));
return 1;
}
// P_MAPUTIL // P_MAPUTIL
/////////////// ///////////////
@ -1929,10 +1953,13 @@ static luaL_Reg lib[] = {
{"print", lib_print}, {"print", lib_print},
// m_random // m_random
{"P_Random",lib_pRandom}, {"P_RandomFixed",lib_pRandomFixed},
{"P_SignedRandom",lib_pSignedRandom}, {"P_RandomByte",lib_pRandomByte},
{"P_RandomKey",lib_pRandomKey}, {"P_RandomKey",lib_pRandomKey},
{"P_RandomRange",lib_pRandomRange}, {"P_RandomRange",lib_pRandomRange},
{"P_Random",lib_pRandom}, // DEPRECATED
{"P_SignedRandom",lib_pSignedRandom}, // MACRO
{"P_RandomChance",lib_pRandomChance}, // MACRO
// p_maputil // p_maputil
{"P_AproxDistance",lib_pAproxDistance}, {"P_AproxDistance",lib_pAproxDistance},

View file

@ -76,6 +76,6 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_B
boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
#endif #endif

View file

@ -100,7 +100,11 @@ static int lib_fixedint(lua_State *L)
static int lib_fixeddiv(lua_State *L) static int lib_fixeddiv(lua_State *L)
{ {
lua_pushfixed(L, FixedDiv(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2))); fixed_t i = luaL_checkfixed(L, 1);
fixed_t j = luaL_checkfixed(L, 2);
if (j == 0)
return luaL_error(L, "divide by zero");
lua_pushfixed(L, FixedDiv(i, j));
return 1; return 1;
} }
@ -112,7 +116,10 @@ static int lib_fixedrem(lua_State *L)
static int lib_fixedsqrt(lua_State *L) static int lib_fixedsqrt(lua_State *L)
{ {
lua_pushfixed(L, FixedSqrt(luaL_checkfixed(L, 1))); fixed_t i = luaL_checkfixed(L, 1);
if (i < 0)
return luaL_error(L, "square root domain error");
lua_pushfixed(L, FixedSqrt(i));
return 1; return 1;
} }

View file

@ -31,6 +31,7 @@
#include "v_video.h" #include "v_video.h"
#include "z_zone.h" #include "z_zone.h"
#include "p_slopes.h"
#include "lua_script.h" #include "lua_script.h"
#include "lua_hook.h" #include "lua_hook.h"
@ -598,9 +599,9 @@ void Command_CauseCfail_f(void)
} }
P_UnsetThingPosition(players[consoleplayer].mo); P_UnsetThingPosition(players[consoleplayer].mo);
P_Random(); P_RandomFixed();
P_Random(); P_RandomByte();
P_Random(); P_RandomFixed();
players[consoleplayer].mo->x = 0; players[consoleplayer].mo->x = 0;
players[consoleplayer].mo->y = 123311; //cfail cansuled kthxbye players[consoleplayer].mo->y = 123311; //cfail cansuled kthxbye
players[consoleplayer].mo->z = 123311; players[consoleplayer].mo->z = 123311;
@ -837,9 +838,19 @@ static void OP_CycleThings(INT32 amt)
static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) static boolean OP_HeightOkay(player_t *player, UINT8 ceiling)
{ {
sector_t *sec = player->mo->subsector->sector;
if (ceiling) if (ceiling)
{ {
if (((player->mo->subsector->sector->ceilingheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT))) #ifdef ESLOPE
// Truncate position to match where mapthing would be when spawned
// (this applies to every further P_GetZAt call as well)
fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight;
#else
fixed_t cheight = sec->ceilingheight;
#endif
if (((cheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT)))
{ {
CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("low"), CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("low"),
(1 << (16-ZSHIFT)), M_GetText("below top ceiling")); (1 << (16-ZSHIFT)), M_GetText("below top ceiling"));
@ -848,7 +859,12 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling)
} }
else else
{ {
if (((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS) >= (1 << (16-ZSHIFT))) #ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
if (((player->mo->z - fheight)>>FRACBITS) >= (1 << (16-ZSHIFT)))
{ {
CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("high"), CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("high"),
(1 << (16-ZSHIFT)), M_GetText("above bottom floor")); (1 << (16-ZSHIFT)), M_GetText("above bottom floor"));
@ -861,6 +877,7 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling)
static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean ceiling) static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean ceiling)
{ {
mapthing_t *mt = mapthings; mapthing_t *mt = mapthings;
sector_t *sec = player->mo->subsector->sector;
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
LUA_InvalidateMapthings(); LUA_InvalidateMapthings();
@ -893,9 +910,23 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c
mt->x = (INT16)(player->mo->x>>FRACBITS); mt->x = (INT16)(player->mo->x>>FRACBITS);
mt->y = (INT16)(player->mo->y>>FRACBITS); mt->y = (INT16)(player->mo->y>>FRACBITS);
if (ceiling) if (ceiling)
mt->options = (UINT16)((player->mo->subsector->sector->ceilingheight - player->mo->z - player->mo->height)>>FRACBITS); {
#ifdef ESLOPE
fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->ceilingheight;
#else
fixed_t cheight = sec->ceilingheight;
#endif
mt->options = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS);
}
else else
mt->options = (UINT16)((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS); {
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS);
}
mt->options <<= ZSHIFT; mt->options <<= ZSHIFT;
mt->angle = (INT16)(FixedInt(AngleFixed(player->mo->angle))); mt->angle = (INT16)(FixedInt(AngleFixed(player->mo->angle)));
@ -949,6 +980,13 @@ void OP_NightsObjectplace(player_t *player)
{ {
UINT16 angle = (UINT16)(player->anotherflyangle % 360); UINT16 angle = (UINT16)(player->anotherflyangle % 360);
INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle
sector_t *sec = player->mo->subsector->sector;
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
player->pflags |= PF_ATTACKDOWN; player->pflags |= PF_ATTACKDOWN;
@ -963,7 +1001,7 @@ void OP_NightsObjectplace(player_t *player)
temp += 90; temp += 90;
temp %= 360; temp %= 360;
mt->options = (UINT16)((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS); mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS);
mt->angle = (INT16)(mt->angle+(INT16)((FixedInt(FixedDiv(temp*FRACUNIT, 360*(FRACUNIT/256))))<<8)); mt->angle = (INT16)(mt->angle+(INT16)((FixedInt(FixedDiv(temp*FRACUNIT, 360*(FRACUNIT/256))))<<8));
P_SpawnHoopsAndRings(mt); P_SpawnHoopsAndRings(mt);
@ -1097,6 +1135,33 @@ void OP_ObjectplaceMovement(player_t *player)
else else
player->viewz = player->mo->z + player->viewheight; player->viewz = player->mo->z + player->viewheight;
// Display flag information
// Moved up so it always updates.
{
sector_t *sec = player->mo->subsector->sector;
if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP))
{
#ifdef ESLOPE
fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight;
#else
fixed_t cheight = sec->ceilingheight;
#endif
op_displayflags = (UINT16)((cheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS);
}
else
{
#ifdef ESLOPE
fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight;
#else
fixed_t fheight = sec->floorheight;
#endif
op_displayflags = (UINT16)((player->mo->z - fheight)>>FRACBITS);
}
op_displayflags <<= ZSHIFT;
op_displayflags |= (UINT16)cv_opflags.value;
}
if (player->pflags & PF_ATTACKDOWN) if (player->pflags & PF_ATTACKDOWN)
{ {
// Are ANY objectplace buttons pressed? If no, remove flag. // Are ANY objectplace buttons pressed? If no, remove flag.
@ -1162,16 +1227,6 @@ void OP_ObjectplaceMovement(player_t *player)
CONS_Printf(M_GetText("Placed object type %d at %d, %d, %d, %d\n"), mt->type, mt->x, mt->y, mt->options>>ZSHIFT, mt->angle); CONS_Printf(M_GetText("Placed object type %d at %d, %d, %d, %d\n"), mt->type, mt->x, mt->y, mt->options>>ZSHIFT, mt->angle);
} }
// Display flag information
{
if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP))
op_displayflags = (UINT16)((player->mo->subsector->sector->ceilingheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS);
else
op_displayflags = (UINT16)((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS);
op_displayflags <<= ZSHIFT;
op_displayflags |= (UINT16)cv_opflags.value;
}
} }
// //

View file

@ -2059,6 +2059,10 @@ static void M_PrevOpt(void)
} while (oldItemOn != itemOn && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE); } while (oldItemOn != itemOn && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE);
} }
// lock out further input in a tic when important buttons are pressed
// (in other words -- stop bullshit happening by mashing buttons in fades)
static boolean noFurtherInput = false;
// //
// M_Responder // M_Responder
// //
@ -2081,6 +2085,12 @@ boolean M_Responder(event_t *ev)
shiftdown = false; shiftdown = false;
return false; return false;
} }
if (noFurtherInput)
{
// Ignore input after enter/escape/other buttons
// (but still allow shift keyup so caps doesn't get stuck)
return false;
}
else if (ev->type == ev_keydown) else if (ev->type == ev_keydown)
{ {
ch = ev->data1; ch = ev->data1;
@ -2182,6 +2192,7 @@ boolean M_Responder(event_t *ev)
// F-Keys // F-Keys
if (!menuactive) if (!menuactive)
{ {
noFurtherInput = true;
switch (ch) switch (ch)
{ {
case KEY_F1: // Help key case KEY_F1: // Help key
@ -2252,6 +2263,7 @@ boolean M_Responder(event_t *ev)
M_StartControlPanel(); M_StartControlPanel();
return true; return true;
} }
noFurtherInput = false; // turns out we didn't care
return false; return false;
} }
@ -2275,6 +2287,7 @@ boolean M_Responder(event_t *ev)
if (routine) if (routine)
routine(ch); routine(ch);
M_StopMessage(0); M_StopMessage(0);
noFurtherInput = true;
return true; return true;
} }
return true; return true;
@ -2354,6 +2367,7 @@ boolean M_Responder(event_t *ev)
return true; return true;
case KEY_ENTER: case KEY_ENTER:
noFurtherInput = true;
currentMenu->lastOn = itemOn; currentMenu->lastOn = itemOn;
if (routine) if (routine)
{ {
@ -2387,6 +2401,7 @@ boolean M_Responder(event_t *ev)
return true; return true;
case KEY_ESCAPE: case KEY_ESCAPE:
noFurtherInput = true;
currentMenu->lastOn = itemOn; currentMenu->lastOn = itemOn;
if (currentMenu->prevMenu) if (currentMenu->prevMenu)
{ {
@ -2443,35 +2458,45 @@ void M_Drawer(void)
if (currentMenu == &MessageDef) if (currentMenu == &MessageDef)
menuactive = true; menuactive = true;
if (!menuactive) if (menuactive)
return;
// now that's more readable with a faded background (yeah like Quake...)
if (!WipeInAction)
V_DrawFadeScreen();
if (currentMenu->drawroutine)
currentMenu->drawroutine(); // call current menu Draw routine
// Draw version down in corner
// ... but only in the MAIN MENU. I'm a picky bastard.
if (currentMenu == &MainDef)
{ {
if (customversionstring[0] != '\0') // now that's more readable with a faded background (yeah like Quake...)
{ if (!WipeInAction)
V_DrawThinString(vid.dupx, vid.height - 17*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT, "Mod version:"); V_DrawFadeScreen();
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, customversionstring);
} if (currentMenu->drawroutine)
else currentMenu->drawroutine(); // call current menu Draw routine
// Draw version down in corner
// ... but only in the MAIN MENU. I'm a picky bastard.
if (currentMenu == &MainDef)
{ {
if (customversionstring[0] != '\0')
{
V_DrawThinString(vid.dupx, vid.height - 17*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT, "Mod version:");
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, customversionstring);
}
else
{
#ifdef DEVELOP // Development -- show revision / branch info #ifdef DEVELOP // Development -- show revision / branch info
V_DrawThinString(vid.dupx, vid.height - 17*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, compbranch); V_DrawThinString(vid.dupx, vid.height - 17*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, compbranch);
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, comprevision); V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, comprevision);
#else // Regular build #else // Regular build
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s", VERSIONSTRING)); V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s", VERSIONSTRING));
#endif #endif
}
} }
} }
// focus lost notification goes on top of everything, even the former everything
if (window_notinfocus)
{
M_DrawTextBox((BASEVIDWIDTH/2) - (60), (BASEVIDHEIGHT/2) - (16), 13, 2);
if (gamestate == GS_LEVEL && (P_AutoPause() || paused))
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2) - (4), V_YELLOWMAP, "Game Paused");
else
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2) - (4), V_YELLOWMAP, "Focus Lost");
}
} }
// //
@ -2656,6 +2681,9 @@ void M_SetupNextMenu(menu_t *menudef)
// //
void M_Ticker(void) void M_Ticker(void)
{ {
// reset input trigger
noFurtherInput = false;
if (dedicated) if (dedicated)
return; return;

View file

@ -10,7 +10,7 @@
// See the 'LICENSE' file for more details. // See the 'LICENSE' file for more details.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// \file m_random.c /// \file m_random.c
/// \brief LCG PRNG originally created for XMOD /// \brief RNG for client effects and PRNG for game actions
#include "doomdef.h" #include "doomdef.h"
#include "doomtype.h" #include "doomtype.h"
@ -19,48 +19,57 @@
#include "m_random.h" #include "m_random.h"
#include "m_fixed.h" #include "m_fixed.h"
// --------------------------- // ---------------------------
// RNG functions (not synched) // RNG functions (not synched)
// --------------------------- // ---------------------------
/** Provides a random byte. /** Provides a random fixed point number. Distribution is uniform.
* Used outside the p_xxx game code and not synchronized in netgames. This is * As with all M_Random functions, not synched in netgames.
* for anything that doesn't need to be synced, e.g. precipitation.
* *
* \return A random byte, 0 to 255. * \return A random fixed point number from [0,1).
*/ */
UINT8 M_Random(void) fixed_t M_RandomFixed(void)
{ {
return (rand() & 255); #if RAND_MAX < 65535
// Compensate for insufficient randomness.
fixed_t rndv = (rand()&1)<<15;
return rand()^rndv;
#else
return (rand() & 0xFFFF);
#endif
} }
/** Provides a random signed byte. Distribution is uniform. /** Provides a random byte. Distribution is uniform.
* As with all M_*Random functions, not synched in netgames. * As with all M_Random functions, not synched in netgames.
* *
* \return A random byte, -128 to 127. * \return A random integer from [0, 255].
* \sa M_Random
*/ */
INT32 M_SignedRandom(void) UINT8 M_RandomByte(void)
{ {
return M_Random() - 128; return (rand() & 0xFF);
} }
/** Provides a random number in between 0 and the given number - 1. /** Provides a random integer for picking random elements from an array.
* Distribution is uniform. Use for picking random elements from an array. * Distribution is uniform.
* As with all M_*Random functions, not synched in netgames. * As with all M_Random functions, not synched in netgames.
* *
* \return A random number, 0 to arg1-1. * \param a Number of items in array.
* \return A random integer from [0,a).
*/ */
INT32 M_RandomKey(INT32 a) INT32 M_RandomKey(INT32 a)
{ {
return (INT32)((rand()/((unsigned)RAND_MAX+1.0f))*a); return (INT32)((rand()/((unsigned)RAND_MAX+1.0f))*a);
} }
/** Provides a random number in between a specific range. /** Provides a random integer in a given range.
* Distribution is uniform. * Distribution is uniform.
* As with all M_*Random functions, not synched in netgames. * As with all M_Random functions, not synched in netgames.
* *
* \return A random number, arg1 to arg2. * \param a Lower bound.
* \param b Upper bound.
* \return A random integer from [a,b].
*/ */
INT32 M_RandomRange(INT32 a, INT32 b) INT32 M_RandomRange(INT32 a, INT32 b)
{ {
@ -74,54 +83,65 @@ INT32 M_RandomRange(INT32 a, INT32 b)
// ------------------------ // ------------------------
// Holds the current seed. // Holds the current seed.
static UINT32 randomseed = 0; static UINT32 randomseed = 0xBADE4404;
// Holds the INITIAL seed value. Used for demos, possibly other debugging. // Holds the INITIAL seed value. Used for demos, possibly other debugging.
static UINT32 initialseed = 0; static UINT32 initialseed = 0xBADE4404;
/** /** Provides a random fixed point number.
* Provides a random byte and sets the seed appropriately. * This is a variant of an xorshift PRNG; state fits in a 32 bit integer structure.
* The nature of this PRNG allows it to cycle through about two million numbers
* before it finally starts repeating numeric sequences.
* That's more than good enough for our purposes.
* *
* \return A random byte, 0 to 255. * \return A random fixed point number from [0,1).
*/ */
#ifndef DEBUGRANDOM ATTRINLINE static fixed_t FUNCINLINE __internal_prng__(void)
UINT8 P_Random(void)
{ {
#else randomseed ^= randomseed >> 13;
UINT8 P_RandomD(const char *rfile, INT32 rline) randomseed ^= randomseed >> 11;
{ randomseed ^= randomseed << 21;
CONS_Printf("P_Random() at: %sp %d\n", rfile, rline); return ( (randomseed*36548569) >> 4) & (FRACUNIT-1);
#endif
randomseed = (randomseed*746151647)+48205429;
return (UINT8)((randomseed >> 17)&255);
} }
/** Provides a random number from -128 to 127. /** Provides a random fixed point number. Distribution is uniform.
* Literally a wrapper for the internal PRNG function.
*
* \return A random fixed point number from [0,1).
*/
#ifndef DEBUGRANDOM
fixed_t P_RandomFixed(void)
{
#else
UINT8 P_RandomFixedD(const char *rfile, INT32 rline)
{
CONS_Printf("P_RandomFixed() at: %sp %d\n", rfile, rline);
#endif
return __internal_prng__();
}
/** Provides a random byte. Distribution is uniform.
* If you're curious, (&0xFF00) >> 8 gives the same result
* as a fixed point multiplication by 256.
*
* \return Random integer from [0, 255].
* \sa __internal_prng__
*/
#ifndef DEBUGRANDOM
UINT8 P_RandomByte(void)
{
#else
UINT8 P_RandomByteD(const char *rfile, INT32 rline)
{
CONS_Printf("P_RandomByte() at: %sp %d\n", rfile, rline);
#endif
return (UINT8)((__internal_prng__()&0xFF00)>>8);
}
/** Provides a random integer for picking random elements from an array.
* Distribution is uniform. * Distribution is uniform.
* NOTE: Maximum range is 65536.
* *
* \return Random number from -128 to 127. * \param a Number of items in array.
* \sa P_Random * \return A random integer from [0,a).
*/ * \sa __internal_prng__
#ifndef DEBUGRANDOM
INT32 P_SignedRandom(void)
{
#else
INT32 P_SignedRandomD(const char *rfile, INT32 rline)
{
CONS_Printf("P_SignedRandom() at: %sp %d\n", rfile, rline);
#endif
return P_Random() - 128;
}
/** Provides a random number in between 0 and the given number - 1.
* Distribution is uniform, also calls for two numbers for bigger output range.
* Use for picking random elements from an array.
*
* \return A random number, 0 to arg1-1.
* \sa P_Random
*/ */
#ifndef DEBUGRANDOM #ifndef DEBUGRANDOM
INT32 P_RandomKey(INT32 a) INT32 P_RandomKey(INT32 a)
@ -131,16 +151,17 @@ INT32 P_RandomKeyD(const char *rfile, INT32 rline, INT32 a)
{ {
CONS_Printf("P_RandomKey() at: %sp %d\n", rfile, rline); CONS_Printf("P_RandomKey() at: %sp %d\n", rfile, rline);
#endif #endif
INT32 prandom = P_Random(); // note: forcing explicit function call order return (INT32)((__internal_prng__() * a) >> FRACBITS);
prandom |= P_Random() << 8; // (function call order is not strictly defined)
return (INT32)((prandom/65536.0f)*a);
} }
/** Provides a random number in between a specific range. /** Provides a random integer in a given range.
* Distribution is uniform, also calls for two numbers for bigger output range. * Distribution is uniform.
* NOTE: Maximum range is 65536.
* *
* \return A random number, arg1 to arg2. * \param a Lower bound.
* \sa P_Random * \param b Upper bound.
* \return A random integer from [a,b].
* \sa __internal_prng__
*/ */
#ifndef DEBUGRANDOM #ifndef DEBUGRANDOM
INT32 P_RandomRange(INT32 a, INT32 b) INT32 P_RandomRange(INT32 a, INT32 b)
@ -150,21 +171,27 @@ INT32 P_RandomRangeD(const char *rfile, INT32 rline, INT32 a, INT32 b)
{ {
CONS_Printf("P_RandomRange() at: %sp %d\n", rfile, rline); CONS_Printf("P_RandomRange() at: %sp %d\n", rfile, rline);
#endif #endif
INT32 prandom = P_Random(); // note: forcing explicit function call order return (INT32)((__internal_prng__() * (b-a+1)) >> FRACBITS) + a;
prandom |= P_Random() << 8; // (function call order is not strictly defined)
return (INT32)((prandom/65536.0f)*(b-a+1))+a;
} }
/** Provides a random byte without saving what the seed would be.
* Used just to debug the PRNG.
// ----------------------
// PRNG seeds & debugging
// ----------------------
/** Peeks to see what the next result from the PRNG will be.
* Used for debugging.
* *
* \return A 'random' byte, 0 to 255. * \return A 'random' fixed point number from [0,1).
* \sa P_Random * \sa __internal_prng__
*/ */
UINT8 P_RandomPeek(void) fixed_t P_RandomPeek(void)
{ {
UINT32 r = (randomseed*746151647)+48205429; UINT32 r = randomseed;
return (UINT8)((r >> 17)&255); fixed_t ret = __internal_prng__();
randomseed = r;
return ret;
} }
/** Gets the current random seed. Used by netgame savegames. /** Gets the current random seed. Used by netgame savegames.
@ -213,6 +240,9 @@ void P_SetRandSeedD(const char *rfile, INT32 rline, UINT32 seed)
{ {
CONS_Printf("P_SetRandSeed() at: %sp %d\n", rfile, rline); CONS_Printf("P_SetRandSeed() at: %sp %d\n", rfile, rline);
#endif #endif
// xorshift requires a nonzero seed
// this should never happen, but just in case it DOES, we check
if (!seed) seed = 0xBADE4404;
randomseed = initialseed = seed; randomseed = initialseed = seed;
} }
@ -222,5 +252,5 @@ void P_SetRandSeedD(const char *rfile, INT32 rline, UINT32 seed)
*/ */
UINT32 M_RandomizedSeed(void) UINT32 M_RandomizedSeed(void)
{ {
return ((totalplaytime & 0xFFFF) << 16)|(rand() & 0xFFFF); return ((totalplaytime & 0xFFFF) << 16)|M_RandomFixed();
} }

View file

@ -20,32 +20,42 @@
//#define DEBUGRANDOM //#define DEBUGRANDOM
// M_Random functions pull random numbers of various types that aren't network synced. // M_Random functions pull random numbers of various types that aren't network synced.
// P_Random functions pulls random bytes from a LCG PRNG that is network synced. // P_Random functions pulls random bytes from a PRNG that is network synced.
// RNG functions // RNG functions
UINT8 M_Random(void); fixed_t M_RandomFixed(void);
INT32 M_SignedRandom(void); UINT8 M_RandomByte(void);
INT32 M_RandomKey(INT32 a); INT32 M_RandomKey(INT32 a);
INT32 M_RandomRange(INT32 a, INT32 b); INT32 M_RandomRange(INT32 a, INT32 b);
// PRNG functions // PRNG functions
#ifdef DEBUGRANDOM #ifdef DEBUGRANDOM
#define P_Random() P_RandomD(__FILE__, __LINE__) #define P_RandomFixed() P_RandomFixedD(__FILE__, __LINE__)
#define P_SignedRandom() P_SignedRandomD(__FILE__, __LINE__) #define P_RandomByte() P_RandomByteD(__FILE__, __LINE__)
#define P_RandomKey(c) P_RandomKeyD(__FILE__, __LINE__, c) #define P_RandomKey(c) P_RandomKeyD(__FILE__, __LINE__, c)
#define P_RandomRange(c, d) P_RandomRangeD(__FILE__, __LINE__, c, d) #define P_RandomRange(c, d) P_RandomRangeD(__FILE__, __LINE__, c, d)
UINT8 P_RandomD(const char *rfile, INT32 rline); fixed_t P_RandomFixedD(const char *rfile, INT32 rline);
INT32 P_SignedRandomD(const char *rfile, INT32 rline); UINT8 P_RandomByteD(const char *rfile, INT32 rline);
INT32 P_RandomKeyD(const char *rfile, INT32 rline, INT32 a); INT32 P_RandomKeyD(const char *rfile, INT32 rline, INT32 a);
INT32 P_RandomRangeD(const char *rfile, INT32 rline, INT32 a, INT32 b); INT32 P_RandomRangeD(const char *rfile, INT32 rline, INT32 a, INT32 b);
#else #else
UINT8 P_Random(void); fixed_t P_RandomFixed(void);
INT32 P_SignedRandom(void); UINT8 P_RandomByte(void);
INT32 P_RandomKey(INT32 a); INT32 P_RandomKey(INT32 a);
INT32 P_RandomRange(INT32 a, INT32 b); INT32 P_RandomRange(INT32 a, INT32 b);
#endif #endif
UINT8 P_RandomPeek(void);
// Macros for other functions
#define M_SignedRandom() ((INT32)M_RandomByte() - 128) // [-128, 127] signed byte, originally a
#define P_SignedRandom() ((INT32)P_RandomByte() - 128) // function of its own, moved to a macro
#define M_RandomChance(p) (M_RandomFixed() < p) // given fixed point probability, p, between 0 (0%)
#define P_RandomChance(p) (P_RandomFixed() < p) // and FRACUNIT (100%), returns true p% of the time
// Debugging
fixed_t P_RandomPeek(void);
// Working with the seed for PRNG // Working with the seed for PRNG
#ifdef DEBUGRANDOM #ifdef DEBUGRANDOM

View file

@ -386,7 +386,7 @@ boolean P_CheckMissileRange(mobj_t *actor)
if (actor->type == MT_EGGMOBILE && dist > 160) if (actor->type == MT_EGGMOBILE && dist > 160)
dist = 160; dist = 160;
if (P_Random() < dist) if (P_RandomByte() < dist)
return false; return false;
return true; return true;
@ -486,7 +486,7 @@ static boolean P_TryWalk(mobj_t *actor)
{ {
if (!P_Move(actor, actor->info->speed)) if (!P_Move(actor, actor->info->speed))
return false; return false;
actor->movecount = P_Random() & 15; actor->movecount = P_RandomByte() & 15;
return true; return true;
} }
@ -539,7 +539,7 @@ void P_NewChaseDir(mobj_t *actor)
} }
// try other directions // try other directions
if (P_Random() > 200 || abs(deltay) > abs(deltax)) if (P_RandomChance(25*FRACUNIT/32) || abs(deltay) > abs(deltax))
{ {
tdir = d[1]; tdir = d[1];
d[1] = d[2]; d[1] = d[2];
@ -577,7 +577,7 @@ void P_NewChaseDir(mobj_t *actor)
} }
// randomly determine direction of search // randomly determine direction of search
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
{ {
for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++) for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++)
{ {
@ -632,7 +632,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed
// BP: first time init, this allow minimum lastlook changes // BP: first time init, this allow minimum lastlook changes
if (actor->lastlook < 0) if (actor->lastlook < 0)
actor->lastlook = P_Random(); actor->lastlook = P_RandomByte();
actor->lastlook %= MAXPLAYERS; actor->lastlook %= MAXPLAYERS;
@ -707,7 +707,7 @@ static boolean P_LookForShield(mobj_t *actor)
// BP: first time init, this allow minimum lastlook changes // BP: first time init, this allow minimum lastlook changes
if (actor->lastlook < 0) if (actor->lastlook < 0)
actor->lastlook = P_Random(); actor->lastlook = P_RandomByte();
actor->lastlook %= MAXPLAYERS; actor->lastlook %= MAXPLAYERS;
@ -2293,12 +2293,7 @@ void A_SkullAttack(mobj_t *actor)
if (locvar1 == 1) if (locvar1 == 1)
actor->angle += ANGLE_180; actor->angle += ANGLE_180;
else if (locvar1 == 2) else if (locvar1 == 2)
{ actor->angle += (P_RandomChance(FRACUNIT/2)) ? ANGLE_90 : -ANGLE_90;
if (P_Random() & 1)
actor->angle += ANGLE_90;
else
actor->angle -= ANGLE_90;
}
an = actor->angle >> ANGLETOFINESHIFT; an = actor->angle >> ANGLETOFINESHIFT;
@ -2398,9 +2393,9 @@ void A_BossScream(mobj_t *actor)
explodetype = (mobjtype_t)locvar2; explodetype = (mobjtype_t)locvar2;
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
z = actor->z + actor->height - mobjinfo[explodetype].height - FixedMul((P_Random()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale); z = actor->z + actor->height - mobjinfo[explodetype].height - FixedMul((P_RandomByte()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
else else
z = actor->z + FixedMul((P_Random()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale); z = actor->z + FixedMul((P_RandomByte()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
mo = P_SpawnMobj(x, y, z, explodetype); mo = P_SpawnMobj(x, y, z, explodetype);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
@ -3461,7 +3456,7 @@ void A_BubbleSpawn(mobj_t *actor)
return; // don't make bubble! return; // don't make bubble!
} }
prandom = P_Random(); prandom = P_RandomByte();
if (leveltime % (3*TICRATE) < 8) if (leveltime % (3*TICRATE) < 8)
bubble = P_SpawnMobj(actor->x, actor->y, actor->z + (actor->height / 2), MT_EXTRALARGEBUBBLE); bubble = P_SpawnMobj(actor->x, actor->y, actor->z + (actor->height / 2), MT_EXTRALARGEBUBBLE);
@ -3509,7 +3504,7 @@ void A_FanBubbleSpawn(mobj_t *actor)
return; // don't make bubble! return; // don't make bubble!
} }
prandom = P_Random(); prandom = P_RandomByte();
if ((prandom & 0x7) == 0x7) if ((prandom & 0x7) == 0x7)
bubble = P_SpawnMobj(actor->x, actor->y, hz, MT_SMALLBUBBLE); bubble = P_SpawnMobj(actor->x, actor->y, hz, MT_SMALLBUBBLE);
@ -3550,7 +3545,7 @@ void A_BubbleRise(mobj_t *actor)
// Move around slightly to make it look like it's bending around the water // Move around slightly to make it look like it's bending around the water
if (!locvar1) if (!locvar1)
{ {
UINT8 prandom = P_Random(); UINT8 prandom = P_RandomByte();
if (!(prandom & 0x7)) // *****000 if (!(prandom & 0x7)) // *****000
{ {
P_InstaThrust(actor, prandom & 0x70 ? actor->angle + ANGLE_90 : actor->angle, P_InstaThrust(actor, prandom & 0x70 ? actor->angle + ANGLE_90 : actor->angle,
@ -3833,7 +3828,7 @@ void A_ThrownRing(mobj_t *actor)
// first time init, this allow minimum lastlook changes // first time init, this allow minimum lastlook changes
if (actor->lastlook < 0) if (actor->lastlook < 0)
actor->lastlook = P_Random(); actor->lastlook = P_RandomByte();
actor->lastlook %= MAXPLAYERS; actor->lastlook %= MAXPLAYERS;
@ -3913,7 +3908,7 @@ void A_SetSolidSteam(mobj_t *actor)
#endif #endif
actor->flags &= ~MF_NOCLIP; actor->flags &= ~MF_NOCLIP;
actor->flags |= MF_SOLID; actor->flags |= MF_SOLID;
if (!(P_Random() & 7)) if (P_RandomChance(FRACUNIT/8))
{ {
if (actor->info->deathsound) if (actor->info->deathsound)
S_StartSound(actor, actor->info->deathsound); // Hiss! S_StartSound(actor, actor->info->deathsound); // Hiss!
@ -4055,7 +4050,7 @@ void A_JetChase(mobj_t *actor)
if (actor->reactiontime) if (actor->reactiontime)
actor->reactiontime--; actor->reactiontime--;
if (P_Random() % 32 == 1) if (P_RandomChance(FRACUNIT/32))
{ {
actor->momx = actor->momx / 2; actor->momx = actor->momx / 2;
actor->momy = actor->momy / 2; actor->momy = actor->momy / 2;
@ -4416,7 +4411,7 @@ void A_JetgThink(mobj_t *actor)
if (actor->target) if (actor->target)
{ {
if (P_Random() <= 32 && !actor->reactiontime) if (P_RandomChance(FRACUNIT/8) && !actor->reactiontime)
P_SetMobjState(actor, actor->info->missilestate); P_SetMobjState(actor, actor->info->missilestate);
else else
A_JetChase (actor); A_JetChase (actor);
@ -4469,10 +4464,10 @@ void A_MouseThink(mobj_t *actor)
{ {
if (twodlevel || actor->flags2 & MF2_TWOD) if (twodlevel || actor->flags2 & MF2_TWOD)
{ {
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
actor->angle += ANGLE_180; actor->angle += ANGLE_180;
} }
else if (P_Random() & 1) else if (P_RandomChance(FRACUNIT/2))
actor->angle += ANGLE_90; actor->angle += ANGLE_90;
else else
actor->angle -= ANGLE_90; actor->angle -= ANGLE_90;
@ -4878,7 +4873,7 @@ void A_RockSpawn(mobj_t *actor)
type = MT_ROCKCRUMBLE1 + (sides[line->sidenum[0]].rowoffset >> FRACBITS); type = MT_ROCKCRUMBLE1 + (sides[line->sidenum[0]].rowoffset >> FRACBITS);
if (line->flags & ML_NOCLIMB) if (line->flags & ML_NOCLIMB)
randomoomph = P_Random() * (FRACUNIT/32); randomoomph = P_RandomByte() * (FRACUNIT/32);
else else
randomoomph = 0; randomoomph = 0;
@ -5172,7 +5167,7 @@ void A_CrawlaCommanderThink(mobj_t *actor)
if (locvar1) if (locvar1)
{ {
if (actor->health < 2 && P_Random() < 2) if (actor->health < 2 && P_RandomChance(FRACUNIT/128))
P_SpawnMissile(actor, actor->target, locvar1); P_SpawnMissile(actor, actor->target, locvar1);
} }
@ -5187,8 +5182,8 @@ void A_CrawlaCommanderThink(mobj_t *actor)
actor->threshold = 0; actor->threshold = 0;
// Roam around, somewhat in the player's direction. // Roam around, somewhat in the player's direction.
actor->angle += (P_Random()<<10); actor->angle += (P_RandomByte()<<10);
actor->angle -= (P_Random()<<10); actor->angle -= (P_RandomByte()<<10);
if (actor->health > 1) if (actor->health > 1)
P_InstaThrust(actor, actor->angle, FixedMul(10*FRACUNIT, actor->scale)); P_InstaThrust(actor, actor->angle, FixedMul(10*FRACUNIT, actor->scale));
@ -5204,7 +5199,7 @@ void A_CrawlaCommanderThink(mobj_t *actor)
actor->threshold = 1; actor->threshold = 1;
} }
} }
actor->reactiontime = 2*TICRATE + P_Random()/2; actor->reactiontime = 2*TICRATE + P_RandomByte()/2;
} }
if (actor->health == 1) if (actor->health == 1)
@ -5222,8 +5217,8 @@ void A_CrawlaCommanderThink(mobj_t *actor)
} }
else else
{ {
UINT8 prandom = P_Random(); UINT8 prandom = P_RandomByte();
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_Random() & 1 ? -prandom : +prandom); actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom);
P_InstaThrust(actor, actor->angle, FixedDiv(FixedMul(locvar2, actor->scale), 3*FRACUNIT/2)); P_InstaThrust(actor, actor->angle, FixedDiv(FixedMul(locvar2, actor->scale), 3*FRACUNIT/2));
actor->momz = FixedMul(locvar2, actor->scale); // Bounce up in air actor->momz = FixedMul(locvar2, actor->scale); // Bounce up in air
} }
@ -5552,7 +5547,7 @@ void A_MixUp(mobj_t *actor)
{ {
if (counter > 255) // fail-safe to avoid endless loop if (counter > 255) // fail-safe to avoid endless loop
break; break;
prandom = P_Random(); prandom = P_RandomByte();
prandom %= numplayers; // I love modular arithmetic, don't you? prandom %= numplayers; // I love modular arithmetic, don't you?
if (prandom) // Make sure it's not a useless mix if (prandom) // Make sure it's not a useless mix
break; break;
@ -5701,7 +5696,7 @@ void A_RecyclePowers(mobj_t *actor)
{ {
UINT8 tempint; UINT8 tempint;
i = j + ((P_Random() + leveltime) % (numplayers - j)); i = j + ((P_RandomByte() + leveltime) % (numplayers - j));
tempint = postscramble[j]; tempint = postscramble[j];
postscramble[j] = postscramble[i]; postscramble[j] = postscramble[i];
postscramble[i] = tempint; postscramble[i] = tempint;
@ -5814,7 +5809,7 @@ void A_Boss1Chase(mobj_t *actor)
{ {
if (actor->health > actor->info->damage) if (actor->health > actor->info->damage)
{ {
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
P_SetMobjState(actor, actor->info->missilestate); P_SetMobjState(actor, actor->info->missilestate);
else else
P_SetMobjState(actor, actor->info->meleestate); P_SetMobjState(actor, actor->info->meleestate);
@ -5833,7 +5828,7 @@ void A_Boss1Chase(mobj_t *actor)
// ? // ?
nomissile: nomissile:
// possibly choose another target // possibly choose another target
if (multiplayer && P_Random() < 2) if (multiplayer && P_RandomChance(FRACUNIT/128))
{ {
if (P_LookForPlayers(actor, true, false, 0)) if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target return; // got a new target
@ -5871,7 +5866,7 @@ nomissile:
deltay = actor->target->y - actor->y; deltay = actor->target->y - actor->y;
actor->movedir = diags[((deltay < 0)<<1) + (deltax > 0)]; actor->movedir = diags[((deltay < 0)<<1) + (deltax > 0)];
actor->movecount = P_Random() & 15; actor->movecount = P_RandomByte() & 15;
} }
} }
@ -5897,13 +5892,13 @@ void A_Boss2Chase(mobj_t *actor)
// Startup randomness // Startup randomness
if (actor->reactiontime <= -666) if (actor->reactiontime <= -666)
actor->reactiontime = 2*TICRATE + P_Random(); actor->reactiontime = 2*TICRATE + P_RandomByte();
// When reactiontime hits zero, he will go the other way // When reactiontime hits zero, he will go the other way
if (--actor->reactiontime <= 0) if (--actor->reactiontime <= 0)
{ {
reverse = true; reverse = true;
actor->reactiontime = 2*TICRATE + P_Random(); actor->reactiontime = 2*TICRATE + P_RandomByte();
} }
P_SetTarget(&actor->target, P_GetClosestAxis(actor)); P_SetTarget(&actor->target, P_GetClosestAxis(actor));
@ -5990,12 +5985,12 @@ void A_Boss2Chase(mobj_t *actor)
if (actor->info->attacksound) if (actor->info->attacksound)
S_StartAttackSound(actor, actor->info->attacksound); S_StartAttackSound(actor, actor->info->attacksound);
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
{ {
goop->momx *= 2; goop->momx *= 2;
goop->momy *= 2; goop->momy *= 2;
} }
else if (P_Random() > 128) else if (P_RandomChance(129*FRACUNIT/256))
{ {
goop->momx *= 3; goop->momx *= 3;
goop->momy *= 3; goop->momy *= 3;
@ -6153,7 +6148,7 @@ void A_Boss7Chase(mobj_t *actor)
{ {
A_FaceTarget(actor); A_FaceTarget(actor);
P_SetMobjState(actor, S_BLACKEGG_SHOOT1); P_SetMobjState(actor, S_BLACKEGG_SHOOT1);
actor->movecount = TICRATE + P_Random()/2; actor->movecount = TICRATE + P_RandomByte()/2;
return; return;
} }
@ -6162,7 +6157,7 @@ void A_Boss7Chase(mobj_t *actor)
if (actor->reactiontime <= 0 && actor->z == actor->floorz) if (actor->reactiontime <= 0 && actor->z == actor->floorz)
{ {
// Here, we'll call P_Random() and decide what kind of attack to do // Here, we'll call P_RandomByte() and decide what kind of attack to do
switch(actor->threshold) switch(actor->threshold)
{ {
case 0: // Lob cannon balls case 0: // Lob cannon balls
@ -6170,7 +6165,7 @@ void A_Boss7Chase(mobj_t *actor)
{ {
A_FaceTarget(actor); A_FaceTarget(actor);
P_SetMobjState(actor, actor->info->xdeathstate); P_SetMobjState(actor, actor->info->xdeathstate);
actor->movecount = 7*TICRATE + P_Random(); actor->movecount = 7*TICRATE + P_RandomByte();
break; break;
} }
actor->threshold++; actor->threshold++;
@ -6180,9 +6175,9 @@ void A_Boss7Chase(mobj_t *actor)
P_SetMobjState(actor, S_BLACKEGG_SHOOT1); P_SetMobjState(actor, S_BLACKEGG_SHOOT1);
if (actor->health > actor->info->damage) if (actor->health > actor->info->damage)
actor->movecount = TICRATE + P_Random()/3; actor->movecount = TICRATE + P_RandomByte()/3;
else else
actor->movecount = TICRATE + P_Random()/2; actor->movecount = TICRATE + P_RandomByte()/2;
break; break;
case 2: // Homing Missile case 2: // Homing Missile
A_FaceTarget(actor); A_FaceTarget(actor);
@ -6266,8 +6261,8 @@ void A_Boss2PogoSFX(mobj_t *actor)
} }
else else
{ {
UINT8 prandom = P_Random(); UINT8 prandom = P_RandomByte();
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_Random() & 1 ? -prandom : +prandom); actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom);
P_InstaThrust(actor, actor->angle, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); P_InstaThrust(actor, actor->angle, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale));
} }
if (actor->info->activesound) S_StartSound(actor, actor->info->activesound); if (actor->info->activesound) S_StartSound(actor, actor->info->activesound);
@ -6307,10 +6302,10 @@ void A_Boss2PogoTarget(mobj_t *actor)
// Target hit, retreat! // Target hit, retreat!
if (actor->target->player->powers[pw_flashing] > TICRATE || actor->flags2 & MF2_FRET) if (actor->target->player->powers[pw_flashing] > TICRATE || actor->flags2 & MF2_FRET)
{ {
UINT8 prandom = P_Random(); UINT8 prandom = P_RandomByte();
actor->z++; // unstick from the floor actor->z++; // unstick from the floor
actor->momz = FixedMul(locvar1, actor->scale); // Bounce up in air actor->momz = FixedMul(locvar1, actor->scale); // Bounce up in air
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_Random() & 1 ? -prandom : +prandom); // Pick a direction, and randomize it. actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom); // Pick a direction, and randomize it.
P_InstaThrust(actor, actor->angle+ANGLE_180, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed P_InstaThrust(actor, actor->angle+ANGLE_180, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed
} }
// Try to land on top of the player. // Try to land on top of the player.
@ -6347,10 +6342,10 @@ void A_Boss2PogoTarget(mobj_t *actor)
// Wander semi-randomly towards the player to get closer. // Wander semi-randomly towards the player to get closer.
else else
{ {
UINT8 prandom = P_Random(); UINT8 prandom = P_RandomByte();
actor->z++; // unstick from the floor actor->z++; // unstick from the floor
actor->momz = FixedMul(locvar1, actor->scale); // Bounce up in air actor->momz = FixedMul(locvar1, actor->scale); // Bounce up in air
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_Random() & 1 ? -prandom : +prandom); // Pick a direction, and randomize it. actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom); // Pick a direction, and randomize it.
P_InstaThrust(actor, actor->angle, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed P_InstaThrust(actor, actor->angle, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed
} }
// Boing! // Boing!
@ -7084,7 +7079,7 @@ void A_SmokeTrailer(mobj_t *actor)
P_SetObjectMomZ(th, FRACUNIT, false); P_SetObjectMomZ(th, FRACUNIT, false);
th->destscale = actor->scale; th->destscale = actor->scale;
P_SetScale(th, actor->scale); P_SetScale(th, actor->scale);
th->tics -= P_Random() & 3; th->tics -= P_RandomByte() & 3;
if (th->tics < 1) if (th->tics < 1)
th->tics = 1; th->tics = 1;
} }
@ -7183,7 +7178,7 @@ void A_ChangeAngleRelative(mobj_t *actor)
// rather than the ranges, so <0 and >360 work as possible values. -Red // rather than the ranges, so <0 and >360 work as possible values. -Red
INT32 locvar1 = var1; INT32 locvar1 = var1;
INT32 locvar2 = var2; INT32 locvar2 = var2;
//angle_t angle = (P_Random()+1)<<24; //angle_t angle = (P_RandomByte()+1)<<24;
const fixed_t amin = locvar1*FRACUNIT; const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT;
//const angle_t amin = FixedAngle(locvar1*FRACUNIT); //const angle_t amin = FixedAngle(locvar1*FRACUNIT);
@ -7217,7 +7212,7 @@ void A_ChangeAngleAbsolute(mobj_t *actor)
{ {
INT32 locvar1 = var1; INT32 locvar1 = var1;
INT32 locvar2 = var2; INT32 locvar2 = var2;
//angle_t angle = (P_Random()+1)<<24; //angle_t angle = (P_RandomByte()+1)<<24;
const fixed_t amin = locvar1*FRACUNIT; const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT;
//const angle_t amin = FixedAngle(locvar1*FRACUNIT); //const angle_t amin = FixedAngle(locvar1*FRACUNIT);
@ -7825,7 +7820,7 @@ void A_RandomState(mobj_t *actor)
return; return;
#endif #endif
P_SetMobjState(actor, P_Random()&1 ? locvar1 : locvar2); P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2);
} }
// Function: A_RandomStateRange // Function: A_RandomStateRange
@ -8516,34 +8511,32 @@ void A_SearchForPlayers(mobj_t *actor)
// Function: A_CheckRandom // Function: A_CheckRandom
// //
// Description: Calls a state by chance (around 1/var1). // Description: Calls a state by chance.
// //
// var1 = denominator (can't exceed 100) // var1:
// lower 16 bits = denominator
// upper 16 bits = numerator (defaults to 1 if zero)
// var2 = state number // var2 = state number
// //
void A_CheckRandom(mobj_t *actor) void A_CheckRandom(mobj_t *actor)
{ {
INT32 locvar1 = var1; INT32 locvar1 = var1;
INT32 locvar2 = var2; INT32 locvar2 = var2;
INT32 i, chance; fixed_t chance = FRACUNIT;
INT32 rndadd = 0;
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
if (LUA_CallAction("A_CheckRandom", actor)) if (LUA_CallAction("A_CheckRandom", actor))
return; return;
#endif #endif
if ((locvar1 & 0xFFFF) == 0)
return;
if(locvar1 > 100) // The PRNG doesn't suck anymore, OK?
locvar1 = 100; if (locvar1 >> 16)
chance *= (locvar1 >> 16);
chance /= (locvar1 & 0xFFFF);
for (i = 0; i < MAXPLAYERS; i++) if (P_RandomChance(chance))
if (playeringame[i])
rndadd += abs((int)players[i].mo->x) + abs((int)players[i].mo->y) + abs((int)players[i].mo->z);
rndadd = rndadd % 10000; //additional component to enlarge random number
chance = (P_Random() + rndadd) % locvar1;
if (chance == 0)
P_SetMobjState(actor, locvar2); P_SetMobjState(actor, locvar2);
} }
@ -9890,7 +9883,7 @@ void A_BrakChase(mobj_t *actor)
S_StartSound(actor, (sfxenum_t)locvar2); S_StartSound(actor, (sfxenum_t)locvar2);
// make active sound // make active sound
if (actor->type != MT_CYBRAKDEMON && actor->info->activesound && P_Random() < 3) if (actor->type != MT_CYBRAKDEMON && actor->info->activesound && P_RandomChance(3*FRACUNIT/256))
{ {
S_StartSound(actor, actor->info->activesound); S_StartSound(actor, actor->info->activesound);
} }

View file

@ -27,6 +27,10 @@
#include "m_misc.h" #include "m_misc.h"
#include "v_video.h" // video flags for CEchos #include "v_video.h" // video flags for CEchos
// CTF player names
#define CTFTEAMCODE(pl) pl->ctfteam ? (pl->ctfteam == 1 ? "\x85" : "\x84") : ""
#define CTFTEAMENDCODE(pl) pl->ctfteam ? "\x80" : ""
void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period) void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period)
{ {
BasicFF_t Basicfeed; BasicFF_t Basicfeed;
@ -574,11 +578,23 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{ {
UINT8 flagteam = (special->type == MT_REDFLAG) ? 1 : 2; UINT8 flagteam = (special->type == MT_REDFLAG) ? 1 : 2;
const char *flagtext; const char *flagtext;
char flagcolor;
char plname[MAXPLAYERNAME+4];
if (special->type == MT_REDFLAG) if (special->type == MT_REDFLAG)
flagtext = M_GetText("red"); {
flagtext = M_GetText("Red flag");
flagcolor = '\x85';
}
else else
flagtext = M_GetText("blue"); {
flagtext = M_GetText("Blue flag");
flagcolor = '\x84';
}
snprintf(plname, sizeof(plname), "%s%s%s",
CTFTEAMCODE(player),
player_names[player - players],
CTFTEAMENDCODE(player));
if (player->ctfteam == flagteam) // Player is on the same team as the flag if (player->ctfteam == flagteam) // Player is on the same team as the flag
{ {
@ -592,10 +608,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (!P_PlayerTouchingSectorSpecial(player, 4, 2 + flagteam)) if (!P_PlayerTouchingSectorSpecial(player, 4, 2 + flagteam))
{ {
CONS_Printf(M_GetText("%s returned the %s flag to base.\n"), player_names[player-players], flagtext); CONS_Printf(M_GetText("%s returned the %c%s%c to base.\n"), plname, flagcolor, flagtext, 0x80);
if (players[consoleplayer].ctfteam == player->ctfteam) // The fuse code plays this sound effect
S_StartSound(NULL, sfx_hoop1); //if (players[consoleplayer].ctfteam == player->ctfteam)
// S_StartSound(NULL, sfx_hoop1);
} }
} }
} }
@ -608,7 +625,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return; return;
player->gotflag |= flagflag; player->gotflag |= flagflag;
CONS_Printf(M_GetText("%s picked up the %s flag!\n"), player_names[player-players], flagtext); CONS_Printf(M_GetText("%s picked up the %c%s%c!\n"), plname, flagcolor, flagtext, 0x80);
(*flagmobj) = NULL; (*flagmobj) = NULL;
// code for dealing with abilities is handled elsewhere now // code for dealing with abilities is handled elsewhere now
break; break;
@ -1236,7 +1253,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (special->target && special->target->state == &states[S_BLACKEGG_SHOOT1]) if (special->target && special->target->state == &states[S_BLACKEGG_SHOOT1])
{ {
if (special->target->health <= 2 && (P_Random() & 1)) if (special->target->health <= 2 && P_RandomChance(FRACUNIT/2))
P_SetMobjState(special->target, special->target->info->missilestate); P_SetMobjState(special->target, special->target->info->missilestate);
else else
P_SetMobjState(special->target, special->target->info->raisestate); P_SetMobjState(special->target, special->target->info->raisestate);
@ -1447,9 +1464,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
P_KillMobj(special, NULL, toucher, 0); P_KillMobj(special, NULL, toucher, 0);
} }
#define CTFTEAMCODE(pl) pl->ctfteam ? (pl->ctfteam == 1 ? "\x85" : "\x84") : ""
#define CTFTEAMENDCODE(pl) pl->ctfteam ? "\x80" : ""
/** Prints death messages relating to a dying or hit player. /** Prints death messages relating to a dying or hit player.
* *
* \param player Affected player. * \param player Affected player.
@ -1473,6 +1487,9 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour
if (!player) if (!player)
return; // Impossible! return; // Impossible!
if (player->spectator)
return; // No messages for dying (crushed) spectators.
if (!netgame) if (!netgame)
return; // Presumably it's obvious what's happening in splitscreen. return; // Presumably it's obvious what's happening in splitscreen.
@ -2076,7 +2093,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
if (target->player->lives <= 0) // Tails 03-14-2000 if (target->player->lives <= 0) // Tails 03-14-2000
{ {
if (P_IsLocalPlayer(target->player) && target->player == &players[consoleplayer]) if (P_IsLocalPlayer(target->player)/* && target->player == &players[consoleplayer] */)
{ {
S_StopMusic(); // Stop the Music! Tails 03-14-2000 S_StopMusic(); // Stop the Music! Tails 03-14-2000
S_ChangeMusicInternal("gmover", false); // Yousa dead now, Okieday? Tails 03-14-2000 S_ChangeMusicInternal("gmover", false); // Yousa dead now, Okieday? Tails 03-14-2000
@ -2194,29 +2211,17 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
default: default:
if (target->info->doomednum) if (target->info->doomednum)
prandom = target->info->doomednum%5; // "Random" animal for new enemies.
else
prandom = P_RandomKey(5); // No placable object, just use a random number.
switch(prandom)
{ {
switch(target->info->doomednum%5)
{
default: item = MT_BUNNY; break; default: item = MT_BUNNY; break;
case 1: item = MT_BIRD; break; case 1: item = MT_BIRD; break;
case 2: item = MT_MOUSE; break; case 2: item = MT_MOUSE; break;
case 3: item = MT_COW; break; case 3: item = MT_COW; break;
case 4: item = MT_CHICKEN; break; case 4: item = MT_CHICKEN; break;
}
}
else
{
prandom = P_Random();
if (prandom < 51)
item = MT_BUNNY;
else if (prandom < 102)
item = MT_BIRD;
else if (prandom < 153)
item = MT_MOUSE;
else if (prandom < 204)
item = MT_COW;
else
item = MT_CHICKEN;
} }
break; break;
} }
@ -3115,7 +3120,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
// Killing dead. Just for kicks. // Killing dead. Just for kicks.
// Require source and inflictor be player. Don't hurt for firing rings. // Require source and inflictor be player. Don't hurt for firing rings.
if (cv_killingdead.value && (source && source->player) && (inflictor && inflictor->player) && P_Random() < 80) if (cv_killingdead.value && (source && source->player) && (inflictor && inflictor->player) && P_RandomChance(5*FRACUNIT/16))
P_DamageMobj(source, target, target, 1, 0); P_DamageMobj(source, target, target, 1, 0);
// do the damage // do the damage
@ -3631,7 +3636,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss)
P_InstaThrust(flag, player->mo->angle, FixedMul(6*FRACUNIT, player->mo->scale)); P_InstaThrust(flag, player->mo->angle, FixedMul(6*FRACUNIT, player->mo->scale));
else else
{ {
angle_t fa = P_Random()*FINEANGLES/256; angle_t fa = P_RandomByte()*FINEANGLES/256;
flag->momx = FixedMul(FINECOSINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); flag->momx = FixedMul(FINECOSINE(fa), FixedMul(6*FRACUNIT, player->mo->scale));
if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) if (!(twodlevel || (player->mo->flags2 & MF2_TWOD)))
flag->momy = FixedMul(FINESINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); flag->momy = FixedMul(FINESINE(fa), FixedMul(6*FRACUNIT, player->mo->scale));
@ -3649,10 +3654,33 @@ void P_PlayerFlagBurst(player_t *player, boolean toss)
flag->fuse = cv_flagtime.value * TICRATE; flag->fuse = cv_flagtime.value * TICRATE;
P_SetTarget(&flag->target, player->mo); P_SetTarget(&flag->target, player->mo);
if (toss) // Flag text
CONS_Printf(M_GetText("%s tossed the %s flag.\n"), player_names[player-players], (type == MT_REDFLAG ? "red" : "blue")); {
else char plname[MAXPLAYERNAME+4];
CONS_Printf(M_GetText("%s dropped the %s flag.\n"), player_names[player-players], (type == MT_REDFLAG ? "red" : "blue")); char *flagtext;
char flagcolor;
snprintf(plname, sizeof(plname), "%s%s%s",
CTFTEAMCODE(player),
player_names[player - players],
CTFTEAMENDCODE(player));
if (type == MT_REDFLAG)
{
flagtext = M_GetText("Red flag");
flagcolor = '\x85';
}
else
{
flagtext = M_GetText("Blue flag");
flagcolor = '\x84';
}
if (toss)
CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80);
else
CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80);
}
player->gotflag = 0; player->gotflag = 0;

View file

@ -51,7 +51,7 @@ void T_FireFlicker(fireflicker_t *flick)
if (--flick->count) if (--flick->count)
return; return;
amount = (INT16)((UINT8)(P_Random() & 3) * 16); amount = (INT16)((UINT8)(P_RandomByte() & 3) * 16);
if (flick->sector->lightlevel - amount < flick->minlight) if (flick->sector->lightlevel - amount < flick->minlight)
flick->sector->lightlevel = (INT16)flick->minlight; flick->sector->lightlevel = (INT16)flick->minlight;
@ -235,7 +235,7 @@ strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector,
flash->minlight = 0; flash->minlight = 0;
if (!inSync) if (!inSync)
flash->count = (P_Random() & 7) + 1; flash->count = (P_RandomByte() & 7) + 1;
else else
flash->count = 1; flash->count = 1;

View file

@ -1156,13 +1156,17 @@ static boolean PIT_CheckLine(line_t *ld)
{ {
tmceilingz = opentop; tmceilingz = opentop;
ceilingline = ld; ceilingline = ld;
#ifdef ESLOPE
tmceilingslope = opentopslope; tmceilingslope = opentopslope;
#endif
} }
if (openbottom > tmfloorz) if (openbottom > tmfloorz)
{ {
tmfloorz = openbottom; tmfloorz = openbottom;
#ifdef ESLOPE
tmfloorslope = openbottomslope; tmfloorslope = openbottomslope;
#endif
} }
if (highceiling > tmdrpoffceilz) if (highceiling > tmdrpoffceilz)
@ -2061,21 +2065,26 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
thing->ceilingz = tmceilingz; thing->ceilingz = tmceilingz;
#ifdef ESLOPE #ifdef ESLOPE
// Assign thing's standingslope if needed if (!(thing->flags & MF_NOCLIPHEIGHT))
if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { {
if (!startingonground && tmfloorslope) // Assign thing's standingslope if needed
P_HandleSlopeLanding(thing, tmfloorslope); if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) {
if (!startingonground && tmfloorslope)
P_HandleSlopeLanding(thing, tmfloorslope);
if (thing->momz <= 0) if (thing->momz <= 0)
thing->standingslope = tmfloorslope; thing->standingslope = tmfloorslope;
} }
else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) {
if (!startingonground && tmceilingslope) if (!startingonground && tmceilingslope)
P_HandleSlopeLanding(thing, tmceilingslope); P_HandleSlopeLanding(thing, tmceilingslope);
if (thing->momz >= 0) if (thing->momz >= 0)
thing->standingslope = tmceilingslope; thing->standingslope = tmceilingslope;
}
} }
else // don't set standingslope if you're not going to clip against it
thing->standingslope = NULL;
#endif #endif
thing->x = x; thing->x = x;

View file

@ -527,13 +527,17 @@ void P_LineOpening(line_t *linedef)
{ {
opentop = frontheight; opentop = frontheight;
highceiling = backheight; highceiling = backheight;
#ifdef ESLOPE
opentopslope = front->c_slope; opentopslope = front->c_slope;
#endif
} }
else else
{ {
opentop = backheight; opentop = backheight;
highceiling = frontheight; highceiling = frontheight;
#ifdef ESLOPE
opentopslope = back->c_slope; opentopslope = back->c_slope;
#endif
} }
frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef); frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef);
@ -543,13 +547,17 @@ void P_LineOpening(line_t *linedef)
{ {
openbottom = frontheight; openbottom = frontheight;
lowfloor = backheight; lowfloor = backheight;
#ifdef ESLOPE
openbottomslope = front->f_slope; openbottomslope = front->f_slope;
#endif
} }
else else
{ {
openbottom = backheight; openbottom = backheight;
lowfloor = frontheight; lowfloor = frontheight;
#ifdef ESLOPE
openbottomslope = back->f_slope; openbottomslope = back->f_slope;
#endif
} }
} }

View file

@ -827,9 +827,9 @@ void P_EmeraldManager(void)
break; break;
if (leveltime < TICRATE) // Start of map if (leveltime < TICRATE) // Start of map
spawnpoints[j]->threshold = 60*TICRATE + P_Random() * (TICRATE/5); spawnpoints[j]->threshold = 60*TICRATE + P_RandomByte() * (TICRATE/5);
else else
spawnpoints[j]->threshold = P_Random() * (TICRATE/5); spawnpoints[j]->threshold = P_RandomByte() * (TICRATE/5);
break; break;
} }
@ -858,26 +858,26 @@ void P_ExplodeMissile(mobj_t *mo)
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx += (P_Random() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy += (P_Random() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale);
S_StartSound(explodemo, sfx_pop); S_StartSound(explodemo, sfx_pop);
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx += (P_Random() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx += (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy -= (P_Random() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy -= (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale);
S_StartSound(explodemo, sfx_dmpain); S_StartSound(explodemo, sfx_dmpain);
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx -= (P_Random() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx -= (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy += (P_Random() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy += (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale);
S_StartSound(explodemo, sfx_pop); S_StartSound(explodemo, sfx_pop);
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx -= (P_Random() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy -= (P_Random() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale);
S_StartSound(explodemo, sfx_cybdth); S_StartSound(explodemo, sfx_cybdth);
// Hack: Release an animal. // Hack: Release an animal.
@ -927,6 +927,7 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover)
return true; return true;
} }
#ifdef ESLOPE
// P_GetFloorZ (and its ceiling counterpart) // P_GetFloorZ (and its ceiling counterpart)
// Gets the floor height (or ceiling height) of the mobj's contact point in sector, assuming object's center if moved to [x, y] // Gets the floor height (or ceiling height) of the mobj's contact point in sector, assuming object's center if moved to [x, y]
// If line is supplied, it's a divider line on the sector. Set it to NULL if you're not checking for collision with a line // If line is supplied, it's a divider line on the sector. Set it to NULL if you're not checking for collision with a line
@ -1030,10 +1031,13 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line,
P_GetZAt(slope, v2.x, v2.y) P_GetZAt(slope, v2.x, v2.y)
); );
} }
#endif
fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{ {
#ifdef ESLOPE
I_Assert(mobj != NULL); I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL); I_Assert(sector != NULL);
#ifdef ESLOPE #ifdef ESLOPE
if (sector->f_slope) { if (sector->f_slope) {
@ -1105,13 +1109,23 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
return HighestOnLine(mobj->radius, x, y, line, slope, lowest); return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the floor height } else // Well, that makes it easy. Just get the floor height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif #endif
return sector->floorheight; return sector->floorheight;
} }
fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{ {
#ifdef ESLOPE
I_Assert(mobj != NULL); I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL); I_Assert(sector != NULL);
#ifdef ESLOPE #ifdef ESLOPE
if (sector->c_slope) { if (sector->c_slope) {
@ -1183,6 +1197,14 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
return HighestOnLine(mobj->radius, x, y, line, slope, lowest); return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the ceiling height } else // Well, that makes it easy. Just get the ceiling height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif #endif
return sector->ceilingheight; return sector->ceilingheight;
} }
@ -1190,7 +1212,9 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
// Now do the same as all above, but for cameras because apparently cameras are special? // Now do the same as all above, but for cameras because apparently cameras are special?
fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{ {
#ifdef ESLOPE
I_Assert(mobj != NULL); I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL); I_Assert(sector != NULL);
#ifdef ESLOPE #ifdef ESLOPE
if (sector->f_slope) { if (sector->f_slope) {
@ -1262,13 +1286,23 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
return HighestOnLine(mobj->radius, x, y, line, slope, lowest); return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the floor height } else // Well, that makes it easy. Just get the floor height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif #endif
return sector->floorheight; return sector->floorheight;
} }
fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect)
{ {
#ifdef ESLOPE
I_Assert(mobj != NULL); I_Assert(mobj != NULL);
#endif
I_Assert(sector != NULL); I_Assert(sector != NULL);
#ifdef ESLOPE #ifdef ESLOPE
if (sector->c_slope) { if (sector->c_slope) {
@ -1340,6 +1374,14 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
return HighestOnLine(mobj->radius, x, y, line, slope, lowest); return HighestOnLine(mobj->radius, x, y, line, slope, lowest);
} else // Well, that makes it easy. Just get the ceiling height } else // Well, that makes it easy. Just get the ceiling height
#else
(void)mobj;
(void)boundsec;
(void)x;
(void)y;
(void)line;
(void)lowest;
(void)perfect;
#endif #endif
return sector->ceilingheight; return sector->ceilingheight;
} }
@ -2281,8 +2323,13 @@ static boolean P_ZMovement(mobj_t *mo)
I_Assert(!P_MobjWasRemoved(mo)); I_Assert(!P_MobjWasRemoved(mo));
#ifdef ESLOPE #ifdef ESLOPE
if (mo->standingslope && !P_IsObjectOnGround(mo)) if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
mo->standingslope = NULL;
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo); P_SlopeLaunch(mo);
}
#endif #endif
// Intercept the stupid 'fall through 3dfloors' bug // Intercept the stupid 'fall through 3dfloors' bug
@ -2580,12 +2627,12 @@ static boolean P_ZMovement(mobj_t *mo)
// If deafed, give the tumbleweed another random kick if it runs out of steam. // If deafed, give the tumbleweed another random kick if it runs out of steam.
mom.z += P_MobjFlip(mo)*FixedMul(6*FRACUNIT, mo->scale); mom.z += P_MobjFlip(mo)*FixedMul(6*FRACUNIT, mo->scale);
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
mom.x += FixedMul(6*FRACUNIT, mo->scale); mom.x += FixedMul(6*FRACUNIT, mo->scale);
else else
mom.x -= FixedMul(6*FRACUNIT, mo->scale); mom.x -= FixedMul(6*FRACUNIT, mo->scale);
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
mom.y += FixedMul(6*FRACUNIT, mo->scale); mom.y += FixedMul(6*FRACUNIT, mo->scale);
else else
mom.y -= FixedMul(6*FRACUNIT, mo->scale); mom.y -= FixedMul(6*FRACUNIT, mo->scale);
@ -2763,8 +2810,13 @@ static void P_PlayerZMovement(mobj_t *mo)
return; return;
#ifdef ESLOPE #ifdef ESLOPE
if (mo->standingslope && !P_IsObjectOnGround(mo)) if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
mo->standingslope = NULL;
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo); P_SlopeLaunch(mo);
}
#endif #endif
// clip movement // clip movement
@ -3061,7 +3113,7 @@ static boolean P_SceneryZMovement(mobj_t *mo)
for (i = 0; i < 4; ++i) // split into four for (i = 0; i < 4; ++i) // split into four
{ {
prandom = P_Random(); prandom = P_RandomByte();
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_SMALLBUBBLE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_SMALLBUBBLE);
explodemo->momx += ((prandom & 0x0F) << (FRACBITS-2)) * (i & 2 ? -1 : 1); explodemo->momx += ((prandom & 0x0F) << (FRACBITS-2)) * (i & 2 ? -1 : 1);
explodemo->momy += ((prandom & 0xF0) << (FRACBITS-6)) * (i & 1 ? -1 : 1); explodemo->momy += ((prandom & 0xF0) << (FRACBITS-6)) * (i & 1 ? -1 : 1);
@ -3393,13 +3445,13 @@ void P_MobjCheckWater(mobj_t *mobj)
// Create tons of bubbles // Create tons of bubbles
for (i = 0; i < bubblecount; i++) for (i = 0; i < bubblecount; i++)
{ {
// P_Random()s are called individually to allow consistency // P_RandomByte()s are called individually to allow consistency
// across various compilers, since the order of function calls // across various compilers, since the order of function calls
// in C is not part of the ANSI specification. // in C is not part of the ANSI specification.
prandom[0] = P_Random(); prandom[0] = P_RandomByte();
prandom[1] = P_Random(); prandom[1] = P_RandomByte();
prandom[2] = P_Random(); prandom[2] = P_RandomByte();
prandom[3] = P_Random(); prandom[3] = P_RandomByte();
bubbletype = MT_SMALLBUBBLE; bubbletype = MT_SMALLBUBBLE;
if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32 if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32
@ -3873,10 +3925,15 @@ static void CalculatePrecipFloor(precipmobj_t *mobj)
mobjsecsubsec = mobj->subsector->sector; mobjsecsubsec = mobj->subsector->sector;
else else
return; return;
mobj->floorz = mobjsecsubsec->floorheight; mobj->floorz =
#ifdef ESLOPE
mobjsecsubsec->f_slope ? P_GetZAt(mobjsecsubsec->f_slope, mobj->x, mobj->y) :
#endif
mobjsecsubsec->floorheight;
if (mobjsecsubsec->ffloors) if (mobjsecsubsec->ffloors)
{ {
ffloor_t *rover; ffloor_t *rover;
fixed_t topheight;
for (rover = mobjsecsubsec->ffloors; rover; rover = rover->next) for (rover = mobjsecsubsec->ffloors; rover; rover = rover->next)
{ {
@ -3887,8 +3944,15 @@ static void CalculatePrecipFloor(precipmobj_t *mobj)
if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE)) if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE))
continue; continue;
if (*rover->topheight > mobj->floorz) #ifdef ESLOPE
mobj->floorz = *rover->topheight; if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y);
else
#endif
topheight = *rover->topheight;
if (topheight > mobj->floorz)
mobj->floorz = topheight;
} }
} }
} }
@ -4001,7 +4065,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest)
// first time init, this allow minimum lastlook changes // first time init, this allow minimum lastlook changes
if (actor->lastlook < 0) if (actor->lastlook < 0)
actor->lastlook = P_Random(); actor->lastlook = P_RandomByte();
actor->lastlook &= PLAYERSMASK; actor->lastlook &= PLAYERSMASK;
for( ; ; actor->lastlook = (actor->lastlook+1) & PLAYERSMASK) for( ; ; actor->lastlook = (actor->lastlook+1) & PLAYERSMASK)
@ -4882,7 +4946,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (mobj->state == &states[S_BLACKEGG_STND] && mobj->tics == mobj->state->tics) if (mobj->state == &states[S_BLACKEGG_STND] && mobj->tics == mobj->state->tics)
{ {
mobj->reactiontime += P_Random(); mobj->reactiontime += P_RandomByte();
if (mobj->health <= mobj->info->damage) if (mobj->health <= mobj->info->damage)
mobj->reactiontime /= 4; mobj->reactiontime /= 4;
@ -5076,7 +5140,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (mobj->tracer && mobj->tracer->type == MT_BOSS3WAYPOINT if (mobj->tracer && mobj->tracer->type == MT_BOSS3WAYPOINT
&& mobj->tracer->spawnpoint && (mobj->tracer->spawnpoint->options & 7) == waypointNum) && mobj->tracer->spawnpoint && (mobj->tracer->spawnpoint->options & 7) == waypointNum)
{ {
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
waypointNum++; waypointNum++;
else else
waypointNum--; waypointNum--;
@ -5088,7 +5152,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
} }
if (waypointNum == 0 && mobj->health <= mobj->info->damage) if (waypointNum == 0 && mobj->health <= mobj->info->damage)
waypointNum = 1 + (P_Random() & 1); waypointNum = 1 + (P_RandomFixed() & 1);
// scan the thinkers to find // scan the thinkers to find
// the waypoint to use // the waypoint to use
@ -5188,7 +5252,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
P_SetMobjState(mobj, mobj->info->spawnstate); P_SetMobjState(mobj, mobj->info->spawnstate);
} }
else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics)
S_StartSound(0, sfx_bedie1 + (P_Random() & 1)); S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1));
} }
@ -5615,7 +5679,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
// An incoming attack is detected! What should we do?! // An incoming attack is detected! What should we do?!
// Go into vector form! // Go into vector form!
mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<<FRACBITS, (mobj->info->spawnhealth-1)<<FRACBITS))); mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<<FRACBITS, (mobj->info->spawnhealth-1)<<FRACBITS)));
if (P_Random()&1) if (P_RandomChance(FRACUNIT/2))
mobj->movedir = InvAngle(mobj->movedir); mobj->movedir = InvAngle(mobj->movedir);
mobj->threshold = 6 + (FixedMul(24<<FRACBITS, FixedDiv((mobj->info->spawnhealth - mobj->health)<<FRACBITS, (mobj->info->spawnhealth-1)<<FRACBITS))>>FRACBITS); mobj->threshold = 6 + (FixedMul(24<<FRACBITS, FixedDiv((mobj->info->spawnhealth - mobj->health)<<FRACBITS, (mobj->info->spawnhealth-1)<<FRACBITS))>>FRACBITS);
if (mobj->info->activesound) if (mobj->info->activesound)
@ -6217,20 +6281,20 @@ static void P_KoopaThinker(mobj_t *koopa)
P_XYMovement(koopa); P_XYMovement(koopa);
if (P_Random() < 8 && koopa->z <= koopa->floorz) if (P_RandomChance(FRACUNIT/32) && koopa->z <= koopa->floorz)
koopa->momz = FixedMul(5*FRACUNIT, koopa->scale); koopa->momz = FixedMul(5*FRACUNIT, koopa->scale);
if (koopa->z > koopa->floorz) if (koopa->z > koopa->floorz)
koopa->momz += FixedMul(FRACUNIT/4, koopa->scale); koopa->momz += FixedMul(FRACUNIT/4, koopa->scale);
if (P_Random() < 4) if (P_RandomChance(FRACUNIT/64))
{ {
mobj_t *flame; mobj_t *flame;
flame = P_SpawnMobj(koopa->x - koopa->radius + FixedMul(5*FRACUNIT, koopa->scale), koopa->y, koopa->z + (P_Random()<<(FRACBITS-2)), MT_KOOPAFLAME); flame = P_SpawnMobj(koopa->x - koopa->radius + FixedMul(5*FRACUNIT, koopa->scale), koopa->y, koopa->z + (P_RandomByte()<<(FRACBITS-2)), MT_KOOPAFLAME);
flame->momx = -FixedMul(flame->info->speed, flame->scale); flame->momx = -FixedMul(flame->info->speed, flame->scale);
S_StartSound(flame, sfx_koopfr); S_StartSound(flame, sfx_koopfr);
} }
else if (P_Random() > 250) else if (P_RandomChance(5*FRACUNIT/256))
{ {
mobj_t *hammer; mobj_t *hammer;
hammer = P_SpawnMobj(koopa->x - koopa->radius, koopa->y, koopa->z + koopa->height, MT_HAMMER); hammer = P_SpawnMobj(koopa->x - koopa->radius, koopa->y, koopa->z + koopa->height, MT_HAMMER);
@ -6673,11 +6737,11 @@ void P_MobjThinker(mobj_t *mobj)
fixed_t ns; fixed_t ns;
mobj_t *mo2; mobj_t *mo2;
i = P_Random(); i = P_RandomByte();
z = mobj->subsector->sector->floorheight + ((P_Random()&63)*FRACUNIT); z = mobj->subsector->sector->floorheight + ((P_RandomByte()&63)*FRACUNIT);
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
{ {
const angle_t fa = (P_Random()*FINEANGLES/16) & FINEMASK; const angle_t fa = (P_RandomByte()*FINEANGLES/16) & FINEMASK;
ns = 64 * FRACUNIT; ns = 64 * FRACUNIT;
x = mobj->x + FixedMul(FINESINE(fa),ns); x = mobj->x + FixedMul(FINESINE(fa),ns);
y = mobj->y + FixedMul(FINECOSINE(fa),ns); y = mobj->y + FixedMul(FINECOSINE(fa),ns);
@ -6687,7 +6751,7 @@ void P_MobjThinker(mobj_t *mobj)
mo2->momx = FixedMul(FINESINE(fa),ns); mo2->momx = FixedMul(FINESINE(fa),ns);
mo2->momy = FixedMul(FINECOSINE(fa),ns); mo2->momy = FixedMul(FINECOSINE(fa),ns);
i = P_Random(); i = P_RandomByte();
if (i % 5 == 0) if (i % 5 == 0)
P_SpawnMobj(x, y, z, MT_CHICKEN); P_SpawnMobj(x, y, z, MT_CHICKEN);
@ -7323,9 +7387,10 @@ void P_MobjThinker(mobj_t *mobj)
if (mobj->type == MT_REDFLAG) if (mobj->type == MT_REDFLAG)
{ {
if (!(mobj->flags2 & MF2_JUSTATTACKED)) if (!(mobj->flags2 & MF2_JUSTATTACKED))
CONS_Printf(M_GetText("The red flag has returned to base.\n")); CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80);
if (players[consoleplayer].ctfteam == 1) // Assumedly in splitscreen players will be on opposing teams
if (players[consoleplayer].ctfteam == 1 || splitscreen)
S_StartSound(NULL, sfx_hoop1); S_StartSound(NULL, sfx_hoop1);
redflag = flagmo; redflag = flagmo;
@ -7333,9 +7398,10 @@ void P_MobjThinker(mobj_t *mobj)
else // MT_BLUEFLAG else // MT_BLUEFLAG
{ {
if (!(mobj->flags2 & MF2_JUSTATTACKED)) if (!(mobj->flags2 & MF2_JUSTATTACKED))
CONS_Printf(M_GetText("The blue flag has returned to base.\n")); CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80);
if (players[consoleplayer].ctfteam == 2) // Assumedly in splitscreen players will be on opposing teams
if (players[consoleplayer].ctfteam == 2 || splitscreen)
S_StartSound(NULL, sfx_hoop1); S_StartSound(NULL, sfx_hoop1);
blueflag = flagmo; blueflag = flagmo;
@ -7925,6 +7991,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
{ {
state_t *st; state_t *st;
precipmobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); precipmobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
fixed_t starting_floorz;
mobj->x = x; mobj->x = x;
mobj->y = y; mobj->y = y;
@ -7943,8 +8010,16 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
// set subsector and/or block links // set subsector and/or block links
P_SetPrecipitationThingPosition(mobj); P_SetPrecipitationThingPosition(mobj);
mobj->floorz = mobj->subsector->sector->floorheight; mobj->floorz = starting_floorz =
mobj->ceilingz = mobj->subsector->sector->ceilingheight; #ifdef ESLOPE
mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) :
#endif
mobj->subsector->sector->floorheight;
mobj->ceilingz =
#ifdef ESLOPE
mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) :
#endif
mobj->subsector->sector->ceilingheight;
mobj->z = z; mobj->z = z;
mobj->momz = mobjinfo[type].speed; mobj->momz = mobjinfo[type].speed;
@ -7954,7 +8029,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
CalculatePrecipFloor(mobj); CalculatePrecipFloor(mobj);
if (mobj->floorz != mobj->subsector->sector->floorheight) if (mobj->floorz != starting_floorz)
mobj->precipflags |= PCF_FOF; mobj->precipflags |= PCF_FOF;
else if (GETSECSPECIAL(mobj->subsector->sector->special, 1) == 7 else if (GETSECSPECIAL(mobj->subsector->sector->special, 1) == 7
|| GETSECSPECIAL(mobj->subsector->sector->special, 1) == 6 || GETSECSPECIAL(mobj->subsector->sector->special, 1) == 6
@ -8171,7 +8246,7 @@ void P_SpawnPrecipitation(void)
continue; continue;
rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE); rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE);
mrand = M_Random(); mrand = M_RandomByte();
if (mrand < 64) if (mrand < 64)
P_SetPrecipMobjState(rainmo, S_SNOW3); P_SetPrecipMobjState(rainmo, S_SNOW3);
else if (mrand < 144) else if (mrand < 144)
@ -8381,7 +8456,11 @@ void P_RespawnSpecials(void)
if (mthing->options & MTF_OBJECTFLIP) if (mthing->options & MTF_OBJECTFLIP)
{ {
z = ss->sector->ceilingheight - (mthing->options >> ZSHIFT) * FRACUNIT; z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT;
if (mthing->options & MTF_AMBUSH if (mthing->options & MTF_AMBUSH
&& (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i)))
z -= 24*FRACUNIT; z -= 24*FRACUNIT;
@ -8389,7 +8468,11 @@ void P_RespawnSpecials(void)
} }
else else
{ {
z = ss->sector->floorheight + (mthing->options >> ZSHIFT) * FRACUNIT; z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT;
if (mthing->options & MTF_AMBUSH if (mthing->options & MTF_AMBUSH
&& (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i)))
z += 24*FRACUNIT; z += 24*FRACUNIT;
@ -8559,7 +8642,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
fixed_t z; fixed_t z;
sector_t *sector; sector_t *sector;
fixed_t floor, ceiling;
player_t *p = &players[playernum]; player_t *p = &players[playernum];
mobj_t *mobj = p->mo; mobj_t *mobj = p->mo;
@ -8575,19 +8658,31 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
// set Z height // set Z height
sector = R_PointInSubsector(x, y)->sector; sector = R_PointInSubsector(x, y)->sector;
floor =
#ifdef ESLOPE
sector->f_slope ? P_GetZAt(sector->f_slope, x, y) :
#endif
sector->floorheight;
ceiling =
#ifdef ESLOPE
sector->c_slope ? P_GetZAt(sector->c_slope, x, y) :
#endif
sector->ceilingheight;
if (mthing) if (mthing)
{ {
// Flagging a player's ambush will make them start on the ceiling // Flagging a player's ambush will make them start on the ceiling
// Objectflip inverts // Objectflip inverts
if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP)) if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP))
{ {
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height; z = ceiling - mobjinfo[MT_PLAYER].height;
if (mthing->options >> ZSHIFT) if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS); z -= ((mthing->options >> ZSHIFT) << FRACBITS);
} }
else else
{ {
z = sector->floorheight; z = floor;
if (mthing->options >> ZSHIFT) if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS); z += ((mthing->options >> ZSHIFT) << FRACBITS);
} }
@ -8599,15 +8694,15 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
} }
} }
else else
z = sector->floorheight; z = floor;
if (z < sector->floorheight) if (z < floor)
z = sector->floorheight; z = floor;
else if (z > sector->ceilingheight - mobjinfo[MT_PLAYER].height) else if (z > ceiling - mobjinfo[MT_PLAYER].height)
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height; z = ceiling - mobjinfo[MT_PLAYER].height;
mobj->floorz = sector->floorheight; mobj->floorz = floor;
mobj->ceilingz = sector->ceilingheight; mobj->ceilingz = ceiling;
P_UnsetThingPosition(mobj); P_UnsetThingPosition(mobj);
mobj->x = x; mobj->x = x;
@ -8615,7 +8710,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
P_SetThingPosition(mobj); P_SetThingPosition(mobj);
mobj->z = z; mobj->z = z;
if (mobj->z == sector->floorheight) if (mobj->z == mobj->floorz)
mobj->eflags |= MFE_ONGROUND; mobj->eflags |= MFE_ONGROUND;
mobj->angle = angle; mobj->angle = angle;
@ -8627,6 +8722,7 @@ void P_MovePlayerToStarpost(INT32 playernum)
{ {
fixed_t z; fixed_t z;
sector_t *sector; sector_t *sector;
fixed_t floor, ceiling;
player_t *p = &players[playernum]; player_t *p = &players[playernum];
mobj_t *mobj = p->mo; mobj_t *mobj = p->mo;
@ -8638,14 +8734,25 @@ void P_MovePlayerToStarpost(INT32 playernum)
P_SetThingPosition(mobj); P_SetThingPosition(mobj);
sector = R_PointInSubsector(mobj->x, mobj->y)->sector; sector = R_PointInSubsector(mobj->x, mobj->y)->sector;
z = p->starpostz << FRACBITS; floor =
if (z < sector->floorheight) #ifdef ESLOPE
z = sector->floorheight; sector->f_slope ? P_GetZAt(sector->f_slope, mobj->x, mobj->y) :
else if (z > sector->ceilingheight - mobjinfo[MT_PLAYER].height) #endif
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height; sector->floorheight;
ceiling =
#ifdef ESLOPE
sector->c_slope ? P_GetZAt(sector->c_slope, mobj->x, mobj->y) :
#endif
sector->ceilingheight;
mobj->floorz = sector->floorheight; z = p->starpostz << FRACBITS;
mobj->ceilingz = sector->ceilingheight; if (z < floor)
z = floor;
else if (z > ceiling - mobjinfo[MT_PLAYER].height)
z = ceiling - mobjinfo[MT_PLAYER].height;
mobj->floorz = floor;
mobj->ceilingz = ceiling;
mobj->z = z; mobj->z = z;
if (mobj->z == mobj->floorz) if (mobj->z == mobj->floorz)
@ -8731,6 +8838,9 @@ void P_SpawnMapThing(mapthing_t *mthing)
return; return;
} }
else if (mthing->type == 750) // Slope vertex point (formerly chaos spawn)
return;
else if (mthing->type == 300 // Ring else if (mthing->type == 300 // Ring
|| mthing->type == 308 || mthing->type == 309 // Team Rings || mthing->type == 308 || mthing->type == 309 // Team Rings
|| mthing->type == 1706 // Nights Wing || mthing->type == 1706 // Nights Wing
@ -8764,8 +8874,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
if (i == NUMMOBJTYPES) if (i == NUMMOBJTYPES)
{ {
if (mthing->type == 3328 // 3D Mode start Thing if (mthing->type == 3328) // 3D Mode start Thing
|| mthing->type == 750) // Chaos mode spawn
return; return;
CONS_Alert(CONS_WARNING, M_GetText("Unknown thing type %d placed at (%d, %d)\n"), mthing->type, mthing->x, mthing->y); CONS_Alert(CONS_WARNING, M_GetText("Unknown thing type %d placed at (%d, %d)\n"), mthing->type, mthing->x, mthing->y);
i = MT_UNKNOWN; i = MT_UNKNOWN;
@ -9073,6 +9182,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
const size_t mthingi = (size_t)(mthing - mapthings); const size_t mthingi = (size_t)(mthing - mapthings);
// Why does P_FindSpecialLineFromTag not work here?!? // Why does P_FindSpecialLineFromTag not work here?!?
// Monster Iestyn: tag lists haven't been initialised yet for the map, that's why
for (line = 0; line < numlines; line++) for (line = 0; line < numlines; line++)
{ {
if (lines[line].special == 9 && lines[line].tag == mthing->angle) if (lines[line].special == 9 && lines[line].tag == mthing->angle)
@ -9222,10 +9332,6 @@ ML_NOCLIMB : Direction not controllable
{ {
if (mthing->options & MTF_OBJECTSPECIAL) // No egg trap for this boss if (mthing->options & MTF_OBJECTSPECIAL) // No egg trap for this boss
mobj->flags2 |= MF2_BOSSNOTRAP; mobj->flags2 |= MF2_BOSSNOTRAP;
z = ss->sector->floorheight + ((mthing->options >> (ZSHIFT)) << FRACBITS);
mthing->z = (INT16)(z>>FRACBITS);
} }
if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE) // Axis Points if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE) // Axis Points
@ -9340,12 +9446,12 @@ ML_NOCLIMB : Direction not controllable
{ {
mobj->momz += FixedMul(16*FRACUNIT, mobj->scale); mobj->momz += FixedMul(16*FRACUNIT, mobj->scale);
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
mobj->momx += FixedMul(16*FRACUNIT, mobj->scale); mobj->momx += FixedMul(16*FRACUNIT, mobj->scale);
else else
mobj->momx -= FixedMul(16*FRACUNIT, mobj->scale); mobj->momx -= FixedMul(16*FRACUNIT, mobj->scale);
if (P_Random() & 1) if (P_RandomChance(FRACUNIT/2))
mobj->momy += FixedMul(16*FRACUNIT, mobj->scale); mobj->momy += FixedMul(16*FRACUNIT, mobj->scale);
else else
mobj->momy -= FixedMul(16*FRACUNIT,mobj->scale); mobj->momy -= FixedMul(16*FRACUNIT,mobj->scale);

View file

@ -613,7 +613,7 @@ static void P_NetArchiveWorld(void)
WRITEUINT16(put, j); // save ffloor "number" WRITEUINT16(put, j); // save ffloor "number"
WRITEUINT8(put, fflr_diff); WRITEUINT8(put, fflr_diff);
if (fflr_diff & 1) if (fflr_diff & 1)
WRITEUINT16(put, rover->flags); WRITEUINT32(put, rover->flags);
if (fflr_diff & 2) if (fflr_diff & 2)
WRITEINT16(put, rover->alpha); WRITEINT16(put, rover->alpha);
} }
@ -815,7 +815,7 @@ static void P_NetUnArchiveWorld(void)
fflr_diff = READUINT8(get); fflr_diff = READUINT8(get);
if (fflr_diff & 1) if (fflr_diff & 1)
rover->flags = READUINT16(get); rover->flags = READUINT32(get);
if (fflr_diff & 2) if (fflr_diff & 2)
rover->alpha = READINT16(get); rover->alpha = READINT16(get);
@ -924,8 +924,12 @@ typedef enum
MD2_EXTVAL1 = 1<<5, MD2_EXTVAL1 = 1<<5,
MD2_EXTVAL2 = 1<<6, MD2_EXTVAL2 = 1<<6,
MD2_HNEXT = 1<<7, MD2_HNEXT = 1<<7,
#ifdef ESLOPE
MD2_HPREV = 1<<8, MD2_HPREV = 1<<8,
MD2_SLOPE = 1<<9 MD2_SLOPE = 1<<9
#else
MD2_HPREV = 1<<8
#endif
} mobj_diff2_t; } mobj_diff2_t;
typedef enum typedef enum
@ -1117,8 +1121,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
diff2 |= MD2_HNEXT; diff2 |= MD2_HNEXT;
if (mobj->hprev) if (mobj->hprev)
diff2 |= MD2_HPREV; diff2 |= MD2_HPREV;
#ifdef ESLOPE
if (mobj->standingslope) if (mobj->standingslope)
diff2 |= MD2_SLOPE; diff2 |= MD2_SLOPE;
#endif
if (diff2 != 0) if (diff2 != 0)
diff |= MD_MORE; diff |= MD_MORE;
@ -1237,8 +1243,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
WRITEUINT32(save_p, mobj->hnext->mobjnum); WRITEUINT32(save_p, mobj->hnext->mobjnum);
if (diff2 & MD2_HPREV) if (diff2 & MD2_HPREV)
WRITEUINT32(save_p, mobj->hprev->mobjnum); WRITEUINT32(save_p, mobj->hprev->mobjnum);
#ifdef ESLOPE
if (diff2 & MD2_SLOPE) if (diff2 & MD2_SLOPE)
WRITEUINT16(save_p, mobj->standingslope->id); WRITEUINT16(save_p, mobj->standingslope->id);
#endif
WRITEUINT32(save_p, mobj->mobjnum); WRITEUINT32(save_p, mobj->mobjnum);
} }
@ -2098,8 +2106,10 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->hnext = (mobj_t *)(size_t)READUINT32(save_p); mobj->hnext = (mobj_t *)(size_t)READUINT32(save_p);
if (diff2 & MD2_HPREV) if (diff2 & MD2_HPREV)
mobj->hprev = (mobj_t *)(size_t)READUINT32(save_p); mobj->hprev = (mobj_t *)(size_t)READUINT32(save_p);
#ifdef ESLOPE
if (diff2 & MD2_SLOPE) if (diff2 & MD2_SLOPE)
mobj->standingslope = P_SlopeById(READUINT16(save_p)); mobj->standingslope = P_SlopeById(READUINT16(save_p));
#endif
if (diff & MD_REDFLAG) if (diff & MD_REDFLAG)

View file

@ -1888,7 +1888,7 @@ static boolean P_LoadBlockMap(lumpnum_t lumpnum)
// //
static void P_GroupLines(void) static void P_GroupLines(void)
{ {
size_t i, j, total = 0; size_t i, j;
line_t *li; line_t *li;
sector_t *sector; sector_t *sector;
subsector_t *ss = subsectors; subsector_t *ss = subsectors;
@ -1922,14 +1922,10 @@ static void P_GroupLines(void)
// count number of lines in each sector // count number of lines in each sector
for (i = 0, li = lines; i < numlines; i++, li++) for (i = 0, li = lines; i < numlines; i++, li++)
{ {
total++;
li->frontsector->linecount++; li->frontsector->linecount++;
if (li->backsector && li->backsector != li->frontsector) if (li->backsector && li->backsector != li->frontsector)
{
li->backsector->linecount++; li->backsector->linecount++;
total++;
}
} }
// allocate linebuffers for each sector // allocate linebuffers for each sector

View file

@ -1099,6 +1099,9 @@ void P_ButteredSlope(mobj_t *mo)
if (!mo->standingslope) if (!mo->standingslope)
return; return;
if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY))
return; // don't slide down slopes if you can't touch them or you're not affected by gravity
if (mo->player) { if (mo->player) {
if (abs(mo->standingslope->zdelta) < FRACUNIT/4 && !(mo->player->pflags & PF_SPINNING)) if (abs(mo->standingslope->zdelta) < FRACUNIT/4 && !(mo->player->pflags & PF_SPINNING))
return; // Don't slide on non-steep slopes unless spinning return; // Don't slide on non-steep slopes unless spinning

View file

@ -2060,7 +2060,7 @@ void P_SwitchWeather(INT32 weathernum)
precipmobj = (precipmobj_t *)think; precipmobj = (precipmobj_t *)think;
precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags;
z = M_Random(); z = M_RandomByte();
if (z < 64) if (z < 64)
z = 2; z = 2;
@ -3782,7 +3782,7 @@ DoneSection2:
HU_SetCEchoDuration(5); HU_SetCEchoDuration(5);
HU_DoCEcho(va(M_GetText("%s\\captured the blue flag.\\\\\\\\"), player_names[player-players])); HU_DoCEcho(va(M_GetText("%s\\captured the blue flag.\\\\\\\\"), player_names[player-players]));
if (players[consoleplayer].ctfteam == 1) if (splitscreen || players[consoleplayer].ctfteam == 1)
S_StartSound(NULL, sfx_flgcap); S_StartSound(NULL, sfx_flgcap);
else if (players[consoleplayer].ctfteam == 2) else if (players[consoleplayer].ctfteam == 2)
S_StartSound(NULL, sfx_lose); S_StartSound(NULL, sfx_lose);
@ -3815,7 +3815,7 @@ DoneSection2:
HU_SetCEchoDuration(5); HU_SetCEchoDuration(5);
HU_DoCEcho(va(M_GetText("%s\\captured the red flag.\\\\\\\\"), player_names[player-players])); HU_DoCEcho(va(M_GetText("%s\\captured the red flag.\\\\\\\\"), player_names[player-players]));
if (players[consoleplayer].ctfteam == 2) if (splitscreen || players[consoleplayer].ctfteam == 2)
S_StartSound(NULL, sfx_flgcap); S_StartSound(NULL, sfx_flgcap);
else if (players[consoleplayer].ctfteam == 1) else if (players[consoleplayer].ctfteam == 1)
S_StartSound(NULL, sfx_lose); S_StartSound(NULL, sfx_lose);
@ -4673,8 +4673,10 @@ void P_UpdateSpecials(void)
// POINT LIMIT // POINT LIMIT
P_CheckPointLimit(); P_CheckPointLimit();
#ifdef ESLOPE
// Dynamic slopeness // Dynamic slopeness
P_RunDynamicSlopes(); P_RunDynamicSlopes();
#endif
// ANIMATE TEXTURES // ANIMATE TEXTURES
for (anim = anims; anim < lastanim; anim++) for (anim = anims; anim < lastanim; anim++)

View file

@ -363,7 +363,7 @@ static void P_DoAutobalanceTeams(void)
{ {
if (totalred > totalblue) if (totalred > totalblue)
{ {
i = M_Random() % red; i = M_RandomKey(red);
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
NetPacket.packet.playernum = redarray[i]; NetPacket.packet.playernum = redarray[i];
NetPacket.packet.verification = true; NetPacket.packet.verification = true;
@ -375,7 +375,7 @@ static void P_DoAutobalanceTeams(void)
if (totalblue > totalred) if (totalblue > totalred)
{ {
i = M_Random() % blue; i = M_RandomKey(blue);
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
NetPacket.packet.playernum = bluearray[i]; NetPacket.packet.playernum = bluearray[i];
NetPacket.packet.verification = true; NetPacket.packet.verification = true;

View file

@ -2167,9 +2167,9 @@ static void P_DoBubbleBreath(player_t *player)
if (!(player->mo->eflags & MFE_UNDERWATER) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !(player->pflags & PF_NIGHTSMODE)) || player->spectator) if (!(player->mo->eflags & MFE_UNDERWATER) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !(player->pflags & PF_NIGHTSMODE)) || player->spectator)
return; return;
if (!(P_Random() % 16)) if (P_RandomChance(FRACUNIT/16))
bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_SMALLBUBBLE); bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_SMALLBUBBLE);
else if (!(P_Random() % 96)) else if (P_RandomChance(3*FRACUNIT/256))
bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_MEDIUMBUBBLE); bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_MEDIUMBUBBLE);
if (bubble) if (bubble)
{ {
@ -6203,6 +6203,14 @@ void P_ElementalFireTrail(player_t *player)
{ {
newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
#ifdef ESLOPE
if (player->mo->standingslope)
{
ground = P_GetZAt(player->mo->standingslope, newx, newy);
if (player->mo->eflags & MFE_VERTICALFLIP)
ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale);
}
#endif
flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE); flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE);
P_SetTarget(&flame->target, player->mo); P_SetTarget(&flame->target, player->mo);
flame->angle = travelangle; flame->angle = travelangle;
@ -6652,7 +6660,7 @@ static void P_MovePlayer(player_t *player)
// Little water sound while touching water - just a nicety. // Little water sound while touching water - just a nicety.
if ((player->mo->eflags & MFE_TOUCHWATER) && !(player->mo->eflags & MFE_UNDERWATER) && !player->spectator) if ((player->mo->eflags & MFE_TOUCHWATER) && !(player->mo->eflags & MFE_UNDERWATER) && !player->spectator)
{ {
if (P_Random() & 1 && leveltime % TICRATE == 0) if (P_RandomChance(FRACUNIT/2) && leveltime % TICRATE == 0)
S_StartSound(player->mo, sfx_floush); S_StartSound(player->mo, sfx_floush);
} }
@ -7539,8 +7547,6 @@ boolean P_LookForEnemies(player_t *player)
if (an > ANGLE_90 && an < ANGLE_270) if (an > ANGLE_90 && an < ANGLE_270)
continue; // behind back continue; // behind back
player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y);
if (!P_CheckSight(player->mo, mo)) if (!P_CheckSight(player->mo, mo))
continue; // out of sight continue; // out of sight
@ -7551,6 +7557,7 @@ boolean P_LookForEnemies(player_t *player)
{ {
// Found a target monster // Found a target monster
P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, closestmo)); P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, closestmo));
player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, closestmo->x, closestmo->y);
return true; return true;
} }
@ -7743,8 +7750,25 @@ static void P_DeathThink(player_t *player)
} }
// Return to level music // Return to level music
if (netgame && player->deadtimer == gameovertics && P_IsLocalPlayer(player)) if (player->lives <= 0)
S_ChangeMusic(mapmusname, mapmusflags, true); {
if (netgame)
{
if (player->deadtimer == gameovertics && P_IsLocalPlayer(player))
S_ChangeMusic(mapmusname, mapmusflags, true);
}
else if (multiplayer) // local multiplayer only
{
if (player->deadtimer != gameovertics)
;
// Restore the other player's music once we're dead for long enough
// -- that is, as long as they aren't dead too
else if (player == &players[displayplayer] && players[secondarydisplayplayer].lives > 0)
P_RestoreMusic(&players[secondarydisplayplayer]);
else if (player == &players[secondarydisplayplayer] && players[displayplayer].lives > 0)
P_RestoreMusic(&players[displayplayer]);
}
}
} }
if (!player->mo) if (!player->mo)
@ -8450,7 +8474,7 @@ static boolean P_SpectatorJoinGame(player_t *player)
else if (redscore > bluescore) else if (redscore > bluescore)
changeto = 2; changeto = 2;
else else
changeto = (P_Random() & 1) + 1; changeto = (P_RandomFixed() & 1) + 1;
if (player->mo) if (player->mo)
{ {
@ -8466,9 +8490,9 @@ static boolean P_SpectatorJoinGame(player_t *player)
displayplayer = consoleplayer; displayplayer = consoleplayer;
if (changeto == 1) if (changeto == 1)
CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red Team"), '\x80'); CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80');
else if (changeto == 2) else if (changeto == 2)
CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x84', M_GetText("Blue Team"), '\x80'); CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x84', M_GetText("Blue team"), '\x80');
return true; // no more player->mo, cannot continue. return true; // no more player->mo, cannot continue.
} }
@ -8701,7 +8725,7 @@ void P_PlayerThink(player_t *player)
// Add some extra randomization. // Add some extra randomization.
if (cmd->forwardmove) if (cmd->forwardmove)
P_Random(); P_RandomFixed();
#ifdef PARANOIA #ifdef PARANOIA
if (player->playerstate == PST_REBORN) if (player->playerstate == PST_REBORN)

View file

@ -462,26 +462,64 @@ static void R_AddLine(seg_t *line)
// Closed door. // Closed door.
#ifdef ESLOPE #ifdef ESLOPE
// Just don't bother checking this if one side is sloped. This is probably inefficient, but it's better than if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope)
// random renderer stopping around slopes...
if (!(frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope))
#endif
if (backsector->ceilingheight <= frontsector->floorheight
|| backsector->floorheight >= frontsector->ceilingheight)
{ {
goto clipsolid; fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = P_GetZAt(slope, line->v1->x, line->v1->y); \
end2 = P_GetZAt(slope, line->v2->x, line->v2->y); \
} else \
end1 = end2 = normalheight;
SLOPEPARAMS(frontsector->f_slope, frontf1, frontf2, frontsector->floorheight)
SLOPEPARAMS(frontsector->c_slope, frontc1, frontc2, frontsector->ceilingheight)
SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector->floorheight)
SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight)
#undef SLOPEPARAMS
if ((backc1 <= frontf1 && backc2 <= frontf2)
|| (backf1 >= frontc1 && backf2 >= frontc2))
{
goto clipsolid;
}
// Check for automap fix. Store in doorclosed for r_segs.c
doorclosed = (backc1 <= backf1 && backc2 <= backf2
&& ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture)
&& ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture)
&& (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum));
if (doorclosed)
goto clipsolid;
// Window.
if (backc1 != frontc1 || backc2 != frontc2
|| backf1 != frontf1 || backf2 != frontf2)
{
goto clippass;
}
} }
else
// Check for automap fix. Store in doorclosed for r_segs.c #endif
doorclosed = R_DoorClosed();
if (doorclosed)
goto clipsolid;
// Window.
if (backsector->ceilingheight != frontsector->ceilingheight
|| backsector->floorheight != frontsector->floorheight)
{ {
goto clippass; if (backsector->ceilingheight <= frontsector->floorheight
|| backsector->floorheight >= frontsector->ceilingheight)
{
goto clipsolid;
}
// Check for automap fix. Store in doorclosed for r_segs.c
doorclosed = R_DoorClosed();
if (doorclosed)
goto clipsolid;
// Window.
if (backsector->ceilingheight != frontsector->ceilingheight
|| backsector->floorheight != frontsector->floorheight)
{
goto clippass;
}
} }
// Reject empty lines used for triggers and special events. // Reject empty lines used for triggers and special events.
@ -966,7 +1004,7 @@ static void R_Subsector(size_t num)
|| (viewz > heightcheck && (rover->flags & FF_BOTHPLANES)))) || (viewz > heightcheck && (rover->flags & FF_BOTHPLANES))))
{ {
light = R_GetPlaneLight(frontsector, planecenterz, light = R_GetPlaneLight(frontsector, planecenterz,
viewz < *rover->bottomheight); viewz < heightcheck);
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs,
@ -984,12 +1022,7 @@ static void R_Subsector(size_t num)
frontsector->hasslope = true; frontsector->hasslope = true;
#endif #endif
ffloor[numffloors].height = ffloor[numffloors].height = heightcheck;
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) :
#endif
*rover->bottomheight;
ffloor[numffloors].ffloor = rover; ffloor[numffloors].ffloor = rover;
numffloors++; numffloors++;
} }
@ -1014,7 +1047,7 @@ static void R_Subsector(size_t num)
&& ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES)) && ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES))
|| (viewz < heightcheck && (rover->flags & FF_BOTHPLANES)))) || (viewz < heightcheck && (rover->flags & FF_BOTHPLANES))))
{ {
light = R_GetPlaneLight(frontsector, planecenterz, viewz < *rover->topheight); light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck);
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle,
@ -1032,12 +1065,7 @@ static void R_Subsector(size_t num)
frontsector->hasslope = true; frontsector->hasslope = true;
#endif #endif
ffloor[numffloors].height = ffloor[numffloors].height = heightcheck;
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) :
#endif
*rover->topheight;
ffloor[numffloors].ffloor = rover; ffloor[numffloors].ffloor = rover;
numffloors++; numffloors++;
} }

View file

@ -517,7 +517,9 @@ static void R_InitTextureMapping(void)
focallength = FixedDiv(centerxfrac, focallength = FixedDiv(centerxfrac,
FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2)); FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2));
#ifdef ESLOPE
focallengthf = FIXED_TO_FLOAT(focallength); focallengthf = FIXED_TO_FLOAT(focallength);
#endif
for (i = 0; i < FINEANGLES/2; i++) for (i = 0; i < FINEANGLES/2; i++)
{ {
@ -971,14 +973,42 @@ void R_SkyboxFrame(player_t *player)
{ {
if (skyboxmo[1]) if (skyboxmo[1])
{ {
fixed_t x = 0, y = 0;
if (mh->skybox_scalex > 0) if (mh->skybox_scalex > 0)
viewx += (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex; x = (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex;
else if (mh->skybox_scalex < 0) else if (mh->skybox_scalex < 0)
viewx += (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex; x = (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex;
if (mh->skybox_scaley > 0) if (mh->skybox_scaley > 0)
viewy += (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley; y = (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley;
else if (mh->skybox_scaley < 0) else if (mh->skybox_scaley < 0)
viewy += (player->mo->y - skyboxmo[1]->y) * -mh->skybox_scaley; y = (player->mo->y - skyboxmo[1]->y) * -mh->skybox_scaley;
if (viewmobj->angle == 0)
{
viewx += x;
viewy += y;
}
else if (viewmobj->angle == ANGLE_90)
{
viewx -= y;
viewy += x;
}
else if (viewmobj->angle == ANGLE_180)
{
viewx -= x;
viewy -= y;
}
else if (viewmobj->angle == ANGLE_270)
{
viewx += y;
viewy -= x;
}
else
{
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
}
} }
if (mh->skybox_scalez > 0) if (mh->skybox_scalez > 0)
viewz += player->viewz / mh->skybox_scalez; viewz += player->viewz / mh->skybox_scalez;
@ -1382,6 +1412,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_allowmlook); CV_RegisterVar(&cv_allowmlook);
CV_RegisterVar(&cv_homremoval); CV_RegisterVar(&cv_homremoval);
CV_RegisterVar(&cv_flipcam); CV_RegisterVar(&cv_flipcam);
CV_RegisterVar(&cv_flipcam2);
// Enough for dedicated server // Enough for dedicated server
if (dedicated) if (dedicated)
@ -1432,10 +1463,12 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_voodoocompatibility); CV_RegisterVar(&cv_voodoocompatibility);
CV_RegisterVar(&cv_grfogcolor); CV_RegisterVar(&cv_grfogcolor);
CV_RegisterVar(&cv_grsoftwarefog); CV_RegisterVar(&cv_grsoftwarefog);
#ifdef ALAM_LIGHTING
CV_RegisterVar(&cv_grstaticlighting); CV_RegisterVar(&cv_grstaticlighting);
CV_RegisterVar(&cv_grdynamiclighting); CV_RegisterVar(&cv_grdynamiclighting);
CV_RegisterVar(&cv_grcoronas); CV_RegisterVar(&cv_grcoronas);
CV_RegisterVar(&cv_grcoronasize); CV_RegisterVar(&cv_grcoronasize);
#endif
CV_RegisterVar(&cv_grmd2); CV_RegisterVar(&cv_grmd2);
#endif #endif

View file

@ -198,7 +198,7 @@ static void R_DrawWallSplats(void)
// draw the columns // draw the columns
for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep) for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep)
{ {
pindex = spryscale>>LIGHTSCALESHIFT; pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
if (pindex >= MAXLIGHTSCALE) if (pindex >= MAXLIGHTSCALE)
pindex = MAXLIGHTSCALE - 1; pindex = MAXLIGHTSCALE - 1;
dc_colormap = walllights[pindex]; dc_colormap = walllights[pindex];
@ -288,6 +288,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
line_t *ldef; line_t *ldef;
sector_t *front, *back; sector_t *front, *back;
INT32 times, repeats; INT32 times, repeats;
#ifdef ESLOPE
INT32 range;
#endif
// Calculate light table. // Calculate light table.
// Use different light tables // Use different light tables
@ -334,6 +337,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
colfunc = fuzzcolfunc; colfunc = fuzzcolfunc;
} }
#ifdef ESLOPE
range = max(ds->x2-ds->x1, 1);
#endif
rw_scalestep = ds->scalestep; rw_scalestep = ds->scalestep;
spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
@ -360,10 +366,30 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
for (i = 0; i < dc_numlights; i++) for (i = 0; i < dc_numlights; i++)
{ {
#ifdef ESLOPE
fixed_t leftheight, rightheight;
#endif
light = &frontsector->lightlist[i]; light = &frontsector->lightlist[i];
rlight = &dc_lightlist[i]; rlight = &dc_lightlist[i];
#ifdef ESLOPE
if (light->slope) {
leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y);
rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y);
} else
leftheight = rightheight = light->height;
leftheight -= viewz;
rightheight -= viewz;
rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1);
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2);
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
//if (x1 > ds->x1)
//rlight->height -= (x1 - ds->x1)*rlight->heightstep;
#else
rlight->height = (centeryfrac) - FixedMul((light->height - viewz), spryscale); rlight->height = (centeryfrac) - FixedMul((light->height - viewz), spryscale);
rlight->heightstep = -FixedMul(rw_scalestep, (light->height - viewz)); rlight->heightstep = -FixedMul(rw_scalestep, (light->height - viewz));
#endif
rlight->lightlevel = *light->lightlevel; rlight->lightlevel = *light->lightlevel;
rlight->extra_colormap = light->extra_colormap; rlight->extra_colormap = light->extra_colormap;
rlight->flags = light->flags; rlight->flags = light->flags;
@ -673,7 +699,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
fixed_t offsetvalue = 0; fixed_t offsetvalue = 0;
lightlist_t *light; lightlist_t *light;
r_lightlist_t *rlight; r_lightlist_t *rlight;
#ifdef ESLOPE
INT32 range;
#endif
#ifndef ESLOPE
fixed_t lheight; fixed_t lheight;
#endif
line_t *newline = NULL; line_t *newline = NULL;
#ifdef ESLOPE #ifdef ESLOPE
// Render FOF sides kinda like normal sides, with the frac and step and everything // Render FOF sides kinda like normal sides, with the frac and step and everything
@ -735,6 +766,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
else if (pfloor->flags & FF_FOG) else if (pfloor->flags & FF_FOG)
colfunc = R_DrawFogColumn_8; colfunc = R_DrawFogColumn_8;
#ifdef ESLOPE
range = max(ds->x2-ds->x1, 1);
#endif
//SoM: Moved these up here so they are available for my lightlist calculations //SoM: Moved these up here so they are available for my lightlist calculations
rw_scalestep = ds->scalestep; rw_scalestep = ds->scalestep;
spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
@ -751,9 +785,49 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
for (i = p = 0; i < dc_numlights; i++) for (i = p = 0; i < dc_numlights; i++)
{ {
#ifdef ESLOPE
fixed_t leftheight, rightheight;
fixed_t pfloorleft, pfloorright;
#endif
light = &frontsector->lightlist[i]; light = &frontsector->lightlist[i];
rlight = &dc_lightlist[p]; rlight = &dc_lightlist[p];
#ifdef ESLOPE
if (light->slope) {
leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y);
rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y);
} else
leftheight = rightheight = light->height;
if (*pfloor->b_slope) {
pfloorleft = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y);
pfloorright = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y);
} else
pfloorleft = pfloorright = *pfloor->bottomheight;
if (leftheight < pfloorleft && rightheight < pfloorright)
continue;
if (*pfloor->t_slope) {
pfloorleft = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y);
pfloorright = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y);
} else
pfloorleft = pfloorright = *pfloor->topheight;
if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights)
{
lightlist_t *nextlight = &frontsector->lightlist[i+1];
if (nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height > pfloorleft
&& nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height > pfloorright)
continue;
}
leftheight -= viewz;
rightheight -= viewz;
rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1);
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2);
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
rlight->height -= rlight->heightstep;
#else
if (light->height < *pfloor->bottomheight) if (light->height < *pfloor->bottomheight)
continue; continue;
@ -763,13 +837,29 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
lheight = light->height;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : light->height; lheight = light->height;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : light->height;
rlight->heightstep = -FixedMul (rw_scalestep, (lheight - viewz)); rlight->heightstep = -FixedMul (rw_scalestep, (lheight - viewz));
rlight->height = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->heightstep; rlight->height = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->heightstep;
#endif
rlight->flags = light->flags; rlight->flags = light->flags;
if (light->flags & FF_CUTLEVEL) if (light->flags & FF_CUTLEVEL)
{ {
#ifdef ESLOPE
if (*light->caster->b_slope) {
leftheight = P_GetZAt(*light->caster->b_slope, ds->leftpos.x, ds->leftpos.y);
rightheight = P_GetZAt(*light->caster->b_slope, ds->rightpos.x, ds->rightpos.y);
} else
leftheight = rightheight = *light->caster->bottomheight;
leftheight -= viewz;
rightheight -= viewz;
rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1);
rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2);
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
rlight->botheight -= rlight->botheightstep;
#else
lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight;
rlight->botheightstep = -FixedMul (rw_scalestep, (lheight - viewz)); rlight->botheightstep = -FixedMul (rw_scalestep, (lheight - viewz));
rlight->botheight = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->botheightstep; rlight->botheight = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->botheightstep;
#endif
} }
rlight->lightlevel = *light->lightlevel; rlight->lightlevel = *light->lightlevel;
@ -873,8 +963,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
top_step = centeryfrac - FixedMul(right_top, ds->scale2); top_step = centeryfrac - FixedMul(right_top, ds->scale2);
bottom_step = centeryfrac - FixedMul(right_bottom, ds->scale2); bottom_step = centeryfrac - FixedMul(right_bottom, ds->scale2);
top_step = (top_step-top_frac)/(ds->x2-ds->x1+1); top_step = (top_step-top_frac)/(range);
bottom_step = (bottom_step-bottom_frac)/(ds->x2-ds->x1+1); bottom_step = (bottom_step-bottom_frac)/(range);
top_frac += top_step * (x1 - ds->x1); top_frac += top_step * (x1 - ds->x1);
bottom_frac += bottom_step * (x1 - ds->x1); bottom_frac += bottom_step * (x1 - ds->x1);
@ -942,7 +1032,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
else else
xwalllights = scalelight[lightnum]; xwalllights = scalelight[lightnum];
pindex = spryscale>>LIGHTSCALESHIFT; pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
if (pindex >= MAXLIGHTSCALE) if (pindex >= MAXLIGHTSCALE)
pindex = MAXLIGHTSCALE-1; pindex = MAXLIGHTSCALE-1;
@ -963,6 +1053,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
} }
} }
solid = 0; // don't carry over solid-cutting flag from the previous light
// Check if the current light can cut the current 3D floor. // Check if the current light can cut the current 3D floor.
if (rlight->flags & FF_CUTSOLIDS && !(pfloor->flags & FF_EXTRA)) if (rlight->flags & FF_CUTSOLIDS && !(pfloor->flags & FF_EXTRA))
solid = 1; solid = 1;
@ -1030,7 +1122,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
} }
// calculate lighting // calculate lighting
pindex = spryscale>>LIGHTSCALESHIFT; pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
if (pindex >= MAXLIGHTSCALE) if (pindex >= MAXLIGHTSCALE)
pindex = MAXLIGHTSCALE - 1; pindex = MAXLIGHTSCALE - 1;
@ -1110,7 +1202,9 @@ static void R_RenderSegLoop (void)
INT32 mid; INT32 mid;
fixed_t texturecolumn = 0; fixed_t texturecolumn = 0;
#ifdef ESLOPE
fixed_t oldtexturecolumn = -1; fixed_t oldtexturecolumn = -1;
#endif
INT32 top; INT32 top;
INT32 bottom; INT32 bottom;
INT32 i; INT32 i;
@ -1421,7 +1515,7 @@ static void R_RenderSegLoop (void)
for (i = 0; i < dc_numlights; i++) for (i = 0; i < dc_numlights; i++)
{ {
dc_lightlist[i].height += dc_lightlist[i].heightstep; dc_lightlist[i].height += dc_lightlist[i].heightstep;
if (dc_lightlist[i].flags & FF_SOLID) if (dc_lightlist[i].flags & FF_CUTSOLIDS)
dc_lightlist[i].botheight += dc_lightlist[i].botheightstep; dc_lightlist[i].botheight += dc_lightlist[i].botheightstep;
} }
} }
@ -1466,22 +1560,26 @@ void R_StoreWallRange(INT32 start, INT32 stop)
fixed_t hyp; fixed_t hyp;
fixed_t sineval; fixed_t sineval;
angle_t distangle, offsetangle; angle_t distangle, offsetangle;
//fixed_t vtop; #ifndef ESLOPE
fixed_t vtop;
#endif
INT32 lightnum; INT32 lightnum;
INT32 i, p; INT32 i, p;
lightlist_t *light; lightlist_t *light;
r_lightlist_t *rlight; r_lightlist_t *rlight;
INT32 range;
#ifdef ESLOPE #ifdef ESLOPE
vertex_t segleft, segright; vertex_t segleft, segright;
fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide; fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide;
#endif #endif
static size_t maxdrawsegs = 0; static size_t maxdrawsegs = 0;
#ifdef ESLOPE
maskedtextureheight = NULL; maskedtextureheight = NULL;
//initialize segleft and segright //initialize segleft and segright
memset(&segleft, 0x00, sizeof(segleft)); memset(&segleft, 0x00, sizeof(segleft));
memset(&segright, 0x00, sizeof(segright)); memset(&segright, 0x00, sizeof(segright));
#endif
if (ds_p == drawsegs+maxdrawsegs) if (ds_p == drawsegs+maxdrawsegs)
{ {
@ -1554,7 +1652,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (stop > start) if (stop > start)
{ {
ds_p->scale2 = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[stop]); ds_p->scale2 = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[stop]);
ds_p->scalestep = rw_scalestep = (ds_p->scale2 - rw_scale) / (stop-start); range = stop-start;
} }
else else
{ {
@ -1575,8 +1673,11 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} }
#endif #endif
ds_p->scale2 = ds_p->scale1; ds_p->scale2 = ds_p->scale1;
range = 1;
} }
ds_p->scalestep = rw_scalestep = (ds_p->scale2 - rw_scale) / (range);
// calculate texture boundaries // calculate texture boundaries
// and decide if floor / ceiling marks are needed // and decide if floor / ceiling marks are needed
#ifdef ESLOPE #ifdef ESLOPE
@ -1799,7 +1900,10 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{ {
ds_p->silhouette = SIL_BOTTOM; ds_p->silhouette = SIL_BOTTOM;
#ifdef ESLOPE #ifdef ESLOPE
ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz)
ds_p->bsilheight = INT32_MAX;
else
ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight);
#else #else
ds_p->bsilheight = frontsector->floorheight; ds_p->bsilheight = frontsector->floorheight;
#endif #endif
@ -1823,7 +1927,10 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{ {
ds_p->silhouette |= SIL_TOP; ds_p->silhouette |= SIL_TOP;
#ifdef ESLOPE #ifdef ESLOPE
ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz)
ds_p->tsilheight = INT32_MIN;
else
ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight);
#else #else
ds_p->tsilheight = frontsector->ceilingheight; ds_p->tsilheight = frontsector->ceilingheight;
#endif #endif
@ -1861,21 +1968,25 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ds_p->silhouette |= SIL_TOP; ds_p->silhouette |= SIL_TOP;
} }
#ifdef ESLOPE
// This causes issues with slopes.
if (!(frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope))
#endif
//SoM: 3/25/2000: This code fixes an automap bug that didn't check //SoM: 3/25/2000: This code fixes an automap bug that didn't check
// frontsector->ceiling and backsector->floor to see if a door was closed. // frontsector->ceiling and backsector->floor to see if a door was closed.
// Without the following code, sprites get displayed behind closed doors. // Without the following code, sprites get displayed behind closed doors.
{ {
#ifdef ESLOPE
if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope))
#else
if (doorclosed || backsector->ceilingheight <= frontsector->floorheight) if (doorclosed || backsector->ceilingheight <= frontsector->floorheight)
#endif
{ {
ds_p->sprbottomclip = negonearray; ds_p->sprbottomclip = negonearray;
ds_p->bsilheight = INT32_MAX; ds_p->bsilheight = INT32_MAX;
ds_p->silhouette |= SIL_BOTTOM; ds_p->silhouette |= SIL_BOTTOM;
} }
#ifdef ESLOPE
if (doorclosed || (worldlow >= worldtop && worldlowslope >= worldtopslope))
#else
if (doorclosed || backsector->floorheight >= frontsector->ceilingheight) if (doorclosed || backsector->floorheight >= frontsector->ceilingheight)
#endif
{ // killough 1/17/98, 2/8/98 { // killough 1/17/98, 2/8/98
ds_p->sprtopclip = screenheightarray; ds_p->sprtopclip = screenheightarray;
ds_p->tsilheight = INT32_MIN; ds_p->tsilheight = INT32_MIN;
@ -1935,8 +2046,13 @@ void R_StoreWallRange(INT32 start, INT32 stop)
markceiling = false; markceiling = false;
} }
#ifdef ESLOPE
if ((worldhigh <= worldbottom && worldhighslope <= worldbottomslope)
|| (worldlow >= worldtop && worldlowslope >= worldtopslope))
#else
if (backsector->ceilingheight <= frontsector->floorheight || if (backsector->ceilingheight <= frontsector->floorheight ||
backsector->floorheight >= frontsector->ceilingheight) backsector->floorheight >= frontsector->ceilingheight)
#endif
{ {
// closed door // closed door
markceiling = markfloor = true; markceiling = markfloor = true;
@ -2119,8 +2235,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
for (r2 = frontsector->ffloors; r2; r2 = r2->next) for (r2 = frontsector->ffloors; r2; r2 = r2->next)
{ {
if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES) if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES))
|| *r2->topheight < lowcut || *r2->bottomheight > highcut) ///TODO: make these account for slopes -Red
continue; continue;
if (r2->norender == leveltime) if (r2->norender == leveltime)
@ -2152,9 +2267,13 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} else } else
low2 = lowslope2 = *r2->bottomheight; low2 = lowslope2 = *r2->bottomheight;
if ((high1 > high2 && highslope1 > highslope2) || (low1 < low2 && lowslope1 < lowslope2)) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope))
continue;
if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2))
continue; continue;
#else #else
if (*r2->topheight < lowcut || *r2->bottomheight > highcut)
continue;
if (*rover->topheight > *r2->topheight || *rover->bottomheight < *r2->bottomheight) if (*rover->topheight > *r2->topheight || *rover->bottomheight < *r2->bottomheight)
continue; continue;
#endif #endif
@ -2199,8 +2318,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
for (r2 = backsector->ffloors; r2; r2 = r2->next) for (r2 = backsector->ffloors; r2; r2 = r2->next)
{ {
if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES) if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES))
|| *r2->topheight < lowcut || *r2->bottomheight > highcut) ///TODO: make these account for slopes -Red
continue; continue;
if (r2->norender == leveltime) if (r2->norender == leveltime)
@ -2232,9 +2350,13 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} else } else
low2 = lowslope2 = *r2->bottomheight; low2 = lowslope2 = *r2->bottomheight;
if ((high1 > high2 && highslope1 > highslope2) || (low1 < low2 && lowslope1 < lowslope2)) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope))
continue;
if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2))
continue; continue;
#else #else
if (*r2->topheight < lowcut || *r2->bottomheight > highcut)
continue;
if (*rover->topheight > *r2->topheight || *rover->bottomheight < *r2->bottomheight) if (*rover->topheight > *r2->topheight || *rover->bottomheight < *r2->bottomheight)
continue; continue;
#endif #endif
@ -2436,11 +2558,11 @@ void R_StoreWallRange(INT32 start, INT32 stop)
#ifdef ESLOPE #ifdef ESLOPE
if (frontsector->c_slope) { if (frontsector->c_slope) {
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2);
topstep = (topfracend-topfrac)/(stop-start+1); topstep = (topfracend-topfrac)/(range);
} }
if (frontsector->f_slope) { if (frontsector->f_slope) {
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2);
bottomstep = (bottomfracend-bottomfrac)/(stop-start+1); bottomstep = (bottomfracend-bottomfrac)/(range);
} }
#endif #endif
@ -2501,14 +2623,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
#ifdef ESLOPE #ifdef ESLOPE
rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale);
rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2);
rlight->heightstep = (rlight->heightstep-rlight->height)/(stop-start+1); rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
#else #else
rlight->height = (centeryfrac>>4) - FixedMul((light->height - viewz) >> 4, rw_scale); rlight->height = (centeryfrac>>4) - FixedMul((light->height - viewz) >> 4, rw_scale);
rlight->heightstep = -FixedMul (rw_scalestep, (light->height - viewz) >> 4); rlight->heightstep = -FixedMul (rw_scalestep, (light->height - viewz) >> 4);
#endif #endif
rlight->flags = light->flags; rlight->flags = light->flags;
if (light->caster && light->caster->flags & FF_SOLID) if (light->caster && light->caster->flags & FF_CUTSOLIDS)
{ {
#ifdef ESLOPE #ifdef ESLOPE
if (*light->caster->b_slope) { if (*light->caster->b_slope) {
@ -2528,7 +2650,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rlight->botheight = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->botheight = (centeryfrac>>4) - FixedMul(leftheight, rw_scale);
rlight->botheightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); rlight->botheightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2);
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(stop-start+1); rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
#else #else
rlight->botheight = (centeryfrac >> 4) - FixedMul((*light->caster->bottomheight - viewz) >> 4, rw_scale); rlight->botheight = (centeryfrac >> 4) - FixedMul((*light->caster->bottomheight - viewz) >> 4, rw_scale);
@ -2557,7 +2679,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
#ifdef ESLOPE #ifdef ESLOPE
ffloor[i].f_pos_slope >>= 4; ffloor[i].f_pos_slope >>= 4;
ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale);
ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(stop-start+1); ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(range);
#else #else
ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos); ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos);
ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale);
@ -2574,11 +2696,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
worldlowslope >>= 4; worldlowslope >>= 4;
#endif #endif
if (worldhigh < worldtop if (toptexture)
#ifdef ESLOPE
|| worldhighslope <= worldtopslope
#endif
)
{ {
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
pixhighstep = -FixedMul (rw_scalestep,worldhigh); pixhighstep = -FixedMul (rw_scalestep,worldhigh);
@ -2586,23 +2704,19 @@ void R_StoreWallRange(INT32 start, INT32 stop)
#ifdef ESLOPE #ifdef ESLOPE
if (backsector->c_slope) { if (backsector->c_slope) {
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2); fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2);
pixhighstep = (topfracend-pixhigh)/(stop-start+1); pixhighstep = (topfracend-pixhigh)/(range);
} }
#endif #endif
} }
if (worldlow > worldbottom if (bottomtexture)
#ifdef ESLOPE
|| worldlowslope >= worldbottomslope
#endif
)
{ {
pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
pixlowstep = -FixedMul (rw_scalestep,worldlow); pixlowstep = -FixedMul (rw_scalestep,worldlow);
#ifdef ESLOPE #ifdef ESLOPE
if (backsector->f_slope) { if (backsector->f_slope) {
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2);
pixlowstep = (bottomfracend-pixlow)/(stop-start+1); pixlowstep = (bottomfracend-pixlow)/(range);
} }
#endif #endif
} }
@ -2610,7 +2724,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{ {
ffloor_t * rover; ffloor_t * rover;
#ifdef ESLOPE #ifdef ESLOPE
fixed_t rovertest; fixed_t roverleft, roverright;
fixed_t planevistest; fixed_t planevistest;
#endif #endif
i = 0; i = 0;
@ -2629,44 +2743,46 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (*rover->b_slope || *rover->t_slope) if (*rover->b_slope || *rover->t_slope)
backsector->hasslope = true; backsector->hasslope = true;
rovertest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, backsector->soundorg.x, backsector->soundorg.y) : *rover->bottomheight) - viewz; roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz;
roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz;
planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight);
if (rovertest>>4 <= worldhigh && if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) &&
rovertest>>4 >= worldlow && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) &&
((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) ||
(viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) (viewz > planevistest && (rover->flags & FF_BOTHPLANES))))
{ {
//ffloor[i].slope = *rover->b_slope; //ffloor[i].slope = *rover->b_slope;
ffloor[i].b_pos = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; ffloor[i].b_pos = roverleft;
ffloor[i].b_pos_slope = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; ffloor[i].b_pos_slope = roverright;
ffloor[i].b_pos >>= 4; ffloor[i].b_pos >>= 4;
ffloor[i].b_pos_slope >>= 4; ffloor[i].b_pos_slope >>= 4;
ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale);
ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2);
ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range);
i++; i++;
} }
if (i >= MAXFFLOORS) if (i >= MAXFFLOORS)
break; break;
rovertest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, backsector->soundorg.x, backsector->soundorg.y) : *rover->topheight) - viewz; roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz;
roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz;
planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight);
if (rovertest>>4 <= worldhigh && if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) &&
rovertest>>4 >= worldlow && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) &&
((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) ||
(viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) (viewz < planevistest && (rover->flags & FF_BOTHPLANES))))
{ {
//ffloor[i].slope = *rover->t_slope; //ffloor[i].slope = *rover->t_slope;
ffloor[i].b_pos = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; ffloor[i].b_pos = roverleft;
ffloor[i].b_pos_slope = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; ffloor[i].b_pos_slope = roverright;
ffloor[i].b_pos >>= 4; ffloor[i].b_pos >>= 4;
ffloor[i].b_pos_slope >>= 4; ffloor[i].b_pos_slope >>= 4;
ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale);
ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2);
ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range);
i++; i++;
} }
#else #else
@ -2714,44 +2830,46 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (*rover->b_slope || *rover->t_slope) if (*rover->b_slope || *rover->t_slope)
frontsector->hasslope = true; frontsector->hasslope = true;
rovertest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) : *rover->bottomheight) - viewz; roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz;
roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz;
planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight);
if (rovertest>>4 <= worldtop && if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) &&
rovertest>>4 >= worldbottom && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) &&
((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) ||
(viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) (viewz > planevistest && (rover->flags & FF_BOTHPLANES))))
{ {
//ffloor[i].slope = *rover->b_slope; //ffloor[i].slope = *rover->b_slope;
ffloor[i].b_pos = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; ffloor[i].b_pos = roverleft;
ffloor[i].b_pos_slope = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; ffloor[i].b_pos_slope = roverright;
ffloor[i].b_pos >>= 4; ffloor[i].b_pos >>= 4;
ffloor[i].b_pos_slope >>= 4; ffloor[i].b_pos_slope >>= 4;
ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale);
ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2);
ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range);
i++; i++;
} }
if (i >= MAXFFLOORS) if (i >= MAXFFLOORS)
break; break;
rovertest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) : *rover->topheight) - viewz; roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz;
roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz;
planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight);
if (rovertest>>4 <= worldtop && if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) &&
rovertest>>4 >= worldbottom && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) &&
((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) ||
(viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) (viewz < planevistest && (rover->flags & FF_BOTHPLANES))))
{ {
//ffloor[i].slope = *rover->t_slope; //ffloor[i].slope = *rover->t_slope;
ffloor[i].b_pos = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; ffloor[i].b_pos = roverleft;
ffloor[i].b_pos_slope = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; ffloor[i].b_pos_slope = roverright;
ffloor[i].b_pos >>= 4; ffloor[i].b_pos >>= 4;
ffloor[i].b_pos_slope >>= 4; ffloor[i].b_pos_slope >>= 4;
ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale);
ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2);
ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range);
i++; i++;
} }
#else #else

View file

@ -968,7 +968,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->scale))>>FRACBITS); cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->scale))>>FRACBITS);
if (cutfrac < 0) if (cutfrac < 0)
continue; continue;
if (cutfrac > vid.height) if (cutfrac > viewheight)
return; return;
// Found a split! Make a new sprite, copy the old sprite to it, and // Found a split! Make a new sprite, copy the old sprite to it, and
@ -1017,7 +1017,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW)
&& (!newsprite->extra_colormap || !newsprite->extra_colormap->fog))) && (!newsprite->extra_colormap || !newsprite->extra_colormap->fog)))
{ {
lindex = sprite->xscale>>(LIGHTSCALESHIFT); lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
if (lindex >= MAXLIGHTSCALE) if (lindex >= MAXLIGHTSCALE)
lindex = MAXLIGHTSCALE-1; lindex = MAXLIGHTSCALE-1;
@ -1338,7 +1338,7 @@ static void R_ProjectSprite(mobj_t *thing)
else else
{ {
// diminished light // diminished light
lindex = xscale>>(LIGHTSCALESHIFT); lindex = FixedMul(xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
if (lindex >= MAXLIGHTSCALE) if (lindex >= MAXLIGHTSCALE)
lindex = MAXLIGHTSCALE-1; lindex = MAXLIGHTSCALE-1;

View file

@ -1310,8 +1310,7 @@ void S_SetDigMusicVolume(INT32 volume)
#ifdef DJGPPDOS #ifdef DJGPPDOS
I_SetDigMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this. I_SetDigMusicVolume(31); // Trick for buggy dos drivers. Win32 doesn't need this.
#endif #endif
if (!nodigimusic) I_SetDigMusicVolume(volume&31);
I_SetDigMusicVolume(volume&31);
} }
void S_SetMIDIMusicVolume(INT32 volume) void S_SetMIDIMusicVolume(INT32 volume)

View file

@ -529,14 +529,8 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
#endif #endif
if (lumpnum == LUMPERROR) if (lumpnum == LUMPERROR)
{ return false;
lumpnum = W_CheckNumForName(va("D_%s",musicname)); midimode = false;
if (lumpnum == LUMPERROR)
return false;
midimode = true;
}
else
midimode = false;
data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC); data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC);
len = W_LumpLength(lumpnum); len = W_LumpLength(lumpnum);
@ -686,10 +680,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return true; return true;
} }
if (midimode) Mix_VolumeMusic((UINT32)music_volume*128/31);
Mix_VolumeMusic((UINT32)midi_volume*128/31);
else
Mix_VolumeMusic((UINT32)music_volume*128/31);
if (loop_point != 0.0f) if (loop_point != 0.0f)
Mix_HookMusicFinished(music_loop); Mix_HookMusicFinished(music_loop);
@ -792,10 +783,15 @@ void I_ShutdownMIDIMusic(void)
void I_SetMIDIMusicVolume(UINT8 volume) void I_SetMIDIMusicVolume(UINT8 volume)
{ {
midi_volume = volume; // HACK: Until we stop using native MIDI,
// disable volume changes
(void)volume;
midi_volume = 31;
//midi_volume = volume;
if (!midimode || !music) if (!midimode || !music)
return; return;
Mix_VolumeMusic((UINT32)volume*128/31); Mix_VolumeMusic((UINT32)midi_volume*128/31);
} }
INT32 I_RegisterSong(void *data, size_t len) INT32 I_RegisterSong(void *data, size_t len)
@ -820,7 +816,8 @@ boolean I_PlaySong(INT32 handle, boolean looping)
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return false; return false;
} }
Mix_VolumeMusic((UINT32)music_volume*128/31);
Mix_VolumeMusic((UINT32)midi_volume*128/31);
return true; return true;
} }

View file

@ -592,9 +592,13 @@ static void ST_drawDebugInfo(void)
if (cv_debug & DBG_RANDOMIZER) // randomizer testing if (cv_debug & DBG_RANDOMIZER) // randomizer testing
{ {
fixed_t peekres = P_RandomPeek();
peekres *= 10000; // Change from fixed point
peekres >>= FRACBITS; // to displayable decimal
V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Init: %08x", P_GetInitSeed())); V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Init: %08x", P_GetInitSeed()));
V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Seed: %08x", P_GetRandSeed())); V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Seed: %08x", P_GetRandSeed()));
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("== : %8d", P_RandomPeek())); V_DrawRightAlignedString(320, height, V_MONOSPACE, va("== : .%04d", peekres));
height -= 32; height -= 32;
} }
@ -1889,7 +1893,7 @@ static void ST_overlayDrawer(void)
ST_drawDebugInfo(); ST_drawDebugInfo();
} }
void ST_Drawer(boolean refresh) void ST_Drawer(void)
{ {
#ifdef SEENAMES #ifdef SEENAMES
if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo) if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo)
@ -1906,8 +1910,11 @@ void ST_Drawer(boolean refresh)
} }
#endif #endif
// Doom's status bar only updated if necessary.
// However, ours updates every frame regardless, so the "refresh" param was removed
//(void)refresh;
// force a set of the palette by using doPaletteStuff() // force a set of the palette by using doPaletteStuff()
(void)refresh; //?
if (vid.recalc) if (vid.recalc)
st_palette = -1; st_palette = -1;

View file

@ -27,7 +27,7 @@
void ST_Ticker(void); void ST_Ticker(void);
// Called by main loop. // Called by main loop.
void ST_Drawer(boolean refresh); void ST_Drawer(void);
// Called when the console player is spawned on each level. // Called when the console player is spawned on each level.
void ST_Start(void); void ST_Start(void);

View file

@ -71,10 +71,12 @@ consvar_t cv_grgammagreen = {"gr_gammagreen", "127", CV_SAVE|CV_CALL, grgamma_co
CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL}; CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons_t, consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons_t,
CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL}; CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL};
#ifdef ALAM_LIGHTING
consvar_t cv_grdynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grdynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE| CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE| CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif
static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}}; static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}};
// console variables in development // console variables in development
@ -1989,7 +1991,7 @@ Unoptimized version
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
if (M_Random() < 32) if (M_RandomChance(FRACUNIT/8)) // 12.5%
heatshifter[y] = true; heatshifter[y] = true;
} }