From: TimePath Date: Fri, 14 Aug 2015 03:53:32 +0000 (+1000) Subject: Merge branches 'TimePath/oo', 'TimePath/buffsys', 'TimePath/gametypesys' X-Git-Tag: xonotic-v0.8.2~2073 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f878adf879c95c0c04ae8806e45aaa285917b39d;p=xonotic%2Fxonotic-data.pk3dir.git Merge branches 'TimePath/oo', 'TimePath/buffsys', 'TimePath/gametypesys' --- f878adf879c95c0c04ae8806e45aaa285917b39d diff --cc qcsrc/common/buffs.qh index 0cd32e0b3,7396f974c,0cd32e0b3..db5794324 --- a/qcsrc/common/buffs.qh +++ b/qcsrc/common/buffs.qh @@@@ -8,70 -8,136 -8,70 +8,136 @@@@ #include "teams.qh" #include "util.qh" - -entity Buff_Type_first; - -entity Buff_Type_last; - -.entity enemy; // internal next pointer - - - -int BUFF_LAST = 1; - -int BUFF_ALL; - - - -.int items; // buff ID - -.string netname; // buff name - -.string message; // human readable name - -.vector colormod; // buff color - -.string model2; // buff sprite - -.int skin; // buff skin - -.float buff_time; - - - -// hacky function to return the cvar value only to server - TODO: do this properly! - -float sv_cvar(string cvarname) - -{ + +#include "registry.qh" + + + +void RegisterBuffs(); + +const int BUFFS_MAX = 16; - entity BUFFS[BUFFS_MAX]; +++entity BUFFS[BUFFS_MAX], BUFFS_first, BUFFS_last; + +int BUFFS_COUNT; + +#define REGISTER_BUFF(id) \ - REGISTER(RegisterBuffs, BUFF, BUFFS, BUFFS_COUNT, id, Buff, m_id); \ +++ REGISTER(RegisterBuffs, BUFF, BUFFS, BUFFS_COUNT, id, m_id, NEW(Buff)); \ + + REGISTER_INIT_POST(BUFF, id) { \ + + this.netname = this.m_name; \ + + this.m_itemid = BIT(this.m_id - 1); \ + + this.m_sprite = strzone(strcat("buff-", this.m_name)); \ + + } \ + + REGISTER_INIT(BUFF, id) + +REGISTER_REGISTRY(RegisterBuffs) + + + +#include "items/item/pickup.qh" + +CLASS(Buff, Pickup) + + /** bit index */ + + ATTRIB(Buff, m_itemid, int, 0) + + ATTRIB(Buff, m_name, string, "buff") + + ATTRIB(Buff, m_color, vector, '1 1 1') + + ATTRIB(Buff, m_prettyName, string, "Buff") + + ATTRIB(Buff, m_skin, int, 0) + + ATTRIB(Buff, m_sprite, string, "") #ifdef SVQC - - return cvar(cvarname); - -#else - - return 0; + + METHOD(Buff, m_time, float(entity)) + + float Buff_m_time(entity this) { return cvar(strcat("g_buffs_", this.netname, "_time")); } #endif + +ENDCLASS(Buff) + + + +REGISTER_BUFF(NULL); + + + +REGISTER_BUFF(AMMO) { + + this.m_prettyName = _("Ammo"); + + this.m_name = "ammo"; + + this.m_skin = 3; + + this.m_color = '0.76 1 0.1'; + +} + + + +REGISTER_BUFF(RESISTANCE) { + + this.m_prettyName = _("Resistance"); + + this.m_name = "resistance"; + + this.m_skin = 0; + + this.m_color = '0.36 1 0.07'; + +} + + + +REGISTER_BUFF(SPEED) { + + this.m_prettyName = _("Speed"); + + this.m_name = "speed"; + + this.m_skin = 9; + + this.m_color = '0.1 1 0.84'; + +} + + + +REGISTER_BUFF(MEDIC) { + + this.m_prettyName = _("Medic"); + + this.m_name = "medic"; + + this.m_skin = 1; + + this.m_color = '1 0.12 0'; + +} + + + +REGISTER_BUFF(BASH) { + + this.m_prettyName = _("Bash"); + + this.m_name = "bash"; + + this.m_skin = 5; + + this.m_color = '1 0.39 0'; + +} + + + +REGISTER_BUFF(VAMPIRE) { + + this.m_prettyName = _("Vampire"); + + this.m_name = "vampire"; + + this.m_skin = 2; + + this.m_color = '1 0 0.24'; + +} + + + +REGISTER_BUFF(DISABILITY) { + + this.m_prettyName = _("Disability"); + + this.m_name = "disability"; + + this.m_skin = 7; + + this.m_color = '0.94 0.3 1'; + +} + + + +REGISTER_BUFF(VENGEANCE) { + + this.m_prettyName = _("Vengeance"); + + this.m_name = "vengeance"; + + this.m_skin = 15; + + this.m_color = '1 0.23 0.61'; + +} + + + +REGISTER_BUFF(JUMP) { + + this.m_prettyName = _("Jump"); + + this.m_name = "jump"; + + this.m_skin = 10; + + this.m_color = '0.24 0.78 1'; + +} + + + +REGISTER_BUFF(FLIGHT) { + + this.m_prettyName = _("Flight"); + + this.m_name = "flight"; + + this.m_skin = 11; + + this.m_color = '0.33 0.56 1'; } - -#define REGISTER_BUFF(hname,sname,NAME,bskin,bcolor) \ - - int BUFF_##NAME; \ - - entity Buff_Type##sname; \ - - void RegisterBuffs_##sname() \ - - { \ - - BUFF_##NAME = BUFF_LAST * 2; \ - - BUFF_LAST = BUFF_##NAME; \ - - BUFF_ALL |= BUFF_##NAME; \ - - Buff_Type##sname = spawn(); \ - - Buff_Type##sname.items = BUFF_##NAME; \ - - Buff_Type##sname.netname = #sname; \ - - Buff_Type##sname.message = hname; \ - - Buff_Type##sname.skin = bskin; \ - - Buff_Type##sname.colormod = bcolor; \ - - Buff_Type##sname.buff_time = sv_cvar(strcat("g_buffs_", #sname, "_time")); \ - - Buff_Type##sname.model2 = strzone(strcat("buff-", #sname)); \ - - if(!Buff_Type_first) \ - - Buff_Type_first = Buff_Type##sname; \ - - if(Buff_Type_last) \ - - Buff_Type_last.enemy = Buff_Type##sname; \ - - Buff_Type_last = Buff_Type##sname; \ - - } \ - - ACCUMULATE_FUNCTION(RegisterBuffs, RegisterBuffs_##sname) - - - -REGISTER_BUFF(_("Ammo"),ammo,AMMO,3,'0.76 1 0.1'); - -REGISTER_BUFF(_("Resistance"),resistance,RESISTANCE,0,'0.36 1 0.07'); - -REGISTER_BUFF(_("Speed"),speed,SPEED,9,'0.1 1 0.84'); - -REGISTER_BUFF(_("Medic"),medic,MEDIC,1,'1 0.12 0'); - -REGISTER_BUFF(_("Bash"),bash,BASH,5,'1 0.39 0'); - -REGISTER_BUFF(_("Vampire"),vampire,VAMPIRE,2,'1 0 0.24'); - -REGISTER_BUFF(_("Disability"),disability,DISABILITY,7,'0.94 0.3 1'); - -REGISTER_BUFF(_("Vengeance"),vengeance,VENGEANCE,15,'1 0.23 0.61'); - -REGISTER_BUFF(_("Jump"),jump,JUMP,10,'0.24 0.78 1'); - -REGISTER_BUFF(_("Flight"),flight,FLIGHT,11,'0.33 0.56 1'); - -REGISTER_BUFF(_("Invisible"),invisible,INVISIBLE,12,'0.5 0.5 1'); - -REGISTER_BUFF(_("Inferno"),inferno,INFERNO,16,'1 0.62 0'); - -REGISTER_BUFF(_("Swapper"),swapper,SWAPPER,17,'0.63 0.36 1'); - -REGISTER_BUFF(_("Magnet"),magnet,MAGNET,18,'1 0.95 0.18'); - -#undef REGISTER_BUFF + +REGISTER_BUFF(INVISIBLE) { + + this.m_prettyName = _("Invisible"); + + this.m_name = "invisible"; + + this.m_skin = 12; + + this.m_color = '0.5 0.5 1'; + +} + + + +REGISTER_BUFF(INFERNO) { + + this.m_prettyName = _("Inferno"); + + this.m_name = "inferno"; + + this.m_skin = 16; + + this.m_color = '1 0.62 0'; + +} + + + +REGISTER_BUFF(SWAPPER) { + + this.m_prettyName = _("Swapper"); + + this.m_name = "swapper"; + + this.m_skin = 17; + + this.m_color = '0.63 0.36 1'; + +} + + + +REGISTER_BUFF(MAGNET) { + + this.m_prettyName = _("Magnet"); + + this.m_name = "magnet"; + + this.m_skin = 18; + + this.m_color = '1 0.95 0.18'; + +} #ifdef SVQC .int buffs; diff --cc qcsrc/common/items/all.qh index c42139e25,372e3ff69,e666ad353..e22bcd747 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@@@ -5,19 -5,12 -5,19 +5,12 @@@@ void RegisterItems(); const int MAX_ITEMS = 24; -- entity ITEMS[MAX_ITEMS]; ++ entity ITEMS[MAX_ITEMS], ITEMS_first, ITEMS_last; int ITEM_COUNT; /** If you register a new item, make sure to add it to all.inc */ -- #define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, ITEMS, ITEM_COUNT, id, class, m_id) ++ #define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, ITEMS, ITEM_COUNT, id, m_id, NEW(class)) REGISTER_REGISTRY(RegisterItems) - -#define ITEMS_FOREACH(pred, body) do { \ - - for (int i = 0; i < ITEM_COUNT; i++) { \ - - const noref entity it = ITEMS[i]; \ - - if (pred) { body } \ - - } \ - -} while(0) - - void Dump_Items(); #endif diff --cc qcsrc/common/registry.qh index 4c24b491d,3bf8f4099,5a15337cf..6e8557edf --- a/qcsrc/common/registry.qh +++ b/qcsrc/common/registry.qh @@@@ -1,17 -1,22 -1,23 +1,27 @@@@ #ifndef REGISTRY_H #define REGISTRY_H + +#include "oo.qh" ++ #include "util.qh" + #define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this) + +#define REGISTER_INIT_POST(ns, id) [[accumulate]] void Register_##ns##_##id##_init_post(entity this) -- #define REGISTER(initfunc, ns, array, counter, id, class, fld) \ ++ #define REGISTER(initfunc, ns, array, counter, id, fld, inst) \ entity ns##_##id; \ REGISTER_INIT(ns, id) { } \ + + REGISTER_INIT_POST(ns, id) { } \ ++ .entity enemy; /* internal next pointer */ \ void Register_##ns##_##id() { \ -- entity this = NEW(class); \ ++ entity this = inst; \ ns##_##id = this; \ this.fld = counter; \ array[counter++] = this; \ ++ if (!array##_first) array##_first = this; \ ++ if ( array##_last) array##_last.enemy = this; \ ++ array##_last = this; \ Register_##ns##_##id##_init(this); \ + + Register_##ns##_##id##_init_post(this); \ } \ ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \ REGISTER_INIT(ns, id) diff --cc qcsrc/server/g_world.qc index 1c88f0472,27db2b4fd,9f9f1f246..881f8f071 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@@@ -561,11 -561,10 -561,9 +561,8 @@@@ void spawnfunc___init_dedicated_server( // needs to be done so early because of the constants they create static_init(); CALL_ACCUMULATED_FUNCTION(RegisterWeapons); -- CALL_ACCUMULATED_FUNCTION(RegisterMonsters); -- CALL_ACCUMULATED_FUNCTION(RegisterGametypes); CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); - - CALL_ACCUMULATED_FUNCTION(RegisterBuffs); MapInfo_Enumerate(); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); @@@@ -612,11 -611,10 -610,9 +609,8 @@@@ void spawnfunc_worldspawn (void // needs to be done so early because of the constants they create static_init(); CALL_ACCUMULATED_FUNCTION(RegisterWeapons); -- CALL_ACCUMULATED_FUNCTION(RegisterMonsters); -- CALL_ACCUMULATED_FUNCTION(RegisterGametypes); CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); - - CALL_ACCUMULATED_FUNCTION(RegisterBuffs); ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));