本文整理汇总了C++中Com_DPrintf函数的典型用法代码示例。如果您正苦于以下问题:C++ Com_DPrintf函数的具体用法?C++ Com_DPrintf怎么用?C++ Com_DPrintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Com_DPrintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IN_InitJoystick
/*
===============
IN_InitJoystick
===============
*/
static void IN_InitJoystick( void )
{
int i = 0;
int total = 0;
char buf[16384] = "";
if (stick != NULL)
SDL_JoystickClose(stick);
stick = NULL;
memset(&stick_state, '\0', sizeof (stick_state));
if (!SDL_WasInit(SDL_INIT_JOYSTICK))
{
Com_DPrintf("Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
if (SDL_Init(SDL_INIT_JOYSTICK) == -1)
{
Com_DPrintf("SDL_Init(SDL_INIT_JOYSTICK) failed: %s\n", SDL_GetError());
return;
}
Com_DPrintf("SDL_Init(SDL_INIT_JOYSTICK) passed.\n");
}
total = SDL_NumJoysticks();
Com_DPrintf("%d possible joysticks\n", total);
// Print list and build cvar to allow ui to select joystick.
for (i = 0; i < total; i++)
{
Q_strcat(buf, sizeof(buf), SDL_JoystickNameForIndex(i));
Q_strcat(buf, sizeof(buf), "\n");
}
Cvar_Get( "in_availableJoysticks", buf, CVAR_ROM );
if( !in_joystick->integer ) {
Com_DPrintf( "Joystick is not active.\n" );
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return;
}
in_joystickNo = Cvar_Get( "in_joystickNo", "0", CVAR_ARCHIVE | CVAR_GLOBAL);
if( in_joystickNo->integer < 0 || in_joystickNo->integer >= total )
Cvar_Set( "in_joystickNo", "0" );
in_joystickUseAnalog = Cvar_Get( "in_joystickUseAnalog", "0", CVAR_ARCHIVE | CVAR_GLOBAL);
stick = SDL_JoystickOpen( in_joystickNo->integer );
if (stick == NULL) {
Com_DPrintf( "No joystick opened.\n" );
return;
}
Com_DPrintf( "Joystick %d opened\n", in_joystickNo->integer );
Com_DPrintf( "Name: %s\n", SDL_JoystickNameForIndex(in_joystickNo->integer) );
Com_DPrintf( "Axes: %d\n", SDL_JoystickNumAxes(stick) );
Com_DPrintf( "Hats: %d\n", SDL_JoystickNumHats(stick) );
Com_DPrintf( "Buttons: %d\n", SDL_JoystickNumButtons(stick) );
Com_DPrintf( "Balls: %d\n", SDL_JoystickNumBalls(stick) );
Com_DPrintf( "Use Analog: %s\n", in_joystickUseAnalog->integer ? "Yes" : "No" );
SDL_JoystickEventState(SDL_QUERY);
}
示例2: NET_IP6Socket
/*
====================
NET_IP6Socket
====================
*/
int NET_IP6Socket(char *net_interface, int port, struct sockaddr_in6 *bindto, int *err)
{
SOCKET newsocket;
struct sockaddr_in6 address;
u_long _true = 1;
*err = 0;
if (net_interface)
{
// Print the name in brackets if there is a colon:
if (Q_CountChar(net_interface, ':'))
{
Com_Printf("Opening IP6 socket: [%s]:%i\n", net_interface, port);
}
else
{
Com_Printf("Opening IP6 socket: %s:%i\n", net_interface, port);
}
}
else
{
Com_Printf("Opening IP6 socket: [::]:%i\n", port);
}
if ((newsocket = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
{
*err = socketError;
Com_Printf("WARNING: NET_IP6Socket: socket: %s\n", NET_ErrorString());
return newsocket;
}
// make it non-blocking
if (ioctlsocket(newsocket, FIONBIO, &_true) == SOCKET_ERROR)
{
Com_Printf("WARNING: NET_IP6Socket: ioctl FIONBIO: %s\n", NET_ErrorString());
*err = socketError;
closesocket(newsocket);
return INVALID_SOCKET;
}
#ifdef IPV6_V6ONLY
{
int i = 1;
// ipv4 addresses should not be allowed to connect via this socket.
if (setsockopt(newsocket, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &i, sizeof(i)) == SOCKET_ERROR)
{
// win32 systems don't seem to support this anyways.
Com_DPrintf("WARNING: NET_IP6Socket: setsockopt IPV6_V6ONLY: %s\n", NET_ErrorString());
}
}
#endif
if (!net_interface || !net_interface[0])
{
address.sin6_family = AF_INET6;
address.sin6_addr = in6addr_any;
}
else
{
if (!Sys_StringToSockaddr(net_interface, (struct sockaddr *)&address, sizeof(address), AF_INET6))
{
closesocket(newsocket);
return INVALID_SOCKET;
}
}
if (port == PORT_ANY)
{
address.sin6_port = 0;
}
else
{
address.sin6_port = htons((short)port);
}
if (bind(newsocket, (void *)&address, sizeof(address)) == SOCKET_ERROR)
{
Com_Printf("WARNING: NET_IP6Socket: bind: %s\n", NET_ErrorString());
*err = socketError;
closesocket(newsocket);
return INVALID_SOCKET;
}
if (bindto)
{
*bindto = address;
}
return newsocket;
}
示例3: SV_AddEntitiesVisibleFromPoint
/*
===============
SV_AddEntitiesVisibleFromPoint
===============
*/
static void SV_AddEntitiesVisibleFromPoint( int psIndex, int playerNum, vec3_t origin, clientSnapshot_t *frame,
snapshotEntityNumbers_t *eNums, qboolean portal ) {
int e, i;
sharedEntity_t *ent;
svEntity_t *svEnt;
int l;
int clientarea, clientcluster;
int leafnum;
byte *clientpvs;
byte *bitvector;
// during an error shutdown message we may need to transmit
// the shutdown message after the server has shutdown, so
// specfically check for it
if ( !sv.state ) {
return;
}
leafnum = CM_PointLeafnum (origin);
clientarea = CM_LeafArea (leafnum);
clientcluster = CM_LeafCluster (leafnum);
// calculate the visible areas
frame->areabytes[psIndex] = CM_WriteAreaBits( frame->areabits[psIndex], clientarea );
clientpvs = CM_ClusterPVS (clientcluster);
for ( e = 0 ; e < sv.num_entities ; e++ ) {
ent = SV_GentityNum(e);
// never send entities that aren't linked in
if ( !ent->r.linked ) {
continue;
}
if (ent->s.number != e) {
Com_DPrintf ("FIXING ENT->S.NUMBER!!!\n");
ent->s.number = e;
}
// entities can be flagged to explicitly not be sent to the client
if ( ent->r.svFlags & SVF_NOCLIENT ) {
continue;
}
// entities can be flagged to be sent to a given mask of clients
if ( ent->r.svFlags & SVF_PLAYERMASK ) {
if ( !Com_ClientListContains( &ent->r.sendPlayers, playerNum ) )
continue;
}
svEnt = SV_SvEntityForGentity( ent );
// don't double add an entity through portals
if ( svEnt->snapshotCounter == sv.snapshotCounter ) {
continue;
}
// limit based on distance
if ( ent->r.cullDistance ) {
vec3_t dir;
VectorSubtract(ent->s.origin, origin, dir);
if ( VectorLengthSquared(dir) > (float) ent->r.cullDistance * ent->r.cullDistance ) {
continue;
}
}
// broadcast entities are always sent
if ( ent->r.svFlags & SVF_BROADCAST ) {
SV_AddEntToSnapshot( frame, svEnt, ent, eNums );
continue;
}
// ignore if not touching a PV leaf
// check area
if ( !CM_AreasConnected( clientarea, svEnt->areanum ) ) {
// doors can legally straddle two areas, so
// we may need to check another one
if ( !CM_AreasConnected( clientarea, svEnt->areanum2 ) ) {
continue; // blocked by a door
}
}
bitvector = clientpvs;
// check individual leafs
if ( !svEnt->numClusters ) {
continue;
}
l = 0;
for ( i=0 ; i < svEnt->numClusters ; i++ ) {
l = svEnt->clusternums[i];
if ( bitvector[l >> 3] & (1 << (l&7) ) ) {
break;
}
//.........这里部分代码省略.........
示例4: Cmd_Exec_f
/*
===============
Cmd_Exec_f
===============
*/
void Cmd_Exec_f (void)
{
const char *path;
char *f, *p;
int len;
char f2[COMMAND_BUFFER_SIZE+2];
if (Cmd_Argc () != 2)
{
Com_Printf ("exec <filename> : execute a config file\n", LOG_GENERAL);
return;
}
path = Cmd_Argv(1);
//r1: normalize
while ((p = strchr (path, '\\')))
p[0] = '/';
//r1: deny traversing outside the q2 directory
p = strstr (path, "../");
if (p)
{
p += 3;
if (strstr (p, "../"))
{
Com_Printf ("WARNING: Illegal config path '%s'\n", LOG_GENERAL, path);
return;
}
}
//r1: sanity check length first so people don't exec pak0.pak and eat 300MB ram
len = FS_LoadFile (path, NULL);
if (len > COMMAND_BUFFER_SIZE - 2)
{
Com_Printf ("WARNING: %s exceeds maximum config file length\n", LOG_GENERAL, Cmd_Argv(1));
len = COMMAND_BUFFER_SIZE - 2;
}
len = FS_LoadFile (path, (void **)&f);
if (!f || len <= 0)
{
//ugly hack to avoid printing missing config errors before startup finishes
if (q2_initialized)
Com_Printf ("couldn't exec %s\n", LOG_GENERAL, path);
return;
}
#ifndef DEDICATED_ONLY
if (Com_ServerState())
#endif
Com_Printf ("execing %s\n", LOG_GENERAL, path);
#ifndef DEDICATED_ONLY
else
Com_DPrintf ("execing %s\n",path);
#endif
// the file doesn't have a trailing 0, so we need to copy it off
//f2 = Z_TagMalloc(len+2, TAGMALLOC_CMDBUFF);
//f2 = alloca (len+2);
memcpy (f2, f, len);
//r1: fix for "no trailing newline = 'u or s'" bug.
f2[len] = '\n';
f2[len+1] = 0;
if ((p = strchr(f2, '\r')) && *(p+1) != '\n')
Com_Printf ("WARNING: Raw \\r found in config file %s\n", LOG_GENERAL|LOG_WARNING, path);
Cbuf_InsertText (f2);
//Z_Free (f2);
FS_FreeFile (f);
}
示例5: SV_AddEntitiesVisibleFromPoint
static void SV_AddEntitiesVisibleFromPoint(vec3_t origin, clientSnapshot_t *frame, snapshotEntityNumbers_t *eNums)
#endif
{
int e, i;
sharedEntity_t *ent, *playerEnt, *ment;
#ifdef FEATURE_ANTICHEAT
sharedEntity_t *client;
#endif
svEntity_t *svEnt;
int l;
int clientarea, clientcluster;
int leafnum;
byte *clientpvs;
byte *bitvector;
// during an error shutdown message we may need to transmit
// the shutdown message after the server has shutdown, so
// specfically check for it
if (!sv.state)
{
return;
}
leafnum = CM_PointLeafnum(origin);
clientarea = CM_LeafArea(leafnum);
clientcluster = CM_LeafCluster(leafnum);
// calculate the visible areas
frame->areabytes = CM_WriteAreaBits(frame->areabits, clientarea);
clientpvs = CM_ClusterPVS(clientcluster);
playerEnt = SV_GentityNum(frame->ps.clientNum);
if (playerEnt->r.svFlags & SVF_SELF_PORTAL)
{
#ifdef FEATURE_ANTICHEAT
SV_AddEntitiesVisibleFromPoint(playerEnt->s.origin2, frame, eNums, qtrue); // portal qtrue?!
#else
SV_AddEntitiesVisibleFromPoint(playerEnt->s.origin2, frame, eNums);
#endif
}
for (e = 0 ; e < sv.num_entities ; e++)
{
ent = SV_GentityNum(e);
// never send entities that aren't linked in
if (!ent->r.linked)
{
continue;
}
if (ent->s.number != e)
{
Com_DPrintf("FIXING ENT->S.NUMBER!!!\n");
ent->s.number = e;
}
// entities can be flagged to explicitly not be sent to the client
if (ent->r.svFlags & SVF_NOCLIENT)
{
continue;
}
// entities can be flagged to be sent to only one client
if (ent->r.svFlags & SVF_SINGLECLIENT)
{
if (ent->r.singleClient != frame->ps.clientNum)
{
continue;
}
}
// entities can be flagged to be sent to everyone but one client
if (ent->r.svFlags & SVF_NOTSINGLECLIENT)
{
if (ent->r.singleClient == frame->ps.clientNum)
{
continue;
}
}
svEnt = SV_SvEntityForGentity(ent);
// don't double add an entity through portals
if (svEnt->snapshotCounter == sv.snapshotCounter)
{
continue;
}
// broadcast entities are always sent
if (ent->r.svFlags & SVF_BROADCAST)
{
SV_AddEntToSnapshot(playerEnt, svEnt, ent, eNums);
continue;
}
bitvector = clientpvs;
// just check origin for being in pvs, ignore bmodel extents
if (ent->r.svFlags & SVF_IGNOREBMODELEXTENTS)
//.........这里部分代码省略.........
示例6: CL_ParseSnapshot
/*
================
CL_ParseSnapshot
If the snapshot is parsed properly, it will be copied to
cl.snap and saved in cl.snapshots[]. If the snapshot is invalid
for any reason, no changes to the state will be made at all.
================
*/
void CL_ParseSnapshot( msg_t *msg ) {
int len;
clSnapshot_t *old;
clSnapshot_t newSnap;
int deltaNum;
int oldMessageNum;
int i, packetNum;
// get the reliable sequence acknowledge number
// NOTE: now sent with all server to client messages
//clc.reliableAcknowledge = MSG_ReadLong( msg );
// read in the new snapshot to a temporary buffer
// we will only copy to cl.snap if it is valid
Com_Memset (&newSnap, 0, sizeof(newSnap));
// we will have read any new server commands in this
// message before we got to svc_snapshot
newSnap.serverCommandNum = clc.serverCommandSequence;
newSnap.serverTime = MSG_ReadLong( msg );
// if we were just unpaused, we can only *now* really let the
// change come into effect or the client hangs.
cl_paused->modified = qfalse;
newSnap.messageNum = clc.serverMessageSequence;
deltaNum = MSG_ReadByte( msg );
if ( !deltaNum ) {
newSnap.deltaNum = -1;
} else {
newSnap.deltaNum = newSnap.messageNum - deltaNum;
}
newSnap.snapFlags = MSG_ReadByte( msg );
// If the frame is delta compressed from data that we
// no longer have available, we must suck up the rest of
// the frame, but not use it, then ask for a non-compressed
// message
if ( newSnap.deltaNum <= 0 ) {
newSnap.valid = qtrue; // uncompressed frame
old = NULL;
clc.demowaiting = qfalse; // we can start recording now
} else {
old = &cl.snapshots[newSnap.deltaNum & PACKET_MASK];
if ( !old->valid ) {
// should never happen
Com_Printf ("Delta from invalid frame (not supposed to happen!).\n");
while ( ( newSnap.deltaNum & PACKET_MASK ) != ( newSnap.messageNum & PACKET_MASK ) && !old->valid ) {
newSnap.deltaNum++;
old = &cl.snapshots[newSnap.deltaNum & PACKET_MASK];
}
if ( old->valid ) {
Com_Printf ("Found more recent frame to delta from.\n");
}
}
if ( !old->valid ) {
Com_Printf ("Failed to find more recent frame to delta from.\n");
} else if ( old->messageNum != newSnap.deltaNum ) {
// The frame that the server did the delta from
// is too old, so we can't reconstruct it properly.
Com_Printf ("Delta frame too old.\n");
} else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES-128 ) {
Com_DPrintf ("Delta parseEntitiesNum too old.\n");
} else {
newSnap.valid = qtrue; // valid delta parse
}
}
// read areamask
len = MSG_ReadByte( msg );
if((unsigned)len > sizeof(newSnap.areamask))
{
Com_Error (ERR_DROP,"CL_ParseSnapshot: Invalid size %d for areamask", len);
return;
}
MSG_ReadData( msg, &newSnap.areamask, len);
// read playerinfo
SHOWNET( msg, "playerstate" );
if ( old ) {
MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );
if (newSnap.ps.m_iVehicleNum)
{ //this means we must have written our vehicle's ps too
MSG_ReadDeltaPlayerstate( msg, &old->vps, &newSnap.vps, qtrue );
}
} else {
MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );
//.........这里部分代码省略.........
示例7: Key_Event
//.........这里部分代码省略.........
// menu key is hardcoded, so the user can never unbind it
if( key == K_ESCAPE )
{
if( ! down )
{
return;
}
// if (cl.frame.playerstate.stats[STAT_LAYOUTS] && ClientStatic.key_dest == key_game)
// { // put away help computer / inventory
// Cbuf_AddText ("cmd putaway\n");
// return;
// }
switch( ClientStatic.key_dest )
{
case key_message:
Key_Message( key );
break;
case KEY_AUTOMAP:
automap_keydown( key );
break;
case key_menu:
M_Keydown( key );
break;
case key_game:
case key_console:
M_Menu_Main_f();
break;
default:
Com_DPrintf( "Bad ClientStatic.key_dest\n" );
}
return;
}
// track if any key is down for BUTTON_ANY
keydown[key] = down;
if (down)
{
if (key_repeats[key] == 1)
{
anykeydown++;
}
}
else
{
anykeydown--;
if (anykeydown < 0)
{
anykeydown = 0;
}
}
//
// key up events only generate commands if the game key binding is
// a button command (leading + sign). These will occur even in console mode,
// to keep the character from continuing an action started before a console
// switch. Button commands include the kenum as a parameter, so multiple
// downs can be matched with ups
//
if( ! down )
{
kb = keybindings[key];
示例8: CL_WritePacket
//.........这里部分代码省略.........
if (clc.voipOutgoingDataSize > 0) { // only send if data.
MSG_WriteByte (&buf, clc_EOF); // placate legacy servers.
MSG_WriteByte (&buf, clc_extension);
MSG_WriteByte (&buf, clc_voip);
MSG_WriteByte (&buf, clc.voipOutgoingGeneration);
MSG_WriteLong (&buf, clc.voipOutgoingSequence);
MSG_WriteByte (&buf, clc.voipOutgoingDataFrames);
MSG_WriteLong (&buf, clc.voipTarget1);
MSG_WriteLong (&buf, clc.voipTarget2);
MSG_WriteLong (&buf, clc.voipTarget3);
MSG_WriteShort (&buf, clc.voipOutgoingDataSize);
MSG_WriteData (&buf, clc.voipOutgoingData, clc.voipOutgoingDataSize);
// If we're recording a demo, we have to fake a server packet with
// this VoIP data so it gets to disk; the server doesn't send it
// back to us, and we might as well eliminate concerns about dropped
// and misordered packets here.
if ( clc.demorecording && !clc.demowaiting ) {
const int voipSize = clc.voipOutgoingDataSize;
msg_t fakemsg;
byte fakedata[MAX_MSGLEN];
MSG_Init (&fakemsg, fakedata, sizeof (fakedata));
MSG_Bitstream (&fakemsg);
MSG_WriteLong (&fakemsg, clc.reliableAcknowledge);
MSG_WriteByte (&fakemsg, svc_EOF);
MSG_WriteByte (&fakemsg, svc_extension);
MSG_WriteByte (&fakemsg, svc_voip);
MSG_WriteShort (&fakemsg, clc.clientNum);
MSG_WriteByte (&fakemsg, clc.voipOutgoingGeneration);
MSG_WriteLong (&fakemsg, clc.voipOutgoingSequence);
MSG_WriteByte (&fakemsg, clc.voipOutgoingDataFrames);
MSG_WriteShort (&fakemsg, clc.voipOutgoingDataSize );
MSG_WriteData (&fakemsg, clc.voipOutgoingData, voipSize);
MSG_WriteByte (&fakemsg, svc_EOF);
CL_WriteDemoMessage (&fakemsg, 0);
}
clc.voipOutgoingSequence += clc.voipOutgoingDataFrames;
clc.voipOutgoingDataSize = 0;
clc.voipOutgoingDataFrames = 0;
} else
#endif
if ( count >= 1 ) {
if ( cl_showSend->integer ) {
Com_Printf( "(%i)", count );
}
// begin a client move command
if ( cl_nodelta->integer || !cl.snap.valid || clc.demowaiting
|| clc.serverMessageSequence != cl.snap.messageNum ) {
MSG_WriteByte (&buf, clc_moveNoDelta);
} else {
MSG_WriteByte (&buf, clc_move);
}
// write the command count
MSG_WriteByte( &buf, count );
// use the checksum feed in the key
key = clc.checksumFeed;
// also use the message acknowledge
key ^= clc.serverMessageSequence;
// also use the last acknowledged server command in the key
key ^= MSG_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);
// write all the commands, including the predicted command
for ( i = 0 ; i < count ; i++ ) {
j = (cl.cmdNumber - count + i + 1) & CMD_MASK;
cmd = &cl.cmds[j];
MSG_WriteDeltaUsercmdKey (&buf, key, oldcmd, cmd);
oldcmd = cmd;
}
}
//
// deliver the message
//
packetNum = clc.netchan.outgoingSequence & PACKET_MASK;
cl.outPackets[ packetNum ].p_realtime = cls.realtime;
cl.outPackets[ packetNum ].p_serverTime = oldcmd->serverTime;
cl.outPackets[ packetNum ].p_cmdNumber = cl.cmdNumber;
clc.lastPacketSentTime = cls.realtime;
if ( cl_showSend->integer ) {
Com_Printf( "%i ", buf.cursize );
}
CL_Netchan_Transmit (&clc.netchan, &buf);
// clients never really should have messages large enough
// to fragment, but in case they do, fire them all off
// at once
// TTimo: this causes a packet burst, which is bad karma for winsock
// added a WARNING message, we'll see if there are legit situations where this happens
while ( clc.netchan.unsentFragments ) {
Com_DPrintf( "WARNING: #462 unsent fragments (not supposed to happen!)\n" );
CL_Netchan_TransmitNextFragment( &clc.netchan );
}
}
示例9: VectorCopy
//.........这里部分代码省略.........
yaw = RAD2DEG(mArea->GetAngle() + mBaseAngle) + 180;
}
else
{
yaw = RAD2DEG(mArea->GetAngle() + mBaseAngle);
}
/*
if( TheRandomMissionManager->GetMission()->GetSymmetric() )
{
vec3_t diagonal;
vec3_t lineToPoint;
vec3_t mins;
vec3_t maxs;
vec3_t point;
vec3_t vProj;
vec3_t vec;
float distance;
VectorCopy( TheRandomMissionManager->GetLandScape()->GetBounds()[1], maxs );
VectorCopy( TheRandomMissionManager->GetLandScape()->GetBounds()[0], mins );
VectorCopy( GetOrigin(), point );
mins[2] = maxs[2] = point[2] = 0;
VectorSubtract( point, mins, lineToPoint );
VectorSubtract( maxs, mins, diagonal);
VectorNormalize(diagonal);
VectorMA( mins, DotProduct(lineToPoint, diagonal), diagonal, vProj);
VectorSubtract(point, vProj, vec );
distance = VectorLength(vec);
// if an instance is too close to the imaginary diagonal that cuts the world in half, don't spawn it
// otherwise you can get overlapping instances
if( distance < GetSpacingRadius() )
{
#ifdef _DEBUG
mAutomapSymbol = AUTOMAP_END;
#endif
if( !HasObjective() )
{
return false;
}
}
}
*/
// Spawn in the bsp model
sprintf(temp,
"{\n"
"\"classname\" \"misc_bsp\"\n"
"\"bspmodel\" \"%s\"\n"
"\"origin\" \"%f %f %f\"\n"
"\"angles\" \"0 %f 0\"\n"
"\"filter\" \"%s\"\n"
"\"teamfilter\" \"%s\"\n"
"\"spacing\" \"%d\"\n"
"\"flatten\" \"%d\"\n"
"}\n",
mBsp,
GetOrigin()[0], GetOrigin()[1], GetOrigin()[2],
AngleNormalize360(yaw),
mFilter,
mTeamFilter,
(int)GetSpacingRadius(),
(int)GetFlattenRadius()
);
if (IsServer)
{ // only allow for true spawning on the server
savePtr = sv.entityParsePoint;
sv.entityParsePoint = temp;
// VM_Call( cgvm, GAME_SPAWN_RMG_ENTITY );
// char *s;
int bufferSize = 1024;
char buffer[1024];
// s = COM_Parse( (const char **)&sv.entityParsePoint );
Q_strncpyz( buffer, sv.entityParsePoint, bufferSize );
if ( sv.entityParsePoint && sv.entityParsePoint[0] )
{
ge->GameSpawnRMGEntity(sv.entityParsePoint);
}
sv.entityParsePoint = savePtr;
}
#ifndef DEDICATED
DrawAutomapSymbol();
#endif
Com_DPrintf( "RMG: Building '%s' spawned at (%f %f %f)\n", mBsp, GetOrigin()[0], GetOrigin()[1], GetOrigin()[2] );
// now restore the instances un-mirrored origin
// NOTE: all this origin flipping, setting the side etc... should be done when mMirror is set
// because right after this function is called, mMirror is set to 0 but all the instance data is STILL MIRRORED -- not good
VectorCopy(notmirrored, GetOrigin());
#endif // PRE_RELEASE_DEMO
return true;
}
示例10: G_Damage
/**
* @brief Deals damage of a give type and amount to a target.
* @param[in,out] target What we want to damage.
* @param[in] fd The fire definition that defines what type of damage is dealt.
* @param[in] damage The value of the damage.
* @param[in] attacker The attacker.
* @param[in] mock pseudo shooting - only for calculating mock values - nullptr for real shots
* @param[in] impact impact location - @c nullptr for splash damage
* @sa G_SplashDamage
* @sa G_TakeDamage
* @sa G_PrintActorStats
*/
static void G_Damage (Edict* target, const fireDef_t* fd, int damage, Edict* attacker, shot_mock_t* mock, const vec3_t impact)
{
const bool stunEl = (fd->obj->dmgtype == gi.csi->damStunElectro);
const bool stunGas = (fd->obj->dmgtype == gi.csi->damStunGas);
const bool shock = (fd->obj->dmgtype == gi.csi->damShock);
const bool smoke = (fd->obj->dmgtype == gi.csi->damSmoke);
bool isRobot;
assert(target);
/* Breakables */
if (G_IsBrushModel(target) && G_IsBreakable(target)) {
/* Breakables are immune to stun & shock damage. */
if (stunEl || stunGas || shock || mock || smoke)
return;
if (damage >= target->HP) {
/* don't reset the HP value here, this value is used to distinguish
* between triggered destroy and a shoot */
assert(target->destroy);
target->destroy(target);
/* maybe the attacker is seeing something new? */
G_CheckVisTeamAll(attacker->team, 0, attacker);
/* check if attacker appears/perishes for any other team */
G_CheckVis(attacker);
} else {
G_TakeDamage(target, damage);
}
return;
}
/* Actors don't die again. */
if (!G_IsLivingActor(target))
return;
/* only actors after this point - and they must have a teamdef */
assert(target->chr.teamDef);
isRobot = CHRSH_IsTeamDefRobot(target->chr.teamDef);
/* Apply armour effects. */
if (damage > 0) {
damage = G_ApplyProtection(target, fd->dmgweight, damage);
} else if (damage < 0) {
/* Robots can't be healed. */
if (isRobot)
return;
}
Com_DPrintf(DEBUG_GAME, " Total damage: %d\n", damage);
/* Apply difficulty settings. */
if (G_IsSinglePlayer()) {
if (G_IsAlien(attacker) && !G_IsAlien(target))
damage *= pow(1.18, g_difficulty->value);
else if (!G_IsAlien(attacker) && G_IsAlien(target))
damage *= pow(1.18, -g_difficulty->value);
}
assert(attacker->team >= 0 && attacker->team < MAX_TEAMS);
assert(target->team >= 0 && target->team < MAX_TEAMS);
if (g_nodamage != nullptr && !g_nodamage->integer) {
/* hit */
if (mock) {
G_UpdateShotMock(mock, attacker, target, damage);
} else if (stunEl) {
target->STUN += damage;
} else if (stunGas) {
if (!isRobot) /* Can't stun robots with gas */
target->STUN += damage;
} else if (shock) {
/* Only do this if it's not one from our own team ... they should have known that there was a flashbang coming. */
if (!isRobot && target->team != attacker->team) {
/** @todo there should be a possible protection, too */
/* dazed entity wont reaction fire */
G_RemoveReaction(target);
G_ActorReserveTUs(target, 0, target->chr.reservedTus.shot, target->chr.reservedTus.crouch);
/* flashbangs kill TUs */
G_ActorSetTU(target, 0);
G_SendStats(*target);
/* entity is dazed */
G_SetDazed(target);
G_ClientPrintf(target->getPlayer(), PRINT_HUD, _("Soldier is dazed!\nEnemy used flashbang!"));
return;
}
} else {
if (damage < 0) {
//.........这里部分代码省略.........
示例11: S_RawSamples
/*
============
S_RawSamples
Music streaming
============
*/
void S_RawSamples( int samples, int rate, int width, int s_channels, const byte *data, float volume ) {
int i;
int src, dst;
float scale;
int intVolume;
if ( !s_soundStarted || s_soundMuted ) {
return;
}
intVolume = 256 * volume;
if ( s_rawend < s_soundtime ) {
Com_DPrintf( "S_RawSamples: resetting minimum: %i < %i\n", s_rawend, s_soundtime );
s_rawend = s_soundtime;
}
scale = (float)rate / dma.speed;
//Com_Printf ("%i < %i < %i\n", s_soundtime, s_paintedtime, s_rawend);
if (s_channels == 2 && width == 2)
{
if (scale == 1.0)
{ // optimized case
for (i=0 ; i<samples ; i++)
{
dst = s_rawend&(MAX_RAW_SAMPLES-1);
s_rawend++;
s_rawsamples[dst].left = ((short *)data)[i*2] * intVolume;
s_rawsamples[dst].right = ((short *)data)[i*2+1] * intVolume;
}
}
else
{
for (i=0 ; ; i++)
{
src = i*scale;
if (src >= samples)
break;
dst = s_rawend&(MAX_RAW_SAMPLES-1);
s_rawend++;
s_rawsamples[dst].left = ((short *)data)[src*2] * intVolume;
s_rawsamples[dst].right = ((short *)data)[src*2+1] * intVolume;
}
}
}
else if (s_channels == 1 && width == 2)
{
for (i=0 ; ; i++)
{
src = i*scale;
if (src >= samples)
break;
dst = s_rawend&(MAX_RAW_SAMPLES-1);
s_rawend++;
s_rawsamples[dst].left = ((short *)data)[src] * intVolume;
s_rawsamples[dst].right = ((short *)data)[src] * intVolume;
}
}
else if (s_channels == 2 && width == 1)
{
intVolume *= 256;
for (i=0 ; ; i++)
{
src = i*scale;
if (src >= samples)
break;
dst = s_rawend&(MAX_RAW_SAMPLES-1);
s_rawend++;
s_rawsamples[dst].left = ((char *)data)[src*2] * intVolume;
s_rawsamples[dst].right = ((char *)data)[src*2+1] * intVolume;
}
}
else if (s_channels == 1 && width == 1)
{
intVolume *= 256;
for (i=0 ; ; i++)
{
src = i*scale;
if (src >= samples)
break;
dst = s_rawend&(MAX_RAW_SAMPLES-1);
s_rawend++;
s_rawsamples[dst].left = (((byte *)data)[src]-128) * intVolume;
s_rawsamples[dst].right = (((byte *)data)[src]-128) * intVolume;
}
}
if ( s_rawend > s_soundtime + MAX_RAW_SAMPLES ) {
Com_DPrintf( "S_RawSamples: overflowed %i > %i\n", s_rawend, s_soundtime );
}
//.........这里部分代码省略.........
示例12: S_StartBackgroundTrack
/*
======================
S_StartBackgroundTrack
======================
*/
void S_StartBackgroundTrack( const char *intro, const char *loop ){
int len;
char dump[16];
char name[MAX_QPATH];
if ( !intro ) {
intro = "";
}
if ( !loop || !loop[0] ) {
loop = intro;
}
Com_DPrintf( "S_StartBackgroundTrack( %s, %s )\n", intro, loop );
Q_strncpyz( name, intro, sizeof( name ) - 4 );
COM_DefaultExtension( name, sizeof( name ), ".wav" );
if ( !intro[0] ) {
return;
}
Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );
// close the background track, but DON'T reset s_rawend
// if restarting the same back ground track
if ( s_backgroundFile ) {
Sys_EndStreamedFile( s_backgroundFile );
FS_FCloseFile( s_backgroundFile );
s_backgroundFile = 0;
}
//
// open up a wav file and get all the info
//
FS_FOpenFileRead( name, &s_backgroundFile, qtrue );
if ( !s_backgroundFile ) {
Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", name );
return;
}
// skip the riff wav header
FS_Read(dump, 12, s_backgroundFile);
if ( !S_FindWavChunk( s_backgroundFile, "fmt " ) ) {
Com_Printf( "No fmt chunk in %s\n", name );
FS_FCloseFile( s_backgroundFile );
s_backgroundFile = 0;
return;
}
// save name for soundinfo
s_backgroundInfo.format = FGetLittleShort( s_backgroundFile );
s_backgroundInfo.channels = FGetLittleShort( s_backgroundFile );
s_backgroundInfo.rate = FGetLittleLong( s_backgroundFile );
FGetLittleLong( s_backgroundFile );
FGetLittleShort( s_backgroundFile );
s_backgroundInfo.width = FGetLittleShort( s_backgroundFile ) / 8;
if ( s_backgroundInfo.format != WAV_FORMAT_PCM ) {
FS_FCloseFile( s_backgroundFile );
s_backgroundFile = 0;
Com_Printf("Not a microsoft PCM format wav: %s\n", name);
return;
}
if ( s_backgroundInfo.channels != 2 || s_backgroundInfo.rate != 22050 ) {
Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", name );
}
if ( ( len = S_FindWavChunk( s_backgroundFile, "data" ) ) == 0 ) {
FS_FCloseFile( s_backgroundFile );
s_backgroundFile = 0;
Com_Printf("No data chunk in %s\n", name);
return;
}
s_backgroundInfo.samples = len / (s_backgroundInfo.width * s_backgroundInfo.channels);
s_backgroundSamples = s_backgroundInfo.samples;
//
// start the background streaming
//
Sys_BeginStreamedFile( s_backgroundFile, 0x10000 );
}
示例13: IN_ProcessEvents
/*
===============
IN_ProcessEvents
===============
*/
static void IN_ProcessEvents( void )
{
SDL_Event e;
fakeAscii_t key = A_NULL;
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
return;
while( SDL_PollEvent( &e ) )
{
switch( e.type )
{
case SDL_KEYDOWN:
if (e.key.keysym.scancode == SDL_SCANCODE_GRAVE) {
Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qtrue, 0, NULL );
} else {
key = IN_TranslateSDLToJKKey( &e.key.keysym, qtrue );
if ( key != A_NULL ) {
fakeAscii_t upperKey = key;
if (e.key.keysym.sym >= A_LOW_A && e.key.keysym.sym <= A_LOW_Z) {
upperKey = (fakeAscii_t)(A_CAP_A + (e.key.keysym.sym - A_LOW_A));
} else if (e.key.keysym.sym >= A_LOW_AGRAVE && e.key.keysym.sym <= A_LOW_THORN && e.key.keysym.sym != A_DIVIDE) {
upperKey = (fakeAscii_t)(A_CAP_AGRAVE + (e.key.keysym.sym - A_LOW_AGRAVE));
}
Sys_QueEvent( 0, SE_KEY, upperKey, qtrue, 0, NULL );
}
if ( key == A_BACKSPACE )
Sys_QueEvent( 0, SE_CHAR, CTRL('h'), qfalse, 0, NULL);
else if ( kg.keys[A_CTRL].down && key >= 'a' && key <= 'z' )
Sys_QueEvent( 0, SE_CHAR, CTRL(key), qfalse, 0, NULL );
}
break;
case SDL_KEYUP:
if (e.key.keysym.scancode == SDL_SCANCODE_GRAVE) {
Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qfalse, 0, NULL );
} else {
key = IN_TranslateSDLToJKKey( &e.key.keysym, qfalse );
if( key != A_NULL ) {
fakeAscii_t upperKey = key;
if (e.key.keysym.sym >= A_LOW_A && e.key.keysym.sym <= A_LOW_Z) {
upperKey = (fakeAscii_t)(A_CAP_A + (e.key.keysym.sym - A_LOW_A));
} else if (e.key.keysym.sym >= A_LOW_AGRAVE && e.key.keysym.sym <= A_LOW_THORN && e.key.keysym.sym != A_DIVIDE) {
upperKey = (fakeAscii_t)(A_CAP_AGRAVE + (e.key.keysym.sym - A_LOW_AGRAVE));
}
Sys_QueEvent( 0, SE_KEY, upperKey, qfalse, 0, NULL );
}
}
if ( ( e.key.keysym.scancode == SDL_SCANCODE_LGUI || e.key.keysym.scancode == SDL_SCANCODE_RGUI ) &&
Cvar_VariableIntegerValue("r_fullscreen")) {
SDL_MinimizeWindow(SDL_window);
}
break;
case SDL_TEXTINPUT:
{
char *c = e.text.text;
// Quick and dirty UTF-8 to UTF-32 conversion
while( *c )
{
int utf32 = 0;
if( ( *c & 0x80 ) == 0 )
utf32 = *c++;
else if( ( *c & 0xE0 ) == 0xC0 ) // 110x xxxx
{
utf32 |= ( *c++ & 0x1F ) << 6;
utf32 |= ( *c++ & 0x3F );
}
else if( ( *c & 0xF0 ) == 0xE0 ) // 1110 xxxx
{
utf32 |= ( *c++ & 0x0F ) << 12;
utf32 |= ( *c++ & 0x3F ) << 6;
utf32 |= ( *c++ & 0x3F );
}
else if( ( *c & 0xF8 ) == 0xF0 ) // 1111 0xxx
{
utf32 |= ( *c++ & 0x07 ) << 18;
utf32 |= ( *c++ & 0x3F ) << 12;
utf32 |= ( *c++ & 0x3F ) << 6;
utf32 |= ( *c++ & 0x3F );
}
else
{
Com_DPrintf( "Unrecognised UTF-8 lead byte: 0x%x\n", (unsigned int)*c );
c++;
}
if( utf32 != 0 )
//.........这里部分代码省略.........
示例14: CL_ConnectionlessPacket
/*
=================
CL_ConnectionlessPacket
Responses to broadcasts, etc
=================
*/
void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
char *s;
const char *c;
MSG_BeginReading( msg );
MSG_ReadLong( msg ); // skip the -1
s = MSG_ReadStringLine( msg );
Cmd_TokenizeString( s );
c = Cmd_Argv(0);
Com_DPrintf ("CL packet %s: %s\n", NET_AdrToString(from), c);
// challenge from the server we are connecting to
if ( !strcmp(c, "challengeResponse") ) {
if ( cls.state != CA_CONNECTING ) {
Com_Printf( "Unwanted challenge response received. Ignored.\n" );
} else {
// start sending challenge repsonse instead of challenge request packets
clc.challenge = atoi(Cmd_Argv(1));
cls.state = CA_CHALLENGING;
clc.connectPacketCount = 0;
clc.connectTime = -99999;
// take this address as the new server address. This allows
// a server proxy to hand off connections to multiple servers
clc.serverAddress = from;
}
return;
}
// server connection
if ( !strcmp(c, "connectResponse") ) {
if ( cls.state >= CA_CONNECTED ) {
Com_Printf ("Dup connect received. Ignored.\n");
return;
}
if ( cls.state != CA_CHALLENGING ) {
Com_Printf ("connectResponse packet while not connecting. Ignored.\n");
return;
}
if ( !NET_CompareBaseAdr( from, clc.serverAddress ) ) {
Com_Printf( "connectResponse from a different address. Ignored.\n" );
Com_Printf( "%s should have been %s\n", NET_AdrToString( from ),
NET_AdrToString( clc.serverAddress ) );
return;
}
Netchan_Setup (NS_CLIENT, &clc.netchan, from, Cvar_VariableIntegerValue( "net_qport" ) );
cls.state = CA_CONNECTED;
clc.lastPacketSentTime = -9999; // send first packet immediately
return;
}
// a disconnect message from the server, which will happen if the server
// dropped the connection but it is still getting packets from us
if (!strcmp(c, "disconnect")) {
CL_DisconnectPacket( from );
return;
}
// echo request from server
if ( !strcmp(c, "echo") ) {
NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) );
return;
}
// print request from server
if ( !strcmp(c, "print") ) {
s = MSG_ReadString( msg );
UI_UpdateConnectionMessageString( s );
Com_Printf( "%s", s );
return;
}
Com_DPrintf ("Unknown connectionless packet command.\n");
}
示例15: CL_ParseServerData
/*
* CL_ParseServerData
*/
static void CL_ParseServerData( msg_t *msg )
{
const char *str, *gamedir;
int i, sv_bitflags, numpure;
int http_portnum;
Com_DPrintf( "Serverdata packet received.\n" );
// wipe the client_state_t struct
CL_ClearState();
CL_SetClientState( CA_CONNECTED );
// parse protocol version number
i = MSG_ReadLong( msg );
if( i != APP_PROTOCOL_VERSION && !(cls.demo.playing && i == APP_DEMO_PROTOCOL_VERSION) )
Com_Error( ERR_DROP, "Server returned version %i, not %i", i, APP_PROTOCOL_VERSION );
cl.servercount = MSG_ReadLong( msg );
cl.snapFrameTime = (unsigned int)MSG_ReadShort( msg );
cl.gamestart = true;
// set extrapolation time to half snapshot time
Cvar_ForceSet( "cl_extrapolationTime", va( "%i", (unsigned int)( cl.snapFrameTime * 0.5 ) ) );
cl_extrapolationTime->modified = false;
// base game directory
str = MSG_ReadString( msg );
if( !str || !str[0] )
Com_Error( ERR_DROP, "Server sent an empty base game directory" );
if( !COM_ValidateRelativeFilename( str ) || strchr( str, '/' ) )
Com_Error( ERR_DROP, "Server sent an invalid base game directory: %s", str );
if( strcmp( FS_BaseGameDirectory(), str ) )
{
Com_Error( ERR_DROP, "Server has different base game directory (%s) than the client (%s)", str,
FS_BaseGameDirectory() );
}
// game directory
str = MSG_ReadString( msg );
if( !str || !str[0] )
Com_Error( ERR_DROP, "Server sent an empty game directory" );
if( !COM_ValidateRelativeFilename( str ) || strchr( str, '/' ) )
Com_Error( ERR_DROP, "Server sent an invalid game directory: %s", str );
gamedir = FS_GameDirectory();
if( strcmp( str, gamedir ) )
{
// shutdown the cgame module first in case it is running for whatever reason
// (happens on wswtv in lobby), otherwise precaches that are going to follow
// will probably fuck up (like models trying to load before the world model)
CL_GameModule_Shutdown();
if( !FS_SetGameDirectory( str, true ) )
Com_Error( ERR_DROP, "Failed to load game directory set by server: %s", str );
ML_Restart( true );
}
// parse player entity number
cl.playernum = MSG_ReadShort( msg );
// get the full level name
Q_strncpyz( cl.servermessage, MSG_ReadString( msg ), sizeof( cl.servermessage ) );
sv_bitflags = MSG_ReadByte( msg );
if( cls.demo.playing )
{
cls.reliable = ( sv_bitflags & SV_BITFLAGS_RELIABLE );
}
else
{
if( cls.reliable != ( ( sv_bitflags & SV_BITFLAGS_RELIABLE ) != 0 ) )
Com_Error( ERR_DROP, "Server and client disagree about connection reliability" );
}
// builting HTTP server port
if( cls.httpbaseurl ) {
Mem_Free( cls.httpbaseurl );
cls.httpbaseurl = NULL;
}
if( ( sv_bitflags & SV_BITFLAGS_HTTP ) != 0 ) {
if( ( sv_bitflags & SV_BITFLAGS_HTTP_BASEURL ) != 0 ) {
// read base upstream url
cls.httpbaseurl = ZoneCopyString( MSG_ReadString( msg ) );
}
else {
http_portnum = MSG_ReadShort( msg ) & 0xffff;
cls.httpaddress = cls.serveraddress;
if( cls.httpaddress.type == NA_IP6 ) {
cls.httpaddress.address.ipv6.port = BigShort( http_portnum );
} else {
cls.httpaddress.address.ipv4.port = BigShort( http_portnum );
}
if( http_portnum ) {
if( cls.httpaddress.type == NA_LOOPBACK ) {
//.........这里部分代码省略.........