void dodGame::Restart() { Uint32 ticks1, ticks2; object.Reset(); creature.Reset(); parser.Reset(); player.Reset(); scheduler.Reset(); viewer.Reset(); hasWon = false; dungeon.VFTPTR = 0; scheduler.SYSTCB(); object.CreateAll(); player.HBEATF = 0; player.setInitialObjects(false); viewer.displayPrepare(); viewer.displayCopyright(); viewer.display_mode = Viewer::MODE_TITLE; viewer.draw_game(); // Delay with "PREPARE!" on screen ticks1 = SDL_GetTicks(); do { oslink.process_events(); ticks2 = SDL_GetTicks(); } while (ticks2 < ticks1 + 2500); creature.NEWLVL(); INIVU(); viewer.PROMPT(); }
void dodGame::LoadGame() { scheduler.LOAD(); viewer.setVidInv((game.LEVEL % 2) ?true: false); --viewer.UPDATE; viewer.draw_game(); INIVU(); viewer.PROMPT(); }
// Game initialization void dodGame::COMINI() { Uint32 ticks1, ticks2; scheduler.SYSTCB(); object.CreateAll(); player.HBEATF = 0; viewer.clearArea(&viewer.TXTSTS); viewer.clearArea(&viewer.TXTPRI); viewer.VXSCAL = 0x80; viewer.VYSCAL = 0x80; viewer.VXSCALf = 128.0f; viewer.VYSCALf = 128.0f; AUTFLG = viewer.ShowFade(Viewer::FADE_BEGIN); //AUTFLG = scheduler.fadeLoop(); //AUTFLG = false; // TAKE THIS LINE OUT !!!!!!!!!! [Prevents demo from starting] player.setInitialObjects(AUTFLG); viewer.displayPrepare(); viewer.display_mode = Viewer::MODE_TITLE; viewer.draw_game(); // Delay with "PREPARE!" on screen ticks1 = SDL_GetTicks(); do { oslink.process_events(); ticks2 = SDL_GetTicks(); } while (ticks2 < ticks1 + viewer.prepPause); creature.NEWLVL(); if (AUTFLG) { // do map viewer.display_mode = Viewer::MODE_TITLE; viewer.showSeerMap = true; --viewer.UPDATE; viewer.draw_game(); // wait 3 seconds ticks1 = SDL_GetTicks(); do { oslink.process_events(); ticks2 = SDL_GetTicks(); } while (ticks2 < ticks1 + 3000); } INIVU(); viewer.PROMPT(); }
void Scheduler::LOAD() { ifstream fin; int ctr, in; char instr[64]; fin.open(oslink.gamefile); if (!fin) { // DISK ERROR viewer.OUTSTR(DERR); viewer.PROMPT(); return; } fin >> instr; if (1==sscanf(instr, "%d", &in)) game.LEVEL = in; fin >> instr; if (1==sscanf(instr, "%d", &in)) dungeon.VFTPTR = in; for (ctr = 0; ctr < 1024; ++ctr) { fin >> instr; if (1==sscanf(instr, "%d", &in)) dungeon.MAZLND[ctr] = in; } fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PROW = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PCOL = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.POBJWT = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PPOW = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PLHAND = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PRHAND = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PDAM = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PDIR = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PTORCH = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PRLITE = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.PMLITE = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.FAINT = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.BAGPTR = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.HEARTF = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.HEARTC = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.HEARTR = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.HEARTS = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) player.HBEATF = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) rng.SEED[0] = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) rng.SEED[1] = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) rng.SEED[2] = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) rng.carry = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.FRZFLG = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CMXPTR = in; for (ctr = 0; ctr < 60; ++ctr) { fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CMXLND[ctr] = in; } for (ctr = 0; ctr < 32; ++ctr) { fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCPOW = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCMGO = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCMGD = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCPHO = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCPHD = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCTMV = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCTAT = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCOBJ = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCDAM = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCUSE = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].creature_id = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCDIR = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCROW = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) creature.CCBLND[ctr].P_CCCOL = in; } fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OFINDF = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBPTR = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OFINDP = in; for (ctr = 0; ctr < 72; ++ctr) { fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCPTR = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCROW = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCCOL = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCLVL = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCOWN = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCXX0 = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCXX1 = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCXX2 = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].obj_id = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].obj_type = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].obj_reveal_lvl = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCMGO = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) object.OCBLND[ctr].P_OCPHO = in; } fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.RLIGHT = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.MLIGHT = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.OLIGHT = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.VXSCAL = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.VYSCAL = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.TXBFLG = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.tcaret = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.tlen = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) viewer.NEWLIN = in; //Original save games ended here. fin >> instr; if (1==sscanf(instr,"%d", &in)) //Do we have more data to load? Yes: { //Load current game levels' rnd seeds, as they are no longer hard-coded. dungeon.LEVTAB[0] = in; for (ctr = 1; ctr <= 6; ++ctr) { fin >> instr; if (1==sscanf(instr,"%d", &in)) dungeon.LEVTAB[ctr] = in; } //Load vertical features table, as they are no longer hard-coded. for (ctr = 0; ctr <= 41; ++ctr) { fin >> instr; if (1==sscanf(instr,"%d", &in)) dungeon.VFTTAB[ctr] = in; } fin >> instr; if (1==sscanf(instr,"%d", &in)) game.RandomMaze = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) game.ShieldFix = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) game.VisionScroll = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) game.CreaturesIgnoreObjects = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) game.CreaturesInstaRegen = in; fin >> instr; if (1==sscanf(instr,"%d", &in)) game.MarkDoorsOnScrollMaps = in; } else { //Do we have more data to load? No:
void Scheduler::SAVE() { ofstream fout; int ctr; char outstr[64]; fout.open(oslink.gamefile, ios::trunc); if (!fout) { // DISK ERROR viewer.OUTSTR(DERR); viewer.PROMPT(); return; } sprintf(outstr, "%d", game.LEVEL); fout << outstr << endl; sprintf(outstr, "%d", dungeon.VFTPTR); fout << outstr << endl; for (ctr = 0; ctr < 1024; ++ctr) { sprintf(outstr, "%d", dungeon.MAZLND[ctr]); fout << outstr << endl; } sprintf(outstr, "%d", player.PROW); fout << outstr << endl; sprintf(outstr, "%d", player.PCOL); fout << outstr << endl; sprintf(outstr, "%d", player.POBJWT); fout << outstr << endl; sprintf(outstr, "%d", player.PPOW); fout << outstr << endl; sprintf(outstr, "%d", player.PLHAND); fout << outstr << endl; sprintf(outstr, "%d", player.PRHAND); fout << outstr << endl; sprintf(outstr, "%d", player.PDAM); fout << outstr << endl; sprintf(outstr, "%d", player.PDIR); fout << outstr << endl; sprintf(outstr, "%d", player.PTORCH); fout << outstr << endl; sprintf(outstr, "%d", player.PRLITE); fout << outstr << endl; sprintf(outstr, "%d", player.PMLITE); fout << outstr << endl; sprintf(outstr, "%d", player.FAINT); fout << outstr << endl; sprintf(outstr, "%d", player.BAGPTR); fout << outstr << endl; sprintf(outstr, "%d", player.HEARTF); fout << outstr << endl; sprintf(outstr, "%d", player.HEARTC); fout << outstr << endl; sprintf(outstr, "%d", player.HEARTR); fout << outstr << endl; sprintf(outstr, "%d", player.HEARTS); fout << outstr << endl; sprintf(outstr, "%d", player.HBEATF); fout << outstr << endl; sprintf(outstr, "%d", rng.SEED[0]); fout << outstr << endl; sprintf(outstr, "%d", rng.SEED[1]); fout << outstr << endl; sprintf(outstr, "%d", rng.SEED[2]); fout << outstr << endl; sprintf(outstr, "%d", rng.carry); fout << outstr << endl; sprintf(outstr, "%d", creature.FRZFLG); fout << outstr << endl; sprintf(outstr, "%d", creature.CMXPTR); fout << outstr << endl; for (ctr = 0; ctr < 60; ++ctr) { sprintf(outstr, "%d", creature.CMXLND[ctr]); fout << outstr << endl; } for (ctr = 0; ctr < 32; ++ctr) { sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCPOW); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCMGO); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCMGD); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCPHO); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCPHD); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCTMV); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCTAT); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCOBJ); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCDAM); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCUSE); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].creature_id); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCDIR); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCROW); fout << outstr << endl; sprintf(outstr, "%d", creature.CCBLND[ctr].P_CCCOL); fout << outstr << endl; } sprintf(outstr, "%d", object.OFINDF); fout << outstr << endl; sprintf(outstr, "%d", object.OCBPTR); fout << outstr << endl; sprintf(outstr, "%d", object.OFINDP); fout << outstr << endl; for (ctr = 0; ctr < 72; ++ctr) { sprintf(outstr, "%d", object.OCBLND[ctr].P_OCPTR); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCROW); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCCOL); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCLVL); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCOWN); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCXX0); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCXX1); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCXX2); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].obj_id); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].obj_type); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].obj_reveal_lvl); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCMGO); fout << outstr << endl; sprintf(outstr, "%d", object.OCBLND[ctr].P_OCPHO); fout << outstr << endl; } sprintf(outstr, "%d", viewer.RLIGHT); fout << outstr << endl; sprintf(outstr, "%d", viewer.MLIGHT); fout << outstr << endl; sprintf(outstr, "%d", viewer.OLIGHT); fout << outstr << endl; sprintf(outstr, "%d", viewer.VXSCAL); fout << outstr << endl; sprintf(outstr, "%d", viewer.VYSCAL); fout << outstr << endl; sprintf(outstr, "%d", viewer.TXBFLG); fout << outstr << endl; sprintf(outstr, "%d", viewer.tcaret); fout << outstr << endl; sprintf(outstr, "%d", viewer.tlen); fout << outstr << endl; sprintf(outstr, "%d", viewer.NEWLIN); fout << outstr << endl; //Save current game levels' rnd seeds, as they are no longer hard-coded. for (ctr = 0; ctr <= 6; ++ctr) { sprintf(outstr, "%d", dungeon.LEVTAB[ctr]); fout << outstr << endl; } //Save vertical features table, as they are no longer hard-coded. for (ctr = 0; ctr <= 41; ++ctr) { sprintf(outstr, "%d", dungeon.VFTTAB[ctr]); fout << outstr << endl; } sprintf(outstr, "%d", game.RandomMaze); fout << outstr << endl; sprintf(outstr, "%d", game.ShieldFix); fout << outstr << endl; sprintf(outstr, "%d", game.VisionScroll); fout << outstr << endl; sprintf(outstr, "%d", game.CreaturesIgnoreObjects); fout << outstr << endl; sprintf(outstr, "%d", game.CreaturesInstaRegen); fout << outstr << endl; sprintf(outstr, "%d", game.MarkDoorsOnScrollMaps); fout << outstr << endl; fout.close(); }
bool Player::HUMAN(dodBYTE c) { int res; dodBYTE A, B; // Check if we are displaying the map if (HEARTF == 0) { game.INIVU(); viewer.PROMPT(); } if (c == parser.I_CR) { carriage_return: viewer.OUTCHR(parser.I_SP); parser.LINBUF[parser.LINPTR] = Parser::I_NULL; parser.LINBUF[parser.LINPTR+1] = Parser::I_NULL; parser.LINPTR = 0; if (!PreTranslateCommand(&parser.LINBUF[0])) { game.AUTFLG = true; game.demoRestart = true; return false; } // dispatch to proper routine res = parser.PARSER(&parser.CMDTAB[0], A, B, true); if (res == 1) { // dispatch switch (A) { case Parser::CMD_ATTACK: PATTK(); break; case Parser::CMD_CLIMB: PCLIMB(); break; case Parser::CMD_DROP: PDROP(); break; case Parser::CMD_EXAMINE: PEXAM(); break; case Parser::CMD_GET: PGET(); break; case Parser::CMD_INCANT: PINCAN(); break; case Parser::CMD_LOOK: PLOOK(); break; case Parser::CMD_MOVE: PMOVE(); break; case Parser::CMD_PULL: PPULL(); break; case Parser::CMD_REVEAL: PREVEA(); break; case Parser::CMD_STOW: PSTOW(); break; case Parser::CMD_TURN: PTURN(); break; case Parser::CMD_USE: PUSE(); break; case Parser::CMD_ZLOAD: PZLOAD(); break; case Parser::CMD_ZSAVE: PZSAVE(); break; } } if (res == -1) { parser.CMDERR(); } if ((HEARTF != 0) && (FAINT == 0)) { viewer.PROMPT(); } parser.LINPTR = 0; return true; } if (c == parser.I_BS) { if (parser.LINPTR == 0) { return true; } --parser.LINPTR; viewer.OUTSTR(parser.M_ERAS); return true; } // Buffer normal characters viewer.OUTCHR(c); parser.LINBUF[parser.LINPTR] = c; ++parser.LINPTR; viewer.OUTSTR(parser.M_CURS); if (parser.LINPTR >= 32) { goto carriage_return; } return true; }