xna-cncnet-client
xna-cncnet-client copied to clipboard
Rename incompatible map extensions to .map
There were two bits of functionality in the YR client when it was closed source:
- It moved any
.yrm
maps from the root game directory into the CnCNet maps folder. - Renamed any
.yrm
maps in the CnCNet maps folder to.map
Something like the below probably.
string path = Directory.GetCurrentDirectory();
DirectoryInfo d = new DirectoryInfo(path);
FileInfo[] infos = d.GetFiles();
foreach (FileInfo f in infos)
{
if (f.Extension == ".yrm")
{
File.Move(f.FullName, Path.ChangeExtension(f.FullName, ".map"));
}
}
In fact, we want these two functions back which is fairly convenient for playing. Please add them back.
How should it handle a scenario, where the corresponding .map file already exists?
I am asking, because I had been playing around with something related to this, namely allowing the client to just flat-out load custom maps with different extensions - for which I have a working implementation, albeit not currently public and likely in need of optimisation. I did that because RA2 / YR map editor always saves .yrm maps if it does not think it is a mission, which gets cumbersome with current custom map system.
This approach would not suffer from filename overlaps, but would at minimum atleast slightly increase maploader code complexity. My current implementation allows defining arbitrary file extensions, however I think simply allowing the standard extensions (yrm/mpr) would be acceptable. It however also creates ambiguity for the loadmap chat command - currently it only loads .map at default, others if explicitly defined after filename. Not sure what the best approach here would be, depending on whether or not the allowed extra extensions should be arbitrary or fixed. If the list is short enough, simply going through all extensions and loading all files matching input filename could be acceptable.
The file copying from game root would obviously work just fine with this method as well.
.map
is the only extension accepted in the mapdb iirc. If a .map
already exists, I would assume it would just ignore it as it's already using it and loaded?
Why not enable the client to read .yrm and .mpr files as well? This would make map makers lives easier by removing an annoying step of having to rename the extension on their map every time they want to test it.
I think renaming map_name.yrm
to map_name.yrm.map
would be the solution here, I doubt someone will intentionally add two extensions in the mapname, and if it already exists - just overwrite it?
In my opinion, for simplify code if 2 maps have the same file name (aaaa.yrm and aaaa.map) the file with ".map" should be the only available in the client list and the ".yrm" file ignored until the user renames manually that ".yrm" map.