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

Mod for Pitboss Games

Discussion in 'Civ4 - PitBoss Games' started by Ramkhamhaeng, Sep 4, 2014.

  1. Caledorn

    Caledorn Chieftain

    Joined:
    Dec 3, 2005
    Messages:
    1,884
    Location:
    Arendal, Norway
    That's great! I will definitely try this, and give feedback! Thanks for all your awesome work, guys. Your contributions to Pitboss is truly appreciated. :)
     
  2. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    Nice to hear :) If you want try it as user you can test it in this game: http://civ.zulan.net/pbspy/game/1/
    If it works you should not see the loading bar. The used mod of the game (just a few MB) is linked on the page, too.

    P.S. A user notes that it does not work if the mod will loaded over the game menu ( the restart of Civ4 reverts my changes ).


    P.P.S. I've opened a ticket for your Realms mod here: https://github.com/erikmooney/Civ4RealmsBeyondBalanceMod/issues/8
    It could be useful to fix the pause game before you start a new game :)
     
  3. Caledorn

    Caledorn Chieftain

    Joined:
    Dec 3, 2005
    Messages:
    1,884
    Location:
    Arendal, Norway
    I use a separate PitBoss exe file per game hosted. How do I tell the wrapper .exe file to use the specific PitBoss exe file per game with the savegame http wrapper? :)
     
  4. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    Hello Caledorn,

    the wrapper is just for the users. As host you need just to configure a webserver.
    Did you use a Windows or Linux host for your PB Servers?


    The Readme on Github contains a description for Linux
    Spoiler :

    2. As Pitboss host ( with Linux in mind):
    Assume that your current Altroot folder for the server is $HOME/PBs/PB1
    and your server has the ip 1.2.3.4. The following steps try to fit some paths/urls
    into matching pairs.

    • Setup a webserver and prepare a folder for your PB saves and allow symlinks.
    Example path: /var/www/PBs

    • Create a folder which encodes the IP/url of your server. The syntax is "_url_[ip|url]".
    Move the Altroot folder into this directory.
    Example path: $HOME/_url_1.2.3.4/PBs/PB1.

    => At runtime Civ4 will stores the save games into
    Z:\home\$USERNAME\_url_1.2.3.4\PBs\PB1\Saves\pitboss\auto.

    • Create the directory /var/www/PBs/PB1/Save/ and place a symbolic link into the above pitboss directory.

    Now, the save games are public available. If a modified client connects, it converts
    _url_1.2.3.4/ into http//1.2.3.4/ and try to download the file. If the download fails
    the save will transfered normally.

    Edit: Example with coloured path's:
    Spoiler :

    Code:
    Url:   [COLOR="#0033FF"]www.example.com[/COLOR]/[COLOR="#FFA500"]subdomain[/COLOR]/[COLOR="#0033FF"]PBs[/COLOR]/[COLOR="#008000"]myPB[/COLOR]
    Empty Webdirectory: /var/www/[COLOR="#FFA500"]subdomain[/COLOR]/[COLOR="#0033FF"]PBs[/COLOR]/[COLOR="#008000"]myPB[/COLOR]/Saves/pitboss
    
    Altroot-Argument (Linux-Path): [COLOR="#FF0000"]/home/$USERNAME[/COLOR]/[B]_url_[/B][COLOR="#0033FF"]example.com[/COLOR]/[COLOR="#FFA500"]subdomain[/COLOR]/[COLOR="#0033FF"]PBs[/COLOR]/[COLOR="#008000"]myPB[/COLOR]
    Altroot-Argument (Wine-Syntax): Z:[COLOR="#FF0000"]\home\$USERNAME[/COLOR]\[B]_url_[/B][COLOR="#0033FF"]example.com[/COLOR]\[COLOR="#FFA500"]subdomain[/COLOR]\[COLOR="#0033FF"]PBs[/COLOR]\[COLOR="#0033FF"]myPB[/COLOR]
    
    Finally, add symbolic link. (Do not forget to allow symlinks in your webserver settings.)
    /var/www/[COLOR="#FFA500"]subdomain[/COLOR]/[COLOR="#0033FF"]PBs[/COLOR]/[COLOR="#008000"]myPB[/COLOR]/Saves/pitboss/auto -> [COLOR="#FF0000"]/home/$USERNAME[/COLOR]/_url_[COLOR="#0033FF"]example.com[/COLOR]/[COLOR="#FFA500"]subdomain[/COLOR]/[COLOR="#008000"]PBs[/COLOR]/[COLOR="#008000"]myPB[/COLOR]/Saves/pitboss/auto
    
    Legend:
    [COLOR="#0033FF"]www.example.com[/COLOR]   Your Domain (or IP)
    [COLOR="#FFA500"]subdomain[/COLOR]         Free choice
    [COLOR="#FF0000"]/home/$USERNAME[/COLOR]   Free choice
    [COLOR="#0033FF"]PBs[/COLOR]               Root folder of your PB games. If you use PBStats this should be the PBs folder of this project. 
    [COLOR="#008000"]myPB[/COLOR]							 Name of your PB, free choice
    

    For Windows it should be similiar, i.e.
    1. Assume your Domain is http://example.com and your games are organized as PBs/PB1, PBs/PB2, etc.
    2. Move your PB ALTROOT-Dir into C:\_url_example.com\PBs\PB1 and restart your server with the new path. The special foldername allows the client to detect the correct domain for the request.
    3. Create in your root folder of your webserver the folder-chain [http_root]\PBs\PB1\Saves

    Now, link (mklink-tool from Microsoft) C:\PBs\PB1\Saves\pitboss into the above folder, i.e.
    mklink /D C:\PBs\PB1\Saves\pitboss [http_root]\PBs\PB1\Saves\pitboss
    (Untested because I use Linux.)

    =>
    If a user with BTS_Wrapper.exe connects to your server the game will try to load
    http://exlample.com/PBs/PB1/Saves/pitboss/[Savename]
     
  5. Caledorn

    Caledorn Chieftain

    Joined:
    Dec 3, 2005
    Messages:
    1,884
    Location:
    Arendal, Norway
    I'm running on a Windows 8.1 installation.

    Your explanation is very handy - but I have a few additional questions:

    • The games do not follow the naming scheme of PB1, PB2, etc. - they follow varying naming schemes. I currently have games with names like RBPB18, RBPB25, Badgame4, CFC2014. Will the design of this feature work with varying names like that?
    • Do I have to modify the altroot of the games, or will a simple symlink of the current altroot into the webserver folder you're describing work the other way around? E.g. If the files are in c:\pitboss\<game name>\saves\pitboss - can I create a symlink to c:\_url_pitboss.watto.no\PBs\<game name>\saves\pitboss and leave the current altroot statements as they are?
    • Will the wrapper work for people who are running Civ4BTS using Steam?
     
  6. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
     
  7. Magno_uy

    Magno_uy Chieftain

    Joined:
    Jun 19, 2003
    Messages:
    273
    Hi Ram, I was wondering if we can include this part of Headless Mode in our Spanish forum mod. aka as aptmod.com

    Can you give me some instructions where to find this in the code?
     
  8. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    Hello Magno_uy,

    does your Mod already work in the Pitboss Mode? Sometimes a few Python errors occurs which dos not affect normal MP games, but Pitboss.

    To integrate the headless mode I would suggest the following. Just ask if something is unclear. I've integrate it already in two other mods. :)

    1. Copy simplejson.py, Webserver.py, Pitboss/*.py from
    https://github.com/YggdrasiI/PBStats/tree/master/PB Mod_v4/Assets/Python
    into your mod. If you look into three of this files you will see that are only stubs. The files will read other Python (*) files outside of the Mod directory. This made updates easier. (Savegames with password looks the assets folder!)
    => This import approach requires the usage of the ALTROOT-Argument if you start your Pitboss server.
    Otherwise the Python files (and the text file with the settings...) will not be found.

    2. Setup a game
    Follow the instructions in the toplevel readme file, PART 'Configuration of the ALTROOT Folder'.

    Short version:
    - Adapt some paths variables in PBs/seed/CivilizationIV.ini, PBs/startPitboss.bat
    - Set 'noGui' and 'autostart' on 0 in PBs/seed/pbSettings.ini

    3. Now, use the batch script to start the Pitboss server (Edit MOD variable!) and start a test game. If you see the 'Message of the day' from the pbSettings.ini, it works.

    4. Now, you could already test the headless mode and controls everything over the above settings file. Save the game in PBs/seed/Saves/multi/, put the filename into the setting file and enable the autostart+noGui flags.
    Attention: If the admin password of the game does not match with the password in pbSettings.json. The game will hang and needs to be killed by hand.

    5. To made the configuration easier, the setup of the webinterface will be the last step. Our interface runs on civ.zulan.net/pbspy and is public available.


    P.S. The newest version can be found in the branch 'PB Mod_v5'.
    I would suggest to use this one
     
  9. Magno_uy

    Magno_uy Chieftain

    Joined:
    Jun 19, 2003
    Messages:
    273
    thanks Ram I will try this and let you know!

    good 2016 for you
     
  10. Magno_uy

    Magno_uy Chieftain

    Joined:
    Jun 19, 2003
    Messages:
    273
    Im not seen it.... :cry: starting again from zero....

    I do have my C:\PBs\PB1 folder

    theres nothing else to copy to
    C:\Users\Usuario\Documents\Sid Meier's Civilization 4\Beyond the Sword\Mods\MyMOD beside this simplejson.py, Webserver.py, Pitboss/*.py ?


    EDIT ADD:
    I have try withthe full mod and i manage to make it work. But only if Iuse the full mod. Between 'all' and just 'simplejson.py, Webserver.py, Pitboss/*.py ' theres must be something else I should copy. no?

    thanks!
     
  11. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    You're right. I've forget one change...
    I assume you are able to compile new DLL files? The missing change is the definition of gc.getAltrootDir(). (If you know a better way to find the altroot directory, let me know. :)¹ )

    CyGlobalContext.h:
    Code:
      int getCITY_HOME_PLOT() const { return GC.getCITY_HOME_PLOT(); } 
    [COLOR="SeaGreen"]
      mutable CvString tmp;
      const char * getAltrootDir( ) const { 
        tmp.Convert( gDLL->GetPitbossSmtpLogin() );
        return tmp.GetCString();
      }[/COLOR]
    
    CyGlobalContextInterface4.cpp
    Code:
        .def("getDiplomacyPowerTypes", &CyGlobalContext::getDiplomacyPowerTypes, "string () - Returns enum string")
    [COLOR="SeaGreen"].def("getAltrootDir", &CyGlobalContext::getAltrootDir, "string ( )" )[/COLOR]
    

    ¹) FVariableSystem.h looks promising.
     
  12. DarkLunaPhantom

    DarkLunaPhantom Chieftain Supporter

    Joined:
    Feb 4, 2013
    Messages:
    365
    Wow, this is excellent and works marvelously. I am trying to merge this with K-Mod and so far all options from the web interface work as intended.

    Do you intend to add an option to kick players from game to the web interface?
     
  13. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    tI'm glad to hear that almost one person managed a merge of the mod :)

    Kicking could be useful, yes. It was the last feature of the normal Pitboss window without an web based replacement.
    I've updated the mod and now it should support the Kicking of players as wished. (I've see that you created a test game on Zulan's Server. Until he updates the server, kicking won't will be available.)

    Edit: Only relevant changes for your K-Mod migration should be this

    If you want host a new Pitboss game please note that our real good stuff hides in the test-subfolder :)
    1. GetSaveOverHttp: Wrapper Exe which hookes the tranfer of savegames during the loading. Speeds up the loading time, but requires access to the savegames over Http(s).

    2. fix_upload_bug: The pitboss server contains a bug which leads
    to very high bandwidth usages.
    This folder contains server applications which
    detect this bug and close the network connections.
    ( It's fakes the disconnect messages of clients. )

    3. Civ4BeyondSword_Pitboss2015.exe:
    Modified executable where almost all gamespy domain names was replaced
    by a new domain. The new domain refers to Zulan's server which host
    a NAT service as gamespy replacement.
    This patch unlock the Direct IP mode again and fix statup issues of
    the Pitboss application, too.
     
  14. DarkLunaPhantom

    DarkLunaPhantom Chieftain Supporter

    Joined:
    Feb 4, 2013
    Messages:
    365
    I've seen it, I didn't think that something like GetSaveOverHttp was even possible. :eek:
    However, since it requires that clients start the game using the wrapper exe, does that make it incompatible with the steam version, since in steam version game cannot be started using the game exe?
     
  15. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
  16. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    One of our players was able to help me with the test.
    He did not change the start arguments of Civ4 in his Steam library but found an other fine solution: The normal Exe of Civ4:BTS could be used to start the Steam version, too.


    Conlusion (for other users):

    How to play Pitboss games over Direct IP (2016)​


    The Gamespy Servers are down and the default Steam variant of Civ4 does not support Direct IP.
    In both cases it is possible to benefit from the Gamespy substitute server project.


    The long way:

    The short way:
    Put Civ4BeyondSword2015 from our Mod project repository into your Beyond the Sword directoy (it already contains the new urls to Zulan's server) and start Civ with this file, now.
    Note that this does not release you from installing the essential latest patch 3.19!



    ¹) Many users, like the person in the linked thread, of Windosw 10 reports that they can not install this patch. I've extracted the content of this patch and put it in Zip file.
     
  17. DarkLunaPhantom

    DarkLunaPhantom Chieftain Supporter

    Joined:
    Feb 4, 2013
    Messages:
    365
    Thank you, this works. However, since I didn't install civ4 in the default steam library folder (...\Steam\steamapps\common), I had to make a symbolic link of my civ4 folder there for this to work. It's because steam games can be started with exe only when they're in the default folder.
     
  18. DarkLunaPhantom

    DarkLunaPhantom Chieftain Supporter

    Joined:
    Feb 4, 2013
    Messages:
    365
    I've seen that your bugfix for OOS in city naming changes city naming sometimes, for example as holy rome my capital was named "AachenAix-la-Chapelle" instead of "Aachen". I read the code and I've got no idea why is that happening...

    EDIT: It's not OOS bugfix, actually your textfile named CIV4GameTextChanged_BTS.xml that has the same name as the file where Aachen's name is saved in BTS somehow caused this weird behaviour. Changin its name to anything else fixes the problem.
     
  19. Ramkhamhaeng

    Ramkhamhaeng Chieftain

    Joined:
    Feb 24, 2014
    Messages:
    142
    Strange Bug. I will rename the xml file in this mod, too.

    @OOS-Fix-Code: If you want know what it does:
    The bug belays in this part of the changed function of CvPlayer.ccp
    Code:
    	for (pNode = headCityNameNode(); (pNode != NULL); pNode = nextCityNameNode(pNode))
    	{
    		szName = gDLL->getText(pNode->m_data);
    		if ([b]isCityNameValid[/b](szName, true))
    		{
    			szName = pNode->m_data;
    			break;
    		}
    	}
    
    If a valid name was found szName contains the key of the city name.
    In some rare cases no valid name will be found by this loop and szName contains the last value for a city key. (I does not check if some TXT_KEY_CITY entries has empty values, but according to the Debugger szName was sometimes empty).

    The problem is that isCityNameValid(...) depends from the language.
    Thus, szName gets an other value on the server's side.
    The OOS-Fix code add some getSorenRandom-calls to balance the number of calls.
     
  20. ntenistromeros

    ntenistromeros Chieftain

    Joined:
    Mar 19, 2009
    Messages:
    34
    Hi guys any luck for a new Pitboss?
     

Share This Page