Changeset 35d702d in network-game


Ignore:
Timestamp:
Feb 2, 2015, 1:48:53 AM (10 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
master
Children:
13a8212, 45c9d0f
Parents:
d58e3c3
Message:

When a player tries to create a game using the name of an existing game, the client displays an error message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    rd58e3c3 r35d702d  
    6161void createGui(ALLEGRO_FONT* font);
    6262
    63 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers, map<string, int>& mapGames, unsigned int& curPlayerId);
     63void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers, map<string, int>& mapGames, unsigned int& curPlayerId, string& alertMessage);
    6464void handleMsgPlayer(NETWORK_MSG &msg, map<unsigned int, Player*>& mapPlayers, map<string, int>& mapGames);
    6565void handleMsgGameInfo(NETWORK_MSG &msg, map<unsigned int, Player*>& mapPlayers, map<string, int>& mapGames);
     
    147147MessageProcessor msgProcessor;
    148148
     149string alertMessage;
     150
    149151int main(int argc, char **argv)
    150152{
     
    169171   numGames = 0;
    170172   gameHistory = NULL;
     173
     174   alertMessage = "";
    171175
    172176   state = STATE_START;
     
    401405
    402406      if (msgProcessor.receiveMessage(&msgFrom, &from) >= 0)
    403          processMessage(msgFrom, state, chatConsole, mapPlayers, mapGames, curPlayerId);
     407         processMessage(msgFrom, state, chatConsole, mapPlayers, mapGames, curPlayerId, alertMessage);
    404408
    405409      if (redraw)
     
    442446               i++;
    443447            }
     448
     449            al_draw_text(font, al_map_rgb(0, 255, 0), SCREEN_W/2, 15, ALLEGRO_ALIGN_CENTER, alertMessage.c_str());
    444450         }
    445451         else if (wndCurrent == wndProfile)
     
    821827}
    822828
    823 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers, map<string, int>& mapGames, unsigned int& curPlayerId)
     829void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers, map<string, int>& mapGames, unsigned int& curPlayerId, string& alertMessage)
    824830{
    825831   cout << "Total players in map: " << mapPlayers.size() << endl;
     
    10031009               break;
    10041010            }
     1011            case MSG_TYPE_CREATE_GAME_FAILURE:
     1012            {
     1013               cout << "Received a CREATE_GAME_FAILURE message" << endl;
     1014               alertMessage = "Game could not be created because one exists with that name";
     1015
     1016               break;
     1017            }
    10051018            case MSG_TYPE_PLAYER:
    10061019            {
     
    10871100               state = STATE_LOBBY;
    10881101               wndCurrent = wndGameSummary;
     1102               alertMessage = "";
    10891103
    10901104               break;
     
    14591473
    14601474   state = STATE_LOBBY;
     1475   alertMessage = "";
    14611476}
    14621477
     
    15891604   state = STATE_LOBBY;
    15901605   wndCurrent = wndLobby;
     1606   alertMessage = "";
    15911607
    15921608   msgTo.type = MSG_TYPE_LEAVE_GAME;
Note: See TracChangeset for help on using the changeset viewer.