Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Starting to make a plugin (not using visual Studio tho)

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Apr 2017 01:33
Well, I've got as far as I can trying to make a DLL plugin.

I don't want to interface T2 AppGameKit, but I'm being forced to supply a ReceiveAGKPtr() function in my DLL.

My bare DLL is exporting clean references which are set up in the commands.txt file, but I get a crash because I'm not supplying the ReceiveAGKPtr() function in my DLL.

Incidentally, I am writing the DLL in Delphi, so I can't use any of the example stuff from the headers supplied in the example.

Is there a way for me to return something that satisfies ReceiveAGKPtr() or ignore it? Can it be overridden in the commands.txt file?

Thanks
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Apr 2017 07:40
I'm playing around in C#, with the help of Chamaeleons helpful sample code.
I have an empty ReceiveAGKPtr() function, with no reference to it in the Commands.txt file. this is working fine.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Apr 2017 15:07
ReceiveAGKPtr() is called by AppGameKit and sends in a pointer to the GetAGKFunction so your DLL can register AGK's function set, you dont need to actully register any functions unless you intend to use them but you do need to declare the ReceiveAGKPtr() function with 1 pointer pram and no return.

however, you will need to register the CreateString() and DeleteString() functions if you want to reciece and return strings in your DLL and altho strings are defined as 'S' in the commands.txt you actully need to send back the string pointer created with CreateString and when recieving string data from AppGameKit you need to call DeleteString to clear its allocated memory when your done with it.

so far we have working examples in C++, C# and PureBasic, it would be nice to add Delphi to the list to, lol
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Apr 2017 15:31
Hmm. I've tried to create an empty function, but it still crashes. How is your blank ReceiveAGKPtr() function defined?

Ah, it's OK - it's working now I was actually returning NIL or NULL or something - now I return nothing (gives me a warning when I compile the DLL, but it works!)
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Apr 2017 15:59
my ReceiveAGKPtr() simply returns 0, in PB any function with no return value set will return integer 0 by default, try setting return type to integer and Result as 0 to satisfy the compiler and avoid crashing in AGK

the problem could be a null taking more memory than a 0, I think null's take 2 bytes and integers only one (depending on language and platform I guess), anyhow, its worth a try, I hate compiler warnings! lol
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Apr 2017 17:44
I've ground to a halt again (C#). Every time I make a change to my code, the ReceiveAGKPtr stops working. I can compile, but when I use the DLL in AppGameKit it tells me I must "export the ReceiveAGKPtr function undecorated."
I haven't changed this function in any way.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Apr 2017 20:15
I've got it working now - basic FMOD wrapper incoming

You were right not to put anything in the commands.txt file - I thought I could over-ride it this way.
For what it's worth, I got my delphi DLL ReceiveAGKPtr() function behaving by doing this:



It gives me a warning in delphi that function may not have a return value but it works nevertheless.
My exported name is just ReceiveAGKPtr which is undecorated, as are all the others. Did you check what it looks like in dependency walker? Easier to just export the references as clean names I think.

After I upload my sample plugin, it may be useful to create a sticky for people to put their plugins for others to use?

good luck!
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Apr 2017 20:16
Quote: "
so far we have working examples in C++, C# and PureBasic, it would be nice to add Delphi to the list to, lol
"


Where's the list?
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Apr 2017 20:21
Here's my FMOD plugin with instructions and sample project.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 18th Apr 2017 22:39
@Batvink: No luck when you set the result of ReceiveAGKPtr() to 0?

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 24th Apr 2017 22:31
Ok, so far playing with the Adder DLL I've managed to compile the DLL and get AppGameKit to compile a test.

When I go to run it though AppGameKit says "Failed to load plugin 'Adder' required by this app. It may not be available for this platform."

I'm setting everything up for x86 so I'm not sure what I need to do at this point. Still searching but I thought I'd throw this up here in case someone has an idea how to move past this part.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 24th Apr 2017 22:52
Not had that message, but perhaps you haven't put it in the compiler folder in the right way. Have you put a commands.txt in there as well?
I've just checked my example and it still works on the 2014.04.24 version.

Another guess could be you didn't name your DLL as "windows.dll"

My import line:


means that there should be a folder called "SimpleFMODWrapper_By_Nzo" in the folder "\App Game Kit 2\Tier 1\Compiler\Plugins"
in that folder should be a "commands.txt" and your DLL named as "windows.dll"

You don't need to put anything in your app folder (unless your DLL needs it) as the DLL and structure will be copied at compile time.

OK, I just played around with my setup and renaming the (source) windows.dll creates the same error.. I guess it's this then?

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 24th Apr 2017 23:17
Ah. Missed the part about renaming to Windows.dll. That helped move forward.

I was writing this response in parts, but I made a change and recompiled and IT WORKED!
Now let's see if I can take that as a template and recreate my database plugin.
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 26th Apr 2017 02:25
It seems AppGameKit is being a little schizophrenic. I've been messing with my plugin now for a day with no luck, then went back to the Adder plugin
to try it out and now it's failing to be recognized, where it worked fine yesterday. I didn't change anything with Adder, so I don't know what's
up with this.

The AppGameKit compiler is saying "add" is not a recognized function or command.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 26th Apr 2017 19:03
Hmm.. Not sure about that one.
Perhaps you should load your DLL into dependency walker and check that the exported names are correct?
Failing that, something with the commands.txt file I think..
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 26th Apr 2017 22:14 Edited at: 26th Apr 2017 22:15
I hate to assume but I'm guessing that it's normal for Dependency Walker to throw a bunch of errors for files it can't find.

Other than that, the function names look fine. They are undecorated, which simplifies things, but I'm not sure what I'm doing wrong here.

The C# code for a test connection to a MySQL database

AppGameKit Test Code

Commands.txt file
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 27th Apr 2017 00:33
Take the ReceiveAGKPtr out of the commands.txt file for a start, but leave it in your c# code as it is.

I'll have to assume you have the following file structure in "\App Game Kit 2\Tier 1\Compiler\Plugins"

[folder] DBConn
windows.dll (your DLL renamed)
commands.txt

Also, I think you need to something with the way you address your plugin.

#import_plugin DBConn

should be like this:

#import_plugin [name as per folder] as [alias]

e.g.
#import_plugin DBConn as myDB

Then, address the methods like:

DB = myDB.dbconnect(connStr)

I think that should do it!
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 27th Apr 2017 01:30
Hmm.. it was the missing reference to the plugin itself.

I changed it to DB = DBConn.DBConnect(connStr) and it worked.
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 29th Apr 2017 00:02
I have it all working now except for passing strings.

In the plugin guide it references calling agk::CreateString(size) if you intend your function to return a string to AGK.

I'm not at all sure how to do that in C#. I'm searching and doing a lot of reading, but not having much luck with it.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 29th Apr 2017 01:49
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 29th Apr 2017 02:49
They are passing just fine from AppGameKit to the plugin. It's returning a string that causes crashes because you have to execute agk::CreateString(len) from within the plugin and pass that back to the AppGameKit app.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 29th Apr 2017 16:36
Oh right. Not tried returning a string back to AppGameKit yet.

Login to post a reply

Server time is: 2024-11-24 16:22:46
Your offset time is: 2024-11-24 16:22:46