Skip to content

Commit

Permalink
[Protocol Bytes] - Support to client 12.85.11525 (#167)
Browse files Browse the repository at this point in the history
Added the bytes for the item classification upgrade (item tier)
  • Loading branch information
marcosvf132 authored Feb 8, 2022
1 parent a1997c8 commit e9c85a5
Show file tree
Hide file tree
Showing 28 changed files with 20,552 additions and 17,946 deletions.
4 changes: 2 additions & 2 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ maxItem = 2000
maxContainer = 100

-- Version
clientVersion = 1272
clientVersionStr = "12.72"
clientVersion = 1285
clientVersionStr = "12.85"

-- Depot Limit
freeDepotLimit = 2000
Expand Down
4 changes: 4 additions & 0 deletions data/XML/mounts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,8 @@
<mount id="188" clientid="1446" name="Rustwurm" speed="20" premium="no" type="store" />
<mount id="189" clientid="1447" name="Bogwurm" speed="20" premium="no" type="store" />
<mount id="190" clientid="1448" name="Gloomwurm" speed="20" premium="no" type="store" />
<mount id="191" clientid="1453" name="Emerald Raven" speed="20" premium="no" type="store" />
<mount id="192" clientid="1454" name="Mystic Raven" speed="20" premium="no" type="store" />
<mount id="193" clientid="1455" name="Radiant Raven" speed="20" premium="no" type="store" />
<mount id="194" clientid="1459" name="Gloothomotive" speed="20" premium="yes" type="store" />
</mounts>
6 changes: 6 additions & 0 deletions data/XML/outfits.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
<outfit type="0" looktype="1437" name="Royal Bounacean Advisor" premium="yes" unlocked="no" enabled="yes" from="quest" />
<outfit type="0" looktype="1445" name="Dragon Knight" premium="no" unlocked="no" enabled="yes" from="store" />
<outfit type="0" looktype="1450" name="Arbalester" premium="no" unlocked="no" enabled="yes" from="store" />
<outfit type="0" looktype="1456" name="Royal Costume" premium="no" unlocked="no" enabled="yes" from="store" />
<outfit type="0" looktype="1461" name="Formal Dress" premium="yes" unlocked="no" enabled="yes" from="store" />
<outfit type="0" looktype="1490" name="Ghost Blade" premium="yes" unlocked="no" enabled="yes" from="store" />

<!-- Male outfits -->
<outfit type="1" looktype="128" name="Citizen" premium="no" unlocked="yes" enabled="yes" />
Expand Down Expand Up @@ -207,4 +210,7 @@
<outfit type="1" looktype="1436" name="Royal Bounacean Advisor" premium="yes" unlocked="no" enabled="yes" from="quest" />
<outfit type="1" looktype="1444" name="Dragon Knight" premium="no" unlocked="no" enabled="yes" from="store" />
<outfit type="1" looktype="1449" name="Arbalester" premium="no" unlocked="no" enabled="yes" from="store" />
<outfit type="1" looktype="1457" name="Royal Costume" premium="no" unlocked="no" enabled="yes" from="store" />
<outfit type="1" looktype="1460" name="Formal Dress" premium="yes" unlocked="no" enabled="yes" from="store" />
<outfit type="1" looktype="1489" name="Ghost Blade" premium="yes" unlocked="no" enabled="yes" from="store" />
</outfits>
Binary file modified data/items/items.otb
Binary file not shown.
37,966 changes: 20,056 additions & 17,910 deletions data/items/items.xml

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions data/scripts/item_classification/item_tiers.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local itemTierClassifications = {
-- Upgrade classification 1
[1] = {
-- Update tier 0
[0] = {price = 25000}
},
-- Upgrade classification 2
[2] = {
-- Update tier 0
[0] = {price = 750000},
-- Update tier 1
[1] = {price = 5000000}
},
-- Upgrade classification 3
[3] = {
[0] = {price = 4000000},
[1] = {price = 10000000},
[2] = {price = 20000000}
},
-- Upgrade classification 4
[4] = {
[0] = {price = 8000000},
[1] = {price = 20000000},
[2] = {price = 40000000},
[3] = {price = 65000000},
[4] = {price = 100000000},
[5] = {price = 250000000},
[6] = {price = 750000000},
[7] = {price = 2500000000},
[8] = {price = 8000000000},
[9] = {price = 15000000000}
}
}

for classificationId, classificationTable in ipairs(itemTierClassifications) do
local itemClassification = Game.createItemClassification(classificationId)
local classification = {}

-- Registers table for register_item_tier.lua interface
classification.Upgrades = {}
for tierId, tierTable in ipairs(classificationTable) do
if tierId then
classification.Upgrades.TierId = tierId
end
if tierTable.price then
classification.Upgrades.Price = tierTable.price
end
end
-- Create item classification and register classification table
itemClassification:register(classification)
end
26 changes: 26 additions & 0 deletions data/scripts/lib/register_item_tier.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
registerItemClassification = {}
setmetatable(registerItemClassification,
{
__call =
function(self, itemClass, mask)
for _,parse in pairs(self) do
parse(itemClass, mask)
end
end
})

ItemClassification.register = function(self, mask)
return registerItemClassification(self, mask)
end

registerItemClassification.Upgrades = function(itemClassification, mask)
if mask.Upgrades then
for _, value in ipairs(mask.Upgrades) do
if value.TierId and value.Price then
itemClassification:addTier(value.TierId, value.Price)
else
Spdlog.warn("[registerItemClassification.Upgrades] - Item classification failed on adquire TierID or Price attribute.")
end
end
end
end
24 changes: 22 additions & 2 deletions data/scripts/talkactions/god/looktype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@ local invalidTypes = {
189, 190, 191, 411, 415, 424, 439, 440, 468, 469, 474, 475, 476, 477, 478,
479, 480, 481, 482, 483, 484, 485, 501, 518, 519, 520, 524, 525, 536, 543,
549, 576, 581, 582, 597, 616, 623, 625, 638, 639, 640, 641, 642, 643, 645,
646, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663
646, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 678, 700,
701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 713, 715, 718, 719,
722, 723, 737, 741, 742, 743, 744, 748, 751, 752, 753, 754, 755, 756, 757,
758, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777,
778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792,
793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807,
808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822,
823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837,
838, 839, 840, 841, 847, 864, 865, 866, 867, 871, 872, 880, 891, 892, 893,
894, 895, 896, 897, 898, 911, 912, 917, 930, 941, 942, 946, 953, 954, 983,
995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008,
1009, 1010, 1012, 1014, 1015, 1022, 1028, 1074, 1075, 1080, 1081, 1082, 1083,
1084, 1085, 1086, 1087, 1089, 1090, 1096, 1097, 1098, 1099, 1100, 1141, 1145,
1153, 1154, 1155, 1156, 1160, 1170, 1171, 1172, 1176, 1177, 1178, 1182, 1192,
1193, 1194, 1198, 1215, 1216, 1225, 1226, 1227, 1228, 1235, 1236, 1237, 1238,
1239, 1240, 1241, 1242, 1250, 1254, 1263, 1267, 1273, 1274, 1287, 1302, 1318,
1319, 1320, 1327, 1328, 1329, 1330, 1340, 1343, 1345, 1347, 1348, 1349, 1350,
1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1368,
1369, 1370, 1374, 1375, 1376, 1388, 1392, 1395, 1400, 1402, 1404, 1409, 1410,
1411, 1420, 1421, 1427, 1429, 1432, 1433, 1434, 1435, 1438, 1442, 1443, 1451,
1452, 1458, 1462
}

local looktype = TalkAction("/looktype")
Expand All @@ -21,7 +41,7 @@ function looktype.onSay(player, words, param)
end

local lookType = tonumber(param)
if lookType >= 0 and lookType < 700 and not table.contains(invalidTypes, lookType) then
if lookType >= 0 and lookType < 1469 and not table.contains(invalidTypes, lookType) then
local playerOutfit = player:getOutfit()
playerOutfit.lookType = lookType
player:setOutfit(playerOutfit)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ target_sources(${PROJECT_NAME}
lua/functions/events/talk_action_functions.cpp
lua/functions/items/container_functions.cpp
lua/functions/items/imbuement_functions.cpp
lua/functions/items/item_classification_functions.cpp
lua/functions/items/item_functions.cpp
lua/functions/items/item_type_functions.cpp
lua/functions/items/weapon_functions.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool ConfigManager::load()
string[MYSQL_PASS] = getGlobalString(L, "mysqlPass", "");
string[MYSQL_DB] = getGlobalString(L, "mysqlDatabase", "canary");
string[MYSQL_SOCK] = getGlobalString(L, "mysqlSock", "");
string[CLIENT_VERSION_STR] = getGlobalString(L, "clientVersionStr", "12.72");
string[CLIENT_VERSION_STR] = getGlobalString(L, "clientVersionStr", "12.85");

integer[SQL_PORT] = getGlobalNumber(L, "mysqlPort", 3306);
integer[GAME_PORT] = getGlobalNumber(L, "gameProtocolPort", 7172);
Expand All @@ -135,7 +135,7 @@ bool ConfigManager::load()

integer[MARKET_OFFER_DURATION] = getGlobalNumber(L, "marketOfferDuration", 30 * 24 * 60 * 60);

integer[CLIENT_VERSION] = getGlobalNumber(L, "clientVersion", 1272);
integer[CLIENT_VERSION] = getGlobalNumber(L, "clientVersion", 1285);
integer[FREE_DEPOT_LIMIT] = getGlobalNumber(L, "freeDepotLimit", 2000);
integer[PREMIUM_DEPOT_LIMIT] = getGlobalNumber(L, "premiumDepotLimit", 8000);
integer[DEPOT_BOXES] = getGlobalNumber(L, "depotBoxes", 19);
Expand Down
5 changes: 3 additions & 2 deletions src/creatures/creatures_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ enum MarketAction_t {
};

enum MarketRequest_t {
MARKETREQUEST_OWN_OFFERS = 0xFFFE,
MARKETREQUEST_OWN_HISTORY = 0xFFFF,
MARKETREQUEST_OWN_HISTORY = 1,
MARKETREQUEST_OWN_OFFERS = 2,
MARKETREQUEST_ITEM_BROWSE = 3,
};

enum MarketOfferState_t {
Expand Down
25 changes: 25 additions & 0 deletions src/game/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
#include "lua/creature/raids.h"
#include "creatures/players/grouping/team_finder.hpp"
#include "utils/wildcardtree.h"
#include "items/items_classification.hpp"

class ServiceManager;
class Creature;
class Monster;
class Npc;
class CombatInfo;
class Charm;
class ItemClassification;

static constexpr int32_t EVENT_LIGHTINTERVAL_MS = 10000;

Expand Down Expand Up @@ -150,6 +152,25 @@ class Game
return itemsSaleCount;
}

void addItemsClassification(ItemClassification* itemsClassification) {
itemsClassifications.push_back(itemsClassification);
}
ItemClassification* getItemsClassification(uint8_t id, bool create) {
auto it = std::find_if(itemsClassifications.begin(), itemsClassifications.end(), [id](ItemClassification* it) {
return it->id == id;
});

if (it != itemsClassifications.end()) {
return *it;
} else if (create) {
ItemClassification* itemClassification = new ItemClassification(id);
addItemsClassification(itemClassification);
return itemClassification;
}

return nullptr;
}

LightInfo getWorldLightInfo() const;

bool gameIsDay();
Expand Down Expand Up @@ -421,6 +442,8 @@ class Game
const std::unordered_map<uint32_t, Player*>& getPlayers() const { return players; }
const std::map<uint32_t, Npc*>& getNpcs() const { return npcs; }

const std::vector<ItemClassification*>& getItemsClassifications() const { return itemsClassifications; }

void addPlayer(Player* player);
void removePlayer(Player* player);

Expand Down Expand Up @@ -612,6 +635,8 @@ class Game

std::map<uint16_t, uint32_t> itemsPriceMap;
uint16_t itemsSaleCount;

std::vector<ItemClassification*> itemsClassifications;
};

#endif // SRC_GAME_GAME_H_
8 changes: 8 additions & 0 deletions src/items/functions/item_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void ItemParse::initParse(const std::string& tmpStrValue, pugi::xml_node attribu
ItemParse::parseDefense(tmpStrValue, valueAttribute, itemType);
ItemParse::parseExtraDefense(tmpStrValue, valueAttribute, itemType);
ItemParse::parseAttack(tmpStrValue, valueAttribute, itemType);
ItemParse::parseUpgradeClassification(tmpStrValue, valueAttribute, itemType);
ItemParse::parseRotateTo(tmpStrValue, valueAttribute, itemType);
ItemParse::parseWrapContainer(tmpStrValue, valueAttribute, itemType);
ItemParse::parseWrapableTo(tmpStrValue, valueAttribute, itemType);
Expand Down Expand Up @@ -151,6 +152,13 @@ void ItemParse::parseAttack(const std::string& tmpStrValue, pugi::xml_attribute
}
}

void ItemParse::parseUpgradeClassification(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType) {
std::string stringValue = tmpStrValue;
if (stringValue == "upgradeclassification") {
itemType.upgradeClassification = pugi::cast<int32_t>(valueAttribute.value());
}
}

void ItemParse::parseRotateTo(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType) {
std::string stringValue = tmpStrValue;
if (stringValue == "rotateto") {
Expand Down
2 changes: 2 additions & 0 deletions src/items/functions/item_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const std::unordered_map<std::string, ItemParseAttributes_t> ItemParseAttributes
{"defense", ITEM_PARSE_DEFENSE},
{"extradef", ITEM_PARSE_EXTRADEF},
{"attack", ITEM_PARSE_ATTACK},
{"upgradeclassification", ITEM_PARSE_UPGRADE_CLASS},
{"rotateto", ITEM_PARSE_ROTATETO},
{"wrapcontainer", ITEM_PARSE_WRAPCONTAINER},
{"wrapableto", ITEM_PARSE_WRAPABLETO},
Expand Down Expand Up @@ -258,6 +259,7 @@ class ItemParse : public Items
static void parseDefense(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
static void parseExtraDefense(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
static void parseAttack(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
static void parseUpgradeClassification(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
static void parseRotateTo(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
static void parseWrapContainer(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
static void parseWrapableTo(const std::string& tmpStrValue, pugi::xml_attribute valueAttribute, ItemType& itemType);
Expand Down
2 changes: 1 addition & 1 deletion src/items/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ FILELOADER_ERRORS Items::loadFromOtb(const std::string& file)
SPDLOG_ERROR("[Items::loadFromOtb] - "
"Old version detected, a newer version of items.otb is required");
return ERROR_INVALID_FORMAT;
} else if (minorVersion < CLIENT_VERSION_1140) {
} else if (minorVersion < CLIENT_VERSION_1285) {
SPDLOG_ERROR("[Items::loadFromOtb] - "
"A newer version of items.otb is required");
return ERROR_INVALID_FORMAT;
Expand Down
3 changes: 2 additions & 1 deletion src/items/items.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
*
Expand Down Expand Up @@ -254,6 +254,7 @@ class ItemType
TileFlags_t floorChange = TILESTATE_NONE;
std::map<ImbuementTypes_t, uint16_t> imbuementTypes;

uint8_t upgradeClassification = 0;
uint8_t alwaysOnTopOrder = 0;
uint8_t lightLevel = 0;
uint8_t lightColor = 0;
Expand Down
48 changes: 48 additions & 0 deletions src/items/items_classification.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Canary - A free and open-source MMORPG server emulator
* Copyright (C) 2021 OpenTibiaBR <opentibiabr@outlook.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef SRC_ITEMS_ITEMS_CLASSIFICATION_HPP_
#define SRC_ITEMS_ITEMS_CLASSIFICATION_HPP_

// Classification class for forging system and market.
class ItemClassification
{
public:
ItemClassification() = default;
explicit ItemClassification(uint8_t id) :
id(id) {}
virtual ~ItemClassification() = default;

void addTier(uint8_t id, uint64_t price)
{
for (std::pair<uint8_t, uint64_t> tier : tiers) {
if (tier.first == id) {
tier.second = price;
return;
}
}

tiers.push_back(std::pair<uint8_t, uint64_t>({ id, price }));
}

uint8_t id;
std::vector<std::pair<uint8_t, uint64_t>> tiers;
};

#endif // SRC_ITEMS_ITEMS_CLASSIFICATION_HPP_
3 changes: 2 additions & 1 deletion src/items/items_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ enum ClientVersion_t {
CLIENT_VERSION_1100_V2 = 59,
CLIENT_VERSION_1100_V3 = 60, // No relased
CLIENT_VERSION_1100_V4 = 61, // No relased
CLIENT_VERSION_1140 = 62,
CLIENT_VERSION_1285 = 62,
};

enum RootAttrib_ {
Expand Down Expand Up @@ -535,6 +535,7 @@ enum ItemParseAttributes_t {
ITEM_PARSE_DEFENSE,
ITEM_PARSE_EXTRADEF,
ITEM_PARSE_ATTACK,
ITEM_PARSE_UPGRADE_CLASS,
ITEM_PARSE_ROTATETO,
ITEM_PARSE_WRAPCONTAINER,
ITEM_PARSE_IMBUEMENT,
Expand Down
Loading

0 comments on commit e9c85a5

Please sign in to comment.