Rewrite automatic trim placement to use the generalized attributes of the terrain spaces

This commit is contained in:
2015-02-02 11:35:18 -05:00
parent e70715874a
commit b11e934162
8 changed files with 156 additions and 1075 deletions

View File

@@ -761,17 +761,6 @@ bool is_nature(short x, short y, unsigned short ground_t) {
return ground_t == univ.scenario.ter_types[ter_type].ground_type; return ground_t == univ.scenario.ter_types[ter_type].ground_type;
} }
ter_num_t get_ground_from_ter(ter_num_t ter){
return get_ter_from_ground(univ.scenario.ter_types[ter].ground_type);
}
ter_num_t get_ter_from_ground(unsigned char ground){
for(int i = 0; i < 256; i++)
if(univ.scenario.ter_types[i].ground_type == ground)
return i;
return 0;
}
std::vector<location> forcecage_locs; std::vector<location> forcecage_locs;
//mode ... if 1, don't place on screen after redoing //mode ... if 1, don't place on screen after redoing
@@ -904,7 +893,7 @@ void draw_terrain(short mode) {
if(trim == eTrimType::WALKWAY){ if(trim == eTrimType::WALKWAY){
int trim = -1; int trim = -1;
unsigned short ground_t = univ.scenario.ter_types[spec_terrain].trim_ter; unsigned short ground_t = univ.scenario.ter_types[spec_terrain].trim_ter;
ter_num_t ground_ter = get_ter_from_ground(ground_t); ter_num_t ground_ter = univ.scenario.get_ter_from_ground(ground_t);
if(!loc_off_act_area(where_draw)) { if(!loc_off_act_area(where_draw)) {
if(is_nature(where_draw.x - 1,where_draw.y,ground_t)){ // check left if(is_nature(where_draw.x - 1,where_draw.y,ground_t)){ // check left
if(is_nature(where_draw.x,where_draw.y - 1,ground_t)){ // check up if(is_nature(where_draw.x,where_draw.y - 1,ground_t)){ // check up
@@ -941,7 +930,7 @@ void draw_terrain(short mode) {
}else if(spec_terrain == 65535) { }else if(spec_terrain == 65535) {
draw_one_terrain_spot(q,r,-1); draw_one_terrain_spot(q,r,-1);
}else{ }else{
current_ground = get_ground_from_ter(spec_terrain); current_ground = univ.scenario.get_ground_from_ter(spec_terrain);
draw_one_terrain_spot(q,r,spec_terrain); draw_one_terrain_spot(q,r,spec_terrain);
} }
} }

View File

@@ -58,9 +58,6 @@ void put_dialog_graphic(short graphic_num,short spec_g,rectangle draw_rect);
void draw_startup_stats(); void draw_startup_stats();
void draw_trim(short q,short r,short which_trim,ter_num_t ground_ter); void draw_trim(short q,short r,short which_trim,ter_num_t ground_ter);
ter_num_t get_ground_from_ter(ter_num_t ter);
ter_num_t get_ter_from_ground(unsigned char ground);
void draw_startup_anim(bool advance); void draw_startup_anim(bool advance);
#endif #endif

View File

@@ -191,3 +191,27 @@ std::string cScenario::format_ed_version() {
std::string cScenario::format_scen_version() { std::string cScenario::format_scen_version() {
return format_version(format.ver); return format_version(format.ver);
} }
ter_num_t cScenario::get_ground_from_ter(ter_num_t ter){
return get_ter_from_ground(ter_types[ter].ground_type);
}
ter_num_t cScenario::get_ter_from_ground(unsigned short ground){
for(int i = 0; i < ter_types.size(); i++)
if(ter_types[i].ground_type == ground)
return i;
return 0;
}
ter_num_t cScenario::get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim) {
for(int i = 0; i < ter_types.size(); i++) {
if(ter_types[i].ground_type != ground)
continue;
if(ter_types[i].trim_ter != trim_g)
continue;
if(ter_types[i].trim_type != trim)
continue;
return i;
}
return 90;
}

View File

@@ -108,6 +108,10 @@ public:
std::string format_scen_version(); std::string format_scen_version();
std::string format_ed_version(); std::string format_ed_version();
ter_num_t get_ground_from_ter(ter_num_t ter);
ter_num_t get_ter_from_ground(unsigned short ground);
ter_num_t get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim);
cScenario& operator=(cScenario&& other); cScenario& operator=(cScenario&& other);
cScenario(cScenario&) = delete; cScenario(cScenario&) = delete;
explicit cScenario(bool init_strings = false); explicit cScenario(bool init_strings = false);

View File

@@ -68,22 +68,22 @@ void cTerrain::append(legacy::terrain_type_type& old){
0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,0, 0,
2, 3, 4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, 0,
18,18,15,15,15,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,16,0, 16,16, 18,18,15,15,15,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,16,0, 16,16,
16,16,16,16,16,16,0, 0, 0, 0, 0, 0, 18,0, 0, 0, 18,18,18,18, 16,16,16,16,16,16,0, 0, 0, 0, 0, 0, 18,0, 0, 0, 18,18,18,18,
2, 4, 6, 8, 18,18,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18,18,18,18,18,18,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14,14,14,14,14,17,18,0, 0, 0, 0, 0, 0, 0, 14,14,14,14,14,17,18,0, 0, 0, 0, 0, 0, 0,
}; };
static const short trim_ters[274] = { static const short trim_ters[274] = {
99,99,99,99,99,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99,99, 99,99,99,99,99,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 99,99,1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 99,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99,
99,1, 99,1, 1, 99,1, 99,99,99, 99,99,99,99,99,99,99,99,99,99, 99,1, 99,1, 1, 99,1, 99,99,99, 99,99,99,99,99,99,99,99,99,99,
99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,
99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,
@@ -115,7 +115,7 @@ void cTerrain::append(legacy::terrain_type_type& old){
trim_type = eTrimType::NONE; trim_type = eTrimType::NONE;
trim_ter = 0; trim_ter = 0;
} }
if(trim_ter == 99) trim_ter = 0; if(trim_ter == 99) trim_ter = -1;
flag1 = old.flag1; flag1 = old.flag1;
flag2 = old.flag2; flag2 = old.flag2;
switch(old.special){ switch(old.special){

View File

@@ -38,7 +38,7 @@ public:
unsigned int obj_num = 0; // ditto (formerly res1) unsigned int obj_num = 0; // ditto (formerly res1)
unsigned int ground_type; // ditto (formerly res2) unsigned int ground_type; // ditto (formerly res2)
eTrimType trim_type; // ditto, mostly (formerly res3) eTrimType trim_type; // ditto, mostly (formerly res3)
unsigned short trim_ter; // ditto long trim_ter; // ditto
unsigned short combat_arena; unsigned short combat_arena;
location obj_pos; // editor use only location obj_pos; // editor use only
location obj_size; // editor use only location obj_size; // editor use only

File diff suppressed because it is too large Load Diff

View File

@@ -10,29 +10,12 @@ void get_town_info();
void get_sign_resource(); void get_sign_resource();
void set_info_strings(); void set_info_strings();
cTown::cItem edit_item(cTown::cItem item); cTown::cItem edit_item(cTown::cItem item);
bool is_wall(short i,short j);
bool is_correctable_wall(short i,short j);
bool is_mountain(short i,short j);
bool is_hill(short i,short j);
bool is_hill_or_mountain(short i,short j);
bool is_water(short i,short j);
bool is_correctable_water(short i,short j);
void shy_change_circle_terrain(location center,short radius,ter_num_t terrain_type,short probability); void shy_change_circle_terrain(location center,short radius,ter_num_t terrain_type,short probability);
void change_circle_terrain(location center,short radius,ter_num_t terrain_type,short probability); void change_circle_terrain(location center,short radius,ter_num_t terrain_type,short probability);
void change_rect_terrain(rectangle r,ter_num_t terrain_type,short probability,bool hollow); void change_rect_terrain(rectangle r,ter_num_t terrain_type,short probability,bool hollow);
void frill_up_terrain(); void frill_up_terrain();
void unfrill_terrain(); void unfrill_terrain();
void set_terrain(location l,ter_num_t terrain_type); void set_terrain(location l,ter_num_t terrain_type);
bool fix_rubble(location l);
bool fix_cave(location l);
bool fix_mountain(location l);
bool fix_hill(location l);
bool fix_water(location l);
bool out_fix_rubble(location l);
bool out_fix_cave(location l);
bool out_fix_mountain(location l);
bool out_fix_hill(location l);
bool out_fix_water(location l);
void adjust_space(location l); void adjust_space(location l);
bool is_lava(short x,short y); bool is_lava(short x,short y);
ter_num_t coord_to_ter(short x,short y); ter_num_t coord_to_ter(short x,short y);
@@ -51,7 +34,6 @@ void start_string_editing(short mode,short just_redo_text);
void start_special_editing(short mode,short just_redo_text); void start_special_editing(short mode,short just_redo_text);
void town_entry(location spot_hit); void town_entry(location spot_hit);
void start_dialogue_editing(short restoring); void start_dialogue_editing(short restoring);
bool is_erasable_water(short i,short j);
void update_mouse_spot(location the_point); void update_mouse_spot(location the_point);
bool monst_on_space(location loc,short m_num); bool monst_on_space(location loc,short m_num);