engine.c
changeset 1196 115f46e3807d
parent 1096 ce698f7e4621
child 1197 4322cf8d6ae7
equal deleted inserted replaced
1195:95bbeb74ca13 1196:115f46e3807d
   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  *
       
   912  * engine = index of the engine to check
       
   913  * type   = the type the engine should be of (VEH_xxx)
       
   914  */
       
   915 bool IsEngineBuildable(int engine, byte type) {
       
   916 	Engine *e;
       
   917 
       
   918 	// check if it's an engine that is in the engine array
       
   919 	if (0 > engine || engine >= TOTAL_NUM_ENGINES ) return false;
       
   920 
       
   921 	e = DEREF_ENGINE(engine);
       
   922 
       
   923 	// check if it's an engine of specified type
       
   924 	if (e->type != type) return false;
       
   925 
       
   926 	// check if it's available
       
   927 	if (!HASBIT(e->player_avail, _current_player)) return false;
       
   928 
       
   929 	return true;
       
   930 }
       
   931 
       
   932 
       
   933 
       
   934