Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/controlconfig/controlsconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ enum IoActionId {
//!< ----------------------------
CYCLE_PRIMARY_WEAPON_SEQUENCE =118, //!< cycle num primaries to fire at once

//!< @n
//!< Auto-balance shields
//!< ----------------------
TOGGLE_AUTO_SHIELD_EQUALIZE =119, //!< toggle automatic shield equalization

/*!
* This must always be below the last defined item
*/
Expand Down
10 changes: 9 additions & 1 deletion code/controlconfig/controlsconfigcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ config_item Control_config[CCFG_MAX + 1] = {
{ KEY_ALTED | KEY_N, -1, COMPUTER_TAB, false, "Cycle Nav Points", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_G, -1, SHIP_TAB, false, "Toggle Gliding", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_O, -1, WEAPON_TAB, false, "Cycle Primary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_Q, -1, COMPUTER_TAB, false, "Toggle Auto Equalize Shields", CC_TYPE_TRIGGER, -1, -1, 0, true, false },
{ -1, -1, -1, false, "", CC_TYPE_TRIGGER, -1, -1, 0, false, false }
};

Expand Down Expand Up @@ -594,7 +595,6 @@ void control_config_common_load_overrides();
void control_config_common_init()
{
for (int i=0; i<CCFG_MAX; i++) {
Control_config[i].disabled = false;
Control_config[i].continuous_ongoing = false;
}

Expand Down Expand Up @@ -812,8 +812,10 @@ void control_config_common_load_overrides()
LoadEnumsIntoMaps();

if (cf_exists_full("controlconfigdefaults.tbl", CF_TYPE_TABLES)) {
mprintf(("Found controlconfigdefaults.tbl\n"));
read_file_text("controlconfigdefaults.tbl", CF_TYPE_TABLES);
} else {
mprintf(("Didn't find controlconfigdefaults.tbl, using hardcoded values\n"));
read_file_text_from_default(defaults_get_file("controlconfigdefaults.tbl"));
}

Expand All @@ -829,8 +831,10 @@ void control_config_common_load_overrides()
SCP_string preset_name;
if (optional_string("$Name:")) {
stuff_string_line(preset_name);
mprintf((" Found preset %s\n", preset_name.c_str()));
} else {
preset_name = "<unnamed preset>";
mprintf((" Found unnamed preset\n"));
}
Control_config_preset_names.push_back(preset_name);

Expand Down Expand Up @@ -902,9 +906,13 @@ void control_config_common_load_overrides()

if (optional_string("+Disable")) {
r_ccConfig.disabled = true;
mprintf((" Deprecated option '+Disable' found. Please use '$Disable: true' instead\n"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dead code since it appears after a return.

mprintf((" Bind '%s' was disabled\n", r_ccConfig.text));
}

if (optional_string("$Disable:")) {
stuff_boolean(&r_ccConfig.disabled);
mprintf((" Bind '%s' was %s\n", r_ccConfig.text, (r_ccConfig.disabled == true) ? "disabled" : "enabled"));
}

// Nerf the buffer now.
Expand Down
36 changes: 29 additions & 7 deletions code/io/keycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ int Normal_key_set[] = {
NAV_CYCLE,

TOGGLE_GLIDING,
CYCLE_PRIMARY_WEAPON_SEQUENCE
CYCLE_PRIMARY_WEAPON_SEQUENCE,

TOGGLE_AUTO_SHIELD_EQUALIZE,
};

int Dead_key_set[] = {
Expand Down Expand Up @@ -394,6 +396,7 @@ int Critical_key_set[] = {
SHIELD_XFER_RIGHT,
XFER_SHIELD,
XFER_LASER,
TOGGLE_AUTO_SHIELD_EQUALIZE,
};

int Non_critical_key_set[] = {
Expand Down Expand Up @@ -465,7 +468,7 @@ int Non_critical_key_set[] = {
AUTO_PILOT_TOGGLE,
NAV_CYCLE,
TOGGLE_GLIDING,
CYCLE_PRIMARY_WEAPON_SEQUENCE
CYCLE_PRIMARY_WEAPON_SEQUENCE,
};

int Ignored_keys[CCFG_MAX];
Expand Down Expand Up @@ -2304,11 +2307,6 @@ int button_function(int n)
case CYCLE_PREV_PRIMARY: // cycle to previous primary weapon
case CYCLE_SECONDARY: // cycle to next secondary weapon
case CYCLE_NUM_MISSLES: // cycle number of missiles fired from secondary bank
case SHIELD_EQUALIZE: // equalize shield energy to all quadrants
case SHIELD_XFER_TOP: // transfer shield energy to front
case SHIELD_XFER_BOTTOM: // transfer shield energy to rear
case SHIELD_XFER_LEFT: // transfer shield energy to left
case SHIELD_XFER_RIGHT: // transfer shield energy to right
case XFER_SHIELD: // transfer energy to shield from weapons
case XFER_LASER: // transfer energy to weapons from shield
return button_function_critical(n);
Expand All @@ -2327,6 +2325,18 @@ int button_function(int n)
}
return 1;
break;

case SHIELD_EQUALIZE: // equalize shield energy to all quadrants
Player->flags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE;
return button_function_critical(n);

case SHIELD_XFER_TOP: // transfer shield energy to front
case SHIELD_XFER_BOTTOM: // transfer shield energy to rear
case SHIELD_XFER_LEFT: // transfer shield energy to left
case SHIELD_XFER_RIGHT: // transfer shield energy to right
Player->flags |= PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE;
return button_function_critical(n);

}

/**
Expand Down Expand Up @@ -2514,6 +2524,7 @@ int button_function(int n)
if (!Sel_NextNav())
gamesnd_play_iface(SND_GENERAL_FAIL);
break;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an accidental whitespace insertion.

default:
keyHasBeenUsed = FALSE;
break;
Expand Down Expand Up @@ -2805,6 +2816,17 @@ int button_function(int n)
hud_escort_target_next();
break;

case TOGGLE_AUTO_SHIELD_EQUALIZE:
Players[Player_num].flags ^= PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE;
if (Players[Player_num].flags & PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE) {
Players[Player_num].flags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE;
button_function(SHIELD_EQUALIZE);
HUD_printf(XSTR("Auto shield equalization activated", 1638));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this uses a printf style format string, the format string should not be supplied from a function call. This should use "%s" as the format string and the XSTR call should be the format parameter.

} else {
HUD_printf(XSTR("Auto shield equalization deactivated", 1639));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

}
break;

default:
keyHasBeenUsed = FALSE;
break;
Expand Down
1 change: 1 addition & 0 deletions code/io/keycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ void process_set_of_keys(int key, int count, int *list);
void game_process_pause_key();
void button_strip_noncritical_keys(button_info *bi);

extern int button_function(int n);

#endif
2 changes: 1 addition & 1 deletion code/localization/localize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int Lcl_english = 1;
// the english version (in the code) to a foreign version (in the table). Thus, if you
// add a new string to the code, you must assign it a new index. Use the number below for
// that index and increase the number below by one.
#define XSTR_SIZE 1638
#define XSTR_SIZE 1640


// struct to allow for strings.tbl-determined x offset
Expand Down
5 changes: 4 additions & 1 deletion code/mission/missiontraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,11 @@ void training_mission_init()

// only clear player flags if this is actually a training mission
if ( The_mission.game_type & MISSION_TYPE_TRAINING ) {
Player->flags &= ~(PLAYER_FLAGS_MATCH_TARGET | PLAYER_FLAGS_MSG_MODE | PLAYER_FLAGS_AUTO_TARGETING | PLAYER_FLAGS_AUTO_MATCH_SPEED | PLAYER_FLAGS_LINK_PRIMARY | PLAYER_FLAGS_LINK_SECONDARY );
Player->flags &= ~(PLAYER_FLAGS_MATCH_TARGET | PLAYER_FLAGS_MSG_MODE | PLAYER_FLAGS_AUTO_TARGETING | PLAYER_FLAGS_AUTO_MATCH_SPEED | PLAYER_FLAGS_LINK_PRIMARY | PLAYER_FLAGS_LINK_SECONDARY | PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE );
}

// never start with auto shield equalization on but overridden
Player->flags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE;
}

void training_mission_page_in()
Expand Down
2 changes: 2 additions & 0 deletions code/playerman/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct campaign_info;
#define PLAYER_FLAGS_KILLED_SELF_UNKNOWN (1<<16) // player died by his own hand
#define PLAYER_FLAGS_KILLED_SELF_MISSILES (1<<17) // player died by his own missile
#define PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE (1<<18) // player died by his own shockwave
#define PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE (1<<19) // is auto shield equalization on?
#define PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE (1<<20) // is auto shield equalization overridden by manual control?

#define PLAYER_KILLED_SELF ( PLAYER_FLAGS_KILLED_SELF_MISSILES | PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE )

Expand Down
4 changes: 4 additions & 0 deletions code/playerman/playercontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,10 @@ void player_save_target_and_weapon_link_prefs()
Player->flags &= ~PLAYER_FLAGS_LINK_SECONDARY;
}
}

if ( Player->flags & PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE ) {
Player->save_flags |= PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE;
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions code/scripting/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ flag_def_list plr_commands[] = {
{ "AUTO_PILOT_TOGGLE", AUTO_PILOT_TOGGLE, 3 },
{ "NAV_CYCLE", NAV_CYCLE, 3 },
{ "TOGGLE_GLIDING", TOGGLE_GLIDING, 3 },
{ "TOGGLE_AUTO_SHIELD_EQUALIZE", TOGGLE_AUTO_SHIELD_EQUALIZE, 3 },
};

int num_plr_commands = sizeof(plr_commands)/sizeof(flag_def_list);
Expand Down
5 changes: 5 additions & 0 deletions code/ship/shiphit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "hud/hudtarget.h"
#include "iff_defs/iff_defs.h"
#include "io/joy_ff.h"
#include "io/keycontrol.h"
#include "io/timer.h"
#include "mission/missionlog.h"
#include "mod_table/mod_table.h"
Expand Down Expand Up @@ -2103,6 +2104,10 @@ static void ship_do_damage(object *ship_objp, object *other_obj, vec3d *hitpos,
damage += (piercing_pct * pre_shield);
subsystem_damage += (piercing_pct * pre_shield_ss);
}

if (((Player->flags & (PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE | PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE)) == PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE) && (ship_objp == Player_obj)) {
button_function(SHIELD_EQUALIZE);
}
}

// if shield damage was increased, don't carry over leftover damage at scaled level
Expand Down