mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Replaced GetPrivateProfileInt/String with wrapper functions
Fixed crash when a name in PremadePaths exceeds 11 characters.
This commit is contained in:
@@ -449,6 +449,7 @@ UseScrollingQuestsList=1
|
||||
|
||||
;Uncomment these lines to control the premade characters offered when starting a new game
|
||||
;Multiple options should be separated by commas, and there must be the same number of entries in both lines
|
||||
;Each name in PremadePaths is limited to 11 characters
|
||||
;PremadePaths=combat,diplomat,stealth
|
||||
;PremadeFIDs=201,203,202
|
||||
|
||||
|
||||
+2
-2
@@ -83,7 +83,7 @@ void CRC(const char* filepath) {
|
||||
DWORD size = GetFileSize(h, 0), crc;
|
||||
bool sizeMatch = (size == ExpectedSize);
|
||||
|
||||
if (!sizeMatch && GetPrivateProfileIntA("Debugging", "SkipSizeCheck", 0, ::sfall::ddrawIni)) {
|
||||
if (!sizeMatch && iniGetInt("Debugging", "SkipSizeCheck", 0, ::sfall::ddrawIni)) {
|
||||
sizeMatch = true;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ void CRC(const char* filepath) {
|
||||
bool matchedCRC = false;
|
||||
|
||||
auto extraCrcList = GetIniList("Debugging", "ExtraCRC", "", 512, ',', ::sfall::ddrawIni);
|
||||
if (extraCrcList.size() > 0) {
|
||||
if (!extraCrcList.empty()) {
|
||||
matchedCRC = std::any_of(extraCrcList.begin(), extraCrcList.end(), [crc](const std::string& testCrcStr) {
|
||||
auto testedCrc = strtoul(testCrcStr.c_str(), 0, 16);
|
||||
return testedCrc && crc == testedCrc;
|
||||
|
||||
+4
-4
@@ -58,16 +58,16 @@ void dlog_f(const char *fmt, int type, ...) {
|
||||
|
||||
void LoggingInit() {
|
||||
Log.open("sfall-log.txt", ios_base::out | ios_base::trunc);
|
||||
if (GetPrivateProfileIntA("Debugging", "Init", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "Init", 0, ::sfall::ddrawIni)) {
|
||||
DebugTypes |= DL_INIT;
|
||||
}
|
||||
if (GetPrivateProfileIntA("Debugging", "Hook", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "Hook", 0, ::sfall::ddrawIni)) {
|
||||
DebugTypes |= DL_HOOK;
|
||||
}
|
||||
if (GetPrivateProfileIntA("Debugging", "Script", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "Script", 0, ::sfall::ddrawIni)) {
|
||||
DebugTypes |= DL_SCRIPT;
|
||||
}
|
||||
if (GetPrivateProfileIntA("Debugging", "Criticals", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "Criticals", 0, ::sfall::ddrawIni)) {
|
||||
DebugTypes |= DL_CRITICALS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ void BarBoxes::init() {
|
||||
MakeCall(0x4615FA, refresh_box_bar_win_hack);
|
||||
SafeWriteBatch<DWORD>((DWORD)newBoxSlot, bboxSlotAddr); // _bboxslot
|
||||
|
||||
ifaceWidth = GetPrivateProfileIntA("IFACE", "IFACE_BAR_WIDTH", 640, ".\\f2_res.ini");
|
||||
ifaceWidth = iniGetInt("IFACE", "IFACE_BAR_WIDTH", 640, ".\\f2_res.ini");
|
||||
if (ifaceWidth < 640) ifaceWidth = 640;
|
||||
|
||||
LoadGameHook::OnAfterGameInit() += SetMaxSlots;
|
||||
|
||||
@@ -89,10 +89,10 @@ void Books::init() {
|
||||
dlog("Applying books patch...", DL_INIT);
|
||||
const char* iniBooks = booksFile.insert(0, ".\\").c_str();
|
||||
|
||||
bool includeVanilla = (GetPrivateProfileIntA("main", "overrideVanilla", 0, iniBooks) == 0);
|
||||
bool includeVanilla = (iniGetInt("main", "overrideVanilla", 0, iniBooks) == 0);
|
||||
if (includeVanilla) BooksCount = 5;
|
||||
|
||||
int count = GetPrivateProfileIntA("main", "count", 0, iniBooks);
|
||||
int count = iniGetInt("main", "count", 0, iniBooks);
|
||||
|
||||
int n = 0;
|
||||
if (count > 0) {
|
||||
@@ -104,9 +104,9 @@ void Books::init() {
|
||||
char section[4];
|
||||
for (int i = 1; i <= count; i++) {
|
||||
_itoa_s(i, section, 10);
|
||||
if (books[BooksCount].bookPid = GetPrivateProfileIntA(section, "PID", 0, iniBooks)) {
|
||||
books[BooksCount].msgID = GetPrivateProfileIntA(section, "TextID", 0, iniBooks);
|
||||
books[BooksCount].skill = GetPrivateProfileIntA(section, "Skill", 0, iniBooks);
|
||||
if (books[BooksCount].bookPid = iniGetInt(section, "PID", 0, iniBooks)) {
|
||||
books[BooksCount].msgID = iniGetInt(section, "TextID", 0, iniBooks);
|
||||
books[BooksCount].skill = iniGetInt(section, "Skill", 0, iniBooks);
|
||||
BooksCount++;
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -2382,7 +2382,7 @@ void BugFixes::init()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
LoadGameHook::OnBeforeGameClose() += PrintAddrList;
|
||||
if (isDebug && (GetPrivateProfileIntA("Debugging", "BugFixes", 1, ::sfall::ddrawIni) == 0)) return;
|
||||
if (isDebug && (iniGetInt("Debugging", "BugFixes", 1, ::sfall::ddrawIni) == 0)) return;
|
||||
#endif
|
||||
|
||||
// Missing game initialization
|
||||
|
||||
@@ -76,9 +76,10 @@ void Criticals::ResetCriticalTable(DWORD critter, DWORD bodypart, DWORD slot, DW
|
||||
critTable[critter][bodypart][slot].values[element] = baseCritTable[critter][bodypart][slot].values[element];
|
||||
}
|
||||
|
||||
static void CritTableLoad() {
|
||||
static int CritTableLoad() {
|
||||
if (mode == 1) {
|
||||
dlogr("Setting up critical hit table using CriticalOverrides.ini (old fmt)", DL_CRITICALS);
|
||||
if (GetFileAttributes(critTableFile.c_str()) == INVALID_FILE_ATTRIBUTES) return 1;
|
||||
char section[16];
|
||||
for (DWORD critter = 0; critter < 20; critter++) {
|
||||
for (DWORD part = 0; part < 9; part++) {
|
||||
@@ -88,7 +89,7 @@ static void CritTableLoad() {
|
||||
fo::CritInfo& newEffect = baseCritTable[newCritter][part][crit];
|
||||
fo::CritInfo& defaultEffect = fo::var::crit_succ_eff[critter][part][crit];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
newEffect.values[i] = GetPrivateProfileIntA(section, critNames[i], defaultEffect.values[i], critTableFile.c_str());
|
||||
newEffect.values[i] = iniGetInt(section, critNames[i], defaultEffect.values[i], critTableFile.c_str());
|
||||
if (isDebug) {
|
||||
char logmsg[256];
|
||||
if (newEffect.values[i] != defaultEffect.values[i]) {
|
||||
@@ -108,15 +109,16 @@ static void CritTableLoad() {
|
||||
|
||||
if (mode == 3) {
|
||||
dlogr(" and CriticalOverrides.ini (new fmt)", DL_CRITICALS);
|
||||
if (GetFileAttributes(critTableFile.c_str()) == INVALID_FILE_ATTRIBUTES) return 1;
|
||||
char buf[32], buf2[32], buf3[32];
|
||||
for (int critter = 0; critter < Criticals::critTableCount; critter++) {
|
||||
sprintf_s(buf, "c_%02d", critter);
|
||||
int all;
|
||||
if (!(all = GetPrivateProfileIntA(buf, "Enabled", 0, critTableFile.c_str()))) continue;
|
||||
if (!(all = iniGetInt(buf, "Enabled", 0, critTableFile.c_str()))) continue;
|
||||
for (int part = 0; part < 9; part++) {
|
||||
if (all < 2) {
|
||||
sprintf_s(buf2, "Part_%d", part);
|
||||
if (!GetPrivateProfileIntA(buf, buf2, 0, critTableFile.c_str())) continue;
|
||||
if (!iniGetInt(buf, buf2, 0, critTableFile.c_str())) continue;
|
||||
}
|
||||
|
||||
sprintf_s(buf2, "c_%02d_%d", critter, part);
|
||||
@@ -124,7 +126,7 @@ static void CritTableLoad() {
|
||||
fo::CritInfo& effect = baseCritTable[critter][part][crit];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
sprintf_s(buf3, "e%d_%s", crit, critNames[i]);
|
||||
effect.values[i] = GetPrivateProfileIntA(buf2, buf3, effect.values[i], critTableFile.c_str());
|
||||
effect.values[i] = iniGetInt(buf2, buf3, effect.values[i], critTableFile.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,6 +135,7 @@ static void CritTableLoad() {
|
||||
dlog("\n", DL_CRITICALS);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SetEntry(critter, bodypart, effect, param, value) fo::var::crit_succ_eff[critter][bodypart][effect].values[param] = value;
|
||||
@@ -240,8 +243,11 @@ static void CriticalTableOverride() {
|
||||
SetEntry(18, 7, 5, 5, 7101);
|
||||
}
|
||||
|
||||
CritTableLoad();
|
||||
dlogr("Completed applying critical hit table.", DL_INIT);
|
||||
if (CritTableLoad()) {
|
||||
dlogr("Failed to initialize critical hit table from file.", DL_INIT);
|
||||
} else {
|
||||
dlogr("Completed applying critical hit table.", DL_INIT);
|
||||
}
|
||||
Inited = true;
|
||||
}
|
||||
#undef SetEntry
|
||||
|
||||
@@ -320,7 +320,7 @@ static void __declspec(naked) win_debug_hook() {
|
||||
}
|
||||
|
||||
void DebugModePatch() {
|
||||
DWORD dbgMode = GetPrivateProfileIntA("Debugging", "DebugMode", 0, ::sfall::ddrawIni);
|
||||
DWORD dbgMode = iniGetInt("Debugging", "DebugMode", 0, ::sfall::ddrawIni);
|
||||
if (dbgMode) {
|
||||
dlog("Applying debugmode patch.", DL_INIT);
|
||||
// If the player is using an exe with the debug patch already applied, just skip this block without erroring
|
||||
@@ -342,7 +342,7 @@ void DebugModePatch() {
|
||||
} else {
|
||||
SafeWrite32(0x4C6D9C, (DWORD)debugGnw);
|
||||
}
|
||||
if (GetPrivateProfileIntA("Debugging", "HideObjIsNullMsg", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "HideObjIsNullMsg", 0, ::sfall::ddrawIni)) {
|
||||
MakeJump(0x453FD2, dbg_error_hack);
|
||||
}
|
||||
dlogr(" Done", DL_INIT);
|
||||
@@ -350,7 +350,7 @@ void DebugModePatch() {
|
||||
}
|
||||
|
||||
void DontDeleteProtosPatch() {
|
||||
if (GetPrivateProfileIntA("Debugging", "DontDeleteProtos", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "DontDeleteProtos", 0, ::sfall::ddrawIni)) {
|
||||
dlog("Applying permanent protos patch.", DL_INIT);
|
||||
SafeWrite8(0x48007E, 0xEB);
|
||||
dlogr(" Done", DL_INIT);
|
||||
|
||||
@@ -268,9 +268,9 @@ void Drugs::init() {
|
||||
dlog("Applying drugs patch...", DL_INIT);
|
||||
const char* iniDrugs = drugsFile.insert(0, ".\\").c_str();
|
||||
|
||||
if (GetPrivateProfileIntA("main", "JetWithdrawal", 0, iniDrugs) == 1) SafeWrite8(0x47A3A8, 0);
|
||||
if (iniGetInt("main", "JetWithdrawal", 0, iniDrugs) == 1) SafeWrite8(0x47A3A8, 0);
|
||||
|
||||
int count = GetPrivateProfileIntA("main", "Count", 0, iniDrugs);
|
||||
int count = iniGetInt("main", "Count", 0, iniDrugs);
|
||||
if (count > 0) {
|
||||
if (count > drugsMax) count = drugsMax;
|
||||
drugs = new sDrugs[count]();
|
||||
@@ -279,12 +279,12 @@ void Drugs::init() {
|
||||
char section[4];
|
||||
for (int i = 1; i <= count; i++) {
|
||||
_itoa_s(i, section, 10);
|
||||
int pid = GetPrivateProfileIntA(section, "PID", 0, iniDrugs);
|
||||
int pid = iniGetInt(section, "PID", 0, iniDrugs);
|
||||
if (pid > 0) {
|
||||
CheckEngineNumEffects(set, pid);
|
||||
drugs[drugsCount].drugPid = pid;
|
||||
drugs[drugsCount].addictTimeOff = drugs[drugsCount].iniAddictTimeOff = GetPrivateProfileIntA(section, "AddictTime", 0, iniDrugs);
|
||||
long ef = GetPrivateProfileIntA(section, "NumEffects", -1, iniDrugs);
|
||||
drugs[drugsCount].addictTimeOff = drugs[drugsCount].iniAddictTimeOff = iniGetInt(section, "AddictTime", 0, iniDrugs);
|
||||
long ef = iniGetInt(section, "NumEffects", -1, iniDrugs);
|
||||
if (set != -1) {
|
||||
if (ef < -1) {
|
||||
ef = -1;
|
||||
@@ -298,12 +298,12 @@ void Drugs::init() {
|
||||
drugs[drugsCount].numEffects = ef; // -1 to use the value from the engine
|
||||
} else {
|
||||
drugs[drugsCount].numEffects = drugs[drugsCount].iniNumEffects = max(0, ef);
|
||||
int gvar = GetPrivateProfileIntA(section, "GvarID", 0, iniDrugs);
|
||||
int gvar = iniGetInt(section, "GvarID", 0, iniDrugs);
|
||||
drugs[drugsCount].gvarID = max(0, gvar); // not allow negative values
|
||||
if (gvar) {
|
||||
int msg = GetPrivateProfileIntA(section, "TextID", -1, iniDrugs);
|
||||
int msg = iniGetInt(section, "TextID", -1, iniDrugs);
|
||||
drugs[drugsCount].msgID = (msg > 0) ? msg : -1;
|
||||
drugs[drugsCount].frmID = GetPrivateProfileIntA(section, "FrmID", -1, iniDrugs);
|
||||
drugs[drugsCount].frmID = iniGetInt(section, "FrmID", -1, iniDrugs);
|
||||
addictionGvarCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ static const int exitsPerElevator = 4;
|
||||
static const int vanillaElevatorCount = 24;
|
||||
static const int elevatorCount = 50;
|
||||
|
||||
//static char elevFile[MAX_PATH] = ".\\";
|
||||
|
||||
static DWORD elevatorType[elevatorCount] = {0};
|
||||
static fo::ElevatorExit elevatorExits[elevatorCount][exitsPerElevator] = {0}; // _retvals
|
||||
static fo::ElevatorFrms elevatorsFrms[elevatorCount] = {0}; // _intotal
|
||||
@@ -118,23 +116,23 @@ static void LoadElevators(const char* elevFile) {
|
||||
if (elevFile) {
|
||||
for (int i = 0; i < elevatorCount; i++) {
|
||||
_itoa_s(i, section, 10);
|
||||
int type = GetPrivateProfileIntA(section, "Image", elevatorType[i], elevFile);
|
||||
int type = iniGetInt(section, "Image", elevatorType[i], elevFile);
|
||||
elevatorType[i] = min(type, elevatorCount - 1);
|
||||
if (i >= vanillaElevatorCount) {
|
||||
int cBtn = GetPrivateProfileIntA(section, "ButtonCount", 2, elevFile);
|
||||
int cBtn = iniGetInt(section, "ButtonCount", 2, elevFile);
|
||||
if (cBtn > exitsPerElevator) cBtn = exitsPerElevator;
|
||||
elevatorsBtnCount[i] = max(2, cBtn);
|
||||
}
|
||||
elevatorsFrms[i].main = GetPrivateProfileIntA(section, "MainFrm", elevatorsFrms[i].main, elevFile);
|
||||
elevatorsFrms[i].buttons = GetPrivateProfileIntA(section, "ButtonsFrm", elevatorsFrms[i].buttons, elevFile);
|
||||
elevatorsFrms[i].main = iniGetInt(section, "MainFrm", elevatorsFrms[i].main, elevFile);
|
||||
elevatorsFrms[i].buttons = iniGetInt(section, "ButtonsFrm", elevatorsFrms[i].buttons, elevFile);
|
||||
char setting[32];
|
||||
for (int j = 0; j < exitsPerElevator; j++) {
|
||||
sprintf_s(setting, "ID%d", j + 1);
|
||||
elevatorExits[i][j].id = GetPrivateProfileIntA(section, setting, elevatorExits[i][j].id, elevFile);
|
||||
elevatorExits[i][j].id = iniGetInt(section, setting, elevatorExits[i][j].id, elevFile);
|
||||
sprintf_s(setting, "Elevation%d", j + 1);
|
||||
elevatorExits[i][j].elevation = GetPrivateProfileIntA(section, setting, elevatorExits[i][j].elevation, elevFile);
|
||||
elevatorExits[i][j].elevation = iniGetInt(section, setting, elevatorExits[i][j].elevation, elevFile);
|
||||
sprintf_s(setting, "Tile%d", j + 1);
|
||||
elevatorExits[i][j].tile = GetPrivateProfileIntA(section, setting, elevatorExits[i][j].tile, elevFile);
|
||||
elevatorExits[i][j].tile = iniGetInt(section, setting, elevatorExits[i][j].tile, elevFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ void LoadPageOffsets() {
|
||||
|
||||
sprintf_s(LoadPath, MAX_PATH, filename, fo::var::patches);
|
||||
|
||||
fo::var::slot_cursor = GetPrivateProfileInt("POSITION", "ListNum", 0, LoadPath);
|
||||
fo::var::slot_cursor = iniGetInt("POSITION", "ListNum", 0, LoadPath);
|
||||
if (fo::var::slot_cursor > 9) {
|
||||
fo::var::slot_cursor = 0;
|
||||
}
|
||||
LSPageOffset = GetPrivateProfileInt("POSITION", "PageOffset", 0, LoadPath);
|
||||
LSPageOffset = iniGetInt("POSITION", "PageOffset", 0, LoadPath);
|
||||
if (LSPageOffset > 9990) {
|
||||
LSPageOffset = 0;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ void HookScripts::init() {
|
||||
LoadGameHook::OnGameModeChange() += GameModeChangeHook;
|
||||
LoadGameHook::OnAfterGameStarted() += SourceUseSkillOnInit;
|
||||
|
||||
HookScripts::injectAllHooks = isDebug && (GetPrivateProfileIntA("Debugging", "InjectAllGameHooks", 0, ::sfall::ddrawIni) != 0);
|
||||
HookScripts::injectAllHooks = isDebug && (iniGetInt("Debugging", "InjectAllGameHooks", 0, ::sfall::ddrawIni) != 0);
|
||||
if (HookScripts::injectAllHooks) dlogr("Injecting all game hooks", DL_HOOK);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,14 +90,16 @@ void ApplyDisplayKarmaChangesPatch() {
|
||||
|
||||
void ApplyKarmaFRMsPatch() {
|
||||
auto karmaFrmList = GetConfigList("Misc", "KarmaFRMs", "", 512);
|
||||
if (!karmaFrmList.empty()) {
|
||||
size_t countFrm = karmaFrmList.size();
|
||||
if (countFrm) {
|
||||
dlog("Applying karma FRM patch.", DL_INIT);
|
||||
|
||||
auto karmaPointsList = GetConfigList("Misc", "KarmaPoints", "", 512);
|
||||
karmaFrms.resize(karmaFrmList.size());
|
||||
for (size_t i = 0; i < karmaFrmList.size(); i++) {
|
||||
|
||||
karmaFrms.resize(countFrm);
|
||||
size_t countPoints = karmaPointsList.size();
|
||||
for (size_t i = 0; i < countFrm; i++) {
|
||||
karmaFrms[i].frm = atoi(karmaFrmList[i].c_str());
|
||||
karmaFrms[i].points = (karmaPointsList.size() > i)
|
||||
karmaFrms[i].points = (countPoints > i)
|
||||
? atoi(karmaPointsList[i].c_str())
|
||||
: INT_MAX;
|
||||
}
|
||||
|
||||
@@ -30,11 +30,16 @@ void Premade::init() {
|
||||
auto premadePaths = GetConfigList("misc", "PremadePaths", "", 512);
|
||||
auto premadeFids = GetConfigList("misc", "PremadeFIDs", "", 512);
|
||||
if (!premadePaths.empty() && !premadeFids.empty()) {
|
||||
dlog("Applying premade characters patch.", DL_INIT);
|
||||
int count = min(premadePaths.size(), premadeFids.size());
|
||||
premade = new fo::PremadeChar[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
auto path = "premade\\" + premadePaths[i];
|
||||
strcpy_s(premade[i].path, 20, path.c_str());
|
||||
if (path.size() > 19) {
|
||||
dlogr(" Failed: name exceeds 11 characters", DL_INIT);
|
||||
return;
|
||||
}
|
||||
strcpy(premade[i].path, path.c_str());
|
||||
premade[i].fid = atoi(premadeFids[i].c_str());
|
||||
}
|
||||
|
||||
@@ -42,7 +47,8 @@ void Premade::init() {
|
||||
SafeWrite32(0x4A7D76, (DWORD)premade);
|
||||
SafeWrite32(0x4A8B1E, (DWORD)premade);
|
||||
SafeWrite32(0x4A7E2C, (DWORD)premade + 20);
|
||||
strcpy_s((char*)0x50AF68, 20, premade[0].path);
|
||||
strcpy((char*)0x50AF68, premade[0].path);
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,17 +37,17 @@ static CityRep* repList = nullptr;
|
||||
void Reputations::init() {
|
||||
auto cityRepList = GetConfigList("Misc", "CityRepsList", "", 512);
|
||||
size_t count = cityRepList.size();
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
repList = new CityRep[count];
|
||||
std::vector<std::string> pair;
|
||||
pair.reserve(2);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
pair.clear();
|
||||
split(cityRepList[i], ':', std::back_inserter(pair), 2);
|
||||
repList[i].cityID = atoi(pair[0].c_str());
|
||||
if (pair.size() >= 2) {
|
||||
repList[i].globalID = atoi(pair[1].c_str());
|
||||
}
|
||||
pair.clear();
|
||||
}
|
||||
|
||||
SafeWrite32(0x43BEA5, (DWORD)&repList[0].cityID);
|
||||
|
||||
@@ -751,7 +751,7 @@ void ScriptExtender::init() {
|
||||
}
|
||||
}
|
||||
|
||||
alwaysFindScripts = isDebug && (GetPrivateProfileIntA("Debugging", "AlwaysFindScripts", 0, ::sfall::ddrawIni) != 0);
|
||||
alwaysFindScripts = isDebug && (iniGetInt("Debugging", "AlwaysFindScripts", 0, ::sfall::ddrawIni) != 0);
|
||||
if (alwaysFindScripts) dlogr("Always searching for global scripts behavior enabled.", DL_SCRIPT);
|
||||
|
||||
MakeJump(0x4A390C, FindSidHack);
|
||||
|
||||
@@ -562,10 +562,10 @@ static DWORD GetIniSetting(const char* str, bool isString) {
|
||||
}
|
||||
if (isString) {
|
||||
IniStrBuffer[0] = 0;
|
||||
GetPrivateProfileStringA(section, key, "", IniStrBuffer, 256, file);
|
||||
iniGetString(section, key, "", IniStrBuffer, 256, file);
|
||||
return (DWORD)&IniStrBuffer[0];
|
||||
} else {
|
||||
return GetPrivateProfileIntA(section, key, -1, file);
|
||||
return iniGetInt(section, key, -1, file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ void InitNewOpcodes() {
|
||||
SafeWrite32(0x46CE6C, (DWORD)opcodes); // call that actually jumps to the opcode
|
||||
SafeWrite32(0x46E390, (DWORD)opcodes); // mov that writes to the opcode
|
||||
|
||||
if (GetPrivateProfileIntA("Debugging", "AllowUnsafeScripting", 0, ::sfall::ddrawIni)) {
|
||||
if (iniGetInt("Debugging", "AllowUnsafeScripting", 0, ::sfall::ddrawIni)) {
|
||||
dlogr(" Unsafe opcodes enabled.", DL_SCRIPT);
|
||||
opcodes[0x1cf] = op_write_byte;
|
||||
opcodes[0x1d0] = op_write_short;
|
||||
|
||||
@@ -331,17 +331,21 @@ void Skills::init() {
|
||||
// 0x00000400 - Energy Weapon (forces weapon to use Energy Weapons skill)
|
||||
HookCall(0x47831E, item_w_skill_hook);
|
||||
|
||||
LoadGameHook::OnGameReset() += Skills_OnGameLoad;
|
||||
|
||||
char buf[512], key[16];
|
||||
auto skillsFile = GetConfigString("Misc", "SkillsFile", "", MAX_PATH);
|
||||
if (!skillsFile.empty()) {
|
||||
fo::SkillInfo *skills = fo::var::skill_data;
|
||||
|
||||
const char* file = skillsFile.insert(0, ".\\").c_str();
|
||||
if (GetFileAttributes(file) == INVALID_FILE_ATTRIBUTES) return;
|
||||
|
||||
multipliers = new double[7 * fo::SKILL_count]();
|
||||
|
||||
for (int i = 0; i < fo::SKILL_count; i++) {
|
||||
sprintf(key, "Skill%d", i);
|
||||
if (GetPrivateProfileStringA("Skills", key, "", buf, 64, file)) {
|
||||
if (iniGetString("Skills", key, "", buf, 64, file)) {
|
||||
char* tok = strtok(buf, "|");
|
||||
while (tok) {
|
||||
if (strlen(tok) >= 2) {
|
||||
@@ -365,7 +369,7 @@ void Skills::init() {
|
||||
if (skills[i].statB >= 0) multipliers[i * 7 + skills[i].statB] = skills[i].statMulti;
|
||||
}
|
||||
sprintf(key, "SkillCost%d", i);
|
||||
if (GetPrivateProfileStringA("Skills", key, "", buf, 512, file)) {
|
||||
if (iniGetString("Skills", key, "", buf, 512, file)) {
|
||||
char* tok = strtok(buf, "|");
|
||||
DWORD upto = 0;
|
||||
BYTE price = 1;
|
||||
@@ -387,15 +391,15 @@ void Skills::init() {
|
||||
for (int j = 201; j <= 512; j++) skillCosts[i * 512 + j] = 6;
|
||||
}
|
||||
sprintf(key, "SkillBase%d", i);
|
||||
skills[i].base = GetPrivateProfileIntA("Skills", key, skills[i].base, file);
|
||||
skills[i].base = iniGetInt("Skills", key, skills[i].base, file);
|
||||
|
||||
sprintf(key, "SkillMulti%d", i);
|
||||
int multi = GetPrivateProfileIntA("Skills", key, skills[i].skillPointMulti, file);
|
||||
int multi = iniGetInt("Skills", key, skills[i].skillPointMulti, file);
|
||||
if (multi < 1) multi = 1; else if (multi > 10) multi = 10;
|
||||
skills[i].skillPointMulti = multi;
|
||||
|
||||
sprintf(key, "SkillImage%d", i);
|
||||
skills[i].image = GetPrivateProfileIntA("Skills", key, skills[i].image, file);
|
||||
skills[i].image = iniGetInt("Skills", key, skills[i].image, file);
|
||||
}
|
||||
|
||||
MakeJump(0x4AA59D, skill_level_hack_bonus, 1);
|
||||
@@ -403,11 +407,12 @@ void Skills::init() {
|
||||
MakeJump(0x4AA940, skill_dec_point_hack_cost, 1);
|
||||
HookCalls(skill_dec_point_hook_cost, {0x4AA9E1, 0x4AA9F1});
|
||||
|
||||
basedOnPoints = GetPrivateProfileIntA("Skills", "BasedOnPoints", 0, file);
|
||||
basedOnPoints = iniGetInt("Skills", "BasedOnPoints", 0, file);
|
||||
if (basedOnPoints) HookCall(0x4AA9EC, (void*)fo::funcoffs::skill_points_); // skill_dec_point_
|
||||
}
|
||||
|
||||
LoadGameHook::OnGameReset() += Skills_OnGameLoad;
|
||||
}
|
||||
|
||||
void Skills::exit() {
|
||||
delete[] multipliers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class Skills : public Module {
|
||||
public:
|
||||
const char* name() { return "Skills"; }
|
||||
void init();
|
||||
void exit() override;
|
||||
};
|
||||
|
||||
void _stdcall SetSkillMax(fo::GameObject* critter, int maximum);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user