Misc little bits of housekeeping and stuff

This commit is contained in:
2014-12-10 23:53:50 -05:00
parent 7a7b7f27c3
commit 5bfdb5eafa
14 changed files with 31 additions and 26 deletions

View File

@@ -440,7 +440,7 @@ void start_outdoor_combat(cOutdoors::cCreature encounter,ter_num_t in_which_terr
bool pc_combat_move(location destination) ////
{
short dir,monst_hit,s1,s2,i,monst_exist,switch_pc;
bool keep_going = true,forced = false,check_f;
bool keep_going = true,forced = false,check_f = false;
location monst_loc,store_loc;
short spec_num;

View File

@@ -597,7 +597,7 @@ RECT get_monster_template_rect (pic_num_t picture_wanted,short mode,short which_
//mode; // 0 - left 1 - right +10 - combat mode
{
RECT store_rect = {0,0,36,28};
short adj;
short adj = 0;
if (mode >= 10) {
adj += 4;

View File

@@ -886,6 +886,8 @@ void set_town_attitude(short lo,short hi,short att) {
run_special(eSpecCtx::TOWN_HOSTILE, 2, univ.town->spec_on_hostile, univ.party.p_loc, &a[0], &a[1], &a[2]);
}
// TODO: Set town status to "dead"? Could reuse above with magic att (eg -1), or write new function.
static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& current_getting_pc, const std::vector<cItemRec*>& item_array)
{

View File

@@ -202,6 +202,7 @@ short sight_obscurity(short x,short y) {
what_terrain = coord_to_ter(x,y);
// TODO: This should not be hard-coded!
// It appears to refer to mountain cave entrances, surface tower, and surface pit. (WHY?)
if ((what_terrain >= 237) && (what_terrain <= 242))
return 1;
@@ -326,6 +327,7 @@ bool is_blocked(location to_check)
return true;
if ((is_combat()) && (scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == eTrimType::CITY))
return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check
// Note: The purpose of the above check is to avoid portals.
// Party there?
if (is_town())

View File

@@ -242,8 +242,6 @@ void init_party(short mode)
univ.party.can_find_town[i] = 0;
for (i = 0; i < 20; i++)
univ.party.key_times[i] = 30000;
// for (i = 0; i < 30; i++)
// univ.party.party_event_timers[i] = 0;
univ.party.party_event_timers.clear();
for (i = 0; i < 50; i++)
univ.party.spec_items[i] = 0;
@@ -369,8 +367,7 @@ void init_party_scen_data()
// univ.party.special_notes_str[i][j] = 0;
// for (i = 0; i < 120; i++)
// univ.party.talk_save[i].personality = -1;
// TODO: The journal at least should persist across scenarios; the other two, maybe, maybe not
univ.party.journal.clear();
// TODO: The journal at least should persist across scenarios; the special and talk notes, maybe, maybe not
univ.party.special_notes.clear();
univ.party.talk_save.clear();
@@ -380,8 +377,6 @@ void init_party_scen_data()
univ.party.can_find_town[i] = 1 - scenario.town_hidden[i];
for (i = 0; i < 20; i++)
univ.party.key_times[i] = 30000;
// for (i = 0; i < 30; i++)
// univ.party.party_event_timers[i] = 0;
univ.party.party_event_timers.clear();
for (i = 0; i < 50; i++)
univ.party.spec_items[i] = (scenario.special_items[i].flags >= 10) ? 1 : 0;
@@ -471,8 +466,6 @@ void put_party_in_scen(std::string scen_name)
univ.party.age = 0;
for (i = 0; i < 200; i++)
univ.party.m_killed[i] = 0;
// for (i = 0; i < 30; i++)
// univ.party.party_event_timers[i] = 0;
univ.party.party_event_timers.clear();
fs::path path;
@@ -1992,6 +1985,8 @@ bool pc_can_cast_spell(short pc_num,short type,short spell_num)
level = spell_level[spell_num];
if(overall_mode >= MODE_TALKING)
return false; // From Windows version. It does kinda make sense, though this function shouldn't even be called in these modes.
if ((spell_num < 0) || (spell_num > 61))
return false;
if (univ.party[pc_num].skills[9 + type] < level)

View File

@@ -365,7 +365,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,short which_pc,sho
fast_bang = 1;
if(mode == eSpecCtx::COMBAT_MOVE)
damage_pc(which_pc,r1,dam_type,eRace::UNKNOWN,0);
if (overall_mode < MODE_COMBAT)
else
boom_space(univ.party.p_loc,overall_mode,pic_type,r1,12);
fast_bang = 0;
break;
@@ -1533,7 +1533,7 @@ bool damage_monst(short which_m, short who_hit, short how_much, short how_much_s
if ((dam_type == 3) && (get_ran(1,0,24) <= victim->level))
how_much /= 2;
// Rentar-Ihrno?
// Invulnerable?
if (victim->spec_skill == 36)
how_much = how_much / 10;
@@ -1632,17 +1632,11 @@ bool damage_monst(short which_m, short who_hit, short how_much, short how_much_s
}
if ((victim->attitude % 2 != 1) && (who_hit < 7) &&
(processing_fields == false) && (monsters_going == false)) {
((processing_fields && !monsters_going) || (processing_fields && !PSD[SDF_HOSTILES_PRESENT]))) {
add_string_to_buf("Damaged an innocent. ");
victim->attitude = 1;
make_town_hostile();
}
if ((victim->attitude % 2 != 1) && (who_hit < 7) &&
((processing_fields == true) && (PSD[SDF_HOSTILES_PRESENT] == 0))) {
add_string_to_buf("Damaged an innocent.");
victim->attitude = 1;
make_town_hostile();
}
return true;
}
@@ -1663,7 +1657,7 @@ void kill_monst(cCreature *which_m,short who_killed)
} else switch(which_m->m_type) {
case eRace::GIANT: play_sound(29); break;
// TODO: Should sliths be considered reptiles too? Check original bladbase.
// TODO: Should birds be considered beasts? If there are iny birds in the bladbase, probably; otherwise, better to have new sound
// TODO: Should birds be considered beasts? If there are any birds in the bladbase, probably; otherwise, better to have new sound
case eRace::REPTILE: case eRace::BEAST: case eRace::DEMON: case eRace::UNDEAD: case eRace::STONE:
i = get_ran(1,0,1); play_sound(31 + i); break;
default: play_sound(33); break;
@@ -1942,7 +1936,7 @@ void run_special(pending_special_type spec, short* a, short* b, short* redraw) {
// 13 - encountering outdoor enc (a - 1 if no fight)
// 14 - winning outdoor enc
// 15 - fleeing outdoor enc
// 16 - ritual of sanct TODO: This will become "target space", hopefully
// 16 - target spell on space TODO: Maybe this will become just "target space"?
// 17 - using space
// 18 - seeing monster
// which_type - 0 - scen 1 - out 2 - town

View File

@@ -1244,7 +1244,7 @@ void erase_specials()////
void erase_out_specials()
{
short i,j,k,l,m,out_num;
short out_num;
cSpecial sn;
short sd1,sd2;
location where;

View File

@@ -619,7 +619,8 @@ void cParty::readFrom(std::istream& file){
cPlayer& cParty::operator[](unsigned short n){
if(n > 6) throw std::out_of_range("Attempt to access a player that doesn't exist.");
else if(n == 6) return adven[0]; // TODO: PC #6 should never be accessed, but bounds checking is rarely done, so this is a quick fix.
else if(n == 6)
return adven[0]; // TODO: PC #6 should never be accessed, but bounds checking is rarely done, so this is a quick fix.
return adven[n];
}

View File

@@ -66,6 +66,7 @@ cTown& cTown::operator = (legacy::town_record_type& old){
max_num_monst = old.max_num_monst;
spec_on_entry = old.spec_on_entry;
spec_on_entry_if_dead = old.spec_on_entry_if_dead;
spec_on_hostile = -1;
for(i = 0; i < 8; i++){
timer_spec_times[i] = old.timer_spec_times[i];
timer_specs[i] = old.timer_specs[i];

View File

@@ -787,7 +787,7 @@ void cCurTown::writeTo(std::ostream& file){
file << "INBOAT " << in_boat << '\n';
file << "AT " << p_loc.x << ' ' << p_loc.y << '\n';
file << '\f';
for(int i; i < 115; i++)
for(int i = 0; i < 115; i++)
if(items[i].variety != eItemType::NO_ITEM){
file << "ITEM " << i << '\n';
items[i].writeTo(file);

View File

@@ -97,6 +97,14 @@ public:
template<typename type> void setResult(const type& val){
result = val;
}
/// Iterate through all the controls in the dialog.
/// @param callback A function taking a string as its first argument
/// and a control reference as its second argument.
template<typename Fcn> void forEach(Fcn callback) {
for(auto ctrl : controls) {
callback(ctrl.first, *ctrl.second);
}
}
/// Set the background pattern of the dialog.
/// @param n The numeric index of the background pattern, which should be in the range [0,20].
/// You can use the constants BG_LIGHT or BG_DARK to reference the most commonly used backgrounds.

View File

@@ -330,7 +330,7 @@ cThreeChoice::cThreeChoice
void cThreeChoice::init_strings(std::vector<std::string>& strings, unsigned short left){
TextStyle style;
RECT cur_text_rect = {2, left, 0, 0};
size_t total_len, str_width, str_height;
size_t total_len = 0, str_width, str_height;
for (unsigned int i = 0; i < strings.size(); i++)
total_len += string_length(strings[i], style);
total_len = total_len * 12;

View File

@@ -715,6 +715,8 @@ bool load_outdoor_str(location which_out, short which_str, char* str){
return false;
}
// TODO: len was never assigned at all, is this the correct value?
len = sizeof(store_out);
n = fread(&store_out, len, 1, file_id);
for (i = 0; i < 120; i++) {
len = (long) (store_out.strlens[i]);

View File

@@ -111,7 +111,7 @@ void play_sound(short which, short how_many_times) { // if < 0, play asynch
}
snd_played[channel] = abs(which);
}
if (which < 0) // TODO: Guessing the delay should be in milliseconds; maybe this isn't the case.
if (which < 0)
sf::sleep(time_in_ticks(sound_delay[-1 * which]));
if(how_many_times > 1)
play_sound(which, how_many_times - 1);