well about the p2p based thing. its sorta tricky but i threw together an approach which is still somewhat comprehensive.
Cyan: hee… well now you did it make sure to read everything… or else you wont get dinner
first off: to keep things simple lets keep the gameworld mostly flat so we can work with 2 dimensions. more are possible but make things unneccssary complicated. you could reduce the dimensions to 1 , which would help a lot in understanding. i might do so later on.
the most basic idea is that every client is a server at the same time, and only deals with other clients/servers which are close to him (in the sense of “their avatars are close to each other in the game world”) so it performs a few tasks of sharing and redirecting data.
that’s all there is… but now for the more interesting part of the idea
so lets assume we have a level. first we do is divide it into spaces. an easy way is to split horizontally then vertically , horizontally , and so on. this would be called binary space partitioning. so we can roughly tell where the player is located based on which side of each split he is. there number of splits depends on mapsize. it doesnt matter if you split a few times too often.
well now take the smallest area you got from this slice. lets call it “area” for convenience.
well now we have players. a player always is in one specific area. that’s ok. but not very suited for later purpose. so lets extend the region in which a player belongs to an “area”. make it twice as big, center at the same spot. lets call this area “sharingArea”. so a player is usualy in 4 “sharingAreas” at the same time.
now… more preperations. every client, is not only a client. but also a server.
to keep things simple we use an login server to let the clients meet each other once.
after than its getting tricky. first we need a “netsplit” value which decides how many players can co-exist in a region before they are re-grouped into smaller groups.
and even more preperations. each area has its own “server” , which is basically only a client handling a at most the number of clients set by netsplit.
other clients can send data to this one, and he will share it amongst the clients in his area. if he has more clients then specified by the netsplit value, the clients will get grouped by the area they are in. one of the clients of the old group will become a “groupserver”. the old groupserver will also send his data to the newly create child-groupserver. this groupserver will share data again.if he getes some.
now more tricky stuff. if a groupserver gets a package. he will redirect to all his clients which are on the “closer” side of the map-splitting thing. (its easy to dertermine based on the area-code and avoids that data gets shared all over ) after redirecting he will send a message back to the original sender that his package was send to him, with his own address. so the original sender can send his next data directly to the groupserver in charge for the closest neighburing area.
to understand this it’s neccessary to understand the sending machanism. i’ll try to explain with an example.
this is quite easy, there always is at least one group per game, even if only one player is present. the clients send a request to the groupserver, the groupserver then returns 2 lists with adresses, the one contains all clients which are in the current group, so to say, the list where the data is send directly without beeing redirected. and a list with groupservers which would typically be the closest servers around on the groupserver (logic wise). each address comes with the area code belonging to it. groupserver addresses have a “deepth”" so their area code is missing the most “detailed” part. it only contains the area code up to the place where they are responsible for managing the data.
the mechanism works like this:
first client connects. joins the world, the login server keeps his address data.
the client is all alone, he becomes a “areaServer”, calculating what’s his “area” , and all “sharingAreas” he’s in. then he checks if other clients are connected he could share his data with.
nothing to do.
then a second cliend connects. the loginserver gives the address from clien1 to client2.
client1 and client2 connect to each other.both calculate their area and sharing area. sending data to each other.both check each others “area” value and check if they have childGroups. no child groups present. everything is clean and simple
more clients connect. and at some point a first netsplit happens. a subgroup is created.
now lets say client9 is the groupserver of the subgroub.
client 5,6,7,8,9 are in the subgroup and 1,2,3,4,9 in the original group. as groupserver the client9 is defacto part of the subgroup AND the groub at the same time.
so if client 1 now sends data to his group-members, client9 will receive it, and send it to his clients which are closest to client1 … all based on the area codes.
more stuff is waiting. if now a client of a subgroup (which is nothing else than a group with a parentgroup, code is the same) has data to send, he sends it to his group members. he also will send his data to the group-server. the groupserver will check if there are neighburing groupservers he knows about, or if the closest neighbors are already part of his group. if he cant find a neighboring groupserver, he will redirect the data to his groupserver again, if one is present. this one will do the same. until either the top is reached, or a neighboring groupserver is found. if one is found the data is send to him, this one will then send the data to his closes childs again, and a message back to the oringinal sender to let him know he is the closet match found for the path the data took until now. now if there are groupservers amongst the receivers of the server which was found as neighburing groupservers, they will again send their data to the closest neighbor and again a message back to the original sender.
this continues until the last branch was reached.
this can cause the first package to take quite a detour. but since the client got noticed about who is his closest neighbor groupserver. the next package from him can be send directly to him, which then gets distributed, so during normal operation the data makes only a single “hop”.
since it can happen that a groupserver disconnected , the process will continue once again do search for closest neighbors.
in case a groupserver just moved away so it’s not longer the “closest” match, he will just notify the client he got some data from and tell him to find someone else in his case.
if a group loses members for what reason ever, groupservers can cancel the group, and merge their clients with the topgroup.
well the whole thing is tricky, but still reasonable small to understand it. your application should be very timing-uncritical. the whole thing can be used to share things like movement data, player properties such as outfit, inventory, stats etc.
presistent data is not meant to be shared with this system. so player accounts, items lying around etc are not part of the whole thing. same with npc’s, which could run as pseudo-clients in the same network.
if a system for storing data such as accounts etc is used, clients can start to monitor each other actions to prevent cheating in a limited manner.
since clients can see what other clients are doing they can “check” on their actions. so things like … the lvl of a player jumped without a reason, the other clients can “suspect” him and log the actions in question. is suspect is grave, the logs can be send to a gamemaster or admin which can manually check the data if this is really bad, and take further steps.
if you leave away the human judging and just check if other clients data are conform to the own simulation you can get a self-evolving system if enough people hack their own client.
well enough for now. if you are still intrested in such an brainmelting idea lemme know. i’ll try to somehow visualize the thing so one can actually imagine what’s going on.
now that it’s 1am, and now that i made at least a dozens of gramatical errors. i’ll go to bed and have some rest^ thx for reading, in case you did i wouldn’t have done it if i where you