diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6a3e03752..a25eac663 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D2X-Rebirth Changelog -------- main/network.c: fix typo causing compiler error on bigendian computers 2d/font.c: make sure a font header only takes up sizeof(grs_font) memory, not sizeof(grs_font) squared +arch/ogl/gr.c, arch/ogl/include/ogl_init.h, arch/ogl/sdlgl.c, include/args.h, main/inferno.c, main/menu.c, main/newdemo.c, misc/args.c: Removed SDL Gammaramp code (obsolete); Improvements on Demo code 20080108 -------- diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index 0289a4b21..446ec3980 100644 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -159,7 +159,7 @@ void ogl_get_verinfo(void) } #endif - con_printf(CON_VERBOSE, "gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i gl_setgammaramp_ok:%i\n", GameArg.DbgGlIntensity4Ok, GameArg.DbgGlLuminance4Alpha4Ok, GameArg.DbgGlRGBA2Ok, GameArg.DbgGlReadPixelsOk, GameArg.DbgGlGetTexLevelParamOk, GameArg.DbgGlSetGammaRampOk); + con_printf(CON_VERBOSE, "gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i\n", GameArg.DbgGlIntensity4Ok, GameArg.DbgGlLuminance4Alpha4Ok, GameArg.DbgGlRGBA2Ok, GameArg.DbgGlReadPixelsOk, GameArg.DbgGlGetTexLevelParamOk); } @@ -323,7 +323,6 @@ int gr_init(int mode) void gr_close() { ogl_brightness_r = ogl_brightness_g = ogl_brightness_b = 0; - ogl_setbrightness_internal(); ogl_close();//platform specific code if (grd_curscreen){ @@ -438,13 +437,7 @@ void gr_palette_step_up(int r, int g, int b) ogl_brightness_g = max(g + gr_palette_gamma, 0); ogl_brightness_b = max(b + gr_palette_gamma, 0); - if (GameArg.DbgGlSetGammaRampOk && - (old_b_r != ogl_brightness_r || - old_b_g != ogl_brightness_g || - old_b_b != ogl_brightness_b)) - ogl_brightness_ok = !ogl_setbrightness_internal(); - - if (!GameArg.DbgGlSetGammaRampOk || !ogl_brightness_ok) + if (!ogl_brightness_ok) { last_r = ogl_brightness_r / 63.0; last_g = ogl_brightness_g / 63.0; diff --git a/arch/ogl/internal.h b/arch/ogl/internal.h index 71d74d5a7..22b057b30 100644 --- a/arch/ogl/internal.h +++ b/arch/ogl/internal.h @@ -16,7 +16,6 @@ void ogl_vivify_texture_list_internal(void); extern int ogl_brightness_ok; extern int ogl_brightness_r, ogl_brightness_g, ogl_brightness_b; -int ogl_setbrightness_internal(void); extern int ogl_fullscreen; void ogl_do_fullscreen_internal(void); diff --git a/arch/ogl/sdlgl.c b/arch/ogl/sdlgl.c index 529eaafa1..11b5be7ba 100644 --- a/arch/ogl/sdlgl.c +++ b/arch/ogl/sdlgl.c @@ -27,26 +27,6 @@ void ogl_do_fullscreen_internal(void){ ogl_init_window(curx,cury); } -static Uint16 gammaramp[512]; - -static void init_gammaramp(void) -{ - int i; - - for (i = 0; i < 256; ++i) - gammaramp[i] = i * 256; - for (i = 256; i < 512; ++i) - gammaramp[i] = 0xffff; -} - -int ogl_setbrightness_internal(void) -{ - return SDL_SetGammaRamp(gammaramp + ogl_brightness_r * 4, - gammaramp + ogl_brightness_g * 4, - gammaramp + ogl_brightness_b * 4 - ); -} - void ogl_swap_buffers_internal(void) { SDL_GL_SwapBuffers(); @@ -107,8 +87,6 @@ void ogl_init(void){ SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,0); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); - - init_gammaramp(); } void ogl_close(void){ diff --git a/include/args.h b/include/args.h index 0603cf8b7..5d02789b1 100644 --- a/include/args.h +++ b/include/args.h @@ -107,7 +107,6 @@ typedef struct Arg int DbgGlRGBA2Ok; int DbgGlReadPixelsOk; int DbgGlGetTexLevelParamOk; - int DbgGlSetGammaRampOk; #else int DbgSdlHWSurface; #endif diff --git a/main/inferno.c b/main/inferno.c index 3e2d409b3..24ba2a5fb 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -240,7 +240,6 @@ void print_commandline_help() printf( " -gl_rgba2_ok %s\n", "Override DbgGlRGBA2Ok - Default: 1"); printf( " -gl_readpixels_ok %s\n", "Override DbgGlReadPixelsOk - Default: 1"); printf( " -gl_gettexlevelparam_ok %s\n", "Override DbgGlGetTexLevelParamOk - Default: 1"); - printf( " -gl_setgammaramp_ok %s\n", "Override DbgGlSetGammaRampOk - Default: 0"); #else printf( " -hwsurface %s\n", "Use HW Surface"); #endif diff --git a/main/menu.c b/main/menu.c index e4a842230..a13f8fad7 100644 --- a/main/menu.c +++ b/main/menu.c @@ -126,7 +126,6 @@ extern int Speedtest_on; void do_sound_menu(); void do_toggles_menu(); -ubyte do_auto_demo = 1; // Flag used to enable auto demo starting in main menu. int Player_default_difficulty; // Last difficulty level chosen by the player int Auto_leveling_on = 1; int Guided_in_big_window = 0; @@ -158,37 +157,37 @@ void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int ci // Don't allow them to hit ESC in the main menu. if (*last_key==KEY_ESC) *last_key = 0; - if ( do_auto_demo ) { - curtime = timer_get_approx_seconds(); - if ( (((keyd_time_when_last_pressed+i2f(25)) < curtime || curtime+i2f(25) < keyd_time_when_last_pressed) && (!Speedtest_on)) || GameArg.SysAutoDemo ) { - int n_demos; - - n_demos = newdemo_count_demos(); + curtime = timer_get_approx_seconds(); + if ( keyd_time_when_last_pressed+i2f(25) < curtime || GameArg.SysAutoDemo ) + { + int n_demos; + n_demos = newdemo_count_demos(); try_again:; - if (((d_rand() % (n_demos+1)) == 0) && !GameArg.SysAutoDemo) - { - #ifndef SHAREWARE + if (((d_rand() % (n_demos+1)) == 0) && !GameArg.SysAutoDemo) + { +#ifndef SHAREWARE #ifdef OGL - Screen_mode = -1; + Screen_mode = -1; #endif - PlayMovie("intro.mve",0); - songs_play_song(SONG_TITLE,1); - *last_key = -3; //exit menu to force redraw even if not going to game mode. -3 tells menu system not to restore - set_screen_mode(SCREEN_MENU); - #endif // end of ifndef shareware - } - else { - WIN(HideCursorW()); - keyd_time_when_last_pressed = curtime; // Reset timer so that disk won't thrash if no demos. - newdemo_start_playback(NULL); // Randomly pick a file - if (Newdemo_state == ND_STATE_PLAYBACK) { - Function_mode = FMODE_GAME; - *last_key = -3; //exit menu to get into game mode. -3 tells menu system not to restore - } - else - goto try_again; //keep trying until we get a demo that works + PlayMovie("intro.mve",0); + songs_play_song(SONG_TITLE,1); + *last_key = -3; //exit menu to force redraw even if not going to game mode. -3 tells menu system not to restore + set_screen_mode(SCREEN_MENU); +#endif // end of ifndef shareware + } + else + { + WIN(HideCursorW()); + if (curtime < 0) curtime = 0; + keyd_time_when_last_pressed = curtime; // Reset timer so that disk won't thrash if no demos. + newdemo_start_playback(NULL); // Randomly pick a file + if (Newdemo_state == ND_STATE_PLAYBACK) { + Function_mode = FMODE_GAME; + *last_key = -3; //exit menu to get into game mode. -3 tells menu system not to restore } + else + goto try_again; //keep trying until we get a demo that works } } } diff --git a/main/newdemo.c b/main/newdemo.c index 6a04c6034..e235f06a4 100644 --- a/main/newdemo.c +++ b/main/newdemo.c @@ -206,7 +206,6 @@ fix nd_playback_total; fix nd_recorded_total; fix nd_recorded_time; sbyte playback_style; -sbyte First_time_playback=1; fix JasonPlaybackTotal=0; @@ -1449,8 +1448,8 @@ void newdemo_set_new_level(int level_num) int newdemo_read_demo_start(int rnd_demo) { - sbyte i, version, game_type, laser_level; - sbyte c, energy, shield; + sbyte i, version, game_type, laser_level, c; + ubyte energy, shield; char text[128], current_mission[9]; Rear_view=0; @@ -1564,8 +1563,8 @@ int newdemo_read_demo_start(int rnd_demo) nd_recorded_total = 0; nd_playback_total = 0; - nd_read_byte(&energy); - nd_read_byte(&shield); + nd_read_byte((sbyte*)&energy); + nd_read_byte((sbyte*)&shield); nd_read_int((int *)&(Players[Player_num].flags)); if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) { @@ -2360,13 +2359,14 @@ int newdemo_read_frame_information() } case ND_EVENT_CLOAKING_WALL: { - sbyte back_wall_num,front_wall_num,type,state,cloak_value; + sbyte type,state,cloak_value; + ubyte back_wall_num,front_wall_num; short l0,l1,l2,l3; segment *segp; int sidenum; - nd_read_byte(&front_wall_num); - nd_read_byte(&back_wall_num); + nd_read_byte((sbyte*)&front_wall_num); + nd_read_byte((sbyte*)&back_wall_num); nd_read_byte(&type); nd_read_byte(&state); nd_read_byte(&cloak_value); @@ -2690,7 +2690,7 @@ void interpolate_frame(fix d_play, fix d_recorded) // Some of this code taken from ai_turn_towards_vector // Don't do the interpolation on certain render types which don't use an orientation matrix - if (!((render_type == RT_LASER) || (render_type == RT_FIREBALL) || (render_type == RT_POWERUP))) { + if (!((render_type == RT_LASER) || (render_type == RT_FIREBALL) || (render_type == RT_POWERUP) || (render_type == RT_WEAPON_VCLIP))) { vms_vector fvec1, fvec2, rvec1, rvec2; fix mag1; @@ -3207,8 +3207,8 @@ void newdemo_start_playback(char * filename) #ifdef NETWORK change_playernum_to(0); #endif - First_time_playback=1; JasonPlaybackTotal=0; + Newdemo_flying_guided=0; if (filename) strcat(filename2, filename); @@ -3242,6 +3242,10 @@ void newdemo_start_playback(char * filename) if (NumFiles > RandFileNum) return; + + // if in random mode, PhysFS may look for all possible files, so check if filename actually points to be a demo file... + if (strncasecmp(".dem",&filename2[strlen(filename2)-4],4)) + return; } infile = PHYSFSX_openReadBuffered(filename2); @@ -3289,6 +3293,7 @@ void newdemo_stop_playback() { PHYSFS_close(infile); Newdemo_state = ND_STATE_NORMAL; + Newdemo_flying_guided=0; #ifdef NETWORK change_playernum_to(0); //this is reality #endif @@ -3407,12 +3412,11 @@ void DoJasonInterpolate (fix recorded_time) JasonPlaybackTotal+=FrameTime; - if (!First_time_playback) + if (recorded_time > 0) { - // get the difference between the recorded time and the playback time the_delay=(recorded_time - FrameTime); - //mprintf ((0,"The delay=%d\n", f2i(the_delay))); - if (!the_delay >= f0_0) + + if (the_delay < f0_0) { while (JasonPlaybackTotal > nd_recorded_total) if (newdemo_read_frame_information() == -1) @@ -3422,7 +3426,6 @@ void DoJasonInterpolate (fix recorded_time) } } } - First_time_playback=0; } #ifdef MACINTOSH diff --git a/main/newmenu.c b/main/newmenu.c index b3a0d3fb9..2bec00297 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -1953,7 +1953,7 @@ int newmenu_get_filename(char *title, char *type, char *filename, int allow_abor w_x=w_y=w_w=w_h=title_height=0; box_x=box_y=box_w=box_h=0; - filenames = d_malloc( MAX_FILES * 14 ); + filenames = d_malloc( MAX_FILES * 140 ); if (filenames==NULL) return 0; citem = 0; diff --git a/misc/args.c b/misc/args.c index 75758414a..a163b4234 100644 --- a/misc/args.c +++ b/misc/args.c @@ -269,7 +269,6 @@ void ReadCmdArgs(void) GameArg.DbgGlRGBA2Ok = get_int_arg("-gl_rgba2_ok", 1); GameArg.DbgGlReadPixelsOk = get_int_arg("-gl_readpixels_ok", 1); GameArg.DbgGlGetTexLevelParamOk = get_int_arg("-gl_gettexlevelparam_ok", 1); - GameArg.DbgGlSetGammaRampOk = get_int_arg("-gl_setgammaramp_ok", 0); #else GameArg.DbgSdlHWSurface = FindArg("-hwsurface"); #endif