(svn r1427) fixed issue where the wrong sprite could be used if autoreplacing between single and multiheaded trains
authorbjarni
Sat, 08 Jan 2005 10:38:07 +0000
changeset 939 eec1a1fd1525
parent 938 23cc832ac8a2
child 940 d8143e65eb6b
(svn r1427) fixed issue where the wrong sprite could be used if autoreplacing between single and multiheaded trains
vehicle.c
--- a/vehicle.c	Sat Jan 08 09:48:08 2005 +0000
+++ b/vehicle.c	Sat Jan 08 10:38:07 2005 +0000
@@ -1505,8 +1505,12 @@
 
 				/* rvi->image_index is the new sprite for the engine. Adding +1 makes the engine head the other way
 				if it is a multiheaded engine (rear engine)
-				(sprite - rvi2->image_index) is 1 if the engine is heading the other way, otherwise 0*/
-				v->spritenum = rvi->image_index + (sprite - rvi2->image_index);
+				(rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) is true if the engine is heading the other way, otherwise 0*/
+				v->spritenum = rvi->image_index + (( rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) ? 1 : 0);
+				
+				// turn the last engine in a multiheaded train if needed
+				if ( v->next == NULL && rvi->flags & RVI_MULTIHEAD && v->spritenum == rvi->image_index )
+					v->spritenum++;
 				
 				v->cargo_type = rvi->cargo_type;
 				v->cargo_cap = rvi->capacity;