Closed TheBadListener closed 3 years ago
Possible Old Save Game Conflict.
Various Reports coming out that _brothel has issues after the set, LocationComplex loses the brothel that it is linking to after 4 hours of gameplay.
private static void BrothelDistrictOnInit(MenuCallbackArgs args)
{
Campaign.Current.GameMenuManager.MenuLocations.Clear();
Settlement settlement = Settlement.CurrentSettlement ?? MobileParty.MainParty.CurrentSettlement;
try
{
// Location Complex need to add to to prevent crashing on overlay menu
FieldInfo fi = LocationComplex.Current.GetType().GetField("_locations", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<string, Location> _locations = (Dictionary<string, Location>)fi.GetValue(LocationComplex.Current);
if (_locations.ContainsKey("brothel")) _locations.Remove("brothel");
//else LocationComplex.Current.AddPassage(LocationComplex.Current.GetLocationWithId("center"), _brothel);
_brothel.SetOwnerComplex(settlement.LocationComplex);
switch (settlement.Culture.GetCultureCode())
{
case CultureCode.Sturgia:
_brothel.SetSceneName(0, "sturgia_house_a_interior_tavern");
break;
case CultureCode.Vlandia:
_brothel.SetSceneName(0, "vlandia_tavern_interior_a");
break;
case CultureCode.Aserai:
_brothel.SetSceneName(0, "arabian_house_new_c_interior_b_tavern");
break;
case CultureCode.Empire:
_brothel.SetSceneName(0, "empire_house_c_tavern_a");
break;
case CultureCode.Battania:
_brothel.SetSceneName(0, "battania_tavern_interior_b");
break;
case CultureCode.Khuzait:
_brothel.SetSceneName(0, "khuzait_tavern_a");
break;
case CultureCode.Nord:
case CultureCode.Darshi:
case CultureCode.Vakken:
case CultureCode.AnyOtherCulture:
case CultureCode.Invalid:
default:
_brothel.SetSceneName(0, "empire_house_c_tavern_a");
break;
}
List<CharacterObject> brothelPrisoners = FetchBrothelPrisoners(Settlement.CurrentSettlement);
_brothel.RemoveAllCharacters();
foreach (CharacterObject brothelPrisoner in brothelPrisoners)
{
if (!brothelPrisoner.IsHero) continue;
_brothel.AddCharacter(CreateBrothelPrisoner(brothelPrisoner, Settlement.CurrentSettlement.Culture, LocationCharacter.CharacterRelations.Neutral));
}
_locations.Add("brothel", _brothel);
if (fi != null) fi.SetValue(LocationComplex.Current, _locations);
Campaign.Current.GameMenuManager.MenuLocations.Add(LocationComplex.Current.GetLocationWithId("brothel"));
}
catch (Exception)
{
CECustomHandler.ForceLogToFile("Failed to load LocationComplex Brothel Statue ");
}
if (CheckAndOpenNextLocation(args)) return;
args.MenuTitle = new TextObject("{=CEEVENTS1099}Brothel");
}
Fixed this with OnSettlementEntered
Bug Report
Hits this twice on entering brothel menu 7/20/2020 2:21:23 PM -- Failed to load LocationComplex Brothel Statue 7/20/2020 2:21:25 PM -- Failed to load LocationComplex Brothel Statue
Might have to do with a mod conflict unsure yet.