FOnline Development > General Discussion

FOnlineServer with Mono

<< < (10/11) > >>

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

Bartosz:
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.

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.


--- Quote from: 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.

--- End quote ---

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.

wladimiiir:
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: ---public static Critter InitCritter (IntPtr ptr, bool firstTime)
{
    Critter npc = (Critter) ptr;
    ...
--- End code ---
or contructor

--- Code: ---public static Critter InitCritter (IntPtr ptr, bool firstTime)
{
    Critter npc = new Critter(ptr);
    ...
--- End code ---
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. :)

Bartosz:
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: ---// AS
viod funcname(int, int)
// mono
void Namespace.ClassName::Method(int,int)

--- End code ---

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: ---// 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;
    // ...
  }
}

--- End code ---

wladimiiir:
1. Did you think about having implicit operator (instead of explicit) for Critter?

--- Code: ---public static implicit operator Critter(IntPtr ptr)
--- End code ---
So in initialization function you could just write:

--- Code: ---public static Critter InitCritter (IntPtr ptr, bool firstTime)
{
    Critter npc = ptr;
    ...
--- End code ---

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: ---#pragma bindfunc "void Foo() -> mono Classname::MethodName"
--- End code ---
and call it in main.fos@check_look?
But I suppose this is stupid solution, right? :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version