summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-01-23 16:20:46 +0000
committerJared Adams <jaxad0127@gmail.com>2009-01-23 16:20:46 +0000
commit8877825c601ce04ddd9d2ed7198c483762a741d3 (patch)
tree978e3334e51b0bb993a1532de99c1a8bbac0339d
parenta8c8788b308025c46472f9036cd0b7430d5e8a9b (diff)
downloadtmwa-8877825c601ce04ddd9d2ed7198c483762a741d3.tar.gz
tmwa-8877825c601ce04ddd9d2ed7198c483762a741d3.tar.bz2
tmwa-8877825c601ce04ddd9d2ed7198c483762a741d3.tar.xz
tmwa-8877825c601ce04ddd9d2ed7198c483762a741d3.zip
Allow getitemname to take a string
-rw-r--r--src/map/script.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/map/script.c b/src/map/script.c
index f4da2b8..9e4880e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -461,7 +461,7 @@ struct {
{buildin_marriage,"marriage","s"},
{buildin_wedding_effect,"wedding",""},
{buildin_divorce,"divorce",""},
- {buildin_getitemname,"getitemname","i"},
+ {buildin_getitemname,"getitemname","*"},
{buildin_getspellinvocation,"getspellinvocation","s"},
{buildin_getanchorinvocation,"getanchorinvocation","s"},
{buildin_getpartnerid,"getpartnerid2","i"},
@@ -2325,7 +2325,7 @@ int buildin_getitem(struct script_state *st)
if( data->type==C_STR || data->type==C_CONSTSTR ){
const char *name=conv_str(st,data);
struct item_data *item_data = itemdb_searchname(name);
- nameid=512; //Apple item ID
+ nameid=727; //Default to iten
if( item_data != NULL)
nameid=item_data->nameid;
}else
@@ -5434,18 +5434,28 @@ int buildin_guardianinfo(struct script_state *st)
*/
int buildin_getitemname(struct script_state *st)
{
- int item_id;
struct item_data *i_data;
char *item_name;
+ struct script_data *data;
- item_id=conv_num(st,& (st->stack->stack_data[st->start+2]));
+ data=&(st->stack->stack_data[st->start+2]);
+ get_val(st,data);
+ if( data->type==C_STR || data->type==C_CONSTSTR ){
+ const char *name=conv_str(st,data);
+ i_data = itemdb_searchname(name);
+ } else {
+ int item_id = conv_num(st,data);
+ i_data = itemdb_search(item_id);
+ }
- i_data = NULL;
- i_data = itemdb_search(item_id);
item_name=(char *)aCalloc(24,sizeof(char));
+ if (i_data)
+ strncpy(item_name,i_data->jname,23);
+ else
+ strncpy(item_name,"Unknown Item",23);
- strncpy(item_name,i_data->jname,23);
push_str(st->stack,C_STR,item_name);
+
return 0;
}