PLUGIN: DirectMusic plugin

Started by modgeulator, Wed 28/04/2004 03:15:15

Previous topic - Next topic

TheMagician

Ah, that's messy but it works.
So in order to use the F5 command I need the plugin and all associated files in the Compiled-, _debug- and Game-Folder?

And another short question:
The plugin uses only one function: DMRoutine(string);

If I type DMRoutine("PlayBackground");

I get an error: Type mismatch: cannot convert 'const string' to 'string'

What do I have to type instead?

monkey0506

That would be because as of AGS 2.71 any string-literals, i.e. the text "PlayBackground" (including quotes), are defined as const strings so-as to be compatible with the new String type. The only workarounds in this situation are to rebuild the plugin (changing string to const string where appropriate within the plugin) or to stick to AGS 2.7 or earlier. :-X

TheMagician

Thanks monkey. I understand.
Sticking to <2.7 is not an option so I wonder: if I wanted to go through the plugin source code what would I need to do that? Does the DirectX SDK provide the necessary tools to view change and compile the code? Or do I need even more advanced stuff like Visual Studio or something?

Scorpiorus

As SSH suggested in the past, another, quite messy yet working method would be to set up a temporary "string" variable and pass it instead:

Code: ags

string temp;
StrCopy( temp, "PlayBackground" );
DMRoutine( temp );


You can probably write a wrapper for each function that expects "string" as parameter.

Or write a converting function to return "string":

Code: ags

string buffer;
string to_string( const string text )
{
    StrCopy( buffer, text );
    return buffer;
}

...

DMRoutine( to_string("PlayBackground") );


Just avoid using the last method when passing to function defined in the script and not a plugin as it can potentially mess things up if not handled properly.

TheMagician

Scorpiorus, your suggestion to write a converting function to return "string" works very well.
Just for the sake of completeness (if anybody is trying to use this code as well) you need to deactivate "Enforce new-style strings" in the general game settings to use the type string used in Scorpiorus' code.

The remaining question is:
what software do I need to have a look at the plugin's source code and to modify and recompile it? Does the DirectX SDK suffice or do I need Visual Studio?

scotch

You can read and modify the c++ code in whatever text editor you prefer, but yes you'll need both VS and the DX SDK to compile it. The free Visual C++ Express is enough.

Scorpiorus

Quote from: TheMagician on Tue 11/12/2007 23:51:45Just for the sake of completeness (if anybody is trying to use this code as well) you need to deactivate "Enforce new-style strings" in the general game settings to use the type string used in Scorpiorus' code.

Ah yeah indeed, sorry for not having mentioned that bit. I'm glad you got it compiled anyway :)

SMF spam blocked by CleanTalk