diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index b2eeeeee..6f09a21a 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -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: diff --git a/src/game/header/local.h b/src/game/header/local.h index 5491c44b..7fdfab8e 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -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 diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index db1e6060..717f4265 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -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: diff --git a/src/game/savegame/tables/fields.h b/src/game/savegame/tables/fields.h index eb952355..5646942a 100644 --- a/src/game/savegame/tables/fields.h +++ b/src/game/savegame/tables/fields.h @@ -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},