X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Ftarget_spawn.qc;h=b4b9b1830509f846efa7aa64f3d701600a07974b;hb=931a2648cb8ff8083a0af9ea06841d548e4d461b;hp=55029775454e3b4202539ee60b5e70d91aeb8985;hpb=1f988ad58a9fb5cef7ed843ad839b23dd23f6dc9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/target_spawn.qc b/qcsrc/server/target_spawn.qc index 550297754..b4b9b1830 100644 --- a/qcsrc/server/target_spawn.qc +++ b/qcsrc/server/target_spawn.qc @@ -1,3 +1,12 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "../dpdefs/progsdefs.qh" + #include "../dpdefs/dpextensions.qh" + #include "../common/util.qh" + #include "defs.qh" +#endif + // spawner entity // "classname" "target_spawn" // "message" "fieldname value fieldname value ..." @@ -39,13 +48,13 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity value = argv(i+1); if(key == "$") { - data_x = -1; - data_y = FIELD_STRING; + data.x = -1; + data.y = FIELD_STRING; } else { data = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", key))); - if(data_y == 0) // undefined field, i.e., invalid type + if(data.y == 0) // undefined field, i.e., invalid type { print("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n"); continue; @@ -169,7 +178,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity if(valueoffset != "") { - switch(data_y) + switch(data.y) { case FIELD_STRING: value = strcat(value, valueoffset); @@ -188,7 +197,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity if(valueoffsetrandom != "") { - switch(data_y) + switch(data.y) { case FIELD_FLOAT: value = ftos(stof(value) + random() * stof(valueoffsetrandom)); @@ -216,17 +225,19 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity self = e; activator = act; - if(self.target_spawn_spawnfunc) - self.target_spawn_spawnfunc(); + self.target_spawn_spawnfunc(); self = oldself; activator = oldactivator; + + // We called an external function, so we have to re-tokenize msg. + n = tokenize_console(msg); } else { - if(data_y == FIELD_VECTOR) + if(data.y == FIELD_VECTOR) value = strreplace("'", "", value); // why?!? - putentityfieldstring(data_x, e, value); + putentityfieldstring(data.x, e, value); } } } @@ -257,7 +268,7 @@ float target_spawn_cancreate() ++c; // increase count to not include MYSELF for(e = world; (e = findfloat(e, target_spawn_id, self.target_spawn_id)); --c) ; - + // if c now is 0, we have AT LEAST the given count (maybe more), so don't spawn any more if(c == 0) return 0; @@ -314,7 +325,7 @@ void initialize_field_db() ft = entityfieldtype(i); new = 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) + if(prev.y == 0) { db_put(TemporaryDB, strcat("/target_spawn/field/", fn), vtos(new)); if(fn == "target_spawn_spawnfunc")