Skip to content

Commit

Permalink
fix: packet Cyclopedia house auction 13.40 (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokekanon authored Jan 3, 2025
1 parent 093edcc commit 9ee23ba
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/client/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,27 @@ namespace Otc
SUPPLY_STASH_ACTION_WITHDRAW = 3
};

enum CyclopediaHouseState_t : uint8_t
{
CYCLOPEDIA_HOUSE_STATE_AVAILABLE = 0,
// 1 ?
CYCLOPEDIA_HOUSE_STATE_RENTED = 2,
CYCLOPEDIA_HOUSE_STATE_TRANSFER = 3,
CYCLOPEDIA_HOUSE_STATE_MOVEOUT = 4,
};

enum CyclopediaHouseAuctionType_t : uint8_t
{
CYCLOPEDIA_HOUSE_TYPE_NONE = 0,
CYCLOPEDIA_HOUSE_TYPE_BID = 1,
CYCLOPEDIA_HOUSE_TYPE_MOVEOUT = 2,
CYCLOPEDIA_HOUSE_TYPE_TRANSFER = 3,
CYCLOPEDIA_HOUSE_TYPE_CANCEL_MOVEOUT = 4,
CYCLOPEDIA_HOUSE_TYPE_CANCEL_TRANSFER = 5,
CYCLOPEDIA_HOUSE_TYPE_ACCEPT_TRANSFER = 6,
CYCLOPEDIA_HOUSE_TYPE_REFECT_TRANSFER = 7,
};

enum CyclopediaCharacterInfoType_t : uint8_t
{
CYCLOPEDIA_CHARACTERINFO_BASEINFORMATION = 0,
Expand Down
8 changes: 8 additions & 0 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,14 @@ void Game::requestSendCharacterInfo(const uint32_t playerId, const Otc::Cycloped
m_protocolGame->sendCyclopediaRequestCharacterInfo(playerId, characterInfoType, entriesPerPage, page);
}

void Game::requestSendCyclopediaHouseAuction(const Otc::CyclopediaHouseAuctionType_t type, const uint32_t houseId, const uint32_t timestamp, const uint64_t bidValue, const std::string_view name)
{
if (!canPerformGameAction())
return;

m_protocolGame->sendCyclopediaHouseAuction(type, houseId, timestamp, bidValue, name);
}

void Game::requestBosstiaryInfo()
{
if (!canPerformGameAction())
Expand Down
1 change: 1 addition & 0 deletions src/client/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ class Game
void requestBestiarySearch(uint16_t raceId);
void requestSendBuyCharmRune(uint8_t runeId, uint8_t action, uint16_t raceId);
void requestSendCharacterInfo(uint32_t playerId, Otc::CyclopediaCharacterInfoType_t characterInfoType, uint16_t entriesPerPage = 0, uint16_t page = 0);
void requestSendCyclopediaHouseAuction(Otc::CyclopediaHouseAuctionType_t type, uint32_t houseId, uint32_t timestamp = 0, uint64_t bidValue = 0, std::string_view name = "");
void requestBosstiaryInfo();
void requestBossSlootInfo();
void requestBossSlotAction(uint8_t action, uint32_t raceId);
Expand Down
1 change: 1 addition & 0 deletions src/client/luafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "requestBossSlootInfo", &Game::requestBossSlootInfo, &g_game);
g_lua.bindSingletonFunction("g_game", "requestBossSlotAction", &Game::requestBossSlotAction, &g_game);
g_lua.bindSingletonFunction("g_game", "sendStatusTrackerBestiary", &Game::sendStatusTrackerBestiary, &g_game);
g_lua.bindSingletonFunction("g_game", "sendCyclopediaHouseAuction", &Game::requestSendCyclopediaHouseAuction, &g_game);

g_lua.bindSingletonFunction("g_game", "getWalkTurnDelay", &Game::getWalkTurnDelay, &g_game);
g_lua.bindSingletonFunction("g_game", "getWalkFirstStepDelay", &Game::getWalkFirstStepDelay, &g_game);
Expand Down
4 changes: 4 additions & 0 deletions src/client/protocolcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ namespace Proto
GameServerFloorChangeUp = 190,
GameServerFloorChangeDown = 191,
GameServerLootContainers = 192,
GameServerCyclopediaHouseAuctionMessage = 195,
GameServerCyclopediaHousesInfo = 198,
GameServerCyclopediaHouseList = 199,
GameServerChooseOutfit = 200,
GameServerSendUpdateImpactTracker = 204,
GameServerSendItemsPrice = 205,
Expand Down Expand Up @@ -301,6 +304,7 @@ namespace Proto
ClientOpenOwnChannel = 170,
ClientInviteToOwnChannel = 171,
ClientExcludeFromOwnChannel = 172,
ClientCyclopediaHouseAuction = 173,
ClientBosstiaryRequestInfo = 174,
ClientBosstiaryRequestSlotInfo = 175,
ClientBosstiaryRequestSlotAction = 176,
Expand Down
5 changes: 5 additions & 0 deletions src/client/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ProtocolGame final : public Protocol
void sendRequestBestiarySearch(uint16_t raceId);
void sendBuyCharmRune(uint8_t runeId, uint8_t action, uint16_t raceId);
void sendCyclopediaRequestCharacterInfo(uint32_t playerId, Otc::CyclopediaCharacterInfoType_t characterInfoType, uint16_t entriesPerPage, uint16_t page);
void sendCyclopediaHouseAuction(Otc::CyclopediaHouseAuctionType_t type, uint32_t houseId, uint32_t timestamp, uint64_t bidValue, std::string_view name);
void sendRequestBosstiaryInfo();
void sendRequestBossSlootInfo();
void sendRequestBossSlotAction(uint8_t action, uint32_t raceId);
Expand Down Expand Up @@ -293,6 +294,10 @@ class ProtocolGame final : public Protocol
void parseTaskHuntingData(const InputMessagePtr& msg);
void parseExperienceTracker(const InputMessagePtr& msg);
void parseLootContainers(const InputMessagePtr& msg);
void parseCyclopediaHouseAuctionMessage(const InputMessagePtr& msg);
void parseCyclopediaHousesInfo(const InputMessagePtr& msg);
void parseCyclopediaHouseList(const InputMessagePtr& msg);

void parseSupplyStash(const InputMessagePtr& msg);
void parseSpecialContainer(const InputMessagePtr& msg);
void parsePartyAnalyzer(const InputMessagePtr& msg);
Expand Down
123 changes: 123 additions & 0 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,15 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
case Proto::GameServerLootContainers:
parseLootContainers(msg);
break;
case Proto::GameServerCyclopediaHouseAuctionMessage:
parseCyclopediaHouseAuctionMessage(msg);
break;
case Proto::GameServerCyclopediaHousesInfo:
parseCyclopediaHousesInfo(msg);
break;
case Proto::GameServerCyclopediaHouseList:
parseCyclopediaHouseList(msg);
break;
case Proto::GameServerChooseOutfit:
parseOpenOutfitWindow(msg);
break;
Expand Down Expand Up @@ -3789,6 +3798,120 @@ void ProtocolGame::parseLootContainers(const InputMessagePtr& msg)
g_lua.callGlobalField("g_game", "onQuickLootContainers", quickLootFallbackToMainContainer, lootList);
}

void ProtocolGame::parseCyclopediaHouseAuctionMessage(const InputMessagePtr& msg)
{
msg->getU32(); // houseId
const uint8_t typeValue = msg->getU8();
if (typeValue == 1) {
msg->getU8(); // 0x00
}
msg->getU8(); // index
// TO-DO Lua - Otui
}

void ProtocolGame::parseCyclopediaHousesInfo(const InputMessagePtr& msg)
{
msg->getU32(); // houseClientId
msg->getU8(); // 0x00

msg->getU8(); // accountHouseCount

msg->getU8(); // 0x00

msg->getU8(); // 3
msg->getU8(); // 3

msg->getU8(); // 0x01

msg->getU8(); // 0x01
msg->getU32(); // houseClientId

const uint16_t housesList = msg->getU16(); // g_game().map.houses.getHouses()
for (auto i = 0; i < housesList; ++i) {
msg->getU32(); // getClientId
}
// TO-DO Lua // Otui
}

void ProtocolGame::parseCyclopediaHouseList(const InputMessagePtr& msg)
{
const uint16_t housesCount = msg->getU16(); // housesCount
for (auto i = 0; i < housesCount; ++i) {
msg->getU32(); // clientId
msg->getU8(); // 0x00 = Renovation, 0x01 = Available

const auto type = static_cast<Otc::CyclopediaHouseState_t>(msg->getU8());
switch (type) {
case Otc::CYCLOPEDIA_HOUSE_STATE_AVAILABLE: {
std::string bidderName = msg->getString();
const auto isBidder = static_cast<bool>(msg->getU8());
msg->getU8(); // disableIndex

if (!bidderName.empty()) {
msg->getU32(); // bidEndDate
msg->getU64(); // highestBid
if (isBidder) {
msg->getU64(); // bidHolderLimit
}
}
break;
}
case Otc::CYCLOPEDIA_HOUSE_STATE_RENTED: {
msg->getString(); // ownerName
msg->getU32(); // paidUntil

const auto isRented = static_cast<bool>(msg->getU8());
if (isRented) {
msg->getU8(); // unknown
msg->getU8(); // unknown
}
break;
}
case Otc::CYCLOPEDIA_HOUSE_STATE_TRANSFER: {
msg->getString(); // ownerName
msg->getU32(); // paidUntil
const auto isOwner = static_cast<bool>(msg->getU8());
if (isOwner) {
msg->getU8(); // unknown
msg->getU8(); // unknown
}
msg->getU32(); // bidEndDate
msg->getString(); // bidderName
msg->getU8(); // unknown
msg->getU64(); // internalBid

const auto isNewOwner = static_cast<bool>(msg->getU8());
if (isNewOwner) {
msg->getU8(); // acceptTransferError
msg->getU8(); // rejectTransferError
}

if (isOwner) {
msg->getU8(); // cancelTransferError
}
break;
}
case Otc::CYCLOPEDIA_HOUSE_STATE_MOVEOUT: {
msg->getString(); // ownerName
msg->getU32(); // paidUntil

const auto isOwner = static_cast<bool>(msg->getU8());
if (isOwner) {
msg->getU8(); // unknown
msg->getU8(); // unknown
msg->getU32(); // bidEndDate
msg->getU8(); // unknown
} else {
msg->getU32(); // bidEndDate
}

break;
}
}
}
// TO-DO Lua - Otui
}

void ProtocolGame::parseSupplyStash(const InputMessagePtr& msg)
{
const uint16_t itemsCount = msg->getU16();
Expand Down
41 changes: 41 additions & 0 deletions src/client/protocolgamesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,47 @@ void ProtocolGame::sendCyclopediaRequestCharacterInfo(const uint32_t playerId, c
send(msg);
}

void ProtocolGame::sendCyclopediaHouseAuction(const Otc::CyclopediaHouseAuctionType_t type, const uint32_t houseId, const uint32_t timestamp, const uint64_t bidValue, const std::string_view name)
{
const auto& msg = std::make_shared<OutputMessage>();
msg->addU8(Proto::ClientCyclopediaHouseAuction);
msg->addU8(type);

switch (type) {
case Otc::CYCLOPEDIA_HOUSE_TYPE_NONE:
msg->addString(name); // townName
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_BID:
msg->addU32(houseId);
msg->addU64(bidValue);
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_MOVEOUT:
msg->addU32(houseId);
msg->addU32(timestamp);
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_TRANSFER:
msg->addU32(houseId);
msg->addU32(timestamp);
msg->addString(name); // newOwner
msg->addU64(bidValue);
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_CANCEL_MOVEOUT:
msg->addU32(houseId);
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_CANCEL_TRANSFER:
msg->addU32(houseId);
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_ACCEPT_TRANSFER:
msg->addU32(houseId);
break;
case Otc::CYCLOPEDIA_HOUSE_TYPE_REFECT_TRANSFER:
msg->addU32(houseId);
break;
}

send(msg);
}

void ProtocolGame::sendRequestBosstiaryInfo()
{
const auto& msg = std::make_shared<OutputMessage>();
Expand Down

0 comments on commit 9ee23ba

Please sign in to comment.