Merge branch 'master' of https://github.com/wesnoth/wesnoth-old
This commit is contained in:
commit
df175d747f
34 changed files with 348 additions and 161 deletions
21
changelog
21
changelog
|
@ -1,4 +1,7 @@
|
|||
Version 1.11.7+dev:
|
||||
* Add-ons client:
|
||||
* Introduced new add-on type "SP/MP Campaign" for campaigns with
|
||||
"type=hybrid."
|
||||
* AI:
|
||||
* RCA AI: fix bug #21334: surrounded units don't attack
|
||||
* Simple Attack Micro AI: new optional parameter weapon=
|
||||
|
@ -45,8 +48,12 @@ Version 1.11.7+dev:
|
|||
* Added flag, flag_icon, and village_support fields to wesnoth.sides table
|
||||
elements.
|
||||
* Made wesnoth.sides[n].hidden a read-write field.
|
||||
* New lua proxy table "wesnoth.game_config.mp_settings" for access to
|
||||
MP specific settings, such as era, scenario name, and timer
|
||||
* Multiplayer:
|
||||
* Unit names and genders are synced in MP games.
|
||||
* Added new CampaignWML attribute "require_campaign". If set to "yes",
|
||||
players not having campaign installed won't be able to join the game.
|
||||
* Replays:
|
||||
* Replays include the prestart and start events again.
|
||||
* Unit names and genders are synced between games and replays.
|
||||
|
@ -62,6 +69,19 @@ Version 1.11.7+dev:
|
|||
to cause severe lags that render the cursor unusable.
|
||||
* Unit overlays are now displayed in the Recall dialog, both on the list
|
||||
and the description panel.
|
||||
* Made filtering controls on the MP create screen functional.
|
||||
* Removed the MP custom options dialog; all options are now shown directly
|
||||
on the configuration screen.
|
||||
* Removed the MP modifications dialog; modifications are now displayed
|
||||
directly on the creation screen.
|
||||
* The "Compressed saves" and "Compress savegames using bzip2" options in
|
||||
Preferences -> Advanced have been replaced by a single option,
|
||||
"Compressed saved games", that lets the user pick between gzip (default),
|
||||
bzip2, and no compression. Users who previously enabled bzip2 compression
|
||||
will need to do so again.
|
||||
* Hide eras menu in MP Create for campaigns which have
|
||||
"allow_era_choice=no".
|
||||
* Introduced side's name in MP Connect.
|
||||
* WML engine:
|
||||
* WML variable turn_number is set correctly (to 1) in prestart and start
|
||||
events. Previously, it retained its last value from the previous scenario
|
||||
|
@ -81,6 +101,7 @@ Version 1.11.7+dev:
|
|||
being displayed instead in e.g. [message] (bug #20996).
|
||||
* Added wmllint code for recognizing unit id fields in macros.
|
||||
* Refactored code in wmltools to create a macro-parsing function.
|
||||
* Added era descriptions.
|
||||
|
||||
Version 1.11.7:
|
||||
* Add-ons client:
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
#textdomain wesnoth
|
||||
[advanced_preference]
|
||||
field=compress_saves
|
||||
name= _ "Compressed saves"
|
||||
type=boolean
|
||||
default=yes
|
||||
# po: Associated save_compression_short^ entries need to be as short as
|
||||
# po: possible to avoid stretching the advanced preferences list too
|
||||
# po: much.
|
||||
name= _ "Compress saved games"
|
||||
type=combo
|
||||
default=gzip
|
||||
[option]
|
||||
id=gzip
|
||||
name= _ "save_compression^Gzip"
|
||||
name_short= _ "save_compression_short^gzip"
|
||||
description= _ "save_compression_desc^Default compression, faster"
|
||||
[/option]
|
||||
[option]
|
||||
id=bzip2
|
||||
name= _ "save_compression^Bzip2"
|
||||
name_short= _ "save_compression_short^bzip2"
|
||||
description= _ "save_compression_desc^Best compression, slower"
|
||||
[/option]
|
||||
[option]
|
||||
id=none
|
||||
name= _ "save_compression^No"
|
||||
name_short= _ "save_compression_short^no"
|
||||
description= _ "save_compression_desc^Large plain text files"
|
||||
[/option]
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
|
@ -159,13 +180,6 @@
|
|||
default=no
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
field=bzip2_savegame_compression
|
||||
name= _ "Compress savegames using bzip2"
|
||||
type=boolean
|
||||
default=no
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
field=new_lobby
|
||||
name= _ "Experimental multiplayer lobby"
|
||||
|
|
|
@ -525,6 +525,10 @@ For gameplay purposes, various races of creatures in the world cooperate with ea
|
|||
|
||||
In <italic>text='Multiplayer'</italic> mode, you can choose an era when creating a new game, and players can pick from the available factions for that era when setting up their sides and teams." + _ "
|
||||
|
||||
<header>text='Multiplayer Modifications'</header>" + _ "
|
||||
|
||||
Modifications are optional, scenario- and era-independent scripts for <italic>text='Multiplayer'</italic> games that can alter the default ruleset in various ways." + _ "
|
||||
|
||||
<header>text='Creator Resources'</header>" + _"
|
||||
|
||||
Content authors can use resource packs available on the add-ons server to enrich their own content with existing assets such as images, music, and code. These are not generally intended for the players’ use and cannot be directly used in-game on their own; however, other playable add-ons may depend on them and suggest or require their installation during download."
|
||||
|
|
|
@ -3,6 +3,8 @@ changes may be omitted). For a complete list of changes, see the main
|
|||
changelog: https://github.com/wesnoth/wesnoth-old/blob/master/changelog
|
||||
|
||||
Version 1.11.7+dev:
|
||||
* Add-ons client:
|
||||
* Introduced new add-on type "SP/MP Campaign".
|
||||
* Campaigns:
|
||||
* Dead Water:
|
||||
* New world map.
|
||||
|
@ -46,6 +48,13 @@ Version 1.11.7+dev:
|
|||
* Added a party full bell to the MP game configuration screen, played once
|
||||
all human player slots have been taken.
|
||||
* Change layout for advertized games in the MP lobby and add map icon.
|
||||
* The "Compressed saves" and "Compress savegames using bzip2" options in
|
||||
Preferences -> Advanced have been replaced by a single option,
|
||||
"Compressed saved games", that lets the user pick between gzip (default),
|
||||
bzip2, and no compression. Users who previously enabled bzip2 compression
|
||||
will need to do so again.
|
||||
* Added possibility to hide eras menu for campaigns in MP Create.
|
||||
* Introduced side's name in MP Connect.
|
||||
|
||||
|
||||
Version 1.11.7:
|
||||
|
|
|
@ -887,6 +887,7 @@
|
|||
<Unit filename="..\..\src\sdl_utils.hpp" />
|
||||
<Unit filename="..\..\src\serialization\binary_or_text.cpp" />
|
||||
<Unit filename="..\..\src\serialization\binary_or_text.hpp" />
|
||||
<Unit filename="..\..\src\serialization\compression.hpp" />
|
||||
<Unit filename="..\..\src\serialization\parser.cpp" />
|
||||
<Unit filename="..\..\src\serialization\parser.hpp" />
|
||||
<Unit filename="..\..\src\serialization\preprocessor.cpp" />
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
<Unit filename="..\..\src\scoped_resource.hpp" />
|
||||
<Unit filename="..\..\src\serialization\binary_or_text.cpp" />
|
||||
<Unit filename="..\..\src\serialization\binary_or_text.hpp" />
|
||||
<Unit filename="..\..\src\serialization\compression.hpp" />
|
||||
<Unit filename="..\..\src\serialization\parser.cpp" />
|
||||
<Unit filename="..\..\src\serialization\parser.hpp" />
|
||||
<Unit filename="..\..\src\serialization\preprocessor.cpp" />
|
||||
|
@ -117,6 +118,8 @@
|
|||
<Unit filename="..\..\src\thread.hpp" />
|
||||
<Unit filename="..\..\src\tstring.cpp" />
|
||||
<Unit filename="..\..\src\tstring.hpp" />
|
||||
<Unit filename="..\..\src\util.cpp" />
|
||||
<Unit filename="..\..\src\util.hpp" />
|
||||
<Unit filename="..\..\src\version.cpp" />
|
||||
<Unit filename="..\..\src\version.hpp" />
|
||||
<Unit filename="..\..\src\wesconfig.h" />
|
||||
|
|
|
@ -79,7 +79,7 @@ void display::parse_team_overlays()
|
|||
{
|
||||
const team& curr_team = (*teams_)[playing_team()];
|
||||
const team& prev_team = (*teams_)[playing_team()-1 < teams_->size() ? playing_team()-1 : teams_->size()-1];
|
||||
BOOST_FOREACH(const game_display::overlay_map::value_type i, overlays_) {
|
||||
BOOST_FOREACH(const game_display::overlay_map::value_type i, *overlays_) {
|
||||
const overlay& ov = i.second;
|
||||
if (!ov.team_name.empty() &&
|
||||
((ov.team_name.find(curr_team.team_name()) + 1) != 0) !=
|
||||
|
@ -97,19 +97,19 @@ void display::add_overlay(const map_location& loc, const std::string& img, const
|
|||
get_location_y(loc) + hex_size() / 2, halo, loc);
|
||||
|
||||
const overlay item(img, halo, halo_handle, team_name, visible_under_fog);
|
||||
overlays_.insert(overlay_map::value_type(loc,item));
|
||||
overlays_->insert(overlay_map::value_type(loc,item));
|
||||
}
|
||||
|
||||
void display::remove_overlay(const map_location& loc)
|
||||
{
|
||||
typedef overlay_map::const_iterator Itor;
|
||||
std::pair<Itor,Itor> itors = overlays_.equal_range(loc);
|
||||
std::pair<Itor,Itor> itors = overlays_->equal_range(loc);
|
||||
while(itors.first != itors.second) {
|
||||
halo::remove(itors.first->second.halo_handle);
|
||||
++itors.first;
|
||||
}
|
||||
|
||||
overlays_.erase(loc);
|
||||
overlays_->erase(loc);
|
||||
}
|
||||
|
||||
void display::remove_single_overlay(const map_location& loc, const std::string& toDelete)
|
||||
|
@ -117,14 +117,14 @@ void display::remove_single_overlay(const map_location& loc, const std::string&
|
|||
//Iterate through the values with key of loc
|
||||
typedef overlay_map::iterator Itor;
|
||||
overlay_map::iterator iteratorCopy;
|
||||
std::pair<Itor,Itor> itors = overlays_.equal_range(loc);
|
||||
std::pair<Itor,Itor> itors = overlays_->equal_range(loc);
|
||||
while(itors.first != itors.second) {
|
||||
//If image or halo of overlay struct matches toDelete, remove the overlay
|
||||
if(itors.first->second.image == toDelete || itors.first->second.halo == toDelete) {
|
||||
iteratorCopy = itors.first;
|
||||
++itors.first;
|
||||
halo::remove(iteratorCopy->second.halo_handle);
|
||||
overlays_.erase(iteratorCopy);
|
||||
overlays_->erase(iteratorCopy);
|
||||
}
|
||||
else {
|
||||
++itors.first;
|
||||
|
@ -2561,7 +2561,7 @@ void display::draw_hex(const map_location& loc) {
|
|||
|
||||
if(!shrouded(loc)) {
|
||||
typedef overlay_map::const_iterator Itor;
|
||||
std::pair<Itor,Itor> overlays = overlays_.equal_range(loc);
|
||||
std::pair<Itor,Itor> overlays = overlays_->equal_range(loc);
|
||||
for( ; overlays.first != overlays.second; ++overlays.first) {
|
||||
if ((overlays.first->second.team_name == "" ||
|
||||
overlays.first->second.team_name.find((*teams_)[playing_team()].team_name()) != std::string::npos)
|
||||
|
|
|
@ -1014,11 +1014,12 @@ protected:
|
|||
bool reach_map_changed_;
|
||||
void process_reachmap_changes();
|
||||
|
||||
private:
|
||||
|
||||
typedef std::multimap<map_location, overlay> overlay_map;
|
||||
|
||||
overlay_map overlays_;
|
||||
private:
|
||||
|
||||
|
||||
overlay_map* overlays_;
|
||||
|
||||
/** Handle for the label which displays frames per second. */
|
||||
int fps_handle_;
|
||||
|
@ -1050,6 +1051,9 @@ private:
|
|||
bool do_reverse_memcpy_workaround_;
|
||||
#endif
|
||||
|
||||
public:
|
||||
void replace_overlay_map(overlay_map* overlays) { overlays_ = overlays; }
|
||||
|
||||
protected:
|
||||
static display * singleton_;
|
||||
};
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
resources::tod_manager = context_manager_.get_map_context().get_time_manager();
|
||||
context_manager_.gui().change_teams(&context_manager_.get_map_context().get_teams());
|
||||
|
||||
context_manager_.gui().replace_overlay_map(&context_manager_.get_map_context().get_overlays());
|
||||
|
||||
resources::teams = &context_manager_.get_map_context().get_teams();
|
||||
|
||||
resources::state_of_game = &context_manager_.get_map_context().get_game_state();
|
||||
|
|
|
@ -237,6 +237,11 @@ void map_context::load_scenario(const config& game_config)
|
|||
tod_manager_->add_time_area(t);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const config& item, scenario.child_range("item")) {
|
||||
overlays_.insert(std::pair<map_location,
|
||||
overlay>(map_location(item["x"], item["y"]), overlay(item) ));
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const config& music, scenario.child_range("music")) {
|
||||
music_tracks_.insert(std::pair<std::string, sound::music_track>(music["name"], sound::music_track(music)));
|
||||
}
|
||||
|
@ -384,6 +389,19 @@ config map_context::to_config()
|
|||
|
||||
labels_.write(scenario);
|
||||
|
||||
overlay_map::const_iterator it;
|
||||
for (it = overlays_.begin(); it != overlays_.end(); it++) {
|
||||
|
||||
config& item = scenario.add_child("item");
|
||||
it->first.write(item);
|
||||
item["image"] = it->second.image;
|
||||
item["id"] = it->second.id;
|
||||
item["halo"] = it->second.halo;
|
||||
item["visible_in_fog"] = it->second.visible_in_fog;
|
||||
item["name"] = it->second.name;
|
||||
item["team_name"] = it->second.team_name;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const music_map::value_type& track, music_tracks_) {
|
||||
track.second.write(scenario, true);
|
||||
}
|
||||
|
@ -410,6 +428,10 @@ config map_context::to_config()
|
|||
side["gold"] = t->gold();
|
||||
side["income"] = t->base_income();
|
||||
|
||||
BOOST_FOREACH(const map_location& village, t->villages()) {
|
||||
village.write(side.add_child("village"));
|
||||
}
|
||||
|
||||
//current visible units
|
||||
for(unit_map::const_iterator i = units_.begin(); i != units_.end(); ++i) {
|
||||
if(i->side() == side_num) {
|
||||
|
@ -421,6 +443,9 @@ config map_context::to_config()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return scenario;
|
||||
}
|
||||
|
||||
|
|
|
@ -424,9 +424,13 @@ private:
|
|||
typedef std::map<std::string, sound::music_track> music_map;
|
||||
music_map music_tracks_;
|
||||
|
||||
typedef std::map<map_location, std::vector<overlay> > overlay_map;
|
||||
typedef std::multimap<map_location, overlay> overlay_map;
|
||||
overlay_map overlays_;
|
||||
|
||||
public:
|
||||
|
||||
overlay_map& get_overlays() { return overlays_; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
const tod_manager& tod, const std::vector<team>& t,
|
||||
const config& theme_cfg, const config& level) :
|
||||
display(&units, video, &map, &t, theme_cfg, level),
|
||||
overlay_map_(),
|
||||
fake_units_(),
|
||||
attack_indicator_src_(),
|
||||
attack_indicator_dst_(),
|
||||
|
@ -71,7 +72,6 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
tod_manager_(tod),
|
||||
level_(level),
|
||||
displayedUnitHex_(),
|
||||
// overlays_(),
|
||||
sidebarScaling_(1.0),
|
||||
first_turn_(true),
|
||||
in_game_(false),
|
||||
|
@ -79,7 +79,7 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
chat_messages_(),
|
||||
game_mode_(RUNNING)
|
||||
{
|
||||
|
||||
replace_overlay_map(&overlay_map_);
|
||||
clear_screen();
|
||||
}
|
||||
|
||||
|
|
|
@ -290,6 +290,8 @@ private:
|
|||
|
||||
void draw_sidebar();
|
||||
|
||||
overlay_map overlay_map_;
|
||||
|
||||
/// collection of units destined to be drawn but not put into the unit map
|
||||
std::deque<unit*> fake_units_;
|
||||
|
||||
|
@ -309,23 +311,6 @@ private:
|
|||
|
||||
map_location displayedUnitHex_;
|
||||
|
||||
// struct overlay {
|
||||
// overlay(const std::string& img, const std::string& halo_img,
|
||||
// int handle, const std::string& overlay_team_name, const bool fogged) : image(img), halo(halo_img),
|
||||
// team_name(overlay_team_name), halo_handle(handle) , visible_in_fog(fogged){}
|
||||
// std::string image;
|
||||
// std::string halo;
|
||||
// std::string team_name;
|
||||
// int halo_handle;
|
||||
// bool visible_in_fog;
|
||||
// };
|
||||
|
||||
// typedef std::multimap<map_location,overlay> overlay_map;
|
||||
|
||||
// overlay_map overlays_;
|
||||
|
||||
|
||||
|
||||
double sidebarScaling_;
|
||||
|
||||
bool first_turn_, in_game_;
|
||||
|
|
|
@ -913,9 +913,25 @@ void set_flip_time(bool value)
|
|||
preferences::set("flip_time", value);
|
||||
}
|
||||
|
||||
bool compress_saves()
|
||||
compression::format save_compression_format()
|
||||
{
|
||||
return preferences::get("compress_saves", true);
|
||||
const std::string& choice =
|
||||
preferences::get("compress_saves");
|
||||
|
||||
// "yes" was used in 1.11.7 and earlier; the compress_saves
|
||||
// option used to be a toggle for gzip in those versions.
|
||||
if(choice.empty() || choice == "gzip" || choice == "yes") {
|
||||
return compression::GZIP;
|
||||
} else if(choice == "bzip2") {
|
||||
return compression::BZIP2;
|
||||
} else if(choice == "none" || choice == "no") { // see above
|
||||
return compression::NONE;
|
||||
} /*else*/
|
||||
|
||||
// In case the preferences file was created by a later version
|
||||
// supporting some algorithm we don't; although why would anyone
|
||||
// playing a game need more algorithms, really...
|
||||
return compression::GZIP;
|
||||
}
|
||||
|
||||
bool startup_effect()
|
||||
|
|
|
@ -21,6 +21,8 @@ class unit_map;
|
|||
|
||||
#include "preferences.hpp"
|
||||
|
||||
#include "serialization/compression.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
@ -230,7 +232,7 @@ class acquaintance;
|
|||
bool show_all_units_in_help();
|
||||
void set_show_all_units_in_help(bool value);
|
||||
|
||||
bool compress_saves();
|
||||
compression::format save_compression_format();
|
||||
|
||||
bool startup_effect();
|
||||
|
||||
|
|
|
@ -1052,7 +1052,18 @@ void preferences_dialog::process_event()
|
|||
int adv_combo_choice = 0;
|
||||
BOOST_FOREACH(const config& adv_combo_option, pref.child_range("option"))
|
||||
{
|
||||
adv_combo_items.push_back(adv_combo_option["name"]);
|
||||
if(adv_combo_option.has_attribute("description")) {
|
||||
// The longer description is supposed to be used in the combo
|
||||
// box only as a workaround for the main listbox's layout
|
||||
// limitations.
|
||||
std::ostringstream ss;
|
||||
ss << adv_combo_option["name"] << '='
|
||||
<< adv_combo_option["description"];
|
||||
adv_combo_items.push_back(ss.str());
|
||||
} else {
|
||||
adv_combo_items.push_back(adv_combo_option["name"]);
|
||||
}
|
||||
|
||||
if(value == adv_combo_option["id"]) {
|
||||
adv_combo_choice = adv_combo_items.size() - 1;
|
||||
}
|
||||
|
@ -1147,7 +1158,11 @@ void preferences_dialog::set_advanced_menu()
|
|||
BOOST_FOREACH(const config& optdef, adv.child_range("option"))
|
||||
{
|
||||
if(field == optdef["id"]) {
|
||||
field = optdef["name"].str();
|
||||
if(optdef.has_attribute("name_short")) {
|
||||
field = optdef["name_short"].str();
|
||||
} else {
|
||||
field = optdef["name"].str();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2825,7 +2825,7 @@ void console_handler::do_benchmark() {
|
|||
void console_handler::do_save() {
|
||||
savegame::ingame_savegame save(menu_handler_.gamestate_, *menu_handler_.gui_,
|
||||
resources::controller->to_config(),
|
||||
preferences::compress_saves());
|
||||
preferences::save_compression_format());
|
||||
save.save_game_automatic(menu_handler_.gui_->video(), true, get_data());
|
||||
}
|
||||
void console_handler::do_save_quit() {
|
||||
|
|
|
@ -79,7 +79,7 @@ configure::configure(game_display& disp, const config &cfg, chat& c, config& gam
|
|||
shroud_game_(disp.video(), _("Shroud"), gui::button::TYPE_CHECK),
|
||||
observers_game_(disp.video(), _("Observers"), gui::button::TYPE_CHECK),
|
||||
shuffle_sides_(disp.video(), _("Shuffle sides"), gui::button::TYPE_CHECK),
|
||||
cancel_game_(disp.video(), _("Cancel")),
|
||||
cancel_game_(disp.video(), _("Back")),
|
||||
launch_game_(disp.video(), _("OK")),
|
||||
password_button_(disp.video(), _("Set Password...")),
|
||||
vision_combo_(disp, std::vector<std::string>()),
|
||||
|
|
|
@ -76,7 +76,7 @@ create::create(game_display& disp, const config& cfg, game_state& state,
|
|||
map_size_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOR),
|
||||
num_players_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOR),
|
||||
level_type_label_(disp.video(), "Game type:", font::SIZE_SMALL, font::LOBBY_COLOR),
|
||||
launch_game_(disp.video(), _("OK")),
|
||||
launch_game_(disp.video(), _("Next")),
|
||||
cancel_game_(disp.video(), _("Cancel")),
|
||||
regenerate_map_(disp.video(), _("Regenerate")),
|
||||
generator_settings_(disp.video(), _("Settings...")),
|
||||
|
@ -376,6 +376,19 @@ void create::process_event()
|
|||
generator_settings_.enable(engine_.generator_assigned());
|
||||
regenerate_map_.enable(engine_.generator_assigned());
|
||||
}
|
||||
|
||||
if (filter_num_players_slider_.value() != engine_.player_num_filter()) {
|
||||
const int val = filter_num_players_slider_.value();
|
||||
engine_.apply_level_filter(val);
|
||||
std::stringstream ss;
|
||||
if (val == 0) {
|
||||
ss << _("Number of players: any");
|
||||
} else {
|
||||
ss << _("Number of players: ") << val;
|
||||
}
|
||||
filter_num_players_label_.set_text(ss.str());
|
||||
init_level_type_changed(0);
|
||||
}
|
||||
}
|
||||
|
||||
void create::init_level_type_changed(size_t index)
|
||||
|
|
|
@ -326,6 +326,7 @@ create_engine::create_engine(game_display& disp, game_state& state) :
|
|||
current_era_index_(0),
|
||||
current_mod_index_(0),
|
||||
level_name_filter_(),
|
||||
player_count_filter_(0),
|
||||
scenarios_(),
|
||||
user_maps_(),
|
||||
user_scenarios_(),
|
||||
|
@ -447,49 +448,14 @@ void create_engine::prepare_for_saved_game()
|
|||
|
||||
void create_engine::apply_level_filter(const std::string &name)
|
||||
{
|
||||
scenarios_filtered_.clear();
|
||||
for (size_t i = 0; i<scenarios_.size(); i++) {
|
||||
if (contains_ignore_case(scenarios_[i]->name(), name)) {
|
||||
scenarios_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
user_scenarios_filtered_.clear();
|
||||
for (size_t i = 0; i<user_scenarios_.size(); i++) {
|
||||
if (contains_ignore_case(user_scenarios_[i]->name(), name)) {
|
||||
user_scenarios_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
user_maps_filtered_.clear();
|
||||
for (size_t i = 0; i<user_maps_.size(); i++) {
|
||||
if (contains_ignore_case(user_maps_[i]->name(), name)) {
|
||||
user_maps_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
campaigns_filtered_.clear();
|
||||
for (size_t i = 0; i<campaigns_.size(); i++) {
|
||||
if (contains_ignore_case(campaigns_[i]->name(), name)) {
|
||||
campaigns_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
sp_campaigns_filtered_.clear();
|
||||
for (size_t i = 0; i<sp_campaigns_.size(); i++) {
|
||||
if (contains_ignore_case(sp_campaigns_[i]->name(), name)) {
|
||||
sp_campaigns_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
random_maps_filtered_.clear();
|
||||
for (size_t i = 0; i<random_maps_.size(); i++) {
|
||||
if (contains_ignore_case(random_maps_[i]->name(), name)) {
|
||||
random_maps_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
level_name_filter_ = name;
|
||||
apply_level_filters();
|
||||
}
|
||||
|
||||
void create_engine::apply_level_filter(int players)
|
||||
{
|
||||
player_count_filter_ = players;
|
||||
apply_level_filters();
|
||||
}
|
||||
|
||||
void create_engine::reset_level_filters()
|
||||
|
@ -532,6 +498,11 @@ const std::string &create_engine::level_name_filter() const
|
|||
return level_name_filter_;
|
||||
}
|
||||
|
||||
int create_engine::player_num_filter() const
|
||||
{
|
||||
return player_count_filter_;
|
||||
}
|
||||
|
||||
std::vector<std::string> create_engine::levels_menu_item_names() const
|
||||
{
|
||||
std::vector<std::string> menu_names;
|
||||
|
@ -807,6 +778,7 @@ void create_engine::init_all_levels()
|
|||
user_map_ptr new_user_map(new user_map(user_map_data,
|
||||
user_map_names_[i], map.get()));
|
||||
user_maps_.push_back(new_user_map);
|
||||
user_maps_.back()->set_metadata();
|
||||
|
||||
// Since user maps are treated as scenarios,
|
||||
// some dependency info is required
|
||||
|
@ -828,6 +800,7 @@ void create_engine::init_all_levels()
|
|||
scenario_ptr new_scenario(new scenario(data));
|
||||
if (new_scenario->id().empty()) continue;
|
||||
user_scenarios_.push_back(new_scenario);
|
||||
user_scenarios_.back()->set_metadata();
|
||||
|
||||
// Since user scenarios are treated as scenarios,
|
||||
// some dependency info is required
|
||||
|
@ -846,9 +819,11 @@ void create_engine::init_all_levels()
|
|||
if (!data["map_generation"].empty()) {
|
||||
random_map_ptr new_random_map(new random_map(data));
|
||||
random_maps_.push_back(new_random_map);
|
||||
random_maps_.back()->set_metadata();
|
||||
} else if (data["allow_new_game"].to_bool(true)) {
|
||||
scenario_ptr new_scenario(new scenario(data));
|
||||
scenarios_.push_back(new_scenario);
|
||||
scenarios_.back()->set_metadata();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -861,9 +836,11 @@ void create_engine::init_all_levels()
|
|||
if (type == "mp" || type == "hybrid") {
|
||||
campaign_ptr new_campaign(new campaign(data));
|
||||
campaigns_.push_back(new_campaign);
|
||||
campaigns_.back()->set_metadata();
|
||||
} else {
|
||||
campaign_ptr new_sp_campaign(new campaign(data));
|
||||
sp_campaigns_.push_back(new_sp_campaign);
|
||||
sp_campaigns_.back()->set_metadata();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -885,6 +862,66 @@ void create_engine::init_extras(const MP_EXTRA extra_type)
|
|||
}
|
||||
}
|
||||
|
||||
void create_engine::apply_level_filters()
|
||||
{
|
||||
scenarios_filtered_.clear();
|
||||
for (size_t i = 0; i<scenarios_.size(); i++) {
|
||||
if (contains_ignore_case(scenarios_[i]->name(), level_name_filter_) &&
|
||||
(player_count_filter_ == 0 ||
|
||||
scenarios_[i]->num_players() == player_count_filter_)) {
|
||||
scenarios_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
user_scenarios_filtered_.clear();
|
||||
for (size_t i = 0; i<user_scenarios_.size(); i++) {
|
||||
if (contains_ignore_case(user_scenarios_[i]->name(), level_name_filter_) &&
|
||||
(player_count_filter_ == 0 ||
|
||||
user_scenarios_[i]->num_players() == player_count_filter_)) {
|
||||
user_scenarios_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
user_maps_filtered_.clear();
|
||||
for (size_t i = 0; i<user_maps_.size(); i++) {
|
||||
if (contains_ignore_case(user_maps_[i]->name(), level_name_filter_) &&
|
||||
(player_count_filter_ == 0 ||
|
||||
user_maps_[i]->num_players() == player_count_filter_)) {
|
||||
user_maps_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
campaigns_filtered_.clear();
|
||||
for (size_t i = 0; i<campaigns_.size(); i++) {
|
||||
if (contains_ignore_case(campaigns_[i]->name(), level_name_filter_) &&
|
||||
(player_count_filter_ == 0 ||
|
||||
(campaigns_[i]->min_players() <= player_count_filter_ &&
|
||||
campaigns_[i]->max_players() >= player_count_filter_))) {
|
||||
campaigns_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
sp_campaigns_filtered_.clear();
|
||||
for (size_t i = 0; i<sp_campaigns_.size(); i++) {
|
||||
if (contains_ignore_case(sp_campaigns_[i]->name(), level_name_filter_) &&
|
||||
(player_count_filter_ == 0 ||
|
||||
(sp_campaigns_[i]->min_players() <= player_count_filter_ &&
|
||||
sp_campaigns_[i]->max_players() >= player_count_filter_))) {
|
||||
sp_campaigns_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
random_maps_filtered_.clear();
|
||||
for (size_t i = 0; i<random_maps_.size(); i++) {
|
||||
if (contains_ignore_case(random_maps_[i]->name(), level_name_filter_) &&
|
||||
(player_count_filter_ == 0 ||
|
||||
random_maps_[i]->num_players() == player_count_filter_)) {
|
||||
random_maps_filtered_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<create_engine::level_ptr>
|
||||
create_engine::get_levels_by_type_unfiltered(level::TYPE type) const
|
||||
{
|
||||
|
|
|
@ -181,9 +181,11 @@ public:
|
|||
void prepare_for_saved_game();
|
||||
|
||||
void apply_level_filter(const std::string& name);
|
||||
void apply_level_filter(int players);
|
||||
void reset_level_filters();
|
||||
|
||||
const std::string& level_name_filter() const;
|
||||
int player_num_filter() const;
|
||||
|
||||
std::vector<level_ptr> get_levels_by_type_unfiltered(level::TYPE type) const;
|
||||
std::vector<level_ptr> get_levels_by_type(level::TYPE type) const;
|
||||
|
@ -223,6 +225,7 @@ private:
|
|||
|
||||
void init_all_levels();
|
||||
void init_extras(const MP_EXTRA extra_type);
|
||||
void apply_level_filters();
|
||||
|
||||
const std::vector<extras_metadata_ptr>&
|
||||
get_const_extras_by_type(const MP_EXTRA extra_type) const;
|
||||
|
@ -238,6 +241,7 @@ private:
|
|||
size_t current_mod_index_;
|
||||
|
||||
std::string level_name_filter_;
|
||||
int player_count_filter_;
|
||||
|
||||
std::vector<scenario_ptr> scenarios_;
|
||||
std::vector<user_map_ptr> user_maps_;
|
||||
|
|
|
@ -410,7 +410,7 @@ void play_controller::status_table(){
|
|||
void play_controller::save_game(){
|
||||
if(save_blocker::try_block()) {
|
||||
save_blocker::save_unblocker unblocker;
|
||||
savegame::ingame_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
savegame::ingame_savegame save(gamestate_, *gui_, to_config(), preferences::save_compression_format());
|
||||
save.save_game_interactive(gui_->video(), "", gui::OK_CANCEL);
|
||||
} else {
|
||||
save_blocker::on_unblock(this,&play_controller::save_game);
|
||||
|
@ -420,7 +420,7 @@ void play_controller::save_game(){
|
|||
void play_controller::save_replay(){
|
||||
if(save_blocker::try_block()) {
|
||||
save_blocker::save_unblocker unblocker;
|
||||
savegame::replay_savegame save(gamestate_, preferences::compress_saves());
|
||||
savegame::replay_savegame save(gamestate_, preferences::save_compression_format());
|
||||
save.save_game_interactive(gui_->video(), "", gui::OK_CANCEL);
|
||||
} else {
|
||||
save_blocker::on_unblock(this,&play_controller::save_replay);
|
||||
|
@ -1160,6 +1160,9 @@ static void trim_items(std::vector<std::string>& newitems) {
|
|||
|
||||
void play_controller::expand_autosaves(std::vector<std::string>& items)
|
||||
{
|
||||
const compression::format comp_format =
|
||||
preferences::save_compression_format();
|
||||
|
||||
savenames_.clear();
|
||||
for (unsigned int i = 0; i < items.size(); ++i) {
|
||||
if (items[i] == "AUTOSAVES") {
|
||||
|
@ -1168,23 +1171,17 @@ void play_controller::expand_autosaves(std::vector<std::string>& items)
|
|||
std::vector<std::string> newsaves;
|
||||
for (unsigned int turn = this->turn(); turn != 0; turn--) {
|
||||
std::string name = gamestate_.classification().label + "-" + _("Auto-Save") + lexical_cast<std::string>(turn);
|
||||
if (savegame::save_game_exists(name, preferences::compress_saves())) {
|
||||
if(preferences::compress_saves()) {
|
||||
newsaves.push_back(name + (preferences::bzip2_savegame_compression() ? ".bz2" : ".gz"));
|
||||
} else {
|
||||
newsaves.push_back(name);
|
||||
}
|
||||
if (savegame::save_game_exists(name, comp_format)) {
|
||||
newsaves.push_back(
|
||||
name + compression::format_extension(comp_format));
|
||||
newitems.push_back(_("Back to Turn ") + lexical_cast<std::string>(turn));
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& start_name = gamestate_.classification().label;
|
||||
if(savegame::save_game_exists(start_name, preferences::compress_saves())) {
|
||||
if(preferences::compress_saves()) {
|
||||
newsaves.push_back(start_name + (preferences::bzip2_savegame_compression() ? ".bz2" : ".gz"));
|
||||
} else {
|
||||
newsaves.push_back(start_name);
|
||||
}
|
||||
if(savegame::save_game_exists(start_name, comp_format)) {
|
||||
newsaves.push_back(
|
||||
start_name + compression::format_extension(comp_format));
|
||||
newitems.push_back(_("Back to Start"));
|
||||
}
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
|
|||
savegame::clean_saves(gamestate.classification().label);
|
||||
|
||||
if (preferences::save_replays() && end_level.replay_save) {
|
||||
savegame::replay_savegame save(gamestate, preferences::compress_saves());
|
||||
savegame::replay_savegame save(gamestate, preferences::save_compression_format());
|
||||
save.save_game_automatic(disp.video(), true);
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
|
|||
// starting position needs to be empty,
|
||||
// to force a reload of the scenario config.
|
||||
|
||||
savegame::scenariostart_savegame save(gamestate, preferences::compress_saves());
|
||||
savegame::scenariostart_savegame save(gamestate, preferences::save_compression_format());
|
||||
|
||||
save.save_game_automatic(disp.video());
|
||||
}
|
||||
|
|
|
@ -544,7 +544,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
disconnect = true;
|
||||
}
|
||||
|
||||
savegame::ingame_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
savegame::ingame_savegame save(gamestate_, *gui_, to_config(), preferences::save_compression_format());
|
||||
save.save_game_interactive(gui_->video(), _("A network disconnection has occurred, and the game cannot continue. Do you want to save the game?"), gui::YES_NO);
|
||||
if(disconnect) {
|
||||
throw network::error();
|
||||
|
@ -700,7 +700,7 @@ void playsingle_controller::before_human_turn(bool save)
|
|||
ai::manager::raise_turn_started();
|
||||
|
||||
if(save && level_result_ == NONE) {
|
||||
savegame::autosave_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
savegame::autosave_savegame save(gamestate_, *gui_, to_config(), preferences::save_compression_format());
|
||||
save.autosave(game_config::disable_autosave, preferences::autosavemax(), preferences::INFINITE_AUTO_SAVES);
|
||||
}
|
||||
|
||||
|
|
|
@ -824,15 +824,5 @@ bool use_twelve_hour_clock_format()
|
|||
return get("use_twelve_hour_clock_format", false);
|
||||
}
|
||||
|
||||
bool bzip2_savegame_compression()
|
||||
{
|
||||
return get("bzip2_savegame_compression", false);
|
||||
}
|
||||
|
||||
void set_bzip2_savegame_compression(bool ison)
|
||||
{
|
||||
preferences::set("bzip2_savegame_compression", ison);
|
||||
}
|
||||
|
||||
} // end namespace preferences
|
||||
|
||||
|
|
|
@ -209,9 +209,6 @@ namespace preferences {
|
|||
bool use_twelve_hour_clock_format();
|
||||
void set_use_twelve_hour_clock_format(bool value);
|
||||
|
||||
bool bzip2_savegame_compression();
|
||||
void set_bzip2_savegame_compression(bool value);
|
||||
|
||||
} // end namespace preferences
|
||||
|
||||
#endif
|
||||
|
|
|
@ -182,10 +182,11 @@ public:
|
|||
log_scope("write_save_index()");
|
||||
try {
|
||||
scoped_ostream stream = ostream_file(get_save_index_file());
|
||||
if (preferences::compress_saves()) {
|
||||
write_gz(*stream, data());
|
||||
if (preferences::save_compression_format() != compression::NONE) {
|
||||
// TODO: maybe allow writing this using bz2 too?
|
||||
write_gz(*stream, data());
|
||||
} else {
|
||||
write(*stream, data());
|
||||
write(*stream, data());
|
||||
}
|
||||
} catch(io_exception& e) {
|
||||
ERR_SAVE << "error writing to save index file: '" << e.what() << "'\n";
|
||||
|
@ -398,14 +399,12 @@ void read_save_file(const std::string& name, config& cfg, std::string* error_log
|
|||
}
|
||||
}
|
||||
|
||||
bool save_game_exists(const std::string& name, bool compress_saves)
|
||||
bool save_game_exists(const std::string& name, compression::format compressed)
|
||||
{
|
||||
std::string fname = name;
|
||||
replace_space2underbar(fname);
|
||||
|
||||
if(compress_saves) {
|
||||
fname += preferences::bzip2_savegame_compression() ? ".bz2" : ".gz";
|
||||
}
|
||||
fname += compression::format_extension(compressed);
|
||||
|
||||
return file_exists(get_saves_dir() + "/" + fname);
|
||||
}
|
||||
|
@ -762,7 +761,7 @@ void loadgame::copy_era(config &cfg)
|
|||
snapshot.add_child("era", era);
|
||||
}
|
||||
|
||||
savegame::savegame(game_state& gamestate, const bool compress_saves, const std::string& title)
|
||||
savegame::savegame(game_state& gamestate, const compression::format compress_saves, const std::string& title)
|
||||
: gamestate_(gamestate)
|
||||
, snapshot_()
|
||||
, filename_()
|
||||
|
@ -945,14 +944,11 @@ void savegame::write_game_to_disk(const std::string& filename)
|
|||
LOG_SAVE << "savegame::save_game";
|
||||
|
||||
filename_ = filename;
|
||||
|
||||
if (compress_saves_) {
|
||||
filename_ += preferences::bzip2_savegame_compression() ? ".bz2" : ".gz";
|
||||
}
|
||||
filename_ += compression::format_extension(compress_saves_);
|
||||
|
||||
std::stringstream ss;
|
||||
{
|
||||
config_writer out(ss, compress_saves_ ? preferences::bzip2_savegame_compression() ? config_writer::BZIP2 : config_writer::GZIP : config_writer::NONE);
|
||||
config_writer out(ss, compress_saves_);
|
||||
write_game(out);
|
||||
finish_save_game(out);
|
||||
}
|
||||
|
@ -1002,7 +998,7 @@ scoped_ostream savegame::open_save_game(const std::string &label)
|
|||
}
|
||||
}
|
||||
|
||||
scenariostart_savegame::scenariostart_savegame(game_state &gamestate, const bool compress_saves)
|
||||
scenariostart_savegame::scenariostart_savegame(game_state &gamestate, const compression::format compress_saves)
|
||||
: savegame(gamestate, compress_saves)
|
||||
{
|
||||
set_filename(gamestate.classification().label);
|
||||
|
@ -1014,7 +1010,7 @@ void scenariostart_savegame::write_game(config_writer &out){
|
|||
out.write_child("carryover_sides_start", gamestate().carryover_sides_start);
|
||||
}
|
||||
|
||||
replay_savegame::replay_savegame(game_state &gamestate, const bool compress_saves)
|
||||
replay_savegame::replay_savegame(game_state &gamestate, const compression::format compress_saves)
|
||||
: savegame(gamestate, compress_saves, _("Save Replay"))
|
||||
{}
|
||||
|
||||
|
@ -1039,7 +1035,7 @@ void replay_savegame::write_game(config_writer &out) {
|
|||
}
|
||||
|
||||
autosave_savegame::autosave_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves)
|
||||
game_display& gui, const config& snapshot_cfg, const compression::format compress_saves)
|
||||
: ingame_savegame(gamestate, gui, snapshot_cfg, compress_saves)
|
||||
{
|
||||
set_error_message(_("Could not auto save the game. Please save the game manually."));
|
||||
|
@ -1067,7 +1063,7 @@ void autosave_savegame::create_filename()
|
|||
}
|
||||
|
||||
oos_savegame::oos_savegame(const config& snapshot_cfg)
|
||||
: ingame_savegame(*resources::state_of_game, *resources::screen, snapshot_cfg, preferences::compress_saves())
|
||||
: ingame_savegame(*resources::state_of_game, *resources::screen, snapshot_cfg, preferences::save_compression_format())
|
||||
{}
|
||||
|
||||
int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, const gui::DIALOG_TYPE /*dialog_type*/)
|
||||
|
@ -1090,7 +1086,7 @@ int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, co
|
|||
}
|
||||
|
||||
ingame_savegame::ingame_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves)
|
||||
game_display& gui, const config& snapshot_cfg, const compression::format compress_saves)
|
||||
: savegame(gamestate, compress_saves, _("Save Game")),
|
||||
gui_(gui)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gamestatus.hpp"
|
||||
#include "tod_manager.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "serialization/compression.hpp"
|
||||
|
||||
class config_writer;
|
||||
class game_display;
|
||||
|
@ -64,7 +65,7 @@ std::vector<save_info> get_saves_list(const std::string* dir = NULL, const std::
|
|||
void read_save_file(const std::string& name, config& cfg, std::string* error_log);
|
||||
|
||||
/** Returns true if there is already a savegame with that name. */
|
||||
bool save_game_exists(const std::string& name, bool compress_saves);
|
||||
bool save_game_exists(const std::string& name, compression::format compressed);
|
||||
|
||||
/** Delete all autosaves of a certain scenario. */
|
||||
void clean_saves(const std::string& label);
|
||||
|
@ -141,7 +142,7 @@ class savegame
|
|||
protected:
|
||||
/** The only constructor of savegame. The title parameter is only necessary if you
|
||||
intend to do interactive saves. */
|
||||
savegame(game_state& gamestate, const bool compress_saves, const std::string& title = "Save");
|
||||
savegame(game_state& gamestate, const compression::format compress_saves, const std::string& title = "Save");
|
||||
|
||||
public:
|
||||
virtual ~savegame() {}
|
||||
|
@ -223,7 +224,7 @@ private:
|
|||
|
||||
bool show_confirmation_; /** Determines if a confirmation of successful saving the game is shown. */
|
||||
|
||||
bool compress_saves_; /** Determines, if compression is used for the savegame file */
|
||||
compression::format compress_saves_; /** Determines, what compression format is used for the savegame file */
|
||||
};
|
||||
|
||||
/** Class for "normal" midgame saves. The additional members are needed for creating the snapshot
|
||||
|
@ -232,7 +233,7 @@ class ingame_savegame : public savegame
|
|||
{
|
||||
public:
|
||||
ingame_savegame(game_state& gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves);
|
||||
game_display& gui, const config& snapshot_cfg, const compression::format compress_saves);
|
||||
|
||||
private:
|
||||
/** Create a filename for automatic saves */
|
||||
|
@ -251,7 +252,7 @@ protected:
|
|||
class replay_savegame : public savegame
|
||||
{
|
||||
public:
|
||||
replay_savegame(game_state& gamestate, const bool compress_saves);
|
||||
replay_savegame(game_state& gamestate, const compression::format compress_saves);
|
||||
|
||||
private:
|
||||
/** Create a filename for automatic saves */
|
||||
|
@ -265,7 +266,7 @@ class autosave_savegame : public ingame_savegame
|
|||
{
|
||||
public:
|
||||
autosave_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves);
|
||||
game_display& gui, const config& snapshot_cfg, const compression::format compress_saves);
|
||||
|
||||
void autosave(const bool disable_autosave, const int autosave_max, const int infinite_autosaves);
|
||||
private:
|
||||
|
@ -287,7 +288,7 @@ private:
|
|||
class scenariostart_savegame : public savegame
|
||||
{
|
||||
public:
|
||||
scenariostart_savegame(game_state& gamestate, const bool compress_saves);
|
||||
scenariostart_savegame(game_state& gamestate, const compression::format compress_saves);
|
||||
|
||||
private:
|
||||
void write_game(config_writer &out);
|
||||
|
|
|
@ -1513,6 +1513,12 @@ static int impl_game_config_get(lua_State *L)
|
|||
return_bool_attrib("debug", game_config::debug);
|
||||
return_bool_attrib("debug_lua", game_config::debug_lua);
|
||||
return_bool_attrib("mp_debug", game_config::mp_debug);
|
||||
|
||||
const game_state & game_state_ = *resources::state_of_game;
|
||||
return_string_attrib("campaign_type", game_state_.classification().campaign_type);
|
||||
if(game_state_.classification().campaign_type=="multiplayer") {
|
||||
return_cfgref_attrib("mp_settings", game_state_.mp_settings().to_config());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ static lg::log_domain log_config("config");
|
|||
#define ERR_CF LOG_STREAM(err, log_config)
|
||||
|
||||
config_writer::config_writer(
|
||||
std::ostream &out, compressor compress) :
|
||||
std::ostream &out, compression::format compress) :
|
||||
filter_(),
|
||||
out_ptr_(compress ? &filter_ : &out), //ternary indirection creates a temporary
|
||||
out_(*out_ptr_), //now MSVC will allow binding to the reference member
|
||||
|
@ -42,11 +42,11 @@ config_writer::config_writer(
|
|||
level_(0),
|
||||
textdomain_(PACKAGE)
|
||||
{
|
||||
if(compress_ == GZIP) {
|
||||
if(compress_ == compression::GZIP) {
|
||||
filter_.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(9)));
|
||||
filter_.push(out);
|
||||
|
||||
} else if(compress_ == BZIP2) {
|
||||
} else if(compress_ == compression::BZIP2) {
|
||||
filter_.push(boost::iostreams::bzip2_compressor(boost::iostreams::bzip2_params()));
|
||||
filter_.push(out);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ config_writer::config_writer(
|
|||
filter_(),
|
||||
out_ptr_(compress ? &filter_ : &out), //ternary indirection creates a temporary
|
||||
out_(*out_ptr_), //now MSVC will allow binding to the reference member
|
||||
compress_(compress ? GZIP : NONE),
|
||||
compress_(compress ? compression::GZIP : compression::NONE),
|
||||
level_(0),
|
||||
textdomain_(PACKAGE)
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ config_writer::config_writer(
|
|||
config_writer::~config_writer()
|
||||
{
|
||||
//we only need this for gzip but we also do it for bz2 for unification.
|
||||
if(compress_ == GZIP || compress_ == BZIP2)
|
||||
if(compress_ == compression::GZIP || compress_ == compression::BZIP2)
|
||||
{
|
||||
// prevent empty gz files because of https://svn.boost.org/trac/boost/ticket/5237
|
||||
out_ << "\n";
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.hpp"
|
||||
#include "preprocessor.hpp"
|
||||
#include "serialization/compression.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
|
@ -28,8 +29,7 @@
|
|||
class config_writer
|
||||
{
|
||||
public:
|
||||
enum compressor { NONE, GZIP, BZIP2 };
|
||||
config_writer(std::ostream &out, compressor compress);
|
||||
config_writer(std::ostream &out, compression::format compress);
|
||||
config_writer(std::ostream &out, bool compress, int level = -1);
|
||||
/** Default implementation, but defined out-of-line for efficiency reasons. */
|
||||
~config_writer();
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
boost::iostreams::filtering_stream<boost::iostreams::output> filter_;
|
||||
std::ostream *out_ptr_;
|
||||
std::ostream &out_;
|
||||
compressor compress_;
|
||||
compression::format compress_;
|
||||
unsigned int level_;
|
||||
std::string textdomain_;
|
||||
};
|
||||
|
|
40
src/serialization/compression.hpp
Normal file
40
src/serialization/compression.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef COMPRESSION_HPP_INCLUDED
|
||||
#define COMPRESSION_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace compression {
|
||||
enum format {
|
||||
NONE,
|
||||
GZIP,
|
||||
BZIP2
|
||||
};
|
||||
|
||||
inline std::string format_extension(format compression_format)
|
||||
{
|
||||
switch(compression_format) {
|
||||
case GZIP:
|
||||
return ".gz";
|
||||
case BZIP2:
|
||||
return ".bz2";
|
||||
case NONE:
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -61,16 +61,16 @@ void time_of_day::write(config& cfg) const
|
|||
cfg["sound"] = sounds;
|
||||
}
|
||||
|
||||
void time_of_day::parse_times(const config& cfg, std::vector<time_of_day>& normal_times)
|
||||
void time_of_day::parse_times(const config& cfg, std::vector<time_of_day>& times)
|
||||
{
|
||||
BOOST_FOREACH(const config &t, cfg.child_range("time")) {
|
||||
normal_times.push_back(time_of_day(t));
|
||||
times.push_back(time_of_day(t));
|
||||
}
|
||||
|
||||
if(normal_times.empty())
|
||||
{
|
||||
// Make sure we have at least default time
|
||||
normal_times.push_back(time_of_day());
|
||||
}
|
||||
// if(times.empty())
|
||||
// {
|
||||
// // Make sure we have at least default time
|
||||
// times.push_back(time_of_day());
|
||||
// }
|
||||
}
|
||||
|
||||
|
|
|
@ -378,6 +378,7 @@ int tod_manager::calculate_current_time(
|
|||
const int current_time,
|
||||
const bool only_to_allowed_range) const
|
||||
{
|
||||
if (number_of_times == 0) return 0;
|
||||
int new_current_time = 0;
|
||||
if(only_to_allowed_range) new_current_time = current_time % number_of_times;
|
||||
else new_current_time = (current_time + for_turn_number - turn_) % number_of_times;
|
||||
|
|
Loading…
Add table
Reference in a new issue