2020-09-07 07:42:02 +02:00
|
|
|
#include "Town.h"
|
2018-01-31 21:27:30 +01:00
|
|
|
#include "interop/interop.hpp"
|
2020-04-22 23:05:01 +02:00
|
|
|
#include "localisation/string_ids.h"
|
2018-01-25 20:03:46 +01:00
|
|
|
#include <algorithm>
|
2018-01-25 00:24:16 +01:00
|
|
|
|
2018-01-31 21:27:30 +01:00
|
|
|
using namespace openloco::interop;
|
|
|
|
|
2018-01-25 00:24:16 +01:00
|
|
|
namespace openloco
|
|
|
|
{
|
2018-01-25 20:03:46 +01:00
|
|
|
constexpr int32_t min_company_rating = -1000;
|
|
|
|
constexpr int32_t max_company_rating = 1000;
|
|
|
|
|
2018-01-25 00:24:16 +01:00
|
|
|
bool town::empty() const
|
|
|
|
{
|
2018-01-27 00:01:23 +01:00
|
|
|
return name == string_ids::null;
|
2018-01-25 00:24:16 +01:00
|
|
|
}
|
2018-01-25 20:03:46 +01:00
|
|
|
|
2018-01-31 21:27:30 +01:00
|
|
|
// 0x0049742F
|
|
|
|
void town::update()
|
|
|
|
{
|
|
|
|
registers regs;
|
|
|
|
regs.esi = (int32_t)this;
|
|
|
|
call(0x0049742F, regs);
|
|
|
|
}
|
|
|
|
|
2020-09-05 14:56:51 +02:00
|
|
|
void town::adjustCompanyRating(company_id_t cid, int amount)
|
2018-01-25 20:03:46 +01:00
|
|
|
{
|
|
|
|
companies_with_rating |= (1 << cid);
|
|
|
|
company_ratings[cid] = std::clamp(
|
|
|
|
company_ratings[cid] + amount,
|
|
|
|
min_company_rating,
|
|
|
|
max_company_rating);
|
|
|
|
}
|
2020-04-22 23:05:01 +02:00
|
|
|
|
|
|
|
string_id town::getTownSizeString() const
|
|
|
|
{
|
|
|
|
static string_id townSizeNames[5] = {
|
|
|
|
string_ids::town_size_hamlet,
|
|
|
|
string_ids::town_size_village,
|
|
|
|
string_ids::town_size_town,
|
|
|
|
string_ids::town_size_city,
|
|
|
|
string_ids::town_size_metropolis
|
|
|
|
};
|
|
|
|
|
|
|
|
if (static_cast<uint8_t>(size) < std::size(townSizeNames))
|
|
|
|
{
|
|
|
|
return townSizeNames[static_cast<uint8_t>(size)];
|
|
|
|
}
|
|
|
|
return string_ids::town_size_hamlet;
|
|
|
|
}
|
2018-01-25 00:24:16 +01:00
|
|
|
}
|