-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection.h
executable file
·242 lines (188 loc) · 5.01 KB
/
connection.h
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
// Copyright 2003 David "Ksilyan" Haley
#ifndef __CONNECTION_H_
#define __CONNECTION_H_
#include "mud.h"
#include "socket_connection.h"
#include "pager.h"
#include <list>
#include <stack>
#include <set>
#include <string>
// forward declaration
typedef tId<Character> idCharacter;
/*
* Connected state for a channel.
*/
enum eConnectedStates {
CON_GET_EMAIL = -50,
CON_GET_NEW_EMAIL,
CON_GET_OLD_PASSWORD,
CON_GET_MAIN_MENU_CHOICE,
CON_GET_NEW_PASSWORD,
CON_CONFIRM_NEW_PASSWORD,
CON_GET_NEW_ACCOUNT,
CON_GET_CHAR_NAME,
CON_GET_NEW_NAME,
CON_CONFIRM_NEW_NAME,
CON_GET_NEW_SEX,
CON_GET_NEW_CLASS,
CON_GET_ADD_NAME,
CON_READ_MOTD,
CON_READ_MOTD_NOCHAR,
CON_GET_NEW_RACE,
CON_GET_ADD_PASS,
CON_CONFIRM_ADD_PASS,
CON_GET_EMULATION,
CON_GET_WANT_RIPANSI,
CON_TITLE,
CON_PRESS_ENTER,
CON_WAIT_1,
CON_WAIT_2,
CON_WAIT_3,
CON_ACCEPTED,
CON_READ_IMOTD,
CON_COPYOVER_RECOVER,
CON_DELETE_PROMPT,
CON_DELETE_PROMPT_2,
CON_PLAYING = 0,
CON_EDITING
};
class PlayerConnection : public SocketConnection
{
private:
short IdleTime;
time_t LastWrite; // the time at which data was last written sucessfully
bool UsingMXP;
unsigned char PreviousColor;
unsigned char CurrentColor;
list<idCharacter> Snooping; // Who this connection is snooping.
Pager * pager_; // output pager
InputHandler * OldInputReceiver;
stack<short> ColorStack; // stack of color changes
public:
PlayerConnection(int descriptor);
virtual ~PlayerConnection();
///////////////////////
// Core connection code
// (SocketConnection)
///////////////////////
virtual bool WantsToWrite();
virtual bool InOutSet();
virtual bool InInSet();
virtual void ProcessInputBuffer();
virtual bool InExcSet();
virtual void Initialize();
virtual void SendText(const char * text, unsigned int textLength = 0);
inline virtual void SendText(std::string text, unsigned int textLength = 0)
{
this->SendText(text.c_str(), (textLength <= 0 ? text.length() : textLength) );
}
bool IsWriteTimingOut();
// Stuff
eConnectedStates ConnectedState;
bool InCommand;
bool InPrompt;
void EnableMXP();
string User; // not used for now... is looked up through identd
ACCOUNT_DATA * Account;
// these should be moved to protected at some point
idCharacter CurrentCharId;
idCharacter OriginalCharId;
/////////////////////
// Pre-game functions
// (menus, etc.)
/////////////////////
void WriteMainMenu(); // write the main menu
void ShowMotd(); // show greeting page
////////////
// Idle Time
////////////
void AddIdle(); // add one tick of idle time
short GetIdleSeconds() const; // return idle time, in seconds
short GetIdleTicks() const; // return idle time, in ticks
///////////
// Snooping
///////////
bool IsSnooping(Character * ch);
bool IsSnooping(idCharacter id);
void CancelAllSnoops(); // stop snooping people
void CancelSnoop(Character * ch);
bool CancelSnoop(idCharacter id);
void StartSnooping(Character * ch);
bool StartSnooping(idCharacter id);
Character * GetCharacter() const; // returns the currently active character
Character * GetOriginalCharacter(); // returns the original (i.e. non-switched)
//void SetCharacter(Character * ch); // set the currently active character
//void SetOriginalCharacter(Character * ch); //
/* NOTE TO SELF
* at some point in the future, it would be neat to have a
* menu class that would be reusable for any kind of in-game
* menu interface.
*/
////////////////////////
// Code object interface
////////////////////////
virtual const string codeGetClassName() const; // Return the name of the class.
virtual const string codeGetBasicInfo() const; // Return a short summary of the object.
virtual const string codeGetFullInfo() const; // Return a complete summary of the object.
//////OLD STUFF/////
//PlayerConnection * snoop_by; // who's snooping me
//sh_int idle;
//sh_int lines;
//sh_int scrlen;
//bool fcommand;
//char inbuf [MAX_INBUF_SIZE];
//char incomm [MAX_INPUT_LENGTH];
//char inlast [MAX_INPUT_LENGTH];
//int repeat;
//char * outbuf;
//unsigned long outsize;
//int outtop;
//char * pagebuf;
//unsigned long pagesize;
//int pagetop;
//char * pagepoint;
//char pagecmd;
char pagecolor;
int auth_inc;
int auth_state;
char abuf[ 256 ];
int auth_fd;
int atimes;
int newstate;
unsigned char prevcolor;
};
/*
* Account ban structure.
*/
struct account_ban_data
{
ACCOUNT_BAN_DATA * next;
ACCOUNT_BAN_DATA * prev;
char * address;
time_t secBanTime;
int flags;
};
/*
* A player account
*/
class Account
{
public:
Account();
~Account();
shared_str autoLoginName_; // name of character to log in to automatically
// old stuff
ACCOUNT_DATA* next;
ACCOUNT_DATA* prev;
int iref; /* keep track of how many instances */
std::string password_;
std::string forumPassword_; // added by Ksilyan
char * characters;
std::set<std::string> allCharacters_;
char * email;
int flags;
time_t secCreatedDate;
NoteData * comments;
};
#endif