Finish implementation of creating a new scenario

This commit is contained in:
2015-02-03 15:35:32 -05:00
parent fcd29fb2ac
commit 2728b06f1a
6 changed files with 169 additions and 518 deletions

View File

@@ -129,7 +129,8 @@ cOutdoors::cOutdoors(cScenario& scenario, bool init_strings) : scenario(scenario
for(i = 0; i < 48; i++)
for(j = 0; j < 48; j++) {
terrain[i][j] = 5; // formerly 0
terrain[i][j] = scenario.default_ground;
special_spot[i][j] = false;
}
for(i = 0; i < 8; i++) {

View File

@@ -270,7 +270,7 @@ unsigned char& cBigTown::lighting(size_t i, size_t r){
cBigTown::cBigTown(cScenario& scenario, bool init_strings) : cTown(scenario, init_strings) {
for(size_t i = 0; i < max_dim(); i++)
for(size_t j = 0; j < max_dim(); j++) {
terrain(i,j) = scenario.default_ground * 2;
terrain(i,j) = scenario.default_ground;
lighting(i / 8,j) = 0;
}
init_start();
@@ -279,7 +279,7 @@ cBigTown::cBigTown(cScenario& scenario, bool init_strings) : cTown(scenario, ini
cMedTown::cMedTown(cScenario& scenario, bool init_strings) : cTown(scenario, init_strings) {
for(size_t i = 0; i < max_dim(); i++)
for(size_t j = 0; j < max_dim(); j++) {
terrain(i,j) = scenario.default_ground * 2;
terrain(i,j) = scenario.default_ground;
lighting(i / 8,j) = 0;
}
init_start();
@@ -288,7 +288,7 @@ cMedTown::cMedTown(cScenario& scenario, bool init_strings) : cTown(scenario, ini
cTinyTown::cTinyTown(cScenario& scenario, bool init_strings) : cTown(scenario, init_strings) {
for(size_t i = 0; i < max_dim(); i++)
for(size_t j = 0; j < max_dim(); j++) {
terrain(i,j) = scenario.default_ground * 2;
terrain(i,j) = scenario.default_ground;
lighting(i / 8,j) = 0;
}
init_start();

View File

@@ -56,7 +56,7 @@ cScenario::cScenario(bool init_strings) {
format.ver[0] = 1;
format.min_run_ver = 2;
format.prog_make_ver[0] = 2;
default_ground = 1;
default_ground = 2;
where_start.x = 24;
where_start.y = 24;
out_start = where_start;
@@ -111,7 +111,7 @@ void cScenario::append(legacy::scenario_data_type& old){
int i,j;
difficulty = old.difficulty;
intro_pic = old.intro_pic;
default_ground = old.default_ground;
default_ground = old.default_ground * 2;
intro_mess_pic = old.intro_pic;
where_start.x = old.where_start.x;
where_start.y = old.where_start.y;

View File

@@ -26,6 +26,7 @@
extern short cen_x, cen_y,cur_town;
extern bool mouse_button_held;
extern bool editing_town;
extern short cur_viewing_mode;
extern cTown* town;
extern cOutdoors* current_terrain;
@@ -2454,9 +2455,9 @@ static bool edit_make_scen_2_event_filter(cDialog& me, std::string, eKeyMod) {
j = me["out-h"].getTextAsNum();
if(cre(j, 1,50,"Outdoors height must be between 1 and 50.","",&me)) return true;
if(cre(i * j, 1,100,"The total number of outdoor sections (width times height) must be between 1 and 100.","",&me)) return true;
i = me["town_s"].getTextAsNum();
j = me["town_m"].getTextAsNum();
k = me["town_l"].getTextAsNum();
i = me["town-s"].getTextAsNum();
j = me["town-m"].getTextAsNum();
k = me["town-l"].getTextAsNum();
if(cre(i, 0,200,"Number of small towns must be between 0 and 200.","",&me)) return true;
if(cre(j, 1,200,"Number of medium towns must be between 1 and 200. The first town (Town 0) must always be of medium size.","",&me)) return true;
if(cre(k, 0,200,"Number of large towns must be between 0 and 200.","",&me)) return true;
@@ -2473,7 +2474,7 @@ bool edit_make_scen_2(short& out_w, short& out_h, short& town_l, short& town_m,
new_dlog.setResult(false);
new_dlog.run();
if(!new_dlog.getResult<bool>()) return false;
if(!new_dlog.accepted()) return false;
out_w = new_dlog["out-w"].getTextAsNum();
out_h = new_dlog["out-h"].getTextAsNum();
@@ -2487,65 +2488,198 @@ bool edit_make_scen_2(short& out_w, short& out_h, short& town_l, short& town_m,
extern fs::path progDir;
extern eScenMode overall_mode;
bool build_scenario() {
short width, height, lg, med, sm, which_town;
short width, height, lg, med, sm;
bool default_town, grass;
std::string filename, title;
short i,j;
cTown* warriors_grove = nullptr;
std::vector<cShop> warriors_grove_shops;
if(!edit_make_scen_1(filename, title, grass))
return false;
filename += ".boes";
if(!edit_make_scen_2(width, height, lg, med, sm, default_town))
return false;
scenario = cScenario(true);
scenario.scen_name = title;
if(!default_town) {
scenario.addTown<cMedTown>();
if(!grass)
for(i = 0; i < 48; i++)
for(j = 0; j < 48; j++)
town->terrain(i,j) = 0;
} else {
scenario.default_ground = grass ? 2 : 0;
fs::path basePath = progDir/"Scenario Editor"/"Blades of Exile Base"/"bladbase.exs";
if(!fs::exists(basePath)) {oopsError(40);}
cScenario base;
load_scenario(basePath, base);
// Load in all terrains, items, and monsters
std::swap(scenario.ter_types, base.ter_types);
std::swap(scenario.scen_items, base.scen_items);
std::swap(scenario.scen_monsters, base.scen_monsters);
if(default_town) {
warriors_grove = base.towns[0];
std::swap(warriors_grove_shops, base.shops);
base.towns[0] = nullptr;
if(!grass) {
// Go through and replace all surface terrains with similar cave terrains
// Note that this assumes the default terrain set is unchanged.
for(int x = 0; x < warriors_grove->max_dim(); x++) {
for(int y = 0; y < warriors_grove->max_dim(); y++) {
ter_num_t ter_there = warriors_grove->terrain(x,y);
if(ter_there >= 36 && ter_there <= 49 && ter_there != 37) // Hills
ter_there = 0;
else if(ter_there >= 50 && ter_there <= 62) // Water
ter_there = 71;
else switch(ter_there) {
// Mountains
case 22: case 23: ter_there = 5; break;
case 24: ter_there = 6; break;
case 25: ter_there = 8; break;
case 26: ter_there = 9; break;
case 27: ter_there = 11; break;
case 28: ter_there = 12; break;
case 29: ter_there = 14; break;
case 30: ter_there = 15; break;
case 31: ter_there = 17; break;
case 32: ter_there = 18; break;
case 33: ter_there = 19; break;
case 34: ter_there = 20; break;
case 35: ter_there = 21; break;
// Water stuff
case 63: case 64: ter_there = 74; break;
case 65: case 66: case 67: ter_there = 73; break;
case 68: case 69: case 70: ter_there = 72; break;
// Rubble
case 87: case 88: case 89: ter_there -= 3; break;
// Vegetation and stuff
case 2: ter_there = 0; break;
case 3: case 4: ter_there = 1; break;
case 110: case 112: ter_there = 97; break;
case 111: ter_there = 96; break;
case 113: ter_there = 91; break;
case 114: case 37: ter_there = 98; break;
case 115: ter_there = 92; break;
case 118: ter_there = 94; break;
// Artificial stuff - walkways, fences, signs
case 83: ter_there = 82; break;
case 116: case 119: ter_there = 99; break;
case 117: case 120: ter_there = 100; break;
case 121: ter_there = 106; break;
}
warriors_grove->terrain(x,y) = ter_there;
}
}
}
if(med > 0) med--;
// TODO: This will probably change drastically once the new scenario format is implemented
}
make_new_scenario(filename,width,height,default_town,grass);
scenario.shops.push_back(cShop('heal'));
overall_mode = MODE_MAIN_SCREEN;
editing_town = false;
scenario.outdoors.resize(width, height);
for(int x = 0; x < width; x++) {
for(int y = 0; y < height; y++) {
scenario.outdoors[x][y] = new cOutdoors(scenario);
// Add borders
if(x == 0) {
for(int i = 0; i < 48; i++) {
scenario.outdoors[x][y]->terrain[0][i] = grass ? 23 : 5;
scenario.outdoors[x][y]->terrain[1][i] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[2][i] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[3][i] = grass ? 22 : 5;
if(grass)
scenario.outdoors[x][y]->terrain[4][i] = 36;
}
}
if(x == width - 1) {
for(int i = 0; i < 48; i++) {
scenario.outdoors[x][y]->terrain[47][i] = grass ? 23 : 5;
scenario.outdoors[x][y]->terrain[46][i] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[45][i] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[44][i] = grass ? 22 : 5;
if(grass)
scenario.outdoors[x][y]->terrain[43][i] = 36;
}
}
if(y == 0) {
for(int i = 0; i < 48; i++) {
scenario.outdoors[x][y]->terrain[i][0] = grass ? 23 : 5;
scenario.outdoors[x][y]->terrain[i][1] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[i][2] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[i][3] = grass ? 22 : 5;
if(grass && scenario.outdoors[x][y]->terrain[i][4] == 2)
scenario.outdoors[x][y]->terrain[i][4] = 36;
}
}
if(y == height - 1) {
for(int i = 0; i < 48; i++) {
scenario.outdoors[x][y]->terrain[i][47] = grass ? 23 : 5;
scenario.outdoors[x][y]->terrain[i][46] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[i][45] = grass ? 22 : 5;
scenario.outdoors[x][y]->terrain[i][44] = grass ? 22 : 5;
if(grass && scenario.outdoors[x][y]->terrain[i][43] == 2)
scenario.outdoors[x][y]->terrain[i][43] = 36;
}
}
// Minor fixup for mountain corners
if(grass) {
if(x == 0 && y == 0) {
scenario.outdoors[x][y]->terrain[0][1] = 23;
scenario.outdoors[x][y]->terrain[0][2] = 23;
scenario.outdoors[x][y]->terrain[0][3] = 23;
}
if(x == 0 && y == height - 1) {
scenario.outdoors[x][y]->terrain[0][46] = 23;
scenario.outdoors[x][y]->terrain[0][45] = 23;
scenario.outdoors[x][y]->terrain[0][44] = 23;
}
if(x == width - 1 && y == 0) {
scenario.outdoors[x][y]->terrain[47][1] = 23;
scenario.outdoors[x][y]->terrain[47][2] = 23;
scenario.outdoors[x][y]->terrain[47][3] = 23;
}
if(x == width - 1 && y == height - 1) {
scenario.outdoors[x][y]->terrain[47][46] = 23;
scenario.outdoors[x][y]->terrain[47][45] = 23;
scenario.outdoors[x][y]->terrain[47][44] = 23;
}
}
current_terrain = scenario.outdoors[x][y];
if(x == 0 || y == 0)
adjust_space(loc(3,3));
if(x == width - 1 || y == height - 1)
adjust_space(loc(44,44));
}
}
cur_out.x = 0;
cur_out.y = 0;
current_terrain = scenario.outdoors[0][0];
current_terrain->terrain[24][24] = grass ? 234 : 232;
current_terrain->terrain[23][23] = grass ? 121 : 106;
if(default_town && warriors_grove)
if(default_town && warriors_grove) {
scenario.towns.push_back(warriors_grove);
std::swap(scenario.shops, warriors_grove_shops);
}
// TODO: Append i+1 to each town name
for(i = 0; i < lg; i++) {
scenario.addTown<cBigTown>();
town->town_name = "Large town";
scenario.towns.back()->town_name = "Large town " + std::to_string(i + 1);
}
for(i = 0; i < med; i++) {
scenario.addTown<cMedTown>();
town->town_name = "Medium town";
scenario.towns.back()->town_name = "Medium town " + std::to_string(i + 1);
}
for(i = 0; i < sm; i++) {
scenario.addTown<cTinyTown>();
town->town_name = "Small town";
scenario.towns.back()->town_name = "Small town " + std::to_string(i + 1);
}
cur_town = 0;
town = scenario.towns[0];
update_item_menu();
return false;
save_scenario(progDir/filename);
return true;
}
static bool check_location_bounds(cDialog& me, std::string id, bool losing) {

View File

@@ -853,487 +853,6 @@ void save_scenario(fs::path toFile) {
zout.close();
}
void create_basic_scenario() {
// short i,j,k,num_outdoors;
// FSSpec to_load,new_file,dummy_file;
// NavReplyRecord reply;
// short dummy_f;
// char *buffer = NULL;
// Size buf_len = 100000;
// OSErr error;
// short out_num;
// long len;
// char message[256] = "Select saved game: ";
// legacy::big_tr_type t_d;
// legacy::ave_tr_type ave_t;
// legacy::tiny_tr_type tiny_t;
//
// //FSMakeFSSpec(start_volume,start_dir,"Blades of Exile Base",&new_file);
//
// //FSpDelete(&new_file);
// //error = FSpCreate(&new_file,'blx!','BETM',smSystemScript);
// //OK. FIrst find out what file name we're working with, and make the dummy file
// // which we'll build the new scenario in
// //to_load = store_file_reply;
// FSMakeFSSpec(start_volume,start_dir,"::::Blades of Exile Base",&dummy_file);
// FSpDelete(&dummy_file);
// error = FSpCreate(&dummy_file,'blx!','BETM',reply.keyScript);
// if((error != 0) && (error != dupFNErr)) {
// //add_string_to_buf("Save: Couldn't create file. ");
// SysBeep(2);
// return;
// }
// if((error = FSpOpenDF(&dummy_file,3,&dummy_f)) != 0) {
// SysBeep(2);
// return;
// }
//
//
// // Now we need to set up a buffer for moving the data over to the dummy
// buffer = (char *) NewPtr(buf_len);
// if(buffer == NULL) {
// SysBeep(2); FSClose(dummy_f);
// return;
// }
//
// cur_town = 0;
// scenario.num_towns = 1;
// scenario.town_size[0] = 1;
// scenario.out_width = 1;
// scenario.out_height = 1;
// cur_out.x = 0;
// cur_out.y = 0;
// scenario.last_out_edited = cur_out;
// // We're finally set up. Let's first set up the new scenario field
// // We need the new info for the current town and outdoors, which may have been changed
// scenario.town_data_size[cur_town][0] = sizeof(legacy::town_record_type);
// if(scenario.town_size[cur_town] == 0)
// scenario.town_data_size[cur_town][0] += sizeof(legacy::big_tr_type);
// else if(scenario.town_size[cur_town] == 1)
// scenario.town_data_size[cur_town][0] += sizeof(legacy::ave_tr_type);
// else scenario.town_data_size[cur_town][0] += sizeof(legacy::tiny_tr_type);
// scenario.town_data_size[cur_town][1] = 0;
// for(i = 0; i < 60; i++)
// scenario.town_data_size[cur_town][1] += strlen(data_store->town_strs[i]);
// scenario.town_data_size[cur_town][2] = 0;
// for(i = 60; i < 140; i++)
// scenario.town_data_size[cur_town][2] += strlen(data_store->town_strs[i]);
// scenario.town_data_size[cur_town][3] = sizeof(legacy::talking_record_type);
// for(i = 0; i < 80; i++)
// scenario.town_data_size[cur_town][3] += strlen(data_store->talk_strs[i]);
// scenario.town_data_size[cur_town][4] = 0;
// for(i = 80; i < 170; i++)
// scenario.town_data_size[cur_town][4] += strlen(data_store->talk_strs[i]);
//
// out_num = cur_out.y * scenario.out_width + cur_out.x;
// scenario.out_data_size[out_num][0] = sizeof(legacy::outdoor_record_type);
// scenario.out_data_size[out_num][1] = 0;
// for(i = 0; i < 120; i++)
// scenario.out_data_size[out_num][1] += strlen(data_store->out_strs[i]);
//
// for(i = 0; i < 300; i++)
// scenario.scen_str_len[i] = 0;
// for(i = 0; i < 270; i++)
// scenario.scen_str_len[i] = strlen(data_store->scen_strs[i]);
// scenario.last_town_edited = cur_town;
// scenario.last_out_edited = cur_out;
//
// // now write scenario data
// scenario.format.flag1 = 10;
// scenario.format.flag2 = 20;
// scenario.format.flag3 = 30;
// scenario.format.flag4 = 40; /// these mean made on mac
// len = sizeof(legacy::scenario_data_type); // scenario data
// if((error = FSWrite(dummy_f, &len, (char *) &scenario)) != 0) {
// SysBeep(2); FSClose(dummy_f);
// return;
// }
// len = sizeof(scen_item_data_type); // item data
// if((error = FSWrite(dummy_f, &len, (char *) &(data_store->scen_item_list))) != 0) {
// SysBeep(2); FSClose(dummy_f);
// return;
// }
// for(i = 0; i < 270; i++) { // scenario strings
// len = (long) scenario.scen_str_len[i];
// if((error = FSWrite(dummy_f, &len, (char *) &(data_store->scen_strs[i]))) != 0) {
// SysBeep(2); FSClose(dummy_f);
// return;
// }
// }
//
// // OK ... scenario written. Now outdoors.
// num_outdoors = scenario.out_width * scenario.out_height;
// for(i = 0; i < num_outdoors; i++)
// if(i == out_num) {
// // write outdoors
// for(j = 0; j < 180; j++)
// current_terrain.strlens[j] = 0;
// for(j = 0; j < 120; j++)
// current_terrain.strlens[j] = strlen(data_store->out_strs[j]);
// len = sizeof(legacy::outdoor_record_type);
// FSWrite(dummy_f, &len, (char *) &current_terrain);
//
// for(j = 0; j < 120; j++) {
// len = (long) current_terrain.strlens[j];
// FSWrite(dummy_f, &len, (char *) &(data_store->out_strs[j]));
// }
// }
//
// // now, finally, write towns.
// for(k = 0; k < scenario.num_towns; k++)
// if(k == cur_town) {
// for(i = 0; i < 180; i++)
// town->strlens[i] = 0;
// for(i = 0; i < 140; i++)
// town->strlens[i] = strlen(data_store->town_strs[i]);
//
// // write towns
// len = sizeof(legacy::town_record_type);
// FSWrite(dummy_f, &len, (char *) &town);
//
// switch(scenario.town_size[cur_town]) {
// case 0:
// len = sizeof(legacy::big_tr_type);
// FSWrite(dummy_f, &len, (char *) &t_d);
// break;
//
// case 1:
// for(i = 0; i < 48; i++)
// for(j = 0; j < 48; j++) {
// ave_t.terrain[i][j] = town->terrain(i,j);
// ave_t.lighting[i / 8][j] = town->lighting(i / 8,j);
// }
// for(i = 0; i < 16; i++) {
// ave_t.room_rect[i] = town->room_rect(i);
// }
// for(i = 0; i < 40; i++) {
// //ave_t.creatures[i] = town->creatures(i);
// }
// len = sizeof(legacy::ave_tr_type);
// FSWrite(dummy_f, &len, (char *) &ave_t);
// break;
//
//
// case 2:
// for(i = 0; i < 32; i++)
// for(j = 0; j < 32; j++) {
// tiny_t.terrain[i][j] = town->terrain(i,j);
// tiny_t.lighting[i / 8][j] = town->lighting(i / 8,j);
// }
// for(i = 0; i < 16; i++) {
// tiny_t.room_rect[i] = town->room_rect(i);
// }
// for(i = 0; i < 30; i++) {
// //tiny_t.creatures[i] = town->creatures(i);
// }
// len = sizeof(legacy::tiny_tr_type);
// FSWrite(dummy_f, &len, (char *) &tiny_t);
// break;
// }
// for(j = 0; j < 140; j++) {
// len = (long) town->strlens[j];
// FSWrite(dummy_f, &len, (char *) &(data_store->town_strs[j]));
// }
//
// for(i = 0; i < 200; i++)
// talking.strlens[i] = 0;
// for(i = 0; i < 170; i++)
// talking.strlens[i] = strlen(data_store->talk_strs[i]);
// len = sizeof(legacy::talking_record_type);
// FSWrite(dummy_f, &len, (char *) &talking);
// for(j = 0; j < 170; j++) {
// len = (long) talking.strlens[j];
// FSWrite(dummy_f, &len, (char *) &(data_store->talk_strs[j]));
// }
//
// }
//
//
// // now, everything is moved over. Delete the original, and rename the dummy
// FSClose(dummy_f);
// DisposePtr(buffer);
giveError("Scenario not created; creation currently disabled.");
}
// 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*/) {
// short i,j,k,num_outdoors;
// FSSpec dummy_file;
// NavReplyRecord reply;
// short dummy_f,file_id;
// Size buf_len = 100000;
// OSErr error;
// short out_num;
// long len,scen_ptr_move = 0,save_town_size = 0,save_out_size = 0;
// location loc;
// short x,y;
// legacy::big_tr_type t_d;
// legacy::ave_tr_type ave_t;
// legacy::tiny_tr_type tiny_t;
//
// // Step 1 - load scenario file from scenario base. It contains all the monsters and
// // items done up properly!
// error = FSMakeFSSpec(start_volume,start_dir,"::::Blades of Exile Base",&temp_file_to_load);
// if(error != 0) {oops_error(80);}
//
// if((error = FSpOpenDF(&temp_file_to_load,1,&file_id)) != 0) {
// give_error("Could not find the file 'Blades of Exile Base', which needs to be in the Scenario Editor folder. If you no longer have it, you need to redownload Blades of Exile.","",0);
// oops_error(81); return;
// }
//
// len = (long) sizeof(legacy::scenario_data_type);
// if((error = FSRead(file_id, &len, (char *) &scenario)) != 0){
// FSClose(file_id); oops_error(82); return;
// }
//
// len = sizeof(scen_item_data_type); // item data
// if((error = FSRead(file_id, &len, (char *) &(data_store->scen_item_list))) != 0){
// FSClose(file_id); oops_error(83); return;
// }
// for(i = 0; i < 270; i++) {
// len = (long) (scenario.scen_str_len[i]);
// FSRead(file_id, &len, (char *) &(data_store->scen_strs[i]));
// data_store->scen_strs[i][len] = 0;
// }
// FSClose(file_id);
//
// char newname[256] = "::::";
// strcat((char*)newname,(char*)file_name);
//
// // now write scenario
// c2pstr((char*) newname);
//
// //OK. FIrst find out what file name we're working with, and make the dummy file
// // which we'll build the new scenario in Blades of Exile Base
// FSMakeFSSpec(file_to_load.vRefNum,file_to_load.parID,newname,&dummy_file);
// FSpDelete(&dummy_file);
// error = FSpCreate(&dummy_file,'blx!','BETM',smSystemScript);
// if((error != 0) && (error != dupFNErr)) {
// oops_error(1);
// return;
// }
// if((error = FSpOpenDF(&dummy_file,3,&dummy_f)) != 0) {
// oops_error(2);
// return;
// }
//
//
// scenario.format.prog_make_ver[0] = 1;
// scenario.format.prog_make_ver[1] = 0;
// scenario.format.prog_make_ver[2] = 0;
// cur_town = 0;
// scenario.num_towns = 1;
// scenario.town_size[0] = 1;
// scenario.out_width = out_width;
// scenario.out_height = out_height;
// cur_out.x = 0;
// cur_out.y = 0;
// scenario.last_out_edited = cur_out;
//
// // We're finally set up. Let's first set up the new scenario field
// // We need the new info for the current town and outdoors, which may have been changed
// scenario.town_data_size[cur_town][0] = sizeof(legacy::town_record_type);
// if(scenario.town_size[cur_town] == 0)
// scenario.town_data_size[cur_town][0] += sizeof(legacy::big_tr_type);
// else if(scenario.town_size[cur_town] == 1)
// scenario.town_data_size[cur_town][0] += sizeof(legacy::ave_tr_type);
// else scenario.town_data_size[cur_town][0] += sizeof(legacy::tiny_tr_type);
// scenario.town_data_size[cur_town][1] = 0;
// for(i = 0; i < 60; i++)
// scenario.town_data_size[cur_town][1] += strlen(data_store->town_strs[i]);
// scenario.town_data_size[cur_town][2] = 0;
// for(i = 60; i < 140; i++)
// scenario.town_data_size[cur_town][2] += strlen(data_store->town_strs[i]);
// scenario.town_data_size[cur_town][3] = sizeof(legacy::talking_record_type);
// for(i = 0; i < 80; i++)
// scenario.town_data_size[cur_town][3] += strlen(data_store->talk_strs[i]);
// scenario.town_data_size[cur_town][4] = 0;
// for(i = 80; i < 170; i++)
// scenario.town_data_size[cur_town][4] += strlen(data_store->talk_strs[i]);
//
// num_outdoors = scenario.out_width * scenario.out_height;
// for(i = 0; i < num_outdoors; i++) {
// scenario.out_data_size[i][0] = sizeof(legacy::outdoor_record_type);
// scenario.out_data_size[i][1] = 0;
// for(j = 0; j < 120; j++)
// scenario.out_data_size[i][1] += strlen(data_store->out_strs[j]);
// }
//
// for(i = 0; i < 300; i++)
// scenario.scen_str_len[i] = 0;
// for(i = 0; i < 270; i++)
// scenario.scen_str_len[i] = strlen(data_store->scen_strs[i]);
// scenario.last_town_edited = cur_town;
// scenario.last_out_edited = cur_out;
//
// // now write scenario data
// scenario.format.flag1 = 10;
// scenario.format.flag2 = 20;
// scenario.format.flag3 = 30;
// scenario.format.flag4 = 40; /// these mean made on mac
// // now flags
// scenario.flag_a = sizeof(legacy::scenario_data_type) + get_ran(1,-1000,1000);
// scenario.flag_b = town_s(user_given_password);
// scenario.flag_c = out_s(user_given_password);
// scenario.flag_e = str_size_1(user_given_password);
// scenario.flag_f = str_size_2(user_given_password);
// scenario.flag_h = str_size_3(user_given_password);
// scenario.flag_g = 10000 + get_ran(1,0,5000);
// scenario.flag_d = init_data(user_given_password);
//
// len = sizeof(legacy::scenario_data_type); // scenario data
// scen_ptr_move += len;
// if((error = FSWrite(dummy_f, &len, (char *) &scenario)) != 0) {
// FSClose(dummy_f);
// oops_error(3);
// return;
// }
// len = sizeof(scen_item_data_type); // item data
// scen_ptr_move += len;
// if((error = FSWrite(dummy_f, &len, (char *) &(data_store->scen_item_list))) != 0) {
// FSClose(dummy_f);
// oops_error(4);
// return;
// }
// for(i = 0; i < 270; i++) { // scenario strings
// len = (long) scenario.scen_str_len[i];
// scen_ptr_move += len;
// if((error = FSWrite(dummy_f, &len, (char *) &(scenario.scen_strs(i)))) != 0) {
// FSClose(dummy_f);oops_error(5);
// return;
// }
// }
//
//
// // OK ... scenario written. Now outdoors.
// num_outdoors = scenario.out_width * scenario.out_height;
// for(i = 0; i < num_outdoors; i++)
// {
// loc.x = i % scenario.out_width;
// loc.y = i / scenario.out_width;
//
// for(x = 0; x < 48; x++)
// for(y = 0; y < 48; y++) {
// current_terrain.terrain[x][y] = (use_grass > 0) ? 2 : 0;
//
// if((x < 4) && (loc.x == 0))
// current_terrain.terrain[x][y] = (use_grass > 0) ? 22 : 5;
// if((y < 4) && (loc.y == 0))
// current_terrain.terrain[x][y] = (use_grass > 0) ? 22 : 5;
// if((x > 43) && (loc.x == scenario.out_width - 1))
// current_terrain.terrain[x][y] = (use_grass > 0) ? 22 : 5;
// if((y > 43) && (loc.y == scenario.out_height - 1))
// current_terrain.terrain[x][y] = (use_grass > 0) ? 22 : 5;
// if((i == 0) && (making_warriors_grove > 0)) {
// current_terrain.terrain[24][24] = (use_grass > 0) ? 234 : 232;
// current_terrain.exit_locs[0].x = 24;
// current_terrain.exit_locs[0].y = 24;
// current_terrain.exit_dests[0] = 0;
// }
// else current_terrain.exit_locs[0].x = 100;
// }
//
// // write outdoors
// for(j = 0; j < 180; j++)
// current_terrain.strlens[j] = 0;
// for(j = 0; j < 120; j++)
// current_terrain.strlens[j] = strlen(current_terrain.out_strs(j));
// len = sizeof(legacy::outdoor_record_type);
// error = FSWrite(dummy_f, &len, (char *) &current_terrain);
// if(error != 0) {FSClose(dummy_f);oops_error(6);}
//
// for(j = 0; j < 120; j++) {
// len = (long) current_terrain.strlens[j];
// error = FSWrite(dummy_f, &len, (char *) &(current_terrain.out_strs(j)));
// if(error != 0) {
// FSClose(dummy_f);
// oops_error(7);
// }
// }
// }
//
//
// // now, finally, write towns.
// for(k = 0; k < scenario.num_towns; k++)
// {
// for(i = 0; i < 180; i++)
// town->strlens[i] = 0;
// for(i = 0; i < 140; i++)
// town->strlens[i] = strlen(town->town_strs[i]);
//
// // write towns
// len = sizeof(legacy::town_record_type);
// error = FSWrite(dummy_f, &len, (char *) &town);
// if(error != 0) {FSClose(dummy_f);oops_error(8);}
//
// switch(scenario.town_size[cur_town]) {
// case 0:
// len = sizeof(legacy::big_tr_type);
// FSWrite(dummy_f, &len, (char *) &t_d);
// break;
//
// case 1:
// for(i = 0; i < 48; i++)
// for(j = 0; j < 48; j++) {
// ave_t.terrain[i][j] = town->terrain(i,j);
// ave_t.lighting[i / 8][j] = town->lighting(i / 8,j);
// }
// for(i = 0; i < 16; i++) {
// ave_t.room_rect[i] = town->room_rect(i);
// }
// for(i = 0; i < 40; i++) {
// //ave_t.creatures[i] = town->creatures(i);
// }
// len = sizeof(legacy::ave_tr_type);
// FSWrite(dummy_f, &len, (char *) &ave_t);
// break;
//
//
// case 2:
// for(i = 0; i < 32; i++)
// for(j = 0; j < 32; j++) {
// tiny_t.terrain[i][j] = town->terrain(i,j);
// tiny_t.lighting[i / 8][j] = town->lighting(i / 8,j);
// }
// for(i = 0; i < 16; i++) {
// tiny_t.room_rect[i] = town->room_rect(i);
// }
// for(i = 0; i < 30; i++) {
// //tiny_t.creatures[i] = town->creatures(i);
// }
// len = sizeof(legacy::tiny_tr_type);
// FSWrite(dummy_f, &len, (char *) &tiny_t);
// break;
// }
// for(j = 0; j < 140; j++) {
// len = (long) town->strlens[j];
// FSWrite(dummy_f, &len, (char *) &(town->town_strs[j]));
// }
//
// for(i = 0; i < 200; i++)
// talking.strlens[i] = 0;
// for(i = 0; i < 170; i++)
// talking.strlens[i] = strlen(town->talk_strs[i]);
// len = sizeof(legacy::talking_record_type);
// error = FSWrite(dummy_f, &len, (char *) &talking);
// if(error != 0) {FSClose(dummy_f);oops_error(9);}
// for(j = 0; j < 170; j++) {
// len = (long) talking.strlens[j];
// FSWrite(dummy_f, &len, (char *) &(town->talk_strs[j]));
// }
//
// }
//
//
// change_made = true;
// // now, everything is moved over. Delete the original, and rename the dummy
// error = FSClose(dummy_f);
// if(error != 0) {FSClose(dummy_f);oops_error(10);}
// file_to_load = dummy_file;
giveError("Scenario not created; creation is currently disabled.");
}
void start_data_dump() {
short i;
using std::endl;

View File

@@ -1,8 +1,5 @@
void save_scenario(fs::path toFile);
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);
void start_data_dump();
void scen_text_dump();