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: invalid mount offer from store #1933

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions data/XML/mounts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<mount id="216" clientid="1677" name="Darkfire Devourer" speed="10" premium="no" type="store" />
<mount id="217" clientid="1682" name="Spirit of Purity" speed="10" premium="no" type="store" />
<mount id="218" clientid="1632" name="Foxmouse" speed="10" premium="no" type="store" />
<mount id="219" clientid="1685" name="Doom Skull" speed="10" premium="no" type="store" />
<!--<mount id="219" clientid="1685" name="Doom Skull" speed="10" premium="no" type="store" />
<mount id="220" clientid="1686" name="Magma Skull" speed="10" premium="no" type="store" />
<mount id="221" clientid="1687" name="Corpsefire Skull" speed="10" premium="no" type="store" />
<mount id="221" clientid="1687" name="Corpsefire Skull" speed="10" premium="no" type="store"-->
</mounts>
14 changes: 7 additions & 7 deletions data/modules/scripts/gamestore/gamestore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1274,16 +1274,16 @@ GameStore.Categories = {
description = "{character}\n{speedboost}\n\n<i>If the Coralripper moves its fins, it generates enough air pressure that it can even float over land. Its numerous eyes allow it to quickly detect dangers even in confusing situations and eliminate them with one powerful bite. If you watch your fingers, you are going to be good friends.</i>",
type = GameStore.OfferTypes.OFFER_TYPE_MOUNT,
},
{
--[[{
icons = { "Corpsefire_Skull.png" },
name = "Corpsefire Skull",
price = 750,
id = 220,
id = 221,
description = "{character}\n{speedboost}\n\n<i>Skulls are the infernal heralds of untamed power. Bodies are obsolete when sinister forces animate your being. Embrace their presence and command the devastating might that awaits on the back of an eerie Corpsefire Skull!</i>",
type = GameStore.OfferTypes.OFFER_TYPE_MOUNT,
state = GameStore.States.STATE_NEW,
home = true,
},
},]]
dudantas marked this conversation as resolved.
Show resolved Hide resolved
{
icons = { "Cranium_Spider.png" },
name = "Cranium Spider",
Expand Down Expand Up @@ -1348,7 +1348,7 @@ GameStore.Categories = {
description = "{character}\n{speedboost}\n\n<i>Its roaring is piercing marrow and bone and can be heard over ten miles away. The Desert King is the undisputed ruler of its territory and no one messes with this animal. Show no fear and prove yourself worthy of its trust and you will get yourself a valuable companion for your adventures.</i>",
type = GameStore.OfferTypes.OFFER_TYPE_MOUNT,
},
{
--[[{
icons = { "Doom_Skull.png" },
name = "Doom Skull",
price = 750,
Expand All @@ -1357,7 +1357,7 @@ GameStore.Categories = {
type = GameStore.OfferTypes.OFFER_TYPE_MOUNT,
state = GameStore.States.STATE_NEW,
home = true,
},
},]]
{
icons = { "Doombringer.png" },
name = "Doombringer",
Expand Down Expand Up @@ -1734,7 +1734,7 @@ GameStore.Categories = {
description = "{character}\n{speedboost}\n\n<i>The Magic Carpet is the perfect mount for those who are too busy to take care of an animal mount or simply like to travel on a beautiful, magic hand-woven carpet.</i>",
type = GameStore.OfferTypes.OFFER_TYPE_MOUNT,
},
{
--[[{
icons = { "Magma_Skull.png" },
name = "Magma Skull",
price = 750,
Expand All @@ -1743,7 +1743,7 @@ GameStore.Categories = {
type = GameStore.OfferTypes.OFFER_TYPE_MOUNT,
state = GameStore.States.STATE_NEW,
home = true,
},
},]]
{
icons = { "Marsh_Toad.png" },
name = "Marsh Toad",
Expand Down
7 changes: 6 additions & 1 deletion data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,12 @@ function sendHomePage(playerId)
msg:addString(offer.icons[1])
elseif type == GameStore.ConverType.SHOW_MOUNT then
local mount = Mount(offer.id)
msg:addU16(mount:getClientId())
if mount then
msg:addU16(mount:getClientId())
else
logger.debug("[sendHomePage] mount with id {} not exist, ignoring to avoid a debug on the client", offer.id)
msg:addU16(0)
end
elseif type == GameStore.ConverType.SHOW_ITEM then
msg:addU16(offer.itemtype)
elseif type == GameStore.ConverType.SHOW_OUTFIT then
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/appearance/mounts/mounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool Mounts::loadFromXml() {
for (auto mountNode : doc.child("mounts").children()) {
uint16_t lookType = pugi::cast<uint16_t>(mountNode.attribute("clientid").value());
if (g_configManager().getBoolean(WARN_UNSAFE_SCRIPTS, __FUNCTION__) && lookType != 0 && !g_game().isLookTypeRegistered(lookType)) {
g_logger().warn("{} - An unregistered creature looktype type with id '{}' was blocked to prevent client crash.", __FUNCTION__, lookType);
g_logger().warn("{} - An unregistered creature mount with id '{}' was blocked to prevent client crash.", __FUNCTION__, lookType);
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/lua/functions/lua_functions_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ std::string LuaFunctionsLoader::getFormatedLoggerMessage(lua_State* L) {
try {
return fmt::vformat(format, args);
} catch (const fmt::format_error &e) {
g_logger().error("[{}] format error: {}", __FUNCTION__, e.what());
g_logger().debug("[{}] format error: {}", __FUNCTION__, e.what());
reportErrorFunc(fmt::format("Format error, {}", e.what()));
}

return {};
Expand Down
Loading