Jump to content

Fix refine proto 5th item


Recommended Posts

  • VIP

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 1
  • Good 1
  • Angry 2
Link to post
  • VIP
		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 post
  • VIP
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 post
  • VIP
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 post
		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 post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Activity

    1. 0

      EVENT FLAG NOTICE

    2. 0

      Sash bug +19% absorb

    3. 1

      TRANSMUTATION WITH BLESSING SCROLL AND MAGIC STONE 100%

    4. 1

      [HowTo] The "hello world" of metin2

    5. 1

      TRANSMUTATION WITH BLESSING SCROLL AND MAGIC STONE 100%

    6. 0

      Sash absorb bug

    7. 0

      Debug DB vanilla Core

    8. 0

      Give item after kill monster [c++]

  • Recently Browsing

    No registered users viewing this page.

Shoutbox

Shoutbox

Chatroom Rules

 

Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules

 

×
×
  • 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.