diff --git a/doomsday/client/include/dd_pinit.h b/doomsday/client/include/dd_pinit.h index 71af510303..af734a90c3 100644 --- a/doomsday/client/include/dd_pinit.h +++ b/doomsday/client/include/dd_pinit.h @@ -41,8 +41,6 @@ extern uint mainWindowIdx; */ void DD_ShutdownAll(void); -int DD_CheckArg(char const *tag, const char** value); - #ifdef __CLIENT__ /** * Compose the title for the main window. diff --git a/doomsday/client/include/render/r_main.h b/doomsday/client/include/render/r_main.h index 581e4e6d8e..2ef762b8ca 100644 --- a/doomsday/client/include/render/r_main.h +++ b/doomsday/client/include/render/r_main.h @@ -1,7 +1,7 @@ /** @file r_main.h * - * @author Copyright © 2003-2013 Jaakko Keränen - * @author Copyright © 2006-2013 Daniel Swanson + * @authors Copyright © 2003-2013 Jaakko Keränen + * @authors Copyright © 2006-2013 Daniel Swanson * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -18,8 +18,8 @@ * 02110-1301 USA */ -#ifndef LIBDENG_RENDER_R_MAIN_H -#define LIBDENG_RENDER_R_MAIN_H +#ifndef DENG_RENDER_R_MAIN_H +#define DENG_RENDER_R_MAIN_H #include #include "dd_share.h" @@ -29,18 +29,21 @@ class BspLeaf; class Lumobj; #endif -typedef struct viewport_s { +struct viewport_t +{ int console; RectRaw geometry; -} viewport_t; +}; -typedef struct viewer_s { +struct viewer_t +{ coord_t origin[3]; angle_t angle; float pitch; -} viewer_t; +}; -typedef struct viewdata_s { +struct viewdata_t +{ viewer_t current; viewer_t lastSharp[2]; ///< For smoothing. viewer_t latest; ///< "Sharp" values taken from here. @@ -57,14 +60,14 @@ typedef struct viewdata_s { RectRaw window, windowTarget, windowOld; float windowInter; -} viewdata_t; +}; -typedef enum fontstyle_e { +enum fontstyle_t { FS_NORMAL, FS_BOLD, FS_LIGHT, FONTSTYLE_COUNT -} fontstyle_t; +}; DENG_EXTERN_C float frameTimePos; // 0...1: fractional part for sharp game tics DENG_EXTERN_C int loadInStartupMode; @@ -93,31 +96,12 @@ DENG_EXTERN_C byte texGammaLut[256]; DENG_EXTERN_C boolean loInited; #endif -#ifdef __cplusplus -extern "C" { -#endif - /** * Register console variables. */ -void R_Register(void); - -void R_BuildTexGammaLut(void); - -/** - * One-time initialization of the refresh daemon. Called by DD_Main. - */ -void R_Init(void); - -/** - * Re-initialize almost everything. - */ -void R_Update(void); +void R_Register(); -/** - * Shutdown the refresh daemon. - */ -void R_Shutdown(void); +void R_BuildTexGammaLut(); void R_Ticker(timespan_t time); @@ -136,15 +120,15 @@ void R_RenderViewPorts(ui::ViewPortLayer layer); /** * Render a blank view for the specified player. */ -void R_RenderBlankView(void); +void R_RenderBlankView(); /** * Draw the border around the view window. */ -void R_RenderPlayerViewBorder(void); +void R_RenderPlayerViewBorder(); /// @return Current viewport; otherwise @c NULL. -viewport_t const *R_CurrentViewPort(void); +viewport_t const *R_CurrentViewPort(); /** * Set the current GL viewport. @@ -155,18 +139,18 @@ viewdata_t const *R_ViewData(int consoleNum); void R_UpdateViewer(int consoleNum); -void R_ResetViewer(void); +void R_ResetViewer(); -int R_NextViewer(void); +int R_NextViewer(); #ifdef __CLIENT__ -void R_ClearViewData(void); +void R_ClearViewData(); /** * To be called at the beginning of a render frame to perform necessary initialization. */ -void R_BeginFrame(void); +void R_BeginFrame(); /** * Returns @c true iff the BSP leaf is marked as visible for the current frame. @@ -207,7 +191,7 @@ void R_ViewerClipLumobjBySight(Lumobj *lum, BspLeaf *bspLeaf); * Update the sharp world data by rotating the stored values of plane * heights and sharp camera positions. */ -void R_NewSharpWorld(void); +void R_NewSharpWorld(); /** * Attempt to set up a view grid and calculate the viewports. Set 'numCols' and @@ -222,17 +206,11 @@ void R_SetupDefaultViewWindow(int consoleNum); */ void R_ViewWindowTicker(int consoleNum, timespan_t ticLength); -void R_SetViewPortPlayer(int consoleNum, int viewPlayer); - -void R_LoadSystemFonts(void); +void R_LoadSystemFonts(); #ifdef __CLIENT__ -char const *R_ChooseFixedFont(void); -char const *R_ChooseVariableFont(fontstyle_t style, int resX, int resY); -#endif - -#ifdef __cplusplus -} // extern "C" +char const *R_ChooseFixedFont(); +char const *R_ChooseVariableFont(fontstyle_t style); #endif -#endif /* LIBDENG_REFRESH_MAIN_H */ +#endif // DENG_REFRESH_MAIN_H diff --git a/doomsday/client/include/resource/resourcesystem.h b/doomsday/client/include/resource/resourcesystem.h index b5b78e5ec4..ab85d0281a 100644 --- a/doomsday/client/include/resource/resourcesystem.h +++ b/doomsday/client/include/resource/resourcesystem.h @@ -37,6 +37,7 @@ #include "Sprite" #include "Texture" #include "TextureScheme" +#include "resource/rawtexture.h" /// @todo not yet owned #include "resource/wad.h" #include "resource/zip.h" #include "uri.hh" diff --git a/doomsday/client/include/world/world.h b/doomsday/client/include/world/world.h index bb9c740556..c1349e5e63 100644 --- a/doomsday/client/include/world/world.h +++ b/doomsday/client/include/world/world.h @@ -47,6 +47,8 @@ class Map; /** * @ingroup world + * + * @todo Derive from de::System */ class World { diff --git a/doomsday/client/src/dd_help.cpp b/doomsday/client/src/dd_help.cpp index cd5abfa521..50cb2e391f 100644 --- a/doomsday/client/src/dd_help.cpp +++ b/doomsday/client/src/dd_help.cpp @@ -1,4 +1,5 @@ -/** @file dd_help.cpp Runtime help text strings. +/** @file dd_help.cpp Runtime help text strings. + * * @ingroup base * * @authors Copyright © 2003-2013 Jaakko Keränen @@ -29,8 +30,6 @@ #include #include -D_CMD(LoadHelp); - using namespace de; typedef QMap StringsByType; // HST_* type => string @@ -38,11 +37,6 @@ typedef QMap HelpStrings; // id => typed strings static HelpStrings helps; -void DH_Register(void) -{ - C_CMD("loadhelp", "", LoadHelp); -} - /** * Parses the given file looking for help strings. The contents of the file are * expected to use UTF-8 encoding. @@ -144,13 +138,13 @@ HelpId DH_Find(char const *id) { return &found.value(); } - return NULL; + return 0; } char const *DH_GetString(HelpId found, int type) { - if(!found || type < 0 || type > NUM_HELPSTRING_TYPES) - return NULL; + if(!found) return 0; + if(type < 0 || type > NUM_HELPSTRING_TYPES) return 0; StringsByType const *hs = reinterpret_cast(found); @@ -159,10 +153,10 @@ char const *DH_GetString(HelpId found, int type) { return Str_Text(AutoStr_FromTextStd(i.value().toUtf8().constData())); } - return NULL; + return 0; } -void DD_InitHelp(void) +void DD_InitHelp() { LOG_AS("DD_InitHelp"); try @@ -175,7 +169,7 @@ void DD_InitHelp(void) } } -void DD_ReadGameHelp(void) +void DD_ReadGameHelp() { LOG_AS("DD_ReadGameHelp"); try @@ -192,16 +186,21 @@ void DD_ReadGameHelp(void) } } -void DD_ShutdownHelp(void) +void DD_ShutdownHelp() { helps.clear(); } D_CMD(LoadHelp) { - DENG2_UNUSED(src); DENG2_UNUSED(argc); DENG2_UNUSED(argv); + DENG2_UNUSED3(src, argc, argv); DD_ShutdownHelp(); DD_InitHelp(); return true; } + +void DH_Register() +{ + C_CMD("loadhelp", "", LoadHelp); +} diff --git a/doomsday/client/src/dd_main.cpp b/doomsday/client/src/dd_main.cpp index 1766a4704b..1b5ec1fd52 100644 --- a/doomsday/client/src/dd_main.cpp +++ b/doomsday/client/src/dd_main.cpp @@ -84,7 +84,7 @@ #include #include #include -#include +#include #include #include #ifdef UNIX @@ -130,10 +130,11 @@ class WadFileType : public de::NativeFileType } }; +static void consoleRegister(); +static void initPathMappings(); static int DD_StartupWorker(void *context); static int DD_DummyWorker(void *context); static void DD_AutoLoad(); -static void initPathMappings(); /** * @param path Path to the file to be loaded. Either a "real" file in @@ -169,44 +170,6 @@ static FileTypes fileTypeMap; static ddstring_t **sessionResourceFileList; static size_t numSessionResourceFileList; -#ifdef __CLIENT__ - -D_CMD(CheckForUpdates) -{ - DENG2_UNUSED3(src, argc, argv); - - Con_Message("Checking for available updates..."); - ClientApp::updater().checkNow(Updater::OnlyShowResultIfUpdateAvailable); - return true; -} - -D_CMD(CheckForUpdatesAndNotify) -{ - DENG2_UNUSED3(src, argc, argv); - - Con_Message("Checking for available updates..."); - ClientApp::updater().checkNow(Updater::AlwaysShowResult); - return true; -} - -D_CMD(LastUpdated) -{ - DENG2_UNUSED3(src, argc, argv); - - ClientApp::updater().printLastUpdated(); - return true; -} - -D_CMD(ShowUpdateSettings) -{ - DENG2_UNUSED3(src, argc, argv); - - ClientApp::updater().showSettings(); - return true; -} - -#endif // __CLIENT__ - static void registerResourceFileTypes() { FileType *ftype; @@ -517,38 +480,6 @@ de::ResourceClass &App_ResourceClass(resourceclassid_t classId) return App_ResourceSystem().resClass(classId); } -static void consoleRegister() -{ -#ifdef __CLIENT__ - C_CMD("update", "", CheckForUpdates); - C_CMD("updateandnotify", "", CheckForUpdatesAndNotify); - C_CMD("updatesettings", "", ShowUpdateSettings); - C_CMD("lastupdated", "", LastUpdated); -#endif - - DD_RegisterLoop(); - F_Register(); - Con_Register(); - DH_Register(); - R_Register(); - S_Register(); -#ifdef __CLIENT__ - B_Register(); // for control bindings - DD_RegisterInput(); - SBE_Register(); // for bias editor - RenderSystem::consoleRegister(); - GL_Register(); - UI_Register(); - Demo_Register(); - P_ControlRegister(); - I_Register(); -#endif - ResourceSystem::consoleRegister(); - Net_Register(); - World::consoleRegister(); - FI_Register(); -} - static void addToPathList(ddstring_t ***list, size_t *listSize, char const *rawPath) { DENG2_ASSERT(list != 0 && listSize != 0 && rawPath != 0 && rawPath[0]); @@ -604,12 +535,15 @@ void DD_StartTitle() { #ifdef __CLIENT__ ddfinale_t fin; - if(!Def_Get(DD_DEF_FINALE, "background", &fin)) return; + if(!Def_Get(DD_DEF_FINALE, "background", &fin)) + { + return; + } ddstring_t setupCmds; Str_Init(&setupCmds); // Configure the predefined fonts (all normal, variable width). - char const *fontName = R_ChooseVariableFont(FS_NORMAL, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT); + char const *fontName = R_ChooseVariableFont(FS_NORMAL); for(int i = 1; i <= FIPAGE_NUM_PREDEFINED_FONTS; ++i) { @@ -683,9 +617,9 @@ static int loadFilesFromDataGameAuto() * * @return Number of new files that were added to the list. */ -static int listFilesFromDataGameAuto(ddstring_t*** list, size_t* listSize) +static int listFilesFromDataGameAuto(ddstring_t ***list, size_t *listSize) { - if(!list || !listSize) return 0; + DENG2_ASSERT(list != 0 && listSize != 0); FS1::PathList found; findAllGameDataPaths(found); @@ -861,7 +795,10 @@ static void initPathMappings() int argC = CommandLine_Count(); for(int i = 0; i < argC; ++i) { - if(strnicmp("-vdmap", CommandLine_At(i), 6)) continue; + if(strnicmp("-vdmap", CommandLine_At(i), 6)) + { + continue; + } if(i < argC - 1 && !CommandLine_IsOption(i + 1) && !CommandLine_IsOption(i + 2)) { @@ -893,7 +830,7 @@ static bool parsePathLumpMapping(lumpname_t lumpName, ddstring_t *path, char con if(!*ptr || *ptr == '\n') return false; // Find the end of the lump name. - char const* end = (char const*)M_FindWhite((char*)ptr); + char const *end = (char const *)M_FindWhite((char *)ptr); if(!*end || *end == '\n') return false; size_t len = end - ptr; @@ -1083,10 +1020,8 @@ static int DD_ActivateGameWorker(void *context) Con_SetProgress(100); } - /** - * Parse the game's main config file. - * If a custom top-level config is specified; let it override. - */ + // Parse the game's main config file. + // If a custom top-level config is specified; let it override. ddstring_t const *configFileName = 0; ddstring_t tmp; if(CommandLine_CheckWith("-config", 1)) @@ -1100,7 +1035,7 @@ static int DD_ActivateGameWorker(void *context) configFileName = App_CurrentGame().mainConfig(); } - Con_Message("Parsing primary config \"%s\"...", F_PrettyPath(Str_Text(configFileName))); + LOG_MSG("Parsing primary config \"%s\"...") << F_PrettyPath(Str_Text(configFileName)); Con_ParseCommands2(Str_Text(configFileName), CPCF_SET_DEFAULT | CPCF_ALLOW_SAVE_STATE); if(configFileName == &tmp) Str_Free(&tmp); @@ -1137,9 +1072,6 @@ static int DD_ActivateGameWorker(void *context) DD_ReadGameHelp(); - // Re-init to update the title, background etc. - //Rend_ConsoleInit(); - // Reset the tictimer so than any fractional accumulation is not added to // the tic/game timer of the newly-loaded game. gameTime = 0; @@ -1393,7 +1325,9 @@ bool App_ChangeGame(Game &game, bool allowReload) if(App_GameLoaded()) { if(gx.Shutdown) + { gx.Shutdown(); + } Con_SaveDefaults(); #ifdef __CLIENT__ @@ -1486,7 +1420,8 @@ bool App_ChangeGame(Game &game, bool allowReload) // Re-initialize subsystems needed even when in ringzero. if(!DD_ExchangeGamePluginEntryPoints(game.pluginId())) { - LOG_WARNING("Failed exchanging entrypoints with plugin %i, aborting...") << int(game.pluginId()); + LOG_WARNING("Failed exchanging entrypoints with plugin %i, aborting...") + << int(game.pluginId()); return false; } @@ -1501,13 +1436,13 @@ bool App_ChangeGame(Game &game, bool allowReload) ClientWindow::main().setWindowTitle(buf); #endif - /** + /* * If we aren't shutting down then we are either loading a game or switching * to ringzero (the current game will have already been unloaded). */ if(!DD_IsShuttingDown()) { - /** + /* * The bulk of this we can do in busy mode unless we are already busy * (which can happen if a fatal error occurs during game load and we must * shutdown immediately; Sys_Shutdown will call back to load the special @@ -1522,7 +1457,7 @@ bool App_ChangeGame(Game &game, bool allowReload) // Phase 2: Loading "startup" resources. { DD_LoadGameStartupResourcesWorker, &p, busyMode, NULL, 200, 0.1f, 0.3f, 0 }, - // Phase 3: Loading "addon" resources. + // Phase 3: Loading "add-on" resources. { DD_LoadAddonResourcesWorker, &p, busyMode, "Loading add-ons...", 200, 0.3f, 0.7f, 0 }, // Phase 4: Game activation. @@ -2040,7 +1975,7 @@ static int DD_StartupWorker(void * /*context*/) Time begunAt; LOG_MSG("Parsing additional (pre-init) config files:"); - for(;;) + forever { char const *arg = CommandLine_NextAsPath(); if(!arg || arg[0] == '-') break; @@ -2075,7 +2010,15 @@ static int DD_StartupWorker(void * /*context*/) Con_SetProgress(90); R_BuildTexGammaLut(); - R_Init(); + R_LoadSystemFonts(); + R_InitTranslationTables(); + R_InitRawTexs(); + R_InitSvgs(); +#ifdef __CLIENT__ + R_InitViewWindow(); + Rend_Init(); +#endif + frameCount = 0; Con_SetProgress(165); Net_InitGame(); @@ -2121,7 +2064,7 @@ static int DD_DummyWorker(void * /*context*/) return 0; } -void DD_CheckTimeDemo(void) +void DD_CheckTimeDemo() { static boolean checked = false; @@ -2155,7 +2098,37 @@ static int DD_UpdateEngineStateWorker(void *context) Con_SetProgress(50); } - R_Update(); + // Reset file IDs so previously seen files can be processed again. + F_ResetFileIds(); + // Re-read definitions. + Def_Read(); + + R_UpdateRawTexs(); + App_ResourceSystem().initSprites(); // Fully reinitialize sprites. +#ifdef __CLIENT__ + App_ResourceSystem().initModels(); // Defs might've changed. +#endif + + R_UpdateTranslationTables(); + + Def_PostInit(); + + App_World().update(); + +#ifdef __CLIENT__ + // Recalculate the light range mod matrix. + Rend_UpdateLightModMatrix(); + + // The rendering lists have persistent data that has changed during the + // re-initialization. + ClientApp::renderSystem().clearDrawLists(); + + /// @todo fixme: Update the game title and the status. +#endif + +#ifdef DENG_DEBUG + Z_CheckHeap(); +#endif if(initiatedBusyMode) { @@ -2334,7 +2307,7 @@ int DD_GetInteger(int ddvalue) case DD_NUMLUMPS: return F_LumpCount(); - case DD_MAP_MUSIC: { + case DD_MAP_MUSIC: if(App_World().hasMap()) { de::Uri mapUri = App_World().map().uri(); @@ -2343,15 +2316,19 @@ int DD_GetInteger(int ddvalue) return Def_GetMusicNum(mapInfo->music); } } - return -1; } + return -1; default: break; } if(ddvalue >= DD_LAST_VALUE || ddvalue <= DD_FIRST_VALUE) + { return 0; + } if(ddValues[ddvalue].readPtr == 0) + { return 0; + } return *ddValues[ddvalue].readPtr; } @@ -2362,9 +2339,14 @@ int DD_GetInteger(int ddvalue) void DD_SetInteger(int ddvalue, int parm) { if(ddvalue <= DD_FIRST_VALUE || ddvalue >= DD_LAST_VALUE) + { return; + } + if(ddValues[ddvalue].writePtr) + { *ddValues[ddvalue].writePtr = parm; + } } /** @@ -2375,11 +2357,8 @@ void DD_SetInteger(int ddvalue, int parm) void *DD_GetVariable(int ddvalue) { static int value; - static float valueF; static double valueD; - DENG_UNUSED(valueF); - switch(ddvalue) { case DD_GAME_EXPORTS: @@ -2413,7 +2392,7 @@ void *DD_GetVariable(int ddvalue) if(App_World().hasMap()) { de::Uri mapUri = App_World().map().uri(); - ded_mapinfo_t* mapInfo = Def_GetMapInfo(reinterpret_cast(&mapUri)); + ded_mapinfo_t *mapInfo = Def_GetMapInfo(reinterpret_cast(&mapUri)); if(mapInfo && mapInfo->author[0]) { return mapInfo->author; @@ -2474,7 +2453,7 @@ void *DD_GetVariable(int ddvalue) // We have to separately calculate the 35 Hz ticks. case DD_GAMETIC: { - static timespan_t fracTic; + static timespan_t fracTic; fracTic = gameTime * TICSPERSEC; return &fracTic; } @@ -2487,7 +2466,9 @@ void *DD_GetVariable(int ddvalue) } if(ddvalue >= DD_LAST_VALUE || ddvalue <= DD_FIRST_VALUE) + { return 0; + } // Other values not supported. return ddValues[ddvalue].writePtr; @@ -2590,7 +2571,6 @@ String DD_MaterialSchemeNameForTextureScheme(String textureSchemeName) { return "System"; } - return ""; } @@ -2610,33 +2590,34 @@ AutoStr *DD_MaterialSchemeNameForTextureScheme(ddstring_t const *textureSchemeNa /** * Convert propertyType enum constant into a string for error/debug messages. */ -const char* value_Str(int val) +char const *value_Str(int val) { static char valStr[40]; struct val_s { - int val; - const char* str; + int val; + char const *str; } valuetypes[] = { - { DDVT_BOOL, "DDVT_BOOL" }, - { DDVT_BYTE, "DDVT_BYTE" }, - { DDVT_SHORT, "DDVT_SHORT" }, - { DDVT_INT, "DDVT_INT" }, - { DDVT_UINT, "DDVT_UINT" }, - { DDVT_FIXED, "DDVT_FIXED" }, - { DDVT_ANGLE, "DDVT_ANGLE" }, - { DDVT_FLOAT, "DDVT_FLOAT" }, - { DDVT_DOUBLE, "DDVT_DOUBLE" }, - { DDVT_LONG, "DDVT_LONG" }, - { DDVT_ULONG, "DDVT_ULONG" }, - { DDVT_PTR, "DDVT_PTR" }, - { DDVT_BLENDMODE, "DDVT_BLENDMODE" }, + { DDVT_BOOL, "DDVT_BOOL" }, + { DDVT_BYTE, "DDVT_BYTE" }, + { DDVT_SHORT, "DDVT_SHORT" }, + { DDVT_INT, "DDVT_INT" }, + { DDVT_UINT, "DDVT_UINT" }, + { DDVT_FIXED, "DDVT_FIXED" }, + { DDVT_ANGLE, "DDVT_ANGLE" }, + { DDVT_FLOAT, "DDVT_FLOAT" }, + { DDVT_DOUBLE, "DDVT_DOUBLE" }, + { DDVT_LONG, "DDVT_LONG" }, + { DDVT_ULONG, "DDVT_ULONG" }, + { DDVT_PTR, "DDVT_PTR" }, + { DDVT_BLENDMODE, "DDVT_BLENDMODE" }, { 0, NULL } }; - uint i; - for(i = 0; valuetypes[i].str; ++i) + for(uint i = 0; valuetypes[i].str; ++i) + { if(valuetypes[i].val == val) return valuetypes[i].str; + } sprintf(valStr, "(unnamed %i)", val); return valStr; @@ -2644,7 +2625,7 @@ const char* value_Str(int val) D_CMD(Load) { - DENG_UNUSED(src); + DENG2_UNUSED(src); bool didLoadGame = false, didLoadResource = false; int arg = 1; @@ -2659,7 +2640,7 @@ D_CMD(Load) // Ignore attempts to load directories. if(Str_RAt(searchPath, 0) == '/') { - Con_Message("Directories cannot be \"loaded\" (only files and/or known games)."); + LOG_WARNING("Directories cannot be \"loaded\" (only files and/or known games)."); return true; } @@ -2669,15 +2650,19 @@ D_CMD(Load) Game &game = App_Games().byIdentityKey(Str_Text(searchPath)); if(!game.allStartupFilesFound()) { - Con_Message("Failed to locate all required startup resources:"); + LOG_WARNING("Failed to locate all required startup resources:"); Game::printFiles(game, FF_STARTUP); - Con_Message("%s (%s) cannot be loaded.", Str_Text(game.title()), Str_Text(game.identityKey())); + LOG_MSG("%s (%s) cannot be loaded.") + << Str_Text(game.title()) << Str_Text(game.identityKey()); return true; } BusyMode_FreezeGameForBusyMode(); - if(!App_ChangeGame(game)) return false; + if(!App_ChangeGame(game)) + { + return false; + } didLoadGame = true; ++arg; @@ -2691,7 +2676,7 @@ D_CMD(Load) try { String foundPath = App_FileSystem().findPath(de::Uri::fromNativePath(argv[arg], RC_PACKAGE), - RLF_MATCH_EXTENSION, App_ResourceClass(RC_PACKAGE)); + RLF_MATCH_EXTENSION, App_ResourceClass(RC_PACKAGE)); foundPath = App_BasePath() / foundPath; // Ensure the path is absolute. if(tryLoadFile(de::Uri(foundPath, RC_NULL))) @@ -2699,7 +2684,7 @@ D_CMD(Load) didLoadResource = true; } } - catch(FS1::NotFoundError const&) + catch(FS1::NotFoundError const &) {} // Ignore this error. } @@ -2711,14 +2696,14 @@ D_CMD(Load) return didLoadGame || didLoadResource; } -static de::File1* tryLoadFile(de::Uri const& search, size_t baseOffset) +static de::File1 *tryLoadFile(de::Uri const &search, size_t baseOffset) { try { de::FileHandle& hndl = App_FileSystem().openFile(search.path(), "rb", baseOffset, false /* no duplicates */); de::Uri foundFileUri = hndl.file().composeUri(); - VERBOSE( Con_Message("Loading \"%s\"...", NativePath(foundFileUri.asText()).pretty().toUtf8().constData()) ) + LOG_VERBOSE("Loading \"%s\"...") << NativePath(foundFileUri.asText()).pretty().toUtf8().constData(); App_FileSystem().index(hndl.file()); @@ -2729,13 +2714,13 @@ static de::File1* tryLoadFile(de::Uri const& search, size_t baseOffset) if(App_FileSystem().accessFile(search)) { // Must already be loaded. - LOG_DEBUG("\"%s\" already loaded.") << NativePath(search.asText()).pretty(); + LOG_INFO("\"%s\" already loaded.") << NativePath(search.asText()).pretty(); } } return 0; } -static bool tryUnloadFile(de::Uri const& search) +static bool tryUnloadFile(de::Uri const &search) { try { @@ -2775,7 +2760,7 @@ D_CMD(Unload) { if(!App_GameLoaded()) { - Con_Message("There is no game currently loaded."); + LOG_MSG("No game is currently loaded."); return true; } return App_ChangeGame(App_Games().nullGame()); @@ -2791,7 +2776,7 @@ D_CMD(Unload) // Ignore attempts to unload directories. if(Str_RAt(searchPath, 0) == '/') { - Con_Message("Directories cannot be \"unloaded\" (only files and/or known games)."); + LOG_MSG("Directories cannot be \"unloaded\" (only files and/or known games)."); return true; } @@ -2806,7 +2791,7 @@ D_CMD(Unload) return App_ChangeGame(App_Games().nullGame()); } - Con_Message("%s is not currently loaded.", Str_Text(game.identityKey())); + LOG_MSG("%s is not currently loaded.") << Str_Text(game.identityKey()); return true; } catch(Games::NotFoundError const &) @@ -2855,13 +2840,83 @@ D_CMD(ReloadGame) if(!App_GameLoaded()) { - Con_Message("No game is presently loaded."); + LOG_MSG("No game is presently loaded."); return true; } App_ChangeGame(App_CurrentGame(), true/* allow reload */); return true; } +#ifdef __CLIENT__ + +D_CMD(CheckForUpdates) +{ + DENG2_UNUSED3(src, argc, argv); + + LOG_MSG("Checking for available updates..."); + ClientApp::updater().checkNow(Updater::OnlyShowResultIfUpdateAvailable); + return true; +} + +D_CMD(CheckForUpdatesAndNotify) +{ + DENG2_UNUSED3(src, argc, argv); + + LOG_MSG("Checking for available updates..."); + ClientApp::updater().checkNow(Updater::AlwaysShowResult); + return true; +} + +D_CMD(LastUpdated) +{ + DENG2_UNUSED3(src, argc, argv); + + ClientApp::updater().printLastUpdated(); + return true; +} + +D_CMD(ShowUpdateSettings) +{ + DENG2_UNUSED3(src, argc, argv); + + ClientApp::updater().showSettings(); + return true; +} + +#endif // __CLIENT__ + +static void consoleRegister() +{ +#ifdef __CLIENT__ + C_CMD("update", "", CheckForUpdates); + C_CMD("updateandnotify", "", CheckForUpdatesAndNotify); + C_CMD("updatesettings", "", ShowUpdateSettings); + C_CMD("lastupdated", "", LastUpdated); +#endif + + DD_RegisterLoop(); + F_Register(); + Con_Register(); + DH_Register(); + R_Register(); + S_Register(); +#ifdef __CLIENT__ + B_Register(); // for control bindings + DD_RegisterInput(); + SBE_Register(); // for bias editor + RenderSystem::consoleRegister(); + GL_Register(); + UI_Register(); + Demo_Register(); + P_ControlRegister(); + I_Register(); +#endif + ResourceSystem::consoleRegister(); + Net_Register(); + World::consoleRegister(); + FI_Register(); +} + // dd_loop.c DENG_EXTERN_C boolean DD_IsSharpTick(void); diff --git a/doomsday/client/src/dd_pinit.cpp b/doomsday/client/src/dd_pinit.cpp index bf31f10e95..aa111b2017 100644 --- a/doomsday/client/src/dd_pinit.cpp +++ b/doomsday/client/src/dd_pinit.cpp @@ -37,6 +37,11 @@ #include "de_filesys.h" #include "def_main.h" +#include "gl/svg.h" +#ifdef __CLIENT__ +# include "render/r_draw.h" +# include "render/rend_main.h" +#endif #include "render/r_main.h" #include "updater.h" @@ -56,22 +61,8 @@ DENG_DECLARE_API(InternalData) = }; game_export_t __gx; -int DD_CheckArg(char const *tag, const char** value) -{ - /// @todo Add parameter for using NextAsPath(). - - int i = CommandLine_Check(tag); - const char* next = CommandLine_Next(); - - if(!i) - return 0; - if(value && next) - *value = next; - return 1; -} - #ifdef __CLIENT__ -void DD_ComposeMainWindowTitle(char* title) +void DD_ComposeMainWindowTitle(char *title) { if(App_GameLoaded() && gx.GetVariable) { @@ -161,8 +152,11 @@ void DD_ShutdownAll(void) #ifdef __SERVER__ Sv_Shutdown(); #endif - R_Shutdown(); - + R_ShutdownSvgs(); +#ifdef __CLIENT__ + R_ShutdownViewWindow(); + Rend_Shutdown(); +#endif Def_Destroy(); F_Shutdown(); Libdeng_Shutdown(); diff --git a/doomsday/client/src/render/r_draw.cpp b/doomsday/client/src/render/r_draw.cpp index bd5e8d1a11..147ab27e28 100644 --- a/doomsday/client/src/render/r_draw.cpp +++ b/doomsday/client/src/render/r_draw.cpp @@ -21,19 +21,19 @@ #include "clientapp.h" #include "render/r_draw.h" -#include "render/r_main.h" +#include "con_main.h" #include "gl/gl_draw.h" #include "gl/gl_main.h" #include "gl/sys_opengl.h" +#include "render/r_main.h" + #include "api_resource.h" #include "MaterialSnapshot" #include "world/p_players.h" // displayPlayer -#include "con_main.h" - using namespace de; // A logical ordering (twice around). @@ -51,7 +51,7 @@ enum { static bool inited = false; static int borderSize; -static struct uri_s *borderGraphicsNames[9]; +static de::Uri *borderGraphicsNames[9]; /// @todo Declare the patches with URNs to avoid unnecessary duplication here -ds static patchid_t borderPatches[9]; @@ -61,35 +61,55 @@ static void loadViewBorderPatches() borderPatches[0] = 0; for(uint i = 1; i < 9; ++i) { - borderPatches[i] = ClientApp::resourceSystem().declarePatch(reinterpret_cast(borderGraphicsNames[i])->path()); + borderPatches[i] = ClientApp::resourceSystem().declarePatch(borderGraphicsNames[i]->path()); } // Detemine the view border size. borderSize = 0; patchinfo_t info; - if(!R_GetPatchInfo(borderPatches[BG_TOP], &info)) return; + if(!R_GetPatchInfo(borderPatches[BG_TOP], &info)) + { + return; + } borderSize = info.geometry.size.height; } +static Texture &borderTexture(int borderComp) +{ + TextureScheme &patches = ClientApp::resourceSystem().textureScheme("Patches"); + DENG2_ASSERT(borderComp >= 0 && borderComp < 9); + return patches.findByUniqueId(borderPatches[borderComp]).texture(); +} + #undef R_SetBorderGfx DENG_EXTERN_C void R_SetBorderGfx(struct uri_s const *const *paths) { DENG2_ASSERT(inited); - if(!paths) Con_Error("R_SetBorderGfx: Missing argument."); + if(!paths) + { +#ifdef DENG_DEBUG + LOG_AS("R_SetBorderGfx"); + LOG_WARNING("R_SetBorderGfx: Invalid arguments, aborting."); +#endif + return; + } for(uint i = 0; i < 9; ++i) { if(paths[i]) { if(!borderGraphicsNames[i]) - borderGraphicsNames[i] = Uri_Dup(paths[i]); - else - Uri_Copy(borderGraphicsNames[i], paths[i]); + { + borderGraphicsNames[i] = new de::Uri; + } + *(borderGraphicsNames[i]) = *reinterpret_cast(paths[i]); } else { if(borderGraphicsNames[i]) - Uri_Delete(borderGraphicsNames[i]); + { + delete borderGraphicsNames[i]; + } borderGraphicsNames[i] = 0; } } @@ -97,7 +117,7 @@ DENG_EXTERN_C void R_SetBorderGfx(struct uri_s const *const *paths) loadViewBorderPatches(); } -void R_InitViewWindow(void) +void R_InitViewWindow() { for(int i = 0; i < DDMAXPLAYERS; ++i) { @@ -110,32 +130,34 @@ void R_InitViewWindow(void) { if(borderGraphicsNames[i]) { - Uri_Delete(borderGraphicsNames[i]); + delete borderGraphicsNames[i]; } } } - memset(borderGraphicsNames, 0, sizeof(borderGraphicsNames)); - memset(borderPatches, 0, sizeof(borderPatches)); + de::zap(borderGraphicsNames); + de::zap(borderPatches); borderSize = 0; inited = true; } -void R_ShutdownViewWindow(void) +void R_ShutdownViewWindow() { if(!inited) return; - for(uint i = 0; i < 9; ++i) + for(int i = 0; i < 9; ++i) { if(borderGraphicsNames[i]) - Uri_Delete(borderGraphicsNames[i]); + { + delete borderGraphicsNames[i]; + } } - memset(borderGraphicsNames, 0, sizeof(borderGraphicsNames)); + de::zap(borderGraphicsNames); inited = false; } -TextureVariantSpec const &Rend_PatchTextureSpec(int flags, - gl::Wrapping wrapS, gl::Wrapping wrapT) +TextureVariantSpec const &Rend_PatchTextureSpec(int flags, gl::Wrapping wrapS, + gl::Wrapping wrapT) { return ClientApp::resourceSystem().textureSpec(TC_UI, flags, 0, 0, 0, GL_Wrap(wrapS), GL_Wrap(wrapT), 0, -3, 0, false, false, false, false); @@ -147,7 +169,7 @@ void R_DrawPatch(Texture &texture, int x, int y, int w, int h, bool useOffsets) { #ifdef DENG_DEBUG LOG_AS("R_DrawPatch3"); - LOG_WARNING("Attempted to draw a non-patch [%p].") << dintptr(&texture); + LOG_WARNING("Attempted to draw a non-patch [%p], aborting.") << dintptr(&texture); #endif return; } @@ -197,10 +219,17 @@ void R_DrawViewBorder() viewport_t const *port = R_CurrentViewPort(); viewdata_t const *vd = R_ViewData(displayPlayer); - DENG_ASSERT(port && vd); + DENG_ASSERT(port != 0 && vd != 0); - if(0 == vd->window.size.width || 0 == vd->window.size.height) return; - if(vd->window.size.width == port->geometry.size.width && vd->window.size.height == port->geometry.size.height) return; + if(!vd->window.size.width || !vd->window.size.height) + { + return; + } + if(vd->window.size.width == port->geometry.size.width && + vd->window.size.height == port->geometry.size.height) + { + return; + } DENG_ASSERT_IN_MAIN_THREAD(); DENG_ASSERT_GL_CONTEXT_ACTIVE(); @@ -229,36 +258,34 @@ void R_DrawViewBorder() try { MaterialSnapshot const &ms = - ClientApp::resourceSystem().material(*reinterpret_cast(borderGraphicsNames[BG_BACKGROUND])) + ClientApp::resourceSystem().material(*borderGraphicsNames[BG_BACKGROUND]) .prepare(bgMaterialSpec()); GL_BindTexture(&ms.texture(MTU_PRIMARY)); GL_DrawCutRectf2Tiled(0, 0, port->geometry.size.width, port->geometry.size.height, ms.width(), ms.height(), 0, 0, - vd->window.origin.x - border, vd->window.origin.y - border, - vd->window.size.width + 2 * border, vd->window.size.height + 2 * border); + vd->window.origin.x - border, vd->window.origin.y - border, + vd->window.size.width + 2 * border, vd->window.size.height + 2 * border); } catch(MaterialManifest::MissingMaterialError const &) {} // Ignore this error. - if(border != 0) + if(border) { - TextureScheme &patches = ClientApp::resourceSystem().textureScheme("Patches"); - R_DrawPatchTiled(patches.findByUniqueId(borderPatches[BG_TOP]).texture(), vd->window.origin.x, vd->window.origin.y - border, vd->window.size.width, border, gl::Repeat, gl::ClampToEdge); - R_DrawPatchTiled(patches.findByUniqueId(borderPatches[BG_BOTTOM]).texture(), vd->window.origin.x, vd->window.origin.y + vd->window.size.height , vd->window.size.width, border, gl::Repeat, gl::ClampToEdge); - R_DrawPatchTiled(patches.findByUniqueId(borderPatches[BG_LEFT]).texture(), vd->window.origin.x - border, vd->window.origin.y, border, vd->window.size.height, gl::ClampToEdge, gl::Repeat); - R_DrawPatchTiled(patches.findByUniqueId(borderPatches[BG_RIGHT]).texture(), vd->window.origin.x + vd->window.size.width, vd->window.origin.y, border, vd->window.size.height, gl::ClampToEdge, gl::Repeat); + R_DrawPatchTiled(borderTexture(BG_TOP), vd->window.origin.x, vd->window.origin.y - border, vd->window.size.width, border, gl::Repeat, gl::ClampToEdge); + R_DrawPatchTiled(borderTexture(BG_BOTTOM), vd->window.origin.x, vd->window.origin.y + vd->window.size.height , vd->window.size.width, border, gl::Repeat, gl::ClampToEdge); + R_DrawPatchTiled(borderTexture(BG_LEFT), vd->window.origin.x - border, vd->window.origin.y, border, vd->window.size.height, gl::ClampToEdge, gl::Repeat); + R_DrawPatchTiled(borderTexture(BG_RIGHT), vd->window.origin.x + vd->window.size.width, vd->window.origin.y, border, vd->window.size.height, gl::ClampToEdge, gl::Repeat); } glMatrixMode(GL_TEXTURE); glPopMatrix(); - if(border != 0) + if(border) { - TextureScheme &patches = ClientApp::resourceSystem().textureScheme("Patches"); - R_DrawPatch(patches.findByUniqueId(borderPatches[BG_TOPLEFT]).texture(), vd->window.origin.x - border, vd->window.origin.y - border, border, border, false); - R_DrawPatch(patches.findByUniqueId(borderPatches[BG_TOPRIGHT]).texture(), vd->window.origin.x + vd->window.size.width, vd->window.origin.y - border, border, border, false); - R_DrawPatch(patches.findByUniqueId(borderPatches[BG_BOTTOMRIGHT]).texture(), vd->window.origin.x + vd->window.size.width, vd->window.origin.y + vd->window.size.height, border, border, false); - R_DrawPatch(patches.findByUniqueId(borderPatches[BG_BOTTOMLEFT]).texture(), vd->window.origin.x - border, vd->window.origin.y + vd->window.size.height, border, border, false); + R_DrawPatch(borderTexture(BG_TOPLEFT), vd->window.origin.x - border, vd->window.origin.y - border, border, border, false); + R_DrawPatch(borderTexture(BG_TOPRIGHT), vd->window.origin.x + vd->window.size.width, vd->window.origin.y - border, border, border, false); + R_DrawPatch(borderTexture(BG_BOTTOMRIGHT), vd->window.origin.x + vd->window.size.width, vd->window.origin.y + vd->window.size.height, border, border, false); + R_DrawPatch(borderTexture(BG_BOTTOMLEFT), vd->window.origin.x - border, vd->window.origin.y + vd->window.size.height, border, border, false); } glDisable(GL_TEXTURE_2D); diff --git a/doomsday/client/src/render/r_main.cpp b/doomsday/client/src/render/r_main.cpp index 1b3ab245e7..131c683c6c 100644 --- a/doomsday/client/src/render/r_main.cpp +++ b/doomsday/client/src/render/r_main.cpp @@ -1,7 +1,7 @@ /** @file r_main.cpp * - * @authors Copyright © 2003-2013 Jaakko Keränen - * @authors Copyright © 2006-2013 Daniel Swanson + * @authors Copyright © 2003-2013 Jaakko Keränen + * @authors Copyright © 2006-2013 Daniel Swanson * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -18,14 +18,9 @@ * 02110-1301 USA */ -#include -#include - -#ifdef __CLIENT__ -#include -#endif +#include "de_platform.h" +#include "render/r_main.h" -#include "de_base.h" #include "de_console.h" #include "de_system.h" #include "de_filesys.h" @@ -54,6 +49,12 @@ #include "BspLeaf" #include "Surface" +#ifdef __CLIENT__ +# include +#endif +#include +#include + using namespace de; #ifdef LIBDENG_CAMERA_MOVEMENT_ANALYSIS @@ -157,12 +158,10 @@ char const *R_ChooseFixedFont() if(DENG_GAMEVIEW_WIDTH > 768) return "console18"; return "console14"; } -#endif -char const *R_ChooseVariableFont(fontstyle_t style, int resX, int resY) +char const *R_ChooseVariableFont(fontstyle_t style) { - DENG_UNUSED(resX); - + int const resY = DENG_GAMEVIEW_HEIGHT; int const SMALL_LIMIT = 500; int const MED_LIMIT = 800; @@ -185,7 +184,6 @@ char const *R_ChooseVariableFont(fontstyle_t style, int resX, int resY) } } -#ifdef __CLIENT__ static AbstractFont *loadSystemFont(char const *name) { DENG2_ASSERT(name != 0 && name[0]); @@ -244,10 +242,10 @@ void R_LoadSystemFonts() if(isDedicated) return; - loadFontIfNeeded(R_ChooseFixedFont(), &fontFixed); - loadFontIfNeeded(R_ChooseVariableFont(FS_NORMAL, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT), &fontVariable[FS_NORMAL]); - loadFontIfNeeded(R_ChooseVariableFont(FS_BOLD, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT), &fontVariable[FS_BOLD]); - loadFontIfNeeded(R_ChooseVariableFont(FS_LIGHT, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT), &fontVariable[FS_LIGHT]); + loadFontIfNeeded(R_ChooseFixedFont(), &fontFixed); + loadFontIfNeeded(R_ChooseVariableFont(FS_NORMAL), &fontVariable[FS_NORMAL]); + loadFontIfNeeded(R_ChooseVariableFont(FS_BOLD), &fontVariable[FS_BOLD]); + loadFontIfNeeded(R_ChooseVariableFont(FS_LIGHT), &fontVariable[FS_LIGHT]); //Con_SetFont(fontFixed); @@ -365,8 +363,8 @@ DENG_EXTERN_C void R_SetViewWindowGeometry(int player, RectRaw const *geometry, RectRaw newGeom; // Clamp to valid range. - newGeom.origin.x = MINMAX_OF(0, geometry->origin.x, vp->geometry.size.width); - newGeom.origin.y = MINMAX_OF(0, geometry->origin.y, vp->geometry.size.height); + newGeom.origin.x = de::clamp(0, geometry->origin.x, vp->geometry.size.width); + newGeom.origin.y = de::clamp(0, geometry->origin.y, vp->geometry.size.height); newGeom.size.width = abs(geometry->size.width); newGeom.size.height = abs(geometry->size.height); if(newGeom.origin.x + newGeom.size.width > vp->geometry.size.width) @@ -531,63 +529,6 @@ boolean R_SetViewGrid(int numCols, int numRows) return true; } -void R_Init() -{ - R_LoadSystemFonts(); - R_InitTranslationTables(); - R_InitRawTexs(); - R_InitSvgs(); -#ifdef __CLIENT__ - R_InitViewWindow(); - Rend_Init(); -#endif - frameCount = 0; -} - -void R_Update() -{ - // Reset file IDs so previously seen files can be processed again. - F_ResetFileIds(); - // Re-read definitions. - Def_Read(); - - R_UpdateRawTexs(); - App_ResourceSystem().initSprites(); // Fully reinitialize sprites. -#ifdef __CLIENT__ - App_ResourceSystem().initModels(); // Defs might've changed. -#endif - - R_UpdateTranslationTables(); - - Def_PostInit(); - - App_World().update(); - -#ifdef __CLIENT__ - // Recalculate the light range mod matrix. - Rend_UpdateLightModMatrix(); - - // The rendering lists have persistent data that has changed during the - // re-initialization. - ClientApp::renderSystem().clearDrawLists(); - - /// @todo fixme: Update the game title and the status. -#endif - -#ifdef DENG_DEBUG - Z_CheckHeap(); -#endif -} - -void R_Shutdown() -{ - R_ShutdownSvgs(); -#ifdef __CLIENT__ - R_ShutdownViewWindow(); - Rend_Shutdown(); -#endif -} - void R_Ticker(timespan_t time) { for(int i = 0; i < DDMAXPLAYERS; ++i)