From a1968f7f86b810be0684888f71d4d4c95ebe2d3a Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 24 Dec 2019 20:58:03 +0800 Subject: [PATCH] Minor edits to the built-in item highlighting function Removed the redundant struct define in Tiles.cpp. Added a comment to ScriptUtils.hpp. --- artifacts/ddraw.ini | 16 ++++++++-------- sfall/FalloutEngine.cpp | 2 +- sfall/FalloutEngine.h | 2 +- sfall/FalloutStructs.h | 9 ++++++++- sfall/ScriptExtender.cpp | 8 ++++---- sfall/ScriptOps/ScriptUtils.hpp | 2 +- sfall/Tiles.cpp | 22 +++------------------- 7 files changed, 26 insertions(+), 35 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index def3fac8..2a19246e 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -157,14 +157,14 @@ HighlightContainers=1 HighlightCorpses=1 ;Set the color of outlines, available colors: -;0x01 - glowing red -;0x02 - red -;0x04 - grey -;0x08 - glowing green -;0x10 - bright yellow -;0x20 - dark yellow -;0x40 - purple -OutlineColor=0x10 +;1 - glowing red +;2 - red +;4 - grey +;8 - glowing green +;16 - bright yellow +;32 - dark yellow +;64 - purple +OutlineColor=16 ;A key to press to reload your currently equipped weapon ;Set to 0 if you don't want a reload key, or a DX scancode otherwise diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index ed6199d1..91c70cfc 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -27,7 +27,7 @@ long* ptr_pc_traits = reinterpret_cast(_pc_trait); // 2 DWORD* ptr_aiInfoList = reinterpret_cast(_aiInfoList); DWORD* ptr_ambient_light = reinterpret_cast(_ambient_light); -Art* ptr_art = reinterpret_cast(_art); +sArt* ptr_art = reinterpret_cast(_art); DWORD* ptr_art_name = reinterpret_cast(_art_name); DWORD* ptr_art_vault_guy_num = reinterpret_cast(_art_vault_guy_num); DWORD* ptr_art_vault_person_nums = reinterpret_cast(_art_vault_person_nums); diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index 33271dc8..965f491a 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -282,7 +282,7 @@ extern long* ptr_pc_traits; // 2 of them extern DWORD* ptr_aiInfoList; extern DWORD* ptr_ambient_light; -extern Art* ptr_art; +extern sArt* ptr_art; extern DWORD* ptr_art_name; extern DWORD* ptr_art_vault_guy_num; extern DWORD* ptr_art_vault_person_nums; diff --git a/sfall/FalloutStructs.h b/sfall/FalloutStructs.h index 8738ad23..53a4c46d 100644 --- a/sfall/FalloutStructs.h +++ b/sfall/FalloutStructs.h @@ -171,7 +171,7 @@ struct TProgram { #pragma pack(pop) #pragma pack(push, 1) -struct Art { +struct sArt { long flags; char path[16]; char* names; @@ -190,6 +190,13 @@ struct BoundRect { }; #pragma pack(pop) +#pragma pack(push, 1) +struct DbFile { + long fileType; + void* handle; +}; +#pragma pack(pop) + #pragma pack(push, 1) struct FrmFile { long id; //0x00 diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index 2c574b92..2c8e343c 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -1182,7 +1182,7 @@ static void __declspec(naked) CombatOverHook() { static void __declspec(naked) obj_outline_all_items_on() { __asm { - pushad; + pushadc; mov eax, ds:[_map_elevation]; call obj_find_first_at_; loopObject: @@ -1224,14 +1224,14 @@ nextObject: jmp loopObject; end: call tile_refresh_display_; - popad; + popadc; retn; } } static void __declspec(naked) obj_outline_all_items_off() { __asm { - pushad; + pushadc; mov eax, ds:[_map_elevation]; call obj_find_first_at_; loopObject: @@ -1258,7 +1258,7 @@ nextObject: jmp loopObject; end: call tile_refresh_display_; - popad; + popadc; retn; } } diff --git a/sfall/ScriptOps/ScriptUtils.hpp b/sfall/ScriptOps/ScriptUtils.hpp index d5fc835a..f402a33b 100644 --- a/sfall/ScriptOps/ScriptUtils.hpp +++ b/sfall/ScriptOps/ScriptUtils.hpp @@ -54,7 +54,7 @@ static bool _stdcall FalloutStringCompare(const char* str1, const char* str2, lo // 128 - 255 (international/extended) switch (codePage) { case 866: - if (c1 != 149 && c2 != 149) { + if (c1 != 149 && c2 != 149) { // code used for the 'bullet' character in Fallout font // upper to lower case if (c1 >= 0x80 && c1 <= 0x9F) { c1 |= 32; diff --git a/sfall/Tiles.cpp b/sfall/Tiles.cpp index aa8f2d68..5edda246 100644 --- a/sfall/Tiles.cpp +++ b/sfall/Tiles.cpp @@ -48,22 +48,6 @@ static const DWORD Tiles_C0[] = { 0x4B247B, 0x4B2A77, 0x4B2BD5, }; -struct sArt { - long flags; - char path[16]; - char* names; - long d18; - long total; - - sArt(char* str) { - flags = 0; - strncpy_s(path, str, 16); - names = 0; - d18 = 0; - total = 0; - } -}; - struct TilesData { short tile[2]; }; @@ -204,7 +188,7 @@ static int ProcessTile(sArt* tiles, int tile, int listpos) { for (int x = 0; x < xsize; x++) { FrmFile frame; db_fseek(art, 0); - db_freadByteCount(art, &frame, 0x4a); + db_freadByteCount(art, (BYTE*)&frame, 0x4a); frame.height = ByteSwapW(36); frame.width = ByteSwapW(80); frame.frameSize = ByteSwapD(80 * 36); @@ -224,7 +208,7 @@ static int ProcessTile(sArt* tiles, int tile, int listpos) { sprintf_s(buf, 32, "art\\tiles\\zzz%04d.frm", listid++); //FScreateFromData(buf, &frame, sizeof(frame)); DWORD file = db_fopen(buf, "w"); - db_fwriteByteCount(file, &frame, sizeof(frame)); + db_fwriteByteCount(file, (BYTE*)&frame, sizeof(frame)); db_fclose(file); } } @@ -239,7 +223,7 @@ static int _stdcall ArtInitHook() { CreateMask(); - sArt* tiles = &((sArt*)_art)[4]; + sArt* tiles = &ptr_art[4]; char buf[32]; DWORD listpos = tiles->total; origTileCount = listpos;