MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / SyncClientSharedTaskWithPersistedState

Method SyncClientSharedTaskWithPersistedState

zone/task_manager.cpp:1630–1716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1628}
1629
1630void TaskManager::SyncClientSharedTaskWithPersistedState(Client *c, ClientTaskState *cts)
1631{
1632 auto character_tasks = CharacterTasksRepository::GetWhere(
1633 database,
1634 fmt::format("charid = {} ORDER BY acceptedtime", c->CharacterID())
1635 );
1636
1637 for (auto &character_task: character_tasks) {
1638 if (character_task.type == TASK_TYPE_SHARED) {
1639 auto st = SharedTaskMembersRepository::GetWhere(
1640 database,
1641 fmt::format(
1642 "character_id = {}",
1643 c->CharacterID()
1644 )
1645 );
1646
1647 if (!st.empty()) {
1648 int64 shared_task_id = st[0].shared_task_id;
1649 auto activities = SharedTaskActivityStateRepository::GetWhere(
1650 database,
1651 fmt::format(
1652 "shared_task_id = {}",
1653 shared_task_id
1654 )
1655 );
1656
1657 ClientTaskInformation *shared_task = nullptr;
1658 shared_task = &cts->m_active_shared_task;
1659
1660 // has active shared task
1661 if (cts->HasActiveSharedTask()) {
1662
1663 LogTasksDetail(
1664 "[SyncClientSharedTaskWithPersistedState] Client [{}] has shared_task, sync with database",
1665 c->GetCleanName()
1666 );
1667
1668 bool fell_behind_state = false;
1669 for (auto &a: activities) {
1670
1671 LogTasksDetail(
1672 "shared_task loop local [{}] shared [{}]",
1673 shared_task->activity[a.activity_id].done_count,
1674 a.done_count
1675 );
1676
1677 // we're behind shared task state, update self
1678 if (shared_task->activity[a.activity_id].done_count < a.done_count) {
1679
1680 // update done count
1681 shared_task->activity[a.activity_id].done_count = a.done_count;
1682
1683 // activity state
1684 shared_task->activity[a.activity_id].activity_state =
1685 (a.completed_time > 0 ? ActivityCompleted : ActivityHidden);
1686
1687 // flag to update character_activities table entry on save

Callers

nothing calls this directly

Calls 9

HasActiveSharedTaskMethod · 0.80
AddReplayTimerMethod · 0.80
RewardTaskMethod · 0.80
SetSharedTaskIdMethod · 0.80
CharacterIDMethod · 0.45
emptyMethod · 0.45
GetCleanNameMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected