Skip to content

Commit 5c5c0ae

Browse files
author
pongo1231
committed
Ped Randomizer: Allow specifying multiple models in ForcePed
1 parent 2cf40c1 commit 5c5c0ae

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

src/peds/peds.cc

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <common/mods.hh>
1111

1212
#include <scrThread.hh>
13+
#include <Random.hh>
1314

1415
#include "CModelInfo.hh"
1516
#include "Utils.hh"
@@ -80,10 +81,11 @@ class PedRandomizer
8081
return model;
8182

8283
// Forced Ped
83-
if (!PR::Config ().ForcedPed.empty ())
84+
if (!PR::Config ().ForcedPedHashes.empty ())
8485
{
8586
uint32_t id = CStreaming::GetModelIndex (
86-
rage::atStringHash (PR::Config ().ForcedPed));
87+
PR::Config ().ForcedPedHashes [ 0, RandomInt(PR::Config()
88+
.ForcedPedHashes.size() - 1) ]);
8789

8890
if (CStreaming::HasModelLoaded (id))
8991
return id;
@@ -176,7 +178,6 @@ class PedRandomizer
176178
/*******************************************************/
177179
PedRandomizer ()
178180
{
179-
std::string ForcedPed;
180181
#define OPTION(option) std::pair (#option, &PR::Config ().option)
181182

182183
if (!ConfigManager::ReadConfig (
@@ -191,8 +192,33 @@ class PedRandomizer
191192
return;
192193

193194
if (PR::Config ().ForcedPed.size ())
194-
PR::Config ().ForcedPedHash
195-
= rage::atStringHash (PR::Config ().ForcedPed);
195+
{
196+
std::string forcedPeds = PR::Config ().ForcedPed;
197+
198+
while (true)
199+
{
200+
size_t splitPos = forcedPeds.find (',');
201+
202+
std::string forcedPed = forcedPeds.substr (0, splitPos);
203+
204+
// trimming
205+
forcedPed.erase (0, forcedPed.find_first_not_of (' '));
206+
if (forcedPed.find_last_not_of (' ') != forcedPed.npos)
207+
forcedPed.erase (forcedPed.find_last_not_of (' ') + 1);
208+
209+
// just in case it was just whitespace
210+
if (forcedPed.size ())
211+
PR::Config ().ForcedPedHashes
212+
.push_back (rage::atStringHash (forcedPed));
213+
214+
if (splitPos == forcedPeds.npos)
215+
{
216+
break;
217+
}
218+
219+
forcedPeds.erase (0, splitPos + 1);
220+
}
221+
}
196222

197223
InitialiseAllComponents ();
198224

src/peds/peds.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <string>
4+
#include <vector>
45

56
#include "peds_Compatibility.hh"
67
#include "peds_Streaming.hh"
@@ -20,7 +21,7 @@ public:
2021
{
2122
std::string ForcedPed = "";
2223
std::string ForcedClipset = "";
23-
uint32_t ForcedPedHash = -1;
24+
std::vector<uint32_t> ForcedPedHashes;
2425
bool EnableNSFWModels = false;
2526
bool RandomizePlayer = true;
2627
bool RandomizePeds = true;

0 commit comments

Comments
 (0)