mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 09:28:15 +00:00
properly applied patch #1100 by Broodkiller
(implements bug #11817: Allow [item]s to be visible only to specified teams) * fixed overlay initialization order * fixed some whitespace issues * added a changelog entry
This commit is contained in:
parent
dd47e71cbc
commit
beb1e6bb3b
@ -34,6 +34,8 @@ Version 1.5.3+svn:
|
||||
* prevent some negative/nonsense values in direct WML unit modifications
|
||||
* Renamed the advanceto key in [unit_type] to advances_to in order to be
|
||||
consistent with its own and [unit]'s internals.
|
||||
* implemented FR #11817: Allow [item]s to be visible only to specified teams
|
||||
(patch #1100 by Broodkiller)
|
||||
* Networking
|
||||
* removed null termination character from end of packet send by wesnoth
|
||||
* Miscellaneous and bug fixes:
|
||||
|
@ -338,8 +338,12 @@ void game_display::draw_hex(const gamemap::location& loc)
|
||||
typedef overlay_map::const_iterator Itor;
|
||||
std::pair<Itor,Itor> overlays = overlays_.equal_range(loc);
|
||||
for( ; overlays.first != overlays.second; ++overlays.first) {
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, tblit(xpos, ypos,
|
||||
image::get_image(overlays.first->second.image,image_type)));
|
||||
if (overlays.first->second.team_name == "" ||
|
||||
overlays.first->second.team_name.find(teams_[playing_team()].team_name()) != std::string::npos)
|
||||
{
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, tblit(xpos, ypos,
|
||||
image::get_image(overlays.first->second.image,image_type)));
|
||||
}
|
||||
}
|
||||
// village-control flags.
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, tblit(xpos, ypos, get_flag(loc)));
|
||||
@ -962,12 +966,12 @@ void game_display::clear_attack_indicator()
|
||||
set_attack_indicator(gamemap::location::null_location, gamemap::location::null_location);
|
||||
}
|
||||
|
||||
void game_display::add_overlay(const gamemap::location& loc, const std::string& img, const std::string& halo)
|
||||
void game_display::add_overlay(const gamemap::location& loc, const std::string& img, const std::string& halo,const std::string& team_name)
|
||||
{
|
||||
const int halo_handle = halo::add(get_location_x(loc) + hex_size() / 2,
|
||||
get_location_y(loc) + hex_size() / 2, halo, loc);
|
||||
|
||||
const overlay item(img,halo,halo_handle);
|
||||
const overlay item(img, halo, halo_handle, team_name);
|
||||
overlays_.insert(overlay_map::value_type(loc,item));
|
||||
}
|
||||
|
||||
@ -1010,6 +1014,20 @@ void game_display::write_overlays(config& cfg) const
|
||||
i->first.write(item);
|
||||
item["image"] = i->second.image;
|
||||
item["halo"] = i->second.halo;
|
||||
item["team_name"] = i->second.team_name;
|
||||
}
|
||||
}
|
||||
|
||||
void game_display::parse_team_overlays()
|
||||
{
|
||||
for (game_display::overlay_map::const_iterator overlay = overlays_.begin(); overlay != overlays_.end(); ++overlay) {
|
||||
|
||||
if (overlay->second.team_name != "" &&
|
||||
bool(overlay->second.team_name.find(teams_[playing_team()].team_name())+1) !=
|
||||
bool(overlay->second.team_name.find(teams_[playing_team()-1 > -1 ? playing_team()-1 : teams_.size()-1].team_name())+1))
|
||||
{
|
||||
invalidate(overlay->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public:
|
||||
//! Functions to add and remove overlays from locations.
|
||||
//! An overlay is an image that is displayed on top of the tile.
|
||||
//! One tile may have multiple overlays.
|
||||
void add_overlay(const gamemap::location& loc, const std::string& image, const std::string& halo="");
|
||||
void add_overlay(const gamemap::location& loc, const std::string& image, const std::string& halo="", const std::string& team_name="");
|
||||
//! remove_overlay will remove all overlays on a tile.
|
||||
void remove_overlay(const gamemap::location& loc);
|
||||
//! remove_single_overlay will remove a single overlay from a tile
|
||||
@ -180,6 +180,9 @@ public:
|
||||
//! Function to serialize overlay data.
|
||||
void write_overlays(config& cfg) const;
|
||||
|
||||
//! Check the overlay_map for proper team-specific overlays
|
||||
//! to be displayed/hidden
|
||||
void parse_team_overlays();
|
||||
|
||||
// Functions used in the editor:
|
||||
|
||||
@ -278,10 +281,11 @@ private:
|
||||
|
||||
struct overlay {
|
||||
overlay(const std::string& img, const std::string& halo_img,
|
||||
int handle) : image(img), halo(halo_img),
|
||||
halo_handle(handle) {}
|
||||
int handle, const std::string& overlay_team_name) : image(img), halo(halo_img),
|
||||
team_name(overlay_team_name), halo_handle(handle) {}
|
||||
std::string image;
|
||||
std::string halo;
|
||||
std::string team_name;
|
||||
int halo_handle;
|
||||
};
|
||||
|
||||
|
@ -1564,9 +1564,10 @@ namespace {
|
||||
gamemap::location loc = cfg_to_loc(cfg);
|
||||
std::string img = cfg["image"];
|
||||
std::string halo = cfg["halo"];
|
||||
std::string team_name = cfg["team_name"];
|
||||
assert(state_of_game != NULL);
|
||||
if(!img.empty() || !halo.empty()) {
|
||||
(screen)->add_overlay(loc,img,halo);
|
||||
(screen)->add_overlay(loc, img, halo, team_name);
|
||||
(screen)->invalidate(loc);
|
||||
(screen)->draw();
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector<config*>& st
|
||||
// Find a list of 'items' (i.e. overlays) on the level, and add them
|
||||
const config::child_list& overlays = level_.get_children("item");
|
||||
for(config::child_list::const_iterator overlay = overlays.begin(); overlay != overlays.end(); ++overlay) {
|
||||
gui_->add_overlay(gamemap::location(**overlay,game_events::get_state_of_game()),(**overlay)["image"], (**overlay)["halo"]);
|
||||
gui_->add_overlay(gamemap::location(**overlay, game_events::get_state_of_game()), (**overlay)["image"], (**overlay)["halo"], (**overlay)["team_name"]);
|
||||
}
|
||||
|
||||
victory_conditions::set_victory_when_enemies_defeated(
|
||||
@ -563,6 +563,9 @@ void playsingle_controller::play_turn(bool save)
|
||||
|
||||
void playsingle_controller::play_side(const unsigned int team_index, bool save)
|
||||
{
|
||||
//check for team-specific items in the scenario
|
||||
gui_->parse_team_overlays();
|
||||
|
||||
//flag used when we fallback from ai and give temporarily control to human
|
||||
bool temporary_human = false;
|
||||
do {
|
||||
|
Loading…
x
Reference in New Issue
Block a user