src/autoreplace_cmd.cpp
changeset 7754 8e7205edd6c7
parent 7545 9a4834d48970
child 7988 6075538f6111
equal deleted inserted replaced
7753:624cc9dddfd2 7754:8e7205edd6c7
   136 
   136 
   137 	/* If the vehicle belongs to a group, check if the group is protected from the global autoreplace.
   137 	/* If the vehicle belongs to a group, check if the group is protected from the global autoreplace.
   138 	 *  If not, chek if an global auto replacement is defined */
   138 	 *  If not, chek if an global auto replacement is defined */
   139 	new_engine_type = (IsValidGroupID(old_v->group_id) && GetGroup(old_v->group_id)->replace_protection) ?
   139 	new_engine_type = (IsValidGroupID(old_v->group_id) && GetGroup(old_v->group_id)->replace_protection) ?
   140 			INVALID_ENGINE :
   140 			INVALID_ENGINE :
   141 			EngineReplacementForPlayer(p, old_v->engine_type, DEFAULT_GROUP);
   141 			EngineReplacementForPlayer(p, old_v->engine_type, ALL_GROUP);
   142 
   142 
   143 	/* If we don't set new_egnine_type previously, we try to check if an autoreplacement was defined
   143 	/* If we don't set new_egnine_type previously, we try to check if an autoreplacement was defined
   144 	 *  for the group and the engine_type of the vehicle */
   144 	 *  for the group and the engine_type of the vehicle */
   145 	if (new_engine_type == INVALID_ENGINE && !IsDefaultGroupID(old_v->group_id)) {
   145 	if (new_engine_type == INVALID_ENGINE && !IsAllGroupID(old_v->group_id)) {
   146 		new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type, old_v->group_id);
   146 		new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type, old_v->group_id);
   147 	}
   147 	}
   148 
   148 
   149 	if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type;
   149 	if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type;
   150 
   150 
   344 				/* If the vehicle belongs to a group, check if the group is protected from the global autoreplace.
   344 				/* If the vehicle belongs to a group, check if the group is protected from the global autoreplace.
   345 				   If not, chek if an global auto remplacement is defined */
   345 				   If not, chek if an global auto remplacement is defined */
   346 				if (IsValidGroupID(w->group_id)) {
   346 				if (IsValidGroupID(w->group_id)) {
   347 					if (!EngineHasReplacementForPlayer(p, w->engine_type, w->group_id) && (
   347 					if (!EngineHasReplacementForPlayer(p, w->engine_type, w->group_id) && (
   348 							GetGroup(w->group_id)->replace_protection ||
   348 							GetGroup(w->group_id)->replace_protection ||
   349 							!EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP))) {
   349 							!EngineHasReplacementForPlayer(p, w->engine_type, ALL_GROUP))) {
   350 						continue;
   350 						continue;
   351 					}
   351 					}
   352 				} else if (!EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP)) {
   352 				} else if (IsDefaultGroupID(w->group_id)) {
       
   353 					if (!EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP) &&
       
   354 							!EngineHasReplacementForPlayer(p, w->engine_type, ALL_GROUP)) {
       
   355 						continue;
       
   356 					}
       
   357 				} else if (!EngineHasReplacementForPlayer(p, w->engine_type, ALL_GROUP)) {
   353 					continue;
   358 					continue;
   354 				}
   359 				}
   355 			}
   360 			}
   356 
   361 
   357 			/* Now replace the vehicle */
   362 			/* Now replace the vehicle */