Skip to content

Commit

Permalink
fix: crash when spectated player exits
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenapte committed Jan 1, 2025
1 parent 774e27e commit 47d140f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions BallanceMMOClient/BallanceMMOClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ void BallanceMMOClient::OnProcess() {

#ifdef BMMO_WITH_PLAYER_SPECTATION
if (spectating_first_person_) {
if (!db_.exists(objects_.get_spectated_id())) {
OnFullCommand("spectate"); // just exit spectation
return;
}
spect_player_pos_ = objects_.get_ball_pos(objects_.get_spectated_id());
if (input_manager_->IsKeyDown(CKKEY_LSHIFT)) {
CKCamera* cam = m_bml->GetTargetCameraByName("InGameCam");
Expand Down Expand Up @@ -625,6 +629,7 @@ inline void BallanceMMOClient::on_fatal_error(char* extra_text) {

void BallanceMMOClient::OnCommand(IBML* bml, const std::vector<std::string>& args)
{
// discard the first "mmo" argument
const std::string full_command = bmmo::string_utils::join_strings(args, 1);
OnFullCommand(full_command);
}
Expand Down Expand Up @@ -1596,6 +1601,10 @@ void BallanceMMOClient::on_message(ISteamNetworkingMessage* network_msg) {

if (logged_in_) {
logger_->Info("New LoginAccepted message received. Resetting current data.");
#ifdef BMMO_WITH_PLAYER_SPECTATION
if (objects_.get_spectated_id() != k_HSteamNetConnection_Invalid)
OnFullCommand("spectate"); // exit spectation properly
#endif // BMMO_WITH_PLAYER_SPECTATION
db_.clear();
objects_.destroy_all_objects();
}
Expand Down

0 comments on commit 47d140f

Please sign in to comment.