mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Merge branch 'refactor-weaponpref' into 'master'
Refactor weapon pref See merge request KartKrew/Kart!715
This commit is contained in:
commit
0acaf80d2c
4 changed files with 51 additions and 42 deletions
|
|
@ -1730,40 +1730,65 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendWeaponPref(UINT8 n)
|
enum {
|
||||||
|
WP_KICKSTARTACCEL = 1<<0,
|
||||||
|
WP_SHRINKME = 1<<1,
|
||||||
|
};
|
||||||
|
|
||||||
|
void WeaponPref_Send(UINT8 ssplayer)
|
||||||
{
|
{
|
||||||
UINT8 buf[1];
|
UINT8 prefs = 0;
|
||||||
|
|
||||||
buf[0] = 0;
|
if (cv_kickstartaccel[ssplayer].value)
|
||||||
|
prefs |= WP_KICKSTARTACCEL;
|
||||||
|
|
||||||
if (cv_kickstartaccel[n].value)
|
if (cv_shrinkme[ssplayer].value)
|
||||||
buf[0] |= 1;
|
prefs |= WP_SHRINKME;
|
||||||
|
|
||||||
if (cv_shrinkme[n].value)
|
SendNetXCmdForPlayer(ssplayer, XD_WEAPONPREF, &prefs, 1);
|
||||||
buf[0] |= 2;
|
|
||||||
|
|
||||||
SendNetXCmdForPlayer(n, XD_WEAPONPREF, buf, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Got_WeaponPref(UINT8 **cp,INT32 playernum)
|
void WeaponPref_Save(UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
|
player_t *player = &players[playernum];
|
||||||
|
|
||||||
|
UINT8 prefs = 0;
|
||||||
|
|
||||||
|
if (player->pflags & PF_KICKSTARTACCEL)
|
||||||
|
prefs |= WP_KICKSTARTACCEL;
|
||||||
|
|
||||||
|
if (player->pflags & PF_SHRINKME)
|
||||||
|
prefs |= WP_SHRINKME;
|
||||||
|
|
||||||
|
WRITEUINT8(*cp, prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WeaponPref_Parse(UINT8 **cp, INT32 playernum)
|
||||||
|
{
|
||||||
|
player_t *player = &players[playernum];
|
||||||
|
|
||||||
UINT8 prefs = READUINT8(*cp);
|
UINT8 prefs = READUINT8(*cp);
|
||||||
|
|
||||||
players[playernum].pflags &= ~(PF_KICKSTARTACCEL|PF_SHRINKME);
|
player->pflags &= ~(PF_KICKSTARTACCEL|PF_SHRINKME);
|
||||||
|
|
||||||
if (prefs & 1)
|
if (prefs & WP_KICKSTARTACCEL)
|
||||||
players[playernum].pflags |= PF_KICKSTARTACCEL;
|
player->pflags |= PF_KICKSTARTACCEL;
|
||||||
|
|
||||||
if (prefs & 2)
|
if (prefs & WP_SHRINKME)
|
||||||
players[playernum].pflags |= PF_SHRINKME;
|
player->pflags |= PF_SHRINKME;
|
||||||
|
|
||||||
if (leveltime < 2)
|
if (leveltime < 2)
|
||||||
{
|
{
|
||||||
// BAD HACK: No other place I tried to slot this in
|
// BAD HACK: No other place I tried to slot this in
|
||||||
// made it work for the host when they initally host,
|
// made it work for the host when they initally host,
|
||||||
// so this will have to do.
|
// so this will have to do.
|
||||||
K_UpdateShrinkCheat(&players[playernum]);
|
K_UpdateShrinkCheat(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Got_WeaponPref(UINT8 **cp,INT32 playernum)
|
||||||
|
{
|
||||||
|
WeaponPref_Parse(cp, playernum);
|
||||||
|
|
||||||
// SEE ALSO g_demo.c
|
// SEE ALSO g_demo.c
|
||||||
demo_extradata[playernum] |= DXD_WEAPONPREF;
|
demo_extradata[playernum] |= DXD_WEAPONPREF;
|
||||||
|
|
@ -1951,7 +1976,7 @@ void D_SendPlayerConfig(UINT8 n)
|
||||||
UINT8 *p = buf;
|
UINT8 *p = buf;
|
||||||
|
|
||||||
SendNameAndColor(n);
|
SendNameAndColor(n);
|
||||||
SendWeaponPref(n);
|
WeaponPref_Send(n);
|
||||||
|
|
||||||
if (pr != NULL)
|
if (pr != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,9 @@ void D_RegisterServerCommands(void);
|
||||||
void D_RegisterClientCommands(void);
|
void D_RegisterClientCommands(void);
|
||||||
void CleanupPlayerName(INT32 playernum, const char *newname);
|
void CleanupPlayerName(INT32 playernum, const char *newname);
|
||||||
boolean EnsurePlayerNameIsGood(char *name, INT32 playernum);
|
boolean EnsurePlayerNameIsGood(char *name, INT32 playernum);
|
||||||
void SendWeaponPref(UINT8 n);
|
void WeaponPref_Send(UINT8 ssplayer);
|
||||||
|
void WeaponPref_Save(UINT8 **cp, INT32 playernum);
|
||||||
|
void WeaponPref_Parse(UINT8 **cp, INT32 playernum);
|
||||||
void D_SendPlayerConfig(UINT8 n);
|
void D_SendPlayerConfig(UINT8 n);
|
||||||
void Command_ExitGame_f(void);
|
void Command_ExitGame_f(void);
|
||||||
void Command_Retry_f(void);
|
void Command_Retry_f(void);
|
||||||
|
|
|
||||||
22
src/g_demo.c
22
src/g_demo.c
|
|
@ -364,20 +364,7 @@ void G_ReadDemoExtraData(void)
|
||||||
}
|
}
|
||||||
if (extradata & DXD_WEAPONPREF)
|
if (extradata & DXD_WEAPONPREF)
|
||||||
{
|
{
|
||||||
i = READUINT8(demo_p);
|
WeaponPref_Parse(&demo_p, p);
|
||||||
players[p].pflags &= ~(PF_KICKSTARTACCEL|PF_SHRINKME);
|
|
||||||
if (i & 1)
|
|
||||||
players[p].pflags |= PF_KICKSTARTACCEL;
|
|
||||||
if (i & 2)
|
|
||||||
players[p].pflags |= PF_SHRINKME;
|
|
||||||
|
|
||||||
if (leveltime < 2)
|
|
||||||
{
|
|
||||||
// BAD HACK: No other place I tried to slot this in
|
|
||||||
// made it work for the host when they initally host,
|
|
||||||
// so this will have to do.
|
|
||||||
K_UpdateShrinkCheat(&players[p]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//CONS_Printf("weaponpref is %d for player %d\n", i, p);
|
//CONS_Printf("weaponpref is %d for player %d\n", i, p);
|
||||||
}
|
}
|
||||||
|
|
@ -492,12 +479,7 @@ void G_WriteDemoExtraData(void)
|
||||||
}
|
}
|
||||||
if (demo_extradata[i] & DXD_WEAPONPREF)
|
if (demo_extradata[i] & DXD_WEAPONPREF)
|
||||||
{
|
{
|
||||||
UINT8 prefs = 0;
|
WeaponPref_Save(&demo_p, i);
|
||||||
if (players[i].pflags & PF_KICKSTARTACCEL)
|
|
||||||
prefs |= 1;
|
|
||||||
if (players[i].pflags & PF_SHRINKME)
|
|
||||||
prefs |= 2;
|
|
||||||
WRITEUINT8(demo_p, prefs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1303,22 +1303,22 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n)
|
||||||
|
|
||||||
static void weaponPrefChange(void)
|
static void weaponPrefChange(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref(0);
|
WeaponPref_Send(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void weaponPrefChange2(void)
|
static void weaponPrefChange2(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref(1);
|
WeaponPref_Send(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void weaponPrefChange3(void)
|
static void weaponPrefChange3(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref(2);
|
WeaponPref_Send(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void weaponPrefChange4(void)
|
static void weaponPrefChange4(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref(3);
|
WeaponPref_Send(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue