View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-21-2013 , 23:57   Re: [TF2] Get map type without relying on map name
Reply With Quote #3

Quote:
Originally Posted by friagram View Post
Except there are things like trade maps with cps and broken logic and such that do nothing... And these "fun" maps are the type of maps that usually have strange prefixes. Grantd they may not have control point masters, but again, they may.. And a lot of them also have flags.

A better method is to detect and write out kvs to file.. Then ops can modify said kvs to override autodetection, and say.. Execute a servercommand (blag.cfg or something, etc) would be most useful.

Also, you can have multistage arena maps.. Vsh megaman? Or there are multistage cp maps.. Dustbowl, kakario which are not properly made. No idea how they are organized, but there are also castrated versions if these maps that are popularly used in vsh.
Out of curiosity, did you actually read the code before posting this? Your third paragraph implies heavily that you didn't.

The map type is discovered by first asking the GameRules entity what type of map it thinks is running. It checks the 5 standalone netprops first: MvM, KOTH, SD, ItemTest, and Training.

If it's not one of those, it asks the GameRules entity for the map type, which is one of unknown, CTF, CP, PL, or Arena.

For CTF, it just returns that it's CTF. For Arena, it just returns that it's Arena. For PL, it checks for the existence of the "tf_logic_multiple_escort" entity which is requires for PLR to actually work.

The only complicated checks come for maps that GameRules reports back as CP. For CP maps, it checks first to see how many rounds the map has. While it's checking that, it checks if a round's priority is the same as the highest priority its encountered yet. If it runs into multiple rounds with the same priority, it's a Terriority Control map (this is actually mentioned in the comments).

If it's a multi-round map and one team is marked as unable to win in all rounds, it's an A/D CP map. Any other multi-round CP map is a push/pull TC map.

If it's a single round CP map where one team is marked as unable to win, it's an A/D CP map. Any other single-round CP map is a symmetric CP map keeping in mind that we already checked if it was a KOTH map, and Arena maps aren't considered CP maps.

Incidentally, I checked a good number of standard maps against this, including:

cp_granary
cp_gravelpit
cp_dustbowl
ctf2_fort
sd_doomsday
tr_dustbowl
tr_target
arena_lumberyard
tc_hydro
ph_lumberyard
pl_goldrush
plr_pipeline

One map I know for sure it will fail on is tc_meridian... because it currently doesn't subdivide CTF maps into categories. cp_kakariko may also be subject to this due to it having multiple rounds.

It'd be nice if Valve would subdivide CP in the gamerules stuff, like marking which maps are A/D.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-22-2013 at 00:17.
Powerlord is offline