forked from sin365/AxibugEmuOnline
MAME避免已经在房间内的玩家重复热机
This commit is contained in:
parent
93bf42e166
commit
c0a8127d6a
@ -14,6 +14,18 @@ namespace MAME.Core
|
||||
mameMainMotion = new MameMainMotion();
|
||||
}
|
||||
|
||||
#region 热机
|
||||
//是否需要预热
|
||||
bool bNeedPreheat { get
|
||||
{
|
||||
return historyUpdateCount < 5;
|
||||
} }
|
||||
/// <summary>
|
||||
/// 推帧计数,(记录本次加载Rom之后推帧的计数)
|
||||
/// </summary>
|
||||
ulong historyUpdateCount = 0;
|
||||
#endregion
|
||||
|
||||
public bool bRom => mameMainMotion.bRom;
|
||||
|
||||
public void Init(
|
||||
@ -31,11 +43,20 @@ namespace MAME.Core
|
||||
public void ResetRomRoot(string RomDir) => mameMainMotion.ResetRomRoot(RomDir);
|
||||
|
||||
public Dictionary<string, RomInfo> GetGameList() => mameMainMotion.GetGameList();
|
||||
public void LoadRom(string Name) => mameMainMotion.LoadRom(Name);
|
||||
public void LoadRom(string Name)
|
||||
{
|
||||
historyUpdateCount = 0;
|
||||
mameMainMotion.LoadRom(Name);
|
||||
}
|
||||
|
||||
public void GetGameScreenSize(out int _width, out int _height, out IntPtr _framePtr) => mameMainMotion.GetGameScreenSize(out _width, out _height, out _framePtr);
|
||||
public void StartGame() => mameMainMotion.StartGame();
|
||||
public void StartGame_WithNewThread() => mameMainMotion.StartGame_WithNewThread();
|
||||
public void UpdateFrame() => Mame.mame_execute_UpdateMode_NextFrame();
|
||||
public void UpdateFrame()
|
||||
{
|
||||
historyUpdateCount++;
|
||||
Mame.mame_execute_UpdateMode_NextFrame();
|
||||
}
|
||||
public void UnlockNextFreme(int moreTick = 1) => mameMainMotion.UnlockNextFreme(moreTick);
|
||||
public void StopGame() => mameMainMotion.StopGame();
|
||||
public long currEmuFrame => Video.screenstate.frame_number;
|
||||
@ -44,10 +65,8 @@ namespace MAME.Core
|
||||
{
|
||||
//热机逻辑:主要解决NEOGEO问题,避免加入其他人房间自动联机时,加载流程,cpu一次都没执行,部分逻辑没有初始化。
|
||||
//再加载数据之前,推若干帧,确保所有组件充分初始化
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
while(bNeedPreheat)
|
||||
UpdateFrame();
|
||||
}
|
||||
Mame.paused = true;
|
||||
Thread.Sleep(20);
|
||||
Mame.soft_reset();//软重启一次,确保没有脏数据
|
||||
|
||||
Loading…
Reference in New Issue
Block a user