Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
556 changes: 278 additions & 278 deletions CMakeLists.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion FUTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
### Future Improvements

- External
- Move from cryptopp to a maintained cryptography library
- Strip down cryptopp and stop downloading it at CMake configuration time
- Move from compressonator to something that isn't a pile of garbage
- There is literally nothing else that supports BC6H
- Fork minizip-ng and change how it handles dependencies
- `bsppp`
- Support parsing more lumps
Expand All @@ -31,6 +32,7 @@
- Parse animations/sequences
- Make something to construct StudioModel objects from a given model file like obj/glTF?
- Add a save method to write the constituent parts of a StudioModel to disk
- Add an SMD parser/writer
- `sndpp`
- WAV write support
- XWV write support
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
<td><a href="https://wiki.mozilla.org/APNG_Specification">APNG</a></td>
<td align="center">✅</td>
<td align="center">❌</td>
<td rowspan="31" align="center">Python</td>
<td rowspan="31" align="center">C<br>Python</td>
</tr>
<tr><!-- empty row to disable github striped bg color --></tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
<td><a href="https://wiki.mozilla.org/APNG_Specification">APNG</a></td>
<td align="center">✅</td>
<td align="center">❌</td>
<td rowspan="16" align="center">Python</td>
<td rowspan="16" align="center">C<br>Python</td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/BMP_file_format">BMP</a></td>
Expand Down
2 changes: 1 addition & 1 deletion include/vpkpp/vpkpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "format/GCF.h"
#include "format/GMA.h"
#include "format/HOG.h"
#include "format/OO7.h"
#include "format/OL.h"
#include "format/OO7.h"
#include "format/ORE.h"
#include "format/PAK.h"
#include "format/PCK.h"
Expand Down
6 changes: 3 additions & 3 deletions include/vtfpp/PPL.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PPL {
std::vector<std::byte> data;
};

explicit PPL(uint32_t checksum_, ImageFormat format_ = ImageFormat::RGB888, uint32_t version_ = 0);
explicit PPL(uint32_t modelChecksum, ImageFormat format_ = ImageFormat::RGB888, uint32_t version_ = 0);

explicit PPL(std::span<const std::byte> pplData);

Expand All @@ -31,9 +31,9 @@ class PPL {

void setVersion(uint32_t newVersion);

[[nodiscard]] uint32_t getChecksum() const;
[[nodiscard]] uint32_t getModelChecksum() const;

void setChecksum(uint32_t newChecksum);
void setModelChecksum(uint32_t newChecksum);

[[nodiscard]] ImageFormat getFormat() const;

Expand Down
10 changes: 5 additions & 5 deletions include/vtfpp/VTF.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ class VTF {
FLAG_HINT_DXT5 = 1 << 5,
FLAG_PWL_CORRECTED = 1 << 6,
FLAG_NORMAL = 1 << 7,
FLAG_NO_MIP = 1 << 8, // Applied at VTF bake time
FLAG_NO_LOD = 1 << 9, // Applied at VTF bake time
FLAG_NO_MIP = 1 << 8, // Controlled by mip count
FLAG_NO_LOD = 1 << 9,
FLAG_LOAD_ALL_MIPS = 1 << 10,
FLAG_PROCEDURAL = 1 << 11,
FLAG_ONE_BIT_ALPHA = 1 << 12, // Applied at VTF bake time
FLAG_MULTI_BIT_ALPHA = 1 << 13, // Applied at VTF bake time
FLAG_ENVMAP = 1 << 14, // Applied at VTF bake time
FLAG_ONE_BIT_ALPHA = 1 << 12,
FLAG_MULTI_BIT_ALPHA = 1 << 13,
FLAG_ENVMAP = 1 << 14, // Controlled by face count
FLAG_RENDERTARGET = 1 << 15,
FLAG_DEPTH_RENDERTARGET = 1 << 16,
FLAG_NO_DEBUG_OVERRIDE = 1 << 17,
Expand Down
2 changes: 2 additions & 0 deletions lang/c/include/sourceppc/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#ifdef __cplusplus
#define SOURCEPP_API extern "C" SOURCEPP_EXPORT
#define SOURCEPP_CAST_CTOR(name) name
#include <cstddef>
#include <cstdint>
using std::size_t;
Expand All @@ -23,6 +24,7 @@
using std::uint64_t;
#else
#define SOURCEPP_API SOURCEPP_EXPORT
#define SOURCEPP_CAST_CTOR(name) (name)
#include <stddef.h>
#include <stdint.h>
#endif
8 changes: 6 additions & 2 deletions lang/c/include/sourceppc/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ extern "C" {

typedef struct {
int64_t size;
uint8_t* data;
void* data;
} sourcepp_buffer_t;

#define SOURCEPP_BUFFER_INVALID (sourcepp_buffer_t{.size = -1, .data = NULL})
#define SOURCEPP_BUFFER_INVALID (SOURCEPP_CAST_CTOR(sourcepp_buffer_t) {.size = -1, .data = NULL})

// Aliases
typedef sourcepp_buffer_t sourcepp_buffer_uint32_t;
typedef sourcepp_buffer_t sourcepp_buffer_uint64_t;

#ifdef __cplusplus
} // extern "C"
Expand Down
8 changes: 7 additions & 1 deletion lang/c/include/sourceppc/Convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@

namespace Convert {

sourcepp_buffer_t toBuffer(const std::vector<std::byte>& vec);
template<typename T>
requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
sourcepp_buffer_t toBuffer(const std::vector<T>& vec) {
auto buf = sourcepp_buffer_new(vec.size() * sizeof(T));
std::memcpy(buf.data, vec.data(), vec.size() * sizeof(T));
return buf;
}

sourcepp_string_t toString(std::string_view str);

Expand Down
4 changes: 2 additions & 2 deletions lang/c/include/sourceppc/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

#define SOURCEPP_EARLY_RETURN(var) \
do { \
if (!var) { \
if (!(var)) { \
return; \
} \
} while (0)

#define SOURCEPP_EARLY_RETURN_VAL(var, value) \
do { \
if (!var) { \
if (!(var)) { \
return value; \
} \
} while (0)
4 changes: 2 additions & 2 deletions lang/c/include/sourceppc/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ typedef struct {
uint8_t* data;
} sourcepp_string_t;

#define SOURCEPP_STRING_INVALID (sourcepp_string_t{.size = -1, .data = NULL})
#define SOURCEPP_STRING_INVALID (SOURCEPP_CAST_CTOR(sourcepp_string_t) {.size = -1, .data = NULL})

typedef struct {
int64_t size;
char** data;
} sourcepp_string_array_t;

#define SOURCEPP_STRING_ARRAY_INVALID (sourcepp_string_array_t{.size = -1, .data = NULL})
#define SOURCEPP_STRING_ARRAY_INVALID (SOURCEPP_CAST_CTOR(sourcepp_string_array_t) {.size = -1, .data = NULL})

#ifdef __cplusplus
} // extern "C"
Expand Down
24 changes: 12 additions & 12 deletions lang/c/include/steamppc/steampp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif

typedef uint32_t AppID;
typedef uint32_t steampp_appid_t;

typedef void* steampp_steam_handle_t;

Expand All @@ -28,31 +28,31 @@ SOURCEPP_API sourcepp_string_array_t steampp_get_library_dirs(steampp_steam_hand
// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t steampp_get_sourcemod_dir(steampp_steam_handle_t handle);

SOURCEPP_API size_t steampp_get_installed_apps(steampp_steam_handle_t handle, AppID* array, size_t arrayLen);
SOURCEPP_API size_t steampp_get_installed_apps(steampp_steam_handle_t handle, steampp_appid_t* array, size_t arrayLen);

SOURCEPP_API size_t steampp_get_installed_apps_count(steampp_steam_handle_t handle);

SOURCEPP_API bool steampp_is_app_installed(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API bool steampp_is_app_installed(steampp_steam_handle_t handle, steampp_appid_t appID);

SOURCEPP_API const char* steampp_get_app_name(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API const char* steampp_get_app_name(steampp_steam_handle_t handle, steampp_appid_t appID);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t steampp_get_app_install_dir(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API sourcepp_string_t steampp_get_app_install_dir(steampp_steam_handle_t handle, steampp_appid_t appID);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t steampp_get_app_icon_path(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API sourcepp_string_t steampp_get_app_icon_path(steampp_steam_handle_t handle, steampp_appid_t appID);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t steampp_get_app_logo_path(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API sourcepp_string_t steampp_get_app_logo_path(steampp_steam_handle_t handle, steampp_appid_t appID);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t steampp_get_app_box_art_path(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API sourcepp_string_t steampp_get_app_box_art_path(steampp_steam_handle_t handle, steampp_appid_t appID);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t steampp_get_app_store_art_path(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API sourcepp_string_t steampp_get_app_store_art_path(steampp_steam_handle_t handle, steampp_appid_t appID);

SOURCEPP_API bool steampp_is_app_using_goldsrc_engine(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API bool steampp_is_app_using_goldsrc_engine(steampp_steam_handle_t handle, steampp_appid_t appID);

SOURCEPP_API bool steampp_is_app_using_source_engine(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API bool steampp_is_app_using_source_engine(steampp_steam_handle_t handle, steampp_appid_t appID);

SOURCEPP_API bool steampp_is_app_using_source_2_engine(steampp_steam_handle_t handle, AppID appID);
SOURCEPP_API bool steampp_is_app_using_source_2_engine(steampp_steam_handle_t handle, steampp_appid_t appID);
14 changes: 7 additions & 7 deletions lang/c/include/vpkppc/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ extern "C" {
#endif

typedef enum {
ENTRY_COMPRESSION_TYPE_NO_OVERRIDE = -1,
ENTRY_COMPRESSION_TYPE_NO_COMPRESS = 0,
ENTRY_COMPRESSION_TYPE_DEFLATE = 8,
ENTRY_COMPRESSION_TYPE_BZIP2 = 12,
ENTRY_COMPRESSION_TYPE_LZMA = 14,
ENTRY_COMPRESSION_TYPE_ZSTD = 93,
ENTRY_COMPRESSION_TYPE_XZ = 95,
VPKPP_ENTRY_COMPRESSION_TYPE_NO_OVERRIDE = -1,
VPKPP_ENTRY_COMPRESSION_TYPE_NO_COMPRESS = 0,
VPKPP_ENTRY_COMPRESSION_TYPE_DEFLATE = 8,
VPKPP_ENTRY_COMPRESSION_TYPE_BZIP2 = 12,
VPKPP_ENTRY_COMPRESSION_TYPE_LZMA = 14,
VPKPP_ENTRY_COMPRESSION_TYPE_ZSTD = 93,
VPKPP_ENTRY_COMPRESSION_TYPE_XZ = 95,
} vpkpp_entry_compression_type_e;

typedef struct {
Expand Down
9 changes: 9 additions & 0 deletions lang/c/include/vpkppc/format/HOG.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "../PackFile.h"

// REQUIRES MANUAL FREE: vpkpp_close
SOURCEPP_API vpkpp_pack_file_handle_t vpkpp_hog_open(const char* path, vpkpp_entry_callback_t callback);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t vpkpp_hog_guid(vpkpp_pack_file_handle_t handle);
9 changes: 9 additions & 0 deletions lang/c/include/vpkppc/format/VPP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "../PackFile.h"

// REQUIRES MANUAL FREE: vpkpp_close
SOURCEPP_API vpkpp_pack_file_handle_t vpkpp_vpp_open(const char* path, vpkpp_entry_callback_t callback);

// REQUIRES MANUAL FREE: sourcepp_string_free
SOURCEPP_API sourcepp_string_t vpkpp_vpp_guid(vpkpp_pack_file_handle_t handle);
3 changes: 2 additions & 1 deletion lang/c/include/vpkppc/vpkpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#include "format/FPX.h"
#include "format/GCF.h"
#include "format/GMA.h"
#include "format/OO7.h"
#include "format/HOG.h"
#include "format/OL.h"
#include "format/OO7.h"
#include "format/ORE.h"
#include "format/PAK.h"
#include "format/PCK.h"
Expand Down
64 changes: 64 additions & 0 deletions lang/c/include/vtfppc/Convert.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once

#include <vtfpp/vtfpp.h>

#include "PPL.h"
#include "SHT.h"
#include "TTX.h"
#include "VTF.h"

/*
* This is a header designed to be included in C++ source code.
* It should not be included in applications using any C wrapper libraries!
*/
#ifndef __cplusplus
#error "This header can only be used in C++!"
#endif

namespace Convert {

vtfpp::ImageConversion::ResizeMethod resizeMethod(vtfpp_image_conversion_resize_method_e method);

vtfpp_image_conversion_resize_method_e resizeMethod(vtfpp::ImageConversion::ResizeMethod method);

vtfpp::ImageConversion::ResizeFilter resizeFilter(vtfpp_image_conversion_resize_filter_e filter);

vtfpp::ImageConversion::FileFormat fileFormat(vtfpp_image_conversion_file_format_e fileFormat);

vtfpp::ImageFormat imageFormat(vtfpp_image_format_e format);

vtfpp_image_format_e imageFormat(vtfpp::ImageFormat format);

vtfpp::PPL* ppl(vtfpp_ppl_handle_t handle);

vtfpp::SHT* sht(vtfpp_sht_handle_t handle);

vtfpp::TTX* ttx(vtfpp_ttx_handle_t handle);

vtfpp::CompressionMethod compressionMethod(vtfpp_compression_method_e method);

vtfpp_compression_method_e compressionMethod(vtfpp::CompressionMethod method);

vtfpp::Resource::Type resourceType(vtfpp_resource_type_e type);

vtfpp_resource_type_e resourceType(vtfpp::Resource::Type type);

vtfpp::Resource::Flags resourceFlags(vtfpp_resource_flags_e flags);

vtfpp_resource_flags_e resourceFlags(vtfpp::Resource::Flags flags);

const vtfpp::Resource* resource(vtfpp_resource_handle_t resource);

vtfpp::VTF::Flags vtfFlags(vtfpp_vtf_flags_e flags);

vtfpp_vtf_flags_e vtfFlags(vtfpp::VTF::Flags flags);

vtfpp::VTF::Platform vtfPlatform(vtfpp_vtf_platform_e platform);

vtfpp_vtf_platform_e vtfPlatform(vtfpp::VTF::Platform platform);

vtfpp::VTF::CreationOptions vtfCreationOptions(vtfpp_vtf_creation_options_t options);

vtfpp::VTF* vtf(vtfpp_vtf_handle_t handle);

} // namespace Convert
Loading