Jump to content

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 3
Link to comment
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/
Share on other sites

  • Honorable Member

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
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-133941
Share on other sites

  • Active Member
		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
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-133942
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
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-133944
Share on other sites

  • Active Member
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
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-133945
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
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-133957
Share on other sites

  • 4 years later...

i have the follow problem,

when i go to refine for exemple, sword +8 to sword +9 he shows the probability in the place of vnum, and in the probability of refine shows 0

some help?

Link to comment
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-171455
Share on other sites

  • Honorable Member
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)
		break;
  
	prt->material_count++;
}

Writing this makes the code logic more clear and easier to follow.

 

  

On 12/7/2020 at 8:43 PM, 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. 

Try setting for example an item for the first and third slot while leaving the second one 0.

Edited by Distraught

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

Link to comment
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-171519
Share on other sites

  • Active Member
15 hours ago, Distraught said:

Try setting for example an item for the first and third slot while leaving the second one 0.

no-i-dont-think.gif

Edited by Metin2 Dev International
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/25044-fix-refine-proto-5th-item/#findComment-171524
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.