mirror of
https://github.com/fallout2-ce/fallout2-ce.git
synced 2026-07-27 16:47:11 -07:00
mapper: fix TMP map files not being deleted, fix edg not loading when changing maps in play mode
This commit is contained in:
+1
-4
@@ -969,11 +969,8 @@ static int mapLoad(File* stream)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (settings.system.executableIsMapper()) {
|
||||
if (settings.system.executableIsMapper() || settings.ui.edg_support) {
|
||||
mapEdgeLoad(gMapHeader.name);
|
||||
} else if (settings.ui.edg_support && !settings.ui.ignore_map_edges) {
|
||||
mapEdgeLoad(gMapHeader.name);
|
||||
mapEdgeSetEnabled(true);
|
||||
}
|
||||
|
||||
error = "Error setting tile center";
|
||||
|
||||
+11
-7
@@ -6,6 +6,7 @@
|
||||
#include "map.h"
|
||||
#include "map_defs.h"
|
||||
#include "platform_compat.h"
|
||||
#include "settings.h"
|
||||
#include "svga.h"
|
||||
#include "tile.h"
|
||||
#include "window_manager.h"
|
||||
@@ -20,8 +21,7 @@ constexpr int kTileHeight = 24;
|
||||
|
||||
static EdgeElevationData edgeData[ELEVATION_COUNT];
|
||||
static bool edgeDataLoaded = false;
|
||||
// Whether edges constrain scrolling/clipping. Enabled in play mode, disabled in the mapper.
|
||||
static bool edgeEnabled = false;
|
||||
static bool mapperMode = false;
|
||||
static bool edgeVersion2 = false;
|
||||
static EdgeZone* currentEdgeZone = nullptr;
|
||||
|
||||
@@ -373,7 +373,6 @@ void mapEdgeFree()
|
||||
data = EdgeElevationData {};
|
||||
}
|
||||
edgeDataLoaded = false;
|
||||
edgeEnabled = false;
|
||||
currentEdgeZone = nullptr;
|
||||
currentTileXAlignment = 0;
|
||||
currentTileYAlignment = 0;
|
||||
@@ -387,15 +386,20 @@ bool mapEdgeIsLoaded()
|
||||
return edgeDataLoaded;
|
||||
}
|
||||
|
||||
void mapEdgeSetEnabled(bool enabled)
|
||||
void mapEdgeSetMapperMode(bool enabled)
|
||||
{
|
||||
edgeEnabled = enabled;
|
||||
mapperMode = enabled;
|
||||
}
|
||||
|
||||
bool mapEdgeIsMapperMode()
|
||||
{
|
||||
return mapperMode;
|
||||
}
|
||||
|
||||
bool mapEdgeIsEnabled()
|
||||
{
|
||||
// Edges can only be enabled when data is actually loaded.
|
||||
return edgeDataLoaded && edgeEnabled;
|
||||
// Enforced when data is loaded, we're not editing in the mapper, and the user enabled it.
|
||||
return edgeDataLoaded && !mapperMode && settings.ui.edg_support && !settings.ui.ignore_map_edges;
|
||||
}
|
||||
|
||||
void mapEdgeUpgradeToVersion2()
|
||||
|
||||
+7
-2
@@ -60,8 +60,13 @@ void mapEdgeFree();
|
||||
// Returns true if EDG data was successfully loaded for the current map.
|
||||
bool mapEdgeIsLoaded();
|
||||
|
||||
// Enables/disables edge constraints (scroll blocking, view clipping). Independent of loading.
|
||||
void mapEdgeSetEnabled(bool enabled);
|
||||
// Mapper-editing mode: when enabled, loaded EDG data is not enforced so edges can be edited.
|
||||
// The game leaves this off; the mapper turns it off only while play-testing.
|
||||
void mapEdgeSetMapperMode(bool enabled);
|
||||
bool mapEdgeIsMapperMode();
|
||||
|
||||
// True when edge constraints are actively enforced: data loaded, not in mapper-editing mode,
|
||||
// and enabled by user settings (edg_support on, ignore_map_edges off).
|
||||
bool mapEdgeIsEnabled();
|
||||
|
||||
// Marks edge data as version 2 so squareRect/clipSides are written on save.
|
||||
|
||||
@@ -412,10 +412,10 @@ static void drawSquareOverlay(unsigned char* buffer, int pitch, int elevation, c
|
||||
|
||||
// Registered as the tile renderer's overlay hook. While a dialog is open, only the active
|
||||
// rect is drawn (plus the moving side highlighted). Otherwise the persistent toggle outlines
|
||||
// every edge rect. Never drawn in play mode (edges enabled).
|
||||
// every edge rect. Never drawn in play mode.
|
||||
static void renderOverlay(unsigned char* buffer, int pitch, int elevation, const Rect* clip)
|
||||
{
|
||||
if (mapEdgeIsEnabled()) {
|
||||
if (!mapEdgeIsMapperMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+13
-10
@@ -1012,6 +1012,7 @@ int mapper_edit_init(int argc, char** argv)
|
||||
mouseShowCursor();
|
||||
mapperValidateDevPath();
|
||||
mapEdgeSetupInit();
|
||||
mapEdgeSetMapperMode(true);
|
||||
|
||||
if (settings.mapper.rebuild_protos) {
|
||||
proto_build_all_texts();
|
||||
@@ -1024,10 +1025,7 @@ int mapper_edit_init(int argc, char** argv)
|
||||
// 0x48752C
|
||||
void mapper_edit_exit()
|
||||
{
|
||||
remove(mapBuildPath("TMP$MAP#.MAP"));
|
||||
remove(mapBuildPath("TMP$MAP#.CFG"));
|
||||
|
||||
MapDirErase("MAPS\\", "SAV");
|
||||
mapper_remove_tmp_map_files();
|
||||
|
||||
if (can_modify_protos) {
|
||||
copy_proto_lists();
|
||||
@@ -2715,8 +2713,12 @@ int mapper_mark_exit_grid()
|
||||
// and on editor shutdown if the user quit while still in play mode.
|
||||
static void mapper_remove_tmp_map_files()
|
||||
{
|
||||
remove(mapBuildPath(tmp_map_name));
|
||||
remove(mapBuildPath("TMP$MAP#.CFG"));
|
||||
remove(mapBuildSavePath(kTmpMapName));
|
||||
remove(mapBuildSavePath("TMP$MAP#.EDG"));
|
||||
|
||||
char cfgPath[COMPAT_MAX_PATH];
|
||||
snprintf(cfgPath, sizeof(cfgPath), "%s\\MAPS\\TMP$MAP#.CFG", settings.system.master_patches_path.c_str());
|
||||
remove(cfgPath);
|
||||
MapDirErase("MAPS\\", "SAV");
|
||||
}
|
||||
|
||||
@@ -2782,10 +2784,8 @@ static void mapper_enter_play_mode(Object** pHlObj1)
|
||||
tileScrollBlockingEnable();
|
||||
tileScrollLimitingEnable();
|
||||
|
||||
// Edges are loaded but disabled while editing; enable them to mirror play behavior.
|
||||
if (settings.ui.edg_support && !settings.ui.ignore_map_edges) {
|
||||
mapEdgeSetEnabled(true);
|
||||
}
|
||||
// Leave mapper-editing mode so loaded edges behave as in the game (subject to settings).
|
||||
mapEdgeSetMapperMode(false);
|
||||
|
||||
if (settings.mapper.run_mapper_as_game) {
|
||||
scriptExecProc(gMapSid, SCRIPT_PROC_MAP_ENTER);
|
||||
@@ -2850,6 +2850,9 @@ static void mapper_exit_play_mode(int* pCurrentType, int* pScrollOffset, Object*
|
||||
tileScrollBlockingDisable();
|
||||
tileScrollLimitingDisable();
|
||||
|
||||
// Back to editing: loaded edges are kept but no longer enforced.
|
||||
mapEdgeSetMapperMode(true);
|
||||
|
||||
// Match the original: if click-to-scroll was on during play, force it off on exit.
|
||||
if (_gmouse_get_click_to_scroll()) {
|
||||
_gmouse_set_click_to_scroll(false);
|
||||
|
||||
+1
-1
@@ -558,7 +558,7 @@ int tileSetCenter(int tile, int flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
const bool edgeActive = mapEdgeIsEnabled() && !settings.ui.ignore_map_edges;
|
||||
const bool edgeActive = mapEdgeIsEnabled();
|
||||
const bool isScroll = flags == 0;
|
||||
|
||||
if (edgeActive && !isScroll) {
|
||||
|
||||
Reference in New Issue
Block a user