Jump to content

Lycan sync tree bug


Go to solution Solved by Gurgarath,

Recommended Posts

When i use mounts like 71124 71125 71126 the mobs disapear and i get syser :

 

Sync: cannot find tree at -2147483648 -2147483648 (name: [GA]Sebi)

 

To make mobs disapear you need to walk in map some metters 20-30 by using mount.

Open char.cpp

Search:

LPSECTREE new_tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), x, y);

 if (!new_tree)
 {
  if (GetDesc())
  {
   sys_err("cannot find tree at %d %d (name: %s)", x, y, GetName());
   GetDesc()->SetPhase(PHASE_CLOSE);
  }
  else
  {
   sys_err("no tree: %s %d %d %d", GetName(), x, y, GetMapIndex());
   Dead();
  }

  return false;
 }

Replace it with:

LPSECTREE new_tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), x, y);

 if (!new_tree)
 {
  if (GetDesc())
  {
   sys_err("cannot find tree at %d %d (name: %s)", x, y, GetName());
   //GetDesc()->SetPhase(PHASE_CLOSE);
   new_tree = GetSectree();
   x = GetX();
   y = GetY();
  }
  else
  {
   sys_err("no tree: %s %d %d %d", GetName(), x, y, GetMapIndex());
   Dead();
  }

  return false;
 }

And that's it. 

  • Metin2 Dev 1
  • Love 3
Link to comment
Share on other sites

  • 7 years later...
On 7/31/2015 at 12:07 AM, TyWin said:

Open char.cpp

Search:

LPSECTREE new_tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), x, y);

 if (!new_tree)
 {
  if (GetDesc())
  {
   sys_err("cannot find tree at %d %d (name: %s)", x, y, GetName());
   GetDesc()->SetPhase(PHASE_CLOSE);
  }
  else
  {
   sys_err("no tree: %s %d %d %d", GetName(), x, y, GetMapIndex());
   Dead();
  }

  return false;
 }

Replace it with:

LPSECTREE new_tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), x, y);

 if (!new_tree)
 {
  if (GetDesc())
  {
   sys_err("cannot find tree at %d %d (name: %s)", x, y, GetName());
   //GetDesc()->SetPhase(PHASE_CLOSE);
   new_tree = GetSectree();
   x = GetX();
   y = GetY();
  }
  else
  {
   sys_err("no tree: %s %d %d %d", GetName(), x, y, GetMapIndex());
   Dead();
  }

  return false;
 }

And that's it. 

I'm digging up this old topic because I'm doing some tests on new server files and I just encountered this problem.

This solutions does work but it doesn't fix the issue at it's origin/source. The origin lies in "CHARACTER::StateMove", here:

float fRate = (float)dwElapsedTime / (float)m_dwMoveDuration;

it sometimes happens that "m_dwMoveDuration" equals 0 thus resulting in undefined behavior (see "CHARACTER::CalculateMoveDuration" for more info)

in "CHARACTER::StateMove" replace this

	DWORD dwElapsedTime = get_dword_time() - m_dwMoveStartTime;
	float fRate = (float)dwElapsedTime / (float)m_dwMoveDuration;

	if (fRate > 1.0f)
		fRate = 1.0f;

	int x = (int)((float)(m_posDest.x - m_posStart.x) * fRate + m_posStart.x);
	int y = (int)((float)(m_posDest.y - m_posStart.y) * fRate + m_posStart.y);

with this

	const DWORD dwElapsedTime = get_dword_time() - m_dwMoveStartTime;
	int x;
	int y;
	bool bMovementFinished = false; //indicates if character moved and has reached destination

	if (!dwElapsedTime || !m_dwMoveDuration)
	{
		x = GetX();
		y = GetY();
	}
	else
	{
		float fRate = (float)dwElapsedTime / (float)m_dwMoveDuration;

		if (fRate >= 1.0f)
		{
			bMovementFinished = true;
			fRate = 1.0f;
		}

		x = (int)((float)(m_posDest.x - m_posStart.x) * fRate + m_posStart.x);
		y = (int)((float)(m_posDest.y - m_posStart.y) * fRate + m_posStart.y);
	}

still in same function replace this

if (1.0f == fRate)

with this

if (bMovementFinished)

 

  • Metin2 Dev 3
Link to comment
Share on other sites

  • Forum Moderator
  • Solution
On 12/24/2022 at 5:40 PM, Trial said:

I'm digging up this old topic because I'm doing some tests on new server files and I just encountered this problem.

This solutions does work but it doesn't fix the issue at it's origin/source. The origin lies in "CHARACTER::StateMove", here:

float fRate = (float)dwElapsedTime / (float)m_dwMoveDuration;

it sometimes happens that "m_dwMoveDuration" equals 0 thus resulting in undefined behavior (see "CHARACTER::CalculateMoveDuration" for more info)

in "CHARACTER::StateMove" replace this

	DWORD dwElapsedTime = get_dword_time() - m_dwMoveStartTime;
	float fRate = (float)dwElapsedTime / (float)m_dwMoveDuration;

	if (fRate > 1.0f)
		fRate = 1.0f;

	int x = (int)((float)(m_posDest.x - m_posStart.x) * fRate + m_posStart.x);
	int y = (int)((float)(m_posDest.y - m_posStart.y) * fRate + m_posStart.y);

with this

	const DWORD dwElapsedTime = get_dword_time() - m_dwMoveStartTime;
	int x;
	int y;
	bool bMovementFinished = false; //indicates if character moved and has reached destination

	if (!dwElapsedTime || !m_dwMoveDuration)
	{
		x = GetX();
		y = GetY();
	}
	else
	{
		float fRate = (float)dwElapsedTime / (float)m_dwMoveDuration;

		if (fRate >= 1.0f)
		{
			bMovementFinished = true;
			fRate = 1.0f;
		}

		x = (int)((float)(m_posDest.x - m_posStart.x) * fRate + m_posStart.x);
		y = (int)((float)(m_posDest.y - m_posStart.y) * fRate + m_posStart.y);
	}

still in same function replace this

if (1.0f == fRate)

with this

if (bMovementFinished)

 

To be fair, I had the exact same bug and I postponed the fix for months because it was a low importance bug so far, but your post interested me. In hindsight I decided to work on it because this didn't fix it for me (I also had no syserr, but I was experiencing the same bug with mounts).

This kind of bug is easy to track, just do /state while running with a mount, if the mount has the bug, the coordinates won't be refreshed, which will postpone the loading of the chunks until the server finally catch up and decides to sent the move packet and the refreshing of the chunks.

Usually, it can happen when the server cannot process something, for players, monsters and NPC it is the data folder that is responsible for dealing with that. It will use the duration and the accumulation of an animation to try to replicate as much as it can where a mob should be and when it should be there. If there is no data or if the data is incorrect, you will have many issues (including but not limited to):

  • False flagged as a cheater / speedhacker
  • Monsters will load with a slight delay (instead of loading in front of you they will load behind you) or won't load at all
  • You will receive damages from monsters far behind because the server thinks you are immobile
  • The server will think a monster has caught up with you while it hasn't and vice-versa

To fix it, you just have to add the "folder" in the mob_proto of every mount having the issue. Long story short, some mounts won't have a "folder" field in your mob_proto.txt, which will result in them not having a data folder and triggering the aforementioned scenario. In my case, the Manny (20246/20247) was having the issue, so I just added "christmas_2016_mammoth" to the "folder" field in mob_proto.txt, made sure I had it in "share/data/monster" and voilà. It fixed the issue completely.

To easily know the folder, just check in NPClist and make sure it is a folder and not a "subfolder".  A subfolder in npc_list.txt is working like this:

#0	#SUBFOLDER	#FOLDER <- (This one should be added into mob_proto.txt)
0	christmas_2016_mammoth_01	christmas_2016_mammoth

 

  • Metin2 Dev 2
  • Good 1
  • Love 1

Gurgarath
coming soon

Link to comment
Share on other sites

20 hours ago, Gurgarath said:

To be fair, I had the exact same bug and I postponed the fix for months because it was a low importance bug so far, but your post interested me. In hindsight I decided to work on it because this didn't fix it for me (I also had no syserr, but I was experiencing the same bug with mounts).

This kind of bug is easy to track, just do /state while running with a mount, if the mount has the bug, the coordinates won't be refreshed, which will postpone the loading of the chunks until the server finally catch up and decides to sent the move packet and the refreshing of the chunks.

Usually, it can happen when the server cannot process something, for players, monsters and NPC it is the data folder that is responsible for dealing with that. It will use the duration and the accumulation of an animation to try to replicate as much as it can where a mob should be and when it should be there. If there is no data or if the data is incorrect, you will have many issues (including but not limited to):

  • False flagged as a cheater / speedhacker
  • Monsters will load with a slight delay (instead of loading in front of you they will load behind you) or won't load at all
  • You will receive damages from monsters far behind because the server thinks you are immobile
  • The server will think a monster has caught up with you while it hasn't and vice-versa

To fix it, you just have to add the "folder" in the mob_proto of every mount having the issue. Long story short, some mounts won't have a "folder" field in your mob_proto.txt, which will result in them not having a data folder and triggering the aforementioned scenario. In my case, the Manny (20246/20247) was having the issue, so I just added "christmas_2016_mammoth" to the "folder" field in mob_proto.txt, made sure I had it in "share/data/monster" and voilà. It fixed the issue completely.

To easily know the folder, just check in NPClist and make sure it is a folder and not a "subfolder".  A subfolder in npc_list.txt is working like this:

#0	#SUBFOLDER	#FOLDER <- (This one should be added into mob_proto.txt)
0	christmas_2016_mammoth_01	christmas_2016_mammoth

 

I still recommend you to apply this fix, I have folders configured as they should be but the problem persisted because of the undefined behavior I quoted above.

SYSERR: Dec 26 17:40:03 :: CHARACTER::Sync: cannot find tree at -2147483648 -2147483648 (name: sync)

Edit: Not same bug I think, the one caused by this undefined behavior is not directly related to motion files.

Edited by Trial
Link to comment
Share on other sites

  • Premium

I think the problem is related to the sectree because your map coord are not multiple of 25600, when you unride from the mount, may happen this issue due to an incorrect calculation in the axis.

 

Get more info with mapindex

sys_err("cannot find tree by %d %d (map index %d)", x, y, lMapIndex);

 

Edited by WeedHex
Link to comment
Share on other sites

1 hour ago, WeedHex said:

I think the problem is related to the sectree because your map coord are not multiple of 25600, when you unride from the mount, may happen this issue due to an incorrect calculation in the axis.

 

Get more info with mapindex

sys_err("cannot find tree by %d %d (map index %d)", x, y, lMapIndex);

 

i don't think it's related, the bug is present on any map/location, it only depends on the call to CHARACTER::CalculateMoveDuration which sets the m_dwMoveDuration to 0 if CHARACTER::m_posStart equals CHARACTER::m_posDest

it's easy to trigger : login, click somewhere to move (do not release mouse button) + CTRL+G to mount -> undefined behavior, it might be "fine" if the result of (float)dwElapsedTime / (float)m_dwMoveDuration is positive (inf) but if the result is negative (-nan / -inf) it results in -INTMAX coordinates.

Anyway it's undefined behavior in all cases 😕

  • Scream 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.