void EDetailManager::AppendIndexObject(u32 color,LPCSTR name, bool bTestUnique) { if (bTestUnique){ EDetail* DO = FindObjectInColorIndices(color,name); if (DO) m_ColorIndices[color].push_back(DO); }else{ EDetail* DO = FindDOByName(name); R_ASSERT(DO); m_ColorIndices[color].push_back(DO); } }
EDetail* EDetailManager::AppendDO(LPCSTR name, bool bTestUnique) { EDetail* D=0; if (bTestUnique&&(0!=(D=FindDOByName(name)))) return D; D = xr_new<EDetail>(); if (!D->Update(name)){ xr_delete(D); return 0; } objects.push_back (D); InvalidateCache (); return D; }
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; }