train_cmd.c
changeset 1137 bce056e230ce
parent 1132 71a2168ceee1
child 1151 06c115ce7b7a
equal deleted inserted replaced
1136:186d65f60c82 1137:bce056e230ce
  2359 	static int8 _random_dir_change[4] = { -1, 0, 0, 1};
  2359 	static int8 _random_dir_change[4] = { -1, 0, 0, 1};
  2360 
  2360 
  2361 	do {
  2361 	do {
  2362 		//I need to buffer the train direction
  2362 		//I need to buffer the train direction
  2363 		if (!(v->u.rail.track & 0x40))
  2363 		if (!(v->u.rail.track & 0x40))
  2364 			v->direction = (v->direction + _random_dir_change[InteractiveRandom()&3]) & 7;
  2364 			v->direction = (v->direction + _random_dir_change[Random()&3]) & 7;
  2365 		if (!(v->vehstatus & VS_HIDDEN)) {
  2365 		if (!(v->vehstatus & VS_HIDDEN)) {
  2366 			BeginVehicleMove(v);
  2366 			BeginVehicleMove(v);
  2367 			UpdateTrainDeltaXY(v, v->direction);
  2367 			UpdateTrainDeltaXY(v, v->direction);
  2368 			v->cur_image = GetTrainImage(v, v->direction);
  2368 			v->cur_image = GetTrainImage(v, v->direction);
  2369 			AfterSetTrainPos(v, false);
  2369 			AfterSetTrainPos(v, false);
  2379 
  2379 
  2380 	if ( (state == 4) && (v->u.rail.track != 0x40) ) {
  2380 	if ( (state == 4) && (v->u.rail.track != 0x40) ) {
  2381 		CreateEffectVehicleRel(v, 4, 4, 8, EV_CRASHED_SMOKE);
  2381 		CreateEffectVehicleRel(v, 4, 4, 8, EV_CRASHED_SMOKE);
  2382 	}
  2382 	}
  2383 
  2383 
  2384 	if (state <= 200 && (uint16)(r=InteractiveRandom()) <= 0x2492) {
  2384 	if (state <= 200 && (uint16)(r=Random()) <= 0x2492) {
  2385 		index = (r * 10 >> 16);
  2385 		index = (r * 10 >> 16);
  2386 
  2386 
  2387 		u = v;
  2387 		u = v;
  2388 		do {
  2388 		do {
  2389 			if (--index < 0) {
  2389 			if (--index < 0) {
  2390 				r = InteractiveRandom();
  2390 				r = Random();
  2391 
  2391 
  2392 				CreateEffectVehicleRel(u,
  2392 				CreateEffectVehicleRel(u,
  2393 					2 + ((r>>8)&7),
  2393 					2 + ((r>>8)&7),
  2394 					2 + ((r>>16)&7),
  2394 					2 + ((r>>16)&7),
  2395 					5 + (r&7),
  2395 					5 + (r&7),