From 61ed7cedcf037ce034e43907b6c2d5f7c9374b24 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Thu, 18 Jul 2024 23:21:14 +0300 Subject: [PATCH] Fix D3Editor compilation --- editor/PreferencesDialog.cpp | 24 +++++++++++++----------- editor/gameeditor.cpp | 23 +++++++---------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/editor/PreferencesDialog.cpp b/editor/PreferencesDialog.cpp index dad96506..05ba3458 100644 --- a/editor/PreferencesDialog.cpp +++ b/editor/PreferencesDialog.cpp @@ -96,6 +96,9 @@ // PreferencesDialog.cpp : implementation file // +#include +#include + #include "stdafx.h" #include "editor.h" #include "PreferencesDialog.h" @@ -183,9 +186,11 @@ void CPreferencesDialog::OnOK() { CComboBox *combo = (CComboBox *)GetDlgItem(IDC_DEFAULT_PILOT); if (combo->GetCount()) { - combo->GetLBText(combo->GetCurSel(), Default_pilot); + char temp[_MAX_PATH]; + combo->GetLBText(combo->GetCurSel(), temp); + Default_pilot = temp; } else { - strcpy(Default_pilot, " "); + Default_pilot = " "; } Slew_key_speed = (slew_slider->GetPos() * 0.5) + 0.5; @@ -195,8 +200,7 @@ void CPreferencesDialog::OnOK() { BOOL CPreferencesDialog::OnInitDialog() { CDialog::OnInitDialog(); - char **pilotlist; - int pilot_count; + std::vector pilotlist; // TODO: Add extra initialization here CSliderCtrl *slew_slider = (CSliderCtrl *)GetDlgItem(IDC_SLEWSLIDER); @@ -218,12 +222,12 @@ BOOL CPreferencesDialog::OnInitDialog() { CComboBox *combo = (CComboBox *)GetDlgItem(IDC_DEFAULT_PILOT); combo->ResetContent(); - pilotlist = PltGetPilots(&pilot_count); - for (int i = 0; i < pilot_count; i++) { - combo->AddString(pilotlist[i]); + pilotlist = PltGetPilots(); + for (auto const &pilot : pilotlist) { + combo->AddString(pilot.c_str()); } - if (pilot_count) { - combo->SelectString(-1, Default_pilot); + if (!pilotlist.empty()) { + combo->SelectString(-1, Default_pilot.c_str()); } PltClearList(); @@ -232,8 +236,6 @@ BOOL CPreferencesDialog::OnInitDialog() { else DisableHardwareOptions(); - PltGetPilotsFree(); - return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } diff --git a/editor/gameeditor.cpp b/editor/gameeditor.cpp index c85ede76..2fe8fcba 100644 --- a/editor/gameeditor.cpp +++ b/editor/gameeditor.cpp @@ -484,20 +484,18 @@ * $NoKeywords: $ */ +#include + #include "stdafx.h" #include "editor.h" #include "MainFrm.h" #include "ui.h" -#include "render.h" #include "pserror.h" #include "gr.h" #include "mono.h" -#include "init.h" #include "game.h" #include "descent.h" -#include "Application.h" -#include "AppDatabase.h" #include "program.h" #include "ddio.h" #include "object.h" @@ -508,18 +506,13 @@ #include "player.h" #include "loadlevel.h" #include "renderer.h" -#include "BOA.h" -//@@#include "d3x.h" -//@@#include "d3xdebug.h" #include "ObjScript.h" #include "controls.h" -#include "multi.h" #include "3d.h" #include "ddvid.h" #include "gamefont.h" #include "newui.h" #include "pilot.h" -#include "streamaudio.h" #include "D3ForceFeedback.h" #include "d3music.h" #include "osiris_dll.h" @@ -938,20 +931,18 @@ void InitEditGameSystems() { Current_pilot.set_filename(Default_pilot); PltReadFile(&Current_pilot, true, true); } else { - strcpy(Default_pilot, " "); + Default_pilot = " "; Current_pilot.set_filename(""); } } void InitGameEditSystems() { // UnLoad the pilot and fill in the default - char p_fname[_MAX_FNAME]; - - Current_pilot.get_filename(p_fname); - if (p_fname[0] != '\0') - strcpy(Default_pilot, p_fname); + std::string p_fname = Current_pilot.get_filename(); + if (p_fname.empty()) + Default_pilot = " "; else - strcpy(Default_pilot, " "); + Default_pilot = p_fname; // reset ship permissions PlayerResetShipPermissions(-1, true);