Getting rid of map_getallusers(), part 1
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12195 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
224a459acf
commit
b24b80c5c9
@ -565,8 +565,9 @@ int atcommand_jump(const int fd, struct map_session_data* sd, const char* comman
|
|||||||
int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
||||||
{
|
{
|
||||||
char temp0[100];
|
char temp0[100];
|
||||||
struct map_session_data *pl_sd, **pl_allsd;
|
struct map_session_data *pl_sd;
|
||||||
int i, j, count, users;
|
struct s_mapiterator* iter;
|
||||||
|
int j, count;
|
||||||
int pl_GM_level, GM_level;
|
int pl_GM_level, GM_level;
|
||||||
char match_text[100];
|
char match_text[100];
|
||||||
char player_name[NAME_LENGTH];
|
char player_name[NAME_LENGTH];
|
||||||
@ -584,40 +585,42 @@ int atcommand_who3(const int fd, struct map_session_data* sd, const char* comman
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
GM_level = pc_isGM(sd);
|
GM_level = pc_isGM(sd);
|
||||||
pl_allsd = map_getallusers(&users);
|
|
||||||
for (i = 0; i < users; i++) {
|
|
||||||
if ((pl_sd = pl_allsd[i])) {
|
|
||||||
pl_GM_level = pc_isGM(pl_sd);
|
|
||||||
if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
|
|
||||||
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
|
|
||||||
for (j = 0; player_name[j]; j++)
|
|
||||||
player_name[j] = TOLOWER(player_name[j]);
|
|
||||||
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
|
|
||||||
|
|
||||||
if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
|
iter = mapit_getallusers();
|
||||||
sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
|
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
|
||||||
} else {
|
{
|
||||||
atcmd_output[0]=0;
|
pl_GM_level = pc_isGM(pl_sd);
|
||||||
}
|
if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
|
||||||
//Player name
|
{// you can look only lower or same level
|
||||||
sprintf(temp0, msg_txt(333), pl_sd->status.name);
|
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
|
||||||
strcat(atcmd_output,temp0);
|
for (j = 0; player_name[j]; j++)
|
||||||
//Player title, if exists
|
player_name[j] = TOLOWER(player_name[j]);
|
||||||
if (pl_GM_level > 0) {
|
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
|
||||||
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
|
|
||||||
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
|
|
||||||
strcat(atcmd_output,temp0);
|
|
||||||
}
|
|
||||||
//Players Location: map x y
|
|
||||||
sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
|
|
||||||
strcat(atcmd_output,temp0);
|
|
||||||
|
|
||||||
clif_displaymessage(fd, atcmd_output);
|
if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
|
||||||
count++;
|
sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
|
||||||
|
} else {
|
||||||
|
atcmd_output[0]=0;
|
||||||
}
|
}
|
||||||
|
//Player name
|
||||||
|
sprintf(temp0, msg_txt(333), pl_sd->status.name);
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
|
//Player title, if exists
|
||||||
|
if (pl_GM_level > 0) {
|
||||||
|
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
|
||||||
|
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
|
}
|
||||||
|
//Players Location: map x y
|
||||||
|
sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
|
|
||||||
|
clif_displaymessage(fd, atcmd_output);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
||||||
@ -637,8 +640,9 @@ int atcommand_who3(const int fd, struct map_session_data* sd, const char* comman
|
|||||||
int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
||||||
{
|
{
|
||||||
char temp0[100];
|
char temp0[100];
|
||||||
struct map_session_data *pl_sd, **pl_allsd;
|
struct map_session_data *pl_sd;
|
||||||
int i, j, count, users;
|
struct s_mapiterator* iter;
|
||||||
|
int j, count;
|
||||||
int pl_GM_level, GM_level;
|
int pl_GM_level, GM_level;
|
||||||
char match_text[100];
|
char match_text[100];
|
||||||
char player_name[NAME_LENGTH];
|
char player_name[NAME_LENGTH];
|
||||||
@ -656,35 +660,37 @@ int atcommand_who2(const int fd, struct map_session_data* sd, const char* comman
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
GM_level = pc_isGM(sd);
|
GM_level = pc_isGM(sd);
|
||||||
pl_allsd = map_getallusers(&users);
|
|
||||||
for (i = 0; i < users; i++) {
|
|
||||||
if ((pl_sd = pl_allsd[i])) {
|
|
||||||
pl_GM_level = pc_isGM(pl_sd);
|
|
||||||
if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
|
|
||||||
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
|
|
||||||
for (j = 0; player_name[j]; j++)
|
|
||||||
player_name[j] = TOLOWER(player_name[j]);
|
|
||||||
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
|
|
||||||
//Players Name
|
|
||||||
//sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
|
|
||||||
sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
|
|
||||||
//Player title, if exists
|
|
||||||
if (pl_GM_level > 0) {
|
|
||||||
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
|
|
||||||
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
|
|
||||||
strcat(atcmd_output,temp0);
|
|
||||||
}
|
|
||||||
//Players Base Level / Job name
|
|
||||||
//sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
|
|
||||||
sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
|
|
||||||
strcat(atcmd_output,temp0);
|
|
||||||
|
|
||||||
clif_displaymessage(fd, atcmd_output);
|
iter = mapit_getallusers();
|
||||||
count++;
|
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
|
||||||
|
{
|
||||||
|
pl_GM_level = pc_isGM(pl_sd);
|
||||||
|
if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
|
||||||
|
{// you can look only lower or same level
|
||||||
|
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
|
||||||
|
for (j = 0; player_name[j]; j++)
|
||||||
|
player_name[j] = TOLOWER(player_name[j]);
|
||||||
|
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
|
||||||
|
//Players Name
|
||||||
|
//sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
|
||||||
|
sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
|
||||||
|
//Player title, if exists
|
||||||
|
if (pl_GM_level > 0) {
|
||||||
|
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
|
||||||
|
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
}
|
}
|
||||||
|
//Players Base Level / Job name
|
||||||
|
//sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
|
||||||
|
sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
|
|
||||||
|
clif_displaymessage(fd, atcmd_output);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
||||||
@ -704,8 +710,9 @@ int atcommand_who2(const int fd, struct map_session_data* sd, const char* comman
|
|||||||
int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
||||||
{
|
{
|
||||||
char temp0[100];
|
char temp0[100];
|
||||||
struct map_session_data *pl_sd, **pl_allsd;
|
struct map_session_data *pl_sd;
|
||||||
int i, j, count, users;
|
struct s_mapiterator* iter;
|
||||||
|
int j, count;
|
||||||
int pl_GM_level, GM_level;
|
int pl_GM_level, GM_level;
|
||||||
char match_text[100];
|
char match_text[100];
|
||||||
char player_name[NAME_LENGTH];
|
char player_name[NAME_LENGTH];
|
||||||
@ -726,44 +733,44 @@ int atcommand_who(const int fd, struct map_session_data* sd, const char* command
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
GM_level = pc_isGM(sd);
|
GM_level = pc_isGM(sd);
|
||||||
pl_allsd = map_getallusers(&users);
|
|
||||||
for (i = 0; i < users; i++) {
|
iter = mapit_getallusers();
|
||||||
if ((pl_sd = pl_allsd[i])) {
|
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
|
||||||
pl_GM_level = pc_isGM(pl_sd);
|
{
|
||||||
if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
|
pl_GM_level = pc_isGM(pl_sd);
|
||||||
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
|
if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
|
||||||
for (j = 0; player_name[j]; j++)
|
{// you can look only lower or same level
|
||||||
player_name[j] = TOLOWER(player_name[j]);
|
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
|
||||||
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
|
for (j = 0; player_name[j]; j++)
|
||||||
g = guild_search(pl_sd->status.guild_id);
|
player_name[j] = TOLOWER(player_name[j]);
|
||||||
p = party_search(pl_sd->status.party_id);
|
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
|
||||||
//Players Name
|
g = guild_search(pl_sd->status.guild_id);
|
||||||
//sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
|
p = party_search(pl_sd->status.party_id);
|
||||||
sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
|
//Players Name
|
||||||
//Player title, if exists
|
sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
|
||||||
if (pl_GM_level > 0) {
|
//Player title, if exists
|
||||||
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
|
if (pl_GM_level > 0) {
|
||||||
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
|
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
|
||||||
strcat(atcmd_output,temp0);
|
strcat(atcmd_output,temp0);
|
||||||
}
|
|
||||||
//Players Party if exists
|
|
||||||
if (p != NULL) {
|
|
||||||
//sprintf(temp0," | Party: '%s'", p->name);
|
|
||||||
sprintf(temp0, msg_txt(335), p->party.name);
|
|
||||||
strcat(atcmd_output,temp0);
|
|
||||||
}
|
|
||||||
//Players Guild if exists
|
|
||||||
if (g != NULL) {
|
|
||||||
//sprintf(temp0," | Guild: '%s'", g->name);
|
|
||||||
sprintf(temp0, msg_txt(336), g->name);
|
|
||||||
strcat(atcmd_output,temp0);
|
|
||||||
}
|
|
||||||
clif_displaymessage(fd, atcmd_output);
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
//Players Party if exists
|
||||||
|
if (p != NULL) {
|
||||||
|
//sprintf(temp0," | Party: '%s'", p->name);
|
||||||
|
sprintf(temp0, msg_txt(335), p->party.name);
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
|
}
|
||||||
|
//Players Guild if exists
|
||||||
|
if (g != NULL) {
|
||||||
|
//sprintf(temp0," | Guild: '%s'", g->name);
|
||||||
|
sprintf(temp0, msg_txt(336), g->name);
|
||||||
|
strcat(atcmd_output,temp0);
|
||||||
|
}
|
||||||
|
clif_displaymessage(fd, atcmd_output);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
||||||
|
@ -408,51 +408,6 @@ int charcommand_save(const int fd, struct map_session_data* sd, const char* comm
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
|
||||||
*
|
|
||||||
*------------------------------------------*/
|
|
||||||
//** Character Stats All by fritz
|
|
||||||
int charcommand_stats_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
|
||||||
{
|
|
||||||
char output[1024], gmlevel[1024];
|
|
||||||
int i;
|
|
||||||
int count, users;
|
|
||||||
struct map_session_data *pl_sd, **pl_allsd;
|
|
||||||
|
|
||||||
memset(output, '\0', sizeof(output));
|
|
||||||
memset(gmlevel, '\0', sizeof(gmlevel));
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
pl_allsd = map_getallusers(&users);
|
|
||||||
for(i = 0; i < users; i++) {
|
|
||||||
if ((pl_sd = pl_allsd[i]))
|
|
||||||
{
|
|
||||||
if (pc_isGM(pl_sd) > 0)
|
|
||||||
sprintf(gmlevel, "| GM Lvl: %d", pc_isGM(pl_sd));
|
|
||||||
else
|
|
||||||
sprintf(gmlevel, " ");
|
|
||||||
|
|
||||||
sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp);
|
|
||||||
clif_displaymessage(fd, output);
|
|
||||||
sprintf(output, "STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", pl_sd->status.str, pl_sd->status.agi, pl_sd->status.vit, pl_sd->status.int_, pl_sd->status.dex, pl_sd->status.luk, pl_sd->status.zeny, gmlevel);
|
|
||||||
clif_displaymessage(fd, output);
|
|
||||||
clif_displaymessage(fd, "--------");
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count == 0)
|
|
||||||
clif_displaymessage(fd, msg_txt(28)); // No player found.
|
|
||||||
else if (count == 1)
|
|
||||||
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
|
|
||||||
else {
|
|
||||||
sprintf(output, msg_txt(30), count); // %d players found.
|
|
||||||
clif_displaymessage(fd, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
* CharSpiritBall Function by PalasX
|
* CharSpiritBall Function by PalasX
|
||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
@ -790,63 +745,68 @@ int charcommand_item(const int fd, struct map_session_data* sd, const char* comm
|
|||||||
(item_data = itemdb_exists(atoi(item_name))) != NULL)
|
(item_data = itemdb_exists(atoi(item_name))) != NULL)
|
||||||
item_id = item_data->nameid;
|
item_id = item_data->nameid;
|
||||||
|
|
||||||
if (item_id >= 500) {
|
if (item_id < 500) {
|
||||||
get_count = number;
|
clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
|
||||||
// check pet egg
|
return -1;
|
||||||
pet_id = search_petDB_index(item_id, PET_EGG);
|
}
|
||||||
if (item_data->type == 4 || item_data->type == 5 ||
|
|
||||||
item_data->type == 7 || item_data->type == 8) {
|
|
||||||
get_count = 1;
|
|
||||||
}
|
|
||||||
if ((pl_sd = map_nick2sd(character)) != NULL) {
|
|
||||||
if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
|
|
||||||
for (i = 0; i < number; i += get_count) {
|
|
||||||
// if pet egg
|
|
||||||
if (pet_id >= 0) {
|
|
||||||
pl_sd->catch_target_class = pet_db[pet_id].class_;
|
|
||||||
intif_create_pet(pl_sd->status.account_id, pl_sd->status.char_id,
|
|
||||||
(short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
|
|
||||||
(short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
|
|
||||||
100, 0, 1, pet_db[pet_id].jname);
|
|
||||||
// if not pet egg
|
|
||||||
} else {
|
|
||||||
memset(&item_tmp, 0, sizeof(item_tmp));
|
|
||||||
item_tmp.nameid = item_id;
|
|
||||||
item_tmp.identify = 1;
|
|
||||||
|
|
||||||
if ((flag = pc_additem(pl_sd, &item_tmp, get_count)))
|
get_count = number;
|
||||||
clif_additem(pl_sd, 0, 0, flag);
|
// check pet egg
|
||||||
}
|
pet_id = search_petDB_index(item_id, PET_EGG);
|
||||||
}
|
if (item_data->type == 4 || item_data->type == 5 ||
|
||||||
|
item_data->type == 7 || item_data->type == 8) {
|
||||||
|
get_count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
//Logs (A)dmins items [Lupus]
|
if ((pl_sd = map_nick2sd(character)) == NULL)
|
||||||
if(log_config.enable_logs&0x400)
|
{
|
||||||
log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
|
if (pc_isGM(sd) < pc_isGM(pl_sd))
|
||||||
|
{// you can give items only to lower or same level
|
||||||
clif_displaymessage(fd, msg_txt(18)); // Item created.
|
clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
|
||||||
} else {
|
|
||||||
clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if(/* from jA's @giveitem */strcmpi(character,"all")==0 || strcmpi(character,"everyone")==0){
|
|
||||||
struct map_session_data **pl_allsd;
|
|
||||||
int users;
|
|
||||||
pl_allsd = map_getallusers(&users);
|
|
||||||
for (i = 0; i < users; i++) {
|
|
||||||
if ((pl_sd = pl_allsd[i])) {
|
|
||||||
charcommand_giveitem_sub(pl_sd,item_data,number);
|
|
||||||
snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "You got %s %d.", item_name,number);
|
|
||||||
clif_displaymessage(pl_sd->fd, tmp_cmdoutput);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "%s received %s %d.","Everyone",item_name,number);
|
|
||||||
clif_displaymessage(fd, tmp_cmdoutput);
|
|
||||||
} else {
|
|
||||||
clif_displaymessage(fd, msg_txt(3)); // Character not found.
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < number; i += get_count) {
|
||||||
|
// if pet egg
|
||||||
|
if (pet_id >= 0) {
|
||||||
|
pl_sd->catch_target_class = pet_db[pet_id].class_;
|
||||||
|
intif_create_pet(pl_sd->status.account_id, pl_sd->status.char_id,
|
||||||
|
(short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
|
||||||
|
(short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
|
||||||
|
100, 0, 1, pet_db[pet_id].jname);
|
||||||
|
// if not pet egg
|
||||||
|
} else {
|
||||||
|
memset(&item_tmp, 0, sizeof(item_tmp));
|
||||||
|
item_tmp.nameid = item_id;
|
||||||
|
item_tmp.identify = 1;
|
||||||
|
|
||||||
|
if ((flag = pc_additem(pl_sd, &item_tmp, get_count)))
|
||||||
|
clif_additem(pl_sd, 0, 0, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Logs (A)dmins items [Lupus]
|
||||||
|
if(log_config.enable_logs&0x400)
|
||||||
|
log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
|
||||||
|
|
||||||
|
clif_displaymessage(fd, msg_txt(18)); // Item created.
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (strcmpi(character,"all")==0 || strcmpi(character,"everyone")==0) {
|
||||||
|
struct s_mapiterator* iter = mapit_getallusers();
|
||||||
|
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
|
||||||
|
{
|
||||||
|
charcommand_giveitem_sub(pl_sd,item_data,number);
|
||||||
|
snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "You got %s %d.", item_name,number);
|
||||||
|
clif_displaymessage(pl_sd->fd, tmp_cmdoutput);
|
||||||
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
|
snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "%s received %s %d.","Everyone",item_name,number);
|
||||||
|
clif_displaymessage(fd, tmp_cmdoutput);
|
||||||
} else {
|
} else {
|
||||||
clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
|
clif_displaymessage(fd, msg_txt(3)); // Character not found.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1326,11 +1326,15 @@ int ping_char_server(int tid, unsigned int tick, int id, int data)
|
|||||||
// unused
|
// unused
|
||||||
int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
|
int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
|
||||||
{
|
{
|
||||||
int count;
|
int count = 0;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
chrif_check(-1);
|
chrif_check(-1);
|
||||||
|
|
||||||
map_getallusers(&count);
|
iter = mapit_getallusers();
|
||||||
|
for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
|
||||||
|
count++;
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
WFIFOHEAD(char_fd,4);
|
WFIFOHEAD(char_fd,4);
|
||||||
WFIFOW(char_fd,0) = 0x2afe;
|
WFIFOW(char_fd,0) = 0x2afe;
|
||||||
@ -1345,22 +1349,32 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
int send_users_tochar(void)
|
int send_users_tochar(void)
|
||||||
{
|
{
|
||||||
int count, users=0, i;
|
int users = 0, i = 0;
|
||||||
struct map_session_data **all_sd;
|
struct map_session_data* sd;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
chrif_check(-1);
|
chrif_check(-1);
|
||||||
|
|
||||||
all_sd = map_getallusers(&count);
|
// get user count (TODO: improve this)
|
||||||
|
iter = mapit_getallusers();
|
||||||
|
for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
|
||||||
|
users++;
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
|
// build the packet
|
||||||
WFIFOHEAD(char_fd, 6+8*users);
|
WFIFOHEAD(char_fd, 6+8*users);
|
||||||
WFIFOW(char_fd,0) = 0x2aff;
|
WFIFOW(char_fd,0) = 0x2aff;
|
||||||
for (i = 0; i < count; i++) {
|
iter = mapit_getallusers();
|
||||||
WFIFOL(char_fd,6+8*users) = all_sd[i]->status.account_id;
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
WFIFOL(char_fd,6+8*users+4) = all_sd[i]->status.char_id;
|
{
|
||||||
users++;
|
WFIFOL(char_fd,6+8*i) = sd->status.account_id;
|
||||||
|
WFIFOL(char_fd,6+8*i+4) = sd->status.char_id;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
WFIFOW(char_fd,2) = 6 + 8 * users;
|
mapit_free(iter);
|
||||||
|
WFIFOW(char_fd,2) = 6 + 8*users;
|
||||||
WFIFOW(char_fd,4) = users;
|
WFIFOW(char_fd,4) = users;
|
||||||
WFIFOSET(char_fd,6+8*users);
|
WFIFOSET(char_fd, 6+8*users);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -470,43 +470,48 @@ int guild_npc_request_info(int guild_id,const char *event)
|
|||||||
// 所属キャラの確認
|
// 所属キャラの確認
|
||||||
int guild_check_member(struct guild *g)
|
int guild_check_member(struct guild *g)
|
||||||
{
|
{
|
||||||
int i, j, users;
|
int i;
|
||||||
struct map_session_data *sd, **all_sd;
|
struct map_session_data *sd;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
nullpo_retr(0, g);
|
nullpo_retr(0, g);
|
||||||
|
|
||||||
all_sd = map_getallusers(&users);
|
iter = mapit_getallusers();
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
|
{
|
||||||
|
if( sd->status.guild_id != g->guild_id )
|
||||||
|
continue;
|
||||||
|
|
||||||
for(i=0;i<users;i++){
|
i = guild_getindex(g,sd->status.account_id,sd->status.char_id);
|
||||||
sd=all_sd[i];
|
if (i < 0) {
|
||||||
if(sd->status.guild_id==g->guild_id){
|
sd->status.guild_id=0;
|
||||||
j=guild_getindex(g,sd->status.account_id,sd->status.char_id);
|
sd->state.guild_sent=0;
|
||||||
if (j < 0) {
|
sd->guild_emblem_id=0;
|
||||||
sd->status.guild_id=0;
|
ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name);
|
||||||
sd->state.guild_sent=0;
|
|
||||||
sd->guild_emblem_id=0;
|
|
||||||
ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 情報所得失敗(そのIDのキャラを全部未所属にする)
|
// 情報所得失敗(そのIDのキャラを全部未所属にする)
|
||||||
int guild_recv_noinfo(int guild_id)
|
int guild_recv_noinfo(int guild_id)
|
||||||
{
|
{
|
||||||
int i, users;
|
struct map_session_data *sd;
|
||||||
struct map_session_data *sd, **all_sd;
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
all_sd = map_getallusers(&users);
|
iter = mapit_getallusers();
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
for(i=0;i<users;i++){
|
{
|
||||||
if((sd=all_sd[i])){
|
if( sd->status.guild_id == guild_id )
|
||||||
if(sd->status.guild_id==guild_id)
|
sd->status.guild_id = 0; // erase guild
|
||||||
sd->status.guild_id=0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 情報所得
|
// 情報所得
|
||||||
int guild_recv_info(struct guild *sg)
|
int guild_recv_info(struct guild *sg)
|
||||||
{
|
{
|
||||||
|
@ -184,8 +184,6 @@ void irc_parse_sub(int fd, char *incoming_string)
|
|||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
struct map_session_data **allsd;
|
|
||||||
|
|
||||||
memset(source,'\0',256);
|
memset(source,'\0',256);
|
||||||
memset(command,'\0',256);
|
memset(command,'\0',256);
|
||||||
memset(target,'\0',256);
|
memset(target,'\0',256);
|
||||||
@ -266,25 +264,41 @@ void irc_parse_sub(int fd, char *incoming_string)
|
|||||||
else // Number of users online
|
else // Number of users online
|
||||||
if(strcmpi(cmdname,"users")==0)
|
if(strcmpi(cmdname,"users")==0)
|
||||||
{
|
{
|
||||||
int users;
|
int users = 0;
|
||||||
map_getallusers(&users);
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
|
iter = mapit_getallusers();
|
||||||
|
for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
|
||||||
|
users++;
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
sprintf(send_string, "PRIVMSG %s :Users Online: %d", irc_channel, users);
|
sprintf(send_string, "PRIVMSG %s :Users Online: %d", irc_channel, users);
|
||||||
irc_send(send_string);
|
irc_send(send_string);
|
||||||
}
|
}
|
||||||
else // List all users online
|
else // List all users online
|
||||||
if(strcmpi(cmdname,"who")==0)
|
if(strcmpi(cmdname,"who")==0)
|
||||||
{
|
{
|
||||||
int users;
|
int users = 0;
|
||||||
allsd = map_getallusers(&users);
|
struct s_mapiterator* iter;
|
||||||
|
struct map_session_data* sd;
|
||||||
|
|
||||||
|
iter = mapit_getallusers();
|
||||||
|
for( mapit_first(iter); mapit_exists(iter); mapit_next(iter) )
|
||||||
|
users++;
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
if(users > 0)
|
if(users > 0)
|
||||||
{
|
{
|
||||||
sprintf(send_string,"NOTICE %s :%d Users Online",source_nick,users);
|
sprintf(send_string,"NOTICE %s :%d Users Online",source_nick,users);
|
||||||
irc_send(send_string);
|
irc_send(send_string);
|
||||||
for(i = 0; i < users; i++)
|
|
||||||
|
iter = mapit_getallusers();
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
{
|
{
|
||||||
sprintf(send_string,"NOTICE %s :Name: \"%s\"",source_nick,allsd[i]->status.name);
|
sprintf(send_string,"NOTICE %s :Name: \"%s\"",source_nick,sd->status.name);
|
||||||
irc_send(send_string);
|
irc_send(send_string);
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1703,39 +1703,51 @@ struct map_session_data* map_charid2sd(int charid)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
struct map_session_data * map_nick2sd(const char *nick)
|
struct map_session_data * map_nick2sd(const char *nick)
|
||||||
{
|
{
|
||||||
int i, users;
|
struct map_session_data* sd;
|
||||||
struct map_session_data *pl_sd = NULL, **pl_allsd;
|
struct map_session_data* found_sd;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
size_t nicklen;
|
||||||
|
|
||||||
if (nick == NULL)
|
if( nick == NULL )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pl_allsd = map_getallusers(&users);
|
nicklen = strlen(nick);
|
||||||
if (battle_config.partial_name_scan)
|
iter = mapit_getallusers();
|
||||||
|
|
||||||
|
found_sd = NULL;
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
{
|
{
|
||||||
int qty = 0, nicklen = strlen(nick);
|
if( battle_config.partial_name_scan )
|
||||||
struct map_session_data *sd = NULL;
|
{// partial name search
|
||||||
for (i = 0; i < users; i++) {
|
if( strnicmp(sd->status.name, nick, nicklen) == 0 )
|
||||||
pl_sd = pl_allsd[i];
|
{
|
||||||
// Without case sensitive check (increase the number of similar character names found)
|
if( strcmp(sd->status.name, nick) == 0 )
|
||||||
if (strnicmp(pl_sd->status.name, nick, nicklen) == 0) {
|
{// perfect match found
|
||||||
// Strict comparison (if found, we finish the function immediatly with correct value)
|
found_sd = sd;
|
||||||
if (strcmp(pl_sd->status.name, nick) == 0)
|
break;
|
||||||
return pl_sd;
|
}
|
||||||
qty++;
|
if( found_sd != NULL )
|
||||||
sd = pl_sd;
|
{// collision
|
||||||
|
found_sd = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
found_sd = sd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We return the found index of a similar account ONLY if there is 1 similar character
|
else
|
||||||
if (qty == 1)
|
{// exact search only
|
||||||
return sd;
|
if( strcasecmp(sd->status.name, nick) == 0 )
|
||||||
} else { //Exact Search
|
{
|
||||||
for (i = 0; i < users; i++) {
|
found_sd = sd;
|
||||||
if (strcasecmp(pl_allsd[i]->status.name, nick) == 0)
|
break;
|
||||||
return pl_allsd[i];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Not found.
|
|
||||||
return NULL;
|
mapit_free(iter);
|
||||||
|
|
||||||
|
return found_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
@ -3134,7 +3146,8 @@ static int cleanup_db_subpc(DBKey key,void *data,va_list va)
|
|||||||
void do_final(void)
|
void do_final(void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
struct map_session_data **pl_allsd;
|
struct map_session_data* sd;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
ShowStatus("Terminating...\n");
|
ShowStatus("Terminating...\n");
|
||||||
|
|
||||||
@ -3143,9 +3156,10 @@ void do_final(void)
|
|||||||
map_foreachinmap(cleanup_sub, i, BL_ALL);
|
map_foreachinmap(cleanup_sub, i, BL_ALL);
|
||||||
|
|
||||||
//Scan any remaining players (between maps?) to kick them out. [Skotlex]
|
//Scan any remaining players (between maps?) to kick them out. [Skotlex]
|
||||||
pl_allsd = map_getallusers(&j);
|
iter = mapit_getallusers();
|
||||||
for (i = 0; i < j; i++)
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
map_quit(pl_allsd[i]);
|
map_quit(sd);
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
id_db->foreach(id_db,cleanup_db_sub);
|
id_db->foreach(id_db,cleanup_db_sub);
|
||||||
chrif_char_reset_offline();
|
chrif_char_reset_offline();
|
||||||
|
@ -159,30 +159,29 @@ int party_request_info(int party_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if each char having a party actually belongs to that party.
|
/// Checks if each char having a party actually belongs to that party.
|
||||||
/// If check fails, the char is marked as 'not in a party'.
|
/// If check fails, the char gets marked as 'not in a party'.
|
||||||
int party_check_member(struct party *p)
|
int party_check_member(struct party *p)
|
||||||
{
|
{
|
||||||
int i, users;
|
int i;
|
||||||
struct map_session_data *sd, **all_sd;
|
struct map_session_data *sd;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
nullpo_retr(0, p);
|
nullpo_retr(0, p);
|
||||||
|
|
||||||
all_sd = map_getallusers(&users);
|
iter = mapit_getallusers();
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
for(i=0;i<users;i++)
|
|
||||||
{
|
{
|
||||||
sd = all_sd[i];
|
if( sd->status.party_id != p->party_id )
|
||||||
if( sd && sd->status.party_id == p->party_id )
|
continue;
|
||||||
|
|
||||||
|
ARR_FIND( 0, MAX_PARTY, i, p->member[i].account_id == sd->status.account_id && p->member[i].char_id == sd->status.char_id );
|
||||||
|
if( i == MAX_PARTY )
|
||||||
{
|
{
|
||||||
int j;
|
ShowWarning("party_check_member: '%s' (acc:%d) is not member of party '%s' (id:%d)\n",sd->status.name,sd->status.account_id,p->name,p->party_id);
|
||||||
ARR_FIND( 0, MAX_PARTY, j, p->member[j].account_id == sd->status.account_id && p->member[j].char_id == sd->status.char_id );
|
sd->status.party_id = 0;
|
||||||
if( j == MAX_PARTY )
|
|
||||||
{
|
|
||||||
ShowWarning("party_check_member: '%s' (acc:%d) is not member of party '%s' (id:%d)\n",sd->status.name,sd->status.account_id,p->name,p->party_id);
|
|
||||||
sd->status.party_id = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -190,15 +189,17 @@ int party_check_member(struct party *p)
|
|||||||
/// Marks all chars belonging to this party as 'not in a party'.
|
/// Marks all chars belonging to this party as 'not in a party'.
|
||||||
int party_recv_noinfo(int party_id)
|
int party_recv_noinfo(int party_id)
|
||||||
{
|
{
|
||||||
int i, users;
|
struct map_session_data *sd;
|
||||||
struct map_session_data *sd, **all_sd;
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
all_sd = map_getallusers(&users);
|
iter = mapit_getallusers();
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
for(i=0;i<users;i++){
|
{
|
||||||
if((sd = all_sd[i]) && sd->status.party_id==party_id)
|
if( sd->status.party_id == party_id )
|
||||||
sd->status.party_id=0;
|
sd->status.party_id = 0; // erase party
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
219
src/map/script.c
219
src/map/script.c
@ -4318,32 +4318,26 @@ BUILDIN_FUNC(areawarp)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
BUILDIN_FUNC(warpchar)
|
BUILDIN_FUNC(warpchar)
|
||||||
{
|
{
|
||||||
int x,y,a,i;
|
int x,y,a;
|
||||||
const char *str;
|
const char *str;
|
||||||
TBL_PC *sd, **pl_allsd;
|
TBL_PC *sd;
|
||||||
int users;
|
|
||||||
|
|
||||||
str=script_getstr(st,2);
|
str=script_getstr(st,2);
|
||||||
x=script_getnum(st,3);
|
x=script_getnum(st,3);
|
||||||
y=script_getnum(st,4);
|
y=script_getnum(st,4);
|
||||||
a=script_getnum(st,5);
|
a=script_getnum(st,5);
|
||||||
|
|
||||||
pl_allsd = map_getallusers(&users);
|
sd = map_charid2sd(a);
|
||||||
|
if( sd == NULL )
|
||||||
|
return 0;
|
||||||
|
|
||||||
for(i=0; i<users; i++) {
|
if(strcmp(str, "Random") == 0)
|
||||||
sd = pl_allsd[i];
|
pc_randomwarp(sd, 3);
|
||||||
if(sd->status.char_id == a) {
|
else
|
||||||
|
if(strcmp(str, "SavePoint") == 0)
|
||||||
if(strcmp(str, "Random") == 0)
|
pc_setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, 3);
|
||||||
pc_randomwarp(sd, 3);
|
else
|
||||||
|
pc_setpos(sd, mapindex_name2id(str), x, y, 3);
|
||||||
else if(strcmp(str, "SavePoint") == 0)
|
|
||||||
pc_setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, 3);
|
|
||||||
|
|
||||||
else
|
|
||||||
pc_setpos(sd, mapindex_name2id(str), x, y, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -4459,87 +4453,63 @@ BUILDIN_FUNC(warpguild)
|
|||||||
int x,y;
|
int x,y;
|
||||||
unsigned short mapindex;
|
unsigned short mapindex;
|
||||||
const char *str;
|
const char *str;
|
||||||
int g;
|
int gid;
|
||||||
int i;
|
|
||||||
TBL_PC *pl_sd, **pl_allsd;
|
|
||||||
int users;
|
|
||||||
TBL_PC *sd;
|
TBL_PC *sd;
|
||||||
|
TBL_PC *pl_sd;
|
||||||
|
struct guild* g;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
int type;
|
||||||
|
|
||||||
str=script_getstr(st,2);
|
str=script_getstr(st,2);
|
||||||
x=script_getnum(st,3);
|
x=script_getnum(st,3);
|
||||||
y=script_getnum(st,4);
|
y=script_getnum(st,4);
|
||||||
g=script_getnum(st,5);
|
gid=script_getnum(st,5);
|
||||||
|
|
||||||
sd=script_rid2sd(st);
|
sd=script_rid2sd(st);
|
||||||
if( sd == NULL )
|
if( sd == NULL )
|
||||||
return 0;
|
return 0;
|
||||||
|
g = guild_search(gid);
|
||||||
|
if( g == NULL )
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(map[sd->bl.m].flag.noreturn || map[sd->bl.m].flag.nowarpto)
|
if(map[sd->bl.m].flag.noreturn || map[sd->bl.m].flag.nowarpto)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(g < 1)
|
type = ( strcmp(str,"Random")==0 ) ? 0
|
||||||
return 0;
|
: ( strcmp(str,"SavePointAll")==0 ) ? 1
|
||||||
|
: ( strcmp(str,"SavePoint")==0 ) ? 2
|
||||||
pl_allsd = map_getallusers(&users);
|
: 3;
|
||||||
|
if( type == 3 )
|
||||||
if(strcmp(str,"Random")==0)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (i = 0; i < users; i++)
|
|
||||||
{
|
|
||||||
if ((pl_sd = pl_allsd[i]) && pl_sd->status.guild_id == g)
|
|
||||||
{
|
|
||||||
if(map[pl_sd->bl.m].flag.nowarp)
|
|
||||||
continue;
|
|
||||||
pc_randomwarp(pl_sd,3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(strcmp(str,"SavePointAll")==0)
|
|
||||||
{
|
|
||||||
if(map[sd->bl.m].flag.noreturn)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < users; i++)
|
|
||||||
{
|
|
||||||
if ((pl_sd = pl_allsd[i]) && pl_sd->status.guild_id == g)
|
|
||||||
{
|
|
||||||
if(map[pl_sd->bl.m].flag.noreturn)
|
|
||||||
continue;
|
|
||||||
pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(strcmp(str,"SavePoint")==0)
|
|
||||||
{
|
|
||||||
if(map[sd->bl.m].flag.noreturn)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
mapindex=sd->status.save_point.map;
|
|
||||||
x=sd->status.save_point.x;
|
|
||||||
y=sd->status.save_point.y;
|
|
||||||
for (i = 0; i < users; i++)
|
|
||||||
{
|
|
||||||
if ((pl_sd = pl_allsd[i]) && pl_sd->status.guild_id == g)
|
|
||||||
{
|
|
||||||
if(map[pl_sd->bl.m].flag.noreturn)
|
|
||||||
continue;
|
|
||||||
pc_setpos(pl_sd,mapindex,x,y,3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mapindex = mapindex_name2id(str);
|
mapindex = mapindex_name2id(str);
|
||||||
for (i = 0; i < users; i++)
|
|
||||||
|
iter = mapit_getallusers();
|
||||||
|
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
|
||||||
|
{
|
||||||
|
if( pl_sd->status.guild_id != gid )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch( type )
|
||||||
{
|
{
|
||||||
if ((pl_sd = pl_allsd[i]) && pl_sd->status.guild_id == g)
|
case 0: // Random
|
||||||
{
|
if(!map[pl_sd->bl.m].flag.nowarp)
|
||||||
if(map[pl_sd->bl.m].flag.noreturn || map[pl_sd->bl.m].flag.nowarp)
|
pc_randomwarp(pl_sd,3);
|
||||||
continue;
|
break;
|
||||||
|
case 1: // SavePointAll
|
||||||
|
if(!map[pl_sd->bl.m].flag.noreturn)
|
||||||
|
pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,3);
|
||||||
|
break;
|
||||||
|
case 2: // SavePoint
|
||||||
|
if(!map[pl_sd->bl.m].flag.noreturn)
|
||||||
|
pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,3);
|
||||||
|
break;
|
||||||
|
case 3: // m,x,y
|
||||||
|
if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
|
||||||
pc_setpos(pl_sd,mapindex,x,y,3);
|
pc_setpos(pl_sd,mapindex,x,y,3);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*==========================================
|
/*==========================================
|
||||||
@ -7947,24 +7917,25 @@ BUILDIN_FUNC(getusers)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
BUILDIN_FUNC(getusersname)
|
BUILDIN_FUNC(getusersname)
|
||||||
{
|
{
|
||||||
TBL_PC *sd, *pl_sd = NULL, **pl_allsd;
|
TBL_PC *sd, *pl_sd;
|
||||||
int i=0,disp_num=1, users;
|
int i=0,disp_num=1;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
sd = script_rid2sd(st);
|
sd = script_rid2sd(st);
|
||||||
if (!sd) return 0;
|
if (!sd) return 0;
|
||||||
|
|
||||||
pl_allsd = map_getallusers(&users);
|
iter = mapit_getallusers();
|
||||||
|
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
|
||||||
for (i=0;i<users;i++)
|
|
||||||
{
|
{
|
||||||
pl_sd = pl_allsd[i];
|
if( battle_config.hide_GM_session && pc_isGM(pl_sd) )
|
||||||
if( !(battle_config.hide_GM_session && pc_isGM(pl_sd)) )
|
continue; // skip hidden GMs
|
||||||
{
|
|
||||||
if((disp_num++)%10==0)
|
if((disp_num++)%10==0)
|
||||||
clif_scriptnext(sd,st->oid);
|
clif_scriptnext(sd,st->oid);
|
||||||
clif_scriptmes(sd,st->oid,pl_sd->status.name);
|
clif_scriptmes(sd,st->oid,pl_sd->status.name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*==========================================
|
/*==========================================
|
||||||
@ -9023,34 +8994,37 @@ BUILDIN_FUNC(removemapflag)
|
|||||||
|
|
||||||
BUILDIN_FUNC(pvpon)
|
BUILDIN_FUNC(pvpon)
|
||||||
{
|
{
|
||||||
int m,i,users;
|
int m;
|
||||||
const char *str;
|
const char *str;
|
||||||
TBL_PC *pl_sd=NULL, **pl_allsd;
|
TBL_PC* sd = NULL;
|
||||||
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
str=script_getstr(st,2);
|
str = script_getstr(st,2);
|
||||||
m = map_mapname2mapid(str);
|
m = map_mapname2mapid(str);
|
||||||
if(m >= 0 && !map[m].flag.pvp) {
|
if( m < 0 || map[m].flag.pvp )
|
||||||
map[m].flag.pvp = 1;
|
return 0; // nothing to do
|
||||||
clif_send0199(m,1);
|
|
||||||
|
|
||||||
if(battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris]
|
map[m].flag.pvp = 1;
|
||||||
return 0;
|
clif_send0199(m,1);
|
||||||
|
|
||||||
pl_allsd = map_getallusers(&users);
|
if(battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris]
|
||||||
|
return 0;
|
||||||
|
|
||||||
for(i=0;i<users;i++)
|
iter = mapit_getallusers();
|
||||||
{
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
if ((pl_sd = pl_allsd[i]) && m == pl_sd->bl.m && pl_sd->pvp_timer == -1)
|
{
|
||||||
{
|
if( sd->bl.m != m || sd->pvp_timer != -1 )
|
||||||
pl_sd->pvp_timer=add_timer(gettick()+200,pc_calc_pvprank_timer,pl_sd->bl.id,0);
|
continue; // not applicable
|
||||||
pl_sd->pvp_rank=0;
|
|
||||||
pl_sd->pvp_lastusers=0;
|
sd->pvp_timer = add_timer(gettick()+200,pc_calc_pvprank_timer,sd->bl.id,0);
|
||||||
pl_sd->pvp_point=5;
|
sd->pvp_rank = 0;
|
||||||
pl_sd->pvp_won = 0;
|
sd->pvp_lastusers = 0;
|
||||||
pl_sd->pvp_lost = 0;
|
sd->pvp_point = 5;
|
||||||
}
|
sd->pvp_won = 0;
|
||||||
}
|
sd->pvp_lost = 0;
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10664,20 +10638,19 @@ BUILDIN_FUNC(dispbottom)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
BUILDIN_FUNC(recovery)
|
BUILDIN_FUNC(recovery)
|
||||||
{
|
{
|
||||||
TBL_PC *sd, **all_sd;
|
TBL_PC* sd;
|
||||||
int i = 0, users;
|
struct s_mapiterator* iter;
|
||||||
|
|
||||||
all_sd = map_getallusers(&users);
|
iter = mapit_getallusers();
|
||||||
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
|
||||||
for (i = 0; i < users; i++)
|
|
||||||
{
|
{
|
||||||
sd = all_sd[i];
|
|
||||||
if(pc_isdead(sd))
|
if(pc_isdead(sd))
|
||||||
status_revive(&sd->bl, 100, 100);
|
status_revive(&sd->bl, 100, 100);
|
||||||
else
|
else
|
||||||
status_percent_heal(&sd->bl, 100, 100);
|
status_percent_heal(&sd->bl, 100, 100);
|
||||||
clif_displaymessage(sd->fd,"You have been recovered!");
|
clif_displaymessage(sd->fd,"You have been recovered!");
|
||||||
}
|
}
|
||||||
|
mapit_free(iter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*==========================================
|
/*==========================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user