$Game::CommonVersion = 114;
function initializeCommon ()
{//echo("initializeCommon()");
	// Common keybindings.
	GlobalActionMap.bind(keyboard, $Game::ScreenshotBind, doScreenShot);
	GlobalActionMap.bindcmd(keyboard, $Game::FullscreenBind, "toggleFullScreen();","");
	
	// Very basic functions used by everyone.
	exec("./audio.cs");
	exec("./canvas.cs");
	exec("./cursor.cs");
	
	// Seed the random number generator.
	setRandomSeed();
	
	// Set up networking.
	if ($Game::UsesNetwork)
	{
		setNetPort(0);
    }
	
	// Spit out operating system.
	echo("--------------------------------------------------------------------------------");
	echo("Operating System:\n  " @ $platform);
	echo("");
	
	// Initialize the canvas.
	initializeCanvas($Game::ProductName);
   
	// Start up the audio system.
	if ($Game::UsesAudio)
	{
		initializeOpenAL();
	}
	
	// Content.
	//exec("../scripts/profiles.cs");
	exec("../scripts/cursors.cs");
	
	// Common GUIs.
	exec("../gui/messageBoxYesNo.gui");
	exec("../gui/messageBoxOKCancel.gui");
	exec("../gui/options.gui");
	exec("../gui/remap.gui");
	
	// Gui Helper Scripts.
	exec("../scripts/messageBox.cs");
	exec("../scripts/help.cs");
	
	// Chat gui
	exec("../gui/chatGui.gui");
	
	// Random Scripts.
	exec("./screenshot.cs");
	exec("./metrics.cs");
	exec("./scriptDoc.cs");
	exec("./keybindings.cs");
	exec("./options.cs");
	exec("./levelManagement.cs");
	exec("./projectManagement.cs");
	exec("./projectResources.cs");
	exec("./align.cs");
	
	// Load client and server scripts.
	if ($Game::UsesNetwork)
	{
		initBaseClient();
		initBaseServer();
	}
	
	exec("./input.cs");		// Need this for function loadKeybindings()!
	loadKeybindings();
	$commonInitialized = true;
}
function _shutdownCommon ()
{
	if (isFunction("shutdownProject"))
	{
		shutdownProject();
    }  
	shutdownOpenAL();
}
function dumpKeybindings ()
{
	for (%i = 0; %i < $keybindCount; %i++)
	{
		if (isObject($keybindMap[%i]))
		{
			$keybindMap[%i].save("~/prefs/bind.cs", %i == 0 ? false : true);
			$keybindMap[%i].delete();
		}
	}
}
function initBaseClient ()
{
	exec("./client/client.cs");
	exec("./client/message.cs");
	exec("./client/serverConnection.cs");
	exec("./client/chatClient.cs");
}
function initBaseServer ()
{
	exec("./server/server.cs");
	exec("./server/message.cs");
	exec("./server/clientConnection.cs");
	exec("./server/kickban.cs");
	exec("./server/chatServer.cs");
}
function loadDir (%dir)
{
	setModPaths(getModPaths() @ ";" @ %dir);
	exec(%dir @ "/main.cs");	// Execute Boot-strap file.
}
function mRound (%num)
{
	if ((%num-mFloor(%num)) >= 0.5)
	{
		%value = mCeil(%num);
	}
	else
	{
		%value = mFloor(%num);
	}    
	return %value;
}
function expandFilename (%fileName)
{//echo("expandFilename()");
	%fileName = "^" @ %fileName;
}