diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-05-22 09:47:24 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-05-22 09:47:24 -0300 |
commit | 8dca6139a7a6b188c5eab7ad96ae9d0f5f37ffd4 (patch) | |
tree | 5db9e2fc1ed3ba10043c375f8b9c0e902dbdb95a /src | |
parent | b9f9183e3a88181dc2888054a67837d255206676 (diff) | |
download | evol-hercules-8dca6139a7a6b188c5eab7ad96ae9d0f5f37ffd4.tar.gz evol-hercules-8dca6139a7a6b188c5eab7ad96ae9d0f5f37ffd4.tar.bz2 evol-hercules-8dca6139a7a6b188c5eab7ad96ae9d0f5f37ffd4.tar.xz evol-hercules-8dca6139a7a6b188c5eab7ad96ae9d0f5f37ffd4.zip |
Override built-in atcommand() to ensure it'll survive upstream changes.
Diffstat (limited to 'src')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 38 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 95f9e19..6a34ee6 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -241,6 +241,7 @@ HPExport void plugin_init (void) // Overrides addScriptCommand("debugmes","v*",debugmes); addScriptCommand("countitem","v?",countitem); + addScriptCommand("atcommand","s",atcommand); do_init_langs(); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index f021658..cacc0d8 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2939,6 +2939,44 @@ BUILDIN(debugmes) } /*========================================== + * gmcommand [MouseJstr] + *------------------------------------------*/ +BUILDIN(atcommand) +{ + struct map_session_data *sd, *dummy_sd = NULL; + int fd; + const char* cmd; + bool ret = true; + + cmd = script_getstr(st,2); + + if (st->rid) { + sd = script->rid2sd(st); + if (sd == NULL) + return true; + fd = sd->fd; + } else { //Use a dummy character. + sd = dummy_sd = pc->get_dummy_sd(); + fd = 0; + + if (st->oid) { + struct block_list* bl = map->id2bl(st->oid); + memcpy(&sd->bl, bl, sizeof(struct block_list)); + if (bl->type == BL_NPC) + safestrncpy(sd->status.name, BL_UCAST(BL_NPC, bl)->name, NAME_LENGTH); + } + } + + if (!atcommand->exec(fd, sd, cmd, false)) { + ShowWarning("script: buildin_atcommand: failed to execute command '%s'\n", cmd); + script->reportsrc(st); + ret = false; + } + if (dummy_sd) aFree(dummy_sd); + return ret; +} + +/*========================================== * *------------------------------------------*/ BUILDIN(countitem) diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 73769b9..685dabd 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -125,5 +125,6 @@ BUILDIN(resetrng); // Overrides BUILDIN(countitem); BUILDIN(debugmes); +BUILDIN(atcommand); #endif // EVOL_MAP_SCRIPT_BUILDINS |