Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #46  
Old 09-03-2004, 05:31 PM
fathernitwit
Developer
 
Join Date: Jul 2004
Posts: 773
Default

alright, if your interested... heres my persistent timers:
http://eqemu.psend.com/files/ptimers.diff

apply on unix with patch -p0 <ptimers.diff from the source root.

This is basically an implementation of the Timer class, but is persistent on a per-client basis. You just have to give each timer type a unique type number... I show an example of this with AA_number... assuming that it is 0 <= AA_number <= 120... if this is not true, if there is a bigger range of AA IDs, then we can adjust the range in the header... it isnt a big deal.

heres some example code:
Code:
Client::something() {
  p_timers.Start(pTimerAAStart + AA_number, duration_in_sec);

  if(p_timers.Check(pTimerAAStart + AA_number, false)) {
    //timer expired, use the AA
  } else {
    //timer not expired...
  }
}

if your not in the Client:: scope, but you have a client ptr, use:
Client *c;
...
c->GetPTimers().Start(....)
heres my little writeup about them:
Code:
Persistent timers, By Father Nitwit

The idea of persistent timers is timers which follow a player
through zoning. You use operations on them much like regular
timers: Start, Check, Clear but they also provide methods
to store them in the DB: Load and Store.

Each persistent timer is attached to a character, and given 
a specific type. A given character can only have one timer
of each type. While the type is just an arbitrary number,
please record what you are using it for in the enum for
pTimerType at the top of ptimer.h, and give it a UNIQUE number.

There should be little need to directly access ptimers. Each
client has a facility called p_timers which should handle
most of what you need. The idea is that instead of making
your own PersistentTimer, you use the methods on p_timers:
Start, Check, Clear, GetRemainingTime to access them. You
starting a timer which does not exist will create it. If 
you need to do more than that with your timer, you should
still use p_timers, just use the Get() method to get direct
access to the PersistentTimer. All timers in the p_timers
list will automatically be loaded and stored to the database.
You should never need to call any Load or Store methods.

To get to p_timers when you are not in the Client:: scope,
use client->GetPTimers(). to access timers.

To use ptimers, you need to create the table below in your DB:

Schema:

CREATE TABLE timers (
	char_id INT(11) NOT NULL,
	type MEDIUMINT UNSIGNED NOT NULL,
	start INT UNSIGNED NOT NULL,
	duration INT UNSIGNED NOT NULL,
	enable TINYINT NOT NULL,
	PRIMARY KEY(char_id, type)
);
Reply With Quote
  #47  
Old 09-04-2004, 02:08 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

I guess this is where I should put this... Just a heads up ptimer.h and cpp weren't added to the zone's common files list in the anon CVS build that is up.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:13 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3