From 7ea15cfdc18ea5af9ada0b45c9be8fed55d3eaf5 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 19 Jun 2007 23:55:04 +0000 Subject: [PATCH] Fixed a recent bug. EvaluateDebugString (ie: the give command) can now accept numbers as entities to retrieve fields from. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2518 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/pr_exec.c | 24 +++++++++++++++++++----- engine/qclib/pr_multi.c | 2 +- engine/qclib/qcc_pr_comp.c | 2 +- engine/qclib/qccmain.c | 5 +++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 1da6911ee..05c05772c 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -431,6 +431,8 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key) eval_t *val; char *assignment; int type; + ddef32_t fakedef; + eval_t fakeval; assignment = strchr(key, '='); if (assignment) @@ -439,19 +441,31 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key) c = strchr(key, '.'); if (c) *c = '\0'; def = ED_FindLocalOrGlobal(progfuncs, key, &val); + if (!def) + { + if (atoi(key)) + { + def = &fakedef; + def->ofs = 0; + def->type = ev_entity; + val = &fakeval; + val->edict = atoi(key); + } + } if (c) *c = '.'; if (!def) { return "(Bad string)"; } - //go through ent vars + type = def->type; + //go through ent vars c = strchr(key, '.'); while(c) { c2 = c+1; c = strchr(c2, '.'); - type = def->type &~DEF_SAVEGLOBAL; + type = type &~DEF_SAVEGLOBAL; if (current_progstate->types) type = current_progstate->types[type].type; if (type != ev_entity) @@ -462,13 +476,13 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key) if (!fdef) return "(Bad string)"; val = (eval_t *) (((char *)PROG_TO_EDICT(progfuncs, val->_int)->fields) + fdef->ofs*4); - def->type = fdef->type; + type = fdef->type; } if (assignment) { assignment++; - switch (def->type&~DEF_SAVEGLOBAL) + switch (type&~DEF_SAVEGLOBAL) { case ev_string: *(string_t *)val = ED_NewString (progfuncs, assignment, 0)-progfuncs->stringtable; @@ -544,7 +558,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key) } assignment[-1] = '='; } - strcpy(buf, PR_ValueString(progfuncs, def->type, val)); + strcpy(buf, PR_ValueString(progfuncs, type, val)); return buf; } diff --git a/engine/qclib/pr_multi.c b/engine/qclib/pr_multi.c index 45362dee7..5e803c97f 100644 --- a/engine/qclib/pr_multi.c +++ b/engine/qclib/pr_multi.c @@ -226,7 +226,7 @@ int QC_RegisterFieldVar(progfuncs_t *progfuncs, unsigned int type, char *name, i { if (field[i].type != type) { - printf("Field type mismatch on %s\n", name); + printf("Field type mismatch on \"%s\"\n", name); continue; } if (!progfuncs->fieldadjust && engineofs>=0) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index d0604ad21..b1a9d54d1 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -3012,7 +3012,7 @@ QCC_def_t *QCC_MakeVectorDef(float a, float b, float c) cn->arraysize = 1; // copy the immediate to the global area - cn->ofs = QCC_GetFreeOffsetSpace (type_size[type_integer->type]); + cn->ofs = QCC_GetFreeOffsetSpace (type_size[type_vector->type]); G_FLOAT(cn->ofs+0) = a; G_FLOAT(cn->ofs+1) = b; diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index 9306abe33..c22d92b9e 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -1676,6 +1676,11 @@ unsigned short QCC_PR_WriteProgdefs (char *filename) QCC_CRC_Init (&crc); // print global vars until the first field is defined + + //ADD: crc and dump + //ADD2: dump but don't crc + //ADD3: crc but don't dump + ADD("\n/* "); if (qcc_targetformat == QCF_HEXEN2) ADD3("generated by hcc, do not modify");