Mod for Pitboss Games

I myself semi-migrated on realmbeyonds site and on the Apolyton spanish community. Regular pitbosses there. Ot4e is there too.
 
P.P.S. It exists an other solution which does not need any changes, but a bond of trust between you and your pitboss host:
Assume that the pitboss host uses the folder Z:\PBs\myPB\Saves\pitboss\ for the save games.
If you mount this folder on your machine with exaclty the same path Civ4 will handle the saves like locale files.
The mounting could be done over several ways. Linux users could use sshfs or ftpfs.
Windows users could mount the pitboss folder with webdav (i.e to Drive X: ) and use mklink to create a link with the desired path ( mklink /D Z:\PBs\myPB\Saves\pitboss X: ).

I've tried this using an ftp server on Windows (Filezilla) and problem arises when transfer starts before new save file is created so ftp server locks it and pitboss can't overwrite the file so it gets an error which causes pb to be blocked until you click ok on the error window. (That's my guess why "save file cannot be created" error happens.) I''ll try you wrapper exe now, since I don't know how to delay transfer or something similar.

EDIT: I've tried the wrapper exe, I think I've set up everything right, but it just waits for about 10 seconds and then resumes normal slow transfer. (I can access saves through browser, I've checked paths multiple times, etc.)
 
@Wrapper: You can test it's functionality in our test game, if you want. (This game uses an admin password. If the game crashs on login some md5-Hashs of the game/Mod does not match. Approx 80% of our the Pitboss players got this problem regardless how detailed I've described the mod installation step ;))
If the Wrapper returns to the normal transfer the timeout for fetching the file was reached. Then, Civ4 falls back to the normal variant. This could indicate a problem with the paths or the "save file cannot be created" popup.
Could you use Wireshark to look which file path was send by the Pitboss server?


@Server setup: Seems that you encounter a bug! I'm share your assumptions about the "save file cannot be created" message.
I could now speculating about the reason why we never has this problem (network delay, faster server, Linux/Apache/Wine combo),
but assume that a short timeout in the wrapper could solve this.
I've will add a two second timeout in Line 191 of https://github.com/YggdrasiI/PBStat...SaveOverHttp/sources/CivSaveOverHttp/main.cpp.
It would be nice if you could test this.
 
@Wrapper: You can test it's functionality in our test game, if you want. (This game uses an admin password. If the game crashs on login some md5-Hashs of the game/Mod does not match. Approx 80% of our the Pitboss players got this problem regardless how detailed I've described the mod installation step ;))
If the Wrapper returns to the normal transfer the timeout for fetching the file was reached. Then, Civ4 falls back to the normal variant. This could indicate a problem with the paths or the "save file cannot be created" popup.
Could you use Wireshark to look which file path was send by the Pitboss server?

Ok, I'll try with your test game and check with Wireshark what is happening.

EDIT: I've tried your test game and fast loader works. That means I probably messed up the paths or something somewhere, I'll try checking with Wireshark.

@Server setup: Seems that you encounter a bug! I'm share your assumptions about the "save file cannot be created" message.
I could now speculating about the reason why we never has this problem (network delay, faster server, Linux/Apache/Wine combo),
but assume that a short timeout in the wrapper could solve this.
I've will add a two second timeout in Line 191 of https://github.com/YggdrasiI/PBStat...SaveOverHttp/sources/CivSaveOverHttp/main.cpp.
It would be nice if you could test this.

Actually, this happened to me without using the wrapper at all, I just mounted ftp folder locally to match the save path of pitboss, so the problem is not in any of your files (since I didn't use them, I just used the idea from your post i quoted before). I was just commenting that the possible method you outlined in one of your post probably also needs some kind of delay.
 
[...] I just mounted ftp folder locally to match the save path of pitboss, so the problem is not in any of your files (since I didn't use them, I just used the idea from your post i quoted before). I was just commenting that the possible method you outlined in one of your post probably also needs some kind of delay.

Sorry, I've ignored the quoted section in your post and miss-understand that you used this approach with direct mounting.

The filename of the savegame depends on the login name. It would be a try to delete the existing file manually and hope that Civ4 waits with reading of the file till it was created. If the problem was caused by some kind of locking mechanism by the ftp program you could try an other sharing variant. I will give an local Apache share a try and reports here.
 
I've managed to get it working.

I used Wireshark and discovered that http (i.e. not https) method doesn't really work. Client first sends a couple of request that sever doesn't understand (I'm guessing that's https attempt) and then it send sequence of GET request going through the folder tree. (Why cannot it request the save immediately since it knows the path?) But the problem is that, while server responds immediately, the client waits 2-3 seconds between each 2 requests so it takes a really long time to finally request the save and by then the whole process probably timeouts and fails. There might be some bug there in your code as I've got no idea why does it take so long.

On the other hand, https method works great, everything is done pretty much immediately. (It works with self-signed certificate with no problems.)

Thank you for all your help and all these great pitboss utilities that you've provided! :)
 
Ok, I will re-check that. The timeout between the https request (first) and http request (if first fails) seems to be the reason. I could lower the timeout but probably I will add the right protocol to the folder name, i.e.
_url_[the url] will be split into _http_[the url] or _https_[the url]. :)


Yesterday I've managed it with a Webdav-Share, too. This functionality could be enabled for many webservers. If your PB game is on X:\{PATH}\PBs\PB1
and the webdav root directory is {url}/webdav.
you has to mirror the path structure into the webdav folder:
webdav\{PATH}\PBs\PB1\Saves\pitboss

and map the folder X:\{PATH}\PBs\PB1\Saves\pitboss\auto into the above one with a symlink.


After this I've used the Windows Exporer to connect the X: drive with {url}/webdav and the client save paths equals the server one. This made the Wrapper obsolete, but has also a few drawbacks. (Using the share was slow like hell.)
 
Yes. Sorry, until now we never implement a kind of victory screen. :-( Setting the status by hand is related to this.
Nevertheless, it' s one of the next features which will be implemented.
 
Well, I've wrote this stuff yesterday. If Zulan update his PBSpy-Server it would be possible to set the victory state of a game. As side-effect the status will be changed, too.

Edit: The interface was updated. Now, a victory and kicking player screens are available.
 
Great! :)

If you're going to be making further modifications, I've got some suggestions:
- ability to put custom headline in victory information (now it's possible to customize leader picture and text, but not the headline itself)
- renaming players
- option to make tracker automatically try to reconnect (without having to click reconnect button) when disconnected because pitboss unavailable (e.g. every 2^n minutes for n positive integer)

Obviously it's nothing important, just some things that might be nice to have.

Edit: Actually, I can probably do the last thing easily myself for my games without even changing PB Mod code, but with using a script which checks connection status.
 
@DarkLunaPhantom : Raising this old thread because I need an advice from you, since you have merged Pitboss mod into K-Mod and other mods. I plan to merge this mod into Rise of Mankind: A New Dawn (RAND), but I'm a bit lost about which files I should use. I'm ok with the dll part, I think, I can do that. But what about the rest that's needed? Even if I leave alone the web interface for the moment, what else should I merge? I've seen there some python code both in PBs and PB Mod_v6 folders. Which one should I use? Do you have any advice? Thanks.

P.S. I'm still not sure on how this all is working with a custom mod like K-Mod or RAND. I mean, I think I need to merge the code into the mod I'm interested into, but what about Pitboss? Do I need to simply launch it as described here after I've merged Pitboss mod into RAND? Thanks again.
 
I'm ok with the dll part, I think, I can do that. But what about the rest that's needed? Even if I leave alone the web interface for the moment, what else should I merge? I've seen there some python code both in PBs and PB Mod_v6 folders. Which one should I use? Do you have any advice? Thanks.

Beside the dll part you need python files from PB MOD_v6 folder, namely Webserver.py, simplejson.py, PbAdmin.py and PbWizard.py. (You need to merge a couple more python things if you want to merge trade screen pause unfreeze bugfix.)

I mean, I think I need to merge the code into the mod I'm interested into, but what about Pitboss? Do I need to simply launch it as described here after I've merged Pitboss mod into RAND?

Yes, to start Pitboss you need a copy of PBs folder and follow those instructions. Old Pitboss (through Pitboss exe) is not available for mods with these modified PbAdmin and PbWizard files.
 
Hello,

first of all I want to write that your request was the reason to push my latest
version of the mod on Github. The branches master, unstable, and PBMod_v7 now
point to version 7 of the mod. :) Please use this as base because the previous version
contains an ugly bug which made an save "unloadable" after removing the ingame admin password.

Secondly, here is an sketch do explain the structure of the required files:

– [Civ4:BTS]\Mods\PB Mod_v7\CvGameCoreDLL : Sources for DLL to merge the changes
Please note the change of one compiling argument (/Oy-) in the Makefile.
– [Civ4:BTS]\Mods\PB Mod_v7\Assets\CvGameCoreDLL.dll : Compiled DLL
– [Civ4:BTS]\Mods\PB Mod_v7\Assets\CvGameCoreDLL.dll : Compiled DLL
– [Civ4:BTS]\Mods\PB Mod_v7\Assets\Python\Webserver.py and
[Civ4:BTS]\Mods\PB Mod_v7\Assets\Python\Pitboss\*.py : "file stubs" which loads python files outside of the mod folder. This allows us change some python code later without influence of the internal hash value for the files.

Now follows the important stuff for the server side. Let's assume you cloned my github repo to
C:\PBStats and you copied my example game from C:\PBStats\PBs\seed to C:\PBStats\PBs\PB1.

– [PBStats]\PBs\PB1\Civilization.ini : Normal Civ4-Ini file, but variable PitbossSMTPLogin is misused as
path definition to this folder. (Here, set it to C:\PBStats\PB1).
– [PBStats]\PBs\PB1\pbSettings.json : Config file for "our" settings. Set "autostart" to 0 to enable the standard Pitboss wizard at startup.
– [PBStats]\PBs\Python\v7\*.py : These files will be loaded at startup of the Pitboss server.
(The game will try to load files in the relative path "[PitbossSMTPLogin]\..\Python\v7")
– [PBStats]\PBs\startPitboss.bat : Helper script to start Pitboss executable with the correct arguments. (mod and /ALTROOT )
– [PBStats]\PBs\startPitboss.sh : Startup helper script for Linux


I would recommend to start one game with my mod and if this works replace the startup arguments in startPitboss.bat with your mod.

Common issues:
- Python files/Altroot directory not found => Pitboss server closes at startup without any error message.
- Autostart enabled, but password not match to save game => Pitboss server hangs with high cpu usage.
( I try to prevent this by prepend an own check of the password hash before the internal Civ4 function is called.)
- Savegame with same filename in different subfolders (PBs\PB1\Saves\[...]). Mod accidental select the wrong file.
 
I was wondering, does the save transfer over http also work in direct IP multiplayer? I mean, it's painfully slow when you connect to another player during an advanced game. it takes minutes to transfer the savegame. is it possible to make your save over http work for DIRECT IP games too?
 
Currently, only the receiving of the save is modified by my modification (combined with an external webserver providing the folder with the saves).
To extend this on DirectIP games, the sending side had to be modified, too (i.e. to open extra port for file transfer). Well, I think it's possible but not trivial.

It could be easier to switch to an other approach like eliminating the timeout between the sending of packages in the net code of Civ4. (This was my first approach but at that time I was not able to made it working.)
 
Currently, only the receiving of the save is modified by my modification (combined with an external webserver providing the folder with the saves).
To extend this on DirectIP games, the sending side had to be modified, too (i.e. to open extra port for file transfer). Well, I think it's possible but not trivial.

It could be easier to switch to an other approach like eliminating the timeout between the sending of packages in the net code of Civ4. (This was my first approach but at that time I was not able to made it working.)

Mmm, I think both modifying the sending side and eliminating the timeout in the net code is beyond my ability although I mod BTS dll since 4 years now. I don't even know where to look for the net code of civ4. If you have any hint or sooner or later you can do it yourself, I will be more than happy (and probably everyone playing Civ4 multiplayer too). I wish I could make Pitboss work for my mod (Rise of Mankind: A New Dawn), but there are probably other problems with some component of the mod which throws the game OOS very frequently with Pitboss (definitely much more often than Direct IP), so probably Direct IP is the easier choice for me right now.

Edit: I also tried the other method without your dll for http transfer, I mean sharing the savegame folder but it didn't work. I tried both sharing it on a webspace (OneDrive) and using my NAS, but although I could access the files, transfer was always slow as usual. I suppose I ran into the same problem DarkLunaPhantom and you were talking about i.e. the timeout
 
Last edited:
Well, I keep trying because I would like to make this thing work for Direct IP too; but before doing that I'm trying to understand the full procedure you've set up, and there's something I probably don't understand.
Here's the procedure as described on github:


Spoiler :
Less flexible, but without any modifcation of the Civ4 executable, you could also mount the http folder with the saves into your local filesystem. If the save path on the client equals the path on the server it will be loaded over this way.

Example set of paths for BTS_Wrapper.exe and Webdav usage:

Public http folder with Webdav support: http://{server}/{prefix}
Altroot directory on Server: /home/$USERNAME/_http_{server}/{path}/PBs/PB1.
Save folder (Wine Syntax): Z:\home\$USERNAME\_http_{server}\{prefix}\PBs\PB1\Saves\pitboss\auto.
Url of saves: http://{server}/{prefix}/home/$USERNAME/_http_{server}/{path}/PBs/PB1/Saves/pitboss/auto

=>
1. A BTS_Wrapper.exe user profits from the '_http_'-syntax. Civ4 download the save over http.
2. If the user maps Z: drive to http://{server}/{prefix} server and client share the same path syntax. Civ4 reads the save from Z:.


I'm using Win7. You say "Public http folder with Webdav support: http://{server}/{prefix}": what exactly is {prefix}? Let's say I'm saving my files on a OneDrive webspace: is that enough to use this folder https://d.docs.live.net/[USERID] if I want to save my files there? Right now I've added that location as a network drive and used mklink to link the save folder under My Games\Beyond the Sword\Saves to that location on OneDrive. My idea was to make everyone download the save from there instead of transferring from the host to the client. Could it work?
 
Top Bottom