]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - misc/source/fteqcc-src/pr_exec.c
Update fteqcc source
[voretournament/voretournament.git] / misc / source / fteqcc-src / pr_exec.c
index 9795603937c8c0cc86b6f0435c36cbe2f98d5521..323c566069bf1dd7e46cb102be90aab5b6daae5f 100644 (file)
@@ -346,6 +346,9 @@ ddef32_t *ED_FindLocalOrGlobal(progfuncs_t *progfuncs, char *name, eval_t **val)
        ddef16_t *def16;
        int i;
 
+       if (pr_typecurrent < 0)
+               return NULL;
+
        switch (pr_progstate[pr_typecurrent].structtype)
        {
        case PST_DEFAULT:
@@ -436,6 +439,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
        int type;
        ddef32_t fakedef;
        eval_t fakeval;
+       edictrun_t *ed;
 
        assignment = strchr(key, '=');
        if (assignment)
@@ -469,7 +473,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
                c2 = c+1;
                c = strchr(c2, '.');
                type = type &~DEF_SAVEGLOBAL;
-               if (current_progstate->types)
+               if (current_progstate && current_progstate->types)
                        type = current_progstate->types[type].type;
                if (type != ev_entity)
                        return "'.' without entity";
@@ -478,13 +482,18 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
                if (c)*c = '.';
                if (!fdef)
                        return "(Bad string)";
-               val = (eval_t *) (((char *)PROG_TO_EDICT(progfuncs, val->_int)->fields) + fdef->ofs*4);
+               ed = PROG_TO_EDICT(progfuncs, val->_int);
+               if (!ed)
+                       return "(Invalid Entity)";
+               val = (eval_t *) (((char *)ed->fields) + fdef->ofs*4);
                type = fdef->type;
        }
 
        if (assignment)
        {
                assignment++;
+               while(*assignment == ' ')
+                       assignment++;
                switch (type&~DEF_SAVEGLOBAL)
                {
                case ev_string:
@@ -492,7 +501,10 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
                        break;
 
                case ev_float:
-                       *(float *)val = (float)atof (assignment);
+                       if (assignment[0] == '0' && (assignment[1] == 'x' || assignment[1] == 'X'))
+                               *(float*)val = strtoul(assignment, NULL, 0);
+                       else
+                               *(float *)val = (float)atof (assignment);
                        break;
 
                case ev_integer:
@@ -849,7 +861,6 @@ void PR_ExecuteCode (progfuncs_t *progfuncs, int s)
        dfunction_t     *newf;
        int             runaway;
        int             i;
-       int p;
        edictrun_t      *ed;
        eval_t  *ptr;
 
@@ -859,9 +870,9 @@ void PR_ExecuteCode (progfuncs_t *progfuncs, int s)
 
        prinst->continuestatement = -1;
 #ifdef QCJIT
-       if (prinst->jit)
+       if (current_progstate->jit)
        {
-               PR_EnterJIT(progfuncs, prinst->jit, s);
+               PR_EnterJIT(progfuncs, current_progstate->jit, s);
                return;
        }
 #endif
@@ -875,7 +886,7 @@ void PR_ExecuteCode (progfuncs_t *progfuncs, int s)
        {                                                                                       \
                pr_xstatement = st-pr_statements;               \
                PR_StackTrace(progfuncs);                               \
-               printf ("runaway loop error");                  \
+               printf ("runaway loop error\n");                \
                while(pr_depth > prinst->exitdepth)             \
                        PR_LeaveFunction(progfuncs);            \
                pr_spushed = 0;                                                 \