Annotation of researchv10no/games/trek/initquad.c, revision 1.1

1.1     ! root        1: # include      "trek.h"
        !             2: 
        !             3: /**
        !             4:  **    initialize quadrant upon entering
        !             5:  **/
        !             6: 
        !             7: initquad(f)
        !             8: int    f;
        !             9: {
        !            10:        register int            i, j;
        !            11:        int                     rx, ry;
        !            12:        int                     nbases, nstars, nholes;
        !            13:        register QUAD           *q;
        !            14: 
        !            15:        q = &Quad[Quadx][Quady];
        !            16:        if (q->stars < 0)
        !            17:                return;
        !            18:        Nkling = q->qkling;
        !            19:        nholes = q->holes;
        !            20:        nbases = q->bases;
        !            21:        nstars = q->stars;
        !            22:        if (Nkling > 0 && !f)
        !            23:        {
        !            24:                printf("Condition RED\n");
        !            25:                Status.cond = RED;
        !            26:                if (!Damage[COMPUTER] && !Status.cloaked && !Damage[SHIELD] && !Status.shldup) {
        !            27:                        printf("Shields are down, %d%%.  ", effshld());
        !            28:                        if(getynpar("Do you want them up")==1)
        !            29:                                protect(0);
        !            30:                }
        !            31:        }
        !            32:        for (i = 0; i < NSECTS; i++)
        !            33:                for (j = 0; j < NSECTS; j++)
        !            34:                        Sect[i][j] = EMPTY;
        !            35: 
        !            36:        /* initialize Enterprise */
        !            37:        Sect[Sectx][Secty] = Status.ship;
        !            38: 
        !            39:        /* initialize Klingons */
        !            40:        for (i = 0; i < Nkling; i++)
        !            41:        {
        !            42:                sector(&rx, &ry);
        !            43:                Sect[rx][ry] = KLINGON;
        !            44:                Kling[i].x = rx;
        !            45:                Kling[i].y = ry;
        !            46:                Kling[i].power = Param.klingpwr;
        !            47:        }
        !            48:        compkldist(1);
        !            49: 
        !            50:        /* initialize star base */
        !            51:        if (nbases > 0)
        !            52:        {
        !            53:                sector(&rx, &ry);
        !            54:                Sect[rx][ry] = BASE;
        !            55:                Starbase.x = rx;
        !            56:                Starbase.y = ry;
        !            57:        }
        !            58: 
        !            59:        /* initialize inhabited starsystem */
        !            60:        if (q->systemname && (q->systemname&Q_GHOST)==0)
        !            61:        {
        !            62:                sector(&rx, &ry);
        !            63:                Sect[rx][ry] = INHABIT;
        !            64:                nstars =- 1;
        !            65:        }
        !            66: 
        !            67:        /* initialize stars */
        !            68:        for (i = 0; i < nstars; i++)
        !            69:        {
        !            70:                sector(&rx, &ry);
        !            71:                Sect[rx][ry] = STAR;
        !            72:        }
        !            73: 
        !            74:        /* initialise black holes */
        !            75:        for (i = 0; i < nholes; i++)
        !            76:        {
        !            77:                sector(&rx, &ry);
        !            78:                Sect[rx][ry] = BLACKHOLE;
        !            79:        }
        !            80:        Move.newquad = 1;
        !            81: }
        !            82: 
        !            83: 
        !            84: sector(x, y)
        !            85: int    *x, *y;
        !            86: {
        !            87:        register int            i, j;
        !            88: 
        !            89:        do
        !            90:        {
        !            91:                i = ranf(NSECTS);
        !            92:                j = ranf(NSECTS);
        !            93:        } while (Sect[i][j] != EMPTY);
        !            94:        *x = i;
        !            95:        *y = j;
        !            96:        return;
        !            97: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.