[0014] Updated realmd to use account_access. This allows for different security levels per account for each realm in realmlist.

This commit is contained in:
Surion 2012-08-07 19:34:25 -05:00 committed by Antz
parent 4f10d552ee
commit 635e447ef5
5 changed files with 45 additions and 44 deletions

View file

@ -21,7 +21,7 @@
DROP TABLE IF EXISTS `realmd_db_version`; DROP TABLE IF EXISTS `realmd_db_version`;
CREATE TABLE `realmd_db_version` ( CREATE TABLE `realmd_db_version` (
`required_0014_xxxxx_01_realmd_account_access` bit(1) default NULL `required_00014_01_realmd_account_access` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
-- --
@ -44,6 +44,7 @@ CREATE TABLE `account` (
`id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier', `id` int(11) unsigned NOT NULL auto_increment COMMENT 'Identifier',
`username` varchar(32) NOT NULL default '', `username` varchar(32) NOT NULL default '',
`sha_pass_hash` varchar(40) NOT NULL default '', `sha_pass_hash` varchar(40) NOT NULL default '',
`gmlevel` tinyint(3) unsigned NOT NULL default '0',
`sessionkey` longtext, `sessionkey` longtext,
`v` longtext, `v` longtext,
`s` longtext, `s` longtext,
@ -58,7 +59,8 @@ CREATE TABLE `account` (
`mutetime` bigint(40) unsigned NOT NULL default '0', `mutetime` bigint(40) unsigned NOT NULL default '0',
`locale` tinyint(3) unsigned NOT NULL default '0', `locale` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `idx_username` (`username`) UNIQUE KEY `idx_username` (`username`),
KEY `idx_gmlevel` (`gmlevel`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='Account System'; ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='Account System';
-- --
@ -68,10 +70,10 @@ CREATE TABLE `account` (
LOCK TABLES `account` WRITE; LOCK TABLES `account` WRITE;
/*!40000 ALTER TABLE `account` DISABLE KEYS */; /*!40000 ALTER TABLE `account` DISABLE KEYS */;
INSERT INTO `account` VALUES INSERT INTO `account` VALUES
(1,'ADMINISTRATOR','a34b29541b87b7e4823683ce6c7bf6ae68beaaac','','0','0','','2006-04-25 10:18:56','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0), (1,'ADMINISTRATOR','a34b29541b87b7e4823683ce6c7bf6ae68beaaac',3,'','0','0','','2006-04-25 10:18:56','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0),
(2,'GAMEMASTER','7841e21831d7c6bc0b57fbe7151eb82bd65ea1f9','','0','0','','2006-04-25 10:18:56','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0), (2,'GAMEMASTER','7841e21831d7c6bc0b57fbe7151eb82bd65ea1f9',2,'','0','0','','2006-04-25 10:18:56','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0),
(3,'MODERATOR','a7f5fbff0b4eec2d6b6e78e38e8312e64d700008','','0','0','','2006-04-25 10:19:35','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0), (3,'MODERATOR','a7f5fbff0b4eec2d6b6e78e38e8312e64d700008',1,'','0','0','','2006-04-25 10:19:35','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0),
(4,'PLAYER','3ce8a96d17c5ae88a30681024e86279f1a38c041','','0','0','','2006-04-25 10:19:35','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0); (4,'PLAYER','3ce8a96d17c5ae88a30681024e86279f1a38c041',0,'','0','0','','2006-04-25 10:19:35','127.0.0.1',0,0,'0000-00-00 00:00:00',0,0,0,0);
/*!40000 ALTER TABLE `account` ENABLE KEYS */; /*!40000 ALTER TABLE `account` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
@ -86,21 +88,7 @@ CREATE TABLE `account_access` (
`gmlevel` tinyint(3) unsigned NOT NULL, `gmlevel` tinyint(3) unsigned NOT NULL,
`RealmID` int(11) NOT NULL DEFAULT '-1', `RealmID` int(11) NOT NULL DEFAULT '-1',
PRIMARY KEY (`id`,`RealmID`) PRIMARY KEY (`id`,`RealmID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Account Access System'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `account_access`
--
LOCK TABLES `account_access` WRITE;
/*!40000 ALTER TABLE `account_access` DISABLE KEYS */;
INSERT INTO `account_access` VALUES
(1,3,-1),
(2,2,-1),
(3,1,-1),
(4,0,-1);
/*!40000 ALTER TABLE `account_access` ENABLE KEYS */;
UNLOCK TABLES;
-- --
-- Table structure for table `account_banned` -- Table structure for table `account_banned`

View file

@ -0,0 +1,14 @@
ALTER TABLE realmd_db_version CHANGE COLUMN required_0001_xxxxx_01_realmd required_00014_01_realmd_account_access bit;
--
-- Table Stucture for table `account `account_access`
--
DROP TABLE IF EXISTS `account_access`;
CREATE TABLE `account_access` (
`id` int(10) unsigned NOT NULL,
`gmlevel` tinyint(3) unsigned NOT NULL,
`RealmID` int(11) NOT NULL DEFAULT '-1',
PRIMARY KEY (`id`,`RealmID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View file

@ -1143,7 +1143,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args)
return false; return false;
int32 gm; int32 gm;
uint32 gmRealmID = realmID; uint32 gmRealmID = realmID;
if (!ExtractInt32(&args, gm)) if (!ExtractInt32(&args, gm))
return false; return false;
@ -1167,13 +1167,13 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args)
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
/// check if provided realmID is not current realmID, or isn't -1 // Check if provided realmID is not current realmID, or isn't -1
if (gmRealmID != realmID && gmRealmID != -1) if (gmRealmID != realmID && gmRealmID != -1)
{ {
SendSysMessage(LANG_INVALID_REALMID); SendSysMessage(LANG_INVALID_REALMID);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
if (targetPlayer) if (targetPlayer)
{ {
@ -1182,20 +1182,19 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args)
} }
PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
// If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID
if (gmRealmID == -1)
{
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId);
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', -1)", targetAccountId, gm);
}
else
{
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND RealmID = '%d'", targetAccountId, realmID);
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID);
}
//LoginDatabase.PExecute("UPDATE account_access SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId); //LoginDatabase.PExecute("UPDATE account_access SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId);
/// If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID
if (gmRealmID == -1)
{
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId);
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', -1)", targetAccountId, gm);
}
else
{
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND RealmID = '%d'", targetAccountId, realmID);
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID);
}
return true; return true;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "0013" #define REVISION_NR "0014"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__ #ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__ #define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_0001_xxxxx_01_characters" #define REVISION_DB_CHARACTERS "required_0001_xxxxx_01_characters"
#define REVISION_DB_MANGOS "required_0023_xxxxx_01_mangos_player_classlevelstats" #define REVISION_DB_MANGOS "required_0001_xxxxx_01_mangos"
#define REVISION_DB_REALMD "required_0014_xxxxx_01_realmd_account_access" #define REVISION_DB_REALMD "required_00014_01_realmd_account_access"
#endif // __REVISION_SQL_H__ #endif // __REVISION_SQL_H__