Need help with building
#1

What's up?
So I wrote this snippet
PHP код:
     switch(P[playerid][Level]){
        case 
0..20SetPlayerColor(playeridCOLOR_NOOB);
        case 
21..50SetPlayerColor(playeridCOLOR_PRISONER);
        case 
51..200SetPlayerColor(playeridCOLOR_SKILLED_PRISONER);
        case 
201..500SetPlayerColor(playeridCOLOR_PROFESSIONAL_PRISONER);
        case 
501..1000SetPlayerColor(playeridCOLOR_DISCORDIA_GOD);
        case 
1001..200000SetPlayerColor(playeridCOLOR_GOD);
    } 
and now compiler frozens! If I comment this snippet up, it will build.
I am using SublimeText to edit/build
Reply
#2

Don't use switch with such large ranges. The compiler generates a jump table with 200002 elements (there is an extra element at the beginning that stores the count of all other elements), which takes at least a minute to compile, if not more. It also affects the runtime performance, so a chain of else if's will probably even be faster here.
Reply
#3

Hue thanks for the fast reply!
EDIT: Works indeed, thanks a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)