[SOLVED] Issues setting up plugins

Posted By: MatAllum

[SOLVED] Issues setting up plugins - 11/25/13 01:36

I'm relatively new to the use of lite-c (long time c-script user here) and I'm having some issues getting the plugin system to work. I've written a plugin for our team project that allows easy customization of game parameters, but actually getting A8 to recognize it is another story.

The manual tells me I can just drop the DLL in the acknex_plugins folder; I've tried that as well as having it directly in the working game folder to no avail. The impression I've gotten is I only need to prototype the DLL functions and they will just work. SED still recognizes dll_open but the manual says I haven't needed it since A6.

Below is the sample code; the engine complains on startup that I'm calling an empty function. Am I missing something?

Code:
#include <acknex.h>

function registerObjectType(STRING* name, var objectSize);
function registerVariable(STRING* name, var targetObjectType);
function loadConfigData(STRING* name);
function getObjectIndex(STRING* name);
function getDataStructure(var* destination, var type, var index);

function main()
{
	registerObjectType("Test", 4);
}

Posted By: Quad

Re: Issues setting up plugins - 11/25/13 10:21

This part does not help at all, how you define your functions in your DLL code?
Posted By: MatAllum

Re: Issues setting up plugins - 11/25/13 12:24

Like this:

Code:
DLLFUNC var registerObjectType(STRING* name, var objectSize)
{
    int result = OTL.createObjectType(std::string(name->chars), _INT(objectSize));
    return(_VAR(result));
}

DLLFUNC void registerVariable(STRING* name, var targetObjectType)
{
    OTL.registerVariable(_INT(targetObjectType), std::string(name->chars));
}

DLLFUNC void loadConfigData(STRING* name)
{
    OTL.loadFileData(std::string(name->chars));
}

DLLFUNC var getObjectIndex(STRING* name)
{
    int result = OTL.objectIndexForName(std::string(name->chars));
    return(_VAR(result));
}

DLLFUNC void getDataStructure(var* destination, var type, var index)
{
    OTL.retrieveStruct(destination, _INT(type), _INT(index));
}

Posted By: 3dgs_snake

Re: Issues setting up plugins - 11/25/13 12:49

And you need to add
Code:
BOOL APIENTRY DllMain( 
	HANDLE hModule,
	DWORD ul_reason_for_call,
	LPVOID lpReserved)
{
	engine_bind();
	return TRUE;
}

Posted By: MatAllum

Re: Issues setting up plugins - 11/25/13 12:53

Yeah, that's in there, as well as including adll.h.
Posted By: Quad

Re: Issues setting up plugins - 11/25/13 13:44

"function" in lite-c defaults to void, your problem might be because of that. Also you need "#define DLL_USE" BEFORE including adll.h
Posted By: MatAllum

Re: Issues setting up plugins - 11/25/13 21:43

Using var rather than function in the prototype doesn't change it. DLL_USE is in there:

Code:
#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#include <windows.h>
#define DLL_USE	// always define before including adll.h
#include "adll.h"



I don't understand what's going on because I have written plugins for A6 in the past, and they always worked fine.

Edit: Okay, I fixed it. I wasn't doing it quite properly when I originally put the DLL in the game folder. It's fine now.
© 2024 lite-C Forums