some of these are meant for previous commit

assigned groups colors!
!find now reports the user's group
ban appeal listed by _website
group help commands so not to clog up the chat
updated stats calculation
speed up rcon output 0.8 -> 0.56
fixed logfile not flushing
This commit is contained in:
RaidMax 2015-03-11 20:25:14 -05:00
parent c7f8b0591b
commit ef80a565cb
12 changed files with 344 additions and 38 deletions

63
.gitattributes vendored Normal file
View File

@ -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

View File

@ -323,7 +323,7 @@ namespace IW4MAdmin
E.Target.setLevel(newPerm); E.Target.setLevel(newPerm);
E.Target.Tell("Congratulations! You have been promoted to ^3" + newPerm); E.Target.Tell("Congratulations! You have been promoted to ^3" + newPerm);
E.Origin.Tell(E.Target.getName() + " was successfully promoted!"); E.Origin.Tell(E.Target.getName() + " was successfully promoted!");
//NEEED TO mOVE //NEEED TO MOVE
E.Owner.DB.updatePlayer(E.Target); E.Owner.DB.updatePlayer(E.Target);
} }
@ -471,7 +471,11 @@ namespace IW4MAdmin
if (E.Target == null) 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)); 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 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())); 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) foreach (Stats S in Top)
{ {
Player P = E.Owner.DB.findPlayers(S.Kills); // BAD Player P = E.Owner.DB.findPlayers(S.Kills); // BAD
if (P != null) if (P != null && P.getLevel() != Player.Permission.Banned)
{ {
P.stats = S; P.stats = S;
TopP.Add(P); TopP.Add(P);

View File

@ -14,7 +14,7 @@ namespace IW4MAdmin
public void Send() 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); Handle.Request(URI);
} }

View File

@ -14,10 +14,15 @@ namespace IW4MAdmin
Skill = Math.Round(skill,2); Skill = Math.Round(skill,2);
} }
public void Update() public void updateKDR()
{ {
KDR = Math.Round((double)((double)Kills / (double)Deaths), 2); 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; public int Kills;

View File

@ -125,10 +125,10 @@ namespace IW4MAdmin
{ {
sendRCON(toSend.Peek()); sendRCON(toSend.Peek());
toSend.Dequeue(); toSend.Dequeue();
Utilities.Wait(0.85); Utilities.Wait(0.567);
} }
else else
Utilities.Wait(0.1); Utilities.Wait(0.01);
} }
} }

View File

@ -84,6 +84,11 @@ namespace IW4MAdmin
return clientnum; return clientnum;
} }
public int getMaxClients()
{
return maxClients;
}
//Returns list of all active bans (loaded at runtime) //Returns list of all active bans (loaded at runtime)
public List<Ban> getBans() public List<Ban> getBans()
{ {
@ -112,7 +117,7 @@ namespace IW4MAdmin
if (P.stats == null) if (P.stats == null)
{ {
stats.addPlayer(P); stats.addPlayer(P);
P.stats = new Stats(0, 0, 0, 0); P.stats = new Stats(0, 0, 0, 1);
} }
if(players[P.getClientNum()] == null) if(players[P.getClientNum()] == null)
@ -292,6 +297,7 @@ namespace IW4MAdmin
Thread eventQueue = new Thread(new ThreadStart(manageEventQueue)); Thread eventQueue = new Thread(new ThreadStart(manageEventQueue));
eventQueue.Start(); eventQueue.Start();
int timeFailed = 0;
long l_size = -1; long l_size = -1;
String[] lines = new String[8]; String[] lines = new String[8];
String[] oldLines = new String[8]; String[] oldLines = new String[8];
@ -381,40 +387,24 @@ namespace IW4MAdmin
{ {
try try
{ {
//get sv_hostname String[] infoResponse = RCON.responseSendRCON("getstatus");
String[] p = RCON.responseSendRCON("sv_hostname");
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; return false;
} }
p = p[1].Split('"'); infoResponse = infoResponse[1].Split('\\');
hostname = Utilities.stripColors(p[3].Substring(0, p[3].Length - 2).Trim()); mapname = infoResponse[20];
p = null; mapname = maps.Find(m => m.Name.Equals(mapname)).Alias;
//END hostname = Utilities.stripColors(infoResponse[32]);
IW_Ver = infoResponse[2];
Thread.Sleep(FLOOD_TIMEOUT); maxClients = Convert.ToInt32(infoResponse[6]);
Gametype = infoResponse[8];
//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);
//get _Website //get _Website
p = RCON.responseSendRCON("_Website"); String[] p = RCON.responseSendRCON("_Website");
if (p == null) if (p == null)
{ {
@ -570,9 +560,12 @@ namespace IW4MAdmin
if (E.Origin != null && E.Target != null && E.Origin.stats != null) if (E.Origin != null && E.Target != null && E.Origin.stats != null)
{ {
E.Origin.stats.Kills++; 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.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); maps.Add(map);
} }
} }
} }
else else
Log.Write("Maps configuration appears to be empty - skipping...", Log.Level.All); Log.Write("Maps configuration appears to be empty - skipping...", Log.Level.All);
} }
@ -829,6 +822,7 @@ namespace IW4MAdmin
public Database stats; public Database stats;
public Heartbeat HB; public Heartbeat HB;
public String Website; public String Website;
public String Gametype;
//Info //Info
private String IP; private String IP;
@ -844,6 +838,8 @@ namespace IW4MAdmin
private TimeSpan lastMessage; private TimeSpan lastMessage;
private int nextMessage; private int nextMessage;
private int errors = 0; private int errors = 0;
private String IW_Ver;
private int maxClients;
//Log stuff //Log stuff

View File

@ -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

View File

@ -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
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
: base()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// 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.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
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
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
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);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{119DA221-3EA7-432C-AAFC-782D94EA1ECF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Game_TEST</RootNamespace>
<AssemblyName>Game_TEST</AssemblyName>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Windows\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Windows\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Compile Include="Game1.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework">
<HintPath>$(MSBuildExtensionsPath)\..\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="Icon.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="Content\" />
</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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,26 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace Game_TEST
{
#if WINDOWS || LINUX
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using (var game = new Game1())
game.Run();
}
}
#endif
}

View File

@ -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")]