summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-25 03:23:45 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-25 03:23:45 +0000
commit25ca739c12a1e73b7095b81cac803eba32561428 (patch)
tree404390523a65a08480902d09503e731c7d3a136d /src/map/script.c
parent2ee02684c08bd57ae8562c2194f161f95fe96000 (diff)
downloadhercules-25ca739c12a1e73b7095b81cac803eba32561428.tar.gz
hercules-25ca739c12a1e73b7095b81cac803eba32561428.tar.bz2
hercules-25ca739c12a1e73b7095b81cac803eba32561428.tar.xz
hercules-25ca739c12a1e73b7095b81cac803eba32561428.zip
Corrected some typos and small details
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9912 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/map/script.c b/src/map/script.c
index bc2b175f8..3edea1b80 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5075,41 +5075,42 @@ BUILDIN_FUNC(copyarray)
}
return 0;
}
+
/*==========================================
- * 配列変数のサイズ所得
- *------------------------------------------
- */
-static int getarraysize(struct script_state *st,int num,int postfix,struct linkdb_node** ref)
+ * Returns the size of the specified array
+ *------------------------------------------*/
+static int getarraysize(struct script_state* st, int num, int postfix, struct linkdb_node** ref)
{
- int i=(num>>24),c=(i==0? -1:i); // Moded to -1 because even if the first element is 0, it will still report as 1 [Lance]
- if(postfix == '$'){
- for(;i<128;i++){
- void *v=get_val2(st,(num & 0x00FFFFFF)+(i<<24),ref);
- if(*((char*)v)) c=i;
+ //TODO: unreadable; remove +-1 trick, remove weird for loop, remove typecast
+ int i = (num>>24), c = (i==0?-1:i); // Moded to -1 because even if the first element is 0, it will still report as 1 [Lance]
+
+ if(postfix == '$') {
+ for(; i < 128; i++) {
+ void* v = get_val2(st, (num & 0x00FFFFFF) + (i<<24), ref);
+ if(*((char*)v)) c = i;
}
- }else{
- for(;i<128;i++){
- void *v=get_val2(st,(num & 0x00FFFFFF)+(i<<24),ref);
- if((int)v) c=i;
+ } else {
+ for(; i < 128; i++) {
+ void* v = get_val2(st, (num & 0x00FFFFFF) + (i<<24), ref);
+ if((int)v) c = i;
}
}
- return c+1;
+ return c + 1;
}
BUILDIN_FUNC(getarraysize)
{
- 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];
+ int num = st->stack->stack_data[st->start+2].u.num;
+ char* name = str_buf + str_data[num&0x00ffffff].str;
+ char prefix = name[0], postfix = name[strlen(name)-1];
- if( prefix!='$' && prefix!='@' && prefix!='.' ){
- ShowWarning("buildin_copyarray: illegal scope !\n");
- push_val(st->stack,C_INT,0);
+ if( prefix != '$' && prefix != '@' && prefix != '.' ) {
+ ShowWarning("buildin_getarraysize: illegal scope !\n");
+ push_val(st->stack, C_INT, 0);
return 1;
}
- push_val(st->stack,C_INT,getarraysize(st,num,postfix,st->stack->stack_data[st->start+2].ref));
+ push_val(st->stack, C_INT, getarraysize(st, num, postfix, st->stack->stack_data[st->start+2].ref));
return 0;
}
/*==========================================
@@ -6146,7 +6147,7 @@ BUILDIN_FUNC(strcharinfo)
num=conv_num(st,& (st->stack->stack_data[st->start+2]));
switch(num){
case 0:
- push_str(st->stack,C_CONSTSTR,sd->status.name);
+ push_str(st->stack,C_STR,aStrdup(sd->status.name));
break;
case 1:
buf=buildin_getpartyname_sub(sd->status.party_id);