diff --git a/01_DCS/Hooks/Perun.lua b/01_DCS/Hooks/Perun.lua index 932c559..8d629f4 100644 --- a/01_DCS/Hooks/Perun.lua +++ b/01_DCS/Hooks/Perun.lua @@ -22,7 +22,7 @@ Perun.MOTD_L2 = "Wymagamy obecnosci DCS SRS oraz TeamSpeak - szczegoly na forum" -- ###################### END OF SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION ###################### -- Variable init -Perun.Version = "v0.10.1" +Perun.Version = "v0.11.0" Perun.StatusData = {} Perun.SlotsData = {} Perun.MissionData = {} diff --git a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs index c7a251c..c2640a1 100644 --- a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs @@ -93,6 +93,38 @@ public class DatabaseController SQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = @PAR_TCPFramePayload, `pe_dataraw_updated`=" + TCPFrameTimestamp + " WHERE `pe_dataraw_type`=" + TCPFrameType + " AND `pe_dataraw_instance` = " + TCPFrameInstance + ";"; } + // Handling of special data (like parsing JSONs to DB) + switch (Int32.Parse(TCPFrameType)) + { + case 1: + // General status information + SQLQueryTxt += "INSERT INTO `pe_OnlineStatus` (`pe_OnlineStatus_instance`) SELECT '" + Int32.Parse(TCPFrameInstance) + "' FROM DUAL WHERE NOT EXISTS(SELECT * FROM `pe_OnlineStatus` WHERE `pe_OnlineStatus_instance` = '" + Int32.Parse(TCPFrameInstance) + "');"; + SQLQueryTxt += "UPDATE `pe_OnlineStatus` SET `pe_OnlineStatus_perunversion_winapp` = '" + TCPFrame.payload.v_win + "', `pe_OnlineStatus_perunversion_dcshook` ='" + TCPFrame.payload.v_dcs_hook + "' WHERE `pe_OnlineStatus_instance` = '" + Int32.Parse(TCPFrameInstance) + "' ;"; + + break; + + case 2: + // SRS Data + SQLQueryTxt += "DELETE FROM pe_OnlinePlayers WHERE pe_OnlinePlayers_instance = " + Int32.Parse(TCPFrameInstance) +";"; + + int player_count = 0; + foreach (var record_player in TCPFrame.payload.players) + { + SQLQueryTxt += "INSERT INTO `pe_OnlinePlayers` (`pe_OnlinePlayers_id`, `pe_OnlinePlayers_instance`, `pe_OnlinePlayers_ping`, `pe_OnlinePlayers_side`, `pe_OnlinePlayers_slot`, `pe_OnlinePlayers_ucid`) VALUES ("+ record_player.id + ", '"+ Int32.Parse(TCPFrameInstance) + "', '" + record_player.ping + "', '" + record_player.side + "', '" + record_player.slot + "', '" + record_player.ucid + "');"; + player_count++; + } + + //SQLQueryTxt += "DELETE FROM pe_OnlineStatus WHERE pe_OnlineStatus_instance = " + Int32.Parse(TCPFrameInstance) + ";"; + SQLQueryTxt += "INSERT INTO `pe_OnlineStatus` (`pe_OnlineStatus_instance`) SELECT '" + Int32.Parse(TCPFrameInstance) + "' FROM DUAL WHERE NOT EXISTS(SELECT * FROM `pe_OnlineStatus` WHERE `pe_OnlineStatus_instance` = '" + Int32.Parse(TCPFrameInstance) + "');"; + SQLQueryTxt += "UPDATE `pe_OnlineStatus` SET `pe_OnlineStatus_theatre` = '" + TCPFrame.payload.mission.theatre + "', `pe_OnlineStatus_name` = '" + TCPFrame.payload.mission.name + "' , `pe_OnlineStatus_pause` = '" + TCPFrame.payload.mission.pause + "', `pe_OnlineStatus_multiplayer` = '" + TCPFrame.payload.mission.multiplayer + "', `pe_OnlineStatus_realtime` = '" + TCPFrame.payload.mission.realtime + "', `pe_OnlineStatus_modeltime` = '" + TCPFrame.payload.mission.modeltime + "', `pe_OnlineStatus_players` = " + player_count + " WHERE `pe_OnlineStatus_instance` = '" + Int32.Parse(TCPFrameInstance) + "';"; + + break; + + default: + break; + } + + // Connect to mysql and execute sql try { diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs index 6a3776f..b0a4fed 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs @@ -37,7 +37,10 @@ namespace Perun_v1 // Get argument server port if (args[1] != null) { - con_txt_dcs_server_port.Text = args[1]; + if (args[1] != "-1") + { + con_txt_dcs_server_port.Text = args[1]; + } } } if (args.Length > 2) @@ -45,16 +48,23 @@ namespace Perun_v1 // Get argument instance id if (args[2] != null) { - con_txt_dcs_instance.Text = args[2]; + if (args[2] != "-1") + { + con_txt_dcs_instance.Text = args[2]; + } } } + if (args.Length > 3) { // Get argument DCS SRS file path if (args[3] != null) { - con_txt_3rd_srs.Text = args[3]; - con_check_3rd_srs.Checked = true; + if (args[3] != "-1") + { + con_txt_3rd_srs.Text = args[3]; + con_check_3rd_srs.Checked = true; + } } } if (args.Length > 4) @@ -62,8 +72,11 @@ namespace Perun_v1 // Get argument lotATC file path if (args[4] != null) { - con_txt_3rd_lotatc.Text = args[4]; - con_check_3rd_lotatc.Checked = true; + if (args[4] != "-1") + { + con_txt_3rd_lotatc.Text = args[4]; + con_check_3rd_lotatc.Checked = true; + } } } @@ -74,8 +87,11 @@ namespace Perun_v1 { if (args[5] == "1") { - TIM_Autostart.Enabled = true; - PerunHelper.AddLog(ref Globals.AppLogHistory, "Autostart parameter provided", 0, 1); + if (args[5] != "-1") + { + TIM_Autostart.Enabled = true; + PerunHelper.AddLog(ref Globals.AppLogHistory, "Autostart parameter provided", 0, 1); + } } } } diff --git a/02_Windows_App/Perun_v1/Perun_v1.csproj b/02_Windows_App/Perun_v1/Perun_v1.csproj index c37da60..4f47b37 100644 --- a/02_Windows_App/Perun_v1/Perun_v1.csproj +++ b/02_Windows_App/Perun_v1/Perun_v1.csproj @@ -31,8 +31,8 @@ szporwolik Perun Perun.htm - 2 - 0.10.1.%2a + 0 + 0.11.0.%2a false true true diff --git a/02_Windows_App/Perun_v1/Properties/AssemblyInfo.cs b/02_Windows_App/Perun_v1/Properties/AssemblyInfo.cs index 63e1ada..3144ec0 100644 --- a/02_Windows_App/Perun_v1/Properties/AssemblyInfo.cs +++ b/02_Windows_App/Perun_v1/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ using System.Runtime.InteropServices; // Możesz określić wszystkie wartości lub użyć domyślnych numerów kompilacji i poprawki // przy użyciu symbolu „*”, tak jak pokazano poniżej: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.10.1.0")] -[assembly: AssemblyFileVersion("0.10.1.0")] +[assembly: AssemblyVersion("0.11.0.0")] +[assembly: AssemblyFileVersion("0.11.0.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/03_MySQL/m1081_perun.sql b/03_MySQL/m1081_perun.sql index c7561cc..8df9ce8 100644 --- a/03_MySQL/m1081_perun.sql +++ b/03_MySQL/m1081_perun.sql @@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `pe_Config` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `pe_Config` (`pe_Config_id`, `pe_Config_payload`) VALUES -(1, 'v0.10.1'); +(1, 'v0.11.0'); DROP TABLE IF EXISTS `pe_DataMissionHashes`; CREATE TABLE IF NOT EXISTS `pe_DataMissionHashes` ( @@ -41,7 +41,6 @@ CREATE TABLE IF NOT EXISTS `pe_DataPlayers` ( UNIQUE KEY `UNIQUE_UCID` (`pe_DataPlayers_ucid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - DROP TABLE IF EXISTS `pe_DataRaw`; CREATE TABLE IF NOT EXISTS `pe_DataRaw` ( `pe_dataraw_type` tinyint(4) NOT NULL, @@ -116,6 +115,7 @@ CREATE TABLE IF NOT EXISTS `pe_LogStats` ( `pe_LogStats_typeid` int(11) DEFAULT NULL, `pe_LogStats_masterslot` int(11) DEFAULT NULL, `pe_LogStats_seat` int(10) DEFAULT NULL, + `ps_kills_X` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_pvp` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_deaths` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_ejections` int(11) UNSIGNED NOT NULL DEFAULT '0', @@ -129,7 +129,7 @@ CREATE TABLE IF NOT EXISTS `pe_LogStats` ( `ps_kills_infantry` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_kills_ships` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_kills_fortification` int(10) UNSIGNED NOT NULL DEFAULT '0', - `ps_kills_artillery` int(10) UNSIGNED NOT NULL DEFAULT '0', + `ps_kills_artillery` int(10) NOT NULL DEFAULT '0', `ps_kills_other` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_airfield_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_airfield_landings` int(11) UNSIGNED NOT NULL DEFAULT '0', @@ -150,7 +150,6 @@ CREATE TABLE IF NOT EXISTS `pe_LogStats` ( KEY `pe_LogStats_mstatus` (`pe_LogStats_mstatus`), KEY `pe_LogStats_seat` (`pe_LogStats_seat`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - DROP TRIGGER IF EXISTS `pe_LogStats_UPDATE`; DELIMITER $$ CREATE TRIGGER `pe_LogStats_UPDATE` BEFORE UPDATE ON `pe_LogStats` FOR EACH ROW BEGIN diff --git a/README.md b/README.md index 4badf69..09893f1 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Windows app supports command line arguments, what may be handy in case of multip The following arguments are accepted (keep the order!): * server port (shall be the same as in the lua file!) * instance ID (shall be the same as in the lua file!) -* path to SRS client-list.json -* path to LotATC stats.json +* path to SRS client-list.json OR put -1 if you do not want to use DCS SRS +* path to LotATC stats.json OR put -1 if you do not want to use LotATC * numeric value (without quotes), set 1 for Autostart (Perun will start within 500ms after starting up) Example for windows shortcut: @@ -88,7 +88,7 @@ DCS API does not track carrier or FARP operations natively, so there is a trick * table: pe_LogLogins - holds login to server event history * table: pe_LogStats - holds static information -![Database Scheme](https://i.imgur.com/dmJ2pIY.png "MIT") +![Database Scheme](https://i.imgur.com/zJsFxV0.png "MIT") ## Data packets - send from lua to TCP port * ```ID: 1```, contains version/diagnostic information