125996Smckusick /* 225996Smckusick * Copyright (c) 1980 Regents of the University of California. 3*34205Sbostic * All rights reserved. 4*34205Sbostic * 5*34205Sbostic * Redistribution and use in source and binary forms are permitted 6*34205Sbostic * provided that this notice is preserved and that due credit is given 7*34205Sbostic * to the University of California at Berkeley. The name of the University 8*34205Sbostic * may not be used to endorse or promote products derived from this 9*34205Sbostic * software without specific prior written permission. This software 10*34205Sbostic * is provided ``as is'' without express or implied warranty. 1125996Smckusick */ 1225996Smckusick 1311703Smckusick #ifndef lint 14*34205Sbostic static char sccsid[] = "@(#)visual.c 5.2 (Berkeley) 05/05/88"; 15*34205Sbostic #endif /* not lint */ 1611703Smckusick 1711703Smckusick # include "trek.h" 1811703Smckusick 1911703Smckusick /* 2011703Smckusick ** VISUAL SCAN 2111703Smckusick ** 2211703Smckusick ** A visual scan is made in a particular direction of three sectors 2311703Smckusick ** in the general direction specified. This takes time, and 2411703Smckusick ** Klingons can attack you, so it should be done only when sensors 2511703Smckusick ** are out. 2611703Smckusick */ 2711703Smckusick 2811703Smckusick /* This struct[] has the delta x, delta y for particular directions */ 2912738Slayer struct xy Visdelta[11] = 3011703Smckusick { 3111703Smckusick -1, -1, 3211703Smckusick -1, 0, 3311703Smckusick -1, 1, 3411703Smckusick 0, 1, 3511703Smckusick 1, 1, 3611703Smckusick 1, 0, 3711703Smckusick 1, -1, 3811703Smckusick 0, -1, 3911703Smckusick -1, -1, 4011703Smckusick -1, 0, 4111703Smckusick -1, 1 4211703Smckusick }; 4311703Smckusick 4411703Smckusick visual() 4511703Smckusick { 4611703Smckusick register int ix, iy; 4711703Smckusick int co; 4811703Smckusick register struct xy *v; 4911703Smckusick 5011703Smckusick co = getintpar("direction"); 5111703Smckusick if (co < 0 || co > 360) 5211703Smckusick return; 5311703Smckusick co = (co + 22) / 45; 5411703Smckusick v = &Visdelta[co]; 5511703Smckusick ix = Ship.sectx + v->x; 5611703Smckusick iy = Ship.secty + v->y; 5711703Smckusick if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS) 5811703Smckusick co = '?'; 5911703Smckusick else 6011703Smckusick co = Sect[ix][iy]; 6111703Smckusick printf("%d,%d %c ", ix, iy, co); 6211703Smckusick v++; 6311703Smckusick ix = Ship.sectx + v->x; 6411703Smckusick iy = Ship.secty + v->y; 6511703Smckusick if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS) 6611703Smckusick co = '?'; 6711703Smckusick else 6811703Smckusick co = Sect[ix][iy]; 6911703Smckusick printf("%c ", co); 7011703Smckusick v++; 7111703Smckusick ix = Ship.sectx + v->x; 7211703Smckusick iy = Ship.secty + v->y; 7311703Smckusick if (ix < 0 || ix >= NSECTS || iy < 0 || iy >= NSECTS) 7411703Smckusick co = '?'; 7511703Smckusick else 7611703Smckusick co = Sect[ix][iy]; 7711703Smckusick printf("%c %d,%d\n", co, ix, iy); 7811703Smckusick Move.time = 0.05; 7911703Smckusick Move.free = 0; 8011703Smckusick } 81