From 64324150783c2b822e5263e0e0a9ae0cc23d7ff1 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 12 Dec 2010 13:10:08 +0000 Subject: * Updates to the playBGM functionality (since r14335). - Removed impossible condition in playBGM script command (from soundeffect). - Removed unused code (retrieving of a bl) in playBGMall (from soundeffectall). - Made playBGMall default to 'entire server' when both map name and coordinates are omitted instead of printing an error. - Updated documentation for playBGM and playBGMall to match actual behavior. - Removed unused parameter 'bl' in clif_playBGM. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14582 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/script.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index c408846a3..8989aa37e 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10802,27 +10802,34 @@ BUILDIN_FUNC(misceffect) *------------------------------------------*/ BUILDIN_FUNC(playBGM) { - TBL_PC* sd = script_rid2sd(st); - const char* name = script_getstr(st,2); + const char* name; + struct map_session_data* sd; - if(sd) + if( ( sd = script_rid2sd(st) ) != NULL ) { - if(!st->rid) - clif_playBGM(sd,map_id2bl(st->oid),name); - else - clif_playBGM(sd,&sd->bl,name); + name = script_getstr(st,2); + + clif_playBGM(sd, name); } return 0; } -int playBGM_sub(struct block_list* bl,va_list ap) +static int playBGM_sub(struct block_list* bl,va_list ap) { - char* name = va_arg(ap,char*); + const char* name = va_arg(ap,const char*); - clif_playBGM((TBL_PC *)bl, bl, name); + clif_playBGM(BL_CAST(BL_PC, bl), name); - return 0; + return 0; +} + +static int playBGM_foreachpc_sub(struct map_session_data* sd, va_list args) +{ + const char* name = va_arg(args, const char*); + + clif_playBGM(sd, name); + return 0; } /*========================================== @@ -10830,33 +10837,29 @@ int playBGM_sub(struct block_list* bl,va_list ap) *------------------------------------------*/ BUILDIN_FUNC(playBGMall) { - struct block_list* bl; const char* name; - bl = (st->rid) ? &(script_rid2sd(st)->bl) : map_id2bl(st->oid); - if (!bl) - return 0; - name = script_getstr(st,2); - if(script_hasdata(st,7)) - { // specified part of map + if( script_hasdata(st,7) ) + {// specified part of map const char* map = script_getstr(st,3); int x0 = script_getnum(st,4); int y0 = script_getnum(st,5); int x1 = script_getnum(st,6); int y1 = script_getnum(st,7); + map_foreachinarea(playBGM_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name); } - else - if(!script_hasdata(st,7)) - { // entire map + else if( script_hasdata(st,3) ) + {// entire map const char* map = script_getstr(st,3); + map_foreachinmap(playBGM_sub, map_mapname2mapid(map), BL_PC, name); } else - { - ShowError("buildin_playBGMall: insufficient arguments for specific area broadcast.\n"); + {// entire server + map_foreachpc(&playBGM_foreachpc_sub, name); } return 0; -- cgit v1.2.3-70-g09d2