Changes in / [cdb4bec:e607c0f] in network-game


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    rcdb4bec re607c0f  
    9494   set_nonblock(sock);
    9595
    96    bool broadcastResponse;
     96   bool broadcastMessage;
    9797   while (true) {
    9898
     
    104104         cout << "Got a message" << endl;
    105105
    106          broadcastResponse = processMessage(clientMsg, from, vctPlayers, serverMsg);
     106         broadcastMessage = processMessage(clientMsg, from, vctPlayers, serverMsg);
    107107
    108108         cout << "msg: " << serverMsg.buffer << endl;
    109109
    110          if (broadcastResponse)
    111          {
    112             cout << "Should be broadcasting the message" << endl;
    113 
     110         if (broadcastMessage)
     111         {
    114112            vector<Player>::iterator it;
    115113
     
    122120         else
    123121         {
    124             cout << "Should be sending back the message" << endl;
    125 
    126122            if ( sendMessage(&serverMsg, sock, &from) < 0 )
    127123               error("sendMessage");
     
    143139   cout << "MSG contents: " << clientMsg.buffer << endl;
    144140
    145    // maybe we should make a message class and have this be a member
    146141   bool broadcastResponse = false;
    147142
     
    191186
    192187            vctPlayers.push_back(newP);
    193             strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with other players.");
     188            strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with outher players.");
    194189         }
    195190
     
    226221      case MSG_TYPE_CHAT:
    227222      {
    228          cout << "Got a chat message" << endl;
    229 
    230223         Player *p = findPlayerByAddr(vctPlayers, from);
    231224
     
    239232
    240233            stringstream ss;
    241             ss << p->name << ": " << clientMsg.buffer;
     234            ss << p->name << ": " << clientMsg.buffer << endl;
    242235
    243236            strcpy(serverMsg.buffer, ss.str().c_str());
     
    256249         break;
    257250      }
    258    }
    259 
    260    return broadcastResponse;
    261 }
    262 
     251
     252      return broadcastResponse;
     253   }
     254}
Note: See TracChangeset for help on using the changeset viewer.