From: TimePath Date: Mon, 31 Aug 2015 03:28:34 +0000 (+1000) Subject: Fix InitializeEntitiesRun() X-Git-Tag: xonotic-v0.8.2~1931^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=07bb44cc4f74e4e908587df687a66b7ad25a0a82;p=xonotic%2Fxonotic-data.pk3dir.git Fix InitializeEntitiesRun() --- diff --git a/qcsrc/lib/Log.qh b/qcsrc/lib/Log.qh index cd99ebf97..f74dd4aa2 100644 --- a/qcsrc/lib/Log.qh +++ b/qcsrc/lib/Log.qh @@ -7,6 +7,8 @@ #define dprintf(...) dprint(sprintf(__VA_ARGS__)) #define _dprintf2(...) do { if (autocvar_developer > 1) dprintf(__VA_ARGS__); } while (0) +#define assert(expr, ...) do { if (!(expr)) LOG_WARNINGF(__VA_ARGS__); } while (0) + #define _LOG(f, level, s) f("[::"level"] ["__FILE__":%s:%.0f] %s", __FUNC__, __LINE__, s) #define LOG_FATAL(...) _LOG_FATAL(strcat("", __VA_ARGS__)) diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 2b1f42f0f..c3891bf24 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1144,10 +1144,8 @@ void InitializeEntity(entity e, void(void) func, float order) if (!e || e.initialize_entity) { // make a proxy initializer entity - entity e_old; - e_old = e; - e = spawn(); - e.classname = "initialize_entity"; + entity e_old = e; + e = new(initialize_entity); e.enemy = e_old; } @@ -1174,45 +1172,46 @@ void InitializeEntity(entity e, void(void) func, float order) } void InitializeEntitiesRun() {SELFPARAM(); - entity startoflist; - startoflist = initialize_entity_first; - initialize_entity_first = world; + entity startoflist = initialize_entity_first; + initialize_entity_first = NULL; remove = remove_except_protected; for (entity e = startoflist; e; e = e.initialize_entity_next) { e.remove_except_protected_forbidden = 1; } - for (entity e_ = startoflist; e_; ) + for (entity e = startoflist; e; ) { - setself(e_); - entity e = e_.initialize_entity_next; - var void(void) func = e_.initialize_entity; - e_.initialize_entity_order = 0; - e_.initialize_entity = func_null; - e_.initialize_entity_next = world; - e_.remove_except_protected_forbidden = 0; - if (e_.classname == "initialize_entity") + e.remove_except_protected_forbidden = 0; + e.initialize_entity_order = 0; + entity next = e.initialize_entity_next; + e.initialize_entity_next = NULL; + var void() func = e.initialize_entity; + e.initialize_entity = func_null; + if (e.classname == "initialize_entity") { - entity e_old = e_.enemy; - builtin_remove(e_); - e_ = e_old; + entity wrappee = e.enemy; + builtin_remove(e); + e = wrappee; + } + //dprint("Delayed initialization: ", e.classname, "\n"); + if (func) + { + SELFCALL(e, func()); + SELFCALL_DONE(); } - //dprint("Delayed initialization: ", e_.classname, "\n"); - if(func) - func(); else { - eprint(e_); - backtrace(strcat("Null function in: ", e_.classname, "\n")); + eprint(e); + backtrace(strcat("Null function in: ", e.classname, "\n")); } - e_ = e; + e = next; } remove = remove_unsafely; } void UncustomizeEntitiesRun() {SELFPARAM(); - for (entity e = world; (e = findfloat(e, uncustomizeentityforclient_set, 1)); ) + for (entity e = NULL; (e = findfloat(e, uncustomizeentityforclient_set, 1)); ) { SELFCALL(e, e.uncustomizeentityforclient()); SELFCALL_DONE();