Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Bing, Yandex

Members: 0
Guests: 15
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
Evoru (32)
Related Links
» SmaugMuds.org » Codebases » AFKMud Support & Development » MySQL Conversion for AFKMud
Forum Rules | Mark all | Recent Posts

MySQL Conversion for AFKMud
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Jun 5, 2006, 3:13 pm   Last edited Jun 5, 2006, 3:14 pm by Zarius
Go to the top of the page
Go to the bottom of the page

Zarius
Apprentice
GroupMembers
Posts69
JoinedApr 23, 2002

I'm currently working on converting most the static structures to MySQL and was wondering if there was any general interest in my releasing the changes to the community. I've only done a couple so far as a proof of concept (Changelog and Connhist) which makes it kinda nice for a few reasons.

1. With most there is no need to worry about save/load of text files which reduces the code amount quite a bit as well as memory. Only memory should be what is currently loaded.

For instance connhist.c went from 11.5k to 7k.

2. Don't need lists to store, consequently, no need to free them at shutdown
3. Accessibility to external things such as a web site that displays realtime data without having to connect to the mud.
4. Accessibility to other muds that can share data (future thoughts) such as a playerbase, help files.
5. Quicker boot as there will be a lot a lot less file reading.
6. Probably more I can't think of right now. :grinning:

If there is interest I can make some functionality to switch between MySQL and text files (currently, I'm not making it switchable) or release as a patch against stock AFKMud and people can do what they want (but I warn it requires a lot of code changes). If Samson wants to release a MySQL version of the codebase I can provide that as well at specific milestones.
       
Post is unread #2 Jun 5, 2006, 6:45 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

I've been increasingly interested in toying with SQL, mainly for the helps as a final means of killing off the webserver code. I like the availability of helpfiles from the website but the webserver code has become a parriah lately. So I'd definitely be interested in seeing what you've done, and would also be very interested in seeing SQL support for 2.0 as a native feature. 1.x would probably only get it as a patch since there are no plans to do any more major feature work on the current branch.

Enabling database support in the MUD would also allow for an interesting experiment I've wanted to try - having the in-game boards also visible from the web ( QSF mod of course, would I pick anything else? :P ) and making it possible to post topics from either end. Sure, it may not be entirely useful but I like the novelty of it enough to want to try that. Not all forums would be publically viewable via the web of course.
       
Post is unread #3 Jun 6, 2006, 1:03 pm
Go to the top of the page
Go to the bottom of the page

Thara
Apprentice
GroupMembers
Posts10
JoinedAug 27, 2005

I for one would be in favour for database support within the MUD... Even if it covered the basic static information initialy - it would then allow for people to expand the code further as the basics (open, close, update, etc) code would already be in place within the MUD.

It would be very useful and a great opertunity to add in the account system - another thing that I feel would be a great plus for the MUD. On the DB side of the house, perhaps ODBC would be a good idea?

How are things going with 2.0?
       
Post is unread #4 Jun 6, 2006, 7:38 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Glad to see there's some interest in this afterall. One of the reasons I hesitated in the past to consider it was because it might restrict the use of the base too much. However I'm guessing this might be the opposite and we should have done it awhile back.

As far as an account system, I'm not entirely opposed to the idea, but I personally haven't ever seen the point. Might be because I always tended to only have one or two characters at any given time on a mud and never needed more complex ways to keep track of them all. The main problem these days is that we lack the time to get involved in larger feature additions like this. So something like this would probably need to come in the forum of a patch developed elsewhere. Unless people are willing to wait months and months for it :P

I don't know anything about how ODBC works. I have some grasp of MySQL though, even if it is only from exposure to it in PHP developing the forum code.

As far as 2.0 itself, it's oozing along slowly. Am waiting on Justice to release his javascript mudprog system so it can be included in 2.0. If the SQL support gets off the ground, that will also go into 2.0. Other than that, it gets attention when there's enough time for it. It's been mostly up-porting FUSS fixes to it over the last few months.
       
Post is unread #5 Jun 6, 2006, 8:28 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

Personally, I might be interested if you do it in a way that can be ported to FUSS, especially as it relates to things like an account system and the help file.
       
Post is unread #6 Jun 6, 2006, 8:43 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Generaly anything made for AFKMud should port to Smaug easily. Afterall, even in C++ form, they're pretty much the same at the level the SQL code would be operating. It obviously would not become standard in FUSS but I'm sure some kind of snippet could be made from it.
       
Post is unread #7 Jun 7, 2006, 8:49 am
Go to the top of the page
Go to the bottom of the page

Zarius
Apprentice
GroupMembers
Posts69
JoinedApr 23, 2002

Well I know this code works on FUSS because I originally worked on it there because I thought I was having an issue with g++. Its pretty simple actually. The only problem I've had so far is passing certain characters in the query. Mainly the ' char. It needs to be escaped like \' in the query, but for the life of me, I can't seem to get it to pass that way unless I hard code it as such. I'll post my changes.c along with the mysql functions so you can get a good idea how it works.
       
Post is unread #8 Jun 7, 2006, 5:55 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Is there a c/c++ equivalent to the php mysql_real_escape_string() function? If so then that's what you'll need to be able to properly escape not only the single quote, but double quots and a couple of other things.
       
Post is unread #9 Jun 7, 2006, 10:14 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

Ideally, once you've got the kinks worked out, Zarius, especially if you are already snippetizing it for others anyway, you could upload the end result to www.mudbytes.net for the rest of the community to reap the benefits of too. :)
       
Post is unread #10 Jun 8, 2006, 9:32 am
Go to the top of the page
Go to the bottom of the page

Zarius
Apprentice
GroupMembers
Posts69
JoinedApr 23, 2002

Samson said:

Is there a c/c++ equivalent to the php mysql_real_escape_string() function? If so then that's what you'll need to be able to properly escape not only the single quote, but double quots and a couple of other things.


that function is from the mysql library, so yes :)

I figured out whats doing it so I should be able to post the results soon. Got hset working and everything as well.
       
Post is unread #11 Jun 30, 2006, 4:46 am
Go to the top of the page
Go to the bottom of the page

kiasyn
Magician
GroupMembers
Posts121
JoinedJun 30, 2006

Here is the code I used for MySQL queries.

MYSQL_RES *query_db( char *fmt, ... )
{
	int		state;
	MYSQL_RES *	result = NULL;
	va_list		args;
	int		i = 0;
	double		j = 0;
	ull		k = 0;
	char            *s = 0, *out = 0, *p = 0;
	char            safe [MAX_STRING_LENGTH];
	char            query [MAX_STRING_LENGTH];
	char		oldquery[MSL];

	if ( port != MAIN_PORT )
	return NULL;

	*query = '\0';
	*safe = '\0';
	mysql_free_result( result );
	strcpy( oldquery, fmt );
	va_start(args, fmt);
	for ( p = fmt, out = query; *p != '\0'; p++ ) {
		if ( *p != '%' ) {
			*out++ = *p;
			continue;
		}
            switch ( *++p ) {
                        case 'c':
                                i = va_arg (args, int);
                                out += sprintf (out, "%c", i);
                                break;
                        case 's':
                                s = va_arg (args, char *);
                                if ( !s ) {
                                        out += sprintf (out, " ";);
                                        break;
                                }
                                mysql_real_escape_string (&mysql, safe, s, strlen(s));
                                out += sprintf (out, "%s", safe);
                                *safe = '\0';
                                break;
                        case 'd':
                                i = va_arg (args, int);
                                out += sprintf (out, "%d", i);
                                break;
                        case 'f':
                                j = va_arg (args, double);
                                out += sprintf (out, "%f", j);
                                break;
			case 'l':
				k = va_arg (args, ull);
				out += sprintf (out, "%lld", k );
				break;
                        case '%':
                                out += sprintf (out, "%%";);
                                break;
                }
        }
        *out = '\0';
	va_end(args);

	state = mysql_query( &mysql, query );
	if ( state != 0 )
	{
		debug_string( "MySQL Query: %s return State: %d", oldquery, state );
		snprintf( bug_buf, MSL*2, mysql_error(&mysql) );
		debug_string( bug_buf );
		perror( bug_buf );
		mysql_free_result( result );
		return NULL;
	}
	if ( sysdata.showmysql )
	debug_string( "MySQL Query: %s", query );
	result = mysql_store_result(&mysql);
	return result;
}


Obviously it will require a few changes but yeah..

Usage is fairly simple..

query_db( "INSERT INTO blah VALUES('%s')", "blah ' blah '' '' '' ''" );

automatically mysql_escapes them. :P
       
Post is unread #12 Jul 29, 2006, 12:27 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Any word on progress? :)
       
Post is unread #13 Aug 2, 2006, 10:58 am
Go to the top of the page
Go to the bottom of the page

Zarius
Apprentice
GroupMembers
Posts69
JoinedApr 23, 2002

Sent you the files, looking forward to AFK 2.0
       
Post is unread #14 Aug 2, 2006, 3:33 pm
Go to the top of the page
Go to the bottom of the page

mordecai

GroupMembers
Posts99
JoinedNov 17, 2005

Share the wealth!
       
Post is unread #15 Aug 3, 2006, 10:14 am
Go to the top of the page
Go to the bottom of the page

Zarius
Apprentice
GroupMembers
Posts69
JoinedApr 23, 2002

mordecai said:

Share the wealth!


Still working on an official snippet-like release, however you'll see it in some fashion in AFK 2.0 hopefully.
       
Post is unread #16 Aug 3, 2006, 8:25 pm
Go to the top of the page
Go to the bottom of the page

mordecai

GroupMembers
Posts99
JoinedNov 17, 2005

From what I heard, it will be a while til 2.0, so I was being impatient. :)
       
Post is unread #17 Aug 3, 2006, 8:43 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

An initial release of 2.0 in whatever form it's in is waiting on one more large contribution before forking for a release. So it's not as far away as you might think now. Even if it isn't as big of an earth shattering release as we'd have liked.
       
Post is unread #18 Aug 4, 2006, 9:16 am
Go to the top of the page
Go to the bottom of the page

mordecai

GroupMembers
Posts99
JoinedNov 17, 2005

I am curious, did you include the improved floodfill algorithm?
       
Post is unread #19 Oct 5, 2006, 1:04 pm
Go to the top of the page
Go to the bottom of the page

Omega

GroupMembers
Posts13
JoinedOct 5, 2006

Any update on this, Zarius? Can we expect to see it in snippet form anytime soon? I'm quite looking forward to it (since it means I won't have to do it myself). Thank you.

       
Post is unread #20 Oct 6, 2006, 12:32 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

This will be available with the 2.0 code. Zarius is of course free to release it separately but we have no plans to do so outside of the codebase. But don't worry. Assuming I can dig up some time and can get a couple more things done I want done the 2.0 code should be released "soon".
       
Pages:<< prev 1, 2 next >>