Parallel Maps

LyTning94

Dragonborn
Joined
Nov 10, 2010
Messages
397
Location
Skyrim
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 {
NO_MAP = -1,
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.​
};
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()];
but since the XML is not loaded yet, getNumMapInfos() was returning 0. To fix this, I added this file to load that number into memory to be used when the size of the mapInfos vector is 0.


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.
 
Changelog:

Spoiler :
1.01 - Fixed a few bugs
 
mmhh....mmhh....will have to test that out.

People already asked if it was possible to make a mod, which continues civ after landing on AC (or in my case on the Mars), and this should offer the possibility to. Not that I'm considering actually doing that (due to time), but this could be quite interesting.
 
Wow, great work. Thx so much! This opens the door to a whole new era of cIV!!!

:xmas: santa coming early this year :goodjob:
 
This could almost be made for the Planetfall mod. Launch a spaceship and play Planetfall, all the while being able to continue the fate of Earth. Have Planet all to yourself until other nations launch their own spaceships.

Now that would be an interesting fusion of mods, no?
 
People already asked if it was possible to make a mod, which continues civ after landing on AC (or in my case on the Mars), and this should offer the possibility to. Not that I'm considering actually doing that (due to time), but this could be quite interesting.

This could almost be made for the Planetfall mod. Launch a spaceship and play Planetfall, all the while being able to continue the fate of Earth. Have Planet all to yourself until other nations launch their own spaceships.

Now that would be an interesting fusion of mods, no?

It's ideas like these that imo make the concept so exciting. There are so many possibilities, and I'm hoping that this can get incorporated into tons of great mods.
 
Very interesting!

So on map switch, all unit and city info is left with the old map, but player info carries over?

Correct. :yup:

i wanna see this implemented as a mod,

it holds a great potential

Great job LyTning94!:goodjob::goodjob: We at C2C are very excited about this. Thanks again for this modding revolution.

Wow, great work. Thx so much! This opens the door to a whole new era of cIV!!!

:xmas: santa coming early this year :goodjob:

Thanks! :) Hopefully C2C and lots of other mods can put this to good use.
 
Now we just need a version of civ 4 that can read more than 3 gigs of ram.

That would be nice...

I ran a test using task manager on how much more memory this mod uses, and came up with these results:

  • After initially allocating the map objects, the game's memory increased by less than 1K bytes for a map.
  • However, after allocating the plots (on a standard size map) for one map, it increased by 1048K.
  • The mod running 9 seperate standard size maps used 43,000K more memory than a vanilla BTS game with a standard size map.
Of course this was also at the beginning of the game, so as the game progresses and improvements are built, I would guess the memory difference would increase.

So it does appear to be a substantial increase in memory usage (~301,000K versus ~258,000K with 9 maps), but not an overly large one. I'm guessing most mods won't be running 9 maps at the same time, so there won't be quite this much of an increase.
 
looks nice. :goodjob:
would it be possible to take the citys, units, technologies, improvements, and this other player specific stuff from the old map? so that just the terrain and the features get changed?
 
looks nice. :goodjob:
would it be possible to take the citys, units, technologies, improvements, and this other player specific stuff from the old map? so that just the terrain and the features get changed?

The technologies are already shared between the two maps. I would guess sharing all this would work, but you could end up with cities/units on water, improvements on tiles they shouldn't be, etc.
 
my idea was to switch between two or more worldbuildersaves, like an europe at summer and on at winter. but i´ve forgot that the progress of science and citys would be also deleted.. so i think it isnt a good idea.
 
A very interesting idea, but is it possible to not share all player data (probably just player name) between the maps? As with Mods like Planetfall, the big thing is that the new Civ(s) on the new world have very little, if anything at all, to do with the old Civ(s) from the old world. The new world would also have it's own unique Tech Tree, so sharing Techs between maps would seem sub-optimal (at least, to me).
 
A very interesting idea, but is it possible to not share all player data (probably just player name) between the maps? As with Mods like Planetfall, the big thing is that the new Civ(s) on the new world have very little, if anything at all, to do with the old Civ(s) from the old world. The new world would also have it's own unique Tech Tree, so sharing Techs between maps would seem sub-optimal (at least, to me).

At the moment the mod doesn't do this, but it should be possible. Find where the discovered techs are stored (in CvTeam, I think), and create an array of the array that holds them. Then access them by returning the GC.getCurrentMap() element of the array.

It's the same way I treat units and cities in the mod.
 
I believe I forgot to mention this in the original post, but there is a way to make maps smaller than the original map through making some plots impassible and unrevealable. This is done through the CvPlot::setNull() function. Of course this also takes out the possibility of wrapping.

In this way the maps are actually still the same size (which is required by the game engine), but can be made to be different sizes.
 
I just wanted to drop by and mention that when I was much younger, I used to watch my dad and brother play Civ 2. They would occasionally try to describe the game to me, and when they told me about the space race victory, I thought it was the coolest thing ever that you could build a civilization from the ground up and then do it all over again on another planet; it wasn't until many years later that I actually played the Civ games and was crushed to find out that it doesn't work that way.

So basically what you did here is a giant leap towards achieving a childhood dream that I've nurtured for about 15 years now. :D
 
Top Bottom