Error with funcall and symbol_function

11 views
Skip to first unread message

Malcolm Tester

unread,
Jan 4, 2021, 5:27:50 PM1/4/21
to LDMud Talk
I have a problem with my master.c since we upgraded to 3.3.720.  I did a semi-workaround which doesn't really work, but it wasn't a big deal because it was rarely used code.  But I figure I should get it fixed, because it has me scratching my head why it doesn't work (in either code I use).

The code is for the creating a castle when a player wizzes.  This is in master.c  (simul_efun of create_wizard() which calls this in master):

string master_create_wizard(string owner, string domain, object caller)
{
  string castle, workroom, castle_dest;
  object player;

  //player = funcall(#'find_player, owner);
  player = funcall(symbol_function('find_player, owner));
  if(!player)
    return 0;
......

The commented out line worked in previous versions of the driver.  In this version, on a clean boot up, the master.c fails to load with Undefined function: find_player.  However, if I uncomment that line while the mud is up and running, and 'update master.c', it works fine...until the next boot.

The replacement line for that commented line compiles fine at boot.  But it doesn't actually work, at all.  When called, it errors with "Failed to load file: 'somewannabewizname'." (player who initiated it).

Ideally, I want the commented out line to work, as that's the simplest way.  But I'm curious why the second doesn't work either (I assume it's my lack of understanding in writing it).

Thoughts?
Malc@Infinity/Alatia

Gnomi

unread,
Jan 4, 2021, 5:47:17 PM1/4/21
to ldmud...@googlegroups.com
Hi Malcom,

Malcolm Tester wrote:
> *//player = funcall(#'find_player, owner);*

This doesn't work at MUD startup, because find_player() is likely a
simul-efun and the simul-efun is loaded after the master. So at the time the
master is loaded, there is no simul-efun or normal function with that name,
so the master fails to load.

Later on when the simul-efun is loaded, this does work. But I will
deactivate that also in future versions. The master is currently not allowed
to call simul-efuns directly (neither at boot nor any later time), it is
only logical to forbid closures to simul-efuns also, to prevent such
mistakes (as they show only when the MUD is restarted).

> * player = funcall(symbol_function('find_player, owner));*

Here is a simple error with the parentheses, it should read
player = funcall(symbol_function('find_player), owner);

symbol_function() needs to be called only with the name of the sefun,
the owner should then be the parameter to the funcall().

Regards,
Gnomi.

Malcolm Tester

unread,
Jan 4, 2021, 6:53:11 PM1/4/21
to LDMud Talk
That makes sense on the find_player() not being found.  I assumed it was something along those lines, but it worked in previous versions, so I wasn't positive.  And thanks for the note about future versions disabling calls to SE altogether.  I'll make a note to go through and convert.

Re: parenthesis error.  smack my head... doh!  Thanks for catching it so quickly.

Thanks!
Malc @Infinity/Alatia

Reply all
Reply to author
Forward
0 new messages