本文整理匯總了C++中Com_Printf函數的典型用法代碼示例。如果您正苦於以下問題:C++ Com_Printf函數的具體用法?C++ Com_Printf怎麽用?C++ Com_Printf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Com_Printf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CL_UISystemCalls
intptr_t CL_UISystemCalls( intptr_t *args ) {
switch( args[0] ) {
//rww - alright, DO NOT EVER add a GAME/CGAME/UI generic call without adding a trap to match, and
//all of these traps must be shared and have cases in sv_game, cl_cgame, and cl_ui. They must also
//all be in the same order, and start at 100.
case TRAP_MEMSET:
Com_Memset( VMA(1), args[2], args[3] );
return 0;
case TRAP_MEMCPY:
Com_Memcpy( VMA(1), VMA(2), args[3] );
return 0;
case TRAP_STRNCPY:
return (int)strncpy( (char *)VMA(1), (const char *)VMA(2), args[3] );
case TRAP_SIN:
return FloatAsInt( sin( VMF(1) ) );
case TRAP_COS:
return FloatAsInt( cos( VMF(1) ) );
case TRAP_ATAN2:
return FloatAsInt( atan2( VMF(1), VMF(2) ) );
case TRAP_SQRT:
return FloatAsInt( sqrt( VMF(1) ) );
case TRAP_MATRIXMULTIPLY:
MatrixMultiply( (vec3_t *)VMA(1), (vec3_t *)VMA(2), (vec3_t *)VMA(3) );
return 0;
case TRAP_ANGLEVECTORS:
AngleVectors( (const float *)VMA(1), (float *)VMA(2), (float *)VMA(3), (float *)VMA(4) );
return 0;
case TRAP_PERPENDICULARVECTOR:
PerpendicularVector( (float *)VMA(1), (const float *)VMA(2) );
return 0;
case UI_ERROR:
Com_Error( ERR_DROP, "%s", VMA(1) );
return 0;
case UI_PRINT:
Com_Printf( "%s", VMA(1) );
return 0;
case UI_MILLISECONDS:
return Sys_Milliseconds();
case UI_CVAR_REGISTER:
Cvar_Register( (vmCvar_t *)VMA(1), (const char *)VMA(2), (const char *)VMA(3), args[4] );
return 0;
case UI_CVAR_UPDATE:
Cvar_Update( (vmCvar_t *)VMA(1) );
return 0;
case UI_CVAR_SET:
Cvar_Set( (const char *)VMA(1), (const char *)VMA(2) );
return 0;
case UI_CVAR_VARIABLEVALUE:
return FloatAsInt( Cvar_VariableValue( (const char *)VMA(1) ) );
case UI_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( (const char *)VMA(1), (char *)VMA(2), args[3] );
return 0;
case UI_CVAR_SETVALUE:
Cvar_SetValue( (const char *)VMA(1), VMF(2) );
return 0;
case UI_CVAR_RESET:
Cvar_Reset( (const char *)VMA(1) );
return 0;
case UI_CVAR_CREATE:
Cvar_Get( (const char *)VMA(1), (const char *)VMA(2), args[3] );
return 0;
case UI_CVAR_INFOSTRINGBUFFER:
Cvar_InfoStringBuffer( args[1], (char *)VMA(2), args[3] );
return 0;
case UI_ARGC:
return Cmd_Argc();
case UI_ARGV:
Cmd_ArgvBuffer( args[1], (char *)VMA(2), args[3] );
return 0;
case UI_CMD_EXECUTETEXT:
Cbuf_ExecuteText( args[1], (const char *)VMA(2) );
return 0;
case UI_FS_FOPENFILE:
return FS_FOpenFileByMode( (const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3] );
case UI_FS_READ:
FS_Read2( VMA(1), args[2], args[3] );
return 0;
case UI_FS_WRITE:
FS_Write( VMA(1), args[2], args[3] );
return 0;
//.........這裏部分代碼省略.........
示例2: ASTAR_FindPathFast
//.........這裏部分代碼省略.........
/*
float height_diff = 0.0f;
float cost = 0.0f;
cost = Distance(gWPArray[newnode]->origin, gWPArray[atNode]->origin);
height_diff = HeightDistance(gWPArray[newnode]->origin, gWPArray[atNode]->origin);
cost += (height_diff * height_diff); // Squared for massive preferance to staying at same plane...
gWPArray[atNode]->neighbors[i].cost = cost;
gc += cost;
*/
}
if ( gc < gcost[newnode] ) //if the new gcost is less (ie, this path is shorter than what we had before)
{
parent[newnode] = atNode; //set the new parent for this node
gcost[newnode] = gc; //and the new g cost
for ( j = 1; j < numOpen; j++ ) //loop through all the items on the open list
{
if ( openlist[j] == newnode ) //find this node in the list
{
//calculate the new fcost and store it
fcost[newnode] = BOT_GetFCost( bot, to, newnode, parent[newnode], gcost );
//reorder the list again, with the lowest fcost item on top
m = j;
while ( m != 1 )
{
if ( fcost[openlist[m]] < fcost[openlist[m / 2]] ) //if the item has a lower fcost than it's parent
{
temp = openlist[m / 2];
openlist[m / 2] = openlist[m];
openlist[m] = temp; //swap them
m /= 2;
}
else
{
break;
}
}
break; //exit the 'for' loop because we already changed this node
} //if
} //for
} //if (gc < gcost[newnode])
} //if (list[newnode] != 1) --> else
} //for (loop through links)
} //if (numOpen != 0)
else
{
found = qfalse; //there is no path between these nodes
break;
}
if ( list[to] == 1 ) //if the destination node is on the open list, we're done
{
found = qtrue;
break;
}
} //while (1)
if ( found == qtrue ) //if we found a path, and are trying to store the pathlist...
{
count = 0;
temp = to; //start at the end point
while ( temp != from ) //travel along the path (backwards) until we reach the starting point
{
if (count+1 >= MAX_WPARRAY_SIZE)
{
Com_Printf("ERROR: pathlist count > MAX_WPARRAY_SIZE.\n");
return -1; // UQ1: Added to stop crash if path is too long for the memory allocation...
}
pathlist[count++] = temp; //add the node to the pathlist and increment the count
temp = parent[temp]; //move to the parent of this node to continue the path
}
pathlist[count++] = from; //add the beginning node to the end of the pathlist
#ifdef __SLOW_PATHING__
if (shorten)
{// UQ1: Now use the path shortener on these waypoints...
int pathlist_copy[MAX_WPARRAY_SIZE];
memcpy(pathlist_copy, pathlist, sizeof(int)*(MAX_WPARRAY_SIZE));
count = ASTAR_ShortenPath(count, pathlist_copy, pathlist);
}
#endif //__SLOW_PATHING__
//G_Printf("Pathsize is %i.\n", count);
return ( count );
}
//G_Printf("Failed to find path.\n");
return ( -1 ); //return the number of nodes in the path, -1 if not found
}
示例3: Sys_GetPacket
bool Sys_GetPacket( netadr_t *net_from, msg_t *net_message ) {
int ret;
struct sockaddr from;
int fromlen;
int net_socket;
int protocol;
int err;
for( protocol = 0 ; protocol < 2 ; protocol++ ) {
if( protocol == 0 ) {
net_socket = ip_socket;
}
else {
net_socket = ipx_socket;
}
if( !net_socket ) {
continue;
}
fromlen = sizeof(from);
recvfromCount++; // performance check
ret = recvfrom( net_socket, reinterpret_cast<char*>(net_message->data), net_message->maxsize, 0, (struct sockaddr *)&from, &fromlen );
if (ret == SOCKET_ERROR)
{
err = WSAGetLastError();
if( err == WSAEWOULDBLOCK || err == WSAECONNRESET ) {
continue;
}
Com_Printf( "NET_GetPacket: %s\n", NET_ErrorString() );
continue;
}
if ( net_socket == ip_socket ) {
memset( ((struct sockaddr_in *)&from)->sin_zero, 0, 8 );
}
if ( usingSocks && net_socket == ip_socket && memcmp( &from, &socksRelayAddr, fromlen ) == 0 ) {
if ( ret < 10 || net_message->data[0] != 0 || net_message->data[1] != 0 || net_message->data[2] != 0 || net_message->data[3] != 1 ) {
continue;
}
net_from->type = NA_IP;
net_from->ip[0] = net_message->data[4];
net_from->ip[1] = net_message->data[5];
net_from->ip[2] = net_message->data[6];
net_from->ip[3] = net_message->data[7];
net_from->port = *(short *)&net_message->data[8];
net_message->readcount = 10;
}
else {
SockadrToNetadr( &from, net_from );
net_message->readcount = 0;
}
if( ret == net_message->maxsize ) {
Com_Printf( "Oversize packet from %s\n", NET_AdrToString (*net_from) );
continue;
}
net_message->cursize = ret;
return true;
}
return false;
}
示例4: UI_RegisterClientModelname
//.........這裏部分代碼省略.........
if(teamval == 1)
{
backpack = "acc/backpack/backpack_cvops.md3";
helmet = "acc/helmet_american/cvops.md3";
}
else
{
backpack = "acc/backpack/backpack_german_cvops.md3";
helmet = "acc/helmet_german/helmet_cvops.md3";
}
}
else
{
playerClass = "lieutenant";
if(teamval == 1)
{
backpack = "acc/backpack/backpack_lieu.md3";
helmet = "acc/helmet_american/lieu.md3";
}
else
{
backpack = "acc/backpack/backpack_german_lieu.md3";
helmet = "acc/helmet_german/helmet_leiu.md3";
}
}
strcpy(skinName, va("%s%s1", team, playerClass));
}
// -NERVE - SMF
// Q_strncpyz( skinName, "bluesoldier1", sizeof( skinName ) ); // NERVE - SMF - make this work with wolf - TESTING!!!
// }
// else {
// Q_strncpyz( skinName, "redsoldier1", sizeof( skinName ) ); // NERVE - SMF - make this work with wolf - TESTING!!!
// }
// load cmodels before models so filecache works
// Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
Com_sprintf(filename, sizeof(filename), "models/players/%s/body.mds", modelName); // NERVE - SMF - make this work with wolf
pi->legsModel = trap_R_RegisterModel(filename);
if(!pi->legsModel)
{
Com_Printf("Failed to load model file %s\n", filename);
return qfalse;
}
// Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
Com_sprintf(filename, sizeof(filename), "models/players/%s/body.mds", modelName); // NERVE - SMF - make this work with wolf
pi->torsoModel = trap_R_RegisterModel(filename);
if(!pi->torsoModel)
{
Com_Printf("Failed to load model file %s\n", filename);
return qfalse;
}
Com_sprintf(filename, sizeof(filename), "models/players/%s/head.md3", modelName);
pi->headModel = trap_R_RegisterModel(filename);
if(!pi->headModel)
{
Com_Printf("Failed to load model file %s\n", filename);
return qfalse;
}
// NERVE - SMF - load backpack and helmet
if(backpack)
{
pi->backpackModel = trap_R_RegisterModel(va("models/players/%s/%s", modelName, backpack));
}
if(helmet)
{
pi->helmetModel = trap_R_RegisterModel(va("models/players/%s/%s", modelName, helmet));
}
// if any skins failed to load, fall back to default
if(!UI_RegisterClientSkin(pi, modelName, skinName))
{
if(!UI_RegisterClientSkin(pi, modelName, "default"))
{
Com_Printf("Failed to load skin file: %s : %s\n", modelName, skinName);
return qfalse;
}
}
// load the animations
//----(SA) changing name of config file to avoid backwards or alternate compatibility confustion
// Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
Com_sprintf(filename, sizeof(filename), "models/players/%s/wolfanim.cfg", modelName);
//----(SA) end
if(!UI_ParseAnimationFile(filename, pi))
{ // NERVE - SMF - make this work with wolf
Com_Printf("Failed to load animation file %s\n", filename);
return qfalse;
}
return qtrue;
}
示例5: FF_Stop
void FF_Stop(ffFX_e effect)
{
Com_Printf("FF_Stop: Please implement fffx_id = %i\n",effect);
// Do nothing
}
示例6: FF_Play
//.........這裏部分代碼省略.........
case fffx_WindGust:
case fffx_WindShear:
case fffx_Pistol:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 2, true);
if (s != -1)
{
IN_AddRumbleState(s, 50000, 10000, 200);
IN_AddRumbleState(s, 0, 0, 10);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_Shotgun:
case fffx_Laser1:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 2, true);
if (s != -1)
{
IN_AddRumbleState(s, 32000, 32000, 75);
IN_AddRumbleState(s, 0, 0, 15);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_Laser2:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 2, true);
if (s != -1)
{
IN_AddRumbleState(s, 25000, 25000, 75);
IN_AddRumbleState(s, 0, 0, 10);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_Laser3:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 2, true);
if (s != -1)
{
IN_AddRumbleState(s, 35000, 35000, 100);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_Laser4:
case fffx_Laser5:
case fffx_Laser6:
case fffx_OutOfAmmo:
case fffx_LightningGun:
case fffx_Missile:
case fffx_GatlingGun:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 2, true);
if (s != -1)
{
IN_AddRumbleState(s, 39000, 0, 220);
IN_AddRumbleState(s, 0, 0, 10);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_ShortPlasma:
case fffx_PlasmaCannon1:
case fffx_PlasmaCannon2:
case fffx_Cannon:
case fffx_FallingShort:
case fffx_FallingMedium:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 1, true);
if (s != -1)
{
IN_AddRumbleState(s, 25000,10000, 230);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_FallingFar:
s = IN_CreateRumbleScript(ClientManager::ActiveController(), 1, true);
if (s != -1)
{
IN_AddRumbleState(s, 32000,10000, 230);
IN_ExecuteRumbleScript(s);
}
break;
case fffx_StartConst:
client = ClientManager::ActiveClientNum();
if(const_rumble[client] == -1)
{
const_rumble[client] = IN_CreateRumbleScript(ClientManager::ActiveController(), 4, true);
if (const_rumble[client] != -1)
{
IN_AddEffectFade4(const_rumble[client], 0,0, 50000, 50000, 1000);
//IN_AddRumbleState(const_rumble[client], 50000, 0, 300);
//IN_AddEffectFade4(const_rumble[client], 50000,50000, 0, 0, 1000);
IN_ExecuteRumbleScript(const_rumble[client]);
}
}
break;
case fffx_StopConst:
client = ClientManager::ActiveClientNum();
if (const_rumble[client] == -1)
return;
IN_KillRumbleScript(const_rumble[client]);
const_rumble[client] = -1;
break;
default:
Com_Printf("No rumble script is defined for fffx_id = %i\n",effect);
break;
}
}
示例7: Netchan_Process
/*
=================
Netchan_Process
Returns qfalse if the message should not be processed due to being
out of order or a fragment.
Msg must be large enough to hold MAX_MSGLEN, because if this is the
final fragment of a multi-part message, the entire thing will be
copied out.
=================
*/
qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) {
int sequence, sequence_ack;
//int qport;
int fragmentStart, fragmentLength;
qboolean fragmented;
// get sequence numbers
MSG_BeginReading( msg );
sequence = MSG_ReadLong( msg );
sequence_ack = MSG_ReadLong( msg );
// check for fragment information
if ( sequence & FRAGMENT_BIT ) {
sequence &= ~FRAGMENT_BIT;
fragmented = qtrue;
} else {
fragmented = qfalse;
}
// read the qport if we are a server
if ( chan->sock == NS_SERVER ) {
/*qport = */MSG_ReadShort( msg );
}
// read the fragment information
if ( fragmented ) {
fragmentStart = MSG_ReadShort( msg );
fragmentLength = MSG_ReadShort( msg );
} else {
fragmentStart = 0; // stop warning message
fragmentLength = 0;
}
if ( showpackets->integer ) {
if ( fragmented ) {
Com_Printf( "%s recv %4i : s=%i ack=%i fragment=%i,%i\n"
, netsrcString[ chan->sock ]
, msg->cursize
, sequence
, sequence_ack
, fragmentStart, fragmentLength );
} else {
Com_Printf( "%s recv %4i : s=%i ack=%i\n"
, netsrcString[ chan->sock ]
, msg->cursize
, sequence
, sequence_ack );
}
}
//
// discard out of order or duplicated packets
//
if ( sequence <= chan->incomingSequence ) {
if ( showdrop->integer || showpackets->integer ) {
Com_Printf( "%s:Out of order packet %i at %i\n"
, NET_AdrToString( chan->remoteAddress )
, sequence
, chan->incomingSequence );
}
return qfalse;
}
//
// dropped packets don't keep the message from being used
//
chan->dropped = sequence - (chan->incomingSequence+1);
if ( chan->dropped > 0 ) {
if ( showdrop->integer || showpackets->integer ) {
Com_Printf( "%s:Dropped %i packets at %i\n"
, NET_AdrToString( chan->remoteAddress )
, chan->dropped
, sequence );
}
}
//
// if this is the final framgent of a reliable message,
// bump incoming_reliable_sequence
//
if ( fragmented ) {
// make sure we
if ( sequence != chan->fragmentSequence ) {
chan->fragmentSequence = sequence;
chan->fragmentLength = 0;
}
//.........這裏部分代碼省略.........
示例8: CL_ServersResponsePacket
/*
===================
CL_ServersResponsePacket
===================
*/
void CL_ServersResponsePacket( msg_t *msg ) {
int i, count, max, total;
serverAddress_t addresses[MAX_SERVERSPERPACKET];
int numservers;
char* buffptr;
char* buffend;
Com_Printf(0, "CL_ServersResponsePacket\n");
if (cls.numglobalservers == -1) {
// state to detect lack of servers or lack of response
cls.numglobalservers = 0;
cls.numGlobalServerAddresses = 0;
}
// parse through server response string
numservers = 0;
buffptr = msg->data;
buffend = buffptr + msg->cursize;
while (buffptr+1 < buffend) {
// advance to initial token
do {
if (*buffptr++ == '\\')
break;
}
while (buffptr < buffend);
if ( buffptr >= buffend - 6 ) {
break;
}
// parse out ip
addresses[numservers].ip[0] = *buffptr++;
addresses[numservers].ip[1] = *buffptr++;
addresses[numservers].ip[2] = *buffptr++;
addresses[numservers].ip[3] = *buffptr++;
// parse out port
addresses[numservers].port = (*(buffptr++))<<8;
addresses[numservers].port += (*(buffptr++)) & 0xFF;
addresses[numservers].port = ntohs( addresses[numservers].port );
// syntax check
if (*buffptr != '\\') {
break;
}
/*Com_DPrintf( 0, "server: %d ip: %d.%d.%d.%d:%d\n",numservers,
addresses[numservers].ip[0],
addresses[numservers].ip[1],
addresses[numservers].ip[2],
addresses[numservers].ip[3],
ntohs(addresses[numservers].port) );*/
numservers++;
if (numservers >= MAX_SERVERSPERPACKET) {
break;
}
// parse out EOT
if (buffptr[1] == 'E' && buffptr[2] == 'O' && buffptr[3] == 'T') {
break;
}
}
count = cls.numglobalservers;
max = MAX_GLOBAL_SERVERS;
for (i = 0; i < numservers && count < max; i++) {
// check if this server already exists
netadr_t address;
address.type = NA_IP;
address.ip[0] = addresses[i].ip[0];
address.ip[1] = addresses[i].ip[1];
address.ip[2] = addresses[i].ip[2];
address.ip[3] = addresses[i].ip[3];
address.port = addresses[i].port;
bool alreadyExists = false;
for (int j = 0; j < cls.numglobalservers; j++)
{
if (NET_CompareAdr(cls.globalServers[j].adr, address))
{
alreadyExists = true;
break;
}
}
if (alreadyExists)
{
continue;
}
// build net address
//.........這裏部分代碼省略.........
示例9: fx_runner_link
//----------------------------------------------------------
void fx_runner_link( gentity_t *ent )
{
vec3_t dir;
if ( ent->target )
{
// try to use the target to override the orientation
gentity_t *target = NULL;
target = G_Find( target, FOFS(targetname), ent->target );
if ( !target )
{
// Bah, no good, dump a warning, but continue on and use the UP vector
Com_Printf( "fx_runner_link: target specified but not found: %s\n", ent->target );
Com_Printf( " -assuming UP orientation.\n" );
}
else
{
// Our target is valid so let's override the default UP vector
VectorSubtract( target->s.origin, ent->s.origin, dir );
VectorNormalize( dir );
vectoangles( dir, ent->s.angles );
}
}
// don't really do anything with this right now other than do a check to warn the designers if the target2 is bogus
if ( ent->target2 )
{
gentity_t *target = NULL;
target = G_Find( target, FOFS(targetname), ent->target2 );
if ( !target )
{
// Target2 is bogus, but we can still continue
Com_Printf( "fx_runner_link: target2 was specified but is not valid: %s\n", ent->target2 );
}
}
G_SetAngles( ent, ent->s.angles );
if ( ent->spawnflags & 1 || ent->spawnflags & 2 ) // STARTOFF || ONESHOT
{
// We won't even consider thinking until we are used
ent->nextthink = -1;
}
else
{
if ( VALIDSTRING( ent->soundSet ) == true )
{
ent->s.loopSound = CAS_GetBModelSound( ent->soundSet, BMS_MID );
if ( ent->s.loopSound < 0 )
{
ent->s.loopSound = 0;
}
}
// Let's get to work right now!
ent->e_ThinkFunc = thinkF_fx_runner_think;
ent->nextthink = level.time + 200; // wait a small bit, then start working
}
// make us useable if we can be targeted
if ( ent->targetname )
{
ent->e_UseFunc = useF_fx_runner_use;
}
}
示例10: Netchan_Transmit
/*
===============
Netchan_Transmit
Sends a message to a connection, fragmenting if necessary
A 0 length will still generate a packet.
================
*/
void Netchan_Transmit( netchan_t *chan, int length, const byte *data ) {
msg_t send;
byte send_buf[MAX_PACKETLEN];
int fragmentStart, fragmentLength;
fragmentStart = 0; // stop warning message
fragmentLength = 0;
// fragment large reliable messages
if ( length >= FRAGMENT_SIZE ) {
fragmentStart = 0;
do {
// write the packet header
MSG_Init (&send, send_buf, sizeof(send_buf));
MSG_WriteLong( &send, chan->outgoingSequence | FRAGMENT_BIT );
MSG_WriteLong( &send, chan->incomingSequence );
// send the qport if we are a client
if ( chan->sock == NS_CLIENT ) {
MSG_WriteShort( &send, qport->integer );
}
// copy the reliable message to the packet first
fragmentLength = FRAGMENT_SIZE;
if ( fragmentStart + fragmentLength > length ) {
fragmentLength = length - fragmentStart;
}
MSG_WriteShort( &send, fragmentStart );
MSG_WriteShort( &send, fragmentLength );
MSG_WriteData( &send, data + fragmentStart, fragmentLength );
// send the datagram
NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );
if ( showpackets->integer ) {
Com_Printf ("%s send %4i : s=%i ack=%i fragment=%i,%i\n"
, netsrcString[ chan->sock ]
, send.cursize
, chan->outgoingSequence - 1
, chan->incomingSequence
, fragmentStart, fragmentLength);
}
fragmentStart += fragmentLength;
// this exit condition is a little tricky, because a packet
// that is exactly the fragment length still needs to send
// a second packet of zero length so that the other side
// can tell there aren't more to follow
} while ( fragmentStart != length || fragmentLength == FRAGMENT_SIZE );
chan->outgoingSequence++;
return;
}
// write the packet header
MSG_Init (&send, send_buf, sizeof(send_buf));
MSG_WriteLong( &send, chan->outgoingSequence );
MSG_WriteLong( &send, chan->incomingSequence );
chan->outgoingSequence++;
// send the qport if we are a client
if ( chan->sock == NS_CLIENT ) {
MSG_WriteShort( &send, qport->integer );
}
MSG_WriteData( &send, data, length );
// send the datagram
NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );
if ( showpackets->integer ) {
Com_Printf( "%s send %4i : s=%i ack=%i\n"
, netsrcString[ chan->sock ]
, send.cursize
, chan->outgoingSequence - 1
, chan->incomingSequence );
}
}
示例11: G2Tur_SetBoneAngles
//special routine for tracking angles between client and server -rww
void G2Tur_SetBoneAngles(gentity_t *ent, char *bone, vec3_t angles)
{
int *thebone = &ent->s.boneIndex1;
int *firstFree = NULL;
int i = 0;
int boneIndex = G_BoneIndex(bone);
int flags, up, right, forward;
vec3_t *boneVector = &ent->s.boneAngles1;
vec3_t *freeBoneVec = NULL;
while (thebone)
{
if (!*thebone && !firstFree)
{ //if the value is 0 then this index is clear, we can use it if we don't find the bone we want already existing.
firstFree = thebone;
freeBoneVec = boneVector;
}
else if (*thebone)
{
if (*thebone == boneIndex)
{ //this is it
break;
}
}
switch (i)
{
case 0:
thebone = &ent->s.boneIndex2;
boneVector = &ent->s.boneAngles2;
break;
case 1:
thebone = &ent->s.boneIndex3;
boneVector = &ent->s.boneAngles3;
break;
case 2:
thebone = &ent->s.boneIndex4;
boneVector = &ent->s.boneAngles4;
break;
default:
thebone = NULL;
boneVector = NULL;
break;
}
i++;
}
if (!thebone)
{ //didn't find it, create it
if (!firstFree)
{ //no free bones.. can't do a thing then.
Com_Printf("WARNING: NPC has no free bone indexes\n");
return;
}
thebone = firstFree;
*thebone = boneIndex;
boneVector = freeBoneVec;
}
//If we got here then we have a vector and an index.
//Copy the angles over the vector in the entitystate, so we can use the corresponding index
//to set the bone angles on the client.
VectorCopy(angles, *boneVector);
//Now set the angles on our server instance if we have one.
if (!ent->ghoul2)
{
return;
}
flags = BONE_ANGLES_POSTMULT;
up = POSITIVE_Y;
right = NEGATIVE_Z;
forward = NEGATIVE_X;
//first 3 bits is forward, second 3 bits is right, third 3 bits is up
ent->s.boneOrient = ((forward)|(right<<3)|(up<<6));
trap->G2API_SetBoneAngles( ent->ghoul2,
0,
bone,
angles,
flags,
up,
right,
forward,
NULL,
100,
level.time );
}
示例12: SHD_Load
//
// Load vertex and fragment shader, compile, link etc.
//
qbool SHD_Load(shader_t *s, const char *vertex_fileName, const char *fragment_fileName)
{
shader_t s_tmp;
GLint linked = 0;
int i;
if (!SHD_Initialized())
{
Com_Printf("SHD_Load: shader system not initialized\n");
return false;
}
memset(&s_tmp, 0, sizeof(s_tmp));
// just some assertion checks
SHD_AlredyLoaded(s);
if (shd.count >= MAX_SHADERS)
{
Com_Printf("SHD_Load: full shader list\n");
goto cleanup;
}
if (!s)
{
Com_Printf("SHD_Load: zero shader\n");
goto cleanup;
}
// we must have here nulified struct
for (i = 0; i < sizeof(*s); i++)
{
if (((byte*)s)[i])
{
Com_Printf("SHD_Load: shader struct not ready\n");
goto cleanup;
}
}
// create a program object
s_tmp.program = glCreateProgramObjectARB();
if (!s_tmp.program)
{
Com_Printf("SHD_Load: failed to create program\n");
goto cleanup;
}
// create shaders
s_tmp.vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
s_tmp.fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
// load source code strings into shaders
if (!SHD_LoadAndCompile(s_tmp.vertexShader, vertex_fileName))
goto cleanup;
if (!SHD_LoadAndCompile(s_tmp.fragmentShader, fragment_fileName))
goto cleanup;
// attach the two compiled shaders
// TODO: check success
glAttachObjectARB(s_tmp.program, s_tmp.vertexShader);
glAttachObjectARB(s_tmp.program, s_tmp.fragmentShader);
// link the program object and print out the info log
glLinkProgramARB(s_tmp.program);
// check for OpenGL errors
if (!SHD_CheckOpenGLError())
{
Com_Printf("SHD_Load: OpenGL errors encountered\n");
goto cleanup;
}
glGetObjectParameterivARB(s_tmp.program, GL_OBJECT_LINK_STATUS_ARB, &linked);
if (!linked)
{
Com_Printf("SHD_Load: program not linked\n");
goto cleanup;
}
// copy struct
*s = s_tmp;
// link to shd list
shd.shaders[shd.count] = s;
shd.count++;
return true;
cleanup: // GOTO MARK
SHD_Free(&s_tmp);
return false;
}
示例13: CG_DrawClientScore
/*
=================
CG_DrawScoreboard
=================
*/
static void CG_DrawClientScore( int y, score_t *score, float *color, float fade, qboolean largeFormat ) {
char string[1024];
vec3_t headAngles;
clientInfo_t *ci;
int iconx, headx;
float scale = 0.35;
int h = CG_Text_Height( "Tj", scale, 0 );
//int ty;
if ( score->client < 0 || score->client >= cgs.maxclients ) {
Com_Printf( "Bad score->client: %i\n", score->client );
return;
}
color[3] = fade;
ci = &cgs.clientinfo[score->client];
iconx = SB_BOTICON_X + (SB_RATING_WIDTH / 2);
headx = SB_HEAD_X + (SB_RATING_WIDTH / 2);
// draw the handicap or bot skill marker (unless player has flag)
if ( ci->powerups & ( 1 << PW_NEUTRALFLAG ) ) {
if( largeFormat ) {
CG_DrawFlagModel( iconx, y - SB_LARGE_SPACER, SB_LARGE_ICON, SB_LARGE_ICON, TEAM_FREE, qfalse, SCR_CENTER );
} else {
CG_DrawFlagModel( iconx, y - SB_SMALL_SPACER, SB_SMALL_ICON, SB_SMALL_ICON, TEAM_FREE, qfalse, SCR_CENTER );
}
} else if ( ci->powerups & ( 1 << PW_REDFLAG ) ) {
if( largeFormat ) {
CG_DrawFlagModel( iconx, y - SB_LARGE_SPACER, SB_LARGE_ICON, SB_LARGE_ICON, TEAM_RED, qfalse, SCR_CENTER );
} else {
CG_DrawFlagModel( iconx, y - SB_SMALL_SPACER, SB_SMALL_ICON, SB_SMALL_ICON, TEAM_RED, qfalse, SCR_CENTER );
}
} else if ( ci->powerups & ( 1 << PW_BLUEFLAG ) ) {
if( largeFormat ) {
CG_DrawFlagModel( iconx, y - SB_LARGE_SPACER, SB_LARGE_ICON, SB_LARGE_ICON, TEAM_BLUE, qfalse, SCR_CENTER );
} else {
CG_DrawFlagModel( iconx, y - SB_SMALL_SPACER, SB_SMALL_ICON, SB_SMALL_ICON, TEAM_BLUE, qfalse, SCR_CENTER );
}
} else {
if ( ci->botSkill > 0 && ci->botSkill <= 5 ) {
if ( cg_drawIcons.integer ) {
if( largeFormat ) {
CG_DrawColorPic( iconx, y - SB_LARGE_SPACER, SB_LARGE_ICON, SB_LARGE_ICON, cgs.media.botSkillShaders[ci->botSkill - 1], SCR_CENTER, color );
} else {
CG_DrawColorPic( iconx, y - SB_SMALL_SPACER, SB_SMALL_ICON, SB_SMALL_ICON, cgs.media.botSkillShaders[ci->botSkill - 1], SCR_CENTER, color );
}
}
} else if ( ci->handicap < 100 ) {
Com_sprintf( string, sizeof( string ), "%i", ci->handicap );
if ( gt[cgs.gametype].duel ) {
if ( cg_highResFonts.integer ) {
CG_Text_Paint( iconx, y + h + ((float)h/2), scale, color, string, 0, 0, ITEM_TEXTSTYLE_SHADOWED, SCR_CENTER );
} else {
CG_DrawSmallStringColor( iconx, y - SMALLCHAR_HEIGHT/2, string, color, SCR_CENTER );
}
} else {
if ( cg_highResFonts.integer ) {
//w = CG_Text_Width(s, scale, 0);
h = CG_Text_Height(string, scale, 0);
CG_Text_Paint( iconx, y + h, scale, color, string, 0, 0, ITEM_TEXTSTYLE_SHADOWED, SCR_CENTER );
} else {
CG_DrawSmallStringColor( iconx, y, string, color, SCR_CENTER );
}
}
}
// draw the wins / losses
if ( gt[cgs.gametype].duel ) {
Com_sprintf( string, sizeof( string ), "%i/%i", ci->wins, ci->losses );
if ( ci->handicap < 100 && !ci->botSkill ) {
if ( cg_highResFonts.integer ) {
CG_Text_Paint( iconx, y + h + ((float)h/2), scale, color, string, 0, 0, ITEM_TEXTSTYLE_SHADOWED, SCR_CENTER );
} else {
CG_DrawSmallStringColor( iconx, y + SMALLCHAR_HEIGHT/2, string, color, SCR_CENTER );
}
} else {
if ( cg_highResFonts.integer ) {
CG_Text_Paint( iconx, y + h, scale, color, string, 0, 0, ITEM_TEXTSTYLE_SHADOWED, SCR_CENTER );
} else {
CG_DrawSmallStringColor( iconx, y, string, color, SCR_CENTER );
}
}
}
}
// draw the face
VectorClear( headAngles );
headAngles[YAW] = 180;
if ( largeFormat ) {
CG_DrawHead( headx, y - SB_LARGE_SPACER*2, ICON_SIZE, ICON_SIZE,
score->client, headAngles, SCR_CENTER, color );
} else {
CG_DrawHead( headx, y + SB_SMALL_SPACER, SB_SMALL_ICON, SB_SMALL_ICON, score->client, headAngles, SCR_CENTER, color );
}
//.........這裏部分代碼省略.........
示例14: S_Init
/*
* S_Init
*/
qboolean S_Init( void *hwnd, int maxEntities, qboolean verbose )
{
int numDevices;
int userDeviceNum = -1;
char *devices, *defaultDevice;
soundpool = S_MemAllocPool( "OpenAL sound module" );
alDevice = NULL;
alContext = NULL;
#ifdef OPENAL_RUNTIME
if( !QAL_Init( ALDRIVER, verbose ) )
{
#ifdef ALDRIVER_ALT
if( !QAL_Init( ALDRIVER_ALT, verbose ) )
#endif
{
Com_Printf( "Failed to load OpenAL library: %s\n", ALDRIVER );
goto fail_no_device;
}
}
#endif
// get system default device identifier
defaultDevice = ( char * )qalcGetString( NULL, ALC_DEFAULT_DEVICE_SPECIFIER );
if( !defaultDevice )
{
Com_Printf( "Failed to get openAL default device\n" );
goto fail_no_device;
}
s_openAL_device = trap_Cvar_Get( "s_openAL_device", ALDEVICE_DEFAULT ? ALDEVICE_DEFAULT : defaultDevice, CVAR_ARCHIVE|CVAR_LATCH_SOUND );
devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
for( numDevices = 0; *devices; devices += strlen( devices ) + 1, numDevices++ )
{
if( !Q_stricmp( s_openAL_device->string, devices ) )
{
userDeviceNum = numDevices;
// force case sensitive
if( strcmp( s_openAL_device->string, devices ) )
trap_Cvar_ForceSet( "s_openAL_device", devices );
}
}
if( !numDevices )
{
Com_Printf( "Failed to get openAL devices\n" );
goto fail_no_device;
}
// the device assigned by the user is not available
if( userDeviceNum == -1 )
{
Com_Printf( "'s_openAL_device': incorrect device name, reseting to default\n" );
trap_Cvar_ForceSet( "s_openAL_device", ALDEVICE_DEFAULT ? ALDEVICE_DEFAULT : defaultDevice );
devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
for( numDevices = 0; *devices; devices += strlen( devices ) + 1, numDevices++ )
{
if( !Q_stricmp( s_openAL_device->string, devices ) )
userDeviceNum = numDevices;
}
if( userDeviceNum == -1 )
trap_Cvar_ForceSet( "s_openAL_device", defaultDevice );
}
alDevice = qalcOpenDevice( (const ALchar *)s_openAL_device->string );
if( !alDevice )
{
Com_Printf( "Failed to open device\n" );
goto fail_no_device;
}
// Create context
alContext = qalcCreateContext( alDevice, NULL );
if( !alContext )
{
Com_Printf( "Failed to create context\n" );
goto fail;
}
qalcMakeContextCurrent( alContext );
if( verbose )
{
Com_Printf( "OpenAL initialized\n" );
if( numDevices )
{
int i;
Com_Printf( " Devices: " );
//.........這裏部分代碼省略.........
示例15: CG_DrawClientScore
static void CG_DrawClientScore( int y, score_t *score, const vector4 *color, float fade, qboolean largeFormat ) {
//vector3 headAngles;
clientInfo_t *ci;
int iconx = SB_SCORELINE_X - 5;//SB_BOTICON_X + (SB_RATING_WIDTH / 2);
float scale = largeFormat ? 1.0f : 0.75f,
iconSize = largeFormat ? SB_NORMAL_HEIGHT : SB_INTER_HEIGHT;
iconx -= iconSize;
if ( score->client < 0 || score->client >= cgs.maxclients ) {
Com_Printf( "Bad score->client: %i\n", score->client );
return;
}
ci = &cgs.clientinfo[score->client];
// draw the handicap or bot skill marker (unless player has flag)
if ( ci->powerups & (1 << PW_NEUTRALFLAG) ) {
if ( largeFormat )
CG_DrawFlagModel( iconx, y - (32 - BIGCHAR_HEIGHT) / 2, iconSize, iconSize, TEAM_FREE, qfalse );
else
CG_DrawFlagModel( iconx, y, iconSize, iconSize, TEAM_FREE, qfalse );
}
else if ( ci->powerups & (1 << PW_REDFLAG) )
CG_DrawFlagModel( iconx, y, iconSize, iconSize, TEAM_RED, qfalse );
else if ( ci->powerups & (1 << PW_BLUEFLAG) )
CG_DrawFlagModel( iconx, y, iconSize, iconSize, TEAM_BLUE, qfalse );
else if ( cgs.gametype == GT_POWERDUEL && (ci->duelTeam == DUELTEAM_LONE || ci->duelTeam == DUELTEAM_DOUBLE) ) {
CG_DrawPic( iconx, y, iconSize, iconSize, trap->R_RegisterShaderNoMip(
(ci->duelTeam == DUELTEAM_LONE) ? "gfx/mp/pduel_icon_lone" : "gfx/mp/pduel_icon_double" ) );
}
else if ( cgs.gametype == GT_SIEGE ) {
// try to draw the shader for this class on the scoreboard
if ( ci->siegeIndex != -1 ) {
siegeClass_t *scl = &bgSiegeClasses[ci->siegeIndex];
if ( scl->classShader )
CG_DrawPic( iconx, y, largeFormat ? 24 : 12, largeFormat ? 24 : 12, scl->classShader );
}
}
else if ( ci->modelIcon && cg_oldScoreboardSkinIcons.integer )
CG_DrawPic( iconx, y, iconSize, iconSize, ci->modelIcon );
// highlight your position
if ( score->client == cg.snap->ps.clientNum ) {
vector4 hcolor;
int rank;
localClient = qtrue;
if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR || cgs.gametype >= GT_TEAM )
rank = -1;
else
rank = cg.snap->ps.persistant[PERS_RANK] & ~RANK_TIED_FLAG;
if ( rank == 0 ) {
hcolor.r = 0;
hcolor.g = 0;
hcolor.b = 0.7f;
}
else if ( rank == 1 ) {
hcolor.r = 0.7f;
hcolor.g = 0;
hcolor.b = 0;
}
else if ( rank == 2 ) {
hcolor.r = 0.7f;
hcolor.g = 0.7f;
hcolor.b = 0;
}
else {
hcolor.r = 0.7f;
hcolor.g = 0.7f;
hcolor.b = 0.7f;
}
hcolor.a = fade * 0.7f;
CG_FillRect( SB_SCORELINE_X - 5, y /*+ 2*/, SB_SCORELINE_WIDTH /*- SB_SCORELINE_X * 2 + 10*/, largeFormat ? SB_NORMAL_HEIGHT : SB_INTER_HEIGHT, &hcolor );
}
CG_Text_Paint( SB_NAME_X, y, 0.9f * scale, &colorWhite, ci->name, 0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_MEDIUM );
if ( score->ping != -1 ) {
if ( ci->team != TEAM_SPECTATOR || cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL ) {
if ( cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL )
CG_Text_Paint( SB_SCORE_X, y, 1.0f * scale, &colorWhite, va( "%i/%i", ci->wins, ci->losses ), 0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL );
else {
if ( Server_Supports( SSF_SCOREBOARD_KD ) )
CG_Text_Paint( SB_SCORE_X, y, 1.0f * scale, &colorWhite, va( "%i/%i", score->score, score->deaths ), 0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL );
else
CG_Text_Paint( SB_SCORE_X, y, 1.0f * scale, &colorWhite, va( "%i", score->score ), 0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL );
}
}
if ( cgs.clientinfo[score->client].botSkill != -1 && cg_oldScoreboardShowBots.integer == 2 )
CG_Text_Paint( SB_PING_X, y, 1.0f * scale, &colorWhite, "-", 0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL );
//.........這裏部分代碼省略.........