summaryrefslogtreecommitdiff
path: root/engine.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-27 21:00:05 +0000
committerbjarni <bjarni@openttd.org>2005-01-27 21:00:05 +0000
commit99338d278da52e2f71fe8c4d3f05449a1ad24144 (patch)
tree5bdf21fd520f2315aba284830d98f9db10e8e388 /engine.c
parent1ae9e7b4480865289c2793ac1f9bad53090d5d40 (diff)
downloadopenttd-99338d278da52e2f71fe8c4d3f05449a1ad24144.tar.xz
(svn r1700) - Fix: Hacked clients can no longer be used to build vehicles that are not available yet (Hackykid)
Diffstat (limited to 'engine.c')
-rw-r--r--engine.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/engine.c b/engine.c
index c6cc4bf4c..93cba6351 100644
--- a/engine.c
+++ b/engine.c
@@ -906,5 +906,29 @@ const ChunkHandler _engine_chunk_handlers[] = {
{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF | CH_LAST},
};
+/*
+ * returns true if an engine is valid, and it is of the specified type, and buildable by the current player, false otherwise
+ *
+ * engine = index of the engine to check
+ * type = the type the engine should be of (VEH_xxx)
+ */
+bool IsEngineBuildable(int engine, byte type) {
+ Engine *e;
+
+ // check if it's an engine that is in the engine array
+ if (0 > engine || engine >= TOTAL_NUM_ENGINES ) return false;
+
+ e = DEREF_ENGINE(engine);
+
+ // check if it's an engine of specified type
+ if (e->type != type) return false;
+
+ // check if it's available
+ if (!HASBIT(e->player_avail, _current_player)) return false;
+
+ return true;
+}
+
+