Missing Location bug

Users who are viewing this thread

Hey everyone, I tried to look for this issue, but couldn't find anything. One of my games got a weird bug, on all savegames: when I'm in a city and I hover the mouse on the portrait of one of its denizens, among all the information appears a white "Location", that has no value. All the NPCs have this issue. So, when I try to recruit a new companion, the game crashes because the game can't find the location of the NPC. I already sent the logs, but I would like to ask you if anyone else has got this problem. Since this is a new account, I can't link or post images, but I'll do it as soon as I can.
Thank you.
 
Just a quick update: yesterday I stayed up until 3:30 AM and I debugged the game to try to understand what variable was null (that was the cause of the exception). The issue appears to be in the following method:

public Location GetLocationOfCharacter(LocationCharacter character)
{
Location location1 = (Location) null;
foreach (KeyValuePair<string, Location> location2 in this._locations)
{
if (location2.Value.ContainsCharacter(character))
location1 = location2.Value;
}
return location1;
}

The exception happens at the line "location1 = location.Value", even if it has no sense. In fact, after setting a break point on the exact line, for some reason the exception seems to disappear: what I mean is that if I try to recruit a companion while the breakpoint is on that line and I'm attached to the Bannerlord process to debug, the issue doesn't happen. I tried it three times just to be sure, but it's really weird. And besides that, I still have to understand why all the NPCs have the white "Location" string appearing under their stats. I still can't link or post images tho, so I can't show you yet.
 
Ooooh sounds like unstable code - did you Verify download on steam - or you might need to reinstall ?

Reminds me of the 90s when I was a "C" programmer , "rogue pointer bug" making your code totally unstable.

Question - why do you need to loop through to match a location ?? surely you could pass down the location as parameter ?

.
 
Ooooh sounds like unstable code - did you Verify download on steam - or you might need to reinstall ?

Reminds me of the 90s when I was a "C" programmer , "rogue pointer bug" making your code totally unstable.

Question - why do you need to loop through to match a location ?? surely you could pass down the location as parameter ?

.
I verified the installation on steam of course.. but this isn't my code, this is Bannerlord source code ?
 
Just a quick update: yesterday I stayed up until 3:30 AM and I debugged the game to try to understand what variable was null (that was the cause of the exception). The issue appears to be in the following method:

public Location GetLocationOfCharacter(LocationCharacter character)
{
Location location1 = (Location) null;
foreach (KeyValuePair<string, Location> location2 in this._locations)
{
if (location2.Value.ContainsCharacter(character))
location1 = location2.Value;
}
return location1;
}

The exception happens at the line "location1 = location.Value", even if it has no sense. In fact, after setting a break point on the exact line, for some reason the exception seems to disappear: what I mean is that if I try to recruit a companion while the breakpoint is on that line and I'm attached to the Bannerlord process to debug, the issue doesn't happen. I tried it three times just to be sure, but it's really weird. And besides that, I still have to understand why all the NPCs have the white "Location" string appearing under their stats. I still can't link or post images tho, so I can't show you yet.
I'm not expert but the code has some sense to me.
All the locations are stored in a list pairing the name of the "string" character with a "Location" location.
The loop will look for the character name and return the location.
  1. At first, the location1 is null
  2. Then the loop using location2 (will give the result)
  3. Then giving the value of location2 to location1
  4. Then return the value.
Adding a break will just get you out of the loop and this why you don't get the exception.

My guess is that the list is corrupted (if I can say this that way), either the character or location references are broken, or whatever.
Maybe after some in-game time all the values will be refreshed slowly?
Did the value of the new companion get refreshed after recruiting her/him?

Question - why do you need to loop through to match a location ?? surely you could pass down the location as parameter ?
For me the question would be "Why not using a Dictionary with Hero + Location".
A dictionary would be faster by just looking for the Hero value (set as a key)... don't even need a loop...
 
Back
Top Bottom