Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
#include stuff for Merv

 
Post new topic   Reply to topic Printable version
 View previous topic  prize3.dll plugin Post :: Post Quickwin prevention  View next topic  
Author Message
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri Sep 21, 2007 2:34 pm    Post subject: #include stuff for Merv Reply to topic Reply with quote

I have made some classes that I can use with many plugins... however, I'd like all my plugin projects to refer to the same file, instead of copying the file to 5 folders, and it's a pain when I need to update stuff, it gets all mixed up...

Here's the current situation:

lvzdisplay class needs a reference to botInfo to be able to use lvz toggling functions...

so in lvzdisplay.h i have:

Code: Show/Hide

class botInfo;
...

void setparent(botInfo * _parent) { parent = _parent; };


however, in lvzdisplay.cpp, I can't just #include lvzdisplay.h, because it needs the references to object_target(), queue_enable(...), queue_disable(...), and toggle_objects()
So I have to #include spawn.h in there...

Is there any way to just tell him that object_target() and the others are methods of botInfo?

If I could get rid of the whole #include spawn.h, I could really make this class independant of the plugin...

I was thinking something along the lines of
Code: Show/Hide
class botInfo;
void botInfo::clear_objects();
void botInfo::object_target(Player *p);
void botInfo::toggle_objects();
void botInfo::queue_enable(int id);
void botInfo::queue_disable(int id);
in my header, but that doesn't work...
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat Sep 22, 2007 1:30 am    Post subject: Reply to topic Reply with quote

Your only option would be to put your custom code in a subclass of botInfo so then your plugin-independent code could access it through polymorphism. I'm not sure how well that would work, though, it's been a while since I've used MERVBot.
_________________
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
View users profile Send private message Add User to Ignore List Visit posters website
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat Sep 22, 2007 12:48 pm    Post subject: Reply to topic Reply with quote

I don't get the problem...
You use Visual Studio, right?
Right-Click Project->Add...->Existing Item...

Doesn't copy the file just adds it to the project.
Make a folder "Common" put everything in there, add it to projects. Done.
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat Sep 22, 2007 1:06 pm    Post subject: Reply to topic Reply with quote

The thing is, because of the references to the botInfo class I need, my lvzdisplay.cpp (the code of the common class I want) needs #include spawn.h
... so for every plugin, the spawn.h path will be different
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat Sep 22, 2007 2:03 pm    Post subject: Reply to topic Reply with quote

Add spawn.h to the "Commons" dir and add it to Visual Studio's search path.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Sep 22, 2007 2:46 pm    Post subject: Reply to topic Reply with quote

or use separate folders and "#include ../spawn.h"
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat Sep 22, 2007 2:56 pm    Post subject: Reply to topic Reply with quote

But won't it cry because of a 'class redefinition' ? It will have 2 botInfo classes to compile
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat Sep 22, 2007 3:24 pm    Post subject: Reply to topic Reply with quote

If, just remove the one not in the common folder.
It won't be needed anyways.

Now that I think about it.
You might not need to copy spawn.h at all as it's include in the project anyways.

Just try it out! tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun Sep 23, 2007 1:05 am    Post subject: Reply to topic Reply with quote

You guys don't really get it... the way MERVBot is setup you modify the actual botInfo class to make your bot do whatever it wants. Therefore you can't have one common class for all your plugins since it actually defines what your plugin does.

That's why I suggest reorganizing it a bit so that all the plugin-specific class inherit from botInfo.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Sep 23, 2007 3:54 am    Post subject: Reply to topic Reply with quote

yeah..but polymorphysm... inheritance... never done that before.. bleh
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Sep 23, 2007 5:17 am    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
You guys don't really get it... the way MERVBot is setup you modify the actual botInfo class to make your bot do whatever it wants. Therefore you can't have one common class for all your plugins since it actually defines what your plugin does.

That's why I suggest reorganizing it a bit so that all the plugin-specific class inherit from botInfo.


You didn't get the problem icon_smile.gif
You're right with what you said, but he didn't modify the botInfo class!
He made a class that has a pointer to a botInfo and therefore it will just work like I told him (if the methods are public).
All he needs to do is to tell the compiler what methods botInfo has.
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Sep 23, 2007 1:17 pm    Post subject: Reply to topic Reply with quote

Quote:
You're right with what you said, but he didn't modify the botInfo class!
But I DO need to modify the botInfo class for each different plugins afterwards


Quote:
All he needs to do is to tell the compiler what methods botInfo has.
That's what I'd want to do...but how?
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Sep 23, 2007 3:01 pm    Post subject: Reply to topic Reply with quote

Samapico wrote:
But I DO need to modify the botInfo class for each different plugins afterwards

But the code will be different for all plugins, if I got that correctly.
If not you can still put it into a function and put that function into commons.


Samapico wrote:
That's what I'd want to do...but how?

Take a look at what I wrote again. I already told you.

Anyways, I'm off to France for a week. Good Luck.
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Sep 23, 2007 3:22 pm    Post subject: Reply to topic Reply with quote

Okay... one last post before I go to bed.

It might not compile, because I didn't try it out.
But it should work like that.

common.h
Code: Show/Hide
#pragma once
#include "spawn.h"

void doSomething(botInfo *bi, Player *p);


common.cpp
Code: Show/Hide
#include "common.h"

void doSomething(botInfo *bi, Player *p)
{
  bi->sendMessage(p, "It works");
  return;
}


spawn.cpp
Code: Show/Hide
#include "spawn.h"
#include "common.h"

void botInfo::EventTick() // I didn't code a plugin in a while
{
  doSomething(this, somePlayer);
}


Add common.h and common.cpp to project (not copying them).
If it's unable to find them, update the search path.

icon_smile.gif
Hope that helped.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Sep 24, 2007 9:11 pm    Post subject: Reply to topic Reply with quote

Oh, I see what you mean now Bob Dole. Yes, that would work, but that's very messy...
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Tue Sep 25, 2007 1:58 am    Post subject: Reply to topic Reply with quote

Who's Bob Dole?

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 65 page(s) served in previous 5 minutes.

phpBB Created this page in 0.554621 seconds : 41 queries executed (91.8%): GZIP compression disabled