fix NesEmulator重构后处理输入数据bug

This commit is contained in:
ALIENJACK\alien 2025-04-29 19:43:02 +08:00
parent 1ffa708e71
commit ace77987e4
5 changed files with 15 additions and 57 deletions

View File

@ -1215,6 +1215,14 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6671307062690349520, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6671307062690349520, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6838719776118089301, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
propertyPath: m_IsActive
value: 1

View File

@ -10,11 +10,6 @@ namespace AxibugEmuOnline.Client
{
public class CoreSupporter : ISupporterImpl
{
private NesControllerMapper m_controllerMapper;
public CoreSupporter(NesControllerMapper conMapper)
{
m_controllerMapper = conMapper;
}
public System.IO.Stream OpenRom(string fname)
{
@ -95,51 +90,9 @@ namespace AxibugEmuOnline.Client
{
var db = Resources.Load<RomDB>("NES/ROMDB");
return db.GetMapperNo(rom.GetPROM_CRC(), out mapperNo);
}
private ControllerState m_sampledState;
public ControllerState GetControllerState()
{
return m_sampledState;
}
uint LastTestInput = 0;
public void SampleInput(uint frameIndex)
{
if (InGameUI.Instance.IsNetPlay)
{
int targetFrame; ReplayStep replayData; int frameDiff; bool inputDiff;
if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out replayData, out frameDiff, out inputDiff))
{
if (inputDiff)
{
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} TryGetNextFrame remoteFrame->{App.roomMgr.netReplay.mRemoteFrameIdx} diff->{frameDiff} " +
$"frame=>{replayData.FrameStartID} InPut=>{replayData.InPut}");
}
m_sampledState = FromNet(replayData);
}
else
{
m_sampledState = default(ControllerState);
}
var localState = m_controllerMapper.CreateState();
var rawData = ToNet(localState);
if (LastTestInput != rawData)
{
LastTestInput = rawData;
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}");
}
App.roomMgr.SendRoomSingelPlayerInput(frameIndex, rawData);
}
//单机模式
else
{
m_sampledState = m_controllerMapper.CreateState();
}
}
}
public ControllerState FromNet(AxiReplay.ReplayStep step)
{
var temp = new ServerInputSnapShot();

View File

@ -45,7 +45,7 @@ namespace AxibugEmuOnline.Client
{
StopGame();
m_coreSupporter = new CoreSupporter(ControllerMapper);
m_coreSupporter = new CoreSupporter();
Supporter.Setup(m_coreSupporter);
Debuger.Setup(new CoreDebuger());
@ -145,7 +145,7 @@ namespace AxibugEmuOnline.Client
protected override ControllerState GetLocalInput()
{
return m_coreSupporter.GetControllerState();
return ControllerMapper.CreateState();
}

View File

@ -99,9 +99,8 @@ namespace AxibugEmuOnline.Client
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}");
}
App.roomMgr.SendRoomSingelPlayerInput(Frame, rawData);
}
//单机模式
else
}
else//单机模式
{
inputData = GetLocalInput();
result = true;

View File

@ -23,7 +23,5 @@
void SaveFile(byte[] fileData, string directPath, string fileName);
System.IO.Stream OpenFile(string directPath, string fileName);
bool TryGetMapperNo(ROM rom, out int mapperNo);
ControllerState GetControllerState();
void SampleInput(uint frameCount);
}
}