Sziasztok!
Hogyan kellene módosítani, hogy ne csak az 1-2 leltárban legyen jó?
bool CExchange::CheckSpace()
{
static CGrid s_grid1(9, 5); // oldal 1
static CGrid s_grid2(9, 5); // oldal 2
static CGrid s_grid3(9, 5); // oldal 3
static CGrid s_grid4(9, 5); // oldal 4
s_grid1.Clear();
s_grid2.Clear();
s_grid3.Clear();
s_grid4.Clear();
LPCHARACTER victim = GetCompany()->GetOwner();
LPITEM item;
int i;
for (i = 0; i < INVENTORY_MAX_NUM / 4; ++i)
{
if (!(item = victim->GetInventoryItem(i)))
continue;
s_grid1.Put(i, 1, item->GetSize());
}
for (i = INVENTORY_MAX_NUM / 4; i < INVENTORY_MAX_NUM; ++i)
{
if (!(item = victim->GetInventoryItem(i)))
continue;
s_grid2.Put(i - INVENTORY_MAX_NUM / 4, 1, item->GetSize());
}
for (i = INVENTORY_MAX_NUM / 4; i < INVENTORY_MAX_NUM; ++i)
{
if (!(item = victim->GetInventoryItem(i)))
continue;
s_grid3.Put(i - INVENTORY_MAX_NUM / 4, 1, item->GetSize());
}
for (i = INVENTORY_MAX_NUM / 4; i < INVENTORY_MAX_NUM; ++i)
{
if (!(item = victim->GetInventoryItem(i)))
continue;
s_grid4.Put(i - INVENTORY_MAX_NUM / 4, 1, item->GetSize());
}
Ha tele van az 1-2 leltár akkor nincs szabad hely, hiába üres a 3-4.
Előre is köszi.
Érdekes, nálam ilyen hiba nem jelentkezik 4. Leltárnál. Esetleg sysser? ???
Nem ártana a fv végét is bővíteni, amit gondolom kihagytál:
else
{
int iPos = s_grid1.FindBlank(1, item->GetSize());
if (iPos >= 0)
{
s_grid1.Put(iPos, 1, item->GetSize());
}
else
{
iPos = s_grid2.FindBlank(1, item->GetSize());
if (iPos >= 0)
{
s_grid2.Put(iPos, 1, item->GetSize());
}
else
{
return false;
}
}
}
Köszi.