/* ----------------------------------------------------------------------------- FUNCTION NAME: void Record_Sort(CLI *, database *, fstream *, char *, char *) PURPOSE: loads classes into vector, and if needs to redo the output file RETURNS: void NOTES: ----------------------------------------------------------------------------- */ void Record_Sort(Command_line_Record * GivenChars, fstream * databasefile, char *Filename, char *Reportname) { Open_File(Filename, databasefile); //all functions require that this file is opened. vector<database> Records(1); //create vector for database entries, and make at least one empty one. int n=-1, i = 0; // n = for do loop only i = number of records that were opened. bool change_file = false; //T/F check to determin if vector has changed do{ // load file into class vector. i++; Records.resize(i); n++; *databasefile >> Records[n]; }while ((*databasefile).eof() == 0); //run until end of file VERBOSE(3) << "loaded file\n"; databasefile->close(); if (GivenChars->add_acount_true() == 1) // check to see if adding account { Add_Account(GivenChars, Records, &i, &n); change_file = true; } else if (GivenChars->Arg_Given[Command_line_Record::reportfile] == true) { Print_Report(Reportname, Records, &i); } else if (GivenChars->transfer() == 1) { Funds_Transfer_Add(Records, GivenChars); change_file = true; } else if (GivenChars->Arg_Given[Command_line_Record::deleaccnt] == true) { n = Delete_Account(Records, GivenChars, &i); if (n>=0) { Records.erase(Records.begin()+n); change_file = true; VERBOSE(3) << "Account Deleted.\n"; } } else { for (n=0; n<i; n++) { database *rec = &Records[n]; //create pointer to current vector location if ((!strncmp(GivenChars->Get_Account(), rec->Get_Account(), 5)) && (!strncmp(GivenChars->Get_PassWd(), rec->Get_PassWd(), 6))) //check that account number and password match { CLI_Sort(GivenChars, rec, &change_file); } } } if (change_file == true) //if a record was chaged, rewrite the output file { databasefile->open(Filename, ios::out | ios::trunc); for (n=0;n<i;n++) { *databasefile << Records[n]; } databasefile->close(); } }
//! Virtual Function to prepare labels for writing void Table::WriteInit() { p_blobPvl["Records"] = toString(Records()); p_nbytes = Records() * RecordSize(); if (Isis::IsLsb()) { p_blobPvl["ByteOrder"] = Isis::ByteOrderName(Isis::Lsb); } else { p_blobPvl["ByteOrder"] = Isis::ByteOrderName(Isis::Msb); } if (p_blobPvl.hasKeyword("Association")) { p_blobPvl.deleteKeyword("Association"); } if (p_assoc == Samples) { p_blobPvl += Isis::PvlKeyword("Association", "Samples"); } else if (p_assoc == Lines) { p_blobPvl += Isis::PvlKeyword("Association", "Lines"); } else if (p_assoc == Bands) { p_blobPvl += Isis::PvlKeyword("Association", "Bands"); } }
// Show that an error occurs when writing a bitcode record that isn't // in any block. TEST(NaClMungeWriteErrorTests, CantWriteRecordOutsideBlock) { const uint64_t Edit[] = { LastExitBlockIndex, NaClMungedBitcode::AddAfter, naclbitc::UNABBREV_RECORD, naclbitc::MODULE_CODE_VERSION, 4, Terminator }; std::string Records(ExpectedRecords); Records.append( " 1: [65535, 4294967295, 3]\n" " 3: [1, 4]\n" " 0: [65534]\n"); CheckWriteEdits( ARRAY(Edit), "Error (Block unknown): Record outside block: 3: [1, 4]\n", "Error (Block unknown): Missing close block.\n", Records); }
void Museum(char plr) { int i, tots = 7, beg; char AName[7][22] = {"DIRECTOR RANKING", "SPACE HISTORY", "MISSION RECORDS", "PRESTIGE SUMMARY", "HARDWARE EFFICIENCY", "ASTRONAUT HISTORY", "EXIT THE MUSEUM" }; char AImg[7] = {8, 9, 10, 11, 13, 14, 0}; if (Data->P[plr].AstroCount == 0) { memcpy(&AName[5][0], &AName[6][0], 22); // move up Exit AImg[5] = AImg[6]; tots = 6; } else if (plr == 1) { strncpy(&AName[5][0], "COSMO", 5); } AImg[3] += plr; // FadeOut(2,pal,10,0,0); music_start(M_THEME); beg = 0; do { if (beg == 0) { beg = (Data->P[plr].AstroCount > 0) ? 7 : 6; // mods for astros } else { FadeOut(2, display::graphics.palette(), 10, 0, 0); DrawSpaceport(plr); PortPal(plr); fill_rectangle(166, 191, 318, 198, 3); display::graphics.setForegroundColor(0); draw_string(257, 197, "CASH:"); draw_megabucks(285, 197, Data->P[plr].Cash); display::graphics.setForegroundColor(11); draw_string(256, 196, "CASH:"); draw_megabucks(284, 196, Data->P[plr].Cash); display::graphics.setForegroundColor(0); if (Data->Season == 0) { draw_string(166, 197, "SPRING 19"); } else { draw_string(166, 197, "FALL 19"); } draw_number(0, 0, Data->Year); display::graphics.setForegroundColor(11); if (Data->Season == 0) { draw_string(165, 196, "SPRING 19"); } else { draw_string(165, 196, "FALL 19"); } draw_number(0, 0, Data->Year); FadeIn(2, display::graphics.palette(), 10, 0, 0); } helpText = (plr == 0) ? "i700" : "i701"; keyHelpText = (plr == 0) ? "k603" : "k604"; i = BChoice(plr, tots, &AName[0][0], &AImg[0]); switch (i) { case 1: RankMe(plr); break; case 2: helpText = "i130"; keyHelpText = "k031"; ShowSpHist(plr); break; case 3: helpText = "i131"; keyHelpText = "k321"; Records(plr); break; case 4: helpText = "i132"; keyHelpText = "k033"; ShowPrest(plr); break; case 5: helpText = "i034"; ShowHard(plr); break; case 6: helpText = (plr == 0) ? "i133" : "i134"; keyHelpText = (plr == 0) ? "k035" : "k441"; if (Data->P[plr].AstroCount > 0) { ShowAstrosHist(plr); } break; case 7: default: break; } helpText = "i000"; keyHelpText = "k000"; } while (i != beg); music_stop(); return; }
/** * Virtual function to write the data * * @param os Outputstream to write the data to */ void Table::WriteData(std::fstream &os) { for (int rec = 0; rec < Records(); rec++) { os.write(p_recbufs[rec], RecordSize()); } }
RootController(ci::JsonTree& params, ci::TimelineRef timeline, Event<std::vector<Touch> >& touch_event) noexcept : params_(params), timeline_(timeline), ui_camera_(createCamera(params["ui_view.camera"])), fov_(ui_camera_.getFov()), near_z_(ui_camera_.getNearClip()), far_z_(ui_camera_.getFarClip()), autolayout_(ui_camera_), touch_event_(touch_event), view_creator_(params, timeline, ui_camera_, autolayout_, event_, touch_event), sound_(params["sounds"]), background_(Json::getColor<float>(params["app.background"])), records_(params["version"].getValue<float>()) { DOUT << "RootController()" << std::endl; event_.connect("begin-progress", [this](const Connection&, EventParam& param) noexcept { addController<ProgressController>(params_, timeline_, event_, view_creator_.create("ui_progress.json")); }); event_.connect("begin-gameover", [this](const Connection&, EventParam& param) noexcept { addController<GameoverController>(params_, timeline_, event_, param, view_creator_.create("ui_gameover.json")); }); event_.connect("begin-stageclear", [this](const Connection&, EventParam& param) noexcept { addController<StageclearController>(params_, timeline_, event_, param, view_creator_.create("ui_stageclear.json")); }); event_.connect("begin-pause", [this](const Connection&, EventParam& param) noexcept { addController<PauseController>(params_, timeline_, event_, view_creator_.create("ui_pause.json")); }); event_.connect("begin-records", [this](const Connection&, EventParam& param) noexcept { EventParam records = { { "total_play", records_.getTotalPlayNum() }, { "total_time", records_.getTotalPlayTime() }, { "high_score", records_.getHighScore() }, { "total_item", records_.getTotalItemNum() }, { "stage_ranks", records_.stageRanks() }, }; addController<RecordsController>(params_, timeline_, event_, records, view_creator_.create("ui_records.json")); }); event_.connect("begin-credits", [this](const Connection&, EventParam& param) noexcept { addController<CreditsController>(params_, timeline_, event_, view_creator_.create("ui_credits.json")); }); event_.connect("begin-title", [this](const Connection&, EventParam& param) noexcept { startTitle(param); }); event_.connect("begin-settings", [this](const Connection&, EventParam& param) noexcept { addController<SettingsController>(params_, timeline_, event_, records_, view_creator_.create("ui_settings.json")); }); event_.connect("begin-regulat-stageclear", [this](const Connection&, EventParam& param) noexcept { addController<AllStageClearController>(params_["regular_stageclear"], timeline_, event_, param, view_creator_.create("ui_regularstageclear.json")); }); event_.connect("begin-all-stageclear", [this](const Connection&, EventParam& param) noexcept { addController<AllStageClearController>(params_["all_stageclear"], timeline_, event_, param, view_creator_.create("ui_allstageclear.json")); }); // GameOver時に色々チェック event_.connect("check-after-gameover", [this](const Connection&, EventParam& param) noexcept { DOUT << "check-after-gameover" << std::endl; Rating::popup([this]() { AppSupport::pauseDraw(true); }, [this]() { AppSupport::pauseDraw(false); }); Achievment::atGameOver(records_); }); // サウンド再生 event_.connect("sound-play", [this](const Connection&, EventParam& param) noexcept { auto& name = boost::any_cast<const std::string&>(param.at("sound")); player_.play(name); // DOUT << "sound:" << name << std::endl; }); event_.connect("se-silent", [this](const Connection&, EventParam& param) noexcept { sound_.setBufferSilent(boost::any_cast<bool>(param["silent"])); }); event_.connect("bgm-silent", [this](const Connection&, EventParam& param) noexcept { sound_.setFileSilent(boost::any_cast<bool>(param["silent"])); }); #ifdef DEBUG event_.connect("force-regular-completed", [this](const Connection&, EventParam& param) noexcept { records_.forceRegularStageComplated(); }); event_.connect("cancel-regular-completed", [this](const Connection&, EventParam& param) noexcept { records_.cancelRegularStageComplated(); }); event_.connect("clear-records", [this](const Connection&, EventParam& param) noexcept { records_ = Records(params_["version"].getValue<float>()); }); event_.connect("do-snapshot", [this](const Connection&, EventParam& param) noexcept { auto surface = ci::app::copyWindowSurface(); auto full_path = getDocumentPath() / std::string("snapshot" + createUniquePath() + ".png"); ci::writeImage(full_path, surface); }); event_.connect("reset-records", [this](const Connection&, EventParam& param) noexcept { records_ = Records(params_["version"].getValue<float>()); }); event_.connect("reset-achievement", [this](const Connection&, EventParam& param) noexcept { DOUT << "reset-achievement" << std::endl; GameCenter::resetAchievement(); }); #endif records_.load(params["game.records"].getValue<std::string>()); sound_.setBufferSilent(!records_.isSeOn()); sound_.setFileSilent(!records_.isBgmOn()); addController<FieldController>(params, touch_event_, event_, records_); addController<IntroController>(params_, timeline_, event_, records_.getTotalPlayNum(), view_creator_.create("ui_intro.json")); // 自動PAUSE // getSignalDidEnterBackground(Backgroundになった直後) // getSignalWillResignActive(アクティブでなくなる直前) resign_active_ = ci::app::App::get()->getSignalWillResignActive().connect([this]() noexcept { DOUT << "SignalWillResignActive" << std::endl; EventParam params = { { "force", true } }; event_.signal("pause-agree", params); GameCenter::writeCachedAchievement(); }); }
void PATHMANAGER::Init(std::ostream & info_output, std::ostream & error_output, bool log_paths) { typedef std::vector<fs::path> Paths; // Set Ogre plugins dir { ogre_plugin = ""; char *plugindir = getenv("OGRE_PLUGIN_DIR"); if (plugindir) { ogre_plugin = plugindir; #ifndef _WIN32 } else if (fs::exists(fs::path(OGRE_PLUGIN_DIR) / "RenderSystem_GL.so")) { ogre_plugin = OGRE_PLUGIN_DIR; #endif } else { #ifdef _WIN32 ogre_plugin = "."; #else Paths dirs; #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(_M_X64) dirs.push_back("/usr/local/lib64"); dirs.push_back("/usr/lib64"); #else dirs.push_back("/usr/local/lib32"); dirs.push_back("/usr/lib32"); #endif dirs.push_back("/usr/local/lib"); dirs.push_back("/usr/lib"); // Loop through the paths and pick the first one that contain a plugin for (Paths::const_iterator p = dirs.begin(); p != dirs.end(); ++p) { if (fs::exists(*p / "OGRE/RenderSystem_GL.so")) { ogre_plugin = (*p / "OGRE").string(); break; } else if (fs::exists(*p / "ogre/RenderSystem_GL.so")) { ogre_plugin = (*p / "ogre").string(); break; } } #endif } } fs::path stuntrally = "stuntrally"; // Figure out the user's home directory { home_dir = ""; #ifndef _WIN32 // POSIX char *homedir = getenv("HOME"); if (homedir == NULL) { home_dir = "/home/"; homedir = getenv("USER"); if (homedir == NULL) { homedir = getenv("USERNAME"); if (homedir == NULL) { error_output << "Could not find user's home directory!" << std::endl; home_dir = "/tmp/"; } } } #else // Windows char *homedir = getenv("USERPROFILE"); if (homedir == NULL) homedir = "data"; // WIN 9x/Me #endif home_dir += homedir; } // Find user's config dir #ifndef _WIN32 // POSIX { char const* conf = getenv("XDG_CONFIG_HOME"); if (conf) user_config = (fs::path(conf) / stuntrally).string(); else user_config = (fs::path(home_dir) / ".config" / stuntrally).string(); } #else // Windows { // Open AppData directory std::string str; ITEMIDLIST* pidl; char AppDir[MAX_PATH]; HRESULT hRes = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE , &pidl); if (hRes == NOERROR) { SHGetPathFromIDList(pidl, AppDir); int i; for (i = 0; AppDir[i] != '\0'; i++) { if (AppDir[i] == '\\') str += '/'; else str += AppDir[i]; } user_config = (fs::path(str) / stuntrally).string(); } } #endif // Create user's config dir CreateDir(user_config, error_output); // Find user's data dir (for additional data) #ifdef _WIN32 user_data = user_config; // APPDATA/stuntrally #else { char const* xdg_data_home = getenv("XDG_DATA_HOME"); user_data = (xdg_data_home ? xdg_data_home / stuntrally : fs::path(home_dir) / ".local/share/games" / stuntrally).string(); } #endif // Create user's data dir and its children ///-------------------------------------------------- CreateDir(user_data, error_output); CreateDir(Records(), error_output); CreateDir(Ghosts(), error_output); CreateDir(Replays(), error_output); CreateDir(Screenshots(), error_output); CreateDir(TracksUser(), error_output); // user tracks CreateDir(DataUser(), error_output); // user data // Find game data dir and defaults config dir char *datadir = getenv("STUNTRALLY_DATA_ROOT"); if (datadir) game_data = std::string(datadir); else { fs::path shareDir = SHARED_DATA_DIR; Paths dirs; // Adding users data dir // TODO: Disabled for now until this is handled properly //dirs.push_back(user_data_dir); // Adding relative path for running from sources dirs.push_back(execname().parent_path().parent_path() / "data"); dirs.push_back(execname().parent_path().parent_path()); dirs.push_back(execname().parent_path() / "data"); dirs.push_back(execname().parent_path()); // Adding relative path from installed executable dirs.push_back(execname().parent_path().parent_path() / shareDir); #ifndef _WIN32 // Adding XDG_DATA_DIRS { char const* xdg_data_dirs = getenv("XDG_DATA_DIRS"); std::istringstream iss(xdg_data_dirs ? xdg_data_dirs : "/usr/local/share/:/usr/share/"); for (std::string p; std::getline(iss, p, ':'); dirs.push_back(p / stuntrally)) {} } #endif // TODO: Adding path from config file // Loop through the paths and pick the first one that contain some data for (Paths::const_iterator p = dirs.begin(); p != dirs.end(); ++p) { // Data dir if (fs::exists(*p / "hud")) game_data = p->string(); // Config dir if (fs::exists(*p / "config")) game_config = (*p / "config").string(); // Check if both are found if (!game_data.empty() && !game_config.empty()) break; } } // Subdirs for each sim_mode ///-------------------------------------------------- std::list <std::string> li; PATHMANAGER::DirList(PATHMANAGER::CarSim(), li); for (std::list <std::string>::iterator i = li.begin(); i != li.end(); ++i) { CreateDir(Records()+"/"+*i, error_output); CreateDir(Ghosts()+"/"+*i, error_output); } // Find cache dir #ifdef _WIN32 cache_dir = user_config + "/cache"; // APPDATA/stuntrally/cache #else char const* xdg_cache_home = getenv("XDG_CACHE_HOME"); cache_dir = (xdg_cache_home ? xdg_cache_home / stuntrally : fs::path(home_dir) / ".cache" / stuntrally).string(); #endif // Create cache dir CreateDir(CacheDir(), error_output); CreateDir(ShaderDir(), error_output); // Print diagnostic info if (log_paths) { std::stringstream out; out << "--- Directories: ---" << std::endl; out << "Ogre plugin: " << ogre_plugin << std::endl; out << "Data: " << Data() << std::endl; //out << "Default cfg: " << GetGameConfigDir() << std::endl; //out << "Home: " << home_dir << std::endl; out << "User cfg,log: " << UserConfigDir() << std::endl; out << "User data: " << user_data << std::endl; out << "Cache: " << CacheDir() << std::endl; info_output << out.str(); } }
void Stat(char Win) { int j, i, starty; DrawStatistics(Win); WaitForMouseUp(); i = 0; key = 0; starty = 118; while (i == 0) { key = 0; GetMouse(); if ((x >= 193 && y >= 42 && x <= 278 && y <= 60 && mousebuttons > 0) || key == K_ENTER) { InBox(193, 42, 278, 60); WaitForMouseUp(); if (key > 0) { delay(150); } i = 1; key = 0; OutBox(193, 42, 278, 60); } else if ((x >= 152 && y >= 41 && x <= 183 && y <= 61 && mousebuttons > 0) || key == 'D') { InBox(152, 41, 183, 61); WaitForMouseUp(); if (key > 0) { delay(150); } RankMe(Win); DrawStatistics(Win); key = 0; i = 0; OutBox(152, 41, 183, 61); }; for (j = 0; j < 5; j++) { if (AI[Win] == 0) { if ((x >= starty + (j * 33) && y >= 87 && x <= 31 + starty + (j * 33) && y <= 107 && mousebuttons > 0) || ((key >= '1' && key <= '4') || key == '0')) { if (key > 0) { switch (key) { case '0': j = 0; break; case '1': j = 1; break; case '2': j = 2; break; case '3': j = 3; break; case '4': j = 4; break; default: break; } } InBox(starty + (j * 33), 87, 31 + starty + (j * 33), 107); WaitForMouseUp(); key = 0; strncpy(keyhelpIndex, "k999", 4); switch (j) { case 0: strncpy(helptextIndex, "i130", 4); strncpy(keyhelpIndex, "k031", 4); if (Option == -1 || (Option == Win)) { ShowSpHist(Win); } //ShowSpHist(Win); break; case 1: strncpy(helptextIndex, "i131", 4); strncpy(keyhelpIndex, "k321", 4); Records(Win); break; case 2: strncpy(helptextIndex, "i132", 4); strncpy(keyhelpIndex, "k033", 4); ShowPrest(Win); break; case 3: strncpy(helptextIndex, "i034", 4); ShowHard(Win); break; case 4: strncpy(helptextIndex, (Win == 0) ? "i133" : "i134", 4); strncpy(keyhelpIndex, (Win == 0) ? "k035" : "k441", 4); if (Data->P[Win].AstroCount > 0) if (Option == -1 || Option == Win) { ShowAstrosHist(Win); } default: break; } strncpy(helptextIndex, "i000", 4); strncpy(keyhelpIndex, "k000", 4); DrawStatistics(Win); key = 0; i = 0; OutBox(starty + (j * 33), 87, 31 + starty + (j * 33), 107); } } // matches AI[Win]==0 } for (j = 0; j < 5; j++) { if (AI[other(Win)] == 0) { if ((x >= starty + (j * 33) && y >= 132 && x <= 31 + starty + (j * 33) && y <= 152 && mousebuttons > 0) || (key >= '5' && key <= '9')) { if (key > 0) { switch (key) { case '5': j = 0; break; case '6': j = 1; break; case '7': j = 2; break; case '8': j = 3; break; case '9': j = 4; break; default: break; } } InBox(starty + (j * 33), 132, 31 + starty + (j * 33), 152); WaitForMouseUp(); key = 0; switch (j) { case 0: strncpy(helptextIndex, "i130", 4); strncpy(keyhelpIndex, "k031", 4); if (Option == -1 || Option == other(Win)) { ShowSpHist(other(Win)); } //ShowSpHist(other(Win)); break; case 1: strncpy(helptextIndex, "i131", 4); strncpy(keyhelpIndex, "k321", 4); Records(other(Win)); break; case 2: strncpy(helptextIndex, "i132", 4); strncpy(keyhelpIndex, "k033", 4); ShowPrest(other(Win)); break; case 3: strncpy(helptextIndex, "i034", 4); strncpy(keyhelpIndex, "k999", 4); ShowHard(other(Win)); break; case 4: strncpy(helptextIndex, (Win == 0) ? "i133" : "i134", 4); strncpy(keyhelpIndex, (Win == 0) ? "k035" : "k441", 4); if (Data->P[other(Win)].AstroCount > 0) if (Option == -1 || Option == other(Win)) { ShowAstrosHist(other(Win)); } break; default: break; } strncpy(helptextIndex, "i000", 4); strncpy(keyhelpIndex, "k000", 4); DrawStatistics(Win); key = 0; i = 0; OutBox(starty + (j * 33), 132, 31 + starty + (j * 33), 152); } } } } return; }