This allows a failed load to not clobber the currently-loaded save or scenario.
131 lines
3.5 KiB
C++
131 lines
3.5 KiB
C++
/*
|
|
* town.h
|
|
* BoE
|
|
*
|
|
* Created by Celtic Minsrel on 22/04/09.
|
|
*
|
|
*/
|
|
|
|
#ifndef BOE_DATA_TOWN_H
|
|
#define BOE_DATA_TOWN_H
|
|
|
|
#include <vector>
|
|
#include <iosfwd>
|
|
#include <array>
|
|
#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<mon_num_t,4> 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<cWandering,4> wandering;
|
|
std::array<location, 4> wandering_locs;
|
|
std::vector<spec_loc_t> special_locs;
|
|
std::vector<sign_loc_t> sign_locs;
|
|
eLighting lighting_type;
|
|
std::array<location, 4> start_locs;
|
|
std::array<spec_loc_t, 4> exits;
|
|
rectangle in_town_rect;
|
|
std::vector<cItem> preset_items;
|
|
std::vector<cTownperson> creatures;
|
|
long max_num_monst;
|
|
std::vector<cField> preset_fields;
|
|
short spec_on_entry,spec_on_entry_if_dead;
|
|
short spec_on_hostile;
|
|
std::array<cTimer,8> timers;
|
|
std::vector<cSpecial> 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<info_rect_t> room_rect;
|
|
std::array<std::string,3> comment;
|
|
std::vector<std::string> spec_strs;
|
|
cSpeech talking;
|
|
// Persistent data for saved games
|
|
std::array<std::bitset<64>, 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
|