Fixed it so division quotas are checked properley when an object is added to
authornveid <nveid@comcast.net>
Sat, 7 Oct 2006 17:59:16 +0000 (17:59 +0000)
committerAri Johnson <ari@nveid.com>
Tue, 12 Sep 2006 12:49:49 +0000 (12:49 +0000)
another divisions quota.
(cherry picked from commit 922facfe9d632b60dd3789b7f29c807863c2888e)

game/txt/changes/0.72p2
hdrs/externs.h
src/division.c
src/predicat.c

index d816af598f1a0c9699fa6a4b1c65a33ff70d71f9..6ba309570195d9957df749db3209df349779f2de 100644 (file)
@@ -16,4 +16,6 @@ CobraMUSH Version 0.72p2
       conversion.  Rewrote supported missing code needed. [RLB]
     * @div/create didn't abide by quotas.  Added can_pay_fees()
       check to div creatin and added new configuration option
-      division_cost.
+      division_cost. [RLB]
+    * Quotas were not being checked properely before a division
+      received objects into their division. [RLB]
index b5928ba2e605c573637abf59b694b77e87a51813..e44a0b449ad30eb78087f7555accfe195a44ba0d 100644 (file)
@@ -319,7 +319,7 @@ void add_player(dbref player, const char *alias);
 void delete_player(dbref player, const char *alias);
 
 /* From predicat.c */
-
+extern int pay_quota(dbref, int);
 extern char *WIN32_CDECL tprintf(const char *fmt, ...)
   __attribute__ ((__format__(__printf__, 1, 2)));
 
index baddd953685be37eb8f1cd7630d0f0ad30513ff7..f99c40967460a1fadb83cf44a7f1628b4f13acf0 100644 (file)
@@ -1462,7 +1462,7 @@ division_set(dbref exec, dbref target, const char *arg2)
   ATTR *divrcd;
   char *p_buf[BUFFER_LEN / 2];
   char buf[BUFFER_LEN], *bp;
-  dbref divi;
+  dbref cur_obj, divi;
   struct power_group_list *pg_l;
   int cnt;
 
@@ -1480,6 +1480,8 @@ division_set(dbref exec, dbref target, const char *arg2)
     return;
   }
 
+  
+
   if (!strcasecmp(arg2, "NONE")) {
     notify(exec, T("Division reset."));
     notify(target, T("GAME: Division reset."));
@@ -1516,6 +1518,23 @@ division_set(dbref exec, dbref target, const char *arg2)
     return;
   }
 
+  /* Make sure the receiving division has the quota to receive all of this crapp...
+   */
+
+  if(Typeof(target) == TYPE_PLAYER) {
+    for(cnt = cur_obj = 0; cur_obj < db_top ; cur_obj++)
+      if(Owner(cur_obj) == target && Division(cur_obj) == Division(target))
+        cnt++;
+  } else cnt = 1;
+
+  if(!pay_quota(divi, cnt)) {
+    notify(exec, T("That division does not have the quota required to receive that."));
+    return;
+  }
+  
+  if(Division(target))
+    change_quota(Division(target), cnt);
+
   if (Typeof(target) == TYPE_PLAYER)
     adjust_divisions(target, Division(target), divi);
   else
index b86f7e08b9ef05b0203b870066d261b307cc7324..7d749eddc385bb24843928bda40d8364a71c048e 100644 (file)
@@ -46,7 +46,7 @@ static int grep_util_helper(dbref player, dbref thing, dbref parent,
 static int grep_helper(dbref player, dbref thing, dbref parent,
                       char const *pattern, ATTR *atr, void *args);
 void do_grep(dbref player, char *obj, char *lookfor, int flag, int insensitive);
-static int pay_quota(dbref, int);
+int pay_quota(dbref, int);
 extern PRIV attr_privs[];
 
 /** A generic function to generate a formatted string. The
@@ -673,7 +673,7 @@ change_quota(dbref who, int payment)
  * \retval 1 quota successfully debitted.
  * \retval 0 not enough quota to debit.
  */
-static int
+int
 pay_quota(dbref who, int cost)
 {
   int curr;