Use object_entry_get_type() throughout

This commit is contained in:
Michael Steenbeek 2018-02-13 15:20:55 +01:00
parent 3ea6a3ea2f
commit a408747c4c
5 changed files with 23 additions and 19 deletions

View file

@ -22,6 +22,7 @@
#include "Game.h"
#include "localisation/Localisation.h"
#include "object/DefaultObjects.h"
#include "object/ObjectList.h"
#include "object/ObjectManager.h"
#include "object/ObjectRepository.h"
#include "OpenRCT2.h"
@ -30,6 +31,7 @@
#include "world/Footpath.h"
#include "world/LargeScenery.h"
bool _maxObjectsWasHit;
std::vector<uint8> _objectSelectionFlags;
sint32 _numSelectedObjectsForType[OBJECT_TYPE_COUNT];
@ -53,7 +55,7 @@ static void setup_track_manager_objects()
{
uint8 * selectionFlags = &_objectSelectionFlags[i];
const ObjectRepositoryItem * item = &items[i];
uint8 object_type = item->ObjectEntry.flags & 0xF;
uint8 object_type = object_entry_get_type(&item->ObjectEntry);
if (object_type == OBJECT_TYPE_RIDE)
{
*selectionFlags |= OBJECT_SELECTION_FLAG_6;
@ -82,7 +84,7 @@ static void setup_track_designer_objects()
{
uint8 * selectionFlags = &_objectSelectionFlags[i];
const ObjectRepositoryItem * item = &items[i];
uint8 objectType = item->ObjectEntry.flags & 0xF;
uint8 objectType = object_entry_get_type(&item->ObjectEntry);
if (objectType == OBJECT_TYPE_RIDE)
{
*selectionFlags |= OBJECT_SELECTION_FLAG_6;
@ -227,7 +229,7 @@ void sub_6AB211()
const ObjectRepositoryItem * items = object_repository_get_items();
for (sint32 i = 0; i < numObjects; i++) {
uint8 objectType = items[i].ObjectEntry.flags & 0xF;
uint8 objectType = object_entry_get_type(&items[i].ObjectEntry);
_numAvailableObjectsForType[objectType]++;
}
@ -360,7 +362,7 @@ void reset_selected_object_count_and_size()
sint32 numObjects = (sint32)object_repository_get_items_count();
const ObjectRepositoryItem * items = object_repository_get_items();
for (sint32 i = 0; i < numObjects; i++) {
uint8 objectType = items[i].ObjectEntry.flags & 0xF;
uint8 objectType = object_entry_get_type(&items[i].ObjectEntry);
if (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED) {
_numSelectedObjectsForType[objectType]++;
}
@ -415,7 +417,7 @@ sint32 window_editor_object_selection_select_object(uint8 bh, sint32 flags, cons
return 0;
}
uint8 objectType = item->ObjectEntry.flags & 0xF;
uint8 objectType = object_entry_get_type(&item->ObjectEntry);
if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & (1 << 2))) {
for (sint32 j = 0; j < item->NumThemeObjects; j++) {
window_editor_object_selection_select_object(++bh, flags, &item->ThemeObjects[j]);
@ -435,7 +437,7 @@ sint32 window_editor_object_selection_select_object(uint8 bh, sint32 flags, cons
return 1;
}
uint8 objectType = item->ObjectEntry.flags & 0xF;
uint8 objectType = object_entry_get_type(&item->ObjectEntry);
uint16 maxObjects = object_entry_group_counts[objectType];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) {
maxObjects = 4;
@ -480,7 +482,7 @@ bool editor_check_object_group_at_least_one_selected(sint32 checkObjectType)
const ObjectRepositoryItem * items = object_repository_get_items();
for (sint32 i = 0; i < numObjects; i++) {
uint8 objectType = items[i].ObjectEntry.flags & 0x0F;
uint8 objectType = object_entry_get_type(&items[i].ObjectEntry);
if (checkObjectType == objectType && (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED)) {
return true;
}
@ -502,7 +504,7 @@ sint32 editor_remove_unused_objects()
if (!(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_IN_USE) && !(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
{
const ObjectRepositoryItem * item = &items[i];
uint8 objectType = item->ObjectEntry.flags & 0xF;
uint8 objectType = object_entry_get_type(&item->ObjectEntry);
if (objectType == OBJECT_TYPE_PARK_ENTRANCE || objectType == OBJECT_TYPE_SCENARIO_TEXT || objectType == OBJECT_TYPE_WATER || objectType == OBJECT_TYPE_SCENERY_GROUP)
{

View file

@ -26,6 +26,8 @@
#include "FootpathObject.h"
#include "LargeSceneryObject.h"
#include "Object.h"
#include "ObjectLimits.h"
#include "ObjectList.h"
#include "ObjectFactory.h"
#include "RideObject.h"
#include "SceneryGroupObject.h"
@ -34,9 +36,6 @@
#include "WallObject.h"
#include "WaterObject.h"
#include "../object/Object.h"
#include "ObjectLimits.h"
class ReadObjectContext : public IReadObjectContext
{
private:
@ -164,7 +163,7 @@ namespace ObjectFactory
Object * CreateObject(const rct_object_entry &entry)
{
Object * result;
uint8 objectType = entry.flags & 0x0F;
uint8 objectType = object_entry_get_type(&entry);
switch (objectType) {
case OBJECT_TYPE_RIDE:
result = new RideObject(entry);

View file

@ -122,7 +122,7 @@ protected:
stream->WriteString(item.Path);
stream->WriteString(item.Name);
switch (item.ObjectEntry.flags & 0x0F) {
switch (object_entry_get_type(&item.ObjectEntry)) {
case OBJECT_TYPE_RIDE:
stream->WriteValue<uint8>(item.RideFlags);
for (sint32 i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
@ -153,7 +153,7 @@ protected:
item.Path = stream->ReadString();
item.Name = stream->ReadString();
switch (item.ObjectEntry.flags & 0x0F) {
switch (object_entry_get_type(&item.ObjectEntry)) {
case OBJECT_TYPE_RIDE:
item.RideFlags = stream->ReadValue<uint8>();
for (sint32 i = 0; i < 2; i++)
@ -434,7 +434,7 @@ private:
item->Path = nullptr;
item->Name = nullptr;
uint8 objectType = item->ObjectEntry.flags & 0x0F;
uint8 objectType = object_entry_get_type(&item->ObjectEntry);
switch (objectType) {
case OBJECT_TYPE_SCENERY_GROUP:
Memory::Free(item->ThemeObjects);

View file

@ -24,6 +24,7 @@
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
#include "../network/network.h"
#include "../object/ObjectList.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../OpenRCT2.h"
@ -485,7 +486,7 @@ static void track_design_mirror_scenery(rct_track_td6 * td6)
uint8 entry_type, entry_index;
if (!find_object_in_entry_group(&scenery->scenery_object, &entry_type, &entry_index))
{
entry_type = scenery->scenery_object.flags & 0xF;
entry_type = object_entry_get_type(&scenery->scenery_object);
if (entry_type != OBJECT_TYPE_PATHS)
{
continue;
@ -770,7 +771,7 @@ track_design_place_scenery(rct_td6_scenery_element * scenery_start, uint8 rideIn
uint8 entry_type, entry_index;
if (!find_object_in_entry_group(&scenery->scenery_object, &entry_type, &entry_index))
{
entry_type = scenery->scenery_object.flags & 0xF;
entry_type = object_entry_get_type(&scenery->scenery_object);
if (entry_type != OBJECT_TYPE_PATHS)
{
entry_type = 0xFF;
@ -895,7 +896,7 @@ track_design_place_scenery(rct_td6_scenery_element * scenery_start, uint8 rideIn
uint8 entry_type, entry_index;
if (!find_object_in_entry_group(&scenery->scenery_object, &entry_type, &entry_index))
{
entry_type = scenery->scenery_object.flags & 0xF;
entry_type = object_entry_get_type(&scenery->scenery_object);
if (entry_type != OBJECT_TYPE_PATHS)
{
_trackDesignPlaceStateSceneryUnavailable = true;

View file

@ -22,6 +22,7 @@
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../interface/Viewport.h"
#include "../object/ObjectList.h"
#include "../util/SawyerCoding.h"
#include "../util/Util.h"
#include "../windows/Intent.h"
@ -36,6 +37,7 @@
#include "TrackDesign.h"
#include "TrackDesignRepository.h"
#define TRACK_MAX_SAVED_TILE_ELEMENTS 1500
#define TRACK_NEARBY_SCENERY_DISTANCE 1
#define TRACK_TD6_MAX_ELEMENTS 8192
@ -640,7 +642,7 @@ static bool track_design_save_copy_scenery_to_td6(rct_track_td6 *td6)
for (size_t i = 0; i < _trackSavedTileElementsDescCount; i++) {
rct_td6_scenery_element *scenery = &td6->scenery_elements[i];
switch (scenery->scenery_object.flags & 0x0F) {
switch (object_entry_get_type(&scenery->scenery_object)) {
case OBJECT_TYPE_PATHS:
{
uint8 slope = (scenery->flags & 0x60) >> 5;