Forum Discussion
Romans_I_XVI
11 years agoRoku Guru
Veeta you are my hero! I am now getting a maximum of 5ms for 50 active players!!! So much better, I used to crash the game if I got up to 30+ players, now my 8 core gaming computer is the bottleneck :shock: . (50 virtual game clients at once is about all it can do). Here is my new code if anyone is curious.
I didn't remove the params = {} object creation, but it really doesn't seem to have much of an effect.
Thanks again! 😛
While this.udp.isReadable()
received = this.udp.receive(this.buffer, 0, 20)
if received > 0
params = {}
params.id = resolve_two_byte_integer(this.buffer[12],this.buffer[13])
id_string = params.id.tostr()
params.x = resolve_two_byte_integer(this.buffer[14],this.buffer[15])
params.y = resolve_two_byte_integer(this.buffer[16],this.buffer[17])
params.color = this.buffer[18]
params.destroy = this.buffer[19]
id_exists = false
player = this.players.Lookup(id_string)
if player <> invalid
this.players[id_string].x = params.x
this.players[id_string].y = params.y
id_exists = true
if params.destroy = 1
print "Removed player - id : " ; this.players[a].id
this.players[id_string].sprite.Remove()
this.players.Delete(id_string)
end if
end if
if not id_exists and params.destroy = 0
params.sprite = this.compositor.NewSprite(270, 500, this.region_ring[params.color])
params.sprite.SetData(params.id)
this.players.AddReplace(id_string, params)
end if
end if
End While
I didn't remove the params = {} object creation, but it really doesn't seem to have much of an effect.
Thanks again! 😛