From: Mario Date: Sun, 14 Aug 2016 07:51:45 +0000 (+1000) Subject: Registrize mapinfo generation and twobasemodes X-Git-Tag: xonotic-v0.8.2~718^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=243016f8c14908146883edd9d50806e2d25418e5;p=xonotic%2Fxonotic-data.pk3dir.git Registrize mapinfo generation and twobasemodes --- diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index d9ca7e994..19313e6b6 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -269,7 +269,6 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp float i; float inWorldspawn; float r; - float twoBaseModes; float diameter, spawnpoints; float spawnplaces; @@ -349,21 +348,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp } else if(k == "classname") { - if(v == "dom_controlpoint") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_DOMINATION.m_flags; - else if(v == "item_flag_team2") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF.m_flags; - else if(v == "team_CTF_blueflag") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF.m_flags; - else if(v == "invasion_spawnpoint") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_INVASION.m_flags; - else if(v == "target_assault_roundend") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ASSAULT.m_flags; - else if(v == "onslaught_generator") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ONSLAUGHT.m_flags; - else if(substring(v, 0, 8) == "nexball_" || substring(v, 0, 4) == "ball") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_NEXBALL.m_flags; - else if(v == "info_player_team1") + if(v == "info_player_team1") ++spawnpoints; else if(v == "info_player_team2") ++spawnpoints; @@ -371,10 +356,6 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp ++spawnpoints; else if(v == "info_player_deathmatch") ++spawnpoints; - else if(v == "trigger_race_checkpoint") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RACE.m_flags; - else if(v == "target_startTimer") - MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS.m_flags; else if(v == "weapon_nex") { } else if(v == "weapon_railgun") @@ -389,6 +370,8 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_MONSTERS; else if(v == "target_music" || v == "trigger_music") _MapInfo_Map_worldspawn_music = string_null; // don't use regular BGM + else + FOREACH(Gametypes, true, it.m_generate_mapinfo(it, v)); } } } @@ -399,8 +382,9 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp } diameter = vlen(mapMaxs - mapMins); - twoBaseModes = MapInfo_Map_supportedGametypes & (MAPINFO_TYPE_CTF.m_flags | MAPINFO_TYPE_ASSAULT.m_flags | MAPINFO_TYPE_RACE.m_flags | MAPINFO_TYPE_NEXBALL.m_flags); - if(twoBaseModes && (MapInfo_Map_supportedGametypes == twoBaseModes)) + int twoBaseModes = 0; + FOREACH(Gametypes, it.m_isTwoBaseMode(), twoBaseModes |= it.m_flags); + if(twoBaseModes && (twoBaseModes &= MapInfo_Map_supportedGametypes)) { // we have a CTF-only or Assault-only map. Don't add other modes then, // as the map is too symmetric for them. diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 0ff6882e0..1b00ff800 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -7,6 +7,20 @@ bool autocvar_developer_mapper; #include "util.qh" +// info about a map that MapInfo loads +string MapInfo_Map_bspname; +string MapInfo_Map_title; +string MapInfo_Map_titlestring; // either bspname: title or just title, depending on whether bspname is redundant +string MapInfo_Map_description; +string MapInfo_Map_author; +string MapInfo_Map_clientstuff; // not in cache, only for map load +string MapInfo_Map_fog; // not in cache, only for map load +int MapInfo_Map_supportedGametypes; +int MapInfo_Map_supportedFeatures; +int MapInfo_Map_flags; +vector MapInfo_Map_mins; // these are '0 0 0' if not supported! +vector MapInfo_Map_maxs; // these are '0 0 0' if not specified! + int MAPINFO_TYPE_ALL; .int m_flags; @@ -32,6 +46,14 @@ CLASS(Gametype, Object) { return false; } + METHOD(Gametype, m_generate_mapinfo, void(Gametype this, string v)) + { + TC(Gametype, this); + } + METHOD(Gametype, m_isTwoBaseMode, bool()) + { + return false; + } METHOD(Gametype, describe, string(Gametype this)) { @@ -102,6 +124,15 @@ CLASS(Race, Gametype) } return false; } + METHOD(Race, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "trigger_race_checkpoint") + MapInfo_Map_supportedGametypes |= this.m_flags; + } + METHOD(Race, m_isTwoBaseMode, bool()) + { + return true; + } ENDCLASS(Race) REGISTER_GAMETYPE(RACE, NEW(Race)); #define g_race IS_GAMETYPE(RACE) @@ -111,6 +142,11 @@ CLASS(RaceCTS, Gametype) { this.gametype_init(this, _("Race CTS"),"cts","g_cts",false,"cloaked","timelimit=20",_("Race for fastest time.")); } + METHOD(RaceCTS, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "target_startTimer") + MapInfo_Map_supportedGametypes |= this.m_flags; + } ENDCLASS(RaceCTS) REGISTER_GAMETYPE(CTS, NEW(RaceCTS)); #define g_cts IS_GAMETYPE(CTS) @@ -142,6 +178,15 @@ CLASS(CaptureTheFlag, Gametype) { this.gametype_init(this, _("Capture the Flag"),"ctf","g_ctf",true,"","timelimit=20 caplimit=10 leadlimit=6",_("Find and bring the enemy flag to your base to capture it, defend your base from the other team")); } + METHOD(CaptureTheFlag, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "item_flag_team2" || v == "team_CTF_blueflag") + MapInfo_Map_supportedGametypes |= this.m_flags; + } + METHOD(CaptureTheFlag, m_isTwoBaseMode, bool()) + { + return true; + } ENDCLASS(CaptureTheFlag) REGISTER_GAMETYPE(CTF, NEW(CaptureTheFlag)); #define g_ctf IS_GAMETYPE(CTF) @@ -186,6 +231,11 @@ CLASS(Domination, Gametype) } return false; } + METHOD(Domination, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "dom_controlpoint") + MapInfo_Map_supportedGametypes |= this.m_flags; + } ENDCLASS(Domination) REGISTER_GAMETYPE(DOMINATION, NEW(Domination)); @@ -215,6 +265,15 @@ CLASS(Assault, Gametype) { this.gametype_init(this, _("Assault"),"as","g_assault",true,"","timelimit=20",_("Destroy obstacles to find and destroy the enemy power core before time runs out")); } + METHOD(Assault, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "target_assault_roundend") + MapInfo_Map_supportedGametypes |= this.m_flags; + } + METHOD(Assault, m_isTwoBaseMode, bool()) + { + return true; + } ENDCLASS(Assault) REGISTER_GAMETYPE(ASSAULT, NEW(Assault)); #define g_assault IS_GAMETYPE(ASSAULT) @@ -224,6 +283,11 @@ CLASS(Onslaught, Gametype) { this.gametype_init(this, _("Onslaught"),"ons","g_onslaught",true,"","pointlimit=1 timelimit=20",_("Capture control points to reach and destroy the enemy generator")); } + METHOD(Onslaught, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "onslaught_generator") + MapInfo_Map_supportedGametypes |= this.m_flags; + } ENDCLASS(Onslaught) REGISTER_GAMETYPE(ONSLAUGHT, NEW(Onslaught)); @@ -232,6 +296,15 @@ CLASS(NexBall, Gametype) { this.gametype_init(this, _("Nexball"),"nb","g_nexball",true,"","timelimit=20 pointlimit=5 leadlimit=0",_("Shoot and kick the ball into the enemies goal, keep your goal clean")); } + METHOD(NexBall, m_generate_mapinfo, void(Gametype this, string v)) + { + if(substring(v, 0, 8) == "nexball_" || substring(v, 0, 4) == "ball") + MapInfo_Map_supportedGametypes |= this.m_flags; + } + METHOD(NexBall, m_isTwoBaseMode, bool()) + { + return true; + } ENDCLASS(NexBall) REGISTER_GAMETYPE(NEXBALL, NEW(NexBall)); #define g_nexball IS_GAMETYPE(NEXBALL) @@ -280,6 +353,11 @@ CLASS(Invasion, Gametype) } return false; } + METHOD(Invasion, m_generate_mapinfo, void(Gametype this, string v)) + { + if(v == "invasion_spawnpoint") + MapInfo_Map_supportedGametypes |= this.m_flags; + } ENDCLASS(Invasion) REGISTER_GAMETYPE(INVASION, NEW(Invasion)); @@ -295,20 +373,6 @@ const int MAPINFO_FLAG_NOAUTOMAPLIST = 8; // do not include when automaticall float MapInfo_count; -// info about a map that MapInfo loads -string MapInfo_Map_bspname; -string MapInfo_Map_title; -string MapInfo_Map_titlestring; // either bspname: title or just title, depending on whether bspname is redundant -string MapInfo_Map_description; -string MapInfo_Map_author; -string MapInfo_Map_clientstuff; // not in cache, only for map load -string MapInfo_Map_fog; // not in cache, only for map load -int MapInfo_Map_supportedGametypes; -int MapInfo_Map_supportedFeatures; -int MapInfo_Map_flags; -vector MapInfo_Map_mins; // these are '0 0 0' if not supported! -vector MapInfo_Map_maxs; // these are '0 0 0' if not specified! - // load MapInfo_count; generate mapinfo for maps that miss them, and clear the // cache; you need to call MapInfo_FilterGametype afterwards! void MapInfo_Enumerate();