Menu

#10 Handling OSP Colors

open
5
2003-12-21
2003-08-07
RRx^Zero
No

(Note: I play RTCW exclusively, so I’m not sure how this
would work with ET or any other game WolfStat
supports)

I’m not sure how hard it is, but I was wondering if
WolfStat could have better awareness of OSP color
codes…

From the OSP Readme:

There are 32 color escape codes in the OSP UI and
cgame modules. From the normal ^0 - ^7, the following
are also available:

- ^8, ^9, ^<, ^>, ^:, ^;, ^=, ^?, ^@
- ^A - ^O (note, caps MUST be used to get
the proper color)
- For future compatibility with Main/, use ^p
(lower case) for the color black.

Now, my nick is RRx^Zero. The “Zero” is supposed to be
the color black, so on any server (except OSP), my
name is: “^1RRx^7^^8Zero”, however, when I log into
an OSP server, the black turns Orange, so I need to
change my name to: “^1RRx^7^^pZero”.
Our servers run both OSP and shrub, and I know these
are completely separate logs, but sometimes I forget to
change my name when I bounce back and forth between
the servers. Subsequently, our logs shows my name
twice as two separate players (which makes my stats
look terrible… :)

In fact, as far as I know, WolfStat doesn’t understand
the 32 color codes for OSP, because our stats output
shows my shrub name correctly as “RRx^Zero”, but
shows my OSP name incorrectly as “RRx^^pZero”. Looks
like it doesn’t know what to do with the “^p”.

Now, I haven't had the chance to look at your code, so
I’m not sure how it runs and I may be incorrect in my
assumptions, but here’s my humble suggestion:

Color codes are a lot like HTML tags – they’re markup for
the name. Markup shouldn’t determine the value of a
tag, it should only describe it. So, when determining
stats for a player, I would strip out all color information
from the name in order to determine if it was unique or
not – this way “^1RRx^7^^pZero”
and “^1RRx^7^^8Zero” are the same name value after
stripping out the color “markup”: “RRx^Zero”.
You could use the following regular expression in a
replace function to strip a name of the above 32 escape
codes:

\^[0-9A-Op<>:;=\?@]

This should work for both OSP and non-OSP names.

Hope this helps and Thanks!
Zero.

Discussion

  • Pontus Ullgren

    Pontus Ullgren - 2003-08-08

    Logged In: YES
    user_id=61176

    hmmm ... seems true ... the problem is is there any regexp
    suport on MS Cripple^H^H^H^H^H^H^H Windows ?

    I'll have a look at it.

     
  • Pontus Ullgren

    Pontus Ullgren - 2003-08-08
    • milestone: 314636 --> Next_Minor_Release
     
  • RRx^Zero

    RRx^Zero - 2003-08-08

    Logged In: YES
    user_id=839998

    Not sure if you're using COM in your Windows version - I
    guess you must be if you're using MSXML, but you can use
    the VBScript Regular Expressions object:

    c:\winnt\System32\vbscript.dll
    {3F4DACA7-160D-11D2-A8E9-00104B365C9F}

    This gives you access to a RegExp object with a convenient
    replace method:

    (sorry, I'm a VB developer... ::ducks::)

    Dim lobjX As New RegExp
    Dim lstrNewName As String
    Dim lstrOldName As String

    lstrOldName = "^1RRx^7^^pZero"

    ' SET MATCH PATTERN
    lobjX.Pattern = "\^[0-9A-Op<>:;=\?@]"
    ' SET TO REPLACE ALL INSTANCES IN STRING
    lobjX.Global = True

    ' EXECUTE REPLACE WITH NULLSTRING
    lstrNewName = lobjX.Replace(lstrOldName, "")

    Good luck!
    Zero.

     
  • Pontus Ullgren

    Pontus Ullgren - 2003-12-21
    • assigned_to: nobody --> ullgren
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.