1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-22 05:59:10 +00:00

(svn r15104) -Codechange: unify the resolving of the xyz kbytes/megabytes strings.

This commit is contained in:
rubidium
2009-01-16 12:59:47 +00:00
parent cdd3676478
commit b1a33a494f
57 changed files with 138 additions and 114 deletions

View File

@@ -556,8 +556,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
_frame_counter = _frame_counter_server = _frame_counter_max = p->Recv_uint32();
_network_join_kbytes = 0;
_network_join_kbytes_total = p->Recv_uint32() / 1024;
_network_join_bytes = 0;
_network_join_bytes_total = p->Recv_uint32();
/* If the network connection has been closed due to loss of connection
* or when _network_join_kbytes_total is 0, the join status window will
@@ -565,7 +565,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
* that. If kbytes_total is 0, the packet must be malformed as a
* savegame less than 1 kilobyte is practically impossible. */
if (MY_CLIENT->has_quit) return NETWORK_RECV_STATUS_CONN_LOST;
if (_network_join_kbytes_total == 0) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
if (_network_join_bytes_total == 0) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
@@ -581,7 +581,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
return NETWORK_RECV_STATUS_SAVEGAME;
}
_network_join_kbytes = ftell(file_pointer) / 1024;
_network_join_bytes = ftell(file_pointer);
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
}

View File

@@ -1765,8 +1765,8 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
// Vars needed for the join-GUI
NetworkJoinStatus _network_join_status;
uint8 _network_join_waiting;
uint16 _network_join_kbytes;
uint16 _network_join_kbytes_total;
uint32 _network_join_bytes;
uint32 _network_join_bytes_total;
struct NetworkJoinStatusWindow : Window {
NetworkJoinStatusWindow(const WindowDesc *desc) : Window(desc)
@@ -1791,12 +1791,12 @@ struct NetworkJoinStatusWindow : Window {
progress = 15; // third stage is 15%
break;
case NETWORK_JOIN_STATUS_DOWNLOADING:
SetDParam(0, _network_join_kbytes);
SetDParam(1, _network_join_kbytes_total);
SetDParam(0, _network_join_bytes);
SetDParam(1, _network_join_bytes_total);
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_DOWNLOADING, TC_GREY);
/* Fallthrough */
default: /* Waiting is 15%, so the resting receivement of map is maximum 70% */
progress = 15 + _network_join_kbytes * (100 - 15) / _network_join_kbytes_total;
progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
}
/* Draw nice progress bar :) */

View File

@@ -111,8 +111,8 @@ extern bool _network_first_time;
// Vars needed for the join-GUI
extern NetworkJoinStatus _network_join_status;
extern uint8 _network_join_waiting;
extern uint16 _network_join_kbytes;
extern uint16 _network_join_kbytes_total;
extern uint32 _network_join_bytes;
extern uint32 _network_join_bytes_total;
extern uint32 _network_last_host_ip;
extern uint8 _network_reconnect;