Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Bots

Development::Bots Forum for bots.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2014, 09:19 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

temp, xtmp, and tmp are never deallocated.
Reply With Quote
  #2  
Old 01-02-2014, 09:44 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

Quote:
Originally Posted by demonstar55 View Post
temp, xtmp, and tmp are never deallocated.
xtmp doesn't appear to be used at all, and none of those allocations should be done with new since they are fixed size. Since there are multiple returns in the function it'd be a pain to try and figure out which of them need to be deleted before each return but if they are created on the stack it's automatically handled.

You only need one buffer to construct all of the strings you send to the client, there's no reason to allocate one, use it once, then allocate another one the next time you need to construct a message. The sizes are also rather random, 100, 250, 1000 when you can be pretty sure what the upper bound is since the only argument is the name of the spell and that has a maximum size.
Reply With Quote
  #3  
Old 01-03-2014, 11:08 AM
seveianrex
Sarnak
 
Join Date: Sep 2008
Location: asdf
Posts: 60
Default

Quote:
Originally Posted by lerxst2112 View Post
xtmp doesn't appear to be used at all, and none of those allocations should be done with new since they are fixed size. Since there are multiple returns in the function it'd be a pain to try and figure out which of them need to be deleted before each return but if they are created on the stack it's automatically handled.

You only need one buffer to construct all of the strings you send to the client, there's no reason to allocate one, use it once, then allocate another one the next time you need to construct a message. The sizes are also rather random, 100, 250, 1000 when you can be pretty sure what the upper bound is since the only argument is the name of the spell and that has a maximum size.
Thanks! I have updated the original code to fix some of these issues. Apparently become a little too dependent on my GarbageCollector in C#

As of this morning I have also added functionality to allow you to specify target as a 3rd argument which will have the spell casted on your current target (defaults to you if no target).
Also, if you perform this command with one of your ungrouped bots targetted, it will also search their spellbook and use that bot if found. This allows commanding of "buff bots" outside of your group of bots.
Reply With Quote
  #4  
Old 01-03-2014, 02:48 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

Just a couple things to note:

Having comments like your name/date are rather pointless (we use version control software to keep track of that)

We use strcasecmp to compare strings case insensitively. On Windows this is just defined to stricmp, on UNIX it just uses the libc extension strcasecmp. (so you can replace strupr and strcmp)

And I believe (from quickly looking through the other bot code) that the bots Say function works like printf family does. So Say("Butts %s", spell_name); kind of thing should work (so you can remove the char buffer and call to sprintf, it internally does use a buffer and printf stuff, but it's nicer :P)

I would highly recommend looking into making a pull request on GitHub if you would like to see this included, if setting up GitHub is too much, you can always make a post with a unified diff in the code submissions forum.

This post http://eqemulator.org/forums/showthread.php?t=36515 might help with some git stuff.

Personally, I probably wouldn't pull this since I've never touched the bots stuff so I would leave it up to someone else :P
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:38 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3