Pedlar
Conjurer


Group: Members
Posts: 113
Joined: May 19, 2006
|
#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.
|
Last edited Aug 16, 2008, 6:06 pm by Pedlar
|
|
MaineCoon
Fledgling

Group: Members
Posts: 9
Joined: Sep 4, 2007
|
#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
As long as nothing calls fix_sender while using the results of a call to fix_sender, you'll be fine.
|
|
|
|
|
Ronfar
Fledgling

Group: Members
Posts: 1
Joined: Aug 16, 2008
|
#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
|
|
|
|
|
|
|
|
|
|
|
|
|
Pedlar
Conjurer


Group: Members
Posts: 113
Joined: May 19, 2006
|
#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.
|
|
|
|
|
|
|
|
|
|
|
|
|