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. Ramkhamhaeng

    Ramkhamhaeng Warlord

    Joined:
    Feb 24, 2014
    Messages:
    172
    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.
     
  2. DarkLunaPhantom

    DarkLunaPhantom Prince Supporter

    Joined:
    Feb 4, 2013
    Messages:
    442
    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.
     
  3. Ramkhamhaeng

    Ramkhamhaeng Warlord

    Joined:
    Feb 24, 2014
    Messages:
    172
    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
    (monthyearqual) = 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')
     
  4. Ramkhamhaeng

    Ramkhamhaeng Warlord

    Joined:
    Feb 24, 2014
    Messages:
    172
    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.
     
  5. DarkLunaPhantom

    DarkLunaPhantom Prince Supporter

    Joined:
    Feb 4, 2013
    Messages:
    442
    Sure, I changed it. Thanks for the notification.
     
  6. DarkLunaPhantom

    DarkLunaPhantom Prince Supporter

    Joined:
    Feb 4, 2013
    Messages:
    442
    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...
     
  7. Ramkhamhaeng

    Ramkhamhaeng Warlord

    Joined:
    Feb 24, 2014
    Messages:
    172
    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:
    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: Mar 6, 2019
    DarkLunaPhantom likes this.
  8. Ramkhamhaeng

    Ramkhamhaeng Warlord

    Joined:
    Feb 24, 2014
    Messages:
    172
    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: Nov 1, 2020
    DarkLunaPhantom likes this.

Share This Page