summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 27ea71cbb..ebe4c490c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3512,6 +3512,7 @@ int buildin_checkequipedcard(struct script_state *st);
int buildin_globalmes(struct script_state *st);
int buildin_jump_zero(struct script_state *st);
int buildin_select(struct script_state *st);
+int buildin_prompt(struct script_state *st);
int buildin_getmapmobs(struct script_state *st); //jA addition end
int buildin_unequip(struct script_state *st); // unequip [Spectre]
int buildin_getstrlen(struct script_state *st); //strlen [valaris]
@@ -3846,6 +3847,7 @@ struct script_function buildin_func[] = {
{buildin_checkequipedcard,"checkequipedcard","i"},
{buildin_jump_zero,"jump_zero","ii"}, //for future jA script compatibility
{buildin_select,"select","*"}, //for future jA script compatibility
+ {buildin_prompt,"prompt","*"},
{buildin_globalmes,"globalmes","s*"},
{buildin_getmapmobs,"getmapmobs","s"}, //end jA addition
{buildin_unequip,"unequip","i"}, // unequip command [Spectre]
@@ -10308,7 +10310,52 @@ int buildin_select(struct script_state *st)
sd->max_menu = max;
clif_scriptmenu(script_rid2sd(st),st->oid,buf);
aFree(buf);
- } /*else if(sd->npc_menu==0xff){ // Cancel will be parsed since this is select() [Lance]
+ } else if(sd->npc_menu==0xff){
+ sd->state.menu_or_input=0;
+ st->state=END;
+ } else {
+ //Skip empty menu entries which weren't displayed on the client (Skotlex)
+ for(i=st->start+2;i< (st->start+2+sd->npc_menu) && sd->npc_menu < (st->end-st->start-2);i++) {
+ conv_str(st,& (st->stack->stack_data[i])); // we should convert variables to strings before access it [jA1983] [EoE]
+ if((int)strlen(st->stack->stack_data[i].u.str) < 1)
+ sd->npc_menu++; //Empty selection which wasn't displayed on the client.
+ }
+ pc_setreg(sd,add_str((unsigned char *) "@menu"),sd->npc_menu);
+ sd->state.menu_or_input=0;
+ push_val(st->stack,C_INT,sd->npc_menu);
+ }
+ return 0;
+}
+
+int buildin_prompt(struct script_state *st)
+{
+ char *buf;
+ int len,i,max = 1;
+ struct map_session_data *sd;
+
+ sd=script_rid2sd(st);
+
+ if(sd->state.menu_or_input==0){
+ st->state=RERUNLINE;
+ sd->state.menu_or_input=1;
+ for(i=st->start+2,len=16;i<st->end;i++){
+ conv_str(st,& (st->stack->stack_data[i]));
+ len+=(int)strlen(st->stack->stack_data[i].u.str)+1;
+ }
+ buf=(char *)aMalloc((len+1)*sizeof(char));
+ buf[0]=0;
+ for(i=st->start+2,len=0;i<st->end;i++){
+ strcat(buf,st->stack->stack_data[i].u.str);
+ strcat(buf,":");
+ }
+ for(i=0; (unsigned int)i < strlen(buf); i++){
+ if(buf[i] == ':')
+ max++;
+ }
+ sd->max_menu = max;
+ clif_scriptmenu(script_rid2sd(st),st->oid,buf);
+ aFree(buf);
+ } /*else if(sd->npc_menu==0xff){
sd->state.menu_or_input=0;
st->state=END;
}*/ else {