Skip to content

Commit

Permalink
fix: send initial positions correctly for non ghost mode settings
Browse files Browse the repository at this point in the history
also fixed debugging segfault trigger being optimized away by compilers
  • Loading branch information
Xenapte committed Jan 8, 2025
1 parent 81eb7ca commit c0ce672
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion BallanceMMOCommon/include/role/role.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class role {

// triggers an actual segmentation fault; I was too lazy to fake one
static void trigger_fatal_error() {
*(int*)0 = 0;
*(volatile int*) 0 = 0;
}

public:
Expand Down
6 changes: 3 additions & 3 deletions BallanceMMOServer/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ class client: public role {
msg->content.sector
);
local_rankings_[msg->content.map.get_hash_bytes_string()].second.push_back({
(bool)msg->content.cheated, player_name, msg->content.sector});
{(bool)msg->content.cheated, player_name}, msg->content.sector});
break;
}
case bmmo::LatencyData: {
Expand All @@ -677,7 +677,7 @@ class client: public role {
msg->content.rank, bmmo::string_utils::get_ordinal_suffix(msg->content.rank),
formatted_score, msg->content.get_formatted_time());
local_rankings_[msg->content.map.get_hash_bytes_string()].first.push_back({
(bool)msg->content.cheated, player_name, msg->content.mode,
{(bool)msg->content.cheated, player_name}, msg->content.mode,
msg->content.rank, msg->content.timeElapsed, formatted_score});
break;
}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ int main(int argc, char** argv) {
return;
}

client_thread = std::move(std::thread([&client]() { client.run(); }));
client_thread = std::thread([&client]() { client.run(); });
client.wait_till_started();
});
console.register_command("cheat", [&] {
Expand Down
6 changes: 3 additions & 3 deletions BallanceMMOServer/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ class server: public role {
connected_msg.serialize();
broadcast_message(connected_msg.raw.str().data(), connected_msg.size(), k_nSteamNetworkingSend_Reliable, networking_msg->m_conn);

if (config_.ghost_mode && is_ghost_spectator) {
if (!config_.ghost_mode || is_ghost_spectator) {
bmmo::owned_compressed_ball_state_msg state_msg{};
pull_ball_states(state_msg.balls);
state_msg.serialize();
Expand Down Expand Up @@ -1085,7 +1085,7 @@ class server: public role {
client_it->second.dnf = true;
broadcast_message(*msg, k_nSteamNetworkingSend_Reliable);
maps_[msg->content.map.get_hash_bytes_string()].rankings.second.push_back({
(bool)msg->content.cheated, player_name, msg->content.sector});
{(bool)msg->content.cheated, player_name}, msg->content.sector});
break;
}
case bmmo::LevelFinish:
Expand Down Expand Up @@ -1123,7 +1123,7 @@ class server: public role {
broadcast_message(*msg, k_nSteamNetworkingSend_Reliable);

current_map.rankings.first.push_back({
(bool)msg->content.cheated, player_name, msg->content.mode,
{(bool)msg->content.cheated, player_name}, msg->content.mode,
current_map.rank, msg->content.timeElapsed, formatted_score});

break;
Expand Down

0 comments on commit c0ce672

Please sign in to comment.