summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2012-11-30 15:22:29 -0800
committerBen Longbons <b.r.longbons@gmail.com>2012-12-01 13:15:42 -0800
commit0ea504c7b77c7d2e3efabc4678fcd396fbeec083 (patch)
treeb0ee56d75b62faf22baaf1a4b42689bafdc3885c
parent280d3c4a87654ad0468de81e259b8768ea6f9743 (diff)
downloadtmwa-0ea504c7b77c7d2e3efabc4678fcd396fbeec083.tar.gz
tmwa-0ea504c7b77c7d2e3efabc4678fcd396fbeec083.tar.bz2
tmwa-0ea504c7b77c7d2e3efabc4678fcd396fbeec083.tar.xz
tmwa-0ea504c7b77c7d2e3efabc4678fcd396fbeec083.zip
Add getmap script function, since I found a use for it.
-rw-r--r--src/map/script.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/map/script.cpp b/src/map/script.cpp
index fac5ad5..8663ae1 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -312,6 +312,7 @@ int buildin_fakenpcname (struct script_state *st); //[Kage]
int buildin_unequip_by_id (struct script_state *st); // [Freeyorp]
int buildin_getx (struct script_state *st); // [Kage]
int buildin_gety (struct script_state *st); // [Kage]
+int buildin_getmap (struct script_state *st);
void push_val (struct script_stack *stack, int type, int val);
@@ -738,6 +739,8 @@ struct
buildin_getx, "getx", ""}, // [Kage]
{
buildin_gety, "gety", ""}, // [Kage]
+ {
+ buildin_getmap, "getmap", ""},
// End Additions
{
NULL, NULL, NULL},};
@@ -1647,6 +1650,7 @@ int get_val (struct script_state *st, struct script_data *data)
data->type = ScriptCode::INT;
if (str_data[data->u.num & 0x00ffffff].type == ScriptCode::INT)
{
+ // unreachable
data->u.num = str_data[data->u.num & 0x00ffffff].val;
}
else if (str_data[data->u.num & 0x00ffffff].type == ScriptCode::PARAM)
@@ -1790,15 +1794,15 @@ const char *conv_str (struct script_state *st, struct script_data *data)
sprintf (buf, "%d", data->u.num);
data->type = ScriptCode::STR;
data->u.str = buf;
-#if 1
}
+#if 1
else if (data->type == ScriptCode::NAME)
{
// テンポラリ。本来無いはず
data->type = ScriptCode::CONSTSTR;
data->u.str = str_buf + str_data[data->u.num].str;
-#endif
}
+#endif
return data->u.str;
}
@@ -7252,6 +7256,18 @@ int buildin_gety (struct script_state *st)
return 0;
}
+/*
+ * Get the PC's current map's name
+ */
+int buildin_getmap (struct script_state *st)
+{
+ struct map_session_data *sd = script_rid2sd (st);
+
+ // A map_data lives essentially forever.
+ push_str (st->stack, ScriptCode::CONSTSTR, map[sd->bl.m].name);
+ return 0;
+}
+
//
// 実行部main
//