Server Help

Bot Questions - Mervbot + .NET

Maverick - Sun Apr 24, 2005 12:00 pm
Post subject: Mervbot + .NET
Bah what a crappy search feature!

Sorry to ask you this, but I knew there was a topic of .NET and .dll (Mervbot) coding and how to setup.
Does someone know the topic title so I can search for it? (Or post a link sa_tongue.gif )

Thanks
Solo Ace - Sun Apr 24, 2005 12:52 pm
Post subject:
What?! MERVBot and .NET?!
D1st0rt - Sun Apr 24, 2005 1:10 pm
Post subject:
I don't remember a thread about it but there are two ways you can go about using framework classes in merv. You can make it all managed c++ by compiling with /clr, or you can use the wrapper used in this code
Cyan~Fire - Tue Apr 26, 2005 11:08 pm
Post subject:
Or you could just write modules how they're supposed to be written?
Cyan~Fire - Tue Apr 26, 2005 11:15 pm
Post subject:
Double post... sorry. I'm too tired.
50% Packetloss - Wed Apr 27, 2005 3:48 am
Post subject:
Are you asking for direction for setting up a new dll project with VC++ .net, mav? I can walk you through that if that is what you need.
Maverick - Wed Apr 27, 2005 5:07 am
Post subject:
yup, I was figuring how Visual Studio .NET might be so much better IDE to use. Also, I was wondering if you can make .dll plugins with the .NET architecture.
Solo Ace - Wed Apr 27, 2005 8:34 am
Post subject:
Good one, Cyan.

Hey Mav, want to help me writing Python scripts in ASM? Or maybe C in VB?
50% Packetloss - Wed Apr 27, 2005 12:47 pm
Post subject:
File->New->Project
Open the folder Visual C++ Projects and then the win32 folder. On the right side, click on win32 project, name it and press ok.
A new window will open. On the left, click on "Application Settings" and click the DLL radio button on the right. Then click the "Empty project" box and "finish."

I suppose you could probably use all the .net stuff in a dll, but I have never used it and don't plan on it, ever. The IDE is very nice but you don't need to use all the microsoft BS (like MFC and .net).
Bak - Wed Apr 27, 2005 1:12 pm
Post subject:
or open the provided .sln files with the core or the template plugin
Maverick - Wed Apr 27, 2005 2:12 pm
Post subject:
ty I will try that
2dragons - Wed Apr 27, 2005 5:08 pm
Post subject:
50% Packetloss wrote:
File->New->Project
Open the folder Visual C++ Projects and then the win32 folder. On the right side, click on win32 project, name it and press ok.
A new window will open. On the left, click on "Application Settings" and click the DLL radio button on the right. Then click the "Empty project" box and "finish."


That's a great start.

Next:

1. From Menu Select: Project
2. Then select: [Project Name] Properties, where [Project Name] is the name of your project
3. On left of new menu click the C/C++ folder
4. Select Precompiled Headers from the options within that folder
5. On the right set Create/Use Precompiled Headers to Not Using Precompiled Headers

And:

1. Change #include <fstream.h> -> #include <fstream>
2. Set your namespace, using namespace std; or specify the namespace where appropriate in your code.
3. This should work for most general cases.
Dark Clouds+ - Thu Apr 28, 2005 12:30 am
Post subject:
^ What he said. ac_withstupid.gif
50% Packetloss - Thu Apr 28, 2005 2:50 am
Post subject:
Precompiled headers? It shouldn't matter.
Don't use fstream, always use stdio.h, it is sexier.
D1st0rt - Thu Apr 28, 2005 7:39 pm
Post subject:
Ekted will declare a jihad on anyone who uses iostream in his presence >.<
Cyan~Fire - Fri Apr 29, 2005 12:11 pm
Post subject:
Yeah, probably MERV would be faster than TWCore if he used <stdio.h> icon_razz.gif
CypherJF - Fri Apr 29, 2005 12:56 pm
Post subject:
*PMs ekted #include <iostream>*

mWah!


So cyan, you've got a summer job; to fix up merv. icon_wink.gif


*still waiting for catid to put in that patch you suggested*
Solo Ace - Fri Apr 29, 2005 12:57 pm
Post subject:
Haha, now that'd be some bad summer job.
Maverick - Fri Apr 29, 2005 2:31 pm
Post subject:
CypherJF wrote:
*still waiting for catid to put in that patch you suggested*

catid.ssihosting.com wrote:
This latest release includes a tiny fix for the encryption thanks to Cyan~Fire, but no new features.

That patch you mean? icon_smile.gif
CypherJF - Fri Apr 29, 2005 2:58 pm
Post subject:
No. I mean the negative time issue that causes awarp detection to fail after 27+ days.
Cyan~Fire - Fri Apr 29, 2005 11:06 pm
Post subject:
I also emailed a code-oriented fix (I don't think it would have had any effect on runtime) to him a while ago (I mean, way before the encryption thing), but no response. :-/

I've actually seriously considered fixing up MERV, not just in iostream but in a lot of the ways it does things, but 1) yes, it would suck; and 2) I'm not sure catid would even accept it.
Maverick - Sat Apr 30, 2005 7:57 am
Post subject:
you would help alot of people that are using mervbot. Mervbot is still lacking on some things. Fixing those would make it a very good bot.
If you'd ask him for permission first I think he would gladly agree since he doesn't develop on it himself anymore.

I am still hoping someone can fix mervbot such a way so you can remotely host more then the theoratical 3 bots without having alot of ploss.
CypherJF - Sat Apr 30, 2005 11:28 am
Post subject:
Aye, he'd probably allow it...
liito-orava - Sun May 01, 2005 4:47 am
Post subject:
Maverick wrote:
I am still hoping someone can fix mervbot such a way so you can remotely host more then the theoratical 3 bots without having alot of ploss.

Is it a problem that only exists in mervbot? I thought the reason might be that the server refuses to send more than x bytes/s to one ip and thus having 3 clients would increase the traffic over the limit x B/s.

And in new subgame you can define botip and the limit does not apply on that ip.

I haven't tried it myself so I don't know if it could be solved with that or not.
Maverick - Sun May 01, 2005 9:01 am
Post subject:
hmmm I should try that one time
EDIT: Thanks alot for that tip, liito-orava! I just hosted 9 bots without a single sign of ploss biggrin.gif icon_biggrin.gif $$$

Do you, or anyone else, know if you can specify more then one IP at that server.ini setting? (I assume comma seperated if its possible)

Another suggestion for mervbot would be to have each plugin in a seperate thread. So if one plugin takes up some recources, it doesn't lock up all bot(s).
Cyan~Fire - Sun May 01, 2005 11:19 am
Post subject:
Are you kidding? Multi-threaded plugins would go absolutely insane with synchronization! It would require a re-write of essentially the entire MERVBot code and all existing plugins...

You should really read up on threads and the problems associated with them before you start suggesting their use. icon_razz.gif
Maverick - Sun May 01, 2005 11:53 am
Post subject:
oooh cool lol
Well I was only thinking about the good sides of threading then of the bad sides ;p
(got kinda sick one plugin can d/c the whole bot lol)
Solo Ace - Sun May 01, 2005 12:27 pm
Post subject:
Try, and catch.
50% Packetloss - Sun May 01, 2005 1:04 pm
Post subject:
Just wait until ekted releases powerbot. I'm not sure when that will be though, and the core will probably remain closed-source.
In my opinion, powerbot is far superior to mervbot, just the mysql support will blow your load. The documentation is awesome, plus everything you need is in one header file.
Maverick - Sun May 01, 2005 2:08 pm
Post subject:
neato biggrin.gif

(However I would hate to port all my mervbot plugins to powerbot though lol)
Maverick - Mon May 02, 2005 3:17 am
Post subject:
Maverick wrote:
Do you, or anyone else, know if you can specify more then one IP at botsip server.ini setting? (I assume comma seperated if its possible)

Anyone know?
Purge - Mon May 02, 2005 3:34 am
Post subject:
No, it's not possible. If you enter more than one, it'll look only at the first IP.
Maverick - Mon May 02, 2005 5:35 am
Post subject:
bah, too bad
liito-orava - Mon May 02, 2005 6:59 am
Post subject:
Guess would need to set somekind of proxy thing so that it'd look like all are from same IP or use shared connection..

It's quite surprising that since such feature was added to subgame they didn't make multiple ip's configurable to it.
Cyan~Fire - Mon May 02, 2005 12:45 pm
Post subject:
Try and catch? What does that have to do with this?
Solo Ace - Mon May 02, 2005 1:18 pm
Post subject:
Heh, Cyan, I was waiting for someone to ask about it. sa_tongue.gif
I might be wrong ^ 2 here, but as what Mav said "(got kinda sick one plugin can d/c the whole bot lol)" I think he complains there about it how plugins can mess the whole bot up when something fails.
But, I guess in the newer versions catid already prevented plugins from crashing the bot, so that might not be what he meant.

I was thinking about using try and catch to prevent the code from crashing the bot, but, after all I think I was wrong.

Let's ask Mav what he actually meant with that, function calls deadlocking the bot or something?

Heh, liito-orava, as I think I've seen in other posts of yours, what you're saying in your post here is irrelevant to the topic, maybe more than what I said. sa_tongue.gif
Maverick - Mon May 02, 2005 4:36 pm
Post subject:
What I exactly meant was that when a single plugin takes up 100% CPU time for a single operation it can d/c one or multiple bots/spawns since its unresponsive and gets d/c due to no data.
Bot crashes are more the fault of the coder of the plugin, and indeed, catid thought of that and made a catch method for it icon_smile.gif
Having the bot threaded would solve this problem (i think).
Solo Ace - Mon May 02, 2005 5:52 pm
Post subject:
How would another thread solve the issue if the plugin's taking the whole CPU for itself already?
D1st0rt - Mon May 02, 2005 8:24 pm
Post subject:
Because with the sockets on another thread it wouldn't timeout while waiting for a plugin to do something?
Maverick - Tue May 03, 2005 6:21 am
Post subject:
Exactly
Solo Ace - Tue May 03, 2005 1:35 pm
Post subject:
The point of my post, was, in theory: If the CPU hangs on one thread, how would it be able to run the other one then? sa_tongue.gif
Cyan~Fire - Tue May 03, 2005 4:15 pm
Post subject:
He means that if one plugin (which would be in its own thread) deadlocks, it won't deadlock the entire bot, which would be true. But it's quite impractical to have each plugin in its own thread.

Now what would be good is to have each spawn in its own thread.
Maverick - Tue May 03, 2005 5:13 pm
Post subject:
yea, agreed cyan~fire
Cyan~Fire - Tue May 03, 2005 9:20 pm
Post subject:
Code: Show/Hide
//////// Multi-threading ////////

DWORD WINAPI ReceiveLoop(LPVOID parameter)
{
   Host *h = (Host *)parameter;
   UDPPacket packet;
   int len, FromLen = sizeof(INADDR);

   while (len = recvfrom(h->sid, packet.msg, PACKET_MAX_LENGTH, 0, packet.src.getAddress(), &FromLen))
   {
      WaitForSingleObject(h->mutex, INFINITE);
      packet.len = len;
      if (h->validateSource(packet.src))
      {
         h->gotPacket(packet.msg, packet.len);
         if (h->killMe)
         {
            ReleaseMutex(h->mutex);
            break;
         }
      }
      ReleaseMutex(h->mutex);
   }

   SetEvent(h->done); //any better way of telling when a thread exits?

   return 0;
}


It's working. (Shhh, Ekted, don't criticize my code, it's just a hack for now!)
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group