ExplodyThingy Posted August 19, 2009 Report Posted August 19, 2009 So I wrote a bot, for several reasons. 1, I was bored. 2, I was rusty on my socket programming and C++ programming. 3. I miss subspace. I'm probably going to keep writing but not really finish it, so to speak as finished as MERBot, or TWCore, or something. Attached is my bot as it stands now. I wrote this on my Mac, so it compiles under a Unix environment. Also everything is hardcoded, no settings or anything yet. It will go so far as make subgame display "Connection Request" and will update ?find's last seen. Most likely I keep rewriting this to keep up with my other languages, like C, Ruby, or Perl for the sake of having done it. I also wrote a UDP echo client. It is nothing but a simple socket that will use subgame as it's echo server. It sends out 8 bytes and triggers subgame to bounce 6 back. Uhm, so yea, here. Judge away.explbot.zipmain.cpp Quote
Bak Posted August 19, 2009 Report Posted August 19, 2009 I heard a great way to practice your C++ skills is to write Discretion modules... Quote
»doc flabby Posted August 19, 2009 Report Posted August 19, 2009 You know subspace works on the mac now Quote
Samapico Posted August 19, 2009 Report Posted August 19, 2009 @splody's avatar: I see your Blacktron, and raise you with Exploriens (looks like a blacktron, anyway, except the borg-like implant ) Quote
ExplodyThingy Posted August 20, 2009 Author Report Posted August 20, 2009 Uh, sure, whatever. I've used that avatar as long as I've ever posted on these forums. Most likely won't change it. Anyone want to post something worthwhile instead of solicit me? How does SS work on the Mac? I have it running in a VM right now. Anyone have a ready-to-go stand-alone ASSS compile ready to work on the Mac? That would be really useful. Quote
»Lynx Posted August 20, 2009 Report Posted August 20, 2009 (edited) SS works on the Mac through wine, just build the latest version from source and apply the process patch - and enjoy. Make sure you enable opengl for decent frame rate, other than that little tweaks here and there make it more playable. There was a few bugs, but nothing major. I also managed to get ASSS to compile on the Mac (I used it to test modules I was working on), however I never actually got ASSS to run on my Mac. -L *latest development build, 1.0.1 won't work. Oh, and you need an intel mac. Edited August 20, 2009 by Lynx Quote
ExplodyThingy Posted August 22, 2009 Author Report Posted August 22, 2009 Thanks Lynx. Attached is the next incarnation, further developed. Still in the early developmental stages though, but you can play with it a bit more. Again, Unix only. I'm considering making it support "plugins," as well as support Snrrrub's recent decryption of the Continuum encryption and SS's encryption. I've never developed anything quite like a plugin or a module from the loader side, and I want to see if I can. Anyone have any advice on where to start, besides ASSS and MERV? MERV can only take me so far, since this is a unix system and that was made for Windows Preferably I want it to be modifiable on-the-fly like MERV can do. I've never played with loading and unloading modules in ASSS.explbot.zip Quote
ExplodyThingy Posted August 23, 2009 Author Report Posted August 23, 2009 5 issues addressed or will be:IO Stream is depreciated, that should just throw a warning. The only reason that IOStream is used is to call close() on the socket descriptor. If anyone knows a better method or a different header I'll use it instead. I know that stl list iterator error too. Should only happens when ~Bot is called, which it is when it disconnects, as it did up there. I've got it bandaged but not properly fixed, meaning it will leak memory at every spawn unload. Since it can only do 1 spawn at a time, that's not a scary issue yet. It involves the STL list that keeps track of player objects, since it's a list of pointers I need to remove them from the list as well as delete them. From time to time malloc throws a hissy fit over a double free() or misplaced free(), and I haven't found it yet, but I've isolated it to the "chunk" class. It doesn't yet support encryption, that's the issue you're seeing there with the inability to connect. It's really verbose. I'll add some command line switches for silent (no output), normal (like merv), verbose (like above, showing inbound/outbound data) and very verbose (showing hexdumps). Quote
ExplodyThingy Posted August 24, 2009 Author Report Posted August 24, 2009 Major improvements on this one. Encryption is supported, and boy was that irritating to tear out of MERVBot, Catid liked to write his own functions for EVERYTHING, even strlen. I got it now though, and it's all loaded into a single header and single source file. Printfs have been removed and replaced with a logger class that will deal with that as well as control verbosity. Not much added to the protocol, except a few random effectively worthless handlers. Line commenting has also increased and I'll go back and add a few more. Still doesn't use a cfg file, everything's hard coded. Comments and input appreciated.explbot.zip Quote
ExplodyThingy Posted August 24, 2009 Author Report Posted August 24, 2009 Yea! I count that as a major success in my book. I'll keep working on it and posting more as I develop it. Quote
ExplodyThingy Posted August 25, 2009 Author Report Posted August 25, 2009 I did more. Have more fun. It won't lag out anymore because it syncs every couple of seconds. I'm not sure if that's how its supposed to work, but it looks like what MERVBot does. It enters spec, according to subgame. It has a config file now, but it doesn't do too much with it, just the 4 important settings for login: server, port, user, and password. The other settings are there as I will add them to the core. The program has grown pretty large, and includes libraries taken from MERVBot and a few places on the Internet. It's fairly well commented, everything I wrote has about 1 comment for every 2 lines, so if you need to follow along, you should be able to.explbot.zip Quote
ExplodyThingy Posted August 27, 2009 Author Report Posted August 27, 2009 Next update and the first major bugfix. When the Bot class was instantiated it copied the username into the password variable. Everything else used password correctly, therefore the bot was sending the username as the password. If you've created bot accounts with this bot, you may want to change their passwords. There are a couple of stability things fixed, and some more that need fixing. Someone should check on my chunk class and see if they can isolate the malloc problem that free() freaks out about on the proper unload of the bot. You can see the issue if you don't terminate it with CTRL-C like I do alot. A couple of commands now work. They function exactly like MERV did, with a switch to control operator access and a long line of ifs to control the commands. I disapprove of that. I want to remake it like ASSS with a hashtable that jumps to functions. I'll burn those bridges later. Keep in mind, !login is uncontrolled and immediately gives everyone full access to the bot. On the plus side, the only restricted command is !die. The config reader is fucked up. Sometimes it works, sometimes it doesn't. It'll load out all the [spawn0] stuff properly and work well with that, but for some reason the [clocks] variables will not load. Others seem to come and go, I haven't quite worked out the issue but I'll get on it. There may not be any updates for a bit, as I'm moving to the other side of the country this weekend, and need to take the time to organize myself and make the move. If people want to contribute, I gladly approve of it. Post it in this forum until I work out a SVN or something. This still requires no outside libraries, I'd like to keep it that way as long as possible. It should also compile error free if you just throw it all at gcc. IOStream is still in there, may throw a warning. That is my highest priority fix, eliminating all warnings. Comments encouraged, positive or negative. Contributions even more so.explbot.zip Quote
Dr Brain Posted August 27, 2009 Report Posted August 27, 2009 There may not be any updates for a bit, as I'm moving to the other side of the country this weekend, and need to take the time to organize myself and make the move. If people want to contribute, I gladly approve of it. Post it in this forum until I work out a SVN or something. On first read, that seemed like a request to help you move. Quote
»Lynx Posted August 27, 2009 Report Posted August 27, 2009 (edited) So the bots password needs to be the same as it's username? Edit: -- Just ran it, there were two major errors with 'gettimeofday(&tim, NULL);' not being declared, however after I commented out both offending lines of code the bot ran fine, good job! -L Edited August 27, 2009 by Lynx Quote
ExplodyThingy Posted August 29, 2009 Author Report Posted August 29, 2009 Yes, if you used the bot to CREATE the account since BEFORE the last posted version, the password is the username. The problem is fixed as of the previously posted version. More: I added more comments throughout the project. I moved some stuff around, bots.h now only has class bot in it. util.h and .c exist and hold the logger and some time control stuff. I'd like to make the logger completely static or remove it from a class altogether, that should be an easy find-replace style fix if they feel like fixing it themselves. STL's hashmap has been used to remake the command structure. It is now very very similar to ASSS, of which I approve. There is also the start of man pages for the commands. I'd like to keep it best practice to have the commands man information be written as the command is written and added to the hashmap as the command is added. I do _not_ have any sort of permissions setup. If someone familiar with the permissions setup of ASSS would like to do that for themselves it is highly encouraged, even if you don't have such extensive knowledge, as long as it's better than MERV. I'd like to find a way to isolate people to permission on certain spawns but also give other people full functional capabilities on every spawn. The packet handlers are still naive and dispatch every packet to its handler regardless of sequence. This should probably be rectified with the hashmap to call functions, and add or remove functions from the map as appropriate for the protocol. Top priority fix: The player enter packet is sometimes repeated several times in the same packet, sort of like the cluster packet. The bot only handles 1 player per one of these packets. If there are two players in the arena when the bot enters, only one of them will register. The other must exist and reenter the arena to get the bot to notice. Many packet types are simply implemented, like player death, score update, KotH info, and such toys. This should be fixed, it would really easy to handle a lot of it now the way I deal with flags, but its sort of a band-aid approach. It would be nice if some handlers were written for it. Reliable packets are simply ACKed and nothing is done to ensure sequencing or in-order processing. This should be fixed and I'm giving it a high priority. Also nothing is sent by the bot reliably. Nothing is clustered, outbound packets should probably be queued up so they can be sent as a cluster if possible. Modules or plugins would be super helpful, once I get to that stage I will begin to think of it as a bot, and no longer a "bot".explbot.zip Quote
ExplodyThingy Posted August 29, 2009 Author Report Posted August 29, 2009 Many packet types are simply implemented, like player death, score update, KotH info, and such toys. Unimplemented. Quote
Samapico Posted August 30, 2009 Report Posted August 30, 2009 The Edit button works nicely, so I heard Quote
»Lynx Posted August 30, 2009 Report Posted August 30, 2009 (edited) In ExplBot.cpp line 38: previously was char *conf = "../path/to/conf"; which worked, however the PATH_TO_CONF; doesn't work for me. I reverted back to the previous and placed the explbot.conf files location, which created the parser however instead of spawning my custom spawn, it spawns the hardcoded spawn. -L [session started at 2009-08-30 21:20:18 +0100.] Activating ExplBot. Spawning krslynx on 209.59.175.210:19911 Spawned. Activating spawn "krslynx". Sending core message type 0x00 01 Sending core message type 0x00 05 Sync Request recieved. Sending core message type 0x00 06 Connection Affirmation recieved. 09 00 6B 72 73 6C 79 6E 78 00 00 00 00 00 00 00 ..krslynx....... 00 00 63 68 61 74 00 00 00 00 00 00 00 00 00 00 ..chat.......... <removed this line for security reasons> 00 00 72 65 67 00 03 00 00 C0 00 00 00 00 00 00 ..reg........... 02 00 00 00 00 00 00 00 00 9D 6F 86 00 BC 01 00 ..........o..... 00 2B 02 00 00 78 56 34 12 00 00 00 00 00 00 00 .+...xV4........ 00 6B 72 73 6C .krsl Sending message type 09 Cluster recieved. Reliable Packet recieved. Sending core message type 0x00 04 Password Response recieved. Successful login. Move along now. Reliable Packet recieved. Sending core message type 0x00 04 We are now past the login sequence. Sending message type 01 Reliable Packet recieved. Sending core message type 0x00 04 Chunk recieved. Reliable Packet recieved. Sending core message type 0x00 04 Chunk recieved. Reliable Packet recieved. Sending core message type 0x00 04 Chunk Tail recieved. Arena settings recieved. Cluster recieved. Reliable Packet recieved. Sending core message type 0x00 04 Recieved Player ID change. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Cluster recieved. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Flag updates recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 Player entering: L Y N X Cluster recieved. Reliable Packet recieved. Sending core message type 0x00 04 Player banner recieved and ignored. Reliable Packet recieved. Sending core message type 0x00 04 An unknown datagram has been recieved: 21 size 1 00 . Reliable Packet recieved. Sending core message type 0x00 04 Recieved map info. Unhandled. Reliable Packet recieved. Sending core message type 0x00 04 We are now in the game. Cluster recieved. Reliable Packet recieved. Sending core message type 0x00 04 Non-core sync recieved. Unhandled. Reliable Packet recieved. Sending core message type 0x00 04 An unknown datagram has been recieved: 1D size 6 08 04 00 29 22 00 ...)". Reliable Packet recieved. Sending core message type 0x00 04 Chat recieved: \213E\213@\211\301\213E\213 > This arena is Continuum-only. Please get Continuum client from http://www.subspace.net to play here Sending core message type 0x00 05 Sync response recieved. Sending core message type 0x00 05 Sync response recieved. Cluster recieved. Reliable Packet recieved. Sending core message type 0x00 04 /Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/debug/safe_iterator.h: [session started at 2009-08-30 21:20:24 +0100.] 221: error: attempt to increment a singular iterator. Objects involved in the operation: iterator "this" @ 0x0xbffff0b8 { type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorIP6playerEEN15__gnu_debug_def4listIS4_SaIS4_EEEEE (mutable iterator); state = singular; references sequence with type `N15__gnu_debug_def4listIP6playerSaIS2_EEE' @ 0x0xbffff0b8 } Loading program into debugger… GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-apple-darwin".Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/cpburke/XCode Projects/Debug/ExplodyBot.app/Contents/MacOS/ExplodyBot', process 41588. The Debugger Debugger is attaching to process Singular Iterator error happens when I exit and enter the arena that the bot is located in. Edited August 30, 2009 by Lynx Quote
ExplodyThingy Posted September 8, 2009 Author Report Posted September 8, 2009 More stuff. Mostly house cleaning, a little tiny bit of protocol work. It's denser, and a little more streamlined. Lots of generalized fixes and todos taken care of, but much remains the same. I don't have Internet, so I'm using a coffee shop. When I get it setup, I'll work on it some more. From what I can think of:ExplBot.cpp renamed main.cppAll settings functions moved to settings.cppA single setlist exists for all "global" settings.command.h made irrelevant and removed.Some possible problems with the playerlist resolved, but not all of them.Help info hashmap made universal instead of unique to each bot.More comments. Of everything I've written, I'd say its about 2:1 comments to code ratio. Thats about how it should be, if not higher. Nothing of the aforementioned fixmes have been addressed, and more FIXME and TODOs are present. Eclipse indicates at least 23 exist in code. I'm also no longer attaching my explbot.conf file because removing my bot's info to make it safe for upload irritates me. Use your existing unless I change it. Hi-Five.explbot.zip Quote
ExplodyThingy Posted September 15, 2009 Author Report Posted September 15, 2009 (edited) Alright, new update. Lots of player event handlers added, so there are a lot less unknown packets. Multiple player entries per packet is now handled properly. You can spawn it into a pub and it will get the list of players just fine. This was a big fix. The malloc and free errors with the chunk class are eliminated but now I have a EAX_BAD_ACCESS problem when I replaced the char array in chunk with a datagram class. This shouldn't ever be an issue except when using !go. This absolutely top priority. More commands added, and it appears to be more stable overall. The continuum encryption is now in the system, but nothing uses it, yet. It will be added soon. The config file has been modified to handle more stuff.src.zip Edited September 15, 2009 by ExplodyThingy Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.