game: do not replace backslash in noise field

Add new field type F_LRAWSTRING for level strings with path.
This commit is contained in:
Denis Pauk 2024-10-23 00:09:58 +03:00
parent b5fe2df7f8
commit d5dad22f8d
23 changed files with 57 additions and 78 deletions

View file

@ -23,7 +23,6 @@ extern qboolean Pickup_Adrenaline(edict_t *ent, edict_t *other);
extern qboolean Pickup_Armor(edict_t *ent, edict_t *other);
extern qboolean Pickup_PowerArmor(edict_t *ent, edict_t *other);
extern edict_t *Sphere_Spawn(edict_t *owner, int spawnflags);
extern void ED_CallSpawn(edict_t *ent);
void fire_doppleganger(edict_t *ent, vec3_t start, vec3_t aimdir);
void

View file

@ -44,7 +44,6 @@ extern void check_dodge(edict_t *self, vec3_t start, vec3_t dir, int speed);
extern void hurt_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);
extern void droptofloor(edict_t *ent);
extern void Grenade_Explode(edict_t *ent);
extern void drawbbox(edict_t *ent);
void
flechette_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)

View file

@ -339,10 +339,10 @@ ED_CallSpawn(edict_t *ent)
}
char *
ED_NewString(const char *string)
ED_NewString(const char *string, qboolean raw)
{
char *newb, *new_p;
int i, l;
char *newb;
int l;
if (!string)
{
@ -353,27 +353,38 @@ ED_NewString(const char *string)
newb = gi.TagMalloc(l, TAG_LEVEL);
new_p = newb;
for (i = 0; i < l; i++)
if (!raw)
{
if ((string[i] == '\\') && (i < l - 1))
{
i++;
char *new_p;
int i;
if (string[i] == 'n')
new_p = newb;
for (i = 0; i < l; i++)
{
if ((string[i] == '\\') && (i < l - 1))
{
*new_p++ = '\n';
i++;
if (string[i] == 'n')
{
*new_p++ = '\n';
}
else
{
*new_p++ = '\\';
}
}
else
{
*new_p++ = '\\';
*new_p++ = string[i];
}
}
else
{
*new_p++ = string[i];
}
}
else
{
/* just copy without convert */
memcpy(newb, string, l);
}
return newb;
@ -460,8 +471,11 @@ ED_ParseField(const char *key, const char *value, edict_t *ent)
switch (f->type)
{
case F_LRAWSTRING:
*(char **)(b + f->ofs) = ED_NewString(value, true);
break;
case F_LSTRING:
*(char **)(b + f->ofs) = ED_NewString(value);
*(char **)(b + f->ofs) = ED_NewString(value, false);
break;
case F_VECTOR:
sscanf(value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
@ -1343,7 +1357,7 @@ CreateMonster(vec3_t origin, vec3_t angles, char *classname)
VectorCopy(origin, newEnt->s.origin);
VectorCopy(angles, newEnt->s.angles);
newEnt->classname = ED_NewString(classname);
newEnt->classname = ED_NewString(classname, true);
newEnt->monsterinfo.aiflags |= AI_DO_NOT_COUNT;
VectorSet(newEnt->gravityVector, 0, 0, -1);
@ -1367,7 +1381,7 @@ DetermineBBox(char *classname, vec3_t mins, vec3_t maxs)
VectorCopy(vec3_origin, newEnt->s.origin);
VectorCopy(vec3_origin, newEnt->s.angles);
newEnt->classname = ED_NewString(classname);
newEnt->classname = ED_NewString(classname, true);
newEnt->monsterinfo.aiflags |= AI_DO_NOT_COUNT;
ED_CallSpawn(newEnt);

View file

@ -18,7 +18,6 @@
#define VENGEANCE_LIFESPAN 30
#define MINIMUM_FLY_TIME 15
extern char *ED_NewString(const char *string);
void LookAtKiller(edict_t *self, edict_t *inflictor, edict_t *attacker);
void defender_think(edict_t *self);

View file

@ -39,8 +39,6 @@
#define LASER_FAT 0x0040
#define LASER_STOPWINDOW 0x0080
void ED_CallSpawn(edict_t *ent);
/*
* QUAKED target_temp_entity (1 0 0) (-8 -8 -8) (8 8 8)
*

View file

@ -719,6 +719,7 @@ typedef enum
F_MMOVE,
F_IGNORE,
F_RGBA,
F_LRAWSTRING, /* raw string on disk, pointer in memory, TAG_LEVEL */
} fieldtype_t;
typedef struct
@ -800,10 +801,6 @@ float vectoyaw2(vec3_t vec);
void vectoangles2(vec3_t vec, vec3_t angles);
edict_t *findradius2(edict_t *from, vec3_t org, float rad);
/* g_spawn.c */
void ED_CallSpawn(edict_t *ent);
void DynamicSpawnInit(void);
/* g_combat.c */
qboolean OnSameTeam(edict_t *ent1, edict_t *ent2);
qboolean CanDamage(edict_t *targ, edict_t *inflictor);
@ -1085,6 +1082,9 @@ void Tag_PlayerDeath(edict_t *targ, edict_t *inflictor, edict_t *attacker);
void fire_doppleganger(edict_t *ent, vec3_t start, vec3_t aimdir);
/* g_spawn.c */
void ED_CallSpawn(edict_t *ent);
char *ED_NewString(const char *string, qboolean raw);
void DynamicSpawnInit(void);
edict_t *CreateFlyMonster(vec3_t origin, vec3_t angles, vec3_t mins,
vec3_t maxs, char *classname);
edict_t *CreateGroundMonster(vec3_t origin, vec3_t angles, vec3_t mins,

View file

@ -30,7 +30,6 @@
#define BOSS2_ROCKET_SPEED 750
qboolean infront(edict_t *self, edict_t *other);
void BossExplode(edict_t *self);
void boss2_run(edict_t *self);
void boss2_stand(edict_t *self);

View file

@ -29,7 +29,6 @@
#include "boss31.h"
extern void SP_monster_makron(edict_t *self);
qboolean visible(edict_t *self, edict_t *other);
void BossExplode(edict_t *self);
void MakronToss(edict_t *self);
void MakronPrecache(void);

View file

@ -28,8 +28,6 @@
#include "../../header/local.h"
#include "boss32.h"
qboolean visible(edict_t *self, edict_t *other);
void MakronRailgun(edict_t *self);
void MakronSaveloc(edict_t *self);
void MakronHyperblaster(edict_t *self);

View file

@ -36,7 +36,6 @@ static int sound_search1;
static int sound_search2;
static int tread_sound;
qboolean visible(edict_t *self, edict_t *other);
void BossExplode2(edict_t *self);
void boss5_dead(edict_t *self);
void boss5Rocket(edict_t *self);

View file

@ -41,12 +41,6 @@ void carrier_prep_spawn(edict_t *self);
void CarrierMachineGunHold(edict_t *self);
void CarrierRocket(edict_t *self);
qboolean infront(edict_t *self, edict_t *other);
qboolean inback(edict_t *self, edict_t *other);
qboolean below(edict_t *self, edict_t *other);
void drawbbox(edict_t *self);
void ED_CallSpawn(edict_t *ent);
static int sound_pain1;
static int sound_pain2;
static int sound_pain3;

View file

@ -30,8 +30,6 @@
#define LEAD_TARGET 1
qboolean visible(edict_t *self, edict_t *other);
void chick_stand(edict_t *self);
void chick_run(edict_t *self);
void chick_reslash(edict_t *self);

View file

@ -19,9 +19,6 @@
#define FIXBOT_GOAL_TIMEOUT 15
#define FIXBOT_WELD_GOAL_TIMEOUT 15
qboolean visible(edict_t *self, edict_t *other);
qboolean infront(edict_t *self, edict_t *other);
static int sound_pain1;
static int sound_die;
static int sound_weld1;
@ -56,7 +53,6 @@ extern mmove_t fixbot_move_landing;
extern mmove_t fixbot_move_turn;
extern void roam_goal(edict_t *self);
void ED_CallSpawn(edict_t *ent);
float
crand(void)

View file

@ -28,8 +28,6 @@
#include "../../header/local.h"
#include "flyer.h"
qboolean visible(edict_t *self, edict_t *other);
static int nextmove; /* Used for start/stop frames */
static int sound_sight;

View file

@ -39,7 +39,6 @@ static int sound_sight;
static int sound_step;
static int sound_step2;
qboolean visible(edict_t *self, edict_t *other);
void GunnerGrenade(edict_t *self);
void GunnerFire(edict_t *self);
void gunner_fire_chain(edict_t *self);

View file

@ -28,7 +28,6 @@
#include "../../header/local.h"
#include "hover.h"
qboolean visible(edict_t *self, edict_t *other);
void hover_run(edict_t *self);
void hover_stand(edict_t *self);
void hover_dead(edict_t *self);

View file

@ -32,15 +32,10 @@
#define MEDIC_MAX_HEAL_DISTANCE 400
#define MEDIC_TRY_TIME 10.0
qboolean visible(edict_t *self, edict_t *other);
void M_SetEffects(edict_t *ent);
qboolean FindTarget(edict_t *self);
void HuntTarget(edict_t *self);
void FoundTarget(edict_t *self);
char *ED_NewString(const char *string);
void spawngrow_think(edict_t *self);
void SpawnGrow_Spawn(vec3_t startpos, int size);
void ED_CallSpawn(edict_t *ent);
void M_FliesOff(edict_t *self);
void M_FliesOn(edict_t *self);
@ -1921,7 +1916,7 @@ MedicCommanderCache(void)
VectorCopy(vec3_origin, newEnt->s.origin);
VectorCopy(vec3_origin, newEnt->s.angles);
newEnt->classname = ED_NewString(reinforcements[i]);
newEnt->classname = ED_NewString(reinforcements[i], true);
newEnt->monsterinfo.aiflags |= AI_DO_NOT_COUNT;

View file

@ -58,7 +58,6 @@ void stalker_false_death_start(edict_t *self);
#define FAUX_GRAVITY 800.0
extern qboolean SV_PointCloseEnough(edict_t *ent, vec3_t goal, float dist);
extern void drawbbox(edict_t *self);
static qboolean
stalker_ok_to_transition(edict_t *self)

View file

@ -29,8 +29,6 @@
#include "../../header/local.h"
#include "supertank.h"
qboolean visible(edict_t *self, edict_t *other);
static int sound_pain1;
static int sound_pain2;
static int sound_pain3;

View file

@ -37,7 +37,6 @@
#define VARIANCE 15.0
void BossExplode(edict_t *self);
qboolean infront(edict_t *self, edict_t *other);
static int sound_pain1;
static int sound_pain2;
@ -95,8 +94,6 @@ void widow_start_run_12(edict_t *self);
void WidowCalcSlots(edict_t *self);
void drawbbox(edict_t *self);
void
widow_search(edict_t *self)
{

View file

@ -49,7 +49,6 @@ static float sweep_angles[] = {
extern vec3_t stalker_mins, stalker_maxs;
qboolean infront(edict_t *self, edict_t *other);
void WidowCalcSlots(edict_t *self);
void WidowPowerups(edict_t *self);

View file

@ -421,6 +421,7 @@ WriteField1(FILE *f, field_t *field, byte *base)
break;
case F_LSTRING:
case F_LRAWSTRING:
case F_GSTRING:
if (*(char **)p)
@ -538,6 +539,7 @@ WriteField2(FILE *f, field_t *field, byte *base)
switch (field->type)
{
case F_LSTRING:
case F_LRAWSTRING:
if (*(char **)p)
{
@ -619,6 +621,7 @@ ReadField(FILE *f, field_t *field, byte *base)
break;
case F_LSTRING:
case F_LRAWSTRING:
len = *(int *)p;
if (!len)

View file

@ -26,18 +26,18 @@
* =======================================================================
*/
{"classname", FOFS(classname), F_LSTRING},
{"model", FOFS(model), F_LSTRING},
{"classname", FOFS(classname), F_LRAWSTRING},
{"model", FOFS(model), F_LRAWSTRING},
{"spawnflags", FOFS(spawnflags), F_INT},
{"speed", FOFS(speed), F_FLOAT},
{"accel", FOFS(accel), F_FLOAT},
{"decel", FOFS(decel), F_FLOAT},
{"target", FOFS(target), F_LSTRING},
{"targetname", FOFS(targetname), F_LSTRING},
{"pathtarget", FOFS(pathtarget), F_LSTRING},
{"deathtarget", FOFS(deathtarget), F_LSTRING},
{"killtarget", FOFS(killtarget), F_LSTRING},
{"combattarget", FOFS(combattarget), F_LSTRING},
{"target", FOFS(target), F_LRAWSTRING},
{"targetname", FOFS(targetname), F_LRAWSTRING},
{"pathtarget", FOFS(pathtarget), F_LRAWSTRING},
{"deathtarget", FOFS(deathtarget), F_LRAWSTRING},
{"killtarget", FOFS(killtarget), F_LRAWSTRING},
{"combattarget", FOFS(combattarget), F_LRAWSTRING},
{"message", FOFS(message), F_LSTRING},
{"team", FOFS(team), F_LSTRING},
{"wait", FOFS(wait), F_FLOAT},
@ -54,7 +54,7 @@
{"mass", FOFS(mass), F_INT},
{"volume", FOFS(volume), F_FLOAT},
{"attenuation", FOFS(attenuation), F_FLOAT},
{"map", FOFS(map), F_LSTRING},
{"map", FOFS(map), F_LRAWSTRING},
{"origin", FOFS(s.origin), F_VECTOR},
{"angles", FOFS(s.angles), F_VECTOR},
{"angle", FOFS(s.angles), F_ANGLEHACK},
@ -62,7 +62,7 @@
{"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},
{"image", STOFS(image), F_LRAWSTRING, FFL_SPAWNTEMP},
{"goalentity", FOFS(goalentity), F_EDICT, FFL_NOSPAWN},
{"movetarget", FOFS(movetarget), F_EDICT, FFL_NOSPAWN},
{"enemy", FOFS(enemy), F_EDICT, FFL_NOSPAWN},
@ -98,12 +98,12 @@
{"lip", STOFS(lip), F_INT, FFL_SPAWNTEMP},
{"distance", STOFS(distance), F_INT, FFL_SPAWNTEMP},
{"height", STOFS(height), F_INT, FFL_SPAWNTEMP},
{"noise", STOFS(noise), F_LSTRING, FFL_SPAWNTEMP},
{"noise", STOFS(noise), F_LRAWSTRING, FFL_SPAWNTEMP},
{"pausetime", STOFS(pausetime), F_FLOAT, FFL_SPAWNTEMP},
{"item", STOFS(item), F_LSTRING, FFL_SPAWNTEMP},
{"item", STOFS(item), F_LRAWSTRING, FFL_SPAWNTEMP},
{"item", FOFS(item), F_ITEM},
{"gravity", STOFS(gravity), F_LSTRING, FFL_SPAWNTEMP},
{"sky", STOFS(sky), F_LSTRING, FFL_SPAWNTEMP},
{"gravity", STOFS(gravity), F_LRAWSTRING, FFL_SPAWNTEMP},
{"sky", STOFS(sky), F_LRAWSTRING, FFL_SPAWNTEMP},
{"skyrotate", STOFS(skyrotate), F_FLOAT, FFL_SPAWNTEMP},
{"skyautorotate", STOFS(skyautorotate), F_INT, FFL_SPAWNTEMP},
{"skyaxis", STOFS(skyaxis), F_VECTOR, FFL_SPAWNTEMP},
@ -111,8 +111,8 @@
{"maxyaw", STOFS(maxyaw), F_FLOAT, FFL_SPAWNTEMP},
{"minpitch", STOFS(minpitch), F_FLOAT, FFL_SPAWNTEMP},
{"maxpitch", STOFS(maxpitch), F_FLOAT, FFL_SPAWNTEMP},
{"music", STOFS(music), F_LSTRING, FFL_SPAWNTEMP},
{"nextmap", STOFS(nextmap), F_LSTRING, FFL_SPAWNTEMP},
{"music", STOFS(music), F_LRAWSTRING, FFL_SPAWNTEMP},
{"nextmap", STOFS(nextmap), F_LRAWSTRING, FFL_SPAWNTEMP},
{"bad_area", FOFS(bad_area), F_EDICT},
{"hint_chain", FOFS(hint_chain), F_EDICT},
{"monster_hint_chain", FOFS(monster_hint_chain), F_EDICT},