protected void SetOwnerOf(int obj, int owner)
{
// In Sam & Max this is necessary, or you won't get your stuff back
// from the Lost and Found tent after riding the Cone of Tragedy. But
// it probably applies to all V6+ games. See bugs #493153 and #907113.
// FT disassembly is checked, behavior is correct. [sev]
int arg = (Game.Version >= 6) ? obj : 0;
// WORKAROUND for bug #1917981: Game crash when finishing Indy3 demo.
// Script 94 tries to empty the inventory but does so in a bogus way.
// This causes it to try to remove object 0 from the inventory.
if (owner == 0)
{
ClearOwnerOf(obj);
if (CurrentScript != 0xFF)
{
var ss = _slots[CurrentScript];
if (ss.Where == WhereIsObject.Inventory)
{
if (ss.Number < _resManager.NumInventory && _inventory[ss.Number] == obj)
{
//throw new NotSupportedException("Odd setOwnerOf case #1: Please report to Fingolfin where you encountered this");
PutOwner(obj, 0);
RunInventoryScript(arg);
StopObjectCode();
return;
}
if (ss.Number == obj)
throw new NotSupportedException("Odd setOwnerOf case #2: Please report to Fingolfin where you encountered this");
}
}
}
PutOwner(obj, (byte)owner);
RunInventoryScript(arg);
}