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]); }
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); }
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; }
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())); }
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 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); } } }
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 CUITalkWnd::AddQuestion(const shared_str& text, const shared_str& value) { if(text.size() == 0) { return; } UITalkDialogWnd->AddQuestion(*CStringTable().translate(text),value.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); }
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 CRestrictedObject::remove_restrictions (const shared_str &out_restrictions, const shared_str &in_restrictions) { if (!out_restrictions.size() && !in_restrictions.size()) return; START_PROFILE("Restricted Object/Remove Restrictions"); Level().space_restriction_manager().remove_restrictions (object().ID(),*out_restrictions,*in_restrictions); actual (false); STOP_PROFILE; }
s32 UITeamState::GetFieldValue(shared_str const & field_name) const { if (field_name.equal("mp_artefacts_upcase")) { return m_artefact_count; } else if (field_name.equal("mp_players")) { return static_cast<s32>(myPlayers.size()); } else if (field_name.equal("mp_frags_upcase")) { return GetSummaryFrags(); } return -1; }
CGameTaskManager::CGameTaskManager() { m_gametasks = xr_new<CGameTaskWrapper>(); m_flags.zero (); m_flags.set (eChanged, TRUE); if(g_active_task_id.size()) SetActiveTask(g_active_task_id, g_active_task_objective_id); }
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 __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 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 (); }
void CUIHudStatesWnd::SetAmmoIcon(const shared_str& sect_name) { if (!sect_name.size()) { m_ui_weapon_icon->Show(false); return; } m_ui_weapon_icon->Show(true); Frect texture_rect; texture_rect.x1 = pSettings->r_float(sect_name, "inv_grid_x") *INV_GRID_WIDTH; texture_rect.y1 = pSettings->r_float(sect_name, "inv_grid_y") *INV_GRID_HEIGHT; texture_rect.x2 = pSettings->r_float( sect_name, "inv_grid_width") *INV_GRID_WIDTH; texture_rect.y2 = pSettings->r_float( sect_name, "inv_grid_height") *INV_GRID_HEIGHT; texture_rect.rb.add (texture_rect.lt); m_ui_weapon_icon->GetUIStaticItem().SetTextureRect(texture_rect); m_ui_weapon_icon->SetStretchTexture(true); float h = texture_rect.height() * 0.8f; float w = texture_rect.width() * 0.8f; // now perform only width scale for ammo, which (W)size >2 if (texture_rect.width() > 2.01f*INV_GRID_WIDTH) w = INV_GRID_WIDTH * 1.5f; m_ui_weapon_icon->SetWidth( w*UI().get_current_kx() ); m_ui_weapon_icon->SetHeight( h ); }
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 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 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 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); } }
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() ); }
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; }
bool CEnvironment::SetWeatherFX(shared_str name) { if (bWFX) return false; if (name.size()){ EnvsMapIt it = WeatherFXs.find(name); R_ASSERT3 (it!=WeatherFXs.end(),"Invalid weather effect name.",*name); EnvVec* PrevWeather = CurrentWeather; VERIFY(PrevWeather); CurrentWeather = &it->second; CurrentWeatherName = it->first; float rewind_tm = WFX_TRANS_TIME*fTimeFactor; float start_tm = fGameTime+rewind_tm; float current_length; float current_weight; if (Current[0]->exec_time>Current[1]->exec_time){ float x = fGameTime>Current[0]->exec_time?fGameTime-Current[0]->exec_time:(DAY_LENGTH-Current[0]->exec_time)+fGameTime; current_length = (DAY_LENGTH-Current[0]->exec_time)+Current[1]->exec_time; current_weight = x/current_length; }else{ current_length = Current[1]->exec_time-Current[0]->exec_time; current_weight = (fGameTime-Current[0]->exec_time)/current_length; } clamp (current_weight,0.f,1.f); std::sort (CurrentWeather->begin(),CurrentWeather->end(),sort_env_etl_pred); CEnvDescriptor* C0 = CurrentWeather->at(0); CEnvDescriptor* C1 = CurrentWeather->at(1); CEnvDescriptor* CE = CurrentWeather->at(CurrentWeather->size()-2); CEnvDescriptor* CT = CurrentWeather->at(CurrentWeather->size()-1); C0->copy (*Current[0]); C0->exec_time = NormalizeTime(fGameTime-((rewind_tm/(Current[1]->exec_time-fGameTime))*current_length-rewind_tm)); C1->copy (*Current[1]); C1->exec_time = NormalizeTime(start_tm); for (EnvIt t_it=CurrentWeather->begin()+2; t_it!=CurrentWeather->end()-1; t_it++) (*t_it)->exec_time= NormalizeTime(start_tm+(*t_it)->exec_time_loaded); SelectEnv (PrevWeather,WFX_end_desc[0],CE->exec_time); SelectEnv (PrevWeather,WFX_end_desc[1],WFX_end_desc[0]->exec_time+0.5f); CT->copy (*WFX_end_desc[0]);CT->exec_time = NormalizeTime(CE->exec_time+rewind_tm); wfx_time = TimeDiff(fGameTime,CT->exec_time); bWFX = true; // sort wfx envs std::sort (CurrentWeather->begin(),CurrentWeather->end(),sort_env_pred); Current[0] = C0; Current[1] = C1; #ifdef WEATHER_LOGGING Msg ("Starting WFX: '%s' - %3.2f sec",*name,wfx_time); for (EnvIt l_it=CurrentWeather->begin(); l_it!=CurrentWeather->end(); l_it++) Msg (". Env: '%s' Tm: %3.2f",*(*l_it)->sect_name,(*l_it)->exec_time); #endif }else{ #ifndef _EDITOR FATAL ("! Empty weather effect name"); #endif } return true; }
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); }
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)); }
void CEffect_Thunderbolt::OnFrame(shared_str id, float period, float duration) { BOOL enabled = !!(id.size()); if (bEnabled!=enabled){ bEnabled = enabled; next_lightning_time = Device.fTimeGlobal+period+Random.randF(-period*0.5f,period*0.5f); }else if (bEnabled&&(Device.fTimeGlobal>next_lightning_time)){ if (state==stIdle && !!(id.size())) Bolt(id,period,duration); } if (state==stWorking){ if (current_time>life_time) state = stIdle; current_time += Device.fTimeDelta; Fvector fClr; int frame; u32 uClr = current->color_anim->CalculateRGB(current_time/life_time,frame); fClr.set ( clampr(float(color_get_R(uClr)/255.f), 0.f, 1.f), clampr(float(color_get_G(uClr)/255.f), 0.f, 1.f), clampr(float(color_get_B(uClr)/255.f), 0.f, 1.f) ); lightning_phase = 1.5f*(current_time/life_time); clamp (lightning_phase,0.f,1.f); CEnvironment& environment = g_pGamePersistent->Environment(); Fvector& sky_color = environment.CurrentEnv->sky_color; sky_color.mad ( fClr, environment.p_sky_color ); clamp ( sky_color.x, 0.f, 1.f ); clamp ( sky_color.y, 0.f, 1.f ); clamp ( sky_color.z, 0.f, 1.f ); environment.CurrentEnv->sun_color.mad(fClr,environment.p_sun_color); environment.CurrentEnv->fog_color.mad(fClr,environment.p_fog_color); if (::Render->get_generation()==IRender_interface::GENERATION_R2) { R_ASSERT ( _valid(current_direction) ); g_pGamePersistent->Environment().CurrentEnv->sun_dir = current_direction; VERIFY2(g_pGamePersistent->Environment().CurrentEnv->sun_dir.y<0,"Invalid sun direction settings while CEffect_Thunderbolt"); } } }
bool CInventoryOwner::HasInfo(shared_str info_id) const { VERIFY( info_id.size() ); const KNOWN_INFO_VECTOR* known_info = m_known_info_registry->registry().objects_ptr (); if(!known_info) return false; if(std::find_if(known_info->begin(), known_info->end(), CFindByIDPred(info_id)) == known_info->end()) return false; return true; }
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); }