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 New Dialog_func.c - stops Game Starting/Loading

Discussion in 'Bug Archive' started by Talisman, Oct 7, 2016.

  1. Talisman

    Talisman Smuggler Storm Modder

    Joined:
    Apr 29, 2009
    Messages:
    2,825
    Gender:
    Male
    Location:
    Hiding From The Coastguard
    :ahoy

    Installed the new Dialog_func.c file from this post:-

    Fixed - Reputation and PcharRepPhrase code | PiratesAhoy!

    Now the game will not start :shock

    when I try to load the engine I get a Crash to desktop with this in the error log

    Code:
    COMPILE ERROR - file: dialog_func.c; line: 1967
    function GenerateQuestShip(args:2) doesnt accept 4 arguments
    
    
    logs attached ( no compile log generated )

    :drunk
     

    Attached Files:

  2. Levis

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

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

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,405
    That version of "Dialog_func.c" does not have my fix to 'PCharRepPhrase' which replaces the hardcoded and incorrect value 41 with the variable 'REPUTATION_NEUTRAL'. Here's the 7th October version with that change reinstated.

    The change is needed because 'PCharRepPhrase' chooses between two supplied string arguments depending on whether your reputation is below a certain point. If that point is the hardcoded 41, which is midway between "Neutral" and "Rascal", then you can be borderline "Rascal" and still get the "good" string. Replacing the 41 with 'REPUTATION_NEUTRAL' means that whatever "Neutral" is defined as in "characters.h", you'll get the "bad" string if your reputation is lower than that.
     

    Attached Files:

    Pieter Boelen likes this.
  4. Talisman

    Talisman Smuggler Storm Modder

    Joined:
    Apr 29, 2009
    Messages:
    2,825
    Gender:
    Male
    Location:
    Hiding From The Coastguard
    Yes it does :yes

    this code is identical in both the file in this post:-
    Fixed - Reputation and PcharRepPhrase code | PiratesAhoy!

    and the file posted by @Grey Roger above - lines 680 -692

    Code:
    string PCharRepPhrase (string Var1, string Var2)
    {
       ref pchar = GetMainCharacter();
    
       if(makeint(pchar.reputation) < REPUTATION_NEUTRAL)
       {
         return Var2;
       }
       else
       {
         return Var1;
       }
    }
    
    The only difference between the 2 files is that lines 876 - 1007 are commented out in the file here:
    Fixed - Reputation and PcharRepPhrase code | PiratesAhoy!

    while they have been deleted completely in the file posted in Post #3 :type1

    I have just tried the file in Post #3 and the same thing still happens - game does not load CTD.

    @Grey Roger - it is not connected with your PCharRepPhrase changes :no

    @ Levis

    with the file in post #3 the error log says :-

    Code:
    COMPILE ERROR - file: dialog_func.c; line: 1835
    function GenerateQuestShip(args:2) doesnt accept 4 arguments
    
    which is the same error as before - different line number because lines in-between have been deleted


    The problem seems to be here:-

    Code:
    
    void SetCoastalEnemy(string model, string sex, string name, string lastname)
    {
       ref Pchar = GetMainCharacter();
       ref rCap1 = CharacterFromID("Coastal_Captain01");
    
       Group_CreateGroup("Coastal_Guards");
    THIS LINE--->>>>   GenerateQuestShip("Enemy_Captain01", 7, 1, GetCurrentLocationNation()); // PB: Use Generic Function //Levis: Set class to be between 7 and 1, might need to be changed for better balance
       SetModelFromID(rCap1, model);
       rCap1.name    = name;
       rCap1.lastname = lastname;
       if(sex=="woman")
       {
         rCap1.sex = sex;
         rCap1.ani ="woman";
       }
    
    

    @Levis - I am using Beta 4-1 16 May since I have not had time to update since then -( the only thing I have installed is the new dialog_func.c file ) if the problem is purely that I am using an "old" version of the game that is not compatible with the new dialog_func.c file - then I can fix that by just moving @Grey Roger 's changes into an older version of the file that works in my game.

    I just reported the CTD in case the problem occurs with more up to date versions of the game than mine. :doff


    :drunk
     

    Attached Files:

  5. Levis

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

    Joined:
    Oct 6, 2013
    Messages:
    6,691
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    Did you change your quest_common.c from the one in my version?
    This is how the first function should look like:
    Code:
    void GenerateQuestShip(string captain_id, int maxclass, int minclass, int iNation) // KK
    {
        //This function will generate a ship and generate the captain on the given captain_id character
        //You should provide a min and max class for the ship. It doesn't matter if these are reverted by accident, it will be caught.
    
        //Check if the character is an enemy
        bool isEnemy = false;
        if(captain_id == "Quest pirate" ) isEnemy = true;
        if(captain_id == "Convoy pirate") isEnemy = true;
    
        //Get the captain which is only half setup
        ref rCaptain = characterFromID(captain_id);
       
        //Determine the nation of the ship etc
        if(isEnemy) iNation = LotHostileNation(iNation);
        else        iNation = iNation;
       
        //Extract the nation and fantomtype from it
        string sFantomType = "war";
        if( iNation >= NATIONS_QUANTITY)    iNation = PIRATE;
        if( iNation == PIRATE)                sFantomType = "pirate";
    
        //Determine the max and minclass of the ship
        int iShipType;
        if(sti(rCaptain.nation) == PIRATE             && maxclass < MAXPIRATECLASS)            maxclass = MAXPIRATECLASS;
        if(HasSubStr(captain_id,"Coastal_Captain") && maxclass < MAXCOASTGUARDCLASS)        maxclass = MAXCOASTGUARDCLASS;
        if(GetCurrentPeriod() <= PERIOD_EARLY_EXPLORERS || GetCurrentPeriod() >= PERIOD_NAPOLEONIC)
        {
            if(iNation == HOLLAND        && maxclass < 3)                        maxclass = 3;
            if(iNation == PORTUGAL       && maxclass < 3)                        maxclass = 3;
        }
        if(minclass > 8)    minclass = 8;
    
        //Make the ship
        iShipType = Force_GetShipType(maxclass, minclass, sFantomType, iNation); //Levis: Also make sure the right fantomtype is set for the ship
       
        //Generate the captain
        if(DEBUG_CAPTAIN_CREATION>1) Trace("CAPTAIN CREATION: In function GenerateQuestShip");
        rCaptain = LAi_Create_Captain(rCaptain, sFantomType, iShipType, iNation); //Levis new function to create a captain
       
        // PB: Have these ships always hostile, regardless of flag
        rCaptain.recognized = true;
    
        if(captain_id == "Quest pirate")    // PB: For Governor Quest Ships only
        {
            //NK edit trademoney
            ref Shiptype = GetShipByType(iShipType);
            aref arship; makearef(arship, rCaptain.ship);
            ref pchar = GetMainCharacter();
            float shipmult = 5.0 * sqrt(intRet(sti(Shiptype.CannonsQuantity),sti(Shiptype.CannonsQuantity),1) * sti(GetLocalShipAttrib(arship, Shiptype, "HP")) * stf(GetLocalShipAttrib(arship, Shiptype, "SpeedRate"))); // PRS3
            float commult = 1.0 + makeint(CalcCharacterSkill(pchar, SKILL_COMMERCE))/20.0;
    
            int iTradeMoney = makeint(sqrt(sti(rCaptain.rank)) * shipmult * commult/25)*25;
            if(iTradeMoney < 100) iTradeMoney = 100;
    
            pchar.quest.generate_kill_quest = "begin";
            pchar.quest.generate_kill_quest.money = iTradeMoney;
            pchar.quest.generate_kill_quest.town = GetCurrentTownID();//MAXIMUS
            pchar.quest.generate_kill_quest.destination = Islands[GetCharacterCurrentIsland(Pchar)].id;
            pchar.quest.generate_kill_quest.nation = iNation; // KK // MAXIMUS
            pchar.quest.generate_kill_quest.shipname = rCaptain.Ship.Name;
        }
    }
    
     
  6. Talisman

    Talisman Smuggler Storm Modder

    Joined:
    Apr 29, 2009
    Messages:
    2,825
    Gender:
    Male
    Location:
    Hiding From The Coastguard
    @Levis

    I am using quest_common.c dated 16/5/2016 - see attached ( I have not made any changes to it) - it is different from yours. :yes

    So the problem is as I said above

    So I can get round that easily enough - no problem - Thanks for the help.

    :type1
     

    Attached Files:

  7. Levis

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

    Joined:
    Oct 6, 2013
    Messages:
    6,691
    Gender:
    Male
    Occupation:
    ICT
    Location:
    University Twente (Netherlands)
    ah, the file posted by @Grey Roger needs my fixes. a certain function is changed. thats why it isn't working for you.
    SO either don't install the fix or update or use winmerge to only change what you need
     
    Talisman likes this.
  8. Talisman

    Talisman Smuggler Storm Modder

    Joined:
    Apr 29, 2009
    Messages:
    2,825
    Gender:
    Male
    Location:
    Hiding From The Coastguard

    That is what I have just done with my 16 may version of dialog_func.c

    It is now all working OK. :thumbs1

    Thanks

    :cheers
     
    Pieter Boelen and Levis like this.
  9. Grey Roger

    Grey Roger Sea Dog Staff Member Storm Modder

    Joined:
    Feb 12, 2007
    Messages:
    6,405
    Something very odd is going on. I downloaded @Levis' fixes - both the first one released today ("Levis-Fixes_7_10.zip") and the later one ("Levis-Fixes_7-10b.zip"). In both cases, if I extract "Dialog_func.c", it has the old line 'if(makeint(pchar.reputation) < 41)'. The file I posted in #3 in this thread is the one from "Levis-Fixes_7_10.zip", in which I replaced the reputation line.

    @Levis: have you in fact replaced the line in 'PCharRepPhrase' with my new one? If yes, how am I getting the old line from your update; if no, how is @Talisman getting the updated line?
     
  10. Talisman

    Talisman Smuggler Storm Modder

    Joined:
    Apr 29, 2009
    Messages:
    2,825
    Gender:
    Male
    Location:
    Hiding From The Coastguard

    I think I misunderstood you earlier :facepalm

    The 2 versions of dialog_func.c that I was comparing were the one in post#3 above ( which you had corrected )

    with the one in Fixed - Reputation and PcharRepPhrase code | PiratesAhoy!

    which also has your correction.

    I was not using the files contained in ("Levis-Fixes_7_10.zip") or ("Levis-Fixes_7-10b.zip") - so I was comparing the 2 corrected files.

    :drunk
     

Share This Page