From c288c9829bbba8a1bee2d3670291da530958348d Mon Sep 17 00:00:00 2001 From: driAn Date: Fri, 23 May 2008 20:35:53 +0000 Subject: [PATCH] detach sounds from disconnecting player git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2092 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 1 - source/src/entity.h | 12 ++++++++++++ source/src/protos.h | 1 + source/src/sound.cpp | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 27d9e3fe..5799389f 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -203,7 +203,6 @@ void freebotent(botent *d) void zapplayer(playerent *&d) { - removebounceents(d); DELETEP(d); } diff --git a/source/src/entity.h b/source/src/entity.h index b1ec597d..b8a35e73 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -172,6 +172,7 @@ struct dynent : physent // animated ent } dynent() { reset(); resetanim(); } + virtual ~dynent() {} }; #define MAXNAMELEN 15 @@ -368,6 +369,17 @@ struct playerent : dynent, playerstate respawn(); } + virtual ~playerent() + { + extern void removebounceents(playerent *owner); + extern void detachsounds(playerent *owner); + extern physent *camera1; + extern void togglespect(); + removebounceents(this); + detachsounds(this); + if(this==camera1) togglespect(); + } + void damageroll(float damage) { float damroll = 2.0f*damage; diff --git a/source/src/protos.h b/source/src/protos.h index b25f2955..c1aaae3d 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -497,6 +497,7 @@ extern void checkplayerloopsounds(); extern void musicsuggest(int id, int millis = 0, bool rndofs = false); extern void musicfadeout(int id); extern void clearsounds(); +extern void detachsounds(playerent *owner); // rendermodel extern void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, float yaw, float pitch, float speed = 0, int basetime = 0, playerent *d = NULL, modelattach *a = NULL, float scale = 1.0f); diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 7bbad89e..258a0fa8 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -980,6 +980,16 @@ void playsoundname(char *s, const vec *loc, int vol) void sound(int n) { playsound(n); } COMMAND(sound, ARG_1INT); +void detachsounds(playerent *owner) +{ + loopv(locations) + { + location &l = locations[i]; + if(l.p != owner) continue; + l.attachtoworldobj(new vec(l.p->o)); + } +} + void playsoundc(int n) { addmsg(SV_SOUND, "i", n);