Register for your free account! | Forgot your password?

You last visited: Today at 17:03

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Xml Database Structure

Discussion on Xml Database Structure within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Xml Database Structure

Alright, this is still unfinished, At the moment it only supports MYSQL, but I will finish rest later, if I get time. It's untested so far and so, but looks like it would work.

Anyways, when I get home I will test it and fix whatever I find of bugs etc.

It also still contains the xml converter as it's under solution.

The XmlLib is a DLL, which you just add as reference to your project, however there is some major things you need to do, before you actually use it.

First of all you have to initialize the dbconfig.
The extension of all xml files using this library should be ".db.xml" as well.

Config.db.xml example
Code:
<?xml version="1.0" encoding="utf-8" ?>

<dbconfig>
	<dblanguage>MYSQL</dblanguage>
	<dbconnectionstring>HOST;USER;PASS;DATABASE</dbconnectionstring>
</dbconfig>
Now that the config has been created you have to initialize it.

Code:
XmlDbConfig.Initialize();//This will initialize the config.
XmlDbConfig.InitializeDbConnection();//This will initialize the database connection.
Now that the config is initialized, then you will need to intialize the different database structures. A good idea would be to do a dictionary with the tablename as key and the database structure as value.
Code:
Dictionary<string, XmlDbStruct> DatabaseStructures;//The collection of the database structures.
To Initialize a dbstruct you call Read().
An example on how a dbstruct could be initialized.
Code:
XmlDbStruct strct = new XmlDbStruct();//Initializing the xmldbstruct.
strct.Read("accounts.db.xml");//Reading the database structure.
DatabaseStructures.Add("Accounts", strct);//Adding the structure to the dictionary.
There is an example in the debug folder called example.db.xml.
It looks like following:
Code:
<?xml version="1.0" encoding="utf-8" ?>

<Accounts Primarykey="UID">
	<UID datatype="UInt32">
		1000000
	</UID>
	<AccountName datatype="String" datasize="16">
		Error
	</AccountName>
	<Password datatype="String">
		1234
    </Password>
</Accounts>
Note: datasize is only available for strings.

The Get() will get a XmlDbList out of the database, which is the dblist containing all values you want to insert/update/read. You have to update the XmlDbList, whenver you want to, but only call Get() on load and Insert()/Fill() on logout or whenever you want to save.

Insert() will insert a new column to the table, out of a XmlDbList.
Fill() will fill (update) a column to the table, out of a XmlDbList.

Library Members

AlreadyReadDbException: <Class>
Code:
AlreadyReadDbException();
ConfigLoad: <Enum>
Code:
None,
DatabaseLanguage,
ConnectionString
DataType: <Enum>
Code:
Char,
String,
SByte,
Int16,
Int32,
Int64,
Byte,
UInt16,
UInt32,
UInt64,
Double,
Float,
Boolean
DBLanguage: <Enum>
Code:
MYSQL,
MSSQL
DBValue: <Struct>
Code:
DataType dataType;
object Value;
EmptyDbStructException: <Class>
Code:
EmptyDbStructException();
InvalidColumnException: <Class>
Code:
InvalidColumnException(string column);
InvalidDbFileException: <Class>
Code:
InvalidDbFileException();
XmlDbConfig: <Class>
Code:
Initialize(string configfile);
InitializeDbConnection();
DBLanguage DBLanguage;
string ConnectString;
XmlDbList: <Class>
Code:
XmlDbList(object PrimaryKey);
string PrimaryKey;
void AddOrUpdate(string column, object value);
KeyValuePair<string, object>[] GetDbStruct();
XmlDbStruct: <Class>
Code:
XmlDbStruct();
string TableName;
void Read(string DbFile);
void Fill(XmlDbList dblist);
void Insert(XmlDbList dblist);
XmlDbList Get(object PrimaryKey);
I think that's it at the moment.

Download: (Includes the whole solution! ini to xml converter & the xml library)


Enjoy .
I don't have a username is offline  
Thanks
2 Users
Old 02/28/2012, 10:44   #2
 
PretendTime's Avatar
 
elite*gold: 0
Join Date: Nov 2011
Posts: 68
Received Thanks: 9
Like always your releases amaze me =D thanks
PretendTime is offline  
Old 02/28/2012, 10:59   #3
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Maybe I'm just dumb but if you're going to xml structure your database.... why not just use nhibernate? Same idea except you get a fully managed database solution which works phenomenally well.
pro4never is offline  
Old 02/28/2012, 11:02   #4


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
I'm failing to see the point to be honest, all the downsides of flat file with no advantages beyond the fact that your able to use the framework's classes to manage it?
Korvacs is offline  
Old 02/28/2012, 11:34   #5
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by pro4never View Post
Maybe I'm just dumb but if you're going to xml structure your database.... why not just use nhibernate? Same idea except you get a fully managed database solution which works phenomenally well.
Because I will learn more by trying to do things myself, I know nhibernate, this is more like a fun project I did.

Quote:
Originally Posted by Korvacs View Post
I'm failing to see the point to be honest, all the downsides of flat file with no advantages beyond the fact that your able to use the framework's classes to manage it?
I don't get your question exactly, maybe it's just me being dumb.
I don't have a username is offline  
Old 02/28/2012, 11:57   #6


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Whats the point, is basically what i was getting at..
Korvacs is offline  
Old 02/28/2012, 12:00   #7
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by Korvacs View Post
Whats the point, is basically what i was getting at..
Read what I said @ pros quote.
I don't have a username is offline  
Old 02/28/2012, 12:06   #8


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
So its entirely pointless as releases go >.<
Korvacs is offline  
Old 02/28/2012, 12:30   #9
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by Korvacs View Post
So its entirely pointless as releases go >.<
Maybe some would be interesting in it.
I don't have a username is offline  
Old 02/28/2012, 16:17   #10
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
That someone would be me, has anybody ever checked which is fastest? ini or xml?

If your like me, and simply wont touch MySQL or any of the sort... :P, flatfile is the next option.

Might rewrite my base to read xml vs ini, not sure though.
_DreadNought_ is offline  
Old 02/28/2012, 16:33   #11


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Quote:
Originally Posted by _DreadNought_ View Post
That someone would be me, has anybody ever checked which is fastest? ini or xml?

If your like me, and simply wont touch MySQL or any of the sort... :P, flatfile is the next option.

Might rewrite my base to read xml vs ini, not sure though.
Your right!

If your thick and refuse to accept that managed database solutions scale 100s of times better under load and are 10 fold more flexible then this is the article for you.

Although technically the performance gain from xml over ini is minimal as your still parsing data at the end of the day, the advantage comes with the fact that xml is actually supported natively by .net and you dont have to hack together old methods using pinvoke to read a file.
Korvacs is offline  
Old 02/28/2012, 20:26   #12
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Meh, my computer is pretty old and ******, and ever since my reformat mysql hasnt worked for ****.

I attempted MsSQL once and failed epicly.

I just dont feel making MySQL work on my computer is worth the effort, so why did Hybrid use INI(And bin) over all the other database options on his latest source?
_DreadNought_ is offline  
Reply


Similar Threads Similar Threads
SQL-DB structure
05/29/2010 - Silkroad Online - 0 Replies
Hey folks, does anyone happen to have the structure of the official SRO SQL-DB? I need no more than the column names and their associated table names (usually located in the DB "INFORMATION_SCHEMA").
[C] Player Structure [PW-MS]
03/16/2010 - PW Hacks, Bots, Cheats, Exploits - 5 Replies
Hi everyone. Just wanna share the stuff i found out when reversing the game. Assuming you are using dll injectiong and you have the base pointer to all player stats, you can simply access all the data from a nice and userfriendly structure. Here how to read from memory: VARBASE *Stats = 0xBASEPOINTER; printf("Player HP: %d/%d", Stats->p_Player->Current_HP, Stats->p_Player->Maximum_HP); And here the structure you need to make this available: typedef unsinged char BYTE;
TQ Database Structure
10/16/2009 - CO2 Private Server - 1 Replies
INSERT INTO `cq_generator` VALUES ('6102', '1075', '0493', '0563', '0021', '0038', '0015', '0001', '0010', '0011', '0000', '0000', '0000', '0000'); index0 = spawnUID index 1 = mapID index 2 = X index 3 = Y index 4 = (not 100%, but i think it's X spawn radius) index 5 = (not 100%, but i think it's Y spawn radius) index 6 = amount to spawn? index 7 = ?
packet structure
03/09/2008 - Conquer Online 2 - 16 Replies
For what I'd like to do, I think packets are the place to start. After that, probably java then C and VB. This is a question for the people here who are self-taught... what resources would you recommend for... 1. understanding packet structure 2. learning some programming language without enrolling at the local university I'm mainly interested in packet structure and how to capture/decipher/edit/send them, and eventually I'd like to "automate" these functions by writing some programs. ...



All times are GMT +1. The time now is 17:03.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.