Preset town fields now use the field type enum

This commit is contained in:
2014-12-22 22:45:27 -05:00
parent c768b2557c
commit fb1f97e2f1
8 changed files with 91 additions and 165 deletions

View File

@@ -19,7 +19,7 @@
void cTinyTown::append(legacy::tiny_tr_type& old, int town_num){
int i,j;
cField the_field;
the_field.type = 2;
the_field.type = SPECIAL_SPOT;
// Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat.
std::vector<int> unused_special_slots;
for(i = 0; i < 100; i++) {
@@ -83,7 +83,7 @@ void cTinyTown::append(legacy::tiny_tr_type& old, int town_num){
void cMedTown::append(legacy::ave_tr_type& old, int town_num){
int i,j;
cField the_field;
the_field.type = 2;
the_field.type = SPECIAL_SPOT;
// Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat.
std::vector<int> unused_special_slots;
for(i = 0; i < 100; i++) {
@@ -147,7 +147,7 @@ void cMedTown::append(legacy::ave_tr_type& old, int town_num){
void cBigTown::append(legacy::big_tr_type& old, int town_numo){
int i,j;
cField the_field;
the_field.type = 2;
the_field.type = SPECIAL_SPOT;
// Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat.
std::vector<int> unused_special_slots;
for(i = 0; i < 100; i++) {

View File

@@ -119,8 +119,6 @@ cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) {
for(i = 0; i < 64; i++)
preset_items[i] = null_item;
max_num_monst = 30000;
// for(i = 0; i < 50; i++)
// preset_fields[i].type = 0;
spec_on_entry = -1;
spec_on_entry_if_dead = -1;
for(i = 0; i < 15; i++) {
@@ -198,7 +196,22 @@ void cTown::cItem::append(legacy::preset_item_type old){
void cTown::cField::append(legacy::preset_field_type old){
loc.x = old.field_loc.x;
loc.y = old.field_loc.y;
type = old.field_type;
switch(old.field_type) {
case 3: type = FIELD_WEB; break;
case 4: type = OBJECT_CRATE; break;
case 5: type = OBJECT_BARREL; break;
case 6: type = BARRIER_FIRE; break;
case 7: type = BARRIER_FORCE; break;
case 8: type = FIELD_QUICKFIRE; break;
case 14: type = SFX_SMALL_BLOOD; break;
case 15: type = SFX_MEDIUM_BLOOD; break;
case 16: type = SFX_LARGE_BLOOD; break;
case 17: type = SFX_SMALL_SLIME; break;
case 18: type = SFX_LARGE_SLIME; break;
case 19: type = SFX_ASH; break;
case 20: type = SFX_BONES; break;
case 21: type = SFX_RUBBLE; break;
}
}
bool cTown::cWandering::isNull(){

View File

@@ -75,9 +75,10 @@ public:
class cField { // formerly preset_field_type
public:
location loc;
short type;
eFieldType type;
void append(legacy::preset_field_type old);
cField() : type(FIELD_DISPEL) {}
};
short town_chop_time,town_chop_key;
cWandering wandering[4];

View File

@@ -99,52 +99,55 @@ void cCurTown::place_preset_fields() {
}
for(size_t i = 0; i < record()->preset_fields.size(); i++) {
switch(record()->preset_fields[i].type){
case 1: // currently unused
case OBJECT_BLOCK:
univ.town.set_block(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 2:
case SPECIAL_SPOT:
set_spot(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 3:
case FIELD_WEB:
set_web(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 4:
case OBJECT_CRATE:
set_crate(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 5:
case OBJECT_BARREL:
set_barrel(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 6:
case BARRIER_FIRE:
set_fire_barr(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 7:
case BARRIER_FORCE:
set_force_barr(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 8:
case BARRIER_CAGE:
set_force_cage(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case FIELD_QUICKFIRE:
set_quickfire(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 14:
case SFX_SMALL_BLOOD:
set_sm_blood(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 15:
case SFX_MEDIUM_BLOOD:
set_med_blood(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 16:
case SFX_LARGE_BLOOD:
set_lg_blood(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 17:
case SFX_SMALL_SLIME:
set_sm_slime(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 18:
case SFX_LARGE_SLIME:
set_lg_slime(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 19:
case SFX_ASH:
set_ash(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 20:
case SFX_BONES:
set_bones(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
case 21:
case SFX_RUBBLE:
set_rubble(record()->preset_fields[i].loc.x,record()->preset_fields[i].loc.y,true);
break;
}

View File

@@ -692,27 +692,35 @@ bool handle_action(location the_point,sf::Event /*event*/) {
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_WEB:
make_web(spot_hit.x,spot_hit.y);
make_field_type(spot_hit.x,spot_hit.y,FIELD_WEB);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_CRATE:
make_crate(spot_hit.x,spot_hit.y);
make_field_type(spot_hit.x,spot_hit.y,OBJECT_CRATE);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_BARREL:
make_barrel(spot_hit.x,spot_hit.y);
make_field_type(spot_hit.x,spot_hit.y,OBJECT_BARREL);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_FIRE_BARRIER:
make_fire_barrier(spot_hit.x,spot_hit.y);
make_field_type(spot_hit.x,spot_hit.y,BARRIER_FIRE);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_FORCE_BARRIER:
make_force_barrier(spot_hit.x,spot_hit.y);
make_field_type(spot_hit.x,spot_hit.y,BARRIER_FORCE);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_QUICKFIRE:
make_quickfire(spot_hit.x,spot_hit.y);
make_field_type(spot_hit.x,spot_hit.y,FIELD_QUICKFIRE);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_STONE_BLOCK:
make_field_type(spot_hit.x,spot_hit.y,OBJECT_BLOCK);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_FORCECAGE:
make_field_type(spot_hit.x,spot_hit.y,BARRIER_CAGE);
overall_mode = MODE_DRAWING;
break;
case MODE_TOGGLE_SPECIAL_DOT:
@@ -721,24 +729,17 @@ bool handle_action(location the_point,sf::Event /*event*/) {
overall_mode = MODE_DRAWING;
break;
}
make_field_type(spot_hit.x, spot_hit.y, 2);
make_field_type(spot_hit.x, spot_hit.y, SPECIAL_SPOT);
overall_mode = MODE_DRAWING;
break;
case MODE_CLEAR_FIELDS:
take_quickfire(spot_hit.x,spot_hit.y);
take_force_barrier(spot_hit.x,spot_hit.y);
take_fire_barrier(spot_hit.x,spot_hit.y);
take_barrel(spot_hit.x,spot_hit.y);
take_crate(spot_hit.x,spot_hit.y);
take_web(spot_hit.x,spot_hit.y);
take_field_type(spot_hit.x, spot_hit.y, 2);
for(i = 0; i < 8; i++)
take_sfx(spot_hit.x,spot_hit.y,i);
for(int i = 8; i <= BARRIER_CAGE; i++)
take_field_type(spot_hit.x,spot_hit.y, eFieldType(i));
set_cursor(wand_curs);
overall_mode = MODE_DRAWING;
break;
case MODE_PLACE_SFX:
make_sfx(spot_hit.x,spot_hit.y,mode_count);
make_field_type(spot_hit.x,spot_hit.y,eFieldType(SFX_SMALL_BLOOD + mode_count));
overall_mode = MODE_DRAWING;
break;
case MODE_EYEDROPPER:
@@ -916,8 +917,6 @@ bool handle_action(location the_point,sf::Event /*event*/) {
break;
case MODE_SET_TOWN_START: // TODO: Implement this
break;
case MODE_PLACE_STONE_BLOCK: // TODO: Implement this
break;
case MODE_INTRO_SCREEN:
case MODE_EDIT_TYPES:
case MODE_MAIN_SCREEN:

View File

@@ -41,6 +41,7 @@ enum eScenMode {
MODE_PLACE_EAST_ENTRANCE = 11,
MODE_PLACE_SOUTH_ENTRANCE = 12,
MODE_PLACE_WEST_ENTRANCE = 13,
MODE_PLACE_FORCECAGE = 19,
MODE_PLACE_WEB = 20,
MODE_PLACE_CRATE = 21,
MODE_PLACE_BARREL = 22,
@@ -48,7 +49,7 @@ enum eScenMode {
MODE_PLACE_FORCE_BARRIER = 24,
MODE_PLACE_QUICKFIRE = 25,
MODE_CLEAR_FIELDS = 26,
MODE_PLACE_STONE_BLOCK = 27, // unused; for something I'd like to add
MODE_PLACE_STONE_BLOCK = 27,
MODE_PLACE_CREATURE = 28,
MODE_LARGE_PAINTBRUSH = 29, // uncertain
MODE_SMALL_PAINTBRUSH = 30, // uncertain

View File

@@ -742,35 +742,45 @@ void draw_terrain(){
tiny_to.offset(0,-7);
i = 4;
}
if(is_web(cen_x + q - 4,cen_y + r - 4)) {
if(is_field_type(cen_x + q - 4,cen_y + r - 4, FIELD_WEB)) {
from_rect = calc_rect(5,0);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
if(is_crate(cen_x + q - 4,cen_y + r - 4)) {
if(is_field_type(cen_x + q - 4,cen_y + r - 4, OBJECT_CRATE)) {
from_rect = calc_rect(6,0);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
if(is_barrel(cen_x + q - 4,cen_y + r - 4)) {
if(is_field_type(cen_x + q - 4,cen_y + r - 4, OBJECT_BARREL)) {
from_rect = calc_rect(7,0);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
if(is_fire_barrier(cen_x + q - 4,cen_y + r - 4)) {
from_rect = calc_rect(0,2);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
if(is_field_type(cen_x + q - 4,cen_y + r - 4, BARRIER_FIRE)) {
from_rect = calc_rect(8,4);
Draw_Some_Item(anim_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
if(is_quickfire(cen_x + q - 4,cen_y + r - 4)) {
if(is_field_type(cen_x + q - 4,cen_y + r - 4, FIELD_QUICKFIRE)) {
from_rect = calc_rect(7,1);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
if(is_force_barrier(cen_x + q - 4,cen_y + r - 4)) {
from_rect = calc_rect(2,2);
if(is_field_type(cen_x + q - 4,cen_y + r - 4, BARRIER_FORCE)) {
from_rect = calc_rect(10,4);
Draw_Some_Item(anim_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
if(is_field_type(cen_x + q - 4,cen_y + r - 4, OBJECT_BLOCK)) {
from_rect = calc_rect(3,0);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
for(i = 0; i < 8; i++)
if(is_sfx(cen_x + q - 4,cen_y + r - 4,i)) {
if(is_field_type(cen_x + q - 4,cen_y + r - 4, BARRIER_CAGE)) {
from_rect = calc_rect(0,0);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
for(i = 0; i < 8; i++) {
eFieldType sfx = eFieldType(SFX_SMALL_BLOOD + i);
if(is_field_type(cen_x + q - 4,cen_y + r - 4,sfx)) {
from_rect = calc_rect(i,3);
Draw_Some_Item(fields_gworld,from_rect,ter_draw_gworld,where_draw,sf::BlendAlpha);
}
}
for(x = 0; x < town->max_items(); x++)
if((cen_x + q - 4 == town->preset_items[x].loc.x) &&
(cen_y + r - 4 == town->preset_items[x].loc.y) && (town->preset_items[x].code >= 0)) {
@@ -1290,23 +1300,17 @@ bool is_special(short i,short j) {
return false;
}
void take_special(short /*i*/,short /*j*/) {
}
void make_special(short /*i*/,short /*j*/) {
}
void sort_specials() {
}
bool is_spot(short i,short j){
if(editing_town)
return is_field_type(i,j,2);
return is_field_type(i,j,SPECIAL_SPOT);
else return current_terrain->special_spot[i][j];
return false;
}
bool is_field_type(short i,short j,short field_type) {
bool is_field_type(short i,short j,eFieldType field_type) {
unsigned short k;
for(k = 0; k < town->preset_fields.size(); k++)
@@ -1317,7 +1321,7 @@ bool is_field_type(short i,short j,short field_type) {
return false;
}
void make_field_type(short i,short j,short field_type) {
void make_field_type(short i,short j,eFieldType field_type) {
unsigned short k;
if(is_field_type(i,j,field_type))
@@ -1338,100 +1342,26 @@ void make_field_type(short i,short j,short field_type) {
}
void take_field_type(short i,short j,short field_type) {
void take_field_type(short i,short j,eFieldType field_type) {
unsigned short k;
for(k = 0; k < town->preset_fields.size(); k++)
if((town->preset_fields[k].type == field_type) &&
(town->preset_fields[k].loc.x == i) &&
(town->preset_fields[k].loc.y == j)) {
town->preset_fields[k].type = 0;
town->preset_fields[k].type = FIELD_DISPEL;
return;
}
}
bool is_web(short i,short j) {
return is_field_type(i,j,3);
}
void make_web(short i,short j) {
make_field_type(i,j,3);
}
void take_web(short i,short j) {
take_field_type(i,j,3);
}
bool is_crate(short i,short j) {
return is_field_type(i,j,4);
}
void make_crate(short i,short j) {
make_field_type(i,j,4);
}
void take_crate(short i,short j) {
take_field_type(i,j,4);
}
bool is_barrel(short i,short j) {
return is_field_type(i,j,5);
}
void make_barrel(short i,short j) {
make_field_type(i,j,5);
}
void take_barrel(short i,short j) {
take_field_type(i,j,5);
}
bool is_fire_barrier(short i,short j) {
return is_field_type(i,j,6);
}
void make_fire_barrier(short i,short j) {
make_field_type(i,j,6);
}
void take_fire_barrier(short i,short j) {
take_field_type(i,j,6);
}
bool is_force_barrier(short i,short j) {
return is_field_type(i,j,7);
}
void make_force_barrier(short i,short j) {
make_field_type(i,j,7);
}
void take_force_barrier(short i,short j) {
take_field_type(i,j,7);
}
bool is_sfx(short i,short j,short type) {
return is_field_type(i,j,type + 14);
}
void make_sfx(short i,short j,short type) {
make_field_type(i,j,type + 14);
}
void take_sfx(short i,short j,short type) {
take_field_type(i,j,type + 14);
}
bool is_quickfire(short i,short j) {
return is_field_type(i,j,8);
}
void make_quickfire(short i,short j) {
make_field_type(i,j,8);
}
void take_quickfire(short i,short j) {
take_field_type(i,j,8);
}
bool container_there(location l) {
if(!editing_town)
return false;
if(scenario.ter_types[town->terrain(l.x,l.y)].special == eTerSpec::IS_A_CONTAINER)
return true;
if(is_barrel(l.x,l.y))
if(is_field_type(l.x,l.y, OBJECT_BARREL))
return true;
if(is_crate(l.x,l.y))
if(is_field_type(l.x,l.y, OBJECT_CRATE))
return true;
return 0;
}

View File

@@ -26,30 +26,9 @@ bool is_special(short i,short j);
void take_special(short i,short j);
void make_special(short i,short j);
void sort_specials();
bool is_field_type(short i,short j,short field_type);
void make_field_type(short i,short j,short field_type);
void take_field_type(short i,short j,short field_type);
bool is_web(short i,short j);
void make_web(short i,short j);
void take_web(short i,short j);
bool is_crate(short i,short j);
void make_crate(short i,short j);
void take_crate(short i,short j);
bool is_barrel(short i,short j);
void make_barrel(short i,short j);
void take_barrel(short i,short j);
bool is_fire_barrier(short i,short j);
void make_fire_barrier(short i,short j);
void take_fire_barrier(short i,short j);
bool is_force_barrier(short i,short j);
void make_force_barrier(short i,short j);
void take_force_barrier(short i,short j);
bool is_sfx(short i,short j,short type);
void make_sfx(short i,short j,short type);
void take_sfx(short i,short j,short type);
bool is_quickfire(short i,short j);
void make_quickfire(short i,short j);
void take_quickfire(short i,short j);
bool is_field_type(short i,short j,eFieldType field_type);
void make_field_type(short i,short j,eFieldType field_type);
void take_field_type(short i,short j,eFieldType field_type);
bool container_there(location l);
bool is_spot(short i,short j);
//void get_str(const char* str,short i, short j);