diff options
-rw-r--r-- | .mailmap | 95 | ||||
-rw-r--r-- | conf/char/char-server.conf | 7 | ||||
-rw-r--r-- | doc/script_commands.txt | 12 | ||||
-rw-r--r-- | npc/dev/test.txt | 10 | ||||
-rw-r--r-- | src/char/char.c | 10 | ||||
-rw-r--r-- | src/map/map.c | 13 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/script.c | 73 |
8 files changed, 209 insertions, 12 deletions
@@ -7,3 +7,98 @@ <joseph.tk.ea@gmail.com> <j-tkay@54d463be-8e91-2dee-dedb-b68131a5f0ec> <ind@henn.et> <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> <Kenpachi.Developer@gmx.de> <kenpachi2k11@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<umage@netvor.sk> <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<ai4rei@users.noreply.github.com> <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<Kenji.Ito@gmx.de> <Playtester@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<masao@gmx.ch> <masao87@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<piotr.halaczkiewicz@gmail.com> <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<piotr.halaczkiewicz@gmail.com> <Gepard@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<missxantara@gmail.com> <xantara@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<lightaisme@gmail.com> <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<brianluau@users.noreply.github.com> <brianluau@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<harrison@isabarwon.com> <calciumkid@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<fw@f-ws.de> <blacksirius@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<fw@f-ws.de> <sirius@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<jmish1987@gmail.com> <jmanfffreak@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<paradox924x@gmail.com> <Paradox924x@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<paradox924x@gmail.com> <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<yomanda@gmail.com> <Yommy@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<masterofmuppets89@gmail.com> <MasterOfMuppets@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<flaviojs2005@gmail.com> <flaviojs@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<flaviojs2005@gmail.com> <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<flaviojs2005@gmail.com> <flaviojs2005@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<macabu.matheus@gmail.com> <momacabu@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<Daegaladh@users.noreply.github.com> <daegaladh@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<greenboxal@gmail.com> <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec> +<malufett.eat.my.binaries@gmail.com> <rud0lp20@54d463be-8e91-2dee-dedb-b68131a5f0ec> + +# old aliases + +<haru@dotalux.com> <haru@originsro.org> +<ind@henn.et> <int@henn.et> +<ind@henn.et> <notind@gmail.com> +<ind@henn.et> <shennetsind@users.noreply.github.com> +<dastgirp@gmail.com> <dastgir@users.noreply.github.com> +<dastgirp@gmail.com> <dastgirpojee@rocketmail.com> +<michieru-kun@hotmail.com> <Michieru@users.noreply.github.com> +<michieru-kun@hotmail.com> <michieru@0-mail.com> +<jedzkie13@rocketmail.com> <Jedzkie@users.noreply.github.com> +<jedzkie13@rocketmail.com> <eikzdej@gmail.com> +<jedzkie13@rocketmail.com> <jedzkie999@gmail.com> +<Equinox1991@gmail.com> <Emistry@users.noreply.github.com> +<gauvain.dauchy@free.fr> <alige@users.noreply.github.com> +<guilherme.menaldo@outlook.com> <guilherme-gm@users.noreply.github.com> +<dev@herc.ws> <Hercules@efficiently.awesome> +<streusel@gravity.co.kr> <advance_me@hotmail.de> +<streusel@gravity.co.kr> <m.me1@live.de> +<ibrahem.h.basyone@gmail.com> <hemagx2@gmail.com> +<Asheraf@users.noreply.github.com> <acheraf1998@gmail.com> +<sagunkho@hotmail.com> <sagunxp@gmail.com> +<git@gumi.ca> <mekolat@users.noreply.github.com> + + + + + +# missing from github: +# - skotlex +# - L0ne_W0lf +# - Lupus +# - celest +# - Lance +# - zephyrus +# - amber +# - Inkfish +# - toms +# - shadowlady +# - codemaster +# - Vicious +# - samuray22 +# - Kevin +# - eathenabot +# - shadow +# - mc_cameri +# - evera +# - SinSloth +# - epoque11 +# - DracoRPG +# - sketchyphoenix +# - littlewolf +# - eaac +# - ajarn +# - wizputer +# - Nasedo +# - valaris +# - blackhole89 +# - protimus +# - Komurka +# - Poki#3 +# - cookiecrumbs +# - Zido +# - akrus +# - markzd +# - xazax-hun +# - lordttseven +# - musahiden +# - Aria +# - og2 diff --git a/conf/char/char-server.conf b/conf/char/char-server.conf index 76bd5e359..0f07731fb 100644 --- a/conf/char/char-server.conf +++ b/conf/char/char-server.conf @@ -50,7 +50,7 @@ char_configuration: { // Server Communication username and password. userid: "s1" passwd: "p1" - + // Login Server IP // The character server connects to the login server using this IP address. // NOTE: This is useful when you are running behind a firewall or are on @@ -162,6 +162,11 @@ char_configuration: { // Set the letters/symbols that you want use with the 'char_name_option' option. // Note: Don't add spaces unless you mean to add 'space' to the list. name_letters: "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" + + // Block renaming if character is in a guild or a party? (BOOL) + // Athena: false Aegis: true + // This check is imposed by Aegis to avoid dead entries in databases and is not needed on Hercules, as we clear data properly + use_aegis_rename: false } deletion: { diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 33d1ee426..219c71205 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8604,6 +8604,18 @@ Example: --------------------------------------- +*data_to_string(<data>) + +Returns a string representation of the given data, similar to the .toString() +method in JavaScript. + +Example: + + data_to_string(DATATYPE_VAR) // "DATATYPE_VAR" + data_to_string(.@foo) // ".@foo" + +--------------------------------------- + *charisalpha("<string>", <position>) This function will return true if the character number Position in the given diff --git a/npc/dev/test.txt b/npc/dev/test.txt index c2f07ab2f..2822ee65c 100644 --- a/npc/dev/test.txt +++ b/npc/dev/test.txt @@ -775,6 +775,16 @@ function script HerculesSelfTestHelper { callsub(OnCheck, "Getdatatype (getarg integer value)", callsub(OnTestGetdatatype, 5), DATATYPE_INT); callsub(OnCheck, "Getdatatype (getarg string)", callsub(OnTestGetdatatype, "foo"), DATATYPE_STR | DATATYPE_CONST); + callsub(OnCheck, "data_to_string (NIL)", data_to_string(), ""); + callsub(OnCheck, "data_to_string (empty string)", data_to_string(""), ""); + callsub(OnCheck, "data_to_string (string)", data_to_string("foo"), "foo"); + callsub(OnCheck, "data_to_string (integer)", data_to_string(5), "5"); + callsub(OnCheck, "data_to_string (parameter)", data_to_string(Hp), "Hp"); + callsub(OnCheck, "data_to_string (constant)", data_to_string(DATATYPE_CONST), "DATATYPE_CONST"); + callsub(OnCheck, "data_to_string (label)", data_to_string(OnTestGetdatatype), "OnTestGetdatatype"); + callsub(OnCheck, "data_to_string (string variable)", data_to_string(.@x$), ".@x$"); + callsub(OnCheck, "data_to_string (integer variable)", data_to_string(.@x), ".@x"); + if (.errors) { debugmes "Script engine self-test [ \033[0;31mFAILED\033[0m ]"; debugmes "**** The test was completed with " + .errors + " errors. ****"; diff --git a/src/char/char.c b/src/char/char.c index e8b57ad2f..18269aeaf 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -139,6 +139,7 @@ char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) i static int char_del_level = 0; ///< From which level you can delete character [Lupus] static int char_del_delay = 86400; static bool char_aegis_delete = false; ///< Verify if char is in guild/party or char and reacts as Aegis does (disallow deletion), @see chr->delete2_req. +static bool char_aegis_rename = false; // whether or not the player can be renamed while in party/guild static int max_connect_user = -1; static int gm_allow_group = -1; @@ -1514,6 +1515,14 @@ static int char_rename_char_sql(struct char_session_data *sd, int char_id) if( char_dat.rename == 0 ) return 1; + if (char_aegis_rename) { + if (char_dat.guild_id > 0) { + return 5; // MSG_FAILED_RENAME_BELONGS_TO_GUILD + } else if (char_dat.party_id > 0) { + return 6; // MSG_FAILED_RENAME_BELONGS_TO_PARTY + } + } + SQL->EscapeStringLen(inter->sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH)); // check if the char exist @@ -5847,6 +5856,7 @@ static bool char_config_read_player_name(const char *filename, const struct conf libconfig->setting_lookup_mutable_string(setting, "name_letters", char_name_letters, sizeof(char_name_letters)); libconfig->setting_lookup_int(setting, "name_option", &char_name_option); libconfig->setting_lookup_bool_real(setting, "name_ignoring_case", &name_ignoring_case); + libconfig->setting_lookup_bool_real(setting, "use_aegis_rename", &char_aegis_rename); return true; } diff --git a/src/map/map.c b/src/map/map.c index 343f219b8..a352d34b0 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -635,6 +635,18 @@ static int map_foreachinmap(int (*func)(struct block_list*, va_list), int16 m, i return returnCount; } +static int map_forcountinmap(int (*func)(struct block_list*, va_list), int16 m, int count, int type, ...) +{ + int returnCount; + va_list ap; + + va_start(ap, type); + returnCount = map->vforcountinarea(func, m, 0, 0, map->list[m].bxs, map->list[m].bys, count, type, ap); + va_end(ap); + + return returnCount; +} + /** * Applies func to every block_list object of bl_type type on all maps * of instance instance_id. @@ -6901,6 +6913,7 @@ void map_defaults(void) map->foreachinpath = map_foreachinpath; map->vforeachinmap = map_vforeachinmap; map->foreachinmap = map_foreachinmap; + map->forcountinmap = map_forcountinmap; map->vforeachininstance = map_vforeachininstance; map->foreachininstance = map_foreachininstance; diff --git a/src/map/map.h b/src/map/map.h index cb025e9c1..0e38bdb13 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1293,6 +1293,7 @@ END_ZEROED_BLOCK; int (*foreachinpath) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...); int (*vforeachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, va_list args); int (*foreachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, ...); + int (*forcountinmap) (int (*func)(struct block_list*,va_list), int16 m, int count, int type, ...); int (*vforeachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type, va_list ap); int (*foreachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type,...); diff --git a/src/map/script.c b/src/map/script.c index d1839676f..fc1ece663 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11300,7 +11300,7 @@ static int buildin_getunits_sub(struct block_list *bl, va_list ap) (const void *)h64BPTRSIZE(bl->id), ref); (*count)++; - return 0; + return 1; } static int buildin_getunits_sub_pc(struct map_session_data *sd, va_list ap) @@ -11372,18 +11372,10 @@ static BUILDIN(getunits) int16 x2 = script_getnum(st, 8); int16 y2 = script_getnum(st, 9); - // FIXME: map_foreachinarea does NOT stop iterating when the callback - // function returns -1. we still limit the array size, but - // this doesn't break the loop. We need a foreach function - // that behaves like map_foreachiddb, but for areas - map->foreachinarea(buildin_getunits_sub, m, x1, y1, x2, y2, type, + map->forcountinarea(buildin_getunits_sub, m, x1, y1, x2, y2, limit, type, st, sd, id, start, &count, limit, name, ref, type); } else { - // FIXME: map_foreachinmap does NOT stop iterating when the callback - // function returns -1. we still limit the array size, but - // this doesn't break the loop. We need a foreach function - // that behaves like map_foreachiddb, but for maps - map->foreachinmap(buildin_getunits_sub, m, type, + map->forcountinmap(buildin_getunits_sub, m, limit, type, st, sd, id, start, &count, limit, name, ref, type); } } else { @@ -16725,6 +16717,63 @@ static BUILDIN(getdatatype) return true; } +static BUILDIN(data_to_string) +{ + if (script_hasdata(st, 2)) { + struct script_data *data = script_getdata(st, 2); + + if (data_isstring(data)) { + script_pushcopy(st, 2); + } else if (data_isint(data)) { + char *str = NULL; + + CREATE(str, char, 20); + safesnprintf(str, 20, "%"PRId64"", data->u.num); + script_pushstr(st, str); + } else if (data_islabel(data)) { + const char *str = ""; + + // XXX: because all we have is the label pos we can't be sure which + // one is the correct label if more than one has the same pos. + // We might want to store both the pos and str_data index in + // data->u.num, similar to how C_NAME stores both the array + // index and str_data index in u.num with bitmasking. This + // would also avoid the awkward for() loops as we could + // directly access the string with script->get_str(). + + if (st->oid) { + struct npc_data *nd = map->id2nd(st->oid); + + for (int i = 0; i < nd->u.scr.label_list_num; ++i) { + if (nd->u.scr.label_list[i].pos == data->u.num) { + str = nd->u.scr.label_list[i].name; + break; + } + } + } else { + for (int i = LABEL_START; script->str_data[i].next != 0; i = script->str_data[i].next) { + if (script->str_data[i].label == data->u.num) { + str = script->get_str(i); + break; + } + } + } + + script_pushconststr(st, str); + } else if (data_isreference(data)) { + script_pushstrcopy(st, reference_getname(data)); + } else { + ShowWarning("script:data_to_string: unknown data type!\n"); + script->reportdata(data); + script_pushconststr(st, ""); + } + } else { + script_pushconststr(st, ""); // NIL + } + + return true; +} + //======================================================= // chr <int> //------------------------------------------------------- @@ -25199,6 +25248,8 @@ static void script_parse_builtin(void) BUILDIN_DEF(charat,"si"), BUILDIN_DEF(isstr,"v"), BUILDIN_DEF(getdatatype, "?"), + BUILDIN_DEF(data_to_string, "?"), + BUILDIN_DEF2(getd, "string_to_data", "?"), BUILDIN_DEF(chr,"i"), BUILDIN_DEF(ord,"s"), BUILDIN_DEF(setchar,"ssi"), |