Parallel Maps
Download Here
Current Version: Beta 1.01
Parallel Maps is a modcomp which allows one game to hold several different maps, which can be switched between to manage several different worlds in the same game. I have accomplished this by allocating multiple CvMap objects in memory at the same time, and switching between them whenever necessary.
It is not playable by itself; it requires some XML, python, and/or SDK modding to create the maps and call the function to switch between them. I set up a new XML system for the different maps. This can be found in Civ4MapInfos.xml. Each entry contains the width and height of the map, the wrapping information, a WB map, and a map script. There is no entry required for the original map, just subsequent ones. To generate each map the first time, the game will use, in order of precedence, first the WB map, next the map script in the XML entry, and if neither are provided, will use the map script from the original map. I have included some more details in the readme file.
I have exposed the following functions to python:
Spoiler :
enum MapTypes {
};
MapTypes CyGame::getCurrentMap()
void CyGame::changeCurrentMap()
void CyGame::setCurrentMap(MapTypes eNewMap)
int CyGlobalContext::getNumMapInfos()
CvMapInfo CyGlobalContext::getMapInfo(MapTypes eMap)
CyMap* CyGlobalContext::getMapByIndex(MapTypes eIndex)
void CyGlobalContext::switchMap(MapTypes eMap = NO_MAP)
int CvMapInfo::getGridWidth()
int CvMapInfo::getGridHeight()
bool CvMapInfo::isWrapX()
bool CvMapInfo::isWrapY()
string CvMapInfo::getInitialWBMap()
string CvMapInfo::getMapScript()
MapTypes CyMap::getType()
void CyMap::setType(MapTypes eNewType)
NO_MAP = -1,
INITIAL_MAP,
MAX_MAPS = 10
INITIAL_MAP,
MAX_MAPS = 10
// MAX_MAPS is more of a precaution than anything. You can make this value anything you like, but
// I thought I should have some form of checking so that the game doesn't allocate memory for
// a huge amount of maps.
// I thought I should have some form of checking so that the game doesn't allocate memory for
// a huge amount of maps.
MapTypes CyGame::getCurrentMap()
void CyGame::changeCurrentMap()
void CyGame::setCurrentMap(MapTypes eNewMap)
int CyGlobalContext::getNumMapInfos()
CvMapInfo CyGlobalContext::getMapInfo(MapTypes eMap)
CyMap* CyGlobalContext::getMapByIndex(MapTypes eIndex)
void CyGlobalContext::switchMap(MapTypes eMap = NO_MAP)
int CvMapInfo::getGridWidth()
int CvMapInfo::getGridHeight()
bool CvMapInfo::isWrapX()
bool CvMapInfo::isWrapY()
string CvMapInfo::getInitialWBMap()
string CvMapInfo::getMapScript()
MapTypes CyMap::getType()
void CyMap::setType(MapTypes eNewType)
The switchMap() function will switch the map to whatever map you provide or, by default, the next map in the XML file. This is the only function that needs to be called to switch between maps.
The modified SDK files are included, and I have commented all code with 'Parallel Maps' for easy access.
In the mod folder, there is also a file called Maps.num. This file contains the number of map entries in Civ4MapInfos, and must be kept manually updated to match this number.
While the game engine requires all the maps to be the same size, there is a way to make maps smaller than the original map through making some plots impassible and unrevealable, making only a portion of the larger map playable. This is done through the CvPlot::setNull() function. Of course, this also takes out the possibility of wrapping.
Spoiler modders :
The reason for this is that the XML is not loaded into the game until after the CvMap objects are allocated. I allocate the maps in an array like this
Code:
m_maps = new CvMap[GC.getNumMapInfos()];
This is a beta version, so don't expect it to be bug-free at first. I haven't done enough testing yet for that. Please report any bugs you come across so that I can fix them and get this as bug-free as possible.
Spoiler screenshots :
The original map
The same location on the second map after it has been switched to.
Credits: AIAndy, for giving me lots of help when I needed it.