MudBytes
» MUDBytes Community » Coding Discussions » Coding and Design » IMC2 Custom Name Mud Seperator
Pages: << prev 1, 2 next >>
IMC2 Custom Name Mud Seperator
Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#1 Posted Aug 16, 2008, 5:56 pm

ok, so, Ronfar was having some issues with color codes and the default @ seperator for the IMC2 network, so i set out to find hiim a fix for his error and here it is:

add somewhere in imc.c (mines at the top.)

Code (text):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
/* Pedlar - Fix for custom Name@Mud seperators */
#define IMC_SEPERATOR "<>"
 
char* fix_sender(char* string)
{
        char from[SMST];
        char senders[SMST];
        static char buf[SMST];
        char *x, *y, *z;
        senders[0] = '\0';
        from[0] = '\0';
 
        y = string;
 
        x = senders;
        while(*y != '\0') {
                if(*y == '@') {
                        *y++;
                        *x++ = '\0';
                       break;
                }
 
                *x++ = *y++;
        }
 
        z = from;
        while(*y != '\0') {
                *z++ = *y++;
        }
        *z++ = '\0';
 
        sprintf(buf, "%s%s%s", senders, IMC_SEPERATOR, from);
 
        return buf;
}
 


in then in function

Quote:
PFUN( imc_recv_pbroadcast )


change
Code (text):
1
2
3
imc_display_channel( c, sender , txt, em );

to
Code (text):
1
2
3
imc_display_channel( c, fix_sender( sender ), txt, em );


and in function
Quote:
PFUN( imc_recv_broadcast )


change
Code (text):
1
2
3
4
5
6
7
8
 
   if( !sender || sender[0] == '\0' )
      imc_display_channel( c, q->from, txt, em );
   else
      imc_display_channel( c, sender, txt, em );
 


to

Code (text):
1
2
3
4
5
6
7
8
 
   if( !sender || sender[0] == '\0' )
      imc_display_channel( c, fix_sender( q->from ), txt, em );
   else
      imc_display_channel( c, fix_sender( sender ), txt, em );
 


Hope this makes some people happy.

you can make the IMC_SEPERATOR whatever you want. i just did <> for testing it out.
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

Last edited Aug 16, 2008, 6:06 pm by Pedlar
MaineCoon
Fledgling




Group: Members
Posts: 9
Joined: Sep 4, 2007

Go to the bottom of the page Go to the top of the page
#2 Posted Aug 16, 2008, 6:02 pm

This code has a memory leak - you are calling str_dup and returning the results of that, but his memory is never freed.

Instead, change

Code (text):
1
2
3
4
5
 
        char buf[SMST];
 


to

Code (text):
1
2
3
4
5
 
        static char buf[SMST];
 


and then change

Code (text):
1
2
3
4
5
 
        return str_dup(buf);
 


to

Code (text):
1
2
3
4
5
 
        return buf;
 


As long as nothing calls fix_sender while using the results of a call to fix_sender, you'll be fine.

Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#3 Posted Aug 16, 2008, 6:16 pm

did already :D
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

Ronfar
Fledgling




Group: Members
Posts: 1
Joined: Aug 16, 2008

Go to the bottom of the page Go to the top of the page
#4 Posted Aug 16, 2008, 6:23 pm

You are truly a life saver... or at least a time saver!

I was cringing at the thought of having to change all my color codes.... can't imagine that being any fun at all.

Thanks a TON!  someday when I'm a coding genius (hah.) I'll repay you :D

David Haley
Wizard






Group: Members
Posts: 5,727
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#5 Posted Aug 16, 2008, 7:01 pm

Looks helpful. :smile: But it's spelled separator, not "seperator". :wink:
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#6 Posted Aug 16, 2008, 7:29 pm

bah David, I can't spell to save my life, who cares :P
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

kiasyn
Wizard






Group: Administrators
Posts: 857
Joined: May 15, 2006

Go to the bottom of the page Go to the top of the page
#7 Posted Aug 16, 2008, 7:40 pm

You'll still have to use @ for stuff like imctell, which could get confusing. Probably should convert in both directions.
.........................
http://www.mudbytes.net/kiasyn-sig.png

Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#8 Posted Aug 16, 2008, 7:50 pm

can use same function, just put it in the imctells functions I forgot that part, since i rarely use imctell :D
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

kiasyn
Wizard






Group: Administrators
Posts: 857
Joined: May 15, 2006

Go to the bottom of the page Go to the top of the page
#9 Posted Aug 16, 2008, 7:53 pm

What I'm saying is any commands requiring 'Person@MUD' should be changed to 'Person' IMC_SEPARATOR 'MUD' and then have a function that translates the separator to '@', which is what the protocol dictates.
.........................
http://www.mudbytes.net/kiasyn-sig.png

Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#10 Posted Aug 16, 2008, 7:58 pm

ahhh, yea, that would be pretty nice, abit of work to do now knowing if anyone would ever use it though, I could possibly rewriteit so IMCSEPERATOR is apart of the imcconfig, and make it like that, and possibly upload the changed version here, so people can just download the changed version instead of patching it. when i find free time to do so.
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

David Haley
Wizard






Group: Members
Posts: 5,727
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#11 Posted Aug 16, 2008, 9:06 pm

Well, I'm just trying to avoid more spelling mistakes getting into the source... I think that SMAUG is responsible for a whole generation of effect vs. affect mistakes. :tongue:
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#12 Posted Aug 17, 2008, 11:10 am

I have Finished work on it yay!

New commands:
imcconfig channsep <channel seperator> (Can be a string)
imcconfig telldelim  <Tell Delimiter>  (Can only be a single character)

it works i tellya!, i have my Tell Delim set to : and i can use imctell kiasyn:talon <message> and have it work ;)

I have a few more changes to make(Changing over the tells to use the channel seperator)

I will post a link to the uploaded base files, and a patch file for people who currently have imc, and wish to add thsese changes.
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

Samson
Evil Overlord






Group: Members
Posts: 2,631
Joined: May 13, 2006

Go to the bottom of the page Go to the top of the page
#13 Posted Aug 17, 2008, 2:11 pm

Just be sure you mark in very clear terms that this should only be done on codebases where there is color interference from the separation character. And for the love of God, make sure the new separator can't leak out onto the network or their communications will simply be dropped as invalid by the servers.
.........................
PDNS-Admin | SmaugMuds.org | Arthmoor MUD Hosting Services | The Truth About Medievia: A Saga of Code Theft.

http://www.mudbytes.net/samson-sig.png

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984

Pedlar
Conjurer






Group: Members
Posts: 113
Joined: May 19, 2006

Go to the bottom of the page Go to the top of the page
#14 Posted Aug 17, 2008, 2:17 pm

Don't worry Samson :D its all client side fixes, wont leak over to the sending packets, those are still going to use @ symbol (I made sure, ive been using the system for a day now :D)  and why does it only need to be for color interference? I kinda liked the idea to be able to change the stuff as I saw fit for it :D
.........................
Coder of: The Abyss Mud

http://www.speedtest.net/result/114439322.png

Samson
Evil Overlord






Group: Members
Posts: 2,631
Joined: May 13, 2006

Go to the bottom of the page Go to the top of the page
#15 Posted Aug 17, 2008, 2:28 pm

Color interference was the reason for the patch, yes? Otherwise there's not much of a point in doing it from what I can tell.
.........................
PDNS-Admin | SmaugMuds.org | Arthmoor MUD Hosting Services | The Truth About Medievia: A Saga of Code Theft.

http://www.mudbytes.net/samson-sig.png

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984

Pages:<< prev 1, 2 next >>

Valid XHTML 1.1! Valid CSS!