Merge cheats in console, pathfinding improvements

This commit is contained in:
Michael Steenbeek 2016-11-14 08:54:51 +01:00 committed by GitHub
commit ba1225cf6e
6 changed files with 95 additions and 23 deletions

View File

@ -392,9 +392,9 @@ void game_command_cheat(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* e
int cheat = *ecx;
if (*ebx & GAME_COMMAND_FLAG_APPLY) {
switch (cheat) {
case CHEAT_SANDBOXMODE: gCheatsSandboxMode = !gCheatsSandboxMode; window_invalidate_by_class(WC_MAP); window_invalidate_by_class(WC_FOOTPATH); break;
case CHEAT_DISABLECLEARANCECHECKS: gCheatsDisableClearanceChecks = !gCheatsDisableClearanceChecks; break;
case CHEAT_DISABLESUPPORTLIMITS: gCheatsDisableSupportLimits = !gCheatsDisableSupportLimits; break;
case CHEAT_SANDBOXMODE: gCheatsSandboxMode = *edx != 0; window_invalidate_by_class(WC_MAP); window_invalidate_by_class(WC_FOOTPATH); break;
case CHEAT_DISABLECLEARANCECHECKS: gCheatsDisableClearanceChecks = *edx != 0; break;
case CHEAT_DISABLESUPPORTLIMITS: gCheatsDisableSupportLimits = *edx != 0; break;
case CHEAT_SHOWALLOPERATINGMODES: gCheatsShowAllOperatingModes = !gCheatsShowAllOperatingModes; break;
case CHEAT_SHOWVEHICLESFROMOTHERTRACKTYPES: gCheatsShowVehiclesFromOtherTrackTypes = !gCheatsShowVehiclesFromOtherTrackTypes; break;
case CHEAT_FASTLIFTHILL: gCheatsFastLiftHill = !gCheatsFastLiftHill; break;

View File

@ -27,6 +27,7 @@
#include "../game.h"
#include "../input.h"
#include "../network/twitch.h"
#include "../network/network.h"
#include "../object.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
@ -665,6 +666,15 @@ static int cc_get(const utf8 **argv, int argc)
else if (strcmp(argv[0], "render_weather_gloom") == 0) {
console_printf("render_weather_gloom %d", gConfigGeneral.render_weather_gloom);
}
else if (strcmp(argv[0], "cheat_sandbox_mode") == 0) {
console_printf("cheat_sandbox_mode %d", gCheatsSandboxMode);
}
else if (strcmp(argv[0], "cheat_disable_clearance_checks") == 0) {
console_printf("cheat_disable_clearance_checks %d", gCheatsDisableClearanceChecks);
}
else if (strcmp(argv[0], "cheat_disable_support_limits") == 0) {
console_printf("cheat_disable_support_limits %d", gCheatsDisableSupportLimits);
}
else {
console_writeline_warning("Invalid variable.");
}
@ -847,6 +857,45 @@ static int cc_set(const utf8 **argv, int argc)
config_save_default();
console_execute_silent("get render_weather_gloom");
}
else if (strcmp(argv[0], "cheat_sandbox_mode") == 0 && invalidArguments(&invalidArgs, int_valid[0])) {
if (gCheatsSandboxMode != (int_val[0] != 0)) {
if (game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SANDBOXMODE, (int_val[0] != 0), GAME_COMMAND_CHEAT, 0, 0) != MONEY32_UNDEFINED) {
//Change it locally so it shows the accurate value in the
//"console_execute_silent("get cheat_sandbox_mode")" line when in network client mode
gCheatsSandboxMode = (int_val[0] != 0);
}
else {
console_writeline_error("Network error: Permission denied!");
}
}
console_execute_silent("get cheat_sandbox_mode");
}
else if (strcmp(argv[0], "cheat_disable_clearance_checks") == 0 && invalidArguments(&invalidArgs, int_valid[0])) {
if (gCheatsDisableClearanceChecks != (int_val[0] != 0)) {
if (game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLECLEARANCECHECKS, (int_val[0] != 0), GAME_COMMAND_CHEAT, 0, 0) != MONEY32_UNDEFINED) {
//Change it locally so it shows the accurate value in the
//"console_execute_silent("get cheat_disable_clearance_checks")" line when in network client mode
gCheatsDisableClearanceChecks = (int_val[0] != 0);
}
else {
console_writeline_error("Network error: Permission denied!");
}
}
console_execute_silent("get cheat_disable_clearance_checks");
}
else if (strcmp(argv[0], "cheat_disable_support_limits") == 0 && invalidArguments(&invalidArgs, int_valid[0])) {
if (gCheatsDisableSupportLimits != (int_val[0] != 0)) {
if (game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLESUPPORTLIMITS, (int_val[0] != 0), GAME_COMMAND_CHEAT, 0, 0) != MONEY32_UNDEFINED) {
//Change it locally so it shows the accurate value in the
//"console_execute_silent("get cheat_disable_support_limits")" line when in network client mode
gCheatsDisableSupportLimits = (int_val[0] != 0);
}
else {
console_writeline_error("Network error: Permission denied!");
}
}
console_execute_silent("get cheat_disable_support_limits");
}
else if (invalidArgs) {
console_writeline_error("Invalid arguments.");
}
@ -1033,6 +1082,9 @@ utf8* console_variable_table[] = {
"window_limit",
"render_weather_effects",
"render_weather_gloom",
"cheat_sandbox_mode",
"cheat_disable_clearance_checks",
"cheat_disable_support_limits",
};
utf8* console_window_table[] = {
"object_selection",

View File

@ -55,7 +55,7 @@ extern "C" {
// This define specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "17"
#define NETWORK_STREAM_VERSION "18"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
#ifdef __cplusplus

View File

@ -8974,7 +8974,7 @@ static bool path_is_thin_junction(rct_map_element *path, sint16 x, sint16 y, uin
*
* rct2: 0x0069A997
*/
static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_map_element *currentMapElement, uint8 counter, uint16 *endScore, int test_edge, uint8 *endJunctions, rct_xyz8 junctionList[16], uint8 directionList[16], rct_xyz8 *endXYZ, uint8 *endSteps) {
static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep *peep, rct_map_element *currentMapElement, uint8 counter, uint16 *endScore, int test_edge, uint8 *endJunctions, rct_xyz8 junctionList[16], uint8 directionList[16], rct_xyz8 *endXYZ, uint8 *endSteps) {
uint8 searchResult = PATH_SEARCH_FAILED;
x += TileDirectionDelta[test_edge].x;
@ -9280,21 +9280,41 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_map_
* junction on this map element. Only 'thin' junctions
* are counted towards the junction search limit. */
/* Check the pathfind_history to see if this junction has been
* previously passed through in the current search path.
* i.e. this is a loop in the current search path.
* If so, the current search path ends here.
* Continue to the next map element without updating the parameters (best result so far). */
/* First check if going through the junction would be
* a loop. If so, the current search path ends here.
* Path finding loop detection can take advantage of both the
* peep->pathfind_history - loops through remembered junctions
* the peep has already passed through getting to its
* current position while on the way to its current goal;
* _peepPathFindHistory - loops in the current search path. */
bool pathLoop = false;
for (int junctionNum = _peepPathFindNumJunctions + 1; junctionNum <= _peepPathFindMaxJunctions; junctionNum++) {
if ((_peepPathFindHistory[junctionNum].location.x == (uint8)(x >> 5)) &&
(_peepPathFindHistory[junctionNum].location.y == (uint8)(y >> 5)) &&
(_peepPathFindHistory[junctionNum].location.z == (uint8)z)) {
pathLoop = true;
break;
/* Check the peep->pathfind_history to see if this junction has
* already been visited by the peep while heading for this goal. */
for (int i = 0; i < 4; ++i) {
if (peep->pathfind_history[i].x == x >> 5 &&
peep->pathfind_history[i].y == y >> 5 &&
peep->pathfind_history[i].z == z) {
pathLoop = true;
break;
}
}
if (!pathLoop) {
/* Check the _peepPathFindHistory to see if this junction has been
* previously passed through in the current search path.
* i.e. this is a loop in the current search path. */
for (int junctionNum = _peepPathFindNumJunctions + 1; junctionNum <= _peepPathFindMaxJunctions; junctionNum++) {
if ((_peepPathFindHistory[junctionNum].location.x == (uint8)(x >> 5)) &&
(_peepPathFindHistory[junctionNum].location.y == (uint8)(y >> 5)) &&
(_peepPathFindHistory[junctionNum].location.z == (uint8)z)) {
pathLoop = true;
break;
}
}
}
if (pathLoop) {
/* Loop detected. The current search path ends here.
* Continue to the next map element without updating the parameters (best result so far). */
#if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2
if (gPathFindDebug) {
log_info("[%03d] Search path ends at %d,%d,%d; Loop", counter, x >> 5, y >> 5, z);
@ -9376,7 +9396,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_map_
_peepPathFindHistory[_peepPathFindNumJunctions + 1].direction = test_edge;
}
peep_pathfind_heuristic_search(x, y, height, mapElement, counter, endScore, test_edge, endJunctions, junctionList, directionList, endXYZ, endSteps);
peep_pathfind_heuristic_search(x, y, height, peep, mapElement, counter, endScore, test_edge, endJunctions, junctionList, directionList, endXYZ, endSteps);
_peepPathFindNumJunctions = savedNumJunctions;
#if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2
@ -9480,7 +9500,7 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep)
edges = peep->pathfind_history[i].direction & 0xF;
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
if (gPathFindDebug) {
log_verbose("Getting untried edges from pf_history for %d,%d,%d: %d", x >> 5, y >> 5, z, edges);
log_verbose("Getting untried edges from pf_history for %d,%d,%d: %s,%s,%s,%s", x >> 5, y >> 5, z, (edges & 1) ? "0" : "-", (edges & 2) ? "1" : "-", (edges & 4) ? "2" : "-", (edges & 8) ? "3" : "-");
}
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
break;
@ -9566,7 +9586,7 @@ int peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep *peep)
rct_xyz8 endJunctionList[16] = { 0 };
uint8 endDirectionList[16] = { 0 };
peep_pathfind_heuristic_search(x, y, height, dest_map_element, 0, &score, test_edge, &endJunctions, endJunctionList, endDirectionList, &endXYZ, &endSteps);
peep_pathfind_heuristic_search(x, y, height, peep, dest_map_element, 0, &score, test_edge, &endJunctions, endJunctionList, endDirectionList, &endXYZ, &endSteps);
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
if (gPathFindDebug) {
log_verbose("Pathfind test edge: %d score: %d steps: %d end: %d,%d,%d junctions: %d", test_edge, score, endSteps, endXYZ.x, endXYZ.y, endXYZ.z, endJunctions);

View File

@ -662,7 +662,7 @@ static void window_cheats_misc_mouseup(rct_window *w, int widgetIndex)
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_UNLOCKALLPRICES, 0, GAME_COMMAND_CHEAT, 0, 0);
break;
case WIDX_SANDBOX_MODE:
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SANDBOXMODE, 0, GAME_COMMAND_CHEAT, 0, 0);
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SANDBOXMODE, !gCheatsSandboxMode, GAME_COMMAND_CHEAT, 0, 0);
// To prevent tools from staying active after disabling cheat
//tool_cancel();
break;

View File

@ -583,13 +583,13 @@ static void window_top_toolbar_dropdown(rct_window *w, int widgetIndex, int drop
window_cheats_open();
break;
case DDIDX_ENABLE_SANDBOX_MODE:
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SANDBOXMODE, 0, GAME_COMMAND_CHEAT, 0, 0);
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SANDBOXMODE, !gCheatsSandboxMode, GAME_COMMAND_CHEAT, 0, 0);
break;
case DDIDX_DISABLE_CLEARANCE_CHECKS:
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLECLEARANCECHECKS, 0, GAME_COMMAND_CHEAT, 0, 0);
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLECLEARANCECHECKS, !gCheatsDisableClearanceChecks, GAME_COMMAND_CHEAT, 0, 0);
break;
case DDIDX_DISABLE_SUPPORT_LIMITS:
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLESUPPORTLIMITS, 0, GAME_COMMAND_CHEAT, 0, 0);
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLESUPPORTLIMITS, !gCheatsDisableSupportLimits, GAME_COMMAND_CHEAT, 0, 0);
break;
}
break;