Skip to content

Commit

Permalink
Merge pull request #5644 from LandSandBoat/packet/s2c-0x011a
Browse files Browse the repository at this point in the history
[packet] Implement C->S 0x119, S->C 0x11A - Emote List
  • Loading branch information
claywar authored May 7, 2024
2 parents 18a5097 + 3cecd15 commit 576c585
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/enum/key_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,7 @@ xi.keyItem =
SHADOW_THRONE = 2833,
LEAF_BENCH = 2834,
ASTRAL_CUBE = 2835,
CHOCOBO_CHAIR_II = 2836,
REISENJIMA_SANCTORIUM_ORB = 2837,
SAKURA_AND_THE_MAGICKED_NET = 2838,
REAPER = 2839,
Expand Down
12 changes: 12 additions & 0 deletions src/map/packet_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ along with this program. If not, see http://www.gnu.org/licenses/
#include "packets/char_abilities.h"
#include "packets/char_appearance.h"
#include "packets/char_check.h"
#include "packets/char_emote_list.h"
#include "packets/char_emotion.h"
#include "packets/char_emotion_jump.h"
#include "packets/char_equip.h"
Expand Down Expand Up @@ -8313,6 +8314,16 @@ void SmallPacket0x118(map_session_data_t* const PSession, CCharEntity* const PCh
}
}

/************************************************************************
* *
* Request Emote List *
* *
************************************************************************/
void SmallPacket0x119(map_session_data_t* const PSession, CCharEntity* const PChar, CBasicPacket& data)
{
PChar->pushPacket(new CCharEmoteListPacket(PChar));
}

/************************************************************************
* *
* Set Job Master Display *
Expand Down Expand Up @@ -8480,6 +8491,7 @@ void PacketParserInitialize()
PacketSize[0x116] = 0x00; PacketParser[0x116] = &SmallPacket0x116;
PacketSize[0x117] = 0x00; PacketParser[0x117] = &SmallPacket0x117;
PacketSize[0x118] = 0x00; PacketParser[0x118] = &SmallPacket0x118;
PacketSize[0x119] = 0x00; PacketParser[0x119] = &SmallPacket0x119;
PacketSize[0x11B] = 0x00; PacketParser[0x11B] = &SmallPacket0x11B;
PacketSize[0x11D] = 0x00; PacketParser[0x11D] = &SmallPacket0x11D;
// clang-format on
Expand Down
2 changes: 2 additions & 0 deletions src/map/packets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ set(PACKET_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/char_appearance.h
${CMAKE_CURRENT_SOURCE_DIR}/char_check.cpp
${CMAKE_CURRENT_SOURCE_DIR}/char_check.h
${CMAKE_CURRENT_SOURCE_DIR}/char_emote_list.cpp
${CMAKE_CURRENT_SOURCE_DIR}/char_emote_list.h
${CMAKE_CURRENT_SOURCE_DIR}/char_emotion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/char_emotion.h
${CMAKE_CURRENT_SOURCE_DIR}/char_emotion_jump.cpp
Expand Down
63 changes: 63 additions & 0 deletions src/map/packets/char_emote_list.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
===========================================================================
Copyright (c) 2024 LandSandBoat Dev Teams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
===========================================================================
*/

#include "char_emote_list.h"
#include "common/socket.h"
#include "entities/baseentity.h"
#include "lua/luautils.h"
#include "utils/charutils.h"

CCharEmoteListPacket::CCharEmoteListPacket(CCharEntity* PChar)
{
this->setType(0x11A);
this->setSize(0x0C);

// RUN and GEO are not sequential with the rest of the list, so grab those two separate offsets first.
// Geomancer begins with bit 20, so create the offset based on an ID with that value subtracted.
auto warriorKeyItem = lua["xi"]["keyItem"]["JOB_GESTURE_WARRIOR"].get<uint16>();
auto geomancerKeyItem = lua["xi"]["keyItem"]["JOB_GESTURE_GEOMANCER"].get<uint16>();

uint32 jobEmotes = 0;
for (const auto& keyItemName : jobGestureKeyItems)
{
auto keyItemId = lua["xi"]["keyItem"][keyItemName].get<uint16>();
if (charutils::hasKeyItem(PChar, keyItemId))
{
uint16 bitOffset = keyItemId < geomancerKeyItem ? warriorKeyItem : geomancerKeyItem - 20;
jobEmotes |= 1 << (keyItemId - bitOffset);
}
}

auto imperialChairKeyItem = lua["xi"]["keyItem"]["IMPERIAL_CHAIR"].get<uint16>();

uint16 chairEmotes = 0;
for (const auto& keyItemName : chairKeyItems)
{
auto keyItemId = lua["xi"]["keyItem"][keyItemName].get<uint16>();
if (charutils::hasKeyItem(PChar, keyItemId))
{
chairEmotes |= 1 << (keyItemId - imperialChairKeyItem);
}
}

ref<uint32>(0x04) = jobEmotes;
ref<uint16>(0x08) = chairEmotes;
}
76 changes: 76 additions & 0 deletions src/map/packets/char_emote_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
===========================================================================
Copyright (c) 2024 LandSandBoat Dev Teams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
===========================================================================
*/

#ifndef _CCHAREMOTELIST_H
#define _CCHAREMOTELIST_H

#include "common/cbasetypes.h"

#include "basic.h"

std::vector<std::string> const jobGestureKeyItems = {
"JOB_GESTURE_WARRIOR",
"JOB_GESTURE_MONK",
"JOB_GESTURE_WHITE_MAGE",
"JOB_GESTURE_BLACK_MAGE",
"JOB_GESTURE_RED_MAGE",
"JOB_GESTURE_THIEF",
"JOB_GESTURE_PALADIN",
"JOB_GESTURE_DARK_KNIGHT",
"JOB_GESTURE_BEASTMASTER",
"JOB_GESTURE_BARD",
"JOB_GESTURE_RANGER",
"JOB_GESTURE_SAMURAI",
"JOB_GESTURE_NINJA",
"JOB_GESTURE_DRAGOON",
"JOB_GESTURE_SUMMONER",
"JOB_GESTURE_BLUE_MAGE",
"JOB_GESTURE_CORSAIR",
"JOB_GESTURE_PUPPETMASTER",
"JOB_GESTURE_DANCER",
"JOB_GESTURE_SCHOLAR",
"JOB_GESTURE_GEOMANCER",
"JOB_GESTURE_RUNE_FENCER",
};

std::vector<std::string> const chairKeyItems = {
"IMPERIAL_CHAIR",
"DECORATIVE_CHAIR",
"ORNATE_STOOL",
"REFINED_CHAIR",
"PORTABLE_CONTAINER",
"CHOCOBO_CHAIR",
"EPHRAMADIAN_THRONE",
"SHADOW_THRONE",
"LEAF_BENCH",
"ASTRAL_CUBE",
"CHOCOBO_CHAIR_II",
};

class CCharEntity;

class CCharEmoteListPacket : public CBasicPacket
{
public:
CCharEmoteListPacket(CCharEntity* PChar);
};

#endif

0 comments on commit 576c585

Please sign in to comment.