Changeset bc70282 in network-game
- Timestamp:
- Jul 27, 2013, 5:58:33 PM (11 years ago)
- Branches:
- master
- Children:
- 297682c
- Parents:
- c4c2a3c
- Location:
- client/Client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/chat.cpp
rc4c2a3c rbc70282 28 28 { 29 29 vctChat.push_back(s); 30 } 31 32 void chat::clear() { 33 vctChat.clear(); 30 34 } 31 35 -
client/Client/chat.h
rc4c2a3c rbc70282 23 23 void draw(ALLEGRO_FONT *font, ALLEGRO_COLOR color); 24 24 void addLine(string s); 25 void clear(); 25 26 26 27 bool handleEvent(ALLEGRO_EVENT e); -
client/Client/main.cpp
rc4c2a3c rbc70282 395 395 wndCurrent->draw(display); 396 396 397 chatConsole.draw(font, al_map_rgb(255,255,255));398 399 397 if(wndCurrent == wndMain) { 398 chatConsole.draw(font, al_map_rgb(255,255,255)); 399 400 400 al_draw_text(font, al_map_rgb(0, 255, 0), 4, 43, ALLEGRO_ALIGN_LEFT, "Message:"); 401 401 … … 558 558 break; 559 559 } 560 default: 561 { 562 cout << "(STATE_REGISTER) Received invalid message of type " << msg.type << endl; 563 break; 564 } 565 } 566 567 break; 568 } 569 case STATE_LOGIN: 570 { 571 switch(msg.type) 572 { 560 573 case MSG_TYPE_LOGIN: 561 574 { 562 575 if (response.compare("Player has already logged in.") == 0) 563 576 { 564 username.clear(); 565 cout << "User login failed" << endl; 577 goToLoginScreen(); 578 state = STATE_START; 579 566 580 lblLoginStatus->setText(response); 567 581 } 568 582 else if (response.compare("Incorrect username or password") == 0) 569 583 { 570 username.clear(); 571 cout << "User login failed" << endl; 584 goToLoginScreen(); 585 state = STATE_START; 586 572 587 lblLoginStatus->setText(response); 573 588 } 574 589 else 575 590 { 576 state = STATE_LOGIN;577 591 wndCurrent = wndMain; 578 592 … … 585 599 cout << "Player id: " << curPlayerId << endl; 586 600 cout << "Player health: " << p.health << endl; 587 cout << " map size: " << mapPlayers.size() << endl;601 cout << "player map size: " << mapPlayers.size() << endl; 588 602 } 589 590 break;591 }592 case MSG_TYPE_PLAYER:593 {594 Player p("", "");595 p.deserialize(msg.buffer);596 p.timeLastUpdated = getCurrentMillis();597 598 mapPlayers[p.id] = p;599 600 break;601 }602 case MSG_TYPE_OBJECT:603 {604 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);605 o.deserialize(msg.buffer);606 cout << "object id: " << o.id << endl;607 gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);608 609 break;610 }611 default:612 {613 cout << "(STATE_REGISTER) Received invlaid message of type " << msg.type << endl;614 break;615 }616 }617 618 break;619 }620 case STATE_LOGIN:621 {622 switch(msg.type)623 {624 case MSG_TYPE_LOGIN:625 {626 cout << "Got a login message" << endl;627 628 chatConsole.addLine(response);629 cout << "Added new line" << endl;630 603 631 604 break; … … 639 612 cout << "Logged out" << endl; 640 613 state = STATE_START; 614 chatConsole.clear(); 641 615 goToLoginScreen(); 642 616 } … … 657 631 p.isDead = false; 658 632 659 cout << mapPlayers[p.id].pos.x << ", " << mapPlayers[p.id].pos.y << endl;660 cout << "health:" << mapPlayers[p.id].health << endl;661 cout << "is dead?:" << mapPlayers[p.id].isDead << endl;662 633 mapPlayers[p.id] = p; 663 cout << mapPlayers[p.id].pos.x << ", " << mapPlayers[p.id].pos.y << endl;664 cout << "health:" << mapPlayers[p.id].health << endl;665 cout << "is dead?:" << mapPlayers[p.id].isDead << endl;666 634 667 635 break; … … 693 661 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0); 694 662 o.deserialize(msg.buffer); 663 cout << "object id: " << o.id << endl; 695 664 gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y); 696 665 … … 925 894 } 926 895 896 // maybe need a goToGameScreen function as well and add state changes to these functions as well 897 927 898 void registerAccount() 928 899 { … … 973 944 974 945 msgProcessor.sendMessage(&msgTo, sock, &server); 946 947 state = STATE_LOGIN; 975 948 } 976 949
Note:
See TracChangeset
for help on using the changeset viewer.