From 4176266ad9d5759074ebf8512cb2c7df2db8189e Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 17 Nov 2007 14:36:59 +0000 Subject: [PATCH] grenade sound fix git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1433 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 4 ++-- source/src/weapon.cpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index f9fcc9f6..da6d4fff 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -279,11 +279,11 @@ 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 || gun==GUN_GRENADE) break; + if(!s) break; if(gun==GUN_SHOTGUN) createrays(from, to); s->lastaction = lastmillis; s->lastattackgun = s->gunselect; - shootv(gun, from, to, s, false, 0); + shootv(gun, from, to, s, false, -1); break; } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 08e50ca9..e7187afc 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -519,6 +519,8 @@ void thrownade(playerent *d, const vec &vel, bounceent *p) d->thrownademillis = lastmillis; d->inhandnade = NULL; + playsound(S_GRENADETHROW); + if(d==player1) { updatelastaction(player1); @@ -547,7 +549,7 @@ bounceent *newnade(playerent *d, int millis = 0) d->inhandnade = p; d->thrownademillis = 0; - if(d==player1) playsoundc(S_GRENADEPULL); + playsoundc(S_GRENADEPULL); return p; } @@ -561,7 +563,7 @@ void explode_nade(bounceent *i) void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademillis) // create visual effect from a shot { - if(guns[gun].sound) playsound(guns[gun].sound, d==player1 ? NULL : d); + if(guns[gun].sound != S_NULL) playsound(guns[gun].sound, d==player1 ? NULL : d); switch(gun) { case GUN_KNIFE: @@ -592,8 +594,15 @@ void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademilli { if(d!=player1) { - bounceent *p = newnade(d, nademillis); - thrownade(d, to, p); + if(nademillis == -1) // activate + { + playsound(S_GRENADEPULL); + } + else if(nademillis >= 0) // throw + { + bounceent *p = newnade(d, nademillis); + thrownade(d, to, p); + } } break; }