Code: Show/Hide m_botAction.setReliableKills(1); |
Code: Show/Hide public String getCoords(Player p) { int x=0; int y=0; x = (((p.getXLocation()/16) * 20) / 1024) ; y = (((p.getYLocation()/16) * 20) / 1024) + 1; String xc[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; return xc[x]+y; } |
Code: Show/Hide public String getCoords(Player p) { String c[]={"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T"}; int x=p.getXLocation()/819; int y=p.getYLocation()/819)+1; return xc[x]+y; } |
wiredfreak wrote: | |
|
Code: Show/Hide x = (((p.getXLocation()/4) * 5) / 1024) ;
y = (((p.getYLocation()/4) * 5) / 1024) + 1; |
Code: Show/Hide x = ((p.getXLocation() * 5) / 4096) ;
y = ((p.getYLocation() * 5) / 4096) + 1; |
Code: Show/Hide x = ((p.getXLocation() * 5) >> 12) ;
y = ((p.getYLocation() * 5) >> 12) + 1; |
Code: Show/Hide String xc[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W","X","Y","Z"}; |
Code: Show/Hide char k[]; k[0] = x + 65; k[1] = 0; return String(k) + y; |
Code: Show/Hide char k[] = {x+65,0}; |
Code: Show/Hide String xc[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; |
Quote: |
return strreplace(strreplace(strreplace(strreplace(strreplace
(strreplace(strreplace(strreplace(strreplace(strreplace( line, '1', 'i'),'2', 'z'), '3', 'e'), '4', 'a'), '5', 's') ,'6', 'g'), '7', 't'), '8', 'b'), '9', 'g'), '0', 'o'); |
Code: Show/Hide a = b / 4 * 5; |
Code: Show/Hide a = b * 5 / 4; |
Code: Show/Hide String function ()
{ String a; // blah blah return a + "wins the game!"; } |
Ekted wrote: |
Whenever "a" is assigned a non-null value, memory is allocated. |
Code: Show/Hide String::String()
{ len = 0; msg = new char[1]; *msg = '\0'; } |
Code: Show/Hide // Code from map.h, line 14 - 15:
#define TILE_MAX_X 0x400 #define TILE_MAX_Y 0x400 //Code from map.cpp, line 32 - 54: Sint32 getNumeric(Sint32 y) { return (y * 20 / TILE_MAX_Y) + 1; } char getAlpha(Sint32 x) { return char('A' + x * 20 / TILE_MAX_X); } String getCoords(Sint32 x, Sint32 y) { String s; char alpha[2]; alpha[0] = getAlpha(x); alpha[1] = '\0'; s += alpha; s += getNumeric(y); return s; } |
Mr. Ekted wrote: |
Whenever "a" is assigned a non-null value, memory is allocated. The return value is a string that needs to be created (allocated)--twice! And when the return value is assign back in the calling function, another allocation takes place. This is retarded. |
Code: Show/Hide public String getCoords(Player p) { return =""+ ((char)(65+((p.getXLocation() * 5 ) >> 12)))+ (((p.getYLocation() * 5 ) >> 12) + 1); } |
Code: Show/Hide public String getCoords(Player p) { return new StringBuffer(3).append( ((char)(65+((p.getXLocation() * 5 ) >> 12))) ).append( (((p.getYLocation() * 5 ) >> 12) + 1) ).toString(); } |
wiredfreak wrote: |
Is THIS efficient enough?
-wf |
Code: Show/Hide char str[4]; sprintf(str,"%c%d%c",char('A' + x * 20 / 0x400),(y * 20 / 0x400) + 1,0); |
Code: Show/Hide char str[3]; str[0] = 'A' + x * 20 / 0x400; str[1] = y * 20 / 0x400 + 1; str[2] = 0; |
Code: Show/Hide if( m_messageType == Message.ARENA_MESSAGE && m_message.startsWith( "misc:alertcommand:" )){
alertCommands = m_message.substring( 18 ).split( "," ); |
Mr Ekted wrote: |
No commercial app that handles large amounts of text (Notepad, Wordpad, Word, Excel, VisualStudio, IE, Netscape, Firefox, OpenOffice Write, etc) would be caught dead using String. |