本文整理汇总了C++中Q_strcat函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_strcat函数的具体用法?C++ Q_strcat怎么用?C++ Q_strcat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_strcat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: G_xpsave_load
qboolean G_xpsave_load(gentity_t *ent)
{
int i, j;
qboolean found = qfalse, XPSMuted = qfalse;
int clientNum;
g_xpsave_t *x = g_xpsaves[0];
time_t t;
char agestr[MAX_STRING_CHARS];
//char desc[64];
// josh: Increased this
// josh: TODO: tjw? What is this desc thing for?
char desc[115];
int age;
int eff_XPSaveMaxAge_xp = G_getXPSaveMaxAge_xp();
int eff_XPSaveMaxAge = G_getXPSaveMaxAge();
float startxptotal = 0.0f;
if(!ent || !ent->client)
return qfalse;
if(!(g_XPSave.integer & XPSF_ENABLE))
return qfalse;
if(!time(&t))
return qfalse;
desc[0] = '\0';
clientNum = ent - g_entities;
for(i=0; g_xpsaves[i]; i++) {
if(!Q_stricmp(g_xpsaves[i]->guid,
ent->client->sess.guid)) {
found = qtrue;
x = g_xpsaves[i];
break;
}
}
if(!found)
return qfalse;
age = t - x->time;
if(age > eff_XPSaveMaxAge) {
return qfalse;
}
if(age <= eff_XPSaveMaxAge_xp) {
for(i=0; i<SK_NUM_SKILLS; i++) {
ent->client->sess.skillpoints[i] = x->skill[i];
// pheno: fix for session startxptotal value
startxptotal += x->skill[i];
}
ent->client->sess.startxptotal = startxptotal;
ent->client->ps.stats[STAT_XP] =
(int)ent->client->sess.startxptotal;
Q_strcat(desc, sizeof(desc), "XP/");
if((g_XPDecay.integer & XPDF_ENABLE) &&
!(g_XPDecay.integer & XPDF_NO_DISCONNECT_DECAY)) {
G_XPDecay(ent, age, qtrue);
}
}
ent->client->sess.overall_killrating = x->kill_rating;
ent->client->sess.overall_killvariance = x->kill_variance;
//ent->client->sess.playerrating = x->playerrating;
ent->client->sess.rating = x->rating;
ent->client->sess.rating_variance = x->rating_variance;
for(i=0; i<SK_NUM_SKILLS; i++) {
for(j=0; j<NUM_SKILL_LEVELS; j++) {
ent->client->sess.pr_skill_updates[i][j] =
x->pr_skill_updates[i][j];
ent->client->sess.pr_skill[i][j] =
x->pr_skill[i][j];
}
}
Q_strcat(desc, sizeof(desc), "ratings/");
if(x->mutetime != 0) {
if(x->mutetime < 0){
ent->client->sess.auto_unmute_time = -1;
XPSMuted = qtrue;
}else if(x->mutetime > t){
ent->client->sess.auto_unmute_time = (level.time + 1000*(x->mutetime - t));
XPSMuted = qtrue;;
}
if(XPSMuted == qtrue){
CP("print \"^5You've been muted by XPSave\n\"" );
Q_strcat(desc, sizeof(desc), "mute/");
}
}
ent->client->sess.hits = x->hits;
ent->client->sess.team_hits = x->team_hits;
G_CalcRank(ent->client);
BG_PlayerStateToEntityState(&ent->client->ps,
&ent->s,
level.time,
qtrue);
// tjw: trim last / from desc
if(strlen(desc))
//.........这里部分代码省略.........
示例2: G_Script_ScriptParse
//.........这里部分代码省略.........
continue;
}
if ( !Q_stricmp( token, "entity" ) ) {
// this is an entity, so go back to look for a name
continue;
}
if ( !Q_stricmp( ent->scriptName, token ) ) {
inScript = true;
numEventItems = 0;
}
wantName = false;
} else if ( inScript ) {
Q_strlwr( token );
eventNum = G_Script_EventForString( token );
if ( eventNum < 0 ) {
G_Error( "G_Script_ScriptParse(), Error (line %d): unknown event: %s.\n", COM_GetCurrentParseLine(), token );
}
if ( numEventItems >= G_MAX_SCRIPT_STACK_ITEMS ) {
G_Error( "G_Script_ScriptParse(), Error (line %d): G_MAX_SCRIPT_STACK_ITEMS reached (%d)\n", COM_GetCurrentParseLine(), G_MAX_SCRIPT_STACK_ITEMS );
}
curEvent = &events[numEventItems];
curEvent->eventNum = eventNum;
memset( params, 0, sizeof( params ) );
// parse any event params before the start of this event's actions
while ( ( token = COM_Parse( &pScript ) ) != NULL && ( token[0] != '{' ) ) {
if ( !token[0] ) {
G_Error( "G_Script_ScriptParse(), Error (line %d): '}' expected, end of script found.\n", COM_GetCurrentParseLine() );
}
if ( strlen( params ) ) { // add a space between each param
Q_strcat( params, sizeof( params ), " " );
}
Q_strcat( params, sizeof( params ), token );
}
if ( strlen( params ) ) { // copy the params into the event
curEvent->params = G_Alloc( strlen( params ) + 1 );
Q_strncpyz( curEvent->params, params, strlen( params ) + 1 );
}
// parse the actions for this event
while ( ( token = COM_Parse( &pScript ) ) != NULL && ( token[0] != '}' ) ) {
if ( !token[0] ) {
G_Error( "G_Script_ScriptParse(), Error (line %d): '}' expected, end of script found.\n", COM_GetCurrentParseLine() );
}
action = G_Script_ActionForString( token );
if ( !action ) {
G_Error( "G_Script_ScriptParse(), Error (line %d): unknown action: %s.\n", COM_GetCurrentParseLine(), token );
}
curEvent->stack.items[curEvent->stack.numItems].action = action;
memset( params, 0, sizeof( params ) );
// Ikkyo - Parse for {}'s if this is a set command
if ( !Q_stricmp( action->actionString, "set" ) ) {
token = COM_Parse( &pScript );
if ( token[0] != '{' ) {
COM_ParseError( "'{' expected, found: %s.\n", token );
}
while ( ( token = COM_Parse( &pScript ) ) && ( token[0] != '}' ) ) {
示例3: GLSL_GetShaderHeader
static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, int size )
{
float fbufWidthScale, fbufHeightScale;
dest[0] = '\0';
// HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones
if(glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 30))
{
Q_strcat(dest, size, "#version 130\n");
if(shaderType == GL_VERTEX_SHADER_ARB)
{
Q_strcat(dest, size, "#define attribute in\n");
Q_strcat(dest, size, "#define varying out\n");
}
else
{
Q_strcat(dest, size, "#define varying in\n");
Q_strcat(dest, size, "out vec4 out_Color;\n");
Q_strcat(dest, size, "#define gl_FragColor out_Color\n");
}
}
else
{
Q_strcat(dest, size, "#version 120\n");
}
// HACK: add some macros to avoid extra uniforms and save speed and code maintenance
//Q_strcat(dest, size,
// va("#ifndef r_SpecularExponent\n#define r_SpecularExponent %f\n#endif\n", r_specularExponent->value));
//Q_strcat(dest, size,
// va("#ifndef r_SpecularScale\n#define r_SpecularScale %f\n#endif\n", r_specularScale->value));
//Q_strcat(dest, size,
// va("#ifndef r_NormalScale\n#define r_NormalScale %f\n#endif\n", r_normalScale->value));
Q_strcat(dest, size, "#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n");
//Q_strcat(dest, size, va("#ifndef MAX_SHADOWMAPS\n#define MAX_SHADOWMAPS %i\n#endif\n", MAX_SHADOWMAPS));
Q_strcat(dest, size,
va("#ifndef deformGen_t\n"
"#define deformGen_t\n"
"#define DGEN_WAVE_SIN %i\n"
"#define DGEN_WAVE_SQUARE %i\n"
"#define DGEN_WAVE_TRIANGLE %i\n"
"#define DGEN_WAVE_SAWTOOTH %i\n"
"#define DGEN_WAVE_INVERSE_SAWTOOTH %i\n"
"#define DGEN_BULGE %i\n"
"#define DGEN_MOVE %i\n"
"#endif\n",
DGEN_WAVE_SIN,
DGEN_WAVE_SQUARE,
DGEN_WAVE_TRIANGLE,
DGEN_WAVE_SAWTOOTH,
DGEN_WAVE_INVERSE_SAWTOOTH,
DGEN_BULGE,
DGEN_MOVE));
Q_strcat(dest, size,
va("#ifndef tcGen_t\n"
"#define tcGen_t\n"
"#define TCGEN_LIGHTMAP %i\n"
"#define TCGEN_TEXTURE %i\n"
"#define TCGEN_ENVIRONMENT_MAPPED %i\n"
"#define TCGEN_FOG %i\n"
"#define TCGEN_VECTOR %i\n"
"#endif\n",
TCGEN_LIGHTMAP,
TCGEN_TEXTURE,
TCGEN_ENVIRONMENT_MAPPED,
TCGEN_FOG,
TCGEN_VECTOR));
Q_strcat(dest, size,
va("#ifndef colorGen_t\n"
"#define colorGen_t\n"
"#define CGEN_LIGHTING_DIFFUSE %i\n"
"#endif\n",
CGEN_LIGHTING_DIFFUSE));
Q_strcat(dest, size,
va("#ifndef alphaGen_t\n"
"#define alphaGen_t\n"
"#define AGEN_LIGHTING_SPECULAR %i\n"
"#define AGEN_PORTAL %i\n"
"#endif\n",
AGEN_LIGHTING_SPECULAR,
AGEN_PORTAL));
Q_strcat(dest, size,
va("#ifndef texenv_t\n"
"#define texenv_t\n"
"#define TEXENV_MODULATE %i\n"
"#define TEXENV_ADD %i\n"
"#define TEXENV_REPLACE %i\n"
"#endif\n",
GL_MODULATE,
//.........这里部分代码省略.........
示例4: _Datagram_SearchForHosts
static void _Datagram_SearchForHosts (qboolean xmit)
{
int ret;
int n;
int i;
struct qsockaddr readaddr;
struct qsockaddr myaddr;
int control;
dfunc.GetSocketAddr (dfunc.controlSock, &myaddr);
if (xmit)
{
SZ_Clear(&net_message);
// save space for the header, filled in later
MSG_WriteLong(&net_message, 0);
MSG_WriteByte(&net_message, CCREQ_SERVER_INFO);
MSG_WriteString(&net_message, "QUAKE");
MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
*((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
dfunc.Broadcast(dfunc.controlSock, net_message.data, net_message.cursize);
SZ_Clear(&net_message);
}
while ((ret = dfunc.Read (dfunc.controlSock, net_message.data, net_message.maxsize, &readaddr)) > 0)
{
if (ret < sizeof(int))
continue;
net_message.cursize = ret;
// don't answer our own query
if (dfunc.AddrCompare(&readaddr, &myaddr) >= 0)
continue;
// is the cache full?
if (hostCacheCount == HOSTCACHESIZE)
continue;
MSG_BeginReading ();
control = BigLong(*((int *)net_message.data));
MSG_ReadLong();
if (control == -1)
continue;
if ((control & (~NETFLAG_LENGTH_MASK)) != NETFLAG_CTL)
continue;
if ((control & NETFLAG_LENGTH_MASK) != ret)
continue;
if (MSG_ReadByte() != CCREP_SERVER_INFO)
continue;
dfunc.GetAddrFromName(MSG_ReadString(), &readaddr);
// search the cache for this server
for (n = 0; n < hostCacheCount; n++)
if (dfunc.AddrCompare(&readaddr, &hostcache[n].addr) == 0)
break;
// is it already there?
if (n < hostCacheCount)
continue;
// add it
hostCacheCount++;
Q_strcpy(hostcache[n].name, MSG_ReadString());
Q_strcpy(hostcache[n].map, MSG_ReadString());
hostcache[n].users = MSG_ReadByte();
hostcache[n].maxusers = MSG_ReadByte();
if (MSG_ReadByte() != NET_PROTOCOL_VERSION)
{
Q_strcpy(hostcache[n].cname, hostcache[n].name);
hostcache[n].cname[14] = 0;
Q_strcpy(hostcache[n].name, "*");
Q_strcat(hostcache[n].name, hostcache[n].cname);
}
Q_memcpy(&hostcache[n].addr, &readaddr, sizeof(struct qsockaddr));
hostcache[n].driver = net_driverlevel;
hostcache[n].ldriver = net_landriverlevel;
Q_strcpy(hostcache[n].cname, dfunc.AddrToString(&readaddr));
// check for a name conflict
for (i = 0; i < hostCacheCount; i++)
{
if (i == n)
continue;
if (Q_strcasecmp (hostcache[n].name, hostcache[i].name) == 0)
{
i = Q_strlen(hostcache[n].name);
if (i < 15 && hostcache[n].name[i-1] > '8')
{
hostcache[n].name[i] = '0';
hostcache[n].name[i+1] = 0;
}
else
hostcache[n].name[i-1]++;
i = -1;
}
}
}
}
示例5: InitSiegeMode
//.........这里部分代码省略.........
//We could probably just see what teams are used on this level,
//then see what classes are used by those teams, and then precache
//all weapons for said classes. However, I'm just going to do them
//all for now.
while (i < bgNumSiegeClasses)
{
cl = &bgSiegeClasses[i];
j = 0;
while (j < WP_NUM_WEAPONS)
{
if (cl->weapons & (1 << j))
{ //we use this weapon so register it.
RegisterItem(BG_FindItemForWeapon(j));
}
j++;
}
i++;
}
*/
//Ok, I'm adding inventory item precaching now, so I'm finally going to optimize this
//to only do weapons/items for the current teams used on the level.
//Now load the teams since we have class data.
BG_SiegeLoadTeams();
if (!bgNumSiegeTeams)
{ //React same as with classes.
trap->Error( ERR_DROP, "Couldn't find any player teams for Siege" );
}
//Get and set the team themes for each team. This will control which classes can be
//used on each team.
if (BG_SiegeGetValueGroup(siege_info, team1, gParseObjectives))
{
if (BG_SiegeGetPairedValue(gParseObjectives, "UseTeam", goalreq))
{
BG_SiegeSetTeamTheme(SIEGETEAM_TEAM1, goalreq);
}
//Now count up the objectives for this team.
i = 1;
strcpy(objecStr, va("Objective%i", i));
while (BG_SiegeGetValueGroup(gParseObjectives, objecStr, objective))
{
objectiveNumTeam1++;
i++;
strcpy(objecStr, va("Objective%i", i));
}
}
if (BG_SiegeGetValueGroup(siege_info, team2, gParseObjectives))
{
if (BG_SiegeGetPairedValue(gParseObjectives, "UseTeam", goalreq))
{
BG_SiegeSetTeamTheme(SIEGETEAM_TEAM2, goalreq);
}
//Now count up the objectives for this team.
i = 1;
strcpy(objecStr, va("Objective%i", i));
while (BG_SiegeGetValueGroup(gParseObjectives, objecStr, objective))
{
objectiveNumTeam2++;
i++;
strcpy(objecStr, va("Objective%i", i));
}
}
//Set the configstring to show status of all current objectives
strcpy(gObjectiveCfgStr, "t1");
while (objectiveNumTeam1 > 0)
{ //mark them all as not completed since we just initialized
Q_strcat(gObjectiveCfgStr, 1024, "-0");
objectiveNumTeam1--;
}
//Finished doing team 1's objectives, now do team 2's
Q_strcat(gObjectiveCfgStr, 1024, "|t2");
while (objectiveNumTeam2 > 0)
{
Q_strcat(gObjectiveCfgStr, 1024, "-0");
objectiveNumTeam2--;
}
//And finally set the actual config string
trap->SetConfigstring(CS_SIEGE_OBJECTIVES, gObjectiveCfgStr);
//precache saber data for classes that use sabers on both teams
BG_PrecacheSabersForSiegeTeam(SIEGETEAM_TEAM1);
BG_PrecacheSabersForSiegeTeam(SIEGETEAM_TEAM2);
G_SiegeRegisterWeaponsAndHoldables(SIEGETEAM_TEAM1);
G_SiegeRegisterWeaponsAndHoldables(SIEGETEAM_TEAM2);
return;
failure:
siege_valid = 0;
}
示例6: variation
/*
====================
CL_UpdateLevelHunkUsage
This updates the "hunkusage.dat" file with the current map and it's hunk usage count
This is used for level loading, so we can show a percentage bar dependant on the amount
of hunk memory allocated so far
This will be slightly inaccurate if some settings like sound quality are changed, but these
things should only account for a small variation (hopefully)
====================
*/
void CL_UpdateLevelHunkUsage( void ) {
int handle;
char *memlistfile = "hunkusage.dat";
char *buf, *outbuf;
char *buftrav, *outbuftrav;
char *token;
char outstr[256];
int len, memusage;
memusage = Cvar_VariableIntegerValue( "com_hunkused" ) + Cvar_VariableIntegerValue( "hunk_soundadjust" );
len = FS_FOpenFileByMode( memlistfile, &handle, FS_READ );
if ( len >= 0 ) { // the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value
buf = (char *)Z_Malloc( len + 1 );
memset( buf, 0, len + 1 );
outbuf = (char *)Z_Malloc( len + 1 );
memset( outbuf, 0, len + 1 );
FS_Read( (void *)buf, len, handle );
FS_FCloseFile( handle );
// now parse the file, filtering out the current map
buftrav = buf;
outbuftrav = outbuf;
outbuftrav[0] = '\0';
while ( ( token = COM_Parse( &buftrav ) ) && token[0] ) {
if ( !Q_strcasecmp( token, cl.mapname ) ) {
// found a match
token = COM_Parse( &buftrav ); // read the size
if ( token && token[0] ) {
if ( atoi( token ) == memusage ) { // if it is the same, abort this process
Z_Free( buf );
Z_Free( outbuf );
return;
}
}
} else { // send it to the outbuf
Q_strcat( outbuftrav, len + 1, token );
Q_strcat( outbuftrav, len + 1, " " );
token = COM_Parse( &buftrav ); // read the size
if ( token && token[0] ) {
Q_strcat( outbuftrav, len + 1, token );
Q_strcat( outbuftrav, len + 1, "\n" );
} else {
Com_Error( ERR_DROP, "hunkusage.dat file is corrupt\n" );
}
}
}
#ifdef __MACOS__ //DAJ MacOS file typing
{
extern _MSL_IMP_EXP_C long _fcreator, _ftype;
_ftype = 'TEXT';
_fcreator = 'WlfS';
}
#endif
handle = FS_FOpenFileWrite( memlistfile );
if ( handle < 0 ) {
Com_Error( ERR_DROP, "cannot create %s\n", memlistfile );
}
// input file is parsed, now output to the new file
len = strlen( outbuf );
if ( FS_Write( (void *)outbuf, len, handle ) != len ) {
Com_Error( ERR_DROP, "cannot write to %s\n", memlistfile );
}
FS_FCloseFile( handle );
Z_Free( buf );
Z_Free( outbuf );
}
// now append the current map to the current file
FS_FOpenFileByMode( memlistfile, &handle, FS_APPEND );
if ( handle < 0 ) {
Com_Error( ERR_DROP, "cannot write to hunkusage.dat, check disk full\n" );
}
Com_sprintf( outstr, sizeof( outstr ), "%s %i\n", cl.mapname, memusage );
FS_Write( outstr, strlen( outstr ), handle );
FS_FCloseFile( handle );
// now just open it and close it, so it gets copied to the pak dir
len = FS_FOpenFileByMode( memlistfile, &handle, FS_READ );
if ( len >= 0 ) {
FS_FCloseFile( handle );
}
}
示例7: Win_CompleteCommand
/*
==============
Win_CompleteCommand
==============
*/
static void Win_CompleteCommand(qboolean showMatches)
{
field_t *edit = &win_consoleField;
field_t temp;
if (win_acLength == 0)
{
// only look at the first token for completion purposes
Cmd_TokenizeString(edit->buffer);
Q_strncpyz(win_completionString, Cmd_Argv(0), sizeof(win_completionString));
if (win_completionString[0] == '\\' || win_completionString[0] == '/')
{
Q_strncpyz(win_completionString, win_completionString + 1, sizeof(win_completionString));
}
win_matchCount = 0;
win_matchIndex = 0;
win_currentMatch[0] = 0;
if (strlen(win_completionString) == 0)
{
return;
}
Cmd_CommandCompletion(Win_FindMatches);
Cvar_CommandCompletion(Win_FindMatches);
if (win_matchCount == 0)
{
return; // no matches
}
Com_Memcpy(&temp, edit, sizeof(field_t));
if (win_matchCount == 1)
{
Com_sprintf(edit->buffer, sizeof(edit->buffer), "%s", win_currentMatch);
if (Cmd_Argc() == 1)
{
Q_strcat(win_consoleField.buffer, sizeof(win_consoleField.buffer), " ");
}
else
{
Win_ConcatRemaining(temp.buffer, win_completionString);
}
edit->cursor = strlen(edit->buffer);
}
else
{
// multiple matches, complete to shortest
Com_sprintf(edit->buffer, sizeof(edit->buffer), "%s", win_currentMatch);
win_acLength = edit->cursor = strlen(edit->buffer);
Win_ConcatRemaining(temp.buffer, win_completionString);
showMatches = qtrue;
}
}
else if (win_matchCount != 1)
{
// get the next match and show instead
char lastMatch[MAX_TOKEN_CHARS];
Q_strncpyz(lastMatch, win_currentMatch, sizeof(lastMatch));
win_matchIndex++;
if (win_matchIndex == win_matchCount)
{
win_matchIndex = 0;
}
win_findMatchIndex = 0;
Cmd_CommandCompletion(Win_FindIndexMatch);
Cvar_CommandCompletion(Win_FindIndexMatch);
Com_Memcpy(&temp, edit, sizeof(field_t));
// and print it
Com_sprintf(edit->buffer, sizeof(edit->buffer), "%s", win_currentMatch);
edit->cursor = strlen(edit->buffer);
Win_ConcatRemaining(temp.buffer, lastMatch);
}
// hijack it
if (win_matchCount == 1)
{
win_acLength = strlen(win_currentMatch);
}
// run through again, printing matches
if (showMatches && win_matchCount > 0)
{
memcpy(&temp, edit, sizeof(*edit));
temp.buffer[win_acLength] = '\0';
Sys_Print(va("] %s\n", temp.buffer));
//.........这里部分代码省略.........
示例8: CG_CheckSVStringEdRef
void CG_CheckSVStringEdRef(char *buf, const char *str)
{ //I don't really like doing this. But it utilizes the system that was already in place.
int i = 0;
int b = 0;
int strLen = 0;
qboolean gotStrip = qfalse;
if (!str || !str[0])
{
if (str)
{
strcpy(buf, str);
}
return;
}
strcpy(buf, str);
strLen = strlen(str);
if (strLen >= MAX_STRINGED_SV_STRING)
{
return;
}
while (i < strLen && str[i])
{
gotStrip = qfalse;
if (str[i] == '@' && (i+1) < strLen)
{
if (str[i+1] == '@' && (i+2) < strLen)
{
if (str[i+2] == '@' && (i+3) < strLen)
{ //@@@ should mean to insert a StringEd reference here, so insert it into buf at the current place
char stringRef[MAX_STRINGED_SV_STRING];
int r = 0;
/*while (i < strLen && str[i] == '@')
{
i++;
}*/
// Oh c'mon.
i += 3;
while (i < strLen && str[i] && str[i] != ' ' && str[i] != ':' && str[i] != '.' && str[i] != '\n')
{
stringRef[r] = str[i];
r++;
i++;
}
stringRef[r] = 0;
buf[b] = 0;
// Bugfix -> DONT JUMP TO CONCLUSIONS, SILLY RAVEN
{
char buffer2[1024];
strcpy(buffer2, CG_GetStringEdString2(stringRef));
if(Q_stricmp(buffer2, stringRef))
{
Q_strcat(buf, MAX_STRINGED_SV_STRING, buffer2);
return;
}
}
Q_strcat(buf, MAX_STRINGED_SV_STRING, CG_GetStringEdString("MP_SVGAME", stringRef)); // Might be a valid point...but WTF seriously
b = strlen(buf);
}
}
}
if (!gotStrip)
{
buf[b] = str[i];
b++;
}
i++;
}
buf[b] = 0;
}
示例9: main
int main ( int argc, char **argv )
{
char commandLine[ MAX_STRING_CHARS ] = { 0 };
// int startTime, endTime;
SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
// _CrtSetBreakAlloc(34804);
Sys_CreateConsole();
// no abort/retry/fail errors
SetErrorMode( SEM_FAILCRITICALERRORS );
// get the initial time base
Sys_Milliseconds();
Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );
// Concatenate the command line for passing to Com_Init
for( int i = 1; i < argc; i++ )
{
const bool containsSpaces = (strchr(argv[i], ' ') != NULL);
if (containsSpaces)
Q_strcat( commandLine, sizeof( commandLine ), "\"" );
Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] );
if (containsSpaces)
Q_strcat( commandLine, sizeof( commandLine ), "\"" );
Q_strcat( commandLine, sizeof( commandLine ), " " );
}
Com_Init( commandLine );
QuickMemTest();
// hide the early console since we've reached the point where we
// have a working graphics subsystems
if ( !com_viewlog->integer ) {
Sys_ShowConsole( 0, qfalse );
}
// main game loop
while( 1 ) {
// if not running as a game client, sleep a bit
if ( g_wv.isMinimized ) {
Sleep( 5 );
}
#ifdef _DEBUG
if (!g_wv.activeApp)
{
Sleep(50);
}
#endif // _DEBUG
// make sure mouse and joystick are only called once a frame
IN_Frame();
// run the game
Com_Frame();
}
}
示例10: Q_strcpy
bool CMapzoneData::LoadFromFile(const char *szMapName)
{
bool toReturn = false;
char zoneFilePath[MAX_PATH];
Q_strcpy(zoneFilePath, c_mapPath);
Q_strcat(zoneFilePath, szMapName, MAX_PATH);
Q_strncat(zoneFilePath, c_zoneFileEnding, MAX_PATH);
DevLog("Looking for zone file: %s \n", zoneFilePath);
KeyValues* zoneKV = new KeyValues(szMapName);
if (zoneKV->LoadFromFile(filesystem, zoneFilePath, "MOD"))
{
// Go through checkpoints
for (KeyValues *cp = zoneKV->GetFirstSubKey(); cp; cp = cp->GetNextKey())
{
// Load position information (will default to 0 if the keys don't exist)
Vector* pos = new Vector(cp->GetFloat("xPos"), cp->GetFloat("yPos"), cp->GetFloat("zPos"));
QAngle* rot = new QAngle(cp->GetFloat("xRot"), cp->GetFloat("yRot"), cp->GetFloat("zRot"));
Vector* scaleMins = new Vector(cp->GetFloat("xScaleMins"), cp->GetFloat("yScaleMins"), cp->GetFloat("zScaleMins"));
Vector* scaleMaxs = new Vector(cp->GetFloat("xScaleMaxs"), cp->GetFloat("yScaleMaxs"), cp->GetFloat("zScaleMaxs"));
// Do specific things for different types of checkpoints
// 0 = start, 1 = checkpoint, 2 = end, 3 = Onehop, 4 = OnehopReset, 5 = Checkpoint_teleport, 6 = Multihop, 7 = stage
int zoneType = -1;
int index = -1;
bool shouldStop = false;
bool shouldTilt = true;
float holdTime = 1.0f;
//int destinationIndex = -1;
bool limitingspeed = true;
float maxleavespeed = 290.0f;
const char * linkedtrigger = NULL;
if (Q_strcmp(cp->GetName(), "start") == 0)
{
zoneType = MOMZONETYPE_START;
limitingspeed = cp->GetBool("limitingspeed");
maxleavespeed = cp->GetFloat("leavespeed");
}
else if (Q_strcmp(cp->GetName(), "checkpoint") == 0)
{
zoneType = MOMZONETYPE_CP;
index = cp->GetInt("number", -1);
}
else if (Q_strcmp(cp->GetName(), "end") == 0)
{
zoneType = MOMZONETYPE_STOP;
}
else if (Q_strcmp(cp->GetName(), "onehop") == 0)
{
zoneType = MOMZONETYPE_ONEHOP;
shouldStop = cp->GetBool("stop", false);
shouldTilt = cp->GetBool("resetang", true);
holdTime = cp->GetFloat("hold", 1);
//destinationIndex = cp->GetInt("destination", 1);
linkedtrigger = cp->GetString("destinationname", NULL);
}
else if (Q_strcmp(cp->GetName(), "resetonehop") == 0)
{
zoneType = MOMZONETYPE_RESETONEHOP;
}
else if (Q_strcmp(cp->GetName(), "checkpoint_teleport") == 0)
{
zoneType = MOMZONETYPE_CPTELE;
//destinationIndex = cp->GetInt("destination", -1);
shouldStop = cp->GetBool("stop", false);
shouldTilt = cp->GetBool("resetang", true);
linkedtrigger = cp->GetString("destinationname", NULL);
}
else if (Q_strcmp(cp->GetName(), "multihop") == 0)
{
zoneType = MOMZONETYPE_MULTIHOP;
shouldStop = cp->GetBool("stop", false);
shouldTilt = cp->GetBool("resetang", true);
holdTime = cp->GetFloat("hold", 1);
//destinationIndex = cp->GetInt("destination", 1);
linkedtrigger = cp->GetString("destinationname", NULL);
}
else if (Q_strcmp(cp->GetName(), "stage") == 0)
{
zoneType = MOMZONETYPE_STAGE;
index = cp->GetInt("number", 0);
}
else
{
Warning("Error while reading zone file: Unknown mapzone type %s!\n", cp->GetName());
continue;
}
// Add element
m_zones.AddToTail(new CMapzone(zoneType, pos, rot, scaleMins, scaleMaxs, index, shouldStop, shouldTilt,
holdTime, limitingspeed, maxleavespeed, MAKE_STRING(linkedtrigger)));
}
DevLog("Successfully loaded map zone file %s!\n", zoneFilePath);
toReturn = true;
}
zoneKV->deleteThis();
return toReturn;
}
示例11: G_BuildEndgameStats
/**
* @brief - send name, team and value when there is a winner - else empty string
* and TEAM_FREE = 0 (client structure is only used for awards!)
* - connectedClients have a team but keep the check for TEAM_FREE
* ... we'll never know for sure, connectedClients are determined in CalculateRanks
*/
void G_BuildEndgameStats(void)
{
char buffer[1024];
int i, j;
gclient_t *best = NULL;
int bestClientNum = -1;
float mapXP, bestMapXP = 0.f;
G_CalcClientAccuracies();
for (i = 0; i < level.numConnectedClients; i++)
{
level.clients[i].hasaward = qfalse;
}
*buffer = '\0';
// highest ranking officer - check rank, then medals and XP
for (i = 0; i < level.numConnectedClients; i++)
{
gclient_t *cl = &level.clients[level.sortedClients[i]];
if (cl->sess.sessionTeam == TEAM_FREE)
{
continue;
}
if (!best || cl->sess.rank > best->sess.rank)
{
best = cl;
bestClientNum = level.sortedClients[i];
}
else if (cl->sess.rank == best->sess.rank && cl->medals > best->medals)
{
best = cl;
bestClientNum = level.sortedClients[i];
}
else if (cl->sess.rank == best->sess.rank && cl->medals == best->medals && cl->ps.persistant[PERS_SCORE] > best->ps.persistant[PERS_SCORE])
{
best = cl;
bestClientNum = level.sortedClients[i];
}
}
if (best)
{
best->hasaward = qtrue;
Q_strcat(buffer, 1024, va("%i 0 %i ", bestClientNum, best->sess.sessionTeam));
}
else
{
Q_strcat(buffer, 1024, "-1 0 0 ");
}
best = NULL;
#ifdef FEATURE_RATING
// highest rated player - check skill rating
for (i = 0; i < level.numConnectedClients; i++)
{
gclient_t *cl = &level.clients[level.sortedClients[i]];
if (cl->sess.sessionTeam == TEAM_FREE)
{
continue;
}
if (cl->sess.mu - 3 * cl->sess.sigma <= 0)
{
continue;
}
if (!best || (cl->sess.mu - 3 * cl->sess.sigma) > (best->sess.mu - 3 * best->sess.sigma))
{
best = cl;
bestClientNum = level.sortedClients[i];
}
}
if (best)
{
best->hasaward = qtrue;
Q_strcat(buffer, 1024, va("%i %.2f %i ", bestClientNum, MIN(best->sess.mu - 3 * best->sess.sigma, 50.f), best->sess.sessionTeam));
}
else
{
Q_strcat(buffer, 1024, "-1 0 0 ");
}
best = NULL;
#endif
// highest experience points - check XP (total in campaign, otherwise this map only then total XP)
for (i = 0; i < level.numConnectedClients; i++)
//.........这里部分代码省略.........
示例12: saveZonFile
//.........这里部分代码省略.........
subKey = new KeyValues("start");
if (pTrigger)
{
subKey->SetFloat("leavespeed", pTrigger->GetMaxLeaveSpeed());
subKey->SetBool("limitingspeed", pTrigger->IsLimitingSpeed());
}
}
else if (pEnt->ClassMatches("trigger_momentum_timer_stop"))
{
subKey = new KeyValues("end");
}
else if (pEnt->ClassMatches("trigger_momentum_timer_checkpoint"))
{
CTriggerCheckpoint* pTrigger = dynamic_cast<CTriggerCheckpoint*>(pEnt);
if (pTrigger)
{
subKey = new KeyValues("checkpoint");
subKey->SetInt("number", pTrigger->GetCheckpointNumber());
}
}
else if (pEnt->ClassMatches("trigger_momentum_onehop"))
{
CTriggerOnehop* pTrigger = dynamic_cast<CTriggerOnehop*>(pEnt);
if (pTrigger)
{
subKey = new KeyValues("onehop");
//subKey->SetInt("destination", pTrigger->GetDestinationIndex());
subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime());
subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
}
}
else if (pEnt->ClassMatches("trigger_momentum_resetonehop"))
{
subKey = new KeyValues("resetonehop");
}
else if (pEnt->ClassMatches("trigger_momentum_teleport_checkpoint"))
{
CTriggerTeleportCheckpoint* pTrigger = dynamic_cast<CTriggerTeleportCheckpoint*>(pEnt);
if (pTrigger)
{
subKey = new KeyValues("checkpoint_teleport");
//subKey->SetInt("destination", pTrigger->GetDestinationCheckpointNumber());
subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
}
}
else if (pEnt->ClassMatches("trigger_momentum_multihop"))
{
CTriggerMultihop* pTrigger = dynamic_cast<CTriggerMultihop*>(pEnt);
if (pTrigger)
{
subKey = new KeyValues("multihop");
//subKey->SetInt("destination", pTrigger->GetDestinationIndex());
subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime());
subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
}
}
else if (pEnt->ClassMatches("trigger_momentum_timer_stage"))
{
CTriggerStage *pTrigger = dynamic_cast<CTriggerStage*>(pEnt);
if (pTrigger)
{
subKey = new KeyValues("stage");
subKey->SetInt("number", pTrigger->GetStageNumber());
}
}
if (subKey)
{
subKey->SetFloat("xPos", pEnt->GetAbsOrigin().x);
subKey->SetFloat("yPos", pEnt->GetAbsOrigin().y);
subKey->SetFloat("zPos", pEnt->GetAbsOrigin().z);
subKey->SetFloat("xRot", pEnt->GetAbsAngles().x);
subKey->SetFloat("yRot", pEnt->GetAbsAngles().y);
subKey->SetFloat("zRot", pEnt->GetAbsAngles().z);
subKey->SetFloat("xScaleMins", pEnt->WorldAlignMins().x);
subKey->SetFloat("yScaleMins", pEnt->WorldAlignMins().y);
subKey->SetFloat("zScaleMins", pEnt->WorldAlignMins().z);
subKey->SetFloat("xScaleMaxs", pEnt->WorldAlignMaxs().x);
subKey->SetFloat("yScaleMaxs", pEnt->WorldAlignMaxs().y);
subKey->SetFloat("zScaleMaxs", pEnt->WorldAlignMaxs().z);
zoneKV->AddSubKey(subKey);
}
pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_*");
}
if (zoneKV->GetFirstSubKey())//not empty
{
char zoneFilePath[MAX_PATH];
Q_strcpy(zoneFilePath, "maps/");
Q_strcat(zoneFilePath, szMapName, MAX_PATH);
Q_strncat(zoneFilePath, ".zon", MAX_PATH);
zoneKV->SaveToFile(filesystem, zoneFilePath, "MOD");
zoneKV->deleteThis();
}
}
示例13: CL_LanguageTest
/**
* @brief Test given language by trying to set locale.
* @param[in] localeID language abbreviation.
* @return true if setting given language is possible.
*/
static bool CL_LanguageTest (const char* localeID)
{
#ifndef _WIN32
int i;
language_t* language;
localeMapping_t* mapping;
#endif
char languagePath[MAX_OSPATH];
assert(localeID);
/* Find the proper *.mo file. */
if (fs_i18ndir->string[0] != '\0')
Q_strncpyz(languagePath, fs_i18ndir->string, sizeof(languagePath));
else
#ifdef LOCALEDIR
Com_sprintf(languagePath, sizeof(languagePath), LOCALEDIR);
#else
Com_sprintf(languagePath, sizeof(languagePath), "%s/" BASEDIRNAME "/i18n/", FS_GetCwd());
#endif
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: using mo files from '%s'\n", languagePath);
Q_strcat(languagePath, sizeof(languagePath), "%s/LC_MESSAGES/ufoai.mo", localeID);
/* No *.mo file -> no language. */
if (!FS_FileExists("%s", languagePath)) {
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: locale '%s' not found.\n", localeID);
return false;
}
#ifdef _WIN32
if (Sys_Setenv("LANGUAGE=%s", localeID) == 0) {
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: locale '%s' found.\n", localeID);
return true;
}
#else
for (i = 0, language = languageList; i < languageCount; language = language->next, i++) {
if (Q_streq(localeID, language->localeID))
break;
}
if (i == languageCount) {
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: Could not find locale with id '%s'\n", localeID);
return false;
}
mapping = language->localeMapping;
if (!mapping) {
Com_DPrintf(DEBUG_CLIENT, "No locale mappings for locale with id '%s'\n", localeID);
return false;
}
/* Cycle through all mappings, but stop at first locale possible to set. */
do {
/* setlocale() will return nullptr if no setting possible. */
if (setlocale(LC_MESSAGES, mapping->localeMapping)) {
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: language '%s' with locale '%s' found.\n", localeID, mapping->localeMapping);
return true;
} else
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: language '%s' with locale '%s' not found on your system.\n", localeID, mapping->localeMapping);
mapping = mapping->next;
} while (mapping);
Com_DPrintf(DEBUG_CLIENT, "CL_LanguageTest: not possible to use language '%s'.\n", localeID);
#endif
return false;
}
示例14: UP_AircraftItemDescription
/**
* @brief Prints the (UFOpaedia and other) description for aircraft items
* @param item The object definition of the item
* @sa UP_Article
* Not only called from UFOpaedia but also from other places to display
* @todo Don't display things like speed for base defence items - a missile
* facility isn't getting slower or faster due a special weapon or ammunition
*/
void UP_AircraftItemDescription (const objDef_t* item)
{
static char itemText[1024];
const technology_t* tech;
/* Set menu text node content to null. */
cgi->INV_ItemDescription(nullptr);
*itemText = '\0';
/* no valid item id given */
if (!item) {
cgi->Cvar_Set("mn_item", "");
cgi->Cvar_Set("mn_itemname", "");
cgi->Cvar_Set("mn_upmodel_top", "");
cgi->UI_ResetData(TEXT_ITEMDESCRIPTION);
return;
}
tech = RS_GetTechForItem(item);
/* select item */
cgi->Cvar_Set("mn_item", "%s", item->id);
cgi->Cvar_Set("mn_itemname", "%s", _(item->name));
if (tech->mdl)
cgi->Cvar_Set("mn_upmodel_top", "%s", tech->mdl);
else
cgi->Cvar_Set("mn_upmodel_top", "");
/* set description text */
if (RS_IsResearched_ptr(tech)) {
const objDef_t* ammo = nullptr;
switch (item->craftitem.type) {
case AC_ITEM_WEAPON:
Q_strcat(itemText, sizeof(itemText), _("Weight:\t%s\n"), AII_WeightToName(AII_GetItemWeightBySize(item)));
break;
case AC_ITEM_BASE_MISSILE:
case AC_ITEM_BASE_LASER:
Q_strcat(itemText, sizeof(itemText), _("Weapon for base defence system\n"));
break;
case AC_ITEM_AMMO:
ammo = item;
break;
default:
break;
}
/* check ammo of weapons */
if (item->craftitem.type <= AC_ITEM_WEAPON) {
for(int i = 0; i < item->numAmmos; i++)
if (item->ammos[i]->isVirtual) {
ammo = item->ammos[i];
break;
}
}
if (ammo) {
/* We display the characteristics of this ammo */
Q_strcat(itemText, sizeof(itemText), _("Ammo:\t%i\n"), ammo->ammo);
if (!EQUAL(ammo->craftitem.weaponDamage, 0))
Q_strcat(itemText, sizeof(itemText), _("Damage:\t%i\n"), (int) ammo->craftitem.weaponDamage);
Q_strcat(itemText, sizeof(itemText), _("Reloading time:\t%i\n"), (int) ammo->craftitem.weaponDelay);
}
/* We write the range of the weapon */
if (!EQUAL(item->craftitem.stats[AIR_STATS_WRANGE], 0))
Q_strcat(itemText, sizeof(itemText), "%s:\t%i\n", UP_AircraftStatToName(AIR_STATS_WRANGE),
AIR_AircraftMenuStatsValues(item->craftitem.stats[AIR_STATS_WRANGE], AIR_STATS_WRANGE));
/* we scan all stats except weapon range */
for (int i = 0; i < AIR_STATS_MAX; i++) {
const char* statsName = UP_AircraftStatToName(i);
if (i == AIR_STATS_WRANGE)
continue;
if (item->craftitem.stats[i] > 2.0f)
Q_strcat(itemText, sizeof(itemText), "%s:\t+%i\n", statsName, AIR_AircraftMenuStatsValues(item->craftitem.stats[i], i));
else if (item->craftitem.stats[i] < -2.0f)
Q_strcat(itemText, sizeof(itemText), "%s:\t%i\n", statsName, AIR_AircraftMenuStatsValues(item->craftitem.stats[i], i));
else if (item->craftitem.stats[i] > 1.0f)
Q_strcat(itemText, sizeof(itemText), _("%s:\t+%i %%\n"), statsName, (int)(item->craftitem.stats[i] * 100) - 100);
else if (!EQUAL(item->craftitem.stats[i], 0))
Q_strcat(itemText, sizeof(itemText), _("%s:\t%i %%\n"), statsName, (int)(item->craftitem.stats[i] * 100) - 100);
}
} else {
Q_strcat(itemText, sizeof(itemText), _("Unknown - need to research this"));
}
cgi->Cvar_Set("mn_upmetadata", "1");
cgi->UI_RegisterText(TEXT_ITEMDESCRIPTION, itemText);
}
示例15: Cmd_CheckMapsList_R
//.........这里部分代码省略.........
{
int num_spawnpoints = 0;
dheader_t *header;
Q_memset( buf, 0, MAX_SYSPATH );
FS_Read( f, buf, MAX_SYSPATH );
ver = *(uint *)buf;
switch( ver )
{
case Q1BSP_VERSION:
case HLBSP_VERSION:
case XTBSP_VERSION:
header = (dheader_t *)buf;
if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 )
{
lumpofs = header->lumps[LUMP_PLANES].fileofs;
lumplen = header->lumps[LUMP_PLANES].filelen;
}
else
{
lumpofs = header->lumps[LUMP_ENTITIES].fileofs;
lumplen = header->lumps[LUMP_ENTITIES].filelen;
}
break;
}
Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename ));
FS_StripExtension( entfilename );
FS_DefaultExtension( entfilename, ".ent" );
ents = FS_LoadFile( entfilename, NULL, true );
if( !ents && lumplen >= 10 )
{
FS_Seek( f, lumpofs, SEEK_SET );
ents = (char *)Mem_Alloc( host.mempool, lumplen + 1 );
FS_Read( f, ents, lumplen );
}
if( ents )
{
// if there are entities to parse, a missing message key just
// means there is no title, so clear the message string now
char token[2048];
qboolean worldspawn = true;
Q_strncpy( message, "No Title", MAX_STRING );
pfile = ents;
while(( pfile = COM_ParseFile( pfile, token )) != NULL )
{
if( token[0] == '}' && worldspawn )
worldspawn = false;
else if( !Q_strcmp( token, "message" ) && worldspawn )
{
// get the message contents
pfile = COM_ParseFile( pfile, message );
}
else if( !Q_strcmp( token, "classname" ))
{
pfile = COM_ParseFile( pfile, token );
if( !Q_strcmp( token, GI->mp_entity ))
num_spawnpoints++;
}
if( num_spawnpoints ) break; // valid map
}
Mem_Free( ents );
}
if( f ) FS_Close( f );
if( num_spawnpoints )
{
// format: mapname "maptitle"\n
Q_sprintf( result, "%s \"%s\"\n", mapname, message );
Q_strcat( buffer, result ); // add new string
}
}
}
if( t ) Mem_Free( t ); // free search result
size = Q_strlen( buffer );
if( !size )
{
if( buffer ) Mem_Free( buffer );
if( onlyingamedir )
return Cmd_CheckMapsList_R( fRefresh, false );
return false;
}
// write generated maps.lst
if( FS_WriteFile( "maps.lst", buffer, Q_strlen( buffer )))
{
if( buffer ) Mem_Free( buffer );
return true;
}
return false;
}