| 07-11-2008, 02:38 AM | #1 |
I think I love how exploitable jasshelper is: giberish:library ARGB initializer init globals private string array i2cc endglobals //this double naming stuff is beginning to make me insane, if only TriggerEvaluate() wasn't so slow... struct ARGB static method create takes integer a, integer r, integer g, integer b returns ARGB return ARGB(b + g*0x100 + r*0x10000 + a*0x1000000) endmethod static method fromPlayer takes player p returns ARGB local playercolor pc=GetPlayerColor(p) if(pc==PLAYER_COLOR_RED) then return 0xFFFF0000 elseif(pc==PLAYER_COLOR_GREEN) then return 0xFF00FF00 elseif(pc==PLAYER_COLOR_BLUE) then return 0xFF0000FF endif //Some body help! return 0x00000000 endmethod method operator alpha takes nothing returns integer if( integer(this) <0) then return 0x80+(-(-integer(this)+0x80000000))/0x1000000 else return (integer(this))/0x1000000 endif endmethod method operator red takes nothing returns integer local integer c=integer(this)*0x100 if(c<0) then return 0x80+(-(-c+0x80000000))/0x1000000 else return c/0x1000000 endif endmethod method operator green takes nothing returns integer local integer c=integer(this)*0x10000 if(c<0) then return 0x80+(-(-c+0x80000000))/0x1000000 else return c/0x1000000 endif endmethod method operator blue takes nothing returns integer local integer c=integer(this)*0x1000000 if(c<0) then return 0x80+(-(-c+0x80000000))/0x1000000 else return c/0x1000000 endif endmethod static method mix takes ARGB c1, ARGB c2, real s returns ARGB //widest function ever return ARGB( R2I(c2.blue*s+c1.blue*(1-s)+0.5) + R2I(c2.green*s+c1.green*(1-s)+0.5)*0x100 + R2I(c2.red*s+c1.red*(1-s)+0.5)*0x10000 + R2I(c2.alpha*s+c1.alpha*(1-s)+0.5)*0x1000000) endmethod method str takes string s returns string return "|c"+i2cc[.alpha]+i2cc[.red]+i2cc[.green]+i2cc[.blue]+s+"|r" endmethod method recolorUnit takes unit u returns nothing local integer a local integer r local integer g local integer b local integer col=integer(this) if (col<0) then set col=-(-col+0x80000000) set a=0x80+col/0x1000000 set col=col-(a-0x80)*0x1000000 else set a=col/0x1000000 set col=col-a*0x1000000 endif set r=col/0x10000 set col=col-r*0x10000 set g=col/0x100 set b=col-r*0x100 call SetUnitVertexColor(u,r,g,b,a) endmethod endstruct private function init takes nothing returns nothing local integer i=0 // Don't run textmacros you don't own! //! textmacro ARGB_CHAR takes int, chr set i=0 loop exitwhen i==16 set i2cc[$int$*16+i]="$chr$"+i2cc[$int$*16+i] set i2cc[i*16+$int$]=i2cc[i*16+$int$]+"$chr$" set i=i+1 endloop //! endtextmacro //! textmacro ARGB_SUFCHAR takes int, chr //! endtextmacro //! runtextmacro ARGB_CHAR( "0","0") //! runtextmacro ARGB_CHAR( "1","1") //! runtextmacro ARGB_CHAR( "2","2") //! runtextmacro ARGB_CHAR( "3","3") //! runtextmacro ARGB_CHAR( "4","4") //! runtextmacro ARGB_CHAR( "5","5") //! runtextmacro ARGB_CHAR( "6","6") //! runtextmacro ARGB_CHAR( "7","7") //! runtextmacro ARGB_CHAR( "8","8") //! runtextmacro ARGB_CHAR( "9","9") //! runtextmacro ARGB_CHAR("10","A") //! runtextmacro ARGB_CHAR("11","B") //! runtextmacro ARGB_CHAR("12","C") //! runtextmacro ARGB_CHAR("13","D") //! runtextmacro ARGB_CHAR("14","E") //! runtextmacro ARGB_CHAR("15","F") endfunction endlibrary sample? JASS:library sandbox initializer init requires ARGB private function init takes nothing returns nothing local ARGB y= ARGB.create(0,2,3,4) local ARGB x= 0xFF010203 call BJDebugMsg(I2S(x.alpha)+" "+I2S(x.red)+" "+I2S(x.green)+" "+I2S(x.blue) ) set x= y call BJDebugMsg(I2S(x.alpha)+" "+I2S(x.red)+" "+I2S(x.green)+" "+I2S(x.blue) ) set y=0x72468912 call BJDebugMsg(I2S(y.alpha)+" "+I2S(y.red)+" "+I2S(y.green)+" "+I2S(y.blue) ) call BJDebugMsg(I2S(x.alpha)+" "+I2S(x.red)+" "+I2S(x.green)+" "+I2S(x.blue) ) endfunction endlibrary Looking for ways to optimize the getters, specially if it is possible to make them inline-friendly. Must make setters... Edit: now that I think of it, setters are impossible. Edit: If anyone has the right RGB values for teamcolor stuff I'll appreciate it. |
| 07-11-2008, 02:53 AM | #2 |
I'm fairly certain it's just 255, 128 and 0 shuffled up a bunch. Also, did you declare a method operator = or something? I just don't understand: local ARGB = 0xFF010203 Isn't that like.... a HUGE number? |
| 07-11-2008, 02:58 AM | #3 | ||
Quote:
Quote:
|
| 07-11-2008, 03:10 AM | #4 |
RGB teamcolors are, if I recall correctly, something like: Red = (255,0,0) Blue = (0,0,255) Teal = (0,128,128) Purple = (255,0,255) Yellow = (128,128,0) Orange = (255,128,0) Green = (0,255,0) Pink = (255,128,128) Gray = (128,128,128) Lightblue = (128,128,255) Darkgreen = (0,128,0) Brown = (something) Black = (0,0,0) |
| 07-11-2008, 03:36 AM | #5 |
I don't think the real values were prime colors? |
| 07-11-2008, 03:40 AM | #6 |
no, they have some slight variation. The one I like the most was on the helper. Ill see if I can go find it. Code:
Red: |CFFFF0303 |R (255,3,3) Blue: |CFF0042FF |R (0,66,255) Teal: |CFF1CB619 |R (28,230,185) Purple: |CFF540081 |R (80,0,129) Yellow: |CFFFFFF01 |R (255,255,1) Orange: |CFFFE8A0E |R (254,138,14) Green: |CFF20C000 |R (32,192,0) Pink: |CFFE55BB0 |R (229,91,176) Grey: |CFF959697 |R (149,150,151) Light Blue: |CFF7EBFF1 |R (126,191,241) Dark Green: |CFF106246 |R (16,98,70) Brown: |CFF4E2A04 |R (74,42,4) |
| 07-11-2008, 09:48 AM | #7 |
So, umm, that works? I mean, it's obviously going to go above the max array index... with no struct members, you can do that? But why implement it as a struct anyway, couldn't you just make it a library of regular functions? |
| 07-11-2008, 01:22 PM | #8 |
cause c.red is prettier than ColorInteger_GetRed(c) |
| 07-11-2008, 06:13 PM | #9 |
u r my hero <3 JassHelper > all. |
