static void restore_blends( buffer_vector<sblend_save>& buffer ) { buffer_vector<sblend_save>::iterator i = buffer.begin(), e = buffer.end(); for(; i != e; ++i ) (*i).restore(); buffer.clear(); }
void TryToDefuseWeapon(CWeapon const * weapon, TIItemContainer const & all_items, buffer_vector<shared_str> & dest_ammo) { if (!weapon) return; CWeaponMagazinedWGrenade const * tmp_gl_weapon = smart_cast<CWeaponMagazinedWGrenade const *>(weapon); if (weapon->IsGrenadeLauncherAttached()) TryToDefuseGrenadeLauncher(tmp_gl_weapon, all_items, dest_ammo); xr_vector<shared_str> const * tmp_ammo_types = NULL; u8 const * tmp_ammo_type = NULL; u16 ammo_elapsed = 0; if (tmp_gl_weapon && tmp_gl_weapon->m_bGrenadeMode) { tmp_ammo_types = &tmp_gl_weapon->m_ammoTypes2; tmp_ammo_type = &tmp_gl_weapon->m_ammoType2; ammo_elapsed = (u16)tmp_gl_weapon->m_magazine2.size(); } else { tmp_ammo_types = &weapon->m_ammoTypes; tmp_ammo_type = &weapon->m_ammoType; ammo_elapsed = (u16)weapon->GetAmmoElapsed(); } if (tmp_ammo_types->size() <= u32(*tmp_ammo_type)) return; shared_str ammo_section = (*tmp_ammo_types)[*tmp_ammo_type]; VERIFY2(ammo_section.size(), make_string( "ammo type of [%s] hasn't section name", weapon->cName().c_str()).c_str()); if (!ammo_section.size()) return; VERIFY(pSettings->line_exist(ammo_section.c_str(), "box_size")); u16 ammo_box_size = pSettings->r_u16(ammo_section.c_str(), "box_size"); while (ammo_elapsed >= ammo_box_size) { dest_ammo.push_back(ammo_section); ammo_elapsed = ammo_elapsed - ammo_box_size; } if (!ammo_elapsed) return; AmmoSearcherPredicate ammo_completitor(ammo_elapsed, ammo_section); TIItemContainer::const_iterator temp_iter = std::find_if( all_items.begin(), all_items.end(), ammo_completitor); if (temp_iter == all_items.end()) return; CWeaponAmmo* temp_ammo = smart_cast<CWeaponAmmo*>(*temp_iter); R_ASSERT2(temp_ammo, "failed to create ammo after defusing weapon"); temp_ammo->m_boxCurr = temp_ammo->m_boxSize; }
void UIPlayerItem::GetIconParamValue(game_PlayerState const * ps, shared_str const & param_name, buffer_vector<char> & dest) { VERIFY(ps); game_cl_mp* cl_game = static_cast<game_cl_mp*>(&Game()); VERIFY(cl_game); if (param_name.equal("rank")) { if (ETeam(cl_game->ModifyTeam(ps->team)) == etGreenTeam) { sprintf_s(dest.begin(), dest.size(), "ui_hud_status_green_0%d", ps->rank + 1); } else if (ETeam(cl_game->ModifyTeam(ps->team)) == etBlueTeam) { sprintf_s(dest.begin(), dest.size(), "ui_hud_status_blue_0%d", ps->rank + 1); } } else if (param_name.equal("death_atf")) { if (ps->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) { strcpy_s(dest.begin(), dest.size(), "death"); return; } if (cl_game->Type() == eGameIDCaptureTheArtefact) { game_cl_CaptureTheArtefact* cta_cl_game = static_cast<game_cl_CaptureTheArtefact*>(cl_game); R_ASSERT(cta_cl_game); if (ps->GameID == cta_cl_game->GetGreenArtefactOwnerID() || ps->GameID == cta_cl_game->GetBlueArtefactOwnerID()) { strcpy_s(dest.begin(), dest.size(), "artefact"); } } else if (cl_game->Type() == eGameIDArtefactHunt) { game_cl_ArtefactHunt* ahunt_cl_game = static_cast<game_cl_ArtefactHunt*>(cl_game); R_ASSERT(ahunt_cl_game); if (ps->GameID == ahunt_cl_game->artefactBearerID) { strcpy_s(dest.begin(), dest.size(), "artefact"); } } } else { VERIFY2(false, make_string("unknown icon parameter: %s", param_name.c_str()).c_str()); } }
static void save_blends( buffer_vector<sblend_save>& buffer, IKinematicsAnimated& KA ) { buffer.clear(); struct scbl: public IterateBlendsCallback, private boost::noncopyable { buffer_vector<sblend_save>& _buffer; scbl( buffer_vector<sblend_save>& bf ): _buffer( bf ){} virtual void operator () ( CBlend &B ) { sblend_save s; s.save( &B ); _buffer.push_back( s ); } } cbl( buffer ); KA.LL_IterateBlends( cbl ); }
void StipplePenHandle::Init(buffer_vector<uint8_t, 8> const & pattern) { // encoding scheme // 63 - 61 bits = size of pattern in range [0 : 8] // 60 - 53 bits = first value of pattern in range [1 : 128] // 52 - 45 bits = second value of pattern // .... // 0 - 5 bits = reserved uint32_t patternSize = pattern.size(); ASSERT(patternSize >= 1 && patternSize < 9, (patternSize)); m_keyValue = patternSize - 1; // we code value 1 as 000 and value 8 as 111 for (size_t i = 0; i < patternSize; ++i) { m_keyValue <<=7; ASSERT(pattern[i] > 0, ()); // we have 7 bytes for value. value = 1 encode like 0000000 ASSERT(pattern[i] < 129, ()); // value = 128 encode like 1111111 uint32_t value = pattern[i] - 1; m_keyValue += value; } m_keyValue <<= ((8 - patternSize) * 7 + 5); }
/// @note! Used only in StraightTextElement. m2::RectD GetLastGlobalRect() const { return m_boundRects.back().GetGlobalRect(); }
void UIPlayerItem::GetTextParamValue(game_PlayerState const * ps, shared_str const & param_name, buffer_vector<char> & dest) { VERIFY(ps); if (param_name.equal("mp_name")) { strcpy_s(dest.begin(), dest.size(), ps->name); } else if (param_name.equal("mp_frags")) { sprintf_s(dest.begin(), dest.size(), "%d", ps->m_iRivalKills - ps->m_iSelfKills); } else if (param_name.equal("mp_deaths")) { sprintf_s(dest.begin(), dest.size(), "%d", ps->m_iDeaths); } else if (param_name.equal("mp_artefacts")) { sprintf_s(dest.begin(), dest.size(), "%d", ps->af_count); } else if (param_name.equal("mp_spots")) { sprintf_s(dest.begin(), dest.size(), "%d", m_checkPoints); }else if (param_name.equal("mp_status")) { CStringTable st; if (ps->testFlag(GAME_PLAYER_FLAG_READY)) strcpy_s(dest.begin(), dest.size(), st.translate("st_mp_ready").c_str()); } else if (param_name.equal("mp_ping")) { sprintf_s(dest.begin(), dest.size(), "%d", ps->ping); } }