Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Methods for getting more information on quest timers. #2060

Merged
merged 5 commits into from
Apr 13, 2022

Conversation

KayenEQ
Copy link
Contributor

@KayenEQ KayenEQ commented Mar 17, 2022

Following methods allow you to obtain more information about the status of your quest timers.

PERL

quest::hastimer(timer name) //bool for if a quest timer is currently active
quest::getremainingtimeMS(timer name) //Returns how much time is remaining on a quest timer in MS
quest::gettimerdurationMS(timer name) //Returns total duration of a quest timer in MS

LUA

bool lua_has_timer(const char *timer) {
	return quest_manager.hastimer(timer);
}

uint32 lua_get_remaining_time(const char *timer) {
	return quest_manager.getremainingtimeMS(timer);
}

uint32 lua_get_timer_duration(const char *timer) {
	return quest_manager.gettimerdurationMS(timer);
}

bool QuestManager::hastimer(const char *timer_name) {
QuestManagerCurrentQuestVars();

std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
Copy link
Member

@Akkadius Akkadius Mar 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verbosity on this code can be cut down rather significantly and use references

	for (auto & cur : QTimerList) {
		if (cur.mob && cur.mob == owner && cur.name == timer_name) {
			if (cur.Timer_.Enabled()) {
				return true;
			}
		}
	}

@Akkadius
Copy link
Member

Overall looks good outside of KK's comments being addressed.

I would have used std::string C++ strings versus old C style pointers, makes things a bit easier to work in general with but its fine for this change

@KayenEQ KayenEQ merged commit bc875ae into EQEmu:master Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants