Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / inventories.cpp
blob5697736ac652d894b31214a00aede5fcb56d6b0e
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2018 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
20 #include "inventories.h"
21 #include "nel/misc/string_conversion.h"
23 using namespace std;
24 using namespace NLMISC;
26 namespace INVENTORIES
28 uint32 TItemId::_LastCreation = 0;
29 uint32 TItemId::_NextSerialNumber = 0;
32 NL_BEGIN_STRING_CONVERSION_TABLE(TInventory)
33 NL_STRING_CONVERSION_TABLE_ENTRY(handling)
34 NL_STRING_CONVERSION_TABLE_ENTRY(temporary)
35 NL_STRING_CONVERSION_TABLE_ENTRY(equipment)
36 NL_STRING_CONVERSION_TABLE_ENTRY(hotbar)
37 NL_STRING_CONVERSION_TABLE_ENTRY(bag)
38 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal1)
39 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal2)
40 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal3)
41 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal4)
42 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal5)
43 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal6)
44 NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal7)
45 // NL_STRING_CONVERSION_TABLE_ENTRY(bot_gift)
46 NL_STRING_CONVERSION_TABLE_ENTRY(UNDEFINED)
47 NL_STRING_CONVERSION_TABLE_ENTRY(exchange)
48 // NL_STRING_CONVERSION_TABLE_ENTRY(exchange_proposition)
49 NL_STRING_CONVERSION_TABLE_ENTRY(trading)
50 NL_STRING_CONVERSION_TABLE_ENTRY(reward_sharing)
51 NL_STRING_CONVERSION_TABLE_ENTRY(guild)
52 NL_STRING_CONVERSION_TABLE_ENTRY(player_room)
53 NL_END_STRING_CONVERSION_TABLE(TInventory, InventoryToString, UNDEFINED)
56 const std::string& toString( TInventory inv )
58 // if this raise, correct the table above
59 nlctassert(MAX_INVENTORY_ANIMAL==7);
60 return InventoryToString.toString(inv);
63 const std::string toLocalDbBranch( TInventory inv )
65 std::string branch = "";
66 if (inv == handling)
67 branch = "HAND";
68 else if (inv == equipment)
69 branch = "EQUIP";
70 if (inv == hotbar)
71 branch = "HOTBAR";
72 return branch;
75 // convert job name to job enum value
76 TInventory toInventory( const std::string& str )
78 TInventory inv = InventoryToString.fromString(str);
80 // support for pack_animalx for backward compatibility (necessary to load old save games)
81 if (inv == UNDEFINED)
83 if (str == "pack_animal1")
84 inv = pet_animal1;
85 else if (str == "pack_animal2")
86 inv = pet_animal2;
87 else if (str == "pack_animal3")
88 inv = pet_animal3;
89 else if (str == "pack_animal4")
90 inv = pet_animal4;
91 else if (str == "pack_animal5")
92 inv = pet_animal5;
93 else if (str == "pack_animal6")
94 inv = pet_animal6;
95 else if (str == "pack_animal7")
96 inv = pet_animal7;
99 return inv;
103 // String for inventories that are not using CInventoryUpdater
104 const char *DatabaseStringFromEInventory [NUM_ALL_INVENTORY] =
106 "HAND", // handling
107 "TEMP", // temporary
108 // "", // pick-up
109 "EQUIP", // equipment
110 "HOTBAR", // hotbar
111 "", // bag
112 "", // pack_animal1
113 "", // pack_animal2
114 "", // pack_animal3
115 "", // pack_animal4
116 "", // pack_animal5
117 "", // pack_animal6
118 "", // pack_animal7
119 "", // harvest
120 // "", // bot_gift
121 "", // exchange
122 // "", // exchange_proposition
123 "", // guild
124 "", // player_room
125 "" // unknown
130 const char *CInventoryCategoryForCharacter::InventoryStr [CInventoryCategoryForCharacter::NbInventoryIds] =
131 { "BAG", "PACK_ANIMAL0", "PACK_ANIMAL1", "PACK_ANIMAL2", "PACK_ANIMAL3", "PACK_ANIMAL4", "PACK_ANIMAL5", "PACK_ANIMAL6", "ROOM" };
132 const uint CInventoryCategoryForCharacter::InventoryNbSlots [CInventoryCategoryForCharacter::NbInventoryIds] =
133 { NbBagSlots, NbPackerSlots, NbPackerSlots, NbPackerSlots, NbPackerSlots, NbPackerSlots, NbPackerSlots, NbPackerSlots, NbRoomSlots };
134 // Other values to change according to these InventoryNbSlots:
135 // - game_share.h/inventories.h: CInventoryCategoryForCharacter::SlotBitSize
136 // - data_common/database.xml: INVENTORY:BAG count
137 // - data/gamedev/interfaces_v3/inventory.xml: inventory:content:bag param inv_branch_nb
139 const char *CInventoryCategoryForGuild::InventoryStr [CInventoryCategoryForGuild::NbInventoryIds] =
140 { "GUILD" };
141 const uint CInventoryCategoryForGuild::InventoryNbSlots [CInventoryCategoryForGuild::NbInventoryIds] =
142 { NbGuildSlots };
143 // Other values to change according to this InventoryNbSlots:
144 // - game_share.h/inventories.h: CInventoryCategoryForGuild::SlotBitSize
145 // - data_common/database.xml: GUILD:INVENTORY count
146 // - data/gamedev/interfaces_v3/inventory.xml: inventory:content:guild param inv_branch_nb
148 const char *InfoVersionStr = "INFO_VERSION";
150 const char *CItemSlot::ItemPropStr [NbItemPropId] =
151 { "SHEET", "QUALITY", "QUANTITY", "USER_COLOR", "CREATE_TIME", "SERIAL", "LOCKED", "WEIGHT", "NAMEID", "ENCHANT", "RM_CLASS_TYPE", "RM_FABER_STAT_TYPE", "PRICE", "RESALE_FLAG", "PREREQUISIT_VALID", "WORNED" };
152 const uint CItemSlot::DataBitSize [NbItemPropId] =
153 { 32, 10, 10, 3, 32, 32, 10, 16, 32, 10, 3, 5, 32, 2, 1, 1 };