summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorshennetsind <shennetsind@users.noreply.github.com>2013-11-06 15:10:38 -0800
committershennetsind <shennetsind@users.noreply.github.com>2013-11-06 15:10:38 -0800
commit87d7348396af97428638723ae49ca2ff166e4acd (patch)
treef9cebecab0aaf281a8ebb5405648fe8d0b731ecb /src/common
parent7d1bbde0046ee7520c907e090f1b4087eb713172 (diff)
parent4fbe8e2a270997b02e2e002074259e4648ac0031 (diff)
downloadhercules-87d7348396af97428638723ae49ca2ff166e4acd.tar.gz
hercules-87d7348396af97428638723ae49ca2ff166e4acd.tar.bz2
hercules-87d7348396af97428638723ae49ca2ff166e4acd.tar.xz
hercules-87d7348396af97428638723ae49ca2ff166e4acd.zip
Merge pull request #217 from HerculesWS/script-checker
Introducing the Hercules Standalone Script Syntax Checker
Diffstat (limited to 'src/common')
-rw-r--r--src/common/core.c14
-rw-r--r--src/common/mapindex.c17
-rw-r--r--src/common/mapindex.h3
3 files changed, 26 insertions, 8 deletions
diff --git a/src/common/core.c b/src/common/core.c
index 6a73d2d39..f57cc4c79 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -302,10 +302,20 @@ int main (int argc, char **argv) {
arg_v = argv;
}
core_defaults();
+
+ {
+ int i;
+ for(i = 0; i < argc; i++) {
+ if( strcmp(argv[i], "--script-check") == 0 ) {
+ msg_silent = 0x7; // silence information and status messages
+ }
+ }
+ }
iMalloc->init();// needed for Show* in display_title() [FlavioJS]
-
- console->display_title();
+
+ if (!(msg_silent&0x1))
+ console->display_title();
#ifdef MINICORE // minimalist Core
usercheck();
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 83de21b2b..a95e143c3 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -21,7 +21,12 @@ int max_index = 0;
char mapindex_cfgfile[80] = "db/map_index.txt";
-#define mapindex_exists(id) (indexes[id].name[0] != '\0')
+#define mapindex_exists_sub(id) (indexes[id].name[0] != '\0')
+
+bool mapindex_exists(int id) {
+ return mapindex_exists_sub(id);
+}
+
/// Retrieves the map name from 'string' (removing .gat extension if present).
/// Result gets placed either into 'buf' or in a static local buffer.
const char* mapindex_getmapname(const char* string, char* output) {
@@ -102,7 +107,7 @@ int mapindex_addmap(int index, const char* name) {
return 0;
}
- if (mapindex_exists(index)) {
+ if (mapindex_exists_sub(index)) {
ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, indexes[index].name, map_name);
strdb_remove(mapindex_db, indexes[index].name);
}
@@ -129,18 +134,18 @@ unsigned short mapindex_name2id(const char* name) {
}
const char* mapindex_id2name_sub(unsigned short id,const char *file, int line, const char *func) {
- if (id > MAX_MAPINDEX || !mapindex_exists(id)) {
+ if (id > MAX_MAPINDEX || !mapindex_exists_sub(id)) {
ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line);
return indexes[0].name; // dummy empty string so that the callee doesn't crash
}
return indexes[id].name;
}
-void mapindex_init(void) {
+int mapindex_init(void) {
FILE *fp;
char line[1024];
int last_index = -1;
- int index;
+ int index, total = 0;
char map_name[12];
if( ( fp = fopen(mapindex_cfgfile,"r") ) == NULL ){
@@ -158,6 +163,7 @@ void mapindex_init(void) {
index = last_index+1;
case 2: //Map with ID given
mapindex_addmap(index,map_name);
+ total++;
break;
default:
continue;
@@ -169,6 +175,7 @@ void mapindex_init(void) {
if( !strdb_iget(mapindex_db, MAP_DEFAULT) ) {
ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n",MAP_DEFAULT);
}
+ return total;
}
int mapindex_removemap(int index){
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index 43953a8e0..646f73f18 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -56,12 +56,13 @@ extern char mapindex_cfgfile[80];
#define MAP_MALAYA "malaya"
#define MAP_ECLAGE "eclage"
+bool mapindex_exists(int id);
const char* mapindex_getmapname(const char* string, char* output);
const char* mapindex_getmapname_ext(const char* string, char* output);
unsigned short mapindex_name2id(const char*);
#define mapindex_id2name(n) mapindex_id2name_sub(n,__FILE__, __LINE__, __func__)
const char* mapindex_id2name_sub(unsigned short,const char *file, int line, const char *func);
-void mapindex_init(void);
+int mapindex_init(void);
void mapindex_final(void);
int mapindex_addmap(int index, const char* name);