forked from sin365/AxibugEmuOnline
fix NesEmulator重构后处理输入数据bug
This commit is contained in:
parent
1ffa708e71
commit
ace77987e4
@ -1215,6 +1215,14 @@ PrefabInstance:
|
|||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 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}
|
- target: {fileID: 6838719776118089301, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 1
|
value: 1
|
||||||
|
|||||||
@ -10,11 +10,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
public class CoreSupporter : ISupporterImpl
|
public class CoreSupporter : ISupporterImpl
|
||||||
{
|
{
|
||||||
private NesControllerMapper m_controllerMapper;
|
|
||||||
public CoreSupporter(NesControllerMapper conMapper)
|
|
||||||
{
|
|
||||||
m_controllerMapper = conMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public System.IO.Stream OpenRom(string fname)
|
public System.IO.Stream OpenRom(string fname)
|
||||||
{
|
{
|
||||||
@ -95,51 +90,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
var db = Resources.Load<RomDB>("NES/ROMDB");
|
var db = Resources.Load<RomDB>("NES/ROMDB");
|
||||||
return db.GetMapperNo(rom.GetPROM_CRC(), out mapperNo);
|
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)
|
public ControllerState FromNet(AxiReplay.ReplayStep step)
|
||||||
{
|
{
|
||||||
var temp = new ServerInputSnapShot();
|
var temp = new ServerInputSnapShot();
|
||||||
|
|||||||
@ -45,7 +45,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
StopGame();
|
StopGame();
|
||||||
|
|
||||||
m_coreSupporter = new CoreSupporter(ControllerMapper);
|
m_coreSupporter = new CoreSupporter();
|
||||||
Supporter.Setup(m_coreSupporter);
|
Supporter.Setup(m_coreSupporter);
|
||||||
Debuger.Setup(new CoreDebuger());
|
Debuger.Setup(new CoreDebuger());
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
protected override ControllerState GetLocalInput()
|
protected override ControllerState GetLocalInput()
|
||||||
{
|
{
|
||||||
return m_coreSupporter.GetControllerState();
|
return ControllerMapper.CreateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}");
|
||||||
}
|
}
|
||||||
App.roomMgr.SendRoomSingelPlayerInput(Frame, rawData);
|
App.roomMgr.SendRoomSingelPlayerInput(Frame, rawData);
|
||||||
}
|
}
|
||||||
//单机模式
|
else//单机模式
|
||||||
else
|
|
||||||
{
|
{
|
||||||
inputData = GetLocalInput();
|
inputData = GetLocalInput();
|
||||||
result = true;
|
result = true;
|
||||||
|
|||||||
@ -23,7 +23,5 @@
|
|||||||
void SaveFile(byte[] fileData, string directPath, string fileName);
|
void SaveFile(byte[] fileData, string directPath, string fileName);
|
||||||
System.IO.Stream OpenFile(string directPath, string fileName);
|
System.IO.Stream OpenFile(string directPath, string fileName);
|
||||||
bool TryGetMapperNo(ROM rom, out int mapperNo);
|
bool TryGetMapperNo(ROM rom, out int mapperNo);
|
||||||
ControllerState GetControllerState();
|
|
||||||
void SampleInput(uint frameCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user