Espcevan

Member
I've been working on this project off and on for a little bit, and came across an issue.
When trying to fill BOD's that take stacked items, It first started to delete the stack and only count as 1. I since then was able to get it to take the amount, and record it to the BOD. Every so often I go to put one ingot in and it won't delete it but counts it. I am probably doing it the hard way with the code I have, so I thought I would get some suggestions and help where its needed.

This is in SmallBod.cs

Code:
if ( (Item)o is BaseIngot )
{
	if (((Item)o) == null)
	{
		return;
	}
	if (((Item)o).Amount == this.m_AmountMax)
	{
		((Item)o).Delete();
		this.m_AmountCur = ((Item)o).Amount;

		from.SendLocalizedMessage(1045170); // The item has been combined with the deed.

		from.SendGump(new SmallBODGump(from, this));

		if (this.m_AmountCur < this.m_AmountMax)
			this.BeginCombine(from);
	}
	else
	{
		if (((Item)o).Amount == 1)
		{
			((Item)o).Delete();
			this.AmountCur += ((Item)o).Amount;
		}
		else if ((this.m_AmountMax - this.m_AmountCur) <= ((Item)o).Amount)
		{
			((Item)o).Amount -= (this.m_AmountMax - this.m_AmountCur);
			this.m_AmountCur += (this.m_AmountMax - this.m_AmountCur);
		}
		else
		{
			--((Item)o).Amount;
			++this.AmountCur;
		}
		from.SendLocalizedMessage(1045170); // The item has been combined with the deed.

		from.SendGump(new SmallBODGump(from, this));

		if (this.m_AmountCur < this.m_AmountMax)
			this.BeginCombine(from);
	}
}
else
{
	((Item)o).Delete();
	++this.AmountCur;

	from.SendLocalizedMessage(1045170); // The item has been combined with the deed.

	from.SendGump(new SmallBODGump(from, this));

	if (this.m_AmountCur < this.m_AmountMax)
		this.BeginCombine(from);
}

I was thinking just now
After
if(this.m_AmountCur<this.m_AmountMax)
Maybe put something like...
Code:
     if(this.m_AmountCur>this.m_AmountMax)
     {
         this.m_AmountCur = this.m_AmountMax
     }
Just to make sure it never goes over...
What do you think I should do to the code to make it work smoother?
 
For this part:

  • if (((Item)o).Amount == this.m_AmountMax)
  • {
  • ((Item)o).Delete();
this.m_AmountCur = ((Item)o).Amount;

I think should be something like:

Code:
if (((Item)o).Amount > 1)
{
     if ( (this.m_AmountCur) + (((Item)o).Amount) > this.m_AmountMax)
     {
         this.m_AmountCur = this.m_AmountMax;
     }
     else
     {
         this.m_AmountCur += ((Item)o).Amount;
     }
     ((Item)o).Delete();
}
else
{
     this.m_AmountCur++
     ((Item)o).Delete();
}

Just did this real quick but I think thats right....hope it helps.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back