Skip to content

Commit

Permalink
Functionnal Linux version
Browse files Browse the repository at this point in the history
Not tested on windows !
  • Loading branch information
Janus committed May 29, 2016
1 parent e9c0708 commit bdeec9c
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 647 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
*.dll

# =========================
# Operating System Files
# =========================
Expand Down
22 changes: 22 additions & 0 deletions Dynmap.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dynmap", "Dynmap\Dynmap.csproj", "{3A5AF8BC-41A6-46A3-8677-A6B54B278B68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3A5AF8BC-41A6-46A3-8677-A6B54B278B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A5AF8BC-41A6-46A3-8677-A6B54B278B68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A5AF8BC-41A6-46A3-8677-A6B54B278B68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A5AF8BC-41A6-46A3-8677-A6B54B278B68}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
82 changes: 47 additions & 35 deletions Dynmap.cs → Dynmap/Dynmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public class DynmapConfiguration : IRocketPluginConfiguration
public string PrivateKey;
public int syncInterval;
public string WebCoreAddress;
public bool displayInChat;

public void LoadDefaults()
{
PrivateKey = "MySecretPrivateKey";
syncInterval = 5000;
WebCoreAddress = "http://localhost";
displayInChat = true;
}
}

Expand All @@ -39,7 +41,7 @@ public class Dynmap : RocketPlugin<DynmapConfiguration>
public static Dynmap Instance;
public List<CSteamID> Nicks = new List<CSteamID>();
public Timer myTimer;
public string directory = Directory.GetCurrentDirectory();
public string directory = System.IO.Directory.GetCurrentDirectory();
public string[] maps;
public string sendMaps;
public string data = string.Empty;
Expand All @@ -58,11 +60,15 @@ public class Dynmap : RocketPlugin<DynmapConfiguration>


protected override void Load()
{
{
Logger.Log("Starting Dynmap ...");

//Načtení privátního klíče a složky Maps
PrivateKey = Configuration.Instance.PrivateKey;
maps = Directory.GetDirectories(directory + @"/../../../Maps");

maps = System.IO.Directory.GetDirectories(System.IO.Path.GetFullPath(directory + @"/../../../Maps"));
foreach(string map in maps){
Logger.Log("Finding maps : " + map);
}

//Vypsání map na serveru
foreach (string splitMap in maps)
Expand Down Expand Up @@ -94,8 +100,8 @@ protected override void Load()
}

//Deaktivuje plugin, pokud se PrivateKey neshoduje
if(output == "Error.PrivateKeyNotMatch")

if (output == "Error.PrivateKeyNotMatch")
{
Logger.LogError("Priavte keys in dynmap-config.php and in Dynmap.configuration.xml doesn't match!");
Logger.LogError("Unloading plugin!");
Expand All @@ -114,14 +120,14 @@ protected override void Load()
//Generování TransferID

RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] rndNumber = new byte[20];
byte[] rndNumber = new byte[20];
rng.GetBytes(rndNumber);
string TransferID = Convert.ToBase64String(rndNumber);

//TransferID
TransferID = TransferID.Remove(TransferID.Length - 1);


//Odeslání TransferID na server
url = Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server";
string TransferIDdata = "TransferID=" + Uri.EscapeDataString(TransferID) + "&privatekey=" + PrivateKey;
Expand All @@ -146,28 +152,34 @@ protected override void Load()
output = reader.ReadToEnd();
}

string mapName = uploadMaps[o].Split('/')[uploadMaps[o].Split('/').Length - 1];
//Nahrání souborů map na server
System.Net.WebClient Client = new System.Net.WebClient ();
System.Net.WebClient Client = new System.Net.WebClient();
Client.Headers.Add("Content-Type", "binary/octet-stream");
byte[] result = Client.UploadFile(Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server&do=uploadfile&TransferID=" + Uri.EscapeDataString(TransferID) + "&mapname=" + uploadMaps[o], "POST", directory + @"/../../../Maps/" + uploadMaps[o] + @"/Map.png");
String s = System.Text.Encoding.UTF8.GetString (result,0,result.Length);
try {
byte[] result = Client.UploadFile(Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server&do=uploadfile&TransferID=" + Uri.EscapeDataString(TransferID) + "&mapname=" + Uri.EscapeDataString(mapName), "POST", uploadMaps[o] + @"/Map.png");
String s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);

if (s == "Error.UploadDone")
{
Logger.LogWarning("Uploaded " + uploadMaps[o]);
if (s == "Error.UploadDone")
{
Logger.LogWarning("Uploaded " + uploadMaps[o]);
}
else if (s == "1Error.UploadFailed")
{
Logger.LogError("Uploading " + uploadMaps[o] + " failed because the uploaded file exceeds the upload_max_filesize directive in php.ini.");
Logger.LogError("See http://php.net/manual/en/ini.core.php#ini.upload-max-filesize for further information!");
}
else
{
Logger.LogError("Uploading " + uploadMaps[o] + " failed!");
}
} catch(System.Net.WebException e) {
Logger.LogException(e);
}
else if (s == "1Error.UploadFailed")
{
Logger.LogError("Uploading " + uploadMaps[o] + " failed because the uploaded file exceeds the upload_max_filesize directive in php.ini.");
Logger.LogError("See http://php.net/manual/en/ini.core.php#ini.upload-max-filesize for further information!");
}
else
{
Logger.LogError("Uploading " + uploadMaps[o] + " failed!");
}

}
if (o == uploadMaps.Length - 1) { Logger.LogWarning("Uploading done!");};
if (o == uploadMaps.Length - 1) { Logger.LogWarning("Uploading done!"); };

}

//Časovač odesílající data o pozici na server
Expand All @@ -187,14 +199,14 @@ protected override void Load()

//Přidání hráčů do listu při připojení na server
U.Events.OnPlayerConnected += (UnturnedPlayer player) =>
{
Nicks.Add(player.CSteamID);
};
{
Nicks.Add(player.CSteamID);
};
//Odebrání hráčů z listu při odpojení ze serveru
U.Events.OnPlayerDisconnected += (UnturnedPlayer player) =>
{
Nicks.Remove(player.CSteamID);
};
{
Nicks.Remove(player.CSteamID);
};
U.Events.OnShutdown += () =>
{
shutdown = true;
Expand Down Expand Up @@ -222,14 +234,14 @@ private void ShowCords()
characterName = player.CharacterName.Replace(";", "&#59").Replace("[", "&#91").Replace("]", "&#93").Replace("=", "&#61");
rotation = Convert.ToInt32(player.Rotation);
if (player.IsAdmin == true) { playerStatus = "admin"; } else if (player.IsPro == true) { playerStatus = "pro"; } else { playerStatus = "player"; }
UnturnedChat.Say(player, player.Position + "=Position");
if (Configuration.Instance.displayInChat == true) { UnturnedChat.Say(player, player.Position + "=Position"); }
if (player.Features.VanishMode == false) { data = data + "[Charactername=" + characterName + ";CSteamID=" + player.CSteamID + ";Position=" + player.Position + ";Rotation=" + rotation + ";PlayerStatus=" + playerStatus + "]"; };
}

//Odešle data na server
if (data != string.Empty || firstrun == true)
{
url = Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server";
url = Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server";
postData = "map=" + SDG.Unturned.Provider.map + "&data=" + Uri.EscapeDataString(data) + "&privatekey=" + PrivateKey;
if (shutdown == true) { postData = "map=" + SDG.Unturned.Provider.map + "&privatekey=" + PrivateKey; };
var post = Encoding.ASCII.GetBytes(postData);
Expand Down
72 changes: 72 additions & 0 deletions Dynmap/Dynmap.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3A5AF8BC-41A6-46A3-8677-A6B54B278B68}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dynmap</RootNamespace>
<AssemblyName>Dynmap</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>References\RocketMod\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>References\Unturned\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Rocket.API">
<HintPath>References\RocketMod\Rocket.API.dll</HintPath>
</Reference>
<Reference Include="Rocket.Core">
<HintPath>References\RocketMod\Rocket.Core.dll</HintPath>
</Reference>
<Reference Include="Rocket.Unturned">
<HintPath>References\RocketMod\Rocket.Unturned.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>References\Unturned\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Dynmap.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
36 changes: 36 additions & 0 deletions Dynmap/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Dynmap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Dynmap")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]

// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("3a5af8bc-41a6-46a3-8677-a6b54b278b68")]

// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
7 changes: 7 additions & 0 deletions Dynmap/References/RocketMod/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Download RocketMod from https://rocketmod.net/get-rocket

Copy/Paste file from RocketMod to this folder :
_Assembly-CSharp.dll
_Rocket.API.dll
_Rocket.Core.dll
_Rocket.Unturned.dll
6 changes: 6 additions & 0 deletions Dynmap/References/Unturned/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copy/Paste file from you Unturned game.
Files are located : Unturned\Unturned_Data\Managed

Copy/Paste file from RocketMod to this folder :
_Assembly-CSharp-firstpass.dll
_UnityEngine.dll
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Before starting Solution, please read the README files in References.
8 changes: 0 additions & 8 deletions dynmap-config.php

This file was deleted.

Loading

0 comments on commit bdeec9c

Please sign in to comment.