2015-05-03 06:22:03 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <engine/GameState.hpp>
|
|
|
|
#include <engine/SaveGame.hpp>
|
2015-06-14 03:44:51 +02:00
|
|
|
#include <script/ScriptMachine.hpp>
|
2017-02-20 17:56:59 +01:00
|
|
|
|
2017-10-26 03:51:24 +02:00
|
|
|
#include "test_Globals.hpp"
|
2015-05-03 06:22:03 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
#if 0 // Disabled until we make a start on saving the game
|
2015-05-03 06:22:03 +02:00
|
|
|
BOOST_AUTO_TEST_SUITE(SaveGameTests)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_write_state)
|
|
|
|
{
|
|
|
|
GameState state;
|
|
|
|
|
|
|
|
// Set some test data
|
|
|
|
state.world = nullptr;
|
|
|
|
state.currentProgress = 10;
|
|
|
|
state.maxProgress = 124;
|
|
|
|
state.numMissions = 12;
|
|
|
|
state.numHiddenPackages = 34;
|
|
|
|
state.numHiddenPackagesDiscovered = 11;
|
|
|
|
state.numUniqueJumps = 14;
|
|
|
|
state.numRampages = 7;
|
|
|
|
state.maxWantedLevel = 5;
|
|
|
|
state.currentWeather = 9;
|
|
|
|
state.overrideNextStart = true;
|
|
|
|
state.hour = 13;
|
|
|
|
state.minute = 32;
|
|
|
|
|
|
|
|
// This may break due to cwd issues
|
|
|
|
SaveGame::writeState(state, "test_savestate.sav");
|
|
|
|
|
|
|
|
GameState loaded;
|
|
|
|
loaded.world = nullptr;
|
|
|
|
|
|
|
|
BOOST_REQUIRE( SaveGame::loadState(loaded, "test_savestate.sav") );
|
|
|
|
BOOST_CHECK( loaded.world == nullptr );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.currentProgress, state.currentProgress );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.maxProgress, state.maxProgress );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.numMissions, state.numMissions );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.numHiddenPackages, state.numHiddenPackages );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.numHiddenPackagesDiscovered, state.numHiddenPackagesDiscovered );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.numUniqueJumps, state.numUniqueJumps );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.numRampages, state.numRampages );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.maxWantedLevel, state.maxWantedLevel );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.currentWeather, state.currentWeather );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.overrideNextStart, state.overrideNextStart );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.hour, state.hour );
|
|
|
|
BOOST_CHECK_EQUAL( loaded.minute, state.minute );
|
2015-06-14 03:44:51 +02:00
|
|
|
|
|
|
|
// Check Garage data + garage vehicle restoration
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_load_game)
|
|
|
|
{
|
|
|
|
GameState state;
|
|
|
|
GameWorld world();
|
|
|
|
SCMOpcodes s;
|
2016-06-11 17:07:30 +02:00
|
|
|
auto file = Global::get().d->loadSCM("main.scm");
|
2015-06-14 03:44:51 +02:00
|
|
|
ScriptMachine machine(&state, file, &s);
|
|
|
|
|
|
|
|
state.world = Global::get().e;
|
|
|
|
state.script = &machine;
|
|
|
|
|
|
|
|
BOOST_REQUIRE( SaveGame::loadGame(state, "GTA3sf1.b") );
|
2015-05-03 06:22:03 +02:00
|
|
|
}
|
|
|
|
|
2016-04-15 02:06:10 +02:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|
|
|
|
#endif
|