mirror of
https://gitlab.com/hashborgir/CharmZone-1.10.git
synced 2024-10-05 17:15:59 +00:00
Working
This commit is contained in:
parent
f88ca7c2f2
commit
0ff4515b2b
57
D2Patch.h
57
D2Patch.h
@ -13,12 +13,57 @@
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
// Function to read settings from D2Mod.ini file
|
||||
int ReadSettingFromIni(const char* section, const char* key, BYTE defaultValue) {
|
||||
return GetPrivateProfileInt(section, key, defaultValue, "D2Mod.ini");
|
||||
#include <Windows.h>
|
||||
|
||||
// Function to read setting from the INI file and provide detailed information
|
||||
int ReadSettingFromIni(const char* section, const char* key, int defaultValue) {
|
||||
// Get the file path
|
||||
const char* filePath = "./D2Mod.ini";
|
||||
|
||||
// Check if the file exists and can be found
|
||||
DWORD fileAttributes = GetFileAttributesA(filePath);
|
||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES) {
|
||||
MessageBoxA(NULL, "INI file not found or inaccessible.", "INI File Error", MB_OK | MB_ICONERROR);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// Try to read the setting from the INI file
|
||||
int value = GetPrivateProfileIntA(section, key, defaultValue, filePath);
|
||||
//DWORD lastError = GetLastError();
|
||||
//if (value == 0 && lastError != 0) {
|
||||
// // Error occurred while reading from INI file
|
||||
// char errorMessage[512];
|
||||
// sprintf(errorMessage, "Error reading setting from INI file:\n\n"
|
||||
// "INI File Path: %s\n"
|
||||
// "Section: %s\n"
|
||||
// "Key: %s\n"
|
||||
// "Default Value: %d\n"
|
||||
// "Error Code: %d\n\n"
|
||||
// "Ensure that the section and key exist in the INI file and the file is accessible.",
|
||||
// filePath, section, key, defaultValue, lastError);
|
||||
// MessageBoxA(NULL, errorMessage, "INI File Error", MB_OK | MB_ICONERROR);
|
||||
//}
|
||||
//else {
|
||||
// // Successfully read the setting
|
||||
// char successMessage[256];
|
||||
// sprintf(successMessage, "Setting read from INI file:\n\n"
|
||||
// "INI File Path: %s\n"
|
||||
// "Section: %s\n"
|
||||
// "Key: %s\n"
|
||||
// "Value: %d", filePath, section, key, value);
|
||||
// MessageBoxA(NULL, successMessage, "INI File Success", MB_OK | MB_ICONINFORMATION);
|
||||
//}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Function to calculate relative offset (D2COMMON base address is 0x6F600000)
|
||||
DWORD calculateRelativeOffsetD2Common(DWORD offset) {
|
||||
return offset - 0x6F600000;
|
||||
@ -30,10 +75,10 @@ DWORD calculateRelativeOffsetD2Client(DWORD offset) {
|
||||
}
|
||||
|
||||
// Define settings from D2Mod.ini
|
||||
BYTE leftBorder = ReadSettingFromIni("CharmZone", "leftBorder", 0x00);
|
||||
BYTE rightBorder = ReadSettingFromIni("CharmZone", "rightBorder", 0x10);
|
||||
BYTE topBorder = ReadSettingFromIni("CharmZone", "topBorder", 0x0C);
|
||||
BYTE bottomBorder = ReadSettingFromIni("CharmZone", "bottomBorder", 0x10);
|
||||
BYTE leftBorder = ReadSettingFromIni("CharmZone", "leftBorder", 0x04);
|
||||
BYTE rightBorder = ReadSettingFromIni("CharmZone", "rightBorder", 0x08);
|
||||
BYTE topBorder = ReadSettingFromIni("CharmZone", "topBorder", 0x00);
|
||||
BYTE bottomBorder = ReadSettingFromIni("CharmZone", "bottomBorder", 0x04);
|
||||
|
||||
// Function to reverse the bytes of a hexadecimal number
|
||||
uint32_t reverseHexBytes(uint32_t hexNumber) {
|
||||
|
Loading…
Reference in New Issue
Block a user