8
|
1 /*--------------------------------------------------------------------------
|
|
2 NETREK II -- Paradise
|
|
3
|
|
4 Permission to use, copy, modify, and distribute this software and its
|
|
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
|
|
6 purpose and without fee is hereby granted, provided that this copyright
|
|
7 notice appear in all copies. No representations are made about the
|
|
8 suitability of this software for any purpose. This software is provided
|
|
9 "as is" without express or implied warranty.
|
|
10
|
|
11 Xtrek Copyright 1986 Chris Guthrie
|
|
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
|
|
13 Scott Silvey
|
|
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
|
|
15 Kurt Olsen
|
|
16 Brandon Gillespie
|
|
17 --------------------------------------------------------------------------*/
|
|
18
|
|
19 #include "config.h"
|
|
20
|
|
21 #include <stdio.h>
|
|
22
|
|
23 #include "defs.h"
|
|
24 #include "shmem.h"
|
|
25 #include "getship.h"
|
|
26 #include "data.h"
|
|
27
|
|
28 #define STEP 10
|
|
29 char *myname;
|
|
30
|
|
31 main(argc, argv)
|
|
32 int argc;
|
|
33 char **argv;
|
|
34 {
|
|
35 int i;
|
|
36 int player;
|
|
37 char buf[1000];
|
|
38 int c, seconds, part;
|
|
39
|
|
40 myname = argv[0];
|
|
41
|
|
42 if (argc > 3)
|
|
43 Usage();
|
|
44
|
|
45 if (argc == 2)
|
|
46 {
|
|
47 i = sscanf(argv[1], "%d", &seconds);
|
|
48 if (i != 1)
|
|
49 Usage();
|
|
50 if (seconds < 0)
|
|
51 Usage();
|
|
52 }
|
|
53 else
|
|
54 {
|
|
55 seconds = 10;
|
|
56 }
|
|
57 openmem(0);
|
|
58
|
|
59 part = seconds % STEP;
|
|
60 if (part)
|
|
61 sleep(part);
|
|
62
|
|
63 for (seconds -= part; seconds > 0; seconds -= STEP)
|
|
64 {
|
|
65 sprintf(buf, "%s->ALL ** Attention: The galaxy will be reset in %d seconds.", SERVNAME, seconds);
|
|
66 pmessage(buf, 0, MALL);
|
|
67 sleep(STEP);
|
|
68 }
|
|
69
|
|
70 sprintf(buf, "%s->ALL ** Manual galaxy reset **", SERVNAME);
|
|
71 pmessage(buf, 0, MALL);
|
|
72
|
|
73 zap();
|
|
74
|
|
75 /* *newgalaxy = 1; */
|
|
76 status2->newgalaxy = 1;
|
|
77 exit(0);
|
|
78 }
|
|
79
|
|
80 pmessage(str, recip, group)
|
|
81 char *str;
|
|
82 int recip;
|
|
83 int group;
|
|
84 {
|
|
85 struct message *cur;
|
|
86 if (++(mctl->mc_current) >= MAXMESSAGE)
|
|
87 mctl->mc_current = 0;
|
|
88 cur = &messages[mctl->mc_current];
|
|
89 cur->m_no = mctl->mc_current;
|
|
90 cur->m_flags = group;
|
|
91 cur->m_time = 0;
|
|
92 cur->m_from = 255; /* change 3/30/91 TC */
|
|
93 cur->m_recpt = recip;
|
|
94 (void) sprintf(cur->m_data, "%s", str);
|
|
95 cur->m_flags |= MVALID;
|
|
96 }
|
|
97
|
|
98
|
|
99 Usage()
|
|
100 {
|
|
101 int x;
|
|
102 char message[][255] = {
|
|
103 "\n\t'%s [n]'\n\n",
|
|
104 "Where n is the seconds until the galaxy is reset (default: 10)\n"
|
|
105 "\nThis tool resets the galaxy.\n",
|
|
106 ""
|
|
107 };
|
|
108
|
|
109 fprintf(stderr, "-- NetrekII (Paradise), %s --\n", PARAVERS);
|
|
110 for (x = 0; *message[x] != '\0'; x++)
|
|
111 fprintf(stderr, message[x], myname);
|
|
112
|
|
113 exit(1);
|
|
114 }
|
|
115
|
|
116 zap()
|
|
117 {
|
|
118 int player;
|
|
119
|
|
120 for (player = 0; player < MAXPLAYER; player++)
|
|
121 {
|
|
122 if (players[player].p_status == PFREE)
|
|
123 continue;
|
|
124 players[player].p_whydead = KPROVIDENCE;
|
|
125 players[player].p_whodead = 0;
|
|
126 players[player].p_status = PEXPLODE;
|
|
127 players[player].p_explode = 10;
|
|
128 players[player].p_ntorp = 0;
|
|
129 players[player].p_nplasmatorp = 0;
|
|
130 }
|
|
131 }
|