ShadowProwl
New Member
I added boss reward chest to TFS 1.5 following
When reward bags inside the reward chest are more than 99 and the player logout, reward bags get inside each other and can't be opened. How to allow 100+ reward bags without the 99 max limit?
I think it's in the iologindata.cpp part
Reward System [remake of #1628] by cezarguimaraes · Pull Request #1641 · otland/forgottenserver
Remake of #1628 Reasoning After seeing a few reward systems on OTLand try and fail to replicate the original one, I decided to give it a try myself. Some images of the result: How I did it...
github.com
I think it's in the iologindata.cpp part
C++:
//load reward chest items
itemMap.clear();
query.str(std::string());
query << "SELECT `pid`, `sid`, `itemtype`, `count`, `attributes` FROM `player_rewards` WHERE `player_id` = " << player->getGUID() << " ORDER BY `sid` DESC";
if ((result = db->storeQuery(query.str()))) {
loadItems(itemMap, result);
//first loop handles the reward containers to retrieve its date attribute
//for (ItemMap::iterator it = itemMap.begin(), end = itemMap.end(); it != end; ++it) {
for (auto& it : itemMap) {
const std::pair<Item*, int32_t>& pair = it.second;
Item* item = pair.first;
int32_t pid = pair.second;
if (pid >= 0 && pid < 100) {
Reward* reward = player->getReward(item->getIntAttr(ITEM_ATTRIBUTE_DATE), true);
if (reward) {
it.second = std::pair<Item*, int32_t>(reward->getItem(), pid); //update the map with the special reward container
}
} else {
break;
}
}
//second loop (this time a reverse one) to insert the items in the correct order
//for (ItemMap::const_reverse_iterator it = itemMap.rbegin(), end = itemMap.rend(); it != end; ++it) {
for (const auto& it : boost::adaptors::reverse(itemMap)) {
const std::pair<Item*, int32_t>& pair = it.second;
Item* item = pair.first;
int32_t pid = pair.second;
if (pid >= 0 && pid < 100) {
break;
}
ItemMap::const_iterator it2 = itemMap.find(pid);
if (it2 == itemMap.end()) {
continue;
}
Container* container = it2->second.first->getContainer();
if (container) {
container->internalAddThing(item);
}
}
}
Last edited: