fodev.net

FOnline Development => General Discussion => Topic started by: Bartosz on December 06, 2012, 10:25:08 am

Title: FOnlineServer with Mono
Post by: Bartosz on December 06, 2012, 10:25:08 am
Hello,

As of rev383 of the SDK I decided to commit the files of the (rather big) functionality I've been working on lately: embedding Mono runtime (http://mono-project.com/) in the server to allow write scripts in .NET languages.

The files are placed under Server/mono directory and do not affect the current state of SDK. They're meant for testing purposes (the work done was rather large, and sometimes tedious, many bugs could slipped in).

Instructions

To try it out, follow the steps:
1. Replace your FOnlineServer.exe and FOnlineServer.pdb files with the one from mono directory.
2. Check the mono/FOnlineServer.cfg file and copy the lines from # Mono runtime section, most importantly:
Code: [Select]
MonoEnabled=1
MonoLibDir=mono/lib
  The rest is optional.
3. Use either Visual Studio or MonoDevelop to build the provided solution file: mono/FOnline.Mono.sln. The resulting files will be copied to Server directory.
4. Run the server, you should see some mono related messages, most notably 'Initializing mono' and 'Init from mono!' that will tell you everything is OK.

Debugging
There are several ways you can debug your code (and even aid in debugging AS code).

REPL console:

It's possible to start server with console that is evaluating C# statements on the fly. Just add -mono_repl to your server command line.
(https://i.imgur.com/WoamP.png) (http://imgur.com/WoamP)

Line-by-line debugging with MonoDevelop' Soft Debugger:

1. Fetch mono runtime (latest version is 3.0.2, the server currently is integrated with 3.0.1, it should work fine) from their download page (http://www.go-mono.com/mono-downloads/download.html).
2. Install it.
3. Fetch MonoDevelop (http://monodevelop.com/), install it, and before starting, set MONODEVELOP_SDB_TEST environment variable to 1.
4. Now, start MonoDevelop, go to Tools->Options->.NET runtimes and add the one you've installed in step 2. Mark it as default.
5. Open FOnline.Mono.sln, place some breakpoint and choose Run->Run with...->Custom Command Mono Soft Debugger and enter the path to FOnlineServer.exe in Command textbox
6. Choose whatever command line you wish, and add -mono_debug
7. Click listen, and wait for server to be started and your breakpoint hit.
8. Enjoy:
(https://i.imgur.com/wZtK5.png) (http://imgur.com/wZtK5)

More info
The project contains few scripts that mimic few scripts from Den location, this is to show briefly how writing scripts in C# looks like. For more information refer to: wiki page on our trac (http://dev.fonline2238.net/trac.wsgi/wiki/MonoScripting).
Title: Re: FOnlineServer with Mono
Post by: Gob on December 06, 2012, 12:21:16 pm
So what? Instead of AngelScript I can now do VB.NET or C# or C++?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on December 06, 2012, 12:25:46 pm
...or F#.

And not really 'instead', rather 'additionally'.
Title: Re: FOnlineServer with Mono
Post by: Gob on December 06, 2012, 12:27:10 pm
F# huh? I might give it a try. This sure is good news.
Title: Re: FOnlineServer with Mono
Post by: Bartosz on December 06, 2012, 12:45:41 pm
Added info about debugging.
Title: Re: FOnlineServer with Mono
Post by: Gob on December 06, 2012, 11:18:37 pm
Error: Forbidden
WIKI_VIEW privileges are required to perform this operation on MonoScripting
Title: Re: FOnlineServer with Mono
Post by: Bartosz on December 06, 2012, 11:29:30 pm
You need to login with you forum credentials.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on December 07, 2012, 12:39:24 am
Very impressive and exciting. :)

Would it be technically possible to use Java the same way?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on December 07, 2012, 05:40:39 am
Apperently, there is some possibility to run Java under mono, but I wouldn't even try...why everyone asks about that Java lang. Is it any good?  ;D
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on December 07, 2012, 07:39:47 am
Sure, Java is the best. Well, almost... ;D
Java is platform independent and has better IDE support, maybe that's why it rules the world. ;)

But I would like to use it because I am used to it (which makes it faster to develop) and it really has better IDE support than .NET.

But thanks anyway, I found some possibility to use Java from Mono, too, I will have a look and keep you informed whether it is worth it. ;)
Title: Re: FOnlineServer with Mono
Post by: Bartosz on December 07, 2012, 08:49:10 am
Well, but if you are talking about IDE, you would probably want to check if there is mono soft debugger plugin for it, otherwise you won't be able to debug your code in it (and I think debugging is significant part of IDE functionality).
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on December 07, 2012, 09:27:02 am
Code completion, refactoring and debugging, for sure. Thanks, I'll have a look.
Title: Re: FOnlineServer with Mono
Post by: Mr Feltzer on December 24, 2012, 02:22:36 am
Oh this sort of Debugging method would have been very helpful a long time ago. Still, Notepad++ has grown on me..
Title: Re: FOnlineServer with Mono
Post by: OmegaPL on February 10, 2013, 06:14:59 pm
I cant get it working .After " Initializing mono" it crashes.
Code: [Select]
[00:038] FOnline server, version 0504-EB.
[01:621] ***   Starting initialization   ****
[01:630] Initializing mono...
I tried it on newest downloaded sdk. I did it like you said in first post.
I replaced .exe and .pdb files
I added in .cfg:
Code: [Select]
MonoEnabled=1
MonoLibDir=mono/lib
and i built solution file (with some warnings) in visual studio 2012
additionally i had to copy from mono dir file mono-2.0.dll otherwise server wont start
Can you tell me what i'm doing wrong?
I can give you dumps if needed.

(windows 7 x64)
Title: Re: FOnlineServer with Mono
Post by: Bartosz on February 10, 2013, 06:37:46 pm
I think there is problem with latest mono-2.0.dll, could you try with one from rev383?
Title: Re: FOnlineServer with Mono
Post by: OmegaPL on February 10, 2013, 06:43:57 pm
you mean that one from "\fonline_sdk\Server\mono" ?
I'm using exacly that one.


edit:
I didnt saw that im using 385 rev.
like you said .I downloaded earlier version of that file and it is working now , big thanks to You :)
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on May 14, 2013, 08:28:06 am
Are there any performance drawbacks when using C# for development?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on May 14, 2013, 09:14:48 am
Unless there are some unintended memory leaks, then performance should be even better, as AngelScript (as it stands now) is not yet JITted (http://en.wikipedia.org/wiki/Just-in-time_compilation), and the bytecode is interpreted as it goes.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on May 14, 2013, 09:32:50 am
That's nice to hear, thanks. :)
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on May 14, 2013, 02:18:04 pm
Do you plan to update FOnlineServer.exe to be compatible with the latest revision? Current version of mono server is 0504-EB, but the newest revision server has version 0518-F7.

EDIT:
Actually, currently I cannot even start the server as it crashes right after Start (and I also tried 383 revision of mono-2.0.dll).
My bad, I forgot to build the project. I "only" have compilation errors because of incompatibility.

And some additional questions:
1. Is it possible to create linux runnable of mono FOnlineServer and use it?
2. Would it be possible to implement also PlaneBegin, PlaneRun and PlaneEnd CRITTER_EVENTS? I understand that it is needed to do some work on engine to call them otherwise I would implement them by myself.
Title: Re: FOnlineServer with Mono
Post by: Bartosz on May 17, 2013, 03:37:44 pm
Do you plan to update FOnlineServer.exe to be compatible with the latest revision? Current version of mono server is 0504-EB, but the newest revision server has version 0518-F7.

Probably not that fast, so I can't promise anything. Ideally, the source would be open for you to modify, but it's not the case:)

Quote
EDIT:
Actually, currently I cannot even start the server as it crashes right after Start (and I also tried 383 revision of mono-2.0.dll).
My bad, I forgot to build the project. I "only" have compilation errors because of incompatibility.

And some additional questions:
1. Is it possible to create linux runnable of mono FOnlineServer and use it?
Should be possible.

Quote
2. Would it be possible to implement also PlaneBegin, PlaneRun and PlaneEnd CRITTER_EVENTS? I understand that it is needed to do some work on engine to call them otherwise I would implement them by myself.
You are right, and unfortunately I can't promise it's gonna be implemented in near future:(
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 06, 2013, 10:01:27 am
Do you plan to update FOnlineServer.exe to be compatible with the latest revision? Current version of mono server is 0504-EB, but the newest revision server has version 0518-F7.
Probably not that fast, so I can't promise anything.
Thanks for the change in the newest revision. :)

Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 06, 2013, 11:08:37 am
Probably not that fast, so I can't promise anything.

Thanks for the change in the newest revision. :)

No problem, hopefuly I will be able to react faster in the future.

Anyway, can I ask what are you using it for, how it goes etc etc?
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 06, 2013, 12:45:23 pm
No problem, hopefuly I will be able to react faster in the future.

Anyway, can I ask what are you using it for, how it goes etc etc?
I was trying to remake Critter Action DSL (see the example below), which I have done in AngelScript and I wanted to rework it in C# as it is easier to debug and develop with (and also maybe have some performance improvement). But currently I am stuck, because I need also PlaneBegin, PlaneRun and PlaneEnd CRITTER_EVENTS to be implemented in Mono, so currently I am trying to remake it in pure C++. ;D
But nevertheless I plan to develop new features in C# (for the productivity), but I am not very productive on the project, so not having much progress ATM. :)


Critter Action DSL: (I know it is not really a DSL, but just to explain what I mean)
This is meant to be used as a simple language to make it easy to setup roles (actions) for NPCs. See the following example and keep in mind, that it is planed to make it public, when it is in the state of publishing. ;D

Examples: :)
Johny, the hungry kid will try to find a (closest) player and asks him for food. Then he searches if any food is on the ground and picks it up:
Code: [Select]
void _HungryKidInit(Critter& npc, bool firstTime)
{
#define TO_DISTANCE (3)

Action@ action = LoopAction()
.AddSubAction(FindCritters(ClosestPlayer)
.If(IsSeen())
.AddSubAction(LoopAction(2)
.AddSubAction(Follow(TO_DISTANCE))
.AddSubAction(LookAt())
               .AddSubAction(Say(TEXTMSG_TEXT, 70113))
.AddSubAction(Wait(REAL_SECOND(5)))))
.AddSubAction(FindItems(FOOD_ITEMS)
       .AddSubAction(PickUp())
       .AddSubAction(DeleteItems()))
.AddSubAction(Patrol(DEFAULT_PATROL_ENTIRE, true))
.AddSubAction(Wait(REAL_SECOND(3)))
           ;

actionManager.Start(npc, action);
}

Brahmin wondering around:
Code: [Select]
void _InitBrahmin(Critter& npc, bool firstTime)
{
      Action@ action = LoopAction(true)
           .AddSubAction(AttackAttacker())
           .AddSubAction(ChangeDirection(RANDOM_DIRECTION, true))
           .AddSubAction(Wait(REAL_SECOND(5), REAL_SECOND(30)))
      ;
     
      actionManager.Start(npc, action);
}
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 06, 2013, 08:15:20 pm
Nice, it reminds me of behavior trees (http://www.altdevblogaday.com/2011/02/24/introduction-to-behavior-trees)
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 07, 2013, 08:38:52 am
Nice, it reminds me of behavior trees (http://www.altdevblogaday.com/2011/02/24/introduction-to-behavior-trees)
Thanks, finally I know how to name the framework. ;D
It is, indeed, something that is supposed to be very close to it (even if I have never heard of it before). Good to know something like that exists and I can use it as a knowledge base. ;)
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 07, 2013, 09:10:25 am
There used to be tons of info about in on AiGameDev.net
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 10, 2013, 08:15:55 am
First of all, thanks for those missing critter events in the newest revision. :)

Second of all I have a question for you:
Is it possible to define interface in Mono and make an implementation of that interface in AngelScript, so it can be further passed to Mono code for processing?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 10, 2013, 09:49:18 am
At the moment, you could try something like:

C# interface:
Code: [Select]
interface IFoo {
   void Bar();
}

Then, in AngelScript (let's say it's module foo):
Code: [Select]
class FooImpl { // not that it doesn't say anywhere we implement that interface
    void Bar() { ... }
}
FooImpl GetImplementation() { return FooImpl(); }

Back in C#:
Code: [Select]
class FooImplWrapper : IFoo {
    ScriptObject foo;
    public Wrapper(ScriptObject impl) {
        foo = impl;
    }
    public void Bar() {
        foo.Bar(); // dynamic call
    }
}

dynamic module = AngelScript.GetModule("foo");
var foo = new FooImplWrapper(module.GetImplementation());
foo.Bar();

But it's rather ugly, and it's exploiting AS dynamic wrappers which are rather experimental (and do not work with overloaded functions).

I never planned such tight binding (implementing interfaces across different script runtime boundaries), as it bounds to be pretty complicated, so question is, what kind of design decisions led you to such requirement?
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 10, 2013, 10:12:47 am
I never planned such tight binding (implementing interfaces across different script runtime boundaries), as it bounds to be pretty complicated, so question is, what kind of design decisions led you to such requirement?
It is again those Critter Action Behaviour Trees I am working on. I already have system that manages these actions (let's call it Manager) and set of actions in AngelScripts.
What I am thinking is reimplementing Manager in Mono, but to be able to reuse those existing actions by introducing interface in Mono, which existing actions would implement, so I could reuse those actions in Manager in Mono.
The second reason is not to be bound to Mono code, as maybe someone does not want to use it in their project and he can implement actions in AngelScript.
And the third reason is the ability to easily switch between the AngelScript Manager and Mono Manager to e.g. see the difference in performance or just to have fallback Manager in case that your Mono project won't be maintained anymore (not compatible with the newest revision of SDK as it happened after UTF change or you will discontinue the project).

I was trying something like that in C++, so I introduced interface which is then implemented in AngelScript (already existing actions), and create C++ Manager for the actions, but I am struggling with it a bit as I am not advanced user of C++ (as being Java focused), but that's another story :)
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 10, 2013, 10:22:36 am
How does this interface look like? Maybe by looking at methods signatures I could think of something/have better knowledge about those requirements.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 10, 2013, 10:31:54 am
This is the current interface of Action in AngelScript (but it is not in its final state):
Code: [Select]
interface Action
{
Action@ GetSuperAction();
void SetSuperAction(Action@ action);
Action@ AddSubAction(Action@ action);
Action@[] GetSubActions();
void CollectListeningActions(Action@[]& collection);
Action@ And(Action@ andAction);
Action@ If(Condition@ condition);
Action@ IfNot(Condition@ condition);
void PerformAndAction(Critter& critter, Critter@ otherCritter, Item@ item);
bool Check(Critter& critter, Critter@ otherCritter, Item@ item);


bool IsRunning();
void SetRunning(bool running);
bool IsListening();
void SetListening(bool listening);

bool Start(Critter& critter);
void Perform(Critter& critter);
void Finish(Critter& critter);
void Cancel(Critter& critter);
void StartNextAction(Critter& critter);

string GetInfo();

void IdleEvent(Critter& critter);
void ShowCritterEvent(Critter& critter, Critter& showCritter);
void HideCritterEvent(Critter& critter, Critter& hideCritter);
bool AttackEvent(Critter& critter, Critter& target);
bool AttackedEvent(Critter& critter, Critter& attacker);
void DeadEvent(Critter& critter, Critter@ killer);
void MessageEvent(Critter& critter, Critter& messenger, int message, int value);
void SeeSomeoneAttackEvent(Critter& critter, Critter& attacker, Critter& attacked);
void SeeSomeoneDeadEvent(Critter& critter, Critter& killed, Critter@ killer);
void SeeSomeoneAttackedEvent(Critter& critter, Critter& attacked, Critter& attacker);
void SeeSomeoneStealingEvent(Critter& critter, Critter& victim, Critter& thief, bool success, Item& item, uint count);
void SeeSomeoneUseSkill(Critter& critter, Critter& skillCritter, int skill, Critter@ onCritter, Item@ onItem, Scenery@ onScenery);
int PlaneBeginEvent(Critter& critter, NpcPlane& plane, int reason, Critter@ someCr, Item@ someItem);
int PlaneRunEvent(Critter& critter, NpcPlane& plane, int reason, uint& result0, uint& result1, uint& result2);
int PlaneEndEvent(Critter& critter, NpcPlane& plane, int reason, Critter@ someCr, Item@ someItem);
}

And Manager has void Start(Critter& critter, Action& action) function, which starts the action for specified critter.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 25, 2013, 07:21:22 pm
I am scared to ask, but what "Virtual events did nothing good" (https://xp-dev.com/sc/change/76003/408) means?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 25, 2013, 11:04:10 pm
It means I've screwed commit message (commiting from git to svn is tricky).

This commit also involved some project structure refactoring, and it should be described in message instead). Scrapping virtual modifier from events was just minor part of refactor.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 28, 2013, 02:32:06 pm
I have problem running Mono server after the latest changes. I tried it on clean version of SDK, rebuild the Mono solution in MonoDevelop, but executing FOnlineServer.exe and pressing Start server will crash the server without dump file created, so I am not sure why it is happening. Did I forget to do something or there might be a bug introduced?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 29, 2013, 04:34:04 pm
I think I know, and it wasn't explained in commit message because I screwed it (as you already know).

The project is now refactored into core FOnline.Mono.dll and FOnline.Server.exe which is the entry assembly for server. Your FOnlineServer.cfg should have the

MonoAssembly=FOnline.Server.exe

line.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 29, 2013, 04:36:23 pm
I think I know, and it wasn't explained in commit message because I screwed it (as you already know).

The project is now refactored into core FOnline.Mono.dll and FOnline.Server.exe which is the entry assembly for server. Your FOnlineServer.cfg should have the

MonoAssembly=FOnline.Server.exe

line.
Should I wait for fixed revision or MonoAssembly=FOnline.Server.exe should be enough to fix it?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on June 29, 2013, 05:13:56 pm
Should I wait for fixed revision or MonoAssembly=FOnline.Server.exe should be enough to fix it?

Should be enough
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on June 30, 2013, 07:10:30 pm
Should be enough
Didn't help. :(
But the problem seems to be that FOnline.Server.exe is not built in Server directory (or anywhere else) after rebuilding the project (I am trying to rebuild Server using Debug|x86). Any suggestions?

EDIT:
Nevermind, I missed incorrect Output path of Assembly set for FOnline.Server project. :)
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on July 02, 2013, 09:27:35 am
When I run mono server, NPC dialogs are not working at all (invoking via scripts or clicking on NPC). Do you know about the problem?

Note: I have tested it also on vanilla SDK.
BTW: Do you have any issue tracker where I could entry such issues?
Title: Re: FOnlineServer with Mono
Post by: Bartosz on July 02, 2013, 10:30:19 am
BTW: Do you have any issue tracker where I could entry such issues?

https://bitbucket.org/rotators/fosrc/issues
Title: Re: FOnlineServer with Mono
Post by: Skycast on July 02, 2013, 01:04:58 pm
https://bitbucket.org/rotators/fosrc/issues
It is only for issues with mono or for all bugs related to fonline sdk?
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on July 02, 2013, 10:03:20 pm
Title: Re: FOnlineServer with Mono
Post by: Bartosz on July 03, 2013, 09:04:33 am
Quote
It is only for issues with mono or for all bugs related to fonline sdk?

For now it's a place for mono-related things, but it would definitely be only for engine-related issues.

Any particular thing you've had in mind?

  • Is it safe to create Timer (and use it for managing e.g. controlling Critter's actions)?
  • I am getting Script::GetGlobalContext - Script context stack overflow! Context call stack: (no call stack after). Is this message part of Mono server? Could it be caused by having another (Timer) thread?



Title: Re: FOnlineServer with Mono
Post by: wladimiiir on July 03, 2013, 09:27:34 am
  • It's better to stay away from multithreading. The Critter (and other game objects) methods are not thread safe. You could use another thread timer with some thread-safe collection that would then act as message dispatcher (and messages it will got could be handled in main loop). And I think that normal Game Events are still viable option (after all, they are saved).
  • Can I have some code snippet?

Title: Re: FOnlineServer with Mono
Post by: E3245 on July 06, 2013, 11:47:21 am
Might I ask, does 2238 SDK support mono or not? Also, I do not understand the advantages by using mono.
Title: Re: FOnlineServer with Mono
Post by: Bartosz on July 07, 2013, 11:20:21 pm
As of rev409, mono subdirectory has been removed from sdk/Server, and its development moved to: https://github.com/rotators/fomono

The repository contains only source files, the rest (modified engine executables + mono libs) are included in releases (https://github.com/rotators/fomono/releases).

This is not only a part of moving our development endeavours in the open source wilderness, it should also make it easier for people wanting to use this modification - as it is now, the library source is the same as the files you need to alter for your particular application (Critter/Item/Map classes etc). Having those files separated as git repository can help with source management.

Might I ask, does 2238 SDK support mono or not? Also, I do not understand the advantages by using mono.

The mono integration hadn't been used with 2238, but you could easily set it up (using aforementioned repository). The only drawback would be that you will be using different server engine executable (you need to overwrite 2238' one with the one from fomono release) - if you're interested in details, ask.

As for advantages, well, just check the first post of this thread.
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on July 09, 2013, 08:21:08 pm
I have some questions about entry functions:

1. When I have entry function for initialization of critter in C#, am I supposed to use explicit conversion:
Code: [Select]
public static Critter InitCritter (IntPtr ptr, bool firstTime)
{
    Critter npc = (Critter) ptr;
    ...
or contructor
Code: [Select]
public static Critter InitCritter (IntPtr ptr, bool firstTime)
{
    Critter npc = new Critter(ptr);
    ...
Both seems to be working fine, but what is the difference here?

2. I would like to implement custom check_look function in C#, but I am not able to bind the function in scripts.cfg. Is it somehow possible or not really without some additional support in hardcoded part of Mono extension?

Thank you. :)
Title: Re: FOnlineServer with Mono
Post by: Bartosz on July 09, 2013, 08:42:11 pm
1. Explicit conversion from IntPtr.Zero will return null reference, whereas new Critter(IntPtr.Zero) will create invalid wrapper pointing to IntPtr.Zero and possibly soon crashing the whole serv. But in init functions it's not possible for the pointer to be zero, so there is no difference here.

2. The scripts.cfg bindings are not working, because scripts.cfg won't allow you to define declaration, and take hardcoded one. And hardcoded ones are AS declarations, not mono ones, difference is:

Code: [Select]
// AS
viod funcname(int, int)
// mono
void Namespace.ClassName::Method(int,int)

so in mapper/dialog you may specify script as mono@SomeClass::Foo and have it working, but you can't do the same in scripts.cfg...

Of course you can do dirty:

Code: [Select]
// scripts.cfg
check_look some_module

// some_module
#pragma bindfunc "bool Helper(Critter&, Critter&) -> mono CheckLook::Check" // don't remember exact signature
bool check_look(Critter& cr1, Critter& cr2)
{
  return Helper(cr1,cr2);
}

// mono class
class CheckLook
{
  public bool static Check(IntPtr ptr1, IntPtr ptr2)
  {
    var cr1 = (Critter)ptr1;
    var cr2 = (Critter)ptr2;
    // ...
  }
}
Title: Re: FOnlineServer with Mono
Post by: wladimiiir on July 09, 2013, 08:53:44 pm
1. Did you think about having implicit operator (instead of explicit) for Critter?
Code: [Select]
public static implicit operator Critter(IntPtr ptr)So in initialization function you could just write:
Code: [Select]
public static Critter InitCritter (IntPtr ptr, bool firstTime)
{
    Critter npc = ptr;
    ...

2. So if I understood it, without introducing some additional functions in FOnline.Main class, the only workaround how I could use it is to bind managed function
Code: [Select]
#pragma bindfunc "void Foo() -> mono Classname::MethodName"and call it in main.fos@check_look?
But I suppose this is stupid solution, right? :)
Title: Re: FOnlineServer with Mono
Post by: Bartosz on July 09, 2013, 10:18:12 pm
1. I kinda don't like implicit conversions, would be damn useful if they would be used when engine calls mono method, but they don't (hence engine-callble methods take IntPtr as argument).

2. Yeah, kind of dirty, but should work.