fixed: spawning ships
This commit is contained in:
1 parent
7e5aa22fee
commit
26233f934f
4 files changed
+195
-4
No files matched your search
@@ -190,7 +190,28 @@ namespace ZL {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (msg.rfind("SPAWN:", 0) == 0) {
|
||||
// SPAWN:playerId:serverTime:<14 полей>
|
||||
if (parts.size() >= 3 + 14) {
|
||||
try {
|
||||
int pid = std::stoi(parts[1]);
|
||||
uint64_t serverTime = std::stoull(parts[2]);
|
||||
|
||||
ClientState st;
|
||||
st.id = pid;
|
||||
std::chrono::system_clock::time_point tp{ std::chrono::milliseconds(serverTime) };
|
||||
st.lastUpdateServerTime = tp;
|
||||
|
||||
// данные начинаются с parts[3]
|
||||
st.handle_full_sync(parts, 3);
|
||||
|
||||
pendingSpawns_.push_back(st);
|
||||
std::cout << "Client: SPAWN received for player " << pid << std::endl;
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (msg.rfind("EVENT:", 0) == 0) {
|
||||
//auto parts = split(msg, ':');
|
||||
if (parts.size() < 5) return; // EVENT:ID:TYPE:TIME:DATA...
|
||||
@@ -334,6 +355,12 @@ namespace ZL {
|
||||
copy.swap(pendingBoxDestructions_);
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::vector<ClientState> WebSocketClientBase::getPendingSpawns() {
|
||||
std::vector<ClientState> copy;
|
||||
copy.swap(pendingSpawns_);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@ namespace ZL {
|
||||
std::vector<BoxDestroyedInfo> pendingBoxDestructions_;
|
||||
int clientId = -1;
|
||||
int64_t timeOffset = 0;
|
||||
std::vector<ClientState> pendingSpawns_;
|
||||
|
||||
public:
|
||||
int GetClientId() const override { return clientId; }
|
||||
@@ -48,6 +49,8 @@ namespace ZL {
|
||||
std::vector<DeathInfo> getPendingDeaths() override;
|
||||
std::vector<int> getPendingRespawns() override;
|
||||
std::vector<BoxDestroyedInfo> getPendingBoxDestructions() override;
|
||||
std::vector<ClientState> getPendingSpawns();
|
||||
int getClientId() const { return clientId; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user