#include "NetCli_Guild.h"

//-------------------------------------------------------------------
NetCli_Guild*    NetCli_Guild::This         = NULL;
int									NetCli_Guild::_MemberCount = 0;
vector< GuildMemberBaseInfoStruct > NetCli_Guild::_MemberList;
//-------------------------------------------------------------------
bool NetCli_Guild::_Init()
{
	Cli_NetReg( PG_Guild_LtoC_CreateGuildResult		);
	Cli_NetReg( PG_Guild_LtoC_NewGuildInvite		);	
	Cli_NetReg( PG_Guild_LtoC_NewGuildInviteResult	);
	Cli_NetReg( PG_Guild_LtoC_JoindNewGuild			);
	Cli_NetReg( PG_Guild_LtoC_LeaveNewGuildResult	);
	Cli_NetReg( PG_Guild_LtoC_DelNewGuildResult		);

	Cli_NetReg( PG_Guild_LtoC_GuildInvite			);	
	Cli_NetReg( PG_Guild_LtoC_GuildInviteResult		);
	Cli_NetReg( PG_Guild_LtoC_JoindGuild			);
	Cli_NetReg( PG_Guild_LtoC_LeaveGuildResult		);
	Cli_NetReg( PG_Guild_LtoC_DelGuildResult		);

	Cli_NetReg( PG_Guild_LtoC_GuildInfo				);	
	Cli_NetReg( PG_Guild_LtoC_GuildMemberListCount	);
	Cli_NetReg( PG_Guild_LtoC_GuildMemberBaseInfo	);
	Cli_NetReg( PG_Guild_LtoC_GuildMemberInfo		);
	Cli_NetReg( PG_Guild_DtoC_GuildCreate			);

	Cli_NetReg( PG_Guild_DtoC_BoardPostResult		);	
	Cli_NetReg( PG_Guild_DtoC_BoardListCount		);
	Cli_NetReg( PG_Guild_DtoC_BoardListData			);
	Cli_NetReg( PG_Guild_DtoC_BoardMessageResult	);
	Cli_NetReg( PG_Guild_DtoC_BoardModifyMessageResult	);
	Cli_NetReg( PG_Guild_DtoC_BoardModifyModeResult	);

    return true;
}
//-------------------------------------------------------------------
bool NetCli_Guild::_Release()
{
    return true;
}
//-------------------------------------------------------------------
void NetCli_Guild::_PG_Guild_LtoC_CreateGuildResult		( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_CreateGuildResult *  PG = (PG_Guild_LtoC_CreateGuildResult *)Data;
	This->RL_CreateGuildResult( (char*)PG->GuildName.Begin() , PG->Result );
}
void NetCli_Guild::_PG_Guild_LtoC_NewGuildInvite		( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_NewGuildInvite *  PG = (PG_Guild_LtoC_NewGuildInvite *)Data;
	This->RL_NewGuildInvite( PG->GuildID , (char*)PG->LeaderName.Begin() , PG->LeaderDBID );
}
void NetCli_Guild::_PG_Guild_LtoC_NewGuildInviteResult	( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_NewGuildInviteResult *  PG = (PG_Guild_LtoC_NewGuildInviteResult *)Data;
	This->RL_NewGuildInviteResult( (char*)PG->PlayerName.Begin() , PG->Result );
}
void NetCli_Guild::_PG_Guild_LtoC_JoindNewGuild		( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_JoindNewGuild *  PG = (PG_Guild_LtoC_JoindNewGuild *)Data;
	This->RL_JoindNewGuild( PG->GuildID , (char*)PG->LeaderName.Begin() );
}
void NetCli_Guild::_PG_Guild_LtoC_LeaveNewGuildResult	( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_LeaveNewGuildResult *  PG = (PG_Guild_LtoC_LeaveNewGuildResult *)Data;
	This->RL_LeaveNewGuildResult( (char*)PG->KickPlayerName.Begin() , PG->Result );
}
void NetCli_Guild::_PG_Guild_LtoC_DelNewGuildResult		( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_DelNewGuildResult *  PG = (PG_Guild_LtoC_DelNewGuildResult *)Data;
	This->RL_DelNewGuildResult( PG->Result );
}
void NetCli_Guild::_PG_Guild_LtoC_GuildInfo				( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_GuildInfo *  PG = (PG_Guild_LtoC_GuildInfo *)Data;
	This->RL_GuildInfo( PG->Guild );
}
void NetCli_Guild::_PG_Guild_LtoC_GuildMemberListCount	( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_GuildMemberListCount *  PG = (PG_Guild_LtoC_GuildMemberListCount *)Data;
	_MemberCount = PG->MemberCount;
	_MemberList.clear();
}
void NetCli_Guild::_PG_Guild_LtoC_GuildMemberBaseInfo	( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_GuildMemberBaseInfo *  PG = (PG_Guild_LtoC_GuildMemberBaseInfo *)Data;

	_MemberList.push_back( PG->Info );
	if( (int)_MemberList.size() >= _MemberCount )
	{

		_MemberList.clear();
	}
}
void NetCli_Guild::_PG_Guild_LtoC_GuildMemberInfo		( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_GuildMemberInfo *  PG = (PG_Guild_LtoC_GuildMemberInfo *)Data;
	This->RL_GuildMemberInfo( PG->Member );
}
void NetCli_Guild::_PG_Guild_DtoC_GuildCreate			( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_GuildCreate *  PG = (PG_Guild_DtoC_GuildCreate *)Data;
	This->RD_GuildCreate( );
}
//////////////////////////////////////////////////////////////////////////
void NetCli_Guild::_PG_Guild_LtoC_GuildInvite				( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_GuildInvite *  PG = (PG_Guild_LtoC_GuildInvite *)Data;
	This->RL_GuildInvite( PG->GuildID , (char*)PG->LeaderName.Begin() , PG->LeaderDBID );
}
void NetCli_Guild::_PG_Guild_LtoC_GuildInviteResult			( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_GuildInviteResult *  PG = (PG_Guild_LtoC_GuildInviteResult *)Data;
	This->RL_GuildInviteResult( (char*)PG->PlayerName.Begin() , PG->Result );
}
void NetCli_Guild::_PG_Guild_LtoC_JoindGuild				( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_JoindGuild *  PG = (PG_Guild_LtoC_JoindGuild *)Data;
	This->RL_JoindGuild( PG->GuildID , (char*)PG->LeaderName.Begin() );
}
void NetCli_Guild::_PG_Guild_LtoC_LeaveGuildResult			( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_LeaveGuildResult *  PG = (PG_Guild_LtoC_LeaveGuildResult *)Data;
	This->RL_LeaveGuildResult( (char*)PG->KickPlayerName.Begin() , PG->Result );
}
void NetCli_Guild::_PG_Guild_LtoC_DelGuildResult			( int Sockid , int Size , void* Data )
{
	PG_Guild_LtoC_DelGuildResult *  PG = (PG_Guild_LtoC_DelGuildResult *)Data;
	This->RL_DelGuildResult( PG->Result );
}
//////////////////////////////////////////////////////////////////////////
void NetCli_Guild::_PG_Guild_DtoC_BoardPostResult			( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_BoardPostResult *  PG = (PG_Guild_DtoC_BoardPostResult *)Data;
	This->RD_BoardPostResult( PG->Result );
}
void NetCli_Guild::_PG_Guild_DtoC_BoardListCount			( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_BoardListCount *  PG = (PG_Guild_DtoC_BoardListCount *)Data;
	This->RD_BoardListCount( PG->MaxCount , PG->Count , PG->PageID );
}
void NetCli_Guild::_PG_Guild_DtoC_BoardListData				( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_BoardListData *  PG = (PG_Guild_DtoC_BoardListData *)Data;
	This->RD_BoardListData( PG->GUID , PG->Index , (char*)PG->PlayerName.Begin() , PG->Time , (char*)PG->Title.Begin() , PG->Type );
}
void NetCli_Guild::_PG_Guild_DtoC_BoardMessageResult		( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_BoardMessageResult *  PG = (PG_Guild_DtoC_BoardMessageResult *)Data;
	This->RD_BoardMessageResult( PG->Message );
}
void NetCli_Guild::_PG_Guild_DtoC_BoardModifyMessageResult	( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_BoardModifyMessageResult *  PG = (PG_Guild_DtoC_BoardModifyMessageResult *)Data;
	This->RD_BoardModifyMessageResult( PG->Result );
}
void NetCli_Guild::_PG_Guild_DtoC_BoardModifyModeResult		( int Sockid , int Size , void* Data )
{
	PG_Guild_DtoC_BoardModifyModeResult *  PG = (PG_Guild_DtoC_BoardModifyModeResult *)Data;
	This->RD_BoardModifyModeResult( PG->Result );
}
//////////////////////////////////////////////////////////////////////////
void NetCli_Guild::SL_CreateGuild				( char* GuildName )
{
	PG_Guild_CtoL_CreateGuild Send;
	Send.GuildName = GuildName;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_NewGuildInvite			( char* PlayerName )
{
	PG_Guild_CtoL_NewGuildInvite Send;
	Send.PlayerName = PlayerName;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_NewGuildInviteResult		( int GuildID , int LeaderDBID , bool Result )
{
	PG_Guild_CtoL_NewGuildInviteResult Send;
	Send.GuildID = GuildID;
	Send.LeaderDBID = LeaderDBID;
	Send.Result = Result;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_LeaveNewGuild			( char* KickPlayerName )
{
	PG_Guild_CtoL_LeaveNewGuild Send;
	Send.PlayerName = KickPlayerName;
	SendToLocal( sizeof(Send) , &Send );

}
void NetCli_Guild::SL_DelNewGuild			( )
{
	PG_Guild_CtoL_DelNewGuild Send;
	SendToLocal( sizeof(Send) , &Send );
}

void NetCli_Guild::SL_GuildInvite			( char* PlayerName )
{
	PG_Guild_CtoL_GuildInvite Send;
	Send.PlayerName = PlayerName;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_GuildInviteResult		( int GuildID , int LeaderDBID , bool Result )
{
	PG_Guild_CtoL_GuildInviteResult Send;
	Send.GuildID = GuildID;
	Send.LeaderDBID = LeaderDBID;
	Send.Result = Result;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_LeaveGuild			( char* KickPlayerName )
{
	PG_Guild_CtoL_LeaveGuild Send;
	Send.PlayerName = KickPlayerName;
	SendToLocal( sizeof(Send) , &Send );

}
void NetCli_Guild::SL_DelGuild			( )
{
	PG_Guild_CtoL_DelGuild Send;
	SendToLocal( sizeof(Send) , &Send );
}

void NetCli_Guild::SL_ModifyGuildInfoRequest		( GuildBaseStruct& Guild )
{
	PG_Guild_CtoL_ModifyGuildInfoRequest Send;
	Send.Guild = Guild;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_ModifyGuildMemberInfoRequest	( GuildMemberStruct& Member )
{
	PG_Guild_CtoL_ModifyGuildMemberInfoRequest Send;
	Send.Member = Member;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_GuildInfoRequet				( int GuildID )
{
	PG_Guild_CtoL_GuildInfoRequet Send;
	Send.GuildID = GuildID;
	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Guild::SL_GuildMemberListRequet		( int GuildID )
{
	PG_Guild_CtoL_GuildMemberListRequet Send;
	Send.GuildID = GuildID;
	SendToLocal( sizeof(Send) , &Send );	
}
void NetCli_Guild::SL_GuildMemberInfoRequet		( int MemberDBID )
{ 
	PG_Guild_CtoL_GuildMemberInfoRequet Send;
	Send.MemberDBID = MemberDBID;
	SendToLocal( sizeof(Send) , &Send );	
}
//////////////////////////////////////////////////////////////////////////
// ¯d¨¥ªO 
//////////////////////////////////////////////////////////////////////////
void NetCli_Guild::SL_BoardPostRequest			( char* Title , char* Msg )
{
	PG_Guild_CtoL_BoardPostRequest Send;
	Send.Message.Title	= Title;
	Send.Message.Message = Msg;
	SendToLocal( sizeof(Send) , &Send );	
}
void NetCli_Guild::SL_BoardListRequest			( int PageID )
{
	PG_Guild_CtoL_BoardListRequest Send;
	Send.PageID = PageID;
	SendToLocal( sizeof(Send) , &Send );	
}
void NetCli_Guild::SL_BoardMessageRequest		( int MessageGUID )
{
	PG_Guild_CtoL_BoardMessageRequest Send;
	Send.GUID = MessageGUID;
	SendToLocal( sizeof(Send) , &Send );	
}
void NetCli_Guild::SL_BoardModifyMessageRequest	( int MessageGUID , char* Message )
{
	PG_Guild_CtoL_BoardModifyMessageRequest Send;
	Send.Message = Message;
	Send.MessageGUID = MessageGUID;
	SendToLocal( sizeof(Send) , &Send );	
}
void NetCli_Guild::SL_BoardModifyModeRequest	( int MessageGUID , GuildBoardModeStruct	Mode )
{
	PG_Guild_CtoL_BoardModifyModeRequest Send;
	Send.Mode = Mode;
	Send.MessageGUID = MessageGUID;
	SendToLocal( sizeof(Send) , &Send );	
}
