summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--projects/openttd_vs100.vcxproj2
-rw-r--r--projects/openttd_vs100.vcxproj.filters6
-rw-r--r--projects/openttd_vs80.vcproj8
-rw-r--r--projects/openttd_vs90.vcproj8
-rw-r--r--source.list2
-rw-r--r--src/newgrf_object.cpp28
-rw-r--r--src/newgrf_object.h74
-rw-r--r--src/object.h61
-rw-r--r--src/object_cmd.cpp12
-rw-r--r--src/table/object_land.h2
-rw-r--r--src/tunnelbridge_cmd.cpp2
11 files changed, 133 insertions, 72 deletions
diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
index 606bf37eb..ba1959fe4 100644
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -485,6 +485,7 @@
<ClInclude Include="..\src\newgrf_house.h" />
<ClInclude Include="..\src\newgrf_industries.h" />
<ClInclude Include="..\src\newgrf_industrytiles.h" />
+ <ClInclude Include="..\src\newgrf_object.h" />
<ClInclude Include="..\src\newgrf_properties.h" />
<ClInclude Include="..\src\newgrf_railtype.h" />
<ClInclude Include="..\src\newgrf_sound.h" />
@@ -983,6 +984,7 @@
<ClCompile Include="..\src\newgrf_house.cpp" />
<ClCompile Include="..\src\newgrf_industries.cpp" />
<ClCompile Include="..\src\newgrf_industrytiles.cpp" />
+ <ClCompile Include="..\src\newgrf_object.cpp" />
<ClCompile Include="..\src\newgrf_railtype.cpp" />
<ClCompile Include="..\src\newgrf_sound.cpp" />
<ClCompile Include="..\src\newgrf_spritegroup.cpp" />
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
index c03d46079..763f8a1f6 100644
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -675,6 +675,9 @@
<ClInclude Include="..\src\newgrf_industrytiles.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\src\newgrf_object.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\src\newgrf_properties.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -2169,6 +2172,9 @@
<ClCompile Include="..\src\newgrf_industrytiles.cpp">
<Filter>NewGRF</Filter>
</ClCompile>
+ <ClCompile Include="..\src\newgrf_object.cpp">
+ <Filter>NewGRF</Filter>
+ </ClCompile>
<ClCompile Include="..\src\newgrf_railtype.cpp">
<Filter>NewGRF</Filter>
</ClCompile>
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 41e823f7c..f4847190d 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1215,6 +1215,10 @@
>
</File>
<File
+ RelativePath=".\..\src\newgrf_object.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\newgrf_properties.h"
>
</File>
@@ -3275,6 +3279,10 @@
>
</File>
<File
+ RelativePath=".\..\src\newgrf_object.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\newgrf_railtype.cpp"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 994b21a9d..39b1b191d 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1212,6 +1212,10 @@
>
</File>
<File
+ RelativePath=".\..\src\newgrf_object.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\newgrf_properties.h"
>
</File>
@@ -3272,6 +3276,10 @@
>
</File>
<File
+ RelativePath=".\..\src\newgrf_object.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\newgrf_railtype.cpp"
>
</File>
diff --git a/source.list b/source.list
index 4456052c9..81ed3d34b 100644
--- a/source.list
+++ b/source.list
@@ -218,6 +218,7 @@ newgrf_generic.h
newgrf_house.h
newgrf_industries.h
newgrf_industrytiles.h
+newgrf_object.h
newgrf_properties.h
newgrf_railtype.h
newgrf_sound.h
@@ -772,6 +773,7 @@ newgrf_generic.cpp
newgrf_house.cpp
newgrf_industries.cpp
newgrf_industrytiles.cpp
+newgrf_object.cpp
newgrf_railtype.cpp
newgrf_sound.cpp
newgrf_spritegroup.cpp
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
new file mode 100644
index 000000000..4728f876a
--- /dev/null
+++ b/src/newgrf_object.cpp
@@ -0,0 +1,28 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD 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, version 2.
+ * OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file newgrf_object.cpp Handling of object NewGRFs. */
+
+#include "stdafx.h"
+#include "newgrf_object.h"
+#include "object_map.h"
+
+extern const ObjectSpec _original_objects[];
+
+/* static */ const ObjectSpec *ObjectSpec::Get(ObjectType index)
+{
+ assert(index < OBJECT_MAX);
+ return &_original_objects[index];
+}
+
+/* static */ const ObjectSpec *ObjectSpec::GetByTile(TileIndex tile)
+{
+ return ObjectSpec::Get(GetObjectType(tile));
+}
+
diff --git a/src/newgrf_object.h b/src/newgrf_object.h
new file mode 100644
index 000000000..37b74a160
--- /dev/null
+++ b/src/newgrf_object.h
@@ -0,0 +1,74 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD 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, version 2.
+ * OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file newgrf_object.h Functions related to NewGRF objects. */
+
+#ifndef NEWGRF_OBJECT_H
+#define NEWGRF_OBJECT_H
+
+#include "economy_func.h"
+#include "strings_type.h"
+#include "object_type.h"
+
+/** Various object behaviours. */
+enum ObjectFlags {
+ OBJECT_FLAG_NONE = 0, ///< Just nothing.
+ OBJECT_FLAG_ONLY_IN_SCENEDIT = 1 << 0, ///< Object can only be constructed in the scenario editor.
+ OBJECT_FLAG_CANNOT_REMOVE = 1 << 1, ///< Object can not be removed.
+ OBJECT_FLAG_AUTOREMOVE = 1 << 2, ///< Object get automatically removed (like "owned land").
+ OBJECT_FLAG_BUILT_ON_WATER = 1 << 3, ///< Object can be built on water (not required).
+ OBJECT_FLAG_CLEAR_INCOME = 1 << 4, ///< When object is cleared a positive income is generated instead of a cost.
+ OBJECT_FLAG_HAS_NO_FOUNDATION = 1 << 5, ///< Do not display foundations when on a slope.
+ OBJECT_FLAG_ANIMATION = 1 << 6, ///< Object has animated tiles.
+ OBJECT_FLAG_ONLY_IN_GAME = 1 << 7, ///< Object can only be built in game.
+ OBJECT_FLAG_2CC_COLOUR = 1 << 8, ///< Object wants 2CC colour mapping.
+ OBJECT_FLAG_NOT_ON_LAND = 1 << 9, ///< Object can not be on land, implicitly sets #OBJECT_FLAG_BUILT_ON_WATER.
+ OBJECT_FLAG_DRAW_WATER = 1 << 10, ///< Object wants to be drawn on water.
+ OBJECT_FLAG_ALLOW_UNDER_BRIDGE = 1 << 11, ///< Object can built under a bridge.
+ OBJECT_FLAG_REQUIRE_FLAT = 1 << 12, ///< Object can only be build of flat land, i.e. not on foundations!
+};
+DECLARE_ENUM_AS_BIT_SET(ObjectFlags)
+
+
+/** An object that isn't use for transport, industries or houses. */
+struct ObjectSpec {
+ StringID name; ///< The name for this object.
+ uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y.
+ uint8 build_cost_multiplier; ///< Build cost multiplier per tile.
+ uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile.
+ ObjectFlags flags; ///< Flags/settings related to the object.
+
+ /**
+ * Get the cost for building a structure of this type.
+ * @return The cost for building.
+ */
+ Money GetBuildCost() const { return (_price[PR_BUILD_OBJECT] * this->build_cost_multiplier); }
+
+ /**
+ * Get the cost for clearing a structure of this type.
+ * @return The cost for clearing.
+ */
+ Money GetClearCost() const { return (_price[PR_CLEAR_OBJECT] * this->clear_cost_multiplier); }
+
+ /**
+ * Get the specification associated with a specific ObjectType.
+ * @param index The object type to fetch.
+ * @return The specification.
+ */
+ static const ObjectSpec *Get(ObjectType index);
+
+ /**
+ * Get the specification associated with a tile.
+ * @param tile The tile to fetch the data for.
+ * @return The specification.
+ */
+ static const ObjectSpec *GetByTile(TileIndex tile);
+};
+
+#endif /* NEWGRF_OBJECT_H */
diff --git a/src/object.h b/src/object.h
index f07ab3039..834cd8c9a 100644
--- a/src/object.h
+++ b/src/object.h
@@ -12,8 +12,8 @@
#ifndef OBJECT_H
#define OBJECT_H
-#include "economy_func.h"
-#include "strings_type.h"
+#include "tile_type.h"
+#include "company_type.h"
#include "object_type.h"
/**
@@ -34,61 +34,4 @@ void UpdateCompanyHQ(TileIndex tile, uint score);
*/
void BuildObject(ObjectType type, TileIndex tile, CompanyID owner = OWNER_NONE, struct Town *town = NULL);
-
-/** Various object behaviours. */
-enum ObjectFlags {
- OBJECT_FLAG_NONE = 0, ///< Just nothing.
- OBJECT_FLAG_ONLY_IN_SCENEDIT = 1 << 0, ///< Object can only be constructed in the scenario editor.
- OBJECT_FLAG_CANNOT_REMOVE = 1 << 1, ///< Object can not be removed.
- OBJECT_FLAG_AUTOREMOVE = 1 << 2, ///< Object get automatically removed (like "owned land").
- OBJECT_FLAG_BUILT_ON_WATER = 1 << 3, ///< Object can be built on water (not required).
- OBJECT_FLAG_CLEAR_INCOME = 1 << 4, ///< When object is cleared a positive income is generated instead of a cost.
- OBJECT_FLAG_HAS_NO_FOUNDATION = 1 << 5, ///< Do not display foundations when on a slope.
- OBJECT_FLAG_ANIMATION = 1 << 6, ///< Object has animated tiles.
- OBJECT_FLAG_ONLY_IN_GAME = 1 << 7, ///< Object can only be built in game.
- OBJECT_FLAG_2CC_COLOUR = 1 << 8, ///< Object wants 2CC colour mapping.
- OBJECT_FLAG_NOT_ON_LAND = 1 << 9, ///< Object can not be on land, implicitly sets #OBJECT_FLAG_BUILT_ON_WATER.
- OBJECT_FLAG_DRAW_WATER = 1 << 10, ///< Object wants to be drawn on water.
- OBJECT_FLAG_ALLOW_UNDER_BRIDGE = 1 << 11, ///< Object can built under a bridge.
- OBJECT_FLAG_REQUIRE_FLAT = 1 << 12, ///< Object can only be build of flat land, i.e. not on foundations!
-};
-DECLARE_ENUM_AS_BIT_SET(ObjectFlags)
-
-
-/** An object that isn't use for transport, industries or houses. */
-struct ObjectSpec {
- StringID name; ///< The name for this object.
- uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y.
- uint8 build_cost_multiplier; ///< Build cost multiplier per tile.
- uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile.
- ObjectFlags flags; ///< Flags/settings related to the object.
-
- /**
- * Get the cost for building a structure of this type.
- * @return The cost for building.
- */
- Money GetBuildCost() const { return (_price[PR_BUILD_OBJECT] * this->build_cost_multiplier); }
-
- /**
- * Get the cost for clearing a structure of this type.
- * @return The cost for clearing.
- */
- Money GetClearCost() const { return (_price[PR_CLEAR_OBJECT] * this->clear_cost_multiplier); }
-
- /**
- * Get the specification associated with a specific ObjectType.
- * @param index The object type to fetch.
- * @return The specification.
- */
- static const ObjectSpec *Get(ObjectType index);
-
- /**
- * Get the specification associated with a tile.
- * @param tile The tile to fetch the data for.
- * @return The specification.
- */
- static const ObjectSpec *GetByTile(TileIndex tile);
-};
-
-
#endif /* OBJECT_H */
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 0385b28a9..c92ff4580 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -30,6 +30,7 @@
#include "core/pool_func.hpp"
#include "object_map.h"
#include "object_base.h"
+#include "newgrf_object.h"
#include "date_func.h"
#include "table/strings.h"
@@ -49,17 +50,6 @@ void InitializeObjects()
_object_pool.CleanPool();
}
-/* static */ const ObjectSpec *ObjectSpec::Get(ObjectType index)
-{
- assert(index < OBJECT_MAX);
- return &_original_objects[index];
-}
-
-/* static */ const ObjectSpec *ObjectSpec::GetByTile(TileIndex tile)
-{
- return ObjectSpec::Get(GetObjectType(tile));
-}
-
void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town)
{
const ObjectSpec *spec = ObjectSpec::Get(type);
diff --git a/src/table/object_land.h b/src/table/object_land.h
index a445296b2..1085550cb 100644
--- a/src/table/object_land.h
+++ b/src/table/object_land.h
@@ -124,7 +124,7 @@ static const DrawTileSprites _object_hq[] = {
#undef TILE_SPRITE_LINE
/** Specification of the original object structures. */
-static const ObjectSpec _original_objects[] = {
+extern const ObjectSpec _original_objects[] = {
{ STR_LAI_OBJECT_DESCRIPTION_TRANSMITTER, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_REQUIRE_FLAT | OBJECT_FLAG_ONLY_IN_SCENEDIT },
{ STR_LAI_OBJECT_DESCRIPTION_LIGHTHOUSE, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_REQUIRE_FLAT | OBJECT_FLAG_ONLY_IN_SCENEDIT },
{ STR_TOWN_BUILDING_NAME_STATUE_1, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_ONLY_IN_GAME | OBJECT_FLAG_ONLY_IN_SCENEDIT }, // Yes, we disallow building this everywhere. Happens in "special" case!
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index e920d279a..315806f71 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -14,7 +14,7 @@
*/
#include "stdafx.h"
-#include "object.h"
+#include "newgrf_object.h"
#include "viewport_func.h"
#include "cmd_helper.h"
#include "command_func.h"