Resume waypoint automatically

I need a function that when my copter come back to "Planned Home"point accidentally (not complete the mission,just for some emergencies like batteries have no power),after I reboot it,I want my copter return to the point where the mission stopped automatically.
What should I do?modify the source code or just set parameters in Mission Planner?