From 0fd8d8c8b8d9d1e422537369d2ea1ab677fa0a5b Mon Sep 17 00:00:00 2001
From: Dennis Friis <peavey@inspircd.org>
Date: Mon, 22 Jun 2009 02:10:17 +0200
Subject: Fixes for @storage / @gstorage ATcommands. Derived from ea stable.

---
 src/map/atcommand.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

(limited to 'src/map')

diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 85ff15c..2283961 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1453,6 +1453,19 @@ int atcommand_storage(
 	const int fd, struct map_session_data* sd,
 	const char* command, const char* message)
 {
+	struct storage *stor; //changes from Freya/Yor
+	nullpo_retr(-1, sd);
+
+	if (sd->state.storage_flag == 1) {
+		clif_displaymessage(fd, "You have opened your guild storage. Close it before.");
+		return -1;
+	}
+
+	if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
+		clif_displaymessage(fd, "You have already opened your storage.");
+		return -1;
+	}
+
 	storage_storageopen(sd);
 
 	return 0;
@@ -1466,8 +1479,23 @@ int atcommand_guildstorage(
 	const int fd, struct map_session_data* sd,
 	const char* command, const char* message)
 {
-	if (sd->status.guild_id > 0)
+	struct storage *stor; //changes from Freya/Yor
+	nullpo_retr(-1, sd);
+
+	if (sd->status.guild_id > 0) {
+		if (sd->state.storage_flag == 1) {
+			clif_displaymessage(fd, "You have already opened your guild storage.");
+			return -1;
+		}
+		if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
+			clif_displaymessage(fd, "Your storage is opened. Close it before.");
+			return -1;
+		}
 		storage_guild_storageopen(sd);
+	} else {
+		clif_displaymessage(fd, "You are not in a guild.");
+		 return -1;
+	}
 
 	return 0;
 }
-- 
cgit v1.2.3-70-g09d2