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
7 changes: 7 additions & 0 deletions src/engine/client/cg_msgdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ enum cgameImport_t
CG_REGISTER_BUTTON_COMMANDS,
CG_NOTIFY_TEAMCHANGE,
CG_PREPAREKEYUP,
CG_DISPATCHRAWDATA,
CG_DISPATCHRAWDATASYNC,

// Sound
CG_S_STARTSOUND,
Expand Down Expand Up @@ -267,6 +269,11 @@ using NotifyTeamChangeMsg = IPC::SyncMessage<
using PrepareKeyUpMsg = IPC::SyncMessage<
IPC::Message<IPC::Id<VM::QVM, CG_PREPAREKEYUP>>
>;
using DispatchRawDataMsg = IPC::Message<IPC::Id<VM::QVM, CG_DISPATCHRAWDATA>, std::string>;
using DispatchRawDataSyncMsg = IPC::SyncMessage<
IPC::Message<IPC::Id<VM::QVM, CG_DISPATCHRAWDATASYNC>, std::string>,
IPC::Reply<std::string>
>;

// All Sounds

Expand Down
41 changes: 41 additions & 0 deletions src/engine/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Maryland 20850 USA.
#include "qcommon/crypto.h"
#include "qcommon/sys.h"

#if USE_VULKAN
#include "../renderer-vulkan/DispatchRawData.h"
#endif

#include "framework/CommonVMServices.h"
#include "framework/CommandSystem.h"
#include "framework/CvarSystem.h"
Expand Down Expand Up @@ -938,6 +942,31 @@ void CL_OnTeamChanged( int newTeam )
Cmd::BufferCommandText( "exec -f " TEAMCONFIG_NAME );
}

static void DispatchRawData( const std::string& data ) {
#if USE_VULKAN
DispatchRawData( data.data() );
#else
Q_UNUSED( data );
#endif
}

static std::string DispatchRawDataSync( const std::string& data ) {
#if USE_VULKAN
void* outMem;
int size;

DispatchRawDataSync( data.data(), &outMem, &size );

out.resize( size );
std::string out { ( const char* ) outMem, size };

return out;
#else
Q_UNUSED( data );
return "";
#endif
}

CGameVM::CGameVM(): VM::VMBase("cgame", Cvar::CHEAT), services(nullptr), cmdBuffer("client")
{
}
Expand Down Expand Up @@ -1163,6 +1192,18 @@ void CGameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& cha
});
break;

case CG_DISPATCHRAWDATA:
IPC::HandleMsg<DispatchRawDataMsg>( channel, std::move( reader ), [this] ( const std::string& data ) {
DispatchRawData( data );
} );
break;

case CG_DISPATCHRAWDATASYNC:
IPC::HandleMsg<DispatchRawDataSyncMsg>( channel, std::move( reader ), [this]( const std::string& data, std::string& out ) {
out = DispatchRawDataSync( data );
} );
break;

// All sounds

case CG_S_REGISTERSOUND:
Expand Down
42 changes: 42 additions & 0 deletions src/engine/renderer-vulkan/DispatchRawData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
===========================================================================
Daemon BSD Source Code
Copyright (c) 2026 Daemon Developers
All rights reserved.
This file is part of the Daemon BSD Source Code (Daemon Source Code).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Daemon developers nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===========================================================================
*/
// DispatchRawData.h

#ifndef DISPATCH_RAW_DATA_H
#define DISPATCH_RAW_DATA_H

void DispatchRawData( void* memory );
void DispatchRawDataSync( void* memory, void** out, int& outSize );

#endif // DISPATCH_RAW_DATA_H
1 change: 1 addition & 0 deletions src/engine/renderer-vulkan/src.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
set(RENDERERLIST
DispatchRawData.h
)
8 changes: 8 additions & 0 deletions src/engine/server/sg_msgdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ enum gameImport_t
BOT_FREE_CLIENT,
BOT_GET_CONSOLE_MESSAGE,
BOT_DEBUG_DRAW,

DISPATCH_RAWDATA,
DISPATCH_RAWDATASYNC
};

using LocateGameDataMsg1 = IPC::Message<IPC::Id<VM::QVM, G_LOCATE_GAME_DATA1>, IPC::SharedMemory, int, int, int>;
Expand Down Expand Up @@ -114,6 +117,11 @@ using BotGetConsoleMessageMsg = IPC::SyncMessage<
>;
// HACK: sgame message that only works when running in a client
using BotDebugDrawMsg = IPC::Message<IPC::Id<VM::QVM, BOT_DEBUG_DRAW>, std::vector<char>>;
using DispatchRawDataMsg = IPC::Message<IPC::Id<VM::QVM, DISPATCH_RAWDATA>, std::string>;
using DispatchRawDataSyncMsg = IPC::SyncMessage<
IPC::Message<IPC::Id<VM::QVM, DISPATCH_RAWDATASYNC>, std::string>,
IPC::Reply<std::string>
>;



Expand Down
41 changes: 41 additions & 0 deletions src/engine/server/sv_sgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Maryland 20850 USA.
#include "client/client.h" // For bot debug draw
#endif

#if USE_VULKAN
#include "../renderer-vulkan/DispatchRawData.h"
#endif

// Suppress warnings for unused [this] lambda captures.
#ifdef __clang__
#pragma clang diagnostic ignored "-Wunused-lambda-capture"
Expand Down Expand Up @@ -323,6 +327,31 @@ void SV_InitGameProgs()
SV_InitGameVM();
}

static void DispatchRawData( const std::string& data ) {
#if USE_VULKAN
DispatchRawData( data.data() );
#else
Q_UNUSED( data );
#endif
}

static std::string DispatchRawDataSync( const std::string& data ) {
#if USE_VULKAN
void* outMem;
int size;

DispatchRawDataSync( data.data(), &outMem, &size );

out.resize( size );
std::string out { ( const char* ) outMem, size };

return out;
#else
Q_UNUSED( data );
return "";
#endif
}

GameVM::GameVM(): VM::VMBase("sgame", Cvar::NONE), services(nullptr) {
}

Expand Down Expand Up @@ -594,6 +623,18 @@ void GameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& chan
});
break;

case DISPATCH_RAWDATA:
IPC::HandleMsg<DispatchRawDataMsg>( channel, std::move( reader ), [this] ( const std::string& data ) {
DispatchRawData( data );
} );
break;

case DISPATCH_RAWDATASYNC:
IPC::HandleMsg<DispatchRawDataSyncMsg>( channel, std::move( reader ), [this]( const std::string& data, std::string& out ) {
out = DispatchRawDataSync( data );
} );
break;

default:
Sys::Drop("Bad game system trap: %d", syscallNum);
}
Expand Down
12 changes: 12 additions & 0 deletions src/shared/client/cg_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ void trap_PrepareKeyUp()
VM::SendMsg<PrepareKeyUpMsg>();
}

void trap_DispatchRawData( const std::string& data ) {
VM::SendMsg<DispatchRawDataMsg>( data );
}

std::string trap_DispatchRawDataSync( const std::string& data ) {
std::string out;

VM::SendMsg<DispatchRawDataSyncMsg>( data, out );

return out;
}

// All Sounds

void trap_S_StartSound( vec3_t origin, int entityNum, soundChannel_t, sfxHandle_t sfx )
Expand Down
2 changes: 2 additions & 0 deletions src/shared/client/cg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ int trap_LAN_ServerStatus( const char *serverAddress, char *serverSt
void trap_LAN_ResetServerStatus();
void trap_R_GetShaderNameFromHandle( const qhandle_t shader, char *out, int len );
void trap_PrepareKeyUp();
void trap_DispatchRawData( const std::string& data );
std::string trap_DispatchRawDataSync( const std::string& data );
void trap_R_SetAltShaderTokens( const char * );
void trap_S_UpdateEntityVelocity( int entityNum, const vec3_t velocity );
void trap_S_UpdateEntityPositionVelocity( int entityNum, const vec3_t position, const vec3_t velocity );
Expand Down
12 changes: 12 additions & 0 deletions src/shared/server/sg_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,15 @@ int trap_BotGetServerCommand(int clientNum, char *message, int size)
Q_strncpyz(message, message2.c_str(), size);
return res;
}

void trap_DispatchRawData( const std::string& data ) {
VM::SendMsg<DispatchRawDataMsg>( data );
}

std::string trap_DispatchRawDataSync( const std::string& data ) {
std::string out;

VM::SendMsg<DispatchRawDataSyncMsg>( data, out );

return out;
}
2 changes: 2 additions & 0 deletions src/shared/server/sg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ int trap_BotAllocateClient();
void trap_BotFreeClient( int clientNum );
void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
int trap_BotGetServerCommand( int clientNum, char *message, int size );
void trap_DispatchRawData( const std::string& data );
std::string trap_DispatchRawDataSync( const std::string& data );
int trap_RSA_GenerateMessage( const char *public_key, char *cleartext, char *encrypted );
void trap_GenFingerprint( const char *pubkey, int size, char *buffer, int bufsize );
void trap_GetPlayerPubkey( int clientNum, char *pubkey, int size );
Expand Down
Loading