mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 05:51:01 +00:00
game: Add fields used in misc_flare
Based on [ED_LoadColor](https://github.com/id-Software/quake2-rerelease-dll).
This commit is contained in:
parent
4f1e668eb7
commit
17603050b6
4 changed files with 65 additions and 1 deletions
|
@ -349,6 +349,54 @@ ED_NewString(const char *string)
|
|||
return newb;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
ED_ParseColorField(const char *value)
|
||||
{
|
||||
/* space means rgba as values */
|
||||
if (strchr(value, ' '))
|
||||
{
|
||||
float v[4] = { 0, 0, 0, 1.0f };
|
||||
qboolean is_float = true;
|
||||
char color_buffer[16], *tmp;
|
||||
int i;
|
||||
|
||||
strncpy(color_buffer, value, sizeof(color_buffer) - 1);
|
||||
tmp = color_buffer;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
v[i] = (float)strtod(COM_Parse(&tmp), (char **)NULL);
|
||||
|
||||
if (v[i] > 1.0f)
|
||||
{
|
||||
is_float = false;
|
||||
}
|
||||
|
||||
if (!tmp)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* convert to bytes */
|
||||
if (is_float)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
v[i] *= 255.f;
|
||||
}
|
||||
}
|
||||
|
||||
return ((byte)v[3]) |
|
||||
(((byte)v[2]) << 8) |
|
||||
(((byte)v[1]) << 16) |
|
||||
(((byte)v[0]) << 24);
|
||||
}
|
||||
|
||||
/* integral */
|
||||
return atoi(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes a key/value pair and sets
|
||||
* the binary values in an edict
|
||||
|
@ -403,6 +451,9 @@ ED_ParseField(const char *key, const char *value, edict_t *ent)
|
|||
((float *)(b + f->ofs))[1] = v;
|
||||
((float *)(b + f->ofs))[2] = 0;
|
||||
break;
|
||||
case F_RGBA:
|
||||
*(unsigned *)(b + f->ofs) = ED_ParseColorField(value);
|
||||
break;
|
||||
case F_IGNORE:
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -410,6 +410,11 @@ typedef struct
|
|||
float maxyaw;
|
||||
float minpitch;
|
||||
float maxpitch;
|
||||
|
||||
float radius;
|
||||
float fade_start_dist;
|
||||
float fade_end_dist;
|
||||
char *image;
|
||||
} spawn_temp_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -712,7 +717,8 @@ typedef enum
|
|||
F_CLIENT, /* index on disk, pointer in memory */
|
||||
F_FUNCTION,
|
||||
F_MMOVE,
|
||||
F_IGNORE
|
||||
F_IGNORE,
|
||||
F_RGBA,
|
||||
} fieldtype_t;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -417,6 +417,7 @@ WriteField1(FILE *f, field_t *field, byte *base)
|
|||
case F_ANGLEHACK:
|
||||
case F_VECTOR:
|
||||
case F_IGNORE:
|
||||
case F_RGBA:
|
||||
break;
|
||||
|
||||
case F_LSTRING:
|
||||
|
@ -614,6 +615,7 @@ ReadField(FILE *f, field_t *field, byte *base)
|
|||
case F_ANGLEHACK:
|
||||
case F_VECTOR:
|
||||
case F_IGNORE:
|
||||
case F_RGBA:
|
||||
break;
|
||||
|
||||
case F_LSTRING:
|
||||
|
|
|
@ -58,6 +58,11 @@
|
|||
{"origin", FOFS(s.origin), F_VECTOR},
|
||||
{"angles", FOFS(s.angles), F_VECTOR},
|
||||
{"angle", FOFS(s.angles), F_ANGLEHACK},
|
||||
{"rgba", FOFS(s.skinnum), F_RGBA},
|
||||
{"radius", STOFS(radius), F_FLOAT, FFL_SPAWNTEMP},
|
||||
{"fade_start_dist", STOFS(fade_start_dist), F_FLOAT, FFL_SPAWNTEMP},
|
||||
{"fade_end_dist", STOFS(fade_end_dist), F_FLOAT, FFL_SPAWNTEMP},
|
||||
{"image", STOFS(image), F_LSTRING, FFL_SPAWNTEMP},
|
||||
{"goalentity", FOFS(goalentity), F_EDICT, FFL_NOSPAWN},
|
||||
{"movetarget", FOFS(movetarget), F_EDICT, FFL_NOSPAWN},
|
||||
{"enemy", FOFS(enemy), F_EDICT, FFL_NOSPAWN},
|
||||
|
|
Loading…
Reference in a new issue