summaryrefslogtreecommitdiff
path: root/src/map/mercenary.c
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-31 22:56:05 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-31 22:56:05 +0000
commit08c870656aeb76d839a8ad2fd071818b8618f899 (patch)
tree3ac8cc1544cd0a60f00312cdb6c8c21f62f287a8 /src/map/mercenary.c
parent409cb0381295716d654fd2ee5021e1011a45ab80 (diff)
downloadhercules-08c870656aeb76d839a8ad2fd071818b8618f899.tar.gz
hercules-08c870656aeb76d839a8ad2fd071818b8618f899.tar.bz2
hercules-08c870656aeb76d839a8ad2fd071818b8618f899.tar.xz
hercules-08c870656aeb76d839a8ad2fd071818b8618f899.zip
- A proper mercenary lifetime calculation.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13165 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mercenary.c')
-rw-r--r--src/map/mercenary.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 08a640275..bcbba3dd1 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -76,7 +76,7 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime)
merc.class_ = class_;
merc.hp = db->status.max_hp;
merc.sp = db->status.max_sp;
- merc.remain_life_time = lifetime;
+ merc.life_time = lifetime;
// Request Char Server to create this mercenary
intif_mercenary_create(&merc);
@@ -84,19 +84,21 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime)
return 1;
}
-int mercenary_save(struct mercenary_data *md)
+int mercenary_get_lifetime(struct mercenary_data *md)
{
- const struct TimerData * td = get_timer(md->contract_timer);
+ const struct TimerData * td;
+ if( md == NULL )
+ return 0;
+ td = get_timer(md->contract_timer);
+ return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
+}
+
+int mercenary_save(struct mercenary_data *md)
+{
md->mercenary.hp = md->battle_status.hp;
md->mercenary.sp = md->battle_status.sp;
- if( td != NULL )
- md->mercenary.remain_life_time = DIFF_TICK(td->tick, gettick());
- else
- {
- md->mercenary.remain_life_time = 0;
- ShowWarning("mercenary_save : mercenary without timer (tid %d)\n", md->contract_timer);
- }
+ md->mercenary.life_time = mercenary_get_lifetime(md);
intif_mercenary_save(&md->mercenary);
return 1;
@@ -127,7 +129,7 @@ static int merc_contract_end(int tid, unsigned int tick, int id, intptr data)
int merc_delete(struct mercenary_data *md, int reply)
{
struct map_session_data *sd = md->master;
- md->mercenary.remain_life_time = 0;
+ md->mercenary.life_time = 0;
merc_contract_stop(md);
@@ -149,7 +151,7 @@ void merc_contract_stop(struct mercenary_data *md)
void merc_contract_init(struct mercenary_data *md)
{
if( md->contract_timer == INVALID_TIMER )
- md->contract_timer = add_timer(gettick() + md->mercenary.remain_life_time, merc_contract_end, md->master->bl.id, 0);
+ md->contract_timer = add_timer(gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0);
md->regen.state.block = 0;
}