mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-17 22:51:30 +00:00
Some clean up in questmgr.cpp
This commit is contained in:
parent
7972937072
commit
f4e085c121
@ -114,7 +114,7 @@ QuestManager::~QuestManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuestManager::Process() {
|
void QuestManager::Process() {
|
||||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end, tmp;
|
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||||
|
|
||||||
end = QTimerList.end();
|
end = QTimerList.end();
|
||||||
while (cur != end) {
|
while (cur != end) {
|
||||||
@ -122,8 +122,7 @@ void QuestManager::Process() {
|
|||||||
if(entity_list.IsMobInZone(cur->mob)) {
|
if(entity_list.IsMobInZone(cur->mob)) {
|
||||||
if(cur->mob->IsNPC()) {
|
if(cur->mob->IsNPC()) {
|
||||||
parse->EventNPC(EVENT_TIMER, cur->mob->CastToNPC(), nullptr, cur->name, 0);
|
parse->EventNPC(EVENT_TIMER, cur->mob->CastToNPC(), nullptr, cur->name, 0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//this is inheriently unsafe if we ever make it so more than npc/client start timers
|
//this is inheriently unsafe if we ever make it so more than npc/client start timers
|
||||||
parse->EventPlayer(EVENT_TIMER, cur->mob->CastToClient(), cur->name, 0);
|
parse->EventPlayer(EVENT_TIMER, cur->mob->CastToClient(), cur->name, 0);
|
||||||
}
|
}
|
||||||
@ -133,13 +132,10 @@ void QuestManager::Process() {
|
|||||||
cur = QTimerList.begin();
|
cur = QTimerList.begin();
|
||||||
end = QTimerList.end(); //dunno if this is needed, cant hurt...
|
end = QTimerList.end(); //dunno if this is needed, cant hurt...
|
||||||
} else {
|
} else {
|
||||||
tmp = cur;
|
cur = QTimerList.erase(cur);
|
||||||
tmp++;
|
|
||||||
QTimerList.erase(cur);
|
|
||||||
cur = tmp;
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
cur++;
|
++cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cur_iter = STimerList.begin();
|
auto cur_iter = STimerList.begin();
|
||||||
@ -168,18 +164,14 @@ void QuestManager::EndQuest() {
|
|||||||
running_quest run = quests_running_.top();
|
running_quest run = quests_running_.top();
|
||||||
if(run.depop_npc && run.owner->IsNPC()) {
|
if(run.depop_npc && run.owner->IsNPC()) {
|
||||||
//clear out any timers for them...
|
//clear out any timers for them...
|
||||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end, tmp;
|
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||||
|
|
||||||
end = QTimerList.end();
|
end = QTimerList.end();
|
||||||
while (cur != end) {
|
while (cur != end) {
|
||||||
if(cur->mob == run.owner) {
|
if (cur->mob == run.owner)
|
||||||
tmp = cur;
|
cur = QTimerList.erase(cur);
|
||||||
tmp++;
|
else
|
||||||
QTimerList.erase(cur);
|
++cur;
|
||||||
cur = tmp;
|
|
||||||
} else {
|
|
||||||
cur++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run.owner->Depop();
|
run.owner->Depop();
|
||||||
@ -462,7 +454,7 @@ void QuestManager::settimer(const char *timer_name, int seconds) {
|
|||||||
cur->Timer_.Start(seconds * 1000, false);
|
cur->Timer_.Start(seconds * 1000, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur++;
|
++cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimerList.push_back(QuestTimer(seconds * 1000, owner, timer_name));
|
QTimerList.push_back(QuestTimer(seconds * 1000, owner, timer_name));
|
||||||
@ -486,7 +478,7 @@ void QuestManager::settimerMS(const char *timer_name, int milliseconds) {
|
|||||||
cur->Timer_.Start(milliseconds, false);
|
cur->Timer_.Start(milliseconds, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur++;
|
++cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name));
|
QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name));
|
||||||
@ -495,7 +487,7 @@ void QuestManager::settimerMS(const char *timer_name, int milliseconds) {
|
|||||||
void QuestManager::stoptimer(const char *timer_name) {
|
void QuestManager::stoptimer(const char *timer_name) {
|
||||||
QuestManagerCurrentQuestVars();
|
QuestManagerCurrentQuestVars();
|
||||||
|
|
||||||
if(questitem) {
|
if (questitem) {
|
||||||
questitem->StopTimer(timer_name);
|
questitem->StopTimer(timer_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -503,14 +495,12 @@ void QuestManager::stoptimer(const char *timer_name) {
|
|||||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||||
|
|
||||||
end = QTimerList.end();
|
end = QTimerList.end();
|
||||||
while (cur != end)
|
while (cur != end) {
|
||||||
{
|
if (cur->mob && cur->mob == owner && cur->name == timer_name) {
|
||||||
if(cur->mob && cur->mob == owner && cur->name == timer_name)
|
|
||||||
{
|
|
||||||
QTimerList.erase(cur);
|
QTimerList.erase(cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur++;
|
++cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,19 +515,11 @@ void QuestManager::stopalltimers() {
|
|||||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end, tmp;
|
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end, tmp;
|
||||||
|
|
||||||
end = QTimerList.end();
|
end = QTimerList.end();
|
||||||
while (cur != end)
|
while (cur != end) {
|
||||||
{
|
|
||||||
if(cur->mob && cur->mob == owner)
|
if(cur->mob && cur->mob == owner)
|
||||||
{
|
cur = QTimerList.erase(cur);
|
||||||
tmp = cur;
|
|
||||||
tmp++;
|
|
||||||
QTimerList.erase(cur);
|
|
||||||
cur = tmp;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
++cur;
|
||||||
cur++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2453,18 +2435,17 @@ uint32 QuestManager::MerchantCountItem(uint32 NPCid, uint32 itemid) {
|
|||||||
|
|
||||||
const Item_Struct* item = nullptr;
|
const Item_Struct* item = nullptr;
|
||||||
item = database.GetItem(itemid);
|
item = database.GetItem(itemid);
|
||||||
if (!item) return 0; // likewise, if it isn't a valid item, the merchant doesn't have any
|
if (!item)
|
||||||
|
return 0; // if it isn't a valid item, the merchant doesn't have any
|
||||||
|
|
||||||
// look for the item in the merchant's temporary list
|
// look for the item in the merchant's temporary list
|
||||||
std::list<TempMerchantList> MerchList = zone->tmpmerchanttable[NPCid];
|
std::list<TempMerchantList> MerchList = zone->tmpmerchanttable[NPCid];
|
||||||
std::list<TempMerchantList>::const_iterator itr;
|
std::list<TempMerchantList>::const_iterator itr;
|
||||||
TempMerchantList ml;
|
|
||||||
uint32 Quant = 0;
|
uint32 Quant = 0;
|
||||||
|
|
||||||
for(itr = MerchList.begin(); itr != MerchList.end(); itr++){
|
for (itr = MerchList.begin(); itr != MerchList.end(); ++itr) {
|
||||||
ml = *itr;
|
if (itr->item == itemid) { // if this is the item we're looking for
|
||||||
if (ml.item == itemid) { // if this is the item we're looking for
|
Quant = itr->charges;
|
||||||
Quant = ml.charges;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user