From 2f4db4a0482965b7aedc92c81fb3789f21b44b75 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Tue, 24 Jan 2017 18:19:50 +0800 Subject: [PATCH] Player keeps any keys collected on a secret level even if they die on the secret level --- common/main/player-flags.h | 5 +++++ similar/main/state.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/common/main/player-flags.h b/common/main/player-flags.h index d8fb19d41..ee3f26f80 100644 --- a/common/main/player-flags.h +++ b/common/main/player-flags.h @@ -87,6 +87,11 @@ public: flags |= rhs.flags; return *this; } + player_flags &operator|=(const uint32_t &rhs) + { + flags |= rhs; + return *this; + } player_flags operator|(const player_flags &rhs) const { return player_flags(flags | rhs.flags); diff --git a/similar/main/state.cpp b/similar/main/state.cpp index 3b34fe636..996d0f25b 100644 --- a/similar/main/state.cpp +++ b/similar/main/state.cpp @@ -1536,6 +1536,12 @@ int state_restore_all_sub(const char *filename, const secret_restore secret) do_cloak_invul_secret_stuff(old_gametime, ret_pl_info); } else { get_local_player() = dummy_player; + // Keep keys even if they died on secret level (otherwise game becomes impossible) + // Example: Cameron 'Stryker' Fultz's Area 51 + pl_info.powerup_flags |= (plrobj.ctype.player_info.powerup_flags & + (PLAYER_FLAGS_BLUE_KEY | + PLAYER_FLAGS_RED_KEY | + PLAYER_FLAGS_GOLD_KEY)); } } else #endif