From: Jaka K. <lyn...@us...> - 2012-12-27 18:30:12
|
gemrb: Infinity Engine emulator The branch master has been updated via 789d00155d294fe0228c4ecb18e58458372b0a98 (commit) Summary of changes: gemrb/core/Map.cpp | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) from 6efbc00aa7a8c80087105535f783e3ef086e3cb8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=789d00155d294fe0228c4ecb18e58458372b0a98 commit 789d00155d294fe0228c4ecb18e58458372b0a98 Author: Jaka Kranjc <lyn...@us...> Date: Thu Dec 27 19:25:40 2012 +0100 MoveVisibleGroundPiles: take all possible merges into account now ctrl-w is really awesome, everything gets merged, with single items first in the list and all repeating ones later diff --git a/gemrb/core/Map.cpp b/gemrb/core/Map.cpp index ae58cf0..a2a96db 100644 --- a/gemrb/core/Map.cpp +++ b/gemrb/core/Map.cpp @@ -3339,13 +3339,30 @@ void Map::MoveVisibleGroundPiles(const Point &Pos) unsigned int i=c->inventory.GetSlotCount(); while (i--) { CREItem *item = c->RemoveItem(i, 0); - int slot = othercontainer->inventory.FindItem(item->ItemResRef, 0); - if (slot != -1) { + int count = othercontainer->inventory.CountItems(item->ItemResRef, 0); + if (count == 0) { + othercontainer->AddItem(item); + continue; + } + // ensure slots are stacked fully before adding new ones + int skipped = count; + while (count) { + int slot = othercontainer->inventory.FindItem(item->ItemResRef, 0, --count); + CREItem *otheritem = othercontainer->inventory.GetSlotItem(slot); + if (otheritem->Usages[0] == otheritem->MaxStackAmount) { + // already full (or nonstackable), nothing to do here + skipped--; + continue; + } if (othercontainer->inventory.MergeItems(slot, item) != ASI_SUCCESS) { // the merge either failed (add whole) or went over the limit (add remainder) othercontainer->AddItem(item); } - } else { + skipped = 1; // just in case we would be eligible for the safety net below + break; + } + // all found slots were already unsuitable, so just dump the item to a new one + if (!skipped) { othercontainer->AddItem(item); } } @@ -3360,7 +3377,6 @@ void Map::MoveVisibleGroundPiles(const Point &Pos) } // sort by removing all items that have copies and readding them at the end - i = othercontainer->inventory.GetSlotCount(); while (i--) { CREItem *item = othercontainer->inventory.GetSlotItem(i); int count = othercontainer->inventory.CountItems(item->ItemResRef, 0); ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |