1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2018 Winch Gate Property Limited
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.
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/>.
20 #include "inventories.h"
21 #include "nel/misc/string_conversion.h"
24 using namespace NLMISC
;
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
= "";
68 else if (inv
== equipment
)
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)
83 if (str
== "pack_animal1")
85 else if (str
== "pack_animal2")
87 else if (str
== "pack_animal3")
89 else if (str
== "pack_animal4")
91 else if (str
== "pack_animal5")
93 else if (str
== "pack_animal6")
95 else if (str
== "pack_animal7")
103 // String for inventories that are not using CInventoryUpdater
104 const char *DatabaseStringFromEInventory
[NUM_ALL_INVENTORY
] =
109 "EQUIP", // equipment
122 // "", // exchange_proposition
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
] =
141 const uint
CInventoryCategoryForGuild::InventoryNbSlots
[CInventoryCategoryForGuild::NbInventoryIds
] =
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 };