summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/map/battle/misc.conf2
-rw-r--r--conf/messages.conf2
-rw-r--r--src/map/atcommand.c14
-rw-r--r--src/map/duel.c23
-rw-r--r--src/map/duel.h2
5 files changed, 15 insertions, 28 deletions
diff --git a/conf/map/battle/misc.conf b/conf/map/battle/misc.conf
index cc2abc16c..8cc1d0171 100644
--- a/conf/map/battle/misc.conf
+++ b/conf/map/battle/misc.conf
@@ -101,7 +101,7 @@ duel_allow_teleport: false
// Autoleave duel when die
duel_autoleave_when_die: true
-// Delay between using @duel in minutes
+// Delay between using @duel in seconds
duel_time_interval: 60
// Restrict duel usage to same map
diff --git a/conf/messages.conf b/conf/messages.conf
index b91b03921..787498e8e 100644
--- a/conf/messages.conf
+++ b/conf/messages.conf
@@ -368,7 +368,7 @@
353: Duel: The Player is in the duel already.
354: Duel: Invitation has been sent.
355: Duel: You can't use @duel without @reject.
-356: Duel: You can take part in duel once per %d minutes.
+356: Duel: You can take part in duel again after %d seconds.
357: Duel: Invalid value.
358: Duel: You can't use @leave. You aren't a duelist.
359: Duel: You've left the duel.
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 3cd26079d..5d95e2c14 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8048,10 +8048,11 @@ ACMD(duel)
return false;
}
- if (!duel->checktime(sd)) {
+ int64 diff = duel->difftime(sd);
+ if (diff > 0) {
char output[CHAT_SIZE_MAX];
- // "Duel: You can take part in duel only one time per %d minutes."
- sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval);
+ // "Duel: You can take part in duel again after %d secconds."
+ sprintf(output, msg_fd(fd,356), (int)diff);
clif->message(fd, output);
return false;
}
@@ -8101,10 +8102,11 @@ ACMD(leave)
ACMD(accept)
{
- if (!duel->checktime(sd)) {
+ int64 diff = duel->difftime(sd);
+ if (diff > 0) {
char output[CHAT_SIZE_MAX];
- // "Duel: You can take part in duel only one time per %d minutes."
- sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval);
+ // "Duel: You can take part in duel again after %d seconds."
+ sprintf(output, msg_fd(fd,356), (int)diff);
clif->message(fd, output);
return false;
}
diff --git a/src/map/duel.c b/src/map/duel.c
index dca040f83..c66fd6fc2 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -41,27 +41,12 @@ struct duel_interface *duel;
*------------------------------------------*/
static void duel_savetime(struct map_session_data *sd)
{
- time_t clock;
- struct tm *t;
-
- time(&clock);
- t = localtime(&clock);
-
- pc_setglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME"), t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
+ pc_setglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME"), (int)time(NULL));
}
-static int duel_checktime(struct map_session_data *sd)
+static int64 duel_difftime(struct map_session_data *sd)
{
- int diff;
- time_t clock;
- struct tm *t;
-
- time(&clock);
- t = localtime(&clock);
-
- diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min - pc_readglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME") );
-
- return !(diff >= 0 && diff < battle_config.duel_time_interval);
+ return (pc_readglobalreg(sd, script->add_variable("PC_LAST_DUEL_TIME")) + battle_config.duel_time_interval - (int)time(NULL));
}
static int duel_showinfo_sub(struct map_session_data *sd, va_list va)
@@ -233,7 +218,7 @@ void duel_defaults(void)
duel->reject = duel_reject;
duel->leave = duel_leave;
duel->showinfo = duel_showinfo;
- duel->checktime = duel_checktime;
+ duel->difftime = duel_difftime;
duel->init = do_init_duel;
duel->final = do_final_duel;
diff --git a/src/map/duel.h b/src/map/duel.h
index 4e8985b96..1620ca891 100644
--- a/src/map/duel.h
+++ b/src/map/duel.h
@@ -52,7 +52,7 @@ struct duel_interface {
void (*reject) (const unsigned int did, struct map_session_data* sd);
void (*leave) (const unsigned int did, struct map_session_data* sd);
void (*showinfo) (const unsigned int did, struct map_session_data* sd);
- int (*checktime) (struct map_session_data* sd);
+ int64 (*difftime) (struct map_session_data* sd);
void (*init) (bool minimal);
void (*final) (void);