-
Notifications
You must be signed in to change notification settings - Fork 4
/
log.c
executable file
·336 lines (298 loc) · 6.3 KB
/
log.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#include "scepter.h"
static void AnnounceLogin(void);
static void SetStats(ChType Cl, int Vit, int Fat, int Mag, int Mony);
static void AnnounceLogin(void)
{
User->Status = SNormal;
*User->LastCmd = '\0';
if (User->LastAccess != Today)
{
User->LastAccess = Today;
if (User->TGuild || User->AGuild)
{
User->Money = MaxL(0L, User->Money - User->Lvl * 20);
if (!User->Money)
{
QOut(Term, "0You have not the funds to pay your dues!");
QOut(Term, "0You have been expelled from the guild.");
User->AGuild = User->TGuild = FALSE;
}
else
{
sprintf(B1, "0Daily %d guild fee paid in full. Thank you!",
User->Lvl * 20);
QOut(Term, B1);
}
}
}
CmdCode = 0;
sprintf(B1, "0### Please welcome %s, the %s.",
User->Name, CName[(int) User->Class]);
AllMsg(B1);
if (!User->SSJ && (User->Invisible || User->NonExistant))
User->NonExistant = User->Invisible = FALSE;
if (User->Invisible)
{
sprintf(B1, "0You are currently %s.",
User->NonExistant ? "nonexistant" : "invisible");
QOut(Term, B1);
}
RoomDisplay(User->RmCode, User->Brief);
}
UserPoint Login(void)
{
UserPoint NewUser;
NUsers++;
NewUser = malloc(sizeof(UserType));
*NewUser = ProtoUser;
sprintf(B1, "0Scepter Fantasy Role-Playing Game Ver 2.4.3 (Run %d)",
NumRun);
QOut(Term, B1);
if (*Notice)
{
sprintf(B1, "0Notice: %s", Notice);
QOut(Term, B1);
}
NewUser->Entry = XName;
NewUser->Status = SLogin;
NewUser->Trm = Term;
NewUser->XPid = Pid;
NewUser->LastCmd[0] = '\0';
NewUser->NextUser = UserTail;
UserTail = NewUser;
return NewUser;
}
void EnterSex(void)
{
char Ch;
int Num;
Alfa Word;
GetWord(Word, &Num);
Ch = Cap(*Word);
User->Entry = XCmd;
if (Ch == 'M')
User->Sex = Male;
else
if (Ch == 'F')
User->Sex = Female;
else
{
User->Entry = XSex;
Loc = LenBuf + 1;
QOut(Term, "0Try again.");
return;
}
PlacePlayer(User, 1);
Loc = LenBuf + 1;
AnnounceLogin();
}
void NewPW(void)
{
int Dummy;
Alfa PassWord;
GetWord(PassWord, &Dummy);
CapAlfa(PassWord);
if (*PassWord)
{
User->PW = Hash(PassWord);
User->Entry = XSex;
}
}
void EnterStats(void)
{
int ILoop, Sum;
int Stat[5];
for (Sum = ILoop = 0; ILoop < 5; ILoop++)
{
int Num;
Alfa Dummy;
GetWord(Dummy, &Num);
Stat[ILoop] = Num;
Sum += Num;
if (Sum > 55 || Num < 5 || Num > 18)
{
QOut(Term, Sum > 55 ?
"0Error. Your average is greater than 11."
: "0Error. A number is more than 18 or less than 5.");
User->Entry = XStats;
Loc = LenBuf + 1;
return;
}
}
User->Str = Stat[0];
User->Int = Stat[1];
User->Dex = Stat[2];
User->Pty = Stat[3];
User->Con = Stat[4];
User->Entry = XSkill;
if (Loc >= LenBuf)
{
QOut(Term, "0Which weapon is your most skillful?");
QOut(Term,
"0Choose from: Sharp weapons, thrusting weapons, blunt weapons,");
QOut(Term, "0or pole weapons.");
}
}
void EnterSkill(void)
{
int Ch, Num;
Alfa Word;
User->Entry = XNewPW;
GetWord(Word, &Num);
Ch = Cap(Word[0]);
switch (Ch)
{
case 'S': User->SSharp = 1; break;
case 'T': User->SThrust = 1; break;
case 'B': User->SBlunt = 1; break;
case 'P': User->SLong = 1; break;
default:
User->Entry = XSkill;
Loc = LenBuf + 1;
QOut(Term, "0No such skill. Try again.");
break;
}
}
static void SetStats(ChType Cl, int Vit, int Fat, int Mag, int Mony)
{
User->Class = Cl;
User->Hits = User->MaxHits = Vit;
User->Fatigue = User->MaxFatigue = Fat;
User->Magic = User->MaxMagic = Mag;
User->Money = Mony;
}
void ChooseClass(void)
{
int Num;
Alfa Word;
User->Entry = XStats;
GetWord(Word, &Num);
CapAlfa(Word);
if (!strcmp(Word, "STOP"))
{
Logoff(User);
QOut(Term, "2");
QDea(Term);
return;
}
switch (*Word)
{
case 'F': SetStats(Fighter, 8, 14, 2, 200); break;
case 'T': SetStats(Thief, 7, 10, 3, 130); break;
case 'M': SetStats(MagicUser, 6, 9, 6, 150); break;
case 'C': SetStats(Cleric, 7, 11, 4, 80); break;
case 'R': SetStats(Ranger, 7, 11, 3, 150); break;
case 'P': SetStats(Paladin, 11, 8, 3, 140); break;
default:
User->Entry = XNewClass;
Loc = LenBuf + 1;
QOut(Term, "0No such class. Try again.");
return;
}
if (Loc >= LenBuf)
{
QOut(Term,
"0Choose your character's attributes for strength, intelligence,");
QOut(Term, "0 dexterity, piety and constitution.");
QOut(Term,
"0(Example: 15, 7, 9, 10, 9) Each must be between 5 and 18, and");
QOut(Term, "0the total average must be 11 or less.");
}
}
void MatchPW(void)
{
int Dummy;
Alfa PassWord;
GetWord(PassWord, &Dummy);
CapAlfa(PassWord);
if (Hash(PassWord) != User->PW)
{
Logoff(User);
QOut(Term, "0Wrong password, sorry.");
QOut(Term, "2");
QDea(Term);
}
else
{
PlacePlayer(User, User->RmCode);
AnnounceLogin();
User->Entry = XCmd;
Loc = LenBuf + 1;
}
}
void GetName(void)
{
UserPoint TempNext, Other;
UserType DumUser;
int Dummy;
Alfa Nam, CapName;
GetWord(Nam, &Dummy);
strcpy(CapName, Nam);
CapAlfa(CapName);
if (!strcmp(CapName, "STOP"))
{
Logoff(User);
QOut(Term, "2");
QDea(Term);
return;
}
if (Dummy || !*Nam)
{
QOut(Term, "0Bad characters in name.");
Loc = LenBuf + 1;
return;
}
for (Other = UserTail; Other; Other = Other->NextUser)
{
Alfa Temp;
strcpy(Temp, Other->Name);
CapAlfa(Temp);
if (!strcmp(Temp, CapName))
{
Logoff(User);
QOut(Term, "0Name already in use!");
QOut(Term, "2");
QDea(Term);
return;
}
}
TempNext = User->NextUser;
ReadPlayer(&DumUser, Nam);
*User = DumUser;
User->Status = SLogin;
User->Trm = Term;
User->XPid = Pid;
User->NextUser = TempNext;
if (!User->SSJ
&& (TaskClosed == 'C' || TaskClosed == 'T' && !User->PlayTester))
{
QOut(Term,
"0As you approach the gates, a little gnome jumps out from behind");
QOut(Term,
"0a rock. He whines, 'Go back! The masters are not ready for");
QOut(Term, "0you yet!' The gnome then disappears into the brush.");
Logoff(User);
QOut(Term, "2");
QDea(Term);
}
else if (!*User->Name)
{
strcpy(User->Name, Nam);
User->Entry = XNewClass;
if (Loc >= LenBuf)
{
QOut(Term, "0Please select your character's class:");
QOut(Term,
"0Fighter, Thief, Cleric, Paladin, Ranger, or Magic-User.");
}
}
else if (IsGuest(User->Trm))
{
QOut(Term, "0Guests can't play saved characters, sorry.");
Logoff(User);
QOut(Term, "2");
QDea(Term);
}
else
User->Entry = XPassword;
}