From dc0e47ac00459664a33d92a316f4e6a504b85919 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 18 Dec 2012 16:17:13 -0500 Subject: fix undo not allowing any more stickmen to be placed, save stickmen in snapshots diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 1e5fbb9..39f496c 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -290,6 +290,9 @@ Snapshot * Simulation::CreateSnapshot() snap->ElecMap.insert(snap->ElecMap.begin(), &emap[0][0], &emap[0][0]+((XRES/CELL)*(YRES/CELL))); snap->FanVelocityX.insert(snap->FanVelocityX.begin(), &fvx[0][0], &fvx[0][0]+((XRES/CELL)*(YRES/CELL))); snap->FanVelocityY.insert(snap->FanVelocityY.begin(), &fvy[0][0], &fvy[0][0]+((XRES/CELL)*(YRES/CELL))); + snap->stickmen.push_back(player2); + snap->stickmen.push_back(player); + snap->stickmen.insert(snap->stickmen.begin(), &fighters[0], &fighters[255]); return snap; } @@ -311,6 +314,9 @@ void Simulation::Restore(const Snapshot & snap) std::copy(snap.ElecMap.begin(), snap.ElecMap.end(), &emap[0][0]); std::copy(snap.FanVelocityX.begin(), snap.FanVelocityX.end(), &fvx[0][0]); std::copy(snap.FanVelocityY.begin(), snap.FanVelocityY.end(), &fvy[0][0]); + std::copy(snap.stickmen.begin(), snap.stickmen.end()-2, &fighters[0]); + player = snap.stickmen[snap.stickmen.size()-1]; + player2 = snap.stickmen[snap.stickmen.size()-2]; } /*int Simulation::Load(unsigned char * data, int dataLength) @@ -3004,7 +3010,6 @@ int Simulation::create_part(int p, int x, int y, int tv) return -1; } create_part(-3,x,y,PT_SPAWN); - elementCount[PT_SPAWN] = 1; break; case PT_STKM2: if (player2.spwn==0) @@ -3026,7 +3031,6 @@ int Simulation::create_part(int p, int x, int y, int tv) return -1; } create_part(-3,x,y,PT_SPAWN2); - elementCount[PT_SPAWN2] = 1; break; case PT_BIZR: case PT_BIZRG: case PT_BIZRS: parts[i].ctype = 0x47FFFF; diff --git a/src/simulation/Snapshot.h b/src/simulation/Snapshot.h index d47f363..983bdf3 100644 --- a/src/simulation/Snapshot.h +++ b/src/simulation/Snapshot.h @@ -28,6 +28,8 @@ public: std::vector FanVelocityX; std::vector FanVelocityY; + std::vector stickmen; + Snapshot() : AirPressure(), AirVelocityX(), @@ -43,7 +45,8 @@ public: BlockMap(), ElecMap(), FanVelocityX(), - FanVelocityY() + FanVelocityY(), + stickmen() { } -- cgit v0.9.2-21-gd62e