char * benum(c) { dest_no = c -= '0'; switch (dest_type) { case T_BEACON: if (c >= sp->num_beacons) return ("Unknown beacon"); p.new_dir = DIR_FROM_DXDY(sp->beacon[c].x - p.xpos, sp->beacon[c].y - p.ypos); break; case T_EXIT: if (c >= sp->num_exits) return ("Unknown exit"); p.new_dir = DIR_FROM_DXDY(sp->exit[c].x - p.xpos, sp->exit[c].y - p.ypos); break; case T_AIRPORT: if (c >= sp->num_airports) return ("Unknown airport"); p.new_dir = DIR_FROM_DXDY(sp->airport[c].x - p.xpos, sp->airport[c].y - p.ypos); break; default: return ("Unknown case in benum! Get help!"); break; } return (NULL); }
const char * delayb(char c) { int xdiff, ydiff; c -= '0'; if (c >= sp->num_beacons) return ("Unknown beacon"); xdiff = sp->beacon[(int)c].x - p.xpos; xdiff = SGN(xdiff); ydiff = sp->beacon[(int)c].y - p.ypos; ydiff = SGN(ydiff); if (xdiff != displacement[p.dir].dx || ydiff != displacement[p.dir].dy) return ("Beacon is not in flight path"); if (xdiff != 0 && ydiff !=0) if (abs(sp->beacon[(int)c].x - p.xpos) != abs(sp->beacon[(int)c].y - p.ypos)) return ("Beacon is not in flight path"); p.delayd = 1; p.delayd_no = c; if (dest_type != T_NODEST) { switch (dest_type) { case T_BEACON: xdiff = sp->beacon[dest_no].x - sp->beacon[(int)c].x; ydiff = sp->beacon[dest_no].y - sp->beacon[(int)c].y; break; case T_EXIT: xdiff = sp->exit[dest_no].x - sp->beacon[(int)c].x; ydiff = sp->exit[dest_no].y - sp->beacon[(int)c].y; break; case T_AIRPORT: xdiff = sp->airport[dest_no].x - sp->beacon[(int)c].x; ydiff = sp->airport[dest_no].y - sp->beacon[(int)c].y; break; default: return ("Bad case in delayb! Get help!"); break; } if (xdiff == 0 && ydiff == 0) return ("Would already be there"); p.new_dir = DIR_FROM_DXDY(xdiff, ydiff); if (p.new_dir == p.dir) return ("Already going in that direction"); } return (NULL); }