void CActor::Die (CObject* who) { inherited::Die(who); //------------------------------------- if (OnServer()) { TISlotArr::iterator I = inventory().m_slots.begin(), B = I; TISlotArr::iterator E = inventory().m_slots.end(); for ( ; I != E; ++I) { if ((I - B) == (int)inventory().GetActiveSlot()) { if((*I).m_pIItem) { if (OnServer()) { if (GameID() == GAME_SINGLE) (*I).m_pIItem->Drop(); else { NET_Packet P; (*I).m_pIItem->object().u_EventGen(P, GE_OWNERSHIP_REJECT, (*I).m_pIItem->object().H_Parent()->ID()); P.w_u16(u16((*I).m_pIItem->object().ID())); (*I).m_pIItem->object().u_EventSend(P); } } }; } else { CCustomOutfit *pOutfit = smart_cast<CCustomOutfit *> ((*I).m_pIItem); if (pOutfit) continue; if((*I).m_pIItem) inventory().Ruck((*I).m_pIItem); }; }; ///!!! чистка пояса TIItemContainer &l_blist = inventory().m_belt; while (!l_blist.empty()) inventory().Ruck(l_blist.front()); if (OnServer() && GameID() != GAME_SINGLE) { // bool MedKitDropped = false; //if we are on server and actor has PDA - destroy PDA TIItemContainer &l_rlist = inventory().m_ruck; for(TIItemContainer::iterator l_it = l_rlist.begin(); l_rlist.end() != l_it; ++l_it) { if (GameID() == GAME_ARTEFACTHUNT) { CArtefact* pArtefact = smart_cast<CArtefact*> (*l_it); if (pArtefact) { (*l_it)->Drop(); continue; }; }; if ((*l_it)->object().CLS_ID == CLSID_OBJECT_PLAYERS_BAG) { (*l_it)->Drop(); continue; }; /* if ((*l_it)->object().CLS_ID == CLSID_IITEM_MEDKIT && !MedKitDropped) { MedKitDropped = true; (*l_it)->Drop(); continue; }; if ((*l_it)->object().CLS_ID == CLSID_DEVICE_PDA) { (*l_it)->Drop(); continue; }; CCustomOutfit *pOutfit = smart_cast<CCustomOutfit *> (*l_it); if (pOutfit) continue; //пока у нас нельзя обыскивать трупы, удаляем все объекты из инвентаря (*l_it)->object().DestroyObject(); */ }; }; }; cam_Set (eacFreeLook); mstate_wishful &= ~mcAnyMove; mstate_real &= ~mcAnyMove; if(!g_pGamePersistent->bDedicatedServer) { ::Sound->play_at_pos (sndDie[Random.randI(SND_DIE_COUNT)],this,Position()); m_HeavyBreathSnd.stop (); m_BloodSnd.stop (); } if(IsGameTypeSingle()) { start_tutorial ("game_over"); } //. HUD().GetUI()->UIGame()->AddCustomStatic("game_over", true); xr_delete (m_sndShockEffector); }
void global_slots_data::Free () { if ( dtFS ) xr_delete( dtFS ); recalculation_data.close(); }
CUICustomEdit::~CUICustomEdit() { xr_delete( m_editor_control ); }
void RELATION_REGISTRY::clear_relation_registry() { xr_delete(m_relation_registry); xr_delete(m_fight_registry); xr_delete(m_spot_names); }
//---------------------------------------------------- void CEditableObject::RemoveMesh(CEditableMesh* mesh){ EditMeshIt m_it = std::find(m_Meshes.begin(),m_Meshes.end(),mesh); VERIFY(m_it!=m_Meshes.end()); m_Meshes.erase(m_it); xr_delete(mesh); }
void game_sv_GameState::Create (shared_str &options) { string_path fn_game; m_item_respawner.clear_respawns(); if (FS.exist(fn_game, "$level$", "level.game")) { IReader *F = FS.r_open (fn_game); IReader *O = 0; // Load RPoints if (0!=(O = F->open_chunk (RPOINT_CHUNK))) { for (int id=0; O->find_chunk(id); ++id) { RPoint R; u8 team; u8 type; u16 GameType; shared_str rp_profile; O->r_fvector3 (R.P); O->r_fvector3 (R.A); team = O->r_u8 (); type = O->r_u8 (); GameType = O->r_u16 (); if(type==rptItemSpawn) O->r_stringZ (rp_profile); if (GameType != EGameIDs(u16(-1))) { if ((Type() == eGameIDCaptureTheArtefact) && (GameType & eGameIDCaptureTheArtefact)) { team = team - 1; R_ASSERT2( ((team >= 0) && (team < 4)) || (type != rptActorSpawn), "Problem with CTA Team indexes. Propably you have added rpoint of team 0 for cta game type."); } if ((!(GameType & eGameIDDeathmatch) && (Type() == eGameIDDeathmatch)) || (!(GameType & eGameIDTeamDeathmatch) && (Type() == eGameIDTeamDeathmatch)) || (!(GameType & eGameIDArtefactHunt) && (Type() == eGameIDArtefactHunt)) || (!(GameType & eGameIDCaptureTheArtefact) && (Type() == eGameIDCaptureTheArtefact)) ) { continue; }; }; switch (type) { case rptActorSpawn: { rpoints[team].push_back (R); for (int i=0; i<int(rpoints[team].size())-1; i++) { RPoint rp = rpoints[team][i]; float dist = R.P.distance_to_xz(rp.P)/2; if (dist<rpoints_MinDist[team]) rpoints_MinDist[team] = dist; dist = R.P.distance_to(rp.P)/2; if (dist<rpoints_Dist[team]) rpoints_Dist[team] = dist; }; }break; case rptItemSpawn: { m_item_respawner.add_new_rpoint(rp_profile, R); } }; }; O->close(); } FS.r_close (F); } if (!g_dedicated_server) { // loading scripts ai().script_engine().remove_script_process(ScriptEngine::eScriptProcessorGame); string_path S; FS.update_path (S,"$game_config$","script.ltx"); CInifile *l_tpIniFile = xr_new<CInifile>(S); R_ASSERT (l_tpIniFile); if( l_tpIniFile->section_exist( type_name() ) ) if (l_tpIniFile->r_string(type_name(),"script")) ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game",l_tpIniFile->r_string(type_name(),"script"))); else ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game","")); xr_delete (l_tpIniFile); } //--------------------------------------------------------------------- ConsoleCommands_Create(); //--------------------------------------------------------------------- // CCC_LoadCFG_custom* pTmp = xr_new<CCC_LoadCFG_custom>("sv_"); // pTmp->Execute (Console->ConfigFile); // xr_delete (pTmp); //--------------------------------------------------------------------- LPCSTR svcfg_ltx_name = "-svcfg "; if (strstr(Core.Params, svcfg_ltx_name)) { string_path svcfg_name = ""; int sz = xr_strlen(svcfg_ltx_name); sscanf (strstr(Core.Params,svcfg_ltx_name)+sz,"%[^ ] ",svcfg_name); // if (FS.exist(svcfg_name)) { Console->ExecuteScript(svcfg_name); } }; //--------------------------------------------------------------------- ReadOptions(options); }
void CBuild::BuildCForm () { // Collecting data Phase ("CFORM: creating..."); vecFace* cfFaces = new vecFace(); vecVertex* cfVertices = new vecVertex(); { xr_vector<bool> cfVertexMarks; cfVertexMarks.assign (lc_global_data()->g_vertices().size(),false); Status("Sorting..."); std::sort(lc_global_data()->g_vertices().begin(),lc_global_data()->g_vertices().end()); Status("Collecting faces..."); cfFaces->reserve (lc_global_data()->g_faces().size()); for (vecFaceIt I=lc_global_data()->g_faces().begin(); I!=lc_global_data()->g_faces().end(); ++I) { Face* F = *I; if (F->Shader().flags.bCollision) { cfFaces->push_back(F); int index = GetVertexIndex(F->v[0]); cfVertexMarks[index] = true; index = GetVertexIndex(F->v[1]); cfVertexMarks[index] = true; index = GetVertexIndex(F->v[2]); cfVertexMarks[index] = true; } } Status("Collecting vertices..."); cfVertices->reserve (lc_global_data()->g_vertices().size()); std::sort(cfFaces->begin(),cfFaces->end()); for (u32 V=0; V<lc_global_data()->g_vertices().size(); V++) if (cfVertexMarks[V]) cfVertices->push_back(lc_global_data()->g_vertices()[V]); } float p_total = 0; float p_cost = 1.f/(cfVertices->size()); Fbox BB; BB.invalidate(); for (vecVertexIt it = cfVertices->begin(); it!=cfVertices->end(); it++) BB.modify((*it)->P ); // CForm Phase ("CFORM: collision model..."); Status ("Items to process: %d", cfFaces->size()); p_total = 0; p_cost = 1.f/(cfFaces->size()); // Collect faces CDB::CollectorPacked CL (BB,cfVertices->size(),cfFaces->size()); for (vecFaceIt F = cfFaces->begin(); F!=cfFaces->end(); F++) { Face* T = *F; TestEdge (T->v[0],T->v[1],T); TestEdge (T->v[1],T->v[2],T); TestEdge (T->v[2],T->v[0],T); CL.add_face ( T->v[0]->P, T->v[1]->P, T->v[2]->P, T->dwMaterialGame, materials()[T->dwMaterial].sector, T->sm_group ); Progress(p_total+=p_cost); // progress } if (bCriticalErrCnt) { err_save (); clMsg ("MultipleEdges: %d faces",bCriticalErrCnt); } xr_delete (cfFaces); xr_delete (cfVertices); // Models Status ("Models..."); for (u32 ref=0; ref<mu_refs().size(); ref++) mu_refs()[ref]->export_cform_game(CL); // Simplification if (g_params().m_quality!=ebqDraft) SimplifyCFORM (CL); // bb? BB.invalidate (); for (size_t it = 0; it<CL.getVS(); it++) BB.modify( CL.getV()[it] ); // Saving string_path fn; IWriter* MFS = FS.w_open (strconcat(sizeof(fn),fn,pBuild->path,"level.cform")); Status ("Saving..."); // Header hdrCFORM hdr; hdr.version = CFORM_CURRENT_VERSION; hdr.vertcount = (u32)CL.getVS(); hdr.facecount = (u32)CL.getTS(); hdr.aabb = BB; MFS->w (&hdr,sizeof(hdr)); // Data MFS->w (CL.getV(),(u32)CL.getVS()*sizeof(Fvector)); MFS->w (CL.getT(),(u32)CL.getTS()*sizeof(CDB::TRI)); // Clear pDeflector (it is stored in the same memory space with dwMaterialGame) for (vecFaceIt I=lc_global_data()->g_faces().begin(); I!=lc_global_data()->g_faces().end(); I++) { Face* F = *I; F->pDeflector = NULL; } FS.w_close (MFS); }
CUIGameAHunt::~CUIGameAHunt() { xr_delete(m_pReinforcementInidcator); delete_data(m_pBuySpawnMsgBox); }
void CBuild::Flex2OGF() { float p_total = 0; float p_cost = 1/float(g_XSplit.size()); validate_splits (); g_tree.clear (); g_tree.reserve (4096); for (splitIt it=g_XSplit.begin(); it!=g_XSplit.end(); it++) { R_ASSERT ( ! (*it)->empty() ); u32 MODEL_ID = u32(it-g_XSplit.begin()); OGF* pOGF = new OGF(); Face* F = *((*it)->begin()); // first face b_material* M = &(materials()[F->dwMaterial]); // and it's material R_ASSERT (F && M); try { // Common data pOGF->Sector = M->sector; pOGF->material = F->dwMaterial; // Collect textures OGF_Texture T; //pOGF->shader = M->shader; //pOGF->shader_xrlc = &F->Shader(); TRY(T.name = textures()[M->surfidx].name); TRY(T.pSurface = &(textures()[M->surfidx])); TRY(pOGF->textures.push_back(T)); try { if (F->hasImplicitLighting()) { // specific lmap string_path tn; strconcat (sizeof(tn),tn,*T.name,"_lm.dds"); T.name = tn; T.pSurface = T.pSurface; // Leave surface intact R_ASSERT (pOGF); pOGF->textures.push_back(T); } else { // If lightmaps persist CLightmap* LM = F->lmap_layer; if (LM) { string_path fn; sprintf_s (fn,"%s_1",LM->lm_texture.name); T.name = fn; T.pSurface = &(LM->lm_texture); R_ASSERT (T.pSurface); R_ASSERT (pOGF); pOGF->textures.push_back(T); //. sprintf (fn,"%s_2",LM->lm_texture.name); T.name = fn; pOGF->textures.push_back(T); } } } catch (...) { clMsg("* ERROR: Flex2OGF, model# %d, *textures*",MODEL_ID); } // Collect faces & vertices F->CacheOpacity (); bool _tc_ = !(F->flags.bOpaque); try { BuildOGFGeom( *pOGF, *(*it), _tc_ ); } catch (...) { clMsg("* ERROR: Flex2OGF, model# %d, *faces*",MODEL_ID); } } catch (...) { clMsg("* ERROR: Flex2OGF, 1st part, model# %d",MODEL_ID); } try { clMsg ("%3d: opt : v(%d)-f(%d)", MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size()); pOGF->Optimize (); clMsg ("%3d: cb : v(%d)-f(%d)", MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size()); pOGF->CalcBounds (); clMsg ("%3d: prog: v(%d)-f(%d)", MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size()); if (!b_noise) pOGF->MakeProgressive (c_PM_MetricLimit_static); clMsg ("%3d: strp: v(%d)-f(%d)", MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size()); pOGF->Stripify (); } catch (...) { clMsg("* ERROR: Flex2OGF, 2nd part, model# %d",MODEL_ID); } g_tree.push_back (pOGF); xr_delete (*it); Progress (p_total+=p_cost); } g_XSplit.clear (); }
void dDestroyTriList(dGeomID g){ xr_delete(((dxTriList*)dGeomGetClassData(g))->Collider); }
void phcapture_destroy(IPHCapture* &c) { CPHCapture* capture = smart_cast<CPHCapture*>(c); xr_delete(capture); c = 0; }
void Startup(LPSTR lpCmdLine) { char cmd[512],name[256]; BOOL bModifyOptions = FALSE; strcpy(cmd,lpCmdLine); strlwr(cmd); if (strstr(cmd,"-?") || strstr(cmd,"-h")) { Help(); return; } if (strstr(cmd,"-f")==0) { Help(); return; } if (strstr(cmd,"-o")) bModifyOptions = TRUE; if (strstr(cmd,"-gi")) b_radiosity = TRUE; if (strstr(cmd,"-noise")) b_noise = TRUE; if (strstr(cmd,"-nosun")) b_nosun = TRUE; // Give a LOG-thread a chance to startup //_set_sbh_threshold(1920); InitCommonControls (); thread_spawn (logThread, "log-update", 1024*1024,0); Sleep (150); // Faster FPU SetPriorityClass (GetCurrentProcess(),NORMAL_PRIORITY_CLASS); /* u32 dwMin = 1800*(1024*1024); u32 dwMax = 1900*(1024*1024); if (0==SetProcessWorkingSetSize(GetCurrentProcess(),dwMin,dwMax)) { clMsg("*** Failed to expand working set"); }; */ // Load project name[0]=0; sscanf(strstr(cmd,"-f")+2,"%s",name); string256 prjName; FS.update_path (prjName,"$game_levels$",strconcat(prjName,name,"\\build.prj")); string256 phaseName; Phase (strconcat(phaseName,"Reading project [",name,"]...")); string256 inf; extern HWND logWindow; IReader* F = FS.r_open(prjName); if (NULL==F){ sprintf (inf,"Build failed!\nCan't find level: '%s'",name); clMsg (inf); MessageBox (logWindow,inf,"Error!",MB_OK|MB_ICONERROR); return; } // Version u32 version; F->r_chunk (EB_Version,&version); clMsg ("version: %d",version); R_ASSERT(XRCL_CURRENT_VERSION==version); // Header b_params Params; F->r_chunk (EB_Parameters,&Params); // Show options if needed if (bModifyOptions) { Phase ("Project options..."); HMODULE L = LoadLibrary ("xrLC_Options.dll"); void* P = GetProcAddress (L,"_frmScenePropertiesRun"); R_ASSERT (P); xrOptions* O = (xrOptions*)P; int R = O(&Params,version,false); FreeLibrary (L); if (R==2) { ExitProcess(0); } } // Conversion Phase ("Converting data structures..."); pBuild = xr_new<CBuild>(); pBuild->Load (Params,*F); xr_delete (F); // Call for builder string256 lfn; CTimer dwStartupTime; dwStartupTime.Start(); FS.update_path (lfn,_game_levels_,name); pBuild->Run (lfn); xr_delete (pBuild); // Show statistic extern std::string make_time(u32 sec); u32 dwEndTime = dwStartupTime.GetElapsed_ms(); sprintf (inf,"Time elapsed: %s",make_time(dwEndTime/1000).c_str()); clMsg ("Build succesful!\n%s",inf); MessageBox (logWindow,inf,"Congratulation!",MB_OK|MB_ICONINFORMATION); // Close log bClose = TRUE; Sleep (500); }
//-------------------------------------------------------------------- CHUDManager::~CHUDManager() { xr_delete (pUI); xr_delete (m_pHUDTarget); b_online = false; }
void CActor::UpdateCL () { if(m_feel_touch_characters>0) { for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++) { CPhysicsShellHolder *sh = smart_cast<CPhysicsShellHolder*>(*it); if(sh&&sh->character_physics_support()) { sh->character_physics_support()->movement()->UpdateObjectBox(character_physics_support()->movement()->PHCharacter()); } } } if(m_holder) m_holder->UpdateEx( currentFOV() ); m_snd_noise -= 0.3f*Device.fTimeDelta; VERIFY2 (_valid(renderable.xform),*cName()); inherited::UpdateCL(); VERIFY2 (_valid(renderable.xform),*cName()); m_pPhysics_support->in_UpdateCL (); VERIFY2 (_valid(renderable.xform),*cName()); if (g_Alive()) PickupModeUpdate (); PickupModeUpdate_COD(); m_bZoomAimingMode = false; CWeapon* pWeapon = smart_cast<CWeapon*>(inventory().ActiveItem()); Device.Statistic->TEST1.Begin (); cam_Update(float(Device.dwTimeDelta)/1000.0f, currentFOV()); Device.Statistic->TEST1.End (); if(Level().CurrentEntity() && this->ID()==Level().CurrentEntity()->ID() ) { psHUD_Flags.set( HUD_CROSSHAIR_RT2, true ); psHUD_Flags.set( HUD_DRAW_RT, true ); } if(pWeapon ) { if(pWeapon->IsZoomed()) { float full_fire_disp = pWeapon->GetFireDispersion(true); CEffectorZoomInertion* S = smart_cast<CEffectorZoomInertion*> (Cameras().GetCamEffector(eCEZoom)); if(S) S->SetParams(full_fire_disp); m_bZoomAimingMode = true; } if(Level().CurrentEntity() && this->ID()==Level().CurrentEntity()->ID() ) { float fire_disp_full = pWeapon->GetFireDispersion(true); HUD().SetCrosshairDisp(fire_disp_full, 0.02f); HUD().ShowCrosshair(pWeapon->use_crosshair()); psHUD_Flags.set( HUD_CROSSHAIR_RT2, pWeapon->show_crosshair() ); psHUD_Flags.set( HUD_DRAW_RT, pWeapon->show_indicators() ); } } else { if(Level().CurrentEntity() && this->ID()==Level().CurrentEntity()->ID() ) { HUD().SetCrosshairDisp(0.f); HUD().ShowCrosshair(false); } } UpdateDefferedMessages(); if (g_Alive()) CStepManager::update(); spatial.type |=STYPE_REACTTOSOUND; if(m_sndShockEffector) { if (this == Level().CurrentViewEntity()) { m_sndShockEffector->Update(); if(!m_sndShockEffector->InWork()) xr_delete(m_sndShockEffector); } else xr_delete(m_sndShockEffector); } }
CUIEditBoxEx::~CUIEditBoxEx() { xr_delete(m_pFrameWindow); }
CObjectHandler::~CObjectHandler () { xr_delete (m_planner); }
void CBuild::xrPhase_ResolveMaterials() { // Count number of materials Status ("Calculating materials/subdivs..."); xr_vector<_counter> counts; { counts.reserve (256); for (vecFaceIt F_it=g_faces.begin(); F_it!=g_faces.end(); F_it++) { Face* F = *F_it; BOOL bCreate = TRUE; for (u32 I=0; I<counts.size(); I++) { if (F->dwMaterial == counts[I].dwMaterial) { counts[I].dwCount += 1; bCreate = FALSE; break; } } if (bCreate) { _counter C; C.dwMaterial = F->dwMaterial; C.dwCount = 1; counts.push_back(C); } Progress(float(F_it-g_faces.begin())/float(g_faces.size())); } } Status ("Perfroming subdivisions..."); { g_XSplit.reserve(64*1024); g_XSplit.resize (counts.size()); for (u32 I=0; I<counts.size(); I++) { g_XSplit[I] = xr_new<vecFace> (); g_XSplit[I]->reserve (counts[I].dwCount); } for (vecFaceIt F_it=g_faces.begin(); F_it!=g_faces.end(); F_it++) { Face* F = *F_it; if (!F->Shader().flags.bRendering) continue; for (u32 I=0; I<counts.size(); I++) { if (F->dwMaterial == counts[I].dwMaterial) { g_XSplit[I]->push_back (F); } } Progress(float(F_it-g_faces.begin())/float(g_faces.size())); } } Status ("Removing empty subdivs..."); { for (int SP = 0; SP<int(g_XSplit.size()); SP++) if (g_XSplit[SP]->empty()) xr_delete(g_XSplit[SP]); g_XSplit.erase(std::remove(g_XSplit.begin(),g_XSplit.end(),(vecFace*) NULL),g_XSplit.end()); } Status ("Detaching subdivs..."); { for (u32 it=0; it<g_XSplit.size(); it++) { Detach(g_XSplit[it]); } } clMsg ("%d subdivisions.",g_XSplit.size()); }
void destroy_lua_wpn_params() { if(g_lua_wpn_params) xr_delete(g_lua_wpn_params); }
void CBuild::xrPhase_UVmap() { // Main loop Status ("Processing..."); lc_global_data()->g_deflectors().reserve (64*1024); float p_cost = 1.f / float(g_XSplit.size()); float p_total = 0.f; vecFace faces_affected; for (int SP = 0; SP<int(g_XSplit.size()); SP++) { Progress (p_total+=p_cost); // ManOwaR, unsure: // Call to IsolateVertices() looks useless here // Calculation speed up, so commented // IsolateVertices (FALSE); // Detect vertex-lighting and avoid this subdivision R_ASSERT (!g_XSplit[SP]->empty()); Face* Fvl = g_XSplit[SP]->front(); if (Fvl->Shader().flags.bLIGHT_Vertex) continue; // do-not touch (skip) if (!Fvl->Shader().flags.bRendering) continue; // do-not touch (skip) if (Fvl->hasImplicitLighting()) continue; // do-not touch (skip) // find first poly that doesn't has mapping and start recursion while (TRUE) { // Select maximal sized poly Face * msF = NULL; float msA = 0; for (vecFaceIt it = g_XSplit[SP]->begin(); it!=g_XSplit[SP]->end(); it++) { if ( (*it)->pDeflector == NULL ) { float a = (*it)->CalcArea(); if (a>msA) { msF = (*it); msA = a; } } } if (msF) { CDeflector *D = xr_new<CDeflector>(); lc_global_data()->g_deflectors().push_back (D); // Start recursion from this face start_unwarp_recursion(); D->OA_SetNormal (msF->N); msF->OA_Unwarp (D); //Deflector = D; // break the cycle to startup again D->OA_Export (); // Detach affected faces faces_affected.clear (); for (int i=0; i<int(g_XSplit[SP]->size()); i++) { Face *F = (*g_XSplit[SP])[i]; if ( F->pDeflector == D ) { faces_affected.push_back(F); g_XSplit[SP]->erase (g_XSplit[SP]->begin()+i); i--; } } // detaching itself Detach (&faces_affected); g_XSplit.push_back (xr_new<vecFace> (faces_affected)); } else { if (g_XSplit[SP]->empty()) { xr_delete (g_XSplit[SP]); g_XSplit.erase (g_XSplit.begin()+SP); SP--; } // Cancel infine loop (while) break; } } } clMsg("%d subdivisions...",g_XSplit.size()); err_save (); }
void xrCompressor::ProcessLTX(CInifile& ltx) { config_ltx =<x; if (ltx.line_exist("options","exclude_exts")) _SequenceToList(exclude_exts, ltx.r_string("options","exclude_exts")); files_list = xr_new< xr_vector<char*> >(); folders_list = xr_new< xr_vector<char*> >(); if(ltx.section_exist("include_folders")) { CInifile::Sect& if_sect = ltx.r_section("include_folders"); for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); ++if_it) { BOOL ifRecurse = CInifile::IsBOOL(if_it->second.c_str()); u32 folder_mask = FS_ListFolders | (ifRecurse?0:FS_RootOnly); string_path path; LPCSTR _path = 0==xr_strcmp(if_it->first.c_str(),".\\")?"":if_it->first.c_str(); xr_strcpy (path,_path); u32 path_len = xr_strlen(path); if ((0!=path_len)&&(path[path_len-1]!='\\')) xr_strcat(path,"\\"); Msg (""); Msg ("Processing folder: '%s'",path); BOOL efRecurse; BOOL val = IsFolderAccepted(ltx,path,efRecurse); if (val || (!val&&!efRecurse)) { if (val) GatherFiles (path); xr_vector<char*>* i_fl_list = FS.file_list_open ("$target_folder$",path,folder_mask); if (!i_fl_list) { Msg ("ERROR: Unable to open folder list:", path); continue; } xr_vector<char*>::iterator it = i_fl_list->begin(); xr_vector<char*>::iterator itE = i_fl_list->end(); for (;it!=itE;++it) { xr_string tmp_path = xr_string(path)+xr_string(*it); bool val = IsFolderAccepted(ltx,tmp_path.c_str(),efRecurse); if (val) { folders_list->push_back(xr_strdup(tmp_path.c_str())); Msg ("+F: %s",tmp_path.c_str()); // collect files if (ifRecurse) GatherFiles (tmp_path.c_str()); }else { Msg ("-F: %s",tmp_path.c_str()); } } FS.file_list_close (i_fl_list); }else { Msg ("-F: %s",path); } } }//if(ltx.section_exist("include_folders")) if(ltx.section_exist("include_files")) { CInifile::Sect& if_sect = ltx.r_section("include_files"); for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); ++if_it) { files_list->push_back (xr_strdup(if_it->first.c_str())); } } PerformWork (); // free xr_vector<char*>::iterator it = files_list->begin(); xr_vector<char*>::iterator itE = files_list->end(); for (;it!=itE;++it) xr_free(*it); xr_delete(files_list); it = folders_list->begin(); itE = folders_list->end(); for (;it!=itE;++it) xr_free(*it); xr_delete(folders_list); exclude_exts.clear_and_free(); }
void CUILines::ParseText() { if ( !fsimilar(m_oldWidth, m_wndSize.x) ) { uFlags.set(flNeedReparse, TRUE); m_oldWidth = m_wndSize.x; } if (!uFlags.test(flComplexMode) || !uFlags.test(flNeedReparse)) return; if(NULL == m_pFont) return; Reset(); if (!m_text.empty() && NULL == m_pFont) R_ASSERT2(false, "can't parse text without font"); CUILine* line = NULL; if (uFlags.test(flColoringMode)) line = ParseTextToColoredLine(m_text.c_str()); else { line = xr_new<CUILine>(); CUISubLine subline; subline.m_text = m_text; subline.m_color = GetTextColor(); line->AddSubLine(&subline); } BOOL bNewLines = FALSE; if (uFlags.test(flRecognizeNewLine)) if ( m_pFont->IsMultibyte() ) { CUILine *ptmp_line = xr_new<CUILine>(); int vsz = line->m_subLines.size(); VERIFY( vsz ); for ( int i = 0 ; i < vsz ; i++ ) { char *pszTemp = NULL; const u32 tcolor = line->m_subLines[i].m_color; char szTempLine[ MAX_MB_CHARS ] , *pszSearch = NULL; size_t llen = xr_strlen( line->m_subLines[i].m_text.c_str() ); VERIFY( llen < MAX_MB_CHARS ); strcpy( szTempLine , line->m_subLines[i].m_text.c_str() ); pszSearch = szTempLine; while ( ( pszTemp = strstr( pszSearch , "\\n" ) ) != NULL ) { bNewLines = TRUE; *pszTemp = '\0'; ptmp_line->AddSubLine( pszSearch , tcolor ); pszSearch = pszTemp + 2; } ptmp_line->AddSubLine( pszSearch , tcolor ); } line->Clear(); xr_free( line ); line=ptmp_line; } else line->ProcessNewLines(); // process "\n" if ( m_pFont->IsMultibyte() ) { #define UBUFFER_SIZE 100 u16 aMarkers[ UBUFFER_SIZE ]; CUILine tmp_line; char szTempLine[ MAX_MB_CHARS ]; float fTargetWidth = 1.0f; UI()->ClientToScreenScaledWidth( fTargetWidth ); VERIFY( ( m_wndSize.x > 0 ) && ( fTargetWidth > 0 ) ); fTargetWidth = m_wndSize.x / fTargetWidth; int vsz = line->m_subLines.size(); VERIFY( vsz ); if ( ( vsz > 1 ) && ( ! bNewLines ) ) { // only colored line, pizdets for ( int i = 0 ; i < vsz ; i++ ) { const char *pszText = line->m_subLines[i].m_text.c_str(); const u32 tcolor = line->m_subLines[i].m_color; VERIFY( pszText ); tmp_line.AddSubLine( pszText , tcolor ); } m_lines.push_back( tmp_line ); tmp_line.Clear(); } else { for ( int i = 0 ; i < vsz ; i++ ) { const char *pszText = line->m_subLines[i].m_text.c_str(); const u32 tcolor = line->m_subLines[i].m_color; u16 uFrom = 0 , uPartLen = 0; VERIFY( pszText ); u16 nMarkers = m_pFont->SplitByWidth( aMarkers , UBUFFER_SIZE , fTargetWidth , pszText ); for ( u16 j = 0 ; j < nMarkers ; j ++ ) { uPartLen = aMarkers[ j ] - uFrom; VERIFY( ( uPartLen > 0 ) && ( uPartLen < MAX_MB_CHARS ) ); strncpy( szTempLine , pszText + uFrom , uPartLen ); szTempLine[ uPartLen ] = '\0'; tmp_line.AddSubLine( szTempLine , tcolor ); m_lines.push_back( tmp_line ); tmp_line.Clear(); // Compiler bug :) #pragma warning( disable : 4244 ) uFrom += uPartLen; #pragma warning( default : 4244 ) } strncpy( szTempLine , pszText + uFrom , MAX_MB_CHARS ); tmp_line.AddSubLine( szTempLine , tcolor ); m_lines.push_back( tmp_line ); tmp_line.Clear(); } } } else { float max_width = m_wndSize.x; u32 sbl_cnt = line->m_subLines.size(); CUILine tmp_line; string4096 buff; float curr_width = 0.0f; bool bnew_line = false; float __eps = get_str_width(m_pFont,'o');//hack -( for(u32 sbl_idx=0; sbl_idx<sbl_cnt; ++sbl_idx) { bool b_last_subl = (sbl_idx==sbl_cnt-1); CUISubLine& sbl = line->m_subLines[sbl_idx]; //. Msg("%s",sbl.m_text.c_str()); u32 sub_len = (u32)sbl.m_text.length(); u32 curr_w_pos = 0; u32 last_space_idx = 0; for(u32 idx=0; idx<sub_len; ++idx) { bool b_last_ch = (idx==sub_len-1); if(isspace(sbl.m_text[idx])) last_space_idx = idx; float w1 = get_str_width(m_pFont, sbl.m_text[idx]); bool bOver = (curr_width+w1+__eps > max_width); if(bOver || b_last_ch) { if(last_space_idx && !b_last_ch) { idx = last_space_idx; last_space_idx = 0; } strncpy_s (buff, sizeof(buff), sbl.m_text.c_str()+curr_w_pos, idx-curr_w_pos+1); //. Msg ("-%s",buff); tmp_line.AddSubLine (buff , sbl.m_color); curr_w_pos = idx+1; } else curr_width += w1; if(bOver || (b_last_ch&&sbl.m_last_in_line) ) { m_lines.push_back (tmp_line); tmp_line.Clear (); curr_width = 0.0f; bnew_line = false; } } if(b_last_subl && !tmp_line.IsEmpty()) { m_lines.push_back (tmp_line); tmp_line.Clear (); curr_width = 0.0f; bnew_line = false; } } } //. while (line->GetSize() > 0 ) //. m_lines.push_back(*line->CutByLength(m_pFont, m_wndSize.x, uFlags.test(flCutWordsMode))); xr_delete(line); uFlags.set(flNeedReparse, FALSE); }
/* bool CEditableObject::LoadSMotions(const char* fname) { IReader* F = FS.r_open(fname); ClearSMotions(); // object motions m_SMotions.resize(F->r_u32()); SetActiveSMotion(0); for (SMotionIt m_it=m_SMotions.begin(); m_it!=m_SMotions.end(); m_it++){ *m_it = xr_new<CSMotion>(); if (!(*m_it)->Load(*F)){ ELog.DlgMsg(mtError,"Motions has different version. Load failed."); xr_delete(*m_it); m_SMotions.clear(); FS.r_close(F); return false; } if (!CheckBoneCompliance(*m_it)){ ClearSMotions(); ELog.DlgMsg(mtError,"Load failed.",fname); xr_delete(&*m_it); FS.r_close(F); return false; } } FS.r_close(F); return true; } */ bool CEditableObject::AppendSMotion(LPCSTR fname, SMotionVec* inserted) { VERIFY(IsSkeleton()); bool bRes = true; LPCSTR ext = strext(fname); if (0==stricmp(ext,".skl")){ CSMotion* M = xr_new<CSMotion>(); if (!M->LoadMotion(fname)){ ELog.Msg(mtError,"Motion '%s' can't load. Append failed.",fname); xr_delete(M); bRes = false; }else{ string256 name; _splitpath(fname,0,0,name,0); if (CheckBoneCompliance(M)){ M->SortBonesBySkeleton(m_Bones); string256 m_name; GenerateSMotionName (m_name,name,M); M->SetName (m_name); m_SMotions.push_back(M); if (inserted) inserted->push_back(M); // optimize M->Optimize (); }else{ ELog.Msg(mtError,"Append failed.",fname); xr_delete(M); bRes = false; } } }else if (0==stricmp(ext,".skls")){ IReader* F = FS.r_open(fname); if (!F){ ELog.Msg(mtError,"Can't open file '%s'.",fname); bRes = false; } if (bRes){ // object motions int cnt = F->r_u32(); for (int k=0; k<cnt; k++){ CSMotion* M = xr_new<CSMotion>(); if (!M->Load(*F)){ ELog.Msg(mtError,"Motion '%s' has different version. Load failed.",M->Name()); xr_delete(M); bRes = false; break; } if (!CheckBoneCompliance(M)){ xr_delete(M); bRes = false; break; } if (bRes){ M->SortBonesBySkeleton(m_Bones); string256 m_name; GenerateSMotionName (m_name,M->Name(),M); M->SetName (m_name); m_SMotions.push_back(M); if (inserted) inserted->push_back(M); // optimize M->Optimize (); } } } FS.r_close(F); } return bRes; }
void CBuild::PreOptimize() { // We use overlapping hash table to avoid boundary conflicts vecVertex* HASH [HDIM_X+1][HDIM_Y+1][HDIM_Z+1]; Fvector VMmin, VMscale, VMeps, scale; // Calculate offset,scale,epsilon Fbox bb = scene_bb; VMscale.set (bb.max.x-bb.min.x, bb.max.y-bb.min.y, bb.max.z-bb.min.z); VMmin.set (bb.min); VMeps.set (VMscale.x/HDIM_X/2,VMscale.y/HDIM_Y/2,VMscale.z/HDIM_Z/2); VMeps.x = (VMeps.x<EPS_L)?VMeps.x:EPS_L; VMeps.y = (VMeps.y<EPS_L)?VMeps.y:EPS_L; VMeps.z = (VMeps.z<EPS_L)?VMeps.z:EPS_L; scale.set (float(HDIM_X),float(HDIM_Y),float(HDIM_Z)); scale.div (VMscale); u32 Vcount = lc_global_data()->g_vertices().size(), Vremoved=0; u32 Fcount = lc_global_data()->g_faces().size(), Fremoved=0; // Pre-alloc memory int _size = (HDIM_X+1)*(HDIM_Y+1)*(HDIM_Z+1); int _average= (Vcount/_size)/2; if (_average<2) _average = 2; { for (int ix=0; ix<HDIM_X+1; ix++) for (int iy=0; iy<HDIM_Y+1; iy++) for (int iz=0; iz<HDIM_Z+1; iz++) { HASH[ix][iy][iz] = xr_new<vecVertex> (); HASH[ix][iy][iz]->reserve (_average); } } // Status("Processing..."); g_bUnregister = false; for (int it = 0; it<(int)lc_global_data()->g_vertices().size(); it++) { if (0==(it%100000)) { Progress(_sqrt(float(it)/float(lc_global_data()->g_vertices().size()))); Status ("Processing... (%d verts removed)",Vremoved); } if (it>=(int)lc_global_data()->g_vertices().size()) break; Vertex *pTest = lc_global_data()->g_vertices()[it]; Fvector &V = pTest->P; // Hash u32 ix,iy,iz; ix = iFloor ((V.x-VMmin.x)*scale.x); iy = iFloor ((V.y-VMmin.y)*scale.y); iz = iFloor ((V.z-VMmin.z)*scale.z); R_ASSERT (ix<=HDIM_X && iy<=HDIM_Y && iz<=HDIM_Z); vecVertex &H = *(HASH[ix][iy][iz]); // Search similar vertices in hash table for (vecVertexIt T=H.begin(); T!=H.end(); T++) { Vertex *pBase = *T; if (pBase->similar(*pTest,g_params().m_weld_distance)) { while(pTest->m_adjacents.size()) pTest->m_adjacents.front()->VReplace(pTest, pBase); lc_global_data()->destroy_vertex(lc_global_data()->g_vertices()[it]); Vremoved += 1; pTest = NULL; break; } } // If we get here - there is no similar vertices - register in hash tables if (pTest) { H.push_back (pTest); u32 ixE,iyE,izE; ixE = iFloor((V.x+VMeps.x-VMmin.x)*scale.x); iyE = iFloor((V.y+VMeps.y-VMmin.y)*scale.y); izE = iFloor((V.z+VMeps.z-VMmin.z)*scale.z); R_ASSERT(ixE<=HDIM_X && iyE<=HDIM_Y && izE<=HDIM_Z); if (ixE!=ix) HASH[ixE][iy][iz]->push_back (pTest); if (iyE!=iy) HASH[ix][iyE][iz]->push_back (pTest); if (izE!=iz) HASH[ix][iy][izE]->push_back (pTest); if ((ixE!=ix)&&(iyE!=iy)) HASH[ixE][iyE][iz]->push_back (pTest); if ((ixE!=ix)&&(izE!=iz)) HASH[ixE][iy][izE]->push_back (pTest); if ((iyE!=iy)&&(izE!=iz)) HASH[ix][iyE][izE]->push_back (pTest); if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) HASH[ixE][iyE][izE]->push_back (pTest); } } Status("Removing degenerated/duplicated faces..."); g_bUnregister = false; for (u32 it=0; it<lc_global_data()->g_faces().size(); it++) { R_ASSERT (it>=0 && it<(int)lc_global_data()->g_faces().size()); Face* F = lc_global_data()->g_faces()[it]; if ( F->isDegenerated()) { lc_global_data()->destroy_face (lc_global_data()->g_faces()[it]); Fremoved ++; } else { // Check validity F->Verify ( ); } Progress (float(it)/float(lc_global_data()->g_faces().size())); } if (InvalideFaces()) { err_save (); Debug.fatal (DEBUG_INFO,"* FATAL: %d invalid faces. Compilation aborted",InvalideFaces()); } Status ("Adjacency check..."); g_bUnregister = false; for (u32 it = 0; it<lc_global_data()->g_vertices().size(); ++it) { if (lc_global_data()->g_vertices()[it] && (lc_global_data()->g_vertices()[it]->m_adjacents.empty())) { lc_global_data()->destroy_vertex (lc_global_data()->g_vertices()[it]); ++Vremoved; } } Status ("Cleanup..."); lc_global_data()->g_vertices().erase (std::remove(lc_global_data()->g_vertices().begin(),lc_global_data()->g_vertices().end(),(Vertex*)0),lc_global_data()->g_vertices().end()); lc_global_data()->g_faces().erase (std::remove(lc_global_data()->g_faces().begin(),lc_global_data()->g_faces().end(),(Face*)0),lc_global_data()->g_faces().end()); { for (int ix=0; ix<HDIM_X+1; ix++) for (int iy=0; iy<HDIM_Y+1; iy++) for (int iz=0; iz<HDIM_Z+1; iz++) { xr_delete(HASH[ix][iy][iz]); } } mem_Compact (); clMsg("%d vertices removed. (%d left)",Vcount-lc_global_data()->g_vertices().size(),lc_global_data()->g_vertices().size()); clMsg("%d faces removed. (%d left)", Fcount-lc_global_data()->g_faces().size(), lc_global_data()->g_faces().size()); // ------------------------------------------------------------- /* int err_count =0 ; for (int _1=0; _1<g_faces.size(); _1++) { Progress(float(_1)/float(g_faces.size())); for (int _2=0; _2<g_faces.size(); _2++) { if (_1==_2) continue; if (FaceEqual(*g_faces[_1],*g_faces[_2])) { err_count ++; } } } clMsg ("! duplicate/same faces found:%d",err_count); */ // ------------------------------------------------------------- }
void CEditableObject::ClearSMotions() { SetActiveSMotion(0); for(SMotionIt m_it=m_SMotions.begin(); m_it!=m_SMotions.end();m_it++)xr_delete(*m_it); m_SMotions.clear(); }
void CSurface::RemoveImageData() { xr_delete (m_ImageData); }
CAI_PseudoDog::~CAI_PseudoDog() { xr_delete(StateMan); }
void global_slots_data::FreeOnAgent () { xr_delete( dtS ); }
CWeaponStatMgun::~CWeaponStatMgun() { delete_data(m_Ammo); xr_delete(camera); }
bool EScene::ReadObjectsLTX(CInifile& ini, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, TAppendObject on_append, SPBItem* pb) { string128 buff; R_ASSERT (on_append); sprintf (buff, "%s_count", sect_name_prefix); u32 count = ini.r_u32(sect_name_parent, buff); bool bRes = true; for(u32 i=0; i<count; ++i) { sprintf (buff, "%s_%s_%d", sect_name_parent, sect_name_prefix, i); CCustomObject* obj = NULL; if(ReadObjectLTX(ini, buff, obj)) { LPCSTR obj_name = obj->Name; CCustomObject* existing = FindObjectByName(obj_name,obj->ClassID); if(existing) { if(g_frmConflictLoadObject->m_result!=2 && g_frmConflictLoadObject->m_result!=4 && g_frmConflictLoadObject->m_result!=6) { g_frmConflictLoadObject->m_existing_object = existing; g_frmConflictLoadObject->m_new_object = obj; g_frmConflictLoadObject->Prepare (); g_frmConflictLoadObject->ShowModal (); } switch(g_frmConflictLoadObject->m_result) { case 1: //Overwrite case 2: //Overwrite All { bool res = RemoveObject (existing, true, true); if(!res) Msg("! RemoveObject [%s] failed", existing->Name); else xr_delete(existing); }break; case 3: //Insert new case 4: //Insert new All { string256 buf; GenObjectName (obj->ClassID, buf, obj->Name); obj->Name = buf; }break; case 0: //Cancel case 5: //Skip case 6: //Skip All { xr_delete(obj); }break; } //switch } //if exist if (obj && !on_append(obj)) xr_delete(obj);} else bRes = false; if (pb) pb->Inc(); } return bRes; }
void RefreshInternetList (void * inData) { RefreshData* pRData = (RefreshData*) inData; pRData->pGSBrowser->RefreshListInternet(pRData->FilterStr); xr_delete(pRData); };