@Callum
Good suggestion. It works great.
It was pretty easy to implement:
Config file:
## ShopReopenOnSell (bool)
# Navigation will go back to the shop's main menu after you sell an item.
# This will force the list of sellable items to update. Otherwise, the sellable list only updates once you re-open the "Sell Item(s)" window.
ShopReopenOnSell = true
eoserv_config.cpp:
eoserv_config_default(config, "ShopReopenOnSell", false);
Shop.cpp:
- Replace "Shop_Open()" method with:
void Shop_Open(Character *character, PacketReader &reader)
{
short id = reader.GetShort();
Shop_Open_ID(character, id);
}
- Add this method to the top:
void Shop_Open_ID(Character *character, short id)
{
UTIL_FOREACH(character->map->npcs, npc)
{
if (npc->index == id && (npc->Data().shop_trade.size() > 0 || npc->Data().shop_craft.size() > 0))
{
character->npc = npc;
character->npc_type = ENF::Shop;
PacketBuilder reply(PACKET_SHOP, PACKET_OPEN,
5 + npc->Data().shop_name.length() + npc->Data().shop_trade.size() * 9 + npc->Data().shop_craft.size() * 14);
reply.AddShort(npc->id);
reply.AddBreakString(npc->Data().shop_name.c_str());
UTIL_FOREACH_CREF(npc->Data().shop_trade, item)
{
reply.AddShort(item->id);
reply.AddThree(item->buy);
reply.AddThree(item->sell);
reply.AddChar(static_cast<int>(character->world->config["MaxShopBuy"]));
}
reply.AddByte(255);
UTIL_FOREACH_CREF(npc->Data().shop_craft, item)
{
std::size_t i = 0;
reply.AddShort(item->id);
for (; i < item->ingredients.size(); ++i)
{
reply.AddShort(item->ingredients[i].id);
reply.AddChar(item->ingredients[i].amount);
}
for (; i < 4; ++i)
{
reply.AddShort(0);
reply.AddChar(0);
}
}
reply.AddByte(255);
character->Send(reply);
break;
}
}
}
- In "void Shop_Sell(Character *character, PacketReader &reader)" below the following line:
character->Send(reply);
Add the following code:
if (character->world->config["ShopReopenOnSell"]) {
Shop_Open_ID(character, character->npc->index);
}
---
Just your friendly neighborhood Programmer-Man!