[Development] 5018 Conquer Server Source

07/18/2010 11:47 ~Yuki~#1
deleted by request.
07/18/2010 11:48 ~Yuki~#2
#Reserved
07/18/2010 11:52 furkan141415#3
nice , you wiLL reLease?
07/18/2010 11:56 -impulse-#4
Quote:
Originally Posted by ~Yuki~ View Post
Tell me wich Database type you would prefer
MySQL
PGSQL
Binary
Or tell me others...
MySQL properly configured that's managed by Subsonic within the C# source.
07/18/2010 12:26 _Emme_#5
Quote:
Originally Posted by -impulse- View Post
MySQL properly configured that's managed by Subsonic within the C# source.
:)
07/18/2010 12:29 MonstersAbroad#6
Yeah, Go with mysql.
07/18/2010 12:50 Korvacs#7
MsSql, or why not do a few databases and have an option to determine which database type you wish to use.
07/18/2010 12:57 ~Yuki~#8
why would i implement more if im only using one :rolleyes:
07/18/2010 13:00 Korvacs#9
Quote:
Originally Posted by ~Yuki~ View Post
why would i implement more if im only using one :rolleyes:
Because i beleive you stated that you might release it, and many people have different oppinions of what is a good database, so why not give them the choice of which they want to use?
07/18/2010 13:04 ~Yuki~#10
Well true. Soo MySQL will be included, but what else? FlatFile? any fast classes?
07/18/2010 13:18 _Emme_#11
Go with subsonic, srsly. I'll help ya if you get stuck
07/18/2010 14:50 pintser#12
MySql would probebly the cleanest.
And easy 2 handle.

Goodluck Yuki!!!
07/18/2010 15:12 Korvacs#13
Quote:
Originally Posted by EmmeTheCoder View Post
Go with subsonic, srsly. I'll help ya if you get stuck
Can you post some examples of Subsonic and some speed tests?
07/18/2010 15:30 MonstersAbroad#14
Here's subsonic querying
Code:
//find a single product by ID
var product = Product.SingleOrDefault(x => x.ProductID == 1);
 
//get a list of products based on some criteria
var products = Product.Find(x => x.ProductID <= 10);
 
//get a list of server-side paged products
var products = Product.GetPaged(0,10);
 
//query using Linq
var products = from p in Product.All()
          join od in OrderDetail.All() on p.ProductID equals od.ProductID
          select p;
07/18/2010 15:52 _Emme_#15
Quote:
Originally Posted by Korvacs View Post
Can you post some examples of Subsonic and some speed tests?
It autogenerates the queries, so basically all you have to do is call the autogenerated class and spawn a new class and direct it values to the database values.

Example (Load NPCs)

Code:
public static void LoadNPCs()
        {
            NpcspawnCollection npcs = new NpcspawnCollection();
            npcs.LoadAndCloseReader(Npcspawn.FetchAll());
            for (int x = 0; x < npcs.Count; x++)
            {
                Npc npc = new Npc();
                npc.UID = (uint)npcs[x].Id;
                npc.Facing = (ConquerAngle)npcs[x].Direction;
                npc.Type = (ushort)npcs[x].Type;
                npc.MapID = (Maps)npcs[x].MapID;
                npc.MapObjType = MapObjectType.Npc;
                npc.X = (ushort)npcs[x].X;
                npc.Y = (ushort)npcs[x].Y;
                npc.Status = (Flags)npcs[x].Status;
                npc.Owner = npc;
                if (Kernel.Maps.ContainsKey((uint)npc.MapID))
                {
                    if (Kernel.Maps[(uint)npc.MapID].ContainsKey(FileIO.DMap.Map.coordinates))
                    {
                    AddNPC:
                        if (Kernel.Objects.ContainsKey(npc.MapID))
                        {
                            Kernel.Objects[npc.MapID].Add(npc);
                        }
                        else
                        {
                            QuadTree<IMapObject> tree = new QuadTree<IMapObject>(new System.Drawing.Rectangle(0, 0, (Kernel.Maps[(uint)npc.MapID][Map.coordinates] as MapCoordinate).Width, (Kernel.Maps[(uint)npc.MapID][FileIO.DMap.Map.coordinates] as MapCoordinate).Height));
                            Kernel.Objects.Add(npc.MapID, tree);
                            goto AddNPC;
                        }
                    }
                }
            }
            IConsole.WriteLine(string.Format(" NPCs: {0}", npcs.Count), ConsoleColor.Cyan);
        }


If intresting, here's the autogenerated code:


Code:
using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Server.Conquer.DAL
{
	/// <summary>
	/// Strongly-typed collection for the Npcspawn class.
	/// </summary>
    [Serializable]
	public partial class NpcspawnCollection : ActiveList<Npcspawn, NpcspawnCollection>
	{	   
		public NpcspawnCollection() {}
        
        /// <summary>
		/// Filters an existing collection based on the set criteria. This is an in-memory filter
		/// Thanks to developingchris for this!
        /// </summary>
        /// <returns>NpcspawnCollection</returns>
		public NpcspawnCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                Npcspawn o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
		
		
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the npcspawns table.
	/// </summary>
	[Serializable]
	public partial class Npcspawn : ActiveRecord<Npcspawn>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public Npcspawn()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public Npcspawn(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public Npcspawn(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public Npcspawn(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("npcspawns", TableType.Table, DataService.GetInstance("Unknown_Server"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"";
				//columns
				
				TableSchema.TableColumn colvarUid = new TableSchema.TableColumn(schema);
				colvarUid.ColumnName = "UID";
				colvarUid.DataType = DbType.Int64;
				colvarUid.MaxLength = 8;
				colvarUid.AutoIncrement = false;
				colvarUid.IsNullable = false;
				colvarUid.IsPrimaryKey = true;
				colvarUid.IsForeignKey = false;
				colvarUid.IsReadOnly = false;
				colvarUid.DefaultSetting = @"";
				colvarUid.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUid);
				
				TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
				colvarId.ColumnName = "ID";
				colvarId.DataType = DbType.Int64;
				colvarId.MaxLength = 8;
				colvarId.AutoIncrement = false;
				colvarId.IsNullable = false;
				colvarId.IsPrimaryKey = false;
				colvarId.IsForeignKey = false;
				colvarId.IsReadOnly = false;
				colvarId.DefaultSetting = @"";
				colvarId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarId);
				
				TableSchema.TableColumn colvarMapID = new TableSchema.TableColumn(schema);
				colvarMapID.ColumnName = "MapID";
				colvarMapID.DataType = DbType.Int32;
				colvarMapID.MaxLength = 4;
				colvarMapID.AutoIncrement = false;
				colvarMapID.IsNullable = false;
				colvarMapID.IsPrimaryKey = false;
				colvarMapID.IsForeignKey = false;
				colvarMapID.IsReadOnly = false;
				colvarMapID.DefaultSetting = @"";
				colvarMapID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMapID);
				
				TableSchema.TableColumn colvarX = new TableSchema.TableColumn(schema);
				colvarX.ColumnName = "X";
				colvarX.DataType = DbType.Int16;
				colvarX.MaxLength = 2;
				colvarX.AutoIncrement = false;
				colvarX.IsNullable = false;
				colvarX.IsPrimaryKey = false;
				colvarX.IsForeignKey = false;
				colvarX.IsReadOnly = false;
				colvarX.DefaultSetting = @"";
				colvarX.ForeignKeyTableName = "";
				schema.Columns.Add(colvarX);
				
				TableSchema.TableColumn colvarY = new TableSchema.TableColumn(schema);
				colvarY.ColumnName = "Y";
				colvarY.DataType = DbType.Int16;
				colvarY.MaxLength = 2;
				colvarY.AutoIncrement = false;
				colvarY.IsNullable = false;
				colvarY.IsPrimaryKey = false;
				colvarY.IsForeignKey = false;
				colvarY.IsReadOnly = false;
				colvarY.DefaultSetting = @"";
				colvarY.ForeignKeyTableName = "";
				schema.Columns.Add(colvarY);
				
				TableSchema.TableColumn colvarType = new TableSchema.TableColumn(schema);
				colvarType.ColumnName = "Type";
				colvarType.DataType = DbType.Int32;
				colvarType.MaxLength = 4;
				colvarType.AutoIncrement = false;
				colvarType.IsNullable = false;
				colvarType.IsPrimaryKey = false;
				colvarType.IsForeignKey = false;
				colvarType.IsReadOnly = false;
				colvarType.DefaultSetting = @"";
				colvarType.ForeignKeyTableName = "";
				schema.Columns.Add(colvarType);
				
				TableSchema.TableColumn colvarDirection = new TableSchema.TableColumn(schema);
				colvarDirection.ColumnName = "Direction";
				colvarDirection.DataType = DbType.Int32;
				colvarDirection.MaxLength = 4;
				colvarDirection.AutoIncrement = false;
				colvarDirection.IsNullable = false;
				colvarDirection.IsPrimaryKey = false;
				colvarDirection.IsForeignKey = false;
				colvarDirection.IsReadOnly = false;
				colvarDirection.DefaultSetting = @"";
				colvarDirection.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDirection);
				
				TableSchema.TableColumn colvarStatus = new TableSchema.TableColumn(schema);
				colvarStatus.ColumnName = "Status";
				colvarStatus.DataType = DbType.Int32;
				colvarStatus.MaxLength = 4;
				colvarStatus.AutoIncrement = false;
				colvarStatus.IsNullable = false;
				colvarStatus.IsPrimaryKey = false;
				colvarStatus.IsForeignKey = false;
				colvarStatus.IsReadOnly = false;
				colvarStatus.DefaultSetting = @"";
				colvarStatus.ForeignKeyTableName = "";
				schema.Columns.Add(colvarStatus);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Unknown_Server"].AddSchema("npcspawns",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("Uid")]
		[Bindable(true)]
		public long Uid 
		{
			get { return GetColumnValue<long>(Columns.Uid); }
			set { SetColumnValue(Columns.Uid, value); }
		}
		  
		[XmlAttribute("Id")]
		[Bindable(true)]
		public long Id 
		{
			get { return GetColumnValue<long>(Columns.Id); }
			set { SetColumnValue(Columns.Id, value); }
		}
		  
		[XmlAttribute("MapID")]
		[Bindable(true)]
		public int MapID 
		{
			get { return GetColumnValue<int>(Columns.MapID); }
			set { SetColumnValue(Columns.MapID, value); }
		}
		  
		[XmlAttribute("X")]
		[Bindable(true)]
		public short X 
		{
			get { return GetColumnValue<short>(Columns.X); }
			set { SetColumnValue(Columns.X, value); }
		}
		  
		[XmlAttribute("Y")]
		[Bindable(true)]
		public short Y 
		{
			get { return GetColumnValue<short>(Columns.Y); }
			set { SetColumnValue(Columns.Y, value); }
		}
		  
		[XmlAttribute("Type")]
		[Bindable(true)]
		public int Type 
		{
			get { return GetColumnValue<int>(Columns.Type); }
			set { SetColumnValue(Columns.Type, value); }
		}
		  
		[XmlAttribute("Direction")]
		[Bindable(true)]
		public int Direction 
		{
			get { return GetColumnValue<int>(Columns.Direction); }
			set { SetColumnValue(Columns.Direction, value); }
		}
		  
		[XmlAttribute("Status")]
		[Bindable(true)]
		public int Status 
		{
			get { return GetColumnValue<int>(Columns.Status); }
			set { SetColumnValue(Columns.Status, value); }
		}
		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(long varUid,long varId,int varMapID,short varX,short varY,int varType,int varDirection,int varStatus)
		{
			Npcspawn item = new Npcspawn();
			
			item.Uid = varUid;
			
			item.Id = varId;
			
			item.MapID = varMapID;
			
			item.X = varX;
			
			item.Y = varY;
			
			item.Type = varType;
			
			item.Direction = varDirection;
			
			item.Status = varStatus;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(long varUid,long varId,int varMapID,short varX,short varY,int varType,int varDirection,int varStatus)
		{
			Npcspawn item = new Npcspawn();
			
				item.Uid = varUid;
			
				item.Id = varId;
			
				item.MapID = varMapID;
			
				item.X = varX;
			
				item.Y = varY;
			
				item.Type = varType;
			
				item.Direction = varDirection;
			
				item.Status = varStatus;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn UidColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn IdColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn MapIDColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn XColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        public static TableSchema.TableColumn YColumn
        {
            get { return Schema.Columns[4]; }
        }
        
        
        
        public static TableSchema.TableColumn TypeColumn
        {
            get { return Schema.Columns[5]; }
        }
        
        
        
        public static TableSchema.TableColumn DirectionColumn
        {
            get { return Schema.Columns[6]; }
        }
        
        
        
        public static TableSchema.TableColumn StatusColumn
        {
            get { return Schema.Columns[7]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string Uid = @"UID";
			 public static string Id = @"ID";
			 public static string MapID = @"MapID";
			 public static string X = @"X";
			 public static string Y = @"Y";
			 public static string Type = @"Type";
			 public static string Direction = @"Direction";
			 public static string Status = @"Status";
						
		}
		#endregion
		
		#region Update PK Collections
		
        #endregion
    
        #region Deep Save
		
        #endregion
	}
}

You should also know that entity framework is a bit faster than Subsonic, but querying has never been easier while using Subsonic, and it can handle a great deal of information without crashing