# 2.11BSD#431 - /usr/src/games/trek/schedule.c

##### Functions

    reschedule        X
    schedule          X
    unschedule        X
    xresched          X
    xsched            X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)schedule.c	5.1 (Berkeley) 5/30/85";
       9: #endif not lint
      10:
      11: # include   "trek.h"
      12:
      13: /*
      14: **  SCHEDULE AN EVENT
      15: **
      16: **	An event of type 'type' is scheduled for time NOW + 'offset'
      17: **	into the first available slot.  'x', 'y', and 'z' are
      18: **	considered the attributes for this event.
      19: **
      20: **	The address of the slot is returned.
      21: */
      22:
      23: struct event *schedule(type, offset, x, y, z)
      24: int type;
      25: double  offset;
      26: char    x, y;
      27: char    z;
      28: {
      29:     register struct event   *e;
      30:     register int        i;
      31:     double          date;
      32:
      33:     date = Now.date + offset;
      34:     for (i = 0; i < MAXEVENTS; i++)
      35:     {
      36:         e = &Event[i];
      37:         if (e->evcode)
      38:             continue;
      39:         /* got a slot */
      40: #		ifdef xTRACE
      41:         if (Trace)
      42:             printf("schedule: type %d @ %.2f slot %d parm %d %d %d\n",
      43:                 type, date, i, x, y, z);
      44: #		endif
      45:         e->evcode = type;
      46:         e->date = date;
      47:         e->x = x;
      48:         e->y = y;
      49:         e->systemname = z;
      50:         Now.eventptr[type] = e;
      51:         return (e);
      52:     }
      53:     syserr("Cannot schedule event %d parm %d %d %d", type, x, y, z);
      54: }
      55:
      56:
      57: /*
      58: **  RESCHEDULE AN EVENT
      59: **
      60: **	The event pointed to by 'e' is rescheduled to the current
      61: **	time plus 'offset'.
      62: */
      63:
      64: reschedule(e1, offset)
      65: struct event    *e1;
      66: double      offset;
      67: {
      68:     double          date;
      69:     register struct event   *e;
      70:
      71:     e = e1;
      72:
      73:     date = Now.date + offset;
      74:     e->date = date;
      75: #	ifdef xTRACE
      76:     if (Trace)
      77:         printf("reschedule: type %d parm %d %d %d @ %.2f\n",
      78:             e->evcode, e->x, e->y, e->systemname, date);
      79: #	endif
      80:     return;
      81: }
      82:
      83:
      84: /*
      85: **  UNSCHEDULE AN EVENT
      86: **
      87: **	The event at slot 'e' is deleted.
      88: */
      89:
      90: unschedule(e1)
      91: struct event    *e1;
      92: {
      93:     register struct event   *e;
      94:
      95:     e = e1;
      96:
      97: #	ifdef xTRACE
      98:     if (Trace)
      99:         printf("unschedule: type %d @ %.2f parm %d %d %d\n",
     100:             e->evcode, e->date, e->x, e->y, e->systemname);
     101: #	endif
     102:     Now.eventptr[e->evcode & E_EVENT] = 0;
     103:     e->date = 1e50;
     104:     e->evcode = 0;
     105:     return;
     106: }
     107:
     108:
     109: /*
     110: **  Abreviated schedule routine
     111: **
     112: **	Parameters are the event index and a factor for the time
     113: **	figure.
     114: */
     115:
     116: struct event *xsched(ev1, factor, x, y, z)
     117: int ev1;
     118: int factor;
     119: int x, y, z;
     120: {
     121:     register int    ev;
     122:
     123:     ev = ev1;
     124:     return (schedule(ev, -Param.eventdly[ev] * Param.time * log(franf()) / factor, x, y, z));
     125: }
     126:
     127:
     128: /*
     129: **  Simplified reschedule routine
     130: **
     131: **	Parameters are the event index, the initial date, and the
     132: **	division factor.  Look at the code to see what really happens.
     133: */
     134:
     135: xresched(e1, ev1, factor)
     136: struct event    *e1;
     137: int     ev1;
     138: int     factor;
     139: {
     140:     register int        ev;
     141:     register struct event   *e;
     142:
     143:     ev = ev1;
     144:     e = e1;
     145:     reschedule(e, -Param.eventdly[ev] * Param.time * log(franf()) / factor);
     146: }

#### Defined functions

reschedule defined in line 64; used 8 times

- in line 145
- in /usr/src/games/trek/damage.c line 60
- in /usr/src/games/trek/dock.c line 82, 114
- in /usr/src/games/trek/dumpme.c line 55
- in /usr/src/games/trek/events.c line 188, 373
- in /usr/src/games/trek/warp.c line 144

schedule defined in line 23; used 6 times

- in line 124
- in /usr/src/games/trek/damage.c line 49
- in /usr/src/games/trek/events.c line 31, 53, 282
- in /usr/src/games/trek/kill.c line 107

unschedule defined in line 90; used 12 times

- in /usr/src/games/trek/abandon.c line 88
- in /usr/src/games/trek/dumpssradio.c line 32
- in /usr/src/games/trek/events.c line 155, 210, 270, 301, 369, 378, 418
- in /usr/src/games/trek/kill.c line 149, 181, 192

xresched defined in line 135; used 6 times

- in /usr/src/games/trek/events.c line 110-115(2), 192, 229, 305, 358

xsched defined in line 116; used 8 times

- in /usr/src/games/trek/events.c line 31, 193, 254
- in /usr/src/games/trek/setup.c line 181-185(5)

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1985-05-30 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 575 |