6 Commits

Author SHA1 Message Date
Szymon Porwolik
f7f688d1a5 Modified event log 2019-03-10 00:48:32 +01:00
Szymon Porwolik
81ff34014a Added stats support 2019-03-10 00:48:32 +01:00
Szymon Porwolik
9e0c515af0 Added stats support 2019-03-10 00:48:32 +01:00
Szymon Porwolik
9391d8778f Added stats suport 2019-03-10 00:48:32 +01:00
Szymon Porwolik
1cfe5a1ea9 Added stats support 2019-03-10 00:48:32 +01:00
Szymon Porwolik
8d1835f6f5 - MOTD will be send only to player who is joining
- after mission end mission hash will be set to ""
2019-03-10 00:48:32 +01:00
5 changed files with 252 additions and 68 deletions

View File

@@ -20,11 +20,13 @@ Perun.MOTD_L2 = "Wymagamy obecnosci na 255Mhz (DCS SRS)" -- (string) Message
-- Variable init -- Variable init
Perun.Version = "v0.4.1" Perun.Version = "v0.5.0"
Perun.StatusData = {} Perun.StatusData = {}
Perun.SlotsData = {} Perun.SlotsData = {}
Perun.MissionData = {} Perun.MissionData = {}
Perun.ServerData = {} Perun.ServerData = {}
Perun.StatData = {}
Perun.StatDataLastType = {}
Perun.MissionHash="" Perun.MissionHash=""
Perun.lastSentStatus =0 Perun.lastSentStatus =0
Perun.lastSentMission =0 Perun.lastSentMission =0
@@ -169,7 +171,6 @@ Perun.UpdateJsonStatus = function()
perun_export = io.open(Perun.JsonStatusLocation .. "perun_status_data.json", "w") perun_export = io.open(Perun.JsonStatusLocation .. "perun_status_data.json", "w")
perun_export:write(_temp .. "\n") perun_export:write(_temp .. "\n")
perun_export:close() perun_export:close()
end end
Perun.Send = function(data_id, data_package) Perun.Send = function(data_id, data_package)
@@ -184,7 +185,7 @@ Perun.Send = function(data_id, data_package)
temp=stripChars(temp) temp=stripChars(temp)
Perun.UDP:send(temp) Perun.UDP:send(temp)
Perun.AddLog("Packet send") Perun.AddLog("Packet send "..data_id)
end end
Perun.UpdateStatusPart = function(part_id, data_package) Perun.UpdateStatusPart = function(part_id, data_package)
@@ -262,11 +263,13 @@ Perun.LogChat = function(playerID,msg,all)
Perun.Send(50,data) Perun.Send(50,data)
end end
Perun.LogEvent = function(log_type,log_content) Perun.LogEvent = function(log_type,log_content,log_arg_1,log_arg_2)
-- Log chat messages -- Log chat messages
data={} data={}
data['log_type']= log_type data['log_type']= log_type
data['log_arg_1']= log_arg_1
data['log_arg_2']= log_arg_2
data['log_content']=log_content data['log_content']=log_content
data['log_datetime']=os.date('%Y-%m-%d %H:%M:%S') data['log_datetime']=os.date('%Y-%m-%d %H:%M:%S')
data['log_missionhash']=Perun.MissionHash data['log_missionhash']=Perun.MissionHash
@@ -274,23 +277,132 @@ Perun.LogEvent = function(log_type,log_content)
Perun.Send(51,data) Perun.Send(51,data)
end end
Perun.LogStatsCount = function(argPlayerID,argAction,argType)
-- Creates or updates Perun statistics array
_ucid=net.get_player_info(argPlayerID, 'ucid')..argType
if Perun.StatData[_ucid] == nil then
-- Create empty element
_temp={}
_temp['ps_type'] = argType
_temp['ps_kills'] = 0
_temp['ps_pvp'] = 0
_temp['ps_deaths'] = 0
_temp['ps_ejections'] = 0
_temp['ps_crashes'] = 0
_temp['ps_teamkills'] = 0
_temp['ps_kills_planes'] = 0
_temp['ps_kills_helicopters'] = 0
_temp['ps_kills_air_defense'] = 0
_temp['ps_kills_armor'] = 0
_temp['ps_kills_unarmed'] = 0
_temp['ps_kills_infantry'] = 0
_temp['ps_kills_ships'] = 0
_temp['ps_kills_other'] = 0
_temp['ps_airfield_takeoffs'] = 0
_temp['ps_airfield_landings'] = 0
_temp['ps_ship_takeoffs'] = 0
_temp['ps_ship_landings'] = 0
_temp['ps_farp_takeoffs'] = 0
_temp['ps_farp_landings'] = 0
Perun.StatData[_ucid]=_temp
end
if argType ~= nil then
Perun.StatData[_ucid]['ps_type']=argType;
Perun.StatDataLastType[net.get_player_info(argPlayerID, 'ucid')]=_ucid
else
-- Do nothing
end
if argAction == "eject" then
Perun.StatData[_ucid]['ps_ejections']=Perun.StatData[_ucid]['ps_ejections']+1
elseif argAction == "pilot_death" then
Perun.StatData[_ucid]['ps_deaths']=Perun.StatData[_ucid]['ps_deaths']+1
elseif argAction == "friendly_fire" then
Perun.StatData[_ucid]['ps_teamkills']=Perun.StatData[_ucid]['ps_teamkills']+1
elseif argAction == "crash" then
Perun.StatData[_ucid]['ps_crashes']=Perun.StatData[_ucid]['ps_crashes']+1
elseif argAction == "landing_FARP" then
Perun.StatData[_ucid]['ps_farp_landings']=Perun.StatData[_ucid]['ps_farp_landings']+1
elseif argAction == "landing_SHIP" then
Perun.StatData[_ucid]['ps_ship_landings']=Perun.StatData[_ucid]['ps_ship_landings']+1
elseif argAction == "landing_AIRFIELD" then
Perun.StatData[_ucid]['ps_airfield_landings']=Perun.StatData[_ucid]['ps_airfield_landings']+1
elseif argAction == "tookoff_FARP" then
Perun.StatData[_ucid]['ps_farp_takeoffs']=Perun.StatData[_ucid]['ps_farp_takeoffs']+1
elseif argAction == "tookoff_SHIP" then
Perun.StatData[_ucid]['ps_ship_takeoffs']=Perun.StatData[_ucid]['ps_ship_takeoffs']+1
elseif argAction == "tookoff_AIRFIELD" then
Perun.StatData[_ucid]['ps_airfield_takeoffs']=Perun.StatData[_ucid]['ps_airfield_takeoffs']+1
elseif argAction == "kill_Planes" then
Perun.StatData[_ucid]['ps_kills_planes']=Perun.StatData[_ucid]['ps_kills_planes']+1
elseif argAction == "kill_Helicopters" then
Perun.StatData[_ucid]['ps_kills_helicopters']=Perun.StatData[_ucid]['ps_kills_helicopters']+1
elseif argAction == "kill_Ships" then
Perun.StatData[_ucid]['ps_kills_ships']=Perun.StatData[_ucid]['ps_kills_ships']+1
elseif argAction == "kill_Air_Defence" then
Perun.StatData[_ucid]['ps_kills_air_defense']=Perun.StatData[_ucid]['ps_kills_air_defense']+1
elseif argAction == "kill_Unarmed" then
Perun.StatData[_ucid]['ps_kills_unarmed']=Perun.StatData[_ucid]['ps_kills_unarmed']+1
elseif argAction == "kill_Armor" then
Perun.StatData[_ucid]['ps_kills_armor']=Perun.StatData[_ucid]['ps_kills_armor']+1
elseif argAction == "kill_Infantry" then
Perun.StatData[_ucid]['ps_kills_infantry']=Perun.StatData[_ucid]['ps_kills_infantry']+1
elseif argAction == "kill_Other" then
Perun.StatData[_ucid]['ps_kills_other']=Perun.StatData[_ucid]['ps_kills_other']+1
elseif argAction == "kill_PvP" then
Perun.StatData[_ucid]['ps_pvp']=Perun.StatData[_ucid]['ps_pvp']+1
end
Perun.LogStats(argPlayerID);
end
Perun.LogStatsGet = function(playerID)
-- Gets Perun statistics array per player
local next = next
if next(Perun.StatDataLastType) == nil then
_ucid=net.get_player_info(playerID, 'ucid')..DCS.getUnitType(playerID)
elseif Perun.StatDataLastType[net.get_player_info(playerID, 'ucid')]== nil then
_ucid=net.get_player_info(playerID, 'ucid')..DCS.getUnitType(playerID)
else
_ucid=Perun.StatDataLastType[net.get_player_info(playerID, 'ucid')]
end
local next = next
if next(Perun.StatData) == nil then
Perun.LogStatsCount(playerID,'init')
end
if Perun.StatData[_ucid]== nil then
Perun.LogStatsCount(playerID,'init')
end
return Perun.StatData[_ucid];
end
Perun.LogStats = function(playerID) Perun.LogStats = function(playerID)
-- Log player status -- Log player status
-- TBD : not working at the moment WIP -- TBD : DCS stats not working at the moment WIP
p_stats={} p_stats_dcs={}
p_stats['PS_CAR']=net.get_stat(playerID,2) p_stats_dcs['PS_CAR']=net.get_stat(playerID,2)
p_stats['PS_PLANE']=net.get_stat(playerID,3) p_stats_dcs['PS_PLANE']=net.get_stat(playerID,3)
p_stats['PS_SHIP']=net.get_stat(playerID,4) p_stats_dcs['PS_SHIP']=net.get_stat(playerID,4)
p_stats['PS_SCORE']=net.get_stat(playerID,5) p_stats_dcs['PS_SCORE']=net.get_stat(playerID,5)
p_stats['PS_LAND']=net.get_stat(playerID,6) p_stats_dcs['PS_LAND']=net.get_stat(playerID,6)
p_stats['PS_PING']=net.get_stat(playerID,0) p_stats_dcs['PS_PING']=net.get_stat(playerID,0)
p_stats['PS_CRASH']=net.get_stat(playerID,1) p_stats_dcs['PS_CRASH']=net.get_stat(playerID,1)
p_stats['PS_EJECT']=net.get_stat(playerID,7) p_stats_dcs['PS_EJECT']=net.get_stat(playerID,7)
p_stats['debug']="ok"
_temp=Perun.LogStatsGet(playerID)
data={} data={}
data['stat_data']=p_stats data['stat_data_dcs']=p_stats_dcs
data['stat_data_perun']=_temp
data['stat_data_type']=_temp['ps_type'];
data['stat_ucid']=net.get_player_info(playerID, 'ucid') data['stat_ucid']=net.get_player_info(playerID, 'ucid')
data['stat_datetime']=os.date('%Y-%m-%d %H:%M:%S') data['stat_datetime']=os.date('%Y-%m-%d %H:%M:%S')
data['stat_missionhash']=Perun.MissionHash data['stat_missionhash']=Perun.MissionHash
@@ -314,15 +426,20 @@ end
Perun.onSimulationStart = function() Perun.onSimulationStart = function()
Perun.MissionHash=DCS.getMissionName( ).."@".. Perun.Instance .. "@"..os.date('%Y%m%d_%H%M%S'); Perun.MissionHash=DCS.getMissionName( ).."@".. Perun.Instance .. "@"..os.date('%Y%m%d_%H%M%S');
Perun.LogEvent("SimStart","Mission " .. Perun.MissionHash .. " started"); Perun.LogEvent("SimStart","Mission " .. Perun.MissionHash .. " started",nil,nil);
Perun.StatData = {}
Perun.StatDataLastType = {}
end end
Perun.onSimulationStop = function() Perun.onSimulationStop = function()
Perun.LogEvent("SimStop","Mission " .. Perun.MissionHash .. " finished"); Perun.LogEvent("SimStop","Mission " .. Perun.MissionHash .. " finished",nil,nil);
Perun.MissionHash="";
Perun.StatData = {}
Perun.StatDataLastType = {}
end end
Perun.onPlayerDisconnect= function(id, err_code) Perun.onPlayerDisconnect = function(id, err_code)
Perun.LogEvent("disconnect", "Player " .. net.get_player_info(id, "name") .. " disconnected; " .. err_code); Perun.LogEvent("disconnect", "Player " .. net.get_player_info(id, "name") .. " disconnected; " .. err_code,net.get_player_info(id, "name"),err_code);
end end
Perun.onSimulationFrame = function() Perun.onSimulationFrame = function()
@@ -347,15 +464,11 @@ Perun.onSimulationFrame = function()
Perun.UpdateStatus() Perun.UpdateStatus()
end end
end end
Perun.onPlayerStart = function (id) Perun.onPlayerStart = function (id)
net.send_chat(Perun.MOTD_L1, id); net.send_chat_to(Perun.MOTD_L1, id);
net.send_chat(Perun.MOTD_L2, id); net.send_chat_to(Perun.MOTD_L2, id);
end end
Perun.onPlayerTrySendChat = function (playerID, msg, all) Perun.onPlayerTrySendChat = function (playerID, msg, all)
@@ -367,47 +480,66 @@ Perun.onPlayerTrySendChat = function (playerID, msg, all)
end end
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7) Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
if eventName == "friendly_fire" then if eventName == "friendly_fire" then
--"friendly_fire", playerID, weaponName, victimPlayerID --"friendly_fire", playerID, weaponName, victimPlayerID
if arg2 == nil then if arg2 == nil then
arg2 = Gun arg2 = "Cannon"
end end
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.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,nil,nil);
Perun.LogStats(arg1); Perun.LogStatsCount(arg1,"friendly_fire",DCS.getUnitType(arg1))
elseif eventName == "mission_end" then elseif eventName == "mission_end" then
--"mission_end", winner, msg --"mission_end", winner, msg
Perun.LogEvent(eventName,"Mission finished, winner " .. arg1 .. " message: " .. arg2); Perun.LogEvent(eventName,"Mission finished, winner " .. arg1 .. " message: " .. arg2,nil,nil);
elseif eventName == "kill" then elseif eventName == "kill" then
--"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName --"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName
if net.get_player_info(arg4, "name") ~= nil then if net.get_player_info(arg4, "name") ~= nil then
_temp = " player ".. net.get_player_info(arg4, "name") .." "; _temp = " player ".. net.get_player_info(arg4, "name") .." ";
Perun.LogStats(arg4);
Perun.LogStats(arg4);
else else
_temp = " AI "; _temp = " AI ";
end end
if net.get_player_info(arg1, "name") ~= nil then if net.get_player_info(arg1, "name") ~= nil then
_temp2 = " player ".. net.get_player_info(arg1, "name") .." "; _temp2 = " player ".. net.get_player_info(arg1, "name") .." ";
Perun.LogStats(arg1);
if Perun.GetCategory(arg5) == "Planes" then
Perun.LogStatsCount(arg1,"kill_Planes",arg2)
elseif Perun.GetCategory(arg5) == "Helicopters" then
Perun.LogStatsCount(arg1,"kill_Helicopters",arg2)
elseif Perun.GetCategory(arg5) == "Ships" then
Perun.LogStatsCount(arg1,"kill_Ships",arg2)
elseif Perun.GetCategory(arg5) == "Air Defence" then
Perun.LogStatsCount(arg1,"kill_Air_Defence",arg2)
elseif Perun.GetCategory(arg5) == "Unarmed" then
Perun.LogStatsCount(arg1,"kill_Unarmed",arg2)
elseif Perun.GetCategory(arg5) == "Armor" then
Perun.LogStatsCount(arg1,"kill_Armor",arg2)
elseif Perun.GetCategory(arg5) == "Infantry" then
Perun.LogStatsCount(arg1,"kill_Infantry",arg2)
else
Perun.LogStatsCount(arg1,"kill_Other",arg2)
end
if net.get_player_info(arg4, "name") ~= nil and killerSide ~= victimSide then
Perun.LogStatsCount(arg1,"kill_PvP",arg2)
end
else else
_temp2 = " AI "; _temp2 = " AI ";
end end
if arg7 == nil then if arg7 == nil then
arg7 = Gun arg7 = "Cannon"
end end
Perun.LogEvent(eventName,Perun.SideID2Name(arg3) .. _temp2 .. " in " .. arg2 .. " killed " .. Perun.SideID2Name(arg6) .. _temp .. " in " .. arg5 .. " using " .. arg7 .. " [".. Perun.GetCategory(arg5).."]"); Perun.LogEvent(eventName,Perun.SideID2Name(arg3) .. _temp2 .. " in " .. arg2 .. " killed " .. Perun.SideID2Name(arg6) .. _temp .. " in " .. arg5 .. " 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
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " killed himself"); Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " killed himself",nil,nil);
Perun.LogStats(arg1); Perun.LogStats(arg1);
elseif eventName == "change_slot" then elseif eventName == "change_slot" then
@@ -420,27 +552,26 @@ Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
end end
Perun.LogEvent(eventName,Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " changed slot to " .. _temp); 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); Perun.LogStatsCount(arg1,"init",_temp,nil,nil)
elseif eventName == "connect" then elseif eventName == "connect" then
--"connect", playerID, name --"connect", playerID, name
Perun.LogLogin(arg1); Perun.LogLogin(arg1);
Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected"); Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected",nil,nil);
elseif eventName == "disconnect" then elseif eventName == "disconnect" then
--"disconnect", playerID, name, playerSide, reason_code --"disconnect", playerID, name, playerSide, reason_code
Perun.LogEvent(eventName, Perun.SideID2Name(arg3) .. " player " ..net.get_player_info(arg1, "name") .. " disconnected"); Perun.LogEvent(eventName, Perun.SideID2Name(arg3) .. " player " ..net.get_player_info(arg1, "name") .. " disconnected",nil,nil);
Perun.LogStats(arg1); Perun.LogStats(arg1);
elseif eventName == "crash" then elseif eventName == "crash" then
--"crash", playerID, unit_missionID --"crash", playerID, unit_missionID
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " crashed in " .. DCS.getUnitType(arg2)); Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " crashed in " .. DCS.getUnitType(arg2),nil,nil);
Perun.LogStats(arg1); Perun.LogStatsCount(arg1,"crash",DCS.getUnitType(arg2))
elseif eventName == "eject" then elseif eventName == "eject" then
--"eject", playerID, unit_missionID --"eject", playerID, unit_missionID
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " ejected " .. DCS.getUnitType(arg2)); Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " ejected " .. DCS.getUnitType(arg2),nil,nil);
Perun.LogStats(arg1); Perun.LogStatsCount(arg1,"eject",DCS.getUnitType(arg2));
elseif eventName == "takeoff" then elseif eventName == "takeoff" then
--"takeoff", playerID, unit_missionID, airdromeName --"takeoff", playerID, unit_missionID, airdromeName
@@ -450,8 +581,18 @@ Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
_temp = ""; _temp = "";
end 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.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " took off in ".. DCS.getUnitType(arg2) .. _temp,arg3,nil);
Perun.LogStats(arg1);
if string.find(arg3, "FARP") then
Perun.LogStatsCount(arg1,"tookoff_FARP",DCS.getUnitType(arg2))
elseif string.find(arg3, "CVN-74 John C. Stennis") or string.find(arg3, "LHA-1 Tarawa") then
Perun.LogStatsCount(arg1,"tookoff_SHIP",DCS.getUnitType(arg2))
elseif arg3 then
Perun.LogStatsCount(arg1,"tookoff_AIRFIELD",DCS.getUnitType(arg2))
else
-- do nothing
end
elseif eventName == "landing" then elseif eventName == "landing" then
--"landing", playerID, unit_missionID, airdromeName --"landing", playerID, unit_missionID, airdromeName
if arg3 then if arg3 then
@@ -460,15 +601,24 @@ Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
_temp =""; _temp ="";
end 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.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " landed in " .. DCS.getUnitType(arg2).. _temp,arg3,nil);
Perun.LogStats(arg1);
if string.find(arg3, "FARP") then
Perun.LogStatsCount(arg1,"landing_FARP",DCS.getUnitType(arg2))
elseif string.find(arg3, "CVN-74 John C. Stennis") or string.find(arg3, "LHA-1 Tarawa") then
Perun.LogStatsCount(arg1,"landing_SHIP",DCS.getUnitType(arg2))
elseif arg3 then
Perun.LogStatsCount(arg1,"landing_AIRFIELD",DCS.getUnitType(arg2))
else
-- do nothing
end
elseif eventName == "pilot_death" then elseif eventName == "pilot_death" then
--"pilot_death", playerID, unit_missionID --"pilot_death", playerID, unit_missionID
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " in " .. DCS.getUnitType(arg2) .. " died"); Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " in " .. DCS.getUnitType(arg2) .. " died",nil,nil);
Perun.LogStats(arg1); Perun.LogStatsCount(arg1,"pilot_death",DCS.getUnitType(arg2))
else else
Perun.LogEvent(eventName,"Unknown event type"); Perun.LogEvent(eventName,"Unknown event type",nil,nil);
end end
end end

View File

@@ -15,6 +15,7 @@ internal class DatabaseController
string strUDPFrameTimestamp = strUDPFrame.timestamp; string strUDPFrameTimestamp = strUDPFrame.timestamp;
string strUDPFrameInstance = strUDPFrame.instance; string strUDPFrameInstance = strUDPFrame.instance;
string strUDPFramePayload = ""; string strUDPFramePayload = "";
string strUDPFramePayload_Perun = "";
string strSQLQueryTxt = ""; string strSQLQueryTxt = "";
@@ -49,19 +50,20 @@ internal class DatabaseController
// Add entry to event log // Add entry to event log
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.log_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");"; strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.log_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ";"; strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ";";
strSQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ( NULL, '" + strUDPFrame.payload.log_datetime + "', '" + strUDPFrame.payload.log_type + "', '" + strUDPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "'));"; strSQLQueryTxt += "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 ('"+ strUDPFrame.payload.log_arg_1 + "','"+ strUDPFrame.payload.log_arg_2 + "', NULL, '" + strUDPFrame.payload.log_datetime + "', '" + strUDPFrame.payload.log_type + "', '" + strUDPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "'));";
} }
else if (strUDPFrameType == "52") else if (strUDPFrameType == "52")
{ {
// Update user stats // Update user stats
strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload.stat_data); // Deserialize payload strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload.stat_data_dcs); // Deserialize payload
strUDPFramePayload_Perun = JsonConvert.SerializeObject(strUDPFrame.payload.stat_data_perun); // Deserialize payload
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.stat_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");"; strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.stat_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + " ;"; strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + " ;";
strSQLQueryTxt += "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.stat_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "');"; strSQLQueryTxt += "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.stat_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "');";
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated`=" + strUDPFrameTimestamp + " WHERE `pe_DataPlayers_ucid`='" + strUDPFrame.payload.stat_ucid + "';"; strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated`=" + strUDPFrameTimestamp + " WHERE `pe_DataPlayers_ucid`='" + strUDPFrame.payload.stat_ucid + "';";
strSQLQueryTxt += "INSERT INTO `pe_LogStats` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`) SELECT (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') 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` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "') );"; strSQLQueryTxt += "INSERT INTO `pe_LogStats` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`,`pe_LogStats_type`) SELECT (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "'),'" + strUDPFrame.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` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "' AND `pe_LogStats_type`='"+ strUDPFrame.payload.stat_data_type + "') );";
strSQLQueryTxt += "UPDATE `pe_LogStats` SET `pe_LogStats_datetime`='" + strUDPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'),`pe_LogStats_debug`=JSON_QUOTE('" + strUDPFramePayload + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "');"; strSQLQueryTxt += "UPDATE `pe_LogStats` SET `ps_kills`="+ strUDPFrame.payload.stat_data_perun.ps_kills + ",`ps_pvp`=" + strUDPFrame.payload.stat_data_perun.ps_pvp + ",`ps_deaths`=" + strUDPFrame.payload.stat_data_perun.ps_deaths + ",`ps_ejections`=" + strUDPFrame.payload.stat_data_perun.ps_ejections + ",`ps_crashes`=" + strUDPFrame.payload.stat_data_perun.ps_crashes + ",`ps_teamkills`=" + strUDPFrame.payload.stat_data_perun.ps_teamkills + ",`ps_kills_planes`=" + strUDPFrame.payload.stat_data_perun.ps_kills_planes + ",`ps_kills_helicopters`=" + strUDPFrame.payload.stat_data_perun.ps_kills_helicopters + ",`ps_kills_air_defense`=" + strUDPFrame.payload.stat_data_perun.ps_kills_air_defense + ",`ps_kills_armor`=" + strUDPFrame.payload.stat_data_perun.ps_kills_armor + ",`ps_kills_unarmed`=" + strUDPFrame.payload.stat_data_perun.ps_kills_unarmed + ",`ps_kills_infantry`=" + strUDPFrame.payload.stat_data_perun.ps_kills_infantry + ",`ps_kills_ships`=" + strUDPFrame.payload.stat_data_perun.ps_kills_ships + ",`ps_kills_other`=" + strUDPFrame.payload.stat_data_perun.ps_kills_other + ",`ps_airfield_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_airfield_takeoffs + ",`ps_airfield_landings`=" + strUDPFrame.payload.stat_data_perun.ps_airfield_landings + ",`ps_ship_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_ship_takeoffs + ",`ps_ship_landings`=" + strUDPFrame.payload.stat_data_perun.ps_ship_landings + ",`ps_farp_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_farp_takeoffs + ",`ps_farp_landings`=" + strUDPFrame.payload.stat_data_perun.ps_farp_landings + ", `pe_LogStats_perun` = JSON_QUOTE('" + strUDPFramePayload_Perun + "'), `pe_LogStats_datetime`='" + strUDPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'),`pe_LogStats_dcs`=JSON_QUOTE('" + strUDPFramePayload + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "') AND `pe_LogStats_type`='" + strUDPFrame.payload.stat_data_type + "';";
} }
else if (strUDPFrameType == "53") else if (strUDPFrameType == "53")
{ {

View File

@@ -33,7 +33,7 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>Perun.htm</WebPage> <WebPage>Perun.htm</WebPage>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>0.4.1.%2a</ApplicationVersion> <ApplicationVersion>0.5.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>

View File

@@ -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.4.0.0")] [assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")] [assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]

View File

@@ -1,4 +1,5 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0; SET AUTOCOMMIT = 0;
START TRANSACTION; START TRANSACTION;
@@ -29,7 +30,8 @@ CREATE TABLE IF NOT EXISTS `pe_DataMissionHashes` (
`pe_DataMissionHashes_hash` varchar(150) NOT NULL, `pe_DataMissionHashes_hash` varchar(150) NOT NULL,
`pe_DataMissionHashes_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `pe_DataMissionHashes_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
@@ -78,7 +80,9 @@ CREATE TABLE IF NOT EXISTS `pe_LogChat` (
`pe_LogChat_playerid` varchar(100) NOT NULL, `pe_LogChat_playerid` varchar(100) NOT NULL,
`pe_LogChat_msg` text NOT NULL, `pe_LogChat_msg` text NOT NULL,
`pe_LogChat_all` varchar(10) NOT NULL, `pe_LogChat_all` varchar(10) NOT NULL,
PRIMARY KEY (`pe_LogChat_id`) PRIMARY KEY (`pe_LogChat_id`),
KEY `pe_LogChat_missionhash_id` (`pe_LogChat_missionhash_id`),
KEY `pe_LogChat_playerid` (`pe_LogChat_playerid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
@@ -94,7 +98,10 @@ CREATE TABLE IF NOT EXISTS `pe_LogEvent` (
`pe_LogEvent_datetime` datetime DEFAULT CURRENT_TIMESTAMP, `pe_LogEvent_datetime` datetime DEFAULT CURRENT_TIMESTAMP,
`pe_LogEvent_type` varchar(100) NOT NULL, `pe_LogEvent_type` varchar(100) NOT NULL,
`pe_LogEvent_content` text NOT NULL, `pe_LogEvent_content` text NOT NULL,
PRIMARY KEY (`pe_LogEvent_id`) `pe_LogEvent_arg1` varchar(150) DEFAULT NULL,
`pe_LogEvent_arg2` varchar(150) DEFAULT NULL,
PRIMARY KEY (`pe_LogEvent_id`),
KEY `pe_LogEvent_missionhash_id` (`pe_LogEvent_missionhash_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
@@ -111,7 +118,8 @@ CREATE TABLE IF NOT EXISTS `pe_LogLogins` (
`pe_LogLogins_playerid` bigint(20) DEFAULT NULL, `pe_LogLogins_playerid` bigint(20) DEFAULT NULL,
`pe_LogLogins_name` varchar(150) NOT NULL, `pe_LogLogins_name` varchar(150) NOT NULL,
`pe_LogLogins_ip` varchar(100) NOT NULL, `pe_LogLogins_ip` varchar(100) NOT NULL,
PRIMARY KEY (`pe_LogLogins_id`) PRIMARY KEY (`pe_LogLogins_id`),
KEY `pe_LogLogins_playerid` (`pe_LogLogins_playerid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
@@ -126,9 +134,33 @@ CREATE TABLE IF NOT EXISTS `pe_LogStats` (
`pe_LogStats_missionhash_id` bigint(20) DEFAULT NULL, `pe_LogStats_missionhash_id` bigint(20) DEFAULT NULL,
`pe_LogStats_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `pe_LogStats_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pe_LogStats_playerid` bigint(20) DEFAULT NULL, `pe_LogStats_playerid` bigint(20) DEFAULT NULL,
`pe_LogStats_type` varchar(50) DEFAULT NULL,
`pe_LogStats_debug` text, `pe_LogStats_debug` text,
`pe_LogStats_dcs` text,
`pe_LogStats_perun` text,
`ps_kills` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_pvp` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_deaths` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_ejections` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_crashes` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_teamkills` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_kills_planes` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_kills_helicopters` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_kills_air_defense` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_kills_armor` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_kills_unarmed` 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_other` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_airfield_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_airfield_landings` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_ship_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_ship_landings` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_farp_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0',
`ps_farp_landings` int(11) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`pe_LogStats_id`), PRIMARY KEY (`pe_LogStats_id`),
UNIQUE KEY `UNIQUE_STATS_PER_MISSION_AND_UCID` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`) USING BTREE UNIQUE KEY `UNIQUE_STATS_PER_MISSION_AND_UCID_AND_TYPE` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`,`pe_LogStats_type`) USING BTREE,
KEY `pe_LogStats_type` (`pe_LogStats_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT; COMMIT;