707707
708708function AIUtil .getWidth (vehicle )
709709 if vehicle .getAIAgentSize then
710- local width , length , lengthOffset , frontOffset , height = vehicle :getAIAgentSize ()
710+ --- Due to invalid implement ai comfigurations this function call might break the save ...
711+ --- So we try it and except the callstack, as every good vehicle/implement should cause this function to fail ..
712+ local valid , width = CpUtil .try (vehicle .getAIAgentSize , vehicle )
713+ if not valid then
714+ return vehicle .size .width
715+ end
711716 return width
712717 else
713718 return vehicle .size .width
@@ -716,10 +721,15 @@ end
716721
717722function AIUtil .getLength (vehicle )
718723 if vehicle .getAIAgentSize then
719- vehicle :updateAIAgentAttachments ()
720- local width , length , lengthOffset , frontOffset , height = vehicle :getAIAgentSize ()
721- for _ , attachment in ipairs (vehicle .spec_aiDrivable .attachments ) do
722- length = length + attachment .length
724+ --- Due to invalid implement ai comfigurations these function calls might break the save ...
725+ --- So we try it and except the callstack, as every good vehicle/implement should cause this function to fail ..
726+ local valid = CpUtil .try (vehicle .updateAIAgentAttachments , vehicle )
727+ if not valid then
728+ return vehicle .size .length
729+ end
730+ local valid , width , length , lengthOffset , frontOffset , height = CpUtil .try (vehicle .getAIAgentSize , vehicle )
731+ if not valid then
732+ return vehicle .size .length
723733 end
724734 return length
725735 else
0 commit comments