mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 10:37:01 +00:00
Rebase resync
This commit is contained in:
parent
a0797532e8
commit
1997c1e903
3106 changed files with 11118 additions and 627576 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -150,6 +150,8 @@ class ByteBuffer
|
|||
{
|
||||
_storage.clear();
|
||||
_rpos = _wpos = 0;
|
||||
_curbitval = 0;
|
||||
_bitpos = 8;
|
||||
}
|
||||
|
||||
template <typename T> ByteBuffer& append(T value)
|
||||
|
|
@ -314,153 +316,153 @@ class ByteBuffer
|
|||
template <typename T> void put(size_t pos, T value)
|
||||
{
|
||||
EndianConvert(value);
|
||||
put(pos, (uint8 *)&value, sizeof(value));
|
||||
put(pos, (uint8*)&value, sizeof(value));
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint8 value)
|
||||
ByteBuffer& operator<<(uint8 value)
|
||||
{
|
||||
append<uint8>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint16 value)
|
||||
ByteBuffer& operator<<(uint16 value)
|
||||
{
|
||||
append<uint16>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint32 value)
|
||||
ByteBuffer& operator<<(uint32 value)
|
||||
{
|
||||
append<uint32>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint64 value)
|
||||
ByteBuffer& operator<<(uint64 value)
|
||||
{
|
||||
append<uint64>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// signed as in 2e complement
|
||||
ByteBuffer &operator<<(int8 value)
|
||||
ByteBuffer& operator<<(int8 value)
|
||||
{
|
||||
append<int8>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(int16 value)
|
||||
ByteBuffer& operator<<(int16 value)
|
||||
{
|
||||
append<int16>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(int32 value)
|
||||
ByteBuffer& operator<<(int32 value)
|
||||
{
|
||||
append<int32>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(int64 value)
|
||||
ByteBuffer& operator<<(int64 value)
|
||||
{
|
||||
append<int64>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// floating points
|
||||
ByteBuffer &operator<<(float value)
|
||||
ByteBuffer& operator<<(float value)
|
||||
{
|
||||
append<float>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(double value)
|
||||
ByteBuffer& operator<<(double value)
|
||||
{
|
||||
append<double>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(const std::string &value)
|
||||
ByteBuffer& operator<<(const std::string& value)
|
||||
{
|
||||
append((uint8 const *)value.c_str(), value.length());
|
||||
append((uint8 const*)value.c_str(), value.length());
|
||||
append((uint8)0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(const char *str)
|
||||
ByteBuffer& operator<<(const char* str)
|
||||
{
|
||||
append((uint8 const *)str, str ? strlen(str) : 0);
|
||||
append((uint8 const*)str, str ? strlen(str) : 0);
|
||||
append((uint8)0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(bool &value)
|
||||
ByteBuffer& operator>>(bool& value)
|
||||
{
|
||||
value = read<char>() > 0 ? true : false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint8 &value)
|
||||
ByteBuffer& operator>>(uint8& value)
|
||||
{
|
||||
value = read<uint8>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint16 &value)
|
||||
ByteBuffer& operator>>(uint16& value)
|
||||
{
|
||||
value = read<uint16>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint32 &value)
|
||||
ByteBuffer& operator>>(uint32& value)
|
||||
{
|
||||
value = read<uint32>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint64 &value)
|
||||
ByteBuffer& operator>>(uint64& value)
|
||||
{
|
||||
value = read<uint64>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
//signed as in 2e complement
|
||||
ByteBuffer &operator>>(int8 &value)
|
||||
// signed as in 2e complement
|
||||
ByteBuffer& operator>>(int8& value)
|
||||
{
|
||||
value = read<int8>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(int16 &value)
|
||||
ByteBuffer& operator>>(int16& value)
|
||||
{
|
||||
value = read<int16>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(int32 &value)
|
||||
ByteBuffer& operator>>(int32& value)
|
||||
{
|
||||
value = read<int32>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(int64 &value)
|
||||
ByteBuffer& operator>>(int64& value)
|
||||
{
|
||||
value = read<int64>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(float &value)
|
||||
ByteBuffer& operator>>(float& value)
|
||||
{
|
||||
value = read<float>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(double &value)
|
||||
ByteBuffer& operator>>(double& value)
|
||||
{
|
||||
value = read<double>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(std::string& value)
|
||||
ByteBuffer& operator>>(std::string& value)
|
||||
{
|
||||
value.clear();
|
||||
while (rpos() < size()) // prevent crash at wrong string format in packet
|
||||
|
|
@ -474,7 +476,7 @@ class ByteBuffer
|
|||
}
|
||||
|
||||
template<class T>
|
||||
ByteBuffer &operator>>(Unused<T> const&)
|
||||
ByteBuffer& operator>>(Unused<T> const&)
|
||||
{
|
||||
return read_skip<T>();
|
||||
}
|
||||
|
|
@ -651,6 +653,12 @@ class ByteBuffer
|
|||
return out;
|
||||
}
|
||||
|
||||
ByteBuffer& WriteStringData(const std::string& str)
|
||||
{
|
||||
FlushBits();
|
||||
return append((uint8 const*)str.c_str(), str.size());
|
||||
}
|
||||
|
||||
bool ReadBoolean()
|
||||
{
|
||||
uint8 b = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue