Skip to content

Commit 9dacefe

Browse files
authored
Merge branch 'DescentDevelopers:main' into unzip
2 parents 30eb861 + f1ec3d7 commit 9dacefe

File tree

12 files changed

+373
-48
lines changed

12 files changed

+373
-48
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
- {runner: macos-12, preset: mac} # This is supposed to be Intel for now, and what macos-latest is defaulting to for some reason (as of 04/2024)
1717
- {runner: macos-14, preset: mac} # This is supposed to be M1
1818
- {runner: ubuntu-latest, preset: linux}
19-
build_type: [Debug, Release]
2019

2120
runs-on: ${{ matrix.os.runner }}
2221

@@ -32,21 +31,23 @@ jobs:
3231
- name: Install Linux dependencies
3332
if: ${{ matrix.os.preset == 'linux' }}
3433
run: |
35-
sudo dpkg --add-architecture i386
3634
sudo apt update
3735
sudo apt install -y --no-install-recommends \
38-
ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev \
39-
libxext6:i386 # for ./scripts/hogutils/hogUtils-i686 binary
40-
mkdir ~/Descent3
36+
ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev
4137
4238
- name: Configure CMake
4339
run: cmake --preset ${{ matrix.os.preset }}
4440

45-
- name: Build
46-
run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }}
41+
- name: Debug Build
42+
run: cmake --build --preset ${{ matrix.os.preset }} --config Debug --verbose
43+
44+
- name: Release Build
45+
run: cmake --build --preset ${{ matrix.os.preset }} --config Release --verbose
4746

4847
- name: Upload Artifacts
4948
uses: actions/upload-artifact@v4
5049
with:
51-
name: build_${{ matrix.os.runner }}_${{ matrix.build_type }}
52-
path: "${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/${{ matrix.build_type }}"
50+
name: build_${{ matrix.os.runner }}
51+
path: |
52+
${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/Debug/
53+
${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/Release/

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,4 @@ cmake-build-*
405405

406406
# Linux stuff
407407
build
408-
*.so
409-
410-
411-
# D3 specific
412-
*.hog
408+
builds

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ add_subdirectory(md5)
123123
add_subdirectory(libacm)
124124
add_subdirectory(Descent3)
125125

126+
add_subdirectory(tools)
127+
126128
# For now we don't need to build the scripts under windows, so we'll only include
127129
# the directory when building for linux/osx. In the future we may want to to fix bugs, etc.
128130
if(UNIX)

Descent3/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ target_link_libraries(Descent3
302302
music networking physics renderer rtperformance sndlib ui unzip vecmat md5
303303
${PLATFORM_LIBS})
304304

305+
if(UNIX)
306+
add_dependencies(Descent3 HogLinuxFull)
307+
endif()
308+
305309
if(WIN32)
306310
set_target_properties(Descent3 PROPERTIES WIN32_EXECUTABLE ON)
307311
endif()

scripts/CMakeLists.txt

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
add_definitions(-DCHECKSUM=2273873307UL)
22
set(HEADERS)
33
set(CPPS)
4-
if(UNIX)
4+
if (UNIX)
55
set(CPPS
66
linux_lib.cpp)
7-
endif()
7+
endif ()
88

99
set(SCRIPTS
1010
aigame2
@@ -64,43 +64,48 @@ set(SCRIPTS
6464
TrainingMission
6565
Y2K)
6666

67+
add_custom_target(HogLinuxFull-copy
68+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog ${CMAKE_BINARY_DIR}/scripts/data/linuxfullhog/
69+
COMMENT "Copy script/data/linuxfullhog directory"
70+
)
71+
72+
#add_custom_target(HogLinuxDemo-copy
73+
# COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog ${CMAKE_BINARY_DIR}/scripts/data/linuxdemohog/
74+
# COMMENT "Copy script/data/linuxdemohog directory"
75+
#)
76+
6777
foreach(SCRIPT ${SCRIPTS})
6878
add_library(${SCRIPT} SHARED ${CPPS} "${SCRIPT}.cpp")
79+
add_dependencies(${SCRIPT} HogLinuxFull-copy) # HogLinuxDemo-copy
6980
set_target_properties(${SCRIPT} PROPERTIES PREFIX "")
70-
if(UNIX)
71-
add_custom_command(
72-
TARGET ${SCRIPT}
73-
POST_BUILD
74-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SCRIPT}> "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/"
75-
COMMENT "Copying file ${SCRIPT} to hogfile directory...")
81+
if (UNIX)
7682
add_custom_command(
7783
TARGET ${SCRIPT}
7884
POST_BUILD
79-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SCRIPT}> "${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog/")
80-
endif()
81-
endforeach()
85+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SCRIPT}> "${CMAKE_BINARY_DIR}/scripts/data/linuxfullhog/"
86+
COMMENT "Copying file ${SCRIPT} to scripts/data/linuxfullhog/..."
87+
)
88+
# add_custom_command(
89+
# TARGET ${SCRIPT}
90+
# POST_BUILD
91+
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SCRIPT}> "${CMAKE_BINARY_DIR}/scripts/data/linuxdemohog/"
92+
# COMMENT "Copying file ${SCRIPT} to scripts/data/linuxdemohog/..."
93+
# )
94+
endif ()
95+
endforeach ()
96+
97+
if (UNIX)
98+
add_custom_target(HogLinuxFull
99+
COMMAND $<TARGET_FILE:HogMaker> "$<TARGET_FILE_DIR:Descent3>/d3-linux.hog" "${CMAKE_BINARY_DIR}/scripts/data/linuxfullhog/d3linuxfullhog.txt"
100+
DEPENDS ${SCRIPTS} HogMaker
101+
COMMENT "Generate linuxfullhog/d3-linux.hog"
102+
)
82103

83-
if(UNIX AND NOT APPLE)
84-
set(HOGBUILDCMD "${CMAKE_SOURCE_DIR}/scripts/hogutils/hogUtils-i686")
85-
set(HOGARCH "linux")
104+
# FIXME: there may be only one d3-linux.hog, need deal with demo somehow.
105+
# add_custom_target(HogLinuxDemo
106+
# COMMAND $<TARGET_FILE:HogMaker> "${CMAKE_BINARY_DIR}/scripts/data/linuxdemohog/d3-linux.hog" "${CMAKE_BINARY_DIR}/scripts/data/linuxdemohog/d3linuxdemohog.txt"
107+
# DEPENDS ${SCRIPTS} HogMaker
108+
# COMMENT "Generate linuxdemohog/d3-linux.hog"
109+
# )
86110

87-
add_custom_target("FullLinuxHog"
88-
ALL
89-
COMMAND ${HOGBUILDCMD} "--makehog" "d3linuxfullhog.txt"
90-
COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/d3-${HOGARCH}.hog"
91-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/new.hog" "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/d3-${HOGARCH}.hog"
92-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/d3-${HOGARCH}.hog" "${CMAKE_BINARY_DIR}"
93-
COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/new.hog"
94-
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/scripts/data/linuxfullhog/"
95-
DEPENDS ${SCRIPTS}
96-
COMMENT "Building platform specific hog.")
97-
add_custom_target("DemoLinuxHog"
98-
ALL
99-
COMMAND ${HOGBUILDCMD} "--makehog" "d3linuxdemohog.txt"
100-
COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog/d3-${HOGARCH}.hog"
101-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog/new.hog" "${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog/d3-${HOGARCH}.hog"
102-
COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog/new.hog"
103-
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/scripts/data/linuxdemohog/"
104-
DEPENDS ${SCRIPTS}
105-
COMMENT "Building platform specific hog.")
106-
endif()
111+
endif ()

scripts/hogutils/hogUtils-i686

-3.59 MB
Binary file not shown.
-939 KB
Binary file not shown.

tools/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if(WIN32)
2+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
3+
endif()
4+
5+
add_executable(
6+
HogMaker
7+
HogMaker/HogFormat.cpp
8+
HogMaker/HogMaker.cpp
9+
)

tools/HogMaker/HogFormat.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Descent 3
3+
* Copyright (C) 2024 Descent Developers
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include "HogFormat.h"
20+
#include "IOOps.h"
21+
22+
#include <fstream>
23+
24+
namespace D3 {
25+
26+
std::ostream &operator<<(std::ostream &output, HogHeader &header) {
27+
output.write((char *)&header.tag[0], 4);
28+
bin_write(output, header.nfiles);
29+
bin_write(output, header.file_data_offset);
30+
output.write((char *)&header.reserved[0], 56);
31+
32+
return output;
33+
}
34+
35+
std::ostream &operator<<(std::ostream &output, HogFileEntry &entry) {
36+
auto tmp = entry.name.c_str();
37+
output.write((char *)&tmp[0], 36);
38+
bin_write(output, entry.flags);
39+
bin_write(output, entry.len);
40+
bin_write(output, entry.timestamp);
41+
return output;
42+
}
43+
44+
std::ostream &operator<<(std::ostream &output, HogFormat &format) {
45+
output << format.m_header;
46+
for (auto i : format.m_file_entries) {
47+
output << i;
48+
}
49+
50+
return output;
51+
}
52+
53+
} // namespace D3

tools/HogMaker/HogFormat.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Descent 3
3+
* Copyright (C) 2024 Descent Developers
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
#pragma once
19+
20+
#include <cstdint>
21+
#include <filesystem>
22+
#include <vector>
23+
24+
#include "IOOps.h"
25+
26+
namespace D3 {
27+
28+
/*
29+
HOG FILE FORMAT v2.0
30+
31+
HOG_TAG_STR [strlen()]
32+
NFILES [int32]
33+
HDRINFO [HOG_HDR_SIZE]
34+
FILE_TABLE [sizeof(FILE_ENTRY) * NFILES]
35+
FILE 0 [filelen(FILE 0)]
36+
FILE 1 [filelen(FILE 1)]
37+
...
38+
FILE NFILES-1 [filelen(NFILES -1)]
39+
*/
40+
41+
struct HogHeader {
42+
std::vector<char> tag = {'H', 'O', 'G', '2'}; // "HOG2"
43+
uint32_t nfiles = 0; // number of files in header
44+
uint32_t file_data_offset = 68; // offset in file to filedata.
45+
std::vector<char> reserved = std::vector<char>(56, -1); // filled with 0xff
46+
};
47+
48+
struct HogFileEntry {
49+
std::filesystem::path name; // file name (36 char max)
50+
uint32_t flags; // extra info
51+
uint32_t len; // length of file
52+
uint32_t timestamp; // time of file.
53+
};
54+
55+
class HogFormat {
56+
private:
57+
HogHeader m_header;
58+
std::vector<HogFileEntry> m_file_entries;
59+
60+
public:
61+
void AddEntry(HogFileEntry &entry) {
62+
m_file_entries.push_back(entry);
63+
m_header.nfiles++;
64+
m_header.file_data_offset += 48;
65+
};
66+
67+
friend std::ostream &operator<<(std::ostream &output, HogFormat &format);
68+
};
69+
70+
} // namespace D3

0 commit comments

Comments
 (0)