Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Lower cpu usage

Hybrid
Loyal Member
Joined
Mar 15, 2006
Messages
451
Reaction score
285
without big explanations.

Here is a part of the code in main.exe
PHP:
	startDraw = GetTickCount();
	
	drawFrame();

	frameTime = GetTickCount() - startDraw;

	while(frameTime < 40)
	{
		frameTime = GetTickCount() - startDraw;
	}

Imagine that we have a simple scene and frame is drawn in 10ms.

After frame is drawn we get here
PHP:
	while(frameTime < 40)
	{
		frameTime = GetTickCount() - startDraw;
	}

for 30 ms we will use cpu just to check if 40ms have passed since frame started to draw.

why we just don't go to sleep for a little and then check for the passed time? Let the system do useful things

PHP:
	while(frameTime < 40)
	{
		Sleep(1); // will sleep for 10-15 ms, depending on time accuracy
		frameTime = GetTickCount() - startDraw;
	}

So the point is - don't waste cpu time if we have a simple frame that is drawn faster then 40 ms.




How to add this thing in main using ollydbg:

1. Search for SwapBuffers or glFlush (search for name/lable CTRL+N)

and you will find this part of the code
PHP:
	frameTime = GetTickCount() - startDraw;

	while(frameTime < 40)
	{
		frameTime = GetTickCount() - startDraw;
	}

in 97d it will look like this:

Gembrid - Lower cpu usage - RaGEZONE Forums


1.03.27 jpn:
Gembrid - Lower cpu usage - RaGEZONE Forums


2. Modify the code by adding sleep function call:

97d:
Gembrid - Lower cpu usage - RaGEZONE Forums


1.03.27 jpn:
Gembrid - Lower cpu usage - RaGEZONE Forums



Gembrid - Lower cpu usage - RaGEZONE Forums




Note: if main spends >= 40 ms for frame drawing, this thing won't save you from high cpu usage :D cpu will be busy in drawing frame


this thing needs testings, i made some tests + thx to Dios he made little tests, so test and maybe it will be useful
 
Experienced Elementalist
Joined
Aug 25, 2005
Messages
253
Reaction score
20
It works. But as you said, if it needs more than 40ms to draw, the CPU usage is still high. For example in towns, where there are players.
A normal main uses 47-50% of my CPU.
With your solution, the main uses 18-23%. :): But unfortunately, not with many players around.

Anyway, great help from you. As always.
 
Last edited:
Newbie Spellweaver
Joined
Oct 3, 2009
Messages
33
Reaction score
25
with small numbers of monsters and characters on the screen the CPU usage to 10%
awesome, thx :thumbup1:

1.07v+

Code:
BYTE FixCpuUsage[7] = { 0xE9, 0x99, 0x5A, 0x4C, 0x00, 0x90, 0x90 };
BYTE FixCpuUsage2[13] = { 0x6A, 0x01, 0xFF, 0x15, 0x74, 0x51, 0x28, 0x09, 0xE9, 0x48, 0xA5, 0xB3, 0xFF };
memcpy((int*)0x004A9A82, FixCpuUsage, sizeof(FixCpuUsage));
memcpy((int*)0x0096F520, FixCpuUsage2, sizeof(FixCpuUsage2));
 
Initiate Mage
Joined
Aug 16, 2011
Messages
2
Reaction score
0
Okay, so I know that newbies are annoying and I'm a newbie, so could you guys explain it like for a neanderthal please?
 
Junior Spellweaver
Joined
Nov 16, 2007
Messages
160
Reaction score
11
Already tried on a 97d main and i did it and looks exactly like yours, but when i get into the login screen, all freezes and i need to close the game.
 
Junior Spellweaver
Joined
Nov 16, 2007
Messages
160
Reaction score
11
If this won't work then go to task manager with process hacker or task manager idk , and set priority to your gameserver LOW.

Uhm, this is for main... some mains have a high cpu usage, im using core i7 ivy bridge and some 97d mains uses 15% of my cpu... thats insanely high for playing only mu online.
 
Initiate Mage
Joined
Sep 17, 2011
Messages
2
Reaction score
0
i try same guide but can't find
1. Search for SwapBuffers or glFlush (search for name/lable CTRL+N)

Gembrid please answer my pm thank you.
 
Custom Title Activated
Loyal Member
Joined
Nov 25, 2010
Messages
1,171
Reaction score
403
This is awesome, lowered from 25 to 17. :)
 
Custom Title Activated
Loyal Member
Joined
Nov 25, 2010
Messages
1,171
Reaction score
403
Yea, 17 was the login screen, in the game it's 5. :)
 
Custom Title Activated
Loyal Member
Joined
Dec 5, 2009
Messages
2,657
Reaction score
1,178
up, if need be i pay this fo some $, contact me! (skype: firenight29)

just research offsets base on the main offsets of gembrid provided of 97 / 1.03.27 main or on 1.07v by 8bitcore
close to ur main using ollydbg (compare code)

then adapt changes / save & test.
 
Back
Top