Author Topic: MudOS and FluffOS: member_array and 'class' type  (Read 5545 times)

Offline Nulvect

  • BFF
  • ***
  • Posts: 127
    • View Profile
MudOS and FluffOS: member_array and 'class' type
« on: October 18, 2008, 12:36:25 pm »
MudOS v22.2b14.

I've defined a class in a header file like so:
Code: [Select]
class Effect {
  // members, not important
}

In a lib file, I created an array of this type and want to see if a certain class variable is in the array:
Code: [Select]
class Effect *AllEffects;
...
  if (member_array(thiseffect, AllEffects) != -1)
  ...

That member_array always returns -1. I had to write a loop to compare it; == works fine.


Upon inspection of the member_array definition in efuns_main.c, it does not handle the class type _at all_. I also checked fluffos 2.13 and it does not handle classes either. This is just FYI for anyone else who may encounter this problem, as well as a possible feature req/bug report for FluffOS.

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #1 on: October 18, 2008, 12:48:06 pm »
Class != array. they're designed to use when you know what's where, with if(class->slot_name == something) syntax.
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline Nulvect

  • BFF
  • ***
  • Posts: 127
    • View Profile
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #2 on: October 18, 2008, 01:37:01 pm »
Yes, that is what a class is used for. I needed an array of them. Each element is a collection of data describing a specific effect. There can be many effects happening at once, or just one, or zero; thus, the array.

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #3 on: October 18, 2008, 02:40:44 pm »
Have you perchance tried member() as opposed to member_array()?  (Isn't member_array() deprecated anyway?)

Offline Nulvect

  • BFF
  • ***
  • Posts: 127
    • View Profile
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #4 on: October 18, 2008, 03:08:33 pm »
There is no member() efun on my driver, nor a member() sefun in my lib. We use member_array() all the time...

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #5 on: October 18, 2008, 04:20:39 pm »
Wow.  Weird.

If I want to find out if a key is defined in a mapping, I do:

Code: [Select]
if(member(map, key))
How do you do that?

Offline Nulvect

  • BFF
  • ***
  • Posts: 127
    • View Profile
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #6 on: October 18, 2008, 05:15:46 pm »
Well, you can either do:

Code: [Select]
if (member_array(item, keys(map)) != -1)

or:

Code: [Select]
if (!nullp(map[item]))

or, if you're sure there won't be values of 0 in your mapping:

Code: [Select]
if (map[item])

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #7 on: October 18, 2008, 05:33:19 pm »
Bizarre.  MudOS sure seems different from when I was doing work toward porting to it.  I could've sworn member() was there, then.  And that there was a push to change 'mapping' to 'map' (and the associated functions to map_delete(), mapp(), etc.), which, according to someone editing Wikipedia's LPC article, has been wiped out as if it never happened.

Offline wodan

  • BFF
  • ***
  • Posts: 434
  • Drink and code, you know you want to!
    • View Profile
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #8 on: October 18, 2008, 05:52:54 pm »
MudOS v22.2b14.
Upon inspection of the member_array definition in efuns_main.c, it does not handle the class type _at all_. I also checked fluffos 2.13 and it does not handle classes either. This is just FYI for anyone else who may encounter this problem, as well as a possible feature req/bug report for FluffOS.

ok, changed that in FluffOS cvs, so it should work in 2.14 whenever that may get released.

PS never heard of member() are you sure that was MudOS?

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #9 on: October 18, 2008, 06:29:33 pm »
PS never heard of member() are you sure that was MudOS

Guess it must not have been.  It was probably 1995 or so when I was doing that port work, so I suppose a detail or two may have become fuzzy.

Offline Tricky

  • BFF
  • ***
  • Posts: 189
  • I like what I code and I code what I like!
    • View Profile
Re: MudOS and FluffOS: member_array and 'class' type
« Reply #10 on: October 27, 2008, 11:10:00 pm »
PS never heard of member() are you sure that was MudOS

Guess it must not have been.  It was probably 1995 or so when I was doing that port work, so I suppose a detail or two may have become fuzzy.

You might have mixed it up with the LDMud driver.

Code: (ldmud/3.4/current/doc/efun/member) [Select]
SYNOPSIS
        int member(mixed *array, mixed elem [, int start])
        int member(string s, int elem [, int start])
        int member(mapping m, mixed key)

DESCRIPTION
        For arrays and strings, returns the index of the first
        occurance of second arg in the first arg, or -1 if none found.
        If <start> is given and non-negative, the search starts at
        that position. A start position beyond the end of the string
        or array will cause the efun to return -1.

        For mappings it checks, if key is present in mapping m and
        returns 1 if so, 0 if key is not in m.

HISTORY
        LDMud 3.3.556 added the <start> parameter.

SEE ALSO
        rmember(E), mappings(LPC)

Tricky