/************************************************************************ ** ** FILE : cellkalook.c ** ** ZWECK : ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "cellkalook.h" #include "cell.H" #include "cell.h" #include #define vorzeichen( x) ((x)>0 ? 1 : ((x) == 0 ? 0 : (-1))) /************************************************************************* ** FUNKTION: CellKaLookFor ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ char CellKaLookFor( mx1, my1, mx2, my2, nr1, nr2) int mx1, my1; int mx2, my2; int nr1, nr2; { OBJECT *c; int x1 = CellXKoord( mx1); int y1 = CellYKoord( my1); int x2 = CellXKoord( mx2); int y2 = CellYKoord( my2); int dx, dy; int dxabs, dyabs; int i, j; int px, py; int sdx, sdy; int x, y; dx = x2-x1; /* Steigung fuer x */ dy = y2-y1; /* Steigung fuer y */ sdx = vorzeichen( dx); /* Steigungsrichtung x */ sdy = vorzeichen( dy); /* Steigungsrichtung y */ dxabs = abs( dx); /* |Steigung x| */ dyabs = abs( dy); /* |Steigung y| */ x = 0; y = 0; px = x1; py = y1; if (dxabs >= dyabs) for (i=0; i= dxabs) { y -= dxabs; py += sdy; } if ( (c = Cell[ px][ py]) ) do { if ( ((c->typ == CE_STELLE) && (c->Nr1 != nr1)) || ((c->typ == CE_TRANSITION) && (c->Nr1 != nr2)) ) return (c->typ); c = c->next; } while (c); px += sdx; } else for (i=0; i= dyabs) { x -= dyabs; px += sdx; } if ( (c = Cell[ px][ py]) ) do { if ( ((c->typ == CE_STELLE) && (c->Nr1 != nr1)) || ((c->typ == CE_TRANSITION) && (c->Nr1 != nr2)) ) return (c->typ); c = c->next; } while (c); py += sdy; } return CE_OK; }