From: MirceaKitsune Date: Wed, 1 Feb 2012 14:44:48 +0000 (+0200) Subject: Safer implementation for removing consumable items X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b63e0917014e198955774e9ef3989cb213a43e2a;p=voretournament%2Fvoretournament.git Safer implementation for removing consumable items --- diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 0dfec051..23ad3241 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -586,13 +586,6 @@ void PutObserverInServer (void) } Vore_Disconnect(); - entity e; - for(e = world; (e = find(e, classname, "consumable")); ) - { - // remove consumable items when we spectate - if(e.predator == self) - Item_Consumable_Remove(e, TRUE); - } kh_Key_DropAll(self, TRUE); @@ -863,12 +856,6 @@ void PutClientInServer (void) Vore_Disconnect(); self.swallow_progress_pred = self.swallow_progress_prey = 0; - for(e = world; (e = find(e, classname, "consumable")); ) - { - // remove consumable items when we respawn - if(e.predator == self) - Item_Consumable_Remove(e, FALSE); - } self.classname = "player"; self.wasplayer = TRUE; @@ -1638,13 +1625,6 @@ void ClientDisconnect (void) } Vore_Disconnect(); - entity e; - for(e = world; (e = find(e, classname, "consumable")); ) - { - // remove consumable items when we disconnect - if(e.predator == self) - Item_Consumable_Remove(e, TRUE); - } CheatShutdownClient(); diff --git a/data/qcsrc/server/progs.src b/data/qcsrc/server/progs.src index 4755d45d..e9ce6eb6 100644 --- a/data/qcsrc/server/progs.src +++ b/data/qcsrc/server/progs.src @@ -52,6 +52,8 @@ playerdemo.qh vore.qh +t_items.qh + scores_rules.qc miscfunctions.qc diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index 69ff60da..f785c3bc 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -221,7 +221,6 @@ void Item_ScheduleInitialRespawn(entity e) .float inithealth, initdmg; .float item_digestion_step; -void Item_Consumable_Remove(entity e, float regurgitate); void Item_Consumable_Think() { if(self.predator.regurgitate_prepare && time > self.predator.regurgitate_prepare) diff --git a/data/qcsrc/server/t_items.qh b/data/qcsrc/server/t_items.qh new file mode 100644 index 00000000..05261108 --- /dev/null +++ b/data/qcsrc/server/t_items.qh @@ -0,0 +1 @@ +void Item_Consumable_Remove(entity e, float regurgitate); diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index ef7f0291..87baed61 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -430,6 +430,7 @@ void Vore_Regurgitate(entity e) void Vore_Disconnect() { // frees prey from their predators when someone disconnects or goes spectating, or in other circumstances + entity e; // prey disconnects or goes spectating while inside someone's belly if(self.stat_eaten) @@ -442,6 +443,12 @@ void Vore_Disconnect() if(head.predator == self) Vore_Regurgitate(head); } + // remove consumable items when we disconnect + for(e = world; (e = find(e, classname, "consumable")); ) + { + if(e.predator == self) + Item_Consumable_Remove(e, TRUE); + } self.stomach_load = self.gravity = 0; // prevents a bug Vore_GurgleSound(); // stop the gurgling sound