• 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 After fast travel or quest reload non-existing characters are loaded

Levis

Find(Rum) = false;
Staff member
Administrator
Creative Support
Programmer
Storm Modder
Mostly a reminder to myself to look into this.
I noticed sometimes after doing questreloads there where non-existing characters loaded.
One way to trigger it was by starting in assassin and then executing this trough the console:
Code:
DoQuestReloadToLocation("Oranjestad_Port_Captain_House", "reload", "reload1", "");

The character init now catches it and wont error. but in the compile log you will still see errors appearing.
This might be some fantoms which weren't completly initialized yet and therefor the clearing of them didn't work as expected but I don't know exactly.

As far as I know this isn't game breaking but it does make for longer loadtimes.
 
One first note is that this line won't give you the "ERROR - Quest name NOT found in ANY function" log entry:
Code:
DoQuestReloadToLocation("Oranjestad_Port_Captain_House", "reload", "reload1", "_");
;)

Other than that, I assume you're referring to these lines?
Code:
XP ERROR: Character  was missing rank during post init
index = 2000
id =
location = none
  locator =
  group =
experience = 1
perks =
  freepoints = 1
skill =
  freeskill = 0
quest =
  officertype = civilian
  officerprice = 0
rank = 1
money = 43
loyality = 20
alignment = none
homelocation =
  group =
  locator =
homestate = citizen
Those characters don't even have an ID set at all! :shock
 
When I tested this just now, I DID get the following error logs:
Code:
RUNTIME ERROR - file: Leveling.c; line: 709
missed attribute: perktypes
RUNTIME ERROR - file: Leveling.c; line: 709
no rAP data
RUNTIME ERROR - file: Leveling.c; line: 709
missed attribute: perktypes
RUNTIME ERROR - file: Leveling.c; line: 709
no rAP data
RUNTIME ERROR - file: Leveling.c; line: 709
missed attribute: perktypes
RUNTIME ERROR - file: Leveling.c; line: 709
no rAP data
 
And I think you're right that this indeed happens if you trigger the QuestReload before the PostInit has completed.
Could it be that the PostInit continues during and after this QuestReload?

Should it not be stopped immediately when any location reload is begun?
If it didn't get the chance to complete, it should be able to do the characters not yet done the next time those characters ARE used.
Right?
 
For testing purposes, I changed your code to this:
Code:
      if(!CheckAttribute(chr,"rank"))
       {
         CheckCharacterSetup(chr); //This shouldn't happen but it seems somewhere between adding it to post init and doing it the rank gets removed sometimes???
         trace("XP ERROR: Character "+chr.id+" was missing rank during post init");
         DumpAttributes(chr);
       }
       else
       {
         trace("XP Success: Character "+chr.id+" was initialized during post init");
         DumpAttributes(chr);
       }
That caused this here:
Code:
XP Success: Character Location fantom character <0> was initialized during post init
index = 2000
id = Location fantom character <0>
location = Douwesen_port
  locator = goto3
  group = goto
  from_sea =
  fantom = 1
model = rabwhite1
  entity = NPCharacter
  animation = man
  height = 1.8000000
sex = man
faceid = 150
headmodel = h_rabwhite1
reputation = 83
friend = 0
nation = 4
  name = 4
name = Friedrich
lastname = Van Giesen
old =
  name = Friedrich
  lastname = Van Giesen
  chr_ai =
  group = monsters
rank = 1
Based on that, I have a theory on why you notice this problem:
- Game is started, "Douwesen_Port" location is loaded
- Random fantoms are added to the location, but aren't yet fully initialized
- Your PostInit queue is started and will fully initialize each character in order; this isn't stopped until ALL characters in the list have been done
- QuestReload to another location BEFORE the PostInit queue completes
- During the reload process, the random fantoms are deleted, but the PostInit queue remains active
- After reload, the original "Douwesen_Port" PostInit queue continues, but the characters that were still supposed to be initialized have already been removed gain

Based on that, I stand by my earlier suggestion that any active PostInit queue should be aborted as soon as a location reload is started.
Any characters that haven't been initialized at that time can be done the next time you encounter them.
Does that sound about right to you?
 
Oh... And what happens if you make a savegame before the PostInit queue completes, then load that savegame?
Is the queue restarted then from where it left off or do then certain characters remain uninitialized?
 
Oh... And what happens if you make a savegame before the PostInit queue completes, then load that savegame?
Is the queue restarted then from where it left off or do then certain characters remain uninitialized?
They should be initialized on the next load. A character gets an attribute after the load is completed. If it doesnt have it, it will do them again.
 
They should be initialized on the next load. A character gets an attribute after the load is completed. If it doesnt have it, it will do them again.
That's what I figured. Then possibly all we need is for the game to ABORT its PostInit queue as soon as a reload starts.
 
It stops when unloadlocation (I believe it's called that) is called.
 
It stops when unloadlocation (I believe it's called that) is called.
How? All I see is this function:
Code:
StopPostInitChars()
But that one doesn't get called on UnloadLocation . Looking through that function, I see nothing related to levelling in there.
Should I add it?

These are all the PostInit related function calls I see in the locations_loader.c file:
Line 494: SetCharacterPostInit(true);
Line 496: SetCharacterPostInit(false);
Line 497: StartPostInitChars();
 
This here DOES seem to help:
Code:
bool UnloadLocation(aref loc)
{
   if(CheckAttribute(loc,"id")) traceif("UnloadLocation(aref loc) " + loc.id);
   StopPostInitChars(); // Levis

   DialogExit();

   ref mainCharacter = GetMainCharacter();
Did a (too) quick test and no performance issues nor error logs.
 
That must have been removed somewhere along the line then :p.
It used to be in there....
This should solve it
 
I am reopening this issue since this may not be working quite as intended just yet....

One thing that springs to mind is that perhaps this added line should be executed ONLY ashore?
 
If there is no post init it won't harm anything.
 
From what I can see with my recent fixes it should be working again and this problem no longer occurs.
 
Did you use that Stop Init line somewhere or did you fix it another way?
 
Back
Top