From b2081c13dc6f436e94f620a9fb535e9aabe8d612 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 20 Oct 2019 12:55:50 -0400 Subject: add buildin_getguildinfo --- src/map/guild.c | 2 +- src/map/guild.h | 2 +- src/map/script.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 107 insertions(+), 6 deletions(-) (limited to 'src/map') diff --git a/src/map/guild.c b/src/map/guild.c index 3b611bb05..e270bf01e 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -277,7 +277,7 @@ static struct guild *guild_search(int guild_id) } /// lookup: guild name -> guild* -static struct guild *guild_searchname(char *str) +static struct guild *guild_searchname(const char *str) { struct guild* g; struct DBIterator *iter = db_iterator(guild->db); diff --git a/src/map/guild.h b/src/map/guild.h index 41f52711d..5a14b8a34 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -91,7 +91,7 @@ struct guild_interface { bool (*isallied) (int guild_id, int guild_id2); //Checks alliance based on guild Ids. [Skotlex] /* */ struct guild *(*search) (int guild_id); - struct guild *(*searchname) (char *str); + struct guild *(*searchname) (const char *str); struct guild_castle *(*castle_search) (int gcid); /* */ struct guild_castle *(*mapname2gc) (const char* mapname); diff --git a/src/map/script.c b/src/map/script.c index ab7513ede..6d8a38093 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8980,6 +8980,93 @@ static BUILDIN(getpartyleader) return true; } +enum guildinfo_type { + GUILDINFO_NAME, + GUILDINFO_ID, + GUILDINFO_LEVEL, + GUILDINFO_ONLINE, + GUILDINFO_AV_LEVEL, + GUILDINFO_MAX_MEMBERS, + GUILDINFO_EXP, + GUILDINFO_NEXT_EXP, + GUILDINFO_SKILL_POINTS, + GUILDINFO_MASTER_NAME, + GUILDINFO_MASTER_CID, +}; + +static BUILDIN(getguildinfo) +{ + struct guild *g = NULL; + + if (script_hasdata(st, 3)) { + if (script_isstringtype(st, 3)) { + const char *guild_name = script_getstr(st, 3); + g = guild->searchname(guild_name); + } else { + int guild_id = script_getnum(st, 3); + g = guild->search(guild_id); + } + } else { + struct map_session_data *sd = script->rid2sd(st); + g = sd ? sd->guild : NULL; + } + + enum guildinfo_type type = script_getnum(st, 2); + + if (g == NULL) { + // guild does not exist + switch (type) { + case GUILDINFO_NAME: + case GUILDINFO_MASTER_NAME: + script_pushconststr(st, ""); + break; + default: + script_pushint(st, -1); + } + } else { + switch (type) { + case GUILDINFO_NAME: + script_pushstrcopy(st, g->name); + break; + case GUILDINFO_ID: + script_pushint(st, g->guild_id); + break; + case GUILDINFO_LEVEL: + script_pushint(st, g->guild_lv); + break; + case GUILDINFO_ONLINE: + script_pushint(st, g->connect_member); + break; + case GUILDINFO_AV_LEVEL: + script_pushint(st, g->average_lv); + break; + case GUILDINFO_MAX_MEMBERS: + script_pushint(st, g->max_member); + break; + case GUILDINFO_EXP: + script_pushint(st, g->exp); + break; + case GUILDINFO_NEXT_EXP: + script_pushint(st, g->next_exp); + break; + case GUILDINFO_SKILL_POINTS: + script_pushint(st, g->skill_point); + break; + case GUILDINFO_MASTER_NAME: + script_pushstrcopy(st, g->member[0].name); + break; + case GUILDINFO_MASTER_CID: + script_pushint(st, g->member[0].char_id); + break; + default: + ShowError("script:getguildinfo: unknown info type!\n"); + st->state = END; + return false; + } + } + return true; +} + /*========================================== * Return the name of the @guild_id * null if not found @@ -15924,7 +16011,7 @@ static BUILDIN(recovery) return true; } -/* +/* * Get your current pet information */ static BUILDIN(getpetinfo) @@ -15977,7 +16064,7 @@ static BUILDIN(getpetinfo) case PETINFO_ACCESSORYFLAG: script_pushint(st, (pd->pet.equip != 0)? 1:0); break; - case PETINFO_EVO_EGGID: + case PETINFO_EVO_EGGID: if (VECTOR_DATA(pd->petDB->evolve_data) != NULL) script_pushint(st, VECTOR_DATA(pd->petDB->evolve_data)->petEggId); else @@ -24901,7 +24988,7 @@ static BUILDIN(showscript) if (script_hasdata(st, 4)) if (script_getnum(st, 4) == SELF) flag = SELF; - + clif->ShowScript(bl, msg, flag); return true; } @@ -25786,7 +25873,7 @@ static BUILDIN(identifyidx) script_pushint(st, false); return true; } - + if (sd->status.inventory[idx].nameid <= 0 || sd->status.inventory[idx].identify != 0) { script_pushint(st, false); return true; @@ -26092,6 +26179,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getguildmaster,"i"), BUILDIN_DEF(getguildmasterid,"i"), BUILDIN_DEF(getguildmember,"i?"), + BUILDIN_DEF(getguildinfo,"i?"), BUILDIN_DEF(getguildonline, "i?"), BUILDIN_DEF(strcharinfo,"i??"), BUILDIN_DEF(strnpcinfo,"i??"), @@ -27207,6 +27295,19 @@ static void script_hardcoded_constants(void) script->set_constant("SIEGE_TYPE_SE", SIEGE_TYPE_SE, false, false); script->set_constant("SIEGE_TYPE_TE", SIEGE_TYPE_TE, false, false); + script->constdb_comment("guildinfo types"); + script->set_constant("GUILDINFO_NAME", GUILDINFO_NAME, false, false); + script->set_constant("GUILDINFO_ID", GUILDINFO_ID, false, false); + script->set_constant("GUILDINFO_LEVEL", GUILDINFO_LEVEL, false, false); + script->set_constant("GUILDINFO_ONLINE", GUILDINFO_ONLINE, false, false); + script->set_constant("GUILDINFO_AV_LEVEL", GUILDINFO_AV_LEVEL, false, false); + script->set_constant("GUILDINFO_MAX_MEMBERS", GUILDINFO_MAX_MEMBERS, false, false); + script->set_constant("GUILDINFO_EXP", GUILDINFO_EXP, false, false); + script->set_constant("GUILDINFO_NEXT_EXP", GUILDINFO_NEXT_EXP, false, false); + script->set_constant("GUILDINFO_SKILL_POINTS", GUILDINFO_SKILL_POINTS, false, false); + script->set_constant("GUILDINFO_MASTER_NAME", GUILDINFO_MASTER_NAME, false, false); + script->set_constant("GUILDINFO_MASTER_CID", GUILDINFO_MASTER_CID, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); -- cgit v1.2.3-70-g09d2 From b9aaf46392137cdcd83fc53d990a5f8b997cf9b2 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 20 Oct 2019 13:21:59 -0400 Subject: deprecate buildin_getguildname --- doc/script_commands.txt | 8 ++++++++ src/map/script.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/map') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 47ad19191..939a5e7c6 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3732,6 +3732,10 @@ Example: *getguildname() + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @ /!\ This command is deprecated @ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + This function returns a guild's name given an ID number. If there is no such guild, "null" will be returned; @@ -3745,6 +3749,10 @@ such guild, "null" will be returned; This is used all over the WoE controlling scripts. You could also use it for a guild-based event. +This command is deprecated and it should not be used in new scripts, as it is +likely to be removed at a later time. Please use getguildinfo instead: + getguildinfo(GUILDINFO_NAME, ) + --------------------------------------- *getguildmaster() diff --git a/src/map/script.c b/src/map/script.c index 6d8a38093..066836b8e 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26175,7 +26175,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getpartyname,"i"), BUILDIN_DEF(getpartymember,"i?"), BUILDIN_DEF(getpartyleader,"i?"), - BUILDIN_DEF(getguildname,"i"), + BUILDIN_DEF_DEPRECATED(getguildname,"i"), BUILDIN_DEF(getguildmaster,"i"), BUILDIN_DEF(getguildmasterid,"i"), BUILDIN_DEF(getguildmember,"i?"), -- cgit v1.2.3-70-g09d2 From b0a890b60f73ddde94c219659979278e75684984 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 20 Oct 2019 13:23:55 -0400 Subject: deprecate buildin_getguildmaster --- doc/script_commands.txt | 8 ++++++++ src/map/script.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/map') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 939a5e7c6..1b53072ad 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3757,6 +3757,10 @@ likely to be removed at a later time. Please use getguildinfo instead: *getguildmaster() + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @ /!\ This command is deprecated @ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + This function return the name of the master of the guild which has the specified ID number. If there is no such guild, "null" will be returned. @@ -3780,6 +3784,10 @@ Maybe you want to make a room only guild masters can enter: mes("Sorry you don't own the guild you are in"); close(); +This command is deprecated and it should not be used in new scripts, as it is +likely to be removed at a later time. Please use getguildinfo instead: + getguildinfo(GUILDINFO_MASTER_NAME, ) + --------------------------------------- *getguildmasterid() diff --git a/src/map/script.c b/src/map/script.c index 066836b8e..91d579178 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26176,7 +26176,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getpartymember,"i?"), BUILDIN_DEF(getpartyleader,"i?"), BUILDIN_DEF_DEPRECATED(getguildname,"i"), - BUILDIN_DEF(getguildmaster,"i"), + BUILDIN_DEF_DEPRECATED(getguildmaster,"i"), BUILDIN_DEF(getguildmasterid,"i"), BUILDIN_DEF(getguildmember,"i?"), BUILDIN_DEF(getguildinfo,"i?"), -- cgit v1.2.3-70-g09d2 From 9127ead75b9baa4e6372d11cb4ba033651976629 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 20 Oct 2019 13:24:48 -0400 Subject: deprecate buildin_getguildmasterid --- doc/script_commands.txt | 8 ++++++++ src/map/script.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/map') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 1b53072ad..45636f23b 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3792,10 +3792,18 @@ likely to be removed at a later time. Please use getguildinfo instead: *getguildmasterid() + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @ /!\ This command is deprecated @ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + This function will return the character ID number of the guild master of the guild specified by the ID. 0 if the character is not a guild master of any guild. +This command is deprecated and it should not be used in new scripts, as it is +likely to be removed at a later time. Please use getguildinfo instead: + getguildinfo(GUILDINFO_MASTER_CID, ) + --------------------------------------- *getcastlename("") diff --git a/src/map/script.c b/src/map/script.c index 91d579178..9d99b99f9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26177,7 +26177,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getpartyleader,"i?"), BUILDIN_DEF_DEPRECATED(getguildname,"i"), BUILDIN_DEF_DEPRECATED(getguildmaster,"i"), - BUILDIN_DEF(getguildmasterid,"i"), + BUILDIN_DEF_DEPRECATED(getguildmasterid,"i"), BUILDIN_DEF(getguildmember,"i?"), BUILDIN_DEF(getguildinfo,"i?"), BUILDIN_DEF(getguildonline, "i?"), -- cgit v1.2.3-70-g09d2