]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branches 'TimePath/oo', 'TimePath/buffsys', 'TimePath/gametypesys'
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 14 Aug 2015 03:53:32 +0000 (13:53 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 14 Aug 2015 03:54:12 +0000 (13:54 +1000)
1  2  3 
qcsrc/client/main.qc
qcsrc/common/buffs.qh
qcsrc/common/items/all.qh
qcsrc/common/mapinfo.qc
qcsrc/common/registry.qh
qcsrc/common/util-pre.qh
qcsrc/server/g_world.qc

Simple merge
index 0cd32e0b357b6ec2b0f98ebac3a403062f14a891,7396f974c2bc5eb1ebacdbfdc31bb7a9586d3479,0cd32e0b357b6ec2b0f98ebac3a403062f14a891..db57943241b9c3d0b0bad9698dfd9f0e76dd1c5d
   #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;
index c42139e25f6a1b4f4c12cba0e350e8ec2daac506,372e3ff69c1a02dd9f0967ab8a82f69ea84d1eaa,e666ad3538ddc61f1243d0c85d0fe089f5d285a4..e22bcd7477c3e8e2ea534f65deb1c20430c1502f
   
   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
Simple merge
index 4c24b491d9b33661bf562a333009dc1d89db5f30,3bf8f40992325a8c90873b5fe64c9ac20518eadc,5a15337cf64bd6944110d9c0f0a3bd4cf8816d4a..6e8557edfd8808a10c0426e6c102d1f1c1304a98
   #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)
Simple merge
index 1c88f0472fe97d21a2b4f4ee437dfb95b2d6ef8a,27db2b4fd90d7b3ad7d0c4c2c81f7be658763056,9f9f1f246536f48b75570a384558c5d808e7aae6..881f8f071915aef1eaa5428cab0b143bca65b953
@@@@ -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));