Splitting large plugin into multiple files.

akka

New member
Messages
8
Points
0
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.

 
Last edited by a moderator:
hmm..why not split the main plugin into sub plugins?

and why create another 'addAtcommand'?

default_ani_meow.gif


 
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
Code:
ACMD(test){//testreturn true}
Then in the "main" plugin file with the HPExport functions put this:
Code:
/* 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.
You seem to do it in a very confusing way.Back to the point,

Run gdb, it will get you to exact location of crash, and probably that symbol might be missing, or something like that..

(Also, myself i never feel to split a plugin, my plugin is ~3k lines and still growing...)

 
Last edited by a moderator:
Back
Top