summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-05 07:24:29 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-05 07:24:29 +0000
commit1bbd86388b5396a4c3ef9f1d34e2c6113955c92b (patch)
tree184a285c17edee681bdaf7a2533888484fc15f89 /src/map/script.c
parenta48d096890242cdde3c9e0f682ddb33c4405163a (diff)
downloadhercules-1bbd86388b5396a4c3ef9f1d34e2c6113955c92b.tar.gz
hercules-1bbd86388b5396a4c3ef9f1d34e2c6113955c92b.tar.bz2
hercules-1bbd86388b5396a4c3ef9f1d34e2c6113955c92b.tar.xz
hercules-1bbd86388b5396a4c3ef9f1d34e2c6113955c92b.zip
- Moved START_ACCOUNT_NUM and END_ACCOUNT_NUM from login.h to mmo.h and changed clif_guess_PacketVer to use that.
- Made the script engine big-endian compatible. (i know it's pointless because of the move to eApp, but just couldn't resist :S) - Commented out the remnants of ladmin packet parsing in map-server. - Added a warning when a player has an invalid packet version (shouldn't happen) PS- also added info on clif_guild_basicinfo packet fields, if anyone is interested git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9408 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/map/script.c b/src/map/script.c
index e6a673d22..36094bfb9 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -25,6 +25,7 @@
#include "../common/nullpo.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
+#include "../common/utils.h"
#include "map.h"
#include "clif.h"
@@ -60,6 +61,9 @@ enum { LABEL_NEXTLINE=1,LABEL_START };
static unsigned char * script_buf = NULL;
static int script_pos,script_size;
+#define GETVALUE(buf,i) ((int)MakeDWord(MakeWord((buf)[i],(buf)[i+1]),MakeWord((buf)[i+2],0)))
+#define SETVALUE(buf,i,n) ((buf)[i]=GetByte(n,0),(buf)[i+1]=GetByte(n,1),(buf)[i+2]=GetByte(n,2))
+
static char *str_buf;
static int str_pos,str_size;
static struct str_data_struct {
@@ -444,11 +448,9 @@ void set_label(int l,int pos, unsigned char *script_pos)
str_data[l].type=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
str_data[l].label=pos;
for(i=str_data[l].backpatch;i>=0 && i!=0x00ffffff;){
- next=(*(int*)(script_buf+i)) & 0x00ffffff;
+ next=GETVALUE(script_buf,i);
script_buf[i-1]=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
- script_buf[i]=pos;
- script_buf[i+1]=pos>>8;
- script_buf[i+2]=pos>>16;
+ SETVALUE(script_buf,i,pos);
i=next;
}
}
@@ -1694,10 +1696,8 @@ struct script_code* parse_script(unsigned char *src,const char *file,int line)
str_data[i].type=C_NAME;
str_data[i].label=i;
for(j=str_data[i].backpatch;j>=0 && j!=0x00ffffff;){
- next=(*(int*)(script_buf+j)) & 0x00ffffff;
- script_buf[j]=i;
- script_buf[j+1]=i>>8;
- script_buf[j+2]=i>>16;
+ next=GETVALUE(script_buf,j);
+ SETVALUE(script_buf,j,i);
j=next;
}
}
@@ -2628,7 +2628,7 @@ void run_script_main(struct script_state *st)
st->state = RUN;
while(st->state == RUN){
- c= get_com((unsigned char *) st->script->script_buf,&st->pos);
+ c= get_com(st->script->script_buf,&st->pos);
switch(c){
case C_EOL:
if(stack->sp!=stack->defsp){
@@ -2647,18 +2647,18 @@ void run_script_main(struct script_state *st)
}
break;
case C_INT:
- push_val(stack,C_INT,get_num((unsigned char *) st->script->script_buf,&st->pos));
+ push_val(stack,C_INT,get_num(st->script->script_buf,&st->pos));
break;
case C_POS:
case C_NAME:
- push_val(stack,c,(*(int*)(st->script->script_buf+st->pos))&0xffffff);
+ push_val(stack,c,GETVALUE(st->script->script_buf,st->pos));
st->pos+=3;
break;
case C_ARG:
push_val(stack,c,0);
break;
case C_STR:
- push_str(stack,C_CONSTSTR,(unsigned char *) (st->script->script_buf+st->pos));
+ push_str(stack,C_CONSTSTR,(st->script->script_buf+st->pos));
while(st->script->script_buf[st->pos++]);
break;
case C_FUNC: