uint32 CFightRecordDC::Get( uint32 guid, SFightRecord &fight_record ) { uint32 _time = GuidToTime( guid ); if ( 0 == _time ) return kErrFightLogNotFind; //先找在不在保存列表里面 std::map<uint32,TFightRecordMap>::iterator iter = db().fight_record_map.find( _time ); if ( iter == db().fight_record_map.end() ) { //再没找到就去load文件 uint32 ret = LoadRecord( _time ); if ( 0 != ret ) return ret; iter = db().fight_record_map.find( _time ); if ( iter == db().fight_record_map.end() ) return kErrFightLogNotFind; } TFightRecordMap &fightrecord_list = iter->second; TFightRecordMap::iterator iter2 = fightrecord_list.find(guid); if ( iter2 != fightrecord_list.end() ) { iter2->second.position(0); iter2->second >> fight_record; db().fight_record_access_map[_time] = (uint32)time(NULL); }
/************************************************************************* *从职员表文件中读取记录到内存 *************************************************************************/ int LoadCollectRecord(int IsFirst) { int ret = LoadRecord(PARACOLLECT_FILE,&CollectHead,LENGHT_MSG_COLLECT,ParseRecordCollect,FRAE,IsFirst); //echoic("LoadCollectRecord = <%s> ",PARACOLLECT_FILE); strncpy(GetMsgRevision()->CollectVer,CollectHead.VerNo,2); return ret; }
void Board::Restart() { needCheckLines_ = false; needSpawnBalls_ = false; gameOver_ = false; for (int i = 0; i < height_; i++) { for (int j = 0; j < width_; j++) { if (board_[i][j]) { board_[i][j]->GetNode()->Remove(); board_[i][j] = nullptr; } } } selectedBall_ = nullptr; LoadRecord(); for (int i = 0; i < numAddBalls_; i++) SpawnBall(); if (difficulty_ <= D_NORMAL) { for (int i = 0; i < numAddBalls_; i++) CreateBall(true); } score_ = 0; }
int LoadYPKListRecord(int IsFirst) { int ret=0; ret= LoadRecord(PARAYPKLIST_FILE,&YPKListHead,YPKListSTRLENGTH,ParseRecordYPKList,FRAE,IsFirst); strncpy(GetMsgRevision()->YPKListVer,YPKListHead.VerNo,2); return ret; }
bool RecorderScenario::LoadElement(const apr_xml_elem* pElem, apr_pool_t* pool) { if(UmcScenario::LoadElement(pElem,pool)) return true; if(strcasecmp(pElem->name,"record") == 0) { LoadRecord(pElem,pool); return true; } return false; }
unsigned FlarmNetReader::LoadFile(NLineReader &reader, FlarmNetDatabase &database) { /* skip first line */ const char *line = reader.ReadLine(); if (line == NULL) return 0; int itemCount = 0; while ((line = reader.ReadLine()) != NULL) { FlarmNetRecord record; if (LoadRecord(record, line)) { database.Insert(record); itemCount++; } } return itemCount; }
size_t RecordRead(RecordReader* reader, FILE* stream, void* buf, size_t amount) { size_t i = 0; while(i < amount) { size_t remaining = reader->dataSize - reader->dataIndex; if(remaining > 0) { size_t read = amount - i < remaining ? amount - i : remaining; GetRecordData(reader, stream, buf + i, read); i += read; } else if(LoadRecord(reader, stream)) { return i; } } return i; }
unsigned FLARMNetDatabase::LoadFile(NLineReader &reader) { /* skip first line */ const char *line = reader.read(); if (line == NULL) return 0; int itemCount = 0; while ((line = reader.read()) != NULL) { FLARMNetRecord *record = new FLARMNetRecord; LoadRecord(line, record); insert(value_type(record->GetId(), record)); itemCount++; }; return itemCount; }
void Board::Init(Difficulty difficulty) { SetDifficulty(difficulty); node_->SetPosition(Vector3(0.0f, 0.0f, Max(width_, height_) * 2.8f)); needCheckLines_ = false; needSpawnBalls_ = false; gameOver_ = false; score_ = 0; record_ = 0; board_.Resize(height_); cells_.Resize(height_); for (int i = 0; i < height_; i++) { board_[i].Resize(width_); cells_[i].Resize(width_); for (int j = 0; j < width_; j++) { Node* cellNode = node_->CreateChild(); Cell* cell = cellNode->CreateComponent<Cell>(); Vector3 targetPos = IV2ToV3(IntVector2(j, i)); Vector3 startPos = Vector3(Random(-50.0f, 50.0f), Random(-50.0f, 50.0f), Random(-50.0f, 50.0f)); cell->Init(startPos, targetPos, IntVector2(j, i)); cells_[i][j] = cell; } } for (int i = 0; i < numAddBalls_; i++) SpawnBall(); if (difficulty_ <= D_NORMAL) { for (int i = 0; i < numAddBalls_; i++) CreateBall(true); } InitSelection(); LoadRecord(); }
void init() { long i,j,k,r,w; long t; nnx=-1,nny=-1,over=0,tn=0; t = time(NULL); srand(t); memset(map,0,sizeof(map)); xn = (CL-BL) / SIDE; yn = (CH-BH) / SIDE; memset(map,0,sizeof(map)); now = 1 ; win = 0; LoadRecord(); cleardevice(); FlushMouseMsgBuffer(); if(DB) { move(7,7,2); now = 1;} //load(); QiPan(); }
void main() { int i; char s[128]; struct ADDRESS address[MAX];/*定义结构体数组*/ int num;/*保存记录数*/ clrscr(); while(1) { clrscr(); printf("********************MENU*******************\n\n"); printf("| 0: Input records |\n"); printf("| 1: List records in the file |\n"); printf("| 2: Delete a record |\n"); printf("| 3: Insert a record to the list |\n"); printf("| 4: Save records to the file |\n"); printf("| 5: Load records from the file |\n"); printf("| 6: Quit |\n\n"); printf("*******************************************\n"); do{ printf("\n Input your choice(0~6):"); /*提示输入选项*/ scanf("%s",s); /*输入选择项*/ i=atoi(s); /*将输入的字符串转化为整型数*/ }while(i<0||i>6); /*选择项不在0~11之间重输*/ switch(i) /*调用主菜单函数,返回值整数作开关语句的条件*/ { case 0:num=InputRecord(address);break;/*输入记录*/ case 1:ListRecord(address,num);break; /*显示全部记录*/ case 2:num=DeleteRecord(address,num);break; /*删除记录*/ case 3:num=InsertRecord(address,num); break; /*插入记录*/ case 4:SaveRecord(address,num);break; /*保存文件*/ case 5:num=LoadRecord(address); break; /*读文件*/ case 6:exit(0); /*如返回值为11则程序结束*/ } } }
void CRacingFrame::CoreFrame() { while(1){ system("CLS"); IntroScreen(); cout<<"Input your choice:"; int choice; cin>>choice; switch (choice) { case 1: { if(PlayerCar!=NULL) delete PlayerCar; PlayerCar=NULL; RunGame(); system("CLS"); char yes_no=' '; while(yes_no!='y'&&yes_no!='n'){ fflush(stdin); cout<<"Do you want to save your record?(y/n):"; cin>>yes_no; } if(yes_no=='y') { LoadRecord(); string _Name; fflush(stdin); cout<<"Input your name:"; getline(cin,_Name); CPlayer record_after_play(_Name,PlayerCar->getCarType(),Point); Player_Record.push_back(record_after_play); SortScore(); SaveRecord(); } if(yes_no=='n') { fflush(stdin); Sleep(500); } break; } case 2: { CMapRacing::SetColor(2); LoadRecord(); ShowRecord(); CMapRacing::SetColor(0); break; } case 3: { CMapRacing::SetColor(3); CustomCar(); CMapRacing::SetColor(0); break; } case 4: break; default: { cout<<"Oopp! You got a wrong choice!"; Sleep(500); break; } } if(choice==4) { system("CLS"); cout<<"You was out of game"; Sleep(500); break; } } }
void CFightRecordDC::Init() { //添加定时器 theSysTimeMgr.AddLoop ( "clear_timeout_record", "", NULL, NULL, CSysTimeMgr::Minute, 1, 0 ); if ( 0 != db().is_init ) return; //创建目录 不管存在与否都创建目录 std::string path = settings::json()["fightlog_path"].asString(); mkdir(path.c_str(), 664 ); //读取guid time文件 std::string _file_name = path + "/guidtime.dat"; const char* file_name = _file_name.c_str(); //设置version db().version = sizeof(SFightRecord) + sizeof(SFightPlayerInfo) + sizeof( SFightSoldier ) + sizeof(SFightLog) + sizeof(SFightOrderTarget); db().fight_record_id = 1; db().is_init = 1; FILE *inFile = fopen( file_name, "rb" ); if ( NULL == inFile ) return; uint32 &fight_record_id = db().fight_record_id; if ( fread( &fight_record_id, 1, sizeof( uint32 ), inFile ) != sizeof( uint32 ) ) return; uint32 time_now = (uint32)time(NULL); uint32 _time = TimeToTime( time_now ); for(;;) { uint32 time = 0; if ( fread( &time, 1, sizeof( uint32 ), inFile ) != sizeof( uint32 ) ) break; if ( 0 == time ) break; if ( time_now < time ) break; //超过30天的记录 不加载 if ( time_now - time > 3600 * 24 * 30 ) continue; S2UInt32 guid; if ( fread( &guid.first, 1, sizeof( uint32 ), inFile ) != sizeof( uint32 ) ) break; if ( 0 == guid.first ) break; if ( fread( &guid.second, 1, sizeof( uint32 ), inFile ) != sizeof( uint32 ) ) break; if ( 0 == guid.second) break; db().fight_guid_time_map[time] = guid; } //加载当前时间的记录 LoadRecord(_time ); }
void RecordReaderInit(RecordReader* reader, FILE* stream, objsize_t firstOffset) { reader->nextOffset = firstOffset; LoadRecord(reader, stream); }