• 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 DeleteCharacter bug

Levis

Find(Rum) = false;
Staff member
Administrator
Creative Support
Programmer
Storm Modder
@Pieter Boelen you changed the deletecharacter to include the entity.
but I see this popping up in errorlogs:
Code:
RUNTIME ERROR - file: characters\characters.c; line: 175
missed attribute: model
RUNTIME ERROR - file: characters\characters.c; line: 175
null ap
RUNTIME ERROR - file: characters\characters.c; line: 175
no rAP data
RUNTIME ERROR - file: characters\characters.c; line: 175
missed attribute: model
RUNTIME ERROR - file: characters\characters.c; line: 175
null ap
RUNTIME ERROR - file: characters\characters.c; line: 175
no rAP data
RUNTIME ERROR - file: characters\characters.c; line: 175
missed attribute: model
RUNTIME ERROR - file: characters\characters.c; line: 175
null ap
RUNTIME ERROR - file: characters\characters.c; line: 175
no rAP data

So I think before copying the entity or remaining it you should check if it exists already and if not just put blank space or something like that.
 
it refers to this line of code:

Code:
bool DeleteCharacter(ref character)
{
    // PB: Completely erase attributes -->
    int index     = character.index;
    string id     = character.id;
    string entity = character.model.entity;    <-----------------THIS LINE
    DeleteClass(character);
    DeleteAttribute(character, "");
    character.index = index;
 
Try this:
Code:
bool DeleteCharacter(ref character)
{
   // PB: Completely erase attributes -->
   TraceAndLog("DeleteCharacter: " + GetMySimpleName(character));
   int index  = character.index;
   string id  = character.id;
   string entity = "";
   if (CheckAttribute(character, "model.entity")) entity = character.model.entity;
   DeleteClass(character);
   DeleteAttribute(character, "");
   character.index = index;
   character.id = id;
   if (entity != "") character.model.entity = entity;
   character.location = "none";
   character.location.locator = "";
   character.location.group = "";
   // PB: Completely erase attributes <--
   return true;
}
And while we're at it, let's add some a line for tracking purposes.
Then at least we'll know if it starts deleting characters that are supposed to stay.
 
Just wanting to point out this is probably going to cause some problems.
I took a look at this function
Code:
int FindFreeRandomOfficer()
{
    // this function rewritten by KAM so new officers don't keep overwriting captains on shore leave [changes made by MAXIMUS 07.10.2007]

    for(int tempnum=0; tempnum<=NUM_RANDOM_OFFICERS; tempnum++) // NK 05-03-30 we now use char not exist to stop loop, so we can have any number of enc_off.
    {
        string tempid = "Enc_Officer_" + tempnum;
        int tempidx = GetCharacterIndex(tempid);
        if(tempidx==-1) break; // NK 05-03-30 ditto
        ref tempChar = GetCharacter(tempidx);

        if(bAllies(tempChar)) { continue; }
        if(tempChar.location == loadedLocation.id) { continue; } // PB: To prevent prospective officers from disappearing when you're talking to them

        DeleteCharacter(tempChar);

        return tempidx;
    }

    return -1;
}

Can you spot the problem too?
If I read it right its looking for specific ID which is reserved for officers.
We could just rewrite it by searching for the first empty ID. but how many more of these kind of functions will there be?

Edit: Nevermind, looking at your code again i see the ID is saved so it wont cause problems.
 
Back
Top