Implement Scenario::reset (#776)
This commit is contained in:
parent
b53bfdbab7
commit
596804a75a
|
@ -26,6 +26,12 @@ namespace OpenLoco::CompanyManager
|
|||
|
||||
static void produceCompanies();
|
||||
|
||||
// 0x0042F7F8
|
||||
void reset()
|
||||
{
|
||||
call(0x0042F7F8);
|
||||
}
|
||||
|
||||
company_id_t updatingCompanyId()
|
||||
{
|
||||
return _updating_company_id;
|
||||
|
@ -231,4 +237,5 @@ namespace OpenLoco::CompanyManager
|
|||
|
||||
GameCommands::do_73(mapPosition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace OpenLoco::CompanyManager
|
|||
{
|
||||
constexpr size_t max_companies = 15;
|
||||
|
||||
void reset();
|
||||
company_id_t updatingCompanyId();
|
||||
void updatingCompanyId(company_id_t id);
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ namespace OpenLoco::IndustryManager
|
|||
{
|
||||
static loco_global<industry[max_industries], 0x005C455C> _industries;
|
||||
|
||||
// 0x00453214
|
||||
void reset()
|
||||
{
|
||||
call(0x00453214);
|
||||
}
|
||||
|
||||
std::array<industry, max_industries>& industries()
|
||||
{
|
||||
auto arr = (std::array<industry, max_industries>*)_industries.get();
|
||||
|
@ -45,4 +51,5 @@ namespace OpenLoco::IndustryManager
|
|||
{
|
||||
call(0x0045383B);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace OpenLoco::IndustryManager
|
|||
{
|
||||
constexpr size_t max_industries = 128;
|
||||
|
||||
void reset();
|
||||
std::array<industry, max_industries>& industries();
|
||||
industry* get(industry_id_t id);
|
||||
void update();
|
||||
|
|
|
@ -79,6 +79,12 @@ namespace OpenLoco::StringManager
|
|||
{ month_id::december, { StringIds::month_short_december, StringIds::month_long_december } },
|
||||
};
|
||||
|
||||
// 0x0049650E
|
||||
void reset()
|
||||
{
|
||||
call(0x0049650E);
|
||||
}
|
||||
|
||||
const char* getString(string_id id)
|
||||
{
|
||||
char* str = _strings[id];
|
||||
|
@ -585,4 +591,5 @@ namespace OpenLoco::StringManager
|
|||
auto wrapped = argswrapper(args);
|
||||
return formatString(buffer, id, wrapped);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ namespace OpenLoco
|
|||
|
||||
namespace OpenLoco::StringManager
|
||||
{
|
||||
void reset();
|
||||
const char* getString(string_id id);
|
||||
char* formatString(char* buffer, string_id id, const void* args = nullptr);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
#include "Scenario.h"
|
||||
#include "CompanyManager.h"
|
||||
#include "Graphics/Gfx.h"
|
||||
#include "IndustryManager.h"
|
||||
#include "Interop/Interop.hpp"
|
||||
#include "Map/MapGenerator.h"
|
||||
#include "Map/TileManager.h"
|
||||
#include "Objects/CargoObject.h"
|
||||
#include "S5/S5.h"
|
||||
#include "StationManager.h"
|
||||
#include "Things/ThingManager.h"
|
||||
#include "Title.h"
|
||||
#include "TownManager.h"
|
||||
#include "Ui/WindowManager.h"
|
||||
#include "Windows/Construction/Construction.h"
|
||||
|
||||
using namespace OpenLoco::Interop;
|
||||
using namespace OpenLoco::Map;
|
||||
|
@ -24,10 +31,85 @@ namespace OpenLoco::Scenario
|
|||
static loco_global<uint8_t, 0x00526240> objectiveTimeLimitYears;
|
||||
static loco_global<uint16_t, 0x00526241> objectiveTimeLimitUntilYear;
|
||||
|
||||
// 0x0046115C
|
||||
static void sub_46115C()
|
||||
{
|
||||
call(0x0046115C);
|
||||
}
|
||||
|
||||
// 0x004C4BC0
|
||||
static void sub_4C4BC0()
|
||||
{
|
||||
call(0x004C4BC0);
|
||||
}
|
||||
|
||||
// 0x00496A18
|
||||
static void sub_496A18()
|
||||
{
|
||||
call(0x00496A18);
|
||||
}
|
||||
|
||||
// 0x00475988
|
||||
static void sub_475988()
|
||||
{
|
||||
call(0x00475988);
|
||||
}
|
||||
|
||||
// 0x004A8810
|
||||
static void sub_4A8810()
|
||||
{
|
||||
call(0x004A8810);
|
||||
}
|
||||
|
||||
// TODO: Move to OrderManager::reset
|
||||
// 0x004702EC
|
||||
static void sub_4702EC()
|
||||
{
|
||||
call(0x004702EC);
|
||||
}
|
||||
|
||||
// TODO: Move to Terraform::reset
|
||||
// 0x004BAEC4
|
||||
static void sub_4BAEC4()
|
||||
{
|
||||
call(0x004BAEC4);
|
||||
}
|
||||
|
||||
// 0x0043C8FD
|
||||
static void sub_43C8FD()
|
||||
{
|
||||
call(0x0043C8FD);
|
||||
}
|
||||
|
||||
// 0x0043C88C
|
||||
void reset()
|
||||
{
|
||||
call(0x0043C88C);
|
||||
WindowManager::closeConstructionWindows();
|
||||
|
||||
CompanyManager::updatingCompanyId(0x0F);
|
||||
WindowManager::setCurrentRotation(0);
|
||||
|
||||
CompanyManager::reset();
|
||||
StringManager::reset();
|
||||
ThingManager::reset();
|
||||
|
||||
Ui::Windows::Construction::Construction::reset();
|
||||
sub_46115C();
|
||||
sub_4C4BC0();
|
||||
|
||||
initialiseDate(1900);
|
||||
|
||||
sub_496A18();
|
||||
sub_475988();
|
||||
TownManager::reset();
|
||||
IndustryManager::reset();
|
||||
StationManager::reset();
|
||||
|
||||
sub_4A8810();
|
||||
sub_4702EC();
|
||||
sub_4BAEC4();
|
||||
sub_43C8FD();
|
||||
Title::sub_4284C8();
|
||||
}
|
||||
|
||||
// 0x004748D4
|
||||
|
@ -57,6 +139,7 @@ namespace OpenLoco::Scenario
|
|||
addr<0x00F25374, uint8_t>() = 0;
|
||||
}
|
||||
|
||||
// 0x0049685C
|
||||
void initialiseDate(uint16_t year)
|
||||
{
|
||||
registers regs;
|
||||
|
@ -66,6 +149,15 @@ namespace OpenLoco::Scenario
|
|||
|
||||
void registerHooks()
|
||||
{
|
||||
registerHook(
|
||||
0x0043C88C,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
reset();
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHook(
|
||||
0x0043C90C,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
|
|
|
@ -13,6 +13,12 @@ namespace OpenLoco::StationManager
|
|||
{
|
||||
static loco_global<station[max_stations], 0x005E6EDC> _stations;
|
||||
|
||||
// 0x0048B1D8
|
||||
void reset()
|
||||
{
|
||||
call(0x0048B1D8);
|
||||
}
|
||||
|
||||
std::array<station, max_stations>& stations()
|
||||
{
|
||||
auto arr = (std::array<station, max_stations>*)_stations.get();
|
||||
|
@ -117,4 +123,5 @@ namespace OpenLoco::StationManager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace OpenLoco::StationManager
|
|||
{
|
||||
constexpr size_t max_stations = 1024;
|
||||
|
||||
void reset();
|
||||
std::array<station, max_stations>& stations();
|
||||
station* get(station_id_t id);
|
||||
void update();
|
||||
|
|
|
@ -15,6 +15,12 @@ namespace OpenLoco::ThingManager
|
|||
static loco_global<string_id, 0x009C68E6> gGameCommandErrorText;
|
||||
constexpr size_t _thingSpatialIndexNull = 0x40000;
|
||||
|
||||
// 0x0046FDFD
|
||||
void reset()
|
||||
{
|
||||
call(0x0046FDFD);
|
||||
}
|
||||
|
||||
thing_id_t firstId(thing_list list)
|
||||
{
|
||||
return _heads[(size_t)list];
|
||||
|
@ -119,4 +125,5 @@ namespace OpenLoco::ThingManager
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace OpenLoco::ThingManager
|
|||
misc = 3,
|
||||
};
|
||||
|
||||
void reset();
|
||||
|
||||
template<typename T>
|
||||
T* get(thing_id_t id);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace OpenLoco::Title
|
|||
}
|
||||
|
||||
// 0x004284C8
|
||||
static void sub_4284C8()
|
||||
void sub_4284C8()
|
||||
{
|
||||
call(0x004284C8);
|
||||
}
|
||||
|
|
|
@ -4,4 +4,5 @@ namespace OpenLoco::Title
|
|||
{
|
||||
void registerHooks();
|
||||
void start();
|
||||
void sub_4284C8();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,12 @@ namespace OpenLoco::TownManager
|
|||
{
|
||||
static loco_global<town[max_towns], 0x005B825C> _towns;
|
||||
|
||||
// 0x00496B38
|
||||
void reset()
|
||||
{
|
||||
call(0x00496B38);
|
||||
}
|
||||
|
||||
std::array<town, max_towns>& towns()
|
||||
{
|
||||
auto arr = (std::array<town, max_towns>*)_towns.get();
|
||||
|
@ -136,4 +142,5 @@ namespace OpenLoco::TownManager
|
|||
|
||||
Ui::WindowManager::invalidate(Ui::WindowType::town);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace OpenLoco::TownManager
|
|||
{
|
||||
constexpr size_t max_towns = 80;
|
||||
|
||||
void reset();
|
||||
std::array<town, max_towns>& towns();
|
||||
town* get(town_id_t id);
|
||||
void update();
|
||||
|
|
|
@ -196,6 +196,7 @@ namespace OpenLoco::Ui::Windows::Construction
|
|||
extern window_event_list events;
|
||||
constexpr uint64_t enabledWidgets = Common::enabledWidgets | allConstruction;
|
||||
|
||||
void reset();
|
||||
void activateSelectedConstructionWidgets();
|
||||
void tabReset(window* self);
|
||||
void initEvents();
|
||||
|
|
|
@ -115,6 +115,12 @@ namespace OpenLoco::Ui::Windows::Construction::Construction
|
|||
static std::optional<TrackPieceId> getRoadPieceId(uint8_t trackPiece, uint8_t gradient, uint8_t rotation);
|
||||
static std::optional<TrackPieceId> getTrackPieceId(uint8_t trackPiece, uint8_t gradient, uint8_t rotation);
|
||||
|
||||
// 0x0049B50C
|
||||
void reset()
|
||||
{
|
||||
call(0x0049B50C);
|
||||
}
|
||||
|
||||
// 0x0049F92D
|
||||
static void constructTrack(window* self, widget_index widgetIndex)
|
||||
{
|
||||
|
@ -2115,4 +2121,5 @@ namespace OpenLoco::Ui::Windows::Construction::Construction
|
|||
events.prepare_draw = prepareDraw;
|
||||
events.draw = draw;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue