summaryrefslogtreecommitdiff
path: root/src/account-server
diff options
context:
space:
mode:
authorRoderic Morris <roderic@ccs.neu.edu>2008-06-03 16:31:32 +0000
committerRoderic Morris <roderic@ccs.neu.edu>2008-06-03 16:31:32 +0000
commitaf045b4818333b4360f14981c695817c4c8adb21 (patch)
tree2b22ff5b23906aa87a2cd5383171ffc44283a829 /src/account-server
parent33d5ea3261e70cba7e0f4af5c1e6eb070f168112 (diff)
downloadmanaserv-af045b4818333b4360f14981c695817c4c8adb21.tar.gz
manaserv-af045b4818333b4360f14981c695817c4c8adb21.tar.bz2
manaserv-af045b4818333b4360f14981c695817c4c8adb21.tar.xz
manaserv-af045b4818333b4360f14981c695817c4c8adb21.zip
stop storing channels in the db, send channel announcements
Diffstat (limited to 'src/account-server')
-rw-r--r--src/account-server/dalstorage.cpp96
-rw-r--r--src/account-server/dalstorage.hpp25
-rw-r--r--src/account-server/dalstoragesql.hpp28
3 files changed, 1 insertions, 148 deletions
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index 02b095dd..8f6feb53 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -127,7 +127,6 @@ void DALStorage::open()
createTable(ACCOUNTS_TBL_NAME, SQL_ACCOUNTS_TABLE);
createTable(CHARACTERS_TBL_NAME, SQL_CHARACTERS_TABLE);
createTable(INVENTORIES_TBL_NAME, SQL_INVENTORIES_TABLE);
- createTable(CHANNELS_TBL_NAME, SQL_CHANNELS_TABLE);
createTable(GUILDS_TBL_NAME, SQL_GUILDS_TABLE);
createTable(GUILD_MEMBERS_TBL_NAME, SQL_GUILD_MEMBERS_TABLE);
createTable(QUESTS_TBL_NAME, SQL_QUESTS_TABLE);
@@ -628,101 +627,6 @@ bool DALStorage::updateCharacter(Character *character)
return true;
}
-std::map<unsigned short, ChatChannel>
-DALStorage::getChannelList()
-{
- // specialize the string_to functor to convert
- // a string to a short.
- string_to<int> toInt;
-
- // The formatted datas
- std::map<unsigned short, ChatChannel> channels;
-
- try {
- std::stringstream sql;
- sql << "select id, name, announcement, password from ";
- sql << CHANNELS_TBL_NAME;
- sql << ";";
-
- const dal::RecordSet& channelInfo = mDb->execSql(sql.str());
-
- // If the map return is empty then we have no choice but to return false.
- if (channelInfo.isEmpty()) {
- return channels;
- }
-
- for (unsigned int i = 0; i < channelInfo.rows(); ++i)
- {
- unsigned short channelId = toInt(channelInfo(i, 0));
- channels.insert(
- std::make_pair(channelId,
- ChatChannel(channelId,
- channelInfo(i, 1),
- channelInfo(i, 2),
- channelInfo(i, 3))));
-
- LOG_DEBUG("Channel (" << channelId << ") loaded: "
- << channelInfo(i, 1) << ": " << channelInfo(i, 2));
- }
-
- return channels;
- }
- catch (const dal::DbSqlQueryExecFailure& e) {
- // TODO: throw an exception.
- LOG_ERROR("(DALStorage::getChannelList) SQL query failure: " << e.what());
- }
-
- return channels;
-}
-
-void
-DALStorage::updateChannels(std::map<unsigned short, ChatChannel>& channelList)
-{
- try {
- // Empties the table
- std::stringstream sql;
- sql << "delete from "
- << CHANNELS_TBL_NAME
- << ";";
-
- mDb->execSql(sql.str());
-
- for (std::map<unsigned short, ChatChannel>::iterator i = channelList.begin();
- i != channelList.end();)
- {
- // insert registered channel if id < MAX_PUBLIC_CHANNELS_RANGE;
- if (i->first < MAX_PUBLIC_CHANNELS_RANGE)
- {
- if (i->second.getName() != "")
- {
- sql.str("");
- sql << "insert into "
- << CHANNELS_TBL_NAME
- << " (id, name, announcement, password, joinable)"
- << " values ("
- << i->first << ", \""
- << i->second.getName() << "\", \""
- << i->second.getAnnouncement() << "\", \""
- << i->second.getPassword() << "\", \""
- << i->second.canJoin() << "\");";
-
- LOG_DEBUG("Channel (" << i->first << ") saved: "
- << i->second.getName()
- << ": " << i->second.getAnnouncement());
- }
-
- mDb->execSql(sql.str());
- }
- ++i;
- }
-
- }
- catch (const dal::DbSqlQueryExecFailure& e) {
- // TODO: throw an exception.
- LOG_ERROR("(DALStorage::updateChannels) SQL query failure: " << e.what());
- }
-}
-
/**
* Create the specified table.
diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp
index 587f996a..e9a15af8 100644
--- a/src/account-server/dalstorage.hpp
+++ b/src/account-server/dalstorage.hpp
@@ -125,15 +125,6 @@ class DALStorage
*/
void banCharacter(int id, int duration);
-#if 0
- /**
- * Get the list of Emails in the accounts list.
- * @return the list of Email's Addresses.
- */
- std::list<std::string>
- getEmailList();
-#endif
-
/**
* Tells if the user name already exists.
* @return true if the user name exists.
@@ -163,20 +154,6 @@ class DALStorage
updateCharacter(Character *ptr);
/**
- * Gives the list of opened public channels registered in database
- * @return a map of the public channels
- */
- std::map<unsigned short, ChatChannel>
- getChannelList();
-
- /**
- * apply channel differences from the list in memory
- * to the one in db.
- */
- void
- updateChannels(std::map<unsigned short, ChatChannel>& channelList);
-
- /**
* Add a new guild
*
*/
@@ -197,7 +174,7 @@ class DALStorage
void
addGuildMember(int guild_id, const std::string &member_name);
- /*
+ /**
* Remove member from guild
*/
void
diff --git a/src/account-server/dalstoragesql.hpp b/src/account-server/dalstoragesql.hpp
index ea7f620e..ee77d8f2 100644
--- a/src/account-server/dalstoragesql.hpp
+++ b/src/account-server/dalstoragesql.hpp
@@ -253,34 +253,6 @@ static char const *SQL_INVENTORIES_TABLE =
");";
/**
- * TABLE: tmw_channels.
- * Keeps opened public Channel list
- */
-static char const *CHANNELS_TBL_NAME = "tmw_channels";
-static char const *SQL_CHANNELS_TABLE =
- "CREATE TABLE tmw_channels ("
-#if defined (MYSQL_SUPPORT)
- "id INTEGER PRIMARY KEY,"
- "name VARCHAR(32) NOT NULL UNIQUE,"
- "announcement VARCHAR(256) NOT NULL,"
- "password VARCHAR(32) NOT NULL,"
- "joinable INTEGER NOT NULL"
-#elif defined (SQLITE_SUPPORT)
- "id INTEGER PRIMARY KEY,"
- "name TEXT NOT NULL UNIQUE,"
- "announcement TEXT NOT NULL,"
- "password TEXT NOT NULL,"
- "joinable INTEGER NOT NULL"
-#elif defined (POSTGRESQL_SUPPORT)
- "id SERIAL PRIMARY KEY,"
- "name TEXT NOT NULL UNIQUE,"
- "announcement TEXT NOT NULL,"
- "password TEXT NOT NULL,"
- "joinable INTEGER NOT NULL"
-#endif
- ");";
-
-/**
* TABLE: tmw_guilds.
* Store player guilds
*/