user database in conjuntion with winsock.

This is a discussion on user database in conjuntion with winsock. within the C++ Programming forums, part of the General Programming Boards category; Well im making game..if you didnt know from my other posts... first text based then.. im going to make a ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    13

    user database in conjuntion with winsock.

    Well im making game..if you didnt know from my other posts... first text based then.. im going to make a client that uses a win32 window instead of console... but use both.. I like text based games better lol...

    Well I was just wondering.. its going to have a chat system... meaning im going to have a user list... So I was just wondering what kind of database should I use/make to store this on the server?

    Should I make like a mysql database of some sort to hold who's online and who left? Or would I use a different kind of data base. Also any tutorials to anything suggested would help or book recommendations(I love buying books because reading them seem to be easier for me and they are great to have as references).

    Also should I use a database to hold characters stats,weapons,armor,ect. or should I make it make a file when someone makes a character and everytime they leave it writes its new stats to the files... Im assuming a database would be fast but I dont know anything about databases in conjunction with programming except web development.

    -- Paul

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    I think a database is a bit of an overkill for a user list.
    Create a binary file and a record for each user, and then read/write this to a file. If you have a lot of users and think this is slow, you can jus index the file.

    Code:
    	#define NAME_SZ 50
    	
    	typedef struct UserData{
    		char achName[NAME_SZ];
    		short sType;
    	}USER_DATA;
    	
    	int addUser(char *achFile, USER_DATA *ud){
    		int iData, iIx;
    		if((iData=_open(achFile, _O_BINARY|_O_CREAT|_O_APPEND|_O_RDWR)) && 
    			(iIx=_open(achFile, _O_BINARY|_O_CREAT|_O_APPEND|_O_RDWR))){
    			_write(iData, ud, sizeof(USER_DATA));
    			_write(iIx, ud->achName, NAME_SZ);
    			_close(iData);
    			_close(iIx);
    			return(1);
    		}else
    			return(0);
    	}

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    13

    Well..

    I have to hold not just users.. but i have to have somthing that holds stats,quest info,weapons,armor,ect... anything that has to be saved until next visit..

    I could use seperate files for these but I think that the database would be overall more efficient..

    Also im using this project as a learning tool .. So if a database could be of use here id like to use it if it wouldnt make it run slower... thus learning to use databases in conjuntion with C++ programs .

    -- Paul

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 07:32 AM
  2. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 11:11 AM
  3. comparing user input
    By lambs4 in forum C Programming
    Replies: 5
    Last Post: 12-15-2002, 09:28 AM
  4. File Database & Data Structure :: C++
    By kuphryn in forum C++ Programming
    Replies: 0
    Last Post: 02-24-2002, 10:47 AM
  5. Winsock Client User Input
    By (TNT) in forum Windows Programming
    Replies: 3
    Last Post: 11-19-2001, 08:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21