http://user.supradigital.org/jcnossen/M ... edTest.zip
Test.exe inside passes "d:/sdks/mono-1.1.18/lib" to mono_set_dirs by default. You can pass the correct path to it through the commandline like:
Code: Select all
test c:/Mono-1.1.18/lib
Moderators: hoijui, Moderators
Code: Select all
test c:/Mono-1.1.18/lib
Ok, interesting.jcnossen wrote:I wrote an example to demonstrate mono_delegate_to_ftnptr:
http://user.supradigital.org/jcnossen/M ... edTest.zip
Test.exe inside passes "d:/sdks/mono-1.1.18/lib" to mono_set_dirs by default. You can pass the correct path to it through the commandline like:
Code: Select all
test c:/Mono-1.1.18/lib
Code: Select all
test H:\bin\Mono-1.1.18\lib
Code: Select all
impdef.exe mono.dll
Code: Select all
lib /out:mono.lib /def:mono.def
Code: Select all
void SendTextMsg( const char *message, int priority )
{
WriteStringToFile( message );
aicallback->SendTextMsg( message, priority );
}
Code: Select all
[MethodImpl(MethodImplOptions.InternalCall )]
public extern static void SendTextMsg( [MarshalAs(UnmanagedType.LPStr)]string message, int priority );
Code: Select all
SendTextMsg( "Hello world", 0 );
Code: Select all
/**
* mono_string_to_utf8:
* @s: a System.String
*
* Return the UTF8 representation for @s.
* the resulting buffer nedds to be freed with g_free().
*/
Code: Select all
void SendTextMsg( MonoString* strobj, int priority )
{
char *msg = mono_string_to_utf8(strobj);
WriteStringToFile( msg );
aicallback->SendTextMsg(msg, priority );
g_free(msg);
}
Good thing I asked; I'd have taken weeks to figure that out by myself.jcnossen wrote:Marshalling isn't used on internal calls, this is what mono uses internally so you get MonoObject* parameters for everything that is an object. (MonoObject maps to System.Object)
mono_string_to_utf8 comment in metadata/object.c:So that results in:Code: Select all
/** * mono_string_to_utf8: * @s: a System.String * * Return the UTF8 representation for @s. * the resulting buffer nedds to be freed with g_free(). */
however for g_free you will need to link to mono/lib/glib-2.0.lib,fortunately they provided a .lib for that already.Code: Select all
void SendTextMsg( MonoString* strobj, int priority ) { char *msg = mono_string_to_utf8(strobj); WriteStringToFile( msg ); aicallback->SendTextMsg(msg, priority ); g_free(msg); }
Code: Select all
namespace AILauncher
{
class TestClass
{
public:
int x;
int y;
};
};
using namespace AILauncher;
Code: Select all
TestClass *MonoObjectToTestClass( MonoObject *incomingobject )
{
TestClass *myobject = new TestClass();
MonoClass*thisclass = mono_object_get_class(incomingobject);
mono_field_get_value (incomingobject, mono_class_get_field_from_name (thisclass, "x"), &(myobject->x ) );
mono_field_get_value (incomingobject, mono_class_get_field_from_name (thisclass, "y"), &(myobject->y ) );
return myobject;
}
// called from cs to send a TestClass object to cpp
void SendObject( MonoObject *incomingobject )
{
TestClass *myobject = MonoObjectToTestClass( incomingobject );
cout << "x: " << myobject->x << " y " << myobject->y << endl;
delete myobject;
}
Code: Select all
MonoObject *TestClassToMonoObject( TestClass *testobject )
{
MonoClass *monoclass = mono_class_from_name( image, "AILauncher", "TestClass" );
MonoObject *monoobject = mono_object_new ( domain, monoclass );
mono_runtime_object_init( monoobject );
mono_field_set_value (monoobject, mono_class_get_field_from_name (monoclass, "x"), &(testobject->x) );
mono_field_set_value (monoobject, mono_class_get_field_from_name (monoclass, "y"), &(testobject->y) );
return monoobject;
}
// called from cs to obtain a TestClass object with x = 12; y = 235
MonoObject *GetTestClass()
{
TestClass *someobject = new TestClass();
someobject->x = 12; someobject->y = 235;
MonoObject *monoobject = TestClassToMonoObject( someobject );
delete someobject;
return monoobject;
}
Code: Select all
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = true)]
public class MarshallAsCNullTerminatedString: Attribute
{
// nothing needed here, empty class
}
MadRat,MadRat wrote:I hate to interupt your development, but I noticed that this ai dll crashes alot on maps with a central obstacle, like plains and passes and the painted desert remake. The ai didn't last more than three minutes on either map.
silp,silp wrote:csai (newsest and 25th of october version, also the new loader dll) crashes for me instantly on 73b1 / aa 2.23 after the 3 sec countdown on smalldivide and core_faf (didnt try other maps). it doesn't create any logs, the error is an unhandled exception in globalai dll or something like that. i installed .net 1.1 (on win 2k) (didn't reboot after, but it didnt require that) and i think i installed the 6 files in the correct directories and also made a copy in the old aidll dir to play with the old ta-singleplayer exe. any ideas / information you need?
Check.hughperkins wrote: MadRat,
...Could you download a new version of csailoader.dll from http://manageddreams.com/utils/csailoader.dll , overwrite the version currently in AI/Bot-libs, and see if the problem still exists?
Ditto on the last check. Didn't see that folder there, but I created one for it now.hughperkins wrote: Also, if it crashes again, could you send the logfile from the AI/CSAI directory to me at hughperkins@gmail.com ?
I've been testing it with two plain jane AA and two CSAI bots, one each running ARM and the other CORE. All are in their own seperate groups. I've tried it in both AA 2.23 and XTA v7 and got the same results.hughperkins wrote: Are there any other AIs running at the same time?