diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-30 18:30:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-30 18:30:50 +0300 |
commit | 21ec9caab9010b3109050dd891228c191e2b0dd0 (patch) | |
tree | a2aea1f87a6e9405922b3357273fd342d41c9385 | |
parent | 5232d8fa98cbfb7a85e15b182eeb1e22d5b7376a (diff) | |
download | plugin-21ec9caab9010b3109050dd891228c191e2b0dd0.tar.gz plugin-21ec9caab9010b3109050dd891228c191e2b0dd0.tar.bz2 plugin-21ec9caab9010b3109050dd891228c191e2b0dd0.tar.xz plugin-21ec9caab9010b3109050dd891228c191e2b0dd0.zip |
Add script command for change music.
New script command: changemusic mapname, music
-rw-r--r-- | src/map/clif.c | 2 | ||||
-rw-r--r-- | src/map/init.c | 1 | ||||
-rw-r--r-- | src/map/script.c | 14 | ||||
-rw-r--r-- | src/map/script.h | 1 | ||||
-rw-r--r-- | src/map/send.c | 16 | ||||
-rw-r--r-- | src/map/send.h | 1 |
6 files changed, 34 insertions, 1 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 4e7f47b..e10b2f5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -201,7 +201,7 @@ int eclif_send_actual(int *fd, void *buf, int *len) if (*len >= 2) { const int packet = RBUFW (buf, 0); - if (packet >= 0xb02 && packet <= 0xb05) + if (packet >= 0xb02 && packet <= 0xb10) { struct SessionExt *data = session_get(*fd); if (!data) diff --git a/src/map/init.c b/src/map/init.c index 2794692..8b5d1fe 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -92,6 +92,7 @@ HPExport void plugin_init (void) addScriptCommand("setavatardir", "i", setAvatarDir); addScriptCommand("setavataraction", "i", setAvatarAction); addScriptCommand("clear", "", clear); + addScriptCommand("changemusic", "ss", changeMusic); do_init_langs(); diff --git a/src/map/script.c b/src/map/script.c index 9cb26c5..6d9a5d0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -801,3 +801,17 @@ BUILDIN(clear) send_npccommand(script->rid2sd (st), st->oid, 9); return true; } + +BUILDIN(changeMusic) +{ + const char *const mapName = script_getstr(st, 2); + const char *const music = script_getstr(st, 3); + if (!music || !mapName) + return 0; + const int m = map->mapname2mapid(mapName); + if (m < 0) + return false; + + send_changemusic_brodcast(m, music); + return true; +} diff --git a/src/map/script.h b/src/map/script.h index 3a8ef8b..97b8f51 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -37,5 +37,6 @@ BUILDIN(showAvatar); BUILDIN(setAvatarDir); BUILDIN(setAvatarAction); BUILDIN(clear); +BUILDIN(changeMusic); #endif // EVOL_MAP_SCRIPT diff --git a/src/map/send.c b/src/map/send.c index b3ab051..be913e0 100644 --- a/src/map/send.c +++ b/src/map/send.c @@ -150,3 +150,19 @@ void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_targ clif->send(buf, i, tbl, target); aFree(buf); } + +void send_changemusic_brodcast(const int map, const char *music) +{ + if (!music) + return; + + struct block_list bl; + const int sz = strlen (music) + 5; + char buf[sz]; + + bl.m = map; + WBUFW (buf, 0) = 0xb05; + WBUFW (buf, 2) = sz; + strcpy ((char *)WBUFP (buf, 4), music); + clif->send (buf, sz, &bl, ALL_SAMEMAP); +} diff --git a/src/map/send.h b/src/map/send.h index d66bca0..438347a 100644 --- a/src/map/send.h +++ b/src/map/send.h @@ -12,5 +12,6 @@ void send_mapmask(int fd, int mask); void send_mapmask_brodcast(const int map, const int mask); void send_mob_info(struct block_list* bl1, struct block_list* bl2, enum send_target target); void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_target target); +void send_changemusic_brodcast(const int map, const char *music); #endif // EVOL_MAP_PC |