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
This commit is contained in:
Spoike 2007-06-19 23:55:04 +00:00
parent 633ccc534e
commit 7ea15cfdc1
4 changed files with 26 additions and 7 deletions

View file

@ -431,6 +431,8 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
eval_t *val; eval_t *val;
char *assignment; char *assignment;
int type; int type;
ddef32_t fakedef;
eval_t fakeval;
assignment = strchr(key, '='); assignment = strchr(key, '=');
if (assignment) if (assignment)
@ -439,19 +441,31 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
c = strchr(key, '.'); c = strchr(key, '.');
if (c) *c = '\0'; if (c) *c = '\0';
def = ED_FindLocalOrGlobal(progfuncs, key, &val); 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 (c) *c = '.';
if (!def) if (!def)
{ {
return "(Bad string)"; return "(Bad string)";
} }
//go through ent vars type = def->type;
//go through ent vars
c = strchr(key, '.'); c = strchr(key, '.');
while(c) while(c)
{ {
c2 = c+1; c2 = c+1;
c = strchr(c2, '.'); c = strchr(c2, '.');
type = def->type &~DEF_SAVEGLOBAL; type = type &~DEF_SAVEGLOBAL;
if (current_progstate->types) if (current_progstate->types)
type = current_progstate->types[type].type; type = current_progstate->types[type].type;
if (type != ev_entity) if (type != ev_entity)
@ -462,13 +476,13 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
if (!fdef) if (!fdef)
return "(Bad string)"; return "(Bad string)";
val = (eval_t *) (((char *)PROG_TO_EDICT(progfuncs, val->_int)->fields) + fdef->ofs*4); val = (eval_t *) (((char *)PROG_TO_EDICT(progfuncs, val->_int)->fields) + fdef->ofs*4);
def->type = fdef->type; type = fdef->type;
} }
if (assignment) if (assignment)
{ {
assignment++; assignment++;
switch (def->type&~DEF_SAVEGLOBAL) switch (type&~DEF_SAVEGLOBAL)
{ {
case ev_string: case ev_string:
*(string_t *)val = ED_NewString (progfuncs, assignment, 0)-progfuncs->stringtable; *(string_t *)val = ED_NewString (progfuncs, assignment, 0)-progfuncs->stringtable;
@ -544,7 +558,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key)
} }
assignment[-1] = '='; assignment[-1] = '=';
} }
strcpy(buf, PR_ValueString(progfuncs, def->type, val)); strcpy(buf, PR_ValueString(progfuncs, type, val));
return buf; return buf;
} }

View file

@ -226,7 +226,7 @@ int QC_RegisterFieldVar(progfuncs_t *progfuncs, unsigned int type, char *name, i
{ {
if (field[i].type != type) if (field[i].type != type)
{ {
printf("Field type mismatch on %s\n", name); printf("Field type mismatch on \"%s\"\n", name);
continue; continue;
} }
if (!progfuncs->fieldadjust && engineofs>=0) if (!progfuncs->fieldadjust && engineofs>=0)

View file

@ -3012,7 +3012,7 @@ QCC_def_t *QCC_MakeVectorDef(float a, float b, float c)
cn->arraysize = 1; cn->arraysize = 1;
// copy the immediate to the global area // 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+0) = a;
G_FLOAT(cn->ofs+1) = b; G_FLOAT(cn->ofs+1) = b;

View file

@ -1676,6 +1676,11 @@ unsigned short QCC_PR_WriteProgdefs (char *filename)
QCC_CRC_Init (&crc); QCC_CRC_Init (&crc);
// print global vars until the first field is defined // 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/* "); ADD("\n/* ");
if (qcc_targetformat == QCF_HEXEN2) if (qcc_targetformat == QCF_HEXEN2)
ADD3("generated by hcc, do not modify"); ADD3("generated by hcc, do not modify");