本文整理汇总了C++中CopyString函数的典型用法代码示例。如果您正苦于以下问题:C++ CopyString函数的具体用法?C++ CopyString怎么用?C++ CopyString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CopyString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyString
OptFitDescription::OptFitDescription()
{
CopyString(fitID, "CompFit", fitIDLen);
}
示例2: OpenAsFile
void OpenAsFile(const char* fName, bool openForRead)
{
CopyString(currConfigFileName, fName, stdFileStrLen);
cfgObject = &txtCfgFile;
txtCfgFile.OpenFile(fName, openForRead);
}
示例3: FlocaleCharsetSetFlocaleCharset
void FlocaleCharsetSetFlocaleCharset(
Display *dpy, FlocaleFont *flf, char *hints, char *encoding,
char *module)
{
char *charset = NULL;
char *iconv = NULL;
Bool iconv_found = False;
int i = 0;
FlocaleCharsetInit(dpy, module);
if (hints && *hints)
{
iconv = GetQuotedString(
hints, &charset, "/", NULL, NULL, NULL);
if (charset && *charset && *charset != '*' )
{
flf->fc = FlocaleCharsetOfXCharset(charset);
}
if (flf->fc == NULL && charset && *charset && *charset != '*')
{
flf->fc = FlocaleCharsetOfLocaleCharset(charset);
}
if (flf->fc == NULL && iconv && *iconv)
{
flf->fc = FlocaleCharsetOfLocaleCharset(iconv);
}
}
if (flf->fc == NULL)
{
if (FftSupport && flf->fftf.fftfont != NULL)
{
flf->fc = FlocaleCharsetOfXCharset(flf->fftf.encoding);
}
else if (flf->fontset != None)
{
if (FLCXOMCharset != NULL)
{
flf->fc = FLCXOMCharset;
}
else
{
/* we are here if !HAVE_XOUTPUT_METHOD */
XFontStruct **fs_list;
char **ml;
if (XFontsOfFontSet(
flf->fontset, &fs_list, &ml) > 0)
{
flf->fc = FLCXOMCharset =
FlocaleCharsetOfFontStruct(
dpy, fs_list[0]);
}
}
}
else if (flf->font != NULL)
{
flf->fc = FlocaleCharsetOfFontStruct(dpy, flf->font);
}
}
if (flf->fc != NULL && iconv && *iconv)
{
/* the user has specified an iconv converter name:
* check if we have it and force user choice */
while(!iconv_found &&
FLC_GET_LOCALE_CHARSET(flf->fc,i) != NULL)
{
if (
strcmp(
iconv,
FLC_GET_LOCALE_CHARSET(flf->fc,i)) ==
0)
{
iconv_found = True;
/* Trust the user? yes ... */
FLC_SET_ICONV_INDEX(flf->fc,i);
}
i++;
}
}
if (iconv && *iconv && !iconv_found)
{
FlocaleCharset *fc;
/* the user has specified an iconv converter name and we do not
* have it: must create a FlocaleCharset */
flf->flags.must_free_fc = True;
fc = (FlocaleCharset *)safemalloc(sizeof(FlocaleCharset));
if (flf->fc != NULL)
{
CopyString(&fc->x, flf->fc->x);
fc->encoding_type = flf->fc->encoding_type;
if (flf->fc->bidi)
CopyString(&fc->bidi, flf->fc->bidi);
else
fc->bidi = NULL;
}
else
{
CopyString(&fc->x, "Unknown"); /* for simplicity */
//.........这里部分代码省略.........
示例4: SV_SetConfigstring
/*
===============
SV_SetConfigstring
===============
*/
void SV_SetConfigstring (int index, const char *val) {
int len, i;
int maxChunkSize = MAX_STRING_CHARS - 24;
client_t *client;
if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
Com_Error (ERR_DROP, "SV_SetConfigstring: bad index %i\n", index);
}
if ( !val ) {
val = "";
}
// don't bother broadcasting an update if no change
if ( !strcmp( val, sv.configstrings[ index ] ) ) {
return;
}
// change the string in sv
Z_Free( sv.configstrings[index] );
sv.configstrings[index] = CopyString( val );
// send it to all the clients if we aren't
// spawning a new server
if ( sv.state == SS_GAME || sv.restarting ) {
// send the data to all relevent clients
for (i = 0, client = svs.clients; i < sv_maxclients->integer ; i++, client++) {
if ( client->state < CS_PRIMED ) {
continue;
}
// do not always send server info to all clients
if ( index == CS_SERVERINFO && client->gentity && (client->gentity->r.svFlags & SVF_NOSERVERINFO) ) {
continue;
}
len = strlen( val );
if( len >= maxChunkSize ) {
int sent = 0;
int remaining = len;
char *cmd;
char buf[MAX_STRING_CHARS];
while (remaining > 0 ) {
if ( sent == 0 ) {
cmd = "bcs0";
}
else if( remaining < maxChunkSize ) {
cmd = "bcs2";
}
else {
cmd = "bcs1";
}
Q_strncpyz( buf, &val[sent], maxChunkSize );
SV_SendServerCommand( client, "%s %i \"%s\"\n", cmd, index, buf );
sent += (maxChunkSize - 1);
remaining -= (maxChunkSize - 1);
}
} else {
// standard cs, just send it
SV_SendServerCommand( client, "cs %i \"%s\"\n", index, val );
}
}
}
}
示例5: Com_Error
/*
============
Cvar_Get
If the variable already exists, the value will not be set unless CVAR_ROM
The flags will be or'ed in if the variable exists.
============
*/
cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
cvar_t *var;
long hash;
if ( !var_name || ! var_value ) {
Com_Error( ERR_FATAL, "Cvar_Get: NULL parameter" );
}
if ( !Cvar_ValidateString( var_name ) ) {
Com_Printf("invalid cvar name string: %s\n", var_name );
var_name = "BADNAME";
}
#if 0 // FIXME: values with backslash happen
if ( !Cvar_ValidateString( var_value ) ) {
Com_Printf("invalid cvar value string: %s\n", var_value );
var_value = "BADVALUE";
}
#endif
var = Cvar_FindVar (var_name);
if ( var ) {
// if the C code is now specifying a variable that the user already
// set a value for, take the new value as the reset value
if ( ( var->flags & CVAR_USER_CREATED ) && !( flags & CVAR_USER_CREATED )
&& var_value[0] ) {
var->flags &= ~CVAR_USER_CREATED;
Z_Free( var->resetString );
var->resetString = CopyString( var_value );
// ZOID--needs to be set so that cvars the game sets as
// SERVERINFO get sent to clients
cvar_modifiedFlags |= flags;
}
var->flags |= flags;
// only allow one non-empty reset string without a warning
if ( !var->resetString[0] ) {
// we don't have a reset string yet
Z_Free( var->resetString );
var->resetString = CopyString( var_value );
} else if ( var_value[0] && strcmp( var->resetString, var_value ) ) {
Com_DPrintf( "Warning: cvar \"%s\" given initial values: \"%s\" and \"%s\"\n",
var_name, var->resetString, var_value );
}
// if we have a latched string, take that value now
if ( var->latchedString ) {
char *s;
s = var->latchedString;
var->latchedString = NULL; // otherwise cvar_set2 would free it
Cvar_Set2( var_name, s, qtrue );
Z_Free( s );
}
// use a CVAR_SET for rom sets, get won't override
#if 0
// CVAR_ROM always overrides
if ( flags & CVAR_ROM ) {
Cvar_Set2( var_name, var_value, qtrue );
}
#endif
return var;
}
//
// allocate a new cvar
//
if ( cvar_numIndexes >= MAX_CVARS ) {
Com_Error( ERR_FATAL, "MAX_CVARS" );
}
var = &cvar_indexes[cvar_numIndexes];
cvar_numIndexes++;
var->name = CopyString (var_name);
var->string = CopyString (var_value);
var->modified = qtrue;
var->modificationCount = 1;
var->value = atof (var->string);
var->integer = atoi(var->string);
var->resetString = CopyString( var_value );
// link the variable in
var->next = cvar_vars;
cvar_vars = var;
var->flags = flags;
hash = generateHashValue(var_name);
var->hashNext = hashTable[hash];
hashTable[hash] = var;
return var;
//.........这里部分代码省略.........
示例6: Com_Printf
/*
============
Cvar_Set2
============
*/
cvar_t *Cvar_Set2( const char *var_name, const char *value, uint32_t defaultFlags, qboolean force ) {
cvar_t *var;
if ( !Cvar_ValidateString( var_name ) ) {
Com_Printf("invalid cvar name string: %s\n", var_name );
var_name = "BADNAME";
}
#if 0 // FIXME
if ( value && !Cvar_ValidateString( value ) ) {
Com_Printf("invalid cvar value string: %s\n", value );
var_value = "BADVALUE";
}
#endif
var = Cvar_FindVar (var_name);
if (!var) {
if ( !value ) {
return NULL;
}
// create it
return Cvar_Get( var_name, value, defaultFlags );
}
if (!value ) {
value = var->resetString;
}
value = Cvar_Validate(var, value, qtrue);
if((var->flags & CVAR_LATCH) && var->latchedString)
{
if(!strcmp(value, var->string))
{
Cvar_FreeString(var->latchedString);
var->latchedString = NULL;
return var;
}
if(!strcmp(value, var->latchedString))
return var;
}
else if(!strcmp(value, var->string))
return var;
// note what types of cvars have been modified (userinfo, archive, serverinfo, systeminfo)
cvar_modifiedFlags |= var->flags;
if (!force)
{
if ( (var->flags & (CVAR_SYSTEMINFO|CVAR_SERVER_CREATED)) && com_sv_running && !com_sv_running->integer && CL_ConnectedToServer() )
{
Com_Printf ("%s can only be set by server.\n", var_name);
return var;
}
if (var->flags & CVAR_ROM)
{
Com_Printf ("%s is read only.\n", var_name);
return var;
}
if (var->flags & CVAR_INIT)
{
Com_Printf ("%s is write protected.\n", var_name);
return var;
}
if (var->flags & CVAR_LATCH)
{
if (var->latchedString)
{
if (strcmp(value, var->latchedString) == 0)
return var;
Cvar_FreeString (var->latchedString);
}
else
{
if (strcmp(value, var->string) == 0)
return var;
}
Com_Printf ("%s will be changed upon restarting.\n", var_name);
var->latchedString = CopyString(value);
var->modified = qtrue;
var->modificationCount++;
return var;
}
if ( (var->flags & CVAR_CHEAT) && !cvar_cheats->integer )
{
Com_Printf ("%s is cheat protected.\n", var_name);
return var;
}
}
//.........这里部分代码省略.........
示例7: Cvar_FindVar
/*
============
Cvar_Set2
============
*/
cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
{
cvar_t *var;
var = Cvar_FindVar (var_name);
if (!var)
{ // create it
return Cvar_Get (var_name, value, 0);
}
if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO))
{
if (!Cvar_InfoValidate (value))
{
Com_Printf("invalid info cvar value\n");
return var;
}
}
if (!force)
{
if (var->flags & CVAR_NOSET)
{
Com_Printf ("%s is write protected.\n", var_name);
return var;
}
if (var->flags & CVAR_LATCH)
{
if (var->latched_string)
{
if (strcmp(value, var->latched_string) == 0)
return var;
Z_Free (var->latched_string);
}
else
{
if (strcmp(value, var->string) == 0)
return var;
}
if (Com_ServerState())
{
Com_Printf ("%s will be changed for next game.\n", var_name);
var->latched_string = CopyString(value);
}
else
{
var->string = CopyString(value);
var->value = atof (var->string);
if (!strcmp(var->name, "game"))
{
FS_SetGamedir (var->string);
FS_ExecAutoexec ();
}
}
return var;
}
}
else
{
if (var->latched_string)
{
Z_Free (var->latched_string);
var->latched_string = NULL;
}
}
if (!strcmp(value, var->string))
return var; // not changed
var->modified = true;
if (var->flags & CVAR_USERINFO)
userinfo_modified = true; // transmit at next oportunity
Z_Free (var->string); // free the old value string
var->string = CopyString(value);
var->value = atof (var->string);
return var;
}
示例8: SV_SpawnServer
void SV_SpawnServer( char *mapname, qboolean killBots, cb_context_t *after ) {
int i;
cb_context_t *context;
spawnserver_data_t *data;
// shut down the existing game if it is running
SV_ShutdownGameProgs();
Com_Printf ("------ Server Initialization ------\n");
Com_Printf ("Server: %s\n",mapname);
// if not running a dedicated server CL_MapLoading will connect the client to the server
// also print some status stuff
CL_MapLoading();
// make sure all the client stuff is unloaded
CL_ShutdownAll(qfalse);
// clear the whole hunk because we're (re)loading the server
Hunk_Clear();
// clear collision map data
CM_ClearMap();
// init client structures and svs.numSnapshotEntities
if ( !Cvar_VariableValue("sv_running") ) {
SV_Startup();
} else {
// check for maxclients change
if ( sv_maxclients->modified ) {
SV_ChangeMaxClients();
}
}
// clear pak references
FS_ClearPakReferences(0);
// allocate the snapshot entities on the hunk
svs.snapshotEntities = Hunk_Alloc( sizeof(entityState_t)*svs.numSnapshotEntities, h_high );
svs.nextSnapshotEntities = 0;
// toggle the server bit so clients can detect that a
// server has changed
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// set nextmap to the same map, but it may be overriden
// by the game startup or another console command
Cvar_Set( "nextmap", "map_restart 0");
// Cvar_Set( "nextmap", va("map %s", server) );
for (i=0 ; i<sv_maxclients->integer ; i++) {
// save when the server started for each client already connected
if (svs.clients[i].state >= CS_CONNECTED) {
svs.clients[i].oldServerTime = sv.time;
}
}
// wipe the entire per-level structure
SV_ClearServer();
for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
sv.configstrings[i] = CopyString("");
}
// make sure we are not paused
Cvar_Set("cl_paused", "0");
// set serverinfo visible name
Cvar_Set("mapname", mapname);
// get a new checksum feed and restart the file system
sv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds();
// Setup callback context.
context = cb_create_context( SV_SpawnServer_after_FS_Restart, spawnserver_data_t );
data = (spawnserver_data_t *)context->data;
Q_strncpyz(data->mapname, mapname, MAX_QPATH);
data->killBots = killBots;
data->after = after;
FS_Restart( sv.checksumFeed, context );
}
示例9: CL_UISystemCalls
//.........这里部分代码省略.........
case UI_STRNCPY:
strncpy( VMA(1), VMA(2), args[3] );
return args[1];
case UI_SIN:
return FloatAsInt( sin( VMF(1) ) );
case UI_COS:
return FloatAsInt( cos( VMF(1) ) );
case UI_ATAN2:
return FloatAsInt( atan2( VMF(1), VMF(2) ) );
case UI_SQRT:
return FloatAsInt( sqrt( VMF(1) ) );
case UI_FLOOR:
return FloatAsInt( floor( VMF(1) ) );
case UI_CEIL:
return FloatAsInt( ceil( VMF(1) ) );
case UI_PC_ADD_GLOBAL_DEFINE:
return botlib_export->PC_AddGlobalDefine( VMA(1) );
case UI_PC_LOAD_SOURCE:
return botlib_export->PC_LoadSourceHandle( VMA(1) );
case UI_PC_FREE_SOURCE:
return botlib_export->PC_FreeSourceHandle( args[1] );
case UI_PC_READ_TOKEN:
return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) );
case UI_PC_SOURCE_FILE_AND_LINE:
return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );
case UI_S_STOPBACKGROUNDTRACK:
S_StopBackgroundTrack();
return 0;
case UI_S_STARTBACKGROUNDTRACK:
S_StartBackgroundTrack( VMA(1), VMA(2));
return 0;
case UI_REAL_TIME:
return Com_RealTime( VMA(1) );
case UI_CIN_PLAYCINEMATIC:
Com_DPrintf("UI_CIN_PlayCinematic\n");
return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);
case UI_CIN_STOPCINEMATIC:
return CIN_StopCinematic(args[1]);
case UI_CIN_RUNCINEMATIC:
return CIN_RunCinematic(args[1]);
case UI_CIN_DRAWCINEMATIC:
CIN_DrawCinematic(args[1]);
return 0;
case UI_CIN_SETEXTENTS:
CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
return 0;
case UI_R_REMAP_SHADER:
re.RemapShader( VMA(1), VMA(2), VMA(3) );
return 0;
case UI_VERIFY_CDKEY:
return CL_CDKeyValidate(VMA(1), VMA(2));
#ifdef USE_AUTH
case UI_NET_STRINGTOADR:
return NET_StringToAdr(VMA(1), VMA(2), NA_IP);
case UI_Q_VSNPRINTF:
return Q_vsnprintf(VMA(1), (size_t)VMA(2), VMA(3), VMA(4));
case UI_NET_SENDPACKET:
{
netadr_t addr;
const char *destination = VMA(4);
NET_StringToAdr(destination, &addr, NA_IP);
NET_SendPacket(args[1], args[2], VMA(3), addr);
}
return 0;
case UI_COPYSTRING:
return (intptr_t)CopyString(VMA(1));
case UI_SYS_STARTPROCESS:
//Sys_StartProcess(VMA(1), (qboolean) VMA(2));
return 0;
#endif
default:
Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] );
}
return 0;
}
示例10: Com_Error
/*
============
Cvar_Get
If the variable already exists, the value will not be set unless CVAR_ROM
The flags will be or'ed in if the variable exists.
============
*/
cvar_t *Cvar_Get(const char *var_name, const char *var_value, int flags)
{
cvar_t *var;
long hash;
if (!var_name || !var_value)
{
Com_Error(ERR_FATAL, "Cvar_Get: NULL parameter\n");
}
if (!Cvar_ValidateString(var_name))
{
Com_Printf("invalid cvar name string: %s\n", var_name);
var_name = "BADNAME";
}
#if 0 // FIXME: values with backslash happen
if (!Cvar_ValidateString(var_value))
{
Com_Printf("invalid cvar value string: %s\n", var_value);
var_value = "BADVALUE";
}
#endif
var = Cvar_FindVar(var_name);
if (var)
{
// if the C code is now specifying a variable that the user already
// set a value for, take the new value as the reset value
if ((var->flags & CVAR_USER_CREATED) && !(flags & CVAR_USER_CREATED)
&& var_value[0])
{
var->flags &= ~CVAR_USER_CREATED;
Z_Free(var->resetString);
var->resetString = CopyString(var_value);
// ZOID--needs to be set so that cvars the game sets as
// SERVERINFO get sent to clients
cvar_modifiedFlags |= flags;
}
var->flags |= flags;
// only allow one non-empty reset string without a warning
if (!var->resetString[0])
{
// we don't have a reset string yet
Z_Free(var->resetString);
var->resetString = CopyString(var_value);
}
else if (var_value[0] && strcmp(var->resetString, var_value))
{
Com_DPrintf("Warning: cvar \"%s\" given initial values: \"%s\" and \"%s\"\n",
var_name, var->resetString, var_value);
}
// if we have a latched string, take that value now
if (var->latchedString)
{
char *s;
s = var->latchedString;
var->latchedString = NULL; // otherwise cvar_set2 would free it
Cvar_Set2(var_name, s, qtrue);
Z_Free(s);
}
// if CVAR_USERINFO was toggled on for an existing cvar, check wether the value needs to be cleaned from foreigh characters
// (for instance, seta name "name-with-foreign-chars" in the config file, and toggle to CVAR_USERINFO happens later in CL_Init)
if (flags & CVAR_USERINFO)
{
char *cleaned = Cvar_ClearForeignCharacters(var->string); // NOTE: it is probably harmless to call Cvar_Set2 in all cases, but I don't want to risk it
if (strcmp(var->string, cleaned))
{
Cvar_Set2(var->name, var->string, qfalse); // call Cvar_Set2 with the value to be cleaned up for verbosity
}
}
// use a CVAR_SET for rom sets, get won't override
#if 0
// CVAR_ROM always overrides
if (flags & CVAR_ROM)
{
Cvar_Set2(var_name, var_value, qtrue);
}
#endif
return var;
}
// allocate a new cvar
if (cvar_numIndexes >= MAX_CVARS)
{
Com_Error(ERR_FATAL, "Cvar_Get: MAX_CVARS (%d) hit -- too many cvars!\n", MAX_CVARS);
//.........这里部分代码省略.........
示例11: Com_DPrintf
//.........这里部分代码省略.........
#endif
Com_Printf("Using %s instead of %s\n", cleaned, value);
return Cvar_Set2(var_name, cleaned, force);
}
}
if (!strcmp(value, var->string))
{
if ((var->flags & CVAR_LATCH) && var->latchedString)
{
if (!strcmp(value, var->latchedString))
{
return var;
}
}
else
{
return var;
}
}
// note what types of cvars have been modified (userinfo, archive, serverinfo, systeminfo)
cvar_modifiedFlags |= var->flags;
if (!force)
{
// don't set unsafe variables when com_crashed is set
if ((var->flags & CVAR_UNSAFE) && com_crashed != NULL && com_crashed->integer)
{
Com_Printf("%s is unsafe. Check com_crashed.\n", var_name);
return var;
}
if (var->flags & CVAR_ROM)
{
Com_Printf("%s is read only.\n", var_name);
return var;
}
if (var->flags & CVAR_INIT)
{
Com_Printf("%s is write protected.\n", var_name);
return var;
}
if ((var->flags & CVAR_CHEAT) && !cvar_cheats->integer)
{
Com_Printf("%s is cheat protected.\n", var_name);
return var;
}
if (var->flags & CVAR_LATCH)
{
if (var->latchedString)
{
if (strcmp(value, var->latchedString) == 0)
{
return var;
}
Z_Free(var->latchedString);
}
else
{
if (strcmp(value, var->string) == 0)
{
return var;
}
}
Com_Printf("%s will be changed upon restarting.\n", var_name);
var->latchedString = CopyString(value);
var->modified = qtrue;
var->modificationCount++;
return var;
}
}
else
{
if (var->latchedString)
{
Z_Free(var->latchedString);
var->latchedString = NULL;
}
}
if (!strcmp(value, var->string))
{
return var; // not changed
}
var->modified = qtrue;
var->modificationCount++;
Z_Free(var->string); // free the old value string
var->string = CopyString(value);
var->value = atof(var->string);
var->integer = atoi(var->string);
return var;
}
示例12: list_new_desk
/***********************************************************************
*
* Procedure:
* list_new_desk - displays packet contents to stderr
*
***********************************************************************/
void list_new_desk(unsigned long *body)
{
int oldDesk;
int change_cs = -1;
int change_ballooncs = -1;
int change_highcs = -1;
oldDesk = Scr.CurrentDesk;
Scr.CurrentDesk = (long)body[0];
if (fAlwaysCurrentDesk && oldDesk != Scr.CurrentDesk)
{
PagerWindow *t;
PagerStringList *item;
char line[100];
desk1 = Scr.CurrentDesk;
desk2 = Scr.CurrentDesk;
for (t = Start; t != NULL; t = t->next)
{
if (t->desk == oldDesk || t->desk == Scr.CurrentDesk)
ChangeDeskForWindow(t, t->desk);
}
item = FindDeskStrings(Scr.CurrentDesk);
if (Desks[0].label != NULL)
{
free(Desks[0].label);
Desks[0].label = NULL;
}
if (item->next != NULL && item->next->label != NULL)
{
CopyString(&Desks[0].label, item->next->label);
}
else
{
sprintf(line, "Desk %d", desk1);
CopyString(&Desks[0].label, line);
}
XStoreName(dpy, Scr.Pager_w, Desks[0].label);
XSetIconName(dpy, Scr.Pager_w, Desks[0].label);
if (Desks[0].bgPixmap != NULL)
{
DestroyPicture(dpy, Desks[0].bgPixmap);
Desks[0].bgPixmap = NULL;
}
if (Desks[0].Dcolor != NULL)
{
free (Desks[0].Dcolor);
Desks[0].Dcolor = NULL;
}
if (item->next != NULL)
{
change_cs = item->next->colorset;
change_ballooncs = item->next->ballooncolorset;
change_highcs = item->next->highcolorset;
}
if (change_cs < 0)
{
change_cs = globalcolorset;
}
Desks[0].colorset = change_cs;
if (change_cs > -1)
{
/* use our colour set if we have one */
change_colorset(change_cs);
}
else if (item->next != NULL && item->next->bgPixmap != NULL)
{
Desks[0].bgPixmap = item->next->bgPixmap;
Desks[0].bgPixmap->count++;
XSetWindowBackgroundPixmap(dpy, Desks[0].w,
Desks[0].bgPixmap->picture);
}
else if (item->next != NULL && item->next->Dcolor != NULL)
{
CopyString(&Desks[0].Dcolor, item->next->Dcolor);
XSetWindowBackground(dpy, Desks[0].w, GetColor(Desks[0].Dcolor));
}
else if (PixmapBack != NULL)
{
Desks[0].bgPixmap = PixmapBack;
Desks[0].bgPixmap->count++;
XSetWindowBackgroundPixmap(dpy, Desks[0].w,
Desks[0].bgPixmap->picture);
}
else
{
CopyString(&Desks[0].Dcolor, PagerBack);
XSetWindowBackground(dpy, Desks[0].w, GetColor(Desks[0].Dcolor));
}
//.........这里部分代码省略.........
示例13: SV_SpawnServer
//.........这里部分代码省略.........
SV_SendMapChange();
// clear pak references
FS_ClearPakReferences(0);
/*
Ghoul2 Insert Start
*/
// allocate the snapshot entities on the hunk
// svs.snapshotEntities = (struct entityState_s *)Hunk_Alloc( sizeof(entityState_t)*svs.numSnapshotEntities, h_high );
svs.nextSnapshotEntities = 0;
// allocate the snapshot entities
svs.snapshotEntities = new entityState_s[svs.numSnapshotEntities];
// we CAN afford to do this here, since we know the STL vectors in Ghoul2 are empty
memset(svs.snapshotEntities, 0, sizeof(entityState_t)*svs.numSnapshotEntities);
/*
Ghoul2 Insert End
*/
// toggle the server bit so clients can detect that a
// server has changed
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// set nextmap to the same map, but it may be overriden
// by the game startup or another console command
Cvar_Set( "nextmap", "map_restart 0");
// Cvar_Set( "nextmap", va("map %s", server) );
// wipe the entire per-level structure
SV_ClearServer();
for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
sv.configstrings[i] = CopyString("");
}
// decide which serverversion to host
mv_serverversion = Cvar_Get("mv_serverversion", "1.04", CVAR_ARCHIVE | CVAR_LATCH | CVAR_GLOBAL);
if (FS_AllPath_Base_FileExists("assets5.pk3") && (!strcmp(mv_serverversion->string, "auto") || !strcmp(mv_serverversion->string, "1.04"))) {
Com_Printf("serverversion set to 1.04\n");
MV_SetCurrentGameversion(VERSION_1_04);
}
else if (FS_AllPath_Base_FileExists("assets2.pk3") && (!strcmp(mv_serverversion->string, "auto") || !strcmp(mv_serverversion->string, "1.03"))) {
Com_Printf("serverversion set to 1.03\n");
MV_SetCurrentGameversion(VERSION_1_03);
} else {
Com_Printf("serverversion set to 1.02\n");
MV_SetCurrentGameversion(VERSION_1_02);
}
Cvar_Set("protocol", va("%i", MV_GetCurrentProtocol()));
// make sure we are not paused
Cvar_Set("cl_paused", "0");
// get a new checksum feed and restart the file system
srand(Com_Milliseconds());
sv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds();
FS_PureServerSetReferencedPaks("", "");
FS_Restart( sv.checksumFeed );
CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum );
SV_SendMapChange();
示例14: Com_Error
/*
============
Cvar_Get
If the variable already exists, the value will not be set unless CVAR_ROM
The flags will be or'ed in if the variable exists.
============
*/
cvar_t *Cvar_Get( const char *var_name, const char *var_value, uint32_t flags ) {
cvar_t *var;
long hash;
int index;
if ( !var_name || ! var_value ) {
Com_Error( ERR_FATAL, "Cvar_Get: NULL parameter" );
}
if ( !Cvar_ValidateString( var_name ) ) {
Com_Printf("invalid cvar name string: %s\n", var_name );
var_name = "BADNAME";
}
#if 0 // FIXME: values with backslash happen
if ( !Cvar_ValidateString( var_value ) ) {
Com_Printf("invalid cvar value string: %s\n", var_value );
var_value = "BADVALUE";
}
#endif
var = Cvar_FindVar (var_name);
if ( var ) {
var_value = Cvar_Validate(var, var_value, qfalse);
// Make sure the game code cannot mark engine-added variables as gamecode vars
if(var->flags & CVAR_VM_CREATED)
{
if(!(flags & CVAR_VM_CREATED))
var->flags &= ~CVAR_VM_CREATED;
}
else if (!(var->flags & CVAR_USER_CREATED))
{
if(flags & CVAR_VM_CREATED)
flags &= ~CVAR_VM_CREATED;
}
// if the C code is now specifying a variable that the user already
// set a value for, take the new value as the reset value
if ( var->flags & CVAR_USER_CREATED )
{
var->flags &= ~CVAR_USER_CREATED;
Cvar_FreeString( var->resetString );
var->resetString = CopyString( var_value );
if(flags & CVAR_ROM)
{
// this variable was set by the user,
// so force it to value given by the engine.
if(var->latchedString)
Cvar_FreeString(var->latchedString);
var->latchedString = CopyString(var_value);
}
}
// Make sure servers cannot mark engine-added variables as SERVER_CREATED
if(var->flags & CVAR_SERVER_CREATED)
{
if(!(flags & CVAR_SERVER_CREATED))
var->flags &= ~CVAR_SERVER_CREATED;
}
else
{
if(flags & CVAR_SERVER_CREATED)
flags &= ~CVAR_SERVER_CREATED;
}
var->flags |= flags;
// only allow one non-empty reset string without a warning
if ( !var->resetString[0] ) {
// we don't have a reset string yet
Cvar_FreeString( var->resetString );
var->resetString = CopyString( var_value );
} else if ( var_value[0] && strcmp( var->resetString, var_value ) ) {
Com_DPrintf( S_COLOR_YELLOW "Warning: cvar \"%s\" given initial values: \"%s\" and \"%s\"\n",
var_name, var->resetString, var_value );
}
// if we have a latched string, take that value now
if ( var->latchedString ) {
char *s;
s = var->latchedString;
var->latchedString = NULL; // otherwise cvar_set2 would free it
Cvar_Set2( var_name, s, 0, qtrue );
Cvar_FreeString( s );
}
// ZOID--needs to be set so that cvars the game sets as
// SERVERINFO get sent to clients
//.........这里部分代码省略.........
示例15: ConWndProc
static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char *cmdString;
static qboolean s_timePolarity;
switch (uMsg)
{
case WM_ACTIVATE:
if ( LOWORD( wParam ) != WA_INACTIVE )
{
SetFocus( s_wcd.hwndInputLine );
}
if ( com_viewlog && ( com_dedicated && !com_dedicated->integer ) )
{
// if the viewlog is open, check to see if it's being minimized
if ( com_viewlog->integer == 1 )
{
if ( HIWORD( wParam ) ) // minimized flag
{
Cvar_Set( "viewlog", "2" );
}
}
else if ( com_viewlog->integer == 2 )
{
if ( !HIWORD( wParam ) ) // minimized flag
{
Cvar_Set( "viewlog", "1" );
}
}
}
break;
case WM_CLOSE:
if ( ( com_dedicated && com_dedicated->integer ) )
{
cmdString = CopyString( "quit" );
Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
}
else if ( s_wcd.quitOnClose )
{
PostQuitMessage( 0 );
}
else
{
Sys_ShowConsole( 0, qfalse );
Cvar_Set( "viewlog", "0" );
}
return 0;
case WM_CTLCOLORSTATIC:
if ( ( HWND ) lParam == s_wcd.hwndBuffer )
{
SetBkColor( ( HDC ) wParam, RGB( 0x10, 0x10, 0x10 ) );
SetTextColor( ( HDC ) wParam, RGB( 0xdc, 0xac, 0x00 ) );
#if 0 // this draws a background in the edit box, but there are issues with this
if ( ( hdcScaled = CreateCompatibleDC( ( HDC ) wParam ) ) != 0 )
{
if ( SelectObject( ( HDC ) hdcScaled, s_wcd.hbmLogo ) )
{
StretchBlt( ( HDC ) wParam, 0, 0, 512, 384,
hdcScaled, 0, 0, 512, 384,
SRCCOPY );
}
DeleteDC( hdcScaled );
}
#endif
return ( long ) s_wcd.hbrEditBackground;
}
else if ( ( HWND ) lParam == s_wcd.hwndErrorBox )
{
if ( s_timePolarity & 1 )
{
SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0xff, 0x0, 0x00 ) );
}
else
{
SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
SetTextColor( ( HDC ) wParam, RGB( 0x00, 0x0, 0x00 ) );
}
return ( long ) s_wcd.hbrErrorBackground;
}
break;
case WM_COMMAND:
if ( wParam == COPY_ID )
{
SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );
}
else if ( wParam == QUIT_ID )
{
if ( s_wcd.quitOnClose )
{
PostQuitMessage( 0 );
}
else
{
cmdString = CopyString( "quit" );
//.........这里部分代码省略.........