Page 1 of 1

getting over my head Adorments

Posted: Sun Jun 11, 2017 5:29 pm
by Ememjr
this is for adornments
i have added an code to handle adornments and basically copied and modified how weapon_info,amor_info is in the code , added a table for item_details_adornments, etc etc everything appears to work fine

Code: Select all

int32 WorldDatabase::LoadAdornments()
{
	Query query;
	MYSQL_ROW row;
	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT item_id, duration, item_types,slot_type FROM item_details_adornments");
	int32 total = 0;
	int32 id = 0;

	if (result)
	{
		while (result && (row = mysql_fetch_row(result)))
		{
			id = strtoul(row[0], NULL, 0);
			Item* item = master_item_list.GetItem(id);

			if (item)
			{
				LogWrite(ITEM__DEBUG, 0, "Items", "\tItem Adornment for item_id: %u", id);
				LogWrite(ITEM__DEBUG, 0, "Items", "\ttype: %i, Duration: %i, item_types_: %i, slot_type: %i", ITEM_TYPE_ADORNMENT, atoi(row[1]), atoi(row[2]), atoi(row[3]));
				item->SetItemType(ITEM_TYPE_ADORNMENT);
				item->adornment_info->duration = atof(row[1]);
				item->adornment_info->item_types = atoi(row[2]);
				item->adornment_info->slot_type = atoi(row[3]);
				LogWrite(ITEM__DEBUG, 0, "Items", "\ttype: %i, Duration: %i, item_types_: %i, slot_type: %i",item->generic_info.item_type, item->adornment_info->duration, item->adornment_info->item_types, item->adornment_info->slot_type);
				total++;
			}
			else
				LogWrite(ITEM__ERROR, 0, "Items", "Error loading `item_details_shield`, ID: %i", id);
		}
	}
	return total;
}
the debug lines are showing the correct entries 3 are are the same and 3 one i beleive is pulling from the item after its updated
but here in items.cpp, generic_info.item_type is always returning 0 for the item_type

Code: Select all

if(!loot_item){
		
		packet->setSubstructDataByName("header", "item_type", generic_info.item_type);
	//	LogWrite(WORLD__ERROR, 0, "World", "Robert checking item type");
		switch(generic_info.item_type){
			case ITEM_TYPE_WEAPON:{
				if(weapon_info){
i am attaching itemsdb.cpp, worlddatabase.h,items.h, and items.cpp , maybe someone can help figure what i am doing wrong

Re: getting over my head Adorments

Posted: Sun Jun 11, 2017 6:25 pm
by Jabantiz
Did you update "void Item::SetItem(Item* old_item)" with the new adornment code?

Normally I would drop your source in to my server but I am in the middle of some massive changes and that isn't an option right now.

Re: getting over my head Adorments

Posted: Mon Jun 12, 2017 5:19 am
by Ememjr
yes originally i added it right after shields which was a mistake, would cause a crash so i moved it lower in the list

Code: Select all

void Item::SetItem(Item* old_item){
	if(old_item->GetItemScript())
		SetItemScript(old_item->GetItemScript());
	name = old_item->name;
	lowername = old_item->lowername;
	description = old_item->description;
	memcpy(&generic_info, &old_item->generic_info, sizeof(Generic_Info));
	weapon_info = 0;
	ranged_info = 0;
	adornment_info = 0;
	bag_info = 0;
	food_info = 0;
	bauble_info = 0;
	thrown_info = 0;
	skill_info = 0;
	recipebook_info = 0;
	armor_info = 0;
	book_info = 0;
	houseitem_info = 0;
	housecontainer_info = 0;
	stack_count = old_item->stack_count;
	generic_info.skill_req1 = old_item->generic_info.skill_req1;
	generic_info.skill_req2 = old_item->generic_info.skill_req2;
	memcpy(&details, &old_item->details, sizeof(ItemCore));
	weapon_type = old_item->GetWeaponType();
	switch(old_item->generic_info.item_type){
		case ITEM_TYPE_WEAPON:{
			weapon_info = new Weapon_Info;
			memcpy(weapon_info, old_item->weapon_info, sizeof(Weapon_Info));
			break;
		}
		case ITEM_TYPE_RANGED:{
			ranged_info = new Ranged_Info;
			memcpy(ranged_info, old_item->ranged_info, sizeof(Ranged_Info));
			break;
		}
		case ITEM_TYPE_SHIELD:		
		case ITEM_TYPE_ARMOR:{
			armor_info = new Armor_Info;
			memcpy(armor_info, old_item->armor_info, sizeof(Armor_Info));
			break;
		}
		case ITEM_TYPE_BAG:{
			bag_info = new Bag_Info;
			memcpy(bag_info, old_item->bag_info, sizeof(Bag_Info));
			break;
		}
		case ITEM_TYPE_FOOD:{
			food_info = new Food_Info;
			memcpy(food_info, old_item->food_info, sizeof(Food_Info));
			break;
		}
		case ITEM_TYPE_BAUBLE:{
			bauble_info = new Bauble_Info;
			memcpy(bauble_info, old_item->bauble_info, sizeof(Bauble_Info));
			break;
		}
	    case ITEM_TYPE_SKILL:{
			skill_info = new Skill_Info;
			memcpy(skill_info, old_item->skill_info, sizeof(Skill_Info));
			break;
		}
		case ITEM_TYPE_THROWN:{
			thrown_info = new Thrown_Info;
			memcpy(thrown_info, old_item->thrown_info, sizeof(Thrown_Info));
			break;
		}
		case ITEM_TYPE_BOOK:{
			book_info = new Book_Info;
			book_info->language = old_item->book_info->language;
			book_info->author.data = old_item->book_info->author.data;
			book_info->author.size = old_item->book_info->author.size;
			book_info->title.data = old_item->book_info->title.data;
			book_info->title.size = old_item->book_info->title.size;
			break;
		}
		case ITEM_TYPE_HOUSE:{
			houseitem_info = new HouseItem_Info;
			memcpy(houseitem_info, old_item->houseitem_info, sizeof(HouseItem_Info));
			break;
		}
		case ITEM_TYPE_RECIPE:{
			// Recipe Book
			recipebook_info = new RecipeBook_Info;
			if (old_item->recipebook_info) {
				recipebook_info->uses = old_item->recipebook_info->uses;
				for (int32 i = 0; i < old_item->recipebook_info->recipes.size(); i++)
					recipebook_info->recipes.push_back(old_item->recipebook_info->recipes.at(i));
			}
			break;
		}
		case ITEM_TYPE_ADORNMENT:{
			adornment_info = new Adornment_Info;
			memcpy(adornment_info, old_item->adornment_info, sizeof(Adornment_Info));
			break;
		}
		case ITEM_TYPE_HOUSE_CONTAINER:{
			// House Containers
			housecontainer_info = new HouseContainer_Info;
			if (old_item->housecontainer_info) {
				housecontainer_info->broker_commission = old_item->housecontainer_info->broker_commission;
				housecontainer_info->fence_commission = old_item->housecontainer_info->fence_commission;
				housecontainer_info->allowed_types = old_item->housecontainer_info->allowed_types;
				housecontainer_info->num_slots = old_item->housecontainer_info->num_slots;
			}
			break;
		}
	}
	creator = old_item->creator;
	adornment = old_item->adornment;
	item_stats.clear();
	for(int32 i=0;i<old_item->item_stats.size();i++){
		ItemStat* stat = old_item->item_stats[i];
		if(stat){
			ItemStat* stat2 = new ItemStat;
			stat2->stat_name = stat->stat_name;
			stat2->stat_type = stat->stat_type;
			stat2->stat_subtype = stat->stat_subtype;
			stat2->value = stat->value;
			stat2->stat_type_combined = stat->stat_type_combined;
			item_stats.push_back(stat2);
		}
	}
	item_string_stats.clear();
	for(int32 i=0;i<old_item->item_string_stats.size();i++){
		ItemStatString* stat = old_item->item_string_stats[i];
		if(stat){
			ItemStatString* stat2 = new ItemStatString;
			stat2->stat_string.data = stat->stat_string.data;
			stat2->stat_string.size = stat->stat_string.size;
			item_string_stats.push_back(stat2);
		}
	}
	item_level_overrides.clear();
	for(int32 i=0;i<old_item->item_level_overrides.size();i++){
		ItemLevelOverride* item_override = old_item->item_level_overrides[i];
		if(item_override){
			ItemLevelOverride* item_override2 = new ItemLevelOverride;
			memcpy(item_override2, item_override, sizeof(ItemLevelOverride));
			item_level_overrides.push_back(item_override2);
		}
	}
	item_effects.clear();
	for(int32 i=0;i<old_item->item_effects.size();i++){
		ItemEffect* effect = old_item->item_effects[i];
		if(effect){
			ItemEffect* effect_2 = new ItemEffect;
			effect_2->effect = effect->effect;
			effect_2->percentage = effect->percentage;
			effect_2->subbulletflag = effect->subbulletflag;
			item_effects.push_back(effect_2);
		}
	}
	slot_data.clear();
	slot_data = old_item->slot_data;
	spell_id = old_item->spell_id;
	spell_tier = old_item->spell_tier;
}

Re: getting over my head Adorments

Posted: Mon Jun 12, 2017 5:26 am
by Ememjr
UPDATE I fixed it moving it down in the list corrected the issue apparently case ITEM_TYPE_ADORNMENT: doesnt like being right after case ITEM_TYPE_SHIELD:
thanks

Re: getting over my head Adorments

Posted: Mon Jun 12, 2017 5:30 am
by Ememjr
adorn.JPG
ignore the 2 adorn slots on the adornment that was a test i hardcoded in so all my items have those 2 adorn slots displaying( i will remove that)

now i just need to get the DB updated with correct item types and slot types

and now back to the rest of the itemstructs