.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Oops!
Old
  (#1)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Oops! - 15-07-2004

The name of the thread does not mean this is a mistake or error, its about an idea.
With metamod plugins you must write out ( or copy ) several exported functions, API tables, ect... Seems like overkill if you just want to write a chat filter plugin don't you think?

This is where OOPS ( Object-Oriented Plugin System ) comes in.
A plugin is created by inheriting from a base class called CPluginBase and overriding the methods they would like to hook.
All plugins will have to export a function called "CreateInstance" which returns a CPluginBase pointer to an instance their plugin class.

Information about the plugin like the title, author, date, ... would be setup by overriding the "GetInfo" method of your class rather than the host plugin ( metamod/oops ) having to lookup and execute a query function.

This is just a small idea I came up with late last night and was wondering wether or not it's worth it to write something like this.

Note: If this thread is in the wrong place I apologize, I figured it would be better here since the plugin loader would be a metamod plugin itself.
  
Reply With Quote
Re: Oops!
Old
  (#2)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Oops! - 16-07-2004

It's a well known method of writing plugins and coding pattern used by professionals to implement plugins to their program. I don't see why it won't be worth it, I know how tedious it can be to have all these functions for metamod plugins and all the return metas etc..
  
Reply With Quote
Re: Oops!
Old
  (#3)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Oops! - 16-07-2004

I don't see the difference with metamod ... ? ???

Code:
C_DLLEXPORT int GetEntityAPI2 (DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
{
   // This exported function declares to metamod which functions from the game DLL interface our
   // DLL will use, by linking each used slot in the gFunctionTable structure to the address
   // of our actual functions. This way, when metamod will bind any function in any slot of
   // gFunctionTable, it will land directly in our functions here, just by following the pointer.
   // These functions will be called by metamod BEFORE calling the actual game DLL function.
 
   static DLL_FUNCTIONS gFunctionTable;
 
   // keep track of pointers to the functions we use in the game DLL API
   gFunctionTable.pfnSpawn = Spawn;
   gFunctionTable.pfnStartFrame = StartFrame;
   gFunctionTable.pfnPlayerPreThink = PlayerPreThink; // for "botcontrol" debug (can be removed)
 
   // copy the whole table for metamod to know which functions we are using here
   memcpy (pFunctionTable, &gFunctionTable, sizeof (DLL_FUNCTIONS));
   return (TRUE); // alright
}



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Oops!
Old
  (#4)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Oops! - 16-07-2004

What we mean here is, i think, something like this
Code:
class CPluginBase
{
public:

...
    virtual ... Spawn (...) { // default Spawn stuff (i.e. call engine spawn etc..?)
    virtual ... StartFrame (...);
    virtual ... PlayerPreThink (...);

...
};

class CMyPlugin : public CPluginBase
{
public:
   // overridden spawn method
   ... Spawn (...)
   {
      // my plugin code
   }

   // overridden startframe
   ... Startframe ()
   {
      // my plugin code
   }

 // didn't over-ride PlayerPreThink and other stuff since we don't need them
   
};
  
Reply With Quote
Re: Oops!
Old
  (#5)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: Oops! - 16-07-2004

Cheeseh is correct, if you want to hook a function it's as simple as overriding it in your class.

There will be similar stuff to metamod such as handling return values and preventing calls to the mod.
To differentiate between pre and post calls a member variable in the CPluginBase class will be set accordingly.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com