diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-05-02 15:08:14 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-05-02 15:08:14 +0000 |
commit | e67711acbe9d29a2feb9293fccc72cd15603ee76 (patch) | |
tree | 4836c33e941c3aef9ee194fe9e9262f563653474 /src/map/map.c | |
parent | 1d835a4b7374e5f185d666bde1e3b0dbced86bd1 (diff) | |
download | hercules-e67711acbe9d29a2feb9293fccc72cd15603ee76.tar.gz hercules-e67711acbe9d29a2feb9293fccc72cd15603ee76.tar.bz2 hercules-e67711acbe9d29a2feb9293fccc72cd15603ee76.tar.xz hercules-e67711acbe9d29a2feb9293fccc72cd15603ee76.zip |
Replaced the very ineffective clif_foreachclient() with map_foreachpc() since they essentially do the same thing (bugreport:1174).
Rewrote map_foreachpc() so that its callback function signature now uses a more natural 'sd' instead of a DBKey/void* pair.
Rewrote atcommand_users() to use a single function, instead of depending on two helper functions and global objects.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12683 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/map/map.c b/src/map/map.c index c828ab9c7..1e7a48af7 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1739,12 +1739,22 @@ struct block_list * map_id2bl(int id) return bl; } -void map_foreachpc(int (*func)(DBKey,void*,va_list),...) +void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) { - va_list ap; - va_start(ap,func); - pc_db->vforeach(pc_db,func,ap); - va_end(ap); + DBIterator* iter; + struct map_session_data* sd; + va_list args, argscopy; + + va_start(args,func); + iter = pc_db->iterator(pc_db); + for( sd = (struct map_session_data*)iter->first(iter,NULL); iter->exists(iter); sd = (struct map_session_data*)iter->next(iter,NULL) ) + { + va_copy(argscopy,args); + func(sd, argscopy); + va_end(argscopy); + } + iter->destroy(iter); + va_end(args); } void map_foreachmob(int (*func)(DBKey,void*,va_list),...) @@ -3120,10 +3130,8 @@ void do_final(void) ShowStatus("Successfully terminated.\n"); } -static int map_abort_sub(DBKey key,void * data,va_list ap) +static int map_abort_sub(struct map_session_data* sd, va_list ap) { - struct map_session_data *sd = (TBL_PC*)data; - chrif_save(sd,1); return 1; } |