summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2023-11-07 18:36:59 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2023-11-07 18:36:59 +0100
commitcf3cfecbcac3835c84dce3711884b7ce0a81b6b8 (patch)
tree413861dbca37c2a13129a97367d40a06cdd8d4f9 /src
parent8777713844f81a7ee171ddbd4e910d83122c9f74 (diff)
sync round data
Diffstat (limited to 'src')
-rw-r--r--src/game.c7
-rw-r--r--src/protocol.c7
2 files changed, 13 insertions, 1 deletions
diff --git a/src/game.c b/src/game.c
index 1f71495..2ebbcf0 100644
--- a/src/game.c
+++ b/src/game.c
@@ -236,6 +236,7 @@ void update_server(platform_window* window) {
broadcast_to_clients(create_protocol_drop_list());
broadcast_to_clients(create_protocol_throwables_list());
broadcast_to_clients(create_protocol_zombie_chunk_list());
+ broadcast_to_clients(create_protocol_round_data(_current_round));
// play sounds locally and send them to clients.
play_sounds_in_queue();
@@ -252,7 +253,6 @@ void update_server(platform_window* window) {
handle_messages = handle_messages - logic_update_time;
logic_update_time = platform_get_time(TIME_FULL, TIME_NS) - logic_update_time;
u64 server_tick = platform_get_time(TIME_FULL, TIME_NS) - handle_messages2;
- broadcast_stamp = platform_get_time(TIME_FULL, TIME_NS) - broadcast_stamp;
if ((logic_update_time/1000000.0f) > 10.0f) {
log_infox("Server update took %.2fms:\n\tmessages: %.2fms\n\ttick: %.2fms\n\t\tbroadcast: %.2fms\n\t\tplayers: %.2fms\n\t\tzombies: %.2fms\n",
(logic_update_time/1000000.0f), (handle_messages/1000000.0f), (server_tick/1000000.0f),
@@ -293,6 +293,11 @@ void update_client(platform_window* window) {
memcpy(players, msg_players->players, sizeof(players));
} break;
+ case MESSAGE_ROUND_DATA: {
+ protocol_round* msg_round = (protocol_round*)msg;
+ _current_round = msg_round->round;
+ } break;
+
case MESSAGE_ZOMBIE_LIST: {
protocol_zombie_list* msg_zombies = (protocol_zombie_list*)msg;
memcpy(zombies, msg_zombies->zombies, sizeof(zombies));
diff --git a/src/protocol.c b/src/protocol.c
index de1a8d1..b6c03ee 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -75,6 +75,13 @@ network_message create_protocol_drop_list()
return network_create_message((u8*)buf, sizeof(protocol_drop_list), MAX_NETWORK_BUFFER_SIZE);
}
+network_message create_protocol_round_data(zombie_round round)
+{
+ protocol_round *buf = alloc_network_message(protocol_round);
+ buf->type = MESSAGE_ROUND_DATA;
+ buf->round = round;
+ return network_create_message((u8*)buf, sizeof(protocol_round), MAX_NETWORK_BUFFER_SIZE);
+}
network_message create_protocol_user_moved(protocol_move_type move, u32 id)
{