Author Topic: strange errors, need help, share wisdom  (Read 6172 times)

Offline mordain

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
strange errors, need help, share wisdom
« on: March 23, 2009, 12:28:31 pm »
Hey guys... im workin on the comms stuff, and i ran into this odd behaviour, i dunno if it's cause im tired but i was hoping one of you could shed light on the seemingly inconsistant behaviour below

Code: [Select]
eval return this_player()->query_name()
Result:
"mordain"
>  eval return this_player()->is_player()
Result:
1
>  eval return this_player()->query_ignored(this_player()->query_name())
Result:
0
>  eval return "/cmds/player/tell"->find_player("test")
Result:
</obj/user#93>
>  eval return "/cmds/player/tell"->find_player("test")->query_name()
Result:
"test"
>  eval return "/cmds/player/tell"->find_player("test")->is_player()
Result:
<nil>
>  eval return "/cmds/player/tell"->find_player("test")->query_ignored(this_player()->query_name())
Result:
<nil>

and in case you are curious...

Code: [Select]
object find_player(string who) {
    int i, sz;
    object *usr;
   
    who = lowercase(who);
    usr = users();
    for( i = 0, sz = sizeof(usr); i < sz; i++ ) {
        if( usr[i]->query_name() == who ) {
            return usr[i];
        }
    }
}

and

Code: [Select]
int query_ignored( string who ) {
    if ( !ignored ) ignored = ({ });   
    who = lowercase(who);
    return member_array( who, ignored ) >= 0;
}

« Last Edit: March 23, 2009, 12:37:28 pm by mordain »

Offline Aidil

  • Friend
  • **
  • Posts: 50
    • View Profile
    • Way of the Force
Re: strange errors, need help, share wisdom
« Reply #1 on: March 23, 2009, 01:52:22 pm »
The first thing that kinda jumps out at me is how you use users()

Users returns an array of objects having a connection, those are not the same as player objects, and can also include things like ftp or intermud connections. I'm not so sure this is what you wanted there.

Second, I wonder, shouldn't the data and as a result the query_ignored() call be in the player object?

To find the player object associated with a user object, you do use user->query_player()
This will return the player object if any, or nil in case of non player connections.

Not sure if this explains your error, but considering

Code: [Select]
>  eval return "/cmds/player/tell"->find_player("test")->is_player()
Result:
<nil>

I think it does.
Way of the Force

A Star Wars LPMud
wotf.org port 23

Offline skullslayer

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
Re: strange errors, need help, share wisdom
« Reply #2 on: March 23, 2009, 02:59:31 pm »
The first thing that kinda jumps out at me is how you use users()

Users returns an array of objects having a connection, those are not the same as player objects, and can also include things like ftp or intermud connections. I'm not so sure this is what you wanted there.

users() returns the array of objects that have at some point been marked as interactive. This may include netdead players as well as those currently connected. It does not include ftp or intermud connections, nor does it include npcs that have been flagged as living. See also: userp()

Unless DGD implements users() totally differently to MudOS etc
« Last Edit: March 23, 2009, 03:01:23 pm by skullslayer »

Offline Aidil

  • Friend
  • **
  • Posts: 50
    • View Profile
    • Way of the Force
Re: strange errors, need help, share wisdom
« Reply #3 on: March 23, 2009, 03:16:15 pm »
Skullslayer,

Yes, DGD behaves slightly differently, it behaves as I explained. Not to dis you, I know you are trying to help, but I maintain the network code in the version of DGD that Mordain is using, I really quite know what I am talking about in this case.

Way of the Force

A Star Wars LPMud
wotf.org port 23

Offline Aidil

  • Friend
  • **
  • Posts: 50
    • View Profile
    • Way of the Force
Re: strange errors, need help, share wisdom
« Reply #4 on: March 23, 2009, 03:44:19 pm »
Let me add a few details on this:

DGD does not concern itself with player objects, all it knows about is connection objects. Every connection object belongs to a connection, either inbound or outbound (the outbound part is where the network package that I distribute comes in). users() lists all those connection objects.

A very common setup on DGD (no way mandatory, just how this is usually done) is to not make such a connection object the player object, instead, a 'user' object contains the connection and any details about it, and a seperate 'player' object represents the 'in-game' player. Possibly a 3rd 'body' object is used, but many libs on DGD don't do this.

The first reason for this setup is persistency. It is possible to make the in-game player object completely persistent (so it never ever gets destroyed until the player gets removed), and just reconnect a user object to it when the player logs in.

The second reason is that this user object can also use an entirely different protocol (say http instead of telnet) and still connect to the exact same 'in-game' player. All the details about the protocol can be 'hidden' in the user object, and kept away from the 'game'.

Then, this setup offers security advantages by being able to keep sensitive data (such as login info) completely seperate from the game.

Last but not least, while DGD can be used as a game driver, it is intended to be usable for many other network server applications, and for quite some time it was used by the now defunct ichat chatroom service. Not implementing players, but 'users' and generic network connections makes a lot of sense because of this. On DGD, it is the task of a 'kernel library' to provide many of the things that in case of Mud/FluffOS are provided for by the driver. This includes everything that has to do with such game aspects as 'players'.

What would help Mordain is me or someone else adding a players() afun to the Gurbalib kernel.

Since this seems like a good idea to me, I suggest those interested and involved discuss this on the DGD channel

Way of the Force

A Star Wars LPMud
wotf.org port 23

Offline mordain

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
Re: strange errors, need help, share wisdom
« Reply #5 on: March 23, 2009, 11:15:51 pm »
ok aidil seems to be correct and in fact the new players() sefun works nicely.


Quote
Second, I wonder, shouldn't the data and as a result the query_ignored() call be in the player object?
It "IS" in player.c  :)