当前位置: 首页>>代码示例>>C++>>正文


C++ G_NewString函数代码示例

本文整理汇总了C++中G_NewString函数的典型用法代码示例。如果您正苦于以下问题:C++ G_NewString函数的具体用法?C++ G_NewString怎么用?C++ G_NewString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了G_NewString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFreeServerEntity

// Give a gentity_t, create a sp entity, copy all pertinent data, and return it
g_serverEntity_t *CreateServerEntity(gentity_t *ent)
{
	// get the entity out of our pool
	g_serverEntity_t *newEnt = GetFreeServerEntity();

	// if we managed to get one, copy over data
	if (newEnt)
	{
		// G_NewString crashes if you pass in NULL, so let's check...
		if (ent->classname)
			newEnt->classname = G_NewString(ent->classname);

		if (ent->targetname)
			newEnt->name = G_NewString(ent->targetname);

		if (ent->target)
			newEnt->target = G_NewString(ent->target);

		newEnt->spawnflags = ent->spawnflags;
		newEnt->team = ent->aiTeam;
		VectorCopy(ent->s.origin, newEnt->origin);
		VectorCopy(ent->s.angles, newEnt->angles);
		// DON'T set the number - that should have been set when it was spawned

		// set the areanum to -1, which means we haven't calculated it yet
		//		these don't move, so we should only have to calc it once, the first
		//		time someone asks for it
		newEnt->areaNum = -1;

	}

	return newEnt;
}
开发者ID:Dragonji,项目名称:jaymod,代码行数:34,代码来源:g_sv_entities.cpp

示例2: CreateServerEntityFromData

// Create a server entity from some basic data
void CreateServerEntityFromData(char* classname, char* targetname, char* target, vec3_t origin, int spawnflags, vec3_t angle)
{
	// get the entity out of our pool
	g_serverEntity_t *newEnt = GetFreeServerEntity();

	// if we managed to get one, copy over data
	if (newEnt)
	{
		// G_NewString crashes if you pass in NULL, so let's check...
		if (classname)
			newEnt->classname = G_NewString(classname);

		if (targetname)
			newEnt->name = G_NewString(targetname);

		if (target)
			newEnt->target = G_NewString(target);

		newEnt->spawnflags = spawnflags;
		//newEnt->team = ent->aiTeam;
		VectorCopy(origin, newEnt->origin);
		VectorCopy(angle, newEnt->angles);
		// DON'T set the number - that should have been set when it was spawned

		// set the areanum to -1, which means we haven't calculated it yet
		//		these don't move, so we should only have to calc it once, the first
		//		time someone asks for it
		newEnt->areaNum = -1;

		// and do class specific stuff
		InitServerEntitySetupFunc(newEnt);
	}
}
开发者ID:Dragonji,项目名称:jaymod,代码行数:34,代码来源:g_sv_entities.cpp

示例3: G_ParseField

/*
===============
G_ParseField

Takes a key/value pair and sets the binary values
in a gentity
===============
*/
void G_ParseField( const char *key, const char *value, gentity_t *ent ) {
	field_t	*f;
	byte	*b;
	float	v;
	vec3_t	vec;
	char	string[64];

	for ( f=fields ; f->name ; f++ ) {
		if ( !Q_stricmp(f->name, key) ) {
			// found it
			b = (byte *)ent;

			switch( f->type ) {
			case F_LSTRING:
				*(char **)(b+f->ofs) = G_NewString (value);
				strcpy(string, G_NewString(value));

				if(!Q_stricmp(key, "name")){
					strcpy(intermission_names[ent->mappart-1], string);
				}

				break;
			case F_VECTOR:
				sscanf (value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
				((float *)(b+f->ofs))[0] = vec[0];
				((float *)(b+f->ofs))[1] = vec[1];
				((float *)(b+f->ofs))[2] = vec[2];
				break;
			case F_INT:
				*(int *)(b+f->ofs) = atoi(value);
				break;
			case F_FLOAT:
				*(float *)(b+f->ofs) = atof(value);
				break;
			case F_ANGLEHACK:
				v = atof(value);
				((float *)(b+f->ofs))[0] = 0;
				((float *)(b+f->ofs))[1] = v;
				((float *)(b+f->ofs))[2] = 0;
				break;
			default:
			case F_IGNORE:
				break;
			}
			return;
		}
	}
}
开发者ID:LuckyBro,项目名称:sgfork,代码行数:56,代码来源:g_spawn.c

示例4: SP_target_stoptimer

void SP_target_stoptimer(gentity_t *ent) {
	char *t = NULL;

	// Nico, used to look for parent
	gentity_t *parent = NULL;

	// Nico, override wait -1 or wait 9999 on stop timer entities
	if (g_forceTimerReset.integer) {
		parent = G_FindByTarget(NULL, ent->targetname);
		if (parent && parent->wait != 0.5 && !Q_stricmp(parent->classname, "trigger_multiple")) {
			G_DPrintf("%s: SP_target_stoptimer, wait found = %f, overrided to 0.5\n", GAME_VERSION, parent->wait);
			G_SpawnFloat("wait", "0.5", &parent->wait);
		}
	}

	G_SpawnString("name", "default", &t);
	ent->timerunName = G_NewString(t);
	// create a timerun with this name if it doesn't exit yet
	GetTimerunNum(ent->timerunName);

	G_SpawnInt("mincheckpoints", "0", &ent->count);

	ent->use = target_stoptimer_use;

	level.isTimerun = qtrue;
}
开发者ID:boutetnico,项目名称:ETrun,代码行数:26,代码来源:g_target.c

示例5: assert

static char *GetStringPtr(int iStrlen, char *psOriginal/*may be NULL*/)
{
	if (iStrlen != -1)
	{
		char sString[768];	// arb, inc if nec.

		sString[0]=0;

		assert(iStrlen+1<=sizeof(sString));
		
		gi.ReadFromSaveGame('STRG', sString, iStrlen);

#ifndef _XBOX	// TAG_G_ALLOC is always blown away, we can never recycle
		if (psOriginal && gi.bIsFromZone(psOriginal, TAG_G_ALLOC)) {
			if (!strcmp(psOriginal,sString))
			{//it's a legal ptr and they're the same so let's just reuse it instead of free/alloc
				return psOriginal;
			}
			gi.Free(psOriginal);
		}
#endif

		return G_NewString(sString);
	}

	return NULL;
}
开发者ID:Hasimir,项目名称:jedi-academy-1,代码行数:27,代码来源:g_savegame.cpp

示例6: SP_misc_beam

void SP_misc_beam(gentity_t *self)
{
	char           *str;

	G_SpawnString("target2", "", &str);

	if (*str)
	{
		self->message = G_NewString(str);
	}

	G_SpawnString("shader", "lightningBolt", &str);

	if (*str)
	{
		self->s.modelindex2 = G_ShaderIndex(str);
	}

	G_SpawnInt("scale", "1", &self->s.torsoAnim);
	G_SpawnVector("color", "1 1 1", self->s.angles2);

	// let everything else get spawned before we start firing
	self->accuracy = 0;
	self->think = misc_beam_start;
	self->nextthink = level.time + FRAMETIME;
}
开发者ID:morsik,项目名称:warpig,代码行数:26,代码来源:g_target.c

示例7: SP_target_checkpoint

void SP_target_checkpoint(gentity_t *ent) {
	char *t         = NULL;
	int  timerunNum = 0;

	// Nico, used to look for parent
	gentity_t *parent = NULL;

	// Nico, override wait -1 or wait 9999 on timer check entities
	if (g_forceTimerReset.integer) {
		parent = G_FindByTarget(NULL, ent->targetname);
		if (parent && parent->wait != 0.5 && !Q_stricmp(parent->classname, "trigger_multiple")) {
			G_DPrintf("%s: SP_target_checkpoint, wait found = %f, overrided to 0.5\n", GAME_VERSION, parent->wait);
			G_SpawnFloat("wait", "0.5", &parent->wait);
		}
	}

	G_SpawnString("name", "default", &t);
	ent->timerunName = G_NewString(t);
	// create a timerun with this name if it doesn't exit yet
	timerunNum = GetTimerunNum(ent->timerunName);

	if (level.numCheckpoints[timerunNum] >= MAX_TIMERUN_CHECKPOINTS) {
		G_Error("Exceeded maximum number of 'target_checkpoint' entities in '%s' timerun (max %i)\n", ent->timerunName, MAX_TIMERUN_CHECKPOINTS);
		return;
	}

	ent->count = level.numCheckpoints[timerunNum];
	ent->use   = target_checkpoint_use;

	level.numCheckpoints[timerunNum]++;

	level.isTimerun = qtrue;
}
开发者ID:boutetnico,项目名称:ETrun,代码行数:33,代码来源:g_target.c

示例8: assert

static char *GetStringPtr(int iStrlen, char *psOriginal/*may be NULL*/)
{
	if (iStrlen != -1)
	{
		char sString[768];	// arb, inc if nec.

		sString[0]=0;

		assert(iStrlen+1<=(int)sizeof(sString));

		ojk::SavedGameHelper saved_game(
			::gi.saved_game);

		saved_game.read_chunk(
			INT_ID('S', 'T', 'R', 'G'),
			sString,
			iStrlen);

		// TAG_G_ALLOC is always blown away, we can never recycle
		if (psOriginal && gi.bIsFromZone(psOriginal, TAG_G_ALLOC)) {
			if (!strcmp(psOriginal,sString))
			{//it's a legal ptr and they're the same so let's just reuse it instead of free/alloc
				return psOriginal;
			}
			gi.Free(psOriginal);
		}

		return G_NewString(sString);
	}

	return NULL;
}
开发者ID:Avygeil,项目名称:NewJK,代码行数:32,代码来源:g_savegame.cpp

示例9: UserSpawn

void UserSpawn( gentity_t *ent, const char *name )
{
	vec3_t		origin;
	vec3_t		vf;
	vec3_t		angles;
	gentity_t	*ent2;
	
	//Spawn the ent
	ent2 = G_Spawn();
	ent2->classname = G_NewString( name );	//FIXME: This will leave floating memory...

	//TODO: This should ultimately make sure this is a safe spawn!

	//Spawn the entity and place it there
	VectorSet( angles, 0, ent->s.apos.trBase[YAW], 0 );
	AngleVectors( angles, vf, NULL, NULL );
	VectorMA( ent->s.pos.trBase, 96, vf, origin );	//FIXME: Find the radius size of the object, and push out 32 + radius

	origin[2] += 8;
	VectorCopy( origin, ent2->s.pos.trBase );
	VectorCopy( origin, ent2->s.origin );
	VectorCopy( ent->s.apos.trBase, ent2->s.angles );

	gi.linkentity( ent2 );

	//Find a valid spawning spot
	if ( G_CallSpawn( ent2 ) == qfalse )
	{
		gi.SendServerCommand( ent-g_entities, "print \"Failed to spawn '%s'\n\"", name );
		G_FreeEntity( ent2 );
		return;
	}
}
开发者ID:PJayB,项目名称:jk2src,代码行数:33,代码来源:g_cmds.cpp

示例10: fx_explosion_trail_use

//----------------------------------------------------------
void fx_explosion_trail_use( gentity_t *self, gentity_t *other, gentity_t *activator )
{
	gentity_t *missile = G_Spawn();

	// We aren't a missile in the truest sense, rather we just move through the world and spawn effects
	if ( missile )
	{
		missile->classname = "fx_exp_trail";

		missile->nextthink = level.time + 50;
		missile->e_ThinkFunc = thinkF_fx_explosion_trail_think;

		missile->s.eType = ET_MOVER;

		missile->owner = self;

		missile->s.modelindex = self->s.modelindex2;

		missile->s.pos.trTime = level.time;
		G_SetOrigin( missile, self->currentOrigin );
		if ( self->spawnflags & 1 ) // gravity
		{
			missile->s.pos.trType = TR_GRAVITY;
		}
		else
		{
			missile->s.pos.trType = TR_LINEAR;
		}

		missile->spawnflags = self->spawnflags;

		G_SetAngles( missile, self->currentAngles );
		VectorScale( self->currentAngles, self->speed, missile->s.pos.trDelta );
		missile->s.pos.trTime = level.time;
		missile->radius = self->radius;
		missile->damage = self->damage;
		missile->splashDamage = self->splashDamage;
		missile->splashRadius = self->splashRadius;
		missile->fxID = self->fxID;
		missile->cameraGroup = self->cameraGroup;	//fxfile2

		missile->clipmask = MASK_SHOT;

		gi.linkentity( missile );

		if ( VALIDSTRING( self->soundSet ) == true )
		{
			G_AddEvent( self, EV_BMODEL_SOUND, CAS_GetBModelSound( self->soundSet, BMS_START ));
			missile->s.loopSound = CAS_GetBModelSound( self->soundSet, BMS_MID );
			missile->soundSet = G_NewString(self->soundSet);//get my own copy so i can free it when i die

			if ( missile->s.loopSound < 0 )
			{
				missile->s.loopSound = 0;
			}
		}
	}
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:59,代码来源:g_fx.cpp

示例11: G_ParseField

/*
===============
G_ParseField

Takes a key/value pair and sets the binary values
in a gentity
===============
 */
void G_ParseField(const char *key, const char *value, gentity_t *ent) {
  field_t *f;
  byte *b;
  float v;
  vec3_t vec;
  vec4_t vec4;

  for (f = fields; f->name; f++) {
    if (!Q_stricmp(f->name, key)) {
      // found it
      b = (byte *) ent;

      switch (f->type) {
        case F_LSTRING:
          *(char **) (b + f->ofs) = G_NewString(value);
          break;

        case F_VECTOR:
          sscanf(value, "%f %f %f", &vec[ 0 ], &vec[ 1 ], &vec[ 2 ]);

          ((float *) (b + f->ofs))[ 0 ] = vec[ 0 ];
          ((float *) (b + f->ofs))[ 1 ] = vec[ 1 ];
          ((float *) (b + f->ofs))[ 2 ] = vec[ 2 ];
          break;

        case F_VECTOR4:
          sscanf(value, "%f %f %f %f", &vec4[ 0 ], &vec4[ 1 ], &vec4[ 2 ], &vec4[ 3 ]);

          ((float *) (b + f->ofs))[ 0 ] = vec4[ 0 ];
          ((float *) (b + f->ofs))[ 1 ] = vec4[ 1 ];
          ((float *) (b + f->ofs))[ 2 ] = vec4[ 2 ];
          ((float *) (b + f->ofs))[ 3 ] = vec4[ 3 ];
          break;

        case F_INT:
          *(int *) (b + f->ofs) = atoi(value);
          break;

        case F_FLOAT:
          *(float *) (b + f->ofs) = atof(value);
          break;

        case F_ANGLEHACK:
          v = atof(value);
          ((float *) (b + f->ofs))[ 0 ] = 0;
          ((float *) (b + f->ofs))[ 1 ] = v;
          ((float *) (b + f->ofs))[ 2 ] = 0;
          break;

        default:
        case F_IGNORE:
          break;
      }

      return;
    }
  }
}
开发者ID:diegomichel,项目名称:zombiemodtremulous,代码行数:66,代码来源:g_spawn.c

示例12: G_ParseField

/*
===============
G_ParseField

Takes a key/value pair and sets the binary values
in a gentity
===============
*/
void G_ParseField( const char *key, const char *value, gentity_t *ent )
{
	field_t *f;
	byte    *b;
	float   v;
	vec3_t  vec;
	vec4_t  vec4;

	f = bsearch( key, fields, ARRAY_LEN( fields ),
	             sizeof( field_t ), cmdcmp );

	if ( !f )
	{
		return;
	}

	b = ( byte * ) ent;

	switch ( f->type )
	{
		case F_STRING:
			* ( char ** )( b + f->ofs ) = G_NewString( value );
			break;

		case F_VECTOR:
			sscanf( value, "%f %f %f", &vec[ 0 ], &vec[ 1 ], &vec[ 2 ] );

			( ( float * )( b + f->ofs ) ) [ 0 ] = vec[ 0 ];
			( ( float * )( b + f->ofs ) ) [ 1 ] = vec[ 1 ];
			( ( float * )( b + f->ofs ) ) [ 2 ] = vec[ 2 ];
			break;

		case F_VECTOR4:
			sscanf( value, "%f %f %f %f", &vec4[ 0 ], &vec4[ 1 ], &vec4[ 2 ], &vec4[ 3 ] );

			( ( float * )( b + f->ofs ) ) [ 0 ] = vec4[ 0 ];
			( ( float * )( b + f->ofs ) ) [ 1 ] = vec4[ 1 ];
			( ( float * )( b + f->ofs ) ) [ 2 ] = vec4[ 2 ];
			( ( float * )( b + f->ofs ) ) [ 3 ] = vec4[ 3 ];
			break;

		case F_INT:
			* ( int * )( b + f->ofs ) = atoi( value );
			break;

		case F_FLOAT:
			* ( float * )( b + f->ofs ) = atof( value );
			break;

		case F_ANGLEHACK:
			v = atof( value );
			( ( float * )( b + f->ofs ) ) [ 0 ] = 0;
			( ( float * )( b + f->ofs ) ) [ 1 ] = v;
			( ( float * )( b + f->ofs ) ) [ 2 ] = 0;
			break;
	}
}
开发者ID:Wattos,项目名称:Unvanquished,代码行数:65,代码来源:g_spawn.c

示例13: G_ParseField

void G_ParseField( const char *key, const char *value, gentity_t *ent )
{
	field_t	*f;
	byte	*b;
	float	v;
	vec3_t	vec;

	f = (field_t *)bsearch( key, fields, ARRAY_LEN( fields ), sizeof( field_t ), fieldcmp );
	if ( f )
	{// found it
		b = (byte *)ent;

		switch( f->type ) {
		case F_STRING:
			*(char **)(b+f->ofs) = G_NewString (value);
			break;
		case F_VECTOR:
			sscanf (value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
			((float *)(b+f->ofs))[0] = vec[0];
			((float *)(b+f->ofs))[1] = vec[1];
			((float *)(b+f->ofs))[2] = vec[2];
			break;
		case F_INT:
			*(int *)(b+f->ofs) = atoi(value);
			break;
		case F_FLOAT:
			*(float *)(b+f->ofs) = atof(value);
			break;
		case F_ANGLEHACK:
			v = atof(value);
			((float *)(b+f->ofs))[0] = 0;
			((float *)(b+f->ofs))[1] = v;
			((float *)(b+f->ofs))[2] = 0;
			break;
		case F_PARM1:
		case F_PARM2:
		case F_PARM3:
		case F_PARM4:
		case F_PARM5:
		case F_PARM6:
		case F_PARM7:
		case F_PARM8:
		case F_PARM9:
		case F_PARM10:
		case F_PARM11:
		case F_PARM12:
		case F_PARM13:
		case F_PARM14:
		case F_PARM15:
		case F_PARM16:
			Q3_SetParm( ent->s.number, (f->type - F_PARM1), (char *) value );
			break;
		}
		return;
	}
}
开发者ID:Camron,项目名称:OpenJK,代码行数:56,代码来源:g_spawn.c

示例14: file

/*QUAKED target_play_music (1 0 0) (-4 -4 -4) (4 4 4)
target_play_music
Plays the requested music files when this target is used.

"targetname"
"music"		music WAV or MP3 file ( music/introfile.mp3 [optional]  music/loopfile.mp3 )

If an intro file and loop file are specified, the intro plays first, then the looping
portion will start and loop indefinetly.  If no introfile is entered, only the loopfile
will play.
*/
void SP_target_play_music( gentity_t *self )
{
	char *s;

	G_SetOrigin( self, self->s.origin );
	if (!G_SpawnString( "music", "", &s ))
	{
		G_Error( "target_play_music without a music key at %s", vtos( self->s.origin ) );
	}

	self->message = G_NewString(s);

	self->use = target_play_music_use;
}
开发者ID:dpadgett,项目名称:base_enhanced,代码行数:25,代码来源:g_target.c

示例15: G_ParseField

/**
 * @brief Takes a key-value pair and sets the binary values in an entity.
 */
static void G_ParseField(const char *key, const char *value, g_entity_t *ent) {
	const g_field_t *f;
	byte *b;
	vec_t v;
	vec3_t vec;

	for (f = fields; f->name; f++) {

		if (!(f->flags & FFL_NO_SPAWN) && !g_ascii_strcasecmp(f->name, key)) { // found it

			if (f->flags & FFL_SPAWN_TEMP) {
				b = (byte *) &g_game.spawn;
			} else {
				b = (byte *) ent;
			}

			switch (f->type) {
				case F_SHORT:
					*(int16_t *) (b + f->ofs) = (int16_t) atoi(value);
					break;
				case F_INT:
					*(int32_t *) (b + f->ofs) = atoi(value);
					break;
				case F_FLOAT:
					*(vec_t *) (b + f->ofs) = atof(value);
					break;
				case F_STRING:
					*(char **) (b + f->ofs) = G_NewString(value);
					break;
				case F_VECTOR:
					sscanf(value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
					((vec_t *) (b + f->ofs))[0] = vec[0];
					((vec_t *) (b + f->ofs))[1] = vec[1];
					((vec_t *) (b + f->ofs))[2] = vec[2];
					break;
				case F_ANGLE:
					v = atof(value);
					((vec_t *) (b + f->ofs))[0] = 0;
					((vec_t *) (b + f->ofs))[1] = v;
					((vec_t *) (b + f->ofs))[2] = 0;
					break;
				default:
					break;
			}
			return;
		}
	}

	//gi.Debug("%s is not a field\n", key);
}
开发者ID:jdolan,项目名称:quetoo,代码行数:53,代码来源:g_entity.c


注:本文中的G_NewString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。