Skip to content

Commit

Permalink
Trunk sync r11222.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.icculus.org/fs2open/branches/fs2_open_3_7_2@11223 387891d4-d844-0410-90c0-e4c51a9137d3
  • Loading branch information
chief1983 authored and niffiwan committed Jan 23, 2015
1 parent 78cf382 commit 3bcab10
Show file tree
Hide file tree
Showing 40 changed files with 624 additions and 375 deletions.
2 changes: 2 additions & 0 deletions code/ai/ai_profiles.cpp
Expand Up @@ -463,6 +463,8 @@ void parse_ai_profiles_tbl(const char *filename)

set_flag(profile, "$fix ai path order bug:", AIPF2_FIX_AI_PATH_ORDER_BUG, AIP_FLAG2);

set_flag(profile, "$strict turret-tagged-only targeting:", AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING, AIP_FLAG2);

// ----------

// compatibility
Expand Down
1 change: 1 addition & 0 deletions code/ai/ai_profiles.h
Expand Up @@ -65,6 +65,7 @@
#define AIPF2_ASPECT_LOCK_COUNTERMEASURE (1 << 11)
#define AIPF2_AI_GUARDS_SPECIFIC_SHIP_IN_WING (1 << 12)
#define AIPF2_FIX_AI_PATH_ORDER_BUG (1 << 13)
#define AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING (1 << 14)

// AI Path types
#define AI_PATH_MODE_NORMAL 0
Expand Down
24 changes: 17 additions & 7 deletions code/ai/aiturret.cpp
Expand Up @@ -650,9 +650,15 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
}
}

// check if turret flagged to only target tagged ships
// check if turret flagged to only target tagged ships
// Note: retail behaviour was turrets with tagged-only could fire at bombs
// and could fire their spawn weapons
// this check is almost redundant; see the almost identical check in ai_fire_from_turret
// however if this is removed turrets still track targets but don't fire at them (which looks silly)
if (eeo->eeo_flags & EEOF_TAGGED_ONLY) {
if (!ship_is_tagged(objp)) {
if (!ship_is_tagged(objp) &&
( (The_mission.ai_profile->flags2 & AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING) ||
( !(objp->type == OBJ_WEAPON) && !(turret_weapon_has_flags(&eeo->turret_subsys->weapons, WIF_SPAWN))) )) {
return;
}
}
Expand Down Expand Up @@ -2281,6 +2287,8 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
}

bool tagged_only = ((wip->wi_flags2 & WIF2_TAGGED_ONLY) || (ss->weapons.flags & SW_FLAG_TAGGED_ONLY));

if (lep->type == OBJ_SHIP) {
// Check if we're targeting a protected ship
if (lep->flags & OF_PROTECTED) {
Expand Down Expand Up @@ -2313,14 +2321,16 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if weapon or turret is set to tagged-only
// must check here in case turret has multiple weapons and not all are tagged-only
else if (!ship_is_tagged(lep) && tagged_only) {
continue;
}
}
else
{
//can't tag anything else, other than asteroids
//but we don't want to waste this type of
//weaponary on asteroids now do we?
if ((wip->wi_flags2 & WIF2_TAGGED_ONLY) || (ss->weapons.flags & SW_FLAG_TAGGED_ONLY))
{
// check tagged-only for non-ship targets
if (tagged_only && (!(lep->type == OBJ_WEAPON) || (The_mission.ai_profile->flags2 & AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING))) {
continue;
}
}
Expand Down
20 changes: 7 additions & 13 deletions code/cfile/cfile.cpp
Expand Up @@ -492,23 +492,17 @@ int cf_access(const char *filename, int dir_type, int mode)

// Returns 1 if the file exists, 0 if not.
// Checks only the file system.
// cf_find_file_location checks the filesystem before VPs
// If offset is 0, it was found in the filesystem, so offset is boolean false
// If offset equates to boolean true, it was found in a VP and the logic will negate the function return
int cf_exists(const char *filename, int dir_type)
{
char longname[MAX_PATH_LEN];

Assert(CF_TYPE_SPECIFIED(dir_type));

cf_create_default_path_string(longname, sizeof(longname) - 1, dir_type, filename);
int offset = 1;

FILE *fp = fopen(longname, "rb");
if (fp)
{
// Goober5000 - these were switched, causing the fclose to be unreachable
fclose(fp);
return 1;
}
if ( (filename == NULL) || !strlen(filename) )
return 0;

return 0;
return (cf_find_file_location(filename, dir_type, 0, NULL, &offset, NULL) && !offset);
}

// Goober5000
Expand Down
8 changes: 8 additions & 0 deletions code/cmdline/cmdline.cpp
Expand Up @@ -198,6 +198,7 @@ Flag exe_params[] =

{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
{ "-brief_lighting", "Enable lighting on briefing models", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-brief_lighting", },

{ "-fps", "Show frames per second on HUD", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fps", },
{ "-pos", "Show position of camera", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pos", },
Expand Down Expand Up @@ -302,6 +303,7 @@ cmdline_parm fxaa_arg("-fxaa", NULL, AT_NONE);
cmdline_parm fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-9), requires -post_process and -fxaa", AT_INT);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL, AT_NONE);
cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL, AT_NONE);
cmdline_parm brieflighting_arg("-brief_lighting", NULL, AT_NONE);

float Cmdline_clip_dist = Default_min_draw_distance;
float Cmdline_fov = 0.75f;
Expand All @@ -326,6 +328,7 @@ int Cmdline_fxaa_preset = 6;
extern int Fxaa_preset_last_frame;
bool Cmdline_fb_explosions = 0;
extern bool ls_force_off;
bool Cmdline_brief_lighting = 0;

// Game Speed related
cmdline_parm cache_bitmaps_arg("-cache_bitmaps", NULL, AT_NONE); // Cmdline_cache_bitmaps
Expand Down Expand Up @@ -1576,6 +1579,11 @@ bool SetCmdlineParams()
Cmdline_fb_explosions = 1;
}

if ( brieflighting_arg.found() )
{
Cmdline_brief_lighting = 1;
}

if ( postprocess_arg.found() )
{
Cmdline_postprocess = 1;
Expand Down
16 changes: 10 additions & 6 deletions code/controlconfig/controlsconfigcommon.cpp
Expand Up @@ -474,14 +474,14 @@ int translate_key_to_index(const char *key, bool find_override)
// convert scancode to Control_config index
if (find_override) {
for (i=0; i<CCFG_MAX; i++) {
if (Control_config[i].key_id == index) {
if (!Control_config[i].disabled && Control_config[i].key_id == index) {
index = i;
break;
}
}
} else {
for (i=0; i<CCFG_MAX; i++) {
if (Control_config[i].key_default == index) {
if (!Control_config[i].disabled && Control_config[i].key_default == index) {
index = i;
break;
}
Expand Down Expand Up @@ -834,8 +834,12 @@ void control_config_common_load_overrides()
int iTemp;

if (optional_string("$Key Default:")) {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.key_default = (short)mKeyNameToVal[szTempBuffer];
if (optional_string("NONE")) {
r_ccConfig.key_default = (short)-1;
} else {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.key_default = (short)mKeyNameToVal[szTempBuffer];
}
}

if (optional_string("$Joy Default:")) {
Expand All @@ -860,7 +864,7 @@ void control_config_common_load_overrides()

if (optional_string("$Category:")) {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.tab = (char)mKeyNameToVal[szTempBuffer];
r_ccConfig.tab = (char)mCCTabNameToVal[szTempBuffer];
}

if (optional_string("$Has XStr:")) {
Expand All @@ -870,7 +874,7 @@ void control_config_common_load_overrides()

if (optional_string("$Type:")) {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.type = (char)mKeyNameToVal[szTempBuffer];
r_ccConfig.type = (char)mCCTypeNameToVal[szTempBuffer];
}

if (optional_string("+Disable")) {
Expand Down
2 changes: 2 additions & 0 deletions code/cutscene/cutscenes.cpp
Expand Up @@ -150,6 +150,8 @@ void cutscene_mark_viewable(char *filename)
}
i++;
}

Warning(LOCATION, "Could not find cutscene '%s' in listing; cannot mark it viewable...", filename);
}

#define NUM_BUTTONS 8
Expand Down
6 changes: 3 additions & 3 deletions code/fred2/missionsave.cpp
Expand Up @@ -714,7 +714,7 @@ int CFred_mission_save::save_cutscenes()
}

for (uint i = 0; i < The_mission.cutscenes.size(); i++) {
if ( strlen(The_mission.cutscenes[i].cutscene_name) ) {
if ( strlen(The_mission.cutscenes[i].filename) ) {
// determine the name of this cutscene type
switch (The_mission.cutscenes[i].type) {
case MOVIE_PRE_FICTION:
Expand Down Expand Up @@ -742,10 +742,10 @@ int CFred_mission_save::save_cutscenes()

if (optional_string_fred(type)) {
parse_comments();
fout(" %s", The_mission.cutscenes[i].cutscene_name);
fout(" %s", The_mission.cutscenes[i].filename);
}
else {
fout_version("%s %s\n", type, The_mission.cutscenes[i].cutscene_name);
fout_version("%s %s\n", type, The_mission.cutscenes[i].filename);
}

required_string_fred("+formula:");
Expand Down
4 changes: 4 additions & 0 deletions code/freespace2/freespace.cpp
Expand Up @@ -8967,6 +8967,10 @@ void game_unpause()
case GS_STATE_GAME_PLAY:
break;

// ditto for if we explicitly paused the game and then minimized it
case GS_STATE_GAME_PAUSED:
break;

case GS_STATE_FICTION_VIEWER:
fiction_viewer_unpause();
break;
Expand Down
36 changes: 19 additions & 17 deletions code/io/keycontrol.cpp
Expand Up @@ -68,8 +68,6 @@ int count;
int table[ MAX_NUM_SLOTS ];
};

#define MAX_SLOT_COUNT 25

class factor_table
{
public:
Expand All @@ -96,9 +94,9 @@ memset( table, 0x00, sizeof( ftable ) * MAX_NUM_SLOTS );
for( int i = 0 ; i < MAX_NUM_SLOTS; ++i )
{
table[ i ].count = 0;
for( int j = 1; j <= i; ++j )
for( int j = 1; j <= i + 1; ++j )
{
if( isAPrimeFactor( j, i ) )
if( isAPrimeFactor( j, i + 1 ) )
{
table[ i ].table[ table[ i ].count ] = j;
table[ i ].count ++;
Expand All @@ -109,28 +107,30 @@ for( int i = 0 ; i < MAX_NUM_SLOTS; ++i )

int factor_table::getNextSlots(int slots_on_ship, int cur_slots)
{
Assert( slots_on_ship <= MAX_NUM_SLOTS );
Assert( slots_on_ship >= 0 );
Assertion( slots_on_ship <= MAX_NUM_SLOTS, "factor_table::getNextSlots() called with %d slots, when MAX_NUM_SLOTS is %d; get a coder!\n", slots_on_ship, MAX_NUM_SLOTS );
Assertion( slots_on_ship >= 1, "factor_table::getNextSlots() called with %d slots, when only positive integers make sense; get a coder!\n" );

int slots_index = slots_on_ship - 1;

for( int i = 0; i < table[ slots_on_ship ].count; ++i )
for( int i = 0; i < table[ slots_index ].count; ++i )
{
if( table[ slots_on_ship ].table[ i ] == cur_slots )
if( table[ slots_index ].table[ i ] == cur_slots )
{
if( table[ slots_on_ship ].count == i + 1 )
if( table[ slots_index ].count == i + 1 )
{
//Overflow back to 1
return 1;
}
else
{
//Next block in the table
return table[ slots_on_ship ].table[ i + 1 ];
return table[ slots_index ].table[ i + 1 ];
}
}
}
//Did not find cur_slots, try and get back on track

Assert( 0 );
Assertion( false, "For some reason, factor_table::getNextSlots() was unable to locate cur_slots. This should never happen; get a coder!\n" );
return 1;
}

Expand Down Expand Up @@ -1737,12 +1737,14 @@ int button_function_critical(int n, net_player *p = NULL)
ship * shipp = &Ships[objp->instance];
ship_weapon *swp = &shipp->weapons;
ship_info *sip = &Ship_info[shipp->ship_info_index];
polymodel *pm = model_get( sip->model_num );
count = ftables.getNextSlots( pm->gun_banks[ swp->current_primary_bank ].num_slots, swp->primary_bank_slot_count[ swp->current_primary_bank ] );
swp->primary_bank_slot_count[ swp->current_primary_bank ] = count;
shipp->last_fired_point[ swp->current_primary_bank ] += count - ( shipp->last_fired_point[ swp->current_primary_bank ] % count);
shipp->last_fired_point[ swp->current_primary_bank ] -= 1;
shipp->last_fired_point[ swp->current_primary_bank ] %= swp->primary_bank_slot_count[ swp->current_primary_bank ];
if (sip->flags2 & SIF2_DYN_PRIMARY_LINKING) {
polymodel *pm = model_get( sip->model_num );
count = ftables.getNextSlots( pm->gun_banks[ swp->current_primary_bank ].num_slots, swp->primary_bank_slot_count[ swp->current_primary_bank ] );
swp->primary_bank_slot_count[ swp->current_primary_bank ] = count;
shipp->last_fired_point[ swp->current_primary_bank ] += count - ( shipp->last_fired_point[ swp->current_primary_bank ] % count);
shipp->last_fired_point[ swp->current_primary_bank ] -= 1;
shipp->last_fired_point[ swp->current_primary_bank ] %= swp->primary_bank_slot_count[ swp->current_primary_bank ];
}
}
break;

Expand Down
40 changes: 40 additions & 0 deletions code/math/vecmat.cpp
Expand Up @@ -1069,6 +1069,46 @@ angles *vm_extract_angles_matrix(angles *a,matrix *m)
return a;
}

// alternate method for extracting angles which seems to be
// less susceptible to rounding errors -- see section 8.7.2
// (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)
{
Assert(a != NULL);
Assert(m != NULL);

// Extract pitch from m32, being careful for domain errors with
// asin(). We could have values slightly out of range due to
// floating point arithmetic.
float sp = -m->vec.fvec.xyz.y;
if (sp <= -1.0f) {
a->p = -PI_2; // -pi/2
} else if (sp >= 1.0f) {
a->p = PI_2; // pi/2
} else {
a->p = asin(sp);
}

// Check for the Gimbal lock case, giving a slight tolerance
// for numerical imprecision
if (fabs(sp) > 0.9999f) {
// We are looking straight up or down.
// Slam bank to zero and just set heading
a->b = 0.0f;
a->h = atan2(-m->vec.rvec.xyz.z, m->vec.rvec.xyz.x);
} else {
// Compute heading
a->h = atan2(m->vec.fvec.xyz.x, m->vec.fvec.xyz.z);

// Compute bank
a->b = atan2(m->vec.rvec.xyz.y, m->vec.uvec.xyz.y);
}

return a;
}


//extract heading and pitch from a vector, assuming bank==0
angles *vm_extract_angles_vector_normalized(angles *a,vec3d *v)
Expand Down
1 change: 1 addition & 0 deletions code/math/vecmat.h
Expand Up @@ -366,6 +366,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_alternate(angles *a,matrix *m);

//extract heading and pitch from a vector, assuming bank==0
angles *vm_extract_angles_vector(angles *a,vec3d *v);
Expand Down
16 changes: 1 addition & 15 deletions code/menuui/playermenu.cpp
Expand Up @@ -975,21 +975,7 @@ void player_select_process_noninput(int k)

// delete the currently highlighted pilot
case KEY_DELETE:
if (Player_select_pilot >= 0) {
int ret;

if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) {
popup(PF_TITLE_BIG | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("Pilots can only be deleted from the single player menu!", 1611));
} else {
// display a popup requesting confirmation
ret = popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON,2,POPUP_NO,POPUP_YES,XSTR( "Are you sure you want to delete this pilot?", 383));

// delete the pilot
if (ret == 1) {
player_select_delete_pilot();
}
}
}
player_select_button_pressed(DELETE_BUTTON);
break;
}

Expand Down
5 changes: 3 additions & 2 deletions code/mission/missionmessage.cpp
Expand Up @@ -1169,8 +1169,9 @@ void message_play_anim( message_q *q )

// support ships use a wingman head.
// terran command uses its own set of heads.
int subhead_selected = FALSE;
if ( (q->message_num < Num_builtin_messages) || !(_strnicmp(HEAD_PREFIX_STRING, ani_name, strlen(HEAD_PREFIX_STRING)-1)) ) {
if ( (anim_info->anim_data.first_frame < 0) && // note, first_frame will be >= 0 when ani is an existing file, and will be < 0 when the file does not exist and needs a, b, or c appended
((q->message_num < Num_builtin_messages) || !(_strnicmp(HEAD_PREFIX_STRING, ani_name, strlen(HEAD_PREFIX_STRING)-1))) ) {
int subhead_selected = FALSE;
persona_index = m->persona_index;

// if this ani should be converted to a terran command, set the persona to the command persona
Expand Down

0 comments on commit 3bcab10

Please sign in to comment.