summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-22 18:19:11 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-22 18:19:11 +0000
commit86419b56c3c04ee10b6c58906124a471b9853d8b (patch)
tree4c5e26d179d09370318bcf4ac0cad45e4927008b /src/map/pc.c
parent93344af48f44a7a3e535831318fe9c991a015ed4 (diff)
downloadhercules-86419b56c3c04ee10b6c58906124a471b9853d8b.tar.gz
hercules-86419b56c3c04ee10b6c58906124a471b9853d8b.tar.bz2
hercules-86419b56c3c04ee10b6c58906124a471b9853d8b.tar.xz
hercules-86419b56c3c04ee10b6c58906124a471b9853d8b.zip
* Removed code in socket.c that tries to avoid send buffer overloading, as there is a scenario (many players and charserver disconnect) where mass char saving produces huge ammounts of data to send (see r11503)
* Cleaned up player respawning code (bugreport:1022) * Increased the max amount of different autocast skills from 5 to 10 * Added a missing function declaration, for real this time (followup to r12229) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12232 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 57f68f201..24e7be3b9 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4735,17 +4735,21 @@ int pc_skillheal_bonus(struct map_session_data *sd, int skill_num)
return 0;
}
-static int pc_respawn(int tid,unsigned int tick,int id,int data)
+void pc_respawn(struct map_session_data* sd, uint8 clrtype)
{
- struct map_session_data *sd = map_id2sd(id);
- if (sd && pc_isdead(sd))
- { //Auto-respawn [Skotlex]
- pc_setstand(sd);
- pc_setrestartvalue(sd,3);
- if(pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0))
- clif_resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet.
+ if( !pc_isdead(sd) )
+ return; // not applicable
- }
+ pc_setstand(sd);
+ pc_setrestartvalue(sd,3);
+ if(pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, clrtype))
+ clif_resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet.
+}
+
+static int pc_respawn_timer(int tid,unsigned int tick,int id,int data)
+{
+ struct map_session_data *sd = map_id2sd(id);
+ pc_respawn(sd,0);
return 0;
}
@@ -5064,13 +5068,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
}
if( sd->pvp_point < 0 ){
sd->pvp_point=0;
- add_timer(tick+1000, pc_respawn,sd->bl.id,0);
+ add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0);
return 1;
}
}
//GvG
if(map_flag_gvg(sd->bl.m)){
- add_timer(tick+1000, pc_respawn,sd->bl.id,0);
+ add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0);
return 1;
}
@@ -6807,41 +6811,38 @@ int pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y)
}
/*==========================================
- * 自動セ?ブ 各クライアント
- *------------------------------------------*/
-static int last_save_id=0,save_flag=0;
-static int pc_autosave_sub(DBKey key,void * data,va_list ap)
-{
- struct map_session_data *sd = (TBL_PC*)data;
-
- if(sd->bl.id == last_save_id && save_flag != 1) {
- save_flag = 1;
- return 1;
- }
-
- if(save_flag != 1) //Not our turn to save yet.
- return 0;
-
- //Save char.
- last_save_id = sd->bl.id;
- save_flag=2;
-
- chrif_save(sd,0);
- return 1;
-}
-
-/*==========================================
* 自動セ?ブ (timer??)
*------------------------------------------*/
int pc_autosave(int tid,unsigned int tick,int id,int data)
{
int interval;
+ struct s_mapiterator* iter;
+ struct map_session_data* sd;
+ static int last_save_id = 0, save_flag = 0;
if(save_flag == 2) //Someone was saved on last call, normal cycle
save_flag = 0;
else
save_flag = 1; //Noone was saved, so save first found char.
- map_foreachpc(pc_autosave_sub);
+
+ iter = mapit_getallusers();
+ for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
+ {
+ if(sd->bl.id == last_save_id) {
+ save_flag = 1;
+ continue;
+ }
+
+ if(save_flag != 1) //Not our turn to save yet.
+ continue;
+
+ //Save char.
+ last_save_id = sd->bl.id;
+ save_flag = 2;
+
+ chrif_save(sd,0);
+ }
+ mapit_free(iter);
interval = autosave_interval/(clif_countusers()+1);
if(interval < minsave_interval)