Add object_entry_get_type()

This commit is contained in:
Gymnasiast 2018-02-08 20:34:05 +01:00 committed by Michael Steenbeek
parent 504e635933
commit b1ab852fb7
8 changed files with 17 additions and 8 deletions

View File

@ -1042,7 +1042,7 @@ static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinf
list_item *listItem = &_listItems[w->selected_list_item];
highlightedEntry = w->object_entry;
type = highlightedEntry->flags & 0x0F;
type = object_entry_get_type(highlightedEntry);
// Draw preview
widget = &w->widgets[WIDX_PREVIEW];
@ -1268,7 +1268,7 @@ static void editor_load_selected_objects()
}
else if (!(gScreenFlags & SCREEN_FLAGS_EDITOR)) {
// Defaults selected items to researched (if in-game)
uint8 objectType = entry->flags & 0x0F;
uint8 objectType = object_entry_get_type(entry);
uint8 entryIndex = object_manager_get_loaded_object_entry_index(loadedObject);
if (objectType == OBJECT_TYPE_RIDE) {
rct_ride_entry *rideEntry = get_ride_entry(entryIndex);

View File

@ -21,6 +21,7 @@
#include <openrct2/platform/platform.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/object/ObjectList.h>
enum WINDOW_OBJECT_LOAD_ERROR_WIDGET_IDX {
WIDX_BACKGROUND,
@ -109,7 +110,7 @@ static std::string file_path;
static rct_string_id get_object_type_string(const rct_object_entry *entry)
{
rct_string_id result;
uint8 objectType = entry->flags & 0x0F;
uint8 objectType = object_entry_get_type(entry);
switch (objectType) {
case OBJECT_TYPE_RIDE:
result = STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS;

View File

@ -58,6 +58,8 @@
#ifndef NO_TTF
#include "../drawing/TTF.h"
#include "../object/ObjectList.h"
#endif
#define CONSOLE_MAX_LINES 300
@ -1150,7 +1152,7 @@ static sint32 cc_load_object(const utf8 **argv, sint32 argc) {
}
sint32 groupIndex = object_manager_get_loaded_object_entry_index(loadedObject);
uint8 objectType = entry->flags & 0x0F;
uint8 objectType = object_entry_get_type(entry);
if (objectType == OBJECT_TYPE_RIDE) {
// Automatically research the ride so it's supported by the game.
rct_ride_entry *rideEntry;

View File

@ -106,6 +106,11 @@ bool object_entry_is_empty(const rct_object_entry *entry)
return false;
}
uint8 object_entry_get_type(const rct_object_entry * objectEntry)
{
return (objectEntry->flags & 0x0F);
}
uint8 object_entry_get_source_game(const rct_object_entry * objectEntry)
{
return (objectEntry->flags & 0xF0) >> 4;

View File

@ -23,5 +23,6 @@ extern rct_stex_entry *gStexEntries[MAX_SCENARIO_TEXT_OBJECTS];
void get_type_entry_index(size_t index, uint8 * outObjectType, uint8 * outEntryIndex);
const rct_object_entry * get_loaded_object_entry(size_t index);
void * get_loaded_object_chunk(size_t index);
uint8 object_entry_get_type(const rct_object_entry * objectEntry);
uint8 object_entry_get_source_game(const rct_object_entry * objectEntry);

View File

@ -100,7 +100,7 @@ public:
loadedObject = ori->LoadedObject;
if (loadedObject == nullptr)
{
uint8 objectType = entry->flags & 0x0F;
uint8 objectType = object_entry_get_type(entry);
sint32 slot = FindSpareSlot(objectType);
if (slot != -1)
{

View File

@ -498,7 +498,7 @@ private:
}
// Encode data
uint8 objectType = entry->flags & 0x0F;
uint8 objectType = object_entry_get_type(entry);
sawyercoding_chunk_header chunkHeader;
chunkHeader.encoding = object_entry_group_encoding[objectType];
chunkHeader.length = (uint32)dataSize;
@ -766,7 +766,7 @@ bool object_entry_compare(const rct_object_entry * a, const rct_object_entry * b
// If an official object don't bother checking checksum
if ((a->flags & 0xF0) || (b->flags & 0xF0))
{
if ((a->flags & 0x0F) != (b->flags & 0x0F))
if (object_entry_get_type(a) != object_entry_get_type(b))
{
return false;
}

View File

@ -550,7 +550,7 @@ private:
const rct_object_entry * foundEntry = object_list_find_by_name(objectName);
if (foundEntry != nullptr)
{
uint8 objectType = foundEntry->flags & 0x0F;
uint8 objectType = object_entry_get_type(foundEntry);
switch (objectType) {
case OBJECT_TYPE_SMALL_SCENERY:
case OBJECT_TYPE_LARGE_SCENERY: