Reimplement importing towns
This commit is contained in:
@@ -1564,6 +1564,7 @@ bool build_scenario() {
|
||||
bool default_town, grass;
|
||||
std::string filename, title;
|
||||
short i,j;
|
||||
cTown* warriors_grove = nullptr;
|
||||
|
||||
if(!edit_make_scen_1(filename, title, grass))
|
||||
return false;
|
||||
@@ -1581,7 +1582,10 @@ bool build_scenario() {
|
||||
} else {
|
||||
fs::path basePath = progDir/"Scenario Editor"/"Blades of Exile Base"/"bladbase.exs";
|
||||
if(!fs::exists(basePath)) {oopsError(40);}
|
||||
import_town(0, basePath);
|
||||
cScenario base;
|
||||
load_scenario(basePath, base);
|
||||
warriors_grove = base.towns[0];
|
||||
base.towns[0] = nullptr;
|
||||
}
|
||||
if(med > 0) med--;
|
||||
// TODO: This will probably change drastically once the new scenario format is implemented
|
||||
@@ -1594,6 +1598,9 @@ bool build_scenario() {
|
||||
cur_out.y = 0;
|
||||
current_terrain = scenario.outdoors[0][0];
|
||||
|
||||
if(default_town && warriors_grove)
|
||||
scenario.towns.push_back(warriors_grove);
|
||||
|
||||
// TODO: Append i+1 to each town name
|
||||
for(i = 0; i < large; i++) {
|
||||
which_town = scenario.num_towns;
|
||||
|
||||
@@ -549,164 +549,6 @@ void create_basic_scenario() {
|
||||
giveError("Scenario not created; creation currently disabled.");
|
||||
}
|
||||
|
||||
// if which_town is -1, load town from base
|
||||
void import_town(short /*which_town*/,fs::path /*temp_file_to_load*/) {
|
||||
giveError("Town import currently disabled.");
|
||||
// short i,j,k,l,file_id;
|
||||
// bool file_ok = false;
|
||||
// OSErr error;
|
||||
// long len,len_to_jump = 0,store;
|
||||
// Size buf_len = 100000;
|
||||
// char *buffer = NULL;
|
||||
// short import_user_given_password;
|
||||
// legacy::big_tr_type t_d;
|
||||
// legacy::ave_tr_type ave_t;
|
||||
// legacy::tiny_tr_type tiny_t;
|
||||
// legacy::talking_record_type talking;
|
||||
// legacy::scenario_data_type *temp_scenario;
|
||||
//
|
||||
// if((error = FSpOpenDF(&temp_file_to_load,1,&file_id)) != 0) {
|
||||
// oops_error(42); return;
|
||||
// }
|
||||
//
|
||||
// buffer = new char[100000];
|
||||
// if(buffer == NULL) {
|
||||
// oops_error(41);
|
||||
// return;
|
||||
// }
|
||||
// scenario_header_flags temp_vers;
|
||||
// len = (long) sizeof(scenario_header_flags);
|
||||
// if((error = FSRead(file_id, &len, &temp_vers)) != 0){
|
||||
// FSClose(file_id); oops_error(43); return;
|
||||
// }
|
||||
//
|
||||
// if((temp_vers.flag1 == 10) && (temp_vers.flag2 == 20) &&
|
||||
// (temp_vers.flag3 == 30) && (temp_vers.flag4 == 40)) {
|
||||
// file_ok = true;
|
||||
// }
|
||||
// if(!file_ok) {
|
||||
// FSClose(file_id); give_error("This is not a legitimate Blades of Exile scenario.","",0); return;
|
||||
// DisposePtr(buffer); FSClose(file_id); give_error("This is not a legitimate Blades of Exile scenario. If it is a scenario, note that it needs to have been saved by the Macintosh scenario editor.","",0); return;
|
||||
// }
|
||||
// if(which_town >= temp_vers.num_towns) {
|
||||
// give_error("Oops ... the selected scenario doesn't have enough towns. The town you selected doesn't exist inside this scenario.","",0);
|
||||
// DisposePtr(buffer); FSClose(file_id);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// len = (long) sizeof(legacy::scenario_data_type);
|
||||
// if((error = FSRead(file_id, &len, buffer)) != 0){
|
||||
// FSClose(file_id); oops_error(43); return;
|
||||
// }
|
||||
// temp_scenario = (legacy::scenario_data_type *) buffer;
|
||||
//
|
||||
// if(temp_scenario->town_size[which_town] != scenario.town_size[cur_town]) {
|
||||
// give_error("Oops ... the town in the selected scenario and the current town are different sizes. Import failed.","",0);
|
||||
// DisposePtr(buffer); FSClose(file_id);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// // Now check password
|
||||
//// if(!import_check_p(0)) {
|
||||
//// import_user_given_password = enter_password();
|
||||
//// if(!import_check_p(import_user_given_password)) {
|
||||
//// fancy_choice_dialog(868,0);
|
||||
//// if(overall_mode != 61) {
|
||||
//// import_user_given_password = enter_password();
|
||||
//// if(!import_check_p(import_user_given_password))
|
||||
//// ExitToShell();
|
||||
//// }
|
||||
//// else return;
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// len_to_jump = sizeof(legacy::scenario_data_type);
|
||||
// len_to_jump += sizeof(scen_item_data_type);
|
||||
// for(i = 0; i < 300; i++)
|
||||
// len_to_jump += (long) temp_scenario->scen_str_len[i];
|
||||
// store = 0;
|
||||
// for(i = 0; i < 100; i++)
|
||||
// for(j = 0; j < 2; j++)
|
||||
// store += (long) (temp_scenario->out_data_size[i][j]);
|
||||
// for(i = 0; i < which_town; i++)
|
||||
// for(j = 0; j < 5; j++)
|
||||
// store += (long) (temp_scenario->town_data_size[i][j]);
|
||||
// len_to_jump += store;
|
||||
// error = SetFPos (file_id, 1, len_to_jump);
|
||||
// if(error != 0) {FSClose(file_id);oops_error(44);}
|
||||
//
|
||||
// len = sizeof(legacy::town_record_type);
|
||||
// error = FSRead(file_id, &len , (char *) &town);
|
||||
// if(error != 0) {FSClose(file_id);oops_error(45);}
|
||||
//
|
||||
// switch(temp_scenario->town_size[which_town]) {
|
||||
// case 0:
|
||||
// len = sizeof(legacy::big_tr_type);
|
||||
// FSRead(file_id, &len, (char *) &t_d);
|
||||
// break;
|
||||
//
|
||||
// case 1:
|
||||
// len = sizeof(legacy::ave_tr_type);
|
||||
// FSRead(file_id, &len, (char *) &ave_t);
|
||||
// for(i = 0; i < 48; i++)
|
||||
// for(j = 0; j < 48; j++) {
|
||||
// town->terrain(i,j) = ave_t.terrain[i][j];
|
||||
// town->lighting(i / 8,j) = ave_t.lighting[i / 8][j];
|
||||
// }
|
||||
// for(i = 0; i < 16; i++) {
|
||||
// town->room_rect(i) = ave_t.room_rect[i];
|
||||
// }
|
||||
// for(i = 0; i < 40; i++) {
|
||||
// //town->creatures(i) = ave_t.creatures[i];
|
||||
// }
|
||||
// for(i = 40; i < 60; i++) {
|
||||
// town->creatures(i).number = 0;
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case 2:
|
||||
// len = sizeof(legacy::tiny_tr_type);
|
||||
// FSRead(file_id,&len , (char *) &tiny_t);
|
||||
// for(i = 0; i < 32; i++)
|
||||
// for(j = 0; j < 32; j++) {
|
||||
// town->terrain(i,j) = tiny_t.terrain[i][j];
|
||||
// town->lighting(i / 8,j) = tiny_t.lighting[i / 8][j];
|
||||
// }
|
||||
// for(i = 0; i < 16; i++) {
|
||||
// town->room_rect(i) = tiny_t.room_rect[i];
|
||||
// }
|
||||
// for(i = 0; i < 30; i++) {
|
||||
// //town->creatures(i) = tiny_t.creatures[i];
|
||||
// }
|
||||
// for(i = 30; i < 60; i++) {
|
||||
// town->creatures(i).number = 0;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// for(i = 0; i < 140; i++) {
|
||||
// len = (long) (town->strlens[i]);
|
||||
// FSRead(file_id, &len, (char *) &(town->town_strs(i)));
|
||||
// town->town_strs(i)[len] = 0;
|
||||
// }
|
||||
//
|
||||
// len = sizeof(legacy::talking_record_type);
|
||||
// error = FSRead(file_id, &len , (char *) &talking);
|
||||
// if(error != 0) {FSClose(file_id);oops_error(46);}
|
||||
//
|
||||
// for(i = 0; i < 170; i++) {
|
||||
// len = (long) (talking.strlens[i]);
|
||||
// FSRead(file_id, &len, (char *) &(town->talking.talk_strs[i]));
|
||||
// town->talking.talk_strs[i][len] = 0;
|
||||
// }
|
||||
//
|
||||
// town->talking = talking;
|
||||
// error = FSClose(file_id);
|
||||
// if(error != 0) {FSClose(file_id);oops_error(47);}
|
||||
// DisposePtr(buffer);
|
||||
}
|
||||
|
||||
// When this is called, the current town is the town to make town 0.
|
||||
void make_new_scenario(std::string /*file_name*/,short /*out_width*/,short /*out_height*/,bool /*making_warriors_grove*/,
|
||||
bool /*use_grass*/) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
void save_scenario();
|
||||
void import_town(short which_town,fs::path temp_file_to_load);
|
||||
void create_basic_scenario();
|
||||
void make_new_scenario(std::string file_name,short out_width,short out_height,bool making_warriors_grove,
|
||||
bool use_grass);
|
||||
|
||||
@@ -331,9 +331,9 @@ void handle_scenario_menu(int item_hit) {
|
||||
giveError("You need to save the changes made to your scenario before you can add a new town.");
|
||||
return;
|
||||
}
|
||||
i = pick_import_town(0,file);
|
||||
if(i >= 0) {
|
||||
import_town(i,file);
|
||||
if(cTown* town = pick_import_town(0)) {
|
||||
delete scenario.towns[cur_town];
|
||||
scenario.towns[cur_town] = town;
|
||||
change_made = true;
|
||||
redraw_screen();
|
||||
}
|
||||
|
||||
@@ -1159,10 +1159,13 @@ void delete_last_town() {
|
||||
save_scenario();
|
||||
}
|
||||
|
||||
short pick_import_town(short def, fs::path& temp_file_to_load) {
|
||||
cTown* pick_import_town(short def) {
|
||||
cScenario temp_scenario;
|
||||
temp_file_to_load = nav_get_scenario();
|
||||
load_scenario(temp_file_to_load, temp_scenario);
|
||||
short town = pick_town_num("select-import-town", def, temp_scenario);
|
||||
fs::path path = nav_get_scenario();
|
||||
load_scenario(path, temp_scenario);
|
||||
short town_num = pick_town_num("select-import-town", def, temp_scenario);
|
||||
if(town_num < 0) return nullptr;
|
||||
cTown* town = temp_scenario.towns[town_num];
|
||||
temp_scenario.towns[town_num] = nullptr;
|
||||
return town;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ void edit_advanced_town();
|
||||
void edit_basic_dlog(short which_node);
|
||||
void edit_talk_node(short which_node);
|
||||
location pick_out(location default_loc);
|
||||
short pick_import_town(short def,fs::path& temp_file_to_load);
|
||||
cTown* pick_import_town(short def);
|
||||
bool new_town(short which_town);
|
||||
void edit_placed_item(short which_i);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user