Skip to content

Commit

Permalink
MapEventCache: Made some methods & parameters const
Browse files Browse the repository at this point in the history
  • Loading branch information
florianessl committed Jun 7, 2024
1 parent 85458f4 commit 5a55054
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/game_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ namespace Game_Map {
namespace Caching {
class MapEventCache {
public:
void AddEvent(lcf::rpg::Event& ev);
void AddEvent(lcf::rpg::Event const& ev);

private:
std::vector<int> event_ids;
Expand All @@ -710,10 +710,10 @@ namespace Game_Map {
class MapCache {
public:
template <ObservervedVarOps Op>
void AddEventAsRefreshTarget(int var_id, lcf::rpg::Event& ev);
void AddEventAsRefreshTarget(int var_id, lcf::rpg::Event const& ev);

template <ObservervedVarOps Op>
bool GetNeedRefresh(int var_id);
bool GetNeedRefresh(int var_id) const;

void Clear();
private:
Expand Down Expand Up @@ -878,7 +878,7 @@ inline bool MapUpdateAsyncContext::IsActive() const {
return GetAsyncOp().IsActive();
}

inline void Game_Map::Caching::MapEventCache::AddEvent(lcf::rpg::Event& ev) {
inline void Game_Map::Caching::MapEventCache::AddEvent(lcf::rpg::Event const& ev) {
auto id = ev.ID;

if (std::find(event_ids.begin(), event_ids.end(), id) == event_ids.end()) {
Expand All @@ -887,15 +887,15 @@ inline void Game_Map::Caching::MapEventCache::AddEvent(lcf::rpg::Event& ev) {
}

template <Game_Map::Caching::ObservervedVarOps Op>
inline void Game_Map::Caching::MapCache::AddEventAsRefreshTarget(int var_id, lcf::rpg::Event& ev) {
inline void Game_Map::Caching::MapCache::AddEventAsRefreshTarget(int var_id, lcf::rpg::Event const& ev) {
static_assert(static_cast<int>(Op) >= 0 && Op < ObservervedVarOps_END);

auto& events_cache = refresh_targets_by_varid[static_cast<int>(Op)];
events_cache[var_id].AddEvent(ev);
}

template <Game_Map::Caching::ObservervedVarOps Op>
inline bool Game_Map::Caching::MapCache::GetNeedRefresh(int var_id) {
inline bool Game_Map::Caching::MapCache::GetNeedRefresh(int var_id) const {
static_assert(static_cast<int>(Op) >= 0 && Op < ObservervedVarOps_END);

auto& events_cache = refresh_targets_by_varid[static_cast<int>(Op)];
Expand Down

0 comments on commit 5a55054

Please sign in to comment.