summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2023-10-28 14:50:52 +0200
committerAldrik Ramaekers <aldrik@amftech.nl>2023-10-28 14:50:52 +0200
commit7d87e8e3e9eccbb3ae351f3218276b2dae506665 (patch)
tree2a38f9ba83bb66c9e85b67aa7a18c4a4942e8d1f /src
parent5de0682c37fc8e9713bb566a637f19a3795abc4a (diff)
fix issue with sprites
Diffstat (limited to 'src')
-rw-r--r--src/game.c17
-rw-r--r--src/protocol.c8
-rw-r--r--src/throwables.c9
3 files changed, 25 insertions, 9 deletions
diff --git a/src/game.c b/src/game.c
index 993d82e..6bb0301 100644
--- a/src/game.c
+++ b/src/game.c
@@ -180,6 +180,7 @@ void update_server(platform_window* window) {
update_spawners_server();
update_drops_server();
update_wallitems_server();
+ update_throwables_server();
broadcast_players = platform_get_time(TIME_FULL, TIME_NS);
update_players_server();
@@ -188,8 +189,7 @@ void update_server(platform_window* window) {
broadcast_zombies = platform_get_time(TIME_FULL, TIME_NS);
update_zombies_server(window);
broadcast_zombies = platform_get_time(TIME_FULL, TIME_NS) - broadcast_zombies;
-
- update_throwables_server(window);
+
clear_throwables();
broadcast_stamp = platform_get_time(TIME_FULL, TIME_NS);
@@ -200,7 +200,7 @@ void update_server(platform_window* window) {
// play sounds locally and send them to clients.
play_sounds_in_queue();
-
+ broadcast_to_clients(create_protocol_sound_list());
clear_sounds_in_queue();
update_timer = 0.0f;
@@ -251,6 +251,10 @@ void update_client(platform_window* window) {
case MESSAGE_USER_LIST: {
protocol_user_list* msg_players = (protocol_user_list*)msg;
memcpy(players, msg_players->players, sizeof(players));
+
+ for (int i = 0; i < MAX_PLAYERS; i++) {
+ players[i].sprite.image = img_player;
+ }
} break;
case MESSAGE_ZOMBIE_LIST: {
@@ -267,6 +271,13 @@ void update_client(platform_window* window) {
protocol_drop_list* msg_drops = (protocol_drop_list*)msg;
memcpy(drops, msg_drops->drops, sizeof(drops));
} break;
+
+ case MESSAGE_SOUND_LIST: {
+ protocol_sound_list* msg_sound = (protocol_sound_list*)msg;
+ memcpy(audio_events, msg_sound->audio_events, sizeof(audio_events));
+ play_sounds_in_queue();
+ clear_sounds_in_queue();
+ } break;
default:
log_info("Unhandled message received");
break;
diff --git a/src/protocol.c b/src/protocol.c
index e0af132..307aac3 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -19,6 +19,14 @@ network_message create_protocol_get_id_down(u32 id)
return network_create_message((u8*)buf, sizeof(protocol_get_id_downstream), MAX_NETWORK_BUFFER_SIZE);
}
+network_message create_protocol_sound_list()
+{
+ protocol_sound_list *buf = alloc_network_message(protocol_sound_list);
+ buf->type = MESSAGE_SOUND_LIST;
+ memcpy(buf->audio_events, audio_events, sizeof(audio_events));
+ return network_create_message((u8*)buf, sizeof(protocol_sound_list), MAX_NETWORK_BUFFER_SIZE);
+}
+
network_message create_protocol_user_list()
{
protocol_user_list *buf = alloc_network_message(protocol_user_list);
diff --git a/src/throwables.c b/src/throwables.c
index 1ad761f..275e95b 100644
--- a/src/throwables.c
+++ b/src/throwables.c
@@ -28,10 +28,7 @@ void throw_throwable(platform_window* window, u32 id, throwable_type type, float
}
}
-bool check_if_throwable_collided_with_object(throwable* b, platform_window* window, vec3f oldpos, vec3f newpos, vec3f* direction) {
- map_info info = get_map_info(window);
- float size = get_bullet_size_in_tile(window);
-
+bool check_if_throwable_collided_with_object(throwable* b, vec3f oldpos, vec3f newpos, vec3f* direction) {
bool result = false;
for (int i = 0; i < MAX_OBJECTS; i++) {
@@ -69,7 +66,7 @@ bool check_if_throwable_collided_with_object(throwable* b, platform_window* wind
return result;
}
-void update_throwables_server(platform_window* window) {
+void update_throwables_server() {
float speed = 7.0f * SERVER_TICK_RATE;
float gravity = 0.015f;
@@ -101,7 +98,7 @@ void update_throwables_server(platform_window* window) {
if (throwables[i].bounces >= 3) throwables[i].direction.z = 0;
}
- if (check_if_throwable_collided_with_object(&throwables[i], window, oldpos, throwables[i].position, &throwables[i].direction)) {
+ if (check_if_throwable_collided_with_object(&throwables[i], oldpos, throwables[i].position, &throwables[i].direction)) {
add_audio_event_to_queue(EVENT_BOUNCE_THROWABLE, b.player_id, b.position);
}
}