Compare commits

..
Author SHA1 Message Date
asarium c084a432d4 Add lights to thrusters 2020-05-02 15:33:52 +02:00
47 changed files with 763 additions and 1019 deletions

No files matched your search

-2
View File
@@ -85,8 +85,6 @@ namespace AI {
Beams_damage_weapons,
Big_ships_can_attack_beam_turrets_on_untargeted_ships,
Disable_linked_fire_penalty,
Disable_player_secondary_doublefire,
Disable_ai_secondary_doublefire,
Disable_weapon_damage_scaling,
Dont_insert_random_turret_fire_delay,
Fix_ai_class_bug,
-4
View File
@@ -375,10 +375,6 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$disable linked fire penalty:", AI::Profile_Flags::Disable_linked_fire_penalty);
set_flag(profile, "$disable player secondary doublefire:", AI::Profile_Flags::Disable_player_secondary_doublefire);
set_flag(profile, "$disable ai secondary doublefire:", AI::Profile_Flags::Disable_ai_secondary_doublefire);
set_flag(profile, "$disable weapon damage scaling:", AI::Profile_Flags::Disable_weapon_damage_scaling);
set_flag(profile, "$use additive weapon velocity:", AI::Profile_Flags::Use_additive_weapon_velocity);
+3 -3
View File
@@ -12552,13 +12552,13 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_
polymodel *pm = model_get( Ship_info[parent_shipp->ship_info_index].model_num );
ship_bay *bay = pm->ship_bay;
if ( bay == nullptr ) {
Warning(LOCATION, "Ship %s was set to arrive from fighter bay on object %s, but no fighter bay exists on that ships' model (%s).\n", shipp->ship_name, parent_shipp->ship_name, pm->filename);
if ( bay == NULL ) {
WarningEx(LOCATION, "Ship %s was set to arrive from fighter bay on object %s, but no fighter bay exists on that ships' model (%s).\n", shipp->ship_name, parent_shipp->ship_name, pm->filename);
return -1;
}
if ( bay->num_paths <= 0 ) {
Warning(LOCATION, "Ship %s was set to arrive from fighter bay on object %s, but no fighter bay paths exist on that ships' model (%s).\n", shipp->ship_name, parent_shipp->ship_name, pm->filename);
WarningEx(LOCATION, "Ship %s was set to arrive from fighter bay on object %s, but no fighter bay paths exist on that ships' model (%s).\n", shipp->ship_name, parent_shipp->ship_name, pm->filename);
return -1;
}
+11 -6
View File
@@ -2544,6 +2544,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
// Ok, the turret is lined up... now line up a particular gun.
bool ok_to_fire = false;
bool something_was_ok_to_fire=false;
vec3d tv2e; //so flak can get their jitter without screwing up other guns
if (in_fov ) {
@@ -2580,9 +2581,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ss->turret_next_fire_pos = ffp_pos;
}
// We're ready to fire... now get down to specifics, like where is the
// actual gun point and normal, not just the one for whole turret.
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
// Fire in the direction the turret is facing, not right at the target regardless of turret dir.
vm_vec_sub(&v2e, &predicted_enemy_pos, &gpos);
@@ -2593,6 +2592,12 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
wip = get_turret_weapon_wip(&ss->weapons, valid_weapons[0]);
else
wip = get_turret_weapon_wip(&ss->weapons, valid_weapons[i]);
// We're ready to fire... now get down to specifics, like where is the
// actual gun point and normal, not just the one for whole turret.
// moved here as if there are two weapons with indentical fire stamps
// they would have shared the fire point.
tv2e = gvec;
// make sure to reset this for current weapon
ok_to_fire = false;
@@ -2600,7 +2605,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
// if the weapon is a flak gun, add some jitter to its aim so it fires in a "cone"
// to make a cool visual effect and make them less lethal
if(wip->wi_flags[Weapon::Info_Flags::Flak]){
flak_jitter_aim(&v2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS), wip);
flak_jitter_aim(&tv2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS), wip);
}
// Fire if:
@@ -2711,9 +2716,9 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//Pass along which gun we are using
if (tp->flags[Model::Subsystem_Flags::Turret_salvo])
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &v2e, &predicted_enemy_pos);
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
else
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &v2e, &predicted_enemy_pos);
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
} else {
// make sure salvo fire mode does not turn into autofire
if ((tp->flags[Model::Subsystem_Flags::Turret_salvo]) && ((i + 1) == number_of_firings)) {
+32 -63
View File
@@ -162,7 +162,8 @@ Flag exe_params[] =
{ "-3dshockwave", "Enable 3D shockwaves", true, EASY_ALL_ON | EASY_HI_MEM_ON, EASY_DEFAULT | EASY_HI_MEM_OFF, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dshockwave" },
{ "-no_post_process", "Disable post-processing", true, EASY_DEFAULT | EASY_HI_MEM_OFF, EASY_ALL_ON | EASY_HI_MEM_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_post_process" },
{ "-soft_particles", "Enable soft particles", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-soft_particles" },
{ "-aa", "Enable Post-process anti-aliasing", true, EASY_ALL_ON | EASY_HI_MEM_ON, EASY_DEFAULT | EASY_HI_MEM_OFF, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-aa" },
{ "-fxaa", "Enable FXAA anti-aliasing", true, EASY_ALL_ON | EASY_HI_MEM_ON, EASY_DEFAULT | EASY_HI_MEM_OFF, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fxaa" },
{ "-smaa", "Enable SMAA anti-aliasing", true, EASY_ALL_ON | EASY_HI_MEM_ON, EASY_DEFAULT | EASY_HI_MEM_OFF, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-smaa" },
{ "-nolightshafts", "Disable lightshafts", true, EASY_DEFAULT | EASY_HI_MEM_OFF, EASY_ALL_ON | EASY_HI_MEM_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nolightshafts"},
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_explosions", },
{ "-fb_thrusters", "Enable Framebuffer Thrusters", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_thrusters", },
@@ -321,12 +322,10 @@ cmdline_parm enable_3d_shockwave_arg("-3dshockwave", NULL, AT_NONE);
cmdline_parm softparticles_arg("-soft_particles", NULL, AT_NONE);
cmdline_parm no_postprocess_arg("-no_post_process", "Disables post-processing", AT_NONE);
cmdline_parm bloom_intensity_arg("-bloom_intensity", "Set bloom intensity, requires post-processing", AT_INT);
cmdline_parm post_process_aa_arg("-aa", "Enables post-process antialiasing", AT_NONE);
cmdline_parm post_process_aa_preset_arg("-aa_preset", "Sets the AA effect to use. See the wiki for details", AT_INT);
cmdline_parm deprecated_fxaa_arg("-fxaa", nullptr, AT_NONE);
cmdline_parm deprecated_fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-2), requires post-processing and -fxaa", AT_INT);
cmdline_parm deprecated_smaa_arg("-smaa", nullptr, AT_NONE);
cmdline_parm deprecated_smaa_preset_arg("-smaa_preset", "SMAA quality (0-3), requires post-processing and -smaa", AT_INT);
cmdline_parm fxaa_arg("-fxaa", NULL, AT_NONE);
cmdline_parm fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-9), requires post-processing and -fxaa", AT_INT);
cmdline_parm smaa_arg("-smaa", nullptr, AT_NONE);
cmdline_parm smaa_preset_arg("-smaa_preset", "SMAA quality (0-9), requires post-processing and -smaa", AT_INT);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL, AT_NONE);
cmdline_parm fb_thrusters_arg("-fb_thrusters", NULL, AT_NONE);
cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL, AT_NONE);
@@ -1864,31 +1863,40 @@ bool SetCmdlineParams()
if ( height_arg.found() ) {
Cmdline_height = 0;
}
if (fxaa_arg.found() ) {
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
if (post_process_aa_arg.found() || post_process_aa_preset_arg.found()) {
Gr_aa_mode = AntiAliasMode::SMAA_Low;
if (post_process_aa_preset_arg.found()) {
switch (post_process_aa_preset_arg.get_int()) {
case 0:
Gr_aa_mode = AntiAliasMode::FXAA_Low;
break;
case 1:
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
break;
case 2:
if (fxaa_preset_arg.found()) {
auto val = fxaa_preset_arg.get_int();
if (val > 6) {
Gr_aa_mode = AntiAliasMode::FXAA_High;
break;
case 3:
} else if (val > 3) {
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
} else {
Gr_aa_mode = AntiAliasMode::FXAA_Low;
}
}
}
if (smaa_arg.found()) {
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
if (smaa_preset_arg.found()) {
switch (smaa_preset_arg.get_int()) {
case 0:
Gr_aa_mode = AntiAliasMode::SMAA_Low;
break;
case 4:
case 1:
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
break;
case 5:
case 2:
Gr_aa_mode = AntiAliasMode::SMAA_High;
break;
case 6:
case 3:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
default:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
}
@@ -2202,45 +2210,6 @@ bool SetCmdlineParams()
if (deprecated_postprocess_arg.found()) {
Cmdline_deprecated_postprocess = true;
}
if (deprecated_fxaa_arg.found() ) {
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
if (deprecated_fxaa_preset_arg.found()) {
auto val = deprecated_fxaa_preset_arg.get_int();
if (val > 6) {
Gr_aa_mode = AntiAliasMode::FXAA_High;
} else if (val > 3) {
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
} else {
Gr_aa_mode = AntiAliasMode::FXAA_Low;
}
}
}
if (deprecated_smaa_arg.found()) {
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
if (deprecated_smaa_preset_arg.found()) {
switch (deprecated_smaa_preset_arg.get_int()) {
case 0:
Gr_aa_mode = AntiAliasMode::SMAA_Low;
break;
case 1:
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
break;
case 2:
Gr_aa_mode = AntiAliasMode::SMAA_High;
break;
case 3:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
default:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
}
}
}
return true;
}
+1 -1
View File
@@ -70,7 +70,7 @@
// from weapon.h
#define MAX_WEAPONS 2000
#define MAX_WEAPON_TYPES 500
#define MAX_WEAPON_TYPES 300
// from model.h
+16 -8
View File
@@ -7,15 +7,12 @@
*
*/
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
#endif
#include "2d.h"
#include "globalincs/alphacolors.h"
#include "globalincs/systemvars.h"
#include "2d.h"
#include "debug.h"
#include "grinternal.h"
#include "grstub.h"
#include "light.h"
@@ -47,6 +44,11 @@
#include <algorithm>
#include <climits>
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
#endif
#if (SDL_VERSION_ATLEAST(1, 2, 7))
#include "SDL_cpuinfo.h"
#endif
@@ -990,13 +992,17 @@ bool gr_unsize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo
void gr_close()
{
if ( !Gr_inited ) {
if (!Gr_inited) {
return;
}
graphics::debug::cleanup();
if (Gr_original_gamma_ramp != nullptr && os::getSDLMainWindow() != nullptr) {
SDL_SetWindowGammaRamp(os::getSDLMainWindow(), Gr_original_gamma_ramp, (Gr_original_gamma_ramp + 256),
(Gr_original_gamma_ramp + 512));
SDL_SetWindowGammaRamp(os::getSDLMainWindow(),
Gr_original_gamma_ramp,
(Gr_original_gamma_ramp + 256),
(Gr_original_gamma_ramp + 512));
}
// This is valid even if Gr_original_gamma_ramp is nullptr
@@ -2629,6 +2635,8 @@ void gr_flip(bool execute_scripting)
Script_system.EndFrame();
}
graphics::debug::render_elements();
gr_reset_immediate_buffer();
// Do per frame operations on the matrix state
+146
View File
@@ -0,0 +1,146 @@
#include "debug.h"
#include "render/3dinternal.h"
namespace graphics {
namespace debug {
namespace {
enum DebugElementType {
Line,
Text,
};
struct LineParams {
vertex projected_from;
vertex projected_to;
color line_color;
};
struct TextParams {
vertex projected_pos;
color text_color;
SCP_string text;
};
struct DebugElement {
DebugElementType type;
// A variant/union would be good here but our C++ version does not support that yet
LineParams lineParams;
TextParams textParams;
};
bool vertex_offscreen(const vertex& v) { return v.flags & PF_OVERFLOW; }
SCP_vector<DebugElement> debugElements;
void render_line(LineParams& lineParams)
{
if (vertex_offscreen(lineParams.projected_from) && vertex_offscreen(lineParams.projected_to)) {
return;
}
gr_set_color_fast(&lineParams.line_color);
gr_line(lineParams.projected_from.screen.xyw.x,
lineParams.projected_from.screen.xyw.y,
lineParams.projected_to.screen.xyw.x,
lineParams.projected_to.screen.xyw.y,
GR_RESIZE_NONE);
}
void render_text(TextParams& params)
{
if (vertex_offscreen(params.projected_pos)) {
return;
}
font::set_font(font::FONT1);
gr_set_color_fast(&params.text_color);
gr_string(params.projected_pos.screen.xyw.x,
params.projected_pos.screen.xyw.y,
params.text.c_str(),
GR_RESIZE_NONE);
}
void render_element(DebugElement& el)
{
switch (el.type) {
case Line:
render_line(el.lineParams);
break;
case Text:
render_text(el.textParams);
break;
default:
UNREACHABLE("Unknown debug element type!");
}
}
} // namespace
void line_3d(const vec3d* from, const vec3d* to, const color* color)
{
DebugElement el;
el.type = DebugElementType::Line;
bool do_g3 = G3_count < 1;
if (do_g3)
g3_start_frame(0);
g3_rotate_vertex(&el.lineParams.projected_from, from);
g3_project_vertex(&el.lineParams.projected_from);
g3_rotate_vertex(&el.lineParams.projected_to, to);
g3_project_vertex(&el.lineParams.projected_to);
if (do_g3)
g3_end_frame();
el.lineParams.line_color = *color;
debugElements.push_back(el);
}
void text_3d(const vec3d* world_pos, const color* color, SCP_string text)
{
DebugElement el;
el.type = DebugElementType::Text;
bool do_g3 = G3_count < 1;
if (do_g3)
g3_start_frame(0);
g3_rotate_vertex(&el.textParams.projected_pos, world_pos);
g3_project_vertex(&el.textParams.projected_pos);
if (do_g3)
g3_end_frame();
el.textParams.text_color = *color;
el.textParams.text = std::move(text);
debugElements.push_back(el);
}
void render_elements()
{
if (debugElements.empty()) {
return;
}
for (auto& dbgEl : debugElements) {
render_element(dbgEl);
}
debugElements.clear();
}
void cleanup() { debugElements.clear(); }
} // namespace debug
} // namespace graphics
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include "graphics/2d.h"
#include "math/vecmat.h"
namespace graphics {
namespace debug {
void line_3d(const vec3d* from, const vec3d* to, const color* color);
void text_3d(const vec3d* world_pos, const color* color, SCP_string text);
void render_elements();
void cleanup();
} // namespace debug
} // namespace graphics
+15 -19
View File
@@ -254,29 +254,25 @@ void gr_opengl_post_process_begin()
Post_in_frame = true;
}
SCP_vector<shader_type> get_aa_shader_types(AntiAliasMode aa_mode) {
auto stypes = SCP_vector<shader_type>();
if (gr_is_fxaa_mode(aa_mode)) {
stypes.push_back(shader_type::SDR_TYPE_POST_PROCESS_FXAA);
}
else if (gr_is_smaa_mode(aa_mode)) {
stypes.push_back(shader_type::SDR_TYPE_POST_PROCESS_SMAA_BLENDING_WEIGHT);
stypes.push_back(shader_type::SDR_TYPE_POST_PROCESS_SMAA_EDGE);
stypes.push_back(shader_type::SDR_TYPE_POST_PROCESS_SMAA_NEIGHBORHOOD_BLENDING);
}
return stypes;
}
void recompile_aa_shader() {
auto stype = SCP_vector<shader_type>();
if (gr_is_fxaa_mode(Gr_aa_mode)) {
stype.push_back(shader_type::SDR_TYPE_POST_PROCESS_FXAA);
}
else if (gr_is_smaa_mode(Gr_aa_mode)) {
stype.push_back(shader_type::SDR_TYPE_POST_PROCESS_SMAA_BLENDING_WEIGHT);
stype.push_back(shader_type::SDR_TYPE_POST_PROCESS_SMAA_EDGE);
stype.push_back(shader_type::SDR_TYPE_POST_PROCESS_SMAA_NEIGHBORHOOD_BLENDING);
}
mprintf(("Recompiling AA shader(s)...\n"));
for (auto sdr : get_aa_shader_types(Gr_aa_mode_last_frame)) {
for (auto sdr : stype) {
// start recompile by grabbing deleting the current shader we have, assuming it's already created
opengl_delete_shader( gr_opengl_maybe_create_shader(sdr, 0) );
}
for (auto sdr : get_aa_shader_types(Gr_aa_mode)) {
// then recreate it again. shader loading code will be updated with the new AA presets
gr_opengl_maybe_create_shader(sdr, 0);
}
@@ -1255,7 +1251,7 @@ static bool opengl_post_init_framebuffer()
opengl_setup_bloom_textures();
if (Gr_aa_mode != AntiAliasMode::None) {
if (gr_is_smaa_mode(Gr_aa_mode)) {
setup_smaa_resources();
}
+5 -13
View File
@@ -3975,14 +3975,12 @@ void HudGaugeLeadIndicator::renderLeadCurrentTarget()
}
frame_offset = pickFrame(prange, srange, dist_to_target);
if ( frame_offset < 0 && srange != -1.0f ) {
if ( frame_offset < 0 ) {
return;
}
if (frame_offset >= 0) {
hud_calculate_lead_pos(&lead_target_pos, &target_pos, targetp, wip, dist_to_target);
renderIndicator(frame_offset, targetp, &lead_target_pos);
}
hud_calculate_lead_pos(&lead_target_pos, &target_pos, targetp, wip, dist_to_target);
renderIndicator(frame_offset, targetp, &lead_target_pos);
//do dumbfire lead indicator - color is orange (255,128,0) - bright, (192,96,0) - dim
//phreak changed 9/01/02
@@ -6076,10 +6074,7 @@ void HudGaugeWeapons::render(float /*frametime*/)
renderPrintf(position[0] + Weapon_sunlinked_offset_x, name_y, EG_NULL, "%c", Weapon_link_icon);
// indicate if this is linked
// don't draw the link indicator if the fire can't be fired link.
// the link flag is ignored rather than cleared so the player can cycle past a no-doublefire weapon without the setting being cleared
if ( Player_ship->flags[Ship::Ship_Flags::Secondary_dual_fire] && !wip->wi_flags[Weapon::Info_Flags::No_doublefire] &&
!The_mission.ai_profile->flags[AI::Profile_Flags::Disable_player_secondary_doublefire] ) {
if ( Player_ship->flags[Ship::Ship_Flags::Secondary_dual_fire] ) {
renderPrintf(position[0] + Weapon_slinked_offset_x, name_y, EG_NULL, "%c", Weapon_link_icon);
}
@@ -6997,10 +6992,7 @@ void HudGaugeSecondaryWeapons::render(float /*frametime*/)
renderPrintf(position[0] + _sunlinked_offset_x, position[1] + text_y_offset, EG_NULL, "%c", Weapon_link_icon);
// indicate if this is linked
// don't draw the link indicator if the fire can't be fired link.
// the link flag is ignored rather than cleared so the player can cycle past a no-doublefire weapon without the setting being cleared
if ( Player_ship->flags[Ship::Ship_Flags::Secondary_dual_fire] && !wip->wi_flags[Weapon::Info_Flags::No_doublefire] &&
!The_mission.ai_profile->flags[AI::Profile_Flags::Disable_player_secondary_doublefire] ) {
if ( Player_ship->flags[Ship::Ship_Flags::Secondary_dual_fire] ) {
renderPrintf(position[0] + _slinked_offset_x, position[1] + text_y_offset, EG_NULL, "%c", Weapon_link_icon);
}
+7 -20
View File
@@ -360,23 +360,6 @@ void iff_init()
num_observed_colors[cur_iff]++;
}
// get F3 override
iff->hotkey_team = IFF_hotkey_team::Default;
if (optional_string("+Hotkey Team:"))
{
char temp[NAME_LENGTH];
stuff_string(temp, F_NAME, NAME_LENGTH);
if (!stricmp(temp, "Friendly"))
iff->hotkey_team = IFF_hotkey_team::Friendly;
else if (!stricmp(temp, "Hostile") || !stricmp(temp, "Enemy"))
iff->hotkey_team = IFF_hotkey_team::Hostile;
else if (!stricmp(temp, "None"))
iff->hotkey_team = IFF_hotkey_team::None;
else
Warning(LOCATION, "Unrecognized +Hotkey Tean: %s\n", temp);
}
// get flags ----------------------------------------------------------
@@ -577,8 +560,10 @@ int iff_get_attacker_mask(int attackee_team)
*
* @param team_x Team of attacker
* @param team_y Team of attackee
*
* @return >0 if true, 0 if false
*/
bool iff_x_attacks_y(int team_x, int team_y)
int iff_x_attacks_y(int team_x, int team_y)
{
return iff_matches_mask(team_y, iff_get_attackee_mask(team_x));
}
@@ -598,10 +583,12 @@ int iff_get_mask(int team)
*
* @param team Team to test
* @param mask Mask
*
* @return 1 if matches, 0 if does not match
*/
bool iff_matches_mask(int team, int mask)
int iff_matches_mask(int team, int mask)
{
return (iff_get_mask(team) & mask) != 0;
return (iff_get_mask(team) & mask) ? 1 : 0;
}
/**
+2 -5
View File
@@ -22,8 +22,6 @@ class object;
#define IFF_COLOR_TAGGED 2
#define MAX_IFF_COLORS (MAX_IFFS + 3)
enum IFF_hotkey_team { Default = -1, None = 0, Friendly, Hostile };
// iff flags
#define IFFF_SUPPORT_ALLOWED (1 << 0) // this IFF can call for support
#define IFFF_EXEMPT_FROM_ALL_TEAMS_AT_WAR (1 << 1) // self-explanatory
@@ -43,7 +41,6 @@ typedef struct iff_info {
int attackee_bitmask; // treat this as private and use iff_get_attackee_mask or iff_x_attacks_y
int attackee_bitmask_all_teams_at_war; // treat this as private and use iff_get_attackee_mask or iff_x_attacks_y
int observed_color_index[MAX_IFFS]; // treat this as private and use iff_get_color or iff_get_color_by_team
IFF_hotkey_team hotkey_team;
// flags
int flags;
@@ -77,11 +74,11 @@ extern int iff_lookup(const char *iff_name);
// If he fires at you, you don't react unless you are coded to attack him, because you are oblivious.
extern int iff_get_attackee_mask(int attacker_team);
extern int iff_get_attacker_mask(int attackee_team);
extern bool iff_x_attacks_y(int team_x, int team_y);
extern int iff_x_attacks_y(int team_x, int team_y);
// mask stuff
extern int iff_get_mask(int team);
extern bool iff_matches_mask(int team, int mask);
extern int iff_matches_mask(int team, int mask);
// get color stuff
extern color *iff_get_color(int color_index, int is_bright);
-52
View File
@@ -17,7 +17,6 @@
#include "io/joy.h"
#include "io/timer.h"
#include "ship/ship.h"
#include "ship/ship_flags.h"
#include "playerman/player.h"
#include "weapon/weapon.h"
#include "hud/hud.h"
@@ -1096,57 +1095,6 @@ void process_debug_keys(int k)
break;
}
// Goober5000
case KEY_DEBUGGED + KEY_SHIFTED + KEY_R:
case KEY_DEBUGGED1 + KEY_SHIFTED + KEY_R:
{
// toggle support for this mission
if (The_mission.support_ships.max_support_ships == 0)
{
HUD_sourced_printf(HUD_SOURCE_HIDDEN, "%s", XSTR("Setting maximum number of support ships to infinite.", 1643));
The_mission.support_ships.max_support_ships = -1;
}
else
{
HUD_sourced_printf(HUD_SOURCE_HIDDEN, "%s", XSTR("Setting maximum number of support ships to zero.", 1644));
The_mission.support_ships.max_support_ships = 0;
}
break;
}
// Goober5000
case KEY_DEBUGGED + KEY_SHIFTED + KEY_U:
case KEY_DEBUGGED1 + KEY_SHIFTED + KEY_U:
{
// toggle the current target between scanned and unscanned
if (Player_ai->target_objnum >= 0)
{
object *objp = &Objects[Player_ai->target_objnum];
if (objp->type == OBJ_SHIP)
{
ship *targeted_shipp = &Ships[objp->instance];
if (Player_ai->targeted_subsys == nullptr)
{
if (targeted_shipp->flags[Ship::Ship_Flags::Cargo_revealed])
ship_do_cargo_hidden(targeted_shipp);
else
ship_do_cargo_revealed(targeted_shipp);
}
else
{
if (Player_ai->targeted_subsys->flags[Ship::Subsystem_Flags::Cargo_revealed])
ship_do_cap_subsys_cargo_hidden(targeted_shipp, Player_ai->targeted_subsys);
else
ship_do_cap_subsys_cargo_revealed(targeted_shipp, Player_ai->targeted_subsys);
}
}
}
break;
}
case KEY_DEBUGGED + KEY_SHIFTED + KEY_UP:
Game_detail_level++;
HUD_printf( XSTR( "Detail level set to %+d\n", 22), Game_detail_level );
-28
View File
@@ -440,13 +440,6 @@ void labviewer_render_model(float frametime)
ship_model_update_instance(obj);
Ships[obj->instance].team_name = Lab_team_color;
if (Lab_viewer_flags & LAB_FLAG_LIGHTNING_ARCS) {
obj->hull_strength = 1.0f;
}
else {
obj->hull_strength = Ship_info[Ships[obj->instance].ship_info_index].max_hull_strength;
}
}
if (Lab_render_wireframe)
@@ -1582,27 +1575,6 @@ void labviewer_change_ship_lod(Tree* caller)
Lab_selected_object = ship_create(&vmd_identity_matrix, &Lab_model_pos, ship_index);
Objects[Lab_selected_object].flags.set(Object::Object_Flags::Player_ship);
auto ship_objp = &Ships[Objects[Lab_selected_object].instance];
auto ship_infop = &Ship_info[ship_objp->ship_info_index];
// If the ship class defines replacement textures, load them and apply them to the ship
// load the texture
auto replacements = SCP_vector<texture_replace>();
for (auto tr : ship_infop->replacement_textures) {
if (!stricmp(tr.new_texture, "invisible"))
{
// invisible is a special case
tr.new_texture_id = REPLACE_WITH_INVISIBLE;
}
else
{
// try to load texture or anim as normal
tr.new_texture_id = bm_load_either(tr.new_texture);
}
replacements.push_back(tr);
}
ship_objp->apply_replacement_textures(replacements);
lab_cam_distance = Objects[Lab_selected_object].radius * 1.6f;
+5 -1
View File
@@ -490,9 +490,13 @@ void light_add_cone(const vec3d *pos, const vec3d *dir, float angle, float inner
Num_lights++;
vec3d screen_dir;
vm_vec_rotate(&screen_dir, dir, &Eye_matrix);
screen_dir.xyz.z = -screen_dir.xyz.z;
l.type = Light_Type::Cone;
l.vec = *pos;
l.vec2= *dir;
l.vec2= screen_dir;
l.cone_angle = angle;
l.cone_inner_angle = inner_angle;
l.dual_cone = dual_cone;
+30 -89
View File
@@ -48,8 +48,6 @@ int Lcl_gr = 0;
int Lcl_pl = 0;
int Lcl_english = 1;
bool *Lcl_unexpected_tstring_check = nullptr;
// executable string localization data --------------------
@@ -58,7 +56,7 @@ bool *Lcl_unexpected_tstring_check = nullptr;
// 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 1645
#define XSTR_SIZE 1643
// struct to allow for strings.tbl-determined x offset
@@ -628,18 +626,15 @@ void lcl_fred_replace_stuff(SCP_string &text)
// XSTR("whee", 20)
// and these should cover all the externalized string cases
// fills in id if non-NULL. a value of -2 indicates it is not an external string
// returns true if we were able to extract the XSTR elements (text_str and maybe id are populated)
bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_len, int *id)
void lcl_ext_localize_sub(const char *in, char *out, size_t max_len, int *id)
{
char text_str[PARSE_BUF_SIZE]="";
int str_id;
size_t str_len;
Assert(in);
Assert(out);
// NOTE: "Token too long" warnings are disabled when Lcl_unexpected_tstring_check is active,
// because in such cases we actually anticipate that the length might be exceeded.
// default (non-external string) value
if (id != NULL) {
*id = -2;
@@ -649,7 +644,7 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
// if the string is < 9 chars, it can't be an XSTR("",) tag, so just copy it
if (str_len < 9) {
if (str_len > max_len && !Lcl_unexpected_tstring_check)
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", in, str_len, max_len);
strncpy(out, in, max_len);
@@ -657,13 +652,13 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
if (id != NULL)
*id = -2;
return false;
return;
}
// otherwise, check to see if it's an XSTR() tag
if (strnicmp(in, "XSTR", 4) != 0) {
// NOT an XSTR() tag
if (str_len > max_len && !Lcl_unexpected_tstring_check)
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", in, str_len, max_len);
strncpy(out, in, max_len);
@@ -671,12 +666,12 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
if (id != NULL)
*id = -2;
return false;
return;
}
// at this point we _know_ its an XSTR() tag, so split off the strings and id sections
if (!lcl_ext_get_text(in, text_str)) {
if (str_len > max_len && !Lcl_unexpected_tstring_check)
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", in, str_len, max_len);
strncpy(out, in, max_len);
@@ -684,10 +679,10 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
if (id != NULL)
*id = -1;
return false;
return;
}
if (!lcl_ext_get_id(in, &str_id)) {
if (str_len > max_len && !Lcl_unexpected_tstring_check)
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", in, str_len, max_len);
strncpy(out, in, max_len);
@@ -695,12 +690,12 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
if (id != NULL)
*id = -1;
return false;
return;
}
// if the localization file is not open, or there's no entry, return the original string
if ( !Xstr_inited || (str_id < 0) ) {
if ( strlen(text_str) > max_len && !Lcl_unexpected_tstring_check )
// if the localization file is not open, or we're running in the default language, return the original string
if ( !Xstr_inited || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
if ( strlen(text_str) > max_len )
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", text_str, strlen(text_str), max_len);
strncpy(out, text_str, max_len);
@@ -708,20 +703,20 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
if (id != NULL)
*id = str_id;
return true;
return;
}
// get the string if it exists
if (Lcl_ext_str.find(str_id) != Lcl_ext_str.end()) {
// copy to the outgoing string
if ( strlen(Lcl_ext_str[str_id]) > max_len && !Lcl_unexpected_tstring_check )
if ( strlen(Lcl_ext_str[str_id]) > max_len )
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", Lcl_ext_str[str_id], strlen(Lcl_ext_str[str_id]), max_len);
strncpy(out, Lcl_ext_str[str_id], max_len);
}
// otherwise use what we have - probably should Int3() or assert here
else {
if ( strlen(text_str) > max_len && !Lcl_unexpected_tstring_check )
if ( strlen(text_str) > max_len )
error_display(0, "Token too long: [%s]. Length = " SIZE_T_ARG ". Max is " SIZE_T_ARG ".\n", text_str, strlen(text_str), max_len);
strncpy(out, text_str, max_len);
@@ -731,13 +726,12 @@ bool lcl_ext_localize_sub(const char *in, char *text_str, char *out, size_t max_
if (id != NULL) {
*id = str_id;
}
return true;
}
// ditto for SCP_string
bool lcl_ext_localize_sub(const SCP_string &in, SCP_string &text_str, SCP_string &out, int *id)
void lcl_ext_localize_sub(const SCP_string &in, SCP_string &out, int *id)
{
SCP_string text_str = "";
int str_id;
// default (non-external string) value
@@ -752,7 +746,7 @@ bool lcl_ext_localize_sub(const SCP_string &in, SCP_string &text_str, SCP_string
if (id != NULL)
*id = -2;
return false;
return;
}
// otherwise, check to see if it's an XSTR() tag
@@ -763,7 +757,7 @@ bool lcl_ext_localize_sub(const SCP_string &in, SCP_string &text_str, SCP_string
if (id != NULL)
*id = -2;
return false;
return;
}
// at this point we _know_ its an XSTR() tag, so split off the strings and id sections
@@ -773,7 +767,7 @@ bool lcl_ext_localize_sub(const SCP_string &in, SCP_string &text_str, SCP_string
if (id != NULL)
*id = -1;
return false;
return;
}
if (!lcl_ext_get_id(in, &str_id)) {
out = in;
@@ -781,17 +775,17 @@ bool lcl_ext_localize_sub(const SCP_string &in, SCP_string &text_str, SCP_string
if (id != NULL)
*id = -1;
return false;
return;
}
// if the localization file is not open, or there's no entry, return the original string
if ( !Xstr_inited || (str_id < 0) ) {
// if the localization file is not open, or we're running in the default language, return the original string
if ( !Xstr_inited || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
out = text_str;
if (id != NULL)
*id = str_id;
return true;
return;
}
// get the string if it exists
@@ -808,43 +802,15 @@ bool lcl_ext_localize_sub(const SCP_string &in, SCP_string &text_str, SCP_string
if (id != NULL){
*id = str_id;
}
return true;
}
// Goober5000 - wrapper for lcl_ext_localize_sub; used because lcl_replace_stuff has to
// be called *after* the translation is done, and the original function returned in so
// many places that it would be messy to call lcl_replace_stuff everywhere
// Addendum: Now, of course, it provides a handy way to encapsulate the unexpected tstring check.
void lcl_ext_localize(const char *in, char *out, size_t max_len, int *id)
{
// buffer for the untranslated string inside the XSTR tag
char text_str[PARSE_BUF_SIZE] = "";
// if we're doing this extra check, then we have to compare the untranslated string with the default language string and see if they're different
if (Lcl_unexpected_tstring_check)
{
int saved_language = Lcl_current_lang;
Lcl_current_lang = FS2_OPEN_DEFAULT_LANGUAGE;
bool extracted = lcl_ext_localize_sub(in, text_str, out, max_len, id);
// the untranslated and default-translated strings should always be identical, so if they're different, it might mean we have some data from a different mod
if (extracted && strcmp(text_str, out) != 0)
*Lcl_unexpected_tstring_check = true;
// at this point, we go back to our usual language and do the translation for real
if (saved_language != Lcl_current_lang)
{
Lcl_current_lang = saved_language;
lcl_ext_localize_sub(in, text_str, out, max_len, id);
}
}
// most of the time we're not going to do the check, so localize as normal
else
{
// do XSTR translation
lcl_ext_localize_sub(in, text_str, out, max_len, id);
}
// do XSTR translation
lcl_ext_localize_sub(in, out, max_len, id);
// do translation of $callsign, $rank, etc.
lcl_replace_stuff(out, max_len);
@@ -853,33 +819,8 @@ void lcl_ext_localize(const char *in, char *out, size_t max_len, int *id)
// ditto for SCP_string
void lcl_ext_localize(const SCP_string &in, SCP_string &out, int *id)
{
// buffer for the untranslated string inside the XSTR tag
SCP_string text_str = "";
// if we're doing this extra check, then we have to compare the untranslated string with the default language string and see if they're different
if (Lcl_unexpected_tstring_check)
{
int saved_language = Lcl_current_lang;
Lcl_current_lang = FS2_OPEN_DEFAULT_LANGUAGE;
bool extracted = lcl_ext_localize_sub(in, text_str, out, id);
// the untranslated and default-translated strings should always be identical, so if they're different, it might mean we have some data from a different mod
if (extracted && text_str != out)
*Lcl_unexpected_tstring_check = true;
// at this point, we go back to our usual language and do the translation for real
if (saved_language != Lcl_current_lang)
{
Lcl_current_lang = saved_language;
lcl_ext_localize_sub(in, text_str, out, id);
}
}
// most of the time we're not going to do the check, so localize as normal
else
{
// do XSTR translation
lcl_ext_localize_sub(in, text_str, out, id);
}
// do XSTR translation
lcl_ext_localize_sub(in, out, id);
// do translation of $callsign, $rank, etc.
lcl_replace_stuff(out);
+2 -5
View File
@@ -61,9 +61,6 @@ extern int Lcl_english;
// The currently active language. Index into Lcl_languages.
extern int Lcl_current_lang;
// special check for misplaced mod data (see Mantis #2942)
extern bool *Lcl_unexpected_tstring_check;
// ------------------------------------------------------------------------------------------------------------
// LOCALIZE FUNCTIONS
@@ -113,8 +110,8 @@ void lcl_fred_replace_stuff(SCP_string &text);
// XSTR("whee", 20)
// and these should cover all the externalized string cases
// fills in id if non-NULL. a value of -2 indicates it is not an external string
void lcl_ext_localize(const char *in, char *out, size_t max_len, int *id = nullptr);
void lcl_ext_localize(const SCP_string &in, SCP_string &out, int *id = nullptr);
void lcl_ext_localize(const char *in, char *out, size_t max_len, int *id = NULL);
void lcl_ext_localize(const SCP_string &in, SCP_string &out, int *id = NULL);
// translate the specified string based upon the current language
const char *XSTR(const char *str, int index);
+8 -2
View File
@@ -541,19 +541,25 @@ inline vec3d& operator-=(vec3d& left, const vec3d& right)
return left;
}
inline vec3d operator*(vec3d& left, float right)
inline vec3d operator*(const vec3d& left, float right)
{
vec3d out;
vm_vec_copy_scale(&out, &left, right);
return out;
}
inline vec3d operator*(float left, const vec3d& right)
{
vec3d out;
vm_vec_copy_scale(&out, &right, left);
return out;
}
inline vec3d& operator*=(vec3d& left, float right)
{
vm_vec_scale(&left, right);
return left;
}
inline vec3d operator/(vec3d& left, float right)
inline vec3d operator/(const vec3d& left, float right)
{
vec3d out;
vm_vec_copy_scale(&out, &left, 1.0f / right);
+2 -21
View File
@@ -450,7 +450,6 @@ int build_standalone_mission_list_do_frame()
int font_height = gr_get_font_height();
char filename[MAX_FILENAME_LEN];
char str[256];
bool lcl_weirdness = false;
// When no standalone missions in data directory
if (Num_standalone_missions == 0) {
@@ -474,16 +473,8 @@ int build_standalone_mission_list_do_frame()
// tack on an extension
strcat_s(filename, FS_MISSION_FILE_EXT);
// activate tstrings check
Lcl_unexpected_tstring_check = &lcl_weirdness;
// check if we can list the mission, if loading basic info didn't return an error code, and if we didn't find an unexpected XSTR mismatch
bool condition = !mission_is_ignored(filename) && !get_mission_info(filename) && !lcl_weirdness;
// deactivate tstrings check
Lcl_unexpected_tstring_check = nullptr;
if (condition) {
// check if we can list the mission and if loading basic info didn't return an error code
if (!mission_is_ignored(filename) && !get_mission_info(filename)) {
Standalone_mission_names[Num_standalone_missions_with_info] = vm_strdup(The_mission.name);
Standalone_mission_flags[Num_standalone_missions_with_info] = The_mission.game_type;
int y = Num_lines * (font_height + 2);
@@ -1108,17 +1099,7 @@ void sim_room_init()
memset(wild_card, 0, 256);
strcpy_s(wild_card, NOX("*"));
strcat_s(wild_card, FS_MISSION_FILE_EXT);
#ifndef NDEBUG
// Activate the check while we fill the mission list so that we don't potentially end up with dozens of string length warnings.
// We don't actually remove mismatched missions from the list here; that will happen in build_standalone_mission_list_do_frame().
bool dummy_buffer;
Lcl_unexpected_tstring_check = &dummy_buffer;
#endif
Num_standalone_missions = cf_get_file_list(MAX_MISSIONS, Mission_filenames, CF_TYPE_MISSIONS, wild_card, CF_SORT_NAME);
#ifndef NDEBUG
Lcl_unexpected_tstring_check = nullptr;
#endif
// set up slider with 0 items to start
Sim_room_slider.create(&Ui_window, Sim_room_slider_coords[gr_screen.res][X_COORD], Sim_room_slider_coords[gr_screen.res][Y_COORD], Sim_room_slider_coords[gr_screen.res][W_COORD], Sim_room_slider_coords[gr_screen.res][H_COORD], 0, Sim_room_slider_filename[gr_screen.res], &sim_room_scroll_screen_up, &sim_room_scroll_screen_down, &sim_room_scroll_capture);
+18 -52
View File
@@ -569,88 +569,63 @@ int hotkey_build_team_listing(int enemy_team_mask, int y, bool list_enemies)
const char *str = NULL;
int i, j, s, z, start, team_mask;
int font_height = gr_get_font_height();
IFF_hotkey_team hotkey_team;
if (list_enemies)
{
str = XSTR( "Enemy ships", 403);
team_mask = enemy_team_mask;
hotkey_team = IFF_hotkey_team::Hostile;
}
else
{
str = XSTR( "Friendly ships", 402);
team_mask = ~enemy_team_mask;
hotkey_team = IFF_hotkey_team::Friendly;
}
for (i=0; i<MAX_SHIPS; i++)
if (iff_matches_mask(Ships[i].team, team_mask))
break;
if (i >= MAX_SHIPS)
return y;
hotkey_line_add(str, HOTKEY_LINE_HEADING, 0, y);
y += 2;
start = Num_lines;
for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) {
bool add_it;
int shipnum;
// don't process non-ships, or the player ship
if ( (Game_mode & GM_NORMAL) && (so->objnum == OBJ_INDEX(Player_obj)) )
continue;
int shipnum = Objects[so->objnum].instance;
ship *shipp = &Ships[shipnum];
// filter out ships in wings
if ( shipp->wingnum >= 0 )
continue;
shipnum = Objects[so->objnum].instance;
// filter out cargo containers, navbouys, etc, and non-ships
if ( Ship_info[shipp->ship_info_index].class_type < 0 || !(Ship_types[Ship_info[shipp->ship_info_index].class_type].flags[Ship::Type_Info_Flags::Hotkey_on_list]) )
if ( Ship_info[Ships[shipnum].ship_info_index].class_type < 0 || !(Ship_types[Ship_info[Ships[shipnum].ship_info_index].class_type].flags[Ship::Type_Info_Flags::Hotkey_on_list] ))
continue;
// don't process ships invisible to sensors, dying or departing
if ( shipp->flags[Ship::Ship_Flags::Hidden_from_sensors] || shipp->is_dying_or_departing() )
if ( Ships[shipnum].flags[Ship::Ship_Flags::Hidden_from_sensors] || Ships[shipnum].is_dying_or_departing() )
continue;
// if a ship's hotkey is the last hotkey on the list, then maybe make the hotkey -1 if
// we are now in mission. Otherwise, skip this ship
if ( shipp->hotkey == MAX_KEYED_TARGETS ) {
if ( Ships[shipnum].hotkey == MAX_KEYED_TARGETS ) {
if ( !(Game_mode & GM_IN_MISSION) )
continue; // skip to next ship
shipp->hotkey = -1;
Ships[shipnum].hotkey = -1;
}
// check IFF override and team mask
if (Iff_info[shipp->team].hotkey_team == IFF_hotkey_team::Default) {
add_it = iff_matches_mask(shipp->team, team_mask);
} else {
add_it = (Iff_info[shipp->team].hotkey_team == hotkey_team);
}
// add it if the teams match or if the IFF says to
if (add_it) {
hotkey_line_add_sorted(shipp->get_display_string(), HOTKEY_LINE_SHIP, shipnum, start);
// be sure this ship isn't in a wing, and that the teams match
if ( iff_matches_mask(Ships[shipnum].team, team_mask) && (Ships[shipnum].wingnum < 0) ) {
hotkey_line_add_sorted(Ships[shipnum].get_display_string(), HOTKEY_LINE_SHIP, shipnum, start);
}
}
for (i=0; i<Num_wings; i++) {
bool add_it;
// the wing has to be valid
if (Wings[i].current_count && Wings[i].ship_index[Wings[i].special_ship] >= 0) {
ship *shipp = &Ships[Wings[i].ship_index[Wings[i].special_ship]];
// check IFF override and team mask
if (Iff_info[shipp->team].hotkey_team == IFF_hotkey_team::Default) {
add_it = iff_matches_mask(shipp->team, team_mask);
} else {
add_it = (Iff_info[shipp->team].hotkey_team == hotkey_team);
}
} else {
add_it = false;
}
// add it if the teams match or if the IFF says to
if (add_it) {
if (Wings[i].current_count && (Wings[i].ship_index[Wings[i].special_ship] >= 0) && iff_matches_mask(Ships[Wings[i].ship_index[Wings[i].special_ship]].team, team_mask)) {
// special check for the player's wing. If he's in a wing, and the only guy left, don't
// do anything
if ( (Player_ship->wingnum == i) && (Wings[i].current_count == 1) )
@@ -677,21 +652,12 @@ int hotkey_build_team_listing(int enemy_team_mask, int y, bool list_enemies)
if (Wings[i].flags[Ship::Wing_Flags::Expanded]) {
for (j=0; j<Wings[i].current_count; j++) {
s = Wings[i].ship_index[j];
if (!Ships[s].is_dying_or_departing()) {
z = hotkey_line_insert(z + 1, Ships[s].get_display_string(), HOTKEY_LINE_SUBSHIP, s);
}
z = hotkey_line_insert(z + 1, Ships[s].get_display_string(), HOTKEY_LINE_SUBSHIP, s);
}
}
}
}
// see if we actually added any lines
if (start == Num_lines) {
// roll back the heading, then return as if nothing happened
Num_lines--;
return y - 2;
}
for (i=start; i<Num_lines; i++) {
if (Hotkey_lines[i].type == HOTKEY_LINE_SUBSHIP)
y += font_height;
+1 -2
View File
@@ -625,7 +625,6 @@ void parse_msgtbl()
generic_message_filenames.clear();
generic_message_filenames.push_back("none");
generic_message_filenames.push_back("cuevoice");
generic_message_filenames.push_back("cue_voice");
generic_message_filenames.push_back("emptymsg");
generic_message_filenames.push_back("generic");
generic_message_filenames.push_back("msgstart");
@@ -1146,7 +1145,7 @@ void message_calc_anim_start_frame(int time, generic_anim *ani, int reverse)
}
if ( start_frame < 0 ) {
mprintf(("Calculated start frame for animation %s was less than 0, setting to 0.", ani->filename));
Int3();
start_frame=0;
}
+30 -23
View File
@@ -60,7 +60,6 @@
#include "object/waypoint.h"
#include "parse/generic_log.h"
#include "parse/parselo.h"
#include "scripting/hook_api.h"
#include "scripting/scripting.h"
#include "playerman/player.h"
#include "popup/popup.h"
@@ -407,11 +406,6 @@ void convertFSMtoFS2();
MONITOR(NumShipArrivals)
MONITOR(NumShipDepartures)
const std::shared_ptr<scripting::Hook> OnDepartureStartedHook = scripting::Hook::Factory(
"On Departure Started", "Called when a ship starts the departure process.",
{
{"Ship", "ship", "The ship that has began the depture process."},
});
// Goober5000
void parse_custom_bitmap(const char *expected_string_640, const char *expected_string_1024, char *string_field_640, char *string_field_1024)
@@ -2030,7 +2024,29 @@ int parse_create_object_sub(p_object *p_objp)
shipp->base_texture_anim_frametime = game_get_overall_frametime();
// handle the replacement textures
shipp->apply_replacement_textures(p_objp->replacement_textures);
if (!p_objp->replacement_textures.empty())
{
shipp->ship_replacement_textures = (int *) vm_malloc( MAX_REPLACEMENT_TEXTURES * sizeof(int));
for (i = 0; i < MAX_REPLACEMENT_TEXTURES; i++)
shipp->ship_replacement_textures[i] = -1;
}
// now fill them in
for (SCP_vector<texture_replace>::iterator tr = p_objp->replacement_textures.begin(); tr != p_objp->replacement_textures.end(); ++tr)
{
pm = model_get(sip->model_num);
// look for textures
for (j = 0; j < pm->n_textures; j++)
{
texture_map *tmap = &pm->maps[j];
int tnum = tmap->FindTexture(tr->old_texture);
if(tnum > -1)
shipp->ship_replacement_textures[j * TM_NUM_TYPES + tnum] = tr->new_texture_id;
}
}
// Copy across the alt classes (if any) for FRED
if (Fred_running) {
@@ -5995,18 +6011,15 @@ void parse_init(bool basic)
{
reset_parse();
// if we just want basic info then we don't need some of this initialization
if (!basic)
{
for (int i = 0; i < MAX_CARGO; i++)
Cargo_names[i] = Cargo_names_buf[i]; // make a pointer array for compatibility
for (int i = 0; i < MAX_CARGO; i++)
Cargo_names[i] = Cargo_names_buf[i]; // make a pointer array for compatibility
Total_goal_target_names = 0;
Total_goal_target_names = 0;
// if we are just wanting basic info then we shouldn't need sexps
// (prevents memory fragmentation with the now dynamic Sexp_nodes[])
// if we are just wanting basic info then we shouldn't need sexps
// (prevents memory fragmentation with the now dynamic Sexp_nodes[])
if ( !basic )
init_sexp();
}
}
// main parse routine for parsing a mission. The default parameter flags tells us which information
@@ -6630,8 +6643,7 @@ int mission_set_arrival_location(int anchor, int location, int dist, int objnum,
// if we get an error, just let the ship arrive(?)
if ( ai_acquire_emerge_path(&Objects[objnum], anchor_objnum, path_mask, &pos, &fvec) == -1 ) {
// get MWA or AL -- not sure what to do here when we cannot acquire a path
mprintf(("Unable to acquire arrival path on anchor ship %s\n", Ships[shipnum].ship_name));
Int3(); // get MWA or AL -- not sure what to do here when we cannot acquire a path
return -1;
}
Objects[objnum].pos = pos;
@@ -7131,11 +7143,6 @@ int mission_do_departure(object *objp, bool goal_is_to_warp)
mprintf(("Entered mission_do_departure() for %s\n", shipp->ship_name));
// add scripting hook for 'On Depature Started' --wookieejedi
// hook is placed at the begining of this function to allow the scripter to
// actually have access to the ship's departure decisions before they are all executed
OnDepartureStartedHook->run(scripting::hook_param_list(scripting::hook_param("Ship", 'o', objp)));
// abort rearm, because if we entered this function we're either going to depart via hyperspace, depart via bay,
// or revert to our default behavior
ai_abort_rearm_request(objp);
+1 -1
View File
@@ -1992,7 +1992,7 @@ int brief_only_allow_briefing()
return 1;
}
if ( The_mission.flags[Mission::Mission_Flags::Scramble, Mission::Mission_Flags::Red_alert] ) {
if ( The_mission.flags[Mission::Mission_Flags::Scramble] || The_mission.flags[Mission::Mission_Flags::Red_alert] ) {
return 1;
}
+3 -8
View File
@@ -1860,11 +1860,6 @@ bool is_a_weapon_slot_empty()
// a ship must exist in this slot
if (Wss_slots[slot].ship_class >= 0)
{
// if the player can't modify the weapons, then an empty bank is not his fault
auto ss_slot = &Ss_wings[slot / MAX_WING_SLOTS].ss_slots[slot % MAX_WING_SLOTS];
if (ss_slot->status & WING_SLOT_WEAPONS_DISABLED)
continue;
ship_info *sip = &Ship_info[Wss_slots[slot].ship_class];
// check primary banks
@@ -1879,7 +1874,7 @@ bool is_a_weapon_slot_empty()
for (int bank = 0; bank < sip->num_secondary_banks; ++bank)
{
// is the slot empty?
if (Wss_slots[slot].wep_count[MAX_SHIP_PRIMARY_BANKS + bank] <= 0)
if (Wss_slots[slot].wep_count[MAX_SHIP_PRIMARY_BANKS+bank] <= 0)
return true;
}
}
@@ -1958,7 +1953,7 @@ void commit_pressed()
// Goober5000 - check that all weapon slots are filled (Mantis 2715)
// Note: don't check for training, scramble, or red-alert missions
// Note2: don't check missions without briefings either
if (is_a_weapon_slot_empty() && !(The_mission.game_type & MISSION_TYPE_TRAINING) && !The_mission.flags[Mission::Mission_Flags::Scramble, Mission::Mission_Flags::Red_alert, Mission::Mission_Flags::No_briefing])
if (is_a_weapon_slot_empty() && !(The_mission.game_type & MISSION_TYPE_TRAINING) && !The_mission.flags[Mission::Mission_Flags::Scramble] && !The_mission.flags[Mission::Mission_Flags::Red_alert] && !The_mission.flags[Mission::Mission_Flags::No_briefing])
{
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("At least one ship has an empty weapon bank. All weapon banks must have weapons assigned.", 1642), weapon_list.c_str());
return;
@@ -2202,7 +2197,7 @@ void draw_wing_block(int wb_num, int hot_slot, int selected_slot, int class_sele
color_to_draw = &Icon_colors[ICON_FRAME_DISABLED];
// in multiplayer, determine if this it the special case where the slot is disabled, and
// it is also _my_ slot (ie, team captains/hosts have not locked players yet)
// it is also _my_ slot (ie, team capatains/host have not locked players yet)
if((Game_mode & GM_MULTIPLAYER) && multi_ts_disabled_high_slot(slot_index)){
if(icon->model_index == -1)
bitmap_to_draw = icon->icon_bmaps[ICON_FRAME_DISABLED_HIGH];
+1 -1
View File
@@ -371,7 +371,7 @@ typedef struct mp_vert {
} mp_vert;
typedef struct model_path {
char name[MAX_NAME_LEN]; // name of the path. Should be unique
char name[MAX_NAME_LEN]; // name of the subsystem. Probably displayed on HUD
char parent_name[MAX_NAME_LEN]; // parent name of submodel that path is linked to in POF
int parent_submodel;
int nverts;
+1 -21
View File
@@ -2273,15 +2273,7 @@ int read_model_file(polymodel * pm, const char *filename, int n_subsystems, mode
memset( pm->paths, 0, sizeof(model_path) * pm->n_paths );
for (i=0; i<pm->n_paths; i++ ) {
cfread_string_len(pm->paths[i].name, MAX_NAME_LEN-1, fp);
// check for reused path names... not fatal, but maybe problematic
for (j = 0; j < i; j++) {
if (!stricmp(pm->paths[i].name, pm->paths[j].name)) {
Warning(LOCATION, "Path '%s' in model %s has a name that is not unique!", pm->paths[i].name, pm->filename);
}
}
cfread_string_len(pm->paths[i].name , MAX_NAME_LEN-1, fp);
if ( pm->version >= 2002 ) {
// store the sub_model name number of the parent
cfread_string_len(pm->paths[i].parent_name , MAX_NAME_LEN-1, fp);
@@ -3081,8 +3073,6 @@ void model_set_bay_path_nums(polymodel *pm)
pm->ship_bay->arrive_flags = 0; // bitfield, set to 1 when that path number is reserved for an arrival
pm->ship_bay->depart_flags = 0; // bitfield, set to 1 when that path number is reserved for a departure
// sanity part 1
memset(pm->ship_bay->path_indexes, -1, MAX_SHIP_BAY_PATHS * sizeof(int));
// iterate through the paths that exist in the polymodel, searching for $bayN pathnames
bool too_many_paths = false;
@@ -3118,16 +3108,6 @@ void model_set_bay_path_nums(polymodel *pm)
{
Warning(LOCATION, "Model '%s' has too many bay paths - max is %d", pm->filename, MAX_SHIP_BAY_PATHS);
}
// sanity part 2
for (i = 0; i < pm->ship_bay->num_paths; i++)
{
if (pm->ship_bay->path_indexes[i] < 0)
{
Warning(LOCATION, "Model '%s' does not have a '$bay%.2d' path specified! A total of %d bay paths were counted. Either there is a gap in the path sequence, or a path has a duplicate name.", pm->filename, i + 1, pm->ship_bay->num_paths);
pm->ship_bay->path_indexes[i] = 0; // avoid crashes
}
}
}
// Get "parent" submodel for live debris submodel
+48 -25
View File
@@ -9,9 +9,12 @@
#include "model/modelrender.h"
#include "globalincs/alphacolors.h"
#include "asteroid/asteroid.h"
#include "cmdline/cmdline.h"
#include "gamesequence/gamesequence.h"
#include "graphics/debug.h"
#include "graphics/light.h"
#include "graphics/matrix.h"
#include "graphics/shadows.h"
@@ -1809,7 +1812,6 @@ void model_render_glowpoint(int point_num, vec3d *pos, matrix *orient, glow_poin
vec3d cone_dir_rot;
vec3d cone_dir_model;
vec3d cone_dir_world;
vec3d cone_dir_screen;
vec3d unused;
if ( gpo->rotating ) {
@@ -1820,9 +1822,7 @@ void model_render_glowpoint(int point_num, vec3d *pos, matrix *orient, glow_poin
find_submodel_instance_point_normal(&unused, &cone_dir_model, shipp->model_instance_num, bank->submodel_parent, &unused, &cone_dir_rot);
vm_vec_unrotate(&cone_dir_world, &cone_dir_model, orient);
vm_vec_rotate(&cone_dir_screen, &cone_dir_world, &Eye_matrix);
cone_dir_screen.xyz.z = -cone_dir_screen.xyz.z;
light_add_cone(&world_pnt, &cone_dir_screen, gpo->cone_angle, gpo->cone_inner_angle, gpo->dualcone, 1.0f, w * gpo->radius_multi, 1, pulse * gpo->light_color.xyz.x + (1.0f-pulse) * gpo->light_mix_color.xyz.x, pulse * gpo->light_color.xyz.y + (1.0f-pulse) * gpo->light_mix_color.xyz.y, pulse * gpo->light_color.xyz.z + (1.0f-pulse) * gpo->light_mix_color.xyz.z, -1);
light_add_cone(&world_pnt, &cone_dir_world, gpo->cone_angle, gpo->cone_inner_angle, gpo->dualcone, 1.0f, w * gpo->radius_multi, 1, pulse * gpo->light_color.xyz.x + (1.0f-pulse) * gpo->light_mix_color.xyz.x, pulse * gpo->light_color.xyz.y + (1.0f-pulse) * gpo->light_mix_color.xyz.y, pulse * gpo->light_color.xyz.z + (1.0f-pulse) * gpo->light_mix_color.xyz.z, -1);
} else {
light_add_point(&world_pnt, 1.0f, w * gpo->radius_multi, 1, pulse * gpo->light_color.xyz.x + (1.0f-pulse) * gpo->light_mix_color.xyz.x, pulse * gpo->light_color.xyz.y + (1.0f-pulse) * gpo->light_mix_color.xyz.y, pulse * gpo->light_color.xyz.z + (1.0f-pulse) * gpo->light_mix_color.xyz.z, -1);
}
@@ -2012,7 +2012,6 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
int n_q = 0;
size_t k;
vec3d norm, norm2, fvec, pnt, npnt;
thruster_bank *bank = NULL;
vertex p;
bool do_render = false;
@@ -2031,7 +2030,7 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
// get an initial count to figure out how man geo batchers we need allocated
for (i = 0; i < pm->n_thrusters; i++ ) {
bank = &pm->thrusters[i];
const auto bank = &pm->thrusters[i];
n_q += bank->num_points;
}
@@ -2073,10 +2072,10 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
vec3d submodel_static_offset; // The associated submodel's static offset in the ship's frame of reference
bool submodel_rotation = false;
bank = &pm->thrusters[i];
const auto bank = &pm->thrusters[i];
// don't draw this thruster if the engine is destroyed or just not on
if ( !model_should_render_engine_glow(objnum, bank->obj_num) )
if (!model_should_render_engine_glow(objnum, bank->obj_num))
continue;
// If bank is attached to a submodel, prepare to account for rotations
@@ -2085,18 +2084,21 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
// set the the necessary submodel instance info needed here. The second
// condition is thus a hack to disable the feature while in the lab, and
// can be removed if the lab is re-structured accordingly. -zookeeper
if ( bank->submodel_num > -1 && pm->submodel[bank->submodel_num].can_move && (gameseq_get_state_idx(GS_STATE_LAB) == -1) ) {
model_find_submodel_offset(&submodel_static_offset, Ship_info[shipp->ship_info_index].model_num, bank->submodel_num);
if (bank->submodel_num > -1 && pm->submodel[bank->submodel_num].can_move &&
(gameseq_get_state_idx(GS_STATE_LAB) == -1)) {
model_find_submodel_offset(&submodel_static_offset,
Ship_info[shipp->ship_info_index].model_num,
bank->submodel_num);
submodel_rotation = true;
}
for (j = 0; j < bank->num_points; j++) {
Assert( bank->points != NULL );
Assert(bank->points != NULL);
float d, D;
vec3d tempv;
glow_point *gpt = &bank->points[j];
glow_point* gpt = &bank->points[j];
vec3d loc_offset = gpt->pnt;
vec3d loc_norm = gpt->norm;
vec3d world_pnt;
@@ -2147,21 +2149,21 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
D = d = vm_vec_dot(&tempv, &world_norm);
// ADAM: Min throttle draws rad*MIN_SCALE, max uses max.
#define NOISE_SCALE 0.5f
#define MIN_SCALE 3.4f
#define MAX_SCALE 4.7f
const auto NOISE_SCALE = 0.5f;
const auto MIN_SCALE = 3.4f;
const auto MAX_SCALE = 4.7f;
float magnitude;
vec3d scale_vec = { { { 1.0f, 0.0f, 0.0f } } };
vec3d scale_vec = {{{1.0f, 0.0f, 0.0f}}};
// normalize banks, in case of incredibly big normals
if ( !IS_VEC_NULL_SQ_SAFE(&world_norm) )
if (!IS_VEC_NULL_SQ_SAFE(&world_norm))
vm_vec_copy_normalize(&scale_vec, &world_norm);
// adjust for thrust
(scale_vec.xyz.x *= thruster_info.length.xyz.x) -= 0.1f;
(scale_vec.xyz.y *= thruster_info.length.xyz.y) -= 0.1f;
(scale_vec.xyz.z *= thruster_info.length.xyz.z) -= 0.1f;
(scale_vec.xyz.z *= thruster_info.length.xyz.z) -= 0.1f;
// get magnitude, which we will use as the scaling reference
magnitude = vm_vec_normalize(&scale_vec);
@@ -2289,9 +2291,9 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
// Where the particles emit from
pe.pos = npnt;
// Initial velocity of all the particles
pe.vel = Objects[shipp->objnum].phys_info.desired_vel;
pe.vel = Objects[shipp->objnum].phys_info.desired_vel;
pe.min_vel = v * 0.75f;
pe.max_vel = v * 1.25f;
pe.max_vel = v * 1.25f;
// What normal the particle emit around
pe.normal = orient->vec.fvec;
vm_vec_negate(&pe.normal);
@@ -2300,16 +2302,37 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
pe.num_low = tp->n_low;
// Highest number of particles to create
pe.num_high = tp->n_high;
pe.min_rad = gpt->radius * tp->min_rad;
pe.max_rad = gpt->radius * tp->max_rad;
pe.min_rad = gpt->radius * tp->min_rad;
pe.max_rad = gpt->radius * tp->max_rad;
// How close they stick to that normal 0=on normal, 1=180, 2=360 degree
pe.normal_variance = tp->variance;
pe.min_life = 0.0f;
pe.max_life = 1.0f;
pe.min_life = 0.0f;
pe.max_life = 1.0f;
particle::emit( &pe, particle::PARTICLE_BITMAP, tp->thruster_bitmap.first_frame);
particle::emit(&pe, particle::PARTICLE_BITMAP, tp->thruster_bitmap.first_frame);
}
}
// vec3d debug_pnt = world_pnt + (10.f * magnitude) * world_norm;
// graphics::debug::line_3d(&world_pnt, &debug_pnt, &Color_red);
//
// graphics::debug::text_3d(&debug_pnt, &Color_white, std::to_string(magnitude));
const auto lightRadius = std::max(1.0f, gpt->radius) * 250.f;
const auto outerAngle = cosf(50.0f / 180.0f * PI);
const auto innerAngle = cosf(25.0f / 180.0f * PI);
light_add_cone(&world_pnt,
&world_norm,
outerAngle,
innerAngle,
false,
lightRadius,
lightRadius,
magnitude,
0.1f,
0.1f,
0.9f,
-1);
}
}
}
+2 -9
View File
@@ -4449,10 +4449,9 @@ void multi_create_list_load_missions()
}
for (idx = 0; idx < file_count; idx++) {
int flags, max_players;
int flags,max_players;
char *filename;
uint m_respawn;
bool lcl_weirdness = false;
fname = file_list[idx];
@@ -4463,16 +4462,10 @@ void multi_create_list_load_missions()
std_gen_set_text(filename, 2);
}
// activate tstrings check
Lcl_unexpected_tstring_check = &lcl_weirdness;
flags = mission_parse_is_multi(filename, mission_name);
// deactivate tstrings check
Lcl_unexpected_tstring_check = nullptr;
// if the mission is a multiplayer mission, and we can list it, then add it to the mission list
if (flags && !mission_is_ignored(filename) && !lcl_weirdness) {
if (flags && !mission_is_ignored(filename)) {
max_players = mission_parse_get_multi_mission_info( filename );
m_respawn = The_mission.num_respawns;
+53 -53
View File
@@ -244,7 +244,7 @@ int get_line_num()
while (p < stoploc)
{
if (*p == '\0')
Warning(LOCATION, "Unexpected end-of-file while looking for error line!");
Assert(0);
if ( !incomment && (*p == COMMENT_CHAR) )
incomment = 1;
@@ -314,6 +314,8 @@ void advance_to_eoln(const char *more_terminators)
terminators[1] = 0;
if (more_terminators != NULL)
strcat_s(terminators, more_terminators);
else
terminators[1] = 0;
while (strchr(terminators, *Mp) == NULL)
Mp++;
@@ -322,7 +324,7 @@ void advance_to_eoln(const char *more_terminators)
// Advance Mp to the next white space (ignoring white space inside of " marks)
void advance_to_next_white()
{
bool in_quotes = false;
int in_quotes = 0;
while ((*Mp != EOLN) && (*Mp != '\0')) {
if (*Mp == '\"')
@@ -763,6 +765,8 @@ void copy_to_eoln(char *outstr, const char *more_terminators, const char *instr,
terminators[1] = 0;
if (more_terminators != NULL)
strcat_s(terminators, more_terminators);
else
terminators[1] = 0;
while (((ch = *instr++) != 0) && (strchr(terminators, ch) == NULL) && (count < max)) {
*outstr++ = ch;
@@ -787,6 +791,8 @@ void copy_to_eoln(SCP_string &outstr, const char *more_terminators, const char *
terminators[1] = 0;
if (more_terminators != NULL)
strcat_s(terminators, more_terminators);
else
terminators[1] = 0;
outstr = "";
while (((ch = *instr++) != 0) && (strchr(terminators, ch) == NULL)) {
@@ -796,10 +802,10 @@ void copy_to_eoln(SCP_string &outstr, const char *more_terminators, const char *
// Copy characters from instr to outstr until next white space is found, or until max
// characters have been copied (including terminator).
void copy_to_next_white(char *outstr, const char *instr, int max)
void copy_to_next_white(char *outstr, char *instr, int max)
{
int count = 0;
bool in_quotes = false;
int in_quotes = 0;
char ch;
while (((ch = *instr++)>0) && (ch != EOLN) && (ch != '\0') && (count < max)) {
@@ -825,9 +831,9 @@ void copy_to_next_white(char *outstr, const char *instr, int max)
}
// Ditto for SCP_string.
void copy_to_next_white(SCP_string &outstr, const char *instr)
void copy_to_next_white(SCP_string &outstr, char *instr)
{
bool in_quotes = false;
int in_quotes = 0;
char ch;
outstr = "";
@@ -848,10 +854,10 @@ void copy_to_next_white(SCP_string &outstr, const char *instr)
}
//Returns a null-terminated character string allocated with vm_malloc() with the data
char* alloc_text_until(const char* instr, const char* endstr)
char* alloc_text_until(char* instr, char* endstr)
{
Assert(instr && endstr);
auto foundstr = stristr(instr, endstr);
char *foundstr = stristr(instr, endstr);
if(foundstr == NULL)
{
@@ -882,11 +888,12 @@ char* alloc_text_until(const char* instr, const char* endstr)
// Copy text until a certain string is matched.
// For example, this is used to copy mission notes, scanning until $END NOTES:
// is found.
void copy_text_until(char *outstr, const char *instr, const char *endstr, int max_chars)
void copy_text_until(char *outstr, char *instr, const char *endstr, int max_chars)
{
char *foundstr;
Assert(outstr && instr && endstr);
auto foundstr = stristr(instr, endstr);
foundstr = stristr(instr, endstr);
if (foundstr == NULL) {
nprintf(("Error", "Error. Looking for [%s], but never found it.\n", endstr));
@@ -908,11 +915,12 @@ void copy_text_until(char *outstr, const char *instr, const char *endstr, int ma
}
// Ditto for SCP_string.
void copy_text_until(SCP_string &outstr, const char *instr, const char *endstr)
void copy_text_until(SCP_string &outstr, char *instr, const char *endstr)
{
char *foundstr;
Assert(instr && endstr);
auto foundstr = stristr(instr, endstr);
foundstr = stristr(instr, endstr);
if (foundstr == NULL) {
nprintf(("Error", "Error. Looking for [%s], but never found it.\n", endstr));
@@ -1359,7 +1367,7 @@ void stuff_string_line(SCP_string &outstr)
// Exactly the same as stuff string only Malloc's the buffer.
// Supports various FreeSpace primitive types. If 'len' is supplied, it will override
// the default string length if using the F_NAME case.
char *stuff_and_malloc_string(int type, const char *terminators)
char *stuff_and_malloc_string(int type, char *terminators)
{
SCP_string tmp_result;
@@ -1372,7 +1380,7 @@ char *stuff_and_malloc_string(int type, const char *terminators)
return vm_strdup(tmp_result.c_str());
}
void stuff_malloc_string(char **dest, int type, const char *terminators)
void stuff_malloc_string(char **dest, int type, char *terminators)
{
Assert(dest != NULL); //wtf?
@@ -1389,62 +1397,53 @@ void stuff_malloc_string(char **dest, int type, const char *terminators)
}
// After reading a multitext string, you can call this function to convert any newlines into
// spaces, so it's a one paragraph string (i.e. as in MS-Word).
// spaces, so it's a one paragraph string (I.e. as in MS-Word).
//
void compact_multitext_string(char *str)
{
auto p_dest = str;
auto p_src = str;
size_t i;
size_t len = strlen(str);
size_t num_cr = 0;
while (*p_src)
for (i=0; i<len; i++)
{
char ch = *p_src;
p_src++;
// skip CR
// convert LF to space
// copy characters backwards if any CRs previously encountered
if (ch != '\r')
{
if (ch == '\n')
*p_dest = ' ';
else if (p_dest != p_src)
*p_dest = *p_src;
p_dest++;
}
if (str[i] == '\r')
num_cr++;
else if (str[i] == '\n')
str[i-num_cr] = ' ';
else if (num_cr > 0)
str[i-num_cr] = str[i];
}
if (p_dest != p_src)
*p_dest = 0;
if (num_cr > 0)
str[len-num_cr] = 0;
}
// ditto for SCP_string
void compact_multitext_string(SCP_string &str)
{
auto p_dest = str.begin();
auto p_src = str.begin();
size_t i;
size_t len = str.length();
size_t num_cr = 0;
while (p_src != str.end())
for (i=0; i<len; i++)
{
char ch = *p_src;
p_src++;
// skip CR
// convert LF to space
// copy characters backwards if any CRs previously encountered
if (ch != '\r')
{
if (ch == '\n')
*p_dest = ' ';
else if (p_dest != p_src)
*p_dest = *p_src;
p_dest++;
}
if (str[i] == '\r')
num_cr++;
else if (str[i] == '\n')
str[i-num_cr] = ' ';
else if (num_cr > 0)
str[i-num_cr] = str[i];
}
if (p_dest != p_src)
str.erase(p_dest);
if (num_cr > 0)
str.resize(len-num_cr);
}
// Converts a character from Windows-1252 to CP437.
@@ -1988,12 +1987,13 @@ void strip_comments(char *line, bool &in_quote, bool &in_multiline_comment_a, bo
}
}
int parse_get_line(char *lineout, int max_line_len, const char *start, int max_size, const char *cur)
int parse_get_line(char *lineout, int max_line_len, char *start, int max_size, char *cur)
{
char * t = lineout;
int i, num_chars_read=0;
char c;
for ( i = 0; i < max_line_len-1; i++ ) {
do {
if ( (cur - start) >= max_size ) {
@@ -2019,7 +2019,7 @@ int parse_get_line(char *lineout, int max_line_len, const char *start, int max_s
// Read mission text, stripping comments.
// When a comment is found, it is removed. If an entire line
// consisted of a comment, a blank line is left in the input file.
// Goober5000 - added ability to read somewhere other than Parse_text
// Goober5000 - added ability to read somewhere other than Mission_text
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
{
// copy the filename
@@ -2134,7 +2134,7 @@ void allocate_parse_text(size_t size)
Parse_text_raw = (char *) vm_malloc(sizeof(char) * size, memory::quiet_alloc);
if ( (Parse_text == nullptr) || (Parse_text_raw == nullptr) ) {
Error(LOCATION, "Unable to allocate enough memory for Parse_text! Aborting...\n");
Error(LOCATION, "Unable to allocate enough memory for Mission_text! Aborting...\n");
}
memset( Parse_text, 0, sizeof(char) * size );
@@ -2170,7 +2170,7 @@ void read_raw_file_text(const char *filename, int mode, char *raw_text)
// that if we have control over the raw_text pointer which is only the case if it's null.
auto can_reallocate = raw_text == nullptr;
if (raw_text == nullptr) {
// allocate, or reallocate, memory for Parse_text and Parse_text_raw based on size we need now
// allocate, or reallocate, memory for Mission_text and Mission_text_raw based on size we need now
allocate_parse_text((size_t) (file_len + 1));
// NOTE: this always has to be done *after* the allocate_mission_text() call!!
raw_text = Parse_text_raw;
+5 -5
View File
@@ -116,7 +116,7 @@ extern int required_string_one_of(int arg_count, ...);
// stuff
extern void copy_to_eoln(char *outstr, const char *more_terminators, const char *instr, int max);
extern void copy_text_until(char *outstr, const char *instr, const char *endstr, int max_chars);
extern void copy_text_until(char *outstr, char *instr, const char *endstr, int max_chars);
extern void stuff_string_white(char *outstr, int len = 0);
extern void stuff_string_until(char *outstr, const char *endstr, int len = 0);
extern void stuff_string(char *outstr, int type, int len, const char *terminators = NULL);
@@ -124,7 +124,7 @@ extern void stuff_string_line(char *outstr, int len);
// SCP_string stuff
extern void copy_to_eoln(SCP_string &outstr, const char *more_terminators, const char *instr);
extern void copy_text_until(SCP_string &outstr, const char *instr, const char *endstr);
extern void copy_text_until(SCP_string &outstr, char *instr, const char *endstr);
extern void stuff_string_white(SCP_string &outstr);
extern void stuff_string_until(SCP_string &outstr, const char *endstr);
extern void stuff_string(SCP_string &outstr, int type, const char *terminators = NULL);
@@ -136,8 +136,8 @@ extern char* alloc_block(const char* startstr, const char* endstr, int extra_cha
// Exactly the same as stuff string only Malloc's the buffer.
// Supports various FreeSpace primitive types. If 'len' is supplied, it will override
// the default string length if using the F_NAME case.
extern char *stuff_and_malloc_string(int type, const char *terminators = nullptr);
extern void stuff_malloc_string(char **dest, int type, const char *terminators = nullptr);
extern char *stuff_and_malloc_string(int type, char *terminators = NULL);
extern void stuff_malloc_string(char **dest, int type, char *terminators = NULL);
extern void stuff_float(float *f);
extern int stuff_float_optional(float *f, bool raw = false);
extern int stuff_int_optional(int *i, bool raw = false);
@@ -252,7 +252,7 @@ extern void reset_parse(char *text = NULL);
extern void display_parse_diagnostics();
extern void pause_parse();
extern void unpause_parse();
// stop parsing, basically just frees up the memory from Parse_text and Parse_text_raw
// stop parsing, basically just free's up the memory from Mission_text and Mission_text_raw
extern void stop_parse();
// utility
+2 -8
View File
@@ -36,18 +36,12 @@
/**
* Start the frame. Pass non-zero to enable zbuffering
*/
#define g3_start_frame(zbuffer_flag) g3_start_frame_func(zbuffer_flag, __FILE__, __LINE__ )
/**
* Use the g3_start_frame macro instead of calling this directly.
*/
extern void g3_start_frame_func(int zbuffer_flag, const char *filename, int lineno);
extern void g3_start_frame(int zbuffer_flag);
/**
* End the frame
*/
#define g3_end_frame() g3_end_frame_func( __FILE__, __LINE__ )
extern void g3_end_frame_func(const char *filename, int lineno);
extern void g3_end_frame();
/**
* Currently in frame?
+2 -2
View File
@@ -72,7 +72,7 @@ int g3_in_frame()
* Start the frame
* Pass true for zbuffer_flag to turn on zbuffering
*/
void g3_start_frame_func(int zbuffer_flag, const char * /*filename*/, int /*lineno*/)
void g3_start_frame(int zbuffer_flag)
{
float s;
int width, height;
@@ -113,7 +113,7 @@ void g3_start_frame_func(int zbuffer_flag, const char * /*filename*/, int /*lin
/**
* This doesn't do anything, but is here for completeness
*/
void g3_end_frame_func(const char * /*filename*/, int /*lineno*/)
void g3_end_frame()
{
G3_count--;
Assert( G3_count == 0 );
+1 -1
View File
@@ -73,7 +73,7 @@ ADE_FUNC(attacks, l_Team, "team", "Checks the IFF status of another team", "bool
{
int x, y;
ade_get_args(L, "oo", l_Team.Get(&x), l_Team.Get(&y));
if (iff_x_attacks_y(x, y))
if (iff_x_attacks_y(x, y) > 0)
return ADE_RETURN_TRUE;
return ADE_RETURN_FALSE;
+50 -87
View File
@@ -446,7 +446,6 @@ flag_def_list_new<Weapon::Info_Flags> ai_tgt_weapon_flags[] = {
{ "big ship", Weapon::Info_Flags::Big_only, true, false },
{ "child", Weapon::Info_Flags::Child, true, false },
{ "no dumbfire", Weapon::Info_Flags::No_dumbfire, true, false },
{ "no doublefire", Weapon::Info_Flags::No_doublefire, true, false },
{ "thruster", Weapon::Info_Flags::Thruster, true, false },
{ "in tech database", Weapon::Info_Flags::In_tech_database, true, false },
{ "player allowed", Weapon::Info_Flags::Player_allowed, true, false },
@@ -1612,7 +1611,7 @@ ship_info::ship_info()
sup_hull_repair_rate = 0.15f;
sup_shield_repair_rate = 0.20f;
sup_subsys_repair_rate = 0.15f; // The retail default is 0.10, but it actually used the hull rate of 0.15
sup_subsys_repair_rate = 0.15f;
vm_vec_zero(&closeup_pos);
closeup_zoom = 0.5f;
@@ -1820,7 +1819,7 @@ static void parse_ship(const char *filename, bool replace)
}
//Remove @ symbol
//these used to denote weapons that would
//these used to be used to denote weapons that would
//only be parsed in demo builds
if ( fname[0] == '@' ) {
backspace(fname);
@@ -6037,33 +6036,6 @@ const char* ship::get_display_string() {
}
}
void ship::apply_replacement_textures(SCP_vector<texture_replace> &replacements)
{
if (!replacements.empty())
{
ship_replacement_textures = (int *) vm_malloc( MAX_REPLACEMENT_TEXTURES * sizeof(int));
for (auto i = 0; i < MAX_REPLACEMENT_TEXTURES; i++)
ship_replacement_textures[i] = -1;
}
// now fill them in
for (auto tr : replacements)
{
auto pm = model_get(Ship_info[ship_info_index].model_num);
// look for textures
for (auto j = 0; j < pm->n_textures; j++)
{
texture_map *tmap = &pm->maps[j];
int tnum = tmap->FindTexture(tr.old_texture);
if(tnum > -1)
ship_replacement_textures[j * TM_NUM_TYPES + tnum] = tr.new_texture_id;
}
}
}
void ship_weapon::clear()
{
flags.reset();
@@ -6927,16 +6899,9 @@ void ship_render_cockpit(object *objp)
//Deal with the model
model_clear_instance(sip->cockpit_model_num);
uint render_flags = MR_NORMAL;
render_flags |= MR_NO_FOGGING;
if (shipp->flags[Ship::Ship_Flags::Glowmaps_disabled]) {
render_flags |= MR_NO_GLOWMAPS;
}
model_render_params render_info;
render_info.set_detail_level_lock(0);
render_info.set_flags(render_flags);
render_info.set_flags(MR_NO_FOGGING);
render_info.set_replacement_textures(Player_cockpit_textures);
model_render_immediate(&render_info, sip->cockpit_model_num, &eye_ori, &pos);
@@ -11985,21 +11950,6 @@ int ship_fire_secondary( object *obj, int allow_swarm )
goto done_secondary;
}
// Handle the optional disabling of dual fire
// dual fire/doublefire can be disabled for individual weapons, for players, or for AIs
// if any of these apply to the current weapon, unset the dual fire flag on the ship
// then proceed as normal.
// This is only handled at firing time so dualfire isn't lost when cycling through weapons
if (shipp->flags[Ship_Flags::Secondary_dual_fire] &&
( wip->wi_flags[Weapon::Info_Flags::No_doublefire] ||
( The_mission.ai_profile->flags[AI::Profile_Flags::Disable_ai_secondary_doublefire] &&
shipp->objnum != OBJ_INDEX(Player_obj) ) ||
( The_mission.ai_profile->flags[AI::Profile_Flags::Disable_player_secondary_doublefire] &&
shipp->objnum == OBJ_INDEX(Player_obj) ))
) {
shipp->flags.remove(Ship_Flags::Secondary_dual_fire);
}
int start_slot, end_slot;
if ( shipp->flags[Ship_Flags::Secondary_dual_fire] && num_slots > 1) {
@@ -13565,8 +13515,8 @@ float ship_calculate_rearm_duration( object *objp )
//
int ship_do_rearm_frame( object *objp, float frametime )
{
int i, banks_full, primary_banks_full, subsys_type, last_ballistic_idx = -1;
float shield_str, max_shield_str = 0.0f, repair_delta, repair_allocated, max_hull_repair = 0, max_subsys_repair;
int i, banks_full, primary_banks_full, subsys_type, subsys_all_ok, last_ballistic_idx = -1;
float shield_str, max_shield_str = 0.0f, repair_delta, repair_allocated, max_hull_repair, max_subsys_repair;
ship *shipp;
ship_weapon *swp;
ship_info *sip;
@@ -13588,7 +13538,6 @@ int ship_do_rearm_frame( object *objp, float frametime )
}
swp->num_primary_banks = sip->num_primary_banks;
}
// AL 12-30-97: Repair broken warp drive
if ( shipp->flags[Ship_Flags::Warp_broken] ) {
// TODO: maybe do something here like informing player warp is fixed?
@@ -13597,7 +13546,7 @@ int ship_do_rearm_frame( object *objp, float frametime )
shipp->flags.remove(Ship_Flags::Warp_broken);
}
// AL 1-16-98: Replenish countermeasures
// AL 1-16-97: Replenish countermeasures
shipp->cmeasure_count = sip->cmeasure_max;
// Do shield repair here
@@ -13618,36 +13567,53 @@ int ship_do_rearm_frame( object *objp, float frametime )
}
// Repair the ship integrity (subsystems + hull). This works by applying the repair points
// to the subsystems. Ships integrity is stored in objp->hull_strength, so that always is
// to the subsystems. Ships integrity is stored is objp->hull_strength, so that always is
// incremented by repair_allocated
repair_allocated = shipp->ship_max_hull_strength * frametime * sip->sup_hull_repair_rate;
// AL 11-24-97: remove increase to hull integrity
// Comments removed by PhReAk; Note that this is toggled on/off with a mission flag
if (The_mission.flags[Mission::Mission_Flags::Support_repairs_hull])
// AL 11-24-97: remove increase to hull integrity
// Comments removed by PhReAk; Note that this is toggled on/off with a mission flag
//Figure out how much of the ship's hull we can repair
max_hull_repair = shipp->ship_max_hull_strength * (The_mission.support_ships.max_hull_repair_val * 0.01f);
//Don't "reverse-repair" the hull if it's already above the max repair threshold
if (objp->hull_strength > max_hull_repair)
{
//Figure out how much of the ship's hull we can repair
//Don't "reverse-repair" the hull if it's already above the max repair threshold
max_hull_repair = shipp->ship_max_hull_strength * (The_mission.support_ships.max_hull_repair_val * 0.01f);
if (objp->hull_strength < max_hull_repair)
max_hull_repair = objp->hull_strength;
}
if(The_mission.flags[Mission::Mission_Flags::Support_repairs_hull])
{
objp->hull_strength += repair_allocated;
if ( objp->hull_strength > max_hull_repair ) {
objp->hull_strength = max_hull_repair;
}
if ( objp->hull_strength > shipp->ship_max_hull_strength )
{
objp->hull_strength += shipp->ship_max_hull_strength * frametime * sip->sup_hull_repair_rate;
if (objp->hull_strength > max_hull_repair)
objp->hull_strength = max_hull_repair;
objp->hull_strength = shipp->ship_max_hull_strength;
repair_allocated -= ( shipp->ship_max_hull_strength - objp->hull_strength);
}
}
// figure out repairs for subsystems
repair_allocated = shipp->ship_max_hull_strength * frametime * sip->sup_subsys_repair_rate;
if(sip->sup_subsys_repair_rate == 0.0f)
repair_allocated = 0.0f;
else if(sip->sup_hull_repair_rate == 0.0f)
repair_allocated = shipp->ship_max_hull_strength * frametime * sip->sup_subsys_repair_rate;
else if(!(sip->sup_hull_repair_rate == sip->sup_subsys_repair_rate))
repair_allocated = repair_allocated * sip->sup_subsys_repair_rate / sip->sup_hull_repair_rate;
// check the subsystems of the ship.
bool subsys_all_ok = true;
subsys_all_ok = 1;
ssp = GET_FIRST(&shipp->subsys_list);
while ( ssp != END_OF_LIST( &shipp->subsys_list ) ) {
//Figure out how much we *can* repair the current subsystem -C
max_subsys_repair = ssp->max_hits * (The_mission.support_ships.max_subsys_repair_val * 0.01f);
if ( ssp->current_hits < max_subsys_repair && repair_allocated > 0 ) {
subsys_all_ok = false;
subsys_all_ok = 0;
subsys_type = ssp->system_info->type;
if ( objp == Player_obj ) {
@@ -13813,8 +13779,7 @@ int ship_do_rearm_frame( object *objp, float frametime )
if ((aip->rearm_first_ballistic_primary == TRUE) && (i == last_ballistic_idx))
{
if (primary_banks_full != swp->num_primary_banks)
{
if (primary_banks_full != swp->num_primary_banks) {
// Goober5000
gamesnd_id sound_index;
if (gamesnd_game_sound_valid(GameSounds::BALLISTIC_START_LOAD))
@@ -13840,24 +13805,23 @@ int ship_do_rearm_frame( object *objp, float frametime )
aip->rearm_first_ballistic_primary = TRUE;
}
int shields_full = false;
int shields_full = 0;
if ( (objp->flags[Object::Object_Flags::No_shields]) ) {
shields_full = true;
shields_full = 1;
} else {
if ( shield_get_strength(objp) >= max_shield_str )
shields_full = true;
shields_full = 1;
if (sip->sup_shield_repair_rate == 0.0f)
shields_full = true;
shields_full = 1;
}
bool hull_ok = false;
if (!(The_mission.flags[Mission::Mission_Flags::Support_repairs_hull])) {
hull_ok = true;
} else {
if (objp->hull_strength >= max_hull_repair)
hull_ok = true;
if (sip->sup_hull_repair_rate == 0.0f)
hull_ok = true;
int hull_ok = 0;
if(objp->hull_strength >= max_hull_repair)
hull_ok = 1;
if(sip->sup_hull_repair_rate == 0.0f) {
subsys_all_ok = 1;
hull_ok = 1;
}
// return 1 if at end of subsystem list, hull damage at 0, and shields full and all secondary banks full.
@@ -13882,8 +13846,7 @@ int ship_do_rearm_frame( object *objp, float frametime )
}
}
if (objp == Player_obj)
Player_rearm_eta -= frametime;
if (objp == Player_obj) Player_rearm_eta -= frametime;
return 0;
}
-2
View File
@@ -727,8 +727,6 @@ public:
bool has_display_name();
const char* get_display_string();
void apply_replacement_textures(SCP_vector<texture_replace> &replacements);
};
struct ai_target_priority {
-4
View File
@@ -1582,10 +1582,6 @@ void shipfx_queue_render_ship_halves_and_debris(model_draw_list *scene, clip_shi
render_flags |= MR_NO_TEXTURING | MR_NO_LIGHTING;
}
if (shipp->flags[Ship::Ship_Flags::Glowmaps_disabled]) {
render_flags |= MR_NO_GLOWMAPS;
}
for (int i = 0; i < pm->num_debris_objects; i++ ) {
// draw DEBRIS_FREE in test only
if (half_ship->draw_debris[i] == DEBRIS_DRAW) {
-14
View File
@@ -38,7 +38,6 @@
#include "object/objectshield.h"
#include "object/objectsnd.h"
#include "parse/parselo.h"
#include "scripting/hook_api.h"
#include "scripting/scripting.h"
#include "scripting/api/objs/subsystem.h"
#include "playerman/player.h"
@@ -73,12 +72,6 @@ vec3d Original_vec_to_deader;
static bool global_damage = false;
const std::shared_ptr<scripting::Hook> OnPainFlashHook = scripting::Hook::Factory(
"On Pain Flash", "Called when a pain flash is displayed.",
{
{"Pain_Type", "number", "The type of pain flash displayed: shield = 0 and hull = 1."},
});
//WMC - Camera rough draft stuff
/*
camid dead_get_camera()
@@ -2644,7 +2637,6 @@ void ship_hit_pain(float damage, int quadrant)
if (!(Player_obj->flags[Object::Object_Flags::Invulnerable]))
{
int pain_type;
if (Shield_pain_flash_factor != 0.0f && quadrant >= 0)
{
float effect = (Shield_pain_flash_factor * Player_obj->shield_quadrant[quadrant] * Player_obj->n_quadrants) / shield_get_max_strength(Player_obj);
@@ -2653,15 +2645,9 @@ void ship_hit_pain(float damage, int quadrant)
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);
pain_type = 0;
}
else
{
game_flash(damage * Generic_pain_flash_factor / 15.0f, -damage * Generic_pain_flash_factor / 30.0f, -damage * Generic_pain_flash_factor / 30.0f);
pain_type = 1;
}
// add scripting hook for 'On Pain Flash' --wookieejedi
OnPainFlashHook->run(scripting::hook_param_list(scripting::hook_param("Pain_Type", 'i', pain_type)));
}
// kill any active popups when you get hit.
+2
View File
@@ -349,6 +349,8 @@ add_file_folder("GlobalIncs\\\\Toolchain"
add_file_folder("Graphics"
graphics/2d.cpp
graphics/2d.h
graphics/debug.cpp
graphics/debug.h
graphics/decal_draw_list.cpp
graphics/decal_draw_list.h
graphics/grbatch.cpp
-1
View File
@@ -23,7 +23,6 @@ namespace Weapon {
Bomb, // Bomb-type missile, can be targeted
Huge, // Huge damage (generally 500+), probably only fired at huge ships.
No_dumbfire, // Missile cannot be fired dumbfire (ie requires aspect lock)
No_doublefire, // Disables linked firing for secondaries - EatThePath
Thruster, // Has thruster cone and/or glow
In_tech_database,
Player_allowed, // allowed to be on starting wing ships/in weaponry pool
+1 -2
View File
@@ -115,7 +115,6 @@ flag_def_list_new<Weapon::Info_Flags> Weapon_Info_Flags[] = {
{ "child", Weapon::Info_Flags::Child, true, false },
{ "bomb", Weapon::Info_Flags::Bomb, true, false },
{ "no dumbfire", Weapon::Info_Flags::No_dumbfire, true, false },
{ "no doublefire", Weapon::Info_Flags::No_doublefire, true, false },
{ "in tech database", Weapon::Info_Flags::In_tech_database, true, false },
{ "player allowed", Weapon::Info_Flags::Player_allowed, true, false },
{ "particle spew", Weapon::Info_Flags::Particle_spew, true, false },
@@ -809,7 +808,7 @@ int parse_weapon(int subtype, bool replace, const char *filename)
}
//Remove @ symbol
//these used to denote weapons that would
//these used to be used to denote weapons that would
//only be parsed in demo builds
if ( fname[0] == '@' ) {
backspace(fname);
+6 -3
View File
@@ -231,8 +231,9 @@ BOOL CFREDApp::InitInstance() {
Lighting_on = GetProfileInt("Preferences", "Lighting On", Lighting_on);
// Goober5000
Mission_save_format = GetProfileInt("Preferences", "FS2 open format", FSO_FORMAT_STANDARD);
Mission_save_format = GetProfileInt("Preferences", "Mission save format", Mission_save_format);
Format_fs2_open = GetProfileInt("Preferences", "FS2 open format", Format_fs2_open);
Format_fs2_retail = GetProfileInt("Preferences", "FS2 retail format", Format_fs2_retail);
Format_fs1_retail = GetProfileInt("Preferences", "FS1 retail format", Format_fs1_retail);
read_window("Main window", &Main_wnd_data);
read_window("Ship window", &Ship_wnd_data);
@@ -492,7 +493,9 @@ void CFREDApp::write_ini_file(int degree) {
WriteProfileInt("Preferences", "Lighting On", Lighting_on);
// Goober5000
WriteProfileInt("Preferences", "Mission save format", Mission_save_format);
WriteProfileInt("Preferences", "FS2 open format", Format_fs2_open);
WriteProfileInt("Preferences", "FS2 retail format", Format_fs2_retail);
WriteProfileInt("Preferences", "FS1 retail format", Format_fs1_retail);
if (!degree) {
record_window_data(&Waypoint_wnd_data, &Waypoint_editor_dialog);
+19 -9
View File
@@ -107,7 +107,9 @@ Marking_box marking_box;
object_orient_pos rotation_backup[MAX_OBJECTS];
// Goober5000 (currently, FS1 retail not implemented)
int Mission_save_format = FSO_FORMAT_STANDARD;
int Format_fs2_open = FSO_FORMAT_STANDARD;
int Format_fs2_retail = 0;
int Format_fs1_retail = 0;
// used by error checker, but needed in more than just one function.
char *names[MAX_OBJECTS], flags[MAX_OBJECTS];
@@ -4521,7 +4523,9 @@ void CFREDView::OnDumpStats()
void CFREDView::OnFormatFs2Open()
{
Mission_save_format = FSO_FORMAT_STANDARD;
Format_fs2_open = FSO_FORMAT_STANDARD;
Format_fs2_retail = 0;
Format_fs1_retail = 0;
theApp.write_ini_file();
Update_window = 1;
@@ -4529,12 +4533,14 @@ void CFREDView::OnFormatFs2Open()
void CFREDView::OnUpdateFormatFs2Open(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(Mission_save_format == FSO_FORMAT_STANDARD);
pCmdUI->SetCheck(Format_fs2_open == FSO_FORMAT_STANDARD);
}
void CFREDView::OnFormatFs2OpenComp()
{
Mission_save_format = FSO_FORMAT_COMPATIBILITY_MODE;
Format_fs2_open = FSO_FORMAT_COMPATIBILITY_MODE;
Format_fs2_retail = 0;
Format_fs1_retail = 0;
theApp.write_ini_file();
Update_window = 1;
@@ -4542,12 +4548,14 @@ void CFREDView::OnFormatFs2OpenComp()
void CFREDView::OnUpdateFormatFs2OpenComp(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(Mission_save_format == FSO_FORMAT_COMPATIBILITY_MODE);
pCmdUI->SetCheck(Format_fs2_open == FSO_FORMAT_COMPATIBILITY_MODE);
}
void CFREDView::OnFormatFs2Retail()
{
Mission_save_format = FSO_FORMAT_RETAIL;
Format_fs2_open = FSO_FORMAT_RETAIL;
Format_fs2_retail = 1;
Format_fs1_retail = 0;
theApp.write_ini_file();
Update_window = 1;
@@ -4555,12 +4563,14 @@ void CFREDView::OnFormatFs2Retail()
void CFREDView::OnUpdateFormatFs2Retail(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(Mission_save_format == FSO_FORMAT_RETAIL);
pCmdUI->SetCheck(Format_fs2_retail);
}
void CFREDView::OnFormatFs1Retail()
{
Mission_save_format = FSO_FORMAT_RETAIL;
Format_fs2_open = FSO_FORMAT_RETAIL;
Format_fs2_retail = 0;
Format_fs1_retail = 1;
theApp.write_ini_file();
Update_window = 1;
@@ -4568,7 +4578,7 @@ void CFREDView::OnFormatFs1Retail()
void CFREDView::OnUpdateFormatFs1Retail(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(Mission_save_format == FSO_FORMAT_RETAIL);
pCmdUI->SetCheck(Format_fs1_retail);
}
void CFREDView::OnEditorsSetGlobalShipFlags()
+5 -1
View File
@@ -364,7 +364,11 @@ enum FSO_FORMAT
FSO_FORMAT_STANDARD = 1,
FSO_FORMAT_COMPATIBILITY_MODE = 2
};
extern int Mission_save_format;
// Goober5000 (currently, FS1 retail not implemented)
extern int Format_fs2_open;
extern int Format_fs2_retail;
extern int Format_fs1_retail;
extern CFREDView *Fred_view_wnd;
+122 -187
View File
@@ -51,8 +51,7 @@
#include <freespace.h>
int CFred_mission_save::autosave_mission_file(char *pathname)
{
int CFred_mission_save::autosave_mission_file(char *pathname) {
char backup_name[256], name2[256];
int i;
@@ -74,8 +73,7 @@ int CFred_mission_save::autosave_mission_file(char *pathname)
return err;
}
void CFred_mission_save::bypass_comment(const char *comment, const char *end)
{
void CFred_mission_save::bypass_comment(const char *comment, const char *end) {
char *ch = strstr(raw_ptr, comment);
if (ch != NULL) {
if (end != NULL) {
@@ -98,23 +96,20 @@ void CFred_mission_save::bypass_comment(const char *comment, const char *end)
}
}
void CFred_mission_save::convert_special_tags_to_retail(char *text, int max_len)
{
void CFred_mission_save::convert_special_tags_to_retail(char *text, int max_len) {
replace_all(text, "$quote", "''", max_len);
replace_all(text, "$semicolon", ",", max_len);
}
void CFred_mission_save::convert_special_tags_to_retail(SCP_string &text)
{
void CFred_mission_save::convert_special_tags_to_retail(SCP_string &text) {
replace_all(text, "$quote", "''");
replace_all(text, "$semicolon", ",");
}
void CFred_mission_save::convert_special_tags_to_retail()
{
void CFred_mission_save::convert_special_tags_to_retail() {
int i, team, stage;
if (Mission_save_format != FSO_FORMAT_RETAIL)
if (Format_fs2_open != FSO_FORMAT_RETAIL)
return;
for (team = 0; team < Num_teams; team++) {
@@ -139,8 +134,7 @@ void CFred_mission_save::convert_special_tags_to_retail()
}
}
int CFred_mission_save::fout(char *format, ...)
{
int CFred_mission_save::fout(char *format, ...) {
SCP_string str;
va_list args;
@@ -156,8 +150,7 @@ int CFred_mission_save::fout(char *format, ...)
return 0;
}
int CFred_mission_save::fout_ext(char *pre_str, char *format, ...)
{
int CFred_mission_save::fout_ext(char *pre_str, char *format, ...) {
SCP_string str_scp;
SCP_string str_out_scp;
va_list args;
@@ -259,8 +252,7 @@ int CFred_mission_save::fout_ext(char *pre_str, char *format, ...)
return 0;
}
int CFred_mission_save::fout_version(char *format, ...)
{
int CFred_mission_save::fout_version(char *format, ...) {
SCP_string str_scp;
char *ch = NULL;
va_list args;
@@ -269,14 +261,9 @@ int CFred_mission_save::fout_version(char *format, ...)
return err;
}
// if we're saving in retail format, we can completely skip this
if (Mission_save_format == FSO_FORMAT_RETAIL) {
return 0;
}
// output the version first thing, but skip the special case where we use
// fout_version() for multiline value strings (typically indicated by an initial space)
if ((Mission_save_format == FSO_FORMAT_COMPATIBILITY_MODE) && (*format != ' ') && !fso_ver_comment.empty()) {
if ((Format_fs2_open == FSO_FORMAT_COMPATIBILITY_MODE) && (*format != ' ') && !fso_ver_comment.empty()) {
while (*format == '\n') {
str_scp.append(1, *format);
format++;
@@ -297,7 +284,7 @@ int CFred_mission_save::fout_version(char *format, ...)
char *str_c = vm_strdup(str_scp.c_str());
// this could be a multi-line string, so we've got to handle it all properly
if ((Mission_save_format == FSO_FORMAT_COMPATIBILITY_MODE) && !fso_ver_comment.empty()) {
if ((Format_fs2_open == FSO_FORMAT_COMPATIBILITY_MODE) && !fso_ver_comment.empty()) {
bool first_line = true;
char *str_p = str_c;
@@ -354,8 +341,7 @@ int CFred_mission_save::fout_version(char *format, ...)
return 0;
}
void CFred_mission_save::parse_comments(int newlines)
{
void CFred_mission_save::parse_comments(int newlines) {
char *comment_start = NULL;
int state = 0, same_line = 0, first_comment = 1, tab = 0, flag = 0;
bool version_added = false;
@@ -515,8 +501,7 @@ void CFred_mission_save::parse_comments(int newlines)
return;
}
void CFred_mission_save::save_ai_goals(ai_goal *goalp, int ship)
{
void CFred_mission_save::save_ai_goals(ai_goal *goalp, int ship) {
char *str = NULL, buf[80];
int i, valid, flag = 1;
@@ -669,8 +654,7 @@ void CFred_mission_save::save_ai_goals(ai_goal *goalp, int ship)
fso_comment_pop(true);
}
int CFred_mission_save::save_asteroid_fields()
{
int CFred_mission_save::save_asteroid_fields() {
int i;
fred_parse_flag = 0;
@@ -764,8 +748,7 @@ int CFred_mission_save::save_asteroid_fields()
return err;
}
int CFred_mission_save::save_bitmaps()
{
int CFred_mission_save::save_bitmaps() {
int i;
uint j;
@@ -911,8 +894,7 @@ int CFred_mission_save::save_bitmaps()
return err;
}
int CFred_mission_save::save_briefing()
{
int CFred_mission_save::save_briefing() {
int i, j, k, nb;
SCP_string sexp_out;
brief_stage *bs;
@@ -1045,13 +1027,13 @@ int CFred_mission_save::save_briefing()
parse_comments();
fout(" %d", (bi->flags & BI_HIGHLIGHT) ? 1 : 0);
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
required_string_fred("$mirror:");
parse_comments();
fout(" %d", (bi->flags & BI_MIRROR_ICON) ? 1 : 0);
}
if ((Mission_save_format != FSO_FORMAT_RETAIL) && (bi->flags & BI_USE_WING_ICON)) {
if ((Format_fs2_open != FSO_FORMAT_RETAIL) && (bi->flags & BI_USE_WING_ICON)) {
required_string_fred("$use wing icon:");
parse_comments();
fout(" %d", (bi->flags & BI_USE_WING_ICON) ? 1 : 0);
@@ -1088,8 +1070,7 @@ int CFred_mission_save::save_briefing()
return err;
}
int CFred_mission_save::save_campaign_file(char *pathname)
{
int CFred_mission_save::save_campaign_file(char *pathname) {
int i, j, m, flag;
Campaign_tree_formp->save_tree(); // flush all changes so they get saved.
@@ -1128,7 +1109,7 @@ int CFred_mission_save::save_campaign_file(char *pathname)
}
// campaign flags - Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
optional_string_fred("$Flags:");
parse_comments();
fout(" %d\n", Campaign.flags);
@@ -1172,7 +1153,7 @@ int CFred_mission_save::save_campaign_file(char *pathname)
parse_comments();
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
// don't save Bastion flag
fout(" %d", Campaign.missions[m].flags & ~CMISSION_FLAG_BASTION);
@@ -1220,7 +1201,7 @@ int CFred_mission_save::save_campaign_file(char *pathname)
//save_campaign_sexp(Links[j].sexp, Campaign.missions[Links[j].to].name);
if (Links[j].is_mission_loop) {
mission_loop = true;
} else if (Links[j].is_mission_fork && (Mission_save_format != FSO_FORMAT_RETAIL)) {
} else if (Links[j].is_mission_fork) {
mission_fork = true;
} else {
save_campaign_sexp(Links[j].sexp, Links[j].to);
@@ -1331,8 +1312,7 @@ int CFred_mission_save::save_campaign_file(char *pathname)
return err;
}
void CFred_mission_save::save_campaign_sexp(int node, int link_num)
{
void CFred_mission_save::save_campaign_sexp(int node, int link_num) {
SCP_string sexp_out;
Assert(node >= 0);
@@ -1352,8 +1332,7 @@ void CFred_mission_save::save_campaign_sexp(int node, int link_num)
}
}
int CFred_mission_save::save_cmd_brief()
{
int CFred_mission_save::save_cmd_brief() {
int stage;
stage = 0;
@@ -1391,8 +1370,7 @@ int CFred_mission_save::save_cmd_brief()
return err;
}
int CFred_mission_save::save_cmd_briefs()
{
int CFred_mission_save::save_cmd_briefs() {
int i;
for (i = 0; i < Num_teams; i++) {
@@ -1403,8 +1381,7 @@ int CFred_mission_save::save_cmd_briefs()
return err;
}
void CFred_mission_save::fso_comment_push(char *ver)
{
void CFred_mission_save::fso_comment_push(char *ver) {
if (fso_ver_comment.empty()) {
fso_ver_comment.push_back(SCP_string(ver));
return;
@@ -1437,8 +1414,7 @@ void CFred_mission_save::fso_comment_push(char *ver)
}
}
void CFred_mission_save::fso_comment_pop(bool pop_all)
{
void CFred_mission_save::fso_comment_pop(bool pop_all) {
if (fso_ver_comment.empty()) {
return;
}
@@ -1451,8 +1427,7 @@ void CFred_mission_save::fso_comment_pop(bool pop_all)
fso_ver_comment.pop_back();
}
int CFred_mission_save::save_common_object_data(object *objp, ship *shipp)
{
int CFred_mission_save::save_common_object_data(object *objp, ship *shipp) {
int j, z;
ship_subsys *ptr = NULL;
ship_info *sip = NULL;
@@ -1471,7 +1446,7 @@ int CFred_mission_save::save_common_object_data(object *objp, ship *shipp)
}
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL && (shipp->special_hitpoints > 0)) {
if (Format_fs2_open != FSO_FORMAT_RETAIL && (shipp->special_hitpoints)) {
temp_max_hull_strength = (float) shipp->special_hitpoints;
} else {
temp_max_hull_strength = sip->max_hull_strength;
@@ -1627,9 +1602,8 @@ int CFred_mission_save::save_common_object_data(object *objp, ship *shipp)
return err;
}
void CFred_mission_save::save_custom_bitmap(const char *expected_string_640, const char *expected_string_1024, const char *string_field_640, const char *string_field_1024, int blank_lines)
{
if (Mission_save_format != FSO_FORMAT_RETAIL) {
void CFred_mission_save::save_custom_bitmap(const char *expected_string_640, const char *expected_string_1024, const char *string_field_640, const char *string_field_1024, int blank_lines) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if ((*string_field_640 != '\0') || (*string_field_1024 != '\0')) {
while (blank_lines-- > 0)
fout("\n");
@@ -1645,14 +1619,13 @@ void CFred_mission_save::save_custom_bitmap(const char *expected_string_640, con
}
}
int CFred_mission_save::save_cutscenes()
{
int CFred_mission_save::save_cutscenes() {
char type[NAME_LENGTH];
SCP_string sexp_out;
// Let's just assume it has them for now -
if (!(The_mission.cutscenes.empty())) {
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (optional_string_fred("#Cutscenes")) {
parse_comments(2);
} else {
@@ -1702,7 +1675,7 @@ int CFred_mission_save::save_cutscenes()
required_string_fred("#end");
parse_comments();
} else {
MessageBox(nullptr, "Warning: This mission contains cutscene data, but you are saving in the retail mission format. This information will be lost.", "Incompatibility with retail mission format", MB_OK);
MessageBox(NULL, "Warning: This mission contains cutscene data, but you are saving in the retail mission format. This information will be lost", "Incompatibility with retail mission format", MB_OK);
}
}
@@ -1710,8 +1683,7 @@ int CFred_mission_save::save_cutscenes()
return err;
}
int CFred_mission_save::save_debriefing()
{
int CFred_mission_save::save_debriefing() {
int j, i;
SCP_string sexp_out;
@@ -1767,8 +1739,7 @@ int CFred_mission_save::save_debriefing()
return err;
}
int CFred_mission_save::save_events()
{
int CFred_mission_save::save_events() {
SCP_string sexp_out;
int i, j, add_flag;
@@ -1807,7 +1778,7 @@ int CFred_mission_save::save_events()
fout(" %d", Mission_events[i].repeat_count);
}
if (Mission_save_format != FSO_FORMAT_RETAIL && Mission_events[i].trigger_count != 1) {
if (Format_fs2_open != FSO_FORMAT_RETAIL && Mission_events[i].trigger_count != 1) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Trigger Count:", "$Formula:")) {
parse_comments();
@@ -1880,7 +1851,7 @@ int CFred_mission_save::save_events()
// save flags, if any
// (the transient flags are not used in FRED, so if the flags field is nonzero they will all be meaningful flags from the flag list)
if (Mission_save_format != FSO_FORMAT_RETAIL && Mission_events[i].flags != 0) {
if (Format_fs2_open != FSO_FORMAT_RETAIL && Mission_events[i].flags != 0) {
fso_comment_push(";;FSO 20.0.0;;");
if (optional_string_fred("+Event Flags: (", "$Formula:")) {
parse_comments();
@@ -1897,7 +1868,7 @@ int CFred_mission_save::save_events()
fout(" )");
}
if (Mission_save_format != FSO_FORMAT_RETAIL && Mission_events[i].mission_log_flags != 0) {
if (Format_fs2_open != FSO_FORMAT_RETAIL && Mission_events[i].mission_log_flags != 0) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Event Log Flags: (", "$Formula:")) {
parse_comments();
@@ -1923,10 +1894,9 @@ int CFred_mission_save::save_events()
return err;
}
int CFred_mission_save::save_fiction()
{
int CFred_mission_save::save_fiction() {
if (mission_has_fiction()) {
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (optional_string_fred("#Fiction Viewer"))
parse_comments(2);
else
@@ -1990,7 +1960,7 @@ int CFred_mission_save::save_fiction()
optional_string_fred("$Formula:");
}
} else {
MessageBox(nullptr, "Warning: This mission contains fiction viewer data, but you are saving in the retail mission format.", "Incompatibility with retail mission format", MB_OK);
MessageBox(NULL, "Warning: This mission contains fiction viewer data, but you are saving in the retail mission format.", "Incompatibility with retail mission format", MB_OK);
}
}
@@ -1999,8 +1969,7 @@ int CFred_mission_save::save_fiction()
return err;
}
int CFred_mission_save::save_goals()
{
int CFred_mission_save::save_goals() {
SCP_string sexp_out;
int i;
@@ -2079,16 +2048,14 @@ int CFred_mission_save::save_goals()
return err;
}
int CFred_mission_save::save_matrix(matrix &m)
{
int CFred_mission_save::save_matrix(matrix &m) {
fout("\n\t%f, %f, %f,\n", m.vec.rvec.xyz.x, m.vec.rvec.xyz.y, m.vec.rvec.xyz.z);
fout("\t%f, %f, %f,\n", m.vec.uvec.xyz.x, m.vec.uvec.xyz.y, m.vec.uvec.xyz.z);
fout("\t%f, %f, %f", m.vec.fvec.xyz.x, m.vec.fvec.xyz.y, m.vec.fvec.xyz.z);
return 0;
}
int CFred_mission_save::save_messages()
{
int CFred_mission_save::save_messages() {
int i;
fred_parse_flag = 0;
@@ -2097,7 +2064,7 @@ int CFred_mission_save::save_messages()
fout("\t\t;! %d total\n", Num_messages - Num_builtin_messages);
// Goober5000 - special Command info
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (stricmp(The_mission.command_sender, DEFAULT_COMMAND))
fout("\n$Command Sender: %s", The_mission.command_sender);
@@ -2163,8 +2130,7 @@ int CFred_mission_save::save_messages()
return err;
}
int CFred_mission_save::save_mission_file(char *pathname)
{
int CFred_mission_save::save_mission_file(char *pathname) {
char backup_name[256], savepath[MAX_PATH_LEN], *p;
strcpy_s(savepath, "");
@@ -2194,8 +2160,7 @@ int CFred_mission_save::save_mission_file(char *pathname)
return err;
}
int CFred_mission_save::save_mission_info()
{
int CFred_mission_save::save_mission_info() {
required_string_fred("#Mission Info");
parse_comments(0);
@@ -2270,7 +2235,7 @@ int CFred_mission_save::save_mission_info()
}
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
// write out the nebula clipping multipliers
fout("\n+Fog Near Mult: %f\n", Neb2_fog_near_mult);
fout("\n+Fog Far Mult: %f\n", Neb2_fog_far_mult);
@@ -2296,7 +2261,7 @@ int CFred_mission_save::save_mission_info()
fout(" %d", The_mission.num_respawns);
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Max Respawn Time:"))
parse_comments(2);
@@ -2311,7 +2276,7 @@ int CFred_mission_save::save_mission_info()
}
}
if (Mission_save_format == FSO_FORMAT_RETAIL) {
if (Format_fs2_open == FSO_FORMAT_RETAIL) {
if (optional_string_fred("+Red Alert:"))
parse_comments(2);
else
@@ -2320,7 +2285,7 @@ int CFred_mission_save::save_mission_info()
fout(" %d", (The_mission.flags[Mission::Mission_Flags::Red_alert]) ? 1 : 0);
}
if (Mission_save_format == FSO_FORMAT_RETAIL) //-V581
if (Format_fs2_open == FSO_FORMAT_RETAIL) //-V581
{
if (optional_string_fred("+Scramble:"))
parse_comments(2);
@@ -2339,7 +2304,7 @@ int CFred_mission_save::save_mission_info()
fout(" %d", (The_mission.support_ships.max_support_ships == 0) ? 1 : 0);
// here be WMCoolmon's hull and subsys repair stuff
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (optional_string_fred("+Hull Repair Ceiling:")) {
parse_comments(1);
} else {
@@ -2400,7 +2365,7 @@ int CFred_mission_save::save_mission_info()
}
// Goober5000 - special wing info
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
int i;
fout("\n");
@@ -2534,8 +2499,7 @@ int CFred_mission_save::save_mission_info()
return err;
}
void CFred_mission_save::save_mission_internal(const char *pathname)
{
void CFred_mission_save::save_mission_internal(const char *pathname) {
CTime t;
t = CTime::GetCurrentTime();
@@ -2606,8 +2570,7 @@ void CFred_mission_save::save_mission_internal(const char *pathname)
mprintf(("Mission saving error code #%d\n", err));
}
int CFred_mission_save::save_music()
{
int CFred_mission_save::save_music() {
required_string_fred("#Music");
parse_comments(2);
@@ -2665,7 +2628,7 @@ int CFred_mission_save::save_music()
}
fout(" %s", Mission_music[SCORE_DEBRIEF_SUCCESS] < 0 ? "None" : Spooled_music[Mission_music[SCORE_DEBRIEF_SUCCESS]].name);
}
if (Mission_save_format != FSO_FORMAT_RETAIL && Mission_music[SCORE_DEBRIEF_AVERAGE] != event_music_get_spooled_music_index("Average")) {
if (Mission_music[SCORE_DEBRIEF_AVERAGE] != event_music_get_spooled_music_index("Average")) {
if (optional_string_fred("$Debriefing Average Music:")) {
parse_comments(1);
} else {
@@ -2703,9 +2666,6 @@ int CFred_mission_save::save_music()
int CFred_mission_save::save_warp_params(WarpDirection direction, ship *shipp)
{
if (Mission_save_format == FSO_FORMAT_RETAIL)
return err;
// for writing to file; c.f. parse_warp_params
const char *prefix = (direction == WarpDirection::WARP_IN) ? "$Warpin" : "$Warpout";
@@ -2800,8 +2760,7 @@ int CFred_mission_save::save_warp_params(WarpDirection direction, ship *shipp)
return err;
}
int CFred_mission_save::save_objects()
{
int CFred_mission_save::save_objects() {
SCP_string sexp_out;
int i, z;
ai_info *aip;
@@ -2832,7 +2791,7 @@ int CFred_mission_save::save_objects()
fout(" %s\t\t;! Object #%d\n", shipp->ship_name, i);
// Display name
if (Mission_save_format != FSO_FORMAT_RETAIL && shipp->has_display_name()) {
if (Format_fs2_open != FSO_FORMAT_RETAIL && shipp->has_display_name()) {
// The display name is only written if there was one at the start to avoid introducing inconsistencies
fout("\n$Display name:");
fout_ext(" ", "%s", shipp->display_name.c_str());
@@ -2844,7 +2803,7 @@ int CFred_mission_save::save_objects()
fout(" %s", Ship_info[shipp->ship_info_index].name);
//alt classes stuff
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
for (SCP_vector<alt_class>::iterator ii = shipp->s_alt_classes.begin(); ii != shipp->s_alt_classes.end(); ++ii) {
// is this a variable?
if (ii->variable_index != -1) {
@@ -2866,7 +2825,7 @@ int CFred_mission_save::save_objects()
}
// optional callsign
if (Mission_save_format != FSO_FORMAT_RETAIL && strlen(Fred_callsigns[i])) {
if (strlen(Fred_callsigns[i])) {
fout("\n$Callsign: %s\n", Fred_callsigns[i]);
}
@@ -2874,7 +2833,7 @@ int CFred_mission_save::save_objects()
parse_comments();
fout(" %s", Iff_info[shipp->team].iff_name);
if (Mission_save_format != FSO_FORMAT_RETAIL && Ship_info[shipp->ship_info_index].uses_team_colors) {
if (Ship_info[shipp->ship_info_index].uses_team_colors) {
required_string_fred("$Team Color Setting:");
parse_comments();
fout(" %s", shipp->team_name.c_str());
@@ -2888,7 +2847,7 @@ int CFred_mission_save::save_objects()
parse_comments();
save_matrix(Objects[shipp->objnum].orient);
if (Mission_save_format == FSO_FORMAT_RETAIL) {
if (Format_fs2_retail) {
required_string_fred("$IFF:");
parse_comments();
fout(" %s", "IFF 1");
@@ -2945,7 +2904,7 @@ int CFred_mission_save::save_objects()
if (z & SPECIAL_ARRIVAL_ANCHOR_FLAG) {
// get name
char tmp[NAME_LENGTH + 15];
stuff_special_arrival_anchor_name(tmp, z, Mission_save_format == FSO_FORMAT_RETAIL ? 1 : 0);
stuff_special_arrival_anchor_name(tmp, z, Format_fs2_retail);
// save it
fout(" %s", tmp);
@@ -2957,7 +2916,7 @@ int CFred_mission_save::save_objects()
}
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if ((shipp->arrival_location == ARRIVE_FROM_DOCK_BAY) && (shipp->arrival_path_mask > 0)) {
int anchor_shipnum;
polymodel *pm;
@@ -3011,7 +2970,7 @@ int CFred_mission_save::save_objects()
}
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if ((shipp->departure_location == DEPART_AT_DOCK_BAY) && (shipp->departure_path_mask > 0)) {
int anchor_shipnum;
polymodel *pm;
@@ -3112,12 +3071,12 @@ int CFred_mission_save::save_objects()
if (shipp->flags[Ship::Ship_Flags::Dont_collide_invis])
fout(" \"don't-collide-invisible\"");
//for compatibility reasons ship locked or weapons locked are saved as both locked in retail mode
if ((Mission_save_format == FSO_FORMAT_RETAIL) && ((shipp->flags[Ship::Ship_Flags::Ship_locked]) || (shipp->flags[Ship::Ship_Flags::Weapons_locked])))
if ((Format_fs2_open == FSO_FORMAT_RETAIL) && ((shipp->flags[Ship::Ship_Flags::Ship_locked]) || (shipp->flags[Ship::Ship_Flags::Weapons_locked])))
fout(" \"locked\"");
fout(" )");
// flags2 added by Goober5000 --------------------------------
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (optional_string_fred("+Flags2:", "$Name:")) {
parse_comments();
fout(" (");
@@ -3191,7 +3150,7 @@ int CFred_mission_save::save_objects()
}
// special explosions
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (shipp->use_special_explosion) {
fso_comment_push(";;FSO 3.6.13;;");
if (optional_string_fred("$Special Explosion:", "$Name:")) {
@@ -3281,7 +3240,7 @@ int CFred_mission_save::save_objects()
}
// Goober5000 ------------------------------------------------
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (shipp->special_hitpoints) {
fso_comment_push(";;FSO 3.6.13;;");
if (optional_string_fred("+Special Hitpoints:", "$Name:")) {
@@ -3336,7 +3295,7 @@ int CFred_mission_save::save_objects()
// Goober5000 - newer code to save off information about initially docked ships. ;)
if (object_is_docked(&Objects[shipp->objnum])) {
// possible incompatibility
if (Mission_save_format == FSO_FORMAT_RETAIL && !dock_check_docked_one_on_one(&Objects[shipp->objnum])) {
if (Format_fs2_open == FSO_FORMAT_RETAIL && !dock_check_docked_one_on_one(&Objects[shipp->objnum])) {
static bool warned = false;
if (!warned) {
CString text = "You are saving in the retail mission format, but \"";
@@ -3365,7 +3324,7 @@ int CFred_mission_save::save_objects()
}
}
// check the ship flag about killing off the ship before a mission starts. Write out the appropriate
// check the ship flag about killing off the ship before a missino starts. Write out the appropriate
// variable if necessary
if (shipp->flags[Ship::Ship_Flags::Kill_before_mission]) {
if (optional_string_fred("+Destroy At:", "$Name:"))
@@ -3418,7 +3377,7 @@ int CFred_mission_save::save_objects()
fout(" %d", shipp->score);
if (Mission_save_format != FSO_FORMAT_RETAIL && shipp->assist_score_pct != 0) {
if (Format_fs2_open != FSO_FORMAT_RETAIL && shipp->assist_score_pct != 0) {
fso_comment_push(";;FSO 3.6.10;;");
if (optional_string_fred("+Assist Score Percentage:")) {
parse_comments();
@@ -3493,9 +3452,7 @@ int CFred_mission_save::save_objects()
return err;
}
int CFred_mission_save::save_players()
{
bool wrote_fso_data = false;
int CFred_mission_save::save_players() {
int i, j;
int var_idx;
int used_pool[MAX_WEAPON_TYPES];
@@ -3521,7 +3478,7 @@ int CFred_mission_save::save_players()
}
// write out callsign list
if (Mission_save_format != FSO_FORMAT_RETAIL && Mission_callsign_count > 0) {
if (Mission_callsign_count > 0) {
fout("\n\n#Callsigns:\n");
// write them all out
@@ -3552,7 +3509,6 @@ int CFred_mission_save::save_players()
if (strlen(Team_data[i].ship_list_variables[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].ship_list_variables[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("\t@%s\t", Sexp_variables[var_idx].variable_name);
} else {
@@ -3563,7 +3519,6 @@ int CFred_mission_save::save_players()
if (strlen(Team_data[i].ship_count_variables[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].ship_count_variables[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("@%s\n", Sexp_variables[var_idx].variable_name);
} else {
@@ -3581,13 +3536,11 @@ int CFred_mission_save::save_players()
fout(" (\n");
generate_weaponry_usage_list(i, used_pool);
for (j = 0; j < Team_data[i].num_weapon_choices; j++) {
// first output the weapon name or a variable that sets it
if (strlen(Team_data[i].weaponry_pool_variable[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].weaponry_pool_variable[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("\t@%s\t", Sexp_variables[var_idx].variable_name);
} else {
@@ -3600,7 +3553,6 @@ int CFred_mission_save::save_players()
if (strlen(Team_data[i].weaponry_amount_variable[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].weaponry_amount_variable[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("@%s\n", Sexp_variables[var_idx].variable_name);
} else {
@@ -3622,12 +3574,6 @@ int CFred_mission_save::save_players()
fout(")");
// sanity check
if (Mission_save_format == FSO_FORMAT_RETAIL && wrote_fso_data) {
// this is such an unlikely (and hard-to-fix) case that a warning should be sufficient
MessageBox(nullptr, "Warning: This mission contains variable-based team loadout information, but you are saving in the retail mission format. Retail FRED and FS2 will not be able to read this information.", "Incompatibility with retail mission format", MB_OK);
}
// Goober5000 - mjn.mixael's required weapon feature
bool uses_required_weapon = false;
for (j = 0; j < weapon_info_size(); j++) {
@@ -3636,7 +3582,7 @@ int CFred_mission_save::save_players()
break;
}
}
if (Mission_save_format != FSO_FORMAT_RETAIL && uses_required_weapon) {
if (uses_required_weapon) {
if (optional_string_fred("+Required for mission:", "$Starting Shipname:"))
parse_comments(2);
else
@@ -3658,9 +3604,8 @@ int CFred_mission_save::save_players()
return err;
}
int CFred_mission_save::save_plot_info()
{
if (Mission_save_format == FSO_FORMAT_RETAIL) {
int CFred_mission_save::save_plot_info() {
if (Format_fs2_open == FSO_FORMAT_RETAIL) {
if (optional_string_fred("#Plot Info")) {
parse_comments(2);
@@ -3709,8 +3654,7 @@ int CFred_mission_save::save_plot_info()
return err;
}
int CFred_mission_save::save_reinforcements()
{
int CFred_mission_save::save_reinforcements() {
int i, j, type;
fred_parse_flag = 0;
@@ -3776,8 +3720,7 @@ int CFred_mission_save::save_reinforcements()
return err;
}
void CFred_mission_save::save_single_dock_instance(ship *shipp, dock_instance *dock_ptr)
{
void CFred_mission_save::save_single_dock_instance(ship *shipp, dock_instance *dock_ptr) {
Assert(shipp && dock_ptr);
Assert(dock_ptr->docked_objp->type == OBJ_SHIP || dock_ptr->docked_objp->type == OBJ_START);
@@ -3809,8 +3752,7 @@ void CFred_mission_save::save_single_dock_instance(ship *shipp, dock_instance *d
fso_comment_pop(true);
}
void CFred_mission_save::save_turret_info(ship_subsys *ptr, int ship)
{
void CFred_mission_save::save_turret_info(ship_subsys *ptr, int ship) {
int i, z;
ship_weapon *wp = &ptr->weapons;
@@ -3891,8 +3833,7 @@ void CFred_mission_save::save_turret_info(ship_subsys *ptr, int ship)
fso_comment_pop(true);
}
int CFred_mission_save::save_variables()
{
int CFred_mission_save::save_variables() {
char *type;
char number[] = "number";
char string[] = "string";
@@ -3906,7 +3847,7 @@ int CFred_mission_save::save_variables()
// get count
int num_variables = sexp_variable_count();
if (Mission_save_format == FSO_FORMAT_RETAIL) {
if (Format_fs2_open == FSO_FORMAT_RETAIL) {
generate_special_explosion_block_variables();
num_block_vars = num_block_variables();
}
@@ -3934,7 +3875,7 @@ int CFred_mission_save::save_variables()
fout("\n\t\t%d\t\t\"%s\"\t\t\"%s\"\t\t\"%s\"", i, Sexp_variables[i].variable_name, Sexp_variables[i].text, type);
// persistent and network variables
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
// Network variable - Karajorma
if (Sexp_variables[i].type & SEXP_VARIABLE_NETWORK) {
fout("\t\t\"%s\"", "network-variable");
@@ -3971,14 +3912,12 @@ int CFred_mission_save::save_variables()
return err;
}
int CFred_mission_save::save_vector(vec3d &v)
{
int CFred_mission_save::save_vector(vec3d &v) {
fout(" %f, %f, %f", v.xyz.x, v.xyz.y, v.xyz.z);
return 0;
}
int CFred_mission_save::save_waypoints()
{
int CFred_mission_save::save_waypoints() {
//object *ptr;
fred_parse_flag = 0;
@@ -3996,41 +3935,39 @@ int CFred_mission_save::save_waypoints()
parse_comments();
fout(" %s", jnp->GetName());
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (jnp->IsSpecialModel()) {
if (optional_string_fred("+Model File:", "$Jump Node:"))
parse_comments();
else
fout("\n+Model File:");
int model = jnp->GetModelNumber();
polymodel *pm = model_get(model);
fout(" %s", pm->filename);
}
if (jnp->IsColored()) {
if (optional_string_fred("+Alphacolor:", "$Jump Node:"))
parse_comments();
else
fout("\n+Alphacolor:");
color jn_color = jnp->GetColor();
fout(" %u %u %u %u", jn_color.red, jn_color.green, jn_color.blue, jn_color.alpha);
}
int hidden_is_there = optional_string_fred("+Hidden:", "$Jump Node:");
if (hidden_is_there)
if (jnp->IsSpecialModel()) {
if (optional_string_fred("+Model File:", "$Jump Node:"))
parse_comments();
else
fout("\n+Model File:");
if (hidden_is_there || jnp->IsHidden()) {
if (!hidden_is_there)
fout("\n+Hidden:");
int model = jnp->GetModelNumber();
polymodel *pm = model_get(model);
fout(" %s", pm->filename);
}
if (jnp->IsHidden())
fout(" %s", "true");
else
fout(" %s", "false");
}
if (jnp->IsColored()) {
if (optional_string_fred("+Alphacolor:", "$Jump Node:"))
parse_comments();
else
fout("\n+Alphacolor:");
color jn_color = jnp->GetColor();
fout(" %u %u %u %u", jn_color.red, jn_color.green, jn_color.blue, jn_color.alpha);
}
int hidden_is_there = optional_string_fred("+Hidden:", "$Jump Node:");
if (hidden_is_there)
parse_comments();
if (hidden_is_there || jnp->IsHidden()) {
if (!hidden_is_there)
fout("\n+Hidden:");
if (jnp->IsHidden())
fout(" %s", "true");
else
fout(" %s", "false");
}
fso_comment_pop();
@@ -4058,8 +3995,7 @@ int CFred_mission_save::save_waypoints()
return err;
}
int CFred_mission_save::save_waypoint_list(waypoint_list *wp_list)
{
int CFred_mission_save::save_waypoint_list(waypoint_list *wp_list) {
Assert(wp_list != NULL);
SCP_vector<waypoint>::iterator ii;
@@ -4071,8 +4007,7 @@ int CFred_mission_save::save_waypoint_list(waypoint_list *wp_list)
return 0;
}
int CFred_mission_save::save_wings()
{
int CFred_mission_save::save_wings() {
SCP_string sexp_out;
int i, j, z, ship, count = 0;
@@ -4092,7 +4027,7 @@ int CFred_mission_save::save_wings()
fout(" %s", Wings[i].name);
// squad logo - Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if (strlen(Wings[i].wing_squad_filename) > 0) //-V805
{
if (optional_string_fred("+Squad Logo:", "$Name:"))
@@ -4137,7 +4072,7 @@ int CFred_mission_save::save_wings()
if (z & SPECIAL_ARRIVAL_ANCHOR_FLAG) {
// get name
char tmp[NAME_LENGTH + 15];
stuff_special_arrival_anchor_name(tmp, z, Mission_save_format == FSO_FORMAT_RETAIL ? 1 : 0);
stuff_special_arrival_anchor_name(tmp, z, Format_fs2_retail);
// save it
fout(" %s", tmp);
@@ -4149,7 +4084,7 @@ int CFred_mission_save::save_wings()
}
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if ((Wings[i].arrival_location == ARRIVE_FROM_DOCK_BAY) && (Wings[i].arrival_path_mask > 0)) {
int anchor_shipnum;
polymodel *pm;
@@ -4199,7 +4134,7 @@ int CFred_mission_save::save_wings()
}
// Goober5000
if (Mission_save_format != FSO_FORMAT_RETAIL) {
if (Format_fs2_open != FSO_FORMAT_RETAIL) {
if ((Wings[i].departure_location == DEPART_AT_DOCK_BAY) && (Wings[i].departure_path_mask > 0)) {
int anchor_shipnum;
polymodel *pm;
+81 -150
View File
@@ -38,8 +38,7 @@
namespace fso {
namespace fred {
int CFred_mission_save::autosave_mission_file(char* pathname)
{
int CFred_mission_save::autosave_mission_file(char* pathname) {
char backup_name[256], name2[256];
int i;
@@ -61,8 +60,7 @@ int CFred_mission_save::autosave_mission_file(char* pathname)
return err;
}
void CFred_mission_save::bypass_comment(const char* comment, const char* end)
{
void CFred_mission_save::bypass_comment(const char* comment, const char* end) {
char* ch = strstr(raw_ptr, comment);
if (ch != NULL) {
if (end != NULL) {
@@ -86,20 +84,17 @@ void CFred_mission_save::bypass_comment(const char* comment, const char* end)
}
}
void CFred_mission_save::convert_special_tags_to_retail(char* text, int max_len)
{
void CFred_mission_save::convert_special_tags_to_retail(char* text, int max_len) {
replace_all(text, "$quote", "''", max_len);
replace_all(text, "$semicolon", ",", max_len);
}
void CFred_mission_save::convert_special_tags_to_retail(SCP_string& text)
{
void CFred_mission_save::convert_special_tags_to_retail(SCP_string& text) {
replace_all(text, "$quote", "''");
replace_all(text, "$semicolon", ",");
}
void CFred_mission_save::convert_special_tags_to_retail()
{
void CFred_mission_save::convert_special_tags_to_retail() {
int i, team, stage;
if (save_format != MissionFormat::RETAIL) {
@@ -128,8 +123,7 @@ void CFred_mission_save::convert_special_tags_to_retail()
}
}
int CFred_mission_save::fout(const char* format, ...)
{
int CFred_mission_save::fout(const char* format, ...) {
SCP_string str;
va_list args;
@@ -145,8 +139,7 @@ int CFred_mission_save::fout(const char* format, ...)
return 0;
}
int CFred_mission_save::fout_ext(const char* pre_str, const char* format, ...)
{
int CFred_mission_save::fout_ext(const char* pre_str, const char* format, ...) {
SCP_string str_scp;
SCP_string str_out_scp;
va_list args;
@@ -248,8 +241,7 @@ int CFred_mission_save::fout_ext(const char* pre_str, const char* format, ...)
return 0;
}
int CFred_mission_save::fout_version(const char* format, ...)
{
int CFred_mission_save::fout_version(const char* format, ...) {
SCP_string str_scp;
char* ch = NULL;
va_list args;
@@ -258,11 +250,6 @@ int CFred_mission_save::fout_version(const char* format, ...)
return err;
}
// if we're saving in retail format, we can completely skip this
if (save_format == MissionFormat::RETAIL) {
return 0;
}
// output the version first thing, but skip the special case where we use
// fout_version() for multiline value strings (typically indicated by an initial space)
if ((save_format == MissionFormat::COMPATIBILITY_MODE) && (*format != ' ') && !fso_ver_comment.empty()) {
@@ -343,8 +330,7 @@ int CFred_mission_save::fout_version(const char* format, ...)
return 0;
}
void CFred_mission_save::parse_comments(int newlines)
{
void CFred_mission_save::parse_comments(int newlines) {
char* comment_start = NULL;
int state = 0, same_line = 0, first_comment = 1, tab = 0, flag = 0;
bool version_added = false;
@@ -521,8 +507,7 @@ void CFred_mission_save::parse_comments(int newlines)
return;
}
void CFred_mission_save::save_ai_goals(ai_goal* goalp, int ship)
{
void CFred_mission_save::save_ai_goals(ai_goal* goalp, int ship) {
const char* str = NULL;
char buf[80];
int i, valid, flag = 1;
@@ -683,8 +668,7 @@ void CFred_mission_save::save_ai_goals(ai_goal* goalp, int ship)
fso_comment_pop(true);
}
int CFred_mission_save::save_asteroid_fields()
{
int CFred_mission_save::save_asteroid_fields() {
int i;
fred_parse_flag = 0;
@@ -779,8 +763,7 @@ int CFred_mission_save::save_asteroid_fields()
return err;
}
int CFred_mission_save::save_bitmaps()
{
int CFred_mission_save::save_bitmaps() {
int i;
uint j;
@@ -926,8 +909,7 @@ int CFred_mission_save::save_bitmaps()
return err;
}
int CFred_mission_save::save_briefing()
{
int CFred_mission_save::save_briefing() {
int i, j, k, nb;
SCP_string sexp_out;
brief_stage* bs;
@@ -1115,8 +1097,7 @@ int CFred_mission_save::save_briefing()
return err;
}
int CFred_mission_save::save_cmd_brief()
{
int CFred_mission_save::save_cmd_brief() {
int stage;
stage = 0;
@@ -1159,8 +1140,7 @@ int CFred_mission_save::save_cmd_brief()
return err;
}
int CFred_mission_save::save_cmd_briefs()
{
int CFred_mission_save::save_cmd_briefs() {
int i;
for (i = 0; i < Num_teams; i++) {
@@ -1171,8 +1151,7 @@ int CFred_mission_save::save_cmd_briefs()
return err;
}
void CFred_mission_save::fso_comment_push(const char* ver)
{
void CFred_mission_save::fso_comment_push(const char* ver) {
if (fso_ver_comment.empty()) {
fso_ver_comment.push_back(SCP_string(ver));
return;
@@ -1207,8 +1186,7 @@ void CFred_mission_save::fso_comment_push(const char* ver)
}
}
void CFred_mission_save::fso_comment_pop(bool pop_all)
{
void CFred_mission_save::fso_comment_pop(bool pop_all) {
if (fso_ver_comment.empty()) {
return;
}
@@ -1221,8 +1199,7 @@ void CFred_mission_save::fso_comment_pop(bool pop_all)
fso_ver_comment.pop_back();
}
int CFred_mission_save::save_common_object_data(object* objp, ship* shipp)
{
int CFred_mission_save::save_common_object_data(object* objp, ship* shipp) {
int j, z;
ship_subsys* ptr = NULL;
ship_info* sip = NULL;
@@ -1242,7 +1219,7 @@ int CFred_mission_save::save_common_object_data(object* objp, ship* shipp)
}
// Goober5000
if (save_format != MissionFormat::RETAIL && (shipp->special_hitpoints > 0)) {
if (save_format != MissionFormat::RETAIL && (shipp->special_hitpoints)) {
temp_max_hull_strength = (float) shipp->special_hitpoints;
} else {
temp_max_hull_strength = sip->max_hull_strength;
@@ -1419,8 +1396,7 @@ void CFred_mission_save::save_custom_bitmap(const char* expected_string_640,
const char* expected_string_1024,
const char* string_field_640,
const char* string_field_1024,
int blank_lines)
{
int blank_lines) {
if (save_format != MissionFormat::RETAIL) {
if ((*string_field_640 != '\0') || (*string_field_1024 != '\0')) {
while (blank_lines-- > 0) {
@@ -1438,8 +1414,7 @@ void CFred_mission_save::save_custom_bitmap(const char* expected_string_640,
}
}
int CFred_mission_save::save_cutscenes()
{
int CFred_mission_save::save_cutscenes() {
char type[NAME_LENGTH];
SCP_string sexp_out;
@@ -1506,8 +1481,7 @@ int CFred_mission_save::save_cutscenes()
return err;
}
int CFred_mission_save::save_debriefing()
{
int CFred_mission_save::save_debriefing() {
int j, i;
SCP_string sexp_out;
@@ -1567,8 +1541,7 @@ int CFred_mission_save::save_debriefing()
return err;
}
int CFred_mission_save::save_events()
{
int CFred_mission_save::save_events() {
SCP_string sexp_out;
int i, j, add_flag;
@@ -1723,8 +1696,7 @@ int CFred_mission_save::save_events()
return err;
}
int CFred_mission_save::save_fiction()
{
int CFred_mission_save::save_fiction() {
if (mission_has_fiction()) {
if (save_format != MissionFormat::RETAIL) {
if (optional_string_fred("#Fiction Viewer")) {
@@ -1815,8 +1787,7 @@ int CFred_mission_save::save_fiction()
return err;
}
int CFred_mission_save::save_goals()
{
int CFred_mission_save::save_goals() {
SCP_string sexp_out;
int i;
@@ -1900,16 +1871,14 @@ int CFred_mission_save::save_goals()
return err;
}
int CFred_mission_save::save_matrix(matrix& m)
{
int CFred_mission_save::save_matrix(matrix& m) {
fout("\n\t%f, %f, %f,\n", m.vec.rvec.xyz.x, m.vec.rvec.xyz.y, m.vec.rvec.xyz.z);
fout("\t%f, %f, %f,\n", m.vec.uvec.xyz.x, m.vec.uvec.xyz.y, m.vec.uvec.xyz.z);
fout("\t%f, %f, %f", m.vec.fvec.xyz.x, m.vec.fvec.xyz.y, m.vec.fvec.xyz.z);
return 0;
}
int CFred_mission_save::save_messages()
{
int CFred_mission_save::save_messages() {
int i;
fred_parse_flag = 0;
@@ -1989,8 +1958,7 @@ int CFred_mission_save::save_messages()
return err;
}
int CFred_mission_save::save_mission_file(const char* pathname_in)
{
int CFred_mission_save::save_mission_file(const char* pathname_in) {
char backup_name[256], savepath[MAX_PATH_LEN], pathname[MAX_PATH_LEN];
strcpy_s(pathname, pathname_in);
@@ -2022,8 +1990,7 @@ int CFred_mission_save::save_mission_file(const char* pathname_in)
return err;
}
int CFred_mission_save::save_mission_info()
{
int CFred_mission_save::save_mission_info() {
required_string_fred("#Mission Info");
parse_comments(0);
@@ -2376,8 +2343,7 @@ int CFred_mission_save::save_mission_info()
return err;
}
void CFred_mission_save::save_mission_internal(const char* pathname)
{
void CFred_mission_save::save_mission_internal(const char* pathname) {
time_t rawtime;
time(&rawtime);
@@ -2450,8 +2416,7 @@ void CFred_mission_save::save_mission_internal(const char* pathname)
mprintf(("Mission saving error code #%d\n", err));
}
int CFred_mission_save::save_music()
{
int CFred_mission_save::save_music() {
required_string_fred("#Music");
parse_comments(2);
@@ -2513,7 +2478,7 @@ int CFred_mission_save::save_music()
Mission_music[SCORE_DEBRIEF_SUCCESS] < 0 ? "None"
: Spooled_music[Mission_music[SCORE_DEBRIEF_SUCCESS]].name);
}
if (save_format != MissionFormat::RETAIL && Mission_music[SCORE_DEBRIEF_AVERAGE] != event_music_get_spooled_music_index("Average")) {
if (Mission_music[SCORE_DEBRIEF_AVERAGE] != event_music_get_spooled_music_index("Average")) {
if (optional_string_fred("$Debriefing Average Music:")) {
parse_comments(1);
} else {
@@ -2554,9 +2519,6 @@ int CFred_mission_save::save_music()
int CFred_mission_save::save_warp_params(WarpDirection direction, ship *shipp)
{
if (save_format == MissionFormat::RETAIL)
return err;
// for writing to file; c.f. parse_warp_params
const char *prefix = (direction == WarpDirection::WARP_IN) ? "$Warpin" : "$Warpout";
@@ -2651,8 +2613,7 @@ int CFred_mission_save::save_warp_params(WarpDirection direction, ship *shipp)
return err;
}
int CFred_mission_save::save_objects()
{
int CFred_mission_save::save_objects() {
SCP_string sexp_out;
int i, z;
ai_info* aip;
@@ -2716,7 +2677,7 @@ int CFred_mission_save::save_objects()
}
// optional callsign
if (save_format != MissionFormat::RETAIL && strlen(Fred_callsigns[i])) {
if (strlen(Fred_callsigns[i])) {
fout("\n$Callsign: %s\n", Fred_callsigns[i]);
}
@@ -2724,7 +2685,7 @@ int CFred_mission_save::save_objects()
parse_comments();
fout(" %s", Iff_info[shipp->team].iff_name);
if (save_format != MissionFormat::RETAIL && Ship_info[shipp->ship_info_index].uses_team_colors) {
if (Ship_info[shipp->ship_info_index].uses_team_colors) {
required_string_fred("$Team Color Setting:");
parse_comments();
fout(" %s", shipp->team_name.c_str());
@@ -3280,7 +3241,7 @@ int CFred_mission_save::save_objects()
}
}
// check the ship flag about killing off the ship before a mission starts. Write out the appropriate
// check the ship flag about killing off the ship before a missino starts. Write out the appropriate
// variable if necessary
if (shipp->flags[Ship::Ship_Flags::Kill_before_mission]) {
if (optional_string_fred("+Destroy At:", "$Name:")) {
@@ -3414,9 +3375,7 @@ int CFred_mission_save::save_objects()
return err;
}
int CFred_mission_save::save_players()
{
bool wrote_fso_data = false;
int CFred_mission_save::save_players() {
int i, j;
int var_idx;
int used_pool[MAX_WEAPON_TYPES];
@@ -3442,7 +3401,7 @@ int CFred_mission_save::save_players()
}
// write out callsign list
if (save_format != MissionFormat::RETAIL && Mission_callsign_count > 0) {
if (Mission_callsign_count > 0) {
fout("\n\n#Callsigns:\n");
// write them all out
@@ -3473,7 +3432,6 @@ int CFred_mission_save::save_players()
if (strlen(Team_data[i].ship_list_variables[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].ship_list_variables[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("\t@%s\t", Sexp_variables[var_idx].variable_name);
} else {
@@ -3484,7 +3442,6 @@ int CFred_mission_save::save_players()
if (strlen(Team_data[i].ship_count_variables[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].ship_count_variables[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("@%s\n", Sexp_variables[var_idx].variable_name);
} else {
@@ -3502,13 +3459,11 @@ int CFred_mission_save::save_players()
fout(" (\n");
generate_weaponry_usage_list_team(i, used_pool);
for (j = 0; j < Team_data[i].num_weapon_choices; j++) {
// first output the weapon name or a variable that sets it
if (strlen(Team_data[i].weaponry_pool_variable[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].weaponry_pool_variable[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("\t@%s\t", Sexp_variables[var_idx].variable_name);
} else {
@@ -3521,7 +3476,6 @@ int CFred_mission_save::save_players()
if (strlen(Team_data[i].weaponry_amount_variable[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].weaponry_amount_variable[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("@%s\n", Sexp_variables[var_idx].variable_name);
} else {
@@ -3543,15 +3497,6 @@ int CFred_mission_save::save_players()
fout(")");
// sanity check
if (save_format == MissionFormat::RETAIL && wrote_fso_data) {
// this is such an unlikely (and hard-to-fix) case that a warning should be sufficient
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Incompatibility with retail mission format",
"Warning: This mission contains variable-based team loadout information, but you are saving in the retail mission format. Retail FRED and FS2 will not be able to read this information.",
{ DialogButton::Ok });
}
// Goober5000 - mjn.mixael's required weapon feature
bool uses_required_weapon = false;
for (j = 0; j < static_cast<int>(Weapon_info.size()); j++) {
@@ -3560,7 +3505,7 @@ int CFred_mission_save::save_players()
break;
}
}
if (save_format != MissionFormat::RETAIL && uses_required_weapon) {
if (uses_required_weapon) {
if (optional_string_fred("+Required for mission:", "$Starting Shipname:")) {
parse_comments(2);
} else {
@@ -3584,8 +3529,7 @@ int CFred_mission_save::save_players()
return err;
}
int CFred_mission_save::save_plot_info()
{
int CFred_mission_save::save_plot_info() {
if (save_format == MissionFormat::RETAIL) {
if (optional_string_fred("#Plot Info")) {
parse_comments(2);
@@ -3635,8 +3579,7 @@ int CFred_mission_save::save_plot_info()
return err;
}
int CFred_mission_save::save_reinforcements()
{
int CFred_mission_save::save_reinforcements() {
int i, j, type;
fred_parse_flag = 0;
@@ -3709,8 +3652,7 @@ int CFred_mission_save::save_reinforcements()
return err;
}
void CFred_mission_save::save_single_dock_instance(ship* shipp, dock_instance* dock_ptr)
{
void CFred_mission_save::save_single_dock_instance(ship* shipp, dock_instance* dock_ptr) {
Assert(shipp && dock_ptr);
Assert(dock_ptr->docked_objp->type == OBJ_SHIP || dock_ptr->docked_objp->type == OBJ_START);
@@ -3747,8 +3689,7 @@ void CFred_mission_save::save_single_dock_instance(ship* shipp, dock_instance* d
fso_comment_pop(true);
}
void CFred_mission_save::save_turret_info(ship_subsys* ptr, int ship)
{
void CFred_mission_save::save_turret_info(ship_subsys* ptr, int ship) {
int i, z;
ship_weapon* wp = &ptr->weapons;
@@ -3840,8 +3781,7 @@ void CFred_mission_save::save_turret_info(ship_subsys* ptr, int ship)
fso_comment_pop(true);
}
int CFred_mission_save::save_variables()
{
int CFred_mission_save::save_variables() {
char* type;
char number[] = "number";
char string[] = "string";
@@ -3924,14 +3864,12 @@ int CFred_mission_save::save_variables()
return err;
}
int CFred_mission_save::save_vector(vec3d& v)
{
int CFred_mission_save::save_vector(vec3d& v) {
fout(" %f, %f, %f", v.xyz.x, v.xyz.y, v.xyz.z);
return 0;
}
int CFred_mission_save::save_waypoints()
{
int CFred_mission_save::save_waypoints() {
//object *ptr;
fred_parse_flag = 0;
@@ -3949,48 +3887,43 @@ int CFred_mission_save::save_waypoints()
parse_comments();
fout(" %s", jnp->GetName());
if (save_format != MissionFormat::RETAIL) {
if (jnp->IsSpecialModel()) {
if (optional_string_fred("+Model File:", "$Jump Node:")) {
parse_comments();
}
else {
fout("\n+Model File:");
}
int model = jnp->GetModelNumber();
polymodel* pm = model_get(model);
fout(" %s", pm->filename);
}
if (jnp->IsColored()) {
if (optional_string_fred("+Alphacolor:", "$Jump Node:")) {
parse_comments();
}
else {
fout("\n+Alphacolor:");
}
color jn_color = jnp->GetColor();
fout(" %u %u %u %u", jn_color.red, jn_color.green, jn_color.blue, jn_color.alpha);
}
int hidden_is_there = optional_string_fred("+Hidden:", "$Jump Node:");
if (hidden_is_there) {
if (jnp->IsSpecialModel()) {
if (optional_string_fred("+Model File:", "$Jump Node:")) {
parse_comments();
} else {
fout("\n+Model File:");
}
if (hidden_is_there || jnp->IsHidden()) {
if (!hidden_is_there) {
fout("\n+Hidden:");
}
int model = jnp->GetModelNumber();
polymodel* pm = model_get(model);
fout(" %s", pm->filename);
}
if (jnp->IsHidden()) {
fout(" %s", "true");
}
else {
fout(" %s", "false");
}
if (jnp->IsColored()) {
if (optional_string_fred("+Alphacolor:", "$Jump Node:")) {
parse_comments();
} else {
fout("\n+Alphacolor:");
}
color jn_color = jnp->GetColor();
fout(" %u %u %u %u", jn_color.red, jn_color.green, jn_color.blue, jn_color.alpha);
}
int hidden_is_there = optional_string_fred("+Hidden:", "$Jump Node:");
if (hidden_is_there) {
parse_comments();
}
if (hidden_is_there || jnp->IsHidden()) {
if (!hidden_is_there) {
fout("\n+Hidden:");
}
if (jnp->IsHidden()) {
fout(" %s", "true");
} else {
fout(" %s", "false");
}
}
@@ -4019,8 +3952,7 @@ int CFred_mission_save::save_waypoints()
return err;
}
int CFred_mission_save::save_waypoint_list(waypoint_list* wp_list)
{
int CFred_mission_save::save_waypoint_list(waypoint_list* wp_list) {
Assert(wp_list != NULL);
SCP_vector<waypoint>::iterator ii;
@@ -4032,8 +3964,7 @@ int CFred_mission_save::save_waypoint_list(waypoint_list* wp_list)
return 0;
}
int CFred_mission_save::save_wings()
{
int CFred_mission_save::save_wings() {
SCP_string sexp_out;
int i, j, z, count = 0;
+6 -6
View File
@@ -29,20 +29,20 @@ class IntelParseTest : public test::FSTestFixture {
// Commonly used expected intel data entries.
static intel_data expected_foo = {
"Foo name default", // XSTR id 3000
"Foo desc default", // XSTR id 3001
"Foo name", // XSTR id 3000
"Foo desc", // XSTR id 3001
"Foo anim",
IIF_IN_TECH_DATABASE | IIF_DEFAULT_IN_TECH_DATABASE
};
static intel_data expected_bar = {
"Bar name default", // XSTR id 3002
"Bar desc default", // XSTR id 3003
"Bar name", // XSTR id 3002
"Bar desc", // XSTR id 3003
"Bar anim",
0
};
static intel_data expected_baz = {
"Baz name default", // XSTR id 3004
"Baz desc default", // XSTR id 3005
"Baz name", // XSTR id 3004
"Baz desc", // XSTR id 3005
"Baz anim",
IIF_IN_TECH_DATABASE | IIF_DEFAULT_IN_TECH_DATABASE
};