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?
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. 
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
I already had the sleep declare so I think it's already in MS.
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.
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.
You could add a /sync command.
Send a packet to the server and simply warp to your current x/y.
Just a thought.
Thought about it, decided against it.
I'd rather remove an issue than patch it up.
=[
No ideas?
Never happened to anyone else game before?
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
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?
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.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
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?
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
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.
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?
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.
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.
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?
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.
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.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
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.
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?
But it doesn't even reach that sub, I'm stuck receiving the map.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
Remove it :evil:
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?
I fixed it, it was that door tutorial, I completely forgot I added it.
I decided to put breaks on the setplayerY/X's in the server side playermove sub.
Which I dunno why I didn't do at first.
I noticed that in 2/4 directions, the setplayerX/Y was never reached because of the fucked up door recognition.
Now everything's fine as far as I can tell.
EDIT: I celebrated by rapidly going back and forth between a map for like 78 seconds.
It was driving me nuts, because I couldn't even figure out the realm of what I was looking for. Usually when something goes wrong you can at least figure out generally where to look, but this was evading me at every turn.
XD
I never actually looked at the "if tile=door" crap before, because at first glance it looks identical to the tile = key stuff.
|