本文整理汇总了C++中tcp_connection::pointer::get_data方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::get_data方法的具体用法?C++ pointer::get_data怎么用?C++ pointer::get_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcp_connection::pointer
的用法示例。
在下文中一共展示了pointer::get_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_from_client
/*!
* \brief Parse from Client
*
* \author Fimbulwinter Development Team
* \author GreenBox
* \date 08/12/11
*
**/
int CharServer::parse_from_client(tcp_connection::pointer cl)
{
CharSessionData *csd = ((CharSessionData *)cl->get_data());
if (cl->flags.eof)
{
if (csd && csd->auth && auth_conn_ok)
{
WFIFOHEAD(auth_conn,6);
WFIFOW(auth_conn,0) = INTER_CA_SET_ACC_OFF;
WFIFOL(auth_conn,2) = csd->account_id;
auth_conn->send_buffer(6);
}
set_char_offline(csd->account_id, -1);
if (csd)
delete csd;
ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", cl->socket().remote_endpoint().address().to_string().c_str());
cl->do_close();
return 0;
}
while(RFIFOREST(cl) >= 2)
{
unsigned short cmd = RFIFOW(cl, 0);
#define FIFOSD_CHECK(rest) { if(RFIFOREST(cl) < rest) return 0; if (csd==NULL || !csd->auth) { cl->skip(rest); return 0; } }
switch (cmd)
{
case HEADER_CH_SELECT_CHAR:
FIFOSD_CHECK(3);
{
int slot = RFIFOB(cl,2);
int char_id;
CharData cd;
cl->skip(3);
{
statement s = (database->prepare << "SELECT `char_id` FROM `char` WHERE `account_id`=:a AND `char_num`=:s",
use(csd->account_id), use(slot), into(char_id));
s.execute(true);
if (s.get_affected_rows() <= 0)
{
WFIFOPACKET(cl, spacket, HC_REFUSE_ENTER);
spacket->error_code = 0;
cl->send_buffer(sizeof(struct PACKET_HC_REFUSE_ENTER));
}
}
chars->load_char(char_id, cd, true);
int server = -1;
if (map_to_zone.count(cd.last_point.map))
server = map_to_zone[cd.last_point.map];
if (server < 0)
{
// TODO: Find for major city
WFIFOPACKET(cl, spacket, SC_NOTIFY_BAN);
spacket->error_code = 1;
cl->send_buffer(sizeof(struct PACKET_SC_NOTIFY_BAN));
break;
}
auth_nodes[csd->account_id].sex = csd->sex;
auth_nodes[csd->account_id].char_id = char_id;
auth_nodes[csd->account_id].gmlevel = csd->gmlevel;
auth_nodes[csd->account_id].login_id1 = csd->login_id1;
auth_nodes[csd->account_id].login_id2 = csd->login_id2;
auth_nodes[csd->account_id].expiration_time = csd->expiration_time;
WFIFOPACKET(cl, spacket, HC_NOTIFY_ZONESVR);
spacket->char_id = char_id;
maps.copy_map_name_ext((char*)spacket->map_name, cd.last_point.map);
spacket->addr.ip = htonl(servers[server].addr.to_ulong());
spacket->addr.port = servers[server].port;
cl->send_buffer(sizeof(struct PACKET_HC_NOTIFY_ZONESVR));
}
break;
case HEADER_CH_REQUEST_DEL_TIMER:
FIFOSD_CHECK(6);
delete2_req(cl, csd);
cl->skip(6);
break;
//.........这里部分代码省略.........