engine.c
changeset 1197 433b4a05fa3e
parent 1196 67f7f3017d99
child 1299 39c06aba09aa
equal deleted inserted replaced
1196:67f7f3017d99 1197:433b4a05fa3e
   904 const ChunkHandler _engine_chunk_handlers[] = {
   904 const ChunkHandler _engine_chunk_handlers[] = {
   905 	{ 'ENGN', Save_ENGN, Load_ENGN, CH_ARRAY},
   905 	{ 'ENGN', Save_ENGN, Load_ENGN, CH_ARRAY},
   906 	{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF | CH_LAST},
   906 	{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF | CH_LAST},
   907 };
   907 };
   908 
   908 
       
   909 
   909 /*
   910 /*
   910  * returns true if an engine is valid, and it is of the specified type, and buildable by the current player, false otherwise
   911  * returns true if an engine is valid, of the specified type, and buildable by
       
   912  * the current player, false otherwise
   911  *
   913  *
   912  * engine = index of the engine to check
   914  * engine = index of the engine to check
   913  * type   = the type the engine should be of (VEH_xxx)
   915  * type   = the type the engine should be of (VEH_xxx)
   914  */
   916  */
   915 bool IsEngineBuildable(int engine, byte type) {
   917 bool IsEngineBuildable(uint engine, byte type)
   916 	Engine *e;
   918 {
       
   919 	const Engine *e;
   917 
   920 
   918 	// check if it's an engine that is in the engine array
   921 	// check if it's an engine that is in the engine array
   919 	if (0 > engine || engine >= TOTAL_NUM_ENGINES ) return false;
   922 	if (engine >= TOTAL_NUM_ENGINES) return false;
   920 
   923 
   921 	e = DEREF_ENGINE(engine);
   924 	e = DEREF_ENGINE(engine);
   922 
   925 
   923 	// check if it's an engine of specified type
   926 	// check if it's an engine of specified type
   924 	if (e->type != type) return false;
   927 	if (e->type != type) return false;
   926 	// check if it's available
   929 	// check if it's available
   927 	if (!HASBIT(e->player_avail, _current_player)) return false;
   930 	if (!HASBIT(e->player_avail, _current_player)) return false;
   928 
   931 
   929 	return true;
   932 	return true;
   930 }
   933 }
   931 
       
   932 
       
   933 
       
   934