summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorgepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-02-13 01:19:04 +0000
committergepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-02-13 01:19:04 +0000
commit526217d77d50dc27b0815e3d5895df7bfa38ff76 (patch)
tree9fb6152ef59b7d08e7f226fbdc47eb6ba9617cc6 /src/login
parent87469dc59de62990878ce6ccd29769ebd5b7d675 (diff)
downloadhercules-526217d77d50dc27b0815e3d5895df7bfa38ff76.tar.gz
hercules-526217d77d50dc27b0815e3d5895df7bfa38ff76.tar.bz2
hercules-526217d77d50dc27b0815e3d5895df7bfa38ff76.tar.xz
hercules-526217d77d50dc27b0815e3d5895df7bfa38ff76.zip
- Added `libconfig` (configuration file library: http://www.hyperrealm.com/libconfig/):
- Updated VS9/10 project files. - Updated `configure` & `Makefile`s. - New GM, Commands & Permissions system: - '''This is a backwards compatibility breaking update''', please read tid:58877 - Replaced GM levels with Player Groups. - Commands permissions & other privileges now depend on group, not GM level. - `@help` command improvements: requires "commandname" param and shows more detailed info about commands. - Modified GM whisper system to deliver messages basing on permissions, not GM level. - Remote trade request is now possible only if player is allowed to use `@trade` command as well. - Added a proper permission to use `/changemaptype` command. - `clif_displaymessage` is now capable of displaying multiline messages. - All `ACMD_FUNC`s are static now, and the only way to invoke them is with `is_atcommand()`; all client commands (starting with `/`) are now translated into corresponding atcommands (with exception of `/kick` used on monster, as there is no atcommand to kill single monster). - Removed nonsense "bot check" triggering when player blocked (`/ex`) Server. - Merged `@monster`, `@monsterbig` and `@monstersmall`. - Improved flow of atcommand execution to avoid revealing info about online players or existing commands to non-privileged players. - Merged `atcommand` and `charcommand` script functions (`charcommand` is aliased to `atcommand`). - Fixed `atcommand` script function reading unknown memory area (possible access violation). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15572 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/login')
-rw-r--r--src/login/Makefile.in21
-rw-r--r--src/login/account.h2
-rw-r--r--src/login/account_sql.c12
-rw-r--r--src/login/login.c24
-rw-r--r--src/login/login.h4
5 files changed, 35 insertions, 28 deletions
diff --git a/src/login/Makefile.in b/src/login/Makefile.in
index 7dfe085c0..7938640aa 100644
--- a/src/login/Makefile.in
+++ b/src/login/Makefile.in
@@ -3,12 +3,13 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a
../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \
../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \
../common/obj_all/strlib.o ../common/obj_all/mapindex.o \
- ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_all/random.o
+ ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_all/random.o \
+ ../common/obj_all/conf.o
COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \
../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \
../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \
../common/mapindex.h \
- ../common/ers.h ../common/md5calc.h ../common/random.h
+ ../common/ers.h ../common/md5calc.h ../common/random.h ../common/conf.h
COMMON_SQL_OBJ = ../common/obj_sql/sql.o
COMMON_SQL_H = ../common/sql.h
@@ -17,6 +18,13 @@ MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
+LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
+ ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
+LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
+ ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
+ ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
+LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
+
LOGIN_OBJ = login.o
LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \
obj_sql/account_sql.o obj_sql/ipban_sql.o obj_sql/loginlog_sql.o
@@ -62,12 +70,12 @@ obj_sql:
#executables
login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS)
- @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@
+ @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
# login object files
-obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H)
- @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+ @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
../common/obj_all/%.o:
@@ -78,3 +86,6 @@ obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H)
MT19937AR_OBJ:
@$(MAKE) -C ../../3rdparty/mt19937ar
+
+LIBCONFIG_OBJ:
+ @$(MAKE) -C ../../3rdparty/libconfig
diff --git a/src/login/account.h b/src/login/account.h
index 170d60aca..1b567be70 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -41,7 +41,7 @@ struct mmo_account
char pass[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords
char sex; // gender (M/F/S)
char email[40]; // e-mail (by default: a@a.com)
- int level; // GM level
+ int group_id; // player group id
unsigned int state; // packet 0x006a value + 1 (0: compte OK)
time_t unban_time; // (timestamp): ban time limit of the account (0 = no ban)
time_t expiration_time; // (timestamp): validity limit of the account (0 = unlimited)
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index bc607c59e..5073941e2 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -522,7 +522,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
// retrieve login entry for the specified account
if( SQL_ERROR == Sql_Query(sql_handle,
- "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`level`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate` FROM `%s` WHERE `account_id` = %d",
+ "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate` FROM `%s` WHERE `account_id` = %d",
db->account_db, account_id )
) {
Sql_ShowDebug(sql_handle);
@@ -540,7 +540,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
Sql_GetData(sql_handle, 2, &data, NULL); safestrncpy(acc->pass, data, sizeof(acc->pass));
Sql_GetData(sql_handle, 3, &data, NULL); acc->sex = data[0];
Sql_GetData(sql_handle, 4, &data, NULL); safestrncpy(acc->email, data, sizeof(acc->email));
- Sql_GetData(sql_handle, 5, &data, NULL); acc->level = atoi(data);
+ Sql_GetData(sql_handle, 5, &data, NULL); acc->group_id = atoi(data);
Sql_GetData(sql_handle, 6, &data, NULL); acc->state = strtoul(data, NULL, 10);
Sql_GetData(sql_handle, 7, &data, NULL); acc->unban_time = atol(data);
Sql_GetData(sql_handle, 8, &data, NULL); acc->expiration_time = atol(data);
@@ -596,14 +596,14 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
if( is_new )
{// insert into account table
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
- "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `level`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
db->account_db)
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_INT, (void*)&acc->level, sizeof(acc->level))
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
@@ -619,12 +619,12 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
}
else
{// update account table
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`level`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_INT, (void*)&acc->level, sizeof(acc->level))
+ || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
diff --git a/src/login/login.c b/src/login/login.c
index 78a9b9420..5a504ce2f 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -548,7 +548,7 @@ int parse_fromchar(int fd)
struct mmo_account acc;
time_t expiration_time = 0;
char email[40] = "";
- int gmlevel = 0;
+ int group_id = 0;
char birthdate[10+1] = "";
int account_id = RFIFOL(fd,2);
@@ -560,7 +560,7 @@ int parse_fromchar(int fd)
{
safestrncpy(email, acc.email, sizeof(email));
expiration_time = acc.expiration_time;
- gmlevel = acc.level;
+ group_id = acc.group_id;
safestrncpy(birthdate, acc.birthdate, sizeof(birthdate));
}
@@ -569,7 +569,7 @@ int parse_fromchar(int fd)
WFIFOL(fd,2) = account_id;
safestrncpy((char*)WFIFOP(fd,6), email, 40);
WFIFOL(fd,46) = (uint32)expiration_time;
- WFIFOB(fd,50) = gmlevel;
+ WFIFOB(fd,50) = group_id;
safestrncpy((char*)WFIFOP(fd,51), birthdate, 10+1);
WFIFOSET(fd,62);
}
@@ -1068,7 +1068,7 @@ int mmo_auth(struct login_session_data* sd)
sd->login_id2 = rnd();
safestrncpy(sd->lastlogin, acc.lastlogin, sizeof(sd->lastlogin));
sd->sex = acc.sex;
- sd->level = acc.level;
+ sd->group_id = acc.group_id;
// update account data
timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S");
@@ -1104,9 +1104,9 @@ void login_auth_ok(struct login_session_data* sd)
return;
}
- if( sd->level < login_config.min_level_to_connect )
+ if( login_config.group_id_to_connect >= 0 && sd->group_id != login_config.group_id_to_connect )
{
- ShowStatus("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d).\n", login_config.min_level_to_connect, sd->userid, sd->level);
+ ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login_config.group_id_to_connect, sd->userid, sd->group_id);
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
@@ -1161,11 +1161,7 @@ void login_auth_ok(struct login_session_data* sd)
}
login_log(ip, sd->userid, 100, "login ok");
-
- if( sd->level > 0 )
- ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", sd->level, sd->userid);
- else
- ShowStatus("Connection of the account '%s' accepted.\n", sd->userid);
+ ShowStatus("Connection of the account '%s' accepted.\n", sd->userid);
WFIFOHEAD(fd,47+32*server_num);
WFIFOW(fd,0) = 0x69;
@@ -1508,7 +1504,7 @@ void login_set_defaults()
login_config.new_account_flag = true;
login_config.new_acc_length_limit = true;
login_config.use_md5_passwds = false;
- login_config.min_level_to_connect = 0;
+ login_config.group_id_to_connect = -1;
login_config.check_client_version = false;
login_config.client_version_to_connect = 20;
@@ -1575,8 +1571,8 @@ int login_config_read(const char* cfgName)
login_config.client_version_to_connect = strtoul(w2, NULL, 10);
else if(!strcmpi(w1, "use_MD5_passwords"))
login_config.use_md5_passwds = (bool)config_switch(w2);
- else if(!strcmpi(w1, "min_level_to_connect"))
- login_config.min_level_to_connect = atoi(w2);
+ else if(!strcmpi(w1, "group_id_to_connect"))
+ login_config.group_id_to_connect = atoi(w2);
else if(!strcmpi(w1, "date_format"))
safestrncpy(login_config.date_format, w2, sizeof(login_config.date_format));
else if(!strcmpi(w1, "console"))
diff --git a/src/login/login.h b/src/login/login.h
index 3f14ec93c..384372c75 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -34,7 +34,7 @@ struct login_session_data {
uint16 md5keylen;
char lastlogin[24];
- uint8 level;
+ uint8 group_id;
uint8 clienttype;
uint32 version;
@@ -64,7 +64,7 @@ struct Login_Config {
bool new_account_flag,new_acc_length_limit; // autoregistration via _M/_F ? / if yes minimum length is 4?
int start_limited_time; // new account expiration time (-1: unlimited)
bool use_md5_passwds; // work with password hashes instead of plaintext passwords?
- int min_level_to_connect; // minimum level of player/GM (0: player, 1-99: GM) to connect
+ int group_id_to_connect; // required group id to connect
bool check_client_version; // check the clientversion set in the clientinfo ?
uint32 client_version_to_connect; // the client version needed to connect (if checking is enabled)