Index: client/Client/main.cpp
===================================================================
--- client/Client/main.cpp	(revision 88258c9e56aa143248e3dd3c900fc0b5a8458307)
+++ client/Client/main.cpp	(revision d519032c3dacb9a09f64fdf0dce1a3e7f1d1d1a2)
@@ -549,5 +549,7 @@
 
    delete gameMap;
-   delete game;
+
+   if (game != NULL)
+      delete game;
 
    al_destroy_event_queue(event_queue);
@@ -654,4 +656,5 @@
       }
       case STATE_LOBBY:
+         cout << "In STATE_LOBBY" << endl;
       case STATE_GAME:
       {
@@ -743,5 +746,5 @@
             case MSG_TYPE_OBJECT:
             {
-               cout << "Received object message in STATE_LOBBY." << endl;
+               cout << "Received OBJECT message" << endl;
 
                WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
@@ -845,4 +848,29 @@
                break;
             }
+            case MSG_TYPE_JOIN_GAME_SUCCESS:
+            {
+               cout << "Received a JOIN_GAME_SUCCESS message" << endl;
+
+               string gameName(msg.buffer);
+               
+               cout << "Game name: " << gameName << endl;
+               
+               game = new Game(gameName);
+
+               state = STATE_NEW_GAME;
+
+               msgTo.type = MSG_TYPE_JOIN_GAME_ACK;
+               strcpy(msgTo.buffer, gameName.c_str());
+
+               msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog);
+
+               break;
+            }
+            case MSG_TYPE_JOIN_GAME_FAILURE:
+            {
+               cout << "Received a JOIN_GAME_FAILURE message" << endl;
+
+               break;
+            }
             default:
             {
@@ -857,14 +885,13 @@
       case STATE_NEW_GAME:
       {
+         cout << "(STATE_NEW_GAME) ";
          switch(msg.type)
          {
             case MSG_TYPE_GAME_INFO:
             {
-               cout << "(STATE_NEW_GAME) Received a GAME_INFO message" << endl;
+               cout << "Received a GAME_INFO message" << endl;
 
                string gameName(msg.buffer+4);
                int numPlayers;
-
-               //game = new Game(gameName);
 
                memcpy(&numPlayers, msg.buffer, 4);
@@ -878,5 +905,5 @@
             case MSG_TYPE_OBJECT:
             {
-               cout << "(STATE_NEW_GAME) Received object message in STATE_LOBBY." << endl;
+               cout << "Received object message in STATE_NEW_GAME" << endl;
 
                WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
@@ -889,5 +916,5 @@
             case MSG_TYPE_REMOVE_OBJECT:
             {
-               cout << "(STATE_NEW_GAME) Received REMOVE_OBJECT message!" << endl;
+               cout << "Received REMOVE_OBJECT message!" << endl;
 
                int id;
@@ -921,5 +948,5 @@
             default:
             {
-               cout << "(STATE_NEW_GAME) Received invalid message of type " << msg.type << endl;
+               cout << "Received invalid message of type " << msg.type << endl;
 
                break;
@@ -1260,11 +1287,9 @@
    cout << "Creating game" << endl;
 
-   // hack to help transitions to multiple games
-   state = STATE_NEW_GAME;
-   game = new Game( txtCreateGame->getStr());
-
    string msg = txtCreateGame->getStr();
    txtCreateGame->clear();
 
+   cout << "Sending message: " << msg.c_str() << endl;
+
    msgTo.type = MSG_TYPE_CREATE_GAME;
    strcpy(msgTo.buffer, msg.c_str());
