static void Monitor_Print(void) { int i, k; if(!monitoredBytes) { Con_Message("Nothing has been sent yet."); return; } Con_Message("%u bytes sent (%i packets).", monitoredBytes, monitoredPackets); for(i = 0, k = 0; i < 256; ++i) { if(!k) Con_Printf(" "); Con_Printf("%10.10lf", (double)(monitor[i]) / (double)monitoredBytes); // Break lines. if(++k == 4) { k = 0; Con_Printf(",\n"); } else { Con_Printf(", "); } } if(k) Con_Printf("\n"); }
//=========================================================================== // DM_FModInit //=========================================================================== int DM_FModInit(void) { if(inited) return true; if(FSOUND_GetVersion() < FMOD_VERSION) { Con_Message ("DM_FModInit: You are using the wrong version of FMOD.DLL!\n" " You should be using version %.02f.\n", FMOD_VERSION); return false; } if(!FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND)) { Con_Message("DM_FModInit: Can't use DirectSound.\n"); if(!FSOUND_SetOutput(FSOUND_OUTPUT_WINMM)) { Con_Message("DM_FModInit: Can't use WINMM!! Aborting...\n"); return false; } } if(!FSOUND_Init(44100, 16, 0)) { Con_Message("DM_FModInit: Init failed. (%s)\n", FMOD_ErrorString(FSOUND_GetError())); return false; } ext_inited = false; return inited = true; }
static void CheatDebugFunc(player_t *player, cheat_t * cheat) { char lumpName[9]; char textBuffer[256]; subsector_t *sub; if(!player->plr->mo || !usergame) return; P_GetMapLumpName(gameepisode, gamemap, lumpName); sprintf(textBuffer, "MAP [%s] X:%5d Y:%5d Z:%5d", lumpName, player->plr->mo->pos[VX] >> FRACBITS, player->plr->mo->pos[VY] >> FRACBITS, player->plr->mo->pos[VZ] >> FRACBITS); P_SetMessage(player, textBuffer, false); // Also print some information to the console. Con_Message(textBuffer); sub = player->plr->mo->subsector; Con_Message("\nSubsector %i:\n", P_ToIndex(sub)); Con_Message(" Floorz:%d pic:%d\n", P_GetIntp(sub, DMU_FLOOR_HEIGHT), P_GetIntp(sub, DMU_FLOOR_MATERIAL)); Con_Message(" Ceilingz:%d pic:%d\n", P_GetIntp(sub, DMU_CEILING_HEIGHT), P_GetIntp(sub, DMU_CEILING_MATERIAL)); Con_Message("Player height:%g Player radius:%x\n", player->plr->mo->height, player->plr->mo->radius); }
boolean B_ParseMouseTypeAndId(const char* desc, ddeventtype_t* type, int* id) { // Maybe it's one of the buttons? *id = I_GetKeyByName(I_GetDevice(IDEV_MOUSE, false), desc); if(*id >= 0) { // Got it. *type = E_TOGGLE; return true; } if(!strncasecmp(desc, "button", 6) && strlen(desc) > 6) // generic button { *type = E_TOGGLE; *id = strtoul(desc + 6, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(IDEV_MOUSE, false)->numKeys) { Con_Message("B_ParseMouseTypeAndId: Button %i does not exist.", *id); return false; } } else { // Try to find the axis. *type = E_AXIS; *id = I_GetAxisByName(I_GetDevice(IDEV_MOUSE, false), desc); if(*id < 0) { Con_Message("B_ParseMouseTypeAndId: Axis \"%s\" is not defined.", desc); return false; } } return true; }
int DirectInput_Init(void) { HRESULT hr; if(dInput || dInput3) return true; // Create the DirectInput interface instance. Try version 8 first. if(FAILED(hr = CoCreateInstance(CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectInput8, (LPVOID*)&dInput)) || FAILED(hr = dInput->Initialize(app.hInstance, DIRECTINPUT_VERSION))) { Con_Message("DirectInput 8 init failed (0x%x).", hr); // Try the older version 3 interface instead. // I'm not sure if this works correctly. if(FAILED(hr = CoCreateInstance(CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, IID_IDirectInput2W, (LPVOID*)&dInput3)) || FAILED(hr = dInput3->Initialize(app.hInstance, 0x0300))) { Con_Message("Failed to create DirectInput 3 object (0x%x).", hr); return false; } Con_Message("Using DirectInput 3."); } if(!dInput && !dInput3) { Con_Message(" DirectInput init failed."); return false; } return true; }
boolean B_ParseKeyId(const char* desc, int* id) { // The possibilies: symbolic key name, or "codeNNN". if(!strncasecmp(desc, "code", 4) && strlen(desc) == 7) { if(desc[4] == 'x' || desc[4] == 'X') { // Hexadecimal. *id = strtoul(desc + 5, NULL, 16); } else { // Decimal. *id = strtoul(desc + 4, NULL, 10); if(*id <= 0 || *id > 255) { Con_Message("B_ParseKeyId: Key code %i out of range.", *id); return false; } } } else { // Symbolic key name. *id = B_KeyForShortName(desc); if(!*id) { Con_Message("B_ParseKeyId: Unknown key \"%s\".", desc); return false; } } return true; }
/** * Initialize platform level services. * * \note This must be called from the main thread due to issues with the devices * we use via the WINAPI, MCI (cdaudio, mixer etc) on the WIN32 platform. */ void Sys_Init(void) { uint startTime; Con_Message("Setting up platform state..."); startTime = (verbose >= 2? Timer_RealMilliseconds() : 0); VERBOSE( Con_Message("Initializing Audio subsystem...") ) S_Init(); #ifdef DENG_CATCH_SIGNALS // Register handler for abnormal situations (in release build). signal(SIGSEGV, handler); signal(SIGTERM, handler); signal(SIGILL, handler); signal(SIGFPE, handler); signal(SIGILL, handler); signal(SIGABRT, handler); #endif #ifndef WIN32 // We are not worried about broken pipes. When a TCP connection closes, // we prefer to receive an error code instead of a signal. signal(SIGPIPE, SIG_IGN); #endif VERBOSE( Con_Message("Initializing Network subsystem...") ) N_Init(); VERBOSE2( Con_Message("Sys_Init: Completed in %.2f seconds.", (Timer_RealMilliseconds() - startTime) / 1000.0f) ); }
//=========================================================================== // CCmdListActs //=========================================================================== int CCmdListActs(int argc, char **argv) { action_t *act; Con_Message("Action commands registered by the game DLL:\n"); for(act = ddactions; act->name[0]; act++) Con_Message(" %s\n", act->name); return true; }
static boolean I_InitKeyboard(void) { HWND hWnd; HRESULT hr; hWnd = Sys_GetWindowHandle(mainWindowIdx); if(!hWnd) { Con_Error("I_Init: Main window not available, cannot init keyboard."); return false; } // Create the keyboard device. hr = IDirectInput_CreateDevice(dInput, &GUID_SysKeyboard, &didKeyb, 0); if(FAILED(hr)) { Con_Message("I_Init: Failed to create keyboard device (0x%x).\n", hr); return false; } // Setup the keyboard input device. hr = IDirectInputDevice_SetDataFormat(didKeyb, &c_dfDIKeyboard); if(FAILED(hr)) { Con_Message("I_Init: Failed to set keyboard data format (0x%x).\n", hr); return false; } // Set behaviour. hr = IDirectInputDevice_SetCooperativeLevel(didKeyb, hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); if(FAILED(hr)) { Con_Message("I_Init: Failed to set keyboard co-op level (0x%x).\n", hr); return false; } // The input buffer size. hr = I_SetProperty(didKeyb, DIPROP_BUFFERSIZE, DIPH_DEVICE, 0, KEYBUFSIZE); if(FAILED(hr)) { Con_Message("I_Init: Failed to set keyboard buffer size (0x%x).\n", hr); return false; } // We'll be needing the DIKey to DDKey translation table. initDIKeyToDDKeyTlat(); return true; }
static void initMixerLine(mixerdata_t* mix, DWORD type) { memset(mix, 0, sizeof(*mix)); mix->line.cbStruct = sizeof(mix->line); mix->line.dwComponentType = type; if((res = mixerGetLineInfo((HMIXEROBJ) mixer, &mix->line, MIXER_GETLINEINFOF_COMPONENTTYPE)) != MMSYSERR_NOERROR) { if(verbose) Con_Message(" Error getting line info: Error %i", res); return; } if(verbose) { Con_Message(" Destination line idx: %i", mix->line.dwDestination); Con_Message(" Line ID: 0x%x", mix->line.dwLineID); Con_Message(" Channels: %i", mix->line.cChannels); Con_Message(" Controls: %i", mix->line.cControls); Con_Message(" Name: %s (%s)", mix->line.szName, mix->line.szShortName); } mix->controls.cbStruct = sizeof(mix->controls); mix->controls.dwLineID = mix->line.dwLineID; mix->controls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; mix->controls.cControls = 1; mix->controls.cbmxctrl = sizeof(mix->volume); mix->controls.pamxctrl = &mix->volume; if((res = mixerGetLineControls((HMIXEROBJ) mixer, &mix->controls, MIXER_GETLINECONTROLSF_ONEBYTYPE)) != MMSYSERR_NOERROR) { if(verbose) Con_Message(" Error getting line controls " "(vol): error %i", res); return; } if(verbose) { Con_Message(" Volume control ID: 0x%x", mix->volume.dwControlID); Con_Message(" Name: %s (%s)", mix->volume.szName, mix->volume.szShortName); Con_Message(" Min/Max: %i/%i", mix->volume.Bounds.dwMinimum, mix->volume.Bounds.dwMaximum); } // This mixer line is now available. mix->available = true; }
/** * Print status information about the workings of data compression * in the network buffer. * * @note Currently numOutBytes excludes transmission header, while * numSentBytes includes every byte written to the socket. * In other words, the efficiency includes protocol overhead. */ void N_PrintTransmissionStats(void) { if(numOutBytes == 0) { Con_Message("Transmission efficiency: Nothing has been sent yet."); } else { Con_Message("Transmission efficiency: %.3f%% (data: %i bytes, sent: %i " "bytes)", 100 - (100.0f * numSentBytes) / numOutBytes, (int)numOutBytes, (int)numSentBytes); } }
boolean I_InitMouse(void) { HWND hWnd; HRESULT hr; if(ArgCheck("-nomouse") || novideo) return false; hWnd = Sys_GetWindowHandle(mainWindowIdx); if(!hWnd) { Con_Error("I_InitMouse: Main window not available, cannot init mouse."); return false; } hr = IDirectInput_CreateDevice(dInput, &GUID_SysMouse, &didMouse, 0); if(FAILED(hr)) { Con_Message("I_InitMouse: Failed to create device (0x%x).\n", hr); return false; } // Set data format. hr = IDirectInputDevice_SetDataFormat(didMouse, &c_dfDIMouse2); if(FAILED(hr)) { Con_Message("I_InitMouse: Failed to set data format (0x%x).\n", hr); goto kill_mouse; } // Set behaviour. hr = IDirectInputDevice_SetCooperativeLevel(didMouse, hWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE); if(FAILED(hr)) { Con_Message("I_InitMouse: Failed to set co-op level (0x%x).\n", hr); goto kill_mouse; } // Acquire the device. IDirectInputDevice_Acquire(didMouse); // Init was successful. return true; kill_mouse: I_SAFE_RELEASE(didMouse); return false; }
static void initStateConditions(fi_state_t* s) { // Only the server is able to figure out the truth values of all the conditions. if(IS_CLIENT) { // Set the presets. s->conditions.secret = false; s->conditions.leave_hub = false; return; } #if __JHEXEN__ s->conditions.secret = false; // Current hub has been completed? s->conditions.leave_hub = (P_GetMapCluster(gameMap) != P_GetMapCluster(nextMap)); # ifdef _DEBUG Con_Message("Infine state condition: leave_hub=%i", s->conditions.leave_hub); # endif #else s->conditions.secret = secretExit; // Only Hexen has hubs. s->conditions.leave_hub = false; #endif }
/** * Sets the new palette based upon current values of player->damageCount * and player->bonusCount */ void R_UpdateViewFilter(int player) { player_t* plr = players + player; int palette = 0; if(player < 0 || player >= MAXPLAYERS) { #if _DEBUG Con_Message("Warning: R_UpdateViewFilter: Invalid player #%i, ignoring.", player); #endif return; } // Not currently present? if(!plr->plr->inGame) return; if(plr->damageCount) { palette = (plr->damageCount + 7) >> 3; if(palette >= NUMREDPALS) { palette = NUMREDPALS - 1; } palette += STARTREDPALS; }
boolean B_ParseAxisPosition(const char* desc, ebstate_t* state, float* pos) { if(!strncasecmp(desc, "within", 6) && strlen(desc) > 6) { *state = EBAXIS_WITHIN; *pos = strtod(desc + 6, NULL); } else if(!strncasecmp(desc, "beyond", 6) && strlen(desc) > 6) { *state = EBAXIS_BEYOND; *pos = strtod(desc + 6, NULL); } else if(!strncasecmp(desc, "pos", 3) && strlen(desc) > 3) { *state = EBAXIS_BEYOND_POSITIVE; *pos = strtod(desc + 3, NULL); } else if(!strncasecmp(desc, "neg", 3) && strlen(desc) > 3) { *state = EBAXIS_BEYOND_NEGATIVE; *pos = -strtod(desc + 3, NULL); } else { Con_Message("B_ParseAxisPosition: Axis position \"%s\" is invalid.", desc); return false; } return true; }
static void timeDeltaStatistics(int deltaMs) { timeDeltas[timeDeltasIndex++] = deltaMs; if(timeDeltasIndex == NUM_FRAMETIME_DELTAS) { timeDeltasIndex = 0; if(devShowFrameTimeDeltas) { int maxDelta = timeDeltas[0], minDelta = timeDeltas[0]; float average = 0, variance = 0; int lateCount = 0; int i; for(i = 0; i < NUM_FRAMETIME_DELTAS; ++i) { maxDelta = MAX_OF(timeDeltas[i], maxDelta); minDelta = MIN_OF(timeDeltas[i], minDelta); average += timeDeltas[i]; variance += timeDeltas[i] * timeDeltas[i]; if(timeDeltas[i] > 0) lateCount++; } average /= NUM_FRAMETIME_DELTAS; variance /= NUM_FRAMETIME_DELTAS; Con_Message("Time deltas [%i frames]: min=%-6i max=%-6i avg=%-11.7f late=%5.1f%% var=%12.10f", NUM_FRAMETIME_DELTAS, minDelta, maxDelta, average, lateCount/(float)NUM_FRAMETIME_DELTAS*100, variance); } } }
void Demo_StopPlayback(void) { //float diff; if(!playback) return; Con_Message("Demo was %.2f seconds (%i tics) long.", (DEMOTIC - demoStartTic) / (float) TICSPERSEC, DEMOTIC - demoStartTic); playback = false; lzClose(playdemo); playdemo = 0; fieldOfView = startFOV; Net_StopGame(); /* if(ArgCheck("-timedemo")) { diff = Sys_GetSeconds() - netConnectTime; if(!diff) diff = 1; // Print summary and exit. Con_Message("Timedemo results: %i game tics in %.1f seconds", r_framecounter, diff); Con_Message("%f FPS", r_framecounter / diff); Sys_Quit(); } */ // "Play demo once" mode? if(CommandLine_Check("-playdemo")) Sys_Quit(); }
void WI_drawOnLnode(int n, dpatch_t * c) { int i; int left; int top; int right; int bottom; boolean fits = false; i = 0; do { left = lnodes[wbs->epsd][n].x - SHORT(c[i].leftoffset); top = lnodes[wbs->epsd][n].y - SHORT(c[i].topoffset); right = left + SHORT(c[i].width); bottom = top + SHORT(c[i].height); if(left >= 0 && right < SCREENWIDTH && top >= 0 && bottom < SCREENHEIGHT) fits = true; else i++; } while(!fits && i != 2); if(fits && i < 2) { WI_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, c[i].lump); } else { // DEBUG Con_Message("Could not place patch on level %d", n + 1); } }
boolean B_ParseToggleState(const char* toggleName, ebstate_t* state) { if(!strlen(toggleName) || !strcasecmp(toggleName, "down")) { *state = EBTOG_DOWN; // this is the default, if omitted return true; } if(!strcasecmp(toggleName, "undefined")) { *state = EBTOG_UNDEFINED; return true; } if(!strcasecmp(toggleName, "repeat")) { *state = EBTOG_REPEAT; return true; } if(!strcasecmp(toggleName, "press")) { *state = EBTOG_PRESS; return true; } if(!strcasecmp(toggleName, "up")) { *state = EBTOG_UP; return true; } Con_Message("B_ParseToggleState: \"%s\" is not a toggle state.", toggleName); return false; // Not recognized. }
static fi_state_t* stateForFinaleId(finaleid_t id) { if(finaleStackInited) { uint i; for(i = 0; i < finaleStackSize; ++i) { fi_state_t* s = &finaleStack[i]; if(s->finaleId == id) return s; } } if(IS_CLIENT) { if(remoteFinaleState.finaleId) { #ifdef _DEBUG VERBOSE2( Con_Message("stateForFinaleId: Finale %i is remote, using server's state (id %i).", id, remoteFinaleState.finaleId) ); #endif return &remoteFinaleState; } } return 0; }
boolean R_ViewFilterColor(float rgba[4], int filter) { if(!rgba) return false; // We have to choose the right color and alpha. if(filter >= STARTREDPALS && filter < STARTREDPALS + NUMREDPALS) { // Red. rgba[CR] = 1; rgba[CG] = 0; rgba[CB] = 0; rgba[CA] = (deathmatch? 1.0f : cfg.filterStrength) * filter / 8.f; // Full red with filter 8. return true; } else if(filter >= STARTBONUSPALS && filter < STARTBONUSPALS + NUMBONUSPALS) { // Light Yellow. rgba[CR] = 1; rgba[CG] = 1; rgba[CB] = .5f; rgba[CA] = cfg.filterStrength * (filter - STARTBONUSPALS + 1) / 16.f; return true; } if(filter) Con_Message("R_ViewFilterColor: Real strange filter number: %d.", filter); return false; }
int DS_Init(void) { // Already initialized? if(initOk) return true; // Open the default playback device. device = alcOpenDevice(NULL); if(!device) { Con_Message("OpenAL init failed (default playback device)."); return false; } // Create and make current a new context. alcMakeContextCurrent(context = alcCreateContext(device, NULL)); DSOPENAL_ERRCHECK(alGetError()); // Attempt to load and configure the EAX extensions. loadExtensions(); // Configure the listener and global OpenAL properties/state. alListenerf(AL_GAIN, 1); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); headYaw = headPitch = 0; unitsPerMeter = 36; // Everything is OK. DSOPENAL_TRACE("DS_Init: OpenAL initialized%s." << (hasEAX? " (EAX 2.0 available)" : "")); initOk = true; return true; }
/* * Initializes the zip file database. */ void Zip_Init(void) { VERBOSE(Con_Message("Zip_Init: Initializing package system...\n")); zipRoot = NULL; zipFiles = 0; zipNumFiles = 0; zipAllocatedFiles = 0; }
/* * Set the data path. The game module is responsible for calling this. */ void R_InitDataPaths(const char *path, boolean justGamePaths) { int i; M_TranslatePath(path, dataPath); Dir_ValidDir(dataPath); VERBOSE(Con_Message("R_SetDataPath: %s\n", M_Pretty(dataPath))); // Update the paths of each class. for(i = 0; i < NUM_RESOURCE_CLASSES; i++) { // The Graphics class resources are under Doomsday's control. if(justGamePaths && i == RC_GRAPHICS) continue; memset(&classInfo[i], 0, sizeof(classInfo[i])); // The -texdir option specifies a path to look for TGA textures. if(ArgCheckWith(explicitOption[i][0], 1)) { M_TranslatePath(ArgNext(), classInfo[i].path); } else { // Build the path for the resource class using the default // elements. strcpy(classInfo[i].path, dataPath); strcat(classInfo[i].path, defaultResourcePath[i]); } Dir_ValidDir(classInfo[i].path); // The overriding path. if(ArgCheckWith(explicitOption[i][1], 1)) { M_TranslatePath(ArgNext(), classInfo[i].overridePath); } Dir_ValidDir(classInfo[i].overridePath); VERBOSE2(Con_Message (" %i: %s (%s)\n", i, M_Pretty(classInfo[i].path), M_Pretty(classInfo[i].overridePath))); } }
//=========================================================================== // SW_Init //=========================================================================== void SW_Init(void) { if(msgWnd) return; // Already initialized. msgWnd = CreateDialog(hInstApp, MAKEINTRESOURCE(IDD_STARTUP_WINDOW), hWndMain, SW_DialogProc); progressBrush = CreateSolidBrush(CREF_PROGRESS); bgBrush = CreateSolidBrush(CREF_BACKGROUND); Con_Message("SW_Init: Startup message window opened.\n"); }
boolean B_ParseJoystickTypeAndId(uint device, const char* desc, ddeventtype_t* type, int* id) { if(!strncasecmp(desc, "button", 6) && strlen(desc) > 6) { *type = E_TOGGLE; *id = strtoul(desc + 6, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(device, false)->numKeys) { Con_Message("B_ParseJoystickTypeAndId: Button %i does not exist in joystick.", *id); return false; } } else if(!strncasecmp(desc, "hat", 3) && strlen(desc) > 3) { *type = E_ANGLE; *id = strtoul(desc + 3, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(device, false)->numHats) { Con_Message("B_ParseJoystickTypeAndId: Hat %i does not exist in joystick.", *id); return false; } } else if(!strcasecmp(desc, "hat")) { *type = E_ANGLE; *id = 0; } else { // Try to find the axis. *type = E_AXIS; *id = I_GetAxisByName(I_GetDevice(device, false), desc); if(*id < 0) { Con_Message("B_ParseJoystickTypeAndId: Axis \"%s\" is not defined in joystick.", desc); return false; } } return true; }
/** * @return @c true, if successful. */ int DM_Music_Init(void) { if(midiAvail) return true; // Already initialized. Con_Message("DM_WinMusInit: %i MIDI-Out devices present.", midiOutGetNumDevs()); MIDIStreamer = new WinMIDIStreamer; // Open the midi stream. if(!MIDIStreamer || !MIDIStreamer->OpenStream()) return false; // Double output volume? MIDIStreamer->volumeShift = CommandLine_Exists("-mdvol") ? 1 : 0; // Now the MIDI is available. Con_Message("DM_WinMusInit: MIDI initialized."); return midiAvail = true; }
boolean FI_ScriptRequestSkip(finaleid_t id) { finale_t* f; if(!inited) Con_Error("FI_ScriptRequestSkip: Not initialized yet!"); f = finalesById(id); if(!f) { Con_Message("FI_ScriptRequestSkip: Unknown finaleid %u.", id); return false; } return FinaleInterpreter_Skip(f->_interpreter); }
void* DD_FindEntryPoint(pluginid_t pluginId, const char* fn) { void* addr = 0; int plugIndex = pluginId - 1; assert(plugIndex >= 0 && plugIndex < MAX_PLUGS); addr = Library_Symbol(hInstPlug[plugIndex], fn); if(!addr) { Con_Message("DD_FindEntryPoint: Error locating address of \"%s\" (%s).", fn, Library_LastError()); } return addr; }
//=========================================================================== // DS_Load // "A3D", "OpenAL" and "Compat" are supported. //=========================================================================== sfxdriver_t *DS_Load(const char *name) { filename_t fn; // Compose the name, use the prefix "ds". sprintf(fn, "libds%s", name); if((handle = lt_dlopenext(fn)) == NULL) { Con_Message("DS_Load: Loading of %s failed.\n", fn); return NULL; } return DS_ImportExternal(); }