bool PS::CPEDef::OnAfterActionNameEdit(PropValue* sender, shared_str& edit_val) { bool found = false; edit_val = AnsiString(edit_val.c_str()).LowerCase().c_str(); FindActionByName (edit_val.c_str(),found); return !found; }
void CRestrictions::AddRestriction4rank(u32 rank, const shared_str& lst) {// private VERIFY (m_bInited); rank_rest_vec& rest = m_restrictions[rank]; if(rank!=_RANK_COUNT) { u32 src_idx = (rank==0)?_RANK_COUNT:(rank-1); rest = m_restrictions[ src_idx ]; } string256 singleItem; u32 count = _GetItemCount(lst.c_str()); for (u32 j = 0; j < count; ++j) { _GetItem (lst.c_str(), j, singleItem); RESTR r = GetRestr(singleItem); restr_item* ritem = find_restr_item_internal(rank, r.name); VERIFY2 ((ritem || rank==_RANK_COUNT), singleItem); if(!ritem) rest.push_back (mk_pair(r.name, r.n)); else ritem->second = r.n; } }
void PDomain::Save2(CInifile& ini, const shared_str& sect) { ini.w_u32 (sect.c_str(), "type", type); ini.w_fvector3 (sect.c_str(), "v0", v[0]); ini.w_fvector3 (sect.c_str(), "v1", v[1]); ini.w_fvector3 (sect.c_str(), "v2", v[2]); }
shared_str manager::unique_id (shared_str const& id) const { if (m_collection->unique_id(id.c_str())) return (id); return (m_collection->generate_unique_id(id.c_str())); }
u32 player_hud::motion_length(const shared_str& anim_name, const shared_str& hud_name, const CMotionDef*& md) { float speed = CalcMotionSpeed(anim_name); attachable_hud_item* pi = create_hud_item(hud_name); player_hud_motion* pm = pi->m_hand_motions.find_motion(anim_name); if(!pm) return 100; // ms TEMPORARY R_ASSERT2 (pm, make_string ("hudItem model [%s] has no motion with alias [%s]", hud_name.c_str(), anim_name.c_str() ).c_str() ); return motion_length (pm->m_animations[0].mid, md, speed); }
void CObject::cNameVisual_set (shared_str N) { // check if equal if (*N && *NameVisual) if (N==NameVisual) return; // replace model if (*N && N[0]) { IRender_Visual *old_v = renderable.visual; #ifdef DEBUG if(NameVisual.size()) Msg("---change NameVisual from[%s] to [%s]",NameVisual.c_str(), N.c_str()); #endif // DEBUG NameVisual = N; renderable.visual = Render->model_Create (*N); CKinematics* old_k = old_v?old_v->dcast_PKinematics():NULL; CKinematics* new_k = renderable.visual->dcast_PKinematics(); if(old_k && new_k){ new_k->Update_Callback = old_k->Update_Callback; new_k->Update_Callback_Param = old_k->Update_Callback_Param; } ::Render->model_Delete (old_v); } else { ::Render->model_Delete (renderable.visual); NameVisual = 0; } OnChangeVisual (); }
BOOL is_combat_cover (shared_str const &table_id) { if (table_id.size() == 0) return (FALSE); string256 temp; xr_strcpy (temp, "smart_covers.descriptions."); xr_strcat (temp, *table_id); luabind::object table, value; bool result = ai().script_engine().function_object( temp, table, LUA_TTABLE ); VERIFY2 (result, make_string("bad or missing description in smart_cover [%s]", table_id.c_str())); if (table.type() != LUA_TTABLE) { VERIFY (table.type() != LUA_TNIL); return (TRUE); } value = table["is_combat_cover"]; if (value.type() == LUA_TNIL) { Msg ("! is_combat_cover flag not found for smart_cover [%s], forcing to \"true\"", table_id.c_str()); return (TRUE); } return (parse_bool(table, "is_combat_cover") ? TRUE : FALSE); }
shared_str weather::generate_unique_id (shared_str const& start) const { string16 id; strcpy_s (id, start.c_str()); VERIFY (xr_strlen(id) == 8); VERIFY (is_digit(id[0])); VERIFY (is_digit(id[1])); VERIFY (id[2] == ':'); VERIFY (is_digit(id[3])); VERIFY (is_digit(id[4])); VERIFY (id[5] == ':'); VERIFY (is_digit(id[6])); VERIFY (is_digit(id[7])); u32 hours, minutes, seconds; sscanf_s (id, "%02d:%02d:%02d", &hours, &minutes, &seconds); shared_str result; if (try_hours(hours, minutes, seconds, result)) return (result); if (try_minutes(hours, minutes, seconds, result)) return (result); return (try_all(hours, minutes, seconds)); }
bool weather::valid_id (shared_str const& id_) const { LPCSTR id = id_.c_str(); if (!is_digit(id[0])) return (false); if (!is_digit(id[1])) return (false); if (id[2] != ':') return (false); if (!is_digit(id[3])) return (false); if (!is_digit(id[4])) return (false); if (id[5] != ':') return (false); if (!is_digit(id[6])) return (false); if (!is_digit(id[7])) return (false); return (true); }
void CEnvironment::SetWeather(shared_str name, bool forced) { //. static BOOL bAlready = FALSE; //. if(bAlready) return; if (name.size()) { //. bAlready = TRUE; EnvsMapIt it = WeatherCycles.find(name); if (it == WeatherCycles.end()) { Msg("! Invalid weather name: %s", name.c_str()); return; } R_ASSERT3 (it!=WeatherCycles.end(),"Invalid weather name.",*name); CurrentCycleName = it->first; if (forced) {Invalidate(); } if (!bWFX){ CurrentWeather = &it->second; CurrentWeatherName = it->first; } if (forced) {SelectEnvs(fGameTime); } #ifdef WEATHER_LOGGING Msg ("Starting Cycle: %s [%s]",*name,forced?"forced":"deferred"); #endif }else{ #ifndef _EDITOR FATAL ("! Empty weather name"); #endif } }
void CUIBagWnd::ReloadItemsPrices () { string256 ItemCostStr = ""; string256 RankStr = ""; u32 sz = m_allItems.size(); for (u32 i = 0; i<sz; i++) { CUICellItem* itm = m_allItems[i]; CInventoryItem* iitm = (CInventoryItem*)itm->m_pData; const shared_str itm_name = iitm->object().cNameSect(); m_info[itm->m_index].price = pSettings->r_u32(m_sectionPrice, *itm_name); strconcat (sizeof(ItemCostStr),ItemCostStr, itm_name.c_str(), "_cost"); if (pSettings->line_exist (m_sectionPrice, ItemCostStr)) m_info[itm->m_index].price = pSettings->r_u32(m_sectionPrice, ItemCostStr); for (u32 i=1; i<=g_mp_restrictions.GetRank(); ++i) { sprintf_s (RankStr, "rank_%d", i); if (!pSettings->line_exist (RankStr, ItemCostStr)) continue; m_info[itm->m_index].price = pSettings->r_u32(RankStr, ItemCostStr); } } }
bool __stdcall PS::CPEDef::NameOnAfterEdit(PropValue* sender, shared_str& edit_val) { for (PS::PGDIt g_it= ::Render->PSLibrary.FirstPGD(); g_it!=::Render->PSLibrary.LastPGD(); ++g_it) { PS::CPGDef* pg = (*g_it); xr_vector<PS::CPGDef::SEffect*>::const_iterator pe_it = pg->m_Effects.begin(); xr_vector<PS::CPGDef::SEffect*>::const_iterator pe_it_e = pg->m_Effects.end(); for(;pe_it!=pe_it_e;++pe_it) { PS::CPGDef::SEffect* Eff = (*pe_it); if(Eff->m_EffectName == this->m_Name) Eff->m_EffectName = edit_val; if(Eff->m_OnPlayChildName == this->m_Name) Eff->m_OnPlayChildName = edit_val; if(Eff->m_OnBirthChildName == this->m_Name) Eff->m_OnBirthChildName = edit_val; if(Eff->m_OnDeadChildName == this->m_Name) Eff->m_OnDeadChildName = edit_val; } } _item_to_select_after_edit = edit_val.c_str(); return true; }
void CUIActorInfoWnd::FillPointsDetail(const shared_str& id) { UIDetailList->Clear (); CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH,ACTOR_STATISTIC_XML); uiXml.SetLocalRoot (uiXml.NavigateToNode("actor_stats_wnd",0)); string512 path; sprintf_s (path,"detail_part_%s",id.c_str()); XML_NODE* n = uiXml.NavigateToNode(path,0); if(!n) sprintf_s (path,"detail_part_def"); #pragma todo("implement this") /* string256 str; sprintf_s (str,"st_detail_list_for_%s", id.c_str()); UIInfoHeader->GetTitleStatic()->SetTextST (str); */ SStatSectionData& section = Actor()-> StatisticMgr().GetSection(id); vStatDetailData::const_iterator it = section.data.begin(); vStatDetailData::const_iterator it_e = section.data.end(); int _cntr = 0; string64 buff; for(;it!=it_e;++it,++_cntr) { CUIActorStaticticDetail* itm = xr_new<CUIActorStaticticDetail>(); itm->Init (&uiXml, path, 0); sprintf_s (buff,"%d.",_cntr); itm->m_text0->SetText (buff); itm->m_text1->SetTextST (*CStringTable().translate((*it).key)); itm->m_text1->AdjustHeightToText (); if( 0==(*it).str_value.size() ) { sprintf_s (buff,"x%d", (*it).int_count); itm->m_text2->SetTextST (buff); sprintf_s (buff,"%d", (*it).int_points); itm->m_text3->SetTextST (buff); }else { itm->m_text2->SetTextST ((*it).str_value.c_str()); itm->m_text3->SetTextST (""); } Fvector2 sz = itm->GetWndSize(); float _height; _height = _max(sz.y, itm->m_text1->GetWndPos().y+itm->m_text1->GetWndSize().y+3); sz.y = _height; itm->SetWndSize (sz); UIDetailList->AddWindow (itm, true); } }
void CUITalkWnd::AddQuestion(const shared_str& text, const shared_str& value) { if(text.size() == 0) { return; } UITalkDialogWnd->AddQuestion(*CStringTable().translate(text),value.c_str()); }
RESTR CRestrictions::GetRestr(const shared_str& item) { // private function VERIFY (m_bInited); RESTR ret; string512 _name; int _cnt = 0; ptrdiff_t n = strchr(item.c_str(),':') - item.c_str(); if( n>0 ) { strncpy (_name, item.c_str(), n ); _name[n] = 0; _cnt = sscanf(item.c_str()+n+1,"%d", &ret.n); } R_ASSERT3 (n>0 && _cnt==1, "invalid record format <name_sect:rank>", item.c_str()); ret.name = _name; return ret; }
void CSE_ALifeInventoryItem::add_upgrade( const shared_str& upgrade_id ) { if ( !has_upgrade( upgrade_id ) ) { m_upgrades.push_back( upgrade_id ); return; } FATAL( make_string( "Can`t add existent upgrade (%s)!", upgrade_id.c_str() ).c_str() ); }
void CUITalkWnd::AddAnswer(const shared_str& text, LPCSTR SpeakerName) { //для пустой фразы вообще ничего не выводим if(text.size() == 0) return; PlaySnd (text.c_str()); bool i_am = (0 == xr_strcmp(SpeakerName, m_pOurInvOwner->Name())); UITalkDialogWnd->AddAnswer(SpeakerName,*CStringTable().translate(text),i_am); }
shared_str weather::unique_id (shared_str const& current, shared_str const& id) const { if (!valid_id(id)) return (current); if (m_collection->unique_id(id.c_str())) return (id); return (generate_unique_id(id)); }
shared_str transform_vertex(shared_str const &vertex_id, bool const &in) { if (*vertex_id.c_str()) return (vertex_id); if (in) return (s_enter_loophole_id); return (s_exit_loophole_id); }
u16 CPartition::part_id(const shared_str& name) const { for(u16 i=0; i<MAX_PARTS; ++i) { const CPartDef& pd = part(i); if(pd.Name == name) return i; } Msg("! there is no part named [%s]", name.c_str() ); return u16(-1); }
const u32 CItemMgr::GetItemIdx(const shared_str& sect_name) const { COST_MAP_CIT it = m_items.find(sect_name); if (it==m_items.end()) { Msg("item not found in registry [%s]", sect_name.c_str()); return u32(-1); } return u32( std::distance(m_items.begin(), it) ); }
u32 CRestrictions::GetItemCount(const shared_str& item_sect) const { VERIFY (m_bInited); const shared_str& group_name = GetItemGroup(item_sect); VERIFY3 (group_name.size(), "item has no group", item_sect.c_str()); const restr_item* res = find_restr_item(m_rank, group_name); VERIFY4 (res, "group has no restrictions for rank", group_name.c_str(), GetRankName(m_rank).c_str()); return res->second; }
void CUIArtefactDetectorElite::RegisterItemToDraw(const Fvector& p, const shared_str& palette_idx) { xr_map<shared_str,CUIStatic*>::iterator it = m_palette.find(palette_idx); if(it==m_palette.end()) { Msg("! RegisterItemToDraw. static not found for [%s]", palette_idx.c_str()); return; } CUIStatic* S = m_palette[palette_idx]; SDrawOneItem itm(S, p); m_items_to_draw.push_back (itm); }
void ammunition_group::init_ammunition_group(CItemMgr const * item_manager, enum_group_id gid, shared_str const & weapons_string) { string256 dststr; u32 count = _GetItemCount(weapons_string.c_str()); for (u32 i = 0; i < count; ++i) { _GetItem (weapons_string.c_str(), i, dststr); u32 itm_index = item_manager->GetItemIdx(dststr); if (itm_index != u32(-1)) { VERIFY((itm_index & 0xffff0000) == 0); m_wpn_groups.push_back( std::make_pair( static_cast<u16>(itm_index), gid ) ); } }; }
u32 get_rank(const shared_str §ion) { int res = 0; // -1; fixed get_rank for weapon w/o rank if( g_ranks[0].size()==0 ) { //load string32 buff; for (int i = 0; i<_RANK_COUNT; i++) { sprintf_s(buff, "rank_%d", i); g_ranks[i] = pSettings->r_string(buff, "available_items"); } } for (u32 i = 0; i<_RANK_COUNT; i++) { if (strstr(g_ranks[i].c_str(), section.c_str())) { res = i; break; } } R_ASSERT3 (res!=-1,"cannot find rank for", section.c_str()); return res; }
void CUITalkWnd::AddQuestion(const shared_str& text, const shared_str& value #ifdef NUM_PHRASES , int number #endif ) { if(text.size() == 0) { return; } UITalkDialogWnd->AddQuestion(*CStringTable().translate(text),value.c_str() #ifdef NUM_PHRASES , number #endif ); }
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()); } }
void CSMotion::add_empty_motion (shared_str const &bone_id) { VERIFY (!FindBoneMotion(bone_id)); st_BoneMotion motion; motion.SetName (bone_id.c_str()); // flRKeyAbsent = (1<<1), motion.m_Flags.assign ( 1 << 1); for (int ch=0; ch<ctMaxChannel; ch++){ motion.envs[ch] = xr_new<CEnvelope> (); // motion.envs[ch]; } bone_mots.push_back (motion); }
shared_str game_sv_GameState::parse_level_version (const shared_str &server_options) { const char* map_ver = strstr(server_options.c_str(), map_ver_string); string128 result_version; if (map_ver) { map_ver += sizeof(map_ver_string); if (strchr(map_ver, '/')) strncpy_s(result_version, map_ver, strchr(map_ver, '/') - map_ver); else xr_strcpy(result_version, map_ver); } else { xr_strcpy(result_version, default_map_version); } return shared_str(result_version); }
bool xr_dsa::verify (public_key_t const & pub_key, u8 const * data, u32 const data_size, shared_str const & dsign) { BN_bin2bn(pub_key.m_value, sizeof(pub_key.m_value), m_dsa->pub_key); BIGNUM* tmp_bn = NULL; BN_hex2bn (&tmp_bn, dsign.c_str()); int sig_size = tmp_bn->top * sizeof(unsigned long); u8* sig_buff = static_cast<u8*>(_alloca(sig_size)); VERIFY (sig_size == DSA_size(m_dsa)); BN_bn2bin (tmp_bn, sig_buff); bool ret = DSA_verify (0, data, data_size, sig_buff, sig_size, m_dsa) == 1 ? true : false; BN_free(tmp_bn); return ret; }