Author: ilor
Date: Fri Feb 12 21:26:25 2010
New Revision: 41173
URL: http://svn.gna.org/viewcvs/wesnoth?rev=41173&view=rev
Log:
Lobby gamelist "joined diffs".
The lobby now polls the network much more often (new game_config variable,
100ms at the moment), but updates the gamelist differences at most every
game_config::lobby_refresh msecs (which was bumped to 4000).
Modified:
trunk/src/game_config.cpp
trunk/src/game_config.hpp
trunk/src/gui/dialogs/lobby/lobby_info.cpp
trunk/src/gui/dialogs/lobby_main.cpp
trunk/src/gui/dialogs/lobby_main.hpp
Modified: trunk/src/game_config.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_config.cpp?rev=41173&r1=41172&r2=41173&view=diff
==============================================================================
--- trunk/src/game_config.cpp (original)
+++ trunk/src/game_config.cpp Fri Feb 12 21:26:25 2010
@@ -40,7 +40,8 @@
int rest_heal_amount= 2;
int recall_cost = 20;
int kill_experience = 8;
- unsigned lobby_refresh = 2000;
+ unsigned lobby_network_timer = 100;
+ unsigned lobby_refresh = 4000;
const int gold_carryover_percentage = 80;
const std::string version = VERSION;
#ifdef REVISION
Modified: trunk/src/game_config.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_config.hpp?rev=41173&r1=41172&r2=41173&view=diff
==============================================================================
--- trunk/src/game_config.hpp (original)
+++ trunk/src/game_config.hpp Fri Feb 12 21:26:25 2010
@@ -35,6 +35,7 @@
extern int rest_heal_amount;
extern int recall_cost;
extern int kill_experience;
+ extern unsigned lobby_network_timer;
extern unsigned lobby_refresh;
extern const std::string version;
extern const std::string revision;
Modified: trunk/src/gui/dialogs/lobby/lobby_info.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/lobby/lobby_info.cpp?rev=41173&r1=41172&r2=41173&view=diff
==============================================================================
--- trunk/src/gui/dialogs/lobby/lobby_info.cpp (original)
+++ trunk/src/gui/dialogs/lobby/lobby_info.cpp Fri Feb 12 21:26:25 2010
@@ -151,7 +151,13 @@
if (current_i == games_by_id_.end()) {
WRN_LB << "Would have to delete a game that I
don't have: " << game_id << "\n";
} else {
- current_i->second->display_status =
game_info::DELETED;
+ if (current_i->second->display_status ==
game_info::NEW) {
+ //this means the game never made it
through to the user interface
+ //so just deleting it is fine
+ games_by_id_.erase(current_i);
+ } else {
+ current_i->second->display_status =
game_info::DELETED;
+ }
}
}
}
Modified: trunk/src/gui/dialogs/lobby_main.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/lobby_main.cpp?rev=41173&r1=41172&r2=41173&view=diff
==============================================================================
--- trunk/src/gui/dialogs/lobby_main.cpp (original)
+++ trunk/src/gui/dialogs/lobby_main.cpp Fri Feb 12 21:26:25 2010
@@ -390,6 +390,9 @@
, selected_game_id_()
, player_list_()
, player_list_dirty_(false)
+ , gamelist_dirty_(false)
+ , last_gamelist_update_(0)
+ , gamelist_diff_update_(false)
, disp_(disp)
, lobby_update_timer_(0)
, preferences_wrapper_()
@@ -588,6 +591,9 @@
gamelistbox_->select_row(select_row);
}
update_selected_game();
+ gamelist_dirty_ = false;
+ last_gamelist_update_ = SDL_GetTicks();
+ lobby_info_.sync_games_display_status();
}
void tlobby_main::update_gamelist_diff()
@@ -662,6 +668,9 @@
gamelistbox_->select_row(select_row);
}
update_selected_game();
+ gamelist_dirty_ = false;
+ last_gamelist_update_ = SDL_GetTicks();
+ lobby_info_.sync_games_display_status();
}
void tlobby_main::update_gamelist_header()
@@ -1010,7 +1019,7 @@
// Force first update to be directly.
tlobby_main::network_handler();
- lobby_update_timer_ = add_timer(game_config::lobby_refresh
+ lobby_update_timer_ = add_timer(game_config::lobby_network_timer
, boost::bind(&tlobby_main::network_handler, this)
, true);
}
@@ -1265,6 +1274,13 @@
void tlobby_main::network_handler()
{
+ if (gamelist_dirty_ && (SDL_GetTicks() - last_gamelist_update_ >
game_config::lobby_refresh)) {
+ if (gamelist_diff_update_) {
+ update_gamelist_diff();
+ } else {
+ update_gamelist();
+ }
+ }
if (player_list_dirty_) {
update_gamelist_filter();
update_playerlist();
@@ -1348,59 +1364,30 @@
void tlobby_main::process_gamelist(const config &data)
{
lobby_info_.process_gamelist(data);
- update_gamelist();
- lobby_info_.sync_games_display_status();
+ DBG_LB << "Received gamelist\n";
+ gamelist_dirty_ = true;
+ gamelist_diff_update_ = false;
+ //update_gamelist();
+ //lobby_info_.sync_games_display_status();
}
void tlobby_main::process_gamelist_diff(const config &data)
{
- if(!new_widgets) {
- // Copy pasted from the part below, we should call invalidate
layout
- // when needed.
- if (lobby_info_.process_gamelist_diff(data)) {
- update_gamelist_diff();
- lobby_info_.sync_games_display_status();
- }
- int joined = data.child_count("insert_child");
- int left = data.child_count("remove_child");
- if (joined > 0 || left > 0) {
- if (left > joined) {
- do_notify(NOTIFY_LOBBY_QUIT);
- } else {
- do_notify(NOTIFY_LOBBY_JOIN);
- }
- }
- } else {
- assert(window_);
- twindow::tinvalidate_layout_blocker blocker(*window_);
-
- if (lobby_info_.process_gamelist_diff(data)) {
- update_gamelist_diff();
- lobby_info_.sync_games_display_status();
- }
- int joined = data.child_count("insert_child");
- int left = data.child_count("remove_child");
- if (joined > 0 || left > 0) {
- if (left > joined) {
- do_notify(NOTIFY_LOBBY_QUIT);
- } else {
- do_notify(NOTIFY_LOBBY_JOIN);
- }
- }
- }
-
- /*
- * As long as the layout is valid update all listboxes; if
- * update_content_size() returns false the layout is invalidated. If
- * invalidated the trying to size the other listboxes is a waste of
- * effort, since they will be requested for a layout phase anyway.
- */
- if(!window_->get_need_layout()) {
- player_list_.active_game.list->update_content_size()
- &&
player_list_.active_room.list->update_content_size()
- &&
player_list_.other_rooms.list->update_content_size()
- &&
player_list_.other_games.list->update_content_size()
- && gamelistbox_->update_content_size();
+ if (lobby_info_.process_gamelist_diff(data)) {
+ DBG_LB << "Received gamelist diff\n";
+ gamelist_dirty_ = true;
+ gamelist_diff_update_ = true;
+ } else {
+ ERR_LB << "process_gamelist_diff failed!\n";
+ }
+ int joined = data.child_count("insert_child");
+ int left = data.child_count("remove_child");
+ if (joined > 0 || left > 0) {
+ if (left > joined) {
+ do_notify(NOTIFY_LOBBY_QUIT);
+ } else {
+ do_notify(NOTIFY_LOBBY_JOIN);
+ }
}
}
Modified: trunk/src/gui/dialogs/lobby_main.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/lobby_main.hpp?rev=41173&r1=41172&r2=41173&view=diff
==============================================================================
--- trunk/src/gui/dialogs/lobby_main.hpp (original)
+++ trunk/src/gui/dialogs/lobby_main.hpp Fri Feb 12 21:26:25 2010
@@ -379,6 +379,12 @@
bool player_list_dirty_;
+ bool gamelist_dirty_;
+
+ unsigned last_gamelist_update_;
+
+ bool gamelist_diff_update_;
+
display& disp_;
/** Timer for updating the lobby. */
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits