void CGameObject::spawn_supplies() { if (!spawn_ini() || ai().get_alife()) return; if (!spawn_ini()->section_exist("spawn")) return; LPCSTR N,V; float p; bool bScope = false; bool bSilencer = false; bool bLauncher = false; for (u32 k = 0, j; spawn_ini()->r_line("spawn",k,&N,&V); k++) { VERIFY (xr_strlen(N)); j = 1; p = 1.f; float f_cond = 1.0f; if (V && xr_strlen(V)) { int n = _GetItemCount(V); string16 temp; if (n > 0) j = atoi(_GetItem(V,0,temp)); //count if(NULL!=strstr(V,"prob=")) p =(float)atof(strstr(V,"prob=")+5); if (fis_zero(p))p = 1.f; if (!j) j = 1; if(NULL!=strstr(V,"cond=")) f_cond = (float)atof(strstr(V,"cond=")+5); bScope = (NULL!=strstr(V,"scope")); bSilencer = (NULL!=strstr(V,"silencer")); bLauncher = (NULL!=strstr(V,"launcher")); } for (u32 i=0; i<j; ++i) if (::Random.randF(1.f) < p){ CSE_Abstract* A=Level().spawn_item (N,Position(),ai_location().level_vertex_id(),ID(),true); CSE_ALifeInventoryItem* pSE_InventoryItem = smart_cast<CSE_ALifeInventoryItem*>(A); if(pSE_InventoryItem) pSE_InventoryItem->m_fCondition = f_cond; CSE_ALifeItemWeapon* W = smart_cast<CSE_ALifeItemWeapon*>(A); if (W) { if (W->m_scope_status == ALife::eAddonAttachable) W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonScope, bScope); if (W->m_silencer_status == ALife::eAddonAttachable) W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonSilencer, bSilencer); if (W->m_grenade_launcher_status == ALife::eAddonAttachable) W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher, bLauncher); } NET_Packet P; A->Spawn_Write (P,TRUE); Level().Send (P,net_flags(TRUE)); F_entity_Destroy (A); } } }
u32 _ParseItem(LPSTR src, int ind, xr_token* token_list) { char dst[128]; _GetItem(src, ind, dst); return _ParseItem(dst, token_list); }
void parse_anim_params(LPCSTR val, SAAParam &anim) { string16 cur_elem; _GetItem (val,0,cur_elem); anim.time = float(atof(cur_elem)); _GetItem (val,1,cur_elem); anim.hit_power = float(atof(cur_elem)); _GetItem (val,2,cur_elem); anim.impulse = float(atof(cur_elem)); _GetItem (val,3,cur_elem); anim.impulse_dir.x = float(atof(cur_elem)); _GetItem (val,4,cur_elem); anim.impulse_dir.y = float(atof(cur_elem)); _GetItem (val,5,cur_elem); anim.impulse_dir.z = float(atof(cur_elem)); _GetItem (val,6,cur_elem); anim.foh.from_yaw = float(atof(cur_elem)); _GetItem (val,7,cur_elem); anim.foh.to_yaw = float(atof(cur_elem)); _GetItem (val,8,cur_elem); anim.foh.from_pitch = float(atof(cur_elem)); _GetItem (val,9,cur_elem); anim.foh.to_pitch = float(atof(cur_elem)); _GetItem (val,10,cur_elem); anim.dist = float(atof(cur_elem)); anim.impulse_dir.normalize(); float clamp_val = PI_DIV_2 - EPS_L; clamp(anim.foh.from_yaw, -clamp_val, clamp_val); clamp(anim.foh.to_yaw, -clamp_val, clamp_val); clamp(anim.foh.from_pitch, -clamp_val, clamp_val); clamp(anim.foh.to_pitch, -clamp_val, clamp_val); }
void CInifileEx::Load(IReader* F, LPCSTR path) { R_ASSERT(F); Sect *Current = 0; string4096 str; string4096 str2; BOOL bInsideSTR = FALSE; while (!F->eof()) { F->r_string (str,sizeof(str)); _Trim (str); LPSTR comm = strchr(str,';'); LPSTR comm_1 = strchr(str,'/'); if(comm_1 && (*(comm_1+1)=='/') && ((!comm) || (comm && (comm_1<comm) )) ) { comm = comm_1; } #ifdef DEBUG LPSTR comment = 0; #endif if (comm) { //."bla-bla-bla;nah-nah-nah" char quot = '"'; bool in_quot = false; LPCSTR q1 = strchr(str,quot); if(q1 && q1<comm) { LPCSTR q2 = strchr(++q1,quot); if(q2 && q2>comm) in_quot = true; } if(!in_quot) { *comm = 0; #ifdef DEBUG comment = comm+1; #endif } } if (str[0] && (str[0]=='#') && strstr(str,"#include")) //handle includes { string_path inc_name; R_ASSERT (path&&path[0]); if (_GetItem (str,1,inc_name,'"')) { string_path fn,inc_path,folder; strconcat (sizeof(fn),fn,path,inc_name); _splitpath (fn,inc_path,folder, 0, 0 ); strcat (inc_path,folder); IReader* I = FS.r_open(fn); R_ASSERT3(I,"Can't find include file:", inc_name); Load (I,inc_path); FS.r_close (I); } } else if (str[0] && (str[0]=='[')) //new section ? { // insert previous filled section if (Current) { //store previous section RootIt I = std::lower_bound(DATA.begin(),DATA.end(),*Current->Name,sect_pred); if ((I!=DATA.end())&&((*I)->Name==Current->Name)) Debug.fatal(DEBUG_INFO,"Duplicate section '%s' found.",*Current->Name); DATA.insert (I,Current); } Current = xr_new<Sect>(); Current->Name = 0; // start new section R_ASSERT3(strchr(str,']'),"Bad ini section found: ",str); LPCSTR inherited_names = strstr(str,"]:"); if (0!=inherited_names) { VERIFY2 (m_flags.test(eReadOnly),"Allow for readonly mode only."); inherited_names += 2; int cnt = _GetItemCount(inherited_names); for (int k=0; k<cnt; ++k) { xr_string tmp; _GetItem (inherited_names,k,tmp); #ifdef DEBUG Current->base_sections.push_back(tmp.c_str()); #endif Sect& inherited_section = r_section(tmp.c_str()); for (SectIt_ it =inherited_section.Data.begin(); it!=inherited_section.Data.end(); it++) insert_item (Current,*it); } } *strchr(str,']') = 0; Current->Name = strlwr(str+1); } else // name = value { if (Current) { string4096 value_raw; char* name = str; char* t = strchr(name,'='); if (t) { *t = 0; _Trim (name); ++t; strcpy_s (value_raw, sizeof(value_raw), t); bInsideSTR = _parse(str2, value_raw); if(bInsideSTR)//multiline str value { while(bInsideSTR) { strcat_s (value_raw, sizeof(value_raw),"\r\n"); string4096 str_add_raw; F->r_string (str_add_raw, sizeof(str_add_raw)); R_ASSERT2 ( xr_strlen(value_raw) + xr_strlen(str_add_raw) < sizeof(value_raw), make_string( "Incorrect inifile format: section[%s], variable[%s]. Odd number of quotes (\") found, but should be even.", Current->Name.c_str(), name ) ); strcat_s (value_raw, sizeof(value_raw),str_add_raw); bInsideSTR = _parse(str2, value_raw); if(bInsideSTR) { if( is_empty_line_now(F) ) strcat_s (value_raw, sizeof(value_raw),"\r\n"); } } } } else { _Trim (name); str2[0] = 0; } Item I; I.first = (name[0]?name:NULL); I.second = (str2[0]?str2:NULL); #ifdef DEBUG I.comment = m_flags.test(eReadOnly)? comment : 0;//:comment; #endif if (m_flags.test(eReadOnly)) { if (*I.first) insert_item (Current,I); } else { if ( *I.first || *I.second #ifdef DEBUG || *I.comment #endif ) insert_item (Current,I); } } } } if (Current) { RootIt I = std::lower_bound(DATA.begin(),DATA.end(),*Current->Name,sect_pred); if ((I!=DATA.end())&&((*I)->Name==Current->Name)) Debug.fatal(DEBUG_INFO,"Duplicate section '%s' found.",*Current->Name); DATA.insert (I,Current); } }
void CSpaceRestriction::merge_free_in_retrictions () { START_PROFILE("Restricted Object/Merge Free In"); string256 temp; for (u32 i=0, n=_GetItemCount(*m_in_restrictions); i<n ;++i) { SpaceRestrictionHolder::CBaseRestrictionPtr bridge = m_space_restriction_manager->restriction(shared_str(_GetItem(*m_in_restrictions,i,temp))); m_free_in_restrictions.push_back (CFreeInRestriction(bridge,false)); } RESTRICTIONS temp_restrictions; for (bool ok = false; !ok; ) { ok = true; temp_restrictions.clear (); FREE_IN_RESTRICTIONS::iterator I = m_free_in_restrictions.begin(), J; FREE_IN_RESTRICTIONS::iterator E = m_free_in_restrictions.end(); for ( ; I != E; ++I) { for (J = I + 1; J != E; ++J) if (intersects((*I).m_restriction,(*J).m_restriction)) temp_restrictions.push_back ((*J).m_restriction); if (!temp_restrictions.empty()) { J = remove_if(m_free_in_restrictions.begin(),m_free_in_restrictions.end(),CRemoveMergedFreeInRestrictions(temp_restrictions)); m_free_in_restrictions.erase (J,m_free_in_restrictions.end()); (*I).m_restriction = merge((*I).m_restriction,temp_restrictions); ok = false; break; } } } STOP_PROFILE; }
// Retrieve item at specified slot; returns false if item not found ItemInst* Inventory::GetItem(int16 slot_id) const { ItemInst* result = nullptr; // Cursor if (slot_id == SLOT_CURSOR) { // Cursor slot result = m_cursor.peek_front(); } // Non bag slots else if (slot_id>=3000 && slot_id<=3007) { // Trade slots result = _GetItem(m_trade, slot_id); } else if (slot_id>=2500 && slot_id<=2501) { // Shared Bank slots result = _GetItem(m_shbank, slot_id); } else if (slot_id>=2000 && slot_id<=2023) { // Bank slots result = _GetItem(m_bank, slot_id); } else if ((slot_id>=22 && slot_id<=29)) { // Personal inventory slots result = _GetItem(m_inv, slot_id); } else if ((slot_id>=0 && slot_id<=21) || (slot_id >= 400 && slot_id<=404) || (slot_id == 9999)) { // Equippable slots (on body) result = _GetItem(m_worn, slot_id); } // Inner bag slots else if (slot_id>=3031 && slot_id<=3110) { // Trade bag slots ItemInst* inst = _GetItem(m_trade, Inventory::CalcSlotId(slot_id)); if (inst && inst->IsType(ItemClassContainer)) { result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); } } else if (slot_id>=2531 && slot_id<=2550) { // Shared Bank bag slots ItemInst* inst = _GetItem(m_shbank, Inventory::CalcSlotId(slot_id)); if (inst && inst->IsType(ItemClassContainer)) { result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); } } else if (slot_id>=2031 && slot_id<=2270) { // Bank bag slots ItemInst* inst = _GetItem(m_bank, Inventory::CalcSlotId(slot_id)); if (inst && inst->IsType(ItemClassContainer)) { result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); } } else if (slot_id>=331 && slot_id<=340) { // Cursor bag slots ItemInst* inst = m_cursor.peek_front(); if (inst && inst->IsType(ItemClassContainer)) { result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); } } else if (slot_id>=251 && slot_id<=330) { // Personal inventory bag slots ItemInst* inst = _GetItem(m_inv, Inventory::CalcSlotId(slot_id)); if (inst && inst->IsType(ItemClassContainer)) { result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); } } return result; }
void show_restriction (const shared_str &restrictions) { string256 temp; for (int i=0, n=_GetItemCount(*restrictions); i<n; ++i) Msg (" %s",_GetItem(*restrictions,i,temp)); }
void CSpaceRestrictionComposition::initialize () { u32 n = _GetItemCount(*m_space_restrictors); VERIFY (n); if (n == 1) { #ifdef DEBUG m_correct = true; check_restrictor_type (); #endif return; } string256 element; for (u32 i=0; i<n ;++i) if (!m_space_restriction_holder->restriction(_GetItem(*m_space_restrictors,i,element))->initialized()) return; Fsphere *spheres = (Fsphere*)_alloca(n*sizeof(Fsphere)); for (u32 i=0; i<n ;++i) { SpaceRestrictionHolder::CBaseRestrictionPtr restriction = m_space_restriction_holder->restriction( _GetItem( *m_space_restrictors, i, element ) ); merge (restriction); spheres[i] = restriction->sphere(); } // computing almost minimum sphere which covers all the almost minimum spheres Fbox3 temp; temp.min.x = spheres[0].P.x - spheres[0].R; temp.min.y = spheres[0].P.y - spheres[0].R; temp.min.z = spheres[0].P.z - spheres[0].R; temp.max.x = spheres[0].P.x + spheres[0].R; temp.max.y = spheres[0].P.y + spheres[0].R; temp.max.z = spheres[0].P.z + spheres[0].R; for (u32 i=1; i<n; ++i) { temp.min.x = _min(temp.min.x,spheres[i].P.x - spheres[i].R); temp.min.y = _min(temp.min.y,spheres[i].P.y - spheres[i].R); temp.min.z = _min(temp.min.z,spheres[i].P.z - spheres[i].R); temp.max.x = _max(temp.max.x,spheres[i].P.x + spheres[i].R); temp.max.y = _max(temp.max.y,spheres[i].P.y + spheres[i].R); temp.max.z = _max(temp.max.z,spheres[i].P.z + spheres[i].R); } m_sphere.P.mad (temp.min,temp.max,.5f); m_sphere.R = m_sphere.P.distance_to(spheres[0].P) + spheres[0].R; for (u32 i=1; i<n ;++i) m_sphere.R = _max(m_sphere.R,m_sphere.P.distance_to(spheres[i].P) + spheres[i].R); m_sphere.R += EPS_L; m_initialized = true; m_border.erase ( std::remove_if( m_border.begin(), m_border.end(), CMergePredicate(this) ), m_border.end() ); process_borders (); #ifdef DEBUG test_correctness (); #endif }
void CKinematicsAnimated::Load(const char* N, IReader *data, u32 dwFlags) { inherited::Load (N, data, dwFlags); // Globals blend_instances = NULL; m_Partition = NULL; Update_LastTime = 0; // Load animation if (data->find_chunk(OGF_S_MOTION_REFS)){ string_path items_nm; data->r_stringZ (items_nm,sizeof(items_nm)); u32 set_cnt = _GetItemCount(items_nm); R_ASSERT (set_cnt<MAX_ANIM_SLOT); m_Motions.reserve(set_cnt); string_path nm; for (u32 k=0; k<set_cnt; k++){ _GetItem (items_nm,k,nm); strcat (nm,".omf"); string_path fn; if (!FS.exist(fn, "$level$", nm)){ if (!FS.exist(fn, "$game_meshes$", nm)){ #ifdef _EDITOR Msg ("!Can't find motion file '%s'.",nm); return; #else Debug.fatal (DEBUG_INFO,"Can't find motion file '%s'.",nm); #endif } } // Check compatibility m_Motions.push_back (SMotionsSlot()); if( !g_pMotionsContainer->has(nm) ) //optimize fs operations { IReader* MS = FS.r_open(fn); m_Motions.back().motions.create (nm,MS,bones); FS.r_close (MS); } m_Motions.back().motions.create (nm,NULL,bones); } }else{ string_path nm; strconcat (sizeof(nm),nm,N,".ogf"); m_Motions.push_back(SMotionsSlot()); m_Motions.back().motions.create(nm,data,bones); } R_ASSERT (m_Motions.size()); m_Partition = m_Motions[0].motions.partition(); // initialize motions for (MotionsSlotVecIt m_it=m_Motions.begin(); m_it!=m_Motions.end(); m_it++){ SMotionsSlot& MS = *m_it; MS.bone_motions.resize(bones->size()); for (u32 i=0; i<bones->size(); i++){ CBoneData* BD = (*bones)[i]; MS.bone_motions[i] = MS.motions.bone_motions(BD->name); } } // Init blend pool IBlend_Startup (); //. if (motions.cycle()->size()<2) //. Msg("* WARNING: model '%s' has only one motion. Candidate for SkeletonRigid???",N); }
void CWeaponMagazined::Load (LPCSTR section) { inherited::Load (section); // Sounds HUD_SOUND::LoadSound(section,"snd_draw" , sndShow , m_eSoundShow ); HUD_SOUND::LoadSound(section,"snd_holster" , sndHide , m_eSoundHide ); HUD_SOUND::LoadSound(section,"snd_shoot" , sndShot , m_eSoundShot ); HUD_SOUND::LoadSound(section,"snd_empty" , sndEmptyClick , m_eSoundEmptyClick ); HUD_SOUND::LoadSound(section,"snd_reload" , sndReload , m_eSoundReload ); m_pSndShotCurrent = &sndShot; // HUD :: Anims R_ASSERT (m_pHUD); animGet (mhud.mhud_idle, pSettings->r_string(*hud_sect, "anim_idle")); animGet (mhud.mhud_reload, pSettings->r_string(*hud_sect, "anim_reload")); animGet (mhud.mhud_show, pSettings->r_string(*hud_sect, "anim_draw")); animGet (mhud.mhud_hide, pSettings->r_string(*hud_sect, "anim_holster")); animGet (mhud.mhud_shots, pSettings->r_string(*hud_sect, "anim_shoot")); if(pSettings->line_exist(*hud_sect,"anim_idle_sprint")) animGet (mhud.mhud_idle_sprint, pSettings->r_string(*hud_sect, "anim_idle_sprint")); if(IsZoomEnabled()) animGet (mhud.mhud_idle_aim, pSettings->r_string(*hud_sect, "anim_idle_aim")); //звуки и партиклы глушителя, еслит такой есть if(m_eSilencerStatus == ALife::eAddonAttachable) { if(pSettings->line_exist(section, "silencer_flame_particles")) m_sSilencerFlameParticles = pSettings->r_string(section, "silencer_flame_particles"); if(pSettings->line_exist(section, "silencer_smoke_particles")) m_sSilencerSmokeParticles = pSettings->r_string(section, "silencer_smoke_particles"); HUD_SOUND::LoadSound(section,"snd_silncer_shot", sndSilencerShot, m_eSoundShot); } // [7/20/2005] if (pSettings->line_exist(section, "dispersion_start")) m_iShootEffectorStart = pSettings->r_u8(section, "dispersion_start"); else m_iShootEffectorStart = 0; // [7/20/2005] // [7/21/2005] if (pSettings->line_exist(section, "fire_modes")) { m_bHasDifferentFireModes = true; shared_str FireModesList = pSettings->r_string(section, "fire_modes"); int ModesCount = _GetItemCount(FireModesList.c_str()); m_aFireModes.clear(); for (int i=0; i<ModesCount; i++) { string16 sItem; _GetItem(FireModesList.c_str(), i, sItem); int FireMode = atoi(sItem); m_aFireModes.push_back(FireMode); } m_iCurFireMode = ModesCount - 1; m_iPrefferedFireMode = READ_IF_EXISTS(pSettings, r_s16,section,"preffered_fire_mode",-1); } else m_bHasDifferentFireModes = false; // [7/21/2005] }
void CSE_ALifeAnomalousZone::spawn_artefacts () { VERIFY2 (!m_bOnline,"Cannot spawn artefacts in online!"); float m_min_start_power = pSettings->r_float(name(),"min_start_power"); float m_max_start_power = pSettings->r_float(name(),"max_start_power"); u32 m_min_artefact_count= pSettings->r_u32 (name(),"min_artefact_count");; u32 m_max_artefact_count= pSettings->r_u32 (name(),"max_artefact_count");; u32 m_artefact_count; if (m_min_artefact_count == m_max_artefact_count) m_artefact_count = m_min_artefact_count; else m_artefact_count = randI(m_min_artefact_count,m_max_artefact_count); if (m_min_start_power == m_max_start_power) m_maxPower = m_min_start_power; else m_maxPower = randF(m_min_start_power,m_max_start_power); LPCSTR artefacts = pSettings->r_string(name(),"artefacts"); u32 n = _GetItemCount(artefacts); VERIFY2 (!(n % 2),"Invalid parameters count in line artefacts for anomalous zone"); n >>= 1; typedef std::pair<shared_str,float> ARTEFACT_PAIR; string256 temp0, temp1; ARTEFACT_PAIR *m_weights = (ARTEFACT_PAIR*)_alloca(n*sizeof(ARTEFACT_PAIR)); ARTEFACT_PAIR *I = m_weights; ARTEFACT_PAIR *E = m_weights + n; for (u32 i = 0; I != E; ++I, ++i) { _GetItem (artefacts,2*i,temp0); _GetItem (artefacts,2*i + 1,temp1); new (I) ARTEFACT_PAIR(temp0,(float)atof(temp1)); } for (u32 ii=0; ii<m_artefact_count; ++ii) { float fProbability = randF(1.f); float fSum = 0.f; for (u16 p=0; p<n; ++p) { fSum += m_weights[p].second; if (fSum > fProbability) break; } if (p < n) { CSE_Abstract *l_tpSE_Abstract = alife().spawn_item(*m_weights[p].first,position(),m_tNodeID,m_tGraphID,0xffff); R_ASSERT3 (l_tpSE_Abstract,"Can't spawn artefact ",*m_weights[p].first); CSE_ALifeDynamicObject *i = smart_cast<CSE_ALifeDynamicObject*>(l_tpSE_Abstract); R_ASSERT2 (i,"Non-ALife object in the 'game.spawn'"); i->m_tSpawnID = m_tSpawnID; i->m_bALifeControl = true; ai().alife().spawns().assign_artefact_position(this,i); Fvector t = i->o_Position ; u32 p = i->m_tNodeID ; float q = i->m_fDistance ; alife().graph().change(i,m_tGraphID,i->m_tGraphID); i->o_Position = t; i->m_tNodeID = p; i->m_fDistance = q; CSE_ALifeItemArtefact *l_tpALifeItemArtefact = smart_cast<CSE_ALifeItemArtefact*>(i); R_ASSERT2 (l_tpALifeItemArtefact,"Anomalous zone can't generate non-artefact objects since they don't have an 'anomaly property'!"); l_tpALifeItemArtefact->m_fAnomalyValue = m_maxPower*(1.f - i->o_Position.distance_to(o_Position)/m_offline_interactive_radius); } } for (I = m_weights; I != E; ++I) I->~ARTEFACT_PAIR (); }
void CInifile::Load(IReader* F, LPCSTR path) { R_ASSERT(F); Sect *Current = 0; string4096 str; string4096 str2; while (!F->eof()) { F->r_string (str,sizeof(str)); _Trim (str); LPSTR semi = strchr(str,';'); LPSTR semi_1 = strchr(str,'/'); if(semi_1 && (*(semi_1+1)=='/') && ((!semi) || (semi && (semi_1<semi) )) ){ semi = semi_1; } #ifdef DEBUG LPSTR comment = 0; #endif if (semi) { *semi = 0; #ifdef DEBUG comment = semi+1; #endif } if (str[0] && (str[0]=='#') && strstr(str,"#include")){ string64 inc_name; R_ASSERT (path&&path[0]); if (_GetItem (str,1,inc_name,'"')){ string_path fn,inc_path,folder; strconcat (sizeof(fn),fn,path,inc_name); _splitpath (fn,inc_path,folder, 0, 0 ); strcat (inc_path,folder); IReader* I = FS.r_open(fn); R_ASSERT3(I,"Can't find include file:", inc_name); Load (I,inc_path); FS.r_close (I); } }else if (str[0] && (str[0]=='[')){ // insert previous filled section if (Current){ RootIt I = std::lower_bound(DATA.begin(),DATA.end(),*Current->Name,sect_pred); if ((I!=DATA.end())&&((*I)->Name==Current->Name)) Debug.fatal(DEBUG_INFO,"Duplicate section '%s' found.",*Current->Name); DATA.insert (I,Current); } Current = xr_new<Sect>(); Current->Name = 0; // start new section R_ASSERT3(strchr(str,']'),"Bad ini section found: ",str); LPCSTR inherited_names = strstr(str,"]:"); if (0!=inherited_names){ VERIFY2 (bReadOnly,"Allow for readonly mode only."); inherited_names += 2; int cnt = _GetItemCount(inherited_names); for (int k=0; k<cnt; ++k){ xr_string tmp; _GetItem (inherited_names,k,tmp); Sect& inherited_section = r_section(tmp.c_str()); for (SectIt_ it =inherited_section.Data.begin(); it!=inherited_section.Data.end(); it++) insert_item (Current,*it); } } *strchr(str,']') = 0; Current->Name = strlwr(str+1); } else { if (Current){ char* name = str; char* t = strchr(name,'='); if (t) { *t = 0; _Trim (name); _parse (str2,++t); } else { _Trim (name); str2[0] = 0; } Item I; I.first = (name[0]?name:NULL); I.second = (str2[0]?str2:NULL); #ifdef DEBUG I.comment = bReadOnly?0:comment; #endif if (bReadOnly) { if (*I.first) insert_item (Current,I); } else { if ( *I.first || *I.second #ifdef DEBUG || *I.comment #endif ) insert_item (Current,I); } } } } if (Current) { RootIt I = std::lower_bound(DATA.begin(),DATA.end(),*Current->Name,sect_pred); if ((I!=DATA.end())&&((*I)->Name==Current->Name)) Debug.fatal(DEBUG_INFO,"Duplicate section '%s' found.",*Current->Name); DATA.insert (I,Current); } }
void CInventoryItem::Load(LPCSTR section) { CHitImmunity::LoadImmunities (pSettings->r_string(section,"immunities_sect"),pSettings); ISpatial* self = smart_cast<ISpatial*> (this); if (self) self->spatial.type |= STYPE_VISIBLEFORAI; m_name = CStringTable().translate( pSettings->r_string(section, "inv_name") ); m_nameShort = CStringTable().translate( pSettings->r_string(section, "inv_name_short")); //. NameComplex (); m_weight = pSettings->r_float(section, "inv_weight"); R_ASSERT (m_weight>=0.f); m_cost = pSettings->r_u32(section, "cost"); #ifdef INV_NEW_SLOTS_SYSTEM const char *str = READ_IF_EXISTS(pSettings, r_string, section, "slot", ""); if (*str) { char buf[16]; const int count = _GetItemCount(str); if (count) m_slots.clear(); // full override! for (int i = 0; i < count; ++i) { SLOT_ID slot = atoi(_GetItem(str, i, buf) ); // вместо std::find(m_slots.begin(), m_slots.end(), slot) == m_slots.end() используется !IsPlaceable if (slot < SLOTS_TOTAL && !IsPlaceable(slot, slot)) m_slots.push_back(slot); } //init selected slots первым же слотом selected_slot = 0; } // alpet: разрешение некоторым объектам попадать в слоты быстрого доступа независимо от настроек if ( smart_cast<CEatableItem*>(&object()) && GetGridWidth () <= SLOT_QUICK_CELLS_X && GetGridHeight() <= SLOT_QUICK_CELLS_Y) { m_slots.push_back(SLOT_QUICK_ACCESS_0); m_slots.push_back(SLOT_QUICK_ACCESS_1); m_slots.push_back(SLOT_QUICK_ACCESS_2); m_slots.push_back(SLOT_QUICK_ACCESS_3); } #else m_slot = READ_IF_EXISTS(pSettings,r_u32,section,"slot", NO_ACTIVE_SLOT); #endif // Description if ( pSettings->line_exist(section, "description") ) m_Description = CStringTable().translate( pSettings->r_string(section, "description") ); m_flags.set(Fbelt, READ_IF_EXISTS(pSettings, r_bool, section, "belt", FALSE)); m_flags.set(FRuckDefault, READ_IF_EXISTS(pSettings, r_bool, section, "default_to_ruck", TRUE)); m_flags.set(FCanTake, READ_IF_EXISTS(pSettings, r_bool, section, "can_take", TRUE)); m_flags.set(FCanTrade, READ_IF_EXISTS(pSettings, r_bool, section, "can_trade", TRUE)); m_flags.set(FIsQuestItem, READ_IF_EXISTS(pSettings, r_bool, section, "quest_item", FALSE)); //время убирания объекта с уровня m_dwItemRemoveTime = READ_IF_EXISTS(pSettings, r_u32, section,"item_remove_time", ITEM_REMOVE_TIME); m_flags.set (FAllowSprint,READ_IF_EXISTS (pSettings, r_bool, section,"sprint_allowed", TRUE)); m_fControlInertionFactor = READ_IF_EXISTS(pSettings, r_float,section,"control_inertion_factor", 1.0f); m_icon_name = READ_IF_EXISTS(pSettings, r_string,section,"icon_name", NULL); }
bool CWeapon::install_upgrade_hit( LPCSTR section, bool test ) { bool result = false; shared_str s_sHitPower; bool result2 = process_if_exists_set( section, "hit_power", &CInifile::r_string_wb, s_sHitPower, test ); if ( result2 && !test ) { string32 buffer; fvHitPower[egdMaster] = (float)atof( _GetItem( *s_sHitPower, 0, buffer ) ); fvHitPower[egdNovice] = fvHitPower[egdStalker] = fvHitPower[egdVeteran] = fvHitPower[egdMaster]; int num_game_diff_param = _GetItemCount( *s_sHitPower ); if ( num_game_diff_param > 1 ) { fvHitPower[egdVeteran] = (float)atof( _GetItem( *s_sHitPower, 1, buffer ) ); } if ( num_game_diff_param > 2 ) { fvHitPower[egdStalker] = (float)atof( _GetItem( *s_sHitPower, 2, buffer ) ); } if ( num_game_diff_param > 3 ) { fvHitPower[egdNovice] = (float)atof( _GetItem( *s_sHitPower, 3, buffer ) ); } } result |= result2; shared_str s_sHitPowerCritical; result2 = process_if_exists_set( section, "hit_power_critical", &CInifile::r_string_wb, s_sHitPower, test ); if ( result2 && !test ) { string32 buffer; fvHitPowerCritical[egdMaster] = (float)atof(_GetItem(*s_sHitPowerCritical,0,buffer)); fvHitPowerCritical[egdNovice] = fvHitPowerCritical[egdStalker] = fvHitPowerCritical[egdVeteran] = fvHitPowerCritical[egdMaster]; int num_game_diff_param = _GetItemCount(*s_sHitPowerCritical); if ( num_game_diff_param > 1 ) { fvHitPowerCritical[egdVeteran] = (float)atof(_GetItem(*s_sHitPowerCritical,1,buffer)); } if ( num_game_diff_param > 2 ) { fvHitPowerCritical[egdStalker] = (float)atof(_GetItem(*s_sHitPowerCritical,2,buffer)); } if ( num_game_diff_param > 3 ) { fvHitPowerCritical[egdNovice] = (float)atof(_GetItem(*s_sHitPowerCritical,3,buffer)); } } result |= result2; result |= process_if_exists( section, "hit_impulse", &CInifile::r_float, fHitImpulse, test ); result |= process_if_exists( section, "bullet_speed", &CInifile::r_float, m_fStartBulletSpeed, test ); /* silencer_hit_power = 0.55, 0.55, 0.55, 0.55 silencer_hit_impulse = 120 silencer_fire_distance = 600 silencer_bullet_speed = 310 */ result |= process_if_exists_set( section, "use_aim_bullet", &CInifile::r_bool, m_bUseAimBullet, test ); if ( m_bUseAimBullet ) // first super bullet { result |= process_if_exists( section, "time_to_aim", &CInifile::r_float, m_fTimeToAim, test ); } LPCSTR weapon_section = cNameSect().c_str(); float rpm = pSettings->r_float( weapon_section, "rpm" ); // fOneShotTime * 60.0f; result2 = process_if_exists( section, "rpm", &CInifile::r_float, rpm, test ); if ( result2 && !test ) { VERIFY( rpm > 0.0f ); fOneShotTime = 60.0f / rpm; } result |= result2; return result; }
void CGameMtlLibrary::MtlNameToMtlPair (LPCSTR name, int& mtl0, int& mtl1) { string256 buf; SGameMtl* M0 = GetMaterial(_GetItem(name,0,buf,',')); R_ASSERT(M0); mtl0=M0->GetID(); SGameMtl* M1 = GetMaterial(_GetItem(name,1,buf,',')); R_ASSERT(M1); mtl1=M1->GetID(); }