mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Merge pull request #730 from regneq/master
Added pause, resume, and ispause to lua.
This commit is contained in:
commit
fdcd39398c
@ -341,6 +341,19 @@ void lua_stop_all_timers(Lua_Encounter enc) {
|
||||
quest_manager.stopalltimers(enc);
|
||||
}
|
||||
|
||||
void lua_pause_timer(const char *timer) {
|
||||
quest_manager.pausetimer(timer);
|
||||
|
||||
}
|
||||
|
||||
void lua_resume_timer(const char *timer) {
|
||||
quest_manager.resumetimer(timer);
|
||||
}
|
||||
|
||||
bool lua_is_paused_timer(const char *timer) {
|
||||
return quest_manager.ispausedtimer(timer);
|
||||
}
|
||||
|
||||
void lua_depop() {
|
||||
quest_manager.depop(0);
|
||||
}
|
||||
@ -1543,6 +1556,9 @@ luabind::scope lua_register_general() {
|
||||
luabind::def("stop_timer", (void(*)(const char*, Lua_ItemInst))&lua_stop_timer),
|
||||
luabind::def("stop_timer", (void(*)(const char*, Lua_Mob))&lua_stop_timer),
|
||||
luabind::def("stop_timer", (void(*)(const char*, Lua_Encounter))&lua_stop_timer),
|
||||
luabind::def("pause_timer", (void(*)(const char*))&lua_pause_timer),
|
||||
luabind::def("resume_timer", (void(*)(const char*))&lua_resume_timer),
|
||||
luabind::def("is_paused_timer", (bool(*)(const char*))&lua_is_paused_timer),
|
||||
luabind::def("stop_all_timers", (void(*)(void))&lua_stop_all_timers),
|
||||
luabind::def("stop_all_timers", (void(*)(Lua_ItemInst))&lua_stop_all_timers),
|
||||
luabind::def("stop_all_timers", (void(*)(Lua_Mob))&lua_stop_all_timers),
|
||||
|
||||
@ -555,6 +555,107 @@ void QuestManager::stopalltimers(Mob *mob) {
|
||||
}
|
||||
}
|
||||
|
||||
void QuestManager::pausetimer(const char *timer_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||
std::list<PausedTimer>::iterator pcur = PTimerList.begin(), pend;
|
||||
PausedTimer pt;
|
||||
uint32 milliseconds = 0;
|
||||
|
||||
pend = PTimerList.end();
|
||||
while (pcur != pend)
|
||||
{
|
||||
if (pcur->owner && pcur->owner == owner && pcur->name == timer_name)
|
||||
{
|
||||
Log(Logs::General, Logs::Quests, "Timer %s is already paused for %s. Returning...", timer_name, owner->GetName());
|
||||
return;
|
||||
}
|
||||
++pcur;
|
||||
}
|
||||
|
||||
end = QTimerList.end();
|
||||
while (cur != end)
|
||||
{
|
||||
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||
{
|
||||
milliseconds = cur->Timer_.GetRemainingTime();
|
||||
QTimerList.erase(cur);
|
||||
break;
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
|
||||
std::string timername = timer_name;
|
||||
pt.name = timername;
|
||||
pt.owner = owner;
|
||||
pt.time = milliseconds;
|
||||
Log(Logs::General, Logs::Quests, "Pausing timer %s for %s with %d ms remaining.", timer_name, owner->GetName(), milliseconds);
|
||||
PTimerList.push_back(pt);
|
||||
}
|
||||
|
||||
void QuestManager::resumetimer(const char *timer_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||
std::list<PausedTimer>::iterator pcur = PTimerList.begin(), pend;
|
||||
PausedTimer pt;
|
||||
uint32 milliseconds = 0;
|
||||
|
||||
pend = PTimerList.end();
|
||||
while (pcur != pend)
|
||||
{
|
||||
if (pcur->owner && pcur->owner == owner && pcur->name == timer_name)
|
||||
{
|
||||
milliseconds = pcur->time;
|
||||
PTimerList.erase(pcur);
|
||||
break;
|
||||
}
|
||||
++pcur;
|
||||
}
|
||||
|
||||
if (milliseconds == 0)
|
||||
{
|
||||
Log(Logs::General, Logs::Quests, "Paused timer %s not found or has expired. Returning...", timer_name);
|
||||
return;
|
||||
}
|
||||
|
||||
end = QTimerList.end();
|
||||
while (cur != end)
|
||||
{
|
||||
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||
{
|
||||
cur->Timer_.Enable();
|
||||
cur->Timer_.Start(milliseconds, false);
|
||||
Log(Logs::General, Logs::Quests, "Resuming timer %s for %s with %d ms remaining.", timer_name, owner->GetName(), milliseconds);
|
||||
return;
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
|
||||
QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name));
|
||||
Log(Logs::General, Logs::Quests, "Creating a new timer and resuming %s for %s with %d ms remaining.", timer_name, owner->GetName(), milliseconds);
|
||||
|
||||
}
|
||||
|
||||
bool QuestManager::ispausedtimer(const char *timer_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
std::list<PausedTimer>::iterator pcur = PTimerList.begin(), pend;
|
||||
|
||||
pend = PTimerList.end();
|
||||
while (pcur != pend)
|
||||
{
|
||||
if (pcur->owner && pcur->owner == owner && pcur->name == timer_name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
++pcur;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QuestManager::emote(const char *str) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (!owner) {
|
||||
|
||||
@ -41,6 +41,12 @@ class QuestManager {
|
||||
bool depop_npc;
|
||||
std::string encounter;
|
||||
};
|
||||
|
||||
struct PausedTimer {
|
||||
Mob * owner;
|
||||
std::string name;
|
||||
uint32 time;
|
||||
};
|
||||
public:
|
||||
QuestManager();
|
||||
virtual ~QuestManager();
|
||||
@ -82,6 +88,9 @@ public:
|
||||
void stopalltimers();
|
||||
void stopalltimers(EQEmu::ItemInstance *inst);
|
||||
void stopalltimers(Mob *mob);
|
||||
void pausetimer(const char *timer_name);
|
||||
void resumetimer(const char *timer_name);
|
||||
bool ispausedtimer(const char *timer_name);
|
||||
void emote(const char *str);
|
||||
void shout(const char *str);
|
||||
void shout2(const char *str);
|
||||
@ -304,6 +313,7 @@ private:
|
||||
};
|
||||
std::list<QuestTimer> QTimerList;
|
||||
std::list<SignalTimer> STimerList;
|
||||
std::list<PausedTimer> PTimerList;
|
||||
size_t item_timers;
|
||||
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user