From 0b792a6355899da41cef3dc6ca9d1336f41e45c8 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 9 Nov 2008 23:29:13 +0000 Subject: [PATCH] Made the boolean type consistently int or float, without using conversions. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3053 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- quakec/basemod/ai.qc | 17 +++--- quakec/basemod/client.qc | 3 +- quakec/basemod/combat.qc | Bin 6744 -> 6742 bytes quakec/basemod/defs.qc | 117 ++++++++++++++++++++++++++------------ quakec/basemod/demon.qc | 7 ++- quakec/basemod/dog.qc | 7 ++- quakec/basemod/doors.qc | 4 +- quakec/basemod/effects.qc | 2 +- quakec/basemod/engine.qc | Bin 5433 -> 5442 bytes quakec/basemod/fight.qc | Bin 6584 -> 6579 bytes quakec/basemod/items.qc | 1 + quakec/basemod/misc.qc | 5 +- quakec/basemod/ogre.qc | 1 + quakec/basemod/progs.src | 2 +- quakec/basemod/subs.qc | Bin 6024 -> 6025 bytes quakec/basemod/weapons.qc | 5 +- quakec/basemod/wizard.qc | 3 +- 17 files changed, 115 insertions(+), 59 deletions(-) diff --git a/quakec/basemod/ai.qc b/quakec/basemod/ai.qc index 0c649ae4b..9ded2dda7 100644 --- a/quakec/basemod/ai.qc +++ b/quakec/basemod/ai.qc @@ -158,7 +158,7 @@ visible returns 1 if the entity is visible to self, even if not infront () ============= */ -float (entity targ) visible = +BOOL (entity targ) visible = { local vector spot1, spot2; @@ -182,7 +182,7 @@ infront returns 1 if the entity is in front (in sight) of self ============= */ -float(entity targ) infront = +BOOL(entity targ) infront = { local vector vec; local float dot; @@ -350,7 +350,7 @@ checked each frame. This means multi player games will have slightly slower noticing monsters. ============ */ -float() FindTarget = +BOOL() FindTarget = { local entity client; local float r; @@ -570,7 +570,7 @@ FacingIdeal ============ */ -float() FacingIdeal = +BOOL() FacingIdeal = { local float delta; @@ -582,11 +582,11 @@ float() FacingIdeal = //============================================================================= -float(float enemy_range) DogCheckAttack; -float(float enemy_range) WizardCheckAttack; -float(float enemy_range) DemonCheckAttack; +BOOL(float enemy_range) DogCheckAttack; +BOOL(float enemy_range) WizardCheckAttack; +BOOL(float enemy_range) DemonCheckAttack; -float(float enemy_range) CheckAnyAttack = +BOOL(float enemy_range) CheckAnyAttack = { switch (self.classname) @@ -748,3 +748,4 @@ void(float dist) ai_run = movetogoal (dist); // done in C code... }; + \ No newline at end of file diff --git a/quakec/basemod/client.qc b/quakec/basemod/client.qc index 1ae402eb3..f22542e2a 100644 --- a/quakec/basemod/client.qc +++ b/quakec/basemod/client.qc @@ -1280,7 +1280,7 @@ ClientObituary called when a player dies ============ */ -float(entity targ, entity attacker) OnSameTeam; +BOOL(entity targ, entity attacker) OnSameTeam; void(entity targ, entity attacker, INTEGER mod) ClientObituary = { @@ -1319,3 +1319,4 @@ void(entity targ, entity attacker, INTEGER mod) ClientObituary = } }; + \ No newline at end of file diff --git a/quakec/basemod/combat.qc b/quakec/basemod/combat.qc index cd68a9b4f89144fd4cd7a64970ecebb92d772a3b..17cf50a6a014708c390e64cfa57bf45dd1f8339d 100644 GIT binary patch delta 45 scmca%a?NDJXGRt$e}A8e@}ir0nM&E99NEoFIHoayIh*adCHWZ{0API$Hvj+t delta 53 xcmca+a>Hc9XGYevoczR+iSnY8@AGhO7G=s|gNev)Uc@nt3C7deoWcE;4*($F6H@>H diff --git a/quakec/basemod/defs.qc b/quakec/basemod/defs.qc index d71c6aafe..2e6f64fda 100644 --- a/quakec/basemod/defs.qc +++ b/quakec/basemod/defs.qc @@ -1,7 +1,3 @@ - -#define FALSE 0 -#define TRUE 1 - #ifdef FTE // use real int if using FTE type progs #define INTEGER int @@ -9,6 +5,12 @@ #define INTEGER float #endif +#define BOOL INTEGER + + +#define FALSE ((BOOL)0) +#define TRUE ((BOOL)1) + /* ============================================================================== @@ -425,7 +427,6 @@ float EF_FLAG2 = 32; // float movedist; string string_null; // null string, nothing should be held here -float empty_float; entity activator; // the entity that activated a trigger or brush @@ -480,8 +481,8 @@ entity shub; // boss entity .INTEGER ammo_cells_real; // real cells count // Zoid Additions -.float maxspeed; // Used to set Maxspeed on a player -.float gravity; // Gravity Multiplier (0 to 1.0) +noref .float maxspeed; // Used to set Maxspeed on a player +noref .float gravity; // Gravity Multiplier (0 to 1.0) .float attack_finished; // used with lots of stuff... .float pain_finished; // used with monsters/players @@ -556,10 +557,9 @@ enum { }; // unions -// DO NOT MIX UNION TYPES LIKE I AM DOING +//floats (includes vectors) .union { struct { // fields used with world object - string wad; float worldtype; // world type, 0=medieval 1=metal 2=base }; struct { // fields used with triggers/doors/plats @@ -567,7 +567,6 @@ enum { float wait; // time from firing to restarting float t_length; // override length to move sideways float t_width; // override length to move upwards/downwards - void() think1; // used with SUB_CalcMove vector finaldest; // used with SUB_CalcMove vector finalangle; // used with SUB_CalcMove float count; // for counting triggers @@ -578,14 +577,11 @@ enum { vector pos1; // top position (doors/buttons/plats) vector pos2; // bottom position (doors/buttons/plats) float height; // height (plats/trigger_monsterjump) - string noise4; // extra sound (doors) - entity trigger_field; // used with linking (doors) vector dest1; // passed to CalcMove (doors) vector dest2; // passed to CalcMove (doors) }; struct { // fields used with players float weaponframe_time; // weapon frame advance time - INTEGER weaponstate; // firing state of current weapon float suicide_time; // time to allow suicide after spawn float healdecay; // time when health will decay float show_hostile; // used to alert monsters @@ -604,32 +600,18 @@ enum { float swim_flag; // swim sound playback float air_finished; // when time > air_finished, start drowning float waterdmg; // damage water will deal when drowning - INTEGER walkframe; // used with walking animation float jump_flag; // last z velocity used for falling damage - INTEGER ammo_type; // ammo type in use - }; - struct { // fields used with bubbles spawned from drowning - INTEGER bubble_count; // keeps track of the number of bubbles - INTEGER bubble_state; // associated with bubble progression }; struct { // fields used with items float healamount; // amount healed with health item - INTEGER healtype; // type of health with health item - string mdl; // model used with SUB_regen float ammo_count; // ammo amount }; struct { // fields used with generic projectiles float damage_direct; // damage done with a direct hit float damage_exp; // damage done from radius damage float radius_exp; // radius of radius damage - INTEGER mod_direct; // mod type for direct hit - INTEGER mod_exp; // mod type for radius damage float expire_time; // time when projectile dies - void() proj_think; // extra think function used with projectile float proj_think_time; // interval between thinks - INTEGER proj_effect; // effect used with projectile - INTEGER voided; // projectile has been voided - float() proj_touch; // extra touch function used with projectile }; struct { // fields used with lights float light_lev; // not used by game, but parsed by light util @@ -638,13 +620,6 @@ enum { struct { // fields used with monsters float search_time; // search time intervals float attack_state; // current AI attack state - void() th_stand; // standing animation - void() th_walk; // walking animation - void() th_run; // running animation - void() th_missile; // ranged animation - void() th_melee; // melee animation - entity oldenemy; // old enemy - entity movetarget; // target entity to move to float pausetime; // time to pause for monsters float hknightattack; // hell knight attack pattern float lefty; // ai slide move @@ -662,6 +637,77 @@ enum { */ }; +//integers +.union { + + struct { // fields used with players + INTEGER weaponstate; // firing state of current weapon + INTEGER walkframe; // used with walking animation + INTEGER ammo_type; // ammo type in use + }; + struct { // fields used with bubbles spawned from drowning + INTEGER bubble_count; // keeps track of the number of bubbles + INTEGER bubble_state; // associated with bubble progression + }; + struct { // fields used with items + INTEGER healtype; // type of health with health item + }; + struct { // fields used with generic projectiles + INTEGER mod_direct; // mod type for direct hit + INTEGER mod_exp; // mod type for radius damage + INTEGER proj_effect; // effect used with projectile + INTEGER voided; // projectile has been voided + }; +}; + +//functions +.union { + struct { // fields used with triggers/doors/plats + void() think1; // used with SUB_CalcMove + }; + struct { // fields used with generic projectiles + void() proj_think; // extra think function used with projectile + float() proj_touch; // extra touch function used with projectile + }; + struct { // fields used with monsters + void() th_stand; // standing animation + void() th_walk; // walking animation + void() th_run; // running animation + void() th_missile; // ranged animation + void() th_melee; // melee animation + }; +}; + + +//entities +.union { + struct { // fields used with triggers/doors/plats + entity trigger_field; // used with linking (doors) + }; + + struct { // fields used with monsters + entity oldenemy; // old enemy + entity movetarget; // target entity to move to + }; +}; + +//strings +.union { + struct { // fields used with world object + string wad; //mute it + }; + struct { // fields used with triggers/doors/plats + string noise4; // extra sound (doors) + }; + struct { // fields used with items + string mdl; // model used with SUB_regen + }; +}; + +//mute those warnings (unions/structs do not support noref mid-struct, but a later def will propogate the noref flag) +noref .string wad; +noref .float light_lev; + //=========================================================================== @@ -789,5 +835,6 @@ void(entity targ, entity inflictor, entity attacker, float damage, INTEGER mod) float (entity e, float healamount, float ignore) T_Heal; // health function -float(entity targ, entity inflictor) CanDamage; +BOOL(entity targ, entity inflictor) CanDamage; + \ No newline at end of file diff --git a/quakec/basemod/demon.qc b/quakec/basemod/demon.qc index 3da513ce2..4f6808989 100644 --- a/quakec/basemod/demon.qc +++ b/quakec/basemod/demon.qc @@ -230,7 +230,7 @@ CheckDemonMelee Returns TRUE if a melee attack would hit right now ============== */ -float(float enemy_range) CheckDemonMelee = +BOOL(float enemy_range) CheckDemonMelee = { if (enemy_range == RANGE_MELEE) { // FIXME: check canreach @@ -246,7 +246,7 @@ CheckDemonJump ============== */ -float() CheckDemonJump = +BOOL() CheckDemonJump = { local vector dist; local float d; @@ -276,7 +276,7 @@ float() CheckDemonJump = return TRUE; }; -float(float enemy_range) DemonCheckAttack = +BOOL(float enemy_range) DemonCheckAttack = { // if close enough for slashing, go for it if (CheckDemonMelee (enemy_range)) @@ -354,3 +354,4 @@ void() Demon_JumpTouch = self.nextthink = time + 0.1; }; + \ No newline at end of file diff --git a/quakec/basemod/dog.qc b/quakec/basemod/dog.qc index 782597be2..791d7a727 100644 --- a/quakec/basemod/dog.qc +++ b/quakec/basemod/dog.qc @@ -253,7 +253,7 @@ CheckDogMelee Returns TRUE if a melee attack would hit right now ============== */ -float(float enemy_range) CheckDogMelee = +BOOL(float enemy_range) CheckDogMelee = { if (enemy_range == RANGE_MELEE) { // FIXME: check canreach @@ -269,7 +269,7 @@ CheckDogJump ============== */ -float() CheckDogJump = +BOOL() CheckDogJump = { local vector dist; local float d; @@ -296,7 +296,7 @@ float() CheckDogJump = return TRUE; }; -float(float enemy_range) DogCheckAttack = +BOOL(float enemy_range) DogCheckAttack = { // if close enough for slashing, go for it if (CheckDogMelee (enemy_range)) @@ -354,3 +354,4 @@ void() monster_dog = walkmonster_start(); }; + \ No newline at end of file diff --git a/quakec/basemod/doors.qc b/quakec/basemod/doors.qc index 9f05c65ea..d06a8419e 100644 --- a/quakec/basemod/doors.qc +++ b/quakec/basemod/doors.qc @@ -287,7 +287,7 @@ entity(vector fmins, vector fmaxs) spawn_field = }; -float (entity e1, entity e2) EntitiesTouching = +BOOL (entity e1, entity e2) EntitiesTouching = { if (e1.mins_x > e2.maxs_x) return FALSE; @@ -767,4 +767,4 @@ void () func_door_secret = self.oldorigin = self.origin; if (!self.wait) self.wait = 5; // 5 seconds before closing -}; +}; \ No newline at end of file diff --git a/quakec/basemod/effects.qc b/quakec/basemod/effects.qc index 05a6ad45a..773cae334 100644 --- a/quakec/basemod/effects.qc +++ b/quakec/basemod/effects.qc @@ -291,4 +291,4 @@ void(float damage) spawn_touchblood = vel = vel + 2*trace_plane_normal; vel = vel * 0.4; SpawnBlood (self.origin + vel, damage); -}; +}; \ No newline at end of file diff --git a/quakec/basemod/engine.qc b/quakec/basemod/engine.qc index ab7963d6fea3fdab83a76f940762c1390574959d..6e7a41a6c8f0af0b210d1371f003138db686f01b 100644 GIT binary patch delta 22 dcmdm~bx3Oi2P3Khc1 delta 72 zcmdmNyu*0I0!G%foczR+%}W@!utJ!VW7s92f)(sDpn{u4cw<X!yUYN= CKN 0) return TRUE; @@ -1222,3 +1222,4 @@ void() testfunction = return; }; */ + \ No newline at end of file diff --git a/quakec/basemod/wizard.qc b/quakec/basemod/wizard.qc index 6ef64fa60..0b9d5c679 100644 --- a/quakec/basemod/wizard.qc +++ b/quakec/basemod/wizard.qc @@ -43,7 +43,7 @@ void() wiz_side1; WizardCheckAttack ================= */ -float(float enemy_range) WizardCheckAttack = +BOOL(float enemy_range) WizardCheckAttack = { local vector spot1, spot2; local entity targ; @@ -317,3 +317,4 @@ void() monster_wizard = flymonster_start (); }; + \ No newline at end of file