Skip to content

Commit

Permalink
Merge pull request #3272 from vietlubu/allow-call-openlapineupgradeui…
Browse files Browse the repository at this point in the history
…-without-itemid

Allow call openlapineupgradeui() and openlapineddukddakboxui() without itemid
  • Loading branch information
MishimaHaruna authored Mar 30, 2024
2 parents 4f6fcb5 + 08a9688 commit be0c897
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 13 deletions.
6 changes: 4 additions & 2 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10997,13 +10997,15 @@ Opens refinery user interface for the player
returns true on success and false on failure

---------------------------------------
*openlapineddukddakboxui(<item_id>)
*openlapineddukddakboxui({<item_id>})
*openlapineddukddakboxui({<item_name>})

Opens lapine ddukddak user interface for the player
returns true on success and false on failure

---------------------------------------
*openlapineupgradeui(<item_id>)
*openlapineupgradeui({<item_id>})
*openlapineupgradeui({<item_name>})

Opens lapine ddukddak upgrade user interface for the player
returns true on success and false on failure
Expand Down
70 changes: 59 additions & 11 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -27941,16 +27941,41 @@ static BUILDIN(openlapineddukddakboxui)
struct map_session_data *sd = script_rid2sd(st);
if (sd == NULL)
return false;
const int item_id = script_getnum(st, 2);
struct item_data *it = itemdb->exists(item_id);
if (it == NULL) {
ShowError("buildin_openlapineddukddakboxui: Item %d is not valid\n", item_id);

struct item_data *it = NULL;
if (script_hasdata(st, 2)) {
if (script_isstring(st, 2)) {
const char *item_name = script_getstr(st, 2);
it = itemdb->search_name(item_name);
if (it == NULL) {
ShowError("buildin_openlapineddukddakboxui: Item %s is not valid\n", item_name);
script->reportfunc(st);
script->reportsrc(st);
script_pushint(st, false);
return true;
}
} else {
it = itemdb->exists(script_getnum(st, 2));
}
} else {
if (sd->itemid > 0) {
it = itemdb->exists(sd->itemid);
}
}

if (it == NULL || it->lapineddukddak == NULL) {
if (it != NULL) {
ShowError("buildin_openlapineddukddakboxui: Item Id %d is not valid\n", it->nameid);
} else {
ShowError("buildin_openlapineddukddakboxui: Item is NULL\n");
}
script->reportfunc(st);
script->reportsrc(st);
script_pushint(st, false);
return true;
}
clif->lapineDdukDdak_open(sd, item_id);

clif->lapineDdukDdak_open(sd, it->nameid);
script_pushint(st, true);
return true;
}
Expand All @@ -27962,17 +27987,40 @@ static BUILDIN(openlapineupgradeui)
if (sd == NULL)
return false;

const int item_id = script_getnum(st, 2);
struct item_data *it = itemdb->exists(item_id);
struct item_data *it = NULL;
if (script_hasdata(st, 2)) {
if (script_isstring(st, 2)) {
const char *item_name = script_getstr(st, 2);
it = itemdb->search_name(item_name);
if (it == NULL) {
ShowError("buildin_openlapineupgradeui: Item %s is not valid\n", item_name);
script->reportfunc(st);
script->reportsrc(st);
script_pushint(st, false);
return true;
}
} else {
it = itemdb->exists(script_getnum(st, 2));
}
} else {
if (sd->itemid > 0) {
it = itemdb->exists(sd->itemid);
}
}

if (it == NULL || it->lapineupgrade == NULL) {
ShowError("buildin_openlapineupgradeui: Item %d is not valid\n", item_id);
if (it != NULL) {
ShowError("buildin_openlapineddukddakboxui: Item Id %d is not valid\n", it->nameid);
} else {
ShowError("buildin_openlapineddukddakboxui: Item is NULL\n");
}
script->reportfunc(st);
script->reportsrc(st);
script_pushint(st, false);
return true;
}

clif->lapineUpgrade_open(sd, item_id);
clif->lapineUpgrade_open(sd, it->nameid);
script_pushint(st, true);
return true;
}
Expand Down Expand Up @@ -29183,8 +29231,8 @@ static void script_parse_builtin(void)

BUILDIN_DEF(identify, "i"),
BUILDIN_DEF(identifyidx, "i"),
BUILDIN_DEF(openlapineddukddakboxui, "i"),
BUILDIN_DEF(openlapineupgradeui, "i"),
BUILDIN_DEF(openlapineddukddakboxui, "?"),
BUILDIN_DEF(openlapineupgradeui, "?"),

BUILDIN_DEF(callfunctionofnpc, "vs*"),

Expand Down

0 comments on commit be0c897

Please sign in to comment.