about summary refs log tree commit diff
path: root/scripts/netobj.py
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-02-24 18:41:02 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-02-24 18:41:02 +0000
commit91eda24ddc8b56c6022a4d99519f28230e6b3bbf (patch)
treefc9e9313ee26cd9f87a2be7d35be989907ef02e1 /scripts/netobj.py
parent4739966e14ca2df24d4f44fb814b6275b9bf2a3c (diff)
downloadzcatch-91eda24ddc8b56c6022a4d99519f28230e6b3bbf.tar.gz
zcatch-91eda24ddc8b56c6022a4d99519f28230e6b3bbf.zip
fixed correction count. fixed miss-behaving server
Diffstat (limited to 'scripts/netobj.py')
-rw-r--r--scripts/netobj.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/netobj.py b/scripts/netobj.py
index 107f49c4..03228e34 100644
--- a/scripts/netobj.py
+++ b/scripts/netobj.py
@@ -184,6 +184,7 @@ def emit_header_file(f, p):
 
 	print >>f, "int netobj_secure(int type, void *data, int size);"
 	print >>f, "const char *netobj_get_name(int type);"
+	print >>f, "int netobj_num_corrections();"
 	print >>f, ""
 
 	for obj in p.objects:
@@ -199,11 +200,15 @@ def emit_source_file(f, p, protofilename):
 	for l in p.source_raw:
 		print >>f, l
 
+	print >>f, ""
+	print >>f, "static int num_corrections = 0;"
+	print >>f, "int netobj_num_corrections() { return num_corrections; }"
+	print >>f, ""
 	print >>f, "static int netobj_clamp_int(int v, int min, int max)"
 	print >>f, "{"
-	print >>f, "if(v<min) return min;"
-	print >>f, "if(v>max) return max;"
-	print >>f, "return v;"
+	print >>f, "\tif(v<min) { num_corrections++; return min; }"
+	print >>f, "\tif(v>max) { num_corrections++; return max; }"
+	print >>f, "\treturn v;"
 	print >>f, "}"
 	print >>f, ""