Changeset 50e6c7a in network-game


Ignore:
Timestamp:
Sep 26, 2013, 1:51:26 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
99afbb8
Parents:
b8f789d
Message:

The client stores and displays a list of existing games

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    rb8f789d r50e6c7a  
    118118chat chatConsole, debugConsole;
    119119bool debugging;
     120vector<string> games;
    120121
    121122MessageProcessor msgProcessor;
     
    421422                     // right now, this code will target all players other than the current one
    422423                     target = &it->second;
    423                      if (target->id != curPlayerId && target->team != curPlayer->team) {
     424                     if (target->id != curPlayerId && target->team != curPlayer->team)
     425                     {
    424426                        msgTo.type = MSG_TYPE_START_ATTACK;
    425427                        memcpy(msgTo.buffer, &curPlayerId, 4);
     
    448450            wndCurrent->draw(display);
    449451
    450          if(wndCurrent == wndGame) {
     452         if (wndCurrent == wndLobby) {
     453            for (int i=0; i<games.size(); i++) {
     454               al_draw_text(font, al_map_rgb(0, 255, 0), SCREEN_W*1/4-100, 120+i*15, ALLEGRO_ALIGN_LEFT, games[i].c_str());
     455            }
     456         }
     457         else if (wndCurrent == wndGame)
     458         {
    451459            if (!debugging)
    452460               chatConsole.draw(font, al_map_rgb(255,255,255));
     
    779787               cout << "Received a PROJECTILE message" << endl;
    780788
    781                int id, x, y, targetId;
     789               unsigned int id, x, y, targetId;
    782790
    783791               memcpy(&id, msg.buffer, 4);
     
    803811
    804812               int id;
    805 
    806813               memcpy(&id, msg.buffer, 4);
    807814               
     
    810817               break;
    811818            }
     819            case MSG_TYPE_GAME_INFO:
     820            {
     821                cout << "Received a GAME_INFO message" << endl;
     822
     823               string name(msg.buffer+4);
     824               int numPlayers;
     825
     826               memcpy(&numPlayers, msg.buffer, 4);
     827               
     828               cout << "Received game info for " << name << " (num players: " << numPlayers << ")" << endl;
     829               games.push_back(name);
     830
     831               break;
     832            }
    812833            default:
    813834            {
    814835               cout << "(STATE_LOBBY) Received invlaid message of type " << msg.type << endl;
     836
    815837               break;
    816838            }
Note: See TracChangeset for help on using the changeset viewer.