From 027d95bbb8e3cd69c577b08a8ccb69522e8d7a8a Mon Sep 17 00:00:00 2001 From: KimLS Date: Sun, 17 Nov 2024 15:44:05 -0800 Subject: [PATCH] WIP on door struct --- common/patches/larion.cpp | 111 +++++++++++++++++++------------- common/patches/larion_ops.h | 2 +- common/patches/larion_structs.h | 40 ++++++++++++ 3 files changed, 106 insertions(+), 47 deletions(-) diff --git a/common/patches/larion.cpp b/common/patches/larion.cpp index 1432fd4ba..81566ac4c 100644 --- a/common/patches/larion.cpp +++ b/common/patches/larion.cpp @@ -489,42 +489,42 @@ namespace Larion FINISH_ENCODE(); } - //ENCODE(OP_SpawnAppearance) - //{ - // EQApplicationPacket* in = *p; - // *p = nullptr; - // - // unsigned char* emu_buffer = in->pBuffer; - // - // SpawnAppearance_Struct* sas = (SpawnAppearance_Struct*)emu_buffer; - // - // if (sas->type != AppearanceType::Size) - // { - // //larion struct is different than rof2's but the idea is the same - // auto outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(structs::SpawnAppearance_Struct)); - // structs::SpawnAppearance_Struct *eq = (structs::SpawnAppearance_Struct*)outapp->pBuffer; - // - // eq->spawn_id = sas->spawn_id; - // eq->type = sas->type; - // eq->parameter = sas->parameter; - // - // dest->FastQueuePacket(&outapp, ack_req); - // delete in; - // return; - // } - // - // auto outapp = new EQApplicationPacket(OP_ChangeSize, sizeof(ChangeSize_Struct)); - // - // ChangeSize_Struct* css = (ChangeSize_Struct*)outapp->pBuffer; - // - // css->EntityID = sas->spawn_id; - // css->Size = (float)sas->parameter; - // css->Unknown08 = 0; - // css->Unknown12 = 1.0f; - // - // dest->FastQueuePacket(&outapp, ack_req); - // delete in; - //} + ENCODE(OP_SpawnAppearance) + { + EQApplicationPacket* in = *p; + *p = nullptr; + + unsigned char* emu_buffer = in->pBuffer; + + SpawnAppearance_Struct* sas = (SpawnAppearance_Struct*)emu_buffer; + + if (sas->type != AppearanceType::Size) + { + //larion struct is different than rof2's but the idea is the same + auto outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(structs::SpawnAppearance_Struct)); + structs::SpawnAppearance_Struct *eq = (structs::SpawnAppearance_Struct*)outapp->pBuffer; + + eq->spawn_id = sas->spawn_id; + eq->type = sas->type; + eq->parameter = sas->parameter; + + dest->FastQueuePacket(&outapp, ack_req); + delete in; + return; + } + + auto outapp = new EQApplicationPacket(OP_ChangeSize, sizeof(ChangeSize_Struct)); + + ChangeSize_Struct* css = (ChangeSize_Struct*)outapp->pBuffer; + + css->EntityID = sas->spawn_id; + css->Size = (float)sas->parameter; + css->Unknown08 = 0; + css->Unknown12 = 1.0f; + + dest->FastQueuePacket(&outapp, ack_req); + delete in; + } ENCODE(OP_PlayerProfile) { EQApplicationPacket* in = *p; @@ -2257,18 +2257,37 @@ namespace Larion delete in; } - ENCODE(OP_SpawnAppearance) - { - EQApplicationPacket* in = *p; - *p = nullptr; - delete in; - } - ENCODE(OP_SpawnDoor) { - EQApplicationPacket* in = *p; - *p = nullptr; - delete in; + SETUP_VAR_ENCODE(Door_Struct); + int door_count = __packet->size / sizeof(Door_Struct); + int total_length = door_count * sizeof(structs::Door_Struct); + ALLOC_VAR_ENCODE(structs::Door_Struct, total_length); + + int r; + for (r = 0; r < door_count; r++) { + // strncpy(eq[r].name, emu[r].name, sizeof(eq[r].name)); + // eq[r].xPos = emu[r].xPos; + // eq[r].yPos = emu[r].yPos; + // eq[r].zPos = emu[r].zPos; + // eq[r].heading = emu[r].heading; + // eq[r].incline = emu[r].incline; + // eq[r].size = emu[r].size; + // eq[r].doorId = emu[r].doorId; + // eq[r].opentype = emu[r].opentype; + // eq[r].state_at_spawn = emu[r].state_at_spawn; + // eq[r].invert_state = emu[r].invert_state; + // eq[r].door_param = emu[r].door_param; + // eq[r].unknown0080 = 0; + // eq[r].unknown0081 = 1; // Both must be 1 to allow clicking doors + // eq[r].unknown0082 = 0; + // eq[r].unknown0083 = 1; // Both must be 1 to allow clicking doors + // eq[r].unknown0084 = 0; + // eq[r].unknown0085 = 0; + // eq[r].unknown0086 = 0; + } + + FINISH_ENCODE(); } ENCODE(OP_GroundSpawn) diff --git a/common/patches/larion_ops.h b/common/patches/larion_ops.h index 1716f8590..5d07d4538 100644 --- a/common/patches/larion_ops.h +++ b/common/patches/larion_ops.h @@ -6,13 +6,13 @@ E(OP_SendMembershipDetails) E(OP_SendMaxCharacters) E(OP_SendCharInfo) E(OP_ExpansionInfo) +E(OP_SpawnAppearance) //E(OP_SendAATable) E(OP_PlayerProfile) E(OP_ZoneEntry) E(OP_ZoneSpawns) E(OP_CharInventory) E(OP_NewZone) -E(OP_SpawnAppearance) E(OP_SpawnDoor) E(OP_GroundSpawn) diff --git a/common/patches/larion_structs.h b/common/patches/larion_structs.h index 156cc0078..dd42cd1bf 100644 --- a/common/patches/larion_structs.h +++ b/common/patches/larion_structs.h @@ -257,6 +257,46 @@ namespace Larion { }; }; + struct Door_Struct + { + /*000*/ char name[32]; + /*032*/ float DefaultY; + /*036*/ float DefaultX; + /*040*/ float DefaultZ; + /*044*/ float DefaultHeading; + /*048*/ uint32 DefaultDoorAngle; //rof2's incline + /*052*/ float Y; //most (all I've seen?) doors match the defaults here + /*056*/ float X; + /*060*/ float Z; + /*064*/ float Heading; + /*068*/ float DoorAngle; //not sure if this is actually a float; it might be a uint32 like DefaultDoorAngle + /*072*/ uint32 ScaleFactor; //rof2's size + /*076*/ uint32 Unknown76; //client doesn't seem to read this + /*080*/ uint8 Id; //doorid + /*081*/ uint8 Type; //opentype + /*082*/ uint8 State; //state_at_spawn + /*083*/ uint8 DefaultState; //invert_state + /*084*/ int32 SpellId; //door_param + /*088*/ uint32 AdventureDoorId; + /*092*/ uint32 DynDoorID; + /*096*/ uint32 RealEstateDoorID; + /*100*/ uint8 bHasScript; + /*101*/ uint8 bUsable; //1 if clickable + /*102*/ uint8 bRemainOpen; + /*103*/ uint8 bVisible; //1 is visible + /*104*/ uint8 bHeadingChanged; + /*105*/ uint8 padding1[3]; + /*108*/ float TopSpeed1; + /*112*/ float TopSpeed2; + /*116*/ uint8 bNeedsTimeStampSet; + /*117*/ uint8 padding2[3]; + /*120*/ float unknownFloat1; + /*124*/ float unknownFloat2; + /*128*/ uint8 unknownByte1; + /*129*/ uint8 padding3[3]; + /*132*/ + }; + #pragma pack()