mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 10:51:58 -05:00
add large scenery object loading
This commit is contained in:
parent
2c02412f98
commit
958dfa6623
4 changed files with 175 additions and 0 deletions
|
@ -122,6 +122,7 @@
|
|||
<ClCompile Include="src\object\FootpathItemObject.cpp" />
|
||||
<ClCompile Include="src\object\FootpathObject.cpp" />
|
||||
<ClCompile Include="src\object\ImageTable.cpp" />
|
||||
<ClCompile Include="src\object\LargeSceneryObject.cpp" />
|
||||
<ClCompile Include="src\object\Object.cpp" />
|
||||
<ClCompile Include="src\object\ObjectFactory.cpp" />
|
||||
<ClCompile Include="src\object\ObjectRepository.cpp" />
|
||||
|
@ -433,6 +434,7 @@
|
|||
<ClInclude Include="src\object\FootpathItemObject.h" />
|
||||
<ClInclude Include="src\object\FootpathObject.h" />
|
||||
<ClInclude Include="src\object\ImageTable.h" />
|
||||
<ClInclude Include="src\object\LargeSceneryObject.h" />
|
||||
<ClInclude Include="src\object\Object.h" />
|
||||
<ClInclude Include="src\object\ObjectFactory.h" />
|
||||
<ClInclude Include="src\object\ObjectRepository.h" />
|
||||
|
|
121
src/object/LargeSceneryObject.cpp
Normal file
121
src/object/LargeSceneryObject.cpp
Normal file
|
@ -0,0 +1,121 @@
|
|||
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
||||
* For more information, visit https://github.com/OpenRCT2/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.
|
||||
*
|
||||
* A full copy of the GNU General Public License can be found in licence.txt
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
#include "LargeSceneryObject.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../localisation/localisation.h"
|
||||
}
|
||||
|
||||
enum OBJ_STRING_ID
|
||||
{
|
||||
OBJ_STRING_ID_NAME,
|
||||
};
|
||||
|
||||
LargeSceneryObject::~LargeSceneryObject()
|
||||
{
|
||||
Memory::Free(_3dFont);
|
||||
Memory::Free(_tiles);
|
||||
}
|
||||
|
||||
void LargeSceneryObject::ReadLegacy(IStream * stream)
|
||||
{
|
||||
_legacyType.name = stream->ReadValue<rct_string_id>();
|
||||
_legacyType.image = stream->ReadValue<uint32>();
|
||||
|
||||
_legacyType.large_scenery.tool_id = stream->ReadValue<uint8>();
|
||||
_legacyType.large_scenery.flags = stream->ReadValue<uint8>();
|
||||
_legacyType.large_scenery.price = stream->ReadValue<sint16>();
|
||||
_legacyType.large_scenery.removal_price = stream->ReadValue<sint16>();
|
||||
stream->Seek(4, STREAM_SEEK_CURRENT);
|
||||
_legacyType.large_scenery.scenery_tab_id = 0xFF;
|
||||
_legacyType.large_scenery.var_11 = stream->ReadValue<uint8>();
|
||||
stream->Seek(5, STREAM_SEEK_CURRENT);
|
||||
|
||||
StringTable.Read(stream, OBJ_STRING_ID_NAME);
|
||||
|
||||
_sceneryTabEntry = stream->ReadValue<rct_object_entry>();
|
||||
|
||||
if (_legacyType.large_scenery.flags & (1 << 2))
|
||||
{
|
||||
_3dFont = Memory::Allocate<rct_large_scenery_text>();
|
||||
stream->Read(_3dFont);
|
||||
_legacyType.large_scenery.text = _3dFont;
|
||||
}
|
||||
|
||||
_tiles = ReadTiles(stream);
|
||||
|
||||
ImageTable.Read(stream);
|
||||
}
|
||||
|
||||
void LargeSceneryObject::Load()
|
||||
{
|
||||
_legacyType.name = language_allocate_object_string(GetName());
|
||||
_legacyType.image = gfx_object_allocate_images(ImageTable.GetImages(), ImageTable.GetCount());
|
||||
|
||||
_legacyType.large_scenery.scenery_tab_id = 0xFF;
|
||||
if ((_sceneryTabEntry.flags & 0xFF) != 0xFF)
|
||||
{
|
||||
uint8 entryType, entryIndex;
|
||||
if (find_object_in_entry_group(&_sceneryTabEntry, &entryType, &entryIndex))
|
||||
{
|
||||
_legacyType.large_scenery.scenery_tab_id = entryIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (_legacyType.large_scenery.flags & (1 << 2))
|
||||
{
|
||||
_legacyType.large_scenery.text_image = _legacyType.image;
|
||||
if (_3dFont->var_C & (1 << 0))
|
||||
{
|
||||
_legacyType.image += (_3dFont->var_C >> 8) * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_legacyType.image += (_3dFont->var_C >> 8) * 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LargeSceneryObject::Unload()
|
||||
{
|
||||
language_free_object_string(_legacyType.name);
|
||||
gfx_object_free_images(_legacyType.image, ImageTable.GetCount());
|
||||
}
|
||||
|
||||
const utf8 * LargeSceneryObject::GetName()
|
||||
{
|
||||
return StringTable.GetString(OBJ_STRING_ID_NAME);
|
||||
}
|
||||
|
||||
rct_large_scenery_tile * LargeSceneryObject::ReadTiles(IStream * stream)
|
||||
{
|
||||
auto tiles = std::vector<rct_large_scenery_tile>();
|
||||
|
||||
uint16 tilesEndMarker;
|
||||
while ((tilesEndMarker = stream->ReadValue<uint16>()) != 0xFFFF)
|
||||
{
|
||||
stream->Seek(-2, STREAM_SEEK_CURRENT);
|
||||
auto tile = stream->ReadValue<rct_large_scenery_tile>();
|
||||
tiles.push_back(tile);
|
||||
}
|
||||
|
||||
return Memory::DuplicateArray(tiles.data(), tiles.size());
|
||||
}
|
48
src/object/LargeSceneryObject.h
Normal file
48
src/object/LargeSceneryObject.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
||||
* For more information, visit https://github.com/OpenRCT2/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.
|
||||
*
|
||||
* A full copy of the GNU General Public License can be found in licence.txt
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../world/scenery.h"
|
||||
}
|
||||
|
||||
class LargeSceneryObject : public Object
|
||||
{
|
||||
private:
|
||||
rct_scenery_entry _legacyType;
|
||||
rct_object_entry _sceneryTabEntry;
|
||||
rct_large_scenery_text * _3dFont;
|
||||
rct_large_scenery_tile * _tiles;
|
||||
|
||||
public:
|
||||
explicit LargeSceneryObject(const rct_object_entry &entry) : Object(entry) { };
|
||||
~LargeSceneryObject();
|
||||
|
||||
void * GetLegacyData() override { return &_legacyType; }
|
||||
|
||||
void ReadLegacy(IStream * stream) override;
|
||||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
const utf8 * GetName() override;
|
||||
|
||||
private:
|
||||
static rct_large_scenery_tile * ReadTiles(IStream * stream);
|
||||
};
|
|
@ -20,6 +20,7 @@
|
|||
#include "EntranceObject.h"
|
||||
#include "FootpathItemObject.h"
|
||||
#include "FootpathObject.h"
|
||||
#include "LargeSceneryObject.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "RideObject.h"
|
||||
|
@ -72,6 +73,9 @@ namespace ObjectFactory
|
|||
case OBJECT_TYPE_SMALL_SCENERY:
|
||||
result = new SmallSceneryObject(entry);
|
||||
break;
|
||||
case OBJECT_TYPE_LARGE_SCENERY:
|
||||
result = new LargeSceneryObject(entry);
|
||||
break;
|
||||
case OBJECT_TYPE_PATHS:
|
||||
result = new FootpathObject(entry);
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue