Get up to p_user

This commit is contained in:
Sally Coolatta 2020-08-14 23:23:14 -04:00
parent 5a98c00405
commit 9b9ab8a2d5
13 changed files with 149 additions and 497 deletions

View file

@ -696,18 +696,18 @@ extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative
extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
#define WAYPOINTSEQUENCESIZE 256
#define NUMWAYPOINTSEQUENCES 256
extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
#define TUBEWAYPOINTSEQUENCESIZE 256
#define NUMTUBEWAYPOINTSEQUENCES 256
extern mobj_t *tubewaypoints[NUMTUBEWAYPOINTSEQUENCES][TUBEWAYPOINTSEQUENCESIZE];
extern UINT16 numtubewaypoints[NUMTUBEWAYPOINTSEQUENCES];
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint);
mobj_t *P_GetFirstWaypoint(UINT8 sequence);
mobj_t *P_GetLastWaypoint(UINT8 sequence);
mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap);
mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap);
mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo);
boolean P_IsDegeneratedWaypointSequence(UINT8 sequence);
void P_AddTubeWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint);
mobj_t *P_GetFirstTubeWaypoint(UINT8 sequence);
mobj_t *P_GetLastTubeWaypoint(UINT8 sequence);
mobj_t *P_GetPreviousTubeWaypoint(mobj_t *current, boolean wrap);
mobj_t *P_GetNextTubeWaypoint(mobj_t *current, boolean wrap);
mobj_t *P_GetClosestTubeWaypoint(UINT8 sequence, mobj_t *mo);
boolean P_IsDegeneratedTubeWaypointSequence(UINT8 sequence);
// =====================================
// Internal parameters, used for engine.

View file

@ -432,7 +432,6 @@ typedef struct
{
char levelname[32];
UINT8 skinnum;
UINT8 botskin;
UINT8 numemeralds;
UINT8 numgameovers;
INT32 lives;

View file

@ -1614,7 +1614,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
if (!po->thinker)
po->thinker = &th->thinker;
target = waypoints[th->sequence][th->pointnum];
target = tubewaypoints[th->sequence][th->pointnum];
if (!target)
{
@ -1663,7 +1663,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
if (!th->stophere)
{
CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n");
waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false);
waypoint = (th->direction == -1) ? P_GetPreviousTubeWaypoint(target, false) : P_GetNextTubeWaypoint(target, false);
if (!waypoint && th->returnbehavior == PWR_WRAP) // If specified, wrap waypoints
{
@ -1673,7 +1673,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
th->stophere = true;
}
waypoint = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence);
waypoint = (th->direction == -1) ? P_GetLastTubeWaypoint(th->sequence) : P_GetFirstTubeWaypoint(th->sequence);
}
else if (!waypoint && th->returnbehavior == PWR_COMEBACK) // Come back to the start
{
@ -1682,7 +1682,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
if (!th->continuous)
th->returnbehavior = PWR_STOP;
waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false);
waypoint = (th->direction == -1) ? P_GetPreviousTubeWaypoint(target, false) : P_GetNextTubeWaypoint(target, false);
}
}
@ -2159,7 +2159,7 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
th->stophere = false;
// Find the first waypoint we need to use
first = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence);
first = (th->direction == -1) ? P_GetLastTubeWaypoint(th->sequence) : P_GetFirstTubeWaypoint(th->sequence);
if (!first)
{
@ -2171,7 +2171,7 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
// Sanity check: If all waypoints are in the same location,
// don't allow the movement to be continuous so we don't get stuck in an infinite loop.
if (th->continuous && P_IsDegeneratedWaypointSequence(th->sequence))
if (th->continuous && P_IsDegeneratedTubeWaypointSequence(th->sequence))
{
CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: All waypoints are in the same location!\n");
th->continuous = false;

View file

@ -62,7 +62,7 @@ typedef enum
static inline void P_ArchivePlayer(void)
{
const player_t *player = &players[consoleplayer];
INT16 skininfo = player->skin + (botskin<<5);
INT16 skininfo = player->skin;
SINT8 pllives = player->lives;
if (pllives < startinglivesbalance[numgameovers]) // Bump up to 3 lives if the player
pllives = startinglivesbalance[numgameovers]; // has less than that.
@ -77,8 +77,7 @@ static inline void P_ArchivePlayer(void)
static inline void P_UnArchivePlayer(void)
{
INT16 skininfo = READUINT16(save_p);
savedata.skin = skininfo & ((1<<5) - 1);
savedata.botskin = skininfo >> 5;
savedata.skin = skininfo;
savedata.numgameovers = READUINT8(save_p);
savedata.lives = READSINT8(save_p);
@ -201,15 +200,6 @@ static void P_NetArchivePlayers(void)
WRITEUINT8(save_p, players[i].texttimer);
WRITEUINT8(save_p, players[i].textvar);
if (players[i].awayviewmobj)
flags |= AWAYVIEW;
if (players[i].followmobj)
flags |= FOLLOWITEM;
if (players[i].follower)
flags |= FOLLOWER;
WRITEINT16(save_p, players[i].lastsidehit);
WRITEINT16(save_p, players[i].lastlinehit);
@ -224,21 +214,26 @@ static void P_NetArchivePlayers(void)
WRITEUINT8(save_p, players[i].splitscreenindex);
if (players[i].awayviewmobj)
flags |= AWAYVIEW;
if (players[i].followmobj)
flags |= FOLLOWITEM;
if (players[i].follower)
flags |= FOLLOWER;
WRITEUINT16(save_p, flags);
if (flags & CAPSULE)
WRITEUINT32(save_p, players[i].capsule->mobjnum);
if (flags & FIRSTAXIS)
WRITEUINT32(save_p, players[i].axis1->mobjnum);
if (flags & SECONDAXIS)
WRITEUINT32(save_p, players[i].axis2->mobjnum);
if (flags & AWAYVIEW)
WRITEUINT32(save_p, players[i].awayviewmobj->mobjnum);
if (flags & FOLLOWITEM)
WRITEUINT32(save_p, players[i].followmobj->mobjnum);
WRITEUINT32(save_p, (UINT32)players[i].followitem);
WRITEUINT32(save_p, players[i].charflags);
// SRB2kart
WRITEUINT8(save_p, players[i].kartspeed);
WRITEUINT8(save_p, players[i].kartweight);
@ -249,9 +244,6 @@ static void P_NetArchivePlayers(void)
if (flags & FOLLOWER)
WRITEUINT32(save_p, players[i].follower->mobjnum);
//
for (j = 0; j < NUMKARTSTUFF; j++)
WRITEINT32(save_p, players[i].kartstuff[j]);
@ -284,11 +276,6 @@ static void P_NetArchivePlayers(void)
WRITEUINT32(save_p, players[i].botvars.itemdelay);
WRITEUINT32(save_p, players[i].botvars.itemconfirm);
WRITESINT8(save_p, players[i].botvars.turnconfirm);
if (flags & FOLLOW)
WRITEUINT32(save_p, players[i].followmobj->mobjnum);
if (flags & DRONE)
WRITEUINT32(save_p, players[i].drone->mobjnum);
}
}
@ -429,25 +416,12 @@ static void P_NetUnArchivePlayers(void)
flags = READUINT16(save_p);
if (flags & CAPSULE)
players[i].capsule = (mobj_t *)(size_t)READUINT32(save_p);
if (flags & FIRSTAXIS)
players[i].axis1 = (mobj_t *)(size_t)READUINT32(save_p);
if (flags & SECONDAXIS)
players[i].axis2 = (mobj_t *)(size_t)READUINT32(save_p);
if (flags & AWAYVIEW)
players[i].awayviewmobj = (mobj_t *)(size_t)READUINT32(save_p);
players[i].viewheight = 32<<FRACBITS;
if (flags & FOLLOW)
if (flags & FOLLOWITEM)
players[i].followmobj = (mobj_t *)(size_t)READUINT32(save_p);
if (flags & DRONE)
players[i].drone = (mobj_t *)(size_t)READUINT32(save_p);
players[i].followitem = (mobjtype_t)READUINT32(save_p);
//SetPlayerSkinByNum(i, players[i].skin);
players[i].charflags = READUINT32(save_p);
@ -497,8 +471,6 @@ static void P_NetUnArchivePlayers(void)
players[i].botvars.itemconfirm = READUINT32(save_p);
players[i].botvars.turnconfirm = READSINT8(save_p);
players[i].followitem = (mobjtype_t)READUINT32(save_p);
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
}
}
@ -736,30 +708,30 @@ static void P_NetUnArchiveColormaps(void)
net_colormaps = NULL;
}
static void P_NetArchiveWaypoints(void)
static void P_NetArchiveTubeWaypoints(void)
{
INT32 i, j;
for (i = 0; i < NUMWAYPOINTSEQUENCES; i++)
for (i = 0; i < NUMTUBEWAYPOINTSEQUENCES; i++)
{
WRITEUINT16(save_p, numwaypoints[i]);
for (j = 0; j < numwaypoints[i]; j++)
WRITEUINT32(save_p, waypoints[i][j] ? waypoints[i][j]->mobjnum : 0);
WRITEUINT16(save_p, numtubewaypoints[i]);
for (j = 0; j < numtubewaypoints[i]; j++)
WRITEUINT32(save_p, tubewaypoints[i][j] ? tubewaypoints[i][j]->mobjnum : 0);
}
}
static void P_NetUnArchiveWaypoints(void)
static void P_NetUnArchiveTubeWaypoints(void)
{
INT32 i, j;
UINT32 mobjnum;
for (i = 0; i < NUMWAYPOINTSEQUENCES; i++)
for (i = 0; i < NUMTUBEWAYPOINTSEQUENCES; i++)
{
numwaypoints[i] = READUINT16(save_p);
for (j = 0; j < numwaypoints[i]; j++)
numtubewaypoints[i] = READUINT16(save_p);
for (j = 0; j < numtubewaypoints[i]; j++)
{
mobjnum = READUINT32(save_p);
waypoints[i][j] = (mobjnum == 0) ? NULL : P_FindNewPosition(mobjnum);
tubewaypoints[i][j] = (mobjnum == 0) ? NULL : P_FindNewPosition(mobjnum);
}
}
}
@ -2878,8 +2850,6 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
mobj->player->viewz = mobj->player->mo->z + mobj->player->viewheight;
}
P_AddThinker(&mobj->thinker);
if (diff2 & MD2_WAYPOINTCAP)
P_SetTarget(&waypointcap, mobj);
@ -4398,8 +4368,8 @@ void P_SaveNetGame(void)
P_ArchivePolyObjects();
P_NetArchiveThinkers();
P_NetArchiveSpecials();
P_NetArchiveWaypoints();
P_NetArchiveColormaps();
P_NetArchiveTubeWaypoints();
P_NetArchiveWaypoints();
}
LUA_Archive();
@ -4441,6 +4411,7 @@ boolean P_LoadNetGame(void)
P_NetUnArchiveThinkers();
P_NetUnArchiveSpecials();
P_NetUnArchiveColormaps();
P_NetUnArchiveTubeWaypoints();
P_NetUnArchiveWaypoints();
P_RelinkPointers();
P_FinishMobjs();

View file

@ -31,7 +31,6 @@ mobj_t *P_FindNewPosition(UINT32 oldposition);
typedef struct
{
UINT8 skin;
UINT8 botskin;
INT32 score;
INT32 lives;
INT32 continues;

View file

@ -21,7 +21,6 @@
#include "p_spec.h"
#include "p_saveg.h"
#include "i_sound.h" // for I_PlayCD()..
#include "i_video.h" // for I_FinishUpdate()..
#include "r_sky.h"
#include "i_system.h"
@ -89,6 +88,11 @@
#include "k_bot.h"
#include "k_grandprix.h"
// Replay names have time
#if !defined (UNDER_CE)
#include <time.h>
#endif
//
// Map MD5, calculated on level load.
// Sent to clients in PT_SERVERINFO.
@ -153,40 +157,41 @@ mapthing_t *playerstarts[MAXPLAYERS];
mapthing_t *bluectfstarts[MAXPLAYERS];
mapthing_t *redctfstarts[MAXPLAYERS];
// Maintain waypoints
mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
// Maintain *ZOOM TUBE* waypoints
// Renamed because SRB2Kart owns real waypoints.
mobj_t *tubewaypoints[NUMTUBEWAYPOINTSEQUENCES][TUBEWAYPOINTSEQUENCESIZE];
UINT16 numtubewaypoints[NUMTUBEWAYPOINTSEQUENCES];
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint)
void P_AddTubeWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint)
{
waypoints[sequence][id] = waypoint;
if (id >= numwaypoints[sequence])
numwaypoints[sequence] = id + 1;
tubewaypoints[sequence][id] = waypoint;
if (id >= numtubewaypoints[sequence])
numtubewaypoints[sequence] = id + 1;
}
static void P_ResetWaypoints(void)
static void P_ResetTubeWaypoints(void)
{
UINT16 sequence, id;
for (sequence = 0; sequence < NUMWAYPOINTSEQUENCES; sequence++)
for (sequence = 0; sequence < NUMTUBEWAYPOINTSEQUENCES; sequence++)
{
for (id = 0; id < numwaypoints[sequence]; id++)
waypoints[sequence][id] = NULL;
for (id = 0; id < numtubewaypoints[sequence]; id++)
tubewaypoints[sequence][id] = NULL;
numwaypoints[sequence] = 0;
numtubewaypoints[sequence] = 0;
}
}
mobj_t *P_GetFirstWaypoint(UINT8 sequence)
mobj_t *P_GetFirstTubeWaypoint(UINT8 sequence)
{
return waypoints[sequence][0];
return tubewaypoints[sequence][0];
}
mobj_t *P_GetLastWaypoint(UINT8 sequence)
mobj_t *P_GetLastTubeWaypoint(UINT8 sequence)
{
return waypoints[sequence][numwaypoints[sequence] - 1];
return tubewaypoints[sequence][numtubewaypoints[sequence] - 1];
}
mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap)
mobj_t *P_GetPreviousTubeWaypoint(mobj_t *current, boolean wrap)
{
UINT8 sequence = current->threshold;
UINT8 id = current->health;
@ -196,20 +201,20 @@ mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap)
if (!wrap)
return NULL;
id = numwaypoints[sequence] - 1;
id = numtubewaypoints[sequence] - 1;
}
else
id--;
return waypoints[sequence][id];
return tubewaypoints[sequence][id];
}
mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap)
mobj_t *P_GetNextTubeWaypoint(mobj_t *current, boolean wrap)
{
UINT8 sequence = current->threshold;
UINT8 id = current->health;
if (id == numwaypoints[sequence] - 1)
if (id == numtubewaypoints[sequence] - 1)
{
if (!wrap)
return NULL;
@ -219,19 +224,19 @@ mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap)
else
id++;
return waypoints[sequence][id];
return tubewaypoints[sequence][id];
}
mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo)
mobj_t *P_GetClosestTubeWaypoint(UINT8 sequence, mobj_t *mo)
{
UINT8 wp;
mobj_t *mo2, *result = NULL;
fixed_t bestdist = 0;
fixed_t curdist;
for (wp = 0; wp < numwaypoints[sequence]; wp++)
for (wp = 0; wp < numtubewaypoints[sequence]; wp++)
{
mo2 = waypoints[sequence][wp];
mo2 = tubewaypoints[sequence][wp];
if (!mo2)
continue;
@ -249,19 +254,19 @@ mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo)
}
// Return true if all waypoints are in the same location
boolean P_IsDegeneratedWaypointSequence(UINT8 sequence)
boolean P_IsDegeneratedTubeWaypointSequence(UINT8 sequence)
{
mobj_t *first, *waypoint;
UINT8 wp;
if (numwaypoints[sequence] <= 1)
if (numtubewaypoints[sequence] <= 1)
return true;
first = waypoints[sequence][0];
first = tubewaypoints[sequence][0];
for (wp = 1; wp < numwaypoints[sequence]; wp++)
for (wp = 1; wp < numtubewaypoints[sequence]; wp++)
{
waypoint = waypoints[sequence][wp];
waypoint = tubewaypoints[sequence][wp];
if (!waypoint)
continue;
@ -376,7 +381,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
mapheaderinfo[num]->musforcereset = -1;
mapheaderinfo[num]->forcecharacter[0] = '\0';
mapheaderinfo[num]->weather = 0;
snprintf(mapheaderinfo[num]->skytexture, 5, "SKY1", G_BuildMapName(i));
snprintf(mapheaderinfo[num]->skytexture, 5, "SKY1");
mapheaderinfo[num]->skytexture[4] = 0;
mapheaderinfo[num]->skybox_scalex = 16;
mapheaderinfo[num]->skybox_scaley = 16;
@ -1593,7 +1598,7 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val)
// Flags
else if (fastcmp(param, "blocking") && fastcmp("true", val))
lines[i].flags |= ML_IMPASSABLE;
else if ((fastcmp(param, "blockplayers") && fastcmp("true", val))
else if (fastcmp(param, "blockplayers") && fastcmp("true", val))
lines[i].flags |= ML_BLOCKPLAYERS;
else if (fastcmp(param, "twosided") && fastcmp("true", val))
lines[i].flags |= ML_TWOSIDED;
@ -2155,11 +2160,10 @@ static void P_InitializeSeg(seg_t *seg)
seg->numlights = 0;
seg->rlights = NULL;
P_UpdateSegLightOffset(seg);
seg->polyseg = NULL;
seg->dontrenderme = false;
P_UpdateSegLightOffset(seg);
}
static void P_LoadSegs(UINT8 *data)
@ -3316,16 +3320,7 @@ static void P_InitLevelSettings(void)
// map time limit
if (mapheaderinfo[gamemap-1]->countdown)
{
tic_t maxtime = 0;
countdowntimer = mapheaderinfo[gamemap-1]->countdown * TICRATE;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (players[i].starposttime > maxtime)
maxtime = players[i].starposttime;
}
countdowntimer -= maxtime;
}
else
countdowntimer = 0;
@ -3371,7 +3366,6 @@ static void P_InitLevelSettings(void)
players[i].gotcontinue = false;
players[i].deadtimer = players[i].numboxes = players[i].laps = 0;
players[i].health = 1;
players[i].aiming = 0;
players[i].pflags &= ~PF_GAMETYPEOVER;
}
@ -3382,12 +3376,6 @@ static void P_InitLevelSettings(void)
{
G_PlayerReborn(i, true);
if (canresetlives && (netgame || multiplayer) && playeringame[i] && (G_CompetitionGametype() || players[i].lives <= 0))
{
// In Co-Op, replenish a user's lives if they are depleted.
players[i].lives = cv_startinglives.value;
}
// obliteration station...
players[i].numboxes = players[i].totalring =\
players[i].laps = players[i].marescore = players[i].lastmarescore =\
@ -3532,6 +3520,8 @@ static void P_RunLevelScript(const char *scriptname)
static void P_ForceCharacter(const char *forcecharskin)
{
UINT8 i;
if (netgame)
{
char skincmd[33];
@ -3551,8 +3541,6 @@ static void P_ForceCharacter(const char *forcecharskin)
}
else
{
UINT8 i;
for (i = 0; i <= splitscreen; i++)
{
SetPlayerSkin(g_localplayers[i], forcecharskin);
@ -3660,114 +3648,6 @@ static void P_LoadRecordGhosts(void)
free(gpath);
}
/*static void P_LoadNightsGhosts(void)
{
const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1;
char *gpath = malloc(glen);
INT32 i;
if (!gpath)
return;
sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap));
// Best Score ghost
if (cv_ghost_bestscore.value)
{
for (i = 0; i < numskins; ++i)
{
if (cv_ghost_bestscore.value == 1 && players[consoleplayer].skin != i)
continue;
if (FIL_FileExists(va("%s-%s-score-best.lmp", gpath, skins[i].name)))
G_AddGhost(va("%s-%s-score-best.lmp", gpath, skins[i].name));
}
}
// Best Time ghost
if (cv_ghost_besttime.value)
{
for (i = 0; i < numskins; ++i)
{
if (cv_ghost_besttime.value == 1 && players[consoleplayer].skin != i)
continue;
if (FIL_FileExists(va("%s-%s-time-best.lmp", gpath, skins[i].name)))
G_AddGhost(va("%s-%s-time-best.lmp", gpath, skins[i].name));
}
}
// Last ghost
if (cv_ghost_last.value)
{
for (i = 0; i < numskins; ++i)
{
if (cv_ghost_last.value == 1 && players[consoleplayer].skin != i)
continue;
if (FIL_FileExists(va("%s-%s-last.lmp", gpath, skins[i].name)))
G_AddGhost(va("%s-%s-last.lmp", gpath, skins[i].name));
}
}
// Guest ghost
if (cv_ghost_guest.value && FIL_FileExists(va("%s-guest.lmp", gpath)))
G_AddGhost(va("%s-guest.lmp", gpath));
// Staff Attack ghosts
if (cv_ghost_staff.value)
{
lumpnum_t l;
UINT8 i = 1;
while (i <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),i))) != LUMPERROR)
{
G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),i));
i++;
}
}
free(gpath);
}*/
static void P_InitTagGametype(void)
{
UINT8 i;
INT32 realnumplayers = 0;
INT32 playersactive[MAXPLAYERS];
//I just realized how problematic this code can be.
//D_NumPlayers() will not always cover the scope of the netgame.
//What if one player is node 0 and the other node 31?
//The solution? Make a temp array of all players that are currently playing and pick from them.
//Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended?
//Also, you'd never have to loop through all 32 players slots to find anything ever again.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !(players[i].spectator || players[i].quittime))
{
playersactive[realnumplayers] = i; //stores the player's node in the array.
realnumplayers++;
}
}
if (!realnumplayers) //this should also fix the dedicated crash bug. You only pick a player if one exists to be picked.
{
CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n"));
return;
}
i = P_RandomKey(realnumplayers);
players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts.
// Taken and modified from G_DoReborn()
// Remove the player so he can respawn elsewhere.
// first disassociate the corpse
if (players[playersactive[i]].mo)
P_RemoveMobj(players[playersactive[i]].mo);
G_SpawnPlayer(playersactive[i]); //respawn the lucky player in his dedicated spawn location.
}
static void P_SetupCamera(UINT8 pnum, camera_t *cam)
{
if (players[pnum].mo && (server || addedtogame))
@ -3789,11 +3669,11 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
if (thing)
{
camera[0].x = thing->x;
camera[0].y = thing->y;
camera[0].z = thing->z;
camera[0].angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
camera[0].subsector = R_PointInSubsector(camera.x, camera.y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->x = thing->x;
cam->y = thing->y;
cam->z = thing->z;
cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
}
}
@ -3804,77 +3684,12 @@ static void P_InitCamera(void)
{
UINT8 i;
P_SetupCamera();
for (i = 0; i <= splitscreen; i++)
{
P_SetupCamera(i, &camera[i]);
displayplayers[i] = g_localplayers[i]; // Start with your OWN view, please!
}
}
static void P_RunSpecialStageWipe(void)
{
tic_t starttime = I_GetTime();
tic_t endtime = starttime + (3*TICRATE)/2;
tic_t nowtime;
S_StartSound(NULL, sfx_s3kaf);
// Fade music! Time it to S3KAF: 0.25 seconds is snappy.
if (RESETMUSIC ||
strnicmp(S_MusicName(),
(mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap - 1]->musname : mapmusname, 7))
S_FadeOutStopMusic(MUSICRATE/4); //FixedMul(FixedDiv(F_GetWipeLength(wipedefs[wipe_speclevel_towhite])*NEWTICRATERATIO, NEWTICRATE), MUSICRATE)
F_WipeStartScreen();
wipestyleflags |= (WSF_FADEOUT|WSF_TOWHITE);
#ifdef HWRENDER
// uh..........
if (rendermode == render_opengl)
F_WipeColorFill(0);
#endif
F_WipeEndScreen();
F_RunWipe(wipedefs[wipe_speclevel_towhite], false);
I_OsPolling();
I_FinishUpdate(); // page flip or blit buffer
if (moviemode)
M_SaveFrame();
nowtime = lastwipetic;
// Hold on white for extra effect.
while (nowtime < endtime)
{
// wait loop
while (!((nowtime = I_GetTime()) - lastwipetic))
I_Sleep();
lastwipetic = nowtime;
if (moviemode) // make sure we save frames for the white hold too
M_SaveFrame();
}
}
static void P_RunLevelWipe(void)
{
F_WipeStartScreen();
wipestyleflags |= WSF_FADEOUT;
#ifdef HWRENDER
// uh..........
if (rendermode == render_opengl)
F_WipeColorFill(31);
#endif
F_WipeEndScreen();
// for titlemap: run a specific wipe if specified
// needed for exiting time attack
if (wipetypepre != INT16_MAX)
F_RunWipe(
(wipetypepre >= 0 && F_WipeExists(wipetypepre)) ? wipetypepre : wipedefs[wipe_level_toblack],
false);
wipetypepre = -1;
}
static void P_InitPlayers(void)
@ -3901,8 +3716,6 @@ static void P_InitPlayers(void)
static void P_InitGametype(void)
{
UINT8 i;
P_InitPlayers();
if (modeattacking && !demo.playback)
@ -3988,12 +3801,6 @@ boolean P_LoadLevel(boolean fromnetsave)
if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0')
P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter);
if (!dedicated)
{
CV_UpdateCamDist();
CV_UpdateCam2Dist();
}
// Initial height of PointOfView
// will be set by player think.
players[consoleplayer].viewz = 1;
@ -4078,9 +3885,7 @@ boolean P_LoadLevel(boolean fromnetsave)
// Fade out music here. Deduct 2 tics so the fade volume actually reaches 0.
// But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug.
if (!titlemapinaction && (RESETMUSIC ||
strnicmp(S_MusicName(),
(mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7)))
if (!titlemapinaction)
S_FadeMusic(0, FixedMul(
FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE));
@ -4088,11 +3893,6 @@ boolean P_LoadLevel(boolean fromnetsave)
if (rendermode != render_none)
V_SetPaletteLump(GetPalette()); // Set the level palette
// Let's fade to black here
// But only if we didn't do the special stage wipe
if (!demo.rewinding)
P_RunLevelWipe();
if (!titlemapinaction)
{
if (ranspecialwipe == 2)
@ -4109,6 +3909,21 @@ boolean P_LoadLevel(boolean fromnetsave)
levelfadecol = (encoremode ? 0 : 31);
// Let's fade to white here
// But only if we didn't do the encore startup wipe
if (!demo.rewinding)
{
if (rendermode != render_none)
{
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
F_WipeEndScreen();
}
F_RunWipe(wipedefs[wipe_level_toblack], false, ((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), false, false);
}
// Close text prompt before freeing the old level
F_EndTextPrompt(false, true);
@ -4139,8 +3954,6 @@ boolean P_LoadLevel(boolean fromnetsave)
players[consoleplayer].continues = savedata.continues;
players[consoleplayer].lives = savedata.lives;
players[consoleplayer].score = savedata.score;
if ((botingame = ((botskin = savedata.botskin) != 0)))
botcolor = skins[botskin-1].prefcolor;
emeralds = savedata.emeralds;
savedata.lives = 0;
}
@ -4160,7 +3973,7 @@ boolean P_LoadLevel(boolean fromnetsave)
P_ResetSpawnpoints();
P_ResetWaypoints();
P_ResetTubeWaypoints();
P_MapStart();
@ -4233,17 +4046,6 @@ boolean P_LoadLevel(boolean fromnetsave)
// clear special respawning que
iquehead = iquetail = 0;
// Fab : 19-07-98 : start cd music for this level (note: can be remapped)
I_PlayCD((UINT8)(gamemap), false);
// preload graphics
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode != render_soft && rendermode != render_none)
{
HWR_PrepLevelCache(numtextures);
}
#endif
P_MapEnd();
// Remove the loading shit from the screen

View file

@ -1442,67 +1442,6 @@ void P_ChangeSectorTag(UINT32 sector, INT16 newtag)
}
}
//
// P_RunNightserizeExecutors
//
void P_RunNightserizeExecutors(mobj_t *actor)
{
size_t i;
for (i = 0; i < numlines; i++)
{
if (lines[i].special == 323 || lines[i].special == 324)
P_RunTriggerLinedef(&lines[i], actor, NULL);
}
}
//
// P_RunDeNightserizeExecutors
//
void P_RunDeNightserizeExecutors(mobj_t *actor)
{
size_t i;
for (i = 0; i < numlines; i++)
{
if (lines[i].special == 325 || lines[i].special == 326)
P_RunTriggerLinedef(&lines[i], actor, NULL);
}
}
//
// P_RunNightsLapExecutors
//
void P_RunNightsLapExecutors(mobj_t *actor)
{
size_t i;
for (i = 0; i < numlines; i++)
{
if (lines[i].special == 327 || lines[i].special == 328)
P_RunTriggerLinedef(&lines[i], actor, NULL);
}
}
//
// P_RunNightsCapsuleTouchExecutors
//
void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean enoughspheres)
{
size_t i;
for (i = 0; i < numlines; i++)
{
if ((lines[i].special == 329 || lines[i].special == 330)
&& ((entering && (lines[i].flags & ML_TFERLINE))
|| (!entering && !(lines[i].flags & ML_TFERLINE)))
&& ((lines[i].flags & ML_DONTPEGTOP)
|| (enoughspheres && !(lines[i].flags & ML_NOTBOUNCY))
|| (!enoughspheres && (lines[i].flags & ML_NOTBOUNCY))))
P_RunTriggerLinedef(&lines[i], actor, NULL);
}
}
/** Finds minimum light from an adjacent sector.
*
* \param sector Sector to start in.
@ -1748,17 +1687,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
return false;
}
break;
case 323: // nightserize - each time
case 324: // nightserize - once
case 325: // denightserize - each time
case 326: // denightserize - once
case 327: // nights lap - each time
case 328: // nights lap - once
case 329: // nights egg capsule touch - each time
case 330: // nights egg capsule touch - once
if (!P_CheckNightsTriggerLine(triggerline, actor))
return false;
break;
case 331: // continuous
case 332: // each time
case 333: // once
@ -1904,10 +1832,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
|| specialtype == 318 // Unlockable trigger - Once
|| specialtype == 320 // Unlockable - Once
|| specialtype == 321 || specialtype == 322 // Trigger on X calls - Continuous + Each Time
|| specialtype == 324 // Nightserize - Once
|| specialtype == 326 // DeNightserize - Once
|| specialtype == 328 // Nights lap - Once
|| specialtype == 330 // Nights Bonus Time - Once
|| specialtype == 333 // Skin - Once
|| specialtype == 336 // Dye - Once
|| specialtype == 399 // Level Load
@ -3775,7 +3699,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 459: // Control Text Prompt
// console player only unless NOCLIMB is set
if (mo && mo->player && P_IsLocalPlayer(mo->player) && (!bot || bot != mo))
if (mo && mo->player && P_IsLocalPlayer(mo->player))
{
INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1);
INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1);
@ -3850,8 +3774,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
break;
case 462: // Stop clock (and end level in record attack)
if (G_PlatformGametype())
{
stoppedclock = true;
CONS_Debug(DBG_GAMELOGIC, "Clock stopped!\n");
if (modeattacking)
@ -3864,7 +3786,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
P_DoPlayerExit(&players[i]);
}
}
}
break;
case 463: // Dye object
@ -4220,8 +4141,13 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number, b
if (((rover->flags & FF_BLOCKPLAYER) && mo->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mo->player))
{
boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == topheight));
boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == bottomheight));
boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP)
|| !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == topheight));
boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP)
|| (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == bottomheight));
// Thing must be on top of the floor to be affected...
if (!(floorallowed || ceilingallowed))
@ -4377,8 +4303,13 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number, b
if (((rover->flags & FF_BLOCKPLAYER) && mo->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mo->player))
{
boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == topheight));
boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == bottomheight));
boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP)
|| !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == topheight));
boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP)
|| (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == bottomheight));
// Thing must be on top of the floor to be affected...
if (!(floorallowed || ceilingallowed))
@ -4793,9 +4724,6 @@ DoneSection2:
}
case 2: // Special stage GOAL sector / Exit Sector / CTF Flag Return
if (!(gametyperules & GTR_ALLOWEXIT))
break;
// Exit (for FOF exits; others are handled in P_PlayerThink in p_user.c)
{
INT32 lineindex;
@ -4808,12 +4736,8 @@ DoneSection2:
// FOF custom exits not to work.
lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1);
if (G_CoopGametype() && lineindex != -1) // Custom exit!
if (lineindex != -1) // Custom exit!
{
// Special goodies with the block monsters flag depending on emeralds collected
if ((lines[lineindex].flags & ML_BLOCKPLAYERS) && ALL7EMERALDS(emeralds))
nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS);
else
nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS);
if (lines[lineindex].flags & ML_NOCLIMB)
@ -4882,7 +4806,7 @@ DoneSection2:
break;
}
waypoint = P_GetFirstWaypoint(sequence);
waypoint = P_GetFirstTubeWaypoint(sequence);
if (!waypoint)
{
@ -4940,7 +4864,7 @@ DoneSection2:
break;
}
waypoint = P_GetLastWaypoint(sequence);
waypoint = P_GetLastTubeWaypoint(sequence);
if (!waypoint)
{
@ -6841,17 +6765,6 @@ void P_SpawnSpecials(boolean fromnetsave)
P_AddEachTimeThinker(&lines[i]);
break;
// NiGHTS trigger executors
case 323:
case 324:
case 325:
case 326:
case 327:
case 328:
case 329:
case 330:
break;
// Skin trigger executors
case 331:
case 333:
@ -7572,8 +7485,8 @@ static void P_SpawnScrollers(void)
CONS_Debug(DBG_GAMELOGIC, "Line special 508 (line #%s) missing back side!\n", sizeu1(i));
break;
case 507: // scroll front and backside of tagged lines
for (s = -1; (s = P_FindLineFromLineTag(l, s)) >= 0 ;)
case 509: // scroll front and backside of tagged lines
for (s = -1; (s = P_FindLineFromTag(l->tag, s)) >= 0 ;)
{
if (s != (INT32)i)
{
@ -8475,9 +8388,6 @@ static inline boolean PIT_PushThing(mobj_t *thing)
if (thing->eflags & MFE_PUSHED)
return false;
if (thing->player && thing->player->powers[pw_carry] == CR_ROPEHANG)
return false;
// Allow this to affect pushable objects at some point?
if (thing->player && !(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)))
{
@ -8665,9 +8575,6 @@ void T_Pusher(pusher_t *p)
if (thing->eflags & MFE_PUSHED)
continue;
if (thing->player && thing->player->powers[pw_carry] == CR_ROPEHANG)
continue;
if (thing->player && (thing->state == &states[thing->info->painstate])
&& (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3
&& thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player)))

View file

@ -40,6 +40,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
(void)starposttime;
(void)starpostangle;
(void)starpostscale;
// the move is ok,
// so link the thing into its new position
@ -90,9 +91,6 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
thing->player->drawangle = drawangle;
// Reset map starposts for the player's new info.
P_ResetStarposts();
P_ResetPlayer(thing->player);
P_SetPlayerMobjState(thing, S_KART_STILL); // SRB2kart - was S_PLAY_STND

View file

@ -611,24 +611,6 @@ void P_Ticker(boolean run)
if (run)
{
if (countdowntimer && G_PlatformGametype() && ((gametyperules & GTR_CAMPAIGN) || leveltime >= 4*TICRATE) && !stoppedclock && --countdowntimer <= 0)
{
countdowntimer = 0;
countdowntimeup = true;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (!players[i].mo)
continue;
if (multiplayer || netgame)
players[i].exiting = 0;
P_DamageMobj(players[i].mo, NULL, NULL, 1, DMG_INSTAKILL);
}
}
if (racecountdown > 1)
racecountdown--;

View file

@ -2478,7 +2478,7 @@ static void P_DoZoomTube(player_t *player)
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
// Find next waypoint
waypoint = reverse ? P_GetPreviousWaypoint(player->mo->tracer, false) : P_GetNextWaypoint(player->mo->tracer, false);
waypoint = reverse ? P_GetPreviousTubeWaypoint(player->mo->tracer, false) : P_GetNextTubeWaypoint(player->mo->tracer, false);
if (waypoint)
{

View file

@ -552,6 +552,8 @@ typedef struct seg_s
void *pv1; // polyvertex_t
void *pv2; // polyvertex_t
float flength; // length of the seg, used by hardware renderer
lightmap_t *lightmaps; // for static lightmap
#endif
// Why slow things down by calculating lightlists for every thick side?
@ -559,14 +561,13 @@ typedef struct seg_s
r_lightlist_t *rlights;
polyobj_t *polyseg;
boolean dontrenderme;
boolean glseg;
// Fake contrast calculated on level load
SINT8 lightOffset;
#ifdef HWRENDER
INT16 hwLightOffset;
#endif
boolean glseg;
} seg_t;
//

View file

@ -289,9 +289,6 @@ void S_RegisterSoundStuff(void)
CV_RegisterVar(&surround);
CV_RegisterVar(&cv_samplerate);
CV_RegisterVar(&cv_resetmusic);
CV_RegisterVar(&cv_resetmusicbyheader);
CV_RegisterVar(&cv_1upsound);
CV_RegisterVar(&cv_playsoundsifunfocused);
CV_RegisterVar(&cv_playmusicifunfocused);
CV_RegisterVar(&cv_gamesounds);
@ -3009,9 +3006,6 @@ void S_StartEx(boolean reset)
S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0);
else
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
if (RESETMUSIC || reset)
S_StopMusic();
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
S_ResetMusicStack();
music_stack_noposition = false;

View file

@ -35,7 +35,6 @@ extern consvar_t cv_soundvolume, cv_closedcaptioning, cv_digmusicvolume;
extern consvar_t cv_midimusicvolume;
#endif
extern consvar_t cv_numChannels;
extern consvar_t surround;
extern consvar_t cv_numChannels;
@ -48,7 +47,7 @@ extern consvar_t cv_musicpref;
extern consvar_t cv_gamesounds;
extern consvar_t cv_playmusicifunfocused;
extern consvar_t cv_playsoundifunfocused;
extern consvar_t cv_playsoundsifunfocused;
extern consvar_t cv_music_resync_threshold;
extern consvar_t cv_music_resync_powerups_only;