summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-11 09:44:12 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-11 09:44:12 +0000
commite73c1ee5e26f59380806d0dcd90c4ed6617e76ef (patch)
treee70f78223b4f35b72a3a1174a8a5294333d913e1 /src/map
parent66773fbfe4b20141c76241c79b53893d7890cfd0 (diff)
downloadhercules-e73c1ee5e26f59380806d0dcd90c4ed6617e76ef.tar.gz
hercules-e73c1ee5e26f59380806d0dcd90c4ed6617e76ef.tar.bz2
hercules-e73c1ee5e26f59380806d0dcd90c4ed6617e76ef.tar.xz
hercules-e73c1ee5e26f59380806d0dcd90c4ed6617e76ef.zip
Replaced clif_countusers() with a more efficient alternative (thanks to the fact that pc_db now only holds fully authed players only).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12339 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-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);