Skip to content

Commit

Permalink
port: net: fix dualwielding, probably; bump protocol version
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed Dec 29, 2023
1 parent bcb5b3f commit f46e112
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
9 changes: 5 additions & 4 deletions port/include/net/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions port/src/net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion port/src/net/netmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down
5 changes: 4 additions & 1 deletion src/game/bondmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down

0 comments on commit f46e112

Please sign in to comment.