void TClipMaker::LoadClips() { bool bRes=true; if (EFS.GetOpenName("$clips$",m_ClipFName)){ Clear (); IReader* F = FS.r_open(m_ClipFName.c_str()); VERIFY(F); m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(),FS.get_path("$clips$")->m_Path); if (F->find_chunk(CHUNK_ZOOM)){ m_Zoom = F->r_float(); } IReader* C = F->open_chunk(CHUNK_CLIPS); if(C){ IReader* M = C->open_chunk(0); for (int count=1; M; count++) { CUIClip* clip = xr_new<CUIClip>(this,count); if (!clip->Load(*M)){ ELog.Msg(mtError,"Unsupported clip version. Load failed."); xr_delete(clip); bRes = false; } M->close(); if (!bRes) break; clips.push_back(clip); M = C->open_chunk(count); } C->close (); UpdateClips (); } FS.r_close(F); } }
void ELightAnimLibrary::Load() { string_path fn; FS.update_path(fn,_game_data_,"lanims.xr"); IReader* fs=FS.r_open(fn); if (fs){ u16 version = 0; if (fs->find_chunk(CHUNK_VERSION)){ version = fs->r_u16(); } IReader* OBJ = fs->open_chunk(CHUNK_ITEM_LIST); if (OBJ){ IReader* O = OBJ->open_chunk(0); for (int count=1; O; count++) { CLAItem* I = xr_new<CLAItem>(); I->Load(*O); if (version==0){ for (CLAItem::KeyPairIt it=I->Keys.begin(); it!=I->Keys.end(); it++) it->second = subst_alpha(bgr2rgb(it->second),color_get_A(it->second)); } Items.push_back(I); O->close(); O = OBJ->open_chunk(count); } OBJ->close(); } FS.r_close(fs); } }
void CALifeSpawnRegistry::load (IReader &file_stream, xrGUID *save_guid) { IReader *chunk; chunk = file_stream.open_chunk(0); m_header.load (*chunk); chunk->close (); R_ASSERT2 (!save_guid || (*save_guid == header().guid()) || ignore_save_incompatibility(),"Saved game doesn't correspond to the spawn : DELETE SAVED GAME!"); chunk = file_stream.open_chunk(1); m_spawns.load (*chunk); chunk->close (); #if 0 SPAWN_GRAPH::vertex_iterator I = m_spawns.vertices().begin(); SPAWN_GRAPH::vertex_iterator E = m_spawns.vertices().end(); for ( ; I != E; ++I) { luabind::wrap_base *base = smart_cast<luabind::wrap_base*>(&(*I).second->data()->object()); if (!base) continue; if (xr_strcmp((*I).second->data()->object().name_replace(),"rostok_stalker_outfit")) continue; dummy *_dummy = (dummy*)((void*)base->m_self.m_impl); lua_State **_state = &_dummy->state; Msg ("0x%08x",*(int*)&_state); break; } #endif chunk = file_stream.open_chunk(2); load_data (m_artefact_spawn_positions,*chunk); chunk->close (); chunk = file_stream.open_chunk(3); R_ASSERT2 (chunk,"Spawn version mismatch - REBUILD SPAWN!"); ai().patrol_path_storage (*chunk); chunk->close (); VERIFY (!m_chunk); m_chunk = file_stream.open_chunk(4); R_ASSERT2 (m_chunk,"Spawn version mismatch - REBUILD SPAWN!"); VERIFY (!m_game_graph); m_game_graph = new CGameGraph(*m_chunk); ai().game_graph (m_game_graph); R_ASSERT2 ((header().graph_guid() == ai().game_graph().header().guid()) || ignore_save_incompatibility(),"Spawn doesn't correspond to the graph : REBUILD SPAWN!"); build_story_spawns (); build_root_spawns (); Msg ("* %d spawn points are successfully loaded",m_spawns.vertex_count()); }
bool ESceneLightTools::Load(IReader& F) { u16 version = 0; if(F.r_chunk(CHUNK_VERSION,&version)) if( version!=LIGHT_TOOLS_VERSION ){ ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); return false; } if (!inherited::Load(F)) return false; if (F.find_chunk(CHUNK_FLAGS)) m_Flags.assign (F.r_u32()); if (F.find_chunk(CHUNK_SUN_SHADOW)){ F.r_u8 (); F.r_fvector2 (m_SunShadowDir); } if (F.find_chunk(CHUNK_LCONTROLS_LAST)) lcontrol_last_idx = F.r_u32(); IReader* R = F.open_chunk(CHUNK_LCONTROLS); if (R){ while (!R->eof()){ shared_str l_name; R->r_stringZ(l_name); u32 l_idx = R->r_u32(); AppendLightControl(l_name.c_str(),&l_idx); } R->close (); } return true; }
void CPatrolPathStorage::load_raw (const CLevelGraph *level_graph, const CGameLevelCrossTable *cross, const CGameGraph *game_graph, IReader &stream) { IReader *chunk = stream.open_chunk(WAY_PATROLPATH_CHUNK); if (!chunk) return; u32 chunk_iterator; for (IReader *sub_chunk = chunk->open_chunk_iterator(chunk_iterator); sub_chunk; sub_chunk = chunk->open_chunk_iterator(chunk_iterator,sub_chunk)) { R_ASSERT (sub_chunk->find_chunk(WAYOBJECT_CHUNK_VERSION)); R_ASSERT (sub_chunk->r_u16() == WAYOBJECT_VERSION); R_ASSERT (sub_chunk->find_chunk(WAYOBJECT_CHUNK_NAME)); shared_str patrol_name; sub_chunk->r_stringZ (patrol_name); const_iterator I = m_registry.find(patrol_name); VERIFY3 (I == m_registry.end(),"Duplicated patrol path found",*patrol_name); m_registry.insert ( std::make_pair( patrol_name, &xr_new<CPatrolPath>( patrol_name )->load_raw( level_graph, cross, game_graph, *sub_chunk ) ) ); } chunk->close (); }
void CALifeSpawnRegistry::load (IReader &file_stream, LPCSTR game_name) { R_ASSERT (FS.exist(game_name)); IReader *chunk, *chunk0; Msg ("* Loading spawn registry..."); R_ASSERT2 (file_stream.find_chunk(SPAWN_CHUNK_DATA),"Cannot find chunk SPAWN_CHUNK_DATA!"); chunk0 = file_stream.open_chunk(SPAWN_CHUNK_DATA); xrGUID guid; chunk = chunk0->open_chunk(0); VERIFY (chunk); chunk->r_stringZ (m_spawn_name); chunk->r (&guid,sizeof(guid)); chunk->close (); string_path file_name; bool file_exists = !!FS.exist(file_name, "$game_spawn$", *m_spawn_name, ".spawn"); R_ASSERT3 (file_exists,"Can't find spawn file:",*m_spawn_name); VERIFY (!m_file); m_file = FS.r_open(file_name); load (*m_file,&guid); chunk0->close (); }
void FHierrarhyVisual::Load(const char* N, IReader *data, u32 dwFlags) { dxRender_Visual::Load(N,data,dwFlags); if (data->find_chunk(OGF_CHILDREN_L)) { // From Link u32 cnt = data->r_u32 (); children.resize (cnt); for (u32 i=0; i<cnt; i++) { #ifdef _EDITOR THROW; #else u32 ID = data->r_u32(); children[i] = (dxRender_Visual*)::Render->getVisual(ID); #endif } bDontDelete = TRUE; } else { if (data->find_chunk(OGF_CHILDREN)) { // From stream IReader* OBJ = data->open_chunk(OGF_CHILDREN); if (OBJ){ IReader* O = OBJ->open_chunk(0); for (int count=1; O; count++) { string_path name_load,short_name,num; xr_strcpy (short_name,N); if (strext(short_name)) *strext(short_name)=0; strconcat (sizeof(name_load),name_load,short_name,":",itoa(count,num,10)); children.push_back ((dxRender_Visual*)::Render->model_CreateChild(name_load,O)); O->close (); O = OBJ->open_chunk (count); } OBJ->close(); } bDontDelete = FALSE; } else { FATAL ("Invalid visual"); } } }
void CHOM::Load () { // Find and open file string_path fName; FS.update_path (fName,"$level$","level.hom"); if (!FS.exist(fName)) { Msg (" WARNING: Occlusion map '%s' not found.",fName); return; } Msg ("* Loading HOM: %s",fName); IReader* fs = FS.r_open(fName); IReader* S = fs->open_chunk(1); // Load tris and merge them CDB::Collector CL; while (!S->eof()) { HOM_poly P; S->r (&P,sizeof(P)); CL.add_face_packed_D (P.v1,P.v2,P.v3,P.flags,0.01f); } // Determine adjacency xr_vector<u32> adjacency; CL.calc_adjacency (adjacency); // Create RASTER-triangles m_pTris = xr_alloc<occTri> (u32(CL.getTS())); for (u32 it=0; it<CL.getTS(); it++) { CDB::TRI& clT = CL.getT()[it]; occTri& rT = m_pTris[it]; Fvector& v0 = CL.getV()[clT.verts[0]]; Fvector& v1 = CL.getV()[clT.verts[1]]; Fvector& v2 = CL.getV()[clT.verts[2]]; rT.adjacent[0] = (0xffffffff==adjacency[3*it+0])?((occTri*) (-1)):(m_pTris+adjacency[3*it+0]); rT.adjacent[1] = (0xffffffff==adjacency[3*it+1])?((occTri*) (-1)):(m_pTris+adjacency[3*it+1]); rT.adjacent[2] = (0xffffffff==adjacency[3*it+2])?((occTri*) (-1)):(m_pTris+adjacency[3*it+2]); rT.flags = clT.dummy; rT.area = Area (v0,v1,v2); if (rT.area<EPS_L) { Msg ("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)",VPUSH(v0),VPUSH(v1),VPUSH(v2)); } rT.plane.build (v0,v1,v2); rT.skip = 0; rT.center.add(v0,v1).add(v2).div(3.f); } // Create AABB-tree m_pModel = xr_new<CDB::MODEL> (); m_pModel->build (CL.getV(),int(CL.getVS()),CL.getT(),int(CL.getTS())); bEnabled = TRUE; S->close (); FS.r_close (fs); }
void transfer(const char *name, xr_vector<T> &dest, IReader& F, u32 chunk) { IReader* O = F.open_chunk(chunk); u32 count = O?(O->length()/sizeof(T)):0; clMsg ("* %16s: %d",name,count); if (count) { dest.reserve(count); dest.insert (dest.begin(), (T*)O->pointer(), (T*)O->pointer() + count); } if (O) O->close (); }
bool CEditableObject::LoadBoneData(IReader& F) { BoneVec load_bones; int count=0; IReader* R; while(0!=(R=F.open_chunk(count++))) { CBone* nBone = xr_new<CBone>(); load_bones.push_back(nBone); nBone->LoadData(*R); Msg("loaded bone [%s]", nBone->Name().c_str()); } bool bRes = true; // load bones if (!load_bones.empty()){ for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ CBone* B = *b_it; BoneIt n_it = std::find_if(load_bones.begin(),load_bones.end(),fBoneNameEQ(B->Name())); if (n_it!=load_bones.end()) { B->CopyData (*n_it); }else{ ELog.Msg (mtError,"Can't find bone: '%s'.",*(*b_it)->Name()); bRes = false; // break; } } for (BoneIt n_it=load_bones.begin(); n_it!=load_bones.end(); n_it++) xr_delete(*n_it); load_bones.clear(); }else{ ELog.Msg (mtError,"Empty bone list."); bRes = false; } // load bone part if (F.find_chunk(EOBJ_CHUNK_BONEPARTS2)){ shared_str buf; m_BoneParts.resize(F.r_u32()); for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ F.r_stringZ (buf); bp_it->alias=buf; bp_it->bones.resize (F.r_u32()); for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) F.r_stringZ (*s_it); } if (!m_BoneParts.empty()&&!VerifyBoneParts()) ELog.Msg (mtError,"Invalid bone parts. Found missing or duplicate bone."); }else{ ELog.Msg (mtError,"Can't load bone parts. Invalid version."); } return bRes; }
void CPatrolPathStorage::load (IReader &stream) { IReader *chunk; chunk = stream.open_chunk(0); u32 size = chunk->r_u32(); chunk->close (); m_registry.clear (); PATROL_REGISTRY::value_type pair; chunk = stream.open_chunk(1); for (u32 i=0; i<size; ++i) { IReader *chunk1; chunk1 = chunk->open_chunk(i); IReader *chunk2; chunk2 = chunk1->open_chunk(0); load_data (pair.first,*chunk2); chunk2->close (); chunk2 = chunk1->open_chunk(1); load_data (pair.second,*chunk2); chunk2->close (); chunk1->close (); const_iterator I = m_registry.find(pair.first); VERIFY3 (I == m_registry.end(),"Duplicated patrol path found ",*pair.first); #ifdef DEBUG pair.second->name (pair.first); #endif m_registry.insert (pair); } chunk->close (); }
bool EDetailManager::LoadColorIndices(IReader& F) { VERIFY (objects.empty()); VERIFY (m_ColorIndices.empty()); bool bRes = true; // objects IReader* OBJ = F.open_chunk(DETMGR_CHUNK_OBJECTS); if (OBJ){ IReader* O = OBJ->open_chunk(0); for (int count=1; O; count++) { EDetail* DO = xr_new<EDetail>(); if (DO->Load(*O)) objects.push_back(DO); else bRes = false; O->close(); O = OBJ->open_chunk(count); } OBJ->close(); } // color index map R_ASSERT (F.find_chunk(DETMGR_CHUNK_COLOR_INDEX)); int cnt = F.r_u8(); string256 buf; u32 index; int ref_cnt; for (int k=0; k<cnt; k++){ index = F.r_u32(); ref_cnt = F.r_u8(); for (int j=0; j<ref_cnt; j++){ F.r_stringZ (buf,sizeof(buf)); EDetail* DO = FindDOByName(buf); if (DO) m_ColorIndices[index].push_back(DO); else bRes=false; } } InvalidateCache (); return bRes; }
bool EScene::LoadSelection( LPCSTR fname ) { u32 version = 0; VERIFY( fname ); xr_string full_name; full_name = fname; ELog.Msg( mtInformation, "EScene: loading part %s...", fname ); bool res = true; if (FS.exist(full_name.c_str())){ SelectObjects( false ); IReader* F = FS.r_open(full_name.c_str()); // Version R_ASSERT(F->r_chunk(CHUNK_VERSION, &version)); if (version!=CURRENT_FILE_VERSION){ ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); FS.r_close(F); return false; } // Objects if (!ReadObjectsStream(*F,CHUNK_OBJECT_LIST,OnLoadSelectionAppendObject,0)) { ELog.DlgMsg(mtError,"EScene. Failed to load selection."); res = false; } SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) if (_I->second&&_I->second->IsEnabled()&&_I->second->IsEditable()){ IReader* chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); if (chunk){ _I->second->LoadSelection(*chunk); chunk->close (); } } // Synchronize SynchronizeObjects(); FS.r_close(F); } return res; }
bool EScene::ReadObjectStream(IReader& F, CCustomObject*& O) { ObjClassID clsid =OBJCLASS_DUMMY; R_ASSERT (F.find_chunk(CHUNK_OBJECT_CLASS)); clsid = ObjClassID(F.r_u32()); O = GetOTool(clsid)->CreateObject(0,0); IReader* S = F.open_chunk(CHUNK_OBJECT_BODY); R_ASSERT (S); bool bRes = O->LoadStream(*S); S->close (); if (!bRes) xr_delete (O); return bRes; }
bool CEditableObject::LoadObject(const char* fname) { if (FS.exist(fname)){ int age = FS.get_file_age (fname); VERIFY3(age>0,"Invalid file age:",fname); IReader* F = FS.r_open (fname); R_ASSERT(F); IReader* OBJ = F->open_chunk (EOBJ_CHUNK_OBJECT_BODY); R_ASSERT2 (OBJ,"Corrupted file."); bool bRes = Load(*OBJ); OBJ->close(); FS.r_close(F); if (bRes){ m_LoadName = fname; m_ObjectVersion = age; } return bRes; } return false; }
BOOL EScene::LoadLevelPart(ESceneToolBase* M, LPCSTR map_name) { if(M->can_use_inifile()) return LoadLevelPartLTX(M, map_name); if (FS.exist(map_name)) { // check locking M->m_EditFlags.set(ESceneToolBase::flReadonly,FALSE); IReader* R = FS.r_open (map_name); VERIFY (R); // check level part GUID R_ASSERT (R->find_chunk (CHUNK_TOOLS_GUID)); xrGUID guid; R->r (&guid,sizeof(guid)); if (guid!=m_GUID) { ELog.DlgMsg (mtError,"Skipping invalid version of level part: '%s\\%s.part'",EFS.ExtractFileName(map_name).c_str(),M->ClassName()); FS.r_close (R); return FALSE; } // read data IReader* chunk = R->open_chunk (CHUNK_TOOLS_DATA+M->ClassID); if(chunk!=NULL) { M->LoadStream (*chunk); chunk->close (); }else { ELog.DlgMsg (mtError,"Skipping corrupted version of level part: '%s\\%s.part'",EFS.ExtractFileName(map_name).c_str(),M->ClassName()); FS.r_close (R); return FALSE; } //success FS.r_close (R); return TRUE; } return TRUE; }
bool CPSLibrary::Load(const char* nm) { IReader* F = FS.r_open(nm); bool bRes = true; R_ASSERT(F->find_chunk(PS_CHUNK_VERSION)); u16 ver = F->r_u16(); if (ver!=PS_VERSION) return false; // second generation IReader* OBJ; OBJ = F->open_chunk(PS_CHUNK_SECONDGEN); if (OBJ){ IReader* O = OBJ->open_chunk(0); for (int count=1; O; count++) { PS::CPEDef* def = xr_new<PS::CPEDef>(); if (def->Load(*O)) m_PEDs.push_back(def); else{ bRes = false; xr_delete(def); } O->close(); if (!bRes) break; O = OBJ->open_chunk(count); } OBJ->close(); } // second generation OBJ = F->open_chunk(PS_CHUNK_THIRDGEN); if (OBJ){ IReader* O = OBJ->open_chunk(0); for (int count=1; O; count++) { PS::CPGDef* def = xr_new<PS::CPGDef>(); if (def->Load(*O)) m_PGDs.push_back(def); else{ bRes = false; xr_delete(def); } O->close(); if (!bRes) break; O = OBJ->open_chunk(count); } OBJ->close(); } // final FS.r_close (F); std::sort (m_PEDs.begin(),m_PEDs.end(),ped_sort_pred); std::sort (m_PGDs.begin(),m_PGDs.end(),pgd_sort_pred); return bRes; }
void CRender::LoadSectors(IReader* fs) { // allocate memory for portals u32 size = fs->find_chunk(fsL_PORTALS); R_ASSERT(0==size%sizeof(b_portal)); u32 count = size/sizeof(b_portal); Portals.resize (count); for (u32 c=0; c<count; c++) Portals[c] = xr_new<CPortal> (); // load sectors IReader* S = fs->open_chunk(fsL_SECTORS); for (u32 i=0; ; i++) { IReader* P = S->open_chunk(i); if (0==P) break; CSector* __S = xr_new<CSector> (); __S->load (*P); Sectors.push_back (__S); P->close(); } S->close(); // load portals if (count) { CDB::Collector CL; fs->find_chunk (fsL_PORTALS); for (i=0; i<count; i++) { b_portal P; fs->r (&P,sizeof(P)); CPortal* __P = (CPortal*)Portals[i]; __P->Setup (P.vertices.begin(),P.vertices.size(), (CSector*)getSector(P.sector_front), (CSector*)getSector(P.sector_back)); for (u32 j=2; j<P.vertices.size(); j++) CL.add_face_packed_D( P.vertices[0],P.vertices[j-1],P.vertices[j], u32(i) ); } if (CL.getTS()<2) { Fvector v1,v2,v3; v1.set (-20000.f,-20000.f,-20000.f); v2.set (-20001.f,-20001.f,-20001.f); v3.set (-20002.f,-20002.f,-20002.f); CL.add_face_packed_D (v1,v2,v3,0); } // build portal model rmPortals = xr_new<CDB::MODEL> (); rmPortals->build (CL.getV(),int(CL.getVS()),CL.getT(),int(CL.getTS())); } else { rmPortals = 0; } // debug // for (int d=0; d<Sectors.size(); d++) // Sectors[d]->DebugDump (); pLastSector = 0; }
bool CEditableObject::Load(IReader& F) { bool bRes = true; do{ u32 version = 0; shared_str buf; shared_str sh_name; R_ASSERT(F.r_chunk(EOBJ_CHUNK_VERSION,&version)); if (version!=EOBJ_CURRENT_VERSION){ ELog.DlgMsg( mtError, "CEditableObject: unsupported file version. Object can't load."); bRes = false; break; } R_ASSERT(F.r_chunk(EOBJ_CHUNK_FLAGS, &m_Flags.flags)); if (F.find_chunk (EOBJ_CHUNK_CLASSSCRIPT)){ F.r_stringZ (m_ClassScript); } if (F.find_chunk (EOBJ_CHUNK_LODS)){ F.r_stringZ (m_LODs); } // surfaces if (F.find_chunk(EOBJ_CHUNK_SURFACES3)){ u32 cnt = F.r_u32(); m_Surfaces.resize(cnt); for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ *s_it = xr_new<CSurface>(); F.r_stringZ (buf); (*s_it)->SetName (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShader (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShaderXRLC (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetGameMtl (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetTexture (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetVMap (buf.c_str()); (*s_it)->m_Flags.assign(F.r_u32()); (*s_it)->SetFVF (F.r_u32()); cnt = F.r_u32(); if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str()); R_ASSERT(1<=cnt); } }else if (F.find_chunk(EOBJ_CHUNK_SURFACES2)){ u32 cnt = F.r_u32(); m_Surfaces.resize(cnt); for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ *s_it = xr_new<CSurface>(); F.r_stringZ (buf); (*s_it)->SetName (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShader (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShaderXRLC (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetTexture (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetVMap (buf.c_str()); (*s_it)->m_Flags.assign(F.r_u32()); (*s_it)->SetFVF (F.r_u32()); cnt = F.r_u32(); if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str()); R_ASSERT(1<=cnt); } }else{ R_ASSERT(F.find_chunk(EOBJ_CHUNK_SURFACES)); u32 cnt = F.r_u32(); m_Surfaces.resize(cnt); for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ *s_it = xr_new<CSurface>(); F.r_stringZ(buf); (*s_it)->SetName(buf.c_str()); F.r_stringZ(sh_name); (*s_it)->m_Flags.set(CSurface::sf2Sided,!!F.r_u8()); (*s_it)->SetFVF (F.r_u32()); cnt = F.r_u32(); if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str()); R_ASSERT(1<=cnt); F.r_stringZ (buf); (*s_it)->SetTexture(buf.c_str()); F.r_stringZ (buf); (*s_it)->SetVMap(buf.c_str()); (*s_it)->SetShader (sh_name.c_str()); (*s_it)->SetShaderXRLC ("default"); } // surfaces xrlc part if(F.find_chunk(EOBJ_CHUNK_SURFACES_XRLC)) for (s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ F.r_stringZ(buf); (*s_it)->SetShaderXRLC(buf.c_str()); } } // Load meshes IReader* OBJ = F.open_chunk(EOBJ_CHUNK_EDITMESHES); if(OBJ){ IReader* M = OBJ->open_chunk(0); for (int count=1; M; count++) { CEditableMesh* mesh=xr_new<CEditableMesh>(this); if (mesh->LoadMesh(*M)) m_Meshes.push_back(mesh); else{ ELog.DlgMsg( mtError, "CEditableObject: Can't load mesh '%s'!", *mesh->m_Name ); xr_delete(mesh); bRes = false; } M->close(); if (!bRes) break; M = OBJ->open_chunk(count); } OBJ->close(); } // bones if (bRes){ IReader* B_CHUNK = F.open_chunk(EOBJ_CHUNK_BONES2); if (B_CHUNK){ int chunk = 0; IReader* O; while (0!=(O=B_CHUNK->open_chunk(chunk++))){ m_Bones.push_back(xr_new<CBone>()); m_Bones.back()->Load_1(*O); O->close(); } B_CHUNK->close(); PrepareBones(); }else if (F.find_chunk(EOBJ_CHUNK_BONES)){ m_Bones.resize(F.r_u32()); for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ *b_it = xr_new<CBone>(); (*b_it)->Load_0(F); } PrepareBones(); } // skeleton motions if (F.find_chunk(EOBJ_CHUNK_SMOTIONS)){ m_SMotions.resize(F.r_u32()); for (SMotionIt s_it=m_SMotions.begin(); s_it!=m_SMotions.end(); s_it++){ *s_it = xr_new<CSMotion>(); if (!(*s_it)->Load(F)){ Log ("!Motions has different version. Load failed."); xr_delete(*s_it); m_SMotions.clear(); break; } // resort bone_mots (*s_it)->SortBonesBySkeleton(m_Bones); } } if (F.find_chunk(EOBJ_CHUNK_SMOTIONS2)){ F.r_stringZ (m_SMotionRefs); } } // bone parts if (bRes){ if (F.find_chunk(EOBJ_CHUNK_BONEPARTS)){ m_BoneParts.resize(F.r_u32()); bool bBPok = true; for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ F.r_stringZ (buf); bp_it->alias=buf; bp_it->bones.resize(F.r_u32()); for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++){ int idx = F.r_u32(); if ((idx>=0)&&(idx<(int)m_Bones.size())){ *s_it = m_Bones[idx]->Name(); }else{ Log ("!Invalid bone parts.",GetName()); bBPok = false; break; } } if (!bBPok) break; } if (!bBPok) m_BoneParts.clear(); if (!m_BoneParts.empty()&&!VerifyBoneParts()) Log ("!Invalid bone parts. Found duplicate bones in object '%s'.",GetName()); }else if (F.find_chunk(EOBJ_CHUNK_BONEPARTS2)){ m_BoneParts.resize(F.r_u32()); for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ F.r_stringZ (buf); bp_it->alias=buf; bp_it->bones.resize(F.r_u32()); for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) F.r_stringZ(*s_it); } if (!m_BoneParts.empty()&&!VerifyBoneParts()) Log ("!Invalid bone parts. Found duplicate bones in object '%s'.",GetName()); } } if (bRes){ if (F.find_chunk (EOBJ_CHUNK_ACTORTRANSFORM)){ F.r_fvector3 (a_vPosition); F.r_fvector3 (a_vRotate); } if (F.find_chunk (EOBJ_CHUNK_DESC)){ F.r_stringZ (m_CreateName); F.r (&m_CreateTime,sizeof(m_CreateTime)); F.r_stringZ (m_ModifName); F.r (&m_ModifTime,sizeof(m_ModifTime)); } ResetSAnimation(); } if (!bRes) break; UpdateBox (); VerifyMeshNames (); }while(0); return bRes; }
void CResourceManager::OnDeviceCreate (IReader* F) { if (!RDEVICE.b_is_Ready) return; string256 name; #ifndef _EDITOR // scripting LS_Load (); #endif IReader* fs = 0; // Load constants fs = F->open_chunk (0); if (fs){ while (!fs->eof()) { fs->r_stringZ (name,sizeof(name)); CConstant* C = _CreateConstant (name); C->Load (fs); } fs->close (); } // Load matrices fs = F->open_chunk(1); if (fs){ while (!fs->eof()) { fs->r_stringZ (name,sizeof(name)); CMatrix* M = _CreateMatrix (name); M->Load (fs); } fs->close (); } // Load blenders fs = F->open_chunk (2); if (fs){ IReader* chunk = NULL; int chunk_id= 0; while ((chunk=fs->open_chunk(chunk_id))!=NULL){ CBlender_DESC desc; chunk->r (&desc,sizeof(desc)); IBlender* B = IBlender::Create(desc.CLS); if (0==B) { Msg ("! Renderer doesn't support blender '%s'",desc.cName); } else { if (B->getDescription().version != desc.version) { Msg ("! Version conflict in shader '%s'",desc.cName); } chunk->seek (0); B->Load (*chunk,desc.version); std::pair<map_BlenderIt, bool> I = m_blenders.insert (mk_pair(xr_strdup(desc.cName),B)); R_ASSERT2 (I.second,"shader.xr - found duplicate name!!!"); } chunk->close (); chunk_id += 1; } fs->close(); } m_textures_description.Load (); }
bool EScene::Load(LPCSTR map_name, bool bUndo) { u32 version = 0; if (!map_name||(0==map_name[0])) return false; xr_string full_name; full_name = map_name; ELog.Msg( mtInformation, "EScene: loading '%s'", map_name); if (FS.exist(full_name.c_str())) { CTimer T; T.Start(); // read main level IReader* F = FS.r_open(full_name.c_str()); VERIFY(F); // Version R_ASSERT (F->r_chunk(CHUNK_VERSION, &version)); if (version!=CURRENT_FILE_VERSION) { ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); FS.r_close(F); return false; } // Lev. ops. IReader* LOP = F->open_chunk(CHUNK_LEVELOP); if (LOP) { m_LevelOp.Read (*LOP); LOP->close (); }else { ELog.DlgMsg (mtError, "Skipping old version of level options.\nCheck level options after loading."); } // if (F->find_chunk(CHUNK_CAMERA)) { Fvector hpb, pos; F->r_fvector3 (hpb); F->r_fvector3 (pos); EDevice.m_Camera.Set(hpb,pos); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); } if (F->find_chunk(CHUNK_TOOLS_GUID)) { F->r (&m_GUID,sizeof(m_GUID)); } if (F->find_chunk(CHUNK_LEVEL_TAG)) { F->r_stringZ (m_OwnerName); F->r (&m_CreateTime,sizeof(m_CreateTime)); }else { m_OwnerName = ""; m_CreateTime = 0; } DWORD obj_cnt = 0; if (F->find_chunk(CHUNK_OBJECT_COUNT)) obj_cnt = F->r_u32(); SPBItem* pb = UI->ProgressStart(obj_cnt,"Loading objects..."); ReadObjectsStream (*F,CHUNK_OBJECT_LIST,OnLoadAppendObject,pb); UI->ProgressEnd (pb); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if (_I->second) { IReader* chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); if (chunk){ _I->second->LoadStream(*chunk); chunk->close (); }else{ if (!bUndo && _I->second->IsEnabled() && (_I->first!=OBJCLASS_DUMMY)) { LoadLevelPart (_I->second,LevelPartName(map_name,_I->first).c_str()); } } } } // snap list if (F->find_chunk(CHUNK_SNAPOBJECTS)) { shared_str buf; int cnt = F->r_u32(); if (cnt) { for (int i=0; i<cnt; ++i) { F->r_stringZ (buf); CCustomObject* O = FindObjectByName(buf.c_str(),OBJCLASS_SCENEOBJECT); if (!O) ELog.Msg(mtError,"EScene: Can't find snap object '%s'.",buf.c_str()); else m_ESO_SnapObjects.push_back(O); } } UpdateSnapList(); } Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec() ); UI->UpdateScene(true); FS.r_close(F); SynchronizeObjects(); if (!bUndo) m_RTFlags.set(flRT_Unsaved|flRT_Modified,FALSE); return true; }else { ELog.Msg(mtError,"Can't find file: '%s'",map_name); } return false; }
bool EScene::ReadObjectsStream(IReader& F, u32 chunk_id, TAppendObject on_append, SPBItem* pb) { R_ASSERT (on_append); bool bRes = true; IReader* OBJ = F.open_chunk(chunk_id); if (OBJ) { IReader* O = OBJ->open_chunk(0); for (int count=1; O; ++count) { CCustomObject* obj =NULL; if (ReadObjectStream(*O, 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; } } if (obj && !on_append(obj)) xr_delete(obj);} else bRes = false; O->close (); O = OBJ->open_chunk(count); if (pb) pb->Inc(); } OBJ->close(); } return bRes; }
void global_claculation_data::xrLoad() { string_path N; FS.update_path ( N, "$game_data$", "shaders_xrlc.xr" ); g_shaders_xrlc = new Shader_xrLC_LIB(); g_shaders_xrlc->Load ( N ); // Load CFORM { FS.update_path (N,"$level$","build.cform"); IReader* fs = FS.r_open("$level$","build.cform"); R_ASSERT (fs->find_chunk(0)); hdrCFORM H; fs->r (&H,sizeof(hdrCFORM)); R_ASSERT (CFORM_CURRENT_VERSION==H.version); Fvector* verts = (Fvector*)fs->pointer(); CDB::TRI* tris = (CDB::TRI*)(verts+H.vertcount); RCAST_Model.build ( verts, H.vertcount, tris, H.facecount ); Msg("* Level CFORM: %dK",RCAST_Model.memory()/1024); g_rc_faces.resize (H.facecount); R_ASSERT(fs->find_chunk(1)); fs->r (&*g_rc_faces.begin(),g_rc_faces.size()*sizeof(b_rc_face)); LevelBB.set (H.aabb); } { slots_data.Load( ); } // Lights { IReader* fs = FS.r_open("$level$","build.lights"); IReader* F; u32 cnt; R_Light* L; // rgb F = fs->open_chunk (0); cnt = F->length()/sizeof(R_Light); L = (R_Light*)F->pointer(); g_lights.rgb.assign (L,L+cnt); F->close (); // hemi F = fs->open_chunk (1); cnt = F->length()/sizeof(R_Light); L = (R_Light*)F->pointer(); g_lights.hemi.assign(L,L+cnt); F->close (); // sun F = fs->open_chunk (2); cnt = F->length()/sizeof(R_Light); L = (R_Light*)F->pointer(); g_lights.sun.assign (L,L+cnt); F->close (); FS.r_close (fs); } // Load level data { IReader* fs = FS.r_open ("$level$","build.prj"); IReader* F; // Version u32 version; fs->r_chunk (EB_Version,&version); R_ASSERT(XRCL_CURRENT_VERSION==version); // Header fs->r_chunk (EB_Parameters,&g_params); // Load level data transfer("materials", g_materials, *fs, EB_Materials); transfer("shaders_xrlc",g_shader_compile, *fs, EB_Shaders_Compile); post_process_materials( *g_shaders_xrlc, g_shader_compile, g_materials ); // process textures #ifdef DEBUG xr_vector<b_texture> dbg_textures; #endif Status ("Processing textures..."); { Surface_Init (); F = fs->open_chunk (EB_Textures); u32 tex_count = F->length()/sizeof(b_texture); for (u32 t=0; t<tex_count; t++) { Progress (float(t)/float(tex_count)); b_texture TEX; F->r (&TEX,sizeof(TEX)); #ifdef DEBUG dbg_textures.push_back( TEX ); #endif b_BuildTexture BT; CopyMemory (&BT,&TEX,sizeof(TEX)); // load thumbnail LPSTR N = BT.name; if (strchr(N,'.')) *(strchr(N,'.')) = 0; strlwr (N); if (0==xr_strcmp(N,"level_lods")) { // HACK for merged lod textures BT.dwWidth = 1024; BT.dwHeight = 1024; BT.bHasAlpha= TRUE; BT.pSurface = 0; } else { strcat (N,".thm"); IReader* THM = FS.r_open("$game_textures$",N); R_ASSERT2 (THM, N); // version u32 version = 0; R_ASSERT (THM->r_chunk(THM_CHUNK_VERSION,&version)); // if( version!=THM_CURRENT_VERSION ) FATAL ("Unsupported version of THM file."); // analyze thumbnail information R_ASSERT(THM->find_chunk(THM_CHUNK_TEXTUREPARAM)); THM->r (&BT.THM.fmt,sizeof(STextureParams::ETFormat)); BT.THM.flags.assign (THM->r_u32()); BT.THM.border_color = THM->r_u32(); BT.THM.fade_color = THM->r_u32(); BT.THM.fade_amount = THM->r_u32(); BT.THM.mip_filter = THM->r_u32(); BT.THM.width = THM->r_u32(); BT.THM.height = THM->r_u32(); BOOL bLOD=FALSE; if (N[0]=='l' && N[1]=='o' && N[2]=='d' && N[3]=='\\') bLOD = TRUE; // load surface if it has an alpha channel or has "implicit lighting" flag BT.dwWidth = BT.THM.width; BT.dwHeight = BT.THM.height; BT.bHasAlpha = BT.THM.HasAlphaChannel(); BT.pSurface = 0; if (!bLOD) { if (BT.bHasAlpha || BT.THM.flags.test(STextureParams::flImplicitLighted)) { clMsg ("- loading: %s",N); u32 w=0, h=0; BT.pSurface = Surface_Load(N,w,h); R_ASSERT2 (BT.pSurface,"Can't load surface"); if ((w != BT.dwWidth) || (h != BT.dwHeight)) Msg ("! THM doesn't correspond to the texture: %dx%d -> %dx%d", BT.dwWidth, BT.dwHeight, w, h); BT.Vflip (); } else { // Free surface memory } } } // save all the stuff we've created g_textures.push_back (BT); } } } }
void xrLoad(LPCSTR name, bool draft_mode) { FS.get_path ("$level$")->_set ((LPSTR)name); string256 N; if (!draft_mode) { // shaders string_path N; FS.update_path (N,"$game_data$","shaders_xrlc.xr"); g_shaders_xrlc = xr_new<Shader_xrLC_LIB> (); g_shaders_xrlc->Load (N); // Load CFORM { strconcat (sizeof(N),N,name,"build.cform"); IReader* fs = FS.r_open(N); R_ASSERT (fs->find_chunk(0)); hdrCFORM H; fs->r (&H,sizeof(hdrCFORM)); R_ASSERT (CFORM_CURRENT_VERSION==H.version); Fvector* verts = (Fvector*)fs->pointer(); CDB::TRI* tris = (CDB::TRI*)(verts+H.vertcount); Level.build ( verts, H.vertcount, tris, H.facecount ); Level.syncronize (); Msg("* Level CFORM: %dK",Level.memory()/1024); g_rc_faces.resize (H.facecount); R_ASSERT(fs->find_chunk(1)); fs->r (&*g_rc_faces.begin(),g_rc_faces.size()*sizeof(b_rc_face)); LevelBB.set (H.aabb); FS.r_close (fs); } // Load level data { strconcat (sizeof(N),N,name,"build.prj"); IReader* fs = FS.r_open (N); IReader* F; // Version u32 version; fs->r_chunk (EB_Version,&version); R_ASSERT (XRCL_CURRENT_VERSION >= 17); R_ASSERT (XRCL_CURRENT_VERSION <= 18); // Header b_params Params; fs->r_chunk (EB_Parameters,&Params); // Load level data transfer("materials", g_materials, *fs, EB_Materials); transfer("shaders_xrlc",g_shader_compile, *fs, EB_Shaders_Compile); // process textures Status ("Processing textures..."); { Surface_Init (); F = fs->open_chunk (EB_Textures); u32 tex_count = F->length()/sizeof(b_texture); for (u32 t=0; t<tex_count; t++) { Progress (float(t)/float(tex_count)); b_texture TEX; F->r (&TEX,sizeof(TEX)); b_BuildTexture BT; CopyMemory (&BT,&TEX,sizeof(TEX)); // load thumbnail string128 &N = BT.name; LPSTR extension = strext(N); if (extension) *extension = 0; xr_strlwr (N); if (0==xr_strcmp(N,"level_lods")) { // HACK for merged lod textures BT.dwWidth = 1024; BT.dwHeight = 1024; BT.bHasAlpha= TRUE; BT.pSurface = 0; } else { xr_strcat (N,".thm"); IReader* THM = FS.r_open("$game_textures$",N); // if (!THM) continue; R_ASSERT2 (THM, N); // version u32 version = 0; R_ASSERT (THM->r_chunk(THM_CHUNK_VERSION,&version)); // if( version!=THM_CURRENT_VERSION ) FATAL ("Unsupported version of THM file."); // analyze thumbnail information R_ASSERT(THM->find_chunk(THM_CHUNK_TEXTUREPARAM)); THM->r (&BT.THM.fmt,sizeof(STextureParams::ETFormat)); BT.THM.flags.assign (THM->r_u32()); BT.THM.border_color = THM->r_u32(); BT.THM.fade_color = THM->r_u32(); BT.THM.fade_amount = THM->r_u32(); BT.THM.mip_filter = THM->r_u32(); BT.THM.width = THM->r_u32(); BT.THM.height = THM->r_u32(); BOOL bLOD=FALSE; if (N[0]=='l' && N[1]=='o' && N[2]=='d' && N[3]=='\\') bLOD = TRUE; // load surface if it has an alpha channel or has "implicit lighting" flag BT.dwWidth = BT.THM.width; BT.dwHeight = BT.THM.height; BT.bHasAlpha = BT.THM.HasAlphaChannel(); BT.pSurface = 0; if (!bLOD) { if (BT.bHasAlpha || BT.THM.flags.test(STextureParams::flImplicitLighted)) { clMsg ("- loading: %s",N); u32 w=0, h=0; BT.pSurface = Surface_Load(N,w,h); R_ASSERT2 (BT.pSurface,"Can't load surface"); if ((w != BT.dwWidth) || (h != BT.dwHeight)) Msg ("! THM doesn't correspond to the texture: %dx%d -> %dx%d", BT.dwWidth, BT.dwHeight, w, h); BT.Vflip (); } else { // Free surface memory } } } // save all the stuff we've created g_textures.push_back (BT); } } } } // // Load emitters // { // strconcat (N,name,"level.game"); // IReader *F = FS.r_open(N); // IReader *O = 0; // if (0!=(O = F->open_chunk (AIPOINT_CHUNK))) { // for (int id=0; O->find_chunk(id); id++) { // Emitters.push_back(Fvector()); // O->r_fvector3 (Emitters.back()); // } // O->close(); // } // } // // Load lights { strconcat (sizeof(N),N,name,"build.prj"); IReader* F = FS.r_open(N); R_ASSERT2 (F,"There is no file 'build.prj'!"); IReader &fs= *F; // Version u32 version; fs.r_chunk (EB_Version,&version); R_ASSERT (XRCL_CURRENT_VERSION >= 17); R_ASSERT (XRCL_CURRENT_VERSION <= 18); // Header b_params Params; fs.r_chunk (EB_Parameters,&Params); // Lights (Static) { F = fs.open_chunk(EB_Light_static); b_light_static temp; u32 cnt = F->length()/sizeof(temp); for (u32 i=0; i<cnt; i++) { R_Light RL; F->r (&temp,sizeof(temp)); Flight& L = temp.data; if (_abs(L.range) > 10000.f) { Msg ("! BAD light range : %f",L.range); L.range = L.range > 0.f ? 10000.f : -10000.f; } // type if (L.type == D3DLIGHT_DIRECTIONAL) RL.type = LT_DIRECT; else RL.type = LT_POINT; // generic properties RL.position.set (L.position); RL.direction.normalize_safe (L.direction); RL.range = L.range*1.1f; RL.range2 = RL.range*RL.range; RL.attenuation0 = L.attenuation0; RL.attenuation1 = L.attenuation1; RL.attenuation2 = L.attenuation2; RL.amount = L.diffuse.magnitude_rgb (); RL.tri[0].set (0,0,0); RL.tri[1].set (0,0,0); RL.tri[2].set (0,0,0); // place into layer if (0==temp.controller_ID) g_lights.push_back (RL); } F->close (); } } // Init params // g_params.Init (); // Load initial map from the Level Editor { string_path file_name; strconcat (sizeof(file_name),file_name,name,"build.aimap"); IReader *F = FS.r_open(file_name); R_ASSERT2 (F, file_name); R_ASSERT (F->open_chunk(E_AIMAP_CHUNK_VERSION)); R_ASSERT (F->r_u16() == E_AIMAP_VERSION); R_ASSERT (F->open_chunk(E_AIMAP_CHUNK_BOX)); F->r (&LevelBB,sizeof(LevelBB)); R_ASSERT (F->open_chunk(E_AIMAP_CHUNK_PARAMS)); F->r (&g_params,sizeof(g_params)); R_ASSERT (F->open_chunk(E_AIMAP_CHUNK_NODES)); u32 N = F->r_u32(); R_ASSERT2 (N < ((u32(1) << u32(MAX_NODE_BIT_COUNT)) - 2),"Too many nodes!"); g_nodes.resize (N); hdrNODES H; H.version = XRAI_CURRENT_VERSION; H.count = N+1; H.size = g_params.fPatchSize; H.size_y = 1.f; H.aabb = LevelBB; typedef BYTE NodeLink[3]; for (u32 i=0; i<N; i++) { NodeLink id; u16 pl; SNodePositionOld _np; NodePosition np; for (int j=0; j<4; ++j) { F->r (&id,3); g_nodes[i].n[j] = (*LPDWORD(&id)) & 0x00ffffff; } pl = F->r_u16(); pvDecompress (g_nodes[i].Plane.n,pl); F->r (&_np,sizeof(_np)); CNodePositionConverter(_np,H,np); g_nodes[i].Pos = vertex_position(np,LevelBB,g_params); g_nodes[i].Plane.build(g_nodes[i].Pos,g_nodes[i].Plane.n); } F->close (); if (!strstr(Core.Params,"-keep_temp_files")) DeleteFile (file_name); } }
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); }