From 9a6ea9db042e459e0af2156700726a172fcfd6fa Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 6 Oct 2010 18:26:04 +0000 Subject: [PATCH] fix suicides not killing people git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5714 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/command.cpp | 2 ++ source/src/entity.h | 7 +++++++ source/src/server.cpp | 22 +++++++++++++--------- source/src/serverevents.h | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index f9ac0985..daf10c82 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -405,11 +405,13 @@ void floatret(float v) void result(const char *s) { commandret = newstring(s); } +#if 0 // seer : script evaluation excessive recursion static int seer_count = 0; // count calls to executeret, check time every n1 (100) calls static int seer_index = -1; // position in timestamp vector vector seer_t1; // timestamp of last n2 (10) level-1 calls vector seer_t2; // timestamp of last n3 (10) level-2 calls +#endif char *executeret(const char *p) // all evaluation happens here, recursively { bool noproblem = true; diff --git a/source/src/entity.h b/source/src/entity.h index 4a75e689..17b90d39 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -332,6 +332,13 @@ public: // just subtract damage here, can set death, etc. later in code calling this int dodamage(int damage) { + if(damage == INT_MAX) + { + damage = health; + armour = health = 0; + return damage; + } + /* 4-level armor - continous approach: 16%, 33%, 37%, 41% */ int armoursection = 0; int ad = damage; diff --git a/source/src/server.cpp b/source/src/server.cpp index 13be76e9..a5ffe6fa 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1302,16 +1302,20 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib, if ( m_arena && gun == GUN_GRENADE && arenaroundstartmillis + 2000 > gamemillis && target != actor ) return; clientstate &ts = target->state; ts.dodamage(damage); - actor->state.damage += damage != 1000 ? damage : 0; - sendf(-1, 1, "ri7", gib ? SV_GIBDAMAGE : SV_DAMAGE, target->clientnum, actor->clientnum, gun, damage, ts.armour, ts.health); - if(target!=actor){ - checkcombo (target, actor, damage, gun); - if(!hitpush.iszero()) + if(damage < INT_MAX) + { + actor->state.damage += damage; + sendf(-1, 1, "ri7", gib ? SV_GIBDAMAGE : SV_DAMAGE, target->clientnum, actor->clientnum, gun, damage, ts.armour, ts.health); + if(target!=actor) { - vec v(hitpush); - if(!v.iszero()) v.normalize(); - sendf(target->clientnum, 1, "ri6", SV_HITPUSH, gun, damage, - int(v.x*DNF), int(v.y*DNF), int(v.z*DNF)); + checkcombo (target, actor, damage, gun); + if(!hitpush.iszero()) + { + vec v(hitpush); + if(!v.iszero()) v.normalize(); + sendf(target->clientnum, 1, "ri6", SV_HITPUSH, gun, damage, + int(v.x*DNF), int(v.y*DNF), int(v.z*DNF)); + } } } if(ts.health<=0) diff --git a/source/src/serverevents.h b/source/src/serverevents.h index ac74895c..83926fad 100644 --- a/source/src/serverevents.h +++ b/source/src/serverevents.h @@ -79,7 +79,7 @@ void processevent(client *c, shotevent &e) void processevent(client *c, suicideevent &e) { - serverdamage(c, c, 1000, GUN_KNIFE, false); + serverdamage(c, c, INT_MAX, GUN_KNIFE, false); } void processevent(client *c, pickupevent &e)