X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftarget%2Fspawn.qc;h=6572221f75a9e008d6c7668e2ff15758a0fb32a7;hb=eeec5ec4584c71acbb89db6eea843b48d6ca4c26;hp=98a3209cc546e18af722de4799d41e5c831a71bc;hpb=6dc9591eba337374f2b4348a6a6deaa1cb6887d0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/target/spawn.qc b/qcsrc/common/triggers/target/spawn.qc index 98a3209cc..6572221f7 100644 --- a/qcsrc/common/triggers/target/spawn.qc +++ b/qcsrc/common/triggers/target/spawn.qc @@ -1,8 +1,7 @@ #if defined(CSQC) #elif defined(MENUQC) #elif defined(SVQC) - #include "../../../dpdefs/progsdefs.qh" - #include "../../../dpdefs/dpextensions.qh" + #include "../../../server/_all.qh" #include "../../util.qh" #include "../../../server/defs.qh" #endif @@ -24,22 +23,21 @@ float target_spawn_spawnfunc_field; float target_spawn_count; void target_spawn_helper_setmodel() -{ +{SELFPARAM(); setmodel(self, self.model); } void target_spawn_helper_setsize() -{ +{SELFPARAM(); setsize(self, self.mins, self.maxs); } void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity t3, entity t4, entity act) -{ +{SELFPARAM(); float i, n, valuefieldpos; string key, value, valuefield, valueoffset, valueoffsetrandom; entity valueent; vector data, data2; - entity oldself; entity oldactivator; n = tokenize_console(msg); @@ -58,7 +56,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity data = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", key))); if(data.y == 0) // undefined field, i.e., invalid type { - print("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n"); + LOG_INFO("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n"); continue; } } @@ -153,7 +151,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity } else { - print("target_spawn: invalid/unknown variable replacement ", value, " specified, ignored!\n"); + LOG_INFO("target_spawn: invalid/unknown variable replacement ", value, " specified, ignored!\n"); continue; } @@ -166,13 +164,13 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity { if(value != "") { - print("target_spawn: try to get a field of a non-entity, ignored!\n"); + LOG_INFO("target_spawn: try to get a field of a non-entity, ignored!\n"); continue; } data2 = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", valuefield))); if(data2_y == 0) // undefined field, i.e., invalid type { - print("target_spawn: invalid/unknown entity key replacement ", valuefield, " specified, ignored!\n"); + LOG_INFO("target_spawn: invalid/unknown entity key replacement ", valuefield, " specified, ignored!\n"); continue; } value = getentityfieldstring(data2_x, valueent); @@ -192,7 +190,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity value = vtos(stov(value) + stov(valueoffset)); break; default: - print("target_spawn: only string, float and vector fields can do calculations, calculation ignored!\n"); + LOG_INFO("target_spawn: only string, float and vector fields can do calculations, calculation ignored!\n"); break; } } @@ -209,7 +207,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity value = vtos(stov(value) + random() * data2_x * '1 0 0' + random() * data2_y * '0 1 0' + random() * data2_z * '0 0 1'); break; default: - print("target_spawn: only float and vector fields can do random calculations, calculation ignored!\n"); + LOG_INFO("target_spawn: only float and vector fields can do random calculations, calculation ignored!\n"); break; } } @@ -221,16 +219,14 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity value = strcat("target_spawn_helper", value); putentityfieldstring(target_spawn_spawnfunc_field, e, value); - oldself = self; oldactivator = activator; - self = e; activator = act; - - self.target_spawn_spawnfunc(); - - self = oldself; + WITH(entity, self, e, e.target_spawn_spawnfunc()); activator = oldactivator; + + // We called an external function, so we have to re-tokenize msg. + n = tokenize_console(msg); } else { @@ -242,7 +238,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity } void target_spawn_useon(entity e) -{ +{SELFPARAM(); self.target_spawn_activator = activator; target_spawn_edit_entity( e, @@ -256,7 +252,7 @@ void target_spawn_useon(entity e) } float target_spawn_cancreate() -{ +{SELFPARAM(); float c; entity e; @@ -275,7 +271,7 @@ float target_spawn_cancreate() } void target_spawn_use() -{ +{SELFPARAM(); entity e; if(self.target == "") @@ -302,7 +298,7 @@ void target_spawn_use() } void target_spawn_spawnfirst() -{ +{SELFPARAM(); activator = self.target_spawn_activator; if(self.spawnflags & 2) target_spawn_use(); @@ -314,7 +310,7 @@ void initialize_field_db() { float n, i; string fn; - vector prev, new; + vector prev, next; float ft; n = numentityfields(); @@ -322,11 +318,11 @@ void initialize_field_db() { fn = entityfieldname(i); ft = entityfieldtype(i); - new = i * '1 0 0' + ft * '0 1 0' + '0 0 1'; + next = i * '1 0 0' + ft * '0 1 0' + '0 0 1'; prev = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", fn))); if(prev.y == 0) { - db_put(TemporaryDB, strcat("/target_spawn/field/", fn), vtos(new)); + db_put(TemporaryDB, strcat("/target_spawn/field/", fn), vtos(next)); if(fn == "target_spawn_spawnfunc") target_spawn_spawnfunc_field = i; } @@ -337,7 +333,7 @@ void initialize_field_db() } void spawnfunc_target_spawn() -{ +{SELFPARAM(); initialize_field_db(); self.use = target_spawn_use; self.message = strzone(strreplace("'", "\"", self.message));