Skip to content

Commit 1b0cfaa

Browse files
authored
Merge branch 'master' into refactor/CWeaponSA
2 parents b669503 + 468ea70 commit 1b0cfaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+7404
-6999
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Crowdin Auto-Merge
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 5' # This cron expression runs the workflow every Friday at midnight (UTC)
6+
workflow_dispatch:
7+
8+
jobs:
9+
crowdin-auto-merge:
10+
if: github.event.repository.fork == false
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Git
19+
run: |
20+
git config --global user.name 'github-actions[bot]'
21+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
22+
23+
- name: Auto-merge pull request
24+
run: |
25+
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --author 'MTABot' --base 'master' --head 'l10n/master' --state open --json number --jq '.[0].number')
26+
if [ -n "$PR_NUMBER" ]; then
27+
gh pr merge $PR_NUMBER --squash --repo ${{ github.repository }} --admin --subject "New Crowdin updates (PR #$PR_NUMBER)" --body ""
28+
git push origin --delete l10n/master
29+
fi
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dockerimage.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
dockerfile: Dockerfile.armhf
2727
- tag: arm64
2828
dockerfile: Dockerfile.arm64
29+
if: github.event.repository.fork == false
2930
runs-on: ubuntu-latest
3031
steps:
3132
- uses: actions/checkout@v4

.github/workflows/rebuild-pots.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push, workflow_dispatch]
44

55
jobs:
66
test:
7+
if: github.event.repository.fork == false
78
runs-on: ubuntu-latest
89
steps:
910
- uses: actions/checkout@v4
@@ -23,6 +24,7 @@ jobs:
2324
run: pytest "utils/localization/tests"
2425
shell: bash -l {0}
2526
rebuild-pots:
27+
if: github.event.repository.fork == false
2628
runs-on: ubuntu-latest
2729
needs: test
2830
steps:

.github/workflows/stale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
jobs:
88
stale:
9+
if: github.event.repository.fork == false
910
runs-on: ubuntu-latest
1011
steps:
1112
- uses: multitheftauto/[email protected]

.github/workflows/sync-master-to-maetro.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
jobs:
99
sync-master-to-maetro:
10+
if: github.event.repository.fork == false
1011
runs-on: ubuntu-latest
1112
steps:
1213
- uses: actions/checkout@v4

Client/game_sa/CPedSA.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,3 +1120,9 @@ void CPedSA::GetAttachedSatchels(std::vector<SSatchelsData>& satchelsList) const
11201120
satchelsList.push_back({pProjectileInterface, &pProjectileInterface->m_vecAttachedOffset, &pProjectileInterface->m_vecAttachedRotation});
11211121
}
11221122
}
1123+
1124+
void CPedSA::Say(const ePedSpeechContext& speechId, float probability)
1125+
{
1126+
// Call CPed::Say
1127+
((void(__thiscall*)(CPedSAInterface*, ePedSpeechContext, int, float, bool, bool, bool))FUNC_CPed_Say)(GetPedInterface(), speechId, 0, probability, false, false, false);
1128+
}

Client/game_sa/CPedSA.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class CPedIntelligenceSAInterface;
5959
#define FUNC_DetachPedFromEntity 0x5E7EC0
6060
#define FUNC_CPed_RemoveBodyPart 0x5f0140
6161
#define FUNC_PreRenderAfterTest 0x5E65A0
62+
#define FUNC_CPed_Say 0x5EFFE0
6263

6364
#define VAR_LocalPlayer 0x94AD28
6465

@@ -419,4 +420,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
419420
ePedState GetPedState() { return GetPedInterface()->pedState; }
420421

421422
void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const override;
423+
424+
void Say(const ePedSpeechContext& speechId, float probability) override;
422425
};

Client/loader-proxy/exports.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
EXPORTS
2-
timeBeginPeriod=noreturn
3-
timeEndPeriod=noreturn
4-
timeGetDevCaps=noreturn
5-
timeGetTime=noreturn
2+
timeBeginPeriod=winmm.timeBeginPeriod
3+
timeEndPeriod=winmm.timeEndPeriod
4+
timeGetDevCaps=winmm.timeGetDevCaps
5+
timeGetTime=winmm.timeGetTime

Client/loader-proxy/main.cpp

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ BOOL OnLibraryAttach();
4747
auto SetImportProcAddress(const char* moduleName, const char* procedureName, FARPROC replacement) -> FARPROC;
4848
void DisplayErrorMessageBox(const std::wstring& message, const std::wstring& errorCode);
4949
bool DisplayWarningMessageBox(const std::wstring& message, const std::wstring& errorCode);
50-
auto PatchWinmmImports() -> int;
5150
auto GetSystemErrorMessage(DWORD errorCode) -> std::wstring;
5251
auto GetCurrentProcessPath() -> fs::path;
5352
auto GetParentProcessPath() -> fs::path;
@@ -232,29 +231,6 @@ VOID OnGameLaunch()
232231
return;
233232
}
234233

235-
// Patch the winmm.dll imports we've taken over with our mtasa.dll library back to the functions from the winmm.dll library.
236-
if (int error = PatchWinmmImports())
237-
{
238-
std::wstring message;
239-
240-
switch (error)
241-
{
242-
case 1:
243-
message = L"Loading system-provided winmm.dll failed.";
244-
break;
245-
case 4:
246-
message = L"Unable to find winmm.dll import entry.";
247-
break;
248-
default:
249-
message = L"Patching winmm.dll imports failed.";
250-
break;
251-
}
252-
253-
AddLaunchLog("Patching imports has failed (%d)", error);
254-
DisplayErrorMessageBox(MakeMissingFilesError(message), L"CL58");
255-
return;
256-
}
257-
258234
// For dll searches, this call replaces the current directory entry and turns off 'SafeDllSearchMode'.
259235
// Meaning it will search the supplied path before the system and windows directory.
260236
// http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx
@@ -357,15 +333,6 @@ BOOL WINAPI MyGetVersionExA(LPOSVERSIONINFOA versionInfo)
357333
return result;
358334
}
359335

360-
/**
361-
* @brief A placeholder function for fake winmm.dll exports.
362-
*/
363-
EXTERN_C void noreturn()
364-
{
365-
// We should never enter this function.
366-
assert(false);
367-
}
368-
369336
/**
370337
* @brief Replaces an import library procedure with the given replacement function.
371338
* @param moduleName Name of the import library (case-insensitive)
@@ -596,81 +563,6 @@ auto GetParentProcessPath() -> fs::path
596563
return GetProcessPath(GetParentProcessId());
597564
}
598565

599-
/**
600-
* @brief Loads the winmm.dll library.
601-
* @return A handle to the library
602-
*/
603-
auto LoadWinmmLibrary() -> HMODULE
604-
{
605-
if (HMODULE winmm = LoadLibraryExW(L"winmm.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32))
606-
return winmm;
607-
608-
return LoadLibraryW(L"winmm.dll");
609-
}
610-
611-
/**
612-
* @brief Replaces fake mtasa.dll imports with functions retrieved from the winmm.dll library.
613-
*/
614-
auto PatchWinmmImports() -> int
615-
{
616-
auto base = reinterpret_cast<std::byte*>(g_exe);
617-
auto dos = reinterpret_cast<IMAGE_DOS_HEADER*>(base);
618-
auto nt = reinterpret_cast<IMAGE_NT_HEADERS32*>(base + dos->e_lfanew);
619-
auto descriptor = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(base + nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
620-
621-
// Iterate through the import descriptors and find the winmm.dll entry, which we renamed to mtasa.dll.
622-
for (; descriptor->Name; ++descriptor)
623-
{
624-
auto name = reinterpret_cast<const char*>(base + descriptor->Name);
625-
626-
if (stricmp("mtasa.dll", name))
627-
continue;
628-
629-
HMODULE winmm = LoadWinmmLibrary();
630-
631-
if (!winmm)
632-
return 1;
633-
634-
auto nameTableEntry = reinterpret_cast<DWORD*>(base + descriptor->FirstThunk);
635-
auto addressTableEntry = reinterpret_cast<FARPROC*>(nameTableEntry);
636-
637-
if (descriptor->OriginalFirstThunk)
638-
nameTableEntry = reinterpret_cast<DWORD*>(base + descriptor->OriginalFirstThunk);
639-
640-
// Replace every import with the correct function from the winmm.dll library.
641-
for (; *nameTableEntry; ++nameTableEntry, ++addressTableEntry)
642-
{
643-
const char* functionName;
644-
645-
if (IMAGE_SNAP_BY_ORDINAL(*nameTableEntry))
646-
{
647-
functionName = reinterpret_cast<char const*>(IMAGE_ORDINAL(*nameTableEntry));
648-
}
649-
else
650-
{
651-
functionName = reinterpret_cast<IMAGE_IMPORT_BY_NAME*>(base + *nameTableEntry)->Name;
652-
}
653-
654-
if (!functionName)
655-
return 2;
656-
657-
FARPROC function = GetProcAddress(winmm, functionName);
658-
659-
if (!function)
660-
return 3;
661-
662-
DWORD protection;
663-
VirtualProtect(addressTableEntry, sizeof(FARPROC), PAGE_READWRITE, &protection);
664-
*addressTableEntry = function;
665-
VirtualProtect(addressTableEntry, sizeof(FARPROC), protection, &protection);
666-
}
667-
668-
return 0;
669-
}
670-
671-
return 4;
672-
}
673-
674566
/**
675567
* @brief Transforms the numeric error code into a system-generated error string.
676568
*/

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5272,6 +5272,14 @@ void CClientPed::Respawn(CVector* pvecPosition, bool bRestoreState, bool bCamera
52725272
}
52735273
}
52745274

5275+
void CClientPed::Say(const ePedSpeechContext& speechId, float probability)
5276+
{
5277+
if (!m_pPlayerPed)
5278+
return;
5279+
5280+
m_pPlayerPed->Say(speechId, probability);
5281+
}
5282+
52755283
const char* CClientPed::GetBodyPartName(unsigned char ucID)
52765284
{
52775285
if (ucID <= 10)

0 commit comments

Comments
 (0)