Allegro.cc - Online Community

Allegro.cc Forums » The Depot » AMGC2 Loader

This thread is locked; no one can reply to it. rss feed Print
 1   2 
AMGC2 Loader
juvinious
Member #5,145
October 2004
avatar

I wrote a command line utility to load AMGC2 plugins, making it easier for me to test and develop new plugins without having to load the GUI each time. The benefit of course is that it doesn't require me to use MASkinG and allows me to play the game. :)
I've tested it with all the plugins on Miran's page and they all work except Blocks and Chess.
This is not to circumvent Miran's work however and for the full experience it's recommended that you use AMGC2. But it could help others that don't have MASkinG or no desire to install it to play and enjoy the games. And hopefully entice other developers into creating more content for AMGC2.
For more information check the page below or the archive.

Links:
Web Page
source

Feedback is appreciated. :)

[edit]
Added the archive in case the links don't resolve.

__________________________________________
Paintown

miran
Member #2,407
June 2002

Nice. The links don't seem to work though. Could be a firewall thing on my side...

Anyway, the games are basically just plugins and IGame.h fully defines the interface, so yeah, anyone can make a client. :) I assume yours just plays the games and doesn't do any fancy stuff like settings and highscores?

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Updated the links, hopefully they'll go through.
If not then there's probably an issue with no-ip.com.

It does offer a menu for doing the settings and save them in a .cfg file. You can also create key bindings manually for it like you do in amgc2 in the .cfg file. I don't see the need for keeping highscores so I left that out. It does however print out your highscore on the cl when you are done. :)

One thing to note is that many of the games, mine included, are dependant on the location from which they are started. ie they look for their data files and what not in ./games/pluginname
so most of them need to be setup just like they were setup to be used in AMGC2.
I was hoping that the SetGamePath() and game_path were to be used for that reason, that way plugins can just use "game_path + resource" to load their data and there wouldn't be a problem. But that's just hopefull wishing. :P

__________________________________________
Paintown

miran
Member #2,407
June 2002

The thing is I only added SetGamePath (is that what it's called? I forget) not long ago, in one of the most recent versions. So most of the games don't use it and still assume to be located where the author put them...

EDIT: Links still don't work for me. I just get "loading ..." in the browser status bar and it never stops... :( EDIT: Actually it's "waiting for <your ip> ..."

--
sig used to be here

Richard Phipps
Member #1,632
November 2001
avatar

juvinious
Member #5,145
October 2004
avatar

Miran: ok I attached the archive in the first post. :)

__________________________________________
Paintown

miran
Member #2,407
June 2002

As I said, could be a firewall thing on my side. I'm at work and there are some pretty paranoid people here, so half the internet doesn't work half the time...

EDIT: I get this when running buildme.bat:

Creating directory obj/...
Creating directory dep/...
Building...
Compiling main.cpp...
Linking amgc2load.exe...
c:/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libmingw32.a(main.o)(.text+0x
97):main.c: undefined reference to `WinMain@16'

EDIT: Adding END_OF_MAIN() fixed that. It works :) but it crashes on shutdown... :-/

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Oops forgot to add END_OF_MAIN()
I'll fix that and update, haven't tested it out on anything but linux.
Thanks. :)

[edit]
Ok fixed the END_OF_MAIN()
miran:
Hmm crashes on exit? Doing what exactly?
After loading a game?
I've added some of your DEBUG("main.log") messages to the main.cpp.
Recompile with "buildme.bat debug" (you might need to do buildme.bat clean first) and then try running again and post the main.log please. :)

__________________________________________
Paintown

miran
Member #2,407
June 2002

When I build in debug mode it says it can't load the dll... :-/

Otherwise this is what it prints:

Initiating Allegro
Loading game numbers.dll
Successfully loaded Numbers
This plugin has no configuration settings
Couldn't init sound. Please check your configuration
Disabling sound
Opening in window
Allocating screen buffer
Please wait while game initiates . . . . . done!
Your score was: 1
Unloading Resources
Shutting down

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Hmmm, when I get a chance I'll get my other box and play around with it on windows. So far that looks fine btw, could be problematic when deleting the game from memory, I'll need to check on that. But I assume the game otherwise plays fine?
Thanks again. :)

__________________________________________
Paintown

miran
Member #2,407
June 2002

I'm home now, on Linux, and the program doesn't work! Any game I try it says this:

Loading game template.so
Failed to load games/template/template.so

Doesn't matter if I build in debug or normal mode. When run in debug mode the main.log file looks like this:

main.cpp, main (203)
amgc2_wrapper.h, GetPlugin (319)
amgc2_wrapper.h, GetPlugin (322)
amgc2_wrapper.h, Plugin (244)
amgc2_wrapper.h, Load (262)
amgc2_wrapper.h, Load (265)
amgc2_wrapper.h, Load (274)
amgc2_wrapper.h, Load (280)
amgc2_wrapper.h, Load (289)
amgc2_wrapper.h, Load (294)
amgc2_wrapper.h, Plugin (246)
main.cpp, main (218)

I just compiled the source, put the binary in the AMGC directory and ran it with amgc2loader games/template/template.so. Doing the same on windows works (although I haven't tried all games) except for crashing on exit...

Btw, I noticed the following passage in your readme.txt:

readme.txt said:

The benefit of course is that you don't need to
have MASkinG installed to play games. :)

I'd just like to say that you don't need to have MASkinG installed to play games with the original AMGC2 either. You just need MASkinG if you want to build the source code, which is only really applicable on Linux...

--
sig used to be here

Audric
Member #907
January 2001

juvinious said:

(...) they all work except Blocks (...)

Curse my metal body, I didn't update to the latest AMGC2 interface.

miran
Member #2,407
June 2002

I think you don't need to change anything in the code, just recompile. The zip on the AMGC2 homepage has a windows exe that is already compiled with the latest specification. :)

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Hmm I figured out why it crashes on exit. Deleting the module from outside is not a good idea, which I was doing. You do include a creational method:

extern "C" DLLEXPORT IGame* GetPlugin() 
{
  return new somegame;
}

It would be nice to add an additional:

extern "C" DLLEXPORT void DestroyPlugin(IGame *game)
{
        delete game;
}

It's recommended that deletion take place from inside the module just to play it safe.

Oh and about not having MASkinG installed, I was more referring to having the entire AMGC2 installed and having to load the GUI each time to play/test a plugin. Which is what my utility allows me to do. I'll reword it...

And the crashes loading plugins on linux seem to be a pain and consistent.
Currently I'm pulling code from amgc's source and dumping into one file. Which could be that I might be overlooking something. I'm going to fix this and not extract code, but include from off the amgc2 source directory and use the methods directly where possible or wrap them. This will probably prevent any failures/incompatibilities between the two and will keep the source consistent with the latest amgc2.
Thanks again. :)

__________________________________________
Paintown

miran
Member #2,407
June 2002

Quote:

It's recommended that deletion take place from inside the module just to play it safe.

Yeah, you're right. I'll make it so in the next revision while trying to keep backwards compatibility. :)

Quote:

And the crashes loading plugins on linux seem to be a pain and consistent.

They're not crashes, the plugins simply fail to load. I took a look at your code and it doesn't seem like you're doing anything any different than me. I really have no idea why simply loading a .so wouldn't work in your program when almost identical code works just fine for me. :-/

--
sig used to be here

Thomas Fjellstrom
Member #476
June 2000
avatar

Do either of you check dlerror for the reason the plugins are failing to load?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

miran
Member #2,407
June 2002

There is dlerror? :o :P

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Yes sir:
Check me out.

[edit]
*** just to clarify it's just an example of it in use, if you want more information check out the man pages.

__________________________________________
Paintown

Thomas Fjellstrom
Member #476
June 2000
avatar

I grepped through juvi's code, and didn't find one, so I had to ask.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

juvinious
Member #5,145
October 2004
avatar

I updated the source to work mostly off of amgc2's source so you are going to need to have it to compile it, which will hopefully eliminate most if not all incompatibility issues.
The script will automatically grab what it needs under *nix systems and build it. On windows you are going to have to manually attain the source tarball and extract it somewhere then pass the src dir with "buildme.bat --dir c:\somedir\amgc2\src".
Follow the instructions in the README file.
:)
The links and the attachment in the first post have been updated.

__________________________________________
Paintown

Audric
Member #907
January 2001

Attached is the fixed version of Blockman, runs fine with AMGC2 Loader (tried MingW), except... the loader seems to reset and/or ignore the configuration ?
Blockman attempts to WRITE in the config file to save the last played level.

push_config_state();
char path[1024];
snprintf(path, sizeof(path), "%s%s.cfg", game_path, GetName());
set_config_file(path);
set_config_int("settings", blocks_settings[1].name, blocks_settings[1].value);
pop_config_state();

Works fine, and is generic enough to suit any installation (game_path and GetName())

miran
Member #2,407
June 2002

Still doesn't work on linux. But now it says it failed to load .so (any .so I try, doesn't matter which) and then crashes...

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

Ok I've updated it once again. Fixed tons of stuff and cleaned up the code. It's at version 1.8.

Audric: Blocks works great and the configurations save correctly now with the latest changes. :)

miran: I'm developing this in linux, I don't know what could be wrong. It re-uses your amgc2 code to properly handle the plugins. Could you try the latest version and see if it fixes any issues? Could be that the plugins need to be recompiled?

Thanks all. :)

__________________________________________
Paintown

miran
Member #2,407
June 2002

I'll test when I get home this afternoon. I don't think anything needs to be recompiled because I recompile AMGC at the same time as your loader and it works while your loader doesn't. It's really weird... :-/

EDIT: Now it prints a different set of messages but basically still doesn't work:

Initiating Allegro
Opening in window
Please wait while game initiates...
Loading game template.so
Failed to load template.so

Oops! There was a problem with the plugin
Terminating
Unloading Resources
Shutting down

--
sig used to be here

juvinious
Member #5,145
October 2004
avatar

That is very strange it shouldn't have a problem, especially if the plugins are being built against the same source.
Well hopefully the latest one works for you, if not I'm at a loss and I can only guess the best thing to do is to put in some more error checking for the .so loading routine. Also evaluating where specifically it's crashing might help too.

[edit]
Hmm I just posted and it seems you did too.

Quote:

EDIT: Now it prints a different set of messages but basically still doesn't work:

Initiating Allegro
Opening in window
Please wait while game initiates...
Loading game template.so
Failed to load template.so

Oops! There was a problem with the plugin
Terminating
Unloading Resources
Shutting down

template.so? :o
template.so isn't loading then.
Hmm could be a problem with cwd and paths, I had issues with that before I thought I fixed it. :-/
Try passing 'amgc2load ./template.so'
Because if the plugin loaded fine it would have given you another error msg.

__________________________________________
Paintown

 1   2 


Go to: