From 45bca98b792f8ced1a57ef8c5beed2a90a79d47f Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 30 Nov 2015 08:47:07 -0500 Subject: switched to 100% new/delete --- src/inventory.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/inventory.cpp') diff --git a/src/inventory.cpp b/src/inventory.cpp index 45d5bce..cd01c11 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -13,15 +13,38 @@ static Item item[5]= { void itemDraw(Player *p,ITEM_ID id); +char *getItemTexturePath(ITEM_ID id){ + return item[id].textureLoc; +} + +Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl){ + id = i; + type = t; + width = w; + height = h; + maxStackSize = m; + count = 0; + + name = new char[strlen(n)+1]; //(char*)calloc(strlen(n ),sizeof(char)); + textureLoc = new char[strlen(tl)+1]; //(char*)calloc(strlen(tl),sizeof(char)); + + strcpy(name,n); + strcpy(textureLoc,tl); + + tex= new Texturec(1,textureLoc); +} + Inventory::Inventory(unsigned int s){ sel=0; size=s; - inv=(struct item_t *)calloc(size,sizeof(struct item_t)); + inv = new struct item_t[size]; //(struct item_t *)calloc(size,sizeof(struct item_t)); + memset(inv,0,size*sizeof(struct item_t)); tossd=false; } Inventory::~Inventory(void){ - free(item); + delete[] inv; + //free(item); } void Inventory::setSelection(unsigned int s){ @@ -64,8 +87,6 @@ void Inventory::draw(void){ ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel); unsigned int i=0; float y,xoff; - - static int numSlot = 7; static std::vectordfp(numSlot); static std::vectoriray(numSlot); @@ -158,6 +179,7 @@ void Inventory::draw(void){ i++; } }*/ + if(inv[sel].count)itemDraw(player,inv[sel].id); } -- cgit v1.2.3