summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chrif.c15
-rw-r--r--src/map/chrif.h2
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/pc.c31
4 files changed, 35 insertions, 19 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 236590ff3..353533561 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -943,6 +943,21 @@ int chrif_char_offline(struct map_session_data *sd)
* Tell char-server to reset all chars offline [Wizputer]
*-----------------------------------------
*/
+int chrif_flush_fifo(void) {
+ if (char_fd < 1)
+ return -1;
+
+ set_nonblocking(char_fd, 0);
+ flush_fifos();
+ set_nonblocking(char_fd, 1);
+
+ return 0;
+}
+
+/*=========================================
+ * Tell char-server to reset all chars offline [Wizputer]
+ *-----------------------------------------
+ */
int chrif_char_reset_offline(void) {
if (char_fd < 1)
return -1;
diff --git a/src/map/chrif.h b/src/map/chrif.h
index d53631e25..7f55d23d6 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -33,4 +33,6 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data);
int do_init_chrif(void);
+int chrif_flush_fifo(void);
+
#endif
diff --git a/src/map/map.c b/src/map/map.c
index 46705dc8d..4e7223d11 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2489,7 +2489,7 @@ static int cleanup_sub(struct block_list *bl, va_list ap) {
switch(bl->type) {
case BL_PC:
- map_delblock(bl); // There is something better...
+ map_quit((struct map_session_data *) bl);
break;
case BL_NPC:
npc_delete((struct npc_data *)bl);
@@ -2522,9 +2522,13 @@ void do_final(void) {
if(map[map_id].m)
map_foreachinarea(cleanup_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, 0, 0);
}
+
#ifndef TXT_ONLY
chrif_char_reset_offline();
#endif
+
+ chrif_flush_fifo();
+
for (i = 0; i < fd_max; i++)
delete_session(i);
diff --git a/src/map/pc.c b/src/map/pc.c
index d314d2e30..881d302c5 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -183,7 +183,6 @@ int pc_delinvincibletimer(struct map_session_data *sd) {
static int pc_spiritball_timer(int tid,unsigned int tick,int id,int data) {
struct map_session_data *sd;
- int i;
if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC )
return 1;
@@ -193,22 +192,24 @@ static int pc_spiritball_timer(int tid,unsigned int tick,int id,int data) {
printf("spirit_timer %d != %d\n",sd->spirit_timer[0],tid);
return 0;
}
- sd->spirit_timer[0]=-1;
- for(i=1;i<sd->spiritball;i++) {
- sd->spirit_timer[i-1] = sd->spirit_timer[i];
- sd->spirit_timer[i] = -1;
+
+ if(sd->spiritball <= 0) {
+ if(battle_config.error_log)
+ printf("Spiritballs are already 0 when pc_spiritball_timer gets called");
+ sd->spiritball = 0;
+ return 0;
}
+
sd->spiritball--;
- if(sd->spiritball < 0)
- sd->spiritball = 0;
+ memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * sd->spiritball );
+ sd->spirit_timer[sd->spiritball]=-1;
+
clif_spiritball(sd);
return 0;
}
int pc_addspiritball(struct map_session_data *sd,int interval,int max) {
- int i;
-
nullpo_retr(0, sd);
if(max > MAX_SKILL_LEVEL)
@@ -217,16 +218,10 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) {
sd->spiritball = 0;
if(sd->spiritball >= max) {
- if(sd->spirit_timer[0] != -1) {
+ if(sd->spirit_timer[0] != -1)
delete_timer(sd->spirit_timer[0],pc_spiritball_timer);
- sd->spirit_timer[0] = -1;
- }
- for(i=1;i<max;i++) {
- sd->spirit_timer[i-1] = sd->spirit_timer[i];
- sd->spirit_timer[i] = -1;
- }
- }
- else
+ memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * (sd->spiritball - 1));
+ } else
sd->spiritball++;
sd->spirit_timer[sd->spiritball-1] = add_timer(gettick()+interval,pc_spiritball_timer,sd->bl.id,0);