Skip to content

Commit

Permalink
Merge pull request #4671 from fluffbeast/map_file
Browse files Browse the repository at this point in the history
Backport map_file feature fixes for 1.14
  • Loading branch information
Vultraz committed Dec 29, 2019
2 parents 65dd82f + ee079d4 commit c650498
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/multiplayer/scenarios/2p_Aethermaw.cfg
Expand Up @@ -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}
Expand Down
14 changes: 12 additions & 2 deletions src/gui/dialogs/multiplayer/mp_create_game.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit c650498

Please sign in to comment.