Show username (if given) and reason (if given) in log files, when disconnecting users before they have completed the login process.

This commit is contained in:
UnknownShadow200 2016-08-13 21:22:08 +10:00
parent 100111037a
commit 00b43d8305
4 changed files with 45 additions and 57 deletions

View File

@ -15,12 +15,10 @@
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Timers;
using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
namespace MCGalaxy.Games
{

View File

@ -392,7 +392,6 @@ namespace MCGalaxy.Games
foreach (player p in Players)
{
Player.Message(p.p, Message);
}
}
catch { };
@ -668,14 +667,11 @@ namespace MCGalaxy.Games
catch { }
}
public bool Finished()
{
public bool Finished() {
if (GameMode == TntWarsGameMode.TDM && (RedScore >= ScoreLimit || BlueScore >= ScoreLimit))
{
return true;
}
if (GameMode == TntWarsGameMode.FFA)
{
if (GameMode == TntWarsGameMode.FFA) {
try
{
if (Players.Any(p => p.Score >= ScoreLimit))
@ -685,20 +681,12 @@ namespace MCGalaxy.Games
}
catch { }
}
if (PlayingPlayers() <= 1)
{
return true;
}
if (GameStatus == TntWarsGameStatus.Finished)
{
return true;
}
return false;
if (PlayingPlayers() <= 1) return true;
return GameStatus == TntWarsGameStatus.Finished;
}
//enums
public enum TntWarsGameStatus : int
{
public enum TntWarsGameStatus {
WaitingForPlayers = 0,
AboutToStart = 1,
GracePeriod = 2,
@ -706,14 +694,12 @@ namespace MCGalaxy.Games
Finished = 4
}
public enum TntWarsGameMode : int
{
public enum TntWarsGameMode {
FFA = 0,
TDM = 1
}
public enum TntWarsDifficulty : int
{
public enum TntWarsDifficulty {
Easy = 0, //2 Hits to die, Tnt has long delay
Normal = 1, //2 Hits to die, Tnt has normal delay
Hard = 2, //1 Hit to die, Tnt has short delay
@ -761,8 +747,7 @@ namespace MCGalaxy.Games
public bool CheckAllSetUp(Player p, bool ReturnErrors = false, bool TellPlayerOnSuccess = true)
{
if (lvl != null
&& GameStatus == 0)
if (lvl != null && GameStatus == 0)
{
if (GameList.Any(g => g.lvl == this.lvl && g != this))
{
@ -810,10 +795,7 @@ namespace MCGalaxy.Games
public static TntWarsGame GetTntWarsGame(Player p)
{
TntWarsGame it = TntWarsGame.Find(p.level);
if (it != null)
{
return it;
}
if (it != null) return it;
it = FindFromGameNumber(p.CurrentTntGameNumber);
return it;
}

View File

@ -294,7 +294,13 @@ namespace MCGalaxy {
if (!loggedIn) {
connections.Remove(this);
RemoveFromPending();
Server.s.Log(ip + " disconnected.");
string user = String.IsNullOrEmpty(name) ? ip : name + " (" + ip + ")";
string msg = discMsg ?? kickMsg;
if (String.IsNullOrEmpty(msg))
Server.s.Log(user + " disconnected.");
else
Server.s.Log(user + " disconnected. (" + msg + ")");
return;
}
@ -308,21 +314,7 @@ namespace MCGalaxy {
}
Entities.DespawnEntities(this, false);
if (discMsg != null) {
string leavem = "&c- " + FullName + " %S" + discMsg;
const LevelPermission perm = LevelPermission.Guest;
if (group.Permission > perm || (Server.guestLeaveNotify && group.Permission <= perm)) {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (Entities.CanSee(pl, this)) Player.Message(pl, leavem);
}
}
Server.s.Log(name + " disconnected (" + discMsg + ").");
} else {
totalKicked++;
SendChatFrom(this, "&c- " + FullName + " %Skicked (" + kickMsg + "%S).", false);
Server.s.Log(name + " kicked (" + kickMsg + ").");
}
SendDisconnectMessage(discMsg, kickMsg);
try { save(); }
catch ( Exception e ) { Server.ErrorLog(e); }
@ -343,6 +335,24 @@ namespace MCGalaxy {
}
}
void SendDisconnectMessage(string discMsg, string kickMsg) {
if (discMsg != null) {
string leavem = "&c- " + FullName + " %S" + discMsg;
const LevelPermission perm = LevelPermission.Guest;
if (group.Permission > perm || (Server.guestLeaveNotify && group.Permission <= perm)) {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (Entities.CanSee(pl, this)) Player.Message(pl, leavem);
}
}
Server.s.Log(name + " disconnected (" + discMsg + ").");
} else {
totalKicked++;
SendChatFrom(this, "&c- " + FullName + " %Skicked (" + kickMsg + "%S).", false);
Server.s.Log(name + " kicked (" + kickMsg + ").");
}
}
public static void SaveUndo(Player p) {
try {
UndoFile.SaveUndo(p);

View File

@ -15,13 +15,11 @@
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using MCGalaxy.SQL;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using MCGalaxy.SQL;
namespace MCGalaxy {
public static partial class Backup {