Jump to content

Fix Reading d:/ymir work, FPS Drops, Slow Loading Time


Recommended Posts

  • Premium

In EterPackManager.cpp update this: 

bool CEterPackManager::Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)
{
	if (m_iSearchMode == SEARCH_PACK_FIRST)
	{
		if (GetFromPack(rMappedFile, c_szFileName, pData))
			return true;
		
		if (c_szFileName[1] != ':' && GetFromFile(rMappedFile, c_szFileName, pData))
		{
			TraceError("%s", c_szFileName); // only for log. it's not an error.
			return true;
		}
	}
	
	if (m_iSearchMode == SEARCH_FILE_FIRST)
	{
		if (GetFromFile(rMappedFile, c_szFileName, pData))
			return true;
		
		return GetFromPack(rMappedFile, c_szFileName, pData);
	}
	
	return false;
}

And

bool CEterPackManager::isExist(const char * c_szFileName)
{
	return isExistInPack(c_szFileName);
}

In CEterPackManager::GetFromFile comment if(m_bTryRelativePath) {.....} (not sure necessary, i did it in the past)

 

In UserInterface set bPackFirst to true to not load from d:/ and false to load from d:/

bool bPackFirst = TRUE;
bPackFirst = TRUE;

 

There is a common problem on all metin2 sources. The game will first load the files which are in d:/ymir work folder and if you have a dvd/cd-rom with letter D the game will load very slow and have big fps drops (for some players the game can be unplayable). I know many players who had a dvd-rom with letter D and reported me how bad the client works.

 

Using this solution:

1. The game will no longer load d:/ymir files.

2. Client will open faster, load the files faster.

3. Less fps drop.

 

Normal metin2 client without fix and with a dvd-rom that has letter D assigned:

https://metin2.download/picture/aXN97muX99n16ND113M1dJnfV0Ol6E93/.gif

 

After fix:

https://metin2.download/picture/WdjkrLm505Z9pf0JBzQ0772oXiNhMnI1/.gif

 

Check this video:

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 19
  • Not Good 1
  • Scream 2
  • Good 16
  • Love 1
  • Love 38

Hey,

Nice to see that this problem is being treated !

 

I'm asking myself why you're searching for "ymir" in the file name and not just compare the second letter with ":"

 

Then, your function:

 

bool CEterPackManager::isExist(const char * c_szFileName)
{
	if (m_iSearchMode == SEARCH_PACK_FIRST)
	{
		if (isExistInPack(c_szFileName))
			return true;
	}

	return isExistInPack(c_szFileName);
}

 

Can be shorten as:

bool CEterPackManager::isExist(const char * c_szFileName)
{
	return isExistInPack(c_szFileName);
}

 

Have you done some testings yet  ?

  • Premium

I've done the test of course. No more slow loading if i have a dvdrom with letter D. No file is loaded from d:/ymir work

I had no time to shorten the code, i just wanted to get it work and after it worked i posted for everyone. Everyone can make it better after.

 

##########

Edited by Speachless

Haha, you're not a noob, that was not what I was saying.

 

Here's what I may suggest you to not takeof some functionalities of the eterpack:

 

 

In the function:

bool CEterPackManager::Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)

 

Adding a condition to check if the filename redirect in a drive in the condition that check if we search from client file first instead of pack file as following:

 

	if (m_iSearchMode == SEARCH_FILE_FIRST && c_szFileName[1] != ':')
	{
		if (GetFromFile(rMappedFile, c_szFileName, pData))
			return true;

		return GetFromPack(rMappedFile, c_szFileName, pData);
	}

	if (GetFromPack(rMappedFile, c_szFileName, pData))
		return true;

	return GetFromFile(rMappedFile, c_szFileName, pData);

 

and using this same structure we can then write the isExist function as following:

bool CEterPackManager::isExist(const char * c_szFileName)
{
	if (m_iSearchMode == SEARCH_FILE_FIRST && c_szFileName[1] != ':')
	{
		if (_access(c_szFileName, 0) == 0)
			return true;

		return isExistInPack(c_szFileName);
	}

	if (isExistInPack(c_szFileName))
		return true;

	return _access(c_szFileName, 0) == 0 ? true : false;
}

 

What do you think ?

 

  • Love 1

@Speachless This is a simple solution. About the (D:) you could just create a different partition in your HDD called (D:) instead to bought a external dvd-roam to test the problem. You can also check if the Game is running in (D:) and after use the ":" method from @ElRenardo. This could be done much more easier with FoxFS cause in FoxFS there is just almost 8 - 10 files with d:/ymir work/ instead of the normal (Client) that have multiple patches and you can put the check only for them by name instead.

Edited by HITRON
  • Premium
42 minutes ago, HITRON said:

@Speachless This is a simple solution. About the (D:) you could just create a different partition in your HDD called (D:) instead to bought a external dvd-roam to test the problem. You can also check if the Game is running in (D:) and after use the ":" method from @ElRenardo. This could be done much more easier with FoxFS cause in FoxFS there is just almost 8 - 10 files with d:/ymir work/ instead of the normal (Client) that have multiple patches and you can put the check only for them by name instead.

Problem happens on a cd/dvd-rom not on a hard drive. ElRenardo code doesn't fix this problem.

 

As long as you do my tutorial the problem is permanently solved with no visible performance loss or crashes. Please run some test first.

 

 

 

 

Edited by Speachless
  • Love 1

So, for better comprehension I changed that:

 

bool CEterPackManager::Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)
{
	//TimeChecker timeChecker(c_szFileName);
	//Logf(1, "Load %s\n", c_szFileName);

	if (m_iSearchMode == SEARCH_PACK_FIRST || c_szFileName[1] == ':')
	{
		if (GetFromPack(rMappedFile, c_szFileName, pData))
			return true;

		return GetFromFile(rMappedFile, c_szFileName, pData);
	}

	if (GetFromFile(rMappedFile, c_szFileName, pData))
		return true;

	return GetFromPack(rMappedFile, c_szFileName, pData);
}

[...]

bool CEterPackManager::isExist(const char * c_szFileName)
{
	if (m_iSearchMode == SEARCH_PACK_FIRST || c_szFileName[1] == ':')
	{
		if (isExistInPack(c_szFileName))
			return true;

		return _access(c_szFileName, 0) == 0 ? true : false;
	}

	if (_access(c_szFileName, 0) == 0)
		return true;

	return isExistInPack(c_szFileName);
}

 

So now it's working exactly as your fix even if SEARCH_FILE_FIRST is false but instead of doing nothing if the file is not found in the pack, it will try to find it in the file directory.

 

Let me explain it a bit better:

 

if the filename we're looking for contains ":" as second letter (for exemple "D:\Ymir Work\monster\barbarian_boss\00.gr2") then it will try to find it in packs first.

If it's not found then it will try to load the file from the file directory and that will eventually cause some lags if you have as you say a dvd player as D drive, but this shouldn't occur except if you have some paths errors in your client.

 

If this cause some lasg to your client, you maybe have some paths error and your client with your fix is certainly not loading everything.

 

 

  • Premium

You're confusing a thing. All metin2 sources are configured to load the files from d:/ymir work. It's only for test-environment not for release. 

Still my way has less performance loss. and there is no point to change. See the videos above.

 

This is my last time i enter any forum. Same shit happened in the past and i have no patience to argue like in the old days. Run tests before post.

Edited by Speachless
28 minutes ago, Speachless said:

You're confusing a thing. All metin2 sources are configured to load the files from d:/ymir work. It's only for test-environment not for release. 

Still my way has less performance loss. and there is no point to change. See the videos above.

 

This is my last time i enter any forum. Same shit happened in the past and i have no patience to argue like in the old days. Run tests before post.

 

I've tested it, and works great! Why are you caring about someone else's opinion? Who cares what he/she thinks... I've implemented it, and works well, lags are gone. Big thanks! :)

  • Love 1

🖥️ SysAdmin — Government (HU)
🛠️ Freelance Metin2 Dev • DevOps
🐧 FreeBSD / Linux | 🛡️ Security & WAF | 🚀 Performance | 🔥 Firewalls | ⚙ Automation
Open to work - Contact me on Discord @matteo_r

You misunderstood me, I didn't wanted to criticize your work in any way.

 

I just wanted to achieve this without losing the functionality that search the file in the file directory if not found in the packs.

But as you said, it should only be used in test env.

 

Quote

This is my last time i enter any forum. Same shit happened in the past and i have no patience to argue like in the old days. Run tests before post.

 

Why couldn't we talk about other options or improving options ? As you said before:

Quote

I had no time to shorten the code, i just wanted to get it work and after it worked i posted for everyone. Everyone can make it better after.

 

I don't understand your reaction. Maybe you had a hard day.

  • Love 1
  • Premium

I did multitasking and I burned my brain that's why i reacted like that. Posting on dev, writing on discord, answering to questions in the game, fixing a post on server's forum, checking the code, configuring a vps. all in the same time. 

#include <iostream>

using namespace std;

int main() 
{
    std::string FileNameStr = "d:/ymir work";
    
    if (FileNameStr.find("ymir") == string::npos)
        cout<<"Hello World";
    else
        cout<<"it is ymir";
}

CPU Time: 0.00 sec(s), Memory: 3236 kilobyte(s)
#include <iostream>

using namespace std;

int main() 
{
    std::string FileNameStr = "d:/ymir work";
    
    if (FileNameStr[1] != ':')
        cout<<"Hello World";
    else
        cout<<"it is ymir";
}

CPU Time: 0.00 sec(s), Memory: 3240 kilobyte(s)

And there is no performance difference between "ymir" and : 

It is more acurate with : i know. But both works in metin2 case and once i will test with : i will update the post.

Edited by Speachless
  • Premium
12 minutes ago, Evo said:

I'm guessing a solution for you

index file

-> change if you have all "d:/ymir work" to  ->  "pack/"

Thanks, but the error still exists (no syserr)

 

edit:

If these 2 values are FALSE, the client will not start

 

bool bPackFirst = TRUE;
bPackFirst = TRUE;

 

Edited by Morpheus™
  • 2 months later...

Hello, i did your tutorial. I use martysama client. The game starts and works normally. I have to change something else? i mean to replace d:// with something else? or since i replaced to your functions im ready?

“𝓐𝓵𝓵 𝔀𝓮 𝓱𝓪𝓿𝓮 𝓽𝓸 𝓭𝓮𝓬𝓲𝓭𝓮 𝓲𝓼 𝔀𝓱𝓪𝓽 𝓽𝓸 𝓭𝓸 𝔀𝓲𝓽𝓱 𝓽𝓱𝓮 𝓽𝓲𝓶𝓮 𝓽𝓱𝓪𝓽 𝓲𝓼 𝓰𝓲𝓿𝓮𝓷 𝓾𝓼.” ~ 𝓖𝓪𝓷𝓭𝓪𝓵𝓯 𝓽𝓱𝓮 𝓖𝓻𝓮𝔂

I don't see the point of disabling loading files from pack.

As I'm concerned, client built in distribute mode has this option disabled by default.

On the other hand you can just disable this option by setting appropriate mode (sometimes reading from disc is useful for debugging stuff).

  • Premium
On 5/1/2020 at 3:23 PM, Sherer said:

I don't see the point of disabling loading files from pack.

As I'm concerned, client built in distribute mode has this option disabled by default.

On the other hand you can just disable this option by setting appropriate mode (sometimes reading from disc is useful for debugging stuff).

 

There is a bug when you have CD/DVD-ROM with letter D on some sources the game will work very bad. This is the main reason of the tutorial, however nobody has any obligation to use my code.

1 hour ago, Speachless said:

 

There is a bug when you have CD/DVD-ROM with letter D on some sources the game will work very bad. This is the main reason of the tutorial, however nobody has any obligation to use my code.

Yeah that's pretty normal. Anyway had one builds its client files should not be read from disk at all (security reason; with exception for whitelist).

Edited by Sherer
  • 5 months later...
  • 3 months later...

0213 22:17:28880 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:17:28880 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:17:30100 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:17:30100 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:17:31008 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:17:31008 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:17:31916 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:17:31916 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:17:32822 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:17:32822 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:17:33731 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:17:33731 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:18:40907 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:18:40907 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:18:43086 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:18:43086 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:18:45281 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:18:45281 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:18:46187 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:18:46187 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)
0213 22:18:52211 :: Not a valid .WAV file: sound/pc2/assassin/bow/attack1.wav
0213 22:18:52211 :: CSoundManager3D::GetInstance (filename: sound/pc2/assassin/bow/attack1.wav)

 

Client syserr.

  • 11 months later...

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.