Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#, PHP, R38] Project Aurora

Status
Not open for further replies.
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,171
Reaction score
916
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

_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
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
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.

3HZNqIN - [C#, PHP, R38] Project Aurora - RaGEZONE Forums


Thanks to spreedblood for writing the database stuff and part of the controllers and the entity classes.

PHP:
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:
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:
 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.
 

Attachments

You must be registered for see attachments list
Joined
Jun 23, 2010
Messages
2,318
Reaction score
2,195
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?
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
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?

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?
 
Joined
Jun 23, 2010
Messages
2,318
Reaction score
2,195
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

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.
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

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.
 
Joined
Aug 10, 2011
Messages
7,401
Reaction score
3,299
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 :)"
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
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 :)"

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.
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

Yes, An old version. What made you decide that? Just curious(Y)

Because no emulator hasn't been made for R35 flash (no good complete one). The one that was far completed (Hebbo's CachingVB6) is vb6 (one thing) and is down (at least, no database is downloadable as it's lost). As for V9, the only good emulator is Thor which was still unfinished and uses MsSQL.

Which errors?

aJkpjSL - [C#, PHP, R38] Project Aurora - RaGEZONE Forums


hCG3Q45 - [C#, PHP, R38] Project Aurora - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

Because no emulator hasn't been made for R35 flash (no good complete one). The one that was far completed (Hebbo's CachingVB6) is vb6 (one thing) and is down (at least, no database is downloadable as it's lost). As for V9, the only good emulator is Thor which was still unfinished and uses MsSQL.



aJkpjSL - [C#, PHP, R38] Project Aurora - RaGEZONE Forums


hCG3Q45 - [C#, PHP, R38] Project Aurora - RaGEZONE Forums
Try
PHP:
ALTER TABLE players ADD online ENUM('0') NOT NULL DEFAULT;
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

Alright, since I was up pretty early I decided to do some poop on my emulator. Few things changed:

- Using C# 7.0 now, which means

PHP:
Item item;

if (items.TryGetValue(itemId, out item))

Is now changed to

PHP:
if (items.TryGetValue(itemId, out Item item))

Which looks much cleaner in my opinion.

Also, a new packet is added:

PHP:
    class MyRoomsSearchMessageEvent : IPacketEvent
    {
        public void Run(Client client, MessageEvent msgEvent)
        {
            client.SendComposer(new GuestRoomSearchResultComposer(msgEvent.ReadVL64(), 5, "", NavigatorController.GetInstance().GetRoomsByOwner(client.Player.Id)));
        }
    }

PHP:
using AuroraEmu.Game.Rooms;
using System.Collections.Generic;

namespace AuroraEmu.Network.Game.Packets.Composers.Navigator
{
    class GuestRoomSearchResultComposer : MessageComposer
    {
        public GuestRoomSearchResultComposer(int tab1, int tab2, string search, List<Room> rooms)
            : base(451)
        {
            AppendVL64(tab1);
            AppendVL64(tab2);
            AppendString(search);
            AppendVL64(rooms.Count);

            foreach(Room room in rooms)
            {
                SerializeRoom(room);
            }
        }

        public void SerializeRoom(Room room)
        {
            AppendVL64(room.Id);
            AppendVL64(false); // events
            AppendString(room.Name);
            AppendString(room.Owner);
            AppendVL64((int)room.State);
            AppendVL64(7);
            AppendVL64(0);
            AppendString(room.Description);
            AppendVL64(0);
            AppendVL64(false); // can trade
            AppendVL64(0); // score
            AppendVL64(0); // tags
            AppendString(room.Icon, 0);
        }
    }
}

Not everything is done yet but it's starting to look okay. Also The General maybe this weekend I'll do the room entry so you can be happy ;-)
Also, if anybody knows stuff about R35 or want to help editing SWF add me on Skype: mr.josh.97
Or join my discord: in where I'll be available most of the time (chances are that I'll answer faster there though).

Screen for the navigator:

zmiuOVr - [C#, PHP, R38] Project Aurora - RaGEZONE Forums



Try
PHP:
ALTER TABLE players ADD online ENUM('0') NOT NULL DEFAULT;

Didn't work but
PHP:
ALTER TABLE players MODIFY online ENUM('1','0') NOT NULL DEFAULT '0';
did work.
 

Attachments

You must be registered for see attachments list

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

Try
PHP:
ALTER TABLE players ADD online ENUM('0') NOT NULL DEFAULT;

Didn't work but
PHP:
ALTER TABLE players MODIFY online ENUM('1','0') NOT NULL DEFAULT '0';
did work.
ya, I forgot the '0' after default, however good job. It reminds me past time, like 2010-2011 :(!
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

qcCKZ67 - [C#, PHP, R38] Project Aurora - RaGEZONE Forums


PHP:
    class GetRoomEntryDataMessageEvent : IPacketEvent
    {
        public void Run(Client client, MessageEvent msgEvent)
        {
            client.SendComposer(new UsersMessageComposer(client.LoadingRoom.Actors.Values));
            client.LoadingRoom.AddActor(client);
            client.CurrentRoom.SendComposer(new UsersMessageComposer(client.RoomActor));
        }
    }

PHP:
public UsersMessageComposer(RoomActor actor)
            : base(28)
        {
            AppendVL64(1);
            SerializeActor(actor);
        }

        public UsersMessageComposer(ICollection<RoomActor> actors)
            : base(28)
        {
            AppendVL64(actors.Count);

            foreach(RoomActor actor in actors)
            {
                SerializeActor(actor);
            }
        }

        private void SerializeActor(RoomActor actor)
        {
            AppendVL64(actor.Client.Player.Id);
            AppendString(actor.Client.Player.Username);
            AppendString(actor.Client.Player.Motto);
            AppendString(actor.Client.Player.Figure);
            AppendVL64(actor.VirtualID);
            AppendVL64(actor.X);
            AppendVL64(actor.Y);
            AppendString(actor.Z.ToString());
            AppendVL64(actor.Rotation);
            AppendVL64(1); // TODO: BOTs, PETs etc.
            AppendString(actor.Client.Player.Gender);
            AppendVL64(5); // xp not used in flash...
            AppendVL64(-1);
            AppendVL64(-1);
            AppendString(""); // pool figure
        }
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Re: [V9] [R35] Aurora Emulator [C#] [NHibernate] [DotNetty] [Log4net]

LOnyWlE - [C#, PHP, R38] Project Aurora - RaGEZONE Forums

fyQOYjf - [C#, PHP, R38] Project Aurora - RaGEZONE Forums


PHP:
        public PopularRoomTagsResultComposer(int history, ICollection<RoomCategory> categories)
            :base(452)
        {
            AppendVL64(history);
            AppendVL64(categories.Count);

            foreach (RoomCategory category in categories.OrderBy(x => x.PlayersInside))
            {
                AppendString(category.Name);
                AppendVL64(category.PlayersInside);
            }
        }

A little note: I think the history int is used for the navigator history. In R35 navigator there was a history. If you clicked through tabs, you had a button that would you take back to the previous tab you clicked. Useless in my opinion, but certainly cool.
 

Attachments

You must be registered for see attachments list
Status
Not open for further replies.
Back
Top