Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Choosing "Wait for some time" in Village Leaves Village #818

Open
2 tasks
garrettluskey opened this issue Jun 18, 2024 · 3 comments
Open
2 tasks

Bug: Choosing "Wait for some time" in Village Leaves Village #818

garrettluskey opened this issue Jun 18, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@garrettluskey
Copy link
Contributor

For New Contributors

How to contribute

Description

Choosing "Wait for some time" in a village will have the party leave the village while the UI is gone. Implement a fix for this.

Intended Design

N/A

Location

Create a branch based from development

Related Issues

N/A

Requirements

N/A

Additional information

N/A

Definition of Done

  • Class level comments exist for all new classes.
  • XUnit tests exist for every method that does not require the game to be ran.
@garrettluskey garrettluskey added the bug Something isn't working label Jun 18, 2024
@Mihail544 Mihail544 self-assigned this Jul 8, 2024
@georgyrudnev
Copy link
Contributor

I think the issue is related to the DisableGameMenuPausePatches inside the GameInterface.Services.Time.Patches.
As I understand the goal of the patch is to selectively disable time setting in some menu´s, but I believe there may be some bug arise from the SwitchToMenu method.
Need to test and probably patch behaviour of TaleWorlds.CampaignSystem.GameMenus.GameMenu.SwitchToMenu(string)

@georgyrudnev
Copy link
Contributor

georgyrudnev commented Oct 22, 2024

Moreover I think it is related to our SetTimeControlModeDeference patch which is removing the Set CampaignTimeControlMode.Stop method inside I believe below bannerlord code which in turn is never allowing the game to enter below code block.

  public static void SwitchToMenu(string menuId)
	{
		Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop;
		MenuContext currentMenuContext = Campaign.Current.CurrentMenuContext;
		if (currentMenuContext != null)
		{
			currentMenuContext.SwitchToMenu(menuId);
			if (currentMenuContext.GameMenu.IsWaitMenu && **Campaign.Current.TimeControlMode == CampaignTimeControlMode.Stop**)
			{       // Never entering this code here
				currentMenuContext.GameMenu.StartWait();
			}
			MenuContext currentMenuContext2 = Campaign.Current.CurrentMenuContext;
			if (currentMenuContext2 != null && currentMenuContext2.GameMenu.StringId == menuId)
			{
				currentMenuContext2.GameMenu.AfterInit(currentMenuContext2);
				return;
			}
		}
		else
		{
			Debug.FailedAssert("false", "C:\\Develop\\MB3\\Source\\Bannerlord\\TaleWorlds.CampaignSystem\\GameMenus\\GameMenu.cs", "SwitchToMenu", 363);
		}
	}

inside TaleWorlds.CampaignSystem.GameMenus.GameMenu.SwitchToMenu(string)

@georgyrudnev
Copy link
Contributor

georgyrudnev commented Nov 3, 2024

Actually I realized that the village bug is fixed now, after Messge broker was made async instead of sync.
But now the same bug occurs when you choose "Wait for some time" inside a settlement!

The piece of code making the difference seems to be in Publish method inside Common.Messaging.MessageBroker
// Making synchronous to maintain sequencing of packets
//Task.Factory.StartNew(() => weakDelegate.Invoke(new object[] { payload }));

            weakDelegate.Invoke(new object[] { payload });

Uncommenting and disabling last code line makes the bug appear again in villages instead of settlements

This was referenced Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Workable
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants