Jump to content

[BUG Reveal] Lag when moving in map


Recommended Posts

  • Bronze

Didn't test yet, you can also test in your client, there is a fast GM teleport system posted by the turks on the internet, they released it 2 days after I coded a such system for my own purpose (during some tests to find the missing properties prb,prt,pre,etc).

 

An hyphothesis would be that there is a problem or memory leak with specific objects on the map and the Snake Field doesn't have those problematic properties.

Link to comment
Share on other sites

  • Premium

You're wrong, try to run around a map with an ultra-fast mount, after like 2 minutes it'll start to lag a lot. It's not a map issue.

 

"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

It's related to network actor management, if I remember it well, the client removes all dynamic actors on main actor "show" but re-inserts them afterwards because they are still stored in a vector or map of network actors because there is aproblem with a function that tests if a given actor is "visible" to main actor.

I can try to take a look at my source edits if you want

  • Love 3
Link to comment
Share on other sites

  • Bronze

The bug is caused by metin stones(their effects maybe).

Edit: Their effect is not the problem, its actually from monster/metinstone_01.GR2

EDIT2: I tried to use another model (metinstone_10.GR2) and still the same, in conclusion the problem is deeper.

Link to comment
Share on other sites

Le 17/07/2019 à 16:58, avertuss a dit :

Do you have link to the teleport by click system? Can't find ;/ 

@avertuss I just made this to test it on my client

PythonMiniMapModule.cpp

PyObject* minimapMousePosToAtlasPos(PyObject* poSelf, PyObject* poArgs)
{
	float fMouseX;
	if (!PyTuple_GetFloat(poArgs, 0, &fMouseX))
		return Py_BuildException();
	float fMouseY;
	if (!PyTuple_GetFloat(poArgs, 1, &fMouseY))
		return Py_BuildException();

	float fAtlasX, fAtlasY;
	CPythonMiniMap::Instance().MousePosToAtlasPos(fMouseX, fMouseY, &fAtlasX, &fAtlasY);

	int iAtlasX, iAtlasY;
	PR_FLOAT_TO_INT(fAtlasX, iAtlasX);
	PR_FLOAT_TO_INT(fAtlasY, iAtlasY);
	iAtlasX /= 100;
	iAtlasY /= 100;
	return Py_BuildValue("ii", iAtlasX, iAtlasY);
}

add this to "s_methods" array

{ "MousePosToAtlasPos",				minimapMousePosToAtlasPos,						METH_VARARGS },

PythonMiniMap.h (somewhere as public method of "CPythonMiniMap" class

void MousePosToAtlasPos(long lmx, long lmy, float* pfx, float* pfy);

PythonMiniMap.cpp

void CPythonMiniMap::MousePosToAtlasPos(long lmx, long lmy, float* pfx, float* pfy)
{
	*pfx = (lmx - m_fAtlasScreenX) * (m_fAtlasMaxX / m_fAtlasImageSizeX);
	*pfy = (lmy - m_fAtlasScreenY) * (m_fAtlasMaxY / m_fAtlasImageSizeY);
}

 

Python (uiminimap.py)

Git diff, you can use https://diffy.org/ to get visual overview of edits, just paste this git diff content and click "Diff me" button. Example: https://diffy.org/diff/b6186f0jn3maex74m1wbnvcxr (link will de destroyed after 24hrs)

diff --git a/root/uiminimap.py b/root/uiminimap.py
index 02393c7..d7cfac3 100644
--- a/root/uiminimap.py
+++ b/root/uiminimap.py
@@ -9,6 +9,7 @@ import app
 import colorInfo
 import constInfo
 import background
+import chr
 
 class MapTextToolTip(ui.Window):
 	def __init__(self):			
@@ -106,6 +107,7 @@ class AtlasWindow(ui.ScriptWindow):
 		self.tooltipInfo.SetParent(self.board)
 		self.infoGuildMark.SetParent(self.board)
 		self.SetPosition(wndMgr.GetScreenWidth() - 136 - 256 - 10, 0)
+		self.board.SetMouseLeftButtonUpEvent(ui.__mem_func__(self.GoToLocalPosition))
 		self.Hide()
 
 		miniMap.RegisterAtlasWindow(self)
@@ -137,12 +139,18 @@ class AtlasWindow(ui.ScriptWindow):
 		(bFind, sName, iPosX, iPosY, dwTextColor, dwGuildID) = miniMap.GetAtlasInfo(mouseX, mouseY)
 
 		if False == bFind:
-			return
+			if chr.IsGameMaster(player.GetMainCharacterIndex()):
+				(iPosX, iPosY) = miniMap.MousePosToAtlasPos(mouseX, mouseY)
+				dwTextColor = 0xffffffff
+			else:
+				return
 
 		if "empty_guild_area" == sName:
 			sName = localeInfo.GUILD_EMPTY_AREA
 
-		if localeInfo.IsARABIC() and sName[-1].isalnum():
+		if bFind == False:
+			self.tooltipInfo.SetText("(%d, %d)" % (iPosX, iPosY))
+		elif localeInfo.IsARABIC() and sName[-1].isalnum():
 			self.tooltipInfo.SetText("(%s)%d, %d" % (sName, iPosX, iPosY))						
 		else:
 			self.tooltipInfo.SetText("%s(%d, %d)" % (sName, iPosX, iPosY))
@@ -159,6 +167,14 @@ class AtlasWindow(ui.ScriptWindow):
 			self.infoGuildMark.SetPosition(mouseX - x - textWidth - 18 - 5, mouseY - y)
 			self.infoGuildMark.Show()
 
+	def GoToLocalPosition(self):
+		if False == self.board.IsIn() or False == chr.IsGameMaster(player.GetMainCharacterIndex()):
+			return
+
+		(mouseX, mouseY) = wndMgr.GetMousePosition()
+		(iPosX, iPosY) = miniMap.MousePosToAtlasPos(mouseX, mouseY)
+		net.SendChatPacket("/goto %d %d" % (iPosX, iPosY))
+
 	def Hide(self):
 		if self.AtlasMainWindow:
 			self.AtlasMainWindow.HideAtlas()

 

  • Metin2 Dev 1
Link to comment
Share on other sites

@Exygo  Could you try to replace

bool CNetworkActorManager::__IsVisiblePos(LONG lPosX, LONG lPosY)

in NetworkActorManager.cpp with this code and try again to see if this makes a difference

bool CNetworkActorManager::__IsVisiblePos(LONG lPosX, LONG lPosY)
{
 	LONG dx = lPosX-m_lMainPosX;
	LONG dy = lPosY-m_lMainPosY;
	LONG len = (LONG)sqrtf((float(dx) * float(dx) + float(dy) * float(dy)));

	extern int CHAR_STAGE_VIEW_BOUND;
	if (len < CHAR_STAGE_VIEW_BOUND && len > -CHAR_STAGE_VIEW_BOUND)
		return true;

	return false;
}

 

  • Love 1
Link to comment
Share on other sites

  • Gold

@Trial Thanks for the tutorial, but I got an error:

Spoiler

0719 21:07:23384 :: Traceback (most recent call last):

0719 21:07:23384 ::   File "networkModule.py", line 248, in SetGamePhase

0719 21:07:23384 ::   File "game.py", line 108, in __init__

0719 21:07:23384 ::   File "interfaceModule.py", line 296, in MakeInterface

0719 21:07:23384 ::   File "interfaceModule.py", line 184, in __MakeWindows

0719 21:07:23384 ::   File "uiMiniMap.py", line 234, in __init__

0719 21:07:23384 ::   File "uiMiniMap.py", line 110, in LoadWindow

0719 21:07:23384 :: AttributeError
0719 21:07:23384 :: : 
0719 21:07:23384 :: 'BoardWithTitleBar' object has no attribute 'SetMouseLeftButtonUpEvent'
0719 21:07:23384 :: 

 

What should I add to _init_ func or it's the problem of uiscript file?

I'll be always helpful! 👊 

Link to comment
Share on other sites

il y a 15 minutes, ReFresh a dit :

@Trial Thanks for the tutorial, but I got an error:

  Masquer le contenu


0719 21:07:23384 :: Traceback (most recent call last):

0719 21:07:23384 ::   File "networkModule.py", line 248, in SetGamePhase

0719 21:07:23384 ::   File "game.py", line 108, in __init__

0719 21:07:23384 ::   File "interfaceModule.py", line 296, in MakeInterface

0719 21:07:23384 ::   File "interfaceModule.py", line 184, in __MakeWindows

0719 21:07:23384 ::   File "uiMiniMap.py", line 234, in __init__

0719 21:07:23384 ::   File "uiMiniMap.py", line 110, in LoadWindow

0719 21:07:23384 :: AttributeError
0719 21:07:23384 :: : 
0719 21:07:23384 :: 'BoardWithTitleBar' object has no attribute 'SetMouseLeftButtonUpEvent'
0719 21:07:23384 :: 

 

What should I add to _init_ func or it's the problem of uiscript file?

It seems that your "Window" class in ui.py differs a bit from mine, you don't have the method "SetMouseLeftButtonUpEvent", edit the "Window" class as following :

class Window(object):
	[...]

	def __init__(self, layer = "UI"):
		[...]

		self.mouseLeftButtonDownEvent = None
		self.mouseLeftButtonDownArgs = None
		self.mouseLeftButtonUpEvent = None
		self.mouseLeftButtonUpArgs = None
          
	[...]
          
	def SetMouseLeftButtonDownEvent(self, event, *args):
		self.mouseLeftButtonDownEvent = event
		self.mouseLeftButtonDownArgs = args

	def OnMouseLeftButtonDown(self):
		if self.mouseLeftButtonDownEvent:
			apply(self.mouseLeftButtonDownEvent, self.mouseLeftButtonDownArgs)

	def SetMouseLeftButtonUpEvent(self, event, *args):
		self.mouseLeftButtonUpEvent = event
		self.mouseLeftButtonUpArgs = args

	def OnMouseLeftButtonUp(self):
		if self.mouseLeftButtonUpEvent:
			apply(self.mouseLeftButtonUpEvent, self.mouseLeftButtonUpArgs)

 

  • Love 1
Link to comment
Share on other sites

  • Gold

@Trial Ah... I can see now. Thanks.

For those who had the same problem, you can just change:

This piece of code:

Spoiler

self.board.SetMouseLeftButtonUpEvent(ui.__mem_func__(self.GoToLocalPosition))

 

To this:

Spoiler

self.board.SetOnMouseLeftButtonUpEvent(ui.__mem_func__(self.GoToLocalPosition))

 

 

I'll be always helpful! 👊 

Link to comment
Share on other sites

3 hours ago, Trial said:

@Exygo  Could you try to replace


bool CNetworkActorManager::__IsVisiblePos(LONG lPosX, LONG lPosY)

in NetworkActorManager.cpp with this code and try again to see if this makes a difference


bool CNetworkActorManager::__IsVisiblePos(LONG lPosX, LONG lPosY)
{
 	LONG dx = lPosX-m_lMainPosX;
	LONG dy = lPosY-m_lMainPosY;
	LONG len = (LONG)sqrtf((float(dx) * float(dx) + float(dy) * float(dy)));

	extern int CHAR_STAGE_VIEW_BOUND;
	if (len < CHAR_STAGE_VIEW_BOUND && len > -CHAR_STAGE_VIEW_BOUND)
		return true;

	return false;
}

 

Only this code works? Or I need the other too? 

Link to comment
Share on other sites

  • Bronze

I fixed it by adding IsStone check.

void CNetworkActorManager::__RemoveDynamicActors()
{
	//copy it
	std::vector<DWORD> dwCharacterVIDList;

	CPythonCharacterManager& rkChrMgr=CPythonCharacterManager::Instance();
	for(CPythonCharacterManager::CharacterIterator i = rkChrMgr.CharacterInstanceBegin(); i!=rkChrMgr.CharacterInstanceEnd(); ++i)
	{
		dwCharacterVIDList.push_back( (*i)->GetVirtualID() );
	}

	for( int i = 0; i < dwCharacterVIDList.size(); ++i )
	{
		CInstanceBase*  pkInstEach = rkChrMgr.GetInstancePtr(dwCharacterVIDList[i]);
		if(!pkInstEach)
			continue;
		
		CActorInstance* rkActorEach=pkInstEach->GetGraphicThingInstancePtr();
		if(rkActorEach->IsPC() || rkActorEach->IsNPC() || rkActorEach->IsEnemy() || rkActorEach->IsStone()) // fix lag la teleportari multiple 18 iulie 2019
		{
			rkChrMgr.DeleteInstance(dwCharacterVIDList[i]);
			auto it = m_kNetActorDict.find (dwCharacterVIDList[i]);
			if (it != m_kNetActorDict.end())
			{
				m_kNetActorDict.erase(it);
			}
		}
	}
						
	rkChrMgr.DestroyDeadInstanceList();
}

 

  • Love 3
Link to comment
Share on other sites

7 godzin temu, Trial napisał:

This is a fix for this method, other code is the "fast teleport" system

Fast teleport doesn't work for me. TkCar6Q.gifSyserr is clean. 

 

I tried to edit def GoToLocalPosition(self):

like

def GoToLocalPosition(self):
		net.SendChatPacket("test")

to check if mouse click works, but it doesn't.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

Il y a 2 heures, avertuss a dit :

Fast teleport doesn't work for me. TkCar6Q.gifSyserr is clean. 

 

I tried to edit def GoToLocalPosition(self):

like


def GoToLocalPosition(self):
		net.SendChatPacket("test")

to check if mouse click works, but it doesn't.

Can you show us your uiminimap.py ? (pastebin it)

Edited by Metin2 Dev
Core X - External 2 Internal
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.