OOS in pitboss/hot-join (inc possible fix)

Discussion in 'Civ4 - Fall from Heaven' started by Dis Citsatnaf, Oct 2, 2011.

  1. Dis Citsatnaf

    Dis Citsatnaf Chieftain

    Joined:
    Oct 2, 2011
    Messages:
    17
    Edit: TL;DR: both 0.41o vanilla and More Naval AI 1.7 DLLs that seem to make ffh2 work with pitboss and MP hotjoins is linked at the bottom of this boring, technical post.

    Hello there (long time lurker, etc),

    We've been trying to get a pitboss game of FFH2 up, and ran into the issue (familiar in hindsight from normal MP) where any hot-joining player will go OOS with the rest of the p2p mesh, including the pitboss 'player' (who keeps his own sync and options checksums.)

    After filling CvGame.cpp up with debugging output, it turns out that the culprit APPEARS to be the following line in CvCity.cpp:

    m_iCrime = GC.getGameINLINE().getSorenRandNum(20, "Crime");

    which is called in CvCity::init, including when the connecting client has deserialized the game (including the random seed,) and is creating its own CvCity objects, even though the other players ran this code when the city was built (and the 'correct' crime value was already deserialized from the p2p mesh.) In other words, RNGs are being called non-synchronously.

    I'm sure there's a better fix here (maybe moving the getSorenRandNum call to somewhere it's guaranteed to be executed synchronously), but changing it to

    m_iCrime = 0;

    is a guaranteed to be synchronous and seems to work. I'm not sure what the ramifications of every city starting with a base crimerate of 0 are to gameplay, but my understanding is that crime is mostly a flavour mechanic in any event, and the utility of being able to hot-join MP games outweighs it, at least for me.

    Here are pre-compiled DLLs with this change (against 0.41o, and Tholal's Naval AI mod 1.7) if anyone wants them. I'll probably have another look at the code later and try and find a better spot to randomize m_iCrime (such that the code isn't called during deserialization), if anybody wants to have a crack at that, be my guest.

    /S
     
  2. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Interesting find!

    As far as I know, Crime Rate is only used for events, so your fix shouldn't have any major effects on the game.
     
  3. Dis Citsatnaf

    Dis Citsatnaf Chieftain

    Joined:
    Oct 2, 2011
    Messages:
    17
    Having more of a look at the code, I'm not entirely sure if there's anywhere safe in CvCity to make an RNG call (at least not anywhere safe in the initialization methods at any rate.)

    Is there a way to tell whether an object is being created because the savegame/network code is about to deserialize something into it (versus because somebody actually built the city just now?) If there is, I can't find it.
     
  4. Sareln

    Sareln Warlord

    Joined:
    Dec 29, 2005
    Messages:
    211
    Location:
    Davis, CA
    Awesome Find!
     
  5. Dis Citsatnaf

    Dis Citsatnaf Chieftain

    Joined:
    Oct 2, 2011
    Messages:
    17
    Thanks Sareln :)

    Are you guys likely to include this fix or something similar in EitB?
     
  6. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Yeah. I think Kael made a mistake by putting that randomization there. Would probably be better to put it in the python code for onCityBuilt.
     
  7. Dis Citsatnaf

    Dis Citsatnaf Chieftain

    Joined:
    Oct 2, 2011
    Messages:
    17
    Yep, just tested this.

    city.changeCrime(CyGame().getSorenRandNum(20, "Crime"))

    added at around line 2294 in CvEventManager.py does the trick. Having said that, this gives a random 0-20 crime in every city built; is this how it's meant to work? I don't recall _ever_ having crime in the capital.
     
  8. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Looks like it. I just started a new game on an older version of my mod and my capitol started with 18% crime.
     
  9. Sareln

    Sareln Warlord

    Joined:
    Dec 29, 2005
    Messages:
    211
    Location:
    Davis, CA
    Definitely, given that it's the difference between having pitboss and not having pitboss :lol:
     
  10. Nykidemus

    Nykidemus Chieftain

    Joined:
    Jan 16, 2012
    Messages:
    10
    I'm pretty excited to try this out, but I'm not entirely sure where to put the DLL.
     
  11. muzbang

    muzbang Prince

    Joined:
    Feb 22, 2007
    Messages:
    307
    hey guys,
    I played with friends
    with BTS 3.19
    FFH2 2041n with o patch
    more naval IA 2.2

    but unfortunatly, OOS happened... around turn 70 (2 times...)

    Now i tried the CvGameCoreDLL.dll in the
    C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets Folder,
    but when i start FFH2, i have an error message while XML is loading :

    "There are more siblings than memory allocated for them in
    CvXMLLoadUtility::SetVariableListTagPair
    Current XML file is xml\Civilisations/CIV4LeaderHeadInfos.xml "

    Don't understand why as games have been played with that file
     
  12. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    This DLL was made with version 1.7 of More Naval AI. There have been quite a few changes since then, some of which are incompatible with older versions.

    If you can attach your OOS log, I can try and figure out what the problem is.
     
  13. muzbang

    muzbang Prince

    Joined:
    Feb 22, 2007
    Messages:
    307
    Thanx for your reply,
    I'have to look for that older version (if it's still dwldable)
    I have no log of the OOS,
    In few words, it was strange because the 3 human players had the same value :crazyeye:

    OSS happened at the begining of 1 turn, when we discovered archery,
    and OOS was unsolvable reloading some turn earlier always lead to the same OOS, same turn.

    We played with no events, and nothing special happened...

    In other hand, we played 30 more turns with OOS and that red message.
    Then the game was reloaded on a server, and today, when i loged in, the situation was realy different than when we stoped the game yesterday, as AI has captured all my cities :eek: and some of the cities of my mates.

    It's just like if we have played a game with my mates that was different of the game hosted in the server.

    But i had heard some things like this on BTS MP game that have been continued despite the OOS.

    Parralel universes really exists :lol:
     
  14. dratboy

    dratboy Chieftain

    Joined:
    Jan 31, 2007
    Messages:
    69
    Location:
    Fredericton, Canada
    Hi there! It's been awhile since anyone has posted here, but I just wanted to

    a) thank the OP for this fix! Thanks to your find, I am currently hosting a successful game of FFH on Pitboss and we just passed the 200 turn mark! It's been a huge blast and although we get some OOS errors during simultaneous play, (par for the course in pitboss) the game hasn't had any permanent OOS failures like so many complain about. Awesome! :thumbsup:

    b) If anyone sees this, are there any other FFH pitboss games going on out there? I don't see any obvious ones on civstats.

    (except ours)
    http://www.civstats.com/viewgame.php?gameid=2563

    Cheers
     

Share This Page