Skip to content

Commit

Permalink
Fixed dedicated server UI on ncurses / Mac OS X
Browse files Browse the repository at this point in the history
Most likely this fixes the dedicated server UI also for other
Unix builds. Added checks for isDedicated in various places
to prevent full resource/GL subsystem preparation.
  • Loading branch information
skyjake committed Mar 5, 2011
1 parent 2158109 commit ea23838
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
4 changes: 2 additions & 2 deletions doomsday/CMakeLists.txt
Expand Up @@ -430,7 +430,7 @@ IF (BUILDOPENAL)
INCLUDE_DIRECTORIES (${OPENAL_INCLUDE_DIR})
ENDIF (BUILDOPENAL)

IF (UNIX)
IF (UNIX AND NOT APPLE)
## Confirm we have dlopen
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DL)
IF(HAVE_DL)
Expand All @@ -441,7 +441,7 @@ IF (UNIX)
ELSE(HAVE_DL)
MESSAGE (FATAL_ERROR "** dlopen not found. On Ubuntu install libc6-dev.")
ENDIF(HAVE_DL)
ENDIF (UNIX)
ENDIF ()

## confirm we have Python
IF (NOT PYTHONINTERP_FOUND)
Expand Down
7 changes: 3 additions & 4 deletions doomsday/engine/mac/src/SDLMain.m
Expand Up @@ -237,7 +237,7 @@ void CustomApplicationMain (argc, argv)

/* Create a window for Doomsday startup messages. */
openStartupWindow();

/* Start the main event loop */
[NSApp run];

Expand Down Expand Up @@ -328,17 +328,16 @@ - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
/* Main entry point to executable - should *not* be SDL_main! */
int main (int argc, char *argv[])
{

/* Copy the arguments into a global variable */
int i;

/* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
gArgc = 1;
gFinderLaunch = YES;
gFinderLaunch = YES;
} else {
gArgc = argc;
gFinderLaunch = NO;
gFinderLaunch = NO;
}
gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
assert (gArgv != NULL);
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -494,8 +494,6 @@ static int DD_StartupWorker(void *parm)

HandleArgs(0); // Everything but WADs.

novideo = ArgCheck("-novideo") || isDedicated;

DAM_Init();

if(gx.PreInit)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/gl_defer.c
Expand Up @@ -173,7 +173,7 @@ DGLuint GL_GetReservedName(void)
DGLuint name;

if(!deferredInited)
Con_Error("GL_GetReserved: Deferred GL task system not initialized.");
Con_Error("GL_GetReservedName: Deferred GL task system not initialized.");

Sys_Lock(deferredMutex);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/p_material.c
Expand Up @@ -121,7 +121,7 @@ byte Material_Prepare(material_snapshot_t* snapshot, material_t* mat,
const gltexture_inst_t* detailInst = NULL, *shinyInst = NULL,
*shinyMaskInst = NULL;

if(!mat)
if(!mat || novideo)
return 0;

if(smoothed)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_data.c
Expand Up @@ -2059,7 +2059,7 @@ void R_PrecacheMobjNum(int num)
{
int i;

if(!((useModels && precacheSkins) || precacheSprites))
if(novideo || !((useModels && precacheSkins) || precacheSprites))
return;

if(num < 0 || num >= defs.count.mobjs.num)
Expand Down
25 changes: 18 additions & 7 deletions doomsday/engine/portable/src/sys_sdl_window.c
Expand Up @@ -48,7 +48,7 @@

// MACROS ------------------------------------------------------------------

#define LINELEN (80)
#define LINELEN (1024)

// TYPES -------------------------------------------------------------------

Expand Down Expand Up @@ -79,6 +79,10 @@ static boolean mainWindowInited = false;

static int screenWidth, screenHeight, screenBPP;

#if defined(UNIX)
static WINDOW* cursesRootWin;
#endif

// CODE --------------------------------------------------------------------

static __inline ddwindow_t *getWindow(uint idx)
Expand All @@ -95,6 +99,9 @@ static __inline ddwindow_t *getWindow(uint idx)
#if defined(UNIX)
static void setAttrib(int flags)
{
if(!mainWindowInited)
return;

if(flags & (CBLF_YELLOW | CBLF_LIGHT))
wattrset(mainWindow.console.winText, A_BOLD);
else
Expand Down Expand Up @@ -132,7 +139,7 @@ void Sys_ConPrint(uint idx, const char *text, int clflags)
if(!winManagerInited)
return;

if(idx != 1)
if(!novideo && idx != 1)
{
// We only support one terminal window (this isn't for us).
return;
Expand Down Expand Up @@ -451,13 +458,15 @@ static ddwindow_t *createDDWindow(application_t *app, int w, int h, int bpp,
int maxPos[2];

// Initialize curses.
if(!initscr())
if(!(cursesRootWin = initscr()))
Sys_CriticalMessage("createDDWindow: Failed creating terminal.");

cbreak();
noecho();
nonl();

mainWindow.type = type;

// The current size of the screen.
getmaxyx(stdscr, maxPos[VY], maxPos[VX]);

Expand Down Expand Up @@ -547,9 +556,6 @@ uint Sys_CreateWindow(application_t *app, uint parentIDX,
{
ddwindow_t *win;

if(isDedicated)
return 1; // No use.

if(!winManagerInited)
return 0; // Window manager not initialized yet.

Expand Down Expand Up @@ -585,11 +591,16 @@ boolean Sys_DestroyWindow(uint idx)
delwin(window->console.winTitle);
delwin(window->console.winText);
delwin(window->console.winCommand);
endwin();

window->console.winTitle = window->console.winText =
window->console.winCommand = NULL;

delwin(cursesRootWin);
cursesRootWin = 0;

endwin();
refresh();

Sys_ConInputShutdown();
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/unix/src/dd_uinit.c
Expand Up @@ -327,8 +327,8 @@ int main(int argc, char** argv)
cmdLine = NULL;

// First order of business: are we running in dedicated mode?
if(ArgCheck("-dedicated"))
isDedicated = true;
if(ArgCheck("-dedicated")) isDedicated = true;
novideo = ArgCheck("-novideo") || isDedicated;

DD_ComposeMainWindowTitle(buf);

Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/common/src/r_common.c
Expand Up @@ -82,6 +82,9 @@ void R_PrecachePSprites(void)
int i, k;
int pclass = players[CONSOLEPLAYER].class;

if(IS_DEDICATED)
return;

for(i = 0; i < NUM_WEAPON_TYPES; ++i)
{
for(k = 0; k < NUMWEAPLEVELS; ++k)
Expand Down

0 comments on commit ea23838

Please sign in to comment.