summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-04-09 17:59:01 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-04-11 14:21:42 -0700
commit8ce76f29ab6bc6ea0809c085b4f395373b3cb8d7 (patch)
tree407e8fb0258440c6dd60cca98b6304fb946eba70 /src/map
parent756085f91d0f01c69550735cf2e60cae54d9c72a (diff)
downloadtmwa-8ce76f29ab6bc6ea0809c085b4f395373b3cb8d7.tar.gz
tmwa-8ce76f29ab6bc6ea0809c085b4f395373b3cb8d7.tar.bz2
tmwa-8ce76f29ab6bc6ea0809c085b4f395373b3cb8d7.tar.xz
tmwa-8ce76f29ab6bc6ea0809c085b4f395373b3cb8d7.zip
Also implement x32 support
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.cpp3
-rw-r--r--src/map/chrif.cpp14
-rw-r--r--src/map/clif.cpp24
-rw-r--r--src/map/magic-stmt.cpp6
-rw-r--r--src/map/map.cpp11
-rw-r--r--src/map/map.hpp6
-rw-r--r--src/map/npc.cpp19
-rw-r--r--src/map/pc.cpp23
-rw-r--r--src/map/pc.hpp2
-rw-r--r--src/map/script.cpp46
-rw-r--r--src/map/skill.cpp24
-rw-r--r--src/map/tmw.cpp6
12 files changed, 86 insertions, 98 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 116139d..ea13a04 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -386,8 +386,7 @@ FILE *get_gm_log()
if (!gm_logfile_name)
return NULL;
- time_t ts = time(NULL);
- struct tm ctime = *gmtime(&ts);
+ struct tm ctime = TimeT::now();
int year = ctime.tm_year + 1900;
int month = ctime.tm_mon + 1;
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 9743072..47eef1a 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -880,13 +880,11 @@ int chrif_accountban(int fd)
}
}
else if (RFIFOB(fd, 6) == 1)
- { // 0: change of statut, 1: ban
- time_t timestamp;
- char tmpstr[2048];
- timestamp = (time_t) RFIFOL(fd, 7); // status or final date of a banishment
- strcpy(tmpstr, "Your account has been banished until ");
- strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S",
- gmtime(&timestamp));
+ {
+ // 0: change of statut, 1: ban
+ TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 7)); // status or final date of a banishment
+ char tmpstr[] = WITH_TIMESTAMP("Your account has been banished until ");
+ REPLACE_TIMESTAMP(tmpstr, timestamp);
clif_displaymessage(sd->fd, tmpstr);
}
clif_setwaitclose(sd->fd); // forced to disconnect for the change
@@ -1098,7 +1096,7 @@ void chrif_parse(int fd)
break;
case 0x2afd:
pc_authok(RFIFOL(fd, 4), RFIFOL(fd, 8),
- (time_t) RFIFOL(fd, 12), RFIFOW(fd, 16),
+ static_cast<time_t>(RFIFOL(fd, 12)), RFIFOW(fd, 16),
(const struct mmo_charstatus *) RFIFOP(fd, 18));
break;
case 0x2afe:
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 1691959..ca8e487 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -5629,12 +5629,12 @@ int clif_check_packet_flood(int fd, int cmd)
// They are flooding
if (tick < sd->flood_rates[cmd] + rate)
{
- time_t now = time(NULL);
+ TimeT now = TimeT::now();
// If it's a nasty flood we log and possibly kick
if (now > sd->packet_flood_reset_due)
{
- sd->packet_flood_reset_due = now + battle_config.packet_spam_threshold;
+ sd->packet_flood_reset_due = static_cast<time_t>(now) + battle_config.packet_spam_threshold;
sd->packet_flood_in = 0;
}
@@ -5914,7 +5914,6 @@ void clif_parse(int fd)
int i;
FILE *fp;
char packet_txt[256] = "save/packet.txt";
- time_t now;
PRINTF("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
for (i = 0; i < packet_len; i++)
{
@@ -5942,24 +5941,25 @@ void clif_parse(int fd)
}
else
{
- time(&now);
+ timestamp_seconds_buffer now;
+ stamp_time(now);
if (sd && sd->state.auth)
{
if (sd->status.name != NULL)
FPRINTF(fp,
- "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
- asctime(gmtime(&now)),
- sd->status.account_id,
- sd->status.char_id, sd->status.name);
+ "%s\nPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
+ now,
+ sd->status.account_id,
+ sd->status.char_id, sd->status.name);
else
FPRINTF(fp,
- "%sPlayer with account ID %d sent wrong packet:\n",
- asctime(gmtime(&now)), sd->bl.id);
+ "%s\nPlayer with account ID %d sent wrong packet:\n",
+ now, sd->bl.id);
}
else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
FPRINTF(fp,
- "%sPlayer with account ID %d sent wrong packet:\n",
- asctime(gmtime(&now)), sd->bl.id);
+ "%s\nPlayer with account ID %d sent wrong packet:\n",
+ now, sd->bl.id);
FPRINTF(fp,
"\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 8058310..c36e334 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -870,7 +870,7 @@ int op_drop_item_for (env_t *, int args_nr, val_t *args)
int stackable;
location_t *loc = &ARGLOCATION(0);
int count = ARGINT(2);
- interval_t time = static_cast<interval_t>(ARGINT(3));
+ interval_t interval = static_cast<interval_t>(ARGINT(3));
character_t *c = ((args_nr > 4) && (ENTITY_TYPE(4) == BL::PC)) ? ARGPC(4) : NULL;
interval_t delay = (args_nr > 5) ? static_cast<interval_t>(ARGINT(5)) : interval_t::zero();
interval_t delaytime[3] = { delay, delay, delay };
@@ -880,11 +880,11 @@ int op_drop_item_for (env_t *, int args_nr, val_t *args)
if (stackable)
map_addflooritem_any(&item, count, loc->m, loc->x, loc->y,
- owners, delaytime, time, 0);
+ owners, delaytime, interval, 0);
else
while (count-- > 0)
map_addflooritem_any(&item, 1, loc->m, loc->x, loc->y,
- owners, delaytime, time, 0);
+ owners, delaytime, interval, 0);
return 0;
}
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 4fa56c2..63fc8c9 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -1540,9 +1540,9 @@ void map_close_logfile(void)
}
static
-void map_start_logfile(long suffix)
+void map_start_logfile(long index)
{
- map_logfile_index = suffix >> LOGFILE_SECONDS_PER_CHUNK_SHIFT;
+ map_logfile_index = index;
std::string filename_buf = STRPRINTF(
"%s.%ld",
@@ -1571,12 +1571,13 @@ void map_log(const_string line)
if (!map_logfile)
return;
- time_t t = time(NULL);
+ time_t t = TimeT::now();
+ long i = t >> LOGFILE_SECONDS_PER_CHUNK_SHIFT;
- if ((t >> LOGFILE_SECONDS_PER_CHUNK_SHIFT) != map_logfile_index)
+ if (i != map_logfile_index)
{
map_close_logfile();
- map_start_logfile(t);
+ map_start_logfile(i);
}
log_with_timestamp(map_logfile, line);
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 7fb6026..ab9b4c8 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -251,14 +251,14 @@ struct map_session_data
unsigned in_progress:1;
} auto_ban_info;
- time_t chat_reset_due;
- time_t chat_repeat_reset_due;
+ TimeT chat_reset_due;
+ TimeT chat_repeat_reset_due;
int chat_lines_in;
int chat_total_repeats;
char chat_lastmsg[513];
tick_t flood_rates[0x220];
- time_t packet_flood_reset_due;
+ TimeT packet_flood_reset_due;
int packet_flood_in;
struct in_addr ip;
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index f0cacb9..7b88705 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -241,30 +241,29 @@ int npc_event_do_l(const char *name, int rid, int argc, argrec_t *args)
static
void npc_event_do_clock(TimerData *, tick_t)
{
- time_t timer = time(NULL);
- struct tm *t = gmtime(&timer);
+ struct tm t = TimeT::now();
- if (t->tm_min != ev_tm_b.tm_min)
+ if (t.tm_min != ev_tm_b.tm_min)
{
std::string buf;
- buf = STRPRINTF("OnMinute%02d", t->tm_min);
+ buf = STRPRINTF("OnMinute%02d", t.tm_min);
npc_event_doall(buf.c_str());
- buf = STRPRINTF("OnClock%02d%02d", t->tm_hour, t->tm_min);
+ buf = STRPRINTF("OnClock%02d%02d", t.tm_hour, t.tm_min);
npc_event_doall(buf.c_str());
}
- if (t->tm_hour != ev_tm_b.tm_hour)
+ if (t.tm_hour != ev_tm_b.tm_hour)
{
std::string buf;
- buf = STRPRINTF("OnHour%02d", t->tm_hour);
+ buf = STRPRINTF("OnHour%02d", t.tm_hour);
npc_event_doall(buf.c_str());
}
- if (t->tm_mday != ev_tm_b.tm_mday)
+ if (t.tm_mday != ev_tm_b.tm_mday)
{
std::string buf;
- buf = STRPRINTF("OnDay%02d%02d", t->tm_mon + 1, t->tm_mday);
+ buf = STRPRINTF("OnDay%02d%02d", t.tm_mon + 1, t.tm_mday);
npc_event_doall(buf.c_str());
}
- memcpy(&ev_tm_b, t, sizeof(ev_tm_b));
+ ev_tm_b = t;
}
/*==========================================
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index a344839..232a767 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -615,7 +615,7 @@ int pc_isequip(struct map_session_data *sd, int n)
* char鯖から送られてきたステータスを設定
*------------------------------------------
*/
-int pc_authok(int id, int login_id2, time_t connect_until_time,
+int pc_authok(int id, int login_id2, TimeT connect_until_time,
short tmw_version, const struct mmo_charstatus *st)
{
struct map_session_data *sd = NULL;
@@ -783,24 +783,27 @@ int pc_authok(int id, int login_id2, time_t connect_until_time,
sd->auto_ban_info.in_progress = 0;
// Initialize antispam vars
- sd->chat_reset_due = sd->chat_lines_in = sd->chat_total_repeats =
- sd->chat_repeat_reset_due = 0;
+ sd->chat_reset_due = TimeT();
+ sd->chat_lines_in = sd->chat_total_repeats = 0;
+ sd->chat_repeat_reset_due = TimeT();
sd->chat_lastmsg[0] = '\0';
memset(sd->flood_rates, 0, sizeof(sd->flood_rates));
- sd->packet_flood_reset_due = sd->packet_flood_in = 0;
+ sd->packet_flood_reset_due = TimeT();
+ sd->packet_flood_in = 0;
// Obtain IP address (if they are still connected)
if (!getpeername(sd->fd, (struct sockaddr *)&sai, &sa_len))
sd->ip = sai.sin_addr;
// message of the limited time of the account
- if (connect_until_time != 0)
- { // don't display if it's unlimited or unknow value
- char tmpstr[1024];
- strftime(tmpstr, sizeof(tmpstr) - 1, "Your account time limit is: %d-%m-%Y %H:%M:%S.", gmtime(&connect_until_time));
- clif_wis_message(sd->fd, wisp_server_name, tmpstr,
- strlen(tmpstr) + 1);
+ if (connect_until_time)
+ {
+ // don't display if it's unlimited or unknow value
+ char tmpstr[] = WITH_TIMESTAMP("Your account time limit is: ");
+ REPLACE_TIMESTAMP(tmpstr, connect_until_time);
+
+ clif_wis_message(sd->fd, wisp_server_name, tmpstr, sizeof(tmpstr));
}
pc_calcstatus(sd, 1);
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 12935b5..201a58e 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -56,7 +56,7 @@ int pc_counttargeted(struct map_session_data *sd, struct block_list *src,
int pc_setrestartvalue(struct map_session_data *sd, int type);
int pc_makesavestatus(struct map_session_data *);
int pc_setnewpc(struct map_session_data *, int, int, int, tick_t, int);
-int pc_authok(int, int, time_t, short tmw_version, const struct mmo_charstatus *);
+int pc_authok(int, int, TimeT, short tmw_version, const struct mmo_charstatus *);
int pc_authfail(int);
EPOS pc_equippoint(struct map_session_data *sd, int n);
diff --git a/src/map/script.cpp b/src/map/script.cpp
index ffa72e7..1a954da 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -2640,23 +2640,19 @@ void builtin_gettimetick(ScriptState *st) /* Asgard Version */
/* Number of seconds elapsed today(0-86399, 00:00:00-23:59:59). */
case 1:
{
- time_t timer;
- struct tm *t;
-
- time(&timer);
- t = gmtime(&timer);
+ struct tm t = TimeT::now();
push_val(st->stack, ScriptCode::INT,
- ((t->tm_hour) * 3600 + (t->tm_min) * 60 + t->tm_sec));
+ t.tm_hour * 3600 + t.tm_min * 60 + t.tm_sec);
break;
}
/* Seconds since Unix epoch. */
case 2:
- push_val(st->stack, ScriptCode::INT, (int) time(NULL));
+ push_val(st->stack, ScriptCode::INT, static_cast<time_t>(TimeT::now()));
break;
/* System tick(unsigned int, and yes, it will wrap). */
case 0:
default:
- push_val(st->stack, ScriptCode::INT, (int) gettick().time_since_epoch().count());
+ push_val(st->stack, ScriptCode::INT, gettick().time_since_epoch().count());
break;
}
}
@@ -2671,37 +2667,32 @@ void builtin_gettimetick(ScriptState *st) /* Asgard Version */
static
void builtin_gettime(ScriptState *st) /* Asgard Version */
{
- int type;
- time_t timer;
- struct tm *t;
-
- type = conv_num(st, &(st->stack->stack_data[st->start + 2]));
+ int type = conv_num(st, &(st->stack->stack_data[st->start + 2]));
- time(&timer);
- t = gmtime(&timer);
+ struct tm t = TimeT::now();
switch (type)
{
case 1: //Sec(0~59)
- push_val(st->stack, ScriptCode::INT, t->tm_sec);
+ push_val(st->stack, ScriptCode::INT, t.tm_sec);
break;
case 2: //Min(0~59)
- push_val(st->stack, ScriptCode::INT, t->tm_min);
+ push_val(st->stack, ScriptCode::INT, t.tm_min);
break;
case 3: //Hour(0~23)
- push_val(st->stack, ScriptCode::INT, t->tm_hour);
+ push_val(st->stack, ScriptCode::INT, t.tm_hour);
break;
case 4: //WeekDay(0~6)
- push_val(st->stack, ScriptCode::INT, t->tm_wday);
+ push_val(st->stack, ScriptCode::INT, t.tm_wday);
break;
case 5: //MonthDay(01~31)
- push_val(st->stack, ScriptCode::INT, t->tm_mday);
+ push_val(st->stack, ScriptCode::INT, t.tm_mday);
break;
case 6: //Month(01~12)
- push_val(st->stack, ScriptCode::INT, t->tm_mon + 1);
+ push_val(st->stack, ScriptCode::INT, t.tm_mon + 1);
break;
case 7: //Year(20xx)
- push_val(st->stack, ScriptCode::INT, t->tm_year + 1900);
+ push_val(st->stack, ScriptCode::INT, t.tm_year + 1900);
break;
default: //(format error)
push_val(st->stack, ScriptCode::INT, -1);
@@ -2716,16 +2707,13 @@ void builtin_gettime(ScriptState *st) /* Asgard Version */
static
void builtin_gettimestr(ScriptState *st)
{
- char *tmpstr;
- int maxlen;
- time_t now = time(NULL);
+ struct tm now = TimeT::now();
const char *fmtstr = conv_str(st, &(st->stack->stack_data[st->start + 2]));
- maxlen = conv_num(st, &(st->stack->stack_data[st->start + 3]));
+ int maxlen = conv_num(st, &(st->stack->stack_data[st->start + 3]));
- tmpstr = (char *) calloc(maxlen + 1, 1);
- strftime(tmpstr, maxlen, fmtstr, gmtime(&now));
- tmpstr[maxlen] = '\0';
+ char *tmpstr = (char *) calloc(maxlen + 1, 1);
+ strftime(tmpstr, maxlen, fmtstr, &now);
push_str(st->stack, ScriptCode::STR, tmpstr);
}
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 4375541..df6ee13 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -561,7 +561,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl,
* 詠唱時間計算
*------------------------------------------
*/
-interval_t skill_castfix(struct block_list *bl, interval_t time)
+interval_t skill_castfix(struct block_list *bl, interval_t interval)
{
struct mob_data *md; // [Valaris]
eptr<struct status_change, StatusChange> sc_data;
@@ -592,48 +592,48 @@ interval_t skill_castfix(struct block_list *bl, interval_t time)
castnodex = skill_get_castnodex(skill, lv);
- if (time == interval_t::zero())
+ if (interval == interval_t::zero())
return interval_t::zero();
if (castnodex > 0 && bl->type == BL::PC)
castrate = 100;
else if (castnodex <= 0 && bl->type == BL::PC)
{
castrate = 100;
- time =
- time * castrate * (battle_config.castrate_dex_scale -
+ interval =
+ interval * castrate * (battle_config.castrate_dex_scale -
dex) / (battle_config.castrate_dex_scale *
100);
- time = time * battle_config.cast_rate / 100;
+ interval = interval * battle_config.cast_rate / 100;
}
- return std::max(time, interval_t::zero());
+ return std::max(interval, interval_t::zero());
}
/*==========================================
* ディレイ計算
*------------------------------------------
*/
-interval_t skill_delayfix(struct block_list *bl, interval_t time)
+interval_t skill_delayfix(struct block_list *bl, interval_t interval)
{
eptr<struct status_change, StatusChange> sc_data;
nullpo_retr(interval_t::zero(), bl);
sc_data = battle_get_sc_data(bl);
- if (time <= interval_t::zero())
+ if (interval <= interval_t::zero())
return interval_t::zero();
if (bl->type == BL::PC)
{
if (battle_config.delay_dependon_dex) /* dexの影響を計算する */
- time =
- time * (battle_config.castrate_dex_scale -
+ interval =
+ interval * (battle_config.castrate_dex_scale -
battle_get_dex(bl)) /
battle_config.castrate_dex_scale;
- time = time * battle_config.delay_rate / 100;
+ interval = interval * battle_config.delay_rate / 100;
}
- return std::max(time, interval_t::zero());
+ return std::max(interval, interval_t::zero());
}
/*==========================================
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index 0229f17..66b8bb9 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -27,21 +27,21 @@ int tmw_ShorterStrlen(const char *s1, const char *s2);
int tmw_CheckChatSpam(struct map_session_data *sd, const char *message)
{
nullpo_retr(1, sd);
- time_t now = time(NULL);
+ TimeT now = TimeT::now();
if (pc_isGM(sd))
return 0;
if (now > sd->chat_reset_due)
{
- sd->chat_reset_due = now + battle_config.chat_spam_threshold;
+ sd->chat_reset_due = static_cast<time_t>(now) + battle_config.chat_spam_threshold;
sd->chat_lines_in = 0;
}
if (now > sd->chat_repeat_reset_due)
{
sd->chat_repeat_reset_due =
- now + (battle_config.chat_spam_threshold * 60);
+ static_cast<time_t>(now) + (battle_config.chat_spam_threshold * 60);
sd->chat_total_repeats = 0;
}