/** * @brief Send the clc_teaminfo command to server * @sa GAME_SendCurrentTeamSpawningInfo */ static void CL_SpawnSoldiers_f (void) { if (!CL_OnBattlescape()) return; if (cl.spawned) return; cl.spawned = true; GAME_SpawnSoldiers(); }
static bool M_PlayRandomByCategory (int category) { if (category != MUSIC_BATTLESCAPE && CL_OnBattlescape()) return false; if (!musicArrayLength[category]) return false; const int rnd = rand() % musicArrayLength[category]; music.category = category; Com_Printf("Music: track changed from %s to %s.\n", music.currentTrack, musicArrays[category][rnd]); Cvar_Set("snd_music", "%s", musicArrays[category][rnd]); return snd_music->modified; }
/** * @sa CL_Frame */ void S_Frame (void) { if (snd_init && snd_init->modified) { S_Restart_f(); snd_init->modified = false; } if (!s_env.initialized) return; M_Frame(); if (CL_OnBattlescape()) { int i; s_channel_t *ch; le_t *le; /* update right angle for stereo panning */ VectorCopy(cl.cam.axis[AXIS_RIGHT], s_env.right); S_MumbleUpdate(cl.cam.camorg, cl.cam.axis[AXIS_FORWARD], cl.cam.axis[AXIS_RIGHT], cl.cam.axis[AXIS_UP]); /* update spatialization for current sounds */ ch = s_env.channels; for (i = 0; i < MAX_CHANNELS; i++, ch++) { if (!ch->sample) continue; /* reset channel's count for loop samples */ ch->count = 0; S_SpatializeChannel(ch); } /* ambient sounds */ le = NULL; while ((le = LE_GetNextInUse(le))) { if (le->type == ET_SOUND) { s_sample_t *sample = S_GetSample(le->sampleIdx); int j; for (j = 0; j < MAX_CHANNELS; j++) { if (s_env.channels[j].sample == sample) break; } if (j == MAX_CHANNELS) S_LoopSample(le->origin, sample, le->volume, le->attenuation); } } } }
/** * @brief This is called every frame, and can also be called explicitly to flush text to the screen * @sa UI_Draw * @sa CL_ViewRender * @sa SCR_DrawConsole * @sa SCR_DrawCursor */ void SCR_UpdateScreen (void) { if (cls.waitingForStart) return; /* if the screen is disabled (loading plaque is up, or vid mode changing) * do nothing at all */ if (cls.disableScreen) { if (CL_Milliseconds() - cls.disableScreen > 120000 && refdef.ready) { cls.disableScreen = 0; Com_Printf("Loading plaque timed out.\n"); return; } } /* not initialized yet */ if (!screenInitialized) return; R_BeginFrame(); /* draw scene, if it is need */ CL_ViewRender(); /* draw the ui on top of the render view */ UI_Draw(); SCR_DrawConsole(); if (cl_fps->integer) SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 10, 0, va("fps: %3.1f", cls.framerate)); if (scr_rspeed->integer) { if (CL_OnBattlescape()) SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80, va("brushes: %6i alias: %6i\n", refdef.brushCount, refdef.aliasCount)); else SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80, va("alias: %6i\n", refdef.aliasCount)); SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight, va("batches: %6i\n", refdef.batchCount)); if (r_programs->integer) { SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight * 2, va("FFP->shader switches: %6i\n", refdef.FFPToShaderCount)); SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight * 3, va("shader->shader switches: %6i\n", refdef.shaderToShaderCount)); SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight * 4, va("shader->FFP switches: %6i\n", refdef.shaderToFFPCount)); } } SCR_DrawCursor(); R_EndFrame(); }
/** * @brief Changes the music if it suits the current situation * @todo Make the music a scriptable list */ static void M_Change_f (void) { if (!s_env.initialized || !music.playing) return; if (Cmd_Argc() != 2) { Com_Printf("Usage: %s <geoscape|battlescape|main|aircombat>\n", Cmd_Argv(0)); return; } const char* type = Cmd_Argv(1); int category; if (Q_streq(type, "geoscape")) { category = MUSIC_GEOSCAPE; } else if (Q_streq(type, "battlescape")) { category = MUSIC_BATTLESCAPE; } else if (Q_streq(type, "main")) { category = MUSIC_MAIN; } else if (Q_streq(type, "aircombat")) { category = MUSIC_AIRCOMBAT; } else { Com_Printf("Invalid parameter given!\n"); return; } if (category != MUSIC_BATTLESCAPE && CL_OnBattlescape()) { Com_DPrintf(DEBUG_SOUND, "Not changing music to %s - we are on the battlescape!\n", type); return; } if (!musicArrayLength[category]) { Com_Printf("M_Change_f: Could not find any %s themed music tracks!\n", type); return; } M_PlayRandomByCategory(category); }
/** * @brief Called by the system between frames for both key up and key down events * @note Should NOT be called during an interrupt! * @sa Key_Message */ void Key_Event (unsigned int key, unsigned short unicode, qboolean down, unsigned time) { char cmd[MAX_STRING_CHARS]; /* unbindable key */ if (key >= K_KEY_SIZE) return; /* any key (except F1-F12) during the sequence mode will bring up the menu */ if (cls.keyDest == key_game && down) { if (UI_KeyPressed(key, unicode)) return; } /* menu key is hardcoded, so the user can never unbind it */ if (key == K_ESCAPE) { if (!down) return; switch (cls.keyDest) { case key_console: Con_ToggleConsole_f(); break; default: Com_Error(ERR_FATAL, "Bad cls.key_dest"); } return; } /* track if any key is down for BUTTON_ANY */ keyDown[key] = down; if (!down) { int i; /* key up events only generate commands if the game key binding is * a button command (leading + sign). These will occur even in console mode, * to keep the character from continuing an action started before a console * switch. Button commands include the kenum as a parameter, so multiple * downs can be matched with ups */ const char *kb = menuKeyBindings[key]; /* this loop ensures, that every down event reaches it's proper kbutton_t */ for (i = 0; i < 3; i++) { if (kb && kb[0] == '+') { /* '-' means we have released the key * the key number is used to determine whether the kbutton_t is really * released or whether any other bound key will still ensure that the * kbutton_t is pressed * the time is the msec value when the key was released */ Com_sprintf(cmd, sizeof(cmd), "-%s %i %i\n", kb + 1, key, time); Cbuf_AddText(cmd); } if (i == 0) kb = keyBindings[key]; else kb = battleKeyBindings[key]; } return; } /* if not a consolekey, send to the interpreter no matter what mode is */ if (cls.keyDest == key_game || (key >= K_MOUSE1 && key <= K_MWHEELUP)) { /* Some keyboards need modifiers to access key values that are * present as bare keys on other keyboards. Smooth over the difference * here by using the translated value if there is a binding for it. */ const char *kb = NULL; if (mouseSpace == MS_UI && unicode >= 32 && unicode < 127) kb = menuKeyBindings[unicode]; if (!kb && mouseSpace == MS_UI) kb = menuKeyBindings[key]; if (!kb && unicode >= 32 && unicode < 127) kb = keyBindings[unicode]; if (!kb) kb = keyBindings[key]; if (!kb && CL_OnBattlescape()) kb = battleKeyBindings[key]; if (kb) { if (kb[0] == '+') { /* button commands add keynum and time as a parm */ /* '+' means we have pressed the key * the key number is used because the kbutton_t can be 'pressed' by several keys * the time is the msec value when the key was pressed */ Com_sprintf(cmd, sizeof(cmd), "%s %i %i\n", kb, key, time); Cbuf_AddText(cmd); } else { Cbuf_AddText(kb); Cbuf_AddText("\n"); } if (cls.keyDest == key_game) return; } } if (!down) return; /* other systems only care about key down events */ switch (cls.keyDest) { case key_game: case key_console: Key_Console(key, unicode); break; default: Com_Error(ERR_FATAL, "Bad cls.key_dest"); } }
/** * @brief Middle mouse click */ static void CL_ActionDown_f (void) { if (!CL_OnBattlescape()) return; IN_KeyDown(&in_pantilt); }
/** * @brief Switch one worldlevel down */ static void CL_LevelDown_f (void) { if (!CL_OnBattlescape()) return; Cvar_SetValue("cl_worldlevel", (cl_worldlevel->integer > 0) ? cl_worldlevel->integer - 1 : 0); }
/** * @brief Switch one worldlevel up */ static void CL_LevelUp_f (void) { if (!CL_OnBattlescape()) return; Cvar_SetValue("cl_worldlevel", (cl_worldlevel->integer < cl.mapMaxLevel - 1) ? cl_worldlevel->integer + 1 : cl.mapMaxLevel - 1); }