Server Help

ASSS Questions - Fakes & chat

Hakaku - Thu Feb 26, 2009 12:47 pm
Post subject: Fakes & chat
At the moment in Deva we currently have the server forward messages to a bot in order to be able to send messages on a ?chat channel. In our attempt to make the zone eventually bot-free, would it technically be possible for the server or a fake player to send messages on a chat channel? If so, how could this be done?
Chambahs - Thu Feb 26, 2009 1:58 pm
Post subject:
I know for sure it is. But do you want to keep the bot on a certain chat channel, or do you want the bot just relaying messages to different chat channels?
Hakaku - Thu Feb 26, 2009 2:23 pm
Post subject:
Chambahs wrote:
I know for sure it is. But do you want to keep the bot on a certain chat channel, or do you want the bot just relaying messages to different chat channels?

I think you misunderstood. Right now we already have a bot relaying messages from the server to a ?chat channel. What I'd like to be able to do is get rid of the bot entirely and just have the server/fake player send messages to the channel. So I'm asking if this is even possible?
Dr Brain - Thu Feb 26, 2009 3:07 pm
Post subject:
It's possible. You'd have to create a module to log a player into the billing server, and send ?chat=...

I don't know how much trouble that will be, though.
Cheese - Thu Feb 26, 2009 5:25 pm
Post subject:
ive been meaning to do an asss chat mod, ill look into it...
Initrd.gz - Fri Feb 27, 2009 8:25 pm
Post subject:
For fakes "speaking":

A ) You can use chat->SendAnyMessage
B ) You can add "Fake>" to the beginning of a message and send it like any other, though it would be green

Look at the Color module for how to "spoof" the color of chat->SendAnyMessage to make it look like a public/team/priv. message
Dr Brain - Fri Feb 27, 2009 9:33 pm
Post subject:
None of that will help with speaking on a ?chat channel.
Cheese - Sat Feb 28, 2009 12:50 am
Post subject:
because it only sends to those inside the zone


yeah, you could fake an entire chat session, but it wouldnt do anything for those in other zones...
Cheese - Thu Mar 05, 2009 2:17 am
Post subject:
in chat.c, it uses

Code: Show/Hide

local void v_send_msg(LinkedList *set, char type, char sound, Player *from, const char *str, va_list ap)
{
   int size;
   char _buf[256];
   const char *ctype = get_chat_type(type);
   struct ChatPacket *cp = (struct ChatPacket*)_buf;

   size = vsnprintf(cp->text, 250, str, ap) + 6;

   if (type == MSG_MODCHAT)
      type = MSG_SYSOPWARNING;

   cp->pktype = S2C_CHAT;
   cp->type = type;
   cp->sound = sound;
   cp->pid = from ? from->pid : -1;
   if (net) net->SendToSet(set, (byte*)cp, size, NET_RELIABLE);
   if (chatnet && ctype)
   {
      if (from)
         chatnet->SendToSet(set, "MSG:%s:%s:%s", ctype, from->name, cp->text);
      else
         chatnet->SendToSet(set, "MSG:%s:%s", ctype, cp->text);
   }
}


i notice it uses
Code: Show/Hide

struct ChatPacket *cp = (struct ChatPacket*)_buf;


which is basically inline structure declaration.
why does this work?
i tried throwing this into my code, but it died with a "dereferencing pointer to incomplete type" error every time i tried to do cp->pktype = S2C_CHAT; or something...


--edit--
i got this to compile without error by tweaking the code.
however, the curent ChatPacket struct expects char text[0], which i know wants the pointer to a char array...
how do i pass char buf[256] to cp.text without getting an incompatible types error?
Dr Brain - Thu Mar 05, 2009 6:43 am
Post subject:
It works because it doesn't do what you think it's doing. It declares the chat packet as pointing to the buffer, it doesn't create a new chat packet. It's not an inline structure declaration.
Samapico - Thu Mar 05, 2009 10:10 am
Post subject:
Yeah, it just typecasts _buf (a char*) to a Chatpacket*
Cheese - Thu Mar 05, 2009 10:54 am
Post subject:
thats what i figured, but how do i pass char buf[256] to cp.text (buf[0]) without getting an incompatible types error?

im not so great at this if you cant tell icon_biggrin.gif
Dr Brain - Thu Mar 05, 2009 4:48 pm
Post subject:
cp->text (not cp.text) already occupies some of the same memory as the buffer. Assigning the buffer to it is not what you want, since the packet IS the buffer. If you're looking to better understand it, I'd suggest you brush up on pointers and arrays. Specifically the part where they talk about the similarities between the two.
Samapico - Thu Mar 05, 2009 5:00 pm
Post subject:
strcpy?
Cheese - Sat Mar 07, 2009 6:14 pm
Post subject:
so i connected this to a command

Code: Show/Hide

local void aCmd(const char *params, const char *params2, Player *p, const Target *target)
{
    chat->SendMessage(p,"net cmd sending...");
   
    //cpp=&cp;
    char buf[256];
    struct ChatPacket *cpp=(struct ChatPacket*)buf;
    int size;
   //cpp->text=buf;
   size=snprintf(cpp->text,250,"%s","weeeeeeeeeeeeeeee")+6;
   cpp->pktype=S2C_CHAT;
   cpp->type=MSG_PUB;//79;//type;
   cpp->sound=0;//sound;
   cpp->pid=p->pid;//-1;//from ? from->pid : -1;
   
    //net->SendToSet(set,(byte*)cp,size,NET_RELIABLE);
    //void (*SendToOne)(Player *p, byte *data, int length, int flags);
    net->SendToOne(p,(byte*)cpp,size,NET_RELIABLE);
   
    chat->SendMessage(p,"net cmd sent");
   
    return;
}


compiled fine, but the zone crashes somewhere between 'sending' and 'sent'...
i have no idea why


after this works, ill figure out how to log a fake player into the biller.
Dr Brain - Sat Mar 07, 2009 6:54 pm
Post subject:
Run it in a debugger (gdb if you're running on linux). If you don't know how to use a debugger, then it's time to learn. You'll never regret any amount of time spent learning to use your debugger. It's easily your most powerful programming tool.

Oh, if you do try to log fake players into a biller, make sure you don't test it on SSC while you're developing. Try it on something like subbill or catid's biller.
Cheese - Sat Mar 07, 2009 7:47 pm
Post subject:
good thing i dont own a ssc connected zone then, right? =D

never used a debugger, and how would i debug a dll? :S
i installed one, but i have no idea how to use it...


unrelated: why does

chat->SendMessage(p,"| %-15c | %-80c |","string","string");

output wierd chars instead?
Dr Brain - Sat Mar 07, 2009 8:56 pm
Post subject:
Cheese wrote:
never used a debugger, and how would i debug a dll? :S

Debug the entire program. It'll treat the dll as part of the whole.


Cheese wrote:
unrelated: why does

chat->SendMessage(p,"| %-15c | %-80c |","string","string");

output wierd chars instead?


Because %c is for a char. You want %s for a string.
Cheese - Sun Mar 08, 2009 3:44 am
Post subject:
oh duh, thanks
Cheese - Tue Mar 10, 2009 11:31 pm
Post subject:
do i need a just in time debugger, or will any work?

know any good ones?
Dr Brain - Wed Mar 11, 2009 6:32 am
Post subject:
Use gdb on Linux. Dev-C++ and MSVC++ both have built in debuggers.
Cheese - Sat Mar 14, 2009 4:30 pm
Post subject:
i dont know assembly, and i dont want to go through the hell of trying to get the core to compile.

im about to give up on this
Dr Brain - Sat Mar 14, 2009 4:53 pm
Post subject:
Compile the core. That should have been your very first step when working with asss programming.
Cheese - Sat Mar 14, 2009 5:45 pm
Post subject:
:(

also,
Unknown exit code: -1073741819.



and the core will not compile if you dont have python

error 2:

CreateProcess((null), uname -s, ...) failed.
\src\Makefile ../build/deps.mk: No such file or directory.
\src\Makefile CreateProcess((null), ../windeps/python.exe ../scripts/makedeps.py -I. -Iinclude -I../build -I../windeps -D_REENTRANT -D_GNU_SOURCE -I../windeps -I../windeps/mysqlinc -I../windeps/pythoninc */*.c -P $(BUILDDIR)/ -o ../build/deps.mk, ...) failed.
\src\Makefile The system cannot find the file specified.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group