2006-02-24 04:48:15 +00:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <io.h>
|
|
|
|
#include <direct.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <process.h>
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/timeb.h>
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
2007-01-09 04:40:58 +00:00
|
|
|
#include <richedit.h>
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
#define USE_WINDOWS_DWORD
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "hardware.h"
|
|
|
|
#include "doomerrors.h"
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "m_argv.h"
|
|
|
|
#include "m_misc.h"
|
|
|
|
#include "i_video.h"
|
|
|
|
#include "i_sound.h"
|
|
|
|
#include "i_music.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
#include "d_main.h"
|
|
|
|
#include "d_net.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "i_input.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "templates.h"
|
2006-09-20 02:00:19 +00:00
|
|
|
#include "gameconfigfile.h"
|
2007-01-09 04:40:58 +00:00
|
|
|
#include "v_font.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#include "stats.h"
|
|
|
|
|
|
|
|
EXTERN_CVAR (String, language)
|
|
|
|
|
|
|
|
#ifdef USEASM
|
|
|
|
extern "C" void STACK_ARGS CheckMMX (CPUInfo *cpu);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
double SecondsPerCycle = 1e-8;
|
|
|
|
double CyclesPerSecond = 1e8; // 100 MHz
|
|
|
|
CPUInfo CPU;
|
|
|
|
}
|
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
extern HWND Window, ConWindow, GameTitleWindow;
|
2006-02-24 04:48:15 +00:00
|
|
|
extern HINSTANCE g_hInst;
|
|
|
|
|
|
|
|
UINT TimerPeriod;
|
|
|
|
UINT TimerEventID;
|
|
|
|
UINT MillisecondsPerTic;
|
|
|
|
HANDLE NewTicArrived;
|
2006-09-14 00:02:31 +00:00
|
|
|
uint32 LanguageIDs[4];
|
2006-02-24 04:48:15 +00:00
|
|
|
void CalculateCPUSpeed ();
|
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
const IWADInfo *DoomStartupInfo;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int (*I_GetTime) (bool saveMS);
|
|
|
|
int (*I_WaitForTic) (int);
|
|
|
|
|
|
|
|
os_t OSPlatform;
|
|
|
|
|
|
|
|
void I_Tactile (int on, int off, int total)
|
|
|
|
{
|
|
|
|
// UNUSED.
|
|
|
|
on = off = total = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ticcmd_t emptycmd;
|
|
|
|
ticcmd_t *I_BaseTiccmd(void)
|
|
|
|
{
|
|
|
|
return &emptycmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD basetime = 0;
|
|
|
|
|
|
|
|
// [RH] Returns time in milliseconds
|
|
|
|
unsigned int I_MSTime (void)
|
|
|
|
{
|
|
|
|
DWORD tm;
|
|
|
|
|
|
|
|
tm = timeGetTime();
|
|
|
|
if (!basetime)
|
|
|
|
basetime = tm;
|
|
|
|
|
|
|
|
return tm - basetime;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD TicStart;
|
|
|
|
static DWORD TicNext;
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_GetTime
|
|
|
|
// returns time in 1/35th second tics
|
|
|
|
//
|
|
|
|
int I_GetTimePolled (bool saveMS)
|
|
|
|
{
|
|
|
|
DWORD tm;
|
|
|
|
|
|
|
|
tm = timeGetTime();
|
|
|
|
if (!basetime)
|
|
|
|
basetime = tm;
|
|
|
|
|
|
|
|
if (saveMS)
|
|
|
|
{
|
|
|
|
TicStart = tm;
|
|
|
|
TicNext = (tm * TICRATE / 1000 + 1) * 1000 / TICRATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ((tm-basetime)*TICRATE)/1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
int I_WaitForTicPolled (int prevtic)
|
|
|
|
{
|
|
|
|
int time;
|
|
|
|
|
|
|
|
while ((time = I_GetTimePolled(false)) <= prevtic)
|
|
|
|
;
|
|
|
|
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int tics;
|
2006-09-14 00:02:31 +00:00
|
|
|
static DWORD ted_start, ted_next;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int I_GetTimeEventDriven (bool saveMS)
|
|
|
|
{
|
|
|
|
if (saveMS)
|
|
|
|
{
|
|
|
|
TicStart = ted_start;
|
|
|
|
TicNext = ted_next;
|
|
|
|
}
|
|
|
|
return tics;
|
|
|
|
}
|
|
|
|
|
|
|
|
int I_WaitForTicEvent (int prevtic)
|
|
|
|
{
|
|
|
|
while (prevtic >= tics)
|
|
|
|
{
|
2008-03-05 03:10:31 +00:00
|
|
|
WaitForSingleObject(NewTicArrived, 1000/TICRATE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tics;
|
|
|
|
}
|
|
|
|
|
2008-04-29 02:43:42 +00:00
|
|
|
void CALLBACK TimerTicked (UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
tics++;
|
|
|
|
ted_start = timeGetTime ();
|
|
|
|
ted_next = ted_start + MillisecondsPerTic;
|
|
|
|
SetEvent (NewTicArrived);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the fractional amount of a tic passed since the most recent tic
|
2006-09-14 00:02:31 +00:00
|
|
|
fixed_t I_GetTimeFrac (uint32 *ms)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
DWORD now = timeGetTime();
|
|
|
|
if (ms) *ms = TicNext;
|
|
|
|
DWORD step = TicNext - TicStart;
|
|
|
|
if (step == 0)
|
|
|
|
{
|
|
|
|
return FRACUNIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fixed_t frac = clamp<fixed_t> ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT);
|
|
|
|
return frac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void I_WaitVBL (int count)
|
|
|
|
{
|
|
|
|
// I_WaitVBL is never used to actually synchronize to the
|
|
|
|
// vertical blank. Instead, it's used for delay purposes.
|
|
|
|
Sleep (1000 * count / 70);
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Detect the OS the game is running under
|
|
|
|
void I_DetectOS (void)
|
|
|
|
{
|
|
|
|
OSVERSIONINFO info;
|
|
|
|
const char *osname;
|
|
|
|
|
|
|
|
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
GetVersionEx (&info);
|
|
|
|
|
|
|
|
switch (info.dwPlatformId)
|
|
|
|
{
|
|
|
|
case VER_PLATFORM_WIN32_WINDOWS:
|
|
|
|
OSPlatform = os_Win95;
|
|
|
|
if (info.dwMinorVersion < 10)
|
|
|
|
{
|
|
|
|
osname = "95";
|
|
|
|
}
|
|
|
|
else if (info.dwMinorVersion < 90)
|
|
|
|
{
|
|
|
|
osname = "98";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
osname = "Me";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VER_PLATFORM_WIN32_NT:
|
2006-10-19 20:20:56 +00:00
|
|
|
OSPlatform = info.dwMajorVersion < 5 ? os_WinNT4 : os_Win2k;
|
|
|
|
osname = "NT";
|
|
|
|
if (info.dwMajorVersion == 5)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-19 20:20:56 +00:00
|
|
|
if (info.dwMinorVersion == 0)
|
|
|
|
{
|
|
|
|
osname = "2000";
|
|
|
|
}
|
|
|
|
if (info.dwMinorVersion == 1)
|
|
|
|
{
|
|
|
|
osname = "XP";
|
|
|
|
}
|
|
|
|
else if (info.dwMinorVersion == 2)
|
|
|
|
{
|
|
|
|
osname = "Server 2003";
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-10-19 20:20:56 +00:00
|
|
|
else if (info.dwMajorVersion == 6 && info.dwMinorVersion == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-19 20:20:56 +00:00
|
|
|
osname = "Vista";
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
OSPlatform = os_unknown;
|
|
|
|
osname = "Unknown OS";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
if (OSPlatform == os_Win95)
|
|
|
|
{
|
|
|
|
Printf ("OS: Windows %s %lu.%lu.%lu %s\n",
|
|
|
|
osname,
|
|
|
|
info.dwMajorVersion, info.dwMinorVersion,
|
|
|
|
info.dwBuildNumber & 0xffff, info.szCSDVersion);
|
|
|
|
}
|
|
|
|
else
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
Printf ("OS: Windows %s %lu.%lu (Build %lu)\n %s\n",
|
|
|
|
osname,
|
|
|
|
info.dwMajorVersion, info.dwMinorVersion,
|
|
|
|
info.dwBuildNumber, info.szCSDVersion);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-10-19 20:20:56 +00:00
|
|
|
if (OSPlatform == os_unknown)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Printf ("(Assuming Windows 95)\n");
|
|
|
|
OSPlatform = os_Win95;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SubsetLanguageIDs
|
|
|
|
//
|
|
|
|
static void SubsetLanguageIDs (LCID id, LCTYPE type, int idx)
|
|
|
|
{
|
|
|
|
char buf[8];
|
|
|
|
LCID langid;
|
|
|
|
char *idp;
|
|
|
|
|
|
|
|
if (!GetLocaleInfo (id, type, buf, 8))
|
|
|
|
return;
|
|
|
|
langid = MAKELCID (strtoul(buf, NULL, 16), SORT_DEFAULT);
|
|
|
|
if (!GetLocaleInfo (langid, LOCALE_SABBREVLANGNAME, buf, 8))
|
|
|
|
return;
|
|
|
|
idp = (char *)(&LanguageIDs[idx]);
|
|
|
|
memset (idp, 0, 4);
|
|
|
|
idp[0] = tolower(buf[0]);
|
|
|
|
idp[1] = tolower(buf[1]);
|
|
|
|
idp[2] = tolower(buf[2]);
|
|
|
|
idp[3] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SetLanguageIDs
|
|
|
|
//
|
|
|
|
void SetLanguageIDs ()
|
|
|
|
{
|
|
|
|
size_t langlen = strlen (language);
|
|
|
|
|
|
|
|
if (langlen < 2 || langlen > 3)
|
|
|
|
{
|
|
|
|
memset (LanguageIDs, 0, sizeof(LanguageIDs));
|
|
|
|
SubsetLanguageIDs (LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, 0);
|
|
|
|
SubsetLanguageIDs (LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 1);
|
|
|
|
SubsetLanguageIDs (LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, 2);
|
|
|
|
SubsetLanguageIDs (LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD lang = 0;
|
|
|
|
|
|
|
|
((BYTE *)&lang)[0] = (language)[0];
|
|
|
|
((BYTE *)&lang)[1] = (language)[1];
|
|
|
|
((BYTE *)&lang)[2] = (language)[2];
|
|
|
|
LanguageIDs[0] = lang;
|
|
|
|
LanguageIDs[1] = lang;
|
|
|
|
LanguageIDs[2] = lang;
|
|
|
|
LanguageIDs[3] = lang;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_Init
|
|
|
|
//
|
|
|
|
void I_Init (void)
|
|
|
|
{
|
|
|
|
#ifndef USEASM
|
|
|
|
memset (&CPU, 0, sizeof(CPU));
|
|
|
|
#else
|
|
|
|
CheckMMX (&CPU);
|
|
|
|
CalculateCPUSpeed ();
|
|
|
|
|
|
|
|
// Why does Intel right-justify this string?
|
|
|
|
char *f = CPU.CPUString, *t = f;
|
|
|
|
|
|
|
|
while (*f == ' ')
|
|
|
|
{
|
|
|
|
++f;
|
|
|
|
}
|
|
|
|
if (f != t)
|
|
|
|
{
|
|
|
|
while (*f != 0)
|
|
|
|
{
|
|
|
|
*t++ = *f++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
if (CPU.VendorID[0])
|
|
|
|
{
|
|
|
|
Printf ("CPU Vendor ID: %s\n", CPU.VendorID);
|
|
|
|
if (CPU.CPUString[0])
|
|
|
|
{
|
|
|
|
Printf (" Name: %s\n", CPU.CPUString);
|
|
|
|
}
|
|
|
|
if (CPU.bIsAMD)
|
|
|
|
{
|
|
|
|
Printf (" Family %d (%d), Model %d, Stepping %d\n",
|
|
|
|
CPU.Family, CPU.AMDFamily, CPU.AMDModel, CPU.AMDStepping);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Printf (" Family %d, Model %d, Stepping %d\n",
|
|
|
|
CPU.Family, CPU.Model, CPU.Stepping);
|
|
|
|
}
|
|
|
|
Printf (" Features:");
|
|
|
|
if (CPU.bMMX) Printf (" MMX");
|
|
|
|
if (CPU.bMMXPlus) Printf (" MMX+");
|
|
|
|
if (CPU.bSSE) Printf (" SSE");
|
|
|
|
if (CPU.bSSE2) Printf (" SSE2");
|
|
|
|
if (CPU.bSSE3) Printf (" SSE3");
|
|
|
|
if (CPU.b3DNow) Printf (" 3DNow!");
|
|
|
|
if (CPU.b3DNowPlus) Printf (" 3DNow!+");
|
|
|
|
Printf ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Use a timer event if possible
|
|
|
|
NewTicArrived = CreateEvent (NULL, FALSE, FALSE, NULL);
|
|
|
|
if (NewTicArrived)
|
|
|
|
{
|
|
|
|
UINT delay;
|
|
|
|
char *cmdDelay;
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
cmdDelay = Args->CheckValue ("-timerdelay");
|
2006-02-24 04:48:15 +00:00
|
|
|
delay = 0;
|
|
|
|
if (cmdDelay != 0)
|
|
|
|
{
|
|
|
|
delay = atoi (cmdDelay);
|
|
|
|
}
|
|
|
|
if (delay == 0)
|
|
|
|
{
|
|
|
|
delay = 1000/TICRATE;
|
|
|
|
}
|
|
|
|
TimerEventID = timeSetEvent
|
|
|
|
(
|
|
|
|
delay,
|
|
|
|
0,
|
|
|
|
TimerTicked,
|
|
|
|
0,
|
|
|
|
TIME_PERIODIC
|
|
|
|
);
|
|
|
|
MillisecondsPerTic = delay;
|
|
|
|
}
|
|
|
|
if (TimerEventID != 0)
|
|
|
|
{
|
|
|
|
I_GetTime = I_GetTimeEventDriven;
|
|
|
|
I_WaitForTic = I_WaitForTicEvent;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // If no timer event, busy-loop with timeGetTime
|
|
|
|
I_GetTime = I_GetTimePolled;
|
|
|
|
I_WaitForTic = I_WaitForTicPolled;
|
|
|
|
}
|
|
|
|
|
|
|
|
atterm (I_ShutdownSound);
|
|
|
|
I_InitSound ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CalculateCPUSpeed ()
|
|
|
|
{
|
|
|
|
LARGE_INTEGER freq;
|
|
|
|
|
|
|
|
QueryPerformanceFrequency (&freq);
|
|
|
|
|
|
|
|
if (freq.QuadPart != 0 && CPU.bRDTSC)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER count1, count2;
|
|
|
|
DWORD minDiff;
|
|
|
|
cycle_t ClockCalibration = 0;
|
|
|
|
|
|
|
|
// Count cycles for at least 55 milliseconds.
|
|
|
|
// The performance counter is very low resolution compared to CPU
|
|
|
|
// speeds today, so the longer we count, the more accurate our estimate.
|
|
|
|
// On the other hand, we don't want to count too long, because we don't
|
|
|
|
// want the user to notice us spend time here, since most users will
|
|
|
|
// probably never use the performance statistics.
|
|
|
|
minDiff = freq.LowPart * 11 / 200;
|
|
|
|
|
|
|
|
// Minimize the chance of task switching during the testing by going very
|
|
|
|
// high priority. This is another reason to avoid timing for too long.
|
|
|
|
SetPriorityClass (GetCurrentProcess (), REALTIME_PRIORITY_CLASS);
|
|
|
|
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL);
|
|
|
|
clock (ClockCalibration);
|
|
|
|
QueryPerformanceCounter (&count1);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
QueryPerformanceCounter (&count2);
|
|
|
|
} while ((DWORD)((unsigned __int64)count2.QuadPart - (unsigned __int64)count1.QuadPart) < minDiff);
|
|
|
|
unclock (ClockCalibration);
|
|
|
|
QueryPerformanceCounter (&count2);
|
|
|
|
SetPriorityClass (GetCurrentProcess (), NORMAL_PRIORITY_CLASS);
|
|
|
|
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL);
|
|
|
|
|
|
|
|
CyclesPerSecond = (double)ClockCalibration *
|
|
|
|
(double)freq.QuadPart /
|
|
|
|
(double)((__int64)count2.QuadPart - (__int64)count1.QuadPart);
|
|
|
|
SecondsPerCycle = 1.0 / CyclesPerSecond;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Printf ("Can't determine CPU speed, so pretending.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
Printf ("CPU Speed: %f MHz\n", CyclesPerSecond / 1e6);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_Quit
|
|
|
|
//
|
|
|
|
static int has_exited;
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
void I_Quit (void)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
has_exited = 1; /* Prevent infinitely recursive exits -- killough */
|
|
|
|
|
|
|
|
if (TimerEventID)
|
|
|
|
timeKillEvent (TimerEventID);
|
|
|
|
if (NewTicArrived)
|
|
|
|
CloseHandle (NewTicArrived);
|
|
|
|
|
|
|
|
timeEndPeriod (TimerPeriod);
|
|
|
|
|
|
|
|
if (demorecording)
|
|
|
|
G_CheckDemoStatus();
|
|
|
|
G_ClearSnapshots ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_Error
|
|
|
|
//
|
|
|
|
extern FILE *Logfile;
|
2006-09-14 00:02:31 +00:00
|
|
|
bool gameisdead;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void STACK_ARGS I_FatalError (const char *error, ...)
|
|
|
|
{
|
|
|
|
static BOOL alreadyThrown = false;
|
|
|
|
gameisdead = true;
|
|
|
|
|
|
|
|
if (!alreadyThrown) // ignore all but the first message -- killough
|
|
|
|
{
|
2006-12-29 20:28:23 +00:00
|
|
|
alreadyThrown = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
char errortext[MAX_ERRORTEXT];
|
|
|
|
va_list argptr;
|
|
|
|
va_start (argptr, error);
|
2008-06-29 08:42:07 +00:00
|
|
|
myvsnprintf (errortext, MAX_ERRORTEXT, error, argptr);
|
2006-02-24 04:48:15 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
// Record error to log (if logging)
|
|
|
|
if (Logfile)
|
|
|
|
fprintf (Logfile, "\n**** DIED WITH FATAL ERROR:\n%s\n", errortext);
|
|
|
|
|
|
|
|
throw CFatalError (errortext);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_exited) // If it hasn't exited yet, exit now -- killough
|
|
|
|
{
|
|
|
|
has_exited = 1; // Prevent infinitely recursive exits -- killough
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void STACK_ARGS I_Error (const char *error, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char errortext[MAX_ERRORTEXT];
|
|
|
|
|
|
|
|
va_start (argptr, error);
|
2008-06-29 08:42:07 +00:00
|
|
|
myvsnprintf (errortext, MAX_ERRORTEXT, error, argptr);
|
2006-02-24 04:48:15 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
throw CRecoverableError (errortext);
|
|
|
|
}
|
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
extern void LayoutMainWindow (HWND hWnd, HWND pane);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
void I_SetIWADInfo (const IWADInfo *info)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
DoomStartupInfo = info;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
// Make the startup banner show itself
|
|
|
|
LayoutMainWindow (Window, NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
void I_PrintStr (const char *cp)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (ConWindow == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
static bool newLine = true;
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
HWND edit = ConWindow;
|
2006-02-24 04:48:15 +00:00
|
|
|
char buf[256];
|
|
|
|
int bpos = 0;
|
2007-01-09 04:40:58 +00:00
|
|
|
CHARRANGE selection;
|
|
|
|
CHARRANGE endselection;
|
|
|
|
LONG lines_before, lines_after;
|
|
|
|
CHARFORMAT format;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-09 04:40:58 +00:00
|
|
|
// Store the current selection and set it to the end so we can append text.
|
|
|
|
SendMessage (edit, EM_EXGETSEL, 0, (LPARAM)&selection);
|
|
|
|
endselection.cpMax = endselection.cpMin = GetWindowTextLength (edit);
|
|
|
|
SendMessage (edit, EM_EXSETSEL, 0, (LPARAM)&endselection);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-09 04:40:58 +00:00
|
|
|
// GetWindowTextLength and EM_EXSETSEL can disagree on where the end of
|
|
|
|
// the text is. Find out what EM_EXSETSEL thought it was and use that later.
|
|
|
|
SendMessage (edit, EM_EXGETSEL, 0, (LPARAM)&endselection);
|
|
|
|
|
|
|
|
// Remember how many lines there were before we added text.
|
|
|
|
lines_before = SendMessage (edit, EM_GETLINECOUNT, 0, 0);
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
while (*cp != 0)
|
|
|
|
{
|
2007-01-09 04:40:58 +00:00
|
|
|
// 28 is the escape code for a color change.
|
|
|
|
if ((*cp == 28 && bpos != 0) || bpos == 255)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
buf[bpos] = 0;
|
|
|
|
SendMessage (edit, EM_REPLACESEL, FALSE, (LPARAM)buf);
|
|
|
|
newLine = buf[bpos-1] == '\n';
|
|
|
|
bpos = 0;
|
|
|
|
}
|
2007-01-09 04:40:58 +00:00
|
|
|
if (*cp != 28)
|
|
|
|
{
|
|
|
|
buf[bpos++] = *cp++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const BYTE *color_id = (const BYTE *)cp + 1;
|
|
|
|
EColorRange range = V_ParseFontColor (color_id, CR_UNTRANSLATED, CR_YELLOW);
|
|
|
|
cp = (const char *)color_id;
|
|
|
|
|
|
|
|
if (range != CR_UNDEFINED)
|
|
|
|
{
|
|
|
|
// Change the color of future text added to the control.
|
|
|
|
PalEntry color = V_LogColorFromColorRange (range);
|
|
|
|
// GDI uses BGR colors, but color is RGB, so swap the R and the B.
|
|
|
|
swap (color.r, color.b);
|
|
|
|
// Change the color.
|
|
|
|
format.cbSize = sizeof(format);
|
|
|
|
format.dwMask = CFM_COLOR;
|
|
|
|
format.crTextColor = color;
|
|
|
|
SendMessage (edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (bpos != 0)
|
|
|
|
{
|
|
|
|
buf[bpos] = 0;
|
2007-01-09 04:40:58 +00:00
|
|
|
SendMessage (edit, EM_REPLACESEL, FALSE, (LPARAM)buf);
|
2006-02-24 04:48:15 +00:00
|
|
|
newLine = buf[bpos-1] == '\n';
|
|
|
|
}
|
2007-01-09 04:40:58 +00:00
|
|
|
|
|
|
|
// If the old selection was at the end of the text, keep it at the end and
|
|
|
|
// scroll. Don't scroll if the selection is anywhere else.
|
|
|
|
if (selection.cpMin == endselection.cpMin && selection.cpMax == endselection.cpMax)
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
{
|
2007-01-09 04:40:58 +00:00
|
|
|
selection.cpMax = selection.cpMin = GetWindowTextLength (edit);
|
|
|
|
lines_after = SendMessage (edit, EM_GETLINECOUNT, 0, 0);
|
|
|
|
if (lines_after > lines_before)
|
|
|
|
{
|
|
|
|
SendMessage (edit, EM_LINESCROLL, 0, lines_after - lines_before);
|
|
|
|
}
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
}
|
2007-01-09 04:40:58 +00:00
|
|
|
// Restore the previous selection.
|
|
|
|
SendMessage (edit, EM_EXSETSEL, 0, (LPARAM)&selection);
|
|
|
|
// Give the edit control a chance to redraw itself.
|
|
|
|
I_GetEvent ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXTERN_CVAR (Bool, queryiwad);
|
2006-07-20 05:13:39 +00:00
|
|
|
CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
|
2006-02-24 04:48:15 +00:00
|
|
|
static WadStuff *WadList;
|
|
|
|
static int NumWads;
|
2006-07-08 02:17:35 +00:00
|
|
|
static int DefaultWad;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static void SetQueryIWad (HWND dialog)
|
|
|
|
{
|
|
|
|
HWND checkbox = GetDlgItem (dialog, IDC_DONTASKIWAD);
|
|
|
|
int state = SendMessage (checkbox, BM_GETCHECK, 0, 0);
|
2006-07-08 02:17:35 +00:00
|
|
|
bool query = (state != BST_CHECKED);
|
|
|
|
|
|
|
|
if (!query && queryiwad)
|
|
|
|
{
|
|
|
|
MessageBox (dialog,
|
|
|
|
"You have chosen not to show this dialog box in the future.\n"
|
|
|
|
"If you wish to see it again, hold down SHIFT while starting " GAMENAME ".",
|
|
|
|
"Don't ask me this again",
|
|
|
|
MB_OK | MB_ICONINFORMATION);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-07-08 02:17:35 +00:00
|
|
|
queryiwad = query;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CALLBACK IWADBoxCallback (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-07-08 02:17:35 +00:00
|
|
|
HWND ctrl;
|
2006-02-24 04:48:15 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2006-06-20 20:30:39 +00:00
|
|
|
// Add our program name to the window title
|
|
|
|
{
|
|
|
|
TCHAR label[256];
|
|
|
|
FString newlabel;
|
|
|
|
|
|
|
|
GetWindowText (hDlg, label, countof(label));
|
|
|
|
newlabel.Format (GAMESIG " " DOTVERSIONSTR_NOREV ": %s", label);
|
|
|
|
SetWindowText (hDlg, newlabel.GetChars());
|
|
|
|
}
|
|
|
|
// Populate the list with all the IWADs found
|
2006-07-08 02:17:35 +00:00
|
|
|
ctrl = GetDlgItem (hDlg, IDC_IWADLIST);
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < NumWads; i++)
|
|
|
|
{
|
2006-06-20 20:30:39 +00:00
|
|
|
FString work;
|
2006-05-16 02:50:18 +00:00
|
|
|
const char *filepart = strrchr (WadList[i].Path, '/');
|
2006-02-24 04:48:15 +00:00
|
|
|
if (filepart == NULL)
|
|
|
|
filepart = WadList[i].Path;
|
|
|
|
else
|
|
|
|
filepart++;
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
work.Format ("%s (%s)", IWADInfos[WadList[i].Type].Name, filepart);
|
2006-07-08 02:17:35 +00:00
|
|
|
SendMessage (ctrl, LB_ADDSTRING, 0, (LPARAM)work.GetChars());
|
|
|
|
SendMessage (ctrl, LB_SETITEMDATA, i, (LPARAM)i);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-07-08 02:17:35 +00:00
|
|
|
SendMessage (ctrl, LB_SETCURSEL, DefaultWad, 0);
|
|
|
|
SetFocus (ctrl);
|
|
|
|
// Set the state of the "Don't ask me again" checkbox
|
|
|
|
ctrl = GetDlgItem (hDlg, IDC_DONTASKIWAD);
|
|
|
|
SendMessage (ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0);
|
|
|
|
// Make sure the dialog is in front. If SHIFT was pressed to force it visible,
|
|
|
|
// then the other window will normally be on top.
|
|
|
|
SetForegroundWindow (hDlg);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (LOWORD(wParam) == IDCANCEL)
|
|
|
|
{
|
|
|
|
EndDialog (hDlg, -1);
|
|
|
|
}
|
|
|
|
else if (LOWORD(wParam) == IDOK ||
|
|
|
|
(LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK))
|
|
|
|
{
|
|
|
|
SetQueryIWad (hDlg);
|
2006-07-08 02:17:35 +00:00
|
|
|
ctrl = GetDlgItem (hDlg, IDC_IWADLIST);
|
|
|
|
EndDialog (hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-07-08 02:17:35 +00:00
|
|
|
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-07-20 05:13:39 +00:00
|
|
|
int vkey;
|
|
|
|
|
|
|
|
if (stricmp (queryiwad_key, "shift") == 0)
|
|
|
|
{
|
|
|
|
vkey = VK_SHIFT;
|
|
|
|
}
|
|
|
|
else if (stricmp (queryiwad_key, "control") == 0 || stricmp (queryiwad_key, "ctrl") == 0)
|
|
|
|
{
|
|
|
|
vkey = VK_CONTROL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vkey = 0;
|
|
|
|
}
|
|
|
|
if (showwin || (vkey != 0 && GetAsyncKeyState(vkey)))
|
2006-07-08 02:17:35 +00:00
|
|
|
{
|
|
|
|
WadList = wads;
|
|
|
|
NumWads = numwads;
|
|
|
|
DefaultWad = defaultiwad;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-07-08 02:17:35 +00:00
|
|
|
return DialogBox (g_hInst, MAKEINTRESOURCE(IDD_IWADDIALOG),
|
|
|
|
(HWND)Window, (DLGPROC)IWADBoxCallback);
|
|
|
|
}
|
|
|
|
return defaultiwad;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-09-20 02:00:19 +00:00
|
|
|
bool I_WriteIniFailed ()
|
|
|
|
{
|
|
|
|
char *lpMsgBuf;
|
|
|
|
FString errortext;
|
|
|
|
|
|
|
|
FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL,
|
|
|
|
GetLastError(),
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
|
|
|
(LPSTR)&lpMsgBuf,
|
|
|
|
0,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf);
|
|
|
|
LocalFree (lpMsgBuf);
|
|
|
|
return MessageBox (Window, errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void *I_FindFirst (const char *filespec, findstate_t *fileinfo)
|
|
|
|
{
|
|
|
|
return FindFirstFileA (filespec, (LPWIN32_FIND_DATAA)fileinfo);
|
|
|
|
}
|
|
|
|
int I_FindNext (void *handle, findstate_t *fileinfo)
|
|
|
|
{
|
|
|
|
return !FindNextFileA ((HANDLE)handle, (LPWIN32_FIND_DATAA)fileinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
int I_FindClose (void *handle)
|
|
|
|
{
|
|
|
|
return FindClose ((HANDLE)handle);
|
|
|
|
}
|
2007-12-06 19:15:07 +00:00
|
|
|
|
|
|
|
static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value)
|
|
|
|
{
|
|
|
|
HKEY steamkey;
|
|
|
|
DWORD pathtype;
|
|
|
|
DWORD pathlen;
|
|
|
|
LONG res;
|
|
|
|
|
|
|
|
if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &steamkey))
|
|
|
|
{
|
|
|
|
if (ERROR_SUCCESS == RegQueryValueEx(steamkey, valname, 0, &pathtype, NULL, &pathlen) &&
|
|
|
|
pathtype == REG_SZ && pathlen != 0)
|
|
|
|
{
|
|
|
|
// Don't include terminating null in count
|
|
|
|
char *chars = value.LockNewBuffer(pathlen - 1);
|
|
|
|
res = RegQueryValueEx(steamkey, valname, 0, NULL, (LPBYTE)chars, &pathlen);
|
|
|
|
value.UnlockBuffer();
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
value = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(steamkey);
|
|
|
|
}
|
|
|
|
return value.IsNotEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
FString I_GetSteamPath()
|
|
|
|
{
|
|
|
|
FString path;
|
|
|
|
|
|
|
|
if (QueryPathKey(HKEY_CURRENT_USER, "Software\\Valve\\Steam", "SteamPath", path))
|
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
if (QueryPathKey(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", "InstallPath", path))
|
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
path = "";
|
|
|
|
return path;
|
|
|
|
}
|