summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/chrif.c10
-rw-r--r--src/map/clif.c17
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/map.c20
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/pc.c2
6 files changed, 20 insertions, 31 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 941e17968..7a7c9873a 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1442,19 +1442,11 @@ int ping_char_server(int tid, unsigned int tick, int id, int data)
// unused
int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
{
- int count = 0;
- struct s_mapiterator* iter;
-
chrif_check(-1);
- iter = mapit_getallusers();
- for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
- count++;
- mapit_free(iter);
-
WFIFOHEAD(char_fd,4);
WFIFOW(char_fd,0) = 0x2afe;
- WFIFOW(char_fd,2) = count;
+ WFIFOW(char_fd,2) = map_usercount();
WFIFOSET(char_fd,4);
return 0;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 1b6b143bc..5a0d9562c 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -165,23 +165,6 @@ uint16 clif_getport(void)
}
/*==========================================
- * Counts connected players.
- *------------------------------------------*/
-int clif_countusers(void)
-{
- int users = 0, i;
- struct map_session_data *sd;
-
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) &&
- sd->state.active && !(battle_config.hide_GM_session && pc_isGM(sd)))
- users++;
- }
- return users;
-}
-
-/*==========================================
* 全てのclientに対してfunc()実行
*------------------------------------------*/
int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //recoded by sasuke, bug when player count gets higher [Kevin]
diff --git a/src/map/clif.h b/src/map/clif.h
index adb12ffc1..286eaa6f1 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -91,7 +91,6 @@ void clif_setport(uint16 port);
uint32 clif_getip(void);
uint32 clif_refresh_ip(void);
uint16 clif_getport(void);
-int clif_countusers(void);
void clif_setwaitclose(int);
int clif_authok(struct map_session_data *);
diff --git a/src/map/map.c b/src/map/map.c
index a9ac939bf..27eeab5d2 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -170,14 +170,28 @@ void map_setusers(int users)
map_users = users;
}
-/*==========================================
- * 全map鯖?計での接??取得 (/wへの?答用)
- *------------------------------------------*/
int map_getusers(void)
{
return map_users;
}
+/*==========================================
+ * server player count (this mapserver only)
+ *------------------------------------------*/
+int map_usercount(void)
+{
+/*
+ int count = 0;
+ struct s_mapiterator* iter = mapit_getallusers();
+ for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
+ count++;
+ mapit_free(iter);
+ return count;
+*/
+ // since pc_db now only holds fully authed players, this approach is equivalent:
+ return pc_db->size(pc_db);
+}
+
//
// block削除の安全性確保?理
//
diff --git a/src/map/map.h b/src/map/map.h
index eac91c219..06d3922c7 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1269,6 +1269,7 @@ extern char wisp_server_name[];
// 鯖全体情報
void map_setusers(int);
int map_getusers(void);
+int map_usercount(void);
// block削除関連
int map_freeblock(struct block_list *bl);
int map_freeblock_lock(void);
diff --git a/src/map/pc.c b/src/map/pc.c
index b0d6cf5b2..fc0eb55f2 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -6900,7 +6900,7 @@ int pc_autosave(int tid,unsigned int tick,int id,int data)
}
mapit_free(iter);
- interval = autosave_interval/(clif_countusers()+1);
+ interval = autosave_interval/(map_usercount()+1);
if(interval < minsave_interval)
interval = minsave_interval;
add_timer(gettick()+interval,pc_autosave,0,0);