Skip to content

Commit b55d267

Browse files
Leystrykudanielga
andauthored
Fix Win32 default branch build of SourceNet3 (#60)
* Fix Windows Builds * Fixed code formatting * Use symbols for SVC_CreateStringTable_Constructor and SVC_CmdKeyValues_Constructor * Removed unnecessary offsets --------- Co-authored-by: Daniel <danielga@outlook.pt>
1 parent d6b43f5 commit b55d267

File tree

1 file changed

+20
-99
lines changed

1 file changed

+20
-99
lines changed

source/netmessage.cpp

Lines changed: 20 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -53,84 +53,6 @@ namespace NetMessage
5353
{
5454
using namespace NetMessages;
5555

56-
#if defined SYSTEM_WINDOWS
57-
58-
#if defined ARCHITECTURE_X86_OLD
59-
60-
static const uintptr_t CLC_CmdKeyValues_offset = 916;
61-
62-
static const uintptr_t SVC_CreateStringTable_offset = 691;
63-
64-
static const uintptr_t SVC_CmdKeyValues_offset = 1935;
65-
66-
#elif defined ARCHITECTURE_X86
67-
68-
static const uintptr_t CLC_CmdKeyValues_offset = 950;
69-
70-
static const uintptr_t SVC_CreateStringTable_offset = 708;
71-
72-
static const uintptr_t SVC_CmdKeyValues_offset = 2100;
73-
74-
#elif defined ARCHITECTURE_X86_64
75-
76-
static const uintptr_t CLC_CmdKeyValues_offset = 1037;
77-
78-
static const uintptr_t SVC_CreateStringTable_offset = 773;
79-
80-
static const uintptr_t SVC_CmdKeyValues_offset = 2443;
81-
82-
#endif
83-
84-
#elif defined SYSTEM_LINUX
85-
86-
#if defined ARCHITECTURE_X86_OLD
87-
88-
static const uintptr_t CLC_CmdKeyValues_offset = 716;
89-
90-
static const uintptr_t SVC_CreateStringTable_offset = 571;
91-
92-
static const uintptr_t SVC_CmdKeyValues_offset = 1691;
93-
94-
#elif defined ARCHITECTURE_X86
95-
96-
static const uintptr_t CLC_CmdKeyValues_offset = 744;
97-
98-
static const uintptr_t SVC_CreateStringTable_offset = 567;
99-
100-
static const uintptr_t SVC_CmdKeyValues_offset = 1707;
101-
102-
#elif defined ARCHITECTURE_X86_64
103-
104-
static const uintptr_t CLC_CmdKeyValues_offset = 901;
105-
106-
static const uintptr_t SVC_CreateStringTable_offset = 676;
107-
108-
static const uintptr_t SVC_CmdKeyValues_offset = 1998;
109-
110-
#endif
111-
112-
#elif defined SYSTEM_MACOSX
113-
114-
#if defined ARCHITECTURE_X86
115-
116-
static const uintptr_t CLC_CmdKeyValues_offset = 1031;
117-
118-
static const uintptr_t SVC_CreateStringTable_offset = 675;
119-
120-
static const uintptr_t SVC_CmdKeyValues_offset = 2112;
121-
122-
#elif defined ARCHITECTURE_X86_64
123-
124-
static const uintptr_t CLC_CmdKeyValues_offset = 1012;
125-
126-
static const uintptr_t SVC_CreateStringTable_offset = 707;
127-
128-
static const uintptr_t SVC_CmdKeyValues_offset = 2301;
129-
130-
#endif
131-
132-
#endif
133-
13456
struct Container
13557
{
13658
INetMessage *msg;
@@ -513,31 +435,30 @@ namespace NetMessage
513435
if( CBaseClientState_ConnectionStart == nullptr )
514436
LUA->ThrowError( "failed to locate CBaseClientState::ConnectionStart" );
515437

438+
const void *CLC_CmdKeyValues_Constructor =
439+
reinterpret_cast<const void *>( FunctionPointers::CLC_CmdKeyValues_Constructor( ) );
440+
if( CLC_CmdKeyValues_Constructor == nullptr )
441+
LUA->ThrowError( "failed to locate CLC_CmdKeyValues::CLC_CmdKeyValues" );
442+
443+
const void *SVC_CmdKeyValues_Constructor =
444+
reinterpret_cast<const void *>( FunctionPointers::SVC_CmdKeyValues_Constructor( ) );
445+
if( SVC_CmdKeyValues_Constructor == nullptr )
446+
LUA->ThrowError( "failed to locate SVC_CmdKeyValues::SVC_CmdKeyValues" );
447+
448+
const void *SVC_CreateStringTable_Constructor =
449+
reinterpret_cast<const void *>( FunctionPointers::SVC_CreateStringTable_Constructor( ) );
450+
if( SVC_CreateStringTable_Constructor == nullptr )
451+
LUA->ThrowError( "failed to locate SVC_CreateStringTable::SVC_CreateStringTable" );
452+
516453
ResolveMessagesFromFunctionCode( LUA, CBaseClient_ConnectionStart );
517454

518455
ResolveMessagesFromFunctionCode( LUA, CBaseClientState_ConnectionStart );
519456

520-
uintptr_t SVC_CreateStringTable = reinterpret_cast<uintptr_t>(
521-
CBaseClientState_ConnectionStart
522-
) + SVC_CreateStringTable_offset;
523-
ResolveMessagesFromFunctionCode( LUA, reinterpret_cast<const uint8_t *>(
524-
SVC_CreateStringTable + sizeof( int32_t ) +
525-
*reinterpret_cast<int32_t *>( SVC_CreateStringTable )
526-
) );
527-
528-
uintptr_t SVC_CmdKeyValues = reinterpret_cast<uintptr_t>(
529-
CBaseClientState_ConnectionStart
530-
) + SVC_CmdKeyValues_offset;
531-
ResolveMessagesFromFunctionCode( LUA, reinterpret_cast<const uint8_t *>(
532-
SVC_CmdKeyValues + sizeof( int32_t ) + *reinterpret_cast<int32_t *>( SVC_CmdKeyValues )
533-
) );
534-
535-
uintptr_t CLC_CmdKeyValues = reinterpret_cast<uintptr_t>(
536-
CBaseClient_ConnectionStart
537-
) + CLC_CmdKeyValues_offset;
538-
ResolveMessagesFromFunctionCode( LUA, reinterpret_cast<const uint8_t *>(
539-
CLC_CmdKeyValues + sizeof( int32_t ) + *reinterpret_cast<int32_t *>( CLC_CmdKeyValues )
540-
) );
457+
ResolveMessagesFromFunctionCode( LUA, CLC_CmdKeyValues_Constructor );
458+
459+
ResolveMessagesFromFunctionCode( LUA, SVC_CmdKeyValues_Constructor );
460+
461+
ResolveMessagesFromFunctionCode( LUA, SVC_CreateStringTable_Constructor );
541462
}
542463

543464
template<class NetMessage> int Constructor( lua_State *L )

0 commit comments

Comments
 (0)