1. Dismiss Notice
  2. GOG.com logo

    Thanks to YOUR votes, GOG.com now sells:
    - Sea Dogs - Sea Dogs: Caribbean Tales
    - Sea Dogs: City of Abandoned Ships

    Vote now to add Pirates of the Caribbean to the list!

    Dismiss Notice
  3. Under the Crossbones Podcast

    A Pirate Podcast with Interviews
    Music, Comedy and all things Pirate!

    - Episode Guide - About - Subscribe -
    - Twitter - Facebook - iTunes - Android -
    - Youtube - Fill the Coffers -

    Dismiss Notice
  4. New Horizons logo

    Quick links for PotC: New Horizons
    - Download latest version
    - Wiki - FAQ - Report bugs here
    - ModDB profile

  5. GOF logo

    Quick links for AoP2: Gentlemen of Fortune 2
    - Downloads and info
    - Historical Immersion Supermod
    - ModDB Profile

Dismiss Notice
New to the forum?
Please take a moment to read our Welcome Message and Forum Rules.

Fixed Cannons are too large on some ships

Discussion in 'Bug Archive' started by Hylie Pistof, Nov 13, 2017 at 8:19 PM.

  1. Hylie Pistof

    Hylie Pistof Curmudgeon Staff Member QA Tester Storm Modder

    Joined:
    Jan 15, 2010
    Messages:
    13,748
    Gender:
    Male
    So the little ships are still getting giant cannons. So be it.
     

    Attached Files:

  2. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,563
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    @Grey Roger...?
     
  3. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,368
    That is definitely a bug. The carrack with 9lb cannons is reasonable - the normal maximum for that type is 6lb, but this one has the "Reinforced hull" upgrade which increases the maximum calibre by one. But the 24lb maximum on the brigantine and sloop of war is definitely wrong.

    @Hylie Pistof: all the ships have the "Reinforced hull" upgrade. Did you remove and re-apply that, or did you just buy it once per ship? Also, are you playing in "Arcade" or "Realistic" mode? And have you altered the setting "USE_REAL_CANNONS" in "InternalSettings.h"?

    Has anyone else seen stupidly large cannons on ships?
     
  4. Hylie Pistof

    Hylie Pistof Curmudgeon Staff Member QA Tester Storm Modder

    Joined:
    Jan 15, 2010
    Messages:
    13,748
    Gender:
    Male
    I have been using that Carrack since I got it. I do not remember about the Sloop of War but it could have been berthed and relaunched. The Brigantine was definitely berthed and relaunched and her cannon size went from 18 to 24 when relaunched. When a ship is berthed all upgrades are lost and it was fully upgraded before it was berthed.

    I play in realistic mode with the Open Sea mod. The only thing I ever change in internalsettings.h are some settings at the top to get the Open Sea mod and turn off magic. I know nothing about "USE_REAL_CANNONS".

    This is variable too. At one time I had 3 Sloop of War and each one had a different caliber of cannons.
     
  5. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,368
    Ah-hah! That's the clue we needed. The problem is berthing, specifically laying up the ship as opposed to putting it on shore leave. Shore leave keeps the ship exactly as you left it, with an officer commanding it, and you get charged for crew expenses when you relaunch it. Laying up is supposed to remove all the upgrades, but although the list of upgrades is cleared, their effects aren't. So, you upgrade the ship with, among other things, "reinforced hull", which raises the maximum calibre one level. You berth it and pick the "laying up" option. When you relaunch it, the upgrade list is cleared but the ship's maximum calibre is still one calibre higher, and when you apply "reinforced hull" again, the maximum calibre goes up one more. So a sloop of war with normal maximum calibre 12 is upgraded to 18, keeps it after you've layed up and then relaunched the ship, then you apply "reinforced hull" again and its maximum calibre goes up to 24. That doesn't explain how a brigantine with normal maximum calibre 9 goes up to 24 unless you berthed and relaunched it several times, and if you're going to do that, why stop at 24?
    pocket_battleship.jpg
    Maximum calibre isn't the only thing increased by "reinforced hull". Unfortunately the crew of that bark is too small to fire more than one of its new monster cannons, which is a pity as the ship would otherwise have been a nasty surprise for any coastguard that tried to interfere with its smuggling run. xD

    OK, down to business. The problem is with berthing, specifically with failing to properly strip out the effects of upgrades when the ship is layed up. Now I need to find the code responsible and see if I can fix this...
     
    DeathDaisy and ANSEL like this.
  6. Hylie Pistof

    Hylie Pistof Curmudgeon Staff Member QA Tester Storm Modder

    Joined:
    Jan 15, 2010
    Messages:
    13,748
    Gender:
    Male
    Some ships get cannons that are too big right from the start. That CastelF was only berthed one time, for instance. Personally I don't want the huge cannons as I feel the sweet spot is 12-18 pounders as the larger guns fire too slowly to be useful against smaller ships.
     
  7. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,368
    There's nothing forcing you to install the biggest guns allowed. ;) Personally, I regard the increase in maximum gun size as unrealistic anyway - no matter how tough you make the hull, if you fit the ship with heavier guns than it was originally designed to carry, it may end up overweight or top heavy, therefore likely to be unstable and capsize in the first storm. So after I've fitted "reinforced hull", I don't upgrade the ship's cannons beyond the normal maximum.

    Meanwhile, trying to hunt down the bugs, I put some 'trace' statements into "KB_routines.c" and "kam_shipberthing_ship.c". This was the result, in "compile.log":
    Code:
    SHIP BERTHING: stripping upgrades
    SHIP BERTHING: ship being stripped belongs to 'Fred Bob
    KB_ROUTINES: unapplytunhullhp: current HP = 1245
    KB_ROUTINES: unapplytunhullhp: new HP = 1132
    KB_ROUTINES: unapplytunupcaliber: current calibre = 1
    KB_ROUTINES: unapplytunupcaliber: new calibre = 4
    So it thinks it's about to restore HP and calibre back to normal. But the reduction in calibre doesn't stick. One cycle later:
    Code:
    SHIP BERTHING: stripping upgrades
    SHIP BERTHING: ship being stripped belongs to 'Fred Bob
    KB_ROUTINES: unapplytunhullhp: current HP = 1137
    KB_ROUTINES: unapplytunhullhp: new HP = 1132
    KB_ROUTINES: unapplytunupcaliber: current calibre = 2
    KB_ROUTINES: unapplytunupcaliber: new calibre = 6
    First time round, it upgraded the ship's normal maximum 4lb to 6lb, then failed to reduce it. Second time round, it upgraded the maximum from 6lb to 9lb, and failed to reduce it. The HP reset does seem to stick, though. That implies a problem specific to 'unapplytunupcaliber'.

    In 'applytunupcaliber', this is where the ship gets the upgrade:
    Code:
    _char.ship.stats.maxcaliber = Cannon_Calibers[cal+inc];
    And in 'unapplytunupcaliber', this is where the ship doesn't get downgraded:if(cal != -1) { cal=cal - inc; _char.ship.maxcaliber= Cannon_Calibers[cal]; }[/code]Next time I get to play this, I'm going to see what happens if "_char.ship.maxcaliber" is replaced by "_char.ship.stats.maxcaliber"...

    Meanwhile, another error has been shown up during these experiments.
    Code:
    RUNTIME ERROR - file: islands\islands.c; line: 17
    invalid index -1 [size:24]
    RUNTIME ERROR - file: islands\islands.c; line: 17
    function 'GetIslandByIndex' stack error
    RUNTIME ERROR - file: interface\shipyard.c; line: 5140
    Using reference variable without initializing
    RUNTIME ERROR - file: interface\shipyard.c; line: 5140
    Using reference variable without initializing
    RUNTIME ERROR - file: interface\shipyard.c; line: 5140
    null ap
    RUNTIME ERROR - file: interface\shipyard.c; line: 5140
    null ap
    RUNTIME ERROR - file: interface\shipyard.c; line: 5142
    uninitialized aref
    Lines 5140-5142 in "shipyard.c" are this:
    Code:
        aref islRef; makearef(islRef,CurIsland.Trade.Contraband);
       int n;
       for(i=0;i<GetAttributesNum(islRef);i++)
    
    It's part of function 'CheckForContraband'. So this is probably for @Levis to sort out. Note that this is from a game in progress with my smuggling character; he's done a smuggling run to Port Royale (more than one, in fact), but currently has nothing which is contraband there. But for this experiment, I'd loaded up a savegame and then went to the shipyard. So at the time when this error log was generated, the only things I'd done were to buy a ship, then upgrade, berth and relaunch it a couple of times.
     

    Attached Files:

  8. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,656
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    @Grey Roger that error was also reported by someone else already. Once I have time I will look into it. I would appreciate if you uploaded the savegame where this happened to a seperate topic so I can replicate the bug.
     
  9. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,656
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
  10. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,368
    No. That is a different problem, and if confirmed by anyone else, will need to be dealt with separately. At the moment I'm trying to hammer the next update archive into shape and don't have time to look into this.
     
    Levis and Pieter Boelen like this.
  11. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,368
    There's no point in uploading the savegame because my installation currently has changes from @DeathDaisy and @Jack Rackham which both require a new game. The savegame is incompatible with any installation that does not also have both changes.

    You can check it easily enough, though. Edit "InternalSettings.h" to enable cheatmode. Start a FreePlay game, give yourself plenty of money, then go into the tavern and recruit an officer - anybody will do, whether a random officer at a table or your choice of specific officer from the tavern keeper. Then go to the shipyard and buy any ship for the officer. Give it the "Reinforced hull" upgrade. Berth it, choose laying up as the berthing method. Relaunch it. That should trigger the error - if not, it may be that you need to do a smuggling run first.
     
  12. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,563
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Ah, if only we could finish this feature I once started on: Planned Feature - Include Cannon Weight and Number in Cargo Capacity
    Then it would be like that FOR REAL! :cheeky
     
  13. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,368
    Meanwhile, back to the "Cannons are too large" bug: fixed! At least, that part of it to do with berthing ships. Replacing "_char.ship.maxcaliber" with "_char.ship.stats.maxcaliber" in this line:
    Code:
    if(cal != -1) { cal=cal - inc; _char.ship.stats.maxcaliber= Cannon_Calibers[cal]; }
    did the trick. Evidence in "compile.log", before I removed the trace commands for the final version:
    Code:
    SHIP BERTHING: stripping upgrades
    SHIP BERTHING: ship being stripped belongs to 'Sympken Bertotten'
    KB_ROUTINES: unapplytunhullhp: current HP = 1690
    KB_ROUTINES: unapplytunhullhp: new HP = 1610
    KB_ROUTINES: unapplytunupcaliber: current calibre = 2
    KB_ROUTINES: unapplytunupcaliber: new calibre = 6
    IT dropped low quality weapon (blade46) in favor of higher quality (blade46+1)
    SMUGGLING smuggler visited Redmond
    Force_GetShipType: Maxclass = 7, Minclass = 8, Per = Golden Age of Piracy, Nat = Britain, Type = trade, Loop = 0, Ship ID = Ketch
    SMUGGLING total amount of smuggled goods: Redmond is 1116
    SHIP BERTHING: stripping upgrades
    SHIP BERTHING: ship being stripped belongs to 'Sympken Bertotten'
    KB_ROUTINES: unapplytunhullhp: current HP = 1707
    KB_ROUTINES: unapplytunhullhp: new HP = 1610
    KB_ROUTINES: unapplytunupcaliber: current calibre = 2
    KB_ROUTINES: unapplytunupcaliber: new calibre = 6
    There is still a minor problem in that, if you buy a ship with "Reinforced hull", it already has its maximum calibre raised by one, and that's the value which is stored when the ship is berthed. So a ship which is supposed to have 4lb cannons instead has a permanent maximum of 6lb, which is what happened here. Laying it up, relaunching it, and buying "Reinforced hull" again raises its maximum to 9lb - but then laying it up again and relaunching it puts it back to 6lb. At least you can't keep upgrading, berthing and relaunching the ship repeatedly to get 32lb guns on a lugger any more.

    There was a problem with HP after all. Adding the "Reinforced hull" upgrade raises the ship's maximum HP and also raises the ship's current HP by the same amount. The code to remove the upgrade didn't reduce the ship's current HP, so the relaunched ship had HP of over 100%. I've added this to "unapplytunhullhp":
    Code:
        if (CheckAttribute(_char, "ship.hp"))
       {
           int shipHP = sti(_char.ship.hp);
           int tuneHP = sti(_char.ship.tune.(_improvement).hp);
           if(shipHP - tuneHP > 0) _char.ship.hp = shipHP - tuneHP; //Levis added check to make sure we dont go under 0
       }
    It's copied from the section of "applytunhullhp" which adds to the current HP, changing a "+" to a "-". I'm not sure why the check for HP going below 0 is needed for adding HP, but it's certainly worth putting into the HP reduction in case the ship was badly damaged when you berthed it, in which case removing the HP added by "Reinforced hull" could very well sink it. The result is that laying up and relaunching a ship doesn't leave it with excess HP any more.

    Fixed "KB_routines.c" attached.
     

    Attached Files:

    Pieter Boelen and DeathDaisy like this.
  14. Hylie Pistof

    Hylie Pistof Curmudgeon Staff Member QA Tester Storm Modder

    Joined:
    Jan 15, 2010
    Messages:
    13,748
    Gender:
    Male
    Cool. To me the bigger cannons was new, but the stronger hull has always been there. I just go looking for a storm to knock it down below 100% ans it's all good.
     

Share This Page