Skip to content

Commit

Permalink
feat: avoid updating /lib/core objects, resolves #11
Browse files Browse the repository at this point in the history
  • Loading branch information
neverbot committed May 1, 2024
1 parent 407f581 commit a4d4748
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 15 deletions.
4 changes: 3 additions & 1 deletion mudlib/lib/cmds/coder/discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ static int cmd(string str, object me, string verb)
}
else
{
write(str + "is not loaded.\n");
write(str + " is not loaded.\n");
}

continue;
}

Expand Down Expand Up @@ -85,6 +86,7 @@ void no_discard(string s)
if (this_player()->affirmative(s))
{
err = catch(discard_obj->dwep());

if (err)
write("Error in dwep():\n " + err + "\n");

Expand Down
13 changes: 11 additions & 2 deletions mudlib/lib/core/efuns/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,27 @@ static nomask int destruct(varargs object ob)
object env;
object * shadows;
int i;
string ob_name;

if (!ob)
ob = this_object();

stderr(" - destruct: <" + object_name(ob) + ">\n");
ob_name = object_name(ob);

stderr(" - destruct: <" + ob_name + ">\n");

// destruct all objects shadowing this object
shadows = ob->_query_shadows();

for (i = 0; i < sizeof(shadows); i++)
destruct(shadows[i]);

if ((strlen(ob_name) >= 10) && (ob_name[0..9] == "/lib/core/"))
{
stderr(" *** destruct: <" + ob_name + "> error, core objects refuse to be destroyed\n");
return 0;
}

// TODO destruct its inventory?

env = environment(ob);
Expand All @@ -208,7 +217,7 @@ static nomask int destruct(varargs object ob)
{
if (!env->_inv_remove(ob))
{
stderr(" *** destruct: <" + object_name(ob) + "> error, its environment refused to let it go\n");
stderr(" *** destruct: <" + ob_name + "> error, its environment refused to let it go\n");
return 0;
}

Expand Down
11 changes: 11 additions & 0 deletions mudlib/lib/core/heart_beats.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,14 @@ nomask int remove_hb_object(object ob)

// _hb_handle = call_out("perform_heart_beat", HEART_BEAT_PERIOD);
// }

// avoid discard or destructions
void dest_me()
{
error("This object does not allow you to destroy it.\n");
}

void dwep()
{
error("This object does not allow you to destroy it.\n");
}
11 changes: 11 additions & 0 deletions mudlib/lib/core/livings.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,14 @@ int _is_in_livings(object ob)

return FALSE;
}

// avoid discard or destructions
void dest_me()
{
error("This object does not allow you to destroy it.\n");
}

void dwep()
{
error("This object does not allow you to destroy it.\n");
}
11 changes: 11 additions & 0 deletions mudlib/lib/core/mudos.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,14 @@ mixed * _call_out_info()

return ret;
}

// avoid discard or destructions
void dest_me()
{
error("This object does not allow you to destroy it.\n");
}

void dwep()
{
error("This object does not allow you to destroy it.\n");
}
11 changes: 11 additions & 0 deletions mudlib/lib/core/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ void create()

::create();
}

// avoid discard or destructions
void dest_me()
{
error("This object does not allow you to destroy it.\n");
}

void dwep()
{
error("This object does not allow you to destroy it.\n");
}
11 changes: 11 additions & 0 deletions mudlib/lib/core/singletons.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ object set_table(string name, object ob)
{
_tables[name] = ob;
}

// avoid discard or destructions
void dest_me()
{
error("This object does not allow you to destroy it.\n");
}

void dwep()
{
error("This object does not allow you to destroy it.\n");
}
11 changes: 11 additions & 0 deletions mudlib/lib/core/users.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,14 @@ object new_connection()

return new_user;
}

// avoid discard or destructions
void dest_me()
{
error("This object does not allow you to destroy it.\n");
}

void dwep()
{
error("This object does not allow you to destroy it.\n");
}
12 changes: 0 additions & 12 deletions mudlib/lib/room/items/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,18 +309,6 @@ object query_parse_id(mixed *arr)
return this_object();
}

void dest_me()
{
destruct(this_object());
return ;
} /* dest_me() */

void dwep()
{
destruct(this_object());
return ;
} /* dwep() */

int move(mixed dest, varargs mixed messin, mixed messout) { return 1; }
// int move() { return 1; }

Expand Down
2 changes: 2 additions & 0 deletions mudlib/lib/user/roles/.lang.en.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define _LANG_CODER_OBJECT_NO_RSV "The void room has gone!\n"
#define _LANG_CODER_OBJECT_DO_NOT_UPDATE "You DIDN'T update that! " + \
"(interactive() objects cannot be updated).\n"
#define _LANG_CODER_OBJECT_DO_NOT_UPDATE_CORE "You DIDN'T update that! " + \
"(core objects cannot be updated).\n"
#define _LANG_CODER_OBJECT_NAME_BROKEN "Ups. Your "+itemname+" just broke.\n"
#define _LANG_CODER_OBJECT_BROKEN "Ups. Something you had just broke.\n"
#define _LANG_CODER_OBJECT_UPDATED "Updated: "
Expand Down
2 changes: 2 additions & 0 deletions mudlib/lib/user/roles/.lang.es.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define _LANG_CODER_OBJECT_NO_RSV "¡La habitación en el vacío ha desaparecido!\n"
#define _LANG_CODER_OBJECT_DO_NOT_UPDATE "¡Tu NO updateas eso! " + \
"(no se pueden updatear objetos interactive()).\n"
#define _LANG_CODER_OBJECT_DO_NOT_UPDATE_CORE "¡Tu NO updateas eso! " + \
"(no se pueden updatear objetos core.\n"
#define _LANG_CODER_OBJECT_NAME_BROKEN "Ups. Tu "+itemname+" acaba de romperse.\n"
#define _LANG_CODER_OBJECT_BROKEN "Ups. Algo que tenías acaba de romperse.\n"
#define _LANG_CODER_OBJECT_UPDATED "Actualizado: "
Expand Down
6 changes: 6 additions & 0 deletions mudlib/lib/user/roles/coder_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ private int _update_objects(object *ov)

filename = file_name(ov[i]);

if ((strlen(filename) >= 10) && (filename[0..9] == "/lib/core/"))
{
notify_fail(_LANG_CODER_OBJECT_DO_NOT_UPDATE_CORE);
return 0;
}

if (sscanf(filename, "%s#%d", filename, dummy) != 2) // a room? a handler? something not cloned
cloned = false;
else
Expand Down

0 comments on commit a4d4748

Please sign in to comment.