mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
Strip quotes from text and improve mission notes handling
This commit is contained in:
1 parent
aede65107b
commit
1182a485ac
10 files changed
+166
-90
No files matched your search
@@ -5,6 +5,7 @@
|
||||
#include "fred.h"
|
||||
#include "CustomWingNames.h"
|
||||
#include "ship/ship.h"
|
||||
#include "management.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
@@ -86,6 +87,19 @@ void CustomWingNames::OnOK()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
|
||||
strip_quotation_marks(m_starting_1);
|
||||
strip_quotation_marks(m_starting_2);
|
||||
strip_quotation_marks(m_starting_3);
|
||||
|
||||
strip_quotation_marks(m_squadron_1);
|
||||
strip_quotation_marks(m_squadron_2);
|
||||
strip_quotation_marks(m_squadron_3);
|
||||
strip_quotation_marks(m_squadron_4);
|
||||
strip_quotation_marks(m_squadron_5);
|
||||
|
||||
strip_quotation_marks(m_tvt_1);
|
||||
strip_quotation_marks(m_tvt_2);
|
||||
|
||||
if (strcmp(m_starting_1, m_tvt_1))
|
||||
{
|
||||
MessageBox("The first starting wing and the first team-versus-team wing must have the same wing name.");
|
||||
@@ -114,7 +128,6 @@ void CustomWingNames::OnOK()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// copy starting wings
|
||||
strcpy_s(Starting_wing_names[0], m_starting_1);
|
||||
strcpy_s(Starting_wing_names[1], m_starting_2);
|
||||
|
||||
@@ -205,6 +205,18 @@ void deconvert_multiline_string(SCP_string &dest, const CString &str)
|
||||
replace_all(dest, "\r\n", "\n");
|
||||
}
|
||||
|
||||
void strip_quotation_marks(CString& str) { str.Remove('\"'); }
|
||||
|
||||
void pad_with_newline(CString& str, int max_size) {
|
||||
int len = str.GetLength();
|
||||
if (!len) {
|
||||
len = 1;
|
||||
}
|
||||
if (str[len - 1] != '\n' && len < max_size) {
|
||||
str += _T("\n");
|
||||
}
|
||||
}
|
||||
|
||||
// medal_stuff Medals[NUM_MEDALS];
|
||||
/*
|
||||
void parse_medal_tbl()
|
||||
|
||||
+86
-87
@@ -1,34 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
||||
*
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* source.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MANAGEMENT_H__
|
||||
#define __MANAGEMENT_H__
|
||||
|
||||
#include <afxmt.h>
|
||||
#include "globalincs/pstypes.h"
|
||||
#include "ship/ship.h"
|
||||
#include "ai/aigoals.h"
|
||||
#include "globalincs/pstypes.h"
|
||||
#include "jumpnode/jumpnode.h"
|
||||
#include "ship/ship.h"
|
||||
#include <afxmt.h>
|
||||
|
||||
|
||||
#define SHIP_FILTER_PLAYERS (1<<0) // set: add players to list as well
|
||||
#define SHIP_FILTER_FLYABLE (1<<1) // set: filter out non-flyable ships
|
||||
#define SHIP_FILTER_PLAYERS (1 << 0) // set: add players to list as well
|
||||
#define SHIP_FILTER_FLYABLE (1 << 1) // set: filter out non-flyable ships
|
||||
|
||||
extern int cur_object_index;
|
||||
extern int cur_ship;
|
||||
extern int cur_wing;
|
||||
extern int cur_wing_index;
|
||||
extern int cur_model_index;
|
||||
extern waypoint *cur_waypoint;
|
||||
extern waypoint_list *cur_waypoint_list;
|
||||
extern waypoint* cur_waypoint;
|
||||
extern waypoint_list* cur_waypoint_list;
|
||||
extern int Update_ship;
|
||||
extern int Update_wing;
|
||||
|
||||
@@ -36,12 +33,12 @@ extern ai_goal_list Ai_goal_list[];
|
||||
extern int Ai_goal_list_size;
|
||||
|
||||
// alternate ship name and callsign stuff
|
||||
extern char Fred_alt_names[MAX_SHIPS][NAME_LENGTH+1];
|
||||
extern char Fred_callsigns[MAX_SHIPS][NAME_LENGTH+1];
|
||||
extern char Fred_alt_names[MAX_SHIPS][NAME_LENGTH + 1];
|
||||
extern char Fred_callsigns[MAX_SHIPS][NAME_LENGTH + 1];
|
||||
|
||||
extern int wing_objects[MAX_WINGS][MAX_SHIPS_PER_WING];
|
||||
extern int wing_objects[MAX_WINGS][MAX_SHIPS_PER_WING];
|
||||
|
||||
extern char *Docking_bay_list[];
|
||||
extern char* Docking_bay_list[];
|
||||
|
||||
extern char Fred_exe_dir[512];
|
||||
extern char Fred_base_dir[512];
|
||||
@@ -62,85 +59,87 @@ extern bool Show_iff[];
|
||||
|
||||
extern CCriticalSection CS_cur_object_index;
|
||||
|
||||
void string_copy(char *dest, const CString &src, size_t max_len, int modify = 0);
|
||||
void string_copy(SCP_string &dest, const CString &src, int modify = 0);
|
||||
void convert_multiline_string(CString &dest, const SCP_string &src);
|
||||
void convert_multiline_string(CString &dest, const char *src);
|
||||
void deconvert_multiline_string(char *dest, const CString &str, int max_len);
|
||||
void deconvert_multiline_string(SCP_string &dest, const CString &str);
|
||||
void string_copy(char* dest, const CString& src, size_t max_len, int modify = 0);
|
||||
void string_copy(SCP_string& dest, const CString& src, int modify = 0);
|
||||
void convert_multiline_string(CString& dest, const SCP_string& src);
|
||||
void convert_multiline_string(CString& dest, const char* src);
|
||||
void deconvert_multiline_string(char* dest, const CString& str, int max_len);
|
||||
void deconvert_multiline_string(SCP_string& dest, const CString& str);
|
||||
void strip_quotation_marks(CString& str);
|
||||
void pad_with_newline(CString& str, int max_size);
|
||||
|
||||
bool fred_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps);
|
||||
void set_physics_controls();
|
||||
int dup_object(object *objp);
|
||||
int create_object_on_grid(int waypoint_instance = -1);
|
||||
int create_object(vec3d *pos, int waypoint_instance = -1);
|
||||
int create_player(int num, vec3d *pos, matrix *orient, int type = -1, int init = 1);
|
||||
void create_new_mission();
|
||||
void reset_mission();
|
||||
void clear_mission();
|
||||
int query_valid_object(int index = cur_object_index);
|
||||
int query_valid_ship(int index = cur_object_index);
|
||||
int query_valid_waypoint(int index = cur_object_index);
|
||||
void set_cur_indices(int obj = -1);
|
||||
void set_cur_object_index(int obj = -1);
|
||||
int delete_object(int obj);
|
||||
int delete_object(object *ptr);
|
||||
int delete_ship(int ship);
|
||||
void delete_marked();
|
||||
void delete_reinforcement(int num);
|
||||
int delete_ship_from_wing(int ship = cur_ship);
|
||||
int find_free_wing();
|
||||
int query_object_in_wing(int obj = cur_object_index);
|
||||
void mark_object(int obj);
|
||||
void unmark_object(int obj);
|
||||
void unmark_all();
|
||||
void clear_menu(CMenu *ptr);
|
||||
void generate_wing_popup_menu(CMenu *mptr, int first_id, int state);
|
||||
void generate_ship_popup_menu(CMenu *mptr, int first_id, int state, int filter = 0);
|
||||
int string_lookup(const CString &str1, char *strlist[], int max);
|
||||
int update_dialog_boxes();
|
||||
void set_cur_wing(int wing);
|
||||
int gray_menu_tree(CMenu *base);
|
||||
int query_initial_orders_conflict(int wing);
|
||||
int query_initial_orders_empty(ai_goal *ai_goals);
|
||||
int set_reinforcement(char *name, int state);
|
||||
int get_docking_list(int model_index);
|
||||
int rename_ship(int ship, char *name);
|
||||
void fix_ship_name(int ship);
|
||||
int internal_integrity_check();
|
||||
void correct_marking();
|
||||
int get_ship_from_obj(int obj);
|
||||
int get_ship_from_obj(object *objp);
|
||||
void set_valid_dock_points(int ship, int type, CComboBox *box);
|
||||
void ai_update_goal_references(int type, const char *old_name, const char *new_name);
|
||||
int query_referenced_in_ai_goals(int type, const char *name);
|
||||
int advanced_stricmp(char *one, char *two);
|
||||
int reference_handler(char *name, int type, int obj);
|
||||
int orders_reference_handler(int code, char *msg);
|
||||
int sexp_reference_handler(int node, int code, char *msg);
|
||||
char *object_name(int obj);
|
||||
bool fred_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps);
|
||||
void set_physics_controls();
|
||||
int dup_object(object* objp);
|
||||
int create_object_on_grid(int waypoint_instance = -1);
|
||||
int create_object(vec3d* pos, int waypoint_instance = -1);
|
||||
int create_player(int num, vec3d* pos, matrix* orient, int type = -1, int init = 1);
|
||||
void create_new_mission();
|
||||
void reset_mission();
|
||||
void clear_mission();
|
||||
int query_valid_object(int index = cur_object_index);
|
||||
int query_valid_ship(int index = cur_object_index);
|
||||
int query_valid_waypoint(int index = cur_object_index);
|
||||
void set_cur_indices(int obj = -1);
|
||||
void set_cur_object_index(int obj = -1);
|
||||
int delete_object(int obj);
|
||||
int delete_object(object* ptr);
|
||||
int delete_ship(int ship);
|
||||
void delete_marked();
|
||||
void delete_reinforcement(int num);
|
||||
int delete_ship_from_wing(int ship = cur_ship);
|
||||
int find_free_wing();
|
||||
int query_object_in_wing(int obj = cur_object_index);
|
||||
void mark_object(int obj);
|
||||
void unmark_object(int obj);
|
||||
void unmark_all();
|
||||
void clear_menu(CMenu* ptr);
|
||||
void generate_wing_popup_menu(CMenu* mptr, int first_id, int state);
|
||||
void generate_ship_popup_menu(CMenu* mptr, int first_id, int state, int filter = 0);
|
||||
int string_lookup(const CString& str1, char* strlist[], int max);
|
||||
int update_dialog_boxes();
|
||||
void set_cur_wing(int wing);
|
||||
int gray_menu_tree(CMenu* base);
|
||||
int query_initial_orders_conflict(int wing);
|
||||
int query_initial_orders_empty(ai_goal* ai_goals);
|
||||
int set_reinforcement(char* name, int state);
|
||||
int get_docking_list(int model_index);
|
||||
int rename_ship(int ship, char* name);
|
||||
void fix_ship_name(int ship);
|
||||
int internal_integrity_check();
|
||||
void correct_marking();
|
||||
int get_ship_from_obj(int obj);
|
||||
int get_ship_from_obj(object* objp);
|
||||
void set_valid_dock_points(int ship, int type, CComboBox* box);
|
||||
void ai_update_goal_references(int type, const char* old_name, const char* new_name);
|
||||
int query_referenced_in_ai_goals(int type, const char* name);
|
||||
int advanced_stricmp(char* one, char* two);
|
||||
int reference_handler(char* name, int type, int obj);
|
||||
int orders_reference_handler(int code, char* msg);
|
||||
int sexp_reference_handler(int node, int code, char* msg);
|
||||
char* object_name(int obj);
|
||||
const char* get_order_name(int order);
|
||||
void object_moved(object *ptr);
|
||||
int invalidate_references(char *name, int type);
|
||||
int query_whole_wing_marked(int wing);
|
||||
void generate_weaponry_usage_list(int team, int *arr);
|
||||
void generate_weaponry_usage_list(int *arr, int wing);
|
||||
void generate_ship_usage_list(int *arr, int wing);
|
||||
void object_moved(object* ptr);
|
||||
int invalidate_references(char* name, int type);
|
||||
int query_whole_wing_marked(int wing);
|
||||
void generate_weaponry_usage_list(int team, int* arr);
|
||||
void generate_weaponry_usage_list(int* arr, int wing);
|
||||
void generate_ship_usage_list(int* arr, int wing);
|
||||
|
||||
CJumpNode *jumpnode_get_by_name(const CString& name);
|
||||
CJumpNode* jumpnode_get_by_name(const CString& name);
|
||||
|
||||
// function and defines to use when adding ships to combo boxes
|
||||
#define SHIPS_2_COMBO_SPECIAL (1<<0)
|
||||
#define SHIPS_2_COMBO_ALL_SHIPS (1<<1)
|
||||
#define SHIPS_2_COMBO_DOCKING_BAY_ONLY (1<<2)
|
||||
#define SHIPS_2_COMBO_SPECIAL (1 << 0)
|
||||
#define SHIPS_2_COMBO_ALL_SHIPS (1 << 1)
|
||||
#define SHIPS_2_COMBO_DOCKING_BAY_ONLY (1 << 2)
|
||||
|
||||
extern void management_add_ships_to_combo( CComboBox *box, int flags );
|
||||
extern void management_add_ships_to_combo(CComboBox* box, int flags);
|
||||
|
||||
// Goober5000
|
||||
extern int wing_is_player_wing(int wing);
|
||||
extern void update_custom_wing_indexes();
|
||||
extern void stuff_special_arrival_anchor_name(char *buf, int iff_index, int restrict_to_players, int retail_format);
|
||||
extern void stuff_special_arrival_anchor_name(char *buf, int anchor_num, int retail_format);
|
||||
extern void update_texture_replacements(const char *old_name, const char *new_name);
|
||||
extern void stuff_special_arrival_anchor_name(char* buf, int iff_index, int restrict_to_players, int retail_format);
|
||||
extern void stuff_special_arrival_anchor_name(char* buf, int anchor_num, int retail_format);
|
||||
extern void update_texture_replacements(const char* old_name, const char* new_name);
|
||||
|
||||
#endif
|
||||
@@ -296,6 +296,18 @@ void CMissionNotesDlg::OnOK()
|
||||
set_modified();
|
||||
}
|
||||
|
||||
//if there's a odd number of quotation marks, the mission won't parse
|
||||
//If there are an even number, nothing after the first one appears
|
||||
//So just get rid of them
|
||||
strip_quotation_marks(m_mission_title);
|
||||
strip_quotation_marks(m_designer_name);
|
||||
strip_quotation_marks(m_mission_notes);
|
||||
strip_quotation_marks(m_mission_desc);
|
||||
strip_quotation_marks(m_squad_name);
|
||||
|
||||
// puts "$End Notes:" on a different line to ensure it's not interpreted as part of a comment
|
||||
pad_with_newline(m_mission_notes, NOTES_LENGTH - 1);
|
||||
|
||||
string_copy(The_mission.name, m_mission_title, NAME_LENGTH, 1);
|
||||
string_copy(The_mission.author, m_designer_name, NAME_LENGTH, 1);
|
||||
string_copy(The_mission.loading_screen[GR_640], m_loading_640, NAME_LENGTH,1);
|
||||
|
||||
@@ -2165,7 +2165,7 @@ int CFred_mission_save::save_mission_info() {
|
||||
|
||||
required_string_fred("$Notes:");
|
||||
parse_comments();
|
||||
fout("\n%s\n", The_mission.notes);
|
||||
fout("\n%s", The_mission.notes);
|
||||
|
||||
required_string_fred("$End Notes:");
|
||||
parse_comments(0);
|
||||
|
||||
@@ -3183,6 +3183,19 @@ void Editor::normalizeShieldSysData() {
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::strip_quotation_marks(SCP_string& str) {
|
||||
SCP_string::size_type idx = 0;
|
||||
while ((idx = str.find('\"', idx)) != SCP_string::npos) {
|
||||
str.erase(idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::pad_with_newline(SCP_string& str, int max_size) {
|
||||
if (str.back() != '\n' && str.size() < max_size) {
|
||||
str += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace fred
|
||||
} // namespace fso
|
||||
@@ -272,6 +272,9 @@ class Editor: public QObject {
|
||||
int global_error_check_player_wings(int multi);
|
||||
|
||||
const char *get_order_name(int order);
|
||||
|
||||
void strip_quotation_marks(SCP_string& str);
|
||||
void pad_with_newline(SCP_string& str, int max_size);
|
||||
};
|
||||
|
||||
} // namespace fred
|
||||
|
||||
@@ -13,6 +13,18 @@ CustomWingNamesDialogModel::CustomWingNamesDialogModel(QObject * parent, EditorV
|
||||
|
||||
bool CustomWingNamesDialogModel::apply() {
|
||||
int i;
|
||||
for (i = 0; i < MAX_STARTING_WINGS; i++) {
|
||||
strip_quotation_marks(_m_starting[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SQUADRON_WINGS; i++) {
|
||||
strip_quotation_marks(_m_squadron[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_TVT_WINGS; i++) {
|
||||
strip_quotation_marks(_m_tvt[i]);
|
||||
}
|
||||
|
||||
if (strcmp(_m_starting[0].c_str(), _m_tvt[0].c_str()) != 0)
|
||||
{
|
||||
auto button = _viewport->dialogProvider->showButtonDialog(DialogType::Error, "Custom Wing Error", "The first starting wing and the first team-versus-team wing must have the same wing name.",
|
||||
|
||||
@@ -95,6 +95,18 @@ bool MissionSpecDialogModel::apply() {
|
||||
} else {
|
||||
The_mission.contrail_threshold = CONTRAIL_THRESHOLD_DEFAULT;
|
||||
}
|
||||
|
||||
//if there's a odd number of quotation marks, the mission won't parse
|
||||
//If there are an even number, nothing after the first one appears
|
||||
//So just get rid of them
|
||||
strip_quotation_marks(_m_mission_title);
|
||||
strip_quotation_marks(_m_designer_name);
|
||||
strip_quotation_marks(_m_mission_notes);
|
||||
strip_quotation_marks(_m_mission_desc);
|
||||
strip_quotation_marks(_m_squad_name);
|
||||
|
||||
// puts "$End Notes:" on a different line to ensure it's not interpreted as part of a comment
|
||||
pad_with_newline(_m_mission_notes, NOTES_LENGTH - 1);
|
||||
|
||||
strncpy(The_mission.name, _m_mission_title.c_str(), NAME_LENGTH-1);
|
||||
strncpy(The_mission.author, _m_designer_name.c_str(), NAME_LENGTH-1);
|
||||
|
||||
@@ -1995,7 +1995,7 @@ int CFred_mission_save::save_mission_info() {
|
||||
|
||||
required_string_fred("$Notes:");
|
||||
parse_comments();
|
||||
fout("\n%s\n", The_mission.notes);
|
||||
fout("\n%s", The_mission.notes);
|
||||
|
||||
required_string_fred("$End Notes:");
|
||||
parse_comments(0);
|
||||
|
||||
Reference in new issue
Block a user