mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-24 08:52:33 +00:00
WIP: Catch a few places which could be going wrong with followers on joining servers.
Definitely better than it was, but current status: sometimes when joining a server cv_follower[n].value is 0 and I don't know why.
This commit is contained in:
parent
8aeaf9738d
commit
fa5aa408be
3 changed files with 53 additions and 29 deletions
|
|
@ -1468,7 +1468,7 @@ static void SendNameAndColor(UINT8 n)
|
|||
const INT32 playernum = g_localplayers[n];
|
||||
player_t *player = &players[playernum];
|
||||
|
||||
char buf[MAXPLAYERNAME+9];
|
||||
char buf[MAXPLAYERNAME+12];
|
||||
char *p;
|
||||
|
||||
if (splitscreen < n)
|
||||
|
|
@ -1501,7 +1501,7 @@ static void SendNameAndColor(UINT8 n)
|
|||
|
||||
// so like, this is sent before we even use anything like cvars or w/e so it's possible that follower is set to a pretty yikes value, so let's fix that before we send garbage that could crash the game:
|
||||
if (cv_follower[n].value >= numfollowers || cv_follower[n].value < -1)
|
||||
CV_StealthSet(&cv_follower[n], "-1");
|
||||
CV_StealthSet(&cv_follower[n], "None");
|
||||
|
||||
if (!strcmp(cv_playername[n].string, player_names[playernum])
|
||||
&& cv_playercolor[n].value == player->skincolor
|
||||
|
|
@ -1587,7 +1587,8 @@ static void SendNameAndColor(UINT8 n)
|
|||
WRITEUINT32(p, (UINT32)player->availabilities);
|
||||
WRITEUINT16(p, (UINT16)cv_playercolor[n].value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin[n].value);
|
||||
WRITESINT8(p, (SINT8)cv_follower[n].value);
|
||||
WRITEINT16(p, (INT16)cv_follower[n].value);
|
||||
//CONS_Printf("Sending follower id %d\n", (INT16)cv_follower[n].value);
|
||||
WRITEUINT16(p, (UINT16)cv_followercolor[n].value);
|
||||
|
||||
SendNetXCmdForPlayer(n, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
|
|
@ -1599,7 +1600,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
|||
char name[MAXPLAYERNAME+1];
|
||||
UINT16 color, followercolor;
|
||||
UINT8 skin;
|
||||
SINT8 follower;
|
||||
INT16 follower;
|
||||
SINT8 localplayer = -1;
|
||||
UINT8 i;
|
||||
|
||||
|
|
@ -1628,7 +1629,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
|||
p->availabilities = READUINT32(*cp);
|
||||
color = READUINT16(*cp);
|
||||
skin = READUINT8(*cp);
|
||||
follower = READSINT8(*cp);
|
||||
follower = READINT16(*cp);
|
||||
//CONS_Printf("Recieved follower id %d\n", follower);
|
||||
followercolor = READUINT16(*cp);
|
||||
|
||||
// set name
|
||||
|
|
|
|||
|
|
@ -77,6 +77,31 @@ boolean K_SetFollowerByName(INT32 playernum, const char *skinname)
|
|||
return false;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void K_RemoveFollower(player_t *player)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void K_RemoveFollower(player_t *player)
|
||||
{
|
||||
mobj_t *bub, *tmp;
|
||||
if (player->follower && !P_MobjWasRemoved(player->follower)) // this is also called when we change colour so don't respawn the follower unless we changed skins
|
||||
{
|
||||
// Remove follower's possible hnext list (bubble)
|
||||
bub = player->follower->hnext;
|
||||
|
||||
while (bub && !P_MobjWasRemoved(bub))
|
||||
{
|
||||
tmp = bub->hnext;
|
||||
P_RemoveMobj(bub);
|
||||
bub = tmp;
|
||||
}
|
||||
|
||||
P_RemoveMobj(player->follower);
|
||||
P_SetTarget(&player->follower, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void K_SetFollowerByNum(INT32 playernum, INT32 skinnum)
|
||||
|
||||
|
|
@ -85,8 +110,6 @@ boolean K_SetFollowerByName(INT32 playernum, const char *skinname)
|
|||
void K_SetFollowerByNum(INT32 playernum, INT32 skinnum)
|
||||
{
|
||||
player_t *player = &players[playernum];
|
||||
mobj_t *bub;
|
||||
mobj_t *tmp;
|
||||
|
||||
player->followerready = true; // we are ready to perform follower related actions in the player thinker, now.
|
||||
|
||||
|
|
@ -97,21 +120,8 @@ void K_SetFollowerByNum(INT32 playernum, INT32 skinnum)
|
|||
However, we will despawn it right here if there's any to make it easy for the player thinker to replace it or delete it.
|
||||
*/
|
||||
|
||||
if (player->follower && skinnum != player->followerskin) // this is also called when we change colour so don't respawn the follower unless we changed skins
|
||||
{
|
||||
// Remove follower's possible hnext list (bubble)
|
||||
bub = player->follower->hnext;
|
||||
|
||||
while (bub && !P_MobjWasRemoved(bub))
|
||||
{
|
||||
tmp = bub->hnext;
|
||||
P_RemoveMobj(bub);
|
||||
bub = tmp;
|
||||
}
|
||||
|
||||
P_RemoveMobj(player->follower);
|
||||
P_SetTarget(&player->follower, NULL);
|
||||
}
|
||||
if (skinnum != player->followerskin)
|
||||
K_RemoveFollower(player);
|
||||
|
||||
player->followerskin = skinnum;
|
||||
|
||||
|
|
@ -256,18 +266,16 @@ void K_HandleFollower(player_t *player)
|
|||
{
|
||||
//CONS_Printf("Follower skin invlaid. Setting to -1.\n");
|
||||
player->followerskin = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
// don't do anything if we can't have a follower to begin with.
|
||||
// (It gets removed under those conditions)
|
||||
if (player->spectator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->followerskin < 0)
|
||||
if (player->spectator || player->followerskin < 0)
|
||||
{
|
||||
if (player->follower)
|
||||
{
|
||||
K_RemoveFollower(player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,5 +182,19 @@ UINT16 K_GetEffectiveFollowerColor(UINT16 followercolor, UINT16 playercolor);
|
|||
|
||||
void K_HandleFollower(player_t *player);
|
||||
|
||||
/*--------------------------------------------------
|
||||
void K_RemoveFollower(player_t *player)
|
||||
|
||||
Removes Follower object
|
||||
|
||||
Input Arguments:-
|
||||
player - The player who we want to remove the follower of.
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
|
||||
void K_RemoveFollower(player_t *player);
|
||||
|
||||
|
||||
#endif // __K_FOLLOWER__
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue