From: nveid Date: Sat, 7 Oct 2006 17:59:16 +0000 (+0000) Subject: Fixed it so division quotas are checked properley when an object is added to X-Git-Tag: 0.72p2~15 X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=83f0290286692ba651882a1fce3a45f45c7a0057;p=cobramush.git Fixed it so division quotas are checked properley when an object is added to another divisions quota. (cherry picked from commit 922facfe9d632b60dd3789b7f29c807863c2888e) --- diff --git a/game/txt/changes/0.72p2 b/game/txt/changes/0.72p2 index d816af5..6ba3095 100644 --- a/game/txt/changes/0.72p2 +++ b/game/txt/changes/0.72p2 @@ -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] diff --git a/hdrs/externs.h b/hdrs/externs.h index b5928ba..e44a0b4 100644 --- a/hdrs/externs.h +++ b/hdrs/externs.h @@ -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))); diff --git a/src/division.c b/src/division.c index baddd95..f99c409 100644 --- a/src/division.c +++ b/src/division.c @@ -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 diff --git a/src/predicat.c b/src/predicat.c index b86f7e0..7d749ed 100644 --- a/src/predicat.c +++ b/src/predicat.c @@ -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;