示例#1
0
文件: g_stats.c 项目: morsik/warpig
void G_DebugAddSkillPoints(gentity_t *ent, skillType_t skill, float points, const char *reason)
{
	qtime_t         ct;

	if (!g_debugSkills.integer)
	{
		return;
	}

	trap_SendServerCommand(ent - g_entities, va("sdbg \"^%c(SK: %2i XP: %6.2f) %s: You gained %.2fXP, reason: %s.\"\n",
	                       COLOR_RED + skill, ent->client->sess.skill[skill],
	                       ent->client->sess.skillpoints[skill], skillNames[skill], points, reason));

	trap_RealTime(&ct);

	if (g_debugSkills.integer >= 2 && skillDebugLog != -1)
	{
		char           *s = va("%02d:%02d:%02d : ^%c(SK: %2i XP: %6.2f) %s: %s gained %.2fXP, reason: %s.\n",
		                       ct.tm_hour, ct.tm_min, ct.tm_sec,
		                       COLOR_RED + skill, ent->client->sess.skill[skill], ent->client->sess.skillpoints[skill],
		                       skillNames[skill], ent->client->pers.netname, points, reason);

		trap_FS_Write(s, strlen(s), skillDebugLog);
	}
}
示例#2
0
void CG_currentTime_f(void)
{
	qtime_t ct;

	trap_RealTime(&ct);
	CG_Printf("[cgnotify]Current time: ^3%02d:%02d:%02d (%02d %s %d)\n", ct.tm_hour, ct.tm_min, ct.tm_sec, ct.tm_mday, aMonths[ct.tm_mon], 1900 + ct.tm_year);
}
示例#3
0
文件: g_stats.c 项目: morsik/warpig
void G_DebugOpenSkillLog(void)
{
	vmCvar_t        mapname;
	qtime_t         ct;
	char           *s;

	if (g_debugSkills.integer < 2)
	{
		return;
	}

	trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);

	trap_RealTime(&ct);

	if (trap_FS_FOpenFile(va("skills-%d-%02d-%02d-%02d%02d%02d-%s.log",
	                         1900 + ct.tm_year, ct.tm_mon + 1, ct.tm_mday,
	                         ct.tm_hour, ct.tm_min, ct.tm_sec, mapname.string), &skillDebugLog, FS_APPEND_SYNC) < 0)
	{
		return;
	}

	s = va("%02d:%02d:%02d : Logfile opened.\n", ct.tm_hour, ct.tm_min, ct.tm_sec);

	trap_FS_Write(s, strlen(s), skillDebugLog);
}
示例#4
0
文件: g_stats.c 项目: morsik/warpig
void G_DebugAddSkillLevel(gentity_t *ent, skillType_t skill)
{
	qtime_t         ct;

	if (!g_debugSkills.integer)
	{
		return;
	}

	trap_SendServerCommand(ent - g_entities, va("sdbg \"^%c(SK: %2i XP: %6.2f) %s: You raised your skill level to %i.\"\n",
	                       COLOR_RED + skill, ent->client->sess.skill[skill],
	                       ent->client->sess.skillpoints[skill], skillNames[skill],
	                       ent->client->sess.skill[skill]));

	trap_RealTime(&ct);

	if (g_debugSkills.integer >= 2 && skillDebugLog != -1)
	{
		char           *s = va("%02d:%02d:%02d : ^%c(SK: %2i XP: %6.2f) %s: %s raised in skill level to %i.\n",
		                       ct.tm_hour, ct.tm_min, ct.tm_sec,
		                       COLOR_RED + skill, ent->client->sess.skill[skill], ent->client->sess.skillpoints[skill],
		                       skillNames[skill], ent->client->pers.netname, ent->client->sess.skill[skill]);

		trap_FS_Write(s, strlen(s), skillDebugLog);
	}
}
示例#5
0
文件: g_shared.c 项目: natelo/rtcwPub
// Returns current time % date
char *getTime( void ) {
	qtime_t		ct;
	trap_RealTime(&ct);

	return va("%02d:%02d:%02d/%02d %s %d",
		ct.tm_hour, ct.tm_min, ct.tm_sec, ct.tm_mday,
		months[ct.tm_mon], 1900 + ct.tm_year);
}
示例#6
0
const char *CG_GetLocalTimeString (void)
{
    qtime_t now;
    static char nowString[128];
    int tm;
    int offset;
    qboolean timeAm = qfalse;

    offset = cg.time - cgs.levelStartTime;
	if (0) {  //(cgs.cpma) {
		tm = atoi(Info_ValueForKey(CG_ConfigStringNoConvert(672), "i"));
	} else {
		tm = atoi(Info_ValueForKey(CG_ConfigString(CS_SERVERINFO), "g_levelStartTime"));
	}

    if (tm  &&  cg.demoPlayback  &&  cg_localTime.integer == 0) {
        if (offset > 0) {
            tm += (offset / 1000);
        }
        trap_RealTime(&now, qfalse, tm);
    } else {
        trap_RealTime(&now, qtrue, 0);
    }
    if (cg_localTimeStyle.integer == 0) {
        Com_sprintf(nowString, sizeof(nowString), "%02d:%02d (%s %d, %d)", now.tm_hour, now.tm_min, MonthAbbrev[now.tm_mon], now.tm_mday, 1900 + now.tm_year);
    } else {
		  if (now.tm_hour < 12) {
			  timeAm = qtrue;
			  if (now.tm_hour < 1) {
				  now.tm_hour = 12;
			  }
		  } else if (now.tm_hour >= 12) {
			  timeAm = qfalse;
			  if (now.tm_hour >= 13) {
				  now.tm_hour -= 12;
			  }
		  }
          Com_sprintf(nowString, sizeof(nowString), "%d:%02d%s (%s %d, %d)", now.tm_hour, now.tm_min, timeAm ? "am" : "pm", MonthAbbrev[now.tm_mon], now.tm_mday, 1900 + now.tm_year);
	  }

    return nowString;
}
示例#7
0
void G_DebugCloseSkillLog( void )
{
	qtime_t		ct;
	char		*s;

	if( skillDebugLog == -1 )
		return;

	trap_RealTime( &ct );

	s = va( "%02d:%02d:%02d : Logfile closed.\n", ct.tm_hour, ct.tm_min, ct.tm_sec );

	trap_FS_Write( s, strlen( s ), skillDebugLog );

	trap_FS_FCloseFile( skillDebugLog );
}
示例#8
0
void G_DebugCloseSkillLog( void )
{
	qtime_t ct;
	char    *s;

	if ( skillDebugLog == -1 )
	{
		return;
	}

	trap_RealTime( &ct );

	s = va( "%04i-%02i-%02i %02i:%02i:%02i : Logfile closed.\n",
	        1900 + ct.tm_year, ct.tm_mon + 1, ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec );

	trap_FS_Write( s, strlen( s ), skillDebugLog );

	trap_FS_FCloseFile( skillDebugLog );
}
int G_globalAdd(gentity_t *adminEnt, gentity_t *victimEnt, char *guid, char *ip, char *playerName, char *reason, int subnet, char *date, globalType_t type)
{
	global_t *temp = G_Alloc(sizeof(global_t));
	char newDate[11];
	char newPlayerName[MAX_NAME_LENGTH];
	char newGuid[33];
	char data[255];

	//DATE
	if (date == NULL)
	{
		qtime_t qt;
		int t;
		t = trap_RealTime(&qt);

		Q_strncpyz(newDate, va("%04i-%02i-%02i", qt.tm_year + 1900, qt.tm_mon
				+ 1, qt.tm_mday), 11);
	}
	else
	{
		Q_strncpyz(newDate, date, 11);
	}

	//PLAYERNAME
	if (playerName == NULL)
	{
		Q_strncpyz(newPlayerName, va("%s", "UnnamedPlayer"), MAX_NAME_LENGTH);
	}
	else
	{
		Q_strncpyz(newPlayerName, playerName, MAX_NAME_LENGTH);
	}

	//GUID
	if (guid == NULL)
	{
		Q_strncpyz(newGuid, va("%s", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), 33);
	}
	else
	{
		Q_strncpyz(newGuid, guid, 33);
	}

	//Setting
	Q_strncpyz(temp->guid, newGuid, 33);
	Q_strncpyz(temp->ip, ip, 16);
	Q_strncpyz(temp->playerName, newPlayerName, MAX_NAME_LENGTH);
	Q_strncpyz(temp->server, va("%s","z"), 2);
	Q_strncpyz(temp->adminName, (G_isPlayerConnected(adminEnt))
			? adminEnt->client->pers.netname
			: "console", MAX_NAME_LENGTH);
	Q_strncpyz(temp->reason, reason, MAX_STRING_CHARS);

	temp->subnet = subnet;
	temp->type = type;

	if (trap_mysql_runquery(va("INSERT HIGH_PRIORITY INTO globals"
		" (playerid,adminid,adminname,ip,guid,name,reason,subnet,type,server) "
		" VALUES (\"%d\",\"%d\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%d\",\"%d\",\"x\") ", (G_isPlayerConnected(victimEnt)
			? victimEnt->client->pers.mysqlid
			: -1), (G_isPlayerConnected(adminEnt)
			? adminEnt->client->pers.mysqlid
			: -1), (G_isPlayerConnected(adminEnt)
			? adminEnt->client->pers.netname
			: "console"), temp->ip, temp->guid, temp->playerName, temp->reason, temp->subnet, temp->type))
			== qtrue)
	{
		trap_mysql_finishquery();
		if (trap_mysql_runquery(va("SELECT HIGH_PRIORITY id FROM globals ORDER BY id DESC LIMIT 1"))
				== qtrue)
		{
			if (trap_mysql_fetchrow() == qtrue)
			{
				trap_mysql_fetchfieldbyName("id", data, sizeof(data));
				trap_mysql_finishquery();
				temp->id = atoi(data);
			}
			else
			{
				G_LogPrintf("Couldnt insert global to database\n");//va("Hacked client tried to connect guid: %s ip: %s\n", guid, ip) );
				if (level.globals)
				{
					temp->id = level.globals->id + 1;
				}
				else
				{
					temp->id = 1;
				}
			}
		}
	}


	temp->next = level.globals;
	level.globals = temp;

	return temp->id;
}
示例#10
0
文件: g_shared.c 项目: natelo/rtcwPub
// Returns current date
char *getDate( void ) {
	qtime_t		ct;
	trap_RealTime(&ct);

	return va("%02d/%s/%d",	ct.tm_mday,	months[ct.tm_mon], 1900 + ct.tm_year);
}
示例#11
0
/*
===========
ClientConnect

Called when a player begins connecting to the server.
Called again for every map change or tournement restart.

The session information will be valid after exit.

Return NULL if the client should be allowed, otherwise return
a string with the reason for denial.

Otherwise, the client will be sent the current gamestate
and will eventually get to ClientBegin.

firstTime will be qtrue the very first time a client connects
to the server machine, but qfalse on map changes and tournement
restarts.
============
*/
char *ClientConnect( int clientNum, qboolean firstTime )
{
	char            *value;
	char            *userInfoError;
	gclient_t       *client;
	char            userinfo[ MAX_INFO_STRING ];
	char            pubkey[ RSA_STRING_LENGTH ];
	gentity_t       *ent;
	char            reason[ MAX_STRING_CHARS ] = { "" };
	int             i;

	ent = &g_entities[ clientNum ];
	client = &level.clients[ clientNum ];

	// ignore if client already connected
	if ( client->pers.connected != CON_DISCONNECTED )
	{
		return NULL;
	}

	ent->client = client;
	memset( client, 0, sizeof( *client ) );

	trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );

	value = Info_ValueForKey( userinfo, "ip" );

	// check for local client
	if ( !strcmp( value, "localhost" ) )
	{
		client->pers.localClient = qtrue;
	}

	G_AddressParse( value, &client->pers.ip );

	trap_GetPlayerPubkey( clientNum, pubkey, sizeof( pubkey ) );

	if ( strlen( pubkey ) != RSA_STRING_LENGTH - 1 )
	{
		return "Invalid pubkey key";
	}
	
	trap_GenFingerprint( pubkey, sizeof( pubkey ), client->pers.guid, sizeof( client->pers.guid ) );

	client->pers.admin = G_admin_admin( client->pers.guid );
	client->pers.pubkey_authenticated = 0;

	if ( client->pers.admin )
	{
		trap_RealTime( &client->pers.admin->lastSeen );
	}

	// check for admin ban
	if ( G_admin_ban_check( ent, reason, sizeof( reason ) ) )
	{
		return va( "%s", reason ); // reason is local
	}

	// check for a password
	value = Info_ValueForKey( userinfo, "password" );

	if ( g_password.string[ 0 ] && Q_stricmp( g_password.string, "none" ) &&
	     strcmp( g_password.string, value ) != 0 )
	{
		return "Invalid password";
	}

	// if a player reconnects quickly after a disconnect, the client disconnect may never be called, thus flag can get lost in the ether
	if ( ent->inuse )
	{
		G_LogPrintf( "Forcing disconnect on active client: %i\n", (int)( ent - g_entities ) );
		// so lets just fix up anything that should happen on a disconnect
		ClientDisconnect( ent-g_entities );
	}

	for ( i = 0; i < level.maxclients; i++ )
	{
		if ( level.clients[ i ].pers.connected == CON_DISCONNECTED )
		{
			continue;
		}
		
		if ( !Q_stricmp( client->pers.guid, level.clients[ i ].pers.guid ) )
		{
			if ( !G_ClientIsLagging( level.clients + i ) )
			{
				trap_SendServerCommand( i, "cp \"Your GUID is not secure\"" );
				return "Duplicate GUID";
			}
			
			trap_DropClient( i, "Ghost" );
		}
	}
	
	client->pers.connected = CON_CONNECTING;

	// read or initialize the session data
	if ( firstTime )
	{
		G_InitSessionData( client, userinfo );
	}

	G_ReadSessionData( client );

	// get and distribute relevent paramters
	G_namelog_connect( client );
	userInfoError = ClientUserinfoChanged( clientNum, qfalse );

	if ( userInfoError != NULL )
	{
		return userInfoError;
	}

	G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s^7\" \"%c%s%c^7\"\n",
	             clientNum, client->pers.ip.str, client->pers.guid,
	             client->pers.netname,
	             DECOLOR_OFF, client->pers.netname, DECOLOR_ON );

	// don't do the "xxx connected" messages if they were caried over from previous level
	if ( firstTime )
	{
		trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 connected\n") ),
		                                Quote( client->pers.netname ) ) );
	}

	// count current clients and rank for scoreboard
	CalculateRanks();

	// if this is after !restart keepteams or !restart switchteams, apply said selection
	if ( client->sess.restartTeam != TEAM_NONE )
	{
		G_ChangeTeam( ent, client->sess.restartTeam );
		client->sess.restartTeam = TEAM_NONE;
	}

	return NULL;
}