mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 00:30:57 +00:00
Clean up the startup file diffs.
This also makes functionality consistent across the platforms, such as adding support for -dedicated to sdl based nq, and various timing calculations are now consistent.
This commit is contained in:
parent
db8eee502f
commit
cca9983a48
12 changed files with 204 additions and 281 deletions
|
@ -47,11 +47,11 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#else
|
||||
# include <sys/fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <signal.h>
|
||||
|
@ -60,20 +60,18 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
#include <SDL.h>
|
||||
#include <SDL_main.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "compat.h"
|
||||
#include "host.h"
|
||||
|
||||
int noconinput;
|
||||
#include "netchan.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include "winquake.h"
|
||||
#endif
|
||||
|
||||
int qf_sdl_link;
|
||||
|
||||
static void
|
||||
startup (void)
|
||||
{
|
||||
|
@ -98,10 +96,12 @@ startup (void)
|
|||
}
|
||||
|
||||
static void
|
||||
shutdown (void)
|
||||
shutdown_f (void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
// change stdin to blocking
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ shutdown (void)
|
|||
#endif
|
||||
|
||||
int
|
||||
SDL_main (int c, char **v)
|
||||
SDL_main (int argc, const char **argv)
|
||||
{
|
||||
double time, oldtime, newtime;
|
||||
|
||||
|
@ -118,24 +118,21 @@ SDL_main (int c, char **v)
|
|||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
COM_InitArgv (c, (const char **)v);
|
||||
COM_InitArgv (argc, argv);
|
||||
host_parms.argc = com_argc;
|
||||
host_parms.argv = com_argv;
|
||||
|
||||
#ifndef _WIN32
|
||||
noconinput = COM_CheckParm ("-noconinput");
|
||||
if (!noconinput)
|
||||
if (!COM_CheckParm ("-noconinput"))
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
Sys_RegisterShutdown (Host_Shutdown);
|
||||
Sys_RegisterShutdown (Net_LogStop);
|
||||
Sys_RegisterShutdown (shutdown);
|
||||
Sys_RegisterShutdown (shutdown_f);
|
||||
|
||||
Host_Init ();
|
||||
|
||||
oldtime = Sys_DoubleTime ();
|
||||
while (1) {
|
||||
while (1) { // Main message loop
|
||||
// find time spent rendering last frame
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
@ -143,5 +140,4 @@ SDL_main (int c, char **v)
|
|||
Host_Frame (time);
|
||||
oldtime = newtime;
|
||||
}
|
||||
return 0; // shouldn't be reachable, but mingw gcc 3.1 is being weird
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
|
@ -42,59 +42,48 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#else
|
||||
# include <sys/fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "host.h"
|
||||
#include "netchan.h"
|
||||
|
||||
int noconinput = 0;
|
||||
|
||||
static void
|
||||
shutdown (void)
|
||||
shutdown_f (void)
|
||||
{
|
||||
// change stdin to blocking
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
int skipframes;
|
||||
|
||||
int
|
||||
main (int c, const char *v[])
|
||||
main (int argc, const char **argv)
|
||||
{
|
||||
// static char cwd[1024];
|
||||
double time, oldtime, newtime;
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
COM_InitArgv (c, v);
|
||||
COM_InitArgv (argc, argv);
|
||||
host_parms.argc = com_argc;
|
||||
host_parms.argv = com_argv;
|
||||
|
||||
noconinput = COM_CheckParm ("-noconinput");
|
||||
if (!noconinput)
|
||||
if (!COM_CheckParm ("-noconinput"))
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
|
||||
|
||||
Sys_RegisterShutdown (Host_Shutdown);
|
||||
Sys_RegisterShutdown (Net_LogStop);
|
||||
Sys_RegisterShutdown (shutdown);
|
||||
Sys_RegisterShutdown (shutdown_f);
|
||||
|
||||
Host_Init ();
|
||||
|
||||
oldtime = Sys_DoubleTime ();
|
||||
while (1) {
|
||||
while (1) { // Main message loop
|
||||
// find time spent rendering last frame
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
|
|
@ -28,33 +28,17 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_CONIO_H
|
||||
# include <conio.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include "winquake.h"
|
||||
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/sound.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "compat.h"
|
||||
#include "host.h"
|
||||
#include "netchan.h"
|
||||
#include "win32/resources/resource.h"
|
||||
|
||||
#define MAXIMUM_WIN_MEMORY 0x1000000
|
||||
#define MINIMUM_WIN_MEMORY 0x0c00000
|
||||
|
@ -112,7 +96,7 @@ startup (void)
|
|||
}
|
||||
|
||||
static void
|
||||
shutdown (void)
|
||||
shutdown_f (void)
|
||||
{
|
||||
if (tevent)
|
||||
CloseHandle (tevent);
|
||||
|
@ -129,18 +113,17 @@ SleepUntilInput (int time)
|
|||
|
||||
HINSTANCE global_hInstance;
|
||||
int global_nCmdShow;
|
||||
const char *argv[MAX_NUM_ARGVS];
|
||||
static const char *empty_string = "";
|
||||
|
||||
int WINAPI
|
||||
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
// MSG msg;
|
||||
static char cwd[1024];
|
||||
double time, oldtime, newtime;
|
||||
int argc;
|
||||
const char *argv[MAX_NUM_ARGVS];
|
||||
double time, oldtime, newtime;
|
||||
#ifdef SPLASH_SCREEN
|
||||
RECT rect;
|
||||
RECT rect;
|
||||
#endif
|
||||
|
||||
// previous instances do not exist in Win32
|
||||
|
@ -152,22 +135,16 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
global_hInstance = hInstance;
|
||||
global_nCmdShow = nCmdShow;
|
||||
|
||||
if (!GetCurrentDirectory (sizeof (cwd), cwd))
|
||||
Sys_Error ("Couldn't determine current directory");
|
||||
|
||||
if (cwd[strlen (cwd) - 1] == '/')
|
||||
cwd[strlen (cwd) - 1] = 0;
|
||||
|
||||
host_parms.argc = 1;
|
||||
argc = 1;
|
||||
argv[0] = empty_string;
|
||||
|
||||
while (*lpCmdLine && (host_parms.argc < MAX_NUM_ARGVS)) {
|
||||
while (*lpCmdLine && (argc < MAX_NUM_ARGVS)) {
|
||||
while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
|
||||
lpCmdLine++;
|
||||
|
||||
if (*lpCmdLine) {
|
||||
argv[host_parms.argc] = lpCmdLine;
|
||||
host_parms.argc++;
|
||||
argv[argc] = lpCmdLine;
|
||||
argc++;
|
||||
|
||||
while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
|
||||
lpCmdLine++;
|
||||
|
@ -179,7 +156,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
}
|
||||
}
|
||||
|
||||
COM_InitArgv (host_parms.argc, argv);
|
||||
COM_InitArgv (argc, argv);
|
||||
host_parms.argc = com_argc;
|
||||
host_parms.argv = com_argv;
|
||||
|
||||
|
@ -207,17 +184,14 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
if (!tevent)
|
||||
Sys_Error ("Couldn't create event");
|
||||
|
||||
Sys_Printf ("Host_Init\n");
|
||||
Host_Init ();
|
||||
|
||||
Sys_RegisterShutdown (Host_Shutdown);
|
||||
Sys_RegisterShutdown (Net_LogStop);
|
||||
Sys_RegisterShutdown (shutdown);
|
||||
Sys_RegisterShutdown (shutdown_f);
|
||||
|
||||
Host_Init ();
|
||||
|
||||
oldtime = Sys_DoubleTime ();
|
||||
|
||||
// main window message loop
|
||||
while (1) {
|
||||
while (1) { // Main message loop
|
||||
// yield CPU for a little bit when paused, minimized, or not the focus
|
||||
if ((cl.paused && (!ActiveApp)) || Minimized) {
|
||||
SleepUntilInput (PAUSE_SLEEP);
|
||||
|
@ -228,10 +202,8 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
||||
Host_Frame (time);
|
||||
oldtime = newtime;
|
||||
}
|
||||
|
||||
// return success of application
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,6 @@
|
|||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
extern int noconinput;
|
||||
extern int qf_sdl_link;
|
||||
|
||||
static __attribute__ ((used)) int *const _noconinput = &noconinput;
|
||||
static __attribute__ ((used)) int *const _sdl_link = &qf_sdl_link;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
|
@ -42,13 +42,6 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/sys.h"
|
||||
|
@ -118,7 +111,7 @@ startup (void)
|
|||
}
|
||||
|
||||
int
|
||||
main (int argc, const char *argv[])
|
||||
main (int argc, const char **argv)
|
||||
{
|
||||
double time, oldtime, newtime;
|
||||
|
||||
|
@ -137,9 +130,8 @@ main (int argc, const char *argv[])
|
|||
// run one frame immediately for first heartbeat
|
||||
SV_Frame (0.1);
|
||||
|
||||
// main loop
|
||||
oldtime = Sys_DoubleTime () - 0.1;
|
||||
while (1) {
|
||||
while (1) { // Main message loop
|
||||
Sys_CheckInput (!svs.num_clients, net_socket);
|
||||
|
||||
// find time passed since last cycle
|
||||
|
@ -154,5 +146,4 @@ main (int argc, const char *argv[])
|
|||
if (sys_extrasleep->int_val)
|
||||
usleep (sys_extrasleep->int_val);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#include "winquake.h"
|
||||
|
@ -36,11 +36,9 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
#include <winsock.h>
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/info.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "server.h"
|
||||
|
||||
qboolean WinNT;
|
||||
|
@ -70,12 +68,10 @@ startup (void)
|
|||
WinNT = false;
|
||||
}
|
||||
|
||||
char *newargv[256];
|
||||
|
||||
int
|
||||
main (int argc, const char **argv)
|
||||
{
|
||||
double newtime, time, oldtime;
|
||||
double time, oldtime, newtime;
|
||||
|
||||
startup ();
|
||||
|
||||
|
@ -105,9 +101,8 @@ main (int argc, const char **argv)
|
|||
// run one frame immediately for first heartbeat
|
||||
SV_Frame (0.1);
|
||||
|
||||
// main loop
|
||||
oldtime = Sys_DoubleTime () - 0.1;
|
||||
while (1) {
|
||||
while (1) { // Main message loop
|
||||
Sys_CheckInput (!svs.num_clients, net_socket);
|
||||
|
||||
// find time passed since last cycle
|
||||
|
@ -117,6 +112,4 @@ main (int argc, const char **argv)
|
|||
|
||||
SV_Frame (time);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue