Changeset f9cb9fb in network-game
- Timestamp:
- Aug 3, 2013, 12:52:15 AM (11 years ago)
- Branches:
- master
- Children:
- 753fa8a
- Parents:
- 8271c78
- Location:
- common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
common/MessageProcessor.cpp
r8271c78 rf9cb9fb 50 50 }else { 51 51 bool isDuplicate = false; 52 map<unsigned int, unsigned long long>& ackedPlayerMessages = ackedMessages[source->sin_addr.s_addr]; 52 53 53 if (acked Messages.find(msg->id) != ackedMessages.end()) {54 if (ackedPlayerMessages.find(msg->id) != ackedPlayerMessages.end()) { 54 55 isDuplicate = true; 55 56 cout << "Got duplicate of type " << msg->type << endl; 57 if (outputLog) 58 (*outputLog) << "Received duplicate (id " << msg->id << ") of type " << MessageContainer::getMsgTypeString(msg->type) << endl; 56 59 }else { 57 60 cout << "Got message of type " << msg->type << endl; … … 60 63 } 61 64 62 ackedMessages[msg->id] = MessageContainer(*msg, *source); 63 ackedMessages[msg->id].setAcked(true); 64 ackedMessages[msg->id].setTimeAcked(getCurrentMillis()); 65 ackedPlayerMessages[msg->id] = getCurrentMillis(); 65 66 66 67 NETWORK_MSG ack; … … 116 117 } 117 118 118 /*119 map<unsigned int, unsigned long long>::iterator it 3 = ackedMessages.begin();119 map<unsigned long, map<unsigned int, unsigned long long> >::iterator it3 = ackedMessages.begin(); 120 map<unsigned int, unsigned long long>::iterator it4; 120 121 122 // somehow want to delete the inner map once that player logs out 121 123 while (it3 != ackedMessages.end()) { 122 if ((getCurrentMillis() - it3->second) > 500) 123 ackedMessages.erase(it3++); 124 else 125 it3++; 124 it4 = it3->second.begin(); 125 while (it4 != it3->second.end()) { 126 if ((getCurrentMillis() - it4->second) > 500) 127 it3->second.erase(it4++); 128 else 129 it4++; 130 } 131 it3++; 126 132 } 127 */128 133 } 129 134 … … 132 137 } 133 138 134 map<unsigned int, MessageContainer>& MessageProcessor::getAckedMessages() {139 map<unsigned long, map<unsigned int, unsigned long long> >& MessageProcessor::getAckedMessages() { 135 140 return this->ackedMessages; 136 141 } -
common/MessageProcessor.h
r8271c78 rf9cb9fb 15 15 map<unsigned int, map<unsigned long, MessageContainer> > sentMessages; 16 16 17 // map from message ids to the time each mesage was acked18 map<unsigned int, MessageContainer> ackedMessages;17 // map from player address to map from message id to time accked 18 map<unsigned long, map<unsigned int, unsigned long long> > ackedMessages; 19 19 20 20 unsigned long pid; … … 30 30 31 31 map<unsigned int, map<unsigned long, MessageContainer> >& getSentMessages(); 32 map<unsigned int, MessageContainer>& getAckedMessages();32 map<unsigned long, map<unsigned int, unsigned long long> >& getAckedMessages(); 33 33 }; 34 34
Note:
See TracChangeset
for help on using the changeset viewer.