Skip to content

Commit f6d361b

Browse files
Merge branch 'master' into radar-jpg-update
2 parents bfbac7d + ad1da87 commit f6d361b

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
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
}

0 commit comments

Comments
 (0)