Implement define= for mp scenarios and eras
Implemented reloading of configs with define= attributes in both mp_create and mp_wait::join_game(). Added myself to about.cfg and updated changelog. Conflicts: changelog src/gamestatus.cpp src/gamestatus.hpp src/multiplayer_wait.cpp
This commit is contained in:
parent
0f7b06cd1a
commit
b5fbda3530
9 changed files with 60 additions and 0 deletions
|
@ -87,6 +87,7 @@ Version 1.13.0-dev:
|
|||
* Added support for [elseif] tags inside [if]
|
||||
* Schema validator messages now conform better to the new WML
|
||||
parser/preprocessor diagnostics format introduced in version 1.11.10.
|
||||
* Added define= functionality to scenarios and eras.
|
||||
* Miscellaneous and bug fixes:
|
||||
* replace 'fight_on_without_leader'=yes/no with defeat_condition=no_leader/
|
||||
no_units/always/never which allows the wml developer to decide when a side
|
||||
|
|
|
@ -1174,6 +1174,10 @@
|
|||
email = "greywhind_AT_users.sourceforge.net"
|
||||
wikiuser = "Greywhind"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Nathan Walker (RiftWalker)"
|
||||
email = "nathan.b.walker@vanderbilt.edu"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Oleg Tsarev"
|
||||
email = "zabivator@gmail.com"
|
||||
|
|
|
@ -34,6 +34,8 @@ game_classification::game_classification():
|
|||
campaign_type(),
|
||||
campaign_define(),
|
||||
campaign_xtra_defines(),
|
||||
scenario_define(),
|
||||
era_define(),
|
||||
campaign(),
|
||||
abbrev(),
|
||||
completion(),
|
||||
|
@ -51,6 +53,8 @@ game_classification::game_classification(const config& cfg):
|
|||
campaign_type(lexical_cast_default<game_classification::CAMPAIGN_TYPE> (cfg["campaign_type"].str(), game_classification::SCENARIO)),
|
||||
campaign_define(cfg["campaign_define"]),
|
||||
campaign_xtra_defines(utils::split(cfg["campaign_extra_defines"])),
|
||||
scenario_define(cfg["scenario_define"]),
|
||||
era_define(cfg["era_define"]),
|
||||
campaign(cfg["campaign"]),
|
||||
abbrev(cfg["abbrev"]),
|
||||
completion(cfg["completion"]),
|
||||
|
@ -68,6 +72,8 @@ game_classification::game_classification(const game_classification& gc):
|
|||
campaign_type(gc.campaign_type),
|
||||
campaign_define(gc.campaign_define),
|
||||
campaign_xtra_defines(gc.campaign_xtra_defines),
|
||||
scenario_define(gc.scenario_define),
|
||||
era_define(gc.era_define),
|
||||
campaign(gc.campaign),
|
||||
abbrev(gc.abbrev),
|
||||
completion(gc.completion),
|
||||
|
@ -88,6 +94,8 @@ config game_classification::to_config() const
|
|||
cfg["campaign_type"] = lexical_cast<std::string> (campaign_type);
|
||||
cfg["campaign_define"] = campaign_define;
|
||||
cfg["campaign_extra_defines"] = utils::join(campaign_xtra_defines);
|
||||
cfg["scenario_define"] = scenario_define;
|
||||
cfg["era_define"] = era_define;
|
||||
cfg["campaign"] = campaign;
|
||||
cfg["abbrev"] = abbrev;
|
||||
cfg["completion"] = completion;
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
CAMPAIGN_TYPE campaign_type;
|
||||
std::string campaign_define; /**< If there is a define the campaign uses to customize data */
|
||||
std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
|
||||
std::string scenario_define; /**< If there is a define the scenario uses to customize data */
|
||||
std::string era_define; /**< If there is a define the era uses to customize data */
|
||||
|
||||
std::string campaign; /**< the campaign being played */
|
||||
|
||||
|
|
|
@ -375,6 +375,10 @@ void game_config_manager::load_game_config_for_game(
|
|||
!classification.difficulty.empty());
|
||||
game_config::scoped_preproc_define campaign(classification.campaign_define,
|
||||
!classification.campaign_define.empty());
|
||||
game_config::scoped_preproc_define scenario(classification.scenario_define,
|
||||
!classification.scenario_define.empty());
|
||||
game_config::scoped_preproc_define era(classification.era_define,
|
||||
!classification.era_define.empty());
|
||||
game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
|
||||
classification.campaign_type == game_classification::MULTIPLAYER);
|
||||
|
||||
|
|
|
@ -238,6 +238,8 @@ void create::process_event()
|
|||
}
|
||||
|
||||
engine_.prepare_for_campaign(difficulty);
|
||||
} else {
|
||||
engine_.prepare_for_scenario();
|
||||
}
|
||||
|
||||
engine_.prepare_for_new_level();
|
||||
|
|
|
@ -412,6 +412,25 @@ void create_engine::prepare_for_new_level()
|
|||
state_.mp_settings().hash = current_level().data().hash();
|
||||
}
|
||||
|
||||
void create_engine::prepare_for_scenario()
|
||||
{
|
||||
DBG_MP << "preparing data for campaign by reloading game config\n";
|
||||
|
||||
state_.classification().scenario_define =
|
||||
current_level().data()["define"].str();
|
||||
state_.classification().era_define =
|
||||
resources::config_manager->game_config().find_child(
|
||||
"era", "id", get_parameters().mp_era)["define"].str();
|
||||
|
||||
resources::config_manager->
|
||||
load_game_config_for_game(state_.classification());
|
||||
|
||||
current_level().set_data(
|
||||
resources::config_manager->game_config().find_child(
|
||||
lexical_cast<std::string> (game_classification::MULTIPLAYER),
|
||||
"id", current_level().data()["id"]));
|
||||
}
|
||||
|
||||
void create_engine::prepare_for_campaign(const std::string& difficulty)
|
||||
{
|
||||
DBG_MP << "preparing data for campaign by reloading game config\n";
|
||||
|
@ -431,6 +450,9 @@ void create_engine::prepare_for_campaign(const std::string& difficulty)
|
|||
current_level().data()["define"].str();
|
||||
state_.classification().campaign_xtra_defines =
|
||||
utils::split(current_level().data()["extra_defines"]);
|
||||
state_.classification().era_define =
|
||||
resources::config_manager->game_config().find_child(
|
||||
"era", "id", get_parameters().mp_era)["define"].str();
|
||||
|
||||
resources::config_manager->
|
||||
load_game_config_for_game(state_.classification());
|
||||
|
|
|
@ -180,6 +180,7 @@ public:
|
|||
void init_generated_level_data();
|
||||
|
||||
void prepare_for_new_level();
|
||||
void prepare_for_scenario();
|
||||
void prepare_for_campaign(const std::string& difficulty);
|
||||
void prepare_for_saved_game();
|
||||
|
||||
|
|
|
@ -237,6 +237,14 @@ void wait::join_game(bool observe)
|
|||
const config* campaign = &resources::config_manager->
|
||||
game_config().find_child("campaign", "id",
|
||||
level_.child("multiplayer")["mp_campaign"]);
|
||||
|
||||
const config* scenario = &resources::config_manager->
|
||||
game_config().find_child("multiplayer", "id",
|
||||
level_.child(lexical_cast<std::string>(game_classification::MULTIPLAYER))["id"]);
|
||||
|
||||
const config* era = &resources::config_manager->
|
||||
game_config().find_child("era", "id", level_.child("era")["id"]);
|
||||
|
||||
if (*campaign) {
|
||||
state_.classification().difficulty =
|
||||
level_.child("multiplayer")["difficulty_define"].str();
|
||||
|
@ -246,6 +254,14 @@ void wait::join_game(bool observe)
|
|||
utils::split((*campaign)["extra_defines"]);
|
||||
}
|
||||
|
||||
if (*scenario)
|
||||
state_.classification().scenario_define =
|
||||
(*scenario)["define"].str();
|
||||
|
||||
if (*era)
|
||||
state_.classification().era_define =
|
||||
(*era)["define"].str();
|
||||
|
||||
// Make sure that we have the same config as host, if possible.
|
||||
resources::config_manager->
|
||||
load_game_config_for_game(state_.classification());
|
||||
|
|
Loading…
Add table
Reference in a new issue