Sacarus
Member
- Joined
- Mar 15, 2016
- Messages
- 52
- Reaction score
- 7
I've been trying to create more item attributes. I had success until the attribute n31 in enums.h. Above 31, it just doesn't keep the information after close the server. Until 31, is totally normal, they all have the same implementation. If I keep server running, it's working, but is useless.
I did some adaptation taking const.h PlayerFlags as base, because enum itemAttrTypes : uint32_t doesnt fit more than 31 elements, as i understood. So i changed to uint64_t and made a cast after elements number 31. It doesnt give me red lines, any error or console warnings.
Im just trying to know how to keep values in those new attributes. I did the propStream.read and propStream.write in item.cpp also, and some other stuff that I think it's not necessary to show.
I did some adaptation taking const.h PlayerFlags as base, because enum itemAttrTypes : uint32_t doesnt fit more than 31 elements, as i understood. So i changed to uint64_t and made a cast after elements number 31. It doesnt give me red lines, any error or console warnings.
C++:
//enums.h
enum itemAttrTypes : uint64_t {
ITEM_ATTRIBUTE_NONE,
ITEM_ATTRIBUTE_ACTIONID = 1 << 0,
ITEM_ATTRIBUTE_UNIQUEID = 1 << 1,
//...
ITEM_ATTRIBUTE_WATER = static_cast<uint64_t>(1) << 31,
ITEM_ATTRIBUTE_FIRE = static_cast<uint64_t>(1) << 32,
ITEM_ATTRIBUTE_EARTH = static_cast<uint64_t>(1) << 33
//...
Im just trying to know how to keep values in those new attributes. I did the propStream.read and propStream.write in item.cpp also, and some other stuff that I think it's not necessary to show.
C++:
//item.cpp
if (hasAttribute(ITEM_ATTRIBUTE_WATER)) {
propWriteStream.write<uint8_t>(ATTR_WATER);
propWriteStream.write<uint32_t>(getIntAttr(ITEM_ATTRIBUTE_WATER));
}
//...
case ATTR_WATER: {
int32_t water;
if (!propStream.read<int32_t>(water)) {
return ATTR_READ_ERROR;
}
setIntAttr(ITEM_ATTRIBUTE_WATER, water);
break;
}
//...