mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-17 22:51:30 +00:00
Fix for OP_ZoneEntry spawn struct sometimes containing garbage data in flags causing random crashes.
This commit is contained in:
parent
018308bfca
commit
b85344f779
@ -1603,6 +1603,8 @@ namespace Larion
|
|||||||
buffer.WriteUInt8(emu->NPC);
|
buffer.WriteUInt8(emu->NPC);
|
||||||
|
|
||||||
structs::Spawn_Struct_Bitfields flags;
|
structs::Spawn_Struct_Bitfields flags;
|
||||||
|
memset(&flags, 0, sizeof(structs::Spawn_Struct_Bitfields));
|
||||||
|
|
||||||
flags.gender = emu->gender;
|
flags.gender = emu->gender;
|
||||||
flags.ispet = emu->is_pet;
|
flags.ispet = emu->is_pet;
|
||||||
flags.afk = emu->afk;
|
flags.afk = emu->afk;
|
||||||
@ -1626,7 +1628,10 @@ namespace Larion
|
|||||||
}
|
}
|
||||||
|
|
||||||
//write flags
|
//write flags
|
||||||
buffer.WriteStructure(flags);
|
//buffer.WriteStructure(flags);
|
||||||
|
for (int j = 0; j < 5; ++j) {
|
||||||
|
buffer.WriteUInt8(flags.raw[j]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
float EmitterScalingRadius;
|
float EmitterScalingRadius;
|
||||||
@ -1868,6 +1873,7 @@ namespace Larion
|
|||||||
|
|
||||||
//u8 CPhysicsData[20];
|
//u8 CPhysicsData[20];
|
||||||
structs::Spawn_Struct_Position position;
|
structs::Spawn_Struct_Position position;
|
||||||
|
memset(&position, 0, sizeof(structs::Spawn_Struct_Position));
|
||||||
|
|
||||||
position.y = emu->y;
|
position.y = emu->y;
|
||||||
position.deltaZ = emu->deltaZ;
|
position.deltaZ = emu->deltaZ;
|
||||||
@ -1879,7 +1885,10 @@ namespace Larion
|
|||||||
position.animation = emu->animation;
|
position.animation = emu->animation;
|
||||||
position.deltaY = emu->deltaY;
|
position.deltaY = emu->deltaY;
|
||||||
|
|
||||||
buffer.WriteStructure(position);
|
//buffer.WriteStructure(position);
|
||||||
|
for (int j = 0; j < 5; ++j) {
|
||||||
|
buffer.WriteUInt32(position.raw[j]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(Flags.title) {
|
if(Flags.title) {
|
||||||
|
|||||||
@ -193,6 +193,8 @@ namespace Larion {
|
|||||||
|
|
||||||
struct Spawn_Struct_Bitfields
|
struct Spawn_Struct_Bitfields
|
||||||
{
|
{
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
// byte 1
|
// byte 1
|
||||||
/*00*/ unsigned gender : 2; // Gender (0=male, 1=female, 2=monster)
|
/*00*/ unsigned gender : 2; // Gender (0=male, 1=female, 2=monster)
|
||||||
/*02*/ unsigned ispet : 1; // Guessed based on observing live spawns
|
/*02*/ unsigned ispet : 1; // Guessed based on observing live spawns
|
||||||
@ -225,9 +227,14 @@ namespace Larion {
|
|||||||
/*38*/ unsigned unk38 : 1;
|
/*38*/ unsigned unk38 : 1;
|
||||||
/*39*/ unsigned unk39 : 1;
|
/*39*/ unsigned unk39 : 1;
|
||||||
};
|
};
|
||||||
|
uint8 raw[5];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
struct Spawn_Struct_Position
|
struct Spawn_Struct_Position
|
||||||
{
|
{
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
signed y : 19;
|
signed y : 19;
|
||||||
signed deltaX : 13;
|
signed deltaX : 13;
|
||||||
|
|
||||||
@ -246,6 +253,9 @@ namespace Larion {
|
|||||||
signed x : 19;
|
signed x : 19;
|
||||||
unsigned pad4 : 13;
|
unsigned pad4 : 13;
|
||||||
};
|
};
|
||||||
|
uint32_t raw[5];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|||||||
@ -181,21 +181,6 @@ public:
|
|||||||
m_pos += len;
|
m_pos += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void WriteStructurePtr(T *value) {
|
|
||||||
auto type_size = sizeof(T);
|
|
||||||
|
|
||||||
if (m_pos + type_size > m_capacity)
|
|
||||||
Grow(m_capacity + type_size);
|
|
||||||
memcpy(m_buffer + m_pos, value, type_size);
|
|
||||||
m_pos += sizeof(type_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void WriteStructure(T& value) {
|
|
||||||
WriteStructurePtr(&value);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const { return m_pos; }
|
size_t size() const { return m_pos; }
|
||||||
size_t length() const { return size(); }
|
size_t length() const { return size(); }
|
||||||
size_t capacity() const { return m_capacity; }
|
size_t capacity() const { return m_capacity; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user