remove lots of old object code

This commit is contained in:
Ted John 2016-07-02 18:01:51 +01:00
parent 2cade7dd13
commit a47c039f22
10 changed files with 81 additions and 1658 deletions

View File

@ -124,15 +124,6 @@ void editor_convert_save_to_scenario_callback(int result)
s6Info->objective_arg_3 = gScenarioObjectiveNumGuests;
climate_reset(gClimate);
rct_stex_entry* stex = g_stexEntries[0];
if ((int)stex != 0xFFFFFFFF) {
object_unload_chunk((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]);
reset_loaded_objects();
format_string(s6Info->details, STR_NO_DETAILS_YET, NULL);
s6Info->name[0] = 0;
}
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
s6Info->editor_step = EDITOR_STEP_OBJECTIVE_SELECTION;
s6Info->category = SCENARIO_CATEGORY_OTHER;
@ -469,15 +460,6 @@ static void editor_clear_map_for_editing()
climate_reset(gClimate);
rct_stex_entry* stex = g_stexEntries[0];
if ((int)stex != 0xFFFFFFFF) {
object_unload_chunk((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]);
reset_loaded_objects();
format_string(gS6Info->details, STR_NO_DETAILS_YET, NULL);
gS6Info->name[0] = 0;
}
news_item_init_queue();
}

File diff suppressed because it is too large Load Diff

View File

@ -121,18 +121,13 @@ void set_load_objects_fail_reason();
bool object_read_and_load_entries(SDL_RWops* rw);
bool object_load_entries(rct_object_entry* entries);
int object_load_packed(SDL_RWops* rw);
bool object_saved_packed(SDL_RWops* rw, const rct_object_entry * entry);
void object_unload_all();
int check_object_entry(rct_object_entry *entry);
int object_load_chunk(int groupIndex, const rct_object_entry *entry, int* chunk_size);
void object_unload_chunk(rct_object_entry *entry);
int object_get_scenario_text(rct_object_entry *entry);
void object_free_scenario_text();
uintptr_t object_get_length(const rct_object_entry *entry);
int object_entry_compare(const rct_object_entry *a, const rct_object_entry *b);
int object_calculate_checksum(const rct_object_entry *entry, const uint8 *data, int dataLength);
rct_object_entry *object_get_next(const rct_object_entry *entry);
int write_object_file(SDL_RWops* rw, rct_object_entry* entry);
void reset_loaded_objects();
int find_object_in_entry_group(const rct_object_entry* entry, uint8* entry_type, uint8* entry_index);
void object_create_identifier_name(char* string_buffer, const rct_object_entry* object);
@ -140,14 +135,4 @@ void object_create_identifier_name(char* string_buffer, const rct_object_entry*
rct_object_entry *object_list_find_by_name(const char *name);
rct_object_entry *object_list_find(rct_object_entry *entry);
char *object_get_name(rct_object_entry *entry);
rct_object_filters *get_object_filter(int index);
bool object_load(int type, void *objectEntry, uint32 entryIndex);
void object_unload(int type, void *objectEntry);
bool object_test(int type, void *objectEntry);
void object_paint(int type, void *objectEntry, rct_drawpixelinfo *dpi, sint32 x, sint32 y);
rct_string_id object_desc(int type, void *objectEntry);
#endif

View File

@ -658,6 +658,12 @@ extern "C"
return (void *)object;
}
void * object_repository_get_loaded_object(uint8 objectType, uint8 entryIndex)
{
int index = GetObjectEntryIndex(objectType, entryIndex);
return (void *)_loadedObjects[index];
}
void object_repository_unload(size_t itemIndex)
{
// TODO
@ -758,6 +764,44 @@ extern "C"
return 1;
}
bool object_saved_packed(SDL_RWops * rw, const rct_object_entry * entry)
{
IObjectRepository * objectRepository = GetObjectRepository();
const ObjectRepositoryItem * item = objectRepository->FindObject(entry);
if (item == nullptr)
{
return false;
}
auto fs = FileStream(item->Path, FILE_MODE_OPEN);
rct_object_entry fileEntry = fs.ReadValue<rct_object_entry>();
if (!object_entry_compare(entry, &fileEntry))
{
return false;
}
sawyercoding_chunk_header chunkHeader = fs.ReadValue<sawyercoding_chunk_header>();
uint8 * chunkData = fs.ReadArray<uint8>(chunkHeader.length);
if (SDL_RWwrite(rw, entry, sizeof(rct_object_entry), 1) != 1)
{
Memory::Free(chunkData);
return false;
}
if (SDL_RWwrite(rw, &chunkHeader, sizeof(sawyercoding_chunk_header), 1) != 1)
{
Memory::Free(chunkData);
return false;
}
if (SDL_RWwrite(rw, chunkData, chunkHeader.length, 1) != 1)
{
Memory::Free(chunkData);
return false;
}
return true;
}
size_t object_repository_get_items_count()
{
IObjectRepository * objectRepository = GetObjectRepository();
@ -778,9 +822,12 @@ extern "C"
void object_delete(void * object)
{
Object * baseObject = (Object *)object;
baseObject->Unload();
delete baseObject;
if (object != nullptr)
{
Object * baseObject = (Object *)object;
baseObject->Unload();
delete baseObject;
}
}
const utf8 * object_get_description(const void * object)

View File

@ -77,6 +77,7 @@ size_t object_repository_get_items_count();
const ObjectRepositoryItem * object_repository_get_items();
const ObjectRepositoryItem * object_repository_find_object_by_entry(const rct_object_entry * entry);
void * object_repository_load_object(const rct_object_entry * objectEntry);
void * object_repository_get_loaded_object(uint8 objectType, uint8 entryIndex);
void object_repository_unload(size_t itemIndex);
void object_delete(void * object);

View File

@ -20,6 +20,7 @@
#include "localisation/localisation.h"
#include "object.h"
#include "object_list.h"
#include "object/ObjectRepository.h"
#include "platform/platform.h"
#include "rct1.h"
#include "ride/track.h"
@ -105,13 +106,14 @@ void *gLastLoadedObjectChunkData;
static uint32 object_list_count_custom_objects()
{
size_t numObjects = object_repository_get_items_count();
const ObjectRepositoryItem * items = object_repository_get_items();
uint32 numCustomObjects = 0;
rct_object_entry *object = gInstalledObjects;
for (uint32 i = 0; i < gInstalledObjectsCount; i++) {
if ((object->flags & 0xF0) == 0) {
for (size_t i = 0; i < numObjects; i++) {
if ((items[i].ObjectEntry.flags & 0xF0) == 0) {
numCustomObjects++;
}
object = object_get_next(object);
}
gNumInstalledCustomObjects = numCustomObjects;

View File

@ -319,16 +319,6 @@ void track_design_dispose(rct_track_td6 *td6)
}
}
uint32 *sub_6AB49A(rct_object_entry* entry)
{
rct_object_entry* object_list_entry = object_list_find(entry);
if (object_list_entry == NULL) return NULL;
// Return the address of the last value of the list entry
return (((uint32*)object_get_next(object_list_entry)) - 1);
}
/**
*
* rct2: 0x006ABDB0

View File

@ -727,7 +727,7 @@ int scenario_write_packed_objects(SDL_RWops* rw)
if (entryData == (void*)0xFFFFFFFF || (entry->flags & 0xF0)) {
continue;
}
if (!write_object_file(rw, (rct_object_entry*)entry)) {
if (!object_saved_packed(rw, (rct_object_entry*)entry)) {
return 0;
}
}

View File

@ -17,16 +17,17 @@
#include "../addresses.h"
#include "../cursors.h"
#include "../input.h"
#include "../interface/themes.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/research.h"
#include "../object.h"
#include "../world/scenery.h"
#include "../interface/themes.h"
#include "../object/ObjectRepository.h"
#include "../rct1.h"
#include "../util/util.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/scenery.h"
#pragma region Widgets
@ -772,9 +773,6 @@ static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo
return;
// Preview image
x = w->x + ((widget->left + widget->right) / 2) + 1;
y = w->y + ((widget->top + widget->bottom) / 2) + 1;
int objectEntryType = 7;
int eax = researchItem->entryIndex & 0xFFFFFF;
if (eax >= 0x10000)
@ -785,7 +783,19 @@ static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo
if (chunk == NULL || chunk == (void*)0xFFFFFFFF)
return;
object_paint(objectEntryType, chunk, dpi, x, y);
// Draw preview
widget = &w->widgets[WIDX_PREVIEW];
void * object = object_repository_get_loaded_object(objectEntryType, researchItem->entryIndex & 0xFF);
if (object != NULL) {
rct_drawpixelinfo clipDPI;
x = w->x + widget->left + 1;
y = w->y + widget->top + 1;
int width = widget->right - widget->left;
int height = widget->bottom - widget->top;
if (clip_drawpixelinfo(&clipDPI, dpi, x, y, width, height)) {
object_draw_preview(object, &clipDPI);
}
}
// Item name
x = w->x + ((widget->left + widget->right) / 2) + 1;

View File

@ -733,9 +733,11 @@ static void window_editor_object_selection_close(rct_window *w)
unload_unselected_objects();
editor_load_selected_objects();
reset_loaded_objects();
object_free_scenario_text();
editor_object_flags_free();
object_delete(_loadedObject);
_loadedObject = NULL;
if (gScreenFlags & SCREEN_FLAGS_EDITOR) {
research_populate_list_random();
}
@ -793,7 +795,6 @@ static void window_editor_object_selection_mouseup(rct_window *w, int widgetInde
w->selected_list_item = -1;
w->object_entry = (rct_object_entry *) 0xFFFFFFFF;
w->scrolls[0].v_top = 0;
object_free_scenario_text();
window_invalidate(w);
break;
case WIDX_FILTER_RIDE_TAB_TRANSPORT:
@ -813,7 +814,6 @@ static void window_editor_object_selection_mouseup(rct_window *w, int widgetInde
w->selected_list_item = -1;
w->object_entry = (rct_object_entry *) 0xFFFFFFFF;
w->scrolls[0].v_top = 0;
object_free_scenario_text();
window_invalidate(w);
break;
@ -825,7 +825,6 @@ static void window_editor_object_selection_mouseup(rct_window *w, int widgetInde
case WIDX_INSTALL_TRACK:
if (w->selected_list_item != -1) {
w->selected_list_item = -1;
object_free_scenario_text();
}
window_invalidate(w);
@ -1035,10 +1034,8 @@ static void window_editor_object_selection_scroll_mouseover(rct_window *w, int s
if (selectedObject != w->selected_list_item) {
w->selected_list_item = selectedObject;
if (_loadedObject != NULL) {
object_delete(_loadedObject);
_loadedObject = NULL;
}
object_delete(_loadedObject);
_loadedObject = NULL;
list_item * listItem = &_listItems[selectedObject];
if (selectedObject == -1) {
@ -1468,7 +1465,6 @@ static void window_editor_object_set_page(rct_window *w, int page)
w->selected_list_item = -1;
w->object_entry = (rct_object_entry *)0xFFFFFFFF;
w->scrolls[0].v_top = 0;
object_free_scenario_text();
if (page == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
_listSortType = RIDE_SORT_TYPE;