update new many items from 7.81. Also fix issue with runes charges to not stack and not throw client debug.

This commit is contained in:
ErikasKontenis 2019-11-16 00:30:27 +02:00
parent 5640c1497d
commit 6a0e161bef
6 changed files with 1553 additions and 102 deletions

View File

@ -52,7 +52,7 @@ timeBetweenExActions = 1000
-- Map
-- NOTE: set mapName WITHOUT .otbm at the end
mapName = "map"
mapName = "mymap"
mapAuthor = "CipSoft"
-- MySQL

File diff suppressed because it is too large Load Diff

View File

@ -326,7 +326,7 @@ ReturnValue Container::queryMaxCount(int32_t index, const Thing& thing, uint32_t
}
} else {
const Item* destItem = getItemByIndex(index);
if (item->equals(destItem) && destItem->getItemCount() < 100) {
if (item->equals(destItem) && !destItem->isRune() && destItem->getItemCount() < 100) {
uint32_t remainder = 100 - destItem->getItemCount();
if (queryAdd(index, *item, remainder, flags) == RETURNVALUE_NOERROR) {
n = remainder;

View File

@ -1018,11 +1018,11 @@ void Game::playerMoveItem(Player* player, const Position& fromPos,
}
}
ReturnValue ret = internalMoveItem(fromCylinder, toCylinder, toIndex, item, count, nullptr, 0, player);
ReturnValue ret = internalMoveItem(fromCylinder, toCylinder, toIndex, item, item->isRune() ? item->getItemCount() : count, nullptr, 0, player);
if (ret != RETURNVALUE_NOERROR) {
player->sendCancelMessage(ret);
} else {
g_events->eventPlayerOnItemMoved(player, item, count, fromPos, toPos, fromCylinder, toCylinder);
g_events->eventPlayerOnItemMoved(player, item, item->isRune() ? item->getItemCount() : count, fromPos, toPos, fromCylinder, toCylinder);
}
}
@ -1096,8 +1096,14 @@ ReturnValue Game::internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder,
uint32_t m;
if (item->isStackable()) {
if (item->isRune()) {
m = std::min<uint32_t>(item->getItemCount(), maxQueryCount);
}
else {
m = std::min<uint32_t>(count, maxQueryCount);
} else {
}
}
else {
m = maxQueryCount;
}
@ -1133,11 +1139,12 @@ ReturnValue Game::internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder,
if (item->isStackable()) {
uint32_t n;
if (item->equals(toItem)) {
if (!item->isRune() && item->equals(toItem)) {
n = std::min<uint32_t>(100 - toItem->getItemCount(), m);
toCylinder->updateThing(toItem, toItem->getID(), toItem->getItemCount() + n);
updateItem = toItem;
} else {
}
else {
n = 0;
}
@ -1232,7 +1239,7 @@ ReturnValue Game::internalAddItem(Cylinder* toCylinder, Item* item, int32_t inde
return RETURNVALUE_NOERROR;
}
if (item->isStackable() && item->equals(toItem)) {
if (item->isStackable() && !item->isRune() && item->equals(toItem)) {
uint32_t m = std::min<uint32_t>(item->getItemCount(), maxQueryCount);
uint32_t n = std::min<uint32_t>(100 - toItem->getItemCount(), m);
@ -1247,7 +1254,8 @@ ReturnValue Game::internalAddItem(Cylinder* toCylinder, Item* item, int32_t inde
ReleaseItem(remainderItem);
remainderCount = count;
}
} else {
}
else {
toCylinder->addThing(index, item);
int32_t itemIndex = toCylinder->getThingIndex(item);
@ -1255,7 +1263,8 @@ ReturnValue Game::internalAddItem(Cylinder* toCylinder, Item* item, int32_t inde
toCylinder->postAddNotification(item, nullptr, itemIndex);
}
}
} else {
}
else {
//fully merged with toItem, item will be destroyed
item->onRemoved();
ReleaseItem(item);
@ -1265,7 +1274,8 @@ ReturnValue Game::internalAddItem(Cylinder* toCylinder, Item* item, int32_t inde
toCylinder->postAddNotification(toItem, nullptr, itemIndex);
}
}
} else {
}
else {
toCylinder->addThing(index, item);
int32_t itemIndex = toCylinder->getThingIndex(item);

View File

@ -711,7 +711,9 @@ class Item : virtual public Thing
bool canDistUse() const {
return items[id].distUse;
}
bool isRune() const {
return items[id].isRune();
}
const std::string& getName() const {
if (hasAttribute(ITEM_ATTRIBUTE_NAME)) {
return getStrAttr(ITEM_ATTRIBUTE_NAME);

View File

@ -2131,7 +2131,7 @@ ReturnValue Player::queryAdd(int32_t index, const Thing& thing, uint32_t count,
if (ret == RETURNVALUE_NOERROR || ret == RETURNVALUE_NOTENOUGHROOM) {
//need an exchange with source?
const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index));
if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) {
if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->isRune() || inventoryItem->getID() != item->getID())) {
return RETURNVALUE_NEEDEXCHANGE;
}
@ -2200,15 +2200,18 @@ ReturnValue Player::queryMaxCount(int32_t index, const Thing& thing, uint32_t co
}
if (destItem) {
if (destItem->isStackable() && item->equals(destItem) && destItem->getItemCount() < 100) {
if (!destItem->isRune() && destItem->isStackable() && item->equals(destItem) && destItem->getItemCount() < 100) {
maxQueryCount = 100 - destItem->getItemCount();
} else {
}
else {
maxQueryCount = 0;
}
} else if (queryAdd(index, *item, count, flags) == RETURNVALUE_NOERROR) { //empty slot
}
else if (queryAdd(index, *item, count, flags) == RETURNVALUE_NOERROR) { //empty slot
if (item->isStackable()) {
maxQueryCount = 100;
} else {
}
else {
maxQueryCount = 1;
}