Skip to content

Commit b970e22

Browse files
committed
add additional double quote conversion to FRED and qtFRED
Any place in FRED that uses XSTR is susceptible to double quotes interfering with the standard XSTR format, not just the expected briefing, debriefing, messages, etc. This PR adds `lcl_fred_replace_stuff()` - which handles not only quotes but semicolons and slashes as well - to the other places where XSTR is used. (Note that quotes are handled just fine in non-XSTR fields. Semicolons will still truncate non-XSTR fields, but addressing that is beyond the scope of this PR as it would require editing every text field in FRED. Fortunately, errant semicolons merely modify the text as opposed to corrupting the mission file.) Fixes scp-fs2open#7005 in both FRED and qtFRED; tested in both. Caveat aedificator: the briefing editor is not yet implemented in qtFRED, so the relevant fixes to briefing icon labels and closeup labels cannot yet be ported over.
1 parent a6f9337 commit b970e22

11 files changed

+25
-1
lines changed

fred2/briefingeditordlg.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ void briefing_editor_dlg::update_data(int update)
467467
ptr->icons[m_last_icon].id = m_id;
468468

469469
string_copy(buf, m_icon_label, MAX_LABEL_LEN - 1);
470+
lcl_fred_replace_stuff(buf, MAX_LABEL_LEN - 1);
470471
if (stricmp(ptr->icons[m_last_icon].label, buf) && !m_change_local) {
471472
set_modified();
472473
reset_icon_loop(m_last_stage);
@@ -476,6 +477,7 @@ void briefing_editor_dlg::update_data(int update)
476477
strcpy_s(ptr->icons[m_last_icon].label, buf);
477478

478479
string_copy(buf, m_icon_closeup_label, MAX_LABEL_LEN - 1);
480+
lcl_fred_replace_stuff(buf, MAX_LABEL_LEN - 1);
479481
if (stricmp(ptr->icons[m_last_icon].closeup_label, buf) && !m_change_local) {
480482
set_modified();
481483
reset_icon_loop(m_last_stage);

fred2/eventeditor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,8 @@ void event_editor::save_event(int e)
911911
}
912912

913913
// handle objective text
914+
lcl_fred_replace_stuff(m_obj_text);
915+
lcl_fred_replace_stuff(m_obj_key_text);
914916
m_events[e].objective_text = (LPCTSTR)m_obj_text;
915917
m_events[e].objective_key_text = (LPCTSTR)m_obj_key_text;
916918

fred2/initialstatus.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ void initial_status::change_subsys()
599599

600600
// update cargo name
601601
if (strlen(m_cargo_name) > 0) { //-V805
602+
lcl_fred_replace_stuff(m_cargo_name);
602603
cargo_index = string_lookup(m_cargo_name, Cargo_names, Num_cargo);
603604
if (cargo_index == -1) {
604605
if (Num_cargo < MAX_CARGO);

fred2/jumpnodedlg.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ int jumpnode_dlg::update_data()
303303
m_name = _T(jnp->GetName());
304304
UpdateData(FALSE);
305305
}
306-
306+
307+
lcl_fred_replace_stuff(m_display);
308+
307309
strcpy_s(old_name, jnp->GetName());
308310
jnp->SetName((LPCSTR) m_name);
309311
jnp->SetDisplayName((m_display.CompareNoCase("<none>") == 0) ? m_name : m_display);

fred2/missiongoalsdlg.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ void CMissionGoalsDlg::OnChangeGoalDesc()
436436
}
437437

438438
UpdateData(TRUE);
439+
lcl_fred_replace_stuff(m_goal_desc);
439440
string_copy(m_goals[cur_goal].message, m_goal_desc);
440441
}
441442

fred2/shipeditordlg.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,8 @@ int CShipEditorDlg::update_ship(int ship)
12911291
CComboBox *box;
12921292
int persona;
12931293

1294+
lcl_fred_replace_stuff(m_ship_display_name);
1295+
12941296
// the display name was precalculated, so now just assign it
12951297
if (m_ship_display_name == m_ship_name || m_ship_display_name.CompareNoCase("<none>") == 0)
12961298
{
@@ -1332,6 +1334,7 @@ int CShipEditorDlg::update_ship(int ship)
13321334
MODIFY(Ships[ship].weapons.ai_class, m_ai_class);
13331335
}
13341336
if (strlen(m_cargo1)) {
1337+
lcl_fred_replace_stuff(m_cargo1);
13351338
z = string_lookup(m_cargo1, Cargo_names, Num_cargo);
13361339
if (z == -1) {
13371340
if (Num_cargo < MAX_CARGO) {

qtfred/src/mission/dialogs/JumpNodeEditorDialogModel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "globalincs/linklist.h"
44
#include <jumpnode/jumpnode.h>
5+
#include <localization/localize.h>
56
#include <mission/missionparse.h>
67
#include <mission/object.h>
78
#include <model/model.h>
@@ -39,6 +40,8 @@ bool JumpNodeEditorDialogModel::apply()
3940
std::strncpy(old_name_buf, jnp->GetName(), NAME_LENGTH - 1);
4041
old_name_buf[NAME_LENGTH - 1] = '\0';
4142

43+
lcl_fred_replace_stuff(_display);
44+
4245
jnp->SetName(_name.c_str());
4346
jnp->SetDisplayName(lcase_equal(_display, "<none>") ? _name.c_str() : _display.c_str());
4447

qtfred/src/mission/dialogs/MissionGoalsDialogModel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <localization/localize.h>
12
#include "MissionGoalsDialogModel.h"
23

34

@@ -167,6 +168,7 @@ mission_goal& MissionGoalsDialogModel::createNewGoal() {
167168
void MissionGoalsDialogModel::setCurrentGoalMessage(const char* text) {
168169
Assertion(isCurrentGoalValid(), "Current goal is not valid!");
169170
getCurrentGoal().message = text;
171+
lcl_fred_replace_stuff(getCurrentGoal().message);
170172

171173
set_modified();
172174
modelChanged();

qtfred/src/mission/dialogs/ShipEditor/ShipEditorDialogModel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "mission/missionmessage.h"
1515

1616
#include <globalincs/linklist.h>
17+
#include <localization/localize.h>
1718
#include <mission/object.h>
1819

1920
#include <QtWidgets>
@@ -636,6 +637,8 @@ namespace fso {
636637
int z, d;
637638
SCP_string str;
638639

640+
lcl_fred_replace_stuff(_m_ship_display_name);
641+
639642
// the display name was precalculated, so now just assign it
640643
if (_m_ship_display_name == _m_ship_name || stricmp(_m_ship_display_name.c_str(), "<none>") == 0)
641644
{
@@ -671,6 +674,7 @@ namespace fso {
671674
Ships[ship].weapons.ai_class = _m_ai_class;
672675
}
673676
if (!_m_cargo1.empty()) {
677+
lcl_fred_replace_stuff(_m_cargo1);
674678
z = string_lookup(_m_cargo1.c_str(), Cargo_names, Num_cargo);
675679
if (z == -1) {
676680
if (Num_cargo < MAX_CARGO) {

qtfred/src/mission/dialogs/ShipEditor/ShipInitialStatusDialogModel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "mission/object.h"
44

55
#include <globalincs/linklist.h>
6+
#include <localization/localize.h>
67

78
#include <QtWidgets>
89
#include <object/objectdock.cpp>
@@ -795,6 +796,7 @@ void ShipInitialStatusDialogModel::change_subsys(const int new_subsys)
795796

796797
// update cargo name
797798
if (!m_cargo_name.empty()) { //-V805
799+
lcl_fred_replace_stuff(m_cargo_name);
798800
cargo_index = string_lookup(m_cargo_name.c_str(), Cargo_names, Num_cargo);
799801
if (cargo_index == -1) {
800802
if (Num_cargo < MAX_CARGO) {

0 commit comments

Comments
 (0)