merentha_fluffos_v2/
merentha_fluffos_v2/bin/
merentha_fluffos_v2/fluffos-2.9-ds2.03/
merentha_fluffos_v2/fluffos-2.9-ds2.03/ChangeLog.old/
merentha_fluffos_v2/fluffos-2.9-ds2.03/Win32/
merentha_fluffos_v2/fluffos-2.9-ds2.03/compat/
merentha_fluffos_v2/fluffos-2.9-ds2.03/compat/simuls/
merentha_fluffos_v2/fluffos-2.9-ds2.03/include/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/clone/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/command/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/data/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/etc/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/include/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/inherit/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/inherit/master/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/log/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/tests/compiler/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/tests/efuns/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/tests/operators/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/u/
merentha_fluffos_v2/fluffos-2.9-ds2.03/tmp/
merentha_fluffos_v2/fluffos-2.9-ds2.03/windows/
merentha_fluffos_v2/lib/cfg/
merentha_fluffos_v2/lib/cfg/races/
merentha_fluffos_v2/lib/cmds/abilities/
merentha_fluffos_v2/lib/cmds/actions/
merentha_fluffos_v2/lib/cmds/spells/
merentha_fluffos_v2/lib/daemon/include/
merentha_fluffos_v2/lib/daemon/services/
merentha_fluffos_v2/lib/doc/
merentha_fluffos_v2/lib/doc/building/
merentha_fluffos_v2/lib/doc/help/classes/
merentha_fluffos_v2/lib/doc/help/general/
merentha_fluffos_v2/lib/doc/help/races/
merentha_fluffos_v2/lib/doc/help/skills/
merentha_fluffos_v2/lib/doc/help/stats/
merentha_fluffos_v2/lib/doc/man/efuns/
merentha_fluffos_v2/lib/doc/man/lfuns/
merentha_fluffos_v2/lib/doc/news/
merentha_fluffos_v2/lib/doc/old/
merentha_fluffos_v2/lib/doc/old/concepts/
merentha_fluffos_v2/lib/doc/old/lpc/constructs/
merentha_fluffos_v2/lib/doc/old/lpc/types/
merentha_fluffos_v2/lib/domains/ROOMS/
merentha_fluffos_v2/lib/domains/obj/armour/
merentha_fluffos_v2/lib/domains/obj/monsters/
merentha_fluffos_v2/lib/domains/obj/other/
merentha_fluffos_v2/lib/domains/obj/weapons/
merentha_fluffos_v2/lib/realms/petrarch/
merentha_fluffos_v2/lib/save/daemons/
merentha_fluffos_v2/lib/save/rid/
merentha_fluffos_v2/lib/save/users/a/
merentha_fluffos_v2/lib/save/users/p/
merentha_fluffos_v2/lib/save/users/t/
merentha_fluffos_v2/lib/std/login/
merentha_fluffos_v2/lib/std/obj/
merentha_fluffos_v2/win32/
// Petrarch
// Merentha Lib 1.0
// container.c

#include <std.h>
#include "container.h"

inherit OBJECT;

int __MaxCarryItems, __MaxCarryWeight;

void create() {
  ::create();
  __MaxCarryItems=0;
  __MaxCarryWeight=0;
}

void set_max_mass (int i) { __MaxCarryWeight=i; }
int query_max_mass () { return __MaxCarryWeight; }

void set_max_items (int i) { __MaxCarryItems=i; }
int query_max_items () { return __MaxCarryItems; }

int query_holding_mass() {
 object *inv;
 int j,i;
 i=sizeof(inv=all_inventory(this_object()));
 while(i--) j+=inv[i]->query_mass();
  return j;
}

string receive_object(object ob) {
  if(!ob) return 0;
  if(living(ob) && living(this_object())) return "You can not carry a living being.";
  if(__MaxCarryWeight && __MaxCarryWeight<query_holding_mass()+ob->query_mass())
    return (this_player()==this_object()?"You":query_cap_name(this_object()))+" can not hold the weight of "+ob->query_short()+".";
  if(__MaxCarryItems && __MaxCarryItems<=sizeof(all_inventory(this_object())))
    return (this_player()==this_object()?"You":query_cap_name(this_object()))+" can not hold any more items.";
  return 0;
}
    
string get_living_contents() {
string tmp="", tmp2, *k;
mapping shorts=([]);
object *obs=all_inventory(this_object());
int i;
if(this_player()) obs-=({this_player()});
i=sizeof(obs);
while (i--)
  if(living(obs[i])) {
    tmp2=(obs[i]->query_short()?obs[i]->query_short():obs[i]->query_name());
    if(!shorts[tmp2]) shorts[tmp2]=1;
    else shorts[tmp2]=shorts[tmp2]+1;
  }
i=sizeof(k=keys(shorts));
if(!i) return "";
while(i--)
  tmp+=capitalize(consolidate(shorts[k[i]], k[i])+"\n");
return tmp;
}

string get_nonliving_contents() {
string tmp="", tmp2, *k;
mapping shorts=([]);
object *obs=all_inventory(this_object());
int i, j, x;
if(this_player()) obs-=({this_player()});
i=sizeof(obs);
while (i--)
  if(!living(obs[i])) {
    tmp2=(obs[i]->query_short()?obs[i]->query_short():obs[i]->query_name());
    if(!shorts[tmp2]) shorts[tmp2]=1;
    else shorts[tmp2]=shorts[tmp2]+1;
    x++;
  }
i=sizeof(k=keys(shorts));
if(!i) return "";
j=i;
while(i--) {
  tmp+=consolidate(shorts[k[i]], k[i]);
  if(j>1) {
    if(i>1) tmp+=", ";
    if(i==1) tmp+=" and ";
  }
}
if(j>1 || x >1) tmp+=" are here.\n";
if(j==1 && x <=1) tmp+=" is here.\n";
return capitalize(tmp);
}

int is_container() { return 1; }