]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Add an entity parameter for CSQC_InputEvent
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index fedfb13dcbe52b86dfd7eaf0a2fcf8b7fe795ec7..352d8c5be40491efe542a7d84a26b2411a41882f 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -196,7 +196,7 @@ void Cbuf_AddText (cmd_state_t *cmd, const char *text)
        l = (int)strlen(text);
 
        Cbuf_Lock(cmd);
-       if (cmd->text.cursize + l >= (size_t)cmd->text.maxsize)
+       if (cmd->text.maxsize - cmd->text.cursize <= l)
                Con_Print("Cbuf_AddText: overflow\n");
        else
                SZ_Write(&cmd->text, (const unsigned char *)text, l);
@@ -237,14 +237,13 @@ Cbuf_Execute_Deferred --blub
 */
 static void Cbuf_Execute_Deferred (cmd_state_t *cmd)
 {
-       static double oldrealtime = 0;
        cmddeferred_t *defcmd, *prev;
        double eat;
-       if (realtime - oldrealtime < 0 || realtime - oldrealtime > 1800) oldrealtime = realtime;
-       eat = realtime - oldrealtime;
+       if (realtime - cmd->deferred_oldrealtime < 0 || realtime - cmd->deferred_oldrealtime > 1800) cmd->deferred_oldrealtime = realtime;
+       eat = realtime - cmd->deferred_oldrealtime;
        if (eat < (1.0 / 120.0))
                return;
-       oldrealtime = realtime;
+       cmd->deferred_oldrealtime = realtime;
        prev = NULL;
        defcmd = cmd->deferred_list;
        while(defcmd)
@@ -328,7 +327,7 @@ void Cbuf_Execute (cmd_state_t *cmd)
                // better than CRASHING on overlong input lines that may SOMEHOW enter the buffer
                if(i >= MAX_INPUTLINE)
                {
-                       Con_Printf("Warning: console input buffer had an overlong line. Ignored.\n");
+                       Con_Warnf("Warning: console input buffer had an overlong line. Ignored.\n");
                        line[0] = 0;
                }
                else
@@ -525,6 +524,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sys_ticrate 0.01388889\n"
 "r_shadow_gloss 1\n"
 "r_shadow_bumpscale_basetexture 0\n"
+"csqc_polygons_defaultmaterial_nocullface 0\n"
                                );
                        break;
                case GAME_NEHAHRA:
@@ -549,6 +549,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sys_ticrate 0.01388889\n"
 "r_shadow_gloss 1\n"
 "r_shadow_bumpscale_basetexture 0\n"
+"csqc_polygons_defaultmaterial_nocullface 0\n"
                                );
                        break;
                // hipnotic mission pack has issues in their 'friendly monster' ai, which seem to attempt to attack themselves for some reason when findradius() returns non-solid entities.
@@ -577,6 +578,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sys_ticrate 0.02\n"
 "r_shadow_gloss 1\n"
 "r_shadow_bumpscale_basetexture 0\n"
+"csqc_polygons_defaultmaterial_nocullface 0\n"
                                );
                        break;
                // rogue mission pack has a guardian boss that does not wake up if findradius returns one of the entities around its spawn area
@@ -602,6 +604,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sys_ticrate 0.01388889\n"
 "r_shadow_gloss 1\n"
 "r_shadow_bumpscale_basetexture 0\n"
+"csqc_polygons_defaultmaterial_nocullface 0\n"
                                );
                        break;
                case GAME_TENEBRAE:
@@ -626,6 +629,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sys_ticrate 0.01388889\n"
 "r_shadow_gloss 2\n"
 "r_shadow_bumpscale_basetexture 4\n"
+"csqc_polygons_defaultmaterial_nocullface 0\n"
                                );
                        break;
                case GAME_NEXUIZ:
@@ -650,6 +654,14 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sys_ticrate 0.01388889\n"
 "sv_gameplayfix_q2airaccelerate 1\n"
 "sv_gameplayfix_stepmultipletimes 1\n"
+"csqc_polygons_defaultmaterial_nocullface 1\n"
+                               );
+                       break;
+               case GAME_XONOTIC:
+               case GAME_VORETOURNAMENT:
+                       // compatibility for versions prior to 2020-05-25, this can be overridden in newer versions to get the default behavior and be consistent with FTEQW engine
+                       Cbuf_InsertText(cmd, "\n"
+"csqc_polygons_defaultmaterial_nocullface 1\n"
                                );
                        break;
                // Steel Storm: Burning Retribution csqc misinterprets CSQC_InputEvent if type is a value other than 0 or 1
@@ -674,6 +686,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sv_gameplayfix_downtracesupportsongroundflag 1\n"
 "sys_ticrate 0.01388889\n"
 "cl_csqc_generatemousemoveevents 0\n"
+"csqc_polygons_defaultmaterial_nocullface 1\n"
                                );
                        break;
                default:
@@ -696,6 +709,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
 "sv_gameplayfix_swiminbmodels 1\n"
 "sv_gameplayfix_downtracesupportsongroundflag 1\n"
 "sys_ticrate 0.01388889\n"
+"csqc_polygons_defaultmaterial_nocullface 0\n"
                                );
                        break;
                }
@@ -1107,9 +1121,9 @@ static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t va
        {
                // empty cvar name?
                if(alias)
-                       Con_Printf("Warning: Could not expand $ in alias %s\n", alias->name);
+                       Con_Warnf("Warning: Could not expand $ in alias %s\n", alias->name);
                else
-                       Con_Printf("Warning: Could not expand $\n");
+                       Con_Warnf("Warning: Could not expand $\n");
                return "$";
        }
 
@@ -1155,9 +1169,9 @@ static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t va
                if(required)
                {
                        if(alias)
-                               Con_Printf("Error: Could not expand $%s in alias %s\n", varname, alias->name);
+                               Con_Errorf("Error: Could not expand $%s in alias %s\n", varname, alias->name);
                        else
-                               Con_Printf("Error: Could not expand $%s\n", varname);
+                               Con_Errorf("Error: Could not expand $%s\n", varname);
                        return NULL;
                }
                else if(optional)
@@ -1167,9 +1181,9 @@ static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t va
                else
                {
                        if(alias)
-                               Con_Printf("Warning: Could not expand $%s in alias %s\n", varname, alias->name);
+                               Con_Warnf("Warning: Could not expand $%s in alias %s\n", varname, alias->name);
                        else
-                               Con_Printf("Warning: Could not expand $%s\n", varname);
+                               Con_Warnf("Warning: Could not expand $%s\n", varname);
                        dpsnprintf(varval, sizeof(varval), "$%s", varname);
                        return varval;
                }