1
0
Fork 0

(svn r24767) -Codechange: Remove some fragile hacks from the multiplayer list who tried to disguised themself as optimisations.

release/1.3
frosch 2012-11-27 21:21:01 +00:00
parent b5674ea9fa
commit 9aeeb5acb9
1 changed files with 15 additions and 28 deletions

View File

@ -329,27 +329,19 @@ protected:
/** Sort the server list */ /** Sort the server list */
void SortNetworkGameList() void SortNetworkGameList()
{ {
bool did_sort = this->servers.Sort(); if (this->servers.Sort()) this->UpdateListPos();
/* In case of 0 or 1 servers there is no sorting, thus this->list_pos }
* isn't set to a "sane" value. So, we only take the short way out
* when we did not (re)sort and we have a valid this->list_pos, or
* there are no servers to actually select. */
if (!did_sort && (this->list_pos != SLP_INVALID || this->servers.Length() == 0)) return;
/* After sorting ngl->sort_list contains the sorted items. Put these back /** Set this->list_pos to match this->server */
* into the original list. Basically nothing has changed, we are only void UpdateListPos()
* shuffling the ->next pointers. While iterating, look for the {
* currently selected server and set list_pos to its position */
this->list_pos = SLP_INVALID; this->list_pos = SLP_INVALID;
_network_game_list = this->servers[0]; for (uint i = 0; i != this->servers.Length(); i++) {
NetworkGameList *item = _network_game_list; if (this->servers[i] == this->server) {
if (item == this->server) this->list_pos = 0; this->list_pos = i;
for (uint i = 1; i != this->servers.Length(); i++) { break;
item->next = this->servers[i]; }
item = item->next;
if (item == this->server) this->list_pos = i;
} }
item->next = NULL;
} }
/** /**
@ -705,12 +697,7 @@ public:
this->server = this->last_joined; this->server = this->last_joined;
/* search the position of the newly selected server */ /* search the position of the newly selected server */
for (uint i = 0; i < this->servers.Length(); i++) { this->UpdateListPos();
if (this->servers[i] == this->server) {
this->list_pos = i;
break;
}
}
this->ScrollToSelectedServer(); this->ScrollToSelectedServer();
this->SetDirty(); this->SetDirty();
@ -797,22 +784,22 @@ public:
switch (keycode) { switch (keycode) {
case WKC_UP: case WKC_UP:
/* scroll up by one */ /* scroll up by one */
if (this->server == NULL) return ES_HANDLED; if (this->list_pos == SLP_INVALID) return ES_HANDLED;
if (this->list_pos > 0) this->list_pos--; if (this->list_pos > 0) this->list_pos--;
break; break;
case WKC_DOWN: case WKC_DOWN:
/* scroll down by one */ /* scroll down by one */
if (this->server == NULL) return ES_HANDLED; if (this->list_pos == SLP_INVALID) return ES_HANDLED;
if (this->list_pos < this->servers.Length() - 1) this->list_pos++; if (this->list_pos < this->servers.Length() - 1) this->list_pos++;
break; break;
case WKC_PAGEUP: case WKC_PAGEUP:
/* scroll up a page */ /* scroll up a page */
if (this->server == NULL) return ES_HANDLED; if (this->list_pos == SLP_INVALID) return ES_HANDLED;
this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity(); this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity();
break; break;
case WKC_PAGEDOWN: case WKC_PAGEDOWN:
/* scroll down a page */ /* scroll down a page */
if (this->server == NULL) return ES_HANDLED; if (this->list_pos == SLP_INVALID) return ES_HANDLED;
this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.Length() - 1); this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.Length() - 1);
break; break;
case WKC_HOME: case WKC_HOME: