// joe: from FuhQuake static byte *LoadColoredLighting (const char *name, char **litfilename) { byte *data; const char *tmpname; extern cvar_t gl_loadlitfiles; if (!gl_loadlitfiles.value) return NULL; tmpname = Host_MapName (); if (!COM_FilenamesEqual(name, va("maps/%s.bsp", tmpname))) return NULL; *litfilename = va("maps/%s.lit", tmpname); data = COM_LoadHunkFile (*litfilename, 0); if (!data) { *litfilename = va("lits/%s.lit", tmpname); data = COM_LoadHunkFile (*litfilename, 0); } return data; }
void Sys_Quit (void) { byte screen[80*25*2]; // byte *d; // 2001-09-12 Returning information about loaded file by Maddes char ver[6]; int i; loadedfile_t *fileinfo; // 2001-09-12 Returning information about loaded file by Maddes // load the sell screen before shuting everything down if (registered->value) // 2001-09-12 Returning information about loaded file by Maddes start // d = COM_LoadHunkFile ("end2.bin"); fileinfo = COM_LoadHunkFile ("end2.bin"); // 2001-09-12 Returning information about loaded file by Maddes end else // 2001-09-12 Returning information about loaded file by Maddes start // d = COM_LoadHunkFile ("end1.bin"); fileinfo = COM_LoadHunkFile ("end1.bin"); // 2001-09-12 Returning information about loaded file by Maddes end // 2001-09-12 Returning information about loaded file by Maddes start /* if (d) memcpy (screen, d, sizeof(screen)); */ if (fileinfo) memcpy (screen, fileinfo->data, sizeof(screen)); // 2001-09-12 Returning information about loaded file by Maddes end // write the version number directly to the end screen sprintf (ver, " v%4.2f", VERSION); for (i=0 ; i<6 ; i++) screen[0*80*2 + 72*2 + i*2] = ver[i]; Host_Shutdown(); // do the text mode sell screen // 2001-09-12 Returning information about loaded file by Maddes start // if (d) if (fileinfo) // 2001-09-12 Returning information about loaded file by Maddes end { memcpy ((void *)real2ptr(0xb8000), screen,80*25*2); // set text pos regs.x.ax = 0x0200; regs.h.bh = 0; regs.h.dl = 0; regs.h.dh = 22; dos_int86 (0x10); } else printf ("couldn't load endscreen.\n"); exit(0); }
void Sys_Quit(void) { byte screen[80*25*2]; byte *d; char ver[6]; int i; // load the sell screen before shuting everything down if (registered.value) { d = COM_LoadHunkFile("end2.bin"); } else { d = COM_LoadHunkFile("end1.bin"); } if (d) { memcpy(screen, d, sizeof(screen)); } // write the version number directly to the end screen sprintf(ver, " v%4.2f", VERSION); for (i=0 ; i<6 ; i++) { screen[0*80*2 + 72*2 + i*2] = ver[i]; } Host_Shutdown(); // do the text mode sell screen if (d) { memcpy((void *)real2ptr(0xb8000), screen,80*25*2); // set text pos regs.x.ax = 0x0200; regs.h.bh = 0; regs.h.dl = 0; regs.h.dh = 22; dos_int86(0x10); } else { printf("couldn't load endscreen.\n"); } exit(0); }
/* =============== Cmd_Exec_f =============== */ void Cmd_Exec_f (void) { char *f; int mark; if (Cmd_Argc () != 2) { Con_Printf ("exec <filename> : execute a script file\n"); return; } // FIXME: is this safe freeing the hunk here??? mark = Hunk_LowMark (); f = (char *)COM_LoadHunkFile (Cmd_Argv(1)); if (!f) { Con_Printf ("couldn't exec %s\n",Cmd_Argv(1)); return; } if (!Cvar_Command () && (cl_warncmd.value || developer.value)) Con_Printf ("execing %s\n",Cmd_Argv(1)); Cbuf_InsertText (f); Hunk_FreeToLowMark (mark); }
/* ==================== W_LoadWadFile ==================== */ void W_LoadWadFile (char *filename) { lumpinfo_t *lump_p; wadinfo_t *header; unsigned i; int infotableofs; wad_base = COM_LoadHunkFile (filename); if (!wad_base) Sys_Error ("W_LoadWadFile: couldn't load %s", filename); header = (wadinfo_t *)wad_base; if (header->identification[0] != 'W' || header->identification[1] != 'A' || header->identification[2] != 'D' || header->identification[3] != '2') Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename); wad_numlumps = LittleLong(header->numlumps); infotableofs = LittleLong(header->infotableofs); wad_lumps = (lumpinfo_t *)(wad_base + infotableofs); for (i=0, lump_p = wad_lumps ; i<wad_numlumps ; i++,lump_p++) { lump_p->filepos = LittleLong(lump_p->filepos); lump_p->size = LittleLong(lump_p->size); W_CleanupName (lump_p->name, lump_p->name); if (lump_p->type == TYP_QPIC) SwapPic ( (qpic_t *)(wad_base + lump_p->filepos)); } }
/* ================= Mod_LoadLighting ================= */ void Mod_LoadLighting (lump_t *l) { int i; byte *in, *out; byte d; char litfilename[1024]; if (!l->filelen) { loadmodel->lightdata = NULL; return; } strcpy(litfilename, loadmodel->name); COM_StripExtension(litfilename, litfilename); strcat(litfilename, ".lit"); loadmodel->lightdata = (byte*) COM_LoadHunkFile (litfilename); if (!loadmodel->lightdata) // expand the white lighting data { loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, litfilename); in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write out = loadmodel->lightdata; memcpy (in, mod_base + l->fileofs, l->filelen); for (i = 0;i < l->filelen;i++) { d = *in++; *out++ = d; *out++ = d; *out++ = d; } } }
/* ================= Mod_LoadEntities ================= */ void Mod_LoadEntities (lump_t *l, loadedfile_t *brush_fileinfo) // 2001-09-12 .ENT support by Maddes { // 2001-09-12 .ENT support by Maddes start char entfilename[1024]; loadedfile_t *fileinfo; searchpath_t *s_check; loadmodel->entities = NULL; if (external_ent->value) { // check for a .ENT file strcpy(entfilename, loadmodel->name); COM_StripExtension(entfilename, entfilename); strcat(entfilename, ".ent"); fileinfo = COM_LoadHunkFile (entfilename); if (fileinfo && fileinfo->filelen) { // .ENT file only allowed from same directory of map file or another directory before in the searchpath s_check = COM_GetDirSearchPath(brush_fileinfo->path); // get last searchpath of map directory while ( (s_check = s_check->next) ) // next searchpath { if (s_check == fileinfo->path) // found .ENT searchpath = after map directory { Con_DPrintf("%s not allowed from %s as map is from %s\n", entfilename, fileinfo->path->pack ? fileinfo->path->pack->filename : fileinfo->path->filename, brush_fileinfo->path->pack ? brush_fileinfo->path->pack->filename : brush_fileinfo->path->filename); break; } } if (!s_check) // .ENT searchpath not found = before map directory { Con_DPrintf("%s loaded from %s\n", entfilename, fileinfo->path->pack ? fileinfo->path->pack->filename : fileinfo->path->filename); loadmodel->entities = fileinfo->data; return; } } // no .ENT found, use the original entity list } // 2001-09-12 .ENT support by Maddes end if (!l->filelen) { loadmodel->entities = NULL; return; } // 2001-09-12 .ENT support by Maddes start // loadmodel->entities = Hunk_AllocName ( l->filelen, loadname); loadmodel->entities = Hunk_AllocName ( l->filelen, "INT_ENT"); // 2001-09-12 .ENT support by Maddes end memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen); CL_ParseEntityLump(loadmodel->entities); // Tomaz - Parse Data }
/* =============== Cmd_Exec_f =============== */ void Cmd_Exec_f (void) { char *f; int mark; if (Cmd_Argc () != 2) { Con_Printf ("exec <filename> : execute a script file\n"); return; } mark = Hunk_LowMark (); f = (char *)COM_LoadHunkFile (Cmd_Argv(1)); if (!f) { Con_Printf ("couldn't exec %s\n",Cmd_Argv(1)); return; } Con_Printf ("execing %s\n",Cmd_Argv(1)); Cbuf_InsertText (f); Hunk_FreeToLowMark (mark); }
bool Host_Init(quakeparms_t *parms) { if (standard_quake) minimum_memory = MINIMUM_MEMORY; else minimum_memory = MINIMUM_MEMORY_LEVELPAK; if (COM_CheckParm("-minmemory")) parms->memsize = minimum_memory; host_parms = *parms; if (parms->memsize < minimum_memory) return Sys_Error("Only %4.1f megs of memory reported, can't execute game", parms->memsize / (float)0x100000); com_argc = parms->argc; com_argv = parms->argv; Memory_Init(parms->membase, parms->memsize); Cbuf_Init(); Cmd_Init(); V_Init(); Chase_Init(); COM_Init(); Host_InitLocal(); if (!W_LoadWadFile("gfx.wad")) return false; Key_Init(); Con_Init(); M_Init(); PR_Init(); Mod_Init(R_ModelLoader()); NET_Init(); SV_Init(); Con_Printf("Exe: " __TIME__ " " __DATE__ "\n"); Con_Printf("%4.1f megabyte heap\n", parms->memsize / (1024 * 1024.0)); R_InitTextures(); // needed even for dedicated servers if (cls.state != ca_dedicated) { host_basepal = (byte*)COM_LoadHunkFile("gfx/palette.lmp"); if (!host_basepal) return Sys_Error("Couldn't load gfx/palette.lmp"); host_colormap = (byte*)COM_LoadHunkFile("gfx/colormap.lmp"); if (!host_colormap) return Sys_Error("Couldn't load gfx/colormap.lmp"); if (coloredlights) host_fullbrights = 256-host_colormap[16384]; // leilei - variable our fullbright counts if available VID_Init(host_basepal); Draw_Init(); SCR_Init(); R_Init(); S_Init(); CDAudio_Init(); BGM_Init(); Sbar_Init(); CL_Init(); IN_Init(); } Hunk_AllocName(0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark(); host_initialized = true; Sys_Printf("========Quake Initialized=========\n"); /* In case exec of quake.rc fails */ if (!setjmp(host_abort)) { Cbuf_InsertText("exec quake.rc\n"); Cbuf_Execute(); } return true; }
/* ================== CL_ParseServerInfo ================== */ void CL_ParseServerInfo (void) { char *str; int i; int nummodels, numsounds; static char model_precache[MAX_MODELS][MAX_QPATH]; static char sound_precache[MAX_SOUNDS][MAX_QPATH]; Con_DPrintf ("Serverinfo packet received.\n"); // // wipe the client_state_t struct // CL_ClearState (); // parse protocol version number i = MSG_ReadLong (); if (i != PROTOCOL_VERSION) { Con_Printf ("Server returned version %i, not %i", i, PROTOCOL_VERSION); return; } // parse maxclients cl.maxclients = MSG_ReadByte (); if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD) { Con_Printf("Bad maxclients (%u) from server\n", cl.maxclients); return; } cl.scores = Hunk_AllocName (cl.maxclients*sizeof(*cl.scores), "scores"); // parse gametype cl.gametype = MSG_ReadByte (); if (cl.gametype == GAME_DEATHMATCH) sv_kingofhill = MSG_ReadShort (); // parse signon message str = MSG_ReadString (); strncpy (cl.levelname, str, sizeof(cl.levelname)-1); // seperate the printfs so the server message can have a color Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); Con_Printf ("%c%s\n", 2, str); // // first we go through and touch all of the precache data that still // happens to be in the cache, so precaching something else doesn't // needlessly purge it // // precache models memset (cl.model_precache, 0, sizeof(cl.model_precache)); for (nummodels=1 ; ; nummodels++) { str = MSG_ReadString (); if (!str[0]) break; if (nummodels==MAX_MODELS) { Con_Printf ("Server sent too many model precaches\n"); return; } strcpy (model_precache[nummodels], str); Mod_TouchModel (str); } // precache sounds memset (cl.sound_precache, 0, sizeof(cl.sound_precache)); for (numsounds=1 ; ; numsounds++) { str = MSG_ReadString (); if (!str[0]) break; if (numsounds==MAX_SOUNDS) { Con_Printf ("Server sent too many sound precaches\n"); return; } strcpy (sound_precache[numsounds], str); S_TouchSound (str); } // // now we try to load everything else until a cache allocation fails // if (precache.value) { total_loading_size = nummodels + numsounds; current_loading_size = 1; loading_stage = 2; } //always precache the world!!! cl.model_precache[1] = Mod_ForName (model_precache[1], false); for (i=2 ; i<nummodels ; i++) { if (precache.value) { cl.model_precache[i] = Mod_ForName (model_precache[i], false); current_loading_size++; //SCR_DrawLoading(); //D_ShowLoadingSize(); } else cl.model_precache[i] = (model_t *)Mod_FindName (model_precache[i]); if (cl.model_precache[i] == NULL) { Con_Printf("Model %s not found\n", model_precache[i]); return; } CL_KeepaliveMessage (); } player_models[0] = (model_t *)Mod_FindName ("models/paladin.mdl"); player_models[1] = (model_t *)Mod_FindName ("models/crusader.mdl"); player_models[2] = (model_t *)Mod_FindName ("models/necro.mdl"); player_models[3] = (model_t *)Mod_FindName ("models/assassin.mdl"); #ifndef NO_PRAVEUS player_models[4] = (model_t *)Mod_FindName ("models/succubus.mdl"); #endif S_BeginPrecaching (); for (i=1 ; i<numsounds ; i++) { cl.sound_precache[i] = S_PrecacheSound (sound_precache[i]); if (precache.value) { current_loading_size++; //SCR_DrawLoading(); //D_ShowLoadingSize(); } CL_KeepaliveMessage (); } S_EndPrecaching (); total_loading_size = 0; loading_stage = 0; // local state cl_entities[0].model = cl.worldmodel = cl.model_precache[1]; R_NewMap (); puzzle_strings = (char *)COM_LoadHunkFile ("puzzles.txt"); Hunk_Check (); // make sure nothing is hurt noclip_anglehack = false; // noclip is turned off at start }
/* ==================== Host_Init ==================== */ void Host_Init (void) { if (standard_quake) minimum_memory = MINIMUM_MEMORY; else minimum_memory = MINIMUM_MEMORY_LEVELPAK; if (COM_CheckParm ("-minmemory")) host_parms->memsize = minimum_memory; if (host_parms->memsize < minimum_memory) Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms->memsize / (float)0x100000); com_argc = host_parms->argc; com_argv = host_parms->argv; Memory_Init (host_parms->membase, host_parms->memsize); Cbuf_Init (); Cmd_Init (); LOG_Init (host_parms); Cvar_Init (); //johnfitz COM_Init (); COM_InitFilesystem (); Host_InitLocal (); W_LoadWadFile (); //johnfitz -- filename is now hard-coded for honesty if (cls.state != ca_dedicated) { Key_Init (); Con_Init (); } PR_Init (); Mod_Init (); NET_Init (); SV_Init (); Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); Con_Printf ("%4.1f megabyte heap\n", host_parms->memsize/ (1024*1024.0)); if (cls.state != ca_dedicated) { host_colormap = (byte *)COM_LoadHunkFile ("gfx/colormap.lmp", NULL); if (!host_colormap) Sys_Error ("Couldn't load gfx/colormap.lmp"); V_Init (); Chase_Init (); M_Init (); ExtraMaps_Init (); //johnfitz Modlist_Init (); //johnfitz DemoList_Init (); //ericw VID_Init (); IN_Init (); TexMgr_Init (); //johnfitz Draw_Init (); SCR_Init (); R_Init (); S_Init (); CDAudio_Init (); BGM_Init(); Sbar_Init (); CL_Init (); } Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark (); host_initialized = true; Con_Printf ("\n========= Quake Initialized =========\n\n"); if (cls.state != ca_dedicated) { Cbuf_InsertText ("exec quake.rc\n"); // johnfitz -- in case the vid mode was locked during vid_init, we can unlock it now. // note: two leading newlines because the command buffer swallows one of them. Cbuf_AddText ("\n\nvid_unlock\n"); } if (cls.state == ca_dedicated) { Cbuf_AddText ("exec autoexec.cfg\n"); Cbuf_AddText ("stuffcmds"); Cbuf_Execute (); if (!sv.active) Cbuf_AddText ("map start\n"); } }
/* ==================== Host_Init ==================== */ void Host_Init (quakeparms_t *parms) { if (standard_quake) minimum_memory = MINIMUM_MEMORY; else minimum_memory = MINIMUM_MEMORY_LEVELPAK; if (COM_CheckParm ("-minmemory")) parms->memsize = minimum_memory; host_parms = *parms; if (parms->memsize < minimum_memory) Sys_Error ("Only %4.1f megs of memory available, can't execute game", parms->memsize / (float)0x100000); com_argc = parms->argc; com_argv = parms->argv; Memory_Init (parms->membase, parms->memsize); Cbuf_Init (); Cmd_Init (); V_Init (); // jkrige - removed chase //Chase_Init (); // jkrige - removed chase Host_InitVCR (parms); COM_Init (parms->basedir); Host_InitLocal (); W_LoadWadFile ("gfx.wad"); Key_Init (); Con_Init (); M_Init (); PR_Init (); Mod_Init (); NET_Init (); SV_Init (); Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); Con_Printf ("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0)); R_InitTextures (); // needed even for dedicated servers if (cls.state != ca_dedicated) { host_basepal = (byte *)COM_LoadHunkFile ("gfx/palette.lmp"); if (!host_basepal) Sys_Error ("Couldn't load gfx/palette.lmp"); host_colormap = (byte *)COM_LoadHunkFile ("gfx/colormap.lmp"); if (!host_colormap) Sys_Error ("Couldn't load gfx/colormap.lmp"); #ifndef _WIN32 // on non win32, mouse comes before video for security reasons IN_Init (); #endif VID_Init (host_basepal); Draw_Init (); SCR_Init (); R_Init (); #ifndef _WIN32 // on Win32, sound initialization has to come before video initialization, so we // can put up a popup if the sound hardware is in use S_Init (); // jkrige - fmod sound system (system) FMOD_Init(); // jkrige - fmod sound system (system) #else #ifdef GLQUAKE // FIXME: doesn't use the new one-window approach yet S_Init (); // jkrige - fmod sound system (system) FMOD_Init(); // jkrige - fmod sound system (system) #endif #endif // _WIN32 // jkrige - fmod sound system (music) //CDAudio_Init (); // jkrige - fmod sound system (music) Sbar_Init (); CL_Init (); #ifdef _WIN32 // on non win32, mouse comes before video for security reasons IN_Init (); #endif } Cbuf_InsertText ("exec quake.rc\n"); Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark (); host_initialized = true; Sys_Printf ("========Quake Initialized=========\n"); }
/* ================= Mod_LoadLighting ================= */ void Mod_LoadLighting (lump_t *l) { // 2001-09-11 Colored lightning by LordHavoc/Sarcazm/Maddes start /* if (!l->filelen) { loadmodel->lightdata = NULL; return; } loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname); memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen); */ int i; byte *in, *out, *data; byte d; char litfilename[1024]; loadedfile_t *fileinfo; // 2001-09-12 Returning information about loaded file by Maddes loadmodel->lightdata = NULL; if (external_lit->value) { // check for a .LIT file strcpy(litfilename, loadmodel->name); COM_StripExtension(litfilename, litfilename); strcat(litfilename, ".lit"); // 2001-09-12 Returning information about loaded file by Maddes start /* data = (byte*) COM_LoadHunkFile(litfilename); if (data) */ fileinfo = COM_LoadHunkFile(litfilename); if (fileinfo) // 2001-09-12 Returning information about loaded file by Maddes end { Con_DPrintf("%s loaded from %s\n", litfilename, fileinfo->path->pack ? fileinfo->path->pack->filename : fileinfo->path->filename); // 2001-09-12 Displaying where .LIT file is loaded from by Maddes data = fileinfo->data; // 2001-09-12 Returning information about loaded file by Maddes if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' && data[3] == 'T') { i = LittleLong(((int *)data)[1]); if (i == 1) { loadmodel->lightdata = data + 8; return; } else Con_Printf("Unknown .LIT file version (%d)\n", i); } else Con_Printf("Corrupt .LIT file (old version?), ignoring\n"); } // no .LIT found, expand the white lighting data to color } if (!l->filelen) return; loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, loadname); in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write out = loadmodel->lightdata; memcpy (in, mod_base + l->fileofs, l->filelen); for (i = 0;i < l->filelen;i++) { d = *in++; *out++ = d; *out++ = d; *out++ = d; } // 2001-09-11 Colored lightning by LordHavoc/Sarcazm/Maddes end }
void Host_Init(quakeparms_t *parms) { if (standard_quake) minimum_memory = MINIMUM_MEMORY; else minimum_memory = MINIMUM_MEMORY_LEVELPAK; if (COM_CheckParm("-minmemory")) parms->memsize = minimum_memory; host_parms = *parms; if (parms->memsize < minimum_memory) Sys_Error("Only %4.1f megs of memory available, can't execute game", parms->memsize / (float) 0x100000); com_argc = parms->argc; com_argv = parms->argv; Memory_Init(parms->membase, parms->memsize); Cbuf_Init(); Cmd::Init(); V_Init(); NN_init(); COM_Init(); Host_InitLocal(); W_LoadWadFile("gfx.wad"); Key_Init(); Con_Init(); M_Init(); PR_Init(); Mod_Init(); NET_Init(); SV_Init(); Bot_Init(); Con_Printf("Exe: "__TIME__" "__DATE__"\n"); Con_Printf("%4.1f megabyte heap\n", parms->memsize / (1024 * 1024.0)); if (cls.state != ca_dedicated) { host_basepal = (byte *) COM_LoadHunkFile("gfx/palette.lmp"); if (!host_basepal) Sys_Error("Couldn't load gfx/palette.lmp"); host_colormap = (byte *) COM_LoadHunkFile("gfx/colormap.lmp"); if (!host_colormap) Sys_Error("Couldn't load gfx/colormap.lmp"); IN_Init(); VID_Init(host_basepal); Draw_Init(); SCR_Init(); R_Init(); TextureManager::Init(); S_Init(); CDAudio_Init(); Sbar_Init(); CL_Init(); } Cbuf_InsertText("exec quake.rc\n"); Hunk_AllocName(0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark(); host_initialized = true; Sys_Printf("========Quake Initialized=========\n"); }
/* =============== PR_LoadProgs =============== */ void PR_LoadProgs (void) { int i; // flush the non-C variable lookup cache for (i=0 ; i<GEFV_CACHESIZE ; i++) gefvCache[i].field[0] = 0; CRC_Init (&pr_crc); progs = (dprograms_t *)COM_LoadHunkFile ("progs.dat"); if (!progs) Sys_Error ("PR_LoadProgs: couldn't load progs.dat"); Con_DPrintf ("Programs occupy %iK.\n", com_filesize/1024); for (i=0 ; i<com_filesize ; i++) CRC_ProcessByte (&pr_crc, ((byte *)progs)[i]); // byte swap the header for (i=0 ; i<sizeof(*progs)/4 ; i++) ((int *)progs)[i] = LittleLong ( ((int *)progs)[i] ); if (progs->version != PROG_VERSION) Sys_Error ("progs.dat has wrong version number (%i should be %i)", progs->version, PROG_VERSION); if (progs->crc != PROGHEADER_CRC) Sys_Error ("progs.dat system vars have been modified, progdefs.h is out of date"); pr_functions = (dfunction_t *)((byte *)progs + progs->ofs_functions); pr_strings = (char *)progs + progs->ofs_strings; pr_globaldefs = (ddef_t *)((byte *)progs + progs->ofs_globaldefs); pr_fielddefs = (ddef_t *)((byte *)progs + progs->ofs_fielddefs); pr_statements = (dstatement_t *)((byte *)progs + progs->ofs_statements); pr_global_struct = (globalvars_t *)((byte *)progs + progs->ofs_globals); pr_globals = (float *)pr_global_struct; pr_edict_size = progs->entityfields * 4 + sizeof (edict_t) - sizeof(entvars_t); // byte swap the lumps for (i=0 ; i<progs->numstatements ; i++) { pr_statements[i].op = LittleShort(pr_statements[i].op); pr_statements[i].a = LittleShort(pr_statements[i].a); pr_statements[i].b = LittleShort(pr_statements[i].b); pr_statements[i].c = LittleShort(pr_statements[i].c); } for (i=0 ; i<progs->numfunctions; i++) { pr_functions[i].first_statement = LittleLong (pr_functions[i].first_statement); pr_functions[i].parm_start = LittleLong (pr_functions[i].parm_start); pr_functions[i].s_name = LittleLong (pr_functions[i].s_name); pr_functions[i].s_file = LittleLong (pr_functions[i].s_file); pr_functions[i].numparms = LittleLong (pr_functions[i].numparms); pr_functions[i].locals = LittleLong (pr_functions[i].locals); } for (i=0 ; i<progs->numglobaldefs ; i++) { pr_globaldefs[i].type = LittleShort (pr_globaldefs[i].type); pr_globaldefs[i].ofs = LittleShort (pr_globaldefs[i].ofs); pr_globaldefs[i].s_name = LittleLong (pr_globaldefs[i].s_name); } for (i=0 ; i<progs->numfielddefs ; i++) { pr_fielddefs[i].type = LittleShort (pr_fielddefs[i].type); if (pr_fielddefs[i].type & DEF_SAVEGLOBAL) Sys_Error ("PR_LoadProgs: pr_fielddefs[i].type & DEF_SAVEGLOBAL"); pr_fielddefs[i].ofs = LittleShort (pr_fielddefs[i].ofs); pr_fielddefs[i].s_name = LittleLong (pr_fielddefs[i].s_name); } for (i=0 ; i<progs->numglobals ; i++) ((int *)pr_globals)[i] = LittleLong (((int *)pr_globals)[i]); }
/* =============== PR_LoadProgs =============== */ void PR_LoadProgs (void) { int i; // flush the non-C variable lookup cache for (i = 0; i < GEFV_CACHESIZE; i++) gefvCache[i].field[0] = 0; CRC_Init (&pr_crc); progs = (dprograms_t *)COM_LoadHunkFile ("progs.dat", NULL); if (!progs) Host_Error ("PR_LoadProgs: couldn't load progs.dat"); Con_DPrintf ("Programs occupy %iK.\n", com_filesize/1024); for (i = 0; i < com_filesize; i++) CRC_ProcessByte (&pr_crc, ((byte *)progs)[i]); // byte swap the header for (i = 0; i < (int) sizeof(*progs) / 4; i++) ((int *)progs)[i] = LittleLong ( ((int *)progs)[i] ); if (progs->version != PROG_VERSION) Host_Error ("progs.dat has wrong version number (%i should be %i)", progs->version, PROG_VERSION); if (progs->crc != PROGHEADER_CRC) Host_Error ("progs.dat system vars have been modified, progdefs.h is out of date"); pr_functions = (dfunction_t *)((byte *)progs + progs->ofs_functions); pr_strings = (char *)progs + progs->ofs_strings; if (progs->ofs_strings + progs->numstrings >= com_filesize) Host_Error ("progs.dat strings go past end of file\n"); // initialize the strings pr_numknownstrings = 0; pr_maxknownstrings = 0; pr_stringssize = progs->numstrings; if (pr_knownstrings) Z_Free ((void *)pr_knownstrings); pr_knownstrings = NULL; PR_SetEngineString(""); pr_globaldefs = (ddef_t *)((byte *)progs + progs->ofs_globaldefs); pr_fielddefs = (ddef_t *)((byte *)progs + progs->ofs_fielddefs); pr_statements = (dstatement_t *)((byte *)progs + progs->ofs_statements); pr_global_struct = (globalvars_t *)((byte *)progs + progs->ofs_globals); pr_globals = (float *)pr_global_struct; // byte swap the lumps for (i = 0; i < progs->numstatements; i++) { pr_statements[i].op = LittleShort(pr_statements[i].op); pr_statements[i].a = LittleShort(pr_statements[i].a); pr_statements[i].b = LittleShort(pr_statements[i].b); pr_statements[i].c = LittleShort(pr_statements[i].c); } for (i = 0; i < progs->numfunctions; i++) { pr_functions[i].first_statement = LittleLong (pr_functions[i].first_statement); pr_functions[i].parm_start = LittleLong (pr_functions[i].parm_start); pr_functions[i].s_name = LittleLong (pr_functions[i].s_name); pr_functions[i].s_file = LittleLong (pr_functions[i].s_file); pr_functions[i].numparms = LittleLong (pr_functions[i].numparms); pr_functions[i].locals = LittleLong (pr_functions[i].locals); } for (i = 0; i < progs->numglobaldefs; i++) { pr_globaldefs[i].type = LittleShort (pr_globaldefs[i].type); pr_globaldefs[i].ofs = LittleShort (pr_globaldefs[i].ofs); pr_globaldefs[i].s_name = LittleLong (pr_globaldefs[i].s_name); } pr_alpha_supported = false; //johnfitz for (i = 0; i < progs->numfielddefs; i++) { pr_fielddefs[i].type = LittleShort (pr_fielddefs[i].type); if (pr_fielddefs[i].type & DEF_SAVEGLOBAL) Host_Error ("PR_LoadProgs: pr_fielddefs[i].type & DEF_SAVEGLOBAL"); pr_fielddefs[i].ofs = LittleShort (pr_fielddefs[i].ofs); pr_fielddefs[i].s_name = LittleLong (pr_fielddefs[i].s_name); //johnfitz -- detect alpha support in progs.dat if (!strcmp(pr_strings + pr_fielddefs[i].s_name,"alpha")) pr_alpha_supported = true; //johnfitz } for (i = 0; i < progs->numglobals; i++) ((int *)pr_globals)[i] = LittleLong (((int *)pr_globals)[i]); pr_edict_size = progs->entityfields * 4 + sizeof(edict_t) - sizeof(entvars_t); // round off to next highest whole word address (esp for Alpha) // this ensures that pointers in the engine data area are always // properly aligned pr_edict_size += sizeof(void *) - 1; pr_edict_size &= ~(sizeof(void *) - 1); }
/* ==================== Host_Init ==================== */ void Host_Init (quakeparms_t *parms) { #if defined(_WIN32) && defined(GLQUAKE) FILE *fp = fopen("opengl32.dll","r"); if (fp) { // exists fclose(fp); Sys_Error ("OpenGL32.dll found in Quake folder. You must delete this file from your Quake folder to run this engine."); } #endif // Windows only if (standard_quake) minimum_memory = MINIMUM_MEMORY; else minimum_memory = MINIMUM_MEMORY_LEVELPAK; if (COM_CheckParm ("-minmemory")) parms->memsize = minimum_memory; host_parms = *parms; if (parms->memsize < minimum_memory) Sys_Error ("Only %4.1f megs of memory available, can't execute game and memsize = %i and minimum memory is %i", parms->memsize / (float)0x100000, parms->memsize, minimum_memory); com_argc = parms->argc; com_argv = parms->argv; #ifdef SUPPORTS_CHEATFREE // JPG 3.00 - moved this here #if defined(_WIN32) srand(time(NULL) ^ _getpid()); #else srand(time(NULL) ^ getpid()); #endif #endif Memory_Init (parms->membase, parms->memsize); Cbuf_Init (); Cmd_Init (); Cvar_Init (); V_Init (); Chase_Init (); Host_InitVCR (parms); COM_Init (parms->basedir); Host_InitLocal (); W_LoadWadFile ("gfx.wad"); Key_Init (); Con_Init (); M_Init (); PR_Init (); Mod_Init (); #ifdef PROQUAKE_EXTENSION Security_Init (); // JPG 3.20 - cheat free #endif NET_Init (); SV_Init (); #ifdef PROQUAKE_EXTENSION IPLog_Init (); // JPG 1.05 - ip address logging Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); #endif #ifdef PSP_SYSTEM_STATS Con_Printf ("Insomnia ProQuake Engine v 4.71 Rev4\n"); //(EBOOT: "__TIME__" "__DATE__")\n"); int currentCPU = scePowerGetCpuClockFrequency(); int currentVRAM = sceGeEdramGetSize(); int currentVRAMADD = sceGeEdramGetAddr(); int currentRAMAVAIL = sceKernelTotalFreeMemSize(); #ifdef NORMAL_MODEL Con_Printf ("PSP Normal 32MB RAM Mode \n"); #endif #ifdef SLIM_MODEL Con_Printf ("PSP Slim 64MB RAM Mode \n"); #endif Con_Printf ("%4.1f megabyte heap \n",parms->memsize/ (1024*1024.0)); Con_Printf ("%4.1f PSP application heap \n",1.0f*PSP_HEAP_SIZE_MB); Con_Printf ("%d VRAM \n",currentVRAM); Con_Printf ("%d VRAM Address \n",currentVRAMADD); Con_Printf ("%d Current Total RAM \n",currentRAMAVAIL); Con_Printf ("CPU Speed %d MHz\n", currentCPU); Con_Printf ("%s \n", com_gamedir); R_InitTextures (); // needed even for dedicated servers #else Con_Printf ("%4.1f megabyte heap\n",parms->memsize/ (1024*1024.0)); #endif if (cls.state != ca_dedicated) { host_basepal = (byte *)COM_LoadHunkFile ("gfx/palette.lmp"); if (!host_basepal) Sys_Error ("Couldn't load gfx/palette.lmp"); host_colormap = (byte *)COM_LoadHunkFile ("gfx/colormap.lmp"); if (!host_colormap) Sys_Error ("Couldn't load gfx/colormap.lmp"); #ifndef _WIN32 // on non win32, mouse comes before video for security reasons IN_Init (); #endif VID_Init (host_basepal); Draw_Init (); SCR_Init (); R_Init (); #ifndef _WIN32 // on Win32, sound initialization has to come before video initialization, so we // can put up a popup if the sound hardware is in use S_Init (); #else #ifdef GLQUAKE // FIXME: doesn't use the new one-window approach yet S_Init (); #endif #endif // _WIN32 CDAudio_Init (); Sbar_Init (); CL_Init (); #ifdef _WIN32 // on non win32, mouse comes before video for security reasons IN_Init (); #endif #ifdef _WIN32 // Baker: 3.99m to get sys info // must be AFTER video init stuff Sys_InfoInit(); // We don't care about dedicated servers for this // Baker 3.76 - Autoplay demo if (com_argc >= 2) { char *infile = com_argv[1]; if (infile[0] && infile[0] != '-' && infile[0] != '+') { char tmp[1024] = {0}, *ext = COM_FileExtension(infile); if (!strncasecmp(ext, "dem", sizeof("dem"))) snprintf(tmp, sizeof(tmp), "playdemo \"%s\"\n", infile); if (tmp[0]) { nostartdemos = true; Cbuf_AddText(tmp); } } } #endif } Cbuf_InsertText ("exec quake.rc\n"); #ifdef PROQUAKE_EXTENSION // Baker 3.80x: this is a hack if (!isDedicated) { Cbuf_AddText ("\nsavefov\n"); Cbuf_AddText ("savesensitivity\n"); } #endif Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark (); host_initialized = true; Con_Printf ("Host Initialized\n"); Sys_Printf ("========Quake Initialized=========\n"); }