1
This commit is contained in:
parent
a3e2157b07
commit
23481dd384
@ -341,9 +341,7 @@ void App::ProcessIMMsg()
|
||||
break;
|
||||
case IM_ClientSocketDisconnect:
|
||||
{
|
||||
#if 0
|
||||
PlayerMgr::Instance()->OnClientDisconnect(pdelnode->params);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case IM_ExecGM:
|
||||
|
@ -115,5 +115,18 @@ enum ResponseCodes
|
||||
CHAR_NAME_SUCCESS = 0x52,
|
||||
};
|
||||
|
||||
#define MAX_PET_STABLES 2
|
||||
|
||||
// stored in character_pet.slot
|
||||
enum PetSaveMode
|
||||
{
|
||||
PET_SAVE_AS_DELETED = -1, // not saved in fact
|
||||
PET_SAVE_AS_CURRENT = 0, // in current slot (with player)
|
||||
PET_SAVE_FIRST_STABLE_SLOT = 1,
|
||||
PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT
|
||||
PET_SAVE_NOT_IN_SLOT = 100, // for avoid conflict with stable size grow will use 100
|
||||
PET_SAVE_REAGENTS = 101 // PET_SAVE_NOT_IN_SLOT with reagents return
|
||||
};
|
||||
|
||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "cs_proto.pb.h"
|
||||
#include "dbengine.h"
|
||||
#include "GCListener.h"
|
||||
#include "app.h"
|
||||
|
||||
void PlayerMgr::Init()
|
||||
{
|
||||
@ -33,7 +34,51 @@ void PlayerMgr::_CMAuthSession(f8::MsgHdr& hdr, const cs::CMAuthSession& msg)
|
||||
|
||||
void PlayerMgr::_CMCharEnum(f8::MsgHdr& hdr, const cs::CMCharEnum& msg)
|
||||
{
|
||||
int i = 0;
|
||||
TempSession* tmp_session = GetTempSessionBySocket(hdr.socket_handle);
|
||||
assert(tmp_session);
|
||||
std::string sql =
|
||||
"SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, "
|
||||
"characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, guild_member.guildid, characters.playerFlags, "
|
||||
"characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache "
|
||||
"FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='%u' "
|
||||
"LEFT JOIN guild_member ON characters.guid = guild_member.guid "
|
||||
"WHERE characters.account = '%u' ORDER BY characters.guid";
|
||||
int ret = DBEngine::Instance()->ExecQuery(
|
||||
sql.c_str(),
|
||||
{
|
||||
PET_SAVE_AS_CURRENT,
|
||||
tmp_session->account_id
|
||||
});
|
||||
cs::SMCharEnum respmsg;
|
||||
if (ret > 0) {
|
||||
while (!DBEngine::Instance()->Eof()) {
|
||||
auto char_info = respmsg.add_char_list();
|
||||
char_info->set_guid(App::Instance()->NewUuid());
|
||||
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
|
||||
char_info->set_level(DBEngine::Instance()->GetValue(7));
|
||||
char_info->set_zone(DBEngine::Instance()->GetValue(8));
|
||||
char_info->set_map(DBEngine::Instance()->GetValue(9));
|
||||
char_info->set_x(DBEngine::Instance()->GetValue(10).GetDouble());
|
||||
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));
|
||||
//first_login
|
||||
//pet_display_id
|
||||
//pet_level
|
||||
//pet_family
|
||||
for (int i = 0; i < 19; ++i) {
|
||||
auto p = char_info->add_inventory_list();
|
||||
}
|
||||
respmsg.set_char_num(respmsg.char_num() + 1);
|
||||
DBEngine::Instance()->Next();
|
||||
}
|
||||
}
|
||||
GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
|
||||
}
|
||||
|
||||
int PlayerMgr::OnlineNum()
|
||||
@ -48,10 +93,20 @@ Player* PlayerMgr::GetPlayerBySocket(int socket)
|
||||
|
||||
void PlayerMgr::OnClientDisconnect(a8::XParams& param)
|
||||
{
|
||||
|
||||
auto itr = tmp_session_hash_.find(param.sender);
|
||||
if (itr != tmp_session_hash_.end()) {
|
||||
delete itr->second;
|
||||
tmp_session_hash_.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMgr::RemovePlayerBySocket(int socket_handle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TempSession* PlayerMgr::GetTempSessionBySocket(int socket_handle)
|
||||
{
|
||||
auto itr = tmp_session_hash_.find(socket_handle);
|
||||
return itr != tmp_session_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
@ -6,6 +6,11 @@ namespace cs
|
||||
class CMCharEnum;
|
||||
}
|
||||
|
||||
struct TempSession
|
||||
{
|
||||
int account_id = 0;
|
||||
};
|
||||
|
||||
class Player;
|
||||
class PlayerMgr : public a8::Singleton<PlayerMgr>
|
||||
{
|
||||
@ -27,7 +32,9 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
||||
Player* GetPlayerBySocket(int socket);
|
||||
void OnClientDisconnect(a8::XParams& param);
|
||||
void RemovePlayerBySocket(int socket_handle);
|
||||
TempSession* GetTempSessionBySocket(int socket_handle);
|
||||
|
||||
private:
|
||||
std::map<int, Player*> socket_hash_;
|
||||
std::map<int, TempSession*> tmp_session_hash_;
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ message MFInventory
|
||||
|
||||
message MFPlayerInfo
|
||||
{
|
||||
optional int32 guid = 1;
|
||||
optional int64 guid = 1;
|
||||
optional string name = 2;
|
||||
optional int32 race = 3 [(fixed_len) = 1];
|
||||
optional int32 class = 4 [(fixed_len) = 1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user