summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-03 15:15:23 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-03 15:15:23 +0000
commitbff8a4273ec7cedd86b95055278be824ff566f98 (patch)
treeade51d50184bbcc361b3cc0ba4e86d0d398946e0
parentf0b6539b1f935f0c05ed3d6543abb604659418d7 (diff)
downloadhercules-bff8a4273ec7cedd86b95055278be824ff566f98.tar.gz
hercules-bff8a4273ec7cedd86b95055278be824ff566f98.tar.bz2
hercules-bff8a4273ec7cedd86b95055278be824ff566f98.tar.xz
hercules-bff8a4273ec7cedd86b95055278be824ff566f98.zip
- Re-coded 'soundeffectall'; removed the third parameter ('coverage')
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10844 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--doc/script_commands.txt19
-rw-r--r--npc/quests/first_class/tu_acolyte.txt2
-rw-r--r--npc/quests/first_class/tu_archer.txt2
-rw-r--r--src/map/atcommand.c4
-rw-r--r--src/map/clif.c32
-rw-r--r--src/map/clif.h4
-rw-r--r--src/map/map.c12
-rw-r--r--src/map/map.h15
-rw-r--r--src/map/script.c91
10 files changed, 89 insertions, 94 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index c95a094a8..c20b32d4b 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/07/03
+ * Re-coded 'soundeffectall'; removed the third parameter ('coverage')
+ - adjust your scripts if you use this command [ultramage]
* Defined out a problematic piece code in conv_num.
* Added reporting of constant and param script data.
* Fixed an incorrect check in menu script command. [FlavioJS]
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 7bcf4389e..fee717683 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -5647,23 +5647,22 @@ those that actually work may differ greatly between client versions.
---------------------------------------
-*soundeffect "<effect filename>",<number>
-*soundeffectall "<effect filename>",<number>
+*soundeffect "<effect filename>",<type>
+*soundeffectall "<effect filename>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>}
These two commands will play a sound effect to either the invoking character
-only 'soundeffect' or everyone around ('soundeffectall'). If the running code
-does not have an object ID (a 'floating' npc) or is not running from an NPC
+only ('soundeffect') or multiple characters ('soundeffectall'). If the running
+code does not have an object ID (a 'floating' npc) or is not running from an NPC
object at all (an item script) the sound will be centered on the character who's
RID got attached to the script, if any. If it does, it will be centered on that
object. (an NPC sprite)
-Effect filename is the filename of the wav in GRF. It must have an extension.
+Effect filename is the filename in a GRF. It must have the .wav extension.
-It's not quite certain what the number actually does, it is sent to the client
-directly, probably it determines which directory of the GRF the effect is played
-from - the sound effect type. It's certain that giving 0 for the number will
-play sound files from 'data/wav', but where the other numbers will read from is
-unclear.
+It's not quite certain what the 'type' actually does, it is sent to the client
+directly. It probably determines which directory to play the effect from.
+It's certain that giving 0 for the number will play sound files from 'data/wav',
+but where the other numbers will read from is unclear.
You can add your own effects this way, naturally.
diff --git a/npc/quests/first_class/tu_acolyte.txt b/npc/quests/first_class/tu_acolyte.txt
index a91ac3b44..d5230660d 100644
--- a/npc/quests/first_class/tu_acolyte.txt
+++ b/npc/quests/first_class/tu_acolyte.txt
@@ -1014,7 +1014,7 @@ prt_monk,226,257,6 script Ill Girl#tu 93,{
mes "Are you alright?";
next;
//misceffect EF_CURSEATTACK ;
- //soundeffectall "_curse.wav",0;
+ soundeffectall "_curse.wav",0;
emotion e_omg;
mes "["+strcharinfo(0)+"]";
mes "This is....!";
diff --git a/npc/quests/first_class/tu_archer.txt b/npc/quests/first_class/tu_archer.txt
index 0a3fb19d1..72a9fb020 100644
--- a/npc/quests/first_class/tu_archer.txt
+++ b/npc/quests/first_class/tu_archer.txt
@@ -1749,7 +1749,7 @@ prontera,126,335,5 script Arthail 51,{
next;
mes "[???]";
mes "...";
- //soundeffectall "se_littlewaves02.wav",0;
+ soundeffectall "se_littlewaves02.wav",0;
next;
mes "["+strcharinfo(0)+"]";
mes "Huh?";
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 63d933538..bfcb2600c 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -7197,7 +7197,7 @@ int atcommand_clearweather(const int fd, struct map_session_data* sd, const char
}
/*===============================================================
- * Sound Command - plays a sound for everyone! [Codemaster]
+ * Sound Command - plays a sound for everyone around! [Codemaster]
*---------------------------------------------------------------*/
int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
{
@@ -7213,7 +7213,7 @@ int atcommand_sound(const int fd, struct map_session_data *sd, const char *comma
if(strstr(sound_file, ".wav") == NULL)
strcat(sound_file, ".wav");
- clif_soundeffectall(&sd->bl, sound_file,0,2);
+ clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
return 0;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index b501d76d4..e7bab9ebc 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7347,42 +7347,36 @@ int clif_wisall(struct map_session_data *sd,int type,int flag)
/*==========================================
* サウンドエフェクト
*------------------------------------------*/
-void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,const char *name,int type)
+void clif_soundeffect(struct map_session_data* sd, struct block_list* bl, const char* name, int type)
{
int fd;
nullpo_retv(sd);
nullpo_retv(bl);
- fd=sd->fd;
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x1d3));
- WFIFOW(fd,0)=0x1d3;
- memcpy(WFIFOP(fd,2),name,NAME_LENGTH);
- WFIFOB(fd,26)=type;
- WFIFOL(fd,27)=0;
- WFIFOL(fd,31)=bl->id;
+ WFIFOW(fd,0) = 0x1d3;
+ safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH);
+ WFIFOB(fd,26) = type;
+ WFIFOL(fd,27) = 0;
+ WFIFOL(fd,31) = bl->id;
WFIFOSET(fd,packet_len(0x1d3));
return;
}
-int clif_soundeffectall(struct block_list *bl, const char *name, int type, int coverage)
+int clif_soundeffectall(struct block_list* bl, const char* name, int type, enum send_target coverage)
{
unsigned char buf[40];
- memset(buf, 0, packet_len(0x1d3));
-
- if(coverage < 0 || coverage > 22){
- ShowError("clif_soundeffectall: undefined coverage.\n");
- return 0;
- }
nullpo_retr(0, bl);
- WBUFW(buf,0)=0x1d3;
- memcpy(WBUFP(buf,2), name, NAME_LENGTH);
- WBUFB(buf,26)=type;
- WBUFL(buf,27)=0;
- WBUFL(buf,31)=bl->id;
+ WBUFW(buf,0) = 0x1d3;
+ safestrncpy((char*)WBUFP(buf,2), name, NAME_LENGTH);
+ WBUFB(buf,26) = type;
+ WBUFL(buf,27) = 0;
+ WBUFL(buf,31) = bl->id;
clif_send(buf, packet_len(0x1d3), bl, coverage);
return 0;
diff --git a/src/map/clif.h b/src/map/clif.h
index cba09da75..9186d8e7c 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -134,8 +134,8 @@ void clif_wedding_effect(struct block_list *bl);
void clif_divorced(struct map_session_data* sd, const char* name);
//void clif_callpartner(struct map_session_data *sd);
void clif_adopt_process(struct map_session_data *sd);
-void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,const char *name,int type);
-int clif_soundeffectall(struct block_list *bl, const char *name, int type, int coverage);
+void clif_soundeffect(struct map_session_data* sd, struct block_list* bl, const char* name, int type);
+int clif_soundeffectall(struct block_list* bl, const char *name, int type, enum send_target coverage);
void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick);
void clif_parse_LoadEndAck(int fd,struct map_session_data *sd);
diff --git a/src/map/map.c b/src/map/map.c
index c7173dfdb..89494a65d 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -608,7 +608,7 @@ struct skill_unit *map_find_skill_unit_oncell(struct block_list *target,int x,in
/*==========================================
* Adapted from foreachinarea for an easier invocation. [Skotlex]
*------------------------------------------*/
-int map_foreachinrange(int (*func)(struct block_list*,va_list),struct block_list *center, int range,int type,...)
+int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...)
{
va_list ap;
int bx,by,m;
@@ -682,7 +682,7 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list),struct block_list
/*==========================================
* Same as foreachinrange, but there must be a shoot-able range between center and target to be counted in. [Skotlex]
*------------------------------------------*/
-int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block_list *center, int range,int type,...)
+int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block_list* center, int range, int type,...)
{
va_list ap;
int bx,by,m;
@@ -762,7 +762,7 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
* funcを呼ぶ
* type!=0 ならその種類のみ
*------------------------------------------*/
-int map_foreachinarea(int (*func)(struct block_list*,va_list),int m,int x0,int y0,int x1,int y1,int type,...)
+int map_foreachinarea(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int type, ...)
{
va_list ap;
int bx,by;
@@ -838,7 +838,7 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list),int m,int x0,int y
*
* dx,dyは-1,0,1のみとする(どんな値でもいいっぽい?)
*------------------------------------------*/
-int map_foreachinmovearea(int (*func)(struct block_list*,va_list),struct block_list *center,int range, int dx,int dy,int type,...)
+int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int dx, int dy, int type, ...)
{
int bx,by,m;
int returnCount =0; //total sum of returned values of func() [Skotlex]
@@ -977,7 +977,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list),struct block_l
// which only checks the exact single x/y passed to it rather than an
// area radius - may be more useful in some instances)
//
-int map_foreachincell(int (*func)(struct block_list*,va_list),int m,int x,int y,int type,...)
+int map_foreachincell(int (*func)(struct block_list*,va_list), int m, int x, int y, int type, ...)
{
int bx,by;
int returnCount =0; //total sum of returned values of func() [Skotlex]
@@ -1215,7 +1215,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
}
// Copy of map_foreachincell, but applied to the whole map. [Skotlex]
-int map_foreachinmap(int (*func)(struct block_list*,va_list),int m,int type,...)
+int map_foreachinmap(int (*func)(struct block_list*,va_list), int m, int type,...)
{
int b, bsize;
int returnCount =0; //total sum of returned values of func() [Skotlex]
diff --git a/src/map/map.h b/src/map/map.h
index b929880d8..1ecaf68b7 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1300,14 +1300,13 @@ int map_delblock_sub(struct block_list *, int);
#define map_addblock(bl) map_addblock_sub(bl,1)
#define map_delblock(bl) map_delblock_sub(bl,1)
int map_moveblock(struct block_list *, int, int, unsigned int);
-int map_foreachinrange(int (*)(struct block_list*,va_list),struct block_list *,int,int,...);
-int map_foreachinshootrange(int (*)(struct block_list*,va_list),struct block_list *,int,int,...);
-int map_foreachinarea(int (*)(struct block_list*,va_list),int,int,int,int,int,int,...);
-// -- moonsoul (added map_foreachincell)
-int map_foreachincell(int (*)(struct block_list*,va_list),int,int,int,int,...);
-int map_foreachinmovearea(int (*)(struct block_list*,va_list),struct block_list*,int,int,int,int,...);
-int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y0,int x1,int y1,int range,int type,...); // Celest
-int map_foreachinmap(int (*)(struct block_list*,va_list),int,int,...);
+int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...);
+int map_foreachinshootrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...);
+int map_foreachinarea(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int type, ...);
+int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int dx, int dy, int type, ...);
+int map_foreachincell(int (*func)(struct block_list*,va_list), int m, int x, int y, int type, ...);
+int map_foreachinpath(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int range, int type, ...);
+int map_foreachinmap(int (*func)(struct block_list*,va_list), int m, int type, ...);
int map_countnearpc(int,int,int);
//block関連に追加
int map_count_oncell(int m,int x,int y,int type);
diff --git a/src/map/script.c b/src/map/script.c
index c3985a4a3..9e909cadb 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10845,73 +10845,74 @@ BUILDIN_FUNC(misceffect)
*------------------------------------------*/
BUILDIN_FUNC(soundeffect)
{
+ TBL_PC* sd = script_rid2sd(st);
+ const char* name = script_getstr(st,2);
+ int type = script_getnum(st,3);
- // Redundn
- TBL_PC *sd=script_rid2sd(st);
- const char *name;
- int type=0;
-
-
- name=script_getstr(st,2);
- type=script_getnum(st,3);
- if(sd){
+ if(sd)
+ {
if(!st->rid)
clif_soundeffect(sd,map_id2bl(st->oid),name,type);
- else{
+ else
clif_soundeffect(sd,&sd->bl,name,type);
- }
}
return 0;
}
int soundeffect_sub(struct block_list* bl,va_list ap)
{
- char *name;
- int type;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
- name = va_arg(ap,char *);
- type = va_arg(ap,int);
+ char* name = va_arg(ap,char*);
+ int type = va_arg(ap,int);
clif_soundeffect((TBL_PC *)bl, bl, name, type);
return 0;
}
+/*==========================================
+ * Play a sound effect (.wav) on multiple clients
+ * soundeffectall "<filepath>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>};
+ *------------------------------------------*/
BUILDIN_FUNC(soundeffectall)
{
- // [Lance] - Improved.
- const char *name, *map = NULL;
- struct block_list *bl;
- int type, coverage, x0, y0, x1, y1;
+ struct block_list* bl;
+ const char* name;
+ int type;
- name=script_getstr(st,2);
- type=script_getnum(st,3);
- coverage=script_getnum(st,4);
+ bl = (st->rid) ? &(script_rid2sd(st)->bl) : map_id2bl(st->oid);
+ if (!bl)
+ return 0;
- if(!st->rid)
- bl = map_id2bl(st->oid);
+ name = script_getstr(st,2);
+ type = script_getnum(st,3);
+
+ //FIXME: enumerating map squares (map_foreach) is slower than enumerating the list of online players (map_foreachpc?)
+
+ if(!script_hasdata(st,4))
+ { // area around
+ clif_soundeffectall(bl, name, type, AREA);
+ }
else
- bl = &(script_rid2sd(st)->bl);
-
- if(bl){
- if(coverage < 23){
- clif_soundeffectall(bl,name,type,coverage);
- }else {
- if(script_hasdata(st,9)){
- map= script_getstr(st,5);
- x0 = script_getnum(st,6);
- y0 = script_getnum(st,7);
- x1 = script_getnum(st,8);
- y1 = script_getnum(st,9);
- map_foreachinarea(soundeffect_sub,map_mapname2mapid(map),x0,y0,x1,y1,BL_PC,name,type);
- } else {
- ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n");
- }
- }
+ if(!script_hasdata(st,5))
+ { // entire map
+ const char* map = script_getstr(st,4);
+ map_foreachinmap(soundeffect_sub, map_mapname2mapid(map), BL_PC, name, type);
+ }
+ else
+ if(script_hasdata(st,9))
+ { // specified part of map
+ const char* map = script_getstr(st,5);
+ int x0 = script_getnum(st,6);
+ int y0 = script_getnum(st,7);
+ int x1 = script_getnum(st,8);
+ int y1 = script_getnum(st,9);
+ map_foreachinarea(soundeffect_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
}
+ else
+ {
+ ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n");
+ }
+
return 0;
}
/*==========================================