Skip to content

Commit

Permalink
More proto tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zer0k-z committed Nov 11, 2023
1 parent 0127372 commit ccc50ff
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
path = hl2sdk-cs2
url = https://github.com/zer0k-z/hl2sdk.git
branch = cs2
[submodule "vendor/protobuf-3.21.8"]
path = vendor/protobuf-3.21.8
url = https://github.com/protocolbuffers/protobuf
2 changes: 1 addition & 1 deletion AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ additional_libs = [
version_string_var = os.environ.get('VERSION_STRING')

if version_string_var is None or version_string_var == '':
version_string='VERSION_STRING=' + get_git_tag()
version_string='VERSION_STRING="' + get_git_tag() + '"'
print("Got version from git tag: " + version_string)
else:
version_string='VERSION_STRING="' + version_string_var + '"'
Expand Down
8 changes: 6 additions & 2 deletions AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ for sdk_name in MMSPlugin.sdks:

if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['--std=c++17']
binary.compiler.linkflags += ['-lstdc++']
binary.compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/std:c++17']

Expand All @@ -28,14 +30,15 @@ for sdk_name in MMSPlugin.sdks:
os.path.join(builder.sourcePath, 'hl2sdk-cs2'),
os.path.join(builder.sourcePath, 'hl2sdk-cs2', 'public', 'entity2'),
os.path.join(builder.sourcePath, 'hl2sdk-cs2', 'game', 'server'),
os.path.join(builder.sourcePath, 'vendor', 'subhook'),
os.path.join(builder.sourcePath, 'vendor', 'protobuf-3.21.8', 'src'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'include'),
]

if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += [
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libfunchook.a'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libdistorm.a'),
os.path.join(builder.sourcePath, 'vendor', 'protobuf-lib', 'libprotobuf.a'),
os.path.join(sdk.path, 'lib', 'linux64', 'mathlib.a'),
]
binary.sources += ['src/utils/plat_linux.cpp']
Expand All @@ -44,6 +47,7 @@ for sdk_name in MMSPlugin.sdks:
os.path.join('psapi.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'funchook.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'distorm.lib'),
os.path.join(builder.sourcePath, 'vendor', 'protobuf-lib', 'libprotobuf.lib'),
]
binary.sources += ['src/utils/plat_win.cpp']

Expand Down Expand Up @@ -79,7 +83,7 @@ for sdk_name in MMSPlugin.sdks:
os.path.join(builder.sourcePath, 'src', 'kz', 'style', 'kz_style_manager.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'style', 'kz_style_normal.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'timer', 'kz_timer.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'tip', 'kz_tip.cpp')
os.path.join(builder.sourcePath, 'src', 'kz', 'tip', 'kz_tip.cpp'),
]

if sdk_name in ['cs2']:
Expand Down
5 changes: 4 additions & 1 deletion src/cs2kz.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

#include "protobuf/generated/usermessages.pb.h"

#include "cs2kz.h"

#include "interface.h"
Expand Down Expand Up @@ -98,7 +101,7 @@ const char *KZPlugin::GetLicense()

const char *KZPlugin::GetVersion()
{
return VERSION_STRING;
return "VERSION_STRING";
}

const char *KZPlugin::GetDate()
Expand Down
21 changes: 13 additions & 8 deletions src/kz/kz_misc.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#include "protobuf/generated/usermessages.pb.h"

#include "common.h"
#include "utils/utils.h"
#include "kz.h"
#include "utils/simplecmds.h"

#include "tier0/memdbgon.h"
#include "public/networksystem/inetworkmessages.h"

#include "checkpoint/kz_checkpoint.h"
#include "jumpstats/kz_jumpstats.h"
#include "quiet/kz_quiet.h"

#include "protobuf/generated/usermessages.pb.h"
#include "tier0/memdbgon.h"
#include <utils/recipientfilters.h>

internal SCMD_CALLBACK(Command_KzNoclip)
{
KZPlayer *player = KZ::GetKZPlayerManager()->ToPlayer(controller);
Expand Down Expand Up @@ -70,12 +73,14 @@ internal SCMD_CALLBACK(Command_KzRestart)
{
KZPlayer *player = KZ::GetKZPlayerManager()->ToPlayer(controller);
CALL_VIRTUAL(void, offsets::Respawn, player->GetPawn());
//INetworkSerializable *netmsg = g_pNetworkMessages->FindNetworkMessagePartial("TextMsg");

//CUserMessageTextMsg *msg = new CUserMessageTextMsg;
//msg->set_dest(target);
//msg->add_param("Test message");
INetworkSerializable *netmsg = g_pNetworkMessages->FindNetworkMessagePartial("TextMsg");

CUserMessageTextMsg *msg = new CUserMessageTextMsg;
msg->set_dest(controller->entindex());
msg->add_param("Test message");
int slot = utils::GetEntityPlayerSlot(controller).Get();
CSingleRecipientFilter filter(slot);
interfaces::pGameEventSystem->PostEventAbstract(0, false, &filter, netmsg, msg, 0);
return MRES_SUPERCEDE;
}

Expand Down
2 changes: 2 additions & 0 deletions src/utils/interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "cgameresourceserviceserver.h"
#include "cschemasystem.h"
#include "igameevents.h"
#include "igameeventsystem.h"

namespace interfaces
{
Expand All @@ -14,4 +15,5 @@ namespace interfaces
inline IVEngineServer2 *pEngine = nullptr;
inline ISource2Server *pServer = nullptr;
inline IGameEventManager2 *pGameEventManager = nullptr;
inline IGameEventSystem *pGameEventSystem = nullptr;
}
4 changes: 3 additions & 1 deletion src/utils/recipientfilters.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class CBroadcastRecipientFilter : public IRecipientFilter

int GetRecipientCount(void) const override { return m_Recipients.Count(); }

CPlayerSlot GetRecipientIndex(int slot) const override { return CPlayerSlot(m_Recipients[slot]); }
CPlayerSlot GetRecipientIndex(int slot) const override {
return CPlayerSlot(m_Recipients[slot]);
}

private:
bool m_bReliable;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/sns.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef enum : unsigned short
k_EIPTypeV6,
} ipadrtype_t;

struct netadr_t
struct netadr_t_s2
{
union {

Expand Down Expand Up @@ -50,6 +50,6 @@ struct RecvPktInfo_t
// FIXME - coming soon!
//SteamNetworkingMicroseconds m_usecRecvMin; // Earliest possible time when the packet might have actually arrived
//SteamNetworkingMicroseconds m_usecRecvMax; // Latest possible time when the packet might have actually arrived
netadr_t m_adrFrom;
netadr_t_s2 m_adrFrom;
void *m_pSock; //IRawUDPSocket
};
3 changes: 3 additions & 0 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "strtools.h"
#include "tier0/dbg.h"
#include "interfaces/interfaces.h"
#include "igameeventsystem.h"
#include "recipientfilters.h"

#include "module.h"
Expand Down Expand Up @@ -44,6 +45,8 @@ bool interfaces::Initialize(ISmmAPI *ismm, char *error, size_t maxlen)
GET_V_IFACE_CURRENT(GetServerFactory, interfaces::pServer, ISource2Server, INTERFACEVERSION_SERVERGAMEDLL);
GET_V_IFACE_CURRENT(GetEngineFactory, interfaces::pSchemaSystem, CSchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pNetworkServerService, INetworkServerService, NETWORKSERVERSERVICE_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pNetworkMessages, INetworkMessages, NETWORKMESSAGES_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, interfaces::pGameEventSystem, IGameEventSystem, GAMEEVENTSYSTEM_INTERFACE_VERSION);
interfaces::pGameEventManager = (IGameEventManager2 *)(CALL_VIRTUAL(uintptr_t, offsets::GetEventManager, interfaces::pServer) - 8);

return true;
Expand Down
Binary file modified vendor/protobuf-lib/libprotobuf.a
Binary file not shown.

0 comments on commit ccc50ff

Please sign in to comment.