Online Gaming Program

Nicko

Expert Member
Joined
Feb 16, 2010
Messages
1,048
Reaction score
1
Location
Cape Town
Hey guys,

I am editing the source code of an open source game, and I near to completion but seeing as I have never done something on this scale before I want to make sure I am doing it right.

The game is written in multiple languages, but its mainly in C++ (well what I deal with is). My aim is to connect the game to an online website so people can have an account and keep track of their statistics along with other things. The way I have gone about this is with the use of remote access from the server to the website to insert and fetch data from the websites database.

My main concern is in regards to three things.

1) Do you guys reckon that Remote Access using MySQL is the best way to connect the server program with the website. If not what are other alternatives.

2) I realize that this will need to be threaded else the Inserting/fetching will hang the server and cause everyone to freeze. But when I searched for C++ and threading every site I came across seemed to use a different way. Also I am unsure how I would go about implementing it within the program. This is my current set-up (without threading). Any suggestions will be appreciated :)

The Server main file, Server.cpp.
if(MsgID == NETMSGTYPE_CL_SAY)
{ // This is pseudo code.
CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg;
char *pMessage = pMsg->m_pMessage;
if (pMessage = "Fetch my online rank"){
int OnlineRank = FetchOnlineRank (PersonsID);
SendChat (Person, OnlineRank);
return;
}
}

My program, lets call it OnlineConnect.cpp
//This is one of the actual functions (well kinda)
int FetchRank (int OnlineID){
char aBuf [256];
str_format (aBuf, sizeof (aBuf), "SELECT Points FROM Players Where AccID = %d", OnlineID);
query_state = mysql_query (connection, aBuf);
result = mysql_store_result(connection);
if (query_state) {
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", mysql_error(connection));
return 0;
}
if ( (row = mysql_fetch_row (result))!= NULL)
return atoi (row [0]);
return 0;
}

3) Lastly, I don't know how exactly I would handle the clients login as remote access won't work. The client would have to send to the website the entered username and password, and the website would send back a key (if client exists). There must be an easy way to do it because it is a commonly used method (steam/skype/etc requires to login). I am just very new to web development, but just point me in the right direction and I am more than willing to learn.

Thanks in advance guys! I know this is quite the wall of text but I want to make sure I get this right as there will be quite a number of people playing on it.
 
Top
Sign up to the MyBroadband newsletter
X