Jump to content
×
×
  • Create New...

Fix refine proto 5th item


Recommended Posts

  • Premium

Fix allow you to use vnum4 in refine_proto

 

Explanation:

By default refine materials are beign loaded until vnumx == 0, but if you assign item to the last socket, material_count will never be assigned. As a result material_count will remain 0, despite 5 material items being set.

Adding simple additional check solves this problem

 

Open db/ClientManagerBoot.cpp

replace

for (int i = 0; i < REFINE_MATERIAL_MAX_NUM; i++)
{
	str_to_number(prt->materials[i].vnum, data[col++]);
	str_to_number(prt->materials[i].count, data[col++]);
	if (prt->materials[i].vnum == 0)
	{
		prt->material_count = i;
		break;
	}
}

 

with

for (int i = 0; i < REFINE_MATERIAL_MAX_NUM; i++)
{
	str_to_number(prt->materials[i].vnum, data[col++]);
	str_to_number(prt->materials[i].count, data[col++]);
	if (prt->materials[i].vnum == 0)
	{
		prt->material_count = i;
		break;
	} 
	else if (i+1 == REFINE_MATERIAL_MAX_NUM)
	{
		prt->material_count = REFINE_MATERIAL_MAX_NUM;
		break;
	}
}

 

final result

   spacer.png

 

 

  • Love 2
  • Good 1
  • Angry 2
Link to comment
Share on other sites

  • Premium

The answer below is correct. I need some sleep.

Edited by Syreldar

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium
		BYTE material_count = 0;
		for (int i = 0; i < REFINE_MATERIAL_MAX_NUM; i++)
		{
			str_to_number(prt->materials[i].vnum, data[col++]);
			str_to_number(prt->materials[i].count, data[col++]);

			if (prt->materials[i].vnum)
				material_count++;
		}

		prt->material_count = material_count;

 

Issue is how they approached counting in the first place. When the loop hits a vnum equal to zero, material count was assigned based on current loop index which means if you had 5 slots occupied you would never hit an empty slot which is why material count would be always zero. By extending the loop you would also need to extend mysql columns which does nothing in this case. 

Edited by Sonitex
Wrong data type :/
  • Good 2
Link to comment
Share on other sites

  • Premium
9 minutes ago, Sonitex said:
		BYTE material_count = 0;
		for (int i = 0; i < REFINE_MATERIAL_MAX_NUM; i++)
		{
			str_to_number(prt->materials[i].vnum, data[col++]);
			str_to_number(prt->materials[i].count, data[col++]);

			if (prt->materials[i].vnum)
				material_count++;
		}

		prt->material_count = material_count;

 

Issue is how they approached counting in the first place. When the loop hits a vnum equal to zero, material count was assigned based on current loop index which means if you had 5 slots occupied you would never hit an empty slot which is why material count would be always zero. By extending the loop you would also need to extend mysql columns which does nothing in this case. 

 

Cleaner, only downside is, if someone for unknow reason will have for example socket3 set to 0 and socket4 to 11 loop in CHARACTER::DoRefine will use value frome socket3 as material vnum which is 0. Summarazing don't do a mess and you are good to go 😀

  • Love 1
Link to comment
Share on other sites

  • Premium
8 minutes ago, Istny said:

 

Cleaner, only downside is, if someone for unknow reason will have for example socket3 set to 0 and socket4 to 11 loop in CHARACTER::DoRefine will use value frome socket3 as material vnum which is 0. Summarazing don't do a mess and you are good to go 😀

 

Yeah but it goes both ways. Before if you set a value for socket0, left socket1 empty and set socket2, 3rd socket would be ignored. But as you said, you need a bit more precision & focus when doing things like that.

Edited by Sonitex
  • Good 1
Link to comment
Share on other sites

		prt->material_count = 0;
		for (int i = 0; i < REFINE_MATERIAL_MAX_NUM; i++)
		{
			str_to_number(prt->materials[i].vnum, data[col++]);
			str_to_number(prt->materials[i].count, data[col++]);
			if (prt->materials[i].vnum != 0)
				prt->material_count++;
		}

 

Edited by meneleos
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.