Horizon Official Technical Documentation
PacketLengthTable.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 * Copyright (c) 2023 Horizon Dev Team.
11 *
12 * Base Author - Sephus. (sagunxp@gmail.com)
13 *
14 * This library is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this library. If not, see <http://www.gnu.org/licenses/>.
26 **************************************************/
27
28#ifndef HORIZON_CHAR_SAKRAY_PACKET_LENGTH_TABLE
29#define HORIZON_CHAR_SAKRAY_PACKET_LENGTH_TABLE
30
34
35namespace Horizon
36{
37namespace Char
38{
39 typedef std::shared_ptr<Base::NetworkPacketHandler<CharSession>> HPacketStructPtrType;
40 typedef std::shared_ptr<Base::NetworkPacketTransmitter<CharSession>> TPacketStructPtrType;
41 typedef std::pair<int16_t, HPacketStructPtrType> HPacketTablePairType;
42 typedef std::pair<int16_t, TPacketStructPtrType> TPacketTablePairType;
46class PacketLengthTable
47{
48public:
49 PacketLengthTable(std::shared_ptr<CharSession> s)
50 : _session(s)
51 {
52#define ADD_HPKT(i, j, k) _hpacket_length_table.insert(i, std::make_pair(j, std::make_shared<k>(s)))
53#define ADD_TPKT(i, j, k) _tpacket_length_table.insert(i, std::make_pair(j, std::make_shared<k>(s)))
54 ADD_HPKT(0x0068, 46, CH_DELETE_CHAR);
55 ADD_HPKT(0x0065, 17, CH_ENTER);
56 ADD_HPKT(0x0067, 37, CH_MAKE_CHAR);
57 ADD_HPKT(0x0066, 3, CH_SELECT_CHAR);
58 ADD_HPKT(0x0187, 6, CH_UNKNOWN_PING);
60 ADD_TPKT(0x006b, -1, HC_ACCEPT_ENTER);
61 ADD_TPKT(0x006d, 108, HC_ACCEPT_MAKECHAR);
62 ADD_TPKT(0x0071, 28, HC_NOTIFY_ZONESVR);
64 ADD_TPKT(0x006c, 3, HC_REFUSE_ENTER);
65 ADD_TPKT(0x006e, 3, HC_REFUSE_MAKECHAR);
66#undef ADD_HPKT
67#undef ADD_TPKT
68 }
69
71
72 std::shared_ptr<CharSession> get_session() { return _session.lock(); }
73
74 HPacketTablePairType get_hpacket_info(uint16_t packet_id) { return _hpacket_length_table.at(packet_id); }
75 TPacketTablePairType get_tpacket_info(uint16_t packet_id) { return _tpacket_length_table.at(packet_id); }
76
77protected:
80 std::weak_ptr<CharSession> _session;
81
82};
83}
84}
85#endif /* HORIZON_CHAR_SAKRAY_PACKET_LENGTH_TABLE */
#define ADD_HPKT(i, j, k)
#define ADD_TPKT(i, j, k)
Main object for the aegis packet: CH_DELETE_CHAR.
Definition: HandledPackets.hpp:192
Main object for the aegis packet: CH_ENTER.
Definition: HandledPackets.hpp:470
Main object for the aegis packet: CH_MAKE_CHAR.
Definition: HandledPackets.hpp:587
Main object for the aegis packet: CH_SELECT_CHAR.
Definition: HandledPackets.hpp:971
Main object for the aegis packet: CH_UNKNOWN_PING.
Definition: HandledPackets.hpp:1048
Main object for the aegis packet: HC_ACCEPT_DELETECHAR.
Definition: TransmittedPackets.hpp:82
Main object for the aegis packet: HC_ACCEPT_ENTER.
Definition: TransmittedPackets.hpp:120
Main object for the aegis packet: HC_ACCEPT_MAKECHAR.
Definition: TransmittedPackets.hpp:211
Main object for the aegis packet: HC_NOTIFY_ZONESVR.
Definition: TransmittedPackets.hpp:896
Main object for the aegis packet: HC_REFUSE_DELETECHAR.
Definition: TransmittedPackets.hpp:1002
Main object for the aegis packet: HC_REFUSE_ENTER.
Definition: TransmittedPackets.hpp:1045
Main object for the aegis packet: HC_REFUSE_MAKECHAR.
Definition: TransmittedPackets.hpp:1091
std::weak_ptr< CharSession > _session
Definition: PacketLengthTable.hpp:82
TPacketTablePairType get_tpacket_info(uint16_t packet_id)
Definition: PacketLengthTable.hpp:75
std::shared_ptr< CharSession > get_session()
Definition: PacketLengthTable.hpp:72
PacketLengthTable(std::shared_ptr< CharSession > s)
Definition: PacketLengthTable.hpp:49
LockedLookupTable< uint16_t, HPacketTablePairType > _hpacket_length_table
Definition: PacketLengthTable.hpp:80
LockedLookupTable< uint16_t, TPacketTablePairType > _tpacket_length_table
Definition: PacketLengthTable.hpp:81
HPacketTablePairType get_hpacket_info(uint16_t packet_id)
Definition: PacketLengthTable.hpp:74
~PacketLengthTable()
Definition: PacketLengthTable.hpp:70
Value at(Key const &key, Value const &default_value=Value()) const
Definition: LockedLookupTable.hpp:63
std::pair< int16_t, HPacketStructPtrType > HPacketTablePairType
Definition: PacketLengthTable.hpp:41
std::pair< int16_t, TPacketStructPtrType > TPacketTablePairType
Definition: PacketLengthTable.hpp:42
std::shared_ptr< Base::NetworkPacketTransmitter< CharSession > > TPacketStructPtrType
Definition: PacketLengthTable.hpp:40
std::shared_ptr< Base::NetworkPacketHandler< CharSession > > HPacketStructPtrType
Definition: PacketLengthTable.hpp:39
Definition: Element.hpp:7