added a 'require_era' attribute for eras.
If set, players will have to have the era to be able to join the game
This commit is contained in:
parent
719c6fff9b
commit
e7a5e57055
3 changed files with 13 additions and 3 deletions
|
@ -125,7 +125,9 @@ void gamebrowser::draw_row(const size_t index, const SDL_Rect& item_rect, ROW_TY
|
|||
|
||||
// Set font color
|
||||
SDL_Color font_color;
|
||||
if (game.vacant_slots > 0) {
|
||||
if (!game.password_required) {
|
||||
font_color = font::BAD_COLOUR;
|
||||
} else if (game.vacant_slots > 0) {
|
||||
if (game.reloaded || game.started) {
|
||||
font_color = font::YELLOW_COLOUR;
|
||||
} else {
|
||||
|
@ -393,6 +395,7 @@ void gamebrowser::set_game_items(const config& cfg, const config& game_config)
|
|||
games_.push_back(game_item());
|
||||
games_.back().password_required = (**game)["password"] == "yes";
|
||||
games_.back().reloaded = (**game)["savegame"] == "yes";
|
||||
games_.back().have_era = true;
|
||||
if((**game)["mp_era"] != "") {
|
||||
const config* const era_cfg = game_config.find_child("era", "id", (**game)["mp_era"]);
|
||||
utils::string_map symbols;
|
||||
|
@ -400,6 +403,9 @@ void gamebrowser::set_game_items(const config& cfg, const config& game_config)
|
|||
if (era_cfg != NULL) {
|
||||
games_.back().map_info = era_cfg->get_attribute("name");
|
||||
} else {
|
||||
if((**game)["require_era"] == "yes") {
|
||||
games_.back().have_era = false;
|
||||
}
|
||||
games_.back().map_info = vgettext("Unknown era: $era_id", symbols);
|
||||
verified = false;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
bool use_map_settings;
|
||||
bool verified;
|
||||
bool password_required;
|
||||
bool have_era;
|
||||
};
|
||||
gamebrowser(CVideo& video,const config* map_hashes);
|
||||
void scroll(unsigned int pos);
|
||||
|
@ -67,8 +68,8 @@ public:
|
|||
SDL_Rect get_item_rect(size_t index) const;
|
||||
bool empty() const { return games_.empty(); }
|
||||
bool selection_is_joinable() const
|
||||
{ return empty() ? false : (games_[selected_].vacant_slots > 0 && !games_[selected_].started); }
|
||||
bool selection_is_observable() const { return empty() ? false : games_[selected_].observers; }
|
||||
{ return empty() ? false : (games_[selected_].vacant_slots > 0 && !games_[selected_].started && games_[selected_].have_era); }
|
||||
bool selection_is_observable() const { return empty() ? false : games_[selected_].observers && games_[selected_].have_era; }
|
||||
bool selected() const { return double_clicked_ && !empty(); }
|
||||
void reset_selection() { double_clicked_ = false; }
|
||||
int selection() const { return selected_; }
|
||||
|
|
|
@ -1236,6 +1236,9 @@ void server::process_data_game(const network::connection sock,
|
|||
}
|
||||
if(data.child("era")) {
|
||||
desc.set_attr_dup("mp_era", data.child("era")->attr("id"));
|
||||
if(data.child("era")->attr("require_era").to_bool()) {
|
||||
desc.set_attr("require_era", "yes");
|
||||
}
|
||||
} else {
|
||||
desc.set_attr("mp_era", "");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue