commands.cxx

changeset 7
118d3d5db64f
parent 6
0005527cad62
child 8
c8bfa7e6ae1b
--- a/commands.cxx	Sat Jul 14 01:49:32 2012 +0300
+++ b/commands.cxx	Sat Jul 14 02:16:48 2012 +0300
@@ -48,6 +48,7 @@
 
 CommandDef* g_CommDef;
 
+#define MAX
 void ReadCommands () {
 	ScriptReader* r = new ScriptReader ((char*)"commands.def");
 	g_CommDef = NULL;
@@ -57,6 +58,11 @@
 	while (r->Next()) {
 		CommandDef* comm = new CommandDef;
 		
+		// Any more than 4 is a warning, any less is an error.
+		unsigned int c = r->token.count (const_cast<char*> (":"));
+		if (c < 4)
+			r->ParserError ("not enough parameters: got %d, expected 4", c);
+		
 		int n = 0;
 		str t = "";
 		for (unsigned int u = 0; u < r->token.len(); u++) {
@@ -89,7 +95,7 @@
 					else if (!t.compare ("bool"))
 						comm->returnvalue = RETURNVAL_BOOLEAN;
 					else
-						r->ParseError ("bad return value type `%s`", t.chars());
+						r->ParserError ("bad return value type `%s`", t.chars());
 					break;
 				case 3:
 					// Num args
@@ -99,6 +105,9 @@
 					// Max args
 					comm->maxargs = i;
 					break;
+				default:
+					r->ParserWarning ("too many parameters");
+					break;
 				}
 				
 				n++;

mercurial