Beispiel #1
0
void Client::ResetAlternateAdvancementTimers() {
	auto outapp = new EQApplicationPacket(OP_AAAction, sizeof(UseAA_Struct));
	UseAA_Struct* uaaout = (UseAA_Struct*)outapp->pBuffer;

	PTimerList::iterator c, e;
	c = p_timers.begin();
	e = p_timers.end();
	std::vector<int> r_timers;
	for(; c != e; ++c) {
		PersistentTimer *cur = c->second;
		if(cur->GetType() < pTimerAAStart || cur->GetType() > pTimerAAEnd)
			continue;
		//send timer
		uaaout->begin = 0;
		uaaout->end = static_cast<uint32>(time(nullptr));
		uaaout->ability = cur->GetType() - pTimerAAStart;
		r_timers.push_back(cur->GetType());
		QueuePacket(outapp);
	}

	for(auto &i : r_timers) {
		p_timers.Clear(&database, i);
	}

	safe_delete(outapp);
}
Beispiel #2
0
PersistentTimer *PersistentTimer::LoadTimer(Database *db, int32 char_id, pTimerType type) {
	PersistentTimer *p;
	p = new PersistentTimer(char_id, type, 0);
	if(p->Load(db))
		return(p);
	delete p;
	return(NULL);
}
Beispiel #3
0
bool PTimerList::Load(Database *db) {
	map<pTimerType, PersistentTimer *>::iterator s;
	s = _list.begin();
	while(s != _list.end()) {
		if(s->second != NULL)
			delete s->second;
		s++;
	}
	_list.clear();
	
	char errbuf[MYSQL_ERRMSG_SIZE];
    MYSQL_RES *result;
    MYSQL_ROW row;
    char *query = 0;
	uint32 qlen = 0;
	uint32 qcount = 0;
	
	qlen = MakeAnyLenString(&query, "SELECT type,start,duration,enable "
	" FROM timers WHERE char_id=%lu", (unsigned long)_char_id);
	
#ifdef DEBUG_PTIMERS
	printf("Loading all timers for char %lu\n", (unsigned long)_char_id);
#endif
	
	if (!db->RunQuery(query, qlen, errbuf, &result)) {
		safe_delete_array(query);
#if EQDEBUG > 5
		LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf);
#endif
		return(false);
	}
	safe_delete_array(query);
	
	pTimerType type;
	int32 start_time, timer_time;
	bool enabled;
	
	PersistentTimer *cur;
	qcount = mysql_num_rows(result);
	while((row = mysql_fetch_row(result)) ) {
		type = atoi(row[0]);
		start_time = strtoul(row[1], NULL, 10);
		timer_time = strtoul(row[2], NULL, 10);
		enabled = (row[3][0] == '1');
		
		//if it expired allready, dont bother.
		
		cur = new PersistentTimer(_char_id, type, start_time, timer_time, enabled);
		if(!cur->Expired(false))
			_list[type] = cur;
		else
			delete cur;
	}
	mysql_free_result(result);
	
	return(true);
}
Beispiel #4
0
//sends all AA timers.
void Client::SendAATimers() {
	//we dont use SendAATimer because theres no reason to allocate the EQApplicationPacket every time
	EQApplicationPacket* outapp = new EQApplicationPacket(OP_AAAction, sizeof(UseAA_Struct));
	UseAA_Struct* uaaout = (UseAA_Struct*)outapp->pBuffer;

	//EQMac sends timers for all the abilities you have, even if they have never been used.
	uint8 macaaid = 0;
	for (uint32 i = 0; i < MAX_PP_AA_ARRAY; i++)
	{
		if (aa[i]->AA > 0)
		{
			SendAA_Struct* aa2 = nullptr;
			aa2 = zone->FindAA(aa[i]->AA);
			if (aa2 && aa2->spell_refresh > 0)
			{
				int32 starttime = 0;
				PTimerList::iterator c, e;
				c = p_timers.begin();
				e = p_timers.end();
				for (; c != e; ++c) {
					PersistentTimer *cur = c->second;
					if (cur->GetType() < pTimerAAStart || cur->GetType() > pTimerAAEnd)
						continue;	//not an AA timer
					else if (cur->GetType() == pTimerAAStart + aa2->spell_type)
					{
						starttime = cur->GetStartTime();
						break;
					}
					uaaout->begin = starttime;
					uaaout->end = static_cast<uint32>(time(nullptr));
					uaaout->ability = zone->EmuToEQMacAA(aa2->id);
					QueuePacket(outapp);
					Log.Out(Logs::Detail, Logs::AA, "Sending out timer for AA: %i. Timer start: %i Timer end: %i Recast Time: %i", uaaout->ability, uaaout->begin, uaaout->end, aa2->spell_refresh);
				}
				uaaout->begin = starttime;
				uaaout->end = static_cast<uint32>(time(nullptr));
				uaaout->ability = zone->EmuToEQMacAA(aa2->id);
				QueuePacket(outapp);
				Log.Out(Logs::General, Logs::Status, "Sending out timer for AA: %i. Timer start: %i Timer end: %i Recast Time: %i", uaaout->ability, uaaout->begin, uaaout->end, aa2->spell_refresh);
			}
		}
	}

	safe_delete(outapp);
}
Beispiel #5
0
//sends all AA timers.
void Client::SendAlternateAdvancementTimers() {
	//we dont use SendAATimer because theres no reason to allocate the EQApplicationPacket every time
	auto outapp = new EQApplicationPacket(OP_AAAction, sizeof(UseAA_Struct));
	UseAA_Struct* uaaout = (UseAA_Struct*)outapp->pBuffer;

	PTimerList::iterator c, e;
	c = p_timers.begin();
	e = p_timers.end();
	for(; c != e; ++c) {
		PersistentTimer *cur = c->second;
		if(cur->GetType() < pTimerAAStart || cur->GetType() > pTimerAAEnd)
			continue;	//not an AA timer
		//send timer
		uaaout->begin = cur->GetStartTime();
		uaaout->end = static_cast<uint32>(time(nullptr));
		uaaout->ability = cur->GetType() - pTimerAAStart; // uuaaout->ability is really a shared timer number
		QueuePacket(outapp);
	}

	safe_delete(outapp);
}