Skip to content

Commit 44fc83a

Browse files
authored
Merge branch 'master' into TheNormalnij/edata_protect
2 parents f67acc6 + ad1da87 commit 44fc83a

File tree

10 files changed

+70
-14
lines changed

10 files changed

+70
-14
lines changed

Client/core/CNickGen.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
*****************************************************************************/
99

1010
#include "StdInc.h"
11-
#include "time.h"
11+
#include <random>
1212

1313
// These words are of a maximum length of 10 characters, capitalized, and stripped of whitespace
14-
const char* const CNickGen::m_szAdjectives[] = {
14+
const char* const szAdjectives[] = {
1515
"Aback", "Abaft", "Abandoned", "Abashed", "Aberrant", "Abhorrent", "Abiding", "Abject", "Ablaze", "Able", "Abnormal",
1616
"Aboard", "Aboriginal", "Abortive", "Abounding", "Abrasive", "Abrupt", "Absent", "Absorbed", "Absorbing", "Abstracted", "Absurd",
1717
"Abundant", "Abusive", "Acceptable", "Accessible", "Accidental", "Accurate", "Acid", "Acidic", "Acoustic", "Acrid", "Actually",
@@ -109,7 +109,7 @@ const char* const CNickGen::m_szAdjectives[] = {
109109
"Worried", "Worthless", "Wrathful", "Wretched", "Wrong", "Wry",
110110
};
111111

112-
const char* const CNickGen::m_szNouns[] = {
112+
const char* const szNouns[] = {
113113
"Aardvark", "Buffalo", "Alligator", "Ant", "Anteater", "Antelope", "Ape", "Armadillo", "Donkey", "Baboon", "Badger",
114114
"Barracuda", "Bat", "Bear", "Beaver", "Bee", "Bison", "Boar", "Bush", "Butterfly", "Camel", "Calf",
115115
"Cat", "Kitten", "Cattle", "Chamois", "Cheetah", "Chicken", "Chick", "Chimpanzee", "Infant", "Empress", "Troop",
@@ -196,10 +196,18 @@ const char* const CNickGen::m_szNouns[] = {
196196
"Vampire", "Parasite", "Tramp", "Bum", "Hobo", "Hitchhiker", "Deadbeat", "Acrobat",
197197
};
198198

199+
constexpr auto numAdjectives = std::size(szAdjectives);
200+
constexpr auto numNouns = std::size(szNouns);
201+
constexpr auto maxNum = 100;
202+
199203
SString CNickGen::GetRandomNickname()
200204
{
201-
srand((unsigned int)time(NULL));
202-
int iAdjective = rand() % NICKGEN_NUM_ADJECTIVES;
203-
int iNoun = rand() % NICKGEN_NUM_NOUNS;
204-
return SString("%s%s%i", m_szAdjectives[iAdjective], m_szNouns[iNoun], rand() % 100);
205+
std::random_device rd;
206+
std::mt19937 gen(rd());
207+
208+
std::uniform_int_distribution<int> adjectiveDist(0, numAdjectives - 1);
209+
std::uniform_int_distribution<int> nounDist(0, numNouns - 1);
210+
std::uniform_int_distribution<int> numDist(0, maxNum);
211+
212+
return SString("%s%s%i", szAdjectives[adjectiveDist(gen)], szNouns[nounDist(gen)], numDist(gen));
205213
}

Client/core/CNickGen.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99

1010
#pragma once
1111

12-
#define NICKGEN_NUM_ADJECTIVES 1048
13-
#define NICKGEN_NUM_NOUNS 934
14-
1512
class CNickGen
1613
{
1714
public:
18-
static const char* const m_szAdjectives[NICKGEN_NUM_ADJECTIVES];
19-
static const char* const m_szNouns[NICKGEN_NUM_NOUNS];
2015
static SString GetRandomNickname();
2116
};

Client/multiplayer_sa/CMultiplayerSA_Weapons.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,33 @@ void _declspec(naked) HOOK_Fx_AddBulletImpact()
200200
}
201201
}
202202

203+
//////////////////////////////////////////////////////////////////////////////////////////
204+
//
205+
// CVisibilityPlugins::RenderWeaponPedsForPC
206+
//
207+
// Fix for the bright objects after weapon change sometimes
208+
//
209+
//////////////////////////////////////////////////////////////////////////////////////////
210+
#define HOOKPOS_CVisibilityPlugins_RenderWeaponPedsForPC 0x733123
211+
#define HOOKSIZE_CVisibilityPlugins_RenderWeaponPedsForPC 5
212+
static constexpr DWORD CONTINUE_CVisibilityPlugins_RenderWeaponPedsForPC = 0x733128;
213+
static void _declspec(naked) HOOK_CVisibilityPlugins_RenderWeaponPedsForPC()
214+
{
215+
_asm
216+
{
217+
mov eax, 5DF4E0h
218+
call eax // call CPed::ResetGunFlashAlpha
219+
220+
mov eax, 5533B0h
221+
mov ecx, ebx
222+
223+
push 0
224+
call eax // call CPed::RemoveLighting
225+
226+
jmp CONTINUE_CVisibilityPlugins_RenderWeaponPedsForPC
227+
}
228+
}
229+
203230
//////////////////////////////////////////////////////////////////////////////////////////
204231
//
205232
// CMultiplayerSA::InitHooks_Weapons
@@ -212,4 +239,5 @@ void CMultiplayerSA::InitHooks_Weapons()
212239
EZHookInstall(CWeapon_GenerateDamageEvent);
213240
EZHookInstall(CShotInfo_Update);
214241
EZHookInstall(Fx_AddBulletImpact);
242+
EZHookInstall(CVisibilityPlugins_RenderWeaponPedsForPC);
215243
}

Server/mods/deathmatch/editor.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@
263263
*NOTE* This only protects resources which use dbConnect with mysql
264264
Values: 0 - Off, 1 - Enabled. Default - 1 -->
265265
<database_credentials_protection>1</database_credentials_protection>
266+
267+
<!-- This parameter determines if resource client files that end in PNG, DFF and TXD should be checked for errors;
268+
Values: 0 - Off, 1 - Enabled. Default - 1 -->
269+
<resource_client_file_checks>1</resource_client_file_checks>
266270

267271
<!-- Specifies the module(s) which are loaded with the server. To load several modules, add more <module>
268272
parameter(s). Optional parameter. -->

Server/mods/deathmatch/local.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@
263263
*NOTE* This only protects resources which use dbConnect with mysql
264264
Values: 0 - Off, 1 - Enabled. Default - 1 -->
265265
<database_credentials_protection>1</database_credentials_protection>
266+
267+
<!-- This parameter determines if resource files that end in PNG, DFF and TXD should be checked for errors;
268+
Values: 0 - Off, 1 - Enabled. Default - 1 -->
269+
<resource_client_file_checks>1</resource_client_file_checks>
266270

267271
<!-- Enables extra protection for element data.
268272
When this option is enabled, the server ignores element data sync packets from the client,

Server/mods/deathmatch/logic/CMainConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,7 @@ const std::vector<SIntSetting>& CMainConfig::GetIntSettingList()
14711471
{false, false, 0, 0, 1, "fakelag", &m_bFakeLagCommandEnabled, NULL},
14721472
{true, true, 50, 1000, 5000, "player_triggered_event_interval", &m_iPlayerTriggeredEventIntervalMs, &CMainConfig::OnPlayerTriggeredEventIntervalChange},
14731473
{true, true, 1, 100, 1000, "max_player_triggered_events_per_interval", &m_iMaxPlayerTriggeredEventsPerInterval, &CMainConfig::OnPlayerTriggeredEventIntervalChange},
1474+
{true, true, 0, 1, 1, "resource_client_file_checks", &m_checkResourceClientFiles, nullptr},
14741475
};
14751476

14761477
static std::vector<SIntSetting> settingsList;

Server/mods/deathmatch/logic/CMainConfig.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class CMainConfig : public CXMLConfig
126126
const std::vector<SString>& GetOwnerEmailAddressList() const { return m_OwnerEmailAddressList; }
127127
bool IsDatabaseCredentialsProtectionEnabled() const { return m_bDatabaseCredentialsProtectionEnabled != 0; }
128128
bool IsFakeLagCommandEnabled() const { return m_bFakeLagCommandEnabled != 0; }
129-
bool IsElementDataWhitelisted() const { return m_elementDataWhitelisted; };
129+
bool IsElementDataWhitelisted() const { return m_elementDataWhitelisted; }
130+
bool IsCheckResourceClientFilesEnabled() const noexcept { return m_checkResourceClientFiles != 0; }
130131

131132
SString GetSetting(const SString& configSetting);
132133
bool GetSetting(const SString& configSetting, SString& strValue);
@@ -229,4 +230,5 @@ class CMainConfig : public CXMLConfig
229230
int m_iPlayerTriggeredEventIntervalMs;
230231
int m_iMaxPlayerTriggeredEventsPerInterval;
231232
bool m_elementDataWhitelisted;
233+
int m_checkResourceClientFiles;
232234
};

Server/mods/deathmatch/logic/CResourceChecker.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "CResourceChecker.h"
1414
#include "CResourceChecker.Data.h"
1515
#include "CResource.h"
16+
#include "CMainConfig.h"
17+
#include "CGame.h"
1618
#include "CLogger.h"
1719
#include "CStaticFunctionDefinitions.h"
1820
#include <core/CServerInterface.h>
@@ -28,6 +30,7 @@
2830

2931
extern CNetServer* g_pRealNetServer;
3032
extern CServerInterface* g_pServerInterface;
33+
extern CGame* g_pGame;
3134

3235
///////////////////////////////////////////////////////////////
3336
//
@@ -48,6 +51,9 @@ void CResourceChecker::CheckResourceForIssues(CResource* pResource, const string
4851
m_ulDeprecatedWarningCount = 0;
4952
m_upgradedFullPathList.clear();
5053

54+
// Checking certain resource client files is optional
55+
bool checkResourceClientFiles = g_pGame->GetConfig()->IsCheckResourceClientFilesEnabled();
56+
5157
// Check each file in the resource
5258
std::list<CResourceFile*>::iterator iterf = pResource->IterBegin();
5359
for (; iterf != pResource->IterEnd(); iterf++)
@@ -73,7 +79,7 @@ void CResourceChecker::CheckResourceForIssues(CResource* pResource, const string
7379
bScript = true;
7480
bClient = true;
7581
}
76-
else if (type == CResourceFile::RESOURCE_FILE_TYPE_CLIENT_FILE)
82+
else if (type == CResourceFile::RESOURCE_FILE_TYPE_CLIENT_FILE && checkResourceClientFiles)
7783
{
7884
bScript = false;
7985
bClient = true;

Server/mods/deathmatch/mtaserver.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@
280280
Max events per interval range: 1 to 1000. Default: 100 -->
281281
<player_triggered_event_interval>1000</player_triggered_event_interval>
282282
<max_player_triggered_events_per_interval>100</max_player_triggered_events_per_interval>
283+
284+
<!-- This parameter determines if resource client files that end in PNG, DFF and TXD should be checked for errors;
285+
Values: 0 - Off, 1 - Enabled. Default - 1 -->
286+
<resource_client_file_checks>1</resource_client_file_checks>
283287

284288
<!-- Specifies the module(s) which are loaded with the server. To load several modules, add more <module>
285289
parameter(s). Optional parameter. -->

Server/mods/deathmatch/mtaserver.conf.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,8 @@
281281
Max events per interval range: 1 to 1000. Default: 100 -->
282282
<player_triggered_event_interval>1000</player_triggered_event_interval>
283283
<max_player_triggered_events_per_interval>100</max_player_triggered_events_per_interval>
284+
285+
<!-- This parameter determines if resource client files that end in PNG, DFF and TXD should be checked for errors;
286+
Values: 0 - Off, 1 - Enabled. Default - 1 -->
287+
<resource_client_file_checks>1</resource_client_file_checks>
284288
</config>

0 commit comments

Comments
 (0)