Corrected the position of entrances on town maps for WorldMapInterface.

This commit is contained in:
NovaRain
2019-06-19 10:56:14 +08:00
parent e790178e66
commit 1020851bcd
2 changed files with 52 additions and 6 deletions
+4 -2
View File
@@ -197,8 +197,10 @@ WorldMapEncounterRate=5
WorldMapSlots=0
;Set to 1 to use the expanded world map interface
;Set to 2 to skip correcting the position of entrance markers on town maps
;You can use resized FRMs in 700x682 for town maps in the expanded world map interface
;Requires High Resolution Patch v4.1.8 and a new worldmap.frm file in art\intrface\ (included in sfall.dat)
;The fullscreen resolution of hi-res patch must be set to at least 890x720
;The resolution of hi-res patch must be set to at least 890x720
WorldMapInterface=0
;To start a new game somewhere other than artemple.map, uncomment the next line and set it to the map you want to load
@@ -390,7 +392,7 @@ AIBestWeaponFix=0
;Set to 1 to fix NPCs not taking chem_primary_desire in AI.txt as drug use preference when using drugs in their inventory
AIDrugUsePerfFix=0
;Allows the use of tiles over 80*36 in size. sfall will just split and resave them at startup
;Allows the use of tiles over 80x36 in size. sfall will just split and resave them at startup
;Set to 1 to check all tiles on started (slow)
;Set to 2 if you provide a XLtiles.lst file in art\tiles\ containing a list of the tile ids that need checking
AllowLargeTiles=0
+48 -4
View File
@@ -664,6 +664,7 @@ long __fastcall Worldmap::GetRestMapLevel(long elev, int mapId) {
#define WMAP_TOWN_BUTTONS (15)
static DWORD wmTownMapSubButtonIds[WMAP_TOWN_BUTTONS + 1]; // replace _wmTownMapSubButtonIds (index 0 - unused element)
static int worldmapInterface;
// Window width
static const DWORD wmWinWidth[] = {
@@ -780,6 +781,46 @@ scale:
}
}
static void __declspec(naked) wmTownMapRefresh_hook_textpos() {
__asm {
push eax;
push ebx;
mov eax, ecx; // xpos
shr ebx, 2; // text_width / 4
test ebx, ebx;
jz skipX;
sub ebx, 5; // x adjust
skipX:
sar eax, 1;
add ecx, eax; // xpos * 1.5
add ecx, ebx;
pop ebx;
mov eax, dword ptr [esp + 8]; // ypos
sar eax, 1;
test eax, eax;
jz skipY;
sub eax, 5; // y adjust
skipY:
add dword ptr [esp + 8], eax; // ypos * 1.5
pop eax;
jmp fo::funcoffs::win_print_;
}
}
static void __declspec(naked) wmTownMapInit_hook() {
__asm {
push eax;
mov eax, edx; // xpos
shr eax, 1;
add edx, eax; // xpos * 1.5
mov eax, ebx; // ypos
shr eax, 1;
add ebx, eax; // ypos * 1.5
pop eax;
jmp fo::funcoffs::win_register_button_;
}
}
void WorldmapViewportPatch() {
if (Graphics::GetGameHeightRes() < WMAP_WIN_HEIGHT || Graphics::GetGameWidthRes() < WMAP_WIN_WIDTH) return;
if (!fo::func::db_access("art\\intrface\\worldmap.frm")) return;
@@ -808,8 +849,12 @@ void WorldmapViewportPatch() {
MakeCall(0x4C4452, wmDrawCursorStopped_hack1);
MakeCalls(wmDrawCursorStopped_hack0, {0x4C43BB, 0x4C42E1});
MakeCall(0x4C5325, wmRefreshTabs_hook);
HookCall(0x4C4BFF, wmTownMapRefresh_hook);
HookCall(0x4C4BFF, wmTownMapRefresh_hook);
if (worldmapInterface == 1) {
HookCall(0x4C4CD5, wmTownMapRefresh_hook_textpos);
HookCall(0x4C4B8F, wmTownMapInit_hook);
}
// up/down buttons of the location list (wmInterfaceInit_)
SafeWriteBatch<DWORD>(WMAP_WIN_WIDTH - (640 - 480), { // offset by X (480)
0x4C2D3C,
@@ -900,9 +945,8 @@ void Worldmap::init() {
WorldMapInterfacePatch();
PipBoyAutomapsPatch();
if (*(DWORD*)0x4E4480 != 0x278805C7 // check if HRP is enabled
&& GetConfigInt("Misc", "WorldMapInterface", 0))
{
worldmapInterface = GetConfigInt("Misc", "WorldMapInterface", 0);
if (worldmapInterface && *(DWORD*)0x4E4480 != 0x278805C7) { // check if HRP is enabled
LoadGameHook::OnAfterGameInit() += WorldmapViewportPatch; // Note: must be applied after WorldMapSlots patch
}
LoadGameHook::OnGameReset() += []() {