nes-protect from syncstates which dont call base.SyncState
This commit is contained in:
parent
9c2a521c19
commit
ecd58fc96e
|
@ -70,12 +70,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
public CartInfo Cart { get { return NES.cart; } }
|
||||
public NES NES { get; set; }
|
||||
|
||||
//this is set to true when SyncState is called, so that we know the base class SyncState was used
|
||||
public bool SyncStateFlag = false;
|
||||
|
||||
public virtual void SyncState(Serializer ser)
|
||||
{
|
||||
ser.Sync("vram", ref vram, true);
|
||||
ser.Sync("wram", ref wram, true);
|
||||
for (int i = 0; i < 4; i++) ser.Sync("mirroring" + i, ref mirroring[i]);
|
||||
ser.Sync("irq_signal", ref irq_signal);
|
||||
SyncStateFlag = true;
|
||||
}
|
||||
|
||||
public virtual void SyncIRQ(bool flag)
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser); //any syncstate which doesnt call base is a BUG!!!!!!!!! im going to protect against this in the near future.
|
||||
base.SyncState(ser);
|
||||
ser.Sync("reg_addr", ref reg_addr);
|
||||
ser.Sync("regs", ref regs);
|
||||
Sync();
|
||||
|
|
|
@ -595,6 +595,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
ser.Sync("cpu_stepcounter", ref cpu_stepcounter);
|
||||
ser.Sync("cpu_deadcounter", ref cpu_deadcounter);
|
||||
board.SyncState(ser);
|
||||
if (board is NESBoardBase && !((NESBoardBase)board).SyncStateFlag)
|
||||
throw new InvalidOperationException("the current NES mapper didnt call base.SyncState");
|
||||
ppu.SyncState(ser);
|
||||
apu.SyncState(ser);
|
||||
ser.EndSection();
|
||||
|
|
Loading…
Reference in New Issue