forked from nickgammon/tinymudserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinymudserver.cpp
executable file
·67 lines (45 loc) · 1.5 KB
/
tinymudserver.cpp
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
/*
tinymudserver - an example MUD server
Author: Nick Gammon
http://www.gammon.com.au/
Date: 22nd July 2004
(C) Copyright Nick Gammon 2004. Permission to copy, use, modify, sell and
distribute this software is granted provided this copyright notice appears
in all copies. This software is provided "as is" without express or implied
warranty, and with no claim as to its suitability for any purpose.
*/
// standard library includes ...
#include <iostream>
using namespace std;
#include "constants.h"
#include "globals.h"
void LoadThings ();
int InitComms ();
void MainLoop ();
void CloseComms ();
// called approximately every 0.5 seconds - handle things like fights here
void PeriodicUpdates ()
{
// The example below just sends a message every MESSAGE_INTERVAL seconds.
// send new command if it is time
if (time (NULL) > (tLastMessage + MESSAGE_INTERVAL))
{
SendToAll ("You hear creepy noises ...\n");
tLastMessage = time (NULL);
}
} // end of PeriodicUpdates
// main program
int main ()
{
cout << "Tiny MUD server version " << VERSION << endl;
LoadThings (); // load stuff
if (InitComms ()) // listen for new connections
return 1;
cout << "Accepting connections from port " << PORT << endl;
MainLoop (); // handle player input/output
// game over - tell them all
SendToAll ("\n\n** Game shut down. **\n\n");
CloseComms (); // stop listening
cout << "Game shut down." << endl;
return 0;
} // end of main