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: game_outfit custom compatible with canary (familiar, outfit/mount in store) #962

Merged
merged 40 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
da810ce
fix: game_outfit custom compatible with canary
kokekanon Nov 7, 2024
dcb3214
review sonarcloud
kokekanon Nov 7, 2024
ec50c06
Update src/client/protocolgameparse.cpp
kokekanon Nov 8, 2024
9817d8f
Update src/client/protocolgameparse.cpp
kokekanon Nov 8, 2024
9e3ebdc
fix compilation post review
kokekanon Nov 8, 2024
b7ac615
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Nov 8, 2024
313eb99
review: sonarcloud
kokekanon Nov 8, 2024
06b14f2
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Nov 8, 2024
310eb24
feat: familiar (need test)
kokekanon Nov 8, 2024
6e3d65b
fix typo
kokekanon Nov 8, 2024
b0ef25b
fix visible
kokekanon Nov 8, 2024
e35c8ea
fix typo again
kokekanon Nov 8, 2024
d681cc8
feat: show Only Mine game_outfit
kokekanon Nov 8, 2024
bb7ccf6
fix only mine mount
kokekanon Nov 8, 2024
597a3c5
Update outfit.lua
kokekanon Nov 8, 2024
aac3d8f
fix: button qt
kokekanon Nov 8, 2024
13f33c4
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Nov 8, 2024
ad191d3
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Nov 29, 2024
bef643d
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Dec 12, 2024
aaa5322
Merge branch 'main' into canary
Nottinghster Dec 19, 2024
c3429eb
bad merge of Nottinghster
kokekanon Dec 19, 2024
6534d7a
Merge branch 'main' into canary
mehah Dec 25, 2024
469b7a0
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 2, 2025
17231ac
missing table
kokekanon Jan 3, 2025
e1a37a3
temp fix: I could not find another solution
kokekanon Jan 3, 2025
8aeab80
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 4, 2025
34b9cd3
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 5, 2025
5f31310
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 6, 2025
43a0a72
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 6, 2025
c7ae156
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 9, 2025
e7d0443
fix familiar
kokekanon Jan 9, 2025
8f216f4
Merge branch 'main' into canary
Nottinghster Jan 14, 2025
625ab3d
Merge branch 'main' into canary
Nottinghster Jan 15, 2025
1bfbe6f
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 16, 2025
5786f9a
Merge remote-tracking branch 'upstream/main' into canary
kokekanon Jan 18, 2025
cff7ffd
Update modules/game_outfit/outfit.lua
kokekanon Jan 22, 2025
53df83a
review:luan lua
kokekanon Jan 22, 2025
805a237
Merge branch 'canary' of https://github.com/kokekanon/otclient.readme…
kokekanon Jan 22, 2025
872130a
Merge branch 'main' into canary
luanluciano93 Jan 22, 2025
6342fe0
Merge branch 'canary' of https://github.com/kokekanon/otclient.readme…
kokekanon Jan 22, 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
3 changes: 0 additions & 3 deletions data/styles/40-outfitwindow.otui
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ SelectionButton < Panel
focusable: true
phantom: false

$hover:
image-color: #ffffff

$focus:
border: 1 white
image-color: #ffffff
Expand Down
3 changes: 0 additions & 3 deletions modules/game_attachedeffects/attachedeffects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ function controller:onTerminate()
g_attachedEffects.clear()
end

-- @ note: sorry, I couldn't find any other way to do it
function getCategory(id)
return AttachedEffectManager.get(id).thingCategory
end
Expand All @@ -84,5 +83,3 @@ function thingId(id)
return "None"
end
end

-- @
7 changes: 1 addition & 6 deletions modules/game_cyclopedia/tab/bestiary/bestiary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ function Cyclopedia.CreateCreatureItems(data)
itemWidget.Stackable:setText("1")
end
end

local price, rarity = ItemsDatabase.getSellValueAndColor(itemWidget.id)
if price > 0 then
itemWidget:setImageSource("/images/ui/rarity_" .. rarity)
end

ItemsDatabase.setRarityItem(itemWidget, itemWidget:getItem())
itemWidget.onMouseRelease = onAddLootClick
end
end
Expand Down
12 changes: 10 additions & 2 deletions modules/game_outfit/outfit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,11 @@ function showOutfits()
if thingType:getRealSize() > 0 then
button.outfit:setCreatureSize(thingType:getRealSize() + 32)
end
--button.outfit:setBorderColor('red')
--button.outfit:setBorderWidth(2)

if outfitData[4] and outfitData[4] ~= 0 then
-- mode: 0x00 - available, 0x01 store (requires U32 store offerId), 0x02 golden outfit tooltip (hardcoded)
button:setImageColor("#49ABFF")
end

button.name:setText(outfitData[2])
if tempOutfit.type == outfitData[1] then
Expand Down Expand Up @@ -904,6 +907,11 @@ function showMounts()
if tempOutfit.mount == mountData[1] then
focused = mountData[1]
end

if mountData[3] and mountData[3] ~= 0 then
-- mode: 0x00 - available, 0x01 store (requires U32 store offerId)
button:setImageColor("#49ABFF")
end
end

if #ServerData.mounts == 1 then
Expand Down
4 changes: 2 additions & 2 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ void Game::processRemoveAutomapFlag(const Position& pos, const uint8_t icon, con
g_lua.callGlobalField("g_game", "onRemoveAutomapFlag", pos, icon, message);
}

void Game::processOpenOutfitWindow(const Outfit& currentOutfit, const std::vector<std::tuple<uint16_t, std::string, uint8_t>>& outfitList,
const std::vector<std::tuple<uint16_t, std::string>>& mountList,
void Game::processOpenOutfitWindow(const Outfit& currentOutfit, const std::vector<std::tuple<uint16_t, std::string, uint8_t, uint8_t>>& outfitList,
const std::vector<std::tuple<uint16_t, std::string, uint8_t>>& mountList,
const std::vector<std::tuple<uint16_t, std::string>>& wingsList,
const std::vector<std::tuple<uint16_t, std::string>>& aurasList,
const std::vector<std::tuple<uint16_t, std::string>>& effectList,
Expand Down
4 changes: 2 additions & 2 deletions src/client/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ class Game
static void processRemoveAutomapFlag(const Position& pos, const uint8_t icon, const std::string_view message);

// outfit
void processOpenOutfitWindow(const Outfit& currentOutfit, const std::vector<std::tuple<uint16_t, std::string, uint8_t>>& outfitList,
const std::vector<std::tuple<uint16_t, std::string>>& mountList,
void processOpenOutfitWindow(const Outfit& currentOutfit, const std::vector<std::tuple<uint16_t, std::string, uint8_t, uint8_t>>& outfitList,
const std::vector<std::tuple<uint16_t, std::string, uint8_t>>& mountList,
const std::vector<std::tuple<uint16_t, std::string>>& wingsList,
const std::vector<std::tuple<uint16_t, std::string>>& aurasList,
const std::vector<std::tuple<uint16_t, std::string>>& effectsList,
Expand Down
1 change: 1 addition & 0 deletions src/client/protocolcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace Proto
GameServerCreatureShader = 54,
GameServerMapShader = 55,
GameServerCreatureTyping = 56,
GameServerFeatures = 67,
GameServerFloorDescription = 75,

// original tibia ONLY
Expand Down
1 change: 1 addition & 0 deletions src/client/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class ProtocolGame : public Protocol
void parseFloorDescription(const InputMessagePtr& msg);
void parseMapDescription(const InputMessagePtr& msg);
void parseCreatureTyping(const InputMessagePtr& msg);
void parseFeatures(const InputMessagePtr& msg);
void parseMapMoveNorth(const InputMessagePtr& msg);
void parseMapMoveEast(const InputMessagePtr& msg);
void parseMapMoveSouth(const InputMessagePtr& msg);
Expand Down
37 changes: 27 additions & 10 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
case Proto::GameServerCreatureTyping:
parseCreatureTyping(msg);
break;
case Proto::GameServerFeatures:
parseFeatures(msg);
break;
case Proto::GameServerFloorDescription:
parseFloorDescription(msg);
break;
Expand Down Expand Up @@ -2552,23 +2555,23 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg) const
msg->getU16(); // current familiar looktype
}

std::vector<std::tuple<uint16_t, std::string, uint8_t>> outfitList;
std::vector<std::tuple<uint16_t, std::string, uint8_t, uint8_t>> outfitList;

if (g_game.getFeature(Otc::GameNewOutfitProtocol)) {
const uint16_t outfitCount = g_game.getClientVersion() >= 1281 ? msg->getU16() : msg->getU8();
for (auto i = 0; i < outfitCount; ++i) {
const uint16_t outfitId = msg->getU16();
const auto& outfitName = msg->getString();
const uint8_t outfitAddons = msg->getU8();

uint8_t outfitMode = 0;
if (g_game.getClientVersion() >= 1281) {
const uint8_t outfitMode = msg->getU8(); // mode: 0x00 - available, 0x01 store (requires U32 store offerId), 0x02 golden outfit tooltip (hardcoded)
outfitMode = msg->getU8(); // mode: 0x00 - available, 0x01 store (requires U32 store offerId), 0x02 golden outfit tooltip (hardcoded)
if (outfitMode == 1) {
msg->getU32();
}
}

outfitList.emplace_back(outfitId, outfitName, outfitAddons);
outfitList.emplace_back(outfitId, outfitName, outfitAddons,outfitMode);
kokekanon marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
uint16_t outfitStart;
Expand All @@ -2582,26 +2585,26 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg) const
}

for (auto i = outfitStart; i <= outfitEnd; ++i) {
outfitList.emplace_back(i, "", 0);
outfitList.emplace_back(i, "", 0, 0);
}
}

std::vector<std::tuple<uint16_t, std::string>> mountList;
std::vector<std::tuple<uint16_t, std::string, uint8_t>> mountList;

if (g_game.getFeature(Otc::GamePlayerMounts)) {
const uint16_t mountCount = g_game.getClientVersion() >= 1281 ? msg->getU16() : msg->getU8();
for (auto i = 0; i < mountCount; ++i) {
const uint16_t mountId = msg->getU16(); // mount type
const auto& mountName = msg->getString(); // mount name

uint8_t mountMode = 0;
if (g_game.getClientVersion() >= 1281) {
const uint8_t mountMode = msg->getU8(); // mode: 0x00 - available, 0x01 store (requires U32 store offerId)
mountMode = msg->getU8(); // mode: 0x00 - available, 0x01 store (requires U32 store offerId)
if (mountMode == 1) {
msg->getU32();
}
}

mountList.emplace_back(mountId, mountName);
mountList.emplace_back(mountId, mountName, mountMode);
}
}

Expand Down Expand Up @@ -3200,7 +3203,7 @@ Outfit ProtocolGame::getOutfit(const InputMessagePtr& msg, const bool parseMount
outfit.setMount(mount);
}

if (g_game.getFeature(Otc::GameWingsAurasEffectsShader)) {
if (g_game.getFeature(Otc::GameWingsAurasEffectsShader) && parseMount) {
const uint16_t wings = msg->getU16();
outfit.setWing(wings);

Expand Down Expand Up @@ -5192,6 +5195,20 @@ void ProtocolGame::parseCreatureTyping(const InputMessagePtr& msg)
creature->setTyping(typing);
}

void ProtocolGame::parseFeatures(const InputMessagePtr& msg)
{
const uint16_t features = msg->getU16();
for (auto i = 0; i < features; ++i) {
auto feature = (Otc::GameFeature)msg->getU8();
bool enabled = msg->getU8() > 0;
kokekanon marked this conversation as resolved.
Show resolved Hide resolved
if (enabled) {
g_game.enableFeature(feature);
} else {
g_game.disableFeature(feature);
}
}
}

void ProtocolGame::parseHighscores(const InputMessagePtr& msg)
{
const bool isEmpty = static_cast<bool>(msg->getU8());
Expand Down
Loading