#include #include "db.h" #include "externs.h" #include "property.h" /* * Return true iff player has at least ndbrefs of building quota room. * * If silent is false and the check fails, a notify() call is done to * tell the player what's wrong; if the check succeeds, or if silent * is true, no message is generated. */ int quota_room(dbref player, int ndbrefs, int silent) { struct propref *pr; char *pval; int q; if (TrueWizard(player)) return(1); pval = 0; pr = lookup_property(player,"@building-quota",0); if (pr) { if ((propref_get_attr(pr) & PATTR_TYPE) == PTYPE_STRING) { pval = propref_get_string(pr); } propref_done(pr); } if (pval == 0) return(1); q = atoi(pval); free(pval); if (DBFETCH(player)->sp.player.dbrefs_owned+ndbrefs <= q) return(1); if (! silent) { pr = lookup_property(GLOBAL_ENVIRONMENT,"@noquota-msg-1",0); if (! pr) { notify(player,"Insufficient building quota."); } else { char qprop[64]; int n; n = 1; while (pr) { if ((propref_get_attr(pr) & PATTR_TYPE) != PTYPE_STRING) break; pval = propref_get_string(pr); propref_done(pr); notify(player,pval?pval:" "); free(pval); n ++; sprintf(&qprop[0],"@noquota-msg-%d",n); pr = lookup_property(GLOBAL_ENVIRONMENT,&qprop[0],0); } if (pr) propref_done(pr); } } return(0); }