Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ add_custom_command(OUTPUT ${PORT_OVERRIDES}
# of ps2/src: it declares what the port defines in place of code PORT leaves
# out, and supplies or renames what the unit takes from MWCC alone.
foreach(unit IN LISTS PS2_SOURCES)
set(private_overrides "")
if(unit STREQUAL "editloop3.cpp")
set(private_overrides --private-variables --private-functions)
endif()
set(copy ${CMAKE_BINARY_DIR}/ps2_src/${unit})
string(REGEX REPLACE "\\.cpp$" ".hpp" header ${CMAKE_SOURCE_DIR}/port/include/stubs/${unit})
if(EXISTS ${header})
Expand All @@ -81,7 +85,7 @@ foreach(unit IN LISTS PS2_SOURCES)
endif()
add_custom_command(OUTPUT ${copy}
COMMAND ${Python3_EXECUTABLE} ${PORT_OVERRIDE_SCRIPT} strip --overrides ${PORT_OVERRIDES} ${stubs}
${port_override_defines} ${PS2_DIR}/${unit} ${copy}
${private_overrides} ${port_override_defines} ${PS2_DIR}/${unit} ${copy}
DEPENDS ${PS2_DIR}/${unit} ${PORT_OVERRIDES} ${PORT_OVERRIDE_SOURCES} ${PORT_OVERRIDE_SCRIPT} ${header}
COMMENT "Removing overridden definitions from ps2/src/${unit}"
VERBATIM)
Expand All @@ -97,6 +101,7 @@ endforeach()
set(PORT_OVERRIDES_CHECKED ${CMAKE_BINARY_DIR}/port_overrides.checked)
add_custom_command(OUTPUT ${PORT_OVERRIDES_CHECKED}
COMMAND ${Python3_EXECUTABLE} ${PORT_OVERRIDE_SCRIPT} check --overrides ${PORT_OVERRIDES}
--private-variables --private-functions --private-function-unit editloop3.cpp
--stubs ${CMAKE_SOURCE_DIR}/port/include/stubs ${port_override_defines} ${PS2_DIR}
-o ${PORT_OVERRIDES_CHECKED}
DEPENDS ${PS2_ORIGINALS} ${PORT_OVERRIDES} ${PORT_OVERRIDE_SOURCES} ${PORT_OVERRIDE_SCRIPT}
Expand Down
3 changes: 3 additions & 0 deletions port/include/stubs/edit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define EdMenuMode PortOriginalEdMenuMode
3 changes: 3 additions & 0 deletions port/include/stubs/editloop3.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#define menu_mode PortEventMenuMode
#define _WORLD_MAP PortWorldMapCommand

// The port's EdMoveVillager and EdMoveVillagerSubMap (port/src/editloop3.cpp) call this unit's
// static EdSetVillagerNextPos, which gets a global forwarder; that also keeps clang from dropping
// the static as unused.
Expand Down
46 changes: 46 additions & 0 deletions port/src/world_map_result.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "common.h"

#include <libvu0.h>

#include "battlemenu.hpp"
#include "edit.hpp"
#include "runscript.hpp"

/**
* Runs the original town menu handler.
*/
int PortOriginalEdMenuMode();

/** The menu requested by the current town event. */
PORT_OVERRIDE int PortEventMenuMode = ED_MENU_NONE;

namespace {

/** The world-map command's native-width script result destination. */
RS_STACKDATA *world_map_result = nullptr;

} // namespace

/**
* Opens the world map while retaining the script result pointer at native width.
*/
PORT_OVERRIDE int PortWorldMapCommand(RS_STACKDATA *stack, int argument_count) {
if (stack->type != RS_PTR) {
return 0;
}
world_map_result = stack->p;
PortEventMenuMode = ED_MENU_WORLD_MAP;
return 1;
}

/**
* Publishes the world-map choice when its menu finishes.
*/
int EdMenuMode() {
const int done = PortOriginalEdMenuMode();
if (done && PortEventMenuMode == ED_MENU_WORLD_MAP && world_map_result != nullptr) {
world_map_result->i = MenuMapJumpMode + 1;
world_map_result = nullptr;
}
return done;
}
Loading