Skip to content

Commit 7c39543

Browse files
Merge remote-tracking branch 'upstream/master' into fix-crash-create-thread-now
2 parents 6c6a362 + 0d108a3 commit 7c39543

File tree

22 files changed

+259
-200
lines changed

22 files changed

+259
-200
lines changed

code/components/citizen-server-impl/include/state/ServerGameState.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ struct CVehicleGameStateNodeData
501501
bool sirenOn;
502502
int lockStatus;
503503
int doorsOpen;
504-
int doorPositions[1 << 7];
504+
int doorPositions[7];
505505
bool isStationary;
506506
bool lightsOn;
507507
bool highbeamsOn;

code/components/citizen-server-impl/include/state/SyncTrees_Five.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4530,11 +4530,11 @@ using CPedSyncTree = SyncTree<
45304530
NodeWrapper<NodeIds<87, 87, 0>, CPedSectorPosNavMeshNode, 4>
45314531
>,
45324532
ParentNode<
4533-
NodeIds<5, 0, 0>,
4533+
NodeIds<87, 0, 0>,
45344534
NodeWrapper<NodeIds<4, 0, 0>, CMigrationDataNode, 13>,
45354535
NodeWrapper<NodeIds<4, 0, 0>, CPhysicalMigrationDataNode, 1>,
45364536
NodeWrapper<NodeIds<4, 0, 1>, CPhysicalScriptMigrationDataNode, 1>,
4537-
NodeWrapper<NodeIds<5, 0, 0>, CPedInventoryDataNode, 321>,
4537+
NodeWrapper<NodeIds<87, 0, 0>, CPedInventoryDataNode, 321>, // Changed from 5 to 87 in CloneManager.cpp
45384538
NodeWrapper<NodeIds<4, 4, 1>, CPedTaskSequenceDataNode, 1>
45394539
>
45404540
>

code/components/citizen-server-impl/src/InfoHttpHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ void InfoHttpHandlerComponentLocals::AttachToObject(fx::ServerInstanceBase* inst
381381
{
382382
constexpr uint8_t pathLength = net::force_consteval<int, std::string_view("/players.json").size()>;
383383
skyr::v1::url_search_parameters searchParameters (std::string_view{path.data() + pathLength, path.size() - pathLength});
384-
if (auto token = searchParameters.get("token"); token.has_value() && server->GetPlayersToken() == token.value())
384+
if (auto token = searchParameters.get("token"); token.has_value() && !token.value().empty() && server->GetPlayersToken() == token.value())
385385
{
386386
authorizedRequest = true;
387387
}

code/components/citizen-server-impl/src/state/ServerGameState.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -3246,21 +3246,26 @@ void ServerGameState::FinalizeClone(const fx::ClientSharedPtr& client, const fx:
32463246

32473247
auto ServerGameState::CreateEntityFromTree(sync::NetObjEntityType type, const std::shared_ptr<sync::SyncTreeBase>& tree) -> fx::sync::SyncEntityPtr
32483248
{
3249-
bool hadId = false;
3250-
32513249
int id = fx::IsLengthHack() ? (MaxObjectId - 1) : 8191;
32523250

32533251
{
3252+
bool valid = false;
32543253
std::unique_lock objectIdsLock(m_objectIdsMutex);
32553254

32563255
for (; id >= 1; id--)
32573256
{
32583257
if (!m_objectIdsSent.test(id) && !m_objectIdsUsed.test(id))
32593258
{
3259+
valid = true;
32603260
break;
32613261
}
32623262
}
32633263

3264+
if (!valid)
3265+
{
3266+
return {};
3267+
}
3268+
32643269
m_objectIdsSent.set(id);
32653270
m_objectIdsUsed.set(id);
32663271
m_objectIdsStolen.set(id);

code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp

+24-5
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,13 @@ static void Init()
678678

679679
if (context.GetArgumentCount() > 1 && doorsOpen)
680680
{
681-
doorStatus = vn->doorPositions[context.GetArgument<int>(1)];
681+
const int index = context.GetArgument<int>(1);
682+
if (index < 0 || index > 6)
683+
{
684+
return doorStatus;
685+
}
686+
687+
doorStatus = vn->doorPositions[index];
682688
}
683689

684690
return doorStatus;
@@ -742,9 +748,14 @@ static void Init()
742748
bool tyreBurst = false;
743749
bool wheelsFine = vn->tyresFine;
744750

745-
if (!wheelsFine && context.GetArgumentCount() > 1)
751+
if (!wheelsFine)
746752
{
747-
int tyreID = context.GetArgument<int>(1);
753+
const int tyreID = context.GetArgument<int>(1);
754+
if (tyreID < 0 || tyreID > 15)
755+
{
756+
return tyreBurst;
757+
}
758+
748759
bool completely = context.GetArgument<bool>(2);
749760

750761
int tyreStatus = vn->tyreStatus[tyreID];
@@ -1252,7 +1263,11 @@ static void Init()
12521263
{
12531264
auto vn = entity->syncTree->GetVehicleGameState();
12541265

1255-
int seatArg = context.GetArgument<int>(1) + 2;
1266+
const int seatArg = context.GetArgument<int>(1) + 2;
1267+
if (seatArg < 0 || seatArg > 31)
1268+
{
1269+
return 0;
1270+
}
12561271

12571272
// get the current resource manager
12581273
auto resourceManager = fx::ResourceManager::GetCurrent();
@@ -1281,7 +1296,11 @@ static void Init()
12811296
{
12821297
auto vn = entity->syncTree->GetVehicleGameState();
12831298

1284-
int seatArg = context.GetArgument<int>(1) + 2;
1299+
const int seatArg = context.GetArgument<int>(1) + 2;
1300+
if (seatArg < 0 || seatArg > 31)
1301+
{
1302+
return 0;
1303+
}
12851304

12861305
// get the current resource manager
12871306
auto resourceManager = fx::ResourceManager::GetCurrent();

code/components/citizen-server-impl/src/state/ServerSetters.cpp

+32-4
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,14 @@ static InitFunction initFunction([]()
330330
auto sgs = ref->GetComponent<fx::ServerGameState>();
331331
auto entity = sgs->CreateEntityFromTree(sync::NetObjEntityType::Automobile, tree);
332332

333-
ctx.SetResult(sgs->MakeScriptHandle(entity));
333+
uint32_t guid = 0;
334+
335+
if (entity)
336+
{
337+
guid = sgs->MakeScriptHandle(entity);
338+
}
339+
340+
ctx.SetResult(guid);
334341
});
335342

336343
fx::ScriptEngine::RegisterNativeHandler("CREATE_VEHICLE_SERVER_SETTER", [ref](fx::ScriptContext& ctx)
@@ -426,7 +433,14 @@ static InitFunction initFunction([]()
426433
auto sgs = ref->GetComponent<fx::ServerGameState>();
427434
auto entity = sgs->CreateEntityFromTree(typeId, tree);
428435

429-
ctx.SetResult(sgs->MakeScriptHandle(entity));
436+
uint32_t guid = 0;
437+
438+
if (entity)
439+
{
440+
guid = sgs->MakeScriptHandle(entity);
441+
}
442+
443+
ctx.SetResult(guid);
430444
});
431445

432446
fx::ScriptEngine::RegisterNativeHandler("CREATE_PED", [=](fx::ScriptContext& ctx)
@@ -450,7 +464,14 @@ static InitFunction initFunction([]()
450464
auto sgs = ref->GetComponent<fx::ServerGameState>();
451465
auto entity = sgs->CreateEntityFromTree(sync::NetObjEntityType::Ped, tree);
452466

453-
ctx.SetResult(sgs->MakeScriptHandle(entity));
467+
uint32_t guid = 0;
468+
469+
if (entity)
470+
{
471+
guid = sgs->MakeScriptHandle(entity);
472+
}
473+
474+
ctx.SetResult(guid);
454475
});
455476

456477
fx::ScriptEngine::RegisterNativeHandler("CREATE_OBJECT_NO_OFFSET", [=](fx::ScriptContext& ctx)
@@ -474,7 +495,14 @@ static InitFunction initFunction([]()
474495
auto sgs = ref->GetComponent<fx::ServerGameState>();
475496
auto entity = sgs->CreateEntityFromTree(sync::NetObjEntityType::Object, tree);
476497

477-
ctx.SetResult(sgs->MakeScriptHandle(entity));
498+
uint32_t guid = 0;
499+
500+
if (entity)
501+
{
502+
guid = sgs->MakeScriptHandle(entity);
503+
}
504+
505+
ctx.SetResult(guid);
478506
});
479507
});
480508
});

code/components/extra-natives-five/src/PedCollectionsNatives.cpp

+69
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ static HookFunction hookFunction([]()
403403
// Call GET_PED_DRAWABLE_VARIATION to get global drawable index.
404404
fx::ScriptEngine::CallNativeHandler(0x67F3780DD425D4FC, newContext);
405405
int globalDrawableIndex = newContext.GetResult<int>();
406+
if(globalDrawableIndex < 0)
407+
{
408+
context.SetResult<int>(-1);
409+
return;
410+
}
411+
406412
context.SetResult<int>(g_GetDlcDrawableIdx(variationInfoCollection, componentId, globalDrawableIndex));
407413
});
408414
fx::ScriptEngine::RegisterNativeHandler("GET_PED_DRAWABLE_VARIATION_COLLECTION_NAME", [](fx::ScriptContext& context)
@@ -422,13 +428,76 @@ static HookFunction hookFunction([]()
422428
// Call GET_PED_DRAWABLE_VARIATION to get global drawable index.
423429
fx::ScriptEngine::CallNativeHandler(0x67F3780DD425D4FC, newContext);
424430
int globalDrawableIndex = newContext.GetResult<int>();
431+
if(globalDrawableIndex < 0)
432+
{
433+
context.SetResult<const char*>(nullptr);
434+
return;
435+
}
436+
425437
auto variationInfo = g_GetVariationInfoFromDrawableIdx(variationInfoCollection, componentId, globalDrawableIndex);
426438
if (!variationInfo)
427439
{
428440
context.SetResult<const char*>(nullptr);
429441
return;
430442
}
431443

444+
context.SetResult<const char*>(GetCollectionName(variationInfo));
445+
});
446+
fx::ScriptEngine::RegisterNativeHandler("GET_PED_PROP_COLLECTION_LOCAL_INDEX", [](fx::ScriptContext& context)
447+
{
448+
uint32_t pedId = context.GetArgument<uint32_t>(0);
449+
int anchorPoint = context.GetArgument<int>(1);
450+
auto variationInfoCollection = GetPedVariationInfoCollection(pedId);
451+
if (!variationInfoCollection)
452+
{
453+
context.SetResult<int>(-1);
454+
return;
455+
}
456+
457+
fx::ScriptContextBuffer newContext;
458+
newContext.Push(pedId);
459+
newContext.Push(anchorPoint);
460+
// Call GET_PED_PROP_INDEX to get global prop index.
461+
fx::ScriptEngine::CallNativeHandler(0x898CC20EA75BACD8, newContext);
462+
int globalPropIndex = newContext.GetResult<int>();
463+
if(globalPropIndex < 0)
464+
{
465+
context.SetResult<int>(-1);
466+
return;
467+
}
468+
469+
context.SetResult<int>(g_GetDlcPropIdx(variationInfoCollection, anchorPoint, globalPropIndex));
470+
});
471+
fx::ScriptEngine::RegisterNativeHandler("GET_PED_PROP_COLLECTION_NAME", [](fx::ScriptContext& context)
472+
{
473+
uint32_t pedId = context.GetArgument<uint32_t>(0);
474+
int anchorPoint = context.GetArgument<int>(1);
475+
auto variationInfoCollection = GetPedVariationInfoCollection(pedId);
476+
if (!variationInfoCollection)
477+
{
478+
context.SetResult<const char*>(nullptr);
479+
return;
480+
}
481+
482+
fx::ScriptContextBuffer newContext;
483+
newContext.Push(pedId);
484+
newContext.Push(anchorPoint);
485+
// Call GET_PED_PROP_INDEX to get global prop index.
486+
fx::ScriptEngine::CallNativeHandler(0x898CC20EA75BACD8, newContext);
487+
int globalPropIndex = newContext.GetResult<int>();
488+
if(globalPropIndex < 0)
489+
{
490+
context.SetResult<const char*>(nullptr);
491+
return;
492+
}
493+
494+
auto variationInfo = g_GetVariationInfoFromPropIdx(variationInfoCollection, anchorPoint, globalPropIndex);
495+
if (!variationInfo)
496+
{
497+
context.SetResult<const char*>(nullptr);
498+
return;
499+
}
500+
432501
context.SetResult<const char*>(GetCollectionName(variationInfo));
433502
});
434503
});

code/components/gta-core-five/component.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"rage:input:five",
1111
"rage:device:five",
1212
"rage:graphics:five",
13-
"vendor:minhook"
13+
"vendor:minhook",
14+
"scripting"
1415
],
1516
"provides": []
1617
}
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,54 @@
11
#include <StdInc.h>
22
#include <Hooking.h>
33
#include "CrossBuildRuntime.h"
4+
#include <ScriptEngine.h>
5+
#include "ICoreGameInit.h"
46

57
//
6-
// This patch forces a tunable (seen starting at b2545) preventing applying
7-
// of ped-to-ped attachment data to networked peds to be 'off', returning the
8-
// old behavior for compatibility.
8+
// This patches multiple checks that prevent the application of entity-to-ped
9+
// attachment data to networked peds so it can be dynamically toggled.
910
//
1011

1112
static bool ReturnFalse()
1213
{
1314
return false;
1415
}
1516

17+
static bool g_disableRemotePedAttachment = false;
18+
19+
static bool ReturnState()
20+
{
21+
return g_disableRemotePedAttachment;
22+
}
23+
1624
static HookFunction hookFunction([]()
1725
{
1826
if (xbr::IsGameBuildOrGreater<2545>())
1927
{
20-
auto location = hook::get_pattern<char>("BA E7 8F A5 1E B9 BD C5 AF E3 E8");
21-
hook::call(location + 23, ReturnFalse);
28+
const auto location = hook::get_pattern<char>("BA E7 8F A5 1E B9 BD C5 AF E3 E8");
29+
hook::call(location + 23, ReturnState);
2230

2331
// This call was removed in 2802.0
2432
if (!xbr::IsGameBuildOrGreater<2802>())
2533
{
2634
hook::call(location + 61, ReturnFalse);
2735
}
2836

29-
auto attachEntityToEntityTunable = hook::get_pattern<char>("BA 37 89 3D 8A B9 BD C5 AF E3");
37+
const auto attachEntityToEntityTunable = hook::get_pattern<char>("BA 37 89 3D 8A B9 BD C5 AF E3");
3038
hook::call(attachEntityToEntityTunable + 23, ReturnFalse);
3139
}
3240
});
41+
42+
static InitFunction initFunction([]()
43+
{
44+
fx::ScriptEngine::RegisterNativeHandler("ONESYNC_ENABLE_REMOTE_ATTACHMENT_SANITIZATION", [](fx::ScriptContext& context)
45+
{
46+
const bool enable = context.GetArgument<bool>(0);
47+
g_disableRemotePedAttachment = enable;
48+
});
49+
50+
Instance<ICoreGameInit>::Get()->OnShutdownSession.Connect([]()
51+
{
52+
g_disableRemotePedAttachment = false;
53+
});
54+
});

code/components/gta-net-five/src/CloneManager.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,13 @@ static HookFunction hookFunctionSceneUpdateWorkaround([]()
17691769
MH_CreateHook(hook::get_pattern("F7 D3 21 58 10 0F", -0x3F), fwSceneUpdate__RemoveFromSceneUpdate_Track, (void**)&fwSceneUpdate__RemoveFromSceneUpdate);
17701770
MH_EnableHook(MH_ALL_HOOKS);
17711771
});
1772+
1773+
static HookFunction hookFunctionModifySyncTrees([]()
1774+
{
1775+
// Change to "mov r8d, ebx; nop;" (44 8B C3 90). ebx value is 87
1776+
// Change inventory node flags from MIGRATE_NODE to UPDATE_CREATE_NODE.
1777+
hook::put<uint32_t>(xbr::IsGameBuildOrGreater<3407>() ? hook::get_pattern("45 8D 47 ? 49 8D 96 ? ? ? ? 45 33 C9") : hook::get_pattern("44 8D 46 ? 45 33 C9 49 8B D4"), 0x90C38B44);
1778+
});
17721779
#endif
17731780

17741781
void CloneManagerLocal::Update()

ext/cfx-ui/src/cfx/apps/mpMenu/pages/HomePage/Feed/Feed.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const Feed = observer(function Feed(props: FeedProps) {
4545
}, []);
4646

4747
return (
48-
<Island widthQ={50}>
48+
<Island widthQ={75}>
4949
<Flex fullHeight vertical gap="none">
5050
<Pad>
5151
<Flex repell>

0 commit comments

Comments
 (0)