mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +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);
|
||||
|
||||
structs::Spawn_Struct_Bitfields flags;
|
||||
memset(&flags, 0, sizeof(structs::Spawn_Struct_Bitfields));
|
||||
|
||||
flags.gender = emu->gender;
|
||||
flags.ispet = emu->is_pet;
|
||||
flags.afk = emu->afk;
|
||||
@ -1626,7 +1628,10 @@ namespace Larion
|
||||
}
|
||||
|
||||
//write flags
|
||||
buffer.WriteStructure(flags);
|
||||
//buffer.WriteStructure(flags);
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
buffer.WriteUInt8(flags.raw[j]);
|
||||
}
|
||||
|
||||
/*
|
||||
float EmitterScalingRadius;
|
||||
@ -1868,6 +1873,7 @@ namespace Larion
|
||||
|
||||
//u8 CPhysicsData[20];
|
||||
structs::Spawn_Struct_Position position;
|
||||
memset(&position, 0, sizeof(structs::Spawn_Struct_Position));
|
||||
|
||||
position.y = emu->y;
|
||||
position.deltaZ = emu->deltaZ;
|
||||
@ -1879,7 +1885,10 @@ namespace Larion
|
||||
position.animation = emu->animation;
|
||||
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) {
|
||||
|
||||
@ -193,58 +193,68 @@ namespace Larion {
|
||||
|
||||
struct Spawn_Struct_Bitfields
|
||||
{
|
||||
// byte 1
|
||||
/*00*/ unsigned gender : 2; // Gender (0=male, 1=female, 2=monster)
|
||||
/*02*/ unsigned ispet : 1; // Guessed based on observing live spawns
|
||||
/*03*/ unsigned afk : 1; // 0=no, 1=afk
|
||||
/*04*/ unsigned anon : 2; // 0=normal, 1=anon, 2=roleplay
|
||||
/*06*/ unsigned gm : 1;
|
||||
/*07*/ unsigned sneak : 1;
|
||||
// byte 2
|
||||
/*08*/ unsigned lfg : 1;
|
||||
/*09*/ unsigned unk9 : 1;
|
||||
/*10*/ unsigned invis : 12; // there are 3000 different (non-GM) invis levels
|
||||
/*22*/ unsigned linkdead : 1; // 1 Toggles LD on or off after name. Correct for RoF2
|
||||
/*23*/ unsigned showhelm : 1;
|
||||
// byte 4
|
||||
/*24*/ unsigned betabuffed : 1; // Prefixes name with !
|
||||
/*25*/ unsigned trader : 1;
|
||||
/*26*/ unsigned animationonpop : 1;
|
||||
/*27*/ unsigned targetable : 1;
|
||||
/*28*/ unsigned targetable_with_hotkey : 1;
|
||||
/*29*/ unsigned showname : 1;
|
||||
/*30*/ unsigned idleanimationsoff : 1; // what we called statue?
|
||||
/*31*/ unsigned untargetable : 1; // bClickThrough
|
||||
// byte 5
|
||||
/*32*/ unsigned buyer : 1;
|
||||
/*33*/ unsigned offline : 1;
|
||||
/*34*/ unsigned interactiveobject : 1;
|
||||
/*35*/ unsigned missile : 1;
|
||||
/*36*/ unsigned title : 1;
|
||||
/*37*/ unsigned suffix : 1;
|
||||
/*38*/ unsigned unk38 : 1;
|
||||
/*39*/ unsigned unk39 : 1;
|
||||
union {
|
||||
struct {
|
||||
// byte 1
|
||||
/*00*/ unsigned gender : 2; // Gender (0=male, 1=female, 2=monster)
|
||||
/*02*/ unsigned ispet : 1; // Guessed based on observing live spawns
|
||||
/*03*/ unsigned afk : 1; // 0=no, 1=afk
|
||||
/*04*/ unsigned anon : 2; // 0=normal, 1=anon, 2=roleplay
|
||||
/*06*/ unsigned gm : 1;
|
||||
/*07*/ unsigned sneak : 1;
|
||||
// byte 2
|
||||
/*08*/ unsigned lfg : 1;
|
||||
/*09*/ unsigned unk9 : 1;
|
||||
/*10*/ unsigned invis : 12; // there are 3000 different (non-GM) invis levels
|
||||
/*22*/ unsigned linkdead : 1; // 1 Toggles LD on or off after name. Correct for RoF2
|
||||
/*23*/ unsigned showhelm : 1;
|
||||
// byte 4
|
||||
/*24*/ unsigned betabuffed : 1; // Prefixes name with !
|
||||
/*25*/ unsigned trader : 1;
|
||||
/*26*/ unsigned animationonpop : 1;
|
||||
/*27*/ unsigned targetable : 1;
|
||||
/*28*/ unsigned targetable_with_hotkey : 1;
|
||||
/*29*/ unsigned showname : 1;
|
||||
/*30*/ unsigned idleanimationsoff : 1; // what we called statue?
|
||||
/*31*/ unsigned untargetable : 1; // bClickThrough
|
||||
// byte 5
|
||||
/*32*/ unsigned buyer : 1;
|
||||
/*33*/ unsigned offline : 1;
|
||||
/*34*/ unsigned interactiveobject : 1;
|
||||
/*35*/ unsigned missile : 1;
|
||||
/*36*/ unsigned title : 1;
|
||||
/*37*/ unsigned suffix : 1;
|
||||
/*38*/ unsigned unk38 : 1;
|
||||
/*39*/ unsigned unk39 : 1;
|
||||
};
|
||||
uint8 raw[5];
|
||||
};
|
||||
};
|
||||
|
||||
struct Spawn_Struct_Position
|
||||
{
|
||||
signed y : 19;
|
||||
signed deltaX : 13;
|
||||
union {
|
||||
struct {
|
||||
signed y : 19;
|
||||
signed deltaX : 13;
|
||||
|
||||
unsigned heading : 12;
|
||||
signed z : 19;
|
||||
unsigned pad1 : 1;
|
||||
unsigned heading : 12;
|
||||
signed z : 19;
|
||||
unsigned pad1 : 1;
|
||||
|
||||
unsigned pitch : 12;
|
||||
signed animation : 10; //these might be swapped
|
||||
signed deltaHeading : 10; //these might be swapped
|
||||
unsigned pitch : 12;
|
||||
signed animation : 10; //these might be swapped
|
||||
signed deltaHeading : 10; //these might be swapped
|
||||
|
||||
signed deltaY : 13;
|
||||
signed deltaZ : 13;
|
||||
unsigned pad3 : 6;
|
||||
signed deltaY : 13;
|
||||
signed deltaZ : 13;
|
||||
unsigned pad3 : 6;
|
||||
|
||||
signed x : 19;
|
||||
unsigned pad4 : 13;
|
||||
signed x : 19;
|
||||
unsigned pad4 : 13;
|
||||
};
|
||||
uint32_t raw[5];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -181,21 +181,6 @@ public:
|
||||
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 length() const { return size(); }
|
||||
size_t capacity() const { return m_capacity; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user