예제 #1
0
        /// <summary>
        /// Return the location string for the specified player
        /// </summary>
        /// <param name="gameData">The current game data.</param>
        /// <param name="charFile">The player's data file.</param>
        /// <returns>A string containing the location.</returns>
        public static string GetLocation(FLGameData gameData, FLDataFile charFile)
        {
            string location = gameData.GetItemDescByNickNameX(charFile.GetSetting("Player", "system").Str(0));

            if (charFile.SettingExists("Player", "pos"))
            {
                float posX = charFile.GetSetting("Player", "pos").Float(0);
                float posY = charFile.GetSetting("Player", "pos").Float(1);
                float posZ = charFile.GetSetting("Player", "pos").Float(2);
                location += String.Format(" in space {0}, {1}, {2}", posX, posY, posZ);
            }
            else
            {
                location += " docked at " + gameData.GetItemDescByNickNameX(charFile.GetSetting("Player", "base").Str(0));
            }
            return(location);
        }
예제 #2
0
        public EditReps(FLGameData gameData, string itemNickName, FLDataFile cfgFile)
        {
            InitializeComponent();

            this.itemNickName = itemNickName;
            this.cfgFile      = cfgFile;
            this.Text         = "Edit Reputations: " + gameData.GetItemDescByNickNameX(itemNickName);

            GameDataSet.HashListRow[] factions = (GameDataSet.HashListRow[])gameData.DataStore.HashList.Select("ItemType = '" + FLGameData.GAMEDATA_FACTIONS + "'");
            foreach (GameDataSet.HashListRow faction in factions)
            {
                uIDataSet.RepFixerItemFactions.AddRepFixerItemFactionsRow(faction.IDSName, faction.ItemNickName, "");
            }

            foreach (FLDataFile.Setting set in cfgFile.GetSettings(itemNickName))
            {
                string factionNick = set.settingName;

                string repStr = "-";
                if (set.NumValues() > 0)
                {
                    string[] values = set.Str(0).Split(',');
                    if (values.Length == 2)
                    {
                        int mode;
                        if (!Int32.TryParse(values[1], out mode))
                        {
                            repStr = "ERR";
                        }
                        else if (mode == MODE_REP_GREATERTHAN)
                        {
                            repStr = ">";
                        }
                        else if (mode == MODE_REP_STATIC)
                        {
                            repStr = "=";
                        }
                        else
                        {
                            repStr = "<";
                        }

                        float rep;
                        if (!Single.TryParse(values[0], out rep))
                        {
                            repStr = "ERR";
                        }
                        else if (rep > 1.0 || rep < -1.0)
                        {
                            repStr = "ERR";
                        }
                        else
                        {
                            repStr += rep.ToString();
                        }
                    }
                    else if (values.Length == 1)
                    {
                        float rep;
                        if (!Single.TryParse(values[0], out rep))
                        {
                            repStr = "ERR";
                        }
                        else if (rep > 1.0 || rep < -1.0)
                        {
                            repStr = "ERR";
                        }
                        repStr = "<" + rep.ToString();
                    }
                }

                foreach (UIDataSet.RepFixerItemFactionsRow faction in uIDataSet.RepFixerItemFactions.Rows)
                {
                    if (faction.ItemNickName == factionNick)
                    {
                        faction.Reputation = repStr;
                        break;
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// generate online statistics for online players ...
        /// </summary>
        private void GenerateOnlinePlayerStats(LogRecorderInterface log)
        {
            //***** assemble the sorted lists for both tables ...
            SortedDictionary <string, FLHookSocket.PlayerInfo> char_list   = new SortedDictionary <string, FLHookSocket.PlayerInfo>();
            SortedDictionary <string, List <string> >          system_list = new SortedDictionary <string, List <string> >();

            string[] playerlistFields = AppSettings.Default.setStatPlayerListShowFields.Split(';');
            bool     column0          = true;
            int      slots_in_use     = -1;

            lock (m_flHookCmdr.playerInfoList)
            {
                slots_in_use = m_flHookCmdr.playerInfoList.Count;
                //***** store the hook characters information into both lists ...
                foreach (KeyValuePair <int, FLHookSocket.PlayerInfo> kvp in m_flHookCmdr.playerInfoList)
                {
                    string character = HtmlEncode(kvp.Value.charname);
                    if (character != "-")
                    {
                        string system = HtmlEncode(m_gameData.GetItemDescByNickNameX(kvp.Value.system));
                        char_list.Add(character, kvp.Value);
                        if (!system_list.ContainsKey(system))
                        {
                            system_list.Add(system, new List <string>());
                        }
                        system_list[system].Add(character);
                    }
                }
            }
            //*****   generate the html contents ...
            string contents = "<html><head><title>Players Online</title><style type=text/css>";;

            contents += ".Column0 {FONT-FAMILY: Tahoma; FONT-SIZE: 10pt;  TEXT-ALIGN: left; COLOR: #000000; BACKGROUND: #FFFFFF;}";
            contents += ".Column1 {FONT-FAMILY: Tahoma; FONT-SIZE: 10pt;  TEXT-ALIGN: left; COLOR: #000000; BACKGROUND: #FFFFFF;}";
            contents += "</style>";
            contents += "</head><body>";
            if (AppSettings.Default.setStatPlayerListTimeUTC)
            {
                contents += "<i>last update: " + DateTime.UtcNow.ToString() + " [UTC]</i><br><br>";
            }
            else
            {
                contents += "<i>last update: " + DateTime.Now.ToString() + "</i><br><br>";
            }
            contents += "<i>used slots: " + String.Format("{0}", slots_in_use) + " </i><br><br><br><br>";
            if (AppSettings.Default.setStatPlayerListShowCharsByName)
            {
                contents += "<size=5><b><u>Characters by Name</u></b></size><br><br>";
                contents += "<table width=\"90%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
                contents += "<tr>";
                foreach (string field in playerlistFields)
                {
                    if (column0)
                    {
                        contents += "<th bgcolor=\"#ECE9D8\" align=\"left\"><font face=\"Tahoma\" color=\"#000000\" size=\"2\">";
                    }
                    else
                    {
                        contents += "<th bgcolor=\"#ECE9D8\" align=\"left\"><font face=\"Tahoma\" color=\"#000000\" size=\"2\">";
                    }
                    contents += field;
                    contents += "</font></th>";
                    column0   = !column0;
                }
                column0   = true;
                contents += "</tr>";
                foreach (KeyValuePair <string, FLHookSocket.PlayerInfo> kvp in char_list)
                {
                    contents += "<tr>";

                    foreach (string field in playerlistFields)
                    {
                        string toAdd = string.Empty;
                        switch (field)
                        {
                        case "Character": toAdd = kvp.Key; break;

                        case "System": toAdd = m_gameData.GetItemDescByNickNameX(kvp.Value.system); break;

                        case "ID": toAdd = kvp.Value.id.ToString(); break;

                        case "IP": toAdd = kvp.Value.ip.ToString(); break;

                        case "Ping": toAdd = kvp.Value.ping.ToString(); break;

                        case "Loss": toAdd = kvp.Value.loss.ToString(); break;

                        case "Fluct": toAdd = kvp.Value.ping_fluct.ToString(); break;

                        case "Saturation": toAdd = kvp.Value.saturation.ToString(); break;

                        case "TxQueue": toAdd = kvp.Value.txqueue.ToString(); break;

                        case "Lag": toAdd = kvp.Value.lag.ToString(); break;
                        }

                        //toAdd = HtmlEncode(toAdd);

                        contents += "<td class=\"column" + (column0 ? "0" : "1") + "\">";
                        contents += toAdd;
                        contents += "</td>";
                        column0   = !column0;
                    }

                    contents += "</tr>";
                }
                contents += "</table><br><br><br><br>";
            }
            if (AppSettings.Default.setStatPlayerListShowCharsBySys)
            {
                contents += "<size=5><b><u>Characters by System</u></b></size><br><br>";
                contents += "<table width=\"90%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
                contents += "<tr><th bgcolor=\"#ECE9D8\" align=\"left\"><font face=\"Tahoma\" color=\"#000000\" size=\"2\">Character</font></th><th bgcolor=\"#ECE9D8\" align=\"left\"><font face=\"Tahoma\" color=\"#000000\" size=\"2\">System</font></th></tr>";
                foreach (KeyValuePair <string, List <string> > kvp in system_list)
                {
                    kvp.Value.Sort();
                    foreach (string character in kvp.Value)
                    {
                        contents += "<tr><td class=\"column0\">" + character + "</td><td class=\"column1\">" + kvp.Key + "</td></tr>";
                    }
                }
                contents += "</table>";
            }
            contents += "</body></html>";
            //*****   open the stream and write the contents ...
            String       online_players_file = String.Format("{0}\\players_online.html", AppSettings.Default.setStatisticsDir);
            StreamWriter writer = new StreamWriter(online_players_file);

            try
            {
                writer.Write(contents);
            }
            catch (Exception ex)
            {
                log.AddLog(String.Format("Error '{0}' in GenerateOnlinePlayerStats", ex.Message));
            }
            finally
            {
                writer.Close();
            }
        }