Merge branch 'master' into acs

This commit is contained in:
Sally Coolatta 2022-12-31 15:04:51 -05:00
commit a0adb05c9b
168 changed files with 2860 additions and 64 deletions

54
.clang-format Normal file
View file

@ -0,0 +1,54 @@
---
Language: Cpp
Standard: c++17
IndentWidth: 4
UseTab: Always
TabWidth: 4
ColumnLimit: 120
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Attach # K&R/OTBS, braces on same line, Java style
BreakConstructorInitializers: BeforeComma
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
Cpp11BracedListStyle: true
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: true
IndentCaseBlocks: true
IndentCaseLabels: false
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Left # Pointer and reference marker is an integral part of type ID
ReferenceAlignment: Left
ReflowComments: true
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

43
.editorconfig Normal file
View file

@ -0,0 +1,43 @@
root = true
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
[.editorconfig]
indent_size = 4
indent_style = tab
tab_width = 4
[src/**.{c,h,cpp,hpp}]
indent_style = tab
indent_size = 4
tab_width = 4
[{CMakeLists.txt,*.cmake}]
indent_size = 4
indent_style = tab
tab_width = 4
[{Makefile,*.mk}]
indent_size = 8
indent_style = tab
tab_width = 8
[*{.yml,.yaml}]
indent_size = 2
indent_style = space
tab_width = 8
[*.sh]
indent_size = 4
indent_style = tab
tab_width = 4
end_of_line = lf
[*.bat]
indent_size = 4
indent_style = tab
tab_width = 4
end_of_line = crlf

View file

@ -173,22 +173,25 @@ add_subdirectory(src)
add_subdirectory(assets)
## config.h generation
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities)
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}")
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
# cause a reconfigure if the branch changes
get_git_dir(SRB2_GIT_DIR)
configure_file("${SRB2_GIT_DIR}/HEAD" HEAD COPYONLY)
git_current_branch(SRB2_GIT_REVISION)
if("${SRB2_GIT_REVISION}" STREQUAL "")
# use abbreviated commit hash if on detached HEAD
git_latest_commit(SRB2_GIT_REVISION)
endif()
list(APPEND EXE_NAME_PARTS "ringracers")
if(NOT "${SRB2_GIT_BRANCH}" STREQUAL "master")
list(APPEND EXE_NAME_PARTS ${SRB2_GIT_BRANCH})
if(NOT "${SRB2_GIT_REVISION}" STREQUAL "master")
list(APPEND EXE_NAME_PARTS ${SRB2_GIT_REVISION})
endif()
else()
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME})

13
cmake/Comptime.cmake Normal file
View file

@ -0,0 +1,13 @@
set(CMAKE_BINARY_DIR "${BINARY_DIR}")
set(CMAKE_CURRENT_BINARY_DIR "${BINARY_DIR}")
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
include(GitUtilities)
git_current_branch(SRB2_COMP_BRANCH)
git_summary(SRB2_COMP_REVISION)
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/config.h")

View file

@ -6,54 +6,54 @@ endif()
set(__GitUtilities ON)
function(git_describe variable path)
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
macro(_git_command)
execute_process(
COMMAND "${GIT_EXECUTABLE}" ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endmacro()
macro(_git_easy_command)
_git_command(${ARGN})
set(${variable} "${output}" PARENT_SCOPE)
endmacro()
function(git_current_branch variable)
_git_command(symbolic-ref -q --short HEAD)
# If a detached head, a ref could still be resolved.
if("${output}" STREQUAL "")
_git_command(describe --all --exact-match)
# Get the ref, in the form heads/master or
# remotes/origin/master so isolate the final part.
string(REGEX REPLACE ".*/" "" output "${output}")
endif()
set(${variable} "${output}" PARENT_SCOPE)
endfunction()
function(git_current_branch variable path)
execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE)
function(git_latest_commit variable)
_git_easy_command(rev-parse --short HEAD)
endfunction()
function(git_latest_commit variable path)
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE)
endfunction()
function(git_working_tree_dirty variable path)
execute_process(COMMAND ${GIT_EXECUTABLE} "status" "--porcelain" "-uno"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
function(git_working_tree_dirty variable)
_git_command(status --porcelain -uno)
if(output STREQUAL "")
set(${variable} FALSE PARENT_SCOPE)
else()
set(${variable} TRUE PARENT_SCOPE)
endif()
endfunction()
endfunction()
function(git_summary variable)
_git_easy_command(log -1 "--format=%h %s")
endfunction()
function(get_git_dir variable)
_git_easy_command(rev-parse --git-dir)
endfunction()

View file

@ -1,5 +1,6 @@
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
comptime.c
cxxutil.hpp
md5.c
config.h.in
string.c
@ -132,6 +133,32 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
k_roulette.c
)
# This updates the modification time for comptime.c at the
# end of building so when the build system is ran next time,
# that file gets flagged. comptime.c will always be rebuilt.
#
# This begs the question, why always rebuild comptime.c?
# Some things like the git commit must be checked each time
# the program is built. But the build system determines which
# files should be rebuilt before anything else. So
# comptime.c, which only needs to be rebuilt based on
# information known at build time, must be told to rebuild
# before that information can be ascertained.
add_custom_command(
TARGET SRB2SDL2
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c
)
# config.h is generated by this command. It should be done at
# build time for accurate git information and before anything
# that needs it, obviously.
add_custom_target(_SRB2_reconf ALL
COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/.. -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Comptime.cmake
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
)
add_dependencies(SRB2SDL2 _SRB2_reconf)
if("${CMAKE_COMPILER_IS_GNUCC}" AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
target_link_options(SRB2SDL2 PRIVATE "-Wl,--disable-dynamicbase")
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND NOT "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
@ -198,6 +225,7 @@ target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN)
target_sources(SRB2SDL2 PRIVATE discord.c stun.c)
target_link_libraries(SRB2SDL2 PRIVATE tcbrindle::span)
target_link_libraries(SRB2SDL2 PRIVATE acsvm::acsvm)
set(SRB2_HAVE_THREADS ON)
@ -511,6 +539,7 @@ if(SRB2_CONFIG_PROFILEMODE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
target_link_options(SRB2SDL2 PRIVATE -pg)
endif()
add_subdirectory(io)
add_subdirectory(sdl)
add_subdirectory(objects)
add_subdirectory(acs)

View file

@ -16,6 +16,10 @@
#include "d_event.h"
#ifdef __cplusplus
extern "C" {
#endif
struct fpoint_t
{
INT32 x, y;
@ -44,4 +48,8 @@ void AM_Start(void);
// Called to force the automap to quit if the level is completed while it is up.
void AM_Stop(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -3,10 +3,18 @@
#include <jni.h>
#ifdef __cplusplus
extern "C" {
#endif
UINT8 *android_surface;
JNIEnv* jni_env;
jobject androidVideo;
jmethodID videoFrameCB;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -39,6 +39,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <png.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct apng_info_def apng_info;
typedef apng_info * apng_infop;
typedef const apng_info * apng_const_infop;
@ -77,4 +81,8 @@ void apng_set_write_fn (png_structp png_ptr, apng_infop ainfo_ptr,
void apng_set_set_acTL_fn (png_structp png_ptr, apng_infop ainfo_ptr,
apng_set_acTL_ptr set_acTL_fn);
#ifdef __cplusplus
} // extern "C"
#endif
#endif/* APNG_H */

View file

@ -11,12 +11,19 @@
/// \brief Macros to read/write from/to a UINT8 *,
/// used for packet creation and such
#ifndef __BYTEPTR_H__
#define __BYTEPTR_H__
#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__)
#define DEALIGNED
#endif
#include "endian.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SRB2_BIG_ENDIAN
//
// Little-endian machines
@ -214,3 +221,9 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
memcpy(s, p, n); \
p += n; \
} while (0)
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __BYTEPTR_H__

View file

@ -16,6 +16,10 @@
#include <stdio.h>
#include "doomdef.h"
#ifdef __cplusplus
extern "C" {
#endif
//===================================
// Command buffer & command execution
//===================================
@ -238,4 +242,8 @@ void CV_CheaterWarning(UINT8 playerID, const char *command);
// Returns cvar by name. Exposed here for Lua.
consvar_t *CV_FindVar(const char *name);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __COMMAND_H__

View file

@ -10,10 +10,17 @@
/// \file console.h
/// \brief Console drawing and input
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
#include "d_event.h"
#include "command.h"
#include "i_threads.h"
#ifdef __cplusplus
extern "C" {
#endif
void CON_Init(void);
boolean CON_Responder(event_t *ev);
@ -90,3 +97,9 @@ void CON_LogMessage(const char *msg);
// Startup loading bar
void CON_SetLoadingProgress(con_loadprogress_t newStep);
void CON_DrawLoadBar(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __CONSOLE_H__

View file

@ -24,6 +24,10 @@
#include "k_pwrlv.h" // PWRLV_NUMTYPES
#include "p_saveg.h" // NETSAVEGAMESIZE
#ifdef __cplusplus
extern "C" {
#endif
/*
The 'packet version' is used to distinguish packet formats.
This version is independent of VERSION and SUBVERSION. Different
@ -545,4 +549,8 @@ void CL_ClearRewinds(void);
rewind_t *CL_SaveRewindPoint(size_t demopos);
rewind_t *CL_RewindToTime(tic_t time);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "doomtype.h"
#include "g_state.h"
#ifdef __cplusplus
extern "C" {
#endif
// Input event types.
typedef enum
{
@ -45,4 +49,8 @@ struct event_t
extern event_t events[MAXEVENTS];
extern INT32 eventhead, eventtail;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -78,12 +78,6 @@
#include "k_specialstage.h"
#include "acs/interface.h"
#ifdef CMAKECONFIG
#include "config.h"
#else
#include "config.h.in"
#endif
#ifdef HWRENDER
#include "hardware/hw_main.h" // 3D View Rendering
#endif
@ -1126,6 +1120,7 @@ static void IdentifyVersion(void)
#define TEXTURESNAME "MISC_TEXTURES.pk3"
#define MAPSNAME "MISC_MAPS.pk3"
#define PATCHNAME "MISC_SCRIPTS.pk3"
#define UNLOCKNAME "MISC_UNLOCKS.pk3"
#define MUSICNAME "MISC_MUSIC.PK3"
////
#else
@ -1133,6 +1128,7 @@ static void IdentifyVersion(void)
#define TEXTURESNAME "textures.pk3"
#define MAPSNAME "maps.pk3"
#define PATCHNAME "scripts.pk3"
#define UNLOCKNAME "unlocks.pk3"
#define MUSICNAME "music.pk3"
////
#endif
@ -1149,7 +1145,7 @@ static void IdentifyVersion(void)
#endif
#define UNLOCKTESTING
#if defined(DEVELOP) && defined(UNLOCKTESTING)
D_AddFile(startupiwads, va(pandf,srb2waddir,"unlocks.pk3"));
D_AddFile(startupiwads, va(pandf,srb2waddir,UNLOCKNAME));
#endif
////
#undef TEXTURESNAME
@ -1216,6 +1212,12 @@ void D_SRB2Main(void)
/* break the version string into version numbers, for netplay */
D_ConvertVersionNumbers();
if (!strcmp(compbranch, ""))
{
// \x8b = aqua highlight
compbranch = "\x8b" "detached HEAD" "\x80";
}
#ifdef DEVELOP
D_AbbrevCommit();
#endif
@ -1445,6 +1447,7 @@ void D_SRB2Main(void)
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAPS_PK3); // maps.pk3 -- 4 - If you touch this, make sure to touch up the majormods stuff below.
mainwads++; W_VerifyFileMd5(mainwads, ASSET_HASH_FOLLOWERS_PK3); // followers.pk3
#ifdef USE_PATCH_FILE
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_PK3); // patch.pk3
#endif
#else

View file

@ -18,6 +18,10 @@
#include "d_event.h"
#include "w_wad.h" // for MAX_WADFILES
#ifdef __cplusplus
extern "C" {
#endif
// make sure not to write back the config until it's been correctly loaded
extern tic_t rendergametic;
@ -52,4 +56,8 @@ const char *D_Home(void);
//
void D_StartTitle(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__D_MAIN__

View file

@ -18,6 +18,10 @@
#ifndef __D_NET__
#define __D_NET__
#ifdef __cplusplus
extern "C" {
#endif
// Max computers in a game
// 127 is probably as high as this can go, because
// SINT8 is used for nodes sometimes >:(
@ -64,4 +68,8 @@ void Net_AbortPacketType(UINT8 packettype);
void Net_SendAcks(INT32 node);
void Net_WaitAllAckReceived(UINT32 timeout);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -4742,7 +4742,7 @@ static void Command_ListDoomednums_f(void)
static void Command_Version_f(void)
{
#ifdef DEVELOP
CONS_Printf("Ring Racers %s-%s (%s %s)\n", compbranch, comprevision, compdate, comptime);
CONS_Printf("Ring Racers %s %s (%s %s)\n", compbranch, comprevision, compdate, comptime);
#else
CONS_Printf("Ring Racers %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch);
#endif

View file

@ -18,6 +18,10 @@
#include "command.h"
#include "d_player.h"
#ifdef __cplusplus
extern "C" {
#endif
// console vars
extern consvar_t cv_playername[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_playercolor[MAXSPLITSCREENPLAYERS];
@ -279,4 +283,8 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...);
UINT8 CanChangeSkin(INT32 playernum);
boolean CanChangeSkinWhilePlaying(INT32 playernum);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "d_clisrv.h"
#include "w_wad.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
SF_FILE,
@ -162,4 +166,8 @@ void CURLGetFile(void);
HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next);
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __D_NETFIL__

View file

@ -32,6 +32,10 @@
// the player struct stores a waypoint for racing
#include "k_waypoint.h"
#ifdef __cplusplus
extern "C" {
#endif
// Extra abilities/settings for skins (combinable stuff)
typedef enum
{
@ -657,4 +661,8 @@ struct player_t
#endif
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#ifndef __D_THINK__
#define __D_THINK__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
@ -51,4 +55,8 @@ struct thinker_t
INT32 references;
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "m_fixed.h"
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
@ -78,4 +82,8 @@ struct ticcmd_t
#pragma pack()
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -13,9 +13,17 @@
#ifndef __DEH_LUA_H__
#define __DEH_LUA_H__
#ifdef __cplusplus
extern "C" {
#endif
boolean LUA_SetLuaAction(void *state, const char *actiontocompare);
const char *LUA_GetActionName(void *action);
void LUA_SetActionByName(void *state, const char *actiontocompare);
size_t LUA_GetActionNumByName(const char *actiontocompare);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -45,6 +45,10 @@
#include "dehacked.h"
#include "doomdef.h" // HWRENDER
#ifdef __cplusplus
extern "C" {
#endif
// Crazy word-reading stuff
/// \todo Put these in a seperate file or something.
mobjtype_t get_mobjtype(const char *word);
@ -87,4 +91,8 @@ void readfollowercategory(MYFILE *f);
preciptype_t get_precip(const char *word);
void readweather(MYFILE *f, INT32 num);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -18,6 +18,10 @@
#include "info.h" // Mobj, state, sprite, etc constants
#include "lua_script.h"
#ifdef __cplusplus
extern "C" {
#endif
// Free slot names
// The crazy word-reading stuff uses these.
extern char *FREE_STATES[NUMSTATEFREESLOTS];
@ -78,4 +82,8 @@ extern struct int_const_s const INT_CONST[];
// Moved to this file because it can't work compile-time otherwise
void DEH_TableCheck(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "m_fixed.h" // for get_number
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
UNDO_NONE = 0x00,
@ -69,5 +73,8 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f);
char *myhashfgets(char *buf, size_t bufsize, MYFILE *f);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include <discord_rpc.h>
#ifdef __cplusplus
extern "C" {
#endif
extern consvar_t cv_discordrp;
extern consvar_t cv_discordstreamer;
extern consvar_t cv_discordasks;
@ -77,4 +81,8 @@ void DRPC_UpdatePresence(void);
#endif // HAVE_DISCORDRPC
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __DISCORD__

View file

@ -26,6 +26,10 @@
#include "taglist.h"
#include "m_fixed.h" // See the mapthing_t scale.
#ifdef __cplusplus
extern "C" {
#endif
//
// Map level types.
// The following data structures define the persistent format
@ -258,4 +262,8 @@ enum
CEILING_SLOPE_THING = 778,
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __DOOMDATA__

View file

@ -97,6 +97,10 @@
#include <io.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
//#define NOMD5
// Uncheck this to compile debugging code
@ -746,4 +750,8 @@ extern int compuncommitted;
/// Other karma comeback modes
//#define OTHERKARMAMODES
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __DOOMDEF__

View file

@ -28,6 +28,10 @@
// For lumpnum_t.
#include "w_wad.h"
#ifdef __cplusplus
extern "C" {
#endif
// =============================
// Selected map etc.
// =============================
@ -750,4 +754,8 @@ extern INT32 adminplayers[MAXPLAYERS];
/// \note put these in d_clisrv outright?
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__DOOMSTAT__

View file

@ -19,6 +19,10 @@
#include "d_event.h"
#include "p_mobj.h"
#ifdef __cplusplus
extern "C" {
#endif
//
// FINALE
//
@ -196,4 +200,8 @@ enum
extern UINT8 wipedefs[NUMWIPEDEFS];
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -1,6 +1,10 @@
#ifndef __FASTCMP_H__
#define __FASTCMP_H__
#ifdef __cplusplus
extern "C" {
#endif
// returns false if s != c
// returns true if s == c
FUNCINLINE static ATTRINLINE boolean fasticmp(const char *s, const char *c)
@ -24,4 +28,8 @@ FUNCINLINE static ATTRINLINE boolean fastncmp(const char *s, const char *c, UINT
return !l; // make sure you reached the end
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -8,6 +8,10 @@
#include "d_netfil.h"
#include "k_menu.h" // MAXSTRINGLENGTH
#ifdef __cplusplus
extern "C" {
#endif
extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_showall, cv_addons_search_case, cv_addons_search_type;
/** \brief The filesearch function
@ -93,4 +97,8 @@ void closefilemenu(boolean validsize);
void searchfilemenu(char *tempname);
boolean preparefilemenu(boolean samedepth, boolean replayhut);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __FILESRCH_H__

View file

@ -13,6 +13,10 @@
#ifndef __FONT_H__
#define __FONT_H__
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_FONTS 32
struct font_t
@ -44,4 +48,8 @@ Register a new font, but do not load it yet.
*/
int Font_DumbRegister (const font_t *);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -18,6 +18,10 @@
#include "doomstat.h"
#include "d_event.h"
#ifdef __cplusplus
extern "C" {
#endif
// ======================================
// DEMO playback/recording related stuff.
// ======================================
@ -201,4 +205,8 @@ boolean G_DemoTitleResponder(event_t *ev);
boolean G_CheckDemoTitleEntry(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __G_DEMO__

View file

@ -75,7 +75,9 @@ JoyType_t Joystick[MAXSPLITSCREENPLAYERS];
// SRB2kart
char gamedatafilename[64] =
#ifdef DEVELOP
#if defined (TESTERS) || defined (HOSTTESTERS)
"test"
#elif defined(DEVELOP)
"develop"
#endif
"ringdata.dat";

View file

@ -20,6 +20,10 @@
#include "g_demo.h"
#include "m_cheat.h" // objectplacing
#ifdef __cplusplus
extern "C" {
#endif
extern char gamedatafilename[64];
extern char timeattackfolder[64];
extern char customversionstring[32];
@ -262,4 +266,8 @@ INT16 G_GetFirstMapOfGametype(UINT8 pgametype);
INT16 G_RandMap(UINT32 tolflags, INT16 pprevmap, UINT8 ignorebuffer, UINT8 maphell, boolean callagainsoon, INT16 *extbuffer);
void G_AddMapToBuffer(INT16 map);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -18,6 +18,10 @@
#include "keys.h"
#include "command.h"
#ifdef __cplusplus
extern "C" {
#endif
// number of total 'button' inputs, include keyboard keys, plus virtual
// keys (mousebuttons and joybuttons becomes keys)
#define NUMKEYS 256
@ -156,4 +160,8 @@ void G_CopyControls(INT32 (*setupcontrols)[MAXINPUTMAPPING], INT32 (*fromcontrol
void G_SaveKeySetting(FILE *f, INT32 (*fromcontrolsa)[MAXINPUTMAPPING], INT32 (*fromcontrolsb)[MAXINPUTMAPPING], INT32 (*fromcontrolsc)[MAXINPUTMAPPING], INT32 (*fromcontrolsd)[MAXINPUTMAPPING]);
INT32 G_CheckDoubleUsage(INT32 keynum, INT32 playernum, boolean modify);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
// the current state of the game
typedef enum
{
@ -58,4 +62,8 @@ extern UINT8 titlemapinaction;
extern UINT8 ultimatemode; // was sk_insane
extern gameaction_t gameaction;
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__G_STATE__

View file

@ -16,6 +16,10 @@
#include "hw_dll.h"
#include "hws_data.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined (HAVE_SDL) || !defined (HWD)
EXPORT void HWRAPI(Shutdown) (void);
#endif
@ -74,4 +78,8 @@ extern struct hardware3ds_s hw3ds_driver;
#endif // _CREATE_DLL_
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __HW_3DS_DRV_H__

View file

@ -17,6 +17,10 @@
//#include "../s_sound.h"
//#include "../p_mobj.h"
#ifdef __cplusplus
extern "C" {
#endif
// Default sound mode (original stereo mode)
enum
{
@ -95,4 +99,8 @@ void HW3S_FreeSfx(sfxinfo_t *sfx);
INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source,
INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __HW3_SOUND_H__

View file

@ -16,6 +16,10 @@
#include "hw_data.h"
#include "hw_drv.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused
@ -33,4 +37,8 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
void HWR_RenderBatches(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -7,11 +7,18 @@
*
*/
#ifndef __HARDWARE_HW_CLIP_H__
#define __HARDWARE_HW_CLIP_H__
// OpenGL BSP clipping
#include "../doomdef.h"
#include "../tables.h"
#include "../doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
//#define HAVE_SPHEREFRUSTRUM // enable if you want gld_SphereInFrustum and related code
boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle);
@ -22,3 +29,9 @@ angle_t gld_FrustumAngle(angle_t tiltangle);
void gld_FrustrumSetup(void);
boolean gld_SphereInFrustum(float x, float y, float z, float radius);
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __HARDWARE_HW_CLIP_H__

View file

@ -22,6 +22,10 @@
#include "../doomdef.h"
#include "../screen.h"
#ifdef __cplusplus
extern "C" {
#endif
// ==========================================================================
// TEXTURE INFO
// ==========================================================================
@ -86,4 +90,8 @@ struct GLPatch_s
};
typedef struct GLPatch_s GLPatch_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif //_HWR_DATA_

View file

@ -15,6 +15,10 @@
#include "../doomtype.h"
#include "../r_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
@ -330,4 +334,8 @@ enum hwdfiltermode
HWD_SET_TEXTUREFILTER_MIXED3,
};
#ifdef __cplusplus
} // extern "C"
#endif
#endif //_HWR_DEFS_

View file

@ -12,6 +12,10 @@
#ifndef __HWR_DLL_H__
#define __HWR_DLL_H__
#ifdef __cplusplus
extern "C" {
#endif
// Function declaration for exports from the DLL :
// EXPORT <return-type> HWRAPI(<function-name>) (<arguments>);
// If _CREATE_DLL_ is defined the above declaration translates to :
@ -56,4 +60,8 @@ void _init();
void _fini();
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -21,6 +21,10 @@
#include "hw_dll.h"
#ifdef __cplusplus
extern "C" {
#endif
// ==========================================================================
// STANDARD DLL EXPORTS
// ==========================================================================
@ -129,4 +133,8 @@ extern struct hwdriver_s hwdriver;
#endif //not defined _CREATE_DLL_
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__HWR_DRV_H__

View file

@ -19,6 +19,10 @@
#include "../r_defs.h"
#include "../p_setup.h"
#ifdef __cplusplus
extern "C" {
#endif
// the original aspect ratio of Doom graphics isn't square
#define ORIGINAL_ASPECT (320.0f/200.0f)
@ -143,4 +147,8 @@ void HWR_SetPalette(RGBA_t *palette);
extern INT32 patchformat;
extern INT32 textureformat;
#ifdef __cplusplus
} // extern "C"
#endif
#endif //_HW_GLOB_

View file

@ -16,6 +16,10 @@
#include "hw_glob.h"
#include "hw_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define NUMLIGHTFREESLOTS 32 // Free light slots (for SOCs)
#ifdef ALAM_LIGHTING
@ -91,4 +95,9 @@ typedef enum
extern light_t lspr[NUMLIGHTS];
extern light_t *t_lspr[NUMSPRITES];
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -20,6 +20,10 @@
#include "../d_player.h"
#include "../r_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
// Startup & Shutdown the hardware mode renderer
void HWR_Startup(void);
void HWR_Switch(void);
@ -150,4 +154,8 @@ extern boolean gl_maptexturesloaded;
extern boolean gl_sessioncommandsadded;
extern boolean gl_shadersavailable;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "hw_glob.h"
#include "hw_model.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_MSC_VER)
#pragma pack()
#endif
@ -46,4 +50,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr);
#define PLAYERMODELPREFIX "PLAYER"
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _HW_MD2_H_

View file

@ -13,7 +13,15 @@
#include "hw_model.h"
#include "../doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
// Load the Model
model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -13,7 +13,15 @@
#include "hw_model.h"
#include "../doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
// Load the Model
model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -12,6 +12,10 @@
#include "../doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
float x, y, z;
@ -132,4 +136,8 @@ void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame);
void CreateVBO(mesh_t *mesh, mdlframe_t *frame);
void DeleteVBOs(model_t *model);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -12,6 +12,10 @@
#ifndef __HWS_DATA_H__
#define __HWS_DATA_H__
#ifdef __cplusplus
extern "C" {
#endif
#define NORMAL_SEP 128
// abuse?
@ -113,4 +117,8 @@ typedef struct snddev_s
#endif
} snddev_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__HWS_DATA_H__

View file

@ -47,6 +47,10 @@
#include "../../doomdef.h"
#include "../hw_drv.h"
#ifdef __cplusplus
extern "C" {
#endif
// ==========================================================================
// DEFINITIONS
// ==========================================================================
@ -138,4 +142,8 @@ typedef enum
GLF_NOTEXENV = 0x02,
} oglflags_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -9,6 +9,10 @@
#ifndef _R_VBO_H_
#define _R_VBO_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
float x, y, z; // Vertex
@ -49,4 +53,8 @@ typedef struct
unsigned char r, g, b, a; // Color
} vbo64_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -10,6 +10,10 @@
#ifndef _U_LIST_H_
#define _U_LIST_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct listitem_s
{
struct listitem_s *next;
@ -26,4 +30,8 @@ void ListRemoveNoFree(void *pItem, listitem_t **itemHead);
unsigned int ListGetCount(void *itemHead);
listitem_t *ListGetByIndex(void *itemHead, unsigned int index);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -19,6 +19,10 @@
#include "r_defs.h"
#include "font.h"
#ifdef __cplusplus
extern "C" {
#endif
//------------------------------------
// heads up font
//------------------------------------
@ -152,4 +156,9 @@ void HU_DoCEcho(const char *msg);
// Demo playback info
extern UINT32 hu_demotime;
extern UINT32 hu_demolap;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -12,6 +12,10 @@
#ifndef __I_ADDRINFO__
#define __I_ADDRINFO__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
@ -68,4 +72,8 @@ int I_getaddrinfo(const char *node, const char *service,
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "g_input.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
\brief -JOYAXISRANGE to +JOYAXISRANGE for each axis
@ -54,4 +58,8 @@ struct JoyType_t
extern JoyType_t Joystick[MAXSPLITSCREENPLAYERS];
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __I_JOY_H__

View file

@ -33,6 +33,10 @@
#define NO_BAN_TIME (time_t)(-1)
#ifdef __cplusplus
extern "C" {
#endif
extern INT16 hardware_MAXPACKETLENGTH;
extern INT32 net_bandwidth; // in byte/s
@ -182,4 +186,8 @@ extern bannednode_t *bannednode;
/// \brief Called by D_SRB2Main to be defined by extern network driver
boolean I_InitNetwork(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -18,6 +18,10 @@
#include "sounds.h"
#include "command.h"
#ifdef __cplusplus
extern "C" {
#endif
// copied from SDL mixer, plus GME
typedef enum {
MU_NONE,
@ -241,4 +245,8 @@ boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
boolean I_FadeOutStopSong(UINT32 ms);
boolean I_FadeInPlaySong(UINT32 ms, boolean looping);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "d_ticcmd.h"
#include "d_event.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
@ -361,4 +365,8 @@ void I_RegisterSysCommands(void);
void I_CursedWindowMovement(int xd, int yd);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -13,6 +13,10 @@
#ifndef __I_TCP__
#define __I_TCP__
#ifdef __cplusplus
extern "C" {
#endif
extern UINT16 current_port;
/** \brief The I_InitTcpNetwork function
@ -28,4 +32,8 @@ boolean I_InitTcpNetwork(void);
boolean I_InitTcpDriver(void);
void I_ShutdownTcpDriver(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -14,6 +14,10 @@
#ifndef I_THREADS_H
#define I_THREADS_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*I_thread_fn)(void *userdata);
typedef void * I_mutex;
@ -35,5 +39,9 @@ void I_hold_cond (I_cond *, I_mutex);
void I_wake_one_cond (I_cond *);
void I_wake_all_cond (I_cond *);
#ifdef __cplusplus
} // extern "C"
#endif
#endif/*I_THREADS_H*/
#endif/*HAVE_THREADS*/

View file

@ -16,6 +16,10 @@
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
@ -153,4 +157,8 @@ void I_EndRead(void);
UINT32 I_GetRefreshRate(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -19,6 +19,10 @@
#include "sounds.h"
#include "m_fixed.h"
#ifdef __cplusplus
extern "C" {
#endif
// deh_tables.c now has lists for the more named enums! PLEASE keep them up to date!
// For great modding!!
@ -6739,4 +6743,8 @@ void P_BackupTables(void);
void P_ResetData(INT32 flags);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

4
src/io/CMakeLists.txt Normal file
View file

@ -0,0 +1,4 @@
target_sources(SRB2SDL2 PRIVATE
streams.cpp
streams.hpp
)

4
src/io/streams.cpp Normal file
View file

@ -0,0 +1,4 @@
#include "streams.hpp"
template class srb2::io::ZlibInputStream<srb2::io::SpanStream>;
template class srb2::io::ZlibInputStream<srb2::io::VecStream>;

733
src/io/streams.hpp Normal file
View file

@ -0,0 +1,733 @@
#ifndef __SRB2_IO_STREAMS_HPP__
#define __SRB2_IO_STREAMS_HPP__
#include <cstddef>
#include <optional>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include <tcb/span.hpp>
#include <zlib.h>
namespace srb2::io {
using StreamSize = uint64_t;
using StreamOffset = int64_t;
enum class SeekFrom {
kStart,
kCurrent,
kEnd
};
template <typename T>
struct IsInputStream
: public std::is_same<decltype(std::declval<T&>().read(std::declval<tcb::span<std::byte>>())), StreamSize> {};
template <typename T>
struct IsOutputStream
: public std::is_same<decltype(std::declval<T&>().write(std::declval<tcb::span<const std::byte>>())), StreamSize> {
};
template <typename T>
struct IsSeekableStream
: public std::is_same<decltype(std::declval<T&>().seek(std::declval<SeekFrom>(), std::declval<StreamOffset>())),
StreamSize> {};
template <typename T>
struct IsStream : public std::disjunction<IsInputStream<T>, IsOutputStream<T>> {};
template <typename T>
struct IsInputOutputStream : public std::conjunction<IsInputStream<T>, IsOutputStream<T>> {};
template <typename T>
inline constexpr const bool IsInputStreamV = IsInputStream<T>::value;
template <typename T>
inline constexpr const bool IsOutputStreamV = IsOutputStream<T>::value;
template <typename T>
inline constexpr const bool IsSeekableStreamV = IsSeekableStream<T>::value;
template <typename T>
inline constexpr const bool IsStreamV = IsStream<T>::value;
template <typename T>
inline constexpr const bool IsInputOutputStreamV = IsInputOutputStream<T>::value;
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read_exact(I& stream, tcb::span<std::byte> buffer) {
std::size_t total = 0;
const std::size_t buf_size = buffer.size();
while (total < buf_size) {
total += stream.read(buffer.subspan(total, buf_size - total));
}
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write_exact(O& stream, tcb::span<const std::byte> buffer) {
std::size_t total = 0;
const std::size_t buf_size = buffer.size();
while (total < buf_size) {
total += stream.write(buffer.subspan(total, buf_size - total));
}
}
enum class Endian {
kLE,
kBE,
};
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(std::byte& value, I& stream) {
read_exact(stream, tcb::span {&value, 1});
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(std::byte value, O& stream) {
write_exact(stream, tcb::span {&value, 1});
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(uint8_t& value, I& stream) {
std::byte in;
read_exact(stream, tcb::span {&in, 1});
value = std::to_integer<uint8_t>(in);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
uint8_t read_uint8(I& stream) {
uint8_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(uint8_t value, O& stream) {
std::byte out {value};
write_exact(stream, tcb::span {&out, 1});
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(bool& value, I& stream) {
uint8_t v;
read(v, stream);
value = !(v == 0);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
bool read_bool(I& stream) {
bool ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(bool value, O& stream) {
uint8_t out;
if (value)
out = 1;
else
out = 0;
write(out, stream);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(int8_t& value, I& stream) {
uint8_t in;
read(in, stream);
value = *reinterpret_cast<int8_t*>(&in);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
int8_t read_int8(I& stream) {
int8_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(int8_t value, O& stream) {
write(*reinterpret_cast<uint8_t*>(&value), stream);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(uint16_t& value, I& stream, Endian endian = Endian::kLE) {
std::array<std::byte, 2> out;
read_exact(stream, tcb::make_span(out));
if (endian == Endian::kBE)
value = std::to_integer<uint16_t>(out[1]) + (std::to_integer<uint16_t>(out[0]) << 8);
else
value = std::to_integer<uint16_t>(out[0]) + (std::to_integer<uint16_t>(out[1]) << 8);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
uint16_t read_uint16(I& stream) {
uint16_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(uint16_t value, O& stream, Endian endian = Endian::kLE) {
std::array<std::byte, 2> out;
if (endian == Endian::kBE)
out = {std::byte {static_cast<uint8_t>((value & 0xFF00) >> 8)},
std::byte {static_cast<uint8_t>((value & 0x00FF) >> 0)}};
else
out = {std::byte {static_cast<uint8_t>((value & 0x00FF) >> 0)},
std::byte {static_cast<uint8_t>((value & 0xFF00) >> 8)}};
write_exact(stream, tcb::make_span(out));
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(int16_t& value, I& stream, Endian endian = Endian::kLE) {
uint16_t r;
read(r, stream, endian);
value = *reinterpret_cast<int16_t*>(&r);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
int16_t read_int16(I& stream) {
int16_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(int16_t value, O& stream, Endian endian = Endian::kLE) {
write(*reinterpret_cast<int16_t*>(&value), stream, endian);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(uint32_t& value, I& stream, Endian endian = Endian::kLE) {
std::array<std::byte, 4> out;
read_exact(stream, tcb::make_span(out));
if (endian == Endian::kBE)
value = std::to_integer<uint32_t>(out[3]) + (std::to_integer<uint32_t>(out[2]) << 8) +
(std::to_integer<uint32_t>(out[1]) << 16) + (std::to_integer<uint32_t>(out[0]) << 24);
else
value = std::to_integer<uint32_t>(out[0]) + (std::to_integer<uint32_t>(out[1]) << 8) +
(std::to_integer<uint32_t>(out[2]) << 16) + (std::to_integer<uint32_t>(out[3]) << 24);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
uint32_t read_uint32(I& stream) {
uint32_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(uint32_t value, O& stream, Endian endian = Endian::kLE) {
std::array<std::byte, 4> out;
if (endian == Endian::kBE)
out = {std::byte {static_cast<uint8_t>((value & 0xFF000000) >> 24)},
std::byte {static_cast<uint8_t>((value & 0x00FF0000) >> 16)},
std::byte {static_cast<uint8_t>((value & 0x0000FF00) >> 8)},
std::byte {static_cast<uint8_t>((value & 0x000000FF) >> 0)}};
else
out = {std::byte {static_cast<uint8_t>((value & 0x000000FF) >> 0)},
std::byte {static_cast<uint8_t>((value & 0x0000FF00) >> 8)},
std::byte {static_cast<uint8_t>((value & 0x00FF0000) >> 16)},
std::byte {static_cast<uint8_t>((value & 0xFF000000) >> 24)}};
write_exact(stream, tcb::make_span(out));
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(int32_t& value, I& stream, Endian endian = Endian::kLE) {
uint32_t r;
read(r, stream, endian);
value = *reinterpret_cast<int32_t*>(&r);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
int32_t read_int32(I& stream) {
int32_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(int32_t value, O& stream, Endian endian = Endian::kLE) {
write(*reinterpret_cast<uint32_t*>(&value), stream, endian);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(uint64_t& value, I& stream, Endian endian = Endian::kLE) {
std::array<std::byte, 8> out;
read_exact(stream, tcb::make_span(out));
if (endian == Endian::kBE)
value = std::to_integer<uint64_t>(out[7]) + (std::to_integer<uint64_t>(out[6]) << 8) +
(std::to_integer<uint64_t>(out[5]) << 16) + (std::to_integer<uint64_t>(out[4]) << 24) +
(std::to_integer<uint64_t>(out[3]) << 32) + (std::to_integer<uint64_t>(out[2]) << 40) +
(std::to_integer<uint64_t>(out[1]) << 48) + (std::to_integer<uint64_t>(out[0]) << 56);
else
value = std::to_integer<uint64_t>(out[0]) + (std::to_integer<uint64_t>(out[1]) << 8) +
(std::to_integer<uint64_t>(out[2]) << 16) + (std::to_integer<uint64_t>(out[3]) << 24) +
(std::to_integer<uint64_t>(out[4]) << 32) + (std::to_integer<uint64_t>(out[5]) << 40) +
(std::to_integer<uint64_t>(out[6]) << 48) + (std::to_integer<uint64_t>(out[7]) << 56);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
uint64_t read_uint64(I& stream) {
uint64_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(uint64_t value, O& stream, Endian endian = Endian::kLE) {
std::array<std::byte, 8> out;
if (endian == Endian::kBE)
out = {std::byte {static_cast<uint8_t>((value & 0xFF00000000000000) >> 56)},
std::byte {static_cast<uint8_t>((value & 0x00FF000000000000) >> 48)},
std::byte {static_cast<uint8_t>((value & 0x0000FF0000000000) >> 40)},
std::byte {static_cast<uint8_t>((value & 0x000000FF00000000) >> 32)},
std::byte {static_cast<uint8_t>((value & 0x00000000FF000000) >> 24)},
std::byte {static_cast<uint8_t>((value & 0x0000000000FF0000) >> 16)},
std::byte {static_cast<uint8_t>((value & 0x000000000000FF00) >> 8)},
std::byte {static_cast<uint8_t>((value & 0x00000000000000FF) >> 0)}};
else
out = {std::byte {static_cast<uint8_t>((value & 0x00000000000000FF) >> 0)},
std::byte {static_cast<uint8_t>((value & 0x000000000000FF00) >> 8)},
std::byte {static_cast<uint8_t>((value & 0x0000000000FF0000) >> 16)},
std::byte {static_cast<uint8_t>((value & 0x00000000FF000000) >> 24)},
std::byte {static_cast<uint8_t>((value & 0x000000FF00000000) >> 32)},
std::byte {static_cast<uint8_t>((value & 0x0000FF0000000000) >> 40)},
std::byte {static_cast<uint8_t>((value & 0x00FF000000000000) >> 48)},
std::byte {static_cast<uint8_t>((value & 0xFF00000000000000) >> 56)}};
write_exact(stream, tcb::make_span(out));
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(int64_t& value, I& stream, Endian endian = Endian::kLE) {
uint64_t r;
read(r, stream, endian);
value = *reinterpret_cast<int64_t*>(&r);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
int64_t read_int64(I& stream) {
int64_t ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(int64_t value, O& stream, Endian endian = Endian::kLE) {
write(*reinterpret_cast<uint64_t*>(&value), stream, endian);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(float& value, I& stream, Endian endian = Endian::kLE) {
uint32_t r;
read(r, stream, endian);
value = *reinterpret_cast<float*>(&r);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
float read_float(I& stream) {
float ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(float value, O& stream, Endian endian = Endian::kLE) {
write(*reinterpret_cast<int32_t*>(&value), stream, endian);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
void read(double& value, I& stream, Endian endian = Endian::kLE) {
uint64_t r;
read(r, stream, endian);
value = *reinterpret_cast<double*>(&r);
}
template <typename I, typename std::enable_if_t<IsInputStreamV<I>>* = nullptr>
double read_double(I& stream) {
double ret;
read(ret, stream);
return ret;
}
template <typename O, typename std::enable_if_t<IsOutputStreamV<O>>* = nullptr>
void write(double value, O& stream, Endian endian = Endian::kLE) {
write(*reinterpret_cast<int64_t*>(&value), stream, endian);
}
template <typename S, typename std::enable_if_t<IsSeekableStreamV<S>>* = nullptr>
StreamSize remaining(S& stream) {
const StreamSize current = stream.seek(SeekFrom::kCurrent, 0);
const StreamSize end = stream.seek(SeekFrom::kEnd, 0);
stream.seek(SeekFrom::kStart, current);
return end - current;
}
// Kinds of streams
class SpanStream {
public:
SpanStream() noexcept = default;
SpanStream(tcb::span<std::byte> span) : span_(span), head_(0) {
if (span_.size() > static_cast<StreamSize>(static_cast<StreamOffset>(-1))) {
throw std::logic_error("Span must not be greater than 2 billion bytes");
}
};
StreamSize read(tcb::span<std::byte> buffer) {
if (head_ >= span_.size())
return 0;
const auto begin = buffer.begin();
const auto end = std::copy(
span_.begin() + head_, span_.begin() + head_ + std::min(buffer.size(), span_.size() - head_), begin);
head_ += std::distance(begin, end);
return std::distance(begin, end);
}
StreamSize write(tcb::span<const std::byte> buffer) {
if (head_ >= span_.size())
return 0;
const auto begin = span_.begin() + head_;
const auto end =
std::copy(buffer.begin(), buffer.begin() + std::min(span_.size() - head_, buffer.size()), begin);
head_ += std::distance(begin, end);
return std::distance(begin, end);
}
StreamSize seek(SeekFrom seek_from, StreamOffset offset) {
std::size_t head = 0;
switch (seek_from) {
case SeekFrom::kStart:
if (offset < 0 || offset >= static_cast<StreamOffset>(span_.size())) {
throw std::logic_error("start offset is out of bounds");
}
head = offset;
break;
case SeekFrom::kEnd:
if (-offset >= static_cast<StreamOffset>(span_.size())) {
throw std::logic_error("end offset is out of bounds");
}
head = span_.size() - offset;
break;
case SeekFrom::kCurrent:
if (head_ + offset < 0 || head_ + offset >= span_.size()) {
throw std::logic_error("offset is out of bounds");
}
head = head_ + offset;
break;
}
std::swap(head, head_);
return head_;
}
private:
tcb::span<std::byte> span_;
std::size_t head_ {0};
};
class VecStream {
std::vector<std::byte> vec_;
std::size_t head_ {0};
public:
VecStream() = default;
VecStream(const std::vector<std::byte>& vec) : vec_(vec) {}
VecStream(std::vector<std::byte>&& vec) : vec_(std::move(vec)) {}
VecStream(const VecStream& rhs) = default;
VecStream(VecStream&& rhs) = default;
VecStream& operator=(const VecStream& rhs) = default;
VecStream& operator=(VecStream&& rhs) = default;
StreamSize read(tcb::span<std::byte> buffer) {
if (head_ >= vec_.size())
return 0;
const auto begin = buffer.begin();
const auto end =
std::copy(vec_.begin() + head_, vec_.begin() + head_ + std::min(buffer.size(), vec_.size() - head_), begin);
head_ += std::distance(begin, end);
return std::distance(begin, end);
}
StreamSize write(tcb::span<const std::byte> buffer) {
const std::size_t buffer_size = buffer.size();
if (head_ + buffer_size >= vec_.size()) {
vec_.resize(head_ + buffer_size);
}
const auto begin = vec_.begin() + head_;
const auto end =
std::copy(buffer.begin(), buffer.begin() + std::min(vec_.size() - head_, buffer.size()), begin);
head_ += std::distance(begin, end);
return std::distance(begin, end);
}
StreamSize seek(SeekFrom seek_from, StreamOffset offset) {
std::size_t head = 0;
switch (seek_from) {
case SeekFrom::kStart:
if (offset < 0 || offset >= static_cast<StreamOffset>(vec_.size())) {
throw std::logic_error("start offset is out of bounds");
}
head = offset;
break;
case SeekFrom::kEnd:
if (-offset >= static_cast<StreamOffset>(vec_.size())) {
throw std::logic_error("end offset is out of bounds");
}
head = vec_.size() - offset;
break;
case SeekFrom::kCurrent:
if (head_ + offset < 0 || head_ + offset >= vec_.size()) {
throw std::logic_error("offset is out of bounds");
}
head = head_ + offset;
break;
}
std::swap(head, head_);
return head_;
}
std::vector<std::byte>& vector() { return vec_; }
};
class ZlibException : public std::exception {
int err_ {0};
std::string msg_;
public:
ZlibException(int err, const char* msg = nullptr) : err_(err), msg_("srb2::io::ZlibException: zlib error: ") {
const char* err_msg = "(UNKNOWN) ";
switch (err_) {
case Z_OK:
err_msg = "(Z_OK) ";
break;
case Z_STREAM_END:
err_msg = "(Z_STREAM_END) ";
break;
case Z_NEED_DICT:
err_msg = "(Z_NEED_DICT) ";
break;
case Z_ERRNO:
err_msg = "(Z_ERRNO) ";
break;
case Z_STREAM_ERROR:
err_msg = "(Z_STREAM_ERROR) ";
break;
case Z_DATA_ERROR:
err_msg = "(Z_DATA_ERROR) ";
break;
case Z_MEM_ERROR:
err_msg = "(Z_MEM_ERROR) ";
break;
case Z_BUF_ERROR:
err_msg = "(Z_BUF_ERROR) ";
break;
case Z_VERSION_ERROR:
err_msg = "(Z_VERSION_ERROR) ";
break;
}
msg_.append(err_msg);
if (msg != nullptr)
msg_.append(msg);
else
msg_.append("nullptr");
}
virtual const char* what() const noexcept override final { return msg_.c_str(); }
};
template <typename I,
typename std::enable_if_t<IsInputStreamV<I> && std::is_move_constructible_v<I> &&
std::is_move_assignable_v<I>>* = nullptr>
class ZlibInputStream {
I inner_;
z_stream stream_;
std::vector<std::byte> buf_;
std::size_t buf_head_;
bool zstream_initialized_;
bool zstream_ended_;
public:
ZlibInputStream(I&& inner)
: inner_(std::move(inner))
, stream_ {}
, buf_()
, buf_head_(0)
, zstream_initialized_ {false}
, zstream_ended_ {false} {}
ZlibInputStream(const ZlibInputStream& rhs) = delete;
ZlibInputStream(ZlibInputStream&& rhs) = delete;
ZlibInputStream& operator=(const ZlibInputStream& rhs) = delete;
ZlibInputStream& operator=(ZlibInputStream&& rhs) = delete;
StreamSize read(tcb::span<std::byte> buffer) {
if (zstream_ended_)
return 0;
std::size_t written = 0;
const std::size_t buffer_size = buffer.size();
while (written < buffer_size && !zstream_ended_) {
_fill_read_buffer();
if (buf_.size() == 0) {
break;
}
const std::size_t written_this_time = _inflate(buffer.subspan(written));
written += written_this_time;
}
return written;
}
I& stream() { return inner_; }
void close() {
if (!zstream_initialized_)
return;
int ret = inflateEnd(&stream_);
if (ret != Z_OK)
throw ZlibException {ret, stream_.msg};
zstream_initialized_ = false;
zstream_ended_ = true;
}
~ZlibInputStream() {
if (zstream_initialized_) {
int ret = inflateEnd(&stream_);
if (ret != Z_OK)
// can't throw exceptions in destructors
std::terminate();
zstream_initialized_ = false;
zstream_ended_ = true;
}
};
private:
constexpr static const std::size_t kReadHighWater = 2048;
void _init() {
stream_.avail_in = buf_.size() - buf_head_;
const std::size_t start_avail_in = stream_.avail_in;
stream_.next_in = reinterpret_cast<Bytef*>(buf_.data() + buf_head_);
int ret = inflateInit2(&stream_, 32);
if (ret != Z_OK) {
throw ZlibException {ret, stream_.msg};
}
buf_head_ += start_avail_in - stream_.avail_in;
_move_buf_backwards();
zstream_initialized_ = true;
zstream_ended_ = false;
}
void _fill_read_buffer() {
const std::size_t old_size = buf_.size();
if (old_size < kReadHighWater) {
buf_.resize(kReadHighWater);
const std::size_t read = inner_.read(tcb::span(buf_.data() + old_size, buf_.size() - old_size));
buf_.resize(old_size + read);
}
}
StreamSize _inflate(tcb::span<std::byte> out) {
if (!zstream_initialized_) {
_init();
}
if (zstream_ended_)
return 0;
const std::size_t out_size = out.size();
stream_.avail_in = buf_.size() - buf_head_;
const std::size_t start_avail_in = stream_.avail_in;
stream_.next_in = reinterpret_cast<Bytef*>(buf_.data() + buf_head_);
stream_.avail_out = out_size;
const std::size_t start_avail_out = stream_.avail_out;
stream_.next_out = reinterpret_cast<Bytef*>(out.data());
int ret = inflate(&stream_, Z_NO_FLUSH);
if (ret == Z_STREAM_END) {
zstream_ended_ = true;
} else if (ret != Z_OK && ret != Z_BUF_ERROR) {
throw ZlibException {ret, stream_.msg};
}
buf_head_ += start_avail_in - stream_.avail_in;
const std::size_t written = start_avail_out - stream_.avail_out;
_move_buf_backwards();
return written;
}
void _move_buf_backwards() {
if (buf_head_ == 0) {
return;
}
if (buf_head_ >= buf_.size()) {
buf_.clear();
buf_head_ = 0;
return;
}
auto end = std::move(buf_.begin() + buf_head_, buf_.end(), buf_.begin());
buf_.resize(end - buf_.begin());
buf_head_ = 0;
}
};
// Utility functions
template <typename I, typename O>
StreamSize pipe_all(I& input, O& output) {
std::vector<std::byte> buf;
StreamSize total_written = 0;
StreamSize read_this_time = 0;
do {
buf.clear();
buf.resize(2048);
read_this_time = input.read(tcb::make_span(buf));
buf.resize(read_this_time);
write_exact(output, tcb::make_span(buf));
total_written += read_this_time;
} while (read_this_time != 0);
return total_written;
}
template <typename I>
std::vector<std::byte> read_to_vec(I& input) {
VecStream out;
pipe_all(input, out);
return std::move(out.vector());
}
// Instantiated templates
extern template class ZlibInputStream<SpanStream>;
extern template class ZlibInputStream<VecStream>;
} // namespace srb2::io
#endif // __SRB2_IO_STREAMS_HPP__

View file

@ -4,6 +4,10 @@
#include "doomtype.h"
#include "d_player.h"
#ifdef __cplusplus
extern "C" {
#endif
extern struct battleovertime
{
UINT16 enabled; ///< Has this been initalized yet?
@ -31,4 +35,8 @@ void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj);
void K_SpawnPlayerBattleBumpers(player_t *p);
void K_BattleInit(boolean singleplayercontext);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "doomdef.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void(*updateindexfunc)(void *const, const size_t);
struct bheapitem_t
@ -150,4 +154,8 @@ size_t K_BHeapContains(bheap_t *const heap, void *const data, size_t index);
boolean K_BHeapFree(bheap_t *const heap);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -16,6 +16,10 @@
#include "doomdef.h"
#include "doomstat.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
SPOT_NONE = 0,
@ -112,4 +116,8 @@ void K_UpdateBossHealthBar(fixed_t magnitude, tic_t jitterlen);
void K_DeclareWeakspot(mobj_t *spot, spottype_t spottype, UINT16 color, boolean minimap);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "d_player.h"
#include "r_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
// Maximum value of botvars.difficulty
#define MAXBOTDIFFICULTY 13
@ -270,4 +274,8 @@ void K_UpdateBotGameplayVars(player_t *player);
void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -17,6 +17,10 @@
#include "doomdef.h"
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
struct brightmapStorage_t
{
// Brightmap storage struct.
@ -46,4 +50,8 @@ void K_InitBrightmapsPwad(INT32 wadNum);
void K_InitBrightmaps(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __K_BRIGHTMAP_H__

View file

@ -4,6 +4,10 @@
#include "doomtype.h"
#include "p_mobj.h"
#ifdef __cplusplus
extern "C" {
#endif
angle_t K_GetCollideAngle(mobj_t *t1, mobj_t *t2);
boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2);
@ -27,4 +31,8 @@ boolean K_SMKIceBlockCollide(mobj_t *t1, mobj_t *t2);
boolean K_PvPTouchDamage(mobj_t *t1, mobj_t *t2);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "doomdef.h"
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SKIN_RAMP_LENGTH 16
#define DEFAULT_STARTTRANSCOLOR 96
#define NUM_PALETTE_ENTRIES 256
@ -110,4 +114,8 @@ void K_HitlagColormap(UINT8 *dest_colormap);
--------------------------------------------------*/
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -3,6 +3,13 @@
/// \file k_director.h
/// \brief SRB2kart automatic spectator camera.
#ifndef __K_DIRECTOR_H__
#define __K_DIRECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
extern struct directorinfo
{
tic_t cooldown; // how long has it been since we last switched?
@ -18,4 +25,10 @@ extern struct directorinfo
void K_InitDirector(void);
void K_UpdateDirector(void);
void K_DrawDirectorDebugger(void);
void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source);
void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __K_DIRECTOR_H__

View file

@ -16,6 +16,10 @@
#include "doomdef.h"
#include "doomstat.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FOLLOWERCOLOR_MATCH UINT16_MAX
#define FOLLOWERCOLOR_OPPOSITE (UINT16_MAX-1)
@ -211,5 +215,8 @@ void K_HandleFollower(player_t *player);
void K_RemoveFollower(player_t *player);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __K_FOLLOWER__

View file

@ -16,6 +16,10 @@
#include "doomdef.h"
#include "doomstat.h"
#ifdef __cplusplus
extern "C" {
#endif
#define GPEVENT_NONE 0
#define GPEVENT_BONUS 1
#define GPEVENT_SPECIAL 2
@ -166,4 +170,8 @@ void K_PlayerLoseLife(player_t *player);
boolean K_CanChangeRules(boolean allowdemos);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -9,12 +9,16 @@
/// \file k_hud.h
/// \brief HUD drawing functions exclusive to Kart
#ifndef __K_HUD__
#define __K_HUD__
#include "doomtype.h"
#include "doomstat.h"
#include "hu_stuff.h"
#ifndef __K_HUD__
#define __K_HUD__
#ifdef __cplusplus
extern "C" {
#endif
#define RINGANIM_NUMFRAMES 10
#define RINGANIM_DELAYMAX 5
@ -43,4 +47,8 @@ void K_DrawLikeMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, patch_t
extern patch_t *kp_facehighlight[8];
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -10,6 +10,10 @@
#include "d_player.h" // Need for player_t
#include "command.h" // Need for player_t
#ifdef __cplusplus
extern "C" {
#endif
#define KART_FULLTURN 800
/*
@ -193,5 +197,9 @@ fixed_t K_ItemScaleForPlayer(player_t *player);
void K_SetItemOut(player_t *player);
void K_UnsetItemOut(player_t *player);
#ifdef __cplusplus
} // extern "C"
#endif
// =========================================================================
#endif // __K_KART__

View file

@ -24,6 +24,10 @@
#include "i_threads.h"
#include "mserv.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SERVERLISTDEBUG
// flags for items in the menu
@ -1195,5 +1199,8 @@ boolean M_StatisticsInputs(INT32 ch);
NULL\
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif //__K_MENU__

View file

@ -2,6 +2,10 @@
#ifndef k_objects_H
#define k_objects_H
#ifdef __cplusplus
extern "C" {
#endif
/* Hyudoro */
void Obj_InitHyudoroCenter(mobj_t *center, mobj_t *master);
void Obj_HyudoroDeploy(mobj_t *master);
@ -69,4 +73,8 @@ void Obj_UFOPieceRemoved(mobj_t *piece);
mobj_t *Obj_CreateSpecialUFO(void);
UINT32 K_GetSpecialUFODistance(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif/*k_objects_H*/

View file

@ -15,6 +15,10 @@
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
// function pointer for returning a node's connected node data
// should return a pointer to an array of pointers to the data, as arguments takes a node's data and a pointer that the
// number of connected nodes should be placed into
@ -84,4 +88,8 @@ struct pathfindsetup_t {
--------------------------------------------------*/
boolean K_PathfindAStar(path_t *const path, pathfindsetup_t *const pathfindsetup);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -22,6 +22,10 @@
#include "g_game.h" // game CVs
#include "k_follower.h" // followers
#ifdef __cplusplus
extern "C" {
#endif
// We have to redefine this because somehow including r_skins.h causes a redefinition of node_t since that's used for both net nodes and BSP nodes too......
// And honestly I don't wanna refactor that.
#define SKINNAMESIZE 16
@ -152,4 +156,8 @@ SINT8 PR_ProfileUsedBy(profile_t *p);
profile_t *PR_GetPlayerProfile(player_t *player);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "doomdef.h"
#include "d_player.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
PWRLV_DISABLED = -1,
@ -47,4 +51,8 @@ void K_CashInPowerLevels(void);
void K_SetPowerLevelScrambles(SINT8 powertype);
void K_PlayerForfeit(UINT8 playernum, boolean nopointloss);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -14,6 +14,10 @@
#include "r_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern line_t *finishBeamLine;
#define FINISHLINEBEAM_SPACING (48*mapobjectscale)
@ -66,4 +70,8 @@ boolean K_GenerateFinishBeamLine(void);
void K_RunFinishLineBeam(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -15,6 +15,10 @@
#include "k_waypoint.h"
#include "d_player.h"
#ifdef __cplusplus
extern "C" {
#endif
#define RESPAWN_DIST 1024
#define RESPAWN_TIME 48
#define RESPAWNST_NONE 0x00
@ -98,4 +102,8 @@ size_t K_NextRespawnWaypointIndex(waypoint_t *waypoint);
void K_RespawnChecker(player_t *player);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -16,6 +16,10 @@
#include "doomtype.h"
#include "d_player.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ROULETTE_SPACING (36 << FRACBITS)
#define ROULETTE_SPACING_SPLITSCREEN (16 << FRACBITS)
@ -165,5 +169,8 @@ fixed_t K_GetRouletteOffset(itemroulette_t *const roulette, fixed_t renderDelta)
void K_KartItemRoulette(player_t *const player, ticcmd_t *cmd);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __K_ROULETTE_H__

View file

@ -16,6 +16,10 @@
#include "doomdef.h"
#include "doomstat.h"
#ifdef __cplusplus
extern "C" {
#endif
extern struct specialStage
{
boolean active; ///< If true, then we are in a special stage
@ -51,5 +55,8 @@ void K_InitSpecialStage(void);
void K_TickSpecialStage(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -20,6 +20,10 @@
#include "m_fixed.h"
#include "p_mobj.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TERRAIN_NAME_LEN 32
struct t_splash_t
@ -565,4 +569,8 @@ void K_UpdateTerrainOverlay(mobj_t *mo);
void K_InitTerrain(UINT16 wadNum);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __K_TERRAIN_H__

View file

@ -18,6 +18,10 @@
#include "p_mobj.h"
#include "k_pathfind.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEFAULT_WAYPOINT_RADIUS (384)
struct waypoint_t
@ -419,4 +423,8 @@ void K_ClearWaypoints(void);
void K_AdjustWaypointsParameters (void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -13,6 +13,10 @@
#ifndef __KEYS_H__
#define __KEYS_H__
#ifdef __cplusplus
extern "C" {
#endif
// These are the key codes as posted by the keyboard handler,
// ascii codes are 0->127,
// scancodes are 0x80 + 0->127
@ -94,4 +98,8 @@
#define KEY_OPENBRACKETS
#define KEY_CLOSEBRACKETS
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View file

@ -10,6 +10,9 @@
/// \file lua_hook.h
/// \brief hooks for Lua scripting
#ifndef __LUA_HOOK_H__
#define __LUA_HOOK_H__
#include "r_defs.h"
#include "d_player.h"
#include "s_sound.h"
@ -17,6 +20,10 @@
#include "lua_hudlib_drawlist.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
Do you know what an 'X Macro' is? Such a macro is called over each element of
a list and expands the input. I use it for the hook lists because both an enum
@ -143,3 +150,9 @@ int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boole
int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend);
int LUA_HookShouldJingleContinue(player_t *, const char *musname);
int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __LUA_HOOK_H__

View file

@ -15,6 +15,10 @@
#include "lua_hudlib_drawlist.h"
#ifdef __cplusplus
extern "C" {
#endif
enum hud {
hud_stagetitle = 0,
hud_textspectator,
@ -49,4 +53,8 @@ boolean LUA_HudEnabled(enum hud option);
void LUA_SetHudHook(int hook, huddrawlist_h list);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __LUA_HUD_H__

View file

@ -9,6 +9,12 @@
//-----------------------------------------------------------------------------
/// \file lua_libs.h
/// \brief libraries for Lua scripting
#ifndef __LUA_LIBS_H__
#define __LUA_LIBS_H__
#ifdef __cplusplus
extern "C" {
#endif
extern lua_State *gL;
@ -110,3 +116,9 @@ int LUA_TagLib(lua_State *L);
int LUA_PolyObjLib(lua_State *L);
int LUA_BlockmapLib(lua_State *L);
int LUA_HudLib(lua_State *L);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __LUA_LIBS_H__

View file

@ -23,6 +23,10 @@
#include "blua/lualib.h"
#include "blua/lauxlib.h"
#ifdef __cplusplus
extern "C" {
#endif
#define lua_optboolean(L, i) (!lua_isnoneornil(L, i) && lua_toboolean(L, i))
#define lua_opttrueboolean(L, i) (lua_isnoneornil(L, i) || lua_toboolean(L, i))
@ -140,4 +144,8 @@ void COM_Lua_f(void);
#define INLEVEL if (! ISINLEVEL)\
return luaL_error(L, "This can only be used in a level!");
#ifdef __cplusplus
} // extern "C"
#endif
#endif/*LUA_SCRIPT_H*/

Some files were not shown because too many files have changed in this diff Show more