summaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2022-12-18 20:17:16 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2022-12-18 20:17:16 +0100
commite917400634a535c6c14afc4e37a759f7c777b73a (patch)
tree5c8a5de1c6c09985395fbfb660a27500a65d1de0 /src/game.c
parent3e825971102a33dfbb82a20a365684d413bc1ba8 (diff)
server tick rate
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/game.c b/src/game.c
index b426761..d3cbb57 100644
--- a/src/game.c
+++ b/src/game.c
@@ -59,8 +59,10 @@ void load_map() {
outgoing_allocator = create_allocator(MAX_NETWORK_BUFFER_SIZE);
messages_to_send_queue_mutex = mutex_create();
- thread send_thread = thread_start(network_send_thread, 0);
- thread_detach(&send_thread);
+ for (int i = 0; i < 3; i++) {
+ thread send_thread = thread_start(network_send_thread, 0);
+ thread_detach(&send_thread);
+ }
load_map_from_data();
create_objects();
@@ -171,14 +173,14 @@ void update_server(platform_window* window) {
allocator_clear(&server_incomming_allocator);
mutex_unlock(&messages_received_on_server.mutex);
- update_spawners();
- update_drops();
- update_wallitems();
- update_bullets(window);
- update_players_server();
- update_zombies_server(window);
+ if (update_timer >= SERVER_TICK_RATE) { // send at 60 ticks
+ update_spawners_server();
+ update_drops_server();
+ update_wallitems_server();
+ update_bullets_server(window);
+ update_players_server();
+ update_zombies_server(window);
- if (update_timer >= (1/60.0f)) { // send at 60 ticks
broadcast_to_clients(create_protocol_user_list());
broadcast_to_clients(create_protocol_zombie_list());
broadcast_to_clients(create_protocol_bullets_list());