mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use sourceGame parameter in JSON files instead of originalId
This commit is contained in:
parent
71bd110526
commit
2a64ec7aff
|
@ -951,7 +951,6 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
|
|||
{
|
||||
int32_t i, x, y, width;
|
||||
rct_widget* widget;
|
||||
rct_object_entry* highlightedEntry;
|
||||
rct_string_id stringId;
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
|
@ -1043,8 +1042,6 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
|
|||
|
||||
list_item* listItem = &_listItems[w->selected_list_item];
|
||||
|
||||
highlightedEntry = w->object_entry;
|
||||
|
||||
// Draw preview
|
||||
widget = &w->widgets[WIDX_PREVIEW];
|
||||
{
|
||||
|
@ -1093,7 +1090,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
|
|||
y += 12;
|
||||
|
||||
// Draw object source
|
||||
stringId = object_manager_get_source_game_string(highlightedEntry);
|
||||
stringId = object_manager_get_source_game_string(listItem->repositoryItem->Sources[0]);
|
||||
gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, w->x + w->width - 5, y);
|
||||
y += 12;
|
||||
|
||||
|
@ -1434,8 +1431,8 @@ static bool filter_source(const ObjectRepositoryItem * item)
|
|||
if (_FILTER_ALL)
|
||||
return true;
|
||||
|
||||
uint8_t source = object_entry_get_source_game(&item->ObjectEntry);
|
||||
uint8_t secondSource = item->Source;
|
||||
uint8_t source = item->Sources[0];
|
||||
uint8_t secondSource = item->Sources[1];
|
||||
|
||||
return sources_match(source) || (secondSource != OBJECT_SOURCE_CUSTOM && sources_match(secondSource));
|
||||
}
|
||||
|
|
|
@ -329,7 +329,8 @@ static void window_object_load_error_scrollpaint(rct_window* w, rct_drawpixelinf
|
|||
gfx_draw_string(dpi, strndup(_invalid_entries[i].name, 8), COLOUR_DARK_GREEN, NAME_COL_LEFT - 3, y);
|
||||
|
||||
// ... source game ...
|
||||
rct_string_id sourceStringId = object_manager_get_source_game_string(&_invalid_entries[i]);
|
||||
rct_string_id sourceStringId = object_manager_get_source_game_string(
|
||||
object_entry_get_source_game_legacy(&_invalid_entries[i]));
|
||||
gfx_draw_string_left(dpi, sourceStringId, nullptr, COLOUR_DARK_GREEN, SOURCE_COL_LEFT - 3, y);
|
||||
|
||||
// ... and type
|
||||
|
|
|
@ -47,10 +47,10 @@ void BannerObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
|||
auto item = objectRepository.FindObject(identifier);
|
||||
if (item != nullptr)
|
||||
{
|
||||
auto objectEntry = &item->ObjectEntry;
|
||||
if (object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_WACKY_WORLDS
|
||||
|| object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_TIME_TWISTER
|
||||
|| object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_CUSTOM)
|
||||
auto sourceGame = item->Sources[0];
|
||||
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS
|
||||
|| sourceGame == OBJECT_SOURCE_TIME_TWISTER
|
||||
|| sourceGame == OBJECT_SOURCE_CUSTOM)
|
||||
{
|
||||
auto scgPathX = Object::GetScgPathXHeader();
|
||||
SetPrimarySceneryGroup(&scgPathX);
|
||||
|
|
|
@ -51,7 +51,7 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream
|
|||
auto item = objectRepository.FindObject(identifier);
|
||||
if (item != nullptr)
|
||||
{
|
||||
auto sourceGame = object_entry_get_source_game(&item->ObjectEntry);
|
||||
auto sourceGame = item->Sources[0];
|
||||
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS || sourceGame == OBJECT_SOURCE_TIME_TWISTER
|
||||
|| sourceGame == OBJECT_SOURCE_CUSTOM)
|
||||
{
|
||||
|
|
|
@ -84,11 +84,14 @@ rct_object_entry Object::CreateHeader(const char name[DAT_NAME_LENGTH + 1], uint
|
|||
return header;
|
||||
}
|
||||
|
||||
uint8_t Object::GetSourceGame()
|
||||
{
|
||||
return _sourceGame;
|
||||
}
|
||||
|
||||
void Object::SetSourceGame(const uint8_t sourceGame)
|
||||
{
|
||||
// FIXME: Temporary disabled because it breaks exporting to vanilla.
|
||||
/*_objectEntry.flags &= 0x0F;
|
||||
_objectEntry.flags |= (sourceGame << 4);*/
|
||||
_sourceGame = sourceGame;
|
||||
}
|
||||
|
||||
uint8_t Object::GetSecondSourceGame()
|
||||
|
|
|
@ -157,6 +157,7 @@ private:
|
|||
rct_object_entry _objectEntry{};
|
||||
StringTable _stringTable;
|
||||
ImageTable _imageTable;
|
||||
uint8_t _sourceGame = OBJECT_SOURCE_CUSTOM;
|
||||
uint8_t _secondSourceGame = OBJECT_SOURCE_CUSTOM;
|
||||
|
||||
protected:
|
||||
|
@ -177,7 +178,6 @@ protected:
|
|||
std::string GetString(uint8_t index) const;
|
||||
std::string GetString(int32_t language, uint8_t index) const;
|
||||
|
||||
void SetSourceGame(const uint8_t sourceGame);
|
||||
bool IsOpenRCT2OfficialObject();
|
||||
|
||||
public:
|
||||
|
@ -216,6 +216,8 @@ public:
|
|||
virtual void SetRepositoryItem(ObjectRepositoryItem* /*item*/) const
|
||||
{
|
||||
}
|
||||
uint8_t GetSourceGame();
|
||||
void SetSourceGame(uint8_t sourceGame);
|
||||
uint8_t GetSecondSourceGame();
|
||||
void SetSecondSourceGame(uint8_t sourceGame);
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ namespace ObjectFactory
|
|||
{
|
||||
throw std::runtime_error("Object has errors");
|
||||
}
|
||||
result->SetSourceGame(object_entry_get_source_game_legacy(&entry));
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
|
@ -251,6 +252,10 @@ namespace ObjectFactory
|
|||
delete result;
|
||||
result = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->SetSourceGame(object_entry_get_source_game_legacy(entry));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -415,9 +420,20 @@ namespace ObjectFactory
|
|||
auto sourceGames = json_object_get(jRoot, "sourceGame");
|
||||
if (json_is_array(sourceGames))
|
||||
{
|
||||
auto sourceGame = json_string_value(json_array_get(sourceGames, 0));
|
||||
auto secondSourceGame = json_string_value(json_array_get(sourceGames, 1));
|
||||
result->SetSourceGame(ParseSourceGame(sourceGame));
|
||||
result->SetSecondSourceGame(ParseSourceGame(secondSourceGame));
|
||||
}
|
||||
else if (json_is_string(sourceGames))
|
||||
{
|
||||
auto sourceGame = json_string_value(sourceGames);
|
||||
result->SetSourceGame(ParseSourceGame(sourceGame));
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("Object %s has an incorrect sourceGame parameter.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -71,7 +71,7 @@ uint8_t object_entry_get_type(const rct_object_entry* objectEntry)
|
|||
return (objectEntry->flags & 0x0F);
|
||||
}
|
||||
|
||||
uint8_t object_entry_get_source_game(const rct_object_entry* objectEntry)
|
||||
uint8_t object_entry_get_source_game_legacy(const rct_object_entry* objectEntry)
|
||||
{
|
||||
return (objectEntry->flags & 0xF0) >> 4;
|
||||
}
|
||||
|
|
|
@ -21,4 +21,4 @@ void get_type_entry_index(size_t index, uint8_t* outObjectType, uint8_t* outEntr
|
|||
const rct_object_entry* get_loaded_object_entry(size_t index);
|
||||
void* get_loaded_object_chunk(size_t index);
|
||||
uint8_t object_entry_get_type(const rct_object_entry* objectEntry);
|
||||
uint8_t object_entry_get_source_game(const rct_object_entry* objectEntry);
|
||||
uint8_t object_entry_get_source_game_legacy(const rct_object_entry* objectEntry);
|
||||
|
|
|
@ -218,9 +218,9 @@ public:
|
|||
// loaded RCT1 and RCT2 save files.
|
||||
}
|
||||
|
||||
static rct_string_id GetObjectSourceGameString(const rct_object_entry* entry)
|
||||
static rct_string_id GetObjectSourceGameString(const uint8_t sourceGame)
|
||||
{
|
||||
switch (object_entry_get_source_game(entry))
|
||||
switch (sourceGame)
|
||||
{
|
||||
case OBJECT_SOURCE_RCT1:
|
||||
return STR_SCENARIO_CATEGORY_RCT1;
|
||||
|
@ -675,7 +675,7 @@ void object_manager_unload_all_objects()
|
|||
}
|
||||
}
|
||||
|
||||
rct_string_id object_manager_get_source_game_string(const rct_object_entry* entry)
|
||||
rct_string_id object_manager_get_source_game_string(const uint8_t sourceGame)
|
||||
{
|
||||
return ObjectManager::GetObjectSourceGameString(entry);
|
||||
return ObjectManager::GetObjectSourceGameString(sourceGame);
|
||||
}
|
||||
|
|
|
@ -49,4 +49,4 @@ uint8_t object_manager_get_loaded_object_entry_index(const void* loadedObject);
|
|||
void* object_manager_load_object(const rct_object_entry* entry);
|
||||
void object_manager_unload_objects(const rct_object_entry* entries, size_t count);
|
||||
void object_manager_unload_all_objects();
|
||||
rct_string_id object_manager_get_source_game_string(const rct_object_entry* entry);
|
||||
rct_string_id object_manager_get_source_game_string(const uint8_t sourceGame);
|
||||
|
|
|
@ -112,7 +112,8 @@ public:
|
|||
item.ObjectEntry = *object->GetObjectEntry();
|
||||
item.Path = path;
|
||||
item.Name = object->GetName();
|
||||
item.Source = object->GetSecondSourceGame();
|
||||
item.Sources[0] = object->GetSourceGame();
|
||||
item.Sources[1] = object->GetSecondSourceGame();
|
||||
object->SetRepositoryItem(&item);
|
||||
delete object;
|
||||
return std::make_tuple(true, item);
|
||||
|
@ -126,7 +127,7 @@ protected:
|
|||
stream->WriteValue(item.ObjectEntry);
|
||||
stream->WriteString(item.Path);
|
||||
stream->WriteString(item.Name);
|
||||
stream->WriteValue(item.Source);
|
||||
stream->WriteArray(item.Sources, 2);
|
||||
|
||||
switch (object_entry_get_type(&item.ObjectEntry))
|
||||
{
|
||||
|
@ -159,7 +160,10 @@ protected:
|
|||
item.ObjectEntry = stream->ReadValue<rct_object_entry>();
|
||||
item.Path = stream->ReadStdString();
|
||||
item.Name = stream->ReadStdString();
|
||||
item.Source = stream->ReadValue<uint8_t>();
|
||||
auto sources = stream->ReadArray<uint8_t>(2);
|
||||
item.Sources[0] = sources[0];
|
||||
item.Sources[1] = sources[1];
|
||||
Memory::Free(sources);
|
||||
|
||||
switch (object_entry_get_type(&item.ObjectEntry))
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ struct ObjectRepositoryItem
|
|||
rct_object_entry ObjectEntry;
|
||||
std::string Path;
|
||||
std::string Name;
|
||||
uint8_t Source;
|
||||
uint8_t Sources[2];
|
||||
Object* LoadedObject{};
|
||||
struct
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue