diff --git a/Makefile.am b/Makefile.am index adfb0f342c..332f3a5271 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,6 +41,8 @@ EXTRA_PROGRAMS = cfilearchiver cfileextractor ## Begin utilitites ## +CPPSOURCES=$(wildcard code/*/*.cpp code/*/*.h) + # cfilearchiver -- to create VPs cfilearchiver_SOURCES = \ code/cfilearchiver/cfilearchiver.cpp @@ -56,6 +58,11 @@ tools: cfilearchiver cfileextractor clean-tools: -test -z "$(EXTRA_PROGRAMS)" || rm -f $(EXTRA_PROGRAMS) +## cppcheck : check for many code issues +cppcheck: ${CPPSOURCES} + cppcheck ${CPPSOURCES} --enable=all --platform=unix64 \ + --std=c99 --inline-suppr --quiet + ## ## End utilitites ## diff --git a/code/Makefile.am b/code/Makefile.am index 90cf2d7eb5..786a749739 100644 --- a/code/Makefile.am +++ b/code/Makefile.am @@ -215,7 +215,6 @@ FS2_SOURCES = \ ai/aigoals.cpp \ ai/aigoals.h \ ai/aiinternal.h \ - ai/ailocal.h \ ai/aiturret.cpp \ ai/ai_profiles.cpp \ ai/ai_profiles.h \ @@ -480,14 +479,10 @@ FS2_SOURCES = \ missionui/missionloopbrief.h \ missionui/missionpause.cpp \ missionui/missionpause.h \ - missionui/missionrecommend.cpp \ - missionui/missionrecommend.h \ missionui/missionscreencommon.cpp \ missionui/missionscreencommon.h \ missionui/missionshipchoice.cpp \ missionui/missionshipchoice.h \ - missionui/missionstats.cpp \ - missionui/missionstats.h \ missionui/missionweaponchoice.cpp \ missionui/missionweaponchoice.h \ missionui/redalert.cpp \ diff --git a/code/ai/ai.h b/code/ai/ai.h index 6eab716bd4..0a8759c5c1 100644 --- a/code/ai/ai.h +++ b/code/ai/ai.h @@ -622,7 +622,7 @@ extern void init_ai_system(void); extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp); extern void ai_evade_object(object *evader, object *evaded); extern void ai_ignore_object(object *ignorer, object *ignored, int ignore_new); -extern void ai_ignore_wing(object *ignorer, int wingnum, int priority); +extern void ai_ignore_wing(object *ignorer, int wingnum); extern void ai_dock_with_object(object *docker, int docker_index, object *dockee, int dockee_index, int dock_type); extern void ai_stay_still(object *still_objp, vec3d *view_pos); extern void ai_do_default_behavior(object *obj); @@ -726,8 +726,7 @@ void process_subobjects(int objnum); //SUSHI: Setting ai_info stuff from both ai class and ai profile void init_aip_from_class_and_profile(ai_info *aip, ai_class *aicp, ai_profile_t *profile); -//SUSHI: Updating AI aim -void ai_update_aim(ai_info *aip, object* En_Objp); +void ai_update_aim(ai_info *aip); //SUSHI: Random evasive sidethrust void do_random_sidethrust(ai_info *aip, ship_info *sip); diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index 34ac6f7b48..94472c2d67 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -2485,7 +2485,7 @@ void ai_ignore_object(object *ignorer, object *ignored, int ignore_new) /** * Ignore some object without changing mode. */ -void ai_ignore_wing(object *ignorer, int wingnum, int priority) +void ai_ignore_wing(object *ignorer, int wingnum) { ai_info *aip; @@ -3411,7 +3411,7 @@ float compute_collision_time(vec3d *targpos, vec3d *targvel, vec3d *attackpos, f // This function doesn't account for the fact that by the time the player // (or his laser) gets to the current enemy position, the enemy will have moved. // This is dealt with in polish_predicted_enemy_pos. -float compute_time_to_enemy(float dist_to_enemy, object *pobjp, object *eobjp) +float compute_time_to_enemy(float dist_to_enemy, object *pobjp) { float time_to_enemy; float pl_speed = pobjp->phys_info.speed; @@ -3493,8 +3493,12 @@ void ai_set_positions(object *pl_objp, object *en_objp, ai_info *aip, vec3d *pla } -// -------------------------------------------------------------------------- -void ai_update_aim(ai_info *aip, object* En_Objp) +/** + * Updates AI aim automatically based on targetted enemy. + * + * @param aip Pointer to AI info + */ +void ai_update_aim(ai_info *aip) { if (Missiontime >= aip->next_aim_pos_time) { @@ -7614,7 +7618,7 @@ void update_aspect_lock_information(ai_info *aip, vec3d *vec_to_enemy, float dis wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]]; - if (num_weapon_types && (wip->wi_flags & WIF_LOCKED_HOMING)) { + if (num_weapon_types && (wip->wi_flags & WIF_LOCKED_HOMING) && !(shipp->flags2 & SF2_NO_SECONDARY_LOCKON)) { if (dist_to_enemy > 300.0f - MIN(enemy_radius, 100.0f)) aip->ai_flags |= AIF_SEEK_LOCK; else @@ -8243,11 +8247,11 @@ void ai_chase() ai_set_positions(Pl_objp, En_objp, aip, &player_pos, &enemy_pos); dist_to_enemy = vm_vec_dist_quick(&player_pos, &enemy_pos); - time_to_enemy = compute_time_to_enemy(dist_to_enemy, Pl_objp, En_objp); + time_to_enemy = compute_time_to_enemy(dist_to_enemy, Pl_objp); vm_vec_sub(&real_vec_to_enemy, &enemy_pos, &player_pos); //Enemy position for the purpose of aiming is already calculated differently, do it explicitly here - ai_update_aim(aip, En_objp); + ai_update_aim(aip); vm_vec_normalize(&real_vec_to_enemy); diff --git a/code/ai/aigoals.cpp b/code/ai/aigoals.cpp index d802523d57..2151bce042 100644 --- a/code/ai/aigoals.cpp +++ b/code/ai/aigoals.cpp @@ -1883,9 +1883,8 @@ int ai_goal_priority_compare(const void *a, const void *b) // Prioritize goal list. // First sort on priority. // Then sort on time for goals of equivalent priority. -// objnum The object number to act upon. Redundant with *aip. // *aip The AI info to act upon. Goals are stored at aip->goals -void prioritize_goals(int objnum, ai_info *aip) +void prioritize_goals(ai_info *aip) { // First sort based on priority field. insertion_sort(aip->goals, MAX_AI_GOALS, sizeof(ai_goal), ai_goal_priority_compare); @@ -2001,7 +2000,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) validate_mission_goals(objnum, aip); // Sort the goal array by priority and other factors. - prioritize_goals(objnum, aip); + prioritize_goals(aip); // Make sure there's a goal to pursue, else return. if (aip->goals[0].signature == -1) { diff --git a/code/ai/ailocal.h b/code/ai/ailocal.h deleted file mode 100644 index 2137b38b5d..0000000000 --- a/code/ai/ailocal.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on the - * source. - * -*/ - -#ifndef _AILOCAL_H -#define _AILOCAL_H - -// -- Don't put anything in here -- -// Put it in ai.h! - -#endif diff --git a/code/asteroid/asteroid.cpp b/code/asteroid/asteroid.cpp index aa88eb753d..55124c95f7 100644 --- a/code/asteroid/asteroid.cpp +++ b/code/asteroid/asteroid.cpp @@ -898,7 +898,7 @@ void lerp(float *goal, float f1, float f2, float scale) *goal = (f2 - f1) * scale + f1; } -void asteroid_process_pre( object *objp, float frame_time) +void asteroid_process_pre( object *objp ) { if (Asteroids_enabled) { // Make vel chase desired_vel @@ -1739,7 +1739,7 @@ void asteroid_verify_collide_objnum(asteroid *asp) } } -void asteroid_process_post(object * obj, float frame_time) +void asteroid_process_post(object * obj) { if (Asteroids_enabled) { int num; diff --git a/code/asteroid/asteroid.h b/code/asteroid/asteroid.h index 0a58ef9515..5fc2db16e4 100644 --- a/code/asteroid/asteroid.h +++ b/code/asteroid/asteroid.h @@ -154,8 +154,8 @@ void asteroid_create_all(); void asteroid_render_DEPRECATED( object *asteroid_objp ); void asteroid_render(object * obj, draw_list *scene); void asteroid_delete( object *asteroid_objp ); -void asteroid_process_pre( object *asteroid_objp, float frame_time); -void asteroid_process_post( object *asteroid_objp, float frame_time); +void asteroid_process_pre( object *asteroid_objp ); +void asteroid_process_post( object *asteroid_objp); int asteroid_check_collision( object *asteroid_objp, object * other_obj, vec3d * hitpos, collision_info_struct *asteroid_hit_info=NULL ); void asteroid_hit( object *asteroid_objp, object *other_objp, vec3d *hitpos, float damage ); int asteroid_count(); diff --git a/code/bmpman/bm_internal.h b/code/bmpman/bm_internal.h index 29e8e57323..995c073510 100644 --- a/code/bmpman/bm_internal.h +++ b/code/bmpman/bm_internal.h @@ -63,7 +63,7 @@ struct bitmap_entry { int dir_type; //!< which directory this was loaded from (to skip other locations with same name) // compressed bitmap stuff (.dds) - RT please take a look at this and tell me if we really need it - int mem_taken; //!< How much memory does this bitmap use? - UnknownPlayer + size_t mem_taken; //!< How much memory does this bitmap use? - UnknownPlayer int num_mipmaps; //!< number of mipmap levels, we need to read all of them // Stuff to keep track of usage diff --git a/code/bmpman/bmpman.cpp b/code/bmpman/bmpman.cpp index f9e71a9e2d..d862ffe193 100644 --- a/code/bmpman/bmpman.cpp +++ b/code/bmpman/bmpman.cpp @@ -415,7 +415,7 @@ int bm_create(int bpp, int w, int h, void *data, int flags) { bm_bitmaps[n].load_count++; - bm_update_memory_used(n, bm_bitmaps[n].mem_taken); + bm_update_memory_used(n, (int)bm_bitmaps[n].mem_taken); gr_bm_create(n); @@ -648,9 +648,9 @@ void bm_get_frame_usage(int *ntotal, int *nnew) { for (i = 0; i= 0); - Assert(num == bm_bitmaps[n].handle); + Assert(handle == bm_bitmaps[n].handle); return bm_bitmaps[n].mem_taken; } @@ -790,7 +790,7 @@ BM_TYPE bm_get_type(int handle) { return bm_bitmaps[bitmapnum].type; } -int bm_has_alpha_channel(int handle) { +bool bm_has_alpha_channel(int handle) { int n = handle % MAX_BITMAPS; Assert(n >= 0); @@ -1002,7 +1002,7 @@ int bm_load(const char *real_filename) { bm_bitmaps[free_slot].bm.data = 0; bm_bitmaps[free_slot].bm.palette = NULL; bm_bitmaps[free_slot].num_mipmaps = mm_lvl; - bm_bitmaps[free_slot].mem_taken = bm_size; + bm_bitmaps[free_slot].mem_taken = (size_t)bm_size; bm_bitmaps[free_slot].dir_type = CF_TYPE_ANY; bm_bitmaps[free_slot].palette_checksum = 0; bm_bitmaps[free_slot].handle = handle; @@ -1317,7 +1317,7 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke bm_bitmaps[n + i].handle = first_handle*MAX_BITMAPS + n + i; bm_bitmaps[n + i].last_used = -1; bm_bitmaps[n + i].num_mipmaps = mm_lvl; - bm_bitmaps[n + i].mem_taken = img_size; + bm_bitmaps[n + i].mem_taken = (size_t)img_size; bm_bitmaps[n + i].dir_type = dir_type; bm_bitmaps[n + i].load_count++; @@ -1559,7 +1559,7 @@ void bm_lock_ani(int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bm = &bm_bitmaps[first_frame].bm; size = bm->w * bm->h * (bpp >> 3); - be->mem_taken = size; + be->mem_taken = (size_t)size; Assert(size > 0); @@ -1677,19 +1677,19 @@ void bm_lock_dds(int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte #if BYTE_ORDER == BIG_ENDIAN // same as with TGA, we need to byte swap 16 & 32-bit, uncompressed, DDS images if ((be->comp_type == BM_TYPE_DDS) || (be->comp_type == BM_TYPE_CUBEMAP_DDS)) { - unsigned int i = 0; + size_t i = 0; if (dds_bpp == 32) { unsigned int *swap_tmp; - for (i = 0; i < (unsigned int)be->mem_taken; i += 4) { + for (i = 0; i < be->mem_taken; i += 4) { swap_tmp = (unsigned int *)(data + i); *swap_tmp = INTEL_INT(*swap_tmp); } } else if (dds_bpp == 16) { unsigned short *swap_tmp; - for (i = 0; i < (unsigned int)be->mem_taken; i += 2) { + for (i = 0; i < be->mem_taken; i += 2) { swap_tmp = (unsigned short *)(data + i); *swap_tmp = INTEL_SHORT(*swap_tmp); } @@ -1994,7 +1994,7 @@ int bm_make_render_target(int width, int height, int flags) { bm_bitmaps[n].bm.data = 0; bm_bitmaps[n].bm.palette = NULL; bm_bitmaps[n].num_mipmaps = mm_lvl; - bm_bitmaps[n].mem_taken = size; + bm_bitmaps[n].mem_taken = (size_t)size; bm_bitmaps[n].dir_type = CF_TYPE_ANY; bm_bitmaps[n].palette_checksum = 0; @@ -2220,21 +2220,23 @@ void bm_page_in_xparent_texture(int bitmapnum, int nframes) { } } -int bm_page_out(int bitmap_id) { - int n = bitmap_id % MAX_BITMAPS; +bool bm_page_out(int handle) { + int n = handle % MAX_BITMAPS; - Assert(n >= 0 && n < MAX_BITMAPS); + Assert(n >= 0); + Assert(handle == bm_bitmaps[n].handle); // in case it's already been released if (bm_bitmaps[n].type == BM_TYPE_NONE) return 0; - Assert(bm_bitmaps[n].handle == bitmap_id); // INVALID BITMAP HANDLE - - // it's possible to hit < 0 here when model_page_out_textures() is called from - // anywhere other than in a mission + // it's possible to hit < 0 here when model_page_out_textures() is + // called from anywhere other than in a mission if (bm_bitmaps[n].preload_count > 0) { - nprintf(("BmpMan", "PAGE-OUT: %s - preload_count remaining: %d\n", bm_bitmaps[n].filename, bm_bitmaps[n].preload_count)); + nprintf(("BmpMan", + "PAGE-OUT: %s - preload_count remaining: %d\n", + bm_bitmaps[n].filename, + bm_bitmaps[n].preload_count)); // lets decrease it for next time around bm_bitmaps[n].preload_count--; @@ -2242,7 +2244,7 @@ int bm_page_out(int bitmap_id) { return 0; } - return (bm_unload(bitmap_id) == 1); + return (bm_unload(handle) == 1); } void bm_print_bitmaps() { @@ -2493,6 +2495,12 @@ int bm_set_render_target(int handle, int face) { gr_screen.save_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed; gr_screen.save_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed; + + gr_screen.save_center_w = gr_screen.center_w; + gr_screen.save_center_h = gr_screen.center_h; + + gr_screen.save_center_offset_x = gr_screen.center_offset_x; + gr_screen.save_center_offset_y = gr_screen.center_offset_y; } if (n < 0) { @@ -2504,6 +2512,12 @@ int bm_set_render_target(int handle, int face) { gr_screen.max_w_unscaled_zoomed = gr_screen.save_max_w_unscaled_zoomed; gr_screen.max_h_unscaled_zoomed = gr_screen.save_max_h_unscaled_zoomed; + + gr_screen.center_w = gr_screen.save_center_w; + gr_screen.center_h = gr_screen.save_center_h; + + gr_screen.center_offset_x = gr_screen.save_center_offset_x; + gr_screen.center_offset_y = gr_screen.save_center_offset_y; } else { gr_screen.max_w = bm_bitmaps[n].bm.w; gr_screen.max_h = bm_bitmaps[n].bm.h; @@ -2513,6 +2527,12 @@ int bm_set_render_target(int handle, int face) { gr_screen.max_w_unscaled_zoomed = bm_bitmaps[n].bm.w; gr_screen.max_h_unscaled_zoomed = bm_bitmaps[n].bm.h; + + gr_screen.center_w = bm_bitmaps[n].bm.w; + gr_screen.center_h = bm_bitmaps[n].bm.h; + + gr_screen.center_offset_x = 0; + gr_screen.center_offset_y = 0; } gr_screen.rendering_to_face = face; diff --git a/code/bmpman/bmpman.h b/code/bmpman/bmpman.h index a79180510a..b3d3489d79 100644 --- a/code/bmpman/bmpman.h +++ b/code/bmpman/bmpman.h @@ -502,10 +502,8 @@ void bm_page_in_aabitmap(int bitmapnum, int num_frames = 1); * @returns 0 If the bitmap had already been released, or * @returns 0 If the handle is invalid, or * @returns 1 If successful - * - * @todo The return type should be a bool */ -int bm_page_out(int handle); +bool bm_page_out(int handle); /** * @brief Sets BMPMAN's memory mode @@ -612,10 +610,8 @@ int bm_get_tcache_type(int handle); /** * @brief Gets the size, in bytes, taken up by the bitmap indexed by handle - * - * @todo retval should be a size_t */ -int bm_get_size(int handle); +size_t bm_get_size(int handle); /** * @brief Gets the number of mipmaps of the indexed texture @@ -626,10 +622,8 @@ int bm_get_num_mipmaps(int handle); * @brief Checks to see if the indexed bitmap has an alpha channel * * @note Currently just checks if the bitmap is 32bpp and is not a .PCX - * - * @todo retval should be a bool */ -int bm_has_alpha_channel(int handle); +bool bm_has_alpha_channel(int handle); /** * @brief (DEBUG) Prints all loaded bitmaps to an outwindow diff --git a/code/camera/camera.cpp b/code/camera/camera.cpp index bc3087b6d1..b019ce7da9 100644 --- a/code/camera/camera.cpp +++ b/code/camera/camera.cpp @@ -653,20 +653,20 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, const char* in_text, const char* //Center it? if(center_x) - image_pos.x = (gr_screen.max_w - tw)/2; + image_pos.x = (gr_screen.center_w - tw)/2 + gr_screen.center_offset_x; if(center_y) - image_pos.y = (gr_screen.max_h - th)/2; + image_pos.y = (gr_screen.center_h - th)/2 + gr_screen.center_offset_y; } if(in_x_pos < 0 && !center_x) - image_pos.x += gr_screen.max_w + in_x_pos; + image_pos.x += gr_screen.center_offset_x + gr_screen.center_w + in_x_pos; else if(!center_x) - image_pos.x += in_x_pos; + image_pos.x += gr_screen.center_offset_x + in_x_pos; if(in_y_pos < 0 && !center_y) - image_pos.y += gr_screen.max_h + in_y_pos; + image_pos.y += gr_screen.center_offset_y + gr_screen.center_h + in_y_pos; else if(!center_y) - image_pos.y += in_y_pos; + image_pos.y += gr_screen.center_offset_y + in_y_pos; image_pos.w = in_width; image_pos.h = in_height; diff --git a/code/cmdline/cmdline.cpp b/code/cmdline/cmdline.cpp index 7bf71538e3..095c695bdf 100644 --- a/code/cmdline/cmdline.cpp +++ b/code/cmdline/cmdline.cpp @@ -172,6 +172,7 @@ Flag exe_params[] = { "-snd_preload", "Preload mission game sounds", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-snd_preload", }, { "-nosound", "Disable all sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nosound", }, { "-nomusic", "Disable music", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomusic", }, + { "-no_enhanced_sound", "Disable enhanced sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_enhanced_sound", }, { "-standalone", "Run as standalone server", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-standalone", }, { "-startgame", "Skip mainhall and start hosting", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-startgame", }, @@ -243,6 +244,7 @@ cmdline_parm allowbelow_arg("-allowbelow", "Ranks below this can join multi", AT cmdline_parm standalone_arg("-standalone", NULL, AT_NONE); cmdline_parm nosound_arg("-nosound", NULL, AT_NONE); // Cmdline_freespace_no_sound cmdline_parm nomusic_arg("-nomusic", NULL, AT_NONE); // Cmdline_freespace_no_music +cmdline_parm noenhancedsound_arg("-no_enhanced_sound", NULL, AT_NONE); // Cmdline_no_enhanced_sound cmdline_parm startgame_arg("-startgame", NULL, AT_NONE); // Cmdline_start_netgame cmdline_parm gameclosed_arg("-closed", NULL, AT_NONE); // Cmdline_closed_game cmdline_parm gamerestricted_arg("-restricted", NULL, AT_NONE); // Cmdline_restricted_game @@ -385,6 +387,7 @@ cmdline_parm voice_recognition_arg("-voicer", NULL, AT_NONE); // Cmdline_voice_r int Cmdline_query_speech = 0; int Cmdline_snd_preload = 0; // preload game sounds during mission load int Cmdline_voice_recognition = 0; +int Cmdline_no_enhanced_sound = 0; // MOD related cmdline_parm mod_arg("-mod", "List of folders to overwrite/add-to the default data", AT_STRING, true); // Cmdline_mod -- DTP modsupport @@ -460,6 +463,7 @@ cmdline_parm save_render_targets_arg("-save_render_target", NULL, AT_NONE); // C cmdline_parm window_arg("-window", NULL, AT_NONE); // Cmdline_window cmdline_parm fullscreen_window_arg("-fullscreen_window", "Fullscreen/borderless window (Windows only)", AT_NONE); cmdline_parm res_arg("-res", "Resolution, formatted like 1600x900", AT_STRING); +cmdline_parm center_res_arg("-center_res", "Resolution of center monitor, formatted like 1600x900", AT_STRING); cmdline_parm verify_vps_arg("-verify_vps", NULL, AT_NONE); // Cmdline_verify_vps -- spew VP crcs to vp_crcs.txt cmdline_parm parse_cmdline_only(PARSE_COMMAND_LINE_STRING, "Ignore any cmdline_fso.cfg files", AT_NONE); cmdline_parm reparse_mainhall_arg("-reparse_mainhall", NULL, AT_NONE); //Cmdline_reparse_mainhall @@ -483,6 +487,7 @@ int Cmdline_save_render_targets = 0; int Cmdline_window = 0; int Cmdline_fullscreen_window = 0; char *Cmdline_res = 0; +char *Cmdline_center_res = 0; int Cmdline_verify_vps = 0; int Cmdline_reparse_mainhall = 0; bool Cmdline_frame_profile = false; @@ -1218,6 +1223,11 @@ bool SetCmdlineParams() Cmdline_freespace_no_music = 1; } + // Disable enhanced sound + if (noenhancedsound_arg.found()) { + Cmdline_no_enhanced_sound = 1; + } + // should we start a network game if ( startgame_arg.found() ) { Cmdline_use_last_pilot = 1; @@ -1313,6 +1323,9 @@ bool SetCmdlineParams() if(res_arg.found()){ Cmdline_res = res_arg.str(); } + if(center_res_arg.found()){ + Cmdline_center_res = center_res_arg.str(); + } if(almission_arg.found()){//DTP for autoload mission // developer oritentated Cmdline_almission = almission_arg.str(); Cmdline_use_last_pilot = 1; diff --git a/code/cmdline/cmdline.h b/code/cmdline/cmdline.h index 6401f00186..4dd1c67828 100644 --- a/code/cmdline/cmdline.h +++ b/code/cmdline/cmdline.h @@ -47,6 +47,7 @@ extern int Cmdline_use_last_pilot; extern int Cmdline_window; extern int Cmdline_fullscreen_window; extern char *Cmdline_res; +extern char *Cmdline_center_res; // FSO OPTIONS ------------------------------------------------- @@ -104,6 +105,7 @@ extern int Cmdline_stretch_menu; extern int Cmdline_query_speech; extern int Cmdline_snd_preload; extern int Cmdline_voice_recognition; +extern int Cmdline_no_enhanced_sound; // MOD related extern char *Cmdline_mod; // DTP for mod support diff --git a/code/controlconfig/controlsconfig.cpp b/code/controlconfig/controlsconfig.cpp index b8a84a9cf2..425928de44 100644 --- a/code/controlconfig/controlsconfig.cpp +++ b/code/controlconfig/controlsconfig.cpp @@ -2204,7 +2204,7 @@ void control_check_indicate() #ifndef NDEBUG if (Show_controls_info) { gr_set_color_fast(&HUD_color_debug); - gr_printf_no_resize(gr_screen.max_w - 154, 5, NOX("Ctrls checked: %d"), Control_check_count); + gr_printf_no_resize(gr_screen.center_offset_x + gr_screen.center_w - 154, gr_screen.center_offset_y + 5, NOX("Ctrls checked: %d"), Control_check_count); } #endif diff --git a/code/cutscene/mveplayer.cpp b/code/cutscene/mveplayer.cpp index 54e06ca93d..5fdd1be3c5 100644 --- a/code/cutscene/mveplayer.cpp +++ b/code/cutscene/mveplayer.cpp @@ -460,13 +460,13 @@ int mve_video_createbuf(ubyte minor, ubyte *data) if (gr_screen.mode == GR_OPENGL) { GLfloat scale_by = 1.0f; - float screen_ratio = (float)gr_screen.max_w / (float)gr_screen.max_h; + float screen_ratio = (float)gr_screen.center_w / (float)gr_screen.center_h; float movie_ratio = (float)g_width / (float)g_height; if (screen_ratio > movie_ratio) { - scale_by = (float)gr_screen.max_h / (float)g_height; + scale_by = (float)gr_screen.center_h / (float)g_height; } else { - scale_by = (float)gr_screen.max_w / (float)g_width; + scale_by = (float)gr_screen.center_w / (float)g_width; } // don't bother setting anything if we aren't going to need it @@ -480,12 +480,12 @@ int mve_video_createbuf(ubyte minor, ubyte *data) } if (mve_scale_video) { - g_screenX = ((ceil((gr_screen.max_w / scale_by) - 0.5f) - g_width) / 2); - g_screenY = ((ceil((gr_screen.max_h / scale_by) - 0.5f) - g_height) / 2); + g_screenX = ((ceil((gr_screen.center_w / scale_by) - 0.5f) - g_width) / 2) + ceil((gr_screen.center_offset_x / scale_by) - 0.5f); + g_screenY = ((ceil((gr_screen.center_h / scale_by) - 0.5f) - g_height) / 2) + ceil((gr_screen.center_offset_y / scale_by) - 0.5f); } else { // centers on 1024x768, fills on 640x480 - g_screenX = ((float)(gr_screen.max_w - g_width) / 2.0f); - g_screenY = ((float)(gr_screen.max_h - g_height) / 2.0f); + g_screenX = ((float)(gr_screen.center_w - g_width) / 2.0f) + gr_screen.center_offset_x; + g_screenY = ((float)(gr_screen.center_h - g_height) / 2.0f) + gr_screen.center_offset_y; } // set additional values for screen width/height and UV coords diff --git a/code/cutscene/oggplayer.cpp b/code/cutscene/oggplayer.cpp index ee1875ca45..2eadbb0304 100644 --- a/code/cutscene/oggplayer.cpp +++ b/code/cutscene/oggplayer.cpp @@ -435,13 +435,13 @@ static void OGG_video_init(theora_info *tinfo) // NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_LUMINANCE8, 1024, 1024, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL); } - float screen_ratio = (float)gr_screen.max_w / (float)gr_screen.max_h; + float screen_ratio = (float)gr_screen.center_w / (float)gr_screen.center_h; float movie_ratio = (float)g_screenWidth / (float)g_screenHeight; if (screen_ratio > movie_ratio) - scale_by = (float)gr_screen.max_h / (float)g_screenHeight; + scale_by = (float)gr_screen.center_h / (float)g_screenHeight; else - scale_by = (float)gr_screen.max_w / (float)g_screenWidth; + scale_by = (float)gr_screen.center_w / (float)g_screenWidth; // don't bother setting anything if we aren't going to need it if (!Cmdline_noscalevid && (scale_by != 1.0f)) { @@ -470,12 +470,12 @@ static void OGG_video_init(theora_info *tinfo) if (scale_video) { - g_screenX = ((fl2i(gr_screen.max_w / scale_by + 0.5f) - g_screenWidth) / 2); - g_screenY = ((fl2i(gr_screen.max_h / scale_by + 0.5f) - g_screenHeight) / 2); + g_screenX = ((fl2i(gr_screen.center_w / scale_by + 0.5f) - g_screenWidth) / 2) + fl2i(gr_screen.center_offset_x / scale_by + 0.5f); + g_screenY = ((fl2i(gr_screen.center_h / scale_by + 0.5f) - g_screenHeight) / 2) + fl2i(gr_screen.center_offset_y / scale_by + 0.5f); } else { // centers on 1024x768, fills on 640x480 - g_screenX = ((gr_screen.max_w - g_screenWidth) / 2); - g_screenY = ((gr_screen.max_h - g_screenHeight) / 2); + g_screenX = ((gr_screen.center_w - g_screenWidth) / 2) + gr_screen.center_offset_x; + g_screenY = ((gr_screen.center_h - g_screenHeight) / 2) + gr_screen.center_offset_y; } // set additional values for screen width/height and UV coords diff --git a/code/debugconsole/console.cpp b/code/debugconsole/console.cpp index 0fe9444345..dbb2fdd6ba 100644 --- a/code/debugconsole/console.cpp +++ b/code/debugconsole/console.cpp @@ -189,7 +189,7 @@ void dc_draw(bool show_prompt = FALSE) gr_clear(); gr_set_font(dc_font); gr_set_color_fast( &Color_bright ); - gr_string( 0x8000, 3, dc_title.c_str(), GR_RESIZE_NONE ); + gr_string( 0x8000, gr_screen.center_offset_y + 3, dc_title.c_str(), GR_RESIZE_NONE ); gr_set_color_fast( &Color_normal ); @@ -209,7 +209,7 @@ void dc_draw_cursor( SCP_string &cmd_string, int x, int y ) w %= (DCOLS * Current_font->w); //gr_string( w, debug_y*16, "_" ); - gr_rect((x + (w + 1)), (y + (h + 1)), 2, Current_font->h, GR_RESIZE_NONE); + gr_rect(gr_screen.center_offset_x + (x + (w + 1)), gr_screen.center_offset_y + (y + (h + 1)), 2, Current_font->h, GR_RESIZE_NONE); } } @@ -245,7 +245,7 @@ void dc_draw_window(bool show_prompt) // Draw the buffer strings for (i = 0; i < buffer_lines; ++i) { if ((i + dc_scroll_y) < dc_buffer.size()) { - gr_string(0, ((i * row_height) + row_height), dc_buffer[i + dc_scroll_y].substr(dc_scroll_x).c_str(), GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x, gr_screen.center_offset_y + ((i * row_height) + row_height), dc_buffer[i + dc_scroll_y].substr(dc_scroll_x).c_str(), GR_RESIZE_NONE); } } @@ -263,7 +263,7 @@ void dc_draw_window(bool show_prompt) ++j; } } - gr_string(0, ((i * row_height) + row_height), out_str.c_str(), GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x, gr_screen.center_offset_y + ((i * row_height) + row_height), out_str.c_str(), GR_RESIZE_NONE); dc_draw_cursor(out_str, 0, ((i * row_height))); gr_set_color_fast(&Color_normal); @@ -284,8 +284,8 @@ void dc_init(void) col_width = Current_font->w; // Col/Character width, in pixels dc_scroll_x = 0; dc_scroll_y = 0; - DCOLS = (gr_screen.max_w / col_width) - 1; // Subtract as needed. Windowed mode has some quirks with the resolution - DROWS = (gr_screen.max_h / row_height) - 2; + DCOLS = (gr_screen.center_w / col_width) - 1; // Subtract as needed. Windowed mode has some quirks with the resolution + DROWS = (gr_screen.center_h / row_height) - 2; DBCOLS = DCOLS; DBROWS = 2 * DROWS; @@ -391,7 +391,7 @@ void dc_putc(char c) temp_str.push_back(c); gr_get_string_size(&w, NULL, temp_str.c_str()); - if ((temp_str.size() >= DBCOLS) || (w > gr_screen.max_w)) { + if ((temp_str.size() >= DBCOLS) || (w > gr_screen.center_w)) { c = '\n'; } else { @@ -415,7 +415,7 @@ void dc_putc(char c) temp_str.append(i, ' '); gr_get_string_size(&w, NULL, temp_str.c_str()); - if ((temp_str.size() >= DBCOLS) || (w > gr_screen.max_w)) { + if ((temp_str.size() >= DBCOLS) || (w > gr_screen.center_w)) { c = '\n'; } else { @@ -458,7 +458,7 @@ void dc_putc(char c) temp_str.push_back(c); gr_get_string_size(&w, NULL, temp_str.c_str()); - if ((temp_str.size() >= DBCOLS) || (w > gr_screen.max_w)) { + if ((temp_str.size() >= DBCOLS) || (w > gr_screen.center_w)) { /** * Word wrapping * Save the word, clear the line of the word, push new line with the word on it diff --git a/code/fred2/freddoc.cpp b/code/fred2/freddoc.cpp index d2fa65caaf..8549c7d42f 100644 --- a/code/fred2/freddoc.cpp +++ b/code/fred2/freddoc.cpp @@ -25,7 +25,6 @@ #include "object/object.h" #include "editor.h" #include "ai/ai.h" -#include "ai/ailocal.h" #include "cfile/cfile.h" #include "cfile/cfilesystem.h" diff --git a/code/fred2/freddoc.h b/code/fred2/freddoc.h index 0976cfd648..0e71628837 100644 --- a/code/fred2/freddoc.h +++ b/code/fred2/freddoc.h @@ -12,7 +12,6 @@ #ifndef _FREDDOC_H #define _FREDDOC_H -#include "ai/ailocal.h" #include "MissionSave.h" #define MISSION_BACKUP_NAME "Backup" diff --git a/code/fred2/fredrender.cpp b/code/fred2/fredrender.cpp index f8a047d563..aba31f589c 100644 --- a/code/fred2/fredrender.cpp +++ b/code/fred2/fredrender.cpp @@ -34,7 +34,6 @@ #include "model/model.h" #include "palman/palman.h" #include "editor.h" -#include "ai/ailocal.h" #include "ship/ship.h" #include "cfile/cfile.h" #include "mission/missionparse.h" diff --git a/code/fred2/fredview.cpp b/code/fred2/fredview.cpp index 2a8e9026a7..6ef0fddbfc 100644 --- a/code/fred2/fredview.cpp +++ b/code/fred2/fredview.cpp @@ -27,7 +27,6 @@ #include "math/fvi.h" // For find_plane_line_intersection #include "math/vecmat.h" #include "io/key.h" -#include "ai/ailocal.h" #include "ai/ai.h" #include "ai/aigoals.h" #include "ship/ship.h" // for ship names diff --git a/code/fred2/management.cpp b/code/fred2/management.cpp index 86c512e36f..242f4f8530 100644 --- a/code/fred2/management.cpp +++ b/code/fred2/management.cpp @@ -15,7 +15,6 @@ #include "FREDDoc.h" #include "FREDView.h" #include "FredRender.h" -#include "ai/ailocal.h" #include "ai/aigoals.h" #include "ship/ship.h" #include "globalincs/linklist.h" diff --git a/code/fred2/missionsave.h b/code/fred2/missionsave.h index 655dd36865..be3e1602c5 100644 --- a/code/fred2/missionsave.h +++ b/code/fred2/missionsave.h @@ -15,7 +15,6 @@ #include #include "mission/missionparse.h" #include "parse/parselo.h" -#include "ai/ailocal.h" #include "ai/ai.h" #include "cfile/cfile.h" #include "ship/ship.h" diff --git a/code/fred2/shipeditordlg.cpp b/code/fred2/shipeditordlg.cpp index 9a50ffacf0..1f4bc8aba4 100644 --- a/code/fred2/shipeditordlg.cpp +++ b/code/fred2/shipeditordlg.cpp @@ -17,7 +17,6 @@ #include "render/3d.h" #include "physics/physics.h" #include "editor.h" -#include "ai/ailocal.h" #include "ai/aigoals.h" #include "parse/parselo.h" #include "Management.h" diff --git a/code/fred2/wing.cpp b/code/fred2/wing.cpp index a3eac2bca8..98eaf044e9 100644 --- a/code/fred2/wing.cpp +++ b/code/fred2/wing.cpp @@ -17,7 +17,6 @@ #include "physics/physics.h" #include "object/object.h" #include "editor.h" -#include "ai/ailocal.h" #include "ship/ship.h" #include "math/vecmat.h" #include "Management.h" diff --git a/code/freespace2/freespace.cpp b/code/freespace2/freespace.cpp index 56cc3a0a30..abea18bb17 100644 --- a/code/freespace2/freespace.cpp +++ b/code/freespace2/freespace.cpp @@ -580,7 +580,7 @@ void game_framerate_check_init() extern float Framerate; void game_framerate_check() { - int y_start = 100; + int y_start = gr_screen.center_offset_y + 100; // if the current framerate is above the critical level, add frametime if(Framerate >= Gf_critical){ @@ -594,7 +594,7 @@ void game_framerate_check() // display if we're above the critical framerate if(Framerate < Gf_critical){ gr_set_color_fast(&Color_bright_red); - gr_string(200, y_start, "Framerate warning", GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x + 200, y_start, "Framerate warning", GR_RESIZE_NONE); y_start += 10; } @@ -609,7 +609,7 @@ void game_framerate_check() gr_set_color_fast(&Color_bright_red); } - gr_printf_no_resize(200, y_start, "%d%%", (int)pct); + gr_printf_no_resize(gr_screen.center_offset_x + 200, y_start, "%d%%", (int)pct); y_start += 10; } @@ -2163,11 +2163,11 @@ void game_show_framerate() for ( pss = GET_FIRST(&shipp->subsys_list); pss !=END_OF_LIST(&shipp->subsys_list); pss = GET_NEXT(pss) ) { if (pss->system_info->type == SUBSYSTEM_TURRET) { if(pss->turret_enemy_objnum == -1) - gr_printf_no_resize(10, t*line_height, "Turret %d: ", t); + gr_printf_no_resize(gr_screen.center_offset_x + 10, gr_screen.center_offset_y + (t*line_height), "Turret %d: ", t); else if (Objects[pss->turret_enemy_objnum].type == OBJ_SHIP) - gr_printf_no_resize(10, t*line_height, "Turret %d: %s", t, Ships[Objects[pss->turret_enemy_objnum].instance].ship_name); + gr_printf_no_resize(gr_screen.center_offset_x + 10, gr_screen.center_offset_y + (t*line_height), "Turret %d: %s", t, Ships[Objects[pss->turret_enemy_objnum].instance].ship_name); else - gr_printf_no_resize(10, t*line_height, "Turret %d: ", t, pss->turret_enemy_objnum); + gr_printf_no_resize(gr_screen.center_offset_x + 10, gr_screen.center_offset_y + (t*line_height), "Turret %d: ", t, pss->turret_enemy_objnum); t++; } @@ -2180,14 +2180,14 @@ void game_show_framerate() gr_set_color_fast(&HUD_color_debug); if (Cmdline_frame_profile) { - gr_string(20, 100 + line_height, profile_output.c_str(), GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100 + line_height, profile_output.c_str(), GR_RESIZE_NONE); } if (Show_framerate) { if (frametotal != 0.0f) - gr_printf_no_resize( 20, 100, "FPS: %0.1f", Framerate ); + gr_printf_no_resize( gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100, "FPS: %0.1f", Framerate ); else - gr_string( 20, 100, "FPS: ?", GR_RESIZE_NONE ); + gr_string( gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100, "FPS: ?", GR_RESIZE_NONE ); } } @@ -2201,6 +2201,10 @@ void game_show_framerate() #ifdef _WIN32 if (Cmdline_show_stats && HUD_draw) { + int sx,sy; + sx = gr_screen.center_offset_x + 20; + sy = gr_screen.center_offset_y + 100 + (line_height * 2); + char mem_buffer[50]; MEMORYSTATUS mem_stats; @@ -2212,22 +2216,27 @@ void game_show_framerate() else sprintf(mem_buffer,"Using Physical: %d Meg",(Mem_starttime_phys - mem_stats.dwAvailPhys)/1024/1024); - gr_string( 20, 100 + (line_height * 2), mem_buffer, GR_RESIZE_NONE); + gr_string( sx, sy, mem_buffer, GR_RESIZE_NONE); + sy += line_height; sprintf(mem_buffer,"Using Pagefile: %d Meg",(Mem_starttime_pagefile - mem_stats.dwAvailPageFile)/1024/1024); - gr_string( 20, 100 + (line_height * 3), mem_buffer, GR_RESIZE_NONE); + gr_string( sx, sy, mem_buffer, GR_RESIZE_NONE); + sy += line_height; sprintf(mem_buffer,"Using Virtual: %d Meg",(Mem_starttime_virtual - mem_stats.dwAvailVirtual)/1024/1024); - gr_string( 20, 100 + (line_height * 4), mem_buffer, GR_RESIZE_NONE); + gr_string( sx, sy, mem_buffer, GR_RESIZE_NONE); + sy += line_height * 2; if ( ((int)mem_stats.dwAvailPhys == -1) || ((int)mem_stats.dwTotalPhys == -1) ) sprintf(mem_buffer, "Physical Free: *** / *** (>4G)"); else sprintf(mem_buffer,"Physical Free: %d / %d Meg",mem_stats.dwAvailPhys/1024/1024, mem_stats.dwTotalPhys/1024/1024); - gr_string( 20, 100 + (line_height * 6), mem_buffer, GR_RESIZE_NONE); + gr_string( sx, sy, mem_buffer, GR_RESIZE_NONE); + sy += line_height; sprintf(mem_buffer,"Pagefile Free: %d / %d Meg",mem_stats.dwAvailPageFile/1024/1024, mem_stats.dwTotalPageFile/1024/1024); - gr_string( 20, 100 + (line_height * 7), mem_buffer, GR_RESIZE_NONE); + gr_string( sx, sy, mem_buffer, GR_RESIZE_NONE); + sy += line_height; sprintf(mem_buffer,"Virtual Free: %d / %d Meg",mem_stats.dwAvailVirtual/1024/1024, mem_stats.dwTotalVirtual/1024/1024); - gr_string( 20, 100 + (line_height * 8), mem_buffer, GR_RESIZE_NONE); + gr_string( sx, sy, mem_buffer, GR_RESIZE_NONE); } #endif @@ -2235,8 +2244,8 @@ void game_show_framerate() if ( Show_cpu == 1 ) { int sx,sy; - sx = gr_screen.max_w - 154; - sy = 15; + sx = gr_screen.center_offset_x + gr_screen.center_w - 154; + sy = gr_screen.center_offset_y + 15; gr_set_color_fast(&HUD_color_debug); @@ -2282,8 +2291,8 @@ void game_show_framerate() if ( Show_mem ) { int sx,sy; - sx = gr_screen.max_w - 154; - sy = 15; + sx = gr_screen.center_offset_x + gr_screen.center_w - 154; + sy = gr_screen.center_offset_y + 15; gr_set_color_fast(&HUD_color_debug); @@ -2316,8 +2325,8 @@ void game_show_framerate() if ( Show_player_pos ) { int sx, sy; - sx = 320; - sy = 100; + sx = gr_screen.center_offset_x + 320; + sy = gr_screen.center_offset_y + 100; gr_printf_no_resize(sx, sy, NOX("Player Pos: (%d,%d,%d)"), fl2i(Player_obj->pos.xyz.x), fl2i(Player_obj->pos.xyz.y), fl2i(Player_obj->pos.xyz.z)); } @@ -2349,11 +2358,11 @@ void game_show_framerate() short_name++; sprintf(mem_buffer,"%s:\t%d K", short_name, size); - gr_string( 20, 100 + (line_height * 12) + (mi*line_height), mem_buffer, GR_RESIZE_NONE); + gr_string( gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100 + (line_height * 12) + (mi*line_height), mem_buffer, GR_RESIZE_NONE); } sprintf(mem_buffer,"Total RAM:\t%d K", TotalRam / 1024); - gr_string( 20, 100 + (line_height * 13) + (mi*line_height), mem_buffer, GR_RESIZE_NONE); + gr_string( gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100 + (line_height * 13) + (mi*line_height), mem_buffer, GR_RESIZE_NONE); } #endif @@ -2388,7 +2397,7 @@ void game_show_eye_pos(camid cid) gr_set_color_fast(&HUD_color_debug); //Position - gr_printf_no_resize(20, 100 - font_height, "X:%f Y:%f Z:%f", cam_pos.xyz.x, cam_pos.xyz.y, cam_pos.xyz.z); + gr_printf_no_resize(gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100 - font_height, "X:%f Y:%f Z:%f", cam_pos.xyz.x, cam_pos.xyz.y, cam_pos.xyz.z); font_height -= font_height/2; //Orientation @@ -2396,7 +2405,7 @@ void game_show_eye_pos(camid cid) rot_angles.p *= (180/PI); rot_angles.b *= (180/PI); rot_angles.h *= (180/PI); - gr_printf_no_resize(20, 100 - font_height, "Xr:%f Yr:%f Zr:%f", rot_angles.p, rot_angles.b, rot_angles.h); + gr_printf_no_resize(gr_screen.center_offset_x + 20, gr_screen.center_offset_y + 100 - font_height, "Xr:%f Yr:%f Zr:%f", rot_angles.p, rot_angles.b, rot_angles.h); } void game_show_standalone_framerate() @@ -2446,7 +2455,7 @@ void game_show_time_left() diff = 0; hud_set_default_color(); - gr_printf_no_resize( 5, 40, XSTR( "Mission time remaining: %d seconds", 179), diff ); + gr_printf_no_resize( gr_screen.center_offset_x + 5, gr_screen.center_offset_y + 40, XSTR( "Mission time remaining: %d seconds", 179), diff ); } //======================================================================================== @@ -3843,7 +3852,7 @@ void game_render_frame( camid cid ) do_timing_test(flFrametime); extern int OO_update_index; - multi_rate_display(OO_update_index, 375, 0); + multi_rate_display(OO_update_index, gr_screen.center_offset_x + 375, gr_screen.center_offset_y); // test extern void oo_display(); @@ -7468,13 +7477,13 @@ void game_show_event_debug(float frametime) gr_clear(); gr_set_color_fast(&Color_bright); gr_set_font(FONT1); - gr_printf_no_resize(0x8000, 15, NOX("EVENT DEBUG VIEW")); + gr_printf_no_resize(0x8000, gr_screen.center_offset_y + 15, NOX("EVENT DEBUG VIEW")); gr_set_color_fast(&Color_normal); gr_set_font(FONT1); gr_get_string_size(&font_width, &font_height, NOX("test")); - y_max = gr_screen.max_h - font_height - 5; - y_index = 45; + y_max = gr_screen.center_offset_y + gr_screen.center_h - font_height - 5; + y_index = gr_screen.center_offset_y + 45; k = scroll_offset; while (k < ED_count) { @@ -7524,7 +7533,7 @@ void game_show_event_debug(float frametime) } } - gr_printf_no_resize(10, y_index, buf); + gr_printf_no_resize(gr_screen.center_offset_x + 10, y_index, buf); y_index += font_height; k++; } diff --git a/code/gamesnd/gamesnd.cpp b/code/gamesnd/gamesnd.cpp index 70b78f12a2..3717572294 100644 --- a/code/gamesnd/gamesnd.cpp +++ b/code/gamesnd/gamesnd.cpp @@ -14,12 +14,250 @@ #include "species_defs/species_defs.h" #include "parse/parselo.h" #include "sound/ds.h" +#include "sound/sound.h" #include SCP_vector Snds; SCP_vector Snds_iface; SCP_vector Snds_iface_handle; +// jg18 - default priorities and limits for retail gameplay sounds +static const int NUM_RETAIL_GAMEPLAY_SOUNDS = 192; // indices 0-191, from retail sounds.tbl +static EnhancedSoundData Default_sound_priorities[NUM_RETAIL_GAMEPLAY_SOUNDS] = +{ + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_MISSILE_TRACKING = 0, //!< Missle tracking to acquire a lock (looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_MISSILE_LOCK = 1, //!< Missle lock (non-looping) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_PRIMARY_CYCLE = 2, //!< cycle primary weapon + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SECONDARY_CYCLE = 3, //!< cycle secondary weapon + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_ENGINE = 4, //!< engine sound (as heard in cockpit) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_CARGO_REVEAL = 5, //!< cargo revealed + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_DEATH_ROLL = 6, //!< ship death roll + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_SHIP_EXPLODE_1 = 7, //!< ship explosion 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_TARGET_ACQUIRE = 8, //!< target acquried + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_ENERGY_ADJUST = 9, //!< energy level change success + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_ENERGY_ADJUST_FAIL = 10, //!< energy level change fail + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_ENERGY_TRANS = 11, //!< energy transfer success + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_ENERGY_TRANS_FAIL = 12, //!< energy transfer fail + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_FULL_THROTTLE = 13, //!< set full throttle + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_ZERO_THROTTLE = 14, //!< set zero throttle + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_THROTTLE_UP = 15, //!< set 1/3 or 2/3 throttle (up) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_THROTTLE_DOWN = 16, //!< set 1/3 or 2/3 throttle (down) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_DOCK_APPROACH = 17, //!< dock approach retros + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_DOCK_ATTACH = 18, //!< dock attach + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_DOCK_DETACH = 19, //!< dock detach + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_DOCK_DEPART = 20, //!< dock depart retros + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_ABURN_ENGAGE = 21, //!< afterburner engage + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_ABURN_LOOP = 22, //!< afterburner burn sound (looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_VAPORIZED = 23, //!< Destroyed by a beam (vaporized) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 2), // SND_ABURN_FAIL = 24, //!< afterburner fail (no fuel when aburn pressed) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_HEATLOCK_WARN = 25, //!< heat-seeker launch warning + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_OUT_OF_MISSLES = 26, //!< tried to fire a missle when none are left + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_OUT_OF_WEAPON_ENERGY = 27, //!< tried to fire lasers when not enough energy left + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_TARGET_FAIL = 28, //!< target fail sound (i.e. press targeting key, but nothing happens) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SQUADMSGING_ON = 29, //!< squadmate message menu appears + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SQUADMSGING_OFF = 30, //!< squadmate message menu disappears + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 5), // SND_DEBRIS = 31, //!< debris sound (persistant, looping) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_SUBSYS_DIE_1 = 32, //!< subsystem gets destroyed on player ship + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_MISSILE_START_LOAD = 33, //!< missle start load (during rearm/repair) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_MISSILE_LOAD = 34, //!< missle load (during rearm/repair) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_SHIP_REPAIR = 35, //!< ship is being repaired (during rearm/repair) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_PLAYER_HIT_LASER = 36, //!< player ship is hit by laser fire + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_PLAYER_HIT_MISSILE = 37, //!< player ship is hit by missile + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_CMEASURE_CYCLE = 38, //!< countermeasure cycle + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_SHIELD_HIT = 39, //!< shield hit + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_SHIELD_HIT_YOU = 40, //!< player shield is hit + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_GAME_MOUSE_CLICK = 41, //!< mouse click + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_ASPECTLOCK_WARN = 42, //!< aspect launch warning + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SHIELD_XFER_OK = 43, //!< shield quadrant transfer successful + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 5), // SND_ENGINE_WASH = 44, //!< Engine wash (looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_WARP_IN = 45, //!< warp hole opening up for arriving + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_WARP_OUT = 46, //!< warp hole opening up for departing (Same as warp in for now) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_PLAYER_WARP_FAIL = 47, //!< player warp has failed + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_STATIC = 48, //!< hud gauge static + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_SHIP_EXPLODE_2 = 49, //!< ship explosion 2 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_PLAYER_WARP_OUT = 50, //!< ship is warping out in 3rd person + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_SHIP_SHIP_HEAVY = 51, //!< heavy ship-ship collide sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_SHIP_SHIP_LIGHT = 52, //!< light ship-ship collide sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_SHIP_SHIP_SHIELD = 53, //!< shield ship-ship collide overlay sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_THREAT_FLASH = 54, //!< missile threat indicator flashes + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_PROXIMITY_WARNING = 55, //!< proximity warning (heat seeker) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 3), // SND_PROXIMITY_ASPECT_WARNING = 56, //!< proximity warning (aspect) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_DIRECTIVE_COMPLETE = 57, //!< directive complete + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_SUBSYS_EXPLODE = 58, //!< other ship subsystem destroyed + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_CAPSHIP_EXPLODE = 59, //!< captial ship explosion + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_CAPSHIP_SUBSYS_EXPLODE = 60, //!< captial ship subsystem destroyed + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_LARGESHIP_WARPOUT = 61, //!< large ship warps out + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 5), // SND_ASTEROID_EXPLODE_LARGE = 62, //!< large asteroid blows up + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 5), // SND_ASTEROID_EXPLODE_SMALL = 63, //!< small asteroid blows up + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_CUE_VOICE = 64, //!< sound to indicate voice is about to start + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_END_VOICE = 65, //!< sound to indicate voice has ended + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 2), // SND_CARGO_SCAN = 66, //!< cargo scanning (looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_WEAPON_FLYBY = 67, //!< weapon flyby sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 5), // SND_ASTEROID = 68, //!< asteroid sound (persistant, looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_CAPITAL_WARP_IN = 69, //!< capital warp hole opening + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_CAPITAL_WARP_OUT = 70, //!< capital warp hole closing + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 5), // SND_ENGINE_LOOP_LARGE = 71, //!< LARGE engine ambient + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SUBSPACE_LEFT_CHANNEL = 72, //!< subspace ambient sound (left channel) (looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SUBSPACE_RIGHT_CHANNEL = 73, //!< subspace ambient sound (right channel) (looped) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 4), // SND_MISSILE_EVADED_POPUP = 74, //!< "evaded" HUD popup + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_ENGINE_LOOP_HUGE = 75, //!< HUGE engine ambient + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_LIGHT_LASER_FIRE = 76, //!< SD-4 Sidearm laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_LIGHT_LASER_IMPACT = 77, //!< DR-2 Scalpel fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_HVY_LASER_FIRE = 78, //!< Flail II fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_HVY_LASER_IMPACT = 79, //!< Prometheus R laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_MASSDRV_FIRED = 80, //!< Prometheus S laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_MASSDRV_IMPACT = 81, //!< GTW-66 Newton Cannon fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_FLAIL_FIRED = 82, //!< UD-8 Kayser Laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_FLAIL_IMPACT = 83, //!< GTW-19 Circe laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_NEUTRON_FLUX_FIRED = 84, //!< GTW-83 Lich laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_NEUTRON_FLUX_IMPACT = 85, //!< Laser impact + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_DEBUG_LASER_FIRED = 86, //!< Subach-HLV Vasudan laser + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_ROCKEYE_FIRED = 87, //!< rockeye missile launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_MISSILE_IMPACT1 = 88, //!< missile impact 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_MAG_MISSILE_LAUNCH = 89, //!< mag pulse missile launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_FURY_MISSILE_LAUNCH = 90, //!< fury missile launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_SHRIKE_MISSILE_LAUNCH = 91, //!< shrike missile launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_ANGEL_MISSILE_LAUNCH = 92, //!< angel fire missile launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_CLUSTER_MISSILE_LAUNCH = 93, //!< cluster bomb launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_CLUSTERB_MISSILE_LAUNCH = 94, //!< cluster baby bomb launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_STILETTO_MISSILE_LAUNCH = 95, //!< stiletto bomb launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_TSUNAMI_MISSILE_LAUNCH = 96, //!< tsunami bomb launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_HARBINGER_MISSILE_LAUNCH = 97, //!< harbinger bomb launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_MEGAWOKKA_MISSILE_LAUNCH = 98, //!< mega wokka launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_CMEASURE1_LAUNCH = 99, //!< countermeasure 1 launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_SHIVAN_LIGHT_LASER_FIRE = 100,//!< Shivan light laser + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_SHOCKWAVE_EXPLODE = 101,//!< shockwave ignition + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_SWARM_MISSILE_LAUNCH = 102,//!< swarm missile sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_103 = 103,//!< Shivan heavy laser + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_UNDEFINED_104 = 104,//!< Vasudan SuperCap engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_UNDEFINED_105 = 105,//!< Shivan SuperCap engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_UNDEFINED_106 = 106,//!< Terran SuperCap engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_107 = 107,//!< Vasudan light laser fired + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_108 = 108,//!< Shivan heavy laser + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 2), // SND_SHOCKWAVE_IMPACT = 109,//!< shockwave impact + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_110 = 110,//!< TERRAN TURRET 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_111 = 111,//!< TERRAN TURRET 2 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_112 = 112,//!< VASUDAN TURRET 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_113 = 113,//!< VASUDAN TURRET 2 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_UNDEFINED_114 = 114,//!< SHIVAN TURRET 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_TARG_LASER_LOOP = 115,//!< targeting laser loop sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 8), // SND_FLAK_FIRE = 116,//!< Flak Gun Launch + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_SHIELD_BREAKER = 117,//!< Flak Gun Impact + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM_LOW, 8), // SND_EMP_MISSILE = 118,//!< EMP Missle + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 5), // SND_AUTOCANNON_LOOP = 119,//!< Escape Pod Drone + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 5), // SND_AUTOCANNON_SHOT = 120,//!< Beam Hit 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_BEAM_LOOP = 121,//!< beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_BEAM_UP = 122,//!< beam power up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_BEAM_DOWN = 123,//!< beam power down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_BEAM_SHOT = 124,//!< Beam shot 1 + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_BEAM_VAPORIZE = 125,//!< Beam shot 2 + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_TERRAN_FIGHTER_ENG = 126,//!< Terran fighter engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_TERRAN_BOMBER_ENG = 127,//!< Terran bomber engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_TERRAN_CAPITAL_ENG = 128,//!< Terran cruiser engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_SPECIESB_FIGHTER_ENG = 129,//!< Vasudan fighter engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_SPECIESB_BOMBER_ENG = 130,//!< Vasudan bomber engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_SPECIESB_CAPITAL_ENG = 131,//!< Vasudan cruiser engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_SHIVAN_FIGHTER_ENG = 132,//!< Shivan fighter engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_SHIVAN_BOMBER_ENG = 133,//!< Shivan bomber engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_SHIVAN_CAPITAL_ENG = 134,//!< Shivan cruiser engine + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_REPAIR_SHIP_ENG = 135,//!< Repair ship beacon/engine sound + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_UNDEFINED_136 = 136,//!< Terran capital engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_UNDEFINED_137 = 137,//!< Vasudan capital engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 4), // SND_UNDEFINED_138 = 138,//!< Shivan capital engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_DEBRIS_ARC_01 = 139,//!< 0.10 second spark sound effect + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_DEBRIS_ARC_02 = 140,//!< 0.25 second spark sound effect + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_DEBRIS_ARC_03 = 141,//!< 0.50 second spark sound effect + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_DEBRIS_ARC_04 = 142,//!< 0.75 second spark sound effect + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_DEBRIS_ARC_05 = 143,//!< 1.00 second spark sound effect + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_144 = 144,//!< LTerSlash beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_145 = 145,//!< TerSlash beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_146 = 146,//!< SGreen beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_147 = 147,//!< BGreen beem loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_148 = 148,//!< BFGreen been loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_149 = 149,//!< Antifighter beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_150 = 150,//!< 1 sec warm up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_151 = 151,//!< 1.5 sec warm up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_152 = 152,//!< 2.5 sec warm up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_153 = 153,//!< 3 sec warm up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_154 = 154,//!< 3.5 sec warm up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_155 = 155,//!< 5 sec warm up + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_156 = 156,//!< LTerSlash warm down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_157 = 157,//!< TerSlash warm down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_158 = 158,//!< SGreen warm down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_159 = 159,//!< BGreen warm down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_160 = 160,//!< BFGreen warm down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_161 = 161,//!< T_AntiFtr warm down + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_COPILOT = 162,//!< copilot (SCP) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_163 = 163,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_164 = 164,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_165 = 165,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_166 = 166,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_167 = 167,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_168 = 168,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_169 = 169,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_170 = 170,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_171 = 171,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_172 = 172,//!< (Empty in Retail) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SUPERNOVA_1 = 173,//!< SuperNova (distant) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MUST_PLAY, 1), // SND_SUPERNOVA_2 = 174,//!< SuperNova (shockwave) + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_UNDEFINED_175 = 175,//!< Shivan large engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_MEDIUM, 3), // SND_UNDEFINED_176 = 176,//!< Shivan large engine + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_177 = 177,//!< SRed beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_178 = 178,//!< LRed beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 3), // SND_UNDEFINED_179 = 179,//!< Antifighter beam loop + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_LIGHTNING_1 = 180,//!< Thunder 1 sound in neblua + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 4), // SND_LIGHTNING_2 = 181,//!< Thunder 2 sound in neblua + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_UNDEFINED_182 = 182,//!< 1 sec warm up + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_UNDEFINED_183 = 183,//!< 1.5 sec warm up + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_UNDEFINED_184 = 184,//!< 3 sec warm up + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 2), // SND_UNDEFINED_185 = 185,//!< Shivan Commnode + EnhancedSoundData( SND_ENHANCED_PRIORITY_HIGH, 1), // SND_UNDEFINED_186 = 186,//!< Volition PirateShip + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_UNDEFINED_187 = 187,//!< SRed warm down + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_UNDEFINED_188 = 188,//!< LRed warm down + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 3), // SND_UNDEFINED_189 = 189,//!< AntiFtr warm down + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 2), // SND_UNDEFINED_190 = 190,//!< Instellation 1 + EnhancedSoundData(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 2) // SND_UNDEFINED_191 = 191,//!< Instellation 2 +}; + +static const EnhancedSoundData default_enhanced_sound_data(SND_ENHANCED_PRIORITY_MEDIUM_HIGH, 1); + + +/* + * Update any uninitialized EnhancedSoundData in Snds + * with hardcoded defaults for retail. + */ +void gamesnd_add_retail_default_enhanced_sound_data() +{ + int i = 0; + + for (SCP_vector::iterator it = Snds.begin(), end = Snds.end(); it != end; ++it, ++i) + { + if (it->enhanced_sound_data.priority== SND_ENHANCED_PRIORITY_INVALID) + { + if (i < NUM_RETAIL_GAMEPLAY_SOUNDS) + { + it->enhanced_sound_data.priority= Default_sound_priorities[i].priority; + } + else + { + it->enhanced_sound_data.priority= default_enhanced_sound_data.priority; + } + } + + if (it->enhanced_sound_data.limit < 1) + { + if (i < NUM_RETAIL_GAMEPLAY_SOUNDS) + { + it->enhanced_sound_data.limit = Default_sound_priorities[i].limit; + } + else + { + it->enhanced_sound_data.limit= default_enhanced_sound_data.limit; + } + } + } +} + void gamesnd_play_iface(int n) { if (Snds_iface_handle[n] >= 0) @@ -408,6 +646,42 @@ void parse_gamesnd_old(game_snd* gs) advance_to_eoln(NULL); } + +EnhancedSoundPriority convert_to_enhanced_priority(const char * priority_str) +{ + Assertion(priority_str != NULL, "convert_to_enhanced_priority given null priority_str!"); + + if (!stricmp(priority_str, "Must Play")) + { + return SND_ENHANCED_PRIORITY_MUST_PLAY; + } + else if (!stricmp(priority_str, "High")) + { + return SND_ENHANCED_PRIORITY_HIGH; + } + else if (!stricmp(priority_str, "Medium-High")) + { + return SND_ENHANCED_PRIORITY_MEDIUM_HIGH; + } + else if (!stricmp(priority_str, "Medium")) + { + return SND_ENHANCED_PRIORITY_MEDIUM; + } + else if (!stricmp(priority_str, "Medium-Low")) + { + return SND_ENHANCED_PRIORITY_MEDIUM_LOW; + } + else if (!stricmp(priority_str, "Low")) + { + return SND_ENHANCED_PRIORITY_LOW; + } + else + { + error_display(1, "Unknown enhanced sound priority: %s\n", priority_str); + return SND_ENHANCED_PRIORITY_INVALID; + } +} + bool required_string_no_create(const char* token, bool no_create) { if (no_create) @@ -469,6 +743,34 @@ void parse_gamesnd_new(game_snd* gs, bool no_create) gs->min = 0; gs->max = 0; } + + // jg18 - enhanced sound parameters + if (optional_string("+Priority:")) + { + SCP_string priority_string; + stuff_string(priority_string, F_NAME); + EnhancedSoundPriority priority = convert_to_enhanced_priority(priority_string.c_str()); + if (priority != SND_ENHANCED_PRIORITY_INVALID) + { + gs->enhanced_sound_data.priority= priority; + } + // else case not needed since conversion function displays message on error + } + + if (optional_string("+Limit:")) + { + int temp_limit; + stuff_int(&temp_limit); + + if ((temp_limit > 0) && (temp_limit <= SND_ENHANCED_MAX_LIMIT)) + { + gs->enhanced_sound_data.limit = (unsigned int)temp_limit; + } + else + { + error_display(1, "Invalid enhanced sound limit: %d\n", temp_limit); + } + } } void gamesnd_parse_entry(game_snd *gs, bool no_create, SCP_vector *lookupVector) @@ -795,6 +1097,8 @@ void parse_sound_table(const char* filename) mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", filename, e.what())); return; } + + gamesnd_add_retail_default_enhanced_sound_data(); } /** diff --git a/code/graphics/2d.cpp b/code/graphics/2d.cpp index 33e0e3b8c4..9117d17c62 100644 --- a/code/graphics/2d.cpp +++ b/code/graphics/2d.cpp @@ -92,65 +92,70 @@ static int GL_cursor_nframes = 0; // Pre-computed screen resize vars static float Gr_full_resize_X = 1.0f, Gr_full_resize_Y = 1.0f; +static float Gr_full_center_resize_X = 1.0f, Gr_full_center_resize_Y = 1.0f; static float Gr_resize_X = 1.0f, Gr_resize_Y = 1.0f; static float Gr_menu_offset_X = 0.0f, Gr_menu_offset_Y = 0.0f; static float Gr_menu_zoomed_offset_X = 0.0f, Gr_menu_zoomed_offset_Y = 0.0f; float Gr_save_full_resize_X = 1.0f, Gr_save_full_resize_Y = 1.0f; +float Gr_save_full_center_resize_X = 1.0f, Gr_save_full_center_resize_Y = 1.0f; float Gr_save_resize_X = 1.0f, Gr_save_resize_Y = 1.0f; float Gr_save_menu_offset_X = 0.0f, Gr_save_menu_offset_Y = 0.0f; float Gr_save_menu_zoomed_offset_X = 0.0f, Gr_save_menu_zoomed_offset_Y = 0.0f; bool Save_custom_screen_size; -void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, bool force_stretch) +void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, int center_w, int center_h, bool force_stretch) { bool do_zoom = zoom_w > 0 && zoom_h > 0 && (zoom_w != w || zoom_h != h); Gr_full_resize_X = (float)max_w / (float)w; Gr_full_resize_Y = (float)max_h / (float)h; + Gr_full_center_resize_X = (float)center_w / (float)w; + Gr_full_center_resize_Y = (float)center_h / (float)h; + if (do_zoom) { - float aspect_quotient = ((float)max_w / (float)max_h) / ((float)zoom_w / (float)zoom_h); + float aspect_quotient = ((float)center_w / (float)center_h) / ((float)zoom_w / (float)zoom_h); - Gr_resize_X = (float)max_w / (float)zoom_w / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f); - Gr_resize_Y = (float)max_h / (float)zoom_h * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f); + Gr_resize_X = (float)center_w / (float)zoom_w / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f); + Gr_resize_Y = (float)center_h / (float)zoom_h * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f); - Gr_menu_offset_X = (max_w - w * Gr_resize_X) / 2.0f; - Gr_menu_offset_Y = (max_h - h * Gr_resize_Y) / 2.0f; + Gr_menu_offset_X = ((center_w - w * Gr_resize_X) / 2.0f) + gr_screen.center_offset_x; + Gr_menu_offset_Y = ((center_h - h * Gr_resize_Y) / 2.0f) + gr_screen.center_offset_y; - Gr_menu_zoomed_offset_X = (Gr_menu_offset_X >= 0.0f) ? Gr_menu_offset_X : 0.0f; - Gr_menu_zoomed_offset_Y = (Gr_menu_offset_Y >= 0.0f) ? Gr_menu_offset_Y : 0.0f; + Gr_menu_zoomed_offset_X = (Gr_menu_offset_X >= 0.0f) ? Gr_menu_offset_X : gr_screen.center_offset_x; + Gr_menu_zoomed_offset_Y = (Gr_menu_offset_Y >= 0.0f) ? Gr_menu_offset_Y : gr_screen.center_offset_y; if (force_stretch || Cmdline_stretch_menu) { - if (Gr_menu_offset_X > 0.0f) { - Gr_resize_X = Gr_full_resize_X; - Gr_menu_offset_X = Gr_menu_zoomed_offset_X = 0.0f; + if (Gr_menu_offset_X > (float)gr_screen.center_offset_x) { + Gr_resize_X = Gr_full_center_resize_X; + Gr_menu_offset_X = Gr_menu_zoomed_offset_X = (float)gr_screen.center_offset_x; } - if (Gr_menu_offset_Y > 0.0f) { - Gr_resize_Y = Gr_full_resize_Y; - Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = 0.0f; + if (Gr_menu_offset_Y > (float)gr_screen.center_offset_y) { + Gr_resize_Y = Gr_full_center_resize_Y; + Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = (float)gr_screen.center_offset_y; } } } else { if (force_stretch || Cmdline_stretch_menu) { - Gr_resize_X = Gr_full_resize_X; - Gr_resize_Y = Gr_full_resize_Y; + Gr_resize_X = Gr_full_center_resize_X; + Gr_resize_Y = Gr_full_center_resize_Y; - Gr_menu_offset_X = Gr_menu_zoomed_offset_X = 0.0f; - Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = 0.0f; + Gr_menu_offset_X = Gr_menu_zoomed_offset_X = (float)gr_screen.center_offset_x; + Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = (float)gr_screen.center_offset_y; } else { - float aspect_quotient = ((float)max_w / (float)max_h) / ((float)w / (float)h); + float aspect_quotient = ((float)center_w / (float)center_h) / ((float)w / (float)h); - Gr_resize_X = Gr_full_resize_X / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f); - Gr_resize_Y = Gr_full_resize_Y * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f); + Gr_resize_X = Gr_full_center_resize_X / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f); + Gr_resize_Y = Gr_full_center_resize_Y * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f); - Gr_menu_offset_X = Gr_menu_zoomed_offset_X = (aspect_quotient > 1.0f) ? ((max_w - w * Gr_resize_X) / 2.0f) : 0.0f; - Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = (aspect_quotient < 1.0f) ? ((max_h - h * Gr_resize_Y) / 2.0f) : 0.0f; + Gr_menu_offset_X = Gr_menu_zoomed_offset_X = ((aspect_quotient > 1.0f) ? ((center_w - w * Gr_resize_X) / 2.0f) : 0.0f) + gr_screen.center_offset_x; + Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = ((aspect_quotient < 1.0f) ? ((center_h - h * Gr_resize_Y) / 2.0f) : 0.0f) + gr_screen.center_offset_y; } } - gr_screen.custom_size = (w != max_w || h != max_h); + gr_screen.custom_size = (w != max_w || w != center_w || h != max_h || h != center_h); if (gr_screen.rendering_to_texture == -1) { gr_screen.max_w_unscaled = w; @@ -177,6 +182,9 @@ void gr_reset_screen_scale() Gr_full_resize_X = Gr_save_full_resize_X; Gr_full_resize_Y = Gr_save_full_resize_Y; + Gr_full_center_resize_X = Gr_save_full_center_resize_X; + Gr_full_center_resize_Y = Gr_save_full_center_resize_Y; + Gr_resize_X = Gr_save_resize_X; Gr_resize_Y = Gr_save_resize_Y; @@ -219,6 +227,10 @@ bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode) xy_tmp = (*x) * Gr_full_resize_X; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*x) * Gr_full_center_resize_X + (float)gr_screen.center_offset_x; + break; + case GR_RESIZE_MENU: xy_tmp = (*x) * Gr_resize_X + Gr_menu_offset_X; break; @@ -240,6 +252,10 @@ bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode) xy_tmp = (*y) * Gr_full_resize_Y; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*y) * Gr_full_center_resize_Y + (float)gr_screen.center_offset_y; + break; + case GR_RESIZE_MENU: xy_tmp = (*y) * Gr_resize_Y + Gr_menu_offset_Y; break; @@ -256,12 +272,40 @@ bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode) } if ( w ) { - xy_tmp = (*w) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*w) * Gr_full_resize_X; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*w) * Gr_full_center_resize_X; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*w) * Gr_resize_X; + break; + } (*w) = fl2ir(xy_tmp); } if ( h ) { - xy_tmp = (*h) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*h) * Gr_full_resize_Y; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*h) * Gr_full_center_resize_Y; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*h) * Gr_resize_Y; + break; + } (*h) = fl2ir(xy_tmp); } @@ -291,6 +335,10 @@ bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode) xy_tmp = (*x) / Gr_full_resize_X; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = ((*x) - (float)gr_screen.center_offset_x) / Gr_full_center_resize_X; + break; + case GR_RESIZE_MENU: xy_tmp = ((*x) - Gr_menu_offset_X) / Gr_resize_X; break; @@ -312,6 +360,10 @@ bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode) xy_tmp = (*y) / Gr_full_resize_Y; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = ((*y) - (float)gr_screen.center_offset_y) / Gr_full_center_resize_Y; + break; + case GR_RESIZE_MENU: xy_tmp = ((*y) - Gr_menu_offset_Y) / Gr_resize_Y; break; @@ -328,12 +380,40 @@ bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode) } if ( w ) { - xy_tmp = (*w) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*w) / Gr_full_resize_X; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*w) / Gr_full_center_resize_X; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*w) / Gr_resize_X; + break; + } (*w) = fl2ir(xy_tmp); } if ( h ) { - xy_tmp = (*h) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*h) / Gr_full_resize_Y; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*h) / Gr_full_center_resize_Y; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*h) / Gr_resize_Y; + break; + } (*h) = fl2ir(xy_tmp); } @@ -365,6 +445,10 @@ bool gr_resize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo xy_tmp = (*x) * Gr_full_resize_X; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*x) * Gr_full_center_resize_X + (float)gr_screen.center_offset_x; + break; + case GR_RESIZE_MENU: xy_tmp = (*x) * Gr_resize_X + Gr_menu_offset_X; break; @@ -386,6 +470,10 @@ bool gr_resize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo xy_tmp = (*y) * Gr_full_resize_Y; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*y) * Gr_full_center_resize_Y + (float)gr_screen.center_offset_y; + break; + case GR_RESIZE_MENU: xy_tmp = (*y) * Gr_resize_Y + Gr_menu_offset_Y; break; @@ -402,12 +490,40 @@ bool gr_resize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo } if ( w ) { - xy_tmp = (*w) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*w) * Gr_full_resize_X; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*w) * Gr_full_center_resize_X; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*w) * Gr_resize_X; + break; + } (*w) = xy_tmp; } if ( h ) { - xy_tmp = (*h) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*h) * Gr_full_resize_Y; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*h) * Gr_full_center_resize_Y; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*h) * Gr_resize_Y; + break; + } (*h) = xy_tmp; } @@ -437,6 +553,10 @@ bool gr_unsize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo xy_tmp = (*x) / Gr_full_resize_X; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = ((*x) - (float)gr_screen.center_offset_x) / Gr_full_center_resize_X; + break; + case GR_RESIZE_MENU: xy_tmp = ((*x) - Gr_menu_offset_X) / Gr_resize_X; break; @@ -458,6 +578,10 @@ bool gr_unsize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo xy_tmp = (*y) / Gr_full_resize_Y; break; + case GR_RESIZE_FULL_CENTER: + xy_tmp = ((*y) - (float)gr_screen.center_offset_y) / Gr_full_center_resize_Y; + break; + case GR_RESIZE_MENU: xy_tmp = ((*y) - Gr_menu_offset_Y) / Gr_resize_Y; break; @@ -474,12 +598,40 @@ bool gr_unsize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo } if ( w ) { - xy_tmp = (*w) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*w) / Gr_full_resize_X; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*w) / Gr_full_center_resize_X; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*w) / Gr_resize_X; + break; + } (*w) = xy_tmp; } if ( h ) { - xy_tmp = (*h) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y); + switch (resize_mode) { + case GR_RESIZE_FULL: + xy_tmp = (*h) / Gr_full_resize_Y; + break; + + case GR_RESIZE_FULL_CENTER: + xy_tmp = (*h) / Gr_full_center_resize_Y; + break; + + case GR_RESIZE_MENU: + case GR_RESIZE_MENU_ZOOMED: + case GR_RESIZE_MENU_NO_OFFSET: + xy_tmp = (*h) / Gr_resize_Y; + break; + } (*h) = xy_tmp; } @@ -590,8 +742,8 @@ void gr_screen_resize(int width, int height) return; } - gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = width; - gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = height; + gr_screen.save_center_w = gr_screen.center_w = gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = width; + gr_screen.save_center_h = gr_screen.center_h = gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = height; gr_screen.offset_x = gr_screen.offset_x_unscaled = 0; gr_screen.offset_y = gr_screen.offset_y_unscaled = 0; @@ -622,20 +774,37 @@ void gr_screen_resize(int width, int height) } } -static bool gr_init_sub(int mode, int width, int height, int depth) +static bool gr_init_sub(int mode, int width, int height, int depth, float center_aspect_ratio) { int res = GR_1024; bool rc = false; memset( &gr_screen, 0, sizeof(screen) ); - if ( ((width == 640) && (height == 480)) || ((width == 1024) && (height == 768)) ) { + float aspect_ratio = (float)width / (float)height; + + if ( (((width == 640) && (height == 480)) || ((width == 1024) && (height == 768))) && (aspect_ratio == center_aspect_ratio) ) { gr_screen.custom_size = false; } else { gr_screen.custom_size = true; } - if ( (width >= GR_1024_THRESHOLD_WIDTH) && (height >= GR_1024_THRESHOLD_HEIGHT) ) { + gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = width; + gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = height; + if (aspect_ratio > center_aspect_ratio) { + gr_screen.save_center_w = gr_screen.center_w = fl2ir(height * center_aspect_ratio); + gr_screen.save_center_h = gr_screen.center_h = height; + } else if (aspect_ratio < center_aspect_ratio) { + gr_screen.save_center_w = gr_screen.center_w = width; + gr_screen.save_center_h = gr_screen.center_h = fl2ir(width / center_aspect_ratio); + } else { + gr_screen.save_center_w = gr_screen.center_w = width; + gr_screen.save_center_h = gr_screen.center_h = height; + } + gr_screen.save_center_offset_x = gr_screen.center_offset_x = (width - gr_screen.center_w) / 2; + gr_screen.save_center_offset_y = gr_screen.center_offset_y = (height - gr_screen.center_h) / 2; + + if ( (gr_screen.center_w >= GR_1024_THRESHOLD_WIDTH) && (gr_screen.center_h >= GR_1024_THRESHOLD_HEIGHT) ) { res = GR_1024; } else { res = GR_640; @@ -652,20 +821,23 @@ static bool gr_init_sub(int mode, int width, int height, int depth) Gr_save_full_resize_X = Gr_full_resize_X = (float)width / ((res == GR_1024) ? 1024.0f : 640.0f); Gr_save_full_resize_Y = Gr_full_resize_Y = (float)height / ((res == GR_1024) ? 768.0f : 480.0f); + Gr_save_full_center_resize_X = Gr_full_center_resize_X = (float)gr_screen.center_w / ((res == GR_1024) ? 1024.0f : 640.0f); + Gr_save_full_center_resize_Y = Gr_full_center_resize_Y = (float)gr_screen.center_h / ((res == GR_1024) ? 768.0f : 480.0f); + if (gr_screen.custom_size && !Cmdline_stretch_menu) { - float aspect_quotient = ((float)width / (float)height) / (4.0f / 3.0f); + float aspect_quotient = center_aspect_ratio / (4.0f / 3.0f); - Gr_save_resize_X = Gr_resize_X = Gr_full_resize_X / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f); - Gr_save_resize_Y = Gr_resize_Y = Gr_full_resize_Y * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f); + Gr_save_resize_X = Gr_resize_X = Gr_full_center_resize_X / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f); + Gr_save_resize_Y = Gr_resize_Y = Gr_full_center_resize_Y * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f); - Gr_save_menu_offset_X = Gr_menu_offset_X = (aspect_quotient > 1.0f) ? ((width - width / aspect_quotient) / 2.0f) : 0.0f; - Gr_save_menu_offset_Y = Gr_menu_offset_Y = (aspect_quotient < 1.0f) ? ((height - height * aspect_quotient) / 2.0f) : 0.0f; + Gr_save_menu_offset_X = Gr_menu_offset_X = ((aspect_quotient > 1.0f) ? ((gr_screen.center_w - gr_screen.center_w / aspect_quotient) / 2.0f) : 0.0f) + gr_screen.center_offset_x; + Gr_save_menu_offset_Y = Gr_menu_offset_Y = ((aspect_quotient < 1.0f) ? ((gr_screen.center_h - gr_screen.center_h * aspect_quotient) / 2.0f) : 0.0f) + gr_screen.center_offset_y; } else { - Gr_save_resize_X = Gr_resize_X = Gr_full_resize_X; - Gr_save_resize_Y = Gr_resize_Y = Gr_full_resize_Y; + Gr_save_resize_X = Gr_resize_X = Gr_full_center_resize_X; + Gr_save_resize_Y = Gr_resize_Y = Gr_full_center_resize_Y; - Gr_save_menu_offset_X = Gr_menu_offset_X = 0.0f; - Gr_save_menu_offset_Y = Gr_menu_offset_Y = 0.0f; + Gr_save_menu_offset_X = Gr_menu_offset_X = (float)gr_screen.center_offset_x; + Gr_save_menu_offset_Y = Gr_menu_offset_Y = (float)gr_screen.center_offset_y; } Gr_save_menu_zoomed_offset_X = Gr_menu_zoomed_offset_X = Gr_menu_offset_X; @@ -682,9 +854,6 @@ static bool gr_init_sub(int mode, int width, int height, int depth) gr_screen.res = res; gr_screen.aspect = 1.0f; // Normal PC screen - gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = width; - gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = height; - gr_screen.offset_x = gr_screen.offset_x_unscaled = 0; gr_screen.offset_y = gr_screen.offset_y_unscaled = 0; @@ -731,6 +900,7 @@ static bool gr_init_sub(int mode, int width, int height, int depth) bool gr_init(int d_mode, int d_width, int d_height, int d_depth) { int width = 1024, height = 768, depth = 32, mode = GR_OPENGL; + float center_aspect_ratio = -1.0f; const char *ptr = NULL; if ( !Gr_inited ) { @@ -815,6 +985,14 @@ bool gr_init(int d_mode, int d_width, int d_height, int d_depth) height = tmp_height; } } + if (Cmdline_center_res != NULL) { + int tmp_center_width = 0; + int tmp_center_height = 0; + + if ( (sscanf(Cmdline_center_res, "%dx%d", &tmp_center_width, &tmp_center_height) == 2) && (tmp_center_width > 0) && (tmp_center_height > 0) ) { + center_aspect_ratio = (float)tmp_center_width / (float)tmp_center_height; + } + } if (d_mode == GR_DEFAULT) { // OpenGL should be default @@ -845,6 +1023,7 @@ bool gr_init(int d_mode, int d_width, int d_height, int d_depth) else { width = 800; height = 600; + center_aspect_ratio = -1.0f; } } @@ -854,6 +1033,7 @@ bool gr_init(int d_mode, int d_width, int d_height, int d_depth) width = 640; height = 480; depth = 16; + center_aspect_ratio = -1.0f; } // These compiler macros will force windowed mode at the specified resolution if @@ -865,22 +1045,34 @@ bool gr_init(int d_mode, int d_width, int d_height, int d_depth) width = 1280; height = 800; depth = 32; + center_aspect_ratio = -1.0f; Cmdline_window = 1; #elif defined(_FORCE_DEBUG_1024) width = 1024; height = 768; depth = 32; + center_aspect_ratio = -1.0f; Cmdline_window = 1; #elif defined(_FORCE_DEBUG_640) width = 640; height = 480; depth = 32; + center_aspect_ratio = -1.0f; Cmdline_window = 1; #endif #endif + if (center_aspect_ratio <= 0.0f) { + float aspect_ratio = (float)width / (float)height; + if (aspect_ratio > 3.5f) { + center_aspect_ratio = aspect_ratio * 0.3f; + } else { + center_aspect_ratio = aspect_ratio; + } + } + // now try to actually init everything... - if ( gr_init_sub(mode, width, height, depth) == false ) { + if ( gr_init_sub(mode, width, height, depth, center_aspect_ratio) == false ) { return false; } diff --git a/code/graphics/2d.h b/code/graphics/2d.h index d9be1f64bc..edff51465b 100644 --- a/code/graphics/2d.h +++ b/code/graphics/2d.h @@ -95,15 +95,15 @@ typedef struct shader { // gr_get_colors after calling gr_set_colors_fast. typedef struct color { uint screen_sig; + int is_alphacolor; + int alphacolor; + int magic; ubyte red; ubyte green; ubyte blue; ubyte alpha; ubyte ac_type; // The type of alphacolor. See AC_TYPE_??? defines - int is_alphacolor; ubyte raw8; - int alphacolor; - int magic; } color; // Used by the team coloring code @@ -361,9 +361,13 @@ typedef struct screen { int max_w, max_h; // Width and height int max_w_unscaled, max_h_unscaled; int max_w_unscaled_zoomed, max_h_unscaled_zoomed; + int center_w, center_h; // Width and height of center monitor + int center_offset_x, center_offset_y; int save_max_w, save_max_h; // Width and height int save_max_w_unscaled, save_max_h_unscaled; int save_max_w_unscaled_zoomed, save_max_h_unscaled_zoomed; + int save_center_w, save_center_h; // Width and height of center monitor + int save_center_offset_x, save_center_offset_y; int res; // GR_640 or GR_1024 int mode; // What mode gr_init was called with. float aspect, clip_aspect; // Aspect ratio, aspect of clip_width/clip_height @@ -703,11 +707,12 @@ extern screen gr_screen; #define GR_RESIZE_NONE 0 #define GR_RESIZE_FULL 1 -#define GR_RESIZE_MENU 2 -#define GR_RESIZE_MENU_ZOOMED 3 -#define GR_RESIZE_MENU_NO_OFFSET 4 +#define GR_RESIZE_FULL_CENTER 2 +#define GR_RESIZE_MENU 3 +#define GR_RESIZE_MENU_ZOOMED 4 +#define GR_RESIZE_MENU_NO_OFFSET 5 -void gr_set_screen_scale(int x, int y, int zoom_x = -1, int zoom_y = -1, int max_x = gr_screen.max_w, int max_y = gr_screen.max_h, bool force_stretch = false); +void gr_set_screen_scale(int x, int y, int zoom_x = -1, int zoom_y = -1, int max_x = gr_screen.max_w, int max_y = gr_screen.max_h, int center_x = gr_screen.center_w, int center_y = gr_screen.center_h, bool force_stretch = false); void gr_reset_screen_scale(); bool gr_unsize_screen_pos(int *x, int *y, int *w = NULL, int *h = NULL, int resize_mode = GR_RESIZE_FULL); bool gr_resize_screen_pos(int *x, int *y, int *w = NULL, int *h = NULL, int resize_mode = GR_RESIZE_FULL); diff --git a/code/graphics/gropengltnl.cpp b/code/graphics/gropengltnl.cpp index 8c08e7e675..1153b71db7 100644 --- a/code/graphics/gropengltnl.cpp +++ b/code/graphics/gropengltnl.cpp @@ -2102,7 +2102,7 @@ void opengl_tnl_set_material(int flags, uint shader_flags, int tmap_type) if ( shader_flags & SDR_FLAG_MODEL_ENV_MAP) { // 0 == env with non-alpha specmap, 1 == env with alpha specmap - int alpha_spec = bm_has_alpha_channel(SPECMAP); + int alpha_spec = bm_has_alpha_channel(SPECMAP) ? 1 : 0; matrix4 texture_mat; diff --git a/code/hud/hud.cpp b/code/hud/hud.cpp index 2ea0aa267b..2d445ee779 100644 --- a/code/hud/hud.cpp +++ b/code/hud/hud.cpp @@ -669,7 +669,7 @@ void HudGauge::renderString(int x, int y, const char *str) int nx = 0, ny = 0; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -692,7 +692,7 @@ void HudGauge::renderString(int x, int y, int gauge_id, const char *str) int nx = 0, ny = 0; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -707,7 +707,7 @@ void HudGauge::renderString(int x, int y, int gauge_id, const char *str) } if ( gauge_id > -2 ) { - emp_hud_string(x + nx, y + ny, gauge_id, str, true); + emp_hud_string(x + nx, y + ny, gauge_id, str, GR_RESIZE_FULL); } else { gr_string(x + nx, y + ny, str); } @@ -762,7 +762,7 @@ void HudGauge::renderBitmapColor(int frame, int x, int y) emp_hud_jitter(&x, &y); if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -792,7 +792,7 @@ void HudGauge::renderBitmap(int x, int y) emp_hud_jitter(&x, &y); if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -830,7 +830,7 @@ void HudGauge::renderBitmapEx(int frame, int x, int y, int w, int h, int sx, int gr_set_bitmap(frame); if( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -854,7 +854,7 @@ void HudGauge::renderLine(int x1, int y1, int x2, int y2) int nx = 0, ny = 0; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -877,7 +877,7 @@ void HudGauge::renderGradientLine(int x1, int y1, int x2, int y2) int nx = 0, ny = 0; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if(reticle_follow) { nx = HUD_nose_x; @@ -900,7 +900,7 @@ void HudGauge::renderRect(int x, int y, int w, int h) int nx = 0, ny = 0; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -923,7 +923,7 @@ void HudGauge::renderCircle(int x, int y, int diameter) int nx = 0, ny = 0; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; @@ -947,7 +947,7 @@ void HudGauge::setClip(int x, int y, int w, int h) int hy = fl2i(HUD_offset_y); if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); hx = display_offset_x; hy = display_offset_y; @@ -983,7 +983,7 @@ void HudGauge::resetClip() int w, h; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); hx = display_offset_x; hy = display_offset_y; diff --git a/code/hud/hudartillery.cpp b/code/hud/hudartillery.cpp index 3f7ddfc474..e377ca2722 100755 --- a/code/hud/hudartillery.cpp +++ b/code/hud/hudartillery.cpp @@ -400,6 +400,6 @@ void hud_artillery_render() // render how long the player has been painting his target if((Player_ai != NULL) && (Player_ai->artillery_objnum >= 0)){ gr_set_color_fast(&Color_bright_blue); - gr_printf(10, 50, "%f", Player_ai->artillery_lock_time); + gr_printf_no_resize(gr_screen.center_offset_x + 10, gr_screen.center_offset_y + 50, "%f", Player_ai->artillery_lock_time); } } diff --git a/code/hud/hudbrackets.cpp b/code/hud/hudbrackets.cpp index 9e7d81fbbf..b16c8efdb9 100644 --- a/code/hud/hudbrackets.cpp +++ b/code/hud/hudbrackets.cpp @@ -251,7 +251,7 @@ void draw_brackets_diamond(int x1, int y1, int x2, int y2) gr_gradient(center_x + x_delta, y2 - y_delta, center_x, y2); } -void draw_brackets_diamond_quick(int x1, int y1, int x2, int y2, int thick) +void draw_brackets_diamond_quick(int x1, int y1, int x2, int y2) { int width, height, half_width, half_height; int center_x, center_y; diff --git a/code/hud/hudbrackets.h b/code/hud/hudbrackets.h index 03108166dc..79877a0710 100644 --- a/code/hud/hudbrackets.h +++ b/code/hud/hudbrackets.h @@ -23,7 +23,7 @@ void draw_bounding_brackets_subobject(); void draw_brackets_square(int x1, int y1, int x2, int y2, int resize_mode = GR_RESIZE_FULL); void draw_brackets_diamond(int x1, int y1, int x2, int y2); void draw_brackets_square_quick(int x1, int y1, int x2, int y2, int thick=0); -void draw_brackets_diamond_quick(int x1, int y1, int x2, int y2, int thick=0); +void draw_brackets_diamond_quick(int x1, int y1, int x2, int y2); void draw_brackets_dashed_square_quick(int x1, int y1, int x2, int y2); int draw_subsys_brackets(ship_subsys* subsys, int min_width, int min_height, bool draw = true, bool set_color = true, int* draw_coords = NULL); diff --git a/code/hud/hudlock.cpp b/code/hud/hudlock.cpp index d84cf236e3..358c5f727a 100644 --- a/code/hud/hudlock.cpp +++ b/code/hud/hudlock.cpp @@ -426,6 +426,10 @@ int hud_abort_lock() return 1; } + if ( Player_ship->flags2 & SF2_NO_SECONDARY_LOCKON ) { + return 1; + } + // if we're on the same team and the team doesn't attack itself, then don't lock! if ((Player_ship->team == target_team) && (!iff_x_attacks_y(Player_ship->team, target_team))) { diff --git a/code/hud/hudmessage.cpp b/code/hud/hudmessage.cpp index 6e383dbcce..ccd9cc538f 100644 --- a/code/hud/hudmessage.cpp +++ b/code/hud/hudmessage.cpp @@ -407,18 +407,18 @@ void HudGaugeMessages::scrollMessages() } } } else { + bool at_end = m == (active_messages.end() - 1); + + if (at_end) { + // Iterator will be invalid + active_messages.pop_back(); + break; + } + *m = active_messages.back(); active_messages.pop_back(); - if (active_messages.empty()) - { - // We may not use the iterator any longer - break; - } - else - { - continue; - } + continue; } ++m; diff --git a/code/hud/hudparse.cpp b/code/hud/hudparse.cpp index e6a89adf45..739d2770da 100644 --- a/code/hud/hudparse.cpp +++ b/code/hud/hudparse.cpp @@ -377,14 +377,14 @@ void parse_hud_gauges_tbl(const char *filename) if (optional_string("$Required Aspect:")) { // filter aspect ratio. if (optional_string("Full Screen")) { - if ((float)gr_screen.max_w / (float)gr_screen.max_h > 1.5) { + if( (float)gr_screen.center_w / (float)gr_screen.center_h > 1.5) { skip_to_start_of_string("#Gauge Config"); //skip_to_start_of_string_either("#Gauge Config", "#End"); continue; } } else if (optional_string("Wide Screen")) { - if ((float)gr_screen.max_w / (float)gr_screen.max_h <= 1.5) { + if( (float)gr_screen.center_w / (float)gr_screen.center_h <= 1.5) { skip_to_start_of_string("#Gauge Config"); //skip_to_start_of_string_either("#Gauge Config", "#End"); continue; @@ -401,8 +401,8 @@ void parse_hud_gauges_tbl(const char *filename) skip_to_start_of_string("#Gauge Config"); continue; } - else if (min_res[0] == gr_screen.max_w) { - if (min_res[1] > gr_screen.max_h) { + else if (min_res[0] == gr_screen.center_w) { + if (min_res[1] > gr_screen.center_h) { skip_to_start_of_string("#Gauge Config"); continue; } @@ -418,8 +418,8 @@ void parse_hud_gauges_tbl(const char *filename) skip_to_start_of_string("#Gauge Config"); continue; } - else if (max_res[0] == gr_screen.max_w) { - if (max_res[1] < gr_screen.max_h) { + else if (max_res[0] == gr_screen.center_w) { + if (max_res[1] < gr_screen.center_h) { skip_to_start_of_string("#Gauge Config"); continue; } @@ -1083,15 +1083,15 @@ void adjust_base_res(int *base_res, bool scaling = true) // Don't scale gauge if: // no scaling is set and base res is smaller than current res // Avoid HUD blurring caused solely by rounding errors - if ((!scaling && gr_screen.max_w >= base_res[0] && gr_screen.max_h >= base_res[1]) || - (gr_screen.max_w >= base_res[0] && gr_screen.max_h == base_res[1]) || - (gr_screen.max_w == base_res[0] && gr_screen.max_h >= base_res[1])) { - base_res[0] = gr_screen.max_w; - base_res[1] = gr_screen.max_h; + if ((!scaling && gr_screen.center_w >= base_res[0] && gr_screen.center_h >= base_res[1]) || + (gr_screen.center_w >= base_res[0] && gr_screen.center_h == base_res[1]) || + (gr_screen.center_w == base_res[0] && gr_screen.center_h >= base_res[1])) { + base_res[0] = gr_screen.center_w; + base_res[1] = gr_screen.center_h; return; } - float aspect_quotient = ((float)gr_screen.max_w / (float)gr_screen.max_h) / ((float)base_res[0] / (float)base_res[1]); + float aspect_quotient = ((float)gr_screen.center_w / (float)gr_screen.center_h) / ((float)base_res[0] / (float)base_res[1]); if (aspect_quotient >= 1.0) { base_res[0] = (int)(base_res[0] * aspect_quotient); } else { @@ -1099,6 +1099,20 @@ void adjust_base_res(int *base_res, bool scaling = true) } } +void adjust_for_multimonitor(int *base_res, bool set_position, int *coords) +{ + float scale_w = (float)gr_screen.center_w / (float)base_res[0]; + float scale_h = (float)gr_screen.center_h / (float)base_res[1]; + + base_res[0] = fl2ir(base_res[0] * ((float)gr_screen.max_w / (float)gr_screen.center_w)); + base_res[1] = fl2ir(base_res[1] * ((float)gr_screen.max_h / (float)gr_screen.center_h)); + + if (set_position) { + coords[0] += fl2ir(gr_screen.center_offset_x / scale_w); + coords[1] += fl2ir(gr_screen.center_offset_y / scale_h); + } +} + template T* gauge_load_common(int base_w, int base_h, int hud_font, bool scale_gauge, SCP_vector* ship_idx, color *use_clr, float default_origin_x, float default_origin_y, int default_offset_x, int default_offset_y, @@ -1187,7 +1201,12 @@ T* gauge_load_common(int base_w, int base_h, int hud_font, bool scale_gauge, SCP required_string("Display Size:"); stuff_int_list(display_size, 2); + } else { + // adjust for multimonitor setups ONLY if not rendering gauge to a texture + adjust_for_multimonitor(base_res, true, coords); } + } else { + adjust_for_multimonitor(base_res, true, coords); } if (set_colour) { @@ -1316,6 +1335,9 @@ void load_gauge_custom(int base_w, int base_h, int hud_font, bool scale_gauge, S required_string("Display Size:"); stuff_int_list(display_size, 2); + } else { + // adjust for multimonitor setups ONLY if not rendering gauge to a texture + adjust_for_multimonitor(base_res, true, coords); } if ( use_clr != NULL ) { @@ -2992,6 +3014,9 @@ void load_gauge_radar_dradis(int base_w, int base_h, int hud_font, bool scale_ga required_string("Display Size:"); stuff_int_list(display_size, 2); + } else { + // adjust for multimonitor setups ONLY if not rendering gauge to a texture + adjust_for_multimonitor(base_res, true, coords); } parse_sound("Loop Sound:", &loop_snd, "DRADIS HudGauge"); diff --git a/code/hud/hudshield.cpp b/code/hud/hudshield.cpp index 4650052475..397ae01c91 100644 --- a/code/hud/hudshield.cpp +++ b/code/hud/hudshield.cpp @@ -864,7 +864,7 @@ void HudGaugeShield::renderShieldIcon(coord2d coords[6]) int nx = 0, ny = 0, i; if ( gr_screen.rendering_to_texture != -1 ) { - gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true); + gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; diff --git a/code/hud/hudtargetbox.cpp b/code/hud/hudtargetbox.cpp index 098ac0b8e0..f59be5591a 100644 --- a/code/hud/hudtargetbox.cpp +++ b/code/hud/hudtargetbox.cpp @@ -2005,9 +2005,9 @@ void HudGaugeTargetBox::showTargetData(float frametime) char outstr2[256]; if ( Show_target_debug_info && (is_ship == 1) ) { int sx, sy, dy; - sx = 5; + sx = gr_screen.center_offset_x + 5; dy = gr_get_font_height() + 1; - sy = 300 - 7*dy; + sy = gr_screen.center_offset_y + 300 - 7*dy; gr_set_color_fast(&HUD_color_debug); @@ -2033,10 +2033,10 @@ void HudGaugeTargetBox::showTargetData(float frametime) break; } - gr_printf(sx, sy, outstr); + gr_printf_no_resize(sx, sy, outstr); sy += dy; - gr_printf(sx, sy, "Max speed = %d, (%d%%)", (int) shipp->current_max_speed, (int) (100.0f * vm_vec_mag(&target_objp->phys_info.vel)/shipp->current_max_speed)); + gr_printf_no_resize(sx, sy, "Max speed = %d, (%d%%)", (int) shipp->current_max_speed, (int) (100.0f * vm_vec_mag(&target_objp->phys_info.vel)/shipp->current_max_speed)); sy += dy; // data can be found in target montior @@ -2050,7 +2050,7 @@ void HudGaugeTargetBox::showTargetData(float frametime) else sprintf(target_str, "%s", Ships[Objects[aip->target_objnum].instance].ship_name); - gr_printf(sx, sy, "Targ: %s", target_str); + gr_printf_no_resize(sx, sy, "Targ: %s", target_str); sy += dy; dist = vm_vec_dist_quick(&Objects[Player_ai->target_objnum].pos, &Objects[aip->target_objnum].pos); @@ -2059,27 +2059,27 @@ void HudGaugeTargetBox::showTargetData(float frametime) dot = vm_vec_dot(&v2t, &Objects[Player_ai->target_objnum].orient.vec.fvec); // data can be found in target monitor - gr_printf(sx, sy, "Targ dot: %3.2f", dot); + gr_printf_no_resize(sx, sy, "Targ dot: %3.2f", dot); sy += dy; - gr_printf(sx, sy, "Targ dst: %3.2f", dist); + gr_printf_no_resize(sx, sy, "Targ dst: %3.2f", dist); sy += dy; if ( aip->targeted_subsys != NULL ) { sprintf(outstr, "Subsys: %s", aip->targeted_subsys->system_info->subobj_name); - gr_printf(sx, sy, outstr); + gr_printf_no_resize(sx, sy, outstr); } sy += dy; } // print out energy transfer information on the ship - sy = 70; + sy = gr_screen.center_offset_y + 70; sprintf(outstr,"MAX G/E: %.0f/%.0f",shipp->weapon_energy,shipp->current_max_speed); - gr_printf(sx, sy, outstr); + gr_printf_no_resize(sx, sy, outstr); sy += dy; sprintf(outstr,"G/S/E: %.2f/%.2f/%.2f",Energy_levels[shipp->weapon_recharge_index],Energy_levels[shipp->shield_recharge_index],Energy_levels[shipp->engine_recharge_index]); - gr_printf(sx, sy, outstr); + gr_printf_no_resize(sx, sy, outstr); sy += dy; // Show information about attacker. @@ -2103,11 +2103,11 @@ void HudGaugeTargetBox::showTargetData(float frametime) dot = vm_vec_dot(&v2t, &Enemy_attacker->orient.vec.fvec); - gr_printf(sx, sy, "#%i: %s", Enemy_attacker-Objects, Ships[Enemy_attacker->instance].ship_name); + gr_printf_no_resize(sx, sy, "#%i: %s", Enemy_attacker-Objects, Ships[Enemy_attacker->instance].ship_name); sy += dy; - gr_printf(sx, sy, "Targ dist: %5.1f", dist); + gr_printf_no_resize(sx, sy, "Targ dist: %5.1f", dist); sy += dy; - gr_printf(sx, sy, "Targ dot: %3.2f", dot); + gr_printf_no_resize(sx, sy, "Targ dot: %3.2f", dot); sy += dy; } } @@ -2137,14 +2137,14 @@ void HudGaugeTargetBox::showTargetData(float frametime) // Show target size // hud_target_w - gr_printf(sx, sy, "Targ size: %dx%d", Hud_target_w, Hud_target_h ); + gr_printf_no_resize(sx, sy, "Targ size: %dx%d", Hud_target_w, Hud_target_h ); sy += dy; polymodel *pm = model_get(sip->model_num); - gr_printf(sx, sy, "POF:%s", pm->filename ); + gr_printf_no_resize(sx, sy, "POF:%s", pm->filename ); sy += dy; - gr_printf(sx, sy, "Mass: %.2f\n", pm->mass); + gr_printf_no_resize(sx, sy, "Mass: %.2f\n", pm->mass); sy += dy; } } @@ -2155,26 +2155,26 @@ void HudGaugeTargetBox::showTargetData(float frametime) ship_weapon *swp; swp = &shipp->weapons; - sx = 400; - sy = 100; + sx = gr_screen.center_offset_x + 400; + sy = gr_screen.center_offset_y + 100; dy = gr_get_font_height(); sprintf(outstr,"Num primaries: %d", swp->num_primary_banks); - gr_printf(sx,sy,outstr); + gr_printf_no_resize(sx,sy,outstr); sy += dy; for ( i = 0; i < swp->num_primary_banks; i++ ) { sprintf(outstr,"%d. %s", i+1, Weapon_info[swp->primary_bank_weapons[i]].name); - gr_printf(sx,sy,outstr); + gr_printf_no_resize(sx,sy,outstr); sy += dy; } sy += dy; sprintf(outstr,"Num secondaries: %d", swp->num_secondary_banks); - gr_printf(sx,sy,outstr); + gr_printf_no_resize(sx,sy,outstr); sy += dy; for ( i = 0; i < swp->num_secondary_banks; i++ ) { sprintf(outstr,"%d. %s", i+1, Weapon_info[swp->secondary_bank_weapons[i]].name); - gr_printf(sx,sy,outstr); + gr_printf_no_resize(sx,sy,outstr); sy += dy; } } diff --git a/code/lab/lab.cpp b/code/lab/lab.cpp index 191a04b24b..abb32fb4e3 100644 --- a/code/lab/lab.cpp +++ b/code/lab/lab.cpp @@ -1269,7 +1269,7 @@ void labviewer_do_render(float frametime) if ( (Lab_model_num < 0) && (Lab_bitmap_id < 0) ) { gr_get_string_size(&w, &h, "Viewer off"); gr_set_color_fast(&Color_white); - gr_string(gr_screen.clip_right - w, gr_screen.clip_bottom - h, "Viewer off", GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x + gr_screen.center_w - w, gr_screen.center_offset_y + gr_screen.center_h - h, "Viewer off", GR_RESIZE_NONE); return; } @@ -1287,7 +1287,7 @@ void labviewer_do_render(float frametime) if ( strlen(Lab_model_filename) ) { gr_get_string_size(&w, &h, Lab_model_filename); gr_set_color_fast(&Color_white); - gr_string(gr_screen.clip_right - w, gr_screen.clip_bottom - h, Lab_model_filename, GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x + gr_screen.center_w - w, gr_screen.center_offset_y + gr_screen.center_h - h, Lab_model_filename, GR_RESIZE_NONE); } } else if (Lab_bitmap_id >= 0) { gr_scene_texture_begin(); @@ -1300,7 +1300,7 @@ void labviewer_do_render(float frametime) if ( strlen(Lab_bitmap_filename) ) { gr_get_string_size(&w, &h, Lab_bitmap_filename); gr_set_color_fast(&Color_white); - gr_string(gr_screen.clip_right - w, gr_screen.clip_bottom - h, Lab_bitmap_filename, GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x + gr_screen.center_w - w, gr_screen.center_offset_y + gr_screen.center_h - h, Lab_bitmap_filename, GR_RESIZE_NONE); } } @@ -1314,26 +1314,26 @@ void labviewer_do_render(float frametime) gr_set_color_fast(&Color_white); if (frametotal != 0.0f) { - gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - gr_get_font_height(), "FPS: %i", fl2i(Framerate + 0.5f)); + gr_printf_no_resize(gr_screen.center_offset_x + 2, gr_screen.center_offset_y + gr_screen.center_h - gr_get_font_height(), "FPS: %i", fl2i(Framerate + 0.5f)); } else { - gr_string(gr_screen.clip_left + 10, gr_screen.clip_bottom - gr_get_font_height(), "FPS: ?", GR_RESIZE_NONE); + gr_string(gr_screen.center_offset_x + 10, gr_screen.center_offset_y + gr_screen.center_h - gr_get_font_height(), "FPS: ?", GR_RESIZE_NONE); } //Print FXAA preset if (Cmdline_fxaa && !PostProcessing_override) - gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height() * 2) - 3, "FXAA Preset: %i", Cmdline_fxaa_preset); + gr_printf_no_resize(gr_screen.center_offset_x + 2, gr_screen.center_offset_y + gr_screen.center_h - (gr_get_font_height() * 2) - 3, "FXAA Preset: %i", Cmdline_fxaa_preset); //Print bloom intensity if (Cmdline_bloom_intensity && !PostProcessing_override) - gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height() * 3) - 3, "Bloom intensity: %i", Cmdline_bloom_intensity); + gr_printf_no_resize(gr_screen.center_offset_x + 2, gr_screen.center_offset_y + gr_screen.center_h - (gr_get_font_height() * 3) - 3, "Bloom intensity: %i", Cmdline_bloom_intensity); //Print current Team Color setting, if any if (Lab_team_color != "") - gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height() * 4) - 3, "Use T and Y to cycle through available Team Color settings. Current: %s", Lab_team_color.c_str()); + gr_printf_no_resize(gr_screen.center_offset_x + 2, gr_screen.center_offset_y + gr_screen.center_h - (gr_get_font_height() * 4) - 3, "Use T and Y to cycle through available Team Color settings. Current: %s", Lab_team_color.c_str()); //Display helpful text if (!PostProcessing_override) - gr_printf_no_resize(gr_screen.clip_left + 70, gr_screen.clip_bottom - gr_get_font_height(), "Use number keys to switch between FXAA presets. B and N can be used to adjust bloom."); + gr_printf_no_resize(gr_screen.center_offset_x + 70, gr_screen.center_offset_y + gr_screen.center_h - gr_get_font_height(), "Use number keys to switch between FXAA presets. B and N can be used to adjust bloom."); } void labviewer_exit(Button *caller) @@ -1363,12 +1363,12 @@ void labviewer_close_class_window(GUIObject *caller) void labviewer_set_class_window(int mode) { if (Lab_class_window == NULL) { - Lab_class_window = (Window*)Lab_screen->Add(new Window("Class Window", 50, 50)); + Lab_class_window = (Window*)Lab_screen->Add(new Window("Class Window", gr_screen.center_offset_x + 50, gr_screen.center_offset_y + 50)); Lab_class_window->SetCloseFunction(labviewer_close_class_window); } if (Lab_class_toolbar == NULL) { - Lab_class_toolbar = (Window*)Lab_screen->Add(new Window("Class Toolbar", 0, Lab_toolbar->GetHeight(), -1, -1, WS_NOTITLEBAR | WS_NONMOVEABLE)); + Lab_class_toolbar = (Window*)Lab_screen->Add(new Window("Class Toolbar", gr_screen.center_offset_x + 0, gr_screen.center_offset_y + Lab_toolbar->GetHeight(), -1, -1, WS_NOTITLEBAR | WS_NONMOVEABLE)); } // clear out all existing children @@ -1559,7 +1559,7 @@ void labviewer_close_flags_window(GUIObject *caller) void labviewer_make_flags_window(Button *caller) { if (Lab_flags_window == NULL) { - Lab_flags_window = (Window*) Lab_screen->Add(new Window("Flags Window", gr_screen.max_w - 205, 200)); + Lab_flags_window = (Window*) Lab_screen->Add(new Window("Flags Window", gr_screen.center_offset_x + gr_screen.center_w - 205, gr_screen.center_offset_y + 200)); Lab_flags_window->SetCloseFunction(labviewer_close_flags_window); } @@ -1864,7 +1864,7 @@ void labviewer_make_variables_window(Button *caller) return; } - Lab_variables_window = (Window*)Lab_screen->Add(new Window("Class Variables", gr_screen.max_w - (VAR_POS_RIGHTX + VAR_POS_RIGHTWIDTH + 25), 200)); + Lab_variables_window = (Window*)Lab_screen->Add(new Window("Class Variables", gr_screen.center_offset_x + gr_screen.center_w - (VAR_POS_RIGHTX + VAR_POS_RIGHTWIDTH + 25), gr_screen.center_offset_y + 200)); // set our new title if (Lab_mode == LAB_MODE_SHIP) { @@ -1921,7 +1921,7 @@ void labviewer_make_render_options_window(Button *caller) return; } - Lab_render_options_window = (Window*)Lab_screen->Add(new Window("Render Options", gr_screen.max_w - 300, 200)); + Lab_render_options_window = (Window*)Lab_screen->Add(new Window("Render Options", gr_screen.center_offset_x + gr_screen.center_w - 300, gr_screen.center_offset_y + 200)); Assert( Lab_render_options_window != NULL ); // add all of the flags that we want/need... @@ -2031,9 +2031,9 @@ void labviewer_make_desc_window(Button *caller) return; } - Lab_description_window = (Window*)Lab_screen->Add(new Window("Description", gr_screen.max_w - gr_screen.max_w/3 - 50, - gr_screen.max_h - gr_screen.max_h/6 - 50, gr_screen.max_w/3, - gr_screen.max_h/6)); + Lab_description_window = (Window*)Lab_screen->Add(new Window("Description", gr_screen.center_offset_x + gr_screen.center_w - gr_screen.center_w/3 - 50, + gr_screen.center_offset_y + gr_screen.center_h - gr_screen.center_h/6 - 50, gr_screen.center_w/3, + gr_screen.center_h/6)); Lab_description_text = (Text*)Lab_description_window->AddChild(new Text("Description Text", "No ship selected.", 0, 0)); labviewer_update_desc_window(); @@ -2405,7 +2405,7 @@ void lab_init() //We start by creating the screen/toolbar Lab_screen = GUI_system.PushScreen(new GUIScreen("Lab")); - Lab_toolbar = (Window*)Lab_screen->Add(new Window("Toolbar", 0, 0, -1, -1, WS_NOTITLEBAR | WS_NONMOVEABLE)); + Lab_toolbar = (Window*)Lab_screen->Add(new Window("Toolbar", gr_screen.center_offset_x, gr_screen.center_offset_y, -1, -1, WS_NOTITLEBAR | WS_NONMOVEABLE)); // start filling the main toolbar x = 0; diff --git a/code/lab/wmcgui.cpp b/code/lab/wmcgui.cpp index e79f6714fa..567d5df16a 100644 --- a/code/lab/wmcgui.cpp +++ b/code/lab/wmcgui.cpp @@ -1624,7 +1624,7 @@ void Button::DoDraw(float frametime) } else { gr_set_color_fast(&Color_text_selected); } - draw_open_rect(Coords[0], Coords[1], Coords[2], Coords[3], false); + draw_open_rect(Coords[0], Coords[1], Coords[2], Coords[3], GR_RESIZE_NONE); int half_x, half_y; gr_get_string_size(&half_x, &half_y, Caption.c_str()); @@ -2398,7 +2398,7 @@ void Checkbox::DoDraw(float frametime) gr_set_color_fast(&Color_text_normal); } - draw_open_rect(CheckCoords[0], CheckCoords[1], CheckCoords[2], CheckCoords[3], false); + draw_open_rect(CheckCoords[0], CheckCoords[1], CheckCoords[2], CheckCoords[3], GR_RESIZE_NONE); if ( (IsChecked && ((FlagPtr == NULL) && (BoolFlagPtr == NULL))) || ((FlagPtr != NULL) && ((*FlagPtr) & Flag)) diff --git a/code/math/fvi.cpp b/code/math/fvi.cpp index 08809466fa..c3a562a447 100644 --- a/code/math/fvi.cpp +++ b/code/math/fvi.cpp @@ -22,10 +22,9 @@ #define UNINITIALIZED_VALUE -1234567.8f #define WARN_DIST 1.0 -void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 ); +static void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 ); - -float matrix_determinant_from_vectors(vec3d *v1,vec3d *v2,vec3d *v3) +static float matrix_determinant_from_vectors(const vec3d *v1, const vec3d *v2, const vec3d *v3) { float ans; ans = v1->xyz.x * v2->xyz.y * v3->xyz.z; @@ -44,7 +43,7 @@ float matrix_determinant_from_vectors(vec3d *v1,vec3d *v2,vec3d *v3) * * lines: L1 = P1 + V1s and L2 = P2 + V2t */ -void fvi_two_lines_in_3space(vec3d *p1, vec3d *v1, vec3d *p2, vec3d *v2, float *s, float *t) +void fvi_two_lines_in_3space(const vec3d *p1, const vec3d *v1, const vec3d *p2, const vec3d *v2, float *s, float *t) { vec3d cross,delta; vm_vec_crossprod(&cross, v1, v2); @@ -73,8 +72,8 @@ void fvi_two_lines_in_3space(vec3d *p1, vec3d *v1, vec3d *p2, vec3d *v2, float * * @param plane_norm Plane description, a normal * @param point A point to test */ -float fvi_point_dist_plane( vec3d *plane_pnt, vec3d *plane_norm, - vec3d *point +float fvi_point_dist_plane(const vec3d *plane_pnt,const vec3d *plane_norm, + const vec3d *point ) { float dist,D; @@ -121,8 +120,8 @@ float fvi_point_dist_plane( vec3d *plane_pnt, vec3d *plane_norm, * intersection if the return value is between 0 and 1. */ float fvi_ray_plane(vec3d *new_pnt, - vec3d *plane_pnt,vec3d *plane_norm, - vec3d *ray_origin,vec3d *ray_direction, + const vec3d *plane_pnt, const vec3d *plane_norm, + const vec3d *ray_origin, const vec3d *ray_direction, float rad) { vec3d w; @@ -165,8 +164,8 @@ float fvi_ray_plane(vec3d *new_pnt, */ int fvi_segment_plane(vec3d *new_pnt, - vec3d *plane_pnt,vec3d *plane_norm, - vec3d *p0,vec3d *p1,float rad) + const vec3d *plane_pnt, const vec3d *plane_norm, + const vec3d *p0, const vec3d *p1,float rad) { float t; vec3d d; @@ -190,7 +189,7 @@ int fvi_segment_plane(vec3d *new_pnt, * vector defined by p0,p1 * @return 1 if intersects, and fills in intp, else returns 0 */ -int fvi_segment_sphere(vec3d *intp,vec3d *p0,vec3d *p1,vec3d *sphere_pos,float sphere_rad) +int fvi_segment_sphere(vec3d *intp, const vec3d *p0, const vec3d *p1, const vec3d *sphere_pos, float sphere_rad) { vec3d d,dn,w,closest_point; float mag_d,dist,w_dist,int_dist; @@ -257,7 +256,7 @@ int fvi_segment_sphere(vec3d *intp,vec3d *p0,vec3d *p1,vec3d *sphere_pos,float s * vector defined by p0,p1 * @return 1 if intersects, and fills in intp. else returns 0 */ -int fvi_ray_sphere(vec3d *intp,vec3d *p0,vec3d *p1,vec3d *sphere_pos,float sphere_rad) +int fvi_ray_sphere(vec3d *intp, const vec3d *p0, const vec3d *p1, const vec3d *sphere_pos,float sphere_rad) { vec3d d,dn,w,closest_point; float mag_d,dist,w_dist,int_dist; @@ -323,7 +322,7 @@ int fvi_ray_sphere(vec3d *intp,vec3d *p0,vec3d *p1,vec3d *sphere_pos,float spher * the point where the ray begins inside the box. * Fast ray-box intersection taken from Graphics Gems I, pages 395,736. */ -int fvi_ray_boundingbox( vec3d *min, vec3d *max, vec3d * p0, vec3d *pdir, vec3d *hitpt ) +int fvi_ray_boundingbox(const vec3d *min, const vec3d *max, const vec3d * p0, const vec3d *pdir, vec3d *hitpt ) { int middle = ((1<<0) | (1<<1) | (1<<2)); int i; @@ -389,7 +388,7 @@ int fvi_ray_boundingbox( vec3d *min, vec3d *max, vec3d * p0, vec3d *pdir, vec3d * Given largest componant of normal, return i & j * If largest componant is negative, swap i & j */ -int ij_table[3][2] = { +static int ij_table[3][2] = { {2,1}, //pos x biggest {0,2}, //pos y biggest {1,0}, //pos z biggest @@ -421,9 +420,10 @@ int ij_table[3][2] = { * and never need doubles. -JAS Aug22,1997 */ #define delta 0.0001f -int fvi_point_face(vec3d *checkp, int nv, vec3d **verts, vec3d * norm1, float *u_out,float *v_out, uv_pair * uvls ) +int fvi_point_face(const vec3d *checkp, int nv, vec3d const *const *verts, const vec3d * norm1, float *u_out,float *v_out, const uv_pair * uvls ) { - float *norm, *P; + const float *norm; + const float *P; vec3d t; int i0, i1,i2; @@ -499,7 +499,7 @@ int fvi_point_face(vec3d *checkp, int nv, vec3d **verts, vec3d * norm1, float *u // // **************************************************************************** -int check_sphere_point( vec3d *point, vec3d *sphere_start, vec3d *sphere_vel, float radius, float *collide_time ); +static int check_sphere_point(const vec3d *point, const vec3d *sphere_start, const vec3d *sphere_vel, float radius, float *collide_time ); /** * Returns whether a sphere hits a given plane in the time [0,1] @@ -517,8 +517,8 @@ int check_sphere_point( vec3d *point, vec3d *sphere_start, vec3d *sphere_vel, fl * * @return 1 if sphere may be in contact with plane in time range [0-1], 0 otherwise */ -int fvi_sphere_plane(vec3d *intersect_point, vec3d *sphere_center_start, vec3d *sphere_velocity, float sphere_radius, - vec3d *plane_normal, vec3d *plane_point, float *hit_time, float *crossing_time) +int fvi_sphere_plane(vec3d *intersect_point, const vec3d *sphere_center_start, const vec3d *sphere_velocity, float sphere_radius, + const vec3d *plane_normal, const vec3d *plane_point, float *hit_time, float *crossing_time) { float D, xs0_dot_norm, vs_dot_norm; float t1, t2; @@ -571,7 +571,7 @@ int fvi_sphere_plane(vec3d *intersect_point, vec3d *sphere_center_start, vec3d * * @param edge_point2 second edge point * @param collide_time actual time of the collision */ -int fvi_sphere_perp_edge(vec3d *intersect_point, vec3d *sphere_center_start, vec3d *sphere_velocity, +int fvi_sphere_perp_edge(vec3d *intersect_point, const vec3d *sphere_center_start, const vec3d *sphere_velocity, float sphere_radius, vec3d *edge_point1, vec3d *edge_point2, float *collide_time) { // find the intersection in the plane normal to sphere velocity and edge velocity @@ -643,7 +643,7 @@ int fvi_sphere_perp_edge(vec3d *intersect_point, vec3d *sphere_center_start, vec * @param radius radius of sphere * @param collide_time time of first collision with t >= 0 */ -int check_sphere_point( vec3d *point, vec3d *sphere_start, vec3d *sphere_vel, float radius, float *collide_time ) +static int check_sphere_point(const vec3d *point, const vec3d *sphere_start, const vec3d *sphere_vel, float radius, float *collide_time ) { vec3d delta_x; float delta_x_sqr, vs_sqr, delta_x_dot_vs; @@ -695,7 +695,7 @@ int check_sphere_point( vec3d *point, vec3d *sphere_start, vec3d *sphere_vel, fl * * @return 1 if sphere hits polyedge, 0 if sphere misses */ -int fvi_polyedge_sphereline(vec3d *hit_point, vec3d *xs0, vec3d *vs, float Rs, int nv, vec3d **verts, float *hit_time) +int fvi_polyedge_sphereline(vec3d *hit_point, const vec3d *xs0, const vec3d *vs, float Rs, int nv, vec3d const *const *verts, float *hit_time) { int i; vec3d v0, v1; @@ -924,7 +924,7 @@ Hit: * @param line_point1 first point on the line * @param line_point2 second point on the line */ -void fvi_closest_point_on_line_segment(vec3d *closest_point, vec3d *fixed_point, vec3d *line_point1, vec3d *line_point2) +void fvi_closest_point_on_line_segment(vec3d *closest_point, const vec3d *fixed_point, const vec3d *line_point1, const vec3d *line_point2) { vec3d delta_x, line_velocity; float t; @@ -958,7 +958,7 @@ void fvi_closest_point_on_line_segment(vec3d *closest_point, vec3d *fixed_point, * * @return 1 if spheres overlap, 0 otherwise */ -int fvi_check_sphere_sphere(vec3d *x_p0, vec3d *x_p1, vec3d *x_s0, vec3d *x_s1, float radius_p, float radius_s, float *t1, float *t2) +int fvi_check_sphere_sphere(const vec3d *x_p0, const vec3d *x_p1, const vec3d *x_s0, const vec3d *x_s1, float radius_p, float radius_s, float *t1, float *t2) { vec3d delta_x, delta_v; float discriminant, separation, delta_x_dot_delta_v, delta_v_sqr, delta_x_sqr; @@ -1033,7 +1033,7 @@ int fvi_check_sphere_sphere(vec3d *x_p0, vec3d *x_p1, vec3d *x_s0, vec3d *x_s1, * * @return 0 if no collision is possible, 1 if collision may be possible */ -int fvi_cull_polyface_sphere(vec3d *poly_center, float poly_r, vec3d *sphere_start, vec3d *sphere_end, float sphere_r) +int fvi_cull_polyface_sphere(const vec3d *poly_center, float poly_r, const vec3d *sphere_start, const vec3d *sphere_end, float sphere_r) { vec3d closest_point, closest_separation; float max_sep; @@ -1053,7 +1053,7 @@ int fvi_cull_polyface_sphere(vec3d *poly_center, float poly_r, vec3d *sphere_sta /** * Finds the closest points between two lines */ -void fvi_closest_line_line( vec3d *x0, vec3d *vx, vec3d *y0, vec3d *vy, float *x_time, float *y_time ) +void fvi_closest_line_line(const vec3d *x0, const vec3d *vx, const vec3d *y0, const vec3d *vy, float *x_time, float *y_time ) { vec3d vx_cross_vy, delta_l, delta_l_cross_vx, delta_l_cross_vy; float denominator; @@ -1071,7 +1071,7 @@ void fvi_closest_line_line( vec3d *x0, vec3d *vx, vec3d *y0, vec3d *vy, float *x } // -------------------------------------------------------------------------------------------------------------------- -void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 ) +static void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 ) { float root = fl_sqrt(discriminant); @@ -1096,7 +1096,7 @@ void accurate_square_root( float A, float B, float C, float discriminant, float * * @return 1 if inside, 0 otherwise. */ -int project_point_onto_bbox(vec3d *mins, vec3d *maxs, vec3d *start, vec3d *box_pt) +int project_point_onto_bbox(const vec3d *mins, const vec3d *maxs, const vec3d *start, vec3d *box_pt) { int inside = TRUE; diff --git a/code/math/fvi.h b/code/math/fvi.h index e507ef0fed..f39eb11bd7 100644 --- a/code/math/fvi.h +++ b/code/math/fvi.h @@ -15,7 +15,7 @@ #include "globalincs/pstypes.h" //finds distance from point to plane -float fvi_point_dist_plane( vec3d *plane_pnt,vec3d *plane_norm, vec3d *point); +float fvi_point_dist_plane(const vec3d *plane_pnt, const vec3d *plane_norm, const vec3d *point); // fvi functions - fvi stands for Find Vector Intersection // fvi_a_b - means find the intersection of something of type a with something of type b @@ -54,8 +54,8 @@ float fvi_point_dist_plane( vec3d *plane_pnt,vec3d *plane_norm, vec3d *point); // intersection if the return value is between 0 and 1. float fvi_ray_plane(vec3d *new_pnt, - vec3d *plane_pnt,vec3d *plane_norm, // Plane description, a point and a normal - vec3d *ray_origin,vec3d *ray_direction, // Ray description, a point and a direction + const vec3d *plane_pnt, const vec3d *plane_norm, // Plane description, a point and a normal + const vec3d *ray_origin, const vec3d *ray_direction, // Ray description, a point and a direction float rad); @@ -64,7 +64,7 @@ float fvi_ray_plane(vec3d *new_pnt, //new_pnt is the found point on the plane //plane_pnt & plane_norm describe the plane //p0 & p1 are the ends of the line -int fvi_segment_plane(vec3d *new_pnt, vec3d *plane_pnt, vec3d *plane_norm, vec3d *p0, vec3d *p1, float rad); +int fvi_segment_plane(vec3d *new_pnt, const vec3d *plane_pnt, const vec3d *plane_norm, const vec3d *p0, const vec3d *p1, float rad); // fvi_point_face @@ -79,7 +79,7 @@ int fvi_segment_plane(vec3d *new_pnt, vec3d *plane_pnt, vec3d *plane_norm, vec3d // u_out,vout - if not null and v_out not null and uvls not_null and point is on face, the uv's of where it hit // uvls - a list of uv pairs for each vertex // This replaces the old check_point_to_face & find_hitpoint_uv -int fvi_point_face(vec3d *checkp, int nv, vec3d **verts, vec3d * norm1, float *u_out, float *v_out, uv_pair * uvls ); +int fvi_point_face(const vec3d *checkp, int nv, vec3d const *const *verts, const vec3d * norm1, float *u_out, float *v_out, const uv_pair * uvls ); //maybe this routine should just return the distance and let the caller @@ -88,13 +88,13 @@ int fvi_point_face(vec3d *checkp, int nv, vec3d **verts, vec3d * norm1, float *u //vector defined by p0,p1 //returns 1 if intersects, and fills in intp //else returns 0 -int fvi_segment_sphere(vec3d *intp, vec3d *p0, vec3d *p1, vec3d *sphere_pos, float sphere_rad); +int fvi_segment_sphere(vec3d *intp, const vec3d *p0, const vec3d *p1, const vec3d *sphere_pos, float sphere_rad); //determine if and where a ray intersects with a sphere //vector defined by p0,p1 //returns 1 if intersects, and fills in intp //else returns 0 -int fvi_ray_sphere(vec3d *intp, vec3d *p0, vec3d *p1, vec3d *sphere_pos, float sphere_rad); +int fvi_ray_sphere(vec3d *intp, const vec3d *p0, const vec3d *p1, const vec3d *sphere_pos, float sphere_rad); //============================================================== @@ -104,15 +104,15 @@ int fvi_ray_sphere(vec3d *intp, vec3d *p0, vec3d *p1, vec3d *sphere_pos, float s // from min to max. If there was an intersection, then hitpt will contain // the point where the ray begins inside the box. // Fast ray-box intersection taken from Graphics Gems I, pages 395,736. -int fvi_ray_boundingbox( vec3d *min, vec3d *max, vec3d * p0, vec3d *pdir, vec3d *hitpt ); +int fvi_ray_boundingbox(const vec3d *min, const vec3d *max, const vec3d * p0, const vec3d *pdir, vec3d *hitpt ); // sphere polygon collision prototypes // Given a polygon vertex list and a moving sphere, find the first contact the sphere makes with the edge, if any -int fvi_polyedge_sphereline(vec3d *hit_point, vec3d *xs0, vec3d *vs, float Rs, int nv, vec3d **verts, float *hit_time); +int fvi_polyedge_sphereline(vec3d *hit_point, const vec3d *xs0, const vec3d *vs, float Rs, int nv, vec3d const *const *verts, float *hit_time); -int fvi_sphere_plane(vec3d *intersect_point, vec3d *sphere_center_start, vec3d *sphere_velocity, float sphere_radius, - vec3d *plane_normal, vec3d *plane_point, float *hit_time, float *delta_time); +int fvi_sphere_plane(vec3d *intersect_point, const vec3d *sphere_center_start, const vec3d *sphere_velocity, float sphere_radius, + const vec3d *plane_normal, const vec3d *plane_point, float *hit_time, float *delta_time); // finds the point of intersection between two lines or the closest points if lines do not intersect // closest points - line 1: p1 + v1 * s, line 2: p2 + v2 * t @@ -122,7 +122,7 @@ int fvi_sphere_plane(vec3d *intersect_point, vec3d *sphere_center_start, vec3d * // v2 - vector direction of line 2 // s - parameter of intersection of line 1 // t - parameter of intersection of line 2 -void fvi_two_lines_in_3space(vec3d *p1, vec3d *v1, vec3d *p2, vec3d *v2, float *s, float *t); +void fvi_two_lines_in_3space(const vec3d *p1, const vec3d *v1, const vec3d *p2, const vec3d *v2, float *s, float *t); // vec3d mins - minimum extents of bbox // vec3d maxs - maximum extents of bbox @@ -130,6 +130,6 @@ void fvi_two_lines_in_3space(vec3d *p1, vec3d *v1, vec3d *p2, vec3d *v2, float * // vec3d box_pt - point in bbox reference frame. // NOTE: if a coordinate of start is *inside* the bbox, it is *not* moved to surface of bbox // return: 1 if inside, 0 otherwise. -int project_point_onto_bbox(vec3d *mins, vec3d *maxs, vec3d *start, vec3d *box_pt); +int project_point_onto_bbox(const vec3d *mins, const vec3d *maxs, const vec3d *start, vec3d *box_pt); #endif diff --git a/code/math/vecmat.cpp b/code/math/vecmat.cpp index c67360db2f..f6608c6388 100755 --- a/code/math/vecmat.cpp +++ b/code/math/vecmat.cpp @@ -22,8 +22,6 @@ #define SMALL_NUM 1e-7 #define SMALLER_NUM 1e-20 #define CONVERT_RADIANS 0.017453 // conversion factor from degrees to radians -int index_largest (float a, float b, float c); // returns index of largest, NO_LARGEST if all less than SMALL_NUM - vec3d vmd_zero_vector = ZERO_VECTOR; vec3d vmd_x_vector = { { { 1.0f, 0.0f, 0.0f } } }; @@ -96,7 +94,7 @@ float atan2_safe(float y, float x) // // finds projection of a vector along a unit (normalized) vector // -float vm_vec_projection_parallel(vec3d *component, vec3d *src, vec3d *unit_vec) +float vm_vec_projection_parallel(vec3d *component, const vec3d *src, const vec3d *unit_vec) { float mag; Assert( vm_vec_mag(unit_vec) > 0.999f && vm_vec_mag(unit_vec) < 1.001f ); @@ -111,7 +109,7 @@ float vm_vec_projection_parallel(vec3d *component, vec3d *src, vec3d *unit_vec) // // finds projection of a vector onto a plane specified by a unit normal vector // -void vm_vec_projection_onto_plane(vec3d *projection, vec3d *src, vec3d *unit_normal) +void vm_vec_projection_onto_plane(vec3d *projection, const vec3d *src, const vec3d *unit_normal) { float mag; Assert( vm_vec_mag(unit_normal) > 0.999f && vm_vec_mag(unit_normal) < 1.001f ); @@ -127,7 +125,7 @@ void vm_vec_projection_onto_plane(vec3d *projection, vec3d *src, vec3d *unit_nor // finds the point on a plane closest to a given point // moves the point in the direction of the plane normal until it is on the plane // -void vm_project_point_onto_plane(vec3d *new_point, vec3d *point, vec3d *plane_normal, vec3d *plane_point) +void vm_project_point_onto_plane(vec3d *new_point, const vec3d *point, const vec3d *plane_normal, const vec3d *plane_point) { float D; // plane constant in Ax+By+Cz+D = 0 or dot(X,n) - dot(Xp,n) = 0, so D = -dot(Xp,n) float dist; @@ -159,7 +157,7 @@ void vm_set_identity(matrix *m) //adds two vectors, fills in dest, returns ptr to dest //ok for dest to equal either source, but should use vm_vec_add2() if so #ifndef _INLINE_VECMAT -void vm_vec_add(vec3d *dest,vec3d *src0,vec3d *src1) +void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1) { dest->xyz.x = src0->xyz.x + src1->xyz.x; dest->xyz.y = src0->xyz.y + src1->xyz.y; @@ -170,7 +168,7 @@ void vm_vec_add(vec3d *dest,vec3d *src0,vec3d *src1) //subs two vectors, fills in dest, returns ptr to dest //ok for dest to equal either source, but should use vm_vec_sub2() if so #ifndef _INLINE_VECMAT -void vm_vec_sub(vec3d *dest,vec3d *src0,vec3d *src1) +void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1) { dest->xyz.x = src0->xyz.x - src1->xyz.x; dest->xyz.y = src0->xyz.y - src1->xyz.y; @@ -182,7 +180,7 @@ void vm_vec_sub(vec3d *dest,vec3d *src0,vec3d *src1) //adds one vector to another. returns ptr to dest //dest can equal source #ifndef _INLINE_VECMAT -void vm_vec_add2(vec3d *dest,vec3d *src) +void vm_vec_add2(vec3d *dest, const vec3d *src) { dest->xyz.x += src->xyz.x; dest->xyz.y += src->xyz.y; @@ -193,7 +191,7 @@ void vm_vec_add2(vec3d *dest,vec3d *src) //subs one vector from another, returns ptr to dest //dest can equal source #ifndef _INLINE_VECMAT -void vm_vec_sub2(vec3d *dest,vec3d *src) +void vm_vec_sub2(vec3d *dest, const vec3d *src) { dest->xyz.x -= src->xyz.x; dest->xyz.y -= src->xyz.y; @@ -203,7 +201,7 @@ void vm_vec_sub2(vec3d *dest,vec3d *src) //averages n vectors. returns ptr to dest //dest can equal either source -vec3d *vm_vec_avg_n(vec3d *dest, int n, vec3d src[]) +vec3d *vm_vec_avg_n(vec3d *dest, int n, const vec3d src[]) { float x=0,y=0,z=0; @@ -223,7 +221,7 @@ vec3d *vm_vec_avg_n(vec3d *dest, int n, vec3d src[]) //averages two vectors. returns ptr to dest //dest can equal either source -vec3d *vm_vec_avg(vec3d *dest,vec3d *src0,vec3d *src1) +vec3d *vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1) { dest->xyz.x = (src0->xyz.x + src1->xyz.x) * 0.5f; dest->xyz.y = (src0->xyz.y + src1->xyz.y) * 0.5f; @@ -234,7 +232,7 @@ vec3d *vm_vec_avg(vec3d *dest,vec3d *src0,vec3d *src1) //averages four vectors. returns ptr to dest //dest can equal any source -vec3d *vm_vec_avg3(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2) +vec3d *vm_vec_avg3(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2) { dest->xyz.x = (src0->xyz.x + src1->xyz.x + src2->xyz.x) * 0.333333333f; dest->xyz.y = (src0->xyz.y + src1->xyz.y + src2->xyz.y) * 0.333333333f; @@ -244,7 +242,7 @@ vec3d *vm_vec_avg3(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2) //averages four vectors. returns ptr to dest //dest can equal any source -vec3d *vm_vec_avg4(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2,vec3d *src3) +vec3d *vm_vec_avg4(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2, const vec3d *src3) { dest->xyz.x = (src0->xyz.x + src1->xyz.x + src2->xyz.x + src3->xyz.x) * 0.25f; dest->xyz.y = (src0->xyz.y + src1->xyz.y + src2->xyz.y + src3->xyz.y) * 0.25f; @@ -255,7 +253,7 @@ vec3d *vm_vec_avg4(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2,vec3d *src3) //scales a vector in place. #ifndef _INLINE_VECMAT -void vm_vec_scale(vec3d *dest,float s) +void vm_vec_scale(vec3d *dest, float s) { dest->xyz.x = dest->xyz.x * s; dest->xyz.y = dest->xyz.y * s; @@ -266,7 +264,7 @@ void vm_vec_scale(vec3d *dest,float s) //scales and copies a vector. #ifndef _INLINE_VECMAT -void vm_vec_copy_scale(vec3d *dest,vec3d *src,float s) +void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s) { dest->xyz.x = src->xyz.x*s; dest->xyz.y = src->xyz.y*s; @@ -277,7 +275,7 @@ void vm_vec_copy_scale(vec3d *dest,vec3d *src,float s) //scales a vector, adds it to another, and stores in a 3rd vector //dest = src1 + k * src2 #ifndef _INLINE_VECMAT -void vm_vec_scale_add(vec3d *dest,vec3d *src1,vec3d *src2,float k) +void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k) { dest->xyz.x = src1->xyz.x + src2->xyz.x*k; dest->xyz.y = src1->xyz.y + src2->xyz.y*k; @@ -287,7 +285,7 @@ void vm_vec_scale_add(vec3d *dest,vec3d *src1,vec3d *src2,float k) //scales a vector, subtracts it to another, and stores in a 3rd vector //dest = src1 - k * src2 -void vm_vec_scale_sub(vec3d *dest, vec3d *src1, vec3d *src2, float k) +void vm_vec_scale_sub(vec3d *dest, const vec3d *src1, const vec3d *src2, float k) { dest->xyz.x = src1->xyz.x - src2->xyz.x*k; dest->xyz.y = src1->xyz.y - src2->xyz.y*k; @@ -297,7 +295,7 @@ void vm_vec_scale_sub(vec3d *dest, vec3d *src1, vec3d *src2, float k) //scales a vector and adds it to another //dest += k * src #ifndef _INLINE_VECMAT -void vm_vec_scale_add2(vec3d *dest,vec3d *src,float k) +void vm_vec_scale_add2(vec3d *dest, const vec3d *src, float k) { dest->xyz.x += src->xyz.x*k; dest->xyz.y += src->xyz.y*k; @@ -308,7 +306,7 @@ void vm_vec_scale_add2(vec3d *dest,vec3d *src,float k) //scales a vector and adds it to another //dest += k * src #ifndef _INLINE_VECMAT -void vm_vec_scale_sub2(vec3d *dest,vec3d *src,float k) +void vm_vec_scale_sub2(vec3d *dest, const vec3d *src, float k) { dest->xyz.x -= src->xyz.x*k; dest->xyz.y -= src->xyz.y*k; @@ -319,7 +317,7 @@ void vm_vec_scale_sub2(vec3d *dest,vec3d *src,float k) //scales a vector in place, taking n/d for scale. //dest *= n/d #ifndef _INLINE_VECMAT -void vm_vec_scale2(vec3d *dest,float n,float d) +void vm_vec_scale2(vec3d *dest, float n, float d) { d = 1.0f/d; @@ -331,7 +329,7 @@ void vm_vec_scale2(vec3d *dest,float n,float d) //returns dot product of 2 vectors #ifndef _INLINE_VECMAT -float vm_vec_dotprod(vec3d *v0,vec3d *v1) +float vm_vec_dotprod(const vec3d *v0, const vec3d *v1) { return (v1->xyz.x*v0->xyz.x)+(v1->xyz.y*v0->xyz.y)+(v1->xyz.z*v0->xyz.z); } @@ -340,14 +338,14 @@ float vm_vec_dotprod(vec3d *v0,vec3d *v1) //returns dot product of and vector #ifndef _INLINE_VECMAT -float vm_vec_dot3(float x,float y,float z,vec3d *v) +float vm_vec_dot3(float x, float y, float z, const vec3d *v) { return (x*v->xyz.x)+(y*v->xyz.y)+(z*v->xyz.z); } #endif //returns magnitude of a vector -float vm_vec_mag(vec3d *v) +float vm_vec_mag(const vec3d *v) { float mag1; @@ -361,12 +359,12 @@ float vm_vec_mag(vec3d *v) } //returns squared magnitude of a vector, useful if you want to compare distances -float vm_vec_mag_squared(vec3d *v) +float vm_vec_mag_squared(const vec3d *v) { return ((v->xyz.x * v->xyz.x) + (v->xyz.y * v->xyz.y) + (v->xyz.z * v->xyz.z)); } -float vm_vec_dist_squared(vec3d *v0, vec3d *v1) +float vm_vec_dist_squared(const vec3d *v0, const vec3d *v1) { float dx, dy, dz; @@ -377,7 +375,7 @@ float vm_vec_dist_squared(vec3d *v0, vec3d *v1) } //computes the distance between two points. (does sub and mag) -float vm_vec_dist(vec3d *v0,vec3d *v1) +float vm_vec_dist(const vec3d *v0, const vec3d *v1) { float t1; vec3d t; @@ -393,7 +391,7 @@ float vm_vec_dist(vec3d *v0,vec3d *v1) //computes an approximation of the magnitude of the vector //uses dist = largest + next_largest*3/8 + smallest*3/16 -float vm_vec_mag_quick(vec3d *v) +float vm_vec_mag_quick(const vec3d *v) { float a,b,c,bc, t; @@ -439,7 +437,7 @@ float vm_vec_mag_quick(vec3d *v) //computes an approximation of the distance between two points. //uses dist = largest + next_largest*3/8 + smallest*3/16 -float vm_vec_dist_quick(vec3d *v0,vec3d *v1) +float vm_vec_dist_quick(const vec3d *v0, const vec3d *v1) { vec3d t; @@ -449,7 +447,7 @@ float vm_vec_dist_quick(vec3d *v0,vec3d *v1) } //normalize a vector. returns mag of source vec -float vm_vec_copy_normalize(vec3d *dest,vec3d *src) +float vm_vec_copy_normalize(vec3d *dest, const vec3d *src) { float m; @@ -519,7 +517,7 @@ float vm_vec_normalize_safe(vec3d *v) //returns approximation of 1/magnitude of a vector -float vm_vec_imag(vec3d *v) +static float vm_vec_imag(const vec3d *v) { #if _M_IX86_FP < 1 return 1.0f / sqrt( (v->xyz.x*v->xyz.x)+(v->xyz.y*v->xyz.y)+(v->xyz.z*v->xyz.z) ); @@ -534,7 +532,7 @@ float vm_vec_imag(vec3d *v) } //normalize a vector. returns 1/mag of source vec. uses approx 1/mag -float vm_vec_copy_normalize_quick(vec3d *dest,vec3d *src) +float vm_vec_copy_normalize_quick(vec3d *dest,const vec3d *src) { // return vm_vec_copy_normalize(dest, src); float im; @@ -570,7 +568,7 @@ float vm_vec_normalize_quick(vec3d *src) } //normalize a vector. returns mag of source vec. uses approx mag -float vm_vec_copy_normalize_quick_mag(vec3d *dest,vec3d *src) +float vm_vec_copy_normalize_quick_mag(vec3d *dest, const vec3d *src) { // return vm_vec_copy_normalize(dest, src); @@ -613,7 +611,7 @@ float vm_vec_normalize_quick_mag(vec3d *v) //return the normalized direction vector between two points //dest = normalized(end - start). Returns mag of direction vector //NOTE: the order of the parameters matches the vector subtraction -float vm_vec_normalized_dir(vec3d *dest,vec3d *end,vec3d *start) +float vm_vec_normalized_dir(vec3d *dest, const vec3d *end, const vec3d *start) { float t; @@ -626,7 +624,7 @@ float vm_vec_normalized_dir(vec3d *dest,vec3d *end,vec3d *start) //return the normalized direction vector between two points //dest = normalized(end - start). Returns mag of direction vector //NOTE: the order of the parameters matches the vector subtraction -float vm_vec_normalized_dir_quick(vec3d *dest,vec3d *end,vec3d *start) +float vm_vec_normalized_dir_quick(vec3d *dest, const vec3d *end, const vec3d *start) { vm_vec_sub(dest,end,start); @@ -636,7 +634,7 @@ float vm_vec_normalized_dir_quick(vec3d *dest,vec3d *end,vec3d *start) //return the normalized direction vector between two points //dest = normalized(end - start). Returns mag of direction vector //NOTE: the order of the parameters matches the vector subtraction -float vm_vec_normalized_dir_quick_mag(vec3d *dest,vec3d *end,vec3d *start) +float vm_vec_normalized_dir_quick_mag(vec3d *dest, const vec3d *end, const vec3d *start) { float t; vm_vec_sub(dest,end,start); @@ -648,7 +646,7 @@ float vm_vec_normalized_dir_quick_mag(vec3d *dest,vec3d *end,vec3d *start) //computes surface normal from three points. result is normalized //returns ptr to dest //dest CANNOT equal either source -vec3d *vm_vec_normal(vec3d *dest,vec3d *p0,vec3d *p1,vec3d *p2) +vec3d *vm_vec_normal(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d *p2) { Assert(dest != p0); Assert(dest != p1); @@ -667,7 +665,7 @@ vec3d *vm_vec_normal(vec3d *dest,vec3d *p0,vec3d *p1,vec3d *p2) //product of the magnitudes of the two source vectors. This means it is //quite easy for this routine to overflow and underflow. Be careful that //your inputs are ok. -vec3d *vm_vec_crossprod(vec3d *dest,vec3d *src0,vec3d *src1) +vec3d *vm_vec_crossprod(vec3d *dest, const vec3d *src0, const vec3d *src1) { dest->xyz.x = (src0->xyz.y * src1->xyz.z) - (src0->xyz.z * src1->xyz.y); dest->xyz.y = (src0->xyz.z * src1->xyz.x) - (src0->xyz.x * src1->xyz.z); @@ -677,7 +675,7 @@ vec3d *vm_vec_crossprod(vec3d *dest,vec3d *src0,vec3d *src1) } // test if 2 vectors are parallel or not. -int vm_test_parallel(vec3d *src0, vec3d *src1) +int vm_test_parallel(const vec3d *src0, const vec3d *src1) { if ( (fl_abs(src0->xyz.x - src1->xyz.x) < 1e-4) && (fl_abs(src0->xyz.y - src1->xyz.y) < 1e-4) && (fl_abs(src0->xyz.z - src1->xyz.z) < 1e-4) ) { return 1; @@ -689,7 +687,7 @@ int vm_test_parallel(vec3d *src0, vec3d *src1) //computes non-normalized surface normal from three points. //returns ptr to dest //dest CANNOT equal either source -vec3d *vm_vec_perp(vec3d *dest,vec3d *p0,vec3d *p1,vec3d *p2) +vec3d *vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1,const vec3d *p2) { Assert(dest != p0); Assert(dest != p1); @@ -709,7 +707,7 @@ vec3d *vm_vec_perp(vec3d *dest,vec3d *p0,vec3d *p1,vec3d *p2) //the forward vector (third parameter) can be NULL, in which case the absolute //value of the angle in returned. Otherwise the angle around that vector is //returned. -float vm_vec_delta_ang(vec3d *v0,vec3d *v1,vec3d *fvec) +float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *fvec) { float t; vec3d t0,t1,t2; @@ -728,7 +726,7 @@ float vm_vec_delta_ang(vec3d *v0,vec3d *v1,vec3d *fvec) } //computes the delta angle between two normalized vectors. -float vm_vec_delta_ang_norm(vec3d *v0,vec3d *v1,vec3d *fvec) +float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1, const vec3d *fvec) { float a; vec3d t; @@ -745,7 +743,7 @@ float vm_vec_delta_ang_norm(vec3d *v0,vec3d *v1,vec3d *fvec) return a; } -matrix *sincos_2_matrix(matrix *m,float sinp,float cosp,float sinb,float cosb,float sinh,float cosh) +static matrix *sincos_2_matrix(matrix *m, float sinp, float cosp, float sinb, float cosb, float sinh, float cosh) { float sbsh,cbch,cbsh,sbch; @@ -774,7 +772,7 @@ matrix *sincos_2_matrix(matrix *m,float sinp,float cosp,float sinb,float cosb,fl } //computes a matrix from a set of three angles. returns ptr to matrix -matrix *vm_angles_2_matrix(matrix *m,angles *a) +matrix *vm_angles_2_matrix(matrix *m, const angles *a) { matrix * t; float sinp,cosp,sinb,cosb,sinh,cosh; @@ -818,7 +816,7 @@ matrix *vm_angle_2_matrix(matrix *m, float a, int angle_index) //computes a matrix from a forward vector and an angle -matrix *vm_vec_ang_2_matrix(matrix *m,vec3d *v,float a) +matrix *vm_vec_ang_2_matrix(matrix *m, const vec3d *v, float a) { matrix * t; float sinb,cosb,sinp,cosp,sinh,cosh; @@ -867,9 +865,11 @@ void vm_vector_2_matrix_gen_vectors(matrix *m) //the up vector is used. If only the forward vector is passed, a bank of //zero is assumed //returns ptr to matrix -matrix *vm_vector_2_matrix(matrix *m,vec3d *fvec,vec3d *uvec,vec3d *rvec) +matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec) { - vec3d *xvec=&m->vec.rvec,*yvec=&m->vec.uvec,*zvec=&m->vec.fvec; + vec3d *xvec=&m->vec.rvec; + vec3d *yvec=&m->vec.uvec; + vec3d *zvec=&m->vec.fvec; Assert(fvec != NULL); @@ -914,7 +914,7 @@ matrix *vm_vector_2_matrix(matrix *m,vec3d *fvec,vec3d *uvec,vec3d *rvec) } //quicker version of vm_vector_2_matrix() that takes normalized vectors -matrix *vm_vector_2_matrix_norm(matrix *m,vec3d *fvec,vec3d *uvec,vec3d *rvec) +matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec) { vec3d *xvec=&m->vec.rvec; vec3d *yvec=&m->vec.uvec; @@ -958,7 +958,7 @@ matrix *vm_vector_2_matrix_norm(matrix *m,vec3d *fvec,vec3d *uvec,vec3d *rvec) // // Goober5000: FYI, the result of rotating a normalized vector through a rotation matrix will // also be a normalized vector. It took me awhile to verify online that this was true. ;) -vec3d *vm_vec_rotate(vec3d *dest,vec3d *src,matrix *m) +vec3d *vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m) { Assert(dest != src); @@ -984,7 +984,7 @@ vec3d *vm_vec_rotate(vec3d *dest,vec3d *src,matrix *m) // // Goober5000: FYI, the result of rotating a normalized vector through a rotation matrix will // also be a normalized vector. It took me awhile to verify online that this was true. ;) -vec3d *vm_vec_unrotate(vec3d *dest,vec3d *src,matrix *m) +vec3d *vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m) { Assert(dest != src); @@ -1009,7 +1009,7 @@ matrix *vm_transpose_matrix(matrix *m) //copy and transpose a matrix. returns ptr to matrix //dest CANNOT equal source. use vm_transpose_matrix() if this is the case -matrix *vm_copy_transpose_matrix(matrix *dest,matrix *src) +matrix *vm_copy_transpose_matrix(matrix *dest, const matrix *src) { Assert(dest != src); @@ -1031,7 +1031,7 @@ matrix *vm_copy_transpose_matrix(matrix *dest,matrix *src) //mulitply 2 matrices, fill in dest. returns ptr to dest //dest CANNOT equal either source -matrix *vm_matrix_x_matrix(matrix *dest,matrix *src0,matrix *src1) +matrix *vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1) { Assert(dest!=src0 && dest!=src1); @@ -1052,7 +1052,7 @@ matrix *vm_matrix_x_matrix(matrix *dest,matrix *src0,matrix *src1) //extract angles from a matrix -angles *vm_extract_angles_matrix(angles *a,matrix *m) +angles *vm_extract_angles_matrix(angles *a, const matrix *m) { float sinh,cosh,cosp; @@ -1102,7 +1102,7 @@ angles *vm_extract_angles_matrix(angles *a,matrix *m) // (pages 278-281) of 3D Math Primer for Graphics and Game // Development, 2nd Edition // http://books.google.com/books?id=X3hmuhBoFF0C&printsec=frontcover#v=onepage&q&f=false -angles *vm_extract_angles_matrix_alternate(angles *a, matrix *m) +angles *vm_extract_angles_matrix_alternate(angles *a, const matrix *m) { Assert(a != NULL); Assert(m != NULL); @@ -1139,7 +1139,7 @@ angles *vm_extract_angles_matrix_alternate(angles *a, matrix *m) //extract heading and pitch from a vector, assuming bank==0 -angles *vm_extract_angles_vector_normalized(angles *a,vec3d *v) +static angles *vm_extract_angles_vector_normalized(angles *a, const vec3d *v) { a->b = 0.0f; //always zero bank @@ -1155,7 +1155,7 @@ angles *vm_extract_angles_vector_normalized(angles *a,vec3d *v) } //extract heading and pitch from a vector, assuming bank==0 -angles *vm_extract_angles_vector(angles *a,vec3d *v) +angles *vm_extract_angles_vector(angles *a, const vec3d *v) { vec3d t; @@ -1169,7 +1169,7 @@ angles *vm_extract_angles_vector(angles *a,vec3d *v) //of the plane (ebx), a point on the plane (edi), and the point to check (esi). //returns distance in eax //distance is signed, so negative dist is on the back of the plane -float vm_dist_to_plane(vec3d *checkp,vec3d *norm,vec3d *planep) +float vm_dist_to_plane(const vec3d *checkp, const vec3d *norm, const vec3d *planep) { float t1; vec3d t; @@ -1229,7 +1229,7 @@ void vm_trackball( int idx, int idy, matrix * RotMat ) } // Compute the outer product of A = A * transpose(A). 1x3 vector becomes 3x3 matrix. -void vm_vec_outer_product(matrix *mat, vec3d *vec) +static void vm_vec_outer_product(matrix *mat, const vec3d *vec) { mat->vec.rvec.xyz.x = vec->xyz.x * vec->xyz.x; mat->vec.rvec.xyz.y = vec->xyz.x * vec->xyz.y; @@ -1250,7 +1250,7 @@ void vm_vec_outer_product(matrix *mat, vec3d *vec) // Returns value indicating whether *nearest_point is between *p0 and *p1. // 0.0f means *nearest_point is *p0, 1.0f means it's *p1. 2.0f means it's beyond p1 by 2x. // -1.0f means it's "before" *p0 by 1x. -float find_nearest_point_on_line(vec3d *nearest_point, vec3d *p0, vec3d *p1, vec3d *int_pnt) +float find_nearest_point_on_line(vec3d *nearest_point, const vec3d *p0, const vec3d *p1, const vec3d *int_pnt) { vec3d norm, xlated_int_pnt, projected_point; matrix mat; @@ -1383,7 +1383,7 @@ void vm_fix_matrix(matrix *m) //Rotates the orient matrix by the angles in tangles and then //makes sure that the matrix is orthogonal. -void vm_rotate_matrix_by_angles( matrix *orient, angles *tangles ) +void vm_rotate_matrix_by_angles( matrix *orient, const angles *tangles ) { matrix rotmat,new_orient; vm_angles_2_matrix(&rotmat,tangles); @@ -1393,7 +1393,7 @@ void vm_rotate_matrix_by_angles( matrix *orient, angles *tangles ) } // dir must be normalized! -float vm_vec_dot_to_point(vec3d *dir, vec3d *p1, vec3d *p2) +float vm_vec_dot_to_point(const vec3d *dir, const vec3d *p1, const vec3d *p2) { vec3d tvec; @@ -1408,7 +1408,7 @@ float vm_vec_dot_to_point(vec3d *dir, vec3d *p1, vec3d *p2) ///////////////////////////////////////////////////////// // Given a plane and a point, return the point on the plane closest the the point. // Result returned in q. -void compute_point_on_plane(vec3d *q, plane *planep, vec3d *p) +void compute_point_on_plane(vec3d *q, const plane *planep, const vec3d *p) { float k, tv; vec3d normal; @@ -1442,7 +1442,7 @@ void vm_vec_rand_vec_quick(vec3d *rvec) // arbritary line defined by a point on the line "line_point" // and the normalized line direction, "line_dir" // Returns the rotated point in "out". -void vm_rot_point_around_line(vec3d *out, vec3d *in, float angle, vec3d *line_point, vec3d *line_dir) +void vm_rot_point_around_line(vec3d *out, const vec3d *in, float angle, const vec3d *line_point, const vec3d *line_dir) { vec3d tmp, tmp1; matrix m, r; @@ -1462,7 +1462,7 @@ void vm_rot_point_around_line(vec3d *out, vec3d *in, float angle, vec3d *line_po } // Given two position vectors, return 0 if the same, else non-zero. -int vm_vec_cmp( vec3d * a, vec3d * b ) +int vm_vec_cmp( const vec3d * a, const vec3d * b ) { float diff = vm_vec_dist(a,b); //mprintf(( "Diff=%.32f\n", diff )); @@ -1473,7 +1473,7 @@ int vm_vec_cmp( vec3d * a, vec3d * b ) } // Given two orientation matrices, return 0 if the same, else non-zero. -int vm_matrix_cmp( matrix * a, matrix * b ) +int vm_matrix_cmp(const matrix * a, const matrix * b) { float tmp1,tmp2,tmp3; tmp1 = fl_abs(vm_vec_dot( &a->vec.uvec, &b->vec.uvec ) - 1.0f); @@ -1553,7 +1553,7 @@ float vm_delta_from_interp_angle( float current_angle, float desired_angle ) } // check a matrix for zero rows and columns -int vm_check_matrix_for_zeros(matrix *m) +int vm_check_matrix_for_zeros(const matrix *m) { if (!m->vec.fvec.xyz.x && !m->vec.fvec.xyz.y && !m->vec.fvec.xyz.z) return 1; @@ -1573,7 +1573,7 @@ int vm_check_matrix_for_zeros(matrix *m) } // see if two vectors are the same -int vm_vec_same(vec3d *v1, vec3d *v2) +int vm_vec_same(const vec3d *v1, const vec3d *v2) { if ( v1->xyz.x == v2->xyz.x && v1->xyz.y == v2->xyz.y && v1->xyz.z == v2->xyz.z ) return 1; @@ -1595,7 +1595,7 @@ int vm_matrix_same(matrix *m1, matrix *m2) // -------------------------------------------------------------------------------------- -void vm_quaternion_rotate(matrix *M, float theta, vec3d *u) +void vm_quaternion_rotate(matrix *M, float theta, const vec3d *u) // given an arbitrary rotation axis and rotation angle, function generates the // corresponding rotation matrix // @@ -1631,9 +1631,9 @@ void vm_quaternion_rotate(matrix *M, float theta, vec3d *u) // this is an optimized version vm_quaternion_rotate // // inputs: m => point to resultant rotation matrix -// angle => rotation angle about z axis (in radians) +// angle => rotation angle about z axis (in radians) // -void rotate_z ( matrix *m, float theta ) +static void rotate_z ( matrix *m, float theta ) { m->vec.rvec.xyz.x = cosf (theta); m->vec.rvec.xyz.y = sinf (theta); @@ -1659,7 +1659,7 @@ void rotate_z ( matrix *m, float theta ) // rot_axis - the resultant axis of rotation // theta - the resultatn rotation around the axis // m - the initial matrix -void vm_matrix_to_rot_axis_and_angle(matrix *m, float *theta, vec3d *rot_axis) +void vm_matrix_to_rot_axis_and_angle(const matrix *m, float *theta, vec3d *rot_axis) { float trace = m->a2d[0][0] + m->a2d[1][1] + m->a2d[2][2]; float cos_theta = 0.5f * (trace - 1.0f); @@ -1741,8 +1741,8 @@ void vm_matrix_to_rot_axis_and_angle(matrix *m, float *theta, vec3d *rot_axis) // theta_goal > 0 // aa > 0 // returns delta_theta -float away(float w_in, float w_max, float theta_goal, float aa, float delta_t, float *w_out, int no_overshoot); -float approach(float w_in, float w_max, float theta_goal, float aa, float delta_t, float *w_out, int no_overshoot) +static float away(float w_in, float w_max, float theta_goal, float aa, float delta_t, float *w_out, int no_overshoot); +static float approach(float w_in, float w_max, float theta_goal, float aa, float delta_t, float *w_out, int no_overshoot) { float delta_theta; // amount rotated during time delta_t Assert(w_in >= 0); @@ -1867,7 +1867,7 @@ float approach(float w_in, float w_max, float theta_goal, float aa, float delta_ // theta_goal > 0 // aa > 0 // returns angle rotated this frame -float away(float w_in, float w_max, float theta_goal, float aa, float delta_t, float *w_out, int no_overshoot) +static float away(float w_in, float w_max, float theta_goal, float aa, float delta_t, float *w_out, int no_overshoot) { float delta_theta;// amount rotated during time @@ -1906,8 +1906,8 @@ float away(float w_in, float w_max, float theta_goal, float aa, float delta_t, f // -------------------------------------------------------------------------------------- -void vm_matrix_interpolate(matrix *goal_orient, matrix *curr_orient, vec3d *w_in, float delta_t, - matrix *next_orient, vec3d *w_out, vec3d *vel_limit, vec3d *acc_limit, int no_overshoot) +void vm_matrix_interpolate(const matrix *goal_orient, const matrix *curr_orient, const vec3d *w_in, float delta_t, + matrix *next_orient, vec3d *w_out, const vec3d *vel_limit, const vec3d *acc_limit, int no_overshoot) { matrix rot_matrix; // rotation matrix from curr_orient to goal_orient matrix Mtemp1; // temp matrix @@ -2052,7 +2052,7 @@ void vm_matrix_interpolate(matrix *goal_orient, matrix *curr_orient, vec3d *w_in // -------------------------------------------------------------------------------------- -void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vec3d *acc_max, vec3d *w_max) +void get_camera_limits(const matrix *start_camera, const matrix *end_camera, float time, vec3d *acc_max, vec3d *w_max) { matrix temp, rot_matrix; float theta; @@ -2092,242 +2092,6 @@ void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vec } } -// --------------------------------------------------------------------------------------------- -// -// inputs: goal_orient => goal orientation matrix -// orient => current orientation matrix (with current forward vector) -// w_in => current input angular velocity -// delta_t => time to move toward goal -// next_orient => the orientation matrix at time delta_t (with current forward vector) -// NOTE: this does not include any rotation about z (bank) -// w_out => the angular velocity of the ship at delta_t -// vel_limit => maximum rotational speed -// acc_limit => maximum rotational speed -// -// function moves the forward vector toward the goal forward vector taking account of anglular -// momentum (velocity) Attempt to try to move bank by goal delta_bank. Rotational velocity -// on x/y is rotated with bank, giving smoother motion. -void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vec3d *w_in, float delta_t, matrix *next_orient, - vec3d *w_out, vec3d *vel_limit, vec3d *acc_limit, int no_overshoot) -{ - matrix Mtemp1; // temporary matrix - matrix M_intermed; // intermediate matrix after xy rotation - vec3d local_rot_axis; // vector indicating direction of rotation axis (local coords) - vec3d rot_axis; // vector indicating direction of rotation axis (world coords) - vec3d theta_goal; // desired angular position at the end of the time interval - vec3d theta_end; // actual angular position at the end of the time interval - float theta; // magnitude of rotation about the rotation axis - float bank; // magnitude of rotation about the forward axis - int no_bank; // flag set if there is no bank for the object - vec3d vtemp; // temp angular velocity before rotation about z - float z_dotprod; // dotprod of orient->vec.fvec and goal_orient->vec.fvec - float r_dotprod; // dotprod of orient->vec.rvec and goal_orient->vec.rvec - float delta_bank; - - // FIND XY ROTATION NEEDED FOR GOAL - // rotation vector is (current fvec) orient->vec.fvec x goal_f - // magnitude = asin ( magnitude of crossprod ) - vm_vec_crossprod ( &rot_axis, &orient->vec.fvec, &goal_orient->vec.fvec ); - - float t = vm_vec_mag(&rot_axis); - if (t > 1.0f) - t = 1.0f; - - z_dotprod = vm_vec_dotprod ( &orient->vec.fvec, &goal_orient->vec.fvec ); - - if ( t < SMALLER_NUM ) { - if ( z_dotprod > 0.0f ) - theta = 0.0f; - else { // the forward vector is pointing exactly opposite of goal - // arbitrarily choose the x axis to rotate around until t becomes large enough - theta = PI; - rot_axis = orient->vec.rvec; - } - } else { - theta = asinf ( t ); - vm_vec_scale ( &rot_axis, 1/t ); - if ( z_dotprod < 0.0f ) - theta = PI - theta; - } - - // rotate rot_axis into ship reference frame - vm_vec_rotate ( &local_rot_axis, &rot_axis, orient ); - - // find theta to goal - vm_vec_copy_scale(&theta_goal, &local_rot_axis, theta); - Assert ( fl_abs (theta_goal.xyz.z) < 0.001f ); // check for proper rotation - - theta_end = vmd_zero_vector; - float delta_theta; - - // find rotation about x - if (theta_goal.xyz.x > 0) { - if (w_in->xyz.x >= 0) { - delta_theta = approach(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); - theta_end.xyz.x = delta_theta; - } else { // w_in->xyz.x < 0 - delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); - theta_end.xyz.x = delta_theta; - } - } else if (theta_goal.xyz.x < 0) { - if (w_in->xyz.x <= 0) { - delta_theta = approach(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); - theta_end.xyz.x = -delta_theta; - w_out->xyz.x = -w_out->xyz.x; - } else { // w_in->xyz.x > 0 - delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); - theta_end.xyz.x = -delta_theta; - w_out->xyz.x = -w_out->xyz.x; - } - } else { // theta_goal == 0 - if (w_in->xyz.x < 0) { - delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); - theta_end.xyz.x = delta_theta; - } else { - delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); - theta_end.xyz.x = -delta_theta; - w_out->xyz.x = -w_out->xyz.x; - } - } - - // find rotation about y - if (theta_goal.xyz.y > 0) { - if (w_in->xyz.y >= 0) { - delta_theta = approach(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); - theta_end.xyz.y = delta_theta; - } else { // w_in->xyz.y < 0 - delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); - theta_end.xyz.y = delta_theta; - } - } else if (theta_goal.xyz.y < 0) { - if (w_in->xyz.y <= 0) { - delta_theta = approach(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); - theta_end.xyz.y = -delta_theta; - w_out->xyz.y = -w_out->xyz.y; - } else { // w_in->xyz.y > 0 - delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); - theta_end.xyz.y = -delta_theta; - w_out->xyz.y = -w_out->xyz.y; - } - } else { // theta_goal == 0 - if (w_in->xyz.y < 0) { - delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); - theta_end.xyz.y = delta_theta; - } else { - delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); - theta_end.xyz.y = -delta_theta; - w_out->xyz.y = -w_out->xyz.y; - } - } - - // FIND Z ROTATON MATRIX - theta_end.xyz.z = 0.0f; - rot_axis = theta_end; - Assert(is_valid_vec(&rot_axis)); - - // normalize rotation axis and determine total rotation angle - theta = vm_vec_mag(&rot_axis); - if (theta < SMALL_NUM) { - theta = 0.0f; - M_intermed = *orient; - } else { - vm_vec_scale ( &rot_axis, 1/theta ); - vm_quaternion_rotate ( &Mtemp1, theta, &rot_axis ); - Assert(is_valid_matrix(&Mtemp1)); - vm_matrix_x_matrix ( &M_intermed, orient, &Mtemp1 ); - Assert(is_valid_matrix(&M_intermed)); - } - - - // FIND ROTATION ABOUT Z (IF ANY) - // no rotation if delta_bank and w_in both 0 or rotational acc in forward is 0 - no_bank = ( acc_limit->xyz.z == 0.0f && vel_limit->xyz.z == 0.0f ); - - if ( no_bank ) { // no rotation on z, so we're done (no rotation of w) - *next_orient = M_intermed; - vm_orthogonalize_matrix ( next_orient ); - return; - } else { - // calculate delta_bank using orient->vec.rvec, goal_orient->vec.rvec - // - vm_vec_crossprod ( &rot_axis, &orient->vec.rvec, &goal_orient->vec.rvec ); - - t = vm_vec_mag(&rot_axis); - if (t > 1.0f) - t = 1.0f; - - r_dotprod = vm_vec_dotprod ( &orient->vec.rvec, &goal_orient->vec.rvec ); - - if ( t < SMALLER_NUM ) { - if ( r_dotprod > 0.0f ) - theta = 0.0f; - else { // the right vector is pointing exactly opposite of goal, so rotate 180 on z - theta = PI; - rot_axis = orient->vec.fvec; - } - } else { - theta = asinf ( t ); - vm_vec_scale ( &rot_axis, 1/t ); - if ( z_dotprod < 0.0f ) - theta = PI - theta; - } - - // rotate rot_axis into ship reference frame - vm_vec_rotate ( &local_rot_axis, &rot_axis, orient ); - - // find theta.xyz.z to goal - delta_bank = local_rot_axis.xyz.z * theta; - Assert( fl_abs (local_rot_axis.xyz.x) < 0.001f ); // check for proper rotation - bank = 0.0f; - - // end calculate delta_bank - // find rotation about z - if (delta_bank > 0) { - if (w_in->xyz.z >= 0) { - delta_theta = approach(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); - bank = delta_theta; - } else { // w_in->xyz.z < 0 - delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); - bank = delta_theta; - } - } else if (delta_bank < 0) { - if (w_in->xyz.z <= 0) { - delta_theta = approach(-w_in->xyz.z, vel_limit->xyz.z, -delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); - bank = -delta_theta; - w_out->xyz.z = -w_out->xyz.z; - } else { // w_in->xyz.z > 0 - delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, -delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); - bank = -delta_theta; - w_out->xyz.z = -w_out->xyz.z; - } - } else { // theta_goal == 0 - if (w_in->xyz.z < 0) { - delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); - bank = delta_theta; - } else { - delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); - bank = -delta_theta; - w_out->xyz.z = -w_out->xyz.z; - } - } - - if ( fl_abs (bank) < SMALL_NUM ) - { - *next_orient = M_intermed; - vm_orthogonalize_matrix ( next_orient ); - } else { - - rotate_z ( &Mtemp1, bank ); - vtemp = *w_out; - vm_vec_rotate ( w_out, &vtemp, &Mtemp1 ); - vm_matrix_x_matrix ( next_orient, &M_intermed, &Mtemp1 ); - Assert(is_valid_matrix(next_orient)); - vm_orthogonalize_matrix ( next_orient ); - } - } -} // end vm_fvec_matrix_interpolate - - // --------------------------------------------------------------------------------------------- // // inputs: goal_f => goal forward vector @@ -2344,8 +2108,8 @@ void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vec3d *w_in // function moves the forward vector toward the goal forward vector taking account of anglular // momentum (velocity) Attempt to try to move bank by goal delta_bank. Rotational velocity // on x/y is rotated with bank, giving smoother motion. -void vm_forward_interpolate(vec3d *goal_f, matrix *orient, vec3d *w_in, float delta_t, float delta_bank, - matrix *next_orient, vec3d *w_out, vec3d *vel_limit, vec3d *acc_limit, int no_overshoot) +void vm_forward_interpolate(const vec3d *goal_f, const matrix *orient, const vec3d *w_in, float delta_t, float delta_bank, + matrix *next_orient, vec3d *w_out, const vec3d *vel_limit, const vec3d *acc_limit, int no_overshoot) { matrix Mtemp1; // temporary matrix vec3d local_rot_axis; // vector indicating direction of rotation axis (local coords) @@ -2532,12 +2296,13 @@ void vm_forward_interpolate(vec3d *goal_f, matrix *orient, vec3d *w_in, float de // radius => OUTPUT PARAMETER: continas radius of bounding sphere // #define BIGNUMBER 100000000.0f -void vm_find_bounding_sphere(vec3d *pnts, int num_pnts, vec3d *center, float *radius) +void vm_find_bounding_sphere(const vec3d *pnts, int num_pnts, vec3d *center, float *radius) { int i; float rad, rad_sq, xspan, yspan, zspan, maxspan; float old_to_p, old_to_p_sq, old_to_new; - vec3d diff, xmin, xmax, ymin, ymax, zmin, zmax, dia1, dia2, *p; + vec3d diff, xmin, xmax, ymin, ymax, zmin, zmax, dia1, dia2; + const vec3d *p; xmin = vmd_zero_vector; ymin = vmd_zero_vector; @@ -2628,7 +2393,7 @@ void vm_find_bounding_sphere(vec3d *pnts, int num_pnts, vec3d *center, float *ra // world_vec => vector in world coordinates // orient => orientation matrix // -vec3d* vm_rotate_vec_to_body(vec3d *body_vec, vec3d *world_vec, matrix *orient) +vec3d* vm_rotate_vec_to_body(vec3d *body_vec, const vec3d *world_vec, const matrix *orient) { return vm_vec_unrotate(body_vec, world_vec, orient); } @@ -2639,11 +2404,11 @@ vec3d* vm_rotate_vec_to_body(vec3d *body_vec, vec3d *world_vec, matrix *orient) // // rotates a vector from body coordinates to world coordinates // -// inputs world_vec => vector in world coordinates -// body_vec => vector in body coordinates +// inputs world_vec => vector in world coordinates +// body_vec => vector in body coordinates // orient => orientation matrix // -vec3d* vm_rotate_vec_to_world(vec3d *world_vec, vec3d *body_vec, matrix *orient) +vec3d* vm_rotate_vec_to_world(vec3d *world_vec, const vec3d *body_vec, const matrix *orient) { return vm_vec_rotate(world_vec, body_vec, orient); } @@ -2654,11 +2419,11 @@ vec3d* vm_rotate_vec_to_world(vec3d *world_vec, vec3d *body_vec, matrix *orient) // // given a last orientation and current orientation, estimate the next orientation // -// inputs: last_orient => last orientation matrix +// inputs: last_orient => last orientation matrix // current_orient => current orientation matrix // next_orient => next orientation matrix [the result] // -void vm_estimate_next_orientation(matrix *last_orient, matrix *current_orient, matrix *next_orient) +void vm_estimate_next_orientation(const matrix *last_orient, const matrix *current_orient, matrix *next_orient) { // R L = C => R = C (L)^-1 // N = R C => N = C (L)^-1 C @@ -2671,19 +2436,19 @@ void vm_estimate_next_orientation(matrix *last_orient, matrix *current_orient, m } // Return true if all elements of *vec are legal, that is, not a NAN. -int is_valid_vec(vec3d *vec) +int is_valid_vec(const vec3d *vec) { return !_isnan(vec->xyz.x) && !_isnan(vec->xyz.y) && !_isnan(vec->xyz.z); } // Return true if all elements of *m are legal, that is, not a NAN. -int is_valid_matrix(matrix *m) +int is_valid_matrix(const matrix *m) { return is_valid_vec(&m->vec.fvec) && is_valid_vec(&m->vec.uvec) && is_valid_vec(&m->vec.rvec); } // interpolate between 2 vectors. t goes from 0.0 to 1.0. at -void vm_vec_interp_constant(vec3d *out, vec3d *v0, vec3d *v1, float t) +void vm_vec_interp_constant(vec3d *out, const vec3d *v0, const vec3d *v1, float t) { vec3d cross; float total_ang; @@ -2700,10 +2465,10 @@ void vm_vec_interp_constant(vec3d *out, vec3d *v0, vec3d *v1, float t) } // randomly perturb a vector around a given (normalized vector) or optional orientation matrix -void vm_vec_random_cone(vec3d *out, vec3d *in, float max_angle, matrix *orient) +void vm_vec_random_cone(vec3d *out, const vec3d *in, float max_angle, const matrix *orient) { vec3d t1, t2; - matrix *rot; + const matrix *rot; matrix m; // get an orientation matrix @@ -2724,9 +2489,9 @@ void vm_vec_random_cone(vec3d *out, vec3d *in, float max_angle, matrix *orient) vm_rot_point_around_line(out, &t2, fl_radians(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->vec.uvec); } -void vm_vec_random_cone(vec3d *out, vec3d *in, float min_angle, float max_angle, matrix *orient){ +void vm_vec_random_cone(vec3d *out, const vec3d *in, float min_angle, float max_angle, const matrix *orient){ vec3d t1, t2; - matrix *rot; + const matrix *rot; matrix m; // get an orientation matrix @@ -2763,7 +2528,7 @@ void vm_vec_random_cone(vec3d *out, vec3d *in, float min_angle, float max_angle, // given a start vector, an orientation and a radius, give a point on the plane of the circle // if on_edge is 1, the point is on the very edge of the circle -void vm_vec_random_in_circle(vec3d *out, vec3d *in, matrix *orient, const float radius, const int on_edge) +void vm_vec_random_in_circle(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge) { vec3d temp; @@ -2776,7 +2541,7 @@ void vm_vec_random_in_circle(vec3d *out, vec3d *in, matrix *orient, const float // given a start vector, an orientation, and a radius, give a point in a spherical volume // if on_edge is 1, the point is on the very edge of the sphere -void vm_vec_random_in_sphere(vec3d *out, vec3d *in, matrix *orient, const float radius, const int on_edge) +void vm_vec_random_in_sphere(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge) { vec3d temp; vm_vec_random_in_circle(&temp, in, orient, radius, on_edge); @@ -2785,7 +2550,7 @@ void vm_vec_random_in_sphere(vec3d *out, vec3d *in, matrix *orient, const float // find the nearest point on the line to p. if dist is non-NULL, it is filled in // returns 0 if the point is inside the line segment, -1 if "before" the line segment and 1 ir "after" the line segment -int vm_vec_dist_to_line(vec3d *p, vec3d *l0, vec3d *l1, vec3d *nearest, float *dist) +int vm_vec_dist_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist) { vec3d a, b, c; float b_mag, comp; @@ -2825,7 +2590,7 @@ int vm_vec_dist_to_line(vec3d *p, vec3d *l0, vec3d *l1, vec3d *nearest, float *d // Goober5000 // Finds the distance squared to a line. Same as above, except it uses vm_vec_dist_squared, which is faster; // and it doesn't check whether the nearest point is on the line segment. -void vm_vec_dist_squared_to_line(vec3d *p, vec3d *l0, vec3d *l1, vec3d *nearest, float *dist_squared) +void vm_vec_dist_squared_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist_squared) { vec3d a, b, c; float b_mag, comp; diff --git a/code/math/vecmat.h b/code/math/vecmat.h index a8e419bd93..43861d462d 100755 --- a/code/math/vecmat.h +++ b/code/math/vecmat.h @@ -86,7 +86,7 @@ typedef struct plane { (dst)->xyz.z = (src0)->xyz.z + (src1)->xyz.z; \ } while(0) #else -void vm_vec_add(vec3d *dest,vec3d *src0,vec3d *src1); +void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1); #endif //adds src onto dest vector, returns ptr to dest @@ -97,7 +97,7 @@ void vm_vec_add(vec3d *dest,vec3d *src0,vec3d *src1); (dst)->xyz.z += (src)->xyz.z; \ } while(0) #else -void vm_vec_add2(vec3d *dest,vec3d *src); +void vm_vec_add2(vec3d *dest, const vec3d *src); #endif @@ -111,7 +111,7 @@ void vm_vec_add2(vec3d *dest,vec3d *src); (dst)->xyz.z -= (src)->xyz.z*tmp_k; \ } while(0) #else -void vm_vec_scale_sub2(vec3d *dest,vec3d *src, float k); +void vm_vec_scale_sub2(vec3d *dest, const vec3d *src, float k); #endif //subs two vectors, fills in dest, returns ptr to dest @@ -123,7 +123,7 @@ void vm_vec_scale_sub2(vec3d *dest,vec3d *src, float k); (dst)->xyz.z = (src0)->xyz.z - (src1)->xyz.z; \ } while(0) #else -void vm_vec_sub(vec3d *dest,vec3d *src0,vec3d *src1); +void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1); #endif @@ -136,22 +136,22 @@ void vm_vec_sub(vec3d *dest,vec3d *src0,vec3d *src1); (dst)->xyz.z -= (src)->xyz.z; \ } while(0) #else -void vm_vec_sub2(vec3d *dest,vec3d *src); +void vm_vec_sub2(vec3d *dest, const vec3d *src); #endif //averages n vectors -vec3d *vm_vec_avg_n(vec3d *dest, int n, vec3d src[]); +vec3d *vm_vec_avg_n(vec3d *dest, int n, const vec3d src[]); //averages two vectors. returns ptr to dest //dest can equal either source -vec3d *vm_vec_avg(vec3d *dest,vec3d *src0,vec3d *src1); +vec3d *vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1); -vec3d *vm_vec_avg3(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2); +vec3d *vm_vec_avg3(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2); //averages four vectors. returns ptr to dest //dest can equal any source -vec3d *vm_vec_avg4(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2,vec3d *src3); +vec3d *vm_vec_avg4(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2, const vec3d *src3); //scales a vector in place. returns ptr to vector #ifdef _INLINE_VECMAT @@ -162,7 +162,7 @@ vec3d *vm_vec_avg4(vec3d *dest,vec3d *src0,vec3d *src1,vec3d *src2,vec3d *src3); (dst)->xyz.z *= tmp_k; \ } while(0) #else -void vm_vec_scale(vec3d *dest,float s); +void vm_vec_scale(vec3d *dest, float s); #endif //scales and copies a vector. returns ptr to dest @@ -174,7 +174,7 @@ void vm_vec_scale(vec3d *dest,float s); (dst)->xyz.z = (src)->xyz.z * tmp_k; \ } while(0) #else -void vm_vec_copy_scale(vec3d *dest,vec3d *src,float s); +void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s); #endif //scales a vector, adds it to another, and stores in a 3rd vector @@ -187,10 +187,10 @@ void vm_vec_copy_scale(vec3d *dest,vec3d *src,float s); (dst)->xyz.z = (src1)->xyz.z + (src2)->xyz.z * tmp_k; \ } while(0) #else -void vm_vec_scale_add(vec3d *dest,vec3d *src1,vec3d *src2,float k); +void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k); #endif -void vm_vec_scale_sub(vec3d *dest,vec3d *src1,vec3d *src2,float k); +void vm_vec_scale_sub(vec3d *dest, const vec3d *src1, const vec3d *src2, float k); //scales a vector and adds it to another //dest += k * src @@ -202,7 +202,7 @@ void vm_vec_scale_sub(vec3d *dest,vec3d *src1,vec3d *src2,float k); (dst)->xyz.z += (src)->xyz.z * tmp_k; \ } while(0) #else -void vm_vec_scale_add2(vec3d *dest,vec3d *src,float k); +void vm_vec_scale_add2(vec3d *dest, const vec3d *src, float k); #endif //scales a vector in place, taking n/d for scale. returns ptr to vector @@ -215,7 +215,7 @@ void vm_vec_scale_add2(vec3d *dest,vec3d *src,float k); (dst)->xyz.z *= tmp_k; \ } while(0) #else -void vm_vec_scale2(vec3d *dest,float n,float d); +void vm_vec_scale2(vec3d *dest, float n, float d); #endif bool vm_vec_equal(const vec2d &self, const vec2d &other); @@ -230,34 +230,34 @@ bool vm_matrix_equal(const matrix4 &self, const matrix4 &other); // finds the projection of source vector along a unit vector // returns the magnitude of the component -float vm_vec_projection_parallel (vec3d *component, vec3d *src, vec3d *unit_vector); +float vm_vec_projection_parallel (vec3d *component, const vec3d *src, const vec3d *unit_vector); // finds the projection of source vector onto a surface given by surface normal -void vm_vec_projection_onto_plane (vec3d *projection, vec3d *src, vec3d *normal); +void vm_vec_projection_onto_plane (vec3d *projection, const vec3d *src, const vec3d *normal); //returns magnitude of a vector -float vm_vec_mag(vec3d *v); +float vm_vec_mag(const vec3d *v); // returns the square of the magnitude of a vector (useful if comparing distances) -float vm_vec_mag_squared(vec3d* v); +float vm_vec_mag_squared(const vec3d* v); // returns the square of the distance between two points (fast and exact) -float vm_vec_dist_squared(vec3d *v0, vec3d *v1); +float vm_vec_dist_squared(const vec3d *v0, const vec3d *v1); //computes the distance between two points. (does sub and mag) -float vm_vec_dist(vec3d *v0,vec3d *v1); +float vm_vec_dist(const vec3d *v0, const vec3d *v1); //computes an approximation of the magnitude of the vector //uses dist = largest + next_largest*3/8 + smallest*3/16 -float vm_vec_mag_quick(vec3d *v); +float vm_vec_mag_quick(const vec3d *v); //computes an approximation of the distance between two points. //uses dist = largest + next_largest*3/8 + smallest*3/16 -float vm_vec_dist_quick(vec3d *v0,vec3d *v1); +float vm_vec_dist_quick(const vec3d *v0, const vec3d *v1); //normalize a vector. returns mag of source vec -float vm_vec_copy_normalize(vec3d *dest,vec3d *src); +float vm_vec_copy_normalize(vec3d *dest, const vec3d *src); float vm_vec_normalize(vec3d *v); // This version of vector normalize checks for the null vector before normalization. @@ -265,88 +265,88 @@ float vm_vec_normalize(vec3d *v); float vm_vec_normalize_safe(vec3d *v); //normalize a vector. returns mag of source vec. uses approx mag -float vm_vec_copy_normalize_quick(vec3d *dest,vec3d *src); +float vm_vec_copy_normalize_quick(vec3d *dest, const vec3d *src); float vm_vec_normalize_quick(vec3d *v); //normalize a vector. returns mag of source vec. uses approx mag -float vm_vec_copy_normalize_quick_mag(vec3d *dest,vec3d *src); +float vm_vec_copy_normalize_quick_mag(vec3d *dest, const vec3d *src); float vm_vec_normalize_quick_mag(vec3d *v); //return the normalized direction vector between two points //dest = normalized(end - start). Returns mag of direction vector //NOTE: the order of the parameters matches the vector subtraction -float vm_vec_normalized_dir(vec3d *dest,vec3d *end,vec3d *start); -float vm_vec_normalized_dir_quick_mag(vec3d *dest,vec3d *end,vec3d *start); +float vm_vec_normalized_dir(vec3d *dest,const vec3d *end, const vec3d *start); +float vm_vec_normalized_dir_quick_mag(vec3d *dest, const vec3d *end, const vec3d *start); // Returns mag of direction vector -float vm_vec_normalized_dir_quick(vec3d *dest,vec3d *end,vec3d *start); +float vm_vec_normalized_dir_quick(vec3d *dest, const vec3d *end, const vec3d *start); ////returns dot product of two vectors #ifdef _INLINE_VECMAT #define vm_vec_dotprod( v0, v1 ) (((v1)->xyz.x*(v0)->xyz.x)+((v1)->xyz.y*(v0)->xyz.y)+((v1)->xyz.z*(v0)->xyz.z)) #define vm_vec_dot( v0, v1 ) (((v1)->xyz.x*(v0)->xyz.x)+((v1)->xyz.y*(v0)->xyz.y)+((v1)->xyz.z*(v0)->xyz.z)) #else -float vm_vec_dotprod(vec3d *v0,vec3d *v1); +float vm_vec_dotprod(const vec3d *v0, const vec3d *v1); #define vm_vec_dot vm_vec_dotprod #endif #ifdef _INLINE_VECMAT #define vm_vec_dot3( x1, y1, z1, v ) (((x1)*(v)->xyz.x)+((y1)*(v)->xyz.y)+((z1)*(v)->xyz.z)) #else -float vm_vec_dot3(float x,float y,float z,vec3d *v); +float vm_vec_dot3(float x, float y, float z, vec3d *v); #endif //computes cross product of two vectors. returns ptr to dest //dest CANNOT equal either source -vec3d *vm_vec_crossprod(vec3d *dest,vec3d *src0,vec3d *src1); +vec3d *vm_vec_crossprod(vec3d *dest, const vec3d *src0, const vec3d *src1); #define vm_vec_cross vm_vec_crossprod // test if 2 vectors are parallel or not. -int vm_test_parallel(vec3d *src0, vec3d *src1); +int vm_test_parallel(const vec3d *src0, const vec3d *src1); //computes surface normal from three points. result is normalized //returns ptr to dest //dest CANNOT equal either source -vec3d *vm_vec_normal(vec3d *dest,vec3d *p0,vec3d *p1,vec3d *p2); +vec3d *vm_vec_normal(vec3d *dest,const vec3d *p0, const vec3d *p1, const vec3d *p2); //computes non-normalized surface normal from three points. //returns ptr to dest //dest CANNOT equal either source -vec3d *vm_vec_perp(vec3d *dest,vec3d *p0,vec3d *p1,vec3d *p2); +vec3d *vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d *p2); //computes the delta angle between two vectors. //vectors need not be normalized. if they are, call vm_vec_delta_ang_norm() //the forward vector (third parameter) can be NULL, in which case the absolute //value of the angle in returned. Otherwise the angle around that vector is //returned. -float vm_vec_delta_ang(vec3d *v0,vec3d *v1,vec3d *fvec); +float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *fvec); //computes the delta angle between two normalized vectors. -float vm_vec_delta_ang_norm(vec3d *v0,vec3d *v1,vec3d *fvec); +float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1,const vec3d *fvec); //computes a matrix from a set of three angles. returns ptr to matrix -matrix *vm_angles_2_matrix(matrix *m,angles *a); +matrix *vm_angles_2_matrix(matrix *m, const angles *a); // Computes a matrix from a single angle. // angle_index = 0,1,2 for p,b,h matrix *vm_angle_2_matrix(matrix *m, float a, int angle_index); //computes a matrix from a forward vector and an angle -matrix *vm_vec_ang_2_matrix(matrix *m,vec3d *v,float a); +matrix *vm_vec_ang_2_matrix(matrix *m, const vec3d *v, float a); //computes a matrix from one or more vectors. The forward vector is required, //with the other two being optional. If both up & right vectors are passed, //the up vector is used. If only the forward vector is passed, a bank of //zero is assumed //returns ptr to matrix -matrix *vm_vector_2_matrix(matrix *m,vec3d *fvec,vec3d *uvec,vec3d *rvec); +matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec); //this version of vector_2_matrix requires that the vectors be more-or-less //normalized and close to perpendicular -matrix *vm_vector_2_matrix_norm(matrix *m,vec3d *fvec,vec3d *uvec = NULL,vec3d *rvec = NULL); +matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec = NULL, const vec3d *rvec = NULL); //rotates a vector through a matrix. returns ptr to dest vector //dest CANNOT equal either source -vec3d *vm_vec_rotate(vec3d *dest,vec3d *src,matrix *m); +vec3d *vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m); //rotates a vector through the transpose of the given matrix. //returns ptr to dest vector @@ -360,7 +360,7 @@ vec3d *vm_vec_rotate(vec3d *dest,vec3d *src,matrix *m); // THIS DOES NOT ACTUALLY TRANSPOSE THE SOURCE MATRIX!!! So if // you need it transposed later on, you should use the // vm_vec_transpose() / vm_vec_rotate() technique. -vec3d *vm_vec_unrotate(vec3d *dest,vec3d *src,matrix *m); +vec3d *vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m); //transpose a matrix in place. returns ptr to matrix matrix *vm_transpose_matrix(matrix *m); @@ -368,19 +368,19 @@ matrix *vm_transpose_matrix(matrix *m); //copy and transpose a matrix. returns ptr to matrix //dest CANNOT equal source. use vm_transpose_matrix() if this is the case -matrix *vm_copy_transpose_matrix(matrix *dest,matrix *src); +matrix *vm_copy_transpose_matrix(matrix *dest, const matrix *src); #define vm_copy_transpose(dest,src) vm_copy_transpose_matrix((dest),(src)) //mulitply 2 matrices, fill in dest. returns ptr to dest //dest CANNOT equal either source -matrix *vm_matrix_x_matrix(matrix *dest,matrix *src0,matrix *src1); +matrix *vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1); //extract angles from a matrix -angles *vm_extract_angles_matrix(angles *a,matrix *m); -angles *vm_extract_angles_matrix_alternate(angles *a,matrix *m); +angles *vm_extract_angles_matrix(angles *a, const matrix *m); +angles *vm_extract_angles_matrix_alternate(angles *a, const matrix *m); //extract heading and pitch from a vector, assuming bank==0 -angles *vm_extract_angles_vector(angles *a,vec3d *v); +angles *vm_extract_angles_vector(angles *a, const vec3d *v); //make sure matrix is orthogonal void vm_orthogonalize_matrix(matrix *m_src); @@ -391,13 +391,13 @@ void vm_fix_matrix(matrix *m); //Rotates the orient matrix by the angles in tangles and then //makes sure that the matrix is orthogonal. -void vm_rotate_matrix_by_angles( matrix *orient, angles *tangles ); +void vm_rotate_matrix_by_angles( matrix *orient, const angles *tangles ); //compute the distance from a point to a plane. takes the normalized normal //of the plane (ebx), a point on the plane (edi), and the point to check (esi). //returns distance in eax //distance is signed, so negative dist is on the back of the plane -float vm_dist_to_plane(vec3d *checkp,vec3d *norm,vec3d *planep); +float vm_dist_to_plane(const vec3d *checkp, const vec3d *norm, const vec3d *planep); // Given mouse movement in dx, dy, returns a 3x3 rotation matrix in RotMat. // Taken from Graphics Gems III, page 51, "The Rolling Ball" @@ -414,11 +414,11 @@ void vm_trackball( int idx, int idy, matrix * RotMat ); // Return value indicated where on the line *nearest_point lies. Between 0.0f and 1.0f means it's // in the line segment. Positive means beyond *p1, negative means before *p0. 2.0f means it's // beyond *p1 by 2x. -float find_nearest_point_on_line(vec3d *nearest_point, vec3d *p0, vec3d *p1, vec3d *int_pnt); +float find_nearest_point_on_line(vec3d *nearest_point, const vec3d *p0, const vec3d *p1, const vec3d *int_pnt); -float vm_vec_dot_to_point(vec3d *dir, vec3d *p1, vec3d *p2); +float vm_vec_dot_to_point(const vec3d *dir, const vec3d *p1, const vec3d *p2); -void compute_point_on_plane(vec3d *q, plane *planep, vec3d *p); +void compute_point_on_plane(vec3d *q, const plane *planep, const vec3d *p); // ---------------------------------------------------------------------------- // computes the point on a plane closest to a given point (which may be on the plane) @@ -427,7 +427,7 @@ void compute_point_on_plane(vec3d *q, plane *planep, vec3d *p); // point => point to compute closest plane point // plane_normal => plane normal // plane_point => plane point -void vm_project_point_onto_plane(vec3d *new_point, vec3d *point, vec3d *plane_normal, vec3d *plane_point); +void vm_project_point_onto_plane(vec3d *new_point, const vec3d *point, const vec3d *plane_normal, const vec3d *plane_point); // Returns fairly random vector, "quick" normalized @@ -437,13 +437,13 @@ void vm_vec_rand_vec_quick(vec3d *rvec); // arbritary line defined by a point on the line "line_point" // and the normalized line direction, "line_dir" // Returns the rotated point in "out". -void vm_rot_point_around_line(vec3d *out, vec3d *in, float angle, vec3d *line_point, vec3d *line_dir); +void vm_rot_point_around_line(vec3d *out, const vec3d *in, float angle, const vec3d *line_point, const vec3d *line_dir); // Given two position vectors, return 0 if the same, else non-zero. -int vm_vec_cmp( vec3d * a, vec3d * b ); +int vm_vec_cmp(const vec3d * a, const vec3d * b); // Given two orientation matrices, return 0 if the same, else non-zero. -int vm_matrix_cmp( matrix * a, matrix * b ); +int vm_matrix_cmp(const matrix * a, const matrix * b); // Moves angle 'h' towards 'desired_angle', taking the shortest // route possible. It will move a maximum of 'step_size' radians @@ -455,10 +455,10 @@ float vm_interp_angle( float *h, float desired_angle, float step_size, bool forc float vm_delta_from_interp_angle( float current_angle, float desired_angle ); // check a matrix for zero rows and columns -int vm_check_matrix_for_zeros(matrix *m); +int vm_check_matrix_for_zeros(const matrix *m); // see if two vectors are identical -int vm_vec_same(vec3d *v1, vec3d *v2); +int vm_vec_same(const vec3d *v1, const vec3d *v2); // see if two matrices are identical int vm_matrix_same(matrix *m1, matrix *m2); @@ -467,66 +467,66 @@ int vm_matrix_same(matrix *m1, matrix *m2); // Moves at maximum rotational acceleration toward the goal when far and then max deceleration when close. // Subject to constaints on rotational velocity and angular accleleration. // Returns next_orientation valid at time delta_t. -void vm_matrix_interpolate(matrix *goal_orient, matrix *start_orient, vec3d *rotvel_in, float delta_t, - matrix *next_orient, vec3d *rotvel_out, vec3d *rotvel_limit, vec3d *acc_limit, int no_overshoot=0); +void vm_matrix_interpolate(const matrix *goal_orient, const matrix *start_orient, const vec3d *rotvel_in, float delta_t, + matrix *next_orient, vec3d *rotvel_out, const vec3d *rotvel_limit, const vec3d *acc_limit, int no_overshoot=0); // Interpolate from a start forward vec toward a goal forward vec, minimizing time between orientations. // Moves at maximum rotational acceleration toward the goal when far and then max deceleration when close. // Subject to constaints on rotational velocity and angular accleleration. // Returns next forward vec valid at time delta_t. -void vm_forward_interpolate(vec3d *goal_fvec, matrix *orient, vec3d *rotvel_in, float delta_t, float delta_bank, - matrix *next_orient, vec3d *rotvel_out, vec3d *vel_limit, vec3d *acc_limit, int no_overshoot=0); +void vm_forward_interpolate(const vec3d *goal_fvec, const matrix *orient, const vec3d *rotvel_in, float delta_t, float delta_bank, + matrix *next_orient, vec3d *rotvel_out, const vec3d *vel_limit, const vec3d *acc_limit, int no_overshoot=0); // Find the bounding sphere for a set of points (center and radius are output parameters) -void vm_find_bounding_sphere(vec3d *pnts, int num_pnts, vec3d *center, float *radius); +void vm_find_bounding_sphere(const vec3d *pnts, int num_pnts, vec3d *center, float *radius); // Version of atan2() that is safe for optimized builds float atan2_safe(float x, float y); // Translates from world coordinates to body coordinates -vec3d* vm_rotate_vec_to_body(vec3d *body_vec, vec3d *world_vec, matrix *orient); +vec3d* vm_rotate_vec_to_body(vec3d *body_vec, const vec3d *world_vec, const matrix *orient); // Translates from body coordinates to world coordiantes -vec3d* vm_rotate_vec_to_world(vec3d *world_vec, vec3d *body_vec, matrix *orient); +vec3d* vm_rotate_vec_to_world(vec3d *world_vec, const vec3d *body_vec, const matrix *orient); // estimate next orientation matrix as extrapolation of last and current -void vm_estimate_next_orientation(matrix *last_orient, matrix *current_orient, matrix *next_orient); +void vm_estimate_next_orientation(const matrix *last_orient, const matrix *current_orient, matrix *next_orient); // Return true if all elements of *vec are legal, that is, not a NAN. -int is_valid_vec(vec3d *vec); +int is_valid_vec(const vec3d *vec); // Return true if all elements of *m are legal, that is, not a NAN. -int is_valid_matrix(matrix *m); +int is_valid_matrix(const matrix *m); // Finds the rotation matrix corresponding to a rotation of theta about axis u -void vm_quaternion_rotate(matrix *m, float theta, vec3d *u); +void vm_quaternion_rotate(matrix *m, float theta, const vec3d *u); // Takes a rotation matrix and returns the axis and angle needed to generate it -void vm_matrix_to_rot_axis_and_angle(matrix *m, float *theta, vec3d *rot_axis); +void vm_matrix_to_rot_axis_and_angle(const matrix *m, float *theta, vec3d *rot_axis); // interpolate between 2 vectors. t goes from 0.0 to 1.0. at -void vm_vec_interp_constant(vec3d *out, vec3d *v1, vec3d *v2, float t); +void vm_vec_interp_constant(vec3d *out, const vec3d *v1, const vec3d *v2, float t); // randomly perturb a vector around a given (normalized vector) or optional orientation matrix -void vm_vec_random_cone(vec3d *out, vec3d *in, float max_angle, matrix *orient = NULL); -void vm_vec_random_cone(vec3d *out, vec3d *in, float min_angle, float max_angle, matrix *orient = NULL); +void vm_vec_random_cone(vec3d *out, const vec3d *in, float max_angle, const matrix *orient = NULL); +void vm_vec_random_cone(vec3d *out, const vec3d *in, float min_angle, float max_angle, const matrix *orient = NULL); // given a start vector, an orientation and a radius, give a point on the plane of the circle // if on_edge is 1, the point is on the very edge of the circle -void vm_vec_random_in_circle(vec3d *out, vec3d *in, matrix *orient, const float radius, const int on_edge); +void vm_vec_random_in_circle(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge); // given a start vector, an orientation, and a radius, give a point in a spherical volume // if on_edge is 1, the point is on the very edge of the sphere -void vm_vec_random_in_sphere(vec3d *out, vec3d *in, matrix *orient, const float radius, const int on_edge); +void vm_vec_random_in_sphere(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge); // find the nearest point on the line to p. if dist is non-NULL, it is filled in // returns 0 if the point is inside the line segment, -1 if "before" the line segment and 1 ir "after" the line segment -int vm_vec_dist_to_line(vec3d *p, vec3d *l0, vec3d *l1, vec3d *nearest, float *dist); +int vm_vec_dist_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist); // Goober5000 // Finds the distance squared to a line. Same as above, except it uses vm_vec_dist_squared, which is faster; // and it doesn't check whether the nearest point is on the line segment. -void vm_vec_dist_squared_to_line(vec3d *p, vec3d *l0, vec3d *l1, vec3d *nearest, float *dist_squared); +void vm_vec_dist_squared_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist_squared); //SUSHI: 2D vector "box" scaling void vm_vec_boxscale(vec2d *vec, float scale); diff --git a/code/menuui/barracks.cpp b/code/menuui/barracks.cpp index acae59253a..78b1e68ba6 100644 --- a/code/menuui/barracks.cpp +++ b/code/menuui/barracks.cpp @@ -364,7 +364,7 @@ void barracks_init_stats(scoring_struct *stats) Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary friendly hit %:", 56)); - if (stats->p_bonehead_hits > 0) { + if (stats->p_shots_fired > 0) { f = (float) stats->p_bonehead_hits * 100.0f / (float) stats->p_shots_fired; } else { f = 0.0f; @@ -404,7 +404,7 @@ void barracks_init_stats(scoring_struct *stats) Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary friendly hit %:", 61)); - if (stats->s_bonehead_hits > 0) { + if (stats->s_shots_fired > 0) { f = (float) stats->s_bonehead_hits * 100.0f / (float) stats->s_shots_fired; } else { f = 0.0f; diff --git a/code/menuui/mainhallmenu.cpp b/code/menuui/mainhallmenu.cpp index 5b513df6d5..5d63eb2055 100644 --- a/code/menuui/mainhallmenu.cpp +++ b/code/menuui/mainhallmenu.cpp @@ -1839,11 +1839,11 @@ int main_hall_get_index(const SCP_string &name_to_find) int main_hall_get_resolution_index(int main_hall_num) { unsigned int i; - float aspect_ratio = (float)gr_screen.max_w / (float)gr_screen.max_h; + float aspect_ratio = (float)gr_screen.center_w / (float)gr_screen.center_h; for (i = Main_hall_defines.at(main_hall_num).size() - 1; i >= 1; i--) { main_hall_defines* m = &Main_hall_defines.at(main_hall_num).at(i); - if (gr_screen.max_w >= m->min_width && gr_screen.max_h >= m->min_height && aspect_ratio >= m->min_aspect_ratio) { + if (gr_screen.center_w >= m->min_width && gr_screen.center_h >= m->min_height && aspect_ratio >= m->min_aspect_ratio) { return i; } } @@ -2125,7 +2125,7 @@ void parse_main_hall_table(const char* filename) } } else { - snprintf(temp_string, MAX_FILENAME_LEN, "%d", count); + snprintf(temp_string, MAX_FILENAME_LEN, "%u", count); m->name = temp_string; } } diff --git a/code/mission/missionbriefcommon.cpp b/code/mission/missionbriefcommon.cpp index be6bdf48ea..2711c3661d 100644 --- a/code/mission/missionbriefcommon.cpp +++ b/code/mission/missionbriefcommon.cpp @@ -265,7 +265,7 @@ void brief_render_grid(grid *gridp); void brief_modify_grid(grid *gridp); void brief_rpd_line(vec3d *v0, vec3d *v1); void brief_set_text_color(char color_tag); -extern void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vec3d *acc_max, vec3d *w_max); +extern void get_camera_limits(const matrix *start_camera, const matrix *end_camera, float time, vec3d *acc_max, vec3d *w_max); int brief_text_wipe_finished(); // -------------------------------------------------------------------------------------- diff --git a/code/mission/missionparse.cpp b/code/mission/missionparse.cpp index 85384b9811..99bf9aa8dd 100644 --- a/code/mission/missionparse.cpp +++ b/code/mission/missionparse.cpp @@ -973,7 +973,7 @@ void parse_cutscenes(mission *pm) { mission_cutscene scene; - while (true) + while (!optional_string("#end")) { // this list should correspond to the MOVIE_* #defines scene.type = optional_string_one_of(6, @@ -1000,9 +1000,6 @@ void parse_cutscenes(mission *pm) // add it pm->cutscenes.push_back(scene); } - - // for reverse compatibility, check that we have a closing tag - optional_string("#end"); } } @@ -1838,6 +1835,7 @@ int parse_create_object_sub(p_object *p_objp) shipp->ship_max_shield_strength = p_objp->ship_max_shield_strength; shipp->ship_max_hull_strength = p_objp->ship_max_hull_strength; + shipp->max_shield_recharge = p_objp->max_shield_recharge; // Goober5000 - ugh, this is really stupid having to do this here; if the // ship creation code was better organized this wouldn't be necessary @@ -2250,7 +2248,7 @@ int parse_create_object_sub(p_object *p_objp) Objects[objnum].hull_strength = p_objp->initial_hull * shipp->ship_max_hull_strength / 100.0f; for (iLoop = 0; iLoopinitial_shields * get_max_shield_quad(&Objects[objnum]) / 100.0f); + Objects[objnum].shield_quadrant[iLoop] = (float) (shipp->max_shield_recharge * p_objp->initial_shields * get_max_shield_quad(&Objects[objnum]) / 100.0f); } // initial velocities now do not apply to ships which warp in after mission starts @@ -3110,6 +3108,7 @@ int parse_object(mission *pm, int flag, p_object *p_objp) } Assert(p_objp->ship_max_hull_strength > 0.0f); // Goober5000: div-0 check (not shield because we might not have one) + p_objp->max_shield_recharge = Ship_info[p_objp->ship_class].max_shield_recharge; // if the kamikaze flag is set, we should have the next flag @@ -7558,6 +7557,7 @@ void mission_bring_in_support_ship( object *requester_objp ) // set support ship hitpoints pobj->ship_max_hull_strength = Ship_info[i].max_hull_strength; pobj->ship_max_shield_strength = Ship_info[i].max_shield_strength; + pobj->max_shield_recharge = Ship_info[i].max_shield_recharge; pobj->team = requester_shipp->team; diff --git a/code/mission/missionparse.h b/code/mission/missionparse.h index 83501a5d64..5f1252efaa 100644 --- a/code/mission/missionparse.h +++ b/code/mission/missionparse.h @@ -424,6 +424,8 @@ public: float ship_max_hull_strength; // Needed to deal with special hitpoints float ship_max_shield_strength; + float max_shield_recharge; + // Goober5000 SCP_vector replacement_textures; diff --git a/code/missionui/missiondebrief.cpp b/code/missionui/missiondebrief.cpp index 34ea2d2cb6..6bd3261e2c 100644 --- a/code/missionui/missiondebrief.cpp +++ b/code/missionui/missiondebrief.cpp @@ -2319,7 +2319,7 @@ void debrief_do_frame(float frametime) gr_set_color_fast(&Color_normal); gr_set_font(FONT2); gr_get_string_size(&str_w, &str_h, please_wait_str); - gr_string((gr_screen.max_w - str_w) / 2, (gr_screen.max_h - str_h) / 2, please_wait_str, GR_RESIZE_MENU); + gr_string((gr_screen.max_w_unscaled - str_w) / 2, (gr_screen.max_h_unscaled - str_h) / 2, please_wait_str, GR_RESIZE_MENU); gr_set_font(FONT1); gr_flip(); diff --git a/code/missionui/missionrecommend.cpp b/code/missionui/missionrecommend.cpp deleted file mode 100644 index 4faa871fbc..0000000000 --- a/code/missionui/missionrecommend.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on the - * source. - * -*/ - - diff --git a/code/missionui/missionrecommend.h b/code/missionui/missionrecommend.h deleted file mode 100644 index 3661c73869..0000000000 --- a/code/missionui/missionrecommend.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on the - * source. - * -*/ - - - -#ifndef __FREESPACE_MISSIONRECOMMEND_H__ -#define __FREESPACE_MISSIONRECOMMEND_H__ - -#endif diff --git a/code/missionui/missionstats.cpp b/code/missionui/missionstats.cpp deleted file mode 100644 index 4faa871fbc..0000000000 --- a/code/missionui/missionstats.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on the - * source. - * -*/ - - diff --git a/code/missionui/missionstats.h b/code/missionui/missionstats.h deleted file mode 100644 index 10954eca05..0000000000 --- a/code/missionui/missionstats.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) Volition, Inc. 1999. All rights reserved. - * - * All source code herein is the property of Volition, Inc. You may not sell - * or otherwise commercially exploit the source or things you created based on the - * source. - * -*/ - - - -#ifndef __FREESPACE_MISSIONSTATS_H__ -#define __FREESPACE_MISSIONSTATS_H__ - -#endif diff --git a/code/mod_table/mod_table.cpp b/code/mod_table/mod_table.cpp index 5b19c7a564..79e83d7402 100644 --- a/code/mod_table/mod_table.cpp +++ b/code/mod_table/mod_table.cpp @@ -32,6 +32,8 @@ float Briefing_window_FOV = 0.29375f; bool Disable_hc_message_ani = false; bool Red_alert_applies_to_delayed_ships = false; bool Beams_use_damage_factors = false; +float Generic_pain_flash_factor = 1.0f; +float Shield_pain_flash_factor = 0.0f; void parse_mod_table(const char *filename) @@ -181,6 +183,21 @@ void parse_mod_table(const char *filename) Briefing_window_FOV = fov; } + + if (optional_string("$Generic Pain Flash Factor:")) { + stuff_float(&Generic_pain_flash_factor); + if (Generic_pain_flash_factor != 1.0f) + mprintf(("Game Settings Table: Setting generic pain flash factor to %.2f\n", Generic_pain_flash_factor)); + + } + + if (optional_string("$Shield Pain Flash Factor:")) { + stuff_float(&Shield_pain_flash_factor); + if (Shield_pain_flash_factor != 0.0f) + mprintf(("Game Settings Table: Setting shield pain flash factor to %.2f\n", Shield_pain_flash_factor)); + + } + optional_string("#NETWORK SETTINGS"); if (optional_string("$FS2NetD port:")) { diff --git a/code/mod_table/mod_table.h b/code/mod_table/mod_table.h index f39481317d..ec864eebb6 100644 --- a/code/mod_table/mod_table.h +++ b/code/mod_table/mod_table.h @@ -27,5 +27,7 @@ extern float Briefing_window_FOV; extern bool Disable_hc_message_ani; extern bool Red_alert_applies_to_delayed_ships; extern bool Beams_use_damage_factors; +extern float Generic_pain_flash_factor; +extern float Shield_pain_flash_factor; void mod_table_init(); diff --git a/code/model/modelinterp.cpp b/code/model/modelinterp.cpp index f33cd37ad4..599ecb3035 100644 --- a/code/model/modelinterp.cpp +++ b/code/model/modelinterp.cpp @@ -129,10 +129,6 @@ static vertex **Interp_list = NULL; static int Num_interp_list_verts_allocated = 0; static float Interp_box_scale = 1.0f; // this is used to scale both detail boxes and spheres -static vec3d Interp_render_box_min = ZERO_VECTOR; -static vec3d Interp_render_box_max = ZERO_VECTOR; -static float Interp_render_sphere_radius = 0.0f; -static vec3d Interp_render_sphere_offset = ZERO_VECTOR; // ------------------------------------------------------------------- // lighting save stuff @@ -424,10 +420,6 @@ void interp_clear_instance() } Interp_box_scale = 1.0f; - Interp_render_box_min = vmd_zero_vector; - Interp_render_box_max = vmd_zero_vector; - Interp_render_sphere_radius = 0.0f; - Interp_render_sphere_offset = vmd_zero_vector; Interp_team_color_set = false; @@ -4723,21 +4715,36 @@ void model_render_children_buffers_DEPRECATED(polymodel *pm, int mn, int detail_ // if using detail boxes or spheres, check that we are valid for the range if ( !(Interp_flags & MR_FULL_DETAIL) && model->use_render_box ) { - vm_vec_copy_scale(&Interp_render_box_min, &model->render_box_min, Interp_box_scale); - vm_vec_copy_scale(&Interp_render_box_max, &model->render_box_max, Interp_box_scale); + vec3d box_min, box_max, offset; - if ( (-model->use_render_box + in_box(&Interp_render_box_min, &Interp_render_box_max, &model->offset, &View_position)) ) + if (model->use_render_box_offset) { + model_find_submodel_offset(&offset, pm->id, mn); + vm_vec_sub(&offset, &vmd_zero_vector, &offset); + vm_vec_add2(&offset, &model->render_box_offset); + } else { + offset = vmd_zero_vector; + } + + vm_vec_copy_scale(&box_min, &model->render_box_min, Interp_box_scale); + vm_vec_copy_scale(&box_max, &model->render_box_max, Interp_box_scale); + + if ( (-model->use_render_box + in_box(&box_min, &box_max, &offset, &View_position)) ) return; } if ( !(Interp_flags & MR_FULL_DETAIL) && model->use_render_sphere ) { - Interp_render_sphere_radius = model->render_sphere_radius * Interp_box_scale; + float radius = model->render_sphere_radius * Interp_box_scale; // TODO: doesn't consider submodel rotations yet -zookeeper vec3d offset; - model_find_submodel_offset(&offset, pm->id, mn); - vm_vec_add2(&offset, &model->render_sphere_offset); + if (model->use_render_sphere_offset) { + model_find_submodel_offset(&offset, pm->id, mn); + vm_vec_sub(&offset, &vmd_zero_vector, &offset); + vm_vec_add2(&offset, &model->render_sphere_offset); + } else { + offset = vmd_zero_vector; + } - if ( (-model->use_render_sphere + in_sphere(&offset, Interp_render_sphere_radius, &View_position)) ) + if ( (-model->use_render_sphere + in_sphere(&offset, radius, &View_position)) ) return; } @@ -4818,21 +4825,36 @@ void model_render_buffers_DEPRECATED(polymodel *pm, int mn, int render, bool is_ // if using detail boxes or spheres, check that we are valid for the range if ( !is_child && !(Interp_flags & MR_FULL_DETAIL) && model->use_render_box ) { - vm_vec_copy_scale(&Interp_render_box_min, &model->render_box_min, Interp_box_scale); - vm_vec_copy_scale(&Interp_render_box_max, &model->render_box_max, Interp_box_scale); + vec3d box_min, box_max, offset; - if ( (-model->use_render_box + in_box(&Interp_render_box_min, &Interp_render_box_max, &model->offset, &View_position)) ) + if (model->use_render_box_offset) { + model_find_submodel_offset(&offset, pm->id, mn); + vm_vec_sub(&offset, &vmd_zero_vector, &offset); + vm_vec_add2(&offset, &model->render_box_offset); + } else { + offset = vmd_zero_vector; + } + + vm_vec_copy_scale(&box_min, &model->render_box_min, Interp_box_scale); + vm_vec_copy_scale(&box_max, &model->render_box_max, Interp_box_scale); + + if ( (-model->use_render_box + in_box(&box_min, &box_max, &offset, &View_position)) ) return; } if ( !is_child && !(Interp_flags & MR_FULL_DETAIL) && model->use_render_sphere ) { - Interp_render_sphere_radius = model->render_sphere_radius * Interp_box_scale; + float radius = model->render_sphere_radius * Interp_box_scale; // TODO: doesn't consider submodel rotations yet -zookeeper vec3d offset; - model_find_submodel_offset(&offset, pm->id, mn); - vm_vec_add2(&offset, &model->render_sphere_offset); + if (model->use_render_sphere_offset) { + model_find_submodel_offset(&offset, pm->id, mn); + vm_vec_sub(&offset, &vmd_zero_vector, &offset); + vm_vec_add2(&offset, &model->render_sphere_offset); + } else { + offset = vmd_zero_vector; + } - if ( (-model->use_render_sphere + in_sphere(&offset, Interp_render_sphere_radius, &View_position)) ) + if ( (-model->use_render_sphere + in_sphere(&offset, radius, &View_position)) ) return; } diff --git a/code/model/modelread.cpp b/code/model/modelread.cpp index b1200b2123..a58b15bef8 100644 --- a/code/model/modelread.cpp +++ b/code/model/modelread.cpp @@ -1315,6 +1315,18 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs while (*p == ' ') p++; pm->submodel[n].use_render_box = atoi(p); + if ( (p = strstr(props, "$box_offset:")) != NULL ) { + p += 12; + while (*p == ' ') p++; + pm->submodel[n].render_box_offset.xyz.x = (float)strtod(p, (char **)NULL); + while (*p != ',') p++; + pm->submodel[n].render_box_offset.xyz.y = (float)strtod(++p, (char **)NULL); + while (*p != ',') p++; + pm->submodel[n].render_box_offset.xyz.z = (float)strtod(++p, (char **)NULL); + + pm->submodel[n].use_render_box_offset = true; + } + if ( (p = strstr(props, "$box_min:")) != NULL ) { p += 9; while (*p == ' ') p++; @@ -1361,6 +1373,8 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs pm->submodel[n].render_sphere_offset.xyz.y = (float)strtod(++p, (char **)NULL); while (*p != ',') p++; pm->submodel[n].render_sphere_offset.xyz.z = (float)strtod(++p, (char **)NULL); + + pm->submodel[n].use_render_sphere_offset = true; } else { pm->submodel[n].render_sphere_offset = vmd_zero_vector; } diff --git a/code/model/modelrender.cpp b/code/model/modelrender.cpp index d431b30359..95316734b3 100644 --- a/code/model/modelrender.cpp +++ b/code/model/modelrender.cpp @@ -1586,16 +1586,20 @@ bool model_render_check_detail_box(vec3d *view_pos, polymodel *pm, int submodel_ float box_scale = model_render_determine_box_scale(); if ( !( flags & MR_FULL_DETAIL ) && model->use_render_box ) { - vec3d box_min, box_max; + vec3d box_min, box_max, offset; + + if (model->use_render_box_offset) { + offset = model->render_box_offset; + } else { + model_find_submodel_offset(&offset, pm->id, submodel_num); + } vm_vec_copy_scale(&box_min, &model->render_box_min, box_scale); vm_vec_copy_scale(&box_max, &model->render_box_max, box_scale); - if ( (-model->use_render_box + in_box(&box_min, &box_max, &model->offset, view_pos)) ) { + if ( (-model->use_render_box + in_box(&box_min, &box_max, &offset, view_pos)) ) { return false; } - - return true; } if ( !(flags & MR_FULL_DETAIL) && model->use_render_sphere ) { @@ -1603,14 +1607,16 @@ bool model_render_check_detail_box(vec3d *view_pos, polymodel *pm, int submodel_ // TODO: doesn't consider submodel rotations yet -zookeeper vec3d offset; - model_find_submodel_offset(&offset, pm->id, submodel_num); - vm_vec_add2(&offset, &model->render_sphere_offset); + + if (model->use_render_sphere_offset) { + offset = model->render_sphere_offset; + } else { + model_find_submodel_offset(&offset, pm->id, submodel_num); + } if ( (-model->use_render_sphere + in_sphere(&offset, sphere_radius, view_pos)) ) { return false; } - - return true; } return true; @@ -2047,7 +2053,7 @@ void model_render_set_glow_points(polymodel *pm, int objnum) if ( objp != NULL && objp->type == OBJ_SHIP ) { shipp = &Ships[Objects[objnum].instance]; sip = &Ship_info[shipp->ship_info_index]; - SCP_unordered_map::iterator gpoi = sip->glowpoint_bank_override_map.find(-1); + gpoi = sip->glowpoint_bank_override_map.find(-1); if (gpoi != sip->glowpoint_bank_override_map.end()) { override_all = true; @@ -2106,7 +2112,7 @@ void model_render_glow_points(polymodel *pm, ship *shipp, matrix *orient, vec3d if ( shipp ) { sip = &Ship_info[shipp->ship_info_index]; - SCP_unordered_map::iterator gpoi = sip->glowpoint_bank_override_map.find(-1); + gpoi = sip->glowpoint_bank_override_map.find(-1); if(gpoi != sip->glowpoint_bank_override_map.end()) { override_all = true; diff --git a/code/network/multi.cpp b/code/network/multi.cpp index 73f3306df7..0da2b620a3 100644 --- a/code/network/multi.cpp +++ b/code/network/multi.cpp @@ -49,6 +49,7 @@ #include "fs2netd/fs2netd_client.h" #include "pilotfile/pilotfile.h" #include "debugconsole/console.h" +#include "network/psnet2.h" @@ -337,9 +338,11 @@ void multi_check_listen() } // the connection was accepted in check_for_listen. Find the netplayer whose address we connected - // with and assign the socket descriptor + // with and assign the socket descriptor. + // Updated to utilize psnet_same() for address comparison so the port is also taken into account. + // This allows multiple players using NAT to access a remote server simultneously. for (i = 0; i < MAX_PLAYERS; i++ ) { - if ( (Net_players[i].flags & NETINFO_FLAG_CONNECTED) && (!memcmp(&(addr.addr), &(Net_players[i].p_info.addr.addr), 6)) ) { + if ( (Net_players[i].flags & NETINFO_FLAG_CONNECTED) && (psnet_same(&addr, &(Net_players[i].p_info.addr))) ) { // mark this flag so we know he's "fully" connected Net_players[i].flags |= NETINFO_FLAG_RELIABLE_CONNECTED; Net_players[i].reliable_socket = sock; @@ -1791,8 +1794,8 @@ DCF(netd, "change netgame debug flags (Mulitplayer)") // display any multiplayer/networking information here void multi_display_netinfo() { - int sx = gr_screen.max_w - 200; - int sy = 20; + int sx = gr_screen.center_offset_x + gr_screen.center_w - 200; + int sy = gr_screen.center_offset_y + 20; int dy = gr_get_font_height() + 1; int idx; diff --git a/code/network/multi_pxo.cpp b/code/network/multi_pxo.cpp index 71e06429f3..9da8a9d4bf 100644 --- a/code/network/multi_pxo.cpp +++ b/code/network/multi_pxo.cpp @@ -1096,7 +1096,7 @@ void multi_pxo_init(int use_last_channel) Assert(Multi_pxo_com_bitmap != -1); // create the interface window - Multi_pxo_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0); + Multi_pxo_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0); Multi_pxo_window.set_mask_bmap(Multi_pxo_mask_fname[gr_screen.res]); // multiplayer screen common palettes @@ -1449,7 +1449,7 @@ void multi_pxo_blit_all() int bmh = -1; if(bmap != -1){ bm_get_info( bmap, &bmw, &bmh); - if((bmw != gr_screen.max_w) || (bmh != gr_screen.max_h)){ + if((bmw != gr_screen.max_w_unscaled) || (bmh != gr_screen.max_h_unscaled)){ gr_clear(); } } else { @@ -3777,7 +3777,7 @@ void multi_pxo_com_init(int input_len) int idx; // create the interface window - Multi_pxo_com_window.create(0, 0, gr_screen.max_w,gr_screen.max_h, 0); + Multi_pxo_com_window.create(0, 0, gr_screen.max_w_unscaled,gr_screen.max_h_unscaled, 0); Multi_pxo_com_window.set_mask_bmap(Multi_pxo_com_mask_fname[gr_screen.res]); // create the interface buttons @@ -4558,7 +4558,7 @@ void multi_pxo_pinfo_build_vals() // primary friendly hit % memset(Multi_pxo_pinfo_vals[15], 0, 50); - if (fs->stats.p_shots_hit > 0) { + if (fs->stats.p_shots_fired > 0) { sprintf(Multi_pxo_pinfo_vals[15], "%d%%", (int)((float)100.0f*((float)fs->stats.p_bonehead_hits/(float)fs->stats.p_shots_fired))); } else { strcpy_s(Multi_pxo_pinfo_vals[15], "0%"); @@ -4570,7 +4570,7 @@ void multi_pxo_pinfo_build_vals() // secondary friendly hit % memset(Multi_pxo_pinfo_vals[17], 0, 50); - if (fs->stats.s_shots_hit > 0) { + if (fs->stats.s_shots_fired > 0) { sprintf(Multi_pxo_pinfo_vals[17], "%d%%", (int)((float)100.0f*((float)fs->stats.s_bonehead_hits/(float)fs->stats.s_shots_fired))); } else { strcpy_s(Multi_pxo_pinfo_vals[17], "0%"); @@ -4585,7 +4585,7 @@ void multi_pxo_pinfo_init() int idx; // create the interface window - Multi_pxo_pinfo_window.create(0,0,gr_screen.max_w,gr_screen.max_h,0); + Multi_pxo_pinfo_window.create(0,0,gr_screen.max_w_unscaled,gr_screen.max_h_unscaled,0); Multi_pxo_pinfo_window.set_mask_bmap(Multi_pxo_pinfo_mask_fname[gr_screen.res]); Multi_pxo_pinfo_bitmap = bm_load(Multi_pxo_pinfo_fname[gr_screen.res]); @@ -4797,7 +4797,7 @@ void multi_pxo_notify_blit() // otherwise blit the text gr_set_color_fast(&Color_bright); gr_get_string_size(&w,NULL,Multi_pxo_notify_text); - gr_string((gr_screen.max_w - w)/2,MULTI_PXO_NOTIFY_Y,Multi_pxo_notify_text,GR_RESIZE_MENU); + gr_string((gr_screen.max_w_unscaled - w)/2,MULTI_PXO_NOTIFY_Y,Multi_pxo_notify_text,GR_RESIZE_MENU); } @@ -4816,7 +4816,7 @@ void multi_pxo_help_init() } // create the interface window - Multi_pxo_help_window.create(0,0,gr_screen.max_w,gr_screen.max_h,0); + Multi_pxo_help_window.create(0,0,gr_screen.max_w_unscaled,gr_screen.max_h_unscaled,0); Multi_pxo_help_window.set_mask_bmap(Multi_pxo_help_mask_fname[gr_screen.res]); // create the interface buttons diff --git a/code/network/multimsgs.cpp b/code/network/multimsgs.cpp index 2c42b38a84..25fb084fca 100644 --- a/code/network/multimsgs.cpp +++ b/code/network/multimsgs.cpp @@ -8393,7 +8393,7 @@ void process_flak_fired_packet(ubyte *data, header *hinfo) #define GET_NORM_VEC(d) do { char vnorm[3]; memcpy(vnorm, data+offset, 3); d.x = (float)vnorm[0] / 127.0f; d.y = (float)vnorm[1] / 127.0f; d.z = (float)vnorm[2] / 127.0f; } while(0); // player pain packet -void send_player_pain_packet(net_player *pl, int weapon_info_index, float damage, vec3d *force, vec3d *hitpos) +void send_player_pain_packet(net_player *pl, int weapon_info_index, float damage, vec3d *force, vec3d *hitpos, int quadrant_num) { ubyte data[MAX_PACKET_SIZE]; short windex; @@ -8417,6 +8417,7 @@ void send_player_pain_packet(net_player *pl, int weapon_info_index, float damage ADD_USHORT(udamage); ADD_VECTOR((*force)); ADD_VECTOR((*hitpos)); + ADD_INT(quadrant_num); // send to the player multi_io_send(pl, data, packet_size); @@ -8432,6 +8433,7 @@ void process_player_pain_packet(ubyte *data, header *hinfo) vec3d force; vec3d local_hit_pos; weapon_info *wip; + int quadrant_num; // get the data for the pain packet offset = HEADER_LENGTH; @@ -8439,6 +8441,7 @@ void process_player_pain_packet(ubyte *data, header *hinfo) GET_USHORT(udamage); GET_VECTOR(force); GET_VECTOR(local_hit_pos); + GET_INT(quadrant_num); PACKET_SET_SIZE(); // mprintf(("PAIN!\n")); @@ -8460,7 +8463,7 @@ void process_player_pain_packet(ubyte *data, header *hinfo) weapon_hit_do_sound(Player_obj, wip, &Player_obj->pos, true); // we need to do 3 things here. player pain (game flash), weapon hit sound, ship_apply_whack() - ship_hit_pain((float)udamage); + ship_hit_pain((float)udamage, quadrant_num); // apply the whack ship_apply_whack(&force, &local_hit_pos, Player_obj); diff --git a/code/network/multimsgs.h b/code/network/multimsgs.h index 73c45e2f4f..ad9f8678df 100644 --- a/code/network/multimsgs.h +++ b/code/network/multimsgs.h @@ -525,7 +525,7 @@ void send_flak_fired_packet(int ship_objnum, int subsys_index, int weapon_objnum void process_flak_fired_packet(ubyte *data, header *hinfo); // player pain packet -void send_player_pain_packet(net_player *pl, int weapon_info_index, float damage, vec3d *force, vec3d *hitpos); +void send_player_pain_packet(net_player *pl, int weapon_info_index, float damage, vec3d *force, vec3d *hitpos, int quadrant_num); void process_player_pain_packet(ubyte *data, header *hinfo); // lightning packet diff --git a/code/network/multiui.cpp b/code/network/multiui.cpp index 02af50f0e7..78f20e3da1 100644 --- a/code/network/multiui.cpp +++ b/code/network/multiui.cpp @@ -2001,7 +2001,7 @@ void multi_join_blit_top_stuff() bm_get_info(Multi_common_icons[MICON_CD], &cd_w, NULL, NULL, NULL, NULL); gr_set_bitmap(Multi_common_icons[MICON_CD]); - gr_bitmap((gr_screen.max_w / 2) - (cd_w / 2), Mj_cd_coords[gr_screen.res], GR_RESIZE_MENU); + gr_bitmap((gr_screen.max_w_unscaled / 2) - (cd_w / 2), Mj_cd_coords[gr_screen.res], GR_RESIZE_MENU); } } diff --git a/code/network/psnet2.cpp b/code/network/psnet2.cpp index 86c38bad9c..d98a3ebfad 100644 --- a/code/network/psnet2.cpp +++ b/code/network/psnet2.cpp @@ -905,7 +905,7 @@ void psnet_string_to_addr( net_addr * address, char * text ) */ int psnet_same( net_addr * a1, net_addr * a2 ) { - return !memcmp(a1->addr, a2->addr, 6); + return !memcmp(a1->addr, a2->addr, 6) && a1->port == a2->port; } /** diff --git a/code/network/stand_gui-unix.cpp b/code/network/stand_gui-unix.cpp index 52958e744c..dfca649724 100644 --- a/code/network/stand_gui-unix.cpp +++ b/code/network/stand_gui-unix.cpp @@ -201,6 +201,57 @@ public: virtual void execute() = 0; }; +class ChangeServerInformationCommand : public WebapiCommand +{ + SCP_string name; + bool hasName; + + SCP_string passwd; + bool hasPasswd; + + int framecap; + +public: + ChangeServerInformationCommand() : hasName(false), hasPasswd(false), framecap(0) {} + + void setFrameCap(int cap) { framecap = cap; } + + void setName(const char* newName) + { + hasName = true; + name.assign(newName); + } + + void setPasswd(const char* newPasswd) + { + hasPasswd = true; + passwd.assign(newPasswd); + } + + virtual void execute() + { + if (hasName) { + strcpy_s(Netgame.name, name.c_str()); + strcpy_s(Multi_options_g.std_pname, name.c_str()); + // update fs2netd with the info + if (MULTI_IS_TRACKER_GAME) { + fs2netd_gameserver_disconnect(); + Sleep(50); + fs2netd_gameserver_start(); + } + } + + if (hasPasswd) { + strcpy_s(Multi_options_g.std_passwd, passwd.c_str()); + } + + if (framecap) + { + Multi_options_g.std_framecap = framecap; + } + } +}; + class KickPlayerCommand: public WebapiCommand { public: KickPlayerCommand(int playerId) @@ -273,6 +324,7 @@ void webapiExecuteCommands() { for (SCP_vector::iterator iter = webapiCommandQueue.begin(); iter != webapiCommandQueue.end(); ++iter) { (*iter)->execute(); + delete *iter; } webapiCommandQueue.clear(); @@ -404,28 +456,25 @@ json_t* serverGet(ResourceContext *context) { } json_t* serverPut(ResourceContext *context) { - const char* name = json_string_value(json_object_get(context->requestEntity, "name")); - if (name) { - strcpy_s(Netgame.name, name); - strcpy_s(Multi_options_g.std_pname, name); - // update fs2netd with the info - if (MULTI_IS_TRACKER_GAME) { - fs2netd_gameserver_disconnect(); - os_sleep(50); - fs2netd_gameserver_start(); - } - } - const char* passwd = json_string_value(json_object_get(context->requestEntity, "password")); - if (passwd) { - strcpy_s(Multi_options_g.std_passwd, passwd); - } - int framecap = atoi(json_string_value(json_object_get(context->requestEntity, "framecap"))); - if (framecap) - { - Multi_options_g.std_framecap = framecap; - } + ChangeServerInformationCommand* changeCommand = new ChangeServerInformationCommand(); - return json_object(); + const char* name = json_string_value(json_object_get(context->requestEntity, "name")); + if (name) { + changeCommand->setName(name); + } + const char* passwd = json_string_value(json_object_get(context->requestEntity, "password")); + if (passwd) { + changeCommand->setPasswd(passwd); + } + int framecap = atoi(json_string_value(json_object_get(context->requestEntity, "framecap"))); + if (framecap) + { + changeCommand->setFrameCap(framecap); + } + + webapiAddCommand(changeCommand); + + return json_object(); } json_t* serverDelete(ResourceContext *context) { diff --git a/code/object/collideshipweapon.cpp b/code/object/collideshipweapon.cpp index dcf5b956b4..9024ac3065 100644 --- a/code/object/collideshipweapon.cpp +++ b/code/object/collideshipweapon.cpp @@ -75,7 +75,17 @@ void ship_weapon_do_hit_stuff(object *ship_obj, object *weapon_obj, vec3d *world // Apply hit & damage & stuff to weapon weapon_hit(weapon_obj, ship_obj, world_hitpos, quadrant_num); - damage = wip->damage; + if (wip->damage_time != 0.0f && wp->lifeleft <= wip->damage_time) { + if (wip->min_damage != 0.0f) { + damage = (((wip->damage - wip->min_damage) * (wp->lifeleft / wip->damage_time)) + wip->min_damage); + } else if (wip->max_damage != 0.0f) { + damage = (((wip->damage - wip->max_damage) * (wp->lifeleft / wip->damage_time)) + wip->max_damage); + } else { + damage = wip->damage * (wp->lifeleft / wip->damage_time); + } + } else { + damage = wip->damage; + } // deterine whack whack float blast = wip->mass; @@ -87,7 +97,7 @@ void ship_weapon_do_hit_stuff(object *ship_obj, object *weapon_obj, vec3d *world // if this is a player ship if((np_index >= 0) && (np_index != MY_NET_PLAYER_NUM) && (wip->subtype == WP_LASER)){ - send_player_pain_packet(&Net_players[np_index], wp->weapon_info_index, wip->damage * weapon_get_damage_scale(wip, weapon_obj, ship_obj), &force, hitpos); + send_player_pain_packet(&Net_players[np_index], wp->weapon_info_index, wip->damage * weapon_get_damage_scale(wip, weapon_obj, ship_obj), &force, hitpos, quadrant_num); } } @@ -407,6 +417,11 @@ int ship_weapon_check_collision(object *ship_objp, object *weapon_objp, float ti bool weapon_override = Script_system.IsConditionOverride(CHA_COLLIDESHIP, weapon_objp); if(!ship_override && !weapon_override) { + if (shield_collision && quadrant_num >= 0) { + if ((sip->shield_impact_explosion_anim > -1) && (wip->shield_impact_explosion_radius > 0)) { + shield_impact_explosion(&mc.hit_point, ship_objp, wip->shield_impact_explosion_radius, sip->shield_impact_explosion_anim); + } + } ship_weapon_do_hit_stuff(ship_objp, weapon_objp, &mc.hit_point_world, &mc.hit_point, quadrant_num, mc.hit_submodel, mc.hit_normal); } diff --git a/code/object/object.cpp b/code/object/object.cpp index 805054e5de..76d6d381cf 100644 --- a/code/object/object.cpp +++ b/code/object/object.cpp @@ -1126,7 +1126,7 @@ void obj_move_all_pre(object *objp, float frametime) break; case OBJ_ASTEROID: if (!physics_paused){ - asteroid_process_pre(objp,frametime); + asteroid_process_pre(objp); } break; /* case OBJ_CMEASURE: @@ -1340,7 +1340,7 @@ void obj_move_all_post(object *objp, float frametime) case OBJ_ASTEROID: { if ( !physics_paused ) - asteroid_process_post(objp, frametime); + asteroid_process_post(objp); break; } diff --git a/code/object/objectshield.cpp b/code/object/objectshield.cpp index 1d9b7a52b7..7c015e6778 100644 --- a/code/object/objectshield.cpp +++ b/code/object/objectshield.cpp @@ -49,10 +49,19 @@ void shield_add_strength(object *objp, float delta) if (delta == 0.0f) return; - + float shield_str = shield_get_strength(objp); + float shield_recharge_limit = Ships[objp->instance].ship_max_shield_strength * Ships[objp->instance].max_shield_recharge; + + if (shield_str >= shield_recharge_limit) + return; + if (!(Ai_info[Ships[objp->instance].ai_index].ai_profile_flags & AIPF_SMART_SHIELD_MANAGEMENT) || delta <= 0.0f) //SUSHI: We don't want smart shield management for negative delta { + // set the limit for the shield recharge + if ((delta > 0.0f) && ((shield_str + delta) > shield_recharge_limit)) + delta = shield_recharge_limit - shield_str; + for (int i = 0; i < objp->n_quadrants; i++) shield_add_quad(objp, i, delta / objp->n_quadrants); } @@ -81,7 +90,11 @@ void shield_add_strength(object *objp, float delta) // all quads are at full strength if (weakest >= section_max) break; - + + // set the limit for the shield recharge + if ((delta > 0.0f) && ((shield_str + delta) > shield_recharge_limit)) + delta = shield_recharge_limit - shield_str; + // throw all possible shield power at this quadrant // if there's any left over then apply it to the next weakest on the next pass float xfer_amount; diff --git a/code/object/objectsnd.cpp b/code/object/objectsnd.cpp index a9f04201b1..72681c782a 100644 --- a/code/object/objectsnd.cpp +++ b/code/object/objectsnd.cpp @@ -17,6 +17,7 @@ #include "ship/ship.h" #include "gamesnd/gamesnd.h" #include "sound/ds.h" +#include "cmdline/cmdline.h" #include "sound/ds3d.h" #include "io/timer.h" #include "render/3d.h" @@ -52,8 +53,8 @@ typedef struct _obj_snd { #define MIN_FORWARD_SPEED 5 #define SPEED_SOUND 600.0f // speed of sound in FreeSpace -#define MAX_OBJ_SOUNDS_PLAYING 5 -static int Num_obj_sounds_playing; +static int MAX_OBJ_SOUNDS_PLAYING = -1; // initialized in obj_snd_level_init() +static int Num_obj_sounds_playing; #define OBJSND_CHANGE_FREQUENCY_THRESHOLD 10 @@ -192,6 +193,11 @@ void obj_snd_level_init() { int i; + if (MAX_OBJ_SOUNDS_PLAYING < 0) + { + MAX_OBJ_SOUNDS_PLAYING = Cmdline_no_enhanced_sound ? 5 : 12; + } + list_init(&obj_snd_list); for ( i = 0; i < MAX_OBJ_SNDS; i++ ) { Objsnds[i].flags = 0; @@ -621,7 +627,7 @@ void obj_snd_do_frame() } // end switch if ( go_ahead_flag ) { - osp->instance = snd_play_3d(gs, &source_pos, &View_position, add_distance, &objp->phys_info.vel, 1, 1.0f, SND_PRIORITY_TRIPLE_INSTANCE); + osp->instance = snd_play_3d(gs, &source_pos, &View_position, add_distance, &objp->phys_info.vel, 1, 1.0f, SND_PRIORITY_TRIPLE_INSTANCE, NULL, 1.0f, 0, true); if ( osp->instance != -1 ) { Num_obj_sounds_playing++; } diff --git a/code/object/objectsort.cpp b/code/object/objectsort.cpp index 68924709c3..33f780a3d2 100644 --- a/code/object/objectsort.cpp +++ b/code/object/objectsort.cpp @@ -286,7 +286,7 @@ void obj_render_all(void (*render_function)(object *objp), bool *draw_viewer_las } if ( obj_render_is_model(obj) ) { - if( (obj->type == OBJ_SHIP) && Ships[obj->instance].shader_effect_active || obj->type == OBJ_FIREBALL ) + if( ((obj->type == OBJ_SHIP) && Ships[obj->instance].shader_effect_active) || (obj->type == OBJ_FIREBALL) ) effect_ships.push_back(obj); else (*render_function)(obj); diff --git a/code/palman/palman.cpp b/code/palman/palman.cpp index 956dda2d9e..22849fd3a7 100644 --- a/code/palman/palman.cpp +++ b/code/palman/palman.cpp @@ -546,7 +546,6 @@ ubyte *palette_get_blend_table(float alpha) if ( alpha <= blend_table_factors[i] ) break; } - if ( i<0 ) i = 0; if ( i>NUM_BLEND_TABLES-1 ) i = NUM_BLEND_TABLES-1; return &palette_blend_table[i*256*256]; diff --git a/code/parse/lua.cpp b/code/parse/lua.cpp index 14c039a2cb..1644bfc3e3 100644 --- a/code/parse/lua.cpp +++ b/code/parse/lua.cpp @@ -2893,6 +2893,25 @@ ADE_FUNC(isGliding, l_Physics, NULL, "True if glide mode is on, false or nil if return ade_set_args(L, "b", false); } +ADE_FUNC(applyWhack, l_Physics, "vector Impulse, [ vector Position]", "Applies a whack to an object at a position (a local vector) based on impulse supplied (a world vector). If no position is supplied, an empty vector is used.", "boolean", "true if it succeeded, false otherwise") + { + object_h objh; + physics_info_h *pih; + vec3d *impulse; + vec3d *offset = &vmd_zero_vector; + + if (!ade_get_args(L, "oo|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&impulse), l_Vector.GetPtr(&offset))) + return ADE_RETURN_NIL; + + objh = pih->objh; + + physics_apply_whack(impulse, offset, pih->pi, &objh.objp->orient, pih->pi->mass); + + return ADE_RETURN_TRUE; + +} + + //**********HANDLE: sexpvariable struct sexpvar_h { @@ -13099,6 +13118,38 @@ ADE_FUNC(getScreenHeight, l_Graphics, NULL, "Gets screen height", "number", "Hei return ade_set_args(L, "i", gr_screen.max_h); } +ADE_FUNC(getCenterWidth, l_Graphics, NULL, "Gets width of center monitor (should be used in conjuction with getCenterOffsetX)", "number", "Width of center monitor in pixels, or 0 if graphics are not initialized yet") +{ + if(!Gr_inited) + return ade_set_error(L, "i", 0); + + return ade_set_args(L, "i", gr_screen.center_w); +} + +ADE_FUNC(getCenterHeight, l_Graphics, NULL, "Gets height of center monitor (should be used in conjuction with getCenterOffsetY)", "number", "Height of center monitor in pixels, or 0 if graphics are not initialized yet") +{ + if(!Gr_inited) + return ade_set_error(L, "i", 0); + + return ade_set_args(L, "i", gr_screen.center_h); +} + +ADE_FUNC(getCenterOffsetX, l_Graphics, NULL, "Gets X offset of center monitor", "number", "X offset of center monitor in pixels") +{ + if(!Gr_inited) + return ade_set_error(L, "i", 0); + + return ade_set_args(L, "i", gr_screen.center_offset_x); +} + +ADE_FUNC(getCenterOffsetY, l_Graphics, NULL, "Gets Y offset of center monitor", "number", "Y offset of center monitor in pixels") +{ + if(!Gr_inited) + return ade_set_error(L, "i", 0); + + return ade_set_args(L, "i", gr_screen.center_offset_y); +} + ADE_FUNC(getCurrentCamera, l_Graphics, "[boolean]", "Gets the current camera handle, if argument is true then it will also return the main camera when no custom camera is in use", "camera", "camera handle or invalid handle on error") { camid current; @@ -13644,7 +13695,7 @@ ADE_FUNC(drawTargetingBrackets, l_Graphics, "object Object, [boolean draw=true, y1 -= padding; y2 += padding; if ( draw_box ) { - draw_brackets_square(x1, y1, x2, y2, false); + draw_brackets_square(x1, y1, x2, y2, GR_RESIZE_NONE); } if ( entered_frame ) diff --git a/code/parse/parselo.cpp b/code/parse/parselo.cpp index 3f7581d9db..23d32a1b5a 100644 --- a/code/parse/parselo.cpp +++ b/code/parse/parselo.cpp @@ -661,16 +661,21 @@ int optional_string_fred(char *pstr, char *end, char *end2) return 1; } -// Return 0 or 1 for str1 match, str2 match. Return -1 if neither matches. -// Does not update Mp if token found. If not found, advances, trying to -// find the string. Doesn't advance past the found string. +/** + * @brief Checks for one of two required strings + * + * @retval 0 for str1 match + * @retval 1 for str2 match + * @throws parse::ParseException If neither strings were found + * + * @details Advances the Mp until a string is found or exceeds RS_MAX_TRIES. Once a string is found, Mp is located at + * the start of the found string. + */ int required_string_either(char *str1, char *str2) { - int count = 0; - ignore_white_space(); - while (count < RS_MAX_TRIES) { + for (int count = 0; count < RS_MAX_TRIES; ++count) { if (strnicmp(str1, Mp, strlen(str1)) == 0) { // Mp += strlen(str1); diag_printf("Found required string [%s]\n", token_found = str1); @@ -685,19 +690,22 @@ int required_string_either(char *str1, char *str2) advance_to_eoln(NULL); ignore_white_space(); - count++; } - if (count == RS_MAX_TRIES) { - nprintf(("Error", "Error: Unable to find either required token [%s] or [%s]\n", str1, str2)); - Warning(LOCATION, "Error: Unable to find either required token [%s] or [%s]\n", str1, str2); - throw parse::ParseException("Required string not found"); - } - - return -1; + nprintf(("Error", "Error: Unable to find either required token [%s] or [%s]\n", str1, str2)); + Warning(LOCATION, "Error: Unable to find either required token [%s] or [%s]\n", str1, str2); + throw parse::ParseException("Required string not found"); + return -1; // Dead code, but some compilers still complain about it } -// Generic version of old required_string_3 and required_string_4; written by ngld, with some tweaks by MageKing17 +/** + * @brief Checks for one of any of the given required strings. + * + * @returns The index number of the found string, if it was found + * @returns -1 if a string was not found + * + * @details By ngld, with some tweaks by MageKing17. + */ int required_string_one_of(int arg_count, ...) { Assertion(arg_count > 0, "required_string_one_of() called with arg_count of %d; get a coder!\n", arg_count); diff --git a/code/parse/scripting.cpp b/code/parse/scripting.cpp index 71e0a60c4a..61ed5c612c 100644 --- a/code/parse/scripting.cpp +++ b/code/parse/scripting.cpp @@ -83,7 +83,10 @@ flag_def_list Script_actions[] = {"On Ship Arrive", CHA_ONSHIPARRIVE, 0}, {"On Beam Collision", CHA_COLLIDEBEAM, 0}, {"On Message Received", CHA_MSGRECEIVED, 0}, - {"On HUD Message Received", CHA_HUDMSGRECEIVED, 0} + {"On HUD Message Received", CHA_HUDMSGRECEIVED, 0}, + { "On Afterburner Engage", CHA_AFTERBURNSTART, 0 }, + { "On Afterburner Stop", CHA_AFTERBURNEND, 0 }, + { "On Beam Fire", CHA_BEAMFIRE, 0 } }; int Num_script_actions = sizeof(Script_actions)/sizeof(flag_def_list); @@ -428,6 +431,11 @@ bool ConditionedHook::ConditionsValid(int action, object *objp, int more_data) return false; break; } + case CHA_BEAMFIRE: { + if (!(stricmp(Weapon_info[more_data].name, scp->data.name) == 0)) + return false; + break; + } } } // case CHC_WEAPONCLASS diff --git a/code/parse/scripting.h b/code/parse/scripting.h index d005cef47f..ba49052b15 100644 --- a/code/parse/scripting.h +++ b/code/parse/scripting.h @@ -76,6 +76,9 @@ struct image_desc #define CHA_ONACTIONSTOPPED 33 #define CHA_MSGRECEIVED 34 #define CHA_HUDMSGRECEIVED 35 +#define CHA_AFTERBURNSTART 36 +#define CHA_AFTERBURNEND 37 +#define CHA_BEAMFIRE 38 // management stuff void scripting_state_init(); diff --git a/code/parse/sexp.cpp b/code/parse/sexp.cpp index ad7edcb4ea..07ba4a2c6b 100755 --- a/code/parse/sexp.cpp +++ b/code/parse/sexp.cpp @@ -16555,6 +16555,7 @@ void parse_copy_damage(p_object *target_pobjp, ship *source_shipp) // ...and shields target_pobjp->ship_max_shield_strength = source_shipp->ship_max_shield_strength; target_pobjp->initial_shields = fl2i(get_shield_pct(source_objp) * 100.0f); + target_pobjp->max_shield_recharge = source_shipp->max_shield_recharge; // search through all subsystems on source ship and map them onto target ship @@ -21095,13 +21096,13 @@ void sexp_show_subtitle(int node) bool post_shaded = false; x_pos = eval_num(node); - if (gr_screen.max_w != 1024) - x_pos = (int) ((x_pos / 1024.0f) * gr_screen.max_w); + if (gr_screen.center_w != 1024) + x_pos = (int) ((x_pos / 1024.0f) * gr_screen.center_w); n = CDR(node); y_pos = eval_num(n); - if (gr_screen.max_h != 768) - y_pos = (int) ((y_pos / 768.0f) * gr_screen.max_h); + if (gr_screen.center_h != 768) + y_pos = (int) ((y_pos / 768.0f) * gr_screen.center_h); n = CDR(n); text = CTEXT(n); @@ -21311,9 +21312,9 @@ void sexp_show_subtitle_text(int node) gr_init_alphacolor(&new_color, red, green, blue, 255); // calculate pixel positions - int x_pos = (int) (gr_screen.max_w * (x_pct / 100.0f)); - int y_pos = (int) (gr_screen.max_h * (y_pct / 100.0f)); - int width = (int) (gr_screen.max_w * (width_pct / 100.0f)); + int x_pos = (int) (gr_screen.center_w * (x_pct / 100.0f)); + int y_pos = (int) (gr_screen.center_h * (y_pct / 100.0f)); + int width = (int) (gr_screen.center_w * (width_pct / 100.0f)); // add the subtitle subtitle new_subtitle(x_pos, y_pos, text, NULL, display_time, fade_time, &new_color, fontnum, center_x, center_y, width, 0, post_shaded); @@ -21374,9 +21375,9 @@ void multi_sexp_show_subtitle_text() gr_init_alphacolor(&new_color, red, green, blue, 255); // calculate pixel positions - int x_pos = (int)(gr_screen.max_w * (x_pct / 100.0f)); - int y_pos = (int)(gr_screen.max_h * (y_pct / 100.0f)); - int width = (int)(gr_screen.max_w * (width_pct / 100.0f)); + int x_pos = (int)(gr_screen.center_w * (x_pct / 100.0f)); + int y_pos = (int)(gr_screen.center_h * (y_pct / 100.0f)); + int width = (int)(gr_screen.center_w * (width_pct / 100.0f)); // add the subtitle subtitle new_subtitle(x_pos, y_pos, text, NULL, display_time, fade_time, &new_color, fontnum, center_x, center_y, width, 0, post_shaded); @@ -21445,10 +21446,10 @@ void sexp_show_subtitle_image(int node) height_pct = 100; // calculate pixel positions - int x_pos = (int)(gr_screen.max_w * (x_pct / 100.0f)); - int y_pos = (int)(gr_screen.max_h * (y_pct / 100.0f)); - int width = (int)(gr_screen.max_w * (width_pct / 100.0f)); - int height = (int)(gr_screen.max_h * (height_pct / 100.0f)); + int x_pos = (int)(gr_screen.center_w * (x_pct / 100.0f)); + int y_pos = (int)(gr_screen.center_h * (y_pct / 100.0f)); + int width = (int)(gr_screen.center_w * (width_pct / 100.0f)); + int height = (int)(gr_screen.center_h * (height_pct / 100.0f)); // add the subtitle subtitle new_subtitle(x_pos, y_pos, NULL, image, display_time, fade_time, NULL, -1, center_x, center_y, width, height, post_shaded); @@ -31597,7 +31598,8 @@ sexp_help_struct Sexp_help[] = { "friendly-stealth-invisible - If set, the ship can't be targeted even by ships on the same team\r\n" "hide-ship-name - If set, the ship name can't be seen when the ship is targeted\r\n" "hidden-from-sensors - If set, the ship can't be targeted and appears on radar as a blinking dot\r\n" - "no-dynamic - Will stop allowing the AI to persue dynamic goals (eg: chasing ships it was not ordered to)\r\n"}, + "no-dynamic - Will stop allowing the AI to persue dynamic goals (eg: chasing ships it was not ordered to)\r\n" + "no-secondary-lock-on - Will disable target acquisition for secondaries of all types (does not affect turrets)\r\n"}, { OP_SHIP_VISIBLE, "ship-visible\r\n" "\tCauses the ships listed in this sexpression to be visible with player sensors.\r\n\r\n" diff --git a/code/ship/afterburner.cpp b/code/ship/afterburner.cpp index 1e467f871f..cc4127b7b6 100644 --- a/code/ship/afterburner.cpp +++ b/code/ship/afterburner.cpp @@ -19,6 +19,7 @@ #include "hud/hudets.h" #include "freespace2/freespace.h" #include "network/multi.h" +#include "parse/scripting.h" // ---------------------------------------------------------- // Global to file @@ -147,6 +148,10 @@ void afterburners_start(object *objp) } else { snd_play_3d( &Snds[ship_get_sound(objp, SND_ABURN_ENGAGE)], &objp->pos, &View_position, objp->radius ); } + + Script_system.SetHookObjects(1, "Ship", objp); + Script_system.RunCondition(CHA_AFTERBURNSTART, 0, NULL, objp); + Script_system.RemHookVars(1, "Ship"); objp->phys_info.flags |= PF_AFTERBURNER_WAIT; } @@ -297,6 +302,10 @@ void afterburners_stop(object *objp, int key_released) return; } + Script_system.SetHookObjects(1, "Ship", objp); + Script_system.RunCondition(CHA_AFTERBURNEND, 0, NULL, objp); + Script_system.RemHookVars(1, "Ship"); + objp->phys_info.flags &= ~PF_AFTERBURNER_ON; //Do anim diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 844c46fee0..903fc014de 100755 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -384,6 +384,7 @@ ship_flag_name Ship_flag_names[] = { {SF2_DONT_COLLIDE_INVIS, "don't-collide-invisible", 2, }, {SF2_NO_ETS, "no-ets", 2, }, {SF2_TOGGLE_SUBSYSTEM_SCANNING, "toggle-subsystem-scanning", 2, }, + {SF2_NO_SECONDARY_LOCKON, "no-secondary-lock-on", 2, }, }; const int num_ai_tgt_weapon_flags = sizeof(ai_tgt_weapon_flags) / sizeof(flag_def_list); @@ -867,6 +868,8 @@ void init_ship_entry(ship_info *sip) sip->max_hull_strength = 100.0f; sip->max_shield_strength = 0.0f; + sip->max_shield_recharge = 1.0f; + sip->auto_shield_spread = 0.0f; sip->auto_shield_spread_bypass = false; sip->auto_shield_spread_from_lod = -1; @@ -1013,6 +1016,7 @@ void init_ship_entry(ship_info *sip) sip->damage_lightning_type = SLT_DEFAULT; + sip->shield_impact_explosion_anim = -1; sip->hud_gauges.clear(); sip->hud_enabled = false; sip->hud_retail = false; @@ -2362,6 +2366,19 @@ int parse_ship_values(ship_info* sip, bool first_time, bool replace) stuff_ubyte(&sip->shield_color[2]); } + if(optional_string("$Shield Impact Explosion:")) { + char fname[MAX_NAME_LEN]; + stuff_string(fname, F_NAME, NAME_LENGTH); + + if ( VALID_FNAME(fname) ) + sip->shield_impact_explosion_anim = Weapon_explosions.Load(fname); + } + + if(optional_string("$Max Shield Recharge:")){ + stuff_float(&sip->max_shield_recharge); + CLAMP(sip->max_shield_recharge, 0.0f, 1.0f); + } + // The next five fields are used for the ETS if (optional_string("$Power Output:")) stuff_float(&sip->power_output); @@ -5120,12 +5137,14 @@ void ship_set(int ship_index, int objnum, int ship_type) } objp->hull_strength = shipp->ship_max_hull_strength; + shipp->max_shield_recharge = sip->max_shield_recharge; + if (Fred_running) { shipp->ship_max_shield_strength = 100.0f; objp->shield_quadrant[0] = 100.0f; } else { shipp->ship_max_shield_strength = sip->max_shield_strength; - shield_set_strength(objp, shipp->ship_max_shield_strength); + shield_set_strength(objp, shipp->ship_max_shield_strength * shipp->max_shield_recharge); } if (sip->flags2 & SIF2_MODEL_POINT_SHIELDS) { @@ -9291,6 +9310,8 @@ void change_ship_type(int n, int ship_type, int by_sexp) objp->hull_strength = hull_pct * sp->ship_max_hull_strength; } + sp->max_shield_recharge = sip->max_shield_recharge; + // set the correct shield strength if (Fred_running) { if (sp->ship_max_shield_strength) @@ -10123,12 +10144,14 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) float next_fire_delay; bool fast_firing = false; if (winfo_p->burst_shots > swp->burst_counter[bank_to_fire]) { - next_fire_delay = (float) winfo_p->burst_delay * 1000.0f; + next_fire_delay = winfo_p->burst_delay * 1000.0f; swp->burst_counter[bank_to_fire]++; if (winfo_p->burst_flags & WBF_FAST_FIRING) fast_firing = true; + } else if (winfo_p->max_delay != 0.0f && winfo_p->min_delay != 0.0f) { // Random fire delay (DahBlount) + next_fire_delay = (((float)rand()) / (((float)RAND_MAX + 1.0f) * (winfo_p->max_delay - winfo_p->min_delay + 1.0f) + winfo_p->min_delay)) * 1000.0f; } else { - next_fire_delay = (float) winfo_p->fire_wait * 1000.0f; + next_fire_delay = winfo_p->fire_wait * 1000.0f; swp->burst_counter[bank_to_fire] = 0; } if (!((obj->flags & OF_PLAYER_SHIP) || (fast_firing))) { @@ -12731,7 +12754,7 @@ float ship_calculate_rearm_duration( object *objp ) //find out time to repair shields if(sip->sup_shield_repair_rate > 0.0f) - shield_rep_time = (sp->ship_max_shield_strength - shield_get_strength(objp)) / (sp->ship_max_shield_strength * sip->sup_shield_repair_rate); + shield_rep_time = ((sp->ship_max_shield_strength * sp->max_shield_recharge) - shield_get_strength(objp)) / (sp->max_shield_recharge * sp->ship_max_shield_strength * sip->sup_shield_repair_rate); max_hull_repair = sp->ship_max_hull_strength * (The_mission.support_ships.max_hull_repair_val * 0.01f); if ((The_mission.flags & MISSION_FLAG_SUPPORT_REPAIRS_HULL) && (max_hull_repair > objp->hull_strength) && (sip->sup_hull_repair_rate > 0.0f)) @@ -12867,7 +12890,7 @@ int ship_do_rearm_frame( object *objp, float frametime ) if ( !(objp->flags & OF_NO_SHIELDS) ) { shield_str = shield_get_strength(objp); - if ( shield_str < shipp->ship_max_shield_strength ) { + if ( shield_str < (shipp->ship_max_shield_strength * shipp->max_shield_recharge) ) { if ( objp == Player_obj ) { player_maybe_start_repair_sound(); } diff --git a/code/ship/ship.h b/code/ship/ship.h index 1a82e5b0c1..1aab8823ef 100644 --- a/code/ship/ship.h +++ b/code/ship/ship.h @@ -424,7 +424,7 @@ typedef struct ship_flag_name { int flag_list; // is this flag in the 1st or 2nd ship flags list? } ship_flag_name; -#define MAX_SHIP_FLAG_NAMES 17 +#define MAX_SHIP_FLAG_NAMES 18 extern ship_flag_name Ship_flag_names[]; // states for the flags variable within the ship structure @@ -505,6 +505,7 @@ extern ship_flag_name Ship_flag_names[]; #define SF2_WEAPONS_LOCKED (1<<25) // Karajorma - Prevents the player from changing the weapons on the ship on the loadout screen #define SF2_SHIP_SELECTIVE_LINKING (1<<26) // RSAXVC - Allow pilot to pick firing configuration #define SF2_SCRAMBLE_MESSAGES (1<<27) // Goober5000 - all messages sent from this ship appear scrambled +#define SF2_NO_SECONDARY_LOCKON (1<<28) // zookeeper - secondary lock-on disabled // If any of these bits in the ship->flags are set, ignore this ship when targeting extern int TARGET_SHIP_IGNORE_FLAGS; @@ -592,6 +593,8 @@ public: float ship_max_shield_strength; float ship_max_hull_strength; + float max_shield_recharge; + int ship_guardian_threshold; // Goober5000 - now also determines whether ship is guardian'd @@ -1306,6 +1309,8 @@ public: int shield_point_augment_ctrls[4]; // Re-mapping of shield augmentation controls for model point shields + float max_shield_recharge; + float hull_repair_rate; //How much of the hull is repaired every second float subsys_repair_rate; //How fast @@ -1429,6 +1434,7 @@ public: float emp_resistance_mod; float piercing_damage_draw_limit; + int shield_impact_explosion_anim; int damage_lightning_type; diff --git a/code/ship/shiphit.cpp b/code/ship/shiphit.cpp index de64d322a9..b1dfdf1e12 100755 --- a/code/ship/shiphit.cpp +++ b/code/ship/shiphit.cpp @@ -2018,7 +2018,7 @@ static void ship_do_damage(object *ship_objp, object *other_obj, vec3d *hitpos, Assert((beam_get_weapon_info_index(other_obj) >= 0) && (beam_get_weapon_info_index(other_obj) < Num_weapon_types)); if (((Weapon_info[beam_get_weapon_info_index(other_obj)].subtype != WP_LASER) || special_check) && (Player_obj != NULL) && (ship_objp == Player_obj)) { - ship_hit_pain(damage * difficulty_scale_factor); + ship_hit_pain(damage * difficulty_scale_factor, quadrant); } } if (other_obj_is_weapon) @@ -2026,7 +2026,7 @@ static void ship_do_damage(object *ship_objp, object *other_obj, vec3d *hitpos, Assert((Weapons[other_obj->instance].weapon_info_index > -1) && (Weapons[other_obj->instance].weapon_info_index < Num_weapon_types)); if (((Weapon_info[Weapons[other_obj->instance].weapon_info_index].subtype != WP_LASER) || special_check) && (Player_obj != NULL) && (ship_objp == Player_obj)) { - ship_hit_pain(damage * difficulty_scale_factor); + ship_hit_pain(damage * difficulty_scale_factor, quadrant); } } } // read violation sanity check @@ -2571,11 +2571,25 @@ void ship_apply_wash_damage(object *ship_objp, object *other_obj, float damage) } // player pain -void ship_hit_pain(float damage) +void ship_hit_pain(float damage, int quadrant) { + + ship *shipp = &Ships[Player_obj->instance]; + ship_info *sip = &Ship_info[shipp->ship_info_index]; + if (!(Player_obj->flags & OF_INVULNERABLE)) { - game_flash( damage/15.0f, -damage/30.0f, -damage/30.0f ); + if (Shield_pain_flash_factor != 0.0f && quadrant >= 0) + { + float effect = (Shield_pain_flash_factor * Player_obj->shield_quadrant[quadrant] * 4) / shipp->ship_max_shield_strength; + + if (Shield_pain_flash_factor < 0.0f) + effect -= Shield_pain_flash_factor; + + game_flash((sip->shield_color[0] * effect) / 255.0f, (sip->shield_color[1] * effect) / 255.0f, (sip->shield_color[2] * effect) / 255.0f); + } + else + game_flash(damage * Generic_pain_flash_factor / 15.0f, -damage * Generic_pain_flash_factor / 30.0f, -damage * Generic_pain_flash_factor / 30.0f); } // kill any active popups when you get hit. diff --git a/code/ship/shiphit.h b/code/ship/shiphit.h index 5e1b95eb13..040c6d8128 100644 --- a/code/ship/shiphit.h +++ b/code/ship/shiphit.h @@ -72,7 +72,7 @@ void ship_generic_kill_stuff( object *objp, float percent_killed ); int get_max_sparks(object* ship_obj); // player pain -void ship_hit_pain(float damage); +void ship_hit_pain(float damage, int quadrant); #endif //_SHIPHIT_H diff --git a/code/sound/channel.h b/code/sound/channel.h index 15f32f80f8..21f5b3eb8e 100644 --- a/code/sound/channel.h +++ b/code/sound/channel.h @@ -22,10 +22,11 @@ typedef struct channel int priority; // implementation dependant priority unsigned int last_position; bool is_voice_msg; + bool is_ambient; channel() : sig(-1), snd_id(-1), source_id(0), sid(-1), looping(0), vol(1.0f), - priority(0), last_position(0), is_voice_msg(false) + priority(0), last_position(0), is_voice_msg(false), is_ambient(false) { } } channel; diff --git a/code/sound/ds.cpp b/code/sound/ds.cpp index 34e91f9b74..a83449e76a 100644 --- a/code/sound/ds.cpp +++ b/code/sound/ds.cpp @@ -11,6 +11,8 @@ #include "globalincs/pstypes.h" #include "cfile/cfile.h" +#include "cmdline/cmdline.h" +#include "sound/sound.h" // jg18 - for enhanced sound #include "sound/openal.h" #include "sound/ds.h" #include "sound/ds3d.h" @@ -40,7 +42,7 @@ typedef struct sound_buffer } sound_buffer; -static int MAX_CHANNELS = 32; // initialized properly in ds_init_channels() +static int MAX_CHANNELS; // initialized properly in ds_init_channels() channel *Channels = NULL; static int channel_next_sig = 1; @@ -1005,6 +1007,8 @@ int ds_load_buffer(int *sid, int *final_size, void *header, sound_info *si, int */ void ds_init_channels() { + MAX_CHANNELS = Cmdline_no_enhanced_sound ? 32 : 128; + try { Channels = new channel[MAX_CHANNELS]; } catch (std::bad_alloc) { @@ -1023,6 +1027,29 @@ void ds_init_buffers() sound_buffers.reserve( BUFFER_BUMP ); } +/** +* Check if the player is using OpenAL Soft, +* which is required to use enhanced sound. +* Returns true on success, false otherwise. +*/ +bool ds_check_for_openal_soft() +{ + const ALchar * renderer = alGetString(AL_RENDERER); + if (renderer == NULL) + { + mprintf(("ds_check_for_openal_soft: renderer is null!")); + return false; + } + else if (!stricmp((const char *)renderer, "OpenAL Soft")) + { + return true; + } + else + { + return false; + } +} + /** * Sound initialisation * @return -1 if init failed, 0 if init success @@ -1119,6 +1146,23 @@ int ds_init() } } + if (!Cmdline_no_enhanced_sound) + { + if (!ds_check_for_openal_soft()) + { + mprintf(("You are not using OpenAL Soft. Disabling enhanced sound.\n")); + Cmdline_no_enhanced_sound = 1; + } + else + { + mprintf(("Enhanced sound is enabled.\n")); + } + } + else + { + mprintf(("Enhanced sound is manually disabled.\n")); + } + // setup default listener position/orientation // this is needed for 2D pan OpenAL_ErrorPrint( alListener3f(AL_POSITION, 0.0, 0.0, 0.0) ); @@ -1313,6 +1357,7 @@ void ds_close() /** * Find a free channel to play a sound on. If no free channels exists, free up one based on volume levels. + * This is the original retail version of ds_get_free_channel(). * * @param new_volume Volume for sound to play at * @param snd_id Which kind of sound to play @@ -1322,7 +1367,7 @@ void ds_close() * * NOTE: snd_id is needed since we limit the number of concurrent samples */ -int ds_get_free_channel(float new_volume, int snd_id, int priority) +int ds_get_free_channel_retail(float new_volume, int snd_id, int priority) { int i, first_free_channel, limit = 100; int instance_count; // number of instances of sound already playing @@ -1443,6 +1488,169 @@ int ds_get_free_channel(float new_volume, int snd_id, int priority) return first_free_channel; } +/** + * Find a free channel to play a sound on. If no free channels exists, free up one based on priority and volume levels. + * Special version for enhanced mode. + * + * @param new_volume Volume for sound to play at + * @param snd_id Which kind of sound to play + * @param enhanced_priority Priority level, see EnhancedSoundPriority enum in gamesnd.h + * @param enhanced_limit Per-sound concurrency limit + * + * @returns Channel number to play sound on, or -1 if no channel could be found + * + * NOTE: snd_id is needed since we limit the number of concurrent samples + */ +int ds_get_free_channel_enhanced(float new_volume, int snd_id, int enhanced_priority, unsigned int enhanced_limit) +{ + int i, first_free_channel; + int instance_count; // number of instances of sound already playing + // least important means lowest volume among lowest priority + // note that higher priority value means lower priority + int least_important_index = -1, least_important_instance_index = -1; + float least_important_vol = 1.1f, least_important_instance_vol = 1.1f; + int least_important_priority = -1, least_important_instance_priority = -1; + channel *chp; + int status; + + instance_count = 0; + first_free_channel = -1; + + // Look for a channel to use to play this sample + for ( i = 0; i < MAX_CHANNELS; i++ ) { + chp = &Channels[i]; + + // source not created yet + if (chp->source_id == 0) { + if (first_free_channel == -1) { + first_free_channel = i; + } + continue; + } + + // source not bound to a buffer + if (chp->sid == -1) { + if (first_free_channel == -1) { + first_free_channel = i; + } + continue; + } + + OpenAL_ErrorCheck( alGetSourcei(chp->source_id, AL_SOURCE_STATE, &status), continue ); + + if ( (status == AL_INITIAL) || (status == AL_STOPPED) ) { + ds_close_channel_fast(i); + + if (first_free_channel == -1) { + first_free_channel = i; + } + continue; + } else { + if ( chp->snd_id == snd_id ) { + instance_count++; + + // looping or ambient soudns can't be preempted + if ((chp->looping == FALSE) && !chp->is_ambient) + { + if (chp->priority > least_important_instance_priority) { + least_important_instance_vol = chp->vol; + least_important_instance_priority = chp->priority; + least_important_instance_index = i; + } else if ((chp->priority == least_important_instance_priority) + && (chp->vol < least_important_instance_vol)) { + least_important_instance_vol = chp->vol; + least_important_instance_priority = chp->priority; + least_important_instance_index = i; + } + } + } else if ( chp->is_voice_msg || (chp->looping == TRUE) || chp->is_ambient ) { + // a playing voice message, looping sound, or ambient sound is not allowed to be preempted. + } else if ( (chp->priority > least_important_priority) ) { + least_important_index = i; + least_important_vol = chp->vol; + least_important_priority = chp->priority; + } else if ( (chp->priority == least_important_priority) && (chp->vol < least_important_vol) ) { + least_important_index = i; + least_important_vol = chp->vol; + least_important_priority = chp->priority; + } + } + } + + // If we've exceeded the limit, then stop the least important duplicate if it is lower or equal volume + // otherwise, don't play the sound + if ( ((unsigned int)instance_count >= enhanced_limit) && (least_important_instance_index >= 0) ) { + if (least_important_instance_vol <= new_volume) { + ds_close_channel_fast(least_important_instance_index); + first_free_channel =least_important_instance_index; + } else { + // don't exceed per-sound concurrency limits, even if there are spare channels + first_free_channel = -1; + } + } else if (first_free_channel == -1) { + // we haven't reached the limit, but we have run out of channels + // attempt to stop the least important sound to play our sound if priority demands it + if ( (least_important_index != -1)) { + // Check if the priority difference is great enough (must play or at least 2 levels away) + // and if the least important sound's volume playing is less than or equal to the volume of the requested sound. + // If so, then we are going to trash the least important sound. + if ( (enhanced_priority == SND_ENHANCED_PRIORITY_MUST_PLAY) || (Channels[least_important_index].priority - enhanced_priority >= 2)) { + if ( Channels[least_important_index].vol <= new_volume ) { + ds_close_channel_fast(least_important_index); + first_free_channel = least_important_index; + } + } + } + } + + if ( (first_free_channel >= 0) && (Channels[first_free_channel].source_id == 0) ) { + OpenAL_ErrorCheck( alGenSources(1, &Channels[first_free_channel].source_id), return -1 ); + } + return first_free_channel; +} + +/** + * Generic function for getting a free channel + * If enhanced soudn is used, set priority to the computed priority. + * Returns -1 if no free channel could be found. + */ + +/** + * Find a free channel to play a sound on. If no free channels exists, free up one based on volume levels. + * This is the new generic version of ds_get_free_channel(). + * + * @param new_volume Volume for sound to play at + * @param snd_id Which kind of sound to play + * @param priority From retail :DS_MUST_PLAY, ::DS_LIMIT_ONE, ::DS_LIMIT_TWO, ::DS_LIMIT_THREE + * @param enhanced_priority Output param that's updated with correct priority if enhanced sound is enabled + * + * @returns Channel number to play sound on, or -1 if no channel could be found + * + * NOTE: snd_id is needed since we limit the number of concurrent samples + */ +int ds_get_free_channel(float volume, int snd_id, int priority, int & enhanced_priority, const EnhancedSoundData & enhanced_sound_data) +{ + int first_free_channel = -1; + unsigned int enhanced_limit = 0; + + if (!Cmdline_no_enhanced_sound) { + enhanced_priority = enhanced_sound_data.priority; + enhanced_limit = enhanced_sound_data.limit; + + // exception: if retail priority is must play, we assume it's for a good reason + // and thus follow suit with enhanced sound + if (priority == DS_MUST_PLAY) { + enhanced_priority = SND_ENHANCED_PRIORITY_MUST_PLAY; + } + + first_free_channel = ds_get_free_channel_enhanced(volume, snd_id, enhanced_priority, enhanced_limit); + } else { // enhanced sound is off + first_free_channel = ds_get_free_channel_retail(volume, snd_id, priority); + } + + return first_free_channel; +} + /** * Create a sound buffer in software, without locking any data in */ @@ -1523,7 +1731,12 @@ int ds_play_easy(int sid, float volume) return -1; } - int ch_idx = ds_get_free_channel(volume, -1, DS_MUST_PLAY); + int ch_idx = -1; + if (!Cmdline_no_enhanced_sound) { + ds_get_free_channel_enhanced(volume, -1, SND_ENHANCED_PRIORITY_MUST_PLAY, SND_ENHANCED_MAX_LIMIT); + } else { + ds_get_free_channel_retail(volume, -1, DS_MUST_PLAY); + } if (ch_idx < 0) { return -1; @@ -1568,15 +1781,16 @@ int ds_play_easy(int sid, float volume) * * @return 1 if sound effect could not be started, >=0 sig for sound effect successfully started */ -int ds_play(int sid, int snd_id, int priority, float volume, float pan, int looping, bool is_voice_msg) +int ds_play(int sid, int snd_id, int priority, const EnhancedSoundData * enhanced_sound_data, float volume, float pan, int looping, bool is_voice_msg) { int ch_idx; + int enhanced_priority = SND_ENHANCED_PRIORITY_INVALID; if (!ds_initialized) { return -1; } - ch_idx = ds_get_free_channel(volume, snd_id, priority); + ch_idx = ds_get_free_channel(volume, snd_id, priority, enhanced_priority, *enhanced_sound_data); if (ch_idx < 0) { return -1; @@ -1628,7 +1842,8 @@ int ds_play(int sid, int snd_id, int priority, float volume, float pan, int loop Channels[ch_idx].is_voice_msg = is_voice_msg; Channels[ch_idx].vol = volume; Channels[ch_idx].looping = looping; - Channels[ch_idx].priority = priority; + Channels[ch_idx].priority = enhanced_priority; + Channels[ch_idx].is_ambient = false; // no support for 2D ambient sounds if (channel_next_sig < 0) { channel_next_sig = 1; @@ -1816,15 +2031,17 @@ void ds_chg_loop_status(int channel_id, int loop) * * @return 0 if sound started successfully, -1 if sound could not be played */ -int ds3d_play(int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, int looping, float max_volume, float estimated_vol, int priority ) +int ds3d_play(int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, int looping, float max_volume, float estimated_vol, const EnhancedSoundData * enhanced_sound_data, int priority, bool is_ambient) { int channel_id; + int enhanced_priority = SND_ENHANCED_PRIORITY_INVALID; + if (!ds_initialized) { return -1; } - channel_id = ds_get_free_channel(estimated_vol, snd_id, priority); + channel_id = ds_get_free_channel(estimated_vol, snd_id, priority, enhanced_priority, *enhanced_sound_data); if (channel_id < 0) { return -1; @@ -1872,7 +2089,8 @@ int ds3d_play(int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, Channels[channel_id].is_voice_msg = false; Channels[channel_id].vol = max_volume; Channels[channel_id].looping = looping; - Channels[channel_id].priority = priority; + Channels[channel_id].priority = enhanced_priority; + Channels[channel_id].is_ambient = is_ambient; if (channel_next_sig < 0 ) { channel_next_sig = 1; diff --git a/code/sound/ds.h b/code/sound/ds.h index 05bf78be04..542543cccd 100644 --- a/code/sound/ds.h +++ b/code/sound/ds.h @@ -42,6 +42,8 @@ extern int Ds_float_supported; #define DS_LIMIT_TWO 2 #define DS_LIMIT_THREE 3 +struct EnhancedSoundData; + #define DS_3D (1<<0) typedef struct sound_info { @@ -65,7 +67,7 @@ int ds_parse_sound(CFILE *fp, ubyte **dest, uint *dest_size, WAVEFORMATEX **head int ds_parse_sound_info(char *real_filename, sound_info *s_info); int ds_load_buffer(int *sid, int *final_size, void *header, sound_info *si, int flags); void ds_unload_buffer(int sid); -int ds_play(int sid, int snd_id, int priority, float volume, float pan, int looping, bool is_voice_msg = false); +int ds_play(int sid, int snd_id, int priority, const EnhancedSoundData * enhanced_sound_data, float volume, float pan, int looping, bool is_voice_msg = false); int ds_get_channel(int sig); int ds_is_channel_playing(int channel); void ds_stop_channel(int channel); @@ -92,7 +94,7 @@ int ds_get_sound_id(int channel); // Returns the number of channels that are actually playing int ds_get_number_channels(); -int ds3d_play( int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, int looping, float max_volume, float estimated_vol, int priority=DS_MUST_PLAY ); +int ds3d_play(int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, int looping, float max_volume, float estimated_vol, const EnhancedSoundData * enhanced_sound_data, int priority = DS_MUST_PLAY, bool is_ambient = false); void ds_do_frame(); diff --git a/code/sound/rtvoice.cpp b/code/sound/rtvoice.cpp index ca8270c3fa..95c085822c 100644 --- a/code/sound/rtvoice.cpp +++ b/code/sound/rtvoice.cpp @@ -451,7 +451,8 @@ int rtvoice_play(int index, unsigned char *data, int size) } // play the voice - rval = ds_play(ds_handle, -100, DS_MUST_PLAY, Master_voice_volume, 0, 0); + EnhancedSoundData enhanced_sound_data(SND_ENHANCED_PRIORITY_MUST_PLAY, SND_ENHANCED_MAX_LIMIT); + rval = ds_play(ds_handle, -100, DS_MUST_PLAY, &enhanced_sound_data, Master_voice_volume, 0, 0); return rval; } diff --git a/code/sound/sound.cpp b/code/sound/sound.cpp index 9f58289650..f8f9deae44 100644 --- a/code/sound/sound.cpp +++ b/code/sound/sound.cpp @@ -35,6 +35,7 @@ #endif #include +const unsigned int SND_ENHANCED_MAX_LIMIT = 15; // seems like a good max limit #define SND_F_USED (1<<0) // Sounds[] element is used @@ -144,7 +145,6 @@ int snd_init() snd_clear(); - rval = ds_init(); if ( rval != 0 ) { @@ -255,11 +255,16 @@ void snd_spew_debug_info() // spew info int line_height = gr_get_font_height() + 1; + int sx = gr_screen.center_offset_x + 30; + int sy = gr_screen.center_offset_y + 100; gr_set_color_fast(&Color_normal); - gr_printf_no_resize(30, 100, "Game sounds : %d\n", game_sounds); - gr_printf_no_resize(30, 100 + line_height, "Interface sounds : %d\n", interface_sounds); - gr_printf_no_resize(30, 100 + (line_height * 2), "Message sounds : %d\n", message_sounds); - gr_printf_no_resize(30, 100 + (line_height * 3), "Total sounds : %d\n", game_sounds + interface_sounds + message_sounds); + gr_printf_no_resize(sx, sy, "Game sounds : %d\n", game_sounds); + sy += line_height; + gr_printf_no_resize(sx, sy, "Interface sounds : %d\n", interface_sounds); + sy += line_height; + gr_printf_no_resize(sx, sy, "Message sounds : %d\n", message_sounds); + sy += line_height; + gr_printf_no_resize(sx, sy, "Total sounds : %d\n", game_sounds + interface_sounds + message_sounds); } // --------------------------------------------------------------------------------------- @@ -552,7 +557,7 @@ int snd_play( game_snd *gs, float pan, float vol_scale, int priority, bool is_vo return -1; if ( volume > MIN_SOUND_VOLUME ) { - handle = ds_play( snd->sid, gs->id_sig, ds_priority(priority), volume, pan, 0, is_voice_msg); + handle = ds_play( snd->sid, gs->id_sig, ds_priority(priority), &gs->enhanced_sound_data, volume, pan, 0, is_voice_msg); } return handle; @@ -584,7 +589,7 @@ MONITOR( Num3DSoundsLoaded ) // returns: -1 => sound could not be played // n => handle for instance of sound // -int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius, vec3d *source_vel, int looping, float vol_scale, int priority, vec3d *sound_fvec, float range_factor, int force ) +int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius, vec3d *source_vel, int looping, float vol_scale, int priority, vec3d *sound_fvec, float range_factor, int force, bool is_ambient ) { int handle; vec3d vector_to_sound; @@ -674,9 +679,9 @@ int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius pan = vm_vec_dot(&View_matrix.vec.rvec, &vector_to_sound); } - handle = ds_play(snd->sid, gs->id_sig, ds_priority(priority), volume / gs->default_volume, pan, looping); + handle = ds_play(snd->sid, gs->id_sig, ds_priority(priority), &gs->enhanced_sound_data, volume / gs->default_volume, pan, looping); } else { - handle = ds3d_play(snd->sid, gs->id_sig, source_pos, source_vel, min_range, max_range, looping, (max_volume*Master_sound_volume*aav_effect_volume), volume, ds_priority(priority)); + handle = ds3d_play(snd->sid, gs->id_sig, source_pos, source_vel, min_range, max_range, looping, (max_volume*Master_sound_volume*aav_effect_volume), volume, &gs->enhanced_sound_data, ds_priority(priority)); } return handle; @@ -850,7 +855,7 @@ int snd_play_looping( game_snd *gs, float pan, int start_loop, int stop_loop, fl volume = 1.0f; if (volume > MIN_SOUND_VOLUME) { - handle = ds_play( snd->sid, gs->id_sig, DS_MUST_PLAY, volume, pan, 1); + handle = ds_play( snd->sid, gs->id_sig, DS_MUST_PLAY, &gs->enhanced_sound_data, volume, pan, 1); if(handle != -1 && scriptingUpdateVolume) { currentlyLoopingSoundInfos.push_back(LoopingSoundInfo(handle, gs->default_volume, vol_scale)); diff --git a/code/sound/sound.h b/code/sound/sound.h index 48983c7bd4..979b6c730e 100644 --- a/code/sound/sound.h +++ b/code/sound/sound.h @@ -28,6 +28,39 @@ #define SND_PRIORITY_DOUBLE_INSTANCE 2 #define SND_PRIORITY_TRIPLE_INSTANCE 3 +// jg18 - new priority system +enum EnhancedSoundPriority +{ + SND_ENHANCED_PRIORITY_MUST_PLAY = 0, + SND_ENHANCED_PRIORITY_HIGH = 1, + SND_ENHANCED_PRIORITY_MEDIUM_HIGH = 2, + SND_ENHANCED_PRIORITY_MEDIUM = 3, + SND_ENHANCED_PRIORITY_MEDIUM_LOW = 4, + SND_ENHANCED_PRIORITY_LOW = 5, + SND_ENHANCED_PRIORITY_INVALID = 6 +}; + +struct EnhancedSoundData +{ + int priority; + unsigned int limit; // limit on how many instances of the sound can play concurrently + + EnhancedSoundData() : + priority(SND_ENHANCED_PRIORITY_INVALID), limit(0) + { + } + + EnhancedSoundData(const int new_priority, const unsigned int new_limit) : + priority(new_priority), limit(new_limit) + { + Assertion(priority >= SND_ENHANCED_PRIORITY_MUST_PLAY && priority <= SND_ENHANCED_PRIORITY_LOW, + "EnhancedSoundData ctor given invalid priority %d", priority); + Assertion(limit > 0, "EnhancedSoundData ctor given invalid limit %d", limit); + } +}; + +extern const unsigned int SND_ENHANCED_MAX_LIMIT; + //For the adjust-audio-volume sexp #define AAV_MUSIC 0 #define AAV_VOICE 1 @@ -49,6 +82,7 @@ public: int id; //!< index into Sounds[], where sound data is stored int id_sig; //!< signature of Sounds[] element int flags; + EnhancedSoundData enhanced_sound_data; game_snd( ); }; @@ -88,7 +122,7 @@ int snd_play_raw( int soundnum, float pan, float vol_scale=1.0f, int priority = // Plays a sound with volume between 0 and 1.0, where 0 is the // inaudible and 1.0 is the loudest sound in the game. It scales // the pan and volume relative to the current viewer's location. -int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius=0.0f, vec3d *vel = NULL, int looping = 0, float vol_scale=1.0f, int priority = SND_PRIORITY_SINGLE_INSTANCE, vec3d *sound_fvec = NULL, float range_factor = 1.0f, int force = 0 ); +int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius=0.0f, vec3d *vel = NULL, int looping = 0, float vol_scale=1.0f, int priority = SND_PRIORITY_SINGLE_INSTANCE, vec3d *sound_fvec = NULL, float range_factor = 1.0f, int force = 0, bool is_ambient = false ); // update the given 3d sound with a new position void snd_update_3d_pos(int soudnnum, game_snd *gs, vec3d *new_pos, float radius = 0.0f, float range_factor = 1.0f); diff --git a/code/stats/stats.cpp b/code/stats/stats.cpp index a70095cd0a..3ecc000f3b 100644 --- a/code/stats/stats.cpp +++ b/code/stats/stats.cpp @@ -156,7 +156,7 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) sprintf(text,"%d",(int)pct); strcat_s(text," %%"); gr_printf_menu(sx,sy,text); sy += dy; - if(Active_player->stats.mp_bonehead_hits>0) + if(Active_player->stats.mp_shots_fired>0) pct=(float)100.0*((float)Active_player->stats.mp_bonehead_hits/(float)Active_player->stats.mp_shots_fired); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat_s(text," %%"); @@ -179,7 +179,7 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) sprintf(text,"%d",(int)pct); strcat_s(text," %%"); gr_printf_menu(sx,sy,text); sy += dy; - if(Active_player->stats.ms_bonehead_hits>0) + if(Active_player->stats.ms_shots_fired>0) pct=(float)100.0*((float)Active_player->stats.ms_bonehead_hits/(float)Active_player->stats.ms_shots_fired); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat_s(text," %%"); diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index 5cd2e06887..a53a920511 100755 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -1888,6 +1888,10 @@ int beam_start_firing(beam *b) // niffwan - if launch_snd < 0, don't play any sound } + Script_system.SetHookObjects(3, "Beam", &Objects[b->objnum], "User", b->objp, "Target", b->target); + Script_system.RunCondition(CHA_BEAMFIRE, 0, NULL, b->objp, b->weapon_info_index); + Script_system.RemHookVars(3, "Beam", "User", "Target"); + // success return 1; } diff --git a/code/weapon/swarm.cpp b/code/weapon/swarm.cpp index 77688c65d7..7a432f4199 100644 --- a/code/weapon/swarm.cpp +++ b/code/weapon/swarm.cpp @@ -263,10 +263,10 @@ void swarm_update_direction(object *objp, float frametime) missile_speed = pi->speed; missile_dist = missile_speed * swarmp->change_time/1000.0f; - if (missile_dist == 0.0f) // Just in case of div by zero, which can happen with local SSMs - swarmp->angle_offset = (float)asin(SWARM_DIST_OFFSET); - else - swarmp->angle_offset = (float)(asin(SWARM_DIST_OFFSET / missile_dist)); + if ( missile_dist < SWARM_DIST_OFFSET ) { + missile_dist = i2fl(SWARM_DIST_OFFSET); + } + swarmp->angle_offset = (float)(asin(SWARM_DIST_OFFSET / missile_dist)); Assert(!_isnan(swarmp->angle_offset) ); } diff --git a/code/weapon/weapon.h b/code/weapon/weapon.h index bb93f56d2e..a40df96fd2 100644 --- a/code/weapon/weapon.h +++ b/code/weapon/weapon.h @@ -123,6 +123,7 @@ extern int Num_weapon_subtypes; #define WIF3_FIGHTER_INTERCEPTABLE (1 << 6) // (like WIF_BOMB), without forcing it to be tagetable -MageKing17 #define WIF3_AOE_ELECTRONICS (1 << 7) // Apply electronics effect across the weapon's entire area of effect instead of just on the impacted ship -MageKing17 #define WIF3_APPLY_RECOIL (1 << 8) // Apply recoil using weapon and ship info +#define WIF3_DONT_SPAWN_IF_SHOT (1 << 9) // Prevent shot down parent weapons from spawning children (DahBlount) #define WIF_HOMING (WIF_HOMING_HEAT | WIF_HOMING_ASPECT | WIF_HOMING_JAVELIN) #define WIF_LOCKED_HOMING (WIF_HOMING_ASPECT | WIF_HOMING_JAVELIN) @@ -141,6 +142,7 @@ extern int Num_weapon_subtypes; #define WF_DESTROYED_BY_WEAPON (1<<6) // destroyed by damage from other weapon #define WF_SPAWNED (1<<7) //Spawned from a spawning type weapon #define WF_HOMING_UPDATE_NEEDED (1<<8) // this is a newly spawned homing weapon which needs to update client machines +#define WF_NO_HOMING (1<<9) // this weapon should ignore any homing behavior it'd usually have // flags for setting burst fire #define WBF_FAST_FIRING (1<<0) // burst is to use only the firewait to determine firing delays @@ -352,8 +354,13 @@ typedef struct weapon_info { float free_flight_time; float mass; // mass of the weapon float fire_wait; // fire rate -- amount of time before you can refire the weapon + float max_delay; // max time to delay a shot (DahBlount) + float min_delay; // min time to delay a shot (DahBlount) float damage; // damage of weapon (for missile, damage within inner radius) + float damage_time; // point in the lifetime of the weapon at which damage starts to attenuate. This applies to non-beam primaries. (DahBlount) + float min_damage; // lowest damage the weapon can deal. (DahBlount) + float max_damage; // highest damage the weapon can deal. (DahBlount) shockwave_create_info shockwave; shockwave_create_info dinky_shockwave; @@ -416,6 +423,7 @@ typedef struct weapon_info { int impact_weapon_expl_index; // Index into Weapon_expl_info of which ANI should play when this thing impacts something float impact_explosion_radius; // How big the explosion should be + float shield_impact_explosion_radius; // How big the shield hit explosion should be int dinky_impact_weapon_expl_index; float dinky_impact_explosion_radius; @@ -677,4 +685,6 @@ void weapon_unpause_sounds(); // Called by hudartillery.cpp after SSMs have been parsed to make sure that $SSM: entries defined in weapons are valid. void validate_SSM_entries(); +void shield_impact_explosion(vec3d *hitpos, object *objp, float radius, int idx); + #endif diff --git a/code/weapon/weapons.cpp b/code/weapon/weapons.cpp index d1ceab4758..e15ad1e42c 100755 --- a/code/weapon/weapons.cpp +++ b/code/weapon/weapons.cpp @@ -685,6 +685,8 @@ void parse_wi_flags(weapon_info *weaponp, int wi_flags, int wi_flags2, int wi_fl weaponp->wi_flags3 |= WIF3_FIGHTER_INTERCEPTABLE; else if (!stricmp(NOX("apply recoil"), weapon_strings[i])) weaponp->wi_flags3 |= WIF3_APPLY_RECOIL; + else if (!stricmp(NOX("don't spawn if shot"), weapon_strings[i])) + weaponp->wi_flags3 |= WIF3_DONT_SPAWN_IF_SHOT; else Warning(LOCATION, "Bogus string in weapon flags: %s\n", weapon_strings[i]); } @@ -879,7 +881,11 @@ void init_weapon_entry(int weap_info_index) wip->vel_inherit_amount = 1.0f; wip->free_flight_time = 0.0f; wip->fire_wait = 1.0f; + wip->max_delay = 0.0f; + wip->min_delay = 0.0f; wip->damage = 0.0f; + wip->damage_time = 0.0f; + wip->min_damage = 0.0f; wip->damage_type_idx = -1; wip->damage_type_idx_sav = -1; @@ -960,6 +966,8 @@ void init_weapon_entry(int weap_info_index) wip->impact_explosion_radius = 1.0f; wip->impact_weapon_expl_index = -1; + wip->shield_impact_explosion_radius = 1.0f; + wip->dinky_impact_explosion_radius = 1.0f; wip->dinky_impact_weapon_expl_index = -1; @@ -1391,6 +1399,15 @@ int parse_weapon(int subtype, bool replace, const char *filename) if(optional_string("$Fire Wait:")) { stuff_float( &(wip->fire_wait) ); diag_printf ("Weapon fire wait -- %7.3f\n", wip->fire_wait); + // Min and max delay stuff for weapon fire wait randomization + if (optional_string("+Max Delay:")) { + stuff_float(&(wip->max_delay)); + diag_printf("Weapon fire max delay -- %7.3f\n", wip->max_delay); + } + if (optional_string("+Min Delay:")) { + stuff_float(&(wip->min_delay)); + diag_printf("Weapon fire min delay -- %7.3f\n", wip->min_delay); + } } if(optional_string("$Damage:")) { @@ -1401,6 +1418,30 @@ int parse_weapon(int subtype, bool replace, const char *filename) wip->shockwave.damage = wip->damage; } } + + // Attenuation of non-beam primary weapon damage + if(optional_string("$Damage Time:")) { + stuff_float(&wip->damage_time); + if(optional_string("+Min Damage:")){ + stuff_float(&wip->min_damage); + } + if(wip->min_damage > wip->damage) { + Warning(LOCATION, "Min Damage is greater than Damage, resetting to zero."); + wip->min_damage = 0.0f; + } + if(optional_string("+Max Damage:")) { + stuff_float(&wip->max_damage); + } + if(wip->max_damage < wip->damage) { + Warning(LOCATION, "Max Damage is less than Damage, resetting to zero."); + wip->max_damage = 0.0f; + } + if(wip->min_damage != 0.0f && wip->max_damage != 0.0f) { + Warning(LOCATION, "Both Min Damage and Max Damage are set to values greater than zero, resetting both to zero."); + wip->min_damage = 0.0f; + wip->max_damage = 0.0f; + } + } if(optional_string("$Damage Type:")) { //This is checked for validity on every armor type @@ -1504,6 +1545,10 @@ int parse_weapon(int subtype, bool replace, const char *filename) Warning(LOCATION, "Lifetime min or max specified, but $Lifetime was also specified; min or max will be used."); } stuff_float(&wip->lifetime); + if (wip->damage_time > wip->lifetime) { + Warning(LOCATION, "Lifetime is lower than Damage Time, setting Damage Time to be one half the value of Lifetime."); + wip->damage_time = 0.5f * wip->lifetime; + } } if(optional_string("$Energy Consumed:")) { @@ -1932,6 +1977,12 @@ int parse_weapon(int subtype, bool replace, const char *filename) if ( optional_string("$Impact Explosion Radius:") ) stuff_float(&wip->impact_explosion_radius); + if ( optional_string("$Shield Impact Explosion Radius:") ) { + stuff_float(&wip->shield_impact_explosion_radius); + } else if (first_time) { + wip->shield_impact_explosion_radius = wip->impact_explosion_radius; + } + if ( optional_string("$Dinky Impact Explosion:") ) { stuff_string(fname, F_NAME, NAME_LENGTH); @@ -4820,7 +4871,7 @@ void weapon_process_post(object * obj, float frame_time) } // a single player or multiplayer server function -- it affects actual weapon movement. - if (wip->wi_flags & WIF_HOMING) { + if (wip->wi_flags & WIF_HOMING && !(wp->weapon_flags & WF_NO_HOMING)) { weapon_home(obj, num, frame_time); // If this is a swarm type missile, @@ -4999,6 +5050,10 @@ void weapon_set_tracking_info(int weapon_objnum, int parent_objnum, int target_o wp = &Weapons[Objects[weapon_objnum].instance]; wip = &Weapon_info[wp->weapon_info_index]; + if (wp->weapon_flags & WF_NO_HOMING) { + return; + } + if (parent_objnum >= 0) { parent_objp = &Objects[parent_objnum]; Assert(parent_objp->type == OBJ_SHIP); @@ -5006,6 +5061,16 @@ void weapon_set_tracking_info(int weapon_objnum, int parent_objnum, int target_o parent_objp = NULL; } + if (parent_objp != NULL && (Ships[parent_objp->instance].flags2 & SF2_NO_SECONDARY_LOCKON)) { + wp->weapon_flags |= WF_NO_HOMING; + wp->homing_object = NULL; + wp->homing_subsys = NULL; + wp->target_num = -1; + wp->target_sig = -1; + + return; + } + if ( parent_objp == NULL || Ships[parent_objp->instance].ai_index >= 0 ) { int target_team = -1; if ( target_objnum >= 0 ) { @@ -6310,7 +6375,9 @@ void weapon_hit( object * weapon_obj, object * other_obj, vec3d * hitpos, int qu // spawn weapons - note the change from FS 1 multiplayer. if (wip->wi_flags & WIF_SPAWN){ - spawn_child_weapons(weapon_obj); + if (!((wip->wi_flags3 & WIF3_DONT_SPAWN_IF_SHOT) && (sw_flag == SW_WEAPON_KILL))){ // prevent spawning of children if shot down and the dont spawn if shot flag is set (DahBlount) + spawn_child_weapons(weapon_obj); + } } } @@ -7127,6 +7194,11 @@ void weapon_unpause_sounds() beam_unpause_sounds(); } +void shield_impact_explosion(vec3d *hitpos, object *objp, float radius, int idx) { + int expl_ani_handle = Weapon_explosions.GetAnim(idx, hitpos, radius); + particle_create( hitpos, &vmd_zero_vector, 0.0f, radius, PARTICLE_BITMAP_PERSISTENT, expl_ani_handle, -1.0f, objp ); +} + void weapon_render(object* obj, draw_list *scene) { int num; diff --git a/projects/MSVC_2010/code.vcxproj b/projects/MSVC_2010/code.vcxproj index 6c6d1bde0c..df2b348a13 100644 --- a/projects/MSVC_2010/code.vcxproj +++ b/projects/MSVC_2010/code.vcxproj @@ -499,10 +499,8 @@ - - @@ -667,7 +665,6 @@ - @@ -796,10 +793,8 @@ - - diff --git a/projects/MSVC_2010/code.vcxproj.filters b/projects/MSVC_2010/code.vcxproj.filters index dffad54134..cf5963aa1f 100644 --- a/projects/MSVC_2010/code.vcxproj.filters +++ b/projects/MSVC_2010/code.vcxproj.filters @@ -576,18 +576,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI @@ -1088,9 +1082,6 @@ AI - - AI - Anim @@ -1463,18 +1454,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI diff --git a/projects/MSVC_2012/Fred2.vcxproj b/projects/MSVC_2012/Fred2.vcxproj index 0873533d40..4dc84ebd4a 100644 --- a/projects/MSVC_2012/Fred2.vcxproj +++ b/projects/MSVC_2012/Fred2.vcxproj @@ -200,7 +200,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _DEBUG;WIN32;_WINDOWS;FRED;WINVER=0x410;_WIN32_WINNT=0x500;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -215,6 +214,7 @@ Level4 true EditAndContinue + true _DEBUG;_VC08;%(PreprocessorDefinitions) @@ -268,7 +268,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _DEBUG;WIN32;_WINDOWS;FRED;WINVER=0x410;_WIN32_WINNT=0x500;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -285,6 +284,7 @@ Level4 true EditAndContinue + true _DEBUG;_VC08;%(PreprocessorDefinitions) @@ -338,7 +338,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _DEBUG;WIN32;_WINDOWS;FRED;WINVER=0x410;_WIN32_WINNT=0x500;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -355,6 +354,7 @@ Level4 true EditAndContinue + true _DEBUG;_VC08;_SSE2;%(PreprocessorDefinitions) @@ -408,7 +408,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _DEBUG;WIN32;_WINDOWS;FRED;WINVER=0x410;_WIN32_WINNT=0x500;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -425,6 +424,7 @@ Level4 true EditAndContinue + true _DEBUG;_VC08;_SSE2;%(PreprocessorDefinitions) @@ -499,6 +499,7 @@ Level3 true OldStyle + true NDEBUG;_VC08;%(PreprocessorDefinitions) @@ -573,6 +574,7 @@ Level3 true OldStyle + true NDEBUG;_VC08;%(PreprocessorDefinitions) @@ -647,6 +649,7 @@ Level3 true OldStyle + true NDEBUG;_VC08;_SSE2;%(PreprocessorDefinitions) @@ -721,6 +724,7 @@ Level3 true OldStyle + true NDEBUG;_VC08;_SSE2;%(PreprocessorDefinitions) diff --git a/projects/MSVC_2012/Freespace2.vcxproj b/projects/MSVC_2012/Freespace2.vcxproj index a19d78d1d8..fd66412978 100644 --- a/projects/MSVC_2012/Freespace2.vcxproj +++ b/projects/MSVC_2012/Freespace2.vcxproj @@ -199,7 +199,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;USE_OPENAL;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -278,7 +277,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;USE_OPENAL;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -358,7 +356,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;USE_OPENAL;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -438,7 +435,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;USE_OPENAL;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false diff --git a/projects/MSVC_2012/code.vcxproj b/projects/MSVC_2012/code.vcxproj index 735dd587b7..6206a70e38 100644 --- a/projects/MSVC_2012/code.vcxproj +++ b/projects/MSVC_2012/code.vcxproj @@ -160,7 +160,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;PDB_DEBUGGING;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -176,6 +175,7 @@ true EditAndContinue NDEBUG;%(UndefinePreprocessorDefinitions) + true _DEBUG;%(PreprocessorDefinitions) @@ -201,7 +201,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;PDB_DEBUGGING;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -219,6 +218,7 @@ true EditAndContinue NDEBUG;%(UndefinePreprocessorDefinitions) + true _DEBUG;%(PreprocessorDefinitions) @@ -244,7 +244,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;PDB_DEBUGGING;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -262,6 +261,7 @@ true EditAndContinue NDEBUG;%(UndefinePreprocessorDefinitions) + true _DEBUG;%(PreprocessorDefinitions) @@ -287,7 +287,6 @@ Disabled ../../code;../../libjpeg;../../libpng;../../lua;../../oggvorbis/include;../../openal/include;../../zlib;../../libsdl/include;%(AdditionalIncludeDirectories) _WINDOWS;WIN32;_DEBUG;PDB_DEBUGGING;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -305,6 +304,7 @@ true EditAndContinue NDEBUG;%(UndefinePreprocessorDefinitions) + true _DEBUG;%(PreprocessorDefinitions) @@ -354,6 +354,7 @@ _DEBUG;%(UndefinePreprocessorDefinitions) + true NDEBUG;%(PreprocessorDefinitions) @@ -398,6 +399,7 @@ _DEBUG;%(UndefinePreprocessorDefinitions) + true NDEBUG;%(PreprocessorDefinitions) @@ -442,6 +444,7 @@ _DEBUG;%(UndefinePreprocessorDefinitions) + true NDEBUG;%(PreprocessorDefinitions) @@ -486,6 +489,7 @@ _DEBUG;%(UndefinePreprocessorDefinitions) + true NDEBUG;%(PreprocessorDefinitions) @@ -628,10 +632,8 @@ - - @@ -796,7 +798,6 @@ - @@ -925,10 +926,8 @@ - - diff --git a/projects/MSVC_2012/code.vcxproj.filters b/projects/MSVC_2012/code.vcxproj.filters index cc60830942..7631714f41 100644 --- a/projects/MSVC_2012/code.vcxproj.filters +++ b/projects/MSVC_2012/code.vcxproj.filters @@ -567,18 +567,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI @@ -1088,9 +1082,6 @@ AI - - AI - Anim @@ -1457,18 +1448,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI diff --git a/projects/MSVC_2012/libjpeg.vcxproj b/projects/MSVC_2012/libjpeg.vcxproj index 082053050f..df3a850ddf 100644 --- a/projects/MSVC_2012/libjpeg.vcxproj +++ b/projects/MSVC_2012/libjpeg.vcxproj @@ -1,10 +1,10 @@  - - Debug AVX - Win32 - + + Debug AVX + Win32 + Debug SSE2 Win32 @@ -17,10 +17,10 @@ Debug Win32 - - Release AVX - Win32 - + + Release AVX + Win32 + Release SSE2 Win32 @@ -47,13 +47,13 @@ true v110_xp - - StaticLibrary - false - NotSet - true - v110 - + + StaticLibrary + false + NotSet + true + v110 + StaticLibrary false @@ -74,12 +74,12 @@ NotSet v110_xp - - StaticLibrary - false - NotSet - v110_xp - + + StaticLibrary + false + NotSet + v110_xp + StaticLibrary false @@ -98,9 +98,9 @@ - - - + + + @@ -110,9 +110,9 @@ - - - + + + @@ -127,23 +127,23 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -151,11 +151,11 @@ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -167,7 +167,6 @@ Disabled _LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -181,6 +180,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -199,7 +199,6 @@ Disabled _LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -215,6 +214,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -233,7 +233,6 @@ Disabled _LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -249,6 +248,41 @@ Level3 true EditAndContinue + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)libjpeg.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + Disabled + _LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + false + true + AdvancedVectorExtensions + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + + + Level3 + true + EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -263,40 +297,6 @@ $(IntDir)$(ProjectName).bsc - - - Disabled - _LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - false - true - AdvancedVectorExtensions - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - - - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libjpeg.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - /MP %(AdditionalOptions) @@ -322,6 +322,7 @@ Level3 true CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -361,6 +362,7 @@ Level3 true CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -400,6 +402,47 @@ Level3 true CompileAsC + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)libjpeg.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + /MP %(AdditionalOptions) + Full + AnySuitable + true + Speed + true + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + false + StreamingSIMDExtensions2 + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + + + Level3 + true + CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -414,45 +457,6 @@ $(IntDir)$(ProjectName).bsc - - - /MP %(AdditionalOptions) - Full - AnySuitable - true - Speed - true - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - false - StreamingSIMDExtensions2 - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - - - Level3 - true - CompileAsC - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libjpeg.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - diff --git a/projects/MSVC_2012/liblua.vcxproj b/projects/MSVC_2012/liblua.vcxproj index 4b20e556c1..8ffde77ec5 100644 --- a/projects/MSVC_2012/liblua.vcxproj +++ b/projects/MSVC_2012/liblua.vcxproj @@ -1,10 +1,10 @@  - - Debug AVX - Win32 - + + Debug AVX + Win32 + Debug SSE2 Win32 @@ -17,10 +17,10 @@ Debug Win32 - - Release AVX - Win32 - + + Release AVX + Win32 + Release SSE2 Win32 @@ -48,14 +48,14 @@ true v110_xp - - StaticLibrary - false - NotSet - false - true - v110 - + + StaticLibrary + false + NotSet + false + true + v110 + StaticLibrary false @@ -78,12 +78,12 @@ NotSet v110_xp - - StaticLibrary - false - NotSet - v110_xp - + + StaticLibrary + false + NotSet + v110_xp + StaticLibrary false @@ -102,9 +102,9 @@ - - - + + + @@ -114,9 +114,9 @@ - - - + + + @@ -131,23 +131,23 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -155,11 +155,11 @@ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -171,7 +171,6 @@ Disabled WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -185,6 +184,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -203,7 +203,6 @@ Disabled WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -219,6 +218,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -237,7 +237,6 @@ Disabled WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -253,6 +252,41 @@ Level3 true EditAndContinue + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)liblua.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + Disabled + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + true + AdvancedVectorExtensions + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + + + $(IntDir) + Level3 + true + EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -267,40 +301,6 @@ $(IntDir)$(ProjectName).bsc - - - Disabled - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - true - AdvancedVectorExtensions - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - - - $(IntDir) - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)liblua.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - /MP %(AdditionalOptions) @@ -326,6 +326,7 @@ Level3 true CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -366,6 +367,7 @@ Level3 true CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -406,6 +408,48 @@ Level3 true CompileAsC + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)liblua.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + /MP %(AdditionalOptions) + Full + AnySuitable + true + Speed + true + true + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + StreamingSIMDExtensions2 + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + + + $(IntDir) + Level3 + true + CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -420,46 +464,6 @@ $(IntDir)$(ProjectName).bsc - - - /MP %(AdditionalOptions) - Full - AnySuitable - true - Speed - true - true - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - StreamingSIMDExtensions2 - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - - - $(IntDir) - Level3 - true - CompileAsC - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)liblua.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - diff --git a/projects/MSVC_2012/libpng.vcxproj b/projects/MSVC_2012/libpng.vcxproj index c55c19d0b2..877c4cd13c 100644 --- a/projects/MSVC_2012/libpng.vcxproj +++ b/projects/MSVC_2012/libpng.vcxproj @@ -1,10 +1,10 @@  - - Debug AVX - Win32 - + + Debug AVX + Win32 + Debug SSE2 Win32 @@ -17,10 +17,10 @@ Debug Win32 - - Release AVX - Win32 - + + Release AVX + Win32 + Release SSE2 Win32 @@ -46,12 +46,12 @@ true v110_xp - - StaticLibrary - false - true - v110 - + + StaticLibrary + false + true + v110 + StaticLibrary false @@ -69,11 +69,11 @@ false v110_xp - - StaticLibrary - false - v110_xp - + + StaticLibrary + false + v110_xp + StaticLibrary false @@ -90,9 +90,9 @@ - - - + + + @@ -102,9 +102,9 @@ - - - + + + @@ -119,23 +119,23 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -143,11 +143,11 @@ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -160,7 +160,6 @@ Disabled ..\..\zlib;%(AdditionalIncludeDirectories) PNG_DEBUG=1;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -172,6 +171,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -191,7 +191,6 @@ Disabled ..\..\zlib;%(AdditionalIncludeDirectories) PNG_DEBUG=1;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -205,6 +204,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -224,7 +224,6 @@ Disabled ..\..\zlib;%(AdditionalIncludeDirectories) PNG_DEBUG=1;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug false @@ -238,6 +237,40 @@ Level3 true EditAndContinue + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)libpng.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + Disabled + ..\..\zlib;%(AdditionalIncludeDirectories) + PNG_DEBUG=1;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + false + true + AdvancedVectorExtensions + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + Level3 + true + EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -252,39 +285,6 @@ $(IntDir)$(ProjectName).bsc - - - Disabled - ..\..\zlib;%(AdditionalIncludeDirectories) - PNG_DEBUG=1;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - false - true - AdvancedVectorExtensions - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libpng.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - /MP %(AdditionalOptions) @@ -312,6 +312,7 @@ CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -355,6 +356,7 @@ CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -398,6 +400,51 @@ CompileAsC + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + ..\..;%(AdditionalIncludeDirectories) + + + $(OutDir)libpng.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + /MP %(AdditionalOptions) + Full + AnySuitable + true + Speed + true + true + ..\..\zlib;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + true + false + Default + MultiThreaded + false + false + StreamingSIMDExtensions2 + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + Level3 + true + + + CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -413,49 +460,6 @@ $(IntDir)$(ProjectName).bsc - - - /MP %(AdditionalOptions) - Full - AnySuitable - true - Speed - true - true - ..\..\zlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - false - Default - MultiThreaded - false - false - StreamingSIMDExtensions2 - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - - - CompileAsC - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - ..\..;%(AdditionalIncludeDirectories) - - - $(OutDir)libpng.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - diff --git a/projects/MSVC_2012/zlib.vcxproj b/projects/MSVC_2012/zlib.vcxproj index f98e3b24e6..8d93121a42 100644 --- a/projects/MSVC_2012/zlib.vcxproj +++ b/projects/MSVC_2012/zlib.vcxproj @@ -1,10 +1,10 @@  - - Debug AVX - Win32 - + + Debug AVX + Win32 + Debug SSE2 Win32 @@ -17,10 +17,10 @@ Debug Win32 - - Release AVX - Win32 - + + Release AVX + Win32 + Release SSE2 Win32 @@ -46,12 +46,12 @@ true v110_xp - - StaticLibrary - false - true - v110 - + + StaticLibrary + false + true + v110 + StaticLibrary false @@ -69,11 +69,11 @@ false v110_xp - - StaticLibrary - false - v110_xp - + + StaticLibrary + false + v110_xp + StaticLibrary false @@ -90,9 +90,9 @@ - - - + + + @@ -102,9 +102,9 @@ - - - + + + @@ -119,23 +119,23 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\ $(Configuration)\$(ProjectName)\ - $(Configuration)\$(ProjectName)\ + $(Configuration)\$(ProjectName)\ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -143,11 +143,11 @@ AllRules.ruleset - AllRules.ruleset + AllRules.ruleset - + - + AllRules.ruleset @@ -159,7 +159,6 @@ Disabled WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -170,6 +169,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -188,7 +188,6 @@ Disabled WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -201,6 +200,7 @@ Level3 true EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -219,7 +219,6 @@ Disabled WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug true @@ -232,6 +231,38 @@ Level3 true EditAndContinue + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)zlib.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + Disabled + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + true + AdvancedVectorExtensions + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + Level3 + true + EditAndContinue + true _DEBUG;%(PreprocessorDefinitions) @@ -246,37 +277,6 @@ $(IntDir)$(ProjectName).bsc - - - Disabled - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - true - AdvancedVectorExtensions - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)zlib.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - /MP %(AdditionalOptions) @@ -299,6 +299,7 @@ Level3 true CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -336,6 +337,7 @@ Level3 true CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -373,6 +375,45 @@ Level3 true CompileAsC + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(OutDir)zlib.lib + true + + + true + $(IntDir)$(ProjectName).bsc + + + + + /MP %(AdditionalOptions) + Full + AnySuitable + true + Speed + true + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + StreamingSIMDExtensions2 + Precise + $(OutDir)$(ProjectName).pch + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + Level3 + true + CompileAsC + true NDEBUG;%(PreprocessorDefinitions) @@ -387,43 +428,6 @@ $(IntDir)$(ProjectName).bsc - - - /MP %(AdditionalOptions) - Full - AnySuitable - true - Speed - true - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - StreamingSIMDExtensions2 - Precise - $(OutDir)$(ProjectName).pch - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - CompileAsC - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)zlib.lib - true - - - true - $(IntDir)$(ProjectName).bsc - - diff --git a/projects/MSVC_2013/code.vcxproj b/projects/MSVC_2013/code.vcxproj index 94774728bc..209e1d7dba 100644 --- a/projects/MSVC_2013/code.vcxproj +++ b/projects/MSVC_2013/code.vcxproj @@ -635,10 +635,8 @@ - - @@ -803,7 +801,6 @@ - @@ -932,10 +929,8 @@ - - diff --git a/projects/MSVC_2013/code.vcxproj.filters b/projects/MSVC_2013/code.vcxproj.filters index d9bc9680aa..db508b1b4b 100644 --- a/projects/MSVC_2013/code.vcxproj.filters +++ b/projects/MSVC_2013/code.vcxproj.filters @@ -573,18 +573,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI @@ -1088,9 +1082,6 @@ AI - - AI - Anim @@ -1463,18 +1454,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI diff --git a/projects/MSVC_2015/Fred2.vcxproj b/projects/MSVC_2015/Fred2.vcxproj index e69826d398..3cf5e668ef 100644 --- a/projects/MSVC_2015/Fred2.vcxproj +++ b/projects/MSVC_2015/Fred2.vcxproj @@ -531,7 +531,7 @@ copy /y "$(OutputPath)$(TargetName).pdb" "$(FS2PATH)\$(TargetName).pdb"true MultiThreaded false - false + true StreamingSIMDExtensions Precise $(OutDir)$(ProjectName).pch @@ -602,7 +602,7 @@ copy /y "$(OutputPath)$(TargetName).pdb" "$(FS2PATH)\$(TargetName).pdb"true MultiThreaded false - false + true StreamingSIMDExtensions2 Precise $(OutDir)$(ProjectName).pch @@ -673,7 +673,7 @@ copy /y "$(OutputPath)$(TargetName).pdb" "$(FS2PATH)\$(TargetName).pdb"true MultiThreaded false - false + true AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch diff --git a/projects/MSVC_2015/Freespace2.vcxproj b/projects/MSVC_2015/Freespace2.vcxproj index 573c8b4bab..fe19bdb29f 100644 --- a/projects/MSVC_2015/Freespace2.vcxproj +++ b/projects/MSVC_2015/Freespace2.vcxproj @@ -566,7 +566,7 @@ copy /y "$(OutputPath)$(TargetName).pdb" "$(FS2PATH)\$(TargetName).pdb"true MultiThreaded false - false + true StreamingSIMDExtensions Precise $(OutDir)$(ProjectName).pch @@ -642,7 +642,7 @@ copy /y "$(OutputPath)$(TargetName).pdb" "$(FS2PATH)\$(TargetName).pdb"true MultiThreaded false - false + true StreamingSIMDExtensions2 Precise $(OutDir)$(ProjectName).pch @@ -721,7 +721,7 @@ copy /y "$(OutputPath)$(TargetName).pdb" "$(FS2PATH)\$(TargetName).pdb"true MultiThreaded false - false + true AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch diff --git a/projects/MSVC_2015/code.vcxproj b/projects/MSVC_2015/code.vcxproj index 3a94a8da38..c4d2c5d059 100644 --- a/projects/MSVC_2015/code.vcxproj +++ b/projects/MSVC_2015/code.vcxproj @@ -387,7 +387,7 @@ Sync MultiThreaded false - false + true StreamingSIMDExtensions Precise $(OutDir)$(ProjectName).pch @@ -432,7 +432,7 @@ Sync MultiThreaded false - false + true StreamingSIMDExtensions2 Precise $(OutDir)$(ProjectName).pch @@ -477,7 +477,7 @@ Sync MultiThreaded false - false + true AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch @@ -635,10 +635,8 @@ - - @@ -803,7 +801,6 @@ - @@ -932,10 +929,8 @@ - - diff --git a/projects/MSVC_2015/code.vcxproj.filters b/projects/MSVC_2015/code.vcxproj.filters index 8f3484dd62..6b14b5144d 100644 --- a/projects/MSVC_2015/code.vcxproj.filters +++ b/projects/MSVC_2015/code.vcxproj.filters @@ -573,18 +573,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI @@ -1088,9 +1082,6 @@ AI - - AI - Anim @@ -1463,18 +1454,12 @@ MissionUI - - MissionUI - MissionUI MissionUI - - MissionUI - MissionUI diff --git a/projects/MSVC_2015/libjpeg.vcxproj b/projects/MSVC_2015/libjpeg.vcxproj index 0dd5763084..1723891744 100644 --- a/projects/MSVC_2015/libjpeg.vcxproj +++ b/projects/MSVC_2015/libjpeg.vcxproj @@ -348,7 +348,7 @@ Default MultiThreaded false - false + true StreamingSIMDExtensions Precise $(OutDir)$(ProjectName).pch @@ -387,7 +387,7 @@ Default MultiThreaded false - false + true StreamingSIMDExtensions2 Precise $(OutDir)$(ProjectName).pch @@ -426,8 +426,8 @@ Default MultiThreaded false - false - StreamingSIMDExtensions2 + true + AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch $(IntDir) diff --git a/projects/MSVC_2015/liblua.vcxproj b/projects/MSVC_2015/liblua.vcxproj index 5939d8cd1f..3d2d4af5ea 100644 --- a/projects/MSVC_2015/liblua.vcxproj +++ b/projects/MSVC_2015/liblua.vcxproj @@ -433,7 +433,7 @@ MultiThreaded false true - StreamingSIMDExtensions2 + AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch $(IntDir) diff --git a/projects/MSVC_2015/libpng.vcxproj b/projects/MSVC_2015/libpng.vcxproj index 8e5e35d5df..f480e13277 100644 --- a/projects/MSVC_2015/libpng.vcxproj +++ b/projects/MSVC_2015/libpng.vcxproj @@ -342,7 +342,7 @@ Default MultiThreaded false - false + true StreamingSIMDExtensions Precise $(OutDir)$(ProjectName).pch @@ -385,7 +385,7 @@ Default MultiThreaded false - false + true StreamingSIMDExtensions2 Precise $(OutDir)$(ProjectName).pch @@ -428,8 +428,8 @@ Default MultiThreaded false - false - StreamingSIMDExtensions2 + true + AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch $(IntDir) diff --git a/projects/MSVC_2015/zlib.vcxproj b/projects/MSVC_2015/zlib.vcxproj index 19885a464b..551f62da17 100644 --- a/projects/MSVC_2015/zlib.vcxproj +++ b/projects/MSVC_2015/zlib.vcxproj @@ -399,7 +399,7 @@ MultiThreaded false true - StreamingSIMDExtensions2 + AdvancedVectorExtensions Precise $(OutDir)$(ProjectName).pch $(IntDir) diff --git a/projects/Xcode4/FS2_Open.xcodeproj/project.pbxproj b/projects/Xcode4/FS2_Open.xcodeproj/project.pbxproj index 59ac124b81..7bd8021c7a 100644 --- a/projects/Xcode4/FS2_Open.xcodeproj/project.pbxproj +++ b/projects/Xcode4/FS2_Open.xcodeproj/project.pbxproj @@ -135,7 +135,6 @@ 34C7187008C4085A00459F5B /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34C7186F08C4085A00459F5B /* OpenAL.framework */; }; 34C7188C08C40DEB00459F5B /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34C7188B08C40DEB00459F5B /* SDL.framework */; }; 34C71AD308C419CB00459F5B /* aiturret.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 345952D908C3D69F003B1351 /* aiturret.cpp */; }; - 34C71AD408C419CB00459F5B /* ailocal.h in Headers */ = {isa = PBXBuildFile; fileRef = 345952D808C3D69F003B1351 /* ailocal.h */; }; 34C71AD508C419CC00459F5B /* aiinternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 345952D708C3D69F003B1351 /* aiinternal.h */; }; 34C71AD608C419CC00459F5B /* aigoals.h in Headers */ = {isa = PBXBuildFile; fileRef = 345952D608C3D69F003B1351 /* aigoals.h */; }; 34C71AD708C419CD00459F5B /* aigoals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 345952D508C3D69F003B1351 /* aigoals.cpp */; }; @@ -179,8 +178,6 @@ 34C71AFF08C41AAA00459F5B /* ddsutils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459530A08C3D69F003B1351 /* ddsutils.cpp */; }; 34C71B0008C41AAD00459F5B /* debris.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459530E08C3D69F003B1351 /* debris.h */; }; 34C71B0108C41AAD00459F5B /* debris.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459530D08C3D69F003B1351 /* debris.cpp */; }; - 34C71B0208C41AB000459F5B /* timerbar.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459531408C3D69F003B1351 /* timerbar.h */; }; - 34C71B0308C41AB000459F5B /* timerbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459531308C3D69F003B1351 /* timerbar.cpp */; }; 34C71B0608C41AB200459F5B /* console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459531008C3D69F003B1351 /* console.cpp */; }; 34C71B0B08C41ABE00459F5B /* exceptionhandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459532D08C3D6A0003B1351 /* exceptionhandler.h */; }; 34C71B0C08C41ABE00459F5B /* exceptionhandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459532C08C3D6A0003B1351 /* exceptionhandler.cpp */; }; @@ -347,14 +344,10 @@ 34C71BC108C41B7000459F5B /* redalert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543F08C3D6A0003B1351 /* redalert.cpp */; }; 34C71BC208C41B7000459F5B /* missionweaponchoice.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543E08C3D6A0003B1351 /* missionweaponchoice.h */; }; 34C71BC308C41B7000459F5B /* missionweaponchoice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543D08C3D6A0003B1351 /* missionweaponchoice.cpp */; }; - 34C71BC408C41B7100459F5B /* missionstats.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543C08C3D6A0003B1351 /* missionstats.h */; }; - 34C71BC508C41B7100459F5B /* missionstats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543B08C3D6A0003B1351 /* missionstats.cpp */; }; 34C71BC608C41B7200459F5B /* missionshipchoice.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543A08C3D6A0003B1351 /* missionshipchoice.h */; }; 34C71BC708C41B7300459F5B /* missionshipchoice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543908C3D6A0003B1351 /* missionshipchoice.cpp */; }; 34C71BC808C41B7300459F5B /* missionscreencommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543808C3D6A0003B1351 /* missionscreencommon.h */; }; 34C71BC908C41B7300459F5B /* missionscreencommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543708C3D6A0003B1351 /* missionscreencommon.cpp */; }; - 34C71BCA08C41B7400459F5B /* missionrecommend.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543608C3D6A0003B1351 /* missionrecommend.h */; }; - 34C71BCB08C41B7500459F5B /* missionrecommend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543508C3D6A0003B1351 /* missionrecommend.cpp */; }; 34C71BCC08C41B7500459F5B /* missionpause.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543408C3D6A0003B1351 /* missionpause.h */; }; 34C71BCD08C41B7600459F5B /* missionpause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3459543308C3D6A0003B1351 /* missionpause.cpp */; }; 34C71BCE08C41B7600459F5B /* missionloopbrief.h in Headers */ = {isa = PBXBuildFile; fileRef = 3459543208C3D6A0003B1351 /* missionloopbrief.h */; }; @@ -976,7 +969,6 @@ 345952D508C3D69F003B1351 /* aigoals.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = aigoals.cpp; sourceTree = ""; }; 345952D608C3D69F003B1351 /* aigoals.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = aigoals.h; sourceTree = ""; }; 345952D708C3D69F003B1351 /* aiinternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = aiinternal.h; sourceTree = ""; }; - 345952D808C3D69F003B1351 /* ailocal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ailocal.h; sourceTree = ""; }; 345952D908C3D69F003B1351 /* aiturret.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = aiturret.cpp; sourceTree = ""; }; 345952DB08C3D69F003B1351 /* animplay.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = animplay.cpp; sourceTree = ""; }; 345952DC08C3D69F003B1351 /* animplay.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = animplay.h; sourceTree = ""; }; @@ -1014,8 +1006,6 @@ 3459530D08C3D69F003B1351 /* debris.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = debris.cpp; sourceTree = ""; }; 3459530E08C3D69F003B1351 /* debris.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = debris.h; sourceTree = ""; }; 3459531008C3D69F003B1351 /* console.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = console.cpp; sourceTree = ""; }; - 3459531308C3D69F003B1351 /* timerbar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = timerbar.cpp; sourceTree = ""; }; - 3459531408C3D69F003B1351 /* timerbar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = timerbar.h; sourceTree = ""; }; 3459531E08C3D69F003B1351 /* dxguid.lib */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = dxguid.lib; sourceTree = ""; }; 3459531F08C3D6A0003B1351 /* strmiids.lib */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = strmiids.lib; sourceTree = ""; }; 3459532008C3D6A0003B1351 /* vasync.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = vasync.h; sourceTree = ""; }; @@ -1230,14 +1220,10 @@ 3459543208C3D6A0003B1351 /* missionloopbrief.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionloopbrief.h; sourceTree = ""; }; 3459543308C3D6A0003B1351 /* missionpause.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missionpause.cpp; sourceTree = ""; }; 3459543408C3D6A0003B1351 /* missionpause.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionpause.h; sourceTree = ""; }; - 3459543508C3D6A0003B1351 /* missionrecommend.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missionrecommend.cpp; sourceTree = ""; }; - 3459543608C3D6A0003B1351 /* missionrecommend.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionrecommend.h; sourceTree = ""; }; 3459543708C3D6A0003B1351 /* missionscreencommon.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missionscreencommon.cpp; sourceTree = ""; }; 3459543808C3D6A0003B1351 /* missionscreencommon.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionscreencommon.h; sourceTree = ""; }; 3459543908C3D6A0003B1351 /* missionshipchoice.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missionshipchoice.cpp; sourceTree = ""; }; 3459543A08C3D6A0003B1351 /* missionshipchoice.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionshipchoice.h; sourceTree = ""; }; - 3459543B08C3D6A0003B1351 /* missionstats.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missionstats.cpp; sourceTree = ""; }; - 3459543C08C3D6A0003B1351 /* missionstats.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionstats.h; sourceTree = ""; }; 3459543D08C3D6A0003B1351 /* missionweaponchoice.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missionweaponchoice.cpp; sourceTree = ""; }; 3459543E08C3D6A0003B1351 /* missionweaponchoice.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = missionweaponchoice.h; sourceTree = ""; }; 3459543F08C3D6A0003B1351 /* redalert.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = redalert.cpp; sourceTree = ""; }; @@ -2014,7 +2000,6 @@ 345952D508C3D69F003B1351 /* aigoals.cpp */, 345952D608C3D69F003B1351 /* aigoals.h */, 345952D708C3D69F003B1351 /* aiinternal.h */, - 345952D808C3D69F003B1351 /* ailocal.h */, 345952D908C3D69F003B1351 /* aiturret.cpp */, ); path = ai; @@ -2155,8 +2140,6 @@ F0E076E2190826C00069F480 /* consolecmds.cpp */, F0E076E3190826C00069F480 /* consoleparse.cpp */, F0E076E4190826C00069F480 /* consoleparse.h */, - 3459531308C3D69F003B1351 /* timerbar.cpp */, - 3459531408C3D69F003B1351 /* timerbar.h */, ); path = debugconsole; sourceTree = ""; @@ -2532,14 +2515,10 @@ 3459543208C3D6A0003B1351 /* missionloopbrief.h */, 3459543308C3D6A0003B1351 /* missionpause.cpp */, 3459543408C3D6A0003B1351 /* missionpause.h */, - 3459543508C3D6A0003B1351 /* missionrecommend.cpp */, - 3459543608C3D6A0003B1351 /* missionrecommend.h */, 3459543708C3D6A0003B1351 /* missionscreencommon.cpp */, 3459543808C3D6A0003B1351 /* missionscreencommon.h */, 3459543908C3D6A0003B1351 /* missionshipchoice.cpp */, 3459543A08C3D6A0003B1351 /* missionshipchoice.h */, - 3459543B08C3D6A0003B1351 /* missionstats.cpp */, - 3459543C08C3D6A0003B1351 /* missionstats.h */, 3459543D08C3D6A0003B1351 /* missionweaponchoice.cpp */, 3459543E08C3D6A0003B1351 /* missionweaponchoice.h */, 3459543F08C3D6A0003B1351 /* redalert.cpp */, @@ -3292,7 +3271,6 @@ F093F85010FDC09B0042E30F /* gropenglpostprocessing.h in Headers */, F093F85110FDC09B0042E30F /* gropenglshader.h in Headers */, F093F85210FDC09B0042E30F /* gropenglstate.h in Headers */, - 34C71AD408C419CB00459F5B /* ailocal.h in Headers */, 34C71AD508C419CC00459F5B /* aiinternal.h in Headers */, 34C71AD608C419CC00459F5B /* aigoals.h in Headers */, 34C71AD908C419CE00459F5B /* aibig.h in Headers */, @@ -3314,7 +3292,6 @@ 34C71AFC08C41A9B00459F5B /* cutscenes.h in Headers */, 34C71AFE08C41AAA00459F5B /* ddsutils.h in Headers */, 34C71B0008C41AAD00459F5B /* debris.h in Headers */, - 34C71B0208C41AB000459F5B /* timerbar.h in Headers */, 34C71B0B08C41ABE00459F5B /* exceptionhandler.h in Headers */, 34C71B0E08C41AC100459F5B /* fireballs.h in Headers */, 34C71B1808C41ACB00459F5B /* gameplayhelp.h in Headers */, @@ -3402,10 +3379,8 @@ 34C71BBE08C41B6B00459F5B /* missionbriefcommon.h in Headers */, 34C71BC008C41B6F00459F5B /* redalert.h in Headers */, 34C71BC208C41B7000459F5B /* missionweaponchoice.h in Headers */, - 34C71BC408C41B7100459F5B /* missionstats.h in Headers */, 34C71BC608C41B7200459F5B /* missionshipchoice.h in Headers */, 34C71BC808C41B7300459F5B /* missionscreencommon.h in Headers */, - 34C71BCA08C41B7400459F5B /* missionrecommend.h in Headers */, 34C71BCC08C41B7500459F5B /* missionpause.h in Headers */, 34C71BCE08C41B7600459F5B /* missionloopbrief.h in Headers */, 34C71BD008C41B7700459F5B /* missiondebrief.h in Headers */, @@ -3931,7 +3906,6 @@ 34C71AFD08C41A9B00459F5B /* cutscenes.cpp in Sources */, 34C71AFF08C41AAA00459F5B /* ddsutils.cpp in Sources */, 34C71B0108C41AAD00459F5B /* debris.cpp in Sources */, - 34C71B0308C41AB000459F5B /* timerbar.cpp in Sources */, 34C71B0608C41AB200459F5B /* console.cpp in Sources */, 34C71B0C08C41ABE00459F5B /* exceptionhandler.cpp in Sources */, 34C71B0D08C41AC100459F5B /* warpineffect.cpp in Sources */, @@ -4013,10 +3987,8 @@ 34C71BBF08C41B6C00459F5B /* missionbriefcommon.cpp in Sources */, 34C71BC108C41B7000459F5B /* redalert.cpp in Sources */, 34C71BC308C41B7000459F5B /* missionweaponchoice.cpp in Sources */, - 34C71BC508C41B7100459F5B /* missionstats.cpp in Sources */, 34C71BC708C41B7300459F5B /* missionshipchoice.cpp in Sources */, 34C71BC908C41B7300459F5B /* missionscreencommon.cpp in Sources */, - 34C71BCB08C41B7500459F5B /* missionrecommend.cpp in Sources */, 34C71BCD08C41B7600459F5B /* missionpause.cpp in Sources */, 34C71BCF08C41B7700459F5B /* missionloopbrief.cpp in Sources */, 34C71BD108C41B7800459F5B /* missiondebrief.cpp in Sources */,