summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/mapindex.c14
-rw-r--r--src/common/mapindex.h1
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/unit.c2
-rwxr-xr-xtools/validateinterfaces.py102
5 files changed, 98 insertions, 23 deletions
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index ec829ee56..e00fc107d 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -165,13 +165,20 @@ int mapindex_init(void) {
}
fclose(fp);
- 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);
- }
+ mapindex->check_default();
return total;
}
+bool mapindex_check_default(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 false;
+ }
+ return true;
+}
+
void mapindex_removemap(int index){
strdb_remove(mapindex->db, mapindex->list[index].name);
mapindex->list[index].name[0] = '\0';
@@ -201,4 +208,5 @@ void mapindex_defaults(void) {
mapindex->getmapname_ext = mapindex_getmapname_ext;
mapindex->name2id = mapindex_name2id;
mapindex->id2name = mapindex_id2name_sub;
+ mapindex->check_default = mapindex_check_default;
}
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index 446a2422d..53d08f8e6 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -84,6 +84,7 @@ struct mapindex_interface {
/* TODO: Hello World! make up your mind, this thing is int on some places and unsigned short on others */
unsigned short (*name2id) (const char*);
const char* (*id2name) (unsigned short,const char *file, int line, const char *func);
+ bool (*check_default) (void);
};
struct mapindex_interface *mapindex;
diff --git a/src/map/script.c b/src/map/script.c
index 6037c61fa..e04ba6f32 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -155,7 +155,7 @@ static void script_dump_stack(struct script_state* st)
break;
case C_NAME:
- ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script_op2name(script->str_data[data->u.num].type));
+ ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script->op2name(script->str_data[data->u.num].type));
break;
case C_RETINFO:
diff --git a/src/map/unit.c b/src/map/unit.c
index 3962e771e..c78919f52 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2323,7 +2323,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i
//Clear target even if there is no timer
if (ud->target || ud->attacktimer != INVALID_TIMER)
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
//Clear stepaction even if there is no timer
if (ud->stepaction || ud->steptimer != INVALID_TIMER)
diff --git a/tools/validateinterfaces.py b/tools/validateinterfaces.py
index a4222adb5..b34bd6233 100755
--- a/tools/validateinterfaces.py
+++ b/tools/validateinterfaces.py
@@ -26,7 +26,7 @@ def searchStructStart(r, ifname):
return True
return False
-def readCFile(cFile):
+def readCFile(tracker, cFile):
methods = Set()
shortIfName = ""
with open(cFile, "r") as r:
@@ -38,7 +38,7 @@ def readCFile(cFile):
ifname = m.group("name1")
if searchDefault(r, ifname) == False:
return (None, shortIfName, methods)
- lineRe = re.compile("(?P<ifname>[a-z_]+)->(?P<method>[\w_]+) ")
+ lineRe = re.compile("(?P<ifname>[a-z_]+)->(?P<method>[\w_]+)[ ][=][ ](?P<fullmethod>[^;]+);")
for line in r:
# print "cline2: " + line
test = line.strip()
@@ -55,10 +55,12 @@ def readCFile(cFile):
shortIfName = m.group("ifname")
# print "{2}: add {0}, from: {1}".format(m.group("method"), line, ifname)
methods.add(m.group("method"))
+ tracker.interfaces.add(ifname);
+ tracker.fullmethods.add(m.group("fullmethod"));
return (ifname, shortIfName, methods)
return (None, shortIfName, methods)
-def readHFile(hFile, ifname):
+def readHFile(tracker, hFile, ifname):
methods = Set()
with open(hFile, "r") as r:
if searchStructStart(r, ifname) == False:
@@ -75,15 +77,16 @@ def readHFile(hFile, ifname):
if m != None:
# print "{2}: add {0}, from: {1}".format(m.group("method"), line, ifname)
methods.add(m.group("method"))
+ tracker.fullmethods.add(ifname + "_" + m.group("method"))
return methods
def checkIfFile(tracker, cFile, hFile):
- data = readCFile(cFile)
+ data = readCFile(tracker, cFile)
cMethods = data[2]
ifname = data[0]
shortIfName = data[1]
if len(cMethods) > 0:
- hMethods = readHFile(hFile, ifname)
+ hMethods = readHFile(tracker, hFile, ifname)
for method in hMethods:
tracker.arr[ifname + "_" + method] = list()
tracker.methods.add(ifname + "_" + method)
@@ -116,7 +119,7 @@ def checkChr(ch):
return False
def checkFile(tracker, cFile):
- print "Checking: " + cFile
+# print "Checking: " + cFile
with open(cFile, "r") as r:
for line in r:
parts = re.findall(r'[\w_]+', line)
@@ -130,8 +133,16 @@ def checkFile(tracker, cFile):
continue
if checkChr(line[idx - 1]):
continue
+ if line[0:3] == " * ":
+ continue;
if line[-1] == "\n":
line = line[:-1]
+ text = line.strip()
+ if text[0:2] == "/*" or text[0:2] == "//":
+ continue
+ idx2 = line.find("//")
+ if idx2 > 0 and idx2 < idx:
+ continue
tracker.arr[part].append(line)
def processDir(tracker, srcDir):
@@ -156,25 +167,80 @@ def reportMethods(tracker):
print "\n"
-tracker = Tracker()
-tracker.arr = dict()
-tracker.methods = Set()
-tracker.retCode = 0
-if len(sys.argv) > 1 and sys.argv[1] == "silent":
- processIfDir(tracker, "../src/char");
- processIfDir(tracker, "../src/map");
- processIfDir(tracker, "../src/login");
- processIfDir(tracker, "../src/common");
-else:
- print "Checking initerfaces initialisation"
+def checkLostFile(tracker, cFile):
+# print "Checking: " + cFile
+ methodRe = re.compile("^([\w0-9* _]*)([ ]|[*])(?P<ifname>[a-z_]+)_(?P<method>[\w_]+)(|[ ])[(]")
+ with open(cFile, "r") as r:
+ for line in r:
+ if line.find("(") < 1 or len(line) < 3 or line[0] == "\t" or line[0] == " " or line.find("_defaults") > 0:
+ continue
+ m = methodRe.search(line)
+ if m != None:
+ name = "{0}_{1}".format(m.group("ifname"), m.group("method"))
+ if m.group("ifname") not in tracker.interfaces:
+ continue
+ if name not in tracker.fullmethods:
+# print "src : " + line
+ print name
+
+def processLostDir(tracker, srcDir):
+ files = os.listdir(srcDir)
+ for file1 in files:
+ if file1[0] == '.' or file1 == "..":
+ continue
+ cPath = os.path.abspath(srcDir + os.path.sep + file1)
+ if not os.path.isfile(cPath):
+ processLostDir(tracker, cPath)
+ elif file1[-2:] == ".c":
+ checkLostFile(tracker, cPath)
+
+def runIf():
processIfDir(tracker, "../src/char");
processIfDir(tracker, "../src/map");
processIfDir(tracker, "../src/login");
processIfDir(tracker, "../src/common");
- print "Checking interfaces usage"
+
+def runLost():
+ processLostDir(tracker, "../src/char");
+ processLostDir(tracker, "../src/map");
+ processLostDir(tracker, "../src/login");
+ processLostDir(tracker, "../src/common");
+
+def runLong():
processDir(tracker, "../src/char");
processDir(tracker, "../src/map");
processDir(tracker, "../src/login");
processDir(tracker, "../src/common");
reportMethods(tracker)
+
+tracker = Tracker()
+tracker.arr = dict()
+tracker.methods = Set()
+tracker.fullmethods = Set()
+tracker.interfaces = Set()
+tracker.retCode = 0
+
+if len(sys.argv) > 1:
+ cmd = sys.argv[1]
+else:
+ cmd = "default"
+
+if cmd == "silent":
+ runIf()
+elif cmd == "init":
+ print "Checking interfaces initialisation"
+ runIf()
+elif cmd == "lost":
+ print "Checking not added functions to interfaces"
+ runLost();
+elif cmd == "long":
+ print "Checking interfaces usage"
+ runLong();
+else:
+ print "Checking interfaces initialisation"
+ runIf()
+ print "Checking not added functions to interfaces"
+ runLost();
+ print "Checking interfaces usage"
+ runLong();
exit(tracker.retCode)