diff --git a/src/client/main.c b/src/client/main.c index 72ea098..ec5b139 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) { if (errflag < 0) err__crash("Failed to connect to host"); - msg__login_req(&sockfd, "username", "passwd"); + msg__req_login(&sockfd, "username", "passwd"); while (1) { bzero(msgbuffer, sizeof msgbuffer); diff --git a/src/server/command.c b/src/server/command.c index 76dc490..e2053e7 100644 --- a/src/server/command.c +++ b/src/server/command.c @@ -1,6 +1,6 @@ #include "command.h" -Room *cmd__move(move_directions direction, Room *current_room) { +Room *cmd__move(move_direction direction, Room *current_room) { switch (direction) { case NORTH: return current_room->north; diff --git a/src/server/command.h b/src/server/command.h index 27569d1..b9becd1 100644 --- a/src/server/command.h +++ b/src/server/command.h @@ -6,4 +6,4 @@ // Returns pointer to new room based on current room and direction If room // doesn't exist returns NULL -Room *cmd__move(move_directions direction, Room *current_room); +Room *cmd__move(move_direction direction, Room *current_room); diff --git a/src/server/main.c b/src/server/main.c index 9c63465..904f363 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) { cli_sockfd = msg__accept_cli_connection(serv_sockfd); // Require login as first request - msg__handle_login(&serv_sockfd); + msg__recv_login(&serv_sockfd); while (1) { // Empty message buffer diff --git a/urchin-util/include/message.h b/urchin-util/include/message.h index bece632..48e3ba1 100644 --- a/urchin-util/include/message.h +++ b/urchin-util/include/message.h @@ -21,10 +21,10 @@ void msg__destroy_connection(int sockfd); int msg__accept_cli_connection(int server_sockfd); // Handle logins -void msg__handle_login(int *con_sockfd); -void msg__login_req(int *con_sockfd, char *usernm, char *passwd); +void msg__recv_login(int *con_sockfd); +void msg__req_login(int *con_sockfd, char *usernm, char *passwd); // send and recive commands -void msg__handle_command(int *con_sockfd); -void msg__command_req(int *con_sockfd, char *usernm, char *passwd); +void msg__recv_command(int *con_sockfd); +void msg__req_command(int *con_sockfd, char *usernm, char *passwd); diff --git a/urchin-util/include/world_structures.h b/urchin-util/include/world_structures.h index 147355b..48268e5 100644 --- a/urchin-util/include/world_structures.h +++ b/urchin-util/include/world_structures.h @@ -2,7 +2,7 @@ // Make world structures accessible to both server and client // Define moveable directions -typedef enum { NORTH, EAST, SOUTH, WEST } move_directions; +typedef enum { NORTH, EAST, SOUTH, WEST } move_direction; // Define what a room is. typedef struct room { diff --git a/urchin-util/protobuf/commands.proto b/urchin-util/protobuf/commands.proto new file mode 100644 index 0000000..f360082 --- /dev/null +++ b/urchin-util/protobuf/commands.proto @@ -0,0 +1,6 @@ +syntax = "proto2"; + +message command { + optional int32 move_direction = 1; // For now this int directly maps onto the enum type + // TODO: Add other optional structures to be processed as command data +} diff --git a/urchin-util/src/message.c b/urchin-util/src/message.c index 041a02f..f644eb9 100644 --- a/urchin-util/src/message.c +++ b/urchin-util/src/message.c @@ -1,4 +1,5 @@ #include "message.h" +#include "world_structures.h" #include "protobuf_gen/amessage.pb-c.h" #include "protobuf_gen/player.pb-c.h" @@ -43,7 +44,7 @@ void msg__amsg_test(int a) { amessage__free_unpacked(msg2, NULL); } -void msg__handle_login(int *con_sockfd) { +void msg__recv_login(int *con_sockfd) { uint8_t msgbuf[MAX_MSG_SIZE]; bzero(msgbuf, sizeof msgbuf); @@ -65,7 +66,7 @@ void msg__handle_login(int *con_sockfd) { err__log(msg); } -void msg__login_req(int *con_sockfd, char *usernm, char *passwd) { +void msg__req_login(int *con_sockfd, char *usernm, char *passwd) { PlayerLogin pl = PLAYER_LOGIN__INIT; void *msgbuf; unsigned len;