Skip to content

Commit

Permalink
Half of the work for making add_object_command work like
Browse files Browse the repository at this point in the history
add_room_command

Kent
  • Loading branch information
Kent Mein committed Apr 26, 2012
1 parent b6ef602 commit 57e000d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 2 additions & 0 deletions lib/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ why /daemons, /kernel/daemons, /sys/daemons
/sys/lib, /kernel/lib
/daemons/data /data /kernel/daemons/data /sys/data /sys/daemons/data

Still need to modify add_item_command so that it uses function names from
add_object_command...
4 changes: 1 addition & 3 deletions lib/domains/boothill/obj/bandana.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ void setup(void) {
set_wear_message("$N $vput $o on.");
set_remove_message("$N $vtake off $o.");

// XXX why does this command only take one arg while room_command takes 2?
// also, it should error if you try to add an undefined function....
add_object_command("shake");
add_object_command("shake","do_shake");
// XXX Need to add call to check_label....
}

Expand Down
33 changes: 20 additions & 13 deletions lib/std/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static string *ids;
static string *adjs;
static int object_size;
string proper_name;
static string *object_commands;
static mapping object_commands;
static string detailed_desc;
private int configured;
static int eatable;
Expand Down Expand Up @@ -277,16 +277,29 @@ nomask mapping query_verb_rules() {
return PARSE_D->query_objects_rules(this_object());
}

void add_object_command(string command) {
if (!object_commands)
object_commands = ( { } );
object_commands += ( { command } );
void add_object_command(string command, string function) {
if (!object_commands[command])
object_commands += ([command:function]);
else
object_commands[command] = function;
}

void remove_object_command(string command) {
object_commands[command] = nil;
}

string query_object_command(string command) {
return object_commands[command];
}

string *query_object_commands(void) {
string *keys;

if (!object_commands)
object_commands = ( { } );
object_commands -= ( { command } );
object_commands = ([ ]);
keys = map_indices(object_commands);

return keys;
}

void set_eatable(int value) {
Expand All @@ -297,12 +310,6 @@ int is_eatable() {
return eatable;
}

string *query_object_commands(void) {
if (!object_commands)
object_commands = ( { } );
return object_commands;
}

void set_detailed_desc(string desc) {
detailed_desc = desc;
}
Expand Down

0 comments on commit 57e000d

Please sign in to comment.