summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2011-01-29 18:27:21 +0100
committerReiner Herrmann <reiner@reiner-h.de>2011-01-29 18:27:21 +0100
commit8d219b75b365b406e300fc9f404809576d18b5fb (patch)
tree380e559b74ef6eb3b69305114c8e854cfba5cdbc
parenta301310bef5706273148fd10d05d7666bc8f5838 (diff)
parent40d93396350dc0cf87b8694691aaad5f5499cd1b (diff)
Merge branch 'master' of ssh://wg.reiner-h.de:22003/~git/oxen
-rw-r--r--src/client_game_states.c2
-rw-r--r--src/data_store.c1
-rw-r--r--src/game.c3
-rw-r--r--src/main.c5
-rw-r--r--src/net/server.c5
-rw-r--r--src/server_game_states.c6
6 files changed, 15 insertions, 7 deletions
diff --git a/src/client_game_states.c b/src/client_game_states.c
index a60fc52..4786ae9 100644
--- a/src/client_game_states.c
+++ b/src/client_game_states.c
@@ -97,7 +97,7 @@ game_state_t state_client_play_cards(const int sock)
uint8_t stack_idx = get_stack_idx_for_card(&ds->table_stacks, c);
bool our_turn = (ds->player_list.players[i].player_id == ds->own_player_id);
- ui_display_wnd_messages("Placing cards...", false);
+ ui_display_wnd_messages("Placing cards ...", false);
ui_display_wnd_current_state(&ds->player_list, ds->player_list.count, true, i, ple->score);
ui_update();
diff --git a/src/data_store.c b/src/data_store.c
index 3d5d440..69baed9 100644
--- a/src/data_store.c
+++ b/src/data_store.c
@@ -5,7 +5,6 @@
static data_store_t *d = NULL;
-// returns global data store
/**
* Returns pointer to global data_store object.
* Creates it at first call.
diff --git a/src/game.c b/src/game.c
index e3eeff5..203d2fe 100644
--- a/src/game.c
+++ b/src/game.c
@@ -146,7 +146,6 @@ void start_game(const bool servermode, const char* addr, const char* port, const
client_socks.player_ids[i] = i+1;
data->player_list.players[i].player_id = i+1;
net_send(client_socks.sockets[i], msg_type_hello_s, &data->player_list.players[i]);
- printf("Player connected: %s\n", data->player_list.players[i].player_name);
}
for(int i = 0; i < num_players; i++)
@@ -168,7 +167,7 @@ void start_game(const bool servermode, const char* addr, const char* port, const
sock = client_connect_server(addr, port);
if(sock != -1)
break;
- usleep(300000); // wait 300 ms before retry
+ sleep(1); // wait one second before retry
}
if(sock == -1)
{
diff --git a/src/main.c b/src/main.c
index 217c1e1..ffae6e2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,6 +27,11 @@ static void print_usage(const char* name)
exit(EXIT_FAILURE);
}
+/**
+ * The application's entry point.
+ * @param[in] argc The number of arguments passed
+ * @param[in] argv The array of passed arguments
+*/
int main(int argc, char *argv[])
{
int opt;
diff --git a/src/net/server.c b/src/net/server.c
index cc6c438..27fbd14 100644
--- a/src/net/server.c
+++ b/src/net/server.c
@@ -104,6 +104,8 @@ void server_get_players(int serversock, socket_list_t* client_socks, const uint8
assert(count <= MAX_PLAYERS && count > 0);
+ printf("Waiting for %d players to connect ...\n", count);
+
// accept connections
for(i=0; i<count; i++)
{
@@ -116,9 +118,10 @@ void server_get_players(int serversock, socket_list_t* client_socks, const uint8
exit(EXIT_FAILURE);
}
//printf("new client connected: %s\n", inet_ntop(sock.ss_family, get_in_addr((struct sockaddr*)&sock), INET6_ADDRSTRLEN));
- printf("new client connected (%d/%d)\n", i+1, count);
}
client_socks->count = count;
+
+ printf("All players connected. Starting game!\n");
}
/**
diff --git a/src/server_game_states.c b/src/server_game_states.c
index c605e48..4f9268a 100644
--- a/src/server_game_states.c
+++ b/src/server_game_states.c
@@ -8,6 +8,7 @@
* Game state handler. If it is the first round, the server takes cards from the main stack and places them onto the table, as table stacks. The server then sends the table stacks to all players. After this, the hands for the players will be drawn from the main stack and sent to the players. On returning from the function, a state transition occurs.
* @param[in] client_socks The client sockets used for communication
* @param[in] round The current round of the game
+ * @param[in,out] m The used main stack
* @return STATE_SERVER_WAIT_FOR_OPEN_CARDS The next state after dealing hand cards
*/
game_state_t state_server_deal_hand_cards(const socket_list_t *client_socks, const uint8_t round, main_stack_t *m)
@@ -91,8 +92,9 @@ game_state_t state_server_wait_for_open_cards(const socket_list_t *client_socks)
/**
* Game state handler. In this state, the server tries to play all open cards. If a player's card is smaller than all the cards on the stacks, the player has to choose a stack. Receive the player's chosen stack, replace it with his open card and increment the player's score. If the player's card fits on a stack, but the stack is already full, then replace the stack with the card, and add the stack points to the player's points.
- * If the players still have hand cards, then wait for chosen open cards from players. If the players do not have anymore hand cards and the mainstack has enough cards to deal every player at least one card, then deal new hand cards. Otherwise the game has finished.
- * @param[in] sock The server socket that is read/written to
+ * If the players still have hand cards, then wait for chosen open cards from players. If the players do not have anymore hand cards and the main stack has enough cards to deal every player at least one card, then deal new hand cards. Otherwise the game has finished.
+ * @param[in] client_socks The client sockets used for communication
+ * @param[in,out] m The used main stack
* @return STATE_SERVER_WAIT_FOR_OPEN_CARDS The next state, if the players still have hand cards
* @return STATE_SERVER_DEAL_HAND_CARDS The next state, if the main stack has at least one card for each player left. The server will then deal those cards
* @return STATE_SERVER_GAME_FINISHED The next state, if the main stack is empty