Implement the industry struct and manager (#58)
This commit is contained in:
parent
77676e6d46
commit
7a12356220
|
@ -0,0 +1,9 @@
|
|||
#include "industry.h"
|
||||
|
||||
namespace openloco
|
||||
{
|
||||
bool industry::empty() const
|
||||
{
|
||||
return name == string_ids::null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "localisation/stringmgr.h"
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
namespace openloco
|
||||
{
|
||||
using industry_id_t = uint16_t;
|
||||
|
||||
namespace industry_id
|
||||
{
|
||||
constexpr industry_id_t null = std::numeric_limits<industry_id_t>::max();
|
||||
}
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct industry
|
||||
{
|
||||
string_id name;
|
||||
uint8_t pad_02[0xD5 - 0x02];
|
||||
uint16_t var_D5;
|
||||
uint8_t pad_D7[0x453 - 0xD7];
|
||||
|
||||
bool empty() const;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#include "industrymgr.h"
|
||||
#include "interop/interop.hpp"
|
||||
|
||||
using namespace openloco::interop;
|
||||
|
||||
namespace openloco::industrymgr
|
||||
{
|
||||
static loco_global_array<industry, max_industries, 0x005C455C> _industries;
|
||||
|
||||
std::array<industry, max_industries>& industries()
|
||||
{
|
||||
auto arr = (std::array<industry, max_industries>*)_industries.get();
|
||||
return *arr;
|
||||
}
|
||||
|
||||
industry* get(industry_id_t id)
|
||||
{
|
||||
if (id >= _industries.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return &_industries[id];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "industry.h"
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
|
||||
namespace openloco::industrymgr
|
||||
{
|
||||
constexpr size_t max_industries = 128;
|
||||
|
||||
std::array<industry, max_industries>& industries();
|
||||
industry* get(industry_id_t id);
|
||||
}
|
|
@ -21,6 +21,8 @@
|
|||
<ClCompile Include="console.cpp" />
|
||||
<ClCompile Include="date.cpp" />
|
||||
<ClCompile Include="envionment.cpp" />
|
||||
<ClCompile Include="industry.cpp" />
|
||||
<ClCompile Include="industrymgr.cpp" />
|
||||
<ClCompile Include="input.cpp" />
|
||||
<ClCompile Include="interop\hooks.cpp" />
|
||||
<ClCompile Include="localisation\stringmgr.cpp" />
|
||||
|
@ -63,6 +65,8 @@
|
|||
<ClInclude Include="date.h" />
|
||||
<ClInclude Include="environment.h" />
|
||||
<ClInclude Include="graphics\colours.h" />
|
||||
<ClInclude Include="industry.h" />
|
||||
<ClInclude Include="industrymgr.h" />
|
||||
<ClInclude Include="input.h" />
|
||||
<ClInclude Include="intro.h" />
|
||||
<ClInclude Include="localisation\stringmgr.h" />
|
||||
|
|
Loading…
Reference in New Issue