[(Awesome)RELEASE] CoEmuv2.Nano(5095) Source Code

06/07/2009 20:55 Andrew.A#616
IM gettin this an error on line 31 of Auth Server
[Only registered and activated users can see links. Click Here To Register...]
This is my AuthServer.cs

Code:
/*
 * Created by SharpDevelop.
 * User: sams
 * Date: 3/8/2009
 * Time: 2:19 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;
using System.Net.Sockets;

namespace CoEmu_v2_LoginServer.Connections
{
	/// <summary>
	/// Description of AuthSocket.
	/// </summary>
	public static class AuthSocket
	{
		private static Socket Auth;
        private const string SERVER_IP = "127.0.0.1";
        public const string NANO_IP = "86.149.255.50";
		private const int AUTH_PORT = 5817;
		
		public static bool Authorize(string user, uint key, bool nano)
		{
			try{
				Auth = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
				if(!nano)
				{
					[COLOR="Red"]Auth.Connect(SERVER_IP, AUTH_PORT);[/COLOR]				}
				else{
					Auth.Connect(NANO_IP, AUTH_PORT);
				}
				Auth.Send(System.Text.Encoding.ASCII.GetBytes("(A)" + user + "," + key));
				Auth.Close();
			}
			catch(Exception e)
			{
				Console.WriteLine(e.ToString());
				return false;
			}
			return true;
		}
	}
}
However when i open this i manage to log in after a few tries?

Help????

I this it has something to do with this....
Code:
/*
 * Created by SharpDevelop.
 * User: sams
 * Date: 3/8/2009
 * Time: 12:38 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using CoEmu_v2_LoginServer.Connections;
using CoEmu_v2_LoginServer.Database;

namespace CoEmu_v2_LoginServer
{
	/// <summary>
	/// Allows for handling of packets from the client->loginserver or client->gameserver.
	/// </summary>
	public static class PacketProcessor
	{
		public static void ProcessPacket(byte[] Data, ClientSocket CSocket)
		{
			int Type = (Data[3] << 8) + Data[2];
			switch(Type)
			{
				case 1086:
					{
						RequestLogin(Data, CSocket);
						break;
					}
				default:
					{
						Console.WriteLine("[LoginServer] Unknown packet type: " + Type);
						break;
					}
			}
		}
		public static void RequestLogin(byte[] Data, ClientSocket CSocket)
		{
			string AccountName = "";
	        string Password = "";
	        string ServerName = "";
	        if(Data.Length >= 276)
	        {
		        for (int i = 4; i < 0x114; i++)
		        {
		            if (i >= 0x14 && i < 0xf9)
		            {
		            	if(Data[i] != 0x00)
		                Password += (Convert.ToString(Data[i], 16)).PadLeft(2, '0');
		            }
		            if (i < 0x14)
		                if (Data[i] != 0x00)
		                    AccountName += Convert.ToChar(Data[i]);
		            if (i > 0xfa)
		            	if (Data[i] != 0x00)
		                    ServerName += Convert.ToChar(Data[i]);
		        }
	        }
	        else
	        {
	        	return;
	        }
	       /* if(AccountName != "dsfreak")
	        {
	        	CSocket.Disconnect();
	        	return;
	        }*/
	        System.Random Random = new System.Random();
	        Console.WriteLine("[LoginServer] " + AccountName + " logging in to " + ServerName);
	        string DBPass = Database.Database.Password(AccountName);
	        //TODO: Check for ban.
	        if(DBPass != "ERROR")
	        {
	        	if(DBPass == Password)
	        	{
	        		//OKAY to login!
	        		uint Key = (uint)(Random.Next(10000000) << 32);
	        		Key = Key << 32;
        			Key = (uint)(Key | (uint)Random.Next(10000000));
        			byte[] Key1 = new byte[4];
			        byte[] Key2 = new byte[4];
			        Key1[0] = (byte)(((ulong)Key & 0xff00000000000000L) >> 56);
			        Key1[1] = (byte)((Key & 0xff000000000000) >> 48);
			        Key1[2] = (byte)((Key & 0xff0000000000) >> 40);
			        Key1[3] = (byte)((Key & 0xff00000000) >> 32);
			        Key2[0] = (byte)((Key & 0xff000000) >> 24);
			        Key2[1] = (byte)((Key & 0xff0000) >> 16);
			        Key2[2] = (byte)((Key & 0xff00) >> 8);
			        Key2[3] = (byte)(Key & 0xff);
[COLOR="red"]			        if(ServerName == "PixelEmpire")
			        {
                        /*if(AuthSocket.Authorize(AccountName, Key, false))
                        {
                            CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
                        }
                        else
                        {
                            CSocket.Disconnect();
                        }*/
                        if (AuthSocket.Authorize(AccountName, Key, false))
				        {
                            CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
				        }
				        else
				        {
				        	CSocket.Disconnect();
				        }
			        }
			        else if(ServerName == "CoEmu.Nano")
			        {
			        	if(AuthSocket.Authorize(AccountName, Key, true))
				        {
                            CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
				        }
				        else
				        {
				        	CSocket.Disconnect();
				        }
			        }
	        	}[/COLOR]	        	else if(DBPass == "")
	        	{
	        		Console.WriteLine("[LoginServer](Diagnostic) Set password for " + AccountName);
	        		Database.Database.SetPass(AccountName, Password);
	        		//OKAY to login!
	        		uint Key = (uint)(Random.Next(10000000) << 32);
	        		Key = Key << 32;
        			Key = (uint)(Key | (uint)Random.Next(10000000));
        			byte[] Key1 = new byte[4];
			        byte[] Key2 = new byte[4];
			        Key1[0] = (byte)(((ulong)Key & 0xff00000000000000L) >> 56);
			        Key1[1] = (byte)((Key & 0xff000000000000) >> 48);
			        Key1[2] = (byte)((Key & 0xff0000000000) >> 40);
			        Key1[3] = (byte)((Key & 0xff00000000) >> 32);
			        Key2[0] = (byte)((Key & 0xff000000) >> 24);
			        Key2[1] = (byte)((Key & 0xff0000) >> 16);
			        Key2[2] = (byte)((Key & 0xff00) >> 8);
			        Key2[3] = (byte)(Key & 0xff);
[COLOR="RoyalBlue"]			        if(ServerName == "PixelEmpire")
			        {
                        /*if(AuthSocket.Authorize(AccountName, Key, false))
                        {
                            CSocket.Send(Packets.AuthResponse("86.149.255.50", Key1, Key2));
                        }
                        else
                        {
                            CSocket.Disconnect();
                        }*/
                        if (AuthSocket.Authorize(AccountName, Key, false))
				        {
                            CSocket.Send(Packets.AuthResponse("86.149.255.50", Key1, Key2));
				        }
				        else
				        {
				        	CSocket.Disconnect();
				        }
			        }
			        else if(ServerName == "CoEmu.Nano")
			        {
			        	if(AuthSocket.Authorize(AccountName, Key, true))
				        {
                            CSocket.Send(Packets.AuthResponse("86.149.255.50", Key1, Key2));
				        }
				        else
				        {
				        	CSocket.Disconnect();
				        }
			        }
	        	}
	        	else
	        	{
	        		CSocket.Send(Packets.WrongPass());
	        		CSocket.Disconnect();
	        	}
	        }
	        else
	        {
	        	Console.WriteLine("DBPass equals ERROR: " + DBPass);
	        	CSocket.Disconnect();
	        }
		}
	}
}[/COLOR]
I did that to see If it would let both on at the same time but im confused now Help please.
06/07/2009 21:30 Zehava333#617
Samig, yes those things HAVE to be edited in C# and then recompiled. Anyone that cannot get the server running you are welcome to add my MSN [Only registered and activated users can see links. Click Here To Register...] And Ill help when and where I can. Though I wont be home till after midnight central standard time tonight. Ill be back on around 10am central tomorrow.

For my next question, can anyone point me in the right direction to add the skill effect graphics peroperly? None of them appear to work properly that Ive tested so far concerning weapon skills. Rage, Phoenix, Snow. Or maybe they do work the chance to go off is just so low I can't get it to go off yet?? not sure. Also Super Gem effects? I looked in the effects CS and that shows interpreting to and/or from the client, but I dont see where the skill is getting the graphic ID from, unless it's from the client it's self and in that case I'll keep looking.

Any suggestions or advice in this area would be much appriciated.
06/07/2009 23:05 samig#618
Quote:
Originally Posted by Zehava333 View Post
Samig, yes those things HAVE to be edited in C# and then recompiled. Anyone that cannot get the server running you are welcome to add my MSN [Only registered and activated users can see links. Click Here To Register...] And Ill help when and where I can. Though I wont be home till after midnight central standard time tonight. Ill be back on around 10am central tomorrow.

For my next question, can anyone point me in the right direction to add the skill effect graphics peroperly? None of them appear to work properly that Ive tested so far concerning weapon skills. Rage, Phoenix, Snow. Or maybe they do work the chance to go off is just so low I can't get it to go off yet?? not sure. Also Super Gem effects? I looked in the effects CS and that shows interpreting to and/or from the client, but I dont see where the skill is getting the graphic ID from, unless it's from the client it's self and in that case I'll keep looking.

Any suggestions or advice in this area would be much appriciated.

//someone needs to tell me what that is and then ill probobly have this thing solved, but only maybe
06/08/2009 02:15 kikomontana94#619
Great Post Andy :P This is the best source ....... Time to Learn C# For all :P

Good Luck
06/08/2009 09:09 arab4life#620
i can't seem to get the username and password to work...keeps telling me invalid user and then shuts off? any ideas?
06/08/2009 09:20 Zehava333#621
Samig, you should have a C# compiler, most likley Visual Studio C# Express, if you dont, get it. Use google, its easy to find. you have to load up the source there, alter all the IP's, user names and pass words properly and then build the project and get new .exe files with your info in it.
06/08/2009 09:59 Andrew.A#622
Does anyone know how to make the barber work or have any codes for hair because i not like being bald =S
06/08/2009 10:13 arab4life#623
can anyone help me with this?
am sure i got the right username/password
06/08/2009 14:21 Kamaik#624
Whats is a passoword? Broo
xP
06/08/2009 15:28 Incariuz#625
Got this working now, well atleast on my own PC. Had to take some measures I didn't want to in order to accomplish it, but it's done. Now I'll start being a leech and stealing everything people have made for this, lol. Shortly after, I will get to work on trying to release some stuff, though I'm not sure what I'll accomplish right away. So used to LOTF, will have to study this source for a bit.
06/08/2009 16:44 Andrew.A#626
Quote:
Originally Posted by Incariuz View Post
Got this working now, well atleast on my own PC. Had to take some measures I didn't want to in order to accomplish it, but it's done. Now I'll start being a leech and stealing everything people have made for this, lol. Shortly after, I will get to work on trying to release some stuff, though I'm not sure what I'll accomplish right away. So used to LOTF, will have to study this source for a bit.
Great :) Hope to see some releases from you =D
06/08/2009 17:41 Incariuz#627
I'm sure you do, lol. I wonder if I should try and redo the Ice Skills for this source... Maybe more people will grow interest in skill creation this time then last time.
06/08/2009 17:54 kinshi88#628
Quote:
Originally Posted by Incariuz View Post
I'm sure you do, lol. I wonder if I should try and redo the Ice Skills for this source... Maybe more people will grow interest in skill creation this time then last time.
I think people should finish the existing skills first =P
Its not hard, almost finished them myself =P
06/08/2009 20:12 Incariuz#629
Didn't know skills weren't working yet. But I'm going to be checking through everything after, get what I can done when I can.
06/08/2009 23:58 hellblayd#630
uhg I hate this stuff lol I dunno how to do it and the post is confusing to me :( plus I get a password protection thing so I can't extract it but I want a private server :/ cuz I find all the other servers so boring because there either to hard or to easy lol