Files
oboe/osx/classes/town.h
Celtic Minstrel 4b96f579b7 Embark on an epic journey to make both the game and the two editors load the entire scenario into memory.
Some other tweaks and fixes got pulled in along the way.
Details:
- Improved const-correctness
- The scenario is now part of the universe, so now there's no global scenario object in the game or the PC editor. (Of course, the scenario editor has no universe, so it still has a global scenario object.)
- Towns and outdoors now store a reference to the scenario; the party, current town, and current outdoors store a reference to the universe. Altogether this means that the data module has no need for global scenario or universe objects.
- The fileio routines now take a scenario or universe reference as a parameter, so they don't need the global scenario or universe objects either.
- cCurOut now has an arrow operator for accessing the current outdoor section, instead of a 2x2 subset of the outdoors; this replaces using i_w_c to index the 2x2 subset. (And it's much less verbose!)
- cCurTown no longer stores a pointer to the town record, since it can simply access it through the universe instance which it stores a reference to.
- Tweaked how the monster roster menu works (it now caches up to 60 monsters)
- The operator= functions that convert from legacy to new scenario/save format are now ordinary functions rather than operators.
- The bizarre use of assigning a cCreature to itself to populate certain fields has been nuked.
- When at the corner of an outdoor sector, the scenario editor now shows the cornermost terrain in the diagonally adjacent sector.
- There was a missing check to prevent horses entering dangerous terrain (eg, swamp) while in town.
- Fix cancelling load party dialog causing a party to appear
2014-12-22 00:20:37 -05:00

139 lines
3.6 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.h"
#include "location.h"
#include "special.h"
#include "monster.h"
#include "talking.h"
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;
};
enum eLighting {
LIGHT_NORMAL = 0,
LIGHT_DARK = 1,
LIGHT_DRAINS = 2,
LIGHT_NONE = 3,
};
class cScenario;
class cTown { // formerly town_record_type
protected:
cScenario& scenario;
public:
// class cCreature { // formerly creature_start_type
// public:
// unsigned short number;
// unsigned char start_attitude;
// location start_loc;
// unsigned char mobile;
// unsigned char time_flag;
// unsigned char extra1,extra2;
// short spec1, spec2;
// char spec_enc_code,time_code;
// short monster_time,personality;
// short special_on_kill,facial_pic;
//
// cCreature& operator = (legacy::creature_start_type old);
// };
class cWandering { // formerly wandering_type
public:
m_num_t monst[4];
bool isNull();
cWandering& operator = (legacy::wandering_type old);
};
class cItem { // formerly preset_item_type
public:
location loc;
short code,ability;
unsigned char charges,always_there,property,contained;
cItem& operator = (legacy::preset_item_type old);
};
class cField { // formerly preset_field_type
public:
location loc;
short type;
cField& operator = (legacy::preset_field_type old);
};
short town_chop_time,town_chop_key;
cWandering wandering[4];
location wandering_locs[4];
location special_locs[50];
unsigned short spec_id[50];
location sign_locs[15];
eLighting lighting_type;
location start_locs[4];
location exit_locs[4];
short exit_specs[4];
rectangle in_town_rect;
cItem preset_items[64];
short max_num_monst;
std::vector<cField> preset_fields;
short spec_on_entry,spec_on_entry_if_dead;
short spec_on_hostile;
short timer_spec_times[8];
short timer_specs[8];
unsigned char strlens[180];
cSpecial specials[100];
//unsigned char specials1,specials2,res1,res2;
bool strong_barriers : 1;
bool defy_mapping : 1;
bool defy_scrying : 1;
char reserved_bits : 5;
short hostile_fry_party; // number of a special to be called when the town goes hostile TODO: Not sure about this yet though
short difficulty;
//char town_strs[180][256];
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::array<std::string,16> rect_names;
std::array<std::string,3> comment;
std::array<std::string,100> spec_strs;
std::array<std::string,20> sign_strs;
cSpeech talking;
virtual ~cTown(){}
virtual void append(legacy::big_tr_type& old, int town_num);
virtual void append(legacy::ave_tr_type& old, int town_num);
virtual void append(legacy::tiny_tr_type& old, int town_num);
virtual ter_num_t& terrain(size_t x, size_t y) = 0;
virtual rectangle& room_rect(size_t i) = 0;
virtual cCreature& creatures(size_t i) = 0;
virtual unsigned char& lighting(size_t i, size_t r) = 0;
virtual short max_dim() const = 0;
virtual short max_monst() const = 0;
virtual short max_items() const = 0;
void set_up_lights();
short light_obscurity(short x,short y); // Obscurity function used for calculating lighting
explicit cTown(cScenario& scenario, bool init_strings = false);
void append(legacy::town_record_type& old);
virtual void writeTerrainTo(std::ostream& file) = 0;
virtual void readTerrainFrom(std::istream& file) = 0;
};
#endif