From d7212d755dca7f4fd99cf4b775cd0d372d7bcbb2 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 5 May 2023 16:35:09 -0400 Subject: Refactored away singletons (Except TrackerConfig, for now at least) --- src/game_data.h | 59 +++++++++------------------------------------------------ 1 file changed, 9 insertions(+), 50 deletions(-) (limited to 'src/game_data.h') diff --git a/src/game_data.h b/src/game_data.h index 0cc7a7b..75eede3 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -81,55 +81,14 @@ struct MapArea { int map_y; }; -class GameData { - public: - GameData(); - - const std::vector& GetMapAreas() const { return map_areas_; } - - const MapArea& GetMapArea(int id) const { return map_areas_.at(id); } - - int GetRoomByName(const std::string& name) const { - return room_by_id_.at(name); - } - - const Room& GetRoom(int room_id) const { return rooms_.at(room_id); } - - const std::vector& GetDoors() const { return doors_; } - - const Door& GetDoor(int door_id) const { return doors_.at(door_id); } - - const Panel& GetPanel(int panel_id) const { return panels_.at(panel_id); } - - int GetRoomForPainting(const std::string& painting_id) const { - return room_by_painting_.at(painting_id); - } - - const std::vector& GetAchievementPanels() const { - return achievement_panels_; - } - - private: - int AddOrGetRoom(std::string room); - int AddOrGetDoor(std::string room, std::string door); - int AddOrGetPanel(std::string room, std::string panel); - int AddOrGetArea(std::string area); - - std::vector rooms_; - std::vector doors_; - std::vector panels_; - std::vector map_areas_; - - std::map room_by_id_; - std::map door_by_id_; - std::map panel_by_id_; - std::map area_by_id_; - - std::map room_by_painting_; - - std::vector achievement_panels_; -}; - -const GameData& GetGameData(); +const std::vector& GD_GetMapAreas(); +const MapArea& GD_GetMapArea(int id); +int GD_GetRoomByName(const std::string& name); +const Room& GD_GetRoom(int room_id); +const std::vector& GD_GetDoors(); +const Door& GD_GetDoor(int door_id); +const Panel& GD_GetPanel(int panel_id); +int GD_GetRoomForPainting(const std::string& painting_id); +const std::vector& GD_GetAchievementPanels(); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ -- cgit 1.4.1