Fix armor indirection bug. The compiler ought to warn about name conflicts like these.

This commit is contained in:
Marco Cawthorne 2020-05-28 19:53:24 +02:00
parent 68669fb701
commit 4d201c281b
10 changed files with 3480 additions and 3446 deletions

View file

@ -22,7 +22,8 @@ Draws a little notification for anyone using voice chat
=================
*/
void
Voice_DrawHUD(void) {
Voice_DrawHUD(void)
{
vector pos = video_mins + [video_res[0] - 160, video_res[1] - 136];
for (int i = -1; i > -32; i--) {
@ -61,7 +62,6 @@ Voice_DrawHUD(void) {
}
}
/*
=================
Player_PreDraw
@ -74,10 +74,10 @@ Voice_Draw3D(entity t)
vector vpos = t.origin + [0,0,48];
makevectors(view_angles);
R_BeginPolygon("gfx/vgui/icntlk_pl");
R_PolygonVertex(vpos + v_right*8 - v_up*8, '1 1', [1,1,1], 1);
R_PolygonVertex(vpos - v_right*8 - v_up*8, '0 1', [1,1,1], 1);
R_PolygonVertex(vpos - v_right*8 + v_up*8, '0 0', [1,1,1], 1);
R_PolygonVertex(vpos + v_right*8 + v_up*8, '1 0', [1,1,1], 1);
R_PolygonVertex(vpos + v_right * 8 - v_up * 8, [1,1], [1,1,1], 1.0f);
R_PolygonVertex(vpos - v_right * 8 - v_up * 8, [0,1], [1,1,1], 1.0f);
R_PolygonVertex(vpos - v_right * 8 + v_up * 8, [0,0], [1,1,1], 1.0f);
R_PolygonVertex(vpos + v_right * 8 + v_up * 8, [1,0], [1,1,1], 1.0f);
R_EndPolygon();
}
}

View file

@ -58,14 +58,15 @@ void func_recharge::PlayerUse(void)
return;
}
if (eActivator.armor >= 100) {
base_player pl = (base_player)eActivator;
if (pl.armor >= 100) {
eActivator.gflags &= ~GF_USE_RELEASED;
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
} else {
if (m_eUser == world) {
sound(this, CHAN_ITEM, m_strSndCharging, 1.0, ATTN_NORM);
}
eActivator.armor = bound(0, eActivator.armor += 1, 100);
pl.armor = bound(0, pl.armor += 1, 100);
}
m_eUser = eActivator;

View file

@ -27,7 +27,6 @@
#define CLASSEXPORT(classname,classa) void classname(void) { spawnfunc_##classa(); }
var int autocvar_mp_flashlight = TRUE;
var int g_hlbsp_materials = FALSE;
void FX_Impact(int, vector, vector);
void FX_Explosion(vector);
@ -55,7 +54,6 @@ entity g_eAttacker;
.int iBleeds;
.entity eUser;
.float material;
.float armor;
.float deaths;
.float fStepTime;

View file

@ -150,10 +150,8 @@ void initents(void)
}
}
fclose(fileMaterial);
g_hlbsp_materials = TRUE;
} else {
print("Failed to load sound/materials.txt!\n");
g_hlbsp_materials = FALSE;
}
}

View file

@ -42,10 +42,6 @@ Footsteps_HLBSP(entity target)
string mat_name = "";
string tex_name = "";
if (!g_hlbsp_materials) {
return;
}
traceline(target.origin + target.view_ofs, target.origin + [0,0,-48], FALSE, target);
tex_name = getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos));

View file

@ -18,6 +18,8 @@
void
Damage_Apply(entity t, entity c, float dmg, int w, int type)
{
base_player tp = (base_player)t;
CGameRules rules = (CGameRules)g_grMode;
if (t.flags & FL_GODMODE) {
return;
@ -30,20 +32,20 @@ Damage_Apply(entity t, entity c, float dmg, int w, int type)
/* skip armor */
if not (type & DMG_SKIP_ARMOR)
if (t.armor && dmg > 0) {
if (tp.armor && dmg > 0) {
float flArmor;
float flNewDamage;
flNewDamage = dmg * 0.2;
flArmor = (dmg - flNewDamage) * 0.5;
if (flArmor > t.armor) {
flArmor = t.armor;
if (flArmor > tp.armor) {
flArmor = tp.armor;
flArmor *= (1/0.5);
flNewDamage = dmg - flArmor;
t.armor = 0;
tp.armor = 0;
} else {
t.armor -= flArmor;
tp.armor -= flArmor;
}
dmg = flNewDamage;
}

View file

@ -40,13 +40,15 @@ void item_battery::touch(void)
return;
}
if (other.armor >= 100) {
base_player pl = (base_player)other;
if (pl.armor >= 100) {
return;
}
/* Move this somewhere else? */
other.armor += Skill_GetValue("battery");
if (other.armor > 100) {
other.armor = 100;
pl.armor += Skill_GetValue("battery");
if (pl.armor > 100) {
pl.armor = 100;
}
Logging_Pickup(other, this, __NULL__);

View file

@ -1,5 +1,5 @@
/*
This file was generated by FTE Quake 5665:5666M, dated Apr 7 2020.
This file was generated by FTE Quake SVNREVISION, dated .
This file can be regenerated by issuing the following command:
pr_dumpplatform
Available options:
@ -64,6 +64,7 @@ Available options:
#define BX_COLOREDTEXT
#define DP_CON_SET /* The 'set' console command exists, and can be used to create/set cvars. */
#define DP_CON_SETA /* The 'seta' console command exists, like the 'set' command, but also marks the cvar for archiving, allowing it to be written into the user's config. Use this command in your default.cfg file. */
#define DP_CSQC_ROTATEMOVES
#define DP_EF_ADDITIVE
#define DP_EF_BLUE
#define DP_EF_FULLBRIGHT
@ -94,6 +95,7 @@ Available options:
#define DP_QC_CVAR_DEFSTRING
#define DP_QC_CVAR_STRING
#define DP_QC_CVAR_TYPE
#define DP_QC_DIGEST_SHA256
#define DP_QC_EDICT_NUM
#define DP_QC_ENTITYDATA
#define DP_QC_ETOS
@ -206,6 +208,10 @@ Available options:
#define FTE_QC_CHECKPVS
#define FTE_QC_CROSSPRODUCT
#define FTE_QC_CUSTOMSKINS /* The engine supports the use of q3 skins, as well as the use of such skin 'files' to specify rich top+bottom colours, qw skins, geomsets, or texture composition even on non-players.. */
#define FTE_QC_DIGEST_SHA1
#define FTE_QC_DIGEST_SHA224
#define FTE_QC_DIGEST_SHA384
#define FTE_QC_DIGEST_SHA512
#define FTE_QC_FS_SEARCH_SIZEMTIME
#define FTE_QC_HARDWARECURSORS /* setcursormode exists in both csqc+menuqc, and accepts additional arguments to specify a cursor image to use when this module has focus. If the image exceeds hardware limits (or hardware cursors are unsupported), it will be emulated using regular draws - this at least still avoids conflicting cursors as only one will ever be used, even if console+menu+csqc are all overlayed. */
#define FTE_QC_HASHTABLES /* Provides efficient string-based lookups. */
@ -503,11 +509,22 @@ int trace_triangle_id; /* 1-based. 0 if not known. */
#endif
#ifdef CSQC
int trace_networkentity; /* Repots which ssqc entnum was hit when a csqc traceline impacts an ssqc-based brush entity. */
vector pmove_org; /* Reports the origin of the engineside player (after prediction). Does not work when the player is a csqc-owned entity. */
vector pmove_vel; /* Reports the velocity of the engineside player (after prediction). Does not work when the player is a csqc-owned entity. */
float pmove_onground; /* Reports the onground state of the engineside player (after prediction). Does not work when the player is a csqc-owned entity. */
#endif
#if defined(CSQC) || defined(SSQC)
vector global_gravitydir = '0 0 -1'; /* The direction gravity should act in if not otherwise specified per entity. */
int serverid; /* The unique id of this server within the server cluster. */
#endif
#ifdef SSQC
.float button3;
.float button4;
.float button5;
.float button6;
.float button7;
.float button8;
#endif
#if defined(NQSSQC)
.float lastruntime; /* This field used to be used to avoid running an entity multiple times in a single frame due to quakeworld's out-of-order thinks. It is no longer used by FTE due to precision issues, but may still be updated for compatibility reasons. */
#endif
@ -1110,6 +1127,9 @@ const float STAT_VIEWZOOM = 21; /* Scales fov and sensitiity. Part of DP_VIEWZOO
const float STAT_USER = 32; /* Custom user stats start here (lower values are reserved for engine use). */
#endif
#if defined(CSQC) || defined(MENU)
const float PRECACHE_PIC_FROMWAD = 1; /* Attempt to load it from the legacy gfx.wad file (usually its better to just use a gfx/ prefix instead). */
const float PRECACHE_PIC_DOWNLOAD = 256; /* If no image could be loaded then attempt to download one from the server. This flag can cause the function to block until completion. (Slow!) */
const float PRECACHE_PIC_TEST = 512; /* The precache will block until the image is fully loaded, returning a null string on failure. (Slow!) */
const float VF_MIN = 1; /* The top-left of the 3d viewport in screenspace. The VF_ values are used via the setviewprop/getviewprop builtins. */
const float VF_MIN_X = 2;
const float VF_MIN_Y = 3;
@ -1220,6 +1240,7 @@ const float GGDI_DESCRIPTION = 1; /* The human-readable title of the mod. Empty
const float GGDI_OVERRIDES = 2; /* A list of settings overrides. */
const float GGDI_LOADCOMMAND = 3; /* The console command needed to actually load the mod. */
const float GGDI_ICON = 4; /* The mod's Icon path, ready for drawpic. */
const float GGDI_GAMEDIRLIST = 4; /* A semi-colon delimited list of gamedirs that the mod's content can be loaded through. */
#endif
#ifdef SSQC
const float CLIENTTYPE_DISCONNECTED = 0; /* Return value from clienttype() builtin. This entity is a player slot that is currently empty. */
@ -1463,6 +1484,7 @@ string(string str, float num, string setval) altstr_set = #85; /*
entity(entity start, .float field, float match) findflags = #87; /* Part of DP_QC_FINDFLAGS*/
entity(.float field, float match) findchainflags = #88; /* Part of DP_QC_FINDCHAINFLAGS*/
string(string name) cvar_defstring = #89; /* Part of DP_QC_CVAR_DEFSTRING*/
void(entity ent, string mname) setmodel = #90; /*
Menuqc-specific version. */
@ -2273,18 +2295,24 @@ float(float resourcetype, float tryload, string resourcename) resourcestatus = #
#endif
hashtable(float tabsize, optional float defaulttype) hash_createtab = #287; /* Part of FTE_QC_HASHTABLES
Creates a hash table object with at least 'tabsize' slots. hash table with index 0 is a game-persistant table and will NEVER be returned by this builtin (except as an error return). */
Creates a hash table object.
The tabsize argument is a performance hint and should generally be set to something similar to the number of entries expected, typically a power of two assumption. Too high simply wastes memory, too low results in extra string compares but no actual bugs.
defaulttype must be one of the EV_* values, if specified.
The hash table with index 0 is a game-persistant table and will NEVER be returned by this builtin (except as an error return). */
void(hashtable table) hash_destroytab = #288; /* Part of FTE_QC_HASHTABLES
Destroys a hash table object. */
void(hashtable table, string name, __variant value, optional float typeandflags) hash_add = #289; /* Part of FTE_QC_HASHTABLES
Adds the given key with the given value to the table.
If flags&HASH_REPLACE, the old value will be removed, if not set then multiple values may be added for a single key, they won't overwrite.
The type argument describes how the value should be stored and saved to files. While you can claim that all variables are just vectors, being more precise can result in less issues with tempstrings or saved games. */
If flags&HASH_REPLACE, the old value will be removed, otherwise if flags&HASH_ADD then a duplicate entry will be added with a second value (can be obtained via hash_get's index argument).
The type argument describes how the value should be stored in saved games, as well as providing constraints with the hash_get function. While you can claim that all variables are just vectors, being more precise can result in less issues with tempstrings or saved games - be sure to be explicit with EV_STRING where appropriate because tempstrings may be reclaimed before the get (especially with saved games or table 0). */
__variant(hashtable table, string name, optional __variant deflt, optional float requiretype, optional float index) hash_get = #290; /* Part of FTE_QC_HASHTABLES
looks up the specified key name in the hash table. returns deflt if key was not found. If stringsonly=1, the return value will be in the form of a tempstring, otherwise it'll be the original value argument exactly as it was. If requiretype is specified, then values not of the specified type will be ignored. Hurrah for multiple types with the same name. */
Looks up the specified key name in the hash table. Returns deflt if the key was not found.
If requiretype is specified then the function will only consider entries of the matching type (allowing you to store both flags+strings under a single name without getting confused).
If index is specified then the function will ignore the first N entries with the same key (applicable only with entries added using HASH_ADD, not HASH_REPLACE), allowing you to store multiple entries. Keep querying higher indexes starting from 0 until it returns the deflt value.
You will usually need to cast the result of this function to a real datatype. */
__variant(hashtable table, string name) hash_delete = #291; /* Part of FTE_QC_HASHTABLES
removes the named key. returns the value of the object that was destroyed, or 0 on error. */
@ -2398,8 +2426,8 @@ void(float width, vector pos1, vector pos2, vector rgb, float alpha, optional fl
float(string name) iscachedpic = #316; /*
Checks to see if the image is currently loaded. Engines might lie, or cache between maps. */
string(string name, optional float trywad) precache_pic = #317; /*
Forces the engine to load the named image. If trywad is specified, the specified name must lack any path and extension. */
string(string name, optional float flags) precache_pic = #317; /*
Forces the engine to load the named image. Flags are a bitmask of the PRECACHE_PIC_* flags. */
#endif
#if defined(CSQC) || defined(MENU)
@ -2413,7 +2441,7 @@ int*(string filename, __out int width, __out int height) r_readimage = #0:r_read
#ifdef CSQC
#define draw_getimagesize drawgetimagesize
vector(string picname) drawgetimagesize = #318; /*
Returns the dimensions of the named image. Images specified with .lmp should give the original .lmp's dimensions even if texture replacements use a different resolution. */
Returns the dimensions of the named image. Images specified with .lmp should give the original .lmp's dimensions even if texture replacements use a different resolution. WARNING: this function may be slow if used without or directly after its initial precache_pic. */
void(string name) freepic = #319; /*
Tells the engine that the image is no longer needed. The image will appear to be new the next time its needed. */
@ -2809,6 +2837,11 @@ float() cvars_haveunsaved = #0:cvars_haveunsaved; /*
float(entity e, float nowreadonly) entityprotection = #0:entityprotection; /*
Changes the protection on the specified entity to protect it from further edits from QC. The return value is the previous setting. Note that this can be used to unprotect the world, but doing so long term is not advised as you will no longer be able to detect invalid entity references. Also, world is not networked, so results might not be seen by clients (or in other words, world.avelocity_y=64 is a bad idea). */
#ifdef CSQC
string(vector pos) getlocationname = #0:getlocationname; /*
Looks up the specified position in the current map's .loc file and reports the nearest marked name. */
#endif
#if defined(CSQC) || defined(SSQC)
entity(entity from, optional entity to) copyentity = #400; /* Part of DP_QC_COPYENTITY
Copies all fields from one entity to another. */
@ -2956,8 +2989,8 @@ string(float uselocaltime, string format, ...) strftime = #478; /* Part of DP_QC
float(string s, string separator1, ...) tokenizebyseparator = #479; /* Part of DP_QC_TOKENIZEBYSEPARATOR*/
string(string s) strtolower = #480; /* Part of DP_QC_STRING_CASE_FUNCTIONS*/
string(string s) strtoupper = #481; /* Part of DP_QC_STRING_CASE_FUNCTIONS*/
string(string s) cvar_defstring = #482; /* Part of DP_QC_CVAR_DEFSTRING*/
#if defined(CSQC) || defined(SSQC)
string(string s) cvar_defstring = #482; /* Part of DP_QC_CVAR_DEFSTRING*/
void(vector origin, string sample, float volume, float attenuation) pointsound = #483; /* Part of DP_SV_POINTSOUND*/
#endif
string(string search, string replace, string subject) strreplace = #484; /* Part of DP_QC_STRREPLACE*/
@ -3191,6 +3224,9 @@ string() getextresponse = #624; /* Part of FTE_CSQC_SERVERBROWSER*/
string(string dnsname, optional float defport) netaddress_resolve = #625;
#if defined(CSQC) || defined(MENU)
string(float n, float prop) getgamedirinfo = #626;
string(int n, int prop) getpackagemanagerinfo = #0:getpackagemanagerinfo; /*
Queries information about a package from the engine's package manager subsystem. Actions can be taken via the pkg console command. */
#endif
string(string fmt, ...) sprintf = #627; /* Part of DP_QC_SPRINTF
'prints' to a formatted temp-string. Mostly acts as in C, however %d assumes floats (fteqcc has arg checking. Use it.).

View file

@ -59,8 +59,8 @@ class base_player
int old_flags;
int old_activeweapon;
int old_items;
int old_health;
int old_armor;
float old_health;
float old_armor;
int old_movetype;
float old_viewofs;
int old_baseframe;

View file

@ -31,6 +31,7 @@ Tripmine Weapon
#ifdef SERVER
class monster_tripmine:CBaseMonster
{
float armor;
void(void) monster_tripmine;
virtual float(entity, float) SendEntity;
@ -43,15 +44,15 @@ float
monster_tripmine::SendEntity(entity pvsent, float flags)
{
WriteByte(MSG_ENTITY, ENT_TRIPMINE);
WriteCoord(MSG_ENTITY, self.origin[0]);
WriteCoord(MSG_ENTITY, self.origin[1]);
WriteCoord(MSG_ENTITY, self.origin[2]);
WriteCoord(MSG_ENTITY, self.angles[0]);
WriteCoord(MSG_ENTITY, self.angles[1]);
WriteCoord(MSG_ENTITY, self.angles[2]);
WriteFloat(MSG_ENTITY, self.armor);
WriteByte(MSG_ENTITY, self.health);
WriteShort(MSG_ENTITY, self.modelindex);
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
WriteCoord(MSG_ENTITY, origin[2]);
WriteCoord(MSG_ENTITY, angles[0]);
WriteCoord(MSG_ENTITY, angles[1]);
WriteCoord(MSG_ENTITY, angles[2]);
WriteFloat(MSG_ENTITY, armor);
WriteByte(MSG_ENTITY, health);
WriteShort(MSG_ENTITY, modelindex);
return TRUE;
}