Author |
Message |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Sat Apr 16, 2005 2:08 pm Post subject: |
 |
|
|
|
Oh right, this is Java. Didn't notice that little "public" at the top of the function.
At any rate, in this case, the efficiency of Strings doesn't matter, since putting a player's location into human-readable letter-number coordinates is the sort of task that happens only once per user interaction.
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. |
I would call the programmer retarded, not the class. (Then again, looking at the way MERVbot's String class handles growing strings, I might reconsider calling the class retarded anyway.)
[Edit: Never mind. I just looked at the MERVbot String class's source code, and I would have to agree that it is something to be avoided. The class is indeed moronic. The standard library string class is much better.] |
|
Back to top |
|
 |
wiredfreak Newbie
Age:50 Gender: Joined: Apr 14 2005 Posts: 14 Offline
|
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Sat Apr 16, 2005 3:46 pm Post subject: |
 |
|
|
|
Does it compile? There is an equals sign there. I don't know Java very well. The example I gave you was me thinking in C++ code for the MERVbot.
If it works, it would be efficient enough. The efficiency is not too important. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:42 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat Apr 16, 2005 4:52 pm Post subject: |
 |
|
|
|
wiredfreak wrote: | Is THIS efficient enough?
-wf |
Not even close. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Sat Apr 16, 2005 6:24 pm Post subject: |
 |
|
|
|
This conversation is getting absurd.
"Efficient enough" means that the program works fast enough for the user not to notice. Outputting coordinates in string form is a rarely executed task, and a few milliseconds aren't going to hurt anybody. |
|
Back to top |
|
 |
wiredfreak Newbie
Age:50 Gender: Joined: Apr 14 2005 Posts: 14 Offline
|
Posted: Sat Apr 16, 2005 6:51 pm Post subject: |
 |
|
|
|
Sam & Cerium... doh. Yea, the equals wasn't supposed to be there. Me and my typos. heh.
Sam... Hehe... Yea, well, I'm trying to learn a little more about this... even if it doesn't get executed often enough to matter... it helps me.
There's more than one way to do anything... But you're right, Sam.
-wf |
|
Back to top |
|
 |
Underlord Novice
Gender: Joined: Feb 17 2004 Posts: 55 Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Apr 17, 2005 10:50 am Post subject: |
 |
|
|
|
Remember, Ek, this is Java. No char arrays for strings.
Also, I think Ekted talked earlier about the right shift. Please, don't do multiplication like that. The compiler will optimize that for you, and it just makes the code less readable. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sun Apr 17, 2005 12:59 pm Post subject: |
 |
|
|
|
Yes, but even in Java you could return the coords as two integral values and let any code that wants to display human-readable location format it how it likes. |
|
Back to top |
|
 |
wiredfreak Newbie
Age:50 Gender: Joined: Apr 14 2005 Posts: 14 Offline
|
Posted: Tue Jun 07, 2005 9:19 pm Post subject: TWCore crashes when logged in as SMod |
 |
|
|
|
Alright. More TWcore issues. I'm using the latest... TWCore 0.89
I'm just getting back into coding the bot I was working on way back when this topic was created.... So... it's still related.
Here's the issue.... If the bot is logged in as Sysop, there's no problem... HOWEVER.... if I log the bot in as an SMod... The whole thing comes crashing down if ?cheater or any similar command is used which displays a ?cheater type message.
When turning verbose on, I get the following thread of messages:
Tue 05-07-2005 08:07:51 slavebot is logging in.
slavebot logged in: 60 ms.
[Loaded java.lang.IndexOutOfBoundsException from C:\j2sdk1.4.2_07\jre\lib\rt.jar]
[Loaded java.lang.StringIndexOutOfBoundsException from C:\j2sdk1.4.2_07\jre\lib\rt.jar]
Tue 05-07-2005 08:07:54 slavebot is disconnecting...
Tue 05-07-2005 08:07:54 masterbot is disconnecting...
[Loaded java.lang.Shutdown from C:\j2sdk1.4.2_07\jre\lib\rt.jar]
[Loaded java.lang.Shutdown$Lock from C:\j2sdk1.4.2_07\jre\lib\rt.jar]
How do I fix the core so that it can be logged in as SMod instead of Sysop?
-wf |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
|
Back to top |
|
 |
wiredfreak Newbie
Age:50 Gender: Joined: Apr 14 2005 Posts: 14 Offline
|
Posted: Tue Jun 07, 2005 11:59 pm Post subject: |
 |
|
|
|
Unfortunately, this is the only information returned at the point of failure....
However... After mussing with the runbots.bat file and just generally screwing with things.... I tried the following batch command:
java -cp twcore.jar;twcore/misc/googleapi.jar;twcore/misc/mysql-connector-java-3.0.6-stable-bin.jar -verbose -Xdebug twcore.core.Start
What EXACTLY this did to my core execution... I do not know.... However... I know that I STILL get the messages *on the first reception* of the ?cheater type messages... but not again after... and the bot no longer craters.
I can't tell you why this works for me, but it's what I did. Also, since I'm *ONLY* using this to *TEST* and develop my bot before giving it to the owner of the zone to run on his own core bot... I do not need the additional functionality that sysop access grants. That's the primary reason I need this to run as SMod, since I'm only a writer for another zone.
I still have a lot to learn... I'm not an expert at all... but I like to believe I can at least stumble my way through a problem when I need to.
-wf |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Fri Jun 10, 2005 4:35 pm Post subject: |
 |
|
|
|
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. |
Firefox uses string classes. There are a few string-related classes in there. But they don't use Mervbot's String class  |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sat Jun 11, 2005 3:56 pm Post subject: |
 |
|
|
|
I figured out why the alert command thing doesn't work and I should have it fixed when we get our next release out (whevener that is ). What happens is it uses *g* to get the alert commands and since it returns nothing if you're smod it goes out of bounds when looking up by index. If its gonna be too long before an official release, I'll put up a patch on my site. |
|
Back to top |
|
 |
|