This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.cpp
751 lines (593 loc) · 19.6 KB
/
extension.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
/**
* @file extension.cpp
* @brief Implement extension code here.
*/
Outputinfo g_Outputinfo; /**< Global singleton for extension's main interface */
SMEXT_LINK(&g_Outputinfo);
#include <isaverestore.h>
#ifdef PLATFORM_WINDOWS
#include <mempool.h>
#else
#include <mempool_hack.h>
#endif
#include <variant_t.h>
#include <itoolentity.h>
IServerTools *servertools = nullptr;
#if SOURCE_ENGINE == SE_CSGO
#ifdef PLATFORM_WINDOWS
typedef int* (*AllocFunction)();
#else
typedef int* (*AllocFunction)(void*);
#endif
CUtlMemoryPool *g_pEntityListPool = nullptr;
AllocFunction g_EntityListPool_Alloc = nullptr;
#endif
#define EVENT_FIRE_ALWAYS -1
class CEventAction
{
public:
CEventAction(const char *ActionData = NULL) { m_iIDStamp = 0; };
string_t m_iTarget; // name of the entity(s) to cause the action in
string_t m_iTargetInput; // the name of the action to fire
string_t m_iParameter; // parameter to send, 0 if none
float m_flDelay; // the number of seconds to wait before firing the action
int m_nTimesToFire; // The number of times to fire this event, or EVENT_FIRE_ALWAYS.
int m_iIDStamp; // unique identifier stamp
static int s_iNextIDStamp;
CEventAction *m_pNext;
// allocates memory from engine.MPool/g_EntityListPool
#if SOURCE_ENGINE == SE_CSGO
static void *operator new(size_t stAllocateBlock)
{
#ifdef PLATFORM_WINDOWS
return g_EntityListPool_Alloc();
#else
return g_EntityListPool_Alloc( g_pEntityListPool );
#endif
}
static void *operator new(size_t stAllocateBlock, int nBlockUse, const char *pFileName, int nLine)
{
#ifdef PLATFORM_WINDOWS
return g_EntityListPool_Alloc();
#else
return g_EntityListPool_Alloc( g_pEntityListPool );
#endif
}
static void operator delete(void *pMem)
{
g_pEntityListPool->Free(pMem);
}
static void operator delete( void *pMem , int nBlockUse, const char *pFileName, int nLine )
{
operator delete(pMem);
}
#endif
DECLARE_SIMPLE_DATADESC();
};
class CBaseEntityOutput
{
public:
~CBaseEntityOutput();
void ParseEventAction( const char *EventData );
void AddEventAction( CEventAction *pEventAction );
int Save( ISave &save );
int Restore( IRestore &restore, int elementCount );
int NumberOfElements( void );
float GetMaxDelay( void );
fieldtype_t ValueFieldType() { return m_Value.FieldType(); }
void FireOutput( variant_t Value, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay = 0 );
/*
/// Delete every single action in the action list.
void DeleteAllElements( void ) ;
*/
public:
variant_t m_Value;
CEventAction *m_ActionList;
DECLARE_SIMPLE_DATADESC();
CBaseEntityOutput() {} // this class cannot be created, only it's children
private:
CBaseEntityOutput( CBaseEntityOutput& ); // protect from accidental copying
};
void CBaseEntityOutput::AddEventAction(CEventAction *pEventAction)
{
pEventAction->m_pNext = m_ActionList;
m_ActionList = pEventAction;
}
int CBaseEntityOutput::NumberOfElements(void)
{
int count = 0;
for (CEventAction *ev = m_ActionList; ev != NULL; ev = ev->m_pNext)
{
count++;
}
return count;
}
inline int GetDataMapOffset(CBaseEntity *pEnt, const char *pName)
{
datamap_t *pMap = gamehelpers->GetDataMap(pEnt);
if(!pMap)
return -1;
typedescription_t *pTypeDesc = gamehelpers->FindInDataMap(pMap, pName);
if(pTypeDesc == NULL)
return -1;
#if SOURCE_ENGINE >= SE_LEFT4DEAD
return pTypeDesc->fieldOffset;
#else
return pTypeDesc->fieldOffset[TD_OFFSET_NORMAL];
#endif
}
string_t AllocPooledString(const char *pszValue)
{
// This is admittedly a giant hack, but it's a relatively safe method for
// inserting a string into the game's string pool that isn't likely to break.
//
// We find the first valid ent (should always be worldspawn), save off it's
// current targetname string_t, set it to our string to insert via SetKeyValue,
// read back the new targetname value, restore the old value, and return the new one.
CBaseEntity *pEntity = reinterpret_cast<IServerUnknown *>(servertools->FirstEntity())->GetBaseEntity();
auto *pDataMap = gamehelpers->GetDataMap(pEntity);
assert(pDataMap);
static int offset = -1;
if (offset == -1)
{
sm_datatable_info_t info;
bool found = gamehelpers->FindDataMapInfo(pDataMap, "m_iName", &info);
assert(found);
offset = info.actual_offset;
}
string_t *pProp = (string_t *) ((intp) pEntity + offset);
string_t backup = *pProp;
servertools->SetKeyValue(pEntity, "targetname", pszValue);
string_t newString = *pProp;
*pProp = backup;
return newString;
}
inline CBaseEntityOutput *GetOutput(CBaseEntity *pEntity, const char *pOutput)
{
int offset = GetDataMapOffset(pEntity, pOutput);
if(offset == -1)
return nullptr;
return (CBaseEntityOutput *)((intptr_t)pEntity + offset);
}
cell_t GetOutputActionCount(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if(pEntityOutput == NULL)
return 0;
return pEntityOutput->NumberOfElements();
}
cell_t GetOutputActionTarget(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if(pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
pContext->StringToLocal(params[4], params[5], pAction->m_iTarget.ToCStr());
return 1;
}
cell_t SetOutputActionTarget(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if(pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
char *szTarget;
pContext->LocalToString(params[4], &szTarget);
pAction->m_iTarget = AllocPooledString(szTarget);
return 1;
}
cell_t GetOutputActionTargetInput(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
pContext->StringToLocal(params[4], params[5], pAction->m_iTargetInput.ToCStr());
return 1;
}
cell_t SetOutputActionTargetInput(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
char *szTargetInput;
pContext->LocalToString(params[4], &szTargetInput);
pAction->m_iTargetInput = AllocPooledString(szTargetInput);
return 1;
}
cell_t GetOutputActionParameter(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
pContext->StringToLocal(params[4], params[5], pAction->m_iParameter.ToCStr());
return 1;
}
cell_t SetOutputActionParameter(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
char *szParameter;
pContext->LocalToString(params[4], &szParameter);
pAction->m_iParameter = AllocPooledString(szParameter);
return 1;
}
cell_t GetOutputActionDelay(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return -1.0f;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return -1.0f;
pAction = pAction->m_pNext;
}
return sp_ftoc(pAction->m_flDelay);
}
cell_t SetOutputActionDelay(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
pAction->m_flDelay = sp_ctof(params[4]);
return 1;
}
cell_t GetOutputActionTimesToFire(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pAction = pAction->m_pNext;
}
return pAction->m_nTimesToFire;
}
cell_t SetOutputActionTimesToFire(IPluginContext *pContext, const cell_t *params)
{
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pPrev = nullptr;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pPrev = pAction;
pAction = pAction->m_pNext;
}
if (params[4] == 0) // delete this action
{
if (pPrev != nullptr)
{
pPrev->m_pNext = pAction->m_pNext;
}
else
{
pEntityOutput->m_ActionList = pAction->m_pNext;
}
delete pAction;
}
else
{
pAction->m_nTimesToFire = params[4];
}
return 1;
}
cell_t RemoveOutputAction(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE == SE_CSGO
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pPrev = nullptr;
CEventAction *pAction = pEntityOutput->m_ActionList;
for(int i = 0; i < params[3]; i++)
{
if( pAction->m_pNext == NULL)
return 0;
pPrev = pAction;
pAction = pAction->m_pNext;
}
if (pPrev != nullptr)
{
pPrev->m_pNext = pAction->m_pNext;
}
else
{
pEntityOutput->m_ActionList = pAction->m_pNext;
}
delete pAction;
return 1;
#else
return pContext->ThrowNativeError( "This feature is unsupported on this version of the engine." );
#endif
}
cell_t InsertOutputAction(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE == SE_CSGO
char *pOutput;
pContext->LocalToString(params[2], &pOutput);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
if (!pEntity)
{
return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
}
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
return 0;
CEventAction *pNewAction = new CEventAction;
char *buffer;
pContext->LocalToString(params[3], &buffer);
pNewAction->m_iTarget = AllocPooledString(buffer);
pContext->LocalToString(params[4], &buffer);
pNewAction->m_iTargetInput = AllocPooledString(buffer);
pContext->LocalToString(params[5], &buffer);
pNewAction->m_iParameter = AllocPooledString(buffer);
pNewAction->m_flDelay = sp_ctof(params[6]);
pNewAction->m_nTimesToFire = params[7];
if(params[8] == 0)
{
pEntityOutput->AddEventAction(pNewAction);
}
else
{
CEventAction *pPrev = nullptr;
CEventAction *pAction = pEntityOutput->m_ActionList;
for( int i = 0; i < params[3]; i++ )
{
if( pAction->m_pNext == NULL )
return 0;
pPrev = pAction;
pAction = pAction->m_pNext;
}
pPrev->m_pNext = pNewAction;
pNewAction->m_pNext = pAction;
}
return 1;
#else
return pContext->ThrowNativeError( "This feature is unsupported on this version of the engine." );
#endif
}
const sp_nativeinfo_t MyNatives[] =
{
{ "GetOutputActionCount", GetOutputActionCount },
{ "GetOutputActionTarget", GetOutputActionTarget },
{ "SetOutputActionTarget", SetOutputActionTarget },
{ "GetOutputActionTargetInput", GetOutputActionTargetInput },
{ "SetOutputActionTargetInput", SetOutputActionTargetInput },
{ "GetOutputActionParameter", GetOutputActionParameter },
{ "SetOutputActionParameter", SetOutputActionParameter },
{ "GetOutputActionDelay", GetOutputActionDelay },
{ "SetOutputActionDelay", SetOutputActionDelay },
{ "GetOutputActionTimesToFire", GetOutputActionTimesToFire },
{ "SetOutputActionTimesToFire", SetOutputActionTimesToFire },
{ "InsertOutputAction", InsertOutputAction },
{ "RemoveOutputAction", RemoveOutputAction },
{ NULL, NULL },
};
bool Outputinfo::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
#if SOURCE_ENGINE == SE_CSGO
IGameConfig *pGameConf;
if(!gameconfs->LoadGameConfigFile("outputinfo.games", &pGameConf, error, maxlength))
{
return false;
}
#ifdef PLATFORM_WINDOWS
pGameConf->GetAddress("g_EntityListPool", reinterpret_cast<void**>(&g_pEntityListPool));
if(g_pEntityListPool == nullptr)
{
snprintf(error, maxlength, "Failed to obtain g_pEntityListPool from gamedata");
gameconfs->CloseGameConfigFile(pGameConf);
return false;
}
#else
char *operator_new_reloffset = nullptr;
pGameConf->GetMemSig("rel_CEventAction_operator_new", reinterpret_cast<void**>(&operator_new_reloffset));
if (operator_new_reloffset == nullptr) {
snprintf( error, maxlength, "Failed to obtain rel_CEventAction_operator_new from gamedata" );
gameconfs->CloseGameConfigFile(pGameConf);
return false;
}
operator_new_reloffset += 1;
g_pEntityListPool = *(CUtlMemoryPool**)((intptr_t)(operator_new_reloffset + 4) + *(intptr_t*)operator_new_reloffset + 12);
#endif
#ifdef PLATFORM_WINDOWS
pGameConf->GetMemSig("g_EntityListPool.Alloc", reinterpret_cast<void**>(&g_EntityListPool_Alloc));
if(g_EntityListPool_Alloc == nullptr)
{
snprintf( error, maxlength, "Failed to obtain g_EntityListPool.Alloc from gamedata" );
gameconfs->CloseGameConfigFile(pGameConf);
return false;
}
#else
pGameConf->GetMemSig( "CUtlMemoryPool_Alloc", reinterpret_cast<void**>( &g_EntityListPool_Alloc ) );
if( g_EntityListPool_Alloc == nullptr )
{
snprintf( error, maxlength, "Failed to obtain CUtlMemoryPool_Alloc from gamedata" );
gameconfs->CloseGameConfigFile( pGameConf );
return false;
}
#endif
gameconfs->CloseGameConfigFile(pGameConf);
#endif
return true;
}
void Outputinfo::SDK_OnAllLoaded()
{
sharesys->AddNatives(myself, MyNatives);
}
bool Outputinfo::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
GET_V_IFACE_CURRENT(GetServerFactory, servertools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION);
return true;
}