Mirage Source

Free ORPG making software.
It is currently Sat Apr 27, 2024 5:37 pm

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Dec 10, 2007 7:51 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
For some reason, starting this morning, my client takes up 78k kb, using 81-100% of my CPU.

I'm not sure why.
Worse, I don't know where to start looking.

The only thing I checked was that everything is cleared properly, but I don't see how that'd affect during runtime.

In the menu, it uses 0%, as soon as the ingame packet is sent, it jumps to 100%.


I'm not sure if It's a DX7 issue, possibly an error in the extra tile types, it could be the "NPCDATA" packet, I think it's being sent too often for every NPC.


Ideas?
:cry:


Top
 Profile  
 
PostPosted: Mon Dec 10, 2007 8:21 pm 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
get a code profiler and see what subs/functions are taking the most time :D

Or you can write a code profiler and (simply get the time a block of code starts, and time it until it ends. Write all the profiled results to a text file and calculate percentages, etc.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Mon Dec 10, 2007 8:50 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
The RAM usage is mostly going towards the graphic files most likely. They are all loaded into memory and stick there.

CPU usage is probably due to a lack of Sleep in the game loop. I'll just steal what I PMed to William a while ago to prevent having to re-type it:

Quote:
First, get the Sleep API declared.

http://allapi.mentalis.org/apilist/Sleep.shtml

Now, say this is your client's pseudo game loop:

Code:
Dim StartTime As Long
Dim ElapsedTime As Long

Do
StartTime = GetTickCount

'Do game loop

ElapsedTime = GetTickCount - StartTime
Loop


Now after you get the elapsed time per frame, check it in comparison to the frame rate you desire. I think MS already does something like this, but the "wait" loop is something like:

Code:
Do While (GetTickCount - StartTime) < (1000 / MyFrameRate)
DoEvents
Loop


If thats the case, then just put after the DoEvents a "Sleep 1".

The Sleep API just basically stops the application for X milliseconds, freeing up the resources. What is happening is I assume you're on a single-core CPU. Your client is sucking up all the CPU, and since it is the active window, Windows gives it the priority over the server.

It is also beneficial to those on a laptop since it keeps their CPU usage down, which means more battery life and less fan usage. ;)


Quote:
I added the declare, but the only thing the client have remotly close to that code you posted is the fps cap:
Code:
' Lock fps
Do While GetTickCount < Tick + 33
DoEvents
Loop

Should I put sleep 1 below the doevetnts?


Quote:
Yup, thats exactly it. So yeah, just add Sleep 1 below that DoEvents and you will no longer be an enemy of CPUs. :P

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
PostPosted: Mon Dec 10, 2007 9:10 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
I already had the sleep declare so I think it's already in MS.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
PostPosted: Tue Dec 11, 2007 1:39 am 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
It was already declared, but used nowhere in the code.

I raised the FPS lock by 2 (to 35) and it dropped CPU usage by 10% on average.
Added a sleep 1 as you said, and brought the FPS lock back to 33, and now it only used 3% CPU.

=]



Only reason I noticed the issue was because I kept freezing changing maps, like I would change maps, and I couldn't move anymore, and when that happened, my CPU would be at 100%.

NPcs and Mobs were skipping too.


EDIT:
Sigh.. I still get stuck walking through maps randomly, like a 13% chance that when switching maps, I'm unable to move.


Top
 Profile  
 
PostPosted: Tue Dec 11, 2007 3:45 am 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
I toggled breakpoints on all the Canmove = False lines, and when I'm frozen, none of them are triggered. Moving = 0, and IsTryingToMove is false.

But NPCs and Mobs can still move around, warping to the map after being frozen fixes it.


Top
 Profile  
 
PostPosted: Tue Dec 11, 2007 4:44 am 
Offline
Newbie
User avatar

Joined: Mon Dec 10, 2007 10:43 pm
Posts: 17
You could add a /sync command.

Send a packet to the server and simply warp to your current x/y.

Just a thought.


Top
 Profile  
 
PostPosted: Tue Dec 11, 2007 4:48 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
Not a good idea, it adds a security hole.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Tue Dec 11, 2007 5:02 am 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
Thought about it, decided against it.


I'd rather remove an issue than patch it up.


Top
 Profile  
 
PostPosted: Tue Dec 11, 2007 11:55 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
=[


No ideas?
Never happened to anyone else game before?


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 12:45 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
I have 50 different tilesets which are only loaded one at a time, so I only take up 1.55mb of RAM with that :]

Gonna create an automatic sprite recognition system which will allow RMXP style spritesheets as well :D

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 6:50 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
My compiled client uses 3.5 MB, and only 2% CPU now.

My problem now is I'm getting the problem that I've seen other have, where you need to resync. I leave/enter a map, and am completely frozen.


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 7:18 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Get a better server, or sort out your packets.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 8:53 pm 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
It's a strange problem, and it seems to happen consistently randomly, if that makes sense :P

For example, with Playerworlds back in the day, there was the ice skating bug. It seemed to happen only sometimes, and only for certain people. These kinds of bugs are the hardest to squish :P

To fix it, I would make certain all the values client side are the same as the ones server side, and probably just get rid of the CanMove sub client side, and instead send a "Can move?" to the server, which replies yes or no.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 9:28 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Actually.. I think Dave might have hit the nail on the head.

Because it's simply the player stopping moving, it's most probably a problem with that sub.

I've been meaning to remove the CanMove sub for a while, because it required twice the amount of work for the same effect as just having it serverside.

<3 Dave.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 10:32 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
Alright, I'll do that today. however the Canmove sub is never called when it happens.
I added breakpoints on canmove, and all the canmove = false's inside of it, as well as every instance of 'istryingtomove' and everything detecting keypresses.

None of them are triggered when I'm frozen, yet NPCs and Mobs are able to move.


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 11:22 pm 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
Actually, thinking about it more, I would send a "Try To Move" and then have the server either move you and say "good" or not move you and say, "wtf you little fuck quit wasting my time with bogus shit!"

That way you avoid the whole "can I move here?" "Yes" "Ok, move me there" "kkthx" loop, and instead turns into "Move me here" "No."

Rez, that's strange. I would guess, since not even keypresses are registering, that you're getting stuck in a loop somewhere.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Wed Dec 12, 2007 11:43 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
Well, I tried compiling and running..

And I noticed that ONLY when I freeze, upon exiting the game, I get the RTE 91, the object variable one.

I'm not sure what object I've fucked up though.
I must be stuck in something like you said, since that RTE is the one that usually pops up when you didn't end something right?

Running through the IDE, I never get that error.


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 12:55 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
do you have any classes in your code?

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 1:29 am 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
Nope.

I never use objects either, I used one for centering font once.. but took it out.
I don't fully understand objects and such, so I don't use them.


Whatever it is is client side, but why don't I get the RTE when running through the IDE?


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 2:13 am 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Wouldn't it be easier to just do:

- Can I move here pl0x?

Then either:

- Ya shure, I tells everyone yous move'd

or:

- Lol u can't move, i dun process yer packet

Quote:
I never use objects either, I used one for centering font once.. but took it out.
I don't fully understand objects and such, so I don't use them.


Thats because objects are worthless crap in VB6.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 2:32 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
That's what I meant :P

kkthx.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 5:07 am 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
But I haven't added any objects.


The only objects being set are the DX7 Surface ones, and they're all release properly as well.
I don't understand why the RTE doesn't pop up in the IDE or during Compilation.


EDIT: I narrowed it down slightly..

you know that bit that displays "Receiving Map..." that's commented out?
I had a gut feeling, and uncommented it.

sure enough, whenever my player freezes, that message is displaying nonstop.


Sooo... for some reason, the 'GettingMap = False' in the map completed packet isn't being read.

For the time being, until I figure out Wtf is wrong, I added a gettickcount timer that sets it back to false after a few seconds, since getting a map never takes that long.

But my coordinates are freaking out, so they must not be getting sent properly, but it happens so randomly..

I think it has something to do with my NPCs for some reason.


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 11:54 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Rezeyu wrote:
But I haven't added any objects.


The only objects being set are the DX7 Surface ones, and they're all release properly as well.
I don't understand why the RTE doesn't pop up in the IDE or during Compilation.


EDIT: I narrowed it down slightly..

you know that bit that displays "Receiving Map..." that's commented out?
I had a gut feeling, and uncommented it.

sure enough, whenever my player freezes, that message is displaying nonstop.


Sooo... for some reason, the 'GettingMap = False' in the map completed packet isn't being read.

For the time being, until I figure out Wtf is wrong, I added a gettickcount timer that sets it back to false after a few seconds, since getting a map never takes that long.

But my coordinates are freaking out, so they must not be getting sent properly, but it happens so randomly..

I think it has something to do with my NPCs for some reason.


Remove CanMove.

:D

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 6:02 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
But it doesn't even reach that sub, I'm stuck receiving the map.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group