From 8e2aa8ea2af148179b377e5eadce3fdd46d7119c Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Wed, 18 Jul 2007 20:13:17 +0000 Subject: [PATCH] Cleaned up more FindArg's - general Debug Options; Cleanups --- 2d/palette.c | 2 - CHANGELOG.txt | 4 ++ SConstruct | 2 +- arch/ogl/gr.c | 30 ++------------- arch/ogl/ogl.c | 10 ++--- arch/sdl/gr.c | 14 ------- include/args.h | 12 ++++++ include/gr.h | 2 - include/ogl_init.h | 8 +--- include/palette.h | 1 - main/game.c | 3 -- main/inferno.c | 95 ++++++++++++---------------------------------- main/movie.c | 8 ++-- main/render.c | 2 +- main/text.c | 4 +- misc/args.c | 58 ++++++++++++++++++++++++++-- 16 files changed, 110 insertions(+), 145 deletions(-) diff --git a/2d/palette.c b/2d/palette.c index 6a86ef806..8eb0fc4a8 100755 --- a/2d/palette.c +++ b/2d/palette.c @@ -61,8 +61,6 @@ ubyte gr_palette_gamma = 0; int gr_palette_gamma_param = 0; ubyte gr_palette_faded_out = 1; -int grd_fades_disabled=0; // Used to skip fading for development - void gr_palette_set_gamma( int gamma ) { if ( gamma < 0 ) gamma = 0; diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c3b23f59c..ab72b87c6 100755 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20070718 +-------- +SCsonstruct, 2d/palette.c, arch/ogl/gr.c, arch/ogl/ogl.c, arch/sdl/gr.c, include/args.h, include/gr.h, include/ogl_init.h, include/palette.h, main/game.c, main/inferno.c, main/movie.c, main/render.c, main/text.c, misc/args.c: Cleaned up more FindArg's - general Debug Options; Cleanups + 20070716 -------- d2x.ini, arch/ogl/gr.c, arch/ogl/ogl.c, arch/ogl/include/internal.h, arch/sdl/gr.c, include/args.h, include/gr.h, include/ogl_init.h, main/automap.c, main/game.c, main/game.h, main/gamecntl.c, main/gamefont.c, main/gauges.c, main/inferno.c, main/menu.c, main/movie.c, main/newmenu.c, main/titles.c, misc/args.c: Cleaned up more FindArg's - (most important) OpenGL Options diff --git a/SConstruct b/SConstruct index ab21822a5..3dcc2b77a 100644 --- a/SConstruct +++ b/SConstruct @@ -344,7 +344,7 @@ if sys.platform == 'win32': sharepath = '' env.Append(CPPDEFINES = ['_WIN32', 'HAVE_STRUCT_TIMEVAL', 'NATIVE_IPX']) env.Append(CPPPATH = ['arch/win32/include', '/msys/1.0/MinGW/include/SDL']) - ogldefines = ['SDL_GL_VIDEO', 'OGL', 'OGL_RUNTIME_LOAD'] + ogldefines = ['SDL_GL_VIDEO', 'OGL'] common_sources += arch_win32_sources ogllibs = '' winlibs = ['glu32', 'wsock32', 'winmm', 'mingw32', 'SDLmain'] diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index de4031dd5..f39c05671 100755 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -280,26 +280,14 @@ int ogl_testneedmipmaps(int i){ Error("unknown texture filter %x\n",i); } -#ifdef OGL_RUNTIME_LOAD #ifdef _WIN32 char *OglLibPath="opengl32.dll"; -#endif -#ifdef __unix__ -char *OglLibPath="libGL.so"; -#endif -#ifdef macintosh -char *OglLibPath = NULL; -#endif int ogl_rt_loaded=0; int ogl_init_load_library(void) { int retcode=0; if (!ogl_rt_loaded){ - int t; - if ((t=FindArg("-gl_library"))) - OglLibPath=Args[t+1]; - retcode = OpenGL_LoadLibrary(true); if(retcode) { @@ -320,31 +308,19 @@ int ogl_init_load_library(void) int gr_init(int mode) { - int retcode, t, glt = 0; + int retcode, t; // Only do this function once! if (gr_installed==1) return -1; -#ifdef OGL_RUNTIME_LOAD +#ifdef _WIN32 ogl_init_load_library(); #endif if (!GameArg.SysWindow) gr_toggle_fullscreen(); - if ((glt=FindArg("-gl_alttexmerge"))) - ogl_alttexmerge=1; - if ((t=FindArg("-gl_stdtexmerge"))) - if (t>=glt)//allow overriding of earlier args - ogl_alttexmerge=0; - - if ((glt = FindArg("-gl_16bittextures"))) - { - ogl_rgba_internalformat = GL_RGB5_A1; - ogl_rgb_internalformat = GL_RGB5; - } - GL_needmipmaps=ogl_testneedmipmaps(GameArg.OglTexMinFilt); if ((t = FindArg("-gl_anisotropy")) || (t = FindArg("-gl_anisotropic"))) @@ -401,7 +377,7 @@ void gr_close() d_free(grd_curscreen); } ogl_close_pixel_buffers(); -#ifdef OGL_RUNTIME_LOAD +#ifdef _WIN32 if (ogl_rt_loaded) OpenGL_LoadLibrary(false); #endif diff --git a/arch/ogl/ogl.c b/arch/ogl/ogl.c index c569c9379..b25064694 100755 --- a/arch/ogl/ogl.c +++ b/arch/ogl/ogl.c @@ -79,7 +79,6 @@ int GL_TEXTURE_2D_enabled=-1; int GL_texclamp_enabled=-1; int r_texcount = 0, r_cachedtexcount = 0; -int ogl_alttexmerge=1;//merge textures by just printing the seperate textures? int ogl_rgba_internalformat = GL_RGBA8; int ogl_rgb_internalformat = GL_RGB8; int ogl_intensity4_ok=1; @@ -246,7 +245,7 @@ int ogl_texture_stats(void){ usedother++; } } - if (gr_renderstats) + if (GameArg.DbgRenderStats) { GLint idx, r, g, b, a, dbl, depth; int res, colorsize, depthsize; @@ -279,7 +278,7 @@ void ogl_clean_texture_cache(void){ int time=120; if (ogl_mem_target<0){ - if (gr_renderstats) + if (GameArg.DbgRenderStats) ogl_texture_stats(); return; } @@ -416,7 +415,7 @@ void ogl_cache_level_textures(void) if (tmap2 != 0){ PIGGY_PAGE_IN(Textures[tmap2&0x3FFF]); bm2 = &GameBitmaps[Textures[tmap2&0x3FFF].index]; - if (ogl_alttexmerge == 0 || (bm2->bm_flags & BM_FLAG_SUPER_TRANSPARENT)) + if (GameArg.DbgAltTexMerge == 0 || (bm2->bm_flags & BM_FLAG_SUPER_TRANSPARENT)) bm = texmerge_get_cached_bitmap( tmap1, tmap2 ); else { ogl_loadbmtexture(bm2); @@ -1015,9 +1014,8 @@ void ogl_end_frame(void){ void gr_flip(void) { ogl_clean_texture_cache(); - if (gr_renderstats){ + if (GameArg.DbgRenderStats) gr_printf(5,GAME_FONT->ft_h*13+3*13,"%i flat %i tex %i sprites %i bitmaps",r_polyc,r_tpolyc,r_bitmapc,r_ubitmapc); - } ogl_do_palfx(); ogl_swap_buffers_internal(); diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index 7ce46564a..382c02bb4 100755 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -425,13 +425,6 @@ int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys) if (gr_palette_faded_out) return 0; -#if 1 //ifndef NDEBUG - if (grd_fades_disabled) { - gr_palette_clear(); - return 0; - } -#endif - palette = screen->format->palette; if (palette == NULL) { return -1; // Display is not palettised @@ -492,13 +485,6 @@ int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) if (!gr_palette_faded_out) return 0; -#if 1 //ifndef NDEBUG - if (grd_fades_disabled) { - gr_palette_load(pal); - return 0; - } -#endif - palette = screen->format->palette; if (palette == NULL) { diff --git a/include/args.h b/include/args.h index 130dac74c..58a5f944d 100755 --- a/include/args.h +++ b/include/args.h @@ -41,6 +41,7 @@ extern int Inferno_verbose; // Dbg - Debugging/Undocumented Options typedef struct Arg { + int SysShowCmdHelp; int SysFPSIndicator; int SysUseNiceFPS; int SysMaxFPS; @@ -85,7 +86,18 @@ typedef struct Arg char *MplIpMyAddr; int MplIpBasePort; #ifdef EDITOR + char *EdiAutoLoad; int EdiMacData; + int EdiSaveHoardData; +#endif + int DbgVerbose; + int DbgNoRun; + int DbgRenderStats; + char *DbgAltTex; + char *DbgTexMap; + int DbgNoMovies; +#ifdef OGL + int DbgAltTexMerge; #endif } __attribute__ ((packed)) Arg; diff --git a/include/gr.h b/include/gr.h index b40f50d2e..0a158b7bc 100755 --- a/include/gr.h +++ b/include/gr.h @@ -397,8 +397,6 @@ extern unsigned char Test_bitmap_data[64*64]; //shortcut to look at current font #define grd_curfont grd_curcanv->cv_font -extern int gr_renderstats; - extern unsigned int FixDivide( unsigned int x, unsigned int y ); extern void gr_set_current_canvas( grs_canvas *canv ); diff --git a/include/ogl_init.h b/include/ogl_init.h index 071a2c193..83c7a6f02 100755 --- a/include/ogl_init.h +++ b/include/ogl_init.h @@ -13,16 +13,11 @@ # define MAC(x) #endif -#ifdef _MSC_VER //_WIN32 -#define OGL_RUNTIME_LOAD -#endif - -#ifdef OGL_RUNTIME_LOAD +#ifdef _WIN32 #include "loadgl.h" int ogl_init_load_library(void); #else #define GL_GLEXT_LEGACY -#undef GL_ARB_multitexture #if defined(__APPLE__) && defined(__MACH__) #include #include @@ -62,7 +57,6 @@ typedef struct _ogl_texture { extern ogl_texture* ogl_get_free_texture(); void ogl_init_texture(ogl_texture* t, int w, int h, int flags); -extern int ogl_alttexmerge;//merge textures by just printing the seperate textures? extern int ogl_rgba_internalformat; extern int ogl_rgb_internalformat; extern int ogl_setgammaramp_ok; diff --git a/include/palette.h b/include/palette.h index d607bfba6..a9c8a800f 100755 --- a/include/palette.h +++ b/include/palette.h @@ -26,7 +26,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. extern void gr_palette_set_gamma( int gamma ); extern int gr_palette_get_gamma(); extern ubyte gr_palette_faded_out; -extern int grd_fades_disabled; extern void gr_palette_clear(); extern int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys ); extern int gr_palette_fade_in(ubyte *pal,int nsteps, int allow_keys ); diff --git a/main/game.c b/main/game.c index 1f2cf2373..835e64620 100755 --- a/main/game.c +++ b/main/game.c @@ -1528,9 +1528,6 @@ int Config_menu_flag; jmp_buf LeaveGame; -int gr_renderstats = 0; -// need to define "cheat" for renderstats - int Cheats_enabled=0; extern int Laser_rapid_fire; diff --git a/main/inferno.c b/main/inferno.c index 544a6a04e..198a8189d 100755 --- a/main/inferno.c +++ b/main/inferno.c @@ -224,48 +224,32 @@ void print_commandline_help() printf( " -ip_baseport %s\n", "Use

as offset from normal port (allows multiple instances of d1x to be run on a single computer)"); #endif // NETWORK -#ifndef NDEBUG - printf( "\n Debug:\n\n"); - printf( " -debug %s\n", "Enable very verbose output"); - printf( " -Verbose %s\n", "Shows initialization steps for tech support"); - printf( " -renderstats %s\n", "Enable renderstats info by default"); - printf( " -norun %s\n", "Bail out after initialization"); - printf( " -nofade %s\n", "Disable fades"); - printf( " -norun %s\n", "Bail out after initialization"); - printf( " -text %s\n", "Specify alternate .tex file"); -#ifndef RELEASE - printf( " -nomovies %s\n", "Don't play movies"); -#endif // RELEASE -#ifdef SDL_VIDEO - printf( " -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch"); -#endif // SDL_VIDEO - #ifdef EDITOR printf( "\n Editor:\n\n"); - printf( " -autoload %s\n", "Autoload a level in the editor"); + printf( " -autoload %s\n", "Autoload a level in the editor"); printf( " -macdata %s\n", "Read and write mac data files in editor (swap colors)"); printf( " -hoarddata %s\n", "Make the hoard ham file from some files, then exit"); #endif // EDITOR +#ifndef NDEBUG + printf( "\n Debug:\n\n"); + printf( " -debug %s\n", "Enable very verbose output"); + printf( " -verbose %s\n", "Shows initialization steps for tech support"); + printf( " -norun %s\n", "Bail out after initialization"); + printf( " -renderstats %s\n", "Enable renderstats info by default"); + printf( " -text %s\n", "Specify alternate .tex file"); + printf( " -tmap %s\n", "Select texmapper to use (c,fp,quad,i386,pent,ppro)"); + printf( " -nomovies %s\n", "Don't play movies"); +#ifdef OGL + printf( " -gl_oldtexmerge %s\n", "Use old texmerge, uses more ram, but _might_ be a bit faster"); +#endif + /* KEPT FOR FURTHER REFERENCE printf( "\n Unused / Obsolete:\n\n"); - printf( " -nobm %s\n", "FIXME: Undocumented"); printf( " -bigpig %s\n", "FIXME: Undocumented"); printf( " -bspgen %s\n", "FIXME: Undocumented"); - printf( " -cdproxy %s\n", "FIXME: Undocumented"); printf( " -checktime %s\n", "FIXME: Undocumented"); - printf( " -showmeminfo %s\n", "FIXME: Undocumented"); - printf( " -codereadonly %s\n", "FIXME: Undocumented"); - printf( " -cyberimpact %s\n", "FIXME: Undocumented"); - printf( " -debugmode %s\n", "FIXME: Undocumented"); - printf( " -disallowgfx %s\n", "FIXME: Undocumented"); - printf( " -disallowreboot %s\n", "FIXME: Undocumented"); - printf( " -dynamicsockets %s\n", "FIXME: Undocumented"); - printf( " -forcegfx %s\n", "FIXME: Undocumented"); - printf( " -hw_3dacc %s\n", "FIXME: Undocumented"); printf( " -jasen %s\n", "FIXME: Undocumented"); - printf( " -joyslow %s\n", "FIXME: Undocumented"); - printf( " -logfile %s\n", "FIXME: Undocumented"); printf( " -memdbg %s\n", "FIXME: Undocumented"); printf( " -monodebug %s\n", "FIXME: Undocumented"); printf( " -nocyberman %s\n", "FIXME: Undocumented"); @@ -273,7 +257,6 @@ void print_commandline_help() printf( " -showaddress %s\n", "FIXME: Undocumented"); printf( " -socket %s\n", "FIXME: Undocumented"); printf( " -nomodex %s\n", "FIXME: Undocumented"); - printf( " -ordinaljoy %s\n", "FIXME: Undocumented"); printf( " -specialdevice %s\n", "FIXME: Undocumented"); printf( " -stickmag %s\n", "FIXME: Undocumented"); printf( " -stopwatch %s\n", "FIXME: Undocumented"); @@ -293,14 +276,7 @@ void print_commandline_help() printf( " -gl_vidmem %s\n", "FIXME: Undocumented"); printf( " -hwsurface %s\n", "FIXME: Undocumented"); printf( " -gl_library %s\n", "use alternate opengl library"); - printf( " -emul %s\n", "Certain video cards need this option in order to run game"); - printf( " -ddemul %s\n", "If -emul doesn't work, use this option"); - printf( " -rtscts %s\n", "Same as -ctsrts"); - printf( " -semiwin %s\n", "Use non-fullscreen mode"); - printf( " -ihaveabrokenmouse %s\n", "try to make mouse work if it is not currently"); - printf( " -joy209 %s\n", "Use alternate port 209 for joystick"); - printf( " -serialdevice %s\n", "Set serial/modem device to "); - printf( " -serialread %s\n", "Set serial/modem to read from "); + */ #endif // NDEBUG @@ -353,7 +329,6 @@ int menu_use_game_res=1; //extern ubyte gr_current_pal[]; #ifdef EDITOR -int Auto_exit = 0; char Auto_file[128] = ""; #endif @@ -368,10 +343,7 @@ int main(int argc, char *argv[]) error_init(NULL, NULL); PHYSFSX_init(argc, argv); - if (FindArg("-debug")) - con_threshold.value = (float)2; - else if (FindArg("-verbose")) - con_threshold.value = (float)1; + con_threshold.value = (float)GameArg.DbgVerbose; if (! cfile_init("descent2.hog", 1)) if (! cfile_init("d2demo.hog", 1)) @@ -402,13 +374,10 @@ int main(int argc, char *argv[]) con_printf(CON_NORMAL, " Copyright (c) 2005 Christian Beckhaeuser\n"); - if (FindArg( "-help" ) || FindArg( "-h" ) || FindArg( "-?" ) || FindArg( "?" ) ) { + if (GameArg.SysShowCmdHelp) { print_commandline_help(); set_exit_message(""); -#ifdef __MINGW32__ - exit(0); /* mingw hangs on this return. dunno why */ -#endif return(0); } @@ -451,20 +420,12 @@ int main(int argc, char *argv[]) atexit(sdl_close); - //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM"); - - if (FindArg("-renderstats")) - gr_renderstats = 1; - #ifndef NDEBUG if ( FindArg( "-checktime") ) checktime = 1; #endif - if ((t=FindArg("-tmap"))){ - select_tmap(Args[t+1]); - }else - select_tmap(NULL); + select_tmap(GameArg.DbgTexMap); Lighting_on = 1; @@ -518,8 +479,6 @@ int main(int argc, char *argv[]) } con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS); - if (FindArg("-nofade")) - grd_fades_disabled=1; //determine whether we're using high-res menus & movies if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res) @@ -560,7 +519,7 @@ int main(int argc, char *argv[]) bm_init(); #ifdef EDITOR - if (FindArg("-hoarddata") != 0) { + if (GameArg.EdiSaveHoardData) { save_hoard_data(); exit(1); } @@ -569,7 +528,7 @@ int main(int argc, char *argv[]) //the bitmap loading code changes gr_palette, so restore it memcpy(gr_palette,title_pal,sizeof(gr_palette)); - if ( FindArg( "-norun" ) ) + if (GameArg.DbgNoRun) return(0); con_printf( CON_DEBUG, "\nInitializing 3d system..." ); @@ -586,15 +545,9 @@ int main(int argc, char *argv[]) // If built with editor, option to auto-load a level and quit game // to write certain data. #ifdef EDITOR - { int t; - if ( (t = FindArg( "-autoload" )) ) { - Auto_exit = 1; - strcpy(Auto_file, Args[t+1]); - } - - } - - if (Auto_exit) { + { + if (GameArg.EdiAutoLoad) { + strcpy(Auto_file, GameArg.EdiAutoLoad); strcpy(Players[0].callsign, "dummy"); } else #endif @@ -643,7 +596,7 @@ int main(int argc, char *argv[]) case FMODE_MENU: set_screen_mode(SCREEN_MENU); #ifdef EDITOR - if (Auto_exit) { + if (GameArg.EdiAutoLoad) { strcpy((char *)&Level_names[0], Auto_file); LoadLevel(1, 1); Function_mode = FMODE_EXIT; diff --git a/main/movie.c b/main/movie.c index 1ed088c5d..c4bb2d28b 100644 --- a/main/movie.c +++ b/main/movie.c @@ -135,7 +135,7 @@ int PlayMovie(const char *filename, int must_have) char name[FILENAME_LEN],*p; int c, ret; - if (FindArg("-nomovies")) + if (GameArg.DbgNoMovies) return MOVIE_NOT_PLAYED; strcpy(name,filename); @@ -404,7 +404,7 @@ void DeInitRobotMovie(void) int InitRobotMovie(char *filename) { - if (FindArg("-nomovies")) + if (GameArg.DbgNoMovies) return 0; con_printf(CON_DEBUG, "RoboFile=%s\n", filename); @@ -610,7 +610,7 @@ void init_movies() { int i; - if (FindArg("-nomovies")) + if (GameArg.DbgNoMovies) return; for (i=0;i