Ejemplo n.º 1
0
	/// <summary>
	/// 查询游戏数据库
	/// </summary>
	/// <param name="server">游戏服务器</param>
	/// <param name="cmd">SQL命令</param>
	/// <returns>查询结果</returns>
	/// <remarks>这个函数是同步的(会阻塞)</remarks>
	public static SqlResult QueryGameServerDb(int userId,GameServer server, SqlCommand cmd)
	{
        object outArg = null;
        //简单判断
        if (!server.IsConnected) return null;
        if (server.DoPlugInAction(userId, GameServerDb.PlugInGuid, GameServerDb.ActionKeyQuery, ref outArg, "xxx", cmd))
		{
			uint sessionId = (uint)outArg;
			for (int i = 0; i < WebConfig.GetQueryResultRetryTimes; i++)
			{
				Thread.Sleep(WebConfig.GetQueryResultDelay);
                SqlResult result = server.GetPlugInData(userId, GameServerDb.PlugInGuid, GameServerDb.DataKeyQueryResult, sessionId) as SqlResult;
				if (result != null)
				{
					return result;
				}
			}
		}

		return null;
	}
Ejemplo n.º 2
0
    /// <summary>
    /// 玩家禁言及解禁言
    /// </summary>
    /// <param name="userId">FSEye用户</param>
    /// <param name="server">服务器</param>
    /// <param name="roleName">角色名</param>
    /// <param name="chatEnable">禁言标志位 true为解禁言 false为禁言</param>
    /// <returns></returns>
    public static bool SetRoleChatEnable(int userId, GameServer server, string roleName, bool chatEnable)
    {
        if (server == null || !server.IsConnected)
            return false;

        //先更新数据库然后发GM指令
        ArrayList paramList = new ArrayList();
        string sqlCmdText = string.Format("UPDATE {0} SET {1}='?' WHERE {2}='?';",
            FS2TableString.RolesfirstTableName,
            FS2TableString.RolesfirstFieldNoChatIn, 
            FS2TableString.RolesfirstFieldRoleName);
        paramList.Add(chatEnable ? "0" : "1");
        paramList.Add(roleName);

        SqlCommand sqlCmd = new SqlCommand(sqlCmdText, paramList.ToArray());
        SqlResult result = WebUtil.QueryGameServerDb(userId, server, sqlCmd);
        if (result != null && result.Success)
        {
            string gmCmd = string.Format("?gm ds SetChatFlag({0})", chatEnable ? 0 : 1);
            server.DoPlugInAction(userId, LordControl.PlugInGuid, LordControl.ActionKeyExecuteGMCommand, roleName, gmCmd);

            FSEye.Security.LogSystem.TheInstance.WriteGMOperationLog(userId,
                chatEnable ? (int)GMOperation.ChatEnable : (int)GMOperation.ChatDisable,
                roleName,
                server.Id,
                string.Format(StringDef.GMMessageLog,
                              AdminServer.TheInstance.SecurityManager.GetUser(userId).RealName,
                              server.Name,
                              roleName == null || roleName.Length == 0 ? string.Empty : string.Format("[{0}]", roleName),
                              chatEnable ? GMOperation.ChatEnable.ToString() : GMOperation.ChatDisable.ToString()),
                (int)GMOpTargetType.Role);
            return true;
        }
        else
        {
            return false;
        }        
    }
Ejemplo n.º 3
0
    public static bool SetRoleFrozen(int userId, GameServer server, string roleName, bool freeze)
    {
        if (server == null || !server.IsConnected)
            return false;

        //先更新数据库然后发GM指令
        ArrayList paramList = new ArrayList();
        string sqlCmdText = string.Format("UPDATE {0} SET {1}='?' WHERE {2}='?';",
            FS2TableString.RolesfirstTableName,
            FS2TableString.RolesfirstFieldNoLoginIn,
            FS2TableString.RolesfirstFieldRoleName);
        paramList.Add(freeze ? "1" : "0");
        paramList.Add(roleName);

        SqlCommand sqlCmd = new SqlCommand(sqlCmdText, paramList.ToArray());
        SqlResult result = WebUtil.QueryGameServerDb(userId, server, sqlCmd);
        if (result != null && result.Success)
        {
            //发GM指令设置Login标志位并把强制玩家下线
            string gmCmd = string.Format("?gm ds SetLoginFlag({0})", freeze ? 1 : 0);
            server.DoPlugInAction(userId, LordControl.PlugInGuid, LordControl.ActionKeyExecuteGMCommand, roleName, gmCmd);

            if (freeze)
                server.DoPlugInAction(userId, LordControl.PlugInGuid, LordControl.ActionKeyExecuteGMCommand, roleName, WebConfig.GMCommandKickPlayer);
            
            FSEye.Security.LogSystem.TheInstance.WriteGMOperationLog(userId,
                freeze ? (int)GMOperation.FreezeRole : (int)GMOperation.UnfreezeRole,
                roleName,
                server.Id,
                string.Format(StringDef.GMMessageLog,
                              AdminServer.TheInstance.SecurityManager.GetUser(userId).RealName,
                              server.Name,
                              roleName == null || roleName.Length == 0 ? string.Empty : string.Format("[{0}]", roleName),
                              freeze ? StringDef.Freeze + StringDef.Role : StringDef.Unfreeze + StringDef.Role),
                (int)GMOpTargetType.Role);
            return true;
        }
        else
        {
            return false;
        }
    }
Ejemplo n.º 4
0
    private void autoUpdate(GameServer server, string ftpPacket)
    {
        if (Page.Request.Params["serverId"] != null)
        {
            string[] para = new string[4];

            _updateServerId = int.Parse(Request.Params["serverId"].ToString());
            FTPServer ftpSvr = AdminServer.TheInstance.FTPClient.GetFTPServer(_updateServerId);
            ////需要对该UpdateServer有Read的权限
            //if (!WebUtil.CheckPrivilege(ftpServer.SecurityObject, OpType.READ, Session))
            //{
            //    Response.Redirect(WebConfig.PageNotEnoughPrivilege, true);
            //}

            para[0] = ftpSvr.Address;
            para[1] = ftpSvr.UserName;
            para[2] = ftpSvr.Password;
            para[3] = ftpPacket;

            if (server.DoPlugInAction(CurrentUser.Id, E2gUpdateserver.PlugInGuid, E2gUpdateserver.actionKey, para))
            {
                LabelOpMsg.Text = StringDef.Success;
                LabelOpMsg.Visible = true;
            }
            else
            {
                LabelOpMsg.Text = StringDef.Failure;
            }
            para = null;
        }
        TimeNow.Text = StringDef.TimeNow + ":" + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();

        TreeViewServerGroup.Enabled = false;
        Timer1.Enabled = true;        
    }
Ejemplo n.º 5
0
		void ServerMessageReceived(GameServer server, IProtocol message)
		{
            if ((ProtocolDef)message.ProtocolId == ProtocolDef.l2e_header_def)
            {
                switch ((ProtocolDef)BitConverter.ToUInt16(message.ToBytes(), 4))
                {
                    case ProtocolDef.l2e_GetGlobalVariable_def:
                        {
                            l2e_GetGlobalVariable protocol = message as l2e_GetGlobalVariable;
                            UpdateGlobalVariable(protocol.VariableIndex, protocol.VariableValue);
                        }
                        break;
                    case ProtocolDef.l2e_ping_def:
                        {
                            
                            server.GameServiceState = GameServer.ServiceState.Running;
                            if (server.PID <= 0)
                            {
                                string[] para = new string[1] { server.Id.ToString() };
                                server.DoPlugInAction(SecurityManager.SystemAutomationId, E2gServerPID.PlugInGuid, E2gServerPID.actionKey, para);
                            }
                            break;
                        }
                }
            }
		}
Ejemplo n.º 6
0
 private void SendGuardCfg(GameServer _server)
 {
     //发送GUARD配置文件
     if (_server != null)
     {
         if (_server.DoPlugInAction(CurrentUser.Id, GameServerControl.PlugInGuid, GameServerControl.ActionKeyReconfigureGuard))
         {
             LabelSuccess.Text = StringDef.Send + StringDef.Colon + StringDef.Success;
         }
         else
         {
             LabelOpMsg.Text = StringDef.Send + StringDef.Colon + StringDef.Failure;
         }
     }
 }