Changes in / [8cbeffc:033c78b] in network-game


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/MessageProcessor.cpp

    r8cbeffc r033c78b  
    3232   msg->id = ++lastUsedId;
    3333   MessageContainer message(*msg, *dest);
    34    message.setTimeSent(getCurrentMillis());
    3534
    3635   if (outputLog)
     
    108107   map<unsigned int, map<unsigned long, MessageContainer> >::iterator it;
    109108   map<unsigned long, MessageContainer>::iterator it2;
    110    map<unsigned long, MessageContainer>* sentMsg;
     109   map<unsigned long, MessageContainer> sentMsg;
    111110
    112111   for (it = sentMessages.begin(); it != sentMessages.end(); it++) {
    113 
    114       unsigned long long maxAge = 0;
    115       sentMsg = &(it->second);
    116 
    117       for (it2 = sentMsg->begin(); it2 != sentMsg->end(); it2++) {
     112      sentMsg = it->second;
     113      for (it2 = sentMsg.begin(); it2 != sentMsg.end(); it2++) {
    118114         if (!(it2->second.getAcked())) {
    119             cout << "Maybe resending message" << endl;
    120             cout << "time sent: " << it2->second.getTimeSent() << endl;
    121             unsigned long long age = getCurrentMillis() - it2->second.getTimeSent();
    122 
    123             cout << "age: " << age << endl;
    124             if (maxAge < age) {
    125                 maxAge = age;
    126                 cout << "new max age: " << maxAge << endl;
    127             }
    128 
    129             if (maxAge > 10000) {
    130                cout << "id " << it2->second.getMessage()->id << " is not getting acked" << endl;
    131                // this will prevent the message from getting resent anymore
    132                it2->second.setAcked(true);
    133                cout << "acked after being set: " << it2->second.getAcked() << endl;
    134             }
    135 
    136115            sendto(sock, (const char*)it2->second.getMessage(), sizeof(NETWORK_MSG), 0, (struct sockaddr *)&it2->first, sizeof(struct sockaddr_in));
    137116         }
    138       }
    139 
    140       if (maxAge > 10000) {
    141          cout << "Connection lost" << endl;
    142117      }
    143118   }
Note: See TracChangeset for help on using the changeset viewer.