diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index aa5cf264..667f38b4 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -325,10 +325,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) loopk(3) from[k] = getint(p)/DMF; loopk(3) to[k] = getint(p)/DMF; playerent *s = getclient(scn); - if(!s) break; + if(!s || !weapon::valid(gun)) break; if(gun==GUN_SHOTGUN) createrays(from, to); s->lastaction = lastmillis; - //s->lastattackweapon = s->weaponsel; + s->mag[gun]--; if(s->weapons[gun]) { s->lastattackweapon = s->weapons[gun]; @@ -350,6 +350,17 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } + case SV_RELOAD: + { + int cn = getint(p), gun = getint(p); + playerent *p = cn==getclientnum() ? player1 : getclient(cn); + if(!p || p==player1) break; + int bullets = magsize(gun)-p->mag[gun]; + p->ammo[gun] -= bullets; + p->mag[gun] += bullets; + break; + } + case SV_GIBDAMAGE: case SV_DAMAGE: { @@ -395,7 +406,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { int cn = getint(p); if(cn<0) break; - int state = getint(p), lifesequence = getint(p), gunselect = getint(p), flagscore = getint(p), frags = getint(p), deaths = getint(p); + 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); playerent *d = (cn == getclientnum() ? player1 : newclient(cn)); if(!d) continue; if(d!=player1) d->state = state; @@ -404,6 +415,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) d->frags = frags; d->deaths = deaths; d->selectweapon(gunselect); + d->health = health; + d->armour = armour; + loopi(NUMGUNS) d->ammo[i] = getint(p); + loopi(NUMGUNS) d->mag[i] = getint(p); } break; } @@ -666,28 +681,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } - case SV_HEALTHINFO: - { - int cn = getint(p); - playerent *pl = cn == getclientnum() ? player1 : getclient(cn); - if(!pl) return; - pl->health = getuint(p); - pl->armour = getuint(p); - break; - } - - case SV_AMMOINFO: - { - int cn = getint(p); - playerent *pl = cn == getclientnum() ? player1 : getclient(cn); - if(!pl) return; - int weapon = pl->gunselect; - if(weapon<0 || weapon>=NUMGUNS) return; - pl->mag[weapon] = getuint(p); - pl->ammo[weapon] = getuint(p); - break; - } - default: neterr("type"); return; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 08cd1aad..b21bf99b 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -367,7 +367,11 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) if(timeinair > 200 && !pl->timeinair) { int sound = timeinair > 800 ? S_HARDLAND : S_SOFTLAND; - if(local) playsoundc(sound); else playsound(sound, pl); + if(pl->state!=CS_DEAD) + { + if(local) playsoundc(sound); + else playsound(sound, pl); + } } const float gravity = 20.0f; diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index c954df5b..9c6b3c66 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -118,7 +118,7 @@ char msgsizesl[] = // size inclusive message token, 0 for variable SV_INITS2C, 5, SV_INITC2S, 0, SV_POS, 0, SV_TEXT, 0, SV_TEAMTEXT, 0, SV_SOUND, 2, SV_VOICECOM, 2, SV_VOICECOMTEAM, 2, SV_CDIS, 2, SV_SHOOT, 0, SV_EXPLODE, 0, SV_SUICIDE, 1, SV_AKIMBO, 2, SV_RELOAD, 3, SV_GIBDIED, 4, SV_DIED, 4, SV_GIBDAMAGE, 6, SV_DAMAGE, 6, SV_HITPUSH, 6, SV_SHOTFX, 9, SV_THROWNADE, 8, - SV_TRYSPAWN, 1, SV_SPAWNSTATE, 20, SV_SPAWN, 3, SV_FORCEDEATH, 2, SV_RESUME, 0, + SV_TRYSPAWN, 1, SV_SPAWNSTATE, 22, SV_SPAWN, 3, SV_FORCEDEATH, 2, SV_RESUME, 0, SV_TIMEUP, 2, SV_EDITENT, 10, SV_MAPRELOAD, 2, SV_NEXTMAP, 0, SV_ITEMACC, 2, SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 2, SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2, @@ -131,7 +131,6 @@ char msgsizesl[] = // size inclusive message token, 0 for variable SV_CALLVOTE, 0, SV_CALLVOTESUC, 1, SV_CALLVOTEERR, 2, SV_VOTE, 2, SV_VOTERESULT, 2, SV_FORCETEAM, 2, SV_AUTOTEAM, 2, SV_CHANGETEAM, 1, SV_WHOIS, 2, SV_WHOISINFO, 3, - SV_HEALTHINFO, 4, SV_AMMOINFO, 4, SV_LISTDEMOS, 1, SV_SENDDEMOLIST, 0, SV_GETDEMO, 2, SV_SENDDEMO, 0, SV_DEMOPLAYBACK, 2, SV_CONNECT, 0, SV_CLIENT, 0, diff --git a/source/src/protocol.h b/source/src/protocol.h index 29f37b7d..055f9764 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -28,7 +28,6 @@ enum SV_CALLVOTE, SV_CALLVOTESUC, SV_CALLVOTEERR, SV_VOTE, SV_VOTERESULT, SV_FORCETEAM, SV_AUTOTEAM, SV_CHANGETEAM, SV_WHOIS, SV_WHOISINFO, - SV_HEALTHINFO, SV_AMMOINFO, SV_LISTDEMOS, SV_SENDDEMOLIST, SV_GETDEMO, SV_SENDDEMO, SV_DEMOPLAYBACK, SV_CONNECT, SV_CLIENT diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index e9700fb9..6efaf5dd 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -503,9 +503,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat { glLoadIdentity(); glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); - - bool onlinespectating = spectating && multiplayer(false); - if(!hidehudequipment && !onlinespectating) + + if(!hidehudequipment) { draw_textf("%d", 90, 827, p->health); if(p->armour) draw_textf("%d", 390, 827, p->armour); diff --git a/source/src/server.cpp b/source/src/server.cpp index aeb4ab8b..ae058bc8 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -14,7 +14,6 @@ #include "servercontroller.h" void resetmap(const char *newname, int newmode, int newtime = -1, bool notify = true); -void recordclientinfo(int cn); servercontroller *svcctrl = NULL; struct log *logger = NULL; @@ -336,7 +335,6 @@ bool buildworldstate() int psize = ws.positions.length(), msize = ws.messages.length(); if(psize) recordpacket(0, ws.positions.getbuf(), psize); if(msize) recordpacket(1, ws.messages.getbuf(), msize); - loopv(clients) recordclientinfo(i); loopi(psize) { uchar c = ws.positions[i]; ws.positions.add(c); } loopi(msize) { uchar c = ws.messages[i]; ws.messages.add(c); } ws.uses = 0; @@ -567,41 +565,6 @@ void recordpacket(int chan, void *data, int len) if(recordpackets) writedemo(chan, data, len); } -enum -{ - DF_NONE = 0, - DF_HEALTHCHANGED = 1<<0, - DF_AMMOCHANGED = 1<<1 -}; - -void recordclientinfo(int cn) -{ - if(!demorecord || !valid_client(cn)) return; - client *c = clients[cn]; - if(c->demoflags==DF_NONE) return; - - uchar buf[MAXTRANS]; - ucharbuf p(buf, sizeof(buf)); - if(c->demoflags&DF_HEALTHCHANGED) - { - putint(p, SV_HEALTHINFO); - putuint(p, c->clientnum); - putuint(p, c->state.health); - putuint(p, c->state.armour); - } - if(c->demoflags&DF_AMMOCHANGED) - { - int weapon = c->state.gunselect; - putint(p, SV_AMMOINFO); - putuint(p, c->clientnum); - putuint(p, c->state.mag[weapon]); - putuint(p, c->state.ammo[weapon]); - } - writedemo(1, buf, p.len); - - c->demoflags = DF_NONE; -} - void enddemorecord() { if(!demorecord) return; @@ -1059,7 +1022,6 @@ bool serverpickup(int i, int sender) // server side item pickup, acknowl } sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); cl->state.pickup(sents[i].type); - cl->demoflags |= (sents[i].type==I_HEALTH || sents[i].type==I_ARMOUR) ? DF_HEALTHCHANGED : DF_AMMOCHANGED; } e.spawned = false; e.spawntime = spawntime(e.type); @@ -1114,7 +1076,6 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib, if(actor->state.frags < scorethreshold) disconnect_client(actor->clientnum, DISC_AUTOKICK); } - target->demoflags |= DF_HEALTHCHANGED; } #include "serverevents.h" @@ -1529,6 +1490,10 @@ void welcomepacket(ucharbuf &p, int n) putint(p, c.state.flagscore); putint(p, c.state.frags); putint(p, c.state.deaths); + putint(p, c.state.health); + putint(p, c.state.armour); + loopi(NUMGUNS) putint(p, c.state.ammo[i]); + loopi(NUMGUNS) putint(p, c.state.mag[i]); } putint(p, -1); } diff --git a/source/src/serverevents.h b/source/src/serverevents.h index 6f0697d9..03538cfd 100644 --- a/source/src/serverevents.h +++ b/source/src/serverevents.h @@ -41,7 +41,6 @@ void processevent(client *c, shotevent &e) loopi(NUMGUNS) if(gs.gunwait[i]) gs.gunwait[i] = max(gs.gunwait[i] - (e.millis-gs.lastshot), 0); gs.lastshot = e.millis; gs.gunwait[e.gun] = attackdelay(e.gun); - c->demoflags |= DF_AMMOCHANGED; if(e.gun==GUN_PISTOL && gs.akimbomillis>gamemillis) gs.gunwait[e.gun] /= 2; sendf(-1, 1, "ri9x", SV_SHOTFX, c->clientnum, e.gun, int(e.from[0]*DMF), int(e.from[1]*DMF), int(e.from[2]*DMF), @@ -88,7 +87,6 @@ void processevent(client *c, suicideevent &e) gs.state = CS_DEAD; gs.respawn(); logger->writeline(log::info, "[%s] %s suicided", c->hostname, c->name); - c->demoflags |= DF_HEALTHCHANGED; } void processevent(client *c, pickupevent &e) @@ -115,6 +113,7 @@ void processevent(client *c, reloadevent &e) gs.ammo[e.gun] -= numbullets; int wait = e.millis - gs.lastshot; + sendf(-1, 1, "ri3", SV_RELOAD, c->clientnum, e.gun); if(gs.gunwait[e.gun] && waitdemoflags |= DF_AMMOCHANGED; } void processevent(client *c, akimboevent &e) @@ -131,7 +129,6 @@ void processevent(client *c, akimboevent &e) if(!gs.isalive(gamemillis) || gs.akimbos<=0) return; gs.akimbos--; gs.akimbomillis = e.millis+30000; - c->demoflags |= DF_AMMOCHANGED; } void clearevent(client *c) diff --git a/source/src/sound.cpp b/source/src/sound.cpp index d9ad1d5a..05c448f7 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -757,7 +757,7 @@ void updatepitch() // set lower pitch if "player's ear got damaged" { if(camera1->type!=ENT_PLAYER) return; playerent *p = (playerent *) camera1; - float pitch = lastmillis>p->eardamagemillis ? 1.0f : 0.65f; + float pitch = lastmillis<=p->eardamagemillis && p->state!=CS_DEAD ? 0.65 : 1.0f; if(pitch==lastpitch) return; loopv(locations) locations[i].pitch(pitch); lastpitch = pitch; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 8ea06415..a8b827ea 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -531,6 +531,7 @@ void weapon::equipplayer(playerent *pl) pl->setnextprimary(GUN_ASSAULT); } +bool weapon::valid(int id) { return id>=0 && idakimbo) owner->weaponswitch(owner->weapons[GUN_AKIMBO]); - else gun::onselecting(); -} +bool pistol::selectable() { return weapon::selectable() && !m_nopistol && !owner->akimbo; } // akimbo diff --git a/source/src/weapon.h b/source/src/weapon.h index 6c30f91c..1d0176a9 100644 --- a/source/src/weapon.h +++ b/source/src/weapon.h @@ -41,6 +41,8 @@ struct weapon void sendshoot(vec &from, vec &to); bool modelattacking(); void renderhudmodel(int lastaction, int index = 0); + + static bool valid(int id); }; struct grenadeent; @@ -130,7 +132,6 @@ struct pistol : gun { pistol(playerent *owner); bool selectable(); - void onselecting(); };