Refactored script_rid2sd (#2062)
It now matches the other script_***2sd or script_***2bl functions.
Also added script_mapid2sd for mapid to map session lookups.
Cleaned up the order of some of the checks in the script functions that used script_rid2sd and sometimes checked the validity of the retrieved session to late or even never at all.