Strictify special node context enum

This commit is contained in:
2014-12-06 23:19:57 -05:00
parent bfdcfeab58
commit 5ec983ef32
10 changed files with 162 additions and 131 deletions

View File

@@ -695,7 +695,7 @@ bool handle_action(sf::Event event)
move_to_zero(univ.party[current_pc].status[eStatus::WEBS]);
put_pc_screen();
}
check_fields(pc_pos[current_pc],2,current_pc);
check_fields(pc_pos[current_pc],eSpecCtx::COMBAT_MOVE,current_pc);
}
else {
add_string_to_buf("Pause.");
@@ -722,7 +722,7 @@ bool handle_action(sf::Event event)
}
}
put_pc_screen();
check_fields(univ.town.p_loc,1,0);
check_fields(univ.town.p_loc,eSpecCtx::TOWN_MOVE,0);
}
did_something = true;
@@ -833,6 +833,8 @@ bool handle_action(sf::Event event)
if (adjacent(univ.town.p_loc,destination) == true)
if (adj_town_look(destination) == true)
need_redraw = true;
// TODO: This would be the place to call OUT_LOOK special
// (Adapt adj_town_look function for this purpose.)
if (is_sign(ter_looked_at)) {
print_buf();
need_reprint = false;
@@ -1289,6 +1291,7 @@ bool handle_action(sf::Event event)
}
// MARK: At this point, see if any specials have been queued up, and deal with them
// TODO: Use an std::queue for this.
for (i = 0; i < 20; i++)
if (special_queue[i].spec >= 0) {
long long store_time = univ.party.age;
@@ -2693,7 +2696,7 @@ bool outd_move_party(location destination,bool forced)
location store_corner,store_iwc;
ter_num_t ter;
keep_going = check_special_terrain(destination,0,0,&spec_num,&check_f);
keep_going = check_special_terrain(destination,eSpecCtx::OUT_MOVE,0,&spec_num,&check_f);
if (check_f == true)
forced = true;
if (in_scen_debug && ghost_mode)
@@ -2906,7 +2909,7 @@ bool town_move_party(location destination,short forced)////
*/
if (monst_there(destination) > univ.town->max_monst())
keep_going = check_special_terrain(destination,1,0,&spec_num,&check_f);
keep_going = check_special_terrain(destination,eSpecCtx::TOWN_MOVE,0,&spec_num,&check_f);
if (check_f == true)
forced = true;

View File

@@ -446,7 +446,7 @@ bool pc_combat_move(location destination) ////
short spec_num;
if (monst_there(destination) > univ.town->max_monst())
keep_going = check_special_terrain(destination,2,current_pc,&spec_num,&check_f);
keep_going = check_special_terrain(destination,eSpecCtx::COMBAT_MOVE,current_pc,&spec_num,&check_f);
if (check_f == true)
forced = true;
@@ -508,7 +508,7 @@ bool pc_combat_move(location destination) ////
pc_pos[switch_pc] = store_loc;
univ.party[current_pc].direction = dir;
take_ap(1);
check_special_terrain(store_loc,2,switch_pc,&spec_num,&check_f);
check_special_terrain(store_loc,eSpecCtx::COMBAT_MOVE,switch_pc,&spec_num,&check_f);
move_sound(combat_terrain[destination.x][destination.y],univ.party[current_pc].ap);
return true;
}

View File

@@ -954,7 +954,7 @@ void handle_talk_event(location p)
break;
// TODO: Strings resulting from this don't seem to be recordable; whyever not?
case 29: // town special
run_special(7,2,a,univ.town.p_loc,&s1,&s2,&s3);
run_special(eSpecCtx::TALK,2,a,univ.town.p_loc,&s1,&s2,&s3);
// check s1 & s2 to see if we got diff str, and, if so, munch old strs
if ((s1 >= 0) || (s2 >= 0)) {
strnum1 = -1;
@@ -969,7 +969,7 @@ void handle_talk_event(location p)
put_item_screen(stat_window,0);
break;
case 30: // scen special
run_special(7,0,a,univ.town.p_loc,&s1,&s2,&s3);
run_special(eSpecCtx::TALK,0,a,univ.town.p_loc,&s1,&s2,&s3);
// check s1 & s2 to see if we got diff str, and, if so, munch old strs
if ((s1 >= 0) || (s2 >= 0)) {
strnum1 = -1;

View File

@@ -328,7 +328,7 @@ void play_see_monster_str(unsigned short m){
for(int i = 2; i < 20; i++){
if(special_queue[i].spec == -1){
special_queue[i].spec = spec;
special_queue[i].mode = SPEC_SEE_MONST;
special_queue[i].mode = eSpecCtx::SEE_MONST;
special_queue[i].type = 0;
special_queue[i].trigger_time = univ.party.age;
special_queue[i].where = loc(); // TODO: Maybe a different location should be passed?

View File

@@ -1810,10 +1810,11 @@ void sanctify_space(location where)
{
short i,s1,s2,s3;
// TODO: Generalize this for other spells cast on the space
for (i = 0; i < 50; i++)
if (where == univ.town->special_locs[i]) {
if(univ.town->specials[univ.town->spec_id[i]].type == eSpecType::SANCTIFY)
run_special(16,2,univ.town->spec_id[i],where,&s1,&s2,&s3);
run_special(eSpecCtx::TARGET,2,univ.town->spec_id[i],where,&s1,&s2,&s3);
return;
}
add_string_to_buf(" Nothing happens.");

View File

@@ -123,27 +123,27 @@ bool handle_wandering_specials (short /*which*/,short mode)
// wanderin spec 99 -> generic spec
{
// TODO: Should a better location be passed to these specials?
short s1 = 0,s2 = 0,s3 = 0;
if ((mode == 0) && (store_wandering_special.spec_on_meet >= 0)) { // When encountering
run_special(13,1,store_wandering_special.spec_on_meet,loc(),&s1,&s2,&s3);
run_special(eSpecCtx::OUTDOOR_ENC,1,store_wandering_special.spec_on_meet,loc(),&s1,&s2,&s3);
if (s1 > 0)
return false;
}
if ((mode == 1) && (store_wandering_special.spec_on_win >= 0)) {// After defeating
run_special(15,1,store_wandering_special.spec_on_win,loc(),&s1,&s2,&s3);
run_special(eSpecCtx::WIN_ENCOUNTER,1,store_wandering_special.spec_on_win,loc(),&s1,&s2,&s3);
}
if ((mode == 2) && (store_wandering_special.spec_on_flee >= 0)) {// After fleeing like a buncha girly men
run_special(14,1,store_wandering_special.spec_on_flee,loc(),&s1,&s2,&s3);
run_special(eSpecCtx::FLEE_ENCOUNTER,1,store_wandering_special.spec_on_flee,loc(),&s1,&s2,&s3);
}
return true;
}
bool check_special_terrain(location where_check,short mode,short which_pc,short *spec_num,
bool check_special_terrain(location where_check,eSpecCtx mode,short which_pc,short *spec_num,
bool *forced)
//short mode; // 0 - out 1 - town 2 - combat
// returns true if can enter this space
// sets forced to true if definitely can enter
{
@@ -161,18 +161,23 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
*forced = false;
switch (mode) {
case 0:
case eSpecCtx::OUT_MOVE:
ter = univ.out[where_check.x][where_check.y];
from_loc = univ.party.p_loc;
break;
case 1:
case eSpecCtx::TOWN_MOVE:
ter = univ.town->terrain(where_check.x,where_check.y);
from_loc = univ.town.p_loc;
break;
case 2:
case eSpecCtx::COMBAT_MOVE:
ter = combat_terrain[where_check.x][where_check.y];
from_loc = pc_pos[current_pc];
break;
default:
// No movement happened, so just return false.
// TODO: Should there be an error message here?
printf("Note: Improper mode passed to check_special_terrain: %d\n", (int)mode);
return false;
}
ter_special = scenario.ter_types[ter].special;
ter_flag1 = scenario.ter_types[ter].flag1;
@@ -180,7 +185,8 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
ter_flag3 = scenario.ter_types[ter].flag3;
ter_pic = scenario.ter_types[ter].picture;
if(mode > 0 && ter_special == eTerSpec::CONVEYOR) {
// TODO: Why not support conveyors outdoors, too?
if(mode != eSpecCtx::OUT_MOVE && ter_special == eTerSpec::CONVEYOR) {
if (
((ter_flag3.u == DIR_N) && (where_check.y > from_loc.y)) ||
((ter_flag3.u == DIR_E) && (where_check.x < from_loc.x)) ||
@@ -191,7 +197,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
}
}
if (mode == 0) {
if(mode == eSpecCtx::OUT_MOVE) {
out_where = global_to_local(where_check);
for (i = 0; i < 18; i++)
@@ -216,7 +222,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
return false; // TODO: Maybe replace eTrimType::CITY check with a blockage == clear/special && is_special() check?
}
if (((mode == 1) || ((mode == 2) && (which_combat_type == 1)))
if((mode == eSpecCtx::TOWN_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 1))
&& (univ.town.is_special(where_check.x,where_check.y))) {
if (univ.town.is_force_barr(where_check.x,where_check.y)) {
add_string_to_buf(" Magic barrier! ");
@@ -248,7 +254,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
if (univ.town.is_web(where_check.x,where_check.y)) {
add_string_to_buf(" Webs! ");
if (mode < 2) {
if(mode != eSpecCtx::COMBAT_MOVE) {
suppress_stat_screen = true;
for (i = 0; i < 6; i++) {
r1 = get_ran(1,2,3);
@@ -300,7 +306,11 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
break;
case eTerSpec::DAMAGING:
//if the party is flying, in a boat, or entering a boat, they cannot be harmed by terrain
if (flying() || univ.party.in_boat >= 0 || (mode?town_boat_there(where_check):out_boat_there(where_check)) < 30)
if(flying() || univ.party.in_boat >= 0)
break;
if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check) < 30)
break;
if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check) < 30)
break;
if(ter_flag3.u > 0 && ter_flag3.u < 8)
dam_type = (eDamageType) ter_flag3.u;
@@ -341,21 +351,25 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
break;
}
if(r1 < 0) break; // "It doesn't affect you."
if (mode < 2)
if(mode != eSpecCtx::COMBAT_MOVE)
hit_party(r1,dam_type);
fast_bang = 1;
if (mode == 2)
if(mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,dam_type,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,pic_type,r1,12);
fast_bang = 0;
break;
case eTerSpec::DANGEROUS:
//if party is flying, in a boat, or entering a boat, they cannot receive statuses from terrain
if (flying() || univ.party.in_boat >= 0 || (mode?town_boat_there(where_check):out_boat_there(where_check)) < 30)
//if the party is flying, in a boat, or entering a boat, they cannot be harmed by terrain
if(flying() || univ.party.in_boat >= 0)
break;
if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check) < 30)
break;
if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check) < 30)
break;
//one_sound(17);
if (mode == 2) i = which_pc; else i = 0;
if(mode == eSpecCtx::COMBAT_MOVE) i = which_pc; else i = 0;
for ( ; i < 6; i++)
if(univ.party[i].main_status == eMainStatus::ALIVE) {
if (get_ran(1,1,100) <= ter_flag2.u) {
@@ -407,7 +421,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
case eStatus::MAIN: case eStatus::CHARM: // These magic values are illegal in this context
break;
}
if(mode == 2) break; // only damage once in combat!
if(mode == eSpecCtx::COMBAT_MOVE) break; // only damage once in combat!
}
}
//print_nums(1,which_pc,current_pc);
@@ -423,10 +437,12 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
{
short spec_type = 0;
if(ter_flag2.u == 3){
if(mode == 1 || (mode == 2 && which_combat_type == 1)) spec_type = 2; else spec_type = 1;
}else if(ter_flag2.u == 2 && (mode == 0 || (mode == 2 && which_combat_type == 0)))
if(mode == eSpecCtx::TOWN_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 1))
spec_type = 2;
else spec_type = 1;
}else if(ter_flag2.u == 2 && (mode == eSpecCtx::OUT_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 0)))
spec_type = 1;
else if(ter_flag2.u == 1 && (mode == 1 || (mode == 2 && which_combat_type == 1)))
else if(ter_flag2.u == 1 && (mode == eSpecCtx::TOWN_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 1)))
spec_type = 2;
run_special(mode,spec_type,ter_flag1.u,where_check,&s1,&s2,&s3);
if (s1 > 0)
@@ -472,11 +488,14 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
// This procedure find the effects of fields that would affect a PC who moves into
// a space or waited in that same space
void check_fields(location where_check,short mode,short which_pc)
//mode; // 0 - out 1 - town 2 - combat
void check_fields(location where_check,eSpecCtx mode,short which_pc)
{
short r1,i;
if(mode != eSpecCtx::COMBAT_MOVE && mode != eSpecCtx::TOWN_MOVE && mode != eSpecCtx::OUT_MOVE) {
printf("Note: Improper mode passed to check_fields: %d\n", (int)mode);
return;
}
if (is_out())
return;
if (is_town())
@@ -484,9 +503,10 @@ void check_fields(location where_check,short mode,short which_pc)
if (univ.town.is_fire_wall(where_check.x,where_check.y)) {
add_string_to_buf(" Fire wall! ");
r1 = get_ran(1,1,6) + 1;
// TODO: Is this commented code important?
// if (mode < 2)
// hit_party(r1,1);
if (mode == 2)
if (mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,DAMAGE_FIRE,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,0,r1,5);
@@ -496,7 +516,7 @@ void check_fields(location where_check,short mode,short which_pc)
r1 = get_ran(2,1,6);
// if (mode < 2)
// hit_party(r1,3);
if (mode == 2)
if (mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,DAMAGE_MAGIC,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,1,r1,12);
@@ -506,7 +526,7 @@ void check_fields(location where_check,short mode,short which_pc)
r1 = get_ran(2,1,6);
// if (mode < 2)
// hit_party(r1,5);
if (mode == 2)
if (mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,DAMAGE_COLD,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,4,r1,7);
@@ -516,7 +536,7 @@ void check_fields(location where_check,short mode,short which_pc)
r1 = get_ran(4,1,8);
// if (mode < 2)
// hit_party(r1,0);
if (mode == 2)
if (mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,DAMAGE_WEAPON,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,3,r1,2);
@@ -526,14 +546,14 @@ void check_fields(location where_check,short mode,short which_pc)
r1 = get_ran(2,1,8);
// if (mode < 2)
// hit_party(r1,1);
if (mode == 2)
if (mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,DAMAGE_FIRE,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,0,r1,5);
}
if (univ.town.is_scloud(where_check.x,where_check.y)) {
add_string_to_buf(" Stinking cloud! ");
if (mode < 2) {
if (mode != eSpecCtx::COMBAT_MOVE) {
suppress_stat_screen = true;
for (i = 0; i < 6; i++) {
r1 = get_ran(1,2,3);
@@ -546,7 +566,7 @@ void check_fields(location where_check,short mode,short which_pc)
}
if (univ.town.is_sleep_cloud(where_check.x,where_check.y)) {
add_string_to_buf(" Sleep cloud! ");
if (mode < 2) {
if (mode != eSpecCtx::COMBAT_MOVE) {
suppress_stat_screen = true;
for (i = 0; i < 6; i++) {
sleep_pc(i,3,eStatus::ASLEEP,0);
@@ -559,9 +579,9 @@ void check_fields(location where_check,short mode,short which_pc)
if (univ.town.is_fire_barr(where_check.x,where_check.y)) {
add_string_to_buf(" Magic barrier! ");
r1 = get_ran(2,1,10);
if (mode < 2)
if (mode != eSpecCtx::COMBAT_MOVE)
hit_party(r1,DAMAGE_MAGIC);
if (mode == 2)
if (mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,DAMAGE_MAGIC,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
boom_space(univ.party.p_loc,overall_mode,1,r1,12);
@@ -574,7 +594,7 @@ void use_spec_item(short item)
short i,j,k;
location null_loc;
run_special(8,0,scenario.special_items[item].special,loc(),&i,&j,&k);
run_special(eSpecCtx::USE_SPEC_ITEM,0,scenario.special_items[item].special,loc(),&i,&j,&k);
}
@@ -1244,7 +1264,7 @@ bool use_space(location where)
spec_type = 2;
else if(scenario.ter_types[ter].flag2.u == 2 && (is_out() || (is_combat() && which_combat_type == 1)))
spec_type = 1;
run_special(17,spec_type,scenario.ter_types[ter].flag1.u,where,&i,&i,&i);
run_special(eSpecCtx::USE_SPACE,spec_type,scenario.ter_types[ter].flag1.u,where,&i,&i,&i);
return true;
}
add_string_to_buf(" Nothing to use.");
@@ -1279,7 +1299,7 @@ bool adj_town_look(location where)
}
//call special can_open = town_specials(i,univ.town.town_num);
run_special(4,2,univ.town->spec_id[i],where,&s1,&s2,&s3);
run_special(eSpecCtx::TOWN_LOOK,2,univ.town->spec_id[i],where,&s1,&s2,&s3);
if (s1 > 0)
can_open = false;
got_special = true;
@@ -1650,9 +1670,9 @@ void kill_monst(cCreature *which_m,short who_killed)
if (sd_legit(which_m->spec1,which_m->spec2) == true)
PSD[which_m->spec1][which_m->spec2] = 1;
run_special(12,2,which_m->special_on_kill,which_m->cur_loc,&s1,&s2,&s3);
run_special(eSpecCtx::KILL_MONST,2,which_m->special_on_kill,which_m->cur_loc,&s1,&s2,&s3);
if (which_m->radiate_1 == 15)
run_special(12,0,which_m->radiate_2,which_m->cur_loc,&s1,&s2,&s3);
run_special(eSpecCtx::KILL_MONST,0,which_m->radiate_2,which_m->cur_loc,&s1,&s2,&s3);
if ((!in_scen_debug) && ((which_m->summoned >= 100) || (which_m->summoned == 0))) { // no xp for party-summoned monsters
xp = which_m->level * 2;
@@ -1848,7 +1868,7 @@ void special_increase_age()
for(i = 0; i < 8; i++)
if((univ.town->timer_spec_times[i] > 0) && (univ.party.age % univ.town->timer_spec_times[i] == 0)
&& ((is_town() == true) || ((is_combat() == true) && (which_combat_type == 1)))) {
run_special(9,2,univ.town->timer_specs[i],null_loc,&s1,&s2,&s3);
run_special(eSpecCtx::TOWN_TIMER,2,univ.town->timer_specs[i],null_loc,&s1,&s2,&s3);
stat_area = true;
if(s3 > 0)
redraw = true;
@@ -1856,7 +1876,7 @@ void special_increase_age()
}
for (i = 0; i < 20; i++)
if ((scenario.scenario_timer_times[i] > 0) && (univ.party.age % scenario.scenario_timer_times[i] == 0)) {
run_special(10,0,scenario.scenario_timer_specs[i],null_loc,&s1,&s2,&s3);
run_special(eSpecCtx::SCEN_TIMER,0,scenario.scenario_timer_specs[i],null_loc,&s1,&s2,&s3);
stat_area = true;
if (s3 > 0)
redraw = true;
@@ -1864,8 +1884,8 @@ void special_increase_age()
for (i = 0; i < univ.party.party_event_timers.size(); i++) {
if (univ.party.party_event_timers[i].time == 1) {
if (univ.party.party_event_timers[i].global_or_town == 0)
run_special(11,0,univ.party.party_event_timers[i].node_to_call,null_loc,&s1,&s2,&s3);
else run_special(11,2,univ.party.party_event_timers[i].node_to_call,null_loc,&s1,&s2,&s3);
run_special(eSpecCtx::PARTY_TIMER,0,univ.party.party_event_timers[i].node_to_call,null_loc,&s1,&s2,&s3);
else run_special(eSpecCtx::PARTY_TIMER,2,univ.party.party_event_timers[i].node_to_call,null_loc,&s1,&s2,&s3);
univ.party.party_event_timers[i].time = 0;
stat_area = true;
if (s3 > 0)
@@ -1902,12 +1922,12 @@ void special_increase_age()
// 15 - fleeing outdoor enc
// 16 - ritual of sanct TODO: This will become "target space", hopefully
// 17 - using space
// 18 - seeing monster TODO: This is currently unused
// 18 - seeing monster
// which_type - 0 - scen 1 - out 2 - town
// start spec - the number of the first spec to call
// a,b - 2 values that can be returned
// redraw - 1 if now need redraw
void run_special(short which_mode,short which_type,short start_spec,location spec_loc,short *a,short *b,short *redraw)
void run_special(eSpecCtx which_mode,short which_type,short start_spec,location spec_loc,short *a,short *b,short *redraw)
{
short cur_spec,cur_spec_type,next_spec,next_spec_type;
cSpecial cur_node;
@@ -2012,7 +2032,7 @@ cSpecial get_node(short cur_spec,short cur_spec_type)
}
// TODO: Make cur_spec_type an enum
void general_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw)
{
bool check_mess = false;
@@ -2051,31 +2071,31 @@ void general_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
check_mess = true;break;
case eSpecType::OUT_BLOCK:
if (is_out()) *next_spec = -1;
if ((is_out()) && (spec.ex1a != 0) && (which_mode == 0)) {
if ((is_out()) && (spec.ex1a != 0) && (which_mode == eSpecCtx::OUT_MOVE)) {
ASB("Can't go here while outdoors.");
*a = 1;
}
break;
case eSpecType::TOWN_BLOCK:
if (is_town()) *next_spec = -1;
if ((is_town()) && (spec.ex1a != 0) && (which_mode == 1)) {
if ((is_town()) && (spec.ex1a != 0) && (which_mode == eSpecCtx::TOWN_MOVE)) {
ASB("Can't go here while in town mode.");
*a = 1;
}
break;
case eSpecType::FIGHT_BLOCK:
if (is_combat()) *next_spec = -1;
if ((is_combat()) && (spec.ex1a != 0) && (which_mode == 2)) {
if ((is_combat()) && (spec.ex1a != 0) && (which_mode == eSpecCtx::COMBAT_MOVE)) {
ASB("Can't go here during combat.");
*a = 1;
}
break;
case eSpecType::LOOK_BLOCK:
if ((which_mode == 3) || (which_mode == 4)) *next_spec = -1;
if ((which_mode == eSpecCtx::OUT_LOOK) || (which_mode == eSpecCtx::TOWN_LOOK)) *next_spec = -1;
break;
case eSpecType::CANT_ENTER:
check_mess = true;
if (which_mode < 3) {
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE) {
if (spec.ex1a != 0)
*a = 1;
else *a = 0;
@@ -2150,7 +2170,8 @@ void general_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
else PSD[spec.sd1][spec.sd2] = PSD[spec.ex1a][spec.ex1b];
break;
case eSpecType::SANCTIFY:
if (which_mode != 16)
// TODO: Generalize this for other spell targeting
if(which_mode != eSpecCtx::TARGET)
*next_spec = spec.ex1b;
break;
case eSpecType::REST:
@@ -2160,7 +2181,7 @@ void general_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
restore_sp_party(spec.ex1b);
break;
case eSpecType::WANDERING_WILL_FIGHT:
if (which_mode != 13)
if(which_mode != eSpecCtx::OUTDOOR_ENC)
break;
*a = (spec.ex1a == 0) ? 1 : 0;
break;
@@ -2196,7 +2217,7 @@ void general_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
*/
// TODO: What was next_spec_type for? Is it still needed?
void oneshot_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short */*next_spec_type*/,short *a,short *b,short *redraw)
{
bool check_mess = true,set_sd = true;
@@ -2377,7 +2398,7 @@ void oneshot_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
}
// TODO: What was next_spec_type for? Is it still needed?
void affect_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short */*next_spec_type*/,short *a,short *b,short *redraw)
{
bool check_mess = true;
@@ -2613,7 +2634,7 @@ void affect_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
}
// TODO: What was next_spec_type for? Is it still needed?
void ifthen_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short */*next_spec_type*/,short *a,short *b,short *redraw)
{
bool check_mess = false;
@@ -2798,7 +2819,7 @@ void ifthen_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
}
// TODO: What was next_spec_type for? Is it still needed?
void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short */*next_spec_type*/,short *a,short *b,short *redraw)
{
static const char*const stairDlogs[8] = {
@@ -2859,27 +2880,27 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
case eSpecType::TOWN_MOVE_PARTY:
if (is_combat()) {
ASB("Not while in combat.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
}
else { // 1 no
*a = 1;
if ((which_mode == 7) || (spec.ex2a == 0))
if(which_mode == eSpecCtx::TALK || spec.ex2a == 0)
teleport_party(spec.ex1a,spec.ex1b,1);
else teleport_party(spec.ex1a,spec.ex1b,0);
}
*redraw = 1;
break;
case eSpecType::TOWN_HIT_SPACE:
if (which_mode == 7)
if(which_mode == eSpecCtx::TALK)
break;
hit_space(l,spec.ex2a,(eDamageType) spec.ex2b,1,1);
*redraw = 1;
break;
case eSpecType::TOWN_EXPLODE_SPACE:
if (which_mode == 7)
if(which_mode == eSpecCtx::TALK)
break;
radius_damage(l,spec.pic, spec.ex2a, (eDamageType) spec.ex2b);
*redraw = 1;
@@ -2897,7 +2918,7 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
*redraw = 1;
break;
case eSpecType::TOWN_SFX_BURST: // TODO: Add a "random offset" mode
if (which_mode == 7)
if(which_mode == eSpecCtx::TALK)
break;
run_a_boom(l,spec.ex2a,0,0);
break;
@@ -2929,7 +2950,8 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
*redraw = 1;
break;
case eSpecType::TOWN_GENERIC_LEVER:
if (which_mode > 4) {
if(which_mode != eSpecCtx::OUT_MOVE && which_mode != eSpecCtx::TOWN_MOVE && which_mode != eSpecCtx::COMBAT_MOVE
&& which_mode != eSpecCtx::OUT_LOOK && which_mode != eSpecCtx::TOWN_LOOK) {
ASB("Can't use lever now.");
check_mess = false;
*next_spec = -1;
@@ -2942,21 +2964,21 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
case eSpecType::TOWN_GENERIC_PORTAL:
if (is_combat()) {
ASB("Not while in combat.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
}
else if ((which_mode != 1) && (which_mode != 4)) {
else if(which_mode != eSpecCtx::TOWN_MOVE && which_mode != eSpecCtx::TOWN_LOOK) {
ASB("Can't teleport now.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
}
else if(cChoiceDlog("basic-portal.xml",{"yes","no"}).show() == "yes") {
*a = 1;
if ((which_mode == 7) || (spec.ex2a == 0))
if(which_mode == eSpecCtx::TALK || spec.ex2a == 0)
teleport_party(spec.ex1a,spec.ex1b,1);
else teleport_party(spec.ex1a,spec.ex1b,0);
}
@@ -2968,14 +2990,14 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
case eSpecType::TOWN_GENERIC_STAIR:
if (is_combat()) {
ASB("Can't change level in combat.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
}
else if (which_mode != 1) {
else if (which_mode != eSpecCtx::TOWN_MOVE) {
ASB("Can't change level now.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
@@ -2991,7 +3013,8 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
check_mess = false;
if (spec.m1 < 0)
break;
if (which_mode > 4) {
if(which_mode != eSpecCtx::OUT_MOVE && which_mode != eSpecCtx::TOWN_MOVE && which_mode != eSpecCtx::COMBAT_MOVE
&& which_mode != eSpecCtx::OUT_LOOK && which_mode != eSpecCtx::TOWN_LOOK) {
ASB("Can't use lever now.");
check_mess = false;
*next_spec = -1;
@@ -3017,14 +3040,14 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
break;
if (is_combat()) {
ASB("Not while in combat.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
}
else if ((which_mode != 1) && (which_mode != 4)) {
else if(which_mode != eSpecCtx::TOWN_MOVE && which_mode != eSpecCtx::TOWN_LOOK) {
ASB("Can't teleport now.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
@@ -3036,10 +3059,14 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
buttons[0] = 9; buttons[1] = 8;
// TODO: Wait, wait, aren't you supposed to be able to pick which picture to show?
i = custom_choice_dialog(strs,22,PIC_DLOG,buttons);
if (i == 1) { *next_spec = -1; if (which_mode < 3) *a = 1;}
if (i == 1) {
*next_spec = -1;
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
}
else {
*a = 1;
if (which_mode == 7)
if(which_mode == eSpecCtx::TALK)
teleport_party(spec.ex1a,spec.ex1b,1);
else teleport_party(spec.ex1a,spec.ex1b,0);
}
@@ -3051,14 +3078,14 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
break;
if (is_combat()) {
ASB("Can't change level in combat.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
}
else if (which_mode != 1) {
else if(which_mode != eSpecCtx::TOWN_MOVE) {
ASB("Can't change level now.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
@@ -3090,11 +3117,11 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
place_item(store_i,l,true);
break;
case eSpecType::TOWN_SPLIT_PARTY:
if (which_mode == 7)
if(which_mode == eSpecCtx::TALK)
break;
if (is_combat()) {
ASB("Not while in combat.");
if (which_mode < 3)
if((which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE) < 3)
*a = 1;
*next_spec = -1;
check_mess = false;
@@ -3102,14 +3129,14 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
}
if (univ.party.is_split() > 0) {
ASB("Party is already split.");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
break;
}
r1 = char_select_pc(1,0,"Which character goes?");
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
if (r1 != 6) {
current_pc = r1;
@@ -3125,7 +3152,7 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
ASB("Not while in combat.");
break;
}
if (which_mode < 3)
if(which_mode == eSpecCtx::OUT_MOVE || which_mode == eSpecCtx::TOWN_MOVE || which_mode == eSpecCtx::COMBAT_MOVE)
*a = 1;
*next_spec = -1;
check_mess = false;
@@ -3143,7 +3170,7 @@ void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
}
// TODO: What was next_spec_type for? Is it still needed?
void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void rect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short */*next_spec_type*/,short *a,short *b,short *redraw){
bool check_mess = true;
short i,j,k;
@@ -3291,7 +3318,7 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
}
// TODO: What was next_spec_type for? Is it still needed?
void outdoor_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void outdoor_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short */*next_spec_type*/,short *a,short *b,short *redraw){
bool check_mess = false;
std::string str1, str2;
@@ -3367,7 +3394,7 @@ void setsd(short a,short b,short val)
PSD[a][b] = val;
}
void handle_message(short which_mode,short cur_type,short mess1,short mess2,short *a,short *b)
void handle_message(eSpecCtx which_mode,short cur_type,short mess1,short mess2,short *a,short *b)
{
eEncNoteType note_type;
switch(cur_type) {
@@ -3387,7 +3414,7 @@ void handle_message(short which_mode,short cur_type,short mess1,short mess2,shor
if ((mess1 < 0) && (mess2 < 0))
return;
if (which_mode == 7) { // talking
if(which_mode == eSpecCtx::TALK) {
*a = mess1 + ((mess1 >= 0) ? mess_adj[cur_type] : 0);
*b = mess2 + ((mess2 >= 0) ? mess_adj[cur_type] : 0);
return;

View File

@@ -1,8 +1,8 @@
bool town_specials(short which,short t_num);
bool handle_wandering_specials (short which,short mode);
bool check_special_terrain(location where_check,short mode,short which_pc,short *spec_num,
bool check_special_terrain(location where_check,eSpecCtx mode,short which_pc,short *spec_num,
bool *forced);
void check_fields(location where_check,short mode,short which_pc);
void check_fields(location where_check,eSpecCtx mode,short which_pc);
void use_spec_item(short item);
void use_item(short pc,short item);
bool use_space(location where);
@@ -18,22 +18,22 @@ void fade_party();
void change_level(short town_num,short x,short y);
void push_things();
void special_increase_age();
void run_special(short which_mode,short which_type,short start_spec,location spec_loc,short *a,short *b,short *redraw);
void run_special(eSpecCtx which_mode,short which_type,short start_spec,location spec_loc,short *a,short *b,short *redraw);
cSpecial get_node(short cur_spec,short cur_spec_type);
void general_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);
void setsd(short a,short b,short val);
void handle_message(short which_mode,short cur_type,short mess1,short mess2,short *a,short *b);
void handle_message(eSpecCtx which_mode,short cur_type,short mess1,short mess2,short *a,short *b);
void get_strs(std::string& str1, std::string& str2,short cur_type,short which_str1,short which_str2) ;
void ifthen_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);
void affect_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);
void oneshot_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void oneshot_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);
void townmode_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);
void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void rect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);
void outdoor_spec(short which_mode,cSpecial cur_node,short cur_spec_type,
void outdoor_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
short *next_spec,short *next_spec_type,short *a,short *b,short *redraw);

View File

@@ -726,7 +726,7 @@ void handle_town_specials(short /*town_number*/, short entry_dir,location /*star
else special_queue[0].spec = univ.town->spec_on_entry;
special_queue[0].where = univ.town.p_loc;
special_queue[0].type = 2;
special_queue[0].mode = SPEC_ENTER_TOWN;
special_queue[0].mode = eSpecCtx::ENTER_TOWN;
special_queue[0].trigger_time = univ.party.age; // TODO: Simply pushing into slot 0 seems like a bad idea
}
@@ -736,7 +736,7 @@ void handle_leave_town_specials(short /*town_number*/, short which_spec,location
special_queue[1].spec = which_spec;
special_queue[1].where = univ.party.p_loc;
special_queue[1].type = 2;
special_queue[1].mode = SPEC_LEAVE_TOWN;
special_queue[1].mode = eSpecCtx::LEAVE_TOWN;
special_queue[1].trigger_time = univ.party.age; // TODO: Simply pushing into slot 1 seems like a bad idea
}

View File

@@ -519,26 +519,26 @@ inline void operator += (eDamageType& cur, eDamageType othr){
// sbyte(signed char k) : c(k) {}
//}
enum eSpecContext {
SPEC_OUT_MOVE = 0,
SPEC_TOWN_MOVE = 1,
SPEC_COMBAT_MOVE = 2,
SPEC_OUT_LOOK = 3,
SPEC_TOWN_LOOK = 4,
SPEC_ENTER_TOWN = 5,
SPEC_LEAVE_TOWN = 6,
SPEC_TALK = 7,
SPEC_USE_SPEC_ITEM = 8,
SPEC_TOWN_TIMER = 9,
SPEC_SCEN_TIMER = 10,
SPEC_PARTY_TIMER = 11,
SPEC_KILL_MONST = 12,
SPEC_OUTDOOR_ENC = 13,
SPEC_WIN_ENCOUNTER = 14,
SPEC_FLEE_ENCOUNTER = 15,
SPEC_TARGET = 16,
SPEC_USE_SPACE = 17,
SPEC_SEE_MONST = 18,
enum class eSpecCtx {
OUT_MOVE = 0,
TOWN_MOVE = 1,
COMBAT_MOVE = 2,
OUT_LOOK = 3,
TOWN_LOOK = 4,
ENTER_TOWN = 5,
LEAVE_TOWN = 6,
TALK = 7,
USE_SPEC_ITEM = 8,
TOWN_TIMER = 9,
SCEN_TIMER = 10,
PARTY_TIMER = 11,
KILL_MONST = 12,
OUTDOOR_ENC = 13,
FLEE_ENCOUNTER = 14,
WIN_ENCOUNTER = 15,
TARGET = 16,
USE_SPACE = 17,
SEE_MONST = 18,
};
enum class eSpecType {

View File

@@ -40,7 +40,7 @@ public:
struct pending_special_type {
spec_num_t spec;
eSpecContext mode;
eSpecCtx mode;
unsigned char type; // 0 - scen, 1 - out, 2 - town
location where;
long long trigger_time;