| 662 | } |
| 663 | |
| 664 | void Player::upkeepPlayer(double timeSinceLastUpkeep) |
| 665 | { |
| 666 | decreaseSpellCooldowns(); |
| 667 | |
| 668 | // Specific stuff for human players |
| 669 | if(!getIsHuman()) |
| 670 | return; |
| 671 | |
| 672 | // Handle fighting time |
| 673 | bool wasFightHappening = false; |
| 674 | bool isFightHappening = false; |
| 675 | bool isEventListUpdated = false; |
| 676 | for(auto it = mEvents.begin(); it != mEvents.end();) |
| 677 | { |
| 678 | PlayerEvent* event = *it; |
| 679 | if(event->getType() != PlayerEventType::fight) |
| 680 | { |
| 681 | ++it; |
| 682 | continue; |
| 683 | } |
| 684 | |
| 685 | wasFightHappening = true; |
| 686 | |
| 687 | float timeRemain = event->getTimeRemain(); |
| 688 | if(timeRemain > timeSinceLastUpkeep) |
| 689 | { |
| 690 | isFightHappening = true; |
| 691 | timeRemain -= timeSinceLastUpkeep; |
| 692 | event->setTimeRemain(timeRemain); |
| 693 | ++it; |
| 694 | continue; |
| 695 | } |
| 696 | |
| 697 | // This event is outdated, we remove it |
| 698 | isEventListUpdated = true; |
| 699 | delete event; |
| 700 | it = mEvents.erase(it); |
| 701 | } |
| 702 | |
| 703 | if(wasFightHappening && !isFightHappening) |
| 704 | { |
| 705 | // Notify the player he is no longer under attack. |
| 706 | ServerNotification *serverNotification = new ServerNotification( |
| 707 | ServerNotificationType::playerNoMoreFighting, this); |
| 708 | ODServer::getSingleton().queueServerNotification(serverNotification); |
| 709 | } |
| 710 | |
| 711 | // Do not notify skill queue empty if no library |
| 712 | if(getIsHuman() && |
| 713 | !getHasLost() && |
| 714 | (getSeat()->getNbRooms(RoomType::library) > 0)) |
| 715 | { |
| 716 | if(mNoSkillInQueueTime > timeSinceLastUpkeep) |
| 717 | mNoSkillInQueueTime -= timeSinceLastUpkeep; |
| 718 | else |
| 719 | { |
| 720 | mNoSkillInQueueTime = 0.0f; |
| 721 |
no test coverage detected