Main Page   Data Structures   File List   Globals  

get_other_players.c

Go to the documentation of this file.
00001 #include "white_interface.h"
00002 
00024 char * strcpy (char *to, const char *from);
00025 
00033 int strcmp(const char *str1, const char *str2);
00034 
00040 char player_name_array[20][20];
00041 
00048 char player_count = 0;
00049 
00050 
00084 /* Init Function */
00085 void poin_entry_Init()
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 }
00108 
00109 
00114 /* Run Function */
00115 void poin_entry_Run()
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 }

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