/* ================= UpdateClientData Data sent to current client only engine sets cd to 0 before calling. ================= */ void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) { cd->flags = ent->v.flags; cd->health = ent->v.health; cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) ); cd->waterlevel = ent->v.waterlevel; cd->watertype = ent->v.watertype; cd->weapons = ent->v.weapons; // Vectors cd->origin = ent->v.origin; cd->velocity = ent->v.velocity; cd->view_ofs = ent->v.view_ofs; cd->punchangle = ent->v.punchangle; cd->bInDuck = ent->v.bInDuck; cd->flTimeStepSound = ent->v.flTimeStepSound; cd->flDuckTime = ent->v.flDuckTime; cd->flSwimTime = ent->v.flSwimTime; cd->waterjumptime = ent->v.teleport_time; strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) ); cd->maxspeed = ent->v.maxspeed; cd->fov = ent->v.fov; cd->weaponanim = ent->v.weaponanim; cd->pushmsec = ent->v.pushmsec; // Spectator cd->iuser1 = ent->v.iuser1; cd->iuser2 = ent->v.iuser2; if ( sendweapons ) { entvars_t *pev = (entvars_t *)&ent->v; CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); if ( pl ) { cd->m_flNextAttack = pl->m_flNextAttack; if ( pl->m_pActiveItem ) { CBasePlayerWeapon *gun; gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr(); if ( gun && gun->UseDecrement() ) { ItemInfo II; memset( &II, 0, sizeof( II ) ); gun->GetItemInfo( &II ); cd->m_iId = II.iId; } } } } }
int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) { #if defined( CLIENT_WEAPONS ) int i; weapon_data_t *item; entvars_t *pev = &player->v; CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); CBasePlayerWeapon *gun; ItemInfo II; memset( info, 0, 32 * sizeof( weapon_data_t ) ); if ( !pl ) return 1; // go through all of the weapons and make a list of the ones to pack for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) { if ( pl->m_rgpPlayerItems[ i ] ) { // there's a weapon here. Should I pack it? CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[ i ]; while ( pPlayerItem ) { gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); if ( gun && gun->UseDecrement() ) { // Get The ID. memset( &II, 0, sizeof( II ) ); gun->GetItemInfo( &II ); if ( II.iId >= 0 && II.iId < 32 ) { item = &info[ II.iId ]; item->m_iId = II.iId; item->m_iClip = gun->m_iClip; item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 ); item->m_fInReload = gun->m_fInReload; } } pPlayerItem = pPlayerItem->m_pNext; } } } #else memset( info, 0, 32 * sizeof( weapon_data_t ) ); #endif return 1; }
bool HUD_GetWeaponEnabled(int inID) { ASSERT(inID >= 0); ASSERT(inID < 32); // puzl: 497 - use the enabled state in the associated WEAPON instead of the CBasePlayerWeapon's iuser3 bool theWeaponEnabled = false; CBasePlayerWeapon* theWeapon = g_pWpns[inID]; if(theWeapon) { ItemInfo theItemInfo; theWeapon->GetItemInfo(&theItemInfo); WEAPON *pWeapon = gWR.GetWeapon( theItemInfo.iId ); if ( pWeapon != 0 ) { theWeaponEnabled = (pWeapon->iEnabled == 1); } } return theWeaponEnabled; }
/* ================= UpdateClientData Data sent to current client only engine sets cd to 0 before calling. ================= */ void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) { cd->flags = ent->v.flags; cd->health = ent->v.health; cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) ); cd->waterlevel = ent->v.waterlevel; cd->watertype = ent->v.watertype; cd->weapons = ent->v.weapons; // Vectors cd->origin = ent->v.origin; cd->velocity = ent->v.velocity; cd->view_ofs = ent->v.view_ofs; cd->punchangle = ent->v.punchangle; cd->bInDuck = ent->v.bInDuck; cd->flTimeStepSound = ent->v.flTimeStepSound; cd->flDuckTime = ent->v.flDuckTime; cd->flSwimTime = ent->v.flSwimTime; cd->waterjumptime = ent->v.teleport_time; strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) ); cd->maxspeed = ent->v.maxspeed; cd->fov = ent->v.fov; cd->weaponanim = ent->v.weaponanim; cd->pushmsec = ent->v.pushmsec; #if defined( CLIENT_WEAPONS ) if ( sendweapons ) { entvars_t *pev = (entvars_t *)&ent->v; CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); if ( pl ) { cd->m_flNextAttack = pl->m_flNextAttack; cd->fuser2 = pl->m_flNextAmmoBurn; cd->fuser3 = pl->m_flAmmoStartCharge; cd->vuser1.x = pl->ammo_9mm; cd->vuser1.y = pl->ammo_357; cd->vuser1.z = pl->ammo_argrens; cd->ammo_nails = pl->ammo_bolts; cd->ammo_shells = pl->ammo_buckshot; cd->ammo_rockets = pl->ammo_rockets; cd->ammo_cells = pl->ammo_uranium; cd->vuser2.x = pl->ammo_hornets; if ( pl->m_pActiveItem ) { CBasePlayerWeapon *gun; gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr(); if ( gun && gun->UseDecrement() ) { ItemInfo II; memset( &II, 0, sizeof( II ) ); gun->GetItemInfo( &II ); cd->m_iId = II.iId; cd->vuser3.z = gun->m_iSecondaryAmmoType; cd->vuser4.x = gun->m_iPrimaryAmmoType; cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType]; cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType]; if ( pl->m_pActiveItem->m_iId == WEAPON_RPG ) { cd->vuser2.y = ( ( CRpg * )pl->m_pActiveItem)->m_fSpotActive; cd->vuser2.z = ( ( CRpg * )pl->m_pActiveItem)->m_cActiveRockets; } } } } } #endif }