Changeset 753fa8a in network-game
- Timestamp:
- Aug 3, 2013, 1:13:25 AM (11 years ago)
- Branches:
- master
- Children:
- f419b09
- Parents:
- f9cb9fb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
rf9cb9fb r753fa8a 112 112 113 113 MessageProcessor msgProcessor; 114 ofstream outputLog; 114 115 115 116 int main(int argc, char **argv) … … 127 128 bool fullscreen = false; 128 129 debugging = false; 129 ofstream outputLog;130 130 131 131 scoreBlue = 0; … … 322 322 msgTo.type = MSG_TYPE_PICKUP_FLAG; 323 323 memcpy(msgTo.buffer, &curPlayerId, 4); 324 msgProcessor.sendMessage(&msgTo, sock, &server );324 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 325 325 } 326 326 break; … … 347 347 msgTo.type = MSG_TYPE_DROP_FLAG; 348 348 memcpy(msgTo.buffer, &curPlayerId, 4); 349 msgProcessor.sendMessage(&msgTo, sock, &server );349 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 350 350 } 351 351 } … … 370 370 memcpy(msgTo.buffer+8, &pos.y, 4); 371 371 372 msgProcessor.sendMessage(&msgTo, sock, &server );372 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 373 373 } 374 374 else … … 397 397 memcpy(msgTo.buffer+4, &target->id, 4); 398 398 399 msgProcessor.sendMessage(&msgTo, sock, &server );399 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 400 400 } 401 401 } … … 404 404 } 405 405 406 if (msgProcessor.receiveMessage(&msgFrom, sock, &from ) >= 0)406 if (msgProcessor.receiveMessage(&msgFrom, sock, &from, &outputLog) >= 0) 407 407 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId, scoreBlue, scoreRed); 408 408 … … 411 411 redraw = false; 412 412 413 msgProcessor.resendUnackedMessages(sock );414 //msgProcessor.cleanAckedMessages( );413 msgProcessor.resendUnackedMessages(sock, &outputLog); 414 //msgProcessor.cleanAckedMessages(&outputLog); 415 415 416 416 if (debugging && wndCurrent == wndMain) … … 958 958 memcpy(msgTo.buffer+username.size()+password.size()+2, &playerClass, 4); 959 959 960 msgProcessor.sendMessage(&msgTo, sock, &server );960 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 961 961 } 962 962 … … 975 975 strcpy(msgTo.buffer+username.size()+1, strPassword.c_str()); 976 976 977 msgProcessor.sendMessage(&msgTo, sock, &server );977 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 978 978 979 979 state = STATE_LOGIN; … … 989 989 strcpy(msgTo.buffer, username.c_str()); 990 990 991 msgProcessor.sendMessage(&msgTo, sock, &server );991 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 992 992 } 993 993 … … 1007 1007 strcpy(msgTo.buffer, msg.c_str()); 1008 1008 1009 msgProcessor.sendMessage(&msgTo, sock, &server );1009 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 1010 1010 } 1011 1011 … … 1032 1032 void drawMessageStatus(ALLEGRO_FONT* font) 1033 1033 { 1034 int clientMsgOffset = 0; 1035 int serverMsgOffset = 650; 1036 1037 al_draw_text(font, al_map_rgb(0, 255, 255), 5, 43, ALLEGRO_ALIGN_LEFT, "ID"); 1038 al_draw_text(font, al_map_rgb(0, 255, 255), 25, 43, ALLEGRO_ALIGN_LEFT, "Type"); 1039 al_draw_text(font, al_map_rgb(0, 255, 255), 245, 43, ALLEGRO_ALIGN_LEFT, "Acked?"); 1040 1041 al_draw_text(font, al_map_rgb(0, 255, 255), 5+serverMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "ID"); 1042 al_draw_text(font, al_map_rgb(0, 255, 255), 25+serverMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "Type"); 1034 int clientMsgOffset = 5; 1035 int serverMsgOffset = 950; 1036 1037 al_draw_text(font, al_map_rgb(0, 255, 255), 0+clientMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "ID"); 1038 al_draw_text(font, al_map_rgb(0, 255, 255), 20+clientMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "Type"); 1039 al_draw_text(font, al_map_rgb(0, 255, 255), 240+clientMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "Acked?"); 1040 1041 al_draw_text(font, al_map_rgb(0, 255, 255), serverMsgOffset, 43, ALLEGRO_ALIGN_LEFT, "ID"); 1043 1042 1044 1043 map<unsigned int, map<unsigned long, MessageContainer> >& sentMessages = msgProcessor.getSentMessages(); … … 1066 1065 ossAcked << boolalpha << acked; 1067 1066 1068 al_draw_text(font, al_map_rgb(0, 255, 0), 5, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossId.str().c_str());1069 al_draw_text(font, al_map_rgb(0, 255, 0), 2 5, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, typeStr.c_str());1070 al_draw_text(font, al_map_rgb(0, 255, 0), 24 5, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossAcked.str().c_str());1067 al_draw_text(font, al_map_rgb(0, 255, 0), clientMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossId.str().c_str()); 1068 al_draw_text(font, al_map_rgb(0, 255, 0), 20+clientMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, typeStr.c_str()); 1069 al_draw_text(font, al_map_rgb(0, 255, 0), 240+clientMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossAcked.str().c_str()); 1071 1070 1072 1071 msgCount++; … … 1074 1073 } 1075 1074 1076 map<unsigned int, MessageContainer>& ackedMessages = msgProcessor.getAckedMessages(); 1077 map<unsigned int, MessageContainer>::iterator it3; 1078 1079 msgCount = 0; 1080 for (it3 = ackedMessages.begin(); it3 != ackedMessages.end(); it3++) { 1081 ossId.str("");; 1082 ossId << it3->first; 1083 1084 string typeStr = MessageContainer::getMsgTypeString(it3->second.getMessage()->type); 1085 1086 al_draw_text(font, al_map_rgb(255, 0, 0), 5+serverMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossId.str().c_str()); 1087 al_draw_text(font, al_map_rgb(255, 0, 0), 25+serverMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, typeStr.c_str()); 1088 1089 msgCount++; 1090 } 1091 } 1075 if (msgProcessor.getAckedMessages().size() > 0) { 1076 map<unsigned int, unsigned long long> ackedMessages = msgProcessor.getAckedMessages()[0]; 1077 map<unsigned int, unsigned long long>::iterator it3; 1078 1079 msgCount = 0; 1080 for (it3 = ackedMessages.begin(); it3 != ackedMessages.end(); it3++) { 1081 ossId.str("");; 1082 ossId << it3->first; 1083 1084 al_draw_text(font, al_map_rgb(255, 0, 0), 25+serverMsgOffset, 60+15*msgCount, ALLEGRO_ALIGN_LEFT, ossId.str().c_str()); 1085 1086 msgCount++; 1087 } 1088 } 1089 }
Note:
See TracChangeset
for help on using the changeset viewer.