mxp entities lagging player

Posted by Lextasy on Sun 02 Apr 2006 08:22 PM — 12 posts, 34,769 views.

#0
I am experiencing two problems, I call the function below whenever the prompt is called. This seems to cause the player a quarter/second or so of lag.

Also, the mxp variables show up for wintin.NET and zmud, but I can't seem to find them anywhere in mushclient. Any chance someone has an idea or two to toss out,whether it has to do with the lag or missing variables in mush?

void mxp_add_prompt_tags(struct descriptor_data *descriptor)
{
char mxp_entity[ 10000 ], mxp_buf[ 10000 ];

if (!descriptor->character)
return;

if((descriptor->mxp) && IS_SET(descriptor->character->specials.player_act,PLR_MXP))
{
snprintf( mxp_buf, 10000, "%s%s%s%s%s%s%s%s", MXP_SECURE_STRING,
"<!ENTITY CurrentHP %i PUBLISH>", "<!ENTITY CurrentMana %i PUBLISH>",
"<!ENTITY CurrentMove %i PUBLISH>", "<!ENTITY MaxHP %i PUBLISH>",
"<!ENTITY MaxMana %i PUBLISH>", "<!ENTITY MaxMove %i PUBLISH>",
MXP_LOCKED_STRING );
snprintf( mxp_entity, 10000, mxp_buf, GET_HIT(descriptor->character),
GET_MANA(descriptor->character), GET_MOVE(descriptor->character),
GET_MAX_HIT(descriptor->character), GET_MAX_MANA(descriptor->character),
GET_MAX_MOVE(descriptor->character));
write_to_descriptor(descriptor, mxp_entity);
}

Then I call this function in comm.c(DIKU) where make_prompt is called...
USA #1
What does this have to do with MUSHclient?
#2
Always love responses like this, god forbid its my first post on these forums and I may of placed it in the wrong category.

How about the second question, any clue why the entities are not recording inside of mushclient? Or are they and I simply can't find them? Or isn't that related to mushclient enough for you?

I certainly hope there are less rude people about than this...
Amended on Sun 02 Apr 2006 08:35 PM by Lextasy
USA #3
There's nothing rude about a simple question. You're taking it out of context. I didn't notice you asked about MUSHclient though. I don't understand your question. What variables?
#4
I'm trying to get the entities for hps, maxhps, etc to show up inside of Mushclient. I think its under file-world properties, variables.

I have defined a bunch of mxp elements such as roomname,roomexits,etc. They all show up there. However the entities in the initial post here are not there,I can't seem to find them anywhere. However they are showing up in other clients so Im wondering if Im simply looking in the wrong spot...

Hope Im speaking clearly enough because this is all relatively new to me...

Thanks for trying to help btw, staring at the same problem for hours is getting a little frustrating-which is probably why I got upset, sorry about that.

USA #5
I'm not familiar with MXP very much either. You have MXP enabled on MUSHclient, correct? I believe MUSHclient trys to follow the standards of MXP, so if something does not appear to be working that may be related to it.

Have you tried looking at MUDs that have MXP? In the download section here, there is a Smaug with MXP.
Australia Forum Administrator #6
Quote:

Also, the mxp variables show up for wintin.NET and zmud, but I can't seem to find them anywhere in mushclient. Any chance someone has an idea or two to toss out,whether it has to do with the lag or missing variables in mush?


First, does this lag also occur in MUSHclient?

I tried sending part of that to MUSHclient with no noticeable lag. You may want to confirm if the lag is server-side or client-side.

I can't think why it would take a long time.

As for the second question, entities are stored internally in MUSHclient in its "custom server entities" table, which can be retrieved using a script, like this:


currenthp = GetEntity ("currenthp")


Note that the entity names are forced to lower case (somewhere it is documented in MXP that entities are not case-dependent) and thus using the exact capitalization you used (CurrentHP) will return nothing.
#7
Thanks a bunch, that answers why I was having a tough time finding the entities via MUSHclient.

The lag is server side, I notice it in all the MXP clients I am testing with. Now Im at a loss as to why. It has to be something with the amount of information I am sending to the player per prompt?

Thanks for all the help, its greatly appreciated...

Very nice client :-)
Australia Forum Administrator #8
Thanks. :)

As for your problem, I am at a loss to understand this code. For a start, you are allocating, on the stack, two buffers of 10,000 characters to hold something like this:


<!ENTITY CurrentHP 9999 PUBLISH>
<!ENTITY CurrentMana 9999 PUBLISH>
<!ENTITY CurrentMove 9999 PUBLISH>
<!ENTITY MaxHP 9999 PUBLISH>
<!ENTITY MaxMana 9999 PUBLISH>
<!ENTITY MaxMove 9999 PUBLISH>


That is around 200 bytes, nothing like 10,000. A buffer of 300 bytes would be plenty.

Allocating 20 Kb bytes every time the function is called may well slow the system down due to page faults.

The second thing is, why the two snprintfs? You seem to be using the first one to simply put into a (large) buffer the thing you want to send to the second one. Why not something like this? ...



void mxp_add_prompt_tags (struct descriptor_data *descriptor)
{
char mxp_buf [300];  /* increase if you add more stuff */

if (!descriptor->character)
  return;

if ((descriptor->mxp) && 
    IS_SET(descriptor->character->specials.player_act,PLR_MXP))
   {
    snprintf (mxp_buf, sizeof (mxp_buf) , 
             "%s"   /* secure string */
             "<!ENTITY CurrentHP %i PUBLISH>"
             "<!ENTITY CurrentMana %i PUBLISH>"
             "<!ENTITY CurrentMove %i PUBLISH>"
             "<!ENTITY MaxHP %i PUBLISH>"
             "<!ENTITY MaxMana %i PUBLISH>"
             "<!ENTITY MaxMove %i PUBLISH>"
             "%s",   /* locked string */
                MXP_SECURE_STRING,
                GET_HIT(descriptor->character),
                GET_MANA(descriptor->character), 
                GET_MOVE(descriptor->character),
                GET_MAX_HIT(descriptor->character), 
                GET_MAX_MANA(descriptor->character),
                GET_MAX_MOVE(descriptor->character),
                MXP_LOCKED_STRING);
    write_to_descriptor(descriptor, mxp_buf);
   }

}




Australia Forum Administrator #9
Quote:

This seems to cause the player a quarter/second or so of lag.

...

The lag is server side ...


In that case, you are causing *all* players a quarter second of lag, every time one of them is shown the prompt.
#10
I appreciate all the help, as it turns out is wasn't the code lagging my server, but the placement of it. Instead of calling it everytime the mud moves, I'm calling it everytime the prompt changes. Now it works as it should.

And I am able to call all of my entities through MUSHclient:)

Is there a list of popular entities and elements anywhere?
I have added hps, maxhps, mvs, maxmoves, mana, maxmana. Then all of the room stuff such as name, exits, description.

I do apologize for swaying off topic and feel free to move the thread if it helps...

Australia Forum Administrator #11
I am not aware of a list of popular entities, but as this is specific to your particular MUD I don't think it matters. The custom entities are separate from the standard ones in MUSHclient, so you can pretty-well call them anything. I wouldn't however use standard HTML entities (like &lt; ) for obvious reasons.