-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
64 lines (54 loc) · 1.76 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <mod/amlmod.h>
#include <mod/logger.h>
#include <fstream>
#include <stdint.h>
#include <ibass.h>
MYMOD(net.rusjj.basslib, BASS Sound Library, 1.1, RusJJ)
BEGIN_DEPLIST()
ADD_DEPENDENCY_VER(net.rusjj.aml, 1.0.2.1)
END_DEPLIST()
std::string loadFrom;
std::string loadSSLFrom;
uintptr_t pGTASA;
extern IBASS* bass;
#ifdef AML32
extern unsigned char bassData[259924];
extern unsigned char bass_sslData[1294584];
#else
extern unsigned char bassData[324856];
extern unsigned char bass_sslData[1808720];
#endif
#include "bass_vars.h"
extern "C" void OnModPreLoad()
{
logger->SetTag("BASS Mod");
pGTASA = aml->GetLib("libGTASA.so");
loadFrom = aml->GetDataPath();
loadSSLFrom = loadFrom + "/bass_ssl.so";
loadFrom += "/bass_mod.so";
std::ofstream fs(loadFrom.data(), std::ios::out | std::ios::binary);
fs.write((const char*)bassData, sizeof(bassData));
fs.close();
void* pBASSHandle = dlopen(loadFrom.data(), RTLD_NOW);
if(pBASSHandle == NULL)
{
logger->Error("Failed to load BASS library!");
return;
}
std::ofstream fs_ssl(loadSSLFrom.data(), std::ios::out | std::ios::binary);
fs_ssl.write((const char*)bass_sslData, sizeof(bass_sslData));
fs_ssl.close();
#include "bass_things.h"
logger->Info("Trying to initialize BASS...");
BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, "BASS/AML_Mod/1.1.0.0");
BASS_SetConfigPtr(BASS_CONFIG_LIBSSL, loadSSLFrom.data());
BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1);
BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT, 10000);
if (!BASS_Init(-1, 44100, 0))
{
logger->Error("Failed to initialize BASS library! Error Code: %d", BASS_ErrorGetCode());
return;
}
RegisterInterface("BASS", bass);
logger->Info("BASS initialized!");
}