Changeset d519032 in network-game


Ignore:
Timestamp:
Sep 27, 2013, 6:20:43 PM (11 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
master
Children:
233e736
Parents:
88258c9
Message:

Reorganized the client-side game creation logic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r88258c9 rd519032  
    549549
    550550   delete gameMap;
    551    delete game;
     551
     552   if (game != NULL)
     553      delete game;
    552554
    553555   al_destroy_event_queue(event_queue);
     
    654656      }
    655657      case STATE_LOBBY:
     658         cout << "In STATE_LOBBY" << endl;
    656659      case STATE_GAME:
    657660      {
     
    743746            case MSG_TYPE_OBJECT:
    744747            {
    745                cout << "Received object message in STATE_LOBBY." << endl;
     748               cout << "Received OBJECT message" << endl;
    746749
    747750               WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
     
    845848               break;
    846849            }
     850            case MSG_TYPE_JOIN_GAME_SUCCESS:
     851            {
     852               cout << "Received a JOIN_GAME_SUCCESS message" << endl;
     853
     854               string gameName(msg.buffer);
     855               
     856               cout << "Game name: " << gameName << endl;
     857               
     858               game = new Game(gameName);
     859
     860               state = STATE_NEW_GAME;
     861
     862               msgTo.type = MSG_TYPE_JOIN_GAME_ACK;
     863               strcpy(msgTo.buffer, gameName.c_str());
     864
     865               msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog);
     866
     867               break;
     868            }
     869            case MSG_TYPE_JOIN_GAME_FAILURE:
     870            {
     871               cout << "Received a JOIN_GAME_FAILURE message" << endl;
     872
     873               break;
     874            }
    847875            default:
    848876            {
     
    857885      case STATE_NEW_GAME:
    858886      {
     887         cout << "(STATE_NEW_GAME) ";
    859888         switch(msg.type)
    860889         {
    861890            case MSG_TYPE_GAME_INFO:
    862891            {
    863                cout << "(STATE_NEW_GAME) Received a GAME_INFO message" << endl;
     892               cout << "Received a GAME_INFO message" << endl;
    864893
    865894               string gameName(msg.buffer+4);
    866895               int numPlayers;
    867 
    868                //game = new Game(gameName);
    869896
    870897               memcpy(&numPlayers, msg.buffer, 4);
     
    878905            case MSG_TYPE_OBJECT:
    879906            {
    880                cout << "(STATE_NEW_GAME) Received object message in STATE_LOBBY." << endl;
     907               cout << "Received object message in STATE_NEW_GAME" << endl;
    881908
    882909               WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
     
    889916            case MSG_TYPE_REMOVE_OBJECT:
    890917            {
    891                cout << "(STATE_NEW_GAME) Received REMOVE_OBJECT message!" << endl;
     918               cout << "Received REMOVE_OBJECT message!" << endl;
    892919
    893920               int id;
     
    921948            default:
    922949            {
    923                cout << "(STATE_NEW_GAME) Received invalid message of type " << msg.type << endl;
     950               cout << "Received invalid message of type " << msg.type << endl;
    924951
    925952               break;
     
    12601287   cout << "Creating game" << endl;
    12611288
    1262    // hack to help transitions to multiple games
    1263    state = STATE_NEW_GAME;
    1264    game = new Game( txtCreateGame->getStr());
    1265 
    12661289   string msg = txtCreateGame->getStr();
    12671290   txtCreateGame->clear();
    12681291
     1292   cout << "Sending message: " << msg.c_str() << endl;
     1293
    12691294   msgTo.type = MSG_TYPE_CREATE_GAME;
    12701295   strcpy(msgTo.buffer, msg.c_str());
Note: See TracChangeset for help on using the changeset viewer.