Main Page   Data Structures   File List   Globals  

get_other_players.c File Reference

Finds the other players on the wireless network. More...

#include "white_interface.h"

Go to the source code of this file.

Functions

char * strcpy (char *to, const char *from)
 C standard library function. More...

int strcmp (const char *str1, const char *str2)
 C standard library function. More...

void poin_entry_Init ()
 VCC Init function. More...

void poin_entry_Run ()
 VCC Run function. More...


Variables

char player_name_array [20][20]
 An array of player names. More...

char player_count = 0
 The number of other players on the network. More...


Detailed Description

Finds the other players on the wireless network.

get_other_players sends the name of the local user to the other game machines so that they can build up a list of opponents to display in their lobby.

It then receives the names of the other players (sent from the other lobby modules) and sends them to the start_game block. Also, the names are sent to the graphics module as PrintString messages so that they are listed on the lobby screen.

Definition in file get_other_players.c.


Function Documentation

void poin_entry_Init  
 

VCC Init function.

This function runs when the VCC simulation is first started.

Definition at line 85 of file get_other_players.c.

00086 {
00087   lobby_message my_name;
00088   PrintString title;
00089 
00090   /* print title of lobby screen. */
00091 
00092   title.text = "Stratego Lobby";
00093   title.x = 1;
00094   title.y = 9;
00095   print_out_Post(&title);
00096 
00097   /* Get the player name from the VCC parameter
00098      PlayerName, and construct a lobby_message. */
00099 
00100   my_name.player_name = PlayerName_Value();
00101   my_name.message = "name";
00102 
00103   /* send player name to the other machines
00104      on the network. */
00105 
00106   net_out_Post(&my_name);
00107 }

void poin_entry_Run  
 

VCC Run function.

This runs whenever a message arrives at any of the input ports.

Definition at line 115 of file get_other_players.c.

References player_count, player_name_array, strcmp, and strcpy.

00116 {
00117   PrintString graphics_out;
00118   lobby_message other_player;
00119 
00120   if (net_in_Enabled())
00121   {
00122     /* if a player name lobby_message arrives, add the name
00123        to the list of possible opponents and increment the
00124        count of the number of other players on the network. */
00125 
00126     other_player = *net_in_Value();
00127     if (strcmp(other_player.message, "name") == 0)
00128     {
00129       player_count++;
00130       strcpy(player_name_array[player_count], other_player.player_name);
00131 
00132       /* now send the player name to start_game block */
00133 
00134       players_out_Post(player_name_array[player_count]);
00135 
00136       /* draw the name on the screen at the next available
00137          line. */
00138 
00139       graphics_out.text = player_name_array[player_count];
00140       graphics_out.x = 1;
00141       graphics_out.y = 8 - (player_count);
00142 
00143       print_out_Post(&graphics_out);
00144     }
00145   }
00146 }

int strcmp const char *    str1,
const char *    str2
 

C standard library function.

Compares two strings.

Parameters:
str1  A pointer to the first string.
str2  A pointer to the second string.
Returns:
An integer (0 if the string are equal).

char* strcpy char *    to,
const char *    from
 

C standard library function.

Copies one string to another.

Parameters:
to  A pointer to the destination string.
from  A pointer to the source string.
Returns:
A pointer to the string.


Variable Documentation

char player_count = 0
 

The number of other players on the network.

This stores the number of player name messages that have been received and should be equal to the number of other players on the wireless network.

Definition at line 48 of file get_other_players.c.

Referenced by poin_entry_Run.

char player_name_array[20][20]
 

An array of player names.

This stores the names of the other players on the network as an array of strings.

Definition at line 40 of file get_other_players.c.

Referenced by poin_entry_Run.


Copyright © 2002 Andrew Bates
Last Updated 04/04/02