Actually I use that code in multiple places and it hasn't caused an issue yet what code would you like to see? Where the class is implemented how it is implemented or what?
Code:
Item::Item()
{
Use_SND = NULL;
Miss_SND = NULL;
Swing_SND = NULL;
Hit_SND = NULL;
ItemName = NULL;
PIC = NULL;
Save_String = NULL;
ID = 0;
size = 1;
min_damage = 1;
max_damage = 3;
min_heal = 0;
max_heal = 0;
min_restore = 0;
max_restore = 0;
armor = 0;
type = 0;
Consumable = false;
level = 0;
for(int aq = 0;aq<5;aq++)
{
enhancements[aq] = 0;
}
}
edit: Might as well use the allegro destructor though I suppose so I will do that if for no other reason other than thats why they wrote it.
Code:
void Monster::SetPicPath(char *path,RGB *pal)
{
if(PIC)destroy_bitmap(PIC);
PIC = load_bitmap(path,pal);
}
BITMAP* Monster::GetPic()
{
return PIC;
}
That works perfectly believe it or not it had the delete call as well just changed that - went looking way back to the tile class and had noticed I used the actual function call for it so yes it was wrong and is now fixed - although wasn't generating the error I am tracking - was probably a memory leak.
Code:
if(p < mymap->GetNumMonster())
{
tmpMonster = mymap->GetMonster(p);
if(tmpMonster != NULL && tmpMonster->GetX() - nm == n && tmpMonster->GetY() - mm == m && tmpMonster->GetX() >= nm && tmpMonster->GetX() <= nm+28 && tmpMonster->GetY() >= mm && tmpMonster->GetY() <= mm+21)
{
if(!tmpMonster->IsDead())
{
masked_blit(tmpMonster->GetPic(),BUFFER,(tmpMonster->GetDir()*3+tmpMonster->GetStep())*charx,0,48+(tmpMonster->GetX() - nm)*32-(charx/2)+16,48+(tmpMonster->GetY() - mm)*32-(chary/2),charx,chary);
}else
if(GetTickCount()-tmpMonster->GetTimeOfDeath() < 1000)
{
masked_blit(tmpMonster->GetPic(),BUFFER,((GetTickCount()-tmpMonster->GetTimeOfDeath())/250)*charx,50,48+(tmpMonster->GetX() - nm)*32-(charx/2)+16,48+(tmpMonster->GetY() - mm)*32-(chary/2),charx,chary);
}
}
}
That works it is directly from a display routine.
Code:
void Run_Inventory()
{
Item TempItem;
while(key[KEY_I]);
while(!key[KEY_I])
{
blit(LAYOUT,BUFFER,0,0,0,0,scrx,scry); //toss the backdrop up.
masked_blit(INVENTORY,BUFFER,0,0,0,0,scrx,scry); //toss the grids.
//DRAW INVENTORY
for(int y = 0;y < 7;y++)
{
for(int x = 0;x< 16;x++)
{
TempItem = player->Inventory_Check(x,y); //returns an Item to us not a pointer just Item is this a problem?
if(TempItem.GetID()!=0 && TempItem.GetID()!=-1) //This checks fine I have saved the ID to a file to check that data.
switch(TempItem.GetSize())
{
case 1:
masked_blit(ItemList[TempItem.GetID()]->GetPic(),BUFFER,0,0,434+(33*x),41+(33*y),32,32); //This crashes as well.
break;
case 2:
masked_blit(ItemList[TempItem.GetID()]->GetPic(),BUFFER,0,0,434+(33*x),41+(33*y),64,32);
break;
case 3:
masked_blit(ItemList[TempItem.GetID()]->GetPic(),BUFFER,0,0,434+(33*x),41+(33*y),32,96);
break;
case 4:
masked_blit(ItemList[TempItem.GetID()]->GetPic(),BUFFER,0,0,434+(33*x),41+(33*y),64,64);
break;
case 6:
masked_blit(ItemList[TempItem.GetID()]->GetPic(),BUFFER,0,0,434+(33*x),41+(33*y),64,96);
break;
}
}
}
//END DRAW INVENTORY
blit(BUFFER,screen,0,0,0,0,scrx,scry);
}
while(key[KEY_I]);
}