1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Parallel Maps

Discussion in 'Civ4 - Mod Components' started by LyTning94, Apr 4, 2012.

  1. LyTning94

    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.
     
  2. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    Changelog:

    Spoiler :
    1.01 - Fixed a few bugs
     
  3. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,211
    Location:
    DE/NL/FR
    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.
     
  4. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,530
    Location:
    israel
    i wanna see this implemented as a mod,

    it holds a great potential
     
  5. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Very interesting!

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

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,069
    Location:
    America
    Great job LyTning94!:goodjob::goodjob: We at C2C are very excited about this. Thanks again for this modding revolution.
     
  7. DRJ

    DRJ Hedonist

    Joined:
    Dec 1, 2005
    Messages:
    1,514
    Location:
    Hamburg, Germany
    Wow, great work. Thx so much! This opens the door to a whole new era of cIV!!!

    :xmas: santa coming early this year :goodjob:
     
  8. Derf

    Derf Modular Mushroom

    Joined:
    Jun 1, 2002
    Messages:
    595
    Location:
    UK
    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?
     
  9. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    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.
     
  10. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    Correct. :yup:

    Thanks! :) Hopefully C2C and lots of other mods can put this to good use.
     
  11. Terradive

    Terradive Warlord

    Joined:
    Jun 4, 2009
    Messages:
    186
    Now we just need a version of civ 4 that can read more than 3 gigs of ram.
     
  12. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    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.
     
  13. fromAustria

    fromAustria Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    54
    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?
     
  14. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    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.
     
  15. fromAustria

    fromAustria Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    54
    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.
     
  16. MagnusIlluminus

    MagnusIlluminus Emperor

    Joined:
    Mar 13, 2012
    Messages:
    1,997
    Location:
    In my own little world...
    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).
     
  17. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    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.
     
  18. LyTning94

    LyTning94 Dragonborn

    Joined:
    Nov 10, 2010
    Messages:
    397
    Location:
    Skyrim
    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.
     
  19. stgelven

    stgelven Prince

    Joined:
    Apr 22, 2003
    Messages:
    398
    Location:
    pays de loire - france
    hi,
    maybe scenarios could be maid, using the change of map like a step in the scenario, is it possible to preload premad maps with different rules in it? my idea is to use different maps like different eras?
     
  20. Jabarto

    Jabarto Emperor

    Joined:
    May 15, 2007
    Messages:
    1,025
    Location:
    Colorado, U.S.
    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
     

Share This Page