Skip to content

Commit c92f3c1

Browse files
authored
Merge branch 'master' into _VeH_39_
2 parents bc0474b + 820c22e commit c92f3c1

File tree

16 files changed

+135
-104
lines changed

16 files changed

+135
-104
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,10 +2735,13 @@ void CClientGame::AddBuiltInEvents()
27352735
m_Events.AddEvent("onClientCursorMove", "relativeX, relativeX, absoluteX, absoluteY, worldX, worldY, worldZ", NULL, false);
27362736

27372737
// Marker events
2738-
m_Events.AddEvent("onClientMarkerHit", "entity, matchingDimension", NULL, false);
2739-
m_Events.AddEvent("onClientMarkerLeave", "entity, matchingDimension", NULL, false);
2738+
m_Events.AddEvent("onClientMarkerHit", "entity, matchingDimension", nullptr, false);
2739+
m_Events.AddEvent("onClientMarkerLeave", "entity, matchingDimension", nullptr, false);
27402740

2741-
// Marker events
2741+
m_Events.AddEvent("onClientPlayerMarkerHit", "marker, matchingDimension", nullptr, false);
2742+
m_Events.AddEvent("onClientPlayerMarkerLeave", "marker, matchingDimension", nullptr, false);
2743+
2744+
// Pickup events
27422745
m_Events.AddEvent("onClientPickupHit", "entity, matchingDimension", NULL, false);
27432746
m_Events.AddEvent("onClientPickupLeave", "entity, matchingDimension", NULL, false);
27442747

Client/mods/deathmatch/logic/CClientMarker.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -410,28 +410,44 @@ void CClientMarker::StreamOut()
410410
}
411411
}
412412

413-
void CClientMarker::Callback_OnCollision(CClientColShape& Shape, CClientEntity& Entity)
413+
void CClientMarker::Callback_OnCollision(CClientColShape& shape, CClientEntity& entity)
414414
{
415-
if (IS_PLAYER(&Entity))
416-
{
417-
// Call the marker hit event
418-
CLuaArguments Arguments;
419-
Arguments.PushElement(&Entity); // player that hit it
420-
Arguments.PushBoolean((GetDimension() == Entity.GetDimension())); // matching dimension?
421-
CallEvent("onClientMarkerHit", Arguments, true);
422-
}
415+
if (GetInterior() != entity.GetInterior())
416+
return;
417+
418+
// Call the marker hit event
419+
CLuaArguments arguments;
420+
arguments.PushElement(&entity); // Hit element
421+
arguments.PushBoolean(GetDimension() == entity.GetDimension()); // Matching dimension?
422+
CallEvent("onClientMarkerHit", arguments, true);
423+
424+
if (!IS_PLAYER(&entity))
425+
return;
426+
427+
CLuaArguments arguments2;
428+
arguments2.PushElement(this); // marker
429+
arguments2.PushBoolean(GetDimension() == entity.GetDimension()); // Matching dimension?
430+
entity.CallEvent("onClientPlayerMarkerHit", arguments2, false);
423431
}
424432

425-
void CClientMarker::Callback_OnLeave(CClientColShape& Shape, CClientEntity& Entity)
433+
void CClientMarker::Callback_OnLeave(CClientColShape& shape, CClientEntity& entity)
426434
{
427-
if (IS_PLAYER(&Entity))
428-
{
429-
// Call the marker hit event
430-
CLuaArguments Arguments;
431-
Arguments.PushElement(&Entity); // player that hit it
432-
Arguments.PushBoolean((GetDimension() == Entity.GetDimension())); // matching dimension?
433-
CallEvent("onClientMarkerLeave", Arguments, true);
434-
}
435+
if (GetInterior() != entity.GetInterior())
436+
return;
437+
438+
// Call the marker leave event
439+
CLuaArguments arguments;
440+
arguments.PushElement(&entity); // Hit element
441+
arguments.PushBoolean(GetDimension() == entity.GetDimension()); // Matching dimension?
442+
CallEvent("onClientMarkerLeave", arguments, true);
443+
444+
if (!IS_PLAYER(&entity))
445+
return;
446+
447+
CLuaArguments arguments2;
448+
arguments2.PushElement(this); // marker
449+
arguments2.PushBoolean(GetDimension() == entity.GetDimension()); // Matching dimension?
450+
entity.CallEvent("onPlayerMarkerLeave", arguments2, false);
435451
}
436452

437453
void CClientMarker::CreateOfType(int iType)

Client/mods/deathmatch/logic/CClientPad.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ bool CClientPad::GetControlState(const char* szName, CControllerState& State, bo
323323
return State.LeftStickX == 128;
324324
break; // right
325325
case 7:
326-
return State.RightShoulder2 == 255;
326+
return State.LeftShoulder2 == 255;
327327
break; // zoom in
328328
case 8:
329-
return State.LeftShoulder2 == 255;
329+
return State.RightShoulder2 == 255;
330330
break; // zoom out
331331
case 9:
332332
return State.ButtonTriangle == 255; // enter_exit

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,14 +1713,12 @@ void CClientPed::SetUsesCollision(bool bUsesCollision)
17131713

17141714
float CClientPed::GetMaxHealth()
17151715
{
1716-
// TODO: Verify this formula
1717-
17181716
// Grab his player health stat
17191717
float fStat = GetStat(MAX_HEALTH);
17201718

17211719
// Do a linear interpolation to get how much health this would allow
1722-
// Assumes: 100 health = 569 stat, 200 health = 1000 stat.
1723-
float fMaxHealth = 100.0f + (100.0f / 431.0f * (fStat - 569.0f));
1720+
// Assumes: 100 health = 569 stat, 176 health = 1000 stat.
1721+
float fMaxHealth = fStat * 0.176f;
17241722

17251723
// Return the max health. Make sure it can't be below 1
17261724
if (fMaxHealth < 1.0f)

Client/mods/deathmatch/logic/CClientPickupManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using std::list;
1515

1616
static const SFixedArray<unsigned short, 47> g_usWeaponModels = {{
1717
0, 331, 333, 334, 335, 336, 337, 338, 339, 341, // 9
18-
321, 322, 323, 0, 325, 326, 342, 343, 344, 0, // 19
18+
321, 322, 323, 324, 325, 326, 342, 343, 344, 0, // 19
1919
0, 0, 346, 347, 348, 349, 350, 351, 352, 353, // 29
2020
355, 356, 372, 357, 358, 359, 360, 361, 362, 363, // 39
2121
364, 365, 366, 367, 368, 369, 371 // 46
@@ -92,7 +92,7 @@ bool CClientPickupManager::IsValidPickupID(unsigned short usPickupID)
9292

9393
bool CClientPickupManager::IsValidWeaponID(unsigned short usWeaponID)
9494
{
95-
return (usWeaponID > 0 && usWeaponID != 13 && usWeaponID != 19 && usWeaponID != 20 && usWeaponID != 21 && usWeaponID <= 46);
95+
return (usWeaponID > 0 && usWeaponID != 19 && usWeaponID != 20 && usWeaponID != 21 && usWeaponID <= 46);
9696
}
9797

9898
bool CClientPickupManager::IsPickupLimitReached()

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,6 @@ void CClientVehicle::SetVariant(unsigned char ucVariant, unsigned char ucVariant
11271127
m_ComponentVisibilityBackup[pair.first] = pair.second.m_bVisible;
11281128
// Clear component data to regenerate it on next create
11291129
m_ComponentData.clear();
1130-
11311130
ReCreate();
11321131
}
11331132

@@ -2636,7 +2635,6 @@ void CClientVehicle::Create()
26362635
m_pVehicle->SetOverrideLights(m_ucOverrideLights);
26372636
m_pVehicle->SetRemap(static_cast<unsigned int>(m_ucPaintjob));
26382637
m_pVehicle->SetBodyDirtLevel(m_fDirtLevel);
2639-
m_pVehicle->SetEngineOn(m_bEngineOn);
26402638
m_pVehicle->SetAreaCode(m_ucInterior);
26412639
m_pVehicle->SetSmokeTrailEnabled(m_bSmokeTrail);
26422640
m_pVehicle->SetGravity(&m_vecGravity);
@@ -2689,6 +2687,8 @@ void CClientVehicle::Create()
26892687
if (m_pDriver)
26902688
m_pDriver->WarpIntoVehicle(this, 0);
26912689

2690+
m_pVehicle->SetEngineOn(m_bEngineOn);
2691+
26922692
// Warp the passengers back in
26932693
for (unsigned int i = 0; i < 8; i++)
26942694
{

Client/mods/deathmatch/logic/CVehicleNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ static const SFixedArray<SVehicleName, 212> VehicleNames = {{{"Landstalker"},
122122
{"Benson"},
123123
{"Mesa"},
124124
{"RC Goblin"},
125-
{"Hotring Racer 3"},
126125
{"Hotring Racer 2"},
126+
{"Hotring Racer 3"},
127127
{"Bloodring Banger"},
128128
{"Rancher Lure"},
129129
{"Super GT"},
@@ -225,7 +225,7 @@ static const SFixedArray<SVehicleName, 212> VehicleNames = {{{"Landstalker"},
225225
{"Alpha"},
226226
{"Phoenix"},
227227
{"Glendale Damaged"},
228-
{"Sadler", "Sadler Damaged"},
228+
{"Sadler Damaged", "Sadler"},
229229
{"Baggage Trailer (covered)"},
230230
{"Baggage Trailer (Uncovered)"},
231231
{"Trailer (Stairs)"},

Client/mods/deathmatch/logic/CWeaponNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ static const SWeaponName _WeaponNames[] = {{"Fist"},
3333
{"Poolstick"},
3434
{"Katana"},
3535
{"Chainsaw"},
36+
{"Purple Dildo"},
3637
{"Dildo"},
37-
{"Dildo"},
38-
{"Vibrator"},
3938
{"Vibrator"},
39+
{"Silver Vibrator"},
4040
{"Flower"},
4141
{"Cane"},
4242
{"Grenade"},

Client/mods/deathmatch/logic/lua/CLuaArguments.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -547,49 +547,53 @@ json_object* CLuaArguments::WriteTableToJSONObject(bool bSerialize, CFastHashMap
547547
bKnownTablesCreated = true;
548548
}
549549

550-
pKnownTables->insert(std::make_pair(this, pKnownTables->size()));
550+
pKnownTables->insert({this, pKnownTables->size()});
551551

552-
bool bIsArray = true;
553-
unsigned int iArrayPos = 1; // lua arrays are 1 based
554-
vector<CLuaArgument*>::const_iterator iter = m_Arguments.begin();
552+
bool bIsArray = true;
553+
std::vector<std::pair<std::uint32_t, CLuaArgument*>> vecSortedArguments; // lua arrays are not necessarily sorted
554+
std::vector<CLuaArgument*>::const_iterator iter = m_Arguments.begin();
555555
for (; iter != m_Arguments.end(); iter += 2)
556556
{
557557
CLuaArgument* pArgument = *iter;
558558
if (pArgument->GetType() == LUA_TNUMBER)
559559
{
560-
double num = pArgument->GetNumber();
561-
unsigned int iNum = static_cast<unsigned int>(num);
562-
if (num == iNum)
563-
{
564-
if (iArrayPos != iNum) // check if the value matches its index in the table
565-
{
566-
bIsArray = false;
567-
break;
568-
}
569-
}
570-
else
571-
{
572-
bIsArray = false;
573-
break;
574-
}
560+
double const num = pArgument->GetNumber();
561+
auto const iNum = static_cast<std::uint32_t>(num);
562+
563+
vecSortedArguments.push_back({iNum, *(iter + 1)});
575564
}
576565
else
577566
{
578567
bIsArray = false;
579568
break;
580569
}
581-
iArrayPos++;
582570
}
583571

584-
if (bIsArray)
572+
if (bIsArray && !vecSortedArguments.empty()) // the table could possibly be an array
585573
{
586-
json_object* my_array = json_object_new_array();
587-
vector<CLuaArgument*>::const_iterator iter = m_Arguments.begin();
588-
for (; iter != m_Arguments.end(); iter++)
574+
// sort the table based on the keys (already handled correctly by std::pair)
575+
std::sort(vecSortedArguments.begin(), vecSortedArguments.end());
576+
577+
// only the first and last element are checked, everything else is correct by default because the vector was sorted
578+
// the last key should match the size of vecSortedArguments to ensure there are no gaps in this array-like table
579+
auto const iFirstKey = vecSortedArguments.front().first;
580+
auto const iLastKey = vecSortedArguments.back().first;
581+
582+
auto const iFirstArrayPos = 1U; // lua arrays are 1 based
583+
auto const iLastArrayPos = static_cast<std::uint32_t>(vecSortedArguments.size());
584+
585+
if (iFirstKey != iFirstArrayPos || iLastKey != iLastArrayPos)
589586
{
590-
iter++; // skip the key values
591-
CLuaArgument* pArgument = *iter;
592-
json_object* object = pArgument->WriteToJSONObject(bSerialize, pKnownTables);
587+
bIsArray = false;
588+
}
589+
}
590+
591+
if (bIsArray) // the table is definitely an array
592+
{
593+
json_object* my_array = json_object_new_array();
594+
for (auto const& [iKey, pArgument] : vecSortedArguments)
595+
{
596+
json_object* object = pArgument->WriteToJSONObject(bSerialize, pKnownTables);
593597
if (object)
594598
{
595599
json_object_array_add(my_array, object);

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,14 @@ void CMultiplayerSA::InitHooks()
15751575
// Allow alpha change for helicopter rotor (#523)
15761576
MemSet((void*)0x6C444B, 0x90, 6);
15771577
MemSet((void*)0x6C4453, 0x90, 0x68);
1578+
1579+
// Disable Z position changes in the matrix in the C3dMarkers::PlaceMarker (#4000, #536)
1580+
// To prevent arrow-type markers from snapping to the ground
1581+
MemCpy((void*)0x725844, "\xDD\xD8\x90", 3);
1582+
MemCpy((void*)0x725619, "\xDD\xD8\x90", 3);
1583+
MemCpy((void*)0x72565A, "\xDD\xD8\x90", 3);
1584+
MemCpy((void*)0x7259B0, "\xDD\xD8\x90", 3);
1585+
MemSet((void*)0x7258B8, 0x90, 6);
15781586

15791587
InitHooks_CrashFixHacks();
15801588
InitHooks_DeviceSelection();

0 commit comments

Comments
 (0)