summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c86
-rw-r--r--src/map/storage.c13
-rw-r--r--src/map/storage.h1
3 files changed, 99 insertions, 1 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d115fdffa..2e2ec658f 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -52,7 +52,7 @@
#define ATCOMMAND_LENGTH 50
#define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
-#define MAX_MSG 1400
+#define MAX_MSG 1500
typedef struct AtCommandInfo AtCommandInfo;
@@ -5258,6 +5258,86 @@ ACMD_FUNC(storeall)
return 0;
}
+ACMD_FUNC(clearstorage)
+{
+ int i, j;
+ nullpo_retr(-1, sd);
+
+ if (sd->state.storage_flag == 1) {
+ clif_displaymessage(fd, msg_txt(250));
+ return -1;
+ }
+
+ j = sd->status.storage.storage_amount;
+ for (i = 0; i < j; ++i) {
+ storage_delitem(sd, i, sd->status.storage.items[i].amount);
+ }
+ storage_storageclose(sd);
+
+ clif_displaymessage(fd, msg_txt(1394)); // Your storage was cleaned.
+ return 0;
+}
+
+ACMD_FUNC(cleargstorage)
+{
+ int i, j;
+ struct guild *g;
+ struct guild_storage *gstorage;
+ nullpo_retr(-1, sd);
+
+ g = guild_search(sd->status.guild_id);
+
+ if (g == NULL) {
+ clif_displaymessage(fd, msg_txt(43));
+ return -1;
+ }
+
+ if (sd->state.storage_flag == 1) {
+ clif_displaymessage(fd, msg_txt(250));
+ return -1;
+ }
+
+ if (sd->state.storage_flag == 2) {
+ clif_displaymessage(fd, msg_txt(251));
+ return -1;
+ }
+
+ gstorage = guild2storage2(sd->status.guild_id);
+ if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
+ return -1;
+ }
+
+ j = gstorage->storage_amount;
+ gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
+ for (i = 0; i < j; ++i) {
+ guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
+ }
+ storage_guild_storageclose(sd);
+ gstorage->lock = 0; // Cleaning done, release lock
+
+ clif_displaymessage(fd, msg_txt(1395)); // Your guild storage was cleaned.
+ return 0;
+}
+
+ACMD_FUNC(clearcart)
+{
+ nullpo_retr(-1, sd);
+
+ if (pc_iscarton(sd) == 0) {
+ clif_displaymessage(fd, msg_txt(1396)); // You do not have a cart to be cleaned.
+ return -1;
+ }
+
+ if (sd->state.vending == 1) { //Somehow...
+ return -1;
+ }
+
+ clif_clearcart(fd);
+
+ clif_displaymessage(fd, msg_txt(1397)); // Your cart was cleaned.
+ return 0;
+}
+
/*==========================================
* @skillid by [MouseJstr]
* lookup a skill by name
@@ -8739,6 +8819,10 @@ void atcommand_basecommands(void) {
ACMD_DEF(item),
ACMD_DEF(item2),
ACMD_DEF(itemreset),
+ ACMD_DEF2("clearinventory", itemreset),
+ ACMD_DEF(clearstorage),
+ ACMD_DEF(cleargstorage),
+ ACMD_DEF(clearcart),
ACMD_DEF2("blvl", baselevelup),
ACMD_DEF2("jlvl", joblevelup),
ACMD_DEF(help),
diff --git a/src/map/storage.c b/src/map/storage.c
index c66f12852..eb7760a0f 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -405,6 +405,9 @@ int storage_guild_storageopen(struct map_session_data* sd)
}
if(gstor->storage_status)
return 1;
+
+ if( gstor->lock )
+ return 1;
gstor->storage_status = 1;
sd->state.storage_flag = 2;
@@ -522,6 +525,11 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
if( amount < 1 || amount > sd->status.inventory[index].amount )
return 0;
+
+ if( stor->lock ) {
+ storage_guild_storageclose(sd);
+ return 0;
+ }
if(guild_storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
pc_delitem(sd,index,amount,0,4,LOG_TYPE_GSTORAGE);
@@ -555,6 +563,11 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
if(amount < 1 || amount > stor->items[index].amount)
return 0;
+
+ if( stor->lock ) {
+ storage_guild_storageclose(sd);
+ return 0;
+ }
if((flag = pc_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)) == 0)
guild_storage_delitem(sd,stor,index,amount);
diff --git a/src/map/storage.h b/src/map/storage.h
index 5a38d865b..c08ec81cb 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -24,6 +24,7 @@ void do_reconnect_storage(void);
void storage_storage_quit(struct map_session_data *sd, int flag);
struct guild_storage* guild2storage(int guild_id);
+struct guild_storage *guild2storage2(int guild_id);
int guild_storage_delete(int guild_id);
int storage_guild_storageopen(struct map_session_data *sd);
int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount);