mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 14:45:39 +02:00
First working version
This commit is contained in:
@@ -7,16 +7,19 @@
|
||||
|
||||
-- ########### SETTINGS ###########
|
||||
|
||||
Perun.Refresh = 15 -- base refresh rate in secounds (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.Refresh = 15 -- base refresh rate in secounds (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
|
||||
Perun.MOTD_L2 = "Wymagamy obecno<6E>ci na 255Mhz (DCS SRS)" -- Message send to players connecting the server - Line 2
|
||||
Perun.MOTD_L3 = "Udanej zabawy" -- Message send to players connecting the server - Line 3
|
||||
|
||||
-- ########### END OF SETTINGS ###########
|
||||
|
||||
-- Variable init
|
||||
Perun.Version = "v0.1.1"
|
||||
Perun.Version = "v0.2.1"
|
||||
Perun.StatusData = {}
|
||||
Perun.MissionData = {}
|
||||
Perun.SlotsData = {}
|
||||
Perun.VersionData = {}
|
||||
Perun.lastSent =0
|
||||
Perun.JsonLocation = lfs.writedir() .. Perun.JsonLocation
|
||||
@@ -25,7 +28,6 @@
|
||||
Perun.UDP:settimeout(0)
|
||||
Perun.UDP:setsockname("*", 48621)
|
||||
Perun.UDP:setpeername("127.0.0.1",Perun.UDPTargetPort)
|
||||
Perun.UDP:send("{'type':999,'payload':'Perun is onlne!'}") -- send welcome message
|
||||
|
||||
-- Function definition
|
||||
Perun.AddLog = function(text)
|
||||
@@ -38,7 +40,7 @@
|
||||
TempData={}
|
||||
TempData["1"]=Perun.VersionData
|
||||
TempData["2"]=Perun.StatusData
|
||||
TempData["3"]=Perun.MissionData
|
||||
TempData["3"]=Perun.SlotsData
|
||||
|
||||
io.open(Perun.JsonLocation,"w"):close()
|
||||
perun_export = io.open(Perun.JsonLocation, "w")
|
||||
@@ -79,7 +81,6 @@
|
||||
-- 1 - Mission
|
||||
temp={}
|
||||
temp['name']=DCS.getMissionName()
|
||||
temp['filename']=DCS.getMissionFilename()
|
||||
temp['modeltime']=DCS.getModelTime()
|
||||
temp['realtime']=DCS.getRealTime()
|
||||
temp['pause']=DCS.getPause()
|
||||
@@ -101,22 +102,36 @@
|
||||
-- Main function for mission information updates
|
||||
|
||||
-- Update Mission data
|
||||
Perun.MissionData['name']=DCS.getMissionName()
|
||||
Perun.MissionData['description']=DCS.getMissionDescription()
|
||||
Perun.MissionData['filename']=DCS.getMissionFilename()
|
||||
Perun.MissionData['modeltime']=DCS.getModelTime()
|
||||
Perun.MissionData['realtime']=DCS.getRealTime()
|
||||
Perun.MissionData['data']=DCS.getCurrentMission()
|
||||
Perun.MissionData['coalitions']=DCS.getAvailableCoalitions()
|
||||
Perun.MissionData['slots']={}
|
||||
Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions()
|
||||
Perun.SlotsData['slots']={}
|
||||
|
||||
for j, i in pairs(Perun.MissionData['coalitions']) do
|
||||
Perun.MissionData['slots'][j]=DCS.getAvailableSlots(j)
|
||||
for j, i in pairs(Perun.SlotsData['coalitions']) do
|
||||
Perun.SlotsData['slots'][j]=DCS.getAvailableSlots(j)
|
||||
end
|
||||
-- Send
|
||||
Perun.Send(3,Perun.MissionData)
|
||||
Perun.Send(3,Perun.SlotsData)
|
||||
end
|
||||
|
||||
Perun.LogChat = function(playerID,msg,all)
|
||||
-- Log chat messages
|
||||
|
||||
data={}
|
||||
data['player']= net.get_player_info(playerID, "name")
|
||||
data['msg']=msg
|
||||
data['all']=all
|
||||
|
||||
Perun.Send(50,data)
|
||||
end
|
||||
|
||||
Perun.LogEvent = function(log_type,log_content)
|
||||
-- Log chat messages
|
||||
|
||||
data={}
|
||||
data['log_type']= log_type
|
||||
data['log_content']=log_content
|
||||
|
||||
Perun.Send(51,data)
|
||||
end
|
||||
|
||||
|
||||
--- Event callbacks
|
||||
Perun.onSimulationFrame = function()
|
||||
@@ -137,6 +152,74 @@
|
||||
Perun.UpdateMission()
|
||||
Perun.UpdateJson()
|
||||
end
|
||||
|
||||
Perun.onPlayerStart = function (id)
|
||||
net.send_chat(Perun.MOTD_L1, id);
|
||||
net.send_chat(Perun.MOTD_L2, id);
|
||||
net.send_chat(Perun.MOTD_L3, id);
|
||||
end
|
||||
|
||||
Perun.onPlayerTrySendChat = function (playerID, msg, all)
|
||||
Perun.LogChat(playerID,msg,all)
|
||||
return msg
|
||||
end
|
||||
|
||||
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4)
|
||||
|
||||
|
||||
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);
|
||||
|
||||
elseif eventName == "mission_end" then
|
||||
--"mission_end", winner, msg
|
||||
Perun.LogEvent(eventName,"Mission end, 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);
|
||||
|
||||
elseif eventName == "self_kill" then
|
||||
--"self_kill", playerID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " killed himself");
|
||||
|
||||
elseif eventName == "change_slot" then
|
||||
--"change_slot", playerID, slotID, prevSide
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " changed slot to " .. arg2);
|
||||
|
||||
elseif eventName == "connect" then
|
||||
--"connect", playerID, name
|
||||
Perun.LogEvent(eventName,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; reason: " .. arg4);
|
||||
|
||||
elseif eventName == "crash" then
|
||||
--"crash", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " crashed");
|
||||
|
||||
elseif eventName == "eject" then
|
||||
--"eject", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " ejected");
|
||||
|
||||
elseif eventName == "takeoff" then
|
||||
--"takeoff", playerID, unit_missionID, airdromeName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " took off from " .. arg3);
|
||||
|
||||
elseif eventName == "landing" then
|
||||
--"landing", playerID, unit_missionID, airdromeName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " landed at " .. arg3);
|
||||
|
||||
elseif eventName == "pilot_death" then
|
||||
--"pilot_death", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. "died");
|
||||
|
||||
else
|
||||
Perun.LogEvent(eventName,"Unknown event type");
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Finalize and set callbacks
|
||||
DCS.setUserCallbacks(Perun)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="Perun_v1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
<section name="Perun.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
@@ -9,6 +10,35 @@
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<Perun_v1.Properties.Settings>
|
||||
<setting name="MYSQL_Server" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MYSQL_User" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MYSQL_Password" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MYSQL_DB" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OTHER_LOTATC_FILE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OTHER_SRS_FILE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OTHER_LOTATC_USE" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="OTHER_SRS_USE" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="MYSQL_Port" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</Perun_v1.Properties.Settings>
|
||||
<Perun.Properties.Settings>
|
||||
<setting name="MYSQL_Server" serializeAs="String">
|
||||
<value />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<ProjectGuid>{5A710507-92E9-4664-9B91-918B8B82F107}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Perun_v1</RootNamespace>
|
||||
<AssemblyName>Perun_v1</AssemblyName>
|
||||
<AssemblyName>Perun</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
@@ -23,8 +23,9 @@
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>1</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<AutorunEnabled>true</AutorunEnabled>
|
||||
<ApplicationRevision>2</ApplicationRevision>
|
||||
<ApplicationVersion>0.2.1.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
@@ -55,7 +56,8 @@
|
||||
<ManifestCertificateThumbprint>2ACE4C8C2C325A04CA5986B1CD76744B4B03755D</ManifestCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestKeyFile>Perun_v1_TemporaryKey.pfx</ManifestKeyFile>
|
||||
<ManifestKeyFile>
|
||||
</ManifestKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
@@ -144,5 +146,8 @@
|
||||
<ItemGroup>
|
||||
<Content Include="perun_logo.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -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.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||
[assembly: AssemblyVersion("0.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.2.0.0")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -60,6 +60,7 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -109,9 +112,9 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -118,5 +118,17 @@ namespace Perun_v1.Properties {
|
||||
this["OTHER_SRS_USE"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string MYSQL_Port {
|
||||
get {
|
||||
return ((string)(this["MYSQL_Port"]));
|
||||
}
|
||||
set {
|
||||
this["MYSQL_Port"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Perun.Properties" GeneratedClassName="Settings">
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Perun_v1.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="MYSQL_Server" Type="System.String" Scope="User">
|
||||
@@ -26,5 +26,8 @@
|
||||
<Setting Name="OTHER_SRS_USE" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="MYSQL_Port" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
54
02_Windows_App/Perun_v1/form_Main.Designer.cs
generated
54
02_Windows_App/Perun_v1/form_Main.Designer.cs
generated
@@ -36,6 +36,8 @@
|
||||
this.con_GroupBox_1 = new System.Windows.Forms.GroupBox();
|
||||
this.tim_1000ms = new System.Windows.Forms.Timer(this.components);
|
||||
this.con_GroupBox_2 = new System.Windows.Forms.GroupBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.con_txt_mysql_port = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.con_txt_mysql_username = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
@@ -83,7 +85,7 @@
|
||||
//
|
||||
// con_Button_Listen_ON
|
||||
//
|
||||
this.con_Button_Listen_ON.Location = new System.Drawing.Point(12, 405);
|
||||
this.con_Button_Listen_ON.Location = new System.Drawing.Point(12, 434);
|
||||
this.con_Button_Listen_ON.Name = "con_Button_Listen_ON";
|
||||
this.con_Button_Listen_ON.Size = new System.Drawing.Size(86, 39);
|
||||
this.con_Button_Listen_ON.TabIndex = 2;
|
||||
@@ -94,7 +96,7 @@
|
||||
// con_Button_Listen_OFF
|
||||
//
|
||||
this.con_Button_Listen_OFF.Enabled = false;
|
||||
this.con_Button_Listen_OFF.Location = new System.Drawing.Point(104, 405);
|
||||
this.con_Button_Listen_OFF.Location = new System.Drawing.Point(104, 434);
|
||||
this.con_Button_Listen_OFF.Name = "con_Button_Listen_OFF";
|
||||
this.con_Button_Listen_OFF.Size = new System.Drawing.Size(86, 39);
|
||||
this.con_Button_Listen_OFF.TabIndex = 3;
|
||||
@@ -105,9 +107,9 @@
|
||||
// con_GroupBox_1
|
||||
//
|
||||
this.con_GroupBox_1.Controls.Add(this.con_List_Received);
|
||||
this.con_GroupBox_1.Location = new System.Drawing.Point(12, 235);
|
||||
this.con_GroupBox_1.Location = new System.Drawing.Point(12, 261);
|
||||
this.con_GroupBox_1.Name = "con_GroupBox_1";
|
||||
this.con_GroupBox_1.Size = new System.Drawing.Size(324, 164);
|
||||
this.con_GroupBox_1.Size = new System.Drawing.Size(324, 167);
|
||||
this.con_GroupBox_1.TabIndex = 4;
|
||||
this.con_GroupBox_1.TabStop = false;
|
||||
this.con_GroupBox_1.Text = "UDP log";
|
||||
@@ -119,6 +121,8 @@
|
||||
//
|
||||
// con_GroupBox_2
|
||||
//
|
||||
this.con_GroupBox_2.Controls.Add(this.label6);
|
||||
this.con_GroupBox_2.Controls.Add(this.con_txt_mysql_port);
|
||||
this.con_GroupBox_2.Controls.Add(this.label4);
|
||||
this.con_GroupBox_2.Controls.Add(this.con_txt_mysql_username);
|
||||
this.con_GroupBox_2.Controls.Add(this.label3);
|
||||
@@ -129,15 +133,31 @@
|
||||
this.con_GroupBox_2.Controls.Add(this.con_txt_mysql_password);
|
||||
this.con_GroupBox_2.Location = new System.Drawing.Point(12, 27);
|
||||
this.con_GroupBox_2.Name = "con_GroupBox_2";
|
||||
this.con_GroupBox_2.Size = new System.Drawing.Size(324, 127);
|
||||
this.con_GroupBox_2.Size = new System.Drawing.Size(324, 154);
|
||||
this.con_GroupBox_2.TabIndex = 5;
|
||||
this.con_GroupBox_2.TabStop = false;
|
||||
this.con_GroupBox_2.Text = "MySQL";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(41, 48);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(59, 13);
|
||||
this.label6.TabIndex = 9;
|
||||
this.label6.Text = "Server port";
|
||||
//
|
||||
// con_txt_mysql_port
|
||||
//
|
||||
this.con_txt_mysql_port.Location = new System.Drawing.Point(106, 45);
|
||||
this.con_txt_mysql_port.Name = "con_txt_mysql_port";
|
||||
this.con_txt_mysql_port.Size = new System.Drawing.Size(207, 20);
|
||||
this.con_txt_mysql_port.TabIndex = 8;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(45, 74);
|
||||
this.label4.Location = new System.Drawing.Point(45, 100);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(55, 13);
|
||||
this.label4.TabIndex = 7;
|
||||
@@ -145,7 +165,7 @@
|
||||
//
|
||||
// con_txt_mysql_username
|
||||
//
|
||||
this.con_txt_mysql_username.Location = new System.Drawing.Point(106, 71);
|
||||
this.con_txt_mysql_username.Location = new System.Drawing.Point(106, 97);
|
||||
this.con_txt_mysql_username.Name = "con_txt_mysql_username";
|
||||
this.con_txt_mysql_username.Size = new System.Drawing.Size(207, 20);
|
||||
this.con_txt_mysql_username.TabIndex = 6;
|
||||
@@ -153,7 +173,7 @@
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(47, 100);
|
||||
this.label3.Location = new System.Drawing.Point(47, 126);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(53, 13);
|
||||
this.label3.TabIndex = 5;
|
||||
@@ -162,7 +182,7 @@
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(47, 48);
|
||||
this.label2.Location = new System.Drawing.Point(47, 74);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(53, 13);
|
||||
this.label2.TabIndex = 4;
|
||||
@@ -179,7 +199,7 @@
|
||||
//
|
||||
// con_txt_mysql_database
|
||||
//
|
||||
this.con_txt_mysql_database.Location = new System.Drawing.Point(106, 45);
|
||||
this.con_txt_mysql_database.Location = new System.Drawing.Point(106, 71);
|
||||
this.con_txt_mysql_database.Name = "con_txt_mysql_database";
|
||||
this.con_txt_mysql_database.Size = new System.Drawing.Size(207, 20);
|
||||
this.con_txt_mysql_database.TabIndex = 2;
|
||||
@@ -193,7 +213,7 @@
|
||||
//
|
||||
// con_txt_mysql_password
|
||||
//
|
||||
this.con_txt_mysql_password.Location = new System.Drawing.Point(106, 97);
|
||||
this.con_txt_mysql_password.Location = new System.Drawing.Point(106, 123);
|
||||
this.con_txt_mysql_password.Name = "con_txt_mysql_password";
|
||||
this.con_txt_mysql_password.PasswordChar = '*';
|
||||
this.con_txt_mysql_password.Size = new System.Drawing.Size(207, 20);
|
||||
@@ -205,9 +225,9 @@
|
||||
this.con_GroupBox_3.Controls.Add(this.con_txt_3rd_srs);
|
||||
this.con_GroupBox_3.Controls.Add(this.con_check_3rd_lotatc);
|
||||
this.con_GroupBox_3.Controls.Add(this.con_check_3rd_srs);
|
||||
this.con_GroupBox_3.Location = new System.Drawing.Point(12, 160);
|
||||
this.con_GroupBox_3.Location = new System.Drawing.Point(12, 187);
|
||||
this.con_GroupBox_3.Name = "con_GroupBox_3";
|
||||
this.con_GroupBox_3.Size = new System.Drawing.Size(324, 69);
|
||||
this.con_GroupBox_3.Size = new System.Drawing.Size(324, 68);
|
||||
this.con_GroupBox_3.TabIndex = 6;
|
||||
this.con_GroupBox_3.TabStop = false;
|
||||
this.con_GroupBox_3.Text = "3rd Party";
|
||||
@@ -250,7 +270,7 @@
|
||||
//
|
||||
// con_Button_Quit
|
||||
//
|
||||
this.con_Button_Quit.Location = new System.Drawing.Point(250, 405);
|
||||
this.con_Button_Quit.Location = new System.Drawing.Point(250, 434);
|
||||
this.con_Button_Quit.Name = "con_Button_Quit";
|
||||
this.con_Button_Quit.Size = new System.Drawing.Size(86, 39);
|
||||
this.con_Button_Quit.TabIndex = 7;
|
||||
@@ -298,14 +318,14 @@
|
||||
//
|
||||
// tim_10000ms
|
||||
//
|
||||
this.tim_10000ms.Interval = 10000;
|
||||
this.tim_10000ms.Interval = 30000;
|
||||
this.tim_10000ms.Tick += new System.EventHandler(this.tim_10000ms_Tick);
|
||||
//
|
||||
// form_Main
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(348, 456);
|
||||
this.ClientSize = new System.Drawing.Size(349, 483);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.con_lab_github);
|
||||
this.Controls.Add(this.con_Button_Quit);
|
||||
@@ -361,6 +381,8 @@
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog_SRS;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog_LotATC;
|
||||
private System.Windows.Forms.Timer tim_10000ms;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TextBox con_txt_mysql_port;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,16 +36,15 @@ namespace Perun_v1
|
||||
public void SendToMySql(string raw_udp_frame)
|
||||
{
|
||||
// Main function to send data to mysql
|
||||
// TODO : persistent connection and error handling
|
||||
|
||||
dynamic udp_frame = JsonConvert.DeserializeObject(raw_udp_frame);
|
||||
|
||||
// Cut raw data to type and paylod for proper mysql insert
|
||||
string type = udp_frame.type;
|
||||
|
||||
string type = udp_frame.type;
|
||||
string payload = "";
|
||||
string sql = "";
|
||||
|
||||
// Type specyfic
|
||||
if (type == "1") // Inject app version information
|
||||
// Modify specific
|
||||
if (type == "1") // Inject app version information
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
@@ -53,7 +52,21 @@ namespace Perun_v1
|
||||
udp_frame.payload["v_win"] = "v"+version;
|
||||
}
|
||||
|
||||
string payload = JsonConvert.SerializeObject(udp_frame.payload);
|
||||
// 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 + "');";
|
||||
}
|
||||
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 + "');";
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
MySqlConnection conn = new MySqlConnection(MySql_connStr);
|
||||
try
|
||||
@@ -61,8 +74,6 @@ namespace Perun_v1
|
||||
Console.WriteLine("Sending data to MySQL - Begin");
|
||||
conn.Open();
|
||||
|
||||
string 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 + "')";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(sql, conn);
|
||||
MySqlDataReader rdr = cmd.ExecuteReader();
|
||||
|
||||
@@ -162,10 +173,16 @@ namespace Perun_v1
|
||||
con_txt_mysql_username.Text = Properties.Settings.Default.MYSQL_User;
|
||||
con_txt_mysql_password.Text = Properties.Settings.Default.MYSQL_Password;
|
||||
con_txt_mysql_server.Text = Properties.Settings.Default.MYSQL_Server;
|
||||
con_txt_mysql_port.Text = Properties.Settings.Default.MYSQL_Port;
|
||||
con_txt_3rd_lotatc.Text = Properties.Settings.Default.OTHER_LOTATC_FILE;
|
||||
con_txt_3rd_srs.Text = Properties.Settings.Default.OTHER_SRS_FILE;
|
||||
con_check_3rd_lotatc.Checked = Properties.Settings.Default.OTHER_LOTATC_USE;
|
||||
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;
|
||||
}
|
||||
|
||||
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
||||
@@ -178,21 +195,22 @@ namespace Perun_v1
|
||||
// Update form controls
|
||||
con_Button_Listen_ON.Enabled = false;
|
||||
con_Button_Listen_OFF.Enabled = true;
|
||||
|
||||
con_txt_mysql_database.Enabled = false;
|
||||
con_txt_mysql_username.Enabled = false;
|
||||
con_txt_mysql_password.Enabled = false;
|
||||
con_txt_mysql_server.Enabled = false;
|
||||
con_txt_mysql_port.Enabled = false;
|
||||
con_txt_3rd_lotatc.Enabled = false;
|
||||
con_txt_3rd_srs.Enabled = false;
|
||||
con_check_3rd_lotatc.Enabled = false;
|
||||
con_check_3rd_srs.Enabled = false;
|
||||
// Prepare connection string
|
||||
MySql_connStr = "server="+con_txt_mysql_server.Text+";user="+con_txt_mysql_username.Text+";database="+con_txt_mysql_database.Text+";port=3306;password="+con_txt_mysql_password.Text;
|
||||
MySql_connStr = "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 timmers
|
||||
tim_1000ms.Enabled = true;
|
||||
tim_10000ms.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
||||
@@ -207,6 +225,7 @@ namespace Perun_v1
|
||||
con_txt_mysql_database.Enabled = true;
|
||||
con_txt_mysql_username.Enabled = true;
|
||||
con_txt_mysql_password.Enabled = true;
|
||||
con_txt_mysql_port.Enabled = true;
|
||||
con_txt_mysql_server.Enabled = true;
|
||||
con_txt_3rd_lotatc.Enabled = true;
|
||||
con_txt_3rd_srs.Enabled = true;
|
||||
@@ -261,7 +280,9 @@ namespace Perun_v1
|
||||
Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text;
|
||||
Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text;
|
||||
Properties.Settings.Default.MYSQL_Password = con_txt_mysql_password.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_server.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_FILE = con_txt_3rd_lotatc.Text;
|
||||
Properties.Settings.Default.OTHER_SRS_FILE = con_txt_3rd_srs.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
|
||||
@@ -333,14 +354,31 @@ namespace Perun_v1
|
||||
private void tim_10000ms_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Main timer to send JSON files to MySQL
|
||||
string strSRSJson = System.IO.File.ReadAllText(con_txt_3rd_srs.Text);
|
||||
LogHistoryAdd(ref LogHistory, "SRS data loaded");
|
||||
string strLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||
LogHistoryAdd(ref LogHistory, "LotATC data loaded");
|
||||
string strSRSJson;
|
||||
string strLotATCJson;
|
||||
|
||||
if (con_check_3rd_srs.Checked)
|
||||
{
|
||||
strSRSJson = System.IO.File.ReadAllText(con_txt_3rd_srs.Text);
|
||||
LogHistoryAdd(ref LogHistory, "SRS data loaded");
|
||||
strSRSJson = "{'type':'100','payload':'" + strSRSJson + "'}";
|
||||
}
|
||||
else
|
||||
{
|
||||
strSRSJson = "{'type':'100','payload':{'ignore':'true'}}";
|
||||
}
|
||||
|
||||
strSRSJson = "{'type':'100','payload':'" + strSRSJson + "'}";
|
||||
SendToMySql(strSRSJson);
|
||||
strLotATCJson = "{'type':'101','payload':'" + strLotATCJson + "'}";
|
||||
if (con_check_3rd_lotatc.Checked)
|
||||
{
|
||||
strLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||
LogHistoryAdd(ref LogHistory, "LotATC data loaded");
|
||||
strLotATCJson = "{'type':'101','payload':'" + strLotATCJson + "'}";
|
||||
|
||||
} else
|
||||
{
|
||||
strLotATCJson = "{'type':'101','payload':{'ignore':'true'}}";
|
||||
}
|
||||
SendToMySql(strLotATCJson);
|
||||
}
|
||||
}
|
||||
|
||||
32
README.md
32
README.md
@@ -1,18 +1,17 @@
|
||||
# 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.
|
||||
|
||||
## Getting Started
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Core:
|
||||
* For JSON Export:
|
||||
* DCS World stable or DCS World beta
|
||||
* For UDP Export:
|
||||
* Windows app which handles UDP readouts
|
||||
* **(Optional)** For MySQL Export:
|
||||
* MySQL server with read/write access
|
||||
|
||||
@@ -24,15 +23,28 @@ Core:
|
||||
|
||||
* 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)
|
||||
* Add the following line to your Export.lua : TBD
|
||||
* Run the Win32 application
|
||||
* create MySQL server 03_MySQL folder contains creation SQL file
|
||||
* **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
|
||||
* Start DCS World and host multiplayer session
|
||||
* by default the JSON is written into : TBD
|
||||
* by default the UDP port TBD is in use
|
||||
* 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
|
||||
|
||||
## Testing
|
||||
|
||||
TBD
|
||||
## Data packets
|
||||
* ID: 1, contains version information
|
||||
* ID: 2, contains status data in the following sections
|
||||
* mission
|
||||
* players
|
||||
* ID: 3, available slots list and coalitions
|
||||
* coalitions
|
||||
* slots
|
||||
* ID: 50, chat event
|
||||
* ID: 51, game event
|
||||
* ID: 100, DCS SRS's client-list.json
|
||||
* ID: 101, LotATC's stats.json
|
||||
|
||||
## Built With
|
||||
|
||||
|
||||
Reference in New Issue
Block a user