Fixed crash bug

Further improved player trails
This commit is contained in:
Louis authored and Ashnal committed 2020-02-17 01:42:44 -05:00
1 parent 499177c4b9
commit 37cd0a596e
3 files changed
+40 -35

No files matched your search

+17 -10
View File
@@ -5445,7 +5445,7 @@ boolean newLoadTic = false;
#define MAXAUTOFUDGERTT 20
boolean autotimefudge = true;
boolean autotimefudge;
UINT8 autotimefudgetime = 0;
UINT16 autotimefudgesamples = 0;
UINT16 autotimefudgedata[MAXAUTOFUDGERTT];
@@ -5708,21 +5708,28 @@ static void RunSimulations()
if (playeringame[j] && players[j].mo && j != consoleplayer)
{
// If there is a big discrepency between the player's current position and their last one, spawn a trail showing their movements
fixed_t distance = max(abs(steadyplayers[j].finalx - players[j].mo->x),
max(abs(steadyplayers[j].finaly - players[j].mo->y),
abs(steadyplayers[j].finalz - players[j].mo->z)));
fixed_t distance = max(abs(steadyplayers[j].finalx - steadyplayers[j].histx[histIndex]),
max(abs(steadyplayers[j].finaly - steadyplayers[j].histy[histIndex]),
abs(steadyplayers[j].finalz - steadyplayers[j].histz[histIndex])));
fixed_t stepDistance = 60 << FRACBITS; // distance between trail steps
// If player is changing direction quickly in a net simulation, create a ghost trail
if (distance > players[j].maxdash)
if (distance > stepDistance)
{
for (int i = 0; i < histIndex; i++)
fixed_t numSteps = FixedDiv(distance, stepDistance) & ~FRACMASK;
fixed_t currentStep; // between 0 and 1
fixed_t step = FixedDiv(1<<FRACBITS, numSteps + 1);
int i = 1;
for (currentStep = step; currentStep < (1<<FRACBITS); currentStep += step)
{
mobj_t* ghost = P_SpawnGhostMobj(players[j].mo);
ghost->x = steadyplayers[j].histx[i];
ghost->y = steadyplayers[j].histy[i];
ghost->z = steadyplayers[j].histz[i];
ghost->fuse = i - (ghost->fuse - histIndex);
ghost->x = steadyplayers[j].finalx + FixedMul(steadyplayers[j].histx[histIndex] - steadyplayers[j].finalx, currentStep);
ghost->y = steadyplayers[j].finaly + FixedMul(steadyplayers[j].histy[histIndex] - steadyplayers[j].finaly, currentStep);
ghost->z = steadyplayers[j].finalz + FixedMul(steadyplayers[j].histz[histIndex] - steadyplayers[j].finalz, currentStep);
ghost->fuse = ghost->fuse + i - (numSteps>>FRACBITS);
i++;
}
}
+1 -1
View File
@@ -476,7 +476,7 @@ UINT8 splitscreen = 0;
boolean circuitmap = true; // SRB2kart
consvar_t cv_simulate = { "simulate", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL };
static CV_PossibleValue_t simulateTics_cons_t[] = { {0, "MIN"}, {BACKUPTICS / 2, "MAX"}, {0, NULL} };
static CV_PossibleValue_t simulateTics_cons_t[] = { {0, "MIN"}, {MAXSIMULATIONS - 1, "MAX"}, {0, NULL} };
consvar_t cv_simulatetics = { "simulatetics", "0", 0, simulateTics_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL };
static CV_PossibleValue_t netdelay_cons_t[] = { {0, "MIN"}, {250, "MAX"}, {0, NULL} };
+22 -24
View File
@@ -457,6 +457,17 @@ static void P_LocalArchivePlayers(void)
continue;
WRITEMEM(save_p, &players[i], sizeof(player_t));
player_t* player = &((player_t*)save_p)[-1];
#define RELINK(var) if (var != NULL) var = (mobj_t*)var->mobjnum
RELINK(player->capsule);
RELINK(player->axis1);
RELINK(player->axis2);
RELINK(player->awayviewmobj);
RELINK(player->followmobj);
RELINK(player->drone);
#undef RELINK
}
}
@@ -473,13 +484,6 @@ static void P_LocalUnArchivePlayers(void)
continue;
READMEM(save_p, &players[i], sizeof(player_t));
players[i].capsule = NULL;
players[i].axis1 = NULL;
players[i].axis2 = NULL;
players[i].awayviewmobj = NULL;
players[i].followmobj = NULL;
players[i].drone = NULL;
}
}
@@ -2229,16 +2233,6 @@ static void P_LocalArchiveThinkers(void)
RELINK(savedMobj->target);
RELINK(savedMobj->hnext);
RELINK(savedMobj->hprev);
if (savedMobj->player)
{
RELINK(savedMobj->player->capsule);
RELINK(savedMobj->player->axis1);
RELINK(savedMobj->player->axis2);
RELINK(savedMobj->player->awayviewmobj);
RELINK(savedMobj->player->followmobj);
RELINK(savedMobj->player->drone);
}
}
}
#undef RELINK
@@ -3508,15 +3502,19 @@ static void P_LocalUnArchiveThinkers()
RELINK(mobj->target);
RELINK(mobj->hnext);
RELINK(mobj->hprev);
}
if (mobj->player)
// restore player pointers (the above doesn't always seem to work perhaps because playeringame is false?
for (int i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
{
RELINK(mobj->player->capsule);
RELINK(mobj->player->axis1);
RELINK(mobj->player->axis2);
RELINK(mobj->player->awayviewmobj);
RELINK(mobj->player->followmobj);
RELINK(mobj->player->drone);
RELINK(players[i].capsule);
RELINK(players[i].axis1);
RELINK(players[i].axis2);
RELINK(players[i].awayviewmobj);
RELINK(players[i].followmobj);
RELINK(players[i].drone);
}
}
#undef RELINK