From f46e112c3defee0a1c8d693759f3725ce348d81c Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 29 Dec 2023 02:06:12 +0100 Subject: [PATCH] port: net: fix dualwielding, probably; bump protocol version --- port/include/net/net.h | 9 +++++---- port/src/net/net.c | 7 +++++++ port/src/net/netmsg.c | 5 ++++- src/game/bondmove.c | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/port/include/net/net.h b/port/include/net/net.h index 80ae4df05..a67a35c3f 100644 --- a/port/include/net/net.h +++ b/port/include/net/net.h @@ -5,7 +5,7 @@ #include "constants.h" #include "net/netbuf.h" -#define NET_PROTOCOL_VER 5 +#define NET_PROTOCOL_VER 6 #define NET_MAX_CLIENTS MAX_PLAYERS #define NET_MAX_NAME MAX_PLAYERNAME @@ -46,11 +46,12 @@ #define UCMD_SQUAT (1 << 5) #define UCMD_ZOOMIN (1 << 6) #define UCMD_SELECT (1 << 7) -#define UCMD_EYESSHUT (1 << 8) -#define UCMD_SECONDARY (1 << 9) +#define UCMD_SELECT_DUAL (1 << 8) +#define UCMD_EYESSHUT (1 << 9) +#define UCMD_SECONDARY (1 << 10) #define UCMD_RESPAWN (1 << 27) #define UCMD_CHAT (1 << 28) -#define UCMD_IMPORTANT_MASK (UCMD_FIRE | UCMD_ACTIVATE | UCMD_RELOAD | UCMD_AIMMODE | UCMD_SELECT) +#define UCMD_IMPORTANT_MASK (UCMD_FIRE | UCMD_ACTIVATE | UCMD_RELOAD | UCMD_AIMMODE | UCMD_SELECT | UCMD_SELECT_DUAL) #define UCMD_FL_FORCEPOS (1 << 29) #define UCMD_FL_FORCEANGLE (1 << 30) #define UCMD_FL_FORCEGROUND (1 << 31) diff --git a/port/src/net/net.c b/port/src/net/net.c index 719177f32..726d8b91b 100644 --- a/port/src/net/net.c +++ b/port/src/net/net.c @@ -208,6 +208,13 @@ static inline void netClientRecordMove(struct netclient *cl, const struct player move->weaponnum = -1; } + if (pl->gunctrl.dualwielding) { + move->ucmd |= UCMD_SELECT_DUAL; + if ((move->ucmd ^ cl->outmove[1].ucmd) & UCMD_SELECT_DUAL) { + move->ucmd |= UCMD_SELECT; + } + } + const s32 oldnum = g_Vars.currentplayernum; setCurrentPlayerNum(cl->playernum); diff --git a/port/src/net/netmsg.c b/port/src/net/netmsg.c index 94b684813..a1cc4f204 100644 --- a/port/src/net/netmsg.c +++ b/port/src/net/netmsg.c @@ -686,8 +686,8 @@ u32 netmsgSvcPlayerStatsRead(struct netbuf *src, struct netclient *srccl) const bool dualwielding = (flags & (1 << 1)) != 0; if (!pl->isdead && (newweaponnum != pl->gunctrl.weaponnum || dualwielding != pl->gunctrl.dualwielding)) { - bgunEquipWeapon(newweaponnum); pl->gunctrl.dualwielding = dualwielding; + bgunEquipWeapon(newweaponnum); } setCurrentPlayerNum(prevplayernum); @@ -875,6 +875,7 @@ u32 netmsgSvcPropSpawnWrite(struct netbuf *dst, struct prop *prop) netbufWriteU32(dst, prop->obj->hidden); netbufWriteU8(dst, prop->obj->hidden2); netbufWriteU16(dst, prop->obj->extrascale); + netbufWriteS16(dst, prop->obj->pad); for (s32 i = 0; i < 3; ++i) { for (s32 j = 0; j < 3; ++j) { netbufWriteF32(dst, prop->obj->realrot[i][j]); @@ -1019,6 +1020,7 @@ u32 netmsgSvcPropSpawnRead(struct netbuf *src, struct netclient *srccl) u32 hidden = netbufReadU32(src); const u8 hidden2 = netbufReadU8(src); const u16 extrascale = netbufReadU16(src); + const s16 pad = netbufReadS16(src); for (s32 i = 0; i < 3; ++i) { for (s32 j = 0; j < 3; ++j) { prop->obj->realrot[i][j] = netbufReadF32(src); @@ -1059,6 +1061,7 @@ u32 netmsgSvcPropSpawnRead(struct netbuf *src, struct netclient *srccl) prop->obj->hidden = hidden; prop->obj->hidden2 = hidden2; prop->obj->extrascale = extrascale; + prop->obj->pad = pad; if (prop->obj->model) { modelSetScale(prop->obj->model, prop->obj->model->scale * ((f32)extrascale / 256.f)); } diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 1f3fb8169..73c0752c3 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -149,7 +149,10 @@ static inline void bmoveProcessRemoteInput(const bool allowc1buttons) pl->crosspos[1] = inmove->crosspos[1]; if (inmove->ucmd & UCMD_SELECT) { - bgunEquipWeapon(inmove->weaponnum); + pl->gunctrl.dualwielding = (inmove->ucmd & UCMD_SELECT_DUAL) != 0; + if (inmove->weaponnum >= 0) { + bgunEquipWeapon(inmove->weaponnum); + } } const bool fireguns = (inmove->ucmd & UCMD_FIRE) &&