static VectorClock* readVectorClock(std::istream* inputStream, int& bytesRead) { std::list<std::pair<short, uint64_t> > entries; bytesRead = 0; uint16_t numEntries; READ_SHORT(inputStream, numEntries); bytesRead += 2; int versionSize = inputStream->get(); bytesRead += 1; for (uint32_t i = 0; i < numEntries; i++) { short nodeId; READ_SHORT(inputStream, nodeId); bytesRead += 2; uint64_t version = readUINT64(inputStream, versionSize); bytesRead += versionSize; entries.push_back(std::make_pair(nodeId, version)); } uint64_t timestamp = readUINT64(inputStream, 8); bytesRead += 8; return new VectorClock(&entries, timestamp); }
//LRC void CHud :: MsgFunc_SetFog( const char *pszName, int iSize, void *pbuf ) { // CONPRINT("MSG:SetFog"); BEGIN_READ( pbuf, iSize ); for ( int i = 0; i < 3; i++ ) g_fFogColor[ i ] = READ_BYTE(); g_fFadeDuration = READ_SHORT(); g_fStartDist = READ_SHORT(); if (g_fFadeDuration > 0) { // // fading in // g_fStartDist = READ_SHORT(); g_iFinalEndDist = READ_SHORT(); // g_fStartDist = FOG_LIMIT; g_fEndDist = FOG_LIMIT; } else if (g_fFadeDuration < 0) { // // fading out // g_iFinalStartDist = g_iFinalEndDist = g_fEndDist = READ_SHORT(); } else { // g_fStartDist = READ_SHORT(); g_fEndDist = READ_SHORT(); } }
//LRC int CHud::MsgFunc_SetFog( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); for ( int i = 0; i < 3; i++ ) g_fFogColor[ i ] = READ_BYTE(); g_fFadeDuration = READ_SHORT(); g_fStartDist = READ_SHORT(); if (g_fFadeDuration > 0) { // // fading in g_iFinalEndDist = READ_SHORT(); g_fEndDist = FOG_LIMIT; } else if (g_fFadeDuration < 0) { // // fading out g_iFinalEndDist = g_fEndDist = READ_SHORT(); } else { g_fEndDist = READ_SHORT(); } return 1; }
// trigger_viewset message int CHud :: MsgFunc_CamData( const char *pszName, int iSize, void *pbuf ) // rain stuff { BEGIN_READ( pbuf, iSize ); gHUD.viewEntityIndex = READ_SHORT(); gHUD.viewFlags = READ_SHORT(); // gEngfuncs.Con_Printf( "Got view entity with index %i\n", gHUD.viewEntityIndex ); return 1; }
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) { g_iTeleNum = 0; g_bLoadedTeles = false; int i; //Clear all the teleporters for ( i = 0; i < MAX_TELES; i++ ) { g_vecTeleMins[ i ].x = 0.0; g_vecTeleMins[ i ].y = 0.0; g_vecTeleMins[ i ].z = 0.0; g_vecTeleMaxs[ i ].x = 0.0; g_vecTeleMaxs[ i ].y = 0.0; g_vecTeleMaxs[ i ].z = 0.0; } /***** FOG CLEARING JIBBA JABBA *****/ for ( i = 0; i < 3; i++ ) g_iFogColor[ i ] = 0.0; g_iStartDist = 0.0; g_iEndDist = 0.0; /***** FOG CLEARING JIBBA JABBA *****/ // prepare all hud data HUDLIST *pList = m_pHudList; while (pList) { if ( pList->p ) pList->p->InitHUDData(); pList = pList->pNext; } BEGIN_READ( pbuf, iSize ); g_iTeleNum = READ_BYTE(); for ( i = 0; i < g_iTeleNum; i++ ) { g_vecTeleMins[ i ].x = READ_COORD(); g_vecTeleMins[ i ].y = READ_COORD(); g_vecTeleMins[ i ].z = READ_COORD(); g_vecTeleMaxs[ i ].x = READ_COORD(); g_vecTeleMaxs[ i ].y = READ_COORD(); g_vecTeleMaxs[ i ].z = READ_COORD(); } for ( i = 0; i < 3; i++ ) g_iFogColor[ i ] = READ_SHORT(); // Should just get a byte. //If they both are 0, it means no fog for this level. g_iStartDist = READ_SHORT(); g_iEndDist = READ_SHORT(); }
//LRC 1.8 void CHud :: MsgFunc_ClampView( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); g_clampMinYaw = READ_SHORT(); g_clampMaxYaw = READ_SHORT(); g_clampMinPitch = READ_BYTE() - 128; g_clampMaxPitch = READ_BYTE() - 128; *(long*)&g_clampTurnSpeed = READ_LONG(); }
int CHud :: MsgFunc_RainData( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); Rain.dripsPerSecond = READ_SHORT(); Rain.distFromPlayer = READ_COORD(); Rain.windX = READ_COORD(); Rain.windY = READ_COORD(); Rain.randX = READ_COORD(); Rain.randY = READ_COORD(); Rain.weatherMode = READ_SHORT(); Rain.globalHeight = READ_COORD(); return 1; }
int CHud :: MsgFunc_SetFog( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); m_vecFogColor.x = (float)(READ_BYTE() / 255.0f); m_vecFogColor.y = (float)(READ_BYTE() / 255.0f); m_vecFogColor.z = (float)(READ_BYTE() / 255.0f); m_flStartDist = READ_SHORT(); m_flEndDist = READ_SHORT(); END_READ(); return 1; }
int CHud :: MsgFunc_Inventory( const char *pszName, int iSize, void *pbuf ) //AJH inventory system { BEGIN_READ( pbuf, iSize ); int i = READ_SHORT(); if (i==0){ //We've died (or got told to lose all items) so remove inventory. for (i=0;i<MAX_ITEMS;i++){ g_iInventory[i]=0; } }else { i-=1; // subtract one so g_iInventory[0] can be used. (lowest ITEM_* is defined as '1') g_iInventory[i] = READ_SHORT(); } return 1; }
/* ==================== MsgCreateSystem ==================== */ int CParticleEngine::MsgCreateSystem( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ(pbuf, iSize); vec3_t pos; pos.x = READ_COORD(); pos.y = READ_COORD(); pos.z = READ_COORD(); vec3_t ang; ang.x = READ_COORD(); ang.y = READ_COORD(); ang.z = READ_COORD(); int iType = READ_BYTE(); char *szPath = READ_STRING(); int iId = READ_SHORT(); if(iType == 2) RemoveSystem(iId); else if(iType == 1) CreateCluster(szPath, pos, ang, iId); else CreateSystem(szPath, pos, ang, iId); return 1; }
int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ) { m_iFlags |= HUD_ACTIVE; BEGIN_READ( pbuf, iSize ); short cl = READ_BYTE(); short frags = READ_SHORT(); short deaths = READ_SHORT(); if ( cl > 0 && cl <= MAX_PLAYERS ) { m_PlayerExtraInfo[cl].frags = frags; m_PlayerExtraInfo[cl].deaths = deaths; } return 1; }
static void nv30_parse(struct nvbios *bios, char *rom, unsigned short nv_offset) { unsigned short init_offset = 0; unsigned short perf_offset=0; unsigned short volt_offset=0; int offset = READ_SHORT(rom, nv_offset + 30); bios->signon_msg = nv_read(rom, offset); init_offset = READ_SHORT(rom, nv_offset + 0x4d); volt_offset = READ_SHORT(rom, nv_offset + 0x98); parse_voltage_table(bios, rom, volt_offset); perf_offset = READ_SHORT(rom, nv_offset + 0x94); parse_nv30_performance_table(bios, rom, perf_offset); }
//LRC void CHud :: MsgFunc_SetFog( const char *pszName, int iSize, void *pbuf ) { // CONPRINT("MSG:SetFog"); BEGIN_READ( pbuf, iSize ); for ( int i = 0; i < 3; i++ ) { g_fogPostFade.fogColor[i] = READ_BYTE(); if ( g_fog.fogColor[i] >= 0 ) g_fogPreFade.fogColor[i] = g_fog.fogColor[i]; else g_fogPreFade.fogColor[i] = g_fogPostFade.fogColor[i]; } g_fFogFadeDuration = READ_SHORT(); g_fogPostFade.startDist = READ_SHORT(); if ( g_fog.startDist >= 0 ) g_fogPreFade.startDist = g_fog.startDist; else g_fogPreFade.startDist = g_fogPostFade.startDist; g_fogPostFade.endDist = READ_SHORT(); if ( g_fog.endDist >= 0 ) g_fogPreFade.endDist = g_fog.endDist; else g_fogPreFade.endDist = g_fogPostFade.endDist; if ( g_fFogFadeDuration < 0 ) { g_fFogFadeDuration *= -1; g_fogPostFade.startDist = FOG_LIMIT; g_fogPostFade.endDist = FOG_LIMIT; } else if ( g_fFogFadeDuration == 0 ) { g_fog.endDist = g_fogPostFade.endDist; for ( int i = 0; i < 3; i++ ) { g_fogPreFade.fogColor[i] = g_fog.fogColor[i]; } } g_fFogFadeFraction = 0; }
static void checkException(std::istream* inputStream) { uint16_t retCode; READ_SHORT(inputStream, retCode); if (retCode != 0) { retCode = ntohs(retCode); std::auto_ptr<std::string> error(readUTF(inputStream)); throw VoldemortException(error->c_str()); } }
// Message handler for ShowMenu message // takes four values: // short: a bitfield of keys that are valid input // char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen. // byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string // string: menu string to display // if this message is never received, then scores will simply be the combined totals of the players. int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) { char *temp = NULL; BEGIN_READ( pszName, pbuf, iSize ); m_bitsValidSlots = READ_SHORT(); int DisplayTime = READ_CHAR(); int NeedMore = READ_BYTE(); if( DisplayTime > 0 ) m_flShutoffTime = DisplayTime + gHUD.m_flTime; else m_flShutoffTime = -1; if( m_bitsValidSlots ) { if( !m_fWaitingForMore ) { // this is the start of a new menu Q_strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); } else { // append to the current menu string Q_strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - Q_strlen( g_szPrelocalisedMenuString )); } g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not) if( !NeedMore ) { // we have the whole string, so we can localise it now Q_strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString )); // Swap in characters if( KB_ConvertString( g_szMenuString, &temp )) { Q_strcpy( g_szMenuString, temp ); free( temp ); } } m_fMenuDisplayed = 1; m_iFlags |= HUD_ACTIVE; } else { m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off m_iFlags &= ~HUD_ACTIVE; } m_fWaitingForMore = NeedMore; END_READ(); return 1; }
int CHud::MsgFunc_ScreenShake( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); ShakeCommand_t eCommand = (ShakeCommand_t)READ_SHORT(); float amplitude = (float)(unsigned short)READ_SHORT() * (1.0f / (float)(1<<12)); float duration = (float)(unsigned short)READ_SHORT() * (1.0f / (float)(1<<12)); float frequency = (float)(unsigned short)READ_SHORT() * (1.0f / (float)(1<<8)); if( eCommand == SHAKE_STOP ) { m_Shake.amplitude = 0; m_Shake.frequency = 0; m_Shake.duration = 0; } else { if(( eCommand == SHAKE_START) || ( eCommand == SHAKE_FREQUENCY )) { m_Shake.frequency = frequency; } if(( eCommand == SHAKE_START) || ( eCommand == SHAKE_AMPLITUDE )) { // don't overwrite larger existing shake unless we are told to. if(( amplitude > m_Shake.amplitude ) || ( eCommand == SHAKE_AMPLITUDE )) { m_Shake.amplitude = amplitude; } } // only reset the timer for a new shake. if( eCommand == SHAKE_START ) { m_Shake.duration = duration; m_Shake.nextShake = 0; m_Shake.time = m_flTime + duration; } } END_READ(); return 1; }
int CHudMenu::MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ(pbuf, iSize); int menuType = READ_BYTE(); m_bitsValidSlots = READ_SHORT(); // is ignored ShowVGUIMenu(menuType); return 1; }
void __MsgFunc_TerrainMod( const char *pszName, int iSize, void *pbuf ) { CTerrainModParams params; BEGIN_READ( pbuf, iSize ); unsigned char type = READ_BYTE(); params.m_vCenter.x = READ_FLOAT(); params.m_vCenter.y = READ_FLOAT(); params.m_vCenter.z = READ_FLOAT(); params.m_flRadius = RemapVal( READ_SHORT(), 0, 65535, MIN_TMOD_RADIUS, MAX_TMOD_RADIUS ); params.m_vecMin.x = READ_FLOAT(); params.m_vecMin.y = READ_FLOAT(); params.m_vecMin.z = READ_FLOAT(); params.m_vecMax.x = READ_FLOAT(); params.m_vecMax.y = READ_FLOAT(); params.m_vecMax.z = READ_FLOAT(); params.m_flStrength = READ_FLOAT(); params.m_Flags = READ_BYTE(); if( type == TMod_Suck && (params.m_Flags & CTerrainModParams::TMOD_SUCKTONORMAL) ) { params.m_vNormal.x = READ_FLOAT(); params.m_vNormal.y = READ_FLOAT(); params.m_vNormal.z = READ_FLOAT(); } // Apply the decal first because the place where we're applying the decal // may not be there if we blow it out first! Vector vPosition(0,0,0); QAngle vAngles(0,0,0); int iModel = 0; C_BaseEntity *ent = cl_entitylist->GetEnt( iModel ); if( ent && type == TMod_Sphere ) { effects->DecalShoot( effects->Draw_DecalIndexFromName( "decals/tscorch" ), iModel, ent->GetModel(), vPosition, vAngles, params.m_vCenter, NULL, 0 ); } engine->ApplyTerrainMod( (TerrainModType)type, params ); }
int CHud :: MsgFunc_CamData( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); gHUD.viewEntityIndex = READ_SHORT(); gHUD.viewFlags = READ_SHORT(); if( gHUD.viewFlags ) m_iCameraMode = 1; else m_iCameraMode = m_iLastCameraMode; // update pparams->viewentity too for right hearing if( gHUD.viewEntityIndex ) gpViewParams->viewentity = gHUD.viewEntityIndex; else gpViewParams->viewentity = GetLocalPlayer()->serialnumber; END_READ(); return 1; }
int CHudRadio::MsgFunc_SendAudio(const char *pszName, int iSize, void *pbuf) { BEGIN_READ( pbuf, iSize ); m_bFirst = READ_BYTE( ); strcpy( m_sentence, READ_STRING( )); m_sThird = READ_SHORT( ); m_enableRadio = true; return 1; }
int CHudTimer::MsgFunc_Timer(const char *pszName, int iSize, void *pbuf ) { Time = READ_SHORT(); Inited = false; if (Time > 0) m_iFlags |= HUD_ACTIVE; else m_iFlags &= ~HUD_ACTIVE; return 1; }
// Message handler for TeamScore message // accepts three values: // string: team name // short: teams kills // short: teams deaths // if this message is never received, then scores will simply be the combined totals of the players. int CHudScoreboard :: MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); char *TeamName = READ_STRING(); // find the team matching the name for ( int i = 1; i <= m_iNumTeams; i++ ) { if ( !stricmp( TeamName, m_TeamInfo[i].name ) ) break; } if ( i > m_iNumTeams ) return 1; // use this new score data instead of combined player scores m_TeamInfo[i].scores_overriden = TRUE; m_TeamInfo[i].frags = READ_SHORT(); m_TeamInfo[i].deaths = READ_SHORT(); return 1; }
int CHud :: MsgFunc_ScreenFade( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); float fadeTime = (float)(unsigned short)READ_SHORT() * (1.0f / (float)(1<<12)); float holdTime = (float)(unsigned short)READ_SHORT() * (1.0f / (float)(1<<12)); int fadeFlags = READ_SHORT(); Vector m_FadeColor; m_FadeColor.x = READ_BYTE(); // fade red m_FadeColor.y = READ_BYTE(); // fade green m_FadeColor.z = READ_BYTE(); // fade blue float alpha = READ_BYTE(); // fade alpha SetScreenFade( m_FadeColor, alpha, fadeTime, holdTime, fadeFlags ); END_READ(); return 1; }
int CHud :: MsgFunc_Particle( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); int idx = READ_SHORT(); char *sz = READ_STRING(); CreateAurora( idx, sz ); END_READ(); return 1; }
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) { m_iFlags |= HUD_ACTIVE; BEGIN_READ( pbuf, iSize ); int x = READ_SHORT(); if (x != m_iBat) { m_fFade = FADE_TIME; m_iBat = x; } // modif de Julien float unTiers = ( (float)MAX_MEMBER_ARMOR / 3 ); float deuxTiers = ( (float)MAX_MEMBER_ARMOR * 2 / 3 ); for ( int i=0; i<MAX_ARMOR_GROUP; i++ ) { // lecture float value = READ_COORD(); // dommages if ( value > m_flArmorvalue[i] ) m_flPain[i] = ARMOR_PAIN_TIME; else if ( value < m_flArmorvalue[i] ) m_flPain[i] = -ARMOR_PAIN_TIME; m_flArmorvalue [i] = value; // couleurs /* horreur pour simplifier les couleurs : blanc 255 255 255 jaune 255 255 0 orange 255 128 0 rouge 255 0 0 */ m_flArmor [i] [0] = (int)( value > unTiers ? 255 : ( value / unTiers ) * ( 255 - 150 ) + 150 ); m_flArmor [i] [1] = (int)( value > deuxTiers ? 255 : ( value / deuxTiers ) * 255 ); m_flArmor [i] [2] = (int)( value < deuxTiers ? 0 : ( (value - deuxTiers) / unTiers ) * 255 ); } return 1; }
int CHudScoreboard::MsgFunc_ScoreInfo(const char *pszName, int iSize, void *pbuf) { m_iFlags |= HUD_ACTIVE; BEGIN_READ(pbuf, iSize); short cl = READ_BYTE(); short frags = READ_SHORT(); short deaths = READ_SHORT(); short playerclass = READ_SHORT(); short teamnumber = READ_SHORT(); if(cl > 0 && cl <= MAX_PLAYERS) { g_PlayerExtraInfo[cl].frags = frags; g_PlayerExtraInfo[cl].deaths = deaths; g_PlayerExtraInfo[cl].playerclass = playerclass; g_PlayerExtraInfo[cl].teamnumber = teamnumber; gViewPort->UpdateOnPlayerInfo(); } return 1; }
// Message handler for StatusText message // accepts two values: // byte: index into the status value array // short: value to store int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int index = READ_BYTE(); if ( index < 1 || index >= MAX_STATUSBAR_VALUES ) return 1; // index out of range m_iStatusValues[index] = READ_SHORT(); m_bReparseString = TRUE; return 1; }
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); m_iFlags |= HUD_ACTIVE; int x = READ_SHORT(); if( x != m_iBat ) { m_fFade = FADE_TIME; m_iBat = x; } return 1; }
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) { m_iFlags |= HUD_ACTIVE; BEGIN_READ( pbuf, iSize ); int x = READ_SHORT(); if (x != m_iBat) { // We're sent the health of the player we're observing as if it were our own m_fFade = FADE_TIME; m_iBat = x; } return 1; }
//=========================================================== // Message handler. Gets the Ids of the players in the round. int CDiscArenaPanel::MsgFunc_GetPlayers(const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); m_iRoundNumber = READ_BYTE(); m_iSecondsToGo = READ_BYTE(); m_iNumPlayers = READ_BYTE(); if ( m_iNumPlayers > 0 && m_iNumPlayers <= MAX_PLAYERS ) { for (int i = 0; i < m_iNumPlayers; i++) m_iClients[i] = READ_SHORT(); } RecalculateText(); return 1; }