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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
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