From: TimePath Date: Sun, 26 Apr 2015 06:46:37 +0000 (+1000) Subject: Reclaim the `new` keyword for entity classes X-Git-Tag: xonotic-v0.8.1~61^2~26 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9f3857d78b4ce83b45bd1e98fe50600a2d306c23;p=xonotic%2Fxonotic-data.pk3dir.git Reclaim the `new` keyword for entity classes --- diff --git a/qcsrc/common/util-pre.qh b/qcsrc/common/util-pre.qh index f24620037..b3aacfa97 100644 --- a/qcsrc/common/util-pre.qh +++ b/qcsrc/common/util-pre.qh @@ -37,6 +37,16 @@ const int false = 0; #endif +#ifndef QCC_SUPPORT_ENTITYCLASS + #define entityclass(name) typedef entity name + #define class(name) + #define new(class) spawn() +#else + #define entityclass(name) entityclass name {} + #define class(name) [[class(name)]] + #define new(class) ((class) spawn()) +#endif + // Transitional aliases [[deprecated("use true")]] [[alias("true")]] const bool TRUE; [[deprecated("use false")]] [[alias("false")]] const bool FALSE; diff --git a/qcsrc/menu/xonotic/inputbox.qc b/qcsrc/menu/xonotic/inputbox.qc index 5d7d17999..fef5311c7 100644 --- a/qcsrc/menu/xonotic/inputbox.qc +++ b/qcsrc/menu/xonotic/inputbox.qc @@ -58,18 +58,18 @@ void XonoticInputBox_focusLeave(entity me) { me.saveCvars(me); } -void XonoticInputBox_setText(entity me, string new) +void XonoticInputBox_setText(entity me, string val) { - if(me.text != new) + if(me.text != val) { - SUPER(XonoticInputBox).setText(me, new); + SUPER(XonoticInputBox).setText(me, val); if(me.onChange) me.onChange(me, me.onChangeEntity); if(me.saveImmediately) me.saveCvars(me); } else - SUPER(XonoticInputBox).setText(me, new); + SUPER(XonoticInputBox).setText(me, val); } void XonoticInputBox_loadCvars(entity me) { diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 64d98f127..d4489106d 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -46,7 +46,7 @@ void make_mapinfo_Think() void changematchtime(float delta, float mi, float ma) { float cur; - float new; + float update; float lim; if(delta == 0) @@ -67,21 +67,21 @@ void changematchtime(float delta, float mi, float ma) if(lim == 0) return; // cannot increase any further else if(lim < ma) - new = min(ma, lim + delta); + update = min(ma, lim + delta); else // already above maximum: FAIL return; } else { if(lim == 0) // infinite: try reducing to max, if we are allowed to - new = max(mi, ma); + update = max(mi, ma); else if(lim > mi) // above minimum: decrease - new = max(mi, lim + delta); + update = max(mi, lim + delta); else // already below minimum: FAIL return; } - cvar_set("timelimit", ftos(new / 60)); + cvar_set("timelimit", ftos(update / 60)); } diff --git a/qcsrc/server/g_tetris.qc b/qcsrc/server/g_tetris.qc index 63e498bfc..70a316386 100644 --- a/qcsrc/server/g_tetris.qc +++ b/qcsrc/server/g_tetris.qc @@ -100,11 +100,11 @@ float GetXBlock(float x, string dat) return stof(substring(dat, x-1, 1)); } -string SetXBlock(float x, string dat, float new) +string SetXBlock(float x, string dat, float val) { return strcat( substring(dat, 0, x-1), - ftos(new), + ftos(val), substring(dat, x, -1) ); } diff --git a/qcsrc/server/target_spawn.qc b/qcsrc/server/target_spawn.qc index b4b9b1830..cba5f365d 100644 --- a/qcsrc/server/target_spawn.qc +++ b/qcsrc/server/target_spawn.qc @@ -315,7 +315,7 @@ void initialize_field_db() { float n, i; string fn; - vector prev, new; + vector prev, next; float ft; n = numentityfields(); @@ -323,11 +323,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; }