SmaugWiz - WriteToBufferColor ----------------------------- This code adds a function to the CDescriptor class that allows you to write directly to a descriptor in color. You could use this to colorize your login and character creation sequence, actually I came up with this code when someone asked about converting their old function from Smaug to SmaugWiz to do this same thing. It's quick, it's simple, it uses existing code already in place and although I haven't really tested it out a ton, I did colorize my login screen with it and it works fine. The only caveat to it is that you can't use the &[ and &] tokens, which save current color and restore color respectively, but any of the other color tokens will work fine. The only reason you can't use them is that the field for stacking colors and the code for handling them is part of the CCharacter class, which if you're coloring things before you've got actual character data will cause a crash. I suppose you could just use a local CPtrList to handle them...but I was too lazy to mess with it. Installation ------------ In Smaug.h - Change the function declarations for MakeColorSequence from: extern int MakeColorSequence (UCHAR Col, char *buf, CDescriptor *d); extern int MakeColorSequence (const char *col, char *buf, CDescriptor *d); To: extern int MakeColorSequence (UCHAR Col, char *buf, CDescriptor *d, BOOL bCheckAnsi = TRUE); extern int MakeColorSequence (const char *col, char *buf, CDescriptor *d, BOOL bCheckAnsi = TRUE); In SmaugWizDoc.cpp - Change the two function headers for MakeColorSequence from - int MakeColorSequence (UCHAR Col, char *buf, CDescriptor *d) int MakeColorSequence (const char *col, char *buf, CDescriptor *d) To: int MakeColorSequence (UCHAR Col, char *buf, CDescriptor *d, BOOL bCheckAnsi /*=TRUE*/) int MakeColorSequence (const char *col, char *buf, CDescriptor *d, BOOL bCheckAnsi /*=TRUE*/) In both of the two MakeColorSequence functions find the code that looks like this: och = d->m_pOriginal ? d->m_pOriginal : d->m_pCharacter; bAnsi = ! och->IsNpc () && och->IsAnsi (); and change that code to look like this: if (bCheckAnsi) { och = d->m_pOriginal ? d->m_pOriginal : d->m_pCharacter; bAnsi = ! och->IsNpc () && och->IsAnsi (); } else bAnsi = TRUE; Note:I don't think you actually need to change both of them, but I changed them both just to be safe in case I mess around with this more in the future, you probably only need to actually change the code for the form of MakeColorSequence that's called by WriteToBufferColor, but that's up to you. In Descriptor.h - In the CDescriptor class find - void WriteToBuffer (const char* txt, int length = 0); and below that add - void WriteToBufferColor (const char* txt); In Descriptor.cpp add the following code - // Append onto an output buffer converting color codes to ascii // sequences - Note this will not use the &[ and &] tokens as that // is associated with the CCharacter class. Internally this uses the standard // WriteToBuffer function and utilizes a stripped down form of the same // code from CCharacter::SendColor to make the ascii color sequences. void CDescriptor::WriteToBufferColor (const char* txt) { // @@@ ECS if (this == NULL) then return; char *colstr; const char *prevstr = txt; char colbuf [32]; int len; if (! txt) return; while ((colstr = strpbrk (prevstr, "&^"))) { len = colstr - prevstr; if (len > 0) WriteToBuffer (prevstr, len); len = MakeColorSequence (colstr, colbuf, this, FALSE); if (len > sizeof (colbuf)) { bug ("BIGBUG!: SendColor: Buffer overflow! (%d)", len); return; } if (len < 0) { prevstr = colstr+1; break; } if (len) WriteToBuffer (colbuf, len); prevstr = colstr + 2; } if (*prevstr) WriteToBuffer (prevstr); } That's all the code, recompile the mud and you should be good to go. Example usage: If you want to colorize the login greeting, simply use hedit to colorize the greeting entry online (this is what gets sent to a player when they first connect to the mud) and then find this code in SmaugSocket.cpp - // Send the greeting. CHelpData *pHelp = HelpList.Find ("GREETING", -2, 2); if (pHelp) dnew->WriteToBuffer (pHelp->GetText ()); and change the last line to: dnew->WriteToBufferColor (pHelp->GetText ()); And now when players connect to your mud the login will be colorized (after you recompile the mud to make the code change take effect of course) This code was written (more like hacked out) for SmaugWiz 2.02 and like I said I haven't tested or used this extensively, but it seems to work just fine. Use it however you like, and if you have improvements feel free to add them :)