diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..1ff0c4230 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/Admin/Command.cs b/Admin/Command.cs index 8f183357e..661a36594 100644 --- a/Admin/Command.cs +++ b/Admin/Command.cs @@ -323,7 +323,7 @@ namespace IW4MAdmin E.Target.setLevel(newPerm); E.Target.Tell("Congratulations! You have been promoted to ^3" + newPerm); E.Origin.Tell(E.Target.getName() + " was successfully promoted!"); - //NEEED TO mOVE + //NEEED TO MOVE E.Owner.DB.updatePlayer(E.Target); } @@ -471,7 +471,11 @@ namespace IW4MAdmin if (E.Target == null) E.Origin.Tell(String.Format("^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", E.Origin.stats.Kills, E.Origin.stats.Deaths, E.Origin.stats.KDR, E.Origin.stats.Skill)); else + { + if (E.Target.stats == null) + E.Target.stats = E.Owner.stats.getStats(E.Target.getDBID()); E.Origin.Tell(String.Format("[^3{4}^7] ^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", E.Target.stats.Kills, E.Target.stats.Deaths, E.Target.stats.KDR, E.Target.stats.Skill, E.Target.getName())); + } } } @@ -487,7 +491,7 @@ namespace IW4MAdmin foreach (Stats S in Top) { Player P = E.Owner.DB.findPlayers(S.Kills); // BAD - if (P != null) + if (P != null && P.getLevel() != Player.Permission.Banned) { P.stats = S; TopP.Add(P); diff --git a/Admin/Heartbeat.cs b/Admin/Heartbeat.cs index 4f94ca0bc..b89fc8703 100644 --- a/Admin/Heartbeat.cs +++ b/Admin/Heartbeat.cs @@ -14,7 +14,7 @@ namespace IW4MAdmin public void Send() { - String URI = String.Format("http://raidmax.org/IW4M/Admin/heartbeat.php?address={0}&name={1}&map={2}&players={3}", Instance.getPort().ToString(), Instance.getName(), Instance.getMap(), Instance.getClientNum().ToString()); + String URI = String.Format("http://raidmax.org/IW4M/Admin/heartbeat.php?address={0}&name={1}&map={2}&players={3}", Instance.getPort().ToString(), Instance.getName(), Instance.getMap(), Instance.getClientNum().ToString() + '/' + Instance.getMaxClients().ToString()); Handle.Request(URI); } diff --git a/Admin/Player.cs b/Admin/Player.cs index c01c74ac9..4f310ef43 100644 --- a/Admin/Player.cs +++ b/Admin/Player.cs @@ -14,10 +14,15 @@ namespace IW4MAdmin Skill = Math.Round(skill,2); } - public void Update() + public void updateKDR() { KDR = Math.Round((double)((double)Kills / (double)Deaths), 2); - Skill = Math.Round((double)Kills * (((double)Kills / (double)Deaths) / 10), 2); + } + + public void updateSkill(double enemySkill) + { + Skill = (Math.Round((double)Kills * (((double)Kills / (double)Deaths) / 10), 2)); + Skill = Math.Round(Math.Log(Skill) * (enemySkill / 2) + (Math.Log(Deaths + 1) * 0.3) * 12, 2); } public int Kills; diff --git a/Admin/RCON.cs b/Admin/RCON.cs index 24a71d0e7..a0ae6edc1 100644 --- a/Admin/RCON.cs +++ b/Admin/RCON.cs @@ -125,10 +125,10 @@ namespace IW4MAdmin { sendRCON(toSend.Peek()); toSend.Dequeue(); - Utilities.Wait(0.85); + Utilities.Wait(0.567); } else - Utilities.Wait(0.1); + Utilities.Wait(0.01); } } diff --git a/Admin/Server.cs b/Admin/Server.cs index e635b9edc..070066f80 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -84,6 +84,11 @@ namespace IW4MAdmin return clientnum; } + public int getMaxClients() + { + return maxClients; + } + //Returns list of all active bans (loaded at runtime) public List getBans() { @@ -112,7 +117,7 @@ namespace IW4MAdmin if (P.stats == null) { stats.addPlayer(P); - P.stats = new Stats(0, 0, 0, 0); + P.stats = new Stats(0, 0, 0, 1); } if(players[P.getClientNum()] == null) @@ -292,6 +297,7 @@ namespace IW4MAdmin Thread eventQueue = new Thread(new ThreadStart(manageEventQueue)); eventQueue.Start(); + int timeFailed = 0; long l_size = -1; String[] lines = new String[8]; String[] oldLines = new String[8]; @@ -381,40 +387,24 @@ namespace IW4MAdmin { try { - //get sv_hostname - String[] p = RCON.responseSendRCON("sv_hostname"); + String[] infoResponse = RCON.responseSendRCON("getstatus"); - if (p == null) + if (infoResponse == null || infoResponse.Length < 2) { - Log.Write("Could not obtain server name!", Log.Level.All); + Log.Write("Could not get server status!", Log.Level.All); return false; } - p = p[1].Split('"'); - hostname = Utilities.stripColors(p[3].Substring(0, p[3].Length - 2).Trim()); - p = null; - //END - - Thread.Sleep(FLOOD_TIMEOUT); - - //get mapname - p = RCON.responseSendRCON("mapname"); - - if (p == null) - { - Log.Write("Could not obtain map name!", Log.Level.All); - return false; - } - - p = p[1].Split('"'); - mapname = Utilities.stripColors(p[3].Substring(0, p[3].Length - 2).Trim()); - p = null; - //END - - Thread.Sleep(FLOOD_TIMEOUT); + infoResponse = infoResponse[1].Split('\\'); + mapname = infoResponse[20]; + mapname = maps.Find(m => m.Name.Equals(mapname)).Alias; + hostname = Utilities.stripColors(infoResponse[32]); + IW_Ver = infoResponse[2]; + maxClients = Convert.ToInt32(infoResponse[6]); + Gametype = infoResponse[8]; //get _Website - p = RCON.responseSendRCON("_Website"); + String[] p = RCON.responseSendRCON("_Website"); if (p == null) { @@ -570,9 +560,12 @@ namespace IW4MAdmin if (E.Origin != null && E.Target != null && E.Origin.stats != null) { E.Origin.stats.Kills++; - E.Origin.stats.Update(); + E.Origin.stats.updateKDR(); + E.Origin.stats.updateSkill(E.Target.stats.Skill); + E.Target.stats.Deaths++; - E.Target.stats.Update(); + E.Target.stats.updateKDR(); + E.Target.stats.updateSkill(E.Origin.stats.Skill); } } @@ -728,7 +721,7 @@ namespace IW4MAdmin maps.Add(map); } } - } + } else Log.Write("Maps configuration appears to be empty - skipping...", Log.Level.All); } @@ -829,6 +822,7 @@ namespace IW4MAdmin public Database stats; public Heartbeat HB; public String Website; + public String Gametype; //Info private String IP; @@ -844,6 +838,8 @@ namespace IW4MAdmin private TimeSpan lastMessage; private int nextMessage; private int errors = 0; + private String IW_Ver; + private int maxClients; //Log stuff diff --git a/GAME/Game_TEST/Game_TEST.sln b/GAME/Game_TEST/Game_TEST.sln new file mode 100644 index 000000000..f2a42128f --- /dev/null +++ b/GAME/Game_TEST/Game_TEST.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Game_TEST", "Game_TEST\Game_TEST.csproj", "{119DA221-3EA7-432C-AAFC-782D94EA1ECF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {119DA221-3EA7-432C-AAFC-782D94EA1ECF}.Debug|x86.ActiveCfg = Debug|x86 + {119DA221-3EA7-432C-AAFC-782D94EA1ECF}.Debug|x86.Build.0 = Debug|x86 + {119DA221-3EA7-432C-AAFC-782D94EA1ECF}.Release|x86.ActiveCfg = Release|x86 + {119DA221-3EA7-432C-AAFC-782D94EA1ECF}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GAME/Game_TEST/Game_TEST/Game1.cs b/GAME/Game_TEST/Game_TEST/Game1.cs new file mode 100644 index 000000000..6d6fc5aca --- /dev/null +++ b/GAME/Game_TEST/Game_TEST/Game1.cs @@ -0,0 +1,91 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Storage; +using Microsoft.Xna.Framework.GamerServices; +#endregion + +namespace Game_TEST +{ + /// + /// This is the main type for your game + /// + public class Game1 : Game + { + GraphicsDeviceManager graphics; + SpriteBatch spriteBatch; + + public Game1() + : base() + { + graphics = new GraphicsDeviceManager(this); + Content.RootDirectory = "Content"; + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize() + { + // TODO: Add your initialization logic here + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch(GraphicsDevice); + + // TODO: use this.Content to load your game content here + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// all content. + /// + protected override void UnloadContent() + { + // TODO: Unload any non ContentManager content here + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update(GameTime gameTime) + { + if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) + Exit(); + + // TODO: Add your update logic here + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.CornflowerBlue); + + // TODO: Add your drawing code here + + base.Draw(gameTime); + } + } +} diff --git a/GAME/Game_TEST/Game_TEST/Game_TEST.csproj b/GAME/Game_TEST/Game_TEST/Game_TEST.csproj new file mode 100644 index 000000000..7ce64010f --- /dev/null +++ b/GAME/Game_TEST/Game_TEST/Game_TEST.csproj @@ -0,0 +1,63 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {119DA221-3EA7-432C-AAFC-782D94EA1ECF} + WinExe + Properties + Game_TEST + Game_TEST + 512 + + + x86 + true + full + false + bin\Windows\Debug\ + DEBUG;TRACE;WINDOWS + prompt + 4 + + + x86 + pdbonly + true + bin\Windows\Release\ + TRACE;WINDOWS + prompt + 4 + + + Icon.ico + + + + + + + + + $(MSBuildExtensionsPath)\..\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/GAME/Game_TEST/Game_TEST/Icon.ico b/GAME/Game_TEST/Game_TEST/Icon.ico new file mode 100644 index 000000000..13be62a66 Binary files /dev/null and b/GAME/Game_TEST/Game_TEST/Icon.ico differ diff --git a/GAME/Game_TEST/Game_TEST/Program.cs b/GAME/Game_TEST/Game_TEST/Program.cs new file mode 100644 index 000000000..b1572f623 --- /dev/null +++ b/GAME/Game_TEST/Game_TEST/Program.cs @@ -0,0 +1,26 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +#endregion + +namespace Game_TEST +{ +#if WINDOWS || LINUX + /// + /// The main class. + /// + public static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + using (var game = new Game1()) + game.Run(); + } + } +#endif +} diff --git a/GAME/Game_TEST/Game_TEST/Properties/AssemblyInfo.cs b/GAME/Game_TEST/Game_TEST/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..c1a40cb9c --- /dev/null +++ b/GAME/Game_TEST/Game_TEST/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Game_TEST")] +[assembly: AssemblyProduct("Game_TEST")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5c4ee4ad-a4b0-483e-a8e8-4cd17cfa4c2d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]