コード例 #1
0
void LTProfileUtils::ReadString(const wchar_t* pszSectionName, 
								const wchar_t* pszKeyName,
								const wchar_t* pszDefaultValue,
								wchar_t*	     pszValueString,
								uint32	     nValueStringBufferSize,
								const wchar_t* pszFileName)
{
	// get ANSI versions of strings
	char pszSectionNameANSI[MAX_PATH];
	LTStrCpy(pszSectionNameANSI, MPW2A(pszSectionName).c_str(), MAX_PATH);
	
	char pszKeyNameANSI[MAX_PATH];
	LTStrCpy(pszKeyNameANSI, MPW2A(pszKeyName).c_str(), MAX_PATH);
	
	char pszDefaultValueANSI[MAX_PATH];
	LTStrCpy(pszDefaultValueANSI, MPW2A(pszDefaultValue).c_str(), MAX_PATH);
	
	char pszFileNameANSI[MAX_PATH];
	LTStrCpy(pszFileNameANSI, MPW2A(pszFileName).c_str(), MAX_PATH);
	
	char* pszValueStringANSI = NULL;
	LT_MEM_TRACK_ALLOC(pszValueStringANSI = new char[nValueStringBufferSize], LT_MEM_TYPE_MISC);
	
	// call ANSI version
	ReadString(pszSectionNameANSI, pszKeyNameANSI, pszDefaultValueANSI, pszValueStringANSI, nValueStringBufferSize, pszFileNameANSI);
	
	// convert output value
	LTStrCpy(pszValueString, MPA2W(pszValueStringANSI), nValueStringBufferSize);
	
	delete [] pszValueStringANSI;
}
コード例 #2
0
ファイル: ClientUtilities.cpp プロジェクト: Arc0re/lithtech
// Launches the end splash screen.
bool LaunchApplication::LaunchEndSplashScreen( )
{
#if defined(PLATFORM_WIN32)

	if( !g_pLTIStringEdit->DoesIDExist(g_pLTDBStringEdit, "EndSplashURL" ))
		return false;

	char szEndSplashURL[MAX_PATH*2] = "";
	LTStrCpy( szEndSplashURL, MPW2A( LoadString( "EndSplashURL" )).c_str(), LTARRAYSIZE( szEndSplashURL ));
	if( LTStrEmpty( szEndSplashURL ))
		return false;

	char szExe[MAX_PATH] = "";
	uint32 nExeSize = LTARRAYSIZE( szExe );
	AssocQueryString(ASSOCF_NOTRUNCATE,
		ASSOCSTR_EXECUTABLE,
		".htm",
		"open",
		szExe,
		( DWORD* )&nExeSize);

	return LaunchFromString( szExe, szEndSplashURL, true, true );
#else
	return false;
#endif
}
コード例 #3
0
ファイル: CheatMgr.cpp プロジェクト: Arc0re/lithtech
void CCheatMgr::GimmeAmmo( CParsedMsgW const& cMsg )
{
	if( !g_pWeaponDB || cMsg.GetArgCount() < 2 )
		return;

	// The full name of the ammo might be split between several 
	// arguments of the message so build the name from all arguments
	// except the name of the actual cheat (Arg 1).
	
	wchar_t szAmmoName[WMGR_MAX_NAME_LENGTH] = {0};
	cMsg.ReCreateMsg( szAmmoName, LTARRAYSIZE( szAmmoName ), 1 );

	HAMMO hAmmo = g_pWeaponDB->GetAmmoRecord( MPW2A(szAmmoName).c_str() );

	wchar_t wszMessage[256] = L"";

	if( hAmmo )
	{
		SendCheatMessageHRecord( CHEAT_GIMMEAMMO, hAmmo );

		LTSNPrintF( wszMessage, ARRAY_LEN(wszMessage), L"Giving ammo '%s'", szAmmoName );
		g_pGameMsgs->AddMessage( wszMessage, kMsgCheatConfirm );
	}
	else
	{
		LTSNPrintF( wszMessage, ARRAY_LEN(wszMessage), L"Ammo '%s' does not exist!", szAmmoName );
		g_pGameMsgs->AddMessage( wszMessage, kMsgCheatConfirm );
	}
}
コード例 #4
0
bool ScmdConsoleDriver_PunkBuster::WriteMessage( wchar_t const* pszMessage )
{
	// Check inputs.
	if( !pszMessage || !pszMessage[0] )
	{
		ASSERT( !"ScmdConsoleDriver_PunkBuster::WriteMessage: Invalid inputs." );
		return false;
	}
	
	std::string strMessage = MPW2A(pszMessage).c_str();
	strMessage += '\n';
	g_pGameServerShell->GetPunkBusterServer()->CaptureConsoleOutput((char*)strMessage.c_str(), strMessage.length());

	return true;
}
コード例 #5
0
void CScreenHostOptionFile::Delete(const wchar_t* pwsName)
{
	char szPath[MAX_PATH*2];

	const char* szFileName = CHostOptionsMapMgr::Instance().GetFileNameFromFriendlyName( pwsName );
	if( szFileName )
		GameModeMgr::Instance( ).GetOptionsFilePath( szFileName, szPath, LTARRAYSIZE( szPath ));
	else
		GameModeMgr::Instance( ).GetOptionsFilePath( MPW2A( pwsName ).c_str( ), szPath, LTARRAYSIZE( szPath ));
		
	LTFileOperations::DeleteFile( szPath );

	CHostOptionsMapMgr::Instance().Delete( pwsName );

	CreateFileList();
}
コード例 #6
0
ファイル: ClientUtilities.cpp プロジェクト: Arc0re/lithtech
// create strings
const wchar_t* CreateHelpString(const char *pszStringID)
{
	static std::wstring wsTmp;
	wsTmp = LoadString(pszStringID);

	uint32 nFirst = wsTmp.find_first_of(L"|");
	while (nFirst != std::wstring::npos)
	{
		uint32 nNext = wsTmp.find_first_of(L"|", nFirst+1);

		if (nNext != std::wstring::npos && nNext)
		{
			uint32 nLen = nNext-nFirst;
			std::wstring wsAction;
			if (nLen >= 2) 
			{
				wsAction = wsTmp.substr(nFirst+1,nLen-1);
			}

			wsTmp.erase(nFirst,nLen+1);

			CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile();
			int nCommand = GetCommandID( MPW2A(wsAction.c_str()).c_str() );
			wchar_t szTriggerName[32] = L"";
			LTStrCpy(szTriggerName,pProfile->GetTriggerNameFromCommandID(nCommand),LTARRAYSIZE(szTriggerName));
			if (LTStrEmpty(szTriggerName))
			{
				LTStrCpy(szTriggerName,LoadString("Control_Unassigned"),LTARRAYSIZE(szTriggerName));
			}
			wsTmp.insert(nFirst,szTriggerName);

		}

		nFirst = wsTmp.find_first_of(L"|");
	}

	return wsTmp.c_str();
}
コード例 #7
0
void CScreenHostOptionFile::SetName(const wchar_t* newName)
{
	const char* szFileName = CHostOptionsMapMgr::Instance().GetFileNameFromFriendlyName( newName );
	if( szFileName )
	{
		if( LTStrEquals( g_pProfileMgr->GetCurrentProfile()->m_sServerOptionsFile.c_str( ), szFileName ))
			return;

		g_pProfileMgr->GetCurrentProfile()->m_sServerOptionsFile = szFileName;
	}
	else
	{
		char szNewName[256];
		LTStrCpy( szNewName, MPW2A( newName ).c_str( ), LTARRAYSIZE( szNewName ));

		if( LTStrEquals( g_pProfileMgr->GetCurrentProfile()->m_sServerOptionsFile.c_str( ), szNewName ))
			return;

		g_pProfileMgr->GetCurrentProfile()->m_sServerOptionsFile = szNewName;
	}

	UpdateName();
};
コード例 #8
0
ファイル: HUDDebugInput.cpp プロジェクト: Arc0re/lithtech
void CHUDDebugInput::Send()
{
	char szPath[MAX_PATH*2];
	char szTemp[MAX_PATH];
	char szShotname[MAX_PATH + 1];

	LTFileOperations::GetUserDirectory(szPath, LTARRAYSIZE(szPath));
	LTStrCat(szPath,"DebugLog",LTARRAYSIZE(szPath));
	LTStrCat(szPath,FILE_PATH_SEPARATOR,LTARRAYSIZE(szPath));

	LTStrCpy(szTemp,g_pMissionMgr->GetCurrentWorldName(),LTARRAYSIZE(szTemp));

	char* szWorld = strrchr(szTemp,FILE_PATH_SEPARATOR[0]);
	if (szWorld)
	{
		szWorld++;
	}
	else
	{
		szWorld = szTemp;
	}

	LTStrCat(szPath,szWorld,LTARRAYSIZE(szPath));

	if (!CWinUtil::DirExist(szPath))
	{
		CWinUtil::CreateDir(szPath);
	}

	LTStrCat(szPath,FILE_PATH_SEPARATOR,LTARRAYSIZE(szPath));


	//determine a filename for this. This should start with the screenshot console variable and be
	//numbered sequentially

	//an upper cap to make sure that we don't attempt to create screenshots indefinitely, which could
	//potentially be caused by some file access issues
	static const uint32 knMaxScreenshotAttempts = 1000;

	for(uint32 nCurrScreenshotIndex = 0; nCurrScreenshotIndex < knMaxScreenshotAttempts; nCurrScreenshotIndex++)
	{
		//build up the filename to use for this screenshot
		
		LTSNPrintF(szShotname, LTARRAYSIZE(szShotname), "Screenshot%03d.jpg", nCurrScreenshotIndex);

		char pszFilename[MAX_PATH];
		LTSNPrintF(pszFilename, LTARRAYSIZE(pszFilename), "DebugLog%s%s%s%s",  FILE_PATH_SEPARATOR,szWorld,FILE_PATH_SEPARATOR,szShotname);

		// get the user path to the screenshot file, as we need this to check if the file exists.
		char pszUserFilename[MAX_PATH];
		g_pLTClient->FileMgr()->GetAbsoluteUserFileName( pszFilename, pszUserFilename, LTARRAYSIZE( pszUserFilename ) );

		//see if this file already exists - if it does, continue searching for an unused file
		if ( !LTFileOperations::FileExists( pszUserFilename ) )
		{
			//the filename doesn't exist, so go ahead and try to make the screenshot
			if(g_pLTClient->GetRenderer()->MakeScreenShot(pszUserFilename) == LT_OK)
			{
				g_pLTClient->CPrint("Successfully created screenshot %s", pszUserFilename);
			}
			else
			{
				g_pLTClient->CPrint("Failed to create screenshot %s", pszUserFilename);
			}
			break;
		}
	}

	//report overflow
	if(nCurrScreenshotIndex >= knMaxScreenshotAttempts)
	{
		g_pLTClient->CPrint("Unable to create screenshot. Please make sure that the directory is readable and that there are less than %d screenshots", knMaxScreenshotAttempts);
	}


	Show(false);

	// Ignore empty messages.
	if( !m_szDebugStr[0] )
		return;

	char szMsg[256];

	static bool bUseTime = false;

	if (bUseTime)
	{
		time_t tmSys;
		time( &tmSys );

		struct tm* pTimeDate = NULL;
		pTimeDate = localtime (&tmSys);
		if (pTimeDate)
		{
			LTSNPrintF(szMsg, LTARRAYSIZE( szMsg ), "<tr><td>%02d/%02d/%02d %02d:%02d:%02d</td>", pTimeDate->tm_mon + 1, pTimeDate->tm_mday, (pTimeDate->tm_year + 1900) % 100, pTimeDate->tm_hour, pTimeDate->tm_min, pTimeDate->tm_sec);
		}
	}
	else
	{
		LTSNPrintF(szMsg, LTARRAYSIZE( szMsg ), "<tr>");
	}


	//determine the offset we should use on the positions
	LTVector vOffset(0, 0, 0);
	g_pLTClient->GetSourceWorldOffset(vOffset);
	HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject();
	if (hPlayerObj)
	{
		char buf[256];
		LTVector vPos;
		g_pLTClient->GetObjectPos(hPlayerObj, &vPos);

		//handle the shift from the current world to the source world
		vPos += vOffset;

		LTSNPrintF(buf, LTARRAYSIZE(buf), "<td>(pos %0.0f %0.0f %0.0f)</td>", vPos.x, vPos.y, vPos.z);
		LTStrCat(szMsg,buf,LTARRAYSIZE(szMsg));

	}

	LTSNPrintF(szTemp,LTARRAYSIZE(szTemp),"<td><a href=\"%s\">%s</a></td>",szShotname,MPW2A(m_szDebugStr).c_str());

	LTStrCat(szMsg,szTemp,LTARRAYSIZE(szMsg));

	LTStrCat(szMsg,"</tr>\r\n",LTARRAYSIZE(szMsg));


	CLTFileWrite cFileWrite;

	LTStrCat( szPath, "debuglog.htm", LTARRAYSIZE( szPath ));

	bool bNewFile = !CWinUtil::FileExist(szPath);

	if (cFileWrite.Open(szPath,true))
	{
		if (bNewFile)
		{
			char szTmp[128] = "<HTML><BODY>\r\n<table>\r\n";
			cFileWrite.Write(szTmp,LTStrLen(szTmp));
		}
		
		cFileWrite.Write(szMsg,LTStrLen(szMsg));
		cFileWrite.Close();
	}

}
コード例 #9
0
ファイル: ServerVoteMgr.cpp プロジェクト: Arc0re/lithtech
void ServerVoteMgr::HandleVotePass( )
{
	// Tell everyone the vote passed.
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_VOTE );
	cMsg.WriteBits( eVote_Pass, FNumBitsExclusive<kNumVoteActions>::k_nValue );
	// Send the vote status info to the eligible voters.
	SendToEligibleVoters( *cMsg.Read( ));

	switch( m_CurrentVote.m_eVoteType )
	{
	case eVote_Kick:
	case eVote_TeamKick:
		{
			// Get the client.
			HCLIENT hClient = g_pLTServer->GetClientHandle( m_CurrentVote.m_nTargetID );			
			if( hClient )
			{
				// Kick the client.
				g_pLTServer->KickClient( hClient );
			}
		}
		break;
	case eVote_Ban:
		{
			// get the user's unique CD Key hash
			const char* pszUserCDKeyHash = NULL;
			g_pGameServerShell->GetGameSpyServer()->GetUserCDKeyHash(m_CurrentVote.m_nTargetID, pszUserCDKeyHash);	

			// get the user's player name
			const wchar_t* pwszPlayerName;
			HCLIENT hClient = g_pLTServer->GetClientHandle( m_CurrentVote.m_nTargetID );			
			GameClientData* pGameClientData = ServerConnectionMgr::Instance().GetGameClientData( hClient );
			if (!pGameClientData)
			{
				pwszPlayerName = L"";
			}
			else
			{
				pwszPlayerName = pGameClientData->GetUniqueName( );
			}

			// add them to the temp ban list
			float fDuration = GameModeMgr::Instance( ).m_ServerSettings.m_nVoteBanDuration * 60.0f;
			BanUserMgr::Instance().AddTempBan( pszUserCDKeyHash, MPW2A(pwszPlayerName).c_str(), fDuration );
		}
		break;
	case eVote_NextRound:
		{
			g_pServerMissionMgr->NextRound( );
		}
		break;
	case eVote_NextMap:
		{
			g_pServerMissionMgr->NextMission( );

		}
		break;
	case eVote_SelectMap:
		{
			// Check to make sure the mission index is within range.
			Campaign& campaign = g_pServerMissionMgr->GetCampaign( );
			if( m_CurrentVote.m_nTargetID < campaign.size( ))
			{
				// Do the switch.
				g_pServerMissionMgr->SwitchToCampaignIndex( m_CurrentVote.m_nTargetID );
			}

		}
		break;

	}

	// Clear the current vote.
	ClearVote( );
}