mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
fix: Implement proper Sound trigger component serialization (#1160)
* cleanup * more cleanup and fully implement the sound trigger and racing sound trigger * more cleanup, and better defaults * fixes and tested * update initializor for guid and when to load sound guids * make racing sound trigger it's own component * fix type * Remove global move serializes --------- Co-authored-by: David Markowitz <EmosewaMC@gmail.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#include "GUID.h"
|
||||
|
||||
namespace {
|
||||
const std::string EMPTY_GUID = "{00000000-0000-0000-0000-000000000000}";
|
||||
}
|
||||
|
||||
GUID::GUID(const std::string& guid) {
|
||||
if(guid == EMPTY_GUID) return;
|
||||
sscanf(guid.c_str(),
|
||||
"{%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx}",
|
||||
&this->data1, &this->data2, &this->data3,
|
||||
@@ -8,20 +13,13 @@ GUID::GUID(const std::string& guid) {
|
||||
&this->data4[4], &this->data4[5], &this->data4[6], &this->data4[7]);
|
||||
}
|
||||
|
||||
uint32_t GUID::GetData1() const {
|
||||
return data1;
|
||||
}
|
||||
|
||||
uint16_t GUID::GetData2() const {
|
||||
return data2;
|
||||
}
|
||||
|
||||
uint16_t GUID::GetData3() const {
|
||||
return data3;
|
||||
}
|
||||
|
||||
std::array<uint8_t, 8> GUID::GetData4() const {
|
||||
return data4;
|
||||
void GUID::Serialize(RakNet::BitStream* outBitStream) {
|
||||
outBitStream->Write(GetData1());
|
||||
outBitStream->Write(GetData2());
|
||||
outBitStream->Write(GetData3());
|
||||
for (const auto& guidSubPart : GetData4()) {
|
||||
outBitStream->Write(guidSubPart);
|
||||
}
|
||||
}
|
||||
|
||||
GUID::GUID() = default;
|
||||
|
@@ -7,10 +7,24 @@ class GUID {
|
||||
public:
|
||||
explicit GUID();
|
||||
explicit GUID(const std::string& guid);
|
||||
uint32_t GetData1() const;
|
||||
uint16_t GetData2() const;
|
||||
uint16_t GetData3() const;
|
||||
std::array<uint8_t, 8> GetData4() const;
|
||||
void Serialize(RakNet::BitStream* outBitStream);
|
||||
|
||||
uint32_t GetData1() const {
|
||||
return data1;
|
||||
}
|
||||
|
||||
uint16_t GetData2() const {
|
||||
return data2;
|
||||
}
|
||||
|
||||
uint16_t GetData3() const {
|
||||
return data3;
|
||||
}
|
||||
|
||||
std::array<uint8_t, 8> GetData4() const {
|
||||
return data4;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t data1 = 0;
|
||||
uint16_t data2 = 0;
|
||||
|
Reference in New Issue
Block a user