Author |
Message |
Samapico No, these DO NOT look like penises, ok?

Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri Sep 21, 2007 2:34 pm Post subject: #include stuff for Merv |
 |
|
|
|
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:
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 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 |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Sep 22, 2007 1:30 am Post subject: |
 |
|
|
|
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 |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Sat Sep 22, 2007 12:48 pm Post subject: |
 |
|
|
|
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 |
|
 |
Samapico No, these DO NOT look like penises, ok?

Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sat Sep 22, 2007 1:06 pm Post subject: |
 |
|
|
|
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 |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Sat Sep 22, 2007 2:03 pm Post subject: |
 |
|
|
|
Add spawn.h to the "Commons" dir and add it to Visual Studio's search path. |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Samapico No, these DO NOT look like penises, ok?

Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sat Sep 22, 2007 2:56 pm Post subject: |
 |
|
|
|
But won't it cry because of a 'class redefinition' ? It will have 2 botInfo classes to compile |
|
Back to top |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Sat Sep 22, 2007 3:24 pm Post subject: |
 |
|
|
|
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!  |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Sep 23, 2007 1:05 am Post subject: |
 |
|
|
|
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 |
|
 |
Samapico No, these DO NOT look like penises, ok?

Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Sep 23, 2007 3:54 am Post subject: |
 |
|
|
|
yeah..but polymorphysm... inheritance... never done that before.. bleh |
|
Back to top |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Sun Sep 23, 2007 5:17 am Post subject: |
 |
|
|
|
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
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 |
|
 |
Samapico No, these DO NOT look like penises, ok?

Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Sep 23, 2007 1:17 pm Post subject: |
 |
|
|
|
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 |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Sun Sep 23, 2007 3:01 pm Post subject: |
 |
|
|
|
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 |
|
 |
k0zy Server Help Squatter

Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Sun Sep 23, 2007 3:22 pm Post subject: |
 |
|
|
|
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
#pragma once
#include "spawn.h"
void doSomething(botInfo *bi, Player *p);
|
common.cpp
#include "common.h"
void doSomething(botInfo *bi, Player *p)
{
bi->sendMessage(p, "It works");
return;
}
|
spawn.cpp
#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.
Hope that helped. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Mon Sep 24, 2007 9:11 pm Post subject: |
 |
|
|
|
Oh, I see what you mean now Bob Dole. Yes, that would work, but that's very messy... |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Tue Sep 25, 2007 1:58 am Post subject: |
 |
|
|
|
Who's Bob Dole?
Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... |
|
Back to top |
|
 |
|