Advertisement

MySql users database

Started by December 29, 2002 05:21 PM
21 comments, last by Raduprv 22 years, 1 month ago
Soon I will start working at my server code (the client is almost ready). And I was thinking that it would be very nice to store all the users (username, password, skills, inventory, etc.) in a MySQl database. The advantages are enormous, but, I was thinking if someone did that before, and how fast it is. Ideally, the database will be accessed only at log in and log out time (and maybe each 5 minutes, to save all the online players info, just in case the server crashes, etc.) BTW, does anyone know a nice, portable, LGPL, C (not C++) mysql library? Thanks in advance. Height Map Editor | Eternal lands
I think that mySQL is a good solution here and it is used in a few comercial games, Dark Age of Camelot, for one. It''s being used on the project that I''m working on and have not had any problems using it. www.mysql.com also has some nice GUI''s that help make database management much easier. mySQL works on the systems that we are running ( Windows and Linux ) and it''s easy to build into the server software.

--------
Andrew
Advertisement
I know a lot about MySQL, I am also a web programmer (php/mysql). But I never used it from C, so that''s why I asked about a nice/easy/free library.
BTW, is your server threaded or not? I mean, each player has it''s own thread? Mine isn''t threaded, and I don''t know if there will be some nasty delay, when someone will log in/out. In general, a MySQL querry should take 00 or 01 MS (a simple query), so that shouldn''t be a problem, but it''s always a good idea to check with other who did it

Thanks for the answer.

Height Map Editor | Eternal lands
They have an official API on the www.mysql.com page called MySQL++

and it is very fast, just remember to keep the connection open to mysql while your program is running, it is the connection phase that takes time.
*c++ = true;
Hmm, that library seems to have everythign I am looking for, except for one thing: It is C++, and I want C...

Height Map Editor | Eternal lands
just make a page you can pass values to, then open a connection with sockets and send a get command for that page. i.e.

  SOCKET sock;struct sockaddr_in addr;sock = socket(AF_INET, SOCK_STREAM, 0);dest_addr.sin_family = AF_INET;dest_addr.sin_port = htons(80);dest_addr.sin_addr.s_addr = inet_addr(my_server_ip);memset(&(dest_addr.sin_zero), '\0', 8);connect(sock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr));char *msg="GET /playerupdate.php?hp="+palyerhp+"&playermp="+playermp+" HTTP/1.0 Host: www.myserver.com";send(sock,msg,sizeof(msg),0);   


although you should probably amke it more secure by required some sort of authentication.

[edited by - elcrazon on December 29, 2002 8:30:47 PM]
Advertisement
Eh, mysql++ is the C++ version of the native C library, libmysql... try that instead.

Also, if you''re using MySQL 4.x then the libraries are GPL, not LGPL, so if you release the server binary, you also got to release the source (they''re very fussy about this and there''s always a lot of debate about it on the mysql mailing lists). Of course, if it''s an MMO style game, then you''re probably not going to release the server, so it doesn''t matter. The other thing is that you can always pay MySQL AB for a different (commercial) license.
Database access are common in MMOG. It provides scalability of application in terms of hardware if you ever need it. Note that however, database access would always be slower than in-memory access as well as file access, but the performance hit should not be worried, unless access is frequent, in which case you should implement a cache or an in-memory image of frequently acccessed data.

Avoid starting too many threads for your application, since it does a performance hit as well. Imagine 500 threads running simultanously on a pc. That's like running 500 applications. Imagine the performance.

What ElCrazon suggested was an interesting solution, making data access function like calling Web Services. It does furthur abstract application from data, and do allow easy future development of clients on other platforms like Mac, Win, XBox, PS2, PDA, Next-Gen Handphone, etc

Massive Multiplayer Online Gaming Discussion, Design and Development

[edited by - _dot_ on December 30, 2002 10:25:24 AM]
If the Server where the mySQL Database is running got enough ram to hold the hole Gamedata in RAM you can even configure mySQL to cache the hole database in RAM. This should be fast enough for every Player-load/save/test operation.
quote:
Original post by Dean Harding
Eh, mysql++ is the C++ version of the native C library, libmysql... try that instead.

Also, if you''re using MySQL 4.x then the libraries are GPL , not LGPL, so if you release the server binary, you also got to release the source (they''re very fussy about this and there''s always a lot of debate about it on the mysql mailing lists). Of course, if it''s an MMO style game, then you''re probably not going to release the server, so it doesn''t matter. The other thing is that you can always pay MySQL AB for a different (commercial) license.


I need LGPL, since giving the source code of the server is NOT an option.. So, if I use the linmysql from MySQL 3.x.x series, it should do the trick, right?



Height Map Editor | Eternal lands

This topic is closed to new replies.

Advertisement