summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-23 04:35:32 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-23 04:35:32 +0000
commit4e45ec34bb37eb515480cfc42dce7d7380a5e235 (patch)
tree0801187366e76552f7862a6206a5cbd2df4baf06
parentae6efe1e4bb013f18d79319f2375695fe241d64f (diff)
downloadhercules-4e45ec34bb37eb515480cfc42dce7d7380a5e235.tar.gz
hercules-4e45ec34bb37eb515480cfc42dce7d7380a5e235.tar.bz2
hercules-4e45ec34bb37eb515480cfc42dce7d7380a5e235.tar.xz
hercules-4e45ec34bb37eb515480cfc42dce7d7380a5e235.zip
* Script parse errors displayed with one ShowError instead of several ShowMessage's.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12637 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/map/script.c30
-rw-r--r--src/map/script.h3
3 files changed, 20 insertions, 15 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 3f2200b82..eb3f551ba 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/04/23
+ * Script parse errors displayed with one ShowError instead of several ShowMessage's. [FlavioJS]
2008/04/22
* Changed itemdb_reload to clear the database before reloading, so it is possible
can remove an item from the DB without restarting the server (bugreport:1348) (r12635). [Kevin]
diff --git a/src/map/script.c b/src/map/script.c
index 0d520ebc3..236bcf71e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1828,31 +1828,32 @@ static void read_constdb(void)
/*==========================================
* エラー表示
*------------------------------------------*/
-const char* script_print_line( const char *p, const char *mark, int line )
+static const char* script_print_line(StringBuf* buf, const char* p, const char* mark, int line)
{
int i;
if( p == NULL || !p[0] ) return NULL;
if( line < 0 )
- ShowMessage("*% 5d : ", -line);
+ StringBuf_Printf(buf, "*% 5d : ", -line);
else
- ShowMessage(" % 5d : ", line);
+ StringBuf_Printf(buf, " % 5d : ", line);
for(i=0;p[i] && p[i] != '\n';i++){
if(p + i != mark)
- ShowMessage("%c",p[i]);
+ StringBuf_Printf(buf, "%c", p[i]);
else
- ShowMessage("\'%c\'",p[i]);
+ StringBuf_Printf(buf, "\'%c\'", p[i]);
}
- ShowMessage("\n");
+ StringBuf_AppendStr(buf, "\n");
return p+i+(p[i] == '\n' ? 1 : 0);
}
-void script_error(const char *src,const char *file,int start_line, const char *error_msg, const char *error_pos)
+void script_error(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos)
{
// エラーが発生した行を求める
int j;
int line = start_line;
const char *p;
const char *linestart[5] = { NULL, NULL, NULL, NULL, NULL };
+ StringBuf buf;
for(p=src;p && *p;line++){
const char *lineend=strchr(p,'\n');
@@ -1866,16 +1867,19 @@ void script_error(const char *src,const char *file,int start_line, const char *e
p=lineend+1;
}
- ShowMessage("\a\n");
- ShowMessage("script error on %s line %d\n", file, line);
- ShowMessage(" %s\n", error_msg);
+ StringBuf_Init(&buf);
+ StringBuf_AppendStr(&buf, "\a\n");
+ StringBuf_Printf(&buf, "script error on %s line %d\n", file, line);
+ StringBuf_Printf(&buf, " %s\n", error_msg);
for(j = 0; j < 5; j++ ) {
- script_print_line( linestart[j], NULL, line + j - 5);
+ script_print_line(&buf, linestart[j], NULL, line + j - 5);
}
- p = script_print_line( p, error_pos, -line);
+ p = script_print_line(&buf, p, error_pos, -line);
for(j = 0; j < 5; j++) {
- p = script_print_line( p, NULL, line + j + 1 );
+ p = script_print_line(&buf, p, NULL, line + j + 1 );
}
+ ShowError("%s", StringBuf_Value(&buf));
+ StringBuf_Destroy(&buf);
}
/*==========================================
diff --git a/src/map/script.h b/src/map/script.h
index 7f07185a8..981c5b985 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -118,8 +118,7 @@ enum script_parse_options {
};
const char* skip_space(const char* p);
-const char* script_print_line(const char* p, const char* mark, int line);
-void script_error(const char *src,const char *file,int start_line, const char *error_msg, const char *error_pos);
+void script_error(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos);
struct script_code* parse_script(const char* src,const char* file,int line,int options);
void run_script_sub(struct script_code *rootscript,int pos,int rid,int oid, char* file, int lineno);