Jump to content
Maintenance : Final step ×

Initial Entity Meeting Freeze Fix


Amun

Recommended Posts

  • Contributor

The client is freezing for a while(anywhere from a few ms to multiple seconds for slower PCs) when meeting a new NPC/enemy for the first time because that's when it registers, creates and loads the entity.

Note: This is only a partial fix.

Why is it partial? Because it only loads the static mobs and NPCs available in the map(npc, regen, boss, group and group_group), so it won't fix the problem for dynamic entities, like pets and mounts.

It can be extended to load those as well, of course, but you'll have to take care of that on your own.

Variant:

A way of completely fixing this would be to create the instances and load their files after registering the path(in root->playerSettingModule->LoadGameNPC), BUT that would slow down the initial loading quite a bit, since it'll load ALL mobs/npcs/pets/mounts, even if most of them will never be used.

There's advantages and drawbacks to both methods. Choose for yourself.

 

Here's the link:

 

Good luck!

- Amun


Edit:

Spoiler

PS: Fuck off - NO SUPPORT.

PSS: Another reason why the client is freezing is because of granular loading of maps. Implement the first step of @ masodikbela experimental full terrain render and you'll get rid of that as well.

Here's the link(Show some love while you're there):

 

 

 UPDATE 08/12/2022:

1. Refactored to use unordered_set from the beginning instead of creating a vector, then filtering unique entities by creating a set, and then moving them back to a vector.

2. Extended to load the full spectrum of entities(both static and dynamic), except for PC(which are loaded in loading phase), WARP, GOTO, and DOOR. They can be included by altering this block in char_manager.cpp:

#ifdef ENABLE_ENTITY_PRELOADING
	//@Amun: or be specific, like if(ch->ispet, mount, whatever)
	if (!ch->IsPC() && !ch->IsGoto() && !ch->IsWarp() && !ch->IsDoor())
		SECTREE_MANAGER::Instance().ExtendPreloadedEntitiesMap(lMapIndex, pkMob->m_table.dwVnum);
#endif

 

Edited by Amun
Updated the code/amended some details.
  • Metin2 Dev 245
  • kekw 1
  • Eyes 3
  • Not Good 2
  • Think 5
  • Scream 2
  • Good 57
  • Love 4
  • Love 120
Link to comment
Share on other sites

  • 1 month later...
  • Forum Moderator
1 hour ago, Euzebiusz said:

Can you make a recording of what the situation looks like before adding the code and what the situation looks like after adding the code?

Before: Consistent stuttering upon meeting an unloaded entity or walking through the map

After: Minimal to no stuttering upon loading a chunk of the map

Gurgarath
coming soon

Link to comment
Share on other sites

  • 2 months later...
  • Contributor
On 2/26/2023 at 10:08 AM, Dr3Ame3r said:

Tested, it works, but, with a slight little problem, after the loading phase ends (the loadingscreen photos disappear) and it should popup your character, it freezes for about 0.7-1s until it shows entities near you(that happens only 1 time for each client)

Yes, and I said that in the readme. If you want to avoid that, load npclist ahead of time and send the entities before the game world is shown. I didn't bother to make that as well because I wanted to keep it simple, so that everyone(or most people) can understand what's going on.

 

If you consider that to be a big problem and have the knowledge to do what I said earlier, you can do it and post it here, so that everyone can use. Unfortunately, I'm extremely busy at the moment, so I won't be able to work on community stuff for a while.

 

Cheers!

- Amun

Link to comment
Share on other sites

  • 2 weeks later...
  • Active Member
1 hour ago, Viello said:

I had some teleport issues, sometimes client crashes, no syserr maybe this code is not perfect for my files, btw thanks for sharing with community.

I assure you the code is great coded, i tested it over 2 weeks and i dont had any problems with my testers, be sure you didn't messed up something or cause is from another system or bad code. As an advice try to have permanently debugging maybe you will find the problem. Good luck !

  • Good 1
Link to comment
Share on other sites

  • 1 month later...
Spoiler

0505 21:47:51889 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:51910 :: Failed to preload race 192
0505 21:47:52341 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:52341 :: Failed to preload race 191
0505 21:47:52489 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:52489 :: Failed to preload race 111
0505 21:47:52646 :: CRaceManager::GetRaceDataPointer: cannot load data by dwRaceIndex 20025
0505 21:47:52646 :: CPythonCharacterManager::CreateInstance VID[20025] Race[20025]
0505 21:47:52646 :: Failed to preload race 20025
0505 21:47:53121 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:53121 :: Failed to preload race 144
0505 21:47:53556 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:53556 :: Failed to preload race 151
0505 21:47:53556 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:53556 :: Failed to preload race 154
0505 21:47:53775 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:53775 :: Failed to preload race 153
0505 21:47:53777 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:53777 :: Failed to preload race 184
0505 21:47:54086 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54086 :: Failed to preload race 152
0505 21:47:54099 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54099 :: Failed to preload race 194
0505 21:47:54134 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54134 :: Failed to preload race 176
0505 21:47:54261 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54261 :: Failed to preload race 182
0505 21:47:54366 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54366 :: Failed to preload race 155
0505 21:47:54435 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54435 :: Failed to preload race 193
0505 21:47:54435 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54435 :: Failed to preload race 142
0505 21:47:54435 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54435 :: Failed to preload race 183
0505 21:47:54702 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54702 :: Failed to preload race 179
0505 21:47:54703 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54703 :: Failed to preload race 180
0505 21:47:54926 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:54926 :: Failed to preload race 110
0505 21:47:55025 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

0505 21:47:55025 :: Failed to preload race 112
0505 21:47:55025 :: CPythonCharacterManager::CreateInstance: VID[0] - ALREADY EXIST

i see this when i move randomly is it a problem or what does it mean?

Edited by gleskpem1
d
Link to comment
Share on other sites

  • 1 year later...
  • Active+ Member
Posted (edited)


I would like to provide feedback based on my experience from a few months ago. On some maps with many entities (like metin farm maps), there is an issue where the screen stays black for 3-4 seconds at the map loading phase.

The recorded instances are transferred from the server as race numbers, but the client uses VID within the

This is the hidden content, please
. If that VID has been used before or will be used later to save an entity, it throws the error "CPythonCharacterManager::CreateInstance: VID[%d] - ALREADY EXIST," and most of the new entitys becomes invisible on the client.

Additionally, on maps with a high number of entities, during the startup phase, there is sometimes an "unknown packet header" error. I haven't fully understood the cause of this, but it is likely that "pack.count = s.size();" just probably returns a value +1 or is not properly cast, causing it to reset when reaching the uint16_t limit.

Edited by Koray
  • Metin2 Dev 41
  • Good 4
  • Love 5
Link to comment
Share on other sites

  • Contributor
4 minutes ago, Koray said:


I would like to provide feedback based on my experience from a few months ago. On some maps with many entities (like metin farm maps), there is an issue where the screen stays black for 3-4 seconds at the map loading phase.

The recorded instances are transferred from the server as race numbers, but the client uses VID within the

This is the hidden content, please
. If that VID has been used before or will be used later to save an entity, it throws the error "CPythonCharacterManager::CreateInstance: VID[%d] - ALREADY EXIST," and most of the new entitys becomes invisible on the client.

Additionally, on maps with a high number of entities, during the startup phase, there is sometimes an "unknown packet header" error. I haven't fully understood the cause of this, but it is likely that "pack.count = s.size();" just probably returns a value +1 or is not properly cast, causing it to reset when reaching the uint16_t limit.

Thanks for sharing, but I have a few things to point out on this

 

The black screen:

You weren't supposed to load them in the game phase. I've only done it this way to keep it simple and for everyone to know where to find the code and do the initial changes. You were supposed to load them in the loading phase, along with all the other things.

 

VID Already exist: Don't know what to say about this one right now, but I'll have a look at it when I got some free time(which probably won't be very soon..)

 

As for the last problem, it's unlikely that you'll ever hit the upper limit of uint16_t. There's space for 65k races, you wouldn't hit it even if you sent the entire mob list * 20, so I tend to think your problem is coming from some other place.

  • Metin2 Dev 1
Link to comment
Share on other sites

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