Server Help

Bot Questions - LVZ toggling

Samapico - Tue Feb 12, 2008 12:51 am
Post subject: LVZ toggling
In mervbot's spawn.h:

// Increase this beyond 1 when Continuum supports LVZ object toggling with more than 1 object at a time.
#define MAX_OBJECTS 1


Can we toggle more than one lvz at once now? Does *objset really toggles many images at once, or sends a single packet for each object individually?
dugwyler - Fri Feb 22, 2008 12:03 pm
Post subject:
Yeah, there's support for this now in packet C2S 0x0A:

index length desc
1 1 type byte (0x0A)
2 2 player id (0xFFFF for all players)
4 1 lvz packet type byte (0x35 for toggle)
5 2* lvz objID bitwise AND with 0x7FFF to turn on, 0x8000 to turn off

* repeat until done with all objects.


As for whether or not MERV supports this, dunno. See TWCore's GamePacketGenerator for an implementation that was ganked from Cerium's Hybrid. Also includes support for the type 0x36, for modification of LVZ objects.



As for just using *objset, yes, it works for any number of objects: *objset +5,-4,+3, -- just remember that you have to end with a trailing comma. I would recommend implementing on the packet level if MERV doesn't yet do it, though.
Samapico - Fri Feb 22, 2008 12:08 pm
Post subject:
Yeah, I'll check that... thanks

(If anyone else more familiar with the Merv core wants to help me out on this, it could help a lot tongue.gif )

Is there really no limit to the number of objects you can toggle with one packet? Would ridiculous amounts like 2000 work? or 70000? tongue.gif
Samapico - Fri Feb 22, 2008 12:21 pm
Post subject:
Code: Show/Hide
clientMessage *generateObjectToggle      (Uint16 player, objectInfo *objects, Uint16 num_objects)
{   clientMessage *ret = new clientMessage(4 + 2 * num_objects);
   if (ret == NULL) return NULL;
   char *msg = ret->msg;

   /*   Field   Length   Description
      0      1      Type byte: 0x0a
      1      2      Player ident (-1 = all players)
      3      1      LVZ type byte: 0x35
   The following are repeated until the end of the message
      4      2      LVZ bitfield
   */

   msg[0] = 0x0a;
   *(Uint16*)&msg[1] = player;
   msg[3] = 0x35;

   memcpy(msg + 4, objects, 2 * num_objects);

   return ret;
}


It seems to be implemented already... But when I changed the MAX_OBJECTS value, my display got kind of screwed up... I'll do some more tests
Samapico - Fri Feb 22, 2008 1:35 pm
Post subject:
hmm... it only effectively toggles HALF the objects

I wanted 5, it toggled 3, I wanted 10, it toggled 5

EDIT:

oh wait... look at the packets the bot received... from the terminal:

PV:Samapico> !toggleon
A:Toggling ON 10 objects
Object number 200 enabled
Object number 19917 disabled
Object number 211 enabled
Object number 19917 disabled
Object number 222 enabled
Object number 19917 disabled
Object number 233 enabled
Object number 19917 disabled
Object number 244 enabled
Object number 19917 disabled

It was supposed to toggle on: 200, 211, 222, 233, 244 and 300, 311, 322, 333, 344
for some reason it queued these 19917 objects off...
Samapico - Fri Feb 22, 2008 1:54 pm
Post subject:
Quote:
5 2* lvz objID bitwise AND with 0x7FFF to turn on, 0x8000 to turn off
Wouldn't that be 0xFFFF to turn it off?

If you do ( id bitwise AND 0x8000 ) it will always give 0...

edit: oh.. it would be a bitwise OR with 0x8000 to turn it off...
Either way, the MSB of that integer is whether or not the object is being disabled, and the other 15 bits are the objectID.
Samapico - Fri Feb 22, 2008 2:06 pm
Post subject:
Code: Show/Hide
union objectInfo
{
   struct
   {
      Uint16 id         : 15;   // Object ident
      Uint16 disabled      : 1;   // 1=off, 0=on
   };

   Uint16 n;
};


I'm not familiar with unions... is this thing 2x 16bits long?
If it is... then that's the bug tongue.gif

Edit: yeah it is... sizeof says it's 4 bytes long... what's the 'n' for???
Samapico - Fri Feb 22, 2008 2:19 pm
Post subject:
what the hell... now it says it's 2 bytes long.. I don't understand anything gaaaah

I made Console application projects in both VS6 and VS2005, and both give me a size of 2 bytes for that union...

Why does it show up as 4 in the plugin project...

Plugin project:
Code: Show/Hide
sendPublic("*arena size: " + (String) sizeof(Uint16) + " " + (String) sizeof(objectInfo) );

Outputs: "size: 2 4"

Visual Studio new console application project:
Code: Show/Hide

#include "stdafx.h"

typedef unsigned short    Uint16;

union objectInfo
{
   struct
   {
      Uint16 id         : 15;   // Object ident
      Uint16 disabled      : 1;   // 1=off, 0=on
   };

   Uint16 n;
};


int main(int argc, char* argv[])
{
   printf("%i %i\n", sizeof(Uint16), sizeof(objectInfo));

   getchar();

   return 0;
}

Outputs: "2 2" in both Visual C++ 6.0 and Visual Studio 2005

What the hell am I doing wrong?




EDIT: I found the problem... the union posted above is from the clientprot.h file, in the core...

In spawn.h, there is a different definition of objectInfo:
Code: Show/Hide
union objectInfo
{
   struct
   {
      unsigned id            : 15;   // Object ident
      unsigned disabled      : 1;   // 1=off, 0=on
   };

   Uint16 n;
};

... so yeah.... tongue.gif unsigned != Uint16 I guess


By changing these 'unsigned' to Uint16, and changing MAX_OBJECTS to something bigger, anything using lvz's will be much more efficient...
Any chance of getting an updated version of Merv released with this?
Bak - Fri Feb 22, 2008 9:07 pm
Post subject:
wowow that's retarded. good find.

As for your union question, it's a way of having different ways to refer to the same memory location.
Samapico - Fri Feb 22, 2008 11:07 pm
Post subject:
Works like a charm now by the way...

My display module responds MUCH faster... When you change team for example, the whole display is changed on your screen with 1 packet, instead of like 20 :/
Smong - Sun Mar 02, 2008 12:01 pm
Post subject: Re: LVZ toggling
Samapico wrote:
In mervbot's spawn.h:

// Increase this beyond 1 when Continuum supports LVZ object toggling with more than 1 object at a time.
#define MAX_OBJECTS 1
Looks like you have an old version of the mervbot tutorial plugin code. I just downloaded a copy and it's set to 20.

Samapico wrote:
In spawn.h, there is a different definition of objectInfo
Can't see that in the tutorial code.

You might want to check for other differences between the latest tutorial code and your plugin before other old bugs creep in.
Samapico - Sun Mar 02, 2008 7:50 pm
Post subject:
hmmm you're right...
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group