Merge pull request #4671 from fluffbeast/map_file

Backport map_file feature fixes for 1.14
This commit is contained in:
Charles Dang 2019-12-28 19:52:23 -05:00 committed by GitHub
commit c650498f58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -4,7 +4,7 @@
name= _ "2p — Aethermaw"
# wmllint: local spellings Sulla Aethermaw Paterson
description= _ "Long ago, the Great Mage Sulla was imprisoned in the Aethermaw, a nexus of mystical energy whose chaotic nature was able to prevent her escape. Over the centuries, however, Sulla gradually attuned her powers to the maelstrom of disorder that is the Aethermaw, and has now begun to project its influence onto the material plane, drawing in entire regions of land from hundreds of different worlds, realities and time-periods. She experiments with these disparate pieces of the cosmos, manipulating them, merging them and sending them back and forth between the Aethermaw and their place of origin. Perhaps, as her mastery over the Aethermaw grows, Sulla will one day break free of its bonds. Until that time comes, she will continue to amuse herself by arranging battles between the mortal beings unlucky enough to be drawn into its depths. Designed by Doc Paterson."
map_data="{multiplayer/maps/2p_Aethermaw.map}"
map_file=multiplayer/maps/2p_Aethermaw.map
random_start_time="no"
{DEFAULT_SCHEDULE}

View file

@ -16,6 +16,7 @@
#include "gui/dialogs/multiplayer/mp_create_game.hpp"
#include "filesystem.hpp"
#include "game_config_manager.hpp"
#include "game_initialization/lobby_data.hpp"
#include "gettext.hpp"
@ -672,7 +673,9 @@ void mp_create_game::update_details(window& win)
if(create_engine_.current_level_type() == ng::level::TYPE::RANDOM_MAP) {
// If the current random map doesn't have data, generate it
if(create_engine_.generator_assigned() && create_engine_.current_level().data()["map_data"].empty()) {
if(create_engine_.generator_assigned() &&
create_engine_.current_level().data()["map_data"].empty() &&
create_engine_.current_level().data()["map_file"].empty()) {
create_engine_.init_generated_level_data();
}
@ -705,7 +708,14 @@ void mp_create_game::update_details(window& win)
create_engine_.get_state().classification().campaign = "";
find_widget<stacked_widget>(&win, "minimap_stack", false).select_layer(0);
find_widget<minimap>(&win, "minimap", false).set_map_data(current_scenario->data()["map_data"]);
const std::string map_data = !current_scenario->data()["map_data"].empty()
? current_scenario->data()["map_data"]
: filesystem::read_map(current_scenario->data()["map_file"]);
if (current_scenario->data()["map_data"].empty()) {
current_scenario->data()["map_data"] = map_data;
current_scenario->set_metadata();
}
find_widget<minimap>(&win, "minimap", false).set_map_data(map_data);
players.set_label(std::to_string(current_scenario->num_players()));
map_size.set_label(current_scenario->map_size());