Using ghost helper funcitons for getting and setting the bit now.

This commit is contained in:
Hielke Morsink 2015-12-04 21:09:49 +01:00
parent b82504c5e4
commit 6f0d14b65f
6 changed files with 38 additions and 20 deletions

View File

@ -203,7 +203,7 @@ static uint8 peep_assess_surroundings(sint16 center_x, sint16 center_y, sint16 c
break;
scenery = g_pathBitSceneryEntries[(mapElement->properties.path.additions & 0x0F) - 1];
if (mapElement->properties.path.additions & (1 << 7))
if (footpath_element_path_scenery_is_ghost(mapElement))
break;
if (scenery->path_bit.var_06 &
@ -620,7 +620,7 @@ static void sub_68F41A(rct_peep *peep, int index)
continue;
uint8 additions = mapElement->properties.path.additions & 0xF;
if (additions != 0 && mapElement->properties.path.additions & (1 << 7)){
if (additions != 0 && footpath_element_path_scenery_is_ghost(mapElement)){
rct_scenery_entry *sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (sceneryEntry->path_bit.var_06 & (1 << 8)){
found = 1;
@ -3670,7 +3670,7 @@ static void peep_update_emptying_bin(rct_peep* peep){
if (
!(scenery_entry->path_bit.var_06 & 1)
|| map_element->flags & (1 << 5)
|| map_element->properties.path.additions & (1 << 7)
|| footpath_element_path_scenery_is_ghost(map_element)
) {
peep_state_reset(peep);
return;
@ -3934,7 +3934,7 @@ static int peep_update_walking_find_bench(rct_peep* peep){
if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)return 0;
if (map_element->properties.path.additions & 0x80)return 0;
if (footpath_element_path_scenery_is_ghost(map_element)) return 0;
int edges = (map_element->properties.path.edges & 0xF) ^ 0xF;
if (edges == 0) return 0;
@ -4011,7 +4011,7 @@ static int peep_update_walking_find_bin(rct_peep* peep){
if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)return 0;
if (map_element->properties.path.additions & 0x80)return 0;
if (footpath_element_path_scenery_is_ghost(map_element)) return 0;
int edges = (map_element->properties.path.edges & 0xF) ^ 0xF;
if (edges == 0) return 0;
@ -4094,7 +4094,7 @@ static void peep_update_walking_break_scenery(rct_peep* peep){
if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)return;
if (map_element->properties.path.additions & 0x80)return;
if (footpath_element_path_scenery_is_ghost(map_element))return;
int edges = map_element->properties.path.edges & 0xF;
if (edges == 0xF) return;
@ -4272,7 +4272,7 @@ static void peep_update_using_bin(rct_peep* peep){
return;
}
if (map_element->properties.path.additions & 0x80){
if (footpath_element_path_scenery_is_ghost(map_element)){
peep_state_reset(peep);
return;
}
@ -4668,7 +4668,7 @@ static int peep_update_patrolling_find_bin(rct_peep* peep){
if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)
return 0;
if (map_element->properties.path.additions & 0x80)
if (footpath_element_path_scenery_is_ghost(map_element))
return 0;
uint8 bin_positions = map_element->properties.path.edges & 0xF;
@ -4962,8 +4962,8 @@ static void peep_update_walking(rct_peep* peep){
int ebp = 15;
if (additions){
if (!(map_element->properties.path.additions & 0x80)){
if (additions) {
if (!footpath_element_path_scenery_is_ghost(map_element)) {
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (!(sceneryEntry->path_bit.var_06 & 0x2)) ebp = 9;

View File

@ -776,7 +776,7 @@ static void rct1_fix_paths()
mapElement->type &= 0xFC;
mapElement->flags &= ~0x60;
mapElement->properties.path.type &= 0x0F;
mapElement->properties.path.additions &= 0x7F;
footpath_scenery_set_is_ghost(mapElement, false);
if (pathType & 0x80) {
mapElement->type |= 1;
}
@ -785,8 +785,8 @@ static void rct1_fix_paths()
// Additions
additions = mapElement->properties.path.additions & 0x0F;
additions = RCT1PathAdditionConversionTable[additions];
if (additions & 0x80) {
additions &= ~0x80;
if (footpath_element_path_scenery_is_ghost(mapElement)) {
footpath_scenery_set_is_ghost(mapElement, false);
mapElement->flags |= MAP_ELEMENT_FLAG_BROKEN;
} else {
mapElement->flags &= ~MAP_ELEMENT_FLAG_BROKEN;

View File

@ -249,17 +249,17 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement
if (flags & GAME_COMMAND_FLAG_4)
return MONEY32_UNDEFINED;
// Try placing a ghost
// Should place a ghost?
if (flags & GAME_COMMAND_FLAG_GHOST) {
// Check if there is something on the path already
if (mapElement->properties.path.additions & 0x0F) {
if (footpath_element_has_path_scenery(mapElement)) {
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_NONE;
return MONEY32_UNDEFINED;
}
// There is nothing yet - check if we should place a ghost
if (flags & GAME_COMMAND_FLAG_APPLY)
mapElement->properties.path.additions |= 0x80;
footpath_scenery_set_is_ghost(mapElement, true);
}
if (!(flags & GAME_COMMAND_FLAG_APPLY))
@ -267,9 +267,9 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement
if (
(pathItemType != 0 && !(flags & GAME_COMMAND_FLAG_GHOST)) ||
(pathItemType == 0 && (mapElement->properties.path.additions & 0x80))
(pathItemType == 0 && footpath_element_path_scenery_is_ghost(mapElement))
) {
mapElement->properties.path.additions &= ~0x80;
footpath_scenery_set_is_ghost(mapElement, false);
}
mapElement->properties.path.additions = (mapElement->properties.path.additions & 0xF0) | pathItemType;
@ -1612,6 +1612,20 @@ uint8 footpath_element_get_path_scenery_index(rct_map_element *mapElement)
return footpath_element_get_path_scenery(mapElement) - 1;
}
bool footpath_element_path_scenery_is_ghost(rct_map_element *mapElement)
{
return (mapElement->properties.path.additions & 0x80) == 0x80;
}
void footpath_scenery_set_is_ghost(rct_map_element *mapElement, bool isGhost)
{
// Remove ghost flag
mapElement->properties.path.additions &= ~0x80;
// Set flag if it should be a ghost
if (isGhost)
mapElement->properties.path.additions |= 0x80;
}
uint8 footpath_element_get_type(rct_map_element *mapElement)
{
return mapElement->properties.path.type >> 4;

View File

@ -77,6 +77,8 @@ uint8 footpath_element_get_type(rct_map_element *mapElement);
bool footpath_element_has_path_scenery(rct_map_element *mapElement);
uint8 footpath_element_get_path_scenery(rct_map_element *mapElement);
uint8 footpath_element_get_path_scenery_index(rct_map_element *mapElement);
bool footpath_element_path_scenery_is_ghost(rct_map_element *mapElement);
void footpath_scenery_set_is_ghost(rct_map_element *mapElement, bool isGhost);
void footpath_remove_edges_at(int x, int y, rct_map_element *mapElement);
#endif

View File

@ -24,6 +24,7 @@
#include "map.h"
#include "scenery.h"
#include "sprite.h"
#include "footpath.h"
enum {
PATTERN_CYCLIC_SQUARES,
@ -297,7 +298,7 @@ static bool is_jumping_fountain(int type, int x, int y, int z)
continue;
if (mapElement->base_height != z)
continue;
if (mapElement->properties.path.additions & 0x80)
if (footpath_element_path_scenery_is_ghost(mapElement))
continue;
int additions = mapElement->properties.path.additions & 0x0F;

View File

@ -28,6 +28,7 @@
#include "map.h"
#include "park.h"
#include "scenery.h"
#include "footpath.h"
void scenery_increase_age(int x, int y, rct_map_element *mapElement);
@ -41,7 +42,7 @@ void scenery_update_tile(int x, int y)
scenery_update_age(x, y, mapElement);
} else if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) {
int additions = mapElement->properties.path.additions & 0x0F;
if (additions != 0 && !(mapElement->properties.path.additions & 0x80)) {
if (additions != 0 && !footpath_element_path_scenery_is_ghost(mapElement)) {
rct_scenery_entry *sceneryEntry;
sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (sceneryEntry->path_bit.var_06 & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) {