void onInit() { sys::info << "app::COGLDev06NormalMapApp::onInit()" << sys::endl; pCamera = new app::CCamera(60.0f, mConfig.mRatio, 0.1f, 100.0f); pCamera->translateLocal(math::vec3(0.0f, -2.0f, -5.0f)); pShadowFBO = new ogl::CShadowFramebuffer(mConfig.mWidth, mConfig.mHeight); init_programs(); init_lights(); init_textures(); init_objects(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepthf(1.0f); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); }
/* This function also initializes the data and code heaps */ void load_image(vm_parameters *p) { FILE *file = OPEN_READ(p->image_path); if(file == NULL) { print_string("Cannot open image file: "); print_native_string(p->image_path); nl(); print_string(strerror(errno)); nl(); exit(1); } image_header h; if(fread(&h,sizeof(image_header),1,file) != 1) fatal_error("Cannot read image header",0); if(h.magic != image_magic) fatal_error("Bad image: magic number check failed",h.magic); if(h.version != image_version) fatal_error("Bad image: version number check failed",h.version); load_data_heap(file,&h,p); load_code_heap(file,&h,p); fclose(file); init_objects(&h); relocate_data(); relocate_code(); /* Store image path name */ userenv[IMAGE_ENV] = allot_alien(F,(cell)p->image_path); }
/* This function also initializes the data and code heaps */ void load_image(F_PARAMETERS *p) { FILE *file = OPEN_READ(p->image); if(file == NULL) { FPRINTF(stderr,"Cannot open image file: %s\n",p->image); fprintf(stderr,"%s\n",strerror(errno)); exit(1); } F_HEADER h; fread(&h,sizeof(F_HEADER),1,file); if(h.magic != IMAGE_MAGIC) fatal_error("Bad image: magic number check failed",h.magic); if(h.version != IMAGE_VERSION) fatal_error("Bad image: version number check failed",h.version); load_data_heap(file,&h,p); load_code_heap(file,&h,p); fclose(file); init_objects(&h); relocate_data(); relocate_code(); /* Store image path name */ userenv[IMAGE_ENV] = tag_object(from_native_string(p->image)); }
// main int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(800, 800); glutInitWindowPosition(300, 300); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow("Cottages"); init_menu(); init_objects(); init_lights(); glutReshapeFunc(reshape); glutDisplayFunc(draw); glutIdleFunc(idle); glutSpecialFunc(pressSpecialKeys); glutSpecialUpFunc(releaseSpecialKeys); glutKeyboardUpFunc(releaseKeys); glutMotionFunc(motion); glutMouseFunc(mouse); glutMainLoop(); delete cottage; delete diamond; delete lamp; delete ground; return 0; }
void test_critical(void) { init_objects(); start_threads(); zassert_true(k_sem_take(&TEST_SEM, TEST_TIMEOUT * 2) == 0, "Timed out waiting for TEST_SEM"); }
static void * kaleidescope_init (Display *dpy, Window window) { GLOBAL *g = (GLOBAL *) calloc (1, sizeof(*g)); g->dpy = dpy; g->window = window; init_g (g); create_objects(g); init_objects (g); return g; }
Context::ErrorCode Context::load_new_config( std::istream *is, const std::set<header_field_pair> &required_fields, const std::set<header_field_pair> &arith_fields) { boost::unique_lock<boost::shared_mutex> lock(request_mutex); // check that there is no ongoing config swap if (p4objects != p4objects_rt) return ONGOING_SWAP; p4objects_rt = std::make_shared<P4Objects>(); init_objects(is, required_fields, arith_fields); return SUCCESS; }
void onInit() { sys::info << "app::COGLDev42PCFShadowMapApp::onInit() " << sys::endl; init_cameras(); init_programs(); init_lights(); init_objects(); init_renderers(); }
int main() { init_objects(); printf("Before unions:\n"); print_objects(); join(4, 3); join(0, 1); join(4, 1); printf("After unions:\n"); print_objects(); printf("0 connected to 3: %s\n", is_connected(0, 3) ? "True" : "False"); return 0; }
void newgame() { fobj = invent = level.buriedobjlist = migrating_objs = (struct obj *)0; fmon = migrating_mons = (struct monst *)0; ftrap = 0; flags.ident = 1; if(wiz1_level.dlevel == 0) init_dungeons(); init_objects(); /* must be before u_init() */ u_init(); init_artifacts(); /* must be after u_init() */ #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); #endif #ifdef NEWS if(flags.news) display_file(NEWS, FALSE); #endif #ifdef MULDGN load_qtlist(); /* load up the quest text info */ quest_init(); if(flags.legacy && moves == 1) com_pager(1); #endif mklev(); u_on_upstairs(); check_special_room(FALSE); vision_reset(); /* set up internals for level (after mklev) */ flags.botlx = 1; /* Move the monster from under you or else * makedog() will fail when it calls makemon(). * - ucsfcgl!kneller */ if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy)); #ifdef CLIPPING cliparound(u.ux, u.uy); #endif (void) makedog(); docrt(); #ifdef INSURANCE save_currentstate(); #endif return; }
void onInit() { sys::info << "app::COGLDev10TessellationApp::onInit() " << sys::endl; init_cameras(); init_programs(); init_lights(); init_objects(); init_renderers(); glExitIfError(); }
int main() { FILE *f; char s[250]; int i; f = fopen("objdefines.h", "w"); fprintf(f, "#ifndef OBJDEFINES_H\n#define OBJDEFINES_H\n\n"); init_objects(); for(i=0;i<num_objects;i++) { int j; strcpy(s, get_def_name(objects[i])); for(j=0;j<strlen(s);j++) { if(s[j] == ' ') s[j] = '_'; if(s[j] == '+') s[j] = 'P'; if(s[j] == '-') { if(s[j+1] >= '0' && s[j+1] <= '9') s[j] = 'M'; else s[j] = '_'; } if(s[j] >= 'a' && s[j] <= 'z') s[j] -= 32; } if(!strncmp(s, "FIRST", 5)) fprintf(f, "#define %s %d\n", s, i+1); else if(!strncmp(s, "LAST", 4)) fprintf(f, "#define %s %d\n", s, i-1); else fprintf(f, "#define %s %d\n", s, i); } fprintf(f, "\n#define NUM_OBJECTS %d\n", i); fprintf(f, "\n#endif\n"); fclose(f); return 0; }
void start () { int i; #ifdef JOYSTICK if (joystickplayer[0] >= 0 && !calibrated[0]) { joystick = 0; joypos = 0; gamemode = JOY; calibrate_init (); return; } if (joystickplayer[1] >= 1 && !calibrated[1]) { joystick = 1; joypos = 0; gamemode = JOY; calibrate_init (); return; } #endif for (i = 0; i < nrockets; i++) { object[i].score = 0; #ifdef JOYSTICK if(joystickplayer[0]==i) { object[i].joymulx = joystickmul[0]/center[0][0]; object[i].joymuly = joystickmul[0]/center[0][1]; object[i].joythresh = joystickthresh[0]; } else if(joystickplayer[1]==i) { object[i].joymulx = joystickmul[1]/center[1][0]; object[i].joymuly = joystickmul[1]/center[1][1]; object[i].joythresh = joystickthresh[1]; } #endif } sound = ssound; gamemode = GAME; gameplan_init (); init_objects (); }
void init() { // HANDLE hCurrentProcess = GetCurrentProcess(); // SetPriorityClass(hCurrentProcess, REALTIME_PRIORITY_CLASS); if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { trace("SDL initialization failed: %s.", SDL_GetError()); exit(1); } atexit(shutdown_app); srand((unsigned int)time(NULL)); // Graphics init init_gfx(X_AXIS, Y_AXIS); init_objects(); }
//------------ Begin of function Sys::init ----------// int Sys::init( HANDLE hInstance ) { err_when( init_flag ); //------- initialize basic vars --------// app_hinstance = (HINSTANCE)hInstance; #ifdef BETA debug_session = m.is_file_exist("DEBUG.SYS"); testing_session = m.is_file_exist("TESTING.SYS"); #endif #ifdef DEBUG // Ben has put debug.sys in download version, so change to use DEBUGCC.SYS debug_session = m.is_file_exist("DEBUGCC.SYS"); testing_session = m.is_file_exist("TESTING.SYS"); #endif // add in (GAME_VERSION>=200) use_true_front = debug_session; // Ben what Win2K winXP has no lock buffer problem, so force to 1 to turn on triple buffer (1 primary + 2 system memory surfaces) use_true_front = 1; if( m.is_file_exist("WINMODE.SYS") ) use_true_front = 2; // window mode set_game_dir(); // set game directories names and game version //------- initialize more stuff ---------// if( !init_win() ) return FALSE; if( !init_directx() ) return FALSE; if( !init_objects() ) // initialize system objects which do not change from games to games. return FALSE; init_flag = 1; return TRUE; }
void NormalGame::init(Log *_log) { STACKTRACE; Game::init(_log); team_table_size = 0; view->window->locate(0,0,0,0,0,0.9,0,1); tw_delete_file(home_ini_full_path("tmp.ini")); tw_delete_file(home_ini_full_path("fleets.tmp")); tw_set_config_file(home_ini_full_path("tmp.ini")); set_config_string (NULL, "Ignorethis", ""); if (!log->playback) init_players(); log_file(home_ini_full_path("tmp.ini")); if (log->playback) { for (int i = 0; true; i += 1) { char buffy[64]; sprintf(buffy, "Player%d", i + 1); log_file(home_ini_full_path("tmp.ini")); const char *type = get_config_string(buffy, "Type", NULL); if (!type) break; const char *name = get_config_string(buffy, "Name", buffy); int channel = get_config_int(buffy, "Channel", -2); int ti = get_config_int(buffy, "Team", 0); add_player(create_control(channel, type), ti, name, buffy); player_fleet[i]->load(NULL, buffy); player_fleet[i]->save("fleets.tmp", buffy); } } prepare(); init_objects(); next_choose_new_ships_time = game_time + 200; // team and health indicators. indteamtoggle = 0; indhealthtoggle = 0; return; }
void handle_event(SDL_Event *event) { SDLKey key = SDLK_CLEAR; if (event == NULL) return; // These events may be used at any time, even when the game is paused switch(event->type) { case SDL_QUIT: app.quit = 1; break; case SDL_KEYDOWN: key = event->key.keysym.sym; switch(key) { case SDLK_q: case SDLK_ESCAPE: app.quit = 1; break; case SDLK_p: app.paused = (app.paused ? 0 : 1); break; case SDLK_RETURN: if (event->key.keysym.mod & KMOD_ALT) { toggle_fullscreen(); init_objects(); } break; case SDLK_v: toggle_vsync(); break; } break; case SDL_VIDEORESIZE: resize_window(event->resize.w, event->resize.h, X_AXIS, Y_AXIS); break; } }
void AD_Scene3D::init (void) { int k; init_materials(); init_lights(); init_camere(); init_objects(); for (k=0; k<num_materials+2; k++) { if (materials[k].trasparencytype==OFF) { materials[k].my_tria_list=(void **) new AD_Tria3DPtr[materials[k].my_num_tria]; materials[k].my_tria_list_copy=materials[k].my_tria_list; } } counter_for_resetting_vertex=0; zclear=-1; return; }
int main(int argc, char* a[]) { int size = SIZE; int x = 200; int i = 0; meanv = 0.0; if (argc > 1) { x = atoi(a[1]); } init_objects(); // LRZ TODO: Switch on the 5 parallelisation lines #pragma omp parallel #pragma omp master { printf("Number of threads: %d\n", omp_get_num_threads()); } printf("starting simulation for %d frames...\n", x); for (;i != x; ++i) { update(); } printf("simulation finished\n"); struct Object crcr = crc(); { printf("crc=%g %g %g %g %g %g %g\n", crcr.x, crcr.y, crcr.z, crcr.vx, crcr.vy, crcr.vz, meanv); } return 0; }
/* This function also initializes the data and code heaps */ void factor_vm::load_image(vm_parameters *p) { FILE *file = OPEN_READ(p->image_path); if(file == NULL) { std::cout << "Cannot open image file: " << p->image_path << std::endl; std::cout << strerror(errno) << std::endl; exit(1); } image_header h; if(safe_fread(&h,sizeof(image_header),1,file) != 1) fatal_error("Cannot read image header",0); if(h.magic != image_magic) fatal_error("Bad image: magic number check failed",h.magic); if(h.version != image_version) fatal_error("Bad image: version number check failed",h.version); load_data_heap(file,&h,p); load_code_heap(file,&h,p); safe_fclose(file); init_objects(&h); cell data_offset = data->tenured->start - h.data_relocation_base; cell code_offset = code->seg->start - h.code_relocation_base; fixup_data(data_offset,code_offset); fixup_code(data_offset,code_offset); /* Store image path name */ special_objects[OBJ_IMAGE] = allot_alien(false_object,(cell)p->image_path); }
int SwitchWContexts::init_from_command_line_options(int argc, char *argv[], TargetParserIface *tp) { OptionsParser parser; parser.parse(argc, argv, tp); notifications_addr = parser.notifications_addr; auto transport = std::shared_ptr<TransportIface>( TransportIface::make_nanomsg(notifications_addr)); transport->open(); #ifdef BMDEBUG_ON // has to be before init_objects because forces arith if (parser.debugger) { for (Context &c : contexts) c.set_force_arith(true); Debugger::init_debugger(parser.debugger_addr); } #endif event_logger_addr = parser.event_logger_addr; if (parser.console_logging) Logger::set_logger_console(); if (parser.file_logger != "") Logger::set_logger_file(parser.file_logger, parser.log_flush); Logger::set_log_level(parser.log_level); int status = init_objects(parser.config_file_path, parser.device_id, transport); if (status != 0) return status; if (parser.use_files) set_dev_mgr_files(parser.wait_time); else if (parser.packet_in) set_dev_mgr_packet_in(device_id, parser.packet_in_addr, transport); else set_dev_mgr_bmi(device_id, transport); for (const auto &iface : parser.ifaces) { std::cout << "Adding interface " << iface.second << " as port " << iface.first << (parser.use_files ? " (files)" : "") << std::endl; const char* inFileName = NULL; const char* outFileName = NULL; std::string inFile; std::string outFile; if (parser.use_files) { inFile = iface.second + "_in.pcap"; inFileName = inFile.c_str(); outFile = iface.second + "_out.pcap"; outFileName = outFile.c_str(); } else if (parser.pcap) { inFile = iface.second + ".pcap"; inFileName = inFile.c_str(); outFileName = inFileName; } port_add(iface.second, iface.first, inFileName, outFileName); } thrift_port = parser.thrift_port; if (parser.state_file_path != "") { status = deserialize_from_file(parser.state_file_path); if (status != 0) return status; } // TODO(unknown): is this the right place to do this? set_packet_handler(packet_handler, static_cast<void *>(this)); start(); return status; }
void newgame() { int i; #ifdef MFLOPPY gameDiskPrompt(); #endif flags.ident = 1; for (i = 0; i < NUMMONS; i++) mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; init_objects(); /* must be before u_init() */ flags.pantheon = -1; /* role_init() will reset this */ role_init(); /* must be before init_dungeons(), u_init(), * and init_artifacts() */ init_dungeons(); /* must be before u_init() to avoid rndmonst() * creating odd monsters for any tins and eggs * in hero's initial inventory */ init_artifacts(); /* before u_init() in case $WIZKIT specifies * any artifacts */ u_init(); #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); #endif #ifdef NEWS if(iflags.news) display_file(NEWS, FALSE); #endif load_qtlist(); /* load up the quest text info */ /* quest_init();*/ /* Now part of role_init() */ mklev(); u_on_upstairs(); vision_reset(); /* set up internals for level (after mklev) */ check_special_room(FALSE); flags.botlx = 1; /* Move the monster from under you or else * makedog() will fail when it calls makemon(). * - ucsfcgl!kneller */ if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy)); (void) makedog(); docrt(); if (flags.legacy) { flush_screen(1); com_pager(1); } #ifdef INSURANCE save_currentstate(); #endif program_state.something_worth_saving++; /* useful data now exists */ #if defined(RECORD_REALTIME) || defined(REALTIME_ON_BOTL) /* Start the timer here */ realtime_data.realtime = (time_t)0L; #if defined(BSD) && !defined(POSIX_TYPES) (void) time((long *)&realtime_data.restoretime); #else (void) time(&realtime_data.restoretime); #endif #endif /* RECORD_REALTIME || REALTIME_ON_BOTL */ /* Success! */ welcome(TRUE); return; }
void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); init_objects(); }
PyMODINIT_FUNC initpassword(void){ if(init_objects()) return; g_critical("Now begin init module"); Py_InitModule("mysql.password", password_methods); }
/* config loader for service register/unregister */ static void win32_load_config(char *conf) { cf_config_file = conf; init_objects(); load_config(false); }
static void newgame(void) { int i; flags.ident = 1; for (i = 0; i < NUMMONS; i++) mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; init_objects(); /* must be before u_init() */ flags.pantheon = -1;/* role_init() will reset this */ role_init(); /* must be before init_dungeons(), u_init(), * and init_artifacts() */ init_dungeons(); /* must be before u_init() to avoid rndmonst() * creating odd monsters for any tins and eggs * in hero's initial inventory */ init_artifacts(); u_init(); /* struct you must have some basic data for mklev to work right */ load_qtlist(); /* load up the quest text info */ level = mklev(&u.uz); u_init_inv_skills();/* level must be valid to create items */ u_on_upstairs(); vision_reset(); /* set up internals for level (after mklev) */ check_special_room(FALSE); iflags.botl = 1; /* Move the monster from under you or else * makedog() will fail when it calls makemon(). * - ucsfcgl!kneller */ if (MON_AT(level, u.ux, u.uy)) mnexto(m_at(level, u.ux, u.uy)); makedog(); doredraw(); if (Role_if(PM_CONVICT)) { setworn(mkobj(level, CHAIN_CLASS, TRUE), W_CHAIN); setworn(mkobj(level, BALL_CLASS, TRUE), W_BALL); uball->spe = 1; /* attach the ball to the hero */ placebc(); } /* help the window port get it's display charset/tiles sorted out */ notify_levelchange(NULL); if (flags.legacy) { flush_screen(); com_pager(Role_if(PM_CONVICT) ? 199 : 1); } /* Stop autoexplore revisiting the entrance stairs (or position). */ level->locations[u.ux][u.uy].mem_stepped = 1; program_state.something_worth_saving++; /* useful data now exists */ historic_event(FALSE, "entered the Dungeons of Doom to retrieve the Amulet of Yendor!"); /* Success! */ welcome(TRUE); maybe_tutorial(); /* Prepare for the first move. */ flags.move = 0; set_wear(); pickup(1); log_command_result(); program_state.game_running = TRUE; youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */ realtime_tasks(); post_init_tasks(); return; }
PyMODINIT_FUNC initproto(void){ if(init_objects()) return; Py_InitModule("mysql.proto", proto_methods); }
int main(int argc, char *argv[]) { int fd; #ifdef CHDIR char *dir; #endif hname = argv[0]; hackpid = getpid(); #ifdef CHDIR /* otherwise no chdir() */ /* * See if we must change directory to the playground. * (Perhaps hack runs suid and playground is inaccessible * for the player.) * The environment variable HACKDIR is overridden by a * -d command line option (must be the first option given) */ dir = getenv("HACKDIR"); if (argc > 1 && !strncmp(argv[1], "-d", 2)) { argc--; argv++; dir = argv[0] + 2; if (*dir == '=' || *dir == ':') dir++; if (!*dir && argc > 1) { argc--; argv++; dir = argv[0]; } if (!*dir) error("Flag -d must be followed by a directory name."); } #endif /* * Who am i? Algorithm: 1. Use name as specified in HACKOPTIONS * 2. Use $USER or $LOGNAME (if 1. fails) * 3. Use getlogin() (if 2. fails) * The resulting name is overridden by command line options. * If everything fails, or if the resulting name is some generic * account like "games", "play", "player", "hack" then eventually * we'll ask him. * Note that we trust him here; it is possible to play under * somebody else's name. */ { char *s; initoptions(); if (!*plname && (s = getenv("USER"))) strncpy(plname, s, sizeof(plname) - 1); if (!*plname && (s = getenv("LOGNAME"))) strncpy(plname, s, sizeof(plname) - 1); if (!*plname && (s = getlogin())) strncpy(plname, s, sizeof(plname) - 1); } /* * Now we know the directory containing 'record' and * may do a prscore(). */ if (argc > 1 && !strncmp(argv[1], "-s", 2)) { #ifdef CHDIR chdirx(dir, 0); #endif prscore(argc, argv); exit(0); } /* * It seems he really wants to play. * Remember tty modes, to be restored on exit. */ gettty(); setbuf(stdout, obuf); umask(007); setrandom(); startup(); cls(); u.uhp = 1; /* prevent RIP on early quits */ u.ux = FAR; /* prevent nscr() */ signal(SIGHUP, hangup); /* * Find the creation date of this game, * so as to avoid restoring outdated savefiles. */ gethdate(hname); /* * We cannot do chdir earlier, otherwise gethdate will fail. */ #ifdef CHDIR chdirx(dir, 1); #endif /* * Process options. */ while (argc > 1 && argv[1][0] == '-') { argv++; argc--; switch (argv[0][1]) { #ifdef WIZARD case 'D': wizard = TRUE; break; #endif #ifdef NEWS case 'n': flags.nonews = TRUE; break; #endif case 'u': if (argv[0][2]) strncpy(plname, argv[0] + 2, sizeof(plname) - 1); else if (argc > 1) { argc--; argv++; strncpy(plname, argv[0], sizeof(plname) - 1); } else printf("Player name expected after -u\n"); break; default: /* allow -T for Tourist, etc. */ strncpy(pl_character, argv[0] + 1, sizeof(pl_character) - 1); } } if (argc > 1) locknum = atoi(argv[1]); #ifdef MAX_NR_OF_PLAYERS if (!locknum || locknum > MAX_NR_OF_PLAYERS) locknum = MAX_NR_OF_PLAYERS; #endif #ifdef DEF_PAGER if (!(catmore = getenv("HACKPAGER")) && !(catmore = getenv("PAGER"))) catmore = DEF_PAGER; #endif #ifdef MAIL getmailstatus(); #endif #ifdef WIZARD if (wizard) strcpy(plname, "wizard"); else #endif if (!*plname || !strncmp(plname, "player", 4) || !strncmp(plname, "games", 4)) askname(); plnamesuffix(); /* strip suffix from name; calls askname() */ /* again if suffix was whole name */ /* accepts any suffix */ #ifdef WIZARD if (!wizard) { #endif /* * check for multiple games under the same name * (if !locknum) or check max nr of players (otherwise) */ signal(SIGQUIT, SIG_IGN); signal(SIGINT, SIG_IGN); if (!locknum) strcpy(lock, plname); getlock(); /* sets lock if locknum != 0 */ #ifdef WIZARD } else { char *sfoo; strcpy(lock, plname); if ((sfoo = getenv("MAGIC"))) while (*sfoo) { switch (*sfoo++) { case 'n': srandom(*sfoo++); break; } } if ((sfoo = getenv("GENOCIDED")) != NULL) { if (*sfoo == '!') { struct permonst *pm = mons; char *gp = genocided; while (pm < mons + CMNUM + 2) { if (!strchr(sfoo, pm->mlet)) *gp++ = pm->mlet; pm++; } *gp = 0; } else strncpy(genocided, sfoo, sizeof(genocided) - 1); strcpy(fut_geno, genocided); } } #endif setftty(); sprintf(SAVEF, "save/%d%s", getuid(), plname); regularize(SAVEF + 5); /* avoid . or / in name */ if ((fd = open(SAVEF, O_RDONLY)) >= 0 && (uptodate(fd) || unlink(SAVEF) == 666)) { signal(SIGINT, done1); pline("Restoring old save file..."); fflush(stdout); if (!dorecover(fd)) goto not_recovered; pline("Hello %s, welcome to %s!", plname, gamename); flags.move = 0; } else { not_recovered: fobj = fcobj = invent = 0; fmon = fallen_down = 0; ftrap = 0; fgold = 0; flags.ident = 1; init_objects(); u_init(); signal(SIGINT, done1); mklev(); u.ux = xupstair; u.uy = yupstair; inshop(); setsee(); flags.botlx = 1; makedog(); { struct monst *mtmp; if ((mtmp = m_at(u.ux, u.uy)) != NULL) mnexto(mtmp); /* riv05!a3 */ } seemons(); #ifdef NEWS if (flags.nonews || !readnews()) /* after reading news we did docrt() already */ #endif docrt(); /* give welcome message before pickup messages */ pline("Hello %s, welcome to %s!", plname, gamename); pickup(1); read_engr_at(u.ux, u.uy); flags.move = 1; } flags.moonphase = phase_of_the_moon(); if (flags.moonphase == FULL_MOON) { pline("You are lucky! Full moon tonight."); u.uluck++; } else if (flags.moonphase == NEW_MOON) pline("Be careful! New moon tonight."); initrack(); for (;;) { if (flags.move) { /* actual time passed */ settrack(); if (moves % 2 == 0 || (!(Fast & ~INTRINSIC) && (!Fast || rn2(3)))) { movemon(); if (!rn2(70)) makemon(NULL, 0, 0); } if (Glib) glibr(); p_timeout(); ++moves; if (flags.time) flags.botl = 1; if (u.uhp < 1) { pline("You die..."); done("died"); } if (u.uhp * 10 < u.uhpmax && moves - wailmsg > 50) { wailmsg = moves; if (u.uhp == 1) pline("You hear the wailing of the Banshee..."); else pline("You hear the howling of the CwnAnnwn..."); } if (u.uhp < u.uhpmax) { if (u.ulevel > 9) { if (Regeneration || !(moves % 3)) { flags.botl = 1; u.uhp += rnd((int)u.ulevel - 9); if (u.uhp > u.uhpmax) u.uhp = u.uhpmax; } } else if (Regeneration || (!(moves % (22 - u.ulevel * 2)))) { flags.botl = 1; u.uhp++; } } if (Teleportation && !rn2(85)) tele(); if (Searching && multi >= 0) dosearch(); gethungry(); invault(); amulet(); } if (multi < 0) { if (!++multi) { pline("%s", nomovemsg ? nomovemsg : "You can move again."); nomovemsg = 0; if (afternmv) (*afternmv)(); afternmv = NULL; } } find_ac(); #ifndef QUEST if (!flags.mv || Blind) #endif { seeobjs(); seemons(); nscr(); } if (flags.botl || flags.botlx) bot(); flags.move = 1; if (multi >= 0 && occupation) { if (monster_nearby()) stop_occupation(); else if ((*occupation)() == 0) occupation = NULL; continue; } if (multi > 0) { #ifdef QUEST if (flags.run >= 4) finddir(); #endif lookaround(); if (!multi) { /* lookaround may clear multi */ flags.move = 0; continue; } if (flags.mv) { if (multi < COLNO && !--multi) flags.mv = flags.run = 0; domove(); } else { --multi; rhack(save_cm); } } else if (multi == 0) { #ifdef MAIL ckmailstatus(); #endif rhack(NULL); } if (multi && multi % 7 == 0) fflush(stdout); } }