Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
I can hear, I can hear the nostalgia coming.
Wasn't you some months ago also developing an v35 Emulator? Or was @Quackster? I don't remember.
Aurora it's a name of a Magibogi Emulator. Actually it was takedown by the creators.: https://github.com/aura-project/aura
Sad.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Glaceon
I won't use LINQ too much, just for Fluent NHibernate (as I guess it uses LINQ somehow itself).
PHP Code:
public OfficialRoomsComposer(IList<FrontpageItem> frontpageItems)
: base(450)
{
AppendVL64(0);
AppendVL64(frontpageItems.Count);
foreach (FrontpageItem item in frontpageItems)
{
AppendString(item.Name);
AppendString(item.Description);
AppendVL64(item.Size);
AppendString(item.Name);
AppendString(item.Image);
AppendVL64(0);
AppendVL64(item.Type);
if (item.Type == 1)
AppendString(item.Tag);
}
}
At least I'm not using LINQ for for(each) loops as that will drop loads of performances. (no comment about the 0, I have to make rooms yet so no user count of something yet).
ALSO: In my old source I got past room loading too, just the annoyance is that shockwave and flash are a bit different in it. That's why I focus on Flash first xp)
Don't know why u put that name but revise the name "OfficialRoomsComposer", i think "SerializePageItems" is better :p
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Amariconao
Don't know why u put that name but revise the name "OfficialRoomsComposer", i think "SerializePageItems" is better :p
_events[450] = com.sulake.habbo.communication.messages.incoming.navigator.OfficialRoomsEvent;
This is SWF wise. This is a composer in emulator. I keep the same names.
Quote:
Originally Posted by
saamus
I can hear, I can hear the nostalgia coming.
Wasn't you some months ago also developing an v35 Emulator? Or was @
Quackster? I don't remember.
Aurora it's a name of a Magibogi Emulator. Actually it was takedown by the creators.:
https://github.com/aura-project/aura
Sad.
It was me (it was R38), though I accidentally deleted the virtual machine it was on. Sad story. Now I have it on Github though.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Dont know why... OfficialRoomsEvent for item serializing... Were they drunk when write that?
PD: Good luck with ur project bro, u can do it perfect ;)
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Amariconao
Dont know why... OfficialRoomsEvent for item serializing... Were they drunk when write that?
PD: Good luck with ur project bro, u can do it perfect ;)
No.
https://pastebin.com/T57CzCHN
I think these names are correct. I keep the same names as Habbo did. SerializePageItems doesn't even tell you which packet it is.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Glaceon
_events[450] = com.sulake.habbo.communication.messages.incoming.navigator.OfficialRoomsEvent;
This is SWF wise. This is a composer in emulator. I keep the same names.
It was me (it was R38), though I accidentally deleted the virtual machine it was on. Sad story. Now I have it on Github though.
You did wha.... Anyways, good luck on this project :D
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
saamus
You did wha.... Anyways, good luck on this project :D
This happens when I get annoyed because my computer is full of shit and I remove without thinking. Thanks anyways.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
A few things happened:
- Catalogue deals work now, you can make packages of furniture. Maybe database wise and code wise it can be improved.
- The emulator doesn't use NHibernate anymore since @spreedblood found it too hard and I found joins annoying.
- The database uses foreign keys and better collations (utf8mb4_general_ci mostly which is like utf8_general_ci but better) .
- Updated DotNetty to latest version on Nuget.
http://i.imgur.com/3HZNqIN.png
Thanks to @spreedblood for writing the database stuff and part of the controllers and the entity classes.
PHP Code:
using System;
using System.Collections.Concurrent;
namespace AuroraEmu.Database.Pool
{
public class ObjectPool<T>
{
private ConcurrentBag<T> _objects;
private Func<T> _objectGenerator;
public ObjectPool(Func<T> objectGenerator)
{
if (objectGenerator == null) throw new ArgumentNullException("objectGenerator");
_objects = new ConcurrentBag<T>();
_objectGenerator = objectGenerator;
}
public T GetObject()
{
T item;
if (_objects.TryTake(out item)) return item;
return _objectGenerator();
}
public void PutObject(T item)
{
_objects.Add(item);
}
}
}
PHP Code:
using AuroraEmu.Database.Pool;
using MySql.Data.MySqlClient;
using System;
using System.Data;
namespace AuroraEmu.Database
{
public class DatabaseConnection : IDisposable
{
private readonly ObjectPool<DatabaseConnection> objectPool;
private MySqlConnection connection;
private MySqlCommand command;
private MySqlTransaction transaction;
public DatabaseConnection(string connectionString, ObjectPool<DatabaseConnection> pool)
{
objectPool = pool;
connection = new MySqlConnection(connectionString);
command = connection.CreateCommand();
}
public void Open()
{
if(connection.State == ConnectionState.Open)
{
throw new InvalidOperationException("Connection is already opened...");
}
connection.Open();
}
public bool IsOpen()
{
return connection.State == ConnectionState.Open;
}
/// <summary>
/// Adds a parameter to the MySqlCommand.
/// </summary>
/// <param name="parameter">The parameter with prefixed with an '@'</param>
/// <param name="value">The value of the parameter.</param>
public void AddParameter(string parameter, object value)
{
command.Parameters.AddWithValue(parameter, value);
}
public void SetQuery(string query)
{
command.CommandText = query;
}
/// <summary>
/// Executes a query.
/// </summary>
/// <returns>The number of rows affected.</returns>
public int Execute()
{
try
{
return command.ExecuteNonQuery();
}
catch (MySqlException ex)
{
Engine.Logger.Error("MySQL Error: ", ex);
return -1;
}
finally
{
command.CommandText = string.Empty;
command.Parameters.Clear();
}
}
public DataSet GetDataSet()
{
try
{
DataSet dataSet = new DataSet();
using (MySqlDataAdapter adapter = new MySqlDataAdapter(command))
{
adapter.Fill(dataSet);
}
return dataSet;
}
catch (Exception ex)
{
Engine.Logger.Error("MySQL Error: ", ex);
return null;
}
}
public DataTable GetTable()
{
try
{
DataTable dataTable = new DataTable();
using (MySqlDataAdapter adapter = new MySqlDataAdapter(command))
{
adapter.Fill(dataTable);
}
return dataTable;
}
catch (Exception ex)
{
Engine.Logger.Error("MySQL Error: ", ex);
return null;
}
}
public DataRow GetRow()
{
try
{
DataRow row = null;
DataSet dataSet = GetDataSet();
if (dataSet != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count == 1)
{
row = dataSet.Tables[0].Rows[0];
}
return row;
}
catch (Exception ex)
{
Engine.Logger.Error("MySQL Error: ", ex);
return null;
}
}
/// <summary>
/// Executes an 'insert'-query. Instead of 'Execute', it returns the inserted ID rather than the amount of affected rows.
/// </summary>
/// <returns>The inserted ID.</returns>
public int Insert()
{
try
{
command.ExecuteNonQuery();
return (int)command.LastInsertedId;
}
catch (MySqlException ex)
{
Engine.Logger.Error("MySQL Error: ", ex);
return -1;
}
finally
{
command.CommandText = string.Empty;
command.Parameters.Clear();
}
}
public void BeginTransaction()
{
transaction = connection.BeginTransaction();
}
public void Commit()
{
if (transaction == null)
throw new InvalidOperationException("Transaction hasn't started yet.");
transaction.Commit();
}
public void Rollback()
{
if (transaction == null)
throw new InvalidOperationException("Transaction hasn't started yet.");
transaction.Rollback();
}
public void Dispose()
{
if(IsOpen())
{
connection.Close();
}
if(transaction != null)
{
transaction.Dispose();
}
if(command != null)
{
command.Dispose();
}
}
}
}
PHP Code:
public Player GetPlayerById(int id)
{
Player player;
if (playersById.TryGetValue(id, out player))
return player;
DataRow result = null;
using (DatabaseConnection dbClient = DatabaseManager.GetInstance().GetConnection())
{
dbClient.SetQuery("SELECT id, username, password, email, gender, figure, motto, coins, pixels, rank, home_room, sso_ticket FROM players WHERE id = @id;");
dbClient.AddParameter("@id", id);
dbClient.Open();
result = dbClient.GetRow();
}
if (result != null)
{
player = new Player(result);
playersById.TryAdd(player.Id, player);
return player;
}
return null;
}
I'm pretty sure most code can be cleaned up even more, but to be honest I'm cba to do it now.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
I'm not sure what is worse... a so called god class or making a instance of it static..
What about dependency injection?
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Joopie
I'm not sure what is worse... a so called god class or making a instance of it static..
What about dependency injection?
Don't blame me about the way it's done now, with the bla.GetInstance() stuff, @spreedblood is completely responsible for it. It was his idea and he changed all that stuff.
But, what way would you recommend?
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Glaceon
Don't blame me about the way it's done now, with the bla.GetInstance() stuff, @
spreedblood is completely responsible for it. It was his idea and he changed all that stuff.
But, what way would you recommend?
And when someone in my project group does something wrong it is not my fault. Sadly it does not work like that. In this project you two are working together. If you do not like his changes, you should have declined it. Ofcourse, vice versa. Saying "it is not me, he did it" is just wrong. I hope you have learned to never point a finger to someone else.
What I recommend? I suggest you read my previous post again.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
Joopie
And when someone in my project group does something wrong it is not my fault. Sadly it does not work like that. In this project you two are working together. If you do not like his changes, you should have declined it. Ofcourse, vice versa. Saying "it is not me, he did it" is just wrong. I hope you have learned to never point a finger to someone else.
What I recommend? I suggest you read my previous post again.
True. However I did not do research into this, and because it seemed like he did I just assumed what he was telling me was right; however, you are right about that.
I'll try and look into dependency injection.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Why dont you skip the catalog part and go straight to loading rooms? Yeah I know its cool to have something that already works on the hotelview but rooms is what habbo is about. This is the kind of George dev structure you apply for any emulator. :p:
Next up is messenger and modtools along with the inventory and purse. Haha :)"
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Quote:
Originally Posted by
The General
Why dont you skip the catalog part and go straight to loading rooms? Yeah I know its cool to have something that already works on the hotelview but rooms is what habbo is about. This is the kind of George dev structure you apply for any emulator. :p:
Next up is messenger and modtools along with the inventory and purse. Haha :)"
Funny thing. One, purse? Purse is just one packet unless you mean something else than purse. Modtools won't be done until everything else is finished. Messenger is in progress but not by me but by @spreedblood. As a mMy Home My Profile Messages atter of fact, I just wanted to have the catalogue listing and pages done first and then focus on navigator. When navigator is mostly finished, I'll move over to room entry.
Now, just accept the way I'm working. And if you don't like it: you can use a magical keyboard combination which contains an ALT and a F4. Have a good day Wesley.
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]
Omg very nice, Question i have is, What made you go backwards? Jw(Y)