diff options
author | codemaster <codemaster@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-03-01 05:35:21 +0000 |
---|---|---|
committer | codemaster <codemaster@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-03-01 05:35:21 +0000 |
commit | 3a44a959e2d8f76d5a43a81992e3d17fe50644d0 (patch) | |
tree | d6646048df2e11355e353fe66bdb6582b3313d71 /src/char_sql/char.c | |
parent | 14924e0da5a32cb765ab8d405f965394cc3dbc6c (diff) | |
download | hercules-3a44a959e2d8f76d5a43a81992e3d17fe50644d0.tar.gz hercules-3a44a959e2d8f76d5a43a81992e3d17fe50644d0.tar.bz2 hercules-3a44a959e2d8f76d5a43a81992e3d17fe50644d0.tar.xz hercules-3a44a959e2d8f76d5a43a81992e3d17fe50644d0.zip |
* Added the ability to select GM loading via Login (default) or Char [Codemaster]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5404 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/char.c')
-rw-r--r-- | src/char_sql/char.c | 95 |
1 files changed, 70 insertions, 25 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c index f28ba008e..079cb743d 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -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();
|