mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-26 13:50:53 +00:00
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:
parent
633ccc534e
commit
7ea15cfdc1
4 changed files with 26 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue