* Changes to map_foreach* functions:
- removed the unecessary use of va_copy in map_foreachpc - applied the same function pattern to map_foreachmob and map_foreachiddb - created map_foreachnpc - extended the behaviour of map_foreach* functions to stop iterating when func returns -1 (also added missing changelog entries from ultramage >.>) git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12684 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
62cc01866b
commit
1be6ba4a63
@ -3,12 +3,39 @@ Date Added
|
||||
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
|
||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
|
||||
2008/05/02
|
||||
* Changes to map_foreach* functions: [FlavioJS]
|
||||
- removed the unecessary use of va_copy in map_foreachpc
|
||||
- applied the same function pattern to map_foreachmob and map_foreachiddb
|
||||
- created map_foreachnpc
|
||||
- extended the behaviour of map_foreach* functions to stop iterating when func returns -1
|
||||
* 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.
|
||||
* Added a custom implementation of the va_copy macro for systems that don't provide it.
|
||||
* Fixed varargs not being used correctly in foreach() calls in db.c (bugreport:551).
|
||||
* Replaced the integers+checking approach in r12679 with usage of floating point arithmetic.
|
||||
* Applied search&replace to use the new name of the function.
|
||||
* Implemented get_percentage() for compact and safe calculation of percentual values.
|
||||
* Fixed integer arithmetic overflows that were occuring in several supernovice checks (bugreport:1135). [ultramage]
|
||||
2008/05/01
|
||||
* Updated mob_db.sql to latest [Toms]
|
||||
2008/04/30
|
||||
* Rev. 12676 Corrected several effect descriptions. [L0ne_W0lf]
|
||||
2008/04/28
|
||||
* Cleaned up char server set online/offline/char select functions. (r12670) [Kevin]
|
||||
2008/04/27
|
||||
* Fixing some timestamp type difference warnings...
|
||||
* Removed the calc_times() no-op (bugreport:1289).
|
||||
* Corrected r12662 where a guild break would trigger the OnGuildBreak event for all castles (even of other guilds).
|
||||
* Corrected some x64 compilation warnings in ers/malloc files.
|
||||
* Cleaned up a case of bad variable reuse.
|
||||
* Cleaning up the itemdb reload mess (see r12635, r12643, r12650, r12661, r12662, r12663): [ultramage]
|
||||
- the player data inventory-itemdb index is now refreshed using pc_setinventorydata()
|
||||
- mobdb will no longer initialize with nonexistent items, and mobs will no longer drop them in case of a reload
|
||||
- the clif_buylist() function once again hides invalid npc shop items
|
||||
- it is no longer possible to purchase nonexistent items from a npc shop
|
||||
- npc shop loading will not abort if there is a nonexistent item entry, it will just skip over it
|
||||
2008/04/26
|
||||
* Added script function hasquest. [Kevin]
|
||||
* Fixed OnGuildBreak. [Kevin]
|
||||
@ -50,6 +77,12 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
* Implemented config setting 'vending_over_max', to let people configure
|
||||
the behavior of vending items over the MAX_ZENY limit [ultramage]
|
||||
* Fixed mapserv crash, thanks to Konard [Lupus]
|
||||
2008/04/17
|
||||
* Modified sv_readdb to be able to process non-native line terminators (bugreport:1382) [ultramage]
|
||||
2008/04/16
|
||||
* Fixed an issue in r12575 where 'not setting char offline when going from mapserver to charserver' also caused a permanent account lockout if the player pressed 'cancel' in the char select screen.
|
||||
* Merged some recent changes from SQL to TXT, as someone didn't bother to do it.
|
||||
* Ifdefed the quest data request code as SQL-only (this was causing server disconnects whenver someone logged in). [ultramage]
|
||||
2008/04/15
|
||||
* Use the same code for script commands getitem & getitem2 as @item to avoid
|
||||
bug in bugreport:1324 (non-stackable items are stacked) [Toms]
|
||||
@ -88,6 +121,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
* Login will no longer set character offline when going from map
|
||||
to character select. (r12575) [Kevin]
|
||||
2008/04/11
|
||||
* The max_account_id packetver detection mechanism will never cause any connection problems ever again. (bugreport:388)
|
||||
* Reverted the `login` table changes from r12464 [ultramage]
|
||||
* Finished most of the quest log code, still bits here and there
|
||||
but it's ready for testing. (r12558) [Kevin]
|
||||
@ -96,6 +130,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
* Client not marked online until map receives auth request from the client
|
||||
- and is approved. Also added some online/offline sets to the auth system
|
||||
- that were being skipped.(r12552) [Kevin]
|
||||
* Modified the charservers to use a DBMap instead of a cyclic array for auth data.
|
||||
* Merged the auth fix from r12473 to TXT as well.
|
||||
* Removed the no-op from r12547. [ultramage]
|
||||
* Rev. 12550 Reverted the change to MAX_SQUARE_LAYOUT. [L0ne_W0lf]
|
||||
* Rev. 12548 Updated NPC skill "Evil Land". More gravity wtfage. [L0ne_W0lf]
|
||||
- Based on visual observation, and experience with it on iRO Sakray.
|
||||
@ -105,6 +142,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
* Fixed party invitation ack messages not displaying (bugreport:1308)
|
||||
* Modified PACKETVER for recent clients to use a YYYYMMDD date format
|
||||
instead of a simple sequence number (allows adding versions inbetween)
|
||||
* Small party/guild creation cleanup. Added packet comments. Removed fake reply packet usage. [ultramage]
|
||||
2008/04/07
|
||||
* Rev. 12529 Updated MAX_GUARDIANS to support an insane amount of guardians. [L0ne_W0lf]
|
||||
* Immunity to magic now makes you immune to the SC effect as well. (r12527) [Kevin]
|
||||
@ -175,6 +213,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
* Added sv_split to strlib.c/h (similar to sv_parse). [FlavioJS]
|
||||
2008/03/31
|
||||
* Fixed ACIDDEMO crash, thanks to Kaato&Konard [Lupus]
|
||||
* Added latest version of dbghelp.dll (from microsoft debugger package), to prevent Windows from loading other, outdated versions.
|
||||
This caused the dbghelpplug plugin to omit information about structures when producing a backtrace. [ultramage]
|
||||
2008/03/30
|
||||
* yet more login server stuff
|
||||
- jA data structure compatibility renaming / adjustments
|
||||
|
@ -1739,43 +1739,93 @@ struct block_list * map_id2bl(int id)
|
||||
return bl;
|
||||
}
|
||||
|
||||
/// Applies func to all the players in the db.
|
||||
/// Stops iterating if func returns -1.
|
||||
void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...)
|
||||
{
|
||||
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);
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, func);
|
||||
ret = func(sd, args);
|
||||
va_end(args);
|
||||
if( ret == -1 )
|
||||
break;// stop iterating
|
||||
}
|
||||
iter->destroy(iter);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void map_foreachmob(int (*func)(DBKey,void*,va_list),...)
|
||||
/// Applies func to all the mobs in the db.
|
||||
/// Stops iterating if func returns -1.
|
||||
void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,func);
|
||||
mobid_db->vforeach(mobid_db,func,ap);
|
||||
va_end(ap);
|
||||
DBIterator* iter;
|
||||
struct mob_data* md;
|
||||
|
||||
iter = db_iterator(mobid_db);
|
||||
for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) )
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, func);
|
||||
ret = func(md, args);
|
||||
va_end(args);
|
||||
if( ret == -1 )
|
||||
break;// stop iterating
|
||||
}
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* id_db?‚Ì‘S‚Ä‚Éfunc‚ð?<EFBFBD>s
|
||||
*------------------------------------------*/
|
||||
int map_foreachiddb(int (*func)(DBKey,void*,va_list),...)
|
||||
/// Applies func to all the npcs in the db.
|
||||
/// Stops iterating if func returns -1.
|
||||
void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...)
|
||||
{
|
||||
va_list ap;
|
||||
DBIterator* iter;
|
||||
struct block_list* bl;
|
||||
|
||||
va_start(ap,func);
|
||||
id_db->vforeach(id_db,func,ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
iter = db_iterator(id_db);
|
||||
for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) )
|
||||
{
|
||||
if( bl->type == BL_NPC )
|
||||
{
|
||||
struct npc_data* nd = (struct npc_data*)bl;
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, func);
|
||||
ret = func(nd, args);
|
||||
va_end(args);
|
||||
if( ret == -1 )
|
||||
break;// stop iterating
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies func to everything in the db.
|
||||
/// Stops iterating if func returns -1.
|
||||
void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...)
|
||||
{
|
||||
DBIterator* iter;
|
||||
struct block_list* bl;
|
||||
|
||||
iter = db_iterator(id_db);
|
||||
for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) )
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, func);
|
||||
ret = func(bl, args);
|
||||
va_end(args);
|
||||
if( ret == -1 )
|
||||
break;// stop iterating
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator.
|
||||
|
@ -563,8 +563,9 @@ int map_eraseallipport(void);
|
||||
void map_addiddb(struct block_list *);
|
||||
void map_deliddb(struct block_list *bl);
|
||||
void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...);
|
||||
void map_foreachmob(int (*func)(DBKey,void*,va_list),...);
|
||||
int map_foreachiddb(int (*)(DBKey,void*,va_list),...);
|
||||
void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...);
|
||||
void map_foreachnpc(int (*func)(struct npc_data* bl, va_list args), ...);
|
||||
void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...);
|
||||
struct map_session_data * map_nick2sd(const char*);
|
||||
|
||||
/// Bitfield of flags for the iterator.
|
||||
|
@ -1666,9 +1666,8 @@ static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
|
||||
/*==========================================
|
||||
* Negligent mode MOB AI (PC is not in near)
|
||||
*------------------------------------------*/
|
||||
static int mob_ai_sub_lazy(DBKey key,void * data,va_list ap)
|
||||
static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
|
||||
{
|
||||
struct mob_data *md = (struct mob_data *)data;
|
||||
unsigned int tick;
|
||||
int mode;
|
||||
|
||||
@ -1677,7 +1676,7 @@ static int mob_ai_sub_lazy(DBKey key,void * data,va_list ap)
|
||||
if(md->bl.prev == NULL)
|
||||
return 0;
|
||||
|
||||
tick=va_arg(ap,unsigned int);
|
||||
tick = va_arg(args,unsigned int);
|
||||
|
||||
if (md->nd || (battle_config.mob_ai&0x20 && map[md->bl.m].users>0))
|
||||
return (int)mob_ai_sub_hard(md, tick);
|
||||
|
@ -1311,15 +1311,14 @@ static int npc_unload_ev(DBKey key, void* data, va_list ap)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int npc_unload_dup_sub(DBKey key, void* data, va_list ap)
|
||||
static int npc_unload_dup_sub(struct npc_data* nd, va_list args)
|
||||
{
|
||||
struct npc_data *nd = (struct npc_data *)data;
|
||||
int src_id;
|
||||
|
||||
if(nd->bl.type!=BL_NPC || nd->subtype != SCRIPT)
|
||||
if( nd->subtype != SCRIPT )
|
||||
return 0;
|
||||
|
||||
src_id=va_arg(ap,int);
|
||||
src_id = va_arg(args, int);
|
||||
if (nd->u.scr.src_id == src_id)
|
||||
npc_unload(nd);
|
||||
return 0;
|
||||
@ -1328,7 +1327,7 @@ static int npc_unload_dup_sub(DBKey key, void* data, va_list ap)
|
||||
//Removes all npcs that are duplicates of the passed one. [Skotlex]
|
||||
void npc_unload_duplicates(struct npc_data* nd)
|
||||
{
|
||||
map_foreachiddb(npc_unload_dup_sub,nd->bl.id);
|
||||
map_foreachnpc(npc_unload_dup_sub,nd->bl.id);
|
||||
}
|
||||
|
||||
int npc_unload(struct npc_data* nd)
|
||||
|
@ -7228,9 +7228,8 @@ int status_change_clear_buffs (struct block_list* bl, int type)
|
||||
|
||||
//Natural regen related stuff.
|
||||
static unsigned int natural_heal_prev_tick,natural_heal_diff_tick;
|
||||
static int status_natural_heal(DBKey key,void * data,va_list ap)
|
||||
static int status_natural_heal(struct block_list* bl, va_list args)
|
||||
{
|
||||
struct block_list *bl = (struct block_list*)data;
|
||||
struct regen_data *regen;
|
||||
struct status_data *status;
|
||||
struct status_change *sc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user