Index: /Daodan/inifile.bat
===================================================================
--- /Daodan/inifile.bat	(revision 451)
+++ /Daodan/inifile.bat	(revision 451)
@@ -0,0 +1,1 @@
+gcc -O3 -s -Wall src/inifile_reader.c src/inifile_test.c -o obj/inifile_test
Index: /Daodan/obj/testini.ini
===================================================================
--- /Daodan/obj/testini.ini	(revision 451)
+++ /Daodan/obj/testini.ini	(revision 451)
@@ -0,0 +1,41 @@
+! --- Syntax Tests ---
+  # Test comment
+
+test1=hi
+
+[TestA]
+test2=lol hi
+test3=this is test2
+test4=
+   test5=sup
+
+!This is test B
+      [Test B]
+test6=test B is awesome
+
+! --- Parsing Tests ---
+
+IntTest=0x00000001
+IntTest=0x00000010
+IntTest=0xA
+IntTest=0xFFFFFFFF
+IntTest=102
+SIntTest=-3456
+IntTest=4294967295
+SIntTest=2147483647
+SIntTest=-2147483648
+
+# These tests are supposed to return an error (0x100000000)
+IntTest=0xEFG
+IntTest=0x123456789
+IntTest=0x
+IntTest=4294967296
+SIntTest=2147483648
+SIntTest=-2147483649
+IntTest=4294967297
+SIntTest=2147483649
+SIntTest=-2147483650
+
+CleanTest= True       
+CleanTest=  	 False
+CleanTest=True  	True  	
Index: /Daodan/src/Daodan.c
===================================================================
--- /Daodan/src/Daodan.c	(revision 450)
+++ /Daodan/src/Daodan.c	(revision 451)
@@ -195,58 +195,55 @@
 		case s_options:
 			if (!stricmp(name, "usedaodanbsl"))
-				opt_usedaodanbsl = !stricmp(value, "true");
+				opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
 			break;
 		case s_patch:
 			if (!stricmp(name, "fonttexturecache"))
-				patch_fonttexturecache = !stricmp(value, "true");
+				patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "largetextures"))
-				patch_largetextures = !stricmp(value, "true");
+				patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "levelplugins"))
-				patch_levelplugins = !stricmp(value, "true");
+				patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "pathfinding"))
-				patch_pathfinding = !stricmp(value, "true");
+				patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "projaware"))
-				patch_projaware = !stricmp(value, "true");
+				patch_projaware = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "directinput"))
-				patch_directinput = !stricmp(value, "true");
+				patch_directinput = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "wpfadetime"))
-				patch_wpfadetime = !stricmp(value, "true");
+				patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "kickguns"))
-				patch_kickguns = !stricmp(value, "true");
+				patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "cooldowntimer"))
-				patch_cooldowntimer = !stricmp(value, "true");
+				patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "throwtest"))
-				patch_throwtest = !stricmp(value, "true");
+				patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "alttab"))
-				patch_alttab = !stricmp(value, "true");
+				patch_alttab = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "particledisablebit"))
-				patch_particledisablebit = !stricmp(value, "true");
+				patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "multibyte"))
-				patch_multibyte = !stricmp(value, "true");
+				patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "cheattable"))
-				patch_cheattable = !stricmp(value, "true");
+				patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "argb8888"))
-				patch_argb8888 = !stricmp(value, "true");
+				patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "safeprintf"))
-				patch_safeprintf = !stricmp(value, "true");
+				patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "daodandisplayenum"))
-				patch_daodandisplayenum = !stricmp(value, "true");
+				patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "usegettickcount"))
-				patch_usegettickcount = !stricmp(value, "true");
+				patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "cheatsenabled"))
-				patch_cheatsenabled = !stricmp(value, "true");
+				patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "usedaodangl"))
-				patch_usedaodangl = !stricmp(value, "true");
+				patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "windowhack"))
-				patch_windowhack = !stricmp(value, "true");
+				patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "daodaninit"))
-				patch_daodaninit = !stricmp(value, "true");
+				patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
 			else if (!stricmp(name, "bsl"))
-				patch_bsl = !stricmp(value, "true");
+				patch_bsl = !stricmp(inifile_cleanstr(value), "true");
 			else
 				DDrStartupMessage("unrecognised patch \"%s\"", name);
-			break;
-		case s_bsl:
-			
 			break;
 		case s_language:
@@ -358,4 +355,5 @@
 				DDrStartupMessage("unrecognised language item \"%s\"", name);
 			break;
+		case s_bsl:
 		default:
 			break;
Index: /Daodan/src/Daodan_BSL.c
===================================================================
--- /Daodan/src/Daodan_BSL.c	(revision 450)
+++ /Daodan/src/Daodan_BSL.c	(revision 451)
@@ -1,5 +1,8 @@
 #include <stdio.h>
+#include <stdbool.h>
 #include <time.h>
 #include <ffi.h>
+
+#include "inifile.h"
 
 #include "Daodan_BSL.h"
@@ -149,14 +152,14 @@
 		is_lsi = 1;
 	}
-	else if(!strcmp(args[1].value_str32,"bossshield")) 
-	{
-		ret->value_int32 = Chr[index].Flags & char_bossshield;
-		ret->type = sl_int32;
-		if (numargs >=3) {
-			if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
-			else Chr[index].Flags = Chr[index].Flags | char_bossshield;
-		}
-		return 0;
-	}
+//	else if(!strcmp(args[1].value_str32,"bossshield")) 
+//	{
+//		ret->value_int32 = Chr[index].Flags & char_bossshield;
+//		ret->type = sl_int32;
+//		if (numargs >=3) {
+//			if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
+//			else Chr[index].Flags = Chr[index].Flags | char_bossshield;
+//		}
+//		return 0;
+//	}
 	else return 1;
 	//todo, add setting
@@ -228,5 +231,5 @@
 	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
 	if ((int)Active == 0) return 1;
-	ret->value_int32 = Active->LastDamageSourceCharacter;
+//	ret->value_int32 = Active->LastDamageSourceCharacter;
 	ret->type = sl_int32;
 	return 0;
@@ -386,6 +389,98 @@
 }
 
+bool ini_inbsl = false;
+bool SLrIniCallback(char* section, bool newsection, char* name, char* value)
+{
+	if (newsection && !stricmp(section, "bsl"))
+		ini_inbsl = true;
+	
+	if (ini_inbsl)
+	{
+		bool isptr = false;
+		sl_type bsl_type;
+		
+		if (value[0] == 'p' && value[1] == 't' && value[2] == 'r' && value[3] == ':')
+		{
+			isptr = true;
+			value += 4;
+		}
+		
+		char* type = value;
+		
+		for (; *type; type++)
+			if (*type == ':')
+			{
+				*type = '\0';
+				type++;
+				break;
+			}
+		
+		if (!*type)
+			DDrStartupMessage("badly formed bsl definition for \"%s\"", name);
+		
+		if (!strcmp(type, "int"))
+			bsl_type = sl_int32;
+		else if (!strcmp(type, "string"))
+			bsl_type = sl_str32;
+		else if (!strcmp(type, "float"))
+			bsl_type = sl_float;
+		else if (!strcmp(type, "bool"))
+			bsl_type = sl_bool;
+		else
+		{
+			DDrStartupMessage("unknown type in bsl definition for \"%s\"", name);
+			return true;
+		}
+		
+		if (isptr)
+		{
+			char* bsl_var = malloc(strlen(name) + 1);
+			memcpy(bsl_var, name, strlen(name) + 1);
+			switch (bsl_type)
+			{
+				case sl_int32:
+					SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", (int32_t*)(uint32_t)inifile_parseint(value, false));
+					break;
+				case sl_float:
+					SLrGlobalVariable_Register_Float(bsl_var, "see daodan.ini", (float*)(uint32_t)inifile_parseint(value, false));
+					break;
+				default:
+					break;
+			}
+		}
+		else
+		{
+			char* bsl_var = malloc(strlen(name) + 1 + sizeof(int32_t));
+			int32_t* bsl_val = (int32_t*)bsl_var;
+			bsl_var += sizeof(int32_t);
+			memcpy(bsl_var, name, strlen(name) + 1);
+			
+			switch (bsl_type)
+			{
+				case sl_int32:
+					*bsl_val = inifile_parseint(value, false);
+					SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", bsl_val);
+					break;
+				case sl_float:
+					break;
+				default:
+					break;
+			}
+		}
+	}
+	return true;
+}
+
+void SLrConfig()
+{
+	DDrStartupMessage("re-parsing daodan.ini for bsl...");
+	inifile_read("daodan.ini", SLrIniCallback);
+	DDrStartupMessage("finished parsing");
+}
+
 void SLrDaodan_Initalize()
 {
+	SLrConfig();
+	
 	SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul);
 	SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul);
@@ -411,12 +506,10 @@
 	SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf);
 	SLrScript_Command_Register_ReturnType("dprintcolor", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
-
-
-
+	
 	SLrScript_Command_Register_ReturnType("d_dprint", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
 }
+
 void SLrDaodan_Patch()
 {
 	DDrPatch_Int32(OniExe + 0x000f3755, (int)cinematic_start_patch);
 }
-
Index: /Daodan/src/inifile.h
===================================================================
--- /Daodan/src/inifile.h	(revision 450)
+++ /Daodan/src/inifile.h	(revision 451)
@@ -4,4 +4,5 @@
 
 #include <stdbool.h>
+#include <stdint.h>
 
 enum {inifile_cantread = -20};
@@ -9,4 +10,6 @@
 typedef bool (*inifile_callback)(char* section, bool newsection, char* name, char* value);
 
+char* inifile_cleanstr(char* str);
+int64_t inifile_parseint(const char* str, bool issigned);
 bool inifile_read(const char* filename, inifile_callback callback);
 
Index: /Daodan/src/inifile_reader.c
===================================================================
--- /Daodan/src/inifile_reader.c	(revision 450)
+++ /Daodan/src/inifile_reader.c	(revision 451)
@@ -6,19 +6,76 @@
 
 #include "inifile.h"
-/*
+
 char* inifile_cleanstr(char* str)
 {
+	int i;
+	for (i = strlen(str) - 1; i >= 0; i --)
+		if (!isspace(str[i]))
+		{
+			str[i + 1] = '\0';
+			break;
+		}
+	
 	while (isspace(*str))
 		str++;
 	
-	int i;
-	for (i = 0; str[i]; i ++)
-	{
-		if 
-	}
-	
 	return str;
 }
-*/
+
+int64_t inifile_parseint(const char* str, bool issigned)
+{
+	int64_t ret = 0;
+	bool neg = false;
+	if (str[0] == '0' && str[1] == 'x')
+	{
+		int i;
+		if (str[2] == '\0')
+			return 0x100000000LL;
+		
+		for (i = 0, str += 2; *str; i++, str++)
+		{
+			if (i == 8)
+				return 0x100000000LL;
+			
+			ret <<= 4;
+			if (*str >= '0' && *str <= '9')
+				ret |= *str - '0';
+			else if (*str >= 'a' && *str <= 'f')
+				ret |= *str - 'a' + 10;
+			else if (*str >= 'A' && *str <= 'F')
+				ret |= *str - 'A' + 10;
+			else
+				return 0x100000000LL;
+		}
+		return ret;
+	}
+	else if ((*str >= '0' && *str <= '9') || (neg = (*str == '-')))
+	{
+		int i;
+		if (neg)
+			str++;
+		for (i = 0; *str; i++, str++)
+		{
+			if (i == 10)
+				return 0x100000000LL;
+			else if (i == 9 && !issigned && (ret > 429496729LL || (ret == 429496729LL && *str > '5')))
+				return 0x100000000LL;
+			else if (i == 9 && issigned && (ret > 214748364LL || (ret == 214748364LL && *str > (neg ? '8' : '7'))))
+				return 0x100000000LL;
+			
+			ret *= 10;
+			if (*str >= '0' && *str <= '9')
+				ret += *str - '0';
+			else
+				return 0x100000000LL;
+		}
+		if (neg)
+			ret *= -1;
+		return ret;
+	}
+	else
+		return 0x100000000LL;
+}
+
 bool inifile_read(const char* filename, inifile_callback callback)
 {
Index: /Daodan/src/inifile_test.c
===================================================================
--- /Daodan/src/inifile_test.c	(revision 450)
+++ /Daodan/src/inifile_test.c	(revision 451)
@@ -1,4 +1,5 @@
 #include <stdio.h>
 #include <stdbool.h>
+#include <string.h>
 #include "inifile.h"
 
@@ -8,4 +9,10 @@
 		puts("New Section!");
 	printf("Section: %s Name: %s Value: %s\n", section, name, value);
+	if (!stricmp(name, "cleantest"))
+		printf("  CleanTest: \"%s\" = \"%s\"\n", value, inifile_cleanstr(value));
+	if (!stricmp(name, "inttest"))
+		printf("  IntTest: %s = %u\n", value, (uint32_t)inifile_parseint(value, false));
+	if (!stricmp(name, "sinttest"))
+		printf("  IntTest: %s = %d\n", value, (int32_t)inifile_parseint(value, true));
 	return true;
 }
Index: odan/src/testini.ini
===================================================================
--- /Daodan/src/testini.ini	(revision 450)
+++ 	(revision )
@@ -1,13 +1,0 @@
-  # Test comment
-
-test1=hi
-
-[TestA]
-test2=lol hi
-test3=this is test2
-test4=
-   test5=sup
-
-!This is test B
-      [Test B]
-test6=test B is awesome
