mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
feat(protocol): add packet serialization and login handling
Introduce packet header and ID mapping for protobuf messages. Refactor session and server_world to use new packet wrapper. Fix missing semicolons in proto files.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "Cubed/gameplay/server_world.hpp"
|
||||
|
||||
#include "Cubed/config.hpp"
|
||||
#include "Cubed/gameplay/packet.hpp"
|
||||
#include "Cubed/gameplay/session.hpp"
|
||||
#include "Cubed/tools/cubed_assert.hpp"
|
||||
#include "Cubed/tools/log.hpp"
|
||||
|
||||
@@ -357,17 +359,14 @@ void ServerWorld::sync_player_pos(const std::string& name, float x, float y,
|
||||
it->second.update_pos(x, y, z);
|
||||
}
|
||||
|
||||
void ServerWorld::handle_player_request(const PlayerRequest& request) {
|
||||
if (request.join()) {
|
||||
player_join(request.name());
|
||||
}
|
||||
if (request.exit()) {
|
||||
player_exit(request.name());
|
||||
}
|
||||
if (request.chunk_send()) {
|
||||
m_request_gen_name = request.name();
|
||||
need_gen();
|
||||
}
|
||||
void ServerWorld::handle_player_login(const std::string& name,
|
||||
std::shared_ptr<Session> session) {
|
||||
player_join(name);
|
||||
m_player_session.emplace(name, session);
|
||||
LoginRsp rsp;
|
||||
rsp.set_success(true);
|
||||
rsp.set_uuid(name);
|
||||
session->send(make_packet(name));
|
||||
}
|
||||
|
||||
void ServerWorld::player_join(const std::string& name) {
|
||||
|
||||
Reference in New Issue
Block a user