-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientManager.hpp
1206 lines (960 loc) · 52.3 KB
/
ClientManager.hpp
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
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright © 2003-2010, by YaPB Development Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// ClientManager.hpp
//
// Class: ClientManager
//
// Version: $ID:$
//
#if defined COMPILER_VISUALC && COMPILER_VISUALC > 1000
# pragma once
#endif // if defined COMPILER_VISUALC && COMPILER_VISUALC > 1000
#ifndef CLIENT_MANAGER_INCLUDED
#define CLIENT_MANAGER_INCLUDED
class ClientManager
{
// It's my best friends! :{P
friend FakeClientNotYaPBManager;
friend HumanManager;
friend YaPBManager;
//
// Group: Type definitions.
//
public:
typedef DynamicArray <Client *, unsigned char> ClientsArray_t;
//
// Group: Private members.
//
private:
Client **const m_clients; // For quickly getting the client pointer, by it's entity index. (Example: client->GetIndex () - 1u)
ClientsArray_t m_clientsArray; // For quickly clients looping/counting.
// Real-time clients number statistics....
ClientsArray_t m_teamClients[TeamArrayID_Total]; // For quickly team clients looping/counting.
ClientsArray_t m_teamAliveClients[TeamArrayID_Total]; // For quickly team alive clients looping/counting. (@note this can be only modified on player change team, spawn being alive or killed)
#if 0
class AdminsManager
{
class Admin
{
private:
};
public:
typedef DynamicArray <Admin *, unsigned char> AdminsArray_t;
private:
AdminsArray_t m_admins;
public:
inline ~AdminsManager (void) { m_admins.DeleteAll (); }
};
#endif // if 0
#include <ClientCommandHooker.hpp>
ClientCommandHooker m_clientCommandHooker;
#include <ClientPutInServerHooker.hpp>
ClientPutInServerHooker m_clientPutInServerHooker;
#include <SV_CalcPingIfFakeClientInjector.hpp>
SV_CalcPingIfFakeClientInjector m_SV_CalcPingIfFakeClientInjector;
#include <FakeClientCommand.hpp>
FakeClientCommand m_fakeClientCommand;
//
// Group: (Con/De)structors.
//
public:
inline ClientManager (void) : m_clients (new Client *[HalfLifeEngine::Globals::g_halfLifeEngine->GetMaximumClients ()])
{
// This function builds all client slots. (Used on server activation)
#if defined _DEBUG
// Reliability check.
if (m_clients == NULL)
TerminateOnMalloc ();
#endif // if defined _DEBUG
// Initialize the clients array....
for (unsigned char index (0u); index < HalfLifeEngine::Globals::g_halfLifeEngine->GetMaximumClients (); ++index)
m_clients[index] = NULL; // Null out the client pointer.
}
inline ~ClientManager (void)
{
// This function frees all client slots. (Used on server shutdown)
// Free all the memory allocated for all clients (including bots)....
for (unsigned char index (0u); index < HalfLifeEngine::Globals::g_halfLifeEngine->GetMaximumClients (); ++index)
delete m_clients[index]; // Delete him/her/it from the list.
/*/
// Free all the memory allocated for all clients (including bots)....
for (unsigned char index (0u); index < HalfLifeEngine::Globals::g_halfLifeEngine->GetMaximumClients (); ++index)
{
/* if (m_clients[index]->IsYaPB ())
g_connectedYaPBs += ConnectedYaPB_t (m_clients[index]->GetYaPBPointer (), &m_clients[index]->GetEngineClient ());
else
*//* if (!m_clients[index]->IsYaPB ())
delete m_clients[index]; // Delete him/her/it from the list.
}
//*/
delete [] m_clients;
}
//
// Group: Private operators.
//
private:
inline ClientManager &operator = (const ClientManager &/*right*/); // Avoid "warning C4512: 'ClientManager' : assignment operator could not be generated".
//
// Group: Functions.
//
public:
inline void RegisterGameDLLAPIForwards (void) { GetClientCommandHooker ().CreateAndDoPatch (); }
inline void UnregisterGameDLLAPIForwards (void) { GetClientCommandHooker ().UndoAndDestroyPatch (); }
inline ClientCommandHooker &GetClientCommandHooker (void) { return m_clientCommandHooker; }
inline ClientPutInServerHooker &GetClientPutInServerHooker (void) { return m_clientPutInServerHooker; }
inline FakeClientCommand &GetFakeClientCommand (void) { return m_fakeClientCommand; }
inline const FakeClientCommand &GetFakeClientCommand (void) const { return m_fakeClientCommand; }
inline Client *const &GetClient (const unsigned char index)
{
// this function finds a client specified by index, and then returns pointer to it (using own 'Client' class).
// Reliability check. (Check bot slot index)
InternalAssert (index < HalfLifeEngine::Globals::g_halfLifeEngine->GetMaximumClients ());
// If no edict, return NULL.
return m_clients[index];
}
inline const Client *const &GetClient (const unsigned char index) const
{
// this function finds a client specified by index, and then returns pointer to it (using own 'Client' class).
// Reliability check. (Check bot slot index)
InternalAssert (index < HalfLifeEngine::Globals::g_halfLifeEngine->GetMaximumClients ());
// If no edict, return NULL.
return m_clients[index];
}
inline Client *const &GetClient (const HalfLifeEngine::SDK::Classes::Edict *const client)
{
// this function finds a client specified by edict, and then returns pointer to it (using own 'Client' class).
// Reliability checks.
InternalAssert (client->IsValid ());
InternalAssert (client->IsNotWorldspawnPlayer ());
// If no edict, return NULL.
return m_clients[client->GetIndex () - 1u];
}
inline const Client *const &GetClient (const HalfLifeEngine::SDK::Classes::Edict *const client) const
{
// this function finds a client specified by edict, and then returns pointer to it (using own 'Client' class).
// Reliability checks.
InternalAssert (client->IsValid ());
InternalAssert (client->IsNotWorldspawnPlayer ());
// If no edict, return NULL.
return m_clients[client->GetIndex () - 1u];
}
inline Client **const GetClients (void) { return m_clients; }
inline const Client *const *const GetClients (void) const { return m_clients; }
inline ClientsArray_t &GetClientsArray (void)
{
// This function returns a reference to non-constant clients array.
return m_clientsArray;
}
inline const ClientsArray_t &GetClientsArray (void) const
{
// This function returns a reference to constant clients array.
return m_clientsArray;
}
inline ClientsArray_t &GetTeamClientsArray (const TeamArrayID_t teamArrayID)
{
// This function returns a reference to non-constant team clients array.
return m_teamClients[teamArrayID];
}
inline const ClientsArray_t &GetTeamClientsArray (const TeamArrayID_t teamArrayID) const
{
// This function returns a reference to constant team clients array.
return m_teamClients[teamArrayID];
}
inline ClientsArray_t &GetTeamAliveClientsArray (const TeamArrayID_t teamArrayID)
{
// This function returns a reference to non-constant team alive clients array.
return m_teamAliveClients[teamArrayID];
}
inline const ClientsArray_t &GetTeamAliveClientsArray (const TeamArrayID_t teamArrayID) const
{
// This function returns a reference to constant team alive clients array.
return m_teamAliveClients[teamArrayID];
}
inline const unsigned char GetAliveClientsNumber (const TeamArrayID_t realTeamArrayIndex) const { return m_teamAliveClients[realTeamArrayIndex].GetElementNumber (); }
inline const unsigned char GetAliveClientsNumber (const HalfLifeEngine::SDK::Constants::TeamID_t realTeam) const { return GetAliveClientsNumber (static_cast <TeamArrayID_t> (realTeam - 1u)); }
// inline const unsigned char GetAliveFakeClientsNumber (const HalfLifeEngine::SDK::Constants::TeamID_t realTeam) const { return m_teamAliveFakeClients[realTeam - 1u].GetElementNumber (); }
// inline const unsigned char GetAliveHumansNumber (const HalfLifeEngine::SDK::Constants::TeamID_t realTeam) const { return m_teamAliveHumans[realTeam - 1u].GetElementNumber (); }
inline const bool IsPointVisibleToTeam (const Math::Vector3D &position, const HalfLifeEngine::SDK::Constants::TeamID_t teamID) const
{
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (teamID));
return IsPointVisibleToTeam (position, static_cast <TeamArrayID_t> (teamID - 1u));
}
inline const bool IsPointVisibleToTeam (const Math::Vector3D &position, const TeamArrayID_t teamArrayID) const
{
HalfLifeEngine::SDK::Structures::TraceResult_t traceResult;
for (unsigned char index (0u); index < m_teamAliveClients[teamArrayID].GetElementNumber (); ++index)
{
Client *const client (m_teamAliveClients[teamArrayID][index]);
HalfLifeEngine::Globals::g_halfLifeEngine->TraceLine (client->GetEyePosition (), position, HalfLifeEngine::SDK::Constants::TraceIgnore_All, *client, traceResult);
if (traceResult.fraction == 1.0f)
return true;
}
return false;
}
inline Client *const GetClosestClientToPosition (const Math::Vector3D &position, const HalfLifeEngine::SDK::Constants::TeamID_t teamID, float minimumDistance = HalfLifeEngine::SDK::Constants::MapSize) const
{
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (teamID));
return GetClosestClientToPosition (position, static_cast <TeamArrayID_t> (teamID - 1u), minimumDistance);
}
inline Client *const GetClosestClientToPosition (const Math::Vector3D &position, const TeamArrayID_t teamArrayID, float minimumDistance = HalfLifeEngine::SDK::Constants::MapSize) const
{
Client *closestClient (NULL);
minimumDistance *= minimumDistance; // Square up the minimum distance.
for (unsigned char index (0u); index < m_teamAliveClients[teamArrayID].GetElementNumber (); ++index)
{
Client *const client (m_teamAliveClients[teamArrayID][index]);
const float distanceSquared (position.GetDistanceSquared (client->GetOrigin ()));
if (minimumDistance > distanceSquared)
{
minimumDistance = distanceSquared;
closestClient = client;
}
}
return closestClient;
}
inline const unsigned char GetDeadClientsNumber (void) const
{
// This function also counts spectator players!
unsigned char deadClientsCount (0u);
// Enumerate all the dead clients/bots in the server....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (!m_clientsArray[index]->IsAlive ())
++deadClientsCount; // This is a dead client/bot.
// Return the number of dead clients/bots.
return deadClientsCount;
}
inline Client *const GetAliveHighestFragsClient (void) const
{
Client *aliveHighestFragsClient (NULL);
float bestScore (-1.0f);
// Search clients in both teams.
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
Client *const client (m_clientsArray[index]);
if (!client->IsAlive () || client->GetEdict ()->variables.frags <= bestScore)
continue; // Filter players with given parameters....
aliveHighestFragsClient = client; // Keep track of the highest frags client.
bestScore = client->GetEdict ()->variables.frags; // Update best score.
}
return aliveHighestFragsClient;
}
inline Client *const GetAliveHighestFragsClient (const HalfLifeEngine::SDK::Constants::TeamID_t team) const
{
Client *aliveHighestFragsClient (NULL);
float bestScore (-1.0f);
// Search clients in this team.
/* for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
Client *const client (m_clientsArray[index]);
if (client->GetRealTeam () != team || !client->IsAlive () || client->GetEdict ()->variables.frags <= bestScore)
continue; // Filter players with given parameters....
aliveHighestFragsClient = client; // Keep track of the highest frags client.
bestScore = client->GetEdict ()->variables.frags; // Update best score.
}*/
for (unsigned char index (0u); index < m_teamAliveClients[team - 1u].GetElementNumber (); ++index)
{
Client *const client (m_teamAliveClients[team - 1u][index]);
if (client->GetEdict ()->variables.frags <= bestScore)
continue; // Filter players with given parameters....
aliveHighestFragsClient = client; // Keep track of the highest frags client.
bestScore = client->GetEdict ()->variables.frags; // Update best score.
}
return aliveHighestFragsClient;
}
inline Client *const GetHighestFragsClient (void) const
{
Client *highestFragsClient (NULL);
float bestScore (-1.0f);
// Search clients in both teams.
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
Client *const client (m_clientsArray[index]);
if (client->GetEdict ()->variables.frags <= bestScore)
continue; // Filter players with given parameters....
highestFragsClient = client; // Keep track of the highest frags client.
bestScore = client->GetEdict ()->variables.frags; // Update best score.
}
return highestFragsClient;
}
inline Client *const GetHighestFragsClient (const HalfLifeEngine::SDK::Constants::TeamID_t team) const
{
Client *highestFragsClient (NULL);
float bestScore (-1.0f);
// Search clients in this team.
/* for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
Client *const client (m_clientsArray[index]);
if (client->GetRealTeam () != team || client->GetEdict ()->variables.frags <= bestScore)
continue; // Filter players with given parameters....
highestFragsClient = client; // Keep track of the highest frags client.
bestScore = client->GetEdict ()->variables.frags; // Update best score.
}*/
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (team));
for (unsigned char index (0u); index < m_teamClients[team - 1u].GetElementNumber (); ++index)
{
Client *const client (m_teamClients[team - 1u][index]);
if (client->GetEdict ()->variables.frags <= bestScore)
continue; // Filter players with given parameters....
highestFragsClient = client; // Keep track of the highest frags client.
bestScore = client->GetEdict ()->variables.frags; // Update best score.
}
return highestFragsClient;
}
inline const Client *const GetC4Defuser (void) const
{
// This function returns client pointer of defuser entity if finds somebody currently defusing the bomb, NULL otherwise.
const HalfLifeEngine::SDK::Classes::BasePlayer *const C4Defuser (g_server->GetZBotManager ()->m_bombDefuser);
return C4Defuser == NULL ? NULL : GetClient (C4Defuser->GetEdict ());
#if 0
// Reliability check.
if (!g_server->GetC4Manager ().IsÑ4Planted ())
return NULL;
/*
// Loop through all client/bot slots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (m_clientsArray[index]->IsDefusing ())
return m_clientsArray[index];
*/
for (unsigned char index (0u); index < m_teamAliveClients[TeamArrayID_CounterTerrorist].GetElementNumber (); ++index)
if (m_teamAliveClients[TeamArrayID_CounterTerrorist][index]->IsDefusing ())
return m_teamAliveClients[TeamArrayID_CounterTerrorist][index];
return NULL;
#endif // if 0
}
inline const bool IsNameTaken (const DynamicString &name) const
{
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (m_clientsArray[index]->GetName ().CompareWithoutCaseCheck (name) == 0) // Don't care about case sensitivity in the name....
return true; // Found a match.
return false; // No match.
}
inline void SwapClientsTeams (void) const
{
// Loop through all client slots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (!m_clientsArray[index]->IsSpectator ())
m_clientsArray[index]->ChangeTeam ();
}
inline const ClientsArray_t::IndexType_t GetClientsCount (void) const
{
// This function returns number of clients/bots playing on the server.
return m_clientsArray.GetElementNumber (); // Return the number of clients/bots.
}
inline const unsigned char GetClientsCount (const HalfLifeEngine::SDK::Constants::TeamID_t teamID) const
{
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (teamID));
return GetClientsCount (static_cast <TeamArrayID_t> (teamID - 1u));
}
inline const unsigned char GetClientsCount (const TeamArrayID_t teamArrayID) const
{
// This function returns number of clients/bots playing on the given team.
// Return the number of clients/bots.
return m_teamClients[teamArrayID].GetElementNumber ();
}
inline const unsigned char GetClientsNumberNearPosition (const Math::Vector3D &origin, const float radius, const HalfLifeEngine::SDK::Constants::TeamID_t teamID) const
{
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (teamID));
return GetClientsNumberNearPosition (origin, radius, static_cast <TeamArrayID_t> (teamID - 1u));
}
inline const unsigned char GetClientsNumberNearPosition (const Math::Vector3D &origin, float radius, const TeamArrayID_t teamArrayID) const
{
unsigned char clientsNumber (0u);
radius *= radius;
// Loop through all player slots in given team....
for (unsigned char index (0u); index < m_teamAliveClients[teamArrayID].GetElementNumber (); ++index)
if (m_teamAliveClients[teamArrayID][index]->GetOrigin ().GetDistanceSquared (origin) <= radius)
++clientsNumber; // Increment clients number.
return clientsNumber;
}
inline const bool IsGroupOfClientsNearPosition (const unsigned char clientsNumber, const Math::Vector3D &origin, const float radius, const HalfLifeEngine::SDK::Constants::TeamID_t teamID) const
{
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (teamID));
return IsGroupOfClientsNearPosition (clientsNumber, origin, radius, static_cast <TeamArrayID_t> (teamID - 1u));
}
inline const bool IsGroupOfClientsNearPosition (unsigned char clientsNumber, const Math::Vector3D &origin, float radius, const TeamArrayID_t teamArrayID) const
{
radius *= radius;
// Loop through all player slots in given team....
for (unsigned char index (0u); index < m_teamAliveClients[teamArrayID].GetElementNumber (); ++index)
if (m_teamAliveClients[teamArrayID][index]->GetOrigin ().GetDistanceSquared (origin) <= radius)
if (--clientsNumber == 0u) // Decrement clients number.
return true;
return false;
}
inline const bool IsSomeClientStayNearPosition (const Math::Vector3D &origin, const float radius, const HalfLifeEngine::SDK::Constants::TeamID_t teamID) const
{
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (teamID));
return IsSomeClientStayNearPosition (origin, radius, static_cast <TeamArrayID_t> (teamID - 1u));
}
inline const bool IsSomeClientStayNearPosition (const Math::Vector3D &origin, float radius, const TeamArrayID_t teamArrayID) const
{
radius *= radius;
for (unsigned char index (0u); index < m_teamAliveClients[teamArrayID].GetElementNumber (); ++index)
if (m_teamAliveClients[teamArrayID][index]->GetOrigin ().GetDistanceSquared (origin) <= radius)
return true;
return false;
}
inline Client *const FindClient (const DynamicString &name)
{
// Loop through all bots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (m_clientsArray[index]->GetName ().CompareWithoutCaseCheck (name) == 0)
return m_clientsArray[index]; // Found.
return NULL;
}
inline const Client *const FindClient (const DynamicString &name) const
{
// Loop through all bots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (m_clientsArray[index]->GetName ().CompareWithoutCaseCheck (name) == 0)
return m_clientsArray[index]; // Found.
return NULL;
}
inline Client *const FindClient (const unsigned char userID)
{
// Loop through all bots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (HalfLifeEngine::Globals::g_halfLifeEngine->GetPlayerUserID (*m_clientsArray[index]) == userID)
return m_clientsArray[index]; // Found.
return NULL;
}
inline const Client *const FindClient (const unsigned char userID) const
{
// Loop through all bots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (HalfLifeEngine::Globals::g_halfLifeEngine->GetPlayerUserID (*m_clientsArray[index]) == userID)
return m_clientsArray[index]; // Found.
return NULL;
}
inline const bool IsMember (const Client *const client) const
{
// Loop through all client/bot slots (if it's not in the list it's not valid)....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (m_clientsArray[index] == client)
return true; // Found.
return false;
}
inline void KillAll (void) const
{
// This function kills all clients on server.
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
m_clientsArray[index]->Kill ();
HalfLifeEngine::Globals::g_halfLifeEngine->PrintFormat (HalfLifeEngine::SDK::Constants::HUDPrint_Center, g_localizer.GetLocalizedString (Localizer::LocalizedStringID_AllKilled), g_localizer.GetLocalizedString (Localizer::LocalizedStringID_Clients).GetData ());
}
inline void KillAll (const HalfLifeEngine::SDK::Constants::TeamID_t team) const
{
// This function kills all clients on server.
/*
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
if (m_clientsArray[index]->GetRealTeam () == team)
m_clientsArray[index]->Kill ();
*/
// Reliability check.
InternalAssert (!HalfLifeEngine::Utilities::IsSpectatorTeam (team));
for (unsigned char index (0u); index < m_teamClients[team - 1u].GetElementNumber (); ++index)
m_teamClients[team - 1u][index]->Kill ();
HalfLifeEngine::Globals::g_halfLifeEngine->PrintFormat (HalfLifeEngine::SDK::Constants::HUDPrint_Center, g_localizer.GetLocalizedString (Localizer::LocalizedStringID_AllKilled), g_localizer.GetLocalizedString (Localizer::LocalizedStringID_Clients).GetData ());
}
inline void KickAll (void) const
{
// This function drops all clients from server.
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
m_clientsArray[index]->Kick (); // Delete him/her/it from the list....
// Reset some console variables....
Console::Bot::variableManager.GetVariable (Console::Bot::VariableID_Quota)->SetValue <unsigned char> (0u);
Console::Bot::variableManager.GetVariable (Console::Bot::VariableID_AutoVacate)->SetValue <unsigned char> (0u);
HalfLifeEngine::Globals::g_halfLifeEngine->PrintFormat (HalfLifeEngine::SDK::Constants::HUDPrint_Center, g_localizer.GetLocalizedString (Localizer::LocalizedStringID_AllKickedFromServer), g_localizer.GetLocalizedString (Localizer::LocalizedStringID_Clients).GetData ());
}
inline const bool IsTeamFull (const HalfLifeEngine::SDK::Constants::TeamID_t teamID) const
{
return g_server->GetGameRules ()->IsTeamFull (teamID);
}
inline const bool IsTeamStacked (const HalfLifeEngine::SDK::Constants::TeamID_t currentTeamID, const HalfLifeEngine::SDK::Constants::TeamID_t newTeamID) const
{
return g_server->GetGameRules ()->IsTeamStacked (currentTeamID, newTeamID);
}
inline Client *const GetClientByString (const DynamicString &string) const
{
// Reliability check.
InternalAssert (!string.IsEmpty ());
// Search client with given user ID or name
if (string[0u] == '#')
return GetClientByUserID (string.GetValue <unsigned char> (1u));
return GetClientByPartialName (string);
}
inline Client *const GetClientByPartialNameWithCaseCheck (const DynamicString &partialName) const
{
Client *bestNominee (NULL);
// loop through all client slots
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
// remember slot of this client entity
Client *const client (m_clientsArray[index]);
const DynamicString clientName (client->GetName ());
if (clientName.Contains (partialName) && (bestNominee == NULL || bestNominee->GetName ().GetElementNumber () > clientName.GetElementNumber ()))
bestNominee = client;
}
return bestNominee;
}
inline Client *const GetClientByPartialName (const DynamicString &partialName) const
{
Client *bestNominee (NULL);
// loop through all client slots
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
// remember slot of this client entity
Client *const client (m_clientsArray[index]);
const DynamicString clientName (client->GetName ());
if (clientName.Contains (partialName, false) && (bestNominee == NULL || bestNominee->GetName ().GetElementNumber () > clientName.GetElementNumber ()))
bestNominee = client;
}
return bestNominee;
}
inline Client *const GetClientByUserID (const unsigned char userID) const
{
// loop through all client slots
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
// remember slot of this client entity
Client *const client (m_clientsArray[index]);
if (HalfLifeEngine::Globals::g_halfLifeEngine->GetPlayerUserID (*client) == userID)
return client;
}
return NULL;
}
inline Client *const GetClientByAuthID (const DynamicString &authID) const
{
// loop through all client slots
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
{
// remember slot of this client entity
Client *const client (m_clientsArray[index]);
if (HalfLifeEngine::Globals::g_halfLifeEngine->GetPlayerAuthID (*client) == authID)
return client;
}
return NULL;
}
inline void SetTeam (const HalfLifeEngine::SDK::Constants::TeamID_t newTeam)
{
// loop through all client slots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
m_clientsArray[index]->SetTeam (newTeam);
}
//
// Group: Game message handler callbacks.
//
public:
inline void RoundStarted (void) const
{
// This function is called at the start of each round.
// Loop through all client slots....
for (ClientsArray_t::IndexType_t index (0u); index < m_clientsArray.GetElementNumber (); ++index)
m_clientsArray[index]->RoundStarted ();
}
void ClientTeamSwitchedToTerrorists (const unsigned char clientEdictIndex);
void ClientTeamSwitchedToCounterTerrorists (const unsigned char clientEdictIndex);
void ClientTeamSwitchedToSpectators (const unsigned char clientEdictIndex, const bool isNewTeamUnassigned);
//
// Group: Engine callbacks.
//
public:
void ClientSpawnPost (const HalfLifeEngine::SDK::Classes::Edict *const client);
void ClientRoundRespawnPost (const HalfLifeEngine::SDK::Classes::Edict *const client);
void ClientUse (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const entity, const HalfLifeEngine::SDK::Classes::Edict *const caller, const HalfLifeEngine::SDK::Constants::UseType_t type, const float value) const;
inline void ClientTouchPost (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const entity)
{
GetClient (client)->TouchPost (entity);
}
inline void ClientItemDeployPost (const HalfLifeEngine::SDK::Classes::Edict *const client, HalfLifeEngine::SDK::Classes::Edict *const weapon) const
{
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ()); // OCCURS!
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability check.
if (m_clients[clientIndex]->IsValid ()) // OCCURS ON changing level.
m_clients[clientIndex]->ItemDeployPost (weapon);
}
inline void ClientWeaponReloadPost (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const weapon) const
{
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ());
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability check.
InternalAssert (m_clients[clientIndex]->IsValid ());
m_clients[clientIndex]->WeaponReloadPost (weapon);
}
inline void ClientKilled (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const killer); // Note: This function declared in YaPBManager.hpp
inline void ClientAddWeapon (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const weapon) const
{
// This function called after client/bot weapon add.
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ());
InternalAssert (weapon->IsValid ());
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability check.
InternalAssert (m_clients[clientIndex]->IsValid ());
m_clients[clientIndex]->AddWeapon (weapon);
}
inline void ClientRemoveWeapon (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const weapon) const
{
// This function called after client/bot weapon remove.
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ());
InternalAssert (weapon->IsValid ());
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability checks.
if (m_clients[clientIndex] == NULL) // OCCURS!!!
return;
InternalAssert (m_clients[clientIndex]->IsValid ());
m_clients[clientIndex]->RemoveWeapon (weapon);
}
inline void ClientOnTouchingWeapon (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Classes::Edict *const weapon)
{
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ());
InternalAssert (weapon->IsValid ());
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability check.
InternalAssert (m_clients[clientIndex]->IsValid ());
m_clients[clientIndex]->OnTouchingWeapon (weapon);
}
inline void UpdateClientData (const HalfLifeEngine::SDK::Classes::Edict *const client) const; // Note: This function declared in YaPBManager.hpp
inline void ClientImpulseCommand (const HalfLifeEngine::SDK::Classes::Edict *const client, const HalfLifeEngine::SDK::Constants::PlayerImpulseID_t impulseCommand)
{
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ());
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability check.
InternalAssert (m_clients[clientIndex]->IsValid ());
m_clients[clientIndex]->ImpulseCommand (impulseCommand);
}
void ClientDisconnect (const HalfLifeEngine::SDK::Classes::Edict *const client);
void ClientPutInServer (HalfLifeEngine::SDK::Classes::Edict *const client);
void ClientUserInfoChanged (HalfLifeEngine::SDK::Classes::Edict *const client, const DynamicString &infoBuffer);
/*
inline void ClientStudioSetupBones (const HalfLifeEngine::SDK::Classes::Edict *const client, HalfLifeEngine::SDK::Structures::Model_t *const model, const float frame, const int sequence, const Math::Angles3D &angles, const Math::Vector3D &origin, const unsigned char *const controller, const unsigned char *const blending, const int boneID)
{
// Reliability checks.
InternalAssert (client->IsValid () && client->IsNotWorldspawnPlayer ());
const unsigned char clientIndex (static_cast <const unsigned char> (client->GetIndex ()) - 1u);
// Reliability check.
InternalAssert (m_clients[clientIndex]->IsValid ());
m_clients[clientIndex]->OnStudioSetupBones (model, frame, sequence, angles, origin, controller, blending, boneID);
}
*/
void EmitSound (const HalfLifeEngine::SDK::Classes::Edict *const entity, const DynamicString &sample, const float volume, const float attenuation, const HalfLifeEngine::SDK::Constants::SoundFlag_t flags, const HalfLifeEngine::SDK::Constants::SoundPitch_t pitch) const;
void Think (void) const;
//
// Group: Other callbacks.
//
public:
inline void OnDestroyNavigationArea (NavigationMesh::NavigationArea *const area)
{
for (unsigned char teamIndex (TeamArrayID_Terrorist); teamIndex < TeamArrayID_Total; ++teamIndex)
for (ClientsArray_t::IndexType_t clientIndex (0u); clientIndex < m_teamAliveClients[teamIndex].GetElementNumber (); ++clientIndex)
if (m_teamAliveClients[teamIndex][clientIndex]->m_lastNavigationArea == area)
m_teamAliveClients[teamIndex][clientIndex]->m_lastNavigationArea = NULL;
}
inline void OnDestroyNavigationMesh (void)
{
for (unsigned char teamIndex (TeamArrayID_Terrorist); teamIndex < TeamArrayID_Total; ++teamIndex)
for (ClientsArray_t::IndexType_t clientIndex (0u); clientIndex < m_teamAliveClients[teamIndex].GetElementNumber (); ++clientIndex)
m_teamAliveClients[teamIndex][clientIndex]->m_lastNavigationArea = NULL;
}
};
inline const bool Client::IsHasMostFrags (void) const
{
return g_server->IsTeamplay () ? g_server->GetClientManager ()->GetHighestFragsClient (GetRealTeam ()) == this : g_server->GetClientManager ()->GetHighestFragsClient () == this;
}
inline const Client *const Client::GetObserverTarget (void) const { return g_server->GetClientManager ()->GetClient (GetObserverTargetEdictIndex () - 1u); }
inline void FakeClient::ExecuteCommand (const DynamicString &command) const { g_server->GetClientManager ()->GetFakeClientCommand ().Execute (m_edict, command); }
inline Server::ThrownGrenadesManager::ThrownGrenade_t::ThrownGrenade_t (const HalfLifeEngine::SDK::Classes::Edict *const inputGrenade, const Type_t inputType) :
grenade (inputGrenade),
type (inputType),
pseudoEntityVariables (HalfLifeEngine::Utilities::TraceThrownGrenadeToss (inputGrenade)),
owner (/*!inputGrenade->variables.owner->IsValid () || !inputGrenade->variables.owner->IsNotWorldspawnPlayer () ? NULL : */g_server->GetClientManager ()->GetClient (inputGrenade->variables.owner))
{ /* VOID */ }
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_AmmoPickup (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ForClient_AmmoPickup (g_server->GetClientManager ()->GetClient (to)));
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing client \"%s\" game message 'AmmoPickup' (id == %u)!", sizeof (GameMessageHandler_ForClient_AmmoPickup), to->GetNetName ().GetData (), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_AmmoPickup));
#endif // if defined _DEBUG
return newCurrentGameMessage;
}
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_AmmoX (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
Client *const client (g_server->GetClientManager ()->GetClient (to));
// Reliability check.
if (client == NULL) // OCCURS ON CientDisconnect().
return NULL;
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ForClient_AmmoX (client));
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing client \"%s\" game message 'AmmoX' (id == %u)!", sizeof (GameMessageHandler_ForClient_AmmoX), to->GetNetName ().GetData (), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_AmmoX));
#endif // if defined _DEBUG
return newCurrentGameMessage;
}
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_CurrentWeapon (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
Client *const client (g_server->GetClientManager ()->GetClient (to));
// Reliability check.
if (client == NULL) // OCCURS ON CientDisconnect().
return NULL;
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ForClient_CurrentWeapon (client));
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing client \"%s\" game message 'CurrentWeapon' (id == %u)!", sizeof (GameMessageHandler_ForClient_CurrentWeapon), to->GetNetName ().GetData (), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_CurrentWeapon));
#endif // if defined _DEBUG
return newCurrentGameMessage;
}
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_Damage (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
Client *const client (g_server->GetClientManager ()->GetClient (to));
// Reliability check.
InternalAssert (client->IsValid ()); // OCCURS ON CientDisconnect().
// Reliability check.
if (!client->IsYaPB ())
return NULL;
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ForYaPB_Damage (client->GetYaPBPointer ()));
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing YaPB \"%s\" game message 'Damage' (id == %u)!", sizeof (GameMessageHandler_ForYaPB_Damage), to->GetNetName ().GetData (), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_Damage));
#endif // if defined _DEBUG
return newCurrentGameMessage;
}
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_ScreenShake (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
Client *const client (g_server->GetClientManager ()->GetClient (to));
// Reliability check.
InternalAssert (client->IsValid ());
// Reliability check.
if (!client->IsYaPB ())
return NULL;
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ForYaPB_ScreenShake (client->GetYaPBPointer ()));
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing YaPB \"%s\" game message 'ScreenShake' (id == %u)!", sizeof (GameMessageHandler_ForYaPB_ScreenShake), to->GetNetName ().GetData (), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_ScreenShake));
#endif // if defined _DEBUG
return newCurrentGameMessage;
}
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_ScreenFade (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
if (Console::Bot::variableManager.GetVariable (Console::Bot::VariableID_AimMethod)->GetValue <Console::Bot::VariableValue_AimMethod_t> () == Console::Bot::VariableValue_AimMethod_1)
return NULL;
Client *const client (g_server->GetClientManager ()->GetClient (to));
// Reliability check.
InternalAssert (client->IsValid ());
// Reliability check.
if (!client->IsYaPB ())
return NULL;
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ForYaPB_ScreenFade (client->GetYaPBPointer ()));
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing YaPB \"%s\" game message 'ScreenFade' (id == %u)!", sizeof (GameMessageHandler_ForYaPB_ScreenFade), to->GetNetName ().GetData (), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_ScreenFade));
#endif // if defined _DEBUG
return newCurrentGameMessage;
}
inline Server::GameMessageHandlerManager::GameMessageHandler *const Server::GameMessageHandlerManager::GameMessageHandlerConstructorFunction_ShowMenu (const HalfLifeEngine::SDK::Constants::MessageDestination_t/* destination*/, const Math::Vector3D *const/* origin*/, const HalfLifeEngine::SDK::Classes::Edict *const to)
{
// Is this message for client?
if (to == NULL)
{
GameMessageHandler *const newCurrentGameMessage (new GameMessageHandler_ShowMenu ());
#if defined _DEBUG
// Reliability check.
if (newCurrentGameMessage == NULL)
AddLogEntry (true, LogLevel_Error, false, "Couldn't allocate %u bytes for processing global game message 'ShowMenu' (id == %u)!", sizeof (GameMessageHandler_ShowMenu), HalfLifeEngine::Globals::g_halfLifeEngine->GetGameMessageContainer ().GetRegisteredGameMessageIndexByType (HalfLifeEngine::Engine::GameMessageContainer::Type_ShowMenu));
#endif // if defined _DEBUG
return newCurrentGameMessage;