summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-11 20:16:55 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-11 20:16:55 +0000
commit792dfbb243bcbeee644bd096b7bd925a1e5c1e74 (patch)
treefa4735cd176917ba43883793fe215defe885220f /src/map/pc.c
parentb9687899ece983642d2a83b4eee47a990a92cacc (diff)
downloadhercules-792dfbb243bcbeee644bd096b7bd925a1e5c1e74.tar.gz
hercules-792dfbb243bcbeee644bd096b7bd925a1e5c1e74.tar.bz2
hercules-792dfbb243bcbeee644bd096b7bd925a1e5c1e74.tar.xz
hercules-792dfbb243bcbeee644bd096b7bd925a1e5c1e74.zip
- Fixed clif_parse not checking for func_parse before sending data to the connected clients. This in turn required various code-rewrites in:
- duel related messaging functions (added clif targets DUEL/DUEL_WOS). - intif whisper to gm function - day/night timers - Rewrote the parse_console function to stop allocating/deallocating memory on every call. - Modified chrif_charselectreq to receive the player's ip among the data. - Added function clif_disp_message, which is the same as clif_disp_onlyself, except you can specify the targets (it sends a guild-chat packet) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7617 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c59
1 files changed, 23 insertions, 36 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index fa7d614ff..a36c38e13 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -7105,7 +7105,16 @@ int pc_read_gm_account(int fd)
}
return GM_num;
}
-
+static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap)
+{
+ if (sd->state.night != night_flag && map[sd->bl.m].flag.nightenabled)
+ { //Night/day state does not match.
+ clif_status_load(&sd->bl, SI_NIGHT, night_flag); //New night effect by dynamix [Skotlex]
+ sd->state.night = night_flag;
+ return 1;
+ }
+ return 0;
+}
/*================================================
* timer to do the day [Yor]
* data: 0 = called by timer, 1 = gmcommand/script
@@ -7114,29 +7123,17 @@ int pc_read_gm_account(int fd)
int map_day_timer(int tid, unsigned int tick, int id, int data)
{
char tmp_soutput[1024];
- struct map_session_data *pl_sd;
if (data == 0 && battle_config.day_duration <= 0) // if we want a day
return 0;
- if (night_flag != 0) {
- int i;
- night_flag = 0; // 0=day, 1=night [Yor]
-
- for(i = 0; i < fd_max; i++) {
- if (session[i] && (pl_sd = (struct map_session_data *) session[i]->session_data) && pl_sd->state.auth && pl_sd->fd)
- {
- if (pl_sd->state.night) {
- clif_status_load(&pl_sd->bl, SI_NIGHT, 0); //New night effect by dynamix [Skotlex]
- pl_sd->state.night = 0;
- }
- }
- }
-
- strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived!
- intif_GMmessage(tmp_soutput, strlen(tmp_soutput) + 1, 0);
- }
-
+ if (!night_flag)
+ return 0; //Already day.
+
+ night_flag = 0; // 0=day, 1=night [Yor]
+ clif_foreachclient(pc_daynight_timer_sub);
+ strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived!
+ intif_GMmessage(tmp_soutput, strlen(tmp_soutput) + 1, 0);
return 0;
}
@@ -7148,27 +7145,17 @@ int map_day_timer(int tid, unsigned int tick, int id, int data)
int map_night_timer(int tid, unsigned int tick, int id, int data)
{
char tmp_soutput[1024];
- struct map_session_data *pl_sd;
if (data == 0 && battle_config.night_duration <= 0) // if we want a night
return 0;
- if (night_flag == 0) {
- int i;
- night_flag = 1; // 0=day, 1=night [Yor]
- for(i = 0; i < fd_max; i++) {
- if (session[i] && (pl_sd = (struct map_session_data *) session[i]->session_data) && pl_sd->state.auth && pl_sd->fd)
- {
- if (!pl_sd->state.night && map[pl_sd->bl.m].flag.nightenabled) {
- clif_status_load(&pl_sd->bl, SI_NIGHT, 1); //New night effect by dynamix [Skotlex]
- pl_sd->state.night = 1;
- }
- }
- }
- strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen...
- intif_GMmessage(tmp_soutput, strlen(tmp_soutput) + 1, 0);
- }
+ if (night_flag)
+ return 0; //Already nigth.
+ night_flag = 1; // 0=day, 1=night [Yor]
+ clif_foreachclient(pc_daynight_timer_sub);
+ strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen...
+ intif_GMmessage(tmp_soutput, strlen(tmp_soutput) + 1, 0);
return 0;
}