FloooD / custom_cs2dsrv

Jermuk's custom Counter Strike 2D Server written in C and modified by FloooD and leegao.
173.192.35.85:36000
3 stars 0 forks source link

updatebuffer #13

Closed FloooD closed 13 years ago

FloooD commented 13 years ago

alright... what's the most efficient way to do this shit

lag compensation requires the server to store the past locations of every player for... say 300 milliseconds

a simple implementation (what's being used right now): add a buffer array to every player's struct. on every frame move each value of the buffer upwards... ya

so at 500 fps, 150 copies per player per frame * 32 players * 500 frames per second = 2.4 million copies per second. (as u can see its a quadratic relationship to fps :P) ew.

this method fails to take advantage of two things:

  1. uh why update the buffers of dead players?
  2. well since cs2d runs at 50 fps, the data inside the buffers are pretty redundant. would replacing all of the repeated values with zeros help? (and somehow having onfire ignore those zeros)

currently im thinking about something like this: getting the x coordinate of player id 21, 123 frames ago: lcbuffer.x[21][123] but would it be better to do lcbuffer.x[123][21]?

im not too familiar with how memory works so idk edit: u could just do a single memmove per frame if x and y are in the same array i.e. lcbuffer[123][21][0] for x, lcbuffer[123][21][1] for y

which makes those two things i wrote above kinda pointless ;p

FloooD commented 13 years ago

http://stackoverflow.com/questions/613294/fully-optimized-memcpy-memmove-for-core-2-or-core-i7-architecture

and i was worrying about 4.8mb/s causing lag

leegao commented 13 years ago

Well, our typical VPS's are around a few hundred times slower than industrial grade stuff :P

FloooD commented 13 years ago

haha well they're faster than this netbook right? that's what i've been using to compile/test

leegao commented 13 years ago

haha, writing code on a netbook? boss. It'd be better if it was with the google netbook :D (no offline access and no text editors, good luck there :P)

FloooD commented 13 years ago

eh... write it on paper hahahah nah i'd prolly write on my phone (palm pre plus). well it has vi and ssh in the terminal :D

anyway stupid question: is unsigned short array[150][32][2] guaranteed to be contiguous?

leegao commented 13 years ago

yes unless it exceeds the max available memory, in which case it should just fail

FloooD commented 13 years ago

k screwd the function replacing with memmove(&lcbuffer[1],lcbuffer,sizeof(short)_(LC_BUFFERSIZE-1)(MAX_CLIENTS)*2)

FloooD commented 13 years ago

eh gonna make player[id].x a pointer to lcbuffer[0][id-1][0] so that u dont have to copy a bunch of crap every frame ;p

FloooD commented 13 years ago

k done