Jump to content

traffic in gta3


Recommended Posts

when the netcode is all optimized and stuff.. it will be interesting to see what will be kept from the normal gta3 game..

as far as traffic goes... i don't see why adding all the other stuff is a big deal...

lets assume there are a hundred AI controlled cars in the game.. the client machines need only know the position and orientation of the vehicles... (maybe some other stuff as far as damage goes... but thats just another integer probably or even a short)...

so you have 3 floats for position and 3 floats for rotation... (on 3 axes)

floats and integers are each 4 bytes.. so we have 24 bytes per car...

in total tahts only an extra 2.34k maybe 2.7k if counting the damage of other vehicles... to have to send across the server... (that doesn't sound like a whole lot when people are getting 300k/sec connections...

add pedestrians to that.. it become bigger.. even still the server would only have to tell the client machine where peds are in a certain radius.. (same for cars)... i imagine a good size chunk of peds and AI vehicles would be 25 cars... and i dunno 30 peds (really crowded area)..

a ped would need the same amount of data (3 position floats, and 3 angle floats.. and an integer for which animation sequence the character is in)..

so thats an extra 1.5k to send each time... thats chump change ...

even then they are adding compression algorithms to the netcode...

I don't think its necessarily going to be aproblem to support all this...

the biggest trouble would be having the client machines clear out all vehicles... and nextly writing the algorithm to customize packets for each person to receive.. (a distance formula sqrt((originx-pedx)^2+(originy-pedz)^2+originy-pedz)^2).. just check that in a condition against some arbitrary distance (which could be customized according to the client's bandwith capabilities...)... it would work, .. also..i think the 3dNow! on Athlons has a built in assembly call for the square root function (its pretty cpu intensive otherwise if doing it for every pedestrian for every packet on each client).... though, even then the more you put on the server's cpu, the less you need to tell the client...

ok im getting entirely way to low level with this, i'll try tokeep it more general.. im just saying that it shouldn't be a big deal for a server running gta3 as an observer, to check where the other cars are and tell the client's accordingly what is near it..)

Kent

Link to comment
i imagine a good size chunk of peds and AI vehicles would be 25 cars... and i dunno 30 peds (really crowded area)..

Kent

I think you'll need more cars and peds, because the players can be in different areas , depending on how much players there will be in the game

Link to comment

There is much much more to consider than just position and orientation.

For Example

-100 Cars-

100 x Positions

100 x Amount of Damage to Each

100 x Damage Decals/Damage texture positons

100 x State Changes (on client-side)

That is being sent every second, plus, if a car gets destroyed, it would have to be replaced etc. And, that information is going to be sent to every connected client continually. And the size of the map, 100 cars is nothing by comparison. Pedestrians also, being a lot more of them would take the same amount of data being sent. Plus Debris/powerups and other player health/coordinates, you can see why most online games are so simple.

Link to comment

Liberty city is so huge, if player1 is on portland (island 1) and player2 is on shoreside vale (island 3) you need minimal 3000 peds/cars in the game to create a good amount of people on the streets. And mind there should be so many details sended with the cars, and don't forget the players in the cars, so for example:

3000 x 2 x position X (3000x amount of characters, 2x every ped in car and car itself)

3000 x 2 x position Y

3000 x 2 x position Z

3000 x 2 x spin X

3000 x 2 x spin Y

3000 x 2 x spin Z

3000 x 2 x speed X

3000 x 2 x speed Y

3000 x 2 x speed Z

3000 x 2 x look X

3000 x 2 x look Y

3000 x 2 x look Z

3000 x 1 x car colors (only car)

3000 x 1 x address of the ped in the car (only car)

and there's alot (about 300 details) more to send to all clients, that would be a huge netcode.

Link to comment

Well, my example of 3000 is a bit much, but considering the UDP connections and the compression that probably will be used in the versions after 0.3. A few weeks ago i tested a special version of mta with UDP and Zlib Compression (also used in ZIP-files) and it worked about 4x faster than the TCP and uncompressed version. There were still some bugs in it that we should fix before implementing it into a version of mta.[/b]

Link to comment

Even if there were 3000 peds / vehicles whatever, only the server needs to keep track on the cpu.. and only tell the client about a certain number of them..

perhaps a variable draw distance for cars/peds

here is an example of what i mean

example.JPG

blue dots are AI controlled peds... pink dashes are cars...

the red circles w/ dots in the middle represent players..

(circles can vary in size according to bandwith capabilities)

anyways.. server is keeping track of thousands of cars and peds... but only tells the client about which ones are inside the circle

(this can be done w/ a simple distance formula)...

(ok technically its a sphere in the 3d world, but i think you can get what im saying)

anyways the effect is that all clients are playing in the server's world without huge bandwith issues..

as far as decals and things go.. i was talking bare necesseties........ other stuff could be added.. but to be played those are the absolute necessary things to be sent.... im not sure why so much data needs to be sent by the server.... as far as i can see the client only needs to know where the car is, where the car is facing, and where its going... (maybe how much damage the car has.. but even still a limited view of this would work) a lot of other things are kinda superfluous....

Kent

Edited by Guest
Link to comment

dont forget that if there are 30 ppl connected that the server has to send that to all 30 ppl, so that will slow it. you have to multiply

30 *

100 x Positions

100 x Amount of Damage to Each

100 x Damage Decals/Damage texture positons

100 x State Changes (on client-side)

* the size per each.

note: clients do not have to send nething to the sever, cept their position. this is because is they crash into something, and everyone else has their data, then gta will calculate their out come ie:

im moving 30 mph, facing a pole and i hit it.. everyones gta should show the pole get damaged. i dont have to send the data that says its damages.. the gta's can figure it out

one other thing, there is more to sync than mentioned in the quote above:

100 x Speed of car

100 x Virtual Ineritia

if you dont have the speed or inertia, then when a car smashed in to a player, nothing will happen... car car moving at 0 mph cant cause damage.

i still think my original idea was the best, and close to flawless as possible

see here

https://forum.multitheftauto.com/viewtopic.php?t=13&postdays=0&postorder=asc&start=0

my final thot:

skrew traffic and peds for now. once MTA is refined and pretty much done, stable, and professional quality, then perhaps IJsVogel will consider adding traffic syncing. by then the MTA Team will have a good handle on the game engine, and be able to add traffic. but now im pretty sure the last thing IJsVogel is worring about it traffic.

PS: we need a forum dedicated to syncing traffic. all tho it will probably be usuless, at least there will be a place for all these ideas. it seems that every new person that comes onto these forums, adds a traffic syncing topic.

Link to comment

exactly.. which is much smaller than having to send the position of every car and every pedestrian to every client....as some people believe..

with the circle method... each client can get the info they need in one or 2 packets... tahts relatively small..

(the server wouldn't have to send out 20 seperate things for each client. it can be done in one transmission. by putting all the info into an array for example.. and just sending that array.)

with more players that will increase.. but that is the case w/ any multiplayer scenario... Personally i think half the fun of GTA is running down the streets trying to avoid the cars going 30 miles/hour..

having a variable circle size would also improve customizability (sp?) for people playing the game... maybe the cirlce radius could change dynamically according to the amount of lag...

I don't think gta would be the same game w/out being able to be a faceless person in the crowd...

thats just me i guess..

maybe it'd be better if i made a little example of how he server code wold work.

some basic assumptions about the server

- server has all cars and peds walking around.. its a lot yeah.. but

- server has a list of all player's position in the game.

ok here's the routine for determining what to tell x-client what cars are in their area:

--

for all cars and peds on server { // even if its 3000 it would be insanely fast

if current AIcar is in players circle (distance formla)

addit to packetlist

if current AIped is in players circle (distance formula)

add it to packetlist

send packet //should probably be able to be done in one transmission

}

on the client side

when received packet for car/peds

{

for each item in the packet list{ //probably 30-50 items?

place car/ped in the scene

}

}

So yeah there is going to be more bandwith w/ more people and more items.. but the method i showed is probably one of the better ways of handling the bandwith.. Its just an idea haha

Kent

Link to comment

i hate to break it to you, but this mod is programmed in VB, not C. therefore they are using (ug) WinSoc to send stuff. winsoc isnt good at cramming, and cant send arrays. winsock can only send strings, int, and longs. (i think.. i know it cant send types, or arrays) also if you wanted to send an array, you would have to use a for loop and send eash element.. which takes time.

also only people with cable or dsl can be the server.. that sux.. second: with 56k, like me, its going to lag when all 30 ppl are on the screen and thats without 20 extra unessisary ai cars. also: it might be fast to send to you, but before you can get any more data, it has to send to the other 29 players, which takes time. it also has to collect data from all 29 ppl. even with uber-optimized netplay code, its still going to take a shitload of time for all that to happen.

yes GTA 3 will be different with out peds etc, but in exchange for internet play, i wont miss them

here is a nother foiling little fact that all peple coming up with traffic sync ideas shud know:

gta has a display\object buffer. this is currently 32 (im pretty sure) this means that there can only be 32 things loaded at once (wheather they are on screen or not) this is why when you spawn 32 tanks, there is no traffic or peds. on playstation2 it would crash it you made to many tanks

so having more than 32 actors in the game at once would be impossible unless they could somehow resize the buffer from vb code. which we dont know is poissible at this point

Link to comment

heh ok i understand the limitations of winsock

but there is no reason one couldn't take the array and store it as a string

each item is put into the string, which is delimited by some character to mark anther item

ie.

car1xpos*car1ypos*car1zpos|car2xpos etc

just some arbitrary character could be used to allow one to turn an array into a string.... the client could could then use a string tokenizer to break that apart...

Thoug i'd highly suggest that future versions have a dedicated server written in C...

also a for loop for each item would still execute extremely fast...

write aprogram in vb to run through a loop 30,000 times then display something in a text box (if you want ot use vb..) it would be a lot faster than you'd think...

the display buffer of 32 objects could actually be used to the advantage of the server... by this the server is limited to only sending 32 elements of data per packet... that would be about 1.56k per packet assuming 32 elements are being sent, assuming each item has 10 4byte properties of the vehicle/ped...

all games in some form have to run through a loop for every object in a multiplayer game... there is no way around that... and 32 objects really isn't that much...

in a game like quake3 arena.. if there are32 objects you'd experience more lag just because each object is controlled individually on seperate computers... in the case of GTA3, all 32 objects are controlled by the server...

I don't think it would be as bad as people think

kent

Link to comment

a few things:

the foor loop by itself is almost instant, but i have 2.0 ghz.. on my 75 mhz it takes a few seconds.. but that is not crucial

yes im familiar with the system you explained with sending strings. ive used that before, the only thing, is that the string needs to be written, sent, and decoded. here what i mean: for loops do execute fast, but with code in them it tick takes longer, and the string will quickely get big, but the annoying thing is decoding the string, there will be lots of mids and instrs, which will take time to extract it completely.

im making a program to show how long it will take.. ill upload in a few minutes, along with source

Link to comment

ok here it is

http://www.angelfire.com/games4/rctcool_stuff/gtamta/Thing.zip

it takes suprisingly a long time to do what would expectedly be really quick.

note: the way i encripted the string is really primitive, most likely a working version would require more.

also note that the numbers i used were randomely generated, not stored vaules

here is the source:

http://www.angelfire.com/games4/rctcool_stuff/gtamta/Source.txt

Link to comment

yea string stuff is a bitch in vb....

could one use masking to make this job easier w/ a double or long...

im not sure if masking is easy in vb...

i dunno

maybe winsock isn't the best way to go about it...

also outputting text to the form caption takes a long time...

regardless netcode should NEVER be done in a manner where things are sent individually...

i bet somewhere out there somebody has designed a control that is similar to winsock, only is polymorphic...

if not a dedicated server written in a decent language should probably be written...

Link to comment

can you explain masking... the "masking" i know of is adding clear to images

ya the onlyway you can make servers with vb in having a control array of winsoc. but when i tried it.. i had a for loop like such

For X = 0 to (Socket.Count-2) step 1

Socket(X).SendData("adsjhdasd")

Next X

the problem is that only the last item in the array sends because its not over written in the loop, (bcuz its the last item to be sent)

and using that method, your have to send the a string similar to the one you mentioned a few posts ago

Link to comment

here's some source code i found online that appears to send an array of data, though i don't htink its winsock... they didn't give much explanation...

though i hardly think winsock is the best idea for doing netcode for a game...

Dim oListener As TcpListener

oListener = New TcpListener(1150)

oListener.Start()

Dim oSocket As Socket = oListener.AcceptSocket()

'// To Receive data use Receive method on ur Socket obj

'// data passed to Receive must be in thr form of an array of byte

Dim arrOfBytesReceive(100) As Byte

Dim intNmberOfBytes As Integer = oSocket.Receive(arrOfBytesReceive, arrOfBytesReceive.Length, SocketFlags.None)

Dim arrOfBytesSending(100) As Byte

'// To Send data u call Send method

oSocket.Send(arrOfBytesSending, arrOfBytesSending.Length, SocketFlags.None)

oSocket.Close()

oListener.Stop()

Link to comment

yeah i think winsock is the devill

don't htinkyou need a control

'//namespace: Imports System.Net.Sockets

was at the top of the code.. i know its commented but maybe that can point you in the right direction (im not a VB coder.. im a C/C++ man)

see if there is something in vb about that, i can't give you all much else i hate the language hahaha

Kent

Link to comment

if it was really that easy, send positions and display etc, then all games would only require minimal bandwidth. it just isnt that simple, look at a 56k ping on counterstrike. lowend graphics, relatively small levels and small max player amounts, and some 56kers find it impossible to play. PLUS CS netcode is 'optimized' all shapes. take into account, this i sbeing programmed in VB, plus, the HUGE level size and, if pedestrians are to be left out, the lack of enteties occupying the area, the max players for mta would have to be 32+. Ever played americas army on a 512k line ? ping can reach 100+ on the fastest of 32 player servers. note: americas army netcode is also professionally programmed and optimized. VB comes with many limitations, especially in this area.

Link to comment

ya thats tru. but this is in vb, and it uses winsoc. the at least need to do the netcode in C.

heres another posible solution:

-net code is in c. if 5 players are on screen (including oneself) it syncs maximun 25 traffic.

-that way there would be no more laq than if all 30 ppl were on screen

-so the server has a program running in the background, which keeps track of 100 cars per island..

-each island is given a grid.

-based on where your car is on the grid, in shows the cars that match. + other players.

-so the server sends out data max 30 to each person.. no more lag than usual

-if there are 10 players on screen, there can only be 20 traffic.

-if there is 10 players and 22 traffic, the extra 2 cars are blown up.. this way all remaind synced, low lag.

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...