Skip to content

Commit

Permalink
Merge pull request #397 from Lgt2x/d3-editor
Browse files Browse the repository at this point in the history
Build internal level editor (WIP, doesn't actually run)
  • Loading branch information
Arcnor authored Jun 14, 2024
2 parents 4ace76c + c00b8ea commit 9e93fc3
Show file tree
Hide file tree
Showing 335 changed files with 1,103 additions and 301 deletions.
2 changes: 1 addition & 1 deletion .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 Down
12 changes: 11 additions & 1 deletion 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 @@ -102,7 +106,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 PRIMARY_HOG=\"d3-win.hog\"
add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX NODRAWTEXT NOBITMAP NOMCX NOSERVICE PRIMARY_HOG=\"d3-win.hog\"
#[[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 @@ -201,6 +205,12 @@ add_subdirectory(vecmat)
add_subdirectory(libmve)
add_subdirectory(md5)
add_subdirectory(libacm)


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 @@ -247,7 +247,7 @@ static int skipped_screens;

static bool IsMissionMaskOK(uint32_t set, uint32_t unset);
static void ReplaceHotTag(char *string, int tag);
static bool ParseForHotTags(char *src, char **dest);
static bool ParseForHotTags(const char *src, char **dest);
static bool PlayBriefing(tTelComInfo *tcs);
static void PBAddTextEffect(TCTEXTDESC* desc, char *text, char *description, int id);
static void PBAddBmpEffect(TCBMPDESC* desc, char *description);
Expand Down Expand Up @@ -456,7 +456,7 @@ bool PlayBriefing(tTelComInfo *tcs) {
return true;
}

void PBAddTextEffect(TCTEXTDESC* desc, const char *text, const char *description, int id) {
void PBAddTextEffect(TCTEXTDESC* 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(TCTEXTDESC* desc, const char *text, const char *description
}
}

void PBAddBmpEffect(TCBMPDESC* desc, const char *description) {
void PBAddBmpEffect(TCBMPDESC* 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(TCMOVIEDESC* desc, const char *description) {
void PBAddMovieEffect(TCMOVIEDESC* 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(TCBKGDESC* desc, const char *description) {
void PBAddBkgEffect(TCBKGDESC* 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(TCPOLYDESC* desc, const char *description) {
void PBAddPolyEffect(TCPOLYDESC* 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(TCSNDDESC* desc, const char *description) {
void PBAddSoundEffect(TCSNDDESC* 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(TCBUTTONDESC* desc, const char *description, int id) {
void PBAddButtonEffect(TCBUTTONDESC* 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(TCBUTTONDESC* 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

struct tBriefParseCallbacks {
void (*AddTextEffect)(TCTEXTDESC* desc, const char *text, const char *description, int id);
void (*AddBmpEffect)(TCBMPDESC* desc, const char *description);
void (*AddMovieEffect)(TCMOVIEDESC* desc, const char *description);
void (*AddBkgEffect)(TCBKGDESC* desc, const char *description);
void (*AddPolyEffect)(TCPOLYDESC* desc, const char *description);
void (*AddSoundEffect)(TCSNDDESC* desc, const char *description);
void (*AddButtonEffect)(TCBUTTONDESC* 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)(TCTEXTDESC* desc, char *text, char *description, int id);
void (*AddBmpEffect)(TCBMPDESC* desc, char *description);
void (*AddMovieEffect)(TCMOVIEDESC* desc, char *description);
void (*AddBkgEffect)(TCBKGDESC* desc, char *description);
void (*AddPolyEffect)(TCPOLYDESC* desc, char *description);
void (*AddSoundEffect)(TCSNDDESC* desc, char *description);
void (*AddButtonEffect)(TCBUTTONDESC* 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);
};

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

private:
void (*AddTextEffect)(TCTEXTDESC* desc, const char *text, const char *description, int id);
void (*AddBmpEffect)(TCBMPDESC* desc, const char *description);
void (*AddMovieEffect)(TCMOVIEDESC* desc, const char *description);
void (*AddBkgEffect)(TCBKGDESC* desc, const char *description);
void (*AddPolyEffect)(TCPOLYDESC* desc, const char *description);
void (*AddSoundEffect)(TCSNDDESC* desc, const char *description);
void (*AddButtonEffect)(TCBUTTONDESC* 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)(TCTEXTDESC* desc, char *text, char *description, int id);
void (*AddBmpEffect)(TCBMPDESC* desc, char *description);
void (*AddMovieEffect)(TCMOVIEDESC* desc, char *description);
void (*AddBkgEffect)(TCBKGDESC* desc, char *description);
void (*AddPolyEffect)(TCPOLYDESC* desc, char *description);
void (*AddSoundEffect)(TCSNDDESC* desc, char *description);
void (*AddButtonEffect)(TCBUTTONDESC* 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
3 changes: 1 addition & 2 deletions Descent3/LoadLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3470,7 +3470,6 @@ void ReadTerrainChunks(CFILE *fp, int version) {
UpdateTerrainLightmaps();

#if (defined(EDITOR) || defined(NEWEDITOR))

memset(TerrainSelected, 0, TERRAIN_WIDTH * TERRAIN_DEPTH);
Num_terrain_selected = 0;
#endif
Expand Down Expand Up @@ -3923,7 +3922,7 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) {
uint8_t buf[1000];
int n = chunk_size, r;
while (n) {
r = cf_ReadBytes(buf, std::min(n, sizeof(buf)), ifile);
r = cf_ReadBytes(buf, std::min(n, static_cast<int>(sizeof(buf))), ifile);
cf_WriteBytes(buf, r, ofile);
n -= r;
}
Expand Down
4 changes: 1 addition & 3 deletions Descent3/SLEW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
* $NoKeywords: $
*/

#ifdef _DEBUG
#if (defined(_DEBUG) || defined(EDITOR))

#ifdef EDITOR
#include "editor\mainfrm.h"
Expand Down Expand Up @@ -226,10 +226,8 @@ int Joystick_active = -1;
void SlewControlInit() {
Joystick_active = -1;

#ifdef EDITOR
if (!D3EditState.joy_slewing)
return;
#endif

if (joy_IsValid(JOYSTICK_1)) {
tJoyPos joystate;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/gamecinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@

#include <algorithm>

#ifdef _DEBUG
#if (defined(_DEBUG) || defined(EDITOR))
bool Cinematics_enabled = true;
extern int DoAI;
#ifdef EDITOR
Expand Down
2 changes: 1 addition & 1 deletion Descent3/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ void InitGraphics(bool editor) {

// Init our renderer
grSurface::init_system();
rend_Init(RENDERER_SOFTWARE_16BIT, Descent, NULL);
rend_Init(RENDERER_OPENGL, Descent, NULL);
Desktop_surf = new grSurface(0, 0, 0, SURFTYPE_VIDEOSCREEN, 0);
#else
strcpy(App_ddvid_subsystem, "GDIX");
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
7 changes: 2 additions & 5 deletions Descent3/objinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const char *Static_object_names[] = {TBL_GENERIC("GuideBot"), TBL_GENERIC("Chaff
#define NUM_STATIC_OBJECTS (sizeof(Static_object_names) / sizeof(*Static_object_names))

#ifdef EDITOR
const char *Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"};
const char *Anim_state_names[] = {"Alert",
const char * const Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"};
const char * const Anim_state_names[] = {"Alert",
"Death",
"Fire Missile 1",
"Missile Recoil 1",
Expand All @@ -85,9 +85,6 @@ const char *Anim_state_names[] = {"Alert",
"Goto rolling",
"Goto walking",
"Goto jumping"};

// extern char *Movement_class_names[];
// extern char *Anim_state_names[];
#endif

// Sets all objects to unused
Expand Down
4 changes: 2 additions & 2 deletions Descent3/objinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@
// The number of ids of each type in the list
extern int Num_object_ids[];

extern char *Movement_class_names[];
extern char *Anim_state_names[];
extern const char * const Movement_class_names[];
extern const char * const Anim_state_names[];

// These defines must correspond to the Static_object_names array
#define GENOBJ_GUIDEBOT 0 // NOTE: This must match ROBOT_GUIDEBOT
Expand Down
27 changes: 14 additions & 13 deletions Descent3/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,7 @@ int Global_buffer_index;
int No_render_windows_hack = -1;
#define WALL_PULSE_INCREMENT .01
// Variables for various debugging features
#ifndef _DEBUG
#define In_editor_mode 0
#define Outline_lightmaps 0
#define Outline_alpha 0
#define Render_floating_triggers 0
#define Use_software_zbuffer 0
#define Render_all_external_rooms 0
#define Render_portals 0
#define Render_one_room_only 0
#define Render_inside_only 0
#define Shell_render_flag 0
#else // ifdef _DEBUG
#if (defined(_DEBUG) || defined(NEWEDITOR) || defined(EDITOR))
// If true, draw white outline for each polygon
int Render_portals = 0;
uint8_t Outline_mode = 0;
Expand All @@ -125,7 +114,19 @@ bool Render_all_external_rooms = 0;
bool In_editor_mode = 0;
bool Render_one_room_only = 0;
bool Render_inside_only = 0;
#endif // ifdef _DEBUG
#else
#define In_editor_mode 0
#define Outline_lightmaps 0
#define Outline_alpha 0
#define Render_floating_triggers 0
#define Use_software_zbuffer 0
#define Render_all_external_rooms 0
#define Render_portals 0
#define Render_one_room_only 0
#define Render_inside_only 0
#define Shell_render_flag 0
#endif

#ifndef RELEASE
int Mine_depth;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Descent3/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
#include "3d.h"

// Variables for debug/test
#if (defined(_DEBUG) || defined(NEWEDITOR))
#if (defined(_DEBUG) || defined(NEWEDITOR) || defined(EDITOR))

#define SRF_NO_SHELL 1 // don't render the shell
#define SRF_NO_NON_SHELL 2 // don't render the non-shell
Expand Down
4 changes: 2 additions & 2 deletions Descent3/robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

extern int Num_robots;
extern object_info Robots[MAX_ROBOTS];
extern char *Movement_class_names[];
extern char *Anim_state_names[];
extern const char * const Movement_class_names[];
extern const char * const Anim_state_names[];

// Sets all robots to unused
void InitRobots();
Expand Down
4 changes: 2 additions & 2 deletions Descent3/room.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ extern int Highest_room_index; // index of highest-numbered room
// Zeroes out the rooms array
void InitRooms();

#ifdef _DEBUG
#if (defined(_DEBUG) || defined(EDITOR))
// Allows a spew'er to find out if he is in a room or external to the mine
// NOTE: THIS FUNCTION IS NOT FOR IN GAME STUFF. It is REALLY SLOW and accurate.
// Talk to Chris if you need something like this function.
Expand Down Expand Up @@ -560,7 +560,7 @@ static inline int GetFacePhysicsFlags(const room *rp, const face *fp) {

// Computes a bounding sphere for the current room
// Parameters: center - filled in with the center point of the sphere
// rp - the room we’re bounding
// rp - the room we're bounding
// Returns: the radius of the bounding sphere
float ComputeRoomBoundingSphere(vector *center, room *rp);

Expand Down
2 changes: 1 addition & 1 deletion Descent3/slew.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef _SLEW_H
#define _SLEW_H

#ifndef RELEASE
#if (defined(_DEBUG) || defined(EDITOR))

#include "object.h"

Expand Down
2 changes: 1 addition & 1 deletion Descent3/terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ extern uint8_t Show_invisible_terrain;

extern int Camera_direction, Sort_direction;

#if (defined(_DEBUG) || defined(NEWEDITOR))
#if (defined(_DEBUG) || defined(EDITOR) || defined(NEWEDITOR))
extern uint8_t TerrainSelected[];
extern int Num_terrain_selected;
#endif
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
* $NoKeywords: $
*/

#include "stdafx.h"
#include "mfc_compatibility.h"
#include "editor.h"
#include "AnimStatesDialog.h"
#include "polymodel.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9e93fc3

Please sign in to comment.