/************************************************************************ ** ** FILE : cellste.c ** ** ZWECK : ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "cellste.h" #include "cellein.h" #include "celldel.h" #include "ste.h" #include "cell.h" #include "cell.H" #include /************************************************************************* ** FUNKTION: CellSteLookFor ** ZWECK: Schaut in Cell nach, ob in dieser Gegend Platz fuer ** eine Stelle frei ist. ** INPUT: Mittelpunktkoordinaten der Stelle ** Falls Stelle bereits eingezeichnet, dann kann mit SNr ** die Nr der Stelle angegeben werden. Stelle und Stellenname ** werden dann ignoriert. Das ist dann sinnvoll, falls eine ** bereits existierende Stelle verschoben werden soll. ** OUTPUT: char = CE_OK oder den Typ des Objekts, das im Weg ist *************************************************************************/ char CellSteLookFor( SNr, mx, my) int SNr; int mx, my; { OBJECT *p; register int x; register int y; int cX1 = CellXKoord( mx - HA_STE_RAD); int cY1 = CellYKoord( my - HA_STE_RAD); int cX2 = CellXKoord( mx + HA_STE_RAD); int cY2 = CellYKoord( my + HA_STE_RAD); if (SNr == CE_NOTHING) for (x=cX1; x <= cX2; x++) for (y=cY1; y <= cY2; y++) if (Cell[ x][ y]) return (Cell[ x][ y]->typ); else for (x=cX1; x <= cX2; x++) for (y=cY1; y <= cY2; y++) if ((p = Cell[ x][ y])) do if ( (p->Nr1 == SNr) && ( (p->typ == CE_STELLE) || (p->typ == CE_STE_NAME) ) ) p = p->next; else return (p->typ); while (p); return (CE_OK); } /************************************************************************* ** FUNKTION: CellSteEin ** ZWECK: Traegt Stelle in Cell ein. ** INPUT: Stellennummer und Mittelpunkt in Plane-Koordinaten ** OUTPUT: - ** ANMERK: - allokiere ein Original STELLE ** - verweise leere Cellen auf Original STELLE ** - nichtleere Cellen: ** - allokiere Original ANDERES_OBJEKT ** - verweise bish. letztes Element auf Original ANDERES_OBJEKT ** - verweise Nachfolgeelement auf Original STELLE *************************************************************************/ void CellSteEin( SNr, mx, my) int SNr; int mx, my; { register int x; register int y; int cX1 = CellXKoord( mx - HA_STE_RAD); int cY1 = CellYKoord( my - HA_STE_RAD); int cX2 = CellXKoord( mx + HA_STE_RAD); int cY2 = CellYKoord( my + HA_STE_RAD); OBJECT *O; O = SteStelle[ SNr]->OrgSte; /* Fehler: darf nicht leer sein */ for (x=cX1; x <= cX2; x++) for (y=cY1; y <= cY2; y++) if ( !(Cell[ x][ y]) ) Cell[ x][ y] = O; else CellObjEin( &(Cell[ x][ y]), O); } /************************************************************************* ** FUNKTION: CellSteRemove ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void CellSteRemove( SNr) int SNr; { register int x; register int y; int mx = SteStelle[ SNr]->PosStelle.x; int my = SteStelle[ SNr]->PosStelle.y; int cX1, cX2, cY1, cY2; OBJECT *O; cX1 = CellXKoord( mx - HA_STE_RAD); cY1 = CellYKoord( my - HA_STE_RAD); cX2 = CellXKoord( mx + HA_STE_RAD); cY2 = CellYKoord( my + HA_STE_RAD); O = SteStelle[ SNr]->OrgSte; for (x=cX1; x <= cX2; x++) for (y=cY1; y <= cY2; y++) CellObjDel( &(Cell[ x][ y]), CE_STELLE, SNr); }