mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 10:51:58 -05:00
add water object loading
This commit is contained in:
parent
6912c537bb
commit
25af7d346c
4 changed files with 112 additions and 0 deletions
|
@ -133,6 +133,7 @@
|
|||
<ClCompile Include="src\object\StexObject.cpp" />
|
||||
<ClCompile Include="src\object\StringTable.cpp" />
|
||||
<ClCompile Include="src\object\WallObject.cpp" />
|
||||
<ClCompile Include="src\object\WaterObject.cpp" />
|
||||
<ClCompile Include="src\object_list.c" />
|
||||
<ClCompile Include="src\openrct2.c" />
|
||||
<ClCompile Include="src\paint\map_element\banner.c" />
|
||||
|
@ -448,6 +449,7 @@
|
|||
<ClInclude Include="src\object\StexObject.h" />
|
||||
<ClInclude Include="src\object\StringTable.h" />
|
||||
<ClInclude Include="src\object\WallObject.h" />
|
||||
<ClInclude Include="src\object\WaterObject.h" />
|
||||
<ClInclude Include="src\object_list.h" />
|
||||
<ClInclude Include="src\openrct2.h" />
|
||||
<ClInclude Include="src\paint\map_element\map_element.h" />
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "SmallSceneryObject.h"
|
||||
#include "StexObject.h"
|
||||
#include "WallObject.h"
|
||||
#include "WaterObject.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -97,6 +98,9 @@ namespace ObjectFactory
|
|||
case OBJECT_TYPE_PARK_ENTRANCE:
|
||||
result = new EntranceObject(entry);
|
||||
break;
|
||||
case OBJECT_TYPE_WATER:
|
||||
result = new WaterObject(entry);
|
||||
break;
|
||||
case OBJECT_TYPE_SCENARIO_TEXT:
|
||||
result = new StexObject(entry);
|
||||
break;
|
||||
|
|
65
src/object/WaterObject.cpp
Normal file
65
src/object/WaterObject.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#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 "WaterObject.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../addresses.h"
|
||||
#include "../localisation/localisation.h"
|
||||
}
|
||||
|
||||
enum OBJ_STRING_ID
|
||||
{
|
||||
OBJ_STRING_ID_NAME,
|
||||
};
|
||||
|
||||
void WaterObject::ReadLegacy(IStream * stream)
|
||||
{
|
||||
_legacyType.string_idx = stream->ReadValue<rct_string_id>();
|
||||
_legacyType.image_id = stream->ReadValue<uint32>();
|
||||
_legacyType.var_06 = stream->ReadValue<uint32>();
|
||||
_legacyType.var_0A = stream->ReadValue<uint32>();
|
||||
_legacyType.var_0E = stream->ReadValue<uint16>();
|
||||
|
||||
StringTable.Read(stream, OBJ_STRING_ID_NAME);
|
||||
ImageTable.Read(stream);
|
||||
}
|
||||
|
||||
void WaterObject::Load()
|
||||
{
|
||||
_legacyType.string_idx = language_allocate_object_string(GetName());
|
||||
_legacyType.image_id = gfx_object_allocate_images(ImageTable.GetImages(), ImageTable.GetCount());
|
||||
_legacyType.var_06 = _legacyType.image_id + 1;
|
||||
_legacyType.var_0A = _legacyType.image_id + 4;
|
||||
|
||||
if (RCT2_GLOBAL(0x009ADAFD, uint8) == 0)
|
||||
{
|
||||
load_palette();
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
}
|
||||
|
||||
void WaterObject::Unload()
|
||||
{
|
||||
language_free_object_string(_legacyType.string_idx);
|
||||
}
|
||||
|
||||
const utf8 * WaterObject::GetName()
|
||||
{
|
||||
return StringTable.GetString(OBJ_STRING_ID_NAME);
|
||||
}
|
41
src/object/WaterObject.h
Normal file
41
src/object/WaterObject.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#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/water.h"
|
||||
}
|
||||
|
||||
class WaterObject : public Object
|
||||
{
|
||||
private:
|
||||
rct_water_type _legacyType;
|
||||
|
||||
public:
|
||||
explicit WaterObject(const rct_object_entry &entry) : Object(entry) { };
|
||||
|
||||
void * GetLegacyData() override { return &_legacyType; }
|
||||
|
||||
void ReadLegacy(IStream * stream) override;
|
||||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
const utf8 * GetName() override;
|
||||
};
|
Loading…
Add table
Reference in a new issue