本文整理汇总了C++中Com_RealTime函数的典型用法代码示例。如果您正苦于以下问题:C++ Com_RealTime函数的具体用法?C++ Com_RealTime怎么用?C++ Com_RealTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Com_RealTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CL_WriteClientChatLog
/*
==================
CL_WriteClientChatLog
==================
*/
void CL_WriteClientChatLog( char *text )
{
if ( cl_logs && cl_logs->integer )
{
if ( LogFileOpened == qfalse || !LogFileHandle )
{
CL_OpenClientLog();
}
if ( FS_Initialized() && LogFileOpened == qtrue )
{
if( cl.serverTime > 0 )
{
// varibles
char NoColorMsg[MAXPRINTMSG];
char Timestamp[ 60 ];
char LogText[ 60 + MAXPRINTMSG ];
if( cl_logs->integer == 1 )
{
//just do 3 stars to seperate from normal logging stuff
Q_strncpyz( Timestamp, "***", sizeof( Timestamp ) );
}
else if ( cl_logs->integer == 2 )
{
//just game time
//do timestamp prep
sprintf( Timestamp, "[%d:%02d]", cl.serverTime / 60000, ( cl.serverTime / 1000 ) % 60 ); //server Time
}
else if ( cl_logs->integer == 3 )
{
//just system time
//do timestamp prep
//get current time/date info
qtime_t now;
Com_RealTime( &now );
sprintf( Timestamp, "[%d:%02d]", now.tm_hour, now.tm_min ); //server Time
}
else if( cl_logs->integer == 4 )
{
//all the data
//do timestamp prep
//get current time/date info
qtime_t now;
Com_RealTime( &now );
sprintf( Timestamp, "[%d:%02d][%d:%02d]", now.tm_hour, now.tm_min, cl.serverTime / 60000, ( cl.serverTime / 1000 ) % 60 ); //server Time
}
//decolor the string
Q_strncpyz( NoColorMsg, text, sizeof(NoColorMsg) );
Q_CleanStr( NoColorMsg );
//prepare text for log
sprintf( LogText, "%s%s\n", Timestamp, NoColorMsg ); //thing to write to log
//write to the file
FS_Write( LogText, strlen( LogText ), LogFileHandle );
//flush the file so we can see the data
FS_ForceFlush( LogFileHandle );
}
}
}
}
示例2: Con_DrawInput
/*
================
Con_DrawInput
Draw the editline after a ] prompt
================
*/
void Con_DrawInput( void )
{
int y;
char prompt[ MAX_STRING_CHARS ];
vec4_t color;
qtime_t realtime;
if ( cls.state != CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_CONSOLE ) )
{
return;
}
Com_RealTime( &realtime );
y = con.vislines - ( SCR_ConsoleFontCharHeight() * 2 ) + 2;
Com_sprintf( prompt, sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, cl_consolePrompt->string );
color[ 0 ] = 1.0f;
color[ 1 ] = 1.0f;
color[ 2 ] = 1.0f;
color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : con.displayFrac * 2.0f );
SCR_DrawSmallStringExt( con.xadjust + cl_conXOffset->integer, y + 10, prompt, color, qfalse, qfalse );
Q_CleanStr( prompt );
Field_Draw( &g_consoleField, con.xadjust + cl_conXOffset->integer + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), y + 10, qtrue, qtrue, color[ 3 ] );
}
示例3: SV_NameServerDemo
/*
Generate unique name for a new server demo file.
(We pretend there are no race conditions.)
*/
static void SV_NameServerDemo(char *filename, int length, const client_t *client)
{
qtime_t time;
char playername[64];
Com_DPrintf("SV_NameServerDemo\n");
Com_RealTime(&time);
Q_strncpyz(playername, client->name, sizeof(playername));
SVD_CleanPlayerName(playername);
do {
// TODO: really this should contain something identifying
// the server instance it came from; but we could be on
// (multiple) IPv4 and IPv6 interfaces; in the end, some
// kind of server guid may be more appropriate; mission?
// TODO: when the string gets too long (what exactly is
// the limit?) it get's cut off at the end ruining the
// file extension
Com_sprintf(
filename, length-1, "serverdemos/%.4d-%.2d-%.2d_%.2d-%.2d-%.2d_%s_%d.dm_%d",
time.tm_year+1900, time.tm_mon, time.tm_mday,
time.tm_hour, time.tm_min, time.tm_sec,
playername,
Sys_Milliseconds(),
PROTOCOL_VERSION
);
filename[length-1] = '\0';
} while (FS_FileExists(filename));
}
示例4: CON_UpdateClock
/*
==================
CON_UpdateClock
Update the clock
==================
*/
static void CON_UpdateClock(void)
{
qtime_t realtime;
Com_RealTime(&realtime);
werase(clockwin);
CON_ColorPrint(clockwin, va("^0[^3%02d%c%02d^0]^7 ", realtime.tm_hour, (realtime.tm_sec & 1) ? ':' : ' ', realtime.tm_min), qtrue);
wnoutrefresh(clockwin);
}
示例5: SCR_DrawClock
/*
=================
SCR_DrawClock
=================
*/
static void SCR_DrawClock( void ) {
qtime_t myTime;
char string[16];
if (Cvar_VariableValue ("cl_drawclock")) {
Com_RealTime( &myTime );
Com_sprintf( string, sizeof ( string ), "%02i:%02i:%02i", myTime.tm_hour, myTime.tm_min, myTime.tm_sec );
SCR_DrawStringExt( 320 - strlen( string ) * 4, 11, 8, string, g_color_table[ColorIndex(COLOR_CYAN)], qtrue, qfalse );
}
}
示例6: Com_RealTime
// Standard naming for screenshots/demos
static char *demoAutoGenerateDefaultFilename(void) {
qtime_t ct;
const char *pszServerInfo = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO];
Com_RealTime(&ct);
return va("%d-%02d-%02d-%02d%02d%02d-%s",
1900+ct.tm_year, ct.tm_mon+1,ct.tm_mday,
ct.tm_hour, ct.tm_min, ct.tm_sec,
COM_SkipPath(Info_ValueForKey(pszServerInfo, "mapname")));
}
示例7: SV_NameServerDemo
/*
Generate unique name for a new server demo file.
(We pretend there are no race conditions.)
*/
static void SV_NameServerDemo(char *filename, int length, const client_t *client, char *fn) {
qtime_t time;
char playername[32];
char demoName[64]; //@Barbatos
Com_DPrintf("SV_NameServerDemo\n");
Com_RealTime(&time);
Q_strncpyz(playername, client->name, sizeof(playername));
SVD_CleanPlayerName(playername);
if (fn != NULL) {
Q_strncpyz(demoName, fn, sizeof(demoName));
#ifdef USE_DEMO_FORMAT_42
Q_snprintf(filename, length-1, "%s/%s.urtdemo", sv_demofolder->string, demoName );
if (FS_FileExists(filename)) {
Q_snprintf(filename, length-1, "%s/%s_%d.urtdemo", sv_demofolder->string, demoName, Sys_Milliseconds() );
}
#else
Q_snprintf(filename, length-1, "%s/%s.dm_%d", sv_demofolder->string, demoName , PROTOCOL_VERSION );
if (FS_FileExists(filename)) {
Q_snprintf(filename, length-1, "%s/%s_%d.dm_%d", sv_demofolder->string, demoName, Sys_Milliseconds() , PROTOCOL_VERSION );
}
#endif
} else {
#ifdef USE_DEMO_FORMAT_42
Q_snprintf(
filename, length-1, "%s/%.4d-%.2d-%.2d_%.2d-%.2d-%.2d_%s_%d.urtdemo",
sv_demofolder->string, time.tm_year+1900, time.tm_mon + 1, time.tm_mday,
time.tm_hour, time.tm_min, time.tm_sec,
playername,
Sys_Milliseconds()
);
#else
Q_snprintf(
filename, length-1, "%s/%.4d-%.2d-%.2d_%.2d-%.2d-%.2d_%s_%d.dm_%d",
sv_demofolder->string, time.tm_year+1900, time.tm_mon + 1, time.tm_mday,
time.tm_hour, time.tm_min, time.tm_sec,
playername,
Sys_Milliseconds(),
PROTOCOL_VERSION
);
#endif
filename[length-1] = '\0';
if (FS_FileExists(filename)) {
filename[0] = 0;
return;
}
}
}
示例8: CL_OpenClientLog
/*
==================
CL_OpenClientLog
==================
*/
void CL_OpenClientLog(void) {
if( cl_logs && cl_logs->integer ) {
if( FS_Initialized() && LogFileOpened == qfalse ) {
char FileLocation[ 255 ];
char *nowString;
//get current time/date info
qtime_t now;
Com_RealTime( &now );
nowString = va( "%04d-%02d-%02d", 1900 + now.tm_year, 1 + now.tm_mon, now.tm_mday );
sprintf(FileLocation,"logs/%s.log", nowString );
LogFileHandle = FS_FOpenFileAppend( FileLocation ); //open file with filename as date
LogFileOpened = qtrue; //var to tell if files open
}
}
}
示例9: SV_WriteAttackLog
void SV_WriteAttackLog(const char *log)
{
if (attHandle > 0)
{
char string[512]; // 512 chars seem enough here
qtime_t time;
Com_RealTime(&time);
Com_sprintf(string, sizeof(string), "%i/%i/%i %i:%i:%i %s", 1900 + time.tm_year, time.tm_mday, time.tm_mon + 1, time.tm_hour, time.tm_min, time.tm_sec, log);
FS_Write(string, strlen(string), attHandle);
}
else
{
Com_Printf("%s", log);
}
}
示例10: Con_DrawInput
/*
================
Con_DrawInput
Draw the editline after a ] prompt
================
*/
void Con_DrawInput( int linePosition, float overrideAlpha )
{
char prompt[ MAX_STRING_CHARS ];
vec4_t color;
qtime_t realtime;
Com_RealTime( &realtime );
Com_sprintf( prompt, sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, con_prompt->string );
color[ 0 ] = 1.0f;
color[ 1 ] = 1.0f;
color[ 2 ] = 1.0f;
color[ 3 ] = consoleState.currentAlphaFactor * overrideAlpha;
SCR_DrawSmallStringExt( consoleState.margin.sides + consoleState.padding.sides, linePosition, prompt, color, qfalse, qfalse );
Q_CleanStr( prompt );
Field_Draw( g_consoleField, consoleState.margin.sides + consoleState.padding.sides + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), linePosition, qtrue, qtrue, color[ 3 ] );
}
示例11: SCR_DrawClock
/*
=================
SCR_DrawClock
=================
*/
void SCR_DrawClock(void) {
int color, fontsize, posx, posy, hour;
char string[16];
qtime_t myTime;
color = cl_drawclockcolor->integer;
fontsize = cl_drawclockfontsize->integer;
posx = cl_drawclockposx->integer;
posy = cl_drawclockposy->integer;
if (cl_drawclock->integer) {
Com_RealTime(&myTime);
hour = myTime.tm_hour;
if (cl_drawclock12->integer)
hour = hourTo12(hour);
Com_sprintf(string, sizeof(string), "%02i:%02i", hour, myTime.tm_min);
SCR_DrawCondensedString(posx * 10, posy * 10, fontsize, string, g_color_table[color], qtrue);
}
}
示例12: SCR_DrawClock
/////////////////////////////////////////////////////////////////////
// Name : SCR_DrawClock
// Description : Draw the clock
/////////////////////////////////////////////////////////////////////
void SCR_DrawClock(void) {
qtime_t now;
char string[16];
// if we are not supposed to draw the clock
if (!Cvar_VariableValue("cl_drawClock")) {
return;
}
// if 2D drawing is disabled
if (!Cvar_VariableValue("cg_draw2D")) {
return;
}
// if we are paused
if (Cvar_VariableValue("cl_paused")) {
return;
}
Com_RealTime(&now);
Com_sprintf(string, sizeof(string), "%02i:%02i:%02i", now.tm_hour, now.tm_min, now.tm_sec);
SCR_DrawStringExt(320 - (SCR_GetSmallStringWidth(string) / 2), 15, SMALLCHAR_WIDTH, string, g_color_table[7], qtrue);
}
示例13: SV_GameSystemCalls
//.........这里部分代码省略.........
case G_ADJUST_AREA_PORTAL_STATE:
SV_AdjustAreaPortalState((sharedEntity_t*)VMA(1),(bool)args[2]);
return 0;
case G_AREAS_CONNECTED:
return CM_AreasConnected(args[1], args[2]);
case G_UPDATE_SHARED_CONFIG:
SV_UpdateSharedConfig( args[1], (char*)VMA(2) );
return 0;
case G_BOT_ALLOCATE_CLIENT:
return SV_BotAllocateClient(args[1]);
case G_BOT_FREE_CLIENT:
SV_BotFreeClient(args[1]);
return 0;
case G_GET_USERCMD:
SV_GetUsercmd(args[1], (usercmd_t*)VMA(2));
return 0;
case G_GET_ENTITY_TOKEN: {
const char *s;
s = COM_Parse(&sv.entityParsePoint);
Q_strncpyz((char*)VMA(1), s, args[2]);
if(!sv.entityParsePoint && !s[0]) {
return false;
} else {
return true;
}
}
case G_DEBUG_POLYGON_CREATE:
return BotImport_DebugPolygonCreate(args[1], args[2], (vec3_t*)VMA(3));
case G_DEBUG_POLYGON_DELETE:
BotImport_DebugPolygonDelete(args[1]);
return 0;
case G_REAL_TIME:
return Com_RealTime((qtime_t*)VMA(1));
case G_SNAPVECTOR:
Q_SnapVector((float*)VMA(1));
return 0;
case G_SEND_GAMESTAT:
SV_MasterGameStat( (char*)VMA(1) );
return 0;
case G_ADDCOMMAND:
Cmd_AddCommand( (char*)VMA(1), NULL, (char*)VMA(3) );
return 0;
case G_REMOVECOMMAND:
Cmd_RemoveCommand( (char*)VMA(1) );
return 0;
case G_GETTAG:
return SV_GetTag(args[1], args[2], (char*)VMA(3), (orientation_t*)VMA(4));
case G_REGISTERTAG:
return SV_LoadTag((char*)VMA(1));
case G_REGISTERSOUND:
return S_RegisterSound((char*)VMA(1), (bool)args[2]);
case G_GET_SOUND_LENGTH:
return S_GetSoundLength(args[1]);
case G_PARSE_ADD_GLOBAL_DEFINE:
return Parse_AddGlobalDefine( (char*)VMA(1) );
case G_PARSE_LOAD_SOURCE:
return Parse_LoadSourceHandle( (char*)VMA(1) );
case G_PARSE_FREE_SOURCE:
return Parse_FreeSourceHandle( args[1] );
case G_PARSE_READ_TOKEN:
return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) );
case G_PARSE_SOURCE_FILE_AND_LINE:
return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) );
case BOTLIB_SETUP:
return SV_BotLibSetup();
示例14: CLWM_UISystemCalls
//.........这里部分代码省略.........
case WMUI_R_REGISTERFONT:
R_RegisterFont( ( char* )VMA( 1 ), args[ 2 ], ( fontInfo_t* )VMA( 3 ) );
return 0;
case WMUI_MEMSET:
return ( qintptr )memset( VMA( 1 ), args[ 2 ], args[ 3 ] );
case WMUI_MEMCPY:
return ( qintptr )memcpy( VMA( 1 ), VMA( 2 ), args[ 3 ] );
case WMUI_STRNCPY:
String::NCpy( ( char* )VMA( 1 ), ( char* )VMA( 2 ), args[ 3 ] );
return args[ 1 ];
case WMUI_SIN:
return FloatAsInt( sin( VMF( 1 ) ) );
case WMUI_COS:
return FloatAsInt( cos( VMF( 1 ) ) );
case WMUI_ATAN2:
return FloatAsInt( atan2( VMF( 1 ), VMF( 2 ) ) );
case WMUI_SQRT:
return FloatAsInt( sqrt( VMF( 1 ) ) );
case WMUI_FLOOR:
return FloatAsInt( floor( VMF( 1 ) ) );
case WMUI_CEIL:
return FloatAsInt( ceil( VMF( 1 ) ) );
case WMUI_PC_ADD_GLOBAL_DEFINE:
return PC_AddGlobalDefine( ( char* )VMA( 1 ) );
case WMUI_PC_LOAD_SOURCE:
return PC_LoadSourceHandle( ( char* )VMA( 1 ) );
case WMUI_PC_FREE_SOURCE:
return PC_FreeSourceHandle( args[ 1 ] );
case WMUI_PC_READ_TOKEN:
return PC_ReadTokenHandleQ3( args[ 1 ], ( q3pc_token_t* )VMA( 2 ) );
case WMUI_PC_SOURCE_FILE_AND_LINE:
return PC_SourceFileAndLine( args[ 1 ], ( char* )VMA( 2 ), ( int* )VMA( 3 ) );
case WMUI_S_STOPBACKGROUNDTRACK:
S_StopBackgroundTrack();
return 0;
case WMUI_S_STARTBACKGROUNDTRACK:
S_StartBackgroundTrack( ( char* )VMA( 1 ), ( char* )VMA( 2 ), 0 );
return 0;
case WMUI_REAL_TIME:
return Com_RealTime( ( qtime_t* )VMA( 1 ) );
case WMUI_CIN_PLAYCINEMATIC:
return CIN_PlayCinematicStretched( ( char* )VMA( 1 ), args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ], args[ 6 ] );
case WMUI_CIN_STOPCINEMATIC:
return CIN_StopCinematic( args[ 1 ] );
case WMUI_CIN_RUNCINEMATIC:
return CIN_RunCinematic( args[ 1 ] );
case WMUI_CIN_DRAWCINEMATIC:
CIN_DrawCinematic( args[ 1 ] );
return 0;
case WMUI_CIN_SETEXTENTS:
CIN_SetExtents( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] );
return 0;
case WMUI_R_REMAP_SHADER:
R_RemapShader( ( char* )VMA( 1 ), ( char* )VMA( 2 ), ( char* )VMA( 3 ) );
return 0;
case WMUI_VERIFY_CDKEY:
return CLT3_CDKeyValidate( ( char* )VMA( 1 ), ( char* )VMA( 2 ) );
case WMUI_CL_GETLIMBOSTRING:
return CLT3_GetLimboString( args[ 1 ], ( char* )VMA( 2 ) );
case WMUI_CL_TRANSLATE_STRING:
CL_TranslateString( ( char* )VMA( 1 ), ( char* )VMA( 2 ) );
return 0;
case WMUI_CHECKAUTOUPDATE:
return 0;
case WMUI_GET_AUTOUPDATE:
return 0;
case WMUI_OPENURL:
CLT3_OpenURL( ( const char* )VMA( 1 ) );
return 0;
default:
common->Error( "Bad UI system trap: %i", static_cast<int>( args[ 0 ] ) );
}
return 0;
}
示例15: CL_CgameSystemCalls
//.........这里部分代码省略.........
case CG_KEY_KEYNUMTOSTRINGBUF:
Key_KeynumToStringBuf( args[1], (char*)VMA(2), args[3] );
return 0;
case CG_KEY_GETBINDINGBUF:
Key_GetBindingBuf( args[1], (char*)VMA(2), args[3] );
return 0;
case CG_KEY_SETBINDING:
Key_SetBinding( args[1], (const char*)VMA(2) );
return 0;
case CG_PARSE_ADD_GLOBAL_DEFINE:
return Parse_AddGlobalDefine( (char*)VMA(1) );
case CG_PARSE_LOAD_SOURCE:
return Parse_LoadSourceHandle( (const char*)VMA(1) );
case CG_PARSE_FREE_SOURCE:
return Parse_FreeSourceHandle( args[1] );
case CG_PARSE_READ_TOKEN:
return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) );
case CG_PARSE_SOURCE_FILE_AND_LINE:
return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) );
case CG_KEY_SETOVERSTRIKEMODE:
Key_SetOverstrikeMode( (bool)args[1] );
return 0;
case CG_KEY_GETOVERSTRIKEMODE:
return Key_GetOverstrikeMode( );
case CG_FIELD_COMPLETELIST:
Field_CompleteList( (char*)VMA(1) );
return 0;
case CG_MEMSET:
::memset( VMA(1), args[2], args[3] );
return 0;
case CG_MEMCPY:
::memcpy( VMA(1), VMA(2), args[3] );
return 0;
case CG_STRNCPY:
safe_strncpy( (char*)VMA(1), (const char*)VMA(2), args[3] );
return args[1];
case CG_SIN:
return FloatAsInt( sin( VMF(1) ) );
case CG_COS:
return FloatAsInt( cos( VMF(1) ) );
case CG_ATAN2:
return FloatAsInt( atan2( VMF(1), VMF(2) ) );
case CG_SQRT:
return FloatAsInt( sqrt( VMF(1) ) );
case CG_FLOOR:
return FloatAsInt( floor( VMF(1) ) );
case CG_CEIL:
return FloatAsInt( ceil( VMF(1) ) );
case CG_ACOS:
return FloatAsInt( Q_acos( VMF(1) ) );
case CG_S_STOPBACKGROUNDTRACK:
S_StopBackgroundTrack();
return 0;
case CG_REAL_TIME:
return Com_RealTime( (qtime_t*)VMA(1) );
case CG_SNAPVECTOR:
Q_SnapVector((float*)VMA(1));
return 0;
case CG_CIN_PLAYCINEMATIC:
return CIN_PlayCinematic((const char*)VMA(1), args[2], args[3], args[4], args[5], args[6]);
case CG_CIN_STOPCINEMATIC:
return CIN_StopCinematic(args[1]);
case CG_CIN_RUNCINEMATIC:
return CIN_RunCinematic(args[1]);
case CG_CIN_DRAWCINEMATIC:
CIN_DrawCinematic(args[1]);
return 0;
case CG_CIN_SETEXTENTS:
CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
return 0;
case CG_R_REMAP_SHADER:
re.RemapShader( (const char*)VMA(1), (const char*)VMA(2), (const char*)VMA(3) );
return 0;
case CG_GET_ENTITY_TOKEN:
return re.GetEntityToken( (char*)VMA(1), args[2] );
case CG_R_INPVS:
return re.inPVS( (const float*)VMA(1), (const float*)VMA(2) );
default:
assert(0);
Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] );
}
return 0;
}