summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-06-21 21:46:24 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-06-21 21:46:24 +0000
commit8e67f78bec84c8d3d6c9331ec9409d7ed1e94233 (patch)
treecbed075dc8a9fdaafb1a729c1a4a31c1f9ca8137
parente53ce7ef5610a1fb1dc3597e56c6610e026828a5 (diff)
downloadhercules-8e67f78bec84c8d3d6c9331ec9409d7ed1e94233.tar.gz
hercules-8e67f78bec84c8d3d6c9331ec9409d7ed1e94233.tar.bz2
hercules-8e67f78bec84c8d3d6c9331ec9409d7ed1e94233.tar.xz
hercules-8e67f78bec84c8d3d6c9331ec9409d7ed1e94233.zip
* Extended script command 'set' to return the variable reference (topic:190602).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12871 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--doc/script_commands.txt8
-rw-r--r--src/map/script.c44
3 files changed, 36 insertions, 18 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 1188ed159..387362364 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,8 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+2008/06/22
+ * Extended script command 'set' to return the variable reference (topic:190602). [FlavioJS]
2008/06/19
* Added Sirius_White's fix for sense working on emperium. (bugreport: 1679) [SketchyPhoenix]
* Fixed SC_CHANGEUNDEAD behavior: Blessing and Increase AGI deals 1 damage and does not apply buffs to those inflicted by it.
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 71ac40864..9ebfdb381 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -4,7 +4,7 @@
//= A reference manual for the eAthena scripting language.
//= Commands are sorted depending on their functionality.
//===== Version ===========================================
-//= 3.21.20080612
+//= 3.22.20080622
//=========================================================
//= 1.0 - First release, filled will as much info as I could
//= remember or figure out, most likely there are errors,
@@ -118,6 +118,8 @@
//= skill, addtoskill, guildskill, getskilllv, getgdskilllv, itemskill,
//= petskillattack, petskillattack2, petskillsupport, skilleffect, npcskilleffect,
//= unitskilluseid, unitskillusepos, bonus/bonus2/bonus3/bonus4/bonus5
+//= 3.22.20080622
+//= Extended 'set' to return the variable reference. [FlavioJS]
//=========================================================
This document is a reference manual for all the scripting commands and functions
@@ -1108,6 +1110,8 @@ will make @x equal 100.
will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are
integer in this language) and make @x equal it.
+Returns the variable reference (since trunk r12870).
+
---------------------------------------
*setd "<variable name>",<value>;
@@ -4394,7 +4398,7 @@ autoscript).
---------------------------------------
*skill <skill id>,<level>{,<flag>};
-*skill "<skill name",<level>{,<flag>};
+*skill "<skill name>",<level>{,<flag>};
*addtoskill <skill id>,<level>{,<flag>};
*addtoskill "<skill name>",<level>{,<flag>};
diff --git a/src/map/script.c b/src/map/script.c
index b1f6371ec..6026345b7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4673,27 +4673,36 @@ BUILDIN_FUNC(input)
return 0;
}
-/*==========================================
- * 変数設定
- *------------------------------------------*/
+/// Sets the value of a variable.
+/// The value is converted to the type of the variable.
+///
+/// set(<variable>,<value>) -> <variable>
BUILDIN_FUNC(set)
{
- TBL_PC *sd=NULL;
- int num=st->stack->stack_data[st->start+2].u.num;
- char *name=str_buf+str_data[num&0x00ffffff].str;
- char prefix=*name;
- char postfix=name[strlen(name)-1];
+ TBL_PC* sd = NULL;
+ struct script_data* data;
+ int num;
+ char* name;
+ char prefix;
+ char postfix;
- if( !data_isreference(script_getdata(st,2)) ){
+ data = script_getdata(st,2);
+ if( !data_isreference(data) )
+ {
ShowError("script:set: not a variable\n");
script_reportdata(script_getdata(st,2));
st->state = END;
return 1;
}
- if(not_server_variable(prefix))
+ num = reference_getuid(data);
+ name = reference_getname(data);
+ prefix = *name;
+ postfix = (*name ? name[strlen(name)-1] : '\0');
+
+ if( not_server_variable(prefix) )
{
- sd=script_rid2sd(st);
+ sd = script_rid2sd(st);
if( sd == NULL )
{
ShowError("script:set: no player attached for player variable '%s'\n", name);
@@ -4701,15 +4710,18 @@ BUILDIN_FUNC(set)
}
}
- if( postfix=='$' ){
- // 文字列
- const char *str = script_getstr(st,3);
+ if( postfix == '$' )
+ {// string variable
+ const char* str = script_getstr(st,3);
set_reg(st,sd,num,name,(void*)str,script_getref(st,2));
- }else{
- // 数値
+ }
+ else
+ {// integer variable
int val = script_getnum(st,3);
set_reg(st,sd,num,name,(void*)val,script_getref(st,2));
}
+ // return a copy of the variable reference
+ script_pushcopy(st,2);
return 0;
}