登录选角ok

This commit is contained in:
aozhiwei 2019-09-23 14:58:57 +08:00
parent 40a8f37ed6
commit 6f48ac9dee
3 changed files with 134 additions and 14 deletions

View File

@ -123,7 +123,7 @@ public:
head->size = (packlen << 8) + (packlen >> 8);
int offset = 0;
CustomPbSerialize(buff + sizeof(ServerPktHeader), offset, packlen, &msg);
SendBuff(buff, sizeof(ServerPktHeader) + packlen);
SendBuff(buff, sizeof(ServerPktHeader) + packlen - 2);
free(buff);
}
@ -234,6 +234,26 @@ void GCListener::SetKey(int sockhandle, const std::string& key)
void GCListener::InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg)
{
#if 0
if (msgid == cs::_SMCharEnum) {
char bin_buf[1024] = {0};
FILE* fp = fopen("/root/1.bin", "rb");
fread(bin_buf, 1, 168, fp);
fclose(fp);
unsigned short packlen = 2 + 168;
char* buff = (char*)malloc(sizeof(ServerPktHeader) + packlen);
memset(buff, 0, sizeof(ServerPktHeader) + packlen);
ServerPktHeader* head = (ServerPktHeader*)buff;
head->cmd = msgid;
head->size = (packlen << 8) + (packlen >> 8);
memmove(buff + sizeof(ServerPktHeader), bin_buf, packlen - 2);
tcp_listener_->SendClientMsg(socket_handle, buff, sizeof(ServerPktHeader) + packlen);
free(buff);
} else {
#else
{
#endif
unsigned short packlen = 2 + CustomPbSerializeSize(&msg);
char* buff = (char*)malloc(sizeof(ServerPktHeader) + packlen);
memset(buff, 0, sizeof(ServerPktHeader) + packlen);
@ -242,6 +262,7 @@ void GCListener::InternalSendMsg(int socket_handle, int msgid, google::protobuf:
head->size = (packlen << 8) + (packlen >> 8);
int offset = 0;
CustomPbSerialize(buff + sizeof(ServerPktHeader), offset, packlen, &msg);
tcp_listener_->SendClientMsg(socket_handle, buff, sizeof(ServerPktHeader) + packlen);
tcp_listener_->SendClientMsg(socket_handle, buff, sizeof(ServerPktHeader) + packlen - 2);
free(buff);
}
}

View File

@ -115,6 +115,30 @@ enum ResponseCodes
CHAR_NAME_SUCCESS = 0x52,
};
enum PlayerFlags
{
PLAYER_FLAGS_NONE = 0x00000000,
PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
PLAYER_FLAGS_AFK = 0x00000002,
PLAYER_FLAGS_DND = 0x00000004,
PLAYER_FLAGS_GM = 0x00000008,
PLAYER_FLAGS_GHOST = 0x00000010,
PLAYER_FLAGS_RESTING = 0x00000020,
PLAYER_FLAGS_UNK7 = 0x00000040, // admin?
PLAYER_FLAGS_FFA_PVP = 0x00000080,
PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
PLAYER_FLAGS_IN_PVP = 0x00000200,
PLAYER_FLAGS_HIDE_HELM = 0x00000400,
PLAYER_FLAGS_HIDE_CLOAK = 0x00000800,
PLAYER_FLAGS_PARTIAL_PLAY_TIME = 0x00001000, // played long time
PLAYER_FLAGS_NO_PLAY_TIME = 0x00002000, // played too long time
PLAYER_FLAGS_UNK15 = 0x00004000,
PLAYER_FLAGS_UNK16 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag
PLAYER_FLAGS_SANCTUARY = 0x00010000, // player entered sanctuary
PLAYER_FLAGS_TAXI_BENCHMARK = 0x00020000, // taxi benchmark mode (on/off) (2.0.1)
PLAYER_FLAGS_PVP_TIMER = 0x00040000, // 3.0.2, pvp timer active (after you disable pvp manually)
};
#define MAX_PET_STABLES 2
// stored in character_pet.slot
@ -128,5 +152,17 @@ enum PetSaveMode
PET_SAVE_REAGENTS = 101 // PET_SAVE_NOT_IN_SLOT with reagents return
};
// 2^n values
enum AtLoginFlags
{
AT_LOGIN_NONE = 0x00,
AT_LOGIN_RENAME = 0x01,
AT_LOGIN_RESET_SPELLS = 0x02,
AT_LOGIN_RESET_TALENTS = 0x04,
// AT_LOGIN_CUSTOMIZE = 0x08, -- used in post-3.x
// AT_LOGIN_RESET_PET_TALENTS = 0x10, -- used in post-3.x
AT_LOGIN_FIRST = 0x20,
};
const char* const PROJ_NAME_FMT = "game%d_gameserver";
const char* const PROJ_ROOT_FMT = "/data/logs/%s";

View File

@ -6,6 +6,43 @@
#include "GCListener.h"
#include "app.h"
enum CharacterFlags
{
CHARACTER_FLAG_NONE = 0x00000000,
CHARACTER_FLAG_UNK1 = 0x00000001,
CHARACTER_FLAG_UNK2 = 0x00000002,
CHARACTER_LOCKED_FOR_TRANSFER = 0x00000004,
CHARACTER_FLAG_UNK4 = 0x00000008,
CHARACTER_FLAG_UNK5 = 0x00000010,
CHARACTER_FLAG_UNK6 = 0x00000020,
CHARACTER_FLAG_UNK7 = 0x00000040,
CHARACTER_FLAG_UNK8 = 0x00000080,
CHARACTER_FLAG_UNK9 = 0x00000100,
CHARACTER_FLAG_UNK10 = 0x00000200,
CHARACTER_FLAG_HIDE_HELM = 0x00000400,
CHARACTER_FLAG_HIDE_CLOAK = 0x00000800,
CHARACTER_FLAG_UNK13 = 0x00001000,
CHARACTER_FLAG_GHOST = 0x00002000,
CHARACTER_FLAG_RENAME = 0x00004000,
CHARACTER_FLAG_UNK16 = 0x00008000,
CHARACTER_FLAG_UNK17 = 0x00010000,
CHARACTER_FLAG_UNK18 = 0x00020000,
CHARACTER_FLAG_UNK19 = 0x00040000,
CHARACTER_FLAG_UNK20 = 0x00080000,
CHARACTER_FLAG_UNK21 = 0x00100000,
CHARACTER_FLAG_UNK22 = 0x00200000,
CHARACTER_FLAG_UNK23 = 0x00400000,
CHARACTER_FLAG_UNK24 = 0x00800000,
CHARACTER_FLAG_LOCKED_BY_BILLING = 0x01000000,
CHARACTER_FLAG_DECLINED = 0x02000000,
CHARACTER_FLAG_UNK27 = 0x04000000,
CHARACTER_FLAG_UNK28 = 0x08000000,
CHARACTER_FLAG_UNK29 = 0x10000000,
CHARACTER_FLAG_UNK30 = 0x20000000,
CHARACTER_FLAG_UNK31 = 0x40000000,
CHARACTER_FLAG_UNK32 = 0x80000000
};
void PlayerMgr::Init()
{
@ -58,12 +95,25 @@ void PlayerMgr::_CMCharEnum(f8::MsgHdr& hdr, const cs::CMCharEnum& msg)
if (ret > 0) {
while (!DBEngine::Instance()->Eof()) {
auto char_info = respmsg.add_char_list();
#if 1
char_info->set_guid(1);
#else
char_info->set_guid(App::Instance()->NewUuid());
#endif
char_info->set_name(DBEngine::Instance()->GetValue(1).GetString());
char_info->set_race(DBEngine::Instance()->GetValue(2));
char_info->set_class_(DBEngine::Instance()->GetValue(3));
char_info->set_gender(DBEngine::Instance()->GetValue(4));
//skin face hair_style hair_color facial_hair
unsigned int player_bytes = DBEngine::Instance()->GetValue(5);
char_info->set_skin((unsigned char)player_bytes);
char_info->set_face((unsigned char)(player_bytes >> 8));
char_info->set_hair_style((unsigned char)(player_bytes >> 16));
char_info->set_hair_color((unsigned char)(player_bytes >> 24));
unsigned int player_bytes2 = DBEngine::Instance()->GetValue(6);
char_info->set_facial_hair((unsigned char)player_bytes2);
char_info->set_level(DBEngine::Instance()->GetValue(7));
char_info->set_zone(DBEngine::Instance()->GetValue(8));
char_info->set_map(DBEngine::Instance()->GetValue(9));
@ -71,8 +121,21 @@ void PlayerMgr::_CMCharEnum(f8::MsgHdr& hdr, const cs::CMCharEnum& msg)
char_info->set_y(DBEngine::Instance()->GetValue(11).GetDouble());
char_info->set_z(DBEngine::Instance()->GetValue(12).GetDouble());
char_info->set_guild_id(DBEngine::Instance()->GetValue(13));
char_info->set_char_flags(DBEngine::Instance()->GetValue(14));
char_info->set_first_login(0);
unsigned int char_flags = 0;
unsigned int playerFlags = DBEngine::Instance()->GetValue(14);
unsigned int atLoginFlags = DBEngine::Instance()->GetValue(15);
if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
{ char_flags |= CHARACTER_FLAG_HIDE_HELM; }
if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
{ char_flags |= CHARACTER_FLAG_HIDE_CLOAK; }
if (playerFlags & PLAYER_FLAGS_GHOST)
{ char_flags |= CHARACTER_FLAG_GHOST; }
if (atLoginFlags & AT_LOGIN_RENAME)
{ char_flags |= CHARACTER_FLAG_RENAME; }
char_info->set_char_flags(char_flags);
char_info->set_first_login(atLoginFlags & AT_LOGIN_FIRST ? 1 : 0);
//pet_display_id
//pet_level
//pet_family