13reak true. The Threads from the Config are IOThreads, so you can maybe speed up your Server if you have many Players, but one of the main CPU Usage Problem is, that Kal uses only one core / thread for the Monster Tick function.
I guess that the Monster Count on Mainserver was much lower many years ago, when the Serverfiles we used was created, so that this wasnt a Problem. But now many People use 10.000 Monster + wich can be handled only via one single Thread.
My Idea:
Orig:
Code:
void __thiscall CMonsterObject__OnTimer(int this, int a2)
{
int v2; // ST18_4@9
int v3; // ST10_4@15
int v4; // [sp+4h] [bp-1Ch]@1
int v5; // [sp+Ch] [bp-14h]@13
int v6; // [sp+14h] [bp-Ch]@7
int v7; // [sp+18h] [bp-8h]@7
DWORD v8; // [sp+1Ch] [bp-4h]@6
v4 = this;
if ( a2 )
{
if ( a2 == 1 )
{
CIOCriticalSection__Enter((struct _RTL_CRITICAL_SECTION *)(this + 16));
CIOCriticalSection__Enter((struct _RTL_CRITICAL_SECTION *)(v4 + 48));
CLink__MoveTo((void *)(v4 + 88), v4 + 80);
CIOCriticalSection__Leave(v4 + 48);
v5 = *(_DWORD *)(v4 + 80);
while ( v5 != v4 + 80 )
{
v3 = v5 - 428;
v5 = *(_DWORD *)v5;
(*(void (__thiscall **)(int))(*(_DWORD *)v3 + 208))(v3);// CMonsterTick
}
CIOCriticalSection__Leave(v4 + 16);
CIOObject__AddTimer(v4, 1000, 1);
}
}
Multithreaded for use with 4 Core Processor (pseudocode):
Code:
void MonsterThread_01(void*) // add needed Params (Pointers) here
{
while ( v5 != (v4 + 80 / 4) ) // Handle only 1/4 of the Monsters in this Thread, so first 25%
{
v3 = v5 - 428;
v5 = *(_DWORD *)v5;
(*(void (__thiscall **)(int))(*(_DWORD *)v3 + 208))(v3);// CMonsterTick
}
}
void MonsterThread_02(void*)
{
// Handle 25 - 50 % Here
}
void MonsterThread_03(void*)
{
// Handle 50 - 75 % Here
}
void MonsterThread_04(void*)
{
// Handle 75 - 100 % Here
}
void __thiscall CMonsterObject__OnTimer(int this, int a2)
{
int v2; // ST18_4@9
int v3; // ST10_4@15
int v4; // [sp+4h] [bp-1Ch]@1
int v5; // [sp+Ch] [bp-14h]@13
int v6; // [sp+14h] [bp-Ch]@7
int v7; // [sp+18h] [bp-8h]@7
DWORD v8; // [sp+1Ch] [bp-4h]@6
v4 = this;
if ( a2 )
{
if ( a2 == 1 )
{
CIOCriticalSection__Enter((struct _RTL_CRITICAL_SECTION *)(this + 16));
CIOCriticalSection__Enter((struct _RTL_CRITICAL_SECTION *)(v4 + 48));
CLink__MoveTo((void *)(v4 + 88), v4 + 80);
CIOCriticalSection__Leave(v4 + 48);
v5 = *(_DWORD *)(v4 + 80);
_beginthread(MonsterThread_01,0,0);
_beginthread(MonsterThread_02,0,0);
_beginthread(MonsterThread_03,0,0);
_beginthread(MonsterThread_04,0,0);
CIOCriticalSection__Leave(v4 + 16);
CIOObject__AddTimer(v4, 1000, 1);
}
}