1
This commit is contained in:
parent
2132b1f008
commit
4a1310c0e8
@ -1,18 +1,24 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <a8/openssl.h>
|
||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "WSListener.h"
|
#include "WSListener.h"
|
||||||
|
|
||||||
void Player::Init()
|
void Player::Init()
|
||||||
{
|
{
|
||||||
|
crc32_code = a8::openssl::Crc32(
|
||||||
|
(unsigned char*)account_id.data(),
|
||||||
|
account_id.size()
|
||||||
|
);
|
||||||
SyncLocToMasterServer();
|
SyncLocToMasterServer();
|
||||||
NotifyOnline();
|
NotifyOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::UnInit()
|
void Player::UnInit()
|
||||||
{
|
{
|
||||||
|
timer_attacher.ClearTimerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMFriendList(f8::MsgHdr& hdr, const cs::CMFriendList& msg)
|
void Player::_CMFriendList(f8::MsgHdr& hdr, const cs::CMFriendList& msg)
|
||||||
|
@ -9,11 +9,15 @@ class Player
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int socket_handle = 0;
|
int socket_handle = 0;
|
||||||
|
unsigned int crc32_code = 0;
|
||||||
|
a8::TimerAttacher timer_attacher;
|
||||||
|
|
||||||
std::string account_id;
|
std::string account_id;
|
||||||
std::string nickname;
|
std::string nickname;
|
||||||
std::string avatar_url;
|
std::string avatar_url;
|
||||||
int sex = 0;
|
int sex = 0;
|
||||||
long long group_id = 0;
|
long long group_id = 0;
|
||||||
|
int data_version1 = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -160,8 +160,8 @@ void PlayerMgr::AsyncLogin1(const cs::CMLogin& msg)
|
|||||||
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(msg.account_id());
|
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(msg.account_id());
|
||||||
DBEngine::Instance()->ExecAsyncScript(conn_info,
|
DBEngine::Instance()->ExecAsyncScript(conn_info,
|
||||||
"INSERT INTO `user`(account_id, nickname, avatar_url,"
|
"INSERT INTO `user`(account_id, nickname, avatar_url,"
|
||||||
" sex, group_id, createtime, modifytime, registertime)"
|
" sex, createtime, modifytime, registertime)"
|
||||||
"VALUES ('%s', '%s', '%s', %d, 0, %d, %d, %d)"
|
"VALUES ('%s', '%s', '%s', %d, %d, %d, %d)"
|
||||||
"ON DUPLICATE KEY UPDATE nickname='%s', avatar_url='%s',"
|
"ON DUPLICATE KEY UPDATE nickname='%s', avatar_url='%s',"
|
||||||
" sex=%d, last_logintime=%d;",
|
" sex=%d, last_logintime=%d;",
|
||||||
{
|
{
|
||||||
@ -205,7 +205,8 @@ void PlayerMgr::AsyncLogin2(const cs::CMLogin& msg)
|
|||||||
data_set->at(0).at(1),
|
data_set->at(0).at(1),
|
||||||
data_set->at(0).at(2),
|
data_set->at(0).at(2),
|
||||||
a8::XValue(data_set->at(0).at(3)),
|
a8::XValue(data_set->at(0).at(3)),
|
||||||
a8::XValue(data_set->at(0).at(4))
|
a8::XValue(data_set->at(0).at(4)),
|
||||||
|
a8::XValue(data_set->at(0).at(5))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
delete msg;
|
delete msg;
|
||||||
@ -226,7 +227,8 @@ void PlayerMgr::AsyncLogin2(const cs::CMLogin& msg)
|
|||||||
*msg_copy = msg;
|
*msg_copy = msg;
|
||||||
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(msg.account_id());
|
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(msg.account_id());
|
||||||
DBEngine::Instance()->ExecAsyncQuery(conn_info,
|
DBEngine::Instance()->ExecAsyncQuery(conn_info,
|
||||||
"SELECT account_id, nickname, avatar_url, sex, group_id "
|
"SELECT account_id, nickname, avatar_url, sex, group_id, "
|
||||||
|
" data_version1 "
|
||||||
"FROM `user` WHERE account_id='%s';",
|
"FROM `user` WHERE account_id='%s';",
|
||||||
{
|
{
|
||||||
msg.account_id(),
|
msg.account_id(),
|
||||||
@ -244,7 +246,8 @@ void PlayerMgr::AsyncLoginOnOk(const std::string& account_id,
|
|||||||
const std::string& nickname,
|
const std::string& nickname,
|
||||||
const std::string& avatar_url,
|
const std::string& avatar_url,
|
||||||
int sex,
|
int sex,
|
||||||
long long group_id)
|
long long group_id,
|
||||||
|
int data_version1)
|
||||||
{
|
{
|
||||||
f8::MsgHdr* hdr = GetHdrByAccountId(account_id);
|
f8::MsgHdr* hdr = GetHdrByAccountId(account_id);
|
||||||
if (hdr) {
|
if (hdr) {
|
||||||
@ -264,6 +267,7 @@ void PlayerMgr::AsyncLoginOnOk(const std::string& account_id,
|
|||||||
hum->avatar_url = avatar_url;
|
hum->avatar_url = avatar_url;
|
||||||
hum->sex = sex;
|
hum->sex = sex;
|
||||||
hum->group_id = group_id;
|
hum->group_id = group_id;
|
||||||
|
hum->data_version1 = data_version1;
|
||||||
hum->Init();
|
hum->Init();
|
||||||
socket_hash_[hdr->socket_handle] = hum;
|
socket_hash_[hdr->socket_handle] = hum;
|
||||||
accountid_hash_[account_id] = hum;
|
accountid_hash_[account_id] = hum;
|
||||||
|
@ -49,7 +49,8 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
|||||||
const std::string& nickname,
|
const std::string& nickname,
|
||||||
const std::string& avatar_url,
|
const std::string& avatar_url,
|
||||||
int sex,
|
int sex,
|
||||||
long long group_id);
|
long long group_id,
|
||||||
|
int data_version1);
|
||||||
void AsyncLoginOnError(const std::string& account_id,
|
void AsyncLoginOnError(const std::string& account_id,
|
||||||
int step,
|
int step,
|
||||||
int error_code,
|
int error_code,
|
||||||
|
@ -43,6 +43,7 @@ CREATE TABLE `user` (
|
|||||||
`avatar_url` varchar(256) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '',
|
`avatar_url` varchar(256) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '',
|
||||||
`sex` int(11) NOT NULL DEFAULT '0' COMMENT 'sex',
|
`sex` int(11) NOT NULL DEFAULT '0' COMMENT 'sex',
|
||||||
`group_id` bigint NOT NULL COMMENT 'group_id',
|
`group_id` bigint NOT NULL COMMENT 'group_id',
|
||||||
|
`data_version1` int(11) NOT NULL DEFAULT '0' COMMENT 'data_version1',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
`registertime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`registertime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
@ -100,11 +101,17 @@ DROP TABLE IF EXISTS `friend_relationship`;
|
|||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `friend_relationship` (
|
CREATE TABLE `friend_relationship` (
|
||||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`first` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'first',
|
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
|
||||||
`second` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'second',
|
`friend_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
|
||||||
|
`friend_nickname` tinyblob COMMENT 'nickname',
|
||||||
|
`friend_avatar_url` varchar(256) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
`friend_sex` int(11) NOT NULL DEFAULT '0' COMMENT 'sex',
|
||||||
|
`friend_data_version1` int(11) NOT NULL DEFAULT '0' COMMENT 'data_version1',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `first_second` (`first`, `second`)
|
UNIQUE KEY `account_id_friend_id` (`account_id`, `friend_id`),
|
||||||
|
KEY `account_id` (`account_id`),
|
||||||
|
KEY `friend_id` (`friend_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user