mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 07:36:23 +00:00
Core/Misc: update g3dlite lib (#2904)
* Core/Misc: update g3dlite lib * update Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
This commit is contained in:
46
deps/g3dlite/source/GUniqueID.cpp
vendored
46
deps/g3dlite/source/GUniqueID.cpp
vendored
@@ -8,8 +8,27 @@
|
||||
#include "G3D/BinaryOutput.h"
|
||||
#include "G3D/TextOutput.h"
|
||||
#include "G3D/NetworkDevice.h"
|
||||
#include "G3D/Any.h"
|
||||
|
||||
namespace G3D {
|
||||
|
||||
GUniqueID& GUniqueID::operator=(const Any& a) {
|
||||
a.verifyName("GUniqueID");
|
||||
a.verifyType(Any::ARRAY);
|
||||
a.verifySize(1);
|
||||
std::string s = a[0];
|
||||
a.verify(s.length() == 16);
|
||||
id = GUniqueID::fromString16(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Any GUniqueID::toAny() const {
|
||||
Any a(Any::ARRAY, "GUniqueID");
|
||||
a.append(toString16());
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
void GUniqueID::serialize(BinaryOutput& b) const {
|
||||
b.writeUInt64(id);
|
||||
@@ -34,6 +53,33 @@ void GUniqueID::deserialize(TextInput& t) {
|
||||
}
|
||||
|
||||
|
||||
GUniqueID GUniqueID::NONE(uint16 tag) {
|
||||
GUniqueID i;
|
||||
uint64 t = tag;
|
||||
i.id = (t << 54);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
std::string GUniqueID::toString16() const {
|
||||
return format("%08x%08x", uint32(id >> 32), uint32(id & 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
|
||||
GUniqueID GUniqueID::fromString16(const std::string& s) {
|
||||
if (s.length() != 16) {
|
||||
debugAssertM(false, "Corrupt 16-character string");
|
||||
return GUniqueID();
|
||||
}
|
||||
|
||||
uint32 high = 0, low = 0;
|
||||
sscanf(s.c_str(), "%08x%08x", &high, &low);
|
||||
GUniqueID i;
|
||||
i.id = (uint64(high) << 32) | low;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
GUniqueID GUniqueID::create(uint16 tag) {
|
||||
static uint64 counter = 0;
|
||||
static uint64 systemID = 0;
|
||||
|
||||
Reference in New Issue
Block a user