[project1dev] Re: networking pirate dice woes

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: project1dev@xxxxxxxxxxxxx
  • Date: Sat, 13 Feb 2010 09:34:38 -0800

Hey Kent,

Totally understandable about your shift in time usage.  I figure i'll take
on some of the scripting tasks but leave the important stuff like networked
pirate dice to you.

If anything becomes uber important and you dont have time to do it, i have
no problem takin it over so we should be fine (:

Ok, about the network stuff hrmms...

#1 - GetServerList: well first things first, i added the network script
functions to the script help documents.  Have you seen those?  If so were
they not too helpful?  If not let me know, maybe i need to document things
better.

Anyhow, GetServerList is only useful for searching for existing servers.
 Theres another function for creating servers but you are right, you would
change the string to PirateDice and thats all you need to do to make it work
for pirate dice.

#2 - SendChat: yeah this is the only place it sends to the server.  For the
success thing, basically what thats about is every network function returns
whether or not it was successful.  If it wasn't, you should display an error
message to the player and then bail out of the game.  The reasons it wouldnt
be successful is like if they unplugged their internet cable or something.

#3 - OnNetworkMessage: This guy is called by the game whenever it receives a
network message from the server.  How network messages work is you send a
message to the server which consists of "MessageName" and "MessageValue".
 After it gets to the server, the server sends it down to all of the
clients, including the person who sent the message in the first place.
 OnNetworkMessage is called once for each message received so that you can
respond to the message (like if someone raised a bet, you can update the pot
size).  Everyone receives messages in the same order (:

Since messages have both a name and a value you can do something like all
chat messages have the message name "Chat" and all message values are what
the person typed for chat.

For when anyone takes a turn you might make a message named "TakeTurn" and
then have the message value be something like "call", "fold", "raise 10"
etc.

OnNetworkMessage also receives messages when players join or leave.

Also each network message (i think... going from memory) give you both the
name of the player, as well as a "PlayerID" which is a unique ID# associated
with that player (if its ever useful to know, this ID# is always the same
for the same player, it's like an account number).

Does this help at all?

On Sat, Feb 13, 2010 at 2:05 AM, Kent Petersen <kentkmp@xxxxxxxxx> wrote:

> Tonight is the first time I really spent any time on the network code and
> let me tell you I am confused as hell. If I follow along the lobby code I
> can make enough sense of it but when it comes time for me to recreate it I
> can't get shit to work right. I can get it to log in to a server by copying
> the "Join chat server" section of the lobby code but I don't really
> understand what to do from there.
>
> Here are some questions off the top of my head
>
> in the "Join chat server" section I think I would want to change
> GameServer_GetServerList("Chat") to GameServer_GetServerList("Pirate Dice")
> I think this would cause the game to join the game server Pirate Dice. Am I
> right?
>
> is the function SendChat the only point in the code where the player can
> send information to the server? I don't really get the success= part?
>
> I also don't really understand the OnNetworkMessage part. I think it has
> something to do with sending messages to the server and out to the players
> but I don't see how it does it. I understand that the bottom portion of
> OnNetworkMessage is updating the chatroom. Pirate Dice should probably have
> an in game chat.
>
>
>
>
> I want to start Pirate Dice. Have a button for join network game. This will
> look through for a list of servers and then create one if there is nothing
> available. Like the lobby, I believe. Pirate Dice will then begin as it does
> now.
>
> Somehow I want the players name and ID to be assigned to the player value.
> For example Player1 will say Atrix.
>
> Somehow I want the players game choices to get sent to the server and back
> to the players. The information that should be sent would, the choice they
> made (raise, bluff, call), what they have in their hand (pair, three of a
> kind), and any money information (amount raised, raising to the called
> amount)
>
>
>
> Between work and school I just don't have a lot of time to invest right
> now. So this is mostly for discussion and to get my brain thinking. I love
> working on this stuff I do it for fun and relaxation these days. I might be
> able to squeeze some time in on the weekends or if I finally get ahead on
> homework. The workload will definitely drop as I get the hang of my job and
> as I finish off my internet classes.
> Any help is greatly appreciated.
>

Other related posts: