|
Main Page Data Structures File List Globals
start_game.c File ReferenceStarts the network game.
More...
#include "white_interface.h"
Go to the source code of this file.
Detailed Description
Starts the network game.
This block is the core of the lobby module. If the user selects an opponent in the lobby screen, start_game sends a lobby_message asking to start a game with the chosen player. It then assigns a player number to the local core module (this will be 0 as this lobby module has initiated the network game). Finally the screen is cleared and a trigger is sent to the relay_MouseClicks block so that user input is forwarded to the input module rather than the lobby.
start_game also waits for requests from other players to play a network game with them. If a lobby_message is received asking the local user to play, a player number of 1 is assigned to the core module (because this lobby did not initiate the game). As before, the screen is cleared and mouse input is redirected to the input module.
The final possibility is that a lobby_message is received that requests a game between 2 other players. In this case, the local machine should observe the game. It does this by assigning a player number of 2 to the core. The core then does nothing except display the moves of other players.
Definition in file start_game.c.
Function Documentation
|
VCC Init function.
This function runs when the VCC simulation is first started.
Definition at line 68 of file start_game.c.
|
|
VCC Run function.
This runs whenever a message arrives at any of the start_game block's input ports.
Definition at line 78 of file start_game.c.
References player_count, player_name_array, strcmp, and strcpy.
00079 {
00080 int other_player;
00081 lobby_message request_play;
00082 lobby_message message_in;
00083
00084
00085
00086
00087
00088 if (players_in_Enabled())
00089 {
00090 player_count++;
00091 strcpy(player_name_array[player_count], players_in_Value());
00092 }
00093
00094
00095
00096
00097
00098 if (line_in_Enabled())
00099 {
00100 other_player = line_in_Value();
00101 if (other_player <= player_count)
00102 {
00103
00104
00105 request_play.player_name = MyName_Value();
00106 request_play.message = player_name_array[other_player];
00107 net_out_Post(&request_play);
00108
00109
00110
00111
00112 player_no_out_Post(0);
00113
00114
00115
00116
00117 trigger_out_Post(1);
00118
00119
00120
00121 clear_out_Post(1);
00122 }
00123 }
00124
00125
00126
00127
00128
00129 if (net_in_Enabled())
00130 {
00131 message_in = *net_in_Value();
00132
00133 if (strcmp(message_in.message, "name") != 0)
00134 {
00135 if (strcmp(message_in.message, MyName_Value()) == 0)
00136 {
00137
00138
00139
00140
00141
00142 player_no_out_Post(1);
00143 }
00144 else
00145 {
00146
00147
00148
00149
00150
00151
00152 player_no_out_Post(2);
00153 }
00154
00155
00156
00157
00158 trigger_out_Post(1);
00159
00160
00161
00162 clear_out_Post(1);
00163 }
00164 }
00165 }
|
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).
Referenced by poin_entry_Run. |
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.
Referenced by poin_entry_Run. |
Variable Documentation
|
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 60 of file start_game.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 52 of file start_game.c.
Referenced by poin_entry_Run. |
|
|