diff --git a/changelog b/changelog index cf1d4de4017..bce16153f8d 100644 --- a/changelog +++ b/changelog @@ -14,6 +14,8 @@ Version 1.3.6+svn: * Enable "Save Game" and "View Chat Log" menu entries in replay mode. * WML engine: * now [base_unit]id= inside [unit] can extend upon existing unit types + * new extra_defines key to define in campaigns some other preprocessor + symbol *before* the files are repreprocessed * miscellaneous and bug fixes * rewrote the config merge routine (should improve parse time slightly) * various code cleanups diff --git a/data/_main.cfg b/data/_main.cfg index efb0868586e..f3dbec9e37e 100644 --- a/data/_main.cfg +++ b/data/_main.cfg @@ -1,22 +1,6 @@ #textdomain wesnoth {themes/} -# This check has to be done early, so USE_L3_OUTLAWS can affect the -# advancement trees of the core units. - -#ifdef CAMPAIGN_LIBERTY -#define USE_L3_OUTLAWS -#enddef -#endif -#ifdef CAMPAIGN_NORTHERN_REBIRTH -#define USE_L3_OUTLAWS -#enddef -#endif -#ifdef CAMPAIGN_THE_RISE_OF_WESNOTH -#define USE_L3_OUTLAWS -#enddef -#endif - {core/} #The editor needs the multiplayer included since the random maps are defined there diff --git a/data/campaigns/Liberty/_main.cfg b/data/campaigns/Liberty/_main.cfg index 9976bf5cc75..f4db6b2b458 100644 --- a/data/campaigns/Liberty/_main.cfg +++ b/data/campaigns/Liberty/_main.cfg @@ -10,6 +10,7 @@ first_scenario=the_raid define=CAMPAIGN_LIBERTY + extra_defines=USE_L3_OUTLAWS difficulties=EASY,NORMAL,HARD difficulty_descriptions={MENU_IMG_TXT2 "units/human-peasants/peasant.png~RC(magenta>red)" _"Peasant" _"(Easy)"} + ";" + {MENU_IMG_TXT2 "units/human-outlaws/outlaw.png~RC(magenta>red)" _"Outlaw" _"(Normal)"} + ";" + {MENU_IMG_TXT2 "units/human-outlaws/fugitive.png~RC(magenta>red)" _"Fugitive" _"(Difficult)"} icon="units/human-outlaws/fugitive.png" diff --git a/data/campaigns/Northern_Rebirth/_main.cfg b/data/campaigns/Northern_Rebirth/_main.cfg index 82dbd55ddb5..2f39a76e384 100644 --- a/data/campaigns/Northern_Rebirth/_main.cfg +++ b/data/campaigns/Northern_Rebirth/_main.cfg @@ -8,6 +8,7 @@ name= _ "Northern Rebirth" first_scenario=chain_break define=CAMPAIGN_NORTHERN_REBIRTH + extra_defines=USE_L3_OUTLAWS difficulties=NEWBIE,EASY,NORMAL,HARD difficulty_descriptions={MENU_IMG_TXT2 "units/human-peasants/peasant.png~RC(magenta>red)" _"Peasant" _"(Normal)"} + ";" + {MENU_IMG_TXT2 "units/human-loyalists/spearman.png~RC(magenta>red)" _"Spearman" _"(Challenging)"} + ";" + diff --git a/data/campaigns/The_Rise_Of_Wesnoth/_main.cfg b/data/campaigns/The_Rise_Of_Wesnoth/_main.cfg index 42e0582e434..ffb000aa6e1 100644 --- a/data/campaigns/The_Rise_Of_Wesnoth/_main.cfg +++ b/data/campaigns/The_Rise_Of_Wesnoth/_main.cfg @@ -7,6 +7,7 @@ #textdomain wesnoth-trow name= _ "The Rise of Wesnoth" define=CAMPAIGN_THE_RISE_OF_WESNOTH + extra_defines=USE_L3_OUTLAWS first_scenario=A_Summer_of_Storms difficulties=EASY,NORMAL,HARD difficulty_descriptions={MENU_IMG_TXT2 TRoW_difficulty_easy.png _"Fighter" _"(Easy)"} + diff --git a/src/game.cpp b/src/game.cpp index 88018c9ecbc..23c8122f3e6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -686,6 +686,12 @@ bool game_controller::load_game() defines_map_["MULTIPLAYER"] = preproc_define(); } + const std::vector campaign_xtra_defines = utils::split(cfg["campaign_extra_defines"]); + + for(std::vector::const_iterator i = campaign_xtra_defines.begin(); i != campaign_xtra_defines.end(); ++i) { + defines_map_[*i] = preproc_define(); + } + refresh_game_cfg(); state_ = game_state(units_data_,cfg); @@ -846,6 +852,7 @@ bool game_controller::new_campaign() #endif state_.campaign_define = campaign["define"]; + state_.campaign_xtra_defines = utils::split(campaign["extra_defines"]); return true; } @@ -1714,6 +1721,11 @@ void game_controller::play_game(RELOAD_GAME_DATA reload) defines_map_[state_.campaign_define] = preproc_define(); } + for( std::vector::const_iterator i = state_.campaign_xtra_defines.begin(); + i != state_.campaign_xtra_defines.end(); ++i) { + defines_map_[*i] = preproc_define(); + } + if(defines_map_.count("NORMAL")) { defines_map_["MEDIUM"] = preproc_define(); } diff --git a/src/gamestatus.cpp b/src/gamestatus.cpp index 5054da677f4..5232b97542c 100644 --- a/src/gamestatus.cpp +++ b/src/gamestatus.cpp @@ -470,6 +470,8 @@ game_state::game_state(const game_data& data, const config& cfg) campaign_define = cfg["campaign_define"]; + campaign_xtra_defines = utils::split(cfg["campaign_extra_defines"]); + campaign_type = cfg["campaign_type"]; if(campaign_type.empty()) campaign_type = "scenario"; @@ -580,7 +582,8 @@ void write_game(const game_state& gamestate, config& cfg, WRITE_GAME_MODE mode) cfg["difficulty"] = gamestate.difficulty; cfg["campaign_define"] = gamestate.campaign_define; - + cfg["campaign_extra_defines"] = utils::join(gamestate.campaign_xtra_defines); + cfg.add_child("variables",gamestate.get_variables()); for(std::map::const_iterator j=gamestate.wml_menu_items.begin(); @@ -630,6 +633,7 @@ void write_game(config_writer &out, const game_state& gamestate, WRITE_GAME_MODE out.write_key_val("campaign_type", gamestate.campaign_type); out.write_key_val("difficulty", gamestate.difficulty); out.write_key_val("campaign_define", gamestate.campaign_define); + out.write_key_val("campaign_xtra_defines", utils::join(gamestate.campaign_xtra_defines)); out.write_child("variables", gamestate.get_variables()); for(std::map::const_iterator j=gamestate.wml_menu_items.begin(); j!=gamestate.wml_menu_items.end(); ++j) { @@ -1301,6 +1305,7 @@ game_state& game_state::operator=(const game_state& state) version = state.version; campaign_type = state.campaign_type; campaign_define = state.campaign_define; + campaign_xtra_defines = state.campaign_xtra_defines; campaign = state.campaign; scenario = state.scenario; players = state.players; diff --git a/src/gamestatus.hpp b/src/gamestatus.hpp index 636de5e6f28..826badc4c83 100644 --- a/src/gamestatus.hpp +++ b/src/gamestatus.hpp @@ -92,6 +92,7 @@ public: std::string campaign_type; //type of the game - campaign, multiplayer etc std::string campaign_define; //if there is a define the campaign uses to customize data + std::vector campaign_xtra_defines; // more customization of data std::string campaign; //the campaign being played std::string scenario; //the scenario being played