470 lines
9.5 KiB
C++
470 lines
9.5 KiB
C++
#include "stdafx.h"
|
|
#include "SQuestMark.h"
|
|
#include "SQuestMgr.h"
|
|
#include "Enc.h"
|
|
#include <toolkit/bits_scramble.h>
|
|
#include "SQuestDB.h"
|
|
|
|
/*
|
|
*/
|
|
bool sQuestMark::existAnotherQuest(int id)
|
|
{
|
|
if (existAnotherQuest(id, false))
|
|
return true;
|
|
if (existAnotherQuest(id, true))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
/*
|
|
*/
|
|
bool sQuestMark::is(int id, bool checkQuestInProgress)
|
|
{
|
|
if (0 == id)
|
|
return false;
|
|
|
|
it_data it = m_list.find(id);
|
|
if (it == m_list.end())
|
|
return false;
|
|
|
|
if (!checkQuestInProgress)
|
|
return true;
|
|
|
|
std::vector<QuestBase::QuestCode>::iterator it_code = it->second.m_list.begin();
|
|
for (; it_code != it->second.m_list.end(); ++it_code)
|
|
{
|
|
unsigned char p = m_questMgr->GetQuestProgress(*it_code);
|
|
if (SQuestMgr::QUEST_IN_PROGRESS == p)
|
|
{
|
|
if (m_questMgr->isNotSuccess(id))
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
/*
|
|
*/
|
|
bool sQuestMark::checkOverCount(int& count)
|
|
{
|
|
++count;
|
|
if (1 < count) return true;
|
|
return false;
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMark::addList(int id, QuestBase::QuestCode code)
|
|
{
|
|
it_data it = m_list.find(id);
|
|
if (it == m_list.end())
|
|
{
|
|
m_list.insert(std::make_pair(id, sQuestCode(code)));
|
|
}
|
|
else
|
|
{
|
|
it->second.add(code);
|
|
}
|
|
}
|
|
|
|
void sQuestMark::delList(int id, QuestBase::QuestCode code)
|
|
{
|
|
it_data it = m_list.find(id);
|
|
if (it == m_list.end())
|
|
return ;
|
|
it->second.del(code);
|
|
if (it->second.empty())
|
|
{
|
|
m_list.erase(it);
|
|
}
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkProp::insertFromId(int id, QuestBase::QuestCode code)
|
|
{
|
|
if (0 == id)
|
|
return ;
|
|
|
|
addList(id, code);
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkProp::insertFromCode(QuestBase* quest)
|
|
{
|
|
if (0 != quest->mark_hide)
|
|
return ;
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkProp::removeFromCode(QuestBase* quest)
|
|
{
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkProp::removeFromId(int id, QuestBase::QuestCode code)
|
|
{
|
|
if (!is(id))
|
|
return ;
|
|
|
|
if (sQuestMark::existAnotherQuest(id))
|
|
return ;
|
|
|
|
delList(id, code);
|
|
}
|
|
/*
|
|
*/
|
|
bool sQuestMarkProp::existAnotherQuest(int id, bool isAuto)
|
|
{
|
|
int isCount = 0;
|
|
m_questMgr->iterBeginQuestList(isAuto);
|
|
for (; !m_questMgr->iterIsEndQuestList(isAuto); m_questMgr->iterNextQuestList())
|
|
{
|
|
QuestBase::QuestCode code = m_questMgr->iterDataQuestList();
|
|
|
|
QuestBase* base = GetQuestDB().GetQuestData( code );
|
|
if (!base)
|
|
continue;
|
|
|
|
if (QuestBase::QUEST_MARK_TARGET_PROP == base->show_target_type)
|
|
{
|
|
if (id == base->show_target_id)
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
*/
|
|
void sQuestMarkMob::insertFromId(int id, QuestBase::QuestCode code)
|
|
{
|
|
if (0 == id)
|
|
return ;
|
|
|
|
ENC_INT mobId = bits_scramble< int, 3 >( id );
|
|
int value = mobId.value();
|
|
|
|
addList(value, code);
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkMob::insertFromCode(QuestBase* quest)
|
|
{
|
|
if (0 != quest->mark_hide)
|
|
return ;
|
|
|
|
QuestBase::QuestCode code = quest->nCode;
|
|
QuestBase::QuestType type = quest->nType;
|
|
|
|
if (QuestBase::QuestType::QUEST_KILL_INDIVIDUAL == type ||
|
|
QuestBase::QuestType::QUEST_KILL_TOTAL == type)
|
|
{
|
|
insertFromId(quest->nValue[0], code);
|
|
insertFromId(quest->nValue[2], code);
|
|
insertFromId(quest->nValue[4], code);
|
|
}
|
|
else if (QuestBase::QuestType::QUEST_RANDOM_KILL_INDIVIDUAL == type)
|
|
{
|
|
insertFromId(m_questMgr->GetQuestRandomValue(code, 0), code);
|
|
insertFromId(m_questMgr->GetQuestRandomValue(code, 2), code);
|
|
insertFromId(m_questMgr->GetQuestRandomValue(code, 4), code);
|
|
}
|
|
else if (QuestBase::QuestType::QUEST_HUNT_ITEM == type)
|
|
{
|
|
insertFromId(quest->nValue[6], code);
|
|
insertFromId(quest->nValue[7], code);
|
|
insertFromId(quest->nValue[8], code);
|
|
insertFromId(quest->nValue[9], code);
|
|
insertFromId(quest->nValue[10], code);
|
|
insertFromId(quest->nValue[11], code);
|
|
}
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkMob::removeFromCode(QuestBase* quest)
|
|
{
|
|
QuestBase::QuestCode code = quest->nCode;
|
|
QuestBase::QuestType type = quest->nType;
|
|
|
|
if (QuestBase::QuestType::QUEST_KILL_INDIVIDUAL == type ||
|
|
QuestBase::QuestType::QUEST_KILL_TOTAL == type)
|
|
{
|
|
removeFromId(quest->nValue[0], code);
|
|
removeFromId(quest->nValue[2], code);
|
|
removeFromId(quest->nValue[4], code);
|
|
}
|
|
else if (QuestBase::QuestType::QUEST_RANDOM_KILL_INDIVIDUAL == type)
|
|
{
|
|
removeFromId(m_questMgr->GetQuestRandomValue(code, 0), code);
|
|
removeFromId(m_questMgr->GetQuestRandomValue(code, 2), code);
|
|
removeFromId(m_questMgr->GetQuestRandomValue(code, 4), code);
|
|
}
|
|
else if (QuestBase::QuestType::QUEST_HUNT_ITEM == type)
|
|
{
|
|
removeFromId(quest->nValue[6], code);
|
|
removeFromId(quest->nValue[7], code);
|
|
removeFromId(quest->nValue[8], code);
|
|
removeFromId(quest->nValue[9], code);
|
|
removeFromId(quest->nValue[10], code);
|
|
removeFromId(quest->nValue[11], code);
|
|
}
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkMob::removeFromId(int id, QuestBase::QuestCode code)
|
|
{
|
|
if (0 == id)
|
|
return ;
|
|
|
|
ENC_INT mobId = bits_scramble< int, 3 >( id );
|
|
int value = mobId.value();
|
|
if (!is(value))
|
|
return ;
|
|
|
|
if (sQuestMark::existAnotherQuest(id))
|
|
return ;
|
|
|
|
delList(value, code);
|
|
}
|
|
/*
|
|
*/
|
|
bool sQuestMarkMob::existAnotherQuest(int id, bool isAuto)
|
|
{
|
|
ENC_INT mobId = bits_scramble< int, 3 >( id );
|
|
int value = mobId.value();
|
|
|
|
/// 같은 몹이 2개 이상인지 체크
|
|
int isCount = 0;
|
|
m_questMgr->iterBeginQuestList(isAuto);
|
|
for (; !m_questMgr->iterIsEndQuestList(isAuto); m_questMgr->iterNextQuestList())
|
|
{
|
|
QuestBase::QuestCode code = m_questMgr->iterDataQuestList();
|
|
|
|
QuestBase* base = GetQuestDB().GetQuestData( code );
|
|
if (!base)
|
|
continue;
|
|
|
|
QuestBase::QuestType type = base->nType;
|
|
|
|
if (QuestBase::QuestType::QUEST_KILL_INDIVIDUAL == type ||
|
|
QuestBase::QuestType::QUEST_KILL_TOTAL == type)
|
|
{
|
|
if (id == base->nValue[0])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[2])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[4])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
}
|
|
else if (QuestBase::QuestType::QUEST_RANDOM_KILL_INDIVIDUAL == type)
|
|
{
|
|
if (id == m_questMgr->GetQuestRandomValue(code, 0))
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == m_questMgr->GetQuestRandomValue(code, 2))
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == m_questMgr->GetQuestRandomValue(code, 4))
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
}
|
|
else if (QuestBase::QuestType::QUEST_HUNT_ITEM == type)
|
|
{
|
|
if (id == base->nValue[6])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[7])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[8])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[9])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[10])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
if (id == base->nValue[11])
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (QuestBase::QUEST_MARK_TARGET_MOB == base->show_target_type)
|
|
{
|
|
if (value == base->show_target_id)
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
*/
|
|
void sQuestMarkNpc::insertFromId(int id, QuestBase::QuestCode code)
|
|
{
|
|
if (0 == id)
|
|
return ;
|
|
|
|
addList(id, code);
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkNpc::insertFromCode(QuestBase* quest)
|
|
{
|
|
if (0 != quest->mark_hide)
|
|
return ;
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkNpc::removeFromCode(QuestBase* quest)
|
|
{
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkNpc::removeFromId(int id, QuestBase::QuestCode code)
|
|
{
|
|
if (!is(id))
|
|
return ;
|
|
|
|
if (sQuestMark::existAnotherQuest(id))
|
|
return ;
|
|
|
|
delList(id, code);
|
|
}
|
|
/*
|
|
*/
|
|
bool sQuestMarkNpc::existAnotherQuest(int id, bool isAuto)
|
|
{
|
|
int isCount = 0;
|
|
m_questMgr->iterBeginQuestList(isAuto);
|
|
for (; !m_questMgr->iterIsEndQuestList(isAuto); m_questMgr->iterNextQuestList())
|
|
{
|
|
QuestBase::QuestCode code = m_questMgr->iterDataQuestList();
|
|
|
|
QuestBase* base = GetQuestDB().GetQuestData( code );
|
|
if (!base)
|
|
continue;
|
|
|
|
if (QuestBase::QUEST_MARK_TARGET_NPC == base->show_target_type)
|
|
{
|
|
if (id == base->show_target_id)
|
|
{
|
|
if (checkOverCount(isCount)) return true;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
*/
|
|
void sQuestMarkDropItem::insertFromCode(QuestBase* quest)
|
|
{
|
|
if (0 != quest->mark_hide)
|
|
return ;
|
|
|
|
QuestBase::QuestCode code = quest->nCode;
|
|
|
|
QuestBase::QuestType type = quest->nType;
|
|
if (QuestBase::QUEST_COLLECT != type)
|
|
return ;
|
|
|
|
for (int i = 0; i < QuestBase::MAX_VALUE_NUMBER; ++i)
|
|
{
|
|
int dropItemId = quest->nValue[i];
|
|
if (dropItemId && !is(dropItemId))
|
|
{
|
|
addList(dropItemId, code);
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
*/
|
|
void sQuestMarkDropItem::removeFromCode(QuestBase* quest)
|
|
{
|
|
QuestBase::QuestCode code = quest->nCode;
|
|
QuestBase::QuestType type = quest->nType;
|
|
|
|
if (QuestBase::QUEST_COLLECT != type)
|
|
return ;
|
|
|
|
for (int i = 0; i < QuestBase::MAX_VALUE_NUMBER; ++i)
|
|
{
|
|
int dropItemId = quest->nValue[i];
|
|
if (0 == dropItemId)
|
|
continue;
|
|
if (!is(dropItemId))
|
|
continue;
|
|
|
|
removeFromCodeFinding(quest, dropItemId, false);
|
|
removeFromCodeFinding(quest, dropItemId, true);
|
|
}
|
|
}
|
|
|
|
void sQuestMarkDropItem::removeFromCodeFinding(QuestBase* quest, int dropItemId, bool isAuto)
|
|
{
|
|
bool find = false;
|
|
QuestBase::QuestCode dropQuestCode = 0;
|
|
|
|
m_questMgr->iterBeginQuestList(isAuto);
|
|
for (; !m_questMgr->iterIsEndQuestList(isAuto); m_questMgr->iterNextQuestList())
|
|
{
|
|
QuestBase::QuestCode code = m_questMgr->iterDataQuestList();
|
|
|
|
QuestBase* quest_n = GetQuestDB().GetQuestData( code );
|
|
if (!quest_n)
|
|
continue;
|
|
if (quest_n->nCode == code)
|
|
continue;
|
|
|
|
for (int j = 0; j < QuestBase::MAX_VALUE_NUMBER; ++j)
|
|
{
|
|
if (dropItemId == quest->nValue[j])
|
|
{
|
|
dropQuestCode = code;
|
|
find = true;
|
|
break;
|
|
}
|
|
}
|
|
if (find)
|
|
break;
|
|
}
|
|
|
|
if (!find)
|
|
delList(dropItemId, dropQuestCode);
|
|
} |