Page 1 of 1

fixing tradeskills

Posted: Sun Mar 03, 2019 7:31 am
by Ememjr
ok here is an issue in the code i cam e accross and not sure how to rewrite it
f

Code: Select all

or (itr = spells.begin(); itr != spells.end(); itr++) {
            size++;

            if (size > 6) {
                // only 6 slots for skills on the ui
                break;
            }
            char str[20];
            char temp[20];
            strcpy(str, "skill");
            itoa(size, temp, 10);
            strcat(str, temp);
            strcat(str, "_id");
            packet->setDataByName(str, *itr);
    }
the str at the packet line is skill1_id, skill2_id,skill3_id etc
but it is supposed to be writing the *itr value to skill_id at the particular index
here is the struct line it is suppose to write to <Data ElementName="skill_id" Type="int32" Size="6"/>

Re: fixing tradeskills

Posted: Sun Mar 03, 2019 4:53 pm
by Jabantiz

Code: Select all

char str[20];
char temp[20];
strcpy(str, "skill");
itoa(size, temp, 10);
strcat(str, temp);
strcat(str, "_id");
This code generates the "skill1_id", "skill2_id" and so on and then uses it in the packet->setDataByName()

Re: fixing tradeskills

Posted: Sun Mar 03, 2019 6:44 pm
by Ememjr
thats the problem

it should not be skill1_id, skill2_id

it should be skill_id, with the proper index of 1 -6 or 0-5?

Re: fixing tradeskills

Posted: Sun Mar 03, 2019 7:39 pm
by Jabantiz
Ah then the stuct was probably changed at some point and not the code. In that case it is easy.

Code: Select all

packet->setDataByName("skill_id", *itr, index);
So that loops would be something like this

Code: Select all

size = 0;
for (itr = spells.begin(); itr != spells.end(); itr++) {
            size++;

            if (size >= 6) {
                // only 6 slots for skills on the ui
                break;
            }
            
            packet->setDataByName("skill_id", *itr, index);
    }
    
In the old loop size started at 1, it needs to start at 0 now as it is being used as an index, should probably change the name to be more clear about that as well.

Re: fixing tradeskills

Posted: Thu Mar 07, 2019 11:45 am
by Ememjr
wow i finally tracked the issue down on why the abilities were not showing up on the tradeskill bar

in this section of code

Code: Select all

packet->setDataByName("product_progress_needed", 1000);

	rp = recipe->products[4];
	item = master_item_list.GetItem(rp->product_id);

	packet->setDataByName("product_item_name",  item->name.c_str());
	packet->setDataByName("product_item_icon", item->details.icon);

	if(client->GetVersion() < 860)
		packet->setItemByName("product_item", item, client->GetPlayer(), 0, -1);
	else if (client->GetVersion() < 1193)
		packet->setItemByName("product_item", item, client->GetPlayer());
	else
		packet->setItemByName("product_item", item, client->GetPlayer(), 0, 2);

	//packet->setItemByName("product_item", item, client->GetPlayer());

	if (rp->byproduct_id > 0) {
		item = 0;
		item = master_item_list.GetItem(rp->byproduct_id);
		if (item) {
			packet->setDataByName("product_byproduct_name", item->name.c_str());
			packet->setDataByName("product_byproduct_icon", item->details.icon);
		}
	}
the comment line was not commented which basically nullified what was happening in the if else above it

so now the abilites will show up still working on the order right now