114 lines
2.5 KiB
C++
114 lines
2.5 KiB
C++
#include "stdafx.h"
|
|
#include "SQuestmarkFactory.h"
|
|
#include "KTypes.h"
|
|
#include "SQuestMgr.h"
|
|
#include "SQuestMark.h"
|
|
#include "SQuestDB.h"
|
|
|
|
/*
|
|
*/
|
|
cQuestMarkFactory::cQuestMarkFactory(SQuestMgr* questMgr) : m_questMgr(questMgr)
|
|
{
|
|
createMarkList();
|
|
}
|
|
/*
|
|
*/
|
|
cQuestMarkFactory::~cQuestMarkFactory()
|
|
{
|
|
clear();
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::createMarkList()
|
|
{
|
|
/*
|
|
MARK_PROP,
|
|
MARK_MOB,
|
|
MARK_NPC,
|
|
MARK_DROP_ITEM,
|
|
*/
|
|
m_markList.push_back(new sQuestMarkProp(m_questMgr));
|
|
m_markList.push_back(new sQuestMarkMob(m_questMgr));
|
|
m_markList.push_back(new sQuestMarkNpc(m_questMgr));
|
|
m_markList.push_back(new sQuestMarkDropItem(m_questMgr));
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::clear()
|
|
{
|
|
std::vector<sQuestMark*>::iterator it = m_markList.begin();
|
|
for (; it != m_markList.end(); ++it)
|
|
{
|
|
SAFE_DELETE(*it);
|
|
}
|
|
m_markList.clear();
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::insertQuestTargetId(QuestBase* quest)
|
|
{
|
|
int targetType = quest->show_target_type;
|
|
|
|
int markType;
|
|
if (QuestBase::QUEST_MARK_TARGET_PROP == targetType) markType = MARK_PROP;
|
|
else if (QuestBase::QUEST_MARK_TARGET_MOB == targetType) markType = MARK_MOB;
|
|
else if (QuestBase::QUEST_MARK_TARGET_NPC == targetType) markType = MARK_NPC;
|
|
else
|
|
return ;
|
|
|
|
m_markList[markType]->insertFromId(quest->show_target_id, quest->nCode);
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::removeQuestTargetId(QuestBase* quest)
|
|
{
|
|
int targetType = quest->show_target_type;
|
|
|
|
int markType;
|
|
if (QuestBase::QUEST_MARK_TARGET_PROP == targetType) markType = MARK_PROP;
|
|
else if (QuestBase::QUEST_MARK_TARGET_MOB == targetType) markType = MARK_MOB;
|
|
else if (QuestBase::QUEST_MARK_TARGET_NPC == targetType) markType = MARK_NPC;
|
|
else
|
|
return ;
|
|
|
|
m_markList[markType]->removeFromId(quest->show_target_id, quest->nCode);
|
|
}
|
|
/*
|
|
*/
|
|
bool cQuestMarkFactory::is(int type, int id, bool checkQuestInProgress)
|
|
{
|
|
return m_markList[type]->is(id, checkQuestInProgress);
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::insert(QuestBase::QuestCode code)
|
|
{
|
|
QuestBase* quest = GetQuestDB().GetQuestData(code);
|
|
if (!quest)
|
|
return ;
|
|
|
|
for (int i = 0; i < MARK_NUM; ++i)
|
|
m_markList[i]->insertFromCode(quest);
|
|
|
|
insertQuestTargetId(quest);
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::remove(QuestBase::QuestCode code)
|
|
{
|
|
QuestBase* quest = GetQuestDB().GetQuestData(code);
|
|
if (!quest)
|
|
return ;
|
|
|
|
for (int i = 0; i < MARK_NUM; ++i)
|
|
m_markList[i]->removeFromCode(quest);
|
|
|
|
removeQuestTargetId(quest);
|
|
}
|
|
/*
|
|
*/
|
|
void cQuestMarkFactory::clearMarkList()
|
|
{
|
|
for (int i = 0; i < MARK_NUM; ++i)
|
|
m_markList[i]->clear();
|
|
} |