Fix switching modes between scenes
This commit is contained in:
parent
34691affb0
commit
d18276d255
|
@ -58,8 +58,9 @@ void GameModeManager::update() {
|
||||||
void GameModeManager::initScene(const GameModeInitInfo& info) {
|
void GameModeManager::initScene(const GameModeInitInfo& info) {
|
||||||
sead::ScopedCurrentHeapSetter heapSetter(mHeap);
|
sead::ScopedCurrentHeapSetter heapSetter(mHeap);
|
||||||
|
|
||||||
if (mCurModeBase != nullptr) {
|
if (mCurModeBase != nullptr && mWasSetMode) {
|
||||||
delete mCurModeBase;
|
delete mCurModeBase;
|
||||||
|
mCurModeBase = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLastInitInfo != nullptr) {
|
if (mLastInitInfo != nullptr) {
|
||||||
|
@ -68,19 +69,17 @@ void GameModeManager::initScene(const GameModeInitInfo& info) {
|
||||||
|
|
||||||
if (mCurMode == GameMode::NONE) {
|
if (mCurMode == GameMode::NONE) {
|
||||||
mCurModeBase = nullptr;
|
mCurModeBase = nullptr;
|
||||||
|
delete mModeInfo;
|
||||||
mModeInfo = nullptr;
|
mModeInfo = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastInitInfo = new GameModeInitInfo(info);
|
mLastInitInfo = new GameModeInitInfo(info);
|
||||||
|
|
||||||
if (!mCurModeBase && mWasSetMode) {
|
if (mWasSetMode) {
|
||||||
GameModeFactory factory("GameModeFactory");
|
GameModeFactory factory("GameModeFactory");
|
||||||
const char* name = factory.getModeString(mCurMode);
|
const char* name = factory.getModeString(mCurMode);
|
||||||
mCurModeBase = factory.getCreator(name)(name);
|
mCurModeBase = factory.getCreator(name)(name);
|
||||||
if (mLastInitInfo) { // check if there's a previously used init info
|
|
||||||
mCurModeBase->init(*mLastInitInfo);
|
|
||||||
}
|
|
||||||
mWasSetMode = false;
|
mWasSetMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue