• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Fixed Need Better Way for Disabling Storylines

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
There are two unfinished storylines now, which are disabled by having their StartStoryline.c files renamed to StartStoryline_off.c .
This has been the case for a long, long time now with the Gold-Bug one. However, it is now also done for DevlinOpera.
Apparently while the current game code CAN handle one storyline being disabled like that, it cannot handle two of them.
Figure that one out! o_O

So now I'm trying to figure out a way to get past this problem.
I tried the following in PROGRAM\utils.c:
Code:
void InitStorylines()
{
   aref flist = GetFiles("PROGRAM\Storyline", "*.c");
   int num = GetAttributesNum(flist);

   ref sl; makeref(sl, Storylines);
   DeleteAttribute(sl, "");
   sl.list = "";

   for (int i = 0; i < num; i++) {
     string sfile = GetAttributeValue(GetAttributeN(flist, i));
     // PB: Check if storyline is disabled -->
     string sdir = strcut(sfile, 0, strlen(sfile) - 3);
     sdir = "PROGRAM\storyline\" + sdir + "\";
     bool bok = FindFile(sdir, "*.c", "StartStoryline_off.c") == "";
     if (!bok) continue;
     // PB: Check if storyline is disabled <--

     if (LoadSegment("Storyline\" + sfile)) {
       RegisterStoryline(i);
       UnloadSegment("Storyline\" + sfile);
     }
   }
}

However, that causes an error message that I do not understand because the code looks fine to me.
This is what I get though:
Code:
RUNTIME ERROR - file: utils.c; line: 2022
incorrect argument index
RUNTIME ERROR - file: utils.c; line: 2022
Bad function argument
RUNTIME ERROR - file: utils.c; line: 2023
Unknown data type
RUNTIME ERROR - file: utils.c; line: 2023
Unknown data type
RUNTIME ERROR - file: utils.c; line: 2023
invalid argument type
RUNTIME ERROR - file: utils.c; line: 2023
Invalid string argument

I haven't yet thought of a solution that actually works for multiple storylines being disabled.
Maybe tomorrow.... :facepalm
 
Can't you just add or remove something in registerstoryline?
 
Stupid question:
Can it be so easy that one of the files should be renamed StartStoryline_off2.c for ex ?
 
Can't you just add or remove something in registerstoryline?
I tried to make those into bools so they can return whether the storyline should be initialized or not.
But this doesn't work either:
Code:
extern bool RegisterStoryline(int i);

void InitStorylines()
{
   aref flist = GetFiles("PROGRAM\Storyline", "*.c");
   int num = GetAttributesNum(flist);

   ref sl; makeref(sl, Storylines);
   DeleteAttribute(sl, "");
   sl.list = "";

   int n = 0;
   bool bEnabled;

   for (int i = 0; i < num; i++) {
     string sfile = GetAttributeValue(GetAttributeN(flist, i));

     if (LoadSegment("Storyline\" + sfile)) {
       bEnabled = RegisterStoryline(n);
       if (bEnabled) n++;
       UnloadSegment("Storyline\" + sfile);
     }
   }
}
As soon as I assign RegisterStoryline to a variable, I get errors messages:
Code:
COMPILE ERROR - file: utils.c; line: 2028
missing ')'
COMPILE ERROR - file: utils.c; line: 2028
Invalid Expression
COMPILE ERROR - file: utils.c; line: 2028
Invalid Expression
COMPILE ERROR - file: utils.c; line: 2028
Invalid Expression
COMPILE ERROR - file: utils.c; line: 2028
Invalid Expression
COMPILE ERROR - file: utils.c; line: 2028
Invalid Expression
COMPILE ERROR - file: utils.c; line: 2028
Invalid Expression
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
COMPILE ERROR - file: Storyline\Assassin.c; line: 51
file not found: Storyline\Storyline\
Despite the functions TRULY being bools everywhere.

This storyline code is apparently very touchy indeed. :modding

Stupid question:
Can it be so easy that one of the files should be renamed StartStoryline_off2.c for ex ?
I just tried: Didn't work. :(
 
Presumably the installer can include or not include files depending on your choices, e.g. it doesn't overwrite everything if you deselect "Main files" and only go for an update.

So what happens if you leave "DevlinOpera.c" and "GoldBug.c" out of "Program\Storylines"?
 
HA! This seems to be doing something at last:
Code:
void InitStorylines()
{
   aref flist = GetFiles("PROGRAM\Storyline", "*.c");
   int num = GetAttributesNum(flist);

   ref sl; makeref(sl, Storylines);
   DeleteAttribute(sl, "");
   sl.list = "";

   string sfile;
   string send;
   int n = 0;
   for (int i = 0; i < num; i++) {
     sfile = GetAttributeValue(GetAttributeN(flist, i));
     // PB: Disable certain storylines -->
     send  = strcut(sfile, strlen(sfile) - 6, strlen(sfile) - 3);
     if (send == "_off")     continue;
     else           n++;
     // PB: Disable certain storylines <--

     if (LoadSegment("Storyline\" + sfile)) {
       RegisterStoryline(n); // PB: was i
       UnloadSegment("Storyline\" + sfile);
     }
   }
}
That skips initializing storylines where the main file ends with "_off".

The bool-based version would have been nice because we could have used a global toggle rather than renaming any files.
But I suppose this will have to do. :shrug
 
Presumably the installer can include or not include files depending on your choices, e.g. it doesn't overwrite everything if you deselect "Main files" and only go for an update.
Yes, it can.

So what happens if you leave "DevlinOpera.c" and "GoldBug.c" out of "Program\Storylines"?
That'll work too. Though I am no fan of leaving files out of the main code folders, because some time or another, I'll forget about it and fail to update it if they get changed or something. :modding
(I hate separate code bases; I tried it for the past month again with the Devlin Opera and it drove me nuts. Again.)
 
@Pieter Boelen maybe you can have the _off file be a separate (empty) file which is just checked? This way enabling it would just require deleting a file. We could even make a simple deinstaller (like enb) to do that.
 
Would be nice, but I'm not particularly excited for making this more complicated.
It was quite annoying as it was....
 
If its working, fine :).
 
Back
Top