I honestly couldn't think of what to make the title. This is
not really a fix for hacking. This is quite simply just a way I came up with to catch hackers easier.
Are you tired of having Unnamed hackers come on your server and having to manually search and delete/ban their account? Well I took it to myself to come up with a way to combat this problem.
I apologize for any poor code, I do not know much C#, only Java really.
What is happening in my code?
When a player enters a world there are a few checks I set up to allow entry into it. First it checks if you have chosen a name. If you have, it'll enter the world as if nothing happened as it should. It also checks a boolean we made to see if the world is in fact the nexus, cloth bazaar, tutorial, daily quest room or the limbo (which is a boolean for the tutorial I believe?). This pretty much means that Unnamed players can enter these areas without the security measure affecting them, so to speak.
Now, if they don't in fact have chosen a name and try to enter anywhere else like the Vault, they will get the following screen:
(Note: They will need to open the options interface and go back to home to get out of it)
Simple enough? I know this isn't a real fix but this is definitely worth doing if you don't want to configure a lot to get rid of unnamed accounts. This is also my first contribution to the rotmg pserver community so sorry if it's shit lol. Only been working on pservers for about a week >.<
Let's get to it.
Open the
World class found in the path
wServer -> realm -> World.cs
You're going to want to add this new boolean anywhere, preferably at the top of the class like so:
Code:
public abstract class World : IDisposable
{
public const int TUT_ID = -1;
public const int NEXUS_ID = -2;
//public const int RAND_REALM = -3;
public const int NEXUS_LIMBO = -3;
public const int VAULT_ID = -5;
public const int TEST_ID = -6;
public const int GAUNTLET = -7;
public const int WC = -8;
public const int ARENA = -9;
public const int GHALL = -10;
public const int MARKET = -11;
public const int PETYARD_ID = -12;
public const int DAILY_QUEST_ID = -13;
public const int GUILD_ID = -14;
protected static readonly ILog Log = LogManager.GetLogger(typeof(World));
public string ExtraVar = "Default";
private int entityInc;
private RealmManager manager;
private bool canBeClosed;
public bool validNewPlayerEntry()
{
return !(this is Nexus) && !(this is ClothBazaar) && !(this is Tutorial) && !(this is DailyQuestRoom) && !IsLimbo;
}
Okay, now search for the following (Still in World.cs):
public virtual int EnterWorld(Entity entity)
And you can replace the whole EnterWorld int with the following or if you like I made the changes in bold. Don't forget to add the closing bracket that's also bold.
Code:
public virtual int EnterWorld(Entity entity)
{
var player = entity as Player;
if (player != null)
{
if (player.NameChosen == true || ValidNewPlayerEntry() == false)
{
try
{
player.Id = GetNextEntityId();
entity.Init(this);
Players.TryAdd(player.Id, player);
PlayersCollision.Insert(player);
}
catch (Exception e)
{
Log.Error(e);
}
} else
{
player.SendError("You must choose a name in order to play the game!");
}
}
else
{
var enemy = entity as Enemy;
if (enemy != null)
{
enemy.Id = GetNextEntityId();
entity.Init(this);
Enemies.TryAdd(enemy.Id, enemy);
EnemiesCollision.Insert(enemy);
if (enemy.ObjectDesc.Quest)
Quests.TryAdd(enemy.Id, enemy);
}
else
{
var projectile = entity as Projectile;
if (projectile != null)
{
projectile.Init(this);
var prj = projectile;
Projectiles[new Tuple<int, byte>(prj.ProjectileOwner.Self.Id, prj.ProjectileId)] = prj;
}
else
{
var staticObject = entity as StaticObject;
if (staticObject != null)
{
staticObject.Id = GetNextEntityId();
staticObject.Init(this);
StaticObjects.TryAdd(staticObject.Id, staticObject);
if (entity is Decoy)
PlayersCollision.Insert(staticObject);
else
EnemiesCollision.Insert(staticObject);
}
else
{
var pet = entity as Pet;
if (pet == null) return entity.Id;
if (pet.IsPet)
{
pet.Id = GetNextEntityId();
pet.Init(this);
if (!Pets.TryAdd(pet.Id, pet))
Log.Error("Failed to add pet!");
PlayersCollision.Insert(pet);
}
else
Log.WarnFormat("This is not a real pet! {0}", pet.Name);
}
}
}
}
return entity.Id;
}
Now just save that and rebuild. If you can get into the nexus as an unnamed player you did it right. Now try and enter the realm. If you can't, then you also did it right. Please note this may protect you from hackers using their hacks unnamed in realm, dungeons, xp portals, etc, but this will not protect you from them using hacks in nexus, etc.
And that's it folks. If you have any questions regarding how the code works, or if I didn't explain something enough, then let me know. This was done on a normal FSOD server and other variations of it (Such as RR) may have a different EnterWorld int than the regular. Use at your own risk.