mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
add some object loading
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
<ClInclude Include="..\src\intro.h" />
|
||||
<ClInclude Include="..\src\map.h" />
|
||||
<ClInclude Include="..\src\news_item.h" />
|
||||
<ClInclude Include="..\src\object.h" />
|
||||
<ClInclude Include="..\src\osinterface.h" />
|
||||
<ClInclude Include="..\src\park.h" />
|
||||
<ClInclude Include="..\src\peep.h" />
|
||||
@@ -55,6 +56,7 @@
|
||||
<ClCompile Include="..\src\intro.c" />
|
||||
<ClCompile Include="..\src\map.c" />
|
||||
<ClCompile Include="..\src\news_item.c" />
|
||||
<ClCompile Include="..\src\object.c" />
|
||||
<ClCompile Include="..\src\osinterface.c" />
|
||||
<ClCompile Include="..\src\park.c" />
|
||||
<ClCompile Include="..\src\peep.c" />
|
||||
|
||||
@@ -102,6 +102,9 @@
|
||||
<ClInclude Include="..\src\sawyercoding.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\object.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\game.c">
|
||||
@@ -191,6 +194,9 @@
|
||||
<ClCompile Include="..\src\sawyercoding.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\object.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\openrct2.exe">
|
||||
|
||||
60
src/object.c
Normal file
60
src/object.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014 Ted John
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "object.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006A8B40
|
||||
*/
|
||||
void object_load_list()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A8B40);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006AA0C6
|
||||
*/
|
||||
void object_read_and_load_entries(HFILE hFile)
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006AA0C6);
|
||||
|
||||
// int i;
|
||||
// rct_object_entry *entries;
|
||||
// entries = malloc(721 * sizeof(rct_object_entry));
|
||||
// sawyercoding_read_chunk(hFile, entries);
|
||||
// for (i = 0; i < 721; i++) {
|
||||
// RCT2_CALLPROC_X(0x006A985D, 0, 0, i, 0, 0, 0, 0);
|
||||
// }
|
||||
// free(entries);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006AA2B7
|
||||
*/
|
||||
int object_load_packed()
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
RCT2_CALLFUNC_X(0x006AA2B7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
return eax;
|
||||
}
|
||||
41
src/object.h
Normal file
41
src/object.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014 Ted John
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _OBJECT_H_
|
||||
#define _OBJECT_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include "rct2.h"
|
||||
|
||||
/**
|
||||
* Object entry structure.
|
||||
* size: 0x0100
|
||||
*/
|
||||
typedef struct {
|
||||
uint32 var_00;
|
||||
char name[8]; // 0x04
|
||||
uint32 var_0C;
|
||||
} rct_object_entry;
|
||||
|
||||
void object_load_list();
|
||||
void object_read_and_load_entries(HFILE hFile);
|
||||
int object_load_packed();
|
||||
|
||||
#endif
|
||||
@@ -80,11 +80,11 @@ static int decode_chunk_rle(char *buffer, int length)
|
||||
rleCodeByte = src[i];
|
||||
if (rleCodeByte & 128) {
|
||||
i++;
|
||||
count = 1 - rleCodeByte + 256;
|
||||
count = 257 - rleCodeByte;
|
||||
for (j = 0; j < count; j++)
|
||||
*dst++ = src[i];
|
||||
} else {
|
||||
for (j = 0; j < rleCodeByte; j++)
|
||||
for (j = 0; j <= rleCodeByte; j++)
|
||||
*dst++ = src[++i];
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ static int decode_chunk_repeat(char *buffer, int length)
|
||||
if (src[i] == 0xFF) {
|
||||
*dst++ = src[++i];
|
||||
} else {
|
||||
count = src[i] & 7;
|
||||
count = (src[i] & 7) + 1;
|
||||
copyOffset = dst + (int)(src[i] >> 3) - 32;
|
||||
for (j = 0; j < count; j++)
|
||||
*dst++ = *copyOffset++;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <windows.h>
|
||||
#include "addresses.h"
|
||||
#include "map.h"
|
||||
#include "object.h"
|
||||
#include "rct2.h"
|
||||
#include "sawyercoding.h"
|
||||
#include "scenario.h"
|
||||
@@ -303,17 +304,6 @@ static int scenario_load_basic(char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006AA2B7
|
||||
*/
|
||||
static int object_load_packed()
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
RCT2_CALLFUNC_X(0x006AA2B7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
return eax;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00676053
|
||||
@@ -326,10 +316,6 @@ void scenario_load(char *path)
|
||||
rct_s6_header *s6Header = 0x009E34E4;
|
||||
rct_s6_info *s6Info = 0x0141F570;
|
||||
|
||||
strcpy(RCT2_ADDRESS(0x0141EF68, char), path);
|
||||
RCT2_CALLPROC_EBPSAFE(0x00676053);
|
||||
return;
|
||||
|
||||
hFile = CreateFile(
|
||||
path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL
|
||||
);
|
||||
@@ -348,11 +334,10 @@ void scenario_load(char *path)
|
||||
for (i = 0; i < s6Header->num_packed_objects; i++)
|
||||
j += object_load_packed();
|
||||
if (j > 0)
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A8B40); // object_load_list
|
||||
object_load_list();
|
||||
}
|
||||
|
||||
// Read available items (721 * 16)
|
||||
RCT2_CALLPROC_EBPSAFE(0x006AA0C6);
|
||||
object_read_and_load_entries(hFile);
|
||||
|
||||
// Read flags (16 bytes)
|
||||
sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_MONTH_YEAR);
|
||||
|
||||
Reference in New Issue
Block a user