#177139 - Azenris - Sat Dec 17, 2011 8:55 pm
I'm not sure I'm even asking the right question, but here goes.
Basically I have a bunch of items, they are binaries added to the .nds file. I have different items deriving from a base class CItem.
CItemExpGain : CItem
CItemPotion : CItem
etcetc
This is the code that registers an item - basically puts it into a list.
I register at init with
Not actual code, but for example I did
It doesn't know whether thats an exp item or potion. I think from what I got at http://www.parashift.com/c++-faq-lite/virtual-functions.html a vtable ptr is added to the class. But I'm creating my binaries outside the program.
Can I achieve what I want or should I scrap this whole process. OR am I confused completely at what I'm doing :D
_________________
My Homebrew Games
Basically I have a bunch of items, they are binaries added to the .nds file. I have different items deriving from a base class CItem.
CItemExpGain : CItem
CItemPotion : CItem
etcetc
This is the code that registers an item - basically puts it into a list.
Code: |
void CItemManager::Register(const void *pItem)
{ CItem *pItemPtr = pItem; int itemID = pItemPtr->GetID(); int listSize = m_items.size(); if (itemID >= listSize) { m_items.resize(itemID + 1); for (int i = listSize; i < (itemID + 1); ++i) m_items[i] = NULL; } ASSERT(m_items[itemID] == NULL, "itemID already registered."); m_items[itemID] = pItemPtr; } |
I register at init with
Code: |
Register(Potion_item);
Register(BigPotion_item); Register(UltraPotion_item); |
Not actual code, but for example I did
Code: |
m_items[0]->Use(); |
It doesn't know whether thats an exp item or potion. I think from what I got at http://www.parashift.com/c++-faq-lite/virtual-functions.html a vtable ptr is added to the class. But I'm creating my binaries outside the program.
Can I achieve what I want or should I scrap this whole process. OR am I confused completely at what I'm doing :D
_________________
My Homebrew Games