mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 19:55:40 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f49734560e | ||
|
|
5d3f7148bb | ||
|
|
2629295f93 | ||
|
|
a6ad17dbe1 | ||
|
|
b7022c22c1 | ||
|
|
907d8d01d6 | ||
|
|
fc82c43072 | ||
|
|
37b6f3419e | ||
|
|
b96affd4fd | ||
|
|
8d733f83ab | ||
|
|
58cc8a7b39 | ||
|
|
e09926aa80 | ||
|
|
13969a95cc | ||
|
|
5c9fa4e284 | ||
|
|
3512f7f5cf | ||
|
|
6847a1e262 | ||
|
|
c917d0ef04 | ||
|
|
784ad9947f | ||
|
|
91c629ed81 | ||
|
|
5d415812fa |
@@ -7,7 +7,8 @@
|
||||
|
||||
-- ########### SETTINGS ###########
|
||||
|
||||
Perun.Refresh = 15 -- base refresh rate in secounds (values lower than 60 may affect performance!)
|
||||
Perun.RefreshStatus = 15 -- base refresh rate in seconds to send status update (values lower than 60 may affect performance!)
|
||||
Perun.RefreshMission = 60 -- refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
|
||||
Perun.JsonLocation = "Scripts\\Json\\perun_export.json" -- relatve do user's SaveGames DCS folder
|
||||
Perun.UDPTargetPort = 48620 -- UDP port to send data to
|
||||
Perun.MOTD_L1 = "Witamy na serwerze Gildia.org !" -- Message send to players connecting the server - Line 1
|
||||
@@ -16,11 +17,14 @@
|
||||
-- ########### END OF SETTINGS ###########
|
||||
|
||||
-- Variable init
|
||||
Perun.Version = "v0.3.0"
|
||||
Perun.Version = "v0.3.5"
|
||||
Perun.StatusData = {}
|
||||
Perun.SlotsData = {}
|
||||
Perun.MissionData = {}
|
||||
Perun.VersionData = {}
|
||||
Perun.lastSent =0
|
||||
Perun.MissionHash=""
|
||||
Perun.lastSentStatus =0
|
||||
Perun.lastSentMission =0
|
||||
Perun.JsonLocation = lfs.writedir() .. Perun.JsonLocation
|
||||
Perun.socket = require("socket")
|
||||
Perun.UDP = assert(Perun.socket.udp())
|
||||
@@ -29,6 +33,33 @@
|
||||
Perun.UDP:setpeername("127.0.0.1",Perun.UDPTargetPort)
|
||||
|
||||
-- Function definition
|
||||
Perun.GetCategory = function(id)
|
||||
-- via https://pastebin.com/GUAXrd2U
|
||||
local _killed_target_category = DCS.getUnitTypeAttribute(id, "category")
|
||||
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
|
||||
end
|
||||
|
||||
Perun.SideID2Name = function(id)
|
||||
-- Helper function
|
||||
local sides = {
|
||||
[0] = 'SPECTATOR',
|
||||
[1] = 'RED',
|
||||
[2] = 'BLUE',
|
||||
}
|
||||
return sides[id]
|
||||
end
|
||||
|
||||
Perun.AddLog = function(text)
|
||||
-- Adds logs to DCS.log file
|
||||
net.log("Perun : ".. text)
|
||||
@@ -40,6 +71,8 @@
|
||||
TempData["1"]=Perun.VersionData
|
||||
TempData["2"]=Perun.StatusData
|
||||
TempData["3"]=Perun.SlotsData
|
||||
TempData["4"]=Perun.MissionData
|
||||
TempData["debug"]=net.get_player_list()
|
||||
|
||||
io.open(Perun.JsonLocation,"w"):close()
|
||||
perun_export = io.open(Perun.JsonLocation, "w")
|
||||
@@ -84,23 +117,26 @@
|
||||
temp['realtime']=DCS.getRealTime()
|
||||
temp['pause']=DCS.getPause()
|
||||
temp['multiplayer']=DCS.isMultiplayer()
|
||||
temp['theatre'] = Perun.MissionData['mission']['theatre']
|
||||
temp['weather'] = Perun.MissionData['mission']['weather']
|
||||
Perun.UpdateStatusPart("mission",temp)
|
||||
|
||||
-- 2 - Players
|
||||
temp = net.get_player_list()
|
||||
for _, i in ipairs(temp) do
|
||||
temp[i]=net.get_player_info(i)
|
||||
_temp = net.get_player_list()
|
||||
_temp2={}
|
||||
for _, i in pairs(_temp) do
|
||||
_temp2[i]=net.get_player_info(i)
|
||||
end
|
||||
Perun.UpdateStatusPart("players",temp)
|
||||
Perun.UpdateStatusPart("players",_temp2)
|
||||
|
||||
-- Send
|
||||
Perun.Send(2,Perun.StatusData)
|
||||
end
|
||||
|
||||
Perun.UpdateMission = function()
|
||||
-- Main function for mission information updates
|
||||
Perun.UpdateSlots = function()
|
||||
-- Main function for slot
|
||||
|
||||
-- Update Mission data
|
||||
-- Update slots data
|
||||
Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions()
|
||||
Perun.SlotsData['slots']={}
|
||||
|
||||
@@ -111,6 +147,16 @@
|
||||
Perun.Send(3,Perun.SlotsData)
|
||||
end
|
||||
|
||||
Perun.UpdateMission = function()
|
||||
-- Main function for mission information updates
|
||||
|
||||
-- Update Mission data
|
||||
Perun.MissionData=DCS.getCurrentMission()
|
||||
|
||||
-- Send
|
||||
-- Perun.Send(4,Perun.MissionData)
|
||||
end
|
||||
|
||||
Perun.LogChat = function(playerID,msg,all)
|
||||
-- Log chat messages
|
||||
|
||||
@@ -118,6 +164,8 @@
|
||||
data['player']= net.get_player_info(playerID, "name")
|
||||
data['msg']=msg
|
||||
data['all']=all
|
||||
data['datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['log_missionhash']=Perun.MissionHash
|
||||
|
||||
Perun.Send(50,data)
|
||||
end
|
||||
@@ -128,20 +176,81 @@
|
||||
data={}
|
||||
data['log_type']= log_type
|
||||
data['log_content']=log_content
|
||||
data['log_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['log_missionhash']=Perun.MissionHash
|
||||
|
||||
Perun.Send(51,data)
|
||||
end
|
||||
|
||||
Perun.LogStats = function(playerID)
|
||||
-- Log player status
|
||||
|
||||
-- TBD : not working at the moment WIP
|
||||
p_stats={}
|
||||
p_stats['PS_CAR']=net.get_stat(playerID,2)
|
||||
p_stats['PS_PLANE']=net.get_stat(playerID,3)
|
||||
p_stats['PS_SHIP']=net.get_stat(playerID,4)
|
||||
p_stats['PS_SCORE']=net.get_stat(playerID,5)
|
||||
p_stats['PS_LAND']=net.get_stat(playerID,6)
|
||||
p_stats['PS_PING']=net.get_stat(playerID,0)
|
||||
p_stats['PS_CRASH']=net.get_stat(playerID,1)
|
||||
p_stats['PS_EJECT']=net.get_stat(playerID,7)
|
||||
p_stats['debug']="ok"
|
||||
|
||||
data={}
|
||||
data['stat_data']=p_stats
|
||||
data['stat_ucid']=net.get_player_info(playerID, 'ucid')
|
||||
data['stat_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['stat_missionhash']=Perun.MissionHash
|
||||
|
||||
Perun.Send(52,data)
|
||||
end
|
||||
|
||||
Perun.LogLogin = function(playerID)
|
||||
-- Player logged in
|
||||
|
||||
data={}
|
||||
data['login_ucid']=net.get_player_info(playerID, 'ucid')
|
||||
data['login_ipaddr']=net.get_player_info(playerID, 'ipaddr')
|
||||
data['login_name']=net.get_player_info(playerID, 'name')
|
||||
data['login_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Perun.Send(53,data)
|
||||
end
|
||||
|
||||
--- Event callbacks
|
||||
|
||||
Perun.onSimulationStart = function()
|
||||
Perun.MissionHash=DCS.getMissionName( ).."@"..os.date('%Y%m%d_%H%M%S');
|
||||
Perun.LogEvent("SimStart",Perun.MissionHash);
|
||||
end
|
||||
|
||||
Perun.onSimulationStop = function()
|
||||
Perun.LogEvent("SimStop",Perun.MissionHash);
|
||||
end
|
||||
|
||||
Perun.onPlayerDisconnect= function(id, err_code)
|
||||
Perun.LogEvent("disconnect", "Player " .. net.get_player_info(id, "name") .. " disconnected; " .. err_code);
|
||||
end
|
||||
|
||||
Perun.onSimulationFrame = function()
|
||||
local _now = DCS.getRealTime()
|
||||
|
||||
if _now > Perun.lastSent + Perun.Refresh then
|
||||
Perun.lastSent = _now
|
||||
-- Send status update
|
||||
if _now > Perun.lastSentStatus + Perun.RefreshStatus then
|
||||
Perun.lastSentStatus = _now
|
||||
|
||||
Perun.UpdateMission()
|
||||
Perun.UpdateStatus()
|
||||
Perun.UpdateVersion()
|
||||
Perun.UpdateJson()
|
||||
end
|
||||
|
||||
-- Send mission update
|
||||
if _now > Perun.lastSentMission + Perun.RefreshMission then
|
||||
Perun.lastSentMission = _now
|
||||
|
||||
Perun.UpdateSlots()
|
||||
Perun.UpdateMission()
|
||||
|
||||
Perun.UpdateJson()
|
||||
end
|
||||
|
||||
@@ -149,6 +258,8 @@
|
||||
|
||||
Perun.onMissionLoadEnd = function()
|
||||
Perun.UpdateMission()
|
||||
Perun.UpdateSlots()
|
||||
Perun.UpdateVersion()
|
||||
Perun.UpdateJson()
|
||||
end
|
||||
|
||||
@@ -158,60 +269,104 @@
|
||||
end
|
||||
|
||||
Perun.onPlayerTrySendChat = function (playerID, msg, all)
|
||||
if msg~=Perun.MOTD_L1 and msg~=Perun.MOTD_L2 then
|
||||
Perun.LogChat(playerID,msg,all)
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4)
|
||||
|
||||
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
|
||||
|
||||
if eventName == "friendly_fire" then
|
||||
--"friendly_fire", playerID, weaponName, victimPlayerID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name").." killed " .. net.get_player_info(arg3, "name") .. " using " .. arg2);
|
||||
Perun.LogEvent(eventName,Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name").." killed friendy " .. net.get_player_info(arg3, "name") .. " using " .. arg2);
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "mission_end" then
|
||||
--"mission_end", winner, msg
|
||||
Perun.LogEvent(eventName,"Mission end, winner " .. arg1 .. " message: " .. arg2);
|
||||
Perun.LogEvent(eventName,"Mission finished, winner " .. arg1 .. " message: " .. arg2);
|
||||
|
||||
elseif eventName == "kill" then
|
||||
--"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name").. " in " .. arg3 .. " " .. arg2 .. " killed " .. net.get_player_info(arg4, "name") .. " in " .. arg6 .. " " .. arg5 .. " using " .. arg7);
|
||||
if net.get_player_info(arg4, "name") ~= nil then
|
||||
_temp = " player ".. net.get_player_info(arg4, "name") .." ";
|
||||
Perun.LogStats(arg4);
|
||||
else
|
||||
_temp = " AI ";
|
||||
end
|
||||
|
||||
if net.get_player_info(arg1, "name") ~= nil then
|
||||
_temp2 = " player ".. net.get_player_info(arg1, "name") .." ";
|
||||
Perun.LogStats(arg1);
|
||||
else
|
||||
_temp2 = " AI ";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName,Perun.SideID2Name(arg3) .. _temp2 .. " in " .. arg2 .. " killed " .. Perun.SideID2Name(arg6) .. _temp .. " in " .. arg5 .. " using " .. arg7 .. " [".. Perun.GetCategory(arg5).."]");
|
||||
|
||||
|
||||
elseif eventName == "self_kill" then
|
||||
--"self_kill", playerID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " killed himself");
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "change_slot" then
|
||||
--"change_slot", playerID, slotID, prevSide
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " changed slot to " .. arg2);
|
||||
|
||||
if DCS.getUnitType(arg2) ~= nil and DCS.getUnitType(arg2) ~= "" then
|
||||
_temp = DCS.getUnitType(arg2);
|
||||
else
|
||||
_temp = "SPECTATOR";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName,Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " changed slot to " .. _temp);
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "connect" then
|
||||
--"connect", playerID, name
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " connected");
|
||||
Perun.LogLogin(arg1);
|
||||
Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected");
|
||||
|
||||
elseif eventName == "disconnect" then
|
||||
--"disconnect", playerID, name, playerSide, reason_code
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " disconnected");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name(arg3) .. " player " ..net.get_player_info(arg1, "name") .. " disconnected");
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "crash" then
|
||||
--"crash", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " crashed");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " crashed in " .. DCS.getUnitType(arg2));
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "eject" then
|
||||
--"eject", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " ejected");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " ejected " .. DCS.getUnitType(arg2));
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "takeoff" then
|
||||
--"takeoff", playerID, unit_missionID, airdromeName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " took off from " .. arg3);
|
||||
if arg3 then
|
||||
_temp = " from " .. arg3;
|
||||
else
|
||||
_temp = "";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " took off in ".. DCS.getUnitType(arg2) .. _temp);
|
||||
Perun.LogStats(arg1);
|
||||
elseif eventName == "landing" then
|
||||
--"landing", playerID, unit_missionID, airdromeName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " landed at " .. arg3);
|
||||
if arg3 then
|
||||
_temp = " at " .. arg3;
|
||||
else
|
||||
_temp ="";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " landed in " .. DCS.getUnitType(arg2).. _temp);
|
||||
Perun.LogStats(arg1);
|
||||
elseif eventName == "pilot_death" then
|
||||
--"pilot_death", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " died");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " in " .. DCS.getUnitType(arg2) .. " died");
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
else
|
||||
Perun.LogEvent(eventName,"Unknown event type");
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="MYSQL_Port" serializeAs="String">
|
||||
<value />
|
||||
<value>3306</value>
|
||||
</setting>
|
||||
</Perun_v1.Properties.Settings>
|
||||
<Perun.Properties.Settings>
|
||||
|
||||
@@ -12,21 +12,30 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>C:\Users\simpo\Desktop\Perun\</PublishUrl>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<PublishUrl>ftp://s18.mydevil.net/perun/</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
<UpdateEnabled>true</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<AutorunEnabled>true</AutorunEnabled>
|
||||
<ApplicationRevision>1</ApplicationRevision>
|
||||
<ApplicationVersion>0.3.0.%2a</ApplicationVersion>
|
||||
<InstallUrl>http://share.porwolik.com/ftp/perun/</InstallUrl>
|
||||
<SupportUrl>https://github.com/szporwolik/perun</SupportUrl>
|
||||
<ErrorReportUrl>https://github.com/szporwolik/perun</ErrorReportUrl>
|
||||
<TargetCulture>en</TargetCulture>
|
||||
<ProductName>Perun for DCS World</ProductName>
|
||||
<PublisherName>szporwolik</PublisherName>
|
||||
<SuiteName>Perun</SuiteName>
|
||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||
<WebPage>Perun.htm</WebPage>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>0.3.5.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
@@ -73,6 +82,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetZone>LocalIntranet</TargetZone>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -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.3.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.3.0.0")]
|
||||
[assembly: AssemblyVersion("0.3.5.0")]
|
||||
[assembly: AssemblyFileVersion("0.3.5.0")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Perun_v1.Properties {
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("3306")]
|
||||
public string MYSQL_Port {
|
||||
get {
|
||||
return ((string)(this["MYSQL_Port"]));
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="MYSQL_Port" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
<Value Profile="(Default)">3306</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -23,6 +23,7 @@ namespace Perun_v1
|
||||
public string[] SendBuffer = new string[10]; // Mysql send buffer
|
||||
public bool LetMeOut = false; // Helper to handle system tray
|
||||
public string MySql_connStr; // MySQL connection string
|
||||
public string publishVersion = "DEBUG"; // Helper for pulling version definition
|
||||
|
||||
public static void LogHistoryAdd(ref string[] LogHistory, string Comment)
|
||||
{
|
||||
@@ -47,28 +48,41 @@ namespace Perun_v1
|
||||
// Modify specific
|
||||
if (type == "1") // Inject app version information
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
string version = fileVersionInfo.ProductVersion;
|
||||
udp_frame.payload["v_win"] = "v"+version;
|
||||
udp_frame.payload["v_win"] = "v" + publishVersion;
|
||||
}
|
||||
|
||||
// Specific SQL
|
||||
if (type == "50")
|
||||
{
|
||||
sql = "INSERT INTO `pe_LogChat` (`pe_LogChat_id`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`) VALUES (NULL, '"+udp_frame.payload.player+ "', '" + udp_frame.payload.msg + "', '" + udp_frame.payload.all + "');";
|
||||
// Add entry to event log
|
||||
sql = "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`) VALUES (NULL,'" + udp_frame.payload.datetime + "', '" + udp_frame.payload.player + "', '" + udp_frame.payload.msg + "', '" + udp_frame.payload.all + "');";
|
||||
}
|
||||
else if (type == "51")
|
||||
{
|
||||
sql = "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`) VALUES (NULL, CURRENT_TIMESTAMP, '" + udp_frame.payload.log_type + "', '" + udp_frame.payload.log_content + "');";
|
||||
// Add entry to event log
|
||||
sql = "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash`) VALUES ( NULL, '" + udp_frame.payload.log_datetime + "', '" + udp_frame.payload.log_type + "', '" + udp_frame.payload.log_content + "', '" + udp_frame.payload.log_missionhash + "');";
|
||||
}
|
||||
else if (type == "52")
|
||||
{
|
||||
// Update user stats
|
||||
payload = JsonConvert.SerializeObject(udp_frame.payload.stat_data);
|
||||
sql = "INSERT INTO `pe_LogStats` (`pe_LogStats_datetime`, `pe_LogStats_ucid`, `pe_LogStats_debug`,`pe_LogStats_missionhash`) VALUES ('" + udp_frame.payload.stat_datetime + "', '" + udp_frame.payload.stat_ucid + "', JSON_QUOTE('" + payload + "'), '" + udp_frame.payload.stat_missionhash + "') ON DUPLICATE KEY UPDATE pe_LogStats_datetime='" + udp_frame.payload.stat_datetime + "',pe_LogStats_ucid = '" + udp_frame.payload.stat_ucid + "', pe_LogStats_debug=JSON_QUOTE('" + payload + "'), pe_LogStats_missionhash='" + udp_frame.payload.stat_missionhash + "'";
|
||||
}
|
||||
else if (type == "53")
|
||||
{
|
||||
// User logged in to DCS server
|
||||
payload = JsonConvert.SerializeObject(udp_frame.payload.stat_data);
|
||||
sql = "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_ucid`, `pe_LogLogins_name`, `pe_LogLogins_ip`) VALUES ('" + udp_frame.payload.login_datetime + "', '" + udp_frame.payload.login_ucid + "', '" + udp_frame.payload.login_name + "', '" + udp_frame.payload.login_ipaddr + "');";
|
||||
sql = sql + "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_id`, `pe_DataPlayers_ucid`, `pe_DataPlayers_lastip`, `pe_DataPlayers_lastname`, `pe_DataPlayers_updated`) VALUES (NULL, '" + udp_frame.payload.login_ucid + "', '" + udp_frame.payload.login_ipaddr + "', '" + udp_frame.payload.login_name + "', '" + udp_frame.payload.login_datetime + "') ON DUPLICATE KEY UPDATE pe_DataPlayers_lastip='" + udp_frame.payload.login_ipaddr + "',pe_DataPlayers_lastname='" + udp_frame.payload.login_name + "',pe_DataPlayers_updated='" + udp_frame.payload.login_datetime + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// General definition used for 1-10 packets
|
||||
payload = JsonConvert.SerializeObject(udp_frame.payload);
|
||||
sql = "INSERT INTO pe_DataRaw(pe_dataraw_type,pe_dataraw_payload) VALUES (" + type + ",JSON_QUOTE('" + payload + "')) ON DUPLICATE KEY UPDATE pe_dataraw_payload = JSON_QUOTE('" + payload + "')";
|
||||
}
|
||||
|
||||
// Connect to mysql
|
||||
// Connect to mysql and execute sql
|
||||
MySqlConnection conn = new MySqlConnection(MySql_connStr);
|
||||
try
|
||||
{
|
||||
@@ -157,7 +171,6 @@ namespace Perun_v1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public form_Main()
|
||||
{
|
||||
// Form init
|
||||
@@ -181,9 +194,12 @@ namespace Perun_v1
|
||||
con_check_3rd_srs.Checked = Properties.Settings.Default.OTHER_SRS_USE;
|
||||
|
||||
// Version to title header
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
this.Text = this.Text + " - v" + fileVersionInfo.ProductVersion;
|
||||
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
|
||||
{
|
||||
System.Deployment.Application.ApplicationDeployment cd = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
|
||||
publishVersion = cd.CurrentVersion.ToString();
|
||||
}
|
||||
this.Text = this.Text + " - v" + publishVersion;
|
||||
}
|
||||
|
||||
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
||||
@@ -344,7 +360,8 @@ namespace Perun_v1
|
||||
{
|
||||
con_txt_3rd_srs.Text = openFileDialog_SRS.FileName;
|
||||
con_check_3rd_srs.Checked = true;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
con_txt_3rd_srs.Text = "";
|
||||
con_check_3rd_srs.Checked = false;
|
||||
@@ -384,6 +401,9 @@ namespace Perun_v1
|
||||
dynamic raw_lotatc = JsonConvert.DeserializeObject(strSRSJson);
|
||||
|
||||
for (int i = 0; i < raw_lotatc.Count; i++)
|
||||
{
|
||||
|
||||
if (raw_lotatc[i].RadioInfo != null)
|
||||
{
|
||||
|
||||
int temp = raw_lotatc[i].RadioInfo.radios.Count - 1;
|
||||
@@ -409,9 +429,17 @@ namespace Perun_v1
|
||||
raw_lotatc[i].ClientChannelId.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.simultaneousTransmission.Parent.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (raw_lotatc.Count > 0)
|
||||
{
|
||||
strSRSJson = JsonConvert.SerializeObject(raw_lotatc);
|
||||
strSRSJson = "{'type':'100','payload':'" + strSRSJson + "'}";
|
||||
}
|
||||
else
|
||||
{
|
||||
strSRSJson = "{'type':'100','payload':{'ignore':'false'}}";
|
||||
}
|
||||
SRSdefault = false;
|
||||
LogHistoryAdd(ref LogHistory, "SRS data loaded");
|
||||
|
||||
|
||||
116
03_MySQL/m1081_perun.sql
Normal file
116
03_MySQL/m1081_perun.sql
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Baza danych: `m1081_perun`
|
||||
--
|
||||
CREATE DATABASE IF NOT EXISTS `m1081_perun` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
USE `m1081_perun`;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_DataPlayers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_DataPlayers`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_DataPlayers` (
|
||||
`pe_DataPlayers_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_DataPlayers_ucid` varchar(150) NOT NULL,
|
||||
`pe_DataPlayers_lastip` varchar(100) NOT NULL,
|
||||
`pe_DataPlayers_lastname` varchar(150) NOT NULL,
|
||||
`pe_DataPlayers_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`pe_DataPlayers_id`),
|
||||
UNIQUE KEY `UNIQUE_UCID` (`pe_DataPlayers_ucid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_DataRaw`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_DataRaw`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_DataRaw` (
|
||||
`pe_dataraw_type` tinyint(4) NOT NULL AUTO_INCREMENT,
|
||||
`pe_dataraw_payload` text NOT NULL,
|
||||
`pe_dataraw_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`pe_dataraw_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogChat`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogChat`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogChat` (
|
||||
`pe_LogChat_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogChat_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogChat_playerid` varchar(100) NOT NULL,
|
||||
`pe_LogChat_msg` text NOT NULL,
|
||||
`pe_LogChat_all` varchar(10) NOT NULL,
|
||||
PRIMARY KEY (`pe_LogChat_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogEvent`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogEvent`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogEvent` (
|
||||
`pe_LogEvent_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogEvent_missionhash` varchar(150) DEFAULT NULL,
|
||||
`pe_LogEvent_datetime` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogEvent_type` varchar(100) NOT NULL,
|
||||
`pe_LogEvent_content` text NOT NULL,
|
||||
PRIMARY KEY (`pe_LogEvent_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogLogins`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogLogins`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogLogins` (
|
||||
`pe_LogLogins_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogLogins_ucid` varchar(150) NOT NULL,
|
||||
`pe_LogLogins_name` varchar(150) NOT NULL,
|
||||
`pe_LogLogins_ip` varchar(100) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogStats`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogStats`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogStats` (
|
||||
`pe_LogStats_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogStats_missionhash` varchar(150) DEFAULT NULL,
|
||||
`pe_LogStats_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogStats_ucid` varchar(200) NOT NULL,
|
||||
`pe_LogStats_debug` text,
|
||||
PRIMARY KEY (`pe_LogStats_id`),
|
||||
UNIQUE KEY `UNIQUE_STATS_PER_MISSION_AND_UCID` (`pe_LogStats_ucid`,`pe_LogStats_missionhash`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
35
README.md
35
README.md
@@ -1,11 +1,13 @@
|
||||
# Perun for DCS World
|
||||
|
||||
This toolset extracts data from DCS World server and export it to local json file and UDP port. **Optional** windows app puts JSON data to MySQL database.
|
||||
Additionaly windows app can be used to merge LotATC and DCS SRS data in one database making Perun for DCS World ultimate integration tool for server admins.
|
||||
This toolset extracts data from DCS World server and sends information to the local Json file and UDP port.
|
||||
|
||||
## Getting Started
|
||||
Provided windows app puts JSON data to MySQL database. Additionaly Perun windows app can be used to merge LotATC and DCS SRS data in one database making Perun for DCS World wannabe ultimate integration tool for the server admins.
|
||||
|
||||
You can use this toolkit with or without Windows app. Simple DCS export scripts will create JSON file which can be used for further processing, by default this file is created in Scripts\Json folder located in your Saved Games DCS folder tree.
|
||||
However this software is intended to be used by experienced users - the output is data Json and MySQL; you will need to process/display it yourself.
|
||||
|
||||

|
||||

|
||||
|
||||
### Prerequisites
|
||||
|
||||
@@ -16,33 +18,36 @@ Core:
|
||||
* MySQL server with read/write access
|
||||
|
||||
3rd party support:
|
||||
* for [DCS SRS](https://github.com/ciribob/DCS-SimpleRadioStandalone/releases) integration location of the clients-list.json file and SRS configuration with JSON data export enabled - see [SRS documentation](https://github.com/ciribob/DCS-SimpleRadioStandalone/wiki)
|
||||
* for [LotATC](https://www.lotatc.com/) integration location of the stats.json file and LotATC configuration with JSON data export enabled - see [LotATC documentation](https://www.lotatc.com/documentation/server_configuration.html)
|
||||
* for [DCS SRS](https://github.com/ciribob/DCS-SimpleRadioStandalone/releases) integration location of the clients-list.json file will be required (by default: SRS Server folder), "Auto Export List" option has to be enabled - see [SRS documentation](https://github.com/ciribob/DCS-SimpleRadioStandalone/wiki)
|
||||
* for [LotATC](https://www.lotatc.com/) you will need location of stats.json file and proper LotATC configuration with JSON data export enabled - see [LotATC documentation](https://www.lotatc.com/documentation/server_configuration.html)
|
||||
|
||||
### Installing
|
||||
|
||||
* Download latest [release](https://github.com/szporwolik/perun/releases) **optionaly** together with Win32 binary file for MySQL export
|
||||
* Copy contents of DCS folder to you \Scripts folder (inside DCS folder in your Saved Games)
|
||||
* create MySQL server 03_MySQL folder contains creation SQL file
|
||||
* Download latest [release](https://github.com/szporwolik/perun/releases), **optionaly** together with Win32 binary file for MySQL export - [DOWNLOAD](http://share.porwolik.com/ftp/perun/Perun.htm)
|
||||
* 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)
|
||||
* **optionaly** Create MySQL server using SQL script located in [03_MySQL](https://github.com/szporwolik/perun/tree/master/03_MySQL)
|
||||
* **optionaly** Run the Win32 application
|
||||
* set MySQL connection data
|
||||
* point LotATC json file location
|
||||
* point DCS SRS json file location
|
||||
* click connect and leave the app running
|
||||
* click connect and leave the app running in the background
|
||||
* Start DCS World and host multiplayer session
|
||||
* by default the JSON is written into Scripts\Json folder located in your Saved Games DCS folder tree
|
||||
* by default the UDP port 48620 is in use as target
|
||||
* by default the UDP port 48620 is in use as target port
|
||||
|
||||
## Data packets
|
||||
* ID: 1, contains version information
|
||||
* ID: 2, contains status data in the following sections
|
||||
* mission
|
||||
* players
|
||||
* mission - minimal information
|
||||
* players - connected players
|
||||
* ID: 3, available slots list and coalitions
|
||||
* coalitions
|
||||
* slots
|
||||
* coalitions - available coalitions
|
||||
* slots - available slots
|
||||
* ID: 4, stores mission data **ONLY JSON FILE**
|
||||
* ID: 50, chat event
|
||||
* ID: 51, game event
|
||||
* ID: 52, player stats
|
||||
* ID: 53, player login to DCS server
|
||||
* ID: 100, DCS SRS's client-list.json
|
||||
* ID: 101, LotATC's stats.json
|
||||
|
||||
|
||||
Reference in New Issue
Block a user