• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

loadmodel / unload_model

O Ilusionista

Captain 80K
I was checking some old posts and I want to better understand how those functions works.

loadmodel(name)

  • "Load" a model that is currently set as "know" in models.txt.
  • "name" is the model's name.
There is a missing info on the manual, as the funcion accepts a value after the name, like this:
C-like:
loadmodel("Axel", 3);

As far as I know - and according to @Kratus post here, loadmodel loads a model in the memory instantly.
And when we use "3" on the extra parameter, it will unload the model only when the level ends, right?
What the other values (1 and 2) does anyway? I can't find the info anymore, I remember it was somthing related with the sprites only.

The engine source has no info about the other values:
C-like:
//loadmodel(name)
HRESULT openbor_loadmodel(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
{
    LONG unload = 0;
    s_model *model;
    if(paramCount < 1)
    {
        goto loadmodel_error;
    }
    if(varlist[0]->vt != VT_STR)
    {
        goto loadmodel_error;
    }


    ScriptVariant_ChangeType(*pretvar, VT_PTR);
    if(paramCount >= 2)
        if(FAILED(ScriptVariant_IntegerValue(varlist[1], &unload)))
        {
            goto loadmodel_error;
        }


    model = load_cached_model(StrCache_Get(varlist[0]->strVal), "openbor_loadmodel", (char)unload);


    if(paramCount >= 3 && model)
    {
        model_cache[model->index].selectable = (char)ScriptVariant_IsTrue(varlist[2]);
    }


    (*pretvar)->ptrVal = (VOID *)model;


    //else, it should return an empty value
    return S_OK;


loadmodel_error:
    printf("Function needs a string and integer parameters: loadmodel(name, unload, selectable)\n");
    ScriptVariant_Clear(*pretvar);
    *pretvar = NULL;
    return E_FAIL;
}

Then @msmalik681 added a new function called unload_model() back in 6412 build (not documented yet) which, if I got it right, unloads the model instantly.
unload_loadmodel(name);

Can we confirm if this works instantly?

Thanks.
 
What the other values (1 and 2) does anyway? I can't find the info anymore, I remember it was somthing related with the sprites only.
According to what I understood in the source the flag 1 will unload the model, the flag 2 will unload sprites and 3 is a mix of both, fully unloading the entity.

1719085713456.png

but if you try using it, you get an error
Yeah, I remember having issues in previous builds with this function, but it looks fixed on the build 7612 because it didn't crash the engine. Maybe Malik fixed it once he was the one that created the function.
 
Back
Top Bottom