Advertisement

Player data on client computer?

Started by April 19, 2002 09:15 AM
4 comments, last by TiStar 22 years, 9 months ago
I have two situations where I don''t really know what the best thing to do is. Maybe someone just could give me a little hint. 1. Say I have a game where the server, on startup, should be able to decide how many players can join the game. From start the client never really knows how many other players there will be. How should I store the the data of the other players on each client? Should I use a linked list or should I send the "MAX_PLAYERS" number to the client on connection and then the client creates an array? (the last one isn''t a good solution I guess) If linked lists is the answer, does anyone know a good site with a tutorial or something on these? 2. What should I let the server do (in both "many-player-games" and "a-few-players-games")? Should the server manage all collision dections and things like that and then just send the info to the players? If this is the case, should the client just send a request to the server that he wants to move and let the server do the acctual moving, or should the client move and let the server check if his new position is vailed? I hope I didn''t explain it to complicated.
Hey there!

1. Well, linked lists is the best way.

struct my_list
{
int val;
my_list *next;
my_list *prev;
};

my_list *head,*tail;

void AddNode(mylist *newNode);

void main()
{
my_list node;
node= new my_list;
node->val=10
AddNode(node);
}

void AddNode(mylist *newNode)
{
if(head==NULL)
{
head=newNode;
newNode->nex=NULL;
head->prev=NULL;
}
else
{
tail->next=newMode;
newNode->prev=tail;
}

tail=newNode;
tail->next=NULL;
}

This is the basic, there might be errors since i made this on the run, so try to find more info..
The head ponter is the pointer for the start and the tail (duh!) for the end.

2. Try making a thread for each player on the server side to avoid cheating.. but it might cause lag :D
on the client side just receive and "paint it"

Hope this was of any help
Advertisement
Ok, hmm I''d look into learning STL (Standard Template Librar) Really, there are a number of great pre-fab ADTs (Abstract Data Types) that have dynamic data allocation that can grow and shrink as you need them to. Im not making any judgments on if anyones implementation of a linked list is better then STLs or visa versa. Just the fact that STL speeds up development when your trying to get a prototype done. Lets face it, writing linked lists is not the funnest aspect of game programming.
It only takes a quick google search to figure out how to use STL''s list and vector classes. Once you''ve used them once or twice you''ll use them all the time. They really do make things easier.
Thanks for your replies!

Should I use linked lists on the server too, or should I settle with an array of the players? (The number maximum players will never change while the server is running)
If I use linked lists on the clientside it''s maybe a good idea to use the same system on the server too?
This isn''t me trying to be rude... but I see questions like this all the time. I don''t see how you can even think about building a client / server system without having a good understanding of data structures. Basically, I understand the desire to get right into making a game when you''re learning to program, but it''s sort of putting the cart before the horse to try to tackle games (especially multiplayer games) before understanding data structures and the basics of the language you''re using.
I really love people that makes you feel good about trying to do something at all. I really feel like being creativ today!

[edited by - TiStar on April 19, 2002 8:47:57 PM]

This topic is closed to new replies.

Advertisement