-
Notifications
You must be signed in to change notification settings - Fork 4
/
Demo08-01.cpp
72 lines (54 loc) · 1.26 KB
/
Demo08-01.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
68
69
70
71
// MUD Programming
// Ron Penton
// (C)2003
// Demo08-01.cpp - The logon module for SimpleMUD
//
//
#include "SimpleMUD/Player.h"
#include "SimpleMUD/PlayerDatabase.h"
#include "SimpleMUD/Item.h"
#include "SimpleMUD/ItemDatabase.h"
#include "SocketLib/SocketLib.h"
#include "SimpleMUD/Logon.h"
#include "SimpleMUD/Game.h"
#include "SimpleMUD/SimpleMUDLogs.h"
using namespace SocketLib;
using namespace SimpleMUD;
int main()
{
try
{
ItemDatabase::Load();
PlayerDatabase::Load();
ListeningManager<Telnet, Logon> lm;
ConnectionManager<Telnet, Logon> cm( 128, 60, 65536 );
lm.SetConnectionManager( &cm );
lm.AddPort( 5100 );
Game::GetTimer().Reset();
Game::Running() = true;
while( Game::Running() )
{
lm.Listen();
cm.Manage();
ThreadLib::YieldThread();
}
}
catch( SocketLib::Exception& e )
{
ERRORLOG.Log( "Fatal Socket Error: " + e.PrintError() );
}
catch( ThreadLib::Exception& )
{
ERRORLOG.Log( "Fatal Thread Error" );
}
catch( std::exception& e )
{
ERRORLOG.Log( "Standard Error: " + std::string( e.what() ) );
}
catch( ... )
{
ERRORLOG.Log( "Unspecified Error" );
}
// save the whole database.
SimpleMUD::PlayerDatabase::Save();
}