Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2232
Server/RylServerProject/RylGameLibrary/Community/guild/Guild.cpp
Normal file
2232
Server/RylServerProject/RylGameLibrary/Community/guild/Guild.cpp
Normal file
File diff suppressed because it is too large
Load Diff
194
Server/RylServerProject/RylGameLibrary/Community/guild/Guild.h
Normal file
194
Server/RylServerProject/RylGameLibrary/Community/guild/Guild.h
Normal file
@@ -0,0 +1,194 @@
|
||||
|
||||
#ifndef _GUILD_H_
|
||||
#define _GUILD_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <Network/Packet/PacketStruct/GuildPacket.h>
|
||||
#include <Community/Guild/GuildConstants.h>
|
||||
|
||||
|
||||
// 전방 참조
|
||||
class CAggresiveCreature;
|
||||
class CCharacter;
|
||||
class CCell;
|
||||
class CSession;
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
// 길드 이름에 부적절한 글자가 있는지 살핀다.
|
||||
bool CheckGuildName(const char* szGuildName);
|
||||
|
||||
class CGuild
|
||||
{
|
||||
protected:
|
||||
|
||||
// 길드 클래스는 길드 매니저에서만 생성 가능 (삭제는 유틸을 이용하는 관계로 public)
|
||||
CGuild(void);
|
||||
CGuild(unsigned long dwGID, unsigned char cNation, char* szName);
|
||||
CGuild(GuildInfoDB& guildInfo);
|
||||
|
||||
friend class CGuildMgr;
|
||||
|
||||
public:
|
||||
|
||||
~CGuild(void);
|
||||
|
||||
public:
|
||||
|
||||
// 클라이언트에게 정보를 받아 체크하고 중계 서버로 보내준다.
|
||||
// (TODO : 각종 에러들은 필요시 넘버링해준다. 일단은 모두 SERVER_ERROR.)
|
||||
unsigned short SetMark(unsigned long dwSenderID, char *szMark);
|
||||
bool SetLevel(unsigned long dwMaster, unsigned char cLevel);
|
||||
bool SetRight(unsigned long dwMaster, GuildRight guildRight);
|
||||
bool SetTitle(unsigned long dwSuperior, unsigned long dwFollower, unsigned char cTitle, unsigned short &wError);
|
||||
|
||||
bool JoinMember(unsigned long dwCID, unsigned char cTitle, unsigned short &wError);
|
||||
bool JoinMemberDB(GuildMemberDB& guildMemberDB);
|
||||
virtual bool JoinMember(MemberInfo& memberInfo);
|
||||
|
||||
bool TacticsMember(unsigned long dwCID, unsigned char cTitle, unsigned char cType, unsigned short &wError);
|
||||
|
||||
bool SetTacticsTitle(unsigned long dwSuperior, unsigned long dwFollower, unsigned short wCmd, unsigned char cTitle, unsigned char cType, unsigned short &wError);
|
||||
|
||||
bool SetTacticsTitle(unsigned long dwCID, unsigned char cTitle);
|
||||
|
||||
bool IsMember(unsigned long dwCID);
|
||||
bool IsTacticsWaitMember(unsigned long dwCID);
|
||||
|
||||
bool KickMember(unsigned long dwSuperior, unsigned long dwFollower, unsigned short &wError);
|
||||
|
||||
bool KickTacticsMember(unsigned long dwSuperior, unsigned long dwFollower, unsigned short wCmd, unsigned short &wError);
|
||||
|
||||
bool LeaveTacticsMember(unsigned long dwCID, unsigned long dwReferenceID, unsigned short wCmd);
|
||||
|
||||
bool UpdateMemberInfo(unsigned long dwCID, unsigned long dwValue, unsigned char cCmd);
|
||||
|
||||
// 중계 서버로부터 정보를 받아 처리하고 클라이언트에게 알려준다.
|
||||
unsigned short SetMark(unsigned long dwSenderID, char *szMark, unsigned long dwGold);
|
||||
bool SetLevel(unsigned char cLevel, unsigned long dwGold);
|
||||
bool SetRight(GuildRight guildRight);
|
||||
virtual bool SetTitle(unsigned long dwCID, unsigned char cTitle);
|
||||
bool SetRelation(unsigned long dwTargetGID, unsigned char cRelationType, unsigned char cActorType=Guild::BY_MINE);
|
||||
|
||||
bool UpdateMemberInfo(unsigned long dwCID, MemberListInfo memberListInfo, MemberDetailInfo memberDetailInfo);
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
MemberInfo GetMaster(void);
|
||||
|
||||
unsigned char GetTitle(unsigned long dwCID);
|
||||
|
||||
const unsigned long GetGID(void) { return m_dwGID; }
|
||||
const char* GetName(void) { return m_strName; }
|
||||
const unsigned long GetFame(void) { return m_dwFame; }
|
||||
const GuildRight& GetRight(void) { return m_GuildRight; }
|
||||
const unsigned long GetGold(void) { return m_dwGold; }
|
||||
|
||||
const unsigned char GetCurrentAllMember(void) const; // 모든 멤버.
|
||||
const unsigned char GetTotalMemberNum(void) const; // 용병을 포함한 모든 멤버
|
||||
const unsigned char GetCurrentMemberNum(void) const; // 가입대기자, 용병을 제외한 멤버
|
||||
const unsigned char GetMemberNum(void) const; // 용병을 제외한 멤버수
|
||||
const unsigned char GetTacticsNum(void) const; // 용병 수
|
||||
|
||||
|
||||
const float GetGuildBonus(unsigned char cRealmPoint, float fPercent = 5.0f); // 길드 보너스 관련 함수
|
||||
|
||||
const unsigned char GetLoginMemberNum(void) const; // 게임중인 길드원수
|
||||
const unsigned char GetMaxMemberNum(void) const; // 최대 길드원수
|
||||
|
||||
const unsigned char GetNation(void) const { return m_cInclination; }
|
||||
const bool IsPeaceMode(void);
|
||||
|
||||
void SetGuildMiles(unsigned long dwGuildMiles);
|
||||
const unsigned long GetGuildMiles() const { return m_dwGuildMiles; }
|
||||
|
||||
|
||||
bool AddGold(unsigned long dwGold);
|
||||
bool DeductGold(unsigned long dwGold);
|
||||
void ReleaseGold(unsigned long dwGold);
|
||||
|
||||
bool AutoRouting(CAggresiveCreature* lpPickkingCreature, Item::CItem* lpItem, unsigned long& dwGold);
|
||||
int GetNearMemberList(CCell *pCell, CCharacter **aryNearCharacterList);
|
||||
|
||||
void UpgradeMemberRespawnSpeedByEmblem(unsigned char cUpgradeType, unsigned char cUpgradeStep);
|
||||
void DegradeMemberRespawnSpeedByEmblem();
|
||||
|
||||
unsigned char GetRelation(unsigned long dwGID, unsigned char cActorType=Guild::BY_MINE);
|
||||
int GetNumOfRelation(unsigned char cRelationType, unsigned char cActorType=Guild::BY_MINE);
|
||||
unsigned long GetRelationGID(unsigned char cRelationType, unsigned char cActorType=Guild::BY_MINE);
|
||||
// Vincent - GetRelationGID() 함수는 적대 선언을 1개 이상 할수 있을경우에는 변경되어야한다.!!
|
||||
|
||||
bool IsEnemyGuild(unsigned long dwGID);
|
||||
|
||||
bool InviteMember(unsigned long dwMember, unsigned long dwGuest, unsigned short &wError);
|
||||
bool LeaveMember(unsigned long dwCID);
|
||||
bool LogInOutMember(unsigned long dwCID, unsigned long dwServerID);
|
||||
|
||||
const GuildLargeInfoNode GetLargeInfo(unsigned char cIndexOfPage, unsigned short wRank, CGuild* lpRelationGuild);
|
||||
|
||||
bool SendGuildSafe(unsigned long dwCID, char* szCharName, unsigned char cCmd);
|
||||
bool SendMemberList(CCharacter* lpCharacter, unsigned char cMemberType, unsigned char cSortCmd, unsigned char cPage);
|
||||
void SendAllMember(const char* szPacket, unsigned long dwPacketSize, unsigned char cCMD_In);
|
||||
void SendCurrentMember(const char* szPacket, unsigned long dwPacketSize, unsigned char cCMD_In);
|
||||
bool SendHostilityList(CCharacter* lpCharacter, unsigned char cCurrentPage, unsigned char cPageState);
|
||||
|
||||
void ChangeMemberName(unsigned long dwCID, const char* szChangeName);
|
||||
|
||||
TIME* GetGuildPointTime(void) { return &m_tmGuildPoint; }
|
||||
unsigned char GetGuildPointFlag(void) { return m_cGuildPointFlag; }
|
||||
void SetGuildPointFlag(unsigned char cFlag) { m_cGuildPointFlag = cFlag; }
|
||||
|
||||
// 길드 관련 메소드
|
||||
void SetGuildSafe(char cGuildSafe) { m_cGuildSafe = cGuildSafe; }
|
||||
char GetGuildSafe() { return m_cGuildSafe; }
|
||||
|
||||
protected:
|
||||
|
||||
bool InsertRelation(unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelation);
|
||||
|
||||
void CalculateGuildFame(void);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// 멤버 변수
|
||||
char m_cGuildSafe;
|
||||
|
||||
unsigned long m_dwGID; // 길드 아이디
|
||||
|
||||
char m_strName[MAX_GUILD_NAME_LEN]; // 길드 이름
|
||||
char m_szMark[MAX_MARK_SIZE]; // 길드 마크
|
||||
|
||||
unsigned char m_cInclination; // 길드 성향 (Guild::Inclination 참고)
|
||||
unsigned char m_cLevel; // 길드 레벨
|
||||
|
||||
unsigned long m_dwFame; // 길드 명성
|
||||
unsigned long m_dwGold; // 길드 금고
|
||||
|
||||
unsigned char m_cGuildPointFlag; // 길드 재정비 관련.
|
||||
|
||||
TIME m_tmLastLogout; /* 최종 길드원 로그아웃 시간
|
||||
(일정 시간동안 길드원이 아무도 로그인하지 않으면 길드가 삭제된다.) */
|
||||
|
||||
TIME m_tmCheckMember; // 길드원 수가 일정 인원 미만으로 떨어져 길드가 삭제되기까지의 시간
|
||||
|
||||
TIME m_tmGMLastLogout; /* 길드 마스터의 로그아웃 시간
|
||||
(일정 시간동안 길드 마스터가 로그인하지 않으면 다음 서열의 길드원이 길드 마스터가 된다.) */
|
||||
|
||||
TIME m_tmChangeInclination; // 길드 성향을 변경한 시간 (24시간 이내에는 다시 변경할 수 없다.)
|
||||
|
||||
TIME m_tmGuildPoint; // 길드 재정비 관련 시간.
|
||||
|
||||
GuildRight m_GuildRight; // 길드 권한
|
||||
|
||||
MemberList m_MemberList; // 길드원
|
||||
|
||||
RelationMap m_Relation[Guild::MAX_RELATION_ACTOR]; // 내가 맺은 길드 관계 / 다른 길드에 의해 맺어진 길드 관계
|
||||
|
||||
unsigned long m_dwGuildMiles;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,180 @@
|
||||
|
||||
#ifndef _GUILD_CONSTANTS_H_
|
||||
#define _GUILD_CONSTANTS_H_
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
enum Const
|
||||
{
|
||||
MAX_GUILD_NAME_LEN = 11, // 길드 이름의 최대 길이 (실제 길이)
|
||||
MAX_GUILD_NAME_FOR_DB = 20, // 길드 이름의 최대 길이 (DB 저장용)
|
||||
MAX_MEMBER_NAME_LEN = 16, // 길드원 이름의 최대 길이 (일반적인 캐릭터 이름의 최대 길이와 동일)
|
||||
|
||||
MAX_MARK_SIZE = 18 * 12 * 2 + 1, // 길드 마크 크기 (18 * 12 크기의 16비트 칼라의 BMP 파일, 첫 1바이트는 마크 존재 여부)
|
||||
MAX_RIGHT_SIZE = 50, // 길드 권한 구조체 크기
|
||||
|
||||
MAX_MEMBER_NUM = 100, // 멤버 수가 가질 수 있는 최대 크기 (가입대기자 때문에 여유분을 더 둔다.)
|
||||
MAX_RELATION_NUM = 255, // 우호/적대 관계 리스트의 최대 크기 (카운터 적대 신청때문에 여유분을 더 둔다.)
|
||||
MAX_HOSTILITY_APPLY_NUM = 49, // 대상으로 받을수 있는 최대 적대 관계 수
|
||||
MAX_HOSTILITY_NUM = 1, // 자신이 적대 선언할 수 있는 최대 수
|
||||
MAX_ALERT_NUM = 1, // 자신이 경계 적대 선언할 수 있는 최대 수
|
||||
|
||||
MAX_LEVEL = 5, // 길드의 최대 레벨
|
||||
CREATE_LEVEL = 30, // 길드 생성시 요구되는 최소 캐릭터 레벨
|
||||
CREATE_LEVEL_FOR_CHINA = 15, // (중국용) 길드 생성시 요구되는 최소 캐릭터 레벨
|
||||
SET_MARK_GOLD = 5000000, // 마크 변경시 필요한 금액
|
||||
FAME_LEAVE_PENALTY = 1000, // 길드마스터의 승인 없이 탈퇴시 깎이는 명성
|
||||
|
||||
MAX_SMALL_NODE_NUM = 500, // 한번에 전송 가능한 길드 간략 정보의 최대 숫자
|
||||
MEMBER_INFO_UPDATE_COUNT = 10, // 길드원 정보를 다른 서버에 업데이트하는 타이밍
|
||||
DELETE_GUILD_MEMBER_NUM = 4, // 길드가 유지될 수 있는 최소 인원
|
||||
|
||||
MINUTES_PER_HOUR = 60,
|
||||
|
||||
// 해외의 요청을 수용하여 탈퇴 대기 시간이 없어졌습니다. (2005-06-13 by 로딘)
|
||||
LEAVE_WAIT_TIME = 0, // 탈퇴 대기 기간 (단위 : 분)
|
||||
LEAVE_WAIT_TIME_FOR_CHINA = 10080, // (중국용) 탈퇴 대기 기간 (단위 : 분)
|
||||
DELETE_GUILD_LOGOUT_TIME = 43200, // 길드원이 로그인하지 않아 길드가 해체될 때까지의 기간 (단위 : 분)
|
||||
MEMBER_NUM_DELETE_TIME = 1440, // 길드원이 DELETE_GUILD_MEMBER_NUM 미만이 된 후 길드 해체까지의 기간 (단위 : 분)
|
||||
TRANFER_MASTER_TIME = 20160, // 오랫동안 접속하지 않은 길드마스터의 권한 양도 기간 (단위 : 분)
|
||||
CHANGE_INCLINATION_TIME = 1440, // 길드 성향 변경 후 다시 변경할 수 있을 때까지의 기간 (단위 : 분)
|
||||
RELATION_WAIT_TIME = 1440, // 관계 변경 대기 시간 (단위 : 분)
|
||||
|
||||
/*
|
||||
// Test : 길드 테스트를 위한 시간
|
||||
LEAVE_WAIT_TIME_FOR_CHINA = 10, // (중국용) 탈퇴 대기 기간 (단위 : 분)
|
||||
DELETE_GUILD_LOGOUT_TIME = 30, // 길드원이 로그인하지 않아 길드가 해체될 때까지의 기간 (단위 : 분)
|
||||
MEMBER_NUM_DELETE_TIME = 15, // 길드원이 DELETE_GUILD_MEMBER_NUM 미만이 된 후 길드 해체까지의 기간 (단위 : 분)
|
||||
TRANFER_MASTER_TIME = 20, // 오랫동안 접속하지 않은 길드마스터의 권한 양도 기간 (단위 : 분)
|
||||
CHANGE_INCLINATION_TIME = 10, // 길드 성향 변경 후 다시 변경할 수 있을 때까지의 기간 (단위 : 분)
|
||||
RELATION_WAIT_TIME = 1, // 관계 변경 대기 시간 (단위 : 분)
|
||||
*/
|
||||
|
||||
MEMBER_WAIT_BIT = 0x80000000, // 가입 대기자에게 마크를 달지못하게 하는 플래그
|
||||
|
||||
TIME_GUILD_POINT = 30, // 길드전 재정비 시간(분단위).
|
||||
|
||||
TACTICE_JON_LEVEL = 1, // 용병 가입 레벨.
|
||||
|
||||
TACTICS = 1, // 용병.
|
||||
TACTICS_WAIT = 2, // 용병 가입 대기자.
|
||||
};
|
||||
|
||||
enum Title
|
||||
{
|
||||
NONE = 0,
|
||||
MASTER = 1, // 길드 마스터
|
||||
MIDDLE_ADMIN = 2, // 중간 관리자
|
||||
COMMON = 3, // 일반 길드원
|
||||
LEAVE_WAIT = 4, // 탈퇴 대기자
|
||||
JOIN_WAIT = 5, // 가입 대기자
|
||||
|
||||
MAX_TITLE = 6
|
||||
};
|
||||
|
||||
enum MemberType
|
||||
{
|
||||
TYPE_MEMBER = 0, // 멤버
|
||||
TYPE_TACTICS = 1 // 용병
|
||||
};
|
||||
|
||||
enum GuildSort
|
||||
{
|
||||
GUILD_FAME = 0, // 순위(명성)
|
||||
GUILD_NAME = 1, // 길드명
|
||||
GUILD_HOSTILITY = 2, // 적대길드
|
||||
GUILD_NEUTRALITY = 3, // 비적대길드
|
||||
GUILD_MINE = 4, // 자신의 길드
|
||||
|
||||
GUILD_REQUEST = 5 // 길드 리스트 요청 (셀 로긴 등에 의한 무작위 정보 요청)
|
||||
};
|
||||
|
||||
enum MemberSort
|
||||
{
|
||||
MEMBER_TITLE = 0, // 직위순
|
||||
MEMBER_CLASS = 1, // 클래스별 소트
|
||||
MEMBER_LEVEL = 2, // 레벨별 소트
|
||||
MEMBER_FAME = 3, // 명성별 소트
|
||||
MEMBER_NAME = 4, // 이름별 소트
|
||||
MEMBER_GOLD = 5, // 소지금액별 소트
|
||||
MEMBER_POSITION = 6, // 위치별 소트
|
||||
MEMBER_JOIN_WAIT = 7, // 신청중인 플레이어
|
||||
MEMBER_WAR_ON = 8, // 길드 전쟁 참여중인 멤버 (이름순으로 소트)
|
||||
MEMBER_WAR_OFF = 9, // 길드 전쟁 불참중인 멤버 (이름순으로 소트)
|
||||
TACTICS_JOIN_WAIT = 10, // 신청중인 용병 (높은 레벨 순)
|
||||
TACTICS_ACTIVE = 11 // 활동중인 용병 (높은 레벨 순)
|
||||
};
|
||||
|
||||
enum Relation
|
||||
{
|
||||
NEUTRALITY = 0, // 중립 관계
|
||||
HOSTILITY = 1, // 적대
|
||||
COUNTER_HOSTILITY = 2, // 카운터 적대
|
||||
ALERT_HOSTILITY = 3, // 경계 적대
|
||||
MINE = 4, // 자신의 길드
|
||||
TARGET_NEUTRALITY = 5, // A->B적대를 하면 DB값이 1로 저장되고 이상태에서 피스를 선언하면
|
||||
// 해당값이 5로 바뀐다. 5로 바뀐뒤에는 B길드가 적대선언삭제를 해주면
|
||||
// 이때 DB에서 사라져 완전히 평화관계가 된다.
|
||||
|
||||
ALL_HOSTILITY = 6 // 모든 적대 관계
|
||||
};
|
||||
|
||||
enum RelationActor
|
||||
{
|
||||
BY_MINE = 0, // 자신이 맺은 길드 관계
|
||||
BY_TARGET = 1, // 대상으로부터 받은 길드 관계
|
||||
|
||||
MAX_RELATION_ACTOR = 2
|
||||
};
|
||||
|
||||
// 중계 서버 전용
|
||||
enum TimeUpdateType
|
||||
{
|
||||
// 수정시엔 CDBObject::UpdateGuildTime 함수를 주의
|
||||
|
||||
LAST_LOGOUT = 0, // 길드원이 마지막으로 로그아웃한 시각
|
||||
MEMBER_NUM_DOWN = 1, // 길드원 수가 3인 이하가 된 시각
|
||||
MASTER_LOGOUT = 2 // 마스터가 마지막으로 로그아웃한 시각
|
||||
};
|
||||
|
||||
enum ErrType
|
||||
{
|
||||
S_SUCCESS = 0,
|
||||
|
||||
// CGuild::SetTitle 함수용
|
||||
E_NOT_MEMBER = 1, // 길드원이 아님
|
||||
E_DISSOLVE_GUILD = 2, // 길드 해체
|
||||
E_NOT_CHANGE = 3, // 변경된 바 없음
|
||||
E_DB_ERROR = 4, // DB 에러
|
||||
E_NOT_TEMP_MASTER = 5 // 임시 마스터가 될 길드원이 없음
|
||||
};
|
||||
|
||||
enum AddFameType
|
||||
{
|
||||
// CGuildDB::AddAllMemberFame, AddFriendGuildMemberFame, AddMemberFame 함수용
|
||||
|
||||
TYPE_VALUE = 0, // Fame 값을 그대로 더해준다.
|
||||
TYPE_HALF = 1, // 명성치를 1/2로 만든다.
|
||||
TYPE_QUARTER = 2 // 명성치를 1/4로 만든다.
|
||||
};
|
||||
|
||||
// 게임 서버 전용
|
||||
enum MemberInfoUpdateType
|
||||
{
|
||||
// CGuild::UpdateMemberInfo 함수 참조
|
||||
|
||||
TYPE_LEVEL = 0,
|
||||
TYPE_CLASS = 1,
|
||||
TYPE_FAME = 2,
|
||||
TYPE_GOLD = 3,
|
||||
TYPE_WARFLAG = 4
|
||||
};
|
||||
|
||||
const unsigned char ms_aryMaxMemberNum[MAX_LEVEL] = { 10, 20, 30, 40, 50 };
|
||||
const unsigned long ms_arySetLevelFame[MAX_LEVEL] = { 0, 1000, 3000, 5000, 10000 };
|
||||
const unsigned long ms_arySetLevelFameForUSA[MAX_LEVEL] = { 0, 400, 2000, 5000, 10000 };
|
||||
const unsigned long ms_arySetLevelGold[MAX_LEVEL] = { 1000000, 5000000, 10000000, 50000000, 100000000 };
|
||||
const unsigned long ms_arySetLevelGoldForChina[MAX_LEVEL] = { 100000, 5000000, 10000000, 50000000, 100000000 };
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,739 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <Utility/CheckSum/Crc32Static.h>
|
||||
|
||||
#include <Network/Dispatch/GameClient/GameClientDispatch.h>
|
||||
#include <Network/Stream/SendStream.h>
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/WrapPacket.h>
|
||||
|
||||
#include <Creature/CreatureManager.h>
|
||||
#include <Creature/Character/Character.h>
|
||||
|
||||
#include "GuildUtil.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
|
||||
|
||||
using namespace Guild;
|
||||
|
||||
|
||||
CGuildMgr& CGuildMgr::GetInstance()
|
||||
{
|
||||
static CGuildMgr guildMgr;
|
||||
return guildMgr;
|
||||
}
|
||||
|
||||
CGuildMgr::CGuildMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
CGuildMgr::~CGuildMgr(void)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CGuildMgr::Destroy(void)
|
||||
{
|
||||
std::for_each(m_GuildMap.begin(), m_GuildMap.end(), FnDeleteSecond());
|
||||
m_GuildMap.clear();
|
||||
m_GuildNameMap.clear();
|
||||
}
|
||||
|
||||
bool CGuildMgr::CreateGuild(unsigned long dwMasterID, unsigned long dwGuildID, unsigned char cInclination, char* szGuildName)
|
||||
{
|
||||
CGuild* lpGuild = new CGuild(dwGuildID, cInclination, szGuildName);
|
||||
|
||||
if (false == m_GuildMap.insert(GuildMap::value_type(dwGuildID, lpGuild)).second)
|
||||
{
|
||||
delete lpGuild;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == m_GuildNameMap.insert(GuildNameMap::value_type(std::string(szGuildName), lpGuild)).second)
|
||||
{
|
||||
m_GuildMap.erase(dwGuildID);
|
||||
delete lpGuild;
|
||||
return false;
|
||||
}
|
||||
|
||||
PktCreateGuild pktCG;
|
||||
pktCG.m_dwCID = 0;
|
||||
pktCG.m_dwGID = dwGuildID;
|
||||
pktCG.m_cInclination = cInclination;
|
||||
::memcpy(pktCG.m_szGuildName, szGuildName, MAX_GUILD_NAME_LEN);
|
||||
|
||||
char* szPacket = reinterpret_cast<char *>(&pktCG);
|
||||
if (PacketWrap::WrapCrypt(szPacket, sizeof(PktCreateGuild), CmdCreateGuild, 0, 0))
|
||||
{
|
||||
CCreatureManager::GetInstance().SendAllCharacter(szPacket, sizeof(PktCreateGuild), CmdCreateGuild);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGuildMgr::GetMemberList(unsigned long dwGID, const MemberList* pMemberList)
|
||||
{
|
||||
GuildMap::iterator it = m_GuildMap.find(dwGID);
|
||||
|
||||
if (it == m_GuildMap.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CGuild* lpGuild = it->second;
|
||||
|
||||
if(lpGuild)
|
||||
{
|
||||
pMemberList = &lpGuild->m_MemberList;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGuildMgr::DissolveGuild(unsigned long dwGID)
|
||||
{
|
||||
GuildMap::iterator it = m_GuildMap.find(dwGID);
|
||||
if (it == m_GuildMap.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef std::vector<unsigned long> DissolveCIDList;
|
||||
|
||||
CGuild* lpGuild = it->second;
|
||||
|
||||
MemberList& memberList = lpGuild->m_MemberList;
|
||||
|
||||
MemberList::iterator member_pos = memberList.begin();
|
||||
MemberList::iterator member_end = memberList.end();
|
||||
|
||||
DissolveCIDList dissolveList;
|
||||
dissolveList.reserve(memberList.size());
|
||||
|
||||
while (member_pos != member_end)
|
||||
{
|
||||
dissolveList.push_back(member_pos->m_dwCID);
|
||||
++member_pos;
|
||||
}
|
||||
|
||||
DissolveCIDList::iterator dissolve_pos = dissolveList.begin();
|
||||
DissolveCIDList::iterator dissolve_end = dissolveList.end();
|
||||
|
||||
while (dissolve_pos != dissolve_end)
|
||||
{
|
||||
lpGuild->LeaveMember(*dissolve_pos);
|
||||
++dissolve_pos;
|
||||
}
|
||||
|
||||
m_GuildNameMap.erase(lpGuild->m_strName);
|
||||
|
||||
m_GuildMap.erase(it);
|
||||
delete lpGuild;
|
||||
|
||||
PktCreateGuild pktCG;
|
||||
pktCG.m_dwGID = dwGID;
|
||||
|
||||
char* szPacket = reinterpret_cast<char*>(&pktCG);
|
||||
if (PacketWrap::WrapCrypt(szPacket, sizeof(PktCreateGuild), CmdCreateGuild, 0, PktCreateGuild::FAIL_DISSOLVE_GUILD))
|
||||
{
|
||||
CCreatureManager::GetInstance().SendAllCharacter(szPacket, sizeof(PktCreateGuild), CmdCreateGuild);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CGuild* CGuildMgr::GetGuild(unsigned long dwGID)
|
||||
{
|
||||
GuildMap::iterator it = m_GuildMap.find(dwGID);
|
||||
if (it == m_GuildMap.end()) { return NULL; }
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
CGuild* CGuildMgr::GetGuild(char* szName)
|
||||
{
|
||||
GuildNameMap::iterator it = m_GuildNameMap.find(szName);
|
||||
if (it == m_GuildNameMap.end()) { return NULL; }
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
bool CGuildMgr::SetRelation(unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType)
|
||||
{
|
||||
CGuild* lpGuild = GetGuild(dwGID);
|
||||
CGuild* lpTargetGuild = GetGuild(dwTargetGID);
|
||||
|
||||
if (NULL == lpGuild || NULL == lpTargetGuild) { return false; }
|
||||
|
||||
if(Guild::TARGET_NEUTRALITY == cRelationType)
|
||||
{
|
||||
if (!lpGuild->SetRelation(dwTargetGID, cRelationType, Guild::BY_TARGET))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!lpTargetGuild->SetRelation(dwGID, cRelationType, Guild::BY_MINE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
lpGuild->SetRelation(dwTargetGID, cRelationType, Guild::BY_MINE);
|
||||
|
||||
lpTargetGuild->SetRelation(dwGID, cRelationType, Guild::BY_TARGET);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CGuildMgr::SendGuildList(unsigned long dwCID, unsigned char cSortCmd, unsigned char cPage, unsigned char cNum, GuildCheckSumNode* lpNode)
|
||||
{
|
||||
PERFORMANCE_CHECK(FunctionTimingCheck);
|
||||
|
||||
CCharacter* lpCharacter = CCreatureManager::GetInstance().GetCharacter(dwCID);
|
||||
if (NULL == lpCharacter)
|
||||
{
|
||||
ERRLOG1(g_Log, "CID:0x%08x 존재하지 않는 캐릭터가 길드 리스트를 요청하였습니다.", dwCID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cNum > PktGuildList::MAX_NUM_PER_PAGE)
|
||||
{
|
||||
ERRLOG2(g_Log, "CID:0x%08x 길드 리스트의 한 페이지에 찍히는 수를 초과하여 요청하였습니다. 요청노드수:%d",
|
||||
dwCID, cNum);
|
||||
cNum = PktGuildList::MAX_NUM_PER_PAGE;
|
||||
}
|
||||
|
||||
const int MAX_BUFFER = sizeof(PktGuildList) + PktGuildList::MAX_NUM_PER_PAGE * sizeof(GuildLargeInfoNode);
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
PktGuildList* lpPktGLAck = reinterpret_cast<PktGuildList *>(szBuffer);
|
||||
GuildSmallInfoNode* lpSmallInfoNode = reinterpret_cast<GuildSmallInfoNode *>(lpPktGLAck + 1);
|
||||
|
||||
lpPktGLAck->m_dwCID = dwCID;
|
||||
lpPktGLAck->m_cSortCmd = cSortCmd;
|
||||
lpPktGLAck->m_cPage = cPage;
|
||||
|
||||
lpPktGLAck->m_cSmallNodeNum = 0;
|
||||
lpPktGLAck->m_cLargeNodeNum = 0;
|
||||
|
||||
GuildLargeInfoNode aryCurrentInfoList[PktGuildList::MAX_NUM_PER_PAGE];
|
||||
// 무작위 요청의 경우 원하는 GID를 알아둔다.
|
||||
if (Guild::GUILD_REQUEST == cSortCmd)
|
||||
{
|
||||
for (int nIndex = 0; nIndex < cNum; ++nIndex)
|
||||
{
|
||||
aryCurrentInfoList[nIndex].m_dwGID = (lpNode + nIndex)->m_dwGID;
|
||||
}
|
||||
}
|
||||
|
||||
GetSortingPageList(lpCharacter, cSortCmd, cPage, aryCurrentInfoList);
|
||||
|
||||
int nClientIndex = 0;
|
||||
int nServerIndex = 0;
|
||||
|
||||
// 무작위 요청은 무조건 전체 정보를 보내준다. (대부분 마크가 없어서 요청한 경우임)
|
||||
if (Guild::GUILD_REQUEST != cSortCmd)
|
||||
{
|
||||
for (; nClientIndex < cNum && nServerIndex < PktGuildList::MAX_NUM_PER_PAGE; ++nClientIndex, ++nServerIndex)
|
||||
{
|
||||
unsigned long dwCheckSum = 0;
|
||||
CCrc32Static::BufferCrc32(reinterpret_cast<const char *>(&aryCurrentInfoList[nServerIndex]),
|
||||
sizeof(GuildSmallInfoNode), dwCheckSum);
|
||||
|
||||
if (NULL != lpNode)
|
||||
{
|
||||
if (lpNode->m_dwGID == aryCurrentInfoList[nServerIndex].m_dwGID)
|
||||
{
|
||||
// 클라이언트와 서버의 체크섬 정보가 틀릴 경우 간략 정보를 보낸다.
|
||||
if (lpNode->m_dwCheckSum != dwCheckSum)
|
||||
{
|
||||
*lpSmallInfoNode = static_cast<GuildSmallInfoNode>(aryCurrentInfoList[nServerIndex]);
|
||||
++lpSmallInfoNode;
|
||||
++lpPktGLAck->m_cSmallNodeNum;
|
||||
}
|
||||
|
||||
// 클라이언트와 서버의 GID 정보가 일치할 경우 전체 정보를 보내지 않는다.
|
||||
aryCurrentInfoList[nServerIndex].m_dwGID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
++lpNode;
|
||||
}
|
||||
}
|
||||
|
||||
GuildLargeInfoNode* lpLargeInfoNode = reinterpret_cast<GuildLargeInfoNode *>(lpSmallInfoNode);
|
||||
|
||||
for (nServerIndex = 0; nServerIndex < PktGuildList::MAX_NUM_PER_PAGE; ++nServerIndex)
|
||||
{
|
||||
if (0 != aryCurrentInfoList[nServerIndex].m_dwGID)
|
||||
{
|
||||
*lpLargeInfoNode = aryCurrentInfoList[nServerIndex];
|
||||
++lpLargeInfoNode;
|
||||
++lpPktGLAck->m_cLargeNodeNum;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char cSmallNodeNum = lpPktGLAck->m_cSmallNodeNum;
|
||||
unsigned char cLargeNodeNum = lpPktGLAck->m_cLargeNodeNum;
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpDispatch->GetSendStream();
|
||||
return SendStream.WrapCompress(szBuffer, sizeof(PktGuildList) +
|
||||
cSmallNodeNum * sizeof(GuildSmallInfoNode) + cLargeNodeNum * sizeof(GuildLargeInfoNode),
|
||||
CmdGuildList, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGuildMgr::SendGuildRelationInfo(unsigned long dwCID, unsigned long dwGID)
|
||||
{
|
||||
PERFORMANCE_CHECK(FunctionTimingCheck);
|
||||
|
||||
CCharacter* lpCharacter = CCreatureManager::GetInstance().GetCharacter(dwCID);
|
||||
if (NULL == lpCharacter)
|
||||
{
|
||||
ERRLOG1(g_Log, "CID:0x%08x 존재하지 않는 캐릭터가 길드 관계 리스트를 요청하였습니다.", dwCID);
|
||||
return false;
|
||||
}
|
||||
|
||||
CGuild* lpRequestGuild = GetGuild(dwGID);
|
||||
if (NULL == lpRequestGuild)
|
||||
{
|
||||
ERRLOG1(g_Log, "GID:0x%08x 존재하지 않는 길드의 관계 리스트를 요청하였습니다.", dwGID);
|
||||
return false;
|
||||
}
|
||||
|
||||
const int MAX_BUFFER = sizeof(PktGuildRelationInfo) + Guild::MAX_RELATION_NUM * sizeof(GuildRelationInfoNode);
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
PktGuildRelationInfo* lpPktGRAck = reinterpret_cast<PktGuildRelationInfo *>(szBuffer);
|
||||
GuildRelationInfoNode* lpRelationNode = reinterpret_cast<GuildRelationInfoNode *>(lpPktGRAck + 1);
|
||||
|
||||
lpPktGRAck->m_dwCID = dwCID;
|
||||
lpPktGRAck->m_dwGID = dwGID;
|
||||
lpPktGRAck->m_wNodeNum = 0;
|
||||
|
||||
CGuild* lpGuild = NULL;
|
||||
GuildLargeInfoNode LargeInfo;
|
||||
|
||||
GuildMap::iterator itr = m_GuildMap.begin();
|
||||
while (itr != m_GuildMap.end())
|
||||
{
|
||||
lpGuild = itr->second;
|
||||
if (NULL != lpGuild)
|
||||
{
|
||||
LargeInfo = lpGuild->GetLargeInfo(0, 0, lpRequestGuild);
|
||||
|
||||
if (Guild::NEUTRALITY != LargeInfo.m_cRelationByMine ||
|
||||
Guild::NEUTRALITY != LargeInfo.m_cRelationByTarget)
|
||||
{
|
||||
++lpPktGRAck->m_wNodeNum;
|
||||
|
||||
lpRelationNode->m_dwGID = LargeInfo.m_dwGID;
|
||||
lpRelationNode->m_cRelationByMine = LargeInfo.m_cRelationByMine;
|
||||
lpRelationNode->m_cRelationByTarget = LargeInfo.m_cRelationByTarget;
|
||||
++lpRelationNode;
|
||||
}
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
CSendStream& SendStream = lpDispatch->GetSendStream();
|
||||
return SendStream.WrapCompress(szBuffer, sizeof(PktGuildRelationInfo) +
|
||||
lpPktGRAck->m_wNodeNum * sizeof(GuildRelationInfoNode),
|
||||
CmdGuildRelationInfo, 0, 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGuildMgr::GetSortingPageList(CCharacter* lpCharacter, unsigned char cSortCmd, unsigned char cPage,
|
||||
GuildLargeInfoNode* aryCurrentInfoList)
|
||||
{
|
||||
CGuild* lpMyGuild = GetGuild(lpCharacter->GetGID());
|
||||
unsigned short wStartOfPage = cPage * PktGuildList::MAX_NUM_PER_PAGE;
|
||||
|
||||
// 명성순으로 소트
|
||||
typedef std::pair<unsigned long, CGuild *> GuildPair;
|
||||
unsigned short wGuildNum = static_cast<unsigned short>(m_GuildMap.size());
|
||||
|
||||
if (wGuildNum < wStartOfPage)
|
||||
{
|
||||
if (false == m_GuildMap.empty())
|
||||
{
|
||||
ERRLOG3(g_Log, "CID:0x%08x 요청 불가능한 페이지를 요청하였습니다. 길드수:%d, 페이지:%d",
|
||||
lpCharacter->GetCID(), wGuildNum, cPage);
|
||||
}
|
||||
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE; ++cIndex)
|
||||
{
|
||||
aryCurrentInfoList[cIndex].m_dwGID = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<GuildPair> sortVector;
|
||||
GuildPair NullPair(0, (Guild::CGuild*)NULL);
|
||||
sortVector.reserve(wGuildNum);
|
||||
sortVector.assign(wGuildNum, NullPair);
|
||||
|
||||
std::partial_sort_copy(m_GuildMap.begin(), m_GuildMap.end(), sortVector.begin(), sortVector.end(), CompareGuildFame());
|
||||
if (true == sortVector.empty())
|
||||
{
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE; ++cIndex)
|
||||
{
|
||||
aryCurrentInfoList[cIndex].m_dwGID = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
unsigned short wVectorSize = static_cast<unsigned short>(sortVector.size());
|
||||
|
||||
switch (cSortCmd)
|
||||
{
|
||||
case Guild::GUILD_FAME:
|
||||
{
|
||||
unsigned char cIndex = 0;
|
||||
unsigned short wRank = wStartOfPage;
|
||||
|
||||
for (; cIndex < PktGuildList::MAX_NUM_PER_PAGE && wRank < wVectorSize; ++cIndex, ++wRank)
|
||||
{
|
||||
CGuild* lpGuild = GetGuild(sortVector[wRank].first);
|
||||
if (NULL == lpGuild)
|
||||
{
|
||||
ERRLOG1(g_Log, "GID:0x%08x 존재하지 않는 길드가 소트 벡터에 들어있습니다.", sortVector[wRank].first);
|
||||
break;
|
||||
}
|
||||
|
||||
aryCurrentInfoList[cIndex] = lpGuild->GetLargeInfo(cIndex, wRank + 1, lpMyGuild);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Guild::GUILD_NAME:
|
||||
{
|
||||
GuildNameMap::iterator it = m_GuildNameMap.begin();
|
||||
std::advance(it, wStartOfPage);
|
||||
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE && it != m_GuildNameMap.end();
|
||||
++cIndex, ++it)
|
||||
{
|
||||
CGuild* lpGuild = it->second;
|
||||
if (NULL == lpGuild) { break; }
|
||||
|
||||
for (unsigned short wRank = 0; wRank < wGuildNum; ++wRank)
|
||||
{
|
||||
if (sortVector[wRank].second == lpGuild)
|
||||
{
|
||||
aryCurrentInfoList[cIndex] = lpGuild->GetLargeInfo(cIndex, wRank + 1, lpMyGuild);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Guild::GUILD_HOSTILITY:
|
||||
{
|
||||
if ( NULL != lpMyGuild )
|
||||
{
|
||||
unsigned short wGuildNum = static_cast<unsigned short>(m_GuildNameMap.size());
|
||||
std::vector<unsigned long> sortVector;
|
||||
sortVector.reserve(wGuildNum);
|
||||
|
||||
unsigned char cRelationByMine, cRelationByTarget ;
|
||||
for (GuildNameMap::iterator it = m_GuildNameMap.begin(); it != m_GuildNameMap.end(); ++it)
|
||||
{
|
||||
CGuild* lpGuild = it->second;
|
||||
if (NULL == lpGuild) { break; }
|
||||
|
||||
cRelationByMine = lpMyGuild->GetRelation( lpGuild->GetGID() ) ;
|
||||
cRelationByTarget = lpGuild->GetRelation( lpMyGuild->GetGID() ) ;
|
||||
|
||||
if (Guild::HOSTILITY == cRelationByMine ||
|
||||
Guild::ALERT_HOSTILITY == cRelationByMine ||
|
||||
Guild::COUNTER_HOSTILITY == cRelationByMine ||
|
||||
Guild::TARGET_NEUTRALITY == cRelationByMine ||
|
||||
Guild::HOSTILITY == cRelationByTarget ||
|
||||
Guild::ALERT_HOSTILITY == cRelationByTarget ||
|
||||
Guild::COUNTER_HOSTILITY == cRelationByTarget ||
|
||||
Guild::TARGET_NEUTRALITY == cRelationByTarget)
|
||||
{
|
||||
sortVector.push_back(lpGuild->GetGID());
|
||||
}
|
||||
}
|
||||
|
||||
if (true == sortVector.empty())
|
||||
{
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE; ++cIndex)
|
||||
{
|
||||
aryCurrentInfoList[cIndex].m_dwGID = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned short wVectorSize = static_cast<unsigned short>(sortVector.size());
|
||||
unsigned char cIndex = 0;
|
||||
unsigned short wRank = wStartOfPage;
|
||||
|
||||
for (; cIndex < PktGuildList::MAX_NUM_PER_PAGE && wRank < wVectorSize; ++cIndex, ++wRank)
|
||||
{
|
||||
CGuild* lpGuild = GetGuild(sortVector[wRank]);
|
||||
if (NULL == lpGuild)
|
||||
{
|
||||
ERRLOG1(g_Log, "GID:0x%08x 존재하지 않는 길드가 소트 벡터에 들어있습니다.", sortVector[wRank]);
|
||||
break;
|
||||
}
|
||||
|
||||
aryCurrentInfoList[cIndex] = lpGuild->GetLargeInfo(cIndex, wRank + 1, lpMyGuild);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Guild::GUILD_NEUTRALITY:
|
||||
{
|
||||
if ( NULL != lpMyGuild )
|
||||
{
|
||||
unsigned short wGuildNum = static_cast<unsigned short>(m_GuildNameMap.size());
|
||||
std::vector<unsigned long> sortVector;
|
||||
sortVector.reserve(wGuildNum);
|
||||
|
||||
unsigned char cRelationByMine, cRelationByTarget ;
|
||||
for (GuildNameMap::iterator it = m_GuildNameMap.begin(); it != m_GuildNameMap.end(); ++it)
|
||||
{
|
||||
CGuild* lpGuild = it->second;
|
||||
if (NULL == lpGuild) { break; }
|
||||
|
||||
cRelationByMine = lpMyGuild->GetRelation( lpGuild->GetGID() ) ;
|
||||
cRelationByTarget = lpGuild->GetRelation( lpMyGuild->GetGID() ) ;
|
||||
|
||||
if (Guild::NEUTRALITY == cRelationByMine && Guild::NEUTRALITY == cRelationByTarget)
|
||||
{
|
||||
sortVector.push_back(lpGuild->GetGID());
|
||||
}
|
||||
}
|
||||
|
||||
if (true == sortVector.empty())
|
||||
{
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE; ++cIndex)
|
||||
{
|
||||
aryCurrentInfoList[cIndex].m_dwGID = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned short wVectorSize = static_cast<unsigned short>(sortVector.size());
|
||||
unsigned char cIndex = 0;
|
||||
unsigned short wRank = wStartOfPage;
|
||||
|
||||
for (; cIndex < PktGuildList::MAX_NUM_PER_PAGE && wRank < wVectorSize; ++cIndex, ++wRank)
|
||||
{
|
||||
CGuild* lpGuild = GetGuild(sortVector[wRank]);
|
||||
if (NULL == lpGuild)
|
||||
{
|
||||
ERRLOG1(g_Log, "GID:0x%08x 존재하지 않는 길드가 소트 벡터에 들어있습니다.", sortVector[wRank]);
|
||||
break;
|
||||
}
|
||||
|
||||
aryCurrentInfoList[cIndex] = lpGuild->GetLargeInfo(cIndex, wRank + 1, lpMyGuild);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Guild::GUILD_MINE:
|
||||
{
|
||||
if (NULL != lpMyGuild)
|
||||
{
|
||||
for (unsigned short wRank = 0; wRank < wGuildNum; ++wRank)
|
||||
{
|
||||
if (sortVector[wRank].second == lpMyGuild)
|
||||
{
|
||||
aryCurrentInfoList[0] = GuildLargeInfoNode(lpMyGuild->m_dwGID, 0, lpMyGuild->m_cInclination,
|
||||
wRank + 1, lpMyGuild->m_dwFame, lpMyGuild->m_cLevel, lpMyGuild->GetCurrentMemberNum(),
|
||||
lpMyGuild->GetMaster().m_strName, lpMyGuild->m_strName, lpMyGuild->m_szMark, MINE, MINE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Guild::GUILD_REQUEST:
|
||||
{
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE; ++cIndex)
|
||||
{
|
||||
if (0 == aryCurrentInfoList[cIndex].m_dwGID) { break; }
|
||||
|
||||
GuildMap::iterator it = m_GuildMap.find(aryCurrentInfoList[cIndex].m_dwGID);
|
||||
if (it == m_GuildMap.end())
|
||||
{
|
||||
// 서버와 클라이언트의 시간차로 없어진 길드 정보를 요청할 수도 있습니다. (이 경우는 무시)
|
||||
aryCurrentInfoList[cIndex].m_dwGID = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
CGuild* lpGuild = it->second;
|
||||
if (NULL == lpGuild) { break; }
|
||||
|
||||
for (unsigned short wRank = 0; wRank < wGuildNum; ++wRank)
|
||||
{
|
||||
if (sortVector[wRank].second == lpGuild)
|
||||
{
|
||||
aryCurrentInfoList[cIndex] = lpGuild->GetLargeInfo(cIndex, wRank + 1, lpMyGuild);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
for (unsigned char cIndex = 0; cIndex < PktGuildList::MAX_NUM_PER_PAGE; ++cIndex)
|
||||
{
|
||||
aryCurrentInfoList[cIndex].m_dwGID = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGuildMgr::SerializeIn(char* lpBuffer_In, unsigned short wBufferSize_In, unsigned char cTotalMemberNum,
|
||||
unsigned char cRelationByMineNum, unsigned char cRelationByTargetNum)
|
||||
{
|
||||
GuildInfoDB* lpGuildInfo = reinterpret_cast<GuildInfoDB *>(lpBuffer_In);
|
||||
CGuild* lpGuild = new CGuild(*lpGuildInfo);
|
||||
if (false == m_GuildMap.insert(GuildMap::value_type(lpGuild->GetGID(), lpGuild)).second)
|
||||
{
|
||||
delete lpGuild;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == m_GuildNameMap.insert(GuildNameMap::value_type(std::string(lpGuild->GetName()), lpGuild)).second)
|
||||
{
|
||||
m_GuildMap.erase(lpGuild->GetGID());
|
||||
delete lpGuild;
|
||||
return false;
|
||||
}
|
||||
|
||||
int nIndex = 0;
|
||||
|
||||
GuildMemberDB* lpGuildMember = reinterpret_cast<GuildMemberDB *>(lpGuildInfo + 1);
|
||||
for (nIndex = 0; nIndex < cTotalMemberNum; ++nIndex, ++lpGuildMember)
|
||||
{
|
||||
lpGuild->JoinMemberDB(*lpGuildMember);
|
||||
}
|
||||
|
||||
GuildRelationDB* lpGuildRelation = reinterpret_cast<GuildRelationDB*>(lpGuildMember);
|
||||
for (nIndex = 0; nIndex < cRelationByMineNum + cRelationByTargetNum; ++nIndex, ++lpGuildRelation)
|
||||
{
|
||||
lpGuild->InsertRelation(lpGuildRelation->m_dwGID, lpGuildRelation->m_dwTargetGID, lpGuildRelation->m_cRelation);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGuildMgr::SerializeOut(CGuild* lpGuild_In, char* lpBuffer_Out, unsigned short& wBufferSize_Out,
|
||||
unsigned char& cTotalMemberNum, unsigned char& cRelationByMineNum, unsigned char& cRelationByTargetNum)
|
||||
{
|
||||
wBufferSize_Out = 0;
|
||||
cTotalMemberNum = cRelationByMineNum = cRelationByTargetNum = 0;
|
||||
|
||||
// 길드 데이터
|
||||
GuildInfoDB* lpGuildInfoDB = reinterpret_cast<GuildInfoDB *>(lpBuffer_Out);
|
||||
|
||||
lpGuildInfoDB->m_dwGID = lpGuild_In->m_dwGID;
|
||||
|
||||
strncpy(lpGuildInfoDB->m_strName, lpGuild_In->m_strName, MAX_GUILD_NAME_LEN);
|
||||
|
||||
lpGuildInfoDB->m_cInclination = lpGuild_In->m_cInclination;
|
||||
lpGuildInfoDB->m_cLevel = lpGuild_In->m_cLevel;
|
||||
|
||||
lpGuildInfoDB->m_dwFame = lpGuild_In->m_dwFame;
|
||||
lpGuildInfoDB->m_dwGold = lpGuild_In->m_dwGold;
|
||||
|
||||
lpGuildInfoDB->m_tmLastLogout = lpGuild_In->m_tmLastLogout;
|
||||
lpGuildInfoDB->m_tmCheckMember = lpGuild_In->m_tmCheckMember;
|
||||
lpGuildInfoDB->m_tmGMLastLogout = lpGuild_In->m_tmGMLastLogout;
|
||||
lpGuildInfoDB->m_tmChangeInclination = lpGuild_In->m_tmChangeInclination;
|
||||
|
||||
::memcpy(lpGuildInfoDB->m_szMark, lpGuild_In->m_szMark, MAX_MARK_SIZE);
|
||||
::memcpy(lpGuildInfoDB->m_szRight, &lpGuild_In->m_GuildRight, sizeof(GuildRight));
|
||||
|
||||
wBufferSize_Out += sizeof(GuildInfoDB);
|
||||
|
||||
// 멤버 데이터
|
||||
GuildMemberDB* lpGuildMemberDB = reinterpret_cast<GuildMemberDB *>(lpGuildInfoDB + 1);
|
||||
for (MemberList::iterator MemberIt = lpGuild_In->m_MemberList.begin();
|
||||
MemberIt != lpGuild_In->m_MemberList.end() && cTotalMemberNum < MAX_MEMBER_NUM;
|
||||
++MemberIt, ++lpGuildMemberDB, ++cTotalMemberNum)
|
||||
{
|
||||
MemberInfo& memberInfo = *MemberIt;
|
||||
|
||||
lpGuildMemberDB->m_dwGID = lpGuild_In->m_dwGID;
|
||||
lpGuildMemberDB->m_dwCID = memberInfo.m_dwCID;
|
||||
|
||||
strncpy(lpGuildMemberDB->m_strName, memberInfo.m_strName, MAX_MEMBER_NAME_LEN);
|
||||
|
||||
lpGuildMemberDB->m_dwRank = memberInfo.m_MemberListInfo.m_cRank;
|
||||
lpGuildMemberDB->m_dwTitle = memberInfo.m_MemberListInfo.m_cTitle;
|
||||
lpGuildMemberDB->m_cLevel = memberInfo.m_MemberListInfo.m_cLevel;
|
||||
lpGuildMemberDB->m_wClass = memberInfo.m_MemberListInfo.m_cClass;
|
||||
lpGuildMemberDB->m_cGuildWarFlag = memberInfo.m_MemberListInfo.m_cGuildWarFlag;
|
||||
|
||||
lpGuildMemberDB->m_dwFame = memberInfo.m_MemberDetailInfo.m_dwFame;
|
||||
lpGuildMemberDB->m_dwGold = memberInfo.m_MemberDetailInfo.m_dwGold;
|
||||
|
||||
lpGuildMemberDB->m_LeaveGuildTime = memberInfo.m_LeaveGuildTime;
|
||||
lpGuildMemberDB->m_cTactics = memberInfo.m_cTactics;
|
||||
|
||||
wBufferSize_Out += sizeof(GuildMemberDB);
|
||||
}
|
||||
|
||||
// 관계 데이터
|
||||
GuildRelationDB* lpGuildRelationDB = reinterpret_cast<GuildRelationDB *>(lpGuildMemberDB);
|
||||
for (RelationMap::iterator itr = lpGuild_In->m_Relation[Guild::BY_MINE].begin();
|
||||
itr != lpGuild_In->m_Relation[Guild::BY_MINE].end() && cRelationByMineNum < MAX_RELATION_NUM;
|
||||
++itr, ++lpGuildRelationDB, ++cRelationByMineNum)
|
||||
{
|
||||
lpGuildRelationDB->m_dwGID = lpGuild_In->m_dwGID;
|
||||
lpGuildRelationDB->m_dwTargetGID = itr->first;
|
||||
lpGuildRelationDB->m_cRelation = itr->second;
|
||||
|
||||
wBufferSize_Out += sizeof(GuildRelationDB);
|
||||
}
|
||||
|
||||
for (RelationMap::iterator itr = lpGuild_In->m_Relation[Guild::BY_TARGET].begin();
|
||||
itr != lpGuild_In->m_Relation[Guild::BY_TARGET].end() && cRelationByTargetNum < MAX_RELATION_NUM;
|
||||
++itr, ++lpGuildRelationDB, ++cRelationByTargetNum)
|
||||
{
|
||||
lpGuildRelationDB->m_dwGID = itr->first;
|
||||
lpGuildRelationDB->m_dwTargetGID = lpGuild_In->m_dwGID;
|
||||
lpGuildRelationDB->m_cRelation = itr->second;
|
||||
|
||||
wBufferSize_Out += sizeof(GuildRelationDB);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
#ifndef _GUILD_MGR_H_
|
||||
#define _GUILD_MGR_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Community/Guild/GuildStructure.h>
|
||||
|
||||
// 전방 참조
|
||||
struct GuildCheckSumNode;
|
||||
struct GuildLargeInfoNode;
|
||||
|
||||
class CCharacter;
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
// 전방 참조
|
||||
class CGuild;
|
||||
|
||||
class CGuildMgr
|
||||
{
|
||||
public:
|
||||
|
||||
static CGuildMgr& GetInstance();
|
||||
|
||||
CGuildMgr(void);
|
||||
~CGuildMgr(void);
|
||||
|
||||
bool Initialize(void);
|
||||
void Destroy(void);
|
||||
|
||||
bool SerializeIn(char* lpBuffer_In, unsigned short wBufferSize_In,
|
||||
unsigned char cTotalMemberNum, unsigned char cRelationByMineNum, unsigned char cRelationByTargetNum);
|
||||
|
||||
bool CreateGuild(unsigned long dwMasterID, unsigned long dwGuildID, unsigned char cInclination, char* szGuildName);
|
||||
bool DissolveGuild(unsigned long dwGID);
|
||||
CGuild* GetGuild(unsigned long dwGID);
|
||||
CGuild* GetGuild(char* szName);
|
||||
|
||||
bool SetRelation(unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType);
|
||||
|
||||
void ProcessGuild(void);
|
||||
bool SendGuildList(unsigned long dwCID, unsigned char cSortCmd, unsigned char cPage,
|
||||
unsigned char cNum, GuildCheckSumNode* lpNode);
|
||||
bool SendGuildRelationInfo(unsigned long dwCID, unsigned long dwGID);
|
||||
|
||||
bool GetMemberList(unsigned long dwGID, const MemberList* pMemberList);
|
||||
|
||||
protected:
|
||||
|
||||
bool GetSortingPageList(CCharacter* lpCharacter, unsigned char cSortCmd, unsigned char cPage,
|
||||
GuildLargeInfoNode* aryCurrentInfoList);
|
||||
|
||||
bool SerializeOut(CGuild* lpGuild_In, char* lpBuffer_Out, unsigned short& wBufferSize_Out,
|
||||
unsigned char& cTotalMemberNum, unsigned char& cRelationByMineNum, unsigned char& cRelationByTargetNum);
|
||||
|
||||
|
||||
GuildMap m_GuildMap; // GID를 이용한 검색용
|
||||
GuildNameMap m_GuildNameMap; // 길드명 순으로 소트용
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static CGuildMgr ms_this;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef _GUILD_STRUCTURE_H_
|
||||
#define _GUILD_STRUCTURE_H_
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <Community/Guild/GuildConstants.h>
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
// 전방 참조
|
||||
class CGuild;
|
||||
|
||||
struct MemberListInfo
|
||||
{
|
||||
unsigned char m_cRank; // 서열 (한 길드내에선 유니크한 숫자. 길드마스터를 0으로 하여 순차적으로 구성)
|
||||
unsigned char m_cTitle; // 직위 (Guild::Title의 상수를 참고)
|
||||
unsigned char m_cLevel; // 레벨
|
||||
unsigned char m_cClass; // 클래스
|
||||
unsigned char m_cGuildWarFlag; // 길드전쟁 참여 플래그 (Creature::WarFlag의 상수를 참고)
|
||||
|
||||
MemberListInfo()
|
||||
: m_cRank(0), m_cTitle(0), m_cLevel(0), m_cClass(0), m_cGuildWarFlag(0)
|
||||
{ }
|
||||
|
||||
MemberListInfo(unsigned char cRank, unsigned char cTitle, unsigned char cLevel, unsigned char cClass, unsigned char cGuildWarFlag)
|
||||
: m_cRank(cRank), m_cTitle(cTitle), m_cLevel(cLevel), m_cClass(cClass), m_cGuildWarFlag(cGuildWarFlag)
|
||||
{ }
|
||||
};
|
||||
|
||||
struct MemberDetailInfo
|
||||
{
|
||||
unsigned long m_dwFame;
|
||||
unsigned long m_dwGold;
|
||||
|
||||
MemberDetailInfo()
|
||||
: m_dwFame(0), m_dwGold(0)
|
||||
{ }
|
||||
|
||||
MemberDetailInfo(unsigned long dwFame, unsigned long dwGold)
|
||||
: m_dwFame(dwFame), m_dwGold(dwGold)
|
||||
{ }
|
||||
};
|
||||
|
||||
struct MemberInfo
|
||||
{
|
||||
// 변하지 않는 정보
|
||||
unsigned long m_dwCID;
|
||||
char m_strName[MAX_MEMBER_NAME_LEN];
|
||||
|
||||
// 따로 처리되는 정보
|
||||
unsigned long m_dwServerID;
|
||||
TIME m_LeaveGuildTime;
|
||||
unsigned char m_cUpdateCount;
|
||||
|
||||
unsigned char m_cTactics;
|
||||
|
||||
// 가끔 변하는 정보 (변경될 때마다 업데이트)
|
||||
MemberListInfo m_MemberListInfo;
|
||||
|
||||
// 자주 변하는 정보 (일정 횟수 이상 변경되면 업데이트)
|
||||
MemberDetailInfo m_MemberDetailInfo;
|
||||
|
||||
MemberInfo()
|
||||
: m_dwCID(0), m_dwServerID(0), m_cUpdateCount(0), m_cTactics(0), m_MemberListInfo(), m_MemberDetailInfo()
|
||||
{
|
||||
std::fill_n(m_strName, int(MAX_MEMBER_NAME_LEN), 0);
|
||||
::memset(&m_LeaveGuildTime, 0, sizeof(TIME));
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map<unsigned long, CGuild *> GuildMap;
|
||||
typedef std::map<std::string, CGuild *> GuildNameMap;
|
||||
|
||||
typedef std::vector<MemberInfo> MemberList;
|
||||
typedef std::map<unsigned long, unsigned char> RelationMap; // <GID, cRelation>
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
#ifndef _GUILD_UTIL_H_
|
||||
#define _GUILD_UTIL_H_
|
||||
|
||||
#include "GuildMgr.h"
|
||||
#include "Guild.h"
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
struct FnDeleteSecond
|
||||
{
|
||||
template<typename PairType>
|
||||
bool operator() (PairType& pair)
|
||||
{
|
||||
if (NULL != pair.second)
|
||||
{
|
||||
delete pair.second;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct IsCurrentMember
|
||||
{
|
||||
bool operator () (const MemberInfo& first) const
|
||||
{
|
||||
unsigned char cTitle = first.m_MemberListInfo.m_cTitle;
|
||||
return (JOIN_WAIT != cTitle && 0 == first.m_cTactics);
|
||||
}
|
||||
};
|
||||
|
||||
struct IsCurrentLoginMember
|
||||
{
|
||||
bool operator () (const MemberInfo& first) const
|
||||
{
|
||||
return (0 != first.m_dwServerID);
|
||||
}
|
||||
};
|
||||
|
||||
struct IsTacticsMember
|
||||
{
|
||||
bool operator () (const MemberInfo& first) const
|
||||
{
|
||||
return (0 != first.m_cTactics);
|
||||
}
|
||||
};
|
||||
|
||||
struct IsNotTacticsMember
|
||||
{
|
||||
bool operator () (const MemberInfo& first) const
|
||||
{
|
||||
return (0 == first.m_cTactics);
|
||||
}
|
||||
};
|
||||
|
||||
struct SumMemberFame
|
||||
{
|
||||
unsigned long operator () (const unsigned long init, const MemberInfo& first) const
|
||||
{
|
||||
return ((true == IsCurrentMember()(first)) ? init + first.m_MemberDetailInfo.m_dwFame : init);
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareGuildFame
|
||||
{
|
||||
bool operator () (const GuildMap::value_type& lhs, const GuildMap::value_type& rhs) const
|
||||
{
|
||||
return lhs.second->GetFame() > rhs.second->GetFame();
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberName
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
return std::string(lhs.m_strName) < std::string(rhs.m_strName);
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberTitle
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
if (lhs.m_MemberListInfo.m_cTitle == rhs.m_MemberListInfo.m_cTitle)
|
||||
{
|
||||
return CompareMemberName()(lhs, rhs);
|
||||
}
|
||||
|
||||
return lhs.m_MemberListInfo.m_cTitle < rhs.m_MemberListInfo.m_cTitle;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberClass
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
if (lhs.m_MemberListInfo.m_cClass == rhs.m_MemberListInfo.m_cClass)
|
||||
{
|
||||
return CompareMemberName()(lhs, rhs);
|
||||
}
|
||||
|
||||
return lhs.m_MemberListInfo.m_cClass < rhs.m_MemberListInfo.m_cClass;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberLevel
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
if (lhs.m_MemberListInfo.m_cLevel == rhs.m_MemberListInfo.m_cLevel)
|
||||
{
|
||||
return CompareMemberName()(lhs, rhs);
|
||||
}
|
||||
|
||||
return lhs.m_MemberListInfo.m_cLevel > rhs.m_MemberListInfo.m_cLevel;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberFame
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
if (lhs.m_MemberDetailInfo.m_dwFame == rhs.m_MemberDetailInfo.m_dwFame)
|
||||
{
|
||||
return CompareMemberName()(lhs, rhs);
|
||||
}
|
||||
|
||||
return lhs.m_MemberDetailInfo.m_dwFame > rhs.m_MemberDetailInfo.m_dwFame;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberGold
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
if (lhs.m_MemberDetailInfo.m_dwGold == rhs.m_MemberDetailInfo.m_dwGold)
|
||||
{
|
||||
return CompareMemberName()(lhs, rhs);
|
||||
}
|
||||
|
||||
return lhs.m_MemberDetailInfo.m_dwGold > rhs.m_MemberDetailInfo.m_dwGold;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareMemberPosition
|
||||
{
|
||||
bool operator () (const MemberInfo& lhs, const MemberInfo& rhs) const
|
||||
{
|
||||
if (lhs.m_dwServerID == rhs.m_dwServerID)
|
||||
{
|
||||
return CompareMemberName()(lhs, rhs);
|
||||
}
|
||||
|
||||
return lhs.m_dwServerID < rhs.m_dwServerID;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompareRelation
|
||||
{
|
||||
bool operator () (const GuildHostilityInfoNode& lhs, const GuildHostilityInfoNode& rhs) const
|
||||
{
|
||||
if (lhs.m_cRelationType == rhs.m_cRelationType)
|
||||
{
|
||||
return std::string(lhs.m_szName) < std::string(rhs.m_szName);
|
||||
}
|
||||
|
||||
return lhs.m_cRelationType > rhs.m_cRelationType;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
2543
Server/RylServerProject/RylGameLibrary/Community/party/Party.cpp
Normal file
2543
Server/RylServerProject/RylGameLibrary/Community/party/Party.cpp
Normal file
File diff suppressed because it is too large
Load Diff
276
Server/RylServerProject/RylGameLibrary/Community/party/Party.h
Normal file
276
Server/RylServerProject/RylGameLibrary/Community/party/Party.h
Normal file
@@ -0,0 +1,276 @@
|
||||
#ifndef _RYL_GAME_LIBRARY_PARTY_H_
|
||||
#define _RYL_GAME_LIBRARY_PARTY_H_
|
||||
|
||||
#include <set>
|
||||
#include <boost/pool/pool_alloc.hpp>
|
||||
|
||||
#include <DB/DBdefine.h>
|
||||
#include <Skill/Spell/PartySpellMgr.h>
|
||||
|
||||
#include <Network/Packet/PacketStruct/CharCommunityPacket.h>
|
||||
#include <Network/Packet/PacketStruct/CharAttackPacket.h>
|
||||
#include <Network/Packet/PacketStruct/PartyPacket.h>
|
||||
|
||||
// 전방 참조
|
||||
class CCell;
|
||||
class CCharacter;
|
||||
class CMonster;
|
||||
class CPacketBuffer;
|
||||
struct Position;
|
||||
|
||||
namespace Item
|
||||
{
|
||||
class CItem;
|
||||
};
|
||||
|
||||
namespace Quest
|
||||
{
|
||||
struct QuestNode;
|
||||
};
|
||||
|
||||
|
||||
#define PARTYLOG(x) (void*)0
|
||||
/*
|
||||
#define PARTYLOG(x) x
|
||||
*/
|
||||
|
||||
class CParty
|
||||
{
|
||||
protected:
|
||||
|
||||
CParty();
|
||||
CParty(const PARTY& PartyInfo);
|
||||
|
||||
CPartySpellMgr m_PartySpellMgr;
|
||||
PARTY_EX m_Party;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~CParty();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// interface
|
||||
|
||||
CPartySpellMgr& GetPartySpellMgr() { return m_PartySpellMgr; }
|
||||
|
||||
unsigned long GetUID(void) { return m_Party.m_dwPartyID; }
|
||||
|
||||
void SetUID(unsigned long dwPartyID) { m_Party.m_dwPartyID = dwPartyID; }
|
||||
|
||||
int GetMemberNum(void) { return m_Party.m_cMemberNum; }
|
||||
|
||||
bool IsMember(unsigned long dwMemberCID);
|
||||
|
||||
void ChangeName(unsigned long dwCID, const char* szChangedName);
|
||||
|
||||
virtual bool Join(unsigned long dwSenderCID, unsigned long dwReferenceID,
|
||||
const char* strSenderName, unsigned short wMapIndex = 0) { return false; }
|
||||
|
||||
virtual int Leave(unsigned long dwSenderCID, unsigned long dwReferenceID = 0,
|
||||
unsigned short wMapIndex = 0) { return 0; }
|
||||
|
||||
virtual bool Destory(unsigned long dwSenderCID, unsigned long dwReferenceID) { return false; }
|
||||
|
||||
virtual bool Login(unsigned long dwSenderCID, unsigned long dwReferenceID) { return false; }
|
||||
virtual bool ReLogin(CCharacter* llpCharacter) { return false; }
|
||||
virtual int Logout(unsigned long dwSenderCID, unsigned long dwReferenceID) { return 0; }
|
||||
virtual void PrepareLogout(unsigned long dwMemberID) { }
|
||||
|
||||
void SetLeader(unsigned long dwLeaderCID) { m_Party.m_dwLeaderID = dwLeaderCID; }
|
||||
unsigned long GetLeader(void) { return m_Party.m_dwLeaderID; }
|
||||
bool IsLeader(unsigned long dwLeaderCID) { return (m_Party.m_dwLeaderID == dwLeaderCID) ? true : false; }
|
||||
|
||||
// 파티원 정보 업데이트 //
|
||||
bool UpdatePartyMemberInfo(unsigned long dwCID, unsigned long dwGID, unsigned short wClass, char cLevel, bool bAutoRouting);
|
||||
bool UpdatePartyMemberLevel(unsigned long dwCID, char cLevel);
|
||||
bool UpdatePartyMemberClass(unsigned long dwCID, unsigned short wClass);
|
||||
bool UpdatePartyMemberGuild(unsigned long dwCID, unsigned long dwGID);
|
||||
bool UpdatePartyMemberServer(unsigned long dwCID, unsigned long dwServerID);
|
||||
bool UpdatePartyMemberAutoRouting(unsigned long dwCID, bool bAutoRouting);
|
||||
|
||||
virtual bool TransferLeader(unsigned long dwLeaderCID) { return false; }
|
||||
|
||||
virtual unsigned char GetLoggedMemberAverageLevel(void) { return 0; }
|
||||
|
||||
virtual bool AdjustAutoRouting(unsigned long dwTargetID, bool bSwitch) { return false; }
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// 파티원 전체에 영향을 주는 명령
|
||||
|
||||
virtual void MovePos(POS NewPos, char cZone, const bool bSitDown) { }
|
||||
virtual void MoveZone(POS NewPos, char Zone, char Channel) { }
|
||||
|
||||
virtual bool AutoRouting(CAggresiveCreature* lpPickkingCreature, Item::CItem* lpItem, unsigned long& dwGold) { return false; }
|
||||
|
||||
virtual bool Attack(AtType attackType, CAggresiveCreature** pDefenders, unsigned char* cDefenserJudges,
|
||||
CAggresiveCreature* lpOffencer, float fDistance, unsigned char cTargetType) { return false; }
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// 일정주기로 호출되는 함수
|
||||
|
||||
virtual void UpdateData() { };
|
||||
};
|
||||
|
||||
|
||||
class CMonsterParty : public CParty
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::set<unsigned long, std::less<unsigned long>,
|
||||
boost::fast_pool_allocator<unsigned long> > PartyTargetSet;
|
||||
|
||||
protected:
|
||||
|
||||
CMonster* m_pMemberPointer[PARTY::MAX_MEM];
|
||||
|
||||
float m_fHelpRange; // 싸우고 있는 파티원을 도와주러 가는 거리
|
||||
|
||||
PartyTargetSet m_partyTargets; // 파티원이 싸우고 있는 상대의 CID
|
||||
|
||||
|
||||
public:
|
||||
|
||||
CMonsterParty(const PARTY& PartyInfo, unsigned short wMapIndex = 0);
|
||||
CMonsterParty();
|
||||
virtual ~CMonsterParty();
|
||||
|
||||
enum Const
|
||||
{
|
||||
DEFAULT_HELP_RANGE = 36,
|
||||
ERROR_OF_LEVEL_GAP = 10
|
||||
};
|
||||
|
||||
PartyTargetSet& GetPartyTargetSet(void) { return m_partyTargets; }
|
||||
float GetHelpRange(void) { return m_fHelpRange; }
|
||||
unsigned short GetAvgLevel(void);
|
||||
unsigned short GetHighestLevel(void);
|
||||
int GetMemberTypeNum(void);
|
||||
|
||||
bool Join(unsigned long dwSenderCID, unsigned long dwReferenceID = 0, const char* strSenderName = NULL, unsigned short wMapIndex = 0);
|
||||
int Leave(unsigned long dwSenderCID, unsigned long dwReferenceID = 0, unsigned short wMapIndex = 0);
|
||||
bool Destory(unsigned long dwSenderCID, unsigned long dwReferenceID);
|
||||
|
||||
CMonster* GetMember(unsigned int nIndex)
|
||||
{
|
||||
if (nIndex < 0 || nIndex >= PARTY::MAX_MEM) return NULL;
|
||||
return m_pMemberPointer[nIndex];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// 파티원 전체에 영향을 주는 명령
|
||||
|
||||
bool Attack(AtType attackType, CAggresiveCreature** pDefenders, unsigned char* cDefenserJudges,
|
||||
CAggresiveCreature* lpOffencer, float fDistance, unsigned char cTargetType);
|
||||
};
|
||||
|
||||
|
||||
class CCharacterParty : public CParty
|
||||
{
|
||||
protected:
|
||||
|
||||
CCharacter* m_pMemberPointer[PARTY::MAX_MEM];
|
||||
bool m_bAutoRouting[PARTY::MAX_MEM];
|
||||
|
||||
CCharacterParty* m_pHostileParty;
|
||||
CCharacter* m_pFightingMember[PARTY::MAX_MEM];
|
||||
|
||||
PartyMemberData m_partyMemberData[PARTY::MAX_MEM];
|
||||
|
||||
void SendPartyCmdInfo(PktPC::PartyCmd Command, CCharacter *lpCharacter);
|
||||
void SendPartyCommand(PktPC::PartyCmd Command, const char *SenderName_In, unsigned long dwSenderCID, unsigned long ReceiverCID);
|
||||
|
||||
static void SetUpdateFlag(PartyMemberData& partyMemberData, CCharacter& character, char*& szPacket, bool bUpdateForce);
|
||||
|
||||
public:
|
||||
|
||||
// 해외 서버에서 사용하는 상수
|
||||
enum ForeignConst
|
||||
{
|
||||
ADDITIONAL_EXP_CAP_MIN_PARTY_MENMBER = 2, // 최소 2명 이상의 파티원이 근처에 있을 때
|
||||
ADDITIONAL_EXP_CAP_PERCENTAGE = 40, // 40 % 추가 Exp Cap 보너스
|
||||
} ;
|
||||
|
||||
CCharacterParty(const PARTY& PartyInfo, bool bCreate);
|
||||
CCharacterParty();
|
||||
~CCharacterParty();
|
||||
|
||||
// 파티원중 휴먼의 비율을 반환한다.
|
||||
unsigned char GetRaceRate(void);
|
||||
|
||||
bool Join(unsigned long dwSenderCID, unsigned long dwReferenceID, const char* strSenderName, unsigned short wMapIndex = 0);
|
||||
int Leave(unsigned long dwSenderCID, unsigned long dwReferenceID = 0, unsigned short wMapIndex = 0);
|
||||
bool Destory(unsigned long dwSenderCID, unsigned long dwReferenceID);
|
||||
|
||||
bool Login(unsigned long dwSenderCID, unsigned long dwReferenceID);
|
||||
bool ReLogin(CCharacter* llpCharacter);
|
||||
int Logout(unsigned long dwSenderCID, unsigned long dwReferenceID);
|
||||
void PrepareLogout(unsigned long dwMemberID);
|
||||
|
||||
bool TransferLeader(unsigned long dwLeaderCID);
|
||||
|
||||
CCharacter** GetMemberPointerList(void) { return m_pMemberPointer; }
|
||||
|
||||
unsigned char GetLoggedMemberAverageLevel(void);
|
||||
int GetNearMemberList(CCell *pCell, bool bAutoRouting, CCharacter **aryNearCharacterList, unsigned char &cHighestLevel);
|
||||
|
||||
bool AdjustAutoRouting(unsigned long dwTargetID, bool bSwitch);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// 팀배틀 관련 메소드
|
||||
|
||||
CCharacterParty* GetHostileParty(void) { return m_pHostileParty; }
|
||||
|
||||
bool StartTeamBattle(CCharacterParty* pHostileParty);
|
||||
int DropMember(CCharacter* pDropMember, PktDuC::DuelCmd eCmd);
|
||||
void EndTeamBattle(void);
|
||||
bool MakeTeamBattleInfo(char* szPacket, unsigned short& dwPacketSize, CCharacter* pChallenger, unsigned char cCmd);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// 파티원 전체에 영향을 주는 명령
|
||||
|
||||
void MovePos(POS NewPos, char cZone, const bool bSitDown);
|
||||
void MoveZone(POS NewPos, char Zone, char Channel);
|
||||
|
||||
bool AutoRouting(CAggresiveCreature* lpPickkingCreature, Item::CItem* lpItem, unsigned long& dwGold);
|
||||
|
||||
bool Attack(AtType attackType, CAggresiveCreature** pDefenders, unsigned char* cDefenserJudges,
|
||||
CAggresiveCreature* lpOffencer, float fDistance, unsigned char cTargetType);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// 파티 퀘스트 관련 함수
|
||||
|
||||
bool StartQuest(Quest::QuestNode* lpQuestNode, const Position& CenterPos, unsigned long dwNPCID);
|
||||
bool CheckTrigger(unsigned long dwExceptCID, unsigned char cTriggerKind, unsigned long dwReferenceID, Position Pos, short wCount);
|
||||
void OperateTrigger(unsigned short wQuestID, unsigned char cPhase, unsigned char cTrigger, unsigned char cCount, Position Pos);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Send 관련
|
||||
|
||||
void SendPartyInfo(CCharacter *lpCharacter);
|
||||
void SendAllLoggedMember(const char* szPacket, unsigned long dwPacketSize, unsigned long dwExclusion, unsigned char cCMD_In);
|
||||
void SendNotNearCellMember(const char* szPacket, unsigned long dwPacketSize, CCell* lpCell, unsigned char cCMD_In);
|
||||
void SendDivisionExp(CCharacter* lpCharacter, CAggresiveCreature* lpDeadCreature, unsigned long dwExp, int nStandardLevel);
|
||||
void SendDropMember(CCharacter* pDropMember, PktDuC::DuelCmd eCmd);
|
||||
void SendRecall(CCharacter* lpCaster);
|
||||
void SendAutoRouting(unsigned long dwCharID, unsigned short wItemID, unsigned char cCmd);
|
||||
void SendPartyAddress(unsigned long dwCharID, const SOCKADDR_IN& PublicAddress, const SOCKADDR_IN& PrivateAddress);
|
||||
|
||||
void SendPartyMemberDataToDBAgent(unsigned long dwSenderID, unsigned long dwGID, unsigned short wClass, unsigned long dwServerID,
|
||||
char cLevel, const char* strSenderName, unsigned short usCmd);
|
||||
|
||||
void SendDivisionFame(CCharacter* lpWinnerCharacter, CCharacter* lpLoserCharacter, unsigned char cCmd, unsigned char cAcquireAmount);
|
||||
|
||||
// 캐릭터 정보가 업데이트 되었을 때 다른 존에 있는 캐릭터 정보를 보내는 함수
|
||||
void SendMemberInfoNZone(const char* szPacket, unsigned long dwPacketSize, unsigned long dwSenderID, unsigned char cCMD_In);
|
||||
|
||||
// 캐릭터 접속시 다른 존에 있는 캐릭터 정보를 보내는 함수
|
||||
bool SendMemberInfoAllNZone(unsigned long dwCID);
|
||||
|
||||
// 로그아웃이나 삭제 메세지를 보낸다.
|
||||
bool SendMemberInfoOutNZone(unsigned long dwCID, unsigned short wCmd);
|
||||
|
||||
// 일정 주기로 호출되는 함수 (여기서는 캐릭터 좌표 및 기타 등의 정보를 업데이트 해준다.)
|
||||
void UpdateData();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,260 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <Creature/CreatureManager.h>
|
||||
#include <Creature/Character/Character.h>
|
||||
#include <Network/Packet/PacketCommand.h>
|
||||
#include <Network/Packet/PacketStruct/CharCommunityPacket.h>
|
||||
#include <Network/Dispatch/GameClient/GameClientDispatch.h>
|
||||
#include <Network/Stream/SendStream.h>
|
||||
|
||||
#include "PartyMgr.h"
|
||||
|
||||
|
||||
CPartyMgr& CPartyMgr::GetInstance()
|
||||
{
|
||||
static CPartyMgr partyMgr;
|
||||
return partyMgr;
|
||||
}
|
||||
|
||||
|
||||
CPartyMgr::CPartyMgr()
|
||||
: m_tempUID(0)
|
||||
{
|
||||
m_PartyMap.clear();
|
||||
m_MemberFindPartyMap.clear();
|
||||
m_PartyFindMemberMap.clear();
|
||||
}
|
||||
|
||||
CPartyMgr::~CPartyMgr()
|
||||
{
|
||||
DestoryPartyList();
|
||||
}
|
||||
|
||||
|
||||
void CPartyMgr::DestoryPartyList()
|
||||
{
|
||||
// ERRLOG1(g_Log, "EDITH :%d 파티가 존재합니다.", m_PartyMap.size());
|
||||
|
||||
for (PartyMap::iterator it = m_PartyMap.begin(); it != m_PartyMap.end(); ++it)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
m_PartyMap.clear();
|
||||
|
||||
// edith 2008.05.29 파티 맵 초기화 추가
|
||||
m_MemberFindPartyMap.clear();
|
||||
m_PartyFindMemberMap.clear();
|
||||
}
|
||||
|
||||
|
||||
void CPartyMgr::UpdatePartyData()
|
||||
{
|
||||
PartyMap::iterator pos = m_PartyMap.begin();
|
||||
PartyMap::iterator end = m_PartyMap.end();
|
||||
|
||||
for (; pos != end; ++pos)
|
||||
{
|
||||
pos->second->UpdateData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::RequestPartyInfoToDB(unsigned long dwLeaderCID, unsigned long dwPartyUID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::AddParty(CParty *pParty)
|
||||
{
|
||||
unsigned long dwPartyUID = pParty->GetUID();
|
||||
|
||||
PartyMap::iterator it = m_PartyMap.find(dwPartyUID);
|
||||
if (it != m_PartyMap.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// edith 2008.05.29 파티맵 수정
|
||||
// m_PartyMap.insert(PartyMap::value_type(pParty->GetUID(), pParty)).second;
|
||||
|
||||
m_PartyMap.insert(PartyMap::value_type(pParty->GetUID(), pParty));
|
||||
return GetParty(dwPartyUID);
|
||||
}
|
||||
|
||||
|
||||
CParty* CPartyMgr::GetParty(unsigned long dwPartyUID)
|
||||
{
|
||||
PartyMap::iterator it = m_PartyMap.find(dwPartyUID);
|
||||
if (it == m_PartyMap.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::DeleteParty(unsigned long dwPartyUID)
|
||||
{
|
||||
PartyMap::iterator it = m_PartyMap.find(dwPartyUID);
|
||||
if (it == m_PartyMap.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
delete it->second;
|
||||
m_PartyMap.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::AddFindPartyList(unsigned long dwCID)
|
||||
{
|
||||
MemberFindPartyMap::iterator it = m_MemberFindPartyMap.find(dwCID);
|
||||
if (it != m_MemberFindPartyMap.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CCharacter* pCharacter = CCreatureManager::GetInstance().GetCharacter(dwCID);
|
||||
if (NULL == pCharacter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_MemberFindPartyMap.insert(MemberFindPartyMap::value_type(dwCID, pCharacter)).second;
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::DeleteFindPartyList(unsigned long dwCID)
|
||||
{
|
||||
MemberFindPartyMap::iterator it = m_MemberFindPartyMap.find(dwCID);
|
||||
if (it == m_MemberFindPartyMap.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_MemberFindPartyMap.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::AddFindMemberList(unsigned long dwPartyUID)
|
||||
{
|
||||
PartyFindMemberMap::iterator it = m_PartyFindMemberMap.find(dwPartyUID);
|
||||
if (it != m_PartyFindMemberMap.end())
|
||||
{
|
||||
ERRLOG1(g_Log, "PID:0x%08x 파티원 찾기 리스트에 이미 있는 파티를 추가하려 합니다.", dwPartyUID);
|
||||
return false;
|
||||
}
|
||||
|
||||
CParty* pParty = CPartyMgr::GetInstance().GetParty(dwPartyUID);
|
||||
if (NULL == pParty)
|
||||
{
|
||||
ERRLOG1(g_Log, "PID:0x%08x 존재하지 않는 파티입니다.", dwPartyUID);
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_PartyFindMemberMap.insert(PartyFindMemberMap::value_type(dwPartyUID, pParty)).second;
|
||||
}
|
||||
|
||||
|
||||
bool CPartyMgr::DeleteFindMemberList(unsigned long dwPartyUID)
|
||||
{
|
||||
PartyFindMemberMap::iterator it = m_PartyFindMemberMap.find(dwPartyUID);
|
||||
if (it == m_PartyFindMemberMap.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_PartyFindMemberMap.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CPartyMgr::SendPartyFind(CCharacter* lpCharacter)
|
||||
{
|
||||
if (NULL != lpCharacter)
|
||||
{
|
||||
CGameClientDispatch* lpDispatch = lpCharacter->GetDispatcher();
|
||||
if (NULL != lpDispatch)
|
||||
{
|
||||
const int MAX_BUFFER_SIZE = sizeof(MemberFindParty) * PktPFAck::MAX_LIST +
|
||||
sizeof(PartyFindMember) * PktPFAck::MAX_LIST + sizeof(PktPFAck);
|
||||
|
||||
char szBuffer[MAX_BUFFER_SIZE];
|
||||
char* lpBufferPos = szBuffer + sizeof(PktPFAck);
|
||||
PktPFAck* lpPktPFAck = reinterpret_cast<PktPFAck*>(szBuffer);
|
||||
|
||||
int nMemberFindPartyNum = 0;
|
||||
int nPartyFindMemberNum = 0;
|
||||
|
||||
const int nMyLevel = lpCharacter->GetStatus().m_nLevel;
|
||||
|
||||
for (MemberFindPartyMap::iterator it = m_MemberFindPartyMap.begin();
|
||||
it != m_MemberFindPartyMap.end() && nMemberFindPartyNum < PktPFAck::MAX_LIST; ++it)
|
||||
{
|
||||
CCharacter* lpEntryCharacter = it->second;
|
||||
|
||||
if (NULL != lpEntryCharacter)// && lpCharacter != lpEntryCharacter)
|
||||
{
|
||||
const int nEntryCharLevel = lpEntryCharacter->GetStatus().m_nLevel;
|
||||
|
||||
if (::abs(nEntryCharLevel - nMyLevel) <= PktPFAck::MAX_DIFF_LEVEL_VIEW &&
|
||||
EnemyCheck::EC_ENEMY != lpCharacter->IsEnemy(lpEntryCharacter))
|
||||
{
|
||||
MemberFindParty* lpEntryMemberFindParty = reinterpret_cast<MemberFindParty*>(lpBufferPos);
|
||||
|
||||
strncpy(lpEntryMemberFindParty->m_strName, lpEntryCharacter->GetCharacterName(), CHAR_INFOST::MAX_NAME_LEN);
|
||||
lpEntryMemberFindParty->m_cLevel= static_cast<unsigned char>(nEntryCharLevel);
|
||||
lpEntryMemberFindParty->m_cClass = static_cast<unsigned char>(lpEntryCharacter->GetClass());
|
||||
|
||||
lpBufferPos += sizeof(MemberFindParty);
|
||||
++nMemberFindPartyNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PartyFindMemberMap::iterator it = m_PartyFindMemberMap.begin();
|
||||
it != m_PartyFindMemberMap.end() && nPartyFindMemberNum < PktPFAck::MAX_LIST; ++it)
|
||||
{
|
||||
CParty* lpEntryParty = it->second;
|
||||
|
||||
// 자기가 속한 파티는 제외
|
||||
if (NULL != lpEntryParty ) // && !lpEntryParty->IsMember(lpCharacter->GetCID()))
|
||||
{
|
||||
const int nAverageLevel = lpEntryParty->GetLoggedMemberAverageLevel();
|
||||
|
||||
if (::abs(nAverageLevel - nMyLevel) <= PktPFAck::MAX_DIFF_LEVEL_VIEW)
|
||||
{
|
||||
PartyFindMember* lpEntryPartyFindMember = reinterpret_cast<PartyFindMember*>(lpBufferPos);
|
||||
|
||||
CCharacter* lpLeaderCharacter = CCreatureManager::GetInstance().GetCharacter(lpEntryParty->GetLeader());
|
||||
if (NULL != lpLeaderCharacter)
|
||||
{
|
||||
if (EnemyCheck::EC_ENEMY != lpCharacter->IsEnemy(lpLeaderCharacter))
|
||||
{
|
||||
strncpy(lpEntryPartyFindMember->m_strLeaderName,
|
||||
lpLeaderCharacter->GetCharacterName(), CHAR_INFOST::MAX_NAME_LEN);
|
||||
|
||||
lpEntryPartyFindMember->m_cAverageLevel = static_cast<unsigned char>(nAverageLevel);
|
||||
lpEntryPartyFindMember->m_cMemberNum = lpEntryParty->GetMemberNum();
|
||||
|
||||
lpBufferPos += sizeof(PartyFindMember);
|
||||
++nPartyFindMemberNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned short usPacketSize = static_cast<unsigned short>(sizeof(PktPFAck) +
|
||||
sizeof(MemberFindParty) * nMemberFindPartyNum + sizeof(PartyFindMember) * nPartyFindMemberNum);
|
||||
|
||||
lpPktPFAck->m_dwCharID = lpCharacter->GetCID();
|
||||
lpPktPFAck->m_cMemberFindPartyNum = nMemberFindPartyNum;
|
||||
lpPktPFAck->m_cPartyFindMemberNum = nPartyFindMemberNum;
|
||||
|
||||
lpDispatch->GetSendStream().WrapCompress(szBuffer, usPacketSize, CmdCharPartyFind, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef _RYL_GAME_LIBRARY_PARTY_MGR_H_
|
||||
#define _RYL_GAME_LIBRARY_PARTY_MGR_H_
|
||||
|
||||
#include <Thread/Lock.h>
|
||||
|
||||
#include <map>
|
||||
#include <boost/pool/pool_alloc.hpp>
|
||||
|
||||
#include "Party.h"
|
||||
|
||||
class CPartyMgr
|
||||
{
|
||||
public:
|
||||
static CPartyMgr& GetInstance();
|
||||
|
||||
void DestoryPartyList();
|
||||
|
||||
bool RequestPartyInfoToDB(unsigned long dwLeaderCID, unsigned long dwPartyUID);
|
||||
|
||||
bool AddParty(CParty *pParty);
|
||||
CParty* GetParty(unsigned long dwPartyUID);
|
||||
bool DeleteParty(unsigned long dwPartyUID);
|
||||
|
||||
bool AddFindPartyList(unsigned long dwCID);
|
||||
bool DeleteFindPartyList(unsigned long dwCID);
|
||||
bool AddFindMemberList(unsigned long dwPartyUID);
|
||||
bool DeleteFindMemberList(unsigned long dwPartyUID);
|
||||
|
||||
unsigned long GetTempUID(void) { m_tempUID++; return m_tempUID; }
|
||||
|
||||
void SendPartyFind(CCharacter* pCharacter);
|
||||
|
||||
void UpdatePartyData();
|
||||
|
||||
protected:
|
||||
|
||||
CPartyMgr();
|
||||
~CPartyMgr();
|
||||
|
||||
typedef std::map<unsigned long, CParty*, std::less<unsigned long>,
|
||||
boost::fast_pool_allocator<std::pair<unsigned long, CParty* > > > PartyMap;
|
||||
|
||||
typedef std::map<unsigned long, CCharacter*, std::less<unsigned long>,
|
||||
boost::fast_pool_allocator<std::pair<unsigned long, CCharacter* > > > MemberFindPartyMap;
|
||||
|
||||
typedef std::map<unsigned long, CParty*, std::less<unsigned long>,
|
||||
boost::fast_pool_allocator<std::pair<unsigned long, CParty* > > > PartyFindMemberMap;
|
||||
|
||||
PartyMap m_PartyMap;
|
||||
MemberFindPartyMap m_MemberFindPartyMap;
|
||||
PartyFindMemberMap m_PartyFindMemberMap;
|
||||
|
||||
unsigned long m_tempUID;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user