Skip to content

Commit

Permalink
Internal editor: minimal compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lgt2x committed May 27, 2024
1 parent 358718b commit b2f5694
Show file tree
Hide file tree
Showing 45 changed files with 371 additions and 236 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
CC: ${{ matrix.os.cc }}
CXX: ${{ matrix.os.cxx }}
VCPKG_ROOT: C:/vcpkg
run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON
run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=ON

- name: Build ${{ matrix.build_type }}
run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }} --verbose
Expand All @@ -94,4 +94,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Descent3_${{ matrix.build_type }}_${{ matrix.os.name }}
path: ${{ github.workspace }}/builds/${{ matrix.os.preset }}/installed/
path: ${{ github.workspace }}/builds/${{ matrix.os.preset }}/installed/
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ option(FORCE_PORTABLE_INSTALL "Install all files into local directory defined by
option(ENABLE_LOGGER "Enable logging to the terminal" OFF)
option(BUILD_TESTING "Enable testing. Requires GTest." OFF)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(BUILD_EDITOR "Build internal editor" OFF)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -104,7 +108,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows.h defines to avoid as many issues as possible.
add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX NODRAWTEXT NOBITMAP NOMCX NOSERVICE NOHELP
add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX NODRAWTEXT NOBITMAP NOMCX NOSERVICE
#[[NOGDI]] # We need GDI for now, enable when GDI is actually not needed (or when all windows.h mentions are gone)
)

Expand Down Expand Up @@ -204,9 +208,11 @@ add_subdirectory(libmve)
add_subdirectory(md5)
add_subdirectory(libacm)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")

if(BUILD_EDITOR AND CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_subdirectory(editor)
endif()

add_subdirectory(Descent3)

add_subdirectory(tools)
Expand Down
22 changes: 11 additions & 11 deletions Descent3/Briefing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void ReplaceHotTag(char *string, int tag) {

// returns true if there were hot tags and it had to allocate memory for dest (so it needs to be freed)
#define MEMORY_BLOCK 50
bool ParseForHotTags(const char *src, char **dest) {
bool ParseForHotTags(char *src, char **dest) {
bool ret = false;
const char *curr_ptr = src;
char *dest_ptr;
Expand Down Expand Up @@ -456,7 +456,7 @@ bool PlayBriefing(tTelComInfo *tcs) {
return true;
}

void PBAddTextEffect(LPTCTEXTDESC desc, const char *text, const char *description, int id) {
void PBAddTextEffect(LPTCTEXTDESC desc, char *text, char *description, int id) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen) {
char *new_text = NULL;
const bool new_stuff = ParseForHotTags(text, &new_text);
Expand All @@ -469,33 +469,33 @@ void PBAddTextEffect(LPTCTEXTDESC desc, const char *text, const char *descriptio
}
}

void PBAddBmpEffect(LPTCBMPDESC desc, const char *description) {
void PBAddBmpEffect(LPTCBMPDESC desc, char *description) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen)
CreateBitmapEffect(desc, MONITOR_MAIN, current_screen);
}

void PBAddMovieEffect(LPTCMOVIEDESC desc, const char *description) {
void PBAddMovieEffect(LPTCMOVIEDESC desc, char *description) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen)
CreateMovieEffect(desc, MONITOR_MAIN, current_screen);
}

void PBAddBkgEffect(LPTCBKGDESC desc, const char *description) {
void PBAddBkgEffect(LPTCBKGDESC desc, char *description) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen) {
mprintf(0, "PB: Add Bkg\n");
}
}

void PBAddPolyEffect(LPTCPOLYDESC desc, const char *description) {
void PBAddPolyEffect(LPTCPOLYDESC desc, char *description) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen)
CreatePolyModelEffect(desc, MONITOR_MAIN, current_screen);
}

void PBAddSoundEffect(LPTCSNDDESC desc, const char *description) {
void PBAddSoundEffect(LPTCSNDDESC desc, char *description) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen)
CreateSoundEffect(desc, MONITOR_MAIN, current_screen);
}

void PBAddButtonEffect(LPTCBUTTONDESC desc, const char *description, int id) {
void PBAddButtonEffect(LPTCBUTTONDESC desc, char *description, int id) {
if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen) {
desc->x += osb_xoff;
desc->y += osb_yoff;
Expand All @@ -504,7 +504,7 @@ void PBAddButtonEffect(LPTCBUTTONDESC desc, const char *description, int id) {
}
}

void PBStartScreen(int screen_num, const char *description, const char *layout, uint32_t mask_set, uint32_t mask_unset) {
void PBStartScreen(int screen_num, char *description, char *layout, uint32_t mask_set, uint32_t mask_unset) {
if (!IsMissionMaskOK(mask_set, mask_unset)) {
ok_to_parse_screen = false;
skipped_screens++;
Expand Down Expand Up @@ -579,7 +579,7 @@ bool PBLoopCallback() {
return ret;
}

void PBSetTitle(const char *title) {
void PBSetTitle(char *title) {
gottitle = true;
strcpy(pbtitle, title);
}
Expand All @@ -594,7 +594,7 @@ void PBSetGlitch(float amount) {
TelcomEnableGlitch(amount);
}

void PBAddVoice(const char *filename, int flags, const char *description) {}
void PBAddVoice(char *filename, int flags,char *description) {}

bool ParseBriefing(const char *filename, tTelComInfo *tcs) {
if (!cfexist(filename)) {
Expand Down
40 changes: 20 additions & 20 deletions Descent3/BriefingParse.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@
#define PBERR_NOERR 0

typedef struct {
void (*AddTextEffect)(LPTCTEXTDESC desc, const char *text, const char *description, int id);
void (*AddBmpEffect)(LPTCBMPDESC desc, const char *description);
void (*AddMovieEffect)(LPTCMOVIEDESC desc, const char *description);
void (*AddBkgEffect)(LPTCBKGDESC desc, const char *description);
void (*AddPolyEffect)(LPTCPOLYDESC desc, const char *description);
void (*AddSoundEffect)(LPTCSNDDESC desc, const char *description);
void (*AddButtonEffect)(LPTCBUTTONDESC desc, const char *description, int id);
void (*StartScreen)(int screen_num, const char *description, const char *layout, uint32_t mask_set, uint32_t mask_unset);
void (*AddTextEffect)(LPTCTEXTDESC desc, char *text, char *description, int id);
void (*AddBmpEffect)(LPTCBMPDESC desc, char *description);
void (*AddMovieEffect)(LPTCMOVIEDESC desc, char *description);
void (*AddBkgEffect)(LPTCBKGDESC desc, char *description);
void (*AddPolyEffect)(LPTCPOLYDESC desc, char *description);
void (*AddSoundEffect)(LPTCSNDDESC desc, char *description);
void (*AddButtonEffect)(LPTCBUTTONDESC desc, char *description, int id);
void (*StartScreen)(int screen_num, char *description, char *layout, uint32_t mask_set, uint32_t mask_unset);
void (*EndScreen)();
bool (*LoopCallback)();
void (*SetTitle)(const char *title);
void (*SetTitle)(char *title);
void (*SetStatic)(float amount);
void (*SetGlitch)(float amount);
void (*AddVoice)(const char *filename, int flags, const char *description);
void (*AddVoice)(char *filename, int flags,char *description);
} tBriefParseCallbacks;

typedef struct {
Expand All @@ -93,20 +93,20 @@ class CBriefParse {
int ParseBriefing(const char *filename);

private:
void (*AddTextEffect)(LPTCTEXTDESC desc, const char *text, const char *description, int id);
void (*AddBmpEffect)(LPTCBMPDESC desc, const char *description);
void (*AddMovieEffect)(LPTCMOVIEDESC desc, const char *description);
void (*AddBkgEffect)(LPTCBKGDESC desc, const char *description);
void (*AddPolyEffect)(LPTCPOLYDESC desc, const char *description);
void (*AddSoundEffect)(LPTCSNDDESC desc, const char *description);
void (*AddButtonEffect)(LPTCBUTTONDESC desc, const char *description, int id);
void (*StartScreen)(int screen_num, const char *desc, const char *layout, uint32_t mask_set, uint32_t mask_unset);
void (*AddTextEffect)(LPTCTEXTDESC desc, char *text, char *description, int id);
void (*AddBmpEffect)(LPTCBMPDESC desc, char *description);
void (*AddMovieEffect)(LPTCMOVIEDESC desc, char *description);
void (*AddBkgEffect)(LPTCBKGDESC desc, char *description);
void (*AddPolyEffect)(LPTCPOLYDESC desc, char *description);
void (*AddSoundEffect)(LPTCSNDDESC desc, char *description);
void (*AddButtonEffect)(LPTCBUTTONDESC desc, char *description, int id);
void (*StartScreen)(int screen_num, char *desc, char *layout, uint32_t mask_set, uint32_t mask_unset);
void (*EndScreen)();
bool (*LoopCallback)();
void (*SetTitle)(const char *title);
void (*SetTitle)(char *title);
void (*SetStatic)(float amount);
void (*SetGlitch)(float amount);
void (*AddVoice)(const char *filename, int flags, const char *description);
void (*AddVoice)(char *filename, int flags, char *description);

void ParseError(const char *msg, const char *p = NULL);
const char *ParseComma(const char *p);
Expand Down
2 changes: 1 addition & 1 deletion Descent3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ add_executable(Descent3
${HEADERS} ${CPPS} ${PLATFORM_CPPS} ${INCS}
)
target_link_libraries(Descent3
2dlib AudioEncode bitmap cfile czip d3music dd_video ddebug ddio libmve libacm
2dlib AudioEncode bitmap cfile czip d3music dd_video ddio libmve libacm
fix grtext manage mem misc model module movie stream_audio
music networking physics renderer rtperformance sndlib ui unzip vecmat md5
${PLATFORM_LIBS})
Expand Down
2 changes: 0 additions & 2 deletions Descent3/lightmap_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ lightmap_info *LightmapInfo = NULL;

static uint16_t *Free_lmi_list = NULL;

static void CloseLightmapInfos();

void CloseLightmapInfos() {
bool final_lightmap = true;

Expand Down
2 changes: 2 additions & 0 deletions Descent3/lightmap_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ int lmi_w(int handle);
// Gets the height of this lightmap_info handle
int lmi_h(int handle);

void CloseLightmapInfos();

// Softens the edges of lightmaps so there are fewer artifaces
void ShadeLightmapInfoEdges(int type);
void BlurLightmapInfos(int type);
Expand Down
2 changes: 1 addition & 1 deletion editor/BriefTextEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ BOOL CBriefTextEdit::OnInitDialog()

int layout = -1;

for(i=0;i<(*PBnum_layouts);i++){
for(int i=0;i<(*PBnum_layouts);i++){
if(!stricmp(Briefing_screens[m_Screen].layout,PBlayouts[i].filename))
layout = i;
}
Expand Down
46 changes: 16 additions & 30 deletions editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Set headers and source files
set(HEADERS
../descent3/aiambient.h
../descent3/AIGoal.h
Expand Down Expand Up @@ -285,6 +284,7 @@ set(HEADERS
WorldSoundsDialog.h
WorldTexturesDialog.h
WorldWeaponsDialog.h
d3x.h
)

set(SOURCE
Expand Down Expand Up @@ -511,6 +511,7 @@ set(SOURCE
QuickCompile.cpp
rad_cast.cpp
rad_init.cpp
rad_hemicube.cpp
Read3ds.cpp
RobotEditWeaponsDialog.cpp
roomkeypaddialog.cpp
Expand Down Expand Up @@ -561,39 +562,21 @@ set(SOURCE
editor.rc
)

# Set platform-specific sources and libraries
if (WIN32)
set(PLATFORM_LIBS dd_sndlib misc libimgui devcon dd_grwin32 dd_vidwin32 ddio_win win32 wsock32.lib winmm.lib Glu32.lib)
set(PLATFORM_SOURCES ../descent3/winmain.cpp)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC")
elseif (UNIX AND NOT APPLE)
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx ${SDL_LIBRARY} caca asound audio esd aa directfb m dl GLU)
set(PLATFORM_SOURCES loki_utils.c lnxmain.cpp)
set(CMAKE_EXE_LINKER_FLAGS "/usr/lib/libpulse-simple.so.0")
elseif (APPLE)
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx ${SDL_LIBRARY} ncurses)
set(PLATFORM_SOURCES loki_utils.c lnxmain.cpp SDLMain.m)
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework Cocoa -framework OpenGL -framework Carbon")
endif()
# Editor only works in Windows
set(PLATFORM_LIBS dd_grwin32 win32 wsock32.lib winmm.lib
${DSOUND_LIBRARY} ${DINPUT_LIBRARY} ${DXGUID_LIBRARY} ${DDRAW_LIBRARY})
set(PLATFORM_SOURCES ../descent3/winmain.cpp)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC")

# Include directories
include_directories(../lib ../ ../manage/)

# Add executable
add_executable(Descent3Editor ${HEADERS} ${SOURCE} ${PLATFORM_SOURCES})
target_include_directories(Descent3Editor PRIVATE ../lib ../ ../manage/ ${PROJECT_BINARY_DIR}/lib)

if(MSVC)
target_compile_definitions(Descent3Editor PUBLIC _CRT_SECURE_NO_WARNINGS _AFXDLL)
endif()

target_compile_definitions(Descent3Editor PUBLIC EDITOR)

if (MSVC)
target_compile_definitions(Descent3Editor PUBLIC _CRT_SECURE_NO_WARNINGS _AFXDLL EDITOR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} /Zc:forScope-")
endif()

target_include_directories(Descent3Editor PRIVATE ${PROJECT_BINARY_DIR}/lib)

# Link libraries
target_link_libraries(Descent3Editor
2dlib
Expand All @@ -602,13 +585,16 @@ target_link_libraries(Descent3Editor
cfile
czip
d3music
ddio_common
dd_video
ddio
ddebug
libmve
libacm
fix
grtext
manage
mem
misc
model
module
movie
Expand All @@ -626,8 +612,8 @@ target_link_libraries(Descent3Editor
${PLATFORM_LIBS}
)

add_definitions(-DEDITOR)

if (WIN32)
set_target_properties(Descent3Editor PROPERTIES WIN32_EXECUTABLE ON)
endif()
endif()

install(TARGETS Descent3Editor RUNTIME)
6 changes: 4 additions & 2 deletions editor/D3XStringEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ END_MESSAGE_MAP()

void CD3XStringEditor::OnLoadscript()
{
#if 0
// open either a level or a .d3x file
char openpath[PSPATHNAME_LEN+1];

Expand Down Expand Up @@ -125,6 +126,7 @@ void CD3XStringEditor::OnLoadscript()
m_pathname = openpath;
m_modified = false;
}
#endif
}

void CD3XStringEditor::OnSelchangeStringlist()
Expand Down Expand Up @@ -165,7 +167,7 @@ void CD3XStringEditor::OnKillfocusStringedit()
void CD3XStringEditor::OnSave()
{
ASSERT(m_modified);

#if 0
// save program by loading it in first and reconstructin a new program obhect
CFILE *fp = cfopen(m_pathname, "rb");
if (fp) {
Expand Down Expand Up @@ -221,7 +223,7 @@ void CD3XStringEditor::OnSave()

m_modified = false;
GetDlgItem(IDC_SAVE)->EnableWindow(FALSE);

#endif
}

void CD3XStringEditor::OnOK()
Expand Down
4 changes: 2 additions & 2 deletions editor/DallasMainDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ class CDallasMainDlg : public CDialog

HTREEITEM ParseScriptNodeLine_v0(char *line, int linenum, HTREEITEM parent, bool &skip_all_children, HTREEITEM insert_before=TVI_LAST);
HTREEITEM ParseScriptNodeLine_v1U(char *line, int linenum, HTREEITEM parent, bool &skip_all_children, int version, HTREEITEM insert_before=TVI_LAST);
void ScriptFileParseError(int error_code, int linenum, int script_ID, char *name);
void SpecialScriptFileParseError(int linenum, int script_ID, char *type_name, char *name);
void ScriptFileParseError(int error_code, int linenum, int script_ID,const char *name);
void SpecialScriptFileParseError(int linenum, int script_ID, char *type_name,const char *name);
bool ValidateFunctionNode(HTREEITEM node, int linenum);

///////////////////////////////////
Expand Down
Loading

0 comments on commit b2f5694

Please sign in to comment.