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


C++ safe_cprintf函数代码示例

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


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

示例1: debug_printf

///////////////////////////////////////////////////////////////////////
// Debug print, could add a "logging" feature to print to a file
///////////////////////////////////////////////////////////////////////
void debug_printf(char *fmt, ...)
{
	int     i;
	char	bigbuffer[0x10000];
	int		len;
	va_list	argptr;
	edict_t	*cl_ent;
	
	va_start (argptr,fmt);
	len = vsprintf (bigbuffer,fmt,argptr);
	va_end (argptr);

	if (dedicated->value)
		safe_cprintf(NULL, PRINT_MEDIUM, bigbuffer);

	for (i=0 ; i<maxclients->value ; i++)
	{
		cl_ent = g_edicts + 1 + i;
		if (!cl_ent->inuse || cl_ent->ai.is_bot)
			continue;

		safe_cprintf(cl_ent,  PRINT_MEDIUM, bigbuffer);
	}

}
开发者ID:emmamai,项目名称:vortex-indy,代码行数:28,代码来源:bot_common.c

示例2: Use_Weapon

/*
================
Use_Weapon

Make the weapon ready if there is ammo
================
*/
void Use_Weapon (edict_t *ent, gitem_t *item)
{
	int			ammo_index;
	gitem_t		*ammo_item;

	// see if we're already using it
	if (item == ent->client->pers.weapon)
		return;

	if (item->ammo && !g_select_empty->value && !(item->flags & IT_AMMO))
	{
		ammo_item = FindItem(item->ammo);
		ammo_index = ITEM_INDEX(ammo_item);

		if (!ent->client->pers.inventory[ammo_index])
		{
			safe_cprintf (ent, PRINT_HIGH, "No %s for %s.\n", ammo_item->pickup_name, item->pickup_name);
			return;
		}

		if (ent->client->pers.inventory[ammo_index] < item->quantity)
		{
			safe_cprintf (ent, PRINT_HIGH, "Not enough %s for %s.\n", ammo_item->pickup_name, item->pickup_name);
			return;
		}
	}

	// change to this weapon when down
	ent->client->newweapon = item;
}
开发者ID:ZwS,项目名称:qudos,代码行数:37,代码来源:p_weapon.c

示例3: SVCmd_AddIP_f

/*
=================
SV_AddIP_f
=================
*/
void SVCmd_AddIP_f (void)
{
	int		i;
	
	if (gi.argc() < 3) {
		safe_cprintf(NULL, PRINT_HIGH, "Usage:  addip <ip-mask>\n");
		return;
	}

	for (i=0 ; i<numipfilters ; i++)
		if (ipfilters[i].compare == 0xffffffff)
			break;		// free spot
	if (i == numipfilters)
	{
		if (numipfilters == MAX_IPFILTERS)
		{
			safe_cprintf (NULL, PRINT_HIGH, "IP filter list is full\n");
			return;
		}
		numipfilters++;
	}
	
	if (!StringToFilter (gi.argv(2), &ipfilters[i]))
		ipfilters[i].compare = 0xffffffff;
}
开发者ID:qbism,项目名称:qbq2,代码行数:30,代码来源:g_svcmds.c

示例4: SVCmd_WriteIP_f

/*
=================
SV_WriteIP_f
=================
*/
void SVCmd_WriteIP_f (void)
{
	FILE	*f;
	char	name[MAX_OSPATH];
	byte	b[4];
	int		i;
	cvar_t	*game;

	game = gi.cvar("game", "", 0);

	if (!*game->string)
		sprintf (name, "%s/listip.cfg", GAMEVERSION);
	else
		sprintf (name, "%s/listip.cfg", game->string);

	safe_cprintf (NULL, PRINT_HIGH, "Writing %s.\n", name);

	f = fopen (name, "wb");
	if (!f)
	{
		safe_cprintf (NULL, PRINT_HIGH, "Couldn't open %s\n", name);
		return;
	}
	
	fprintf(f, "set filterban %d\n", (int)filterban->value);

	for (i=0 ; i<numipfilters ; i++)
	{
		*(unsigned *)b = ipfilters[i].compare;
		fprintf (f, "sv addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
	}
	
	fclose (f);
}
开发者ID:qbism,项目名称:qbq2,代码行数:39,代码来源:g_svcmds.c

示例5: SVCmd_RemoveIP_f

/*
=================
SV_RemoveIP_f
=================
*/
void SVCmd_RemoveIP_f (void)
{
	ipfilter_t	f;
	int			i, j;

	if (gi.argc() < 3) {
		safe_cprintf(NULL, PRINT_HIGH, "Usage:  sv removeip <ip-mask>\n");
		return;
	}

	if (!StringToFilter (gi.argv(2), &f))
		return;

	for (i=0 ; i<numipfilters ; i++)
		if (ipfilters[i].mask == f.mask
		&& ipfilters[i].compare == f.compare)
		{
			for (j=i+1 ; j<numipfilters ; j++)
				ipfilters[j-1] = ipfilters[j];
			numipfilters--;
			safe_cprintf (NULL, PRINT_HIGH, "Removed.\n");
			return;
		}
	safe_cprintf (NULL, PRINT_HIGH, "Didn't find %s.\n", gi.argv(2));
}
开发者ID:qbism,项目名称:qbq2,代码行数:30,代码来源:g_svcmds.c

示例6: my_bprintf

void my_bprintf (int printlevel, char *fmt, ...)
{
	int i;
	char	bigbuffer[0x10000];
	int		len;
	va_list		argptr;
	edict_t	*cl_ent;

	va_start (argptr,fmt);
//	len = vsprintf (bigbuffer,fmt,argptr);
	len = Q_vsnprintf (bigbuffer, sizeof(bigbuffer), fmt, argptr);
	va_end (argptr);

	if (dedicated->value)
		safe_cprintf(NULL, printlevel, bigbuffer);

	for (i=0 ; i<maxclients->value ; i++)
	{
		cl_ent = g_edicts + 1 + i;
		if (!cl_ent->inuse)
			continue;

		safe_cprintf(cl_ent, printlevel, bigbuffer);
	}
}
开发者ID:PBrookfield,项目名称:vrgamex86,代码行数:25,代码来源:g_utils.c

示例7: BombArea

void BombArea (edict_t *ent, float skill_mult, float cost_mult)
{
	vec3_t	angles, offset;
	vec3_t	forward, right, start, end;
	trace_t	tr;
	edict_t *bomb;
	int		cost=COST_FOR_BOMB*cost_mult;

#ifdef OLD_NOLAG_STYLE
	// 3.5 don't allow bomb area to prevent lag
	if (nolag->value)
	{
		safe_cprintf(ent, PRINT_HIGH, "Bomb area is temporarily disabled to prevent lag.\n");
		return;
	}
#endif

	AngleVectors (ent->client->v_angle, forward, right, NULL);
	VectorSet(offset, 0, 7, ent->viewheight-8);
	P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start);
	VectorMA(start, 8192, forward, end);
	tr = gi.trace(start, NULL, NULL, end, ent, MASK_SOLID);

	// make sure this is a floor
	vectoangles(tr.plane.normal, angles);
	ValidateAngles(angles);
	if (angles[PITCH] == FLOOR_PITCH)
	{
		VectorCopy(tr.endpos, start);
		VectorCopy(tr.endpos, end);
		end[2] += BOMBAREA_FLOOR_HEIGHT;
		tr = gi.trace(start, NULL, NULL, end, ent, MASK_SOLID);
	}
	else if (angles[PITCH] != CEILING_PITCH)
	{
		safe_cprintf(ent, PRINT_HIGH, "You must look at a ceiling or floor to cast this spell.\n");
		return;
	}

	bomb = G_Spawn();
	bomb->solid = SOLID_NOT;
	bomb->svflags |= SVF_NOCLIENT;
	VectorClear(bomb->velocity);
	VectorClear(bomb->mins);
	VectorClear(bomb->maxs);
	bomb->owner = ent;
	bomb->delay = level.time + BOMBAREA_DURATION + BOMBAREA_STARTUP_DELAY;
	bomb->nextthink = level.time + BOMBAREA_STARTUP_DELAY;
	bomb->dmg = 50 + 10*ent->myskills.abilities[BOMB_SPELL].current_level*skill_mult;
	bomb->think = bombarea_think;
	VectorCopy(tr.endpos, bomb->s.origin);
	VectorCopy(tr.endpos, bomb->s.old_origin);
	VectorCopy(angles, bomb->s.angles);
	gi.linkentity(bomb);

    gi.sound(bomb, CHAN_WEAPON, gi.soundindex("abilities/meteorlaunch_short.wav"), 1, ATTN_NORM, 0);
	ent->client->pers.inventory[power_cube_index] -= cost;

	ent->client->ability_delay = level.time + (DELAY_BOMB * cost_mult);
}
开发者ID:zardoru,项目名称:vrxcl,代码行数:60,代码来源:bombspell.c

示例8: CheckFlood

qboolean CheckFlood (edict_t *who)
{
	int	i;
	gclient_t *cl;

		cl = who->client;
		//DB
        if (level.time < cl->flood_locktill)
		{
			safe_cprintf(who, PRINT_HIGH, "You can't talk for %d more seconds\n",
				(int)(cl->flood_locktill - level.time));
            return false;
        }
        i = cl->flood_whenhead - flood_msgs->value + 1;
		if (i < 0)
            i = (sizeof(cl->flood_when)/sizeof(cl->flood_when[0])) + i;
		if (cl->flood_when[i] && level.time - cl->flood_when[i] < flood_persecond->value)
		{
			cl->flood_locktill = level.time + flood_waitdelay->value;
			safe_cprintf(who, PRINT_CHAT, "Flood protection:  You can't talk for %d seconds.\n",(int)flood_waitdelay->value);
            return false;
        }
		cl->flood_whenhead = (cl->flood_whenhead + 1) % (sizeof(cl->flood_when)/sizeof(cl->flood_when[0]));
		cl->flood_when[cl->flood_whenhead] = level.time;
		return true;
}
开发者ID:qbism,项目名称:tmg,代码行数:26,代码来源:g_utils.c

示例9: Cmd_HolyFreeze

void Cmd_HolyFreeze(edict_t *ent)
{
	qboolean sameaura=false;

	if (debuginfo->value)
		gi.dprintf("DEBUG: %s just called Cmd_HolyFreeze()\n", ent->client->pers.netname);

	if(ent->myskills.abilities[HOLY_FREEZE].disable)
		return;

	if (!G_CanUseAbilities(ent, ent->myskills.abilities[HOLY_FREEZE].current_level, 0))
		return;
	// if we already had an aura on, remove it
	if (que_typeexists(ent->auras, AURA_HOLYFREEZE))
	{
		safe_cprintf(ent, PRINT_HIGH, "Holy freeze removed.\n");
		AuraRemove(ent, AURA_HOLYFREEZE);
		return;
	}
	
	ent->client->ability_delay = level.time + DEFAULT_AURA_DELAY;
	// do we have enough power cubes?
	if (ent->client->pers.inventory[power_cube_index] < DEFAULT_AURA_INIT_COST)
	{
		safe_cprintf(ent, PRINT_HIGH, "You need more %d power cubes to use this ability.\n", 
			DEFAULT_AURA_INIT_COST-ent->client->pers.inventory[power_cube_index]);
		return;
	}
	ent->client->pers.inventory[power_cube_index] -= DEFAULT_AURA_INIT_COST;
	gi.sound(ent, CHAN_ITEM, gi.soundindex("auras/holywind.wav"), 1, ATTN_NORM, 0);
	safe_cprintf(ent, PRINT_HIGH, "Now using holy freeze aura.\n");
	aura_holyfreeze(ent);
}
开发者ID:emmamai,项目名称:vortex-indy,代码行数:33,代码来源:auras.c

示例10: depot_die

void depot_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
	if (attacker->client)
		safe_cprintf(self->creator, PRINT_HIGH, "Your supply station was destroyed by %s.\n", attacker->client->pers.netname);
	else
		safe_cprintf(self->creator, PRINT_HIGH, "Your supply station was destroyed.\n");
	depot_remove(self, NULL, true);
}
开发者ID:zardoru,项目名称:vrxcl,代码行数:8,代码来源:supplystation.c

示例11: SVCmd_ListIP_f

/*
=================
SV_ListIP_f
=================
*/
void SVCmd_ListIP_f (void)
{
	int		i;
	byte	b[4];

	safe_cprintf (NULL, PRINT_HIGH, "Filter list:\n");
	for (i=0 ; i<numipfilters ; i++)
	{
		*(unsigned *)b = ipfilters[i].compare;
		safe_cprintf (NULL, PRINT_HIGH, "%3i.%3i.%3i.%3i\n", b[0], b[1], b[2], b[3]);
	}
}
开发者ID:qbism,项目名称:qbq2,代码行数:17,代码来源:g_svcmds.c

示例12: ShowAllyMenu

void ShowAllyMenu (edict_t *ent)
{
	int i;
	int j = 0;
	edict_t *temp;

	//Don't bother displaying the menu if alliances are disabled
	if (!allies->value)
	{
		safe_cprintf(ent, PRINT_HIGH, "Alliances are disabled.\n");
		return;
	}

	// alliance only work in pvp mode
	if (!ValidAllyMode())
	{
		safe_cprintf(ent, PRINT_HIGH, "Alliances are disabled.\n");
		return;
	}

	 if (!ShowMenu(ent))
        return;
	clearmenu(ent);

	addlinetomenu(ent, "Currently allied with:", MENU_GREEN_CENTERED);
	addlinetomenu(ent, " ", 0);

	for_each_player(temp, i)
	{
		if (IsAlly(ent, temp))
		{
			//Add player to the list
			addlinetomenu(ent, va(" %s", temp->myskills.player_name), 0);
			++j;
		}
	}

	//Menu footer
	addlinetomenu(ent, " ", 0);
	addlinetomenu(ent, "Add Ally", 1);
	addlinetomenu(ent, "Remove Ally", 2);
	addlinetomenu(ent, "Exit", 666);

	//Set handler
	setmenuhandler(ent, ShowAllyMenu_handler);

	//Set current line
	ent->client->menustorage.currentline = 6 + j;

	//Display the menu
	showmenu(ent);
}
开发者ID:emmamai,项目名称:vortex-indy,代码行数:52,代码来源:ally.c

示例13: ShowAllyInviteMenu_handler

void ShowAllyInviteMenu_handler (edict_t *ent, int option)
{
	edict_t *e = ent->client->allytarget;

	if (!e || !e->inuse)
		return;

	// make sure they can still ally
	if (!CanAlly(ent, e, ALLY_RANGE))
		return;

	if (option == 1)
	{
		// notify inviter and his previous allies, if any
		gi.centerprintf(e, "Now allied with %s\n", ent->client->pers.netname);
		NotifyAllies(e, CENTERPRINT, va("Now allied with %s\n", ent->client->pers.netname));

		// notify invitee's allies
		NotifyAllies(ent, CENTERPRINT, va("Now allied with %s\n", e->client->pers.netname));

		// join allies
		AddAlly(ent, e);

		// notify invitee
		safe_cprintf(ent, PRINT_HIGH, "Ally added.\n");

		// reset wait menu variables
		AbortAllyWait(ent);
		AbortAllyWait(e);

		// close the invitation menu
		closemenu(ent);

		if (InMenu(e, 0, ShowAllyWaitMenu_handler))
			closemenu(e);
	}
	else if (option == 2)
	{
		// reset wait menu variables
		AbortAllyWait(ent);
		AbortAllyWait(e);

		// close the invitation menu
		closemenu(ent);

		if (InMenu(e, 0, ShowAllyWaitMenu_handler))
			closemenu(e);

		safe_cprintf(e, PRINT_HIGH, "%s declined your offer to ally.\n", ent->client->pers.netname);
	}
}
开发者ID:emmamai,项目名称:vortex-indy,代码行数:51,代码来源:ally.c

示例14: Cmd_BuildLaser

void Cmd_BuildLaser (edict_t *ent)
{
	int talentLevel, cost=LASER_COST;
	float skill_mult=1.0, cost_mult=1.0, delay_mult=1.0;//Talent: Rapid Assembly & Precision Tuning

	if(ent->myskills.abilities[BUILD_LASER].disable)
		return;

	if (Q_strcasecmp (gi.args(), "remove") == 0)
	{
		RemoveLasers(ent);
		safe_cprintf(ent, PRINT_HIGH, "All lasers removed.\n");
		return;
	}

	// cost is doubled if you are a flyer or cacodemon below skill level 5
	if ((ent->mtype == MORPH_FLYER && ent->myskills.abilities[FLYER].current_level < 5) 
		|| (ent->mtype == MORPH_CACODEMON && ent->myskills.abilities[CACODEMON].current_level < 5))
		cost *= 2;

	//Talent: Rapid Assembly
	talentLevel = getTalentLevel(ent, TALENT_RAPID_ASSEMBLY);
	if (talentLevel > 0)
		delay_mult -= 0.1 * talentLevel;
	//Talent: Precision Tuning
	else if ((talentLevel = getTalentLevel(ent, TALENT_PRECISION_TUNING)) > 0)
	{
		cost_mult += PRECISION_TUNING_COST_FACTOR * talentLevel;
		delay_mult += PRECISION_TUNING_DELAY_FACTOR * talentLevel;
		skill_mult += PRECISION_TUNING_SKILL_FACTOR * talentLevel;
	}
	cost *= cost_mult;

	if (!G_CanUseAbilities(ent, ent->myskills.abilities[BUILD_LASER].current_level, cost))
		return;

	if (ent->num_lasers >= MAX_LASERS)
	{
		safe_cprintf(ent, PRINT_HIGH, "Can't build any more lasers.\n");
		return;
	}

	if (ctf->value && (CTF_DistanceFromBase(ent, NULL, CTF_GetEnemyTeam(ent->teamnum)) < CTF_BASE_DEFEND_RANGE))
	{
		safe_cprintf(ent, PRINT_HIGH, "Can't build in enemy base!\n");
		return;
	}

	SpawnLaser(ent, cost, skill_mult, delay_mult);
}
开发者ID:wafleh,项目名称:vrxcl,代码行数:50,代码来源:lasers.c

示例15: DeleteMenu_handler

void DeleteMenu_handler(edict_t *ent, int option)
{
	if (option - 777 > 0)
	{
		int i;

		//Delete item
		memset(&ent->myskills.items[option - 778], 0, sizeof(item_t));

		//Re-apply equipment
		V_ResetAllStats(ent);
		for (i = 0; i < 3; ++i)
			V_ApplyRune(ent, &ent->myskills.items[i]);

		safe_cprintf(ent, PRINT_HIGH, "Item deleted.\n");
	}
	else if (option - 666 > 0)
	{
		//Back to main
		ShowInventoryMenu(ent, option - 666, false);
		return;
	}
	else
	{
		//Closing menu
		closemenu(ent);
		return;
	}
}
开发者ID:emmamai,项目名称:vortex-indy,代码行数:29,代码来源:item.c


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