| 1472 | } |
| 1473 | |
| 1474 | void Seat::setSkillTree(const std::vector<SkillType>& skills) |
| 1475 | { |
| 1476 | if(mGameMap->isServerGameMap()) |
| 1477 | { |
| 1478 | // We check if all the skills in the vector are allowed. If not, we don't update the list |
| 1479 | std::vector<SkillType> skillsDoneInTree = mSkillDone; |
| 1480 | for(SkillType skillType : skills) |
| 1481 | { |
| 1482 | // We check if the skill is allowed |
| 1483 | if(std::find(mSkillNotAllowed.begin(), mSkillNotAllowed.end(), skillType) != mSkillNotAllowed.end()) |
| 1484 | { |
| 1485 | // Invalid skill. This might be allowed in the gui to enter invalid |
| 1486 | // values. In this case, we should remove the assert |
| 1487 | OD_LOG_ERR("Unallowed skill: " + Skills::toString(skillType)); |
| 1488 | return; |
| 1489 | } |
| 1490 | const Skill* skill = SkillManager::getSkill(skillType); |
| 1491 | if(skill == nullptr) |
| 1492 | { |
| 1493 | // We found an unknown skill |
| 1494 | OD_LOG_ERR("Unknown skill: " + Skills::toString(skillType)); |
| 1495 | return; |
| 1496 | } |
| 1497 | |
| 1498 | if(!skill->canBeSkilled(skillsDoneInTree)) |
| 1499 | { |
| 1500 | // Invalid skill. This might happen if the level has a skill pending with a non skillable dependency. |
| 1501 | // In this case, we don't use the skill tree |
| 1502 | OD_LOG_ERR("Unallowed skill: " + Skills::toString(skillType)); |
| 1503 | return; |
| 1504 | } |
| 1505 | |
| 1506 | // This skill is valid. We add it in the list and we check if the next one also is |
| 1507 | skillsDoneInTree.push_back(skillType); |
| 1508 | } |
| 1509 | |
| 1510 | mSkillPending = skills; |
| 1511 | if((getPlayer() != nullptr) && getPlayer()->getIsHuman()) |
| 1512 | { |
| 1513 | // We notify the client |
| 1514 | ServerNotification *serverNotification = new ServerNotification( |
| 1515 | ServerNotificationType::skillTree, getPlayer()); |
| 1516 | |
| 1517 | uint32_t nbItems = mSkillPending.size(); |
| 1518 | serverNotification->mPacket << nbItems; |
| 1519 | for(SkillType skill : mSkillPending) |
| 1520 | serverNotification->mPacket << skill; |
| 1521 | |
| 1522 | ODServer::getSingleton().queueServerNotification(serverNotification); |
| 1523 | } |
| 1524 | |
| 1525 | // We start working on the skill tree |
| 1526 | setNextSkill(SkillType::nullSkillType); |
| 1527 | } |
| 1528 | else |
| 1529 | { |
| 1530 | // On client side, no need to check if the skill tree is allowed |
| 1531 | mSkillPending = skills; |
no test coverage detected