MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / RollbackToCheckpoint

Method RollbackToCheckpoint

Sources/Jazz2/LevelHandler.cpp:1254–1291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1252 }
1253
1254 void LevelHandler::RollbackToCheckpoint(Actors::Player* player)
1255 {
1256 // Reset the camera
1257 LimitCameraView(player, player->_pos, 0, 0);
1258
1259 WarpCameraToTarget(player);
1260
1261 if (IsLocalSession()) {
1262 for (auto& actor : _actors) {
1263 // Despawn all actors that were created after the last checkpoint
1264 if (actor->_spawnFrames > _checkpointFrames && !actor->GetState(Actors::ActorState::PreserveOnRollback)) {
1265 if ((actor->_state & (Actors::ActorState::IsCreatedFromEventMap | Actors::ActorState::IsFromGenerator)) != Actors::ActorState::None) {
1266 Vector2i originTile = actor->_originTile;
1267 if ((actor->_state & Actors::ActorState::IsFromGenerator) == Actors::ActorState::IsFromGenerator) {
1268 _eventMap->ResetGenerator(originTile.X, originTile.Y);
1269 }
1270
1271 _eventMap->Deactivate(originTile.X, originTile.Y);
1272 }
1273
1274 actor->_state |= Actors::ActorState::IsDestroyed;
1275 }
1276 }
1277
1278 _eventMap->RollbackToCheckpoint();
1279 // Don't rollback the tilemap in local sessions for now
1280 //_tileMap->RollbackToCheckpoint();
1281 _elapsedFrames = _checkpointFrames;
1282 }
1283
1284 BeginPlayMusic(_musicDefaultPath);
1285
1286#if defined(WITH_ANGELSCRIPT)
1287 if (_scripts != nullptr) {
1288 _scripts->OnLevelReload();
1289 }
1290#endif
1291 }
1292
1293 void LevelHandler::HandleActivateSugarRush(Actors::Player* player)
1294 {

Callers

nothing calls this directly

Calls 4

ResetGeneratorMethod · 0.80
OnLevelReloadMethod · 0.80
GetStateMethod · 0.45
DeactivateMethod · 0.45

Tested by

no test coverage detected