Skip to content

Commit

Permalink
Add random comments and remove one unnecessary use of Formatter.Valid…
Browse files Browse the repository at this point in the history
…Name
  • Loading branch information
UnknownShadow200 committed Oct 22, 2021
1 parent bf9296c commit dc92ff8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion MCGalaxy/Commands/Maintenance/CmdInfoSwap.cs
Expand Up @@ -36,7 +36,7 @@ public sealed class CmdInfoSwap : Command2 {
Group srcGroup = Group.GroupIn(src), dstGroup = Group.GroupIn(dst);
if (!CheckRank(p, data, src, srcGroup.Permission, "&T/InfoSwap&S", false)) return;
if (!CheckRank(p, data, dst, dstGroup.Permission, "&T/InfoSwap&S", false)) return;

SwapStats(src, dst);
SwapGroups(src, dst, srcGroup, dstGroup);
OnInfoSwapEvent.Call(src, dst);
Expand Down
1 change: 0 additions & 1 deletion MCGalaxy/Commands/World/PermissionCmds.cs
Expand Up @@ -79,7 +79,6 @@ public abstract class PermissionCmd : Command2 {
return false;
}

if (!Formatter.ValidName(p, name, "player")) return false;
name = PlayerInfo.FindMatchesPreferOnline(p, name);
if (name == null) return false;

Expand Down
3 changes: 3 additions & 0 deletions MCGalaxy/Database/PlayerDB.cs
Expand Up @@ -90,18 +90,21 @@ public static class PlayerDB {
}


/// <summary> Returns the fields of the row whose Name field caselessly equals the given name </summary>
public static PlayerData FindData(string name) {
string suffix = Database.Backend.CaselessWhereSuffix;
object raw = Database.ReadRows("Players", "*", null, PlayerData.Read,
"WHERE Name=@0" + suffix, name);
return (PlayerData)raw;
}

/// <summary> Returns the Name field of the row whose Name field caselessly equals the given name </summary>
public static string FindName(string name) {
string suffix = Database.Backend.CaselessWhereSuffix;
return Database.ReadString("Players", "Name", "WHERE Name=@0" + suffix, name);
}

/// <summary> Returns the IP field of the row whose Name field caselessly equals the given name </summary>
public static string FindIP(string name) {
string suffix = Database.Backend.CaselessWhereSuffix;
return Database.ReadString("Players", "IP", "WHERE Name=@0" + suffix, name);
Expand Down
11 changes: 7 additions & 4 deletions MCGalaxy/util/Extensions/DateExts.cs
Expand Up @@ -19,11 +19,11 @@
using System.Collections.Generic;
using MCGalaxy.SQL;

namespace MCGalaxy {

namespace MCGalaxy
{
/// <summary> Extension methods relating to dates. </summary>
public static class DateExts {

public static class DateExts
{
public static TimeSpan ParseOldDBTimeSpent(this string value) {
string[] parts = value.SplitSpaces();
return new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]),
Expand All @@ -37,12 +37,15 @@ public static class DateExts {
return DateTime.Parse(value);
}

/// <summary> Origin point in time for Unix time (Midnight January 1, 1970) </summary>
public static DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

public static DateTime FromUnixTime(this long offset) {
return UnixEpoch.AddTicks(offset * TimeSpan.TicksPerSecond);
}

/// <summary> Converts the given DateTime instance to Unix time </summary>
/// <remarks> Unix time is the number of seconds since Midnight January 1, 1970 </remarks>
public static long ToUnixTime(this DateTime time) {
return (long)(time.ToUniversalTime() - UnixEpoch).TotalSeconds;
}
Expand Down
15 changes: 11 additions & 4 deletions MCGalaxy/util/Math/Vectors.cs
Expand Up @@ -17,8 +17,11 @@
*/
using System;

namespace MCGalaxy.Maths {
public struct Vec3U16 : IEquatable<Vec3U16> {
namespace MCGalaxy.Maths
{
/// <summary> 3 component vector (unsigned 16 bit integer) </summary>
public struct Vec3U16 : IEquatable<Vec3U16>
{
public ushort X, Y, Z;
public static Vec3U16 Zero = new Vec3U16(0);
public static Vec3U16 MinVal = new Vec3U16(ushort.MinValue);
Expand Down Expand Up @@ -68,7 +71,9 @@ public struct Vec3U16 : IEquatable<Vec3U16> {
public override string ToString() { return X + ", " + Y + ", " + Z; }
}

public struct Vec3S32 : IEquatable<Vec3S32> {
/// <summary> 3 component vector (signed 32 bit integer) </summary>
public struct Vec3S32 : IEquatable<Vec3S32>
{
public int X, Y, Z;
public static Vec3S32 Zero = new Vec3S32(0);

Expand Down Expand Up @@ -163,7 +168,9 @@ public struct Vec3S32 : IEquatable<Vec3S32> {
}
}

public struct Vec3F32 : IEquatable<Vec3F32> {
/// <summary> 3 component vector (32 bit floating point) </summary>
public struct Vec3F32 : IEquatable<Vec3F32>
{
public float X, Y, Z;

public Vec3F32(float x, float y, float z) {
Expand Down
8 changes: 5 additions & 3 deletions MCGalaxy/util/UIHelpers.cs
Expand Up @@ -19,9 +19,11 @@
using System.Threading;
using MCGalaxy;

namespace MCGalaxy.UI {
public static class UIHelpers {

namespace MCGalaxy.UI
{
/// <summary> Common functionality for a CLI or GUI server console </summary>
public static class UIHelpers
{
static string lastCMD = "";
public static void HandleChat(string text) {
if (text != null) text = text.Trim();
Expand Down

0 comments on commit dc92ff8

Please sign in to comment.