Skip to content
Home
Post Code
Jass (Warcraft III)
Wurst
GUI (Warcraft III)
Galaxy (StarCraft II)
GUI (StarCraft II)
C++
Java
Delphi
Text
Search Code
Compare Code
Uploads
Draw
Create New Drawing
View Drawings
Graph
Log in
package CustomObjectIdGenerator
int
array
id
constant
heroPrefix
=
'W'
constant
nonheroPrefix
=
'%'
boolean
helperActivator
=
initHelper
(
)
function
initHelper
(
)
returns
boolean
for
int i
=
0
to
2
id
[
i
]
=
'0'
return
true
function
nextValid
(
int c
)
returns
int
int r
=
c
+
1
if
r
=
=
'_'
or
r
=
=
'
,
'or r
=
=
'
"'or r == '\' or r == ' - '
r + +
if r == '_' or r == ', 'or r == '"
'or r
=
=
'\'
or
r
=
=
'
-
'
r
+
+
return
r
function
fourChar
(
int a
,
int b
,
int c
,
int d
)
returns
int
return
(
(
(
(
(
a
*
256
)
+
b
)
*
256
)
+
c
)
*
256
)
+
d
function
newId
(
int prefix
)
returns
int
if
helperActivator
for
i
=
0
to
2
if
id
[
i
]
< '~'
id
[
i
]
=
nextValid
(
id
[
i
]
)
for
j
=
0
to i
-
1
id
[
j
]
=
'
!
'
return
fourChar
(
prefix
,
id
[
2
]
,
id
[
1
]
,
id
[
0
]
)
error
(
"No vaild id left"
)
return
0
public
function
genId
(
)
returns
int
return
newId
(
nonheroPrefix
)
public
function
genHeroId
(
)
returns
int
return
newId
(
heroPrefix
)
Diesen Code in Original-Formatierung anzeigen
select language
> jass
java
delphi
C++
php
GSL
galaxy
visualBasic
wurst
Text
Markdown
select style
default
bbcode - default
Jasscraft
jasscraft html
> visual
lightweight
lightweightNr
goto line:
Compare with:
text copy window
edit this code
post new code
package CustomObjectIdGenerator int array id constant heroPrefix = 'W' constant nonheroPrefix = '%' boolean helperActivator = initHelper() function initHelper() returns boolean for int i = 0 to 2 id[ i ] = '0' return true function nextValid( int c ) returns int int r = c + 1 if r == '_' or r == ', 'or r == '"'or r == '\' or r == ' - ' r + + if r == '_' or r == ', 'or r == '"'or r == '\' or r == ' - ' r + + return r function fourChar( int a, int b, int c, int d ) returns int return((((( a * 256 ) + b ) * 256 ) + c ) * 256 ) + d function newId( int prefix ) returns int if helperActivator for i = 0 to 2 if id[ i ] < '~' id[ i ] = nextValid( id[ i ] ) for j = 0 to i - 1 id[ j ] = '!' return fourChar( prefix, id[ 2 ], id[ 1 ], id[ 0 ] ) error( "No vaild id left" ) return 0 public function genId() returns int return newId( nonheroPrefix ) public function genHeroId() returns int return newId( heroPrefix )