Skip to content

Commit

Permalink
Determine global paths (userdir, basedir etc) as early as possible du…
Browse files Browse the repository at this point in the history
…ring startup, so that under Windows we can provide LoadLibrary() with absolute paths. Also added DENG_LIBRARY_DIR which if defined at compile time; changes the location of the library dir under Windows relative to the base directory (Added for dev purposes only. It should NOT be defined in release builds (a compile time warning will be generated if so)).
  • Loading branch information
danij committed Mar 20, 2008
1 parent 6ca8083 commit 24b42cc
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 262 deletions.
4 changes: 2 additions & 2 deletions doomsday/build/win32/vs8/doomsday.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/Gs "
AdditionalIncludeDirectories="..\..\..\engine\win32\include;..\..\..\engine\portable\include;..\..\..\engine\api\;..\..\..\external\lzss\portable\include;..\..\..\external\zlib\portable\include;..\..\..\external\libpng\portable\include;..\..\..\external\libcurl\portable\include"
PreprocessorDefinitions="__DOOMSDAY__,ZLIB_DLL,WIN32_GAMMA,NORANGECHECKING,WIN32,NDEBUG,_WINDOWS"
PreprocessorDefinitions="DENG_LIBRARY_DIR="\"bin\\release\"";__DOOMSDAY__;ZLIB_DLL;WIN32_GAMMA;NORANGECHECKING;WIN32;NDEBUG;_WINDOWS"
BasicRuntimeChecks="0"
AssemblerListingLocation="./Obj/Release/"
ObjectFile="./Obj/Release/"
Expand Down Expand Up @@ -145,7 +145,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\engine\win32\include;..\..\..\engine\portable\include;..\..\..\engine\api\;..\..\..\external\lzss\portable\include;..\..\..\external\zlib\portable\include;..\..\..\external\libpng\portable\include;..\..\..\external\libcurl\portable\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE,ZLIB_DLL,__DOOMSDAY__,WIN32_GAMMA,WIN32,_DEBUG,_WINDOWS"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS;DENG_LIBRARY_DIR="\"bin\\debug\"";__DOOMSDAY__;ZLIB_DLL;WIN32_GAMMA;WIN32;_DEBUG;_WINDOWS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
Expand Down
57 changes: 2 additions & 55 deletions doomsday/engine/portable/src/dd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ int queryResult = 0;
// PRIVATE DATA DEFINITIONS ------------------------------------------------

static char *wadfiles[MAXWADFILES];
static boolean userDirOk = true;

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

Expand Down Expand Up @@ -341,58 +340,6 @@ int DD_Main(void)
boolean noCenter = false;
int exitCode;

#ifdef UNIX
# ifndef MACOSX
if(getenv("HOME"))
{
filename_t homeDir;
sprintf(homeDir, "%s/.deng", getenv("HOME"));
M_CheckPath(homeDir);
Dir_MakeDir(homeDir, &ddRuntimeDir);
userDirOk = Dir_ChDir(&ddRuntimeDir);
}
# endif
#endif

// The -userdir option sets the working directory.
if(ArgCheckWith("-userdir", 1))
{
Dir_MakeDir(ArgNext(), &ddRuntimeDir);
userDirOk = Dir_ChDir(&ddRuntimeDir);
}

// The current working directory is the runtime dir.
Dir_GetDir(&ddRuntimeDir);

#ifdef UNIX
/** The base path is always the same and depends on the build
* configuration. Usually this is something like
* "/usr/share/deng/".
*/
# ifdef MACOSX
strcpy(ddBasePath, "./");
# else
strcpy(ddBasePath, DENG_BASE_DIR);
# endif
#endif

#ifdef WIN32
// The standard base directory is two levels upwards.
if(ArgCheck("-stdbasedir"))
{
strcpy(ddBasePath, "..\\..\\");
}
#endif

if(ArgCheckWith("-basedir", 1))
{
strcpy(ddBasePath, ArgNext());
Dir_ValidDir(ddBasePath);
}

Dir_MakeAbsolute(ddBasePath);
Dir_ValidDir(ddBasePath);

// By default, use the resolution defined in (default).cfg.
winX = 0;
winY = 0;
Expand Down Expand Up @@ -508,7 +455,7 @@ int DD_Main(void)

static int DD_StartupWorker(void *parm)
{
int p = 0;
int p = 0;

#ifdef WIN32
// Initialize COM for this thread (needed for DirectInput).
Expand All @@ -535,7 +482,7 @@ static int DD_StartupWorker(void *parm)
sprintf(defsFileName, "%sdefs\\doomsday.ded", ddBasePath);

// Was the change to userdir OK?
if(!userDirOk)
if(!app.userDirOk)
Con_Message("--(!)-- User directory not found " "(check -userdir).\n");

bamsInit(); // Binary angle calculations.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/dd_pinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void DD_Verbosity(void)
*/
boolean DD_EarlyInit(void)
{
char *outfilename = "doomsday.out";
char *outfilename = "doomsday.out";

// We'll redirect stdout to a log file.
DD_CheckArg("-out", &outfilename);
Expand Down
94 changes: 48 additions & 46 deletions doomsday/engine/unix/include/dd_uinit.h
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2006-2007 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2007 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

/*
* dd_uinit.h: Unix Initialization
*/

#ifndef __DOOMSDAY_UINIT_H__
#define __DOOMSDAY_UINIT_H__

#include "dd_pinit.h"
#include "sys_dylib.h"

typedef struct {
lt_dlhandle hGame; // Instance handle to the game library.
lt_dlhandle hPlugins[MAX_PLUGS]; // Instance handle to all other libs.
GETGAMEAPI GetGameAPI;
} application_t;

extern uint windowIDX; // Main window.
extern application_t app;

void DD_Shutdown(void);

#endif
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2006-2007 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2008 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

/**
* dd_uinit.h: Unix Initialization.
*/

#ifndef __DOOMSDAY_UINIT_H__
#define __DOOMSDAY_UINIT_H__

#include "dd_pinit.h"
#include "sys_dylib.h"

typedef struct {
boolean userDirOk;

lt_dlhandle hInstGame; // Instance handle to the game library.
lt_dlhandle hInstPlug[MAX_PLUGS]; // Instance handle to all other libs.
GETGAMEAPI GetGameAPI;
} application_t;

extern uint windowIDX; // Main window.
extern application_t app;

void DD_Shutdown(void);

#endif
Loading

0 comments on commit 24b42cc

Please sign in to comment.