示例#1
0
bool ASW_System_GetCurrentTimeAndDate(int *year, int *month, int *dayOfWeek, int *day, int *hour, int *minute, int *second)
{
	struct tm timeinfo;
	Plat_GetLocalTime( &timeinfo );

	if (year)
	{
		*year = timeinfo.tm_year;
	}
	if (month)
	{
		*month = timeinfo.tm_mon;
	}
	if (dayOfWeek)
	{
		*dayOfWeek = timeinfo.tm_wday;
	}
	if (day)
	{
		*day = timeinfo.tm_mday;
	}
	if (hour)
	{
		*hour = timeinfo.tm_hour;
	}
	if (minute)
	{
		*minute = timeinfo.tm_min;
	}
	if (second)
	{
		*second = timeinfo.tm_sec;
	}
	return true;
}
	virtual void LevelInitPreEntity()
	{
		BaseClass::LevelInitPreEntity();

		if (engine->IsPlayingDemo())
			return;

		if (engine->IsRecordingDemo())
			return;

		if (asw_auto_record.GetBool())
		{
			if (asw_auto_record.GetInt() > 0)
			{
				DeleteOldRecordings(asw_auto_record.GetInt() - 1);
			}

			struct tm now;
			Plat_GetLocalTime(&now);
			// we assume a map will only be started once per second, and that if a map is started multiple times per second, the old recordings aren't useful.
			// our date format is RFC2550 compliant until January 1st 10000.
			engine->ClientCmd_Unrestricted(VarArgs("record \"aswauto-%04d%02d%02d%02d%02d%02d_%s\"", now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, MapName()));
			m_bIsRecording = true;
		}
	}