summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-04-18 23:02:19 -0300
committerpanikon <panikon@zoho.com>2014-04-18 23:02:19 -0300
commit69ca0aaecc5823dfe273810077c185dff7f20611 (patch)
tree21bb0cd4f5ce4e4ada42738cdf43f3d5991bd001 /src/map
parentc9bc22834a472d4b766586135d4c954c49f736cc (diff)
downloadhercules-69ca0aaecc5823dfe273810077c185dff7f20611.tar.gz
hercules-69ca0aaecc5823dfe273810077c185dff7f20611.tar.bz2
hercules-69ca0aaecc5823dfe273810077c185dff7f20611.tar.xz
hercules-69ca0aaecc5823dfe273810077c185dff7f20611.zip
# Several minor changes in atcommands
1. Reallocated and added checks in @jumpto, @jump, @mapmove in order to increase performance * Checks are now made to avoid unnecessary lookups and unnecessary warps 2. Corrected return failure values of @zeny 3. Added messages to * ATclearcart > Warns that it's not possible to clean a cart while vending * ATshowmobs > Asks user to enter a mob name/id and warns if the mob name is invalid * ATgstorage > Warns when another guild member is using the gstorage # Fixed issue where while using storage/gstorage and then refreshing would close the storage but only for the client, the server wouldn't now and this would cause the guild storage to remain locked and the character without ability to do anything.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c78
-rw-r--r--src/map/clif.c20
2 files changed, 78 insertions, 20 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 6668214fa..e9b00cce6 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -404,6 +404,11 @@ ACMD(mapmove) {
clif->message(fd, msg_txt(1)); // Map not found.
return false;
}
+
+ if( sd->bl.m == m && sd->bl.x == x && sd->bl.y == y ) {
+ clif->message(fd, msg_txt(253)); // You already are at your destination!
+ return false;
+ }
if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc_get_group_level(sd) < battle_config.gm_ignore_warpable_area) {
//This is to prevent the pc->setpos call from printing an error.
@@ -466,27 +471,37 @@ ACMD(jumpto) {
clif->message(fd, msg_txt(911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
return false;
}
-
- if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
- clif->message(fd, msg_txt(3)); // Character not found.
- return false;
- }
-
- if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
- clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map.
+
+ if( message == sd->status.name || (atoi(message)) == sd->status.char_id ) {
+ clif->message(fd, msg_txt(253)); // You already are at your destination!
return false;
}
-
+
if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map.
return false;
}
-
+
if( pc_isdead(sd) ) {
clif->message(fd, msg_txt(864)); // "You cannot use this command when dead."
return false;
}
+ if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
+ clif->message(fd, msg_txt(3)); // Character not found.
+ return false;
+ }
+
+ if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
+ clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map.
+ return false;
+ }
+
+ if( pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y ) {
+ clif->message(fd, msg_txt(253)); // You already are at your destination!
+ return false;
+ }
+
pc->setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
clif->message(fd, atcmd_output);
@@ -521,6 +536,11 @@ ACMD(jump)
if (!map->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
+
+ if( x && y && sd->bl.x == x && sd->bl.y == y ) {
+ clif->message(fd, msg_txt(253)); // You already are at your destination!
+ return false;
+ }
pc->setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
@@ -825,7 +845,11 @@ ACMD(guildstorage)
return false;
}
- gstorage->open(sd);
+ if( gstorage->open(sd) ) {
+ clif->message(fd, msg_txt(1201)); // Your guild's storage has already been opened by another member, try again later.
+ return false;
+ }
+
clif->message(fd, msg_txt(920)); // Guild storage opened.
return true;
}
@@ -2354,7 +2378,11 @@ ACMD(zeny)
if((ret=pc->payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
}
- if(!ret) clif->message(fd, msg_txt(176)); //ret=0 mean cmd success
+
+ if( ret ) //ret != 0 means cmd failure
+ return false;
+
+ clif->message(fd, msg_txt(176));
return true;
}
@@ -5184,9 +5212,10 @@ ACMD(clearcart)
return false;
}
- if (sd->state.vending == 1) { //Somehow...
- return false;
- }
+ if( sd->state.vending == 1 ) {
+ clif->message(fd, msg_txt(548)); // You can't clean a cart while vending!
+ return false;
+ }
for( i = 0; i < MAX_CART; i++ )
if(sd->status.cart[i].nameid > 0)
@@ -6674,20 +6703,29 @@ ACMD(showmobs)
int number = 0;
struct s_mapiterator* it;
- if(sscanf(message, "%99[^\n]", mob_name) < 0)
+ if( sscanf(message, "%99[^\n]", mob_name) < 0 ) {
+ clif->message(fd, msg_txt(546)); // Please enter a mob name/id (usage: @showmobs <mob name/id>)
return false;
-
- if((mob_id = atoi(mob_name)) == 0)
+ }
+
+ if( (mob_id = atoi(mob_name)) == 0 )
mob_id = mob->db_searchname(mob_name);
+
+ if( mob_id == 0 ) {
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(547), mob_name); // Invalid mob name %s!
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
if(mob_id > 0 && mob->db_checkid(mob_id) == 0){
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
clif->message(fd, atcmd_output);
- return true;
+ return false;
}
if(mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
clif->message(fd, msg_txt(1251)); // Can't show boss mobs!
- return true;
+ return false;
}
if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname)
diff --git a/src/map/clif.c b/src/map/clif.c
index 7715e6c6a..d0fb08486 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8480,6 +8480,26 @@ void clif_refresh(struct map_session_data *sd)
pc->disguise(sd, disguise);
}
+ // Notify the client that the storage is open
+ if( sd->state.storage_flag == 1 ) {
+ storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
+ clif->storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
+ clif->updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE);
+ }
+ // Notify the client that the gstorage is open otherwise it will
+ // remain locked forever and nobody will be able to access it
+ if( sd->state.storage_flag == 2 ) {
+ struct guild_storage *gstor;
+ if( (gstor = gstorage->id2storage2(sd->status.guild_id)) == NULL) {
+ // Shouldn't happen... The information should already be at the map-server
+ intif->request_guild_storage(sd->status.account_id,sd->status.guild_id);
+ } else {
+ storage->sortitem(gstor->items, ARRAYLENGTH(gstor->items));
+ clif->storagelist(sd, gstor->items, ARRAYLENGTH(gstor->items));
+ clif->updatestorageamount(sd, gstor->storage_amount, MAX_GUILD_STORAGE);
+ }
+ }
+
}