coding question

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

coding question

Post by Ememjr » Sun Mar 17, 2019 12:11 pm

i want to create a vector of items i am using the very common one

Code: Select all

vector<Item*>* items
what i do not know is how to add a single item to the list (because i want to use the same loot code and it uses a vector)
when i know what the item is and it is here as master_item

Code: Select all

master_item = master_item_list.GetItem(item_harvested);
and it will be used here

Code: Select all

void Client::Loot(int32 total_coins, vector<Item*>* items, Entity* entity, bool collection){
	if(!entity && !collection){
		CloseLoot();
			return;
	}

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: coding question

Post by Jabantiz » Sun Mar 17, 2019 4:32 pm

So you just want to add an item to the vector? That is just

Code: Select all

 items.push_back(item_to_add)
master_item_list will just get a pointer to an item in the master list, this item should not be modified at all or given to the player. If you need an item to be modified or given to the player it would be

Code: Select all

Item* new_item = new Item(master_item_list.Get(ItemID));

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests