Jump to content

  •  

akka

Member Since 11 Jan 2014
Offline Last Active Mar 29 2015 04:08 PM
-----

Topics I've Started

Splitting large plugin into multiple files.

14 February 2015 - 06:08 PM

Hi my plugin project has grown into a huge inconvenient file, so i tried to split it into a number of files. For example i created atcommands.c and atcommands.h

 

 

 

atcommands.h:

struct atcommands_interface {	bool (*atcommand_test) (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info);};struct atcommands_interface *atcommands;

atcommands.c

ACMD(test){//testreturn true}

Then in the "main" plugin file with the HPExport functions put this:

/* HPMi->addCommand */#define addAtcommand2(cname,funcname) 	if ( HPMi->addCommand != NULL ) { 		HPMi->addCommand(cname,funcname); 	} else { 		ShowWarning("HPM (%s):addAtcommand("%s",%s) failed, addCommand sub is NULL!n",pinfo.name,cname,# funcname);	}

Because the original HPMi->addCommand adds "atcommand_" to the beginning of the atcommand name inorder to call it.

 

and then i just add this as usual:

addAtcommand2("test", atcommands->atcommand_test);

It all compiles just fine, but the map server crashes and I guess its due to missing symbols. Is what im trying to do even possible? I've looked at numerous plugins but all of 'em seems to consist of a .c file and not header files.