Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TiStar

Player data on client computer?

This topic is 6080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!