Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: packet Cyclopedia house auction 13.40 #970

Merged
merged 24 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
47cb9dd
fix: packet cyclopedia house auction Canary PR # 3022
kokekanon Nov 18, 2024
06a34a3
fix: Sonarbot string_view to string
kokekanon Nov 18, 2024
c58eb8f
fix: sonar (Auto | Use the init-statement to declare "isOwner" inside…
kokekanon Nov 19, 2024
6ec2fe1
fix: sonar Use the init-statement to declare "isRented" inside the if…
kokekanon Nov 19, 2024
b3d9a41
Merge branch 'main' into fix-warning
Nottinghster Nov 25, 2024
48c9645
Update src/client/protocolgame.h
kokekanon Nov 25, 2024
79fd222
Update src/client/game.cpp
kokekanon Nov 25, 2024
d6bcada
Update src/client/game.h
kokekanon Nov 25, 2024
7d4df98
Update src/client/protocolgameparse.cpp
kokekanon Nov 25, 2024
55f6a1e
Update src/client/protocolgameparse.cpp
kokekanon Nov 25, 2024
793c2d4
Update src/client/protocolgamesend.cpp
kokekanon Nov 25, 2024
b9e1788
Update src/client/protocolgamesend.cpp
kokekanon Nov 25, 2024
e41f07d
Update src/client/protocolgamesend.cpp
kokekanon Nov 25, 2024
f5e8b40
Update src/client/protocolgamesend.cpp
kokekanon Nov 25, 2024
2149b6f
Update src/client/protocolgamesend.cpp
kokekanon Nov 25, 2024
48c36c7
Merge branch 'main' into fix-warning
kokekanon Nov 29, 2024
b3a1691
Merge remote-tracking branch 'upstream/main' into fix-warning
kokekanon Dec 12, 2024
9aa5037
Merge remote-tracking branch 'upstream/main' into fix-warning
kokekanon Dec 18, 2024
024c47b
Merge branch 'main' into fix-warning
Nottinghster Dec 19, 2024
8c49c69
Merge branch 'main' into fix-warning
mehah Dec 25, 2024
98e0d65
Merge remote-tracking branch 'upstream/main' into fix-warning
kokekanon Dec 31, 2024
8fa0219
Update src/client/protocolgameparse.cpp
kokekanon Dec 31, 2024
005111a
Update protocolgamesend.cpp
kokekanon Dec 31, 2024
88d1b01
Merge remote-tracking branch 'upstream/main' into fix-warning
kokekanon Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading