From 42b4af7a60bcc74926250a39b23a3328af535e3c Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 4 Dec 2008 05:50:05 +0000 Subject: [PATCH] cleaner primary weapon syncing fix git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3869 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 7 +++++-- source/src/entity.h | 7 +------ source/src/server.cpp | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index aee77dca..7db749bb 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -334,7 +334,9 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) s->lifesequence = getint(p); s->health = getint(p); s->armour = getint(p); - s->selectweapon(getint(p)); + int gunselect = getint(p); + s->setprimary(gunselect); + s->selectweapon(gunselect); loopi(NUMGUNS) s->ammo[i] = getint(p); loopi(NUMGUNS) s->mag[i] = getint(p); s->state = CS_SPAWNING; @@ -460,7 +462,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { int cn = getint(p); if(p.overread() || cn<0) break; - int state = getint(p), lifesequence = getint(p), gunselect = getint(p), flagscore = getint(p), frags = getint(p), deaths = getint(p), health = getint(p), armour = getint(p); + int state = getint(p), lifesequence = getint(p), primary = getint(p), gunselect = getint(p), flagscore = getint(p), frags = getint(p), deaths = getint(p), health = getint(p), armour = getint(p); int ammo[NUMGUNS], mag[NUMGUNS]; loopi(NUMGUNS) ammo[i] = getint(p); loopi(NUMGUNS) mag[i] = getint(p); @@ -473,6 +475,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) d->deaths = deaths; if(d!=player1) { + d->setprimary(primary); d->selectweapon(gunselect); d->health = health; d->armour = armour; diff --git a/source/src/entity.h b/source/src/entity.h index 5f55273c..6631f080 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -268,12 +268,7 @@ struct playerstate additem(ammostats[GUN_PISTOL], ammo[GUN_PISTOL]); additem(ammostats[GUN_AKIMBO], ammo[GUN_AKIMBO]); break; - case I_AMMO: // ugly fix: we don't know the 'primary' of other players -> restock all ammo types - additem(ammostats[GUN_SHOTGUN], ammo[GUN_SHOTGUN]); - additem(ammostats[GUN_SUBGUN], ammo[GUN_SUBGUN]); - additem(ammostats[GUN_SNIPER], ammo[GUN_SNIPER]); - additem(ammostats[GUN_ASSAULT], ammo[GUN_ASSAULT]); - break; + case I_AMMO: additem(ammostats[primary], ammo[primary]); break; case I_GRENADE: additem(ammostats[GUN_GRENADE], mag[GUN_GRENADE]); break; case I_HEALTH: additem(powerupstats[type-I_HEALTH], health); break; case I_ARMOUR: additem(powerupstats[type-I_HEALTH], armour); break; diff --git a/source/src/server.cpp b/source/src/server.cpp index 7271add0..ff1f8982 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -2318,10 +2318,11 @@ void getservermap(void) void sendresume(client &c, bool broadcast) { - sendf(broadcast ? -1 : c.clientnum, 1, "rxii9vvi", broadcast ? c.clientnum : -1, SV_RESUME, + sendf(broadcast ? -1 : c.clientnum, 1, "rxi2i9vvi", broadcast ? c.clientnum : -1, SV_RESUME, c.clientnum, c.state.state, c.state.lifesequence, + c.state.primary, c.state.gunselect, c.state.flagscore, c.state.frags, @@ -2441,6 +2442,7 @@ void welcomepacket(ucharbuf &p, int n, ENetPacket *packet, bool forcedeath) putint(p, c.clientnum); putint(p, c.state.state); putint(p, c.state.lifesequence); + putint(p, c.state.primary); putint(p, c.state.gunselect); putint(p, c.state.flagscore); putint(p, c.state.frags);