28 Jul, 2015, arholly wrote in the 1st comment:
Votes: 0
Hello:
So, I'm using the display grid by Davion for some formatting and I'm running into an issue. My output is looking like this (minus the spaces between the @ symbol:
+__________________________________________________________________________+
| Account Information for XXXXX |
+————————————————————————–+
| Email + XXXXXXX @ gmail.com |
+————————————————————————–+


You can see that it is adding extra spaces and it's because of the code which prevents the "@" symbol from registering as a color. The code is:
char *escape_colorcode(char *query)
{

if (!*query)
return NULL;

if (strlen(query) >= MAX_STRING_LENGTH)
return NULL;

char escape[MAX_STRING_LENGTH];

int i = 0, j = 0;

for (i = 0; i < strlen(query); i++) {
if (query[i] == '@') {
escape[i+j] = '@';
escape[i + (++j)] = query[i];
} else {
escape[i+j] = query[i];
}
}

escape[i+j] = '\0';

return strdup(escape);

}


I've also got the color code in the grid code modified to allow for the "@" symbol, but it's still off. Can anyone help?
//Counts colour codes to display offsets properly
int count_colour( char *str )
{ char c;
int count = 0;
while ( (c = *str++ ) != '\0' )
{
if(c == '{' || c == '@')
count++;
}
return count*2;
}


Thanks in advance
29 Jul, 2015, Davion wrote in the 2nd comment:
Votes: 0
I take it the original source is @@?

//Counts colour codes to display offsets properly
int count_colour( char *str )
{ char c;
int count = 0;
while ( (c = *str++ ) != '\0' )
{
if(c == '{' || c == '@')
count++;
}
return count*2;
}


Is probably your problem. It looks like if you give it @@ or {{, it'll register it as two separate colour codes. Hmm. Maybe add a str++; after count++ there.
29 Jul, 2015, arholly wrote in the 3rd comment:
Votes: 0
That got it to where it is only one space off now instead of two.
int count_colour( char *str )
{
char c;
int count = 0;
while ( (c = *str++ ) != '\0' )
{
if(c == '{' || c == '@')
{
count++;
str++;
}
}
return count*2;
}
29 Jul, 2015, alteraeon wrote in the 4th comment:
Votes: 0
FFS step through it with a debugger or print output to a tty. This isn't rocket science.
11 Aug, 2015, Omega wrote in the 5th comment:
Votes: 0
alteraeon said:
FFS step through it with a debugger or print output to a tty. This isn't rocket science.


Wow, a bit testy. That's not how you make friends is it? Because that surely will lead to none. Someone asks for help and act like a dick to them. No wonder the mudding community is dying.
11 Aug, 2015, Ssolvarain wrote in the 6th comment:
Votes: 0
Calm down, you know there are a few elitists on mudbytes :rolleyes:
11 Aug, 2015, quixadhal wrote in the 7th comment:
Votes: 0
The way I always did stuff like this was to use a color_strip() function to first translate ALL color codes to empty strings. THEN, take the strlen() of the result, and use THAT to figure out your padding space.

So, if you wanted two columns, and your overall width was 80, you'd have 78 columns of useable space.

If the left side were "Hit Points:" and the right side were "281", you know you have lengths of 11 and 3. If you have a column seperator that gives you 77 columns of working space. 77 - 11 - 3 is 63 spaces of padding. Where it goes depends on how you want to format.

Let's say you wanted both columns left justified.

So, your sprintf() would look like:

sprintf(tmp, "|%-s%-*s|%-s%-*s|\r\n", hp_string, 32 - strlen(stripped_hp_string), " ", hp_total, 31 - strlen(stripped_hp_total));

Of course, you could do it any number of ways… you could build your padding and just use it without the %*s parts. You could even write a pad function to return such a thing. Many Dikurivatives have center() functions coded that just don't deal with color codes properly, and you could modify one of those.

In fact:

https://github.com/quixadhal/SmaugFUSS/b...
11 Aug, 2015, Davion wrote in the 8th comment:
Votes: 0
Try this. I think it's not accounting for the fact that @@ actually has a length where as @r does not.

int count_colour( char *str )
{ char c;
int count = 0;

while((c = *str++) != '\0')
{
if(c == '{' || c == '@')
{
count++;
str++;
if(*str != '{' || *str != '@')
count++;
}

}
return count;
}
12 Aug, 2015, alteraeon wrote in the 9th comment:
Votes: 0
Omega said:
alteraeon said:
FFS step through it with a debugger or print output to a tty. This isn't rocket science.

Wow, a bit testy. That's not how you make friends is it? Because that surely will lead to none. Someone asks for help and act like a dick to them. No wonder the mudding community is dying.

No, the mudding community is dying because muds aren't putting forth the effort to compete with games that have actual resources behind them. It's dying because devs refuse to update user interfaces; because requiring quotes around spell names is still considered acceptable behaviour; because dropping new players into a mud school written in 1993 is commonplace. It's dying because people continue to start new games with 20+ year old codebases.

As for people asking for help, I happily help a lot of them. I tolerate without comment even more of them. But I do have a problem with laziness, and see no need to keep my mouth shut about it.

The fact of the matter in this situation is that this is a simple, detail oriented problem that's specific to his changes and setup. It's not somebody asking about why you can't use fwrite() from inside a signal handler; it's not somebody asking about best practices when trying to design an interactive area, or when trying to build a delayed destruct system for use with an async event handler. This problem is about somebody not bothering to instrument and figure out simple string processing code using well-established tools. It's akin to a freshman comp-sci student asking Stack Overflow to debug his homework.

If discouraging such things is not "making me any friends", well, I can live with that.
12 Aug, 2015, Tijer wrote in the 10th comment:
Votes: 0
Personally i try to help as many people as i can, with what i know… Helping new people get into mud coding is what will continue the whole thing into the next generation. The whole premise of my free mudhosting server is to get people up to speed with everything, i have a fair few people hosted on there, who are new to this.

Granted the original post would've been more suited in a newbie code forum, but seeing as Mudbytes doesn't have a newbie code forum then I am quite happy for it to be here.

Acting grumpy and above yourself really isn't the way to get people into doing this! You also have to remember a lot of the newbies to mud coding haven't really had ANY other experience apart from their MUD!! When i started my first mud in 1997, i had basic knowledge or how things worked as i had worked with computers at college/university. Most of these new people's knowledge comes from actually playing MUD's and wishing to create their own. They aren't software engineers with 15-20 years experience, and probably never will be.

Saying that though, i know of quite a few people who had no knowledge of coding when they first started their MUD, but have since gone on to have a career in software engineering.

At the end of the day, the people who have been doing this for a long time, need to take time to help people getting into doing this, to keep MUD's alive!
12 Aug, 2015, arholly wrote in the 11th comment:
Votes: 0
Well, as the OP, I'll just say this. Yes, was alteraeon's post a little prickly, yeah. But whatever. I was fine until later when he made the accusation of laziness. That I think is uncalled for until you know the circumstances of the person. Maybe it is because the person has a family, church ministry, and a full-time job and is doing coding for fun. Oh yeah, and the person doesn't have a CS degree either. Could he figure it out eventually, sure. Heck, I did figure it out (not using Davion's method, but something rather hackish). There are a lot of people who have a busy life and want to code, but don't have a lot of time to dedicate to it.

Asking for help, most of the time, is a humbling process and a learning process. I do think part of the reason more people don't ask for help is because of reactions like this. I don't particularly mind because I've been involved in the mudding community for 20+ years now and realize it's a bunch of cacti-like people who are soft and squishy once you get past the needles. Wow, this has inspired to write up a different post now.
12 Aug, 2015, Tijer wrote in the 12th comment:
Votes: 0
arholly said:
Well, as the OP, I'll just say this. Yes, was alteraeon's post a little prickly, yeah. But whatever. I was fine until later when he made the accusation of laziness. That I think is uncalled for until you know the circumstances of the person. Maybe it is because the person has a family, church ministry, and a full-time job and is doing coding for fun. Oh yeah, and the person doesn't have a CS degree either. Could he figure it out eventually, sure. Heck, I did figure it out (not using Davion's method, but something rather hackish). There are a lot of people who have a busy life and want to code, but don't have a lot of time to dedicate to it.

Asking for help, most of the time, is a humbling process and a learning process. I do think part of the reason more people don't ask for help is because of reactions like this. I don't particularly mind because I've been involved in the mudding community for 20+ years now and realize it's a bunch of cacti-like people who are soft and squishy once you get past the needles. Wow, this has inspired to write up a different post now.


I'll help when i can…. :)
12 Aug, 2015, arholly wrote in the 13th comment:
Votes: 0
I appreciate the offer. I've actually got someone whose mentoring me when he can on the side as far as coding goes. I'm learning as I go, which is slow and I generally learn what I need to know and not a lot else, unless I ask detailed questions.
12 Aug, 2015, Tijer wrote in the 14th comment:
Votes: 0
i meant on here nothing else :)
13 Aug, 2015, Rhien wrote in the 15th comment:
Votes: 0
Quote
It's dying because people continue to start new games with 20+ year old codebases.


Text in, text out. Most players won't know or care what the backend is written in or whether it's DikuMud, CoffeeMud, etc. Most new muds fail because they don't get players so they're almost inconsequential (a majority of them also don't build a good story or dedicate time to content along with code). The muds that hang around have melded decent code with a good story and let the players build the history of those worlds. You could not have to have quotes around spells but that isn't what is going to make or break a mud (although I agree, it is a little annoying). I also suspect very much so that changing technology has a lot to do with some of this (compare the online gaming landscape in 1996). There are more devices, with more games in more formats, it is a saturated market. Also, is there a single decent mobile mud client? Nope. I haven't found one anyway.

Also, a lot of people don't even know what a mud is which is a marketing issue. I almost never run into anyone whose heard of one. I had a co-worker ask me about it when they saw it on my github page, huge modern gamer, never heard of a mud which is almost a metaphor.
0.0/15