Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - brainfrz

Pages: [1]
1
Dead Souls Support / Extended Workroom
« on: January 23, 2009, 09:40:52 am »
What I am trying to do is make it possible to have multiple rooms in your workroom rather than just a single room. This could be so you'd have different rooms to work on different things, or maybe just have different rooms so you could just feel more at home. The problem is, I'm trying to make the privacy field extend throughout the entire "house". Also, as a sidefeature, I'm making the privacy field take users that are allowed and let them in even when the field is up. Both things share the same problem: I don't know all the connected rooms beforehand, and I need to reload all the connected rooms, as well as change some variables in them. Namely, `string *ban' and `string *trust' must be changed in each room, loaded or not. Here's what I have currently:
Code: ("workroom_base.c") [Select]
/*
 *  The idea behind this base_file is to allow for creators to have a larger
 *  workroom than just a single room. This "house" will still have a privacy
 *  field, and will also have a list of people who are "banned" from your house,
 *  and a list of those who
 */

#define ALLOW_FILE __DIR__".allow.list"
#define BAN_FILE   __DIR__".ban.list"

#include <rooms.h>

inherit LIB_ROOM;

int privacy = 0, sizeTrust, sizeBan;
string *trust, *ban, owner, desc = "";

void create_workroom() { }
void init_workroom()   { }
int DumpList();
int DumpAllowList();
int DumpBanList();
string SetPrivacy(int i);
string SetDesc(string str);
string GetDesc();

string DescPrivacy()
{
    if( privacy )
        return desc + "\n\
%^YELLOW%^The walls seem to be encased in a yellowish shield.%^RESET%^";
    return desc;
}
string SetDesc( string str )
{
    return desc = str;
}
string GetDesc()
{
    return desc;
}

static void create()
{
    trust = explode(read_file(ALLOW_FILE), "\n");
    ban   = explode(read_file(BAN_FILE), "\n");
    sizeTrust = sizeof(trust);
    owner = trust[0];
    room::create();
    SetShort("Within a House");
    SetClimate("indoors");
    SetAmbientLight(30);
    create_workroom();
    SetDesc(this_object()->GetDesc());
    SetLong((: DescPrivacy :));
}
void init()
{
    ::init();
    init_workroom();
    add_action("mod_privacy", ({ "privacy", "priv" }));
    add_action("eventAllow",  "allow");
    add_action("eventReject", "reject");
    add_action("eventBan",    "ban");
}

int CanReceive( object sneak )
{
    int ret;
    object *living_stack;
    if( member_array(capitalize(sneak->GetName()), ban) == -1 )
        return 0;
    if( !privacy )
        return ::CanReceive(sneak);
    living_stack = get_livings(sneak);
    if( !living_stack || !arrayp(living_stack) )
        living_stack = ({ sneak });
    foreach( object ob in living_stack )
    {
        if( !archp(ob) && member_array(ob->GetName(), trust) == -1 )
        {
            message("info", "You bounce off the privacy field.", ob);
            message("info", ob->GetName()+" bounced off the privacy field.",
                    this_object());
            if( !environment(ob) )
                ob->eventMoveLiving(ROOM_START);
            return 0;
        }
    }
    ret = ::CanReceive(sneak);
    if( ret )
        tell_room(this_object(), "\n\n%^BOLD%^%^RED%^PRIVACY WARNING: %^RESET%^%^RED%^"+identify(sneak)+
                "%^BOLD%^ has entered the room.%^RESET%^\n\n", sneak);
    return ret;
}

int set_privacy( int i )
{
    object *npcs = filter(deep_inventory(this_object()),
            (: living($1) && !interactive($1) :));
    privacy = i;
    SetProperty("no peer", i);
    if( sizeof(npcs) )
    {
        foreach( object npc in npcs )
        {
            tell_room(this_object(), "Ejecting "+identify(npc), npc);
            npc->eventMove(ROOM_FURNACE);
        }
    }
    SetLong((: DescPrivacy :));
    return privacy;
}

int mod_privacy( string str )
{
    int toggle;
    if( !archp(this_player()) &&
            this_player()->GetName() != owner )
    {
        write("You close your eyes, but nothing changes.");
        say(this_player()->GetName()+" is trying to muck around with the
privacy field system.");
        return 1;
    }
    if( lower_case(str) == "list" )
        return DumpList();
    if( !privacy )
    {
        write("You close your eyes, and the walls shimmer briefly.");
        say(this_player()->GetName()+" closes "+possessive(this_player())+
            " eyes, and the walls shimmer briefly.");
        foreach( object room in children(file_name()) )
        {
            message("env", "The walls shimmer briefly before stabalizing their "
                    "yellowish hue.", room);
            room->set_privacy(1);
        }
        return 1;
    }
    else
    {
        set_privacy(0);
        write("You close your eyes, and a gentle draft passes through the
room.");
        say(this_player()->GetName()+" closes "+possessive(this_player())+
            " eyes, and a gentle draft passes through the room.");
        return 1;
    }
}

int eventReject( string who )
{
    if( !who )
        return notify_fail("Who do you want to reject?");
    who = lower_case(who);
    if( who == "list" )
        return notify_fail("Use 'allow list' for that.\n");
    who = capitalize(who);
    if( member_array(who, trust) == -1 )
        return notify_fail(who+" is not on the list!");
    write_file(ALLOW_FILE, implode(trust-({ who }), "\n"), 1);
    write("You will no longer allow "+who+" through the privacy field.");
    return 1;
}
int eventAllow( string who )
{
    if( !who )
        return notify_fail("Who do you want to allow?");
    who = lower_case(who);
    if( who == "list" )
        return DumpAllowList();
    who = capitalize(who);
    if( member_array(who, trust) != -1 )
        return notify_fail(who+" is already on the list!");
    if( member_array(who, ban) != -1 )
    {
        write("You have unbanned "+who+", but not added "+objective(who)+
              " to the trusted list.");
        write_file(BAN_FILE, implode(ban-({ who }), "\n"), 1);
    }
    else
    {
        write("You now trust "+who+" and will let "+objective(who)+
              "through the privacy field.");
        write_file(ALLOW_FILE, "\n"+who);
    }
    return 1;
}
int eventBan( string who )
{
    if( !who )
        return notify_fail("Who do you want to ban?");
    who = lower_case(who);
    if( who == "list" )
        return DumpBanList();
    who = capitalize(who);
    if( member_array(who, ban) != -1 )
        return notify_fail(who+" is already banned!");
   
}

int DumpAllowList()
{
    int sizeTrust = sizeof(trust);
    string list;
    if( sizeTrust == 1 )    list = trust[0];
    if( sizeTrust == 2 )    list = trust[0]+" and "+trust[1];
    if( sizeTrust >= 3 )    list = implode(trust[0 .. <2], ", ")+", and "+trust[<1];
    write("Trusted players: "+list);
    return 1;
}
int DumpBanList()
{
    string list;
    if( !sizeBan )
    {
        write("No one is currently banned.");
        return 1;
    }
    if( sizeBan == 1 )  list = ban[0];
    if( sizeBan == 2 )  list = ban[0]+" and "+ban[1];
    if( sizeBan >= 3 )  list = implode(ban[0 .. <2], ", ")+", and "+ban[<1];
    write("Banned players: "+list);
    return 1;
}
int DumpList()
{
    DumpAllowList();
    DumpBanList();
    return 1;
}
How would I be able to load those objects that aren't loaded and then call it in each of the files.

2
Dead Souls Support / Parse Error in Hiding
« on: January 19, 2009, 01:59:42 pm »
For some strange reason, line 10 is coming up with a parse error. What I'm trying to do is make it so a set of rooms can inherit this one and have the privacy field code. Here's the file:
Code: [Select]
#define PRIV_FILE  __DIR__"allow.list"

#include <rooms.h>

inherit LIB_ROOM;

int privacy = 0;
string *trust = explode(read_file(PRIV_FILE), "\n");
for( int i = 0; i < sizeof(trust); i++ )
    trust[i] = lower_case(trust[i]);
string owner = trust[0];

void create_workroom() { }
void init_workroom()   { }
string SetPrivacy(int i);
string SetDesc(string str);
string GetDesc();

string DescPrivacy()
{
    if( privacy )
        return desc + "\n\
%^YELLOW%^The walls seem to be encased in a yellowish shield.%^RESET%^";
    return desc;
}
string SetDesc( string str )
{
    return desc = str;
}
string GetDesc()
{
    return desc;
}

static void create()
{
    room::create();
    create_workroom();
    SetDesc(this_object()->GetDesc())
    SetLong((: DescPrivacy :));
}
void init()
{
    ::init();
    init_workroom();
    add_action("mod_privacy", ({ "privacy", "priv" }));
    add_action("eventAllow",  "allow");
    add_action("eventReject", "reject");
}

int CanReceive( object sneak )
{
    int ret;
    object *living_stack;
    if( !privacy )
        return ::CanReceive(sneak);
    living_stack = get_livings(sneak);
    if( !living_stack || !arrayp(living_stack) )
        living_stack = ({ sneak });
    foreach( object ob in living_stack )
    {
        if( !archp(ob) && member_array(ob->GetKeyName(), trust) == -1 )
        {
            message("info", "You bounce off the privacy field.", ob);
            message("info", ob->GetName()+" bounced off the privacy field.",
                    this_object());
            if( !environment(ob) )
                ob->eventMoveLiving(ROOM_START);
            return 0;
        }
    }
    ret = ::CanReceive(sneak);
    if( ret )
        tell_room(this_object(), "\n\nPRIVACY WARNING: "+identify(sneak)+
                " has entered the room.\n\n", sneak);
    return ret;
}

int set_privacy( int i )
{
    object *npcs = filter(deep_inventory(this_object()),
            (: living($1) && !interactive($1) :));
    privacy = i;
    SetProperty("no peer", i);
    if( sizeof(npcs) )
    {
        foreach( object npc in npcs )
        {
            tell_room(this_object(), "Ejecting "+identify(npc), npc);
            npc->eventMove(ROOM_FURNACE);
        }
    }
    SetLong((: DescPrivacy :));
    return privacy;
}

int mod_privacy( string str )
{
    if( !archp(this_player()) &&
            this_player()->GetKeyName() != lower_case(owner) )
    {
        write("You close your eyes, but nothing changes.");
        say(this_player()->GetName()+" is trying to muck around with the privacy field system.");
        return 1;
    }
    if( !str || (str != "off" && str != "on") )
    {
        if( privacy )
            str = "off";
        else
            str = "on";
    }
    if( str == "on" )
    {
        set_privacy(1);
        write("You close your eyes, and the walls shimmer briefly.");
        say(this_player()->GetName()+" closes "+possessive(this_player())+
            " eyes, and the walls shimmer briefly.");
        return 1;
    }
    if( str == "off" )
    {
        set_privacy(0);
        write("You close your eyes, and a gentle draft passes through the room.");
        say(this_player()->GetName()+" closes "+possessive(this_player())+
            " eyes, and a gentle draft passes through the room.");
        return 1;
    }
}

3
General / Casts in LPC
« on: January 12, 2009, 12:44:33 pm »
I've seen a lot of casts in the stock DS libcode. I realize that in C, casts are often necessary. However, in LPC, aren't casts ignored? I was wondering if they are necessary and if they even do anything. In my experience,
Code: [Select]
int foo()
{
    return (int)"1";
}
will return an error even though it is casted, because the cast gets skipped over.
Thanks for the help.

4
Dead Souls Support / Fatal error in 'make' with ds2.9a13
« on: January 11, 2009, 09:54:51 pm »
I was trying to install DS2 after switching from TMI-2. I used the zipped download from the downloads page of LPMuds.net. Anyway, when I tried to 'make' after building FluffOS, it hit an almost-fatal error and limped to its death the rest of the way. Here's a log. It's long, but if anyone has any ideas, please help.  ;D

Code: (log.txt) [Select]
Script started on Sun 11 Jan 2009 10:42:11 PM EST
]0;brainfrz@linux: ~/ds2/driverbrainfrz@linux:~/ds2/driver$ ./build.FluffOS
Preparing to build standard MudOS driver ...
Trying out some stuff to see what works; ignore errors ...
./build.FluffOS: 176: gmake: not found
make: Nothing to be done for `nothing'.
Using standard a.out for compiler default executable
./build.FluffOS: 199: xlc: not found
CC: gcc
mkdir: cannot create directory `tmp': File exists
install: invalid option -- f
Try `install --help' for more information.
rm: cannot remove `tmp/insttest': No such file or directory
comptest.y:4 parser name defined to default :"parse"
mkdir: cannot create directory `obj': File exists
***************** Configuration completed **************
Installing MudOS on Linux

Using install -c to install binaries in ../bin.
Using gcc -E  for preprocessing.
Using gcc -D__USE_FIXED_PROTOTYPES__            -O2 to compile.
Using bison -d -y  to make the compiler.
Edit GNUmakefile if this is not what you want

Otherwise, type 'make' to build MudOS, then 'make install'.
]0;brainfrz@linux: ~/ds2/driverbrainfrz@linux:~/ds2/driver$ make
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "gcc"' >> cc.h
echo '#define OPTIMIZE "-O2"' >> cc.h
echo '#define CFLAGS   "-D__USE_FIXED_PROTOTYPES__ -O2"' >> cc.h
echo '#define OBJDIR   "obj"' >> cc.h
gcc -D__USE_FIXED_PROTOTYPES__ -o obj/edit_source.o -c edit_source.c
bison -d -y  make_func.y
make_func.y:62 parser name defined to default :"parse"
rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
gcc -D__USE_FIXED_PROTOTYPES__ -o obj/make_func.tab.o -c make_func.tab.c
gcc -D__USE_FIXED_PROTOTYPES__ obj/edit_source.o obj/hash.o obj/make_func.tab.o -o edit_source
if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
    rm -f configuration; \
    touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
    echo "Skipping configuration ..."; \
else \
    ./edit_source -configure; \
    echo "Machine `uname -a` Configure version 5" > configuration; \
fi
Skipping configuration ...
./edit_source -options -malloc -build_func_spec 'gcc -E -D__USE_FIXED_PROTOTYPES__' \
              -process grammar.y.pre
No "local_options" file present.  If you create one from "options.h",
you can use it when you get a new driver, and you will be warned if there are
changes to the real options.h which you should include in your local file.
Writing build options to option_defs.c ...
Using memory allocation package: sysmalloc.c
Building compiler files ...
Creating 'grammar.y' from 'grammar.y.pre' ...

./edit_source -process packages/Makefile.pre
Creating 'packages/Makefile' from 'packages/Makefile.pre' ...

./edit_source -process packages/GNUmakefile.pre
Creating 'packages/GNUmakefile' from 'packages/GNUmakefile.pre' ...

./edit_source -build_efuns -build_applies
Building efun tables ...

touch mallocwrapper.c
touch malloc.c
touch files
make main_build2
make[1]: Entering directory `/home/brainfrz/ds2/driver'
bison -d -y grammar.y
grammar.y:144 parser name defined to default :"parse"
rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c  > grammar.tab.c
mv y.tab.h grammar.tab.h
gcc -D__USE_FIXED_PROTOTYPES__ -O2 -o obj/grammar.tab.o -c grammar.tab.c
gcc -D__USE_FIXED_PROTOTYPES__ -O2 -o obj/lex.o -c lex.c
lex.c: In function ‘add_predefines’:
lex.c:2195: warning: left shift count >= width of type
gcc -D__USE_FIXED_PROTOTYPES__ -O2 -o obj/malloc.o -c malloc.c
gcc -D__USE_FIXED_PROTOTYPES__ -O2 -o obj/mallocwrapper.o -c mallocwrapper.c
gcc -D__USE_FIXED_PROTOTYPES__ -O2 -o obj/applies_table.o -c applies_table.c
mv -f driver driver.old
gcc -D__USE_FIXED_PROTOTYPES__ -O2 obj/grammar.tab.o obj/lex.o obj/main.o obj/rc.o obj/interpret.o obj/simulate.o obj/file.o obj/object.o obj/backend.o obj/array.o obj/mapping.o obj/comm.o obj/ed.o obj/regexp.o obj/buffer.o obj/crc32.o obj/malloc.o obj/mallocwrapper.o obj/class.o obj/efuns_main.o obj/efuns_port.o obj/call_out.o obj/otable.o obj/dumpstat.o obj/stralloc.o obj/hash.o obj/port.o obj/reclaim.o obj/parse.o obj/simul_efun.o obj/sprintf.o obj/program.o obj/compiler.o obj/avltree.o obj/icode.o obj/trees.o obj/generate.o obj/scratchpad.o obj/socket_efuns.o obj/socket_ctrl.o obj/qsort.o obj/eoperators.o obj/socket_err.o obj/md.o obj/disassembler.o obj/uvalarm.o obj/replace_program.o obj/master.o obj/function.o obj/debug.o obj/crypt.o obj/applies_table.o obj/add_action.o obj/eval.o obj/fliconv.o obj/console.o -o driver packages/packages.a  `cat system_libs`
if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
    rm -f configuration; \
    touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
    echo "Skipping configuration ..."; \
else \
    ./edit_source -configure; \
    echo "Machine `uname -a` Configure version 5" > configuration; \
fi
Skipping configuration ...
gcc -D__USE_FIXED_PROTOTYPES__ -O2 obj/socket_ctrl.o obj/addr_server.o obj/port.o \
-o addr_server `cat system_libs`
make[1]: Leaving directory `/home/brainfrz/ds2/driver'
]0;brainfrz@linux: ~/ds2/driverbrainfrz@linux:~/ds2/driver$ make install
if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
    rm -f configuration; \
    touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
    echo "Skipping configuration ..."; \
else \
    ./edit_source -configure; \
    echo "Machine `uname -a` Configure version 5" > configuration; \
fi
Skipping configuration ...
make main_build2
make[1]: Entering directory `/home/brainfrz/ds2/driver'
if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
    rm -f configuration; \
    touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
    echo "Skipping configuration ..."; \
else \
    ./edit_source -configure; \
    echo "Machine `uname -a` Configure version 5" > configuration; \
fi
Skipping configuration ...
make[1]: Leaving directory `/home/brainfrz/ds2/driver'
mkdir ../bin
mkdir: cannot create directory `../bin': File exists
make: [install] Error 1 (ignored)
install -c driver ../bin
install -c addr_server ../bin
install -c portbind ../bin
]0;brainfrz@linux: ~/ds2/driverbrainfrz@linux:~/ds2/driver$ exit
exit

Script done on Sun 11 Jan 2009 10:42:52 PM EST

5
Code Vault / Command/Object Completion
« on: December 10, 2008, 12:28:02 pm »
I wrote some code to complete commands and objects. (The one is just a command to test command completion.) I was wondering if there is a better way of doing this?

Code: (This is a command to test command completion.) [Select]
/*
 * This is just a useless command to test out command completion. Type an
 * incomplete command, and it will return the completed command as a
 * string.
 */
#include <daemons.h>
inherit DAEMON;

int cmd_ccomplete(string str) {
    string *path, *list = ({ });
    if(!str)
        return notify_fail("Syntax: ccomplete <command>\n");
    str = lower_case(str);

    // Adapted from /cmd/wiz/_pathcmd.c
    path = explode(TP->query("PATH"), ":");
    for(int dir=0;dir<sizeof(path);dir++)
        list += CMD_D->list_cmds(path[dir]);

    // Sort in ascending order and figure out which command you're
    // looking for.
    foreach(string cmd in list = sort_array(list, 1))
        if(cmd[0..strlen(str)-1] == str) {
            printf("%s expands to %s.\n", CAP(str), cmd);
            return 1;
        }

    // if(dir == sizeof(path))
    printf("No such command.\n");
    return 1;
}

Code: (This is a function to complete objects.) [Select]
// '08Dec10, Air@StarWars: New Identities
varargs object cpresent(string str, object env) {
    string *objs = ({ });
    object obj;

    if(!env)
        env = TO;

    foreach(object ob in all_inventory(env))
        objs += ob->query("id");

    foreach(string ob in objs = sort_array(objs, 1))
        if(ob[0..strlen(str)-1] == str) {
            obj = present(ob, env);
            break;
        }

    return obj;
}
Thanks for the help,
BrainFRZ

6
TMI Tête - à - Tête / Lfuns
« on: December 10, 2008, 09:12:49 am »
I was wondering where to find lfuns. I know that they're located in the shell, but are they all stuffed in a binary and inaccessible? I'm just trying to figure out if it's best to just cover stuff over with a sefun, or to try to find the lfun and edit it directly.
Thanks for the help,
BrainFRZ

7
TMI Tête - à - Tête / Strange SegFault
« on: November 28, 2008, 03:18:14 pm »
I'm getting a rather strange segmentation fault when I try to do step 9 in the INSTALL file, but I don't see any tracebacks anywhere that would explain why. Everything seems to have worked correctly in compilation, and it all seems to be installed, except for what I've logged below. Would anyone be able to tell me where I can find the tracebacks so I can figure out what's wrong? I looked in the various log dirs, and none seemed relevant.

Code: (Here's what's happening in the shell.) [Select]
~/tmi2/bin$ ls
addr_server  config.tmi2  driver

~/tmi2/bin$ ./driver config.tmi2&
[3] 1800
~/tmi2/bin$ using config file: config.tmi2
Initializing internal tables....
At this point, it seems to lock up, so I hit ^C.
Code: (I then get this:) [Select]
[3]   Segmentation fault      ./driver config.tmi2

Any help would be greatly appreciated, as I've never seen this error before.

Pages: [1]