aboutsummaryrefslogtreecommitdiff
path: root/src/connections.hh
blob: 0aef82bb797c7f8d0f34300d2b85c1c252719e17 (plain) (blame)
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
#ifndef TIBIA_CONNECTION_HH_
#define TIBIA_CONNECTION_HH_ 1

#include "common.hh"
#include "crypto.hh"
#include "enums.hh"

struct TConnection;
struct TPlayer;

struct TKnownCreature {
	KNOWNCREATURESTATE State;
	uint32 CreatureID;
	TKnownCreature *Next;
	TConnection *Connection;
};

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);
	void EmergencyPing(void);

	// TODO(fusion): Maybe rename this later?
	bool Live(void) const {
		return this->State == CONNECTION_LOGIN
			|| this->State == CONNECTION_GAME
			|| this->State == CONNECTION_DEAD
			|| this->State == CONNECTION_LOGOUT;
	}

	// DATA
	// =================
	uint8 InData[2048];
	int InDataSize;
	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;
	pid_t PID;
	int Socket;
	char IPAddress[16];
	TXTEASymmetricKey SymmetricKey;
	bool ConnectionIsOk;
	bool ClosingIsDelayed;
	uint8 field23_0x4852;
	uint8 field24_0x4853;
	uint32 TimeStamp;
	uint32 TimeStampAction;
	int TerminalType;
	int TerminalVersion;
	int TerminalOffsetX;
	int TerminalOffsetY;
	int TerminalWidth;
	int TerminalHeight;
	uint32 CharacterID;
	char Name[31];
	uint8 field35_0x4897;
	TKnownCreature KnownCreatureTable[150];
};

#endif // TIBIA_CONNECTION_HH_