Fix some issues with loading/saving new-format scenarios

- Terrain was saved rotated and was not loaded
- Graphics were not loaded (also for old-format scenarios)
- Crashed when attempting to convert a scenario without custom graphics
This commit is contained in:
2015-02-11 17:01:32 -05:00
parent 1894b31e20
commit bb98455e4f
3 changed files with 15 additions and 11 deletions

View File

@@ -2102,17 +2102,20 @@ void load_spec_graphics_v1(fs::path scen_file) {
spec_scen_g.sheets[0].loadFromImage(graphics_store);
}
}
reload_core_graphics();
}
void load_spec_graphics_v2(int num_sheets) {
if(num_sheets == 0) return;
spec_scen_g.clear();
spec_scen_g.sheets = new sf::Texture[num_sheets];
spec_scen_g.numSheets = num_sheets;
while(num_sheets--) {
if(num_sheets > 0) {
spec_scen_g.sheets = new sf::Texture[num_sheets];
spec_scen_g.numSheets = num_sheets;
}
while(num_sheets-- > 0) {
std::string name = "sheet" + std::to_string(num_sheets);
spec_scen_g.sheets[num_sheets].loadFromImage(*ResMgr::get<ImageRsrc>(name));
}
reload_core_graphics();
}
void reload_core_graphics() {

View File

@@ -24,14 +24,14 @@ map_data load_map(std::istream& fin, bool isTown) {
int n = 0, col = 0;
eMapFeature curFeature = eMapFeature::NONE;
// vehicle_owned = true means the party owns it
bool vehicle_owned;
bool vehicle_owned, found_something;
for(char c : line) {
if(c == '#') break; // Found a comment
if(isblank(c)) continue;
found_something = true;
if(isdigit(c)) {
n *= 10;
n += c - '0';
} else if(isblank(c)) {
continue;
} else if(c == '^' && isTown) {
data.addFeature(col, row, eMapFeature::ENTRANCE_NORTH);
} else if(c == '<' && isTown) {
@@ -85,6 +85,7 @@ map_data load_map(std::istream& fin, bool isTown) {
}
}
}
row++;
}
return data;
}
@@ -126,9 +127,9 @@ void map_data::writeTo(std::ostream& out) {
unsigned int width = std::accumulate(grid.begin(), grid.end(), 0, [](size_t m, std::vector<int>& v){
return std::max(m, v.size());
});
for(unsigned int x = 0; x < width; x++) {
for(unsigned int y = 0; y < height; y++) {
bool first = true;
for(unsigned int y = 0; y < height; y++) {
for(unsigned int x = 0; x < width; x++) {
if(!first) out << ',';
first = false;
out << grid[y][x];