diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-03-01 19:44:37 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-03-01 19:44:37 +0000 |
commit | 094168fde61dd27a21b9bf91c162a8de6d37c58c (patch) | |
tree | 092c53703515623de7be794542ba5aeca8c30945 /src | |
parent | 7564712d7fc9d13890011fdd22215e9ff912e1a4 (diff) | |
download | hercules-094168fde61dd27a21b9bf91c162a8de6d37c58c.tar.gz hercules-094168fde61dd27a21b9bf91c162a8de6d37c58c.tar.bz2 hercules-094168fde61dd27a21b9bf91c162a8de6d37c58c.tar.xz hercules-094168fde61dd27a21b9bf91c162a8de6d37c58c.zip |
- Checked and fixed the script engine barking when you try to have a label with the same name as a const.txt defined parameter.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5415 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/login_sql/login.c | 3 | ||||
-rw-r--r-- | src/map/script.c | 142 |
2 files changed, 34 insertions, 111 deletions
diff --git a/src/login_sql/login.c b/src/login_sql/login.c index ba5b4dcc6..e2924b1de 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -237,10 +237,9 @@ void read_gm_account(void) { gm_account_db[GM_num].level = atoi(sql_row[1]);
GM_num++;
}
+ mysql_free_result(sql_res);
}
}
-
- mysql_free_result(sql_res);
}
int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len);
diff --git a/src/map/script.c b/src/map/script.c index ee1100ac8..b37542fb3 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -110,6 +110,7 @@ unsigned char* parse_syntax_close(unsigned char *p); unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag);
unsigned char* parse_syntax(unsigned char *p);
static int parse_syntax_for_flag = 0;
+static void disp_error_message(const char *mes,const unsigned char *pos);
extern int current_equip_item_index; //for New CARS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus]
int potion_flag=0; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
@@ -926,9 +927,17 @@ static void add_scriptl(int l) * ���x������������
*------------------------------------------
*/
-void set_label(int l,int pos)
+void set_label(int l,int pos, unsigned char *name)
{
int i,next;
+ if (str_data[l].label != -1) {
+ disp_error_message("dup label", name);
+ exit(1);
+ }
+ if(str_data[l].type == C_PARAM) {
+ disp_error_message("invalid label name",name);
+ exit(1);
+ }
str_data[l].type=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
str_data[l].label=pos;
@@ -1387,11 +1396,7 @@ unsigned char* parse_curly_close(unsigned char *p) { // ���ݒn�̃��x����t����
sprintf(label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
if(syntax.curly[pos].flag) {
// default �����݂���
@@ -1404,11 +1409,7 @@ unsigned char* parse_curly_close(unsigned char *p) { // �I�����x����t����
sprintf(label,"__SW%x_FIN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly_count--;
return p+1;
@@ -1479,11 +1480,7 @@ unsigned char* parse_syntax(unsigned char *p) { // ���ݒn�̃��x����t����
sprintf(label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
}
// switch ���蕶
p = skip_word(p);
@@ -1508,11 +1505,7 @@ unsigned char* parse_syntax(unsigned char *p) { // FALLTHRU �I����̃��x��
sprintf(label,"__SW%x_%xJ",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
}
// �ꎞ�ϐ�������
sprintf(label,"set $@__SW%x_VAL,0;",syntax.curly[pos].index);
@@ -1576,11 +1569,7 @@ unsigned char* parse_syntax(unsigned char *p) { p++;
sprintf(label,"__SW%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
// �������Ŏ��̃����N�ɔ��
sprintf(label,"goto __SW%x_%x;",syntax.curly[pos].index,syntax.curly[pos].count+1);
@@ -1591,11 +1580,7 @@ unsigned char* parse_syntax(unsigned char *p) { // default �̃��x����t����
sprintf(label,"__SW%x_DEF",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly[syntax.curly_count - 1].flag = 1;
syntax.curly[pos].count++;
@@ -1616,11 +1601,7 @@ unsigned char* parse_syntax(unsigned char *p) { // ���ݒn�̃��x���`������
sprintf(label,"__DO%x_BGN",syntax.curly[syntax.curly_count].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly_count++;
return p;
}
@@ -1653,11 +1634,7 @@ unsigned char* parse_syntax(unsigned char *p) { // �������f�J�n�̃��x���`������
sprintf(label,"__FR%x_J",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
if(*p == ';') {
// for(;;) �̃p�^�[���Ȃ̂ŕK���^
@@ -1687,11 +1664,7 @@ unsigned char* parse_syntax(unsigned char *p) { // ���̃��[�v�ւ̃��x���`������
sprintf(label,"__FR%x_NXT",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
// ���̃��[�v�ɓ��鎞�̏���
// for �Ō�� '(' �� ';' �Ƃ��Ĉ����t���O
@@ -1710,11 +1683,7 @@ unsigned char* parse_syntax(unsigned char *p) { // ���[�v�J�n�̃��x���t��
sprintf(label,"__FR%x_BGN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
return p;
} else if(!strncmp(p,"function",8) && !isalpha(*(p + 8))) {
unsigned char *func_name;
@@ -1755,19 +1724,10 @@ unsigned char* parse_syntax(unsigned char *p) { // �����̃��x����t����
*p = 0;
l=add_str(func_name);
- if(str_data[l].type == C_PARAM) {
- disp_error_message("invalid label name ",p);
- exit(1);
- }
if(str_data[l].type == C_NOP) {
str_data[l].type = C_USERFUNC;
}
- if(str_data[l].label!=-1){
- *p=c;
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,&c);
strdb_put(scriptlabel_db,func_name,(void*)script_pos); // �O���plabel db�o�^
*p = c;
return skip_space(p);
@@ -1834,11 +1794,7 @@ unsigned char* parse_syntax(unsigned char *p) { // �������f�J�n�̃��x���`������
sprintf(label,"__WL%x_NXT",syntax.curly[syntax.curly_count].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
// �������U�Ȃ�I���n�_�ɔ��
sprintf(label,"__WL%x_FIN",syntax.curly[syntax.curly_count].index);
@@ -1889,11 +1845,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // ���ݒn�̃��x����t����
sprintf(label,"__IF%x_%x",syntax.curly[pos].index,syntax.curly[pos].count);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly[pos].count++;
p = skip_space(p);
@@ -1928,11 +1880,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // �ŏI�n�̃��x����t����
sprintf(label,"__IF%x_FIN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
if(syntax.curly[pos].flag == 1) {
// ����if�ɑ���else����Ȃ��̂Ń|�C���^�̈ʒu�͓���
return p2;
@@ -1947,11 +1895,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // ���ݒn�̃��x���`������(continue �ł����ɗ���)
sprintf(label,"__DO%x_NXT",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
}
// �������U�Ȃ�I���n�_�ɔ��
@@ -1979,11 +1923,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // �����I���n�_�̃��x���`������
sprintf(label,"__DO%x_FIN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
p = skip_space(p);
if(*p != ';') {
disp_error_message("need ';'",p);
@@ -2002,11 +1942,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // for �I���̃��x���t��
sprintf(label,"__FR%x_FIN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly_count--;
return p;
} else if(syntax.curly[pos].type == TYPE_WHILE) {
@@ -2019,11 +1955,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // while �I���̃��x���t��
sprintf(label,"__WL%x_FIN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly_count--;
return p;
} else if(syntax.curly[syntax.curly_count-1].type == TYPE_USERFUNC) {
@@ -2039,11 +1971,7 @@ unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag) { // ���ݒn�̃��x����t����
sprintf(label,"__FN%x_FIN",syntax.curly[pos].index);
l=add_str(label);
- if(str_data[l].label!=-1){
- disp_error_message("dup label ",p);
- exit(1);
- }
- set_label(l,script_pos);
+ set_label(l,script_pos,p);
syntax.curly_count--;
return p + 1;
} else {
@@ -2161,16 +2089,12 @@ unsigned char* parse_script(unsigned char *src,int line) // label�������ꏈ��
tmpp = skip_space(skip_word(p));
if (*tmpp == ':' && !(!strncmp(p,"default",7) && !isalpha(*(p + 7)))) {
- int l, c;
+ int l;
+ unsigned char c;
c = *skip_word(p);
*skip_word(p) = 0;
l = add_str(p);
- if (str_data[l].label != -1) {
- *skip_word(p) = c;
- disp_error_message("dup label ", p);
- exit(1);
- }
- set_label(l, script_pos);
+ set_label(l, script_pos,&c);
strdb_put(scriptlabel_db, p, (void*)script_pos); // �O���plabel db�o�^
*skip_word(p) = c;
p = tmpp + 1;
@@ -2182,7 +2106,7 @@ unsigned char* parse_script(unsigned char *src,int line) p = skip_space(p);
add_scriptc(C_EOL);
- set_label(LABEL_NEXTLINE, script_pos);
+ set_label(LABEL_NEXTLINE, script_pos,p);
str_data[LABEL_NEXTLINE].type = C_NOP;
str_data[LABEL_NEXTLINE].backpatch = -1;
str_data[LABEL_NEXTLINE].label = -1;
|