Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Constand multiplayer update (x,y,z,etc)

Author
Message
AluminumPork
21
Years of Service
User Offline
Joined: 28th Oct 2003
Location: Duluth, MN, USA
Posted: 19th Jan 2004 05:18
I've been working on a top-down 3D military game. It's coming along VERY nicely. But the main aspect of the game will be multiplayer, and while I'm not very new to DB Enhanced, I'm very new to the multiplayer aspect of it. I thought I had it figured out when I was able to write a simple chat prog from scratch. But when I tried to adapt the same principal to the game, it failed.

Here's basically what I'm trying to do:

do
if net game exists() = 1
perform checklist for net players
if checklist quantity() > 0 then player = 1
get net message
if net message exists() = 1
Tank_X#(2) = val(net message string$()
endif
position object 2,Tank_X#(2),Tank_Y#(2),Tank_Z#(2)
endif

if checklist quantity() > 0
send net message integer 1,object position x(1)
endif

loop

Of course there's a whole bunch of other stuff, but that's basically all my multiplayer component has. I was only testing it on the X axis to see if I could anything to move. But alas, nothing. . Any body have some words of wisdom?

Thanks a bunch
Porky
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 19th Jan 2004 15:02
don't try to send a network message every loop. Use some kind of delay timer. Perform a ping test every now and then (about every 1-2 minutes) to determine how much od a lag time you have and try not to send a message faster than the lag time.

There is no need to perform a checklist for net players during the game, unless you detect a player entering/leaving...

Create a global array for multiplayer data and reference that array from the checklist values... Place all checklist values into this array as you will need them. The most common data is the local ID number (LID for short) and the unique ID number (UID). Do not confuse these. UID is the actual ID a users has for a connection to a game and is unique for each users. The LID is only unique to the current machine, meaning player 2 on computer 2 may have a different UID than player 2 on computer 3 which is caused by each player 2 being a different actual user. But, there can be only one UID, but its non-squential and can't be directly used for arrays while the LID is well suited for arrays.

When checking net message from, that will give you the LID and you can use this information to look up or update other data in the array.

have a cup of coffee and think about what was said here.

You will need to become comfortable with not knowing exactly which computer is actually the real player 1 (if each player starts in a different spot). One option is for each computer to scan through the array of users using the LID and make a sorting note of actual player connection order by checking the UID values. The real player 1 will have the lowest UID while the last player will have the highest UID.

OR....

You could have the host computer send out a message to all players informing thier computer which one is 1,2,3,4 based upon the LID list on the host machine.... Just remember that this list will never match the LID list on client machines where they think that user 1 is the client and 2 is the host .....

So..... in summary
in your array you must track at least
PID - the actual player ID (player 1,2,3,...)
as determined by your game
LID - Order of user connections
Use this to reference the array
UID - Actual user ID unique to all users
determined as users connect to the host
HOST- Identifies this user as the current host
This can change as the game goes on....
Name- A string to store the players name
MID - Memblock ID you use to receive memblock data
can also be used to send data if this is the current user
PING- Ping time for user
MTIM- Message Time. Time that next message will be sent
or that the last message was recieved.

internet gaming group
current project http://home.comcast.net/~norman.perry/Archon.html
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 19th Jan 2004 15:35
detailed, and quite helpful thanks for that it sorted out a few things for me

Login to post a reply

Server time is: 2025-05-22 19:24:09
Your offset time is: 2025-05-22 19:24:09