#include "../mainproc/GameMain.h"
#include "../../netwaker_member/NetWakerClientInc.h"
#include "../maintain/Maintain.h"
#include "MailFrame.h"
#include "TradeFrame.h"
#include "ChatFrame.h"
#include "ChatEdit.h"

CChatEdit*					g_pChatEdit = NULL;
map<string, int>			g_chatTypeInfo;

int LuaFunc_SendChatMessage(lua_State* L);
int LuaFunc_ParseText(lua_State* L);

// --------------------------------------------------------------------------------------
// 特殊命令處理
void TalkToWhisper(const char* text);
void TalkToZone(const char* text);
void TalkToGM(const char* text);
void GMCommand(const char* text);
void ScriptCommand(const char* text);
void OpenMaintainFrame(const char* text);
void ModifyObj(const char* text);
void DelObj(const char* text);
void PlayMotion(const char* text);
void SetTarrainDetailLevel(const char* text);
void TradeRequest(const char* text);
void TradeAgree(const char* text);
void TradeDisagree(const char* text);
void SetScale(const char* text);
void SetPos(const char* text);
void SetTargetPos(const char* text);
void SetGlow(const char* text);
void SetPlayerSpeed(const char* text);
void OpenBank(const char* text);
void ShowFps(const char* text);
void SpriteContainer(const char* text);
void SetStableFrame(const char* text);
void SetPlayerTitle(const char* text);
void SetNpcTitle(const char* text);
void OpenMacroFrame(const char* text);
void OpenLootFrame(const char* text);
void SetWidgetGrid(const char* text);

// --------------------------------------------------------------------------------------
// 物件重載 
void ReloadObj(const char* text);

// ----------------------------------------------------------------------------
// Channel 測試
void CreateChannel(const char* text);
void JoinChannel  (const char* text);
void LeaveChannel (const char* text);
void TellChannel  (const char* text);

void PlayerListChannel	(const char* text);
void JoinDisabledChannel(const char* text);
void KickPlayerChannel	(const char* text);
void SetManagerChannel	(const char* text);

void ChannelZoneID( const char* text );

// --------------------------------------------------------------------------------------
// Party 測試
void PartyInvite	( const char* text );
void PartyJoin		( const char* text );
void PartyKickMember( const char* text );
void PartyRule		( const char* text );
// --------------------------------------------------------------------------------------
//Party 物品分享
void PartyLoot		( const char* text );
void PartyPass		( const char* text );
void PartyAssist	( const char* text );

// --------------------------------------------------------------------------------------
//好友名單 測試
static void FriendInvite	( const char* text );	
static void FriendJoin		( const char* text );
static void FriendDel		( const char* text );

static void FriendSetInfo	( const char* text );
static void FriendSetFriend	( const char* text );

// --------------------------------------------------------------------------------------
//Mail 測試
void OpenMail		( const char* text );

static void MailList	( const char* text );
static void MailSendBack( const char* text );
static void MailDel		( const char* text );
static void MailRead	( const char* text );
static void MailGetItem	( const char* text );


//AC 測試
static void	ACSell( const char* text );
static void	ACSellCancel( const char* text );
static void	ACSearch( const char* text );
static void	ACSearchNext( const char* text );
static void	ACClose( const char* text );
static void	ACBuy( const char* text );
static void	ACItemHistory( const char* text );

//施法測試
static void Spell( const char* text );

//合成測試
static void Refine( const char* text );

//公會測試
static void NewGuildCreate( const char* text );
static void NewGuildInvite( const char* text );
static void NewGuildJoin( const char* text );
static void NewGuildLeave( const char* text );
static void NewGuildDel( const char* text );

static void GuildInvite( const char* text );
static void GuildJoin( const char* text );
static void GuildLeave( const char* text );
static void GuildDel( const char* text );

static void GuildModify( const char* text );
static void GuildModifyMember( const char* text );
static void GuildInfo( const char* text );
static void GuildMemberList( const char* text );
static void GuildMemberInfo( const char* text );


//公會留言板測試
static void GuildBoardPost			( const char* text );
static void GuildBoardList			( const char* text );
static void GuildBoardMessage		( const char* text );
static void GuildBoardMsgModify		( const char* text );
static void GuildBoardTypeModify	( const char* text );

// --------------------------------------------------------------------------------------
CSplitArgString::CSplitArgString()
{
	m_str = NULL;	
}

// --------------------------------------------------------------------------------------
CSplitArgString::CSplitArgString(const char* str)
{
	m_str = NULL;
	SetString(str);
}

// --------------------------------------------------------------------------------------
CSplitArgString::~CSplitArgString()
{
	if (m_str)
		delete [] m_str;
	m_str = NULL;
}

// --------------------------------------------------------------------------------------
void CSplitArgString::SetString(const char* str)
{
	if (str == NULL)
		return;

	m_startIndex.clear();
	m_endIndex.clear();
	m_startIndex.push_back( 0 );

	char* start = (char*)str;
	char* end;
	while ( end = strchr(start, ' ') )
	{
		m_endIndex.push_back( end - str );
		start = end;
		while ( *start == ' ' ) start++;
		m_startIndex.push_back( start - str );
	}

	if ( m_startIndex.size() != m_endIndex.size() )
		m_endIndex.push_back( strlen(str) );

	SAFE_DELETE( m_str );
	m_str = new char[strlen(str) + 1];
	strcpy( m_str, str );
}

// --------------------------------------------------------------------------------------
string CSplitArgString::GetString(int start, int end)
{
	string content;

	if (end == -1)
		end = m_endIndex.size() - 1;

	start	= max(start, 0);
	start	= min(start, (int)(m_startIndex.size() - 1));
	end		= max(end, 0);
	end		= min(end, (int)(m_endIndex.size() - 1));

	if (m_str && start >= 0)
	{
		char *first = m_str + m_startIndex[start];
		content.assign(first, m_endIndex[end] - m_startIndex[start]);
	}

	return content;
}

// ----------------------------------------------------------------------------
CChatEdit::CChatEdit(CInterface* object)
	: CInterfaceBase(object)
{
	// 建立發話頻道字串跟代碼索引
	g_chatTypeInfo.insert( make_pair("SAY", eChatType_SAY) );
	g_chatTypeInfo.insert( make_pair("YELL", eChatType_YELL) );
	g_chatTypeInfo.insert( make_pair("WHISPER", eChatType_WHISPER) );
	g_chatTypeInfo.insert( make_pair("PARTY", eChatType_PARTY) );
	g_chatTypeInfo.insert( make_pair("RAID", eChatType_RAID) );
	g_chatTypeInfo.insert( make_pair("GUILD", eChatType_GUILD) );
	g_chatTypeInfo.insert( make_pair("LFG", eChatType_LFG) );
	g_chatTypeInfo.insert( make_pair("SALE", eChatType_SALE) );
	g_chatTypeInfo.insert( make_pair("CHANNEL", eChatType_CHANNEL) );
	g_chatTypeInfo.insert( make_pair("GM", eChatType_GM) );

	//RegisterCmd("help",	NULL, Help);
	RegisterCmd("t", "talk to player", TalkToWhisper);
	RegisterCmd("zone", "talk to zone", TalkToZone);
	RegisterCmd("gm", "talk to gm", TalkToGM);
	RegisterCmd("?", "GM command", GMCommand);
	RegisterCmd("script", "lua script command", ScriptCommand);
	RegisterCmd("new", "", OpenMaintainFrame);
	RegisterCmd("modify", "", ModifyObj );
	RegisterCmd("del", "", DelObj );

	RegisterCmd("motion", "", PlayMotion);

	RegisterCmd("terrain_detail_level", "", SetTarrainDetailLevel);	
	RegisterCmd("trade_request", "", TradeRequest);
	RegisterCmd("trade_agree", "", TradeAgree);
	RegisterCmd("trade_disagree", "", TradeDisagree);
	RegisterCmd("scale", "", SetScale);
	RegisterCmd("set_pos", "", SetPos);
	RegisterCmd("settargetpos", "", SetTargetPos);
	RegisterCmd("glow", "", SetGlow);
	RegisterCmd("speed", "", SetPlayerSpeed);
	RegisterCmd("bank", "", OpenBank);
	RegisterCmd("fps", "", ShowFps);
	RegisterCmd("sprite_container", "", SpriteContainer);	
	RegisterCmd("stable_frame", "", SetStableFrame);
	RegisterCmd("set_player_title", "", SetPlayerTitle);
	RegisterCmd("set_npc_title", "", SetNpcTitle);
	RegisterCmd("macro", "", OpenMacroFrame);
	RegisterCmd("loot", "", OpenLootFrame);
	RegisterCmd("grid", "", SetWidgetGrid);

	//物件重載
	RegisterCmd("reloadobj", "", ReloadObj);	

	//頻道測試
	RegisterCmd("ccreate", "", CreateChannel );
	RegisterCmd("cjoin", ""  , JoinChannel   );
	RegisterCmd("cleave", "" , LeaveChannel  );
	RegisterCmd("ctell", ""  , TellChannel   );

	RegisterCmd("cplayerlist"	, "", PlayerListChannel	 );
	RegisterCmd("cjoindisabled"	, ""  , JoinDisabledChannel );
	RegisterCmd("ckickplayer"	, "" , KickPlayerChannel	 );
	RegisterCmd("csetmanager"	, ""  , SetManagerChannel	 );
	RegisterCmd("czoneid"	, ""  , ChannelZoneID	 );

	//Party 測試
	RegisterCmd("partyinvite"		, ""	, PartyInvite	  );
	RegisterCmd("partyjoin"			, ""	, PartyJoin		  );
	RegisterCmd("partykickMember"	, ""	, PartyKickMember );
	RegisterCmd("partyrule"			, ""	, PartyRule		  );

	RegisterCmd("partyloot"			, ""	, PartyLoot		);
	RegisterCmd("partypass"			, ""	, PartyPass		);
	RegisterCmd("partyassist"		, ""	, PartyAssist	);


	RegisterCmd("friendinvite"		, ""	,  FriendInvite		);
	RegisterCmd("friendjoin"		, ""	,  FriendJoin		);
	RegisterCmd("frienddel"			, ""	,  FriendDel		);
	RegisterCmd("friendsetinfo"		, ""	,  FriendSetInfo		);
	RegisterCmd("friendsetfriend"	, ""	,  FriendSetFriend		);

	//Mail測試	
	RegisterCmd("openmail"			, ""	,  OpenMail			);
	RegisterCmd("mlist"				, ""	,  MailList			);
	RegisterCmd("msendback"			, ""	,  MailSendBack		);
	RegisterCmd("mdel"				, ""	,  MailDel			);
	RegisterCmd("mread"				, ""	,  MailRead			);
	RegisterCmd("mgetitem"			, ""	,  MailGetItem		);

	//ac 測試
	RegisterCmd("acsell"			, ""	,  ACSell		);
	RegisterCmd("acsellcancel"		, ""	,  ACSellCancel	);
	RegisterCmd("acsearch"			, ""	,  ACSearch		);
	RegisterCmd("acsearchnext"		, ""	,  ACSearchNext	);
	RegisterCmd("acclose"			, ""	,  ACClose		);
	RegisterCmd("acbuy"				, ""	,  ACBuy		);
	RegisterCmd("acitemhistory"		, ""	,  ACItemHistory);

	//施法測試
	RegisterCmd("spell"				, ""	,  Spell );

	//合成測試
	RegisterCmd("refine"			, ""	,  Refine );

	//公會測試
	RegisterCmd("newguildcreate"	, ""	,  NewGuildCreate	);
	RegisterCmd("newguildinvite"	, ""	,  NewGuildInvite	);
	RegisterCmd("newguildjoin"		, ""	,  NewGuildJoin		);
	RegisterCmd("newguildleave"		, ""	,  NewGuildLeave	);
	RegisterCmd("newguilddel"		, ""	,  NewGuildDel		);

	RegisterCmd("guildinvite"		, ""	,  GuildInvite		);
	RegisterCmd("guildjoin"			, ""	,  GuildJoin		);
	RegisterCmd("guildleave"		, ""	,  GuildLeave		);
	RegisterCmd("guilddel"			, ""	,  GuildDel			);

	RegisterCmd("guildmodify"		, ""	,  GuildModify		);
	RegisterCmd("guildmodifymember"	, ""	,  GuildModifyMember);
	RegisterCmd("guildinfo"			, ""	,  GuildInfo		);
	RegisterCmd("guildmemberlist"	, ""	,  GuildMemberList	);
	RegisterCmd("guildmemberinfo"	, ""	,  GuildMemberInfo	);

	//公會留言版測試
	RegisterCmd("GuildBoardPost"		, ""	,  GuildBoardPost			);
	RegisterCmd("GuildBoardList"		, ""	,  GuildBoardList			);
	RegisterCmd("GuildBoardMessage"		, ""	,  GuildBoardMessage		);
	RegisterCmd("GuildBoardMsgModify"	, ""	,  GuildBoardMsgModify		);
	RegisterCmd("GuildBoardTypeModify"	, ""	,  GuildBoardTypeModify		);
/*
	static void SL_BoardPostRequest				( GuildBoardStruct& Message );
	static void SL_BoardListRequest				( int PageID );
	static void SL_BoardMessageRequest			( int MessageGUID );
	static void SL_BoardModifyMessageRequest	( char* Message );
	static void SL_BoardModifyModeRequest		( GuildBoardModeStruct	Mode );	
*/
	g_pChatEdit			= this;
	m_channel			= eChatType_Range;
}

// ----------------------------------------------------------------------------
CChatEdit::~CChatEdit()
{
	g_pChatEdit = NULL;
}

// ----------------------------------------------------------------------------
void CChatEdit::RegisterFunc()
{
	lua_State* l = GetLuaStateWorld();
	if (l)
	{
		lua_register(l, "SendChatMessage",		LuaFunc_SendChatMessage);
		lua_register(l, "ParseText",			LuaFunc_ParseText);
	}
}

// ----------------------------------------------------------------------------
void CChatEdit::RegisterCmd(const char* cmdStr, const char* explain, com_func func)
{
	if (cmdStr == NULL || func == NULL)
		return;

	string tmp(cmdStr);
	_strlwr( (char*)tmp.c_str() );

	CommandInfo info;
	if ( explain )
		info.explain = explain;
	info.func = func;

	m_command.insert(make_pair(tmp, info));

	/*
	//交易測試
	RegisterCmd("opentrade", NULL, UI_OpenTrade);
	RegisterCmd("trade", NULL, Trade);
	RegisterCmd("agreetrade", NULL, AgreeTrade);

	// 功能開關
	RegisterCmd("title", "{on or off} object title", TitleVisible);
	RegisterCmd("sprite_update", "{on or off}", SpriteUpdate);
	RegisterCmd("sprite_render", "{on or off}", SpriteRender);

	RegisterCmd("Touch", NULL, Touch);

	RegisterCmd("newobj", NULL, NewObj);

	RegisterCmd("useitem", NULL, UseItem_Body);

	//設定點術策試
	RegisterCmd("setpoint", "{ str or sta or int ...}" , SetPoint);
	RegisterCmd("spellmagic", NULL, SpellMagic);
	RegisterCmd("showfps", "{on or off}", ShowFps);
	RegisterCmd("camera_set", "{x, y, z}", SetCameraPos);
	RegisterCmd("camera_move", "{x, y, z}", MoveCameraPos);
	RegisterCmd("camera_far_plane", "{far(int)}", SetCameraFarPlane);
	RegisterCmd("setfog", "{min(int) max(int)}", SetFog);
	RegisterCmd("glow", "{on or off}", Glow);
	RegisterCmd("options", "open options frame", OpenOptionsFrame);
	*/
}

// ----------------------------------------------------------------------------
void CChatEdit::SendChatMessage(ChatTypeInfo type, const char* text, const char* language, const char* extra)
{
	if ( text == NULL )
		return;
	
	int len = strlen(text);
	char* buf = new char[len * 2];

	Translator(text, buf);			// 轉譯特別字元
	
	char playerName[MAX_PATH];
	strcpy( playerName, g_pGameMain->GetPlayerName() );

	switch (type)
	{
	case eChatType_SAY:				// 範圍
		NetCli_Talk::Range( buf );
		break;

	case eChatType_YELL:			// 區域
		NetCli_Talk::Channel( EM_GroupObjectType_SysZoneChannel, NetCli_ChannelChild::GetZoneChannelID("yell"), playerName, (char*)text );
		break;

	case eChatType_WHISPER:			// 密語
		if ( extra != NULL )
		{
			NetCli_Talk::TalkTo( extra, buf );
		}		
		break;

	case eChatType_PARTY:			// 隊伍
		NetCli_Talk::Channel(EM_GroupObjectType_Party, 0, playerName, buf );
		break;

	case eChatType_RAID:			// 團隊
		break;

	case eChatType_GUILD:			// 公會
		NetCli_Talk::Channel(EM_GroupObjectType_Guild, 0, playerName, buf );
		break;

	case eChatType_LFG:				// 招幕
		break;

	case eChatType_SALE:			// 買賣
		break;

	case eChatType_CHANNEL:			// 自定頻道
		if ( extra != NULL )
		{
			g_pChatFrame->SendChannelMsg(atoi(extra), playerName, buf);
		}
		break;

	case eChatType_GM:				// GM 頻道
		ParseText(buf);
		break;
	}

	delete [] buf;
}

// ----------------------------------------------------------------------------
void CChatEdit::SendChatMessage(const char* text, int channel)
{
	static char tmp[1024];
	if (text == NULL || text[0] == 0)
		return;

	Translator(text, tmp);

	if (text[0] == '/')
		ParseText(tmp + 1);
	else
	{
		switch (m_channel)
		{
		case eChatType_Whisper:
			NetCli_Talk::TalkTo( m_tellTarget.c_str(), tmp );
			break;

		case eChatType_Range:
			NetCli_Talk::Range( tmp );
			break;

		case eChatType_Zone:
			//			NetCli_Talk::Zone( tmp );
			break;

		case eChatType_GMCommand:
			NetCli_Talk::GMCommand( tmp );
			break;

		case eChatType_System:
			break;
		}
	}
}

// ----------------------------------------------------------------------------
void CChatEdit::ParseText(const char* text)
{
	CSplitArgString arg_text(text);	
	string str = arg_text.GetString(0 , 0);
	_strlwr( (char*)str.c_str() );

	map<string, CommandInfo>::iterator iter = m_command.find(str);
	if (iter == m_command.end())
	{
		// 命令錯誤
		// RECEIVE_CHAT_MESSAGE
		// System error 9
		char tmp[MAX_PATH];
		sprintf(tmp, "%s 語法錯誤", str.c_str());
		g_pChatFrame->AddMessage(9, tmp);
	}
	else
	{
		string second_text = arg_text.GetString(1);
		(iter->second).func(second_text.c_str());
	}
}

// ----------------------------------------------------------------------------
void CChatEdit::Translator(const char* src, char* dest)
{
	while ( *src )
	{
		if ( *src > 0x80 )
		{
			*dest++ = *src++;
			*dest++ = *src++;
		}
		else if ( *src == '%' )
		{
			if ( strnicmp(src + 1, "t_id", 4) == 0 )
			{
				CRoleSprite* player = g_pGameMain->GetTargetPlayer();
				src += 5;

				if ( player )
				{
					char tmp[16];
					sprintf( tmp, "%d", player->GetIdentify() );

					int len = strlen(tmp);
					memcpy( dest, tmp, len );
					dest += len;
				}
			}
			else if ( strnicmp(src + 1, "s_id", 4) == 0 )
			{
				CRoleSprite* player = g_pGameMain->GetPlayer();
				src += 5;

				if ( player )
				{
					char tmp[16];
					sprintf( tmp, "%d", player->GetIdentify() );

					int len = strlen(tmp);
					memcpy( dest, tmp, len );
					dest += len;
				}
			}
			else if ( strnicmp(src + 1, "t", 1) == 0 )
			{
				CRoleSprite* player = g_pGameMain->GetTargetPlayer();
				src += 2;

				if ( player && player->GetName() )
				{
					int len = strlen( player->GetName() );
					memcpy( dest, player->GetName(), len );
					dest += len;
				}
			}
			else if ( strnicmp(src + 1, "s", 1) == 0 )
			{
				CRoleSprite* player = g_pGameMain->GetPlayer();
				src += 2;

				if ( player && player->GetName() )
				{
					int len = strlen( player->GetName() );
					memcpy( dest, player->GetName(), len );
					dest += len;
				}
			}			
			else if ( strnicmp(src + 1, "%", 1) == 0 )
			{
				src += 2;
				*dest++ = '%';
			}
			else
				*dest++ = *src++;
		}
		else
			*dest++ = *src++;
	}
	*dest = 0;
}

// ----------------------------------------------------------------------------
int LuaFunc_SendChatMessage(lua_State* L)
{
	const char* text = luaL_checkstring(L, 1);
	const char* type = luaL_checkstring(L, 2);
	const char* language = (lua_isstring(L, 3)) ? lua_tostring(L, 3) : NULL;
	const char* extra = (lua_isstring(L, 4)) ? lua_tostring(L, 4) : NULL;

	string chatType = type;
	_strupr( (char*)chatType.c_str() );
	map<string, int>::iterator iter = g_chatTypeInfo.find(chatType);
	if ( iter != g_chatTypeInfo.end() )
	{
		g_pChatEdit->SendChatMessage((ChatTypeInfo)iter->second, text, language, extra);
	}	
	return 0;
}

// ----------------------------------------------------------------------------
int LuaFunc_ParseText(lua_State* L)
{
	g_pChatEdit->ParseText(luaL_checkstring(L, 1));
	return 0;
}

// ----------------------------------------------------------------------------
void TalkToWhisper(const char* text)
{	
	CSplitArgString arg_text(text);
	string player, content;
	player = arg_text.GetString(0, 0);
	content = arg_text.GetString(1, 1);
	NetCli_Talk::TalkTo(player.c_str(), content.c_str());	
}

// ----------------------------------------------------------------------------
void TalkToZone(const char* text)
{
	//	NetCli_Talk::Zone(text);
}

// ----------------------------------------------------------------------------
void GMCommand(const char* text)
{
	NetCli_Talk::GMCommand(text);
}
void TalkToGM(const char* text)
{
	char Buf[1024];
	sprintf( Buf , "[通知GM] : %s" , text );
	g_pChatFrame->AddMessage( 5, Buf );

	NetCli_Talk::GMMsg(text);
}
// ----------------------------------------------------------------------------
void ScriptCommand(const char* text)
{
	lua_State* L = g_pChatEdit->GetLuaStateWorld();
	if (L)
	{
		if ( lua_dostring(L, text) != 0 )
		{
			const char* err = lua_tostring(L, -1);				
			lua_pop(L, 1);
			UiOuputError(err);
		}
	}
}


// ----------------------------------------------------------------------------
void OpenMaintainFrame(const char* text)
{
	g_pMaintain->Open();
	/*
	lua_State* L = g_pChatEdit->GetLuaStateWorld();
	if (L)
	{
		lua_dostring(L, "MaintainInterface:Show()");
	}
	*/
}

// ----------------------------------------------------------------------------
void PlayMotion(const char* text)
{		
	if (text)
	{
		CRoleSprite* player = g_pGameMain->GetPlayer();
		if (player)
		{
			player->Motion(atoi(text));
		}
	}
}

// ----------------------------------------------------------------------------
void SetTarrainDetailLevel(const char* text)
{
	int level = 0;
	if (text)
		level = atoi(text);
	g_pGameMain->SetTerrainDetailLevel(level);	
}

// ----------------------------------------------------------------------------
void TradeRequest(const char* text)
{
	if ( text )
	{		
		g_pTradeFrame->SetProcess(eTradeState_Request_Made, atoi(text));
	}
}

// ----------------------------------------------------------------------------
void TradeAgree(const char* text)
{
	g_pTradeFrame->SetProcess(eTradeState_Agree, g_pTradeFrame->GetPlayerId());
}

// ----------------------------------------------------------------------------
void TradeDisagree(const char* text)
{
	g_pTradeFrame->SetProcess(eTradeState_Disagree, 0);
}

// ----------------------------------------------------------------------------
void SetScale(const char* text)
{
	float scale = 1.0f;
	if (text)
		scale = (float)atof(text);

	CRoleSprite* sprite = g_pGameMain->GetTargetPlayer();
	if ( sprite == NULL )
		sprite = g_pGameMain->GetPlayer();

	if ( sprite )
		sprite->Scale( scale );
}

// ----------------------------------------------------------------------------
void SetPos(const char* text)
{
	CRuVector3 pos(0.0f, 0.0f, 0.0f);
	CSplitArgString arg_text(text);
	pos.m_x = (float)atof( arg_text.GetString(0, 0).c_str() );
	pos.m_y = (float)atof( arg_text.GetString(1, 1).c_str() );
	pos.m_z = (float)atof( arg_text.GetString(2, 2).c_str() );

	CRoleSprite* sprite = g_pGameMain->GetPlayer();
	if (sprite)
		sprite->SetPos( pos );
}

// ----------------------------------------------------------------------------
void SetTargetPos(const char* text)
{
	CRuVector3 pos(0.0f, 0.0f, 0.0f);
	CSplitArgString arg_text(text);
	pos.m_x = (float)atof( arg_text.GetString(0, 0).c_str() );
	pos.m_y = (float)atof( arg_text.GetString(1, 1).c_str() );
	pos.m_z = (float)atof( arg_text.GetString(2, 2).c_str() );

	CRoleSprite* sprite = g_pGameMain->GetPlayer();
	if (sprite)
		sprite->SetTargetPos(pos, false);
}

// ----------------------------------------------------------------------------
void SetGlow(const char* text)	
{
	bool open = false;
	if ( text && strcmp(text, "on") == 0 )
		open = true;
	g_pGameMain->SetGlow( open );
}	

// ----------------------------------------------------------------------------
void SetPlayerSpeed(const char* text)
{
	float speed = 33.0f;
	if ( text )
		speed = (float)atof(text);

	CRoleSprite* player = g_pGameMain->GetPlayer();
	if ( player )
		player->SetMoveSpeed(speed);
}

// ----------------------------------------------------------------------------
void OpenBank(const char* text)
{
	lua_State* L = g_pChatEdit->GetLuaStateWorld();
	if (L)
	{
		lua_dostring(L, "BankFrame:Show()");
	}
}

// ----------------------------------------------------------------------------
void ShowFps(const char* text)
{
	bool open = false;
	if ( text && strcmp(text, "on") == 0 )
		open = true;
	g_pGameMain->SetShowFps( open );
}

// ----------------------------------------------------------------------------
void SpriteContainer(const char* text)
{
	set<IBaseSprite*>& container = IBaseSprite::GetContainer();
	for ( set<IBaseSprite*>::iterator iter = container.begin(); iter != container.end(); iter++ )
	{
		char tmp[MAX_PATH];
		memset( tmp, 0, sizeof(tmp) );
		switch ((*iter)->GetClassType())
		{
		case eSpriteClass_Base:
			{				
				sprintf( tmp, "[Base] id : %d ", (*iter)->GetIdentify() );
			}			
			break;

		case eSpriteClass_Role:
			{
				CRoleSprite* role = (CRoleSprite*)(*iter);
				switch ((*iter)->GetObjectType())
				{
				case eSpriteObject_Unknown:
					sprintf( tmp, "[Role][Unknown] id : %d Name : %s", role->GetIdentify(), role->GetName() );
					break;
				case eSpriteObject_Player:
					sprintf( tmp, "[Role][Player] id : %d Name : %s", role->GetIdentify(), role->GetName() );
					break;
				case eSpriteObject_NPC:
					sprintf( tmp, "[Role][NPC] id : %d Name : %s", role->GetIdentify(), role->GetName() );
					break;
				case eSpriteObject_Effect:
					sprintf( tmp, "[Role][Effect] id : %d Name : %s", role->GetIdentify(), role->GetName() );
					break;
				}
			}			
			break;

		case eSpriteClass_Effect:
			sprintf( tmp, "[Effect] id : %d ", (*iter)->GetIdentify() );
			break;

		case eSpriteClass_Effect_Line:
			sprintf( tmp, "[Effect_Line] id : %d ", (*iter)->GetIdentify() );
			break;
		}

		g_pChatFrame->AddMessage(0, tmp);
	}
}

// ----------------------------------------------------------------------------
void SetStableFrame(const char* text)
{
	bool isStable =  false;
	if ( text && stricmp(text, "on") == 0 )
		isStable = true;

	g_pGameMain->SetStableFrame( isStable );
}

// ----------------------------------------------------------------------------
void SetPlayerTitle(const char* text)
{
	bool isVisible = false;
	if ( text && stricmp(text, "on") == 0 )
		isVisible = true;

	CRoleSprite::SetPlayerTitleVisible( isVisible );
}

// ----------------------------------------------------------------------------
void SetNpcTitle(const char* text)
{
	bool isVisible = false;
	if ( text && stricmp(text, "on") == 0 )
		isVisible = true;

	CRoleSprite::SetNpcTitleVisible( isVisible );
}

// ----------------------------------------------------------------------------
void OpenMacroFrame(const char* text)
{
	lua_State* L = g_pChatEdit->GetLuaStateWorld();
	if (L)
	{
		lua_dostring(L, "MacroFrame:Show()");
	}
}

// ----------------------------------------------------------------------------
void OpenLootFrame(const char* text)
{
	lua_State* L = g_pChatEdit->GetLuaStateWorld();
	if (L)
	{
		lua_dostring(L, "LootFrame:Show()");
	}
}

// ----------------------------------------------------------------------------
void SetWidgetGrid(const char* text)
{
	if ( text && stricmp(text, "off") == 0 )
		g_pGameMain->ReleaseWidgetGrid();
	else
	{
		CSplitArgString arg(text);
		CRuVector3 pos(0.0f, 0.0f, 0.0f);
		float size = 100.0f;
		float spacing = 5.0f;
		bool isLocked = false;

		for ( int i = 0; i < arg.GetArgSize(); i++ )
		{
			switch (i)
			{
			case 0:
				isLocked = atoi(arg.GetString(0, 0).c_str());
				break;

			case 1:
				pos.m_x = (float)atof( arg.GetString(1, 1).c_str() );
				break;

			case 2:
				pos.m_y = (float)atof( arg.GetString(2, 2).c_str() );
				break;

			case 3:
				pos.m_z = (float)atof( arg.GetString(3, 3).c_str() );
				break;

			case 4:
				size = (float)atof( arg.GetString(4, 4).c_str() );
				break;

			case 5:
				spacing = (float)atof( arg.GetString(5, 5).c_str() );
				break;
			}
		}
		g_pGameMain->CreateWidgetGrid(pos, isLocked, size, spacing);
	}
}

// ----------------------------------------------------------------------------
// Channel 測試
void CreateChannel(const char* text)
{
	CSplitArgString arg_text(text);
	string ChannelName = arg_text.GetString(0, 0);
	string Password	   = arg_text.GetString(1, 1);

	NetCli_Channel::S_CreateChannel( (char*)ChannelName.c_str() , (char*)Password.c_str() );
}
void JoinChannel  (const char* text)
{
	CSplitArgString arg_text(text);
	string ChannelName	= arg_text.GetString(0, 0);
	string Password	= arg_text.GetString(1, 1);

	NetCli_Channel::S_JoinChannel( (char*)ChannelName.c_str() , (char*)Password.c_str() );
}
void LeaveChannel (const char* text)
{
	CSplitArgString arg_text(text);
	int ChannelType = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int ChannelID	= atol( (char*)(arg_text.GetString(1, 1).c_str()) );


	NetCli_Channel::S_LeaveChannel( (GroupObjectTypeEnum)ChannelType , ChannelID );
}
void TellChannel  (const char* text)
{
	/*
	EM_GroupObjectType_SysChannel    = 0   ,
	EM_GroupObjectType_PlayerChannel    ,
	EM_GroupObjectType_Party            ,
	EM_GroupObjectType_Guild            ,
	*/
	CSplitArgString arg_text(text);
	int ChannelType = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int ChannelID	= atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	string Context = arg_text.GetString(2, 2);

	NetCli_Talk::Channel( (GroupObjectTypeEnum)ChannelType , ChannelID , "Name" , (char*)Context.c_str() );

}
void PlayerListChannel(const char* text)
{
	CSplitArgString arg_text(text);
	int ChannelType = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int ChannelID	= atol( (char*)(arg_text.GetString(1, 1).c_str()) );

	NetCli_Channel::S_ChannelPlayerList( (GroupObjectTypeEnum)ChannelType , ChannelID );
}
void JoinDisabledChannel(const char* text)
{
	CSplitArgString arg_text(text);
	int ChannelType = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int ChannelID	= atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	int	JoinEnabled = atol( (char*)(arg_text.GetString(2, 2).c_str()) );

	NetCli_Channel::S_JoinPlayerDisabled( (GroupObjectTypeEnum)ChannelType , ChannelID , JoinEnabled != 0 );
}
void KickPlayerChannel(const char* text)
{
	CSplitArgString arg_text(text);
	int ChannelType = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int ChannelID	= atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	string PlayerName = arg_text.GetString(2, 2);

	NetCli_Channel::S_KickPlayer( (GroupObjectTypeEnum)ChannelType , ChannelID , (char*)PlayerName.c_str() );
}
void SetManagerChannel(const char* text)
{
	CSplitArgString arg_text(text);
	int ChannelType = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int ChannelID	= atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	string PlayerName = arg_text.GetString(2, 2);

	NetCli_Channel::S_SetManager( (GroupObjectTypeEnum)ChannelType , ChannelID , (char*)PlayerName.c_str() );
}
void ChannelZoneID(const char* text)
{
	CSplitArgString arg_text(text);
	int ZoneID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );

	NetCli_Channel::S_ChannelZoneID( ZoneID );
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Party 測試
void PartyInvite	( const char* text )
{
	CSplitArgString arg_text(text);
	string Name = arg_text.GetString(0, 0);
	NetCli_PartyChild::InviteToParty( Name.c_str() );
}
void PartyJoin		( const char* text )
{
	NetCli_PartyChild::InviteAnswerState(true);
}
void PartyKickMember( const char* text )
{
	CSplitArgString arg_text(text);
	string MemberName = arg_text.GetString(0, 0);
	NetCli_PartyChild::KickMember( (char*)MemberName.c_str() );
}
void PartyRule		( const char* text )
{
	CSplitArgString arg_text(text);
	string Type  = arg_text.GetString(0, 0);
	string TypeValue = arg_text.GetString(1, 1);
	PartyBaseInfoStruct Info = NetCli_PartyChild::GetPartyInfo();

	if( Type.compare( "Leader" ) ==  0 )
	{
		//改隊長
		Info.LeaderName = TypeValue.c_str();
	}
	else if( Type.compare( "Attack" ) ==  0 )
	{
		Info.AttackName = TypeValue.c_str();

	}
	else if( Type.compare( "Share" ) ==  0 )
	{
		Info.ShareName = TypeValue.c_str();
		Info.ItemShareType = EM_PartyItemShare_Assign;
	}
	else if( Type.compare( "ShareType" ) ==  0 )
	{
		if( TypeValue.compare( "Roll" ) == 0 )
		{
			Info.ItemShareType = EM_PartyItemShare_Roll;	
		}
		/*else if( TypeValue.compare( "InOrder" ) == 0 )
		{
		Info.ItemShareType = EM_PartyItemShare_InOrder;
		}*/
		else
		{
			g_pChatFrame->AddMessage(9, "語法錯誤 ( Type : Leader , Attack , Share , ShareType ) (ShareType: Roll , InOrder )");
			return;
		}
	}
	else
	{
		g_pChatFrame->AddMessage(9, "語法錯誤 ( Type : Leader , Attack , Share , ShareType ) (ShareType: Roll , InOrder )");

		return;
	}

	NetCli_PartyChild::S_PartyRule( Info );

}

void PartyTell  (const char* text)
{
	CSplitArgString arg_text(text);
	int ChannelID	= atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	string Context = arg_text.GetString(1, 1);

	NetCli_Channel::S_DataTransmitToCli_Group( EM_GroupObjectType_Party , ChannelID , (char*)Context.c_str() , Context.size() + 1 );

}
void PartyLoot		( const char* text )
{
	CSplitArgString arg_text(text);
	int ItemVersion = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Party::S_LootItem( ItemVersion );
}
void PartyPass		( const char* text )
{
	CSplitArgString arg_text(text);
	int ItemVersion = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Party::S_PassItem( ItemVersion );

}
void PartyAssist	( const char* text )
{
	CSplitArgString arg_text(text);
	int ItemVersion = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int DBID		= atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	NetCli_Party::S_AssistItem( ItemVersion , DBID );

}

void FriendInvite	( const char* text )
{
	CSplitArgString arg_text(text);
	string Name  = arg_text.GetString(0, 0);

	NetCli_FriendList::SChat_BefriendRequest( (char*)Name.c_str() );
}
void FriendJoin		( const char* text )
{
	CSplitArgString arg_text(text);
	string Name  = arg_text.GetString(0, 0);

	NetCli_FriendList::SChat_BefriendResult( (char*)Name.c_str() , true );
}
void FriendDel		( const char* text )
{
	CSplitArgString arg_text(text);
	string Name  = arg_text.GetString(0, 0);

	NetCli_FriendList::SL_DelFriend( (char*)Name.c_str() );
}

void FriendSetInfo	( const char* text )
{
	CSplitArgString arg_text(text);
	string Note  = arg_text.GetString(0, 0);
	NetCli_FriendList::SL_ModifyMyInfo( (char*)Note.c_str() );
}
void FriendSetFriend	( const char* text )
{
	CSplitArgString arg_text(text);
	string Name  = arg_text.GetString(0, 0);
	string Group  = arg_text.GetString(1, 1);
	string Note  = arg_text.GetString(2, 2);

	NetCli_FriendList::SL_SetFriendInfo		( (char*)Name.c_str() , (char*)Group.c_str() , (char*)Note.c_str() );
}
// ----------------------------------------------------------------------------
// 物件重載 
void ReloadObj(const char* text)
{
	g_pChatFrame->AddMessage(9, "Cli 端物件資料重載");
	ObjectDataClass::Init( g_pRuneDev->GetFullFilePath("Data\\") );
}
// ----------------------------------------------------------------------------
void ModifyObj( const char* text )
{
	CRoleSprite* Obj = g_pGameMain->GetTargetPlayer();
	

	if ( Obj == NULL )
	{
		g_pChatFrame->AddMessage(9, "目標不存在!!");
		return;
	}
	
	char tmp[256];
	sprintf(tmp, "/? modify %d", Obj->GetIdentify() );
	g_pChatEdit->SendChatMessage(tmp, 0);

}
// ----------------------------------------------------------------------------
void DelObj( const char* text )
{
	CRoleSprite* Obj = g_pGameMain->GetTargetPlayer();

	if ( Obj == NULL )
	{
		g_pChatFrame->AddMessage(9, "目標不存在!!");
		return;
	}

	char tmp[256];
	sprintf(tmp, "/? delobj %d", Obj->GetIdentify() );
	g_pChatEdit->SendChatMessage(tmp, 0);

}
// ----------------------------------------------------------------------------
void OpenMail ( const char* text )
{
	g_pMailFrame->OpenMail();
}
// ----------------------------------------------------------------------------
void MailList		( const char* text )
{
	NetCli_Mail::SL_MailList();
}
void MailSendBack	( const char* text )
{
	CSplitArgString arg_text(text);
	int MailDBID  = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Mail::SL_SendBack( MailDBID );
}
void MailDel		( const char* text )
{
	CSplitArgString arg_text(text);
	int MailDBID  = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Mail::SL_DelMail( MailDBID );
}
void MailRead		( const char* text )
{
	CSplitArgString arg_text(text);
	int MailDBID  = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Mail::SL_ReadMail( MailDBID );
}
void MailGetItem	( const char* text )
{
	CSplitArgString arg_text(text);
	int MailDBID  = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int Money	  = atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	NetCli_Mail::SL_GetItem( MailDBID , Money );
}
// ----------------------------------------------------------------------------
void ACSell( const char* text )
{
	CSplitArgString arg_text(text);

	int		Pos			= atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int		Price		= atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	int		BuyOutPrice	= atol( (char*)(arg_text.GetString(2, 2).c_str()) );

	RoleDataEx* Role = CNetGlobal::RoleData();

	ItemFieldStruct* Item = Role->GetBodyItem( Pos );

	if( Item == NULL )
		return ;

	NetCli_ACChild::SL_SellItem( Pos , *Item , Price , BuyOutPrice , 1000 );

}
// ----------------------------------------------------------------------------
void	ACSellCancel( const char* text )
{
	CSplitArgString arg_text(text);

	int		ACItemDBID = atol( (char*)(arg_text.GetString(0, 0).c_str()) ); 
	NetCli_ACChild::SL_CancelSellItem( ACItemDBID );
}
// ----------------------------------------------------------------------------
void	ACSearch( const char* text )
{
	CSplitArgString arg_text(text);
	ACSearchConditionStruct Data;
	Data.LevelHi = 100;
	Data.LevelLow = 0;
	Data.Type[0] = -1;
	Data.Type[1] = -1;
	Data.Type[2] = -1;
	Data.SearchName = "狼"; 
	NetCli_ACChild::SL_SearchItem( Data );
}
// ----------------------------------------------------------------------------
void	ACSearchNext( const char* text )
{


	NetCli_ACChild::SL_GetNextSearchItem(  );
}
// ----------------------------------------------------------------------------
void	ACClose( const char* text )
{
	NetCli_ACChild::SL_CloseAC();
}
void	ACBuy( const char* text )
{	
	CSplitArgString arg_text(text);
	int		ACItemDBID	= atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int		Prices		= atol( (char*)(arg_text.GetString(1, 1).c_str()) );

	NetCli_ACChild::SL_BuyItem( ACItemDBID , Prices );
}

void	ACItemHistory( const char* text )
{
	CSplitArgString arg_text(text);
	int		OrgObjID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int		Inherent = atol( (char*)(arg_text.GetString(1, 1).c_str()) );

	NetCli_ACChild::SL_ItemHistoryRequest( OrgObjID , Inherent );
}

//施法測試
void Spell( const char* text )
{
	CSplitArgString arg_text(text);
	int		MagicID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int		TargetID;

	CRoleSprite* Target = g_pGameMain->GetTargetPlayer();

	if( Target == NULL )
		TargetID = g_pGameMain->GetPlayerID();
	else
		TargetID = Target->GetIdentify();

	RoleDataEx* Role = CNetGlobal::RoleData();

	for( int i = 0 ; i <  _MAX_SPSkill_COUNT_+_MAX_NormalSkill_COUNT_+_MAX_NormalSkill_COUNT_ ; i++ )
	{
		if( Role->TempData.Skill.AllSkill[i] != MagicID )
			continue;

		NetCli_Magic::BeginSpell( g_pGameMain->GetPlayerID() , TargetID , MagicID , i );
		return;
	}

	g_pChatFrame->AddMessage(9, "不會此法術" );

}

//合成測試
void Refine( const char* text )
{
	CSplitArgString arg_text(text);
	int		RecipeID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );

	NetCli_Recipe::SL_RefineItem( RecipeID );
}

//公會測試
void NewGuildCreate( const char* text )
{
	CSplitArgString arg_text(text);

	string GuildName = arg_text.GetString(0, 0);
	NetCli_Guild::SL_CreateGuild( (char*)GuildName.c_str() );

}
void NewGuildInvite( const char* text )
{
	CSplitArgString arg_text(text);
	string PlayerName = arg_text.GetString(0, 0);
	NetCli_Guild::SL_NewGuildInvite( (char*)PlayerName.c_str() );
}
void NewGuildJoin( const char* text )
{
	CSplitArgString arg_text(text);
	int		GuildID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int		LeaderDBID = atol( (char*)(arg_text.GetString(1, 1).c_str()) );
	
	
	NetCli_Guild::SL_NewGuildInviteResult( GuildID , LeaderDBID , true );
}

void NewGuildLeave( const char* text )
{
	CSplitArgString arg_text(text);
	string PlayerName = arg_text.GetString(0, 0);
	NetCli_Guild::SL_LeaveNewGuild( (char*)PlayerName.c_str() );
}
void NewGuildDel( const char* text )
{
	NetCli_Guild::SL_DelNewGuild( );
}

//---------------------------------------------------------------------------------------------
void GuildInvite( const char* text )
{
	CSplitArgString arg_text(text);
	string PlayerName = arg_text.GetString(0, 0);
	NetCli_Guild::SL_GuildInvite( (char*)PlayerName.c_str() );
}
void GuildJoin( const char* text )
{
	CSplitArgString arg_text(text);
	int		GuildID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	int		LeaderDBID = atol( (char*)(arg_text.GetString(1, 1).c_str()) );

	NetCli_Guild::SL_GuildInviteResult( GuildID , LeaderDBID , true );
}

void GuildLeave( const char* text )
{
	CSplitArgString arg_text(text);
	string PlayerName = arg_text.GetString(0, 0);
	NetCli_Guild::SL_LeaveGuild( (char*)PlayerName.c_str() );
}
void GuildDel( const char* text )
{
	NetCli_Guild::SL_DelGuild( );
}
//-------------------------------------------------------------------------------------------
void GuildModify( const char* text )
{
	//測試用  debug 硬塞
	GuildBaseStruct Guild;

	NetCli_Guild::SL_ModifyGuildInfoRequest( Guild );
}
void GuildModifyMember( const char* text )
{
	//測試用  debug 硬塞
	GuildMemberStruct Member;

	NetCli_Guild::SL_ModifyGuildMemberInfoRequest( Member );

}
void GuildInfo( const char* text )
{
	CSplitArgString arg_text(text);
	int		GuildID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Guild::SL_GuildInfoRequet( GuildID );
}
void GuildMemberList( const char* text )
{
	CSplitArgString arg_text(text);
	int		GuildID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Guild::SL_GuildMemberListRequet( GuildID );
}
void GuildMemberInfo( const char* text )
{
	CSplitArgString arg_text(text);
	int		MemberDBID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Guild::SL_GuildMemberInfoRequet( MemberDBID );
}

//公會留言板測試
void GuildBoardPost			( const char* text )
{
	static int ID = 0;
	char Buf[256];
	sprintf( Buf , "Title%d" , ID );
	NetCli_Guild::SL_BoardPostRequest( Buf , "Message" );

	ID++;
}
void GuildBoardList			( const char* text )
{
	CSplitArgString arg_text(text);
	int		PageID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Guild::SL_BoardListRequest( PageID );
}
void GuildBoardMessage		( const char* text )
{
	CSplitArgString arg_text(text);
	int		MessageGUID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );
	NetCli_Guild::SL_BoardMessageRequest( MessageGUID );
}
void GuildBoardMsgModify	( const char* text )
{
	CSplitArgString arg_text(text);	
	string	Msg			= arg_text.GetString(1, 1);
	int		MessageGUID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );

	NetCli_Guild::SL_BoardModifyMessageRequest( MessageGUID , (char*)Msg.c_str() );
}
void GuildBoardTypeModify	( const char* text )
{
	CSplitArgString arg_text(text);
	GuildBoardModeStruct	Mode;
	Mode._Type = atol( (char*)(arg_text.GetString(1, 1).c_str()) );

	int		MessageGUID = atol( (char*)(arg_text.GetString(0, 0).c_str()) );

	NetCli_Guild::SL_BoardModifyModeRequest( MessageGUID ,  Mode );
	
}
