//----------------------------------------------------------------------------- // Purpose: // Input : index - // Output : model_t //----------------------------------------------------------------------------- model_t *CGameServer::GetModel( int index ) { if ( index <= 0 || !m_pModelPrecacheTable ) return NULL; if ( index >= m_pModelPrecacheTable->GetNumStrings() ) { return NULL; } CPrecacheItem *slot = &model_precache[ index ]; model_t *m = slot->GetModel(); if ( m ) { return m; } char const *modelname = m_pModelPrecacheTable->GetString( index ); Assert( modelname ); if ( host_showcachemiss.GetBool() ) { ConDMsg( "server model cache miss on %s\n", modelname ); } m = modelloader->GetModelForName( modelname, IModelLoader::FMODELLOADER_SERVER ); slot->SetModel( m ); return m; }
static inline void ShowEncodeDeltaWatchInfo( const SendTable *pTable, const SendProp *pProp, bf_read &buffer, const int objectID, const int index ) { if ( !ShouldWatchThisProp( pTable, objectID, pProp->GetName()) ) return; static int lastframe = -1; if ( host_framecount != lastframe ) { lastframe = host_framecount; ConDMsg( "delta entity: %i\n", objectID ); } // work on copy of bitbuffer bf_read copy = buffer; s_debug_info_shown = true; DecodeInfo info; info.m_pStruct = NULL; info.m_pData = NULL; info.m_pRecvProp = NULL; info.m_pProp = pProp; info.m_pIn = © info.m_ObjectID = objectID; info.m_Value.m_Type = (SendPropType)pProp->m_Type; int startBit = copy.GetNumBitsRead(); g_PropTypeFns[pProp->m_Type].Decode( &info ); int bits = copy.GetNumBitsRead() - startBit; const char *type = g_PropTypeFns[pProp->m_Type].GetTypeNameString(); const char *value = info.m_Value.ToString(); ConDMsg( "+ %s %s, %s, index %i, bits %i, value %s\n", pTable->GetName(), pProp->GetName(), type, index, bits, value ); }
bool CGameClient::SendSignonData( void ) { bool bClientHasdifferentTables = false; if ( sv.m_FullSendTables.IsOverflowed() ) { Host_Error( "Send Table signon buffer overflowed %i bytes!!!\n", sv.m_FullSendTables.GetNumBytesWritten() ); return false; } if ( SendTable_GetCRC() != (CRC32_t)0 ) { bClientHasdifferentTables = m_nSendtableCRC != SendTable_GetCRC(); } #ifdef _DEBUG if ( sv_sendtables.GetInt() == 2 ) { // force sending class tables, for debugging bClientHasdifferentTables = true; } #endif // Write the send tables & class infos if needed if ( bClientHasdifferentTables ) { if ( sv_sendtables.GetBool() ) { // send client class table descriptions so it can rebuild tables ConDMsg("Client sent different SendTable CRC, sending full tables.\n" ); m_NetChannel->SendData( sv.m_FullSendTables ); } else { Disconnect( "Server uses different class tables" ); return false; } } else { // use your class infos, CRC is correct SVC_ClassInfo classmsg( true, m_Server->serverclasses ); m_NetChannel->SendNetMsg( classmsg ); } if ( !CBaseClient::SendSignonData() ) return false; m_nSoundSequence = 1; // reset sound sequence numbers after signon block return true; }
/* ================= R_StudioSetupModel based on the body part, figure out which mesh it should be using. inputs: outputs: pstudiomesh pmdl ================= */ int R_StudioSetupModel( int bodypart, int entity_body, mstudiomodel_t **ppSubModel, const studiohdr_t *pStudioHdr ) { int index; mstudiobodyparts_t *pbodypart; if (bodypart > pStudioHdr->numbodyparts) { ConDMsg ("R_StudioSetupModel: no such bodypart %d\n", bodypart); bodypart = 0; } pbodypart = pStudioHdr->pBodypart( bodypart ); index = entity_body / pbodypart->base; index = index % pbodypart->nummodels; Assert( ppSubModel ); *ppSubModel = pbodypart->pModel( index ); return index; }
static int luasrc_ConDMsg (lua_State *L) { ConDMsg(luaL_checkstring(L, 1)); return 0; }
void SendTable_WritePropList( const SendTable *pTable, const void *pState, const int nBits, bf_write *pOut, const int objectID, const int *pCheckProps, const int nCheckProps ) { if ( nCheckProps == 0 ) { // Write single final zero bit, signifying that there no changed properties pOut->WriteOneBit( 0 ); return; } bool bDebugWatch = Sendprop_UsingDebugWatch(); s_debug_info_shown = false; s_debug_bits_start = pOut->GetNumBitsWritten(); CSendTablePrecalc *pPrecalc = pTable->m_pPrecalc; CDeltaBitsWriter deltaBitsWriter( pOut ); bf_read inputBuffer( "SendTable_WritePropList->inputBuffer", pState, BitByte( nBits ), nBits ); CDeltaBitsReader inputBitsReader( &inputBuffer ); // Ok, they want to specify a small list of properties to check. int iToProp = NextProp( &inputBitsReader ); int i = 0; while ( i < nCheckProps ) { // Seek the 'to' state to the current property we want to check. while ( iToProp < pCheckProps[i] ) { SkipPropData( &inputBuffer, pPrecalc->GetProp( iToProp ) ); iToProp = NextProp( &inputBitsReader ); } if ( iToProp == PROP_SENTINEL ) { break; } else if ( iToProp == pCheckProps[i] ) { const SendProp *pProp = pPrecalc->GetProp( iToProp ); // Show debug stuff. if ( bDebugWatch ) { ShowEncodeDeltaWatchInfo( pTable, pProp, inputBuffer, objectID, iToProp ); } // See how many bits the data for this property takes up. int iStartBit = inputBuffer.GetNumBitsRead(); SkipPropData( &inputBuffer, pProp ); int nToStateBits = inputBuffer.GetNumBitsRead() - iStartBit; TRACE_PACKET( ( " Send Field (%s) = %d (%d bytes)\n", pProp->GetName(), nToStateBits, ( nToStateBits + 7 ) / 8 ) ); // Write the data into the output. deltaBitsWriter.WritePropIndex( iToProp ); inputBuffer.Seek( iStartBit ); pOut->WriteBitsFromBuffer( &inputBuffer, nToStateBits ); // Seek to the next prop. iToProp = NextProp( &inputBitsReader ); } ++i; } if ( s_debug_info_shown ) { int bits = pOut->GetNumBitsWritten() - s_debug_bits_start; ConDMsg( "= %i bits (%i bytes)\n", bits, Bits2Bytes(bits) ); } inputBitsReader.ForceFinished(); // avoid a benign assert }
bool CClientState::ProcessVoiceData( SVC_VoiceData *msg ) { char chReceived[4096]; int nBytes = Bits2Bytes( msg->m_nLength ); nBytes = min( nBytes, sizeof( chReceived ) ); msg->m_DataIn.ReadBits( chReceived, msg->m_nLength ); #if defined ( _X360 ) DWORD dwLength = msg->m_nLength; XUID xuid = msg->m_xuid; Audio_GetXVoice()->PlayIncomingVoiceData( xuid, (byte*)chReceived, dwLength ); if ( voice_debugfeedback.GetBool() ) { Msg( "Received voice from: %d\n", msg->m_nFromClient + 1 ); } return true; #endif #if !defined( NO_VOICE )//#ifndef _XBOX int iEntity = msg->m_nFromClient + 1; if ( iEntity == (m_nPlayerSlot + 1) ) { Voice_LocalPlayerTalkingAck(); } player_info_t playerinfo; engineClient->GetPlayerInfo( iEntity, &playerinfo ); if ( Q_strlen( cl_voice_filter.GetString() ) > 0 && Q_strstr( playerinfo.name, cl_voice_filter.GetString() ) == NULL ) return true; // Data length can be zero when the server is just acking a client's voice data. if ( nBytes == 0 ) return true; if ( !Voice_Enabled() ) { return true; } // Have we already initialized the channels for this guy? int nChannel = Voice_GetChannel( iEntity ); if ( nChannel == VOICE_CHANNEL_ERROR ) { // Create a channel in the voice engine and a channel in the sound engine for this guy. nChannel = Voice_AssignChannel( iEntity, msg->m_bProximity ); if ( nChannel == VOICE_CHANNEL_ERROR ) { // If they used -nosound, then it's not a problem. if ( S_IsInitted() ) ConDMsg("ProcessVoiceData: Voice_AssignChannel failed for client %d!\n", iEntity-1); return true; } } // Give the voice engine the data (it in turn gives it to the mixer for the sound engine). Voice_AddIncomingData( nChannel, chReceived, nBytes, m_nCurrentSequence ); #endif return true; };