/* * town.h * BoE * * Created by Celtic Minsrel on 22/04/09. * */ #ifndef BOE_DATA_TOWN_H #define BOE_DATA_TOWN_H #include #include #include #include "simpletypes.hpp" #include "location.hpp" #include "special.hpp" #include "monster.hpp" #include "talking.hpp" #include "item.hpp" namespace legacy { struct town_record_type; struct big_tr_type; struct ave_tr_type; struct tiny_tr_type; struct creature_start_type; struct wandering_type; struct preset_item_type; struct preset_field_type; }; class cScenario; class cTown { // formerly town_record_type protected: cScenario* scenario; public: class cWandering { // formerly wandering_type public: std::array monst; bool isNull(); void import_legacy(legacy::wandering_type old); }; class cItem { // formerly preset_item_type public: location loc; short code,ability; int charges = -1; bool always_there = false, property = false, contained = false; void import_legacy(legacy::preset_item_type old); cItem(); cItem(location loc, short num, ::cItem& item); }; class cField { // formerly preset_field_type public: location loc; eFieldType type; void import_legacy(legacy::preset_field_type old); cField() : type(FIELD_DISPEL) {} cField(location l, eFieldType t) : loc(l), type(t) {} }; short town_chop_time,town_chop_key; int bg_town, bg_fight; std::array wandering; std::array wandering_locs; std::vector special_locs; std::vector sign_locs; eLighting lighting_type; std::array start_locs; std::array exits; rectangle in_town_rect; std::vector preset_items; std::vector creatures; long max_num_monst; std::vector preset_fields; short spec_on_entry,spec_on_entry_if_dead; short spec_on_hostile; std::array timers; std::vector specials; bool strong_barriers, defy_mapping, defy_scrying; bool is_hidden, has_tavern; short difficulty; std::string town_name; // Using std::array here so we can have .size() // This'll make the transition smoother once it becomes a vector. std::vector room_rect; std::array comment; std::vector spec_strs; cSpeech talking; // Persistent data for saved games std::array, 64> maps; std::bitset<64> item_taken; bool can_find; long m_killed; virtual ~cTown(){} virtual void import_legacy(legacy::big_tr_type& old, int town_num); virtual void import_legacy(legacy::ave_tr_type& old, int town_num); virtual void import_legacy(legacy::tiny_tr_type& old, int town_num); virtual ter_num_t& terrain(size_t x, size_t y) = 0; virtual unsigned char& lighting(size_t i, size_t r) = 0; virtual size_t max_dim() const = 0; virtual bool is_templated() const {return false;} void init_start(); void set_up_lights(); short light_obscurity(short x,short y); // Obscurity function used for calculating lighting bool is_cleaned_out(); explicit cTown(cScenario& scenario); void import_legacy(legacy::town_record_type& old); void reattach(cScenario& to); virtual void writeTerrainTo(std::ostream& file) = 0; virtual void readTerrainFrom(std::istream& file) = 0; virtual cTown* clone() = 0; // Copy-and-swap // However, it's protected so that it can only be used by the clone implementations protected: virtual void swap(cTown& other); cTown(const cTown& other); cTown(cTown&& other); }; std::ostream& operator<< (std::ostream& out, eLighting light); std::istream& operator>> (std::istream& in, eLighting& light); #endif