From: Mircea Kitsune Date: Wed, 4 Jan 2012 19:51:04 +0000 (+0200) Subject: Use a different and smarter way to go through the bones of a model. The previous... X-Git-Tag: xonotic-v0.6.0~110^2^2~66 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c23e98576c85491afbdb69be9ed66fb4deaa858a;p=xonotic%2Fxonotic-data.pk3dir.git Use a different and smarter way to go through the bones of a model. The previous loop had a bug which would eventually crash CSQC. Also use this for the sandbox to fix the same issue. --- diff --git a/qcsrc/client/damage.qc b/qcsrc/client/damage.qc index ae7440500..9130f972a 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/client/damage.qc @@ -301,7 +301,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum, float ent } float closest; - for(i = 0; gettaginfo(self, i); i++) + FOR_EACH_TAG(self) { // go through all tags on the player model, choose the one closest to the damage origin if(!closest || vlen(hitorg - gettaginfo(self, i)) <= vlen(hitorg - gettaginfo(self, closest))) diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 6d4eb6113..f4f8970d5 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -279,3 +279,8 @@ entity ReadCSQCEntity() // generic shutdown handler void Shutdown(); + +#ifndef MENUQC +// loop that goes through all the bones of a model +#define FOR_EACH_TAG(v) for(i = 1, gettaginfo(v, i);; i++, gettaginfo(v, i)) if not(gettaginfo_name) break; else +#endif diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 66377d1d8..e7f51aa88 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -744,7 +744,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) print_to(self, strcat("^2SANDBOX - INFO: ^7Object is owned by \"^7", e.netname, "^7\", created \"^3", e.message, "^7\", last edited \"^3", e.message2, "^7\"")); return TRUE; case "mesh": - for(i = 1; gettaginfo(e, i); i++) + FOR_EACH_TAG(e) s = strcat(s, "^7\"^5", gettaginfo_name, "^7\", "); print_to(self, strcat("^2SANDBOX - INFO: ^7Object mesh is \"^3", e.model, "^7\" at animation frame ^3", ftos(e.frame), " ^7containing the following tags: ", s)); return TRUE;