Hi I am making a emulator from scratch
It uses Fluent NHibernate mapping and Socket Async Event Args (SAEA)
I lost my other source because my laptop 'died', so I had to start over.
It runs on RELEASE63-201301231323-316947488 (post-shuffle SWF)
It will be finished (backupped on Dropbox, link won't be shared!)
I will definitely opload it on Github sometimes, but first I need to finish more.
It can be used with Visual Studios 2010 (just saying because for people like me who hate the GUI of Visual Studios 2011/2012)
Snippets:
BotsMapping.cs:
PHP Code:
public class BotsMapping : ClassMap<Bots>
{
public BotsMapping()
{
base.Table("bots");
base.LazyLoad();
base.Id().GeneratedBy.Identity().Column("id");
base.Map(x => x.RoomID).Column("room_id");
base.Map(x => x.Name).Column("name");
base.Map(x => x.Motto).Column("motto");
base.Map(x => x.Look).Column("look");
base.Map(x => x.X).Column("x");
base.Map(x => x.Y).Column("y");
base.Map(x => x.Z).Column("z");
base.Map(x => x.Rotation).Column("rotation");
base.Map(x => x.MinX).Column("min_x");
base.Map(x => x.MaxX).Column("max_x");
base.Map(x => x.MinY).Column("min_y");
base.Map(x => x.MaxY).Column("max_y");
base.Map(x => x.Walk).Column("walk_mode");
}
}
Create ISessionFactory:
PHP Code:
private static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(ConnectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<UserMap>())
.BuildSessionFactory();
}
What I (will) cache in the beginning:
- Navigator frontpage items ('public' room listing and campaign winned rooms)
- Vouchers
- Catalogue pages (No items and no base items)
When getting an user from ID, it checks if the id is in the dictionary. If not, will get the user from sql and insert the ID in dictionary. Otherwise, get user from dictionary. If an user is already connected, the id is already in dictionary.
What I mean:
CharacterManager:
PHP Code:
public class CharacterManager
{
private IDictionary<int, User> _characters;
public CharacterManager()
{
this._characters = new Dictionary<int, User>();
}
public bool TryAuthenticateUser(string SSO, out User User)
{
try
{
User = Application.Session.CreateCriteria<User>().Add(Restrictions.Eq("Auth_Ticket", SSO)).UniqueResult<User>();
if (!_characters.ContainsKey(User.Id))
_characters.Add(User.Id, User);
return true;
}
catch
{
User = null;
return false;
}
}
public void GetUser(int Id, out User User)
{
if (_characters.ContainsKey(Id))
{
User = _characters[Id];
}
else
{
try
{
User = Application.Session.Get<User>(Id);
if (!_characters.ContainsKey(User.Id))
_characters.Add(User.Id, User);
}
catch
{
User = null;
}
}
}
(offcourse this contains the namespace and using things, just cba to add them:P)
Screens:
Credits:
Tha (AKA me) - Coding the components and packets
Jagregory - Fluent NHibernate
Habbolatino - Some packet ID comparing
Droppy - Helping me in previous stages + supporting
vista4life - Helping me a few times