aboutsummaryrefslogtreecommitdiff
path: root/src/connections.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/connections.hh')
-rw-r--r--src/connections.hh65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/connections.hh b/src/connections.hh
index 79462c5..921a604 100644
--- a/src/connections.hh
+++ b/src/connections.hh
@@ -1,5 +1,5 @@
-#ifndef TIBIA_CONNECTION_HH_
-#define TIBIA_CONNECTION_HH_ 1
+#ifndef TIBIA_CONNECTIONS_HH_
+#define TIBIA_CONNECTIONS_HH_ 1
#include "common.hh"
#include "crypto.hh"
@@ -8,6 +8,11 @@
struct TConnection;
struct TPlayer;
+// TODO(fusion): The maximum number of connections should probably be kept in
+// sync with the maximum number of communication threads, or maybe it is the
+// same constant.
+#define MAX_CONNECTIONS 1100
+
struct TKnownCreature {
KNOWNCREATURESTATE State;
uint32 CreatureID;
@@ -16,23 +21,37 @@ struct TKnownCreature {
};
struct TConnection {
- TPlayer *GetPlayer(void);
- void Logout(int Delay, bool StopFight);
- bool IsVisible(int x, int y, int z);
- void EnterGame(void);
- const char *GetIPAddress(void);
- void Die(void);
- KNOWNCREATURESTATE KnownCreature(uint32 CreatureID, bool UpdateFollows);
- int GetSocket(void);
+ TConnection(void);
+ void Process(void);
+ void ResetTimer(int Command);
void EmergencyPing(void);
- void Login(void);
- const char *GetName(void);
+ pid_t GetPID(void);
+ int GetSocket(void);
+ const char *GetIPAddress(void);
+ void Free(void);
+ void Assign(void);
void Connect(int Socket);
+ void Login(void);
+ bool JoinGame(TReadBuffer *Buffer);
+ void EnterGame(void);
+ void Die(void);
+ void Logout(int Delay, bool StopFight);
void Close(bool Delay);
- void Free(void);
- pid_t GetPID(void);
+ void Disconnect(void);
+ TPlayer *GetPlayer(void);
+ const char *GetName(void);
+ void GetPosition(int *x, int *y, int *z);
+ bool IsVisible(int x, int y, int z);
+ KNOWNCREATURESTATE KnownCreature(uint32 ID, bool UpdateFollows);
+ uint32 NewKnownCreature(uint32 NewID);
+ void ClearKnownCreatureTable(bool Unchain);
+ void UnchainKnownCreature(uint32 ID);
+
+ bool InGame(void) const {
+ return this->State == CONNECTION_GAME
+ || this->State == CONNECTION_DEAD;
+ }
- // TODO(fusion): Maybe rename this later?
bool Live(void) const {
return this->State == CONNECTION_LOGIN
|| this->State == CONNECTION_GAME
@@ -47,15 +66,11 @@ struct TConnection {
bool SigIOPending;
bool WaitingForACK;
uint8 OutData[16384];
- uint8 field5_0x4806;
- uint8 field6_0x4807;
int NextToSend;
int NextToCommit;
int NextToWrite;
bool Overflow;
bool WillingToSend;
- uint8 field12_0x4816;
- uint8 field13_0x4817;
TConnection *NextSendingConnection;
uint32 RandomSeed;
CONNECTIONSTATE State;
@@ -65,8 +80,6 @@ struct TConnection {
TXTEASymmetricKey SymmetricKey;
bool ConnectionIsOk;
bool ClosingIsDelayed;
- uint8 field23_0x4852;
- uint8 field24_0x4853;
uint32 TimeStamp;
uint32 TimeStampAction;
int TerminalType;
@@ -77,8 +90,14 @@ struct TConnection {
int TerminalHeight;
uint32 CharacterID;
char Name[31];
- uint8 field35_0x4897;
TKnownCreature KnownCreatureTable[150];
};
-#endif // TIBIA_CONNECTION_HH_
+TConnection *AssignFreeConnection(void);
+TConnection *GetFirstConnection(void);
+TConnection *GetNextConnection(void);
+void ProcessConnections(void);
+void InitConnections(void);
+void ExitConnections(void);
+
+#endif // TIBIA_CONNECTIONS_HH_