vehicle.c
changeset 1237 1c7a3f9c94b9
parent 1217 59c024cfaf54
child 1266 eccd576e322f
equal deleted inserted replaced
1236:928560eaf613 1237:1c7a3f9c94b9
  1329 	 This way the max is 6553 millions and it is more than the 32 bit that is stored in _patches
  1329 	 This way the max is 6553 millions and it is more than the 32 bit that is stored in _patches
  1330 	 This is a nice way to send 32 bit and only use 16 bit
  1330 	 This is a nice way to send 32 bit and only use 16 bit
  1331 	 the last 8 bit is the engine. The 8 bits in front of the engine is free so it have room for 16 bit engine entries */
  1331 	 the last 8 bit is the engine. The 8 bits in front of the engine is free so it have room for 16 bit engine entries */
  1332 	uint16 new_engine_type = (uint16)(p2 & 0xFFFF);
  1332 	uint16 new_engine_type = (uint16)(p2 & 0xFFFF);
  1333 	uint32 autorefit_money = (p2  >> 16) * 100000;
  1333 	uint32 autorefit_money = (p2  >> 16) * 100000;
  1334 	Vehicle *v = GetVehicle(p1);
  1334 	Vehicle *v, *u;
  1335 	int cost, build_cost, rear_engine_cost = 0;
  1335 	int cost, build_cost, rear_engine_cost = 0;
  1336 	Vehicle *u = v;
  1336 	byte old_engine_type;
  1337 	byte old_engine_type = v->engine_type;
  1337 
  1338 
  1338 	if (!IsVehicleIndex(p1)) return CMD_ERROR;
  1339 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
  1339 
  1340 
  1340 	v = u = GetVehicle(p1);
       
  1341 
       
  1342 	old_engine_type = v->engine_type;
  1341 
  1343 
  1342 	// first we make sure that it's a valid type the user requested
  1344 	// first we make sure that it's a valid type the user requested
  1343 	// check that it's an engine that is in the engine array
  1345 	// check that it's an engine that is in the engine array
  1344 	if (new_engine_type >= TOTAL_NUM_ENGINES ) return CMD_ERROR;
  1346 	if (new_engine_type >= TOTAL_NUM_ENGINES ) return CMD_ERROR;
  1345 
  1347 
  1634 int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
  1636 int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
  1635 {
  1637 {
  1636 	Vehicle *v;
  1638 	Vehicle *v;
  1637 	StringID str;
  1639 	StringID str;
  1638 
  1640 
       
  1641 	if (!IsVehicleIndex(p1)) return CMD_ERROR;
       
  1642 
  1639 	v = GetVehicle(p1);
  1643 	v = GetVehicle(p1);
  1640 
  1644 
  1641 	if (!CheckOwnership(v->owner))
  1645 	if (!CheckOwnership(v->owner))
  1642 		return CMD_ERROR;
  1646 		return CMD_ERROR;
  1643 
  1647