Getting path scenery type and index using helper functions throughout the entire project.

This commit is contained in:
Hielke Morsink 2015-12-05 00:08:34 +01:00
parent 6f0d14b65f
commit f04c97fbc1
9 changed files with 46 additions and 54 deletions

View File

@ -291,7 +291,7 @@ int viewport_interaction_get_item_right(int x, int y, viewport_interaction_info
return info->type;
case VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM:
sceneryEntry = g_pathBitSceneryEntries[(mapElement->properties.path.additions & 0x0F) - 1];
sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(mapElement)];
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS + 0, uint16) = 1164;
if (mapElement->flags & 0x20) {
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS + 2, uint16) = 3124;

View File

@ -199,10 +199,10 @@ static uint8 peep_assess_surroundings(sint16 center_x, sint16 center_y, sint16 c
switch (map_element_get_type(mapElement)){
case MAP_ELEMENT_TYPE_PATH:
if ((mapElement->properties.path.additions & 0xF) == 0)
if (!footpath_element_has_path_scenery(mapElement))
break;
scenery = g_pathBitSceneryEntries[(mapElement->properties.path.additions & 0x0F) - 1];
scenery = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(mapElement)];
if (footpath_element_path_scenery_is_ghost(mapElement))
break;
@ -619,9 +619,10 @@ static void sub_68F41A(rct_peep *peep, int index)
if (mapElement->base_height != peep->next_z)
continue;
uint8 additions = mapElement->properties.path.additions & 0xF;
if (additions != 0 && footpath_element_path_scenery_is_ghost(mapElement)){
rct_scenery_entry *sceneryEntry = g_pathBitSceneryEntries[additions - 1];
// Check if the footpath has ghost path scenery on it
if (footpath_element_has_path_scenery(mapElement) && footpath_element_path_scenery_is_ghost(mapElement)){
uint8 pathSceneryIndex = footpath_element_get_path_scenery_index(mapElement);
rct_scenery_entry *sceneryEntry = g_pathBitSceneryEntries[pathSceneryIndex];
if (sceneryEntry->path_bit.var_06 & (1 << 8)){
found = 1;
}
@ -3661,12 +3662,12 @@ static void peep_update_emptying_bin(rct_peep* peep){
}
}
if ((map_element->properties.path.additions & 0x0F) == 0) {
if (!footpath_element_has_path_scenery(map_element)) {
peep_state_reset(peep);
return;
}
rct_scenery_entry* scenery_entry = g_pathBitSceneryEntries[(map_element->properties.path.additions & 0xF) - 1];
rct_scenery_entry* scenery_entry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (
!(scenery_entry->path_bit.var_06 & 1)
|| map_element->flags & (1 << 5)
@ -3925,10 +3926,8 @@ static int peep_update_walking_find_bench(rct_peep* peep){
}
}
uint8 additions = map_element->properties.path.additions & 0xF;
if (!additions) return 0;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (!footpath_element_has_path_scenery(map_element)) return 0;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (!(sceneryEntry->path_bit.var_06 & 0x2))return 0;
@ -4002,10 +4001,8 @@ static int peep_update_walking_find_bin(rct_peep* peep){
}
}
uint8 additions = map_element->properties.path.additions & 0xF;
if (!additions) return 0;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (!footpath_element_has_path_scenery(map_element)) return 0;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (!(sceneryEntry->path_bit.var_06 & 0x1))return 0;
@ -4085,10 +4082,8 @@ static void peep_update_walking_break_scenery(rct_peep* peep){
}
}
uint8 additions = map_element->properties.path.additions & 0xF;
if (!additions) return;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (!footpath_element_has_path_scenery(map_element)) return;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (!(sceneryEntry->path_bit.var_06 & 0x4))return;
@ -4255,13 +4250,12 @@ static void peep_update_using_bin(rct_peep* peep){
}
}
uint8 additions = map_element->properties.path.additions & 0x0F;
if (!additions){
if (!footpath_element_has_path_scenery(map_element)){
peep_state_reset(peep);
return;
}
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (!(sceneryEntry->path_bit.var_06 & 1)){
peep_state_reset(peep);
return;
@ -4656,11 +4650,8 @@ static int peep_update_patrolling_find_bin(rct_peep* peep){
return 0;
}
uint8 additions = map_element->properties.path.additions & 0xF;
if (additions == 0)return 0;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
if (!footpath_element_has_path_scenery(map_element)) return 0;
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (!(sceneryEntry->path_bit.var_06 & 1))
return 0;
@ -4958,13 +4949,11 @@ static void peep_update_walking(rct_peep* peep){
}
}
uint8 additions = map_element->properties.path.additions & 0xF;
int ebp = 15;
if (additions) {
if (footpath_element_has_path_scenery(map_element)) {
if (!footpath_element_path_scenery_is_ghost(map_element)) {
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[additions - 1];
rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(map_element)];
if (!(sceneryEntry->path_bit.var_06 & 0x2)) ebp = 9;
}
@ -6629,7 +6618,7 @@ static int peep_interact_with_path(rct_peep* peep, sint16 x, sint16 y, rct_map_e
// 0x00F1AEE2
bool vandalism_present = false;
if ((map_element->properties.path.additions & 0xF) != 0 &&
if (footpath_element_has_path_scenery(map_element) &&
(map_element->flags & MAP_ELEMENT_FLAG_BROKEN) &&
(map_element->properties.path.edges & 0xF) != 0xF){
vandalism_present = 1;

View File

@ -783,16 +783,15 @@ static void rct1_fix_paths()
mapElement->properties.path.type |= pathType << 4;
// Additions
additions = mapElement->properties.path.additions & 0x0F;
additions = RCT1PathAdditionConversionTable[additions];
additions = RCT1PathAdditionConversionTable[footpath_element_get_path_scenery(mapElement)];
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;
}
mapElement->properties.path.additions &= 0xF0;
mapElement->properties.path.additions |= additions;
footpath_element_set_path_scenery(mapElement, additions);
break;
case MAP_ELEMENT_TYPE_ENTRANCE:
if (mapElement->properties.entrance.type == ENTRANCE_TYPE_PARK_ENTRANCE) {

View File

@ -483,7 +483,7 @@ static void cheat_fix_vandalism()
if (map_element_get_type(it.element) != MAP_ELEMENT_TYPE_PATH)
continue;
if ((it.element->properties.path.additions & 0x0F) == 0)
if (!footpath_element_has_path_scenery(it.element))
continue;
it.element->flags &= ~MAP_ELEMENT_FLAG_BROKEN;
@ -511,10 +511,10 @@ static void cheat_remove_litter()
if (map_element_get_type(it.element) != MAP_ELEMENT_TYPE_PATH)
continue;
if ((it.element->properties.path.additions & 0x0F) == 0)
if (!footpath_element_has_path_scenery(it.element))
continue;
sceneryEntry = g_pathBitSceneryEntries[(it.element->properties.path.additions & 0xF) - 1];
sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(it.element)];
if(sceneryEntry->path_bit.var_06 & (1 << 0))
it.element->properties.path.addition_status = 0xFF;

View File

@ -36,6 +36,7 @@
#include "dropdown.h"
#include "error.h"
#include "../util/util.h"
#include "../world/footpath.h"
enum {
@ -577,7 +578,6 @@ static void setup_in_use_selection_flags(){
map_element_iterator_begin(&iter);
do {
uint16 type;
uint8 path_additions;
rct_banner* banner;
switch (map_element_get_type(iter.element)) {
@ -591,10 +591,9 @@ static void setup_in_use_selection_flags(){
assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]);
RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_PATHS][type] |= (1 << 0);
path_additions = iter.element->properties.path.additions & 0xF;
if (path_additions){
path_additions--;
RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_PATH_BITS][path_additions] |= (1 << 0);
if (footpath_element_has_path_scenery(iter.element)) {
uint8 path_additions = footpath_element_get_path_scenery_index(iter.element);
RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_PATH_BITS][path_additions] |= 1;
}
break;
case MAP_ELEMENT_TYPE_SCENERY:

View File

@ -210,7 +210,7 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement
} else if (pathItemType != 0) {
if (
!(flags & GAME_COMMAND_FLAG_GHOST) &&
(mapElement->properties.path.additions & 0x0F) == pathItemType &&
footpath_element_get_path_scenery(mapElement) == pathItemType &&
!(mapElement->flags & MAP_ELEMENT_FLAG_BROKEN)
) {
if (flags & GAME_COMMAND_FLAG_4)
@ -272,7 +272,7 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement
footpath_scenery_set_is_ghost(mapElement, false);
}
mapElement->properties.path.additions = (mapElement->properties.path.additions & 0xF0) | pathItemType;
footpath_element_set_path_scenery(mapElement, pathItemType);
mapElement->flags &= ~MAP_ELEMENT_FLAG_BROKEN;
if (pathItemType != 0) {
rct_scenery_entry* scenery_entry = g_pathBitSceneryEntries[pathItemType - 1];
@ -295,7 +295,7 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement
mapElement->properties.path.type = (mapElement->properties.path.type & 0x0F) | (type << 4);
mapElement->type = (mapElement->type & 0xFE) | (type >> 7);
mapElement->properties.path.additions = (mapElement->properties.path.additions & 0xF0) | pathItemType;
footpath_element_set_path_scenery(mapElement, pathItemType);
mapElement->flags &= ~MAP_ELEMENT_FLAG_BROKEN;
loc_6A6620(flags, x, y, mapElement);
@ -1607,6 +1607,11 @@ uint8 footpath_element_get_path_scenery(rct_map_element *mapElement)
return mapElement->properties.path.additions & 0xF;
}
void footpath_element_set_path_scenery(rct_map_element *mapElement, uint8 pathSceneryType)
{
mapElement->properties.path.additions = (mapElement->properties.path.additions & 0xF0) | pathSceneryType;
}
uint8 footpath_element_get_path_scenery_index(rct_map_element *mapElement)
{
return footpath_element_get_path_scenery(mapElement) - 1;

View File

@ -76,6 +76,7 @@ bool footpath_element_is_wide(rct_map_element *mapElement);
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);
void footpath_element_set_path_scenery(rct_map_element *mapElement, uint8 pathSceneryType);
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);

View File

@ -301,11 +301,11 @@ static bool is_jumping_fountain(int type, int x, int y, int z)
if (footpath_element_path_scenery_is_ghost(mapElement))
continue;
int additions = mapElement->properties.path.additions & 0x0F;
if (additions == 0)
if (!footpath_element_has_path_scenery(mapElement))
continue;
rct_scenery_entry *sceneryEntry = g_pathBitSceneryEntries[additions - 1];
uint8 additionIndex = footpath_element_get_path_scenery_index(mapElement);
rct_scenery_entry *sceneryEntry = g_pathBitSceneryEntries[additionIndex];
if (!(sceneryEntry->path_bit.var_06 & pathBitFlagMask))
continue;

View File

@ -41,10 +41,9 @@ void scenery_update_tile(int x, int y)
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SCENERY) {
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 && !footpath_element_path_scenery_is_ghost(mapElement)) {
if (footpath_element_has_path_scenery(mapElement) && !footpath_element_path_scenery_is_ghost(mapElement)) {
rct_scenery_entry *sceneryEntry;
sceneryEntry = g_pathBitSceneryEntries[additions - 1];
sceneryEntry = g_pathBitSceneryEntries[footpath_element_get_path_scenery_index(mapElement)];
if (sceneryEntry->path_bit.var_06 & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) {
jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_WATER, x, y, mapElement);
} else if (sceneryEntry->path_bit.var_06 & PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW) {