mirror of https://github.com/OpenRCT2/OpenRCT2.git
remove required flag (unused) and fix scenery selection
This commit is contained in:
parent
4bed693344
commit
7e1f948e19
|
@ -40,7 +40,7 @@ typedef enum{
|
||||||
OBJECT_SELECTION_FLAG_SELECTED = (1 << 0),
|
OBJECT_SELECTION_FLAG_SELECTED = (1 << 0),
|
||||||
OBJECT_SELECTION_FLAG_2 = (1 << 1),
|
OBJECT_SELECTION_FLAG_2 = (1 << 1),
|
||||||
OBJECT_SELECTION_FLAG_IN_USE = (1 << 2),
|
OBJECT_SELECTION_FLAG_IN_USE = (1 << 2),
|
||||||
OBJECT_SELECTION_FLAG_REQUIRED = (1 << 3),
|
// OBJECT_SELECTION_FLAG_REQUIRED = (1 << 3), // Unused feature
|
||||||
OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED = (1 << 4),
|
OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED = (1 << 4),
|
||||||
OBJECT_SELECTION_FLAG_6 = (1 << 5),
|
OBJECT_SELECTION_FLAG_6 = (1 << 5),
|
||||||
OBJECT_SELECTION_FLAG_7 = (1 << 6),
|
OBJECT_SELECTION_FLAG_7 = (1 << 6),
|
||||||
|
|
|
@ -44,7 +44,7 @@ extern "C"
|
||||||
#include "../util/sawyercoding.h"
|
#include "../util/sawyercoding.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint16 OBJECT_REPOSITORY_VERSION = 6;
|
constexpr uint16 OBJECT_REPOSITORY_VERSION = 7;
|
||||||
|
|
||||||
struct ObjectRepositoryHeader
|
struct ObjectRepositoryHeader
|
||||||
{
|
{
|
||||||
|
@ -391,13 +391,6 @@ private:
|
||||||
item.NumImages = stream->ReadValue<uint32>();
|
item.NumImages = stream->ReadValue<uint32>();
|
||||||
item.Name = stream->ReadString();
|
item.Name = stream->ReadString();
|
||||||
item.ChunkSize = stream->ReadValue<size_t>();
|
item.ChunkSize = stream->ReadValue<size_t>();
|
||||||
item.NumRequiredObjects = stream->ReadValue<uint16>();
|
|
||||||
|
|
||||||
item.RequiredObjects = Memory::AllocateArray<rct_object_entry>(item.NumRequiredObjects);
|
|
||||||
for (uint16 i = 0; i < item.NumRequiredObjects; i++)
|
|
||||||
{
|
|
||||||
item.RequiredObjects[i] = stream->ReadValue<rct_object_entry>();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.ObjectEntry.flags & 0x0F) {
|
switch (item.ObjectEntry.flags & 0x0F) {
|
||||||
case OBJECT_TYPE_RIDE:
|
case OBJECT_TYPE_RIDE:
|
||||||
|
@ -430,12 +423,6 @@ private:
|
||||||
stream->WriteValue(item.NumImages);
|
stream->WriteValue(item.NumImages);
|
||||||
stream->WriteString(item.Name);
|
stream->WriteString(item.Name);
|
||||||
stream->WriteValue(item.ChunkSize);
|
stream->WriteValue(item.ChunkSize);
|
||||||
|
|
||||||
stream->WriteValue(item.NumRequiredObjects);
|
|
||||||
for (uint16 i = 0; i < item.NumRequiredObjects; i++)
|
|
||||||
{
|
|
||||||
stream->WriteValue(item.RequiredObjects[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.ObjectEntry.flags & 0x0F) {
|
switch (item.ObjectEntry.flags & 0x0F) {
|
||||||
case OBJECT_TYPE_RIDE:
|
case OBJECT_TYPE_RIDE:
|
||||||
|
@ -463,11 +450,9 @@ private:
|
||||||
{
|
{
|
||||||
Memory::Free(item->Path);
|
Memory::Free(item->Path);
|
||||||
Memory::Free(item->Name);
|
Memory::Free(item->Name);
|
||||||
Memory::Free(item->RequiredObjects);
|
|
||||||
Memory::Free(item->ThemeObjects);
|
Memory::Free(item->ThemeObjects);
|
||||||
item->Path = nullptr;
|
item->Path = nullptr;
|
||||||
item->Name = nullptr;
|
item->Name = nullptr;
|
||||||
item->RequiredObjects = nullptr;
|
|
||||||
item->ThemeObjects = nullptr;
|
item->ThemeObjects = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ typedef struct ObjectRepositoryItem
|
||||||
uint32 NumImages;
|
uint32 NumImages;
|
||||||
utf8 * Name;
|
utf8 * Name;
|
||||||
size_t ChunkSize;
|
size_t ChunkSize;
|
||||||
uint16 NumRequiredObjects;
|
|
||||||
rct_object_entry * RequiredObjects;
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
|
#include "ObjectRepository.h"
|
||||||
#include "SceneryGroupObject.h"
|
#include "SceneryGroupObject.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -100,6 +101,18 @@ const utf8 * SceneryGroupObject::GetName() const
|
||||||
return name != nullptr ? name : "";
|
return name != nullptr ? name : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneryGroupObject::SetRepositoryItem(ObjectRepositoryItem * item) const
|
||||||
|
{
|
||||||
|
Memory::Free(item->ThemeObjects);
|
||||||
|
|
||||||
|
item->NumThemeObjects = _numItems;
|
||||||
|
item->ThemeObjects = Memory::AllocateArray<rct_object_entry>(_numItems);
|
||||||
|
for (uint32 i = 0; i < _numItems; i++)
|
||||||
|
{
|
||||||
|
item->ThemeObjects[i] = _items[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SceneryGroupObject::ReadItems(IStream * stream)
|
void SceneryGroupObject::ReadItems(IStream * stream)
|
||||||
{
|
{
|
||||||
auto items = std::vector<rct_object_entry>();
|
auto items = std::vector<rct_object_entry>();
|
||||||
|
|
|
@ -23,6 +23,8 @@ extern "C"
|
||||||
#include "../world/scenery.h"
|
#include "../world/scenery.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ObjectRepositoryItem;
|
||||||
|
|
||||||
class SceneryGroupObject : public Object
|
class SceneryGroupObject : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -44,6 +46,8 @@ public:
|
||||||
|
|
||||||
const utf8 * GetName() const override;
|
const utf8 * GetName() const override;
|
||||||
|
|
||||||
|
void SetRepositoryItem(ObjectRepositoryItem * item) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReadItems(IStream * stream);
|
void ReadItems(IStream * stream);
|
||||||
};
|
};
|
||||||
|
|
|
@ -231,7 +231,6 @@ static bool filter_chunks(const ObjectRepositoryItem * item);
|
||||||
static void filter_update_counts();
|
static void filter_update_counts();
|
||||||
|
|
||||||
void reset_selected_object_count_and_size();
|
void reset_selected_object_count_and_size();
|
||||||
void reset_required_object_flags();
|
|
||||||
static int sub_6AB211();
|
static int sub_6AB211();
|
||||||
|
|
||||||
static rct_object_entry RequiredSelectedObjects[] = {
|
static rct_object_entry RequiredSelectedObjects[] = {
|
||||||
|
@ -673,7 +672,6 @@ static int sub_6AB211()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_required_object_flags();
|
|
||||||
reset_selected_object_count_and_size();
|
reset_selected_object_count_and_size();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1420,7 +1418,7 @@ static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpi
|
||||||
x = 2;
|
x = 2;
|
||||||
gCurrentFontSpriteBase = colour == 14 ? -2 : -1;
|
gCurrentFontSpriteBase = colour == 14 ? -2 : -1;
|
||||||
colour2 = w->colours[1] & 0x7F;
|
colour2 = w->colours[1] & 0x7F;
|
||||||
if (*listItem->flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_REQUIRED | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
|
if (*listItem->flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
|
||||||
colour2 |= 0x40;
|
colour2 |= 0x40;
|
||||||
|
|
||||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour2, x, y);
|
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour2, x, y);
|
||||||
|
@ -1537,53 +1535,6 @@ void reset_selected_object_count_and_size()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* rct2: 0x006AB863
|
|
||||||
*/
|
|
||||||
void set_required_object_flags(rct_object_entry* required_object)
|
|
||||||
{
|
|
||||||
int numObjects = (int)object_repository_get_items_count();
|
|
||||||
const ObjectRepositoryItem * items = object_repository_get_items();
|
|
||||||
for (int i = 0; i < numObjects; i++) {
|
|
||||||
const ObjectRepositoryItem * item = &items[i];
|
|
||||||
if (object_entry_compare(required_object, &item->ObjectEntry)) {
|
|
||||||
_objectSelectionFlags[i] |= OBJECT_SELECTION_FLAG_REQUIRED;
|
|
||||||
|
|
||||||
uint16 numRequiredObjects = item->NumRequiredObjects;
|
|
||||||
for (uint16 j = 0; j < numRequiredObjects; j++) {
|
|
||||||
set_required_object_flags(&item->RequiredObjects[j]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* rct2: 0x006AB923
|
|
||||||
*/
|
|
||||||
void reset_required_object_flags()
|
|
||||||
{
|
|
||||||
int numObjects = (int)object_repository_get_items_count();
|
|
||||||
const ObjectRepositoryItem * items = object_repository_get_items();
|
|
||||||
|
|
||||||
for (int i = 0; i < numObjects; i++) {
|
|
||||||
_objectSelectionFlags[i] &= ~OBJECT_SELECTION_FLAG_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < numObjects; i++) {
|
|
||||||
const ObjectRepositoryItem * item = &items[i];
|
|
||||||
|
|
||||||
if (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED) {
|
|
||||||
uint16 numRequiredObjects = item->NumRequiredObjects;
|
|
||||||
for (uint16 j = 0; j < numRequiredObjects; j++) {
|
|
||||||
set_required_object_flags(&item->RequiredObjects[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Master objects are objects that are not
|
* Master objects are objects that are not
|
||||||
* optional / required dependants of an
|
* optional / required dependants of an
|
||||||
|
@ -1620,41 +1571,27 @@ static int window_editor_object_selection_select_object(uint8 bh, int flags, con
|
||||||
|
|
||||||
uint8 * selectionFlags = &_objectSelectionFlags[index];
|
uint8 * selectionFlags = &_objectSelectionFlags[index];
|
||||||
if (!(flags & 1)) {
|
if (!(flags & 1)) {
|
||||||
if (!(*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED))
|
if (!(*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED)) {
|
||||||
{
|
|
||||||
if (bh == 0){
|
|
||||||
reset_required_object_flags();
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (*selectionFlags & OBJECT_SELECTION_FLAG_IN_USE){
|
else if (*selectionFlags & OBJECT_SELECTION_FLAG_IN_USE) {
|
||||||
set_object_selection_error(bh, 3173);
|
set_object_selection_error(bh, 3173);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (*selectionFlags & OBJECT_SELECTION_FLAG_REQUIRED){
|
else if (*selectionFlags & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED) {
|
||||||
set_object_selection_error(bh, 3174);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (*selectionFlags & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED){
|
|
||||||
set_object_selection_error(bh, 3175);
|
set_object_selection_error(bh, 3175);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 numThemeObjects = item->NumThemeObjects;
|
if (flags & (1 << 2)) {
|
||||||
if (numThemeObjects != 0 && flags & (1 << 2)) {
|
for (int j = 0; j < item->NumThemeObjects; j++) {
|
||||||
rct_object_entry* theme_object = item->ThemeObjects;
|
window_editor_object_selection_select_object(++bh, flags, &item->ThemeObjects[j]);
|
||||||
for (; numThemeObjects > 0; numThemeObjects--) {
|
|
||||||
window_editor_object_selection_select_object(++bh, flags, theme_object);
|
|
||||||
theme_object++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
||||||
_numSelectedObjectsForType[objectType]--;
|
_numSelectedObjectsForType[objectType]--;
|
||||||
*selectionFlags &= ~OBJECT_SELECTION_FLAG_SELECTED;
|
*selectionFlags &= ~OBJECT_SELECTION_FLAG_SELECTED;
|
||||||
if (bh == 0) {
|
|
||||||
reset_required_object_flags();
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
if (bh == 0) {
|
if (bh == 0) {
|
||||||
|
@ -1663,9 +1600,6 @@ static int window_editor_object_selection_select_object(uint8 bh, int flags, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED) {
|
if (*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED) {
|
||||||
if (bh == 0) {
|
|
||||||
reset_required_object_flags();
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1680,21 +1614,10 @@ static int window_editor_object_selection_select_object(uint8 bh, int flags, con
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint16 j = 0; j < item->NumRequiredObjects; j++) {
|
if (objectType == OBJECT_TYPE_SCENERY_SETS && (flags & (1 << 2))) {
|
||||||
if (!window_editor_object_selection_select_object(++bh, flags, &item->RequiredObjects[j])) {
|
|
||||||
if (bh != 0) {
|
|
||||||
reset_selected_object_count_and_size();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objectType == OBJECT_TYPE_SCENERY_SETS) {
|
|
||||||
for (uint16 j = 0; j < item->NumThemeObjects; j++) {
|
for (uint16 j = 0; j < item->NumThemeObjects; j++) {
|
||||||
if (flags & (1 << 2)) {
|
if (!window_editor_object_selection_select_object(++bh, flags, &item->ThemeObjects[j])) {
|
||||||
if (!window_editor_object_selection_select_object(++bh, flags, &item->ThemeObjects[j])) {
|
_maxObjectsWasHit = true;
|
||||||
_maxObjectsWasHit = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1714,9 +1637,6 @@ static int window_editor_object_selection_select_object(uint8 bh, int flags, con
|
||||||
_numSelectedObjectsForType[objectType]++;
|
_numSelectedObjectsForType[objectType]++;
|
||||||
|
|
||||||
*selectionFlags |= OBJECT_SELECTION_FLAG_SELECTED;
|
*selectionFlags |= OBJECT_SELECTION_FLAG_SELECTED;
|
||||||
if (bh == 0) {
|
|
||||||
reset_required_object_flags();
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue