Jump to content

Fix refine proto 5th item


Istny

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

 

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Angry 2
  • Good 1
  • Love 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

Announcements



×
×
  • Create New...

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.