port: net: fix a bunch of access violations

This commit is contained in:
fgsfds committed 2024-01-07 19:54:27 +01:00
1 parent 4439fdf411
commit 4eca4a1f07
7 files changed
+46 -10

No files matched your search

+5 -3
View File
@@ -854,12 +854,14 @@ void netPlayersAllocate(void)
cfg->options |= OPTION_FORWARDPITCH;
}
cl->player = g_Vars.players[cl->playernum];
cl->config = &g_PlayerConfigsArray[cl->playernum];
cl->config->client = cl;
cl->config->handicap = 0x80;
cl->player->client = cl;
cl->player->isremote = (cl != g_NetLocalClient);
cl->player = g_Vars.players[cl->playernum];
if (cl->player) {
cl->player->client = cl;
cl->player->isremote = (cl != g_NetLocalClient);
}
}
}
+12 -2
View File
@@ -112,6 +112,10 @@ static void bgunProcessInputAltButton(struct movedata *data, s8 contpad, s32 i)
static inline void bmoveProcessRemoteInput(const bool allowc1buttons)
{
struct player *pl = g_Vars.currentplayer;
if (!pl->client) {
return;
}
struct netplayermove *inmove = &pl->client->inmove[0];
struct netplayermove *inmoveprev = &pl->client->inmove[1];
s32 moveticks = inmove->tick - inmoveprev->tick;
@@ -899,14 +903,17 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
const f32 mlookscale = g_Vars.lvupdate240 ? (4.f / (f32)g_Vars.lvupdate240) : 4.f;
const bool allowmlook = (g_Vars.currentplayernum == 0) && (allowc1x || allowc1y);
bool allowmcross = false;
#endif
if (g_Vars.currentplayer->isremote) {
controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex);
#ifndef PLATFORM_N64
if (g_Vars.currentplayer->isremote || controlmode == CONTROLMODE_NA) {
bmoveProcessRemoteInput(allowc1buttons);
return;
}
#endif
controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex);
weaponnum = bgunGetWeaponNum(HAND_RIGHT);
canmanualzoom = weaponHasAimFlag(weaponnum, INVAIMFLAG_MANUALZOOM);
contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex);
@@ -1421,6 +1428,9 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
aimoffhist[i] = !aimonhist[i];
}
#ifdef AVOID_UB
if (numsamples)
#endif
g_Vars.currentplayer->insightaimmode = aimonhist[numsamples - 1];
}
+20 -4
View File
@@ -184,7 +184,10 @@ u32 var80070748 = 0;
u32 var8007074c = 0;
bool g_PlayersWithControl[] = {
true, true, true, true,
#if MAX_PLAYERS > 4
true, true, true, true
#endif
};
bool g_PlayerInvincible = false;
@@ -3507,6 +3510,11 @@ void playerTick(bool arg0)
bool pause = false;
f32 newspeed;
#ifndef PLATFORM_N64
if (mode == CONTROLMODE_NA) {
// TODO
} else
#endif
if (mode == CONTROLMODE_23
|| mode == CONTROLMODE_24
|| mode == CONTROLMODE_22
@@ -5886,10 +5894,6 @@ f32 playerGetZoomFovMult(s32 playernum)
return g_PlayerExtCfg[playernum % MAX_LOCAL_PLAYERS].fovzoommult;
}
#endif
#if MAX_PLAYERS > 4
s32 playerGetCount(void)
{
s32 count = 0;
@@ -5899,4 +5903,16 @@ s32 playerGetCount(void)
return count;
}
s32 playerGetLocalCount(void)
{
if (g_NetMode) {
return 1;
}
const s32 playercount = playerGetCount();
if (playercount > MAX_LOCAL_PLAYERS) {
return MAX_LOCAL_PLAYERS;
}
return playercount;
}
#endif
+6
View File
@@ -148,6 +148,12 @@ void playerReset(void)
g_PlayersWithControl[1] = true;
g_PlayersWithControl[2] = true;
g_PlayersWithControl[3] = true;
#if MAX_PLAYERS > 4
g_PlayersWithControl[4] = true;
g_PlayersWithControl[5] = true;
g_PlayersWithControl[6] = true;
g_PlayersWithControl[7] = true;
#endif
g_PlayerInvincible = false;
playerSetTickMode(TICKMODE_GE_FADEIN);
+1 -1
View File
@@ -4728,7 +4728,7 @@ enum weaponnum {
#define NETMODE_SERVER 1
#define NETMODE_CLIENT 2
#define LOCALPLAYERCOUNT() (g_NetMode ? 1 : PLAYERCOUNT())
#define LOCALPLAYERCOUNT() playerGetLocalCount()
#endif
+1
View File
@@ -562,6 +562,7 @@ extern s32 g_NetMode;
#define TEX_FILTER_2D g_TexFilter2D
s32 playerGetCount(void);
s32 playerGetLocalCount(void);
#else // PLATFORM_N64
+1
View File
@@ -110,6 +110,7 @@ struct sndstate *playerSndStart(s32 arg0, s16 sound, struct sndstate **handle, s
#if MAX_PLAYERS > 4
s32 playerGetCount(void);
s32 playerGetLocalCount(void);
#endif
#ifndef PLATFORM_N64