]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
even less game type ref lists
authorRudolf Polzer <divverent@xonotic.org>
Thu, 29 Dec 2011 10:40:11 +0000 (11:40 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 29 Dec 2011 10:40:11 +0000 (11:40 +0100)
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh

index 270a30147724bf61b66e7c8893897c24d52b7803..3a72f7387687ae9d942cd2b17f203d91091bbafb 100644 (file)
@@ -535,26 +535,11 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl
 
 string _MapInfo_GetDefaultEx(float t)
 {
-       switch(t)
-       {
-               case MAPINFO_TYPE_DEATHMATCH:      return "timelimit=20 pointlimit=30 leadlimit=0";
-               case MAPINFO_TYPE_TEAM_DEATHMATCH: return "timelimit=20 pointlimit=50 teams=2 leadlimit=0";
-               case MAPINFO_TYPE_DOMINATION:      return "timelimit=20 pointlimit=200 teams=2 leadlimit=0";
-               case MAPINFO_TYPE_CTF:             return "timelimit=20 pointlimit=300 caplimit=10 leadlimit=0";
-               case MAPINFO_TYPE_RUNEMATCH:       return "timelimit=20 pointlimit=200 leadlimit=0";
-               case MAPINFO_TYPE_LMS:             return "timelimit=20 lives=9 leadlimit=0";
-               case MAPINFO_TYPE_ARENA:           return "timelimit=20 pointlimit=10 leadlimit=0";
-               case MAPINFO_TYPE_CA:              return "timelimit=20 pointlimit=10 leadlimit=0";
-               case MAPINFO_TYPE_KEYHUNT:         return "timelimit=20 pointlimit=1000 teams=3 leadlimit=0";
-               case MAPINFO_TYPE_ASSAULT:         return "timelimit=20";
-               case MAPINFO_TYPE_RACE:            return "timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0";
-               case MAPINFO_TYPE_ONSLAUGHT:       return "timelimit=20";
-               case MAPINFO_TYPE_NEXBALL:         return "timelimit=20 pointlimit=5 leadlimit=0";
-               case MAPINFO_TYPE_CTS:             return "timelimit=20 skill=-1";
-               case MAPINFO_TYPE_FREEZETAG:       return "timelimit=20 pointlimit=10 teams=2 leadlimit=0";
-               case MAPINFO_TYPE_KEEPAWAY:        return "timelimit=20 pointlimit=30";
-               default:                           return "";
-       }
+       entity e;
+       for(e = MapInfo_Type_first; e; e = e.enemy)
+               if(t == e.weapons)
+                       return e.message;
+       return "";
 }
 
 void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType)
@@ -667,7 +652,7 @@ float MapInfo_Type_FromString(string t)
        if(t == "all")
                return MAPINFO_TYPE_ALL;
        for(e = MapInfo_Type_first; e; e = e.enemy)
-               if(t == e.model2)
+               if(t == e.mdl)
                        return e.weapons;
        return 0;
 }
@@ -679,7 +664,7 @@ string MapInfo_Type_ToString(float t)
                return "all";
        for(e = MapInfo_Type_first; e; e = e.enemy)
                if(t == e.weapons)
-                       return e.model2;
+                       return e.mdl;
        return "";
 }
 
@@ -1170,11 +1155,11 @@ float MapInfo_CurrentFeatures()
 
 float MapInfo_CurrentGametype()
 {
-       float prev, i;
+       float prev;
        entity e;
        prev = cvar("gamecfg");
        for(e = MapInfo_Type_first; e; e = e.enemy)
-               if(cvar(e.mdl))
+               if(cvar(e.netname))
                        if(prev != e.weapons)
                                return e.weapons;
        if(prev)
@@ -1201,20 +1186,11 @@ float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with th
        return r;
 }
 
-string MapInfo_GetGameTypeCvar(float t)
-{
-       entity e;
-       for(e = MapInfo_Type_first; e; e = e.enemy)
-               if(e.weapons == t)
-                       return e.mdl;
-       return "";
-}
-
 void MapInfo_SwitchGameType(float t)
 {
        entity e;
        for(e = MapInfo_Type_first; e; e = e.enemy)
-               cvar_set(e.mdl, (t == e.weapons) ? "1" : "0");
+               cvar_set(e.netname, (t == e.weapons) ? "1" : "0");
 }
 
 void MapInfo_LoadMap(string s, float reinit)
index 72b066288f86b14a6c53d3a02c8f41dd82a83514..2b9e0d6a86672f38d4e9bef3dad15fb66b608310 100644 (file)
@@ -1,80 +1,82 @@
 var float MAPINFO_TYPE_ALL = 0;
 entity MapInfo_Type_first;
 entity MapInfo_Type_last;
+.entity enemy; // internal next pointer
 
-#define REGISTER_GAMETYPE_LONG(name,sname,NAME,g_name,MAPINFO_TYPE_NAME,MapInfo_Type_name) \
-       var float MAPINFO_TYPE_NAME; \
-       var entity MapInfo_Type_name; \
-       void RegisterGametypes_##name() \
+.float weapons; // game type ID
+.string netname; // game type name as in cvar (with g_ prefix)
+.string mdl; // game type short name
+.string message; // game type defaults
+
+#define REGISTER_GAMETYPE(g_name,sname,NAME,defaults) \
+       var float MAPINFO_TYPE_##NAME; \
+       var entity MapInfo_Type##g_name; \
+       void RegisterGametypes_##g_name() \
        { \
-               MAPINFO_TYPE_NAME = MAPINFO_TYPE_ALL + 1; \
-               MAPINFO_TYPE_ALL |= MAPINFO_TYPE_NAME; \
-               MapInfo_Type_name = spawn(); \
-               MapInfo_Type_name.weapons = MAPINFO_TYPE_NAME; \
-               MapInfo_Type_name.netname = #name; \
-               MapInfo_Type_name.message = #NAME; \
-               MapInfo_Type_name.mdl = #g_name; \
-               MapInfo_Type_name.model2 = #sname; \
+               MAPINFO_TYPE_##NAME = MAPINFO_TYPE_ALL + 1; \
+               MAPINFO_TYPE_ALL |= MAPINFO_TYPE_##NAME; \
+               MapInfo_Type##g_name = spawn(); \
+               MapInfo_Type##g_name.weapons = MAPINFO_TYPE_##NAME; \
+               MapInfo_Type##g_name.netname = #g_name; \
+               MapInfo_Type##g_name.mdl = #sname; \
+               MapInfo_Type##g_name.message = defaults; \
                if(!MapInfo_Type_first) \
-                       MapInfo_Type_first = MapInfo_Type_name; \
+                       MapInfo_Type_first = MapInfo_Type##g_name; \
                if(MapInfo_Type_last) \
-                       MapInfo_Type_last.enemy = MapInfo_Type_name; \
-               MapInfo_Type_last = MapInfo_Type_name; \
+                       MapInfo_Type_last.enemy = MapInfo_Type##g_name; \
+               MapInfo_Type_last = MapInfo_Type##g_name; \
        } \
-       ACCUMULATE_FUNCTION(RegisterGametypes, RegisterGametypes_##name)
-
-#define REGISTER_GAMETYPE(name,sname,NAME) \
-       REGISTER_GAMETYPE_LONG(name,sname,NAME,g_##name,MAPINFO_TYPE_##NAME,MapInfo_Type_##name)
+       ACCUMULATE_FUNCTION(RegisterGametypes, RegisterGametypes_##g_name)
 
 #define IS_GAMETYPE(NAME) \
        (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
 
-REGISTER_GAMETYPE(dm,dm,DEATHMATCH)
+REGISTER_GAMETYPE(dm,g_dm,DEATHMATCH,"timelimit=20 pointlimit=30 leadlimit=0")
 #define g_dm IS_GAMETYPE(DEATHMATCH)
 
-REGISTER_GAMETYPE(lms,lms,LMS)
+REGISTER_GAMETYPE(lms,g_lms,LMS,"timelimit=20 lives=9 leadlimit=0")
 #define g_lms IS_GAMETYPE(LMS)
 
-REGISTER_GAMETYPE(arena,arena,ARENA)
+REGISTER_GAMETYPE(arena,g_arena,ARENA,"timelimit=20 pointlimit=10 leadlimit=0")
 #define g_arena IS_GAMETYPE(ARENA)
 
-REGISTER_GAMETYPE(runematch,rune,RUNEMATCH)
+REGISTER_GAMETYPE(rune,g_runematch,RUNEMATCH,"timelimit=20 pointlimit=200 leadlimit=0")
 #define g_runematch IS_GAMETYPE(RUNEMATCH)
 
-REGISTER_GAMETYPE(race,rc,RACE)
+REGISTER_GAMETYPE(rc,g_race,RACE,"timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0")
 #define g_race IS_GAMETYPE(RACE)
 
-REGISTER_GAMETYPE(cts,cts,CTS)
+REGISTER_GAMETYPE(cts,g_cts,CTS,"timelimit=20 skill=-1")
 #define g_cts IS_GAMETYPE(CTS)
 
-REGISTER_GAMETYPE(tdm,tdm,TEAM_DEATHMATCH)
+REGISTER_GAMETYPE(tdm,g_tdm,TEAM_DEATHMATCH,"timelimit=20 pointlimit=50 teams=2 leadlimit=0")
 #define g_tdm IS_GAMETYPE(TEAM_DEATHMATCH)
 
-REGISTER_GAMETYPE(ctf,ctf,CTF)
+REGISTER_GAMETYPE(ctf,g_ctf,CTF,"timelimit=20 pointlimit=300 caplimit=10 leadlimit=0")
 #define g_ctf IS_GAMETYPE(CTF)
 
-REGISTER_GAMETYPE(ca,ca,CA)
+REGISTER_GAMETYPE(ca,g_ca,CA,"timelimit=20 pointlimit=10 leadlimit=0")
 #define g_ca IS_GAMETYPE(CA)
 
-REGISTER_GAMETYPE(domination,dom,DOMINATION)
+REGISTER_GAMETYPE(dom,g_domination,DOMINATION,"timelimit=20 pointlimit=200 teams=2 leadlimit=0")
 #define g_domination IS_GAMETYPE(DOMINATION)
 
-REGISTER_GAMETYPE(keyhunt,kh,KEYHUNT)
+REGISTER_GAMETYPE(kh,g_keyhunt,KEYHUNT,"timelimit=20 pointlimit=1000 teams=3 leadlimit=0")
 #define g_keyhunt IS_GAMETYPE(KEYHUNT)
 
-REGISTER_GAMETYPE(assault,as,ASSAULT)
+REGISTER_GAMETYPE(as,g_assault,ASSAULT,"timelimit=20")
 #define g_assault IS_GAMETYPE(ASSAULT)
 
-REGISTER_GAMETYPE(onslaught,ons,ONSLAUGHT)
+REGISTER_GAMETYPE(ons,g_onslaught,ONSLAUGHT,"timelimit=20")
 #define g_onslaught IS_GAMETYPE(ONSLAUGHT)
 
-REGISTER_GAMETYPE(nexball,nexball,NEXBALL)
+REGISTER_GAMETYPE(nexball,g_nexball,NEXBALL,"timelimit=20 pointlimit=5 leadlimit=0")
 #define g_nexball IS_GAMETYPE(NEXBALL)
 
-REGISTER_GAMETYPE(freezetag,freezetag,FREEZETAG)
+REGISTER_GAMETYPE(freezetag,g_freezetag,FREEZETAG,"timelimit=20 pointlimit=10 teams=2 leadlimit=0")
 #define g_freezetag IS_GAMETYPE(FREEZETAG)
 
-REGISTER_GAMETYPE(keepaway,keepaway,KEEPAWAY)
+REGISTER_GAMETYPE(keepaway,g_keepaway,KEEPAWAY,"timelimit=20 pointlimit=30")
 #define g_keepaway IS_GAMETYPE(KEEPAWAY)
 
 float MAPINFO_FEATURE_WEAPONS       = 1; // not defined for minstagib-only maps
@@ -138,7 +140,6 @@ string MapInfo_ListAllAllowedMaps(float pFlagsRequired, float pFlagsForbidden);
 // gets a gametype from a string
 float MapInfo_Type_FromString(string t);
 string MapInfo_Type_ToString(float t);
-string MapInfo_GetGameTypeCvar(float t);
 void MapInfo_SwitchGameType(float t);
 
 // to be called from worldspawn to set up cvars