DarkPlacesEngine / DarkPlaces

The DarkPlaces Quake engine, created by LadyHavoc. Official Git repository (replaces SVN).
https://icculus.org/twilight/darkplaces/
GNU General Public License v2.0
290 stars 42 forks source link

Quake Mods With quake.rc lacking "exec default.cfg" #171

Open Baker7 opened 7 months ago

Baker7 commented 7 months ago

There are some Quake mods that lack exec default.cfg. An example mod is Smej2 https://www.quaddicted.com/reviews/smej2_1.1.html and the map smej2m4 Lumen Valama (origin = "origin" "2293 1747 296" -- the map is huge, use "prvm_edictset server 1 origin "2293 1747 296" to teleport there")

smej2m4_webs_smej_1_2

This shows the correct behavior, but if you start up DarkPlaces from the command line with darkplaces -game smej2 +map mapname jakub1 says the cobwebs will be solid and grenades will bounce off them and rockets and such will bounce off waterfalls instead of going through them.

"exec default.cfg" signals for DarkPlaces to set "ideal Quake settings", lock default values, etc.

Running a mod without "exec default.cfg" in the "quake.rc" will result in all sorts of crazy and odd behaviors, because the "ideal Quake settings for cvars" never run. It is also likely the default values for cvars are bad/invalid.

Here is what I am doing in Zircon engine to fix:

GAME_NORMAL is Quake, but not hipnotic or quoth or such. This won't run if hipnotic or rogue or such are the gamedir, but the mod should be hipnotic in that case, anyway and use the quake.rc for such so this should cover all valid cases for a Quake mod.

cmd.c in Cmd_Exec (the fix I am using ...)

    f = (char *)FS_LoadFile (filename, tempmempool, fs_quiet_FALSE, fs_size_ptr_null);
    // fix starts here
    if (gamemode == GAME_NORMAL) {
        qbool is_quake_rc = String_Does_Match (filename, "quake.rc") || String_Does_End_With(filename, "/quake.rc");
        if (is_quake_rc) {
            if (strstr (f, "default.cfg") == NULL) {
                // quake.rc with no default.cfg .. DarkPlaces needs to run default.cfg
                // it sets/locks defaults and signals to run DarkPlaces_Settings_For_Game
                // Prepend to f data.
                const char *s_default_cfg = "exec default.cfg" "\n";
                size_t extrasize = strlen(s_default_cfg) + 1; // +1 for null
                size_t currentsize = strlen(f) + 1; // +1 for null
                size_t totalsize = extrasize + currentsize;
                char *s = (char *)Mem_Alloc (tempmempool, currentsize + extrasize);
                strlcpy (s, s_default_cfg, totalsize);
                strlcat (s, f, totalsize);
                Mem_Free (f);
                f = s;
            }
        } // quake_rc
    } // gamemode normal

Note ... for someone to type "prvm_edictset server 1 origin "2293 1747 296" to teleport is unwieldly ... in Quakespasm derivates (and Zircon) there is a command "setpos 2293 1747 296" ... the code for that looks as such ...

// Baker r3174: "setpos x y z [pitch] [yaw] [roll]"
static void SV_SetPos_f(cmd_state_t *cmd)
{
    prvm_prog_t *prog = SVVM_prog;
    prvm_edict_t *player_ed = host_client->edict;

    vec3_t origin = {0}, angles = {0};
    int do_angles = false;

    if (Cmd_Argc(cmd) == 7) {
        origin[0] = atof(Cmd_Argv(cmd, 1));
        origin[1] = atof(Cmd_Argv(cmd, 2));
        origin[2] = atof(Cmd_Argv(cmd, 3));
        angles[0] = atof(Cmd_Argv(cmd, 4));
        angles[1] = atof(Cmd_Argv(cmd, 5));
        angles[2] = atof(Cmd_Argv(cmd, 6));
        do_angles = true;
    } else if (Cmd_Argc(cmd) == 4) {
        origin[0] = atof(Cmd_Argv(cmd, 1));
        origin[1] = atof(Cmd_Argv(cmd, 2));
        origin[2] = atof(Cmd_Argv(cmd, 3));
//      VectorCopy (cl.viewangles, angles);
    } else {
        SV_ClientPrint("Can't setpos -- need origin" NEWLINE);
        return;
    }

    VectorClear (PRVM_serveredictvector(player_ed, velocity));
    VectorCopy  (origin, PRVM_serveredictvector(player_ed, origin));
    if (do_angles) {
        VectorCopy  (angles, PRVM_serveredictvector(player_ed, angles));
    }

    // Baker: simulate teleport
    PRVM_serveredictfloat(player_ed, fixangle) =
        (int)true;

    int flagz = PRVM_serveredictfloat(player_ed, flags);
    if (Have_Flag (flagz, FL_ONGROUND)) {
        Flag_Remove_From (flagz, FL_ONGROUND);
        PRVM_serveredictfloat(player_ed, flags) = (int)flagz;
    }
}

Cmd_AddCommand(CF_CHEAT | CF_SERVER_FROM_CLIENT, "setpos", SV_SetPos_f, "teleport/set current origin <angles> [Zircon]"); // Baker r3174
ladyhavoc commented 7 months ago

Quake mods that lack default.cfg in their quake.rc already broke in stock quake, there's no change in behavior here other than some engine defaults possibly not triggering, so why was that mod made broken to begin with?

Baker7 commented 7 months ago

The Quake Remaster doesn't exec default.cfg either.

Baker7 commented 7 months ago

This is what I said when I realized the cause ...


The smej quake.rc file is at fault.

It does not run default.cfg

And it is supposed to.

But I thought about it, and I had to decide whether or not I wanted every mod with this issue to malfunction or if I just wanted it "to work".

ladyhavoc commented 7 months ago

I think the best strategy is to run default.cfg and post a warning (in red text perhaps?) in the console saying the engine is working around a bug in the mod as exec default.cfg is required for normal operation, if you really want to avoid default.cfg then please make an empty one.

Baker7 commented 7 months ago

I think not executing a default.cfg is the "new normal".

Consider this ...

1) Johnny has "Quake Remastered". 2) Johnny installs a gamedir mod with only a progs.dat and a map. 3) Since "Quake Remastered" does not execute default.cfg and the mod with a progs.dat does not supply a quake.rc

Where is the "exec default.cfg" supposed to come from?

Because it isn't in Quake Remastered -- and for some people that is the "new Quake". And the mod is just a progs.dat

ladyhavoc commented 7 months ago

But if there is no quake.rc in a mod, it still runs the quake.rc in id1, as it falls back to that one, and quake.rc is what specifies the startdemos command, which is the only way to trigger that on startup. The fact that quake.rc also contains the stuffcmds (which runs the commandline options beginning with +) is more of a curiosity. So a lot of mods include a quake.rc specifically to remove the startdemos command because they have no demos to show, but they intend to have all other behaviors in place.

Baker7 commented 7 months ago

I don't know. Thinking about it more, it really is a smej "issue".

I just opened the re-release folder and looked around. It does have a quake.rc and it does exec default.cfg, it just does not come with a default.cfg (go figure.)

[Yes it is true, Quake Remastered does not have a default.cfg -- Quakespasm overcomes this by providing its own default.cfg in the engine.]

My goal was to document and share the details of the investigation into the solid cobwebs and solid waterwall, because it was very difficult to unravel.