예제 #1
0
 /// <summary>
 /// Makes our current state match the state passed in by GGPO.
 /// </summary>
 /// <param name="frame"></param>
 /// <returns></returns>
 public bool SaveGameState(ref Sync.SavedFrame frame)
 {
     frame.buffer   = gs;
     frame.frame    = gs.FrameNumber;
     frame.checksum = Utility.CreateChecksum(Utility.GetByteArray(gs));
     return(true);
 }
예제 #2
0
        protected unsafe void Serialize(ref Sync.SavedFrame frame)
        {
            WorldPoolID id = SavedStates.Get(out World saveState);

            EntityManager.BeginExclusiveEntityTransaction();
            saveState.EntityManager.CopyAndReplaceEntitiesFrom(EntityManager);
            EntityManager.EndExclusiveEntityTransaction();

            // Get the hash and reduce
            ulong hash = _hasher.GetWorldHash();

            unchecked {
                frame = new Sync.SavedFrame {
                    // NOTE: THIS IS A HUGE HACK. If this ever gets dereferenced, the
                    // game will hard crash via segmentation fault.
                    Buffer = (byte *)id,
                    // Reduce the 64 bit hash by XORing the top 32 bits with the bottom 32
                    Checksum = (int)((hash & 0xffffffff) ^ ((hash >> 32) & 0xffffffff)),
                    Size     = 0,
                };
            }
        }