Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, dBc), 18,430 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How can I define a STRUCTURE in plugin DLL and use it #278101
07/12/09 07:46
07/12/09 07:46
Joined: May 2009
Posts: 7
micmoc Offline OP
Newbie
micmoc  Offline OP
Newbie

Joined: May 2009
Posts: 7
MY GOAL
I wanna put my custom STRUCTURE definition and it's methods in a plugin dll, and then use them in my project.

QUESTION
Functions works well, but when I using the structure SED said the structure was a undeclared identifier.

NEED HELP
How can I define a STRUCTURE in a plugin dll and use it in SED?

I HAVE DONE THIS
I learned from the acknex manual and found it only says how to write functions into a dll and call them in .c files at chapter "plugin SDK", follow that I created a dll with one function only use ENGINE OBJECT TYPE. I named this dll "DllTemplate.dll" and copy it to acknex_plugins folder. It works.

I put my structure and methods in the dll source like followed code, Compile and update the acknex_plugins folder files.

Code:
/************************************************
*
*THE "DllTemplate.dll" SOURCE
*Name:DllTemplate.cpp
*Node:Those code compile the DllTemplate.dll file
*Using:VS2008 C++
*
*************************************************/
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <math.h.>
// engine specific header file
#define DLL_USE	// always define before including adll.h
#include "adll.h"

/************************************************
*MY STRUCTURE DEFINE HERE
*************************************************/
typedef struct DllStruct
{
	BMAP *m_pBmap;
}DllStruct;


BOOL APIENTRY DllMain( 
  HANDLE hModule,
  DWORD ul_reason_for_call,
  LPVOID lpReserved)
{
  engine_bind();
  return TRUE;
}

/************************************************
*FIRST FUNCTION, IT WORKS WELL
*************************************************/
DLLFUNC void PanelBgChange(PANEL* pPanel, BMAP *pBmap)
{
  pPanel->bmap = pBmap;
}
/************************************************
*MY STRUCTURE TEST METHOD
*************************************************/
DLLFUNC DllStruct* CreateDllStruct( BMAP *pBmap)
{
	DllStruct *DllStructInst = new DllStruct;
	DllStructInst->m_pBmap = pBmap;
	return DllStructInst;
}



And then I write these in SED to test the dll.
Code:
/************************************************
*
*THE DLL TEST PROGRAM SOURCE
*Name:DllTest.c
*Node:Those code do some tests of the DllTemplate.dll file
*Using:SED
*
*************************************************/
#include<acknex.h>
BMAP *pDllBg = "images\btn_jump.jpg";
BMAP *pBgImg = "images\btn_empty.jpg";

//The test result shower. The panel.bmap shows the different states.
PANEL *pDllTestPanel = 
{
	pos_x = 100;
	pos_y = 100;
	flags = VISIBLE;
	digits(0,0,"Press A",*,0,0); 
}

//Declare the functions defined in dll
void PanelBgChange(PANEL* pPanel, BMAP *pBmap);
DllStruct* CreateDllStruct( BMAP *pBmap);

//main function
function main()
{
	level_load("");
	wait(2);
	//create a dll structure instance
	DllStruct *pDllStructInst= CreateDllStruct(pBgImg);
	pDllTestPanel.bmap = pDllStructInst.m_pBmap;
	while(1)
	{
		if(key_a)
		{
			PanelBgChange(pDllTestPanel, pDllBg);
		}
		else
		{
			PanelBgChange(pDllTestPanel, pBgImg);
		}
		wait(1);	
	}
}



SED told me ERROR:
'DllStruct' undeclared identifier.
<DllStruct* CreateDllStruct( BMAP *pBmap);>.

So I have to put this code in front of main function.
Code:
/************************************************
*
*STRUCTURE DEFINITION 
*Node:This is a part of DllTest.c
*Using:SED
*
*************************************************/
typedef struct DllStruct
{
	BMAP *m_pBmap;
}DllStruct;



This time everything is Ok.

But I wanna put this STRUCTURE DEFINITION in the dll.
How can I do that?

Thanks to read.

Last edited by micmoc; 07/13/09 06:51.
Re: [help]How can I define a STRUCTURE in plugin DLL and use it [Re: micmoc] #278136
07/12/09 10:55
07/12/09 10:55
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
As far as I understood your problem, you want to declare your struct in your dll, and use it in your script without declaring it there. That's not posible. You haeve to declare it in your script.
That's not even possible for engine structs. Just take a look into acknex.h wink

Re: [help]How can I define a STRUCTURE in plugin DLL and use it [Re: Lukas] #278165
07/12/09 13:45
07/12/09 13:45
Joined: May 2009
Posts: 7
micmoc Offline OP
Newbie
micmoc  Offline OP
Newbie

Joined: May 2009
Posts: 7
Thanks Lukas.
Rewrite acknex.h and other files can compile my code in the acknex.dll.It works.
But others who has my source can't compile it again.
Thanks a lot.

Re: [help]How can I define a STRUCTURE in plugin DLL and use it [Re: micmoc] #278217
07/12/09 17:31
07/12/09 17:31
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Better don't put it in acknex.h. Put it in your main script or make your own header you can include.

Re: [help]How can I define a STRUCTURE in plugin DLL and use it [Re: Lukas] #278323
07/13/09 06:30
07/13/09 06:30
Joined: May 2009
Posts: 7
micmoc Offline OP
Newbie
micmoc  Offline OP
Newbie

Joined: May 2009
Posts: 7
Receive it.Thanks.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1