Index: Daodan/MSVC/Daodan.c
===================================================================
--- Daodan/MSVC/Daodan.c	(revision 568)
+++ Daodan/MSVC/Daodan.c	(revision 569)
@@ -83,6 +83,10 @@
 	if (patch_pathfinding)
 	{
+		const char pathfinding[2] = {0x90 , 0xE9 };
 		DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
 		DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20);
+
+		//other stuff
+		DDrPatch_Const(0x440789, pathfinding);
 	}
 	
@@ -99,5 +103,5 @@
 	if (patch_directinput)
 		DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
-	
+
 	if (patch_wpfadetime)
 	{
@@ -111,4 +115,9 @@
 	}
 	
+	// FIXME: add switches
+	//pathfinding fix
+
+	
+
 	
 	// Hackish fix for Konoko not kicking guns
@@ -208,4 +217,24 @@
 		DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
 	
+	if (patch_bsl)
+	{
+		//Calculating the value of the needed offset is much more reliable when the compiler does it for you.
+
+		//TODO: fix moonshadow.
+		Character * Chr = 0;
+		int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
+		const char regen_patch[] =
+		{0x90, 0x90, 0x90, 0x90, 0x90,				// mov    al, _WPgRegenerationCheat	-> NOOP
+		0x90, 0x90,									// test   al, al					-> NOOP
+		0x90, 0x90,									// jz	  short loc_51BB98			-> NOOP
+		0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov     eax, [esi+Character.field_1E8]
+													//	-> mov     eax, [esi+Character.RegenHax]
+		0x85, 0xC0,									// test eax, eax
+		0x74, 0x21									// jnz 0x21 -> jz 0x21
+		};	
+		DDrPatch_Const(0x0051BB64, regen_patch);
+	}
+
+
 	return true;
 }
@@ -562,16 +591,21 @@
 	if (patch_cheatsenabled)
 		DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
-#if 0
+//#if 0
 	// Windowed mode
-	if (patch_usedaodangl)
-	{
+//	if (patch_usedaodangl)
+	{
+	DDrPatch_NOOP((char*)0x004032B7, 6);
+	DDrPatch_MakeCall((char*)0x004032B7, LIiP_SetCursorPosHook);
+	
+	DDrPatch_NOOP((char*)0x00403349, 6);
+	DDrPatch_MakeCall((char*)0x00403349, LIiP_SetCursorPosHook);
 		DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
 		DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
 	}
-#endif
+//#endif
 	// Hacked windowed mode (for when daodangl isn't working properly)
 	//if (patch_windowhack)
 
-		DDrWindowHack_Install();
+	//	DDrWindowHack_Install();
 	
 	if (patch_daodaninit)
Index: Daodan/MSVC/Daodan_BSL.c
===================================================================
--- Daodan/MSVC/Daodan_BSL.c	(revision 568)
+++ Daodan/MSVC/Daodan_BSL.c	(revision 569)
@@ -553,9 +553,21 @@
 //	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
 //	if ((int)Active == 0) return 1;
+
 	int i = 2;
 	int j = 0;
 	int Input1 = 0;
 	int Input2 = 0;
-	for(i = 0; i < numargs; i++) {
+/*
+	numargs = 0;
+	for(i = 0; args[i].type <= sl_void; i++)
+	{
+		//DDrConsole_PrintF("%i", args[i].type );
+		numargs++;
+
+	}
+	if(numargs < 1 || args[0].value == 0)  return;
+	//for(i = 0; i < numargs; i++) {
+	*/
+	i = 0;
 		for(j = 0; j < 32; j++) {
 			//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit);
@@ -570,10 +582,12 @@
 	
 		}
-		}
-	//DDrConsole_PrintF("Waiting...");
+	//	}
+	DDrConsole_PrintF("Waiting...");
 	if ( 
 		(( ONgGameState->Input.Current.Actions1 & Input1) == Input1)  && 
 		(( ONgGameState->Input.Current.Actions2 & Input2) == Input2) 
-	){
+	)
+	{
+	DDrConsole_PrintF("Found key!");
 	}
 	else {
@@ -582,43 +596,94 @@
 	*dontuse1 = 1;
 	}
-/*
-	__asm__(
-		"movl 0x10(%esp), %edx\n\t"
-		"movl    $1,(%eax)\n\t"
-		);
-	//ret->type = sl_void
-*/	return 0;
-}
-
+	return 0;
+}
+
+
+uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	char output[1024];
+	char buffer[1024];
+	int i;
+	char* placeinoutput = output;
+	char* placeininput = args[0].value_str32;
+	int formatnum = 0;
+	//fix the broken bsl numargs...
+	numargs = 0;
+	
+	for(i = 0; args[i].type < sl_void; i++)
+	{
+		numargs++;
+	}
+	
+	
+	if (numargs < 1)
+		return 1;
+	
+	while(1)
+	{
+		int size;
+		//s is the pointer to the args
+		char* s = strchr(placeininput , '%');
+		//we didnt find a %, break!
+		if(!s)
+		{
+			strcpy(placeinoutput, placeininput);
+			break;
+		}
+		size = (int)s - (int)placeininput ;
+		//we found one, so copy the portion of string
+		
+
+		
+		memcpy( placeinoutput,placeininput, size);
+		placeininput += size;
+		placeinoutput += size;
+
+		memset( placeinoutput, '%', (int)pow(2, formatnum));
+		placeinoutput += (int)pow(2, formatnum);
+
+
+		placeininput += 1;
+		*placeinoutput = 0;
+		formatnum++;
+		
+	}
+	//strcpy( output, args[0].value_str32 );
+
+	for(i = 1; i < numargs; i++)	{
+		//sprintf(output, output, args[i].value_str32);
+		memcpy(buffer, output, 1024);
+		if(args[i].value == 0) break;
+		switch(args[i].type)
+		{
+		case sl_bool:
+		case sl_int32:
+			sprintf(output, buffer, args[i].value_int32);
+			break;
+		case sl_float:
+			//crashes oni, why?
+		//	sprintf(output, output, args[i].value_float);
+			break;
+		case sl_str32:
+			sprintf(output, buffer, args[i].value_str32);
+			break;
+		case sl_void:
+		default:
+			break;
+		}	
+	}
+	//output[32] = 0;
+	ret->value_str32 = output;
+	ret->type = sl_str32;
+	return 0;
+}
+
+//Sorry rossy, I broke this. FFI isnt in windows
 /*
 uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
 {
-	if (numargs < 2)
-		return 1;
-	
-	char output[255];
-	int i;
-	for(i = 1; i < numargs; i++)	{
-		sprintf(output, args[0].value_str32, args[i].value_str32);
-	}
-	
-	ret->value_str32 = output;
-	ret->type = sl_str32;
-	return 0;
-}
-*/
-/*
-uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	if (numargs < 1 || args[0].type != sl_str32)
-	{
-		DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": parameter list does not match: format:string arg1 arg2 ...", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name);
-		return 0;
-	}
-	
-	if (!args[0].value_str32)
-		args[0].value_str32 = "";
-	
-	int ffi_ret;
+	
+	
+		int ffi_ret;
 	char* str = NULL;
 	int size = 0;
@@ -627,4 +692,23 @@
 	ffi_type* ffi_args[256];
 	void* values[256];
+	int i;
+		numargs = 0;
+	for(i = 0; args[i].type <= sl_void; i++)
+	{
+		//DDrConsole_PrintF("%i", args[i].type );
+		numargs++;
+
+	}
+
+	if (numargs < 1 || args[0].type != sl_str32)
+	{
+		DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": parameter list does not match: format:string arg1 arg2 ...", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name);
+		return 0;
+	}
+	
+	if (!args[0].value_str32)
+		args[0].value_str32 = "";
+	
+	
 	
 	ffi_args[0] = &ffi_type_pointer;
@@ -633,5 +717,5 @@
 	values[1] = &size;
 	
-	int i;
+
 	for(i = 2; i < numargs + 2; i ++)
 	{
@@ -654,8 +738,8 @@
 	if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK)
 		return 1;
-	ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values);
+	ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values);
 	str = malloc(ffi_ret + 1);
 	size = ffi_ret + 1;
-	ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values);
+	ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values);
 	ret->value_str32 = str;
 	ret->type = sl_str32;
@@ -777,5 +861,4 @@
 	void* TSFFTahoma;
 	int returnval;
-	
 	TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
 	returnval = TSrContext_New( TSFFTahoma, 7, 1, 1,  0, &TSrTest);
@@ -785,20 +868,4 @@
 void SLrDaodan_Initalize()
 {
-	//Calculating the value of the needed offset is much more reliable when the compiler does it for you.
-
-	//TODO: fix moonshadow.
-	Character * Chr = 0;
-	
-	int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
-
-	
-
-	const char regen_patch[] =
-		{0x90, 0x90, 0x90, 0x90, 0x90,	// mov     al, _WPgRegenerationCheat
-		0x90, 0x90,						// test    al, al
-		0x90, 0x90,						// jz      short loc_51BB98
-		0x8B, 0x86, (char)NoPath, 0x01};	
-	DDrPatch_Const(OniExe + 0x0011BB64, regen_patch);
-
  	SLrConfig();
 
@@ -824,5 +891,5 @@
 	SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "ai_name:string | script_id:int xyz:string [newlocation:float]", sl_float, bsl_location);
 	SLrScript_Command_Register_ReturnType("d_distance","Returns the distance between two characters", "ai_name:string | script_id:int ai_name:string | script_id:int", sl_float, bsl_distance);
-	SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "keys", bsl_waitforkey);
+	SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey);
 
 	//broken, only works for one damage type.
@@ -832,6 +899,5 @@
 //	SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset);
 
-	//SLrDaodan_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf);
-	
+	SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf);
 	SLrScript_Command_Register_ReturnType("st", "prints to console in color", "text:string color1:int color2:int", sl_void, bsl_dprintcolored);
 	
Index: Daodan/MSVC/Daodan_Cheater.c
===================================================================
--- Daodan/MSVC/Daodan_Cheater.c	(revision 568)
+++ Daodan/MSVC/Daodan_Cheater.c	(revision 569)
@@ -95,5 +95,5 @@
 float cheat_oldheight2 = 135;
 bool inc_fallingframes = true;
-
+extern bool patch_bsl;
 uint8_t ONICALL DDrCheater(uint32_t cheat)
 {
@@ -250,4 +250,25 @@
 			return 1;
 		}
+		case cheat_elderrune:
+		{
+			if(patch_bsl) {
+				int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax;
+				if(*Regeneration)
+				{
+					*Regeneration = 0;
+					return 0;
+				}
+				else
+				{
+					*Regeneration = 1;
+					return 1;
+				}
+			}
+			else
+			{
+				return ONrCheater(cheat_elderrune);
+			}
+		}
+
 		case cheat_tellmetheversion:
 			return 1;
Index: Daodan/MSVC/Daodan_Win32.c
===================================================================
--- Daodan/MSVC/Daodan_Win32.c	(revision 568)
+++ Daodan/MSVC/Daodan_Win32.c	(revision 569)
@@ -7,5 +7,5 @@
 
 #include "Oni.h"
-
+extern HWND onihwnd;
 short ONICALL DDrPlatform_Initialize(ONtPlatformData *PlatformData)
 {
@@ -13,4 +13,5 @@
 	RECT Rect;
 	const int Width = 640, Height = 480;
+	HINSTANCE temp_Instance = PlatformData->Instance;
 
 	PlatformData->Instance = g_Instance;
@@ -22,6 +23,6 @@
 	WndClass.hInstance = PlatformData->Instance;
 	WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
-	WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
-	WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+	WndClass.hIcon = LoadIcon(g_Instance, MAKEINTRESOURCE(103) );
+	WndClass.hIconSm = LoadIcon(g_Instance, MAKEINTRESOURCE(103));
 	WndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
 	WndClass.lpszMenuName = NULL;
@@ -36,6 +37,6 @@
 	Rect.bottom = Rect.top + Height;
 	AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_TILEDWINDOW , FALSE);
-	PlatformData->Window = CreateWindowEx(0, "ONI ", "ONI ", WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_OVERLAPPED, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, NULL, NULL, PlatformData->Instance, NULL);
-	
+	PlatformData->Window = CreateWindowEx(0, "ONI ", "ONI ",  WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_TILEDWINDOW, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, NULL, NULL, PlatformData->Instance, NULL);
+	onihwnd = PlatformData->Window;
 	ShowWindow(PlatformData->Window, SW_SHOWNORMAL);
 	UpdateWindow(PlatformData->Window);
@@ -45,5 +46,5 @@
 	// I dont know why this is needed but Oni doesn't init without it.
 	ONgPlatformData.Window = PlatformData->Window;
-	//ONgPlatformData.Instance = PlatformData->Instance;
+	ONgPlatformData.Instance = PlatformData->Instance;
 	
 	return 0;
Index: Daodan/MSVC/Daodan_WindowHack.h
===================================================================
--- Daodan/MSVC/Daodan_WindowHack.h	(revision 568)
+++ Daodan/MSVC/Daodan_WindowHack.h	(revision 569)
@@ -4,4 +4,6 @@
 
 void DDrWindowHack_Install();
+BOOL WINAPI LIiP_GetCursorPosHook(LPPOINT lpPoint);
+BOOL WINAPI LIiP_SetCursorPosHook(int X, int Y);
 
 #endif
Index: Daodan/MSVC/Flatline.c
===================================================================
--- Daodan/MSVC/Flatline.c	(revision 568)
+++ Daodan/MSVC/Flatline.c	(revision 569)
@@ -219,4 +219,5 @@
 	return NetUDPServer_Listen(27777, FLrServer_PacketCallback);
 }
+
 
 	RGBA green = {0, 0xFF, 0, 0};
@@ -511,5 +512,5 @@
 {
 	uint16_t i;
-	/*DDrConsole_PrintF("Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x", 
+		/*DDrConsole_PrintF("Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x", 
 		ONgGameState->Input.Current.Actions1, ONgGameState->Input.Current.Actions2,
 		ONgGameState->Input.Start.Actions1,ONgGameState->Input.Start.Actions2,
@@ -519,5 +520,19 @@
 	*/	
 	ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters;
-	
+	Active_Player->PhyContext->Rotation;
+	Active_Player->PhyContext->Position;
+	ONgGameState->PlayerCharacter->Position;
+
+ 
+	
+	/*
+	if( ONgGameState->Input.MouseDeltaX != 0 || ONgGameState->Input.MouseDeltaY != 0 ||
+		ONgGameState->Input.field_8 != 0 || ONgGameState->Input.field_C != 0 )
+
+	DDrConsole_PrintF("%f %f | %f %f",
+		ONgGameState->Input.MouseDeltaX , ONgGameState->Input.MouseDeltaY,
+		ONgGameState->Input.field_8, ONgGameState->Input.field_C);
+
+		*/
 	//if sprint timer is equal to 0, display 0
 	//else if sprint timer is equal to -1, display -1
@@ -565,4 +580,7 @@
 			player_data * data;
 			flatline_packet data_out = {0};
+
+			//if( PlayerList[i]->Chr->Health == 0) PlayerList[i]->Chr->Health = PlayerList[i]->Chr->MaxHealth;
+
 			data_out.id = PLAYER_DATA;
 			data = (void*)&(data_out.data);
@@ -576,4 +594,6 @@
 			data->DesiredFacing = PlayerList[i]->Chr->DesiredFacing;
 			data->CosmeticFacing = PlayerList[i]->Chr->CosmeticFacing;
+
+
 			data->Position = Active_Player->PhyContext->Position;
 			
@@ -614,8 +634,12 @@
 				data->Inputs.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1;
 				data->Inputs.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2;
+				data->Inputs.MouseDeltaX = ONgGameState->Input.MouseDeltaX;
+				data->Inputs.MouseDeltaY = ONgGameState->Input.MouseDeltaY;
 			}
 			else{
 				data->Inputs.Actions1 = PlayerList[i]->Actions1;
 				data->Inputs.Actions2 = PlayerList[i]->Actions2;
+				data->Inputs.MouseDeltaX = PlayerList[i]->MouseDeltaX;
+				data->Inputs.MouseDeltaY = PlayerList[i]->MouseDeltaY;
 			}
 			memcpy( &(PlayerList[i]->player_data), data, sizeof(player_data) );
@@ -626,7 +650,5 @@
 		if( (server_started && i !=0)  || (!server_started/* && i != client_slot*/) ) 
 		{
-			//this just made sync even worse....maybe keystrokes are actually _behind_
-			//
-			//
+			//this just made sync even worse...
 #ifdef JITTER_FIX
 			input_struct * New_Input = &PlayerList[i]->MouseDeltaX;
@@ -656,5 +678,5 @@
 			Active_Input->MouseDeltaX = PlayerList[i]->MouseDeltaX;
 			Active_Input->MouseDeltaY = PlayerList[i]->MouseDeltaY;
-			DDrConsole_PrintF("Timer: %i", (Active_Player->SprintTimer != 0) ? (Active_Player->SprintTimer == -1) ? -1 : (ONgGameState->GameTime - Active_Player->SprintTimer) : 0);
+			//DDrConsole_PrintF("Timer: %i", (Active_Player->SprintTimer != 0) ? (Active_Player->SprintTimer == -1) ? -1 : (ONgGameState->GameTime - Active_Player->SprintTimer) : 0);
 
 			//DDrConsole_PrintF("1E8 %u", ONgGameState->PlayerCharacter->field_1E8);
@@ -693,17 +715,4 @@
 	}
 
-	//Make the current controls match the sent controls, now that we have sent them off and everything is synced.
-	//No, don't do it to the direct input, it breaks stuff.
-	//Need to disable the function that puts game input onto characters because we are doing it directly.
-	/*
-	if( !server_started )
-	{
-		ONgGameState->Input.MouseDeltaX = PlayerList[client_slot]->MouseDeltaX;
-		ONgGameState->Input.MouseDeltaY = PlayerList[client_slot]->MouseDeltaY;
-		ONgGameState->Input.Current.Actions1 = PlayerList[client_slot]->Actions1;
-		ONgGameState->Input.Current.Actions2 = PlayerList[client_slot]->Actions2;
-	}
-	*/
-	
 	return ONgGameState;
 }
Index: Daodan/MSVC/Flatline_BSL.c
===================================================================
--- Daodan/MSVC/Flatline_BSL.c	(revision 568)
+++ Daodan/MSVC/Flatline_BSL.c	(revision 569)
@@ -114,4 +114,5 @@
 	return 0;
 }
+
 uint16_t ONICALL addfake(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
 {
@@ -121,4 +122,19 @@
 return 0;
 }
+
+uint16_t ONICALL list_players(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int i;
+	for(i = 0; i++; i < MAX_PLAYERS)
+	{
+		if(PlayerList[i])
+		{
+			DDrConsole_PrintF("%i %i | %s", i, PlayerList[i]->spawnnumber, PlayerList[i]->name);
+		}
+	}
+return 0;
+}
+
+
 void SLrFlatline_Initialize() {
 	
Index: Daodan/MSVC/Oni_Symbols.c
===================================================================
--- Daodan/MSVC/Oni_Symbols.c	(revision 568)
+++ Daodan/MSVC/Oni_Symbols.c	(revision 569)
@@ -170,5 +170,5 @@
 DefVar( onibool,		ai2_deaf,				0x005ec0c1 );
 
-DefVar(	HINSTANCE,		g_Instance,				0x0051f9e4 );
+DefVar(	HINSTANCE,		g_Instance,				0x0061F9E4 );
 
 DefVar( gl_api_t*,		gl_api,					0x00560604 );
