/** Executes a script file. */ static void COM_Exec_f(void) { size_t length; UINT8 *buf = NULL; if (COM_Argc() < 2 || COM_Argc() > 3) { CONS_Printf("exec <filename> : run a script file\n"); return; } // load file length = FIL_ReadFile(COM_Argv(1), &buf); if (!buf) { if (!COM_CheckParm("-noerror")) CONS_Printf("couldn't execute file %s\n", COM_Argv(1)); return; } if (!COM_CheckParm("-silent")) CONS_Printf("executing %s\n", COM_Argv(1)); // insert text file into the command buffer COM_BufAddText((char *)buf); COM_BufAddText("\n"); // free buffer Z_Free(buf); }
void GameInfo::LoadGame(int slot) { CONS_Printf("Loading a game...\n"); char savename[255]; byte *savebuffer; sprintf(savename, savegamename, slot); int length = FIL_ReadFile(savename, &savebuffer); if (!length) { CONS_Printf("Couldn't open save file %s\n", savename); return; } LArchive a; if (!a.Open(savebuffer, length)) return; Z_Free(savebuffer); // the compressed buffer is no longer needed Downgrade(LEGACY_VERSION); // reset the game version SV_Reset(); ReadResourceLumps(); // dearchive all the modifications if (Unserialize(a)) { CONS_Printf("\aSavegame file corrupted!\n\n"); SV_Reset(); return; } SetState(GS_LEVEL); if (netgame) net->SV_Open(true); // let the remote players in paused = false; // view the local human players by default for (int i=0; i < NUM_LOCALHUMANS; i++) if (LocalPlayers[i].info) ViewPlayers.push_back(LocalPlayers[i].info); // TODO have other playerinfos waiting for clients to rejoin if (ViewPlayers.size()) hud.ST_Start(); // done /* if (setsizeneeded) R_ExecuteSetViewSize(); R_FillBackScreen(); // draw the pattern into the back screen */ con.Toggle(true); CONS_Printf("...done.\n"); }
int MapInfo::Serialize(LArchive &a) { int temp; a << (temp = state); a << found; a << lumpname << nicename << savename; a << cluster << mapnumber << hub; a << version << author << description; a << namepic; // only save those items that cannot be found in the MapInfo separator lump for sure! // note that MAPINFO is not read when loading a game! a << partime << gravity; // TODO thing number mappings? a << musiclump; // the warp* numbers are not used and hence need not be stored a << nextlevel << secretlevel; a << doublesky << lightning; a << sky1 << sky1sp << sky2 << sky2sp; a << cdtrack << fadetablelump; a << BossDeathKey; a << interpic << intermusic; if (state == MAP_SAVED) { // utilize the existing hubsave file a << (temp = 2); byte *buffer; int length = FIL_ReadFile(savename.c_str(), &buffer); if (!length) { I_Error("Couldn't read hubsave file %s", savename.c_str()); return -1; } a << length; a.Write(buffer, length); Z_Free(buffer); } else if (me) { a << (temp = 1); me->Serialize(a); } else a << (temp = 0); // deferred scripts a << (temp = ACS_deferred.size()); for (int i = 0; i < temp; i++) a.Write((byte *)&ACS_deferred[i], sizeof(acs_deferred_t)); return 0; }
/** Executes a script file. */ static void COM_Exec_f(void) { UINT8 *buf = NULL; char filename[256]; if (COM_Argc() < 2 || COM_Argc() > 3) { CONS_Printf(M_GetText("exec <filename>: run a script file\n")); return; } // load file // Try with Argv passed verbatim first, for back compat FIL_ReadFile(COM_Argv(1), &buf); if (!buf) { // Now try by searching the file path // filename is modified with the full found path strcpy(filename, COM_Argv(1)); if (findfile(filename, NULL, true) != FS_NOTFOUND) FIL_ReadFile(filename, &buf); if (!buf) { if (!COM_CheckParm("-noerror")) CONS_Printf(M_GetText("couldn't execute file %s\n"), COM_Argv(1)); return; } } if (!COM_CheckParm("-silent")) CONS_Printf(M_GetText("executing %s\n"), COM_Argv(1)); // insert text file into the command buffer COM_BufAddText((char *)buf); COM_BufAddText("\n"); // free buffer Z_Free(buf); }