diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/mmo.h | 2 | ||||
-rw-r--r-- | src/login/login.c | 89 | ||||
-rw-r--r-- | src/map/atcommand.c | 17 | ||||
-rw-r--r-- | src/map/atcommand.h | 1 | ||||
-rw-r--r-- | src/map/charcommand.c | 1 | ||||
-rw-r--r-- | src/map/script.c | 9 |
6 files changed, 85 insertions, 34 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h index a21680191..865468a16 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -14,6 +14,8 @@ #define RETCODE "\n" // (LFFUnixŒnj #endif +#define RET RETCODE + #define FIFOSIZE_SERVERLINK 128*1024 // set to 0 to not check IP of player between each server. diff --git a/src/login/login.c b/src/login/login.c index 28cfafce9..8d7ce12a2 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -191,6 +191,46 @@ int isGM(int account_id) { return 0; } +//---------------------------------------------------------------------- +// Adds a new GM using acc id and level +//---------------------------------------------------------------------- +void addGM(int account_id, int level) { + int i; + int do_add = 0; + for(i = 0; i < auth_num; i++) { + if (auth_dat[i].account_id==account_id) { + do_add = 1; + break; + } + } + for(i = 0; i < GM_num; i++) + if (gm_account_db[i].account_id == account_id) { + if (gm_account_db[i].level == level) + printf("addGM: GM account %d defined twice (same level: %d).\n", account_id, level); + else { + printf("addGM: GM account %d defined twice (levels: %d and %d).\n", account_id, gm_account_db[i].level, level); + gm_account_db[i].level = level; + } + return; + } + + // if new account + if (i == GM_num && do_add) { + if (GM_num >= GM_max) { + GM_max += 256; + gm_account_db = realloc(gm_account_db, sizeof(struct gm_account) * GM_max); + memset(gm_account_db + (GM_max - 256), 0, sizeof(struct gm_account) * 256); + } + gm_account_db[GM_num].account_id = account_id; + gm_account_db[GM_num].level = level; + GM_num++; + if (GM_num >= 4000) { + printf("***WARNING: 4000 GM accounts found. Next GM accounts are not read.\n"); + login_log("***WARNING: 4000 GM accounts found. Next GM accounts are not read." RETCODE); + } + } +} + //------------------------------------------------------- // Reading function of GM accounts file (and their level) //------------------------------------------------------- @@ -198,8 +238,9 @@ int read_gm_account() { char line[512]; FILE *fp; int account_id, level; - int i, line_counter; + int line_counter; struct stat file_stat; + int start_range = 0, end_range = 0, is_range = 0, current_id = 0; if(gm_account_db) free(gm_account_db); GM_num = 0; @@ -227,8 +268,9 @@ int read_gm_account() { line_counter++; if ((line[0] == '/' && line[1] == '/') || line[0] == '\0' || line[0] == '\n' || line[0] == '\r') continue; - if (sscanf(line, "%d %d", &account_id, &level) != 2 && sscanf(line, "%d: %d", &account_id, &level) != 2) - printf("read_gm_account: file [%s], invalid 'id_acount level' format (line #%d).\n", GM_account_filename, line_counter); + is_range = (sscanf(line, "%d%*[-~]%d %d",&start_range,&end_range,&level)==3); // ID Range [MC Cameri] + if (!is_range && sscanf(line, "%d %d", &account_id, &level) != 2 && sscanf(line, "%d: %d", &account_id, &level) != 2) + printf("read_gm_account: file [%s], invalid 'acount_id|range level' format (line #%d).\n", GM_account_filename, line_counter); else if (level <= 0) printf("read_gm_account: file [%s] %dth account (line #%d) (invalid level [0 or negative]: %d).\n", GM_account_filename, GM_num+1, line_counter, level); else { @@ -236,37 +278,23 @@ int read_gm_account() { printf("read_gm_account: file [%s] %dth account (invalid level, but corrected: %d->99).\n", GM_account_filename, GM_num+1, level); level = 99; } - for(i = 0; i < GM_num; i++) - if (gm_account_db[i].account_id == account_id) { - if (gm_account_db[i].level == level) - printf("read_gm_account: GM account %d defined twice (same level: %d).\n", account_id, level); - else { - printf("read_gm_account: GM account %d defined twice (levels: %d and %d).\n", account_id, gm_account_db[i].level, level); - gm_account_db[i].level = level; - } - break; - } - // if new account - if (i == GM_num) { - if (GM_num >= GM_max) { - GM_max += 256; - gm_account_db = realloc(gm_account_db, sizeof(struct gm_account) * GM_max); - memset(gm_account_db + (GM_max - 256), 0, sizeof(struct gm_account) * 256); - } - gm_account_db[GM_num].account_id = account_id; - gm_account_db[GM_num].level = level; - GM_num++; - if (GM_num >= 4000) { - printf("***WARNING: 4000 GM accounts found. Next GM accounts are not readed.\n"); - login_log("***WARNING: 4000 GM accounts found. Next GM accounts are not readed." RETCODE); - } + if (is_range) { + if (start_range==end_range) + printf("read_gm_account: file [%s] invalid range, beginning of range is equal to end of range (line #%d).\n", GM_account_filename, line_counter); + else if (start_range>end_range) + printf("read_gm_account: file [%s] invalid range, beginning of range must be lower than end of range (line #%d).\n", GM_account_filename, line_counter); + else + for (current_id = start_range;current_id<=end_range;current_id++) + addGM(current_id,level); + } else { + addGM(account_id,level); } } } fclose(fp); - printf("read_gm_account: file '%s' readed (%d GM accounts found).\n", GM_account_filename, GM_num); - login_log("read_gm_account: file '%s' readed (%d GM accounts found)." RETCODE, GM_account_filename, GM_num); + printf("read_gm_account: file '%s' read (%d GM accounts found).\n", GM_account_filename, GM_num); + login_log("read_gm_account: file '%s' read (%d GM accounts found)." RETCODE, GM_account_filename, GM_num); return 0; } @@ -447,6 +475,7 @@ int search_account_index(char* account_name) { quantity = 0; index = -1; + for(i = 0; i < auth_num; i++) { // Without case sensitive check (increase the number of similar account names found) if (stricmp(auth_dat[i].userid, account_name) == 0) { @@ -3872,8 +3901,8 @@ int do_init(int argc, char **argv) { gm_account_db = NULL; GM_num = 0; GM_max = 0; - read_gm_account(); mmo_auth_init(); + read_gm_account(); // set_termfunc(mmo_auth_sync); set_defaultparse(parse_login); login_fd = make_listen_port(login_port); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index b8368db1d..7ea5eb975 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -220,6 +220,7 @@ ATCOMMAND_FUNC(refresh); // by MC Cameri ATCOMMAND_FUNC(petid); // by MC Cameri ATCOMMAND_FUNC(identify); // by MC Cameri ATCOMMAND_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw +ATCOMMAND_FUNC(misceffect); // by MC Cameri #ifndef TXT_ONLY ATCOMMAND_FUNC(checkmail); // [Valaris] @@ -475,6 +476,7 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw + { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri #ifndef TXT_ONLY // sql-only commands { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris] @@ -7914,6 +7916,21 @@ atcommand_gmotd( return 0; } +int atcommand_misceffect( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + int effect = 0; + nullpo_retr(-1, sd); + if (!message || !*message) + return -1; + if (sscanf(message, "%d", &effect) < 1) + return -1; + clif_misceffect(&sd->bl,effect); + + return 0; +} + #ifndef TXT_ONLY /* Begin SQL-Only commands */ /*========================================== diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 77ecebf79..a87166064 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -200,6 +200,7 @@ enum AtCommandType { AtCommand_PetId, // by MC Cameri AtCommand_Identify, // by MC Cameri AtCommand_Gmotd, // Added by MC Cameri, created by davidsiaw + AtCommand_MiscEffect, // by MC Cameri // SQL-only commands start #ifndef TXT_ONLY diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 6a8b0cbeb..c2e091302 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -408,6 +408,7 @@ int charcommand_petfriendly( t = pl_sd->pet.intimate;
pl_sd->pet.intimate = friendly;
clif_send_petstatus(pl_sd);
+ clif_pet_emotion(pl_sd->pd,0);
if (battle_config.pet_status_support) {
if ((pl_sd->pet.intimate > 0 && t <= 0) ||
(pl_sd->pet.intimate <= 0 && t > 0)) {
diff --git a/src/map/script.c b/src/map/script.c index 0f76d4ec7..f198d42fe 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2916,12 +2916,13 @@ int buildin_getequipisenableref(struct script_state *st) num=conv_num(st,& (st->stack->stack_data[st->start+2])); sd=script_rid2sd(st); i=pc_checkequip(sd,equip[num-1]); - if(i >= 0 && num<7 && sd->inventory_data[i] && (num!=1 || sd->inventory_data[i]->def > 1 + if(i >= 0 && num<7 && sd->inventory_data[i] && (num!=1 + || sd->inventory_data[i]->def > 1 || (sd->inventory_data[i]->def==1 && sd->inventory_data[i]->equip_script==NULL) - || (sd->inventory_data[i]->def<=0 && sd->inventory_data[i]->equip_script!=NULL)) - ){ + || (sd->inventory_data[i]->def<=0 && sd->inventory_data[i]->equip_script!=NULL))) + { push_val(st->stack,C_INT,1); - }else{ + } else { push_val(st->stack,C_INT,0); } |