diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-02-11 17:46:31 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-02-11 17:46:31 +0000 |
commit | c2e7d12b8baff6c190b1a61c175366a6af15326d (patch) | |
tree | becd092d9c0d11065f722991c7caace7502c9535 /src/map/chrif.c | |
parent | c31be7e56e5c1d4345df7c5baf6fb4f4c412d7aa (diff) | |
download | hercules-c2e7d12b8baff6c190b1a61c175366a6af15326d.tar.gz hercules-c2e7d12b8baff6c190b1a61c175366a6af15326d.tar.bz2 hercules-c2e7d12b8baff6c190b1a61c175366a6af15326d.tar.xz hercules-c2e7d12b8baff6c190b1a61c175366a6af15326d.zip |
Getting rid of map_getallusers(), part 1
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12195 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r-- | src/map/chrif.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c index c5ee538ea..e88ee3c5d 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1326,12 +1326,16 @@ 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; + int count = 0; + struct s_mapiterator* iter; chrif_check(-1); - - map_getallusers(&count); - + + 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; @@ -1345,22 +1349,32 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, int data) *------------------------------------------*/ int send_users_tochar(void) { - int count, users=0, i; - struct map_session_data **all_sd; + int users = 0, i = 0; + struct map_session_data* sd; + struct s_mapiterator* iter; chrif_check(-1); - all_sd = map_getallusers(&count); + // get user count (TODO: improve this) + iter = mapit_getallusers(); + for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) ) + users++; + mapit_free(iter); + + // build the packet WFIFOHEAD(char_fd, 6+8*users); WFIFOW(char_fd,0) = 0x2aff; - for (i = 0; i < count; i++) { - WFIFOL(char_fd,6+8*users) = all_sd[i]->status.account_id; - WFIFOL(char_fd,6+8*users+4) = all_sd[i]->status.char_id; - users++; + iter = mapit_getallusers(); + for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) + { + WFIFOL(char_fd,6+8*i) = sd->status.account_id; + WFIFOL(char_fd,6+8*i+4) = sd->status.char_id; + i++; } - WFIFOW(char_fd,2) = 6 + 8 * users; + mapit_free(iter); + WFIFOW(char_fd,2) = 6 + 8*users; WFIFOW(char_fd,4) = users; - WFIFOSET(char_fd,6+8*users); + WFIFOSET(char_fd, 6+8*users); return 0; } |