Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace Server Timers
#1
I dont know if this will speed up anything or slow it down. So please tell me if it dont and I remove the topic. This will replace the timers with a part of code in the game loop using TickCount.

Server Side - This will replace the tmrSpawnMapItems.
Go inside:
Code:
Sub GameAI()
At the top add:
Code:
Dim XTickCount(1 to 2) as Long, XFirst(1 to 2) as Byte
Then at the bottom add:
Code:
If XFirst(1) = 0 Then
  XTickCount(1) = GetTickCount
  XFirst(1) = 1
End if

If GetTickCount > XTickCount(1) + 1000 Then
  Call CheckSpawnMapItems
  XFirst(1) = 0
End If

Server Side - This will replace the tmrPlayerSave.
Go inside:
Code:
Sub GameAI()
Then at the bottom add:
Code:
If XFirst(2) = 0 Then
  XTickCount(2) = GetTickCount
  XFirst(2) = 1
End if

If GetTickCount > XTickCount(2) + 60000 Then
  Call PlayerSaveTimer
  XFirst(2) = 0
End If

The tmrShutdown is a little bit different, but Im tired so Im not gonna do that one.

Follow Up
If you want to add more timers into the gameloop. Change:
Code:
Dim XTickCount(1 to 2) as Long, XFirst(1 to 2) as Byte
To:
Code:
Dim XTickCount(1 to 3) as Long, XFirst(1 to 3) as Byte
You add by 1 for each new timer that is going to be removed.
Now in the bottom part of the Sub GameAI, you will add two new parts:
Code:
If XFirst(3) = 0 Then
  XTickCount(3) = GetTickCount
  XFirst(3) = 1
End if

If GetTickCount > XTickCount(3) + 60000 Then
  'Run the timer code here.
  XFirst(3) = 0
End If
You see that instead of using 1 and 2 as the first two timers, you now use the added number, which now is 3.
Now where it says "'Run the timer code here", that is the place were you put whats inside the timer. And thats it Smile Now you can simply do this for all timers to get rid of them.
Reply
#2
The thing i have found with timers is they behave differently on different speeds of computer... at least thats what its like at college ~.~
Reply
#3
They should work independently i think, can't be sure thought.
Reply
#4
I think its just a case of the pc's we use in class are just lagging so bad, its a pain in the arse since you make something and its timed perfectly then you go onto a normal pc and its hyperspeed -.-
Reply
#5
But the tick count should be reliable thought. So its probably better than using timers.
Reply
#6
William, does the login rely on any of these? Getting really :?'d off with 'connected sending login information...' freezes >.
Reply
#7
I'm looking into that right now, Fox. Have you tried this tut to see if it helps your problem?
Reply
#8
[quote="Fox"]William, does the login rely on any of these? Getting really :?'d off with 'connected sending login information...' freezes >.
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?
Reply
#9
Updated a follow up.
Reply
#10
I converted the gameAI timer.. booted and noticed no npc's etc were moving... then realised that timers needed to run through the sub the tickcounts in lol.

How would i work around this?
Reply
#11
Opss xD

I forgot it should be:
Private XTickCount(1 To 2) As Long, XFirst(1 To 2) As Byte

If its just dimmed, it wont keep the variable after the sub is completed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)