summaryrefslogtreecommitdiff
path: root/src/map/chrif.h
blob: 0617a67027fb13ecb586a1522607f6ef4c575521 (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
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
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams

#ifndef _CHRIF_H_
#define _CHRIF_H_

#include "../common/cbasetypes.h"
#include <time.h>
#include "map.h" //TBL_stuff

/**
 * Defines
 **/
//Interval at which map server updates online listing. [Valaris]
#define CHECK_INTERVAL 3600000
//Interval at which map server sends number of connected users. [Skotlex]
#define UPDATE_INTERVAL 10000

#define CHRIF_PACKET_LEN_TABLE_SIZE 0x3d

/**
 * Enumerations
 **/
enum sd_state { ST_LOGIN, ST_LOGOUT, ST_MAPCHANGE };

/**
 * Structures
 **/
struct auth_node {
	int account_id, char_id;
	int login_id1, login_id2, sex, fd;
	time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
	struct map_session_data *sd;	//Data from logged on char.
	struct mmo_charstatus *char_dat;	//Data from char server.
	unsigned int node_created; //timestamp for node timeouts
	enum sd_state state; //To track whether player was login in/out or changing maps.
};

/*=====================================
* Interface : chrif.h 
* Generated by HerculesInterfaceMaker
* created by Susu
*-------------------------------------*/
struct chrif_interface {

	/* vars */
	
	int connected;
	int other_mapserver_count; //Holds count of how many other map servers are online (apart of this instance) [Skotlex]

	/* */
	struct eri *auth_db_ers; //For reutilizing player login structures.
	DBMap* auth_db; // int id -> struct auth_node*
	/* */
	int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE];
	int fd;
	int srvinfo;
	char ip_str[128];
	uint32 ip;
	uint16 port;
	char userid[NAME_LENGTH], passwd[NAME_LENGTH];
	int state;
	/* */
	int (*final) (void);
	int (*init) (void);
	/* funcs */
	void (*setuserid) (char* id);
	void (*setpasswd) (char* pwd);
	void (*checkdefaultlogin) (void);
	int (*setip) (const char* ip);
	void (*setport) (uint16 port);
	
	int (*isconnected) (void);
	void (*check_shutdown) (void);
	
	struct auth_node* (*search) (int account_id);
	struct auth_node* (*auth_check) (int account_id, int char_id, enum sd_state state);
	bool (*auth_delete) (int account_id, int char_id, enum sd_state state);
	bool (*auth_finished) (struct map_session_data* sd);
	
	void (*authreq) (struct map_session_data* sd);
	void (*authok) (int fd);
	int (*scdata_request) (int account_id, int char_id);
	int (*save) (struct map_session_data* sd, int flag);
	int (*charselectreq) (struct map_session_data* sd, uint32 s_ip);
	int (*changemapserver) (struct map_session_data* sd, uint32 ip, uint16 port);
	
	int (*searchcharid) (int char_id);
	int (*changeemail) (int id, const char *actual_email, const char *new_email);
	int (*char_ask_name) (int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second);
	int (*updatefamelist) (struct map_session_data *sd);
	int (*buildfamelist) (void);
	int (*save_scdata) (struct map_session_data *sd);
	int (*ragsrvinfo) (int base_rate,int job_rate, int drop_rate);
	int (*char_offline) (struct map_session_data *sd);
	int (*char_offline_nsd) (int account_id, int char_id);
	int (*char_reset_offline) (void);
	int (*send_users_tochar) (void);
	int (*char_online) (struct map_session_data *sd);
	int (*changesex) (struct map_session_data *sd);
	//int (*chardisconnect) (struct map_session_data *sd); // FIXME: Commented out in clif.c, function does not exist
	int (*divorce) (int partner_id1, int partner_id2);
	
	int (*removefriend) (int char_id, int friend_id);
	void (*send_report) (char* buf, int len);
			
	int (*flush_fifo) (void);
	void (*skillid2idx) (int fd);
	
	bool (*sd_to_auth) (TBL_PC* sd, enum sd_state state);
	int (*check_connect_char_server) (int tid, unsigned int tick, int id, intptr_t data);
	bool (*auth_logout) (TBL_PC* sd, enum sd_state state);
	void (*save_ack) (int fd);
	int (*reconnect) (DBKey key, DBData *data, va_list ap);
	int (*auth_db_cleanup_sub) (DBKey key, DBData *data, va_list ap);
	void (*char_ask_name_answer) (int acc, const char* player_name, uint16 type, uint16 answer);
	int (*auth_db_final) (DBKey key, DBData *data, va_list ap);
	int (*send_usercount_tochar) (int tid, unsigned int tick, int id, intptr_t data);
	int (*auth_db_cleanup) (int tid, unsigned int tick, int id, intptr_t data);

	int (*connect) (int fd);
	int (*connectack) (int fd);
	int (*sendmap) (int fd);
	int (*sendmapack) (int fd);
	int (*recvmap) (int fd);
	int (*changemapserverack) (int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port);
	int (*changedsex) (int fd);
	int (*divorceack) (int char_id, int partner_id);
	int (*accountban) (int fd);
	int (*recvfamelist) (int fd);
	int (*load_scdata) (int fd);
	void (*update_ip) (int fd);
	int (*disconnectplayer) (int fd);
	int (*removemap) (int fd);
	int (*updatefamelist_ack) (int fd);
	void (*keepalive)(int fd);
	void (*keepalive_ack) (int fd);
	int (*deadopt) (int father_id, int mother_id, int child_id);
	void (*authfail) (int fd);
	void (*on_ready) (void);
	void (*on_disconnect) (void);
	int (*parse) (int fd);
};

struct chrif_interface *chrif;

void chrif_defaults(void);

#endif /* _CHRIF_H_ */