Changed: #ifdef'd windows only stuff that's waiting for abstraction
~g2k
This commit is contained in:
		| @@ -32,12 +32,6 @@ using namespace std; | |||||||
|  |  | ||||||
| LEVEL::LEVEL() | LEVEL::LEVEL() | ||||||
| { | { | ||||||
| /* |  | ||||||
| 	consoleHistory[0] = "hello0"; |  | ||||||
| 	consoleHistory[1] = "hello1"; |  | ||||||
| 	consoleHistory[MAX_CONSOLE_HISTORY_LINES-2] = "hello3"; |  | ||||||
| 	consoleHistory[MAX_CONSOLE_HISTORY_LINES-1] = "hello4"; |  | ||||||
| */ |  | ||||||
| 	textureNames = NULL; | 	textureNames = NULL; | ||||||
| 	numTextures = 0; | 	numTextures = 0; | ||||||
| 	textures = NULL; | 	textures = NULL; | ||||||
| @@ -62,7 +56,7 @@ LEVEL::LEVEL() | |||||||
| 	//Player Stuff | 	//Player Stuff | ||||||
| 	mouseSpeed = 5; | 	mouseSpeed = 5; | ||||||
| 	turnSpeed = 1.0f; | 	turnSpeed = 1.0f; | ||||||
| 	moveSpeed = .2f; | 	moveSpeed = 0.2f; | ||||||
| 	mlook = true; | 	mlook = true; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -96,7 +90,10 @@ bool LEVEL::LoadMap(string mapname) | |||||||
| 		strcat(tmpChar, mapname.c_str()); | 		strcat(tmpChar, mapname.c_str()); | ||||||
| 		strcat(tmpChar, " doesn't exist."); | 		strcat(tmpChar, " doesn't exist."); | ||||||
| 		 | 		 | ||||||
|  | 		//This needs to be abstracted somehow | ||||||
|  | 		#ifdef WIN32 | ||||||
| 		MessageBox(NULL,tmpChar,"ERROR",MB_OK|MB_ICONEXCLAMATION); | 		MessageBox(NULL,tmpChar,"ERROR",MB_OK|MB_ICONEXCLAMATION); | ||||||
|  | 		#endif | ||||||
| 		delete [] tmpChar; | 		delete [] tmpChar; | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| @@ -174,9 +171,12 @@ bool LEVEL::LoadMap(string mapname) | |||||||
| 	{ | 	{ | ||||||
| 		ConsolePrint("Starting sound"); | 		ConsolePrint("Starting sound"); | ||||||
|  |  | ||||||
|  | 		//This needs to be abstracted somehow | ||||||
|  | 		#ifdef WIN32 | ||||||
| 		BASS_Init(-1, 44100, BASS_DEVICE_LEAVEVOL, g_hWnd); | 		BASS_Init(-1, 44100, BASS_DEVICE_LEAVEVOL, g_hWnd); | ||||||
| 		BASS_Start(); | 		BASS_Start(); | ||||||
| 		BASS_CDInit(NULL, BASS_DEVICE_LEAVEVOL); | 		BASS_CDInit(NULL, BASS_DEVICE_LEAVEVOL); | ||||||
|  | 		#endif | ||||||
| 		 | 		 | ||||||
| 		if(bgm.length()>=4) | 		if(bgm.length()>=4) | ||||||
| 		{ | 		{ | ||||||
| @@ -185,19 +185,29 @@ bool LEVEL::LoadMap(string mapname) | |||||||
| 				toupper(bgm[2]) == 'A') | 				toupper(bgm[2]) == 'A') | ||||||
| 			{ | 			{ | ||||||
| 				bgmCDA = Integer(bgm.substr(3,bgm.length())); | 				bgmCDA = Integer(bgm.substr(3,bgm.length())); | ||||||
|  | 				//This needs to be abstracted somehow | ||||||
|  | 				#ifdef WIN32 | ||||||
| 				BASS_CDPlay(bgmCDA, 1, 0); | 				BASS_CDPlay(bgmCDA, 1, 0); | ||||||
|  | 				#endif | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				bgmCDA=0; | 				bgmCDA=0; | ||||||
| 				string tmpstr = gamedir + "music/bgm/" + bgm; | 				string tmpstr = gamedir + "music/bgm/" + bgm; | ||||||
|  | 				//This needs to be abstracted somehow | ||||||
|  | 				#ifdef WIN32 | ||||||
| 				bgmStream = BASS_StreamCreateFile(0, (void*)tmpstr.c_str(), 0, 0, BASS_STREAM_AUTOFREE); | 				bgmStream = BASS_StreamCreateFile(0, (void*)tmpstr.c_str(), 0, 0, BASS_STREAM_AUTOFREE); | ||||||
| 				BASS_StreamPlay(bgmStream, 1, BASS_SAMPLE_LOOP);					 | 				BASS_StreamPlay(bgmStream, 1, BASS_SAMPLE_LOOP);					 | ||||||
|  | 				#endif | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		ConsolePrint("Sound init complete"); | 		ConsolePrint("Sound init complete"); | ||||||
| 	} | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
|  | 		ConsolePrint("Sound disabled"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| @@ -224,7 +234,10 @@ void LEVEL::SaveMap(string mapname) | |||||||
| 		strcat(tmpChar, mapname.c_str()); | 		strcat(tmpChar, mapname.c_str()); | ||||||
| 		strcat(tmpChar, " already exists."); | 		strcat(tmpChar, " already exists."); | ||||||
|  |  | ||||||
|  | 		//This needs to be abstracted somehow | ||||||
|  | 		#ifdef WIN32 | ||||||
| 		MessageBox(NULL,tmpChar,"ERROR",MB_OK|MB_ICONEXCLAMATION); | 		MessageBox(NULL,tmpChar,"ERROR",MB_OK|MB_ICONEXCLAMATION); | ||||||
|  | 		#endif | ||||||
| 		delete [] tmpChar; | 		delete [] tmpChar; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -359,7 +372,8 @@ void LEVEL::Render() | |||||||
|  |  | ||||||
| 		//render the console background | 		//render the console background | ||||||
| 		//render the console output text | 		//render the console output text | ||||||
| 		for(unsigned int i=0; i<MAX_CONSOLE_LINES-1; i++) | 		unsigned int i; | ||||||
|  | 		for(i=0; i<MAX_CONSOLE_LINES-1; i++) | ||||||
| 		{ | 		{ | ||||||
| 			Print(30, glFont.ScreenHeight() - i*20, consoleOutput[MAX_CONSOLE_LINES-i-2].c_str(), 0); | 			Print(30, glFont.ScreenHeight() - i*20, consoleOutput[MAX_CONSOLE_LINES-i-2].c_str(), 0); | ||||||
| 		} | 		} | ||||||
| @@ -379,25 +393,31 @@ void LEVEL::Render() | |||||||
| void LEVEL::UnloadMap() | void LEVEL::UnloadMap() | ||||||
| { | { | ||||||
| 	//Stop audio | 	//Stop audio | ||||||
|  | 	//This needs to be abstracted somehow | ||||||
|  | 	#ifdef WIN32 | ||||||
| 	BASS_StreamFree(bgmStream); | 	BASS_StreamFree(bgmStream); | ||||||
| 	BASS_Stop(); | 	BASS_Stop(); | ||||||
| 	BASS_CDFree(); | 	BASS_CDFree(); | ||||||
| 	BASS_Free(); | 	BASS_Free(); | ||||||
|  | 	#endif | ||||||
| 	 | 	 | ||||||
| 	//Delete display list | 	//Delete display list | ||||||
| 	 | 	 | ||||||
|  | 	//Free all polygon data | ||||||
| 	if(triangles) | 	if(triangles) | ||||||
| 	{ | 	{ | ||||||
| 		delete [] triangles; | 		delete [] triangles; | ||||||
| 		triangles = NULL; | 		triangles = NULL; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	//Free all map textures | ||||||
| 	if(textures) | 	if(textures) | ||||||
| 	{ | 	{ | ||||||
| 		delete [] textures; | 		delete [] textures; | ||||||
| 		textures = NULL; | 		textures = NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	//Free the array of texture names | ||||||
| 	if (textureNames) | 	if (textureNames) | ||||||
| 	{ | 	{ | ||||||
| 		delete [] textureNames; | 		delete [] textureNames; | ||||||
| @@ -440,7 +460,12 @@ uint32 LEVEL::FPS() | |||||||
| 	static uint32 fps2=0; | 	static uint32 fps2=0; | ||||||
| 	static float last=0.0f;  // might need to change to double | 	static float last=0.0f;  // might need to change to double | ||||||
|  |  | ||||||
|  | 	//hmmm what the hell is this called in linux I should possibly abstract this | ||||||
|  | 	#ifdef WIN32 | ||||||
| 	float time=GetTickCount()*.001f; | 	float time=GetTickCount()*.001f; | ||||||
|  | 	#else | ||||||
|  | 	float time = 0; | ||||||
|  | 	#endif | ||||||
|  |  | ||||||
| 	++fps; | 	++fps; | ||||||
|  |  | ||||||
| @@ -744,7 +769,11 @@ void LEVEL::Execute(string cmd) | |||||||
| 		*/ | 		*/ | ||||||
| 		else if(command == "quit") | 		else if(command == "quit") | ||||||
| 		{ | 		{ | ||||||
|  | 			//This needs to be abstracted somehow | ||||||
|  | 			#ifdef WIN32 | ||||||
| 			PostQuitMessage(0); | 			PostQuitMessage(0); | ||||||
|  | 			#endif | ||||||
|  | 			 | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| @@ -753,7 +782,7 @@ void LEVEL::Execute(string cmd) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| void LEVEL::ParseCmds(LPSTR lpCmdLine) | void LEVEL::ParseCmds(const char* lpCmdLine) | ||||||
| { | { | ||||||
| 	string cmd = lpCmdLine; | 	string cmd = lpCmdLine; | ||||||
| 	string command; | 	string command; | ||||||
| @@ -1164,7 +1193,7 @@ void LEVEL::UpdateConsole(char newChar) | |||||||
| 		Execute(tolower(consoleHistory[1])); | 		Execute(tolower(consoleHistory[1])); | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	else if(newChar == VK_BACK) | 	else if(newChar == KEY_BACK) | ||||||
| 	{ | 	{ | ||||||
| 		consoleHistory[0] = Left(consoleHistory[0], consoleHistory[0].length()-1); | 		consoleHistory[0] = Left(consoleHistory[0], consoleHistory[0].length()-1); | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user