Remove calls to already implemented functions (#1116)
* Remove calls to already implemented functions * Fix location comment for getClosestTownAndUnk * Move buildDeliveredCargoPaymentsTable (Maybe just keep in UI?) * Remove terraform hooks
This commit is contained in:
parent
2d1b9944b7
commit
d793467167
|
@ -1,4 +1,5 @@
|
|||
#include "Economy.h"
|
||||
#include "../CompanyManager.h"
|
||||
#include "../Interop/Interop.hpp"
|
||||
#include "../Ui/WindowManager.h"
|
||||
#include "../Ui/WindowType.h"
|
||||
|
@ -43,6 +44,7 @@ namespace OpenLoco::Economy
|
|||
};
|
||||
|
||||
static loco_global<uint32_t[32], 0x00525E5E> currencyMultiplicationFactor;
|
||||
static loco_global<currency32_t[32][60], 0x009C68F8> _deliveredCargoPayment;
|
||||
|
||||
// NB: This is not used for anything due to a mistake in original inflation calculation
|
||||
// looks as if it was meant to be extra precesion for the currencyMultiplicationFactor
|
||||
|
@ -50,9 +52,21 @@ namespace OpenLoco::Economy
|
|||
static loco_global<uint32_t[32], 0x00525EDE> _525EDE;
|
||||
|
||||
// 0x004375F7
|
||||
static void sub_4375F7()
|
||||
void buildDeliveredCargoPaymentsTable()
|
||||
{
|
||||
call(0x004375F7);
|
||||
for (uint8_t cargoItem = 0; cargoItem < ObjectManager::getMaxObjects(ObjectType::cargo); ++cargoItem)
|
||||
{
|
||||
auto* cargoObj = ObjectManager::get<CargoObject>(cargoItem);
|
||||
if (cargoObj == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint16_t numDays = 2; numDays <= 122; ++numDays)
|
||||
{
|
||||
_deliveredCargoPayment[cargoItem][(numDays / 2) - 1] = CompanyManager::calculateDeliveredCargoPayment(cargoItem, 100, 10, numDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 0x0046E239
|
||||
|
@ -64,7 +78,7 @@ namespace OpenLoco::Economy
|
|||
currencyMultiplicationFactor[i] += (static_cast<uint64_t>(_inflationFactors[i]) * currencyMultiplicationFactor[i]) >> 12;
|
||||
}
|
||||
|
||||
sub_4375F7();
|
||||
buildDeliveredCargoPaymentsTable();
|
||||
Ui::WindowManager::invalidate(Ui::WindowType::companyList);
|
||||
Ui::WindowManager::invalidate(Ui::WindowType::buildVehicle);
|
||||
Ui::WindowManager::invalidate(Ui::WindowType::construction);
|
||||
|
|
|
@ -8,4 +8,5 @@ namespace OpenLoco::Economy
|
|||
void updateMonthly();
|
||||
void sub_46E2C0(uint16_t year);
|
||||
currency32_t getInflationAdjustedCost(uint16_t costFactor, uint8_t costIndex, uint8_t divisor);
|
||||
void buildDeliveredCargoPaymentsTable();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace OpenLoco::Game
|
|||
Audio::pauseSound();
|
||||
setPauseFlag(1 << 2);
|
||||
Gfx::invalidateScreen();
|
||||
Ui::ProgressBar::sub_4CF63B();
|
||||
Gfx::render();
|
||||
|
||||
bool confirm = Ui::Windows::PromptBrowse::open(type, &_savePath[0], filter, titleBuffer);
|
||||
|
||||
|
@ -58,7 +58,7 @@ namespace OpenLoco::Game
|
|||
Ui::processMessagesMini();
|
||||
unsetPauseFlag(1 << 2);
|
||||
Gfx::invalidateScreen();
|
||||
Ui::ProgressBar::sub_4CF63B();
|
||||
Gfx::render();
|
||||
|
||||
return confirm;
|
||||
}
|
||||
|
|
|
@ -778,7 +778,6 @@ void OpenLoco::Interop::registerHooks()
|
|||
Ui::Windows::ToolTip::registerHooks();
|
||||
Ui::Windows::Vehicle::registerHooks();
|
||||
Ui::Windows::BuildVehicle::registerHooks();
|
||||
Ui::Windows::Terraform::registerHooks();
|
||||
Ui::Windows::Error::registerHooks();
|
||||
Ui::Windows::Construction::registerHooks();
|
||||
Ui::WindowManager::registerHooks();
|
||||
|
|
|
@ -441,7 +441,7 @@ namespace OpenLoco
|
|||
initialiseViewports();
|
||||
Title::sub_4284C8();
|
||||
call(0x004969DA);
|
||||
call(0x0043C88C);
|
||||
Scenario::reset();
|
||||
setScreenFlag(ScreenFlags::initialised);
|
||||
#ifdef _SHOW_INTRO_
|
||||
Intro::state(Intro::State::begin);
|
||||
|
@ -459,12 +459,6 @@ namespace OpenLoco
|
|||
call(0x00428E47);
|
||||
}
|
||||
|
||||
// 0x00444387
|
||||
void sub_444387()
|
||||
{
|
||||
call(0x00444387);
|
||||
}
|
||||
|
||||
// 0x0046E388
|
||||
static void sub_46E388()
|
||||
{
|
||||
|
|
|
@ -67,6 +67,4 @@ namespace OpenLoco
|
|||
void promptTickLoop(std::function<bool()> tickAction);
|
||||
[[noreturn]] void exitCleanly();
|
||||
void exitWithError(OpenLoco::string_id message, uint32_t errorCode);
|
||||
|
||||
void sub_444387();
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace OpenLoco::Scenario
|
|||
{
|
||||
S5::getOptions().scenarioFlags &= ~(Scenario::flags::landscape_generation_done);
|
||||
Ui::WindowManager::invalidate(Ui::WindowType::landscapeGeneration, 0);
|
||||
call(0x0043C88C);
|
||||
reset();
|
||||
S5::getOptions().madeAnyChanges = 0;
|
||||
addr<0x00F25374, uint8_t>() = 0;
|
||||
Gfx::invalidateScreen();
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace OpenLoco::TownManager
|
|||
Ui::WindowManager::invalidate(Ui::WindowType::town);
|
||||
}
|
||||
|
||||
// 0x00497DC1
|
||||
// 0x00497E52
|
||||
std::optional<std::pair<TownId_t, uint8_t>> getClosestTownAndUnk(const Map::Pos2& loc)
|
||||
{
|
||||
int32_t closestDistance = std::numeric_limits<uint16_t>::max();
|
||||
|
|
|
@ -57,12 +57,6 @@ namespace OpenLoco::Ui::ProgressBar
|
|||
call(0x004CF631, regs);
|
||||
}
|
||||
|
||||
// 0x004CF63B
|
||||
void sub_4CF63B()
|
||||
{
|
||||
call(0x004CF63B);
|
||||
}
|
||||
|
||||
// 0x004CF621
|
||||
// eax: value
|
||||
void setProgress(int32_t value)
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace OpenLoco::Ui::ProgressBar
|
|||
{
|
||||
void begin(std::string_view string);
|
||||
void begin(string_id stringId);
|
||||
void sub_4CF63B();
|
||||
void setProgress(int32_t value);
|
||||
void end();
|
||||
void registerHooks();
|
||||
|
|
|
@ -299,7 +299,6 @@ namespace OpenLoco::Ui::Windows
|
|||
void openPlantTrees();
|
||||
void openBuildWalls();
|
||||
bool rotate(Window*);
|
||||
void registerHooks();
|
||||
}
|
||||
|
||||
namespace TextInput
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "../Company.h"
|
||||
#include "../CompanyManager.h"
|
||||
#include "../Date.h"
|
||||
#include "../Economy/Economy.h"
|
||||
#include "../Graphics/Colour.h"
|
||||
#include "../Graphics/ImageIds.h"
|
||||
#include "../Input.h"
|
||||
|
@ -1134,24 +1135,6 @@ namespace OpenLoco::Ui::Windows::CompanyList
|
|||
Gfx::drawString_494B3F(*context, x, y, Colour::black, StringIds::cargo_transit_time);
|
||||
}
|
||||
|
||||
// 0x004375F7
|
||||
static void buildDeliveredCargoPaymentsTable()
|
||||
{
|
||||
for (uint8_t cargoItem = 0; cargoItem < ObjectManager::getMaxObjects(ObjectType::cargo); ++cargoItem)
|
||||
{
|
||||
auto* cargoObj = ObjectManager::get<CargoObject>(cargoItem);
|
||||
if (cargoObj == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint16_t numDays = 2; numDays <= 122; ++numDays)
|
||||
{
|
||||
_deliveredCargoPayment[cargoItem][(numDays / 2) - 1] = CompanyManager::calculateDeliveredCargoPayment(cargoItem, 100, 10, numDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 0x004379F2
|
||||
static void setLegendHover(Window* self, int16_t x, int16_t y)
|
||||
{
|
||||
|
@ -1203,7 +1186,7 @@ namespace OpenLoco::Ui::Windows::CompanyList
|
|||
self->max_height = windowSize.height;
|
||||
self->width = windowSize.width;
|
||||
self->height = windowSize.height;
|
||||
buildDeliveredCargoPaymentsTable();
|
||||
Economy::buildDeliveredCargoPaymentsTable();
|
||||
}
|
||||
|
||||
static void initEvents()
|
||||
|
@ -1229,7 +1212,7 @@ namespace OpenLoco::Ui::Windows::CompanyList
|
|||
|
||||
static WindowEventList events;
|
||||
|
||||
// 0x0043737D
|
||||
// 0x00437591
|
||||
static void onResize(Window* self)
|
||||
{
|
||||
self->setSize(windowSize, windowSize);
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace OpenLoco::Ui::Windows::ProgressBar
|
|||
|
||||
_progressBarValue = value;
|
||||
WindowManager::invalidate(WindowType::progressBar);
|
||||
Ui::ProgressBar::sub_4CF63B();
|
||||
Gfx::render();
|
||||
}
|
||||
|
||||
// 0x004CF78A
|
||||
|
|
|
@ -1206,8 +1206,8 @@ namespace OpenLoco::Ui::Windows::Terraform
|
|||
events.on_update = Common::onUpdate;
|
||||
events.on_tool_update = onToolUpdate;
|
||||
events.on_tool_down = onToolDown;
|
||||
events.toolDragContinue = (void (*)(Window&, const WidgetIndex_t, const int16_t, const int16_t))0x004BC682;
|
||||
events.toolDragEnd = (void (*)(Window&, const WidgetIndex_t))0x004BC701;
|
||||
events.toolDragContinue = toolDragContinue;
|
||||
events.toolDragEnd = toolDragEnd;
|
||||
events.prepare_draw = prepareDraw;
|
||||
events.draw = draw;
|
||||
}
|
||||
|
@ -1628,8 +1628,8 @@ namespace OpenLoco::Ui::Windows::Terraform
|
|||
events.on_update = Common::onUpdate;
|
||||
events.on_tool_update = onToolUpdate;
|
||||
events.on_tool_down = onToolDown;
|
||||
events.toolDragContinue = (void (*)(Window&, const WidgetIndex_t, const int16_t, const int16_t))0x004BC9E2;
|
||||
events.toolDragEnd = (void (*)(Window&, const WidgetIndex_t))0x004BCA5D;
|
||||
events.toolDragContinue = toolDragContinue;
|
||||
events.toolDragEnd = toolDragEnd;
|
||||
events.prepare_draw = prepareDraw;
|
||||
events.draw = draw;
|
||||
}
|
||||
|
@ -1908,8 +1908,8 @@ namespace OpenLoco::Ui::Windows::Terraform
|
|||
events.on_update = Common::onUpdate;
|
||||
events.on_tool_update = onToolUpdate;
|
||||
events.on_tool_down = onToolDown;
|
||||
events.toolDragContinue = (void (*)(Window&, const WidgetIndex_t, const int16_t, const int16_t))0x004BCDBF;
|
||||
events.toolDragEnd = (void (*)(Window&, const WidgetIndex_t))0x004BCDE8;
|
||||
events.toolDragContinue = toolDragContinue;
|
||||
events.toolDragEnd = toolDragEnd;
|
||||
events.prepare_draw = prepareDraw;
|
||||
events.draw = draw;
|
||||
}
|
||||
|
@ -2667,61 +2667,4 @@ namespace OpenLoco::Ui::Windows::Terraform
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void registerHooks()
|
||||
{
|
||||
registerHook(
|
||||
0x004BC9E2,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
AdjustLand::toolDragContinue((Ui::Window&)regs.esi, (WidgetIndex_t)regs.dx, (int16_t)regs.ax, (int16_t)regs.bx);
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHook(
|
||||
0x004BCA5D,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
AdjustLand::toolDragEnd((Ui::Window&)regs.esi, (WidgetIndex_t)regs.dx);
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHook(
|
||||
0x004BCDBF,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
AdjustWater::toolDragContinue((Ui::Window&)regs.esi, (WidgetIndex_t)regs.dx, (int16_t)regs.ax, (int16_t)regs.bx);
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHook(
|
||||
0x004BCDE8,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
AdjustWater::toolDragEnd((Ui::Window&)regs.esi, (WidgetIndex_t)regs.dx);
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHook(
|
||||
0x004BC682,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
ClearArea::toolDragContinue((Ui::Window&)regs.esi, (WidgetIndex_t)regs.dx, (int16_t)regs.ax, (int16_t)regs.bx);
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
|
||||
registerHook(
|
||||
0x004BC701,
|
||||
[](registers& regs) FORCE_ALIGN_ARG_POINTER -> uint8_t {
|
||||
registers backup = regs;
|
||||
ClearArea::toolDragEnd((Ui::Window&)regs.esi, (WidgetIndex_t)regs.dx);
|
||||
regs = backup;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace OpenLoco::Ui::Windows::TitleVersion
|
|||
&_events);
|
||||
window->widgets = widgets;
|
||||
|
||||
_events.prepare_draw = (void (*)(Ui::Window*))0x0042A035;
|
||||
_events.draw = draw;
|
||||
|
||||
return window;
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace OpenLoco::Ui::Windows::ToolbarTop::Editor
|
|||
switch (itemIndex)
|
||||
{
|
||||
case 0:
|
||||
call(0x0043DA43);
|
||||
Windows::LandscapeGeneration::open();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue