Mod for Pitboss Games

Hello DarkLunaPhantom,

there are a few 'reasons' for this approach.
1. Previous versions of PBSpy parses the year information only. The month information was attached later and adding it in the upper bits was the easiest solution.
2. I prefer the storage of numbers over strings.
3. For security reasons the input string should not be stored/displayed without any parsing. I wrote the most restrictive parsing function and wait until somebody needs a more flexible solution.
(Well, this point is not 100% valid because two fields, game name and mod name, are string fields the values were currently saved raw. :) I will update this in the next version and strip out tags, etc...)
4. The Pitboss server method CyPitboss().getGamedate(bSavegameSyntax) depends on the selected language. This could mess up the displayed string on the interface. A new more robust/general solution should respect this.

=========
It exists two possible solution.
A) Simply display the full calendar string, given getGamedate() a.k.a. CyGameTextMgr::getDateStr(...). This approach will work for all mods, too. (Your suggestion)
B) Write an own function, similar to getDateStr, which returns all information in a predefined, language independent form. This is secure, but do not respect new/fancy calendar types. Disadvantage is complexity and redundancy.

Currently, I prefer solution B.
 
B) Write an own function, similar to getDateStr, which returns all information in a predefined, language independent form. This is secure, but do not respect new/fancy calendar types. Disadvantage is complexity and redundancy.

Currently, I prefer solution B.

Just adding all other months (other than January and July) to current parsing function would cover most use cases. That should be more than enough until (and if) someone is eventually willing to spend time to implement solution B.
 
Ok, I've added the missing month and the seasons. Should be merged by Zulan on his server soon.
Sketch of changes:
PHP:
date_string = PB.getGamedate(False)  # PB Server side, i.e 'January, 1 AD'

# PBSpy side
(month, year, qual) = year_str.split()
MONTH_NAMES_ENG = ["undefined", "january", "february", "march",
                   "april", "may", "june", "july", "august",
                   "september", "october", "november", "december"]
# Seasons treated as extra months
MONTH_NAMES_ENG.extend(["winter", "spring", "summer", "fall"])

month = month.replace(",", "")  # Remove tailing ','
try:
    imonth = MONTH_NAMES_ENG.index(month.lower())
except ValueError:
    raise ValueError('Failed to parse month/season part of date')
 
Hello DarkLunaPhantom,

Could you please update the stored PBSpy-Url in your pbSettings.json to
Code:
"url": "http:\/\/civ.zulan.net\/pbspy\/update",
?

We want get rid of this ancient url redirection on our server. :)
Thanks.
 
I am having some trouble merging some parts of PBMod. Are you using a newer version of boost?

Spoiler :

One of the error messages I am getting is:
Code:
unresolved external symbol "int __cdecl boost::xtime_get(struct boost::xtime *,int)"
used inside Timer::calc_next_time in CvGame.cpp, but this function should be included via boost/thread.hpp in CvGame.h...
 
Hui, thanks for posting this!
I didn't use a newer boost version, but add some boost library functions. The required files wasn't added to the PBStats repository. I will push a commit in the next minutes to fix this. Please note that you must alter the Makefile.

Background:
https://en.wikipedia.org/wiki/Boost_(C%2B%2B_libraries) said:
Most Boost libraries are header based, consisting of inline functions and templates, and as such do not need to be built in advance of their use. Some Boost libraries coexist as independent libraries.

Normally, the boost stuff is completely header based but xtime_get needs to be compiled… It was (at least for me) difficult to build up a proper environment to compile the required parts of the ancient boost version but fortunately the C2C-guys provides pre-compiled files their SVN.

I've adapted this solution and added the *.obj-files with the required library functions.
Here, you could restrict it to xtime.obj, I assume.
 
Last edited:
A note to other PB hosters:

If you encountered the following error message, I can provide you some background information.

Error: After an connection attempt by a player the server isn't available anymore and had to be restarted. The PBServer shows:
Code:
 Disconnected: The network socket encountered an error and was closed. Disconnected.

The reason for this message is that providers change the UDP data packets in a very unexpected way during transmission: In order to use their IPv4 addresses as efficiently as possible, they share one address for multiple users and spread the traffic over the whole port range. Here, they overwrite the sending port with zero.
The Pitboss server expects a positive value.


(Package from user to server)


Partial solution: On the server side you can intercept the critical packets to keep the server reachable. E.g.
Code:
iptables -t filter -A INPUT -p udp --sport=0 [--dport=<PBServer-Port>] -j REJECT

The affected player will be blocked and has to refresh his internet connection by hand…
Hopefully the ISP chooses another port for their next login. Unfortunately, the player cannot recognize with which port his UDP data packets arrive at the server.

Please post here if you're also affected by this bug or know a more elegant solution :)
 
Last edited:
Top Bottom