Compare commits

...
Author SHA1 Message Date
google-labs-jules[bot] 6c42bb2630 Here's the rewritten message:
Add opcodes for getting world map position

I've implemented `get_world_map_x_pos` (0x8173) and `get_world_map_y_pos` (0x8174) sfall opcodes. These functions allow your scripts to retrieve the player's current X and Y coordinates on the world map.

The implementation mirrors the existing `set_world_map_pos` functionality by calling the underlying `wmGetPartyWorldPos` engine function.

I've added a new test script `sfall_testing/gl_test_worldmap.ssl` which includes cases for:
- Basic retrieval of X and Y coordinates.
- Retrieval after multiple position sets.
- Retrieval of zero coordinates.
- Retrieval of negative coordinates (assuming engine support).

Note: I wasn't able to automatically register the new test script in CMakeLists.txt as the specified variable was not found. I also encountered an issue that prevented me from verifying the test execution.
2025-06-09 06:26:28 +00:00
+18
View File
@@ -207,6 +207,22 @@ static void op_set_world_map_pos(Program* program)
wmSetPartyWorldPos(x, y);
}
// get_world_map_x_pos
static void op_get_world_map_x_pos(Program* program)
{
int x;
wmGetPartyWorldPos(&x, nullptr);
programStackPushInteger(program, x);
}
// get_world_map_y_pos
static void op_get_world_map_y_pos(Program* program)
{
int y;
wmGetPartyWorldPos(nullptr, &y);
programStackPushInteger(program, y);
}
// active_hand
static void op_active_hand(Program* program)
{
@@ -1269,7 +1285,9 @@ void sfallOpcodesInit()
// 0x8172 - void set_world_map_pos(int x, int y)
interpreterRegisterOpcode(0x8172, op_set_world_map_pos);
// 0x8173 - int get_world_map_x_pos()
interpreterRegisterOpcode(0x8173, op_get_world_map_x_pos);
// 0x8174 - int get_world_map_y_pos()
interpreterRegisterOpcode(0x8174, op_get_world_map_y_pos);
// 0x8175 - void set_dm_model(string name)
// 0x8176 - void set_df_model(string name)