warvulture
This commit is contained in:
parent
4b95e705e7
commit
ee5a2e2e7b
12 changed files with 314 additions and 76 deletions
|
|
@ -24,12 +24,26 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// The ZDO copy is authoritative once it has been written - but it is written by a
|
||||
// Player.OnSpawned postfix in ZdoVisualSync that Harmony registers AFTER this race's own
|
||||
// OnSpawned postfix (type 363 against type 319 in the built assembly), and the player's
|
||||
// ZDO is a brand new empty one every session. So on every single load there is a window
|
||||
// where m_customData is the only place the race exists, and returning out of the ZDO
|
||||
// branch unconditionally made that window answer "not a Trol" - which is what had
|
||||
// TrolFoodManager.LoadFood wiping the 4th and 5th stomach out of the save file on reload.
|
||||
//
|
||||
// Same fix, same reason, as FactionHostilityPatch.GetPlayerRace: only trust the ZDO
|
||||
// string when it is non-empty. An explicit "Human" written by resetrace IS non-empty and
|
||||
// still wins over a stale m_customData, which is the behaviour that fix was added for.
|
||||
public static bool IsTrol()
|
||||
{
|
||||
if (Player.m_localPlayer == null) return false;
|
||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
return nview.GetZDO().GetString("RacesOfValheim_Race", "") == "Trol";
|
||||
{
|
||||
string zdoRace = nview.GetZDO().GetString("RacesOfValheim_Race", "");
|
||||
if (!string.IsNullOrEmpty(zdoRace)) return zdoRace == "Trol";
|
||||
}
|
||||
return Player.m_localPlayer.m_customData.TryGetValue("Race", out string r) && r == "Trol";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue