Eliminate function-scope loop index variables
This makes all loop index variables local to their loop and fixes some issue arising from the loop variables being present through the whole function, such as using the wrong index variable. In addition, there has been some reduction of code duplication in the scenario editor.
This commit is contained in:
@@ -114,7 +114,6 @@ template<typename Container> static void port_shop_spec_node(cSpecial& spec, std
|
||||
|
||||
static const std::string err_prefix = "Error loading Blades of Exile Scenario: ";
|
||||
bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_header){
|
||||
short i,n;
|
||||
bool file_ok = false;
|
||||
long len;
|
||||
char temp_str[256];
|
||||
@@ -155,16 +154,14 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head
|
||||
}
|
||||
|
||||
len = (long) sizeof(legacy::scenario_data_type);
|
||||
n = fread(temp_scenario, len, 1, file_id);
|
||||
if(n < 1){
|
||||
if(fread(temp_scenario, len, 1, file_id) < 1) {
|
||||
showError(err_prefix + "Failed to read scenario data.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
}
|
||||
port_scenario(temp_scenario);
|
||||
len = sizeof(legacy::scen_item_data_type); // item data
|
||||
n = fread(item_data, len, 1, file_id);
|
||||
if(n < 1){
|
||||
if(fread(item_data, len, 1, file_id) < 1) {
|
||||
showError(err_prefix + "Failed to read scenario items.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
@@ -177,9 +174,9 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head
|
||||
scenario.special_items.resize(50);
|
||||
scenario.journal_strs.resize(50);
|
||||
scenario.spec_strs.resize(100);
|
||||
for(i = 0; i < 270; i++) {
|
||||
for(short i = 0; i < 270; i++) {
|
||||
len = (long) (temp_scenario->scen_str_len[i]);
|
||||
n = fread(temp_str, len, 1, file_id);
|
||||
fread(temp_str, len, 1, file_id);
|
||||
temp_str[len] = 0;
|
||||
if(i == 0) scenario.scen_name = temp_str;
|
||||
else if(i == 1 || i == 2)
|
||||
@@ -2168,20 +2165,19 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario, bool only_head
|
||||
}
|
||||
|
||||
static long get_town_offset(short which_town, legacy::scenario_data_type& scenario){
|
||||
int i,j;
|
||||
long len_to_jump,store;
|
||||
|
||||
len_to_jump = sizeof(scenario_header_flags);
|
||||
len_to_jump += sizeof(legacy::scenario_data_type);
|
||||
len_to_jump += sizeof(legacy::scen_item_data_type);
|
||||
for(i = 0; i < 300; i++)
|
||||
for(short i = 0; i < 300; i++)
|
||||
len_to_jump += (long) scenario.scen_str_len[i];
|
||||
store = 0;
|
||||
for(i = 0; i < 100; i++)
|
||||
for(j = 0; j < 2; j++)
|
||||
for(short i = 0; i < 100; i++)
|
||||
for(short j = 0; j < 2; j++)
|
||||
store += (long) (scenario.out_data_size[i][j]);
|
||||
for(i = 0; i < which_town; i++)
|
||||
for(j = 0; j < 5; j++)
|
||||
for(short i = 0; i < which_town; i++)
|
||||
for(short j = 0; j < 5; j++)
|
||||
store += (long) (scenario.town_data_size[i][j]);
|
||||
len_to_jump += store;
|
||||
|
||||
@@ -2189,7 +2185,6 @@ static long get_town_offset(short which_town, legacy::scenario_data_type& scenar
|
||||
}
|
||||
|
||||
bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy::scenario_data_type& scenario, std::vector<shop_info_t>& shops) {
|
||||
short i,n;
|
||||
long len,len_to_jump = 0;
|
||||
char temp_str[256];
|
||||
legacy::town_record_type store_town;
|
||||
@@ -2205,16 +2200,14 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
}
|
||||
|
||||
len_to_jump = get_town_offset(which_town, scenario);
|
||||
n = fseek(file_id, len_to_jump, SEEK_SET);
|
||||
if(n != 0) {
|
||||
if(fseek(file_id, len_to_jump, SEEK_SET) != 0) {
|
||||
showError(err_prefix + "Failure seeking to town record.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
len = sizeof(legacy::town_record_type);
|
||||
n = fread(&store_town, len, 1, file_id);
|
||||
if(n < 1) {
|
||||
if(fread(&store_town, len, 1, file_id) < 1) {
|
||||
showError(err_prefix + "Could not read town record.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
@@ -2224,7 +2217,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
switch(scenario.town_size[which_town]) {
|
||||
case 0:
|
||||
len = sizeof(legacy::big_tr_type);
|
||||
n = fread(&t_d, len, 1, file_id);
|
||||
fread(&t_d, len, 1, file_id);
|
||||
port_t_d(&t_d);
|
||||
the_town.append(store_town);
|
||||
the_town.append(t_d, which_town);
|
||||
@@ -2232,7 +2225,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
|
||||
case 1:
|
||||
len = sizeof(legacy::ave_tr_type);
|
||||
n = fread(&ave_t, len, 1, file_id);
|
||||
fread(&ave_t, len, 1, file_id);
|
||||
port_ave_t(&ave_t);
|
||||
the_town.append(store_town);
|
||||
the_town.append(ave_t, which_town);
|
||||
@@ -2240,7 +2233,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
|
||||
case 2:
|
||||
len = sizeof(legacy::tiny_tr_type);
|
||||
n = fread(&tiny_t, len, 1, file_id);
|
||||
fread(&tiny_t, len, 1, file_id);
|
||||
port_tiny_t(&tiny_t);
|
||||
the_town.append(store_town);
|
||||
the_town.append(tiny_t, which_town);
|
||||
@@ -2250,9 +2243,9 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
the_town.spec_strs.resize(100);
|
||||
the_town.sign_locs.resize(20);
|
||||
the_town.room_rect.resize(16);
|
||||
for(i = 0; i < 140; i++) {
|
||||
for(short i = 0; i < 140; i++) {
|
||||
len = (long) (store_town.strlens[i]);
|
||||
n = fread(temp_str, len, 1, file_id);
|
||||
fread(temp_str, len, 1, file_id);
|
||||
temp_str[len] = 0;
|
||||
if(i == 0) the_town.town_name = temp_str;
|
||||
else if(i >= 1 && i < 17)
|
||||
@@ -2266,8 +2259,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
}
|
||||
|
||||
len = sizeof(legacy::talking_record_type);
|
||||
n = fread(&store_talk, len, 1, file_id);
|
||||
if(n < 1) {
|
||||
if(fread(&store_talk, len, 1, file_id) < 1) {
|
||||
showError(err_prefix + "Could not read dialogue record.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
@@ -2275,9 +2267,9 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
port_talk_nodes(&store_talk);
|
||||
|
||||
the_town.talking.talk_nodes.resize(60);
|
||||
for(i = 0; i < 170; i++) {
|
||||
for(short i = 0; i < 170; i++) {
|
||||
len = (long) (store_talk.strlens[i]);
|
||||
n = fread(temp_str, len, 1, file_id);
|
||||
fread(temp_str, len, 1, file_id);
|
||||
temp_str[len] = 0;
|
||||
if(i >= 0 && i < 10)
|
||||
the_town.talking.people[i].title = temp_str;
|
||||
@@ -2302,8 +2294,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
// And lastly, calculate lighting
|
||||
the_town.set_up_lights();
|
||||
|
||||
n = fclose(file_id);
|
||||
if(n != 0) {
|
||||
if(fclose(file_id) != 0) {
|
||||
showError(err_prefix + "An error occurred while closing the file.", get_file_error());
|
||||
}
|
||||
|
||||
@@ -2311,18 +2302,18 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
|
||||
}
|
||||
|
||||
static long get_outdoors_offset(location& which_out, legacy::scenario_data_type& scenario){
|
||||
int i,j,out_sec_num;
|
||||
int out_sec_num;
|
||||
long len_to_jump,store;
|
||||
out_sec_num = scenario.out_width * which_out.y + which_out.x;
|
||||
|
||||
len_to_jump = sizeof(scenario_header_flags);
|
||||
len_to_jump += sizeof(legacy::scenario_data_type);
|
||||
len_to_jump += sizeof(legacy::scen_item_data_type);
|
||||
for(i = 0; i < 300; i++)
|
||||
for(short i = 0; i < 300; i++)
|
||||
len_to_jump += (long) scenario.scen_str_len[i];
|
||||
store = 0;
|
||||
for(i = 0; i < out_sec_num; i++)
|
||||
for(j = 0; j < 2; j++)
|
||||
for(short i = 0; i < out_sec_num; i++)
|
||||
for(short j = 0; j < 2; j++)
|
||||
store += (long) (scenario.out_data_size[i][j]);
|
||||
len_to_jump += store;
|
||||
|
||||
@@ -2331,7 +2322,6 @@ static long get_outdoors_offset(location& which_out, legacy::scenario_data_type&
|
||||
|
||||
//mode -> 0 - primary load 1 - add to top 2 - right 3 - bottom 4 - left
|
||||
bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out, legacy::scenario_data_type& scenario){
|
||||
short i,n;
|
||||
long len,len_to_jump;
|
||||
char temp_str[256];
|
||||
legacy::outdoor_record_type store_out;
|
||||
@@ -2343,16 +2333,14 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out,
|
||||
}
|
||||
|
||||
len_to_jump = get_outdoors_offset(which_out, scenario);
|
||||
n = fseek(file_id, len_to_jump, SEEK_SET);
|
||||
if(n != 0) {
|
||||
if(fseek(file_id, len_to_jump, SEEK_SET) != 0) {
|
||||
showError(err_prefix + "Failure seeking to outdoor record.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
len = sizeof(legacy::outdoor_record_type);
|
||||
n = fread(&store_out, len, 1, file_id);
|
||||
if(n < 1) {
|
||||
if(fread(&store_out, len, 1, file_id) < 1) {
|
||||
showError(err_prefix + "Could not read outdoor record.", get_file_error());
|
||||
fclose(file_id);
|
||||
return false;
|
||||
@@ -2365,9 +2353,9 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out,
|
||||
the_out.spec_strs.resize(90);
|
||||
the_out.sign_locs.resize(8);
|
||||
the_out.info_rect.resize(8);
|
||||
for(i = 0; i < 108; i++) {
|
||||
for(short i = 0; i < 108; i++) {
|
||||
len = (long) (store_out.strlens[i]);
|
||||
n = fread(temp_str, len, 1, file_id);
|
||||
fread(temp_str, len, 1, file_id);
|
||||
temp_str[len] = 0;
|
||||
if(i == 0) the_out.out_name = temp_str;
|
||||
else if(i == 9) the_out.comment = temp_str;
|
||||
@@ -2378,8 +2366,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out,
|
||||
the_out.sign_locs[i-100].text = temp_str;
|
||||
}
|
||||
|
||||
n = fclose(file_id);
|
||||
if(n != 0) {
|
||||
if(fclose(file_id) != 0) {
|
||||
showError(err_prefix + "Something went wrong when closing the file.", get_file_error());
|
||||
}
|
||||
return true;
|
||||
|
@@ -81,7 +81,6 @@ void init_graph_tool(){
|
||||
delete[] fbuf;
|
||||
delete[] vbuf;
|
||||
} while(false);
|
||||
int i;
|
||||
static const location pat_offs[17] = {
|
||||
{0,3}, {1,1}, {2,1}, {2,0},
|
||||
{3,0}, {3,1}, {1,3}, {0,0},
|
||||
@@ -92,7 +91,7 @@ void init_graph_tool(){
|
||||
2, 3, 4, 5, 6, 8, 9, 10,
|
||||
11,12,13,14,15,16,17,19,20
|
||||
};
|
||||
for(i = 0; i < 17; i++){
|
||||
for(short i = 0; i < 17; i++){
|
||||
bg_rects[pat_i[i]] = {0,0,64,64};
|
||||
bg_rects[pat_i[i]].offset(64 * pat_offs[i].x,64 * pat_offs[i].y);
|
||||
}
|
||||
@@ -273,7 +272,7 @@ void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::stri
|
||||
short line_height = options.style.lineHeight;
|
||||
sf::Text str_to_draw;
|
||||
options.style.applyTo(str_to_draw);
|
||||
short str_len,i;
|
||||
short str_len;
|
||||
unsigned short last_line_break = 0,last_word_break = 0;
|
||||
short total_width = 0;
|
||||
short adjust_x = 0,adjust_y = 0;
|
||||
@@ -308,7 +307,8 @@ void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::stri
|
||||
|
||||
if(mode == eTextMode::WRAP) {
|
||||
moveTo = location(dest_rect.left + 1 + adjust_x, dest_rect.top + 1 + adjust_y + 9);
|
||||
for(i = 0; text_len(i) != text_len(i + 1) && i < str_len;i++) {
|
||||
short i;
|
||||
for(i = 0; text_len(i) != text_len(i + 1) && i < str_len; i++) {
|
||||
if(((text_len(i) - text_len(last_line_break) > (dest_rect.width() - 6))
|
||||
&& (last_word_break >= last_line_break)) || (str[i] == '|')) {
|
||||
if(str[i] == '|') {
|
||||
|
@@ -11,12 +11,12 @@
|
||||
|
||||
short get_ran (short times,short min,short max){
|
||||
long int store;
|
||||
short i, to_ret = 0;
|
||||
short to_ret = 0;
|
||||
|
||||
if(max < min) max = min;
|
||||
if(max == min) return times * min;
|
||||
|
||||
for(i = 1; i < times + 1; i++) {
|
||||
for(short i = 1; i < times + 1; i++) {
|
||||
store = rand();
|
||||
to_ret += min + (store % (max - min + 1));
|
||||
}
|
||||
|
@@ -11,42 +11,38 @@
|
||||
extern bool cur_scen_is_mac, mac_is_intel;
|
||||
|
||||
void port_town(legacy::town_record_type* dummy_town_ptr){
|
||||
short i;
|
||||
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
flip_short(&dummy_town_ptr->town_chop_time);
|
||||
flip_short(&dummy_town_ptr->town_chop_key);
|
||||
flip_short(&dummy_town_ptr->lighting);
|
||||
for(i =0 ; i < 4; i++)
|
||||
for(short i = 0; i < 4; i++)
|
||||
flip_short(&dummy_town_ptr->exit_specs[i]);
|
||||
flip_rect(&dummy_town_ptr->in_town_rect);
|
||||
for(i =0 ; i < 64; i++) {
|
||||
for(short i = 0; i < 64; i++) {
|
||||
flip_short(&dummy_town_ptr->preset_items[i].item_code);
|
||||
flip_short(&dummy_town_ptr->preset_items[i].ability);
|
||||
}
|
||||
for(i =0 ; i < 50; i++) {
|
||||
for(short i = 0; i < 50; i++) {
|
||||
flip_short(&dummy_town_ptr->preset_fields[i].field_type);
|
||||
}
|
||||
flip_short(&dummy_town_ptr->max_num_monst);
|
||||
flip_short(&dummy_town_ptr->spec_on_entry);
|
||||
flip_short(&dummy_town_ptr->spec_on_entry_if_dead);
|
||||
for(i =0 ; i < 8; i++)
|
||||
for(short i = 0; i < 8; i++)
|
||||
flip_short(&dummy_town_ptr->timer_spec_times[i]);
|
||||
for(i =0 ; i < 8; i++)
|
||||
for(short i = 0; i < 8; i++)
|
||||
flip_short(&dummy_town_ptr->timer_specs[i]);
|
||||
flip_short(&dummy_town_ptr->difficulty);
|
||||
for(i =0 ; i < 100; i++)
|
||||
for(short i = 0; i < 100; i++)
|
||||
flip_spec_node(&dummy_town_ptr->specials[i]);
|
||||
|
||||
}
|
||||
|
||||
void port_talk_nodes(legacy::talking_record_type* dummy_talk_ptr) {
|
||||
short i;
|
||||
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
for(i = 0; i < 60; i++) {
|
||||
for(short i = 0; i < 60; i++) {
|
||||
flip_short(&dummy_talk_ptr->talk_nodes[i].personality);
|
||||
flip_short(&dummy_talk_ptr->talk_nodes[i].type);
|
||||
flip_short(&dummy_talk_ptr->talk_nodes[i].extras[0]);
|
||||
@@ -57,13 +53,12 @@ void port_talk_nodes(legacy::talking_record_type* dummy_talk_ptr) {
|
||||
}
|
||||
|
||||
void port_t_d(legacy::big_tr_type* old) {
|
||||
short i;
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i =0 ; i < 16; i++)
|
||||
for(short i = 0; i < 16; i++)
|
||||
flip_rect(&old->room_rect[i]);
|
||||
for(i =0 ; i < 60; i++) {
|
||||
for(short i = 0; i < 60; i++) {
|
||||
flip_short(&old->creatures[i].spec1);
|
||||
flip_short(&old->creatures[i].spec2);
|
||||
flip_short(&old->creatures[i].monster_time);
|
||||
@@ -74,13 +69,12 @@ void port_t_d(legacy::big_tr_type* old) {
|
||||
}
|
||||
|
||||
void port_ave_t(legacy::ave_tr_type* old) {
|
||||
short i;
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i =0 ; i < 16; i++)
|
||||
for(short i = 0; i < 16; i++)
|
||||
flip_rect(&old->room_rect[i]);
|
||||
for(i =0 ; i < 40; i++) {
|
||||
for(short i = 0; i < 40; i++) {
|
||||
flip_short(&old->creatures[i].spec1);
|
||||
flip_short(&old->creatures[i].spec2);
|
||||
flip_short(&old->creatures[i].monster_time);
|
||||
@@ -91,13 +85,12 @@ void port_ave_t(legacy::ave_tr_type* old) {
|
||||
}
|
||||
|
||||
void port_tiny_t(legacy::tiny_tr_type* old) {
|
||||
short i;
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i =0 ; i < 16; i++)
|
||||
for(short i = 0; i < 16; i++)
|
||||
flip_rect(&old->room_rect[i]);
|
||||
for(i =0 ; i < 30; i++) {
|
||||
for(short i = 0; i < 30; i++) {
|
||||
flip_short(&old->creatures[i].spec1);
|
||||
flip_short(&old->creatures[i].spec2);
|
||||
flip_short(&old->creatures[i].monster_time);
|
||||
@@ -108,8 +101,6 @@ void port_tiny_t(legacy::tiny_tr_type* old) {
|
||||
}
|
||||
|
||||
void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||
short i,j;
|
||||
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
flip_short(&temp_scenario->flag_a);
|
||||
@@ -124,28 +115,28 @@ void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||
flip_short(&temp_scenario->intro_mess_pic);
|
||||
flip_short(&temp_scenario->intro_mess_len);
|
||||
flip_short(&temp_scenario->which_town_start);
|
||||
for(i = 0; i < 200; i++)
|
||||
for(j = 0; j < 5; j++)
|
||||
for(short i = 0; i < 200; i++)
|
||||
for(short j = 0; j < 5; j++)
|
||||
flip_short(&temp_scenario->town_data_size[i][j]);
|
||||
for(i = 0; i < 10; i++)
|
||||
for(short i = 0; i < 10; i++)
|
||||
flip_short(&temp_scenario->town_to_add_to[i]);
|
||||
for(i = 0; i < 10; i++)
|
||||
for(j = 0; j < 2; j++)
|
||||
for(short i = 0; i < 10; i++)
|
||||
for(short j = 0; j < 2; j++)
|
||||
flip_short(&temp_scenario->flag_to_add_to_town[i][j]);
|
||||
for(i = 0; i < 100; i++)
|
||||
for(j = 0; j < 2; j++)
|
||||
for(short i = 0; i < 100; i++)
|
||||
for(short j = 0; j < 2; j++)
|
||||
flip_short(&temp_scenario->out_data_size[i][j]);
|
||||
for(i = 0; i < 3; i++)
|
||||
for(short i = 0; i < 3; i++)
|
||||
flip_rect(&temp_scenario->store_item_rects[i]);
|
||||
for(i = 0; i < 3; i++)
|
||||
for(short i = 0; i < 3; i++)
|
||||
flip_short(&temp_scenario->store_item_towns[i]);
|
||||
for(i = 0; i < 50; i++)
|
||||
for(short i = 0; i < 50; i++)
|
||||
flip_short(&temp_scenario->special_items[i]);
|
||||
for(i = 0; i < 50; i++)
|
||||
for(short i = 0; i < 50; i++)
|
||||
flip_short(&temp_scenario->special_item_special[i]);
|
||||
flip_short(&temp_scenario->rating);
|
||||
flip_short(&temp_scenario->uses_custom_graphics);
|
||||
for(i = 0; i < 256; i++) {
|
||||
for(short i = 0; i < 256; i++) {
|
||||
flip_short(&temp_scenario->scen_monsters[i].health);
|
||||
flip_short(&temp_scenario->scen_monsters[i].m_health);
|
||||
flip_short(&temp_scenario->scen_monsters[i].max_mp);
|
||||
@@ -160,26 +151,26 @@ void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||
flip_short(&temp_scenario->scen_monsters[i].picture_num);
|
||||
}
|
||||
|
||||
for(i = 0; i < 256; i++) {
|
||||
for(short i = 0; i < 256; i++) {
|
||||
flip_short(&temp_scenario->ter_types[i].picture);
|
||||
}
|
||||
for(i = 0; i < 30; i++) {
|
||||
for(short i = 0; i < 30; i++) {
|
||||
flip_short(&temp_scenario->scen_boats[i].which_town);
|
||||
}
|
||||
for(i = 0; i < 30; i++) {
|
||||
for(short i = 0; i < 30; i++) {
|
||||
flip_short(&temp_scenario->scen_horses[i].which_town);
|
||||
}
|
||||
for(i = 0; i < 20; i++)
|
||||
for(short i = 0; i < 20; i++)
|
||||
flip_short(&temp_scenario->scenario_timer_times[i]);
|
||||
for(i = 0; i < 20; i++)
|
||||
for(short i = 0; i < 20; i++)
|
||||
flip_short(&temp_scenario->scenario_timer_specs[i]);
|
||||
for(i = 0; i < 256; i++) {
|
||||
for(short i = 0; i < 256; i++) {
|
||||
flip_spec_node(&temp_scenario->scen_specials[i]);
|
||||
}
|
||||
for(i = 0; i < 10; i++) {
|
||||
for(short i = 0; i < 10; i++) {
|
||||
flip_short(&temp_scenario->storage_shortcuts[i].ter_type);
|
||||
flip_short(&temp_scenario->storage_shortcuts[i].property);
|
||||
for(j = 0; j < 10; j++) {
|
||||
for(short j = 0; j < 10; j++) {
|
||||
flip_short(&temp_scenario->storage_shortcuts[i].item_num[j]);
|
||||
flip_short(&temp_scenario->storage_shortcuts[i].item_odds[j]);
|
||||
}
|
||||
@@ -189,12 +180,10 @@ void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||
|
||||
|
||||
void port_item_list(legacy::scen_item_data_type* old){
|
||||
short i;
|
||||
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i = 0; i < 400; i++) {
|
||||
for(short i = 0; i < 400; i++) {
|
||||
flip_short(&(old->scen_items[i].variety));
|
||||
flip_short(&(old->scen_items[i].item_level));
|
||||
flip_short(&(old->scen_items[i].value));
|
||||
@@ -202,12 +191,10 @@ void port_item_list(legacy::scen_item_data_type* old){
|
||||
}
|
||||
|
||||
void port_out(legacy::outdoor_record_type *out) {
|
||||
short i;
|
||||
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
for(short i = 0; i < 4; i++) {
|
||||
flip_short(&(out->wandering[i].spec_on_meet));
|
||||
flip_short(&(out->wandering[i].spec_on_win));
|
||||
flip_short(&(out->wandering[i].spec_on_flee));
|
||||
@@ -221,42 +208,41 @@ void port_out(legacy::outdoor_record_type *out) {
|
||||
flip_short(&(out->special_enc[i].end_spec1));
|
||||
flip_short(&(out->special_enc[i].end_spec2));
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
for(short i = 0; i < 8; i++)
|
||||
flip_rect(&(out->info_rect[i]));
|
||||
for(i = 0; i < 60; i++)
|
||||
for(short i = 0; i < 60; i++)
|
||||
flip_spec_node(&(out->specials[i]));
|
||||
}
|
||||
|
||||
void port_party(legacy::party_record_type* old){
|
||||
int i,j,k;
|
||||
flip_long(&old->age);
|
||||
flip_short(&old->gold);
|
||||
flip_short(&old->food);
|
||||
flip_short(&old->light_level);
|
||||
for(i = 0; i < 30; i++){
|
||||
for(short i = 0; i < 30; i++){
|
||||
flip_short(&old->boats[i].which_town);
|
||||
flip_short(&old->horses[i].which_town);
|
||||
flip_short(&old->party_event_timers[i]);
|
||||
flip_short(&old->global_or_town[i]);
|
||||
flip_short(&old->node_to_call[i]);
|
||||
}
|
||||
for(i = 0; i < 4; i++){
|
||||
for(short i = 0; i < 4; i++){
|
||||
flip_short(&old->creature_save[i].which_town);
|
||||
flip_short(&old->creature_save[i].hostile);
|
||||
for(j = 0; j < 60; j++){
|
||||
for(short j = 0; j < 60; j++){
|
||||
flip_short(&old->creature_save[i].dudes[j].active);
|
||||
flip_short(&old->creature_save[i].dudes[j].attitude);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.health);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.m_health);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.mp);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.max_mp);
|
||||
for(k = 0; k < 3; k++)
|
||||
for(short k = 0; k < 3; k++)
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.a[k]);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.morale);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.m_morale);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.corpse_item);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.corpse_item_chance);
|
||||
for(k = 0; k < 15; k++)
|
||||
for(short k = 0; k < 15; k++)
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.status[k]);
|
||||
flip_short(&old->creature_save[i].dudes[j].m_d.picture_num);
|
||||
flip_short(&old->creature_save[i].dudes[j].summoned);
|
||||
@@ -271,7 +257,7 @@ void port_party(legacy::party_record_type* old){
|
||||
}
|
||||
flip_short(&old->in_boat);
|
||||
flip_short(&old->in_horse);
|
||||
for(i = 0; i < 10; i++){
|
||||
for(short i = 0; i < 10; i++){
|
||||
flip_short(&old->out_c[i].direction);
|
||||
flip_short(&old->out_c[i].what_monst.spec_on_meet);
|
||||
flip_short(&old->out_c[i].what_monst.spec_on_win);
|
||||
@@ -280,19 +266,19 @@ void port_party(legacy::party_record_type* old){
|
||||
flip_short(&old->out_c[i].what_monst.end_spec1);
|
||||
flip_short(&old->out_c[i].what_monst.end_spec2);
|
||||
}
|
||||
for(i = 0; i < 5; i++)
|
||||
for(j = 0; j < 10; j++){
|
||||
for(short i = 0; i < 5; i++)
|
||||
for(short j = 0; j < 10; j++){
|
||||
flip_short(&old->magic_store_items[i][j].variety);
|
||||
flip_short(&old->magic_store_items[i][j].item_level);
|
||||
flip_short(&old->magic_store_items[i][j].value);
|
||||
}
|
||||
for(i = 0; i < 50; i++)
|
||||
for(short i = 0; i < 50; i++)
|
||||
flip_short(&old->journal_day[i]);
|
||||
for(i = 0; i < 140; i++){
|
||||
for(short i = 0; i < 140; i++){
|
||||
flip_short(&old->special_notes_str[i][0]);
|
||||
flip_short(&old->special_notes_str[i][1]);
|
||||
}
|
||||
for(i = 0; i < 120; i++){
|
||||
for(short i = 0; i < 120; i++){
|
||||
flip_short(&old->talk_save[i].personality);
|
||||
flip_short(&old->talk_save[i].town_num);
|
||||
flip_short(&old->talk_save[i].str1);
|
||||
@@ -300,9 +286,9 @@ void port_party(legacy::party_record_type* old){
|
||||
}
|
||||
flip_short(&old->direction);
|
||||
flip_short(&old->at_which_save_slot);
|
||||
for(i = 0; i < 100; i++)
|
||||
for(short i = 0; i < 100; i++)
|
||||
flip_short(&old->key_times[i]);
|
||||
for(i = 0; i < 200; i++)
|
||||
for(short i = 0; i < 200; i++)
|
||||
flip_short(&old->m_killed[i]);
|
||||
flip_long(&old->total_m_killed);
|
||||
flip_long(&old->total_dam_done);
|
||||
@@ -311,9 +297,8 @@ void port_party(legacy::party_record_type* old){
|
||||
}
|
||||
|
||||
void port_pc(legacy::pc_record_type* old){
|
||||
int i;
|
||||
flip_short(&old->main_status);
|
||||
for(i = 0; i < 30; i++)
|
||||
for(short i = 0; i < 30; i++)
|
||||
flip_short(&old->skills[i]);
|
||||
flip_short(&old->max_health);
|
||||
flip_short(&old->cur_health);
|
||||
@@ -322,9 +307,9 @@ void port_pc(legacy::pc_record_type* old){
|
||||
flip_short(&old->experience);
|
||||
flip_short(&old->skill_pts);
|
||||
flip_short(&old->level);
|
||||
for(i = 0; i < 15; i++)
|
||||
for(short i = 0; i < 15; i++)
|
||||
flip_short(&old->status[i]);
|
||||
for(i = 0; i < 10; i++){
|
||||
for(short i = 0; i < 10; i++){
|
||||
flip_short(&old->items[i].variety);
|
||||
flip_short(&old->items[i].item_level);
|
||||
flip_short(&old->items[i].value);
|
||||
@@ -337,26 +322,25 @@ void port_pc(legacy::pc_record_type* old){
|
||||
}
|
||||
|
||||
void port_c_town(legacy::current_town_type* old){
|
||||
int i,j;
|
||||
flip_short(&old->town_num);
|
||||
flip_short(&old->difficulty);
|
||||
port_town(&old->town);
|
||||
flip_short(&old->monst.which_town);
|
||||
flip_short(&old->monst.hostile);
|
||||
for(j = 0; j < 60; j++){
|
||||
for(short j = 0; j < 60; j++){
|
||||
flip_short(&old->monst.dudes[j].active);
|
||||
flip_short(&old->monst.dudes[j].attitude);
|
||||
flip_short(&old->monst.dudes[j].m_d.health);
|
||||
flip_short(&old->monst.dudes[j].m_d.m_health);
|
||||
flip_short(&old->monst.dudes[j].m_d.mp);
|
||||
flip_short(&old->monst.dudes[j].m_d.max_mp);
|
||||
for(i = 0; i < 3; i++)
|
||||
for(short i = 0; i < 3; i++)
|
||||
flip_short(&old->monst.dudes[j].m_d.a[i]);
|
||||
flip_short(&old->monst.dudes[j].m_d.morale);
|
||||
flip_short(&old->monst.dudes[j].m_d.m_morale);
|
||||
flip_short(&old->monst.dudes[j].m_d.corpse_item);
|
||||
flip_short(&old->monst.dudes[j].m_d.corpse_item_chance);
|
||||
for(i = 0; i < 15; i++)
|
||||
for(short i = 0; i < 15; i++)
|
||||
flip_short(&old->monst.dudes[j].m_d.status[i]);
|
||||
flip_short(&old->monst.dudes[j].m_d.picture_num);
|
||||
flip_short(&old->monst.dudes[j].summoned);
|
||||
|
@@ -39,9 +39,7 @@ std::unordered_map<int,int> sound_delay = {
|
||||
short store_last_sound_played;
|
||||
|
||||
bool sound_going(snd_num_t which_s) {
|
||||
short i;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for(short i = 0; i < 4; i++)
|
||||
if(snd_played[i] == which_s)
|
||||
return chan[i]->getStatus() == sf::Sound::Playing;
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user