-
Notifications
You must be signed in to change notification settings - Fork 5
How to Engine fork compatibility
Serious Sam Classics Patch can be built for forks of open-source version of Serious Engine 1. This page with guide you through the process of preparing your engine fork for the patch.
Even though it's possible to build the patch for 1.10, it's not officially supported due to the ambiguity of engine forks. It is still mainly recommended that you go through the code of Classics Patch and extract chunks of code that you need in your code (with respect to the license, of course).
This guide is primarily targeted towards users who aren't extremely familiar with Serious Engine 1 code but already had some experience with building it. If you're an experienced programmer and know quite a bit about the engine code, this guide will simply help point you in the right direction. It's not necessary to implement the exact code changes as described here. You are free to modify both Serious Engine 1 and Classics Patch code however you like.
Some features of Classics Patch have been automatically disabled when building under the TSE 1.10 configuration in order to minimize the external engine modifications and to avoid random errors with patching certain functions.
You can see which features are being automatically disabled in Core/Config.h file. If you wish to restore them, it's recommended to port all of the related code directly into the engine instead of trying to reenable them and fixing all the issues in Classics Patch itself.
Important
Be aware that if you have too many modifications in your fork, particularly in Ecc, Engine, EntitiesMP and GameMP projects, it might not be compatible with the patch and would require extra work in both the engine fork and Classics Patch to make them compatible with each other.
Here's a list of changes you have to make for your fork first.
You need to export certain classes and functions from the engine in order to let the patch hook and utilize them.
The steps described here aren't the most clean or convenient ways of doing things, but they are the easiest.
Global symbols to export:
- Classes:
CActionBuffer,CPlayerTarget,CSessionSocketParams,CSessionSocket - Filesystem functionality:
InitStreams(),_azeFiles,_azhHandles,_afnmArchives,zip_csLock
Class methods to export:
CNetworkMessage &CPlayerCharacter::operator<<(CNetworkMessage &, CPlayerCharacter &)CNetworkMessage &CPlayerCharacter::operator>>(CNetworkMessage &, CPlayerCharacter &)CNetworkMessage &CPlayerAction::operator<<(CNetworkMessage &, const CPlayerAction &)CNetworkMessage &CPlayerAction::operator>>(CNetworkMessage &, CPlayerAction &)CTStream &CPlayerAction::operator<<(CTStream &, const CPlayerAction &)CTStream &CPlayerAction::operator>>(CTStream &, CPlayerAction &)CNetworkMessage &CSessionSocketParams::operator<<(CNetworkMessage &, CSessionSocketParams &)CNetworkMessage &CSessionSocketParams::operator>>(CNetworkMessage &, CSessionSocketParams &)
Insert ENGINE_API in the beginning of this line.
void InitStreams(void)Replace static keyword with ENGINE_API in the beginning of these lines.
// all files in all active zip archives
static CStaticStackArray<CZipEntry> _azeFiles;
// handles for currently open files
static CStaticStackArray<CZipHandle> _azhHandles;
// filenames of all archives
static CStaticStackArray<CTFileName> _afnmArchives;Insert ENGINE_API in the beginning of this line.
CTCriticalSection zip_csLock;Insert ENGINE_API in the beginning of these lines inside the CPlayerCharacter class definition.
friend CNetworkMessage &operator<<(CNetworkMessage &nm, CPlayerCharacter &pc);
friend CNetworkMessage &operator>>(CNetworkMessage &nm, CPlayerCharacter &pc);Insert ENGINE_API in the beginning of these lines inside the CPlayerAction class definition.
friend CNetworkMessage &operator<<(CNetworkMessage &nm, const CPlayerAction &pa);
friend CNetworkMessage &operator>>(CNetworkMessage &nm, CPlayerAction &pa);
friend CTStream &operator<<(CTStream &strm, const CPlayerAction &pa);
friend CTStream &operator>>(CTStream &strm, CPlayerAction &pa);Export CActionBuffer class by adding ENGINE_API to its declaration.
// buffer of player actions, sorted by time of arrival
class ENGINE_API CActionBuffer {Export CPlayerTarget class by adding ENGINE_API to its declaration.
/*
* Player target, located in each session state; receiving actions
*/
class ENGINE_API CPlayerTarget {Export CSessionSocketParams and CSessionSocket classes by adding ENGINE_API to their declarations.
// parameters for a client
class ENGINE_API CSessionSocketParams {// connection data for each session connected to a server
class ENGINE_API CSessionSocket {Insert ENGINE_API in the beginning of these lines inside the CSessionSocketParams class declaration.
friend CNetworkMessage &operator<<(CNetworkMessage &nm, CSessionSocketParams &ssp);
friend CNetworkMessage &operator>>(CNetworkMessage &nm, CSessionSocketParams &ssp);Now this is a list of changes you have to make for Classics Patch.
Tip
Find a way to replace text in multiple source files at once, for example by using Notepad++ and its Ctrl+Shift+F shortcut.
After you're done building your engine fork, you need to copy its engine headers and libraries to replace the default ones for the 1.10 version.
- Go to your engine fork and copy all
.hand.inlfiles from theEnginefolder (or copy the folder in its entirety and delete the other files later). - Navigate to
Includes/Engine110/Enginewithin the Classics Patch source code and place all the copied files there, replacing existing ones.
- Find where your
Enginebinaries have been built (e.g.Sources/Engine/Releasein the original source code) and copyEngine.libfile from it. - Navigate to
Includes/Engine110and replaceEngine.libin there with your library.
If you've made significant changes to the EntitiesMP project in your engine fork, you need to copy its sources as well and do some slight adjustments to the code.
- Go to your engine fork and navigate to the
EntitiesMPfolder. - Copy all
.esfiles from the folder itself and.hfiles fromCommonandStdHsubfolders. - Navigate to
Includes/Engine110/EntitiesVwithin the Classics Patch source code and place all the copied files there, replacing existing ones.
- Navigate to
Includes/Engine110/EntitiesVfolder and replace all paths to sources fromEntitiesMPfolder toEntitiesVin all.esand.hfiles, either by using regex or by performing simple replacements:
-
#include "EntitiesMP->#include "EntitiesV -
uses "EntitiesMP->uses "EntitiesV
- Go back to
Includes/Engine110folder and run theCompileAllEntities.batscript to generate new.hfiles from the entity sources. - Open
Includes/Engine110/EntitiesV/StdH/StdH.hand modify it:
- Remove inclusion of
Engine/Engine.hheader. - Replace
DECL_DLLdefinition with_declspec(dllimport). - (If applicable) Replace all include paths from
GameMPfiles toGameVfiles.
If you've made significant changes to the GameMP project in your engine fork, you need to copy its headers as well.
- Go to your engine fork and copy all
.hfiles from theGameMPfolder (or copy the folder in its entirety and delete the other files later). - Navigate to
Includes/Engine110/GameVwithin the Classics Patch source code and place all the copied files there, replacing existing ones. - (If applicable) Replace all include paths from
GameMPfiles toGameVfiles in all headers.
Designed and developed by Dreamy Cecil since 2022