Skip to content

Commit

Permalink
Bug fixes. Release candidate?
Browse files Browse the repository at this point in the history
  • Loading branch information
Swung0x48 committed Apr 25, 2021
1 parent aa3cbd5 commit bd6d3c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions BallanceMMOClient/BallanceMMOClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void BallanceMMOClient::OnLoad()
void BallanceMMOClient::OnPostStartMenu() {
if (client_.is_connected()) {
m_bml->SendIngameMessage("Connected!");
client_.get_incoming_messages().clear();
}

if (gui_avail_)
Expand Down Expand Up @@ -81,7 +82,7 @@ void BallanceMMOClient::OnProcess()
// auto msg = client_.get_incoming_messages().pop_front();
// process_incoming_message(msg.msg);
//}
if (loop_count_ % 5 == 0) {
if (loop_count_ % 60 == 0) {
GetLogger()->Info("Pinging Server...");
client_.ping_server();
if (gui_avail_) {
Expand Down Expand Up @@ -115,10 +116,12 @@ void BallanceMMOClient::OnStartLevel()
while (client_.get_incoming_messages().empty())
client_.get_incoming_messages().wait();

//GetLogger()->Info("%d msg", client_.get_incoming_messages().size());
auto msg = client_.get_incoming_messages().pop_front();
process_incoming_message(msg.msg);
//if (client_.get_incoming_messages().size() > MSG_MAX_SIZE)
//client_.get_incoming_messages().clear();

if (client_.get_incoming_messages().size() > MSG_MAX_SIZE)
client_.get_incoming_messages().clear();
}
});
msg_receive_thread_.detach();
Expand Down Expand Up @@ -194,7 +197,7 @@ void BallanceMMOClient::process_incoming_message(blcl::net::message<MsgType>& ms
msg >> sent;
//GetLogger()->Info("%d", int(std::chrono::duration_cast<std::chrono::milliseconds>(now - sent).count()));
auto lk = std::scoped_lock<std::mutex>(ping_char_mtx_);
sprintf(ping_char_, "Ping: %4.lld ms", std::chrono::duration_cast<std::chrono::milliseconds>(now - sent).count());
sprintf(ping_char_, "Ping: %02lld ms", std::chrono::duration_cast<std::chrono::milliseconds>(now - sent).count());

break;
}
Expand Down Expand Up @@ -227,6 +230,7 @@ void BallanceMMOClient::process_incoming_message(blcl::net::message<MsgType>& ms
//if (state.current_ball > 3)
//state.current_ball = 0;
peer_balls_.insert({ remote_id, std::move(state) });
peer_balls_[remote_id].balls[msg_state.type]->Show(CKSHOW);
}

if (peer_balls_.size() == 0)
Expand Down
4 changes: 2 additions & 2 deletions BallanceMMOClient/BallanceMMOClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BallanceMMOClient : public IMod {
BallanceMMOClient(IBML* bml) : IMod(bml) {}

virtual CKSTRING GetID() override { return "BallanceMMOClient"; }
virtual CKSTRING GetVersion() override { return "0.1.9"; }
virtual CKSTRING GetVersion() override { return "0.1.12"; }
virtual CKSTRING GetName() override { return "BallanceMMOClient"; }
virtual CKSTRING GetAuthor() override { return "Swung0x48"; }
virtual CKSTRING GetDescription() override { return "The client to connect your game to the universe."; }
Expand All @@ -33,7 +33,7 @@ class BallanceMMOClient : public IMod {
VxQuaternion rotation;
};

const size_t MSG_MAX_SIZE = 500;
const size_t MSG_MAX_SIZE = 25;
Client client_;
bool receiving_msg_ = false;
std::thread msg_receive_thread_;
Expand Down

0 comments on commit bd6d3c4

Please sign in to comment.