(svn r635) Fix choosing a spritegroup from deterministic variational spritegroups if there is no structure to search (i.e. in purchase lists) (pasky)
This commit is contained in:
		
							
								
								
									
										24
									
								
								engine.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								engine.c
									
									
									
									
									
								
							@@ -255,22 +255,36 @@ ResolveVehicleSpriteGroup(struct SpriteGroup *spritegroup, struct Vehicle *veh)
 | 
				
			|||||||
			struct SpriteGroup *target;
 | 
								struct SpriteGroup *target;
 | 
				
			||||||
			int value = -1;
 | 
								int value = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//debug("[%p] Having fun resolving variable %x", dsg->variable);
 | 
								//debug("[%p] Having fun resolving variable %x", veh, dsg->variable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ((dsg->variable >> 6) == 0) {
 | 
								if ((dsg->variable >> 6) == 0) {
 | 
				
			||||||
				/* General property */
 | 
									/* General property */
 | 
				
			||||||
				value = GetDeterministicSpriteValue(dsg->variable);
 | 
									value = GetDeterministicSpriteValue(dsg->variable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				/* Station-specific property. */
 | 
									/* Vehicle-specific property. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (veh == NULL) {
 | 
				
			||||||
 | 
										/* We are in a purchase list of something,
 | 
				
			||||||
 | 
										 * and we are checking for something undefined.
 | 
				
			||||||
 | 
										 * That means we should get the first target
 | 
				
			||||||
 | 
										 * (NOT the default one). */
 | 
				
			||||||
 | 
										if (dsg->num_ranges > 0) {
 | 
				
			||||||
 | 
											target = &dsg->ranges[0].group;
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											target = dsg->default_group;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return ResolveVehicleSpriteGroup(target, NULL);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (dsg->var_scope == VSG_SCOPE_PARENT) {
 | 
									if (dsg->var_scope == VSG_SCOPE_PARENT) {
 | 
				
			||||||
					/* First engine in the vehicle chain */
 | 
										/* First engine in the vehicle chain */
 | 
				
			||||||
					if (veh != NULL && veh->type == VEH_Train)
 | 
										if (veh->type == VEH_Train)
 | 
				
			||||||
						veh = GetFirstVehicleInChain(veh);
 | 
											veh = GetFirstVehicleInChain(veh);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (dsg->variable == 0x40) {
 | 
									if (dsg->variable == 0x40) {
 | 
				
			||||||
					if (veh && veh->type == VEH_Train) {
 | 
										if (veh->type == VEH_Train) {
 | 
				
			||||||
						Vehicle *u = GetFirstVehicleInChain(veh);
 | 
											Vehicle *u = GetFirstVehicleInChain(veh);
 | 
				
			||||||
						byte chain_before = 0, chain_after = 0;
 | 
											byte chain_before = 0, chain_after = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -293,7 +307,7 @@ ResolveVehicleSpriteGroup(struct SpriteGroup *spritegroup, struct Vehicle *veh)
 | 
				
			|||||||
					// TTDPatch runs on little-endian arch;
 | 
										// TTDPatch runs on little-endian arch;
 | 
				
			||||||
					// Variable is 0x80 + offset in TTD's vehicle structure
 | 
										// Variable is 0x80 + offset in TTD's vehicle structure
 | 
				
			||||||
					switch (dsg->variable - 0x80) {
 | 
										switch (dsg->variable - 0x80) {
 | 
				
			||||||
#define veh_prop(id_, value_) case id_: if (veh != NULL) value = value_; break /* XXX factorise "if" */
 | 
					#define veh_prop(id_, value_) case id_: value = value_; break
 | 
				
			||||||
						veh_prop(0x00, veh->type);
 | 
											veh_prop(0x00, veh->type);
 | 
				
			||||||
						veh_prop(0x01, veh->subtype);
 | 
											veh_prop(0x01, veh->subtype);
 | 
				
			||||||
						veh_prop(0x04, veh->index);
 | 
											veh_prop(0x04, veh->index);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1023,6 +1023,19 @@ ResolveStationSpriteGroup(struct SpriteGroup *spritegroup, struct Station *stat)
 | 
				
			|||||||
				value = GetDeterministicSpriteValue(dsg->variable);
 | 
									value = GetDeterministicSpriteValue(dsg->variable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
 | 
									if (stat == NULL) {
 | 
				
			||||||
 | 
										/* We are in a build dialog of something,
 | 
				
			||||||
 | 
										 * and we are checking for something undefined.
 | 
				
			||||||
 | 
										 * That means we should get the first target
 | 
				
			||||||
 | 
										 * (NOT the default one). */
 | 
				
			||||||
 | 
										if (dsg->num_ranges > 0) {
 | 
				
			||||||
 | 
											target = &dsg->ranges[0].group;
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											target = dsg->default_group;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return ResolveStationSpriteGroup(target, NULL);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				/* Station-specific property. */
 | 
									/* Station-specific property. */
 | 
				
			||||||
				if (dsg->var_scope == VSG_SCOPE_PARENT) {
 | 
									if (dsg->var_scope == VSG_SCOPE_PARENT) {
 | 
				
			||||||
					/* TODO: Town structure. */
 | 
										/* TODO: Town structure. */
 | 
				
			||||||
@@ -1039,25 +1052,25 @@ ResolveStationSpriteGroup(struct SpriteGroup *spritegroup, struct Station *stat)
 | 
				
			|||||||
						// Variable is 0x70 + offset in the TTD's station structure
 | 
											// Variable is 0x70 + offset in the TTD's station structure
 | 
				
			||||||
						switch (dsg->variable - 0x70) {
 | 
											switch (dsg->variable - 0x70) {
 | 
				
			||||||
							case 0x80:
 | 
												case 0x80:
 | 
				
			||||||
								if (stat) value = stat->facilities;
 | 
													value = stat->facilities;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
							case 0x81:
 | 
												case 0x81:
 | 
				
			||||||
								if (stat) value = stat->airport_type;
 | 
													value = stat->airport_type;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
							case 0x82:
 | 
												case 0x82:
 | 
				
			||||||
								if (stat) value = stat->truck_stop_status;
 | 
													value = stat->truck_stop_status;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
							case 0x83:
 | 
												case 0x83:
 | 
				
			||||||
								if (stat) value = stat->bus_stop_status;
 | 
													value = stat->bus_stop_status;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
							case 0x86:
 | 
												case 0x86:
 | 
				
			||||||
								if (stat) value = stat->airport_flags & 0xFFFF;
 | 
													value = stat->airport_flags & 0xFFFF;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
							case 0x87:
 | 
												case 0x87:
 | 
				
			||||||
								if (stat) value = stat->airport_flags & 0xFF;
 | 
													value = stat->airport_flags & 0xFF;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
							case 0x8A:
 | 
												case 0x8A:
 | 
				
			||||||
								if (stat) value = stat->build_date;
 | 
													value = stat->build_date;
 | 
				
			||||||
								break;
 | 
													break;
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user