1
0
mirror of synced 2024-11-14 23:07:36 +01:00

Merge pull request #150 from doomertheboomer/master

WMMT5DX+ work, add mileage saving and add old terminal options from MT5
This commit is contained in:
Boomslangnz 2021-08-26 16:47:25 +12:00 committed by GitHub
commit 659ca03b10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,9 +15,9 @@
extern LPCSTR hookPort;
uintptr_t imageBasedxplus;
static unsigned char hasp_buffer[0xD40];
//static bool isFreePlay;
//static bool isEventMode2P;
//static bool isEventMode4P;
static bool isFreePlay;
static bool isEventMode2P;
static bool isEventMode4P;
const char *ipaddrdxplus;
/*
// Data for IC card, Force Feedback etc OFF.
@ -133,9 +133,9 @@ unsigned char dxpterminalPackage6_Free[139] = {
0x20, 0x00, 0x52, 0x0B, 0x08, 0x64, 0x10, 0xDE, 0x0F, 0x18, 0x05, 0x20,
0x00, 0x28, 0x00, 0x26, 0xB7, 0x89, 0xD0
};
/*
// FOR COIN ENTRY!
unsigned char terminalPackage1_Coin[75] = {
unsigned char dxpterminalPackage1_Coin[75] = {
0x01, 0x04, 0x47, 0x00, 0x12, 0x14, 0x0A, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0x00,
0x50, 0x00, 0x1A, 0x00, 0x2A, 0x12, 0x08, 0x0B, 0x12, 0x0C, 0x32, 0x37,
@ -145,7 +145,7 @@ unsigned char terminalPackage1_Coin[75] = {
0x06, 0x41, 0x0B
};
unsigned char terminalPackage2_Coin[135] = {
unsigned char dxpterminalPackage2_Coin[135] = {
0x01, 0x04, 0x83, 0x00, 0x12, 0x14, 0x0A, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0x00,
0x50, 0x00, 0x1A, 0x00, 0x2A, 0x12, 0x08, 0x39, 0x12, 0x0C, 0x32, 0x37,
@ -160,7 +160,7 @@ unsigned char terminalPackage2_Coin[135] = {
0xF1, 0x0D, 0xB2
};
unsigned char terminalPackage3_Coin[75] = {
unsigned char dxpterminalPackage3_Coin[75] = {
0x01, 0x04, 0x47, 0x00, 0x12, 0x14, 0x0A, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0x00,
0x50, 0x00, 0x1A, 0x00, 0x2A, 0x12, 0x08, 0x3A, 0x12, 0x0C, 0x32, 0x37,
@ -170,7 +170,7 @@ unsigned char terminalPackage3_Coin[75] = {
0x25, 0x31, 0x0D
};
unsigned char terminalPackage4_Coin[135] = {
unsigned char dxpterminalPackage4_Coin[135] = {
0x01, 0x04, 0x83, 0x00, 0x12, 0x14, 0x0A, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0x00,
0x50, 0x00, 0x1A, 0x00, 0x2A, 0x12, 0x08, 0x57, 0x12, 0x0C, 0x32, 0x37,
@ -185,7 +185,7 @@ unsigned char terminalPackage4_Coin[135] = {
0x8B, 0x15, 0xCB
};
unsigned char terminalPackage5_Coin[79] = {
unsigned char dxpterminalPackage5_Coin[79] = {
0x01, 0x04, 0x4B, 0x00, 0x12, 0x14, 0x0A, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0x00,
0x50, 0x00, 0x1A, 0x02, 0x5A, 0x00, 0x2A, 0x12, 0x08, 0x58, 0x12, 0x0C,
@ -195,7 +195,7 @@ unsigned char terminalPackage5_Coin[79] = {
0x00, 0x28, 0x00, 0x3E, 0xB1, 0xB7, 0x22
};
unsigned char terminalPackage6_Coin[139] = {
unsigned char dxpterminalPackage6_Coin[139] = {
0x01, 0x04, 0x87, 0x00, 0x12, 0x14, 0x0A, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0x00,
0x50, 0x00, 0x1A, 0x02, 0x5A, 0x00, 0x2A, 0x12, 0x08, 0x77, 0x12, 0x0C,
@ -212,7 +212,7 @@ unsigned char terminalPackage6_Coin[139] = {
//Event mode 2P
unsigned char terminalPackage1_Event4P[79] = {
unsigned char dxpterminalPackage1_Event4P[79] = {
0x01, 0x04, 0x44, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xd1, 0x0b, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -221,7 +221,7 @@ unsigned char terminalPackage1_Event4P[79] = {
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0xc1, 0x96, 0xc9, 0x2e
};
unsigned char terminalPackage2_Event4P[139] = {
unsigned char dxpterminalPackage2_Event4P[139] = {
0x01, 0x04, 0x80, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xd2, 0x0b, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -236,7 +236,7 @@ unsigned char terminalPackage2_Event4P[139] = {
};
unsigned char terminalPackage3_Event4P[79] = {
unsigned char dxpterminalPackage3_Event4P[79] = {
0x01, 0x04, 0x44, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0x8d, 0x0c, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -245,7 +245,7 @@ unsigned char terminalPackage3_Event4P[79] = {
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0x86, 0xb1, 0x27, 0x9e
};
unsigned char terminalPackage4_Event4P[139] = {
unsigned char dxpterminalPackage4_Event4P[139] = {
0x01, 0x04, 0x80, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0x8e, 0x0c, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -260,7 +260,7 @@ unsigned char terminalPackage4_Event4P[139] = {
};
unsigned char terminalPackage5_Event4P[79] = {
unsigned char dxpterminalPackage5_Event4P[79] = {
0x01, 0x04, 0x44, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xc9, 0x0c, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -269,7 +269,7 @@ unsigned char terminalPackage5_Event4P[79] = {
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0x5d, 0x49, 0x01, 0x1e
};
unsigned char terminalPackage6_Event4P[139] = {
unsigned char dxpterminalPackage6_Event4P[139] = {
0x01, 0x04, 0x80, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xca, 0x0c, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -285,7 +285,7 @@ unsigned char terminalPackage6_Event4P[139] = {
//Event mode 2P
unsigned char terminalPackage1_Event2P[79] = {
unsigned char dxpterminalPackage1_Event2P[79] = {
0x01, 0x04, 0x44, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xfe, 0x0e, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -294,7 +294,7 @@ unsigned char terminalPackage1_Event2P[79] = {
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0xaf, 0xa1, 0x42, 0x3d
};
unsigned char terminalPackage2_Event2P[139] = {
unsigned char dxpterminalPackage2_Event2P[139] = {
0x01, 0x04, 0x80, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xff, 0x0e, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -309,7 +309,7 @@ unsigned char terminalPackage2_Event2P[139] = {
};
unsigned char terminalPackage3_Event2P[79] = {
unsigned char dxpterminalPackage3_Event2P[79] = {
0x01, 0x04, 0x44, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0x80, 0x0f, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -318,7 +318,7 @@ unsigned char terminalPackage3_Event2P[79] = {
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0xa3, 0x94, 0x12, 0x9b
};
unsigned char terminalPackage4_Event2P[139] = {
unsigned char dxpterminalPackage4_Event2P[139] = {
0x01, 0x04, 0x80, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0x8d, 0x0f, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -333,7 +333,7 @@ unsigned char terminalPackage4_Event2P[139] = {
};
unsigned char terminalPackage5_Event2P[79] = {
unsigned char dxpterminalPackage5_Event2P[79] = {
0x01, 0x04, 0x44, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0x8e, 0x0f, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -342,7 +342,7 @@ unsigned char terminalPackage5_Event2P[79] = {
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0xa3, 0xc2, 0x27, 0x9c
};
unsigned char terminalPackage6_Event2P[139] = {
unsigned char dxpterminalPackage6_Event2P[139] = {
0x01, 0x04, 0x80, 0x00, 0x12, 0x0e, 0x0a, 0x00, 0x10, 0x04, 0x18, 0x00,
0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1a, 0x00, 0x2a, 0x13,
0x08, 0xf0, 0x0e, 0x12, 0x0c, 0x32, 0x37, 0x32, 0x32, 0x31, 0x31, 0x39,
@ -355,7 +355,7 @@ unsigned char terminalPackage6_Event2P[139] = {
0x03, 0x10, 0x01, 0x18, 0x00, 0x20, 0x00, 0x52, 0x0b, 0x08, 0x64, 0x10,
0xde, 0x0f, 0x18, 0x05, 0x20, 0x00, 0x28, 0x00, 0x97, 0xd5, 0x79, 0xa6
};
*/
#define HASP_STATUS_OK 0
unsigned int dxpHook_hasp_login(int feature_id, void* vendor_code, int hasp_handle) {
@ -409,6 +409,8 @@ unsigned int dxpHook_hasp_write(int hasp_handle, int hasp_fileid, unsigned int o
unsigned char saveDatadxp[0x2000];
unsigned char mileDatadxp[0x08];
// BASE: 0x24E0
// Campaing honor data: 2998, save 0xB8
// Story Mode Honor data: 25F0, save 0x98
@ -527,6 +529,38 @@ char carFileNamedxp[0xFF];
bool loadOkdxp = false;
bool customCardxp = false;
static void saveMileagedxp()
{
//Mileage Write to "GAME/mileage.dat"
auto mileageLocation = (uintptr_t*)(*(uintptr_t*)(imageBasedxplus + 0x1F7D578) + 0x280);
//try this maybe, casting to int probably not right/not gonna work
FILE* tempFile = fopen("mileage.dat", "wb");
fwrite(mileageLocation, 1, sizeof(mileageLocation), tempFile);
fclose(tempFile);
}
static void LoadMileagedxp()
{
memset(mileDatadxp, 0, 0x08);
FILE* miles = fopen("mileage.dat", "rb");
if (miles)
{
fseek(miles, 0, SEEK_END);
int mileSize = ftell(miles);
if (mileSize == 0x08)
{
fseek(miles, 0, SEEK_SET);
fread(mileDatadxp, mileSize, 1, miles);
uintptr_t mileMemory = *(uintptr_t*)(imageBasedxplus + 0x1F7D578);
memcpy((void*)(mileMemory + 0x280), mileDatadxp + 0x00, 0x04);
fclose(miles);
}
}
}
static int SaveGameData()
{
if (!saveOk)
@ -559,6 +593,8 @@ static int SaveGameData()
fwrite(carDatadxp, 1, 0xFF, file);
fclose(file);
saveMileagedxp();
saveOk = false;
return 1;
@ -863,6 +899,8 @@ static void LoadWmmt5CarData()
memset(carFileNamedxp, 0, 0xFF);
CreateDirectoryA("OpenParrot_Cars", nullptr);
LoadMileagedxp();
// check for custom car
sprintf(carFileNamedxp, ".\\OpenParrot_Cars\\custom.car");
if (FileExists(carFileNamedxp))
@ -1066,72 +1104,72 @@ static DWORD WINAPI SpamMulticast(LPVOID)
sizeof(dxpterminalPackage5_Free),
sizeof(dxpterminalPackage6_Free),
};
/*
const uint8_t* byteSequences_Event2P[] = {
terminalPackage1_Event2P,
terminalPackage2_Event2P,
terminalPackage3_Event2P,
terminalPackage4_Event2P,
terminalPackage5_Event2P,
terminalPackage6_Event2P,
dxpterminalPackage1_Event2P,
dxpterminalPackage2_Event2P,
dxpterminalPackage3_Event2P,
dxpterminalPackage4_Event2P,
dxpterminalPackage5_Event2P,
dxpterminalPackage6_Event2P,
};
const size_t byteSizes_Event2P[] = {
sizeof(terminalPackage1_Event2P),
sizeof(terminalPackage2_Event2P),
sizeof(terminalPackage3_Event2P),
sizeof(terminalPackage4_Event2P),
sizeof(terminalPackage5_Event2P),
sizeof(terminalPackage6_Event2P),
sizeof(dxpterminalPackage1_Event2P),
sizeof(dxpterminalPackage2_Event2P),
sizeof(dxpterminalPackage3_Event2P),
sizeof(dxpterminalPackage4_Event2P),
sizeof(dxpterminalPackage5_Event2P),
sizeof(dxpterminalPackage6_Event2P),
};
const uint8_t* byteSequences_Event4P[] = {
terminalPackage1_Event4P,
terminalPackage2_Event4P,
terminalPackage3_Event4P,
terminalPackage4_Event4P,
terminalPackage5_Event4P,
terminalPackage6_Event4P,
dxpterminalPackage1_Event4P,
dxpterminalPackage2_Event4P,
dxpterminalPackage3_Event4P,
dxpterminalPackage4_Event4P,
dxpterminalPackage5_Event4P,
dxpterminalPackage6_Event4P,
};
const size_t byteSizes_Event4P[] = {
sizeof(terminalPackage1_Event4P),
sizeof(terminalPackage2_Event4P),
sizeof(terminalPackage3_Event4P),
sizeof(terminalPackage4_Event4P),
sizeof(terminalPackage5_Event4P),
sizeof(terminalPackage6_Event4P),
sizeof(dxpterminalPackage1_Event4P),
sizeof(dxpterminalPackage2_Event4P),
sizeof(dxpterminalPackage3_Event4P),
sizeof(dxpterminalPackage4_Event4P),
sizeof(dxpterminalPackage5_Event4P),
sizeof(dxpterminalPackage6_Event4P),
};
const uint8_t* byteSequences_Coin[] = {
terminalPackage1_Coin,
terminalPackage2_Coin,
terminalPackage3_Coin,
terminalPackage4_Coin,
terminalPackage5_Coin,
terminalPackage6_Coin,
dxpterminalPackage1_Coin,
dxpterminalPackage2_Coin,
dxpterminalPackage3_Coin,
dxpterminalPackage4_Coin,
dxpterminalPackage5_Coin,
dxpterminalPackage6_Coin,
};
const size_t byteSizes_Coin[] = {
sizeof(terminalPackage1_Coin),
sizeof(terminalPackage2_Coin),
sizeof(terminalPackage3_Coin),
sizeof(terminalPackage4_Coin),
sizeof(terminalPackage5_Coin),
sizeof(terminalPackage6_Coin),
sizeof(dxpterminalPackage1_Coin),
sizeof(dxpterminalPackage2_Coin),
sizeof(dxpterminalPackage3_Coin),
sizeof(dxpterminalPackage4_Coin),
sizeof(dxpterminalPackage5_Coin),
sizeof(dxpterminalPackage6_Coin),
};
*/
sockaddr_in toAddr = { 0 };
toAddr.sin_family = AF_INET;
toAddr.sin_addr.s_addr = inet_addr("225.0.0.1");
toAddr.sin_port = htons(50765);
/*
isFreePlay = ToBool(config["General"]["FreePlay"]);
isEventMode2P = ToBool(config["TerminalEmuConfig"]["2P Event Mode"]);
isEventMode4P = ToBool(config["TerminalEmuConfig"]["4P Event Mode"]);
*/
/*
if (isFreePlay)
{
if (isEventMode2P) {
@ -1161,12 +1199,6 @@ static DWORD WINAPI SpamMulticast(LPVOID)
{
sendto(sock, (const char*)byteSequences_Coin[i], byteSizes_Coin[i], 0, (sockaddr*)&toAddr, sizeof(toAddr));
Sleep(8);
}*/
while (true) for (int i = 0; i < _countof(byteSequences_Free); i++)
{
sendto(sock, (const char*)byteSequences_Free[i], byteSizes_Free[i], 0, (sockaddr*)&toAddr, sizeof(toAddr));
Sleep(8);
}
}
@ -1392,7 +1424,7 @@ static InitFunction Wmmt5Func([]()
//safeJMP(imageBase + 0x806020, ReturnTrue);
}
std::string value = config["General"]["Custom Name"];
std::string value = config["General"]["CustomName"];
if (!value.empty())
{