1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

do more cleanup of old object code

This commit is contained in:
Ted John
2016-07-02 22:13:37 +01:00
parent faf1f08b7f
commit 7124143b89
8 changed files with 62 additions and 261 deletions

View File

@@ -640,8 +640,6 @@ extern "C"
void reset_loaded_objects()
{
gTotalNoImages = 0xF26E;
for (int i = 0; i < 721; i++)
{
Object * object = _loadedObjects[i];
@@ -881,4 +879,61 @@ extern "C"
const Object * baseObject = (const Object *)object;
baseObject->DrawPreview(dpi);
}
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))
{
return 0;
}
int match = memcmp(a->name, b->name, 8);
if (match)
{
return 0;
}
}
else
{
if (a->flags != b->flags)
{
return 0;
}
int match = memcmp(a->name, b->name, 8);
if (match)
{
return 0;
}
if (a->checksum != b->checksum)
{
return 0;
}
}
return 1;
}
int object_calculate_checksum(const rct_object_entry * entry, const void * data, size_t dataLength)
{
const uint8 *entryBytePtr = (uint8*)entry;
uint32 checksum = 0xF369A75B;
checksum ^= entryBytePtr[0];
checksum = rol32(checksum, 11);
for (int i = 4; i < 12; i++)
{
checksum ^= entryBytePtr[i];
checksum = rol32(checksum, 11);
}
uint8 * dataBytes = (uint8 *)data;
for (size_t i = 0; i < dataLength; i++)
{
checksum ^= dataBytes[i];
checksum = rol32(checksum, 11);
}
return (int)checksum;
}
}