summaryrefslogtreecommitdiff
path: root/network_udp.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-08-20 18:40:57 +0000
committerrubidium <rubidium@openttd.org>2006-08-20 18:40:57 +0000
commit28a08437075be6495df383ca854f6026965a8b8e (patch)
tree146ad5e3c72a49bcc04fae58e750b972f063d8c2 /network_udp.c
parent5e4667624e5093ea2b83bcdf63d836d1a34d46bc (diff)
downloadopenttd-28a08437075be6495df383ca854f6026965a8b8e.tar.xz
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
The game date subsystem now allows someone to start in the year 0 and continue up to the year 5 000 000. However, you currently cannot build anything before 1920 as there is no newgrf support for dates before 1920 or after 2090 yet.
Diffstat (limited to 'network_udp.c')
-rw-r--r--network_udp.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/network_udp.c b/network_udp.c
index de811c722..aacf53372 100644
--- a/network_udp.c
+++ b/network_udp.c
@@ -63,6 +63,10 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER)
NetworkSend_uint8 (packet, NETWORK_GAME_INFO_VERSION);
+ /* NETWORK_GAME_INFO_VERSION = 3 */
+ NetworkSend_uint32(packet, _network_game_info.game_date);
+ NetworkSend_uint32(packet, _network_game_info.start_date);
+
/* NETWORK_GAME_INFO_VERSION = 2 */
NetworkSend_uint8 (packet, _network_game_info.companies_max);
NetworkSend_uint8 (packet, ActivePlayerCount());
@@ -76,8 +80,6 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER)
NetworkSend_uint8 (packet, _network_game_info.clients_max);
NetworkSend_uint8 (packet, _network_game_info.clients_on);
NetworkSend_uint8 (packet, NetworkSpectatorCount());
- NetworkSend_uint16(packet, _network_game_info.game_date);
- NetworkSend_uint16(packet, _network_game_info.start_date);
NetworkSend_string(packet, _network_game_info.map_name);
NetworkSend_uint16(packet, _network_game_info.map_width);
NetworkSend_uint16(packet, _network_game_info.map_height);
@@ -114,6 +116,10 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE)
/* Please observer the order. In the order in which packets are sent
* they are to be received */
switch (game_info_version) {
+ case 3:
+ item->info.game_date = NetworkRecv_uint32(&_udp_cs, p);
+ item->info.start_date = NetworkRecv_uint32(&_udp_cs, p);
+ /* Fallthrough */
case 2:
item->info.companies_max = NetworkRecv_uint8(&_udp_cs, p);
item->info.companies_on = NetworkRecv_uint8(&_udp_cs, p);
@@ -127,8 +133,10 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE)
item->info.clients_max = NetworkRecv_uint8(&_udp_cs, p);
item->info.clients_on = NetworkRecv_uint8(&_udp_cs, p);
item->info.spectators_on = NetworkRecv_uint8(&_udp_cs, p);
- item->info.game_date = NetworkRecv_uint16(&_udp_cs, p);
- item->info.start_date = NetworkRecv_uint16(&_udp_cs, p);
+ if (game_info_version < 3) { // 16 bits dates got scrapped and are read earlier
+ item->info.game_date = NetworkRecv_uint16(&_udp_cs, p) + DAYS_TILL_ORIGINAL_BASE_YEAR;
+ item->info.start_date = NetworkRecv_uint16(&_udp_cs, p) + DAYS_TILL_ORIGINAL_BASE_YEAR;
+ }
NetworkRecv_string(&_udp_cs, p, item->info.map_name, sizeof(item->info.map_name));
item->info.map_width = NetworkRecv_uint16(&_udp_cs, p);
item->info.map_height = NetworkRecv_uint16(&_udp_cs, p);
@@ -185,7 +193,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
NetworkSend_uint8(packet, current);
NetworkSend_string(packet, _network_player_info[player->index].company_name);
- NetworkSend_uint8 (packet, _network_player_info[player->index].inaugurated_year);
+ NetworkSend_uint32(packet, _network_player_info[player->index].inaugurated_year);
NetworkSend_uint64(packet, _network_player_info[player->index].company_value);
NetworkSend_uint64(packet, _network_player_info[player->index].money);
NetworkSend_uint64(packet, _network_player_info[player->index].income);
@@ -212,7 +220,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
NetworkSend_uint8(packet, 1);
NetworkSend_string(packet, ci->client_name);
NetworkSend_string(packet, ci->unique_id);
- NetworkSend_uint16(packet, ci->join_date);
+ NetworkSend_uint32(packet, ci->join_date);
}
}
/* Also check for the server itself */
@@ -222,7 +230,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
NetworkSend_uint8(packet, 1);
NetworkSend_string(packet, ci->client_name);
NetworkSend_string(packet, ci->unique_id);
- NetworkSend_uint16(packet, ci->join_date);
+ NetworkSend_uint32(packet, ci->join_date);
}
/* Indicates end of client list */
@@ -237,7 +245,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
NetworkSend_uint8(packet, 1);
NetworkSend_string(packet, ci->client_name);
NetworkSend_string(packet, ci->unique_id);
- NetworkSend_uint16(packet, ci->join_date);
+ NetworkSend_uint32(packet, ci->join_date);
}
}
/* Also check for the server itself */
@@ -247,7 +255,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
NetworkSend_uint8(packet, 1);
NetworkSend_string(packet, ci->client_name);
NetworkSend_string(packet, ci->unique_id);
- NetworkSend_uint16(packet, ci->join_date);
+ NetworkSend_uint32(packet, ci->join_date);
}
/* Indicates end of client list */