* Added the ability to select GM loading via Login (default) or Char [Codemaster]
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5404 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
2adcba7bb2
commit
018dec7fb4
@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
|
||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE
|
||||
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
|
||||
|
||||
2006/03/01
|
||||
* Added the ability to select GM loading via Login (default) or Char [Codemaster]
|
||||
2006/02/28
|
||||
* Rewrote LAN support code. Changed configuration file name
|
||||
lan_support.conf to subnet_athena.conf, changed it syntax. [LuzZza]
|
||||
|
@ -22,3 +22,11 @@ Lance
|
||||
- General coding and scripting. Little Code Monkey :D
|
||||
- Was invited by Manipulator and Nexon. Promoted by Deviant.
|
||||
- Got really into eA at 14, began scripting in 15. Started coding this year.
|
||||
|
||||
Codemaster
|
||||
- Andrew
|
||||
- 18
|
||||
- Ohio (College in New York)
|
||||
- Go Crazy :D, help with random questions, coding, scripting, documentation
|
||||
- Merged in with omniAthena ^_^
|
||||
- Been programming and scripting since age 9 :)
|
||||
|
@ -46,6 +46,10 @@ kick_on_disconnect: 1
|
||||
// WARNING: Don't use it in multi char/map or customized table names config.
|
||||
charsave_method: 0
|
||||
|
||||
// GM Reading Method
|
||||
// 1 to have Char read GMs, 0 to have Login-controlled GMs
|
||||
gm_read_method: 0
|
||||
|
||||
// The level at which a player with access is considered a GM.
|
||||
// An account with an access level lower than this is not effected
|
||||
// by gm_can_drop_lv (battle_athena.conf).
|
||||
|
@ -61,6 +61,7 @@ char guild_skill_db[256] = "guild_skill";
|
||||
char guild_storage_db[256] = "guild_storage";
|
||||
char party_db[256] = "party";
|
||||
char pet_db[256] = "pet";
|
||||
char gm_db[256] = "gm_accounts";
|
||||
char friend_db[256] = "friends";
|
||||
int db_use_sqldbs;
|
||||
|
||||
@ -153,6 +154,7 @@ unsigned int save_flag = 0;
|
||||
// start point (you can reset point on conf file)
|
||||
struct point start_point = { 0, 53, 111};
|
||||
|
||||
bool char_gm_read = false;
|
||||
struct gm_account *gm_account = NULL;
|
||||
int GM_num = 0;
|
||||
|
||||
@ -330,6 +332,32 @@ int isGM(int account_id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void read_gm_account(void) {
|
||||
if(char_gm_read)
|
||||
{
|
||||
if (gm_account != NULL)
|
||||
aFree(gm_account);
|
||||
GM_num = 0;
|
||||
|
||||
sprintf(tmp_sql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'",login_db_account_id,login_db_level,gm_db,login_db_level,lowest_gm_level);
|
||||
if (mysql_query(&lmysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
lsql_res = mysql_store_result(&lmysql_handle);
|
||||
if (lsql_res) {
|
||||
gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1);
|
||||
while ((lsql_row = mysql_fetch_row(lsql_res))) {
|
||||
gm_account[GM_num].account_id = atoi(lsql_row[0]);
|
||||
gm_account[GM_num].level = atoi(lsql_row[1]);
|
||||
GM_num++;
|
||||
}
|
||||
}
|
||||
|
||||
mysql_free_result(lsql_res);
|
||||
mapif_send_gmaccounts();
|
||||
}
|
||||
}
|
||||
|
||||
int compare_item(struct item *a, struct item *b) {
|
||||
|
||||
@ -2026,27 +2054,30 @@ int parse_tologin(int fd) {
|
||||
break;
|
||||
|
||||
case 0x2732:
|
||||
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
|
||||
return 0;
|
||||
{
|
||||
unsigned char buf[32000];
|
||||
if (gm_account != NULL)
|
||||
aFree(gm_account);
|
||||
gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
|
||||
GM_num = 0;
|
||||
for (i = 4; i < RFIFOW(fd,2); i = i + 5) {
|
||||
gm_account[GM_num].account_id = RFIFOL(fd,i);
|
||||
gm_account[GM_num].level = (int)RFIFOB(fd,i+4);
|
||||
//printf("GM account: %d -> level %d\n", gm_account[GM_num].account_id, gm_account[GM_num].level);
|
||||
GM_num++;
|
||||
if(!char_gm_read)
|
||||
{
|
||||
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
|
||||
return 0;
|
||||
{
|
||||
unsigned char buf[32000];
|
||||
if (gm_account != NULL)
|
||||
aFree(gm_account);
|
||||
gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
|
||||
GM_num = 0;
|
||||
for (i = 4; i < RFIFOW(fd,2); i = i + 5) {
|
||||
gm_account[GM_num].account_id = RFIFOL(fd,i);
|
||||
gm_account[GM_num].level = (int)RFIFOB(fd,i+4);
|
||||
//printf("GM account: %d -> level %d\n", gm_account[GM_num].account_id, gm_account[GM_num].level);
|
||||
GM_num++;
|
||||
}
|
||||
ShowStatus("From login-server: receiving information of %d GM accounts.\n", GM_num);
|
||||
// send new gm acccounts level to map-servers
|
||||
memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2));
|
||||
WBUFW(buf,0) = 0x2b15;
|
||||
mapif_sendall(buf, RFIFOW(fd,2));
|
||||
}
|
||||
RFIFOSKIP(fd,RFIFOW(fd,2));
|
||||
}
|
||||
ShowStatus("From login-server: receiving information of %d GM accounts.\n", GM_num);
|
||||
// send new gm acccounts level to map-servers
|
||||
memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2));
|
||||
WBUFW(buf,0) = 0x2b15;
|
||||
mapif_sendall(buf, RFIFOW(fd,2));
|
||||
}
|
||||
RFIFOSKIP(fd,RFIFOW(fd,2));
|
||||
break;
|
||||
|
||||
// Receive GM accounts [Freya login server packet by Yor]
|
||||
@ -2223,10 +2254,13 @@ int parse_frommap(int fd) {
|
||||
break;
|
||||
|
||||
case 0x2af7:
|
||||
RFIFOSKIP(fd,2);
|
||||
if (login_fd > 0) { // don't send request if no login-server
|
||||
WFIFOW(login_fd,0) = 0x2709;
|
||||
WFIFOSET(login_fd, 2);
|
||||
if(char_gm_read)
|
||||
{
|
||||
RFIFOSKIP(fd,2);
|
||||
if (login_fd > 0) { // don't send request if no login-server
|
||||
WFIFOW(login_fd,0) = 0x2709;
|
||||
WFIFOSET(login_fd, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3798,7 +3832,14 @@ void sql_config_read(const char *cfgName){ /* Kalaspuff, to get login_db */
|
||||
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
|
||||
continue;
|
||||
|
||||
if(strcmpi(w1,"char_db")==0){
|
||||
if(strcmpi(w1, "gm_read_method") == 0) {
|
||||
if(atoi(w2) != 0)
|
||||
char_gm_read = true;
|
||||
else
|
||||
char_gm_read = false;
|
||||
} else if(strcmpi(w1, "gm_db") == 0) {
|
||||
strcpy(gm_db, w2);
|
||||
} else if(strcmpi(w1,"char_db")==0){
|
||||
strcpy(char_db,w2);
|
||||
}else if(strcmpi(w1,"scdata_db")==0){
|
||||
strcpy(scdata_db,w2);
|
||||
@ -4115,6 +4156,10 @@ int do_init(int argc, char **argv){
|
||||
add_timer_interval(gettick() + 10, send_users_tologin, 0, 0, 5 * 1000);
|
||||
add_timer_interval(gettick() + 3600*1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour.
|
||||
|
||||
if(char_gm_read)
|
||||
read_gm_account();
|
||||
|
||||
|
||||
if ( console ) {
|
||||
set_defaultconsoleparse(parse_console);
|
||||
start_console();
|
||||
|
@ -120,6 +120,7 @@ int use_md5_passwds = 0;
|
||||
char login_db[256] = "login";
|
||||
int log_login=1; //Whether to log the logins or not. [Skotlex]
|
||||
char loginlog_db[256] = "loginlog";
|
||||
bool login_gm_read = true;
|
||||
|
||||
// added to help out custom login tables, without having to recompile
|
||||
// source so options are kept in the login_athena.conf or the inter_athena.conf
|
||||
@ -128,6 +129,8 @@ char login_db_userid[256] = "userid";
|
||||
char login_db_user_pass[256] = "user_pass";
|
||||
char login_db_level[256] = "level";
|
||||
|
||||
char gm_db[256] = "gm_accounts";
|
||||
|
||||
char reg_db[256] = "global_reg_value";
|
||||
|
||||
struct gm_account *gm_account_db;
|
||||
@ -210,27 +213,30 @@ void read_gm_account(void) {
|
||||
MYSQL_RES* sql_res ;
|
||||
MYSQL_ROW sql_row;
|
||||
|
||||
sprintf(tmp_sql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`> '0'",login_db_account_id,login_db_level,login_db,login_db_level);
|
||||
if (mysql_query(&mysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
return; //Failed to read GM list!
|
||||
}
|
||||
|
||||
if (gm_account_db != NULL)
|
||||
if(login_gm_read)
|
||||
{
|
||||
aFree(gm_account_db);
|
||||
gm_account_db = NULL;
|
||||
}
|
||||
GM_num = 0;
|
||||
sprintf(tmp_sql, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`> '0'",login_db_account_id,login_db_level,login_db,login_db_level);
|
||||
if (mysql_query(&mysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
return; //Failed to read GM list!
|
||||
}
|
||||
|
||||
sql_res = mysql_store_result(&mysql_handle);
|
||||
if (sql_res) {
|
||||
gm_account_db = (struct gm_account*)aCalloc((size_t)mysql_num_rows(sql_res), sizeof(struct gm_account));
|
||||
while ((sql_row = mysql_fetch_row(sql_res))) {
|
||||
gm_account_db[GM_num].account_id = atoi(sql_row[0]);
|
||||
gm_account_db[GM_num].level = atoi(sql_row[1]);
|
||||
GM_num++;
|
||||
if (gm_account_db != NULL)
|
||||
{
|
||||
aFree(gm_account_db);
|
||||
gm_account_db = NULL;
|
||||
}
|
||||
GM_num = 0;
|
||||
|
||||
sql_res = mysql_store_result(&mysql_handle);
|
||||
if (sql_res) {
|
||||
gm_account_db = (struct gm_account*)aCalloc((size_t)mysql_num_rows(sql_res), sizeof(struct gm_account));
|
||||
while ((sql_row = mysql_fetch_row(sql_res))) {
|
||||
gm_account_db[GM_num].account_id = atoi(sql_row[0]);
|
||||
gm_account_db[GM_num].level = atoi(sql_row[1]);
|
||||
GM_num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,22 +253,25 @@ void send_GM_accounts(int fd) {
|
||||
unsigned char buf[32767];
|
||||
int len;
|
||||
|
||||
len = 4;
|
||||
WBUFW(buf,0) = 0x2732;
|
||||
for(i = 0; i < GM_num; i++)
|
||||
// send only existing accounts. We can not create a GM account when server is online.
|
||||
if (gm_account_db[i].level > 0) {
|
||||
WBUFL(buf,len) = gm_account_db[i].account_id;
|
||||
WBUFB(buf,len+4) = (unsigned char)gm_account_db[i].level;
|
||||
len += 5;
|
||||
}
|
||||
WBUFW(buf,2) = len;
|
||||
if (fd == -1)
|
||||
charif_sendallwos(-1, buf, len);
|
||||
else
|
||||
if(login_gm_read)
|
||||
{
|
||||
memcpy(WFIFOP(fd,0), buf, len);
|
||||
WFIFOSET(fd,len);
|
||||
len = 4;
|
||||
WBUFW(buf,0) = 0x2732;
|
||||
for(i = 0; i < GM_num; i++)
|
||||
// send only existing accounts. We can not create a GM account when server is online.
|
||||
if (gm_account_db[i].level > 0) {
|
||||
WBUFL(buf,len) = gm_account_db[i].account_id;
|
||||
WBUFB(buf,len+4) = (unsigned char)gm_account_db[i].level;
|
||||
len += 5;
|
||||
}
|
||||
WBUFW(buf,2) = len;
|
||||
if (fd == -1)
|
||||
charif_sendallwos(-1, buf, len);
|
||||
else
|
||||
{
|
||||
memcpy(WFIFOP(fd,0), buf, len);
|
||||
WFIFOSET(fd,len);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1796,8 +1805,11 @@ int parse_login(int fd) {
|
||||
WFIFOSET(fd,3);
|
||||
session[fd]->func_parse=parse_fromchar;
|
||||
realloc_fifo(fd,FIFOSIZE_SERVERLINK,FIFOSIZE_SERVERLINK);
|
||||
// send GM account to char-server
|
||||
send_GM_accounts(fd);
|
||||
if(login_gm_read)
|
||||
{
|
||||
// send GM account to char-server
|
||||
send_GM_accounts(fd);
|
||||
}
|
||||
} else {
|
||||
WFIFOW(fd, 0) =0x2711;
|
||||
WFIFOB(fd, 2)=3;
|
||||
@ -2122,7 +2134,14 @@ void sql_config_read(const char *cfgName){ /* Kalaspuff, to get login_db */
|
||||
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
|
||||
if(i!=2)
|
||||
continue;
|
||||
if (strcmpi(w1, "login_db") == 0) {
|
||||
if(strcmpi(w1, "gm_read_method") == 0) {
|
||||
if(atoi(w2) == 0)
|
||||
login_gm_read = true;
|
||||
else
|
||||
login_gm_read = false;
|
||||
} else if(strcmpi(w1, "gm_db") == 0) {
|
||||
strcpy(gm_db, w2);
|
||||
} else if (strcmpi(w1, "login_db") == 0) {
|
||||
strcpy(login_db, w2);
|
||||
}
|
||||
//add for DB connection
|
||||
@ -2237,8 +2256,11 @@ int do_init(int argc,char **argv){
|
||||
mmo_auth_sqldb_init();
|
||||
ShowInfo("finished mmo_auth_sqldb_init()\n");
|
||||
|
||||
//Read account information.
|
||||
read_gm_account();
|
||||
if(login_gm_read)
|
||||
{
|
||||
//Read account information.
|
||||
read_gm_account();
|
||||
}
|
||||
|
||||
//set default parser as parse_login function
|
||||
set_defaultparse(parse_login);
|
||||
|
Loading…
x
Reference in New Issue
Block a user