Jump to content


Photo

Gm Database System v10.3


  • Please log in to reply
86 replies to this topic

#61 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 26 May 2010 - 03:43 PM

Oh wow I came up with some insanely useful functions.

db_table_clear_area(table, x1, y1, x2, y2, val); (val is what to change the entry value to)
db_table_copy_area(table, x1, y1, x2, y2);
db_table_paste_area(table, x1, y1);

I'm about to make my own script to handle that, but I think it would be insanely useful.

Edited by brod, 26 May 2010 - 03:55 PM.

  • 0

#62 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 26 May 2010 - 07:11 PM

benetonmovie -- you wouldn't be at all mad if I created my own database scripts in competition with yours would you? (maybe even benchmark it against yours?) :)

it'll be open source of course :)

(although I'm asking as if for your permission, it really is going to happen anyway, just preparing you ahead of time...I'll put a mention in for you since you gave me the idea to do it)
  • 0

#63 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 27 May 2010 - 11:32 AM

db_table_clear_area(table, x1, y1, x2, y2, val); (val is what to change the entry value to)
db_table_copy_area(table, x1, y1, x2, y2);
db_table_paste_area(table, x1, y1);

Good suggestions, thanks! Not sure about the usefulness of the copy-paste though...?

benetonmovie -- you wouldn't be at all mad if I created my own database scripts in competition with yours would you? (maybe even benchmark it against yours?)

Why don't we work together? :unsure:
But no lol, I wouldn't be mad...
  • 0

#64 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 28 May 2010 - 01:14 AM

benetonmovie -- you wouldn't be at all mad if I created my own database scripts in competition with yours would you? (maybe even benchmark it against yours?)

Why don't we work together? :unsure:
But no lol, I wouldn't be mad...


Well sure, we can work together, if you can decipher the way I'm writing the database code. Here's a little taste of what I have:

id = database_create()

var b;

b = createbuffer();

	writeint(1, b);	 //version
	writeint(64, b);	//end of file +1 pointer
	writeint(0, b);	 //number of tables
	writeint(0, b);	 //first table pointer
	writeint(0, b);	 //last table pointer
	writeint(0, b);	 //size of free space
	writeint(0, b);	 //first free space pointer
	writeint(0, b);	 //last free space pointer

	writechars(string_repeat(chr(0),32), b); //reserved

return b;

//----------------------------------------------------------

database_destroy(id)

freebuffer(argument0);

//----------------------------------------------------------

mptr = database_allocate(id, size)

var _freespace, _this, _prev, _next, _size;

setpos(20, argument0);
_freespace = readint(argument0);
if (_freespace >= argument1)
{
	_this = readint(argument0);
	while (_this != 0)
	{
		setpos(_this, argument0);
		_prev = readint(argument0);
		_next = readint(argument0);
		_size = readint(argument0);
		if (_size >= argument1)
		{
			if (_size >= (argument1 + 12))
			{
				setpos(20, argument0);
				writeint(_freespace - argument1, argument0);
				_size -= argument1;
				setpos(_this + 8, argument0);
				writeint(_size, argument0);
				_this += _size;
				break;
			}
			setpos(20, argument0);
			writeint(_freespace - _size, argument0);
			if (_prev == 0)
			{
				setpos(24, argument0);
				writeint(_next, argument0);
			} else {
				setpos(_prev + 4, argument0);
				writeint(_next, argument0);
			}
			if (_next == 0)
			{
				setpos(28, argument0);
				writeint(_prev, argument0);
			} else {
				setpos(_next, argument0);
				writeint(_prev, argument0);
			}
			break;
		}
		_this = _next;
	}
} else {
	setpos(4, argument0);
	_this = readint(argument0);
	writeint(_this + argument1, argument0);
	setpos(_this, argument0);
	writechars(string_repeat(chr(0), argument1), argument0);
}
return _this;

//----------------------------------------------------------

database_addfree(id, mptr, size)

var _last, _freespace;
setpos(20, argument0);
_freespace = readint(argument0);
writeint(_freespace + argument2, argument0);
setpos(28, argument0);
_last = readint(argument0);
if (_last == 0)
{
	setpos(24, argument0);
	writeint(argument1, argument0);
} else {
	setpos(_last + 4, argument0);
	writeint(argument1, argument0);
}
setpos(argument1, argument0);
writeint(_last, argument0);
writeint(0, argument0);
writeint(argument2, argument0);

//----------------------------------------------------------

tloc = database_table_select(id, name)

var _this, _name, _cname;

_cname = string_lower(argument1);
setpos(12, argument0);
_this = readint(argument0);

while (_this != 0)
{
	setpos(_this + 20, argument0);
	_name = readstring(argument0);
	if (_name == _cname) break;
	setpos(_this + 4, argument0);
	_this = readint(argument0);
}
return _this;

As you can see, I'll be using 39dll....BUT...I am going to probably implement it directly into the 39dll itself and rerelease a new dll for all of this. I have the file format here if you understand formats:

header:
 0 int version
 4 int EOF+1 pointer
 8 int tables
12 table* first
16 table* last
20 int freespace
24 free* first
28 free* last
32 32-byte expansion

table:
 0 table* prev
 4 table* next
 8 int columns
12 column* first
16 column* last
20 zstring name

column:
 0 column* prev
 4 column* next
 8 int type
12 int typelength
16 int flags
20 entry* first
24 entry* last
28 entry* orderfirst
32 entry* orderlast
36 entry* default
40 int incrementer
44 zstring name

entry:
 0 column* parent
 4 entry* prev
 8 entry* next
12 entry* orderprev
16 entry* ordernext
20 entry* columnprev
24 entry* columnnext
28 ? data

free:
 0 free* prev
 4 free* next
 8 int size

Similar to SQL, types can be: date, string, integer, ID (auto increment), etc. Flags can be: auto-incremented (ID is automatically set for this), ordered ascending/descending/none, not null, defaulted, etc. The entries are laid out in a grid fashion, this allows columns to be added without having to rewrite the entire file or be renamed/sorted, etc. etc. (you only have to change pointers). Let me know if this is something you'd be interested in working on with me.

:(

Edited by sabriath, 28 May 2010 - 01:16 AM.

  • 0

#65 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 28 May 2010 - 02:52 AM

Oh, I'm not familiar with 39dll. I don't think I would be much help... but your project is very promising and I look forward to it! :unsure:
  • 0

#66 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 26 November 2010 - 07:37 PM

Version 10.1 now available as scripts only (see first post for details). It contains an important bug fix and sends debug messages in debug mode.
  • 0

#67 HaRRiKiRi

HaRRiKiRi

    GMC Member

  • GMC Member
  • 1364 posts

Posted 27 November 2010 - 11:48 AM

Version 10.1 now available as scripts only (see first post for details). It contains an important bug fix and sends debug messages in debug mode.

Do you have comments in thous scripts that use // instead of /* */? That can cause problems with extensions, as all new line characters are removed in the extension and so code like this:
//This is comment
i = 10;
Would turn into this:
//This is comment i = 10;
And that will surely cause problem.
  • 0

#68 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 27 November 2010 - 10:11 PM


Version 10.1 now available as scripts only (see first post for details). It contains an important bug fix and sends debug messages in debug mode.

Do you have comments in thous scripts that use // instead of /* */? That can cause problems with extensions, as all new line characters are removed in the extension and so code like this:
//This is comment
i = 10;
Would turn into this:
//This is comment i = 10;
And that will surely cause problem.

Thanks! I removed all comments and it works fine now. I updated my first post with the new version of the extension.
  • 0

#69 BenBaron

BenBaron

    GMC Member

  • New Member
  • 5 posts

Posted 29 May 2011 - 04:37 PM

Hi,

at first...thanks for this amazing extension. Without it my life would be a lot harder :lol: ! I stumbled across the following problem:

I am trying to destroy several columns within my table (db_column_destroy). But as soon as I try to destroy more than one column I am getting this error: "Data structure with index does not exist." Every column is destroyable on its own but as soon as there are more it throws this error.

Any info on this?

Greets, Benny
  • 0

#70 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 30 May 2011 - 01:47 AM

Hey Benny, thanks for the feedback. I couldn't reproduce the bug though, could you please send me a small GMK example in which it happens? Thank you very much.
  • 0

#71 BenBaron

BenBaron

    GMC Member

  • New Member
  • 5 posts

Posted 31 May 2011 - 06:51 PM

Hey Benny, thanks for the feedback. I couldn't reproduce the bug though, could you please send me a small GMK example in which it happens? Thank you very much.


Mailed it to admin [AT] benetonfilms.com.

All the best, Benny
  • 0

#72 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 06 June 2011 - 04:51 AM

I have found and fixed the critical bug. I also added full GM 8.1 compatibility by updating functions with an arbitrary number of arguments (db_entry_add() and db_entry_insert()). As a result the "fields" argument was no longer needed in these functions, so I removed it. Please update your scripts!

Go to first post to download version 10.2. :snitch:

EDIT: It seems there are new bugs in this version... I should have taken more time testing. Will look at it and update as soon as possible.

Edited by benetonmovie, 06 June 2011 - 04:18 PM.

  • 0

#73 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 28 July 2011 - 09:38 PM

Version 10.3 is finally available! The first "stable" release in a while (I hope!). Here's what's new:

- Fixed a bug with db_entry_add() introduced in the last version
- New functions db_table_exists() and db_column_exists()
- New constants DB_TYPE_REAL and DB_TYPE_STRING for column types
- Updated more functions with an arbitrary number of arguments. Everytime it says an argument is optional in the documentation, you should be able to omit it entirely.
- Improved error-checking

It's only compatible with GM 8.1. See first post for download!
  • 0

#74 lballaty

lballaty

    GMC Member

  • New Member
  • 83 posts

Posted 15 December 2011 - 08:04 PM

Version 10.3 is finally available! The first "stable" release in a while (I hope!). Here's what's new:

- Fixed a bug with db_entry_add() introduced in the last version
- New functions db_table_exists() and db_column_exists()
- New constants DB_TYPE_REAL and DB_TYPE_STRING for column types
- Updated more functions with an arbitrary number of arguments. Everytime it says an argument is optional in the documentation, you should be able to omit it entirely.
- Improved error-checking

It's only compatible with GM 8.1. See first post for download!


Hi I just came across this and it's really simplified some things I was trying to do. I have one question. Would it be possible to store a picture in a table? If so then I would be able to import and export pictures that way into an existing and already compiled game wouldn't I?

Of course they would only stick around if I somehow saved them after .... but it would be enough for me if I could just provide an import file and then have an option to import data through the database functionality.

Hmm ... is that a silly idea?
  • 0

#75 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 16 December 2011 - 10:22 PM

Hi I just came across this and it's really simplified some things I was trying to do. I have one question. Would it be possible to store a picture in a table? If so then I would be able to import and export pictures that way into an existing and already compiled game wouldn't I?

It might be possible but I haven't tried it. You would have to read the image file and save its binary data in the table (which I'm not even sure is possible) and then every time you want to load it back to display it in your game/project, write the binary data back to a file and add a sprite from this file. It's worth a try.
  • 0

#76 Bleed

Bleed

    Chevalier

  • GMC Member
  • 668 posts
  • Version:GM:Studio

Posted 23 December 2011 - 11:51 AM

I have to hearty thank you for making this extremely useful system, you have no idea how hard it was to work with 20+ lists at a time (well maybe you do) just to get some simple values.
I'm in the process of writing version 1.0 of my map editor and this extension has proven a huge time saver. Version 0.9 uses about 57 open lists in total to keep track of all the mess and it was a big pain to work with. Things have gotten alot simpler since i've incorporated this extension, for that you deserve proper respect and recognition

Also, having to work with so many table entries at a time i make thoroughly use of many features this extension offers...no bugs or limitations to report. Posted Image although i do have a suggestion.

As you know, when we remove an entry from, for example : the middle of the table, the table size goes down -1 and all entries above the removed entry get position -1
(similar to a First-In First-Out stack), therefore if i was to use db_entry_get_pos_all to make a list with some random positions i need removed from a table and then later do a loop with db_entry_delete on the table, the original list holding the positions that need removing would be obsolete since the table wont have the same positions as the list, am i right?

What i suggest is, make a db_entry_delete_all or something so that all positions in need of deletion would execute in one pass while avoiding this collapsing reaction.
-Maybe null all positions on the first pass (no deletion), then do a loop on the whole table to remove the empty (null) entries? *could prove slow especially on huge tables*
-Or move all the (listed) positions at the start of the table on the first pass then do a (no. of listed entries) loop to remove them. *faster since you wont have to loop through the whole table*

Question : Know anything about the limitation in the number of entries in the lists/table?...since my tables averagely pass the 12 digits in size.

Again, thank you very much for this useful system and happy Christmas. Posted Image

Edited by Bleed, 23 December 2011 - 01:03 PM.

  • 0

#77 lballaty

lballaty

    GMC Member

  • New Member
  • 83 posts

Posted 21 January 2012 - 10:58 PM

Hi I just wanted to mention that I found this extremely useful. It's very flexible and easy to use. I especially like that I can control when to write it to the storage. This means that I can load once modify things in the course of running the app and save at the appropriate time without having every change written right away. It really sped things up over doing similar things with an sql database running in the background. I wish I had found this a while back ... but it's better late than never isn't it.

This is really excellent and thanks for sharing it. :biggrin:
  • 0

#78 grugin

grugin

    GMC Member

  • GMC Member
  • 118 posts

Posted 26 March 2012 - 12:27 PM

Great system here, I use it alot.

Can we have the constants.txt because I want to use your system with GM:studio by importing your scripts ?

Thanks in advance !
  • 0

#79 lballaty

lballaty

    GMC Member

  • New Member
  • 83 posts

Posted 29 March 2012 - 08:17 AM

Hi, I just bought the HTML5 version of GM and I tried to import this including the extension but I can't seem to get it to work.

Has anyone else tried it?

thanks
  • 0

#80 grugin

grugin

    GMC Member

  • GMC Member
  • 118 posts

Posted 29 March 2012 - 10:31 AM

Yes it works but you must import the gml file not the gex if you want to use it in html5 mode. After that, you must recreate the arborecense and comment all db_log call because GMS doesn't have the debug_mode constant.
If you have any problem, let me know and I can send you a gmz file
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users