Changeset - r17200:ff0d682fa50c
[Not reviewed]
master
0 1 0
smatz - 13 years ago 2011-02-02 23:06:38
smatz@openttd.org
(svn r21949) -Change: randomize the vehicle a small UFO targets, do not use the one with lowest index
1 file changed with 18 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/disaster_cmd.cpp
Show inline comments
 
@@ -307,17 +307,28 @@ static bool DisasterTick_Ufo(DisasterVeh
 
		}
 
		v->current_order.SetDestination(1);
 

	
 
		uint n = 0; // Total number of targetable road vehicles.
 
		RoadVehicle *u;
 
		FOR_ALL_ROADVEHICLES(u) {
 
			if (u->IsFrontEngine()) {
 
				v->dest_tile = u->index;
 
				v->age = 0;
 
				return true;
 
			}
 
			if (u->IsFrontEngine()) n++;
 
		}
 

	
 
		if (n == 0) {
 
			/* If there are no targetable road vehicles, destroy the UFO. */
 
			delete v;
 
			return false;
 
		}
 

	
 
		delete v;
 
		return false;
 
		n = RandomRange(n); // Choose one of them.
 
		FOR_ALL_ROADVEHICLES(u) {
 
			/* Find (n+1)-th road vehicle. */
 
			if (u->IsFrontEngine() && (n-- == 0)) break;
 
		}
 

	
 
		/* Target it. */
 
		v->dest_tile = u->index;
 
		v->age = 0;
 
		return true;
 
	} else {
 
		/* Target a vehicle */
 
		RoadVehicle *u = RoadVehicle::Get(v->dest_tile);
0 comments (0 inline, 0 general)