Fix machine envelope G-code emitting wrong limits due to broken extruder_id indexing (#12414)

print_machine_envelope() used get_extruder_id(extruder_id)*2 to index
machine limit arrays that only hold [Normal, Stealth] (2 entries).
For multi-extruder setups this went out-of-bounds, causing wrong M201/M203
values in the G-code which then override the estimator's correct limits.

Same class of bug as c6d1c11ebb but on the G-code writer side.

Changes:
- Remove unused extruder_id param from print_machine_envelope()
- Use .values.front() for M201/M203, matching M204/M205 in same function
- Change get_option_value() fallback from .back() to .front() so any
  future out-of-bounds index returns Normal mode instead of Stealth
This commit is contained in:
SoftFever
2026-02-22 16:13:06 +08:00
committed by GitHub
parent 859f401df5
commit c085eb845c
3 changed files with 12 additions and 13 deletions

View File

@@ -640,7 +640,7 @@ private:
double calc_max_volumetric_speed(const double layer_height, const double line_width, const std::string co_str);
std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
bool _needSAFC(const ExtrusionPath &path);
void print_machine_envelope(GCodeOutputStream& file, Print& print, int extruder_id);
void print_machine_envelope(GCodeOutputStream& file, Print& print);
void _print_first_layer_bed_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
void _print_first_layer_extruder_temperatures(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
// On the first printing layer. This flag triggers first layer speeds.