deejayy / hlds-v8

Half Life Dedicated Server with Google V8 JS Engine (a metamod plugin)
12 stars 2 forks source link

NodeJS port #5

Open Silviu-Marian opened 10 years ago

Silviu-Marian commented 10 years ago

Hello there.

I'd like to see NodeJS in this faster and I can even throw some money (donation) into this project if necessary.

I managed to get it to work but I have extremely limited C++ abilities. But I can tell you what I did and worked. Step by step:

    [env]
    NODE_PATH=./;../;cstrike/addons/amxmodx/plugins-node
    NODE_MODULE_CONTEXTS=0
    NODE_DISABLE_COLORS=1
    NODE_BOOTSTRAPPER_SCRIPT=plugins-node/base.js

    [args]
    --expose_gc
    --no-deprecation

    [files]
    plugins-node/demo-timer.js
You can see there I have a simple bootstrapper script. This script was supposed to re-read the ini file provided above and execute (via `require`) the files under the `[files]` section. This way we can have plugins.

Like I said, my knowledge on this is very limited, but I'd really like to see this project work; I know there'll be lots of work with porting all the cstrike/engine/fun/ham functions but if you give me a starting point maybe I'll be able to help out.

deejayy commented 10 years ago

Hey ketamynx, you've done a very good work there. I also ended up this kind of conclusion about node-hlds cooperation, except i just thought it, but you've done it.

I also have a very superficial knowledge in c++, i think it's one of the reasons i suspended this project a while - and other things got in the way. I don't know when can i set me about it again, i'm very busy now, but i like to see this working, too.

Anyway, the project is open, free to fork, and i encourage all people, who interested in this to further develop this project to achieve all things that amxx can do - and even more.

Silviu-Marian commented 10 years ago

Alright then. I'll try to make it my weekend project this weekend then. Hopefully we can see something useful soon.

Silviu-Marian commented 10 years ago

Hey there. I hope you don't mind if I ask a question every now and again.

So I've wrote a script to convert all those forwards (like ClientConnect etc.) to NodeJS events, I even managed to wrap the various structures (like edict_t, entvars_s etc.) and throw them in the arguments list, but I have a question here.

So, right now everything is converted properly and is read only; I stumbled across this type which is KeyValueData. It looks like this:

    typedef struct KeyValueData_s
    {
        char    *szClassName;   // in: entity classname
        char    *szKeyName;     // in: name of key
        char    *szValue;       // in: value of key
        int32   fHandled;       // out: DLL sets to true if key-value pair was understood
    } KeyValueData;

I know this type is not really useful anywhere, and there's no problem reading from those char *, but for educational purposes, how can I change their values without causing memory leaks? I tried making them point to a passed string value, but everything is in references here and the string goes away the second it gets out of scope.