From: Mario Date: Sat, 9 Jun 2018 16:23:57 +0000 (+1000) Subject: Clean up mapobjects' includes a little bit, move some subs around X-Git-Tag: xonotic-v0.8.5~2097 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=44d3fb06e530c783948c7f292b40f70330729fa9;p=xonotic%2Fxonotic-data.pk3dir.git Clean up mapobjects' includes a little bit, move some subs around --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 8e0c76d42..c22112541 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/qcsrc/common/_all.inc b/qcsrc/common/_all.inc index 708b4e951..9d7c68a8e 100644 --- a/qcsrc/common/_all.inc +++ b/qcsrc/common/_all.inc @@ -22,7 +22,7 @@ noref float autocvar_net_connecttimeout = 30; #ifdef GAMEQC #include "physics/all.inc" -#include "mapobjects/include.qc" +#include "mapobjects/_mod.inc" #include "viewloc.qc" #endif diff --git a/qcsrc/common/mapobjects/_mod.inc b/qcsrc/common/mapobjects/_mod.inc index efc838487..1aab2b927 100644 --- a/qcsrc/common/mapobjects/_mod.inc +++ b/qcsrc/common/mapobjects/_mod.inc @@ -1,5 +1,5 @@ // generated file; do not modify -#include +#include #include #include #include diff --git a/qcsrc/common/mapobjects/_mod.qh b/qcsrc/common/mapobjects/_mod.qh index 11854c091..ebb7a4325 100644 --- a/qcsrc/common/mapobjects/_mod.qh +++ b/qcsrc/common/mapobjects/_mod.qh @@ -1,5 +1,5 @@ // generated file; do not modify -#include +#include #include #include #include diff --git a/qcsrc/common/mapobjects/func/_mod.inc b/qcsrc/common/mapobjects/func/_mod.inc index e3425e34a..0c82e979a 100644 --- a/qcsrc/common/mapobjects/func/_mod.inc +++ b/qcsrc/common/mapobjects/func/_mod.inc @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/common/mapobjects/func/_mod.qh b/qcsrc/common/mapobjects/func/_mod.qh index c0381a3f2..052edb954 100644 --- a/qcsrc/common/mapobjects/func/_mod.qh +++ b/qcsrc/common/mapobjects/func/_mod.qh @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/common/mapobjects/func/include.qc b/qcsrc/common/mapobjects/func/include.qc deleted file mode 100644 index 290c2e984..000000000 --- a/qcsrc/common/mapobjects/func/include.qc +++ /dev/null @@ -1,19 +0,0 @@ -#include "include.qh" - -#include "bobbing.qc" -#include "breakable.qc" -#include "button.qc" -#include "conveyor.qc" -#include "door.qc" -#include "door_rotating.qc" -#include "door_secret.qc" -#include "fourier.qc" -#include "ladder.qc" -#include "pendulum.qc" -#include "plat.qc" -#include "pointparticles.qc" -#include "rainsnow.qc" -#include "rotating.qc" -#include "stardust.qc" -#include "train.qc" -#include "vectormamamam.qc" diff --git a/qcsrc/common/mapobjects/func/include.qh b/qcsrc/common/mapobjects/func/include.qh deleted file mode 100644 index 4e8b94cd1..000000000 --- a/qcsrc/common/mapobjects/func/include.qh +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include "door.qh" -#include "ladder.qh" -#include "train.qh" diff --git a/qcsrc/common/mapobjects/include.qc b/qcsrc/common/mapobjects/include.qc deleted file mode 100644 index 59da1f217..000000000 --- a/qcsrc/common/mapobjects/include.qc +++ /dev/null @@ -1,20 +0,0 @@ -#include "include.qh" - -// some required common stuff -#include "subs.qc" -#include "triggers.qc" -#include "platforms.qc" -#include "teleporters.qc" - -// func -#include "func/include.qc" - -// misc -#include "misc/include.qc" - -// target -#include "target/include.qc" - -// trigger -#include "trigger/include.qc" - diff --git a/qcsrc/common/mapobjects/include.qh b/qcsrc/common/mapobjects/include.qh deleted file mode 100644 index 87c07c14d..000000000 --- a/qcsrc/common/mapobjects/include.qh +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -// some required common stuff -#ifdef SVQC - #include -#endif -#include "triggers.qh" -#include "subs.qh" -#include "platforms.qh" -#include "teleporters.qh" - -// func -#include "func/include.qh" - -// target -#include "target/include.qh" - -// trigger -#include "trigger/include.qh" diff --git a/qcsrc/common/mapobjects/misc/_mod.inc b/qcsrc/common/mapobjects/misc/_mod.inc index d8d5ea6a6..3698cf822 100644 --- a/qcsrc/common/mapobjects/misc/_mod.inc +++ b/qcsrc/common/mapobjects/misc/_mod.inc @@ -1,6 +1,5 @@ // generated file; do not modify #include #include -#include #include #include diff --git a/qcsrc/common/mapobjects/misc/_mod.qh b/qcsrc/common/mapobjects/misc/_mod.qh index 5fefbe41b..5b156176e 100644 --- a/qcsrc/common/mapobjects/misc/_mod.qh +++ b/qcsrc/common/mapobjects/misc/_mod.qh @@ -1,6 +1,5 @@ // generated file; do not modify #include #include -#include #include #include diff --git a/qcsrc/common/mapobjects/misc/include.qc b/qcsrc/common/mapobjects/misc/include.qc deleted file mode 100644 index bbe5ce03d..000000000 --- a/qcsrc/common/mapobjects/misc/include.qc +++ /dev/null @@ -1,5 +0,0 @@ -#include "include.qh" -#include "corner.qc" -#include "follow.qc" -#include "laser.qc" -#include "teleport_dest.qc" diff --git a/qcsrc/common/mapobjects/misc/include.qh b/qcsrc/common/mapobjects/misc/include.qh deleted file mode 100644 index 6f70f09be..000000000 --- a/qcsrc/common/mapobjects/misc/include.qh +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/qcsrc/common/mapobjects/models.qc b/qcsrc/common/mapobjects/models.qc new file mode 100644 index 000000000..9b1f2f8a4 --- /dev/null +++ b/qcsrc/common/mapobjects/models.qc @@ -0,0 +1,196 @@ +#include "models.qh" + +#ifdef SVQC +#include +#include +#include +#include +#include "subs.qh" +#include "triggers.qh" + +entityclass(BGMScript); +classfield(BGMScript) .string bgmscript; +classfield(BGMScript) .float bgmscriptattack; +classfield(BGMScript) .float bgmscriptdecay; +classfield(BGMScript) .float bgmscriptsustain; +classfield(BGMScript) .float bgmscriptrelease; + +#include +#include "../../lib/csqcmodel/sv_model.qh" + +.float modelscale; + +void g_model_setcolormaptoactivator(entity this, entity actor, entity trigger) +{ + if(teamplay) + { + if(actor.team) + this.colormap = (actor.team - 1) * 0x11; + else + this.colormap = 0x00; + } + else + this.colormap = floor(random() * 256); + this.colormap |= BIT(10); // RENDER_COLORMAPPED +} + +void g_clientmodel_setcolormaptoactivator(entity this, entity actor, entity trigger) +{ + g_model_setcolormaptoactivator(this, actor, trigger); + this.SendFlags |= (BIT(3) | BIT(0)); +} + +void g_clientmodel_use(entity this, entity actor, entity trigger) +{ + if (this.antiwall_flag == 1) + { + this.inactive = 1; + this.solid = SOLID_NOT; + } + else if (this.antiwall_flag == 2) + { + this.inactive = 0; + this.solid = this.default_solid; + } + g_clientmodel_setcolormaptoactivator(this, actor, trigger); +} + +void g_model_dropbyspawnflags(entity this) +{ + if((this.spawnflags & 3) == 1) // ALIGN_ORIGIN + { + traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this); + setorigin(this, trace_endpos); + } + else if((this.spawnflags & 3) == 2) // ALIGN_BOTTOM + { + tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 4096', MOVE_NOMONSTERS, this); + setorigin(this, trace_endpos); + } + else if((this.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM + { + traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this); + setorigin(this, trace_endpos - '0 0 1' * this.mins.z); + } +} + +void g_clientmodel_dropbyspawnflags(entity this) +{ + vector o0; + o0 = this.origin; + g_model_dropbyspawnflags(this); + if(this.origin != o0) + this.SendFlags |= 2; +} + +bool g_clientmodel_genericsendentity(entity this, entity to, int sf) +{ + sf = sf & 0x0F; + if(this.angles != '0 0 0') + sf |= 0x10; + if(this.mins != '0 0 0' || this.maxs != '0 0 0') + sf |= 0x20; + if(this.colormap != 0) + sf |= 0x40; + if(this.lodmodelindex1) + sf |= 0x80; + + WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL); + WriteByte(MSG_ENTITY, sf); + + if(sf & BIT(0)) + { + if(sf & 0x40) + WriteShort(MSG_ENTITY, this.colormap); + WriteByte(MSG_ENTITY, this.skin); + } + + if(sf & BIT(1)) + { + WriteVector(MSG_ENTITY, this.origin); + } + + if(sf & BIT(2)) + { + if(sf & 0x10) + { + WriteAngle(MSG_ENTITY, this.angles.x); + WriteAngle(MSG_ENTITY, this.angles.y); + WriteAngle(MSG_ENTITY, this.angles.z); + } + } + + if(sf & BIT(3)) + { + if(sf & 0x80) + { + WriteShort(MSG_ENTITY, this.lodmodelindex0); + WriteShort(MSG_ENTITY, bound(0, this.loddistance1, 65535)); + WriteShort(MSG_ENTITY, this.lodmodelindex1); + WriteShort(MSG_ENTITY, bound(0, this.loddistance2, 65535)); + WriteShort(MSG_ENTITY, this.lodmodelindex2); + } + else + WriteShort(MSG_ENTITY, this.modelindex); + WriteByte(MSG_ENTITY, this.solid); + WriteShort(MSG_ENTITY, floor(this.scale * 256)); + if(sf & 0x20) + { + WriteVector(MSG_ENTITY, this.mins); + WriteVector(MSG_ENTITY, this.maxs); + } + WriteString(MSG_ENTITY, this.bgmscript); + if(this.bgmscript != "") + { + WriteByte(MSG_ENTITY, floor(this.bgmscriptattack * 64)); + WriteByte(MSG_ENTITY, floor(this.bgmscriptdecay * 64)); + WriteByte(MSG_ENTITY, floor(this.bgmscriptsustain * 255)); + WriteByte(MSG_ENTITY, floor(this.bgmscriptrelease * 64)); + WriteVector(MSG_ENTITY, this.movedir); + WriteByte(MSG_ENTITY, floor(this.lip * 255)); + } + WriteByte(MSG_ENTITY, this.fade_start); + WriteByte(MSG_ENTITY, this.fade_end); + WriteByte(MSG_ENTITY, this.alpha_max); + WriteByte(MSG_ENTITY, this.alpha_min); + WriteByte(MSG_ENTITY, this.inactive); + WriteShort(MSG_ENTITY, this.fade_vertical_offset); + } + + return true; +} + + +#define G_MODEL_INIT(ent,sol) \ + if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); \ + if(!ent.scale) ent.scale = ent.modelscale; \ + SetBrushEntityModel(ent); \ + ent.use = g_model_setcolormaptoactivator; \ + InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ + if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; + +#define G_CLIENTMODEL_INIT(ent,sol) \ + if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); \ + if(!ent.scale) ent.scale = ent.modelscale; \ + SetBrushEntityModel(ent); \ + ent.use = g_clientmodel_use; \ + InitializeEntity(ent, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ + if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; \ + if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1; else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0; \ + Net_LinkEntity(ent, true, 0, g_clientmodel_genericsendentity); \ + ent.default_solid = sol; + +// non-solid model entities: +spawnfunc(misc_gamemodel) { this.angles_x = -this.angles.x; G_MODEL_INIT (this, SOLID_NOT) } // model entity +spawnfunc(misc_clientmodel) { this.angles_x = -this.angles.x; G_CLIENTMODEL_INIT(this, SOLID_NOT) } // model entity +spawnfunc(misc_models) { this.angles_x = -this.angles.x; G_MODEL_INIT (this, SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use + +// non-solid brush entities: +spawnfunc(func_illusionary) { G_MODEL_INIT (this, SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED) +spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(this, SOLID_NOT) } // brush entity +spawnfunc(func_static) { G_MODEL_INIT (this, SOLID_NOT) } // DEPRECATED old alias name from some other game + +// solid brush entities +spawnfunc(func_wall) { G_MODEL_INIT (this, SOLID_BSP) } // Q1 name +spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(this, SOLID_BSP) } // brush entity (WARNING: MISPREDICTED) +#endif diff --git a/qcsrc/common/mapobjects/models.qh b/qcsrc/common/mapobjects/models.qh new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/common/mapobjects/models.qh @@ -0,0 +1 @@ +#pragma once diff --git a/qcsrc/common/mapobjects/subs.qc b/qcsrc/common/mapobjects/subs.qc index 2a237fdcb..bc6998131 100644 --- a/qcsrc/common/mapobjects/subs.qc +++ b/qcsrc/common/mapobjects/subs.qc @@ -4,6 +4,14 @@ void SUB_NullThink(entity this) { } void SUB_CalcMoveDone(entity this); void SUB_CalcAngleMoveDone(entity this); +#ifdef SVQC +spawnfunc(info_null) +{ + delete(this); + // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately. +} +#endif + /* ================== SUB_Friction @@ -180,12 +188,6 @@ void SUB_CalcMove_controller_setlinear (entity controller, vector org, vector de controller.destvec2 = '0 0 0'; } -float TSPEED_TIME = -1; -float TSPEED_LINEAR = 0; -float TSPEED_START = 1; -float TSPEED_END = 2; -// TODO average too? - void SUB_CalcMove_Bezier (entity this, vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func) { float traveltime; @@ -367,3 +369,129 @@ void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float { SUB_CalcAngleMove (ent, destangle, tspeedtype, tspeed, func); } + +#ifdef SVQC +void ApplyMinMaxScaleAngles(entity e) +{ + if(e.angles.x != 0 || e.angles.z != 0 || e.avelocity.x != 0 || e.avelocity.z != 0) // "weird" rotation + { + e.maxs = '1 1 1' * vlen( + '1 0 0' * max(-e.mins.x, e.maxs.x) + + '0 1 0' * max(-e.mins.y, e.maxs.y) + + '0 0 1' * max(-e.mins.z, e.maxs.z) + ); + e.mins = -e.maxs; + } + else if(e.angles.y != 0 || e.avelocity.y != 0) // yaw only is a bit better + { + e.maxs_x = vlen( + '1 0 0' * max(-e.mins.x, e.maxs.x) + + '0 1 0' * max(-e.mins.y, e.maxs.y) + ); + e.maxs_y = e.maxs.x; + e.mins_x = -e.maxs.x; + e.mins_y = -e.maxs.x; + } + if(e.scale) + setsize(e, e.mins * e.scale, e.maxs * e.scale); + else + setsize(e, e.mins, e.maxs); +} + +void SetBrushEntityModel(entity this) +{ + if(this.model != "") + { + precache_model(this.model); + if(this.mins != '0 0 0' || this.maxs != '0 0 0') + { + vector mi = this.mins; + vector ma = this.maxs; + _setmodel(this, this.model); // no precision needed + setsize(this, mi, ma); + } + else + _setmodel(this, this.model); // no precision needed + InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET); + } + setorigin(this, this.origin); + ApplyMinMaxScaleAngles(this); +} + +void SetBrushEntityModelNoLOD(entity this) +{ + if(this.model != "") + { + precache_model(this.model); + if(this.mins != '0 0 0' || this.maxs != '0 0 0') + { + vector mi = this.mins; + vector ma = this.maxs; + _setmodel(this, this.model); // no precision needed + setsize(this, mi, ma); + } + else + _setmodel(this, this.model); // no precision needed + } + setorigin(this, this.origin); + ApplyMinMaxScaleAngles(this); +} + +/* +================ +InitTrigger +================ +*/ + +void SetMovedir(entity this) +{ + if(this.movedir != '0 0 0') + this.movedir = normalize(this.movedir); + else + { + makevectors(this.angles); + this.movedir = v_forward; + } + + this.angles = '0 0 0'; +} + +void InitTrigger(entity this) +{ +// trigger angles are used for one-way touches. An angle of 0 is assumed +// to mean no restrictions, so use a yaw of 360 instead. + SetMovedir(this); + this.solid = SOLID_TRIGGER; + SetBrushEntityModel(this); + set_movetype(this, MOVETYPE_NONE); + this.modelindex = 0; + this.model = ""; +} + +void InitSolidBSPTrigger(entity this) +{ +// trigger angles are used for one-way touches. An angle of 0 is assumed +// to mean no restrictions, so use a yaw of 360 instead. + SetMovedir(this); + this.solid = SOLID_BSP; + SetBrushEntityModel(this); + set_movetype(this, MOVETYPE_NONE); // why was this PUSH? -div0 +// this.modelindex = 0; + this.model = ""; +} + +bool InitMovingBrushTrigger(entity this) +{ +// trigger angles are used for one-way touches. An angle of 0 is assumed +// to mean no restrictions, so use a yaw of 360 instead. + this.solid = SOLID_BSP; + SetBrushEntityModel(this); + set_movetype(this, MOVETYPE_PUSH); + if(this.modelindex == 0) + { + objerror(this, "InitMovingBrushTrigger: no brushes found!"); + return false; + } + return true; +} +#endif diff --git a/qcsrc/common/mapobjects/subs.qh b/qcsrc/common/mapobjects/subs.qh index 8d4e40650..3d265364c 100644 --- a/qcsrc/common/mapobjects/subs.qh +++ b/qcsrc/common/mapobjects/subs.qh @@ -44,6 +44,12 @@ void SUB_VanishOrRemove (entity ent); .entity move_controller; +const int TSPEED_TIME = -1; +const int TSPEED_LINEAR = 0; +const int TSPEED_START = 1; +const int TSPEED_END = 2; +// TODO average too? + #ifdef CSQC // this stuff is defined in the server side engine VM, so we must define it separately here .float takedamage; @@ -55,3 +61,71 @@ const int DAMAGE_AIM = 2; .float max_health; // players maximum health is stored here #endif + +#ifdef SVQC +spawnfunc(info_null); +#endif + +/* +============= +SUB_CalcMove + +calculate this.velocity and this.nextthink to reach dest from +this.origin traveling at speed +=============== +*/ +void SUB_CalcMoveDone(entity this); + +.float platmovetype_turn; +void SUB_CalcMove_controller_think (entity this); + +void SUB_CalcMove_controller_setbezier (entity controller, vector org, vector control, vector dest); + +void SUB_CalcMove_controller_setlinear (entity controller, vector org, vector dest); + +void SUB_CalcMove_Bezier (entity this, vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func); + +void SUB_CalcMove (entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func); + +void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func); + +#ifdef SVQC +void ApplyMinMaxScaleAngles(entity e); + +void SetBrushEntityModel(entity this); + +void SetBrushEntityModelNoLOD(entity this); +#endif + +/* +============= +SUB_CalcAngleMove + +calculate this.avelocity and this.nextthink to reach destangle from +this.angles rotating + +The calling function should make sure this.think is valid +=============== +*/ +void SUB_CalcAngleMoveDone (entity this); + +// FIXME: I fixed this function only for rotation around the main axes +void SUB_CalcAngleMove (entity this, vector destangle, float tspeedtype, float tspeed, void(entity this) func); + +void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func); + +/* +================ +InitTrigger +================ +*/ + +#ifdef SVQC +void SetMovedir(entity this); + +void InitTrigger(entity this); + +void InitSolidBSPTrigger(entity this); + +bool InitMovingBrushTrigger(entity this); +#endif diff --git a/qcsrc/common/mapobjects/target/_mod.inc b/qcsrc/common/mapobjects/target/_mod.inc index 5ac26d9cf..f9cc536ed 100644 --- a/qcsrc/common/mapobjects/target/_mod.inc +++ b/qcsrc/common/mapobjects/target/_mod.inc @@ -1,6 +1,5 @@ // generated file; do not modify #include -#include #include #include #include diff --git a/qcsrc/common/mapobjects/target/_mod.qh b/qcsrc/common/mapobjects/target/_mod.qh index 80a1a7f0c..e3f4cede9 100644 --- a/qcsrc/common/mapobjects/target/_mod.qh +++ b/qcsrc/common/mapobjects/target/_mod.qh @@ -1,6 +1,5 @@ // generated file; do not modify #include -#include #include #include #include diff --git a/qcsrc/common/mapobjects/target/include.qc b/qcsrc/common/mapobjects/target/include.qc deleted file mode 100644 index a45c65ed0..000000000 --- a/qcsrc/common/mapobjects/target/include.qc +++ /dev/null @@ -1,11 +0,0 @@ -#include "include.qh" - -#include "changelevel.qc" -#include "kill.qc" -#include "levelwarp.qc" -#include "location.qc" -#include "music.qc" -#include "spawn.qc" -#include "spawnpoint.qc" -#include "speaker.qc" -#include "voicescript.qc" diff --git a/qcsrc/common/mapobjects/target/include.qh b/qcsrc/common/mapobjects/target/include.qh deleted file mode 100644 index c0f7cad44..000000000 --- a/qcsrc/common/mapobjects/target/include.qh +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "music.qh" diff --git a/qcsrc/common/mapobjects/trigger/_mod.inc b/qcsrc/common/mapobjects/trigger/_mod.inc index 82eb9f4a9..c2a663f05 100644 --- a/qcsrc/common/mapobjects/trigger/_mod.inc +++ b/qcsrc/common/mapobjects/trigger/_mod.inc @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/common/mapobjects/trigger/_mod.qh b/qcsrc/common/mapobjects/trigger/_mod.qh index 6250a76a7..08a6e5a06 100644 --- a/qcsrc/common/mapobjects/trigger/_mod.qh +++ b/qcsrc/common/mapobjects/trigger/_mod.qh @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/common/mapobjects/trigger/include.qc b/qcsrc/common/mapobjects/trigger/include.qc deleted file mode 100644 index 1c762fc35..000000000 --- a/qcsrc/common/mapobjects/trigger/include.qc +++ /dev/null @@ -1,25 +0,0 @@ -#include "include.qh" - -#include "counter.qc" -#include "delay.qc" -#include "disablerelay.qc" -#include "flipflop.qc" -#include "gamestart.qc" -#include "gravity.qc" -#include "heal.qc" -#include "hurt.qc" -#include "impulse.qc" -#include "jumppads.qc" -#include "keylock.qc" -#include "magicear.qc" -#include "monoflop.qc" -#include "multi.qc" -#include "multivibrator.qc" -#include "relay.qc" -#include "relay_activators.qc" -#include "relay_if.qc" -#include "relay_teamcheck.qc" -#include "secret.qc" -#include "swamp.qc" -#include "teleport.qc" -#include "viewloc.qc" diff --git a/qcsrc/common/mapobjects/trigger/include.qh b/qcsrc/common/mapobjects/trigger/include.qh deleted file mode 100644 index 8aa6b2b17..000000000 --- a/qcsrc/common/mapobjects/trigger/include.qh +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "multi.qh" -#include "jumppads.qh" -#include "secret.qh" -#include "swamp.qh" -#include "keylock.qh" -#include "impulse.qh" -#include "viewloc.qh" diff --git a/qcsrc/common/mapobjects/triggers.qc b/qcsrc/common/mapobjects/triggers.qc index 9db38a10b..6968a6556 100644 --- a/qcsrc/common/mapobjects/triggers.qc +++ b/qcsrc/common/mapobjects/triggers.qc @@ -1,4 +1,8 @@ #include "triggers.qh" +#ifdef SVQC + #include +#endif + void SUB_DontUseTargets(entity this, entity actor, entity trigger) { } void SUB_UseTargets(entity this, entity actor, entity trigger); diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 04dc20770..2b9808a55 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -1,5 +1,5 @@ #include "player.qh" -#include "../mapobjects/include.qh" +#include "../mapobjects/_mod.qh" #include "../viewloc.qh" #ifdef SVQC diff --git a/qcsrc/server/_mod.inc b/qcsrc/server/_mod.inc index 569301c5d..cffc7f507 100644 --- a/qcsrc/server/_mod.inc +++ b/qcsrc/server/_mod.inc @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/server/_mod.qh b/qcsrc/server/_mod.qh index 2013fd6bb..cb66bc888 100644 --- a/qcsrc/server/_mod.qh +++ b/qcsrc/server/_mod.qh @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/server/g_models.qc b/qcsrc/server/g_models.qc deleted file mode 100644 index b7779368d..000000000 --- a/qcsrc/server/g_models.qc +++ /dev/null @@ -1,194 +0,0 @@ -#include "g_models.qh" - -#include -#include -#include "g_subs.qh" -#include -#include "../common/mapobjects/subs.qh" -#include "../common/mapobjects/triggers.qh" - -entityclass(BGMScript); -classfield(BGMScript) .string bgmscript; -classfield(BGMScript) .float bgmscriptattack; -classfield(BGMScript) .float bgmscriptdecay; -classfield(BGMScript) .float bgmscriptsustain; -classfield(BGMScript) .float bgmscriptrelease; - -#include "../common/constants.qh" -#include "../lib/csqcmodel/sv_model.qh" - -.float modelscale; - -void g_model_setcolormaptoactivator(entity this, entity actor, entity trigger) -{ - if(teamplay) - { - if(actor.team) - this.colormap = (actor.team - 1) * 0x11; - else - this.colormap = 0x00; - } - else - this.colormap = floor(random() * 256); - this.colormap |= BIT(10); // RENDER_COLORMAPPED -} - -void g_clientmodel_setcolormaptoactivator(entity this, entity actor, entity trigger) -{ - g_model_setcolormaptoactivator(this, actor, trigger); - this.SendFlags |= (BIT(3) | BIT(0)); -} - -void g_clientmodel_use(entity this, entity actor, entity trigger) -{ - if (this.antiwall_flag == 1) - { - this.inactive = 1; - this.solid = SOLID_NOT; - } - else if (this.antiwall_flag == 2) - { - this.inactive = 0; - this.solid = this.default_solid; - } - g_clientmodel_setcolormaptoactivator(this, actor, trigger); -} - -void g_model_dropbyspawnflags(entity this) -{ - if((this.spawnflags & 3) == 1) // ALIGN_ORIGIN - { - traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this); - setorigin(this, trace_endpos); - } - else if((this.spawnflags & 3) == 2) // ALIGN_BOTTOM - { - tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 4096', MOVE_NOMONSTERS, this); - setorigin(this, trace_endpos); - } - else if((this.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM - { - traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this); - setorigin(this, trace_endpos - '0 0 1' * this.mins.z); - } -} - -void g_clientmodel_dropbyspawnflags(entity this) -{ - vector o0; - o0 = this.origin; - g_model_dropbyspawnflags(this); - if(this.origin != o0) - this.SendFlags |= 2; -} - -bool g_clientmodel_genericsendentity(entity this, entity to, int sf) -{ - sf = sf & 0x0F; - if(this.angles != '0 0 0') - sf |= 0x10; - if(this.mins != '0 0 0' || this.maxs != '0 0 0') - sf |= 0x20; - if(this.colormap != 0) - sf |= 0x40; - if(this.lodmodelindex1) - sf |= 0x80; - - WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL); - WriteByte(MSG_ENTITY, sf); - - if(sf & BIT(0)) - { - if(sf & 0x40) - WriteShort(MSG_ENTITY, this.colormap); - WriteByte(MSG_ENTITY, this.skin); - } - - if(sf & BIT(1)) - { - WriteVector(MSG_ENTITY, this.origin); - } - - if(sf & BIT(2)) - { - if(sf & 0x10) - { - WriteAngle(MSG_ENTITY, this.angles.x); - WriteAngle(MSG_ENTITY, this.angles.y); - WriteAngle(MSG_ENTITY, this.angles.z); - } - } - - if(sf & BIT(3)) - { - if(sf & 0x80) - { - WriteShort(MSG_ENTITY, this.lodmodelindex0); - WriteShort(MSG_ENTITY, bound(0, this.loddistance1, 65535)); - WriteShort(MSG_ENTITY, this.lodmodelindex1); - WriteShort(MSG_ENTITY, bound(0, this.loddistance2, 65535)); - WriteShort(MSG_ENTITY, this.lodmodelindex2); - } - else - WriteShort(MSG_ENTITY, this.modelindex); - WriteByte(MSG_ENTITY, this.solid); - WriteShort(MSG_ENTITY, floor(this.scale * 256)); - if(sf & 0x20) - { - WriteVector(MSG_ENTITY, this.mins); - WriteVector(MSG_ENTITY, this.maxs); - } - WriteString(MSG_ENTITY, this.bgmscript); - if(this.bgmscript != "") - { - WriteByte(MSG_ENTITY, floor(this.bgmscriptattack * 64)); - WriteByte(MSG_ENTITY, floor(this.bgmscriptdecay * 64)); - WriteByte(MSG_ENTITY, floor(this.bgmscriptsustain * 255)); - WriteByte(MSG_ENTITY, floor(this.bgmscriptrelease * 64)); - WriteVector(MSG_ENTITY, this.movedir); - WriteByte(MSG_ENTITY, floor(this.lip * 255)); - } - WriteByte(MSG_ENTITY, this.fade_start); - WriteByte(MSG_ENTITY, this.fade_end); - WriteByte(MSG_ENTITY, this.alpha_max); - WriteByte(MSG_ENTITY, this.alpha_min); - WriteByte(MSG_ENTITY, this.inactive); - WriteShort(MSG_ENTITY, this.fade_vertical_offset); - } - - return true; -} - - -#define G_MODEL_INIT(ent,sol) \ - if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); \ - if(!ent.scale) ent.scale = ent.modelscale; \ - SetBrushEntityModel(ent); \ - ent.use = g_model_setcolormaptoactivator; \ - InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ - if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; - -#define G_CLIENTMODEL_INIT(ent,sol) \ - if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); \ - if(!ent.scale) ent.scale = ent.modelscale; \ - SetBrushEntityModel(ent); \ - ent.use = g_clientmodel_use; \ - InitializeEntity(ent, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ - if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; \ - if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1; else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0; \ - Net_LinkEntity(ent, true, 0, g_clientmodel_genericsendentity); \ - ent.default_solid = sol; - -// non-solid model entities: -spawnfunc(misc_gamemodel) { this.angles_x = -this.angles.x; G_MODEL_INIT (this, SOLID_NOT) } // model entity -spawnfunc(misc_clientmodel) { this.angles_x = -this.angles.x; G_CLIENTMODEL_INIT(this, SOLID_NOT) } // model entity -spawnfunc(misc_models) { this.angles_x = -this.angles.x; G_MODEL_INIT (this, SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use - -// non-solid brush entities: -spawnfunc(func_illusionary) { G_MODEL_INIT (this, SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED) -spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(this, SOLID_NOT) } // brush entity -spawnfunc(func_static) { G_MODEL_INIT (this, SOLID_NOT) } // DEPRECATED old alias name from some other game - -// solid brush entities -spawnfunc(func_wall) { G_MODEL_INIT (this, SOLID_BSP) } // Q1 name -spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(this, SOLID_BSP) } // brush entity (WARNING: MISPREDICTED) diff --git a/qcsrc/server/g_models.qh b/qcsrc/server/g_models.qh deleted file mode 100644 index 6f70f09be..000000000 --- a/qcsrc/server/g_models.qh +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index 21c43ea10..dbbd6d2b4 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -8,11 +8,6 @@ #include "../lib/warpzone/common.qh" #include "../common/mapobjects/subs.qh" -spawnfunc(info_null) -{ - delete(this); - // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately. -} /* ================== @@ -313,127 +308,3 @@ void LODmodel_attach(entity this) if (!getSendEntity(this)) SetCustomizer(this, LOD_customize, LOD_uncustomize); } - -void ApplyMinMaxScaleAngles(entity e) -{ - if(e.angles.x != 0 || e.angles.z != 0 || e.avelocity.x != 0 || e.avelocity.z != 0) // "weird" rotation - { - e.maxs = '1 1 1' * vlen( - '1 0 0' * max(-e.mins.x, e.maxs.x) + - '0 1 0' * max(-e.mins.y, e.maxs.y) + - '0 0 1' * max(-e.mins.z, e.maxs.z) - ); - e.mins = -e.maxs; - } - else if(e.angles.y != 0 || e.avelocity.y != 0) // yaw only is a bit better - { - e.maxs_x = vlen( - '1 0 0' * max(-e.mins.x, e.maxs.x) + - '0 1 0' * max(-e.mins.y, e.maxs.y) - ); - e.maxs_y = e.maxs.x; - e.mins_x = -e.maxs.x; - e.mins_y = -e.maxs.x; - } - if(e.scale) - setsize(e, e.mins * e.scale, e.maxs * e.scale); - else - setsize(e, e.mins, e.maxs); -} - -void SetBrushEntityModel(entity this) -{ - if(this.model != "") - { - precache_model(this.model); - if(this.mins != '0 0 0' || this.maxs != '0 0 0') - { - vector mi = this.mins; - vector ma = this.maxs; - _setmodel(this, this.model); // no precision needed - setsize(this, mi, ma); - } - else - _setmodel(this, this.model); // no precision needed - InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET); - } - setorigin(this, this.origin); - ApplyMinMaxScaleAngles(this); -} - -void SetBrushEntityModelNoLOD(entity this) -{ - if(this.model != "") - { - precache_model(this.model); - if(this.mins != '0 0 0' || this.maxs != '0 0 0') - { - vector mi = this.mins; - vector ma = this.maxs; - _setmodel(this, this.model); // no precision needed - setsize(this, mi, ma); - } - else - _setmodel(this, this.model); // no precision needed - } - setorigin(this, this.origin); - ApplyMinMaxScaleAngles(this); -} - -/* -================ -InitTrigger -================ -*/ - -void SetMovedir(entity this) -{ - if(this.movedir != '0 0 0') - this.movedir = normalize(this.movedir); - else - { - makevectors(this.angles); - this.movedir = v_forward; - } - - this.angles = '0 0 0'; -} - -void InitTrigger(entity this) -{ -// trigger angles are used for one-way touches. An angle of 0 is assumed -// to mean no restrictions, so use a yaw of 360 instead. - SetMovedir(this); - this.solid = SOLID_TRIGGER; - SetBrushEntityModel(this); - set_movetype(this, MOVETYPE_NONE); - this.modelindex = 0; - this.model = ""; -} - -void InitSolidBSPTrigger(entity this) -{ -// trigger angles are used for one-way touches. An angle of 0 is assumed -// to mean no restrictions, so use a yaw of 360 instead. - SetMovedir(this); - this.solid = SOLID_BSP; - SetBrushEntityModel(this); - set_movetype(this, MOVETYPE_NONE); // why was this PUSH? -div0 -// this.modelindex = 0; - this.model = ""; -} - -bool InitMovingBrushTrigger(entity this) -{ -// trigger angles are used for one-way touches. An angle of 0 is assumed -// to mean no restrictions, so use a yaw of 360 instead. - this.solid = SOLID_BSP; - SetBrushEntityModel(this); - set_movetype(this, MOVETYPE_PUSH); - if(this.modelindex == 0) - { - objerror(this, "InitMovingBrushTrigger: no brushes found!"); - return false; - } - return true; -} diff --git a/qcsrc/server/g_subs.qh b/qcsrc/server/g_subs.qh index 1f5537cea..2528786e7 100644 --- a/qcsrc/server/g_subs.qh +++ b/qcsrc/server/g_subs.qh @@ -2,11 +2,6 @@ void SUB_NullThink(entity this); -void SUB_CalcMoveDone(entity this); -void SUB_CalcAngleMoveDone(entity this); - -spawnfunc(info_null); - /* ================== SUB_Friction @@ -37,46 +32,6 @@ Fade 'ent' out when time >= 'when' */ void SUB_SetFade (entity ent, float when, float fadetime); -/* -============= -SUB_CalcMove - -calculate this.velocity and this.nextthink to reach dest from -this.origin traveling at speed -=============== -*/ -void SUB_CalcMoveDone(entity this); - -.float platmovetype_turn; -void SUB_CalcMove_controller_think (entity this); - -void SUB_CalcMove_controller_setbezier (entity controller, vector org, vector control, vector dest); - -void SUB_CalcMove_controller_setlinear (entity controller, vector org, vector dest); - -void SUB_CalcMove_Bezier (entity this, vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func); - -void SUB_CalcMove (entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func); - -void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func); - -/* -============= -SUB_CalcAngleMove - -calculate this.avelocity and this.nextthink to reach destangle from -this.angles rotating - -The calling function should make sure this.think is valid -=============== -*/ -void SUB_CalcAngleMoveDone (entity this); - -// FIXME: I fixed this function only for rotation around the main axes -void SUB_CalcAngleMove (entity this, vector destangle, float tspeedtype, float tspeed, void(entity this) func); - -void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func); - /* ================== main @@ -119,14 +74,6 @@ Ripped from DPMod */ vector findbetterlocation (vector org, float mindist); -/* -================== -Angc used for animations -================== -*/ - - -float angc (float a1, float a2); .string lodtarget1; .string lodtarget2; @@ -143,23 +90,3 @@ bool LOD_customize(entity this, entity client); void LOD_uncustomize(entity this); void LODmodel_attach(entity this); - -void ApplyMinMaxScaleAngles(entity e); - -void SetBrushEntityModel(entity this); - -void SetBrushEntityModelNoLOD(entity this); - -/* -================ -InitTrigger -================ -*/ - -void SetMovedir(entity this); - -void InitTrigger(entity this); - -void InitSolidBSPTrigger(entity this); - -bool InitMovingBrushTrigger(entity this); diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index fa2cd48da..fd7bad4f8 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -25,7 +25,7 @@ #include "../common/physics/player.qh" #include "../common/effects/qc/_mod.qh" #include "../common/mutators/mutator/waypoints/waypointsprites.qh" -#include "../common/mapobjects/include.qh" +#include "../common/mapobjects/_mod.qh" #include "../common/wepent.qh" #include "weapons/weaponstats.qh"