static JSBool sys_getglconfig(JSContext *cx, unsigned argc, jsval *vp) { JSObject *res; jsval rval; glconfig_t cfg; jsval vidWidth, vidHeight; memset(&cfg,0,sizeof(glconfig_t)); trap_GetGlconfig(&cfg); res = JS_NewObject(cx,NULL,NULL,NULL); if (!res) { JS_ReportError(cx, "Unable to create glConfig object"); return JS_FALSE; } rval = OBJECT_TO_JSVAL(res); JS_NewNumberValue(cx, cfg.vidWidth, &vidWidth); JS_SetProperty(cx, res, "vidWidth", &vidWidth); JS_NewNumberValue(cx, cfg.vidHeight, &vidHeight); JS_SetProperty(cx, res, "vidHeight", &vidHeight); JS_SET_RVAL(cx, vp, rval); return JS_TRUE; }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { const char *s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); memset( cg_weapons, 0, sizeof(cg_weapons) ); cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; // load a few needed things before we do any screen updates cgs.media.charsetShader = trap_R_RegisterShader( "interface/fonts/font0.png" ); cgs.media.whiteShader = trap_R_RegisterShader( "white" ); cgs.media.clearShader = trap_R_RegisterShader( "clear" ); cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "interface/fonts/font1.png" ); cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "interface/fonts/font1Glow.png" ); cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "interface/fonts/font2.png" ); CG_RegisterCvars(); CG_InitConsoleCommands(); cg.weaponSelect = 1; // get the rendering configuration from the client system trap_GetGlconfig( &cgs.glconfig ); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // get the gamestate from the client system trap_GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_PRODUCT_VERSION ); if ( strcmp( s, PRODUCT_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", PRODUCT_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); CG_ParseServerinfo(); // load the new map CG_LoadingString( "collision map" ); trap_CM_LoadMap( cgs.mapname ); cg.loading = qtrue; // force players to load instead of defer CG_LoadingString( "sounds" ); CG_RegisterSounds(); CG_LoadingString( "graphics" ); CG_RegisterGraphics(); CG_LoadingString( "clients" ); CG_RegisterClients(); // if low on memory, some clients will be deferred cg.loading = qfalse; // future players will be deferred CG_InitLocalEntities(); // ADDING FOR ZEQ2 CG_FrameHist_Init(); CG_InitTrails(); CG_InitParticleSystems(); CG_InitBeamTables(); CG_InitRadarBlips(); // END ADDING CG_InitMarkPolys(); // remove the last loading update cg.infoScreenText[0] = 0; // Make sure we have update values (scores) CG_SetConfigValues(); CG_LoadingString( "" ); CG_ShaderStateChanged(); trap_S_ClearLoopingSounds( qtrue ); }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { const char *s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); memset( cg_weapons, 0, sizeof(cg_weapons) ); memset( cg_items, 0, sizeof(cg_items) ); cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; // load a few needed things before we do any screen updates cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" ); cgs.media.whiteShader = trap_R_RegisterShader( "white" ); cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "menu/art/font1_prop.tga" ); cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "menu/art/font1_prop_glo.tga" ); cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "menu/art/font2_prop.tga" ); CG_RegisterCvars(); CG_InitConsoleCommands(); cg.weaponSelect = WP_MACHINEGUN; cgs.redflag = cgs.blueflag = -1; // For compatibily, default to unset for cgs.flagStatus = -1; // old servers // get the rendering configuration from the client system trap_GetGlconfig( &cgs.glconfig ); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // get the gamestate from the client system trap_GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_GAME_VERSION ); if ( strcmp( s, GAME_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); CG_ParseServerinfo(); // load the new map CG_LoadingString( "collision map" ); trap_CM_LoadMap( cgs.mapname ); cg.loading = qtrue; // force players to load instead of defer CG_LoadingString( "sounds" ); CG_RegisterSounds(); CG_LoadingString( "graphics" ); CG_RegisterGraphics(); CG_LoadingString( "clients" ); CG_RegisterClients(); // if low on memory, some clients will be deferred cg.loading = qfalse; // future players will be deferred CG_InitLocalEntities(); CG_InitMarkPolys(); // remove the last loading update cg.infoScreenText[0] = 0; // Make sure we have update values (scores) CG_SetConfigValues(); CG_StartMusic(); CG_LoadingString( "" ); CG_ShaderStateChanged(); trap_S_ClearLoopingSounds( qtrue ); }
/** Generates and draws a game scene and status information at the given time. */ void CG_DrawActiveFrame(int serverTime, stereoFrame_t stereoView, qboolean demoPlayback) { int inwater; cg.totalTime = serverTime; // TODO predict pause end and pauseTime which is useful for high ping players if (cgs.pauseStart) { cg.time = cgs.pauseStart; } else { // cg.time needs to be the same as level.time, otherwise // animations and missiles will skip cg.time = cg.totalTime - cgs.pauseTime; } cg.demoPlayback = demoPlayback; // get the rendering configuration from the client system trap_GetGlconfig(&cgs.glconfig); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // update cvars CG_UpdateCvars(); // if we are only updating the screen as a loading // pacifier, don't even try to read snapshots if (cg.showInfoScreen) { CG_DrawInformation(); return; } // any looped sounds will be respecified as entities // are added to the render list trap_S_ClearLoopingSounds(qfalse); // clear all the render lists trap_R_ClearScene(); // set up cg.snap and possibly cg.nextSnap CG_ProcessSnapshots(); // if we haven't received any snapshots yet, all // we can draw is the information screen if (!cg.snap || (cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE)) { CG_DrawInformation(); return; } // let the client system know what our weapon and zoom settings are trap_SetUserCmdValue(cg.weaponSelect, cg.zoomSensitivity); // this counter will be bumped for every valid scene we generate cg.clientFrame++; // update cg.predictedPlayerState CG_PredictPlayerState(); // decide on third person view cg.renderingThirdPerson = cg_thirdPerson.integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0); // build cg.refdef inwater = CG_CalcViewValues(); // first person blend blobs, done after AnglesToAxis if (!cg.renderingThirdPerson) { CG_DamageBlendBlob(); } // build the render lists if (!cg.hyperspace) { CG_AddPacketEntities(); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); CG_AddParticles(); CG_AddLocalEntities(); CG_AddSpawnpoints(); } CG_AddViewWeapon(&cg.predictedPlayerState); // add buffered sounds CG_PlayBufferedSounds(); // finish up the rest of the refdef if (cg.testModelEntity.hModel) { CG_AddTestModel(); } cg.refdef.time = cg.time; memcpy(cg.refdef.areamask, cg.snap->areamask, sizeof(cg.refdef.areamask)); CG_CountdownSounds(); CG_PopReward(); // warning sounds when powerup is wearing off CG_PowerupTimerSounds(); // update audio positions trap_S_Respatialize(cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater); // make sure the lagometerSample and frame timing isn't done twice when in stereo if (stereoView != STEREO_RIGHT) { cg.frametime = cg.time - cg.oldTime; if (cg.frametime < 0) { cg.frametime = 0; } cg.oldTime = cg.time; CG_AddLagometerFrameInfo(); } if (cg_timescale.value != cg_timescaleFadeEnd.value) { if (cg_timescale.value < cg_timescaleFadeEnd.value) { cg_timescale.value += cg_timescaleFadeSpeed.value * ((float)cg.frametime) / 1000; if (cg_timescale.value > cg_timescaleFadeEnd.value) cg_timescale.value = cg_timescaleFadeEnd.value; } else { cg_timescale.value -= cg_timescaleFadeSpeed.value * ((float)cg.frametime) / 1000; if (cg_timescale.value < cg_timescaleFadeEnd.value) cg_timescale.value = cg_timescaleFadeEnd.value; } if (cg_timescaleFadeSpeed.value) { trap_Cvar_Set("timescale", va("%f", cg_timescale.value)); } } // actually issue the rendering calls CG_DrawActive(stereoView); if (cg_stats.integer) { CG_Printf("cg.clientFrame:%i\n", cg.clientFrame); } }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum, int randomSeed ) { const char *s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); srand( randomSeed ); cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; trap_R_RegisterFont( "facfont-20", 0, &cgs.media.facfont ); trap_R_RegisterFont( "verdana-14", 0, &cgs.media.verdana ); // load a few needed things before we do any screen updates // cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" ); cgs.media.whiteShader = trap_R_RegisterShader( "*white" ); // cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "menu/art/font1_prop.tga" ); // cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "menu/art/font1_prop_glo.tga" ); // cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "menu/art/font2_prop.tga" ); cgs.media.blackShader = trap_R_RegisterShaderNoMip( "textures/mohmenu/black.tga" ); CG_RegisterCvars(); CG_InitConsoleCommands(); // get the rendering configuration from the client system trap_GetGlconfig( &cgs.glconfig ); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // get the gamestate from the client system trap_GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_GAME_VERSION ); if ( strcmp( s, GAME_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); CG_ParseServerinfo(); // load the new map CG_LoadingString( "collision map" ); trap_CM_LoadMap( cgs.mapname ); CG_LoadingString( "sounds" ); CG_RegisterSounds(); CG_LoadUbersound(); CG_LoadingString( "graphics" ); CG_RegisterGraphics(); CG_LoadingString( "clients" ); CG_RegisterClients(); // if low on memory, some clients will be deferred CG_InitLocalEntities(); CG_InitMarkPolys(); CG_InitEventSystem(); CG_InitBeams(); CG_InitRainEffect(); // remove the last loading update cg.infoScreenText[0] = 0; // Make sure we have update values (scores) CG_SetConfigValues(); CG_StartMusic(); CG_LoadingString( "" ); trap_S_ClearLoopingSounds( qtrue ); }