//读取设置,一般不用调用,在本ARX初化时会调用 bool INISetting::ReadFile() { int i; CString sFilePath; CStringArray aKey; CStringArray aValue; PtrStruct *pWillAdd; sFilePath=m_sINIFilePath; m_aAppNameArray.RemoveAll(); // DPrintf("\n ***当前的设置文件是 %s\n",sFilePath); //2003.3.6 //-------------->>>>何永平 加入求文件长度 CFileStatus fs; if (CFile::GetStatus(sFilePath,fs) == FALSE) return false; if (m_pBuffer != NULL) delete [] m_pBuffer; m_pBuffer=new char[int(fs.m_size*1.5)]; if (m_pBuffer == NULL) { CString sPrompt; sPrompt.Format("ini文件分配内存错!\n[%d]字节",int(fs.m_size*1.2)); AfxMessageBox(sPrompt); } //清空全局变量 //读取所有字段 if (GetPrivateProfileSectionNames(m_pBuffer,INIBUFFERLENGTH-3,sFilePath) && Get00Strings(m_pBuffer,m_aAppNameArray)) { //清空过去的映射 ClearMap(); //下面读取所有字段 for (i=0;i<m_aAppNameArray.GetSize();i++) { aKey.RemoveAll(); aValue.RemoveAll(); pWillAdd=new PtrStruct; //读入字段,并把KEY 转为大写 if (ReadIni(m_aAppNameArray[i],pWillAdd->Data,sFilePath)) { CString sKey=m_aAppNameArray[i]; sKey.MakeUpper(); pWillAdd->sAppName=sKey; //加入到映射 m_mapStringToMap.SetAt(sKey,pWillAdd); // DPrintf("\n ***读取 %s %d个",pWillAdd->sAppName,pWillAdd->Data.GetCount()); } else { delete pWillAdd; // DPrintf("\n ***读取 %s 的 [%s]失败!\n",sFilePath,m_aAppNameArray[i]); ;//这个是空句,至于用处嘛 …… } } } return !m_mapStringToMap.IsEmpty(); }
int main (void) { StartCurses(); DrawMenu(); Level lvl; TowerList tList; // Tower List UnitList uList; // Unit List UnitList sQueue; // Spawn queue PathList pList; // Path list UnitList PDUL; // Initializing variables TowerInitialize(&tList); UnitInitialize(&uList); UnitInitialize(&sQueue); UnitInitialize(&PDUL); PathInitialize(&pList); ReadStandardUnits(&PDUL); ReadFile(1, &tList, &pList, &lvl); DrawAvailableUnits(&lvl,&PDUL); refresh(); DrawMap(&tList,&pList); PrintArrows(&pList); PrintUnitSelection(); ClearMap(); LeaderBoard(); getchar(); EndCurses(); }
BOOL CeRepMapEditorDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd()); if (!pFrame) return FALSE; ClearMap(); int i,j; m_piiSize.first = m_piiSize.second = 10; for(i=0; i<m_piiSize.first; i++) for(j=0; j<m_piiSize.second; j++) { piiPair pp = make_pair(i,j); CMapItem* item = new CMapItem; item->m_piiIndex = pp; item->m_iType = MODE_PLAIN; item->m_iSubType = 0; item->m_iBuilding = 0; m_Elements.insert(make_pair(pp,item)); } CalcNeibs(); CString sBuf; sBuf.Format(_T("%d"),m_piiSize.first); pFrame->m_WEdit->SetEditText(sBuf); sBuf.Format(_T("%d"),m_piiSize.second); pFrame->m_HEdit->SetEditText(sBuf); m_scale = 1; sBuf.Format(_T("%d %%"),int(m_scale*100)); pFrame->m_SEdit->SetEditText(sBuf); return TRUE; }
void StageLose(void) { clear(); DrawMenu(); ClearWindows(); attron(COLOR_PAIR(11)); mvprintw(21,28," __ "); mvprintw(22,28," | |"); mvprintw(23,28," _____ _ _____ _ _ _ | |"); mvprintw(24,28,"| __| |_ ___ ___ ___ | __|___|_| |___ _| | |__|"); mvprintw(25,28,"|__ | _| .'| . | -_| | __| .'| | | -_| . | __ "); mvprintw(26,28,"|_____|_| |__,|_ |___| |__| |__,|_|_|___|___| |__|"); mvprintw(27,28," |___| "); attroff(COLOR_PAIR(11)); refresh(); LoadStage('l'); attron(A_BOLD); mvprintw(32,54,"Done!"); attroff(A_BOLD); refresh(); usleep(500000); ClearMap(); curs_set(1); }
INISetting::~INISetting() { // DPrintf(" \n ##### 析构 INISetting 对象 %s",m_sINIFilePath); ClearMap(); if (m_pBuffer != NULL) delete [] m_pBuffer; };
Tilemap::~Tilemap() { if (grid) destroy_bitmap(grid); if (citizen_saved) destroy_bitmap(citizen_saved); if (blood) destroy_bitmap(blood); ClearMap(); }
CWorldDbmgr::~CWorldDbmgr() { ClearMap(m_avatars4LookupByAccount); { map<string, map<TDBID, SEntityLookup*>*>::iterator iter = m_entities4LookupByDbid.begin(); for(; iter != m_entities4LookupByDbid.end(); ++iter) { ClearMap(*(iter->second)); } ClearMap(m_entities4LookupByDbid); } { map<string, map<string, SEntityLookup*>*>::iterator iter = m_entities4LookupByName.begin(); for(; iter != m_entities4LookupByName.end(); ++iter) { ClearMap(*(iter->second)); } ClearMap(m_entities4LookupByName); } }
CMapBlocks::~CMapBlocks() { ClearMap(); if (m_pFileCreater != NULL) { delete m_pFileCreater; m_pFileCreater = NULL; } if (m_pDriveReader != NULL) { delete m_pDriveReader; m_pDriveReader = NULL; } }
far GenerateMap() { GRanArray[0] = TickCount(); /* This is the only machine-specific call */ /* It inits GRand() w/ clockcount(long) */ if (!(GRand(10))) { /* 1 in 3 chance that island is generated */ MakeIsland(); return; } ClearMap(); /* else make river map */ GetRandStart(); DoRivers(); MakeLakes(); SmoothRiver(); DoTrees(); }
bool CCastingProcessCfgClient::LoadConfig(const TCHAR* cfgFile) { CSkillCfg::InitMapCastingType(); CSkillCfg::InitMapCastingInterruptType(); CTxtTableFile TabFile; CCastingProcessCfgClient* pCfgNode; if (!TabFile.Load(PATH_ALIAS_CFG.c_str(), cfgFile)) return false; ClearMap(m_mapCfgById); for(int32 i=1; i<TabFile.GetHeight(); i++) { pCfgNode = new CCastingProcessCfgClient; pCfgNode->m_uId = i; pCfgNode->m_sName = TabFile.GetString(i,szCasting_Name); trimend(pCfgNode->m_sName); string strCastingType = TabFile.GetString(i, szCasting_Type); trimend(strCastingType); pCfgNode->m_eCastingType = CSkillCfg::ms_mapCastingType[strCastingType]; pCfgNode->m_pCastingTime = new CCfgCalc(); string sCastingTime = TabFile.GetString(i, szCastingTime); trimend(sCastingTime); pCfgNode->m_pCastingTime->InputString(sCastingTime) ; pCfgNode->m_sProcessAction = TabFile.GetString(i, szProcessAction); trimend(pCfgNode->m_sProcessAction); pCfgNode->m_sProcessEffect = TabFile.GetString(i, szProcessEffect); trimend(pCfgNode->m_sProcessEffect); //ReadItem(pCfgNode->m_bMoveInterrupt, szCasting_MoveInterrupt, CANEMPTY, NO); string strMoveInterrupt = TabFile.GetString(i,szCasting_InterruptType); trimend(strMoveInterrupt); pCfgNode->m_eCastingInterruptType = CSkillCfg::ms_mapCastingInterruptType[strMoveInterrupt]; string strLinkEffect = TabFile.GetString(i,szLinkEffect); trimend(strLinkEffect); pCfgNode->m_bLinkEffect= strLinkEffect.compare("ÊÇ") == 0 ? true : false; CCastingProcessCfgClientSharedPtr* pCfgNodeSharedPtr = new CCastingProcessCfgClientSharedPtr(pCfgNode); m_mapCfgById.insert(make_pair(pCfgNode->m_uId, pCfgNodeSharedPtr)); m_mapCfgByName.insert(make_pair(pCfgNode->m_sName, pCfgNodeSharedPtr)); } return true; }
bool CPositionMagicCfgClient::LoadConfig(const TCHAR* cfgFile) { CTxtTableFile TabFile; CPositionMagicCfgClient* pCfgNode; if (!TabFile.Load(PATH_ALIAS_CFG.c_str(), cfgFile)) return false; ClearMap(m_mapCfgById); for(int32 i=1; i<TabFile.GetHeight(); i++) { pCfgNode = new CPositionMagicCfgClient; pCfgNode->m_uId = i; pCfgNode->m_sFX = TabFile.GetString(i, szMagic_FxName); trimend(pCfgNode->m_sFX); CPositionMagicCfgClientSharedPtr* pCfgNodeSharedPtr = new CPositionMagicCfgClientSharedPtr(pCfgNode); m_mapCfgById.insert(make_pair(pCfgNode->m_uId, pCfgNodeSharedPtr)); } return true; }
bool CCubeGame::CheckBumpItemAndMap() { //这里是碰撞检测 //首先是判断是不是到了底边? if(m_Current_Cubeitem_RowNum < 1) { //判断CurrentCubItem是不是能够下移动? for (int i = 0 ; i < 4; i++) { if ((m_Current_Cubeitem_RowNum+ i) == 0 ) { for (int j = 0 ; j < 4; j++) { //判断Cubeitem是不是有东西的点碰到底边了 if (m_Current_Cubeitem->c[i][j] && (!m_Map[m_Current_Cubeitem_RowNum +i][m_Current_Cubeitem_ColNum + j])) return true; } } } }else //没有到最低边 { //判断CurrentCubItem是不是能够下移动? for (int i = 0 ; i < 4; i++) { for (int j = 0 ; j < 4; j++) { //判断Cubeitem是不是有东西的点碰到东西了? if (m_Current_Cubeitem_RowNum + i >= cMapRows) break; if (m_Current_Cubeitem_RowNum + i - 1 >= cMapRows) break; if(m_Current_Cubeitem->c[i][j] && (m_Map[m_Current_Cubeitem_RowNum + i-1][m_Current_Cubeitem_ColNum+j ])) return true; } } } ClearMap(); return false; }
bool IsoBarMap::Recompute(wxWindow *parent) { /* clear out old data */ ClearMap(); m_bComputing = true; #if 1 wxProgressDialog *progressdialog = NULL; wxDateTime start = wxDateTime::Now(); #endif int cachepage = 0; m_Cache[0].Initialize(m_Step); m_Cache[1].Initialize(m_Step); double min = -MAX_LAT, max = MAX_LAT; BuildParamCache(m_Cache[cachepage], min); double lastupdate = min; for(double lat = min; lat + m_Step <= max; lat += m_Step) { if(m_bNeedsRecompute) { delete progressdialog; return false; } if(lat - lastupdate > 8) { lastupdate = lat; if(progressdialog) { if(!progressdialog->Update(lat - min)) { delete progressdialog; return false; } } else { wxDateTime now = wxDateTime::Now(); if((now-start).GetMilliseconds() > 500 && lat < (max - min)/2) { progressdialog = new wxProgressDialog( _("Building Isobar Map"), m_Name, max - min + 1, parent, wxPD_ELAPSED_TIME | wxPD_CAN_ABORT); } } } cachepage = !cachepage; BuildParamCache(m_Cache[cachepage], lat+m_Step); int latind = floor((lat+MAX_LAT)/ZONE_SIZE); if(latind>LATITUDE_ZONES-1) latind = LATITUDE_ZONES-1; for(double lon = -180; lon+m_Step <= 180; lon += m_Step) { int lonind = floor((lon+180)/ZONE_SIZE); PlotRegion(m_map[latind][lonind], lat, lon, lat+m_Step, lon+m_Step); } } delete progressdialog; m_bComputing = false; m_MinContour /= m_Spacing; m_MinContour = floor(m_MinContour); m_MinContour *= m_Spacing; m_MaxContour /= m_Spacing; m_MaxContour = ceil(m_MaxContour); m_MaxContour *= m_Spacing; if(isnan(m_MaxContour) || isnan(m_MinContour)) m_contourcachesize = 0; else m_contourcachesize = (m_MaxContour - m_MinContour) / m_Spacing + 1; m_contourcache = new ContourBitmap[m_contourcachesize]; for(int i=0; i<m_contourcachesize; i++) m_contourcache[i] = ContourCacheData(m_MinContour + i*m_Spacing); return true; }
IsoBarMap::~IsoBarMap() { ClearMap(); }
void CPositionMagicCfgClient::UnloadConfig() { ClearMap(m_mapCfgById); }
void CCastingProcessCfgClient::UnloadConfig() { ClearMap(m_mapCfgById); }
CWorldMgrD::~CWorldMgrD() { ClearMap(m_globalBases); }
void CRivalStateMgr::ClearAll() { ClearMap(m_mapRivalCategory); }
CDefParser::~CDefParser() { delete[] m_typeInt2Str; ClearMap(m_entityDefs); }
CRpcUtil::~CRpcUtil() { ClearMap(m_methods); }
void CSoundCDTimeMgr::OnDestroy() { ClearMap(ms_mapSoundWithCD); }
CeRepMapEditorDoc::~CeRepMapEditorDoc() { ClearMap(); }
// // LoadMap // void Raycaster::LoadMap(const char *filename) { int i, j; FILE *fp; char c, errMsg[MAX_STR_LENGTH]; mapChange = false; ClearMap(); doors.clear(); mapH = framework->CountRowsInFile(filename); mapW = framework->CountColsInFile(filename); fp = fopen(filename, "r"); if(!fp) { sprintf(errMsg, "Can't load file: %s!", filename); framework->Error(errMsg); } for(i=0; i<mapH; i++) { for(j=0; j<mapW; j++) { c = fgetc(fp); while(!IS_VALID_CHAR(c) && !feof(fp)) c = fgetc(fp); if(feof(fp) || !IS_VALID_CHAR(c)) break; if(c >= '0' && c <= '9') map[i][j] = c - '0'; else if(c >= 'A' && c <= 'Z') map[i][j] = c - 'A' + 10; else if(c >= 'a' && c <= 'z') { if(c == 'z') { posX = j + 0.5f; posY = i + 0.5f; map[i][j] = 0; } else map[i][j] = c - 'a' + 36; } if(map[i][j] == DOOR_INDEX) { Door door(j, i, this); doors.push_back(door); } else if(map[i][j] == LOCKED_DOOR_INDEX) { Door door(j, i, this, true); doors.push_back(door); } } } fclose(fp); }
CEntityParent::~CEntityParent() { //cout << "CEntity::~CEntity: " << m_id << endl; ClearMap(m_data); }
void MapEditor::LoadMapgen(const std::string &name) { std::fstream sfile; sfile.open(name, std::ios_base::in); if(sfile.fail()) { SYSTEM_STREAM << "Error open " << name << std::endl; return; } ClearMap(); std::stringstream ss; sfile.seekg (0, std::ios::end); std::streamoff length = sfile.tellg(); sfile.seekg (0, std::ios::beg); char* buff = new char[static_cast<size_t>(length)]; sfile.read(buff, length); sfile.close(); ss.write(buff, length); delete[] buff; int x, y, z; ss >> x; ss >> y; ss >> z; Resize(x, y, z); while (ss) { std::string t_item; size_t x, y, z; ss >> t_item; if (!ss) { continue; } ss >> x; if (!ss) { continue; } ss >> y; if (!ss) { continue; } ss >> z; if (!ss) { continue; } MapEditor::EditorEntry* ee; if (turf_types_.find(t_item) != turf_types_.end()) { ee = &SetTurf(t_item, x, y, z); } else { ee = &AddItem(t_item, x, y, z); } WrapReadMessage(ss, ee->variables); // TODO UpdateDirs(ee); } }
CMsgRoute::~CMsgRoute() { ClearMap(m_Mappings); ClearMap(m_ThreadMappings); }
int asCGarbageCollector::IdentifyGarbageWithCyclicRefs() { for(;;) { switch( detectState ) { case clearCounters_init: { ClearMap(); detectState = clearCounters_loop; detectIdx = 0; } break; case clearCounters_loop: { // Build a map of objects that will be checked, the map will // hold the object pointer as key, and the gcCount and the // object's type as value. As objects are added to the map the // gcFlag must be set in the objects, so we can be verify if // the object is accessed during the GC cycle. // If an object is removed from the gcObjects list during the // iteration of this step, it is possible that an object won't // be used during the analyzing for cyclic references. This // isn't a problem, as the next time the GC cycle starts the // object will be verified. while( detectIdx < gcObjects.GetLength() ) { // Add the gc count for this object asSObjTypePair gcObj = GetObjectAtIdx(detectIdx); int refCount = engine->CallObjectMethodRetInt(gcObj.obj, gcObj.type->beh.gcGetRefCount); if( refCount > 1 ) { asSIntTypePair it = {refCount-1, gcObj.type}; gcMap.Insert(gcObj.obj, it); // Increment the object's reference counter when putting it in the map engine->CallObjectMethod(gcObj.obj, gcObj.type->beh.addref); // Mark the object so that we can // see if it has changed since read engine->CallObjectMethod(gcObj.obj, gcObj.type->beh.gcSetFlag); detectIdx++; // Let the application work a little return 1; } else detectIdx++; } detectState = countReferences_init; } break; case countReferences_init: { detectIdx = (asUINT)-1; gcMap.MoveFirst(&gcMapCursor); detectState = countReferences_loop; } break; case countReferences_loop: { // Call EnumReferences on all objects in the map to count the number // of references reachable from between objects in the map. If all // references for an object in the map is reachable from other objects // in the map, then we know that no outside references are held for // this object, thus it is a potential dead object in a circular reference. // If the gcFlag is cleared for an object we consider the object alive // and referenced from outside the GC, thus we don't enumerate its references. // Any new objects created after this step in the GC cycle won't be // in the map, and is thus automatically considered alive. while( gcMapCursor ) { void *obj = gcMap.GetKey(gcMapCursor); asCObjectType *type = gcMap.GetValue(gcMapCursor).type; gcMap.MoveNext(&gcMapCursor, gcMapCursor); if( engine->CallObjectMethodRetBool(obj, type->beh.gcGetFlag) ) { engine->CallObjectMethod(obj, engine, type->beh.gcEnumReferences); // Allow the application to work a little return 1; } } detectState = detectGarbage_init; } break; case detectGarbage_init: { detectIdx = (asUINT)-1; gcMap.MoveFirst(&gcMapCursor); liveObjects.SetLength(0); detectState = detectGarbage_loop1; } break; case detectGarbage_loop1: { // All objects that are known not to be dead must be removed from the map, // along with all objects they reference. What remains in the map after // this pass is sure to be dead objects in circular references. // An object is considered alive if its gcFlag is cleared, or all the // references were not found in the map. // Add all alive objects from the map to the liveObjects array while( gcMapCursor ) { asSMapNode<void*, asSIntTypePair> *cursor = gcMapCursor; gcMap.MoveNext(&gcMapCursor, gcMapCursor); void *obj = gcMap.GetKey(cursor); asSIntTypePair it = gcMap.GetValue(cursor); bool gcFlag = engine->CallObjectMethodRetBool(obj, it.type->beh.gcGetFlag); if( !gcFlag || it.i > 0 ) { liveObjects.PushLast(obj); // Allow the application to work a little return 1; } } detectState = detectGarbage_loop2; } break; case detectGarbage_loop2: { // In this step we are actually removing the alive objects from the map. // As the object is removed, all the objects it references are added to the // liveObjects list, by calling EnumReferences. Only objects still in the map // will be added to the liveObjects list. while( liveObjects.GetLength() ) { void *gcObj = liveObjects.PopLast(); asCObjectType *type = 0; // Remove the object from the map to mark it as alive asSMapNode<void*, asSIntTypePair> *cursor = 0; if( gcMap.MoveTo(&cursor, gcObj) ) { type = gcMap.GetValue(cursor).type; gcMap.Erase(cursor); // We need to decrease the reference count again as we remove the object from the map engine->CallObjectMethod(gcObj, type->beh.release); // Enumerate all the object's references so that they too can be marked as alive engine->CallObjectMethod(gcObj, engine, type->beh.gcEnumReferences); } // Allow the application to work a little return 1; } detectState = verifyUnmarked; } break; case verifyUnmarked: { // In this step we must make sure that none of the objects still in the map // has been touched by the application. If they have then we must run the // detectGarbage loop once more. gcMap.MoveFirst(&gcMapCursor); while( gcMapCursor ) { void *gcObj = gcMap.GetKey(gcMapCursor); asCObjectType *type = gcMap.GetValue(gcMapCursor).type; bool gcFlag = engine->CallObjectMethodRetBool(gcObj, type->beh.gcGetFlag); if( !gcFlag ) { // The unmarked object was touched, rerun the detectGarbage loop detectState = detectGarbage_init; return 1; } gcMap.MoveNext(&gcMapCursor, gcMapCursor); } // No unmarked object was touched, we can now be sure // that objects that have gcCount == 0 really is garbage detectState = breakCircles_init; } break; case breakCircles_init: { detectIdx = (asUINT)-1; gcMap.MoveFirst(&gcMapCursor); detectState = breakCircles_loop; } break; case breakCircles_loop: case breakCircles_haveGarbage: { // All objects in the map are now known to be dead objects // kept alive through circular references. To be able to free // these objects we need to force the breaking of the circle // by having the objects release their references. while( gcMapCursor ) { numDetected++; void *gcObj = gcMap.GetKey(gcMapCursor); asCObjectType *type = gcMap.GetValue(gcMapCursor).type; engine->CallObjectMethod(gcObj, engine, type->beh.gcReleaseAllReferences); gcMap.MoveNext(&gcMapCursor, gcMapCursor); detectState = breakCircles_haveGarbage; // Allow the application to work a little return 1; } // If no garbage was detected we can finish now if( detectState != breakCircles_haveGarbage ) { // Restart the GC detectState = clearCounters_init; return 0; } else { // Restart the GC detectState = clearCounters_init; return 1; } } break; } // switch } // Shouldn't reach this point UNREACHABLE_RETURN; }
void CModelInfoClient::UnloadConfig() { ClearMap(ms_mapModelInfo); }
CWorldCrossserver::~CWorldCrossserver() { ClearMap(m_InRpc); ClearMap(m_globalBases); }
void CTextures::ChangeMap(unsigned int ID) { ClearMap(); SetMap(ID); }