58 Commits

Author SHA1 Message Date
VladMordock
27ff04092b Merge pull request #48 from szporwolik/dev
v0.11.1
2020-11-12 02:37:50 +01:00
VladMordock
a695d32ee3 0.11.1 for Perun.lua 2020-11-12 00:28:01 +01:00
VladMordock
3f33b2a166 Fixed SQL Code 2020-11-12 00:27:34 +01:00
VladMordock
174dccbe1a Added info about STRICT_TRANS_TABLES into ReadMe 2020-11-12 00:26:06 +01:00
szporowolik
8917701a19 Fixed default port to 48621 and info about new tables added in v0.11.0 2020-11-07 12:08:31 +01:00
VladMordock
8e28b5b735 Merge pull request #47 from szporwolik/dev
v0.11.0-hotfix
2020-11-06 22:57:03 +01:00
szporowolik
b07ec7b9c3 v0.11.0-hotfix 2020-11-06 22:53:18 +01:00
VladMordock
d591da2c43 Merge pull request #46 from szporwolik/dev
v0.11.0
2020-11-06 17:21:33 +01:00
szporowolik
174bb1e2ef v0.11.1 config 2020-11-06 17:13:52 +01:00
szporowolik
a4ce9ed254 Update for v0.11.0 2020-11-06 17:08:32 +01:00
szporowolik
ff268a47e4 Fixes for: #43 , #44, #45 2020-11-06 16:59:25 +01:00
szporowolik
37fd76c8ae Config for 0.11.0 2020-09-16 01:17:29 +02:00
szporowolik
167f3e9021 Added status tables:
- pe_OnlinePlayers
- pe_OnlineStatus
2020-09-16 01:01:42 +02:00
szporowolik
4723702d28 0.10.2 config prepared 2020-09-15 23:23:30 +02:00
VladMordock
f6d1ec82d5 Merge pull request #41 from szporwolik/master
Merge master with Dev
2020-09-15 23:21:46 +02:00
VladMordock
fd6b0a65ab Added donation link 2020-09-15 00:58:09 +02:00
VladMordock
78310771c3 Merge pull request #40 from szporwolik/dev
0.10.1
2020-09-15 00:45:41 +02:00
szporowolik
18b6d8b0ce Build for 0.10.1 2020-09-15 00:38:53 +02:00
szporowolik
dcb9510802 DB update for 0.10.1 2020-09-15 00:25:27 +02:00
szporowolik
d35ceafab2 Final build for 0.10.1 2020-09-15 00:24:36 +02:00
VladMordock
84e1d97c8e Changed autostart to 500ms 2020-09-15 00:20:24 +02:00
szporowolik
9f22b0e4df Fixed #38 - Scuds shall be counted now 2020-09-15 00:09:38 +02:00
VladMordock
699787c00e Commend line parameter for autostart 2020-09-15 00:01:20 +02:00
szporowolik
403b3df59a - Prepared for 0.10.1 build
- Added autostart parameter
2020-09-14 23:59:20 +02:00
VladMordock
c2fa89e364 Updated ReadMe as per #37
Updated ReadMe as per #37
2020-09-14 23:27:06 +02:00
Szymon Porwolik
5b96f2387e Added PHP integration example
Added PHP integration example per #37
2020-09-14 23:24:01 +02:00
VladMordock
52891a19e7 Merge pull request #36 from szporwolik/dev
Fixed events not triggered
2020-07-01 14:32:24 +02:00
szporowolik
466171a756 Fixed events not triggered 2020-07-01 14:31:45 +02:00
VladMordock
d8a38059da Merge pull request #35 from szporwolik/dev
Added some debug information and fixed statics counted as helicopters…
2020-07-01 13:13:40 +02:00
szporowolik
57583c3501 Added some debug information and fixed statics counted as helicopters (again) 2020-07-01 13:13:08 +02:00
VladMordock
d41495a8ab Merge pull request #34 from szporwolik/dev
0.10.0
2020-07-01 10:34:21 +02:00
szporowolik
4bceb1b944 Config fo 0.10.0 release 2020-07-01 10:07:38 +02:00
szporowolik
a2ac6cfcd8 Config changes for 0.9.5 2020-06-28 12:29:38 +02:00
szporowolik
c5fd25d996 Fix for #33 - database structure and winapp update 2020-06-28 12:25:01 +02:00
szporowolik
fdd1f72edf Fix for #33 - artillery kills shall be now properlly counted 2020-06-28 12:14:37 +02:00
szporowolik
b054ebc59f Fix for #32 - the helicopters shall be now properly counted and unknown kills will not increase helicopter kill ratio 2020-06-28 12:11:33 +02:00
VladMordock
85260cb98a Merge pull request #31 from szporwolik/dev
Fixed MySQL code
2020-05-08 22:01:20 +02:00
VladMordock
66b4702954 Fixed missing closing bracket
Fix per https://github.com/szporwolik/perun/issues/30
2020-05-08 21:59:11 +02:00
szporowolik
a1253d8057 Merge branch 'dev' of https://github.com/szporwolik/perun into dev 2020-05-02 23:41:48 +02:00
szporowolik
bba09a9158 0.9.5 configuration 2020-05-02 23:41:41 +02:00
VladMordock
4c52f91fbb Merge pull request #29 from szporwolik/dev
Fix for SimpleRadioStandalone-1.8.0.2
2020-05-02 23:16:26 +02:00
VladMordock
18e03947f3 Merge branch 'master' into dev 2020-05-02 23:16:17 +02:00
szporowolik
7b75eba79b Fixed SRS export for SimpleRadioStandalone-1.8.0.2.zip 2020-05-02 23:14:21 +02:00
VladMordock
8e4f60649a Add files via upload
Added logo
2020-01-07 20:15:40 +01:00
VladMordock
c68a0aecd1 Update README.md
New logo ;-)
2020-01-07 16:10:12 +01:00
VladMordock
fc9c976387 Update README.md
New logo ;-)
2020-01-07 16:09:43 +01:00
szporowolik
a3c1fecae3 Cherry pick of double quotes 2019-12-23 14:27:52 +01:00
szporowolik
e37b73a4f1 Fix for double quotes after adding parameters. 2019-12-23 14:26:06 +01:00
szporowolik
1540615814 Fix for double quotes after adding parameters. 2019-12-23 14:21:14 +01:00
szporowolik
d700430333 v0.9.4 configuration 2019-12-23 14:04:21 +01:00
VladMordock
f42a3e60a2 Merge pull request #28 from szporwolik/dev
9.3
2019-12-23 13:52:16 +01:00
VladMordock
ff78ba1cfe Merge branch 'master' into dev 2019-12-23 13:52:02 +01:00
szporowolik
a117d37bc0 Update and sync with 0.9.3 2019-12-23 13:48:50 +01:00
szporowolik
c36befd5a0 Changes related to #27 .
This shall prevent SQL injection.
2019-12-23 13:43:19 +01:00
VladMordock
1cadd04092 Fix for error when MySQL is running in TRADITIONAL mode
https://www.got-it.ai/solutions/sqlquerychat/sql-help/data-manipulation/handling-overflow-and-out-of-range-errors-in-mysql/
2019-11-18 18:26:14 +01:00
szporowolik
4cca5ee405 v0.9.3 preparation 2019-11-18 01:50:17 +01:00
szporowolik
ca48b4bc0a v0.9.3 preparation 2019-11-18 01:49:46 +01:00
szporowolik
c55c4efaf8 9.2 final 2019-11-18 01:48:03 +01:00
14 changed files with 432 additions and 69 deletions

View File

@@ -9,7 +9,7 @@ package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
Perun.RefreshStatus = 15 -- (int) [default: 60] Base refresh rate in seconds to send status update Perun.RefreshStatus = 15 -- (int) [default: 60] Base refresh rate in seconds to send status update
Perun.RefreshMission = 60 -- (int) [default: 120] Refresh rate in seconds to send mission information Perun.RefreshMission = 60 -- (int) [default: 120] Refresh rate in seconds to send mission information
Perun.TCPTargetPort = 48620 -- (int) [default: 48621] TCP port to send data to Perun.TCPTargetPort = 48621 -- (int) [default: 48621] TCP port to send data to
Perun.TCPPerunHost = "localhost" -- (string) [default: "localhost"] IP adress of the Perun instance or "localhost" Perun.TCPPerunHost = "localhost" -- (string) [default: "localhost"] IP adress of the Perun instance or "localhost"
Perun.Instance = 1 -- (int) [default: 1] Id number of instance (if multiple DCS instances are to run at the same PC) Perun.Instance = 1 -- (int) [default: 1] Id number of instance (if multiple DCS instances are to run at the same PC)
Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) [default: "Scripts\\Json\\"] Folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) [default: "Scripts\\Json\\"] Folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
@@ -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 ###################### -- ###################### END OF SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION ######################
-- Variable init -- Variable init
Perun.Version = "v0.9.2" Perun.Version = "v0.11.1"
Perun.StatusData = {} Perun.StatusData = {}
Perun.SlotsData = {} Perun.SlotsData = {}
Perun.MissionData = {} Perun.MissionData = {}
@@ -138,20 +138,26 @@ end
Perun.GetCategory = function(id) Perun.GetCategory = function(id)
-- Helper function returns object category basing on https://pastebin.com/GUAXrd2U -- Helper function returns object category basing on https://pastebin.com/GUAXrd2U
local _killed_target_category = DCS.getUnitTypeAttribute(id, "category") local _killed_target_category = "Other"
-- Sometimes we get empty object id (seems like DCS API bug)
if id ~= nil and id ~= "" then
_killed_target_category = DCS.getUnitTypeAttribute(id, "category")
-- Below, simple hack to get the propper category when DCS API is not returning correct value
if _killed_target_category == nil then
local _killed_target_cat_check_ship = DCS.getUnitTypeAttribute(id, "DeckLevel")
local _killed_target_cat_check_plane = DCS.getUnitTypeAttribute(id, "WingSpan")
if _killed_target_cat_check_ship ~= nil and _killed_target_cat_check_plane == nil then
_killed_target_category = "Ships"
elseif _killed_target_cat_check_ship == nil and _killed_target_cat_check_plane ~= nil then
_killed_target_category = "Planes"
else
_killed_target_category = "Helicopters"
end
end
end
-- Below, simple hack to get the propper category when DCS API is not returning correct value
if _killed_target_category == nil then
local _killed_target_cat_check_ship = DCS.getUnitTypeAttribute(id, "DeckLevel")
local _killed_target_cat_check_plane = DCS.getUnitTypeAttribute(id, "WingSpan")
if _killed_target_cat_check_ship ~= nil and _killed_target_cat_check_plane == nil then
_killed_target_category = "Ships"
elseif _killed_target_cat_check_ship == nil and _killed_target_cat_check_plane ~= nil then
_killed_target_category = "Planes"
else
_killed_target_category = "Helicopters"
end
end
return _killed_target_category return _killed_target_category
end end
@@ -163,7 +169,11 @@ Perun.SideID2Name = function(id)
[2] = 'BLUE', [2] = 'BLUE',
[3] = 'NEUTRAL', -- TBD check once this is released in DCS [3] = 'NEUTRAL', -- TBD check once this is released in DCS
} }
return _sides[id] if id > 0 then
return _sides[id]
else
return "?"
end
end end
Perun.AddLog = function(text,LogLevel) Perun.AddLog = function(text,LogLevel)
@@ -488,6 +498,7 @@ Perun.LogStatsCount = function(argPlayerID,argAction,argTimer)
_TempData['ps_kills_infantry'] = 0 _TempData['ps_kills_infantry'] = 0
_TempData['ps_kills_ships'] = 0 _TempData['ps_kills_ships'] = 0
_TempData['ps_kills_fortification'] = 0 _TempData['ps_kills_fortification'] = 0
_TempData['ps_kills_artillery'] = 0
_TempData['ps_kills_other'] = 0 _TempData['ps_kills_other'] = 0
_TempData['ps_airfield_takeoffs'] = 0 _TempData['ps_airfield_takeoffs'] = 0
_TempData['ps_airfield_landings'] = 0 _TempData['ps_airfield_landings'] = 0
@@ -546,6 +557,8 @@ Perun.LogStatsCount = function(argPlayerID,argAction,argTimer)
Perun.StatData[_player_hash]['ps_kills_infantry']=Perun.StatData[_player_hash]['ps_kills_infantry']+1 Perun.StatData[_player_hash]['ps_kills_infantry']=Perun.StatData[_player_hash]['ps_kills_infantry']+1
elseif argAction == "kill_Fortification" then elseif argAction == "kill_Fortification" then
Perun.StatData[_player_hash]['ps_kills_fortification']=Perun.StatData[_player_hash]['ps_kills_fortification']+1 Perun.StatData[_player_hash]['ps_kills_fortification']=Perun.StatData[_player_hash]['ps_kills_fortification']+1
elseif argAction == "kill_Artillery" then
Perun.StatData[_player_hash]['ps_kills_artillery']=Perun.StatData[_player_hash]['ps_kills_artillery']+1
elseif argAction == "kill_Other" then elseif argAction == "kill_Other" then
Perun.StatData[_player_hash]['ps_kills_other']=Perun.StatData[_player_hash]['ps_kills_other']+1 Perun.StatData[_player_hash]['ps_kills_other']=Perun.StatData[_player_hash]['ps_kills_other']+1
elseif argAction == "kill_PvP" then elseif argAction == "kill_PvP" then
@@ -782,6 +795,7 @@ end
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7) Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
-- Game event has occured -- Game event has occured
Perun.AddLog("Event handler for ".. eventName .. " started",2) Perun.AddLog("Event handler for ".. eventName .. " started",2)
if eventName == "friendly_fire" then if eventName == "friendly_fire" then
--"friendly_fire", playerID, weaponName, victimPlayerID --"friendly_fire", playerID, weaponName, victimPlayerID
if arg2 == "" then if arg2 == "" then
@@ -828,6 +842,8 @@ Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
_temp_event_type="kill_Infantry" _temp_event_type="kill_Infantry"
elseif _temp_category == "Fortification" then elseif _temp_category == "Fortification" then
_temp_event_type="kill_Fortification" _temp_event_type="kill_Fortification"
elseif _temp_category == "Artillery" or _temp_category == "MissilesSS" then
_temp_event_type="kill_Artillery"
else else
_temp_event_type="kill_Other" _temp_event_type="kill_Other"
end end
@@ -848,7 +864,12 @@ Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
arg7 = "Cannon" arg7 = "Cannon"
end end
Perun.LogEvent(eventName,Perun.SideID2Name(arg3) .. _temp_killers .. " in " .. arg2 .. " killed " .. Perun.SideID2Name(arg6) .. _temp_victims .. " in " .. arg5 .. " using " .. arg7 .. " [".. Perun.GetCategory(arg5).."]",arg7,Perun.GetCategory(arg5)); local victim_vehicle = arg5
if victim_vehicle == "" then
victim_vehicle = "?"
end
Perun.LogEvent(eventName,Perun.SideID2Name(arg3) .. _temp_killers .. " in " .. arg2 .. " killed " .. Perun.SideID2Name(arg6) .. _temp_victims .. " in " .. victim_vehicle .. " using " .. arg7 .. " [".. Perun.GetCategory(arg5).."]",arg7,Perun.GetCategory(arg5));
elseif eventName == "self_kill" then elseif eventName == "self_kill" then
--"self_kill", playerID --"self_kill", playerID

View File

@@ -8,13 +8,19 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A710507-92E9-4664-9B91-918B8B82F107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5A710507-92E9-4664-9B91-918B8B82F107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A710507-92E9-4664-9B91-918B8B82F107}.Debug|Any CPU.Build.0 = Debug|Any CPU {5A710507-92E9-4664-9B91-918B8B82F107}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A710507-92E9-4664-9B91-918B8B82F107}.Debug|x64.ActiveCfg = Debug|x64
{5A710507-92E9-4664-9B91-918B8B82F107}.Debug|x64.Build.0 = Debug|x64
{5A710507-92E9-4664-9B91-918B8B82F107}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A710507-92E9-4664-9B91-918B8B82F107}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A710507-92E9-4664-9B91-918B8B82F107}.Release|Any CPU.Build.0 = Release|Any CPU {5A710507-92E9-4664-9B91-918B8B82F107}.Release|Any CPU.Build.0 = Release|Any CPU
{5A710507-92E9-4664-9B91-918B8B82F107}.Release|x64.ActiveCfg = Release|x64
{5A710507-92E9-4664-9B91-918B8B82F107}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -48,17 +48,17 @@ public class DatabaseController
{ {
// Add entry to chat log // Add entry to chat log
SQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + TCPFrame.payload.ucid + "' );"; SQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + TCPFrame.payload.ucid + "' );";
SQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated` = " + TCPFrameTimestamp + ",`pe_DataPlayers_lastname`='" + TCPFrame.payload.player + "' WHERE `pe_DataPlayers_ucid`='" + TCPFrame.payload.ucid + "' ;"; SQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated` = " + TCPFrameTimestamp + ",`pe_DataPlayers_lastname`=@PAR_payload_player WHERE `pe_DataPlayers_ucid`='" + TCPFrame.payload.ucid + "' ;";
SQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + TCPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");"; SQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + TCPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");";
SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + " ;"; SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + " ;";
SQLQueryTxt += "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`,`pe_LogChat_missionhash_id`) VALUES (NULL,'" + TCPFrame.payload.datetime + "', (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.ucid + "'), '" + TCPFrame.payload.msg + "', '" + TCPFrame.payload.all + "',(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.missionhash + "'));"; SQLQueryTxt += "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`,`pe_LogChat_missionhash_id`) VALUES (NULL,'" + TCPFrame.payload.datetime + "', (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.ucid + "'), @PAR_payload_msg, '" + TCPFrame.payload.all + "',(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.missionhash + "'));";
} }
else if (TCPFrameType == "51") else if (TCPFrameType == "51")
{ {
// Add entry to event log // Add entry to event log
SQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.log_missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");"; SQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.log_missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");";
SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ";"; SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ";";
SQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_arg1`,`pe_LogEvent_arg2`,`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ('" + TCPFrame.payload.log_arg_1 + "','" + TCPFrame.payload.log_arg_2 + "', NULL, '" + TCPFrame.payload.log_datetime + "', '" + TCPFrame.payload.log_type + "', '" + TCPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "'));"; SQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_arg1`,`pe_LogEvent_arg2`,`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ('" + TCPFrame.payload.log_arg_1 + "','" + TCPFrame.payload.log_arg_2 + "', NULL, '" + TCPFrame.payload.log_datetime + "', '" + TCPFrame.payload.log_type + "', @PAR_log_content, (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "'));";
} }
else if (TCPFrameType == "52") else if (TCPFrameType == "52")
{ {
@@ -69,15 +69,15 @@ public class DatabaseController
SQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated`=" + TCPFrameTimestamp + " WHERE `pe_DataPlayers_ucid`='" + TCPFrame.payload.stat_ucid + "';"; SQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated`=" + TCPFrameTimestamp + " WHERE `pe_DataPlayers_ucid`='" + TCPFrame.payload.stat_ucid + "';";
SQLQueryTxt += "INSERT INTO `pe_DataTypes` (`pe_DataTypes_name`) SELECT '" + TCPFrame.payload.stat_data_type + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "');"; SQLQueryTxt += "INSERT INTO `pe_DataTypes` (`pe_DataTypes_name`) SELECT '" + TCPFrame.payload.stat_data_type + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "');";
SQLQueryTxt += "INSERT INTO `pe_LogStats` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`,`pe_LogStats_typeid`) SELECT (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "'), (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "') FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_LogStats` WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`= (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "'));"; SQLQueryTxt += "INSERT INTO `pe_LogStats` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`,`pe_LogStats_typeid`) SELECT (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "'), (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "') FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_LogStats` WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`= (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "'));";
SQLQueryTxt += "UPDATE `pe_LogStats` SET `ps_time`=" + TCPFrame.payload.stat_data_perun.ps_time + ",`pe_LogStats_seat`=" + TCPFrame.payload.stat_data_subslot + ",`pe_LogStats_masterslot`=" + TCPFrame.payload.stat_data_masterslot + ",`ps_kills_fortification`=" + TCPFrame.payload.stat_data_perun.ps_kills_fortification + ",`ps_other_landings`=" + TCPFrame.payload.stat_data_perun.ps_other_landings + ",`ps_other_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_other_takeoffs + ",`ps_pvp`=" + TCPFrame.payload.stat_data_perun.ps_pvp + ",`ps_deaths`=" + TCPFrame.payload.stat_data_perun.ps_deaths + ",`ps_ejections`=" + TCPFrame.payload.stat_data_perun.ps_ejections + ",`ps_crashes`=" + TCPFrame.payload.stat_data_perun.ps_crashes + ",`ps_teamkills`=" + TCPFrame.payload.stat_data_perun.ps_teamkills + ",`ps_kills_planes`=" + TCPFrame.payload.stat_data_perun.ps_kills_planes + ",`ps_kills_helicopters`=" + TCPFrame.payload.stat_data_perun.ps_kills_helicopters + ",`ps_kills_air_defense`=" + TCPFrame.payload.stat_data_perun.ps_kills_air_defense + ",`ps_kills_armor`=" + TCPFrame.payload.stat_data_perun.ps_kills_armor + ",`ps_kills_unarmed`=" + TCPFrame.payload.stat_data_perun.ps_kills_unarmed + ",`ps_kills_infantry`=" + TCPFrame.payload.stat_data_perun.ps_kills_infantry + ",`ps_kills_ships`=" + TCPFrame.payload.stat_data_perun.ps_kills_ships + ",`ps_kills_other`=" + TCPFrame.payload.stat_data_perun.ps_kills_other + ",`ps_airfield_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_airfield_takeoffs + ",`ps_airfield_landings`=" + TCPFrame.payload.stat_data_perun.ps_airfield_landings + ",`ps_ship_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_ship_takeoffs + ",`ps_ship_landings`=" + TCPFrame.payload.stat_data_perun.ps_ship_landings + ",`ps_farp_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_farp_takeoffs + ",`ps_farp_landings`=" + TCPFrame.payload.stat_data_perun.ps_farp_landings + ", `pe_LogStats_datetime`='" + TCPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`=(SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "');"; SQLQueryTxt += "UPDATE `pe_LogStats` SET `ps_time`=" + TCPFrame.payload.stat_data_perun.ps_time + ",`pe_LogStats_seat`=" + TCPFrame.payload.stat_data_subslot + ",`pe_LogStats_masterslot`=" + TCPFrame.payload.stat_data_masterslot + ",`ps_kills_fortification`=" + TCPFrame.payload.stat_data_perun.ps_kills_fortification +",`ps_kills_artillery`=" + TCPFrame.payload.stat_data_perun.ps_kills_artillery + ",`ps_other_landings`=" + TCPFrame.payload.stat_data_perun.ps_other_landings + ",`ps_other_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_other_takeoffs + ",`ps_pvp`=" + TCPFrame.payload.stat_data_perun.ps_pvp + ",`ps_deaths`=" + TCPFrame.payload.stat_data_perun.ps_deaths + ",`ps_ejections`=" + TCPFrame.payload.stat_data_perun.ps_ejections + ",`ps_crashes`=" + TCPFrame.payload.stat_data_perun.ps_crashes + ",`ps_teamkills`=" + TCPFrame.payload.stat_data_perun.ps_teamkills + ",`ps_kills_planes`=" + TCPFrame.payload.stat_data_perun.ps_kills_planes + ",`ps_kills_helicopters`=" + TCPFrame.payload.stat_data_perun.ps_kills_helicopters + ",`ps_kills_air_defense`=" + TCPFrame.payload.stat_data_perun.ps_kills_air_defense + ",`ps_kills_armor`=" + TCPFrame.payload.stat_data_perun.ps_kills_armor + ",`ps_kills_unarmed`=" + TCPFrame.payload.stat_data_perun.ps_kills_unarmed + ",`ps_kills_infantry`=" + TCPFrame.payload.stat_data_perun.ps_kills_infantry + ",`ps_kills_ships`=" + TCPFrame.payload.stat_data_perun.ps_kills_ships + ",`ps_kills_other`=" + TCPFrame.payload.stat_data_perun.ps_kills_other + ",`ps_airfield_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_airfield_takeoffs + ",`ps_airfield_landings`=" + TCPFrame.payload.stat_data_perun.ps_airfield_landings + ",`ps_ship_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_ship_takeoffs + ",`ps_ship_landings`=" + TCPFrame.payload.stat_data_perun.ps_ship_landings + ",`ps_farp_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_farp_takeoffs + ",`ps_farp_landings`=" + TCPFrame.payload.stat_data_perun.ps_farp_landings + ", `pe_LogStats_datetime`='" + TCPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`=(SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "');";
} }
else if (TCPFrameType == "53") else if (TCPFrameType == "53")
{ {
// User logged in to DCS server // User logged in to DCS server
SQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.login_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where pe_DataPlayers_ucid='" + TCPFrame.payload.login_ucid + "');"; SQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.login_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where pe_DataPlayers_ucid='" + TCPFrame.payload.login_ucid + "');";
SQLQueryTxt += "UPDATE `pe_DataPlayers` SET pe_DataPlayers_lastip='" + TCPFrame.payload.login_ipaddr + "', pe_DataPlayers_lastname='" + TCPFrame.payload.login_name + "',pe_DataPlayers_updated='" + TCPFrame.payload.login_datetime + "' WHERE `pe_DataPlayers_ucid`= '" + TCPFrame.payload.login_ucid + "';"; SQLQueryTxt += "UPDATE `pe_DataPlayers` SET pe_DataPlayers_lastip='" + TCPFrame.payload.login_ipaddr + "', pe_DataPlayers_lastname=@PAR_login_name,pe_DataPlayers_updated='" + TCPFrame.payload.login_datetime + "' WHERE `pe_DataPlayers_ucid`= '" + TCPFrame.payload.login_ucid + "';";
SQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`,`pe_LogLogins_instance`) VALUES ('" + TCPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + TCPFrame.payload.login_ucid + "'), '" + TCPFrame.payload.login_name + "', '" + TCPFrame.payload.login_ipaddr + "','" + TCPFrameInstance + "');"; SQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`,`pe_LogLogins_instance`) VALUES ('" + TCPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + TCPFrame.payload.login_ucid + "'), @PAR_login_name, '" + TCPFrame.payload.login_ipaddr + "','" + TCPFrameInstance + "');";
} }
else if (TCPFrameType == "-1") else if (TCPFrameType == "-1")
{ {
@@ -87,12 +87,44 @@ public class DatabaseController
else else
{ {
// General definition used for 1-10 type packets // General definition used for 1-10 type packets
TCPFramePayload = JsonConvert.SerializeObject(TCPFrame.payload); // Deserialize payload
SQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`,`pe_dataraw_instance`) SELECT '" + TCPFrameType + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE `pe_dataraw_type` = '" + TCPFrameType + "' AND `pe_dataraw_instance` = " + TCPFrameInstance + ");"; SQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`,`pe_dataraw_instance`) SELECT '" + TCPFrameType + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE `pe_dataraw_type` = '" + TCPFrameType + "' AND `pe_dataraw_instance` = " + TCPFrameInstance + ");";
SQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = JSON_QUOTE('" + TCPFramePayload + "'), `pe_dataraw_updated`=" + TCPFrameTimestamp + " WHERE `pe_dataraw_type`=" + TCPFrameType + " AND `pe_dataraw_instance` = " + TCPFrameInstance + ";"; 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 // Connect to mysql and execute sql
try try
{ {
@@ -104,7 +136,29 @@ public class DatabaseController
DatabaseConnection.Open(); DatabaseConnection.Open();
DatabaseStatus = true; DatabaseStatus = true;
MySqlCommand DatabaseCommand = new MySqlCommand(SQLQueryTxt, DatabaseConnection); MySqlCommand DatabaseCommand = new MySqlCommand(SQLQueryTxt, DatabaseConnection);
MySqlDataReader DatabaseReader = DatabaseCommand.ExecuteReader();
// Add parameters - prevent SQL injection
if (TCPFrameType == "50")
{
DatabaseCommand.Parameters.AddWithValue("@PAR_payload_player", TCPFrame.payload.player);
DatabaseCommand.Parameters.AddWithValue("@PAR_payload_msg", TCPFrame.payload.msg);
}
else if (TCPFrameType == "51")
{
DatabaseCommand.Parameters.AddWithValue("@PAR_log_content", TCPFrame.payload.log_content);
}
else if (TCPFrameType == "53")
{
DatabaseCommand.Parameters.AddWithValue("@PAR_login_name", TCPFrame.payload.login_name);
}
else
{
TCPFramePayload = JsonConvert.SerializeObject(TCPFrame.payload); // Deserialize payload
DatabaseCommand.Parameters.AddWithValue("@PAR_TCPFramePayload", TCPFramePayload);
}
// End of add parameters
MySqlDataReader DatabaseReader = DatabaseCommand.ExecuteReader();
if (DatabaseReader.HasRows) if (DatabaseReader.HasRows)
{ {

View File

@@ -77,6 +77,7 @@
this.con_img_dcs = new System.Windows.Forms.PictureBox(); this.con_img_dcs = new System.Windows.Forms.PictureBox();
this.con_img_db = new System.Windows.Forms.PictureBox(); this.con_img_db = new System.Windows.Forms.PictureBox();
this.con_Button_Add_Marker = new System.Windows.Forms.Button(); this.con_Button_Add_Marker = new System.Windows.Forms.Button();
this.TIM_Autostart = new System.Windows.Forms.Timer(this.components);
this.con_GroupBox_1.SuspendLayout(); this.con_GroupBox_1.SuspendLayout();
this.con_GroupBox_2.SuspendLayout(); this.con_GroupBox_2.SuspendLayout();
this.con_GroupBox_3.SuspendLayout(); this.con_GroupBox_3.SuspendLayout();
@@ -524,6 +525,10 @@
this.con_Button_Add_Marker.UseVisualStyleBackColor = true; this.con_Button_Add_Marker.UseVisualStyleBackColor = true;
this.con_Button_Add_Marker.Click += new System.EventHandler(this.con_Button_Add_Marker_Click); this.con_Button_Add_Marker.Click += new System.EventHandler(this.con_Button_Add_Marker_Click);
// //
// TIM_Autostart
//
this.TIM_Autostart.Interval = 500;
//
// form_Main // form_Main
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -573,7 +578,10 @@
((System.ComponentModel.ISupportInitialize)(this.con_img_db)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.con_img_db)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
// TIM_Autostart
//
this.TIM_Autostart.Tick += new System.EventHandler(this.TIM_Autostart_Tick);
//
} }
#endregion #endregion
@@ -625,6 +633,7 @@
private System.Windows.Forms.Label label13; private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14; private System.Windows.Forms.Label label14;
private System.Windows.Forms.Button con_Button_Add_Marker; private System.Windows.Forms.Button con_Button_Add_Marker;
private System.Windows.Forms.Timer TIM_Autostart;
} }
} }

View File

@@ -37,7 +37,10 @@ namespace Perun_v1
// Get argument server port // Get argument server port
if (args[1] != null) 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) if (args.Length > 2)
@@ -45,16 +48,23 @@ namespace Perun_v1
// Get argument instance id // Get argument instance id
if (args[2] != null) 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) if (args.Length > 3)
{ {
// Get argument DCS SRS file path // Get argument DCS SRS file path
if (args[3] != null) if (args[3] != null)
{ {
con_txt_3rd_srs.Text = args[3]; if (args[3] != "-1")
con_check_3rd_srs.Checked = true; {
con_txt_3rd_srs.Text = args[3];
con_check_3rd_srs.Checked = true;
}
} }
} }
if (args.Length > 4) if (args.Length > 4)
@@ -62,8 +72,27 @@ namespace Perun_v1
// Get argument lotATC file path // Get argument lotATC file path
if (args[4] != null) if (args[4] != null)
{ {
con_txt_3rd_lotatc.Text = args[4]; if (args[4] != "-1")
con_check_3rd_lotatc.Checked = true; {
con_txt_3rd_lotatc.Text = args[4];
con_check_3rd_lotatc.Checked = true;
}
}
}
if (args.Length > 5)
{
// Get argument lotATC file path
if (args[5] != null)
{
if (args[5] == "1")
{
if (args[5] != "-1")
{
TIM_Autostart.Enabled = true;
PerunHelper.AddLog(ref Globals.AppLogHistory, "Autostart parameter provided", 0, 1);
}
}
} }
} }
@@ -183,7 +212,7 @@ namespace Perun_v1
DatabaseConnection.DatabaseConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text; DatabaseConnection.DatabaseConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
// Start listening // Start listening
PerunHelper.AddLog(ref Globals.AppLogHistory, "Opening connections",0,1); PerunHelper.AddLog(ref Globals.AppLogHistory, "Opening connections", 0, 1);
TCPServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.AppLogHistory, ref DatabaseSendBuffer); TCPServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.AppLogHistory, ref DatabaseSendBuffer);
TCPServer.thrTCPListener = new Thread(TCPServer.StartListen); TCPServer.thrTCPListener = new Thread(TCPServer.StartListen);
TCPServer.thrTCPListener.Start(); TCPServer.thrTCPListener.Start();
@@ -197,13 +226,14 @@ namespace Perun_v1
// Send initial data // Send initial data
Tim_MySQL_Tick(null, null); Tim_MySQL_Tick(null, null);
tim_3rdparties_Tick(null, null); tim_3rdparties_Tick(null, null);
TIM_Autostart.Enabled = false;
} }
private void con_Button_Listen_OFF_Click(object sender, EventArgs e) private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
{ {
// Stop listening // Stop listening
// Prepare GUI // Prepare GUI
PerunHelper.AddLog(ref Globals.AppLogHistory, "Closing connections",0,1); PerunHelper.AddLog(ref Globals.AppLogHistory, "Closing connections", 0, 1);
con_Button_Listen_OFF.Enabled = false; con_Button_Listen_OFF.Enabled = false;
Tim_GUI_Tick(null, null); Tim_GUI_Tick(null, null);
this.Refresh(); this.Refresh();
@@ -239,7 +269,7 @@ namespace Perun_v1
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
// Display information about closed connections // Display information about closed connections
PerunHelper.AddLog(ref Globals.AppLogHistory, "Connections closed",0,1); PerunHelper.AddLog(ref Globals.AppLogHistory, "Connections closed", 0, 1);
Tim_GUI_Tick(null, null); Tim_GUI_Tick(null, null);
// Set title bar // Set title bar
@@ -483,9 +513,9 @@ namespace Perun_v1
// Send ping to check for possible connection issues // Send ping to check for possible connection issues
DatabaseConnection.SendToMySql("", true); DatabaseConnection.SendToMySql("", true);
if (PerunHelper.CheckVersions()==0) if (PerunHelper.CheckVersions() == 0)
{ {
MessageBox.Show("Version mismatch detected - please check log files and update.\n\nPerun will now terminate.", "Perun ERROR!",MessageBoxButtons.OK,MessageBoxIcon.Error); MessageBox.Show("Version mismatch detected - please check log files and update.\n\nPerun will now terminate.", "Perun ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
con_Button_Listen_OFF_Click(null, null); con_Button_Listen_OFF_Click(null, null);
} }
@@ -515,25 +545,12 @@ namespace Perun_v1
int temp = raw_lotatc.Clients[i].RadioInfo.radios.Count - 1; int temp = raw_lotatc.Clients[i].RadioInfo.radios.Count - 1;
for (int j = temp; j >= 0; j--) for (int j = temp; j >= 0; j--)
{ {
raw_lotatc.Clients[i].RadioInfo.radios[j].enc.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].encKey.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].encMode.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].freqMax.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].freqMin.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].modulation.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].freqMode.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].volMode.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].expansion.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].channel.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.radios[j].simul.Parent.Remove();
if (raw_lotatc.Clients[i].RadioInfo.radios[j].name == "No Radio") if (raw_lotatc.Clients[i].RadioInfo.radios[j].name == "No Radio")
{ {
raw_lotatc.Clients[i].RadioInfo.radios[j].Remove(); raw_lotatc.Clients[i].RadioInfo.radios[j].Remove();
} }
} }
raw_lotatc.Clients[i].ClientChannelId.Parent.Remove();
raw_lotatc.Clients[i].RadioInfo.simultaneousTransmission.Parent.Remove();
} }
} }
@@ -622,7 +639,7 @@ namespace Perun_v1
Globals.AppForceIconReload = true; Globals.AppForceIconReload = true;
// Add information // Add information
PerunHelper.AddLog(ref Globals.AppLogHistory, "Resetted error counter",0,1); PerunHelper.AddLog(ref Globals.AppLogHistory, "Resetted error counter", 0, 1);
} }
else if (dialogResult == DialogResult.No) else if (dialogResult == DialogResult.No)
{ {
@@ -634,7 +651,14 @@ namespace Perun_v1
private void con_Button_Add_Marker_Click(object sender, EventArgs e) private void con_Button_Add_Marker_Click(object sender, EventArgs e)
{ {
// Added user marker // Added user marker
PerunHelper.AddLog(ref Globals.AppLogHistory, "User Marker",0,1); PerunHelper.AddLog(ref Globals.AppLogHistory, "User Marker", 0, 1);
}
private void TIM_Autostart_Tick(object sender, EventArgs e)
{
// Handle autostart parameter from command line
TIM_Autostart.Enabled = false; // Disable timer
con_Button_Listen_ON_Click(sender,e); // Simulate button click
} }
} }
} }

View File

@@ -419,6 +419,9 @@
<metadata name="tim_MySQL.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="tim_MySQL.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>687, 19</value> <value>687, 19</value>
</metadata> </metadata>
<metadata name="TIM_Autostart.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>800, 4</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>26</value> <value>26</value>
</metadata> </metadata>

View File

@@ -31,8 +31,8 @@
<PublisherName>szporwolik</PublisherName> <PublisherName>szporwolik</PublisherName>
<SuiteName>Perun</SuiteName> <SuiteName>Perun</SuiteName>
<WebPage>Perun.htm</WebPage> <WebPage>Perun.htm</WebPage>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>0.9.2.%2a</ApplicationVersion> <ApplicationVersion>0.11.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
@@ -48,6 +48,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>SecurityRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>SecurityRules.ruleset</CodeAnalysisRuleSet>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -86,6 +87,28 @@
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest> <ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>SecurityRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942"> <Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll</HintPath> <HintPath>..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll</HintPath>

View File

@@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Szymon Porwolik")] [assembly: AssemblyCompany("Szymon Porwolik")]
[assembly: AssemblyProduct("Perun for DCS World")] [assembly: AssemblyProduct("Perun for DCS World")]
[assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyCopyright("Copyright © 2019-2020")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@@ -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 // 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: // przy użyciu symbolu „*”, tak jak pokazano poniżej:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.2.0")] [assembly: AssemblyVersion("0.11.1.0")]
[assembly: AssemblyFileVersion("0.9.2.0")] [assembly: AssemblyFileVersion("0.11.1.0")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]

View File

@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `pe_Config` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `pe_Config` (`pe_Config_id`, `pe_Config_payload`) VALUES INSERT INTO `pe_Config` (`pe_Config_id`, `pe_Config_payload`) VALUES
(1, 'v0.9.2'); (1, 'v0.11.1');
DROP TABLE IF EXISTS `pe_DataMissionHashes`; DROP TABLE IF EXISTS `pe_DataMissionHashes`;
CREATE TABLE IF NOT EXISTS `pe_DataMissionHashes` ( CREATE TABLE IF NOT EXISTS `pe_DataMissionHashes` (
@@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `pe_DataMissionHashes` (
PRIMARY KEY (`pe_DataMissionHashes_id`), PRIMARY KEY (`pe_DataMissionHashes_id`),
UNIQUE KEY `UNIQUE_hash` (`pe_DataMissionHashes_hash`), UNIQUE KEY `UNIQUE_hash` (`pe_DataMissionHashes_hash`),
KEY `pe_DataMissionHashes_instance` (`pe_DataMissionHashes_instance`) KEY `pe_DataMissionHashes_instance` (`pe_DataMissionHashes_instance`)
ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `pe_DataPlayers`; DROP TABLE IF EXISTS `pe_DataPlayers`;
CREATE TABLE IF NOT EXISTS `pe_DataPlayers` ( CREATE TABLE IF NOT EXISTS `pe_DataPlayers` (
@@ -41,7 +41,6 @@ CREATE TABLE IF NOT EXISTS `pe_DataPlayers` (
UNIQUE KEY `UNIQUE_UCID` (`pe_DataPlayers_ucid`) UNIQUE KEY `UNIQUE_UCID` (`pe_DataPlayers_ucid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `pe_DataRaw`; DROP TABLE IF EXISTS `pe_DataRaw`;
CREATE TABLE IF NOT EXISTS `pe_DataRaw` ( CREATE TABLE IF NOT EXISTS `pe_DataRaw` (
`pe_dataraw_type` tinyint(4) NOT NULL, `pe_dataraw_type` tinyint(4) NOT NULL,
@@ -115,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `pe_LogStats` (
`pe_LogStats_playerid` bigint(20) DEFAULT NULL, `pe_LogStats_playerid` bigint(20) DEFAULT NULL,
`pe_LogStats_typeid` int(11) DEFAULT NULL, `pe_LogStats_typeid` int(11) DEFAULT NULL,
`pe_LogStats_masterslot` int(11) DEFAULT NULL, `pe_LogStats_masterslot` int(11) DEFAULT NULL,
`pe_LogStats_seat` int(10) UNSIGNED DEFAULT NULL, `pe_LogStats_seat` int(10) DEFAULT NULL,
`ps_kills_X` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_kills_X` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_pvp` 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_deaths` int(11) UNSIGNED NOT NULL DEFAULT '0',
@@ -130,6 +129,7 @@ CREATE TABLE IF NOT EXISTS `pe_LogStats` (
`ps_kills_infantry` int(11) UNSIGNED NOT NULL DEFAULT '0', `ps_kills_infantry` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_kills_ships` 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_fortification` 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_kills_other` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_airfield_takeoffs` 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', `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_mstatus` (`pe_LogStats_mstatus`),
KEY `pe_LogStats_seat` (`pe_LogStats_seat`) KEY `pe_LogStats_seat` (`pe_LogStats_seat`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TRIGGER IF EXISTS `pe_LogStats_UPDATE`; DROP TRIGGER IF EXISTS `pe_LogStats_UPDATE`;
DELIMITER $$ DELIMITER $$
CREATE TRIGGER `pe_LogStats_UPDATE` BEFORE UPDATE ON `pe_LogStats` FOR EACH ROW BEGIN CREATE TRIGGER `pe_LogStats_UPDATE` BEFORE UPDATE ON `pe_LogStats` FOR EACH ROW BEGIN
@@ -173,6 +172,32 @@ END
$$ $$
DELIMITER ; DELIMITER ;
DROP TABLE IF EXISTS `pe_OnlinePlayers`;
CREATE TABLE IF NOT EXISTS `pe_OnlinePlayers` (
`pe_OnlinePlayers_id` int(11) NOT NULL,
`pe_OnlinePlayers_instance` int(11) NOT NULL,
`pe_OnlinePlayers_ping` int(11) DEFAULT NULL,
`pe_OnlinePlayers_side` int(11) DEFAULT NULL,
`pe_OnlinePlayers_slot` varchar(255) DEFAULT NULL,
`pe_OnlinePlayers_ucid` varchar(255) DEFAULT NULL,
`pe_OnlinePlayers_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `pe_OnlineStatus`;
CREATE TABLE IF NOT EXISTS `pe_OnlineStatus` (
`pe_OnlineStatus_instance` int(11) NOT NULL,
`pe_OnlineStatus_theatre` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_name` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_pause` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_multiplayer` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_realtime` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_modeltime` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_players` int(11) DEFAULT NULL,
`pe_OnlineStatus_perunversion_winapp` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_perunversion_dcshook` varchar(255) DEFAULT NULL,
`pe_OnlineStatus_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `pe_DataMissionHashes` ADD FULLTEXT KEY `pe_DataMissionHashes_hash` (`pe_DataMissionHashes_hash`); ALTER TABLE `pe_DataMissionHashes` ADD FULLTEXT KEY `pe_DataMissionHashes_hash` (`pe_DataMissionHashes_hash`);

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

View File

@@ -0,0 +1,183 @@
<!-- This is integration example for https://github.com/szporwolik/perun - please keep the code as simple and straightforward as possible -->
<!DOCTYPE html>
<html>
<head>
<title>Perun - Example of PHP Integration</title>
<meta charset="utf-8">
<meta name="description" content="Example of PHP integration of Perun for DCS World">
<meta name="keywords" content="dcs world perun">
<meta name="author" content="VladMordock">
<style>
body {
background-color: #eeeeee;
padding: 0 20px 0 20px;
}
h1,h2,h3 {
color: navy;
}
#header{
padding: 10px 0 10px 0px;
}
#content{
border-top: 1px solid navy;
border-bottom: 1px solid navy;
padding: 10px 0 10px 0px;
}
#footer{
padding: 10px 0 10px 0px;
text-align: right;
}
table, td{
border: 1px solid navy;
}
</style>
</head>
<body>
<div id="header">
<h1>Perun Integration Example</h2>
<h2>PHP Integration example for Perun for DCS World</h2>
<h3>Get support at our <a href="https://discord.gg/MTahREx">Discord</a>
</div>
<div id="content">
<?php
// Configure database connection - put your database address and credentials here
$config_db_username="CHANGE_ME"; // <<=== CHANGE TO YOUR MYSQL SERVER USERNAME
$config_db_password="CHANGE_ME"; // <<=== CHANGE TO YOUR MYSQL SERVER PASSWORD
$config_db_host="CHANGE_ME"; // <<=== CHANGE TO YOUR MYSQL SERVER ADDRESS
$config_db_database="CHANGE_ME"; // <<=== CHANGE TO YOUR MYSQL DATABASE
// Try to connect to the database
$mysqli = new mysqli($config_db_host, $config_db_username, $config_db_password, $config_db_database);
// Check connection
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
// Some Examples
// List last 5 missions at the server
echo "<h3>List last 5 missions at the server</h3>";
if ($result = $mysqli->query("SELECT * FROM `pe_DataMissionHashes` ORDER BY `pe_DataMissionHashes`.`pe_DataMissionHashes_datetime` DESC LIMIT 5")) {
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pe_DataMissionHashes_id'] . "</td>";
echo "<td>" . $row['pe_DataMissionHashes_hash'] . "</td>";
echo "<td>" . $row['pe_DataMissionHashes_datetime'] . "</td>";
echo "</tr>";
}
echo "</table>";
$result->close();
}
// List last 5
echo "<h3>List last 5 players known server </h3>";
if ($result = $mysqli->query("SELECT * FROM `pe_DataPlayers` ORDER BY `pe_DataPlayers`.`pe_DataPlayers_updated` DESC LIMIT 5")) {
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pe_DataPlayers_id'] . "</td>";
echo "<td>" . $row['pe_DataPlayers_ucid'] . "</td>";
echo "<td>" . $row['pe_DataPlayers_lastname'] . "</td>";
echo "<td>" . $row['pe_DataPlayers_updated'] . "</td>";
echo "</tr>";
}
echo "</table>";
$result->close();
}
// List last 5 chat messages
echo "<h3>List last 5 chat messages (note: INNER JOIN is used to pull the player's name from other table)</h3>";
if ($result = $mysqli->query("SELECT * FROM `pe_LogChat` INNER JOIN `pe_DataPlayers` on `pe_LogChat`.pe_LogChat_playerid = `pe_DataPlayers`.pe_DataPlayers_id ORDER BY `pe_LogChat`.`pe_LogChat_datetime` DESC LIMIT 5")) {
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pe_LogChat_datetime'] . "</td>";
echo "<td>" . $row['pe_DataPlayers_lastname'] . "</td>";
echo "<td>" . $row['pe_LogChat_msg'] . "</td>";
echo "</tr>";
}
echo "</table>";
$result->close();
}
// List last 5 events
echo "<h3>List last 5 events</h3>";
if ($result = $mysqli->query("SELECT * FROM `pe_LogEvent` ORDER BY `pe_LogEvent_datetime` DESC LIMIT 5")) {
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pe_LogEvent_datetime'] . "</td>";
echo "<td>" . $row['pe_LogEvent_content'] . "</td>";
echo "</tr>";
}
echo "</table>";
$result->close();
}
// List last statistics
echo "<h3>List last statistics (note: multiple INNER JOINs is used to pull information from other table)</h3>";
if ($result = $mysqli->query("SELECT * FROM `pe_LogStats` INNER JOIN `pe_DataMissionHashes` ON `pe_LogStats`.pe_LogStats_missionhash_id = `pe_DataMissionHashes`.pe_DataMissionHashes_id INNER JOIN `pe_DataPlayers` ON `pe_LogStats`.pe_LogStats_playerid = `pe_DataPlayers`.pe_DataPlayers_id INNER JOIN `pe_DataTypes` ON `pe_LogStats`.pe_LogStats_typeid = `pe_DataTypes`.pe_DataTypes_id ORDER BY pe_LogStats_datetime desc LIMIT 5")) {
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pe_LogStats_datetime'] . "</td>";
echo "<td>" . $row['pe_DataPlayers_lastname'] . "</td>";
echo "<td>" . $row['pe_DataTypes_name'] . "</td>";
echo "<td>" . $row['ps_crashes'] . "</td>";
echo "<td>" . $row['ps_kills_planes'] . "</td>";
echo "<td>" . $row['ps_kills_armor'] . "</td>";
// TIP: See documentation there is many more counted events which can be displayed here
echo "<td>" . $row['pe_LogStats_mstatus'] . "</td>";
echo "</tr>";
}
echo "</table>";
$result->close();
}
// Get JSON objects with actual server information including LotATC and DCS SRS information
echo "<h3>Get JSON objects with actual server information including LotATC and DCS SRS information</h3>";
if ($result = $mysqli->query("SELECT * FROM `pe_DataRaw`")) {
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pe_dataraw_updated'] . "</td>";
echo "<td>" . $row['pe_dataraw_payload'] . "</td>";
echo "</tr>";
}
echo "</table>";
$result->close();
}
// Close database connection
$mysqli->close();
?>
</div>
<div id="footer">
<a href="https://github.com/szporwolik/perun">
<img src="https://camo.githubusercontent.com/50a1df184e069b36f3ddf9223bf16582f49aa16c/68747470733a2f2f692e696d6775722e636f6d2f5072496b714e412e706e67" alt="Perun_Logo">
</a>
</div>
</body>
</html>

View File

@@ -2,8 +2,9 @@
![alt text](https://img.shields.io/github/license/szporwolik/perun.svg "MIT") ![alt text](https://img.shields.io/github/license/szporwolik/perun.svg "MIT")
![alt text](https://img.shields.io/github/release-pre/szporwolik/perun.svg "Latest release") ![alt text](https://img.shields.io/github/release-pre/szporwolik/perun.svg "Latest release")
![alt text](https://img.shields.io/github/release-date-pre/szporwolik/perun.svg "Latest release date") ![alt text](https://img.shields.io/github/release-date-pre/szporwolik/perun.svg "Latest release date")
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ZBW8R5L25A8QW&currency_code=EUR&source=url)
![Perun logo](https://i.imgur.com/JkeHYjJ.png) ![Perun logo](https://i.imgur.com/PrIkqNA.png)
# Perun for DCS World # Perun for DCS World
Included lua script extracts data from DCS World multiplayer server and sends information to TCP port for further processing. Included lua script extracts data from DCS World multiplayer server and sends information to TCP port for further processing.
@@ -30,10 +31,11 @@ Core:
* Download latest [release](https://github.com/szporwolik/perun/releases) * Download latest [release](https://github.com/szporwolik/perun/releases)
* Copy contents of [01_DCS](https://github.com/szporwolik/perun/tree/master/01_DCS) to your \Scripts folder (located inside DCS folder in your Saved Games) * Copy contents of [01_DCS](https://github.com/szporwolik/perun/tree/master/01_DCS) to your \Scripts folder (located inside DCS folder in your Saved Games)
* Create MySQL database using SQL script located in [03_MySQL](https://github.com/szporwolik/perun/tree/master/03_MySQL); note that you need just a one database per DCS server machine - multiple instances pushing data to the one database are supported * Create MySQL database using SQL script located in [03_MySQL](https://github.com/szporwolik/perun/tree/master/03_MySQL); note that you need just a one database per DCS server machine - multiple instances pushing data to the one database are supported
* Ensure that your MySQL config is not using STRICT_TRANS_TABLES
## Running ## Running
* Start DCS World and host multiplayer session * Start DCS World and host multiplayer session
* by default the TCP port 48620 is in use as target port - ensure that port and instance ID in the options sections of the Lua file matches data * by default the TCP port 48621 is in use as target port - ensure that port and instance ID in the options sections of the Lua file matches data
* run the Win32 application * run the Win32 application
* set MySQL connection data * set MySQL connection data
* **optionaly** point LotATC json file location * **optionaly** point LotATC json file location
@@ -47,8 +49,9 @@ Windows app supports command line arguments, what may be handy in case of multip
The following arguments are accepted (keep the order!): The following arguments are accepted (keep the order!):
* server port (shall be the same as in the lua file!) * server port (shall be the same as in the lua file!)
* instance ID (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 SRS client-list.json OR put -1 if you do not want to use DCS SRS
* path to LotATC stats.json * 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: Example for windows shortcut:
``` ```
@@ -60,6 +63,8 @@ Data displaying and handling is not in the current scope of this project. Since
![Mission statistics](https://i.imgur.com/uiRSa9e.png) ![Mission statistics](https://i.imgur.com/uiRSa9e.png)
Due to resource limitations, "Perun for DCS World" will focus on pulling the data from DCS (and external modules) and pushing it to MySQL server, but if anyone would like to develop open sourced PHP applets for data/statistics displaying we're willing to cooperate and support such projects. Unfortunetly it's not possible to share the hardcoded code from forum.gildia.org. Due to resource limitations, "Perun for DCS World" will focus on pulling the data from DCS (and external modules) and pushing it to MySQL server, but if anyone would like to develop open sourced PHP applets for data/statistics displaying we're willing to cooperate and support such projects. Unfortunetly it's not possible to share the hardcoded code from forum.gildia.org.
Basic example was provided [HERE](/04_Misc/05_PHP_Example/index.php) , support is available via Perun community at our [Discord](https://discord.gg/MTahREx).
## Troubleshooting - FAQ ## Troubleshooting - FAQ
- [I keep getting 1305 MySQL error](#i-keep-getting-1305-mysql-error) - [I keep getting 1305 MySQL error](#i-keep-getting-1305-mysql-error)
- [Carrier landing are not tracked correctly](#carrier-landing-are-not-tracked-correctly) - [Carrier landing are not tracked correctly](#carrier-landing-are-not-tracked-correctly)
@@ -83,6 +88,10 @@ DCS API does not track carrier or FARP operations natively, so there is a trick
* table: pe_LogEvent - holds event history * table: pe_LogEvent - holds event history
* table: pe_LogLogins - holds login to server event history * table: pe_LogLogins - holds login to server event history
* table: pe_LogStats - holds static information * table: pe_LogStats - holds static information
* table: pe_OnlinePlayers - holds the list of actual players connected to the server
* table: pe_OnlineStatus - holds the information about server status of all instantes
![Database Scheme](https://i.imgur.com/zJsFxV0.png "MIT")
## Data packets - send from lua to TCP port ## Data packets - send from lua to TCP port
* ```ID: 1```, contains version/diagnostic information * ```ID: 1```, contains version/diagnostic information
@@ -127,7 +136,13 @@ See also the list of [contributors](https://github.com/szporwolik/perun/contribu
## License ## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
## Donation
This software is provide "as it is" without any warranties, but if you would like to thank me for development/support please
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ZBW8R5L25A8QW&currency_code=EUR&source=url)
## Acknowledgments ## Acknowledgments
![Gildia.org Logo](https://images.weserv.nl/?url=https://i.imgur.com/nFHxQMy.png&w=140&il) ![Gildia.org Logo](https://images.weserv.nl/?url=https://i.imgur.com/nFHxQMy.png&w=140&il)
Thanks to [Gildia DCS](https://forum.gildia.org) Polish community of DCS World pilots. Thanks to [Gildia DCS](https://forum.gildia.org) Polish community of DCS World pilots.
Thanks to our Discord community for all the disussions, tests and proposals!