mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge branch 'refactor-object-paint' into develop
This commit is contained in:
commit
8f4c8006b5
|
@ -129,7 +129,7 @@ void editor_convert_save_to_scenario_callback(int result)
|
||||||
|
|
||||||
rct_stex_entry* stex = g_stexEntries[0];
|
rct_stex_entry* stex = g_stexEntries[0];
|
||||||
if ((int)stex != 0xFFFFFFFF) {
|
if ((int)stex != 0xFFFFFFFF) {
|
||||||
object_unload((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]);
|
object_unload_chunk((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]);
|
||||||
reset_loaded_objects();
|
reset_loaded_objects();
|
||||||
|
|
||||||
format_string(s6Info->details, STR_NO_DETAILS_YET, NULL);
|
format_string(s6Info->details, STR_NO_DETAILS_YET, NULL);
|
||||||
|
@ -464,7 +464,7 @@ static int editor_read_s6(const char *path)
|
||||||
|
|
||||||
rct_stex_entry* stex = g_stexEntries[0];
|
rct_stex_entry* stex = g_stexEntries[0];
|
||||||
if ((int)stex != 0xFFFFFFFF) {
|
if ((int)stex != 0xFFFFFFFF) {
|
||||||
object_unload((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]);
|
object_unload_chunk((rct_object_entry*)&object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0]);
|
||||||
reset_loaded_objects();
|
reset_loaded_objects();
|
||||||
|
|
||||||
format_string(s6Info->details, STR_NO_DETAILS_YET, NULL);
|
format_string(s6Info->details, STR_NO_DETAILS_YET, NULL);
|
||||||
|
|
|
@ -734,7 +734,7 @@ static void editor_load_selected_objects_console()
|
||||||
uint8 entry_index, entry_type;
|
uint8 entry_index, entry_type;
|
||||||
if (!find_object_in_entry_group(installed_entry, &entry_type, &entry_index)){
|
if (!find_object_in_entry_group(installed_entry, &entry_type, &entry_index)){
|
||||||
int chunk_size;
|
int chunk_size;
|
||||||
if (!object_load(-1, installed_entry, &chunk_size)) {
|
if (!object_load_chunk(-1, installed_entry, &chunk_size)) {
|
||||||
log_error("Failed to load entry %.8s", installed_entry->name);
|
log_error("Failed to load entry %.8s", installed_entry->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -773,7 +773,7 @@ static int cc_load_object(const utf8 **argv, int argc) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Load the obect
|
// Load the obect
|
||||||
if (!object_load(entryGroupIndex, &entry, NULL)) {
|
if (!object_load_chunk(entryGroupIndex, &entry, NULL)) {
|
||||||
console_writeline_error("Could not load object file.");
|
console_writeline_error("Could not load object file.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
2154
src/object.c
2154
src/object.c
File diff suppressed because it is too large
Load Diff
12
src/object.h
12
src/object.h
|
@ -22,6 +22,7 @@
|
||||||
#define _OBJECT_H_
|
#define _OBJECT_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "drawing/drawing.h"
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
|
|
||||||
// First 0xF of rct_object_entry->flags
|
// First 0xF of rct_object_entry->flags
|
||||||
|
@ -108,15 +109,14 @@ int object_load_packed(SDL_RWops* rw);
|
||||||
void object_unload_all();
|
void object_unload_all();
|
||||||
|
|
||||||
int check_object_entry(rct_object_entry *entry);
|
int check_object_entry(rct_object_entry *entry);
|
||||||
int object_load(int groupIndex, rct_object_entry *entry, int* chunk_size);
|
|
||||||
int object_load_file(int groupIndex, const rct_object_entry *entry, int* chunkSize, const rct_object_entry *installedObject);
|
int object_load_file(int groupIndex, const rct_object_entry *entry, int* chunkSize, const rct_object_entry *installedObject);
|
||||||
void object_unload(rct_object_entry *entry);
|
int object_load_chunk(int groupIndex, rct_object_entry *entry, int* chunk_size);
|
||||||
|
void object_unload_chunk(rct_object_entry *entry);
|
||||||
int object_get_scenario_text(rct_object_entry *entry);
|
int object_get_scenario_text(rct_object_entry *entry);
|
||||||
void object_free_scenario_text();
|
void object_free_scenario_text();
|
||||||
int object_get_length(rct_object_entry *entry);
|
int object_get_length(rct_object_entry *entry);
|
||||||
int object_entry_compare(const rct_object_entry *a, const rct_object_entry *b);
|
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);
|
int object_calculate_checksum(const rct_object_entry *entry, const uint8 *data, int dataLength);
|
||||||
int object_paint(int type, int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
|
||||||
rct_object_entry *object_get_next(rct_object_entry *entry);
|
rct_object_entry *object_get_next(rct_object_entry *entry);
|
||||||
int write_object_file(SDL_RWops* rw, rct_object_entry* entry);
|
int write_object_file(SDL_RWops* rw, rct_object_entry* entry);
|
||||||
void reset_loaded_objects();
|
void reset_loaded_objects();
|
||||||
|
@ -129,4 +129,10 @@ char *object_get_name(rct_object_entry *entry);
|
||||||
|
|
||||||
rct_object_filters *get_object_filter(int index);
|
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
|
#endif
|
||||||
|
|
|
@ -212,7 +212,7 @@ void reset_loaded_objects()
|
||||||
for (int j = 0; j < object_entry_group_counts[type]; j++){
|
for (int j = 0; j < object_entry_group_counts[type]; j++){
|
||||||
uint8* chunk = object_entry_groups[type].chunks[j];
|
uint8* chunk = object_entry_groups[type].chunks[j];
|
||||||
if (chunk != (uint8*)-1)
|
if (chunk != (uint8*)-1)
|
||||||
object_paint(type, 0, j, type, 0, (int)chunk, 0, 0);
|
object_load(type, chunk, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ int object_read_and_load_entries(SDL_RWops* rw)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the obect
|
// Load the obect
|
||||||
if (!object_load(entryGroupIndex, &entries[i], NULL)) {
|
if (!object_load_chunk(entryGroupIndex, &entries[i], NULL)) {
|
||||||
log_error("failed to load entry: %.8s", entries[i].name);
|
log_error("failed to load entry: %.8s", entries[i].name);
|
||||||
memcpy((char*)0x13CE952, &entries[i], sizeof(rct_object_entry));
|
memcpy((char*)0x13CE952, &entries[i], sizeof(rct_object_entry));
|
||||||
load_fail = 1;
|
load_fail = 1;
|
||||||
|
@ -579,7 +579,7 @@ void object_unload_all()
|
||||||
for (i = 0; i < OBJECT_ENTRY_GROUP_COUNT; i++)
|
for (i = 0; i < OBJECT_ENTRY_GROUP_COUNT; i++)
|
||||||
for (j = 0; j < object_entry_group_counts[i]; j++)
|
for (j = 0; j < object_entry_group_counts[i]; j++)
|
||||||
if (object_entry_groups[i].chunks[j] != (uint8*)0xFFFFFFFF)
|
if (object_entry_groups[i].chunks[j] != (uint8*)0xFFFFFFFF)
|
||||||
object_unload((rct_object_entry*)&object_entry_groups[i].entries[j]);
|
object_unload_chunk((rct_object_entry*)&object_entry_groups[i].entries[j]);
|
||||||
|
|
||||||
reset_loaded_objects();
|
reset_loaded_objects();
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in
|
||||||
log_error("Incorrect number of vanilla RCT2 objects.");
|
log_error("Incorrect number of vanilla RCT2 objects.");
|
||||||
gNumInstalledRCT2Objects--;
|
gNumInstalledRCT2Objects--;
|
||||||
gInstalledObjectsCount--;
|
gInstalledObjectsCount--;
|
||||||
object_unload(entry);
|
object_unload_chunk(entry);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -806,7 +806,7 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in
|
||||||
|
|
||||||
uint32 size_of_object = installed_entry_pointer - (uint8*)installed_entry;
|
uint32 size_of_object = installed_entry_pointer - (uint8*)installed_entry;
|
||||||
|
|
||||||
object_unload(entry);
|
object_unload_chunk(entry);
|
||||||
|
|
||||||
return size_of_object;
|
return size_of_object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,7 @@ static void rct1_load_default_objects()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object_load(j, &entries[j], NULL)) {
|
if (!object_load_chunk(j, &entries[j], NULL)) {
|
||||||
error_string_quit(0x99990000 + (i * 0x100) + j, -1);
|
error_string_quit(0x99990000 + (i * 0x100) + j, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ static void rct1_load_default_objects()
|
||||||
// Water is a special case
|
// Water is a special case
|
||||||
rct_object_entry *waterEntries = (rct_object_entry*)RCT1DefaultObjects[9].entries;
|
rct_object_entry *waterEntries = (rct_object_entry*)RCT1DefaultObjects[9].entries;
|
||||||
rct_object_entry *waterEntry = &waterEntries[RCT2_GLOBAL(0x01358841, uint8) == 0 ? 0 : 1];
|
rct_object_entry *waterEntry = &waterEntries[RCT2_GLOBAL(0x01358841, uint8) == 0 ? 0 : 1];
|
||||||
if (!object_load(0, waterEntry, NULL)) {
|
if (!object_load_chunk(0, waterEntry, NULL)) {
|
||||||
error_string_quit(0x99990900, -1);
|
error_string_quit(0x99990900, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3173,7 +3173,7 @@ rct_track_design *temp_track_get_info(char* path, uint8** preview)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object_load(0, &loaded_track->vehicle_object, NULL)){
|
if (!object_load_chunk(0, &loaded_track->vehicle_object, NULL)){
|
||||||
if (preview != NULL) *preview = NULL;
|
if (preview != NULL) *preview = NULL;
|
||||||
log_error("Failed to load track (vehicle load fail): %s", path);
|
log_error("Failed to load track (vehicle load fail): %s", path);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -787,7 +787,7 @@ static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo
|
||||||
if (chunk == NULL || chunk == (void*)0xFFFFFFFF)
|
if (chunk == NULL || chunk == (void*)0xFFFFFFFF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
object_paint(objectEntryType, 3, objectEntryType, x, y, 0, (int)dpi, (int)chunk);
|
object_paint(objectEntryType, chunk, dpi, x, y);
|
||||||
|
|
||||||
// Item name
|
// Item name
|
||||||
x = w->x + ((widget->left + widget->right) / 2) + 1;
|
x = w->x + ((widget->left + widget->right) / 2) + 1;
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
#include "../world/footpath.h"
|
#include "../world/footpath.h"
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
FILTER_RCT2 = (1 << 0),
|
FILTER_RCT2 = (1 << 0),
|
||||||
FILTER_WW = (1 << 1),
|
FILTER_WW = (1 << 1),
|
||||||
|
@ -757,7 +756,7 @@ void unload_unselected_objects(){
|
||||||
for (int i = gInstalledObjectsCount; i > 0; --i){
|
for (int i = gInstalledObjectsCount; i > 0; --i){
|
||||||
if (!(*selection_flags & OBJECT_SELECTION_FLAG_SELECTED)){
|
if (!(*selection_flags & OBJECT_SELECTION_FLAG_SELECTED)){
|
||||||
remove_selected_objects_from_research(installedObject);
|
remove_selected_objects_from_research(installedObject);
|
||||||
object_unload(installedObject);
|
object_unload_chunk(installedObject);
|
||||||
}
|
}
|
||||||
selection_flags++;
|
selection_flags++;
|
||||||
installedObject = object_get_next(installedObject);
|
installedObject = object_get_next(installedObject);
|
||||||
|
@ -1348,7 +1347,7 @@ static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinf
|
||||||
widget = &w->widgets[WIDX_PREVIEW];
|
widget = &w->widgets[WIDX_PREVIEW];
|
||||||
x = w->x + (widget->left + widget->right) / 2 + 1;
|
x = w->x + (widget->left + widget->right) / 2 + 1;
|
||||||
y = w->y + (widget->top + widget->bottom) / 2 + 1;
|
y = w->y + (widget->top + widget->bottom) / 2 + 1;
|
||||||
object_paint(type, 3, type, x, y, 0, (int)dpi, (int)stex_entry);
|
object_paint(type, stex_entry, dpi, x, y);
|
||||||
|
|
||||||
// Draw name of object
|
// Draw name of object
|
||||||
x = w->x + (widget->left + widget->right) / 2 + 1;
|
x = w->x + (widget->left + widget->right) / 2 + 1;
|
||||||
|
@ -1394,9 +1393,17 @@ static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinf
|
||||||
gfx_draw_string_centred_clipped(dpi, stringId, NULL, 0, x, y, width);
|
gfx_draw_string_centred_clipped(dpi, stringId, NULL, 0, x, y, width);
|
||||||
|
|
||||||
// Draw description of object
|
// Draw description of object
|
||||||
x = w->x + w->widgets[WIDX_LIST].right + 4;
|
stringId = object_desc(type, stex_entry);
|
||||||
y += 15;
|
if (stringId != STR_NONE) {
|
||||||
object_paint(type, 259, type, x, y, (int)w, (int)dpi, (int)stex_entry);
|
x = w->x + w->widgets[WIDX_LIST].right + 4;
|
||||||
|
y += 15;
|
||||||
|
int width = w->x + w->width - x - 4;
|
||||||
|
if (type == OBJECT_TYPE_SCENARIO_TEXT) {
|
||||||
|
gfx_draw_string_left_wrapped(dpi, &stringId, x, y, width, 3168, 0);
|
||||||
|
} else {
|
||||||
|
gfx_draw_string_left_wrapped(dpi, &stringId, x, y + 5, width, 1191, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw object source
|
// Draw object source
|
||||||
source = (highlightedEntry->flags & 0xF0) >> 4;
|
source = (highlightedEntry->flags & 0xF0) >> 4;
|
||||||
|
@ -1981,7 +1988,7 @@ static void editor_load_selected_objects()
|
||||||
uint8 entry_index, entry_type;
|
uint8 entry_index, entry_type;
|
||||||
if (!find_object_in_entry_group(installed_entry, &entry_type, &entry_index)){
|
if (!find_object_in_entry_group(installed_entry, &entry_type, &entry_index)){
|
||||||
int chunk_size;
|
int chunk_size;
|
||||||
if (!object_load(-1, installed_entry, &chunk_size)) {
|
if (!object_load_chunk(-1, installed_entry, &chunk_size)) {
|
||||||
log_error("Failed to load entry %.8s", installed_entry->name);
|
log_error("Failed to load entry %.8s", installed_entry->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue