[Help] COEmu 2 on LAN

06/08/2009 10:28 editor05#1
Hi,

I manage to run the source sample provided here (thanks Andy and to all who was involved in making. You know who you are).

I perfectly run the server locally on my computer, bu since then i have extra 4 pcs and my friends wants to play FB, I manage to install the client to the other 4 pcs editing the server.dat on theirs to the ip on my pc locally with an ip address of 192.168.0.187 (you know Dlink DHCP ip's)

On my pc, server.dat sticks to 127.0.0.1

I edited the loginservers packerprocessor.cs and change the ip's to my pc's ip which is the 192.168.0.187

I manage to create a reg page too with those ip.

Now, when i run the client to the 4 PCs, it can't connect to my server (My Pc)

Anyone can help me out here?
06/08/2009 11:18 yuko#2
that is becaus the client doesn't accept the same IP as the host. or you play from an other pc or you just able an other servername with 127.0.0.1
you should have something like
Code:
if (ServerName == Program.SERVER_NAME)
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse(Program.IP_Server, Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        else if (ServerName == "LocCoEmu")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
06/08/2009 11:56 N6gesemees#3
Quote:
Originally Posted by editor05 View Post
Hi,

I manage to run the source sample provided here (thanks Andy and to all who was involved in making. You know who you are).

I perfectly run the server locally on my computer, bu since then i have extra 4 pcs and my friends wants to play FB, I manage to install the client to the other 4 pcs editing the server.dat on theirs to the ip on my pc locally with an ip address of 192.168.0.187 (you know Dlink DHCP ip's)

On my pc, server.dat sticks to 127.0.0.1

I edited the loginservers packerprocessor.cs and change the ip's to my pc's ip which is the 192.168.0.187

I manage to create a reg page too with those ip.

Now, when i run the client to the 4 PCs, it can't connect to my server (My Pc)

Anyone can help me out here?
That is NOT your ip, a normal ip starts with 8x.xx.xx.xx or 5.xx.xx.xx or soemthing similar.
06/08/2009 12:21 yuko#4
lol dam are you stupid

first server needs to open the ports on your lan IP
database needs to connect on 127 or your lan IP
if you change the clients "server.dat" to the IP where the Client is on it won't work.
so this means you need to use 127.0.0.1 to connect the client on the same pc as the server is running on.
in order to let other ppl connect to your lan IP they need that IP





exemple

on PC1 -> IP 192.168.1.2 dns = 192.168.1.1
server running -> ports opend on 192.168.1.2
and you start a client -> 127.0.0.1 with a new server name

on pc2 -> Ip 192.168.1.3 dns 192.168.1.1
client connects on 192.168.1.2

on pc3 -> Ip 192.168.1.4 dns 192.168.1.1
client connects on 192.168.1.2

Pc 1 needs to have his own server name in server.dat
Code:
[B]server.dat[/B]
[COLOR="Lime"]for all ppl in the same network[/COLOR]
	<row>
		<field name="id">101</field>
		<field name="ServerName">CoEmu</field>
		<field name="ServerIP">[COLOR="red"]192.168.1.2[/COLOR]</field>
		<field name="ServerPort">9958</field>
		<field name="FlashName">CoEmu</field>
		<field name="FlashIcon">Group3/server2.swf</field>
		<field name="FlashHint"></field>
		<field name="Child">0</field>
	</row>
[COLOR="Lime"]For a client where the server is hosted[/COLOR]
	<row>
		<field name="id">102</field>
		<field name="ServerName">LocCoEmu</field>
		<field name="ServerIP">[COLOR="Red"]127.0.0.1[/COLOR]</field>
		<field name="ServerPort">9958</field>
		<field name="FlashName">LocCoEmu</field>
		<field name="FlashIcon">Group3/server8.swf</field>
		<field name="FlashHint"></field>
		<field name="Child">0</field>
	</row>

[B]Code from login to enable LocCoEmu[/B]
if (ServerName == "CoEmu")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))//enable everyone else to connect
                            {
                                CSocket.Send(Packets.AuthResponse([COLOR="Red"]"192.168.1.2"[/COLOR], Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        else if (ServerName == "LocCoEmu")//enable PC1 to COnnect
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse([COLOR="red"]"127.0.0.1"[/COLOR], Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }

@n6gesemees
http://en.wikipedia.org/wiki/IP_address
06/08/2009 12:51 editor05#5
Thanks yuko... Lemme try and get back to you
06/08/2009 13:18 editor05#6
Thanks Again Yuko... Manage to change as per your advice... but didn't work at the moment, i'm sure later on...

Some quick questions..

1. Re: LocCoEmu <--- should i use this name? and change the server.dat's servername on PC 2 3 and 4?

2. Should i open port 9958 5816 5817 on my server pc? (thru windows firewall)

3. should i open port on the router (Virtual Server on Dlink router sort of port forwarding...

Again, Thanks much...
06/08/2009 13:24 _Emme_#7
Quote:
Originally Posted by editor05 View Post
Thanks Again Yuko... Manage to change as per your advice... but didn't work at the moment, i'm sure later on...

Some quick questions..

1. Re: LocCoEmu <--- should i use this name? and change the server.dat's servername on PC 2 3 and 4?

2. Should i open port 9958 5816 5817 on my server pc? (thru windows firewall)

3. should i open port on the router (Virtual Server on Dlink router sort of port forwarding...

Again, Thanks much...

Yes, open all those ports by going to [Only registered and activated users can see links. Click Here To Register...] or something like that, logon to your router and open em up, if that doesn't work see if your router has a firewall, if it does pause it and do the same thing to your computers firewall.

Goodluck
06/08/2009 14:50 editor05#8
here's my code on the packetprocessor on login server

/*
* 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);
if(ServerName == "CoEmu")
{
/*if(AuthSocket.Authorize(AccountName, Key, false))
{
CSocket.Send(Packets.AuthResponse("66.187.101.86", Key1, Key2));
}
else
{
CSocket.Disconnect();
}*/
if (AuthSocket.Authorize(AccountName, Key, false))//enable everyone else to connect

{
CSocket.Send(Packets.AuthResponse("192.168.0.187", Key1, Key2));
}
else
{
CSocket.Disconnect();
}
}
else if (ServerName == "LocCoEmu")//enable PC1 to COnnect

{
if(AuthSocket.Authorize(AccountName, Key, true))
{
CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
}
else
{
CSocket.Disconnect();
}
}
}
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);
if(ServerName == "CoEmu")
{
/*if(AuthSocket.Authorize(AccountName, Key, false))
{
CSocket.Send(Packets.AuthResponse("66.187.101.86", Key1, Key2));
}
else
{
CSocket.Disconnect();
}*/
if (AuthSocket.Authorize(AccountName, Key, false))//enable everyone else to connect
{
CSocket.Send(Packets.AuthResponse("192.168.0.187", Key1, Key2));
}
else
{
CSocket.Disconnect();
}
}
else if (ServerName == "LocCoEmu")////enable PC1 to COnnect

{
if(AuthSocket.Authorize(AccountName, Key, true))
{
CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
}
else
{
CSocket.Disconnect();
}
}
}
else
{
CSocket.Send(Packets.WrongPass());
CSocket.Disconnect();
}
}
else
{
Console.WriteLine("DBPass equals ERROR: " + DBPass);
CSocket.Disconnect();
}
}
}
}


Still i can't connect from the other pc except the server which is doin smooth..

am i missing somethin in there? i also opened all the ports necessary
06/08/2009 16:44 yuko#9
mmm oki here we go again.
gameserver
mastersocket.cs
server_ip = 192.168.0.187
site Ip = whatever

databaseconnection.cs
server = 127.0.0.1


loginserver
server_ip = 192.168.0.187
site Ip = whatever

databaseconnection.cs
server = 127.0.0.1



this is in order to host the server on the computer with the IP = 192.168.0.187
now lets say pc2 and pc3 wanna connect to pc1(192.168.0.187)
they need to connect on CoEmu (server.dat with the ip = 192.168.0.187)
now to connect pc1 to the server he needs to connect trough 127.0.0.1 wich is named LocCoEmu
and you don't have to enable any firewall on the router caus local connections are open. you only might need to disable windows firewall
else it should work perfectly
i use this system all the time
06/08/2009 16:53 Andrew.A#10
Quote:
Originally Posted by yuko View Post
mmm oki here we go again.
gameserver
mastersocket.cs
server_ip = 192.168.0.187
site Ip = whatever

databaseconnection.cs
server = 127.0.0.1


loginserver
server_ip = 192.168.0.187
site Ip = whatever

databaseconnection.cs
server = 127.0.0.1



this is in order to host the server on the computer with the IP = 192.168.0.187
now lets say pc2 and pc3 wanna connect to pc1(192.168.0.187)
they need to connect on CoEmu (server.dat with the ip = 192.168.0.187)
now to connect pc1 to the server he needs to connect trough 127.0.0.1 wich is named LocCoEmu
and you don't have to enable any firewall on the router caus local connections are open. you only might need to disable windows firewall
else it should work perfectly
i use this system all the time

OK i have a question, which ip do i use in all these places?
192.168.1.254 (DNS) or 86.149.255.50???
06/08/2009 16:58 yuko#11
depends how you wanna instal the server. the guy who started the treat want his server to work in lan (Local Area Network) that usualy goes with the IP sets 192.168.x.x
if you wanna put your server on the wan network (wide area network) than you need the IP send by your modem. just hope you have a static one ;)
if you are behind a router you'll need to do some portforward. else ppl won't be able to bypass the router
06/08/2009 17:17 Andrew.A#12
Ok thanks Im gonna try this now But heres a Thanks for explaining all this to me =)

Np figured it out

EDIT1: I take that back no i haven't...
Code:
if (ServerName == Program."PixelEmpire")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse(Program."86.149.255.50", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        else if (ServerName == "LocCoEmu")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
Do i need to delete "Program." because I don't get errors if its deleted but i get them when its there


EDIT2: Now when I load client with this Server.Dat
Code:
 <?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="cq2">
	<table_structure name="outenserver">
		<field Field="id" Type="smallint(1) unsigned zerofill" Null="NO" Key="PRI" Default="0" Extra="" />
		<field Field="ServerName" Type="varchar(32)" Null="YES" Key="" Extra="" />
		<field Field="ServerIP" Type="varchar(15)" Null="YES" Key="" Extra="" />
		<field Field="ServerPort" Type="int(1) unsigned" Null="YES" Key="" Extra="" />
		<field Field="FlashName" Type="varchar(32)" Null="YES" Key="" Extra="" />
		<field Field="FlashIcon" Type="varchar(32)" Null="YES" Key="" Extra="" />
		<field Field="FlashHint" Type="varchar(128)" Null="YES" Key="" Extra="" />
		<field Field="Child" Type="tinyint(1) unsigned zerofill" Null="NO" Key="" Default="0" Extra="" />
		<key Table="outenserver" Non_unique="0" Key_name="id" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="97" Null="" Index_type="BTREE" Comment="" />
		<options Name="outenserver" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="97" Avg_row_length="58" Data_length="5644" Max_data_length="281474976710655" Index_length="2048" Data_free="0" Create_time="2008-11-26 08:33:09" Update_time="2008-12-18 08:39:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
	</table_structure>
	<table_data name="outenserver">
	<row>
		<field name="id">0</field>
		<field name="ServerName"></field>
		<field name="ServerIP"></field>
		<field name="ServerPort">0</field>
		<field name="FlashName"></field>
		<field name="FlashIcon"></field>
		<field name="FlashHint"></field>
		<field name="Child">1</field>
	</row>
	<row>
		<field name="id">101</field>
		<field name="ServerName">PixelEmpire</field>
		<field name="ServerIP">86.149.255.50</field>
		<field name="ServerPort">9958</field>
		<field name="FlashName">PixelEmpire</field>
		<field name="FlashIcon">Group3/server2.swf</field>
		<field name="FlashHint"></field>
		<field name="Child">0</field>
	</row>
	<row>
		<field name="id">102</field>
		<field name="ServerName">UnderConstruction</field>
		<field name="ServerIP">127.0.0.1</field>
		<field name="ServerPort">9958</field>
		<field name="FlashName">UnderConstruction</field>
		<field name="FlashIcon">Group3/server8.swf</field>
		<field name="FlashHint"></field>
		<field name="Child">0</field>
	</row>
	</table_data>
</database>
</mysqldump>
and this packet Processor
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);
                    if (ServerName == "PixelEmpire")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false)) // Enable Public
                            {
                                CSocket.Send(Packets.AuthResponse("86.149.255.50", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        else if (ServerName == "UnderConstruction")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false)) //Enable Andrew
                            {
                                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("86.149.255.50", Key1, Key2));
				        }
				        else
				        {
				        	CSocket.Disconnect();
				        }
			        }
	        	}
	        	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);
			        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();
				        }
			        }
	        	}
	        	else
	        	{
	        		CSocket.Send(Packets.WrongPass());
	        		CSocket.Disconnect();
	        	}
	        }
	        else
	        {
	        	Console.WriteLine("DBPass equals ERROR: " + DBPass);
	        	CSocket.Disconnect();
	        }
		}
	}
}
I get this [Only registered and activated users can see links. Click Here To Register...]
and also an error that says it cant read Server.dat

Help Pleaseee
06/08/2009 18:03 yuko#13
Code:
if (ServerName == "PixelEmpire")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse("86.149.255.50", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        else if (ServerName == "LocCoEmu")[COLOR="Red"]// this one will ONLY work if you try to connect on this name/ip (server.dat servername)[/COLOR]
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
that is what you need, Program is becaus i have stored everything in inifiles so if i move the source i don't have to recompil i only need to change the ini's
06/08/2009 19:19 Andrew.A#14
So what exactly do I do? When i but "Program." on the end i get errors. Do you need to send me the ini's or something?
06/08/2009 19:47 yuko#15
damn is it really that hard?
Quote:
Originally Posted by Andrew.A View Post
Ok thanks Im gonna try this now But heres a Thanks for explaining all this to me =)

Np figured it out

EDIT1: I take that back no i haven't...
Code:
if (ServerName == Program."PixelEmpire")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse(Program."86.149.255.50", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        [COLOR="Lime"]else if (ServerName == "UnderConstruction")[/COLOR]                        {
                            if (AuthSocket.Authorize(AccountName, Key, false))
                            {
                                CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
Do i need to delete "Program." because I don't get errors if its deleted but i get them when its there


EDIT2: Now when I load client with this Server.Dat
Code:
 <?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="cq2">
	<table_structure name="outenserver">
		<field Field="id" Type="smallint(1) unsigned zerofill" Null="NO" Key="PRI" Default="0" Extra="" />
		<field Field="ServerName" Type="varchar(32)" Null="YES" Key="" Extra="" />
		<field Field="ServerIP" Type="varchar(15)" Null="YES" Key="" Extra="" />
		<field Field="ServerPort" Type="int(1) unsigned" Null="YES" Key="" Extra="" />
		<field Field="FlashName" Type="varchar(32)" Null="YES" Key="" Extra="" />
		<field Field="FlashIcon" Type="varchar(32)" Null="YES" Key="" Extra="" />
		<field Field="FlashHint" Type="varchar(128)" Null="YES" Key="" Extra="" />
		<field Field="Child" Type="tinyint(1) unsigned zerofill" Null="NO" Key="" Default="0" Extra="" />
		<key Table="outenserver" Non_unique="0" Key_name="id" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="97" Null="" Index_type="BTREE" Comment="" />
		<options Name="outenserver" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="97" Avg_row_length="58" Data_length="5644" Max_data_length="281474976710655" Index_length="2048" Data_free="0" Create_time="2008-11-26 08:33:09" Update_time="2008-12-18 08:39:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
	</table_structure>
	<table_data name="outenserver">
	<row>
		<field name="id">0</field>
		<field name="ServerName"></field>
		<field name="ServerIP"></field>
		<field name="ServerPort">0</field>
		<field name="FlashName"></field>
		<field name="FlashIcon"></field>
		<field name="FlashHint"></field>
		<field name="Child">1</field>
	</row>
	<row>
		<field name="id">101</field>
		<field name="ServerName">PixelEmpire</field>
		[COLOR="Red"]<field name="ServerIP">86.149.255.50</field>[/COLOR]<-- [COLOR="Lime"]remove that becaus thats why he can't load the server.dat. its your own Ip clinet won't accept that. you need only 127.0.0.1[/COLOR]
		<field name="ServerPort">9958</field>
		<field name="FlashName">PixelEmpire</field>
		<field name="FlashIcon">Group3/server2.swf</field>
		<field name="FlashHint"></field>
		<field name="Child">0</field>
	</row>
	<row>
		<field name="id">102</field>
		<field name="ServerName">UnderConstruction</field>
		<field name="ServerIP">127.0.0.1</field>
		<field name="ServerPort">9958</field>
		<field name="FlashName">UnderConstruction</field>
		<field name="FlashIcon">Group3/server8.swf</field>
		<field name="FlashHint"></field>
		<field name="Child">0</field>
	</row>
	</table_data>
</database>
</mysqldump>
and this packet Processor
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);
                    if (ServerName == "PixelEmpire")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false)) // Enable Public
                            {
                                CSocket.Send(Packets.AuthResponse("86.149.255.50", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
                        else if (ServerName == "UnderConstruction")
                        {
                            if (AuthSocket.Authorize(AccountName, Key, false)) //Enable Andrew
                            {
                                CSocket.Send(Packets.AuthResponse("127.0.0.1", Key1, Key2));
                            }
                            else
                            {
                                CSocket.Disconnect();
                            }
                        }
			        	        	}
	        	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);
			        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
	        	{
	        		CSocket.Send(Packets.WrongPass());
	        		CSocket.Disconnect();
	        	}
	        }
	        else
	        {
	        	Console.WriteLine("DBPass equals ERROR: " + DBPass);
	        	CSocket.Disconnect();
	        }
		}
	}
}
I get this [Only registered and activated users can see links. Click Here To Register...]
and also an error that says it cant read Server.dat

Help Pleaseee