2020-06-28 06:54:42 +00:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
|
|
|
*
|
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
|
|
|
* This code is based on source code created by Revolution Software,
|
|
|
|
* used with permission.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp
|
|
|
|
|
|
|
|
#include "engines/icb/common/px_common.h"
|
2020-10-06 07:51:20 +00:00
|
|
|
#include "engines/icb/global_objects.h"
|
|
|
|
#include "engines/icb/global_vars.h"
|
|
|
|
#include "engines/icb/global_switches.h"
|
|
|
|
#include "engines/icb/mission.h"
|
|
|
|
#include "engines/icb/mission_functions.h"
|
|
|
|
#include "engines/icb/res_man.h"
|
2020-06-28 06:54:42 +00:00
|
|
|
|
|
|
|
#include "common/textconsole.h"
|
|
|
|
|
|
|
|
namespace ICB {
|
|
|
|
|
2021-03-08 09:00:06 +00:00
|
|
|
int32 LoadMission(int32 m, void * /*usr*/) {
|
2021-03-13 18:20:24 +00:00
|
|
|
int32 demo = g_globalScriptVariables->GetVariable("demo");
|
2020-06-28 06:54:42 +00:00
|
|
|
Init_globals(); // reload the global vars for the new mission
|
2021-03-13 18:20:24 +00:00
|
|
|
g_globalScriptVariables->SetVariable("missionelapsedtime", 0);
|
2020-06-28 06:54:42 +00:00
|
|
|
|
|
|
|
// On mission 8 (m=7?) then set a global variable to say we are on mission 8 and not on mission 9
|
|
|
|
if (m == 7) {
|
2021-03-13 18:20:24 +00:00
|
|
|
g_globalScriptVariables->SetVariable("mission9", 0);
|
2020-06-28 06:54:42 +00:00
|
|
|
}
|
|
|
|
// On mission 9 (m=8?) then set a global variable to say we are on mission 9 and not on mission 8
|
|
|
|
if (m == 8) {
|
2021-03-13 18:20:24 +00:00
|
|
|
g_globalScriptVariables->SetVariable("mission9", 1);
|
2020-06-28 06:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update the demo flag status
|
2021-03-13 18:20:24 +00:00
|
|
|
g_globalScriptVariables->SetVariable("demo", demo);
|
2020-06-28 06:54:42 +00:00
|
|
|
|
|
|
|
// Purge the res_man's to prevent them getting confused
|
|
|
|
rs_anims->Res_purge_all();
|
|
|
|
rs_bg->Res_purge_all();
|
|
|
|
|
|
|
|
warning("rs_anims %d files %dKB rs_bg %d files %dKB", rs_anims->Fetch_files_open(), (rs_anims->Fetch_mem_used() / 1024), rs_bg->Fetch_files_open(),
|
|
|
|
(rs_bg->Fetch_mem_used() / 1024));
|
|
|
|
|
2021-03-14 07:59:48 +00:00
|
|
|
g_px->current_cd = WhichCD(g_mission_names[m - 1]);
|
2020-06-28 06:54:42 +00:00
|
|
|
|
|
|
|
// Load in the session (mission_name, session_name)
|
|
|
|
if (Setup_new_mission(g_mission_startup_names[(m - 1) * 2], g_mission_startup_names[(m - 1) * 2 + 1])) {
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Go straight into mission not the console
|
|
|
|
|
|
|
|
zdebug = FALSE8;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RestartMission(void) {
|
|
|
|
if (g_mission == NULL) {
|
|
|
|
Fatal_error("Can't restart a deleted mission");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the mission name for the current mission
|
|
|
|
const char *mission_name;
|
|
|
|
|
|
|
|
mission_name = g_mission->Fetch_tiny_mission_name();
|
|
|
|
|
|
|
|
// Find which mission number the current mission is
|
2021-03-07 08:56:34 +00:00
|
|
|
int32 m = FindMissionNumber(mission_name);
|
2020-06-28 06:54:42 +00:00
|
|
|
if (m == -1) {
|
|
|
|
Fatal_error("Couldn't find the mission '%s'", mission_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change the mission number from 0-8 to 1-9
|
|
|
|
m++;
|
|
|
|
|
|
|
|
// Right : so just Load that mission
|
|
|
|
LoadMission(m, NULL);
|
|
|
|
}
|
|
|
|
|
2021-03-07 08:56:34 +00:00
|
|
|
int32 FindMissionNumber(const char *mission) {
|
|
|
|
int32 m;
|
2020-06-28 06:54:42 +00:00
|
|
|
|
|
|
|
// Find which mission number this mission is
|
|
|
|
for (m = 0; m < NUMBER_OF_MISSIONS; m++) {
|
2020-10-09 20:46:40 +00:00
|
|
|
if (scumm_stricmp(g_mission_names[m], mission) == 0) {
|
2020-06-28 06:54:42 +00:00
|
|
|
// Mission 8-9 special case check
|
|
|
|
if (m == 6) {
|
2021-03-13 18:20:24 +00:00
|
|
|
if (g_globalScriptVariables->GetVariable("mission9") == 1)
|
2020-06-28 06:54:42 +00:00
|
|
|
m = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m == NUMBER_OF_MISSIONS) {
|
|
|
|
m = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace ICB
|