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://svn.code.sf.net/p/rathena/svn/trunk@12339 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
ad2bb04eab
commit
a5f7761c0f
@ -1442,19 +1442,11 @@ int ping_char_server(int tid, unsigned int tick, int id, int data)
|
|||||||
// unused
|
// unused
|
||||||
int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
|
int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
|
||||||
{
|
{
|
||||||
int count = 0;
|
|
||||||
struct s_mapiterator* iter;
|
|
||||||
|
|
||||||
chrif_check(-1);
|
chrif_check(-1);
|
||||||
|
|
||||||
iter = mapit_getallusers();
|
|
||||||
for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
|
|
||||||
count++;
|
|
||||||
mapit_free(iter);
|
|
||||||
|
|
||||||
WFIFOHEAD(char_fd,4);
|
WFIFOHEAD(char_fd,4);
|
||||||
WFIFOW(char_fd,0) = 0x2afe;
|
WFIFOW(char_fd,0) = 0x2afe;
|
||||||
WFIFOW(char_fd,2) = count;
|
WFIFOW(char_fd,2) = map_usercount();
|
||||||
WFIFOSET(char_fd,4);
|
WFIFOSET(char_fd,4);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -164,23 +164,6 @@ uint16 clif_getport(void)
|
|||||||
return map_port;
|
return map_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
|
||||||
* 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()実行
|
* 全てのclientに対してfunc()実行
|
||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
|
@ -91,7 +91,6 @@ void clif_setport(uint16 port);
|
|||||||
uint32 clif_getip(void);
|
uint32 clif_getip(void);
|
||||||
uint32 clif_refresh_ip(void);
|
uint32 clif_refresh_ip(void);
|
||||||
uint16 clif_getport(void);
|
uint16 clif_getport(void);
|
||||||
int clif_countusers(void);
|
|
||||||
void clif_setwaitclose(int);
|
void clif_setwaitclose(int);
|
||||||
|
|
||||||
int clif_authok(struct map_session_data *);
|
int clif_authok(struct map_session_data *);
|
||||||
|
@ -170,14 +170,28 @@ void map_setusers(int users)
|
|||||||
map_users = users;
|
map_users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
|
||||||
* 全map鯖?計での接??取得 (/wへの?答用)
|
|
||||||
*------------------------------------------*/
|
|
||||||
int map_getusers(void)
|
int map_getusers(void)
|
||||||
{
|
{
|
||||||
return map_users;
|
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削除の安全性確保?理
|
// block削除の安全性確保?理
|
||||||
//
|
//
|
||||||
|
@ -1269,6 +1269,7 @@ extern char wisp_server_name[];
|
|||||||
// ŽI‘S‘Ì<E28098>î•ñ
|
// ŽI‘S‘Ì<E28098>î•ñ
|
||||||
void map_setusers(int);
|
void map_setusers(int);
|
||||||
int map_getusers(void);
|
int map_getusers(void);
|
||||||
|
int map_usercount(void);
|
||||||
// block<63>í<EFBFBD>œŠÖ˜A
|
// block<63>í<EFBFBD>œŠÖ˜A
|
||||||
int map_freeblock(struct block_list *bl);
|
int map_freeblock(struct block_list *bl);
|
||||||
int map_freeblock_lock(void);
|
int map_freeblock_lock(void);
|
||||||
|
@ -6900,7 +6900,7 @@ int pc_autosave(int tid,unsigned int tick,int id,int data)
|
|||||||
}
|
}
|
||||||
mapit_free(iter);
|
mapit_free(iter);
|
||||||
|
|
||||||
interval = autosave_interval/(clif_countusers()+1);
|
interval = autosave_interval/(map_usercount()+1);
|
||||||
if(interval < minsave_interval)
|
if(interval < minsave_interval)
|
||||||
interval = minsave_interval;
|
interval = minsave_interval;
|
||||||
add_timer(gettick()+interval,pc_autosave,0,0);
|
add_timer(gettick()+interval,pc_autosave,0,0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user