diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000000..cfa8c3674e
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,10 @@
+---
+BasedOnStyle: LLVM
+UseTab: Always
+TabWidth: 4
+IndentWidth: 4
+ColumnLimit: 160
+SortIncludes: Never
+---
+Language: Cpp
+Standard: c++11
diff --git a/code/Ratl/ratl.cpp b/code/Ratl/ratl.cpp
index b6830ddc02..acacd15cb4 100644
--- a/code/Ratl/ratl.cpp
+++ b/code/Ratl/ratl.cpp
@@ -23,7 +23,7 @@ along with this program; if not, see .
#include "../qcommon/q_shared.h"
#if !defined(RATL_COMMON_INC)
- #include "ratl_common.h"
+#include "ratl_common.h"
#endif
#if 0
@@ -43,85 +43,69 @@ along with this program; if not, see .
#endif
#if !defined(CTYPE_H_INC)
- #include
- #define CTYPE_H_INC
+#include
+#define CTYPE_H_INC
#endif
#if !defined(STDARG_H_INC)
- #include
- #define STDARG_H_INC
+#include
+#define STDARG_H_INC
#endif
#if !defined(STDIO_H_INC)
- #include
- #define STDIO_H_INC
+#include
+#define STDIO_H_INC
#endif
-
#if !defined(RUFL_HFILE_INC)
- #include "../Rufl/hfile.h"
+#include "../Rufl/hfile.h"
#endif
+void (*ratl::ratl_base::OutputPrint)(const char *) = 0;
-void (*ratl::ratl_base::OutputPrint)(const char*) = 0;
-
-
-
-namespace ratl
-{
+namespace ratl {
#ifdef _DEBUG
- int HandleSaltValue=1027; //this is used in debug for global uniqueness of handles
- int FoolTheOptimizer=5; //this is used to make sure certain things aren't optimized out
+int HandleSaltValue = 1027; // this is used in debug for global uniqueness of handles
+int FoolTheOptimizer = 5; // this is used to make sure certain things aren't optimized out
#endif
+void ratl_base::save(hfile &file) {}
-void ratl_base::save(hfile& file)
-{
-}
-
-void ratl_base::load(hfile& file)
-{
-}
+void ratl_base::load(hfile &file) {}
////////////////////////////////////////////////////////////////////////////////////////
// A Profile Print Function
////////////////////////////////////////////////////////////////////////////////////////
#if !defined(FINAL_BUILD)
-void ratl_base::ProfilePrint(const char * format, ...)
-{
- static char string[2][1024]; // in case this is called by nested functions
- static int index = 0;
- static char nFormat[300];
- char* buf;
+void ratl_base::ProfilePrint(const char *format, ...) {
+ static char string[2][1024]; // in case this is called by nested functions
+ static int index = 0;
+ static char nFormat[300];
+ char *buf;
// Tack On The Standard Format Around The Given Format
//-----------------------------------------------------
sprintf(nFormat, "[PROFILE] %s\n", format);
-
// Resolve Remaining Elipsis Parameters Into Newly Formated String
//-----------------------------------------------------------------
buf = string[index & 1];
index++;
- va_list argptr;
- va_start (argptr, format);
- vsprintf (buf, nFormat, argptr);
- va_end (argptr);
+ va_list argptr;
+ va_start(argptr, format);
+ vsprintf(buf, nFormat, argptr);
+ va_end(argptr);
// Print It To Debug Output Console
//----------------------------------
- if (OutputPrint!=0)
- {
- void (*OutputPrintFcn)(const char* text) = (void (*)(const char*))OutputPrint;
+ if (OutputPrint != 0) {
+ void (*OutputPrintFcn)(const char *text) = (void (*)(const char *))OutputPrint;
OutputPrintFcn(buf);
}
}
#else
-void ratl_base::ProfilePrint(const char * format, ...)
-{
-}
+void ratl_base::ProfilePrint(const char *format, ...) {}
#endif
-}
-
+} // namespace ratl
diff --git a/code/Ravl/CBounds.cpp b/code/Ravl/CBounds.cpp
index a341527568..23d20decaf 100644
--- a/code/Ravl/CBounds.cpp
+++ b/code/Ravl/CBounds.cpp
@@ -47,9 +47,6 @@ along with this program; if not, see .
#include
#include "CBounds.h"
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
@@ -79,55 +76,43 @@ along with this program; if not, see .
}
}*/
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-float CBBox::LargestAxisSize() const
-{
- CVec3 Work(mMax);
- Work-=mMin;
+float CBBox::LargestAxisSize() const {
+ CVec3 Work(mMax);
+ Work -= mMin;
return Work.MaxElement();
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-float CBBox::DistanceEstimate(const CVec3 &p) const
-{
- float ret=0.0f;
+float CBBox::DistanceEstimate(const CVec3 &p) const {
+ float ret = 0.0f;
// X Axis
//--------
- if (p[0]>mMax[0])
- {
- ret=p[0]-mMax[0];
- }
- else if (p[0] mMax[0]) {
+ ret = p[0] - mMax[0];
+ } else if (p[0] < mMin[0]) {
+ ret = mMax[0] - p[0];
}
// Y Axis
//--------
- if (p[1]>mMax[1])
- {
- ret+=p[1]-mMax[1];
- }
- else if (p[1] mMax[1]) {
+ ret += p[1] - mMax[1];
+ } else if (p[1] < mMin[1]) {
+ ret += mMax[1] - p[1];
}
// Z Axis
//--------
- if (p[2]>mMax[2])
- {
- ret+=p[2]-mMax[2];
- }
- else if (p[2] mMax[2]) {
+ ret += p[2] - mMax[2];
+ } else if (p[2] < mMin[2]) {
+ ret += mMax[2] - p[2];
}
return ret;
}
@@ -135,22 +120,18 @@ float CBBox::DistanceEstimate(const CVec3 &p) const
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-float CBBox::AreaEstimate(const CVec3 &p) const
-{
- float Distance=DistanceEstimate(p);
- if (Distance)
- {
- return LargestAxisSize()/Distance;
+float CBBox::AreaEstimate(const CVec3 &p) const {
+ float Distance = DistanceEstimate(p);
+ if (Distance) {
+ return LargestAxisSize() / Distance;
}
return 0;
}
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void CBBox::Intersect(const CBBox &b2)
-{
+void CBBox::Intersect(const CBBox &b2) {
mMin.Max(b2.mMin);
mMax.Min(b2.mMax);
Validate();
@@ -159,21 +140,17 @@ void CBBox::Intersect(const CBBox &b2)
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void CBBox::Union(const CBBox &b2)
-{
+void CBBox::Union(const CBBox &b2) {
mMin.Min(b2.mMin);
mMax.Max(b2.mMax);
Validate();
}
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-ESide CBBox::InOutTest(const CVec3 &v) const
-{
- if (v>mMin && v mMin && v < mMax) {
return Side_In;
}
return Side_Out;
@@ -182,18 +159,13 @@ ESide CBBox::InOutTest(const CVec3 &v) const
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-ESide CBBox::InOutTest(const CVec3 &v,float tolout,float tolin) const
-{
- if (v[0]mMax[0]+tolout||
- v[1]mMax[1]+tolout||
- v[2]mMax[2]+tolout)
- {
+ESide CBBox::InOutTest(const CVec3 &v, float tolout, float tolin) const {
+ if (v[0] < mMin[0] - tolout || v[0] > mMax[0] + tolout || v[1] < mMin[1] - tolout || v[1] > mMax[1] + tolout || v[2] < mMin[2] - tolout ||
+ v[2] > mMax[2] + tolout) {
return Side_Out;
}
- if (v[0]>mMin[0]+tolin&&v[0]mMin[1]+tolin&&v[1]mMin[2]+tolin&&v[2] mMin[0] + tolin && v[0] < mMax[0] - tolin && v[1] > mMin[1] + tolin && v[1] < mMax[1] - tolin && v[2] > mMin[2] + tolin &&
+ v[2] < mMax[2] - tolin) {
return Side_In;
}
return Side_None;
@@ -202,28 +174,19 @@ ESide CBBox::InOutTest(const CVec3 &v,float tolout,float tolin) const
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CBBox::BoxTouchTest(const CBBox &b2,float tolout) const
-{
- if (mMin[0]-tolout>b2.mMax[0] ||
- mMin[1]-tolout>b2.mMax[1] ||
- mMin[2]-tolout>b2.mMax[2] ||
- b2.mMin[0]-tolout>mMax[0] ||
- b2.mMin[1]-tolout>mMax[1] ||
- b2.mMin[2]-tolout>mMax[2])
- {
+bool CBBox::BoxTouchTest(const CBBox &b2, float tolout) const {
+ if (mMin[0] - tolout > b2.mMax[0] || mMin[1] - tolout > b2.mMax[1] || mMin[2] - tolout > b2.mMax[2] || b2.mMin[0] - tolout > mMax[0] ||
+ b2.mMin[1] - tolout > mMax[1] || b2.mMin[2] - tolout > mMax[2]) {
return false;
}
- return true;
+ return true;
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CBBox::SphereTouchTest(const CVec3 &v,float rad) const
-{
- if (v[0]mMax[0]+rad||
- v[1]mMax[1]+rad||
- v[2]mMax[2]+rad)
+bool CBBox::SphereTouchTest(const CVec3 &v, float rad) const {
+ if (v[0] < mMin[0] - rad || v[0] > mMax[0] + rad || v[1] < mMin[1] - rad || v[1] > mMax[1] + rad || v[2] < mMin[2] - rad || v[2] > mMax[2] + rad)
return false;
return true;
}
@@ -231,32 +194,22 @@ bool CBBox::SphereTouchTest(const CVec3 &v,float rad) const
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-TPlanes CBBox::PlaneFlags(const CVec3 &p)
-{
- TPlanes ret=0;
- if (p[0]mMax[0])
- {
- ret|=2;
- }
- if (p[1] mMax[0]) {
+ ret |= 2;
}
- else if (p[1]>mMax[1])
- {
- ret|=8;
+ if (p[1] < mMin[1]) {
+ ret |= 4;
+ } else if (p[1] > mMax[1]) {
+ ret |= 8;
}
- if (p[2]mMax[2])
- {
- ret|=32;
+ if (p[2] < mMin[2]) {
+ ret |= 16;
+ } else if (p[2] > mMax[2]) {
+ ret |= 32;
}
return ret;
}
@@ -265,38 +218,31 @@ TPlanes CBBox::PlaneFlags(const CVec3 &p)
//
// return true if the segment intersect the box, in that case, return the first contact.
////////////////////////////////////////////////////////////////////////////////////////
-bool CBBox::HitTest(CBTrace& Tr) const
-{
+bool CBBox::HitTest(CBTrace &Tr) const {
// Quick Box Cull
//----------------
CBBox tmp;
tmp.AddPoint(Tr.mStart);
tmp.AddPoint(Tr.mStop);
- if (!BoxTouchTest(tmp))
- {
+ if (!BoxTouchTest(tmp)) {
return false;
}
-
// Initialize Our Ranges
//-----------------------
- Tr.mRange =-1E30f;
- Tr.mRangeMax = 1E30f;
-
+ Tr.mRange = -1E30f;
+ Tr.mRangeMax = 1E30f;
// For Each Non Zero Axis Of The Aim Vector
//------------------------------------------
- float tmax,tmin,temp;
- for (int axis=0; axis<3; axis++)
- {
- if (fabs(Tr.mAim[axis])>1E-6f)
- {
+ float tmax, tmin, temp;
+ for (int axis = 0; axis < 3; axis++) {
+ if (fabs(Tr.mAim[axis]) > 1E-6f) {
// Find Mins And Maxs From The Start Along The Axis Of Aim
//---------------------------------------------------------
- tmax = ((mMax[axis]-Tr.mStart[axis])/Tr.mAim[axis]);
- tmin = ((mMin[axis]-Tr.mStart[axis])/Tr.mAim[axis]);
- if (tmaxTr.mRange)
- {
- Tr.mRange=tmin;
+ if (tmin > Tr.mRange) {
+ Tr.mRange = tmin;
Tr.mNormal.Clear();
- Tr.mNormal[axis]=-1.0f;
+ Tr.mNormal[axis] = -1.0f;
}
}
}
-
// Missed?
//---------
- if (Tr.mRangeMaxTr.mLength)
- {
+ if (Tr.mRangeMax < Tr.mRange || Tr.mRangeMax < 0.0f || Tr.mRange > Tr.mLength) {
return false;
}
-
// Start Solid Conditions
//------------------------
- if (Tr.mRange<0.0f)
- {
+ if (Tr.mRange < 0.0f) {
Tr.mRange = 0.0f;
Tr.mPoint = Tr.mStart;
return true;
}
-
// Calculate The End Point
//-------------------------
- Tr.mPoint = Tr.mAim;
+ Tr.mPoint = Tr.mAim;
Tr.mPoint *= Tr.mRange;
Tr.mPoint += Tr.mStart;
return true;
}
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void CBBox::FromStr(const char *s)
-{
+void CBBox::FromStr(const char *s) {
assert(s && s[0]);
- char MinS[256];
- char MaxS[266];
+ char MinS[256];
+ char MaxS[266];
sscanf(s, "(%s|%s)", MinS, MaxS);
mMin.FromStr(MinS);
@@ -366,12 +303,11 @@ void CBBox::FromStr(const char *s)
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void CBBox::ToStr(char* s)
-{
+void CBBox::ToStr(char *s) {
assert(s && s[0]);
- char MinS[256];
- char MaxS[266];
+ char MinS[256];
+ char MaxS[266];
mMin.ToStr(MinS);
mMax.ToStr(MaxS);
@@ -381,8 +317,4 @@ void CBBox::ToStr(char* s)
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void CBBox::Validate()
-{
- assert(mMax>=mMin);
-}
-
+void CBBox::Validate() { assert(mMax >= mMin); }
diff --git a/code/Ravl/CVec.cpp b/code/Ravl/CVec.cpp
index 48d00d529f..99ea972853 100644
--- a/code/Ravl/CVec.cpp
+++ b/code/Ravl/CVec.cpp
@@ -36,50 +36,35 @@ along with this program; if not, see .
#include
#include "CVec.h"
-//using namespace ravl;
-
-
+// using namespace ravl;
////////////////////////////////////////////////////////////////////////////////////////
// Static Class Member Initialization
////////////////////////////////////////////////////////////////////////////////////////
-const CVec4 CVec4::mX(1.f, 0.f, 0.f, 0.f);
-const CVec4 CVec4::mY(0.f, 1.f, 0.f, 0.f);
-const CVec4 CVec4::mZ(0.f, 0.f, 1.f, 0.f);
-const CVec4 CVec4::mW(0.f, 0.f, 0.f, 1.f);
-const CVec4 CVec4::mZero(0.f, 0.f, 0.f, 0.f);
-
-
-
+const CVec4 CVec4::mX(1.f, 0.f, 0.f, 0.f);
+const CVec4 CVec4::mY(0.f, 1.f, 0.f, 0.f);
+const CVec4 CVec4::mZ(0.f, 0.f, 1.f, 0.f);
+const CVec4 CVec4::mW(0.f, 0.f, 0.f, 1.f);
+const CVec4 CVec4::mZero(0.f, 0.f, 0.f, 0.f);
////////////////////////////////////////////////////////////////////////////////////////
// Length
////////////////////////////////////////////////////////////////////////////////////////
-float CVec4::Len() const
-{
- return sqrtf(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]+v[3]*v[3]);
-}
-
+float CVec4::Len() const { return sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2] + v[3] * v[3]); }
////////////////////////////////////////////////////////////////////////////////////////
// Distance To Other Point
////////////////////////////////////////////////////////////////////////////////////////
-float CVec4::Dist(const CVec4& t) const
-{
- return sqrtf(
- (t.v[0]-v[0])*(t.v[0]-v[0]) +
- (t.v[1]-v[1])*(t.v[1]-v[1]) +
- (t.v[2]-v[2])*(t.v[2]-v[2]) +
- (t.v[3]-v[3])*(t.v[3]-v[3]));
+float CVec4::Dist(const CVec4 &t) const {
+ return sqrtf((t.v[0] - v[0]) * (t.v[0] - v[0]) + (t.v[1] - v[1]) * (t.v[1] - v[1]) + (t.v[2] - v[2]) * (t.v[2] - v[2]) + (t.v[3] - v[3]) * (t.v[3] - v[3]));
}
////////////////////////////////////////////////////////////////////////////////////////
// Normalize
////////////////////////////////////////////////////////////////////////////////////////
-float CVec4::Norm()
-{
- float L = Len();
- (*this)/=L;
+float CVec4::Norm() {
+ float L = Len();
+ (*this) /= L;
return L;
}
@@ -87,15 +72,13 @@ float CVec4::Norm()
// Safe Normalize
// Do Not Normalize If Length Is Too Small
////////////////////////////////////////////////////////////////////////////////////////
-float CVec4::SafeNorm()
-{
- float d=this->Len();
- if (d>1E-10)
- {
- (*this)/=d;
+float CVec4::SafeNorm() {
+ float d = this->Len();
+ if (d > 1E-10) {
+ (*this) /= d;
return d;
}
- (*this)=0.0f;
+ (*this) = 0.0f;
return 0;
}
@@ -103,19 +86,24 @@ float CVec4::SafeNorm()
// Angular Normalize
// All floats Exist(-180, +180)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::AngleNorm()
-{
- v[0]= fmodf(v[0],360.0f);
- if (v[0]<-180.f) v[0]+=360.0f;
- if (v[0]>180.f) v[0]-=360.0f;
+void CVec4::AngleNorm() {
+ v[0] = fmodf(v[0], 360.0f);
+ if (v[0] < -180.f)
+ v[0] += 360.0f;
+ if (v[0] > 180.f)
+ v[0] -= 360.0f;
- v[1]= fmodf(v[1],360.0f);
- if (v[1]<-180.f) v[1]+=360.0f;
- if (v[1]>180.f) v[1]-=360.0f;
+ v[1] = fmodf(v[1], 360.0f);
+ if (v[1] < -180.f)
+ v[1] += 360.0f;
+ if (v[1] > 180.f)
+ v[1] -= 360.0f;
- v[2]= fmodf(v[2],360.0f);
- if (v[2]<-180.f) v[2]+=360.0f;
- if (v[2]>180.f) v[2]-=360.0f;
+ v[2] = fmodf(v[2], 360.0f);
+ if (v[2] < -180.f)
+ v[2] += 360.0f;
+ if (v[2] > 180.f)
+ v[2] -= 360.0f;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -124,28 +112,25 @@ void CVec4::AngleNorm()
// This implimentation is a bit slow, needs some optimization work...
//
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::Perp()
-{
- float rlen,tlen;
- CVec4 r,t;
+void CVec4::Perp() {
+ float rlen, tlen;
+ CVec4 r, t;
r = (*this);
r.Cross(mX);
- rlen=r.Len();
+ rlen = r.Len();
t = (*this);
t.Cross(mY);
- tlen=t.Len();
- if (tlen>rlen)
- {
- r=t;
- rlen=tlen;
+ tlen = t.Len();
+ if (tlen > rlen) {
+ r = t;
+ rlen = tlen;
}
t = (*this);
t.Cross(mZ);
- tlen=t.Len();
- if (tlen>rlen)
- {
- r=t;
- rlen=tlen;
+ tlen = t.Len();
+ if (tlen > rlen) {
+ r = t;
+ rlen = tlen;
}
(*this) = r;
}
@@ -153,14 +138,11 @@ void CVec4::Perp()
////////////////////////////////////////////////////////////////////////////////////////
// Find Largest Element (Ignores 4th component for now)
////////////////////////////////////////////////////////////////////////////////////////
-int CVec4::MaxElementIndex() const
-{
- if (fabs(v[0])>fabs(v[1]) && fabs(v[0])>fabs(v[2]))
- {
+int CVec4::MaxElementIndex() const {
+ if (fabs(v[0]) > fabs(v[1]) && fabs(v[0]) > fabs(v[2])) {
return 0;
}
- if (fabs(v[1])>fabs(v[2]))
- {
+ if (fabs(v[1]) > fabs(v[2])) {
return 1;
}
return 2;
@@ -169,65 +151,55 @@ int CVec4::MaxElementIndex() const
////////////////////////////////////////////////////////////////////////////////////////
// Convert To {Pitch, Yaw} (DEGREES)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::VecToAng()
-{
- float yaw;
- float pitch;
+void CVec4::VecToAng() {
+ float yaw;
+ float pitch;
- if (!v[1] && !v[0])
- {
- yaw = 0;
- pitch = (v[2]>0) ? (90.0f):(270.0f);
- }
- else
- {
+ if (!v[1] && !v[0]) {
+ yaw = 0;
+ pitch = (v[2] > 0) ? (90.0f) : (270.0f);
+ } else {
// Calculate Yaw
//---------------
- if (v[0])
- {
+ if (v[0]) {
yaw = (RAVL_VEC_RADTODEG(atan2f(v[1], v[0])));
- if (yaw<0)
- {
+ if (yaw < 0) {
yaw += 360;
}
- }
- else
- {
- yaw = (v[1]>0) ? (90.0f):(270.0f);
+ } else {
+ yaw = (v[1] > 0) ? (90.0f) : (270.0f);
}
// Calculate Pitch
//-----------------
- float forward = (sqrtf(v[0]*v[0] + v[1]*v[1]));
- pitch = (RAVL_VEC_RADTODEG(atan2f(v[2], forward)));
- if (pitch<0)
- {
+ float forward = (sqrtf(v[0] * v[0] + v[1] * v[1]));
+ pitch = (RAVL_VEC_RADTODEG(atan2f(v[2], forward)));
+ if (pitch < 0) {
pitch += 360;
}
}
// Copy Over Current Vector
//--------------------------
- v[0] = -pitch;
- v[1] = yaw;
- v[2] = 0;
- v[3] = 0;
+ v[0] = -pitch;
+ v[1] = yaw;
+ v[2] = 0;
+ v[3] = 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw} (DEGREES)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::AngToVec()
-{
- float angle;
- float sp, sy, cp, cy;
+void CVec4::AngToVec() {
+ float angle;
+ float sp, sy, cp, cy;
- angle = yaw() * (RAVL_VEC_DEGTORADCONST);
- sy = sinf(angle);
- cy = cosf(angle);
- angle = pitch() * (RAVL_VEC_DEGTORADCONST);
- sp = sinf(angle);
- cp = cosf(angle);
+ angle = yaw() * (RAVL_VEC_DEGTORADCONST);
+ sy = sinf(angle);
+ cy = cosf(angle);
+ angle = pitch() * (RAVL_VEC_DEGTORADCONST);
+ sp = sinf(angle);
+ cp = cosf(angle);
v[0] = cp * cy;
v[1] = cp * sy;
@@ -238,20 +210,19 @@ void CVec4::AngToVec()
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw, Roll} (DEGREES)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::AngToVec(CVec4& Right, CVec4& Up)
-{
- float angle;
- float sr, sp, sy, cr, cp, cy;
-
- angle = yaw() * (RAVL_VEC_DEGTORADCONST);
- sy = sinf(angle);
- cy = cosf(angle);
- angle = pitch() * (RAVL_VEC_DEGTORADCONST);
- sp = sinf(angle);
- cp = cosf(angle);
- angle = roll() * (RAVL_VEC_DEGTORADCONST);
- sr = sinf(angle);
- cr = cosf(angle);
+void CVec4::AngToVec(CVec4 &Right, CVec4 &Up) {
+ float angle;
+ float sr, sp, sy, cr, cp, cy;
+
+ angle = yaw() * (RAVL_VEC_DEGTORADCONST);
+ sy = sinf(angle);
+ cy = cosf(angle);
+ angle = pitch() * (RAVL_VEC_DEGTORADCONST);
+ sp = sinf(angle);
+ cp = cosf(angle);
+ angle = roll() * (RAVL_VEC_DEGTORADCONST);
+ sr = sinf(angle);
+ cr = cosf(angle);
// Forward Vector Is Stored Here
v[0] = cp * cy;
@@ -272,60 +243,49 @@ void CVec4::AngToVec(CVec4& Right, CVec4& Up)
Up.v[3] = 0;
}
-
-
-
///////////////////////////////////////////////////////////////////////////////////////
// Convert To {Pitch, Yaw} (RADIANS)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::VecToAngRad()
-{
- float yaw;
- float pitch;
+void CVec4::VecToAngRad() {
+ float yaw;
+ float pitch;
- if (!v[1] && !v[0])
- {
- yaw = 0;
- pitch = (v[2]>0) ? (RAVL_VEC_PI*0.5f):(RAVL_VEC_PI*1.5f);
- }
- else
- {
+ if (!v[1] && !v[0]) {
+ yaw = 0;
+ pitch = (v[2] > 0) ? (RAVL_VEC_PI * 0.5f) : (RAVL_VEC_PI * 1.5f);
+ } else {
// Calculate Yaw
//---------------
- if (v[0])
- {
+ if (v[0]) {
yaw = (atan2f(v[1], v[0]));
- }
- else
- {
- yaw = (v[1]>0) ? (RAVL_VEC_PI*0.5f):(RAVL_VEC_PI*1.5f);
+ } else {
+ yaw = (v[1] > 0) ? (RAVL_VEC_PI * 0.5f) : (RAVL_VEC_PI * 1.5f);
}
// Calculate Pitch
//-----------------
- float forward = (sqrtf(v[0]*v[0] + v[1]*v[1]));
- pitch = (atan2f(v[2], forward));
+ float forward = (sqrtf(v[0] * v[0] + v[1] * v[1]));
+ pitch = (atan2f(v[2], forward));
}
// Copy Over Current Vector
//--------------------------
- v[0] = -pitch;
- v[1] = yaw;
- v[2] = 0;
- v[3] = 0;
+ v[0] = -pitch;
+ v[1] = yaw;
+ v[2] = 0;
+ v[3] = 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw} (RADIANS)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::AngToVecRad()
-{
- float sp, sy, cp, cy;
+void CVec4::AngToVecRad() {
+ float sp, sy, cp, cy;
- sy = sinf(yaw());
- cy = cosf(yaw());
- sp = sinf(pitch());
- cp = cosf(pitch());
+ sy = sinf(yaw());
+ cy = cosf(yaw());
+ sp = sinf(pitch());
+ cp = cosf(pitch());
v[0] = cp * cy;
v[1] = cp * sy;
@@ -336,16 +296,15 @@ void CVec4::AngToVecRad()
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw, Roll} (RADIANS)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::AngToVecRad(CVec4& Right, CVec4& Up)
-{
- float sr, sp, sy, cr, cp, cy;
+void CVec4::AngToVecRad(CVec4 &Right, CVec4 &Up) {
+ float sr, sp, sy, cr, cp, cy;
- sy = sinf(yaw());
- cy = cosf(yaw());
- sp = sinf(pitch());
- cp = cosf(pitch());
- sr = sinf(roll());
- cr = cosf(roll());
+ sy = sinf(yaw());
+ cy = cosf(yaw());
+ sp = sinf(pitch());
+ cp = cosf(pitch());
+ sr = sinf(roll());
+ cr = cosf(roll());
// Forward Vector Is Stored Here
v[0] = cp * cy;
@@ -366,12 +325,10 @@ void CVec4::AngToVecRad(CVec4& Right, CVec4& Up)
Up.v[3] = 0;
}
-
////////////////////////////////////////////////////////////////////////////////////////
// Convert To Radians
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::ToRadians()
-{
+void CVec4::ToRadians() {
v[0] = RAVL_VEC_DEGTORAD(v[0]);
v[1] = RAVL_VEC_DEGTORAD(v[1]);
v[2] = RAVL_VEC_DEGTORAD(v[2]);
@@ -380,46 +337,36 @@ void CVec4::ToRadians()
////////////////////////////////////////////////////////////////////////////////////////
// Convert To Degrees
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::ToDegrees()
-{
+void CVec4::ToDegrees() {
v[0] = RAVL_VEC_RADTODEG(v[0]);
v[1] = RAVL_VEC_RADTODEG(v[1]);
v[2] = RAVL_VEC_RADTODEG(v[2]);
}
-
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Copy Values From String
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::FromStr(const char *s)
-{
-// assert(s && s[0]);
+void CVec4::FromStr(const char *s) {
+ // assert(s && s[0]);
sscanf(s, "(%f %f %f %f)", &v[0], &v[1], &v[2], &v[3]);
}
////////////////////////////////////////////////////////////////////////////////////////
// Write Values To A String
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::ToStr(char* s) const
-{
-// assert(s);
+void CVec4::ToStr(char *s) const {
+ // assert(s);
sprintf(s, "(%3.3f %3.3f %3.3f %3.3f)", v[0], v[1], v[2], v[3]);
}
-
-
#ifdef _DEBUG
////////////////////////////////////////////////////////////////////////////////////////
// Make Sure Entire Vector Has Valid Numbers
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec4::IsFinite()
-{
+bool CVec4::IsFinite() {
#if defined(_MSC_VER)
- return (_finite(v[0]) && _finite(v[1]) && _finite(v[2]) && _finite(v[3]));
+ return (_finite(v[0]) && _finite(v[1]) && _finite(v[2]) && _finite(v[3]));
#else
return isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]);
#endif
@@ -428,16 +375,10 @@ bool CVec4::IsFinite()
////////////////////////////////////////////////////////////////////////////////////////
// Make Sure Vector Has Been Initialized
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec4::IsInitialized()
-{
- return (v[0]!=RAVL_VEC_UDF && v[1]!=RAVL_VEC_UDF && v[2]!=RAVL_VEC_UDF && v[3]!=RAVL_VEC_UDF);
-}
+bool CVec4::IsInitialized() { return (v[0] != RAVL_VEC_UDF && v[1] != RAVL_VEC_UDF && v[2] != RAVL_VEC_UDF && v[3] != RAVL_VEC_UDF); }
#endif
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Point In Circumscribed Circle (True/False)
//
@@ -452,38 +393,40 @@ bool CVec4::IsInitialized()
// \_______/
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec4::PtInCircle(const CVec4 &A, const CVec4 &B, const CVec4 &C) const
-{
- float vol;
- float ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz;
- float bxdx, bydy, bzdz, cxdx, cydy, czdz;
+bool CVec4::PtInCircle(const CVec4 &A, const CVec4 &B, const CVec4 &C) const {
+ float vol;
+ float ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz;
+ float bxdx, bydy, bzdz, cxdx, cydy, czdz;
- float tolerance=0.00000005f;
+ float tolerance = 0.00000005f;
ax = A.v[0];
ay = A.v[1];
- az = ax*ax + ay*ay;
+ az = ax * ax + ay * ay;
bx = B.v[0];
by = B.v[1];
- bz = bx*bx + by*by;
+ bz = bx * bx + by * by;
cx = C.v[0];
cy = C.v[1];
- cz = cx*cx + cy*cy;
+ cz = cx * cx + cy * cy;
dx = v[0];
dy = v[1];
- dz = dx*dx + dy*dy;
-
- bxdx=bx-dx;
- bydy=by-dy;
- bzdz=bz-dz;
- cxdx=cx-dx;
- cydy=cy-dy;
- czdz=cz-dz;
- vol = (az-dz)*(bxdx*cydy-bydy*cxdx) + (ay-dy)*(bzdz*cxdx-bxdx*czdz) + (ax-dx)*(bydy*czdz-bzdz*cydy);
-
- if ( vol > tolerance) return true;
- else if ( vol < -1*tolerance) return false;
- else return false;
+ dz = dx * dx + dy * dy;
+
+ bxdx = bx - dx;
+ bydy = by - dy;
+ bzdz = bz - dz;
+ cxdx = cx - dx;
+ cydy = cy - dy;
+ czdz = cz - dz;
+ vol = (az - dz) * (bxdx * cydy - bydy * cxdx) + (ay - dy) * (bzdz * cxdx - bxdx * czdz) + (ax - dx) * (bydy * czdz - bzdz * cydy);
+
+ if (vol > tolerance)
+ return true;
+ else if (vol < -1 * tolerance)
+ return false;
+ else
+ return false;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -499,14 +442,7 @@ bool CVec4::PtInCircle(const CVec4 &A, const CVec4 &B, const CVec4 &C) const
// \_______/
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec4::PtInCircle(const CVec4 &Circle, float Radius) const
-{
- return (Dist2(Circle)<(Radius*Radius));
-}
-
-
-
-
+bool CVec4::PtInCircle(const CVec4 &Circle, float Radius) const { return (Dist2(Circle) < (Radius * Radius)); }
////////////////////////////////////////////////////////////////////////////////////////
// Line Intersects Circle (True/False)
@@ -528,16 +464,14 @@ bool CVec4::PtInCircle(const CVec4 &Circle, float Radius) const
// A
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec4::LineInCircle(const CVec4 &A, const CVec4 &B, float r, CVec4 &P)
-{
+bool CVec4::LineInCircle(const CVec4 &A, const CVec4 &B, float r, CVec4 &P) {
P = (*this);
- float Scale = P.ProjectToLine(A, B);
+ float Scale = P.ProjectToLine(A, B);
// If The Projected Position Is Not On The Line Segment,
// Check If It Is Within Radius Of Endpoints A and B.
//-------------------------------------------------------
- if (Scale<0 || Scale>1)
- {
+ if (Scale < 0 || Scale > 1) {
return (PtInCircle(A, r) || PtInCircle(B, r));
}
@@ -549,16 +483,14 @@ bool CVec4::LineInCircle(const CVec4 &A, const CVec4 &B, float r, CVec4 &P)
////////////////////////////////////////////////////////////////////////////////////////
// Same As Test Above, Just Don't Bother Returning P
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec4::LineInCircle(const CVec4 &A, const CVec4 &B, float r)
-{
- CVec4 P(*this);
- float Scale = P.ProjectToLine(A, B);
+bool CVec4::LineInCircle(const CVec4 &A, const CVec4 &B, float r) {
+ CVec4 P(*this);
+ float Scale = P.ProjectToLine(A, B);
// If The Projected Position Is Not On The Line Segment,
// Check If It Is Within Radius Of Endpoints A and B.
//-------------------------------------------------------
- if (Scale<0 || Scale>1)
- {
+ if (Scale < 0 || Scale > 1) {
return (PtInCircle(A, r) || PtInCircle(B, r));
}
@@ -567,28 +499,24 @@ bool CVec4::LineInCircle(const CVec4 &A, const CVec4 &B, float r)
return (PtInCircle(P, r));
}
-
////////////////////////////////////////////////////////////////////////////////////////
// Rotate
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::RotatePoint(const CVec4 &, const CVec4 &)
-{
+void CVec4::RotatePoint(const CVec4 &, const CVec4 &) {
// TO DO: Use Matrix Code To Rotate
}
////////////////////////////////////////////////////////////////////////////////////////
// Reposition
////////////////////////////////////////////////////////////////////////////////////////
-void CVec4::Reposition(const CVec4 &Translation, float RotationDegrees)
-{
+void CVec4::Reposition(const CVec4 &Translation, float RotationDegrees) {
// Apply Any Rotation First
//--------------------------
- if (RotationDegrees)
- {
+ if (RotationDegrees) {
CVec4 Old(*this);
float Rotation = RAVL_VEC_DEGTORAD(RotationDegrees);
- v[0] = Old.v[0]*cosf(Rotation) - Old.v[1]*sinf(Rotation);
- v[1] = Old.v[0]*sinf(Rotation) + Old.v[1]*cosf(Rotation);
+ v[0] = Old.v[0] * cosf(Rotation) - Old.v[1] * sinf(Rotation);
+ v[1] = Old.v[0] * sinf(Rotation) + Old.v[1] * cosf(Rotation);
}
// Now Apply Translation
@@ -596,56 +524,32 @@ void CVec4::Reposition(const CVec4 &Translation, float RotationDegrees)
(*this) += Translation;
}
-
-
-
-
-
-
-
-
-
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Static Class Member Initialization
////////////////////////////////////////////////////////////////////////////////////////
-const CVec3 CVec3::mX(1.f, 0.f, 0.f);
-const CVec3 CVec3::mY(0.f, 1.f, 0.f);
-const CVec3 CVec3::mZ(0.f, 0.f, 1.f);
-const CVec3 CVec3::mZero(0.f, 0.f, 0.f);
-
-
-
+const CVec3 CVec3::mX(1.f, 0.f, 0.f);
+const CVec3 CVec3::mY(0.f, 1.f, 0.f);
+const CVec3 CVec3::mZ(0.f, 0.f, 1.f);
+const CVec3 CVec3::mZero(0.f, 0.f, 0.f);
////////////////////////////////////////////////////////////////////////////////////////
// Length
////////////////////////////////////////////////////////////////////////////////////////
-float CVec3::Len() const
-{
- return sqrtf(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
-}
-
+float CVec3::Len() const { return sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); }
////////////////////////////////////////////////////////////////////////////////////////
// Distance To Other Point
////////////////////////////////////////////////////////////////////////////////////////
-float CVec3::Dist(const CVec3& t) const
-{
- return sqrtf(
- (t.v[0]-v[0])*(t.v[0]-v[0]) +
- (t.v[1]-v[1])*(t.v[1]-v[1]) +
- (t.v[2]-v[2])*(t.v[2]-v[2]));
+float CVec3::Dist(const CVec3 &t) const {
+ return sqrtf((t.v[0] - v[0]) * (t.v[0] - v[0]) + (t.v[1] - v[1]) * (t.v[1] - v[1]) + (t.v[2] - v[2]) * (t.v[2] - v[2]));
}
////////////////////////////////////////////////////////////////////////////////////////
// Normalize
////////////////////////////////////////////////////////////////////////////////////////
-float CVec3::Norm()
-{
- float L = Len();
- (*this)/=L;
+float CVec3::Norm() {
+ float L = Len();
+ (*this) /= L;
return L;
}
@@ -653,15 +557,13 @@ float CVec3::Norm()
// Safe Normalize
// Do Not Normalize If Length Is Too Small
////////////////////////////////////////////////////////////////////////////////////////
-float CVec3::SafeNorm()
-{
- float d=this->Len();
- if (d>1E-10)
- {
- (*this)/=d;
+float CVec3::SafeNorm() {
+ float d = this->Len();
+ if (d > 1E-10) {
+ (*this) /= d;
return d;
}
- (*this)=0.0f;
+ (*this) = 0.0f;
return 0;
}
@@ -669,30 +571,33 @@ float CVec3::SafeNorm()
// Angular Normalize
// All floats Exist(-180, +180)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::AngleNorm()
-{
- v[0]= fmodf(v[0],360.0f);
- if (v[0]<-180.f) v[0]+=360.0f;
- if (v[0]>180.f) v[0]-=360.0f;
+void CVec3::AngleNorm() {
+ v[0] = fmodf(v[0], 360.0f);
+ if (v[0] < -180.f)
+ v[0] += 360.0f;
+ if (v[0] > 180.f)
+ v[0] -= 360.0f;
- v[1]= fmodf(v[1],360.0f);
- if (v[1]<-180.f) v[1]+=360.0f;
- if (v[1]>180.f) v[1]-=360.0f;
+ v[1] = fmodf(v[1], 360.0f);
+ if (v[1] < -180.f)
+ v[1] += 360.0f;
+ if (v[1] > 180.f)
+ v[1] -= 360.0f;
- v[2]= fmodf(v[2],360.0f);
- if (v[2]<-180.f) v[2]+=360.0f;
- if (v[2]>180.f) v[2]-=360.0f;
+ v[2] = fmodf(v[2], 360.0f);
+ if (v[2] < -180.f)
+ v[2] += 360.0f;
+ if (v[2] > 180.f)
+ v[2] -= 360.0f;
}
////////////////////////////////////////////////////////////////////////////////////////
// Angular Normalize
// All floats Exist(-180, +180)
////////////////////////////////////////////////////////////////////////////////////////
-float CVec3::Truncate(float maxlen)
-{
- float len=this->Len();
- if (len>maxlen && len>1E-10)
- {
+float CVec3::Truncate(float maxlen) {
+ float len = this->Len();
+ if (len > maxlen && len > 1E-10) {
len = maxlen / len;
v[0] *= len;
v[1] *= len;
@@ -709,28 +614,25 @@ float CVec3::Truncate(float maxlen)
// This implimentation is a bit slow, needs some optimization work...
//
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::Perp()
-{
- float rlen,tlen;
- CVec3 r,t;
+void CVec3::Perp() {
+ float rlen, tlen;
+ CVec3 r, t;
r = (*this);
r.Cross(mX);
- rlen=r.Len();
+ rlen = r.Len();
t = (*this);
t.Cross(mY);
- tlen=t.Len();
- if (tlen>rlen)
- {
- r=t;
- rlen=tlen;
+ tlen = t.Len();
+ if (tlen > rlen) {
+ r = t;
+ rlen = tlen;
}
t = (*this);
t.Cross(mZ);
- tlen=t.Len();
- if (tlen>rlen)
- {
- r=t;
- rlen=tlen;
+ tlen = t.Len();
+ if (tlen > rlen) {
+ r = t;
+ rlen = tlen;
}
(*this) = r;
}
@@ -738,14 +640,11 @@ void CVec3::Perp()
////////////////////////////////////////////////////////////////////////////////////////
// Find Largest Element (Ignores 4th component for now)
////////////////////////////////////////////////////////////////////////////////////////
-int CVec3::MaxElementIndex() const
-{
- if (fabs(v[0])>fabs(v[1]) && fabs(v[0])>fabs(v[2]))
- {
+int CVec3::MaxElementIndex() const {
+ if (fabs(v[0]) > fabs(v[1]) && fabs(v[0]) > fabs(v[2])) {
return 0;
}
- if (fabs(v[1])>fabs(v[2]))
- {
+ if (fabs(v[1]) > fabs(v[2])) {
return 1;
}
return 2;
@@ -754,64 +653,54 @@ int CVec3::MaxElementIndex() const
////////////////////////////////////////////////////////////////////////////////////////
// Convert To {Pitch, Yaw} (DEGREES)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::VecToAng()
-{
- float yaw;
- float pitch;
+void CVec3::VecToAng() {
+ float yaw;
+ float pitch;
- if (!v[1] && !v[0])
- {
- yaw = 0;
- pitch = (v[2]>0) ? (90.0f):(270.0f);
- }
- else
- {
+ if (!v[1] && !v[0]) {
+ yaw = 0;
+ pitch = (v[2] > 0) ? (90.0f) : (270.0f);
+ } else {
// Calculate Yaw
//---------------
- if (v[0])
- {
+ if (v[0]) {
yaw = (RAVL_VEC_RADTODEG(atan2f(v[1], v[0])));
- if (yaw<0)
- {
+ if (yaw < 0) {
yaw += 360;
}
- }
- else
- {
- yaw = (v[1]>0) ? (90.0f):(270.0f);
+ } else {
+ yaw = (v[1] > 0) ? (90.0f) : (270.0f);
}
// Calculate Pitch
//-----------------
- float forward = (sqrtf(v[0]*v[0] + v[1]*v[1]));
- pitch = (RAVL_VEC_RADTODEG(atan2f(v[2], forward)));
- if (pitch<0)
- {
+ float forward = (sqrtf(v[0] * v[0] + v[1] * v[1]));
+ pitch = (RAVL_VEC_RADTODEG(atan2f(v[2], forward)));
+ if (pitch < 0) {
pitch += 360;
}
}
// Copy Over Current Vector
//--------------------------
- v[0] = -pitch;
- v[1] = yaw;
- v[2] = 0;
+ v[0] = -pitch;
+ v[1] = yaw;
+ v[2] = 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw} (DEGREES)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::AngToVec()
-{
- float angle;
- float sp, sy, cp, cy;
+void CVec3::AngToVec() {
+ float angle;
+ float sp, sy, cp, cy;
- angle = yaw() * (RAVL_VEC_DEGTORADCONST);
- sy = sinf(angle);
- cy = cosf(angle);
- angle = pitch() * (RAVL_VEC_DEGTORADCONST);
- sp = sinf(angle);
- cp = cosf(angle);
+ angle = yaw() * (RAVL_VEC_DEGTORADCONST);
+ sy = sinf(angle);
+ cy = cosf(angle);
+ angle = pitch() * (RAVL_VEC_DEGTORADCONST);
+ sp = sinf(angle);
+ cp = cosf(angle);
v[0] = cp * cy;
v[1] = cp * sy;
@@ -821,20 +710,19 @@ void CVec3::AngToVec()
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw, Roll} (DEGREES)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::AngToVec(CVec3& Right, CVec3& Up)
-{
- float angle;
- float sr, sp, sy, cr, cp, cy;
-
- angle = yaw() * (RAVL_VEC_DEGTORADCONST);
- sy = sinf(angle);
- cy = cosf(angle);
- angle = pitch() * (RAVL_VEC_DEGTORADCONST);
- sp = sinf(angle);
- cp = cosf(angle);
- angle = roll() * (RAVL_VEC_DEGTORADCONST);
- sr = sinf(angle);
- cr = cosf(angle);
+void CVec3::AngToVec(CVec3 &Right, CVec3 &Up) {
+ float angle;
+ float sr, sp, sy, cr, cp, cy;
+
+ angle = yaw() * (RAVL_VEC_DEGTORADCONST);
+ sy = sinf(angle);
+ cy = cosf(angle);
+ angle = pitch() * (RAVL_VEC_DEGTORADCONST);
+ sp = sinf(angle);
+ cp = cosf(angle);
+ angle = roll() * (RAVL_VEC_DEGTORADCONST);
+ sr = sinf(angle);
+ cr = cosf(angle);
// Forward Vector Is Stored Here
v[0] = cp * cy;
@@ -852,59 +740,48 @@ void CVec3::AngToVec(CVec3& Right, CVec3& Up)
Up.v[2] = cr * cp;
}
-
-
-
///////////////////////////////////////////////////////////////////////////////////////
// Convert To {Pitch, Yaw} (RADIANS)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::VecToAngRad()
-{
- float yaw;
- float pitch;
+void CVec3::VecToAngRad() {
+ float yaw;
+ float pitch;
- if (!v[1] && !v[0])
- {
- yaw = 0;
- pitch = (v[2]>0) ? (RAVL_VEC_PI*0.5f):(RAVL_VEC_PI*1.5f);
- }
- else
- {
+ if (!v[1] && !v[0]) {
+ yaw = 0;
+ pitch = (v[2] > 0) ? (RAVL_VEC_PI * 0.5f) : (RAVL_VEC_PI * 1.5f);
+ } else {
// Calculate Yaw
//---------------
- if (v[0])
- {
+ if (v[0]) {
yaw = (atan2f(v[1], v[0]));
- }
- else
- {
- yaw = (v[1]>0) ? (RAVL_VEC_PI*0.5f):(RAVL_VEC_PI*1.5f);
+ } else {
+ yaw = (v[1] > 0) ? (RAVL_VEC_PI * 0.5f) : (RAVL_VEC_PI * 1.5f);
}
// Calculate Pitch
//-----------------
- float forward = (sqrtf(v[0]*v[0] + v[1]*v[1]));
- pitch = (atan2f(v[2], forward));
+ float forward = (sqrtf(v[0] * v[0] + v[1] * v[1]));
+ pitch = (atan2f(v[2], forward));
}
// Copy Over Current Vector
//--------------------------
- v[0] = -pitch;
- v[1] = yaw;
- v[2] = 0;
+ v[0] = -pitch;
+ v[1] = yaw;
+ v[2] = 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw} (RADIANS)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::AngToVecRad()
-{
- float sp, sy, cp, cy;
+void CVec3::AngToVecRad() {
+ float sp, sy, cp, cy;
- sy = sinf(yaw());
- cy = cosf(yaw());
- sp = sinf(pitch());
- cp = cosf(pitch());
+ sy = sinf(yaw());
+ cy = cosf(yaw());
+ sp = sinf(pitch());
+ cp = cosf(pitch());
v[0] = cp * cy;
v[1] = cp * sy;
@@ -914,16 +791,15 @@ void CVec3::AngToVecRad()
////////////////////////////////////////////////////////////////////////////////////////
// Convert From {Picth, Yaw, Roll} (RADIANS)
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::AngToVecRad(CVec3& Right, CVec3& Up)
-{
- float sr, sp, sy, cr, cp, cy;
+void CVec3::AngToVecRad(CVec3 &Right, CVec3 &Up) {
+ float sr, sp, sy, cr, cp, cy;
- sy = sinf(yaw());
- cy = cosf(yaw());
- sp = sinf(pitch());
- cp = cosf(pitch());
- sr = sinf(roll());
- cr = cosf(roll());
+ sy = sinf(yaw());
+ cy = cosf(yaw());
+ sp = sinf(pitch());
+ cp = cosf(pitch());
+ sr = sinf(roll());
+ cr = cosf(roll());
// Forward Vector Is Stored Here
v[0] = cp * cy;
@@ -941,12 +817,10 @@ void CVec3::AngToVecRad(CVec3& Right, CVec3& Up)
Up.v[2] = cr * cp;
}
-
////////////////////////////////////////////////////////////////////////////////////////
// Convert To Radians
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::ToRadians()
-{
+void CVec3::ToRadians() {
v[0] = RAVL_VEC_DEGTORAD(v[0]);
v[1] = RAVL_VEC_DEGTORAD(v[1]);
v[2] = RAVL_VEC_DEGTORAD(v[2]);
@@ -955,22 +829,16 @@ void CVec3::ToRadians()
////////////////////////////////////////////////////////////////////////////////////////
// Convert To Degrees
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::ToDegrees()
-{
+void CVec3::ToDegrees() {
v[0] = RAVL_VEC_RADTODEG(v[0]);
v[1] = RAVL_VEC_RADTODEG(v[1]);
v[2] = RAVL_VEC_RADTODEG(v[2]);
}
-
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Copy Values From String
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::FromStr(const char *s)
-{
+void CVec3::FromStr(const char *s) {
assert(s && s[0]);
sscanf(s, "(%f %f %f)", &v[0], &v[1], &v[2]);
}
@@ -978,41 +846,31 @@ void CVec3::FromStr(const char *s)
////////////////////////////////////////////////////////////////////////////////////////
// Write Values To A String
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::ToStr(char* s) const
-{
+void CVec3::ToStr(char *s) const {
assert(s);
sprintf(s, "(%3.3f %3.3f %3.3f)", v[0], v[1], v[2]);
}
-
-
#ifdef _DEBUG
////////////////////////////////////////////////////////////////////////////////////////
// Make Sure Entire Vector Has Valid Numbers
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec3::IsFinite()
-{
+bool CVec3::IsFinite() {
#if defined(_MSC_VER)
- return (_finite(v[0]) && _finite(v[1]) && _finite(v[2]));
+ return (_finite(v[0]) && _finite(v[1]) && _finite(v[2]));
#else
- return isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]);
+ return isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]);
#endif
}
////////////////////////////////////////////////////////////////////////////////////////
// Make Sure Vector Has Been Initialized
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec3::IsInitialized()
-{
- return (v[0]!=RAVL_VEC_UDF && v[1]!=RAVL_VEC_UDF && v[2]!=RAVL_VEC_UDF);
-}
+bool CVec3::IsInitialized() { return (v[0] != RAVL_VEC_UDF && v[1] != RAVL_VEC_UDF && v[2] != RAVL_VEC_UDF); }
#endif
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Point In Circumscribed Circle (True/False)
//
@@ -1027,38 +885,40 @@ bool CVec3::IsInitialized()
// \_______/
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec3::PtInCircle(const CVec3 &A, const CVec3 &B, const CVec3 &C) const
-{
- float vol;
- float ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz;
- float bxdx, bydy, bzdz, cxdx, cydy, czdz;
+bool CVec3::PtInCircle(const CVec3 &A, const CVec3 &B, const CVec3 &C) const {
+ float vol;
+ float ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz;
+ float bxdx, bydy, bzdz, cxdx, cydy, czdz;
- float tolerance=0.00000005f;
+ float tolerance = 0.00000005f;
ax = A.v[0];
ay = A.v[1];
- az = ax*ax + ay*ay;
+ az = ax * ax + ay * ay;
bx = B.v[0];
by = B.v[1];
- bz = bx*bx + by*by;
+ bz = bx * bx + by * by;
cx = C.v[0];
cy = C.v[1];
- cz = cx*cx + cy*cy;
+ cz = cx * cx + cy * cy;
dx = v[0];
dy = v[1];
- dz = dx*dx + dy*dy;
-
- bxdx=bx-dx;
- bydy=by-dy;
- bzdz=bz-dz;
- cxdx=cx-dx;
- cydy=cy-dy;
- czdz=cz-dz;
- vol = (az-dz)*(bxdx*cydy-bydy*cxdx) + (ay-dy)*(bzdz*cxdx-bxdx*czdz) + (ax-dx)*(bydy*czdz-bzdz*cydy);
-
- if ( vol > tolerance) return true;
- else if ( vol < -1*tolerance) return false;
- else return false;
+ dz = dx * dx + dy * dy;
+
+ bxdx = bx - dx;
+ bydy = by - dy;
+ bzdz = bz - dz;
+ cxdx = cx - dx;
+ cydy = cy - dy;
+ czdz = cz - dz;
+ vol = (az - dz) * (bxdx * cydy - bydy * cxdx) + (ay - dy) * (bzdz * cxdx - bxdx * czdz) + (ax - dx) * (bydy * czdz - bzdz * cydy);
+
+ if (vol > tolerance)
+ return true;
+ else if (vol < -1 * tolerance)
+ return false;
+ else
+ return false;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -1074,14 +934,7 @@ bool CVec3::PtInCircle(const CVec3 &A, const CVec3 &B, const CVec3 &C) const
// \_______/
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec3::PtInCircle(const CVec3 &Circle, float Radius) const
-{
- return (Dist2(Circle)<(Radius*Radius));
-}
-
-
-
-
+bool CVec3::PtInCircle(const CVec3 &Circle, float Radius) const { return (Dist2(Circle) < (Radius * Radius)); }
////////////////////////////////////////////////////////////////////////////////////////
// Line Intersects Circle (True/False)
@@ -1103,16 +956,14 @@ bool CVec3::PtInCircle(const CVec3 &Circle, float Radius) const
// A
//
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec3::LineInCircle(const CVec3 &A, const CVec3 &B, float r, CVec3 &P)
-{
+bool CVec3::LineInCircle(const CVec3 &A, const CVec3 &B, float r, CVec3 &P) {
P = (*this);
- float Scale = P.ProjectToLine(A, B);
+ float Scale = P.ProjectToLine(A, B);
// If The Projected Position Is Not On The Line Segment,
// Check If It Is Within Radius Of Endpoints A and B.
//-------------------------------------------------------
- if (Scale<0 || Scale>1)
- {
+ if (Scale < 0 || Scale > 1) {
return (PtInCircle(A, r) || PtInCircle(B, r));
}
@@ -1124,16 +975,14 @@ bool CVec3::LineInCircle(const CVec3 &A, const CVec3 &B, float r, CVec3 &P)
////////////////////////////////////////////////////////////////////////////////////////
// Same As Test Above, Just Don't Bother Returning P
////////////////////////////////////////////////////////////////////////////////////////
-bool CVec3::LineInCircle(const CVec3 &A, const CVec3 &B, float r)
-{
- CVec3 P(*this);
- float Scale = P.ProjectToLine(A, B);
+bool CVec3::LineInCircle(const CVec3 &A, const CVec3 &B, float r) {
+ CVec3 P(*this);
+ float Scale = P.ProjectToLine(A, B);
// If The Projected Position Is Not On The Line Segment,
// Check If It Is Within Radius Of Endpoints A and B.
//-------------------------------------------------------
- if (Scale<0 || Scale>1)
- {
+ if (Scale < 0 || Scale > 1) {
return (PtInCircle(A, r) || PtInCircle(B, r));
}
@@ -1142,32 +991,27 @@ bool CVec3::LineInCircle(const CVec3 &A, const CVec3 &B, float r)
return (PtInCircle(P, r));
}
-
////////////////////////////////////////////////////////////////////////////////////////
// Rotate
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::RotatePoint(const CVec3 &, const CVec3 &)
-{
+void CVec3::RotatePoint(const CVec3 &, const CVec3 &) {
// TO DO: Use Matrix Code To Rotate
}
////////////////////////////////////////////////////////////////////////////////////////
// Reposition
////////////////////////////////////////////////////////////////////////////////////////
-void CVec3::Reposition(const CVec3 &Translation, float RotationDegrees)
-{
+void CVec3::Reposition(const CVec3 &Translation, float RotationDegrees) {
// Apply Any Rotation First
//--------------------------
- if (RotationDegrees)
- {
+ if (RotationDegrees) {
CVec3 Old(*this);
float Rotation = RAVL_VEC_DEGTORAD(RotationDegrees);
- v[0] = Old.v[0]*cosf(Rotation) - Old.v[1]*sinf(Rotation);
- v[1] = Old.v[0]*sinf(Rotation) + Old.v[1]*cosf(Rotation);
+ v[0] = Old.v[0] * cosf(Rotation) - Old.v[1] * sinf(Rotation);
+ v[1] = Old.v[0] * sinf(Rotation) + Old.v[1] * cosf(Rotation);
}
// Now Apply Translation
//-----------------------
(*this) += Translation;
}
-
diff --git a/code/Rufl/hfile.cpp b/code/Rufl/hfile.cpp
index f5003cbd8f..c4c4391fcc 100644
--- a/code/Rufl/hfile.cpp
+++ b/code/Rufl/hfile.cpp
@@ -30,8 +30,6 @@ along with this program; if not, see .
//
////////////////////////////////////////////////////////////////////////////////////////
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////////////////////////
@@ -41,81 +39,63 @@ along with this program; if not, see .
#endif
#include "hfile.h"
#if !defined(RATL_HANDLE_POOL_VS_INC)
- #include "../Ratl/handle_pool_vs.h"
+#include "../Ratl/handle_pool_vs.h"
#endif
#if !defined(RATL_VECTOR_VS_INC)
- #include "../Ratl/vector_vs.h"
+#include "../Ratl/vector_vs.h"
#endif
#if !defined(RUFL_HSTRING_INC)
- #include "hstring.h"
+#include "hstring.h"
#endif
-
-
-
-extern bool HFILEopen_read(int& handle, const char* filepath);
-extern bool HFILEopen_write(int& handle, const char* filepath);
-extern bool HFILEread(int& handle, void* data, int size);
-extern bool HFILEwrite(int& handle, const void* data, int size);
-extern bool HFILEclose(int& handle);
-
-
-
-
+extern bool HFILEopen_read(int &handle, const char *filepath);
+extern bool HFILEopen_write(int &handle, const char *filepath);
+extern bool HFILEread(int &handle, void *data, int size);
+extern bool HFILEwrite(int &handle, const void *data, int size);
+extern bool HFILEclose(int &handle);
////////////////////////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////////////////////////
-#define MAX_OPEN_FILES 20
-
+#define MAX_OPEN_FILES 20
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-struct SOpenFile
-{
- hstring mPath;
- bool mForRead;
- int mHandle;
- float mVersion;
- int mChecksum;
+struct SOpenFile {
+ hstring mPath;
+ bool mForRead;
+ int mHandle;
+ float mVersion;
+ int mChecksum;
};
-typedef ratl::handle_pool_vs TFilePool;
+typedef ratl::handle_pool_vs TFilePool;
-static TFilePool& Pool()
-{
+static TFilePool &Pool() {
static TFilePool TFP;
return TFP;
}
-
-
-
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Constructor
//
// Allocates a new OpenFile structure and initializes it. DOES NOT OPEN!
//
////////////////////////////////////////////////////////////////////////////////////////
-hfile::hfile(const char* file)
-{
- if (Pool().full())
- {
+hfile::hfile(const char *file) {
+ if (Pool().full()) {
mHandle = 0;
- assert("HFILE: Too Many Files Open, Unable To Grab An Unused Handle"==0);
+ assert("HFILE: Too Many Files Open, Unable To Grab An Unused Handle" == 0);
return;
}
mHandle = Pool().alloc();
- SOpenFile& sfile = Pool()[mHandle];
+ SOpenFile &sfile = Pool()[mHandle];
- sfile.mPath = file;
- sfile.mHandle = 0;
- sfile.mForRead = true;
+ sfile.mPath = file;
+ sfile.mHandle = 0;
+ sfile.mForRead = true;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -124,15 +104,12 @@ hfile::hfile(const char* file)
// Releases the open file structure for resue. Also closes the file if open.
//
////////////////////////////////////////////////////////////////////////////////////////
-hfile::~hfile()
-{
- if (is_open())
- {
+hfile::~hfile() {
+ if (is_open()) {
close();
}
- if (mHandle && Pool().is_used(mHandle))
- {
+ if (mHandle && Pool().is_used(mHandle)) {
Pool().free(mHandle);
}
mHandle = 0;
@@ -141,11 +118,9 @@ hfile::~hfile()
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-bool hfile::is_open(void) const
-{
- if (mHandle && Pool().is_used(mHandle))
- {
- return (Pool()[mHandle].mHandle!=0);
+bool hfile::is_open(void) const {
+ if (mHandle && Pool().is_used(mHandle)) {
+ return (Pool()[mHandle].mHandle != 0);
}
return false;
}
@@ -153,12 +128,10 @@ bool hfile::is_open(void) const
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-bool hfile::is_open_for_read(void) const
-{
- if (mHandle && Pool().is_used(mHandle))
- {
- SOpenFile& sfile = Pool()[mHandle];
- return (sfile.mHandle!=0 && sfile.mForRead);
+bool hfile::is_open_for_read(void) const {
+ if (mHandle && Pool().is_used(mHandle)) {
+ SOpenFile &sfile = Pool()[mHandle];
+ return (sfile.mHandle != 0 && sfile.mForRead);
}
return false;
}
@@ -166,100 +139,80 @@ bool hfile::is_open_for_read(void) const
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-bool hfile::is_open_for_write(void) const
-{
- if (mHandle && Pool().is_used(mHandle))
- {
- SOpenFile& sfile = Pool()[mHandle];
- return (sfile.mHandle!=0 && !sfile.mForRead);
+bool hfile::is_open_for_write(void) const {
+ if (mHandle && Pool().is_used(mHandle)) {
+ SOpenFile &sfile = Pool()[mHandle];
+ return (sfile.mHandle != 0 && !sfile.mForRead);
}
return false;
}
-
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
-bool hfile::open(float version, int checksum, bool read)
-{
+bool hfile::open(float version, int checksum, bool read) {
// Make Sure This Is A Valid Handle
//----------------------------------
- if (!mHandle || !Pool().is_used(mHandle))
- {
- assert("HFILE: Invalid Handle"==0);
+ if (!mHandle || !Pool().is_used(mHandle)) {
+ assert("HFILE: Invalid Handle" == 0);
return false;
}
// Make Sure The File Is Not ALREADY Open
//----------------------------------------
- SOpenFile& sfile = Pool()[mHandle];
- if (sfile.mHandle!=0)
- {
- assert("HFILE: Attempt To Open An Already Open File"==0);
+ SOpenFile &sfile = Pool()[mHandle];
+ if (sfile.mHandle != 0) {
+ assert("HFILE: Attempt To Open An Already Open File" == 0);
return false;
}
sfile.mForRead = read;
- if (read)
- {
+ if (read) {
HFILEopen_read(sfile.mHandle, *sfile.mPath);
- }
- else
- {
+ } else {
HFILEopen_write(sfile.mHandle, *sfile.mPath);
}
// If The Open Failed, Report It And Free The SOpenFile
//------------------------------------------------------
- if (sfile.mHandle==0)
- {
- if (!read)
- {
- assert("HFILE: Unable To Open File"==0);
+ if (sfile.mHandle == 0) {
+ if (!read) {
+ assert("HFILE: Unable To Open File" == 0);
}
return false;
}
-
// Read The File's Header
//------------------------
- if (read)
- {
- if (!HFILEread(sfile.mHandle, &sfile.mVersion, sizeof(sfile.mVersion)))
- {
- assert("HFILE: Unable To Read File Header"==0);
+ if (read) {
+ if (!HFILEread(sfile.mHandle, &sfile.mVersion, sizeof(sfile.mVersion))) {
+ assert("HFILE: Unable To Read File Header" == 0);
close();
return false;
}
- if (!HFILEread(sfile.mHandle, &sfile.mChecksum, sizeof(sfile.mChecksum)))
- {
- assert("HFILE: Unable To Read File Header"==0);
+ if (!HFILEread(sfile.mHandle, &sfile.mChecksum, sizeof(sfile.mChecksum))) {
+ assert("HFILE: Unable To Read File Header" == 0);
close();
return false;
}
// Make Sure The Checksum & Version Match
//----------------------------------------
- if (sfile.mVersion!=version || sfile.mChecksum!=checksum)
- {
+ if (sfile.mVersion != version || sfile.mChecksum != checksum) {
close();
- return false; // Failed To Match Checksum Or Version Number -> Old Data
+ return false; // Failed To Match Checksum Or Version Number -> Old Data
}
- }
- else
- {
+ } else {
sfile.mVersion = version;
sfile.mChecksum = checksum;
- if (!HFILEwrite(sfile.mHandle, &sfile.mVersion, sizeof(sfile.mVersion)))
- {
- assert("HFILE: Unable To Write File Header"==0);
+ if (!HFILEwrite(sfile.mHandle, &sfile.mVersion, sizeof(sfile.mVersion))) {
+ assert("HFILE: Unable To Write File Header" == 0);
close();
return false;
}
- if (!HFILEwrite(sfile.mHandle, &sfile.mChecksum, sizeof(sfile.mChecksum)))
- {
- assert("HFILE: Unable To Write File Header"==0);
+ if (!HFILEwrite(sfile.mHandle, &sfile.mChecksum, sizeof(sfile.mChecksum))) {
+ assert("HFILE: Unable To Write File Header" == 0);
close();
return false;
}
@@ -271,25 +224,21 @@ bool hfile::open(float version, int checksum, bool read)
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
-bool hfile::close()
-{
- if (!mHandle || !Pool().is_used(mHandle))
- {
- assert("HFILE: Invalid Handle"==0);
+bool hfile::close() {
+ if (!mHandle || !Pool().is_used(mHandle)) {
+ assert("HFILE: Invalid Handle" == 0);
return false;
}
- SOpenFile& sfile = Pool()[mHandle];
- if (sfile.mHandle==0)
- {
- assert("HFILE: Unable TO Close Unopened File"==0);
+ SOpenFile &sfile = Pool()[mHandle];
+ if (sfile.mHandle == 0) {
+ assert("HFILE: Unable TO Close Unopened File" == 0);
return false;
}
- if (!HFILEclose(sfile.mHandle))
- {
+ if (!HFILEclose(sfile.mHandle)) {
sfile.mHandle = 0;
- assert("HFILE: Unable To Close File"==0);
+ assert("HFILE: Unable To Close File" == 0);
return false;
}
sfile.mHandle = 0;
@@ -300,15 +249,12 @@ bool hfile::close()
////////////////////////////////////////////////////////////////////////////////////
// Searches for the first block with the matching data size, and reads it in.
////////////////////////////////////////////////////////////////////////////////////
-bool hfile::load(void* data, int datasize)
-{
+bool hfile::load(void *data, int datasize) {
// Go Ahead And Open The File For Reading
//----------------------------------------
bool auto_opened = false;
- if (!is_open())
- {
- if (!open_read())
- {
+ if (!is_open()) {
+ if (!open_read()) {
return false;
}
auto_opened = true;
@@ -316,25 +262,20 @@ bool hfile::load(void* data, int datasize)
// Make Sure That The File Is Readable
//-------------------------------------
- SOpenFile& sfile = Pool()[mHandle];
- if (!sfile.mForRead)
- {
- assert("HFILE: Unable to load from a file that is opened for save"==0);
- if (auto_opened)
- {
+ SOpenFile &sfile = Pool()[mHandle];
+ if (!sfile.mForRead) {
+ assert("HFILE: Unable to load from a file that is opened for save" == 0);
+ if (auto_opened) {
close();
}
return false;
}
-
// Now Read It
//-------------
- if (!HFILEread(sfile.mHandle, data, datasize))
- {
- assert("HFILE: Unable To Read Object"==0);
- if (auto_opened)
- {
+ if (!HFILEread(sfile.mHandle, data, datasize)) {
+ assert("HFILE: Unable To Read Object" == 0);
+ if (auto_opened) {
close();
}
return false;
@@ -342,8 +283,7 @@ bool hfile::load(void* data, int datasize)
// Success!
//----------
- if (auto_opened)
- {
+ if (auto_opened) {
close();
}
return true;
@@ -352,15 +292,12 @@ bool hfile::load(void* data, int datasize)
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
-bool hfile::save(void* data, int datasize)
-{
+bool hfile::save(void *data, int datasize) {
// Go Ahead And Open The File For Reading
//----------------------------------------
bool auto_opened = false;
- if (!is_open())
- {
- if (!open_write())
- {
+ if (!is_open()) {
+ if (!open_write()) {
return false;
}
auto_opened = true;
@@ -368,32 +305,26 @@ bool hfile::save(void* data, int datasize)
// Make Sure That The File Is Readable
//-------------------------------------
- SOpenFile& sfile = Pool()[mHandle];
- if (sfile.mForRead)
- {
- assert("HFILE: Unable to save to a file that is opened for read"==0);
- if (auto_opened)
- {
+ SOpenFile &sfile = Pool()[mHandle];
+ if (sfile.mForRead) {
+ assert("HFILE: Unable to save to a file that is opened for read" == 0);
+ if (auto_opened) {
close();
}
return false;
}
-
// Write The Actual Object
//-------------------------
- if (!HFILEwrite(sfile.mHandle, data, datasize))
- {
- assert("HFILE: Unable To Write File Data"==0);
- if (auto_opened)
- {
+ if (!HFILEwrite(sfile.mHandle, data, datasize)) {
+ assert("HFILE: Unable To Write File Data" == 0);
+ if (auto_opened) {
close();
}
return false;
}
- if (auto_opened)
- {
+ if (auto_opened) {
close();
}
return true;
diff --git a/code/Rufl/hstring.cpp b/code/Rufl/hstring.cpp
index 0c328e8cf7..410d5b272b 100644
--- a/code/Rufl/hstring.cpp
+++ b/code/Rufl/hstring.cpp
@@ -36,8 +36,6 @@ along with this program; if not, see .
//
////////////////////////////////////////////////////////////////////////////////////////
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////////////////////////
@@ -46,71 +44,52 @@ along with this program; if not, see .
#include
#include "../Ratl/hash_pool_vs.h"
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////////////////////////
-#define MAX_HASH 16384 // How Many Hash
-#define BLOCK_SIZE 65536 // Size of a string storage block in bytes.
-
-
-
-
-
-
+#define MAX_HASH 16384 // How Many Hash
+#define BLOCK_SIZE 65536 // Size of a string storage block in bytes.
////////////////////////////////////////////////////////////////////////////////////////
// The Hash Pool
////////////////////////////////////////////////////////////////////////////////////////
-typedef ratl::hash_pool TStrPool;
+typedef ratl::hash_pool TStrPool;
-
-static TStrPool& Pool()
-{
+static TStrPool &Pool() {
static TStrPool TSP;
return TSP;
}
-
-
////////////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////////////
-hstring::hstring()
-{
- mHandle = 0;
+hstring::hstring() {
+ mHandle = 0;
#ifdef _DEBUG
- mStr = 0;
+ mStr = 0;
#endif
}
////////////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////////////
-hstring::hstring(const char *str)
-{
- init(str);
-}
+hstring::hstring(const char *str) { init(str); }
////////////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////////////
-hstring::hstring(const hstring &str)
-{
+hstring::hstring(const hstring &str) {
mHandle = str.mHandle;
#ifdef _DEBUG
- mStr = str.mStr;
+ mStr = str.mStr;
#endif
}
-
////////////////////////////////////////////////////////////////////////////////////////
// Assignment
////////////////////////////////////////////////////////////////////////////////////////
-hstring& hstring::operator= (const char *str)
-{
+hstring &hstring::operator=(const char *str) {
init(str);
return *this;
}
@@ -118,81 +97,61 @@ hstring& hstring::operator= (const char *str)
////////////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////////////
-hstring& hstring::operator= (const hstring &str)
-{
+hstring &hstring::operator=(const hstring &str) {
mHandle = str.mHandle;
#ifdef _DEBUG
- mStr = str.mStr;
+ mStr = str.mStr;
#endif
return *this;
}
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-const char* hstring::c_str(void) const
-{
- if (!mHandle)
- {
- return("");
+const char *hstring::c_str(void) const {
+ if (!mHandle) {
+ return ("");
}
- return ((const char*)Pool()[mHandle]);
+ return ((const char *)Pool()[mHandle]);
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-const char* hstring::operator *(void) const
-{
- return c_str();
-}
+const char *hstring::operator*(void) const { return c_str(); }
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
-int hstring::length() const
-{
- return strlen(c_str());
-}
+int hstring::length() const { return strlen(c_str()); }
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
-int hstring::handle() const
-{
- return mHandle;
-}
-
-
+int hstring::handle() const { return mHandle; }
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
-void hstring::init(const char *str)
-{
- if (!str)
- {
+void hstring::init(const char *str) {
+ if (!str) {
mHandle = 0;
+ } else {
+ mHandle = Pool().get_handle(str, strlen(str) + 1); // +1 for null character
}
- else
- {
- mHandle = Pool().get_handle(str, strlen(str)+1); // +1 for null character
- }
- #ifdef _DEBUG
- mStr = (char*)Pool()[mHandle];
- #endif
+#ifdef _DEBUG
+ mStr = (char *)Pool()[mHandle];
+#endif
}
-
////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
-float hstring::ave_collisions() {return Pool().average_collisions();}
-int hstring::total_strings() {return Pool().total_allocs();}
-int hstring::total_bytes() {return Pool().size();}
-int hstring::total_finds() {return Pool().total_finds();}
-int hstring::total_collisions() {return Pool().total_collisions();}
+float hstring::ave_collisions() { return Pool().average_collisions(); }
+int hstring::total_strings() { return Pool().total_allocs(); }
+int hstring::total_bytes() { return Pool().size(); }
+int hstring::total_finds() { return Pool().total_finds(); }
+int hstring::total_collisions() { return Pool().total_collisions(); }
#endif
diff --git a/code/cgame/FX_ATSTMain.cpp b/code/cgame/FX_ATSTMain.cpp
index 04d7ac1227..68aac0b846 100644
--- a/code/cgame/FX_ATSTMain.cpp
+++ b/code/cgame/FX_ATSTMain.cpp
@@ -27,20 +27,16 @@ along with this program; if not, see .
#include "cg_media.h"
#include "FxScheduler.h"
-
/*
---------------------------
FX_ATSTMainProjectileThink
---------------------------
*/
-void FX_ATSTMainProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_ATSTMainProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -48,19 +44,17 @@ void FX_ATSTMainProjectileThink( centity_t *cent, const struct weaponInfo_s *wea
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 30 )
- {
- if ( dif < 0 )
- {
+ if (dif < 30) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 30.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 30.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- theFxScheduler.PlayEffect( "atst/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("atst/shot", cent->lerpOrigin, forward);
}
/*
@@ -68,25 +62,18 @@ void FX_ATSTMainProjectileThink( centity_t *cent, const struct weaponInfo_s *wea
FX_ATSTMainHitWall
---------------------------
*/
-void FX_ATSTMainHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "atst/wall_impact", origin, normal );
-}
+void FX_ATSTMainHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect("atst/wall_impact", origin, normal); }
/*
---------------------------
FX_ATSTMainHitPlayer
---------------------------
*/
-void FX_ATSTMainHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- if ( humanoid )
- {
- theFxScheduler.PlayEffect( "atst/flesh_impact", origin, normal );
- }
- else
- {
- theFxScheduler.PlayEffect( "atst/droid_impact", origin, normal );
+void FX_ATSTMainHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) {
+ if (humanoid) {
+ theFxScheduler.PlayEffect("atst/flesh_impact", origin, normal);
+ } else {
+ theFxScheduler.PlayEffect("atst/droid_impact", origin, normal);
}
}
@@ -95,16 +82,14 @@ void FX_ATSTMainHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
FX_ATSTSideAltProjectileThink
---------------------------
*/
-void FX_ATSTSideAltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_ATSTSideAltProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "atst/side_alt_shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("atst/side_alt_shot", cent->lerpOrigin, forward);
}
/*
@@ -112,14 +97,12 @@ void FX_ATSTSideAltProjectileThink( centity_t *cent, const struct weaponInfo_s *
FX_ATSTSideMainProjectileThink
---------------------------
*/
-void FX_ATSTSideMainProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_ATSTSideMainProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "atst/side_main_shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("atst/side_main_shot", cent->lerpOrigin, forward);
}
diff --git a/code/cgame/FX_Blaster.cpp b/code/cgame/FX_Blaster.cpp
index 840b98594c..28bce37583 100644
--- a/code/cgame/FX_Blaster.cpp
+++ b/code/cgame/FX_Blaster.cpp
@@ -34,20 +34,14 @@ FX_BlasterProjectileThink
-------------------------
*/
-void FX_BlasterProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_BlasterProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if (cent->currentState.eFlags & EF_USE_ANGLEDELTA)
- {
+ if (cent->currentState.eFlags & EF_USE_ANGLEDELTA) {
AngleVectors(cent->currentState.angles, forward, 0, 0);
- }
- else
- {
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ } else {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -56,25 +50,20 @@ void FX_BlasterProjectileThink( centity_t *cent, const struct weaponInfo_s *weap
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- if ( cent->gent && cent->gent->owner && cent->gent->owner->s.number > 0 )
- {
- theFxScheduler.PlayEffect( "blaster/NPCshot", cent->lerpOrigin, forward );
- }
- else
- {
- theFxScheduler.PlayEffect( cgs.effects.blasterShotEffect, cent->lerpOrigin, forward );
+ if (cent->gent && cent->gent->owner && cent->gent->owner->s.number > 0) {
+ theFxScheduler.PlayEffect("blaster/NPCshot", cent->lerpOrigin, forward);
+ } else {
+ theFxScheduler.PlayEffect(cgs.effects.blasterShotEffect, cent->lerpOrigin, forward);
}
}
@@ -83,34 +72,26 @@ void FX_BlasterProjectileThink( centity_t *cent, const struct weaponInfo_s *weap
FX_BlasterAltFireThink
-------------------------
*/
-void FX_BlasterAltFireThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
- FX_BlasterProjectileThink( cent, weapon );
-}
+void FX_BlasterAltFireThink(centity_t *cent, const struct weaponInfo_s *weapon) { FX_BlasterProjectileThink(cent, weapon); }
/*
-------------------------
FX_BlasterWeaponHitWall
-------------------------
*/
-void FX_BlasterWeaponHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( cgs.effects.blasterWallImpactEffect, origin, normal );
-}
+void FX_BlasterWeaponHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect(cgs.effects.blasterWallImpactEffect, origin, normal); }
/*
-------------------------
FX_BlasterWeaponHitPlayer
-------------------------
*/
-void FX_BlasterWeaponHitPlayer( gentity_t *hit, vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- //temporary? just testing out the damage skin stuff -rww
- if ( hit && hit->client && hit->ghoul2.size() )
- {
- CG_AddGhoul2Mark(cgs.media.bdecal_burnmark1, flrand(3.5, 4.0), origin, normal, hit->s.number,
- hit->client->ps.origin, hit->client->renderInfo.legsYaw, hit->ghoul2, hit->s.modelScale, Q_irand(10000, 13000));
+void FX_BlasterWeaponHitPlayer(gentity_t *hit, vec3_t origin, vec3_t normal, qboolean humanoid) {
+ // temporary? just testing out the damage skin stuff -rww
+ if (hit && hit->client && hit->ghoul2.size()) {
+ CG_AddGhoul2Mark(cgs.media.bdecal_burnmark1, flrand(3.5, 4.0), origin, normal, hit->s.number, hit->client->ps.origin, hit->client->renderInfo.legsYaw,
+ hit->ghoul2, hit->s.modelScale, Q_irand(10000, 13000));
}
- theFxScheduler.PlayEffect( cgs.effects.blasterFleshImpactEffect, origin, normal );
+ theFxScheduler.PlayEffect(cgs.effects.blasterFleshImpactEffect, origin, normal);
}
diff --git a/code/cgame/FX_Bowcaster.cpp b/code/cgame/FX_Bowcaster.cpp
index 36f14302b2..8e7483e899 100644
--- a/code/cgame/FX_Bowcaster.cpp
+++ b/code/cgame/FX_Bowcaster.cpp
@@ -33,14 +33,11 @@ FX_BowcasterProjectileThink
---------------------------
*/
-void FX_BowcasterProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_BowcasterProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -48,19 +45,17 @@ void FX_BowcasterProjectileThink( centity_t *cent, const struct weaponInfo_s *we
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- theFxScheduler.PlayEffect( cgs.effects.bowcasterShotEffect, cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect(cgs.effects.bowcasterShotEffect, cent->lerpOrigin, forward);
}
/*
@@ -69,10 +64,7 @@ FX_BowcasterHitWall
---------------------------
*/
-void FX_BowcasterHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( cgs.effects.bowcasterImpactEffect, origin, normal );
-}
+void FX_BowcasterHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect(cgs.effects.bowcasterImpactEffect, origin, normal); }
/*
---------------------------
@@ -80,7 +72,4 @@ FX_BowcasterHitPlayer
---------------------------
*/
-void FX_BowcasterHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( cgs.effects.bowcasterImpactEffect, origin, normal );
-}
+void FX_BowcasterHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) { theFxScheduler.PlayEffect(cgs.effects.bowcasterImpactEffect, origin, normal); }
diff --git a/code/cgame/FX_BryarPistol.cpp b/code/cgame/FX_BryarPistol.cpp
index 8e8fb0af1f..997c60098b 100644
--- a/code/cgame/FX_BryarPistol.cpp
+++ b/code/cgame/FX_BryarPistol.cpp
@@ -36,14 +36,11 @@ along with this program; if not, see .
FX_BryarProjectileThink
-------------------------
*/
-void FX_BryarProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_BryarProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -51,25 +48,20 @@ void FX_BryarProjectileThink( centity_t *cent, const struct weaponInfo_s *weapo
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- if ( cent->gent && cent->gent->owner && cent->gent->owner->s.number > 0 )
- {
- theFxScheduler.PlayEffect( "bryar/NPCshot", cent->lerpOrigin, forward );
- }
- else
- {
- theFxScheduler.PlayEffect( cgs.effects.bryarShotEffect, cent->lerpOrigin, forward );
+ if (cent->gent && cent->gent->owner && cent->gent->owner->s.number > 0) {
+ theFxScheduler.PlayEffect("bryar/NPCshot", cent->lerpOrigin, forward);
+ } else {
+ theFxScheduler.PlayEffect(cgs.effects.bryarShotEffect, cent->lerpOrigin, forward);
}
}
@@ -78,21 +70,14 @@ void FX_BryarProjectileThink( centity_t *cent, const struct weaponInfo_s *weapo
FX_BryarHitWall
-------------------------
*/
-void FX_BryarHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect, origin, normal );
-}
+void FX_BryarHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect(cgs.effects.bryarWallImpactEffect, origin, normal); }
/*
-------------------------
FX_BryarHitPlayer
-------------------------
*/
-void FX_BryarHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( cgs.effects.bryarFleshImpactEffect, origin, normal );
-}
-
+void FX_BryarHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) { theFxScheduler.PlayEffect(cgs.effects.bryarFleshImpactEffect, origin, normal); }
/*
-------------------------
@@ -103,14 +88,11 @@ void FX_BryarHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
FX_BryarAltProjectileThink
-------------------------
*/
-void FX_BryarAltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_BryarAltProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -118,26 +100,23 @@ void FX_BryarAltProjectileThink( centity_t *cent, const struct weaponInfo_s *we
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
// see if we have some sort of extra charge going on
- for ( int t = 1; t < cent->gent->count; t++ )
- {
+ for (int t = 1; t < cent->gent->count; t++) {
// just add ourselves over, and over, and over when we are charged
- theFxScheduler.PlayEffect( cgs.effects.bryarPowerupShotEffect, cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect(cgs.effects.bryarPowerupShotEffect, cent->lerpOrigin, forward);
}
- theFxScheduler.PlayEffect( cgs.effects.bryarShotEffect, cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect(cgs.effects.bryarShotEffect, cent->lerpOrigin, forward);
}
/*
@@ -145,22 +124,20 @@ void FX_BryarAltProjectileThink( centity_t *cent, const struct weaponInfo_s *we
FX_BryarAltHitWall
-------------------------
*/
-void FX_BryarAltHitWall( vec3_t origin, vec3_t normal, int power )
-{
- switch( power )
- {
+void FX_BryarAltHitWall(vec3_t origin, vec3_t normal, int power) {
+ switch (power) {
case 4:
case 5:
- theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect3, origin, normal );
+ theFxScheduler.PlayEffect(cgs.effects.bryarWallImpactEffect3, origin, normal);
break;
case 2:
case 3:
- theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect2, origin, normal );
+ theFxScheduler.PlayEffect(cgs.effects.bryarWallImpactEffect2, origin, normal);
break;
default:
- theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect, origin, normal );
+ theFxScheduler.PlayEffect(cgs.effects.bryarWallImpactEffect, origin, normal);
break;
}
}
@@ -170,7 +147,4 @@ void FX_BryarAltHitWall( vec3_t origin, vec3_t normal, int power )
FX_BryarAltHitPlayer
-------------------------
*/
-void FX_BryarAltHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( cgs.effects.bryarFleshImpactEffect, origin, normal );
-}
+void FX_BryarAltHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) { theFxScheduler.PlayEffect(cgs.effects.bryarFleshImpactEffect, origin, normal); }
diff --git a/code/cgame/FX_Concussion.cpp b/code/cgame/FX_Concussion.cpp
index 91244693d3..5d24f91be0 100644
--- a/code/cgame/FX_Concussion.cpp
+++ b/code/cgame/FX_Concussion.cpp
@@ -33,16 +33,14 @@ FX_ConcProjectileThink
---------------------------
*/
-void FX_ConcProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_ConcProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "concussion/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("concussion/shot", cent->lerpOrigin, forward);
}
/*
@@ -51,10 +49,7 @@ FX_ConcHitWall
---------------------------
*/
-void FX_ConcHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "concussion/explosion", origin, normal );
-}
+void FX_ConcHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect("concussion/explosion", origin, normal); }
/*
---------------------------
@@ -62,57 +57,46 @@ FX_ConcHitPlayer
---------------------------
*/
-void FX_ConcHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( "concussion/explosion", origin, normal );
-}
+void FX_ConcHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) { theFxScheduler.PlayEffect("concussion/explosion", origin, normal); }
/*
---------------------------
FX_ConcAltShot
---------------------------
*/
-static vec3_t WHITE ={1.0f,1.0f,1.0f};
+static vec3_t WHITE = {1.0f, 1.0f, 1.0f};
-void FX_ConcAltShot( vec3_t start, vec3_t end )
-{
+void FX_ConcAltShot(vec3_t start, vec3_t end) {
//"concussion/beam"
- FX_AddLine( -1, start, end, 0.1f, 10.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- WHITE, WHITE, 0.0f,
- 175, cgi_R_RegisterShader( "gfx/effects/blueLine" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
+ FX_AddLine(-1, start, end, 0.1f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, 175, cgi_R_RegisterShader("gfx/effects/blueLine"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
- vec3_t BRIGHT={0.75f,0.5f,1.0f};
+ vec3_t BRIGHT = {0.75f, 0.5f, 1.0f};
// add some beef
- FX_AddLine( -1, start, end, 0.1f, 7.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- BRIGHT, BRIGHT, 0.0f,
- 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
+ FX_AddLine(-1, start, end, 0.1f, 7.0f, 0.0f, 1.0f, 0.0f, 0.0f, BRIGHT, BRIGHT, 0.0f, 150, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
}
-
/*
---------------------------
FX_ConcAltMiss
---------------------------
*/
-void FX_ConcAltMiss( vec3_t origin, vec3_t normal )
-{
+void FX_ConcAltMiss(vec3_t origin, vec3_t normal) {
vec3_t pos, c1, c2;
- VectorMA( origin, 4.0f, normal, c1 );
- VectorCopy( c1, c2 );
+ VectorMA(origin, 4.0f, normal, c1);
+ VectorCopy(c1, c2);
c1[2] += 4;
c2[2] += 12;
- VectorAdd( origin, normal, pos );
+ VectorAdd(origin, normal, pos);
pos[2] += 28;
- FX_AddBezier( origin, pos, c1, vec3_origin, c2, vec3_origin, 6.0f, 6.0f, 0.0f, 0.0f, 0.2f, 0.5f, WHITE, WHITE, 0.0f, 4000, cgi_R_RegisterShader( "gfx/effects/smokeTrail" ), FX_ALPHA_WAVE );
+ FX_AddBezier(origin, pos, c1, vec3_origin, c2, vec3_origin, 6.0f, 6.0f, 0.0f, 0.0f, 0.2f, 0.5f, WHITE, WHITE, 0.0f, 4000,
+ cgi_R_RegisterShader("gfx/effects/smokeTrail"), FX_ALPHA_WAVE);
- theFxScheduler.PlayEffect( "concussion/alt_miss", origin, normal );
+ theFxScheduler.PlayEffect("concussion/alt_miss", origin, normal);
}
diff --git a/code/cgame/FX_DEMP2.cpp b/code/cgame/FX_DEMP2.cpp
index f5430c47ec..e69f839b56 100644
--- a/code/cgame/FX_DEMP2.cpp
+++ b/code/cgame/FX_DEMP2.cpp
@@ -34,18 +34,16 @@ FX_DEMP2_ProjectileThink
---------------------------
*/
-void FX_DEMP2_ProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_DEMP2_ProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
-// theFxScheduler.PlayEffect( "demp2/shot", cent->lerpOrigin, forward );
-// theFxScheduler.PlayEffect( "demp2/shot2", cent->lerpOrigin, forward );
- theFxScheduler.PlayEffect( "demp2/projectile", cent->lerpOrigin, forward );
+ // theFxScheduler.PlayEffect( "demp2/shot", cent->lerpOrigin, forward );
+ // theFxScheduler.PlayEffect( "demp2/shot2", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("demp2/projectile", cent->lerpOrigin, forward);
}
/*
@@ -54,10 +52,7 @@ FX_DEMP2_HitWall
---------------------------
*/
-void FX_DEMP2_HitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "demp2/wall_impact", origin, normal );
-}
+void FX_DEMP2_HitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect("demp2/wall_impact", origin, normal); }
/*
---------------------------
@@ -65,10 +60,7 @@ FX_DEMP2_HitPlayer
---------------------------
*/
-void FX_DEMP2_HitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( "demp2/flesh_impact", origin, normal );
-}
+void FX_DEMP2_HitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) { theFxScheduler.PlayEffect("demp2/flesh_impact", origin, normal); }
/*
---------------------------
@@ -76,26 +68,23 @@ FX_DEMP2_AltProjectileThink
---------------------------
*/
-void FX_DEMP2_AltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_DEMP2_AltProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "demp2/projectile", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("demp2/projectile", cent->lerpOrigin, forward);
}
//---------------------------------------------
-void FX_DEMP2_AltDetonate( vec3_t org, float size )
-{
- localEntity_t *ex;
+void FX_DEMP2_AltDetonate(vec3_t org, float size) {
+ localEntity_t *ex;
ex = CG_AllocLocalEntity();
ex->leType = LE_FADE_SCALE_MODEL;
- memset( &ex->refEntity, 0, sizeof( refEntity_t ));
+ memset(&ex->refEntity, 0, sizeof(refEntity_t));
ex->refEntity.renderfx |= RF_VOLUMETRIC;
@@ -103,10 +92,10 @@ void FX_DEMP2_AltDetonate( vec3_t org, float size )
ex->endTime = ex->startTime + 1300;
ex->radius = size;
- ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/effects/demp2shell" );
+ ex->refEntity.customShader = cgi_R_RegisterShader("gfx/effects/demp2shell");
- ex->refEntity.hModel = cgi_R_RegisterModel( "models/items/sphere.md3" );
- VectorCopy( org, ex->refEntity.origin );
+ ex->refEntity.hModel = cgi_R_RegisterModel("models/items/sphere.md3");
+ VectorCopy(org, ex->refEntity.origin);
ex->color[0] = ex->color[1] = ex->color[2] = 255.0f;
}
diff --git a/code/cgame/FX_Disruptor.cpp b/code/cgame/FX_Disruptor.cpp
index 33881f2b0f..ec26634ade 100644
--- a/code/cgame/FX_Disruptor.cpp
+++ b/code/cgame/FX_Disruptor.cpp
@@ -27,47 +27,33 @@ along with this program; if not, see .
#include "cg_media.h"
#include "FxScheduler.h"
-
/*
---------------------------
FX_DisruptorMainShot
---------------------------
*/
-static vec3_t WHITE ={1.0f,1.0f,1.0f};
-
-void FX_DisruptorMainShot( vec3_t start, vec3_t end )
-{
- FX_AddLine( -1, start, end, 0.1f, 4.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- WHITE, WHITE, 0.0f,
- 120, cgi_R_RegisterShader( "gfx/effects/redLine" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
-}
+static vec3_t WHITE = {1.0f, 1.0f, 1.0f};
+void FX_DisruptorMainShot(vec3_t start, vec3_t end) {
+ FX_AddLine(-1, start, end, 0.1f, 4.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, 120, cgi_R_RegisterShader("gfx/effects/redLine"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
+}
/*
---------------------------
FX_DisruptorAltShot
---------------------------
*/
-void FX_DisruptorAltShot( vec3_t start, vec3_t end, qboolean fullCharge )
-{
- FX_AddLine( -1, start, end, 0.1f, 10.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- WHITE, WHITE, 0.0f,
- 175, cgi_R_RegisterShader( "gfx/effects/redLine" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
-
- if ( fullCharge )
- {
- vec3_t YELLER={0.8f,0.7f,0.0f};
+void FX_DisruptorAltShot(vec3_t start, vec3_t end, qboolean fullCharge) {
+ FX_AddLine(-1, start, end, 0.1f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, 175, cgi_R_RegisterShader("gfx/effects/redLine"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
+
+ if (fullCharge) {
+ vec3_t YELLER = {0.8f, 0.7f, 0.0f};
// add some beef
- FX_AddLine( -1, start, end, 0.1f, 7.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- YELLER, YELLER, 0.0f,
- 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
+ FX_AddLine(-1, start, end, 0.1f, 7.0f, 0.0f, 1.0f, 0.0f, 0.0f, YELLER, YELLER, 0.0f, 150, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
}
}
@@ -77,21 +63,21 @@ FX_DisruptorAltMiss
---------------------------
*/
-void FX_DisruptorAltMiss( vec3_t origin, vec3_t normal )
-{
+void FX_DisruptorAltMiss(vec3_t origin, vec3_t normal) {
vec3_t pos, c1, c2;
- VectorMA( origin, 4.0f, normal, c1 );
- VectorCopy( c1, c2 );
+ VectorMA(origin, 4.0f, normal, c1);
+ VectorCopy(c1, c2);
c1[2] += 4;
c2[2] += 12;
- VectorAdd( origin, normal, pos );
+ VectorAdd(origin, normal, pos);
pos[2] += 28;
- FX_AddBezier( origin, pos, c1, vec3_origin, c2, vec3_origin, 6.0f, 6.0f, 0.0f, 0.0f, 0.2f, 0.5f, WHITE, WHITE, 0.0f, 4000, cgi_R_RegisterShader( "gfx/effects/smokeTrail" ), FX_ALPHA_WAVE );
+ FX_AddBezier(origin, pos, c1, vec3_origin, c2, vec3_origin, 6.0f, 6.0f, 0.0f, 0.0f, 0.2f, 0.5f, WHITE, WHITE, 0.0f, 4000,
+ cgi_R_RegisterShader("gfx/effects/smokeTrail"), FX_ALPHA_WAVE);
- theFxScheduler.PlayEffect( "disruptor/alt_miss", origin, normal );
+ theFxScheduler.PlayEffect("disruptor/alt_miss", origin, normal);
}
/*
@@ -99,20 +85,13 @@ void FX_DisruptorAltMiss( vec3_t origin, vec3_t normal )
FX_KothosBeam
---------------------------
*/
-void FX_KothosBeam( vec3_t start, vec3_t end )
-{
- FX_AddLine( -1, start, end, 0.1f, 10.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- WHITE, WHITE, 0.0f,
- 175, cgi_R_RegisterShader( "gfx/misc/dr1" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
+void FX_KothosBeam(vec3_t start, vec3_t end) {
+ FX_AddLine(-1, start, end, 0.1f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, 175, cgi_R_RegisterShader("gfx/misc/dr1"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
- vec3_t YELLER={0.8f,0.7f,0.0f};
+ vec3_t YELLER = {0.8f, 0.7f, 0.0f};
// add some beef
- FX_AddLine( -1, start, end, 0.1f, 7.0f, 0.0f,
- 1.0f, 0.0f, 0.0f,
- YELLER, YELLER, 0.0f,
- 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ),
- 0, FX_SIZE_LINEAR | FX_ALPHA_LINEAR );
+ FX_AddLine(-1, start, end, 0.1f, 7.0f, 0.0f, 1.0f, 0.0f, 0.0f, YELLER, YELLER, 0.0f, 150, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0,
+ FX_SIZE_LINEAR | FX_ALPHA_LINEAR);
}
diff --git a/code/cgame/FX_Emplaced.cpp b/code/cgame/FX_Emplaced.cpp
index 5d24e9fd65..feef3e239d 100644
--- a/code/cgame/FX_Emplaced.cpp
+++ b/code/cgame/FX_Emplaced.cpp
@@ -33,14 +33,11 @@ FX_EmplacedProjectileThink
---------------------------
*/
-void FX_EmplacedProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_EmplacedProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -48,47 +45,33 @@ void FX_EmplacedProjectileThink( centity_t *cent, const struct weaponInfo_s *wea
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
// If tie-fighter missle use green shot.
- if ( cent->currentState.weapon == WP_TIE_FIGHTER )
- {
- theFxScheduler.PlayEffect( "ships/imp_blastershot", cent->lerpOrigin, forward );
- }
- else
- {
- if ( cent->gent && cent->gent->owner && cent->gent->owner->activator && cent->gent->owner->activator->s.number > 0 )
- {
+ if (cent->currentState.weapon == WP_TIE_FIGHTER) {
+ theFxScheduler.PlayEffect("ships/imp_blastershot", cent->lerpOrigin, forward);
+ } else {
+ if (cent->gent && cent->gent->owner && cent->gent->owner->activator && cent->gent->owner->activator->s.number > 0) {
// NPC's do short shot
- if ( cent->gent->alt_fire )
- {
- theFxScheduler.PlayEffect( "eweb/shotNPC", cent->lerpOrigin, forward );
- }
- else
- {
- theFxScheduler.PlayEffect( "emplaced/shotNPC", cent->lerpOrigin, forward );
+ if (cent->gent->alt_fire) {
+ theFxScheduler.PlayEffect("eweb/shotNPC", cent->lerpOrigin, forward);
+ } else {
+ theFxScheduler.PlayEffect("emplaced/shotNPC", cent->lerpOrigin, forward);
}
- }
- else
- {
+ } else {
// players do long shot
- if ( cent->gent && cent->gent->alt_fire )
- {
- theFxScheduler.PlayEffect( "eweb/shotNPC", cent->lerpOrigin, forward );
- }
- else
- {
- theFxScheduler.PlayEffect( "emplaced/shot", cent->lerpOrigin, forward );
+ if (cent->gent && cent->gent->alt_fire) {
+ theFxScheduler.PlayEffect("eweb/shotNPC", cent->lerpOrigin, forward);
+ } else {
+ theFxScheduler.PlayEffect("emplaced/shot", cent->lerpOrigin, forward);
}
}
}
@@ -100,15 +83,11 @@ FX_EmplacedHitWall
---------------------------
*/
-void FX_EmplacedHitWall( vec3_t origin, vec3_t normal, qboolean eweb )
-{
- if ( eweb )
- {
- theFxScheduler.PlayEffect( "eweb/wall_impact", origin, normal );
- }
- else
- {
- theFxScheduler.PlayEffect( "emplaced/wall_impact", origin, normal );
+void FX_EmplacedHitWall(vec3_t origin, vec3_t normal, qboolean eweb) {
+ if (eweb) {
+ theFxScheduler.PlayEffect("eweb/wall_impact", origin, normal);
+ } else {
+ theFxScheduler.PlayEffect("emplaced/wall_impact", origin, normal);
}
}
@@ -118,15 +97,11 @@ FX_EmplacedHitPlayer
---------------------------
*/
-void FX_EmplacedHitPlayer( vec3_t origin, vec3_t normal, qboolean eweb )
-{
- if ( eweb )
- {
- theFxScheduler.PlayEffect( "eweb/flesh_impact", origin, normal );
- }
- else
- {
- theFxScheduler.PlayEffect( "emplaced/wall_impact", origin, normal );
+void FX_EmplacedHitPlayer(vec3_t origin, vec3_t normal, qboolean eweb) {
+ if (eweb) {
+ theFxScheduler.PlayEffect("eweb/flesh_impact", origin, normal);
+ } else {
+ theFxScheduler.PlayEffect("emplaced/wall_impact", origin, normal);
}
}
/*
@@ -135,14 +110,11 @@ FX_TurretProjectileThink
---------------------------
*/
-void FX_TurretProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_TurretProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -150,17 +122,15 @@ void FX_TurretProjectileThink( centity_t *cent, const struct weaponInfo_s *weapo
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- theFxScheduler.PlayEffect( "turret/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("turret/shot", cent->lerpOrigin, forward);
}
diff --git a/code/cgame/FX_Flechette.cpp b/code/cgame/FX_Flechette.cpp
index 424418704d..eca4afe79e 100644
--- a/code/cgame/FX_Flechette.cpp
+++ b/code/cgame/FX_Flechette.cpp
@@ -33,18 +33,16 @@ FX_FlechetteProjectileThink
-------------------------
*/
-void FX_FlechetteProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_FlechetteProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- EvaluateTrajectoryDelta( ¢->gent->s.pos, cg.time, forward );
+ EvaluateTrajectoryDelta(¢->gent->s.pos, cg.time, forward);
- if ( VectorNormalize( forward ) == 0.0f )
- {
+ if (VectorNormalize(forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( cgs.effects.flechetteShotEffect, cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect(cgs.effects.flechetteShotEffect, cent->lerpOrigin, forward);
}
/*
@@ -52,26 +50,22 @@ void FX_FlechetteProjectileThink( centity_t *cent, const struct weaponInfo_s *we
FX_FlechetteWeaponHitWall
-------------------------
*/
-void FX_FlechetteWeaponHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( cgs.effects.flechetteShotDeathEffect, origin, normal );
-}
+void FX_FlechetteWeaponHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect(cgs.effects.flechetteShotDeathEffect, origin, normal); }
/*
-------------------------
FX_BlasterWeaponHitPlayer
-------------------------
*/
-void FX_FlechetteWeaponHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
-// if ( humanoid )
-// {
- theFxScheduler.PlayEffect( cgs.effects.flechetteFleshImpactEffect, origin, normal );
-// }
-// else
-// {
-// theFxScheduler.PlayEffect( "blaster/droid_impact", origin, normal );
-// }
+void FX_FlechetteWeaponHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) {
+ // if ( humanoid )
+ // {
+ theFxScheduler.PlayEffect(cgs.effects.flechetteFleshImpactEffect, origin, normal);
+ // }
+ // else
+ // {
+ // theFxScheduler.PlayEffect( "blaster/droid_impact", origin, normal );
+ // }
}
/*
@@ -80,14 +74,12 @@ FX_FlechetteProjectileThink
-------------------------
*/
-void FX_FlechetteAltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_FlechetteAltProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( cgs.effects.flechetteAltShotEffect, cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect(cgs.effects.flechetteAltShotEffect, cent->lerpOrigin, forward);
}
diff --git a/code/cgame/FX_HeavyRepeater.cpp b/code/cgame/FX_HeavyRepeater.cpp
index 4c1e758506..96f02ad921 100644
--- a/code/cgame/FX_HeavyRepeater.cpp
+++ b/code/cgame/FX_HeavyRepeater.cpp
@@ -33,16 +33,14 @@ FX_RepeaterProjectileThink
---------------------------
*/
-void FX_RepeaterProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_RepeaterProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "repeater/projectile", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("repeater/projectile", cent->lerpOrigin, forward);
}
/*
@@ -51,10 +49,7 @@ FX_RepeaterHitWall
------------------------
*/
-void FX_RepeaterHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "repeater/wall_impact", origin, normal );
-}
+void FX_RepeaterHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect("repeater/wall_impact", origin, normal); }
/*
------------------------
@@ -62,10 +57,9 @@ FX_RepeaterHitPlayer
------------------------
*/
-void FX_RepeaterHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( "repeater/wall_impact", origin, normal );
-// theFxScheduler.PlayEffect( "repeater/flesh_impact", origin, normal );
+void FX_RepeaterHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) {
+ theFxScheduler.PlayEffect("repeater/wall_impact", origin, normal);
+ // theFxScheduler.PlayEffect( "repeater/flesh_impact", origin, normal );
}
/*
@@ -74,17 +68,15 @@ FX_RepeaterAltProjectileThink
-----------------------------
*/
-void FX_RepeaterAltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_RepeaterAltProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "repeater/alt_projectile", cent->lerpOrigin, forward );
-// theFxScheduler.PlayEffect( "repeater/alt_projectile", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("repeater/alt_projectile", cent->lerpOrigin, forward);
+ // theFxScheduler.PlayEffect( "repeater/alt_projectile", cent->lerpOrigin, forward );
}
/*
@@ -93,10 +85,9 @@ FX_RepeaterAltHitWall
------------------------
*/
-void FX_RepeaterAltHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "repeater/concussion", origin, normal );
-// theFxScheduler.PlayEffect( "repeater/alt_wall_impact2", origin, normal );
+void FX_RepeaterAltHitWall(vec3_t origin, vec3_t normal) {
+ theFxScheduler.PlayEffect("repeater/concussion", origin, normal);
+ // theFxScheduler.PlayEffect( "repeater/alt_wall_impact2", origin, normal );
}
/*
@@ -105,8 +96,7 @@ FX_RepeaterAltHitPlayer
------------------------
*/
-void FX_RepeaterAltHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( "repeater/concussion", origin );
-// theFxScheduler.PlayEffect( "repeater/alt_wall_impact2", origin, normal );
+void FX_RepeaterAltHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) {
+ theFxScheduler.PlayEffect("repeater/concussion", origin);
+ // theFxScheduler.PlayEffect( "repeater/alt_wall_impact2", origin, normal );
}
diff --git a/code/cgame/FX_NoghriShot.cpp b/code/cgame/FX_NoghriShot.cpp
index 8f8a07de68..604d17bab7 100644
--- a/code/cgame/FX_NoghriShot.cpp
+++ b/code/cgame/FX_NoghriShot.cpp
@@ -34,14 +34,11 @@ FX_NoghriShotProjectileThink
-------------------------
*/
-void FX_NoghriShotProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_NoghriShotProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -49,19 +46,17 @@ void FX_NoghriShotProjectileThink( centity_t *cent, const struct weaponInfo_s *w
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- theFxScheduler.PlayEffect( "noghri_stick/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("noghri_stick/shot", cent->lerpOrigin, forward);
}
/*
@@ -69,18 +64,16 @@ void FX_NoghriShotProjectileThink( centity_t *cent, const struct weaponInfo_s *w
FX_NoghriShotWeaponHitWall
-------------------------
*/
-void FX_NoghriShotWeaponHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "noghri_stick/flesh_impact", origin, normal );//no "noghri/wall_impact"?
+void FX_NoghriShotWeaponHitWall(vec3_t origin, vec3_t normal) {
+ theFxScheduler.PlayEffect("noghri_stick/flesh_impact", origin, normal); // no "noghri/wall_impact"?
}
/*
-------------------------
FX_NoghriShotWeaponHitPlayer
-------------------------
*/
-void FX_NoghriShotWeaponHitPlayer( gentity_t *hit, vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- //temporary? just testing out the damage skin stuff -rww
+void FX_NoghriShotWeaponHitPlayer(gentity_t *hit, vec3_t origin, vec3_t normal, qboolean humanoid) {
+ // temporary? just testing out the damage skin stuff -rww
/*
if ( hit && hit->client && hit->ghoul2.size() )
{
@@ -89,5 +82,5 @@ void FX_NoghriShotWeaponHitPlayer( gentity_t *hit, vec3_t origin, vec3_t normal,
}
*/
- theFxScheduler.PlayEffect( "noghri_stick/flesh_impact", origin, normal );
+ theFxScheduler.PlayEffect("noghri_stick/flesh_impact", origin, normal);
}
diff --git a/code/cgame/FX_RocketLauncher.cpp b/code/cgame/FX_RocketLauncher.cpp
index 4b4ce4a380..1eec8912c2 100644
--- a/code/cgame/FX_RocketLauncher.cpp
+++ b/code/cgame/FX_RocketLauncher.cpp
@@ -32,16 +32,14 @@ FX_RocketProjectileThink
---------------------------
*/
-void FX_RocketProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_RocketProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "rocket/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("rocket/shot", cent->lerpOrigin, forward);
}
/*
@@ -50,10 +48,7 @@ FX_RocketHitWall
---------------------------
*/
-void FX_RocketHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "rocket/explosion", origin, normal );
-}
+void FX_RocketHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect("rocket/explosion", origin, normal); }
/*
---------------------------
@@ -61,10 +56,7 @@ FX_RocketHitPlayer
---------------------------
*/
-void FX_RocketHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- theFxScheduler.PlayEffect( "rocket/explosion", origin, normal );
-}
+void FX_RocketHitPlayer(vec3_t origin, vec3_t normal, qboolean humanoid) { theFxScheduler.PlayEffect("rocket/explosion", origin, normal); }
/*
---------------------------
@@ -72,14 +64,12 @@ FX_RocketAltProjectileThink
---------------------------
*/
-void FX_RocketAltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_RocketAltProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
- theFxScheduler.PlayEffect( "rocket/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("rocket/shot", cent->lerpOrigin, forward);
}
diff --git a/code/cgame/FX_TuskenShot.cpp b/code/cgame/FX_TuskenShot.cpp
index 68be530623..6688d5cd9d 100644
--- a/code/cgame/FX_TuskenShot.cpp
+++ b/code/cgame/FX_TuskenShot.cpp
@@ -34,14 +34,11 @@ FX_TuskenShotProjectileThink
-------------------------
*/
-void FX_TuskenShotProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
-{
+void FX_TuskenShotProjectileThink(centity_t *cent, const struct weaponInfo_s *weapon) {
vec3_t forward;
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
- {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(cent->currentState.pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
@@ -49,19 +46,17 @@ void FX_TuskenShotProjectileThink( centity_t *cent, const struct weaponInfo_s *w
// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
- theFxScheduler.PlayEffect( "tusken/shot", cent->lerpOrigin, forward );
+ theFxScheduler.PlayEffect("tusken/shot", cent->lerpOrigin, forward);
}
/*
@@ -69,23 +64,18 @@ void FX_TuskenShotProjectileThink( centity_t *cent, const struct weaponInfo_s *w
FX_TuskenShotWeaponHitWall
-------------------------
*/
-void FX_TuskenShotWeaponHitWall( vec3_t origin, vec3_t normal )
-{
- theFxScheduler.PlayEffect( "tusken/hitwall", origin, normal );
-}
+void FX_TuskenShotWeaponHitWall(vec3_t origin, vec3_t normal) { theFxScheduler.PlayEffect("tusken/hitwall", origin, normal); }
/*
-------------------------
FX_TuskenShotWeaponHitPlayer
-------------------------
*/
-void FX_TuskenShotWeaponHitPlayer( gentity_t *hit, vec3_t origin, vec3_t normal, qboolean humanoid )
-{
- //temporary? just testing out the damage skin stuff -rww
- if ( hit && hit->client && hit->ghoul2.size() )
- {
- CG_AddGhoul2Mark(cgs.media.bdecal_burnmark1, flrand(3.5, 4.0), origin, normal, hit->s.number,
- hit->client->ps.origin, hit->client->renderInfo.legsYaw, hit->ghoul2, hit->s.modelScale, Q_irand(10000, 13000));
+void FX_TuskenShotWeaponHitPlayer(gentity_t *hit, vec3_t origin, vec3_t normal, qboolean humanoid) {
+ // temporary? just testing out the damage skin stuff -rww
+ if (hit && hit->client && hit->ghoul2.size()) {
+ CG_AddGhoul2Mark(cgs.media.bdecal_burnmark1, flrand(3.5, 4.0), origin, normal, hit->s.number, hit->client->ps.origin, hit->client->renderInfo.legsYaw,
+ hit->ghoul2, hit->s.modelScale, Q_irand(10000, 13000));
}
- theFxScheduler.PlayEffect( "tusken/hit", origin, normal );
+ theFxScheduler.PlayEffect("tusken/hit", origin, normal);
}
diff --git a/code/cgame/FxPrimitives.cpp b/code/cgame/FxPrimitives.cpp
index 74dc874a88..337e155c31 100644
--- a/code/cgame/FxPrimitives.cpp
+++ b/code/cgame/FxPrimitives.cpp
@@ -23,7 +23,7 @@ along with this program; if not, see .
#include "common_headers.h"
#if !defined(FX_SCHEDULER_H_INC)
- #include "FxScheduler.h"
+#include "FxScheduler.h"
#endif
#include "cg_media.h"
@@ -34,25 +34,20 @@ extern int mOParticles;
extern int mLines;
extern int mTails;
-extern vmCvar_t fx_expensivePhysics;
+extern vmCvar_t fx_expensivePhysics;
// Helper function
//-------------------------
-void ClampVec( vec3_t dat, byte *res )
-{
+void ClampVec(vec3_t dat, byte *res) {
int r;
// clamp all vec values, then multiply the normalized values by 255 to maximize the result
- for ( int i = 0; i < 3; i++ )
- {
+ for (int i = 0; i < 3; i++) {
r = Q_ftol(dat[i] * 255.0f);
- if ( r < 0 )
- {
+ if (r < 0) {
r = 0;
- }
- else if ( r > 255 )
- {
+ } else if (r > 255) {
r = 255;
}
@@ -60,28 +55,22 @@ void ClampVec( vec3_t dat, byte *res )
}
}
-void GetOrigin( int clientID, vec3_t org )
-{
- if ( clientID >=0 )
- {
+void GetOrigin(int clientID, vec3_t org) {
+ if (clientID >= 0) {
centity_t *cent = &cg_entities[clientID];
- if ( cent && cent->gent && cent->gent->client )
- {
- VectorCopy( cent->gent->client->renderInfo.muzzlePoint, org );
+ if (cent && cent->gent && cent->gent->client) {
+ VectorCopy(cent->gent->client->renderInfo.muzzlePoint, org);
}
}
}
-void GetDir( int clientID, vec3_t org )
-{
- if ( clientID >=0 )
- {
+void GetDir(int clientID, vec3_t org) {
+ if (clientID >= 0) {
centity_t *cent = &cg_entities[clientID];
- if ( cent && cent->gent && cent->gent->client )
- {
- VectorCopy( cent->gent->client->renderInfo.muzzleDir, org );
+ if (cent && cent->gent && cent->gent->client) {
+ VectorCopy(cent->gent->client->renderInfo.muzzleDir, org);
}
}
}
@@ -92,46 +81,40 @@ void GetDir( int clientID, vec3_t org )
//
//--------------------------
-
//--------------------------
//
// Derived Particle Class
//
//--------------------------
-void CParticle::Die()
-{
- if ( mFlags & FX_DEATH_RUNS_FX && !(mFlags & FX_KILL_ON_IMPACT) )
- {
- vec3_t norm;
+void CParticle::Die() {
+ if (mFlags & FX_DEATH_RUNS_FX && !(mFlags & FX_KILL_ON_IMPACT)) {
+ vec3_t norm;
// Man, this just seems so, like, uncool and stuff...
- VectorSet( norm, Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f));
- VectorNormalize( norm );
+ VectorSet(norm, Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f));
+ VectorNormalize(norm);
- theFxScheduler.PlayEffect( mDeathFxID, mOrigin1, norm );
+ theFxScheduler.PlayEffect(mDeathFxID, mOrigin1, norm);
}
}
//----------------------------
-bool CParticle::Cull()
-{
- vec3_t dir;
+bool CParticle::Cull() {
+ vec3_t dir;
// Get the direction to the view
- VectorSubtract( mOrigin1, cg.refdef.vieworg, dir );
+ VectorSubtract(mOrigin1, cg.refdef.vieworg, dir);
// Check if it's behind the viewer
- if ( (DotProduct( cg.refdef.viewaxis[0], dir )) < 0 )
- {
+ if ((DotProduct(cg.refdef.viewaxis[0], dir)) < 0) {
return true;
}
- float len = VectorLengthSquared( dir );
+ float len = VectorLengthSquared(dir);
// Can't be too close
- if ( len < 16 * 16 )
- {
+ if (len < 16 * 16) {
return true;
}
@@ -139,17 +122,15 @@ bool CParticle::Cull()
}
//----------------------------
-void CParticle::Draw()
-{
- if ( mFlags & FX_DEPTH_HACK )
- {
+void CParticle::Draw() {
+ if (mFlags & FX_DEPTH_HACK) {
// Not sure if first person needs to be set, but it can't hurt?
mRefEnt.renderfx |= RF_DEPTHHACK;
}
// Add our refEntity to the scene
- VectorCopy( mOrigin1, mRefEnt.origin );
- theFxHelper.AddFxToScene( &mRefEnt );
+ VectorCopy(mOrigin1, mRefEnt.origin);
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
mParticles++;
@@ -158,80 +139,69 @@ void CParticle::Draw()
//----------------------------
// Update
//----------------------------
-bool CParticle::Update()
-{
+bool CParticle::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- if ( mFlags & FX_RELATIVE )
- {
- if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
- { // we are somehow not bolted even though the flag is on?
+ if (mFlags & FX_RELATIVE) {
+ if (mClientID < 0 || mClientID >= ENTITYNUM_WORLD) { // we are somehow not bolted even though the flag is on?
return false;
}
- vec3_t org;
- vec3_t ax[3];
+ vec3_t org;
+ vec3_t ax[3];
// Get our current position and direction
- if (mModelNum>=0 && mBoltNum>=0) //bolt style
+ if (mModelNum >= 0 && mBoltNum >= 0) // bolt style
{
const centity_t ¢ = cg_entities[mClientID];
- if (!cent.gent->ghoul2.IsValid())
- {
+ if (!cent.gent->ghoul2.IsValid()) {
return false;
}
- if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, org, ax))
- { //could not get bolt
+ if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, org, ax)) { // could not get bolt
return false;
}
- }
- else
- {//fixme change this to bolt style...
+ } else { // fixme change this to bolt style...
vec3_t dir, ang;
- GetOrigin( mClientID, org );
- GetDir( mClientID, dir );
+ GetOrigin(mClientID, org);
+ GetDir(mClientID, dir);
- vectoangles( dir, ang );
- AngleVectors( ang, ax[0], ax[1], ax[2] );
+ vectoangles(dir, ang);
+ AngleVectors(ang, ax[0], ax[1], ax[2]);
}
- vec3_t realVel, realAccel;
+ vec3_t realVel, realAccel;
- VectorMA( org, mOrgOffset[0], ax[0], org );
- VectorMA( org, mOrgOffset[1], ax[1], org );
- VectorMA( org, mOrgOffset[2], ax[2], org );
+ VectorMA(org, mOrgOffset[0], ax[0], org);
+ VectorMA(org, mOrgOffset[1], ax[1], org);
+ VectorMA(org, mOrgOffset[2], ax[2], org);
- const float time = (theFxHelper.mTime - mTimeStart) * 0.001f;
+ const float time = (theFxHelper.mTime - mTimeStart) * 0.001f;
// calc the real velocity and accel vectors
- VectorScale( ax[0], mVel[0], realVel );
- VectorMA( realVel, mVel[1], ax[1], realVel );
- VectorMA( realVel, mVel[2], ax[2], realVel );
+ VectorScale(ax[0], mVel[0], realVel);
+ VectorMA(realVel, mVel[1], ax[1], realVel);
+ VectorMA(realVel, mVel[2], ax[2], realVel);
realVel[2] += 0.5f * mGravity * time;
- VectorScale( ax[0], mAccel[0], realAccel );
- VectorMA( realAccel, mAccel[1], ax[1], realAccel );
- VectorMA( realAccel, mAccel[2], ax[2], realAccel );
+ VectorScale(ax[0], mAccel[0], realAccel);
+ VectorMA(realAccel, mAccel[1], ax[1], realAccel);
+ VectorMA(realAccel, mAccel[2], ax[2], realAccel);
// Get our real velocity at the current time, taking into account the effects of acceleartion. NOTE: not sure if this is even 100% correct math-wise
- VectorMA( realVel, time, realAccel, realVel );
+ VectorMA(realVel, time, realAccel, realVel);
// Now move us to where we should be at the given time
- VectorMA( org, time, realVel, mOrigin1 );
+ VectorMA(org, time, realVel, mOrigin1);
- }
- else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
- {
+ } else if ((mTimeStart < theFxHelper.mTime) && UpdateOrigin() == false) {
// we are marked for death
return false;
}
- if ( !Cull())
- {
+ if (!Cull()) {
UpdateSize();
UpdateRGB();
UpdateAlpha();
@@ -246,111 +216,89 @@ bool CParticle::Update()
//----------------------------
// Update Origin
//----------------------------
-bool CParticle::UpdateOrigin()
-{
- vec3_t new_origin;
-// float ftime, time2;
+bool CParticle::UpdateOrigin() {
+ vec3_t new_origin;
+ // float ftime, time2;
UpdateVelocity();
// Calc the time differences
-// ftime = theFxHelper.mFrameTime * 0.001f;
- //time2 = ftime * ftime * 0.5f;
-// time2=0;
+ // ftime = theFxHelper.mFrameTime * 0.001f;
+ // time2 = ftime * ftime * 0.5f;
+ // time2=0;
// Predict the new position
- new_origin[0] = mOrigin1[0] + theFxHelper.mFloatFrameTime * mVel[0];// + time2 * mVel[0];
- new_origin[1] = mOrigin1[1] + theFxHelper.mFloatFrameTime * mVel[1];// + time2 * mVel[1];
- new_origin[2] = mOrigin1[2] + theFxHelper.mFloatFrameTime * mVel[2];// + time2 * mVel[2];
+ new_origin[0] = mOrigin1[0] + theFxHelper.mFloatFrameTime * mVel[0]; // + time2 * mVel[0];
+ new_origin[1] = mOrigin1[1] + theFxHelper.mFloatFrameTime * mVel[1]; // + time2 * mVel[1];
+ new_origin[2] = mOrigin1[2] + theFxHelper.mFloatFrameTime * mVel[2]; // + time2 * mVel[2];
// Only perform physics if this object is tagged to do so
- if ( (mFlags & FX_APPLY_PHYSICS) )
- {
+ if ((mFlags & FX_APPLY_PHYSICS)) {
bool solid;
- if ( (mFlags&FX_EXPENSIVE_PHYSICS)
- && fx_expensivePhysics.integer )
- {
+ if ((mFlags & FX_EXPENSIVE_PHYSICS) && fx_expensivePhysics.integer) {
solid = true; // by setting this to true, we force a real trace to happen
- }
- else
- {
+ } else {
// if this returns solid, we need to do a trace
- solid = !!(CG_PointContents( new_origin, ENTITYNUM_WORLD ) & ( MASK_SHOT | CONTENTS_WATER ));
+ solid = !!(CG_PointContents(new_origin, ENTITYNUM_WORLD) & (MASK_SHOT | CONTENTS_WATER));
}
- if ( solid )
- {
- trace_t trace;
- float dot;
-
- if ( mFlags & FX_USE_BBOX )
- {
- if (mFlags & FX_GHOUL2_TRACE)
- {
- theFxHelper.G2Trace( &trace, mOrigin1, mMin, mMax, new_origin, ENTITYNUM_NONE, ( MASK_SHOT | CONTENTS_WATER ) );
- }
- else
- {
- theFxHelper.Trace( &trace, mOrigin1, mMin, mMax, new_origin, -1, ( MASK_SHOT | CONTENTS_WATER ) );
- }
- }
- else
- {
- if (mFlags & FX_GHOUL2_TRACE)
- {
- theFxHelper.G2Trace( &trace, mOrigin1, NULL, NULL, new_origin, ENTITYNUM_NONE, ( MASK_SHOT | CONTENTS_WATER ) );
+ if (solid) {
+ trace_t trace;
+ float dot;
+
+ if (mFlags & FX_USE_BBOX) {
+ if (mFlags & FX_GHOUL2_TRACE) {
+ theFxHelper.G2Trace(&trace, mOrigin1, mMin, mMax, new_origin, ENTITYNUM_NONE, (MASK_SHOT | CONTENTS_WATER));
+ } else {
+ theFxHelper.Trace(&trace, mOrigin1, mMin, mMax, new_origin, -1, (MASK_SHOT | CONTENTS_WATER));
}
- else
- {
- theFxHelper.Trace( &trace, mOrigin1, NULL, NULL, new_origin, -1, ( MASK_SHOT | CONTENTS_WATER ) );
+ } else {
+ if (mFlags & FX_GHOUL2_TRACE) {
+ theFxHelper.G2Trace(&trace, mOrigin1, NULL, NULL, new_origin, ENTITYNUM_NONE, (MASK_SHOT | CONTENTS_WATER));
+ } else {
+ theFxHelper.Trace(&trace, mOrigin1, NULL, NULL, new_origin, -1, (MASK_SHOT | CONTENTS_WATER));
}
}
- if ( trace.startsolid || trace.allsolid || trace.fraction == 1.0)
- {
- }
- else
- {
+ if (trace.startsolid || trace.allsolid || trace.fraction == 1.0) {
+ } else {
// Hit something
- if ( mFlags & FX_IMPACT_RUNS_FX && !(trace.surfaceFlags & SURF_NOIMPACT ))
- {
- theFxScheduler.PlayEffect( mImpactFxID, trace.endpos, trace.plane.normal );
+ if (mFlags & FX_IMPACT_RUNS_FX && !(trace.surfaceFlags & SURF_NOIMPACT)) {
+ theFxScheduler.PlayEffect(mImpactFxID, trace.endpos, trace.plane.normal);
}
- if ( mFlags & FX_KILL_ON_IMPACT )
- {
+ if (mFlags & FX_KILL_ON_IMPACT) {
// time to die
return false;
}
- VectorMA( mVel, theFxHelper.mFloatFrameTime * trace.fraction, mAccel, mVel );
+ VectorMA(mVel, theFxHelper.mFloatFrameTime * trace.fraction, mAccel, mVel);
- dot = DotProduct( mVel, trace.plane.normal );
+ dot = DotProduct(mVel, trace.plane.normal);
- VectorMA( mVel, -2 * dot, trace.plane.normal, mVel );
+ VectorMA(mVel, -2 * dot, trace.plane.normal, mVel);
- VectorScale( mVel, mElasticity, mVel );
+ VectorScale(mVel, mElasticity, mVel);
// If the velocity is too low, make it stop moving, rotating, and turn off physics to avoid
// doing expensive operations when they aren't needed
- if ( trace.plane.normal[2] > 0 && mVel[2] < 4 )
- {
- VectorClear( mVel );
- VectorClear( mAccel );
+ if (trace.plane.normal[2] > 0 && mVel[2] < 4) {
+ VectorClear(mVel);
+ VectorClear(mAccel);
- mFlags &= ~(FX_APPLY_PHYSICS|FX_IMPACT_RUNS_FX);
+ mFlags &= ~(FX_APPLY_PHYSICS | FX_IMPACT_RUNS_FX);
}
// Set the origin to the exact impact point
- VectorCopy( trace.endpos, mOrigin1 );
+ VectorCopy(trace.endpos, mOrigin1);
return true;
}
}
}
// No physics were done to this object, move it
- VectorCopy( new_origin, mOrigin1 );
+ VectorCopy(new_origin, mOrigin1);
return true;
}
@@ -358,72 +306,51 @@ bool CParticle::UpdateOrigin()
//----------------------------
// Update Size
//----------------------------
-void CParticle::UpdateSize()
-{
+void CParticle::UpdateSize() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
+ float perc1 = 1.0f, perc2 = 1.0f;
- if ( (mFlags & FX_SIZE_LINEAR) )
- {
+ if ((mFlags & FX_SIZE_LINEAR)) {
// calculate element biasing
- perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart)
- / (float)(mTimeEnd - mTimeStart);
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR, FX_WAVE, or FX_CLAMP
- if (( mFlags & FX_SIZE_PARM_MASK ) == FX_SIZE_NONLINEAR )
- {
- if ( theFxHelper.mTime > mSizeParm )
- {
+ if ((mFlags & FX_SIZE_PARM_MASK) == FX_SIZE_NONLINEAR) {
+ if (theFxHelper.mTime > mSizeParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)(theFxHelper.mTime - mSizeParm)
- / (float)(mTimeEnd - mSizeParm);
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mSizeParm) / (float)(mTimeEnd - mSizeParm);
}
- if ( mFlags & FX_SIZE_LINEAR )
- {
+ if (mFlags & FX_SIZE_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
+ } else if ((mFlags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos( (theFxHelper.mTime - mTimeStart) * mSizeParm );
- }
- else if (( mFlags & FX_SIZE_PARM_MASK ) == FX_SIZE_CLAMP )
- {
- if ( theFxHelper.mTime < mSizeParm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mSizeParm);
+ } else if ((mFlags & FX_SIZE_PARM_MASK) == FX_SIZE_CLAMP) {
+ if (theFxHelper.mTime < mSizeParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mSizeParm - theFxHelper.mTime)
- / (float)(mSizeParm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mSizeParm - theFxHelper.mTime) / (float)(mSizeParm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if ( (mFlags & FX_SIZE_LINEAR) )
- {
+ if ((mFlags & FX_SIZE_LINEAR)) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if (( mFlags & FX_SIZE_RAND ))
- {
+ if ((mFlags & FX_SIZE_RAND)) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
@@ -434,144 +361,102 @@ void CParticle::UpdateSize()
//----------------------------
// Update RGB
//----------------------------
-void CParticle::UpdateRGB()
-{
+void CParticle::UpdateRGB() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
- vec3_t res;
+ float perc1 = 1.0f, perc2 = 1.0f;
+ vec3_t res;
- if ( (mFlags & FX_RGB_LINEAR) )
- {
+ if ((mFlags & FX_RGB_LINEAR)) {
// calculate element biasing
- perc1 = 1.0f - (float)( theFxHelper.mTime - mTimeStart )
- / (float)( mTimeEnd - mTimeStart );
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR, FX_WAVE, or FX_CLAMP
- if (( mFlags & FX_RGB_PARM_MASK ) == FX_RGB_NONLINEAR )
- {
- if ( theFxHelper.mTime > mRGBParm )
- {
+ if ((mFlags & FX_RGB_PARM_MASK) == FX_RGB_NONLINEAR) {
+ if (theFxHelper.mTime > mRGBParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)( theFxHelper.mTime - mRGBParm )
- / (float)( mTimeEnd - mRGBParm );
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mRGBParm) / (float)(mTimeEnd - mRGBParm);
}
- if ( (mFlags & FX_RGB_LINEAR) )
- {
+ if ((mFlags & FX_RGB_LINEAR)) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
+ } else if ((mFlags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos(( theFxHelper.mTime - mTimeStart ) * mRGBParm );
- }
- else if (( mFlags & FX_RGB_PARM_MASK ) == FX_RGB_CLAMP )
- {
- if ( theFxHelper.mTime < mRGBParm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mRGBParm);
+ } else if ((mFlags & FX_RGB_PARM_MASK) == FX_RGB_CLAMP) {
+ if (theFxHelper.mTime < mRGBParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mRGBParm - theFxHelper.mTime)
- / (float)(mRGBParm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mRGBParm - theFxHelper.mTime) / (float)(mRGBParm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if (( mFlags & FX_RGB_LINEAR ))
- {
+ if ((mFlags & FX_RGB_LINEAR)) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if (( mFlags & FX_RGB_RAND ))
- {
+ if ((mFlags & FX_RGB_RAND)) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
// Now get the correct color
- VectorScale( mRGBStart, perc1, res );
- VectorMA( res, (1.0f - perc1), mRGBEnd, mRefEnt.angles ); // angles is a temp storage, will get clamped to a byte in the UpdateAlpha section
+ VectorScale(mRGBStart, perc1, res);
+ VectorMA(res, (1.0f - perc1), mRGBEnd, mRefEnt.angles); // angles is a temp storage, will get clamped to a byte in the UpdateAlpha section
}
-
//----------------------------
// Update Alpha
//----------------------------
-void CParticle::UpdateAlpha()
-{
+void CParticle::UpdateAlpha() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
+ float perc1 = 1.0f, perc2 = 1.0f;
- if ( mFlags & FX_ALPHA_LINEAR )
- {
+ if (mFlags & FX_ALPHA_LINEAR) {
// calculate element biasing
- perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart)
- / (float)(mTimeEnd - mTimeStart);
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR, FX_WAVE, or FX_CLAMP
- if (( mFlags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_NONLINEAR )
- {
- if ( theFxHelper.mTime > mAlphaParm )
- {
+ if ((mFlags & FX_ALPHA_PARM_MASK) == FX_ALPHA_NONLINEAR) {
+ if (theFxHelper.mTime > mAlphaParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)(theFxHelper.mTime - mAlphaParm)
- / (float)(mTimeEnd - mAlphaParm);
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mAlphaParm) / (float)(mTimeEnd - mAlphaParm);
}
- if ( mFlags & FX_ALPHA_LINEAR )
- {
+ if (mFlags & FX_ALPHA_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
+ } else if ((mFlags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos( (theFxHelper.mTime - mTimeStart) * mAlphaParm );
- }
- else if (( mFlags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_CLAMP )
- {
- if ( theFxHelper.mTime < mAlphaParm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mAlphaParm);
+ } else if ((mFlags & FX_ALPHA_PARM_MASK) == FX_ALPHA_CLAMP) {
+ if (theFxHelper.mTime < mAlphaParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mAlphaParm - theFxHelper.mTime)
- / (float)(mAlphaParm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mAlphaParm - theFxHelper.mTime) / (float)(mAlphaParm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if ( mFlags & FX_ALPHA_LINEAR )
- {
+ if (mFlags & FX_ALPHA_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
@@ -580,33 +465,26 @@ void CParticle::UpdateAlpha()
perc1 = (mAlphaStart * perc1) + (mAlphaEnd * (1.0f - perc1));
// We should be in the right range, but clamp to ensure
- if ( perc1 < 0.0f )
- {
+ if (perc1 < 0.0f) {
perc1 = 0.0f;
- }
- else if ( perc1 > 1.0f )
- {
+ } else if (perc1 > 1.0f) {
perc1 = 1.0f;
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if ( (mFlags & FX_ALPHA_RAND) )
- {
+ if ((mFlags & FX_ALPHA_RAND)) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
- if ( mFlags & FX_USE_ALPHA )
- {
+ if (mFlags & FX_USE_ALPHA) {
// should use this when using art that has an alpha channel
- ClampVec( mRefEnt.angles, (byte*)(&mRefEnt.shaderRGBA) );
- mRefEnt.shaderRGBA[3] = (byte)(perc1 * 0xff);
- }
- else
- {
+ ClampVec(mRefEnt.angles, (byte *)(&mRefEnt.shaderRGBA));
+ mRefEnt.shaderRGBA[3] = (byte)(perc1 * 0xff);
+ } else {
// Modulate the rgb fields by the alpha value to do the fade, works fine for additive blending
- VectorScale( mRefEnt.angles, perc1, mRefEnt.angles );
- ClampVec( mRefEnt.angles, (byte*)(&mRefEnt.shaderRGBA) );
+ VectorScale(mRefEnt.angles, perc1, mRefEnt.angles);
+ ClampVec(mRefEnt.angles, (byte *)(&mRefEnt.shaderRGBA));
}
}
@@ -616,26 +494,22 @@ void CParticle::UpdateAlpha()
//
//--------------------------------
-
//----------------------------
-bool COrientedParticle::Cull()
-{
- vec3_t dir;
+bool COrientedParticle::Cull() {
+ vec3_t dir;
// Get the direction to the view
- VectorSubtract( mOrigin1, cg.refdef.vieworg, dir );
+ VectorSubtract(mOrigin1, cg.refdef.vieworg, dir);
// Check if it's behind the viewer
- if ( (DotProduct( cg.refdef.viewaxis[0], dir )) < 0 )
- {
+ if ((DotProduct(cg.refdef.viewaxis[0], dir)) < 0) {
return true;
}
- float len = VectorLengthSquared( dir );
+ float len = VectorLengthSquared(dir);
// Can't be too close
- if ( len < 24 * 24 )
- {
+ if (len < 24 * 24) {
return true;
}
@@ -643,18 +517,16 @@ bool COrientedParticle::Cull()
}
//----------------------------
-void COrientedParticle::Draw()
-{
- if ( mFlags & FX_DEPTH_HACK )
- {
+void COrientedParticle::Draw() {
+ if (mFlags & FX_DEPTH_HACK) {
// Not sure if first person needs to be set
mRefEnt.renderfx |= RF_DEPTHHACK;
}
// Add our refEntity to the scene
- VectorCopy( mOrigin1, mRefEnt.origin );
- VectorCopy( mNormal, mRefEnt.axis[0] );
- theFxHelper.AddFxToScene( &mRefEnt );
+ VectorCopy(mOrigin1, mRefEnt.origin);
+ VectorCopy(mNormal, mRefEnt.axis[0]);
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
mOParticles++;
@@ -663,87 +535,76 @@ void COrientedParticle::Draw()
//----------------------------
// Update
//----------------------------
-bool COrientedParticle::Update()
-{
+bool COrientedParticle::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- if ( mFlags & FX_RELATIVE )
- {
- if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
- { // we are somehow not bolted even though the flag is on?
+ if (mFlags & FX_RELATIVE) {
+ if (mClientID < 0 || mClientID >= ENTITYNUM_WORLD) { // we are somehow not bolted even though the flag is on?
return false;
}
- vec3_t org;
- vec3_t ax[3];
+ vec3_t org;
+ vec3_t ax[3];
// Get our current position and direction
- if (mModelNum>=0 && mBoltNum>=0) //bolt style
+ if (mModelNum >= 0 && mBoltNum >= 0) // bolt style
{
const centity_t ¢ = cg_entities[mClientID];
- if (!cent.gent->ghoul2.IsValid())
- {
+ if (!cent.gent->ghoul2.IsValid()) {
return false;
}
- if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, org, ax))
- { //could not get bolt
+ if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, org, ax)) { // could not get bolt
return false;
}
- }
- else
- {//fixme change this to bolt style...
+ } else { // fixme change this to bolt style...
vec3_t dir, ang;
- GetOrigin( mClientID, org );
- GetDir( mClientID, dir );
+ GetOrigin(mClientID, org);
+ GetDir(mClientID, dir);
- vectoangles( dir, ang );
- AngleVectors( ang, ax[0], ax[1], ax[2] );
+ vectoangles(dir, ang);
+ AngleVectors(ang, ax[0], ax[1], ax[2]);
}
- vec3_t realVel, realAccel;
+ vec3_t realVel, realAccel;
- VectorMA( org, mOrgOffset[0], ax[0], org );
- VectorMA( org, mOrgOffset[1], ax[1], org );
- VectorMA( org, mOrgOffset[2], ax[2], org );
+ VectorMA(org, mOrgOffset[0], ax[0], org);
+ VectorMA(org, mOrgOffset[1], ax[1], org);
+ VectorMA(org, mOrgOffset[2], ax[2], org);
- const float time = (theFxHelper.mTime - mTimeStart) * 0.001f;
+ const float time = (theFxHelper.mTime - mTimeStart) * 0.001f;
// calc the real velocity and accel vectors
- VectorScale( ax[0], mVel[0], realVel );
- VectorMA( realVel, mVel[1], ax[1], realVel );
- VectorMA( realVel, mVel[2], ax[2], realVel );
+ VectorScale(ax[0], mVel[0], realVel);
+ VectorMA(realVel, mVel[1], ax[1], realVel);
+ VectorMA(realVel, mVel[2], ax[2], realVel);
realVel[2] += 0.5f * mGravity * time;
- VectorScale( ax[0], mAccel[0], realAccel );
- VectorMA( realAccel, mAccel[1], ax[1], realAccel );
- VectorMA( realAccel, mAccel[2], ax[2], realAccel );
+ VectorScale(ax[0], mAccel[0], realAccel);
+ VectorMA(realAccel, mAccel[1], ax[1], realAccel);
+ VectorMA(realAccel, mAccel[2], ax[2], realAccel);
// Get our real velocity at the current time, taking into account the effects of acceleartion. NOTE: not sure if this is even 100% correct math-wise
- VectorMA( realVel, time, realAccel, realVel );
+ VectorMA(realVel, time, realAccel, realVel);
// Now move us to where we should be at the given time
- VectorMA( org, time, realVel, mOrigin1 );
-
- //use the normalOffset and add that to the actual normal of the bolt
- //NOTE: not tested!!!
- vec3_t boltAngles, offsetAngles, transformedAngles;
- vectoangles( ax[0], boltAngles );
- vectoangles( mNormalOffset, offsetAngles );
- VectorAdd( boltAngles, offsetAngles, transformedAngles );
- AngleVectors( transformedAngles, mNormal, NULL, NULL );
- }
- else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
- {
+ VectorMA(org, time, realVel, mOrigin1);
+
+ // use the normalOffset and add that to the actual normal of the bolt
+ // NOTE: not tested!!!
+ vec3_t boltAngles, offsetAngles, transformedAngles;
+ vectoangles(ax[0], boltAngles);
+ vectoangles(mNormalOffset, offsetAngles);
+ VectorAdd(boltAngles, offsetAngles, transformedAngles);
+ AngleVectors(transformedAngles, mNormal, NULL, NULL);
+ } else if ((mTimeStart < theFxHelper.mTime) && UpdateOrigin() == false) {
// we are marked for death
return false;
}
- if ( !Cull())
- {
+ if (!Cull()) {
UpdateSize();
UpdateRGB();
UpdateAlpha();
@@ -755,7 +616,6 @@ bool COrientedParticle::Update()
return true;
}
-
//----------------------------
//
// Derived Line Class
@@ -763,83 +623,69 @@ bool COrientedParticle::Update()
//----------------------------
//----------------------------
-void CLine::Draw()
-{
- if ( mFlags & FX_DEPTH_HACK )
- {
+void CLine::Draw() {
+ if (mFlags & FX_DEPTH_HACK) {
// Not sure if first person needs to be set, but it can't hurt?
mRefEnt.renderfx |= RF_DEPTHHACK;
}
- VectorCopy( mOrigin1, mRefEnt.origin );
- VectorCopy( mOrigin2, mRefEnt.oldorigin );
+ VectorCopy(mOrigin1, mRefEnt.origin);
+ VectorCopy(mOrigin2, mRefEnt.oldorigin);
- theFxHelper.AddFxToScene( &mRefEnt );
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
mLines++;
}
//----------------------------
-bool CLine::Update()
-{
+bool CLine::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- if ( mFlags & FX_RELATIVE )
- {
- if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
- { // we are somehow not bolted even though the flag is on?
+ if (mFlags & FX_RELATIVE) {
+ if (mClientID < 0 || mClientID >= ENTITYNUM_WORLD) { // we are somehow not bolted even though the flag is on?
return false;
}
- vec3_t ax[3] = {};
+ vec3_t ax[3] = {};
// Get our current position and direction
- if (mModelNum>=0 && mBoltNum>=0) //bolt style
+ if (mModelNum >= 0 && mBoltNum >= 0) // bolt style
{
const centity_t ¢ = cg_entities[mClientID];
- if (!cent.gent->ghoul2.IsValid())
- {
+ if (!cent.gent->ghoul2.IsValid()) {
return false;
}
- if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, mOrigin1, ax))
- { //could not get bolt
+ if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, mOrigin1, ax)) { // could not get bolt
return false;
}
- }
- else
- {//fixme change this to bolt style...
+ } else { // fixme change this to bolt style...
// Get our current position and direction
- GetOrigin( mClientID, mOrigin1 );
- GetDir( mClientID, ax[0] );
+ GetOrigin(mClientID, mOrigin1);
+ GetDir(mClientID, ax[0]);
}
- VectorAdd(mOrigin1, mOrgOffset, mOrigin1); //add the offset to the bolt point
+ VectorAdd(mOrigin1, mOrgOffset, mOrigin1); // add the offset to the bolt point
- vec3_t end;
- trace_t trace;
- if ( mFlags & FX_APPLY_PHYSICS )
- {
- VectorMA( mOrigin1, 2048, ax[0], end );
+ vec3_t end;
+ trace_t trace;
+ if (mFlags & FX_APPLY_PHYSICS) {
+ VectorMA(mOrigin1, 2048, ax[0], end);
- theFxHelper.Trace( &trace, mOrigin1, NULL, NULL, end, mClientID, MASK_SHOT );
+ theFxHelper.Trace(&trace, mOrigin1, NULL, NULL, end, mClientID, MASK_SHOT);
- VectorCopy( trace.endpos, mOrigin2 );
+ VectorCopy(trace.endpos, mOrigin2);
- if ( mImpactFxID > 0 )
- {
- theFxScheduler.PlayEffect( mImpactFxID, trace.endpos, trace.plane.normal );
+ if (mImpactFxID > 0) {
+ theFxScheduler.PlayEffect(mImpactFxID, trace.endpos, trace.plane.normal);
}
- }
- else
- {
- VectorMA( mOrigin1, mVel[0], ax[0], mOrigin2 );
- VectorMA( mOrigin2, mVel[1], ax[1], mOrigin2 );
- VectorMA( mOrigin2, mVel[2], ax[2], mOrigin2 );
+ } else {
+ VectorMA(mOrigin1, mVel[0], ax[0], mOrigin2);
+ VectorMA(mOrigin2, mVel[1], ax[1], mOrigin2);
+ VectorMA(mOrigin2, mVel[2], ax[2], mOrigin2);
}
}
@@ -852,100 +698,85 @@ bool CLine::Update()
return true;
}
-
//----------------------------
//
// Derived Electricity Class
//
//----------------------------
-void CElectricity::Initialize()
-{
+void CElectricity::Initialize() {
mRefEnt.frame = Q_flrand(0.0f, 1.0f) * 1265536;
mRefEnt.endTime = cg.time + (mTimeEnd - mTimeStart);
- if ( mFlags & FX_DEPTH_HACK )
- {
+ if (mFlags & FX_DEPTH_HACK) {
mRefEnt.renderfx |= RF_DEPTHHACK;
}
- if ( mFlags & FX_BRANCH )
- {
+ if (mFlags & FX_BRANCH) {
mRefEnt.renderfx |= RF_FORKED;
}
- if ( mFlags & FX_TAPER )
- {
+ if (mFlags & FX_TAPER) {
mRefEnt.renderfx |= RF_TAPERED;
}
- if ( mFlags & FX_GROW )
- {
+ if (mFlags & FX_GROW) {
mRefEnt.renderfx |= RF_GROW;
}
}
//----------------------------
-void CElectricity::Draw()
-{
- VectorCopy( mOrigin1, mRefEnt.origin );
- VectorCopy( mOrigin2, mRefEnt.oldorigin );
+void CElectricity::Draw() {
+ VectorCopy(mOrigin1, mRefEnt.origin);
+ VectorCopy(mOrigin2, mRefEnt.oldorigin);
mRefEnt.angles[0] = mChaos;
mRefEnt.angles[1] = mTimeEnd - mTimeStart;
- theFxHelper.AddFxToScene( &mRefEnt );
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
mLines++; // NOT REALLY A LINE!
}
//----------------------------
-bool CElectricity::Update()
-{
+bool CElectricity::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- //Handle Relative and Bolted Effects
- if ( mFlags & FX_RELATIVE )
- {//add mOrgOffset to bolt position and store in mOrigin1
- if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
- { // we are somehow not bolted even though the flag is on?
+ // Handle Relative and Bolted Effects
+ if (mFlags & FX_RELATIVE) { // add mOrgOffset to bolt position and store in mOrigin1
+ if (mClientID < 0 || mClientID >= ENTITYNUM_WORLD) { // we are somehow not bolted even though the flag is on?
return false;
}
- vec3_t ax[3] = {};
+ vec3_t ax[3] = {};
// Get our current position and direction
- if (mModelNum>=0 && mBoltNum>=0) //bolt style
+ if (mModelNum >= 0 && mBoltNum >= 0) // bolt style
{
const centity_t ¢ = cg_entities[mClientID];
- if (!cent.gent->ghoul2.IsValid())
- {
+ if (!cent.gent->ghoul2.IsValid()) {
return false;
}
- if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, mOrigin1, ax))
- { //could not get bolt
+ if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, mOrigin1, ax)) { // could not get bolt
return false;
}
- }
- else
- {//fixme change this to bolt style...
+ } else { // fixme change this to bolt style...
// Get our current position and direction
- GetOrigin( mClientID, mOrigin1 );
- GetDir( mClientID, ax[0] );
+ GetOrigin(mClientID, mOrigin1);
+ GetDir(mClientID, ax[0]);
}
- //add the offset to the bolt point
+ // add the offset to the bolt point
VectorAdd(mOrigin1, mOrgOffset, mOrigin1);
- //add the endpoint offset to the start to get the final offset
- VectorMA( mOrigin1, mVel[0], ax[0], mOrigin2 );
- VectorMA( mOrigin2, mVel[1], ax[1], mOrigin2 );
- VectorMA( mOrigin2, mVel[2], ax[2], mOrigin2 );
+ // add the endpoint offset to the start to get the final offset
+ VectorMA(mOrigin1, mVel[0], ax[0], mOrigin2);
+ VectorMA(mOrigin2, mVel[1], ax[1], mOrigin2);
+ VectorMA(mOrigin2, mVel[2], ax[2], mOrigin2);
}
- //else just uses the static origin1 & origin2 as start and end
+ // else just uses the static origin1 & origin2 as start and end
UpdateSize();
UpdateRGB();
UpdateAlpha();
@@ -955,22 +786,19 @@ bool CElectricity::Update()
return true;
}
-
//----------------------------
//
// Derived Tail Class
//
//----------------------------
-bool CTail::Cull()
-{
- vec3_t dir;
+bool CTail::Cull() {
+ vec3_t dir;
// Get the direction to the view
- VectorSubtract( mOrigin1, cg.refdef.vieworg, dir );
+ VectorSubtract(mOrigin1, cg.refdef.vieworg, dir);
// Check if it's behind the viewer
- if ( (DotProduct( cg.refdef.viewaxis[0], dir )) < 0 )
- {
+ if ((DotProduct(cg.refdef.viewaxis[0], dir)) < 0) {
return true;
}
@@ -978,105 +806,92 @@ bool CTail::Cull()
}
//----------------------------
-void CTail::Draw()
-{
- if ( mFlags & FX_DEPTH_HACK )
- {
+void CTail::Draw() {
+ if (mFlags & FX_DEPTH_HACK) {
// Not sure if first person needs to be set
mRefEnt.renderfx |= RF_DEPTHHACK;
}
- VectorCopy( mOrigin1, mRefEnt.origin );
+ VectorCopy(mOrigin1, mRefEnt.origin);
- theFxHelper.AddFxToScene( &mRefEnt );
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
mTails++;
}
//----------------------------
-bool CTail::Update()
-{
+bool CTail::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- if ( !fx_freeze.integer )
- {
- VectorCopy( mOrigin1, mOldOrigin );
+ if (!fx_freeze.integer) {
+ VectorCopy(mOrigin1, mOldOrigin);
}
- if ( mFlags & FX_RELATIVE )
- {
- if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
- { // we are somehow not bolted even though the flag is on?
+ if (mFlags & FX_RELATIVE) {
+ if (mClientID < 0 || mClientID >= ENTITYNUM_WORLD) { // we are somehow not bolted even though the flag is on?
return false;
}
- vec3_t org;
- vec3_t ax[3];
- if (mModelNum>=0 && mBoltNum>=0) //bolt style
+ vec3_t org;
+ vec3_t ax[3];
+ if (mModelNum >= 0 && mBoltNum >= 0) // bolt style
{
const centity_t ¢ = cg_entities[mClientID];
- if (!cent.gent->ghoul2.IsValid())
- {
+ if (!cent.gent->ghoul2.IsValid()) {
return false;
}
- if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, org, ax))
- { //could not get bolt
+ if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, org, ax)) { // could not get bolt
return false;
}
- }
- else
- {
- vec3_t dir;
+ } else {
+ vec3_t dir;
// Get our current position and direction
- GetOrigin( mClientID, org );
- GetDir( mClientID, dir );
+ GetOrigin(mClientID, org);
+ GetDir(mClientID, dir);
vec3_t ang;
- vectoangles( dir, ang );
- AngleVectors( ang, ax[0], ax[1], ax[2] );
+ vectoangles(dir, ang);
+ AngleVectors(ang, ax[0], ax[1], ax[2]);
}
- vec3_t realVel, realAccel;
+ vec3_t realVel, realAccel;
- VectorMA( org, mOrgOffset[0], ax[0], org );
- VectorMA( org, mOrgOffset[1], ax[1], org );
- VectorMA( org, mOrgOffset[2], ax[2], org );
+ VectorMA(org, mOrgOffset[0], ax[0], org);
+ VectorMA(org, mOrgOffset[1], ax[1], org);
+ VectorMA(org, mOrgOffset[2], ax[2], org);
// calc the real velocity and accel vectors
- // FIXME: if you want right and up movement in addition to the forward movement, you'll have to convert dir into a set of perp. axes and do some extra work
- VectorScale( ax[0], mVel[0], realVel );
- VectorMA( realVel, mVel[1], ax[1], realVel );
- VectorMA( realVel, mVel[2], ax[2], realVel );
+ // FIXME: if you want right and up movement in addition to the forward movement, you'll have to convert dir into a set of perp. axes and do some extra
+ // work
+ VectorScale(ax[0], mVel[0], realVel);
+ VectorMA(realVel, mVel[1], ax[1], realVel);
+ VectorMA(realVel, mVel[2], ax[2], realVel);
- VectorScale( ax[0], mAccel[0], realAccel );
- VectorMA( realAccel, mAccel[1], ax[1], realAccel );
- VectorMA( realAccel, mAccel[2], ax[2], realAccel );
+ VectorScale(ax[0], mAccel[0], realAccel);
+ VectorMA(realAccel, mAccel[1], ax[1], realAccel);
+ VectorMA(realAccel, mAccel[2], ax[2], realAccel);
- const float time = (theFxHelper.mTime - mTimeStart) * 0.001f;
+ const float time = (theFxHelper.mTime - mTimeStart) * 0.001f;
// Get our real velocity at the current time, taking into account the effects of acceleration. NOTE: not sure if this is even 100% correct math-wise
- VectorMA( realVel, time, realAccel, realVel );
+ VectorMA(realVel, time, realAccel, realVel);
// Now move us to where we should be at the given time
- VectorMA( org, time, realVel, mOrigin1 );
+ VectorMA(org, time, realVel, mOrigin1);
// Just calc an old point some time in the past, doesn't really matter when
- VectorMA( org, (time - 0.003f), realVel, mOldOrigin );
- }
- else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
- {
+ VectorMA(org, (time - 0.003f), realVel, mOldOrigin);
+ } else if ((mTimeStart < theFxHelper.mTime) && UpdateOrigin() == false) {
// we are marked for death
return false;
}
- if ( !Cull() )
- {
+ if (!Cull()) {
UpdateSize();
UpdateLength();
UpdateRGB();
@@ -1091,72 +906,51 @@ bool CTail::Update()
}
//----------------------------
-void CTail::UpdateLength()
-{
+void CTail::UpdateLength() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
+ float perc1 = 1.0f, perc2 = 1.0f;
- if ( mFlags & FX_LENGTH_LINEAR )
- {
+ if (mFlags & FX_LENGTH_LINEAR) {
// calculate element biasing
- perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart)
- / (float)(mTimeEnd - mTimeStart);
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR or FX_WAVE
- if (( mFlags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_NONLINEAR )
- {
- if ( theFxHelper.mTime > mLengthParm )
- {
+ if ((mFlags & FX_LENGTH_PARM_MASK) == FX_LENGTH_NONLINEAR) {
+ if (theFxHelper.mTime > mLengthParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)(theFxHelper.mTime - mLengthParm)
- / (float)(mTimeEnd - mLengthParm);
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mLengthParm) / (float)(mTimeEnd - mLengthParm);
}
- if ( mFlags & FX_LENGTH_LINEAR )
- {
+ if (mFlags & FX_LENGTH_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE )
- {
+ } else if ((mFlags & FX_LENGTH_PARM_MASK) == FX_LENGTH_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos( (theFxHelper.mTime - mTimeStart) * mLengthParm );
- }
- else if (( mFlags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_CLAMP )
- {
- if ( theFxHelper.mTime < mLengthParm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mLengthParm);
+ } else if ((mFlags & FX_LENGTH_PARM_MASK) == FX_LENGTH_CLAMP) {
+ if (theFxHelper.mTime < mLengthParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mLengthParm - theFxHelper.mTime)
- / (float)(mLengthParm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mLengthParm - theFxHelper.mTime) / (float)(mLengthParm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if ( mFlags & FX_LENGTH_LINEAR )
- {
+ if (mFlags & FX_LENGTH_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if ( mFlags & FX_LENGTH_RAND )
- {
+ if (mFlags & FX_LENGTH_RAND) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
@@ -1165,37 +959,33 @@ void CTail::UpdateLength()
}
//----------------------------
-void CTail::CalcNewEndpoint()
-{
+void CTail::CalcNewEndpoint() {
vec3_t temp;
// FIXME: Hmmm, this looks dumb when physics are on and a bounce happens
- VectorSubtract( mOldOrigin, mOrigin1, temp );
+ VectorSubtract(mOldOrigin, mOrigin1, temp);
// I wish we didn't have to do a VectorNormalize every frame.....
- VectorNormalize( temp );
+ VectorNormalize(temp);
- VectorMA( mOrigin1, mLength, temp, mRefEnt.oldorigin );
+ VectorMA(mOrigin1, mLength, temp, mRefEnt.oldorigin);
}
-
//----------------------------
//
// Derived Cylinder Class
//
//----------------------------
-void CCylinder::Draw()
-{
- if ( mFlags & FX_DEPTH_HACK )
- {
+void CCylinder::Draw() {
+ if (mFlags & FX_DEPTH_HACK) {
// Not sure if first person needs to be set, but it can't hurt?
mRefEnt.renderfx |= RF_DEPTHHACK;
}
- VectorCopy( mOrigin1, mRefEnt.origin );
- VectorMA( mOrigin1, mLength, mRefEnt.axis[0], mRefEnt.oldorigin );
+ VectorCopy(mOrigin1, mRefEnt.origin);
+ VectorMA(mOrigin1, mLength, mRefEnt.axis[0], mRefEnt.oldorigin);
- theFxHelper.AddFxToScene( &mRefEnt );
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
}
@@ -1203,72 +993,51 @@ void CCylinder::Draw()
//----------------------------
// Update Size2
//----------------------------
-void CCylinder::UpdateSize2()
-{
+void CCylinder::UpdateSize2() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
+ float perc1 = 1.0f, perc2 = 1.0f;
- if ( mFlags & FX_SIZE2_LINEAR )
- {
+ if (mFlags & FX_SIZE2_LINEAR) {
// calculate element biasing
- perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart)
- / (float)(mTimeEnd - mTimeStart);
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR or FX_WAVE
- if (( mFlags & FX_SIZE2_PARM_MASK ) == FX_SIZE2_NONLINEAR )
- {
- if ( theFxHelper.mTime > mSize2Parm )
- {
+ if ((mFlags & FX_SIZE2_PARM_MASK) == FX_SIZE2_NONLINEAR) {
+ if (theFxHelper.mTime > mSize2Parm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)(theFxHelper.mTime - mSize2Parm)
- / (float)(mTimeEnd - mSize2Parm);
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mSize2Parm) / (float)(mTimeEnd - mSize2Parm);
}
- if ( (mFlags & FX_SIZE2_LINEAR) )
- {
+ if ((mFlags & FX_SIZE2_LINEAR)) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_SIZE2_PARM_MASK ) == FX_SIZE2_WAVE )
- {
+ } else if ((mFlags & FX_SIZE2_PARM_MASK) == FX_SIZE2_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos( (theFxHelper.mTime - mTimeStart) * mSize2Parm );
- }
- else if (( mFlags & FX_SIZE2_PARM_MASK ) == FX_SIZE2_CLAMP )
- {
- if ( theFxHelper.mTime < mSize2Parm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mSize2Parm);
+ } else if ((mFlags & FX_SIZE2_PARM_MASK) == FX_SIZE2_CLAMP) {
+ if (theFxHelper.mTime < mSize2Parm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mSize2Parm - theFxHelper.mTime)
- / (float)(mSize2Parm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mSize2Parm - theFxHelper.mTime) / (float)(mSize2Parm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if ( mFlags & FX_SIZE2_LINEAR )
- {
+ if (mFlags & FX_SIZE2_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if ( mFlags & FX_SIZE2_RAND )
- {
+ if (mFlags & FX_SIZE2_RAND) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
@@ -1277,47 +1046,39 @@ void CCylinder::UpdateSize2()
}
//----------------------------
-bool CCylinder::Update()
-{
+bool CCylinder::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- if ( mFlags & FX_RELATIVE )
- {
- if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
- { // we are somehow not bolted even though the flag is on?
+ if (mFlags & FX_RELATIVE) {
+ if (mClientID < 0 || mClientID >= ENTITYNUM_WORLD) { // we are somehow not bolted even though the flag is on?
return false;
}
- vec3_t ax[3] = {};
+ vec3_t ax[3] = {};
// Get our current position and direction
- if (mModelNum>=0 && mBoltNum>=0) //bolt style
+ if (mModelNum >= 0 && mBoltNum >= 0) // bolt style
{
const centity_t ¢ = cg_entities[mClientID];
- if (!cent.gent->ghoul2.IsValid())
- {
+ if (!cent.gent->ghoul2.IsValid()) {
return false;
}
- if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, mOrigin1, ax))
- { //could not get bolt
+ if (!theFxHelper.GetOriginAxisFromBolt(cent, mModelNum, mBoltNum, mOrigin1, ax)) { // could not get bolt
return false;
}
- }
- else
- {//fixme change this to bolt style...
+ } else { // fixme change this to bolt style...
// Get our current position and direction
- GetOrigin( mClientID, mOrigin1 );
- GetDir( mClientID, ax[0] );
+ GetOrigin(mClientID, mOrigin1);
+ GetDir(mClientID, ax[0]);
}
- VectorAdd(mOrigin1, mOrgOffset, mOrigin1); //add the offset to the bolt point
+ VectorAdd(mOrigin1, mOrgOffset, mOrigin1); // add the offset to the bolt point
- VectorCopy( ax[0], mRefEnt.axis[0] );
- //FIXME: should mNormal be a modifier on the forward axis?
+ VectorCopy(ax[0], mRefEnt.axis[0]);
+ // FIXME: should mNormal be a modifier on the forward axis?
/*
VectorMA( mOrigin1, mNormal[0], ax[0], mOrigin2 );
VectorMA( mOrigin2, mNormal[1], ax[1], mOrigin2 );
@@ -1336,7 +1097,6 @@ bool CCylinder::Update()
return true;
}
-
//----------------------------
//
// Derived Emitter Class
@@ -1346,34 +1106,29 @@ bool CCylinder::Update()
//----------------------------
// Draw
//----------------------------
-void CEmitter::Draw()
-{
+void CEmitter::Draw() {
// Emitters don't draw themselves, but they may need to add an attached model
- if ( mFlags & FX_ATTACHED_MODEL )
- {
+ if (mFlags & FX_ATTACHED_MODEL) {
mRefEnt.nonNormalizedAxes = qtrue;
- VectorCopy( mOrigin1, mRefEnt.origin );
+ VectorCopy(mOrigin1, mRefEnt.origin);
// ensure that we are sized
- for ( int i = 0; i < 3; i++ )
- {
- VectorScale( mRefEnt.axis[i], mRefEnt.radius, mRefEnt.axis[i] );
+ for (int i = 0; i < 3; i++) {
+ VectorScale(mRefEnt.axis[i], mRefEnt.radius, mRefEnt.axis[i]);
}
- theFxHelper.AddFxToScene( &mRefEnt );
+ theFxHelper.AddFxToScene(&mRefEnt);
}
// If we are emitting effects, we had better be careful because just calling it every cgame frame could
// either choke up the effects system on a fast machine, or look really nasty on a low end one.
- if ( mFlags & FX_EMIT_FX )
- {
- vec3_t org, v;
- float ftime, time2,
- step;
- int i, t, dif;
+ if (mFlags & FX_EMIT_FX) {
+ vec3_t org, v;
+ float ftime, time2, step;
+ int i, t, dif;
-#define TRAIL_RATE 8 // we "think" at about a 60hz rate
+#define TRAIL_RATE 8 // we "think" at about a 60hz rate
// Pick a target step distance and square it
step = mDensity + Q_flrand(-1.0f, 1.0f) * mVariance;
@@ -1381,72 +1136,59 @@ void CEmitter::Draw()
dif = 0;
- for ( t = mOldTime; t <= theFxHelper.mTime; t += TRAIL_RATE )
- {
+ for (t = mOldTime; t <= theFxHelper.mTime; t += TRAIL_RATE) {
dif += TRAIL_RATE;
// ?Not sure if it's better to update this before or after updating the origin
- VectorMA( mOldVelocity, dif * 0.001f, mAccel, v );
+ VectorMA(mOldVelocity, dif * 0.001f, mAccel, v);
// Calc the time differences
ftime = dif * 0.001f;
time2 = ftime * ftime * 0.5f;
// Predict the new position
- for ( i = 0 ; i < 3 ; i++ )
- {
+ for (i = 0; i < 3; i++) {
org[i] = mOldOrigin[i] + ftime * v[i] + time2 * v[i];
}
// Only perform physics if this object is tagged to do so
- if ( (mFlags & FX_APPLY_PHYSICS) )
- {
+ if ((mFlags & FX_APPLY_PHYSICS)) {
bool solid;
- if ( (mFlags&FX_EXPENSIVE_PHYSICS)
- && fx_expensivePhysics.integer )
- {
+ if ((mFlags & FX_EXPENSIVE_PHYSICS) && fx_expensivePhysics.integer) {
solid = true; // by setting this to true, we force a real trace to happen
- }
- else
- {
+ } else {
// if this returns solid, we need to do a trace
- solid = !!(CG_PointContents( org, ENTITYNUM_WORLD ) & MASK_SHOT);
+ solid = !!(CG_PointContents(org, ENTITYNUM_WORLD) & MASK_SHOT);
}
- if ( solid )
- {
- trace_t trace;
+ if (solid) {
+ trace_t trace;
- if ( mFlags & FX_USE_BBOX )
- {
- theFxHelper.Trace( &trace, mOldOrigin, mMin, mMax, org, -1, MASK_SHOT );
- }
- else
- {
- theFxHelper.Trace( &trace, mOldOrigin, NULL, NULL, org, -1, MASK_SHOT );
+ if (mFlags & FX_USE_BBOX) {
+ theFxHelper.Trace(&trace, mOldOrigin, mMin, mMax, org, -1, MASK_SHOT);
+ } else {
+ theFxHelper.Trace(&trace, mOldOrigin, NULL, NULL, org, -1, MASK_SHOT);
}
// Hit something
- if ( trace.fraction < 1.0f || trace.startsolid || trace.allsolid )
- {
+ if (trace.fraction < 1.0f || trace.startsolid || trace.allsolid) {
return;
}
}
}
// Is it time to draw an effect?
- if ( DistanceSquared( org, mOldOrigin ) >= step )
- {
+ if (DistanceSquared(org, mOldOrigin) >= step) {
// Pick a new target step distance and square it
step = mDensity + Q_flrand(-1.0f, 1.0f) * mVariance;
step *= step;
// We met the step criteria so, we should add in the effect
- theFxScheduler.PlayEffect( mEmitterFxID, org, mRefEnt.axis );
+ theFxScheduler.PlayEffect(mEmitterFxID, org, mRefEnt.axis);
- VectorCopy( org, mOldOrigin );
- VectorCopy( v, mOldVelocity );
+ VectorCopy(org, mOldOrigin);
+ VectorCopy(v, mOldVelocity);
dif = 0;
mOldTime = t;
}
@@ -1457,15 +1199,13 @@ void CEmitter::Draw()
}
//----------------------------
-bool CEmitter::Update()
-{
+bool CEmitter::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- //FIXME: Handle Relative and Bolted Effects
+ // FIXME: Handle Relative and Bolted Effects
/*
if ( mFlags & FX_RELATIVE )
{
@@ -1481,25 +1221,23 @@ bool CEmitter::Update()
}
*/
// Use this to track if we've stopped moving
- VectorCopy( mOrigin1, mOldOrigin );
- VectorCopy( mVel, mOldVelocity );
+ VectorCopy(mOrigin1, mOldOrigin);
+ VectorCopy(mVel, mOldVelocity);
- if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
- { // we are marked for death
+ if ((mTimeStart < theFxHelper.mTime) && UpdateOrigin() == false) { // we are marked for death
return false;
}
// If the thing is no longer moving, kill the angle delta, but don't do it too quickly or it will
// look very artificial. Don't do it too slowly or it will look like there is no friction.
- if ( VectorCompare( mOldOrigin, mOrigin1 ))
- {
- VectorScale( mAngleDelta, 0.6f, mAngleDelta );
+ if (VectorCompare(mOldOrigin, mOrigin1)) {
+ VectorScale(mAngleDelta, 0.6f, mAngleDelta);
}
UpdateAngles();
UpdateSize();
-// UpdateRGB(); // had wanted to do something slick whereby an emitted effect could somehow inherit these
-// UpdateAlpha(); // values, but it's not a priority right now.
+ // UpdateRGB(); // had wanted to do something slick whereby an emitted effect could somehow inherit these
+ // UpdateAlpha(); // values, but it's not a priority right now.
Draw();
@@ -1507,13 +1245,12 @@ bool CEmitter::Update()
}
//----------------------------
-void CEmitter::UpdateAngles()
-{
- VectorMA( mAngles, theFxHelper.mFrameTime * 0.01f, mAngleDelta, mAngles ); // was 0.001f, but then you really have to jack up the delta to even notice anything
- AnglesToAxis( mAngles, mRefEnt.axis );
+void CEmitter::UpdateAngles() {
+ VectorMA(mAngles, theFxHelper.mFrameTime * 0.01f, mAngleDelta,
+ mAngles); // was 0.001f, but then you really have to jack up the delta to even notice anything
+ AnglesToAxis(mAngles, mRefEnt.axis);
}
-
//--------------------------
//
// Derived Light Class
@@ -1522,15 +1259,13 @@ void CEmitter::UpdateAngles()
//----------------------------
// Update
//----------------------------
-bool CLight::Update()
-{
+bool CLight::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- //FIXME: Handle Relative and Bolted Effects
+ // FIXME: Handle Relative and Bolted Effects
/*
if ( mFlags & FX_RELATIVE )
{
@@ -1556,72 +1291,51 @@ bool CLight::Update()
//----------------------------
// Update Size
//----------------------------
-void CLight::UpdateSize()
-{
+void CLight::UpdateSize() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
+ float perc1 = 1.0f, perc2 = 1.0f;
- if ( mFlags & FX_SIZE_LINEAR )
- {
+ if (mFlags & FX_SIZE_LINEAR) {
// calculate element biasing
- perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart)
- / (float)(mTimeEnd - mTimeStart);
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR or FX_WAVE
- if (( mFlags & FX_SIZE_PARM_MASK ) == FX_SIZE_NONLINEAR )
- {
- if ( theFxHelper.mTime > mSizeParm )
- {
+ if ((mFlags & FX_SIZE_PARM_MASK) == FX_SIZE_NONLINEAR) {
+ if (theFxHelper.mTime > mSizeParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)(theFxHelper.mTime - mSizeParm)
- / (float)(mTimeEnd - mSizeParm);
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mSizeParm) / (float)(mTimeEnd - mSizeParm);
}
- if ( (mFlags & FX_SIZE_LINEAR) )
- {
+ if ((mFlags & FX_SIZE_LINEAR)) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
+ } else if ((mFlags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos( (theFxHelper.mTime - mTimeStart) * mSizeParm );
- }
- else if (( mFlags & FX_SIZE_PARM_MASK ) == FX_SIZE_CLAMP )
- {
- if ( theFxHelper.mTime < mSizeParm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mSizeParm);
+ } else if ((mFlags & FX_SIZE_PARM_MASK) == FX_SIZE_CLAMP) {
+ if (theFxHelper.mTime < mSizeParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mSizeParm - theFxHelper.mTime)
- / (float)(mSizeParm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mSizeParm - theFxHelper.mTime) / (float)(mSizeParm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if ( mFlags & FX_SIZE_LINEAR )
- {
+ if (mFlags & FX_SIZE_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if ( mFlags & FX_SIZE_RAND )
- {
+ if (mFlags & FX_SIZE_RAND) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
@@ -1632,120 +1346,97 @@ void CLight::UpdateSize()
//----------------------------
// Update RGB
//----------------------------
-void CLight::UpdateRGB()
-{
+void CLight::UpdateRGB() {
// completely biased towards start if it doesn't get overridden
- float perc1 = 1.0f, perc2 = 1.0f;
- vec3_t res;
+ float perc1 = 1.0f, perc2 = 1.0f;
+ vec3_t res;
- if ( mFlags & FX_RGB_LINEAR )
- {
+ if (mFlags & FX_RGB_LINEAR) {
// calculate element biasing
- perc1 = 1.0f - (float)( theFxHelper.mTime - mTimeStart )
- / (float)( mTimeEnd - mTimeStart );
+ perc1 = 1.0f - (float)(theFxHelper.mTime - mTimeStart) / (float)(mTimeEnd - mTimeStart);
}
// We can combine FX_LINEAR with _either_ FX_NONLINEAR or FX_WAVE
- if (( mFlags & FX_RGB_PARM_MASK ) == FX_RGB_NONLINEAR )
- {
- if ( theFxHelper.mTime > mRGBParm )
- {
+ if ((mFlags & FX_RGB_PARM_MASK) == FX_RGB_NONLINEAR) {
+ if (theFxHelper.mTime > mRGBParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = 1.0f - (float)( theFxHelper.mTime - mRGBParm )
- / (float)( mTimeEnd - mRGBParm );
+ perc2 = 1.0f - (float)(theFxHelper.mTime - mRGBParm) / (float)(mTimeEnd - mRGBParm);
}
- if ( mFlags & FX_RGB_LINEAR )
- {
+ if (mFlags & FX_RGB_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
- }
- else if (( mFlags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
+ } else if ((mFlags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
// wave gen, with parm being the frequency multiplier
- perc1 = perc1 * (float)cos(( theFxHelper.mTime - mTimeStart ) * mRGBParm );
- }
- else if (( mFlags & FX_RGB_PARM_MASK ) == FX_RGB_CLAMP )
- {
- if ( theFxHelper.mTime < mRGBParm )
- {
+ perc1 = perc1 * (float)cos((theFxHelper.mTime - mTimeStart) * mRGBParm);
+ } else if ((mFlags & FX_RGB_PARM_MASK) == FX_RGB_CLAMP) {
+ if (theFxHelper.mTime < mRGBParm) {
// get percent done, using parm as the start of the non-linear fade
- perc2 = (float)(mRGBParm - theFxHelper.mTime)
- / (float)(mRGBParm - mTimeStart);
- }
- else
- {
+ perc2 = (float)(mRGBParm - theFxHelper.mTime) / (float)(mRGBParm - mTimeStart);
+ } else {
perc2 = 0.0f; // make it full size??
}
- if ( mFlags & FX_RGB_LINEAR )
- {
+ if (mFlags & FX_RGB_LINEAR) {
// do an even blend
perc1 = perc1 * 0.5f + perc2 * 0.5f;
- }
- else
- {
+ } else {
// just copy it over...sigh
perc1 = perc2;
}
}
// If needed, RAND can coexist with linear and either non-linear or wave.
- if ( mFlags & FX_RGB_RAND )
- {
+ if (mFlags & FX_RGB_RAND) {
// Random simply modulates the existing value
perc1 = Q_flrand(0.0f, 1.0f) * perc1;
}
// Now get the correct color
- VectorScale( mRGBStart, perc1, res );
+ VectorScale(mRGBStart, perc1, res);
- mRefEnt.lightingOrigin[0] = res[0] + ( 1.0f - perc1 ) * mRGBEnd[0];
- mRefEnt.lightingOrigin[1] = res[1] + ( 1.0f - perc1 ) * mRGBEnd[1];
- mRefEnt.lightingOrigin[2] = res[2] + ( 1.0f - perc1 ) * mRGBEnd[2];
+ mRefEnt.lightingOrigin[0] = res[0] + (1.0f - perc1) * mRGBEnd[0];
+ mRefEnt.lightingOrigin[1] = res[1] + (1.0f - perc1) * mRGBEnd[1];
+ mRefEnt.lightingOrigin[2] = res[2] + (1.0f - perc1) * mRGBEnd[2];
}
-
//--------------------------
//
// Derived Trail Class
//
//--------------------------
-#define NEW_MUZZLE 0
-#define NEW_TIP 1
-#define OLD_TIP 2
-#define OLD_MUZZLE 3
+#define NEW_MUZZLE 0
+#define NEW_TIP 1
+#define OLD_TIP 2
+#define OLD_MUZZLE 3
//----------------------------
-void CTrail::Draw()
-{
- polyVert_t verts[3];
-// vec3_t color;
+void CTrail::Draw() {
+ polyVert_t verts[3];
+ // vec3_t color;
// build the first tri out of the new muzzle...new tip...old muzzle
- VectorCopy( mVerts[NEW_MUZZLE].origin, verts[0].xyz );
- VectorCopy( mVerts[NEW_TIP].origin, verts[1].xyz );
- VectorCopy( mVerts[OLD_MUZZLE].origin, verts[2].xyz );
+ VectorCopy(mVerts[NEW_MUZZLE].origin, verts[0].xyz);
+ VectorCopy(mVerts[NEW_TIP].origin, verts[1].xyz);
+ VectorCopy(mVerts[OLD_MUZZLE].origin, verts[2].xyz);
-// VectorScale( mVerts[NEW_MUZZLE].curRGB, mVerts[NEW_MUZZLE].curAlpha, color );
+ // VectorScale( mVerts[NEW_MUZZLE].curRGB, mVerts[NEW_MUZZLE].curAlpha, color );
verts[0].modulate[0] = mVerts[NEW_MUZZLE].rgb[0];
verts[0].modulate[1] = mVerts[NEW_MUZZLE].rgb[1];
verts[0].modulate[2] = mVerts[NEW_MUZZLE].rgb[2];
verts[0].modulate[3] = mVerts[NEW_MUZZLE].alpha;
-// VectorScale( mVerts[NEW_TIP].curRGB, mVerts[NEW_TIP].curAlpha, color );
+ // VectorScale( mVerts[NEW_TIP].curRGB, mVerts[NEW_TIP].curAlpha, color );
verts[1].modulate[0] = mVerts[NEW_TIP].rgb[0];
verts[1].modulate[1] = mVerts[NEW_TIP].rgb[1];
verts[1].modulate[2] = mVerts[NEW_TIP].rgb[2];
verts[1].modulate[3] = mVerts[NEW_TIP].alpha;
-// VectorScale( mVerts[OLD_MUZZLE].curRGB, mVerts[OLD_MUZZLE].curAlpha, color );
+ // VectorScale( mVerts[OLD_MUZZLE].curRGB, mVerts[OLD_MUZZLE].curAlpha, color );
verts[2].modulate[0] = mVerts[OLD_MUZZLE].rgb[0];
verts[2].modulate[1] = mVerts[OLD_MUZZLE].rgb[1];
verts[2].modulate[2] = mVerts[OLD_MUZZLE].rgb[2];
@@ -1759,26 +1450,26 @@ void CTrail::Draw()
verts[2].st[1] = mVerts[OLD_MUZZLE].curST[1];
// Add this tri
- theFxHelper.AddPolyToScene( mShader, 3, verts );
+ theFxHelper.AddPolyToScene(mShader, 3, verts);
// build the second tri out of the old muzzle...old tip...new tip
- VectorCopy( mVerts[OLD_MUZZLE].origin, verts[0].xyz );
- VectorCopy( mVerts[OLD_TIP].origin, verts[1].xyz );
- VectorCopy( mVerts[NEW_TIP].origin, verts[2].xyz );
+ VectorCopy(mVerts[OLD_MUZZLE].origin, verts[0].xyz);
+ VectorCopy(mVerts[OLD_TIP].origin, verts[1].xyz);
+ VectorCopy(mVerts[NEW_TIP].origin, verts[2].xyz);
-// VectorScale( mVerts[OLD_MUZZLE].curRGB, mVerts[OLD_MUZZLE].curAlpha, color );
+ // VectorScale( mVerts[OLD_MUZZLE].curRGB, mVerts[OLD_MUZZLE].curAlpha, color );
verts[0].modulate[0] = mVerts[OLD_MUZZLE].rgb[0];
verts[0].modulate[1] = mVerts[OLD_MUZZLE].rgb[1];
verts[0].modulate[2] = mVerts[OLD_MUZZLE].rgb[2];
verts[0].modulate[3] = mVerts[OLD_MUZZLE].alpha;
-// VectorScale( mVerts[OLD_TIP].curRGB, mVerts[OLD_TIP].curAlpha, color );
+ // VectorScale( mVerts[OLD_TIP].curRGB, mVerts[OLD_TIP].curAlpha, color );
verts[1].modulate[0] = mVerts[OLD_TIP].rgb[0];
verts[1].modulate[1] = mVerts[OLD_TIP].rgb[1];
verts[1].modulate[2] = mVerts[OLD_TIP].rgb[2];
verts[0].modulate[3] = mVerts[OLD_TIP].alpha;
-// VectorScale( mVerts[NEW_TIP].curRGB, mVerts[NEW_TIP].curAlpha, color );
+ // VectorScale( mVerts[NEW_TIP].curRGB, mVerts[NEW_TIP].curAlpha, color );
verts[2].modulate[0] = mVerts[NEW_TIP].rgb[0];
verts[2].modulate[1] = mVerts[NEW_TIP].rgb[1];
verts[2].modulate[2] = mVerts[NEW_TIP].rgb[2];
@@ -1792,7 +1483,7 @@ void CTrail::Draw()
verts[2].st[1] = mVerts[NEW_TIP].curST[1];
// Add this tri
- theFxHelper.AddPolyToScene( mShader, 3, verts );
+ theFxHelper.AddPolyToScene(mShader, 3, verts);
drawnFx++;
}
@@ -1800,15 +1491,13 @@ void CTrail::Draw()
//----------------------------
// Update
//----------------------------
-bool CTrail::Update()
-{
+bool CTrail::Update() {
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
- //FIXME: Handle Relative and Bolted Effects
+ // FIXME: Handle Relative and Bolted Effects
/*
if ( mFlags & FX_RELATIVE )
{
@@ -1825,22 +1514,20 @@ bool CTrail::Update()
*/
float perc = (float)(mTimeEnd - theFxHelper.mTime) / (float)(mTimeEnd - mTimeStart);
- for ( int t = 0; t < 4; t++ )
- {
-// mVerts[t].curAlpha = mVerts[t].alpha * perc + mVerts[t].destAlpha * ( 1.0f - perc );
-// if ( mVerts[t].curAlpha < 0.0f )
-// {
-// mVerts[t].curAlpha = 0.0f;
-// }
-
-// VectorScale( mVerts[t].rgb, perc, mVerts[t].curRGB );
-// VectorMA( mVerts[t].curRGB, ( 1.0f - perc ), mVerts[t].destrgb, mVerts[t].curRGB );
- mVerts[t].curST[0] = mVerts[t].ST[0] * perc + mVerts[t].destST[0] * ( 1.0f - perc );
- if ( mVerts[t].curST[0] > 1.0f )
- {
+ for (int t = 0; t < 4; t++) {
+ // mVerts[t].curAlpha = mVerts[t].alpha * perc + mVerts[t].destAlpha * ( 1.0f - perc );
+ // if ( mVerts[t].curAlpha < 0.0f )
+ // {
+ // mVerts[t].curAlpha = 0.0f;
+ // }
+
+ // VectorScale( mVerts[t].rgb, perc, mVerts[t].curRGB );
+ // VectorMA( mVerts[t].curRGB, ( 1.0f - perc ), mVerts[t].destrgb, mVerts[t].curRGB );
+ mVerts[t].curST[0] = mVerts[t].ST[0] * perc + mVerts[t].destST[0] * (1.0f - perc);
+ if (mVerts[t].curST[0] > 1.0f) {
mVerts[t].curST[0] = 1.0f;
}
- mVerts[t].curST[1] = mVerts[t].ST[1] * perc + mVerts[t].destST[1] * ( 1.0f - perc );
+ mVerts[t].curST[1] = mVerts[t].ST[1] * perc + mVerts[t].destST[1] * (1.0f - perc);
}
Draw();
@@ -1848,30 +1535,26 @@ bool CTrail::Update()
return true;
}
-
//--------------------------
//
// Derived Poly Class
//
//--------------------------
-bool CPoly::Cull()
-{
- vec3_t dir;
+bool CPoly::Cull() {
+ vec3_t dir;
// Get the direction to the view
- VectorSubtract( mOrigin1, cg.refdef.vieworg, dir );
+ VectorSubtract(mOrigin1, cg.refdef.vieworg, dir);
// Check if it's behind the viewer
- if ( (DotProduct( cg.refdef.viewaxis[0], dir )) < 0 )
- {
+ if ((DotProduct(cg.refdef.viewaxis[0], dir)) < 0) {
return true;
}
- float len = VectorLengthSquared( dir );
+ float len = VectorLengthSquared(dir);
// Can't be too close
- if ( len < 24 * 24 )
- {
+ if (len < 24 * 24) {
return true;
}
@@ -1879,50 +1562,47 @@ bool CPoly::Cull()
}
//----------------------------
-void CPoly::Draw()
-{
- polyVert_t verts[MAX_CPOLY_VERTS];
+void CPoly::Draw() {
+ polyVert_t verts[MAX_CPOLY_VERTS];
- for ( int i = 0; i < mCount; i++ )
- {
+ for (int i = 0; i < mCount; i++) {
// Add our midpoint and vert offset to get the actual vertex
- VectorAdd( mOrigin1, mOrg[i], verts[i].xyz );
+ VectorAdd(mOrigin1, mOrg[i], verts[i].xyz);
// Assign the same color to each vert
- for ( int k=0; k<4; k++ )
+ for (int k = 0; k < 4; k++)
verts[i].modulate[k] = mRefEnt.shaderRGBA[k];
// Copy the ST coords
- VectorCopy2( mST[i], verts[i].st );
+ VectorCopy2(mST[i], verts[i].st);
}
// Add this poly
- theFxHelper.AddPolyToScene( mRefEnt.customShader, mCount, verts );
+ theFxHelper.AddPolyToScene(mRefEnt.customShader, mCount, verts);
drawnFx++;
}
//----------------------------
-void CPoly::CalcRotateMatrix()
-{
- float cosX, cosZ;
- float sinX, sinZ;
- float rad;
+void CPoly::CalcRotateMatrix() {
+ float cosX, cosZ;
+ float sinX, sinZ;
+ float rad;
// rotate around Z
- rad = DEG2RAD( mRotDelta[YAW] * theFxHelper.mFrameTime * 0.01f );
- cosZ = cos( rad );
- sinZ = sin( rad );
+ rad = DEG2RAD(mRotDelta[YAW] * theFxHelper.mFrameTime * 0.01f);
+ cosZ = cos(rad);
+ sinZ = sin(rad);
// rotate around X
- rad = DEG2RAD( mRotDelta[PITCH] * theFxHelper.mFrameTime * 0.01f );
- cosX = cos( rad );
- sinX = sin( rad );
-
-/*Pitch - aroundx Yaw - around z
-1 0 0 c -s 0
-0 c -s s c 0
-0 s c 0 0 1
-*/
+ rad = DEG2RAD(mRotDelta[PITCH] * theFxHelper.mFrameTime * 0.01f);
+ cosX = cos(rad);
+ sinX = sin(rad);
+
+ /*Pitch - aroundx Yaw - around z
+ 1 0 0 c -s 0
+ 0 c -s s c 0
+ 0 s c 0 0 1
+ */
mRot[0][0] = cosZ;
mRot[1][0] = -sinZ;
mRot[2][0] = 0;
@@ -1932,45 +1612,41 @@ void CPoly::CalcRotateMatrix()
mRot[0][2] = sinX * sinZ;
mRot[1][2] = sinX * cosZ;
mRot[2][2] = cosX;
-/*
-// ROLL is not supported unless anyone complains, if it needs to be added, use this format
-Roll
+ /*
+ // ROLL is not supported unless anyone complains, if it needs to be added, use this format
+ Roll
- c 0 s
- 0 1 0
--s 0 c
-*/
+ c 0 s
+ 0 1 0
+ -s 0 c
+ */
mLastFrameTime = theFxHelper.mFrameTime;
}
//--------------------------------
-void CPoly::Rotate()
-{
- vec3_t temp[MAX_CPOLY_VERTS];
- float dif = abs(mLastFrameTime - theFxHelper.mFrameTime);
+void CPoly::Rotate() {
+ vec3_t temp[MAX_CPOLY_VERTS];
+ float dif = abs(mLastFrameTime - theFxHelper.mFrameTime);
// Very generous check with frameTimes
- if ( dif > 0.5f * mLastFrameTime )
- {
+ if (dif > 0.5f * mLastFrameTime) {
CalcRotateMatrix();
}
// Multiply our rotation matrix by each of the offset verts to get their new position
- for ( int i = 0; i < mCount; i++ )
- {
- VectorRotate( mOrg[i], mRot, temp[i] );
- VectorCopy( temp[i], mOrg[i] );
+ for (int i = 0; i < mCount; i++) {
+ VectorRotate(mOrg[i], mRot, temp[i]);
+ VectorCopy(temp[i], mOrg[i]);
}
}
//----------------------------
// Update
//----------------------------
-bool CPoly::Update()
-{
- vec3_t mOldOrigin = { 0.0f };
+bool CPoly::Update() {
+ vec3_t mOldOrigin = {0.0f};
- //FIXME: Handle Relative and Bolted Effects
+ // FIXME: Handle Relative and Bolted Effects
/*
if ( mFlags & FX_RELATIVE )
{
@@ -1986,31 +1662,25 @@ bool CPoly::Update()
}
*/
// Game pausing can cause dumb time things to happen, so kill the effect in this instance
- if ( mTimeStart > theFxHelper.mTime )
- {
+ if (mTimeStart > theFxHelper.mTime) {
return false;
}
// If our timestamp hasn't exired yet, we won't even consider doing any kind of motion
- if ( theFxHelper.mTime > mTimeStamp )
- {
- VectorCopy( mOrigin1, mOldOrigin );
+ if (theFxHelper.mTime > mTimeStamp) {
+ VectorCopy(mOrigin1, mOldOrigin);
- if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
- {
+ if ((mTimeStart < theFxHelper.mTime) && UpdateOrigin() == false) {
// we are marked for death
return false;
}
}
- if ( !Cull() )
- {
+ if (!Cull()) {
// only rotate when our start timestamp has expired
- if ( theFxHelper.mTime > mTimeStamp )
- {
+ if (theFxHelper.mTime > mTimeStamp) {
// Only rotate whilst moving
- if ( !VectorCompare( mOldOrigin, mOrigin1 ))
- {
+ if (!VectorCompare(mOldOrigin, mOrigin1)) {
Rotate();
}
}
@@ -2025,32 +1695,28 @@ bool CPoly::Update()
}
//----------------------------
-void CPoly::PolyInit()
-{
- if ( mCount < 3 )
- {
+void CPoly::PolyInit() {
+ if (mCount < 3) {
return;
}
- int i;
- vec3_t org={0,0,0};
+ int i;
+ vec3_t org = {0, 0, 0};
// Find our midpoint
- for ( i = 0; i < mCount; i++ )
- {
- VectorAdd( org, mOrg[i], org );
+ for (i = 0; i < mCount; i++) {
+ VectorAdd(org, mOrg[i], org);
}
- VectorScale( org, (float)(1.0f / mCount), org );
+ VectorScale(org, (float)(1.0f / mCount), org);
// now store our midpoint for physics purposes
- VectorCopy( org, mOrigin1 );
+ VectorCopy(org, mOrigin1);
// Now we process the passed in points and make it so that they aren't actually the point...
// rather, they are the offset from mOrigin1.
- for ( i = 0; i < mCount; i++ )
- {
- VectorSubtract( mOrg[i], mOrigin1, mOrg[i] );
+ for (i = 0; i < mCount; i++) {
+ VectorSubtract(mOrg[i], mOrigin1, mOrg[i]);
}
CalcRotateMatrix();
@@ -2064,11 +1730,10 @@ Bezier curve line
-------------------------
*/
//----------------------------
-bool CBezier::Update( void )
-{
- float ftime, time2;
+bool CBezier::Update(void) {
+ float ftime, time2;
- //FIXME: Handle Relative and Bolted Effects
+ // FIXME: Handle Relative and Bolted Effects
/*
if ( mFlags & FX_RELATIVE )
{
@@ -2086,8 +1751,7 @@ bool CBezier::Update( void )
ftime = cg.frametime * 0.001f;
time2 = ftime * ftime * 0.5f;
- for ( int i = 0; i < 3; i++ )
- {
+ for (int i = 0; i < 3; i++) {
mControl1[i] = mControl1[i] + ftime * mControl1Vel[i] + time2 * mControl1Vel[i];
mControl2[i] = mControl2[i] + ftime * mControl2Vel[i] + time2 * mControl2Vel[i];
}
@@ -2102,49 +1766,44 @@ bool CBezier::Update( void )
}
//----------------------------
-void CBezier::DrawSegment( vec3_t start, vec3_t end, float texcoord1, float texcoord2 )
-{
- vec3_t lineDir, cross, viewDir;
- static vec3_t lastEnd[2];
- polyVert_t verts[4];
- float scale;
-
- VectorSubtract( end, start, lineDir );
- VectorSubtract( end, cg.refdef.vieworg, viewDir );
- CrossProduct( lineDir, viewDir, cross );
- VectorNormalize( cross );
+void CBezier::DrawSegment(vec3_t start, vec3_t end, float texcoord1, float texcoord2) {
+ vec3_t lineDir, cross, viewDir;
+ static vec3_t lastEnd[2];
+ polyVert_t verts[4];
+ float scale;
+
+ VectorSubtract(end, start, lineDir);
+ VectorSubtract(end, cg.refdef.vieworg, viewDir);
+ CrossProduct(lineDir, viewDir, cross);
+ VectorNormalize(cross);
scale = mRefEnt.radius * 0.5f;
- //Construct the oriented quad
- if ( mInit )
- {
- VectorCopy( lastEnd[0], verts[0].xyz );
- VectorCopy( lastEnd[1], verts[1].xyz );
- }
- else
- {
- VectorMA( start, -scale, cross, verts[0].xyz );
- VectorMA( start, scale, cross, verts[1].xyz );
+ // Construct the oriented quad
+ if (mInit) {
+ VectorCopy(lastEnd[0], verts[0].xyz);
+ VectorCopy(lastEnd[1], verts[1].xyz);
+ } else {
+ VectorMA(start, -scale, cross, verts[0].xyz);
+ VectorMA(start, scale, cross, verts[1].xyz);
}
verts[0].st[0] = 0.0f;
verts[0].st[1] = texcoord1;
- verts[0].modulate[0] = mRefEnt.shaderRGBA[0] * ( 1.0f - texcoord1 );
- verts[0].modulate[1] = mRefEnt.shaderRGBA[1] * ( 1.0f - texcoord1 );
- verts[0].modulate[2] = mRefEnt.shaderRGBA[2] * ( 1.0f - texcoord1 );
+ verts[0].modulate[0] = mRefEnt.shaderRGBA[0] * (1.0f - texcoord1);
+ verts[0].modulate[1] = mRefEnt.shaderRGBA[1] * (1.0f - texcoord1);
+ verts[0].modulate[2] = mRefEnt.shaderRGBA[2] * (1.0f - texcoord1);
verts[0].modulate[3] = mRefEnt.shaderRGBA[3];
verts[1].st[0] = 1.0f;
verts[1].st[1] = texcoord1;
- verts[1].modulate[0] = mRefEnt.shaderRGBA[0] * ( 1.0f - texcoord1 );
- verts[1].modulate[1] = mRefEnt.shaderRGBA[1] * ( 1.0f - texcoord1 );
- verts[1].modulate[2] = mRefEnt.shaderRGBA[2] * ( 1.0f - texcoord1 );
+ verts[1].modulate[0] = mRefEnt.shaderRGBA[0] * (1.0f - texcoord1);
+ verts[1].modulate[1] = mRefEnt.shaderRGBA[1] * (1.0f - texcoord1);
+ verts[1].modulate[2] = mRefEnt.shaderRGBA[2] * (1.0f - texcoord1);
verts[1].modulate[3] = mRefEnt.shaderRGBA[3];
- if ( texcoord1 == 0.0f )
- {
+ if (texcoord1 == 0.0f) {
verts[0].modulate[0] = 0;
verts[0].modulate[1] = 0;
verts[0].modulate[2] = 0;
@@ -2155,83 +1814,80 @@ void CBezier::DrawSegment( vec3_t start, vec3_t end, float texcoord1, float texc
verts[1].modulate[3] = 0;
}
- VectorMA( end, scale, cross, verts[2].xyz );
+ VectorMA(end, scale, cross, verts[2].xyz);
verts[2].st[0] = 1.0f;
verts[2].st[1] = texcoord2;
- verts[2].modulate[0] = mRefEnt.shaderRGBA[0] * ( 1.0f - texcoord2 );
- verts[2].modulate[1] = mRefEnt.shaderRGBA[1] * ( 1.0f - texcoord2 );
- verts[2].modulate[2] = mRefEnt.shaderRGBA[2] * ( 1.0f - texcoord2 );
+ verts[2].modulate[0] = mRefEnt.shaderRGBA[0] * (1.0f - texcoord2);
+ verts[2].modulate[1] = mRefEnt.shaderRGBA[1] * (1.0f - texcoord2);
+ verts[2].modulate[2] = mRefEnt.shaderRGBA[2] * (1.0f - texcoord2);
verts[2].modulate[3] = mRefEnt.shaderRGBA[3];
- VectorMA( end, -scale, cross, verts[3].xyz );
+ VectorMA(end, -scale, cross, verts[3].xyz);
verts[3].st[0] = 0.0f;
verts[3].st[1] = texcoord2;
- verts[3].modulate[0] = mRefEnt.shaderRGBA[0] * ( 1.0f - texcoord2 );
- verts[3].modulate[1] = mRefEnt.shaderRGBA[1] * ( 1.0f - texcoord2 );
- verts[3].modulate[2] = mRefEnt.shaderRGBA[2] * ( 1.0f - texcoord2 );
+ verts[3].modulate[0] = mRefEnt.shaderRGBA[0] * (1.0f - texcoord2);
+ verts[3].modulate[1] = mRefEnt.shaderRGBA[1] * (1.0f - texcoord2);
+ verts[3].modulate[2] = mRefEnt.shaderRGBA[2] * (1.0f - texcoord2);
verts[3].modulate[3] = mRefEnt.shaderRGBA[3];
- cgi_R_AddPolyToScene( mRefEnt.customShader, 4, verts );
+ cgi_R_AddPolyToScene(mRefEnt.customShader, 4, verts);
- VectorCopy( verts[2].xyz, lastEnd[1] );
- VectorCopy( verts[3].xyz, lastEnd[0] );
+ VectorCopy(verts[2].xyz, lastEnd[1]);
+ VectorCopy(verts[3].xyz, lastEnd[0]);
mInit = true;
}
-const float BEZIER_RESOLUTION = 16.0f;
+const float BEZIER_RESOLUTION = 16.0f;
//----------------------------
-void CBezier::Draw( void )
-{
- vec3_t pos, old_pos;
- float mu, mum1;
- float incr = 1.0f / BEZIER_RESOLUTION, tex = 1.0f, tc1, tc2;
- int i;
+void CBezier::Draw(void) {
+ vec3_t pos, old_pos;
+ float mu, mum1;
+ float incr = 1.0f / BEZIER_RESOLUTION, tex = 1.0f, tc1, tc2;
+ int i;
- VectorCopy( mOrigin1, old_pos );
+ VectorCopy(mOrigin1, old_pos);
- mInit = false; //Signify a new batch for vert gluing
+ mInit = false; // Signify a new batch for vert gluing
// Calculate the texture coords so the texture can stretch along the whole bezier
-// if ( mFlags & FXF_WRAP )
-// {
-// tex = m_stScale / 1.0f;
-// }
+ // if ( mFlags & FXF_WRAP )
+ // {
+ // tex = m_stScale / 1.0f;
+ // }
float mum13, mu3, group1, group2;
tc1 = 0.0f;
- for ( mu = incr; mu <= 1.0f; mu += incr )
- {
- //Four point curve
- mum1 = 1 - mu;
- mum13 = mum1 * mum1 * mum1;
- mu3 = mu * mu * mu;
- group1 = 3 * mu * mum1 * mum1;
- group2 = 3 * mu * mu *mum1;
-
- for ( i = 0; i < 3; i++ )
- {
+ for (mu = incr; mu <= 1.0f; mu += incr) {
+ // Four point curve
+ mum1 = 1 - mu;
+ mum13 = mum1 * mum1 * mum1;
+ mu3 = mu * mu * mu;
+ group1 = 3 * mu * mum1 * mum1;
+ group2 = 3 * mu * mu * mum1;
+
+ for (i = 0; i < 3; i++) {
pos[i] = mum13 * mOrigin1[i] + group1 * mControl1[i] + group2 * mControl2[i] + mu3 * mOrigin2[i];
}
-// if ( m_flags & FXF_WRAP )
-// {
- tc2 = mu * tex;
-// }
-// else
-// {
-// // Texture will get mapped onto each segement
-// tc1 = 0.0f;
-// tc2 = 1.0f;
-// }
-
- //Draw it
- DrawSegment( old_pos, pos, tc1, tc2 );
-
- VectorCopy( pos, old_pos );
+ // if ( m_flags & FXF_WRAP )
+ // {
+ tc2 = mu * tex;
+ // }
+ // else
+ // {
+ // // Texture will get mapped onto each segement
+ // tc1 = 0.0f;
+ // tc2 = 1.0f;
+ // }
+
+ // Draw it
+ DrawSegment(old_pos, pos, tc1, tc2);
+
+ VectorCopy(pos, old_pos);
tc1 = tc2;
}
@@ -2248,8 +1904,7 @@ Full screen flash
*/
//----------------------------
-bool CFlash::Update( void )
-{
+bool CFlash::Update(void) {
UpdateRGB();
Draw();
@@ -2257,48 +1912,39 @@ bool CFlash::Update( void )
}
//----------------------------
-void CFlash::Init( void )
-{
- vec3_t dif;
- float mod = 1.0f, dis;
+void CFlash::Init(void) {
+ vec3_t dif;
+ float mod = 1.0f, dis;
- VectorSubtract( mOrigin1, cg.refdef.vieworg, dif );
- dis = VectorNormalize( dif );
+ VectorSubtract(mOrigin1, cg.refdef.vieworg, dif);
+ dis = VectorNormalize(dif);
- mod = DotProduct( dif, cg.refdef.viewaxis[0] );
+ mod = DotProduct(dif, cg.refdef.viewaxis[0]);
- if ( dis > 600 || ( mod < 0.5f && dis > 100 ))
- {
+ if (dis > 600 || (mod < 0.5f && dis > 100)) {
mod = 0.0f;
- }
- else if ( mod < 0.5f && dis <= 100 )
- {
+ } else if (mod < 0.5f && dis <= 100) {
mod += 1.1f;
}
mod *= (1.0f - ((dis * dis) / (600.0f * 600.0f)));
- VectorScale( mRGBStart, mod, mRGBStart );
- VectorScale( mRGBEnd, mod, mRGBEnd );
+ VectorScale(mRGBStart, mod, mRGBStart);
+ VectorScale(mRGBEnd, mod, mRGBEnd);
}
//----------------------------
-void CFlash::Draw( void )
-{
- // Interestingly, if znear is set > than this, then the flash
- // doesn't appear at all.
- const float FLASH_DISTANCE_FROM_VIEWER = 8.0f;
+void CFlash::Draw(void) {
+ // Interestingly, if znear is set > than this, then the flash
+ // doesn't appear at all.
+ const float FLASH_DISTANCE_FROM_VIEWER = 8.0f;
mRefEnt.reType = RT_SPRITE;
- for ( int i = 0; i < 3; i++ )
- {
- if ( mRefEnt.lightingOrigin[i] > 1.0f )
- {
+ for (int i = 0; i < 3; i++) {
+ if (mRefEnt.lightingOrigin[i] > 1.0f) {
mRefEnt.lightingOrigin[i] = 1.0f;
- }
- else if ( mRefEnt.lightingOrigin[i] < 0.0f )
- {
+ } else if (mRefEnt.lightingOrigin[i] < 0.0f) {
mRefEnt.lightingOrigin[i] = 0.0f;
}
}
@@ -2307,13 +1953,13 @@ void CFlash::Draw( void )
mRefEnt.shaderRGBA[2] = mRefEnt.lightingOrigin[2] * 255;
mRefEnt.shaderRGBA[3] = 255;
- VectorCopy( cg.refdef.vieworg, mRefEnt.origin );
- VectorMA( mRefEnt.origin, FLASH_DISTANCE_FROM_VIEWER, cg.refdef.viewaxis[0], mRefEnt.origin );
+ VectorCopy(cg.refdef.vieworg, mRefEnt.origin);
+ VectorMA(mRefEnt.origin, FLASH_DISTANCE_FROM_VIEWER, cg.refdef.viewaxis[0], mRefEnt.origin);
- // This is assuming that the screen is wider than it is tall.
- mRefEnt.radius = FLASH_DISTANCE_FROM_VIEWER * tan (DEG2RAD (cg.refdef.fov_x * 0.5f));
+ // This is assuming that the screen is wider than it is tall.
+ mRefEnt.radius = FLASH_DISTANCE_FROM_VIEWER * tan(DEG2RAD(cg.refdef.fov_x * 0.5f));
- theFxHelper.AddFxToScene( &mRefEnt );
+ theFxHelper.AddFxToScene(&mRefEnt);
drawnFx++;
}
diff --git a/code/cgame/FxScheduler.cpp b/code/cgame/FxScheduler.cpp
index 2b91ef1871..b27ef7055b 100644
--- a/code/cgame/FxScheduler.cpp
+++ b/code/cgame/FxScheduler.cpp
@@ -22,63 +22,55 @@ along with this program; if not, see .
#include "common_headers.h"
-
#if !defined(FX_SCHEDULER_H_INC)
- #include "FxScheduler.h"
+#include "FxScheduler.h"
#endif
#if !defined(GHOUL2_SHARED_H_INC)
- #include "../game/ghoul2_shared.h" //for CGhoul2Info_v
+#include "../game/ghoul2_shared.h" //for CGhoul2Info_v
#endif
#if !defined(G2_H_INC)
- #include "../ghoul2/G2.h"
+#include "../ghoul2/G2.h"
#endif
#if !defined(__Q_SHARED_H)
- #include "../qcommon/q_shared.h"
+#include "../qcommon/q_shared.h"
#endif
#include "qcommon/safe/string.h"
#include
#include "qcommon/ojk_saved_game_helper.h"
-CFxScheduler theFxScheduler;
+CFxScheduler theFxScheduler;
// don't even ask,. it's to do with loadsave...
//
-std::vector < sstring_t > g_vstrEffectsNeededPerSlot;
-SLoopedEffect gLoopedEffectArray[MAX_LOOPED_FX]; // must be in sync with CFxScheduler::mLoopedEffectArray
-void CFxScheduler::FX_CopeWithAnyLoadedSaveGames(void)
-{
- if ( !g_vstrEffectsNeededPerSlot.empty() )
- {
- memcpy( mLoopedEffectArray, gLoopedEffectArray, sizeof(mLoopedEffectArray) );
- assert( g_vstrEffectsNeededPerSlot.size() == MAX_LOOPED_FX );
-
- for (size_t iFX = 0; iFX < g_vstrEffectsNeededPerSlot.size(); iFX++)
- {
+std::vector g_vstrEffectsNeededPerSlot;
+SLoopedEffect gLoopedEffectArray[MAX_LOOPED_FX]; // must be in sync with CFxScheduler::mLoopedEffectArray
+void CFxScheduler::FX_CopeWithAnyLoadedSaveGames(void) {
+ if (!g_vstrEffectsNeededPerSlot.empty()) {
+ memcpy(mLoopedEffectArray, gLoopedEffectArray, sizeof(mLoopedEffectArray));
+ assert(g_vstrEffectsNeededPerSlot.size() == MAX_LOOPED_FX);
+
+ for (size_t iFX = 0; iFX < g_vstrEffectsNeededPerSlot.size(); iFX++) {
const char *psFX_Filename = g_vstrEffectsNeededPerSlot[iFX].c_str();
- if ( psFX_Filename[0] )
- {
+ if (psFX_Filename[0]) {
// register it...
//
- mLoopedEffectArray[ iFX ].mId = RegisterEffect( psFX_Filename );
+ mLoopedEffectArray[iFX].mId = RegisterEffect(psFX_Filename);
//
// cope with any relative stop time...
//
- if ( mLoopedEffectArray[ iFX ].mLoopStopTime )
- {
- mLoopedEffectArray[ iFX ].mLoopStopTime -= mLoopedEffectArray[ iFX ].mNextTime;
+ if (mLoopedEffectArray[iFX].mLoopStopTime) {
+ mLoopedEffectArray[iFX].mLoopStopTime -= mLoopedEffectArray[iFX].mNextTime;
}
//
// and finally reset the time to be the newly-zeroed game time...
//
- mLoopedEffectArray[ iFX ].mNextTime = 0; // otherwise it won't process until game time catches up
- }
- else
- {
- mLoopedEffectArray[ iFX ].mId = 0;
+ mLoopedEffectArray[iFX].mNextTime = 0; // otherwise it won't process until game time catches up
+ } else {
+ mLoopedEffectArray[iFX].mId = 0;
}
}
@@ -86,62 +78,42 @@ void CFxScheduler::FX_CopeWithAnyLoadedSaveGames(void)
}
}
-void FX_CopeWithAnyLoadedSaveGames(void)
-{
- theFxScheduler.FX_CopeWithAnyLoadedSaveGames();
-}
+void FX_CopeWithAnyLoadedSaveGames(void) { theFxScheduler.FX_CopeWithAnyLoadedSaveGames(); }
// for loadsave...
//
-void FX_Read( void )
-{
- theFxScheduler.LoadSave_Read();
-}
+void FX_Read(void) { theFxScheduler.LoadSave_Read(); }
// for loadsave...
//
-void FX_Write( void )
-{
- theFxScheduler.LoadSave_Write();
-}
+void FX_Write(void) { theFxScheduler.LoadSave_Write(); }
-void CFxScheduler::LoadSave_Read()
-{
- Clean(); // need to get rid of old pre-cache handles, or it thinks it has some older effects when it doesn't
- g_vstrEffectsNeededPerSlot.clear(); // jic
+void CFxScheduler::LoadSave_Read() {
+ Clean(); // need to get rid of old pre-cache handles, or it thinks it has some older effects when it doesn't
+ g_vstrEffectsNeededPerSlot.clear(); // jic
- ojk::SavedGameHelper saved_game(
- ::gi.saved_game);
+ ojk::SavedGameHelper saved_game(::gi.saved_game);
- saved_game.read_chunk(
- INT_ID('F', 'X', 'L', 'E'),
- ::gLoopedEffectArray);
+ saved_game.read_chunk(INT_ID('F', 'X', 'L', 'E'), ::gLoopedEffectArray);
//
// now read in and re-register the effects we need for those structs...
//
- for (int iFX = 0; iFX < MAX_LOOPED_FX; iFX++)
- {
+ for (int iFX = 0; iFX < MAX_LOOPED_FX; iFX++) {
char sFX_Filename[MAX_QPATH];
- saved_game.read_chunk(
- INT_ID('F', 'X', 'F', 'N'),
- sFX_Filename);
+ saved_game.read_chunk(INT_ID('F', 'X', 'F', 'N'), sFX_Filename);
- g_vstrEffectsNeededPerSlot.push_back( sFX_Filename );
+ g_vstrEffectsNeededPerSlot.push_back(sFX_Filename);
}
}
-void CFxScheduler::LoadSave_Write()
-{
- ojk::SavedGameHelper saved_game(
- ::gi.saved_game);
+void CFxScheduler::LoadSave_Write() {
+ ojk::SavedGameHelper saved_game(::gi.saved_game);
// bsave the data we need...
//
- saved_game.write_chunk(
- INT_ID('F', 'X', 'L', 'E'),
- mLoopedEffectArray);
+ saved_game.write_chunk(INT_ID('F', 'X', 'L', 'E'), mLoopedEffectArray);
//
// then cope with the fact that the mID field in each struct of the array we've just saved will not
@@ -151,22 +123,19 @@ void CFxScheduler::LoadSave_Write()
// since this is only for savegames, and I've got < 2 hours to finish this and test it I'm going to be lazy
// with the ondisk data... (besides, the RLE compression will kill most of this anyway)
//
- for (int iFX = 0; iFX < MAX_LOOPED_FX; iFX++)
- {
+ for (int iFX = 0; iFX < MAX_LOOPED_FX; iFX++) {
char sFX_Filename[MAX_QPATH];
- memset(sFX_Filename,0,sizeof(sFX_Filename)); // instead of "sFX_Filename[0]=0;" so RLE will squash whole array to nothing, not just stop at '\0' then have old crap after it to compress
+ memset(sFX_Filename, 0, sizeof(sFX_Filename)); // instead of "sFX_Filename[0]=0;" so RLE will squash whole array to nothing, not just stop at '\0' then
+ // have old crap after it to compress
- int &iID = mLoopedEffectArray[ iFX ].mId;
- if ( iID )
- {
+ int &iID = mLoopedEffectArray[iFX].mId;
+ if (iID) {
// now we need to look up what string this represents, unfortunately the existing
// lookup table is backwards (keywise) for our needs, so parse the whole thing...
//
- for (TEffectID::iterator it = mEffectIDs.begin(); it != mEffectIDs.end(); ++it)
- {
- if ( (*it).second == iID )
- {
- Q_strncpyz( sFX_Filename, (*it).first.c_str(), sizeof(sFX_Filename) );
+ for (TEffectID::iterator it = mEffectIDs.begin(); it != mEffectIDs.end(); ++it) {
+ if ((*it).second == iID) {
+ Q_strncpyz(sFX_Filename, (*it).first.c_str(), sizeof(sFX_Filename));
break;
}
}
@@ -174,45 +143,34 @@ void CFxScheduler::LoadSave_Write()
// write out this string...
//
- saved_game.write_chunk(
- INT_ID('F', 'X', 'F', 'N'),
- sFX_Filename);
+ saved_game.write_chunk(INT_ID('F', 'X', 'F', 'N'), sFX_Filename);
}
}
-
//-----------------------------------------------------------
-void CMediaHandles::operator=(const CMediaHandles &that )
-{
+void CMediaHandles::operator=(const CMediaHandles &that) {
mMediaList.clear();
- for ( size_t i = 0; i < that.mMediaList.size(); i++ )
- {
- mMediaList.push_back( that.mMediaList[i] );
+ for (size_t i = 0; i < that.mMediaList.size(); i++) {
+ mMediaList.push_back(that.mMediaList[i]);
}
}
//------------------------------------------------------
-CFxScheduler::CFxScheduler()
-{
- memset( &mEffectTemplates, 0, sizeof( mEffectTemplates ));
- memset( &mLoopedEffectArray, 0, sizeof( mLoopedEffectArray ));
+CFxScheduler::CFxScheduler() {
+ memset(&mEffectTemplates, 0, sizeof(mEffectTemplates));
+ memset(&mLoopedEffectArray, 0, sizeof(mLoopedEffectArray));
}
-int CFxScheduler::ScheduleLoopedEffect( int id, int boltInfo, bool isPortal, int iLoopTime, bool isRelative )
-{
+int CFxScheduler::ScheduleLoopedEffect(int id, int boltInfo, bool isPortal, int iLoopTime, bool isRelative) {
int i;
assert(id);
- assert(boltInfo!=-1);
+ assert(boltInfo != -1);
- for (i=0;i> ENTITY_SHIFT ) & ENTITY_AND;
- if ( cg_entities[entNum].gent->inuse )
- {// only play the looped effect when the ent is still inUse....
- PlayEffect( mLoopedEffectArray[i].mId, cg_entities[entNum].lerpOrigin, 0, mLoopedEffectArray[i].mBoltInfo, -1, mLoopedEffectArray[i].mPortalEffect, false, mLoopedEffectArray[i].mIsRelative ); //very important to send FALSE looptime to not recursively add me!
+ for (i = 0; i < MAX_LOOPED_FX; i++) {
+ if (mLoopedEffectArray[i].mId && mLoopedEffectArray[i].mNextTime < theFxHelper.mTime) {
+ const int entNum = (mLoopedEffectArray[i].mBoltInfo >> ENTITY_SHIFT) & ENTITY_AND;
+ if (cg_entities[entNum].gent->inuse) { // only play the looped effect when the ent is still inUse....
+ PlayEffect(mLoopedEffectArray[i].mId, cg_entities[entNum].lerpOrigin, 0, mLoopedEffectArray[i].mBoltInfo, -1,
+ mLoopedEffectArray[i].mPortalEffect, false,
+ mLoopedEffectArray[i].mIsRelative); // very important to send FALSE looptime to not recursively add me!
mLoopedEffectArray[i].mNextTime = theFxHelper.mTime + mEffectTemplates[mLoopedEffectArray[i].mId].mRepeatDelay;
- }
- else
- {
- theFxHelper.Print( "CFxScheduler::AddLoopedEffects- entity was removed without stopping any looping fx it owned." );
- memset( &mLoopedEffectArray[i], 0, sizeof(mLoopedEffectArray[i]) );
+ } else {
+ theFxHelper.Print("CFxScheduler::AddLoopedEffects- entity was removed without stopping any looping fx it owned.");
+ memset(&mLoopedEffectArray[i], 0, sizeof(mLoopedEffectArray[i]));
continue;
}
- if ( mLoopedEffectArray[i].mLoopStopTime && mLoopedEffectArray[i].mLoopStopTime < theFxHelper.mTime ) //time's up
- {//kill this entry
- memset( &mLoopedEffectArray[i], 0, sizeof(mLoopedEffectArray[i]) );
+ if (mLoopedEffectArray[i].mLoopStopTime && mLoopedEffectArray[i].mLoopStopTime < theFxHelper.mTime) // time's up
+ { // kill this entry
+ memset(&mLoopedEffectArray[i], 0, sizeof(mLoopedEffectArray[i]));
}
}
}
-
}
//-----------------------------------------------------------
-void SEffectTemplate::operator=(const SEffectTemplate &that)
-{
+void SEffectTemplate::operator=(const SEffectTemplate &that) {
mCopy = true;
- strcpy( mEffectName, that.mEffectName );
+ strcpy(mEffectName, that.mEffectName);
mPrimitiveCount = that.mPrimitiveCount;
- for( int i = 0; i < mPrimitiveCount; i++ )
- {
+ for (int i = 0; i < mPrimitiveCount; i++) {
mPrimitives[i] = new CPrimitiveTemplate;
*(mPrimitives[i]) = *(that.mPrimitives[i]);
// Mark use as a copy so that we know that we should be chucked when used up
@@ -336,40 +277,33 @@ void SEffectTemplate::operator=(const SEffectTemplate &that)
// None
//
//------------------------------------------------------
-void CFxScheduler::Clean(bool bRemoveTemplates /*= true*/, int idToPreserve /*= 0*/)
-{
- int i, j;
- TScheduledEffect::iterator itr, next;
+void CFxScheduler::Clean(bool bRemoveTemplates /*= true*/, int idToPreserve /*= 0*/) {
+ int i, j;
+ TScheduledEffect::iterator itr, next;
// Ditch any scheduled effects
itr = mFxSchedule.begin();
- while ( itr != mFxSchedule.end() )
- {
+ while (itr != mFxSchedule.end()) {
next = itr;
++next;
- mScheduledEffectsPool.Free (*itr);
+ mScheduledEffectsPool.Free(*itr);
mFxSchedule.erase(itr);
itr = next;
}
- if (bRemoveTemplates)
- {
+ if (bRemoveTemplates) {
// Ditch any effect templates
- for ( i = 1; i < FX_MAX_EFFECTS; i++ )
- {
- if ( i == idToPreserve)
- {
+ for (i = 1; i < FX_MAX_EFFECTS; i++) {
+ if (i == idToPreserve) {
continue;
}
- if ( mEffectTemplates[i].mInUse )
- {
+ if (mEffectTemplates[i].mInUse) {
// Ditch the primitives
- for (j = 0; j < mEffectTemplates[i].mPrimitiveCount; j++)
- {
+ for (j = 0; j < mEffectTemplates[i].mPrimitiveCount; j++) {
delete mEffectTemplates[i].mPrimitives[j];
}
}
@@ -377,21 +311,16 @@ void CFxScheduler::Clean(bool bRemoveTemplates /*= true*/, int idToPreserve /*=
mEffectTemplates[i].mInUse = false;
}
- if (idToPreserve == 0)
- {
+ if (idToPreserve == 0) {
mEffectIDs.clear();
- }
- else
- {
+ } else {
// Clear the effect names, but first get the name of the effect to preserve,
// and restore it after clearing.
fxString_t str;
TEffectID::iterator iter;
- for (iter = mEffectIDs.begin(); iter != mEffectIDs.end(); ++iter)
- {
- if ((*iter).second == idToPreserve)
- {
+ for (iter = mEffectIDs.begin(); iter != mEffectIDs.end(); ++iter) {
+ if ((*iter).second == idToPreserve) {
str = (*iter).first;
break;
}
@@ -415,80 +344,67 @@ void CFxScheduler::Clean(bool bRemoveTemplates /*= true*/, int idToPreserve /*=
// Return:
// int handle to the effect
//------------------------------------------------------
-int CFxScheduler::RegisterEffect( const char *path, bool bHasCorrectPath /*= false*/ )
-{
+int CFxScheduler::RegisterEffect(const char *path, bool bHasCorrectPath /*= false*/) {
// Dealing with file names:
// File names can come from two places - the editor, in which case we should use the given
// path as is, and the effect file, in which case we should add the correct path and extension.
// In either case we create a stripped file name to use for naming effects.
//
- // FIXME: this could maybe be a cstring_view, if mEffectIDs were to use a transparent comparator, but those were only added in C++14, which we don't support yet (sigh)
+ // FIXME: this could maybe be a cstring_view, if mEffectIDs were to use a transparent comparator, but those were only added in C++14, which we don't support
+ // yet (sigh)
char filenameNoExt[MAX_QPATH];
// Get an extension stripped version of the file
- if (bHasCorrectPath)
- {
+ if (bHasCorrectPath) {
// FIXME: this is basically COM_SkipPath, except it also accepts '\\' instead of '/'
const char *last = path, *p = path;
- while (*p != '\0')
- {
- if ((*p == '/') || (*p == '\\'))
- {
+ while (*p != '\0') {
+ if ((*p == '/') || (*p == '\\')) {
last = p + 1;
}
p++;
}
- COM_StripExtension( last, filenameNoExt, sizeof( filenameNoExt ) );
- }
- else
- {
- COM_StripExtension( path, filenameNoExt, sizeof( filenameNoExt ) );
+ COM_StripExtension(last, filenameNoExt, sizeof(filenameNoExt));
+ } else {
+ COM_StripExtension(path, filenameNoExt, sizeof(filenameNoExt));
}
// see if the specified file is already registered. If it is, just return the id of that file
TEffectID::iterator itr;
- itr = mEffectIDs.find( filenameNoExt );
+ itr = mEffectIDs.find(filenameNoExt);
- if ( itr != mEffectIDs.end() )
- {
+ if (itr != mEffectIDs.end()) {
return (*itr).second;
}
- char correctFilenameBuffer[MAX_QPATH];
- const char *pfile;
- if (bHasCorrectPath)
- {
+ char correctFilenameBuffer[MAX_QPATH];
+ const char *pfile;
+ if (bHasCorrectPath) {
pfile = path;
- }
- else
- {
+ } else {
// Add on our extension and prepend the file with the default path
- Com_sprintf( correctFilenameBuffer, sizeof( correctFilenameBuffer ), "%s/%s.efx", FX_FILE_PATH, filenameNoExt );
+ Com_sprintf(correctFilenameBuffer, sizeof(correctFilenameBuffer), "%s/%s.efx", FX_FILE_PATH, filenameNoExt);
pfile = correctFilenameBuffer;
}
// Let the generic parser process the whole file
- CGenericParser2 parser;
- if( !parser.Parse( pfile ) )
- {
- if( !parser.ValidFile() )
- {
- theFxHelper.Print( "RegisterEffect: INVALID file: %s\n", pfile );
+ CGenericParser2 parser;
+ if (!parser.Parse(pfile)) {
+ if (!parser.ValidFile()) {
+ theFxHelper.Print("RegisterEffect: INVALID file: %s\n", pfile);
}
return false;
- if( parser.ValidFile() )
- {
+ if (parser.ValidFile()) {
return false;
}
}
// Lets convert the effect file into something that we can work with
- return ParseEffect( filenameNoExt, parser.GetBaseParseGroup() );
+ return ParseEffect(filenameNoExt, parser.GetBaseParseGroup());
}
-
//------------------------------------------------------
// ParseEffect
// Starts at ground zero, using each group header to
@@ -503,59 +419,43 @@ int CFxScheduler::RegisterEffect( const char *path, bool bHasCorrectPath /*= fal
// int handle of the effect
//------------------------------------------------------
-int CFxScheduler::ParseEffect( const char *file, const CGPGroup& base )
-{
+int CFxScheduler::ParseEffect(const char *file, const CGPGroup &base) {
int handle;
- SEffectTemplate* effect = GetNewEffectTemplate( &handle, file );
+ SEffectTemplate *effect = GetNewEffectTemplate(&handle, file);
- if ( !handle || !effect )
- {
+ if (!handle || !effect) {
// failure
return 0;
}
- for( auto& property : base.GetProperties() )
- {
- if( Q::stricmp( property.GetName(), CSTRING_VIEW( "repeatDelay" ) ) == Q::Ordering::EQ )
- {
- effect->mRepeatDelay = Q::svtoi( property.GetTopValue() );
+ for (auto &property : base.GetProperties()) {
+ if (Q::stricmp(property.GetName(), CSTRING_VIEW("repeatDelay")) == Q::Ordering::EQ) {
+ effect->mRepeatDelay = Q::svtoi(property.GetTopValue());
}
}
- for( const auto& primitiveGroup : base.GetSubGroups() )
- {
- static std::map< gsl::cstring_span, EPrimType, Q::CStringViewILess > primitiveTypes{
- { CSTRING_VIEW( "particle" ), Particle },
- { CSTRING_VIEW( "line" ), Line },
- { CSTRING_VIEW( "tail" ), Tail },
- { CSTRING_VIEW( "sound" ), Sound },
- { CSTRING_VIEW( "cylinder" ), Cylinder },
- { CSTRING_VIEW( "electricity" ), Electricity },
- { CSTRING_VIEW( "emitter" ), Emitter },
- { CSTRING_VIEW( "decal" ), Decal },
- { CSTRING_VIEW( "orientedparticle" ), OrientedParticle },
- { CSTRING_VIEW( "fxrunner" ), FxRunner },
- { CSTRING_VIEW( "light" ), Light },
- { CSTRING_VIEW( "cameraShake" ), CameraShake },
- { CSTRING_VIEW( "flash" ), ScreenFlash }
- };
- auto pos = primitiveTypes.find( primitiveGroup.GetName() );
- if( pos != primitiveTypes.end() )
- {
+ for (const auto &primitiveGroup : base.GetSubGroups()) {
+ static std::map primitiveTypes{
+ {CSTRING_VIEW("particle"), Particle}, {CSTRING_VIEW("line"), Line}, {CSTRING_VIEW("tail"), Tail},
+ {CSTRING_VIEW("sound"), Sound}, {CSTRING_VIEW("cylinder"), Cylinder}, {CSTRING_VIEW("electricity"), Electricity},
+ {CSTRING_VIEW("emitter"), Emitter}, {CSTRING_VIEW("decal"), Decal}, {CSTRING_VIEW("orientedparticle"), OrientedParticle},
+ {CSTRING_VIEW("fxrunner"), FxRunner}, {CSTRING_VIEW("light"), Light}, {CSTRING_VIEW("cameraShake"), CameraShake},
+ {CSTRING_VIEW("flash"), ScreenFlash}};
+ auto pos = primitiveTypes.find(primitiveGroup.GetName());
+ if (pos != primitiveTypes.end()) {
CPrimitiveTemplate *prim = new CPrimitiveTemplate;
prim->mType = pos->second;
- prim->ParsePrimitive( primitiveGroup );
+ prim->ParsePrimitive(primitiveGroup);
// Add our primitive template to the effect list
- AddPrimitiveToEffect( effect, prim );
+ AddPrimitiveToEffect(effect, prim);
}
}
return handle;
}
-
//------------------------------------------------------
// AddPrimitiveToEffect
// Takes a primitive and attaches it to the effect.
@@ -567,16 +467,12 @@ int CFxScheduler::ParseEffect( const char *file, const CGPGroup& base )
// Return:
// None
//------------------------------------------------------
-void CFxScheduler::AddPrimitiveToEffect( SEffectTemplate *fx, CPrimitiveTemplate *prim )
-{
+void CFxScheduler::AddPrimitiveToEffect(SEffectTemplate *fx, CPrimitiveTemplate *prim) {
int ct = fx->mPrimitiveCount;
- if ( ct >= FX_MAX_EFFECT_COMPONENTS )
- {
- theFxHelper.Print( "FxScheduler: Error--too many primitives in an effect\n" );
- }
- else
- {
+ if (ct >= FX_MAX_EFFECT_COMPONENTS) {
+ theFxHelper.Print("FxScheduler: Error--too many primitives in an effect\n");
+ } else {
fx->mPrimitives[ct] = prim;
fx->mPrimitiveCount++;
}
@@ -594,25 +490,21 @@ void CFxScheduler::AddPrimitiveToEffect( SEffectTemplate *fx, CPrimitiveTemplate
// Return:
// the id of the added effect template
//------------------------------------------------------
-SEffectTemplate *CFxScheduler::GetNewEffectTemplate( int *id, const char *file )
-{
+SEffectTemplate *CFxScheduler::GetNewEffectTemplate(int *id, const char *file) {
SEffectTemplate *effect;
// wanted zero to be a bogus effect ID, so we just skip it.
- for ( int i = 1; i < FX_MAX_EFFECTS; i++ )
- {
+ for (int i = 1; i < FX_MAX_EFFECTS; i++) {
effect = &mEffectTemplates[i];
- if ( !effect->mInUse )
- {
+ if (!effect->mInUse) {
*id = i;
- memset( effect, 0, sizeof( SEffectTemplate ));
+ memset(effect, 0, sizeof(SEffectTemplate));
// If we are a copy, we really won't have a name that we care about saving for later
- if ( file )
- {
+ if (file) {
mEffectIDs[file] = i;
- strcpy( effect->mEffectName, file );
+ strcpy(effect->mEffectName, file);
}
effect->mInUse = true;
@@ -621,7 +513,7 @@ SEffectTemplate *CFxScheduler::GetNewEffectTemplate( int *id, const char *file )
}
}
- theFxHelper.Print( "FxScheduler: Error--reached max effects\n" );
+ theFxHelper.Print("FxScheduler: Error--reached max effects\n");
*id = 0;
return nullptr;
}
@@ -639,10 +531,7 @@ SEffectTemplate *CFxScheduler::GetNewEffectTemplate( int *id, const char *file )
// Return:
// the pointer to the copy
//------------------------------------------------------
-SEffectTemplate *CFxScheduler::GetEffectCopy( const char *file, int *newHandle )
-{
- return ( GetEffectCopy( mEffectIDs[file], newHandle ) );
-}
+SEffectTemplate *CFxScheduler::GetEffectCopy(const char *file, int *newHandle) { return (GetEffectCopy(mEffectIDs[file], newHandle)); }
//------------------------------------------------------
// GetEffectCopy
@@ -657,28 +546,24 @@ SEffectTemplate *CFxScheduler::GetEffectCopy( const char *file, int *newHandle )
// Return:
// the pointer to the copy
//------------------------------------------------------
-SEffectTemplate *CFxScheduler::GetEffectCopy( int fxHandle, int *newHandle )
-{
- if ( fxHandle < 1 || fxHandle >= FX_MAX_EFFECTS || !mEffectTemplates[fxHandle].mInUse )
- {
+SEffectTemplate *CFxScheduler::GetEffectCopy(int fxHandle, int *newHandle) {
+ if (fxHandle < 1 || fxHandle >= FX_MAX_EFFECTS || !mEffectTemplates[fxHandle].mInUse) {
// Didn't even request a valid effect to copy!!!
- theFxHelper.Print( "FxScheduler: Bad effect file copy request\n" );
+ theFxHelper.Print("FxScheduler: Bad effect file copy request\n");
*newHandle = 0;
return 0;
}
// never get a copy when time is frozen
- if ( fx_freeze.integer )
- {
+ if (fx_freeze.integer) {
return 0;
}
// Copies shouldn't have names, otherwise they could trash our stl map used for getting ID from name
- SEffectTemplate *copy = GetNewEffectTemplate( newHandle, NULL );
+ SEffectTemplate *copy = GetNewEffectTemplate(newHandle, NULL);
- if ( copy && *newHandle )
- {
+ if (copy && *newHandle) {
// do the effect copy and mark us as what we are
*copy = mEffectTemplates[fxHandle];
copy->mCopy = true;
@@ -703,17 +588,13 @@ SEffectTemplate *CFxScheduler::GetEffectCopy( int fxHandle, int *newHandle )
// Return:
// the pointer to the desired primitive
//------------------------------------------------------
-CPrimitiveTemplate *CFxScheduler::GetPrimitiveCopy( SEffectTemplate *effectCopy, const char *componentName )
-{
- if ( !effectCopy || !effectCopy->mInUse )
- {
+CPrimitiveTemplate *CFxScheduler::GetPrimitiveCopy(SEffectTemplate *effectCopy, const char *componentName) {
+ if (!effectCopy || !effectCopy->mInUse) {
return NULL;
}
- for ( int i = 0; i < effectCopy->mPrimitiveCount; i++ )
- {
- if ( !Q_stricmp( effectCopy->mPrimitives[i]->mName, componentName ))
- {
+ for (int i = 0; i < effectCopy->mPrimitiveCount; i++) {
+ if (!Q_stricmp(effectCopy->mPrimitives[i]->mName, componentName)) {
// we found a match, so return it
return effectCopy->mPrimitives[i];
}
@@ -724,14 +605,12 @@ CPrimitiveTemplate *CFxScheduler::GetPrimitiveCopy( SEffectTemplate *effectCopy,
}
//------------------------------------------------------
-static void ReportPlayEffectError(int id)
-{
+static void ReportPlayEffectError(int id) {
#ifdef _DEBUG
- theFxHelper.Print( "CFxScheduler::PlayEffect called with invalid effect ID: %i\n", id );
+ theFxHelper.Print("CFxScheduler::PlayEffect called with invalid effect ID: %i\n", id);
#endif
}
-
//------------------------------------------------------
// PlayEffect
// Handles scheduling an effect so all the components
@@ -744,15 +623,14 @@ static void ReportPlayEffectError(int id)
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( int id, vec3_t origin, bool isPortal )
-{
- vec3_t axis[3];
+void CFxScheduler::PlayEffect(int id, vec3_t origin, bool isPortal) {
+ vec3_t axis[3];
- VectorSet( axis[0], 0, 0, 1 );
- VectorSet( axis[1], 1, 0, 0 );
- VectorSet( axis[2], 0, 1, 0 );
+ VectorSet(axis[0], 0, 0, 1);
+ VectorSet(axis[1], 1, 0, 0);
+ VectorSet(axis[2], 0, 1, 0);
- PlayEffect( id, origin, axis, -1, -1, isPortal );
+ PlayEffect(id, origin, axis, -1, -1, isPortal);
}
//------------------------------------------------------
@@ -767,15 +645,14 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, bool isPortal )
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t forward, bool isPortal )
-{
- vec3_t axis[3];
+void CFxScheduler::PlayEffect(int id, vec3_t origin, vec3_t forward, bool isPortal) {
+ vec3_t axis[3];
// Take the forward vector and create two arbitrary but perpendicular vectors
- VectorCopy( forward, axis[0] );
- MakeNormalVectors( forward, axis[1], axis[2] );
+ VectorCopy(forward, axis[0]);
+ MakeNormalVectors(forward, axis[1], axis[2]);
- PlayEffect( id, origin, axis, -1, -1, isPortal );
+ PlayEffect(id, origin, axis, -1, -1, isPortal);
}
//------------------------------------------------------
@@ -791,29 +668,27 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t forward, bool isPor
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( const char *file, vec3_t origin, vec3_t axis[3], const int boltInfo, const int entNum, bool isPortal, int iLoopTime, bool isRelative )
-{
- char sfile[MAX_QPATH];
+void CFxScheduler::PlayEffect(const char *file, vec3_t origin, vec3_t axis[3], const int boltInfo, const int entNum, bool isPortal, int iLoopTime,
+ bool isRelative) {
+ char sfile[MAX_QPATH];
// Get an extenstion stripped version of the file
- COM_StripExtension( file, sfile, sizeof(sfile) );
+ COM_StripExtension(file, sfile, sizeof(sfile));
// This is a horribly dumb thing to have to do, but QuakeIII might not have calc'd the lerpOrigin
// for the entity we may be trying to bolt onto. We like having the correct origin, so we are
// forced to call this function....
- if ( entNum > -1 )
- {
- CG_CalcEntityLerpPositions( &cg_entities[entNum] );
+ if (entNum > -1) {
+ CG_CalcEntityLerpPositions(&cg_entities[entNum]);
}
#ifndef FINAL_BUILD
- if ( mEffectIDs[sfile] == 0 )
- {
- theFxHelper.Print( "CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", sfile );
+ if (mEffectIDs[sfile] == 0) {
+ theFxHelper.Print("CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", sfile);
}
#endif
- PlayEffect( mEffectIDs[sfile], origin, axis, boltInfo, entNum, isPortal, iLoopTime, isRelative );
+ PlayEffect(mEffectIDs[sfile], origin, axis, boltInfo, entNum, isPortal, iLoopTime, isRelative);
}
//------------------------------------------------------
@@ -829,30 +704,27 @@ void CFxScheduler::PlayEffect( const char *file, vec3_t origin, vec3_t axis[3],
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( const char *file, int clientID, bool isPortal )
-{
- char sfile[MAX_QPATH];
- int id;
+void CFxScheduler::PlayEffect(const char *file, int clientID, bool isPortal) {
+ char sfile[MAX_QPATH];
+ int id;
// Get an extenstion stripped version of the file
- COM_StripExtension( file, sfile, sizeof(sfile) );
+ COM_StripExtension(file, sfile, sizeof(sfile));
id = mEffectIDs[sfile];
#ifndef FINAL_BUILD
- if ( id == 0 )
- {
- theFxHelper.Print( "CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", file );
+ if (id == 0) {
+ theFxHelper.Print("CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", file);
}
#endif
- SEffectTemplate *fx;
- CPrimitiveTemplate *prim;
- int i = 0;
- int count = 0, delay = 0;
- float factor = 0.0f;
+ SEffectTemplate *fx;
+ CPrimitiveTemplate *prim;
+ int i = 0;
+ int count = 0, delay = 0;
+ float factor = 0.0f;
- if ( id < 1 || id >= FX_MAX_EFFECTS || !mEffectTemplates[id].mInUse )
- {
+ if (id < 1 || id >= FX_MAX_EFFECTS || !mEffectTemplates[id].mInUse) {
// Now you've done it!
ReportPlayEffectError(id);
return;
@@ -864,78 +736,63 @@ void CFxScheduler::PlayEffect( const char *file, int clientID, bool isPortal )
fx = &mEffectTemplates[id];
// Loop through the primitives and schedule each bit
- for ( i = 0; i < fx->mPrimitiveCount; i++ )
- {
+ for (i = 0; i < fx->mPrimitiveCount; i++) {
prim = fx->mPrimitives[i];
count = prim->mSpawnCount.GetRoundedVal();
- if ( prim->mCopy )
- {
+ if (prim->mCopy) {
// If we are a copy, we need to store a "how many references count" so that we
// can keep the primitive template around for the correct amount of time.
prim->mRefCount = count;
}
- if ( prim->mSpawnFlags & FX_EVEN_DISTRIBUTION )
- {
+ if (prim->mSpawnFlags & FX_EVEN_DISTRIBUTION) {
factor = abs(prim->mSpawnDelay.GetMax() - prim->mSpawnDelay.GetMin()) / (float)count;
}
// Schedule the random number of bits
- for ( int t = 0; t < count; t++ )
- {
- if ( prim->mSpawnFlags & FX_EVEN_DISTRIBUTION )
- {
+ for (int t = 0; t < count; t++) {
+ if (prim->mSpawnFlags & FX_EVEN_DISTRIBUTION) {
delay = t * factor;
- }
- else
- {
+ } else {
delay = prim->mSpawnDelay.GetVal();
}
// if the delay is so small, we may as well just create this bit right now
- if ( delay < 1 && !isPortal )
- {
- CreateEffect( prim, clientID, -delay );
- }
- else
- {
- SScheduledEffect *sfx = mScheduledEffectsPool.Alloc();
+ if (delay < 1 && !isPortal) {
+ CreateEffect(prim, clientID, -delay);
+ } else {
+ SScheduledEffect *sfx = mScheduledEffectsPool.Alloc();
- if ( sfx == NULL )
- {
- Com_Error (ERR_DROP, "ERROR: Failed to allocate EFX from memory pool.");
+ if (sfx == NULL) {
+ Com_Error(ERR_DROP, "ERROR: Failed to allocate EFX from memory pool.");
return;
}
sfx->mStartTime = theFxHelper.mTime + delay;
sfx->mpTemplate = prim;
- sfx->mClientID = clientID;
+ sfx->mClientID = clientID;
- if (isPortal)
- {
+ if (isPortal) {
sfx->mPortalEffect = true;
- }
- else
- {
+ } else {
sfx->mPortalEffect = false;
}
- mFxSchedule.push_front( sfx );
+ mFxSchedule.push_front(sfx);
}
}
}
// We track effect templates and primitive templates separately.
- if ( fx->mCopy )
- {
+ if (fx->mCopy) {
// We don't use dynamic memory allocation, so just mark us as dead
fx->mInUse = false;
}
}
-bool gEffectsInPortal = false; //this is just because I don't want to have to add an mPortalEffect field to every actual effect.
+bool gEffectsInPortal = false; // this is just because I don't want to have to add an mPortalEffect field to every actual effect.
//------------------------------------------------------
// CreateEffect
@@ -950,136 +807,111 @@ bool gEffectsInPortal = false; //this is just because I don't want to have to ad
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, int clientID, int delay )
-{
- vec3_t sRGB, eRGB;
- vec3_t vel, accel;
- vec3_t org,org2;
- int flags = 0;
+void CFxScheduler::CreateEffect(CPrimitiveTemplate *fx, int clientID, int delay) {
+ vec3_t sRGB, eRGB;
+ vec3_t vel, accel;
+ vec3_t org, org2;
+ int flags = 0;
// Origin calculations -- completely ignores most things
//-------------------------------------
- VectorSet( org, fx->mOrigin1X.GetVal(), fx->mOrigin1Y.GetVal(), fx->mOrigin1Z.GetVal() );
- VectorSet( org2, fx->mOrigin2X.GetVal(), fx->mOrigin2Y.GetVal(), fx->mOrigin2Z.GetVal() );
+ VectorSet(org, fx->mOrigin1X.GetVal(), fx->mOrigin1Y.GetVal(), fx->mOrigin1Z.GetVal());
+ VectorSet(org2, fx->mOrigin2X.GetVal(), fx->mOrigin2Y.GetVal(), fx->mOrigin2Z.GetVal());
// handle RGB color
- if ( fx->mSpawnFlags & FX_RGB_COMPONENT_INTERP )
- {
+ if (fx->mSpawnFlags & FX_RGB_COMPONENT_INTERP) {
float perc = Q_flrand(0.0f, 1.0f);
- VectorSet( sRGB, fx->mRedStart.GetVal( perc ), fx->mGreenStart.GetVal( perc ), fx->mBlueStart.GetVal( perc ) );
- VectorSet( eRGB, fx->mRedEnd.GetVal( perc ), fx->mGreenEnd.GetVal( perc ), fx->mBlueEnd.GetVal( perc ) );
- }
- else
- {
- VectorSet( sRGB, fx->mRedStart.GetVal(), fx->mGreenStart.GetVal(), fx->mBlueStart.GetVal() );
- VectorSet( eRGB, fx->mRedEnd.GetVal(), fx->mGreenEnd.GetVal(), fx->mBlueEnd.GetVal() );
+ VectorSet(sRGB, fx->mRedStart.GetVal(perc), fx->mGreenStart.GetVal(perc), fx->mBlueStart.GetVal(perc));
+ VectorSet(eRGB, fx->mRedEnd.GetVal(perc), fx->mGreenEnd.GetVal(perc), fx->mBlueEnd.GetVal(perc));
+ } else {
+ VectorSet(sRGB, fx->mRedStart.GetVal(), fx->mGreenStart.GetVal(), fx->mBlueStart.GetVal());
+ VectorSet(eRGB, fx->mRedEnd.GetVal(), fx->mGreenEnd.GetVal(), fx->mBlueEnd.GetVal());
}
// NOTE: This completely disregards a few specialty flags.
- VectorSet( vel, fx->mVelX.GetVal( ), fx->mVelY.GetVal( ), fx->mVelZ.GetVal( ) );
- VectorSet( accel, fx->mAccelX.GetVal( ), fx->mAccelY.GetVal( ), fx->mAccelZ.GetVal( ) );
+ VectorSet(vel, fx->mVelX.GetVal(), fx->mVelY.GetVal(), fx->mVelZ.GetVal());
+ VectorSet(accel, fx->mAccelX.GetVal(), fx->mAccelY.GetVal(), fx->mAccelZ.GetVal());
// If depth hack ISN'T already on, then turn it on. Otherwise, we treat a pre-existing depth_hack flag as NOT being depth_hack.
// This is done because muzzle flash fx files are shared amongst all shooters, but for the player we need to do depth hack in first person....
- if ( !( fx->mFlags & FX_DEPTH_HACK ) && !cg.renderingThirdPerson ) // hack!
+ if (!(fx->mFlags & FX_DEPTH_HACK) && !cg.renderingThirdPerson) // hack!
{
flags = fx->mFlags | FX_RELATIVE | FX_DEPTH_HACK;
- }
- else
- {
+ } else {
flags = (fx->mFlags | FX_RELATIVE) & ~FX_DEPTH_HACK;
}
// We only support particles for now
//------------------------
- switch( fx->mType )
- {
+ switch (fx->mType) {
//---------
case Particle:
- //---------
+ //---------
- FX_AddParticle( clientID, org, vel, accel, fx->mGravity.GetVal(),
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mRotation.GetVal(), fx->mRotationDelta.GetVal(),
- fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
- fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags );
+ FX_AddParticle(clientID, org, vel, accel, fx->mGravity.GetVal(), fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
+ fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mRotation.GetVal(),
+ fx->mRotationDelta.GetVal(), fx->mMin, fx->mMax, fx->mElasticity.GetVal(), fx->mDeathFxHandles.GetHandle(),
+ fx->mImpactFxHandles.GetHandle(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags);
break;
//---------
case Line:
- //---------
+ //---------
- FX_AddLine( clientID, org, org2,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(), flags );
+ FX_AddLine(clientID, org, org2, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mAlphaStart.GetVal(),
+ fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(),
+ fx->mImpactFxHandles.GetHandle(), flags);
break;
//---------
case Tail:
- //---------
+ //---------
- FX_AddTail( clientID, org, vel, accel,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mLengthStart.GetVal(), fx->mLengthEnd.GetVal(), fx->mLengthParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
- fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags );
+ FX_AddTail(clientID, org, vel, accel, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mLengthStart.GetVal(),
+ fx->mLengthEnd.GetVal(), fx->mLengthParm.GetVal(), fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB,
+ fx->mRGBParm.GetVal(), fx->mMin, fx->mMax, fx->mElasticity.GetVal(), fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
+ fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags);
break;
-
//---------
case Sound:
- //---------
+ //---------
- if (gEffectsInPortal)
- { //could orient this anyway for panning, but eh. It's going to appear to the player in the sky the same place no matter what, so just make it a local sound.
- theFxHelper.PlayLocalSound( fx->mMediaHandles.GetHandle(), CHAN_AUTO );
- }
- else
- {
+ if (gEffectsInPortal) { // could orient this anyway for panning, but eh. It's going to appear to the player in the sky the same place no matter what, so
+ // just make it a local sound.
+ theFxHelper.PlayLocalSound(fx->mMediaHandles.GetHandle(), CHAN_AUTO);
+ } else {
// bolted sounds actually play on the client....
- theFxHelper.PlaySound( NULL, clientID, CHAN_WEAPON, fx->mMediaHandles.GetHandle() );
+ theFxHelper.PlaySound(NULL, clientID, CHAN_WEAPON, fx->mMediaHandles.GetHandle());
}
break;
//---------
case Light:
- //---------
+ //---------
// don't much care if the light stays bolted...so just add it.
- if ( clientID >= 0 && clientID < ENTITYNUM_WORLD )
- {
+ if (clientID >= 0 && clientID < ENTITYNUM_WORLD) {
// ..um, ok.....
centity_t *cent = &cg_entities[clientID];
- if ( cent && cent->gent && cent->gent->client )
- {
- FX_AddLight( cent->gent->client->renderInfo.muzzlePoint, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mLife.GetVal(), fx->mFlags );
+ if (cent && cent->gent && cent->gent->client) {
+ FX_AddLight(cent->gent->client->renderInfo.muzzlePoint, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), sRGB, eRGB,
+ fx->mRGBParm.GetVal(), fx->mLife.GetVal(), fx->mFlags);
}
}
break;
//---------
case CameraShake:
- //---------
+ //---------
- if ( clientID >= 0 && clientID < ENTITYNUM_WORLD )
- {
+ if (clientID >= 0 && clientID < ENTITYNUM_WORLD) {
// ..um, ok.....
centity_t *cent = &cg_entities[clientID];
- if ( cent && cent->gent && cent->gent->client )
- {
- theFxHelper.CameraShake( cent->gent->currentOrigin, fx->mElasticity.GetVal(), fx->mRadius.GetVal(), fx->mLife.GetVal() );
+ if (cent && cent->gent && cent->gent->client) {
+ theFxHelper.CameraShake(cent->gent->currentOrigin, fx->mElasticity.GetVal(), fx->mRadius.GetVal(), fx->mLife.GetVal());
}
}
break;
@@ -1089,12 +921,10 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, int clientID, int delay
}
// Track when we need to clean ourselves up if we are a copy
- if ( fx->mCopy )
- {
+ if (fx->mCopy) {
fx->mRefCount--;
- if ( fx->mRefCount <= 0 )
- {
+ if (fx->mRefCount <= 0) {
delete fx;
}
}
@@ -1113,59 +943,52 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, int clientID, int delay
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int boltInfo, const int entNum, bool isPortal, int iLoopTime, bool isRelative )
-{
- SEffectTemplate *fx;
- CPrimitiveTemplate *prim;
- int i = 0;
- int count = 0, delay = 0;
- float factor = 0.0f;
- bool forceScheduling = false;
-
- if ( id < 1 || id >= FX_MAX_EFFECTS || !mEffectTemplates[id].mInUse )
- {
+void CFxScheduler::PlayEffect(int id, vec3_t origin, vec3_t axis[3], const int boltInfo, const int entNum, bool isPortal, int iLoopTime, bool isRelative) {
+ SEffectTemplate *fx;
+ CPrimitiveTemplate *prim;
+ int i = 0;
+ int count = 0, delay = 0;
+ float factor = 0.0f;
+ bool forceScheduling = false;
+
+ if (id < 1 || id >= FX_MAX_EFFECTS || !mEffectTemplates[id].mInUse) {
// Now you've done it!
ReportPlayEffectError(id);
return;
}
// Don't bother scheduling the effect if the system is currently frozen
- if ( fx_freeze.integer )
- {
+ if (fx_freeze.integer) {
return;
}
- int modelNum = 0, boltNum = -1;
- int entityNum = entNum;
+ int modelNum = 0, boltNum = -1;
+ int entityNum = entNum;
- if ( boltInfo > 0 )
- {
+ if (boltInfo > 0) {
// extract the wraith ID from the bolt info
- modelNum = ( boltInfo >> MODEL_SHIFT ) & MODEL_AND;
- boltNum = ( boltInfo >> BOLT_SHIFT ) & BOLT_AND;
- entityNum = ( boltInfo >> ENTITY_SHIFT ) & ENTITY_AND;
+ modelNum = (boltInfo >> MODEL_SHIFT) & MODEL_AND;
+ boltNum = (boltInfo >> BOLT_SHIFT) & BOLT_AND;
+ entityNum = (boltInfo >> ENTITY_SHIFT) & ENTITY_AND;
// We always force ghoul bolted objects to be scheduled so that they don't play right away.
forceScheduling = true;
- if (iLoopTime)//0 = not looping, 1 for infinite, else duration
- {//store off the id to reschedule every frame
+ if (iLoopTime) // 0 = not looping, 1 for infinite, else duration
+ { // store off the id to reschedule every frame
ScheduleLoopedEffect(id, boltInfo, isPortal, iLoopTime, isRelative);
}
}
-
// Get the effect.
fx = &mEffectTemplates[id];
// Loop through the primitives and schedule each bit
- for ( i = 0; i < fx->mPrimitiveCount; i++ )
- {
+ for (i = 0; i < fx->mPrimitiveCount; i++) {
prim = fx->mPrimitives[i];
- if ( prim->mCullRange )
- {
- if ( DistanceSquared( origin, cg.refdef.vieworg ) > prim->mCullRange ) // cull range has already been squared
+ if (prim->mCullRange) {
+ if (DistanceSquared(origin, cg.refdef.vieworg) > prim->mCullRange) // cull range has already been squared
{
// is too far away, so don't add this primitive group
continue;
@@ -1174,50 +997,37 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int
count = prim->mSpawnCount.GetRoundedVal();
- if ( prim->mCopy )
- {
+ if (prim->mCopy) {
// If we are a copy, we need to store a "how many references count" so that we
// can keep the primitive template around for the correct amount of time.
prim->mRefCount = count;
}
- if ( prim->mSpawnFlags & FX_EVEN_DISTRIBUTION )
- {
+ if (prim->mSpawnFlags & FX_EVEN_DISTRIBUTION) {
factor = abs(prim->mSpawnDelay.GetMax() - prim->mSpawnDelay.GetMin()) / (float)count;
}
// Schedule the random number of bits
- for ( int t = 0; t < count; t++ )
- {
- if ( prim->mSpawnFlags & FX_EVEN_DISTRIBUTION )
- {
+ for (int t = 0; t < count; t++) {
+ if (prim->mSpawnFlags & FX_EVEN_DISTRIBUTION) {
delay = t * factor;
- }
- else
- {
+ } else {
delay = prim->mSpawnDelay.GetVal();
}
// if the delay is so small, we may as well just create this bit right now
- if ( delay < 1 && !forceScheduling && !isPortal )
- {
- if ( boltInfo == -1 && entNum != -1 )
- {
+ if (delay < 1 && !forceScheduling && !isPortal) {
+ if (boltInfo == -1 && entNum != -1) {
// Find out where the entity currently is
- CreateEffect( prim, cg_entities[entNum].lerpOrigin, axis, -delay );
+ CreateEffect(prim, cg_entities[entNum].lerpOrigin, axis, -delay);
+ } else {
+ CreateEffect(prim, origin, axis, -delay);
}
- else
- {
- CreateEffect( prim, origin, axis, -delay );
- }
- }
- else
- {
- SScheduledEffect *sfx = mScheduledEffectsPool.Alloc();
+ } else {
+ SScheduledEffect *sfx = mScheduledEffectsPool.Alloc();
- if ( sfx == NULL )
- {
- Com_Error (ERR_DROP, "ERROR: Failed to allocate EFX from memory pool.");
+ if (sfx == NULL) {
+ Com_Error(ERR_DROP, "ERROR: Failed to allocate EFX from memory pool.");
return;
}
@@ -1225,40 +1035,31 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int
sfx->mpTemplate = prim;
sfx->mClientID = -1;
sfx->mIsRelative = isRelative;
- sfx->mEntNum = entityNum; //ent if bolted, else -1 for none, or -2 for _Immersion client 0
+ sfx->mEntNum = entityNum; // ent if bolted, else -1 for none, or -2 for _Immersion client 0
sfx->mPortalEffect = isPortal;
- if ( boltInfo == -1 )
- {
- if ( entNum == -1 )
- {
+ if (boltInfo == -1) {
+ if (entNum == -1) {
// we aren't bolting, so make sure the spawn system knows this by putting -1's in these fields
sfx->mBoltNum = -1;
sfx->mModelNum = 0;
- if ( origin )
- {
- VectorCopy( origin, sfx->mOrigin );
- }
- else
- {
- VectorClear( sfx->mOrigin );
+ if (origin) {
+ VectorCopy(origin, sfx->mOrigin);
+ } else {
+ VectorClear(sfx->mOrigin);
}
- AxisCopy( axis, sfx->mAxis );
- }
- else
- {
+ AxisCopy(axis, sfx->mAxis);
+ } else {
// we are doing bolting onto the origin of the entity, so use a cheaper method
sfx->mBoltNum = -1;
sfx->mModelNum = 0;
- AxisCopy( axis, sfx->mAxis );
+ AxisCopy(axis, sfx->mAxis);
}
- }
- else
- {
+ } else {
// we are bolting, so store the extra info
sfx->mBoltNum = boltNum;
sfx->mModelNum = modelNum;
@@ -1267,14 +1068,13 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int
sfx->mStartTime++;
}
- mFxSchedule.push_front( sfx );
+ mFxSchedule.push_front(sfx);
}
}
}
// We track effect templates and primitive templates separately.
- if ( fx->mCopy )
- {
+ if (fx->mCopy) {
// We don't use dynamic memory allocation, so just mark us as dead
fx->mInUse = false;
}
@@ -1292,19 +1092,17 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( const char *file, vec3_t origin, bool isPortal )
-{
- char sfile[MAX_QPATH];
+void CFxScheduler::PlayEffect(const char *file, vec3_t origin, bool isPortal) {
+ char sfile[MAX_QPATH];
// Get an extenstion stripped version of the file
- COM_StripExtension( file, sfile, sizeof(sfile) );
+ COM_StripExtension(file, sfile, sizeof(sfile));
- PlayEffect( mEffectIDs[sfile], origin, isPortal );
+ PlayEffect(mEffectIDs[sfile], origin, isPortal);
#ifndef FINAL_BUILD
- if ( mEffectIDs[sfile] == 0 )
- {
- theFxHelper.Print( "CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", file );
+ if (mEffectIDs[sfile] == 0) {
+ theFxHelper.Print("CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", file);
}
#endif
}
@@ -1321,19 +1119,17 @@ void CFxScheduler::PlayEffect( const char *file, vec3_t origin, bool isPortal )
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::PlayEffect( const char *file, vec3_t origin, vec3_t forward, bool isPortal )
-{
- char sfile[MAX_QPATH];
+void CFxScheduler::PlayEffect(const char *file, vec3_t origin, vec3_t forward, bool isPortal) {
+ char sfile[MAX_QPATH];
// Get an extenstion stripped version of the file
- COM_StripExtension( file, sfile, sizeof(sfile) );
+ COM_StripExtension(file, sfile, sizeof(sfile));
- PlayEffect( mEffectIDs[sfile], origin, forward, isPortal );
+ PlayEffect(mEffectIDs[sfile], origin, forward, isPortal);
#ifndef FINAL_BUILD
- if ( mEffectIDs[sfile] == 0 )
- {
- theFxHelper.Print( "CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", file );
+ if (mEffectIDs[sfile] == 0) {
+ theFxHelper.Print("CFxScheduler::PlayEffect unregistered/non-existent effect: %s\n", file);
}
#endif
}
@@ -1350,62 +1146,40 @@ void CFxScheduler::PlayEffect( const char *file, vec3_t origin, vec3_t forward,
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::AddScheduledEffects( bool portal )
-{
- TScheduledEffect::iterator itr, next;
- vec3_t origin;
- vec3_t axis[3];
- int oldEntNum = -1, oldBoltIndex = -1, oldModelNum = -1;
- qboolean doesBoltExist = qfalse;
-
- if (portal)
- {
+void CFxScheduler::AddScheduledEffects(bool portal) {
+ TScheduledEffect::iterator itr, next;
+ vec3_t origin;
+ vec3_t axis[3];
+ int oldEntNum = -1, oldBoltIndex = -1, oldModelNum = -1;
+ qboolean doesBoltExist = qfalse;
+
+ if (portal) {
gEffectsInPortal = true;
- }
- else
- {
+ } else {
AddLoopedEffects();
}
- for ( itr = mFxSchedule.begin(); itr != mFxSchedule.end(); /* do nothing */ )
- {
+ for (itr = mFxSchedule.begin(); itr != mFxSchedule.end(); /* do nothing */) {
SScheduledEffect *effect = *itr;
- if (portal == effect->mPortalEffect && effect->mStartTime <= theFxHelper.mTime )
- {
- if ( effect->mClientID >= 0 )
- {
- CreateEffect( effect->mpTemplate, effect->mClientID,
- theFxHelper.mTime - effect->mStartTime );
- }
- else if (effect->mBoltNum == -1)
- {// normal effect
- if ( effect->mEntNum != -1 ) // -1
+ if (portal == effect->mPortalEffect && effect->mStartTime <= theFxHelper.mTime) {
+ if (effect->mClientID >= 0) {
+ CreateEffect(effect->mpTemplate, effect->mClientID, theFxHelper.mTime - effect->mStartTime);
+ } else if (effect->mBoltNum == -1) { // normal effect
+ if (effect->mEntNum != -1) // -1
{
// Find out where the entity currently is
- CreateEffect( effect->mpTemplate,
- cg_entities[effect->mEntNum].lerpOrigin, effect->mAxis,
- theFxHelper.mTime - (*itr)->mStartTime );
- }
- else
- {
- CreateEffect( effect->mpTemplate,
- effect->mOrigin, effect->mAxis,
- theFxHelper.mTime - effect->mStartTime );
+ CreateEffect(effect->mpTemplate, cg_entities[effect->mEntNum].lerpOrigin, effect->mAxis, theFxHelper.mTime - (*itr)->mStartTime);
+ } else {
+ CreateEffect(effect->mpTemplate, effect->mOrigin, effect->mAxis, theFxHelper.mTime - effect->mStartTime);
}
- }
- else
- { //bolted on effect
+ } else { // bolted on effect
// do we need to go and re-get the bolt matrix again? Since it takes time lets try to do it only once
- if ((effect->mModelNum != oldModelNum) || (effect->mEntNum != oldEntNum) || (effect->mBoltNum != oldBoltIndex))
- {
+ if ((effect->mModelNum != oldModelNum) || (effect->mEntNum != oldEntNum) || (effect->mBoltNum != oldBoltIndex)) {
const centity_t ¢ = cg_entities[effect->mEntNum];
- if (cent.gent->ghoul2.IsValid())
- {
- if (effect->mModelNum>=0&&effect->mModelNumghoul2.size())
- {
- if (cent.gent->ghoul2[effect->mModelNum].mModelindex>=0)
- {
+ if (cent.gent->ghoul2.IsValid()) {
+ if (effect->mModelNum >= 0 && effect->mModelNum < cent.gent->ghoul2.size()) {
+ if (cent.gent->ghoul2[effect->mModelNum].mModelindex >= 0) {
doesBoltExist = (qboolean)(theFxHelper.GetOriginAxisFromBolt(cent, effect->mModelNum, effect->mBoltNum, origin, axis) != 0);
}
}
@@ -1417,28 +1191,18 @@ void CFxScheduler::AddScheduledEffects( bool portal )
}
// only do this if we found the bolt
- if (doesBoltExist)
- {
- if (effect->mIsRelative )
- {
- CreateEffect( effect->mpTemplate,
- vec3_origin, axis,
- 0, effect->mEntNum, effect->mModelNum, effect->mBoltNum );
- }
- else
- {
- CreateEffect( effect->mpTemplate,
- origin, axis,
- theFxHelper.mTime - effect->mStartTime );
+ if (doesBoltExist) {
+ if (effect->mIsRelative) {
+ CreateEffect(effect->mpTemplate, vec3_origin, axis, 0, effect->mEntNum, effect->mModelNum, effect->mBoltNum);
+ } else {
+ CreateEffect(effect->mpTemplate, origin, axis, theFxHelper.mTime - effect->mStartTime);
}
}
}
- mScheduledEffectsPool.Free( effect );
- itr = mFxSchedule.erase( itr );
- }
- else
- {
+ mScheduledEffectsPool.Free(effect);
+ itr = mFxSchedule.erase(itr);
+ } else {
++itr;
}
}
@@ -1462,129 +1226,105 @@ void CFxScheduler::AddScheduledEffects( bool portal )
// Return:
// none
//------------------------------------------------------
-void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, const vec3_t origin, vec3_t axis[3], int lateTime, int clientID, int modelNum, int boltNum )
-{
- vec3_t org, org2, temp,
- vel, accel,
- sRGB, eRGB,
- ang, angDelta,
- ax[3];
- trace_t tr;
- int emitterModel;
+void CFxScheduler::CreateEffect(CPrimitiveTemplate *fx, const vec3_t origin, vec3_t axis[3], int lateTime, int clientID, int modelNum, int boltNum) {
+ vec3_t org, org2, temp, vel, accel, sRGB, eRGB, ang, angDelta, ax[3];
+ trace_t tr;
+ int emitterModel;
// We may modify the axis, so make a work copy
- AxisCopy( axis, ax );
+ AxisCopy(axis, ax);
int flags = fx->mFlags;
- if (clientID>=0 && modelNum>=0 && boltNum>=0)
- {//since you passed in these values, mark as relative to use them
+ if (clientID >= 0 && modelNum >= 0 && boltNum >= 0) { // since you passed in these values, mark as relative to use them
flags |= FX_RELATIVE;
}
- if( fx->mSpawnFlags & FX_RAND_ROT_AROUND_FWD )
- {
- RotatePointAroundVector( ax[1], ax[0], axis[1], Q_flrand(0.0f, 1.0f)*360.0f );
- CrossProduct( ax[0], ax[1], ax[2] );
+ if (fx->mSpawnFlags & FX_RAND_ROT_AROUND_FWD) {
+ RotatePointAroundVector(ax[1], ax[0], axis[1], Q_flrand(0.0f, 1.0f) * 360.0f);
+ CrossProduct(ax[0], ax[1], ax[2]);
}
// Origin calculations
//-------------------------------------
- if ( fx->mSpawnFlags & FX_CHEAP_ORG_CALC || flags & FX_RELATIVE )
- { // let's take the easy way out
- VectorSet( org, fx->mOrigin1X.GetVal(), fx->mOrigin1Y.GetVal(), fx->mOrigin1Z.GetVal() );
- }
- else
- { // time for some extra work
- VectorScale( ax[0], fx->mOrigin1X.GetVal(), org );
- VectorMA( org, fx->mOrigin1Y.GetVal(), ax[1], org );
- VectorMA( org, fx->mOrigin1Z.GetVal(), ax[2], org );
+ if (fx->mSpawnFlags & FX_CHEAP_ORG_CALC || flags & FX_RELATIVE) { // let's take the easy way out
+ VectorSet(org, fx->mOrigin1X.GetVal(), fx->mOrigin1Y.GetVal(), fx->mOrigin1Z.GetVal());
+ } else { // time for some extra work
+ VectorScale(ax[0], fx->mOrigin1X.GetVal(), org);
+ VectorMA(org, fx->mOrigin1Y.GetVal(), ax[1], org);
+ VectorMA(org, fx->mOrigin1Z.GetVal(), ax[2], org);
}
// We always add our calculated offset to the passed in origin...
- VectorAdd( org, origin, org );
+ VectorAdd(org, origin, org);
// Now, we may need to calc a point on a sphere/ellipsoid/cylinder/disk and add that to it
//----------------------------------------------------------------
- if ( fx->mSpawnFlags & FX_ORG_ON_SPHERE )
- {
+ if (fx->mSpawnFlags & FX_ORG_ON_SPHERE) {
float x, y;
float width, height;
- x = DEG2RAD( Q_flrand(0.0f, 1.0f) * 360.0f );
- y = DEG2RAD( Q_flrand(0.0f, 1.0f) * 180.0f );
+ x = DEG2RAD(Q_flrand(0.0f, 1.0f) * 360.0f);
+ y = DEG2RAD(Q_flrand(0.0f, 1.0f) * 180.0f);
width = fx->mRadius.GetVal();
height = fx->mHeight.GetVal();
// calculate point on ellipse
- VectorSet( temp, sin(x) * width * sin(y), cos(x) * width * sin(y), cos(y) * height ); // sinx * siny, cosx * siny, cosy
- VectorAdd( org, temp, org );
+ VectorSet(temp, sin(x) * width * sin(y), cos(x) * width * sin(y), cos(y) * height); // sinx * siny, cosx * siny, cosy
+ VectorAdd(org, temp, org);
- if ( fx->mSpawnFlags & FX_AXIS_FROM_SPHERE )
- {
+ if (fx->mSpawnFlags & FX_AXIS_FROM_SPHERE) {
// well, we will now override the axis at the users request
- VectorNormalize2( temp, ax[0] );
- MakeNormalVectors( ax[0], ax[1], ax[2] );
+ VectorNormalize2(temp, ax[0]);
+ MakeNormalVectors(ax[0], ax[1], ax[2]);
}
- }
- else if ( fx->mSpawnFlags & FX_ORG_ON_CYLINDER )
- {
- vec3_t pt;
+ } else if (fx->mSpawnFlags & FX_ORG_ON_CYLINDER) {
+ vec3_t pt;
// set up our point, then rotate around the current direction to. Make unrotated cylinder centered around 0,0,0
- VectorScale( ax[1], fx->mRadius.GetVal(), pt );
- VectorMA( pt, Q_flrand(-1.0f, 1.0f) * 0.5f * fx->mHeight.GetVal(), ax[0], pt );
- RotatePointAroundVector( temp, ax[0], pt, Q_flrand(0.0f, 1.0f) * 360.0f );
+ VectorScale(ax[1], fx->mRadius.GetVal(), pt);
+ VectorMA(pt, Q_flrand(-1.0f, 1.0f) * 0.5f * fx->mHeight.GetVal(), ax[0], pt);
+ RotatePointAroundVector(temp, ax[0], pt, Q_flrand(0.0f, 1.0f) * 360.0f);
- VectorAdd( org, temp, org );
+ VectorAdd(org, temp, org);
- if ( fx->mSpawnFlags & FX_AXIS_FROM_SPHERE )
- {
- vec3_t up={0,0,1};
+ if (fx->mSpawnFlags & FX_AXIS_FROM_SPHERE) {
+ vec3_t up = {0, 0, 1};
// well, we will now override the axis at the users request
- VectorNormalize2( temp, ax[0] );
+ VectorNormalize2(temp, ax[0]);
- if ( ax[0][2] == 1.0f )
- {
+ if (ax[0][2] == 1.0f) {
// readjust up
- VectorSet( up, 0, 1, 0 );
+ VectorSet(up, 0, 1, 0);
}
- CrossProduct( up, ax[0], ax[1] );
- CrossProduct( ax[0], ax[1], ax[2] );
+ CrossProduct(up, ax[0], ax[1]);
+ CrossProduct(ax[0], ax[1], ax[2]);
}
}
-
// There are only a few types that really use velocity and acceleration, so do extra work for those types
//--------------------------------------------------------------------------------------------------------
- if ( fx->mType == Particle || fx->mType == OrientedParticle || fx->mType == Tail || fx->mType == Emitter )
- {
+ if (fx->mType == Particle || fx->mType == OrientedParticle || fx->mType == Tail || fx->mType == Emitter) {
// Velocity calculations
//-------------------------------------
- if ( fx->mSpawnFlags & FX_VEL_IS_ABSOLUTE || flags & FX_RELATIVE )
- {
- VectorSet( vel, fx->mVelX.GetVal(), fx->mVelY.GetVal(), fx->mVelZ.GetVal() );
- }
- else
- { // bah, do some extra work to coerce it
- VectorScale( ax[0], fx->mVelX.GetVal(), vel );
- VectorMA( vel, fx->mVelY.GetVal(), ax[1], vel );
- VectorMA( vel, fx->mVelZ.GetVal(), ax[2], vel );
+ if (fx->mSpawnFlags & FX_VEL_IS_ABSOLUTE || flags & FX_RELATIVE) {
+ VectorSet(vel, fx->mVelX.GetVal(), fx->mVelY.GetVal(), fx->mVelZ.GetVal());
+ } else { // bah, do some extra work to coerce it
+ VectorScale(ax[0], fx->mVelX.GetVal(), vel);
+ VectorMA(vel, fx->mVelY.GetVal(), ax[1], vel);
+ VectorMA(vel, fx->mVelZ.GetVal(), ax[2], vel);
}
// Acceleration calculations
//-------------------------------------
- if ( fx->mSpawnFlags & FX_ACCEL_IS_ABSOLUTE || flags & FX_RELATIVE )
- {
- VectorSet( accel, fx->mAccelX.GetVal(), fx->mAccelY.GetVal(), fx->mAccelZ.GetVal() );
- }
- else
- {
- VectorScale( ax[0], fx->mAccelX.GetVal(), accel );
- VectorMA( accel, fx->mAccelY.GetVal(), ax[1], accel );
- VectorMA( accel, fx->mAccelZ.GetVal(), ax[2], accel );
+ if (fx->mSpawnFlags & FX_ACCEL_IS_ABSOLUTE || flags & FX_RELATIVE) {
+ VectorSet(accel, fx->mAccelX.GetVal(), fx->mAccelY.GetVal(), fx->mAccelZ.GetVal());
+ } else {
+ VectorScale(ax[0], fx->mAccelX.GetVal(), accel);
+ VectorMA(accel, fx->mAccelY.GetVal(), ax[1], accel);
+ VectorMA(accel, fx->mAccelZ.GetVal(), ax[2], accel);
}
// Gravity is completely decoupled from acceleration since it is __always__ absolute
@@ -1593,17 +1333,15 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, const vec3_t origin, ve
// There may be a lag between when the effect should be created and when it actually gets created.
// Since we know what the discrepancy is, we can attempt to compensate...
- if ( lateTime > 0 )
- {
+ if (lateTime > 0) {
// Calc the time differences
float ftime = lateTime * 0.001f;
float time2 = ftime * ftime * 0.5f;
- VectorMA( vel, ftime, accel, vel );
+ VectorMA(vel, ftime, accel, vel);
// Predict the new position
- for ( int i = 0 ; i < 3 ; i++ )
- {
+ for (int i = 0; i < 3; i++) {
org[i] = org[i] + ftime * vel[i] + time2 * vel[i];
}
}
@@ -1611,232 +1349,172 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, const vec3_t origin, ve
// Line type primitives work with an origin2, so do the extra work for them
//--------------------------------------------------------------------------
- if ( fx->mType == Line || fx->mType == Electricity )
- {
+ if (fx->mType == Line || fx->mType == Electricity) {
// We may have to do a trace to find our endpoint
- if ( fx->mSpawnFlags & FX_ORG2_FROM_TRACE )
- {
- VectorMA( org, FX_MAX_TRACE_DIST, ax[0], temp );
+ if (fx->mSpawnFlags & FX_ORG2_FROM_TRACE) {
+ VectorMA(org, FX_MAX_TRACE_DIST, ax[0], temp);
- if ( fx->mSpawnFlags & FX_ORG2_IS_OFFSET )
- { // add a random flair to the endpoint...note: org2 will have to be pretty large to affect this much
+ if (fx->mSpawnFlags & FX_ORG2_IS_OFFSET) { // add a random flair to the endpoint...note: org2 will have to be pretty large to affect this much
// we also do this pre-trace as opposed to post trace since we may have to render an impact effect
// and we will want the normal at the exact endpos...
- if ( fx->mSpawnFlags & FX_CHEAP_ORG2_CALC || flags & FX_RELATIVE )
- {
- VectorSet( org2, fx->mOrigin2X.GetVal(), fx->mOrigin2Y.GetVal(), fx->mOrigin2Z.GetVal() );
- VectorAdd( org2, temp, temp );
- }
- else
- { // I can only imagine a few cases where you might want to do this...
- VectorMA( temp, fx->mOrigin2X.GetVal(), ax[0], temp );
- VectorMA( temp, fx->mOrigin2Y.GetVal(), ax[1], temp );
- VectorMA( temp, fx->mOrigin2Z.GetVal(), ax[2], temp );
+ if (fx->mSpawnFlags & FX_CHEAP_ORG2_CALC || flags & FX_RELATIVE) {
+ VectorSet(org2, fx->mOrigin2X.GetVal(), fx->mOrigin2Y.GetVal(), fx->mOrigin2Z.GetVal());
+ VectorAdd(org2, temp, temp);
+ } else { // I can only imagine a few cases where you might want to do this...
+ VectorMA(temp, fx->mOrigin2X.GetVal(), ax[0], temp);
+ VectorMA(temp, fx->mOrigin2Y.GetVal(), ax[1], temp);
+ VectorMA(temp, fx->mOrigin2Z.GetVal(), ax[2], temp);
}
}
- theFxHelper.Trace( &tr, org, NULL, NULL, temp, -1, CONTENTS_SOLID | CONTENTS_SHOTCLIP );//MASK_SHOT );
+ theFxHelper.Trace(&tr, org, NULL, NULL, temp, -1, CONTENTS_SOLID | CONTENTS_SHOTCLIP); // MASK_SHOT );
- if ( tr.startsolid || tr.allsolid )
- {
- VectorCopy( org, org2 ); // this is not a very good solution
- }
- else
- {
- VectorCopy( tr.endpos, org2 );
+ if (tr.startsolid || tr.allsolid) {
+ VectorCopy(org, org2); // this is not a very good solution
+ } else {
+ VectorCopy(tr.endpos, org2);
}
- if ( fx->mSpawnFlags & FX_TRACE_IMPACT_FX )
- {
- PlayEffect( fx->mImpactFxHandles.GetHandle(), org2, tr.plane.normal );
+ if (fx->mSpawnFlags & FX_TRACE_IMPACT_FX) {
+ PlayEffect(fx->mImpactFxHandles.GetHandle(), org2, tr.plane.normal);
}
- }
- else
- {
- if ( fx->mSpawnFlags & FX_CHEAP_ORG2_CALC || flags & FX_RELATIVE )
- {
- VectorSet( org2, fx->mOrigin2X.GetVal(), fx->mOrigin2Y.GetVal(), fx->mOrigin2Z.GetVal() );
- }
- else
- {
- VectorScale( ax[0], fx->mOrigin2X.GetVal(), org2 );
- VectorMA( org2, fx->mOrigin2Y.GetVal(), ax[1], org2 );
- VectorMA( org2, fx->mOrigin2Z.GetVal(), ax[2], org2 );
-
- VectorAdd( org2, origin, org2 );
+ } else {
+ if (fx->mSpawnFlags & FX_CHEAP_ORG2_CALC || flags & FX_RELATIVE) {
+ VectorSet(org2, fx->mOrigin2X.GetVal(), fx->mOrigin2Y.GetVal(), fx->mOrigin2Z.GetVal());
+ } else {
+ VectorScale(ax[0], fx->mOrigin2X.GetVal(), org2);
+ VectorMA(org2, fx->mOrigin2Y.GetVal(), ax[1], org2);
+ VectorMA(org2, fx->mOrigin2Z.GetVal(), ax[2], org2);
+
+ VectorAdd(org2, origin, org2);
}
-
}
} // end special org2 types
// handle RGB color, but only for types that will use it
//---------------------------------------------------------------------------
- if ( fx->mType != Sound && fx->mType != FxRunner && fx->mType != CameraShake )
- {
- if ( fx->mSpawnFlags & FX_RGB_COMPONENT_INTERP )
- {
+ if (fx->mType != Sound && fx->mType != FxRunner && fx->mType != CameraShake) {
+ if (fx->mSpawnFlags & FX_RGB_COMPONENT_INTERP) {
float perc = Q_flrand(0.0f, 1.0f);
- VectorSet( sRGB, fx->mRedStart.GetVal( perc ), fx->mGreenStart.GetVal( perc ), fx->mBlueStart.GetVal( perc ) );
- VectorSet( eRGB, fx->mRedEnd.GetVal( perc ), fx->mGreenEnd.GetVal( perc ), fx->mBlueEnd.GetVal( perc ) );
- }
- else
- {
- VectorSet( sRGB, fx->mRedStart.GetVal(), fx->mGreenStart.GetVal(), fx->mBlueStart.GetVal() );
- VectorSet( eRGB, fx->mRedEnd.GetVal(), fx->mGreenEnd.GetVal(), fx->mBlueEnd.GetVal() );
+ VectorSet(sRGB, fx->mRedStart.GetVal(perc), fx->mGreenStart.GetVal(perc), fx->mBlueStart.GetVal(perc));
+ VectorSet(eRGB, fx->mRedEnd.GetVal(perc), fx->mGreenEnd.GetVal(perc), fx->mBlueEnd.GetVal(perc));
+ } else {
+ VectorSet(sRGB, fx->mRedStart.GetVal(), fx->mGreenStart.GetVal(), fx->mBlueStart.GetVal());
+ VectorSet(eRGB, fx->mRedEnd.GetVal(), fx->mGreenEnd.GetVal(), fx->mBlueEnd.GetVal());
}
}
// Now create the appropriate effect entity
//------------------------
- switch( fx->mType )
- {
+ switch (fx->mType) {
//---------
case Particle:
- //---------
+ //---------
- FX_AddParticle( clientID, org, vel, accel, fx->mGravity.GetVal(),
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mRotation.GetVal(), fx->mRotationDelta.GetVal(),
- fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
- fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum );
+ FX_AddParticle(clientID, org, vel, accel, fx->mGravity.GetVal(), fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
+ fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mRotation.GetVal(),
+ fx->mRotationDelta.GetVal(), fx->mMin, fx->mMax, fx->mElasticity.GetVal(), fx->mDeathFxHandles.GetHandle(),
+ fx->mImpactFxHandles.GetHandle(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum);
break;
//---------
case Line:
- //---------
+ //---------
- FX_AddLine( clientID, org, org2,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(), flags, modelNum, boltNum );
+ FX_AddLine(clientID, org, org2, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mAlphaStart.GetVal(),
+ fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(),
+ fx->mImpactFxHandles.GetHandle(), flags, modelNum, boltNum);
break;
//---------
case Tail:
- //---------
+ //---------
- FX_AddTail( clientID, org, vel, accel,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mLengthStart.GetVal(), fx->mLengthEnd.GetVal(), fx->mLengthParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
- fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum );
+ FX_AddTail(clientID, org, vel, accel, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mLengthStart.GetVal(),
+ fx->mLengthEnd.GetVal(), fx->mLengthParm.GetVal(), fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB,
+ fx->mRGBParm.GetVal(), fx->mMin, fx->mMax, fx->mElasticity.GetVal(), fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
+ fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum);
break;
//----------------
case Electricity:
- //----------------
+ //----------------
- FX_AddElectricity( clientID, org, org2,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mElasticity.GetVal(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum );
+ FX_AddElectricity(clientID, org, org2, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mAlphaStart.GetVal(),
+ fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mElasticity.GetVal(), fx->mLife.GetVal(),
+ fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum);
break;
//---------
case Cylinder:
- //---------
+ //---------
- FX_AddCylinder( clientID, org, ax[0],
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mSize2Start.GetVal(), fx->mSize2End.GetVal(), fx->mSize2Parm.GetVal(),
- fx->mLengthStart.GetVal(), fx->mLengthEnd.GetVal(), fx->mLengthParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum );
+ FX_AddCylinder(clientID, org, ax[0], fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mSize2Start.GetVal(),
+ fx->mSize2End.GetVal(), fx->mSize2Parm.GetVal(), fx->mLengthStart.GetVal(), fx->mLengthEnd.GetVal(), fx->mLengthParm.GetVal(),
+ fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mLife.GetVal(),
+ fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum);
break;
//---------
case Emitter:
- //---------
+ //---------
// for chunk angles, you don't really need much control over the end result...you just want variation..
- VectorSet( ang,
- fx->mAngle1.GetVal(),
- fx->mAngle2.GetVal(),
- fx->mAngle3.GetVal() );
+ VectorSet(ang, fx->mAngle1.GetVal(), fx->mAngle2.GetVal(), fx->mAngle3.GetVal());
- vectoangles( ax[0], temp );
- VectorAdd( ang, temp, ang );
+ vectoangles(ax[0], temp);
+ VectorAdd(ang, temp, ang);
- VectorSet( angDelta,
- fx->mAngle1Delta.GetVal(),
- fx->mAngle2Delta.GetVal(),
- fx->mAngle3Delta.GetVal() );
+ VectorSet(angDelta, fx->mAngle1Delta.GetVal(), fx->mAngle2Delta.GetVal(), fx->mAngle3Delta.GetVal());
emitterModel = fx->mMediaHandles.GetHandle();
- FX_AddEmitter( org, vel, accel,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- ang, angDelta,
- fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
- fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
- fx->mEmitterFxHandles.GetHandle(),
- fx->mDensity.GetVal(), fx->mVariance.GetVal(),
- fx->mLife.GetVal(), emitterModel, flags );
+ FX_AddEmitter(org, vel, accel, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(),
+ fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), ang, angDelta, fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
+ fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(), fx->mEmitterFxHandles.GetHandle(), fx->mDensity.GetVal(),
+ fx->mVariance.GetVal(), fx->mLife.GetVal(), emitterModel, flags);
break;
//---------
case Decal:
- //---------
+ //---------
// I'm calling this function ( at least for now ) because it handles projecting
// the decal mark onto the surfaces properly. This is especially important for large marks.
// The downside is that it's much less flexible....
- CG_ImpactMark( fx->mMediaHandles.GetHandle(), org, ax[0], fx->mRotation.GetVal(),
- sRGB[0], sRGB[1], sRGB[2], fx->mAlphaStart.GetVal(),
- qtrue, fx->mSizeStart.GetVal(), qfalse );
+ CG_ImpactMark(fx->mMediaHandles.GetHandle(), org, ax[0], fx->mRotation.GetVal(), sRGB[0], sRGB[1], sRGB[2], fx->mAlphaStart.GetVal(), qtrue,
+ fx->mSizeStart.GetVal(), qfalse);
- if (fx->mFlags & FX_GHOUL2_DECALS)
- {
- trace_t tr;
- vec3_t end;
+ if (fx->mFlags & FX_GHOUL2_DECALS) {
+ trace_t tr;
+ vec3_t end;
VectorMA(org, 64, ax[0], end);
theFxHelper.G2Trace(&tr, org, NULL, NULL, end, ENTITYNUM_NONE, MASK_PLAYERSOLID);
- if (tr.entityNum < ENTITYNUM_WORLD &&
- g_entities[tr.entityNum].ghoul2.size())
- {
+ if (tr.entityNum < ENTITYNUM_WORLD && g_entities[tr.entityNum].ghoul2.size()) {
gentity_t *ent = &g_entities[tr.entityNum];
- if ( ent != NULL )
- {
+ if (ent != NULL) {
vec3_t entOrg, hitDir;
float entYaw;
float firstModel = 0;
- if ( !(ent->s.eFlags&EF_NODRAW) )
- {//not drawn, no marks
- if ( ent->client )
- {
- VectorCopy( ent->client->ps.origin, entOrg );
- }
- else
- {
- VectorCopy( ent->currentOrigin, entOrg );
+ if (!(ent->s.eFlags & EF_NODRAW)) { // not drawn, no marks
+ if (ent->client) {
+ VectorCopy(ent->client->ps.origin, entOrg);
+ } else {
+ VectorCopy(ent->currentOrigin, entOrg);
}
- if ( ent->client )
- {
+ if (ent->client) {
entYaw = ent->client->ps.viewangles[YAW];
- }
- else
- {
+ } else {
entYaw = ent->currentAngles[YAW];
}
- //if ( VectorCompare( tr.plane.normal, vec3_origin ) )
- {//hunh, no plane? Use trace dir
- VectorCopy( ax[0], hitDir );
+ // if ( VectorCompare( tr.plane.normal, vec3_origin ) )
+ { // hunh, no plane? Use trace dir
+ VectorCopy(ax[0], hitDir);
}
/*
else
@@ -1845,9 +1523,8 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, const vec3_t origin, ve
}
*/
- CG_AddGhoul2Mark(fx->mMediaHandles.GetHandle(), fx->mSizeStart.GetVal(), tr.endpos, tr.plane.normal,
- tr.entityNum, entOrg, entYaw,
- ent->ghoul2, ent->s.modelScale, Q_irand(40000, 60000), firstModel);
+ CG_AddGhoul2Mark(fx->mMediaHandles.GetHandle(), fx->mSizeStart.GetVal(), tr.endpos, tr.plane.normal, tr.entityNum, entOrg, entYaw,
+ ent->ghoul2, ent->s.modelScale, Q_irand(40000, 60000), firstModel);
}
}
}
@@ -1856,66 +1533,56 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, const vec3_t origin, ve
//-------------------
case OrientedParticle:
- //-------------------
+ //-------------------
- FX_AddOrientedParticle( clientID, org, ax[0], vel, accel,
- fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mRotation.GetVal(), fx->mRotationDelta.GetVal(),
- fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
- fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags, modelNum, boltNum );
+ FX_AddOrientedParticle(clientID, org, ax[0], vel, accel, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
+ fx->mAlphaStart.GetVal(), fx->mAlphaEnd.GetVal(), fx->mAlphaParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(),
+ fx->mRotation.GetVal(), fx->mRotationDelta.GetVal(), fx->mMin, fx->mMax, fx->mElasticity.GetVal(),
+ fx->mDeathFxHandles.GetHandle(), fx->mImpactFxHandles.GetHandle(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), flags,
+ modelNum, boltNum);
break;
//---------
case Sound:
- //---------
- if (gEffectsInPortal)
- { //could orient this anyway for panning, but eh. It's going to appear to the player in the sky the same place no matter what, so just make it a local sound.
- theFxHelper.PlayLocalSound( fx->mMediaHandles.GetHandle(), CHAN_AUTO );
- }
- else if ( fx->mSpawnFlags & FX_SND_LESS_ATTENUATION )
- {
- theFxHelper.PlaySound( org, ENTITYNUM_NONE, CHAN_LESS_ATTEN, fx->mMediaHandles.GetHandle() );
- }
- else
- {
- theFxHelper.PlaySound( org, ENTITYNUM_NONE, CHAN_AUTO, fx->mMediaHandles.GetHandle() );
+ //---------
+ if (gEffectsInPortal) { // could orient this anyway for panning, but eh. It's going to appear to the player in the sky the same place no matter what, so
+ // just make it a local sound.
+ theFxHelper.PlayLocalSound(fx->mMediaHandles.GetHandle(), CHAN_AUTO);
+ } else if (fx->mSpawnFlags & FX_SND_LESS_ATTENUATION) {
+ theFxHelper.PlaySound(org, ENTITYNUM_NONE, CHAN_LESS_ATTEN, fx->mMediaHandles.GetHandle());
+ } else {
+ theFxHelper.PlaySound(org, ENTITYNUM_NONE, CHAN_AUTO, fx->mMediaHandles.GetHandle());
}
break;
//---------
case FxRunner:
- //---------
+ //---------
- PlayEffect( fx->mPlayFxHandles.GetHandle(), org, ax );
+ PlayEffect(fx->mPlayFxHandles.GetHandle(), org, ax);
break;
//---------
case Light:
- //---------
+ //---------
- FX_AddLight( org, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(),
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mLife.GetVal(), fx->mFlags );
+ FX_AddLight(org, fx->mSizeStart.GetVal(), fx->mSizeEnd.GetVal(), fx->mSizeParm.GetVal(), sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mLife.GetVal(),
+ fx->mFlags);
break;
//---------
case CameraShake:
- //---------
+ //---------
// It calculates how intense the shake should be based on how close you are to the origin you pass in here
// elasticity is actually the intensity...radius is the distance in which the shake will have some effect
// life is how long the effect lasts.
- theFxHelper.CameraShake( org, fx->mElasticity.GetVal(), fx->mRadius.GetVal(), fx->mLife.GetVal() );
+ theFxHelper.CameraShake(org, fx->mElasticity.GetVal(), fx->mRadius.GetVal(), fx->mLife.GetVal());
break;
//--------------
case ScreenFlash:
- //--------------
+ //--------------
- FX_AddFlash( org,
- sRGB, eRGB, fx->mRGBParm.GetVal(),
- fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), fx->mFlags );
+ FX_AddFlash(org, sRGB, eRGB, fx->mRGBParm.GetVal(), fx->mLife.GetVal(), fx->mMediaHandles.GetHandle(), fx->mFlags);
break;
default:
@@ -1923,12 +1590,10 @@ void CFxScheduler::CreateEffect( CPrimitiveTemplate *fx, const vec3_t origin, ve
}
// Track when we need to clean ourselves up if we are a copy
- if ( fx->mCopy )
- {
+ if (fx->mCopy) {
fx->mRefCount--;
- if ( fx->mRefCount <= 0 )
- {
+ if (fx->mRefCount <= 0) {
delete fx;
}
}
diff --git a/code/cgame/FxSystem.cpp b/code/cgame/FxSystem.cpp
index 0a0112d136..c08a5473c2 100644
--- a/code/cgame/FxSystem.cpp
+++ b/code/cgame/FxSystem.cpp
@@ -23,54 +23,45 @@ along with this program; if not, see .
#include "common_headers.h"
#if !defined(FX_SCHEDULER_H_INC)
- #include "FxScheduler.h"
+#include "FxScheduler.h"
#endif
-#include "cg_media.h" //for cgs.model_draw for G2
+#include "cg_media.h" //for cgs.model_draw for G2
-extern vmCvar_t fx_debug;
-extern vmCvar_t fx_freeze;
+extern vmCvar_t fx_debug;
+extern vmCvar_t fx_freeze;
-extern void CG_ExplosionEffects( vec3_t origin, float intensity, int radius, int time );
+extern void CG_ExplosionEffects(vec3_t origin, float intensity, int radius, int time);
// Stuff for the FxHelper
//------------------------------------------------------
-void SFxHelper::Init()
-{
- mTime = 0;
-}
+void SFxHelper::Init() { mTime = 0; }
//------------------------------------------------------
-void SFxHelper::Print( const char *msg, ... )
-{
+void SFxHelper::Print(const char *msg, ...) {
#ifndef FINAL_BUILD
- va_list argptr;
- char text[1024];
+ va_list argptr;
+ char text[1024];
- va_start( argptr, msg );
- Q_vsnprintf (text, sizeof(text), msg, argptr);
- va_end( argptr );
+ va_start(argptr, msg);
+ Q_vsnprintf(text, sizeof(text), msg, argptr);
+ va_end(argptr);
- gi.Printf( text );
+ gi.Printf(text);
#endif
}
//------------------------------------------------------
-void SFxHelper::AdjustTime( int frameTime )
-{
- if ( fx_freeze.integer || ( frameTime <= 0 ))
- {
+void SFxHelper::AdjustTime(int frameTime) {
+ if (fx_freeze.integer || (frameTime <= 0)) {
// Allow no time progression when we are paused.
mFrameTime = 0;
mFloatFrameTime = 0.0f;
- }
- else
- {
- if ( !cg_paused.integer )
- {
- if ( frameTime > 300 ) // hack for returning from paused and time bursts
+ } else {
+ if (!cg_paused.integer) {
+ if (frameTime > 300) // hack for returning from paused and time bursts
{
frameTime = 300;
}
@@ -83,128 +74,88 @@ void SFxHelper::AdjustTime( int frameTime )
}
//------------------------------------------------------
-int SFxHelper::OpenFile( const char *file, fileHandle_t *fh, int mode )
-{
-// char path[256];
+int SFxHelper::OpenFile(const char *file, fileHandle_t *fh, int mode) {
+ // char path[256];
-// sprintf( path, "%s/%s", FX_FILE_PATH, file );
- return cgi_FS_FOpenFile( file, fh, FS_READ );
+ // sprintf( path, "%s/%s", FX_FILE_PATH, file );
+ return cgi_FS_FOpenFile(file, fh, FS_READ);
}
//------------------------------------------------------
-int SFxHelper::ReadFile( void *data, int len, fileHandle_t fh )
-{
- return cgi_FS_Read( data, len, fh );
-}
+int SFxHelper::ReadFile(void *data, int len, fileHandle_t fh) { return cgi_FS_Read(data, len, fh); }
//------------------------------------------------------
-void SFxHelper::CloseFile( fileHandle_t fh )
-{
- cgi_FS_FCloseFile( fh );
-}
+void SFxHelper::CloseFile(fileHandle_t fh) { cgi_FS_FCloseFile(fh); }
//------------------------------------------------------
-void SFxHelper::PlaySound( const vec3_t org, int entityNum, int entchannel, int sfxHandle )
-{
- cgi_S_StartSound( org, entityNum, entchannel, sfxHandle );
-}
+void SFxHelper::PlaySound(const vec3_t org, int entityNum, int entchannel, int sfxHandle) { cgi_S_StartSound(org, entityNum, entchannel, sfxHandle); }
//------------------------------------------------------
-void SFxHelper::PlayLocalSound( int sfxHandle, int channelNum )
-{
- cgi_S_StartLocalSound(sfxHandle, channelNum);
-}
+void SFxHelper::PlayLocalSound(int sfxHandle, int channelNum) { cgi_S_StartLocalSound(sfxHandle, channelNum); }
//------------------------------------------------------
-void SFxHelper::Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max,
- vec3_t end, int skipEntNum, int flags )
-{
- CG_Trace( tr, start, min, max, end, skipEntNum, flags );
+void SFxHelper::Trace(trace_t *tr, vec3_t start, vec3_t min, vec3_t max, vec3_t end, int skipEntNum, int flags) {
+ CG_Trace(tr, start, min, max, end, skipEntNum, flags);
}
-void SFxHelper::G2Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max,
- vec3_t end, int skipEntNum, int flags )
-{
- //CG_Trace( tr, start, min, max, end, skipEntNum, flags, G2_COLLIDE );
+void SFxHelper::G2Trace(trace_t *tr, vec3_t start, vec3_t min, vec3_t max, vec3_t end, int skipEntNum, int flags) {
+ // CG_Trace( tr, start, min, max, end, skipEntNum, flags, G2_COLLIDE );
gi.trace(tr, start, NULL, NULL, end, skipEntNum, flags, G2_COLLIDE, 0);
}
//------------------------------------------------------
-void SFxHelper::AddFxToScene( refEntity_t *ent )
-{
- cgi_R_AddRefEntityToScene( ent );
-}
+void SFxHelper::AddFxToScene(refEntity_t *ent) { cgi_R_AddRefEntityToScene(ent); }
//------------------------------------------------------
-int SFxHelper::RegisterShader( const gsl::cstring_span& shader )
-{
+int SFxHelper::RegisterShader(const gsl::cstring_span &shader) {
// TODO: it would be nice to change the ABI here to allow for passing of string views
- return cgi_R_RegisterShader( std::string( shader.begin(), shader.end() ).c_str() );
+ return cgi_R_RegisterShader(std::string(shader.begin(), shader.end()).c_str());
}
//------------------------------------------------------
-int SFxHelper::RegisterSound( const gsl::cstring_span& sound )
-{
+int SFxHelper::RegisterSound(const gsl::cstring_span &sound) {
// TODO: it would be nice to change the ABI here to allow for passing of string views
- return cgi_S_RegisterSound( std::string( sound.begin(), sound.end() ).c_str() );
+ return cgi_S_RegisterSound(std::string(sound.begin(), sound.end()).c_str());
}
//------------------------------------------------------
-int SFxHelper::RegisterModel( const gsl::cstring_span& model )
-{
- return cgi_R_RegisterModel( std::string( model.begin(), model.end() ).c_str() );
-}
+int SFxHelper::RegisterModel(const gsl::cstring_span &model) { return cgi_R_RegisterModel(std::string(model.begin(), model.end()).c_str()); }
//------------------------------------------------------
-void SFxHelper::AddLightToScene( vec3_t org, float radius, float red, float green, float blue )
-{
- cgi_R_AddLightToScene( org, radius, red, green, blue );
-}
+void SFxHelper::AddLightToScene(vec3_t org, float radius, float red, float green, float blue) { cgi_R_AddLightToScene(org, radius, red, green, blue); }
//------------------------------------------------------
-void SFxHelper::AddPolyToScene( int shader, int count, polyVert_t *verts )
-{
- cgi_R_AddPolyToScene( shader, count, verts );
-}
+void SFxHelper::AddPolyToScene(int shader, int count, polyVert_t *verts) { cgi_R_AddPolyToScene(shader, count, verts); }
//------------------------------------------------------
-void SFxHelper::CameraShake( vec3_t origin, float intensity, int radius, int time )
-{
- CG_ExplosionEffects( origin, intensity, radius, time );
-}
+void SFxHelper::CameraShake(vec3_t origin, float intensity, int radius, int time) { CG_ExplosionEffects(origin, intensity, radius, time); }
//------------------------------------------------------
-int SFxHelper::GetOriginAxisFromBolt(const centity_t ¢, int modelNum, int boltNum, vec3_t /*out*/origin, vec3_t /*out*/axis[3])
-{
- if ((cg.time-cent.snapShotTime) > 200)
- { //you were added more than 200ms ago, so I say you are no longer valid/in our snapshot.
+int SFxHelper::GetOriginAxisFromBolt(const centity_t ¢, int modelNum, int boltNum, vec3_t /*out*/ origin, vec3_t /*out*/ axis[3]) {
+ if ((cg.time - cent.snapShotTime) > 200) { // you were added more than 200ms ago, so I say you are no longer valid/in our snapshot.
return 0;
}
int doesBoltExist;
- mdxaBone_t boltMatrix;
- vec3_t G2Angles = {cent.lerpAngles[0] , cent.lerpAngles[1], cent.lerpAngles[2]};
- if ( cent.currentState.eType == ET_PLAYER )
- {//players use cent.renderAngles
- VectorCopy( cent.renderAngles, G2Angles );
-
- if ( cent.gent //has a game entity
- && cent.gent->s.m_iVehicleNum != 0 //in a vehicle
- && cent.gent->m_pVehicle //have a valid vehicle pointer
- && cent.gent->m_pVehicle->m_pVehicleInfo->type != VH_FIGHTER //it's not a fighter
- && cent.gent->m_pVehicle->m_pVehicleInfo->type != VH_SPEEDER //not a speeder
- )
- {
- G2Angles[PITCH]=0;
- G2Angles[ROLL] =0;
+ mdxaBone_t boltMatrix;
+ vec3_t G2Angles = {cent.lerpAngles[0], cent.lerpAngles[1], cent.lerpAngles[2]};
+ if (cent.currentState.eType == ET_PLAYER) { // players use cent.renderAngles
+ VectorCopy(cent.renderAngles, G2Angles);
+
+ if (cent.gent // has a game entity
+ && cent.gent->s.m_iVehicleNum != 0 // in a vehicle
+ && cent.gent->m_pVehicle // have a valid vehicle pointer
+ && cent.gent->m_pVehicle->m_pVehicleInfo->type != VH_FIGHTER // it's not a fighter
+ && cent.gent->m_pVehicle->m_pVehicleInfo->type != VH_SPEEDER // not a speeder
+ ) {
+ G2Angles[PITCH] = 0;
+ G2Angles[ROLL] = 0;
}
}
// go away and get me the bolt position for this frame please
- doesBoltExist = gi.G2API_GetBoltMatrix(cent.gent->ghoul2, modelNum,
- boltNum, &boltMatrix, G2Angles,
- cent.lerpOrigin, cg.time, cgs.model_draw,
- cent.currentState.modelScale);
+ doesBoltExist = gi.G2API_GetBoltMatrix(cent.gent->ghoul2, modelNum, boltNum, &boltMatrix, G2Angles, cent.lerpOrigin, cg.time, cgs.model_draw,
+ cent.currentState.modelScale);
// set up the axis and origin we need for the actual effect spawning
origin[0] = boltMatrix.matrix[0][3];
origin[1] = boltMatrix.matrix[1][3];
diff --git a/code/cgame/FxTemplate.cpp b/code/cgame/FxTemplate.cpp
index 78b3503fc2..633140b4ca 100644
--- a/code/cgame/FxTemplate.cpp
+++ b/code/cgame/FxTemplate.cpp
@@ -23,7 +23,7 @@ along with this program; if not, see .
#include "common_headers.h"
#if !defined(FX_SCHEDULER_H_INC)
- #include "FxScheduler.h"
+#include "FxScheduler.h"
#endif
#include "../game/genericparser2.h"
@@ -41,8 +41,7 @@ along with this program; if not, see .
// Return:
// none
//------------------------------------------------------
-CPrimitiveTemplate::CPrimitiveTemplate()
-{
+CPrimitiveTemplate::CPrimitiveTemplate() {
// We never start out as a copy or with a name
mCopy = false;
mName[0] = 0;
@@ -50,134 +49,133 @@ CPrimitiveTemplate::CPrimitiveTemplate()
mFlags = mSpawnFlags = 0;
- mLife.SetRange( 50.0f, 50.0f );
- mSpawnCount.SetRange( 1.0f, 1.0f );
- mRadius.SetRange( 10.0f, 10.0f );
- mHeight.SetRange( 10.0f, 10.0f );
- mWindModifier.SetRange( 1.0f, 1.0f );
+ mLife.SetRange(50.0f, 50.0f);
+ mSpawnCount.SetRange(1.0f, 1.0f);
+ mRadius.SetRange(10.0f, 10.0f);
+ mHeight.SetRange(10.0f, 10.0f);
+ mWindModifier.SetRange(1.0f, 1.0f);
- VectorSet( mMin, 0.0f, 0.0f, 0.0f );
- VectorSet( mMax, 0.0f, 0.0f, 0.0f );
+ VectorSet(mMin, 0.0f, 0.0f, 0.0f);
+ VectorSet(mMax, 0.0f, 0.0f, 0.0f);
- mRedStart.SetRange( 1.0f, 1.0f );
- mGreenStart.SetRange( 1.0f, 1.0f );
- mBlueStart.SetRange( 1.0f, 1.0f );
+ mRedStart.SetRange(1.0f, 1.0f);
+ mGreenStart.SetRange(1.0f, 1.0f);
+ mBlueStart.SetRange(1.0f, 1.0f);
- mRedEnd.SetRange( 1.0f, 1.0f );
- mGreenEnd.SetRange( 1.0f, 1.0f );
- mBlueEnd.SetRange( 1.0f, 1.0f );
+ mRedEnd.SetRange(1.0f, 1.0f);
+ mGreenEnd.SetRange(1.0f, 1.0f);
+ mBlueEnd.SetRange(1.0f, 1.0f);
- mAlphaStart.SetRange( 1.0f, 1.0f );
- mAlphaEnd.SetRange( 1.0f, 1.0f );
+ mAlphaStart.SetRange(1.0f, 1.0f);
+ mAlphaEnd.SetRange(1.0f, 1.0f);
- mSizeStart.SetRange( 1.0f, 1.0f );
- mSizeEnd.SetRange( 1.0f, 1.0f );
+ mSizeStart.SetRange(1.0f, 1.0f);
+ mSizeEnd.SetRange(1.0f, 1.0f);
- mSize2Start.SetRange( 1.0f, 1.0f );
- mSize2End.SetRange( 1.0f, 1.0f );
+ mSize2Start.SetRange(1.0f, 1.0f);
+ mSize2End.SetRange(1.0f, 1.0f);
- mLengthStart.SetRange( 1.0f, 1.0f );
- mLengthEnd.SetRange( 1.0f, 1.0f );
+ mLengthStart.SetRange(1.0f, 1.0f);
+ mLengthEnd.SetRange(1.0f, 1.0f);
- mTexCoordS.SetRange( 1.0f, 1.0f );
- mTexCoordT.SetRange( 1.0f, 1.0f );
+ mTexCoordS.SetRange(1.0f, 1.0f);
+ mTexCoordT.SetRange(1.0f, 1.0f);
- mVariance.SetRange( 1.0f, 1.0f );
- mDensity.SetRange( 10.0f, 10.0f );// default this high so it doesn't do bad things
+ mVariance.SetRange(1.0f, 1.0f);
+ mDensity.SetRange(10.0f, 10.0f); // default this high so it doesn't do bad things
}
//-----------------------------------------------------------
-void CPrimitiveTemplate::operator=(const CPrimitiveTemplate &that)
-{
+void CPrimitiveTemplate::operator=(const CPrimitiveTemplate &that) {
// I'm assuming that doing a memcpy wouldn't work here
// If you are looking at this and know a better way to do this, please tell me.
- strcpy( mName, that.mName );
+ strcpy(mName, that.mName);
- mType = that.mType;
+ mType = that.mType;
- mSpawnDelay = that.mSpawnDelay;
- mSpawnCount = that.mSpawnCount;
- mLife = that.mLife;
- mCullRange = that.mCullRange;
+ mSpawnDelay = that.mSpawnDelay;
+ mSpawnCount = that.mSpawnCount;
+ mLife = that.mLife;
+ mCullRange = that.mCullRange;
- mMediaHandles = that.mMediaHandles;
- mImpactFxHandles = that.mImpactFxHandles;
- mDeathFxHandles = that.mDeathFxHandles;
- mEmitterFxHandles = that.mEmitterFxHandles;
- mPlayFxHandles = that.mPlayFxHandles;
+ mMediaHandles = that.mMediaHandles;
+ mImpactFxHandles = that.mImpactFxHandles;
+ mDeathFxHandles = that.mDeathFxHandles;
+ mEmitterFxHandles = that.mEmitterFxHandles;
+ mPlayFxHandles = that.mPlayFxHandles;
- mFlags = that.mFlags;
- mSpawnFlags = that.mSpawnFlags;
+ mFlags = that.mFlags;
+ mSpawnFlags = that.mSpawnFlags;
- VectorCopy( that.mMin, mMin );
- VectorCopy( that.mMax, mMax );
+ VectorCopy(that.mMin, mMin);
+ VectorCopy(that.mMax, mMax);
- mOrigin1X = that.mOrigin1X;
- mOrigin1Y = that.mOrigin1Y;
- mOrigin1Z = that.mOrigin1Z;
+ mOrigin1X = that.mOrigin1X;
+ mOrigin1Y = that.mOrigin1Y;
+ mOrigin1Z = that.mOrigin1Z;
- mOrigin2X = that.mOrigin2X;
- mOrigin2Y = that.mOrigin2Y;
- mOrigin2Z = that.mOrigin2Z;
+ mOrigin2X = that.mOrigin2X;
+ mOrigin2Y = that.mOrigin2Y;
+ mOrigin2Z = that.mOrigin2Z;
- mRadius = that.mRadius;
- mHeight = that.mHeight;
- mWindModifier = that.mWindModifier;
+ mRadius = that.mRadius;
+ mHeight = that.mHeight;
+ mWindModifier = that.mWindModifier;
- mRotation = that.mRotation;
- mRotationDelta = that.mRotationDelta;
+ mRotation = that.mRotation;
+ mRotationDelta = that.mRotationDelta;
- mAngle1 = that.mAngle1;
- mAngle2 = that.mAngle2;
- mAngle3 = that.mAngle3;
+ mAngle1 = that.mAngle1;
+ mAngle2 = that.mAngle2;
+ mAngle3 = that.mAngle3;
- mAngle1Delta = that.mAngle1Delta;
- mAngle2Delta = that.mAngle2Delta;
- mAngle3Delta = that.mAngle3Delta;
+ mAngle1Delta = that.mAngle1Delta;
+ mAngle2Delta = that.mAngle2Delta;
+ mAngle3Delta = that.mAngle3Delta;
- mVelX = that.mVelX;
- mVelY = that.mVelY;
- mVelZ = that.mVelZ;
+ mVelX = that.mVelX;
+ mVelY = that.mVelY;
+ mVelZ = that.mVelZ;
- mAccelX = that.mAccelX;
- mAccelY = that.mAccelY;
- mAccelZ = that.mAccelZ;
+ mAccelX = that.mAccelX;
+ mAccelY = that.mAccelY;
+ mAccelZ = that.mAccelZ;
- mGravity = that.mGravity;
+ mGravity = that.mGravity;
- mDensity = that.mDensity;
- mVariance = that.mVariance;
+ mDensity = that.mDensity;
+ mVariance = that.mVariance;
- mRedStart = that.mRedStart;
- mGreenStart = that.mGreenStart;
- mBlueStart = that.mBlueStart;
+ mRedStart = that.mRedStart;
+ mGreenStart = that.mGreenStart;
+ mBlueStart = that.mBlueStart;
- mRedEnd = that.mRedEnd;
- mGreenEnd = that.mGreenEnd;
- mBlueEnd = that.mBlueEnd;
+ mRedEnd = that.mRedEnd;
+ mGreenEnd = that.mGreenEnd;
+ mBlueEnd = that.mBlueEnd;
- mRGBParm = that.mRGBParm;
+ mRGBParm = that.mRGBParm;
- mAlphaStart = that.mAlphaStart;
- mAlphaEnd = that.mAlphaEnd;
- mAlphaParm = that.mAlphaParm;
+ mAlphaStart = that.mAlphaStart;
+ mAlphaEnd = that.mAlphaEnd;
+ mAlphaParm = that.mAlphaParm;
- mSizeStart = that.mSizeStart;
- mSizeEnd = that.mSizeEnd;
- mSizeParm = that.mSizeParm;
+ mSizeStart = that.mSizeStart;
+ mSizeEnd = that.mSizeEnd;
+ mSizeParm = that.mSizeParm;
- mSize2Start = that.mSize2Start;
- mSize2End = that.mSize2End;
- mSize2Parm = that.mSize2Parm;
+ mSize2Start = that.mSize2Start;
+ mSize2End = that.mSize2End;
+ mSize2Parm = that.mSize2Parm;
- mLengthStart = that.mLengthStart;
- mLengthEnd = that.mLengthEnd;
- mLengthParm = that.mLengthParm;
+ mLengthStart = that.mLengthStart;
+ mLengthEnd = that.mLengthEnd;
+ mLengthParm = that.mLengthParm;
- mTexCoordS = that.mTexCoordS;
- mTexCoordT = that.mTexCoordT;
+ mTexCoordS = that.mTexCoordS;
+ mTexCoordT = that.mTexCoordT;
- mElasticity = that.mElasticity;
+ mElasticity = that.mElasticity;
}
//------------------------------------------------------
@@ -193,24 +191,19 @@ void CPrimitiveTemplate::operator=(const CPrimitiveTemplate &that)
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_span& val, float& min, float& max )
-{
+bool CPrimitiveTemplate::ParseFloat(const gsl::cstring_span &val, float &min, float &max) {
// attempt to read out the values
- int v = Q::sscanf( val, min, max );
+ int v = Q::sscanf(val, min, max);
- if ( v == 0 )
- { // nothing was there, failure
+ if (v == 0) { // nothing was there, failure
return false;
- }
- else if ( v == 1 )
- { // only one field entered, this is ok, but we should copy min into max
+ } else if (v == 1) { // only one field entered, this is ok, but we should copy min into max
max = min;
}
return true;
}
-
//------------------------------------------------------
// ParseVector
// Removes up to six values from a passed in string and
@@ -224,60 +217,44 @@ bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_span& val, float& min, f
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseVector( const gsl::cstring_span& val, vec3_t min, vec3_t max )
-{
+bool CPrimitiveTemplate::ParseVector(const gsl::cstring_span &val, vec3_t min, vec3_t max) {
// we don't allow passing in a null
- if ( min == nullptr || max == nullptr )
- {
+ if (min == nullptr || max == nullptr) {
return false;
}
// attempt to read out our values
- int v = Q::sscanf( val, min[0], min[1], min[2], max[0], max[1], max[2] );
+ int v = Q::sscanf(val, min[0], min[1], min[2], max[0], max[1], max[2]);
// Check for completeness
- if ( v < 3 || v == 4 || v == 5 )
- { // not a complete value
+ if (v < 3 || v == 4 || v == 5) { // not a complete value
return false;
- }
- else if ( v == 3 )
- { // only a min was entered, so copy the result into max
- VectorCopy( min, max );
+ } else if (v == 3) { // only a min was entered, so copy the result into max
+ VectorCopy(min, max);
}
return true;
}
-namespace detail
-{
- // calls Q::sscanf with the elements of the given array as arguments
+namespace detail {
+// calls Q::sscanf with the elements of the given array as arguments
- template< std::size_t remaining >
- struct ScanStrings
- {
- template< std::size_t count, typename... Args >
- static int call( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr, Args&... args )
- {
- return ScanStrings< remaining - 1 >::call( val, arr, arr[ remaining - 1 ], args... );
- }
- };
+template struct ScanStrings {
+ template static int call(const gsl::cstring_span &val, std::array &arr, Args &...args) {
+ return ScanStrings::call(val, arr, arr[remaining - 1], args...);
+ }
+};
- template<>
- struct ScanStrings< 0 >
- {
- template< std::size_t count, typename... Args >
- static int call( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr, Args&... args )
- {
- return Q::sscanf( val, args... );
- }
- };
-}
+template <> struct ScanStrings<0> {
+ template static int call(const gsl::cstring_span &val, std::array &arr, Args &...args) {
+ return Q::sscanf(val, args...);
+ }
+};
+} // namespace detail
-template< std::size_t count >
-static gsl::span< gsl::cstring_span > scanStrings( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr )
-{
- int numParsed = detail::ScanStrings< count >::call( val, arr );
- return{ arr.data(), arr.data() + numParsed };
+template static gsl::span scanStrings(const gsl::cstring_span &val, std::array &arr) {
+ int numParsed = detail::ScanStrings::call(val, arr);
+ return {arr.data(), arr.data() + numParsed};
}
//------------------------------------------------------
@@ -293,34 +270,26 @@ static gsl::span< gsl::cstring_span > scanStrings( const gsl::cstring_span& val,
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_span& val, int& flags )
-{
+bool CPrimitiveTemplate::ParseGroupFlags(const gsl::cstring_span &val, int &flags) {
// For a sub group, really you probably only have one or two flags set
- std::array< gsl::cstring_span, 4 > flag;
+ std::array flag;
- const auto availableFlag = scanStrings( val, flag );
+ const auto availableFlag = scanStrings(val, flag);
// Clear out the flags field, then convert the flag string to an actual value ( use generic flags )
flags = 0;
bool ok = true;
- for( auto& cur : availableFlag )
- {
- static StringViewIMap< int > flagNames{
- { CSTRING_VIEW( "linear" ), FX_LINEAR },
- { CSTRING_VIEW( "nonlinear" ), FX_NONLINEAR },
- { CSTRING_VIEW( "wave" ), FX_WAVE },
- { CSTRING_VIEW( "random" ), FX_RAND },
- { CSTRING_VIEW( "clamp" ), FX_CLAMP },
+ for (auto &cur : availableFlag) {
+ static StringViewIMap flagNames{
+ {CSTRING_VIEW("linear"), FX_LINEAR}, {CSTRING_VIEW("nonlinear"), FX_NONLINEAR}, {CSTRING_VIEW("wave"), FX_WAVE},
+ {CSTRING_VIEW("random"), FX_RAND}, {CSTRING_VIEW("clamp"), FX_CLAMP},
};
- auto pos = flagNames.find( cur );
- if( pos == flagNames.end() )
- {
+ auto pos = flagNames.find(cur);
+ if (pos == flagNames.end()) {
ok = false;
- }
- else
- {
+ } else {
flags |= pos->second;
}
}
@@ -338,13 +307,11 @@ bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_span& val, int& fla
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseMin( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseMin(const gsl::cstring_span &val) {
vec3_t min;
- if ( ParseVector( val, min, min ) == true )
- {
- VectorCopy( min, mMin );
+ if (ParseVector(val, min, min) == true) {
+ VectorCopy(min, mMin);
// We assume that if a min is being set that we are using physics and a bounding box
mFlags |= (FX_USE_BBOX | FX_APPLY_PHYSICS);
@@ -364,13 +331,11 @@ bool CPrimitiveTemplate::ParseMin( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseMax( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseMax(const gsl::cstring_span &val) {
vec3_t max;
- if ( ParseVector( val, max, max ) == true )
- {
- VectorCopy( max, mMax );
+ if (ParseVector(val, max, max) == true) {
+ VectorCopy(max, mMax);
// We assume that if a max is being set that we are using physics and a bounding box
mFlags |= (FX_USE_BBOX | FX_APPLY_PHYSICS);
@@ -390,13 +355,11 @@ bool CPrimitiveTemplate::ParseMax( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseLife( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseLife(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mLife.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mLife.SetRange(min, max);
return true;
}
@@ -413,13 +376,11 @@ bool CPrimitiveTemplate::ParseLife( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseDelay(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSpawnDelay.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSpawnDelay.SetRange(min, max);
return true;
}
@@ -436,13 +397,11 @@ bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseCount( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseCount(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSpawnCount.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSpawnCount.SetRange(min, max);
return true;
}
@@ -459,17 +418,15 @@ bool CPrimitiveTemplate::ParseCount( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseElasticity(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mElasticity.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mElasticity.SetRange(min, max);
// We assume that if elasticity is set that we are using physics, but don't assume we are
// using a bounding box unless a min/max are explicitly set
-// mFlags |= FX_APPLY_PHYSICS;
+ // mFlags |= FX_APPLY_PHYSICS;
return true;
}
@@ -486,15 +443,13 @@ bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseOrigin1(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mOrigin1X.SetRange( min[0], max[0] );
- mOrigin1Y.SetRange( min[1], max[1] );
- mOrigin1Z.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mOrigin1X.SetRange(min[0], max[0]);
+ mOrigin1Y.SetRange(min[1], max[1]);
+ mOrigin1Z.SetRange(min[2], max[2]);
return true;
}
@@ -511,15 +466,13 @@ bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseOrigin2(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mOrigin2X.SetRange( min[0], max[0] );
- mOrigin2Y.SetRange( min[1], max[1] );
- mOrigin2Z.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mOrigin2X.SetRange(min[0], max[0]);
+ mOrigin2Y.SetRange(min[1], max[1]);
+ mOrigin2Z.SetRange(min[2], max[2]);
return true;
}
@@ -536,13 +489,11 @@ bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRadius(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mRadius.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mRadius.SetRange(min, max);
return true;
}
@@ -559,13 +510,11 @@ bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseHeight(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mHeight.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mHeight.SetRange(min, max);
return true;
}
@@ -582,13 +531,11 @@ bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseWindModifier( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseWindModifier(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mWindModifier.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mWindModifier.SetRange(min, max);
return true;
}
@@ -605,13 +552,11 @@ bool CPrimitiveTemplate::ParseWindModifier( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRotation(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == qtrue )
- {
- mRotation.SetRange( min, max );
+ if (ParseFloat(val, min, max) == qtrue) {
+ mRotation.SetRange(min, max);
return true;
}
@@ -628,13 +573,11 @@ bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRotationDelta(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == qtrue )
- {
- mRotationDelta.SetRange( min, max );
+ if (ParseFloat(val, min, max) == qtrue) {
+ mRotationDelta.SetRange(min, max);
return true;
}
@@ -651,15 +594,13 @@ bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAngle(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mAngle1.SetRange( min[0], max[0] );
- mAngle2.SetRange( min[1], max[1] );
- mAngle3.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mAngle1.SetRange(min[0], max[0]);
+ mAngle2.SetRange(min[1], max[1]);
+ mAngle3.SetRange(min[2], max[2]);
return true;
}
@@ -676,15 +617,13 @@ bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAngleDelta(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mAngle1Delta.SetRange( min[0], max[0] );
- mAngle2Delta.SetRange( min[1], max[1] );
- mAngle3Delta.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mAngle1Delta.SetRange(min[0], max[0]);
+ mAngle2Delta.SetRange(min[1], max[1]);
+ mAngle3Delta.SetRange(min[2], max[2]);
return true;
}
@@ -701,15 +640,13 @@ bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseVelocity(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mVelX.SetRange( min[0], max[0] );
- mVelY.SetRange( min[1], max[1] );
- mVelZ.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mVelX.SetRange(min[0], max[0]);
+ mVelY.SetRange(min[1], max[1]);
+ mVelZ.SetRange(min[2], max[2]);
return true;
}
@@ -727,41 +664,36 @@ bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseFlags(const gsl::cstring_span &val) {
// For a primitive, really you probably only have two or less flags set
- std::array< gsl::cstring_span, 7 > flag;
-
- const auto availableFlag = scanStrings( val, flag );
-
- bool ok = true;
- for( auto& cur : availableFlag )
- {
- static StringViewIMap< int > flagNames{
- { CSTRING_VIEW( "useModel" ), FX_ATTACHED_MODEL },
- { CSTRING_VIEW( "useBBox" ), FX_USE_BBOX },
- { CSTRING_VIEW( "usePhysics" ), FX_APPLY_PHYSICS },
- { CSTRING_VIEW( "expensivePhysics" ), FX_EXPENSIVE_PHYSICS },
- //rww - begin g2 stuff
- { CSTRING_VIEW( "ghoul2Collision" ), ( FX_GHOUL2_TRACE | FX_APPLY_PHYSICS | FX_EXPENSIVE_PHYSICS ) },
- { CSTRING_VIEW( "ghoul2Decals" ), FX_GHOUL2_DECALS },
- //rww - end
- { CSTRING_VIEW( "impactKills" ), FX_KILL_ON_IMPACT },
- { CSTRING_VIEW( "impactFx" ), FX_IMPACT_RUNS_FX },
- { CSTRING_VIEW( "deathFx" ), FX_DEATH_RUNS_FX },
- { CSTRING_VIEW( "useAlpha" ), FX_USE_ALPHA },
- { CSTRING_VIEW( "emitFx" ), FX_EMIT_FX },
- { CSTRING_VIEW( "depthHack" ), FX_DEPTH_HACK },
- { CSTRING_VIEW( "setShaderTime" ), FX_SET_SHADER_TIME },
+ std::array flag;
+
+ const auto availableFlag = scanStrings(val, flag);
+
+ bool ok = true;
+ for (auto &cur : availableFlag) {
+ static StringViewIMap flagNames{
+ {CSTRING_VIEW("useModel"), FX_ATTACHED_MODEL},
+ {CSTRING_VIEW("useBBox"), FX_USE_BBOX},
+ {CSTRING_VIEW("usePhysics"), FX_APPLY_PHYSICS},
+ {CSTRING_VIEW("expensivePhysics"), FX_EXPENSIVE_PHYSICS},
+ // rww - begin g2 stuff
+ {CSTRING_VIEW("ghoul2Collision"), (FX_GHOUL2_TRACE | FX_APPLY_PHYSICS | FX_EXPENSIVE_PHYSICS)},
+ {CSTRING_VIEW("ghoul2Decals"), FX_GHOUL2_DECALS},
+ // rww - end
+ {CSTRING_VIEW("impactKills"), FX_KILL_ON_IMPACT},
+ {CSTRING_VIEW("impactFx"), FX_IMPACT_RUNS_FX},
+ {CSTRING_VIEW("deathFx"), FX_DEATH_RUNS_FX},
+ {CSTRING_VIEW("useAlpha"), FX_USE_ALPHA},
+ {CSTRING_VIEW("emitFx"), FX_EMIT_FX},
+ {CSTRING_VIEW("depthHack"), FX_DEPTH_HACK},
+ {CSTRING_VIEW("setShaderTime"), FX_SET_SHADER_TIME},
};
- auto pos = flagNames.find( cur );
- if( pos == flagNames.end() )
- { // we have badness going on, but continue on in case there are any valid fields in here
+ auto pos = flagNames.find(cur);
+ if (pos == flagNames.end()) { // we have badness going on, but continue on in case there are any valid fields in here
ok = false;
- }
- else
- {
+ } else {
mFlags |= pos->second;
}
}
@@ -780,39 +712,34 @@ bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_span& val )
-{
- std::array< gsl::cstring_span, 7 > flag;
+bool CPrimitiveTemplate::ParseSpawnFlags(const gsl::cstring_span &val) {
+ std::array flag;
// For a primitive, really you probably only have two or less flags set
- const auto availableFlag = scanStrings( val, flag );
+ const auto availableFlag = scanStrings(val, flag);
bool ok = true;
- for( auto& cur : availableFlag )
- {
- static StringViewIMap< int > flagNames{
- { CSTRING_VIEW( "org2fromTrace" ), FX_ORG2_FROM_TRACE },
- { CSTRING_VIEW( "traceImpactFx" ), FX_TRACE_IMPACT_FX },
- { CSTRING_VIEW( "org2isOffset" ), FX_ORG2_IS_OFFSET },
- { CSTRING_VIEW( "cheapOrgCalc" ), FX_CHEAP_ORG_CALC },
- { CSTRING_VIEW( "cheapOrg2Calc" ), FX_CHEAP_ORG2_CALC },
- { CSTRING_VIEW( "absoluteVel" ), FX_VEL_IS_ABSOLUTE },
- { CSTRING_VIEW( "absoluteAccel" ), FX_ACCEL_IS_ABSOLUTE },
- { CSTRING_VIEW( "orgOnSphere" ), FX_ORG_ON_SPHERE },
- { CSTRING_VIEW( "orgOnCylinder" ), FX_ORG_ON_CYLINDER },
- { CSTRING_VIEW( "axisFromSphere" ), FX_AXIS_FROM_SPHERE },
- { CSTRING_VIEW( "randrotaroundfwd" ), FX_RAND_ROT_AROUND_FWD },
- { CSTRING_VIEW( "evenDistribution" ), FX_EVEN_DISTRIBUTION },
- { CSTRING_VIEW( "rgbComponentInterpolation" ), FX_RGB_COMPONENT_INTERP },
- { CSTRING_VIEW( "lessAttenuation" ), FX_SND_LESS_ATTENUATION },
+ for (auto &cur : availableFlag) {
+ static StringViewIMap flagNames{
+ {CSTRING_VIEW("org2fromTrace"), FX_ORG2_FROM_TRACE},
+ {CSTRING_VIEW("traceImpactFx"), FX_TRACE_IMPACT_FX},
+ {CSTRING_VIEW("org2isOffset"), FX_ORG2_IS_OFFSET},
+ {CSTRING_VIEW("cheapOrgCalc"), FX_CHEAP_ORG_CALC},
+ {CSTRING_VIEW("cheapOrg2Calc"), FX_CHEAP_ORG2_CALC},
+ {CSTRING_VIEW("absoluteVel"), FX_VEL_IS_ABSOLUTE},
+ {CSTRING_VIEW("absoluteAccel"), FX_ACCEL_IS_ABSOLUTE},
+ {CSTRING_VIEW("orgOnSphere"), FX_ORG_ON_SPHERE},
+ {CSTRING_VIEW("orgOnCylinder"), FX_ORG_ON_CYLINDER},
+ {CSTRING_VIEW("axisFromSphere"), FX_AXIS_FROM_SPHERE},
+ {CSTRING_VIEW("randrotaroundfwd"), FX_RAND_ROT_AROUND_FWD},
+ {CSTRING_VIEW("evenDistribution"), FX_EVEN_DISTRIBUTION},
+ {CSTRING_VIEW("rgbComponentInterpolation"), FX_RGB_COMPONENT_INTERP},
+ {CSTRING_VIEW("lessAttenuation"), FX_SND_LESS_ATTENUATION},
};
- auto pos = flagNames.find( cur );
- if( pos == flagNames.end() )
- {
+ auto pos = flagNames.find(cur);
+ if (pos == flagNames.end()) {
ok = false;
- }
- else
- {
+ } else {
mSpawnFlags |= pos->second;
}
}
@@ -830,15 +757,13 @@ bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAcceleration(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mAccelX.SetRange( min[0], max[0] );
- mAccelY.SetRange( min[1], max[1] );
- mAccelZ.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mAccelX.SetRange(min[0], max[0]);
+ mAccelY.SetRange(min[1], max[1]);
+ mAccelZ.SetRange(min[2], max[2]);
return true;
}
@@ -855,13 +780,11 @@ bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseGravity(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mGravity.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mGravity.SetRange(min, max);
return true;
}
@@ -880,13 +803,11 @@ bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseDensity(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mDensity.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mDensity.SetRange(min, max);
return true;
}
@@ -906,13 +827,11 @@ bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseVariance(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mVariance.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mVariance.SetRange(min, max);
return true;
}
@@ -929,15 +848,13 @@ bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRGBStart(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mRedStart.SetRange( min[0], max[0] );
- mGreenStart.SetRange( min[1], max[1] );
- mBlueStart.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mRedStart.SetRange(min[0], max[0]);
+ mGreenStart.SetRange(min[1], max[1]);
+ mBlueStart.SetRange(min[2], max[2]);
return true;
}
@@ -954,15 +871,13 @@ bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRGBEnd(const gsl::cstring_span &val) {
vec3_t min, max;
- if ( ParseVector( val, min, max ) == true )
- {
- mRedEnd.SetRange( min[0], max[0] );
- mGreenEnd.SetRange( min[1], max[1] );
- mBlueEnd.SetRange( min[2], max[2] );
+ if (ParseVector(val, min, max) == true) {
+ mRedEnd.SetRange(min[0], max[0]);
+ mGreenEnd.SetRange(min[1], max[1]);
+ mBlueEnd.SetRange(min[2], max[2]);
return true;
}
@@ -979,13 +894,11 @@ bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRGBParm(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mRGBParm.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mRGBParm.SetRange(min, max);
return true;
}
@@ -1002,14 +915,12 @@ bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseRGBFlags(const gsl::cstring_span &val) {
int flags;
- if ( ParseGroupFlags( val, flags ) == true )
- {
+ if (ParseGroupFlags(val, flags) == true) {
// Convert our generic flag values into type specific ones
- mFlags |= ( flags << FX_RGB_SHIFT );
+ mFlags |= (flags << FX_RGB_SHIFT);
return true;
}
@@ -1026,13 +937,11 @@ bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAlphaStart(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mAlphaStart.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mAlphaStart.SetRange(min, max);
return true;
}
@@ -1049,13 +958,11 @@ bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAlphaEnd(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mAlphaEnd.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mAlphaEnd.SetRange(min, max);
return true;
}
@@ -1072,13 +979,11 @@ bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAlphaParm(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mAlphaParm.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mAlphaParm.SetRange(min, max);
return true;
}
@@ -1095,14 +1000,12 @@ bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseAlphaFlags(const gsl::cstring_span &val) {
int flags;
- if ( ParseGroupFlags( val, flags ) == true )
- {
+ if (ParseGroupFlags(val, flags) == true) {
// Convert our generic flag values into type specific ones
- mFlags |= ( flags << FX_ALPHA_SHIFT );
+ mFlags |= (flags << FX_ALPHA_SHIFT);
return true;
}
@@ -1119,13 +1022,11 @@ bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSizeStart(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSizeStart.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSizeStart.SetRange(min, max);
return true;
}
@@ -1142,13 +1043,11 @@ bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSizeEnd(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSizeEnd.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSizeEnd.SetRange(min, max);
return true;
}
@@ -1165,13 +1064,11 @@ bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSizeParm(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSizeParm.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSizeParm.SetRange(min, max);
return true;
}
@@ -1188,14 +1085,12 @@ bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSizeFlags(const gsl::cstring_span &val) {
int flags;
- if ( ParseGroupFlags( val, flags ) == true )
- {
+ if (ParseGroupFlags(val, flags) == true) {
// Convert our generic flag values into type specific ones
- mFlags |= ( flags << FX_SIZE_SHIFT );
+ mFlags |= (flags << FX_SIZE_SHIFT);
return true;
}
@@ -1212,13 +1107,11 @@ bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSize2Start(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSize2Start.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSize2Start.SetRange(min, max);
return true;
}
@@ -1235,13 +1128,11 @@ bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSize2End(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSize2End.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSize2End.SetRange(min, max);
return true;
}
@@ -1258,13 +1149,11 @@ bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSize2Parm(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mSize2Parm.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mSize2Parm.SetRange(min, max);
return true;
}
@@ -1281,14 +1170,12 @@ bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseSize2Flags(const gsl::cstring_span &val) {
int flags;
- if ( ParseGroupFlags( val, flags ) == true )
- {
+ if (ParseGroupFlags(val, flags) == true) {
// Convert our generic flag values into type specific ones
- mFlags |= ( flags << FX_SIZE2_SHIFT );
+ mFlags |= (flags << FX_SIZE2_SHIFT);
return true;
}
@@ -1305,13 +1192,11 @@ bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseLengthStart(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mLengthStart.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mLengthStart.SetRange(min, max);
return true;
}
@@ -1328,13 +1213,11 @@ bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseLengthEnd(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mLengthEnd.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mLengthEnd.SetRange(min, max);
return true;
}
@@ -1351,13 +1234,11 @@ bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseLengthParm(const gsl::cstring_span &val) {
float min, max;
- if ( ParseFloat( val, min, max ) == true )
- {
- mLengthParm.SetRange( min, max );
+ if (ParseFloat(val, min, max) == true) {
+ mLengthParm.SetRange(min, max);
return true;
}
@@ -1374,14 +1255,12 @@ bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseLengthFlags( const gsl::cstring_span& val )
-{
+bool CPrimitiveTemplate::ParseLengthFlags(const gsl::cstring_span &val) {
int flags;
- if ( ParseGroupFlags( val, flags ) == true )
- {
+ if (ParseGroupFlags(val, flags) == true) {
// Convert our generic flag values into type specific ones
- mFlags |= ( flags << FX_LENGTH_SHIFT );
+ mFlags |= (flags << FX_LENGTH_SHIFT);
return true;
}
@@ -1398,22 +1277,18 @@ bool CPrimitiveTemplate::ParseLengthFlags( const gsl::cstring_span& val )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseShaders( const CGPProperty& grp )
-{
+bool CPrimitiveTemplate::ParseShaders(const CGPProperty &grp) {
bool any = false;
- for( auto& value : grp.GetValues() )
- {
- if( !value.empty() )
- {
+ for (auto &value : grp.GetValues()) {
+ if (!value.empty()) {
any = true;
- int handle = theFxHelper.RegisterShader( value );
- mMediaHandles.AddHandle( handle );
+ int handle = theFxHelper.RegisterShader(value);
+ mMediaHandles.AddHandle(handle);
}
}
- if( !any )
- {
+ if (!any) {
// empty "list"
- theFxHelper.Print( "CPrimitiveTemplate::ParseShaders called with an empty list!\n" );
+ theFxHelper.Print("CPrimitiveTemplate::ParseShaders called with an empty list!\n");
return false;
}
return true;
@@ -1429,22 +1304,18 @@ bool CPrimitiveTemplate::ParseShaders( const CGPProperty& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSounds( const CGPProperty& grp )
-{
+bool CPrimitiveTemplate::ParseSounds(const CGPProperty &grp) {
bool any = false;
- for( auto& value : grp.GetValues() )
- {
- if( !value.empty() )
- {
+ for (auto &value : grp.GetValues()) {
+ if (!value.empty()) {
any = true;
- int handle = theFxHelper.RegisterSound( value );
- mMediaHandles.AddHandle( handle );
+ int handle = theFxHelper.RegisterSound(value);
+ mMediaHandles.AddHandle(handle);
}
}
- if( !any )
- {
+ if (!any) {
// empty "list"
- theFxHelper.Print( "CPrimitiveTemplate::ParseSounds called with an empty list!\n" );
+ theFxHelper.Print("CPrimitiveTemplate::ParseSounds called with an empty list!\n");
return false;
}
return true;
@@ -1460,52 +1331,42 @@ bool CPrimitiveTemplate::ParseSounds( const CGPProperty& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseModels( const CGPProperty& grp )
-{
+bool CPrimitiveTemplate::ParseModels(const CGPProperty &grp) {
bool any = false;
- for( auto& value : grp.GetValues() )
- {
- if( !value.empty() )
- {
+ for (auto &value : grp.GetValues()) {
+ if (!value.empty()) {
any = true;
- int handle = theFxHelper.RegisterModel( value );
- mMediaHandles.AddHandle( handle );
+ int handle = theFxHelper.RegisterModel(value);
+ mMediaHandles.AddHandle(handle);
}
}
- if( !any )
- {
+ if (!any) {
// empty "list"
- theFxHelper.Print( "CPrimitiveTemplate::ParseModels called with an empty list!\n" );
+ theFxHelper.Print("CPrimitiveTemplate::ParseModels called with an empty list!\n");
return false;
}
mFlags |= FX_ATTACHED_MODEL;
return true;
}
-static bool ParseFX( const CGPProperty& grp, CFxScheduler& scheduler, CMediaHandles& handles, SFxHelper& helper, int& flags, int successFlags, gsl::czstring loadError, gsl::czstring emptyError )
-{
+static bool ParseFX(const CGPProperty &grp, CFxScheduler &scheduler, CMediaHandles &handles, SFxHelper &helper, int &flags, int successFlags,
+ gsl::czstring loadError, gsl::czstring emptyError) {
bool any = false;
- for( auto& value : grp.GetValues() )
- {
- if( !value.empty() )
- {
+ for (auto &value : grp.GetValues()) {
+ if (!value.empty()) {
any = true;
// TODO: string_view parameter
- int handle = scheduler.RegisterEffect( std::string( value.begin(), value.end() ).c_str() );
- if( handle )
- {
- handles.AddHandle( handle );
+ int handle = scheduler.RegisterEffect(std::string(value.begin(), value.end()).c_str());
+ if (handle) {
+ handles.AddHandle(handle);
flags |= successFlags;
- }
- else
- {
- helper.Print( "%s", loadError );
+ } else {
+ helper.Print("%s", loadError);
}
}
}
- if( !any )
- {
- helper.Print( "%s", emptyError );
+ if (!any) {
+ helper.Print("%s", emptyError);
}
return any;
}
@@ -1520,15 +1381,9 @@ static bool ParseFX( const CGPProperty& grp, CFxScheduler& scheduler, CMediaHand
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseImpactFxStrings( const CGPProperty& grp )
-{
- return ParseFX(
- grp,
- theFxScheduler, mImpactFxHandles, theFxHelper,
- mFlags, FX_IMPACT_RUNS_FX | FX_APPLY_PHYSICS,
- "FxTemplate: Impact effect file not found.\n",
- "CPrimitiveTemplate::ParseImpactFxStrings called with an empty list!\n"
- );
+bool CPrimitiveTemplate::ParseImpactFxStrings(const CGPProperty &grp) {
+ return ParseFX(grp, theFxScheduler, mImpactFxHandles, theFxHelper, mFlags, FX_IMPACT_RUNS_FX | FX_APPLY_PHYSICS,
+ "FxTemplate: Impact effect file not found.\n", "CPrimitiveTemplate::ParseImpactFxStrings called with an empty list!\n");
}
//------------------------------------------------------
@@ -1541,15 +1396,9 @@ bool CPrimitiveTemplate::ParseImpactFxStrings( const CGPProperty& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseDeathFxStrings( const CGPProperty& grp )
-{
- return ParseFX(
- grp,
- theFxScheduler, mDeathFxHandles, theFxHelper,
- mFlags, FX_DEATH_RUNS_FX,
- "FxTemplate: Death effect file not found.\n",
- "CPrimitiveTemplate::ParseDeathFxStrings called with an empty list!\n"
- );
+bool CPrimitiveTemplate::ParseDeathFxStrings(const CGPProperty &grp) {
+ return ParseFX(grp, theFxScheduler, mDeathFxHandles, theFxHelper, mFlags, FX_DEATH_RUNS_FX, "FxTemplate: Death effect file not found.\n",
+ "CPrimitiveTemplate::ParseDeathFxStrings called with an empty list!\n");
}
//------------------------------------------------------
@@ -1562,15 +1411,9 @@ bool CPrimitiveTemplate::ParseDeathFxStrings( const CGPProperty& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseEmitterFxStrings( const CGPProperty& grp )
-{
- return ParseFX(
- grp,
- theFxScheduler, mEmitterFxHandles, theFxHelper,
- mFlags, FX_EMIT_FX,
- "FxTemplate: Emitter effect file not found.\n",
- "CPrimitiveTemplate::ParseEmitterFxStrings called with an empty list!\n"
- );
+bool CPrimitiveTemplate::ParseEmitterFxStrings(const CGPProperty &grp) {
+ return ParseFX(grp, theFxScheduler, mEmitterFxHandles, theFxHelper, mFlags, FX_EMIT_FX, "FxTemplate: Emitter effect file not found.\n",
+ "CPrimitiveTemplate::ParseEmitterFxStrings called with an empty list!\n");
}
//------------------------------------------------------
@@ -1583,30 +1426,19 @@ bool CPrimitiveTemplate::ParseEmitterFxStrings( const CGPProperty& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParsePlayFxStrings( const CGPProperty& grp )
-{
- return ParseFX(
- grp,
- theFxScheduler, mPlayFxHandles, theFxHelper,
- mFlags, 0,
- "FxTemplate: Effect file not found.\n",
- "CPrimitiveTemplate::ParsePlayFxStrings called with an empty list!\n"
- );
+bool CPrimitiveTemplate::ParsePlayFxStrings(const CGPProperty &grp) {
+ return ParseFX(grp, theFxScheduler, mPlayFxHandles, theFxHelper, mFlags, 0, "FxTemplate: Effect file not found.\n",
+ "CPrimitiveTemplate::ParsePlayFxStrings called with an empty list!\n");
}
-bool CPrimitiveTemplate::ParseGroup( const CGPGroup& grp, const StringViewIMap< ParseMethod >& parseMethods, gsl::czstring name )
-{
- for( auto& cur : grp.GetProperties() )
- {
- auto pos = parseMethods.find( cur.GetName() );
- if( pos == parseMethods.end() )
- {
- theFxHelper.Print( "Unknown key parsing %s group!", name );
- }
- else
- {
+bool CPrimitiveTemplate::ParseGroup(const CGPGroup &grp, const StringViewIMap &parseMethods, gsl::czstring name) {
+ for (auto &cur : grp.GetProperties()) {
+ auto pos = parseMethods.find(cur.GetName());
+ if (pos == parseMethods.end()) {
+ theFxHelper.Print("Unknown key parsing %s group!", name);
+ } else {
ParseMethod method = pos->second;
- ( this->*method )( cur.GetTopValue() );
+ (this->*method)(cur.GetTopValue());
}
}
return true;
@@ -1623,20 +1455,17 @@ bool CPrimitiveTemplate::ParseGroup( const CGPGroup& grp, const StringViewIMap<
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseRGB( const CGPGroup& grp )
-{
- static StringViewIMap< ParseMethod > parseMethods{
- { CSTRING_VIEW( "start" ), &CPrimitiveTemplate::ParseRGBStart },
+bool CPrimitiveTemplate::ParseRGB(const CGPGroup &grp) {
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("start"), &CPrimitiveTemplate::ParseRGBStart},
- { CSTRING_VIEW( "end" ), &CPrimitiveTemplate::ParseRGBEnd },
+ {CSTRING_VIEW("end"), &CPrimitiveTemplate::ParseRGBEnd},
- { CSTRING_VIEW( "parm" ), &CPrimitiveTemplate::ParseRGBParm },
- { CSTRING_VIEW( "parms" ), &CPrimitiveTemplate::ParseRGBParm },
+ {CSTRING_VIEW("parm"), &CPrimitiveTemplate::ParseRGBParm}, {CSTRING_VIEW("parms"), &CPrimitiveTemplate::ParseRGBParm},
- { CSTRING_VIEW( "flag" ), &CPrimitiveTemplate::ParseRGBFlags },
- { CSTRING_VIEW( "flags" ), &CPrimitiveTemplate::ParseRGBFlags },
+ {CSTRING_VIEW("flag"), &CPrimitiveTemplate::ParseRGBFlags}, {CSTRING_VIEW("flags"), &CPrimitiveTemplate::ParseRGBFlags},
};
- return ParseGroup( grp, parseMethods, "RGB" );
+ return ParseGroup(grp, parseMethods, "RGB");
}
//------------------------------------------------------
@@ -1650,20 +1479,17 @@ bool CPrimitiveTemplate::ParseRGB( const CGPGroup& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseAlpha( const CGPGroup& grp )
-{
- static StringViewIMap< ParseMethod > parseMethods{
- { CSTRING_VIEW( "start" ), &CPrimitiveTemplate::ParseAlphaStart },
+bool CPrimitiveTemplate::ParseAlpha(const CGPGroup &grp) {
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("start"), &CPrimitiveTemplate::ParseAlphaStart},
- { CSTRING_VIEW( "end" ), &CPrimitiveTemplate::ParseAlphaEnd },
+ {CSTRING_VIEW("end"), &CPrimitiveTemplate::ParseAlphaEnd},
- { CSTRING_VIEW( "parm" ), &CPrimitiveTemplate::ParseAlphaParm },
- { CSTRING_VIEW( "parms" ), &CPrimitiveTemplate::ParseAlphaParm },
+ {CSTRING_VIEW("parm"), &CPrimitiveTemplate::ParseAlphaParm}, {CSTRING_VIEW("parms"), &CPrimitiveTemplate::ParseAlphaParm},
- { CSTRING_VIEW( "flag" ), &CPrimitiveTemplate::ParseAlphaFlags },
- { CSTRING_VIEW( "flags" ), &CPrimitiveTemplate::ParseAlphaFlags },
+ {CSTRING_VIEW("flag"), &CPrimitiveTemplate::ParseAlphaFlags}, {CSTRING_VIEW("flags"), &CPrimitiveTemplate::ParseAlphaFlags},
};
- return ParseGroup( grp, parseMethods, "Alpha" );
+ return ParseGroup(grp, parseMethods, "Alpha");
}
//------------------------------------------------------
@@ -1677,20 +1503,17 @@ bool CPrimitiveTemplate::ParseAlpha( const CGPGroup& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSize( const CGPGroup& grp )
-{
- static StringViewIMap< ParseMethod > parseMethods{
- { CSTRING_VIEW( "start" ), &CPrimitiveTemplate::ParseSizeStart },
+bool CPrimitiveTemplate::ParseSize(const CGPGroup &grp) {
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("start"), &CPrimitiveTemplate::ParseSizeStart},
- { CSTRING_VIEW( "end" ), &CPrimitiveTemplate::ParseSizeEnd },
+ {CSTRING_VIEW("end"), &CPrimitiveTemplate::ParseSizeEnd},
- { CSTRING_VIEW( "parm" ), &CPrimitiveTemplate::ParseSizeParm },
- { CSTRING_VIEW( "parms" ), &CPrimitiveTemplate::ParseSizeParm },
+ {CSTRING_VIEW("parm"), &CPrimitiveTemplate::ParseSizeParm}, {CSTRING_VIEW("parms"), &CPrimitiveTemplate::ParseSizeParm},
- { CSTRING_VIEW( "flag" ), &CPrimitiveTemplate::ParseSizeFlags },
- { CSTRING_VIEW( "flags" ), &CPrimitiveTemplate::ParseSizeFlags },
+ {CSTRING_VIEW("flag"), &CPrimitiveTemplate::ParseSizeFlags}, {CSTRING_VIEW("flags"), &CPrimitiveTemplate::ParseSizeFlags},
};
- return ParseGroup( grp, parseMethods, "Size" );
+ return ParseGroup(grp, parseMethods, "Size");
}
//------------------------------------------------------
@@ -1704,20 +1527,17 @@ bool CPrimitiveTemplate::ParseSize( const CGPGroup& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseSize2( const CGPGroup& grp )
-{
- static StringViewIMap< ParseMethod > parseMethods{
- { CSTRING_VIEW( "start" ), &CPrimitiveTemplate::ParseSize2Start },
+bool CPrimitiveTemplate::ParseSize2(const CGPGroup &grp) {
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("start"), &CPrimitiveTemplate::ParseSize2Start},
- { CSTRING_VIEW( "end" ), &CPrimitiveTemplate::ParseSize2End },
+ {CSTRING_VIEW("end"), &CPrimitiveTemplate::ParseSize2End},
- { CSTRING_VIEW( "parm" ), &CPrimitiveTemplate::ParseSize2Parm },
- { CSTRING_VIEW( "parms" ), &CPrimitiveTemplate::ParseSize2Parm },
+ {CSTRING_VIEW("parm"), &CPrimitiveTemplate::ParseSize2Parm}, {CSTRING_VIEW("parms"), &CPrimitiveTemplate::ParseSize2Parm},
- { CSTRING_VIEW( "flag" ), &CPrimitiveTemplate::ParseSize2Flags },
- { CSTRING_VIEW( "flags" ), &CPrimitiveTemplate::ParseSize2Flags },
+ {CSTRING_VIEW("flag"), &CPrimitiveTemplate::ParseSize2Flags}, {CSTRING_VIEW("flags"), &CPrimitiveTemplate::ParseSize2Flags},
};
- return ParseGroup( grp, parseMethods, "Size2" );
+ return ParseGroup(grp, parseMethods, "Size2");
}
//------------------------------------------------------
@@ -1731,144 +1551,124 @@ bool CPrimitiveTemplate::ParseSize2( const CGPGroup& grp )
// return:
// success of parse operation.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParseLength( const CGPGroup& grp )
-{
- static StringViewIMap< ParseMethod > parseMethods{
- { CSTRING_VIEW( "start" ), &CPrimitiveTemplate::ParseLengthStart },
+bool CPrimitiveTemplate::ParseLength(const CGPGroup &grp) {
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("start"), &CPrimitiveTemplate::ParseLengthStart},
- { CSTRING_VIEW( "end" ), &CPrimitiveTemplate::ParseLengthEnd },
+ {CSTRING_VIEW("end"), &CPrimitiveTemplate::ParseLengthEnd},
- { CSTRING_VIEW( "parm" ), &CPrimitiveTemplate::ParseLengthParm },
- { CSTRING_VIEW( "parms" ), &CPrimitiveTemplate::ParseLengthParm },
+ {CSTRING_VIEW("parm"), &CPrimitiveTemplate::ParseLengthParm}, {CSTRING_VIEW("parms"), &CPrimitiveTemplate::ParseLengthParm},
- { CSTRING_VIEW( "flag" ), &CPrimitiveTemplate::ParseLengthFlags },
- { CSTRING_VIEW( "flags" ), &CPrimitiveTemplate::ParseLengthFlags },
+ {CSTRING_VIEW("flag"), &CPrimitiveTemplate::ParseLengthFlags}, {CSTRING_VIEW("flags"), &CPrimitiveTemplate::ParseLengthFlags},
};
- return ParseGroup( grp, parseMethods, "Length" );
+ return ParseGroup(grp, parseMethods, "Length");
}
-
// Parse a primitive, apply defaults first, grab any base level
// key pairs, then process any sub groups we may contain.
//------------------------------------------------------
-bool CPrimitiveTemplate::ParsePrimitive( const CGPGroup& grp )
-{
+bool CPrimitiveTemplate::ParsePrimitive(const CGPGroup &grp) {
// Property
- for( auto& prop : grp.GetProperties() )
- {
+ for (auto &prop : grp.GetProperties()) {
// Single Value Parsing
{
- static StringViewIMap< ParseMethod > parseMethods{
- { CSTRING_VIEW( "count" ), &CPrimitiveTemplate::ParseCount },
- { CSTRING_VIEW( "life" ), &CPrimitiveTemplate::ParseLife },
- { CSTRING_VIEW( "delay" ), &CPrimitiveTemplate::ParseDelay },
- { CSTRING_VIEW( "bounce" ), &CPrimitiveTemplate::ParseElasticity },
- { CSTRING_VIEW( "intensity" ), &CPrimitiveTemplate::ParseElasticity },
- { CSTRING_VIEW( "min" ), &CPrimitiveTemplate::ParseMin },
- { CSTRING_VIEW( "max" ), &CPrimitiveTemplate::ParseMax },
- { CSTRING_VIEW( "angle" ), &CPrimitiveTemplate::ParseAngle },
- { CSTRING_VIEW( "angles" ), &CPrimitiveTemplate::ParseAngle },
- { CSTRING_VIEW( "angleDelta" ), &CPrimitiveTemplate::ParseAngleDelta },
- { CSTRING_VIEW( "velocity" ), &CPrimitiveTemplate::ParseVelocity },
- { CSTRING_VIEW( "vel" ), &CPrimitiveTemplate::ParseVelocity },
- { CSTRING_VIEW( "acceleration" ), &CPrimitiveTemplate::ParseAcceleration },
- { CSTRING_VIEW( "accel" ), &CPrimitiveTemplate::ParseAcceleration },
- { CSTRING_VIEW( "gravity" ), &CPrimitiveTemplate::ParseGravity },
- { CSTRING_VIEW( "density" ), &CPrimitiveTemplate::ParseDensity },
- { CSTRING_VIEW( "variance" ), &CPrimitiveTemplate::ParseVariance },
- { CSTRING_VIEW( "origin" ), &CPrimitiveTemplate::ParseOrigin1 },
- { CSTRING_VIEW( "origin2" ), &CPrimitiveTemplate::ParseOrigin2 },
- { CSTRING_VIEW( "radius" ), &CPrimitiveTemplate::ParseRadius },
- { CSTRING_VIEW( "height" ), &CPrimitiveTemplate::ParseHeight },
- { CSTRING_VIEW( "wind" ), &CPrimitiveTemplate::ParseWindModifier },
- { CSTRING_VIEW( "rotation" ), &CPrimitiveTemplate::ParseRotation },
- { CSTRING_VIEW( "rotationDelta" ), &CPrimitiveTemplate::ParseRotationDelta },
- { CSTRING_VIEW( "flags" ), &CPrimitiveTemplate::ParseFlags },
- { CSTRING_VIEW( "flag" ), &CPrimitiveTemplate::ParseFlags },
- { CSTRING_VIEW( "spawnFlags" ), &CPrimitiveTemplate::ParseSpawnFlags },
- { CSTRING_VIEW( "spawnFlag" ), &CPrimitiveTemplate::ParseSpawnFlags },
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("count"), &CPrimitiveTemplate::ParseCount},
+ {CSTRING_VIEW("life"), &CPrimitiveTemplate::ParseLife},
+ {CSTRING_VIEW("delay"), &CPrimitiveTemplate::ParseDelay},
+ {CSTRING_VIEW("bounce"), &CPrimitiveTemplate::ParseElasticity},
+ {CSTRING_VIEW("intensity"), &CPrimitiveTemplate::ParseElasticity},
+ {CSTRING_VIEW("min"), &CPrimitiveTemplate::ParseMin},
+ {CSTRING_VIEW("max"), &CPrimitiveTemplate::ParseMax},
+ {CSTRING_VIEW("angle"), &CPrimitiveTemplate::ParseAngle},
+ {CSTRING_VIEW("angles"), &CPrimitiveTemplate::ParseAngle},
+ {CSTRING_VIEW("angleDelta"), &CPrimitiveTemplate::ParseAngleDelta},
+ {CSTRING_VIEW("velocity"), &CPrimitiveTemplate::ParseVelocity},
+ {CSTRING_VIEW("vel"), &CPrimitiveTemplate::ParseVelocity},
+ {CSTRING_VIEW("acceleration"), &CPrimitiveTemplate::ParseAcceleration},
+ {CSTRING_VIEW("accel"), &CPrimitiveTemplate::ParseAcceleration},
+ {CSTRING_VIEW("gravity"), &CPrimitiveTemplate::ParseGravity},
+ {CSTRING_VIEW("density"), &CPrimitiveTemplate::ParseDensity},
+ {CSTRING_VIEW("variance"), &CPrimitiveTemplate::ParseVariance},
+ {CSTRING_VIEW("origin"), &CPrimitiveTemplate::ParseOrigin1},
+ {CSTRING_VIEW("origin2"), &CPrimitiveTemplate::ParseOrigin2},
+ {CSTRING_VIEW("radius"), &CPrimitiveTemplate::ParseRadius},
+ {CSTRING_VIEW("height"), &CPrimitiveTemplate::ParseHeight},
+ {CSTRING_VIEW("wind"), &CPrimitiveTemplate::ParseWindModifier},
+ {CSTRING_VIEW("rotation"), &CPrimitiveTemplate::ParseRotation},
+ {CSTRING_VIEW("rotationDelta"), &CPrimitiveTemplate::ParseRotationDelta},
+ {CSTRING_VIEW("flags"), &CPrimitiveTemplate::ParseFlags},
+ {CSTRING_VIEW("flag"), &CPrimitiveTemplate::ParseFlags},
+ {CSTRING_VIEW("spawnFlags"), &CPrimitiveTemplate::ParseSpawnFlags},
+ {CSTRING_VIEW("spawnFlag"), &CPrimitiveTemplate::ParseSpawnFlags},
};
- auto pos = parseMethods.find( prop.GetName() );
- if( pos != parseMethods.end() )
- {
+ auto pos = parseMethods.find(prop.GetName());
+ if (pos != parseMethods.end()) {
ParseMethod method = pos->second;
- ( this->*method )( prop.GetTopValue() );
+ (this->*method)(prop.GetTopValue());
continue;
}
}
// Property Parsing
{
- using PropertyParseMethod = bool( CPrimitiveTemplate::* )( const CGPProperty& );
- static StringViewIMap< PropertyParseMethod > parseMethods{
- { CSTRING_VIEW( "shaders" ), &CPrimitiveTemplate::ParseShaders },
- { CSTRING_VIEW( "shader" ), &CPrimitiveTemplate::ParseShaders },
- { CSTRING_VIEW( "models" ), &CPrimitiveTemplate::ParseModels },
- { CSTRING_VIEW( "model" ), &CPrimitiveTemplate::ParseModels },
- { CSTRING_VIEW( "sounds" ), &CPrimitiveTemplate::ParseSounds },
- { CSTRING_VIEW( "sound" ), &CPrimitiveTemplate::ParseSounds },
- { CSTRING_VIEW( "impactfx" ), &CPrimitiveTemplate::ParseImpactFxStrings },
- { CSTRING_VIEW( "deathfx" ), &CPrimitiveTemplate::ParseDeathFxStrings },
- { CSTRING_VIEW( "emitfx" ), &CPrimitiveTemplate::ParseEmitterFxStrings },
- { CSTRING_VIEW( "playfx" ), &CPrimitiveTemplate::ParsePlayFxStrings },
+ using PropertyParseMethod = bool (CPrimitiveTemplate::*)(const CGPProperty &);
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("shaders"), &CPrimitiveTemplate::ParseShaders},
+ {CSTRING_VIEW("shader"), &CPrimitiveTemplate::ParseShaders},
+ {CSTRING_VIEW("models"), &CPrimitiveTemplate::ParseModels},
+ {CSTRING_VIEW("model"), &CPrimitiveTemplate::ParseModels},
+ {CSTRING_VIEW("sounds"), &CPrimitiveTemplate::ParseSounds},
+ {CSTRING_VIEW("sound"), &CPrimitiveTemplate::ParseSounds},
+ {CSTRING_VIEW("impactfx"), &CPrimitiveTemplate::ParseImpactFxStrings},
+ {CSTRING_VIEW("deathfx"), &CPrimitiveTemplate::ParseDeathFxStrings},
+ {CSTRING_VIEW("emitfx"), &CPrimitiveTemplate::ParseEmitterFxStrings},
+ {CSTRING_VIEW("playfx"), &CPrimitiveTemplate::ParsePlayFxStrings},
};
- auto pos = parseMethods.find( prop.GetName() );
- if( pos != parseMethods.end() )
- {
+ auto pos = parseMethods.find(prop.GetName());
+ if (pos != parseMethods.end()) {
PropertyParseMethod method = pos->second;
- ( this->*method )( prop );
+ (this->*method)(prop);
continue;
}
}
// Special Cases
- if( Q::stricmp( prop.GetName(), CSTRING_VIEW( "cullrange" ) ) == Q::Ordering::EQ )
- {
- mCullRange = Q::svtoi( prop.GetTopValue() );
+ if (Q::stricmp(prop.GetName(), CSTRING_VIEW("cullrange")) == Q::Ordering::EQ) {
+ mCullRange = Q::svtoi(prop.GetTopValue());
mCullRange *= mCullRange; // Square
- }
- else if( Q::stricmp( prop.GetName(), CSTRING_VIEW( "name" ) ) == Q::Ordering::EQ )
- {
- if( !prop.GetTopValue().empty() )
- {
+ } else if (Q::stricmp(prop.GetName(), CSTRING_VIEW("name")) == Q::Ordering::EQ) {
+ if (!prop.GetTopValue().empty()) {
// just stash the descriptive name of the primitive
- std::size_t len = std::min< std::size_t >( prop.GetTopValue().size(), FX_MAX_PRIM_NAME - 1 );
+ std::size_t len = std::min(prop.GetTopValue().size(), FX_MAX_PRIM_NAME - 1);
auto begin = prop.GetTopValue().begin();
- std::copy( begin, begin + len, &mName[ 0 ] );
- mName[ len ] = '\0';
+ std::copy(begin, begin + len, &mName[0]);
+ mName[len] = '\0';
}
}
// Error
- else
- {
- theFxHelper.Print( "Unknown key parsing an effect primitive!\n" );
+ else {
+ theFxHelper.Print("Unknown key parsing an effect primitive!\n");
}
}
- for( auto& subGrp : grp.GetSubGroups() )
- {
- using GroupParseMethod = bool ( CPrimitiveTemplate::* )( const CGPGroup& );
- static StringViewIMap< GroupParseMethod > parseMethods{
- { CSTRING_VIEW( "rgb" ), &CPrimitiveTemplate::ParseRGB },
+ for (auto &subGrp : grp.GetSubGroups()) {
+ using GroupParseMethod = bool (CPrimitiveTemplate::*)(const CGPGroup &);
+ static StringViewIMap parseMethods{
+ {CSTRING_VIEW("rgb"), &CPrimitiveTemplate::ParseRGB},
- { CSTRING_VIEW( "alpha" ), &CPrimitiveTemplate::ParseAlpha },
+ {CSTRING_VIEW("alpha"), &CPrimitiveTemplate::ParseAlpha},
- { CSTRING_VIEW( "size" ), &CPrimitiveTemplate::ParseSize },
- { CSTRING_VIEW( "width" ), &CPrimitiveTemplate::ParseSize },
+ {CSTRING_VIEW("size"), &CPrimitiveTemplate::ParseSize}, {CSTRING_VIEW("width"), &CPrimitiveTemplate::ParseSize},
- { CSTRING_VIEW( "size2" ), &CPrimitiveTemplate::ParseSize2 },
- { CSTRING_VIEW( "width2" ), &CPrimitiveTemplate::ParseSize2 },
+ {CSTRING_VIEW("size2"), &CPrimitiveTemplate::ParseSize2}, {CSTRING_VIEW("width2"), &CPrimitiveTemplate::ParseSize2},
- { CSTRING_VIEW( "length" ), &CPrimitiveTemplate::ParseLength },
- { CSTRING_VIEW( "height" ), &CPrimitiveTemplate::ParseLength },
+ {CSTRING_VIEW("length"), &CPrimitiveTemplate::ParseLength}, {CSTRING_VIEW("height"), &CPrimitiveTemplate::ParseLength},
};
- auto pos = parseMethods.find( subGrp.GetName() );
- if( pos == parseMethods.end() )
- {
- theFxHelper.Print( "Unknown group key parsing a particle!\n" );
- }
- else
- {
+ auto pos = parseMethods.find(subGrp.GetName());
+ if (pos == parseMethods.end()) {
+ theFxHelper.Print("Unknown group key parsing a particle!\n");
+ } else {
GroupParseMethod method = pos->second;
- ( this->*method )( subGrp );
+ (this->*method)(subGrp);
}
}
return true;
diff --git a/code/cgame/FxUtil.cpp b/code/cgame/FxUtil.cpp
index 499dad065c..7f13582ebb 100644
--- a/code/cgame/FxUtil.cpp
+++ b/code/cgame/FxUtil.cpp
@@ -23,45 +23,41 @@ along with this program; if not, see .
#include "common_headers.h"
#if !defined(FX_SCHEDULER_H_INC)
- #include "FxScheduler.h"
+#include "FxScheduler.h"
#endif
-vec3_t WHITE = {1.0f, 1.0f, 1.0f};
+vec3_t WHITE = {1.0f, 1.0f, 1.0f};
-struct SEffectList
-{
+struct SEffectList {
CEffect *mEffect;
- int mKillTime;
- bool mPortal;
+ int mKillTime;
+ bool mPortal;
};
-#define PI 3.14159f
+#define PI 3.14159f
-SEffectList effectList[MAX_EFFECTS];
-SEffectList *nextValidEffect;
-SFxHelper theFxHelper;
+SEffectList effectList[MAX_EFFECTS];
+SEffectList *nextValidEffect;
+SFxHelper theFxHelper;
-int activeFx = 0;
-int mMax = 0;
-int mMaxTime = 0;
-int drawnFx;
-int mParticles;
-int mOParticles;
-int mLines;
-int mTails;
-qboolean fxInitialized = qfalse;
+int activeFx = 0;
+int mMax = 0;
+int mMaxTime = 0;
+int drawnFx;
+int mParticles;
+int mOParticles;
+int mLines;
+int mTails;
+qboolean fxInitialized = qfalse;
//-------------------------
// FX_Free
//
// Frees all FX
//-------------------------
-bool FX_Free( void )
-{
- for ( int i = 0; i < MAX_EFFECTS; i++ )
- {
- if ( effectList[i].mEffect )
- {
+bool FX_Free(void) {
+ for (int i = 0; i < MAX_EFFECTS; i++) {
+ if (effectList[i].mEffect) {
delete effectList[i].mEffect;
}
@@ -79,12 +75,9 @@ bool FX_Free( void )
//
// Frees all active FX but leaves the templates
//-------------------------
-void FX_Stop( void )
-{
- for ( int i = 0; i < MAX_EFFECTS; i++ )
- {
- if ( effectList[i].mEffect )
- {
+void FX_Stop(void) {
+ for (int i = 0; i < MAX_EFFECTS; i++) {
+ if (effectList[i].mEffect) {
delete effectList[i].mEffect;
}
@@ -101,14 +94,11 @@ void FX_Stop( void )
//
// Preps system for use
//-------------------------
-int FX_Init( void )
-{
- if ( fxInitialized == qfalse )
- {
+int FX_Init(void) {
+ if (fxInitialized == qfalse) {
fxInitialized = qtrue;
- for ( int i = 0; i < MAX_EFFECTS; i++ )
- {
+ for (int i = 0; i < MAX_EFFECTS; i++) {
effectList[i].mEffect = 0;
}
}
@@ -129,12 +119,10 @@ int FX_Init( void )
return true;
}
-
//-------------------------
// FX_FreeMember
//-------------------------
-static void FX_FreeMember( SEffectList *obj )
-{
+static void FX_FreeMember(SEffectList *obj) {
obj->mEffect->Die();
delete obj->mEffect;
obj->mEffect = 0;
@@ -145,7 +133,6 @@ static void FX_FreeMember( SEffectList *obj )
activeFx--;
}
-
//-------------------------
// FX_GetValidEffect
//
@@ -154,58 +141,48 @@ static void FX_FreeMember( SEffectList *obj )
// Note - in the editor, this function may return NULL, indicating that all
// effects are being stopped.
//-------------------------
-static SEffectList *FX_GetValidEffect()
-{
- if ( nextValidEffect->mEffect == 0 )
- {
+static SEffectList *FX_GetValidEffect() {
+ if (nextValidEffect->mEffect == 0) {
return nextValidEffect;
}
- int i;
- SEffectList *ef;
+ int i;
+ SEffectList *ef;
// Blah..plow through the list till we find something that is currently untainted
- for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ )
- {
- if ( ef->mEffect == 0 )
- {
+ for (i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++) {
+ if (ef->mEffect == 0) {
return ef;
}
}
// report the error.
#ifndef FINAL_BUILD
- theFxHelper.Print( "FX system out of effects\n" );
+ theFxHelper.Print("FX system out of effects\n");
#endif
// Hmmm.. just trashing the first effect in the list is a poor approach
- FX_FreeMember( &effectList[0] );
+ FX_FreeMember(&effectList[0]);
// Recursive call
return nextValidEffect;
}
-
//-------------------------
// FX_ActiveFx
//
// Returns whether these are any active or scheduled effects
//-------------------------
-bool FX_ActiveFx(void)
-{
- return ((activeFx > 0) || (theFxScheduler.NumScheduledFx() > 0));
-}
-
+bool FX_ActiveFx(void) { return ((activeFx > 0) || (theFxScheduler.NumScheduledFx() > 0)); }
//-------------------------
// FX_Add
//
// Adds all fx to the view
//-------------------------
-void FX_Add( bool portal )
-{
- int i;
- SEffectList *ef;
+void FX_Add(bool portal) {
+ int i;
+ SEffectList *ef;
drawnFx = 0;
mParticles = 0;
@@ -213,362 +190,271 @@ void FX_Add( bool portal )
mLines = 0;
mTails = 0;
- int numFx = activeFx; //but stop when there can't be any more left!
- for ( i = 0, ef = effectList; i < MAX_EFFECTS && numFx; i++, ef++ )
- {
- if ( ef->mEffect != 0)
- {
+ int numFx = activeFx; // but stop when there can't be any more left!
+ for (i = 0, ef = effectList; i < MAX_EFFECTS && numFx; i++, ef++) {
+ if (ef->mEffect != 0) {
--numFx;
- if (portal != ef->mPortal)
- {
- continue; //this one does not render in this scene
+ if (portal != ef->mPortal) {
+ continue; // this one does not render in this scene
}
// Effect is active
- if ( theFxHelper.mTime > ef->mKillTime )
- {
+ if (theFxHelper.mTime > ef->mKillTime) {
// Clean up old effects, calling any death effects as needed
// this flag just has to be cleared otherwise death effects might not happen correctly
- ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT );
- FX_FreeMember( ef );
- }
- else
- {
- if ( ef->mEffect->Update() == false )
- {
+ ef->mEffect->ClearFlags(FX_KILL_ON_IMPACT);
+ FX_FreeMember(ef);
+ } else {
+ if (ef->mEffect->Update() == false) {
// We've been marked for death
- FX_FreeMember( ef );
+ FX_FreeMember(ef);
continue;
}
}
}
}
- if ( fx_debug.integer == 2 && !portal )
- {
+ if (fx_debug.integer == 2 && !portal) {
if (theFxHelper.mFrameTime > 100 || theFxHelper.mFrameTime < 5)
- theFxHelper.Print( "theFxHelper.mFrameTime = %i\n", theFxHelper.mFrameTime );
+ theFxHelper.Print("theFxHelper.mFrameTime = %i\n", theFxHelper.mFrameTime);
}
- if ( fx_debug.integer == 1 && !portal )
- {
- if ( theFxHelper.mTime > mMaxTime )
- {
+ if (fx_debug.integer == 1 && !portal) {
+ if (theFxHelper.mTime > mMaxTime) {
// decay pretty harshly when we do it
mMax *= 0.9f;
mMaxTime = theFxHelper.mTime + 200; // decay 5 times a second if we haven't set a new max
}
- if ( activeFx > mMax )
- {
+ if (activeFx > mMax) {
// but we can never be less that the current activeFx count
mMax = activeFx;
mMaxTime = theFxHelper.mTime + 4000; // since we just increased the max, hold it for at least 4 seconds
}
// Particles
- if ( mParticles > 500 )
- {
- theFxHelper.Print( ">Particles ^1%4i ", mParticles );
- }
- else if ( mParticles > 250 )
- {
- theFxHelper.Print( ">Particles ^3%4i ", mParticles );
- }
- else
- {
- theFxHelper.Print( ">Particles %4i ", mParticles );
+ if (mParticles > 500) {
+ theFxHelper.Print(">Particles ^1%4i ", mParticles);
+ } else if (mParticles > 250) {
+ theFxHelper.Print(">Particles ^3%4i ", mParticles);
+ } else {
+ theFxHelper.Print(">Particles %4i ", mParticles);
}
// Lines
- if ( mLines > 500 )
- {
- theFxHelper.Print( ">Lines ^1%4i\n", mLines );
- }
- else if ( mLines > 250 )
- {
- theFxHelper.Print( ">Lines ^3%4i\n", mLines );
- }
- else
- {
- theFxHelper.Print( ">Lines %4i\n", mLines );
+ if (mLines > 500) {
+ theFxHelper.Print(">Lines ^1%4i\n", mLines);
+ } else if (mLines > 250) {
+ theFxHelper.Print(">Lines ^3%4i\n", mLines);
+ } else {
+ theFxHelper.Print(">Lines %4i\n", mLines);
}
// OParticles
- if ( mOParticles > 500 )
- {
- theFxHelper.Print( ">OParticles ^1%4i ", mOParticles );
- }
- else if ( mOParticles > 250 )
- {
- theFxHelper.Print( ">OParticles ^3%4i ", mOParticles );
- }
- else
- {
- theFxHelper.Print( ">OParticles %4i ", mOParticles );
+ if (mOParticles > 500) {
+ theFxHelper.Print(">OParticles ^1%4i ", mOParticles);
+ } else if (mOParticles > 250) {
+ theFxHelper.Print(">OParticles ^3%4i ", mOParticles);
+ } else {
+ theFxHelper.Print(">OParticles %4i ", mOParticles);
}
// Tails
- if ( mTails > 400 )
- {
- theFxHelper.Print( ">Tails ^1%4i\n", mTails );
- }
- else if ( mTails > 200 )
- {
- theFxHelper.Print( ">Tails ^3%4i\n", mTails );
- }
- else
- {
- theFxHelper.Print( ">Tails %4i\n", mTails );
+ if (mTails > 400) {
+ theFxHelper.Print(">Tails ^1%4i\n", mTails);
+ } else if (mTails > 200) {
+ theFxHelper.Print(">Tails ^3%4i\n", mTails);
+ } else {
+ theFxHelper.Print(">Tails %4i\n", mTails);
}
// Active
- if ( activeFx > 600 )
- {
- theFxHelper.Print( ">Active ^1%4i ", activeFx );
- }
- else if ( activeFx > 400 )
- {
- theFxHelper.Print( ">Active ^3%4i ", activeFx );
- }
- else
- {
- theFxHelper.Print( ">Active %4i ", activeFx );
+ if (activeFx > 600) {
+ theFxHelper.Print(">Active ^1%4i ", activeFx);
+ } else if (activeFx > 400) {
+ theFxHelper.Print(">Active ^3%4i ", activeFx);
+ } else {
+ theFxHelper.Print(">Active %4i ", activeFx);
}
// Drawn
- if ( drawnFx > 600 )
- {
- theFxHelper.Print( ">Drawn ^1%4i ", drawnFx );
- }
- else if ( drawnFx > 400 )
- {
- theFxHelper.Print( ">Drawn ^3%4i ", drawnFx );
- }
- else
- {
- theFxHelper.Print( ">Drawn %4i ", drawnFx );
+ if (drawnFx > 600) {
+ theFxHelper.Print(">Drawn ^1%4i ", drawnFx);
+ } else if (drawnFx > 400) {
+ theFxHelper.Print(">Drawn ^3%4i ", drawnFx);
+ } else {
+ theFxHelper.Print(">Drawn %4i ", drawnFx);
}
// Max
- if ( mMax > 600 )
- {
- theFxHelper.Print( ">Max ^1%4i ", mMax );
- }
- else if ( mMax > 400 )
- {
- theFxHelper.Print( ">Max ^3%4i ", mMax );
- }
- else
- {
- theFxHelper.Print( ">Max %4i ", mMax );
+ if (mMax > 600) {
+ theFxHelper.Print(">Max ^1%4i ", mMax);
+ } else if (mMax > 400) {
+ theFxHelper.Print(">Max ^3%4i ", mMax);
+ } else {
+ theFxHelper.Print(">Max %4i ", mMax);
}
// Scheduled
- if ( theFxScheduler.NumScheduledFx() > 100 )
- {
- theFxHelper.Print( ">Scheduled ^1%4i\n", theFxScheduler.NumScheduledFx() );
- }
- else if ( theFxScheduler.NumScheduledFx() > 50 )
- {
- theFxHelper.Print( ">Scheduled ^3%4i\n", theFxScheduler.NumScheduledFx() );
- }
- else
- {
- theFxHelper.Print( ">Scheduled %4i\n", theFxScheduler.NumScheduledFx() );
+ if (theFxScheduler.NumScheduledFx() > 100) {
+ theFxHelper.Print(">Scheduled ^1%4i\n", theFxScheduler.NumScheduledFx());
+ } else if (theFxScheduler.NumScheduledFx() > 50) {
+ theFxHelper.Print(">Scheduled ^3%4i\n", theFxScheduler.NumScheduledFx());
+ } else {
+ theFxHelper.Print(">Scheduled %4i\n", theFxScheduler.NumScheduledFx());
}
}
}
-
//-------------------------
// FX_AddPrimitive
//
// Note - in the editor, this function may change *pEffect to NULL, indicating that
// all effects are being stopped.
//-------------------------
-extern bool gEffectsInPortal; //from FXScheduler.cpp so i don't have to pass it in on EVERY FX_ADD*
-void FX_AddPrimitive( CEffect **pEffect, int killTime )
-{
+extern bool gEffectsInPortal; // from FXScheduler.cpp so i don't have to pass it in on EVERY FX_ADD*
+void FX_AddPrimitive(CEffect **pEffect, int killTime) {
SEffectList *item = FX_GetValidEffect();
item->mEffect = *pEffect;
item->mKillTime = theFxHelper.mTime + killTime;
- item->mPortal = gEffectsInPortal; //global set in AddScheduledEffects
+ item->mPortal = gEffectsInPortal; // global set in AddScheduledEffects
activeFx++;
// Stash these in the primitive so it has easy access to the vals
- (*pEffect)->SetTimeStart( theFxHelper.mTime );
- (*pEffect)->SetTimeEnd( theFxHelper.mTime + killTime );
+ (*pEffect)->SetTimeStart(theFxHelper.mTime);
+ (*pEffect)->SetTimeEnd(theFxHelper.mTime + killTime);
}
-
//-------------------------
// FX_AddParticle
//-------------------------
-CParticle *FX_AddParticle( int clientID, const vec3_t org, const vec3_t vel, const vec3_t accel, float gravity,
- float size1, float size2, float sizeParm,
- float alpha1, float alpha2, float alphaParm,
- const vec3_t sRGB, const vec3_t eRGB, float rgbParm,
- float rotation, float rotationDelta,
- const vec3_t min, const vec3_t max, float elasticity,
- int deathID, int impactID,
- int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding effects when the system is paused
+CParticle *FX_AddParticle(int clientID, const vec3_t org, const vec3_t vel, const vec3_t accel, float gravity, float size1, float size2, float sizeParm,
+ float alpha1, float alpha2, float alphaParm, const vec3_t sRGB, const vec3_t eRGB, float rgbParm, float rotation, float rotationDelta,
+ const vec3_t min, const vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags,
+ int modelNum, int boltNum) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding effects when the system is paused
return 0;
}
CParticle *fx = new CParticle;
- if ( fx )
- {
- if (flags&FX_RELATIVE && clientID>=0)
- {
- fx->SetOrigin1( NULL );
- fx->SetOrgOffset( org );
- fx->SetClient( clientID, modelNum, boltNum );
- }
- else
- {
- fx->SetOrigin1( org );
+ if (fx) {
+ if (flags & FX_RELATIVE && clientID >= 0) {
+ fx->SetOrigin1(NULL);
+ fx->SetOrgOffset(org);
+ fx->SetClient(clientID, modelNum, boltNum);
+ } else {
+ fx->SetOrigin1(org);
}
- fx->SetVel( vel );
- fx->SetAccel( accel );
- fx->SetGravity( gravity );
+ fx->SetVel(vel);
+ fx->SetAccel(accel);
+ fx->SetGravity(gravity);
// RGB----------------
- fx->SetRGBStart( sRGB );
- fx->SetRGBEnd( eRGB );
+ fx->SetRGBStart(sRGB);
+ fx->SetRGBEnd(eRGB);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
-
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
- }
-
- fx->SetFlags( flags );
- fx->SetShader( shader );
- fx->SetRotation( rotation );
- fx->SetRotationDelta( rotationDelta );
- fx->SetElasticity( elasticity );
- fx->SetMin( min );
- fx->SetMax( max );
- fx->SetDeathFxID( deathID );
- fx->SetImpactFxID( impactID );
-
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
+
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
+ }
+
+ fx->SetFlags(flags);
+ fx->SetShader(shader);
+ fx->SetRotation(rotation);
+ fx->SetRotationDelta(rotationDelta);
+ fx->SetElasticity(elasticity);
+ fx->SetMin(min);
+ fx->SetMax(max);
+ fx->SetDeathFxID(deathID);
+ fx->SetImpactFxID(impactID);
+
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
return fx;
}
-
//-------------------------
// FX_AddLine
//-------------------------
-CLine *FX_AddLine( int clientID, vec3_t start, vec3_t end, float size1, float size2, float sizeParm,
- float alpha1, float alpha2, float alphaParm,
- vec3_t sRGB, vec3_t eRGB, float rgbParm,
- int killTime, qhandle_t shader, int impactFX_id, int flags, int modelNum, int boltNum )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding new effects when the system is paused
+CLine *FX_AddLine(int clientID, vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB,
+ vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int impactFX_id, int flags, int modelNum, int boltNum) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding new effects when the system is paused
return 0;
}
CLine *fx = new CLine;
- if ( fx )
- {
- if (flags&FX_RELATIVE && clientID>=0)
- {
- fx->SetOrigin1( NULL );
- fx->SetOrgOffset( start ); //offset from bolt pos
- fx->SetVel( end ); //vel is the vector offset from bolt+orgOffset
- fx->SetClient( clientID, modelNum, boltNum );
- }
- else
- {
- fx->SetOrigin1( start );
- fx->SetOrigin2( end );
+ if (fx) {
+ if (flags & FX_RELATIVE && clientID >= 0) {
+ fx->SetOrigin1(NULL);
+ fx->SetOrgOffset(start); // offset from bolt pos
+ fx->SetVel(end); // vel is the vector offset from bolt+orgOffset
+ fx->SetClient(clientID, modelNum, boltNum);
+ } else {
+ fx->SetOrigin1(start);
+ fx->SetOrigin2(end);
}
// RGB----------------
- fx->SetRGBStart( sRGB );
- fx->SetRGBEnd( eRGB );
+ fx->SetRGBStart(sRGB);
+ fx->SetRGBEnd(eRGB);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetShader( shader );
- fx->SetFlags( flags );
+ fx->SetShader(shader);
+ fx->SetFlags(flags);
- fx->SetSTScale( 1.0f, 1.0f );
- fx->SetImpactFxID( impactFX_id );
+ fx->SetSTScale(1.0f, 1.0f);
+ fx->SetImpactFxID(impactFX_id);
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
@@ -578,83 +464,65 @@ CLine *FX_AddLine( int clientID, vec3_t start, vec3_t end, float size1, float si
//-------------------------
// FX_AddElectricity
//-------------------------
-CElectricity *FX_AddElectricity( int clientID, vec3_t start, vec3_t end, float size1, float size2, float sizeParm,
- float alpha1, float alpha2, float alphaParm,
- vec3_t sRGB, vec3_t eRGB, float rgbParm,
- float chaos, int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding new effects when the system is paused
+CElectricity *FX_AddElectricity(int clientID, vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm,
+ vec3_t sRGB, vec3_t eRGB, float rgbParm, float chaos, int killTime, qhandle_t shader, int flags, int modelNum, int boltNum) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding new effects when the system is paused
return 0;
}
CElectricity *fx = new CElectricity;
- if ( fx )
- {
- if (flags&FX_RELATIVE && clientID>=0)
- {
- fx->SetOrigin1( NULL );
- fx->SetOrgOffset( start );//offset
- fx->SetVel( end ); //vel is the vector offset from bolt+orgOffset
- fx->SetClient( clientID, modelNum, boltNum );
- }
- else
- {
- fx->SetOrigin1( start );
- fx->SetOrigin2( end );
+ if (fx) {
+ if (flags & FX_RELATIVE && clientID >= 0) {
+ fx->SetOrigin1(NULL);
+ fx->SetOrgOffset(start); // offset
+ fx->SetVel(end); // vel is the vector offset from bolt+orgOffset
+ fx->SetClient(clientID, modelNum, boltNum);
+ } else {
+ fx->SetOrigin1(start);
+ fx->SetOrigin2(end);
}
// RGB----------------
- fx->SetRGBStart( sRGB );
- fx->SetRGBEnd( eRGB );
+ fx->SetRGBStart(sRGB);
+ fx->SetRGBEnd(eRGB);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetShader( shader );
- fx->SetFlags( flags );
- fx->SetChaos( chaos );
+ fx->SetShader(shader);
+ fx->SetFlags(flags);
+ fx->SetChaos(chaos);
- fx->SetSTScale( 1.0f, 1.0f );
+ fx->SetSTScale(1.0f, 1.0f);
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL?
- if ( fx )
- {
+ if (fx) {
fx->Initialize();
}
}
@@ -662,103 +530,79 @@ CElectricity *FX_AddElectricity( int clientID, vec3_t start, vec3_t end, float s
return fx;
}
-
//-------------------------
// FX_AddTail
//-------------------------
-CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel,
- float size1, float size2, float sizeParm,
- float length1, float length2, float lengthParm,
- float alpha1, float alpha2, float alphaParm,
- vec3_t sRGB, vec3_t eRGB, float rgbParm,
- vec3_t min, vec3_t max, float elasticity,
- int deathID, int impactID,
- int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding effects when the system is paused
+CTail *FX_AddTail(int clientID, vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float length1, float length2, float lengthParm,
+ float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, vec3_t min, vec3_t max, float elasticity, int deathID,
+ int impactID, int killTime, qhandle_t shader, int flags, int modelNum, int boltNum) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding effects when the system is paused
return 0;
}
CTail *fx = new CTail;
- if ( fx )
- {
- if (flags&FX_RELATIVE && clientID>=0)
- {
- fx->SetOrigin1( NULL );
- fx->SetOrgOffset( org );
- fx->SetClient( clientID, modelNum, boltNum );
- }
- else
- {
- fx->SetOrigin1( org );
+ if (fx) {
+ if (flags & FX_RELATIVE && clientID >= 0) {
+ fx->SetOrigin1(NULL);
+ fx->SetOrgOffset(org);
+ fx->SetClient(clientID, modelNum, boltNum);
+ } else {
+ fx->SetOrigin1(org);
}
- fx->SetVel( vel );
- fx->SetAccel( accel );
+ fx->SetVel(vel);
+ fx->SetAccel(accel);
// RGB----------------
- fx->SetRGBStart( sRGB );
- fx->SetRGBEnd( eRGB );
+ fx->SetRGBStart(sRGB);
+ fx->SetRGBEnd(eRGB);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
// Length----------------
- fx->SetLengthStart( length1 );
- fx->SetLengthEnd( length2 );
+ fx->SetLengthStart(length1);
+ fx->SetLengthEnd(length2);
- if (( flags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE )
- {
- fx->SetLengthParm( lengthParm * PI * 0.001f );
- }
- else if ( flags & FX_LENGTH_PARM_MASK )
- {
- fx->SetLengthParm( lengthParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_LENGTH_PARM_MASK) == FX_LENGTH_WAVE) {
+ fx->SetLengthParm(lengthParm * PI * 0.001f);
+ } else if (flags & FX_LENGTH_PARM_MASK) {
+ fx->SetLengthParm(lengthParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetFlags( flags );
- fx->SetShader( shader );
- fx->SetElasticity( elasticity );
- fx->SetMin( min );
- fx->SetMax( max );
- fx->SetSTScale( 1.0f, 1.0f );
- fx->SetDeathFxID( deathID );
- fx->SetImpactFxID( impactID );
+ fx->SetFlags(flags);
+ fx->SetShader(shader);
+ fx->SetElasticity(elasticity);
+ fx->SetMin(min);
+ fx->SetMax(max);
+ fx->SetSTScale(1.0f, 1.0f);
+ fx->SetDeathFxID(deathID);
+ fx->SetImpactFxID(impactID);
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
@@ -768,107 +612,82 @@ CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel,
//-------------------------
// FX_AddCylinder
//-------------------------
-CCylinder *FX_AddCylinder( int clientID, vec3_t start, vec3_t normal,
- float size1s, float size1e, float sizeParm,
- float size2s, float size2e, float size2Parm,
- float length1, float length2, float lengthParm,
- float alpha1, float alpha2, float alphaParm,
- vec3_t rgb1, vec3_t rgb2, float rgbParm,
- int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding new effects when the system is paused
+CCylinder *FX_AddCylinder(int clientID, vec3_t start, vec3_t normal, float size1s, float size1e, float sizeParm, float size2s, float size2e, float size2Parm,
+ float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm,
+ int killTime, qhandle_t shader, int flags, int modelNum, int boltNum) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding new effects when the system is paused
return 0;
}
CCylinder *fx = new CCylinder;
- if ( fx )
- {
- if (flags&FX_RELATIVE && clientID>=0)
- {
- fx->SetOrigin1( NULL );
- fx->SetOrgOffset( start );//offset
- //NOTE: relative version doesn't ever use normal!
- //fx->SetNormal( normal );
- fx->SetClient( clientID, modelNum, boltNum );
- }
- else
- {
- fx->SetOrigin1( start );
- fx->SetNormal( normal );
+ if (fx) {
+ if (flags & FX_RELATIVE && clientID >= 0) {
+ fx->SetOrigin1(NULL);
+ fx->SetOrgOffset(start); // offset
+ // NOTE: relative version doesn't ever use normal!
+ // fx->SetNormal( normal );
+ fx->SetClient(clientID, modelNum, boltNum);
+ } else {
+ fx->SetOrigin1(start);
+ fx->SetNormal(normal);
}
// RGB----------------
- fx->SetRGBStart( rgb1 );
- fx->SetRGBEnd( rgb2 );
+ fx->SetRGBStart(rgb1);
+ fx->SetRGBEnd(rgb2);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size1----------------
- fx->SetSizeStart( size1s );
- fx->SetSizeEnd( size1e );
+ fx->SetSizeStart(size1s);
+ fx->SetSizeEnd(size1e);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size2----------------
- fx->SetSize2Start( size2s );
- fx->SetSize2End( size2e );
+ fx->SetSize2Start(size2s);
+ fx->SetSize2End(size2e);
- if (( flags & FX_SIZE2_PARM_MASK ) == FX_SIZE2_WAVE )
- {
- fx->SetSize2Parm( size2Parm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE2_PARM_MASK )
- {
- fx->SetSize2Parm( size2Parm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE2_PARM_MASK) == FX_SIZE2_WAVE) {
+ fx->SetSize2Parm(size2Parm * PI * 0.001f);
+ } else if (flags & FX_SIZE2_PARM_MASK) {
+ fx->SetSize2Parm(size2Parm * 0.01f * killTime + theFxHelper.mTime);
}
// Length1---------------
- fx->SetLengthStart( length1 );
- fx->SetLengthEnd( length2 );
+ fx->SetLengthStart(length1);
+ fx->SetLengthEnd(length2);
- if (( flags & FX_LENGTH_PARM_MASK ) == FX_LENGTH_WAVE )
- {
- fx->SetLengthParm( lengthParm * PI * 0.001f );
- }
- else if ( flags & FX_LENGTH_PARM_MASK )
- {
- fx->SetLengthParm( lengthParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_LENGTH_PARM_MASK) == FX_LENGTH_WAVE) {
+ fx->SetLengthParm(lengthParm * PI * 0.001f);
+ } else if (flags & FX_LENGTH_PARM_MASK) {
+ fx->SetLengthParm(lengthParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetShader( shader );
- fx->SetFlags( flags );
+ fx->SetShader(shader);
+ fx->SetFlags(flags);
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
}
return fx;
@@ -877,87 +696,69 @@ CCylinder *FX_AddCylinder( int clientID, vec3_t start, vec3_t normal,
//-------------------------
// FX_AddEmitter
//-------------------------
-CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel,
- float size1, float size2, float sizeParm,
- float alpha1, float alpha2, float alphaParm,
- vec3_t rgb1, vec3_t rgb2, float rgbParm,
- vec3_t angs, vec3_t deltaAngs,
- vec3_t min, vec3_t max, float elasticity,
- int deathID, int impactID, int emitterID,
- float density, float variance,
- int killTime, qhandle_t model, int flags )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding effects when the system is paused
+CEmitter *FX_AddEmitter(vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm,
+ vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t angs, vec3_t deltaAngs, vec3_t min, vec3_t max, float elasticity, int deathID,
+ int impactID, int emitterID, float density, float variance, int killTime, qhandle_t model, int flags) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding effects when the system is paused
return 0;
}
CEmitter *fx = new CEmitter;
- if ( fx )
- {
- fx->SetOrigin1( org );
- fx->SetVel( vel );
- fx->SetAccel( accel );
+ if (fx) {
+ fx->SetOrigin1(org);
+ fx->SetVel(vel);
+ fx->SetAccel(accel);
// RGB----------------
- fx->SetRGBStart( rgb1 );
- fx->SetRGBEnd( rgb2 );
+ fx->SetRGBStart(rgb1);
+ fx->SetRGBEnd(rgb2);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
-
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
- }
-
- fx->SetAngles( angs );
- fx->SetAngleDelta( deltaAngs );
- fx->SetFlags( flags );
- fx->SetModel( model );
- fx->SetElasticity( elasticity );
- fx->SetMin( min );
- fx->SetMax( max );
- fx->SetDeathFxID( deathID );
- fx->SetImpactFxID( impactID );
- fx->SetEmitterFxID( emitterID );
- fx->SetDensity( density );
- fx->SetVariance( variance );
- fx->SetOldTime( theFxHelper.mTime );
-
- fx->SetLastOrg( org );
- fx->SetLastVel( vel );
-
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
+
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
+ }
+
+ fx->SetAngles(angs);
+ fx->SetAngleDelta(deltaAngs);
+ fx->SetFlags(flags);
+ fx->SetModel(model);
+ fx->SetElasticity(elasticity);
+ fx->SetMin(min);
+ fx->SetMax(max);
+ fx->SetDeathFxID(deathID);
+ fx->SetImpactFxID(impactID);
+ fx->SetEmitterFxID(emitterID);
+ fx->SetDensity(density);
+ fx->SetVariance(variance);
+ fx->SetOldTime(theFxHelper.mTime);
+
+ fx->SetLastOrg(org);
+ fx->SetLastVel(vel);
+
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
@@ -967,299 +768,235 @@ CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel,
//-------------------------
// FX_AddLight
//-------------------------
-CLight *FX_AddLight( vec3_t org, float size1, float size2, float sizeParm,
- vec3_t rgb1, vec3_t rgb2, float rgbParm,
- int killTime, int flags )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding effects when the system is paused
+CLight *FX_AddLight(vec3_t org, float size1, float size2, float sizeParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, int killTime, int flags) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding effects when the system is paused
return 0;
}
CLight *fx = new CLight;
- if ( fx )
- {
- fx->SetOrigin1( org );
+ if (fx) {
+ fx->SetOrigin1(org);
// RGB----------------
- fx->SetRGBStart( rgb1 );
- fx->SetRGBEnd( rgb2 );
+ fx->SetRGBStart(rgb1);
+ fx->SetRGBEnd(rgb2);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetFlags( flags );
+ fx->SetFlags(flags);
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
return fx;
-
}
-
//-------------------------
// FX_AddOrientedParticle
//-------------------------
-COrientedParticle *FX_AddOrientedParticle( int clientID, vec3_t org, vec3_t norm, vec3_t vel, vec3_t accel,
- float size1, float size2, float sizeParm,
- float alpha1, float alpha2, float alphaParm,
- vec3_t rgb1, vec3_t rgb2, float rgbParm,
- float rotation, float rotationDelta,
- vec3_t min, vec3_t max, float bounce,
- int deathID, int impactID,
- int killTime, qhandle_t shader, int flags, int modelNum, int boltNum )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding effects when the system is paused
+COrientedParticle *FX_AddOrientedParticle(int clientID, vec3_t org, vec3_t norm, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm,
+ float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, float rotation,
+ float rotationDelta, vec3_t min, vec3_t max, float bounce, int deathID, int impactID, int killTime, qhandle_t shader,
+ int flags, int modelNum, int boltNum) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding effects when the system is paused
return 0;
}
COrientedParticle *fx = new COrientedParticle;
- if ( fx )
- {
- if (flags&FX_RELATIVE && clientID>=0)
- {
- fx->SetOrigin1( NULL );
- fx->SetOrgOffset( org );//offset
- fx->SetNormalOffset( norm );
- fx->SetClient( clientID, modelNum, boltNum );
- }
- else
- {
- fx->SetOrigin1( org );
- fx->SetNormal( norm );
+ if (fx) {
+ if (flags & FX_RELATIVE && clientID >= 0) {
+ fx->SetOrigin1(NULL);
+ fx->SetOrgOffset(org); // offset
+ fx->SetNormalOffset(norm);
+ fx->SetClient(clientID, modelNum, boltNum);
+ } else {
+ fx->SetOrigin1(org);
+ fx->SetNormal(norm);
}
- fx->SetVel( vel );
- fx->SetAccel( accel );
+ fx->SetVel(vel);
+ fx->SetAccel(accel);
// RGB----------------
- fx->SetRGBStart( rgb1 );
- fx->SetRGBEnd( rgb2 );
+ fx->SetRGBStart(rgb1);
+ fx->SetRGBEnd(rgb2);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
-
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
- }
-
- fx->SetFlags( flags );
- fx->SetShader( shader );
- fx->SetRotation( rotation );
- fx->SetRotationDelta( rotationDelta );
- fx->SetElasticity( bounce );
- fx->SetMin( min );
- fx->SetMax( max );
- fx->SetDeathFxID( deathID );
- fx->SetImpactFxID( impactID );
-
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
+
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
+ }
+
+ fx->SetFlags(flags);
+ fx->SetShader(shader);
+ fx->SetRotation(rotation);
+ fx->SetRotationDelta(rotationDelta);
+ fx->SetElasticity(bounce);
+ fx->SetMin(min);
+ fx->SetMax(max);
+ fx->SetDeathFxID(deathID);
+ fx->SetImpactFxID(impactID);
+
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
return fx;
}
-
//-------------------------
// FX_AddPoly
//-------------------------
-CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts,
- vec3_t vel, vec3_t accel,
- float alpha1, float alpha2, float alphaParm,
- vec3_t rgb1, vec3_t rgb2, float rgbParm,
- vec3_t rotationDelta, float bounce, int motionDelay,
- int killTime, qhandle_t shader, int flags )
-{
- if ( theFxHelper.mFrameTime < 1 || !verts )
- { // disallow adding effects when the system is paused or the user doesn't pass in a vert array
+CPoly *FX_AddPoly(vec3_t *verts, vec2_t *st, int numVerts, vec3_t vel, vec3_t accel, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2,
+ float rgbParm, vec3_t rotationDelta, float bounce, int motionDelay, int killTime, qhandle_t shader, int flags) {
+ if (theFxHelper.mFrameTime < 1 || !verts) { // disallow adding effects when the system is paused or the user doesn't pass in a vert array
return 0;
}
CPoly *fx = new CPoly;
- if ( fx )
- {
+ if (fx) {
// Do a cheesy copy of the verts and texture coords into our own structure
- for ( int i = 0; i < numVerts; i++ )
- {
- VectorCopy( verts[i], fx->mOrg[i] );
- VectorCopy2( st[i], fx->mST[i] );
+ for (int i = 0; i < numVerts; i++) {
+ VectorCopy(verts[i], fx->mOrg[i]);
+ VectorCopy2(st[i], fx->mST[i]);
}
- fx->SetVel( vel );
- fx->SetAccel( accel );
+ fx->SetVel(vel);
+ fx->SetAccel(accel);
// RGB----------------
- fx->SetRGBStart( rgb1 );
- fx->SetRGBEnd( rgb2 );
+ fx->SetRGBStart(rgb1);
+ fx->SetRGBEnd(rgb2);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetFlags( flags );
- fx->SetShader( shader );
- fx->SetRot( rotationDelta );
- fx->SetElasticity( bounce );
- fx->SetMotionTimeStamp( motionDelay );
- fx->SetNumVerts( numVerts );
+ fx->SetFlags(flags);
+ fx->SetShader(shader);
+ fx->SetRot(rotationDelta);
+ fx->SetElasticity(bounce);
+ fx->SetMotionTimeStamp(motionDelay);
+ fx->SetNumVerts(numVerts);
// Now that we've set our data up, let's process it into a useful format
fx->PolyInit();
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
// in the editor, fx may now be NULL
}
return fx;
}
-
//-------------------------
// FX_AddBezier
//-------------------------
-CBezier *FX_AddBezier( const vec3_t start, const vec3_t end,
- const vec3_t control1, const vec3_t control1Vel,
- const vec3_t control2, const vec3_t control2Vel,
- float size1, float size2, float sizeParm,
- float alpha1, float alpha2, float alphaParm,
- const vec3_t sRGB, const vec3_t eRGB, const float rgbParm,
- int killTime, qhandle_t shader, int flags )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding new effects when the system is paused
+CBezier *FX_AddBezier(const vec3_t start, const vec3_t end, const vec3_t control1, const vec3_t control1Vel, const vec3_t control2, const vec3_t control2Vel,
+ float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, const vec3_t sRGB, const vec3_t eRGB,
+ const float rgbParm, int killTime, qhandle_t shader, int flags) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding new effects when the system is paused
return 0;
}
CBezier *fx = new CBezier;
- if ( fx )
- {
- fx->SetOrigin1( start );
- fx->SetOrigin2( end );
+ if (fx) {
+ fx->SetOrigin1(start);
+ fx->SetOrigin2(end);
- fx->SetControlPoints( control1, control2 );
- fx->SetControlVel( control1Vel, control2Vel );
+ fx->SetControlPoints(control1, control2);
+ fx->SetControlVel(control1Vel, control2Vel);
// RGB----------------
- fx->SetRGBStart( sRGB );
- fx->SetRGBEnd( eRGB );
+ fx->SetRGBStart(sRGB);
+ fx->SetRGBEnd(eRGB);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
// Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ fx->SetAlphaStart(alpha1);
+ fx->SetAlphaEnd(alpha2);
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_ALPHA_PARM_MASK) == FX_ALPHA_WAVE) {
+ fx->SetAlphaParm(alphaParm * PI * 0.001f);
+ } else if (flags & FX_ALPHA_PARM_MASK) {
+ fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime);
}
// Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ fx->SetSizeStart(size1);
+ fx->SetSizeEnd(size2);
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ if ((flags & FX_SIZE_PARM_MASK) == FX_SIZE_WAVE) {
+ fx->SetSizeParm(sizeParm * PI * 0.001f);
+ } else if (flags & FX_SIZE_PARM_MASK) {
+ fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime);
}
- fx->SetShader( shader );
- fx->SetFlags( flags );
+ fx->SetShader(shader);
+ fx->SetFlags(flags);
- fx->SetSTScale( 1.0f, 1.0f );
+ fx->SetSTScale(1.0f, 1.0f);
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
}
return fx;
@@ -1268,68 +1005,61 @@ CBezier *FX_AddBezier( const vec3_t start, const vec3_t end,
//-------------------------
// FX_AddFlash
//-------------------------
-CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm,
- int killTime, qhandle_t shader, int flags = 0 )
-{
- if ( theFxHelper.mFrameTime < 1 )
- { // disallow adding new effects when the system is paused
+CFlash *FX_AddFlash(vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int flags = 0) {
+ if (theFxHelper.mFrameTime < 1) { // disallow adding new effects when the system is paused
return 0;
}
CFlash *fx = new CFlash;
- if ( fx )
- {
- fx->SetOrigin1( origin );
+ if (fx) {
+ fx->SetOrigin1(origin);
// RGB----------------
- fx->SetRGBStart( sRGB );
- fx->SetRGBEnd( eRGB );
+ fx->SetRGBStart(sRGB);
+ fx->SetRGBEnd(eRGB);
- if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
- {
- fx->SetRGBParm( rgbParm * PI * 0.001f );
- }
- else if ( flags & FX_RGB_PARM_MASK )
- {
+ if ((flags & FX_RGB_PARM_MASK) == FX_RGB_WAVE) {
+ fx->SetRGBParm(rgbParm * PI * 0.001f);
+ } else if (flags & FX_RGB_PARM_MASK) {
// rgbParm should be a value from 0-100..
- fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
+ fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime);
}
-/* // Alpha----------------
- fx->SetAlphaStart( alpha1 );
- fx->SetAlphaEnd( alpha2 );
+ /* // Alpha----------------
+ fx->SetAlphaStart( alpha1 );
+ fx->SetAlphaEnd( alpha2 );
- if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
- {
- fx->SetAlphaParm( alphaParm * PI * 0.001f );
- }
- else if ( flags & FX_ALPHA_PARM_MASK )
- {
- fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
- }
+ if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
+ {
+ fx->SetAlphaParm( alphaParm * PI * 0.001f );
+ }
+ else if ( flags & FX_ALPHA_PARM_MASK )
+ {
+ fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
+ }
- // Size----------------
- fx->SetSizeStart( size1 );
- fx->SetSizeEnd( size2 );
+ // Size----------------
+ fx->SetSizeStart( size1 );
+ fx->SetSizeEnd( size2 );
- if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
- {
- fx->SetSizeParm( sizeParm * PI * 0.001f );
- }
- else if ( flags & FX_SIZE_PARM_MASK )
- {
- fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
- }
-*/
- fx->SetShader( shader );
- fx->SetFlags( flags );
+ if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
+ {
+ fx->SetSizeParm( sizeParm * PI * 0.001f );
+ }
+ else if ( flags & FX_SIZE_PARM_MASK )
+ {
+ fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
+ }
+ */
+ fx->SetShader(shader);
+ fx->SetFlags(flags);
-// fx->SetSTScale( 1.0f, 1.0f );
+ // fx->SetSTScale( 1.0f, 1.0f );
fx->Init();
- FX_AddPrimitive( (CEffect**)&fx, killTime );
+ FX_AddPrimitive((CEffect **)&fx, killTime);
}
return fx;
@@ -1345,76 +1075,33 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm,
//-------------------------------------------------------
//---------------------------------------------------
-void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel,
- float scale, float dscale,
- float sAlpha, float eAlpha,
- float rotation, float bounce,
- int life, qhandle_t shader, int flags )
-{
- FX_AddParticle( -1, origin, vel, accel, 0, scale, scale, 0,
- sAlpha, eAlpha, FX_ALPHA_LINEAR,
- WHITE, WHITE, 0,
- rotation, 0,
- vec3_origin, vec3_origin, bounce,
- 0, 0,
- life, shader, flags );
+void FX_AddSprite(vec3_t origin, vec3_t vel, vec3_t accel, float scale, float dscale, float sAlpha, float eAlpha, float rotation, float bounce, int life,
+ qhandle_t shader, int flags) {
+ FX_AddParticle(-1, origin, vel, accel, 0, scale, scale, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, WHITE, WHITE, 0, rotation, 0, vec3_origin, vec3_origin, bounce,
+ 0, 0, life, shader, flags);
}
//---------------------------------------------------
-void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel,
- float scale, float dscale,
- float sAlpha, float eAlpha,
- vec3_t sRGB, vec3_t eRGB,
- float rotation, float bounce,
- int life, qhandle_t shader, int flags )
-{
- FX_AddParticle( -1, origin, vel, accel, 0, scale, scale, 0,
- sAlpha, eAlpha, FX_ALPHA_LINEAR,
- sRGB, eRGB, 0,
- rotation, 0,
- vec3_origin, vec3_origin, bounce,
- 0, 0,
- life, shader, flags );
+void FX_AddSprite(vec3_t origin, vec3_t vel, vec3_t accel, float scale, float dscale, float sAlpha, float eAlpha, vec3_t sRGB, vec3_t eRGB, float rotation,
+ float bounce, int life, qhandle_t shader, int flags) {
+ FX_AddParticle(-1, origin, vel, accel, 0, scale, scale, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, sRGB, eRGB, 0, rotation, 0, vec3_origin, vec3_origin, bounce, 0,
+ 0, life, shader, flags);
}
//---------------------------------------------------
-void FX_AddLine( vec3_t start, vec3_t end, float stScale,
- float width, float dwidth,
- float sAlpha, float eAlpha,
- int life, qhandle_t shader, int flags )
-{
- FX_AddLine( -1, start, end, width, width, 0,
- sAlpha, eAlpha, FX_ALPHA_LINEAR,
- WHITE, WHITE, 0,
- life, shader, 0, 0 );
+void FX_AddLine(vec3_t start, vec3_t end, float stScale, float width, float dwidth, float sAlpha, float eAlpha, int life, qhandle_t shader, int flags) {
+ FX_AddLine(-1, start, end, width, width, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, WHITE, WHITE, 0, life, shader, 0, 0);
}
//---------------------------------------------------
-void FX_AddLine( vec3_t start, vec3_t end, float stScale,
- float width, float dwidth,
- float sAlpha, float eAlpha,
- vec3_t sRGB, vec3_t eRGB,
- int life, qhandle_t shader, int flags )
-{
- FX_AddLine( -1, start, end, width, width, 0,
- sAlpha, eAlpha, FX_ALPHA_LINEAR,
- sRGB, eRGB, 0,
- life, shader, 0, flags );
+void FX_AddLine(vec3_t start, vec3_t end, float stScale, float width, float dwidth, float sAlpha, float eAlpha, vec3_t sRGB, vec3_t eRGB, int life,
+ qhandle_t shader, int flags) {
+ FX_AddLine(-1, start, end, width, width, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, sRGB, eRGB, 0, life, shader, 0, flags);
}
//---------------------------------------------------
-void FX_AddQuad( vec3_t origin, vec3_t normal,
- vec3_t vel, vec3_t accel,
- float sradius, float eradius,
- float salpha, float ealpha,
- vec3_t sRGB, vec3_t eRGB,
- float rotation, int life, qhandle_t shader, int flags )
-{
- FX_AddOrientedParticle( -1, origin, normal, vel, accel,
- sradius, eradius, 0.0f,
- salpha, ealpha, 0.0f,
- sRGB, eRGB, 0.0f,
- rotation, 0.0f,
- NULL, NULL, 0.0f, 0, 0, life,
- shader, 0 );
+void FX_AddQuad(vec3_t origin, vec3_t normal, vec3_t vel, vec3_t accel, float sradius, float eradius, float salpha, float ealpha, vec3_t sRGB, vec3_t eRGB,
+ float rotation, int life, qhandle_t shader, int flags) {
+ FX_AddOrientedParticle(-1, origin, normal, vel, accel, sradius, eradius, 0.0f, salpha, ealpha, 0.0f, sRGB, eRGB, 0.0f, rotation, 0.0f, NULL, NULL, 0.0f, 0,
+ 0, life, shader, 0);
}
diff --git a/code/cgame/cg_camera.cpp b/code/cgame/cg_camera.cpp
index 878a17dd3e..8683dcedb6 100644
--- a/code/cgame/cg_camera.cpp
+++ b/code/cgame/cg_camera.cpp
@@ -20,7 +20,7 @@ along with this program; if not, see .
===========================================================================
*/
-//Client camera controls for cinematics
+// Client camera controls for cinematics
#include "cg_headers.h"
@@ -28,18 +28,18 @@ along with this program; if not, see .
#include "../game/g_roff.h"
-bool in_camera = false;
-camera_t client_camera={};
-extern qboolean player_locked;
+bool in_camera = false;
+camera_t client_camera = {};
+extern qboolean player_locked;
-extern gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
-extern void G_UseTargets (gentity_t *ent, gentity_t *activator);
-void CGCam_FollowDisable( void );
-void CGCam_TrackDisable( void );
-void CGCam_Distance( float distance, qboolean initLerp );
-void CGCam_DistanceDisable( void );
-extern qboolean CG_CalcFOVFromX( float fov_x );
-extern void WP_SaberCatch( gentity_t *self, gentity_t *saber, qboolean switchToSaber );
+extern gentity_t *G_Find(gentity_t *from, int fieldofs, const char *match);
+extern void G_UseTargets(gentity_t *ent, gentity_t *activator);
+void CGCam_FollowDisable(void);
+void CGCam_TrackDisable(void);
+void CGCam_Distance(float distance, qboolean initLerp);
+void CGCam_DistanceDisable(void);
+extern qboolean CG_CalcFOVFromX(float fov_x);
+extern void WP_SaberCatch(gentity_t *self, gentity_t *saber, qboolean switchToSaber);
/*
TODO:
@@ -59,12 +59,10 @@ CGCam_Init
-------------------------
*/
-void CGCam_Init( void )
-{
+void CGCam_Init(void) {
extern qboolean qbVidRestartOccured;
- if (!qbVidRestartOccured)
- {
- memset( &client_camera, 0, sizeof ( camera_t ) );
+ if (!qbVidRestartOccured) {
+ memset(&client_camera, 0, sizeof(camera_t));
}
}
@@ -74,8 +72,7 @@ CGCam_Enable
-------------------------
*/
extern void CG_CalcVrect(void);
-void CGCam_Enable( void )
-{
+void CGCam_Enable(void) {
client_camera.bar_alpha = 0.0f;
client_camera.bar_time = cg.time;
@@ -83,46 +80,40 @@ void CGCam_Enable( void )
client_camera.bar_alpha_dest = 1.0f;
client_camera.bar_height_source = 0.0f;
- client_camera.bar_height_dest = 480/10;
+ client_camera.bar_height_dest = 480 / 10;
client_camera.bar_height = 0.0f;
client_camera.info_state |= CAMERA_BAR_FADING;
- client_camera.FOV = CAMERA_DEFAULT_FOV;
- client_camera.FOV2 = CAMERA_DEFAULT_FOV;
+ client_camera.FOV = CAMERA_DEFAULT_FOV;
+ client_camera.FOV2 = CAMERA_DEFAULT_FOV;
in_camera = true;
client_camera.next_roff_time = 0;
- if ( g_entities[0].inuse && g_entities[0].client )
- {
- //Player zero not allowed to do anything
- VectorClear( g_entities[0].client->ps.velocity );
+ if (g_entities[0].inuse && g_entities[0].client) {
+ // Player zero not allowed to do anything
+ VectorClear(g_entities[0].client->ps.velocity);
g_entities[0].contents = 0;
- if ( cg.zoomMode )
- {
+ if (cg.zoomMode) {
// need to shut off some form of zooming
cg.zoomMode = 0;
}
- if ( g_entities[0].client->ps.saberInFlight && g_entities[0].client->ps.saber[0].Active() )
- {//saber is out
+ if (g_entities[0].client->ps.saberInFlight && g_entities[0].client->ps.saber[0].Active()) { // saber is out
gentity_t *saberent = &g_entities[g_entities[0].client->ps.saberEntityNum];
- if ( saberent )
- {
- WP_SaberCatch( &g_entities[0], saberent, qfalse );
+ if (saberent) {
+ WP_SaberCatch(&g_entities[0], saberent, qfalse);
}
}
- for ( int i = 0; i < NUM_FORCE_POWERS; i++ )
- {//deactivate any active force powers
+ for (int i = 0; i < NUM_FORCE_POWERS; i++) { // deactivate any active force powers
g_entities[0].client->ps.forcePowerDuration[i] = 0;
-extern void WP_ForcePowerStop( gentity_t *self, forcePowers_t forcePower );
- if ( g_entities[0].client->ps.forcePowerDuration[i] || (g_entities[0].client->ps.forcePowersActive&( 1 << i )) )
- {
- WP_ForcePowerStop( &g_entities[0], (forcePowers_t)i );
+ extern void WP_ForcePowerStop(gentity_t * self, forcePowers_t forcePower);
+ if (g_entities[0].client->ps.forcePowerDuration[i] || (g_entities[0].client->ps.forcePowersActive & (1 << i))) {
+ WP_ForcePowerStop(&g_entities[0], (forcePowers_t)i);
}
}
}
@@ -133,8 +124,7 @@ CGCam_Disable
-------------------------
*/
-void CGCam_Disable( void )
-{
+void CGCam_Disable(void) {
in_camera = false;
client_camera.bar_alpha = 1.0f;
@@ -143,27 +133,26 @@ void CGCam_Disable( void )
client_camera.bar_alpha_source = 1.0f;
client_camera.bar_alpha_dest = 0.0f;
- client_camera.bar_height_source = 480/10;
+ client_camera.bar_height_source = 480 / 10;
client_camera.bar_height_dest = 0.0f;
client_camera.info_state |= CAMERA_BAR_FADING;
- if ( g_entities[0].inuse && g_entities[0].client )
- {
- g_entities[0].contents = CONTENTS_BODY;//MASK_PLAYERSOLID;
+ if (g_entities[0].inuse && g_entities[0].client) {
+ g_entities[0].contents = CONTENTS_BODY; // MASK_PLAYERSOLID;
}
- gi.SendServerCommand( 0, "cts");
+ gi.SendServerCommand(0, "cts");
- //if ( cg_skippingcin.integer )
- {//We're skipping the cinematic and it's over now
+ // if ( cg_skippingcin.integer )
+ { // We're skipping the cinematic and it's over now
gi.cvar_set("timescale", "1");
gi.cvar_set("skippingCinematic", "0");
}
- //we just came out of camera, so update cg.refdef.vieworg out of the camera's origin so the snapshot will know our new ori
- VectorCopy( g_entities[0].currentOrigin, cg.refdef.vieworg);
- VectorCopy( g_entities[0].client->ps.viewangles, cg.refdefViewAngles );
+ // we just came out of camera, so update cg.refdef.vieworg out of the camera's origin so the snapshot will know our new ori
+ VectorCopy(g_entities[0].currentOrigin, cg.refdef.vieworg);
+ VectorCopy(g_entities[0].client->ps.viewangles, cg.refdefViewAngles);
}
/*
@@ -172,10 +161,9 @@ CGCam_SetPosition
-------------------------
*/
-void CGCam_SetPosition( vec3_t org )
-{
- VectorCopy( org, client_camera.origin );
- VectorCopy( client_camera.origin, cg.refdef.vieworg );
+void CGCam_SetPosition(vec3_t org) {
+ VectorCopy(org, client_camera.origin);
+ VectorCopy(client_camera.origin, cg.refdef.vieworg);
}
/*
@@ -184,26 +172,23 @@ CGCam_Move
-------------------------
*/
-void CGCam_Move( vec3_t dest, float duration )
-{
- if ( client_camera.info_state & CAMERA_ROFFING )
- {
+void CGCam_Move(vec3_t dest, float duration) {
+ if (client_camera.info_state & CAMERA_ROFFING) {
client_camera.info_state &= ~CAMERA_ROFFING;
}
CGCam_TrackDisable();
CGCam_DistanceDisable();
- if ( !duration )
- {
+ if (!duration) {
client_camera.info_state &= ~CAMERA_MOVING;
- CGCam_SetPosition( dest );
+ CGCam_SetPosition(dest);
return;
}
client_camera.info_state |= CAMERA_MOVING;
- VectorCopy( dest, client_camera.origin2 );
+ VectorCopy(dest, client_camera.origin2);
client_camera.move_duration = duration;
client_camera.move_time = cg.time;
@@ -215,10 +200,9 @@ CGCam_SetAngles
-------------------------
*/
-void CGCam_SetAngles( vec3_t ang )
-{
- VectorCopy( ang, client_camera.angles );
- VectorCopy(client_camera.angles, cg.refdefViewAngles );
+void CGCam_SetAngles(vec3_t ang) {
+ VectorCopy(ang, client_camera.angles);
+ VectorCopy(client_camera.angles, cg.refdefViewAngles);
}
/*
@@ -227,81 +211,57 @@ CGCam_Pan
-------------------------
*/
-void CGCam_Pan( vec3_t dest, vec3_t panDirection, float duration )
-{
- //vec3_t panDirection = {0, 0, 0};
- int i;
- float delta1 , delta2;
+void CGCam_Pan(vec3_t dest, vec3_t panDirection, float duration) {
+ // vec3_t panDirection = {0, 0, 0};
+ int i;
+ float delta1, delta2;
CGCam_FollowDisable();
CGCam_DistanceDisable();
- if ( !duration )
- {
- CGCam_SetAngles( dest );
+ if (!duration) {
+ CGCam_SetAngles(dest);
client_camera.info_state &= ~CAMERA_PANNING;
return;
}
- //FIXME: make the dest an absolute value, and pass in a
- //panDirection as well. If a panDirection's axis value is
- //zero, find the shortest difference for that axis.
- //Store the delta in client_camera.angles2.
- for( i = 0; i < 3; i++ )
- {
- dest[i] = AngleNormalize360( dest[i] );
- delta1 = dest[i] - AngleNormalize360( client_camera.angles[i] );
- if ( delta1 < 0 )
- {
+ // FIXME: make the dest an absolute value, and pass in a
+ // panDirection as well. If a panDirection's axis value is
+ // zero, find the shortest difference for that axis.
+ // Store the delta in client_camera.angles2.
+ for (i = 0; i < 3; i++) {
+ dest[i] = AngleNormalize360(dest[i]);
+ delta1 = dest[i] - AngleNormalize360(client_camera.angles[i]);
+ if (delta1 < 0) {
delta2 = delta1 + 360;
- }
- else
- {
+ } else {
delta2 = delta1 - 360;
}
- if ( !panDirection[i] )
- {//Didn't specify a direction, pick shortest
- if( Q_fabs(delta1) < Q_fabs(delta2) )
- {
+ if (!panDirection[i]) { // Didn't specify a direction, pick shortest
+ if (Q_fabs(delta1) < Q_fabs(delta2)) {
client_camera.angles2[i] = delta1;
- }
- else
- {
+ } else {
client_camera.angles2[i] = delta2;
}
- }
- else if ( panDirection[i] < 0 )
- {
- if( delta1 < 0 )
- {
+ } else if (panDirection[i] < 0) {
+ if (delta1 < 0) {
client_camera.angles2[i] = delta1;
- }
- else if( delta1 > 0 )
- {
+ } else if (delta1 > 0) {
client_camera.angles2[i] = delta2;
- }
- else
- {//exact
+ } else { // exact
client_camera.angles2[i] = 0;
}
- }
- else if ( panDirection[i] > 0 )
- {
- if( delta1 > 0 )
- {
+ } else if (panDirection[i] > 0) {
+ if (delta1 > 0) {
client_camera.angles2[i] = delta1;
- }
- else if( delta1 < 0 )
- {
+ } else if (delta1 < 0) {
client_camera.angles2[i] = delta2;
- }
- else
- {//exact
+ } else { // exact
client_camera.angles2[i] = 0;
}
}
}
- //VectorCopy( dest, client_camera.angles2 );
+ // VectorCopy( dest, client_camera.angles2 );
client_camera.info_state |= CAMERA_PANNING;
@@ -315,10 +275,7 @@ CGCam_SetRoll
-------------------------
*/
-void CGCam_SetRoll( float roll )
-{
- client_camera.angles[2] = roll;
-}
+void CGCam_SetRoll(float roll) { client_camera.angles[2] = roll; }
/*
-------------------------
@@ -326,19 +283,17 @@ CGCam_Roll
-------------------------
*/
-void CGCam_Roll( float dest, float duration )
-{
- if ( !duration )
- {
- CGCam_SetRoll( dest );
+void CGCam_Roll(float dest, float duration) {
+ if (!duration) {
+ CGCam_SetRoll(dest);
return;
}
- //FIXME/NOTE: this will override current panning!!!
+ // FIXME/NOTE: this will override current panning!!!
client_camera.info_state |= CAMERA_PANNING;
- VectorCopy( client_camera.angles, client_camera.angles2 );
- client_camera.angles2[2] = AngleDelta( dest, client_camera.angles[2] );
+ VectorCopy(client_camera.angles, client_camera.angles2);
+ client_camera.angles2[2] = AngleDelta(dest, client_camera.angles[2]);
client_camera.pan_duration = duration;
client_camera.pan_time = cg.time;
@@ -350,10 +305,7 @@ CGCam_SetFOV
-------------------------
*/
-void CGCam_SetFOV( float FOV )
-{
- client_camera.FOV = FOV;
-}
+void CGCam_SetFOV(float FOV) { client_camera.FOV = FOV; }
/*
-------------------------
@@ -361,46 +313,40 @@ CGCam_Zoom
-------------------------
*/
-void CGCam_Zoom( float FOV, float duration )
-{
- if ( !duration )
- {
- CGCam_SetFOV( FOV );
+void CGCam_Zoom(float FOV, float duration) {
+ if (!duration) {
+ CGCam_SetFOV(FOV);
return;
}
client_camera.info_state |= CAMERA_ZOOMING;
- client_camera.FOV_time = cg.time;
- client_camera.FOV2 = FOV;
+ client_camera.FOV_time = cg.time;
+ client_camera.FOV2 = FOV;
client_camera.FOV_duration = duration;
}
-void CGCam_Zoom2( float FOV, float FOV2, float duration )
-{
- if ( !duration )
- {
- CGCam_SetFOV( FOV2 );
+void CGCam_Zoom2(float FOV, float FOV2, float duration) {
+ if (!duration) {
+ CGCam_SetFOV(FOV2);
return;
}
client_camera.info_state |= CAMERA_ZOOMING;
- client_camera.FOV_time = cg.time;
+ client_camera.FOV_time = cg.time;
client_camera.FOV = FOV;
- client_camera.FOV2 = FOV2;
+ client_camera.FOV2 = FOV2;
client_camera.FOV_duration = duration;
}
-void CGCam_ZoomAccel( float initialFOV, float fovVelocity, float fovAccel, float duration)
-{
- if ( !duration )
- {
+void CGCam_ZoomAccel(float initialFOV, float fovVelocity, float fovAccel, float duration) {
+ if (!duration) {
return;
}
client_camera.info_state |= CAMERA_ACCEL;
- client_camera.FOV_time = cg.time;
+ client_camera.FOV_time = cg.time;
client_camera.FOV2 = initialFOV;
client_camera.FOV_vel = fovVelocity;
client_camera.FOV_acc = fovAccel;
@@ -414,12 +360,11 @@ CGCam_Fade
-------------------------
*/
-void CGCam_SetFade( vec4_t dest )
-{//Instant completion
+void CGCam_SetFade(vec4_t dest) { // Instant completion
client_camera.info_state &= ~CAMERA_FADING;
client_camera.fade_duration = 0;
- VectorCopy4( dest, client_camera.fade_source );
- VectorCopy4( dest, client_camera.fade_color );
+ VectorCopy4(dest, client_camera.fade_source);
+ VectorCopy4(dest, client_camera.fade_color);
}
/*
@@ -428,16 +373,14 @@ CGCam_Fade
-------------------------
*/
-void CGCam_Fade( vec4_t source, vec4_t dest, float duration )
-{
- if ( !duration )
- {
- CGCam_SetFade( dest );
+void CGCam_Fade(vec4_t source, vec4_t dest, float duration) {
+ if (!duration) {
+ CGCam_SetFade(dest);
return;
}
- VectorCopy4( source, client_camera.fade_source );
- VectorCopy4( dest, client_camera.fade_dest );
+ VectorCopy4(source, client_camera.fade_source);
+ VectorCopy4(dest, client_camera.fade_dest);
client_camera.fade_duration = duration;
client_camera.fade_time = cg.time;
@@ -445,72 +388,57 @@ void CGCam_Fade( vec4_t source, vec4_t dest, float duration )
client_camera.info_state |= CAMERA_FADING;
}
-void CGCam_FollowDisable( void )
-{
+void CGCam_FollowDisable(void) {
client_camera.info_state &= ~CAMERA_FOLLOWING;
client_camera.cameraGroup[0] = 0;
client_camera.cameraGroupZOfs = 0;
client_camera.cameraGroupTag[0] = 0;
}
-void CGCam_TrackDisable( void )
-{
+void CGCam_TrackDisable(void) {
client_camera.info_state &= ~CAMERA_TRACKING;
client_camera.trackEntNum = ENTITYNUM_WORLD;
}
-void CGCam_DistanceDisable( void )
-{
- client_camera.distance = 0;
-}
+void CGCam_DistanceDisable(void) { client_camera.distance = 0; }
/*
-------------------------
CGCam_Follow
-------------------------
*/
-void CGCam_Follow( const char *cameraGroup, float speed, float initLerp )
-{
- //Clear any previous
+void CGCam_Follow(const char *cameraGroup, float speed, float initLerp) {
+ // Clear any previous
CGCam_FollowDisable();
- if(!cameraGroup || !cameraGroup[0])
- {
+ if (!cameraGroup || !cameraGroup[0]) {
return;
}
- if ( Q_stricmp("none", (char *)cameraGroup) == 0 )
- {//Turn off all aiming
+ if (Q_stricmp("none", (char *)cameraGroup) == 0) { // Turn off all aiming
return;
}
- if ( Q_stricmp("NULL", (char *)cameraGroup) == 0 )
- {//Turn off all aiming
+ if (Q_stricmp("NULL", (char *)cameraGroup) == 0) { // Turn off all aiming
return;
}
- //NOTE: if this interrupts a pan before it's done, need to copy the cg.refdef.viewAngles to the camera.angles!
+ // NOTE: if this interrupts a pan before it's done, need to copy the cg.refdef.viewAngles to the camera.angles!
client_camera.info_state |= CAMERA_FOLLOWING;
client_camera.info_state &= ~CAMERA_PANNING;
- //NULL terminate last char in case they type a name too long
- Q_strncpyz( client_camera.cameraGroup, cameraGroup, sizeof(client_camera.cameraGroup) );
+ // NULL terminate last char in case they type a name too long
+ Q_strncpyz(client_camera.cameraGroup, cameraGroup, sizeof(client_camera.cameraGroup));
- if ( speed )
- {
+ if (speed) {
client_camera.followSpeed = speed;
- }
- else
- {
+ } else {
client_camera.followSpeed = 100.0f;
}
- if ( initLerp )
- {
+ if (initLerp) {
client_camera.followInitLerp = qtrue;
- }
- else
- {
+ } else {
client_camera.followInitLerp = qfalse;
}
}
@@ -526,8 +454,7 @@ Q3_CameraAutoAim
-------------------------
*/
-void CG_CameraAutoAim( const char *name )
-{
+void CG_CameraAutoAim(const char *name) {
/*
gentity_t *aimEnt = NULL;
@@ -559,24 +486,21 @@ void CG_CameraAutoAim( const char *name )
CGCam_Track
-------------------------
*/
-void CGCam_Track( const char *trackName, float speed, float initLerp )
-{
- gentity_t *trackEnt = NULL;
+void CGCam_Track(const char *trackName, float speed, float initLerp) {
+ gentity_t *trackEnt = NULL;
CGCam_TrackDisable();
- if(Q_stricmp("none", (char *)trackName) == 0)
- {//turn off tracking
+ if (Q_stricmp("none", (char *)trackName) == 0) { // turn off tracking
return;
}
- //NOTE: if this interrupts a move before it's done, need to copy the cg.refdef.vieworg to the camera.origin!
- //This will find a path_corner now, not a misc_camera_track
+ // NOTE: if this interrupts a move before it's done, need to copy the cg.refdef.vieworg to the camera.origin!
+ // This will find a path_corner now, not a misc_camera_track
trackEnt = G_Find(NULL, FOFS(targetname), (char *)trackName);
- if ( !trackEnt )
- {
- gi.Printf(S_COLOR_RED"ERROR: %s camera track target not found\n", trackName);
+ if (!trackEnt) {
+ gi.Printf(S_COLOR_RED "ERROR: %s camera track target not found\n", trackName);
return;
}
@@ -584,16 +508,13 @@ void CGCam_Track( const char *trackName, float speed, float initLerp )
client_camera.info_state &= ~CAMERA_MOVING;
client_camera.trackEntNum = trackEnt->s.number;
- client_camera.initSpeed = speed/10.0f;
+ client_camera.initSpeed = speed / 10.0f;
client_camera.speed = speed;
client_camera.nextTrackEntUpdateTime = cg.time;
- if ( initLerp )
- {
+ if (initLerp) {
client_camera.trackInitLerp = qtrue;
- }
- else
- {
+ } else {
client_camera.trackInitLerp = qfalse;
}
/*
@@ -602,27 +523,24 @@ void CGCam_Track( const char *trackName, float speed, float initLerp )
}
*/
- //Set a moveDir
- VectorSubtract( trackEnt->currentOrigin, client_camera.origin, client_camera.moveDir );
+ // Set a moveDir
+ VectorSubtract(trackEnt->currentOrigin, client_camera.origin, client_camera.moveDir);
- if ( !client_camera.trackInitLerp )
- {//want to snap to first position
- //Snap to trackEnt's origin
- VectorCopy( trackEnt->currentOrigin, client_camera.origin );
+ if (!client_camera.trackInitLerp) { // want to snap to first position
+ // Snap to trackEnt's origin
+ VectorCopy(trackEnt->currentOrigin, client_camera.origin);
- //Set new moveDir if trackEnt has a next path_corner
- //Possible that track has no next point, in which case we won't be moving anyway
- if ( trackEnt->target && trackEnt->target[0] )
- {
- gentity_t *newTrackEnt = G_Find( NULL, FOFS(targetname), trackEnt->target );
- if ( newTrackEnt )
- {
- VectorSubtract( newTrackEnt->currentOrigin, client_camera.origin, client_camera.moveDir );
+ // Set new moveDir if trackEnt has a next path_corner
+ // Possible that track has no next point, in which case we won't be moving anyway
+ if (trackEnt->target && trackEnt->target[0]) {
+ gentity_t *newTrackEnt = G_Find(NULL, FOFS(targetname), trackEnt->target);
+ if (newTrackEnt) {
+ VectorSubtract(newTrackEnt->currentOrigin, client_camera.origin, client_camera.moveDir);
}
}
}
- VectorNormalize( client_camera.moveDir );
+ VectorNormalize(client_camera.moveDir);
}
/*
@@ -638,8 +556,7 @@ Q3_CameraAutoTrack
-------------------------
*/
-void CG_CameraAutoTrack( const char *name )
-{
+void CG_CameraAutoTrack(const char *name) {
/*
gentity_t *trackEnt = NULL;
@@ -672,36 +589,28 @@ CGCam_Distance
-------------------------
*/
-void CGCam_Distance( float distance, float initLerp )
-{
+void CGCam_Distance(float distance, float initLerp) {
client_camera.distance = distance;
- if ( initLerp )
- {
+ if (initLerp) {
client_camera.distanceInitLerp = qtrue;
- }
- else
- {
+ } else {
client_camera.distanceInitLerp = qfalse;
}
}
//========================================================================================
+void CGCam_FollowUpdate(void) {
+ vec3_t center, dir, cameraAngles, vec, focus[MAX_CAMERA_GROUP_SUBJECTS]; // No more than 16 subjects in a cameraGroup
+ gentity_t *from = NULL;
+ centity_t *fromCent = NULL;
+ int num_subjects = 0, i;
+ qboolean focused = qfalse;
-void CGCam_FollowUpdate ( void )
-{
- vec3_t center, dir, cameraAngles, vec, focus[MAX_CAMERA_GROUP_SUBJECTS];//No more than 16 subjects in a cameraGroup
- gentity_t *from = NULL;
- centity_t *fromCent = NULL;
- int num_subjects = 0, i;
- qboolean focused = qfalse;
-
- if ( client_camera.cameraGroup[0] )
- {
- //Stay centered in my cameraGroup, if I have one
- while( NULL != (from = G_Find(from, FOFS(cameraGroup), client_camera.cameraGroup)))
- {
+ if (client_camera.cameraGroup[0]) {
+ // Stay centered in my cameraGroup, if I have one
+ while (NULL != (from = G_Find(from, FOFS(cameraGroup), client_camera.cameraGroup))) {
/*
if ( from->s.number == client_camera.aimEntNum )
{//This is the misc_camera_focus, we'll be removing this ent altogether eventually
@@ -709,93 +618,80 @@ void CGCam_FollowUpdate ( void )
}
*/
- if ( num_subjects >= MAX_CAMERA_GROUP_SUBJECTS )
- {
- gi.Printf(S_COLOR_RED"ERROR: Too many subjects in shot composition %s", client_camera.cameraGroup);
+ if (num_subjects >= MAX_CAMERA_GROUP_SUBJECTS) {
+ gi.Printf(S_COLOR_RED "ERROR: Too many subjects in shot composition %s", client_camera.cameraGroup);
break;
}
fromCent = &cg_entities[from->s.number];
- if ( !fromCent )
- {
+ if (!fromCent) {
continue;
}
focused = qfalse;
- if ( from->client && client_camera.cameraGroupTag[0] && fromCent->gent->ghoul2.size() )
- {
- int newBolt = gi.G2API_AddBolt( &fromCent->gent->ghoul2[from->playerModel], client_camera.cameraGroupTag );
- if ( newBolt != -1 )
- {
- mdxaBone_t boltMatrix;
- vec3_t fromAngles = {0,from->client->ps.legsYaw,0};
+ if (from->client && client_camera.cameraGroupTag[0] && fromCent->gent->ghoul2.size()) {
+ int newBolt = gi.G2API_AddBolt(&fromCent->gent->ghoul2[from->playerModel], client_camera.cameraGroupTag);
+ if (newBolt != -1) {
+ mdxaBone_t boltMatrix;
+ vec3_t fromAngles = {0, from->client->ps.legsYaw, 0};
- gi.G2API_GetBoltMatrix( fromCent->gent->ghoul2, from->playerModel, newBolt, &boltMatrix, fromAngles, fromCent->lerpOrigin, cg.time, cgs.model_draw, fromCent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, focus[num_subjects] );
+ gi.G2API_GetBoltMatrix(fromCent->gent->ghoul2, from->playerModel, newBolt, &boltMatrix, fromAngles, fromCent->lerpOrigin, cg.time,
+ cgs.model_draw, fromCent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, focus[num_subjects]);
focused = qtrue;
}
}
- if ( !focused )
- {
- if ( from->s.pos.trType != TR_STATIONARY )
-// if ( from->s.pos.trType == TR_INTERPOLATE )
- {//use interpolated origin?
- if ( !VectorCompare( vec3_origin, fromCent->lerpOrigin ) )
- {//hunh? Somehow we've never seen this gentity on the client, so there is no lerpOrigin, so cheat over to the game and use the currentOrigin
- VectorCopy( from->currentOrigin, focus[num_subjects] );
+ if (!focused) {
+ if (from->s.pos.trType != TR_STATIONARY)
+ // if ( from->s.pos.trType == TR_INTERPOLATE )
+ { // use interpolated origin?
+ if (!VectorCompare(vec3_origin, fromCent->lerpOrigin)) { // hunh? Somehow we've never seen this gentity on the client, so there is no
+ // lerpOrigin, so cheat over to the game and use the currentOrigin
+ VectorCopy(from->currentOrigin, focus[num_subjects]);
+ } else {
+ VectorCopy(fromCent->lerpOrigin, focus[num_subjects]);
}
- else
- {
- VectorCopy( fromCent->lerpOrigin, focus[num_subjects] );
- }
- }
- else
- {
+ } else {
VectorCopy(from->currentOrigin, focus[num_subjects]);
}
- //FIXME: make a list here of their s.numbers instead so we can do other stuff with the list below
- if ( from->client )
- {//Track to their eyes - FIXME: maybe go off a tag?
- //FIXME:
- //Based on FOV and distance to subject from camera, pick the point that
- //keeps eyes 3/4 up from bottom of screen... what about bars?
+ // FIXME: make a list here of their s.numbers instead so we can do other stuff with the list below
+ if (from->client) { // Track to their eyes - FIXME: maybe go off a tag?
+ // FIXME:
+ // Based on FOV and distance to subject from camera, pick the point that
+ // keeps eyes 3/4 up from bottom of screen... what about bars?
focus[num_subjects][2] += from->client->ps.viewheight;
}
}
- if ( client_camera.cameraGroupZOfs )
- {
+ if (client_camera.cameraGroupZOfs) {
focus[num_subjects][2] += client_camera.cameraGroupZOfs;
}
num_subjects++;
}
- if ( !num_subjects ) // Bad cameragroup
+ if (!num_subjects) // Bad cameragroup
{
#ifndef FINAL_BUILD
- gi.Printf(S_COLOR_RED"ERROR: Camera Focus unable to locate cameragroup: %s\n", client_camera.cameraGroup);
+ gi.Printf(S_COLOR_RED "ERROR: Camera Focus unable to locate cameragroup: %s\n", client_camera.cameraGroup);
#endif
return;
}
- //Now average all points
- VectorCopy( focus[0], center );
- for( i = 1; i < num_subjects; i++ )
- {
- VectorAdd( focus[i], center, center );
+ // Now average all points
+ VectorCopy(focus[0], center);
+ for (i = 1; i < num_subjects; i++) {
+ VectorAdd(focus[i], center, center);
}
- VectorScale( center, 1.0f/((float)num_subjects), center );
- }
- else
- {
+ VectorScale(center, 1.0f / ((float)num_subjects), center);
+ } else {
return;
}
- //Need to set a speed to keep a distance from
- //the subject- fixme: only do this if have a distance
- //set
- VectorSubtract( client_camera.subjectPos, center, vec );
- client_camera.subjectSpeed = VectorLengthSquared( vec ) * 100.0f / cg.frametime;
+ // Need to set a speed to keep a distance from
+ // the subject- fixme: only do this if have a distance
+ // set
+ VectorSubtract(client_camera.subjectPos, center, vec);
+ client_camera.subjectSpeed = VectorLengthSquared(vec) * 100.0f / cg.frametime;
/*
if ( !cg_skippingcin.integer )
@@ -803,232 +699,183 @@ void CGCam_FollowUpdate ( void )
Com_Printf( S_COLOR_RED"org: %s\n", vtos(center) );
}
*/
- VectorCopy( center, client_camera.subjectPos );
+ VectorCopy(center, client_camera.subjectPos);
- VectorSubtract( center, cg.refdef.vieworg, dir );//can't use client_camera.origin because it's not updated until the end of the move.
+ VectorSubtract(center, cg.refdef.vieworg, dir); // can't use client_camera.origin because it's not updated until the end of the move.
- //Get desired angle
+ // Get desired angle
vectoangles(dir, cameraAngles);
- if ( client_camera.followInitLerp )
- {//Lerping
- float frac = cg.frametime/100.0f * client_camera.followSpeed/100.f;
- for( i = 0; i < 3; i++ )
- {
- cameraAngles[i] = AngleNormalize180( cameraAngles[i] );
- cameraAngles[i] = AngleNormalize180( client_camera.angles[i] + frac * AngleNormalize180(cameraAngles[i] - client_camera.angles[i]) );
- cameraAngles[i] = AngleNormalize180( cameraAngles[i] );
+ if (client_camera.followInitLerp) { // Lerping
+ float frac = cg.frametime / 100.0f * client_camera.followSpeed / 100.f;
+ for (i = 0; i < 3; i++) {
+ cameraAngles[i] = AngleNormalize180(cameraAngles[i]);
+ cameraAngles[i] = AngleNormalize180(client_camera.angles[i] + frac * AngleNormalize180(cameraAngles[i] - client_camera.angles[i]));
+ cameraAngles[i] = AngleNormalize180(cameraAngles[i]);
}
#if 0
Com_Printf( "%s\n", vtos(cameraAngles) );
#endif
- }
- else
- {//Snapping, should do this first time if follow_lerp_to_start_duration is zero
- //will lerp from this point on
+ } else { // Snapping, should do this first time if follow_lerp_to_start_duration is zero
+ // will lerp from this point on
client_camera.followInitLerp = qtrue;
- for( i = 0; i < 3; i++ )
- {//normalize so that when we start lerping, it doesn't freak out
- cameraAngles[i] = AngleNormalize180( cameraAngles[i] );
+ for (i = 0; i < 3; i++) { // normalize so that when we start lerping, it doesn't freak out
+ cameraAngles[i] = AngleNormalize180(cameraAngles[i]);
}
- //So tracker doesn't move right away thinking the first angle change
- //is the subject moving... FIXME: shouldn't set this until lerp done OR snapped?
+ // So tracker doesn't move right away thinking the first angle change
+ // is the subject moving... FIXME: shouldn't set this until lerp done OR snapped?
client_camera.subjectSpeed = 0;
}
- //Point camera to lerp angles
+ // Point camera to lerp angles
/*
if ( !cg_skippingcin.integer )
{
Com_Printf( "ang: %s\n", vtos(cameraAngles) );
}
*/
- VectorCopy( cameraAngles, client_camera.angles );
+ VectorCopy(cameraAngles, client_camera.angles);
}
-void CGCam_TrackEntUpdate ( void )
-{//FIXME: only do every 100 ms
- gentity_t *trackEnt = NULL;
- gentity_t *newTrackEnt = NULL;
- qboolean reached = qfalse;
- vec3_t vec;
- float dist;
+void CGCam_TrackEntUpdate(void) { // FIXME: only do every 100 ms
+ gentity_t *trackEnt = NULL;
+ gentity_t *newTrackEnt = NULL;
+ qboolean reached = qfalse;
+ vec3_t vec;
+ float dist;
- if ( client_camera.trackEntNum >= 0 && client_camera.trackEntNum < ENTITYNUM_WORLD )
- {//We're already heading to a path_corner
+ if (client_camera.trackEntNum >= 0 && client_camera.trackEntNum < ENTITYNUM_WORLD) { // We're already heading to a path_corner
trackEnt = &g_entities[client_camera.trackEntNum];
- VectorSubtract( trackEnt->currentOrigin, client_camera.origin, vec );
- dist = VectorLengthSquared( vec );
- if ( dist < 256 )//16 squared
- {//FIXME: who should be doing the using here?
- G_UseTargets( trackEnt, trackEnt );
+ VectorSubtract(trackEnt->currentOrigin, client_camera.origin, vec);
+ dist = VectorLengthSquared(vec);
+ if (dist < 256) // 16 squared
+ { // FIXME: who should be doing the using here?
+ G_UseTargets(trackEnt, trackEnt);
reached = qtrue;
}
}
- if ( trackEnt && reached )
- {
+ if (trackEnt && reached) {
- if ( trackEnt->target && trackEnt->target[0] )
- {//Find our next path_corner
- newTrackEnt = G_Find( NULL, FOFS(targetname), trackEnt->target );
- if ( newTrackEnt )
- {
- if ( newTrackEnt->radius < 0 )
- {//Don't bother trying to maintain a radius
+ if (trackEnt->target && trackEnt->target[0]) { // Find our next path_corner
+ newTrackEnt = G_Find(NULL, FOFS(targetname), trackEnt->target);
+ if (newTrackEnt) {
+ if (newTrackEnt->radius < 0) { // Don't bother trying to maintain a radius
client_camera.distance = 0;
client_camera.speed = client_camera.initSpeed;
- }
- else if ( newTrackEnt->radius > 0 )
- {
+ } else if (newTrackEnt->radius > 0) {
client_camera.distance = newTrackEnt->radius;
}
- if ( newTrackEnt->speed < 0 )
- {//go back to our default speed
+ if (newTrackEnt->speed < 0) { // go back to our default speed
client_camera.speed = client_camera.initSpeed;
- }
- else if ( newTrackEnt->speed > 0 )
- {
- client_camera.speed = newTrackEnt->speed/10.0f;
+ } else if (newTrackEnt->speed > 0) {
+ client_camera.speed = newTrackEnt->speed / 10.0f;
}
}
- }
- else
- {//stop thinking if this is the last one
+ } else { // stop thinking if this is the last one
CGCam_TrackDisable();
}
}
- if ( newTrackEnt )
- {//Update will lerp this
+ if (newTrackEnt) { // Update will lerp this
client_camera.info_state |= CAMERA_TRACKING;
client_camera.trackEntNum = newTrackEnt->s.number;
- VectorCopy( newTrackEnt->currentOrigin, client_camera.trackToOrg );
+ VectorCopy(newTrackEnt->currentOrigin, client_camera.trackToOrg);
}
client_camera.nextTrackEntUpdateTime = cg.time + 100;
}
-void CGCam_TrackUpdate ( void )
-{
- vec3_t goalVec, curVec, trackPos, vec;
- float goalDist, dist;
- //qboolean slowDown = qfalse;
+void CGCam_TrackUpdate(void) {
+ vec3_t goalVec, curVec, trackPos, vec;
+ float goalDist, dist;
+ // qboolean slowDown = qfalse;
- if ( client_camera.nextTrackEntUpdateTime <= cg.time )
- {
+ if (client_camera.nextTrackEntUpdateTime <= cg.time) {
CGCam_TrackEntUpdate();
}
- VectorSubtract( client_camera.trackToOrg, client_camera.origin, goalVec );
- goalDist = VectorNormalize( goalVec );
- if ( goalDist > 100 )
- {
+ VectorSubtract(client_camera.trackToOrg, client_camera.origin, goalVec);
+ goalDist = VectorNormalize(goalVec);
+ if (goalDist > 100) {
goalDist = 100;
- }
- else if ( goalDist < 10 )
- {
+ } else if (goalDist < 10) {
goalDist = 10;
}
- if ( client_camera.distance && client_camera.info_state & CAMERA_FOLLOWING )
- {
- float adjust = 0.0f, desiredSpeed = 0.0f;
- float dot;
+ if (client_camera.distance && client_camera.info_state & CAMERA_FOLLOWING) {
+ float adjust = 0.0f, desiredSpeed = 0.0f;
+ float dot;
- if ( !client_camera.distanceInitLerp )
- {
- VectorSubtract( client_camera.origin, client_camera.subjectPos, vec );
- VectorNormalize( vec );
- //FIXME: use client_camera.moveDir here?
- VectorMA( client_camera.subjectPos, client_camera.distance, vec, client_camera.origin );
- //Snap to first time only
+ if (!client_camera.distanceInitLerp) {
+ VectorSubtract(client_camera.origin, client_camera.subjectPos, vec);
+ VectorNormalize(vec);
+ // FIXME: use client_camera.moveDir here?
+ VectorMA(client_camera.subjectPos, client_camera.distance, vec, client_camera.origin);
+ // Snap to first time only
client_camera.distanceInitLerp = qtrue;
return;
- }
- else if ( client_camera.subjectSpeed > 0.05f )
- {//Don't start moving until subject moves
- VectorSubtract( client_camera.subjectPos, client_camera.origin, vec );
+ } else if (client_camera.subjectSpeed > 0.05f) { // Don't start moving until subject moves
+ VectorSubtract(client_camera.subjectPos, client_camera.origin, vec);
dist = VectorNormalize(vec);
dot = DotProduct(goalVec, vec);
- if ( dist > client_camera.distance )
- {//too far away
- if ( dot > 0 )
- {//Camera is moving toward the subject
- adjust = (dist - client_camera.distance);//Speed up
- }
- else if ( dot < 0 )
- {//Camera is moving away from the subject
- adjust = (dist - client_camera.distance) * -1.0f;//Slow down
+ if (dist > client_camera.distance) { // too far away
+ if (dot > 0) { // Camera is moving toward the subject
+ adjust = (dist - client_camera.distance); // Speed up
+ } else if (dot < 0) { // Camera is moving away from the subject
+ adjust = (dist - client_camera.distance) * -1.0f; // Slow down
}
- }
- else if ( dist < client_camera.distance )
- {//too close
- if(dot > 0)
- {//Camera is moving toward the subject
- adjust = (client_camera.distance - dist) * -1.0f;//Slow down
- }
- else if(dot < 0)
- {//Camera is moving away from the subject
- adjust = (client_camera.distance - dist);//Speed up
+ } else if (dist < client_camera.distance) { // too close
+ if (dot > 0) { // Camera is moving toward the subject
+ adjust = (client_camera.distance - dist) * -1.0f; // Slow down
+ } else if (dot < 0) { // Camera is moving away from the subject
+ adjust = (client_camera.distance - dist); // Speed up
}
}
- //Speed of the focus + our error
- //desiredSpeed = aimCent->gent->speed + (adjust * cg.frametime/100.0f);//cg.frameInterpolation);
- desiredSpeed = (adjust);// * cg.frametime/100.0f);//cg.frameInterpolation);
+ // Speed of the focus + our error
+ // desiredSpeed = aimCent->gent->speed + (adjust * cg.frametime/100.0f);//cg.frameInterpolation);
+ desiredSpeed = (adjust); // * cg.frametime/100.0f);//cg.frameInterpolation);
- //self->moveInfo.speed = desiredSpeed;
+ // self->moveInfo.speed = desiredSpeed;
- //Don't change speeds faster than 10 every 10th of a second
- float max_allowed_accel = MAX_ACCEL_PER_FRAME * (cg.frametime/100.0f);
+ // Don't change speeds faster than 10 every 10th of a second
+ float max_allowed_accel = MAX_ACCEL_PER_FRAME * (cg.frametime / 100.0f);
- if ( !client_camera.subjectSpeed )
- {//full stop
+ if (!client_camera.subjectSpeed) { // full stop
client_camera.speed = desiredSpeed;
- }
- else if ( client_camera.speed - desiredSpeed > max_allowed_accel )
- {//new speed much slower, slow down at max accel
+ } else if (client_camera.speed - desiredSpeed > max_allowed_accel) { // new speed much slower, slow down at max accel
client_camera.speed -= max_allowed_accel;
- }
- else if ( desiredSpeed - client_camera.speed > max_allowed_accel )
- {//new speed much faster, speed up at max accel
+ } else if (desiredSpeed - client_camera.speed > max_allowed_accel) { // new speed much faster, speed up at max accel
client_camera.speed += max_allowed_accel;
- }
- else
- {//remember this speed
+ } else { // remember this speed
client_camera.speed = desiredSpeed;
}
- //Com_Printf("Speed: %4.2f (%4.2f)\n", self->moveInfo.speed, aimCent->gent->speed);
+ // Com_Printf("Speed: %4.2f (%4.2f)\n", self->moveInfo.speed, aimCent->gent->speed);
}
+ } else {
+ // slowDown = qtrue;
}
- else
- {
- //slowDown = qtrue;
- }
-
- //FIXME: this probably isn't right, round it out more
- VectorScale( goalVec, cg.frametime/100.0f, goalVec );
- VectorScale( client_camera.moveDir, (100.0f - cg.frametime)/100.0f, curVec );
- VectorAdd( goalVec, curVec, client_camera.moveDir );
- VectorNormalize( client_camera.moveDir );
+ // FIXME: this probably isn't right, round it out more
+ VectorScale(goalVec, cg.frametime / 100.0f, goalVec);
+ VectorScale(client_camera.moveDir, (100.0f - cg.frametime) / 100.0f, curVec);
+ VectorAdd(goalVec, curVec, client_camera.moveDir);
+ VectorNormalize(client_camera.moveDir);
/*if(slowDown)
{
VectorMA( client_camera.origin, client_camera.speed * goalDist/100.0f * cg.frametime/100.0f, client_camera.moveDir, trackPos );
}
else*/
- {
- VectorMA( client_camera.origin, client_camera.speed * cg.frametime/100.0f , client_camera.moveDir, trackPos );
- }
+ { VectorMA(client_camera.origin, client_camera.speed * cg.frametime / 100.0f, client_camera.moveDir, trackPos); }
- //FIXME: Implement
- //Need to find point on camera's path that is closest to the desired distance from subject
- //OR: Need to intelligently pick this desired distance based on framing...
- VectorCopy( trackPos, client_camera.origin );
+ // FIXME: Implement
+ // Need to find point on camera's path that is closest to the desired distance from subject
+ // OR: Need to intelligently pick this desired distance based on framing...
+ VectorCopy(trackPos, client_camera.origin);
}
//=========================================================================================
@@ -1039,18 +886,18 @@ CGCam_UpdateBarFade
-------------------------
*/
-void CGCam_UpdateBarFade( void )
-{
- if ( client_camera.bar_time + BAR_DURATION < cg.time )
- {
+void CGCam_UpdateBarFade(void) {
+ if (client_camera.bar_time + BAR_DURATION < cg.time) {
client_camera.bar_alpha = client_camera.bar_alpha_dest;
client_camera.info_state &= ~CAMERA_BAR_FADING;
client_camera.bar_height = client_camera.bar_height_dest;
- }
- else
- {
- client_camera.bar_alpha = client_camera.bar_alpha_source + ( ( client_camera.bar_alpha_dest - client_camera.bar_alpha_source ) / BAR_DURATION ) * ( cg.time - client_camera.bar_time );;
- client_camera.bar_height = client_camera.bar_height_source + ( ( client_camera.bar_height_dest - client_camera.bar_height_source ) / BAR_DURATION ) * ( cg.time - client_camera.bar_time );;
+ } else {
+ client_camera.bar_alpha = client_camera.bar_alpha_source +
+ ((client_camera.bar_alpha_dest - client_camera.bar_alpha_source) / BAR_DURATION) * (cg.time - client_camera.bar_time);
+ ;
+ client_camera.bar_height = client_camera.bar_height_source +
+ ((client_camera.bar_height_dest - client_camera.bar_height_source) / BAR_DURATION) * (cg.time - client_camera.bar_time);
+ ;
}
}
@@ -1060,20 +907,16 @@ CGCam_UpdateFade
-------------------------
*/
-void CGCam_UpdateFade( void )
-{
- if ( client_camera.info_state & CAMERA_FADING )
- {
- if ( client_camera.fade_time + client_camera.fade_duration < cg.time )
- {
- VectorCopy4( client_camera.fade_dest, client_camera.fade_color );
+void CGCam_UpdateFade(void) {
+ if (client_camera.info_state & CAMERA_FADING) {
+ if (client_camera.fade_time + client_camera.fade_duration < cg.time) {
+ VectorCopy4(client_camera.fade_dest, client_camera.fade_color);
client_camera.info_state &= ~CAMERA_FADING;
- }
- else
- {
- for ( int i = 0; i < 4; i++ )
- {
- client_camera.fade_color[i] = client_camera.fade_source[i] + (( ( client_camera.fade_dest[i] - client_camera.fade_source[i] ) ) / client_camera.fade_duration ) * ( cg.time - client_camera.fade_time );
+ } else {
+ for (int i = 0; i < 4; i++) {
+ client_camera.fade_color[i] =
+ client_camera.fade_source[i] +
+ (((client_camera.fade_dest[i] - client_camera.fade_source[i])) / client_camera.fade_duration) * (cg.time - client_camera.fade_time);
}
}
}
@@ -1083,228 +926,173 @@ void CGCam_UpdateFade( void )
CGCam_Update
-------------------------
*/
-static void CGCam_Roff( void );
+static void CGCam_Roff(void);
-void CGCam_Update( void )
-{
- int i;
- qboolean checkFollow = qfalse;
- qboolean checkTrack = qfalse;
+void CGCam_Update(void) {
+ int i;
+ qboolean checkFollow = qfalse;
+ qboolean checkTrack = qfalse;
// Apply new roff data to the camera as needed
- if ( client_camera.info_state & CAMERA_ROFFING )
- {
+ if (client_camera.info_state & CAMERA_ROFFING) {
CGCam_Roff();
}
- //Check for a zoom
- if (client_camera.info_state & CAMERA_ACCEL)
- {
+ // Check for a zoom
+ if (client_camera.info_state & CAMERA_ACCEL) {
// x = x0 + vt + 0.5*a*t*t
- float actualFOV_X = client_camera.FOV;
- float sanityMin = 1, sanityMax = 180;
- float t = (cg.time - client_camera.FOV_time)*0.001; // mult by 0.001 cuz otherwise t is too darned big
- float fovDuration = client_camera.FOV_duration;
+ float actualFOV_X = client_camera.FOV;
+ float sanityMin = 1, sanityMax = 180;
+ float t = (cg.time - client_camera.FOV_time) * 0.001; // mult by 0.001 cuz otherwise t is too darned big
+ float fovDuration = client_camera.FOV_duration;
#ifndef FINAL_BUILD
- if (cg_roffval4.integer)
- {
+ if (cg_roffval4.integer) {
fovDuration = cg_roffval4.integer;
}
#endif
- if ( client_camera.FOV_time + fovDuration < cg.time )
- {
+ if (client_camera.FOV_time + fovDuration < cg.time) {
client_camera.info_state &= ~CAMERA_ACCEL;
- }
- else
- {
- float initialPosVal = client_camera.FOV2;
- float velVal = client_camera.FOV_vel;
- float accVal = client_camera.FOV_acc;
+ } else {
+ float initialPosVal = client_camera.FOV2;
+ float velVal = client_camera.FOV_vel;
+ float accVal = client_camera.FOV_acc;
#ifndef FINAL_BUILD
- if (cg_roffdebug.integer)
- {
- if (fabs(cg_roffval1.value) > 0.001f)
- {
+ if (cg_roffdebug.integer) {
+ if (fabs(cg_roffval1.value) > 0.001f) {
initialPosVal = cg_roffval1.value;
}
- if (fabs(cg_roffval2.value) > 0.001f)
- {
+ if (fabs(cg_roffval2.value) > 0.001f) {
velVal = cg_roffval2.value;
}
- if (fabs(cg_roffval3.value) > 0.001f)
- {
+ if (fabs(cg_roffval3.value) > 0.001f) {
accVal = cg_roffval3.value;
}
}
#endif
- float initialPos = initialPosVal;
- float vel = velVal*t;
- float acc = 0.5*accVal*t*t;
+ float initialPos = initialPosVal;
+ float vel = velVal * t;
+ float acc = 0.5 * accVal * t * t;
actualFOV_X = initialPos + vel + acc;
- if (cg_roffdebug.integer)
- {
- Com_Printf("%d: fovaccel from %2.1f using vel = %2.4f, acc = %2.4f (current fov calc = %5.6f)\n",
- cg.time, initialPosVal, velVal, accVal, actualFOV_X);
+ if (cg_roffdebug.integer) {
+ Com_Printf("%d: fovaccel from %2.1f using vel = %2.4f, acc = %2.4f (current fov calc = %5.6f)\n", cg.time, initialPosVal, velVal, accVal,
+ actualFOV_X);
}
- if (actualFOV_X < sanityMin)
- {
+ if (actualFOV_X < sanityMin) {
actualFOV_X = sanityMin;
- }
- else if (actualFOV_X > sanityMax)
- {
+ } else if (actualFOV_X > sanityMax) {
actualFOV_X = sanityMax;
}
client_camera.FOV = actualFOV_X;
}
- CG_CalcFOVFromX( actualFOV_X );
- }
- else if ( client_camera.info_state & CAMERA_ZOOMING )
- {
- float actualFOV_X;
+ CG_CalcFOVFromX(actualFOV_X);
+ } else if (client_camera.info_state & CAMERA_ZOOMING) {
+ float actualFOV_X;
- if ( client_camera.FOV_time + client_camera.FOV_duration < cg.time )
- {
+ if (client_camera.FOV_time + client_camera.FOV_duration < cg.time) {
actualFOV_X = client_camera.FOV = client_camera.FOV2;
client_camera.info_state &= ~CAMERA_ZOOMING;
+ } else {
+ actualFOV_X = client_camera.FOV + (((client_camera.FOV2 - client_camera.FOV)) / client_camera.FOV_duration) * (cg.time - client_camera.FOV_time);
}
- else
- {
- actualFOV_X = client_camera.FOV + (( ( client_camera.FOV2 - client_camera.FOV ) ) / client_camera.FOV_duration ) * ( cg.time - client_camera.FOV_time );
- }
- CG_CalcFOVFromX( actualFOV_X );
- }
- else
- {
- CG_CalcFOVFromX( client_camera.FOV );
+ CG_CalcFOVFromX(actualFOV_X);
+ } else {
+ CG_CalcFOVFromX(client_camera.FOV);
}
- //Check for roffing angles
- if ( (client_camera.info_state & CAMERA_ROFFING) && !(client_camera.info_state & CAMERA_FOLLOWING) )
- {
- if (client_camera.info_state & CAMERA_CUT)
- {
+ // Check for roffing angles
+ if ((client_camera.info_state & CAMERA_ROFFING) && !(client_camera.info_state & CAMERA_FOLLOWING)) {
+ if (client_camera.info_state & CAMERA_CUT) {
// we're doing a cut, so just go to the new angles. none of this hifalutin lerping business.
- for ( i = 0; i < 3; i++ )
- {
- cg.refdefViewAngles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) );
+ for (i = 0; i < 3; i++) {
+ cg.refdefViewAngles[i] = AngleNormalize360((client_camera.angles[i] + client_camera.angles2[i]));
}
- }
- else
- {
- for ( i = 0; i < 3; i++ )
- {
- cg.refdefViewAngles[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( cg.time - client_camera.pan_time );
+ } else {
+ for (i = 0; i < 3; i++) {
+ cg.refdefViewAngles[i] = client_camera.angles[i] + (client_camera.angles2[i] / client_camera.pan_duration) * (cg.time - client_camera.pan_time);
}
}
- }
- else if ( client_camera.info_state & CAMERA_PANNING )
- {
- if (client_camera.info_state & CAMERA_CUT)
- {
+ } else if (client_camera.info_state & CAMERA_PANNING) {
+ if (client_camera.info_state & CAMERA_CUT) {
// we're doing a cut, so just go to the new angles. none of this hifalutin lerping business.
- for ( i = 0; i < 3; i++ )
- {
- cg.refdefViewAngles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) );
+ for (i = 0; i < 3; i++) {
+ cg.refdefViewAngles[i] = AngleNormalize360((client_camera.angles[i] + client_camera.angles2[i]));
}
- }
- else
- {
- //Note: does not actually change the camera's angles until the pan time is done!
- if ( client_camera.pan_time + client_camera.pan_duration < cg.time )
- {//finished panning
- for ( i = 0; i < 3; i++ )
- {
- client_camera.angles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) );
+ } else {
+ // Note: does not actually change the camera's angles until the pan time is done!
+ if (client_camera.pan_time + client_camera.pan_duration < cg.time) { // finished panning
+ for (i = 0; i < 3; i++) {
+ client_camera.angles[i] = AngleNormalize360((client_camera.angles[i] + client_camera.angles2[i]));
}
client_camera.info_state &= ~CAMERA_PANNING;
- VectorCopy(client_camera.angles, cg.refdefViewAngles );
- }
- else
- {//still panning
- for ( i = 0; i < 3; i++ )
- {
- //NOTE: does not store the resultant angle in client_camera.angles until pan is done
- cg.refdefViewAngles[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( cg.time - client_camera.pan_time );
+ VectorCopy(client_camera.angles, cg.refdefViewAngles);
+ } else { // still panning
+ for (i = 0; i < 3; i++) {
+ // NOTE: does not store the resultant angle in client_camera.angles until pan is done
+ cg.refdefViewAngles[i] =
+ client_camera.angles[i] + (client_camera.angles2[i] / client_camera.pan_duration) * (cg.time - client_camera.pan_time);
}
}
}
- }
- else
- {
+ } else {
checkFollow = qtrue;
}
- //Check for movement
- if ( client_camera.info_state & CAMERA_MOVING )
- {
- //NOTE: does not actually move the camera until the movement time is done!
- if ( client_camera.move_time + client_camera.move_duration < cg.time )
- {
- VectorCopy( client_camera.origin2, client_camera.origin );
+ // Check for movement
+ if (client_camera.info_state & CAMERA_MOVING) {
+ // NOTE: does not actually move the camera until the movement time is done!
+ if (client_camera.move_time + client_camera.move_duration < cg.time) {
+ VectorCopy(client_camera.origin2, client_camera.origin);
client_camera.info_state &= ~CAMERA_MOVING;
- VectorCopy( client_camera.origin, cg.refdef.vieworg );
- }
- else
- {
- if (client_camera.info_state & CAMERA_CUT)
- {
+ VectorCopy(client_camera.origin, cg.refdef.vieworg);
+ } else {
+ if (client_camera.info_state & CAMERA_CUT) {
// we're doing a cut, so just go to the new origin. none of this fancypants lerping stuff.
- for ( i = 0; i < 3; i++ )
- {
+ for (i = 0; i < 3; i++) {
cg.refdef.vieworg[i] = client_camera.origin2[i];
}
- }
- else
- {
- for ( i = 0; i < 3; i++ )
- {
- cg.refdef.vieworg[i] = client_camera.origin[i] + (( ( client_camera.origin2[i] - client_camera.origin[i] ) ) / client_camera.move_duration ) * ( cg.time - client_camera.move_time );
+ } else {
+ for (i = 0; i < 3; i++) {
+ cg.refdef.vieworg[i] = client_camera.origin[i] + (((client_camera.origin2[i] - client_camera.origin[i])) / client_camera.move_duration) *
+ (cg.time - client_camera.move_time);
}
}
}
- }
- else
- {
+ } else {
checkTrack = qtrue;
}
- if ( checkFollow )
- {
- if ( client_camera.info_state & CAMERA_FOLLOWING )
- {//This needs to be done after camera movement
+ if (checkFollow) {
+ if (client_camera.info_state & CAMERA_FOLLOWING) { // This needs to be done after camera movement
CGCam_FollowUpdate();
}
- VectorCopy(client_camera.angles, cg.refdefViewAngles );
+ VectorCopy(client_camera.angles, cg.refdefViewAngles);
}
- if ( checkTrack )
- {
- if ( client_camera.info_state & CAMERA_TRACKING )
- {//This has to run AFTER Follow if the camera is following a cameraGroup
+ if (checkTrack) {
+ if (client_camera.info_state & CAMERA_TRACKING) { // This has to run AFTER Follow if the camera is following a cameraGroup
CGCam_TrackUpdate();
}
- VectorCopy( client_camera.origin, cg.refdef.vieworg );
+ VectorCopy(client_camera.origin, cg.refdef.vieworg);
}
- //Bar fading
- if ( client_camera.info_state & CAMERA_BAR_FADING )
- {
+ // Bar fading
+ if (client_camera.info_state & CAMERA_BAR_FADING) {
CGCam_UpdateBarFade();
}
- //Normal fading - separate call because can finish after camera is disabled
+ // Normal fading - separate call because can finish after camera is disabled
CGCam_UpdateFade();
- //Update shaking if there's any
- //CGCam_UpdateSmooth( cg.refdef.vieworg, cg.refdefViewAngles );
- CGCam_UpdateShake( cg.refdef.vieworg, cg.refdefViewAngles );
- AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
+ // Update shaking if there's any
+ // CGCam_UpdateSmooth( cg.refdef.vieworg, cg.refdefViewAngles );
+ CGCam_UpdateShake(cg.refdef.vieworg, cg.refdefViewAngles);
+ AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
}
/*
@@ -1313,27 +1101,25 @@ CGCam_DrawWideScreen
-------------------------
*/
-void CGCam_DrawWideScreen( void )
-{
- vec4_t modulate;
+void CGCam_DrawWideScreen(void) {
+ vec4_t modulate;
- //Only draw if visible
- if ( client_camera.bar_alpha )
- {
+ // Only draw if visible
+ if (client_camera.bar_alpha) {
CGCam_UpdateBarFade();
modulate[0] = modulate[1] = modulate[2] = 0.0f;
modulate[3] = client_camera.bar_alpha;
- CG_FillRect( cg.refdef.x, cg.refdef.y, 640, client_camera.bar_height, modulate );
- CG_FillRect( cg.refdef.x, cg.refdef.y + 480 - client_camera.bar_height, 640, client_camera.bar_height, modulate );
+ CG_FillRect(cg.refdef.x, cg.refdef.y, 640, client_camera.bar_height, modulate);
+ CG_FillRect(cg.refdef.x, cg.refdef.y + 480 - client_camera.bar_height, 640, client_camera.bar_height, modulate);
}
- //NOTENOTE: Camera always draws the fades unless the alpha is 0
- if ( client_camera.fade_color[3] == 0.0f )
+ // NOTENOTE: Camera always draws the fades unless the alpha is 0
+ if (client_camera.fade_color[3] == 0.0f)
return;
- CG_FillRect( cg.refdef.x, cg.refdef.y, 640, 480, client_camera.fade_color );
+ CG_FillRect(cg.refdef.x, cg.refdef.y, 640, 480, client_camera.fade_color);
}
/*
@@ -1341,8 +1127,7 @@ void CGCam_DrawWideScreen( void )
CGCam_RenderScene
-------------------------
*/
-void CGCam_RenderScene( void )
-{
+void CGCam_RenderScene(void) {
CGCam_Update();
CG_CalcVrect();
}
@@ -1353,9 +1138,8 @@ CGCam_Shake
-------------------------
*/
-void CGCam_Shake( float intensity, int duration )
-{
- if ( intensity > MAX_SHAKE_INTENSITY )
+void CGCam_Shake(float intensity, int duration) {
+ if (intensity > MAX_SHAKE_INTENSITY)
intensity = MAX_SHAKE_INTENSITY;
client_camera.shake_intensity = intensity;
@@ -1371,51 +1155,47 @@ This doesn't actually affect the camera's info, but passed information instead
-------------------------
*/
-void CGCam_UpdateShake( vec3_t origin, vec3_t angles )
-{
- vec3_t moveDir;
- float intensity_scale, intensity;
+void CGCam_UpdateShake(vec3_t origin, vec3_t angles) {
+ vec3_t moveDir;
+ float intensity_scale, intensity;
- if ( client_camera.shake_duration <= 0 )
+ if (client_camera.shake_duration <= 0)
return;
- if ( cg.time > ( client_camera.shake_start + client_camera.shake_duration ) )
- {
+ if (cg.time > (client_camera.shake_start + client_camera.shake_duration)) {
client_camera.shake_intensity = 0;
client_camera.shake_duration = 0;
client_camera.shake_start = 0;
return;
}
- //intensity_scale now also takes into account FOV with 90.0 as normal
- intensity_scale = 1.0f - ( (float) ( cg.time - client_camera.shake_start ) / (float) client_camera.shake_duration ) * (((client_camera.FOV+client_camera.FOV2)/2.0f)/90.0f);
+ // intensity_scale now also takes into account FOV with 90.0 as normal
+ intensity_scale = 1.0f - ((float)(cg.time - client_camera.shake_start) / (float)client_camera.shake_duration) *
+ (((client_camera.FOV + client_camera.FOV2) / 2.0f) / 90.0f);
intensity = client_camera.shake_intensity * intensity_scale;
- for ( int i = 0; i < 3; i++ )
- {
- moveDir[i] = ( Q_flrand(-1.0f, 1.0f) * intensity );
+ for (int i = 0; i < 3; i++) {
+ moveDir[i] = (Q_flrand(-1.0f, 1.0f) * intensity);
}
- //FIXME: Lerp
+ // FIXME: Lerp
- //Move the camera
- VectorAdd( origin, moveDir, origin );
+ // Move the camera
+ VectorAdd(origin, moveDir, origin);
- for ( int i = 0; i < 2; i++ ) // Don't do ROLL
- moveDir[i] = ( Q_flrand(-1.0f, 1.0f) * intensity );
+ for (int i = 0; i < 2; i++) // Don't do ROLL
+ moveDir[i] = (Q_flrand(-1.0f, 1.0f) * intensity);
- //FIXME: Lerp
+ // FIXME: Lerp
- //Move the angles
- VectorAdd( angles, moveDir, angles );
+ // Move the angles
+ VectorAdd(angles, moveDir, angles);
}
-void CGCam_Smooth( float intensity, int duration )
-{
- client_camera.smooth_active=false; // means smooth_origin and angles are valid
- if ( intensity>1.0f||intensity==0.0f||duration<1)
- {
+void CGCam_Smooth(float intensity, int duration) {
+ client_camera.smooth_active = false; // means smooth_origin and angles are valid
+ if (intensity > 1.0f || intensity == 0.0f || duration < 1) {
client_camera.info_state &= ~CAMERA_SMOOTHING;
return;
}
@@ -1425,80 +1205,65 @@ void CGCam_Smooth( float intensity, int duration )
client_camera.smooth_start = cg.time;
}
-void CGCam_UpdateSmooth( vec3_t origin, vec3_t angles )
-{
- if (!(client_camera.info_state&CAMERA_SMOOTHING)||cg.time > ( client_camera.smooth_start + client_camera.smooth_duration ))
- {
+void CGCam_UpdateSmooth(vec3_t origin, vec3_t angles) {
+ if (!(client_camera.info_state & CAMERA_SMOOTHING) || cg.time > (client_camera.smooth_start + client_camera.smooth_duration)) {
client_camera.info_state &= ~CAMERA_SMOOTHING;
return;
}
- if (!client_camera.smooth_active)
- {
- client_camera.smooth_active=true;
- VectorCopy(origin,client_camera.smooth_origin);
+ if (!client_camera.smooth_active) {
+ client_camera.smooth_active = true;
+ VectorCopy(origin, client_camera.smooth_origin);
return;
}
- float factor=client_camera.smooth_intensity;
- if (client_camera.smooth_duration>200&&cg.time > ( client_camera.smooth_start + client_camera.smooth_duration-100 ))
- {
- factor+=(1.0f-client_camera.smooth_intensity)*
- (100.0f-(client_camera.smooth_start + client_camera.smooth_duration-cg.time))/100.0f;
+ float factor = client_camera.smooth_intensity;
+ if (client_camera.smooth_duration > 200 && cg.time > (client_camera.smooth_start + client_camera.smooth_duration - 100)) {
+ factor += (1.0f - client_camera.smooth_intensity) * (100.0f - (client_camera.smooth_start + client_camera.smooth_duration - cg.time)) / 100.0f;
}
int i;
- for (i=0;i<3;i++)
- {
- client_camera.smooth_origin[i]*=(1.0f-factor);
- client_camera.smooth_origin[i]+=factor*origin[i];
- origin[i]=client_camera.smooth_origin[i];
+ for (i = 0; i < 3; i++) {
+ client_camera.smooth_origin[i] *= (1.0f - factor);
+ client_camera.smooth_origin[i] += factor * origin[i];
+ origin[i] = client_camera.smooth_origin[i];
}
}
-void CGCam_NotetrackProcessFov(const char *addlArg)
-{
+void CGCam_NotetrackProcessFov(const char *addlArg) {
int a = 0;
char t[64];
- if (!addlArg || !addlArg[0])
- {
+ if (!addlArg || !addlArg[0]) {
Com_Printf("camera roff 'fov' notetrack missing fov argument\n", addlArg);
return;
}
- if (isdigit(addlArg[a]))
- {
+ if (isdigit(addlArg[a])) {
// "fov "
int d = 0, tsize = 64;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && d < tsize) {
t[d++] = addlArg[a++];
}
// now the contents of t represent our desired fov
float newFov = atof(t);
#ifndef FINAL_BUILD
- if (cg_roffdebug.integer)
- {
- if (fabs(cg_roffval1.value) > 0.001f)
- {
+ if (cg_roffdebug.integer) {
+ if (fabs(cg_roffval1.value) > 0.001f) {
newFov = cg_roffval1.value;
}
}
#endif
- if (cg_roffdebug.integer)
- {
+ if (cg_roffdebug.integer) {
Com_Printf("notetrack: 'fov %2.2f' on frame %d\n", newFov, client_camera.roff_frame);
}
CGCam_Zoom(newFov, 0);
}
}
-void CGCam_NotetrackProcessFovZoom(const char *addlArg)
-{
- int a = 0;
- float beginFOV = 0, endFOV = 0, fovTime = 0;
+void CGCam_NotetrackProcessFovZoom(const char *addlArg) {
+ int a = 0;
+ float beginFOV = 0, endFOV = 0, fovTime = 0;
- if (!addlArg || !addlArg[0])
- {
+ if (!addlArg || !addlArg[0]) {
Com_Printf("camera roff 'fovzoom' notetrack missing arguments\n", addlArg);
return;
}
@@ -1508,96 +1273,75 @@ void CGCam_NotetrackProcessFovZoom(const char *addlArg)
char t[64];
int d = 0, tsize = 64;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
- if (!isdigit(t[0]))
- {
+ if (!isdigit(t[0])) {
// assume a non-number here means we should start from our current fov
beginFOV = client_camera.FOV;
- }
- else
- {
+ } else {
// now the contents of t represent our beginning fov
beginFOV = atof(t);
}
// eat leading whitespace
- while (addlArg[a] && addlArg[a] == ' ')
- {
+ while (addlArg[a] && addlArg[a] == ' ') {
a++;
}
- if (addlArg[a])
- {
+ if (addlArg[a]) {
d = 0;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
// now the contents of t represent our end fov
endFOV = atof(t);
// eat leading whitespace
- while (addlArg[a] && addlArg[a] == ' ')
- {
+ while (addlArg[a] && addlArg[a] == ' ') {
a++;
}
- if (addlArg[a])
- {
+ if (addlArg[a]) {
d = 0;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
// now the contents of t represent our time
fovTime = atof(t);
- }
- else
- {
+ } else {
Com_Printf("camera roff 'fovzoom' notetrack missing 'time' argument\n", addlArg);
return;
}
#ifndef FINAL_BUILD
- if (cg_roffdebug.integer)
- {
- if (fabs(cg_roffval1.value) > 0.001f)
- {
+ if (cg_roffdebug.integer) {
+ if (fabs(cg_roffval1.value) > 0.001f) {
beginFOV = cg_roffval1.value;
}
- if (fabs(cg_roffval2.value) > 0.001f)
- {
+ if (fabs(cg_roffval2.value) > 0.001f) {
endFOV = cg_roffval2.value;
}
- if (fabs(cg_roffval3.value) > 0.001f)
- {
+ if (fabs(cg_roffval3.value) > 0.001f) {
fovTime = cg_roffval3.value;
}
}
#endif
- if (cg_roffdebug.integer)
- {
+ if (cg_roffdebug.integer) {
Com_Printf("notetrack: 'fovzoom %2.2f %2.2f %5.1f' on frame %d\n", beginFOV, endFOV, fovTime, client_camera.roff_frame);
}
CGCam_Zoom2(beginFOV, endFOV, fovTime);
- }
- else
- {
+ } else {
Com_Printf("camera roff 'fovzoom' notetrack missing 'end fov' argument\n", addlArg);
return;
}
}
-void CGCam_NotetrackProcessFovAccel(const char *addlArg)
-{
- int a = 0;
- float beginFOV = 0, fovDelta = 0, fovDelta2 = 0, fovTime = 0;
+void CGCam_NotetrackProcessFovAccel(const char *addlArg) {
+ int a = 0;
+ float beginFOV = 0, fovDelta = 0, fovDelta2 = 0, fovTime = 0;
- if (!addlArg || !addlArg[0])
- {
+ if (!addlArg || !addlArg[0]) {
Com_Printf("camera roff 'fovaccel' notetrack missing arguments\n", addlArg);
return;
}
@@ -1608,149 +1352,124 @@ void CGCam_NotetrackProcessFovAccel(const char *addlArg)
char t[64];
int d = 0, tsize = 64;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
- if (!isdigit(t[0]))
- {
+ if (!isdigit(t[0])) {
// assume a non-number here means we should start from our current fov
beginFOV = client_camera.FOV;
- }
- else
- {
+ } else {
// now the contents of t represent our beginning fov
beginFOV = atof(t);
}
// eat leading whitespace
- while (addlArg[a] && addlArg[a] == ' ')
- {
+ while (addlArg[a] && addlArg[a] == ' ') {
a++;
}
- if (addlArg[a])
- {
+ if (addlArg[a]) {
d = 0;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
// now the contents of t represent our delta
fovDelta = atof(t);
// eat leading whitespace
- while (addlArg[a] && addlArg[a] == ' ')
- {
+ while (addlArg[a] && addlArg[a] == ' ') {
a++;
}
- if (addlArg[a])
- {
+ if (addlArg[a]) {
d = 0;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
// now the contents of t represent our fovDelta2
fovDelta2 = atof(t);
// eat leading whitespace
- while (addlArg[a] && addlArg[a] == ' ')
- {
+ while (addlArg[a] && addlArg[a] == ' ') {
a++;
}
- if (addlArg[a])
- {
+ if (addlArg[a]) {
d = 0;
- memset(t, 0, tsize*sizeof(char));
- while (addlArg[a] && !isspace(addlArg[a]) && d < tsize)
- {
+ memset(t, 0, tsize * sizeof(char));
+ while (addlArg[a] && !isspace(addlArg[a]) && d < tsize) {
t[d++] = addlArg[a++];
}
// now the contents of t represent our time
fovTime = atof(t);
- }
- else
- {
+ } else {
Com_Printf("camera roff 'fovaccel' notetrack missing 'time' argument\n", addlArg);
return;
}
- if (cg_roffdebug.integer)
- {
+ if (cg_roffdebug.integer) {
Com_Printf("notetrack: 'fovaccel %2.2f %3.5f %3.5f %d' on frame %d\n", beginFOV, fovDelta, fovDelta2, fovTime, client_camera.roff_frame);
}
CGCam_ZoomAccel(beginFOV, fovDelta, fovDelta2, fovTime);
- }
- else
- {
+ } else {
Com_Printf("camera roff 'fovaccel' notetrack missing 'delta2' argument\n", addlArg);
return;
}
- }
- else
- {
+ } else {
Com_Printf("camera roff 'fovaccel' notetrack missing 'delta' argument\n", addlArg);
return;
}
}
// 3/18/03 kef -- blatantly thieved from G_RoffNotetrackCallback
-static void CG_RoffNotetrackCallback(const char *notetrack)
-{
+static void CG_RoffNotetrackCallback(const char *notetrack) {
int i = 0, r = 0;
char type[256];
-// char argument[512];
+ // char argument[512];
char addlArg[512];
int addlArgs = 0;
- if (!notetrack)
- {
+ if (!notetrack) {
return;
}
- //notetrack = "fov 65";
+ // notetrack = "fov 65";
- while (notetrack[i] && notetrack[i] != ' ')
- {
+ while (notetrack[i] && notetrack[i] != ' ') {
type[i] = notetrack[i];
i++;
}
type[i] = '\0';
- //if (notetrack[i] != ' ')
+ // if (notetrack[i] != ' ')
//{ //didn't pass in a valid notetrack type, or forgot the argument for it
// return;
- //}
+ // }
-/* i++;
+ /* i++;
- while (notetrack[i] && notetrack[i] != ' ')
- {
- if (notetrack[i] != '\n' && notetrack[i] != '\r')
- { //don't read line ends for an argument
- argument[r] = notetrack[i];
- r++;
+ while (notetrack[i] && notetrack[i] != ' ')
+ {
+ if (notetrack[i] != '\n' && notetrack[i] != '\r')
+ { //don't read line ends for an argument
+ argument[r] = notetrack[i];
+ r++;
+ }
+ i++;
}
- i++;
- }
- argument[r] = '\0';
- if (!r)
- {
- return;
- }
-*/
+ argument[r] = '\0';
+ if (!r)
+ {
+ return;
+ }
+ */
- if (notetrack[i] == ' ')
- { //additional arguments...
+ if (notetrack[i] == ' ') { // additional arguments...
addlArgs = 1;
i++;
r = 0;
- while (notetrack[i])
- {
+ while (notetrack[i]) {
addlArg[r] = notetrack[i];
r++;
i++;
@@ -1758,42 +1477,30 @@ static void CG_RoffNotetrackCallback(const char *notetrack)
addlArg[r] = '\0';
}
- if (strcmp(type, "cut") == 0)
- {
+ if (strcmp(type, "cut") == 0) {
client_camera.info_state |= CAMERA_CUT;
- if (cg_roffdebug.integer)
- {
+ if (cg_roffdebug.integer) {
Com_Printf("notetrack: 'cut' on frame %d\n", client_camera.roff_frame);
}
// this is just a really hacky way of getting a cut and a fov command on the same frame
- if (addlArgs)
- {
+ if (addlArgs) {
CG_RoffNotetrackCallback(addlArg);
}
- }
- else if (strcmp(type, "fov") == 0)
- {
- if (addlArgs)
- {
+ } else if (strcmp(type, "fov") == 0) {
+ if (addlArgs) {
CGCam_NotetrackProcessFov(addlArg);
return;
}
Com_Printf("camera roff 'fov' notetrack missing fov argument\n", addlArg);
- }
- else if (strcmp(type, "fovzoom") == 0)
- {
- if (addlArgs)
- {
+ } else if (strcmp(type, "fovzoom") == 0) {
+ if (addlArgs) {
CGCam_NotetrackProcessFovZoom(addlArg);
return;
}
Com_Printf("camera roff 'fovzoom' notetrack missing 'begin fov' argument\n", addlArg);
- }
- else if (strcmp(type, "fovaccel") == 0)
- {
- if (addlArgs)
- {
+ } else if (strcmp(type, "fovaccel") == 0) {
+ if (addlArgs) {
CGCam_NotetrackProcessFovAccel(addlArg);
return;
}
@@ -1810,8 +1517,7 @@ a rof file
-------------------------
*/
-void CGCam_StartRoff( char *roff )
-{
+void CGCam_StartRoff(char *roff) {
CGCam_FollowDisable();
CGCam_TrackDisable();
@@ -1820,18 +1526,17 @@ void CGCam_StartRoff( char *roff )
client_camera.info_state |= CAMERA_MOVING;
client_camera.info_state |= CAMERA_PANNING;
- if ( !G_LoadRoff( roff ) )
- {
+ if (!G_LoadRoff(roff)) {
// The load failed so don't turn on the roff playback...
- Com_Printf( S_COLOR_RED"ROFF camera playback failed\n" );
+ Com_Printf(S_COLOR_RED "ROFF camera playback failed\n");
return;
};
client_camera.info_state |= CAMERA_ROFFING;
- Q_strncpyz(client_camera.sRoff,roff,sizeof(client_camera.sRoff));
+ Q_strncpyz(client_camera.sRoff, roff, sizeof(client_camera.sRoff));
client_camera.roff_frame = 0;
- client_camera.next_roff_time = cg.time; // I can work right away
+ client_camera.next_roff_time = cg.time; // I can work right away
}
/*
@@ -1842,8 +1547,7 @@ Stops camera rof
-------------------------
*/
-static void CGCam_StopRoff( void )
-{
+static void CGCam_StopRoff(void) {
// Clear the roff flag
client_camera.info_state &= ~CAMERA_ROFFING;
client_camera.info_state &= ~CAMERA_MOVING;
@@ -1861,96 +1565,81 @@ so often...or maybe I'm just on crack.
------------------------------------------------------
*/
-static void CGCam_Roff( void )
-{
- while ( client_camera.next_roff_time <= cg.time )
- {
- // Make sure that the roff is cached
- const int roff_id = G_LoadRoff( client_camera.sRoff );
+static void CGCam_Roff(void) {
+ while (client_camera.next_roff_time <= cg.time) {
+ // Make sure that the roff is cached
+ const int roff_id = G_LoadRoff(client_camera.sRoff);
- if ( !roff_id )
- {
- return;
- }
+ if (!roff_id) {
+ return;
+ }
- // The ID is one higher than the array index
- const roff_list_t *roff = &roffs[ roff_id - 1 ];
- vec3_t org, ang;
+ // The ID is one higher than the array index
+ const roff_list_t *roff = &roffs[roff_id - 1];
+ vec3_t org, ang;
- if ( roff->type == 2 )
- {
- move_rotate2_t *data = &((move_rotate2_t *)roff->data)[ client_camera.roff_frame ];
- VectorCopy( data->origin_delta, org );
- VectorCopy( data->rotate_delta, ang );
+ if (roff->type == 2) {
+ move_rotate2_t *data = &((move_rotate2_t *)roff->data)[client_camera.roff_frame];
+ VectorCopy(data->origin_delta, org);
+ VectorCopy(data->rotate_delta, ang);
- // since we just hit a new frame, clear our CUT flag
- client_camera.info_state &= ~CAMERA_CUT;
+ // since we just hit a new frame, clear our CUT flag
+ client_camera.info_state &= ~CAMERA_CUT;
- if (data->mStartNote != -1 || data->mNumNotes)
- {
- CG_RoffNotetrackCallback(roffs[roff_id - 1].mNoteTrackIndexes[data->mStartNote]);
+ if (data->mStartNote != -1 || data->mNumNotes) {
+ CG_RoffNotetrackCallback(roffs[roff_id - 1].mNoteTrackIndexes[data->mStartNote]);
+ }
+ } else {
+ move_rotate_t *data = &((move_rotate_t *)roff->data)[client_camera.roff_frame];
+ VectorCopy(data->origin_delta, org);
+ VectorCopy(data->rotate_delta, ang);
}
- }
- else
- {
- move_rotate_t *data = &((move_rotate_t *)roff->data)[ client_camera.roff_frame ];
- VectorCopy( data->origin_delta, org );
- VectorCopy( data->rotate_delta, ang );
- }
- // Yeah, um, I guess this just has to be negated?
- //ang[PITCH] =- ang[PITCH];
- ang[ROLL] = -ang[ROLL];
- // might need to to yaw as well. need a test...
+ // Yeah, um, I guess this just has to be negated?
+ // ang[PITCH] =- ang[PITCH];
+ ang[ROLL] = -ang[ROLL];
+ // might need to to yaw as well. need a test...
- if ( cg_developer.integer )
- {
- Com_Printf( S_COLOR_GREEN"CamROFF: frame: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n",
- client_camera.roff_frame,
- org[0], org[1], org[2],
- ang[0], ang[1], ang[2] );
- }
+ if (cg_developer.integer) {
+ Com_Printf(S_COLOR_GREEN "CamROFF: frame: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", client_camera.roff_frame, org[0], org[1], org[2], ang[0],
+ ang[1], ang[2]);
+ }
- if ( client_camera.roff_frame )
- {
- // Don't mess with angles if we are following
- if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
- {
- VectorAdd( client_camera.angles, client_camera.angles2, client_camera.angles );
+ if (client_camera.roff_frame) {
+ // Don't mess with angles if we are following
+ if (!(client_camera.info_state & CAMERA_FOLLOWING)) {
+ VectorAdd(client_camera.angles, client_camera.angles2, client_camera.angles);
+ }
+
+ VectorCopy(client_camera.origin2, client_camera.origin);
}
- VectorCopy( client_camera.origin2, client_camera.origin );
- }
+ // Don't mess with angles if we are following
+ if (!(client_camera.info_state & CAMERA_FOLLOWING)) {
+ VectorCopy(ang, client_camera.angles2);
+ client_camera.pan_time = cg.time;
+ client_camera.pan_duration = roff->mFrameTime;
+ }
- // Don't mess with angles if we are following
- if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
- {
- VectorCopy( ang, client_camera.angles2 );
- client_camera.pan_time = cg.time;
- client_camera.pan_duration = roff->mFrameTime;
- }
+ VectorAdd(client_camera.origin, org, client_camera.origin2);
- VectorAdd( client_camera.origin, org, client_camera.origin2 );
+ client_camera.move_time = cg.time;
+ client_camera.move_duration = roff->mFrameTime;
- client_camera.move_time = cg.time;
- client_camera.move_duration = roff->mFrameTime;
+ if (++client_camera.roff_frame >= roff->frames) {
+ CGCam_StopRoff();
+ return;
+ }
- if ( ++client_camera.roff_frame >= roff->frames )
- {
- CGCam_StopRoff();
- return;
+ // Check back in frameTime to get the next roff entry
+ client_camera.next_roff_time += roff->mFrameTime;
}
-
- // Check back in frameTime to get the next roff entry
- client_camera.next_roff_time += roff->mFrameTime;
- }
}
-void CMD_CGCam_Disable( void )
-{
- vec4_t fade = {0, 0, 0, 0};
+void CMD_CGCam_Disable(void) {
+ vec4_t fade = {0, 0, 0, 0};
CGCam_Disable();
- CGCam_SetFade( fade );
+ CGCam_SetFade(fade);
player_locked = qfalse;
}
diff --git a/code/cgame/cg_consolecmds.cpp b/code/cgame/cg_consolecmds.cpp
index eb4b79a7aa..40da97e486 100644
--- a/code/cgame/cg_consolecmds.cpp
+++ b/code/cgame/cg_consolecmds.cpp
@@ -26,15 +26,15 @@ along with this program; if not, see .
#include "cg_headers.h"
-#include "cg_media.h" //just for cgs....
+#include "cg_media.h" //just for cgs....
-void CG_TargetCommand_f( void );
-extern qboolean player_locked;
-extern void CMD_CGCam_Disable( void );
-void CG_NextInventory_f( void );
-void CG_PrevInventory_f( void );
-void CG_NextForcePower_f( void );
-void CG_PrevForcePower_f( void );
+void CG_TargetCommand_f(void);
+extern qboolean player_locked;
+extern void CMD_CGCam_Disable(void);
+void CG_NextInventory_f(void);
+void CG_PrevInventory_f(void);
+void CG_NextForcePower_f(void);
+void CG_PrevForcePower_f(void);
/*
=================
@@ -42,17 +42,17 @@ CG_TargetCommand_f
=================
*/
-void CG_TargetCommand_f( void ) {
- int targetNum;
- char test[4];
+void CG_TargetCommand_f(void) {
+ int targetNum;
+ char test[4];
targetNum = CG_CrosshairPlayer();
- if ( targetNum == -1 ) {
+ if (targetNum == -1) {
return;
}
- cgi_Argv( 1, test, 4 );
- cgi_SendClientCommand( va( "gc %i %i", targetNum, atoi( test ) ) );
+ cgi_Argv(1, test, 4);
+ cgi_SendClientCommand(va("gc %i %i", targetNum, atoi(test)));
}
/*
@@ -62,56 +62,50 @@ CG_Viewpos_f
Debugging command to print the current position
=============
*/
-static void CG_Viewpos_f (void) {
- CG_Printf ("%s (%i %i %i) : %i\n", cgs.mapname, (int)cg.refdef.vieworg[0],
- (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2],
- (int)cg.refdefViewAngles[YAW]);
+static void CG_Viewpos_f(void) {
+ CG_Printf("%s (%i %i %i) : %i\n", cgs.mapname, (int)cg.refdef.vieworg[0], (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2],
+ (int)cg.refdefViewAngles[YAW]);
}
-void CG_WriteCam_f (void)
-{
- char text[1024];
- const char *targetname;
- static int numCams;
+void CG_WriteCam_f(void) {
+ char text[1024];
+ const char *targetname;
+ static int numCams;
numCams++;
targetname = CG_Argv(1);
- if( !targetname || !targetname[0] )
- {
+ if (!targetname || !targetname[0]) {
targetname = "nameme!";
}
- CG_Printf( "Camera #%d ('%s') written to: ", numCams, targetname );
- Com_sprintf( text, sizeof(text), "//entity %d\n{\n\"classname\" \"ref_tag\"\n\"targetname\" \"%s\"\n\"origin\" \"%i %i %i\"\n\"angles\" \"%i %i %i\"\n\"fov\" \"%i\"\n}\n", numCams, targetname, (int)cg.refdef.vieworg[0], (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], (int)cg.refdefViewAngles[0], (int)cg.refdefViewAngles[1], (int)cg.refdefViewAngles[2], cg_fov.integer );
- gi.WriteCam( text );
+ CG_Printf("Camera #%d ('%s') written to: ", numCams, targetname);
+ Com_sprintf(text, sizeof(text),
+ "//entity %d\n{\n\"classname\" \"ref_tag\"\n\"targetname\" \"%s\"\n\"origin\" \"%i %i %i\"\n\"angles\" \"%i %i %i\"\n\"fov\" \"%i\"\n}\n",
+ numCams, targetname, (int)cg.refdef.vieworg[0], (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], (int)cg.refdefViewAngles[0],
+ (int)cg.refdefViewAngles[1], (int)cg.refdefViewAngles[2], cg_fov.integer);
+ gi.WriteCam(text);
}
-void Lock_Disable ( void )
-{
- player_locked = qfalse;
-}
+void Lock_Disable(void) { player_locked = qfalse; }
-extern float cg_zoomFov; //from cg_view.cpp
+extern float cg_zoomFov; // from cg_view.cpp
-void CG_ToggleBinoculars( void )
-{
- if ( in_camera || !cg.snap )
- {
+void CG_ToggleBinoculars(void) {
+ if (in_camera || !cg.snap) {
return;
}
- if ( cg.zoomMode == 0 || cg.zoomMode >= 2 ) // not zoomed or currently zoomed with the disruptor or LA goggles
+ if (cg.zoomMode == 0 || cg.zoomMode >= 2) // not zoomed or currently zoomed with the disruptor or LA goggles
{
- if ( (cg.snap->ps.saber[0].Active() && cg.snap->ps.saberInFlight) || cg.snap->ps.stats[STAT_HEALTH] <= 0)
- {//can't select binoculars when throwing saber
- //FIXME: indicate this to the player
+ if ((cg.snap->ps.saber[0].Active() && cg.snap->ps.saberInFlight) || cg.snap->ps.stats[STAT_HEALTH] <= 0) { // can't select binoculars when throwing
+ // saber
+ // FIXME: indicate this to the player
return;
}
- if ( cg.snap->ps.viewEntity || ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & ( EF_LOCKED_TO_WEAPON | EF_IN_ATST )))
- {
+ if (cg.snap->ps.viewEntity || (cg_entities[cg.snap->ps.clientNum].currentState.eFlags & (EF_LOCKED_TO_WEAPON | EF_IN_ATST))) {
// can't zoom when you have a viewEntity or driving an atst or in an emplaced gun
return;
}
@@ -119,142 +113,123 @@ void CG_ToggleBinoculars( void )
cg.zoomMode = 1;
cg.zoomLocked = qfalse;
- if ( cg.weaponSelect == WP_SABER )
- {
+ if (cg.weaponSelect == WP_SABER) {
cg.weaponSelect = WP_NONE;
}
- if ( cg.snap->ps.batteryCharge )
- {
+ if (cg.snap->ps.batteryCharge) {
// when you have batteries, you can actually zoom in
cg_zoomFov = 40.0f;
- }
- else if ( cg.overrides.active & CG_OVERRIDE_FOV )
- {
+ } else if (cg.overrides.active & CG_OVERRIDE_FOV) {
cg_zoomFov = cg.overrides.fov;
- }
- else
- {
+ } else {
cg_zoomFov = cg_fov.value;
}
- cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomStart );
- }
- else
- {
+ cgi_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomStart);
+ } else {
cg.zoomMode = 0;
cg.zoomTime = cg.time;
- cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd );
+ cgi_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd);
- if( cg.weaponSelect == WP_NONE && cg.snap->ps.stats[STAT_WEAPONS] & ( 1 << WP_SABER ) )
- {
+ if (cg.weaponSelect == WP_NONE && cg.snap->ps.stats[STAT_WEAPONS] & (1 << WP_SABER)) {
// FIXME: this is pretty damn ugly but whatever
cg.weaponSelect = WP_SABER;
}
}
}
-void CG_ToggleLAGoggles( void )
-{
- if ( in_camera || !cg.snap)
- {
+void CG_ToggleLAGoggles(void) {
+ if (in_camera || !cg.snap) {
return;
}
- if ( cg.zoomMode == 0 || cg.zoomMode < 3 ) // not zoomed or currently zoomed with the disruptor or regular binoculars
+ if (cg.zoomMode == 0 || cg.zoomMode < 3) // not zoomed or currently zoomed with the disruptor or regular binoculars
{
- if ( (cg.snap->ps.saber[0].Active() && cg.snap->ps.saberInFlight) || cg.snap->ps.stats[STAT_HEALTH] <= 0 )
- {//can't select binoculars when throwing saber
- //FIXME: indicate this to the player
+ if ((cg.snap->ps.saber[0].Active() && cg.snap->ps.saberInFlight) || cg.snap->ps.stats[STAT_HEALTH] <= 0) { // can't select binoculars when throwing
+ // saber
+ // FIXME: indicate this to the player
return;
}
- if ( cg.snap->ps.viewEntity || ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & ( EF_LOCKED_TO_WEAPON | EF_IN_ATST )))
- {
+ if (cg.snap->ps.viewEntity || (cg_entities[cg.snap->ps.clientNum].currentState.eFlags & (EF_LOCKED_TO_WEAPON | EF_IN_ATST))) {
// can't zoom when you have a viewEntity or driving an atst or in an emplaced gun
return;
}
cg.zoomMode = 3;
cg.zoomLocked = qfalse;
- if ( cg.overrides.active & CG_OVERRIDE_FOV )
- {
+ if (cg.overrides.active & CG_OVERRIDE_FOV) {
cg_zoomFov = cg.overrides.fov;
- }
- else
- {
+ } else {
cg_zoomFov = cg_fov.value; // does not zoom!!
}
- cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomStart );
- }
- else
- {
+ cgi_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomStart);
+ } else {
cg.zoomMode = 0;
cg.zoomTime = cg.time;
- cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd );
+ cgi_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd);
}
}
-void CG_LoadHud_f( void ) {
+void CG_LoadHud_f(void) {
const char *hudSet = cg_hudFiles.string;
- if ( hudSet[0] == '\0' ) {
+ if (hudSet[0] == '\0') {
hudSet = "ui/jahud.txt";
}
- //cgi_UI_String_Init();
- //cgi_UI_Menu_Reset();
- CG_LoadMenus( hudSet );
+ // cgi_UI_String_Init();
+ // cgi_UI_Menu_Reset();
+ CG_LoadMenus(hudSet);
}
typedef struct {
- const char *cmd;
- void (*func)(void);
+ const char *cmd;
+ void (*func)(void);
} consoleCommand_t;
-int cmdcmp( const void *a, const void *b ) {
- return Q_stricmp( (const char *)a, ((consoleCommand_t*)b)->cmd );
-}
+int cmdcmp(const void *a, const void *b) { return Q_stricmp((const char *)a, ((consoleCommand_t *)b)->cmd); }
/* This array MUST be sorted correctly by alphabetical name field */
-static consoleCommand_t commands[] = {
- { "cam_disable", CMD_CGCam_Disable }, //gets out of camera mode for debuggin
- { "cam_enable", CGCam_Enable }, //gets into camera mode for precise camera placement
- { "dpforcenext", CG_DPNextForcePower_f },
- { "dpforceprev", CG_DPPrevForcePower_f },
- { "dpinvnext", CG_DPNextInventory_f },
- { "dpinvprev", CG_DPPrevInventory_f },
- { "dpweapnext", CG_DPNextWeapon_f },
- { "dpweapprev", CG_DPPrevWeapon_f },
- { "forcenext", CG_NextForcePower_f },
- { "forceprev", CG_PrevForcePower_f },
- { "invnext", CG_NextInventory_f },
- { "invprev", CG_PrevInventory_f },
- { "la_zoom", CG_ToggleLAGoggles },
- { "loadhud", CG_LoadHud_f },
- { "lock_disable", Lock_Disable }, //player can move now
- { "nextframe", CG_TestModelNextFrame_f },
- { "nextskin", CG_TestModelNextSkin_f },
- { "prevframe", CG_TestModelPrevFrame_f },
- { "prevskin", CG_TestModelPrevSkin_f },
- { "tcmd", CG_TargetCommand_f },
- { "testG2Model", CG_TestG2Model_f},
- { "testanglespost", CG_TestModelSetAnglespost_f},
- { "testanglespre", CG_TestModelSetAnglespre_f},
- { "testanimate", CG_TestModelAnimate_f},
- { "testlistbones", CG_ListModelBones_f},
- { "testlistsurfaces", CG_ListModelSurfaces_f},
- { "testmodel", CG_TestModel_f },
- { "testsurface", CG_TestModelSurfaceOnOff_f },
- { "viewpos", CG_Viewpos_f },
- { "weapnext", CG_NextWeapon_f },
- { "weapon", CG_Weapon_f },
- { "weapprev", CG_PrevWeapon_f },
- { "writecam", CG_WriteCam_f },
- { "zoom", CG_ToggleBinoculars },
+static consoleCommand_t commands[] = {
+ {"cam_disable", CMD_CGCam_Disable}, // gets out of camera mode for debuggin
+ {"cam_enable", CGCam_Enable}, // gets into camera mode for precise camera placement
+ {"dpforcenext", CG_DPNextForcePower_f},
+ {"dpforceprev", CG_DPPrevForcePower_f},
+ {"dpinvnext", CG_DPNextInventory_f},
+ {"dpinvprev", CG_DPPrevInventory_f},
+ {"dpweapnext", CG_DPNextWeapon_f},
+ {"dpweapprev", CG_DPPrevWeapon_f},
+ {"forcenext", CG_NextForcePower_f},
+ {"forceprev", CG_PrevForcePower_f},
+ {"invnext", CG_NextInventory_f},
+ {"invprev", CG_PrevInventory_f},
+ {"la_zoom", CG_ToggleLAGoggles},
+ {"loadhud", CG_LoadHud_f},
+ {"lock_disable", Lock_Disable}, // player can move now
+ {"nextframe", CG_TestModelNextFrame_f},
+ {"nextskin", CG_TestModelNextSkin_f},
+ {"prevframe", CG_TestModelPrevFrame_f},
+ {"prevskin", CG_TestModelPrevSkin_f},
+ {"tcmd", CG_TargetCommand_f},
+ {"testG2Model", CG_TestG2Model_f},
+ {"testanglespost", CG_TestModelSetAnglespost_f},
+ {"testanglespre", CG_TestModelSetAnglespre_f},
+ {"testanimate", CG_TestModelAnimate_f},
+ {"testlistbones", CG_ListModelBones_f},
+ {"testlistsurfaces", CG_ListModelSurfaces_f},
+ {"testmodel", CG_TestModel_f},
+ {"testsurface", CG_TestModelSurfaceOnOff_f},
+ {"viewpos", CG_Viewpos_f},
+ {"weapnext", CG_NextWeapon_f},
+ {"weapon", CG_Weapon_f},
+ {"weapprev", CG_PrevWeapon_f},
+ {"writecam", CG_WriteCam_f},
+ {"zoom", CG_ToggleBinoculars},
};
-static const size_t numCommands = ARRAY_LEN( commands );
+static const size_t numCommands = ARRAY_LEN(commands);
/*
=================
@@ -264,66 +239,64 @@ The string has been tokenized and can be retrieved with
Cmd_Argc() / Cmd_Argv()
=================
*/
-qboolean CG_ConsoleCommand( void ) {
- consoleCommand_t *command = NULL;
+qboolean CG_ConsoleCommand(void) {
+ consoleCommand_t *command = NULL;
- command = (consoleCommand_t *)Q_LinearSearch( CG_Argv( 0 ), commands, numCommands, sizeof( commands[0] ), cmdcmp );
+ command = (consoleCommand_t *)Q_LinearSearch(CG_Argv(0), commands, numCommands, sizeof(commands[0]), cmdcmp);
- if ( !command )
+ if (!command)
return qfalse;
command->func();
return qtrue;
}
-static const char *gcmds[] = {
- "bow",
- "entitylist",
- "difficulty",
- "flourish",
- "force_absorb",
- "force_distract",
- "force_grip",
- "force_heal",
- "force_protect",
- "force_pull",
- "force_rage",
- "force_sight",
- "force_speed",
- "force_throw",
- "give",
- "gloat",
- "god",
- "invuse",
- "kill",
- "meditate",
- "nav",
- "noclip",
- "notarget",
- "npc",
- "playermodel",
- "playerteam",
- "playertint",
- "runscript",
- "saber",
- "saberAttackCycle",
- "saberColor",
- "saberblade",
- "secrets",
- "setForceAll",
- "setSaberAll",
- "setobjective",
- "setviewpos",
- "taunt",
- "undying",
- "use_bacta",
- "use_electrobinoculars",
- "use_lightamp_goggles",
- "use_seeker",
- "use_sentry",
- "viewobjective"
-};
-static const size_t numgcmds = ARRAY_LEN( gcmds );
+static const char *gcmds[] = {"bow",
+ "entitylist",
+ "difficulty",
+ "flourish",
+ "force_absorb",
+ "force_distract",
+ "force_grip",
+ "force_heal",
+ "force_protect",
+ "force_pull",
+ "force_rage",
+ "force_sight",
+ "force_speed",
+ "force_throw",
+ "give",
+ "gloat",
+ "god",
+ "invuse",
+ "kill",
+ "meditate",
+ "nav",
+ "noclip",
+ "notarget",
+ "npc",
+ "playermodel",
+ "playerteam",
+ "playertint",
+ "runscript",
+ "saber",
+ "saberAttackCycle",
+ "saberColor",
+ "saberblade",
+ "secrets",
+ "setForceAll",
+ "setSaberAll",
+ "setobjective",
+ "setviewpos",
+ "taunt",
+ "undying",
+ "use_bacta",
+ "use_electrobinoculars",
+ "use_lightamp_goggles",
+ "use_seeker",
+ "use_sentry",
+ "viewobjective"};
+static const size_t numgcmds = ARRAY_LEN(gcmds);
/*
=================
@@ -333,16 +306,16 @@ Let the client system know about all of our commands
so it can perform tab completion
=================
*/
-void CG_InitConsoleCommands( void ) {
+void CG_InitConsoleCommands(void) {
size_t i;
- for ( i = 0 ; i < numCommands ; i++ )
- cgi_AddCommand( commands[i].cmd );
+ for (i = 0; i < numCommands; i++)
+ cgi_AddCommand(commands[i].cmd);
//
// the game server will interpret these commands, which will be automatically
// forwarded to the server after they are not recognized locally
//
- for( i = 0; i < numgcmds; i++ )
- cgi_AddCommand( gcmds[i] );
+ for (i = 0; i < numgcmds; i++)
+ cgi_AddCommand(gcmds[i]);
}
diff --git a/code/cgame/cg_credits.cpp b/code/cgame/cg_credits.cpp
index 68ff647634..eb54866dd1 100644
--- a/code/cgame/cg_credits.cpp
+++ b/code/cgame/cg_credits.cpp
@@ -28,10 +28,9 @@ along with this program; if not, see .
#include "cg_media.h"
-#define fCARD_FADESECONDS 1.0f // fade up time, also fade down time
-#define fCARD_SUSTAINSECONDS 2.0f // hold time before fade down
-#define fLINE_SECONDTOSCROLLUP 15.0f // how long one line takes to scroll up the screen
-
+#define fCARD_FADESECONDS 1.0f // fade up time, also fade down time
+#define fCARD_SUSTAINSECONDS 2.0f // hold time before fade down
+#define fLINE_SECONDTOSCROLLUP 15.0f // how long one line takes to scroll up the screen
#define MAX_LINE_BYTES 2048
@@ -39,97 +38,76 @@ qhandle_t ghFontHandle = 0;
float gfFontScale = 1.0f;
vec4_t gv4Color = {0};
-struct StringAndSize_t
-{
+struct StringAndSize_t {
int iStrLenPixels;
std::string str;
- StringAndSize_t()
- {
+ StringAndSize_t() {
iStrLenPixels = -1;
str = "";
}
- StringAndSize_t(const char *psString)
- {
+ StringAndSize_t(const char *psString) {
iStrLenPixels = -1;
str = psString;
}
- StringAndSize_t & operator = (const char *psString)
- {
+ StringAndSize_t &operator=(const char *psString) {
iStrLenPixels = -1;
str = psString;
return *this;
}
- const char *c_str(void)
- {
- return str.c_str();
- }
+ const char *c_str(void) { return str.c_str(); }
- int GetPixelLength(void)
- {
- if (iStrLenPixels == -1)
- {
+ int GetPixelLength(void) {
+ if (iStrLenPixels == -1) {
iStrLenPixels = cgi_R_Font_StrLenPixels(str.c_str(), ghFontHandle, gfFontScale);
}
return iStrLenPixels;
}
- bool IsEmpty(void)
- {
- return str.empty();
- }
+ bool IsEmpty(void) { return str.empty(); }
};
-struct CreditCard_t
-{
- int iTime;
- StringAndSize_t strTitle;
+struct CreditCard_t {
+ int iTime;
+ StringAndSize_t strTitle;
std::vector vstrText;
- CreditCard_t()
- {
- iTime = -1; // flag "not set yet"
+ CreditCard_t() {
+ iTime = -1; // flag "not set yet"
}
};
-struct CreditLine_t
-{
- int iLine;
- StringAndSize_t strText;
+struct CreditLine_t {
+ int iLine;
+ StringAndSize_t strText;
std::vector vstrText;
- bool bDotted;
+ bool bDotted;
};
-typedef std::list CreditLines_t;
-typedef std::list CreditCards_t;
+typedef std::list CreditLines_t;
+typedef std::list CreditCards_t;
-struct CreditData_t
-{
- int iStartTime;
+struct CreditData_t {
+ int iStartTime;
CreditCards_t CreditCards;
CreditLines_t CreditLines;
- qboolean Running(void)
- {
- return (qboolean)( CreditCards.size() || CreditLines.size() );
- }
+ qboolean Running(void) { return (qboolean)(CreditCards.size() || CreditLines.size()); }
};
CreditData_t CreditData;
-
-static const char *Capitalize(const char *psTest)
-{
+static const char *Capitalize(const char *psTest) {
static char sTemp[MAX_LINE_BYTES];
Q_strncpyz(sTemp, psTest, sizeof(sTemp));
-// if (!cgi_Language_IsAsian()) // we don't have asian credits, so this is ok to do now
+ // if (!cgi_Language_IsAsian()) // we don't have asian credits, so this is ok to do now
{
- Q_strupr(sTemp); // capitalise titles (if not asian!!!!)
+ Q_strupr(sTemp); // capitalise titles (if not asian!!!!)
}
return sTemp;
@@ -137,71 +115,62 @@ static const char *Capitalize(const char *psTest)
// cope with hyphenated names and initials (awkward gits)...
//
-static bool CountsAsWhiteSpaceForCaps( unsigned /* avoid euro-char sign-extend assert within isspace()*/char c )
-{
- return !!(isspace(c) || c == '-' || c == '.' || c == '(' || c == ')' || c=='\'');
+static bool CountsAsWhiteSpaceForCaps(unsigned /* avoid euro-char sign-extend assert within isspace()*/ char c) {
+ return !!(isspace(c) || c == '-' || c == '.' || c == '(' || c == ')' || c == '\'');
}
-static const char *UpperCaseFirstLettersOnly(const char *psTest)
-{
+static const char *UpperCaseFirstLettersOnly(const char *psTest) {
static char sTemp[MAX_LINE_BYTES];
Q_strncpyz(sTemp, psTest, sizeof(sTemp));
-// if (!cgi_Language_IsAsian()) // we don't have asian credits, so this is ok to do now
+ // if (!cgi_Language_IsAsian()) // we don't have asian credits, so this is ok to do now
{
Q_strlwr(sTemp);
char *p = sTemp;
- while (*p)
- {
- while (*p && CountsAsWhiteSpaceForCaps(*p)) p++;
- if (*p)
- {
+ while (*p) {
+ while (*p && CountsAsWhiteSpaceForCaps(*p))
+ p++;
+ if (*p) {
*p = toupper(*p);
- while (*p && !CountsAsWhiteSpaceForCaps(*p)) p++;
+ while (*p && !CountsAsWhiteSpaceForCaps(*p))
+ p++;
}
}
}
// now restore any weird stuff...
//
- char *p = strstr(sTemp," Mc"); // eg "Mcfarrell" should be "McFarrell"
- if (p && isalpha(p[3]))
- {
+ char *p = strstr(sTemp, " Mc"); // eg "Mcfarrell" should be "McFarrell"
+ if (p && isalpha(p[3])) {
p[3] = toupper(p[3]);
}
- p = strstr(sTemp," O'"); // eg "O'flaherty" should be "O'Flaherty" (this is probably done automatically now, but wtf.
- if (p && isalpha(p[3]))
- {
+ p = strstr(sTemp, " O'"); // eg "O'flaherty" should be "O'Flaherty" (this is probably done automatically now, but wtf.
+ if (p && isalpha(p[3])) {
p[3] = toupper(p[3]);
}
- p = strstr(sTemp,"Lucasarts");
- if (p)
- {
- p[5] = 'A'; // capitalise the 'A' in LucasArts (jeez...)
+ p = strstr(sTemp, "Lucasarts");
+ if (p) {
+ p[5] = 'A'; // capitalise the 'A' in LucasArts (jeez...)
}
return sTemp;
}
-static const char *GetSubString(std::string &strResult)
-{
+static const char *GetSubString(std::string &strResult) {
static char sTemp[MAX_LINE_BYTES];
if (!strlen(strResult.c_str()))
return NULL;
- Q_strncpyz(sTemp,strResult.c_str(),sizeof(sTemp));
+ Q_strncpyz(sTemp, strResult.c_str(), sizeof(sTemp));
- char *psSemiColon = strchr(sTemp,';');
- if ( psSemiColon)
- {
- *psSemiColon = '\0';
+ char *psSemiColon = strchr(sTemp, ';');
+ if (psSemiColon) {
+ *psSemiColon = '\0';
- strResult.erase(0,(psSemiColon-sTemp)+1);
- }
- else
- {
+ strResult.erase(0, (psSemiColon - sTemp) + 1);
+ } else {
// no semicolon found, probably last entry? (though i think even those have them on, oh well)
//
strResult.erase();
@@ -212,28 +181,21 @@ static const char *GetSubString(std::string &strResult)
// sort entries by their last name (starts at back of string and moves forward until start or just before whitespace)
// ...
-static bool SortBySurname(const StringAndSize_t &str1, const StringAndSize_t &str2)
-{
+static bool SortBySurname(const StringAndSize_t &str1, const StringAndSize_t &str2) {
std::string::const_reverse_iterator rstart1 = std::find_if(str1.str.rbegin(), str1.str.rend(), isspace);
std::string::const_reverse_iterator rstart2 = std::find_if(str2.str.rbegin(), str2.str.rend(), isspace);
-
return Q_stricmp(&*rstart1.base(), &*rstart2.base()) < 0;
}
-
-
-void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
-{
+void CG_Credits_Init(const char *psStripReference, vec4_t *pv4Color) {
// Play the light side end credits music.
- if ( g_entities[0].client->sess.mission_objectives[0].status != 2 )
- {
- cgi_S_StartBackgroundTrack( "music/endcredits.mp3", NULL, qfalse );
+ if (g_entities[0].client->sess.mission_objectives[0].status != 2) {
+ cgi_S_StartBackgroundTrack("music/endcredits.mp3", NULL, qfalse);
}
// Play the dark side end credits music.
- else
- {
- cgi_S_StartBackgroundTrack( "music/vjun3/vjun3_explore.mp3", NULL, qfalse );
+ else {
+ cgi_S_StartBackgroundTrack("music/vjun3/vjun3_explore.mp3", NULL, qfalse);
}
// could make these into parameters later, but for now...
@@ -241,13 +203,12 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
ghFontHandle = cgs.media.qhFontMedium;
gfFontScale = 1.0f;
- memcpy(gv4Color,pv4Color,sizeof(gv4Color)); // memcpy so we can poke into alpha channel
+ memcpy(gv4Color, pv4Color, sizeof(gv4Color)); // memcpy so we can poke into alpha channel
// first, ask the strlen of the final string...
//
- int iStrLen = cgi_SP_GetStringTextString( psStripReference, NULL, 0 );
- if (!iStrLen)
- {
+ int iStrLen = cgi_SP_GetStringTextString(psStripReference, NULL, 0);
+ if (!iStrLen) {
#ifndef FINAL_BUILD
Com_Printf("WARNING: CG_Credits_Init(): invalid text key :'%s'\n", psStripReference);
#endif
@@ -256,15 +217,14 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
//
// malloc space to hold it...
//
- char *psMallocText = (char *) cgi_Z_Malloc( iStrLen+1, TAG_TEMP_WORKSPACE );
+ char *psMallocText = (char *)cgi_Z_Malloc(iStrLen + 1, TAG_TEMP_WORKSPACE);
//
// now get the string...
//
- iStrLen = cgi_SP_GetStringTextString( psStripReference, psMallocText, iStrLen+1 );
- //ensure we found a match
- if (!iStrLen)
- {
- assert(0); // should never get here now, but wtf?
+ iStrLen = cgi_SP_GetStringTextString(psStripReference, psMallocText, iStrLen + 1);
+ // ensure we found a match
+ if (!iStrLen) {
+ assert(0); // should never get here now, but wtf?
cgi_Z_Free(psMallocText);
#ifndef FINAL_BUILD
Com_Printf("WARNING: CG_Credits_Init(): invalid text key :'%s'\n", psStripReference);
@@ -274,8 +234,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
// read whole string in and process as cards, lines etc...
//
- typedef enum
- {
+ typedef enum {
eNothing = 0,
eLine,
eDotEntry,
@@ -288,15 +247,13 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
qboolean bCardsFinished = qfalse;
int iLineNumber = 0;
const char *psTextParse = psMallocText;
- while (*psTextParse != '\0')
- {
+ while (*psTextParse != '\0') {
// read a line...
//
char sLine[MAX_LINE_BYTES];
- sLine[0]='\0';
+ sLine[0] = '\0';
qboolean bWasCommand = qtrue;
- while (1)
- {
+ while (1) {
qboolean bIsTrailingPunctuation;
int iAdvanceCount;
unsigned int uiLetter = cgi_AnyLanguage_ReadCharFromString(psTextParse, &iAdvanceCount, &bIsTrailingPunctuation);
@@ -304,187 +261,142 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
// concat onto string so far...
//
- if (uiLetter == 32 && sLine[0] == '\0')
- {
- continue; // unless it's a space at the start of a line, in which case ignore it.
+ if (uiLetter == 32 && sLine[0] == '\0') {
+ continue; // unless it's a space at the start of a line, in which case ignore it.
}
- if (uiLetter == '\n' || uiLetter == '\0' )
- {
+ if (uiLetter == '\n' || uiLetter == '\0') {
// have we got a command word?...
//
- if (!Q_stricmpn(sLine,"(#",2))
- {
+ if (!Q_stricmpn(sLine, "(#", 2)) {
// yep...
//
- if (!Q_stricmp(sLine, "(#CARD)"))
- {
- if (!bCardsFinished)
- {
+ if (!Q_stricmp(sLine, "(#CARD)")) {
+ if (!bCardsFinished) {
eMode = eCard;
- }
- else
- {
- #ifndef FINAL_BUILD
- Com_Printf( S_COLOR_YELLOW "CG_Credits_Init(): No current support for cards after scroll!\n" );
- #endif
+ } else {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "CG_Credits_Init(): No current support for cards after scroll!\n");
+#endif
eMode = eNothing;
}
break;
- }
- else
- if (!Q_stricmp(sLine, "(#TITLE)"))
- {
+ } else if (!Q_stricmp(sLine, "(#TITLE)")) {
eMode = eTitle;
bCardsFinished = qtrue;
break;
- }
- else
- if (!Q_stricmp(sLine, "(#LINE)"))
- {
+ } else if (!Q_stricmp(sLine, "(#LINE)")) {
eMode = eLine;
bCardsFinished = qtrue;
break;
- }
- else
- if (!Q_stricmp(sLine, "(#DOTENTRY)"))
- {
+ } else if (!Q_stricmp(sLine, "(#DOTENTRY)")) {
eMode = eDotEntry;
bCardsFinished = qtrue;
break;
- }
- else
- {
- #ifndef FINAL_BUILD
- Com_Printf( S_COLOR_YELLOW "CG_Credits_Init(): bad keyword \"%s\"!\n", sLine );
- #endif
+ } else {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "CG_Credits_Init(): bad keyword \"%s\"!\n", sLine);
+#endif
eMode = eNothing;
}
- }
- else
- {
+ } else {
// I guess not...
//
bWasCommand = qfalse;
break;
}
- }
- else
- {
+ } else {
// must be a letter...
//
- if (uiLetter > 255)
- {
- assert(0); // this means we're attempting to display asian credits, and we don't
- // support these now because the auto-capitalisation rules etc would have to
- // be inhibited.
- Q_strcat(sLine, sizeof(sLine), va("%c%c",uiLetter >> 8, uiLetter & 0xFF));
- }
- else
- {
- Q_strcat(sLine, sizeof(sLine), va("%c",uiLetter & 0xFF));
+ if (uiLetter > 255) {
+ assert(0); // this means we're attempting to display asian credits, and we don't
+ // support these now because the auto-capitalisation rules etc would have to
+ // be inhibited.
+ Q_strcat(sLine, sizeof(sLine), va("%c%c", uiLetter >> 8, uiLetter & 0xFF));
+ } else {
+ Q_strcat(sLine, sizeof(sLine), va("%c", uiLetter & 0xFF));
}
}
}
// command?...
//
- if (bWasCommand)
- {
+ if (bWasCommand) {
// this'll just be a mode change, so ignore...
//
- }
- else
- {
+ } else {
// else we've got some text to display...
//
- switch (eMode)
- {
- case eNothing: break;
- case eLine:
- {
- CreditLine_t CreditLine;
- CreditLine.iLine = iLineNumber++;
- CreditLine.strText = sLine;
-
- CreditData.CreditLines.push_back( CreditLine );
- }
+ switch (eMode) {
+ case eNothing:
break;
-
- case eDotEntry:
- {
- CreditLine_t CreditLine;
- CreditLine.iLine = iLineNumber;
- CreditLine.bDotted = true;
-
- std::string strResult(sLine);
- const char *p;
- while ((p=GetSubString(strResult)) != NULL)
- {
- if (CreditLine.strText.IsEmpty())
- {
- CreditLine.strText = p;
- }
- else
- {
- CreditLine.vstrText.push_back( UpperCaseFirstLettersOnly(p) );
- }
+ case eLine: {
+ CreditLine_t CreditLine;
+ CreditLine.iLine = iLineNumber++;
+ CreditLine.strText = sLine;
+
+ CreditData.CreditLines.push_back(CreditLine);
+ } break;
+
+ case eDotEntry: {
+ CreditLine_t CreditLine;
+ CreditLine.iLine = iLineNumber;
+ CreditLine.bDotted = true;
+
+ std::string strResult(sLine);
+ const char *p;
+ while ((p = GetSubString(strResult)) != NULL) {
+ if (CreditLine.strText.IsEmpty()) {
+ CreditLine.strText = p;
+ } else {
+ CreditLine.vstrText.push_back(UpperCaseFirstLettersOnly(p));
}
+ }
- if (!CreditLine.strText.IsEmpty() && CreditLine.vstrText.size())
- {
- // sort entries RHS dotted entries by alpha...
- //
- std::sort( CreditLine.vstrText.begin(), CreditLine.vstrText.end(), SortBySurname );
+ if (!CreditLine.strText.IsEmpty() && CreditLine.vstrText.size()) {
+ // sort entries RHS dotted entries by alpha...
+ //
+ std::sort(CreditLine.vstrText.begin(), CreditLine.vstrText.end(), SortBySurname);
- CreditData.CreditLines.push_back( CreditLine );
- iLineNumber += CreditLine.vstrText.size();
- }
+ CreditData.CreditLines.push_back(CreditLine);
+ iLineNumber += CreditLine.vstrText.size();
}
- break;
+ } break;
- case eTitle:
- {
- iLineNumber++; // leading blank line
+ case eTitle: {
+ iLineNumber++; // leading blank line
- CreditLine_t CreditLine;
- CreditLine.iLine = iLineNumber++;
- CreditLine.strText = Capitalize(sLine);
+ CreditLine_t CreditLine;
+ CreditLine.iLine = iLineNumber++;
+ CreditLine.strText = Capitalize(sLine);
- CreditData.CreditLines.push_back( CreditLine );
+ CreditData.CreditLines.push_back(CreditLine);
- iLineNumber++; // trailing blank line
- break;
- }
- case eCard:
- {
- CreditCard_t CreditCard;
-
- std::string strResult(sLine);
- const char *p;
- while ((p=GetSubString(strResult)) != NULL)
- {
- if (CreditCard.strTitle.IsEmpty())
- {
- CreditCard.strTitle = Capitalize( p );
- }
- else
- {
- CreditCard.vstrText.push_back( UpperCaseFirstLettersOnly( p ) );
- }
+ iLineNumber++; // trailing blank line
+ break;
+ }
+ case eCard: {
+ CreditCard_t CreditCard;
+
+ std::string strResult(sLine);
+ const char *p;
+ while ((p = GetSubString(strResult)) != NULL) {
+ if (CreditCard.strTitle.IsEmpty()) {
+ CreditCard.strTitle = Capitalize(p);
+ } else {
+ CreditCard.vstrText.push_back(UpperCaseFirstLettersOnly(p));
}
+ }
- if (!CreditCard.strTitle.IsEmpty())
- {
- // sort entries by alpha...
- //
- std::sort( CreditCard.vstrText.begin(), CreditCard.vstrText.end(), SortBySurname );
+ if (!CreditCard.strTitle.IsEmpty()) {
+ // sort entries by alpha...
+ //
+ std::sort(CreditCard.vstrText.begin(), CreditCard.vstrText.end(), SortBySurname);
- CreditData.CreditCards.push_back(CreditCard);
- }
+ CreditData.CreditCards.push_back(CreditCard);
}
- break;
- default:
+ } break;
+ default:
break;
}
}
@@ -494,31 +406,24 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
CreditData.iStartTime = cg.time;
}
-qboolean CG_Credits_Running( void )
-{
- return CreditData.Running();
-}
+qboolean CG_Credits_Running(void) { return CreditData.Running(); }
// returns qtrue if still drawing...
//
-qboolean CG_Credits_Draw( void )
-{
- if ( CG_Credits_Running() )
- {
- const int iFontHeight = (int) (1.5f * (float) cgi_R_Font_HeightPixels(ghFontHandle, gfFontScale)); // taiwanese & japanese need 1.5 fontheight spacing
+qboolean CG_Credits_Draw(void) {
+ if (CG_Credits_Running()) {
+ const int iFontHeight = (int)(1.5f * (float)cgi_R_Font_HeightPixels(ghFontHandle, gfFontScale)); // taiwanese & japanese need 1.5 fontheight spacing
-// cgi_R_SetColor( *gpv4Color );
+ // cgi_R_SetColor( *gpv4Color );
// display cards first...
//
- if (CreditData.CreditCards.size())
- {
+ if (CreditData.CreditCards.size()) {
// grab first card off the list (we know there's at least one here, so...)
//
CreditCard_t &CreditCard = (*CreditData.CreditCards.begin());
- if (CreditCard.iTime == -1)
- {
+ if (CreditCard.iTime == -1) {
// onceonly time init...
//
CreditCard.iTime = cg.time;
@@ -527,65 +432,56 @@ qboolean CG_Credits_Draw( void )
// play with the alpha channel for fade up/down...
//
const float fMilliSecondsElapsed = cg.time - CreditCard.iTime;
- const float fSecondsElapsed = fMilliSecondsElapsed / 1000.0f;
- if (fSecondsElapsed < fCARD_FADESECONDS)
- {
+ const float fSecondsElapsed = fMilliSecondsElapsed / 1000.0f;
+ if (fSecondsElapsed < fCARD_FADESECONDS) {
// fading up...
//
gv4Color[3] = fSecondsElapsed / fCARD_FADESECONDS;
-// OutputDebugString(va("fade up: %f\n",gv4Color[3]));
- }
- else
- if (fSecondsElapsed > fCARD_FADESECONDS + fCARD_SUSTAINSECONDS)
- {
+ // OutputDebugString(va("fade up: %f\n",gv4Color[3]));
+ } else if (fSecondsElapsed > fCARD_FADESECONDS + fCARD_SUSTAINSECONDS) {
// fading down...
//
const float fFadeDownSeconds = fSecondsElapsed - (fCARD_FADESECONDS + fCARD_SUSTAINSECONDS);
gv4Color[3] = 1.0f - (fFadeDownSeconds / fCARD_FADESECONDS);
-// OutputDebugString(va("fade dw: %f\n",gv4Color[3]));
- }
- else
- {
+ // OutputDebugString(va("fade dw: %f\n",gv4Color[3]));
+ } else {
gv4Color[3] = 1.0f;
-// OutputDebugString(va("normal: %f\n",gv4Color[3]));
+ // OutputDebugString(va("normal: %f\n",gv4Color[3]));
}
if (gv4Color[3] < 0.0f)
- gv4Color[3] = 0.0f; // ... otherwise numbers that have dipped slightly -ve flash up fullbright after fade down
+ gv4Color[3] = 0.0f; // ... otherwise numbers that have dipped slightly -ve flash up fullbright after fade down
//
// how many lines is it?
//
- int iLines = CreditCard.vstrText.size() + 2; // +2 for title itself & one seperator line
+ int iLines = CreditCard.vstrText.size() + 2; // +2 for title itself & one seperator line
//
- int iYpos = (SCREEN_HEIGHT - (iLines * iFontHeight))/2;
+ int iYpos = (SCREEN_HEIGHT - (iLines * iFontHeight)) / 2;
//
// draw it, title first...
//
int iWidth = CreditCard.strTitle.GetPixelLength();
- int iXpos = (SCREEN_WIDTH - iWidth)/2;
+ int iXpos = (SCREEN_WIDTH - iWidth) / 2;
cgi_R_Font_DrawString(iXpos, iYpos, CreditCard.strTitle.c_str(), gv4Color, ghFontHandle, -1, gfFontScale);
//
- iYpos += iFontHeight*2; // skip blank line then move to main pos
+ iYpos += iFontHeight * 2; // skip blank line then move to main pos
//
- for (size_t i=0; i fCARD_FADESECONDS + fCARD_SUSTAINSECONDS + fCARD_FADESECONDS)
- {
+ if (fSecondsElapsed > fCARD_FADESECONDS + fCARD_SUSTAINSECONDS + fCARD_FADESECONDS) {
// yep, so erase the first entry (which will trigger the next one to be initialised on re-entry)...
//
- CreditData.CreditCards.erase( CreditData.CreditCards.begin() );
+ CreditData.CreditCards.erase(CreditData.CreditCards.begin());
- if (!CreditData.CreditCards.size())
- {
+ if (!CreditData.CreditCards.size()) {
// all cards gone, so re-init timer for lines...
//
CreditData.iStartTime = cg.time;
@@ -593,46 +489,38 @@ qboolean CG_Credits_Draw( void )
}
//
return qtrue;
- }
- else
- {
+ } else {
// doing scroll text...
//
- if (CreditData.CreditLines.size())
- {
+ if (CreditData.CreditLines.size()) {
// process all lines...
//
const float fMilliSecondsElapsed = cg.time - CreditData.iStartTime;
- const float fSecondsElapsed = fMilliSecondsElapsed / 1000.0f;
+ const float fSecondsElapsed = fMilliSecondsElapsed / 1000.0f;
bool bEraseOccured = false;
- for (CreditLines_t::iterator it = CreditData.CreditLines.begin(); it != CreditData.CreditLines.end(); bEraseOccured ? it : ++it)
- {
+ for (CreditLines_t::iterator it = CreditData.CreditLines.begin(); it != CreditData.CreditLines.end(); bEraseOccured ? it : ++it) {
CreditLine_t &CreditLine = (*it);
bEraseOccured = false;
static const float fPixelsPerSecond = ((float)SCREEN_HEIGHT / fLINE_SECONDTOSCROLLUP);
int iYpos = SCREEN_HEIGHT + (CreditLine.iLine * iFontHeight);
- iYpos-= (int) (fPixelsPerSecond * fSecondsElapsed);
+ iYpos -= (int)(fPixelsPerSecond * fSecondsElapsed);
- int iTextLinesThisItem = Q_max( (int)CreditLine.vstrText.size(), 1);
- if (iYpos + (iTextLinesThisItem * iFontHeight) < 0)
- {
+ int iTextLinesThisItem = Q_max((int)CreditLine.vstrText.size(), 1);
+ if (iYpos + (iTextLinesThisItem * iFontHeight) < 0) {
// scrolled off top of screen, so erase it...
//
- it = CreditData.CreditLines.erase( it );
+ it = CreditData.CreditLines.erase(it);
bEraseOccured = true;
- }
- else
- if (iYpos < SCREEN_HEIGHT)
- {
+ } else if (iYpos < SCREEN_HEIGHT) {
// onscreen, so print it...
//
- bool bIsDotted = !!CreditLine.vstrText.size(); // eg "STUNTS ...................... MR ED"
+ bool bIsDotted = !!CreditLine.vstrText.size(); // eg "STUNTS ...................... MR ED"
int iWidth = CreditLine.strText.GetPixelLength();
- int iXpos = bIsDotted ? 4 : (SCREEN_WIDTH - iWidth)/2;
+ int iXpos = bIsDotted ? 4 : (SCREEN_WIDTH - iWidth) / 2;
gv4Color[3] = 1.0f;
@@ -640,11 +528,10 @@ qboolean CG_Credits_Draw( void )
// now print any dotted members...
//
- for (size_t i=0; i.
#include "../game/objectives.h"
#include "../game/g_vehicles.h"
-extern vmCvar_t cg_debugHealthBars;
+extern vmCvar_t cg_debugHealthBars;
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
void CG_DrawIconBackground(void);
-void CG_DrawMissionInformation( void );
-void CG_DrawInventorySelect( void );
-void CG_DrawForceSelect( void );
+void CG_DrawMissionInformation(void);
+void CG_DrawInventorySelect(void);
+void CG_DrawForceSelect(void);
qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y);
qboolean CG_WorldCoordToScreenCoordFloat(vec3_t worldCoord, float *x, float *y);
@@ -52,13 +52,13 @@ extern int g_rocketLockEntNum;
extern int g_rocketLockTime;
extern int g_rocketSlackTime;
-vec3_t vfwd;
-vec3_t vright;
-vec3_t vup;
-vec3_t vfwd_n;
-vec3_t vright_n;
-vec3_t vup_n;
-int infoStringCount;
+vec3_t vfwd;
+vec3_t vright;
+vec3_t vup;
+vec3_t vfwd_n;
+vec3_t vright_n;
+vec3_t vup_n;
+int infoStringCount;
int cgRageTime = 0;
int cgRageFadeTime = 0;
@@ -77,22 +77,17 @@ int cgProtectFadeTime = 0;
float cgProtectFadeVal = 0;
//===============================================================
-
/*
================
CG_DrawMessageLit
================
*/
-static void CG_DrawMessageLit(centity_t *cent,int x,int y)
-{
+static void CG_DrawMessageLit(centity_t *cent, int x, int y) {
cgi_R_SetColor(colorTable[CT_WHITE]);
- if (cg.missionInfoFlashTime > cg.time )
- {
- if (!((cg.time / 600 ) & 1))
- {
- if (!cg.messageLitActive)
- {
+ if (cg.missionInfoFlashTime > cg.time) {
+ if (!((cg.time / 600) & 1)) {
+ if (!cg.messageLitActive) {
/*
kef 4/16/03 -- as fun as this was, its time has passed. I will, however, hijack this cvar at James'
@@ -107,17 +102,14 @@ static void CG_DrawMessageLit(centity_t *cent,int x,int y)
}
cgi_R_SetColor(colorTable[CT_HUD_RED]);
- CG_DrawPic( x + 33,y + 41, 16,16, cgs.media.messageLitOn);
- }
- else
- {
+ CG_DrawPic(x + 33, y + 41, 16, 16, cgs.media.messageLitOn);
+ } else {
cg.messageLitActive = qfalse;
}
}
cgi_R_SetColor(colorTable[CT_WHITE]);
- CG_DrawPic( x + 33,y + 41, 16,16, cgs.media.messageLitOff);
-
+ CG_DrawPic(x + 33, y + 41, 16, 16, cgs.media.messageLitOff);
}
/*
@@ -128,126 +120,90 @@ Draw the force power graphics (tics) and the force power numeric amount. Any tic
be alphaed out.
================
*/
-static void CG_DrawForcePower(const centity_t *cent,const int xPos,const int yPos)
-{
- int i;
- qboolean flash=qfalse;
- vec4_t calcColor;
- float value,extra=0,inc,percent;
+static void CG_DrawForcePower(const centity_t *cent, const int xPos, const int yPos) {
+ int i;
+ qboolean flash = qfalse;
+ vec4_t calcColor;
+ float value, extra = 0, inc, percent;
- if ( !cent->gent->client->ps.forcePowersKnown )
- {
+ if (!cent->gent->client->ps.forcePowersKnown) {
return;
}
// Make the hud flash by setting forceHUDTotalFlashTime above cg.time
- if (cg.forceHUDTotalFlashTime > cg.time )
- {
+ if (cg.forceHUDTotalFlashTime > cg.time) {
flash = qtrue;
- if (cg.forceHUDNextFlashTime < cg.time)
- {
+ if (cg.forceHUDNextFlashTime < cg.time) {
cg.forceHUDNextFlashTime = cg.time + 400;
- cgi_S_StartSound( NULL, 0, CHAN_AUTO, cgs.media.noforceSound );
- if (cg.forceHUDActive)
- {
+ cgi_S_StartSound(NULL, 0, CHAN_AUTO, cgs.media.noforceSound);
+ if (cg.forceHUDActive) {
cg.forceHUDActive = qfalse;
- }
- else
- {
+ } else {
cg.forceHUDActive = qtrue;
}
-
}
- }
- else // turn HUD back on if it had just finished flashing time.
+ } else // turn HUD back on if it had just finished flashing time.
{
cg.forceHUDNextFlashTime = 0;
cg.forceHUDActive = qtrue;
}
// I left the funtionality for flashing in because I might be needed yet.
-// if (!cg.forceHUDActive)
-// {
-// return;
-// }
+ // if (!cg.forceHUDActive)
+ // {
+ // return;
+ // }
- inc = (float) cent->gent->client->ps.forcePowerMax / MAX_HUD_TICS;
+ inc = (float)cent->gent->client->ps.forcePowerMax / MAX_HUD_TICS;
value = cent->gent->client->ps.forcePower;
- if ( value > cent->gent->client->ps.forcePowerMax )
- {//supercharged with force
+ if (value > cent->gent->client->ps.forcePowerMax) { // supercharged with force
extra = value - cent->gent->client->ps.forcePowerMax;
value = cent->gent->client->ps.forcePowerMax;
}
- for (i=MAX_HUD_TICS-1;i>=0;i--)
- {
- if ( extra )
- {//supercharged
+ for (i = MAX_HUD_TICS - 1; i >= 0; i--) {
+ if (extra) { // supercharged
memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
- percent = 0.75f + (sin( cg.time * 0.005f )*((extra/cent->gent->client->ps.forcePowerMax)*0.25f));
+ percent = 0.75f + (sin(cg.time * 0.005f) * ((extra / cent->gent->client->ps.forcePowerMax) * 0.25f));
calcColor[0] *= percent;
calcColor[1] *= percent;
calcColor[2] *= percent;
- }
- else if ( value <= 0 ) // no more
+ } else if (value <= 0) // no more
{
break;
- }
- else if (value < inc) // partial tic
+ } else if (value < inc) // partial tic
{
- if (flash)
- {
- memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t));
- }
- else
- {
- memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
+ if (flash) {
+ memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t));
+ } else {
+ memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
}
percent = value / inc;
calcColor[3] = percent;
- }
- else
- {
- if (flash)
- {
- memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t));
- }
- else
- {
- memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
+ } else {
+ if (flash) {
+ memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t));
+ } else {
+ memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
}
}
- cgi_R_SetColor( calcColor);
- CG_DrawPic( forceTics[i].xPos,
- forceTics[i].yPos,
- forceTics[i].width,
- forceTics[i].height,
- forceTics[i].background );
+ cgi_R_SetColor(calcColor);
+ CG_DrawPic(forceTics[i].xPos, forceTics[i].yPos, forceTics[i].width, forceTics[i].height, forceTics[i].background);
value -= inc;
}
- if (flash)
- {
- cgi_R_SetColor( colorTable[CT_RED] );
- }
- else
- {
- cgi_R_SetColor( otherHUDBits[OHB_FORCEAMOUNT].color );
+ if (flash) {
+ cgi_R_SetColor(colorTable[CT_RED]);
+ } else {
+ cgi_R_SetColor(otherHUDBits[OHB_FORCEAMOUNT].color);
}
// Print force numeric amount
- CG_DrawNumField (
- otherHUDBits[OHB_FORCEAMOUNT].xPos,
- otherHUDBits[OHB_FORCEAMOUNT].yPos,
- 3,
- cent->gent->client->ps.forcePower,
- otherHUDBits[OHB_FORCEAMOUNT].width,
- otherHUDBits[OHB_FORCEAMOUNT].height,
- NUM_FONT_SMALL,
- qfalse);
+ CG_DrawNumField(otherHUDBits[OHB_FORCEAMOUNT].xPos, otherHUDBits[OHB_FORCEAMOUNT].yPos, 3, cent->gent->client->ps.forcePower,
+ otherHUDBits[OHB_FORCEAMOUNT].width, otherHUDBits[OHB_FORCEAMOUNT].height, NUM_FONT_SMALL, qfalse);
}
/*
@@ -258,54 +214,36 @@ If the weapon is a light saber (which needs no ammo) then draw a graphic showing
the saber style (fast, medium, strong)
================
*/
-static void CG_DrawSaberStyle(const centity_t *cent,const int xPos,const int yPos)
-{
+static void CG_DrawSaberStyle(const centity_t *cent, const int xPos, const int yPos) {
int index;
- if (!cent->currentState.weapon ) // We don't have a weapon right now
+ if (!cent->currentState.weapon) // We don't have a weapon right now
{
return;
}
- if ( cent->currentState.weapon != WP_SABER || !cent->gent )
- {
+ if (cent->currentState.weapon != WP_SABER || !cent->gent) {
return;
}
- cgi_R_SetColor( colorTable[CT_WHITE] );
+ cgi_R_SetColor(colorTable[CT_WHITE]);
- if ( !cg.saberAnimLevelPending && cent->gent->client )
- {//uninitialized after a loadgame, cheat across and get it
+ if (!cg.saberAnimLevelPending && cent->gent->client) { // uninitialized after a loadgame, cheat across and get it
cg.saberAnimLevelPending = cent->gent->client->ps.saberAnimLevel;
}
// don't need to draw ammo, but we will draw the current saber style in this window
- if (cg.saberAnimLevelPending == SS_FAST
- || cg.saberAnimLevelPending == SS_TAVION )
- {
+ if (cg.saberAnimLevelPending == SS_FAST || cg.saberAnimLevelPending == SS_TAVION) {
index = OHB_SABERSTYLE_FAST;
- }
- else if (cg.saberAnimLevelPending == SS_MEDIUM
- || cg.saberAnimLevelPending == SS_DUAL
- || cg.saberAnimLevelPending == SS_STAFF )
- {
+ } else if (cg.saberAnimLevelPending == SS_MEDIUM || cg.saberAnimLevelPending == SS_DUAL || cg.saberAnimLevelPending == SS_STAFF) {
index = OHB_SABERSTYLE_MEDIUM;
- }
- else
- {
+ } else {
index = OHB_SABERSTYLE_STRONG;
}
- cgi_R_SetColor( otherHUDBits[index].color);
-
- CG_DrawPic(
- otherHUDBits[index].xPos,
- otherHUDBits[index].yPos,
- otherHUDBits[index].width,
- otherHUDBits[index].height,
- otherHUDBits[index].background
- );
+ cgi_R_SetColor(otherHUDBits[index].color);
+ CG_DrawPic(otherHUDBits[index].xPos, otherHUDBits[index].yPos, otherHUDBits[index].width, otherHUDBits[index].height, otherHUDBits[index].background);
}
/*
@@ -316,20 +254,18 @@ Draw the ammo graphics (tics) and the ammo numeric amount. Any tics that are par
be alphaed out.
================
*/
-static void CG_DrawAmmo(const centity_t *cent,const int xPos,const int yPos)
-{
- playerState_t *ps;
- int i;
- vec4_t calcColor;
- float currValue=0,inc;
+static void CG_DrawAmmo(const centity_t *cent, const int xPos, const int yPos) {
+ playerState_t *ps;
+ int i;
+ vec4_t calcColor;
+ float currValue = 0, inc;
- if (!cent->currentState.weapon ) // We don't have a weapon right now
+ if (!cent->currentState.weapon) // We don't have a weapon right now
{
return;
}
- if ( cent->currentState.weapon == WP_STUN_BATON )
- {
+ if (cent->currentState.weapon == WP_STUN_BATON) {
return;
}
@@ -337,154 +273,106 @@ static void CG_DrawAmmo(const centity_t *cent,const int xPos,const int yPos)
currValue = ps->ammo[weaponData[cent->currentState.weapon].ammoIndex];
- if (currValue < 0) // No ammo
+ if (currValue < 0) // No ammo
{
return;
}
-
//
// ammo
//
- if (cg.oldammo < currValue)
- {
+ if (cg.oldammo < currValue) {
cg.oldAmmoTime = cg.time + 200;
}
cg.oldammo = currValue;
-
// Determine the color of the numeric field
// Firing or reloading?
- if (( cg.predicted_player_state.weaponstate == WEAPON_FIRING
- && cg.predicted_player_state.weaponTime > 100 ))
- {
+ if ((cg.predicted_player_state.weaponstate == WEAPON_FIRING && cg.predicted_player_state.weaponTime > 100)) {
memcpy(calcColor, colorTable[CT_LTGREY], sizeof(vec4_t));
- }
- else
- {
- if ( currValue > 0 )
- {
- if (cg.oldAmmoTime > cg.time)
- {
+ } else {
+ if (currValue > 0) {
+ if (cg.oldAmmoTime > cg.time) {
memcpy(calcColor, colorTable[CT_YELLOW], sizeof(vec4_t));
- }
- else
- {
+ } else {
memcpy(calcColor, otherHUDBits[OHB_AMMOAMOUNT].color, sizeof(vec4_t));
}
- }
- else
- {
+ } else {
memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t));
}
}
// Print number amount
- cgi_R_SetColor( calcColor );
+ cgi_R_SetColor(calcColor);
- CG_DrawNumField (
- otherHUDBits[OHB_AMMOAMOUNT].xPos,
- otherHUDBits[OHB_AMMOAMOUNT].yPos,
- 3,
- ps->ammo[weaponData[cent->currentState.weapon].ammoIndex],
- otherHUDBits[OHB_AMMOAMOUNT].width,
- otherHUDBits[OHB_AMMOAMOUNT].height,
- NUM_FONT_SMALL,
- qfalse);
+ CG_DrawNumField(otherHUDBits[OHB_AMMOAMOUNT].xPos, otherHUDBits[OHB_AMMOAMOUNT].yPos, 3, ps->ammo[weaponData[cent->currentState.weapon].ammoIndex],
+ otherHUDBits[OHB_AMMOAMOUNT].width, otherHUDBits[OHB_AMMOAMOUNT].height, NUM_FONT_SMALL, qfalse);
-
-
- inc = (float) ammoData[weaponData[cent->currentState.weapon].ammoIndex].max / MAX_HUD_TICS;
- currValue =ps->ammo[weaponData[cent->currentState.weapon].ammoIndex];
+ inc = (float)ammoData[weaponData[cent->currentState.weapon].ammoIndex].max / MAX_HUD_TICS;
+ currValue = ps->ammo[weaponData[cent->currentState.weapon].ammoIndex];
memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
- for (i=MAX_HUD_TICS-1;i>=0;i--)
- {
+ for (i = MAX_HUD_TICS - 1; i >= 0; i--) {
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
memcpy(calcColor, ammoTics[i].color, sizeof(vec4_t));
float percent = currValue / inc;
calcColor[3] *= percent;
}
- cgi_R_SetColor( calcColor);
- CG_DrawPic( ammoTics[i].xPos,
- ammoTics[i].yPos,
- ammoTics[i].width,
- ammoTics[i].height,
- ammoTics[i].background );
+ cgi_R_SetColor(calcColor);
+ CG_DrawPic(ammoTics[i].xPos, ammoTics[i].yPos, ammoTics[i].width, ammoTics[i].height, ammoTics[i].background);
currValue -= inc;
}
-
}
-
/*
================
CG_DrawHealth
================
*/
-static void CG_DrawHealth(const int x,const int y,const int w,const int h)
-{
- vec4_t calcColor;
- playerState_t *ps = &cg.snap->ps;
+static void CG_DrawHealth(const int x, const int y, const int w, const int h) {
+ vec4_t calcColor;
+ playerState_t *ps = &cg.snap->ps;
// Print all the tics of the health graphic
// Look at the amount of health left and show only as much of the graphic as there is health.
// Use alpha to fade out partial section of health
- float inc = (float) ps->stats[STAT_MAX_HEALTH] / MAX_HUD_TICS;
+ float inc = (float)ps->stats[STAT_MAX_HEALTH] / MAX_HUD_TICS;
float currValue = ps->stats[STAT_HEALTH];
memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
int i;
- for (i=(MAX_HUD_TICS-1);i>=0;i--)
- {
+ for (i = (MAX_HUD_TICS - 1); i >= 0; i--) {
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
memcpy(calcColor, healthTics[i].color, sizeof(vec4_t));
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- CG_DrawPic(
- healthTics[i].xPos,
- healthTics[i].yPos,
- healthTics[i].width,
- healthTics[i].height,
- healthTics[i].background
- );
+ CG_DrawPic(healthTics[i].xPos, healthTics[i].yPos, healthTics[i].width, healthTics[i].height, healthTics[i].background);
currValue -= inc;
}
-
// Print force health amount
- cgi_R_SetColor( otherHUDBits[OHB_HEALTHAMOUNT].color );
-
- CG_DrawNumField (
- otherHUDBits[OHB_HEALTHAMOUNT].xPos,
- otherHUDBits[OHB_HEALTHAMOUNT].yPos,
- 3,
- ps->stats[STAT_HEALTH],
- otherHUDBits[OHB_HEALTHAMOUNT].width,
- otherHUDBits[OHB_HEALTHAMOUNT].height,
- NUM_FONT_SMALL,
- qfalse);
+ cgi_R_SetColor(otherHUDBits[OHB_HEALTHAMOUNT].color);
+ CG_DrawNumField(otherHUDBits[OHB_HEALTHAMOUNT].xPos, otherHUDBits[OHB_HEALTHAMOUNT].yPos, 3, ps->stats[STAT_HEALTH], otherHUDBits[OHB_HEALTHAMOUNT].width,
+ otherHUDBits[OHB_HEALTHAMOUNT].height, NUM_FONT_SMALL, qfalse);
}
/*
@@ -495,108 +383,74 @@ Draw the armor graphics (tics) and the armor numeric amount. Any tics that are p
be alphaed out.
================
*/
-static void CG_DrawArmor(const int x,const int y,const int w,const int h)
-{
- vec4_t calcColor;
- playerState_t *ps = &cg.snap->ps;
+static void CG_DrawArmor(const int x, const int y, const int w, const int h) {
+ vec4_t calcColor;
+ playerState_t *ps = &cg.snap->ps;
// Print all the tics of the armor graphic
// Look at the amount of armor left and show only as much of the graphic as there is armor.
// Use alpha to fade out partial section of armor
// MAX_HEALTH is the same thing as max armor
- float inc = (float) ps->stats[STAT_MAX_HEALTH] / MAX_HUD_TICS;
+ float inc = (float)ps->stats[STAT_MAX_HEALTH] / MAX_HUD_TICS;
float currValue = ps->stats[STAT_ARMOR];
memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
int i;
- for (i=(MAX_HUD_TICS-1);i>=0;i--)
- {
+ for (i = (MAX_HUD_TICS - 1); i >= 0; i--) {
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
memcpy(calcColor, armorTics[i].color, sizeof(vec4_t));
float percent = currValue / inc;
calcColor[3] *= percent;
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- if ((i==(MAX_HUD_TICS-1)) && (currValue < inc))
- {
- if (cg.HUDArmorFlag)
- {
- CG_DrawPic(
- armorTics[i].xPos,
- armorTics[i].yPos,
- armorTics[i].width,
- armorTics[i].height,
- armorTics[i].background
- );
+ if ((i == (MAX_HUD_TICS - 1)) && (currValue < inc)) {
+ if (cg.HUDArmorFlag) {
+ CG_DrawPic(armorTics[i].xPos, armorTics[i].yPos, armorTics[i].width, armorTics[i].height, armorTics[i].background);
}
- }
- else
- {
- CG_DrawPic(
- armorTics[i].xPos,
- armorTics[i].yPos,
- armorTics[i].width,
- armorTics[i].height,
- armorTics[i].background
- );
+ } else {
+ CG_DrawPic(armorTics[i].xPos, armorTics[i].yPos, armorTics[i].width, armorTics[i].height, armorTics[i].background);
}
currValue -= inc;
}
// Print armor amount
- cgi_R_SetColor( otherHUDBits[OHB_ARMORAMOUNT].color );
-
- CG_DrawNumField (
- otherHUDBits[OHB_ARMORAMOUNT].xPos,
- otherHUDBits[OHB_ARMORAMOUNT].yPos,
- 3,
- ps->stats[STAT_ARMOR],
- otherHUDBits[OHB_ARMORAMOUNT].width,
- otherHUDBits[OHB_ARMORAMOUNT].height,
- NUM_FONT_SMALL,
- qfalse);
+ cgi_R_SetColor(otherHUDBits[OHB_ARMORAMOUNT].color);
+ CG_DrawNumField(otherHUDBits[OHB_ARMORAMOUNT].xPos, otherHUDBits[OHB_ARMORAMOUNT].yPos, 3, ps->stats[STAT_ARMOR], otherHUDBits[OHB_ARMORAMOUNT].width,
+ otherHUDBits[OHB_ARMORAMOUNT].height, NUM_FONT_SMALL, qfalse);
// If armor is low, flash a graphic to warn the player
- if (ps->stats[STAT_ARMOR]) // Is there armor? Draw the HUD Armor TIC
+ if (ps->stats[STAT_ARMOR]) // Is there armor? Draw the HUD Armor TIC
{
- float quarterArmor = (float) (ps->stats[STAT_MAX_HEALTH] / 4.0f);
+ float quarterArmor = (float)(ps->stats[STAT_MAX_HEALTH] / 4.0f);
// Make tic flash if armor is at 25% of full armor
- if (ps->stats[STAT_ARMOR] < quarterArmor) // Do whatever the flash timer says
+ if (ps->stats[STAT_ARMOR] < quarterArmor) // Do whatever the flash timer says
{
- if (cg.HUDTickFlashTime < cg.time) // Flip at the same time
+ if (cg.HUDTickFlashTime < cg.time) // Flip at the same time
{
cg.HUDTickFlashTime = cg.time + 400;
- if (cg.HUDArmorFlag)
- {
+ if (cg.HUDArmorFlag) {
cg.HUDArmorFlag = qfalse;
- }
- else
- {
+ } else {
cg.HUDArmorFlag = qtrue;
}
}
+ } else {
+ cg.HUDArmorFlag = qtrue;
}
- else
- {
- cg.HUDArmorFlag=qtrue;
- }
- }
- else // No armor? Don't show it.
+ } else // No armor? Don't show it.
{
- cg.HUDArmorFlag=qfalse;
+ cg.HUDArmorFlag = qfalse;
}
-
}
#define MAX_VHUD_SHIELD_TICS 12
@@ -604,150 +458,101 @@ static void CG_DrawArmor(const int x,const int y,const int w,const int h)
#define MAX_VHUD_ARMOR_TICS 5
#define MAX_VHUD_AMMO_TICS 5
-static void CG_DrawVehicleSheild( const centity_t *cent, const Vehicle_t *pVeh )
-{
- int xPos,yPos,width,height,i;
- vec4_t color,calcColor;
- qhandle_t background;
+static void CG_DrawVehicleSheild(const centity_t *cent, const Vehicle_t *pVeh) {
+ int xPos, yPos, width, height, i;
+ vec4_t color, calcColor;
+ qhandle_t background;
char itemName[64];
- float inc, currValue,maxHealth;
+ float inc, currValue, maxHealth;
- //riding some kind of living creature
- if ( pVeh->m_pVehicleInfo->type == VH_ANIMAL || pVeh->m_pVehicleInfo->type == VH_FLIER )
- {
+ // riding some kind of living creature
+ if (pVeh->m_pVehicleInfo->type == VH_ANIMAL || pVeh->m_pVehicleInfo->type == VH_FLIER) {
maxHealth = 100.0f;
currValue = pVeh->m_pParentEntity->health;
- }
- else //normal vehicle
+ } else // normal vehicle
{
maxHealth = pVeh->m_pVehicleInfo->armor;
currValue = pVeh->m_iArmor;
}
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "shieldbackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "shieldbackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
// Print all the tics of the shield graphic
// Look at the amount of health left and show only as much of the graphic as there is health.
// Use alpha to fade out partial section of health
- inc = (float) maxHealth / MAX_VHUD_SHIELD_TICS;
- for (i=1;i <= MAX_VHUD_SHIELD_TICS;i++)
- {
- Com_sprintf( itemName, sizeof(itemName), "shield_tic%d", i );
-
- if (!cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- itemName,
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
+ inc = (float)maxHealth / MAX_VHUD_SHIELD_TICS;
+ for (i = 1; i <= MAX_VHUD_SHIELD_TICS; i++) {
+ Com_sprintf(itemName, sizeof(itemName), "shield_tic%d", i);
+
+ if (!cgi_UI_GetMenuItemInfo("swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) {
continue;
}
memcpy(calcColor, color, sizeof(vec4_t));
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
currValue -= inc;
}
}
// The HUD.menu file has the graphic print with a negative height, so it will print from the bottom up.
-static void CG_DrawVehicleTurboRecharge( const centity_t *cent, const Vehicle_t *pVeh )
-{
- int xPos,yPos,width,height;
- qhandle_t background;
- vec4_t color;
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "turborecharge",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- float percent=0.0f;
- int diff = ( cg.time - pVeh->m_iTurboTime );
+static void CG_DrawVehicleTurboRecharge(const centity_t *cent, const Vehicle_t *pVeh) {
+ int xPos, yPos, width, height;
+ qhandle_t background;
+ vec4_t color;
+
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "turborecharge", &xPos, &yPos, &width, &height, color, &background)) {
+ float percent = 0.0f;
+ int diff = (cg.time - pVeh->m_iTurboTime);
// Calc max time
- if (diff > pVeh->m_pVehicleInfo->turboRecharge)
- {
+ if (diff > pVeh->m_pVehicleInfo->turboRecharge) {
percent = 1.0f;
- cgi_R_SetColor( colorTable[CT_GREEN] );
- }
- else
- {
- percent = (float) diff / pVeh->m_pVehicleInfo->turboRecharge;
- if (percent < 0.0f)
- {
+ cgi_R_SetColor(colorTable[CT_GREEN]);
+ } else {
+ percent = (float)diff / pVeh->m_pVehicleInfo->turboRecharge;
+ if (percent < 0.0f) {
percent = 0.0f;
}
- cgi_R_SetColor( colorTable[CT_RED] );
+ cgi_R_SetColor(colorTable[CT_RED]);
}
height *= percent;
- CG_DrawPic(xPos,yPos, width, height, cgs.media.whiteShader); // Top
+ CG_DrawPic(xPos, yPos, width, height, cgs.media.whiteShader); // Top
}
-
-
}
-static void CG_DrawVehicleSpeed( const centity_t *cent, const Vehicle_t *pVeh, const char *entHud )
-{
- int xPos,yPos,width,height;
- qhandle_t background;
+static void CG_DrawVehicleSpeed(const centity_t *cent, const Vehicle_t *pVeh, const char *entHud) {
+ int xPos, yPos, width, height;
+ qhandle_t background;
gentity_t *parent = pVeh->m_pParentEntity;
playerState_t *parentPS = &parent->client->ps;
- float currValue,maxSpeed;
- vec4_t color,calcColor;
+ float currValue, maxSpeed;
+ vec4_t color, calcColor;
float inc;
int i;
char itemName[64];
- if (cgi_UI_GetMenuItemInfo(
- entHud,
- "speedbackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo(entHud, "speedbackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
maxSpeed = pVeh->m_pVehicleInfo->speedMax;
@@ -756,93 +561,61 @@ static void CG_DrawVehicleSpeed( const centity_t *cent, const Vehicle_t *pVeh, c
// Print all the tics of the shield graphic
// Look at the amount of health left and show only as much of the graphic as there is health.
// Use alpha to fade out partial section of health
- inc = (float) maxSpeed / MAX_VHUD_SPEED_TICS;
- for (i=1;i<=MAX_VHUD_SPEED_TICS;i++)
- {
- Com_sprintf( itemName, sizeof(itemName), "speed_tic%d", i );
-
- if (!cgi_UI_GetMenuItemInfo(
- entHud,
- itemName,
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
+ inc = (float)maxSpeed / MAX_VHUD_SPEED_TICS;
+ for (i = 1; i <= MAX_VHUD_SPEED_TICS; i++) {
+ Com_sprintf(itemName, sizeof(itemName), "speed_tic%d", i);
+
+ if (!cgi_UI_GetMenuItemInfo(entHud, itemName, &xPos, &yPos, &width, &height, color, &background)) {
continue;
}
- if ( level.time > pVeh->m_iTurboTime )
- {
+ if (level.time > pVeh->m_iTurboTime) {
memcpy(calcColor, color, sizeof(vec4_t));
- }
- else // In turbo mode
+ } else // In turbo mode
{
- if (cg.VHUDFlashTime < cg.time)
- {
+ if (cg.VHUDFlashTime < cg.time) {
cg.VHUDFlashTime = cg.time + 400;
- if (cg.VHUDTurboFlag)
- {
+ if (cg.VHUDTurboFlag) {
cg.VHUDTurboFlag = qfalse;
- }
- else
- {
+ } else {
cg.VHUDTurboFlag = qtrue;
}
}
- if (cg.VHUDTurboFlag)
- {
+ if (cg.VHUDTurboFlag) {
memcpy(calcColor, colorTable[CT_LTRED1], sizeof(vec4_t));
- }
- else
- {
+ } else {
memcpy(calcColor, color, sizeof(vec4_t));
}
}
-
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
currValue -= inc;
}
-
}
-static void CG_DrawVehicleArmor( const centity_t *cent, const Vehicle_t *pVeh )
-{
- int xPos,yPos,width,height,i;
- qhandle_t background;
+static void CG_DrawVehicleArmor(const centity_t *cent, const Vehicle_t *pVeh) {
+ int xPos, yPos, width, height, i;
+ qhandle_t background;
char itemName[64];
- float inc, currValue,maxArmor;
- vec4_t color,calcColor;
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "armorbackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ float inc, currValue, maxArmor;
+ vec4_t color, calcColor;
+
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "armorbackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
maxArmor = pVeh->m_iArmor;
@@ -851,768 +624,497 @@ static void CG_DrawVehicleArmor( const centity_t *cent, const Vehicle_t *pVeh )
// Print all the tics of the shield graphic
// Look at the amount of health left and show only as much of the graphic as there is health.
// Use alpha to fade out partial section of health
- inc = (float) maxArmor / MAX_VHUD_ARMOR_TICS;
- for (i=1;i<=MAX_VHUD_ARMOR_TICS;i++)
- {
- Com_sprintf( itemName, sizeof(itemName), "armor_tic%d", i );
-
- if (!cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- itemName,
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
+ inc = (float)maxArmor / MAX_VHUD_ARMOR_TICS;
+ for (i = 1; i <= MAX_VHUD_ARMOR_TICS; i++) {
+ Com_sprintf(itemName, sizeof(itemName), "armor_tic%d", i);
+
+ if (!cgi_UI_GetMenuItemInfo("swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) {
continue;
}
memcpy(calcColor, color, sizeof(vec4_t));
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
currValue -= inc;
}
}
-static void CG_DrawVehicleAmmo( const centity_t *cent, const Vehicle_t *pVeh )
-{
- int xPos,yPos,width,height,i;
- qhandle_t background;
+static void CG_DrawVehicleAmmo(const centity_t *cent, const Vehicle_t *pVeh) {
+ int xPos, yPos, width, height, i;
+ qhandle_t background;
char itemName[64];
- float inc, currValue,maxAmmo;
- vec4_t color,calcColor;
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "ammobackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ float inc, currValue, maxAmmo;
+ vec4_t color, calcColor;
+
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "ammobackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
maxAmmo = pVeh->m_pVehicleInfo->weapon[0].ammoMax;
currValue = pVeh->weaponStatus[0].ammo;
- inc = (float) maxAmmo / MAX_VHUD_AMMO_TICS;
- for (i=1;i<=MAX_VHUD_AMMO_TICS;i++)
- {
- Com_sprintf( itemName, sizeof(itemName), "ammo_tic%d", i );
-
- if (!cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- itemName,
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
+ inc = (float)maxAmmo / MAX_VHUD_AMMO_TICS;
+ for (i = 1; i <= MAX_VHUD_AMMO_TICS; i++) {
+ Com_sprintf(itemName, sizeof(itemName), "ammo_tic%d", i);
+
+ if (!cgi_UI_GetMenuItemInfo("swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) {
continue;
}
memcpy(calcColor, color, sizeof(vec4_t));
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor );
- CG_DrawPic( xPos, yPos, width, height, background );
+ cgi_R_SetColor(calcColor);
+ CG_DrawPic(xPos, yPos, width, height, background);
currValue -= inc;
}
}
-
-static void CG_DrawVehicleAmmoUpper( const centity_t *cent, const Vehicle_t *pVeh )
-{
- int xPos,yPos,width,height,i;
- qhandle_t background;
+static void CG_DrawVehicleAmmoUpper(const centity_t *cent, const Vehicle_t *pVeh) {
+ int xPos, yPos, width, height, i;
+ qhandle_t background;
char itemName[64];
- float inc, currValue,maxAmmo;
- vec4_t color,calcColor;
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "ammoupperbackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ float inc, currValue, maxAmmo;
+ vec4_t color, calcColor;
+
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "ammoupperbackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
maxAmmo = pVeh->m_pVehicleInfo->weapon[0].ammoMax;
currValue = pVeh->weaponStatus[0].ammo;
- inc = (float) maxAmmo / MAX_VHUD_AMMO_TICS;
- for (i=1;im_pVehicleInfo->weapon[1].ammoMax;
currValue = pVeh->weaponStatus[1].ammo;
- inc = (float) maxAmmo / MAX_VHUD_AMMO_TICS;
- for (i=1;igent && cent->gent->owner )
- {
- if (( cent->gent->owner->flags & FL_GODMODE ))
- {
+ if (cent->gent && cent->gent->owner) {
+ if ((cent->gent->owner->flags & FL_GODMODE)) {
// chair is in godmode, so render the health of the player instead
health = cent->gent->health;
- }
- else
- {
+ } else {
// render the chair health
health = cent->gent->owner->health;
}
- }
- else
- {
+ } else {
return;
}
- //riding some kind of living creature
+ // riding some kind of living creature
maxHealth = (float)cent->gent->max_health;
currValue = health;
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "shieldbackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "shieldbackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
// Print all the tics of the shield graphic
// Look at the amount of health left and show only as much of the graphic as there is health.
// Use alpha to fade out partial section of health
- inc = (float) maxHealth / MAX_VHUD_SHIELD_TICS;
- for (i=1;i <= MAX_VHUD_SHIELD_TICS;i++)
- {
- Com_sprintf( itemName, sizeof(itemName), "shield_tic%d", i );
-
- if (!cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- itemName,
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
+ inc = (float)maxHealth / MAX_VHUD_SHIELD_TICS;
+ for (i = 1; i <= MAX_VHUD_SHIELD_TICS; i++) {
+ Com_sprintf(itemName, sizeof(itemName), "shield_tic%d", i);
+
+ if (!cgi_UI_GetMenuItemInfo("swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) {
continue;
}
memcpy(calcColor, color, sizeof(vec4_t));
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
currValue -= inc;
}
}
-static void CG_DrawEmplacedGunHud( const centity_t *cent )
-{
- int xPos,yPos,width,height;
- vec4_t color;
- qhandle_t background;
+static void CG_DrawEmplacedGunHud(const centity_t *cent) {
+ int xPos, yPos, width, height;
+ vec4_t color;
+ qhandle_t background;
// Draw frame
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "leftframe",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
- }
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "rightframe",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
- CG_DrawEmplacedGunHealth( cent );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
+ }
+ CG_DrawEmplacedGunHealth(cent);
}
-
-static void CG_DrawItemHealth( float currValue, float maxHealth )
-{
- int xPos,yPos,width,height,i;
- vec4_t color,calcColor;
- qhandle_t background;
+static void CG_DrawItemHealth(float currValue, float maxHealth) {
+ int xPos, yPos, width, height, i;
+ vec4_t color, calcColor;
+ qhandle_t background;
char itemName[64];
float inc;
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "shieldbackground",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "shieldbackground", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
// Print all the tics of the shield graphic
// Look at the amount of health left and show only as much of the graphic as there is health.
// Use alpha to fade out partial section of health
- inc = (float) maxHealth / MAX_VHUD_SHIELD_TICS;
- for (i=1;i <= MAX_VHUD_SHIELD_TICS;i++)
- {
- Com_sprintf( itemName, sizeof(itemName), "shield_tic%d", i );
-
- if (!cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- itemName,
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
+ inc = (float)maxHealth / MAX_VHUD_SHIELD_TICS;
+ for (i = 1; i <= MAX_VHUD_SHIELD_TICS; i++) {
+ Com_sprintf(itemName, sizeof(itemName), "shield_tic%d", i);
+
+ if (!cgi_UI_GetMenuItemInfo("swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) {
continue;
}
memcpy(calcColor, color, sizeof(vec4_t));
- if (currValue <= 0) // don't show tic
+ if (currValue <= 0) // don't show tic
{
break;
- }
- else if (currValue < inc) // partial tic (alpha it out)
+ } else if (currValue < inc) // partial tic (alpha it out)
{
float percent = currValue / inc;
- calcColor[3] *= percent; // Fade it out
+ calcColor[3] *= percent; // Fade it out
}
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
currValue -= inc;
}
}
-static void CG_DrawPanelTurretHud( void )
-{
- int xPos,yPos,width,height;
- vec4_t color;
- qhandle_t background;
+static void CG_DrawPanelTurretHud(void) {
+ int xPos, yPos, width, height;
+ vec4_t color;
+ qhandle_t background;
// Draw frame
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "leftframe",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
- }
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "rightframe",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
- CG_DrawItemHealth(
- g_entities[cg.snap->ps.viewEntity].health,
- (float)g_entities[cg.snap->ps.viewEntity].max_health
- );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
+ }
+ CG_DrawItemHealth(g_entities[cg.snap->ps.viewEntity].health, (float)g_entities[cg.snap->ps.viewEntity].max_health);
}
-static void CG_DrawATSTHud( centity_t *cent )
-{
- int xPos,yPos,width,height;
- vec4_t color;
- qhandle_t background;
- float health;
+static void CG_DrawATSTHud(centity_t *cent) {
+ int xPos, yPos, width, height;
+ vec4_t color;
+ qhandle_t background;
+ float health;
- if ( !cg.snap
- ||!g_entities[cg.snap->ps.viewEntity].activator )
- {
+ if (!cg.snap || !g_entities[cg.snap->ps.viewEntity].activator) {
return;
}
// Draw frame
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "leftframe",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
- }
-
- if (cgi_UI_GetMenuItemInfo(
- "swoopvehiclehud",
- "rightframe",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
- // we just calc the display value from the sum of health and armor
- if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health
- {
- health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] );
+ if (cgi_UI_GetMenuItemInfo("swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
- else
+
+ // we just calc the display value from the sum of health and armor
+ if (g_entities[cg.snap->ps.viewEntity].activator) // ensure we can look back to the atst_drivable to get the max health
{
- health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] );
+ health = (g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]);
+ } else {
+ health = (g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]);
}
- CG_DrawItemHealth(health,g_entities[cg.snap->ps.viewEntity].activator->max_health );
+ CG_DrawItemHealth(health, g_entities[cg.snap->ps.viewEntity].activator->max_health);
- if (cgi_UI_GetMenuItemInfo(
- "atsthud",
- "background",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
+ if (cgi_UI_GetMenuItemInfo("atsthud", "background", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
}
- if (cgi_UI_GetMenuItemInfo(
- "atsthud",
- "outer_frame",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
- }
-
- if (cgi_UI_GetMenuItemInfo(
- "atsthud",
- "left_pic",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
+ if (cgi_UI_GetMenuItemInfo("atsthud", "outer_frame", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
+ }
+
+ if (cgi_UI_GetMenuItemInfo("atsthud", "left_pic", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
- CG_DrawPic( xPos, yPos, width, height, background );
+ CG_DrawPic(xPos, yPos, width, height, background);
}
}
//-----------------------------------------------------
-static qboolean CG_DrawCustomHealthHud( centity_t *cent )
-{
+static qboolean CG_DrawCustomHealthHud(centity_t *cent) {
Vehicle_t *pVeh;
// In a Weapon?
- if (( cent->currentState.eFlags & EF_LOCKED_TO_WEAPON ))
- {
+ if ((cent->currentState.eFlags & EF_LOCKED_TO_WEAPON)) {
CG_DrawEmplacedGunHud(cent);
// DRAW emplaced HUD
-/* color[0] = color[1] = color[2] = 0.0f;
- color[3] = 0.3f;
+ /* color[0] = color[1] = color[2] = 0.0f;
+ color[3] = 0.3f;
- cgi_R_SetColor( color );
- CG_DrawPic( 14, 480 - 50, 94, 32, cgs.media.whiteShader );
+ cgi_R_SetColor( color );
+ CG_DrawPic( 14, 480 - 50, 94, 32, cgs.media.whiteShader );
- // NOTE: this looks ugly
- if ( cent->gent && cent->gent->owner )
- {
- if (( cent->gent->owner->flags & FL_GODMODE ))
- {
- // chair is in godmode, so render the health of the player instead
- health = cent->gent->health / (float)cent->gent->max_health;
- }
- else
- {
- // render the chair health
- health = cent->gent->owner->health / (float)cent->gent->owner->max_health;
- }
- }
+ // NOTE: this looks ugly
+ if ( cent->gent && cent->gent->owner )
+ {
+ if (( cent->gent->owner->flags & FL_GODMODE ))
+ {
+ // chair is in godmode, so render the health of the player instead
+ health = cent->gent->health / (float)cent->gent->max_health;
+ }
+ else
+ {
+ // render the chair health
+ health = cent->gent->owner->health / (float)cent->gent->owner->max_health;
+ }
+ }
- color[0] = 1.0f;
- color[3] = 0.5f;
+ color[0] = 1.0f;
+ color[3] = 0.5f;
- cgi_R_SetColor( color );
- CG_DrawPic( 18, 480 - 41, 87 * health, 19, cgs.media.whiteShader );
+ cgi_R_SetColor( color );
+ CG_DrawPic( 18, 480 - 41, 87 * health, 19, cgs.media.whiteShader );
- cgi_R_SetColor( colorTable[CT_WHITE] );
- CG_DrawPic( 2, 480 - 64, 128, 64, cgs.media.emplacedHealthBarShader);
-*/
+ cgi_R_SetColor( colorTable[CT_WHITE] );
+ CG_DrawPic( 2, 480 - 64, 128, 64, cgs.media.emplacedHealthBarShader);
+ */
return qfalse; // drew this hud, so don't draw the player one
}
// In an ATST
- else if (( cent->currentState.eFlags & EF_IN_ATST ))
- {
+ else if ((cent->currentState.eFlags & EF_IN_ATST)) {
-/*
- // we are an ATST...
- color[0] = color[1] = color[2] = 0.0f;
- color[3] = 0.3f;
+ /*
+ // we are an ATST...
+ color[0] = color[1] = color[2] = 0.0f;
+ color[3] = 0.3f;
- cgi_R_SetColor( color );
- CG_DrawPic( 14, 480 - 50, 94, 32, cgs.media.whiteShader );
+ cgi_R_SetColor( color );
+ CG_DrawPic( 14, 480 - 50, 94, 32, cgs.media.whiteShader );
- // we just calc the display value from the sum of health and armor
- if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health
- {
- health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) /
- (float)(g_entities[cg.snap->ps.viewEntity].max_health + g_entities[cg.snap->ps.viewEntity].activator->max_health );
- }
- else
- {
- health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) /
- (float)(g_entities[cg.snap->ps.viewEntity].max_health + 800 ); // hacked max armor since we don't have an activator...should never happen
- }
+ // we just calc the display value from the sum of health and armor
+ if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health
+ {
+ health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) /
+ (float)(g_entities[cg.snap->ps.viewEntity].max_health + g_entities[cg.snap->ps.viewEntity].activator->max_health );
+ }
+ else
+ {
+ health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) /
+ (float)(g_entities[cg.snap->ps.viewEntity].max_health + 800 ); // hacked max armor since we don't have an activator...should never
+ happen
+ }
- color[1] = 0.25f; // blue-green
- color[2] = 1.0f;
- color[3] = 0.5f;
+ color[1] = 0.25f; // blue-green
+ color[2] = 1.0f;
+ color[3] = 0.5f;
- cgi_R_SetColor( color );
- CG_DrawPic( 18, 480 - 41, 87 * health, 19, cgs.media.whiteShader );
+ cgi_R_SetColor( color );
+ CG_DrawPic( 18, 480 - 41, 87 * health, 19, cgs.media.whiteShader );
- cgi_R_SetColor( colorTable[CT_WHITE] );
- CG_DrawPic( 2, 480 - 64, 128, 64, cgs.media.emplacedHealthBarShader);
-*/
+ cgi_R_SetColor( colorTable[CT_WHITE] );
+ CG_DrawPic( 2, 480 - 64, 128, 64, cgs.media.emplacedHealthBarShader);
+ */
CG_DrawATSTHud(cent);
return qfalse; // drew this hud, so don't draw the player one
}
// In a vehicle
- else if ( (pVeh = G_IsRidingVehicle( cent->gent ) ) != 0 )
- {
+ else if ((pVeh = G_IsRidingVehicle(cent->gent)) != 0) {
- //riding some kind of living creature
- if ( pVeh->m_pVehicleInfo->type == VH_ANIMAL )
- {
- CG_DrawTauntaunHud( cent, pVeh );
- }
- else
- {
- CG_DrawVehicleHud( cent, pVeh );
+ // riding some kind of living creature
+ if (pVeh->m_pVehicleInfo->type == VH_ANIMAL) {
+ CG_DrawTauntaunHud(cent, pVeh);
+ } else {
+ CG_DrawVehicleHud(cent, pVeh);
}
return qtrue; // draw this hud AND the player one
}
// Other?
- else if ( cg.snap->ps.viewEntity && ( g_entities[cg.snap->ps.viewEntity].dflags & DAMAGE_CUSTOM_HUD ))
- {
+ else if (cg.snap->ps.viewEntity && (g_entities[cg.snap->ps.viewEntity].dflags & DAMAGE_CUSTOM_HUD)) {
CG_DrawPanelTurretHud();
return qfalse; // drew this hud, so don't draw the player one
}
@@ -1621,100 +1123,90 @@ static qboolean CG_DrawCustomHealthHud( centity_t *cent )
}
//--------------------------------------
-static void CG_DrawBatteryCharge( void )
-{
- if ( cg.batteryChargeTime > cg.time )
- {
+static void CG_DrawBatteryCharge(void) {
+ if (cg.batteryChargeTime > cg.time) {
vec4_t color;
// FIXME: drawing it here will overwrite zoom masks...find a better place
- if ( cg.batteryChargeTime < cg.time + 1000 )
- {
+ if (cg.batteryChargeTime < cg.time + 1000) {
// fading out for the last second
color[0] = color[1] = color[2] = 1.0f;
color[3] = (cg.batteryChargeTime - cg.time) / 1000.0f;
- }
- else
- {
+ } else {
// draw full
color[0] = color[1] = color[2] = color[3] = 1.0f;
}
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
// batteries were just charged
- CG_DrawPic( 605, 295, 24, 32, cgs.media.batteryChargeShader );
+ CG_DrawPic(605, 295, 24, 32, cgs.media.batteryChargeShader);
}
}
-#define SimpleHud_DrawString( x, y, str, color ) cgi_R_Font_DrawString( x, y, str, color, (int)0x80000000 | cgs.media.qhFontSmall, -1, 1.0f )
+#define SimpleHud_DrawString(x, y, str, color) cgi_R_Font_DrawString(x, y, str, color, (int)0x80000000 | cgs.media.qhFontSmall, -1, 1.0f)
-static void CG_DrawSimpleSaberStyle( const centity_t *cent )
-{
- uint32_t calcColor;
- char num[7] = { 0 };
- int weapX = 16;
+static void CG_DrawSimpleSaberStyle(const centity_t *cent) {
+ uint32_t calcColor;
+ char num[7] = {0};
+ int weapX = 16;
- if ( !cent->currentState.weapon ) // We don't have a weapon right now
+ if (!cent->currentState.weapon) // We don't have a weapon right now
{
return;
}
- if ( cent->currentState.weapon != WP_SABER || !cent->gent )
- {
+ if (cent->currentState.weapon != WP_SABER || !cent->gent) {
return;
}
- if ( !cg.saberAnimLevelPending && cent->gent && cent->gent->client )
- {//uninitialized after a loadgame, cheat across and get it
+ if (!cg.saberAnimLevelPending && cent->gent && cent->gent->client) { // uninitialized after a loadgame, cheat across and get it
cg.saberAnimLevelPending = cent->gent->client->ps.saberAnimLevel;
}
- switch ( cg.saberAnimLevelPending )
- {
+ switch (cg.saberAnimLevelPending) {
default:
case SS_FAST:
- Com_sprintf( num, sizeof( num ), "FAST" );
+ Com_sprintf(num, sizeof(num), "FAST");
calcColor = CT_ICON_BLUE;
weapX = 0;
break;
case SS_MEDIUM:
- Com_sprintf( num, sizeof( num ), "MEDIUM" );
+ Com_sprintf(num, sizeof(num), "MEDIUM");
calcColor = CT_YELLOW;
break;
case SS_STRONG:
- Com_sprintf( num, sizeof( num ), "STRONG" );
+ Com_sprintf(num, sizeof(num), "STRONG");
calcColor = CT_HUD_RED;
break;
case SS_DESANN:
- Com_sprintf( num, sizeof( num ), "DESANN" );
+ Com_sprintf(num, sizeof(num), "DESANN");
calcColor = CT_HUD_RED;
break;
case SS_TAVION:
- Com_sprintf( num, sizeof( num ), "TAVION" );
+ Com_sprintf(num, sizeof(num), "TAVION");
calcColor = CT_ICON_BLUE;
break;
case SS_DUAL:
- Com_sprintf( num, sizeof( num ), "AKIMBO" );
+ Com_sprintf(num, sizeof(num), "AKIMBO");
calcColor = CT_HUD_ORANGE;
break;
case SS_STAFF:
- Com_sprintf( num, sizeof( num ), "STAFF" );
+ Com_sprintf(num, sizeof(num), "STAFF");
calcColor = CT_HUD_ORANGE;
break;
}
- SimpleHud_DrawString( SCREEN_WIDTH - (weapX + 16 + 32), (SCREEN_HEIGHT - 80) + 40, num, colorTable[calcColor] );
+ SimpleHud_DrawString(SCREEN_WIDTH - (weapX + 16 + 32), (SCREEN_HEIGHT - 80) + 40, num, colorTable[calcColor]);
}
-static void CG_DrawSimpleAmmo( const centity_t *cent )
-{
- playerState_t *ps;
- uint32_t calcColor;
- int currValue = 0;
- char num[16] = { 0 };
+static void CG_DrawSimpleAmmo(const centity_t *cent) {
+ playerState_t *ps;
+ uint32_t calcColor;
+ int currValue = 0;
+ char num[16] = {0};
- if ( !cent->currentState.weapon ) // We don't have a weapon right now
+ if (!cent->currentState.weapon) // We don't have a weapon right now
{
return;
}
@@ -1724,86 +1216,64 @@ static void CG_DrawSimpleAmmo( const centity_t *cent )
currValue = ps->ammo[weaponData[cent->currentState.weapon].ammoIndex];
// No ammo
- if ( currValue < 0 || (weaponData[cent->currentState.weapon].energyPerShot == 0 && weaponData[cent->currentState.weapon].altEnergyPerShot == 0) )
- {
- SimpleHud_DrawString( SCREEN_WIDTH - (16 + 32), (SCREEN_HEIGHT - 80) + 40, "--", colorTable[CT_HUD_ORANGE] );
+ if (currValue < 0 || (weaponData[cent->currentState.weapon].energyPerShot == 0 && weaponData[cent->currentState.weapon].altEnergyPerShot == 0)) {
+ SimpleHud_DrawString(SCREEN_WIDTH - (16 + 32), (SCREEN_HEIGHT - 80) + 40, "--", colorTable[CT_HUD_ORANGE]);
return;
}
//
// ammo
//
- if ( cg.oldammo < currValue )
- {
+ if (cg.oldammo < currValue) {
cg.oldAmmoTime = cg.time + 200;
}
cg.oldammo = currValue;
-
// Determine the color of the numeric field
// Firing or reloading?
- if ( (cg.predicted_player_state.weaponstate == WEAPON_FIRING
- && cg.predicted_player_state.weaponTime > 100) )
- {
+ if ((cg.predicted_player_state.weaponstate == WEAPON_FIRING && cg.predicted_player_state.weaponTime > 100)) {
calcColor = CT_LTGREY;
- }
- else
- {
- if ( currValue > 0 )
- {
- if ( cg.oldAmmoTime > cg.time )
- {
+ } else {
+ if (currValue > 0) {
+ if (cg.oldAmmoTime > cg.time) {
calcColor = CT_YELLOW;
- }
- else
- {
+ } else {
calcColor = CT_HUD_ORANGE;
}
- }
- else
- {
+ } else {
calcColor = CT_RED;
}
}
- Com_sprintf( num, sizeof( num ), "%i", currValue );
+ Com_sprintf(num, sizeof(num), "%i", currValue);
- SimpleHud_DrawString( SCREEN_WIDTH - (16 + 32), (SCREEN_HEIGHT - 80) + 40, num, colorTable[calcColor] );
+ SimpleHud_DrawString(SCREEN_WIDTH - (16 + 32), (SCREEN_HEIGHT - 80) + 40, num, colorTable[calcColor]);
}
-static void CG_DrawSimpleForcePower( const centity_t *cent )
-{
- uint32_t calcColor;
- char num[16] = { 0 };
- qboolean flash = qfalse;
+static void CG_DrawSimpleForcePower(const centity_t *cent) {
+ uint32_t calcColor;
+ char num[16] = {0};
+ qboolean flash = qfalse;
- if ( !cent->gent || !cent->gent->client->ps.forcePowersKnown )
- {
+ if (!cent->gent || !cent->gent->client->ps.forcePowersKnown) {
return;
}
// Make the hud flash by setting forceHUDTotalFlashTime above cg.time
- if ( cg.forceHUDTotalFlashTime > cg.time )
- {
+ if (cg.forceHUDTotalFlashTime > cg.time) {
flash = qtrue;
- if ( cg.forceHUDNextFlashTime < cg.time )
- {
+ if (cg.forceHUDNextFlashTime < cg.time) {
cg.forceHUDNextFlashTime = cg.time + 400;
- cgi_S_StartSound( NULL, 0, CHAN_AUTO, cgs.media.noforceSound );
- if ( cg.forceHUDActive )
- {
+ cgi_S_StartSound(NULL, 0, CHAN_AUTO, cgs.media.noforceSound);
+ if (cg.forceHUDActive) {
cg.forceHUDActive = qfalse;
- }
- else
- {
+ } else {
cg.forceHUDActive = qtrue;
}
-
}
- }
- else // turn HUD back on if it had just finished flashing time.
+ } else // turn HUD back on if it had just finished flashing time.
{
cg.forceHUDNextFlashTime = 0;
cg.forceHUDActive = qtrue;
@@ -1812,9 +1282,9 @@ static void CG_DrawSimpleForcePower( const centity_t *cent )
// Determine the color of the numeric field
calcColor = flash ? CT_RED : CT_ICON_BLUE;
- Com_sprintf( num, sizeof( num ), "%i", cent->gent->client->ps.forcePower );
+ Com_sprintf(num, sizeof(num), "%i", cent->gent->client->ps.forcePower);
- SimpleHud_DrawString( SCREEN_WIDTH - (16 + 32), (SCREEN_HEIGHT - 80) + 40 + 14, num, colorTable[calcColor] );
+ SimpleHud_DrawString(SCREEN_WIDTH - (16 + 32), (SCREEN_HEIGHT - 80) + 40 + 14, num, colorTable[calcColor]);
}
/*
@@ -1822,121 +1292,89 @@ static void CG_DrawSimpleForcePower( const centity_t *cent )
CG_DrawHUD
================
*/
-static void CG_DrawHUD( centity_t *cent )
-{
+static void CG_DrawHUD(centity_t *cent) {
int value;
- int sectionXPos,sectionYPos,sectionWidth,sectionHeight;
+ int sectionXPos, sectionYPos, sectionWidth, sectionHeight;
- if ( cg_hudFiles.integer )
- {
+ if (cg_hudFiles.integer) {
int x = 0;
int y = SCREEN_HEIGHT - 80;
- SimpleHud_DrawString( x + 16, y + 40, va( "%i", cg.snap->ps.stats[STAT_HEALTH] ), colorTable[CT_HUD_RED] );
+ SimpleHud_DrawString(x + 16, y + 40, va("%i", cg.snap->ps.stats[STAT_HEALTH]), colorTable[CT_HUD_RED]);
- SimpleHud_DrawString( x + 18 + 14, y + 40 + 14, va( "%i", cg.snap->ps.stats[STAT_ARMOR] ), colorTable[CT_HUD_GREEN] );
+ SimpleHud_DrawString(x + 18 + 14, y + 40 + 14, va("%i", cg.snap->ps.stats[STAT_ARMOR]), colorTable[CT_HUD_GREEN]);
- CG_DrawSimpleForcePower( cent );
+ CG_DrawSimpleForcePower(cent);
- if ( cent->currentState.weapon == WP_SABER )
- CG_DrawSimpleSaberStyle( cent );
+ if (cent->currentState.weapon == WP_SABER)
+ CG_DrawSimpleSaberStyle(cent);
else
- CG_DrawSimpleAmmo( cent );
+ CG_DrawSimpleAmmo(cent);
return;
}
// Draw the lower left section of the HUD
- if (cgi_UI_GetMenuInfo("lefthud",§ionXPos,§ionYPos,§ionWidth,§ionHeight))
- {
+ if (cgi_UI_GetMenuInfo("lefthud", §ionXPos, §ionYPos, §ionWidth, §ionHeight)) {
// Draw all the HUD elements --eez
- cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "lefthud" ), qtrue );
+ cgi_UI_Menu_Paint(cgi_UI_GetMenuByName("lefthud"), qtrue);
// Draw armor & health values
- if ( cg_drawStatus.integer == 2 )
- {
- CG_DrawSmallStringColor(sectionXPos+5, sectionYPos - 60,va("Armor:%d",cg.snap->ps.stats[STAT_ARMOR]), colorTable[CT_HUD_GREEN] );
- CG_DrawSmallStringColor(sectionXPos+5, sectionYPos - 40,va("Health:%d",cg.snap->ps.stats[STAT_HEALTH]), colorTable[CT_HUD_GREEN] );
+ if (cg_drawStatus.integer == 2) {
+ CG_DrawSmallStringColor(sectionXPos + 5, sectionYPos - 60, va("Armor:%d", cg.snap->ps.stats[STAT_ARMOR]), colorTable[CT_HUD_GREEN]);
+ CG_DrawSmallStringColor(sectionXPos + 5, sectionYPos - 40, va("Health:%d", cg.snap->ps.stats[STAT_HEALTH]), colorTable[CT_HUD_GREEN]);
}
// Print scanline
- cgi_R_SetColor( otherHUDBits[OHB_SCANLINE_LEFT].color);
+ cgi_R_SetColor(otherHUDBits[OHB_SCANLINE_LEFT].color);
- CG_DrawPic(
- otherHUDBits[OHB_SCANLINE_LEFT].xPos,
- otherHUDBits[OHB_SCANLINE_LEFT].yPos,
- otherHUDBits[OHB_SCANLINE_LEFT].width,
- otherHUDBits[OHB_SCANLINE_LEFT].height,
- otherHUDBits[OHB_SCANLINE_LEFT].background
- );
+ CG_DrawPic(otherHUDBits[OHB_SCANLINE_LEFT].xPos, otherHUDBits[OHB_SCANLINE_LEFT].yPos, otherHUDBits[OHB_SCANLINE_LEFT].width,
+ otherHUDBits[OHB_SCANLINE_LEFT].height, otherHUDBits[OHB_SCANLINE_LEFT].background);
// Print frame
- cgi_R_SetColor( otherHUDBits[OHB_FRAME_LEFT].color);
- CG_DrawPic(
- otherHUDBits[OHB_FRAME_LEFT].xPos,
- otherHUDBits[OHB_FRAME_LEFT].yPos,
- otherHUDBits[OHB_FRAME_LEFT].width,
- otherHUDBits[OHB_FRAME_LEFT].height,
- otherHUDBits[OHB_FRAME_LEFT].background
- );
+ cgi_R_SetColor(otherHUDBits[OHB_FRAME_LEFT].color);
+ CG_DrawPic(otherHUDBits[OHB_FRAME_LEFT].xPos, otherHUDBits[OHB_FRAME_LEFT].yPos, otherHUDBits[OHB_FRAME_LEFT].width,
+ otherHUDBits[OHB_FRAME_LEFT].height, otherHUDBits[OHB_FRAME_LEFT].background);
- CG_DrawArmor(sectionXPos,sectionYPos,sectionWidth,sectionHeight);
+ CG_DrawArmor(sectionXPos, sectionYPos, sectionWidth, sectionHeight);
- CG_DrawHealth(sectionXPos,sectionYPos,sectionWidth,sectionHeight);
+ CG_DrawHealth(sectionXPos, sectionYPos, sectionWidth, sectionHeight);
}
-
// Draw the lower right section of the HUD
- if (cgi_UI_GetMenuInfo("righthud",§ionXPos,§ionYPos,§ionWidth,§ionHeight))
- {
+ if (cgi_UI_GetMenuInfo("righthud", §ionXPos, §ionYPos, §ionWidth, §ionHeight)) {
// Draw all the HUD elements --eez
- cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "righthud" ), qtrue );
+ cgi_UI_Menu_Paint(cgi_UI_GetMenuByName("righthud"), qtrue);
// Draw armor & health values
- if ( cg_drawStatus.integer == 2 )
- {
- if ( cent->currentState.weapon != WP_SABER && cent->currentState.weapon != WP_STUN_BATON && cent->gent )
- {
+ if (cg_drawStatus.integer == 2) {
+ if (cent->currentState.weapon != WP_SABER && cent->currentState.weapon != WP_STUN_BATON && cent->gent) {
value = cg.snap->ps.ammo[weaponData[cent->currentState.weapon].ammoIndex];
- CG_DrawSmallStringColor(sectionXPos, sectionYPos - 60,va("Ammo:%d",value), colorTable[CT_HUD_GREEN] );
+ CG_DrawSmallStringColor(sectionXPos, sectionYPos - 60, va("Ammo:%d", value), colorTable[CT_HUD_GREEN]);
}
- CG_DrawSmallStringColor(sectionXPos, sectionYPos - 40,va("Force:%d",cent->gent->client->ps.forcePower), colorTable[CT_HUD_GREEN] );
+ CG_DrawSmallStringColor(sectionXPos, sectionYPos - 40, va("Force:%d", cent->gent->client->ps.forcePower), colorTable[CT_HUD_GREEN]);
}
// Print scanline
- cgi_R_SetColor( otherHUDBits[OHB_SCANLINE_RIGHT].color);
-
- CG_DrawPic(
- otherHUDBits[OHB_SCANLINE_RIGHT].xPos,
- otherHUDBits[OHB_SCANLINE_RIGHT].yPos,
- otherHUDBits[OHB_SCANLINE_RIGHT].width,
- otherHUDBits[OHB_SCANLINE_RIGHT].height,
- otherHUDBits[OHB_SCANLINE_RIGHT].background
- );
+ cgi_R_SetColor(otherHUDBits[OHB_SCANLINE_RIGHT].color);
+ CG_DrawPic(otherHUDBits[OHB_SCANLINE_RIGHT].xPos, otherHUDBits[OHB_SCANLINE_RIGHT].yPos, otherHUDBits[OHB_SCANLINE_RIGHT].width,
+ otherHUDBits[OHB_SCANLINE_RIGHT].height, otherHUDBits[OHB_SCANLINE_RIGHT].background);
// Print frame
- cgi_R_SetColor( otherHUDBits[OHB_FRAME_RIGHT].color);
- CG_DrawPic(
- otherHUDBits[OHB_FRAME_RIGHT].xPos,
- otherHUDBits[OHB_FRAME_RIGHT].yPos,
- otherHUDBits[OHB_FRAME_RIGHT].width,
- otherHUDBits[OHB_FRAME_RIGHT].height,
- otherHUDBits[OHB_FRAME_RIGHT].background
- );
+ cgi_R_SetColor(otherHUDBits[OHB_FRAME_RIGHT].color);
+ CG_DrawPic(otherHUDBits[OHB_FRAME_RIGHT].xPos, otherHUDBits[OHB_FRAME_RIGHT].yPos, otherHUDBits[OHB_FRAME_RIGHT].width,
+ otherHUDBits[OHB_FRAME_RIGHT].height, otherHUDBits[OHB_FRAME_RIGHT].background);
- CG_DrawForcePower(cent,sectionXPos,sectionYPos);
+ CG_DrawForcePower(cent, sectionXPos, sectionYPos);
// Draw ammo tics or saber style
- if ( cent->currentState.weapon == WP_SABER )
- {
- CG_DrawSaberStyle(cent,sectionXPos,sectionYPos);
- }
- else
- {
- CG_DrawAmmo(cent,sectionXPos,sectionYPos);
+ if (cent->currentState.weapon == WP_SABER) {
+ CG_DrawSaberStyle(cent, sectionXPos, sectionYPos);
+ } else {
+ CG_DrawAmmo(cent, sectionXPos, sectionYPos);
}
-// CG_DrawMessageLit(cent,x,y);
+ // CG_DrawMessageLit(cent,x,y);
}
}
@@ -1945,17 +1383,16 @@ static void CG_DrawHUD( centity_t *cent )
CG_ClearDataPadCvars
================
*/
-void CG_ClearDataPadCvars( void )
-{
- cgi_Cvar_Set( "cg_updatedDataPadForcePower1", "0" );
- cgi_Cvar_Update( &cg_updatedDataPadForcePower1 );
- cgi_Cvar_Set( "cg_updatedDataPadForcePower2", "0" );
- cgi_Cvar_Update( &cg_updatedDataPadForcePower2 );
- cgi_Cvar_Set( "cg_updatedDataPadForcePower3", "0" );
- cgi_Cvar_Update( &cg_updatedDataPadForcePower3 );
-
- cgi_Cvar_Set( "cg_updatedDataPadObjective", "0" );
- cgi_Cvar_Update( &cg_updatedDataPadObjective );
+void CG_ClearDataPadCvars(void) {
+ cgi_Cvar_Set("cg_updatedDataPadForcePower1", "0");
+ cgi_Cvar_Update(&cg_updatedDataPadForcePower1);
+ cgi_Cvar_Set("cg_updatedDataPadForcePower2", "0");
+ cgi_Cvar_Update(&cg_updatedDataPadForcePower2);
+ cgi_Cvar_Set("cg_updatedDataPadForcePower3", "0");
+ cgi_Cvar_Update(&cg_updatedDataPadForcePower3);
+
+ cgi_Cvar_Set("cg_updatedDataPadObjective", "0");
+ cgi_Cvar_Update(&cg_updatedDataPadObjective);
}
/*
@@ -1963,19 +1400,17 @@ void CG_ClearDataPadCvars( void )
CG_DrawDataPadHUD
================
*/
-void CG_DrawDataPadHUD( centity_t *cent )
-{
- int x,y;
+void CG_DrawDataPadHUD(centity_t *cent) {
+ int x, y;
x = 34;
y = 286;
- CG_DrawHealth(x,y,80,80);
+ CG_DrawHealth(x, y, 80, 80);
x = 526;
- if ((missionInfo_Updated) && ((cg_updatedDataPadForcePower1.integer) || (cg_updatedDataPadObjective.integer)))
- {
+ if ((missionInfo_Updated) && ((cg_updatedDataPadForcePower1.integer) || (cg_updatedDataPadObjective.integer))) {
// Stop flashing light
cg.missionInfoFlashTime = 0;
missionInfo_Updated = qfalse;
@@ -1983,73 +1418,63 @@ void CG_DrawDataPadHUD( centity_t *cent )
// Set which force power to show.
// cg_updatedDataPadForcePower is set from Q3_Interface, because force powers would only be given
// from a script.
- if (cg_updatedDataPadForcePower1.integer)
- {
+ if (cg_updatedDataPadForcePower1.integer) {
cg.DataPadforcepowerSelect = cg_updatedDataPadForcePower1.integer - 1; // Not pretty, I know
- if (cg.DataPadforcepowerSelect >= MAX_DPSHOWPOWERS)
- { //duh
- cg.DataPadforcepowerSelect = MAX_DPSHOWPOWERS-1;
- }
- else if (cg.DataPadforcepowerSelect<0)
- {
- cg.DataPadforcepowerSelect=0;
+ if (cg.DataPadforcepowerSelect >= MAX_DPSHOWPOWERS) { // duh
+ cg.DataPadforcepowerSelect = MAX_DPSHOWPOWERS - 1;
+ } else if (cg.DataPadforcepowerSelect < 0) {
+ cg.DataPadforcepowerSelect = 0;
}
}
-// CG_ClearDataPadCvars();
+ // CG_ClearDataPadCvars();
}
- CG_DrawForcePower(cent,x,y);
- CG_DrawAmmo(cent,x,y);
- CG_DrawMessageLit(cent,x,y);
-
- cgi_R_SetColor( colorTable[CT_WHITE]);
- CG_DrawPic( 0, 0, 640, 480, cgs.media.dataPadFrame );
+ CG_DrawForcePower(cent, x, y);
+ CG_DrawAmmo(cent, x, y);
+ CG_DrawMessageLit(cent, x, y);
+ cgi_R_SetColor(colorTable[CT_WHITE]);
+ CG_DrawPic(0, 0, 640, 480, cgs.media.dataPadFrame);
}
//------------------------
// CG_DrawZoomMask
//------------------------
-static void CG_DrawBinocularNumbers( qboolean power )
-{
+static void CG_DrawBinocularNumbers(qboolean power) {
vec4_t color1;
- cgi_R_SetColor( colorTable[CT_BLACK]);
- CG_DrawPic( 212, 367, 200, 40, cgs.media.whiteShader );
+ cgi_R_SetColor(colorTable[CT_BLACK]);
+ CG_DrawPic(212, 367, 200, 40, cgs.media.whiteShader);
- if ( power )
- {
+ if (power) {
// Numbers should be kind of greenish
color1[0] = 0.2f;
color1[1] = 0.4f;
color1[2] = 0.2f;
color1[3] = 0.3f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
// Draw scrolling numbers, use intervals 10 units apart--sorry, this section of code is just kind of hacked
// up with a bunch of magic numbers.....
int val = ((int)((cg.refdefViewAngles[YAW] + 180) / 10)) * 10;
float off = (cg.refdefViewAngles[YAW] + 180) - val;
- for ( int i = -10; i < 30; i += 10 )
- {
+ for (int i = -10; i < 30; i += 10) {
val -= 10;
- if ( val < 0 )
- {
+ if (val < 0) {
val += 360;
}
// we only want to draw the very far left one some of the time, if it's too far to the left it will poke outside the mask.
- if (( off > 3.0f && i == -10 ) || i > -10 )
- {
+ if ((off > 3.0f && i == -10) || i > -10) {
// draw the value, but add 200 just to bump the range up...arbitrary, so change it if you like
- CG_DrawNumField( 155 + i * 10 + off * 10, 374, 3, val + 200, 24, 14, NUM_FONT_CHUNKY, qtrue );
- CG_DrawPic( 245 + (i-1) * 10 + off * 10, 376, 6, 6, cgs.media.whiteShader );
+ CG_DrawNumField(155 + i * 10 + off * 10, 374, 3, val + 200, 24, 14, NUM_FONT_CHUNKY, qtrue);
+ CG_DrawPic(245 + (i - 1) * 10 + off * 10, 376, 6, 6, cgs.media.whiteShader);
}
}
- CG_DrawPic( 212, 367, 200, 28, cgs.media.binocularOverlay );
+ CG_DrawPic(212, 367, 200, 28, cgs.media.binocularOverlay);
}
}
@@ -2059,136 +1484,116 @@ CG_DrawZoomMask
================
*/
-extern float cg_zoomFov; //from cg_view.cpp
+extern float cg_zoomFov; // from cg_view.cpp
-static void CG_DrawZoomMask( void )
-{
- vec4_t color1;
- centity_t *cent;
- float level;
- static qboolean flip = qtrue;
- float charge = cg.snap->ps.batteryCharge / (float)MAX_BATTERIES; // convert charge to a percentage
- qboolean power = qfalse;
+static void CG_DrawZoomMask(void) {
+ vec4_t color1;
+ centity_t *cent;
+ float level;
+ static qboolean flip = qtrue;
+ float charge = cg.snap->ps.batteryCharge / (float)MAX_BATTERIES; // convert charge to a percentage
+ qboolean power = qfalse;
cent = &cg_entities[0];
- if ( charge > 0.0f )
- {
+ if (charge > 0.0f) {
power = qtrue;
}
//-------------
// Binoculars
//--------------------------------
- if ( cg.zoomMode == 1 )
- {
- CG_RegisterItemVisuals( ITM_BINOCULARS_PICKUP );
+ if (cg.zoomMode == 1) {
+ CG_RegisterItemVisuals(ITM_BINOCULARS_PICKUP);
// zoom level
level = (float)(80.0f - cg_zoomFov) / 80.0f;
// ...so we'll clamp it
- if ( level < 0.0f )
- {
+ if (level < 0.0f) {
level = 0.0f;
- }
- else if ( level > 1.0f )
- {
+ } else if (level > 1.0f) {
level = 1.0f;
}
// Using a magic number to convert the zoom level to scale amount
level *= 162.0f;
- if ( power )
- {
+ if (power) {
// draw blue tinted distortion mask, trying to make it as small as is necessary to fill in the viewable area
- cgi_R_SetColor( colorTable[CT_WHITE] );
- CG_DrawPic( 34, 48, 570, 362, cgs.media.binocularStatic );
+ cgi_R_SetColor(colorTable[CT_WHITE]);
+ CG_DrawPic(34, 48, 570, 362, cgs.media.binocularStatic);
}
- CG_DrawBinocularNumbers( power );
+ CG_DrawBinocularNumbers(power);
// Black out the area behind the battery display
- cgi_R_SetColor( colorTable[CT_DKGREY]);
- CG_DrawPic( 50, 389, 161, 16, cgs.media.whiteShader );
+ cgi_R_SetColor(colorTable[CT_DKGREY]);
+ CG_DrawPic(50, 389, 161, 16, cgs.media.whiteShader);
- if ( power )
- {
- color1[0] = sin( cg.time * 0.01f ) * 0.5f + 0.5f;
+ if (power) {
+ color1[0] = sin(cg.time * 0.01f) * 0.5f + 0.5f;
color1[0] = color1[0] * color1[0];
color1[1] = color1[0];
color1[2] = color1[0];
color1[3] = 1.0f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
- CG_DrawPic( 82, 94, 16, 16, cgs.media.binocularCircle );
+ CG_DrawPic(82, 94, 16, 16, cgs.media.binocularCircle);
}
- CG_DrawPic( 0, 0, 640, 480, cgs.media.binocularMask );
+ CG_DrawPic(0, 0, 640, 480, cgs.media.binocularMask);
- if ( power )
- {
+ if (power) {
// Flickery color
color1[0] = 0.7f + Q_flrand(-1.0f, 1.0f) * 0.1f;
color1[1] = 0.8f + Q_flrand(-1.0f, 1.0f) * 0.1f;
color1[2] = 0.7f + Q_flrand(-1.0f, 1.0f) * 0.1f;
color1[3] = 1.0f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
- CG_DrawPic( 4, 282 - level, 16, 16, cgs.media.binocularArrow );
- }
- else
- {
+ CG_DrawPic(4, 282 - level, 16, 16, cgs.media.binocularArrow);
+ } else {
// No power color
color1[0] = 0.15f;
color1[1] = 0.15f;
color1[2] = 0.15f;
color1[3] = 1.0f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
}
// The top triangle bit randomly flips when the power is on
- if ( flip && power )
- {
- CG_DrawPic( 330, 60, -26, -30, cgs.media.binocularTri );
- }
- else
- {
- CG_DrawPic( 307, 40, 26, 30, cgs.media.binocularTri );
+ if (flip && power) {
+ CG_DrawPic(330, 60, -26, -30, cgs.media.binocularTri);
+ } else {
+ CG_DrawPic(307, 40, 26, 30, cgs.media.binocularTri);
}
- if ( Q_flrand(0.0f, 1.0f) > 0.98f && ( cg.time & 1024 ))
- {
+ if (Q_flrand(0.0f, 1.0f) > 0.98f && (cg.time & 1024)) {
flip = (qboolean)!flip;
}
- if ( power )
- {
- color1[0] = 1.0f * ( charge < 0.2f ? !!(cg.time & 256) : 1 );
+ if (power) {
+ color1[0] = 1.0f * (charge < 0.2f ? !!(cg.time & 256) : 1);
color1[1] = charge * color1[0];
color1[2] = 0.0f;
color1[3] = 0.2f;
- cgi_R_SetColor( color1 );
- CG_DrawPic( 60, 394.5f, charge * 141, 5, cgs.media.whiteShader );
+ cgi_R_SetColor(color1);
+ CG_DrawPic(60, 394.5f, charge * 141, 5, cgs.media.whiteShader);
}
}
//------------
// Disruptor
//--------------------------------
- else if ( cg.zoomMode == 2 )
- {
+ else if (cg.zoomMode == 2) {
level = (float)(80.0f - cg_zoomFov) / 80.0f;
// ...so we'll clamp it
- if ( level < 0.0f )
- {
+ if (level < 0.0f) {
level = 0.0f;
- }
- else if ( level > 1.0f )
- {
+ } else if (level > 1.0f) {
level = 1.0f;
}
@@ -2196,31 +1601,29 @@ static void CG_DrawZoomMask( void )
level *= 103.0f;
// Draw target mask
- cgi_R_SetColor( colorTable[CT_WHITE] );
- CG_DrawPic( 0, 0, 640, 480, cgs.media.disruptorMask );
+ cgi_R_SetColor(colorTable[CT_WHITE]);
+ CG_DrawPic(0, 0, 640, 480, cgs.media.disruptorMask);
// apparently 99.0f is the full zoom level
- if ( level >= 99 )
- {
+ if (level >= 99) {
// Fully zoomed, so make the rotating insert pulse
color1[0] = 1.0f;
color1[1] = 1.0f;
color1[2] = 1.0f;
- color1[3] = 0.7f + sin( cg.time * 0.01f ) * 0.3f;
+ color1[3] = 0.7f + sin(cg.time * 0.01f) * 0.3f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
}
// Draw rotating insert
- CG_DrawRotatePic2( 320, 240, 640, 480, -level, cgs.media.disruptorInsert );
+ CG_DrawRotatePic2(320, 240, 640, 480, -level, cgs.media.disruptorInsert);
float cx, cy;
float max;
max = cg_entities[0].gent->client->ps.ammo[weaponData[WP_DISRUPTOR].ammoIndex] / (float)ammoData[weaponData[WP_DISRUPTOR].ammoIndex].max;
- if ( max > 1.0f )
- {
+ if (max > 1.0f) {
max = 1.0f;
}
@@ -2230,112 +1633,105 @@ static void CG_DrawZoomMask( void )
color1[3] = 1.0f;
// If we are low on ammo, make us flash
- if ( max < 0.15f && ( cg.time & 512 ))
- {
- VectorClear( color1 );
+ if (max < 0.15f && (cg.time & 512)) {
+ VectorClear(color1);
}
- if ( color1[0] > 1.0f )
- {
+ if (color1[0] > 1.0f) {
color1[0] = 1.0f;
}
- if ( color1[1] > 1.0f )
- {
+ if (color1[1] > 1.0f) {
color1[1] = 1.0f;
}
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
max *= 58.0f;
- for ( float i = 18.5f; i <= 18.5f + max; i+= 3 ) // going from 15 to 45 degrees, with 5 degree increments
+ for (float i = 18.5f; i <= 18.5f + max; i += 3) // going from 15 to 45 degrees, with 5 degree increments
{
- cx = 320 + sin( (i+90.0f)/57.296f ) * 190;
- cy = 240 + cos( (i+90.0f)/57.296f ) * 190;
+ cx = 320 + sin((i + 90.0f) / 57.296f) * 190;
+ cy = 240 + cos((i + 90.0f) / 57.296f) * 190;
- CG_DrawRotatePic2( cx, cy, 12, 24, 90 - i, cgs.media.disruptorInsertTick );
+ CG_DrawRotatePic2(cx, cy, 12, 24, 90 - i, cgs.media.disruptorInsertTick);
}
// FIXME: doesn't know about ammo!! which is bad because it draws charge beyond what ammo you may have..
- if ( cg_entities[0].gent->client->ps.weaponstate == WEAPON_CHARGING_ALT )
- {
- cgi_R_SetColor( colorTable[CT_WHITE] );
+ if (cg_entities[0].gent->client->ps.weaponstate == WEAPON_CHARGING_ALT) {
+ cgi_R_SetColor(colorTable[CT_WHITE]);
// draw the charge level
- max = ( cg.time - cg_entities[0].gent->client->ps.weaponChargeTime ) / ( 150.0f * 10.0f ); // bad hardcodedness 150 is disruptor charge unit and 10 is max charge units allowed.
+ max = (cg.time - cg_entities[0].gent->client->ps.weaponChargeTime) /
+ (150.0f * 10.0f); // bad hardcodedness 150 is disruptor charge unit and 10 is max charge units allowed.
- if ( max > 1.0f )
- {
+ if (max > 1.0f) {
max = 1.0f;
}
- CG_DrawPic2( 257, 435, 134 * max, 34, 0,0,max,1,cgi_R_RegisterShaderNoMip( "gfx/2d/crop_charge" ));
+ CG_DrawPic2(257, 435, 134 * max, 34, 0, 0, max, 1, cgi_R_RegisterShaderNoMip("gfx/2d/crop_charge"));
}
}
//-----------
// Light Amp
//--------------------------------
- else if ( cg.zoomMode == 3 )
- {
- CG_RegisterItemVisuals( ITM_LA_GOGGLES_PICKUP );
+ else if (cg.zoomMode == 3) {
+ CG_RegisterItemVisuals(ITM_LA_GOGGLES_PICKUP);
- if ( power )
- {
- cgi_R_SetColor( colorTable[CT_WHITE] );
- CG_DrawPic( 34, 29, 580, 410, cgs.media.laGogglesStatic );
+ if (power) {
+ cgi_R_SetColor(colorTable[CT_WHITE]);
+ CG_DrawPic(34, 29, 580, 410, cgs.media.laGogglesStatic);
- CG_DrawPic( 570, 140, 12, 160, cgs.media.laGogglesSideBit );
+ CG_DrawPic(570, 140, 12, 160, cgs.media.laGogglesSideBit);
- float light = (128-cent->gent->lightLevel) * 0.5f;
+ float light = (128 - cent->gent->lightLevel) * 0.5f;
- if ( light < -81 ) // saber can really jack up local light levels....?magic number??
+ if (light < -81) // saber can really jack up local light levels....?magic number??
{
light = -81;
}
float pos1 = 220 + light;
- float pos2 = 220 + cos( cg.time * 0.0004f + light * 0.05f ) * 40 + sin( cg.time * 0.0013f + 1 ) * 20 + sin( cg.time * 0.0021f ) * 5;
+ float pos2 = 220 + cos(cg.time * 0.0004f + light * 0.05f) * 40 + sin(cg.time * 0.0013f + 1) * 20 + sin(cg.time * 0.0021f) * 5;
// Flickery color
color1[0] = 0.7f + Q_flrand(-1.0f, 1.0f) * 0.2f;
color1[1] = 0.8f + Q_flrand(-1.0f, 1.0f) * 0.2f;
color1[2] = 0.7f + Q_flrand(-1.0f, 1.0f) * 0.2f;
color1[3] = 1.0f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
- CG_DrawPic( 565, pos1, 22, 8, cgs.media.laGogglesBracket );
- CG_DrawPic( 558, pos2, 14, 5, cgs.media.laGogglesArrow );
+ CG_DrawPic(565, pos1, 22, 8, cgs.media.laGogglesBracket);
+ CG_DrawPic(558, pos2, 14, 5, cgs.media.laGogglesArrow);
}
// Black out the area behind the battery display
- cgi_R_SetColor( colorTable[CT_DKGREY]);
- CG_DrawPic( 236, 357, 164, 16, cgs.media.whiteShader );
+ cgi_R_SetColor(colorTable[CT_DKGREY]);
+ CG_DrawPic(236, 357, 164, 16, cgs.media.whiteShader);
- if ( power )
- {
+ if (power) {
// Power bar
- color1[0] = 1.0f * ( charge < 0.2f ? !!(cg.time & 256) : 1 );
+ color1[0] = 1.0f * (charge < 0.2f ? !!(cg.time & 256) : 1);
color1[1] = charge * color1[0];
color1[2] = 0.0f;
color1[3] = 0.4f;
- cgi_R_SetColor( color1 );
- CG_DrawPic( 247.0f, 362.5f, charge * 143.0f, 6, cgs.media.whiteShader );
+ cgi_R_SetColor(color1);
+ CG_DrawPic(247.0f, 362.5f, charge * 143.0f, 6, cgs.media.whiteShader);
// pulsing dot bit
- color1[0] = sin( cg.time * 0.01f ) * 0.5f + 0.5f;
+ color1[0] = sin(cg.time * 0.01f) * 0.5f + 0.5f;
color1[0] = color1[0] * color1[0];
color1[1] = color1[0];
color1[2] = color1[0];
color1[3] = 1.0f;
- cgi_R_SetColor( color1 );
+ cgi_R_SetColor(color1);
- CG_DrawPic( 65, 94, 16, 16, cgs.media.binocularCircle );
+ CG_DrawPic(65, 94, 16, 16, cgs.media.binocularCircle);
}
- CG_DrawPic( 0, 0, 640, 480, cgs.media.laGogglesMask );
+ CG_DrawPic(0, 0, 640, 480, cgs.media.laGogglesMask);
}
}
@@ -2345,20 +1741,18 @@ CG_DrawStats
================
*/
-static void CG_DrawStats( void )
-{
- centity_t *cent;
+static void CG_DrawStats(void) {
+ centity_t *cent;
- if ( cg_drawStatus.integer == 0 ) {
+ if (cg_drawStatus.integer == 0) {
return;
}
cent = &cg_entities[cg.snap->ps.clientNum];
- if ((cg.snap->ps.viewEntity>0&&cg.snap->ps.viewEntityps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD)) {
// MIGHT try and draw a custom hud if it wants...
- CG_DrawCustomHealthHud( cent );
+ CG_DrawCustomHealthHud(cent);
return;
}
@@ -2366,165 +1760,142 @@ static void CG_DrawStats( void )
qboolean drawHud = qtrue;
- if ( cent && cent->gent )
- {
- drawHud = CG_DrawCustomHealthHud( cent );
+ if (cent && cent->gent) {
+ drawHud = CG_DrawCustomHealthHud(cent);
}
- if (( drawHud ) && ( cg_drawHUD.integer ))
- {
- CG_DrawHUD( cent );
+ if ((drawHud) && (cg_drawHUD.integer)) {
+ CG_DrawHUD(cent);
}
}
-
/*
===================
CG_DrawPickupItem
===================
*/
-static void CG_DrawPickupItem( void ) {
- int value;
- float *fadeColor;
+static void CG_DrawPickupItem(void) {
+ int value;
+ float *fadeColor;
value = cg.itemPickup;
- if ( value && cg_items[ value ].icon != -1 )
- {
- fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 );
- if ( fadeColor )
- {
- CG_RegisterItemVisuals( value );
- cgi_R_SetColor( fadeColor );
- CG_DrawPic( 573, 320, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );
- //CG_DrawBigString( ICON_SIZE + 16, 398, bg_itemlist[ value ].classname, fadeColor[0] );
- //CG_DrawProportionalString( ICON_SIZE + 16, 398,
+ if (value && cg_items[value].icon != -1) {
+ fadeColor = CG_FadeColor(cg.itemPickupTime, 3000);
+ if (fadeColor) {
+ CG_RegisterItemVisuals(value);
+ cgi_R_SetColor(fadeColor);
+ CG_DrawPic(573, 320, ICON_SIZE, ICON_SIZE, cg_items[value].icon);
+ // CG_DrawBigString( ICON_SIZE + 16, 398, bg_itemlist[ value ].classname, fadeColor[0] );
+ // CG_DrawProportionalString( ICON_SIZE + 16, 398,
// bg_itemlist[ value ].classname, CG_SMALLFONT,fadeColor );
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
}
}
-void CMD_CGCam_Disable( void );
+void CMD_CGCam_Disable(void);
/*
===================
CG_DrawPickupItem
===================
*/
-void CG_DrawCredits(void)
-{
- if (!cg.creditsStart)
- {
+void CG_DrawCredits(void) {
+ if (!cg.creditsStart) {
//
cg.creditsStart = qtrue;
CG_Credits_Init("CREDITS_RAVEN", &colorTable[CT_ICON_BLUE]);
- if ( cg_skippingcin.integer )
- {//Were skipping a cinematic and it's over now
+ if (cg_skippingcin.integer) { // Were skipping a cinematic and it's over now
gi.cvar_set("timescale", "1");
gi.cvar_set("skippingCinematic", "0");
}
}
-
- if (cg.creditsStart)
- {
- if ( !CG_Credits_Running() )
- {
- cgi_Cvar_Set( "cg_endcredits", "0" );
+ if (cg.creditsStart) {
+ if (!CG_Credits_Running()) {
+ cgi_Cvar_Set("cg_endcredits", "0");
CMD_CGCam_Disable();
cgi_SendConsoleCommand("disconnect\n");
}
}
}
-//draw the health bar based on current "health" and maxhealth
-void CG_DrawHealthBar(centity_t *cent, float chX, float chY, float chW, float chH)
-{
+// draw the health bar based on current "health" and maxhealth
+void CG_DrawHealthBar(centity_t *cent, float chX, float chY, float chW, float chH) {
vec4_t aColor;
vec4_t cColor;
- float x = chX-(chW/2);
- float y = chY-chH;
+ float x = chX - (chW / 2);
+ float y = chY - chH;
float percent = 0.0f;
- if ( !cent || !cent->gent )
- {
+ if (!cent || !cent->gent) {
return;
}
- percent = ((float)cent->gent->health/(float)cent->gent->max_health);
- if (percent <= 0)
- {
+ percent = ((float)cent->gent->health / (float)cent->gent->max_health);
+ if (percent <= 0) {
return;
}
- //color of the bar
- //hostile
+ // color of the bar
+ // hostile
aColor[0] = 1.0f;
aColor[1] = 0.0f;
aColor[2] = 0.0f;
aColor[3] = 0.4f;
- //color of greyed out "missing health"
+ // color of greyed out "missing health"
cColor[0] = 0.5f;
cColor[1] = 0.5f;
cColor[2] = 0.5f;
cColor[3] = 0.4f;
- //draw the background (black)
+ // draw the background (black)
CG_DrawRect(x, y, chW, chH, 1.0f, colorTable[CT_BLACK]);
- //now draw the part to show how much health there is in the color specified
- CG_FillRect(x+1.0f, y+1.0f, (percent*chW)-1.0f, chH-1.0f, aColor);
+ // now draw the part to show how much health there is in the color specified
+ CG_FillRect(x + 1.0f, y + 1.0f, (percent * chW) - 1.0f, chH - 1.0f, aColor);
- //then draw the other part greyed out
- CG_FillRect(x+(percent*chW), y+1.0f, chW-(percent*chW)-1.0f, chH-1.0f, cColor);
+ // then draw the other part greyed out
+ CG_FillRect(x + (percent * chW), y + 1.0f, chW - (percent * chW) - 1.0f, chH - 1.0f, cColor);
}
#define MAX_HEALTH_BAR_ENTS 32
int cg_numHealthBarEnts = 0;
int cg_healthBarEnts[MAX_HEALTH_BAR_ENTS];
-#define HEALTH_BAR_WIDTH 50
-#define HEALTH_BAR_HEIGHT 5
+#define HEALTH_BAR_WIDTH 50
+#define HEALTH_BAR_HEIGHT 5
-void CG_DrawHealthBars( void )
-{
- float chX=0, chY=0;
+void CG_DrawHealthBars(void) {
+ float chX = 0, chY = 0;
centity_t *cent;
vec3_t pos;
- for ( int i = 0; i < cg_numHealthBarEnts; i++ )
- {
+ for (int i = 0; i < cg_numHealthBarEnts; i++) {
cent = &cg_entities[cg_healthBarEnts[i]];
- if ( cent && cent->gent )
- {
- VectorCopy( cent->lerpOrigin, pos );
- pos[2] += cent->gent->maxs[2]+HEALTH_BAR_HEIGHT+8;
- if ( CG_WorldCoordToScreenCoordFloat( pos, &chX, &chY ) )
- {//on screen
- CG_DrawHealthBar( cent, chX, chY, HEALTH_BAR_WIDTH, HEALTH_BAR_HEIGHT );
+ if (cent && cent->gent) {
+ VectorCopy(cent->lerpOrigin, pos);
+ pos[2] += cent->gent->maxs[2] + HEALTH_BAR_HEIGHT + 8;
+ if (CG_WorldCoordToScreenCoordFloat(pos, &chX, &chY)) { // on screen
+ CG_DrawHealthBar(cent, chX, chY, HEALTH_BAR_WIDTH, HEALTH_BAR_HEIGHT);
}
}
}
}
#define HEALTHBARRANGE 422
-void CG_AddHealthBarEnt( int entNum )
-{
- if ( cg_numHealthBarEnts >= MAX_HEALTH_BAR_ENTS )
- {//FIXME: Debug error message?
+void CG_AddHealthBarEnt(int entNum) {
+ if (cg_numHealthBarEnts >= MAX_HEALTH_BAR_ENTS) { // FIXME: Debug error message?
return;
}
- if (DistanceSquared( cg_entities[entNum].lerpOrigin, g_entities[0].client->renderInfo.eyePoint ) < (HEALTHBARRANGE*HEALTHBARRANGE) )
- {
+ if (DistanceSquared(cg_entities[entNum].lerpOrigin, g_entities[0].client->renderInfo.eyePoint) < (HEALTHBARRANGE * HEALTHBARRANGE)) {
cg_healthBarEnts[cg_numHealthBarEnts++] = entNum;
}
}
-void CG_ClearHealthBarEnts( void )
-{
- if ( cg_numHealthBarEnts )
- {
+void CG_ClearHealthBarEnts(void) {
+ if (cg_numHealthBarEnts) {
cg_numHealthBarEnts = 0;
- memset( &cg_healthBarEnts, 0, sizeof(cg_healthBarEnts) );
+ memset(&cg_healthBarEnts, 0, sizeof(cg_healthBarEnts));
}
}
/*
@@ -2535,190 +1906,147 @@ CROSSHAIR
================================================================================
*/
-
/*
=================
CG_DrawCrosshair
=================
*/
-static void CG_DrawCrosshair( vec3_t worldPoint )
-{
- float w, h;
- qhandle_t hShader;
- qboolean corona = qfalse;
- vec4_t ecolor;
- float f;
- float x, y;
-
- if ( !cg_drawCrosshair.integer )
- {
+static void CG_DrawCrosshair(vec3_t worldPoint) {
+ float w, h;
+ qhandle_t hShader;
+ qboolean corona = qfalse;
+ vec4_t ecolor;
+ float f;
+ float x, y;
+
+ if (!cg_drawCrosshair.integer) {
return;
}
- if ( cg.zoomMode > 0 && cg.zoomMode < 3 )
- {
- //not while scoped
+ if (cg.zoomMode > 0 && cg.zoomMode < 3) {
+ // not while scoped
return;
}
- //set color based on what kind of ent is under crosshair
- if ( g_crosshairEntNum >= ENTITYNUM_WORLD )
- {
+ // set color based on what kind of ent is under crosshair
+ if (g_crosshairEntNum >= ENTITYNUM_WORLD) {
ecolor[0] = ecolor[1] = ecolor[2] = 1.0f;
- }
- else if ( cg_forceCrosshair && cg_crosshairForceHint.integer )
- {
+ } else if (cg_forceCrosshair && cg_crosshairForceHint.integer) {
ecolor[0] = 0.2f;
ecolor[1] = 0.5f;
ecolor[2] = 1.0f;
corona = qtrue;
- }
- else if ( cg_crosshairIdentifyTarget.integer )
- {
+ } else if (cg_crosshairIdentifyTarget.integer) {
gentity_t *crossEnt = &g_entities[g_crosshairEntNum];
- if ( crossEnt->client )
- {
- if ( crossEnt->client->ps.powerups[PW_CLOAKED] )
- {//cloaked don't show up
- ecolor[0] = 1.0f;//R
- ecolor[1] = 1.0f;//G
- ecolor[2] = 1.0f;//B
- }
- else if ( g_entities[0].client && g_entities[0].client->playerTeam == TEAM_FREE )
- {//evil player: everyone is red
- //Enemies are red
- ecolor[0] = 1.0f;//R
- ecolor[1] = 0.1f;//G
- ecolor[2] = 0.1f;//B
- }
- else if ( crossEnt->client->playerTeam == TEAM_PLAYER )
- {
- //Allies are green
- ecolor[0] = 0.0f;//R
- ecolor[1] = 1.0f;//G
- ecolor[2] = 0.0f;//B
- }
- else if ( crossEnt->client->playerTeam == TEAM_NEUTRAL )
- {
+ if (crossEnt->client) {
+ if (crossEnt->client->ps.powerups[PW_CLOAKED]) { // cloaked don't show up
+ ecolor[0] = 1.0f; // R
+ ecolor[1] = 1.0f; // G
+ ecolor[2] = 1.0f; // B
+ } else if (g_entities[0].client && g_entities[0].client->playerTeam == TEAM_FREE) { // evil player: everyone is red
+ // Enemies are red
+ ecolor[0] = 1.0f; // R
+ ecolor[1] = 0.1f; // G
+ ecolor[2] = 0.1f; // B
+ } else if (crossEnt->client->playerTeam == TEAM_PLAYER) {
+ // Allies are green
+ ecolor[0] = 0.0f; // R
+ ecolor[1] = 1.0f; // G
+ ecolor[2] = 0.0f; // B
+ } else if (crossEnt->client->playerTeam == TEAM_NEUTRAL) {
// NOTE: was yellow, but making it white unless they really decide they want to see colors
- ecolor[0] = 1.0f;//R
- ecolor[1] = 1.0f;//G
- ecolor[2] = 1.0f;//B
+ ecolor[0] = 1.0f; // R
+ ecolor[1] = 1.0f; // G
+ ecolor[2] = 1.0f; // B
+ } else {
+ // Enemies are red
+ ecolor[0] = 1.0f; // R
+ ecolor[1] = 0.1f; // G
+ ecolor[2] = 0.1f; // B
}
- else
- {
- //Enemies are red
- ecolor[0] = 1.0f;//R
- ecolor[1] = 0.1f;//G
- ecolor[2] = 0.1f;//B
- }
- }
- else if ( crossEnt->s.weapon == WP_TURRET && (crossEnt->svFlags&SVF_NONNPC_ENEMY) )
- {
+ } else if (crossEnt->s.weapon == WP_TURRET && (crossEnt->svFlags & SVF_NONNPC_ENEMY)) {
// a turret
- if ( crossEnt->noDamageTeam == TEAM_PLAYER )
- {
+ if (crossEnt->noDamageTeam == TEAM_PLAYER) {
// mine are green
- ecolor[0] = 0.0;//R
- ecolor[1] = 1.0;//G
- ecolor[2] = 0.0;//B
- }
- else
- {
+ ecolor[0] = 0.0; // R
+ ecolor[1] = 1.0; // G
+ ecolor[2] = 0.0; // B
+ } else {
// hostile ones are red
- ecolor[0] = 1.0;//R
- ecolor[1] = 0.0;//G
- ecolor[2] = 0.0;//B
+ ecolor[0] = 1.0; // R
+ ecolor[1] = 0.0; // G
+ ecolor[2] = 0.0; // B
}
- }
- else if ( crossEnt->s.weapon == WP_TRIP_MINE )
- {
+ } else if (crossEnt->s.weapon == WP_TRIP_MINE) {
// tripmines are red
- ecolor[0] = 1.0;//R
- ecolor[1] = 0.0;//G
- ecolor[2] = 0.0;//B
- }
- else if ( (crossEnt->flags&FL_RED_CROSSHAIR) )
- {//special case flagged to turn crosshair red
- ecolor[0] = 1.0;//R
- ecolor[1] = 0.0;//G
- ecolor[2] = 0.0;//B
- }
- else
- {
- VectorCopy( crossEnt->startRGBA, ecolor );
-
- if ( !ecolor[0] && !ecolor[1] && !ecolor[2] )
- {
+ ecolor[0] = 1.0; // R
+ ecolor[1] = 0.0; // G
+ ecolor[2] = 0.0; // B
+ } else if ((crossEnt->flags & FL_RED_CROSSHAIR)) { // special case flagged to turn crosshair red
+ ecolor[0] = 1.0; // R
+ ecolor[1] = 0.0; // G
+ ecolor[2] = 0.0; // B
+ } else {
+ VectorCopy(crossEnt->startRGBA, ecolor);
+
+ if (!ecolor[0] && !ecolor[1] && !ecolor[2]) {
// We don't want a black crosshair, so use white since it will show up better
- ecolor[0] = 1.0f;//R
- ecolor[1] = 1.0f;//G
- ecolor[2] = 1.0f;//B
+ ecolor[0] = 1.0f; // R
+ ecolor[1] = 1.0f; // G
+ ecolor[2] = 1.0f; // B
}
}
- }
- else // cg_crosshairIdentifyTarget is not on, so make it white
+ } else // cg_crosshairIdentifyTarget is not on, so make it white
{
ecolor[0] = ecolor[1] = ecolor[2] = 1.0f;
}
ecolor[3] = 1.0;
- cgi_R_SetColor( ecolor );
+ cgi_R_SetColor(ecolor);
- if ( cg.forceCrosshairStartTime )
- {
+ if (cg.forceCrosshairStartTime) {
// both of these calcs will fade the corona in one direction
- if ( cg.forceCrosshairEndTime )
- {
+ if (cg.forceCrosshairEndTime) {
ecolor[3] = (cg.time - cg.forceCrosshairEndTime) / 500.0f;
- }
- else
- {
+ } else {
ecolor[3] = (cg.time - cg.forceCrosshairStartTime) / 300.0f;
}
// clamp
- if ( ecolor[3] < 0 )
- {
+ if (ecolor[3] < 0) {
ecolor[3] = 0;
- }
- else if ( ecolor[3] > 1.0f )
- {
+ } else if (ecolor[3] > 1.0f) {
ecolor[3] = 1.0f;
}
- if ( !cg.forceCrosshairEndTime )
- {
+ if (!cg.forceCrosshairEndTime) {
// but for the other direction, we'll need to reverse it
ecolor[3] = 1.0f - ecolor[3];
}
}
- if ( corona ) // we are pointing at a crosshair item
+ if (corona) // we are pointing at a crosshair item
{
- if ( !cg.forceCrosshairStartTime )
- {
+ if (!cg.forceCrosshairStartTime) {
// must have just happened because we are not fading in yet...start it now
cg.forceCrosshairStartTime = cg.time;
cg.forceCrosshairEndTime = 0;
}
- if ( cg.forceCrosshairEndTime )
- {
+ if (cg.forceCrosshairEndTime) {
// must have just gone over a force thing again...and we were in the process of fading out. Set fade in level to the level where the fade left off
- cg.forceCrosshairStartTime = cg.time - ( 1.0f - ecolor[3] ) * 300.0f;
+ cg.forceCrosshairStartTime = cg.time - (1.0f - ecolor[3]) * 300.0f;
cg.forceCrosshairEndTime = 0;
}
- }
- else // not pointing at a crosshair item
+ } else // not pointing at a crosshair item
{
- if ( cg.forceCrosshairStartTime && !cg.forceCrosshairEndTime ) // were currently fading in
+ if (cg.forceCrosshairStartTime && !cg.forceCrosshairEndTime) // were currently fading in
{
// must fade back out, but we will have to set the fadeout time to be equal to the current level of faded-in-edness
cg.forceCrosshairEndTime = cg.time - ecolor[3] * 500.0f;
}
- if ( cg.forceCrosshairEndTime && cg.time - cg.forceCrosshairEndTime > 500.0f ) // not pointing at anything and fade out is totally done
+ if (cg.forceCrosshairEndTime && cg.time - cg.forceCrosshairEndTime > 500.0f) // not pointing at anything and fade out is totally done
{
// reset everything
cg.forceCrosshairStartTime = 0;
@@ -2730,65 +2058,49 @@ static void CG_DrawCrosshair( vec3_t worldPoint )
// pulse the size of the crosshair when picking up items
f = cg.time - cg.itemPickupBlendTime;
- if ( f > 0 && f < ITEM_BLOB_TIME ) {
+ if (f > 0 && f < ITEM_BLOB_TIME) {
f /= ITEM_BLOB_TIME;
- w *= ( 1 + f );
- h *= ( 1 + f );
+ w *= (1 + f);
+ h *= (1 + f);
}
- if ( worldPoint && VectorLength( worldPoint ) )
- {
- if ( !CG_WorldCoordToScreenCoordFloat( worldPoint, &x, &y ) )
- {//off screen, don't draw it
- cgi_R_SetColor( NULL );
+ if (worldPoint && VectorLength(worldPoint)) {
+ if (!CG_WorldCoordToScreenCoordFloat(worldPoint, &x, &y)) { // off screen, don't draw it
+ cgi_R_SetColor(NULL);
return;
}
- x -= 320;//????
- y -= 240;//????
- }
- else
- {
+ x -= 320; //????
+ y -= 240; //????
+ } else {
x = cg_crosshairX.integer;
y = cg_crosshairY.integer;
}
- if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {
- if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname ))
- {
+ if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) {
+ if (!Q_stricmp("misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname)) {
// draws a custom crosshair that is twice as large as normal
- cgi_R_DrawStretchPic( x + cg.refdef.x + 320 - w,
- y + cg.refdef.y + 240 - h,
- w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader );
-
+ cgi_R_DrawStretchPic(x + cg.refdef.x + 320 - w, y + cg.refdef.y + 240 - h, w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader);
}
- }
- else
- {
- hShader = cgs.media.crosshairShader[ cg_drawCrosshair.integer % NUM_CROSSHAIRS ];
+ } else {
+ hShader = cgs.media.crosshairShader[cg_drawCrosshair.integer % NUM_CROSSHAIRS];
- cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (640 - w),
- y + cg.refdef.y + 0.5 * (480 - h),
- w, h, 0, 0, 1, 1, hShader );
+ cgi_R_DrawStretchPic(x + cg.refdef.x + 0.5 * (640 - w), y + cg.refdef.y + 0.5 * (480 - h), w, h, 0, 0, 1, 1, hShader);
}
- if ( cg.forceCrosshairStartTime && cg_crosshairForceHint.integer ) // drawing extra bits
+ if (cg.forceCrosshairStartTime && cg_crosshairForceHint.integer) // drawing extra bits
{
- ecolor[0] = ecolor[1] = ecolor[2] = (1 - ecolor[3]) * ( sin( cg.time * 0.001f ) * 0.08f + 0.35f ); // don't draw full color
+ ecolor[0] = ecolor[1] = ecolor[2] = (1 - ecolor[3]) * (sin(cg.time * 0.001f) * 0.08f + 0.35f); // don't draw full color
ecolor[3] = 1.0f;
- cgi_R_SetColor( ecolor );
+ cgi_R_SetColor(ecolor);
w *= 2.0f;
h *= 2.0f;
- cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5f * ( 640 - w ), y + cg.refdef.y + 0.5f * ( 480 - h ),
- w, h,
- 0, 0, 1, 1,
- cgs.media.forceCoronaShader );
+ cgi_R_DrawStretchPic(x + cg.refdef.x + 0.5f * (640 - w), y + cg.refdef.y + 0.5f * (480 - h), w, h, 0, 0, 1, 1, cgs.media.forceCoronaShader);
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
/*
@@ -2796,36 +2108,35 @@ qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y)
Take any world coord and convert it to a 2D virtual 640x480 screen coord
*/
-qboolean CG_WorldCoordToScreenCoordFloat(vec3_t worldCoord, float *x, float *y)
-{
- vec3_t trans;
- float xc, yc;
- float px, py;
- float z;
+qboolean CG_WorldCoordToScreenCoordFloat(vec3_t worldCoord, float *x, float *y) {
+ vec3_t trans;
+ float xc, yc;
+ float px, py;
+ float z;
- px = tan(cg.refdef.fov_x * (M_PI / 360) );
- py = tan(cg.refdef.fov_y * (M_PI / 360) );
+ px = tan(cg.refdef.fov_x * (M_PI / 360));
+ py = tan(cg.refdef.fov_y * (M_PI / 360));
- VectorSubtract(worldCoord, cg.refdef.vieworg, trans);
+ VectorSubtract(worldCoord, cg.refdef.vieworg, trans);
- xc = 640 / 2.0;
- yc = 480 / 2.0;
+ xc = 640 / 2.0;
+ yc = 480 / 2.0;
// z = how far is the object in our forward direction
- z = DotProduct(trans, cg.refdef.viewaxis[0]);
- if (z <= 0.001)
- return qfalse;
+ z = DotProduct(trans, cg.refdef.viewaxis[0]);
+ if (z <= 0.001)
+ return qfalse;
- *x = xc - DotProduct(trans, cg.refdef.viewaxis[1])*xc/(z*px);
- *y = yc - DotProduct(trans, cg.refdef.viewaxis[2])*yc/(z*py);
+ *x = xc - DotProduct(trans, cg.refdef.viewaxis[1]) * xc / (z * px);
+ *y = yc - DotProduct(trans, cg.refdef.viewaxis[2]) * yc / (z * py);
- return qtrue;
+ return qtrue;
}
-qboolean CG_WorldCoordToScreenCoord( vec3_t worldCoord, int *x, int *y ) {
+qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y) {
float xF, yF;
- if ( CG_WorldCoordToScreenCoordFloat( worldCoord, &xF, &yF ) ) {
+ if (CG_WorldCoordToScreenCoordFloat(worldCoord, &xF, &yF)) {
*x = (int)xF;
*y = (int)yF;
return qtrue;
@@ -2836,74 +2147,62 @@ qboolean CG_WorldCoordToScreenCoord( vec3_t worldCoord, int *x, int *y ) {
// I'm keeping the rocket tracking code separate for now since I may want to do different logic...but it still uses trace info from scanCrosshairEnt
//-----------------------------------------
-static void CG_ScanForRocketLock( void )
+static void CG_ScanForRocketLock(void)
//-----------------------------------------
{
- gentity_t *traceEnt;
+ gentity_t *traceEnt;
static qboolean tempLock = qfalse; // this will break if anything else uses this locking code ( other than the player )
traceEnt = &g_entities[g_crosshairEntNum];
- if ( !traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET ) || !traceEnt->health
- || ( traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_CLOAKED] ))
- {
+ if (!traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET) ||
+ !traceEnt->health || (traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_CLOAKED])) {
// see how much locking we have
- int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f );
+ int dif = (cg.time - g_rocketLockTime) / (1200.0f / 8.0f);
// 8 is full locking....also if we just traced onto the world,
// give them 1/2 second of slop before dropping the lock
- if ( dif < 8 && g_rocketSlackTime + 500 < cg.time )
- {
+ if (dif < 8 && g_rocketSlackTime + 500 < cg.time) {
// didn't have a full lock and not in grace period, so drop the lock
g_rocketLockTime = 0;
g_rocketSlackTime = 0;
tempLock = qfalse;
}
- if ( g_rocketSlackTime + 500 >= cg.time && g_rocketLockEntNum < ENTITYNUM_WORLD )
- {
+ if (g_rocketSlackTime + 500 >= cg.time && g_rocketLockEntNum < ENTITYNUM_WORLD) {
// were locked onto an ent, aren't right now.....but still within the slop grace period
// keep the current lock amount
g_rocketLockTime += cg.frametime;
}
- if ( !tempLock && g_rocketLockEntNum < ENTITYNUM_WORLD && dif >= 8 )
- {
+ if (!tempLock && g_rocketLockEntNum < ENTITYNUM_WORLD && dif >= 8) {
tempLock = qtrue;
- if ( g_rocketLockTime + 1200 < cg.time )
- {
+ if (g_rocketLockTime + 1200 < cg.time) {
g_rocketLockTime = cg.time - 1200; // doh, hacking the time so the targetting still gets drawn full
}
}
// keep locking to this thing for one second after it gets out of view
- if ( g_rocketLockTime + 2000.0f < cg.time ) // since time was hacked above, I'm compensating so that 2000ms is really only 1000ms
+ if (g_rocketLockTime + 2000.0f < cg.time) // since time was hacked above, I'm compensating so that 2000ms is really only 1000ms
{
// too bad, you had your chance
g_rocketLockEntNum = ENTITYNUM_NONE;
g_rocketSlackTime = 0;
g_rocketLockTime = 0;
}
- }
- else
- {
+ } else {
tempLock = qfalse;
- if ( g_rocketLockEntNum >= ENTITYNUM_WORLD )
- {
- if ( g_rocketSlackTime + 500 < cg.time )
- {
+ if (g_rocketLockEntNum >= ENTITYNUM_WORLD) {
+ if (g_rocketSlackTime + 500 < cg.time) {
// we just locked onto something, start the lock at the current time
g_rocketLockEntNum = g_crosshairEntNum;
g_rocketLockTime = cg.time;
g_rocketSlackTime = cg.time;
}
- }
- else
- {
- if ( g_rocketLockEntNum != g_crosshairEntNum )
- {
+ } else {
+ if (g_rocketLockEntNum != g_crosshairEntNum) {
g_rocketLockTime = cg.time;
}
@@ -2919,110 +2218,88 @@ static void CG_ScanForRocketLock( void )
CG_ScanForCrosshairEntity
=================
*/
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
extern float forcePushPullRadius[];
-static void CG_ScanForCrosshairEntity( qboolean scanAll )
-{
- trace_t trace;
- gentity_t *traceEnt = NULL;
- vec3_t start, end;
- int content;
- int ignoreEnt = cg.snap->ps.clientNum;
+static void CG_ScanForCrosshairEntity(qboolean scanAll) {
+ trace_t trace;
+ gentity_t *traceEnt = NULL;
+ vec3_t start, end;
+ int content;
+ int ignoreEnt = cg.snap->ps.clientNum;
Vehicle_t *pVeh = NULL;
- //FIXME: debounce this to about 10fps?
+ // FIXME: debounce this to about 10fps?
cg_forceCrosshair = qfalse;
- if ( cg_entities[0].gent && cg_entities[0].gent->client ) // <-Mike said it should always do this //if (cg_crosshairForceHint.integer &&
- {//try to check for force-affectable stuff first
+ if (cg_entities[0].gent && cg_entities[0].gent->client) // <-Mike said it should always do this //if (cg_crosshairForceHint.integer &&
+ { // try to check for force-affectable stuff first
vec3_t d_f, d_rt, d_up;
// If you're riding a vehicle and not being drawn.
- if ( ( pVeh = G_IsRidingVehicle( cg_entities[0].gent ) ) != NULL && cg_entities[0].currentState.eFlags & EF_NODRAW )
- {
- VectorCopy( cg_entities[pVeh->m_pParentEntity->s.number].lerpOrigin, start );
- AngleVectors( cg_entities[pVeh->m_pParentEntity->s.number].lerpAngles, d_f, d_rt, d_up );
- }
- else
- {
- VectorCopy( g_entities[0].client->renderInfo.eyePoint, start );
- AngleVectors( cg_entities[0].lerpAngles, d_f, d_rt, d_up );
+ if ((pVeh = G_IsRidingVehicle(cg_entities[0].gent)) != NULL && cg_entities[0].currentState.eFlags & EF_NODRAW) {
+ VectorCopy(cg_entities[pVeh->m_pParentEntity->s.number].lerpOrigin, start);
+ AngleVectors(cg_entities[pVeh->m_pParentEntity->s.number].lerpAngles, d_f, d_rt, d_up);
+ } else {
+ VectorCopy(g_entities[0].client->renderInfo.eyePoint, start);
+ AngleVectors(cg_entities[0].lerpAngles, d_f, d_rt, d_up);
}
- VectorMA( start, 2048, d_f, end );//4028 is max for mind trick
+ VectorMA(start, 2048, d_f, end); // 4028 is max for mind trick
- //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James.
- gi.trace( &trace, start, vec3_origin, vec3_origin, end,
- ignoreEnt, MASK_OPAQUE|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM|CONTENTS_TERRAIN, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too...
+ // YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James.
+ gi.trace(&trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE | CONTENTS_SHOTCLIP | CONTENTS_BODY | CONTENTS_ITEM | CONTENTS_TERRAIN,
+ G2_NOCOLLIDE, 10); // ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys
+ // aren't shown, could just remove their body earlier too...
- if ( trace.entityNum < ENTITYNUM_WORLD )
- {//hit something
+ if (trace.entityNum < ENTITYNUM_WORLD) { // hit something
traceEnt = &g_entities[trace.entityNum];
- if ( traceEnt )
- {
+ if (traceEnt) {
// Check for mind trickable-guys
- if ( traceEnt->client )
- {//is a client
- if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_TELEPATHY] && traceEnt->health > 0 && VALIDSTRING(traceEnt->behaviorSet[BSET_MINDTRICK]) )
- {//I have the ability to mind-trick and he is alive and he has a mind trick script
- //NOTE: no need to check range since it's always 2048
+ if (traceEnt->client) { // is a client
+ if (cg_entities[0].gent->client->ps.forcePowerLevel[FP_TELEPATHY] && traceEnt->health > 0 &&
+ VALIDSTRING(traceEnt->behaviorSet[BSET_MINDTRICK])) { // I have the ability to mind-trick and he is alive and he has a mind trick script
+ // NOTE: no need to check range since it's always 2048
cg_forceCrosshair = qtrue;
}
}
// No? Check for force-push/pullable doors and func_statics
- else if ( traceEnt->s.eType == ET_MOVER )
- {//hit a mover
- if ( !Q_stricmp( "func_door", traceEnt->classname ) )
- {//it's a func_door
- if ( traceEnt->spawnflags & 2/*MOVER_FORCE_ACTIVATE*/ )
- {//it's force-usable
- if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] || cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH] )
- {//player has push or pull
+ else if (traceEnt->s.eType == ET_MOVER) { // hit a mover
+ if (!Q_stricmp("func_door", traceEnt->classname)) { // it's a func_door
+ if (traceEnt->spawnflags & 2 /*MOVER_FORCE_ACTIVATE*/) { // it's force-usable
+ if (cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] ||
+ cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]) { // player has push or pull
float maxRange;
- if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] > cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH] )
- {//use the better range
+ if (cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] >
+ cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]) { // use the better range
maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]];
- }
- else
- {//use the better range
+ } else { // use the better range
maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]];
}
- if ( maxRange >= trace.fraction * 2048 )
- {//actually close enough to use one of our force powers on it
+ if (maxRange >= trace.fraction * 2048) { // actually close enough to use one of our force powers on it
cg_forceCrosshair = qtrue;
}
}
}
- }
- else if ( !Q_stricmp( "func_static", traceEnt->classname ) )
- {//it's a func_static
- if ( (traceEnt->spawnflags & 1/*F_PUSH*/) && (traceEnt->spawnflags & 2/*F_PULL*/) )
- {//push or pullable
+ } else if (!Q_stricmp("func_static", traceEnt->classname)) { // it's a func_static
+ if ((traceEnt->spawnflags & 1 /*F_PUSH*/) && (traceEnt->spawnflags & 2 /*F_PULL*/)) { // push or pullable
float maxRange;
- if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] > cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH] )
- {//use the better range
+ if (cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] >
+ cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]) { // use the better range
maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]];
- }
- else
- {//use the better range
+ } else { // use the better range
maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]];
}
- if ( maxRange >= trace.fraction * 2048 )
- {//actually close enough to use one of our force powers on it
+ if (maxRange >= trace.fraction * 2048) { // actually close enough to use one of our force powers on it
cg_forceCrosshair = qtrue;
}
- }
- else if ( (traceEnt->spawnflags & 1/*F_PUSH*/) )
- {//pushable only
- if ( forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]] >= trace.fraction * 2048 )
- {//actually close enough to use force push on it
+ } else if ((traceEnt->spawnflags & 1 /*F_PUSH*/)) { // pushable only
+ if (forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]] >=
+ trace.fraction * 2048) { // actually close enough to use force push on it
cg_forceCrosshair = qtrue;
}
- }
- else if ( (traceEnt->spawnflags & 2/*F_PULL*/) )
- {//pullable only
- if ( forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]] >= trace.fraction * 2048 )
- {//actually close enough to use force pull on it
+ } else if ((traceEnt->spawnflags & 2 /*F_PULL*/)) { // pullable only
+ if (forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]] >=
+ trace.fraction * 2048) { // actually close enough to use force pull on it
cg_forceCrosshair = qtrue;
}
}
@@ -3031,65 +2308,50 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll )
}
}
}
- if ( !cg_forceCrosshair )
- {
- if ( cg_dynamicCrosshair.integer )
- {//100% accurate
+ if (!cg_forceCrosshair) {
+ if (cg_dynamicCrosshair.integer) { // 100% accurate
vec3_t d_f, d_rt, d_up;
// If you're riding a vehicle and not being drawn.
- if ( ( pVeh = G_IsRidingVehicle( cg_entities[0].gent ) ) != NULL && cg_entities[0].currentState.eFlags & EF_NODRAW )
- {
- VectorCopy( cg_entities[pVeh->m_pParentEntity->s.number].lerpOrigin, start );
- AngleVectors( cg_entities[pVeh->m_pParentEntity->s.number].lerpAngles, d_f, d_rt, d_up );
- }
- else if ( cg.snap->ps.weapon == WP_NONE || cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_STUN_BATON )
- {
- if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {//in camera ent view
+ if ((pVeh = G_IsRidingVehicle(cg_entities[0].gent)) != NULL && cg_entities[0].currentState.eFlags & EF_NODRAW) {
+ VectorCopy(cg_entities[pVeh->m_pParentEntity->s.number].lerpOrigin, start);
+ AngleVectors(cg_entities[pVeh->m_pParentEntity->s.number].lerpAngles, d_f, d_rt, d_up);
+ } else if (cg.snap->ps.weapon == WP_NONE || cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_STUN_BATON) {
+ if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) { // in camera ent view
ignoreEnt = cg.snap->ps.viewEntity;
- if ( g_entities[cg.snap->ps.viewEntity].client )
- {
- VectorCopy( g_entities[cg.snap->ps.viewEntity].client->renderInfo.eyePoint, start );
+ if (g_entities[cg.snap->ps.viewEntity].client) {
+ VectorCopy(g_entities[cg.snap->ps.viewEntity].client->renderInfo.eyePoint, start);
+ } else {
+ VectorCopy(cg_entities[cg.snap->ps.viewEntity].lerpOrigin, start);
}
- else
- {
- VectorCopy( cg_entities[cg.snap->ps.viewEntity].lerpOrigin, start );
- }
- AngleVectors( cg_entities[cg.snap->ps.viewEntity].lerpAngles, d_f, d_rt, d_up );
- }
- else
- {
- VectorCopy( g_entities[0].client->renderInfo.eyePoint, start );
- AngleVectors( cg_entities[0].lerpAngles, d_f, d_rt, d_up );
+ AngleVectors(cg_entities[cg.snap->ps.viewEntity].lerpAngles, d_f, d_rt, d_up);
+ } else {
+ VectorCopy(g_entities[0].client->renderInfo.eyePoint, start);
+ AngleVectors(cg_entities[0].lerpAngles, d_f, d_rt, d_up);
}
+ } else {
+ extern void CalcMuzzlePoint(gentity_t *const ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint, float lead_in);
+ AngleVectors(cg_entities[0].lerpAngles, d_f, d_rt, d_up);
+ CalcMuzzlePoint(&g_entities[0], d_f, d_rt, d_up, start, 0);
}
- else
- {
- extern void CalcMuzzlePoint( gentity_t *const ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint, float lead_in );
- AngleVectors( cg_entities[0].lerpAngles, d_f, d_rt, d_up );
- CalcMuzzlePoint( &g_entities[0], d_f, d_rt, d_up, start , 0 );
- }
- //VectorCopy( g_entities[0].client->renderInfo.muzzlePoint, start );
- //FIXME: increase this? Increase when zoom in?
- VectorMA( start, 4096, d_f, end );//was 8192
- }
- else
- {//old way
- VectorCopy( cg.refdef.vieworg, start );
- //FIXME: increase this? Increase when zoom in?
- VectorMA( start, 131072, cg.refdef.viewaxis[0], end );//was 8192
- }
- //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James.
- gi.trace( &trace, start, vec3_origin, vec3_origin, end,
- ignoreEnt, MASK_OPAQUE|CONTENTS_TERRAIN|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too...
+ // VectorCopy( g_entities[0].client->renderInfo.muzzlePoint, start );
+ // FIXME: increase this? Increase when zoom in?
+ VectorMA(start, 4096, d_f, end); // was 8192
+ } else { // old way
+ VectorCopy(cg.refdef.vieworg, start);
+ // FIXME: increase this? Increase when zoom in?
+ VectorMA(start, 131072, cg.refdef.viewaxis[0], end); // was 8192
+ }
+ // YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James.
+ gi.trace(&trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE | CONTENTS_TERRAIN | CONTENTS_SHOTCLIP | CONTENTS_BODY | CONTENTS_ITEM,
+ G2_NOCOLLIDE, 10); // ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys
+ // aren't shown, could just remove their body earlier too...
/*
CG_Trace( &trace, start, vec3_origin, vec3_origin, end,
cg.snap->ps.clientNum, MASK_PLAYERSOLID|CONTENTS_CORPSE|CONTENTS_ITEM );
*/
- //FIXME: pick up corpses
- if ( trace.startsolid || trace.allsolid )
- {
+ // FIXME: pick up corpses
+ if (trace.startsolid || trace.allsolid) {
// trace should not be allowed to pick up anything if it started solid. I tried actually moving the trace start back, which also worked,
// but the dynamic cursor drawing caused it to render around the clip of the gun when I pushed the blaster all the way into a wall.
// It looked quite horrible...but, if this is bad for some reason that I don't know
@@ -3099,68 +2361,54 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll )
traceEnt = &g_entities[trace.entityNum];
}
-
// if the object is "dead", don't show it
-/* if ( cg.crosshairClientNum && g_entities[cg.crosshairClientNum].health <= 0 )
- {
- cg.crosshairClientNum = 0;
- return;
- }
-*/
- //draw crosshair at endpoint
- CG_DrawCrosshair( trace.endpos );
+ /* if ( cg.crosshairClientNum && g_entities[cg.crosshairClientNum].health <= 0 )
+ {
+ cg.crosshairClientNum = 0;
+ return;
+ }
+ */
+ // draw crosshair at endpoint
+ CG_DrawCrosshair(trace.endpos);
g_crosshairEntNum = trace.entityNum;
- g_crosshairEntDist = 4096*trace.fraction;
+ g_crosshairEntDist = 4096 * trace.fraction;
- if ( !traceEnt )
- {
- //not looking at anything
+ if (!traceEnt) {
+ // not looking at anything
g_crosshairSameEntTime = 0;
g_crosshairEntTime = 0;
- }
- else
- {//looking at a valid ent
- //store the distance
- if ( trace.entityNum != g_crosshairEntNum )
- {//new crosshair ent
+ } else { // looking at a valid ent
+ // store the distance
+ if (trace.entityNum != g_crosshairEntNum) { // new crosshair ent
g_crosshairSameEntTime = 0;
- }
- else if ( g_crosshairEntDist < 256 )
- {//close enough to start counting how long you've been looking
+ } else if (g_crosshairEntDist < 256) { // close enough to start counting how long you've been looking
g_crosshairSameEntTime += cg.frametime;
}
- //remember the last time you looked at the person
+ // remember the last time you looked at the person
g_crosshairEntTime = cg.time;
}
- if ( !traceEnt )
- {
- if ( traceEnt && scanAll )
- {
- }
- else
- {
+ if (!traceEnt) {
+ if (traceEnt && scanAll) {
+ } else {
return;
}
}
// if the player is in fog, don't show it
- content = cgi_CM_PointContents( trace.endpos, 0 );
- if ( content & CONTENTS_FOG )
- {
+ content = cgi_CM_PointContents(trace.endpos, 0);
+ if (content & CONTENTS_FOG) {
return;
}
// if the player is cloaked, don't show it
- if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_CLOAKED ))
- {
+ if (cg_entities[trace.entityNum].currentState.powerups & (1 << PW_CLOAKED)) {
return;
}
// update the fade timer
- if ( cg.crosshairClientNum != trace.entityNum )
- {
+ if (cg.crosshairClientNum != trace.entityNum) {
infoStringCount = 0;
}
@@ -3168,37 +2416,32 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll )
cg.crosshairClientTime = cg.time;
}
-
/*
=====================
CG_DrawCrosshairNames
=====================
*/
-static void CG_DrawCrosshairNames( void )
-{
- qboolean scanAll = qfalse;
- centity_t *player = &cg_entities[0];
+static void CG_DrawCrosshairNames(void) {
+ qboolean scanAll = qfalse;
+ centity_t *player = &cg_entities[0];
- if ( cg_dynamicCrosshair.integer )
- {
+ if (cg_dynamicCrosshair.integer) {
// still need to scan for dynamic crosshair
- CG_ScanForCrosshairEntity( scanAll );
+ CG_ScanForCrosshairEntity(scanAll);
return;
}
- if ( !player->gent )
- {
+ if (!player->gent) {
return;
}
- if ( !player->gent->client )
- {
+ if (!player->gent->client) {
return;
}
// scan the known entities to see if the crosshair is sighted on one
// This is currently being called by the rocket tracking code, so we don't necessarily want to do duplicate traces :)
- CG_ScanForCrosshairEntity( scanAll );
+ CG_ScanForCrosshairEntity(scanAll);
}
//--------------------------------------------------------------
@@ -3206,14 +2449,13 @@ static void CG_DrawActivePowers(void)
//--------------------------------------------------------------
{
int icon_size = 40;
- int startx = icon_size*2+16;
- int starty = SCREEN_HEIGHT - icon_size*2;
+ int startx = icon_size * 2 + 16;
+ int starty = SCREEN_HEIGHT - icon_size * 2;
int endx = icon_size;
int endy = icon_size;
- if (cg.zoomMode)
- { //don't display over zoom mask
+ if (cg.zoomMode) { // don't display over zoom mask
return;
}
@@ -3238,138 +2480,113 @@ static void CG_DrawActivePowers(void)
}
*/
- //additionally, draw an icon force force rage recovery
- if (cg.snap->ps.forceRageRecoveryTime > cg.time)
- {
- CG_DrawPic( startx, starty, endx, endy, cgs.media.rageRecShader);
+ // additionally, draw an icon force force rage recovery
+ if (cg.snap->ps.forceRageRecoveryTime > cg.time) {
+ CG_DrawPic(startx, starty, endx, endy, cgs.media.rageRecShader);
}
}
//--------------------------------------------------------------
-static void CG_DrawRocketLocking( int lockEntNum, int lockTime )
+static void CG_DrawRocketLocking(int lockEntNum, int lockTime)
//--------------------------------------------------------------
{
gentity_t *gent = &g_entities[lockEntNum];
- if ( !gent )
- {
+ if (!gent) {
return;
}
- int cx, cy;
- vec3_t org;
- static int oldDif = 0;
+ int cx, cy;
+ vec3_t org;
+ static int oldDif = 0;
- VectorCopy( gent->currentOrigin, org );
+ VectorCopy(gent->currentOrigin, org);
org[2] += (gent->mins[2] + gent->maxs[2]) * 0.5f;
- if ( CG_WorldCoordToScreenCoord( org, &cx, &cy ))
- {
+ if (CG_WorldCoordToScreenCoord(org, &cx, &cy)) {
// we care about distance from enemy to eye, so this is good enough
- float sz = Distance( gent->currentOrigin, cg.refdef.vieworg ) / 1024.0f;
+ float sz = Distance(gent->currentOrigin, cg.refdef.vieworg) / 1024.0f;
- if ( cg.zoomMode > 0 )
- {
- if ( cg.overrides.active & CG_OVERRIDE_FOV )
- {
- sz -= ( cg.overrides.fov - cg_zoomFov ) / 80.0f;
- }
- else
- {
- sz -= ( cg_fov.value - cg_zoomFov ) / 80.0f;
+ if (cg.zoomMode > 0) {
+ if (cg.overrides.active & CG_OVERRIDE_FOV) {
+ sz -= (cg.overrides.fov - cg_zoomFov) / 80.0f;
+ } else {
+ sz -= (cg_fov.value - cg_zoomFov) / 80.0f;
}
}
- if ( sz > 1.0f )
- {
+ if (sz > 1.0f) {
sz = 1.0f;
- }
- else if ( sz < 0.0f )
- {
+ } else if (sz < 0.0f) {
sz = 0.0f;
}
sz = (1.0f - sz) * (1.0f - sz) * 32 + 6;
- vec4_t color={0.0f,0.0f,0.0f,0.0f};
+ vec4_t color = {0.0f, 0.0f, 0.0f, 0.0f};
cy += sz * 0.5f;
// well now, take our current lock time and divide that by 8 wedge slices to get the current lock amount
- int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f );
+ int dif = (cg.time - g_rocketLockTime) / (1200.0f / 8.0f);
- if ( dif < 0 )
- {
+ if (dif < 0) {
oldDif = 0;
return;
- }
- else if ( dif > 8 )
- {
+ } else if (dif > 8) {
dif = 8;
}
// do sounds
- if ( oldDif != dif )
- {
- if ( dif == 8 )
- {
- cgi_S_StartSound( org, 0, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/rocket/lock.wav" ));
- }
- else
- {
- cgi_S_StartSound( org, 0, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/rocket/tick.wav" ));
+ if (oldDif != dif) {
+ if (dif == 8) {
+ cgi_S_StartSound(org, 0, CHAN_AUTO, cgi_S_RegisterSound("sound/weapons/rocket/lock.wav"));
+ } else {
+ cgi_S_StartSound(org, 0, CHAN_AUTO, cgi_S_RegisterSound("sound/weapons/rocket/tick.wav"));
}
}
oldDif = dif;
- for ( int i = 0; i < dif; i++ )
- {
+ for (int i = 0; i < dif; i++) {
color[0] = 1.0f;
color[1] = 0.0f;
color[2] = 0.0f;
color[3] = 0.1f * i + 0.2f;
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
// our slices are offset by about 45 degrees.
- CG_DrawRotatePic( cx - sz, cy - sz, sz, sz, i * 45.0f, cgi_R_RegisterShaderNoMip( "gfx/2d/wedge" ));
+ CG_DrawRotatePic(cx - sz, cy - sz, sz, sz, i * 45.0f, cgi_R_RegisterShaderNoMip("gfx/2d/wedge"));
}
// we are locked and loaded baby
- if ( dif == 8 )
- {
- color[0] = color[1] = color[2] = sin( cg.time * 0.05f ) * 0.5f + 0.5f;
+ if (dif == 8) {
+ color[0] = color[1] = color[2] = sin(cg.time * 0.05f) * 0.5f + 0.5f;
color[3] = 1.0f; // this art is additive, so the alpha value does nothing
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
- CG_DrawPic( cx - sz, cy - sz * 2, sz * 2, sz * 2, cgi_R_RegisterShaderNoMip( "gfx/2d/lock" ));
+ CG_DrawPic(cx - sz, cy - sz * 2, sz * 2, sz * 2, cgi_R_RegisterShaderNoMip("gfx/2d/lock"));
}
}
}
-
//------------------------------------
-static void CG_RunRocketLocking( void )
+static void CG_RunRocketLocking(void)
//------------------------------------
{
- centity_t *player = &cg_entities[0];
+ centity_t *player = &cg_entities[0];
// Only bother with this when the player is holding down the alt-fire button of the rocket launcher
- if ( player->currentState.weapon == WP_ROCKET_LAUNCHER )
- {
- if ( player->currentState.eFlags & EF_ALT_FIRING )
- {
+ if (player->currentState.weapon == WP_ROCKET_LAUNCHER) {
+ if (player->currentState.eFlags & EF_ALT_FIRING) {
CG_ScanForRocketLock();
- if ( g_rocketLockEntNum > 0 && g_rocketLockEntNum < ENTITYNUM_WORLD && g_rocketLockTime > 0 )
- {
- CG_DrawRocketLocking( g_rocketLockEntNum, g_rocketLockTime );
+ if (g_rocketLockEntNum > 0 && g_rocketLockEntNum < ENTITYNUM_WORLD && g_rocketLockTime > 0) {
+ CG_DrawRocketLocking(g_rocketLockEntNum, g_rocketLockTime);
}
- }
- else
- {
+ } else {
// disengage any residual locking
g_rocketLockEntNum = ENTITYNUM_WORLD;
g_rocketLockTime = 0;
@@ -3382,51 +2599,46 @@ static void CG_RunRocketLocking( void )
CG_DrawIntermission
=================
*/
-static void CG_DrawIntermission( void ) {
- CG_DrawScoreboard();
-}
-
+static void CG_DrawIntermission(void) { CG_DrawScoreboard(); }
/*
==================
CG_DrawSnapshot
==================
*/
-static float CG_DrawSnapshot( float y ) {
- char *s;
- int w;
+static float CG_DrawSnapshot(float y) {
+ char *s;
+ int w;
- s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime,
- cg.latestSnapshotNum, cgs.serverCommandSequence );
+ s = va("time:%i snap:%i cmd:%i", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence);
w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f);
- cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
+ cgi_R_Font_DrawString(635 - w, y + 2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
return y + BIGCHAR_HEIGHT + 10;
}
-
/*
==================
CG_DrawFPS
==================
*/
-#define FPS_FRAMES 16
-static float CG_DrawFPS( float y ) {
- char *s;
+#define FPS_FRAMES 16
+static float CG_DrawFPS(float y) {
+ char *s;
static unsigned short previousTimes[FPS_FRAMES];
static unsigned short index;
- static int previous, lastupdate;
- int t, i, fps, total;
+ static int previous, lastupdate;
+ int t, i, fps, total;
unsigned short frameTime;
- const int xOffset = 0;
+ const int xOffset = 0;
// don't use serverTime, because that will be drifting to
// correct for internet lag changes, timescales, timedemos, etc
t = cgi_Milliseconds();
frameTime = t - previous;
previous = t;
- if (t - lastupdate > 50) //don't sample faster than this
+ if (t - lastupdate > 50) // don't sample faster than this
{
lastupdate = t;
previousTimes[index % FPS_FRAMES] = frameTime;
@@ -3434,17 +2646,17 @@ static float CG_DrawFPS( float y ) {
}
// average multiple frames together to smooth changes out a bit
total = 0;
- for ( i = 0 ; i < FPS_FRAMES ; i++ ) {
+ for (i = 0; i < FPS_FRAMES; i++) {
total += previousTimes[i];
}
- if ( !total ) {
+ if (!total) {
total = 1;
}
fps = 1000 * FPS_FRAMES / total;
- s = va( "%ifps", fps );
+ s = va("%ifps", fps);
const int w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f);
- cgi_R_Font_DrawString(635-xOffset - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
+ cgi_R_Font_DrawString(635 - xOffset - w, y + 2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
return y + BIGCHAR_HEIGHT + 10;
}
@@ -3454,10 +2666,10 @@ static float CG_DrawFPS( float y ) {
CG_DrawTimer
=================
*/
-static float CG_DrawTimer( float y ) {
- char *s;
- int w;
- int mins, seconds, tens;
+static float CG_DrawTimer(float y) {
+ char *s;
+ int w;
+ int mins, seconds, tens;
seconds = cg.time / 1000;
mins = seconds / 60;
@@ -3465,83 +2677,72 @@ static float CG_DrawTimer( float y ) {
tens = seconds / 10;
seconds -= tens * 10;
- s = va( "%i:%i%i", mins, tens, seconds );
+ s = va("%i:%i%i", mins, tens, seconds);
w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f);
- cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
+ cgi_R_Font_DrawString(635 - w, y + 2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
return y + BIGCHAR_HEIGHT + 10;
}
-
/*
=================
CG_DrawAmmoWarning
=================
*/
-static void CG_DrawAmmoWarning( void ) {
- char text[1024]={0};
- int w;
+static void CG_DrawAmmoWarning(void) {
+ char text[1024] = {0};
+ int w;
- if ( cg_drawAmmoWarning.integer == 0 ) {
+ if (cg_drawAmmoWarning.integer == 0) {
return;
}
- if ( !cg.lowAmmoWarning ) {
+ if (!cg.lowAmmoWarning) {
return;
}
- if ( weaponData[cg.snap->ps.weapon].ammoIndex == AMMO_NONE )
- {//doesn't use ammo, so no warning
+ if (weaponData[cg.snap->ps.weapon].ammoIndex == AMMO_NONE) { // doesn't use ammo, so no warning
return;
}
- if ( cg.lowAmmoWarning == 2 ) {
- cgi_SP_GetStringTextString( "SP_INGAME_INSUFFICIENTENERGY", text, sizeof(text) );
+ if (cg.lowAmmoWarning == 2) {
+ cgi_SP_GetStringTextString("SP_INGAME_INSUFFICIENTENERGY", text, sizeof(text));
} else {
return;
- //s = "LOW AMMO WARNING";
+ // s = "LOW AMMO WARNING";
}
w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
- cgi_R_Font_DrawString(320 - w/2, 64, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f);
+ cgi_R_Font_DrawString(320 - w / 2, 64, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f);
}
//---------------------------------------
-static qboolean CG_RenderingFromMiscCamera()
-{
- //centity_t *cent;
+static qboolean CG_RenderingFromMiscCamera() {
+ // centity_t *cent;
- //cent = &cg_entities[cg.snap->ps.clientNum];
+ // cent = &cg_entities[cg.snap->ps.clientNum];
- if ( cg.snap->ps.viewEntity > 0 &&
- cg.snap->ps.viewEntity < ENTITYNUM_WORLD )// cent && cent->gent && cent->gent->client && cent->gent->client->ps.viewEntity)
+ if (cg.snap->ps.viewEntity > 0 &&
+ cg.snap->ps.viewEntity < ENTITYNUM_WORLD) // cent && cent->gent && cent->gent->client && cent->gent->client->ps.viewEntity)
{
// Only check viewEntities
- if ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname ))
- {
+ if (!Q_stricmp("misc_camera", g_entities[cg.snap->ps.viewEntity].classname)) {
// Only doing a misc_camera, so check health.
- if ( g_entities[cg.snap->ps.viewEntity].health > 0 )
- {
- CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/workingCamera" ));
- }
- else
- {
- CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/brokenCamera" ));
+ if (g_entities[cg.snap->ps.viewEntity].health > 0) {
+ CG_DrawPic(0, 0, 640, 480, cgi_R_RegisterShader("gfx/2d/workingCamera"));
+ } else {
+ CG_DrawPic(0, 0, 640, 480, cgi_R_RegisterShader("gfx/2d/brokenCamera"));
}
// don't render other 2d stuff
return qtrue;
- }
- else if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname ))
- {
+ } else if (!Q_stricmp("misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname)) {
// could do a panel turret screen overlay...this is a cheesy placeholder
- CG_DrawPic( 30, 90, 128, 300, cgs.media.turretComputerOverlayShader );
- CG_DrawPic( 610, 90, -128, 300, cgs.media.turretComputerOverlayShader );
- }
- else
- {
+ CG_DrawPic(30, 90, 128, 300, cgs.media.turretComputerOverlayShader);
+ CG_DrawPic(610, 90, -128, 300, cgs.media.turretComputerOverlayShader);
+ } else {
// FIXME: make sure that this assumption is correct...because I'm assuming that I must be a droid.
- CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/droid_view" ));
+ CG_DrawPic(0, 0, 640, 480, cgi_R_RegisterShader("gfx/2d/droid_view"));
}
}
@@ -3550,26 +2751,21 @@ static qboolean CG_RenderingFromMiscCamera()
}
qboolean cg_usingInFrontOf = qfalse;
-qboolean CanUseInfrontOf(gentity_t*);
-static void CG_UseIcon()
-{
+qboolean CanUseInfrontOf(gentity_t *);
+static void CG_UseIcon() {
cg_usingInFrontOf = CanUseInfrontOf(cg_entities[cg.snap->ps.clientNum].gent);
- if (cg_usingInFrontOf)
- {
- cgi_R_SetColor( NULL );
- CG_DrawPic( 50, 285, 64, 64, cgs.media.useableHint );
+ if (cg_usingInFrontOf) {
+ cgi_R_SetColor(NULL);
+ CG_DrawPic(50, 285, 64, 64, cgs.media.useableHint);
}
}
-static void CG_Draw2DScreenTints( void )
-{
- float rageTime, rageRecTime, absorbTime, protectTime;
- vec4_t hcolor;
- //force effects
- if (cg.snap->ps.forcePowersActive & (1 << FP_RAGE))
- {
- if (!cgRageTime)
- {
+static void CG_Draw2DScreenTints(void) {
+ float rageTime, rageRecTime, absorbTime, protectTime;
+ vec4_t hcolor;
+ // force effects
+ if (cg.snap->ps.forcePowersActive & (1 << FP_RAGE)) {
+ if (!cgRageTime) {
cgRageTime = cg.time;
}
@@ -3577,12 +2773,10 @@ static void CG_Draw2DScreenTints( void )
rageTime /= 9000;
- if ( rageTime < 0 )
- {
+ if (rageTime < 0) {
rageTime = 0;
}
- if ( rageTime > 0.15f )
- {
+ if (rageTime > 0.15f) {
rageTime = 0.15f;
}
@@ -3591,82 +2785,64 @@ static void CG_Draw2DScreenTints( void )
hcolor[1] = 0;
hcolor[2] = 0;
- if (!cg.renderingThirdPerson)
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
+ if (!cg.renderingThirdPerson) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
}
cgRageFadeTime = 0;
cgRageFadeVal = 0;
- }
- else if (cgRageTime)
- {
- if (!cgRageFadeTime)
- {
+ } else if (cgRageTime) {
+ if (!cgRageFadeTime) {
cgRageFadeTime = cg.time;
cgRageFadeVal = 0.15f;
}
rageTime = cgRageFadeVal;
- cgRageFadeVal -= (cg.time - cgRageFadeTime)*0.000005;
+ cgRageFadeVal -= (cg.time - cgRageFadeTime) * 0.000005;
- if (rageTime < 0)
- {
+ if (rageTime < 0) {
rageTime = 0;
}
- if ( rageTime > 0.15f )
- {
+ if (rageTime > 0.15f) {
rageTime = 0.15f;
}
- if ( cg.snap->ps.forceRageRecoveryTime > cg.time )
- {
+ if (cg.snap->ps.forceRageRecoveryTime > cg.time) {
float checkRageRecTime = rageTime;
- if ( checkRageRecTime < 0.15f )
- {
+ if (checkRageRecTime < 0.15f) {
checkRageRecTime = 0.15f;
}
hcolor[3] = checkRageRecTime;
- hcolor[0] = rageTime*4;
- if ( hcolor[0] < 0.2f )
- {
+ hcolor[0] = rageTime * 4;
+ if (hcolor[0] < 0.2f) {
hcolor[0] = 0.2f;
}
hcolor[1] = 0.2f;
hcolor[2] = 0.2f;
- }
- else
- {
+ } else {
hcolor[3] = rageTime;
hcolor[0] = 0.7f;
hcolor[1] = 0;
hcolor[2] = 0;
}
- if (!cg.renderingThirdPerson && rageTime)
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
- }
- else
- {
- if (cg.snap->ps.forceRageRecoveryTime > cg.time)
- {
+ if (!cg.renderingThirdPerson && rageTime) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
+ } else {
+ if (cg.snap->ps.forceRageRecoveryTime > cg.time) {
hcolor[3] = 0.15f;
hcolor[0] = 0.2f;
hcolor[1] = 0.2f;
hcolor[2] = 0.2f;
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
}
cgRageTime = 0;
}
- }
- else if (cg.snap->ps.forceRageRecoveryTime > cg.time)
- {
- if (!cgRageRecTime)
- {
+ } else if (cg.snap->ps.forceRageRecoveryTime > cg.time) {
+ if (!cgRageRecTime) {
cgRageRecTime = cg.time;
}
@@ -3674,12 +2850,11 @@ static void CG_Draw2DScreenTints( void )
rageRecTime /= 9000;
- if ( rageRecTime < 0.15f )//0)
+ if (rageRecTime < 0.15f) // 0)
{
- rageRecTime = 0.15f;//0;
+ rageRecTime = 0.15f; // 0;
}
- if ( rageRecTime > 0.15f )
- {
+ if (rageRecTime > 0.15f) {
rageRecTime = 0.15f;
}
@@ -3688,32 +2863,26 @@ static void CG_Draw2DScreenTints( void )
hcolor[1] = 0.2f;
hcolor[2] = 0.2f;
- if ( !cg.renderingThirdPerson )
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
+ if (!cg.renderingThirdPerson) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
}
cgRageRecFadeTime = 0;
cgRageRecFadeVal = 0;
- }
- else if (cgRageRecTime)
- {
- if (!cgRageRecFadeTime)
- {
+ } else if (cgRageRecTime) {
+ if (!cgRageRecFadeTime) {
cgRageRecFadeTime = cg.time;
cgRageRecFadeVal = 0.15f;
}
rageRecTime = cgRageRecFadeVal;
- cgRageRecFadeVal -= (cg.time - cgRageRecFadeTime)*0.000005;
+ cgRageRecFadeVal -= (cg.time - cgRageRecFadeTime) * 0.000005;
- if (rageRecTime < 0)
- {
+ if (rageRecTime < 0) {
rageRecTime = 0;
}
- if ( rageRecTime > 0.15f )
- {
+ if (rageRecTime > 0.15f) {
rageRecTime = 0.15f;
}
@@ -3722,20 +2891,15 @@ static void CG_Draw2DScreenTints( void )
hcolor[1] = 0.2f;
hcolor[2] = 0.2f;
- if (!cg.renderingThirdPerson && rageRecTime)
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
- }
- else
- {
+ if (!cg.renderingThirdPerson && rageRecTime) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
+ } else {
cgRageRecTime = 0;
}
}
- if (cg.snap->ps.forcePowersActive & (1 << FP_ABSORB))
- {
- if (!cgAbsorbTime)
- {
+ if (cg.snap->ps.forcePowersActive & (1 << FP_ABSORB)) {
+ if (!cgAbsorbTime) {
cgAbsorbTime = cg.time;
}
@@ -3743,68 +2907,55 @@ static void CG_Draw2DScreenTints( void )
absorbTime /= 9000;
- if ( absorbTime < 0 )
- {
+ if (absorbTime < 0) {
absorbTime = 0;
}
- if ( absorbTime > 0.15f )
- {
+ if (absorbTime > 0.15f) {
absorbTime = 0.15f;
}
- hcolor[3] = absorbTime/2;
+ hcolor[3] = absorbTime / 2;
hcolor[0] = 0;
hcolor[1] = 0;
hcolor[2] = 0.7f;
- if ( !cg.renderingThirdPerson )
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
+ if (!cg.renderingThirdPerson) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
}
cgAbsorbFadeTime = 0;
cgAbsorbFadeVal = 0;
- }
- else if (cgAbsorbTime)
- {
- if (!cgAbsorbFadeTime)
- {
+ } else if (cgAbsorbTime) {
+ if (!cgAbsorbFadeTime) {
cgAbsorbFadeTime = cg.time;
cgAbsorbFadeVal = 0.15f;
}
absorbTime = cgAbsorbFadeVal;
- cgAbsorbFadeVal -= (cg.time - cgAbsorbFadeTime)*0.000005;
+ cgAbsorbFadeVal -= (cg.time - cgAbsorbFadeTime) * 0.000005;
- if ( absorbTime < 0 )
- {
+ if (absorbTime < 0) {
absorbTime = 0;
}
- if ( absorbTime > 0.15f )
- {
+ if (absorbTime > 0.15f) {
absorbTime = 0.15f;
}
- hcolor[3] = absorbTime/2;
+ hcolor[3] = absorbTime / 2;
hcolor[0] = 0;
hcolor[1] = 0;
hcolor[2] = 0.7f;
- if ( !cg.renderingThirdPerson && absorbTime )
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
- }
- else
- {
+ if (!cg.renderingThirdPerson && absorbTime) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
+ } else {
cgAbsorbTime = 0;
}
}
- if (cg.snap->ps.forcePowersActive & (1 << FP_PROTECT))
- {
- if (!cgProtectTime)
- {
+ if (cg.snap->ps.forcePowersActive & (1 << FP_PROTECT)) {
+ if (!cgProtectTime) {
cgProtectTime = cg.time;
}
@@ -3812,93 +2963,77 @@ static void CG_Draw2DScreenTints( void )
protectTime /= 9000;
- if (protectTime < 0)
- {
+ if (protectTime < 0) {
protectTime = 0;
}
- if ( protectTime > 0.15f )
- {
+ if (protectTime > 0.15f) {
protectTime = 0.15f;
}
- hcolor[3] = protectTime/2;
+ hcolor[3] = protectTime / 2;
hcolor[0] = 0;
hcolor[1] = 0.7f;
hcolor[2] = 0;
- if ( !cg.renderingThirdPerson )
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
+ if (!cg.renderingThirdPerson) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
}
cgProtectFadeTime = 0;
cgProtectFadeVal = 0;
- }
- else if ( cgProtectTime )
- {
- if ( !cgProtectFadeTime )
- {
+ } else if (cgProtectTime) {
+ if (!cgProtectFadeTime) {
cgProtectFadeTime = cg.time;
cgProtectFadeVal = 0.15f;
}
protectTime = cgProtectFadeVal;
- cgProtectFadeVal -= (cg.time - cgProtectFadeTime)*0.000005;
+ cgProtectFadeVal -= (cg.time - cgProtectFadeTime) * 0.000005;
- if (protectTime < 0)
- {
+ if (protectTime < 0) {
protectTime = 0;
}
- if (protectTime > 0.15f)
- {
+ if (protectTime > 0.15f) {
protectTime = 0.15f;
}
- hcolor[3] = protectTime/2;
+ hcolor[3] = protectTime / 2;
hcolor[0] = 0;
hcolor[1] = 0.7f;
hcolor[2] = 0;
- if ( !cg.renderingThirdPerson && protectTime )
- {
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
- }
- else
- {
+ if (!cg.renderingThirdPerson && protectTime) {
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
+ } else {
cgProtectTime = 0;
}
}
- if ( (cg.refdef.viewContents&CONTENTS_LAVA) )
- {//tint screen red
+ if ((cg.refdef.viewContents & CONTENTS_LAVA)) { // tint screen red
float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
- hcolor[3] = 0.5 + (0.15f*sin( phase ));
+ hcolor[3] = 0.5 + (0.15f * sin(phase));
hcolor[0] = 0.7f;
hcolor[1] = 0;
hcolor[2] = 0;
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
- }
- else if ( (cg.refdef.viewContents&CONTENTS_SLIME) )
- {//tint screen green
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
+ } else if ((cg.refdef.viewContents & CONTENTS_SLIME)) { // tint screen green
float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
- hcolor[3] = 0.4 + (0.1f*sin( phase ));
+ hcolor[3] = 0.4 + (0.1f * sin(phase));
hcolor[0] = 0;
hcolor[1] = 0.7f;
hcolor[2] = 0;
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
- }
- else if ( (cg.refdef.viewContents&CONTENTS_WATER) )
- {//tint screen light blue -- FIXME: check to see if in fog?
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
+ } else if ((cg.refdef.viewContents & CONTENTS_WATER)) { // tint screen light blue -- FIXME: check to see if in fog?
float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
- hcolor[3] = 0.3 + (0.05f*sin( phase ));
+ hcolor[3] = 0.3 + (0.05f * sin(phase));
hcolor[0] = 0;
hcolor[1] = 0.2f;
hcolor[2] = 0.8f;
- CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor );
+ CG_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor);
}
}
/*
@@ -3906,38 +3041,32 @@ static void CG_Draw2DScreenTints( void )
CG_Draw2D
=================
*/
-extern void CG_SaberClashFlare( void );
-static void CG_Draw2D( void )
-{
- char text[1024]={0};
- int w,y_pos;
+extern void CG_SaberClashFlare(void);
+static void CG_Draw2D(void) {
+ char text[1024] = {0};
+ int w, y_pos;
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
// if we are taking a levelshot for the menu, don't draw anything
- if ( cg.levelShot )
- {
+ if (cg.levelShot) {
return;
}
- if ( cg_draw2D.integer == 0 )
- {
+ if (cg_draw2D.integer == 0) {
return;
}
- if ( cg.snap->ps.pm_type == PM_INTERMISSION )
- {
+ if (cg.snap->ps.pm_type == PM_INTERMISSION) {
CG_DrawIntermission();
return;
}
CG_Draw2DScreenTints();
- //end credits
- if (cg_endcredits.integer)
- {
- if (!CG_Credits_Draw())
- {
- CG_DrawCredits(); // will probably get rid of this soon
+ // end credits
+ if (cg_endcredits.integer) {
+ if (!CG_Credits_Draw()) {
+ CG_DrawCredits(); // will probably get rid of this soon
}
}
@@ -3945,28 +3074,24 @@ static void CG_Draw2D( void )
CG_DrawBatteryCharge();
- if (cg.snap->ps.forcePowersActive || cg.snap->ps.forceRageRecoveryTime > cg.time)
- {
+ if (cg.snap->ps.forcePowersActive || cg.snap->ps.forceRageRecoveryTime > cg.time) {
CG_DrawActivePowers();
}
// Draw this before the text so that any text won't get clipped off
- if ( !in_camera )
- {
+ if (!in_camera) {
CG_DrawZoomMask();
}
CG_DrawScrollText();
CG_DrawCaptionText();
- if ( in_camera )
- {//still draw the saber clash flare, but nothing else
+ if (in_camera) { // still draw the saber clash flare, but nothing else
CG_SaberClashFlare();
return;
}
- if ( CG_RenderingFromMiscCamera())
- {
+ if (CG_RenderingFromMiscCamera()) {
// purposely doing an early out when in a misc_camera, change it if needed.
// allowing center print when in camera mode, probably just an alpha thing - dmv
@@ -3974,40 +3099,34 @@ static void CG_Draw2D( void )
return;
}
- if ( (cg.snap->ps.forcePowersActive&(1<ps.forcePowersActive & (1 << FP_SEE))) { // force sight is on
+ // indicate this with sight cone thingy
+ CG_DrawPic(0, 0, 640, 480, cgi_R_RegisterShader("gfx/2d/jsense"));
CG_DrawHealthBars();
- }
- else if ( cg_debugHealthBars.integer )
- {
+ } else if (cg_debugHealthBars.integer) {
CG_DrawHealthBars();
}
-
// don't draw any status if dead
- if ( cg.snap->ps.stats[STAT_HEALTH] > 0 )
- {
- if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON )))//|EF_IN_ATST
+ if (cg.snap->ps.stats[STAT_HEALTH] > 0) {
+ if (!(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON))) //|EF_IN_ATST
{
- //CG_DrawIconBackground();
+ // CG_DrawIconBackground();
}
CG_DrawWeaponSelect();
- if ( cg.zoomMode == 0 )
- {
+ if (cg.zoomMode == 0) {
CG_DrawStats();
}
CG_DrawAmmoWarning();
- //CROSSHAIR is now done from the crosshair ent trace
- //if ( !cg.renderingThirdPerson && !cg_dynamicCrosshair.integer ) // disruptor draws it's own crosshair artwork; binocs draw nothing; third person draws its own crosshair
+ // CROSSHAIR is now done from the crosshair ent trace
+ // if ( !cg.renderingThirdPerson && !cg_dynamicCrosshair.integer ) // disruptor draws it's own crosshair artwork; binocs draw nothing; third person
+ // draws its own crosshair
//{
// CG_DrawCrosshair( NULL );
- //}
-
+ // }
CG_DrawCrosshairNames();
@@ -4025,51 +3144,48 @@ static void CG_Draw2D( void )
float y = 0;
if (cg_drawSnapshot.integer) {
- y=CG_DrawSnapshot(y);
+ y = CG_DrawSnapshot(y);
}
if (cg_drawFPS.integer) {
- y=CG_DrawFPS(y);
+ y = CG_DrawFPS(y);
}
if (cg_drawTimer.integer) {
- y=CG_DrawTimer(y);
+ y = CG_DrawTimer(y);
}
// don't draw center string if scoreboard is up
- if ( !CG_DrawScoreboard() ) {
+ if (!CG_DrawScoreboard()) {
CG_DrawCenterString();
}
-/* if (cg.showInformation)
- {
-// CG_DrawMissionInformation();
- }
- else
-*/
- if (missionInfo_Updated)
- {
- if (cg.predicted_player_state.pm_type != PM_DEAD)
+ /* if (cg.showInformation)
{
+ // CG_DrawMissionInformation();
+ }
+ else
+ */
+ if (missionInfo_Updated) {
+ if (cg.predicted_player_state.pm_type != PM_DEAD) {
// Was a objective given?
-/* if ((cg_updatedDataPadForcePower.integer) || (cg_updatedDataPadObjective.integer))
- {
- // How long has the game been running? If within 15 seconds of starting, throw up the datapad.
- if (cg.dataPadLevelStartTime>cg.time)
- {
- // Make it pop up
- if (!in_camera)
- {
- cgi_SendConsoleCommand( "datapad" );
- cg.dataPadLevelStartTime=cg.time; //and don't do it again this level!
- }
- }
- }
-*/
- if (!cg.missionInfoFlashTime)
- {
- cg.missionInfoFlashTime = cg.time + cg_missionInfoFlashTime.integer;
+ /* if ((cg_updatedDataPadForcePower.integer) || (cg_updatedDataPadObjective.integer))
+ {
+ // How long has the game been running? If within 15 seconds of starting, throw up the datapad.
+ if (cg.dataPadLevelStartTime>cg.time)
+ {
+ // Make it pop up
+ if (!in_camera)
+ {
+ cgi_SendConsoleCommand( "datapad" );
+ cg.dataPadLevelStartTime=cg.time; //and don't do it again this level!
+ }
+ }
+ }
+ */
+ if (!cg.missionInfoFlashTime) {
+ cg.missionInfoFlashTime = cg.time + cg_missionInfoFlashTime.integer;
}
- if (cg.missionInfoFlashTime < cg.time) // Time's up. They didn't read it.
+ if (cg.missionInfoFlashTime < cg.time) // Time's up. They didn't read it.
{
cg.missionInfoFlashTime = 0;
missionInfo_Updated = qfalse;
@@ -4077,26 +3193,25 @@ static void CG_Draw2D( void )
CG_ClearDataPadCvars();
}
- cgi_SP_GetStringTextString( "SP_INGAME_NEW_OBJECTIVE_INFO", text, sizeof(text) );
+ cgi_SP_GetStringTextString("SP_INGAME_NEW_OBJECTIVE_INFO", text, sizeof(text));
int x_pos = 0;
y_pos = 20;
- w = cgi_R_Font_StrLenPixels(text,cgs.media.qhFontMedium, 1.0f);
- x_pos = (SCREEN_WIDTH/2)-(w/2);
- cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f);
+ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.0f);
+ x_pos = (SCREEN_WIDTH / 2) - (w / 2);
+ cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f);
}
}
- if (cg.weaponPickupTextTime > cg.time )
- {
+ if (cg.weaponPickupTextTime > cg.time) {
int x_pos = 0;
y_pos = 5;
- gi.Cvar_VariableStringBuffer( "cg_WeaponPickupText", text, sizeof(text) );
+ gi.Cvar_VariableStringBuffer("cg_WeaponPickupText", text, sizeof(text));
- w = cgi_R_Font_StrLenPixels(text,cgs.media.qhFontMedium, 0.8f);
- x_pos = (SCREEN_WIDTH/2)-(w/2);
+ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 0.8f);
+ x_pos = (SCREEN_WIDTH / 2) - (w / 2);
- cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 0.8f);
+ cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 0.8f);
}
}
@@ -4108,115 +3223,92 @@ Choose the proper background for the icons, scale it depending on if your openin
closing the icon section of the HU
===================
*/
-void CG_DrawIconBackground(void)
-{
- int backgroundXPos,backgroundYPos;
- int backgroundWidth,backgroundHeight;
- qhandle_t background;
- const float shutdownTime = 130.0f;
+void CG_DrawIconBackground(void) {
+ int backgroundXPos, backgroundYPos;
+ int backgroundWidth, backgroundHeight;
+ qhandle_t background;
+ const float shutdownTime = 130.0f;
- if ( cg_hudFiles.integer )
- { //simple hud
+ if (cg_hudFiles.integer) { // simple hud
return;
}
// Are we in zoom mode or the HUD is turned off?
- if (( cg.zoomMode != 0 ) || !( cg_drawHUD.integer ))
- {
+ if ((cg.zoomMode != 0) || !(cg_drawHUD.integer)) {
return;
}
- if ((cg.snap->ps.viewEntity>0 && cg.snap->ps.viewEntityps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD)) {
return;
}
// Get size and location of bakcround specified in the HUD.MENU file
- if (!cgi_UI_GetMenuInfo("iconbackground",&backgroundXPos,&backgroundYPos,&backgroundWidth,&backgroundHeight))
- {
+ if (!cgi_UI_GetMenuInfo("iconbackground", &backgroundXPos, &backgroundYPos, &backgroundWidth, &backgroundHeight)) {
return;
}
// Use inventory background?
- if (((cg.inventorySelectTime+WEAPON_SELECT_TIME)>cg.time) || (cgs.media.currentBackground == ICON_INVENTORY))
- {
+ if (((cg.inventorySelectTime + WEAPON_SELECT_TIME) > cg.time) || (cgs.media.currentBackground == ICON_INVENTORY)) {
background = cgs.media.inventoryIconBackground;
}
// Use weapon background?
- else if (((cg.weaponSelectTime+WEAPON_SELECT_TIME)>cg.time) || (cgs.media.currentBackground == ICON_WEAPONS))
- {
+ else if (((cg.weaponSelectTime + WEAPON_SELECT_TIME) > cg.time) || (cgs.media.currentBackground == ICON_WEAPONS)) {
background = 0;
- //background = cgs.media.weaponIconBackground;
+ // background = cgs.media.weaponIconBackground;
}
// Use force background?
- else
- {
+ else {
background = cgs.media.forceIconBackground;
}
// Time is up, shutdown the icon section of the HUD
- if ((cg.iconSelectTime+WEAPON_SELECT_TIME)1.0f)
- {
+ if (cg.iconHUDPercent > 1.0f) {
cg.iconHUDActive = qtrue;
- cg.iconHUDPercent=1.0f;
- }
- else if (cg.iconHUDPercent<0.0f)
- {
- cg.iconHUDPercent=0.0f;
+ cg.iconHUDPercent = 1.0f;
+ } else if (cg.iconHUDPercent < 0.0f) {
+ cg.iconHUDPercent = 0.0f;
}
- }
- else
- {
- cg.iconHUDPercent=1.0f;
+ } else {
+ cg.iconHUDPercent = 1.0f;
}
// Print the background
- if (background)
- {
- cgi_R_SetColor( colorTable[CT_WHITE] );
- float holdFloat = (float) backgroundHeight;
- backgroundHeight = (int) (holdFloat*cg.iconHUDPercent);
- CG_DrawPic( backgroundXPos, backgroundYPos, backgroundWidth, -backgroundHeight, background); // Top half
- CG_DrawPic( backgroundXPos, backgroundYPos,backgroundWidth, backgroundHeight, background); // Bottom half
- }
- if ((cg.inventorySelectTime+WEAPON_SELECT_TIME)>cg.time)
- {
+ if (background) {
+ cgi_R_SetColor(colorTable[CT_WHITE]);
+ float holdFloat = (float)backgroundHeight;
+ backgroundHeight = (int)(holdFloat * cg.iconHUDPercent);
+ CG_DrawPic(backgroundXPos, backgroundYPos, backgroundWidth, -backgroundHeight, background); // Top half
+ CG_DrawPic(backgroundXPos, backgroundYPos, backgroundWidth, backgroundHeight, background); // Bottom half
+ }
+ if ((cg.inventorySelectTime + WEAPON_SELECT_TIME) > cg.time) {
cgs.media.currentBackground = ICON_INVENTORY;
- }
- else if ((cg.weaponSelectTime+WEAPON_SELECT_TIME)>cg.time)
- {
+ } else if ((cg.weaponSelectTime + WEAPON_SELECT_TIME) > cg.time) {
cgs.media.currentBackground = ICON_WEAPONS;
- }
- else
- {
+ } else {
cgs.media.currentBackground = ICON_FORCE;
}
}
@@ -4228,26 +3320,26 @@ CG_DrawActive
Perform all drawing needed to completely fill the screen
=====================
*/
-void CG_DrawActive( stereoFrame_t stereoView ) {
- float separation;
- vec3_t baseOrg;
+void CG_DrawActive(stereoFrame_t stereoView) {
+ float separation;
+ vec3_t baseOrg;
// optionally draw the info screen instead
- if ( !cg.snap ) {
+ if (!cg.snap) {
CG_DrawInformation();
return;
}
- //FIXME: these globals done once at start of frame for various funcs
- AngleVectors (cg.refdefViewAngles, vfwd, vright, vup);
- VectorCopy( vfwd, vfwd_n );
- VectorCopy( vright, vright_n );
- VectorCopy( vup, vup_n );
- VectorNormalize( vfwd_n );
- VectorNormalize( vright_n );
- VectorNormalize( vup_n );
+ // FIXME: these globals done once at start of frame for various funcs
+ AngleVectors(cg.refdefViewAngles, vfwd, vright, vup);
+ VectorCopy(vfwd, vfwd_n);
+ VectorCopy(vright, vright_n);
+ VectorCopy(vup, vup_n);
+ VectorNormalize(vfwd_n);
+ VectorNormalize(vright_n);
+ VectorNormalize(vup_n);
- switch ( stereoView ) {
+ switch (stereoView) {
case STEREO_CENTER:
separation = 0;
break;
@@ -4259,41 +3351,37 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
break;
default:
separation = 0;
- CG_Error( "CG_DrawActive: Undefined stereoView" );
+ CG_Error("CG_DrawActive: Undefined stereoView");
}
-
// clear around the rendered view if sized down
CG_TileClear();
// offset vieworg appropriately if we're doing stereo separation
- VectorCopy( cg.refdef.vieworg, baseOrg );
- if ( separation != 0 ) {
- VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );
+ VectorCopy(cg.refdef.vieworg, baseOrg);
+ if (separation != 0) {
+ VectorMA(cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg);
}
- if ( cg.zoomMode == 3 && cg.snap->ps.batteryCharge ) // doing the Light amp goggles thing
+ if (cg.zoomMode == 3 && cg.snap->ps.batteryCharge) // doing the Light amp goggles thing
{
cgi_R_LAGoggles();
}
- if ( (cg.snap->ps.forcePowersActive&(1<ps.forcePowersActive & (1 << FP_SEE))) {
cg.refdef.rdflags |= RDF_ForceSightOn;
}
cg.refdef.rdflags |= RDF_DRAWSKYBOX;
// draw 3D view
- cgi_R_RenderScene( &cg.refdef );
+ cgi_R_RenderScene(&cg.refdef);
// restore original viewpoint if running stereo
- if ( separation != 0 ) {
- VectorCopy( baseOrg, cg.refdef.vieworg );
+ if (separation != 0) {
+ VectorCopy(baseOrg, cg.refdef.vieworg);
}
// draw status bar and other floating elements
CG_Draw2D();
-
}
-
diff --git a/code/cgame/cg_drawtools.cpp b/code/cgame/cg_drawtools.cpp
index a49607c12f..f17d1bb3c3 100644
--- a/code/cgame/cg_drawtools.cpp
+++ b/code/cgame/cg_drawtools.cpp
@@ -33,15 +33,15 @@ Coords are virtual 640x480
================
*/
void CG_DrawSides(float x, float y, float w, float h, float size) {
- //size *= cgs.screenXScale;
- cgi_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );
- cgi_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );
+ // size *= cgs.screenXScale;
+ cgi_R_DrawStretchPic(x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader);
+ cgi_R_DrawStretchPic(x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader);
}
void CG_DrawTopBottom(float x, float y, float w, float h, float size) {
- //size *= cgs.screenYScale;
- cgi_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader );
- cgi_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, cgs.media.whiteShader );
+ // size *= cgs.screenYScale;
+ cgi_R_DrawStretchPic(x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader);
+ cgi_R_DrawStretchPic(x, y + h - size, w, size, 0, 0, 0, 0, cgs.media.whiteShader);
}
/*
@@ -51,13 +51,13 @@ CG_DrawRect
Coordinates are 640*480 virtual values
=================
*/
-void CG_DrawRect( float x, float y, float width, float height, float size, const float *color ) {
- cgi_R_SetColor( color );
+void CG_DrawRect(float x, float y, float width, float height, float size, const float *color) {
+ cgi_R_SetColor(color);
CG_DrawTopBottom(x, y, width, height, size);
CG_DrawSides(x, y, width, height, size);
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
/*
@@ -67,13 +67,12 @@ CG_FillRect
Coordinates are 640*480 virtual values
=================
*/
-void CG_FillRect( float x, float y, float width, float height, const float *color ) {
- cgi_R_SetColor( color );
- cgi_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader);
- cgi_R_SetColor( NULL );
+void CG_FillRect(float x, float y, float width, float height, const float *color) {
+ cgi_R_SetColor(color);
+ cgi_R_DrawStretchPic(x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader);
+ cgi_R_SetColor(NULL);
}
-
/*
================
CG_Scissor
@@ -81,13 +80,7 @@ CG_Scissor
Coordinates are 640*480 virtual values
=================
*/
-void CG_Scissor( float x, float y, float width, float height)
-{
-
- cgi_R_Scissor( x, y, width, height);
-
-}
-
+void CG_Scissor(float x, float y, float width, float height) { cgi_R_Scissor(x, y, width, height); }
/*
================
@@ -97,9 +90,7 @@ Coordinates are 640*480 virtual values
A width of 0 will draw with the original image width
=================
*/
-void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) {
- cgi_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
-}
+void CG_DrawPic(float x, float y, float width, float height, qhandle_t hShader) { cgi_R_DrawStretchPic(x, y, width, height, 0, 0, 1, 1, hShader); }
/*
================
@@ -110,9 +101,8 @@ A width of 0 will draw with the original image width
Can also specify the exact texture coordinates
=================
*/
-void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader )
-{
- cgi_R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, hShader );
+void CG_DrawPic2(float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader) {
+ cgi_R_DrawStretchPic(x, y, width, height, s1, t1, s2, t2, hShader);
}
/*
@@ -124,8 +114,8 @@ A width of 0 will draw with the original image width
rotates around the upper right corner of the passed in point
=================
*/
-void CG_DrawRotatePic( float x, float y, float width, float height,float angle, qhandle_t hShader ) {
- cgi_R_DrawRotatePic( x, y, width, height, 0, 0, 1, 1, angle, hShader );
+void CG_DrawRotatePic(float x, float y, float width, float height, float angle, qhandle_t hShader) {
+ cgi_R_DrawRotatePic(x, y, width, height, 0, 0, 1, 1, angle, hShader);
}
/*
@@ -137,8 +127,8 @@ A width of 0 will draw with the original image width
Actually rotates around the center point of the passed in coordinates
=================
*/
-void CG_DrawRotatePic2( float x, float y, float width, float height,float angle, qhandle_t hShader ) {
- cgi_R_DrawRotatePic2( x, y, width, height, 0, 0, 1, 1, angle, hShader );
+void CG_DrawRotatePic2(float x, float y, float width, float height, float angle, qhandle_t hShader) {
+ cgi_R_DrawRotatePic2(x, y, width, height, 0, 0, 1, 1, angle, hShader);
}
/*
@@ -148,15 +138,15 @@ CG_DrawChar
Coordinates and size in 640*480 virtual screen size
===============
*/
-void CG_DrawChar( int x, int y, int width, int height, int ch ) {
+void CG_DrawChar(int x, int y, int width, int height, int ch) {
int row, col;
float frow, fcol;
float size;
- float ax, ay, aw, ah;
+ float ax, ay, aw, ah;
ch &= 255;
- if ( ch == ' ' ) {
+ if (ch == ' ') {
return;
}
@@ -165,32 +155,29 @@ void CG_DrawChar( int x, int y, int width, int height, int ch ) {
aw = width;
ah = height;
- row = ch>>4;
- col = ch&15;
-/*
- frow = row*0.0625;
- fcol = col*0.0625;
- size = 0.0625;
-
- cgi_R_DrawStretchPic( ax, ay, aw, ah,
- fcol, frow,
- fcol + size, frow + size,
- cgs.media.charsetShader );
-*/
+ row = ch >> 4;
+ col = ch & 15;
+ /*
+ frow = row*0.0625;
+ fcol = col*0.0625;
+ size = 0.0625;
+
+ cgi_R_DrawStretchPic( ax, ay, aw, ah,
+ fcol, frow,
+ fcol + size, frow + size,
+ cgs.media.charsetShader );
+ */
float size2;
- frow = row*0.0625;
- fcol = col*0.0625;
+ frow = row * 0.0625;
+ fcol = col * 0.0625;
size = 0.03125;
size2 = 0.0625;
- cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2,
- cgs.media.charsetShader );
-
+ cgi_R_DrawStretchPic(ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, cgs.media.charsetShader);
}
-
/*
==================
CG_DrawStringExt
@@ -201,25 +188,24 @@ to a fixed color.
Coordinates are at 640 by 480 virtual resolution
==================
*/
-void CG_DrawStringExt( int x, int y, const char *string, const float *setColor,
- qboolean forceColor, qboolean shadow, int charWidth, int charHeight ) {
- vec4_t color;
- const char *s;
- int xx;
+void CG_DrawStringExt(int x, int y, const char *string, const float *setColor, qboolean forceColor, qboolean shadow, int charWidth, int charHeight) {
+ vec4_t color;
+ const char *s;
+ int xx;
// draw the drop shadow
if (shadow) {
color[0] = color[1] = color[2] = 0;
color[3] = setColor[3];
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
s = string;
xx = x;
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
+ while (*s) {
+ if (Q_IsColorString(s)) {
s += 2;
continue;
}
- CG_DrawChar( xx + 2, y + 2, charWidth, charHeight, *s );
+ CG_DrawChar(xx + 2, y + 2, charWidth, charHeight, *s);
xx += charWidth;
s++;
}
@@ -228,28 +214,25 @@ void CG_DrawStringExt( int x, int y, const char *string, const float *setColor,
// draw the colored text
s = string;
xx = x;
- cgi_R_SetColor( setColor );
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
- if ( !forceColor ) {
- memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
+ cgi_R_SetColor(setColor);
+ while (*s) {
+ if (Q_IsColorString(s)) {
+ if (!forceColor) {
+ memcpy(color, g_color_table[ColorIndex(*(s + 1))], sizeof(color));
color[3] = setColor[3];
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
}
s += 2;
continue;
}
- CG_DrawChar( xx, y, charWidth, charHeight, *s );
+ CG_DrawChar(xx, y, charWidth, charHeight, *s);
xx += charWidth;
s++;
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
-
-void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color ) {
- CG_DrawStringExt( x, y, s, color, qtrue, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT );
-}
+void CG_DrawSmallStringColor(int x, int y, const char *s, vec4_t color) { CG_DrawStringExt(x, y, s, color, qtrue, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT); }
/*
=================
@@ -258,12 +241,12 @@ CG_DrawStrlen
Returns character count, skiping color escape codes
=================
*/
-int CG_DrawStrlen( const char *str ) {
+int CG_DrawStrlen(const char *str) {
const char *s = str;
int count = 0;
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
+ while (*s) {
+ if (Q_IsColorString(s)) {
s += 2;
} else {
count++;
@@ -282,18 +265,16 @@ This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
-static void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader ) {
- float s1, t1, s2, t2;
-
- s1 = x/64.0;
- t1 = y/64.0;
- s2 = (x+w)/64.0;
- t2 = (y+h)/64.0;
- cgi_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader );
+static void CG_TileClearBox(int x, int y, int w, int h, qhandle_t hShader) {
+ float s1, t1, s2, t2;
+
+ s1 = x / 64.0;
+ t1 = y / 64.0;
+ s2 = (x + w) / 64.0;
+ t2 = (y + h) / 64.0;
+ cgi_R_DrawStretchPic(x, y, w, h, s1, t1, s2, t2, hShader);
}
-
-
/*
==============
CG_TileClear
@@ -301,60 +282,57 @@ CG_TileClear
Clear around a sized down screen
==============
*/
-void CG_TileClear( void ) {
- int top, bottom, left, right;
- int w, h;
+void CG_TileClear(void) {
+ int top, bottom, left, right;
+ int w, h;
w = cgs.glconfig.vidWidth;
h = cgs.glconfig.vidHeight;
- if ( cg.refdef.x == 0 && cg.refdef.y == 0 &&
- cg.refdef.width == w && cg.refdef.height == h ) {
- return; // full screen rendering
+ if (cg.refdef.x == 0 && cg.refdef.y == 0 && cg.refdef.width == w && cg.refdef.height == h) {
+ return; // full screen rendering
}
top = cg.refdef.y;
- bottom = top + cg.refdef.height-1;
+ bottom = top + cg.refdef.height - 1;
left = cg.refdef.x;
- right = left + cg.refdef.width-1;
+ right = left + cg.refdef.width - 1;
// clear above view screen
- CG_TileClearBox( 0, 0, w, top, cgs.media.backTileShader );
+ CG_TileClearBox(0, 0, w, top, cgs.media.backTileShader);
// clear below view screen
- CG_TileClearBox( 0, bottom, w, h - bottom, cgs.media.backTileShader );
+ CG_TileClearBox(0, bottom, w, h - bottom, cgs.media.backTileShader);
// clear left of view screen
- CG_TileClearBox( 0, top, left, bottom - top + 1, cgs.media.backTileShader );
+ CG_TileClearBox(0, top, left, bottom - top + 1, cgs.media.backTileShader);
// clear right of view screen
- CG_TileClearBox( right, top, w - right, bottom - top + 1, cgs.media.backTileShader );
+ CG_TileClearBox(right, top, w - right, bottom - top + 1, cgs.media.backTileShader);
}
-
-
/*
================
CG_FadeColor
================
*/
-float *CG_FadeColor( int startMsec, int totalMsec ) {
- static vec4_t color;
- int t;
+float *CG_FadeColor(int startMsec, int totalMsec) {
+ static vec4_t color;
+ int t;
- if ( startMsec == 0 ) {
+ if (startMsec == 0) {
return NULL;
}
t = cg.time - startMsec;
- if ( t >= totalMsec ) {
+ if (t >= totalMsec) {
return NULL;
}
// fade out
- if ( totalMsec - t < FADE_TIME ) {
- color[3] = ( totalMsec - t ) * 1.0/FADE_TIME;
+ if (totalMsec - t < FADE_TIME) {
+ color[3] = (totalMsec - t) * 1.0 / FADE_TIME;
} else {
color[3] = 1.0;
}
@@ -371,12 +349,11 @@ Take x,y positions as if 640 x 480 and scales them to the proper resolution
==============
*/
-void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill)
-{
- char num[16], *ptr;
- int l;
- int frame;
- int xWidth;
+void CG_DrawNumField(int x, int y, int width, int value, int charWidth, int charHeight, int style, qboolean zeroFill) {
+ char num[16], *ptr;
+ int l;
+ int frame;
+ int xWidth;
if (width < 1) {
return;
@@ -387,7 +364,7 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH
width = 5;
}
- switch ( width ) {
+ switch (width) {
case 1:
value = value > 9 ? 9 : value;
value = value < 0 ? 0 : value;
@@ -406,71 +383,63 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH
break;
}
- Com_sprintf (num, sizeof(num), "%i", value);
+ Com_sprintf(num, sizeof(num), "%i", value);
l = strlen(num);
if (l > width)
l = width;
// FIXME: Might need to do something different for the chunky font??
- switch(style)
- {
+ switch (style) {
case NUM_FONT_SMALL:
xWidth = charWidth;
break;
case NUM_FONT_CHUNKY:
- xWidth = (charWidth/1.2f) + 2;
+ xWidth = (charWidth / 1.2f) + 2;
break;
default:
case NUM_FONT_BIG:
- xWidth = (charWidth/2) + 7;//(charWidth/6);
+ xWidth = (charWidth / 2) + 7; //(charWidth/6);
break;
}
- if ( zeroFill )
- {
- for (int i = 0; i < (width - l); i++ )
- {
- switch(style)
- {
+ if (zeroFill) {
+ for (int i = 0; i < (width - l); i++) {
+ switch (style) {
case NUM_FONT_SMALL:
- CG_DrawPic( x,y, charWidth, charHeight, cgs.media.smallnumberShaders[0] );
+ CG_DrawPic(x, y, charWidth, charHeight, cgs.media.smallnumberShaders[0]);
break;
case NUM_FONT_CHUNKY:
- CG_DrawPic( x,y, charWidth, charHeight, cgs.media.chunkyNumberShaders[0] );
+ CG_DrawPic(x, y, charWidth, charHeight, cgs.media.chunkyNumberShaders[0]);
break;
default:
case NUM_FONT_BIG:
- CG_DrawPic( x,y, charWidth, charHeight, cgs.media.numberShaders[0] );
+ CG_DrawPic(x, y, charWidth, charHeight, cgs.media.numberShaders[0]);
break;
}
x += 2 + (xWidth);
}
- }
- else
- {
- x += 2 + (xWidth)*(width - l);
+ } else {
+ x += 2 + (xWidth) * (width - l);
}
ptr = num;
- while (*ptr && l)
- {
+ while (*ptr && l) {
if (*ptr == '-')
frame = STAT_MINUS;
else
- frame = *ptr -'0';
+ frame = *ptr - '0';
- switch(style)
- {
+ switch (style) {
case NUM_FONT_SMALL:
- CG_DrawPic( x,y, charWidth, charHeight, cgs.media.smallnumberShaders[frame] );
- x++; // For a one line gap
+ CG_DrawPic(x, y, charWidth, charHeight, cgs.media.smallnumberShaders[frame]);
+ x++; // For a one line gap
break;
case NUM_FONT_CHUNKY:
- CG_DrawPic( x,y, charWidth, charHeight, cgs.media.chunkyNumberShaders[frame] );
+ CG_DrawPic(x, y, charWidth, charHeight, cgs.media.chunkyNumberShaders[frame]);
break;
default:
case NUM_FONT_BIG:
- CG_DrawPic( x,y, charWidth, charHeight, cgs.media.numberShaders[frame] );
+ CG_DrawPic(x, y, charWidth, charHeight, cgs.media.numberShaders[frame]);
break;
}
@@ -478,7 +447,6 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH
ptr++;
l--;
}
-
}
/*
@@ -486,8 +454,7 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH
CG_DrawProportionalString
=================
*/
-void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color )
-{
- //assert(!style);//call this directly if you need style (OR it into the font handle)
- cgi_R_Font_DrawString (x, y, str, color, cgs.media.qhFontMedium, -1, 1.0f);
+void CG_DrawProportionalString(int x, int y, const char *str, int style, vec4_t color) {
+ // assert(!style);//call this directly if you need style (OR it into the font handle)
+ cgi_R_Font_DrawString(x, y, str, color, cgs.media.qhFontMedium, -1, 1.0f);
}
\ No newline at end of file
diff --git a/code/cgame/cg_effects.cpp b/code/cgame/cg_effects.cpp
index bd58dc4fa1..a34b2536e0 100644
--- a/code/cgame/cg_effects.cpp
+++ b/code/cgame/cg_effects.cpp
@@ -28,7 +28,7 @@ along with this program; if not, see .
#include "cg_media.h"
#if !defined(FX_SCHEDULER_H_INC)
- #include "FxScheduler.h"
+#include "FxScheduler.h"
#endif
/*
@@ -107,7 +107,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
}
*/
// When calling this version, just pass in a zero for the flags
-//localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
+// localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
// qhandle_t hModel, int numFrames, qhandle_t shader,
// int msec, qboolean isSprite, float scale ) {
// return CG_MakeExplosion( origin, dir, hModel, numFrames, shader, msec, isSprite, scale, 0 );
@@ -118,12 +118,11 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
CG_AddTempLight
====================
*/
-localEntity_t *CG_AddTempLight( vec3_t origin, float scale, vec3_t color, int msec )
-{
- localEntity_t *ex;
+localEntity_t *CG_AddTempLight(vec3_t origin, float scale, vec3_t color, int msec) {
+ localEntity_t *ex;
- if ( msec <= 0 ) {
- CG_Error( "CG_AddTempLight: msec = %i", msec );
+ if (msec <= 0) {
+ CG_Error("CG_AddTempLight: msec = %i", msec);
}
ex = CG_AllocLocalEntity();
@@ -134,10 +133,10 @@ localEntity_t *CG_AddTempLight( vec3_t origin, float scale, vec3_t color, int ms
ex->endTime = ex->startTime + msec;
// set origin
- VectorCopy ( origin, ex->refEntity.origin);
- VectorCopy ( origin, ex->refEntity.oldorigin );
+ VectorCopy(origin, ex->refEntity.origin);
+ VectorCopy(origin, ex->refEntity.oldorigin);
- VectorCopy( color, ex->lightColor );
+ VectorCopy(color, ex->lightColor);
ex->light = scale;
return ex;
@@ -152,29 +151,27 @@ intensity ranges from 1 (minor tremble) to 16 (major quake)
-------------------------
*/
-void CG_ExplosionEffects( vec3_t origin, float intensity, int radius, int time )
-{
- //FIXME: When exactly is the vieworg calculated in relation to the rest of the frame?s
+void CG_ExplosionEffects(vec3_t origin, float intensity, int radius, int time) {
+ // FIXME: When exactly is the vieworg calculated in relation to the rest of the frame?s
- vec3_t dir;
- float dist, intensityScale;
- float realIntensity;
+ vec3_t dir;
+ float dist, intensityScale;
+ float realIntensity;
- VectorSubtract( cg.refdef.vieworg, origin, dir );
- dist = VectorNormalize( dir );
+ VectorSubtract(cg.refdef.vieworg, origin, dir);
+ dist = VectorNormalize(dir);
- //Use the dir to add kick to the explosion
+ // Use the dir to add kick to the explosion
- if ( dist > radius )
+ if (dist > radius)
return;
- intensityScale = 1 - ( dist / (float) radius );
+ intensityScale = 1 - (dist / (float)radius);
realIntensity = intensity * intensityScale;
- CGCam_Shake( realIntensity, time );
+ CGCam_Shake(realIntensity, time);
}
-
/*
-------------------------
CG_SurfaceExplosion
@@ -232,8 +229,9 @@ void CG_SurfaceExplosion( vec3_t origin, vec3_t normal, float radius, float shak
for ( i = 0; i < 4; i++ )
{
- VectorSet( temp_org, new_org[0] + (Q_flrand(-1.0f, 1.0f) * 16.0f), new_org[1] + (Q_flrand(-1.0f, 1.0f) * 16.0f), new_org[2] + (Q_flrand(0.0f, 1.0f) * 4.0f) );
- VectorSet( temp_vel, velocity[0] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[1] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[2] + (Q_flrand(-1.0f, 1.0f) * 8.0f) );
+ VectorSet( temp_org, new_org[0] + (Q_flrand(-1.0f, 1.0f) * 16.0f), new_org[1] + (Q_flrand(-1.0f, 1.0f) * 16.0f), new_org[2] + (Q_flrand(0.0f, 1.0f)
+* 4.0f) ); VectorSet( temp_vel, velocity[0] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[1] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[2] + (Q_flrand(-1.0f, 1.0f)
+* 8.0f) );
FX_AddSprite( temp_org,
temp_vel,
@@ -255,14 +253,14 @@ void CG_SurfaceExplosion( vec3_t origin, vec3_t normal, float radius, float shak
VectorNormalize( direction );
//Tag the last one with a light
- le = CG_MakeExplosion( origin, direction, cgs.media.explosionModel, 6, cgs.media.surfaceExplosionShader, 500, qfalse, radius * 0.02f + (Q_flrand(0.0f, 1.0f) * 0.3f) );
- le->light = 150;
- VectorSet( le->lightColor, 0.9f, 0.8f, 0.5f );
+ le = CG_MakeExplosion( origin, direction, cgs.media.explosionModel, 6, cgs.media.surfaceExplosionShader, 500, qfalse, radius * 0.02f + (Q_flrand(0.0f, 1.0f)
+* 0.3f) ); le->light = 150; VectorSet( le->lightColor, 0.9f, 0.8f, 0.5f );
for ( i = 0; i < NUM_EXPLOSIONS-1; i ++)
{
- VectorSet( new_org, (origin[0] + (16 + (Q_flrand(-1.0f, 1.0f) * 8))*Q_flrand(-1.0f, 1.0f)), (origin[1] + (16 + (Q_flrand(-1.0f, 1.0f) * 8))*Q_flrand(-1.0f, 1.0f)), (origin[2] + (16 + (Q_flrand(-1.0f, 1.0f) * 8))*Q_flrand(-1.0f, 1.0f)) );
- le = CG_MakeExplosion( new_org, direction, cgs.media.explosionModel, 6, cgs.media.surfaceExplosionShader, 300 + (rand() & 99), qfalse, radius * 0.05f + (Q_flrand(-1.0f, 1.0f) *0.3f) );
+ VectorSet( new_org, (origin[0] + (16 + (Q_flrand(-1.0f, 1.0f) * 8))*Q_flrand(-1.0f, 1.0f)), (origin[1] + (16 + (Q_flrand(-1.0f, 1.0f) *
+8))*Q_flrand(-1.0f, 1.0f)), (origin[2] + (16 + (Q_flrand(-1.0f, 1.0f) * 8))*Q_flrand(-1.0f, 1.0f)) ); le = CG_MakeExplosion( new_org, direction,
+cgs.media.explosionModel, 6, cgs.media.surfaceExplosionShader, 300 + (rand() & 99), qfalse, radius * 0.05f + (Q_flrand(-1.0f, 1.0f) *0.3f) );
}
//Shake the camera
@@ -290,18 +288,16 @@ Adds an explosion to a misc model breakables
-------------------------
*/
-void CG_MiscModelExplosion( vec3_t mins, vec3_t maxs, int size, material_t chunkType )
-{
- int ct = 13;
- float r;
- vec3_t org, mid, dir;
- char *effect = NULL, *effect2 = NULL;
+void CG_MiscModelExplosion(vec3_t mins, vec3_t maxs, int size, material_t chunkType) {
+ int ct = 13;
+ float r;
+ vec3_t org, mid, dir;
+ char *effect = NULL, *effect2 = NULL;
- VectorAdd( mins, maxs, mid );
- VectorScale( mid, 0.5f, mid );
+ VectorAdd(mins, maxs, mid);
+ VectorScale(mid, 0.5f, mid);
- switch( chunkType )
- {
+ switch (chunkType) {
case MAT_GLASS:
effect = "chunks/glassbreak";
ct = 5;
@@ -332,12 +328,11 @@ void CG_MiscModelExplosion( vec3_t mins, vec3_t maxs, int size, material_t chunk
ct = 20;
effect = "chunks/ropebreak";
break;
- case MAT_WHITE_METAL: //not sure what this crap is really supposed to be..
+ case MAT_WHITE_METAL: // not sure what this crap is really supposed to be..
case MAT_DRK_STONE:
case MAT_LT_STONE:
case MAT_GREY_STONE:
- switch( size )
- {
+ switch (size) {
case 2:
effect = "chunks/rockbreaklg";
break;
@@ -350,42 +345,35 @@ void CG_MiscModelExplosion( vec3_t mins, vec3_t maxs, int size, material_t chunk
break;
}
- if ( !effect )
- {
+ if (!effect) {
return;
}
ct += 7 * size;
// FIXME: real precache .. VERify that these need to be here...don't think they would because the effects should be registered in g_breakable
- theFxScheduler.RegisterEffect( effect );
+ theFxScheduler.RegisterEffect(effect);
- if ( effect2 )
- {
+ if (effect2) {
// FIXME: real precache
- theFxScheduler.RegisterEffect( effect2 );
+ theFxScheduler.RegisterEffect(effect2);
}
// spawn chunk roughly in the bbox of the thing..
- for ( int i = 0; i < ct; i++ )
- {
- for( int j = 0; j < 3; j++ )
- {
+ for (int i = 0; i < ct; i++) {
+ for (int j = 0; j < 3; j++) {
r = Q_flrand(0.0f, 1.0f) * 0.8f + 0.1f;
- org[j] = ( r * mins[j] + ( 1 - r ) * maxs[j] );
+ org[j] = (r * mins[j] + (1 - r) * maxs[j]);
}
// shoot effect away from center
- VectorSubtract( org, mid, dir );
- VectorNormalize( dir );
+ VectorSubtract(org, mid, dir);
+ VectorNormalize(dir);
- if ( effect2 && ( rand() & 1 ))
- {
- theFxScheduler.PlayEffect( effect2, org, dir );
- }
- else
- {
- theFxScheduler.PlayEffect( effect, org, dir );
+ if (effect2 && (rand() & 1)) {
+ theFxScheduler.PlayEffect(effect2, org, dir);
+ } else {
+ theFxScheduler.PlayEffect(effect, org, dir);
}
}
}
@@ -398,87 +386,76 @@ Fun chunk spewer
-------------------------
*/
-void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins, const vec3_t maxs,
- float speed, int numChunks, material_t chunkType, int customChunk, float baseScale, int customSound = 0 )
-{
- localEntity_t *le;
- refEntity_t *re;
- vec3_t dir;
- int i, j, k;
- int chunkModel = 0;
- leBounceSound_t bounce = LEBS_NONE;
- float r, speedMod = 1.0f;
- qboolean chunk = qfalse;
-
- if ( chunkType == MAT_NONE )
- {
+void CG_Chunks(int owner, vec3_t origin, const vec3_t normal, const vec3_t mins, const vec3_t maxs, float speed, int numChunks, material_t chunkType,
+ int customChunk, float baseScale, int customSound = 0) {
+ localEntity_t *le;
+ refEntity_t *re;
+ vec3_t dir;
+ int i, j, k;
+ int chunkModel = 0;
+ leBounceSound_t bounce = LEBS_NONE;
+ float r, speedMod = 1.0f;
+ qboolean chunk = qfalse;
+
+ if (chunkType == MAT_NONE) {
// Well, we should do nothing
return;
}
- if ( customSound )
- {
- if ( cgs.sound_precache[customSound] )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.sound_precache[customSound] );
+ if (customSound) {
+ if (cgs.sound_precache[customSound]) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.sound_precache[customSound]);
}
}
- // Set up our chunk sound info...breaking sounds are done here so they are done once on breaking..some return instantly because the chunks are done with effects instead of models
- switch( chunkType )
- {
+ // Set up our chunk sound info...breaking sounds are done here so they are done once on breaking..some return instantly because the chunks are done with
+ // effects instead of models
+ switch (chunkType) {
case MAT_GLASS:
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.media.glassChunkSound );
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.media.glassChunkSound);
}
return;
break;
case MAT_GRATE1:
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.media.grateSound );
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.media.grateSound);
}
return;
break;
- case MAT_ELECTRICAL:// (sparks)
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgi_S_RegisterSound (va("sound/ambience/spark%d.wav", Q_irand(1, 6))) );
+ case MAT_ELECTRICAL: // (sparks)
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgi_S_RegisterSound(va("sound/ambience/spark%d.wav", Q_irand(1, 6))));
}
return;
break;
case MAT_DRK_STONE:
case MAT_LT_STONE:
case MAT_GREY_STONE:
- case MAT_WHITE_METAL: // not quite sure what this stuff is supposed to be...it's for Stu
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.media.rockBreakSound );
+ case MAT_WHITE_METAL: // not quite sure what this stuff is supposed to be...it's for Stu
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.media.rockBreakSound);
bounce = LEBS_ROCK;
}
speedMod = 0.5f; // rock blows up less
break;
case MAT_GLASS_METAL:
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.media.glassChunkSound ); // FIXME: should probably have a custom sound
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.media.glassChunkSound); // FIXME: should probably have a custom sound
bounce = LEBS_METAL;
}
break;
case MAT_CRATE1:
case MAT_CRATE2:
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.media.crateBreakSound[Q_irand(0,1)] );
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.media.crateBreakSound[Q_irand(0, 1)]);
}
break;
case MAT_METAL:
case MAT_METAL2:
case MAT_METAL3:
- case MAT_ELEC_METAL:// FIXME: maybe have its own sound?
- if ( !customSound )
- {
- cgi_S_StartSound( NULL, owner, CHAN_BODY, cgs.media.chunkSound );
+ case MAT_ELEC_METAL: // FIXME: maybe have its own sound?
+ if (!customSound) {
+ cgi_S_StartSound(NULL, owner, CHAN_BODY, cgs.media.chunkSound);
bounce = LEBS_METAL;
}
speedMod = 0.8f; // metal blows up a bit more
@@ -495,62 +472,53 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins
break;
}
- if ( baseScale <= 0.0f )
- {
+ if (baseScale <= 0.0f) {
baseScale = 1.0f;
}
// Chunks
- for( i = 0; i < numChunks; i++ )
- {
- if ( customChunk > 0 )
- {
+ for (i = 0; i < numChunks; i++) {
+ if (customChunk > 0) {
// Try to use a custom chunk.
- if ( cgs.model_draw[customChunk] )
- {
+ if (cgs.model_draw[customChunk]) {
chunk = qtrue;
chunkModel = cgs.model_draw[customChunk];
}
}
- if ( !chunk )
- {
+ if (!chunk) {
// No custom chunk. Pick a random chunk type at run-time so we don't get the same chunks
- switch( chunkType )
- {
- case MAT_METAL2: //bluegrey
+ switch (chunkType) {
+ case MAT_METAL2: // bluegrey
chunkModel = cgs.media.chunkModels[CHUNK_METAL2][Q_irand(0, 3)];
break;
- case MAT_GREY_STONE://gray
+ case MAT_GREY_STONE: // gray
chunkModel = cgs.media.chunkModels[CHUNK_ROCK1][Q_irand(0, 3)];
break;
- case MAT_LT_STONE: //tan
+ case MAT_LT_STONE: // tan
chunkModel = cgs.media.chunkModels[CHUNK_ROCK2][Q_irand(0, 3)];
break;
- case MAT_DRK_STONE://brown
+ case MAT_DRK_STONE: // brown
chunkModel = cgs.media.chunkModels[CHUNK_ROCK3][Q_irand(0, 3)];
break;
case MAT_WHITE_METAL:
chunkModel = cgs.media.chunkModels[CHUNK_WHITE_METAL][Q_irand(0, 3)];
break;
- case MAT_CRATE1://yellow multi-colored crate chunks
+ case MAT_CRATE1: // yellow multi-colored crate chunks
chunkModel = cgs.media.chunkModels[CHUNK_CRATE1][Q_irand(0, 3)];
break;
- case MAT_CRATE2://red multi-colored crate chunks
+ case MAT_CRATE2: // red multi-colored crate chunks
chunkModel = cgs.media.chunkModels[CHUNK_CRATE2][Q_irand(0, 3)];
break;
case MAT_ELEC_METAL:
case MAT_GLASS_METAL:
- case MAT_METAL://grey
+ case MAT_METAL: // grey
chunkModel = cgs.media.chunkModels[CHUNK_METAL1][Q_irand(0, 3)];
break;
case MAT_METAL3:
- if ( rand() & 1 )
- {
+ if (rand() & 1) {
chunkModel = cgs.media.chunkModels[CHUNK_METAL1][Q_irand(0, 3)];
- }
- else
- {
+ } else {
chunkModel = cgs.media.chunkModels[CHUNK_METAL2][Q_irand(0, 3)];
}
break;
@@ -560,8 +528,7 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins
}
// It wouldn't look good to throw a bunch of RGB axis models...so make sure we have something to work with.
- if ( chunkModel )
- {
+ if (chunkModel) {
le = CG_AllocLocalEntity();
re = &le->refEntity;
@@ -570,26 +537,25 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins
le->endTime = cg.time + 1300 + Q_flrand(0.0f, 1.0f) * 900;
// spawn chunk roughly in the bbox of the thing...bias towards center in case thing blowing up doesn't complete fill its bbox.
- for( j = 0; j < 3; j++ )
- {
+ for (j = 0; j < 3; j++) {
r = Q_flrand(0.0f, 1.0f) * 0.8f + 0.1f;
- re->origin[j] = ( r * mins[j] + ( 1 - r ) * maxs[j] );
+ re->origin[j] = (r * mins[j] + (1 - r) * maxs[j]);
}
- VectorCopy( re->origin, le->pos.trBase );
+ VectorCopy(re->origin, le->pos.trBase);
// Move out from center of thing, otherwise you can end up things moving across the brush in an undesirable direction. Visually looks wrong
- VectorSubtract( re->origin, origin, dir );
- VectorNormalize( dir );
- VectorScale( dir, Q_flrand( speed * 0.5f, speed * 1.25f ) * speedMod, le->pos.trDelta );
+ VectorSubtract(re->origin, origin, dir);
+ VectorNormalize(dir);
+ VectorScale(dir, Q_flrand(speed * 0.5f, speed * 1.25f) * speedMod, le->pos.trDelta);
// Angular Velocity
- VectorSet( le->angles.trBase, Q_flrand(0.0f, 1.0f) * 360, Q_flrand(0.0f, 1.0f) * 360, Q_flrand(0.0f, 1.0f) * 360 );
+ VectorSet(le->angles.trBase, Q_flrand(0.0f, 1.0f) * 360, Q_flrand(0.0f, 1.0f) * 360, Q_flrand(0.0f, 1.0f) * 360);
le->angles.trDelta[0] = Q_flrand(-1.0f, 1.0f);
le->angles.trDelta[1] = Q_flrand(-1.0f, 1.0f);
le->angles.trDelta[2] = 0; // don't do roll
- VectorScale( le->angles.trDelta, Q_flrand(0.0f, 1.0f) * 600.0f + 200.0f, le->angles.trDelta );
+ VectorScale(le->angles.trDelta, Q_flrand(0.0f, 1.0f) * 600.0f + 200.0f, le->angles.trDelta);
le->pos.trType = TR_GRAVITY;
le->angles.trType = TR_LINEAR;
@@ -600,52 +566,47 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins
le->leBounceSoundType = bounce;
// Make sure that we have the desired start size set
- le->radius = Q_flrand( baseScale * 0.75f, baseScale * 1.25f );
+ le->radius = Q_flrand(baseScale * 0.75f, baseScale * 1.25f);
re->nonNormalizedAxes = qtrue;
- AxisCopy( axisDefault, re->axis ); // could do an angles to axis, but this is cheaper and works ok
- for( k = 0; k < 3; k++ )
- {
- VectorScale( re->axis[k], le->radius, re->axis[k] );
+ AxisCopy(axisDefault, re->axis); // could do an angles to axis, but this is cheaper and works ok
+ for (k = 0; k < 3; k++) {
+ VectorScale(re->axis[k], le->radius, re->axis[k]);
}
}
}
}
-void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int radius )
-{
- localEntity_t *le;
- refEntity_t *re;
+void CG_TestLine(vec3_t start, vec3_t end, int time, unsigned int color, int radius) {
+ localEntity_t *le;
+ refEntity_t *re;
le = CG_AllocLocalEntity();
le->leType = LE_LINE;
le->startTime = cg.time;
le->endTime = cg.time + time;
- le->lifeRate = 1.0 / ( le->endTime - le->startTime );
+ le->lifeRate = 1.0 / (le->endTime - le->startTime);
re = &le->refEntity;
- VectorCopy( start, re->origin );
- VectorCopy( end, re->oldorigin);
+ VectorCopy(start, re->origin);
+ VectorCopy(end, re->oldorigin);
re->shaderTime = cg.time / 1000.0f;
re->reType = RT_LINE;
- re->radius = 0.5*radius;
- re->customShader = cgs.media.whiteShader; //trap_R_RegisterShaderNoMip("textures/colombia/canvas_doublesided");
+ re->radius = 0.5 * radius;
+ re->customShader = cgs.media.whiteShader; // trap_R_RegisterShaderNoMip("textures/colombia/canvas_doublesided");
re->shaderTexCoord[0] = re->shaderTexCoord[1] = 1.0f;
- if (color==0)
- {
+ if (color == 0) {
re->shaderRGBA[0] = re->shaderRGBA[1] = re->shaderRGBA[2] = re->shaderRGBA[3] = 0xff;
- }
- else
- {
+ } else {
re->shaderRGBA[0] = color & 0xff;
color >>= 8;
re->shaderRGBA[1] = color & 0xff;
color >>= 8;
re->shaderRGBA[2] = color & 0xff;
-// color >>= 8;
-// re->shaderRGBA[3] = color & 0xff;
+ // color >>= 8;
+ // re->shaderRGBA[3] = color & 0xff;
re->shaderRGBA[3] = 0xff;
}
@@ -661,300 +622,256 @@ void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int ra
// Since we have shared verts when we tesselate the glass sheet, it helps to have a
// random offset table set up up front...so that we can have more random looking breaks.
-static float offX[20][20],
- offZ[20][20];
+static float offX[20][20], offZ[20][20];
-static void CG_DoGlassQuad( vec3_t p[4], vec2_t uv[4], bool stick, int time, vec3_t dmgDir )
-{
- float bounce;
- vec3_t rotDelta;
- vec3_t vel, accel;
- vec3_t rgb1;
+static void CG_DoGlassQuad(vec3_t p[4], vec2_t uv[4], bool stick, int time, vec3_t dmgDir) {
+ float bounce;
+ vec3_t rotDelta;
+ vec3_t vel, accel;
+ vec3_t rgb1;
- VectorSet( vel, Q_flrand(-1.0f, 1.0f) * 12, Q_flrand(-1.0f, 1.0f) * 12, -1 );
+ VectorSet(vel, Q_flrand(-1.0f, 1.0f) * 12, Q_flrand(-1.0f, 1.0f) * 12, -1);
- if ( !stick )
- {
+ if (!stick) {
// We aren't a motion delayed chunk, so let us move quickly
- VectorMA( vel, 0.3f, dmgDir, vel );
+ VectorMA(vel, 0.3f, dmgDir, vel);
}
// Set up acceleration due to gravity, 800 is standard QuakeIII gravity, so let's use something close
- VectorSet( accel, 0.0f, 0.0f, -(600.0f + Q_flrand(0.0f, 1.0f) * 100.0f ) );
+ VectorSet(accel, 0.0f, 0.0f, -(600.0f + Q_flrand(0.0f, 1.0f) * 100.0f));
- VectorSet( rgb1, 1.0f, 1.0f, 1.0f );
+ VectorSet(rgb1, 1.0f, 1.0f, 1.0f);
// Being glass, we don't want to bounce much
bounce = Q_flrand(0.0f, 1.0f) * 0.2f + 0.15f;
// Set up our random rotate, we only do PITCH and YAW, not ROLL. This is something like degrees per second
- VectorSet( rotDelta, Q_flrand(-1.0f, 1.0f) * 40.0f, Q_flrand(-1.0f, 1.0f) * 40.0f, 0.0f );
-
- CPoly *pol = FX_AddPoly(p, uv, 4, // verts, ST, vertCount
- vel, accel, // motion
- 0.15f, 0.0f, 85.0f, // alpha start, alpha end, alpha parm ( begin alpha fade when 85% of life is complete )
- rgb1, rgb1, 0.0f, // rgb start, rgb end, rgb parm ( not used )
- rotDelta, bounce, time, // rotation amount, bounce, and time to delay motion for ( zero if no delay );
- 3500 + Q_flrand(0.0f, 1.0f) * 1000, // life
- cgi_R_RegisterShader( "gfx/misc/test_crackle" ),
- FX_APPLY_PHYSICS | FX_ALPHA_NONLINEAR | FX_USE_ALPHA );
-
- if ( Q_flrand(0.0f, 1.0f) > 0.95f && pol )
- {
- pol->AddFlags( FX_IMPACT_RUNS_FX | FX_KILL_ON_IMPACT );
- pol->SetImpactFxID( theFxScheduler.RegisterEffect( "misc/glass_impact" ));
+ VectorSet(rotDelta, Q_flrand(-1.0f, 1.0f) * 40.0f, Q_flrand(-1.0f, 1.0f) * 40.0f, 0.0f);
+
+ CPoly *pol = FX_AddPoly(p, uv, 4, // verts, ST, vertCount
+ vel, accel, // motion
+ 0.15f, 0.0f, 85.0f, // alpha start, alpha end, alpha parm ( begin alpha fade when 85% of life is complete )
+ rgb1, rgb1, 0.0f, // rgb start, rgb end, rgb parm ( not used )
+ rotDelta, bounce, time, // rotation amount, bounce, and time to delay motion for ( zero if no delay );
+ 3500 + Q_flrand(0.0f, 1.0f) * 1000, // life
+ cgi_R_RegisterShader("gfx/misc/test_crackle"), FX_APPLY_PHYSICS | FX_ALPHA_NONLINEAR | FX_USE_ALPHA);
+
+ if (Q_flrand(0.0f, 1.0f) > 0.95f && pol) {
+ pol->AddFlags(FX_IMPACT_RUNS_FX | FX_KILL_ON_IMPACT);
+ pol->SetImpactFxID(theFxScheduler.RegisterEffect("misc/glass_impact"));
}
}
-static void CG_CalcBiLerp( vec3_t verts[4], vec3_t subVerts[4], vec2_t uv[4] )
-{
- vec3_t temp;
+static void CG_CalcBiLerp(vec3_t verts[4], vec3_t subVerts[4], vec2_t uv[4]) {
+ vec3_t temp;
// Nasty crap
- VectorScale( verts[0], 1.0f - uv[0][0], subVerts[0] );
- VectorMA( subVerts[0], uv[0][0], verts[1], subVerts[0] );
- VectorScale( subVerts[0], 1.0f - uv[0][1], temp );
- VectorScale( verts[3], 1.0f - uv[0][0], subVerts[0] );
- VectorMA( subVerts[0], uv[0][0], verts[2], subVerts[0] );
- VectorMA( temp, uv[0][1], subVerts[0], subVerts[0] );
-
- VectorScale( verts[0], 1.0f - uv[1][0], subVerts[1] );
- VectorMA( subVerts[1], uv[1][0], verts[1], subVerts[1] );
- VectorScale( subVerts[1], 1.0f - uv[1][1], temp );
- VectorScale( verts[3], 1.0f - uv[1][0], subVerts[1] );
- VectorMA( subVerts[1], uv[1][0], verts[2], subVerts[1] );
- VectorMA( temp, uv[1][1], subVerts[1], subVerts[1] );
-
- VectorScale( verts[0], 1.0f - uv[2][0], subVerts[2] );
- VectorMA( subVerts[2], uv[2][0], verts[1], subVerts[2] );
- VectorScale( subVerts[2], 1.0f - uv[2][1], temp );
- VectorScale( verts[3], 1.0f - uv[2][0], subVerts[2] );
- VectorMA( subVerts[2], uv[2][0], verts[2], subVerts[2] );
- VectorMA( temp, uv[2][1], subVerts[2], subVerts[2] );
-
- VectorScale( verts[0], 1.0f - uv[3][0], subVerts[3] );
- VectorMA( subVerts[3], uv[3][0], verts[1], subVerts[3] );
- VectorScale( subVerts[3], 1.0f - uv[3][1], temp );
- VectorScale( verts[3], 1.0f - uv[3][0], subVerts[3] );
- VectorMA( subVerts[3], uv[3][0], verts[2], subVerts[3] );
- VectorMA( temp, uv[3][1], subVerts[3], subVerts[3] );
+ VectorScale(verts[0], 1.0f - uv[0][0], subVerts[0]);
+ VectorMA(subVerts[0], uv[0][0], verts[1], subVerts[0]);
+ VectorScale(subVerts[0], 1.0f - uv[0][1], temp);
+ VectorScale(verts[3], 1.0f - uv[0][0], subVerts[0]);
+ VectorMA(subVerts[0], uv[0][0], verts[2], subVerts[0]);
+ VectorMA(temp, uv[0][1], subVerts[0], subVerts[0]);
+
+ VectorScale(verts[0], 1.0f - uv[1][0], subVerts[1]);
+ VectorMA(subVerts[1], uv[1][0], verts[1], subVerts[1]);
+ VectorScale(subVerts[1], 1.0f - uv[1][1], temp);
+ VectorScale(verts[3], 1.0f - uv[1][0], subVerts[1]);
+ VectorMA(subVerts[1], uv[1][0], verts[2], subVerts[1]);
+ VectorMA(temp, uv[1][1], subVerts[1], subVerts[1]);
+
+ VectorScale(verts[0], 1.0f - uv[2][0], subVerts[2]);
+ VectorMA(subVerts[2], uv[2][0], verts[1], subVerts[2]);
+ VectorScale(subVerts[2], 1.0f - uv[2][1], temp);
+ VectorScale(verts[3], 1.0f - uv[2][0], subVerts[2]);
+ VectorMA(subVerts[2], uv[2][0], verts[2], subVerts[2]);
+ VectorMA(temp, uv[2][1], subVerts[2], subVerts[2]);
+
+ VectorScale(verts[0], 1.0f - uv[3][0], subVerts[3]);
+ VectorMA(subVerts[3], uv[3][0], verts[1], subVerts[3]);
+ VectorScale(subVerts[3], 1.0f - uv[3][1], temp);
+ VectorScale(verts[3], 1.0f - uv[3][0], subVerts[3]);
+ VectorMA(subVerts[3], uv[3][0], verts[2], subVerts[3]);
+ VectorMA(temp, uv[3][1], subVerts[3], subVerts[3]);
}
// bilinear
-//f(p',q') = (1 - y) × {[(1 - x) × f(p,q)] + [x × f(p,q+1)]} + y × {[(1 - x) × f(p+1,q)] + [x × f(p+1,q+1)]}.
-
-
-static void CG_CalcHeightWidth( vec3_t verts[4], float *height, float *width )
-{
- vec3_t dir1, dir2, cross;
-
- VectorSubtract( verts[3], verts[0], dir1 ); // v
- VectorSubtract( verts[1], verts[0], dir2 ); // p-a
- CrossProduct( dir1, dir2, cross );
- *width = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v
- VectorSubtract( verts[2], verts[0], dir2 ); // p-a
- CrossProduct( dir1, dir2, cross );
- *width += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v
+// f(p',q') = (1 - y) × {[(1 - x) × f(p,q)] + [x × f(p,q+1)]} + y × {[(1 - x) × f(p+1,q)] + [x × f(p+1,q+1)]}.
+
+static void CG_CalcHeightWidth(vec3_t verts[4], float *height, float *width) {
+ vec3_t dir1, dir2, cross;
+
+ VectorSubtract(verts[3], verts[0], dir1); // v
+ VectorSubtract(verts[1], verts[0], dir2); // p-a
+ CrossProduct(dir1, dir2, cross);
+ *width = VectorNormalize(cross) / VectorNormalize(dir1); // v
+ VectorSubtract(verts[2], verts[0], dir2); // p-a
+ CrossProduct(dir1, dir2, cross);
+ *width += VectorNormalize(cross) / VectorNormalize(dir1); // v
*width *= 0.5f;
- VectorSubtract( verts[1], verts[0], dir1 ); // v
- VectorSubtract( verts[2], verts[0], dir2 ); // p-a
- CrossProduct( dir1, dir2, cross );
- *height = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v
- VectorSubtract( verts[3], verts[0], dir2 ); // p-a
- CrossProduct( dir1, dir2, cross );
- *height += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v
+ VectorSubtract(verts[1], verts[0], dir1); // v
+ VectorSubtract(verts[2], verts[0], dir2); // p-a
+ CrossProduct(dir1, dir2, cross);
+ *height = VectorNormalize(cross) / VectorNormalize(dir1); // v
+ VectorSubtract(verts[3], verts[0], dir2); // p-a
+ CrossProduct(dir1, dir2, cross);
+ *height += VectorNormalize(cross) / VectorNormalize(dir1); // v
*height *= 0.5f;
}
-//Consider a line in 3D with position vector "a" and direction vector "v" and
-// let "p" be the position vector of an arbitrary point in 3D
-//dist = len( crossprod(p-a,v) ) / len(v);
+// Consider a line in 3D with position vector "a" and direction vector "v" and
+// let "p" be the position vector of an arbitrary point in 3D
+// dist = len( crossprod(p-a,v) ) / len(v);
-void CG_InitGlass( void )
-{
+void CG_InitGlass(void) {
int i, t;
// Build a table first, so that we can do a more unpredictable crack scheme
// do it once, up front to save a bit of time.
- for ( i = 0; i < 20; i++ )
- {
- for ( t = 0; t < 20; t++ )
- {
+ for (i = 0; i < 20; i++) {
+ for (t = 0; t < 20; t++) {
offX[t][i] = Q_flrand(-1.0f, 1.0f) * 0.03f;
offZ[i][t] = Q_flrand(-1.0f, 1.0f) * 0.03f;
}
}
}
-#define TIME_DECAY_SLOW 0.1f
-#define TIME_DECAY_MED 0.04f
-#define TIME_DECAY_FAST 0.009f
+#define TIME_DECAY_SLOW 0.1f
+#define TIME_DECAY_MED 0.04f
+#define TIME_DECAY_FAST 0.009f
-void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, float dmgRadius )
-{
- int i, t;
- int mxHeight, mxWidth;
- float height, width;
- float stepWidth, stepHeight;
- float timeDecay;
- float x, z;
- float xx, zz;
- int time = 0;
- bool stick = true;
- vec3_t subVerts[4];
- vec2_t biPoints[4];
+void CG_DoGlass(vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, float dmgRadius) {
+ int i, t;
+ int mxHeight, mxWidth;
+ float height, width;
+ float stepWidth, stepHeight;
+ float timeDecay;
+ float x, z;
+ float xx, zz;
+ int time = 0;
+ bool stick = true;
+ vec3_t subVerts[4];
+ vec2_t biPoints[4];
// To do a smarter tesselation, we should figure out the relative height and width of the brush face,
// then use this to pick a lod value from 1-3 in each axis. This will give us 1-9 lod levels, which will
// hopefully be sufficient.
- CG_CalcHeightWidth( verts, &height, &width );
+ CG_CalcHeightWidth(verts, &height, &width);
- cgi_S_StartSound( dmgPt, -1, CHAN_AUTO, cgi_S_RegisterSound("sound/effects/glassbreak1.wav"));
+ cgi_S_StartSound(dmgPt, -1, CHAN_AUTO, cgi_S_RegisterSound("sound/effects/glassbreak1.wav"));
// Pick "LOD" for height
- if ( height < 100 )
- {
+ if (height < 100) {
stepHeight = 0.2f;
mxHeight = 5;
timeDecay = TIME_DECAY_SLOW;
}
-/* else if ( height > 220 ) // was originally mxHeight = 20....but removing this whole section because it causes huge number of chunks...which is bad
- {
- stepHeight = 0.075f;
- mxHeight = 15;
- timeDecay = TIME_DECAY_FAST;
- }*/
- else
- {
+ /* else if ( height > 220 ) // was originally mxHeight = 20....but removing this whole section because it causes huge number of chunks...which is bad
+ {
+ stepHeight = 0.075f;
+ mxHeight = 15;
+ timeDecay = TIME_DECAY_FAST;
+ }*/
+ else {
stepHeight = 0.1f;
mxHeight = 10;
timeDecay = TIME_DECAY_MED;
}
// Pick "LOD" for width
- if ( width < 100 )
- {
+ if (width < 100) {
stepWidth = 0.2f;
mxWidth = 5;
- timeDecay = ( timeDecay + TIME_DECAY_SLOW ) * 0.5f;
+ timeDecay = (timeDecay + TIME_DECAY_SLOW) * 0.5f;
}
-/* else if ( width > 220 ) // don't do this because it causes too much chug with large glass panes...especially when more than one pane can be broken at a time
- {
- stepWidth = 0.075f;
- mxWidth = 15;
- timeDecay = ( timeDecay + TIME_DECAY_FAST ) * 0.5f;
- }*/
- else
- {
+ /* else if ( width > 220 ) // don't do this because it causes too much chug with large glass panes...especially when more than one pane can be broken at a
+ time
+ {
+ stepWidth = 0.075f;
+ mxWidth = 15;
+ timeDecay = ( timeDecay + TIME_DECAY_FAST ) * 0.5f;
+ }*/
+ else {
stepWidth = 0.1f;
mxWidth = 10;
- timeDecay = ( timeDecay + TIME_DECAY_MED ) * 0.5f;
+ timeDecay = (timeDecay + TIME_DECAY_MED) * 0.5f;
}
- for ( z = 0.0f, i = 0; z < 1.0f; z += stepHeight, i++ )
- {
- for ( x = 0.0f, t = 0; x < 1.0f; x += stepWidth, t++ )
- {
+ for (z = 0.0f, i = 0; z < 1.0f; z += stepHeight, i++) {
+ for (x = 0.0f, t = 0; x < 1.0f; x += stepWidth, t++) {
// This is nasty..we do this because we don't want to add a random offset on the edge of the glass brush
// ...but we do in the center, otherwise the breaking scheme looks way too orderly
- if ( t > 0 && t < mxWidth )
- {
+ if (t > 0 && t < mxWidth) {
xx = x - offX[i][t];
- }
- else
- {
+ } else {
xx = x;
}
- if ( i > 0 && i < mxHeight )
- {
+ if (i > 0 && i < mxHeight) {
zz = z - offZ[t][i];
- }
- else
- {
+ } else {
zz = z;
}
- VectorSet2( biPoints[0], xx, zz );
+ VectorSet2(biPoints[0], xx, zz);
- if ( t + 1 > 0 && t + 1 < mxWidth )
- {
+ if (t + 1 > 0 && t + 1 < mxWidth) {
xx = x - offX[i][t + 1];
- }
- else
- {
+ } else {
xx = x;
}
- if ( i > 0 && i < mxHeight )
- {
+ if (i > 0 && i < mxHeight) {
zz = z - offZ[t + 1][i];
- }
- else
- {
+ } else {
zz = z;
}
- VectorSet2( biPoints[1], xx + stepWidth, zz );
+ VectorSet2(biPoints[1], xx + stepWidth, zz);
- if ( t + 1 > 0 && t + 1 < mxWidth )
- {
+ if (t + 1 > 0 && t + 1 < mxWidth) {
xx = x - offX[i + 1][t + 1];
- }
- else
- {
+ } else {
xx = x;
}
- if ( i + 1 > 0 && i + 1 < mxHeight )
- {
+ if (i + 1 > 0 && i + 1 < mxHeight) {
zz = z - offZ[t + 1][i + 1];
- }
- else
- {
+ } else {
zz = z;
}
- VectorSet2( biPoints[2], xx + stepWidth, zz + stepHeight);
+ VectorSet2(biPoints[2], xx + stepWidth, zz + stepHeight);
- if ( t > 0 && t < mxWidth )
- {
+ if (t > 0 && t < mxWidth) {
xx = x - offX[i + 1][t];
- }
- else
- {
+ } else {
xx = x;
}
- if ( i + 1 > 0 && i + 1 < mxHeight )
- {
+ if (i + 1 > 0 && i + 1 < mxHeight) {
zz = z - offZ[t][i + 1];
- }
- else
- {
+ } else {
zz = z;
}
- VectorSet2( biPoints[3], xx, zz + stepHeight );
+ VectorSet2(biPoints[3], xx, zz + stepHeight);
- CG_CalcBiLerp( verts, subVerts, biPoints );
+ CG_CalcBiLerp(verts, subVerts, biPoints);
- float dif = DistanceSquared( subVerts[0], dmgPt ) * timeDecay - Q_flrand(0.0f, 1.0f) * 32;
+ float dif = DistanceSquared(subVerts[0], dmgPt) * timeDecay - Q_flrand(0.0f, 1.0f) * 32;
// If we decrease dif, we are increasing the impact area, making it more likely to blow out large holes
dif -= dmgRadius * dmgRadius;
- if ( dif > 1 )
- {
+ if (dif > 1) {
stick = true;
time = dif + Q_flrand(0.0f, 1.0f) * 200;
- }
- else
- {
+ } else {
stick = false;
time = 0;
}
- CG_DoGlassQuad( subVerts, biPoints, stick, time, dmgDir );
+ CG_DoGlassQuad(subVerts, biPoints, stick, time, dmgDir);
}
}
}
@@ -999,113 +916,92 @@ CG_Seeker
}
*/
//------------------------------------------------------------------------------------------
-void CG_DrawTargetBeam( vec3_t start, vec3_t end, vec3_t norm, const char *beamFx, const char *impactFx )
-{
- int handle = 0;
- vec3_t dir;
- SEffectTemplate *temp;
+void CG_DrawTargetBeam(vec3_t start, vec3_t end, vec3_t norm, const char *beamFx, const char *impactFx) {
+ int handle = 0;
+ vec3_t dir;
+ SEffectTemplate *temp;
// overriding the effect, so give us a copy first
- temp = theFxScheduler.GetEffectCopy( beamFx, &handle );
+ temp = theFxScheduler.GetEffectCopy(beamFx, &handle);
- VectorSubtract( start, end, dir );
- VectorNormalize( dir );
+ VectorSubtract(start, end, dir);
+ VectorNormalize(dir);
- if ( temp )
- {
+ if (temp) {
// have a copy, so get the line element out of there
- CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy( temp, "beam" );
+ CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy(temp, "beam");
- if ( prim )
- {
+ if (prim) {
// we have the primitive, so modify the endpoint
- prim->mOrigin2X.SetRange( end[0], end[0] );
- prim->mOrigin2Y.SetRange( end[1], end[1] );
- prim->mOrigin2Z.SetRange( end[2], end[2] );
+ prim->mOrigin2X.SetRange(end[0], end[0]);
+ prim->mOrigin2Y.SetRange(end[1], end[1]);
+ prim->mOrigin2Z.SetRange(end[2], end[2]);
// have a copy, so get the line element out of there
- CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy( temp, "glow" );
+ CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy(temp, "glow");
// glow is not required
- if ( prim )
- {
+ if (prim) {
// we have the primitive, so modify the endpoint
- prim->mOrigin2X.SetRange( end[0], end[0] );
- prim->mOrigin2Y.SetRange( end[1], end[1] );
- prim->mOrigin2Z.SetRange( end[2], end[2] );
+ prim->mOrigin2X.SetRange(end[0], end[0]);
+ prim->mOrigin2Y.SetRange(end[1], end[1]);
+ prim->mOrigin2Z.SetRange(end[2], end[2]);
}
// play the modified effect
- theFxScheduler.PlayEffect( handle, start, dir );
+ theFxScheduler.PlayEffect(handle, start, dir);
}
}
- if ( impactFx )
- {
- theFxScheduler.PlayEffect( impactFx, end, norm );
+ if (impactFx) {
+ theFxScheduler.PlayEffect(impactFx, end, norm);
}
}
-void CG_PlayEffectBolted( const char *fxName, const int modelIndex, const int boltIndex, const int entNum, vec3_t origin, int iLoopTime, const bool isRelative )
-{
- vec3_t axis[3];//FIXME: shouldn't this be initialized to something? It isn't in the EV_PLAY_EFFECT call... irrelevant?
- int boltInfo;
-
- //pack the data into boltInfo as if we were going to send it over the network
- gi.G2API_AttachEnt(&boltInfo,
- &g_entities[entNum].ghoul2[modelIndex],
- boltIndex,
- entNum,
- modelIndex);
- //send direcly to FX scheduler
- theFxScheduler.PlayEffect( fxName,
- origin,
- axis,
- boltInfo,
- -1,
- false,
- iLoopTime,
- isRelative ); //iLoopTime 0 = not looping, 1 for infinite, else duration
+void CG_PlayEffectBolted(const char *fxName, const int modelIndex, const int boltIndex, const int entNum, vec3_t origin, int iLoopTime, const bool isRelative) {
+ vec3_t axis[3]; // FIXME: shouldn't this be initialized to something? It isn't in the EV_PLAY_EFFECT call... irrelevant?
+ int boltInfo;
+
+ // pack the data into boltInfo as if we were going to send it over the network
+ gi.G2API_AttachEnt(&boltInfo, &g_entities[entNum].ghoul2[modelIndex], boltIndex, entNum, modelIndex);
+ // send direcly to FX scheduler
+ theFxScheduler.PlayEffect(fxName, origin, axis, boltInfo, -1, false, iLoopTime,
+ isRelative); // iLoopTime 0 = not looping, 1 for infinite, else duration
}
-void CG_PlayEffectIDBolted( const int fxID, const int modelIndex, const int boltIndex, const int entNum, vec3_t origin, int iLoopTime, const bool isRelative )
-{
- const char *fxName = CG_ConfigString( CS_EFFECTS + fxID );
- CG_PlayEffectBolted( fxName, modelIndex, boltIndex, entNum, origin, iLoopTime, isRelative );
+void CG_PlayEffectIDBolted(const int fxID, const int modelIndex, const int boltIndex, const int entNum, vec3_t origin, int iLoopTime, const bool isRelative) {
+ const char *fxName = CG_ConfigString(CS_EFFECTS + fxID);
+ CG_PlayEffectBolted(fxName, modelIndex, boltIndex, entNum, origin, iLoopTime, isRelative);
}
-void CG_PlayEffectOnEnt( const char *fxName, const int clientNum, vec3_t origin, const vec3_t fwd )
-{
- vec3_t temp, axis[3];
+void CG_PlayEffectOnEnt(const char *fxName, const int clientNum, vec3_t origin, const vec3_t fwd) {
+ vec3_t temp, axis[3];
// Assume angles, we'll do a cross product to finish up
- VectorCopy( fwd, axis[0] );
- MakeNormalVectors( fwd, axis[1], temp );
- CrossProduct( axis[0], axis[1], axis[2] );
- //call FX scheduler directly
- theFxScheduler.PlayEffect( fxName, origin, axis, -1, clientNum, false );
+ VectorCopy(fwd, axis[0]);
+ MakeNormalVectors(fwd, axis[1], temp);
+ CrossProduct(axis[0], axis[1], axis[2]);
+ // call FX scheduler directly
+ theFxScheduler.PlayEffect(fxName, origin, axis, -1, clientNum, false);
}
-void CG_PlayEffectIDOnEnt( const int fxID, const int clientNum, vec3_t origin, const vec3_t fwd )
-{
- const char *fxName = CG_ConfigString( CS_EFFECTS + fxID );
- CG_PlayEffectOnEnt( fxName, clientNum, origin, fwd );
+void CG_PlayEffectIDOnEnt(const int fxID, const int clientNum, vec3_t origin, const vec3_t fwd) {
+ const char *fxName = CG_ConfigString(CS_EFFECTS + fxID);
+ CG_PlayEffectOnEnt(fxName, clientNum, origin, fwd);
}
-void CG_PlayEffect( const char *fxName, vec3_t origin, const vec3_t fwd )
-{
- vec3_t temp, axis[3];
+void CG_PlayEffect(const char *fxName, vec3_t origin, const vec3_t fwd) {
+ vec3_t temp, axis[3];
// Assume angles, we'll do a cross product to finish up
- VectorCopy( fwd, axis[0] );
- MakeNormalVectors( fwd, axis[1], temp );
- CrossProduct( axis[0], axis[1], axis[2] );
- //call FX scheduler directly
- theFxScheduler.PlayEffect( fxName, origin, axis, -1, -1, false );
+ VectorCopy(fwd, axis[0]);
+ MakeNormalVectors(fwd, axis[1], temp);
+ CrossProduct(axis[0], axis[1], axis[2]);
+ // call FX scheduler directly
+ theFxScheduler.PlayEffect(fxName, origin, axis, -1, -1, false);
}
-void CG_PlayEffectID( const int fxID, vec3_t origin, const vec3_t fwd )
-{
- const char *fxName = CG_ConfigString( CS_EFFECTS + fxID );
- CG_PlayEffect( fxName, origin, fwd );
+void CG_PlayEffectID(const int fxID, vec3_t origin, const vec3_t fwd) {
+ const char *fxName = CG_ConfigString(CS_EFFECTS + fxID);
+ CG_PlayEffect(fxName, origin, fwd);
}
diff --git a/code/cgame/cg_ents.cpp b/code/cgame/cg_ents.cpp
index 4c8ea97538..989cf163a0 100644
--- a/code/cgame/cg_ents.cpp
+++ b/code/cgame/cg_ents.cpp
@@ -32,12 +32,12 @@ along with this program; if not, see .
#include "../game/wp_saber.h"
#include "../game/g_vehicles.h"
-extern void CG_AddSaberBlade( centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles);
-extern void CG_CheckSaberInWater( centity_t *cent, centity_t *scent, int saberNum, int modelIndex, vec3_t origin, vec3_t angles );
-extern void CG_ForcePushBlur( const vec3_t org, qboolean darkSide = qfalse );
-extern void CG_AddForceSightShell( refEntity_t *ent, centity_t *cent );
-extern qboolean CG_PlayerCanSeeCent( centity_t *cent );
-extern cvar_t *debug_subdivision;
+extern void CG_AddSaberBlade(centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles);
+extern void CG_CheckSaberInWater(centity_t *cent, centity_t *scent, int saberNum, int modelIndex, vec3_t origin, vec3_t angles);
+extern void CG_ForcePushBlur(const vec3_t org, qboolean darkSide = qfalse);
+extern void CG_AddForceSightShell(refEntity_t *ent, centity_t *cent);
+extern qboolean CG_PlayerCanSeeCent(centity_t *cent);
+extern cvar_t *debug_subdivision;
/*
======================
@@ -47,24 +47,21 @@ Modifies the entities position and axis by the given
tag location
======================
*/
-void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
- qhandle_t parentModel, char *tagName ) {
- int i;
- orientation_t lerped;
+void CG_PositionEntityOnTag(refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName) {
+ int i;
+ orientation_t lerped;
// lerp the tag
- cgi_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,
- 1.0f - parent->backlerp, tagName );
+ cgi_R_LerpTag(&lerped, parentModel, parent->oldframe, parent->frame, 1.0f - parent->backlerp, tagName);
// FIXME: allow origin offsets along tag?
- VectorCopy( parent->origin, entity->origin );
- for ( i = 0 ; i < 3 ; i++ )
- {
- VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );
+ VectorCopy(parent->origin, entity->origin);
+ for (i = 0; i < 3; i++) {
+ VectorMA(entity->origin, lerped.origin[i], parent->axis[i], entity->origin);
}
// had to cast away the const to avoid compiler problems...
- MatrixMultiply( lerped.axis, ((refEntity_t *)parent)->axis, entity->axis );
+ MatrixMultiply(lerped.axis, ((refEntity_t *)parent)->axis, entity->axis);
entity->backlerp = parent->backlerp;
}
@@ -76,37 +73,31 @@ Modifies the entities position and axis by the given
tag location
======================
*/
-void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
- qhandle_t parentModel, char *tagName, orientation_t *tagOrient ) {
- int i;
- orientation_t lerped;
- vec3_t tempAxis[3];
+void CG_PositionRotatedEntityOnTag(refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName, orientation_t *tagOrient) {
+ int i;
+ orientation_t lerped;
+ vec3_t tempAxis[3];
// lerp the tag
- cgi_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,
- 1.0f - parent->backlerp, tagName );
+ cgi_R_LerpTag(&lerped, parentModel, parent->oldframe, parent->frame, 1.0f - parent->backlerp, tagName);
- if ( tagOrient )
- {
- VectorCopy( lerped.origin, tagOrient->origin );
- for ( i = 0 ; i < 3 ; i++ )
- {
- VectorCopy( lerped.axis[i], tagOrient->axis[i] );
+ if (tagOrient) {
+ VectorCopy(lerped.origin, tagOrient->origin);
+ for (i = 0; i < 3; i++) {
+ VectorCopy(lerped.axis[i], tagOrient->axis[i]);
}
}
// FIXME: allow origin offsets along tag?
- VectorCopy( parent->origin, entity->origin );
- for ( i = 0 ; i < 3 ; i++ ) {
- VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );
+ VectorCopy(parent->origin, entity->origin);
+ for (i = 0; i < 3; i++) {
+ VectorMA(entity->origin, lerped.origin[i], parent->axis[i], entity->origin);
}
- MatrixMultiply( entity->axis, lerped.axis, tempAxis );
- MatrixMultiply( tempAxis, ((refEntity_t *)parent)->axis, entity->axis );
+ MatrixMultiply(entity->axis, lerped.axis, tempAxis);
+ MatrixMultiply(tempAxis, ((refEntity_t *)parent)->axis, entity->axis);
}
-
-
/*
==========================================================================
@@ -122,31 +113,26 @@ CG_SetEntitySoundPosition
Also called by event processing code
======================
*/
-vec3_t *CG_SetEntitySoundPosition( centity_t *cent ) {
+vec3_t *CG_SetEntitySoundPosition(centity_t *cent) {
static vec3_t v3Return;
- if ( cent->currentState.solid == SOLID_BMODEL ) {
- vec3_t origin;
- float *v;
+ if (cent->currentState.solid == SOLID_BMODEL) {
+ vec3_t origin;
+ float *v;
- v = cgs.inlineModelMidpoints[ cent->currentState.modelindex ];
- VectorAdd( cent->lerpOrigin, v, origin );
- cgi_S_UpdateEntityPosition( cent->currentState.number, origin );
+ v = cgs.inlineModelMidpoints[cent->currentState.modelindex];
+ VectorAdd(cent->lerpOrigin, v, origin);
+ cgi_S_UpdateEntityPosition(cent->currentState.number, origin);
VectorCopy(origin, v3Return);
} else {
- if ( cent->currentState.eType == ET_PLAYER
- && cent->gent
- && cent->gent->client
- && cent->gent->ghoul2.IsValid()
- && cent->gent->ghoul2[0].animModelIndexOffset )//If it has an animOffset it's a cinematic anim
- {//I might be running out of my bounding box, so use my headPoint from the last render frame...?
- //NOTE: if I'm not rendered, will this not update correctly? Would cent->lerpOrigin be any more updated?
+ if (cent->currentState.eType == ET_PLAYER && cent->gent && cent->gent->client && cent->gent->ghoul2.IsValid() &&
+ cent->gent->ghoul2[0].animModelIndexOffset) // If it has an animOffset it's a cinematic anim
+ { // I might be running out of my bounding box, so use my headPoint from the last render frame...?
+ // NOTE: if I'm not rendered, will this not update correctly? Would cent->lerpOrigin be any more updated?
VectorCopy(cent->gent->client->renderInfo.eyePoint, v3Return);
- }
- else
- {//just use my org
+ } else { // just use my org
VectorCopy(cent->lerpOrigin, v3Return);
}
- cgi_S_UpdateEntityPosition( cent->currentState.number, v3Return );
+ cgi_S_UpdateEntityPosition(cent->currentState.number, v3Return);
}
return &v3Return;
@@ -159,149 +145,136 @@ CG_EntityEffects
Add continuous entity effects, like local entity emission and lighting
==================
*/
-static void CG_EntityEffects( centity_t *cent ) {
+static void CG_EntityEffects(centity_t *cent) {
// update sound origins
vec3_t v3Origin;
- VectorCopy(*CG_SetEntitySoundPosition( cent ),v3Origin);
+ VectorCopy(*CG_SetEntitySoundPosition(cent), v3Origin);
// add loop sound
- if ( cent->currentState.loopSound )
- {
+ if (cent->currentState.loopSound) {
soundChannel_t chan = CHAN_AUTO;
gentity_t *ent = cent->gent;
- if ( ent->s.eFlags & EF_LESS_ATTEN )
- {
+ if (ent->s.eFlags & EF_LESS_ATTEN) {
chan = CHAN_LESS_ATTEN;
}
- sfxHandle_t sfx = ( cent->currentState.eType == ET_MOVER ) ? cent->currentState.loopSound : cgs.sound_precache[ cent->currentState.loopSound ];
+ sfxHandle_t sfx = (cent->currentState.eType == ET_MOVER) ? cent->currentState.loopSound : cgs.sound_precache[cent->currentState.loopSound];
// Only play sound if being drawn.
- if ( !( ent->s.eFlags & EF_NODRAW ) )
- {
- cgi_S_AddLoopingSound( cent->currentState.number, v3Origin/*cent->lerpOrigin*/, vec3_origin, sfx, chan );
+ if (!(ent->s.eFlags & EF_NODRAW)) {
+ cgi_S_AddLoopingSound(cent->currentState.number, v3Origin /*cent->lerpOrigin*/, vec3_origin, sfx, chan);
}
}
// constant light glow
- if ( cent->currentState.constantLight ) {
- int cl;
- float i, r, g, b;
+ if (cent->currentState.constantLight) {
+ int cl;
+ float i, r, g, b;
cl = cent->currentState.constantLight;
- r = (float) (cl & 0xFF) / 255.0;
- g = (float) ((cl >> 8) & 0xFF) / 255.0;
- b = (float) ((cl >> 16) & 0xFF) / 255.0;
- i = (float) ((cl >> 24) & 0xFF) * 4.0;
- cgi_R_AddLightToScene( cent->lerpOrigin, i, r, g, b );
+ r = (float)(cl & 0xFF) / 255.0;
+ g = (float)((cl >> 8) & 0xFF) / 255.0;
+ b = (float)((cl >> 16) & 0xFF) / 255.0;
+ i = (float)((cl >> 24) & 0xFF) * 4.0;
+ cgi_R_AddLightToScene(cent->lerpOrigin, i, r, g, b);
}
}
-void CG_AddRefEntWithTransportEffect ( centity_t *cent, refEntity_t *ent )
-{
+void CG_AddRefEntWithTransportEffect(centity_t *cent, refEntity_t *ent) {
// We are a normal thing....
- cgi_R_AddRefEntityToScene (ent);
+ cgi_R_AddRefEntityToScene(ent);
- if ( ent->renderfx & RF_PULSATE && cent->gent->owner && cent->gent->owner->health &&
- !cent->gent->owner->s.number && cent->gent->owner->client && //only for player
- cent->gent->owner->client->ps.saberEntityState == SES_RETURNING &&
- cent->currentState.saberActive == qfalse )
- {
+ if (ent->renderfx & RF_PULSATE && cent->gent->owner && cent->gent->owner->health && !cent->gent->owner->s.number &&
+ cent->gent->owner->client && // only for player
+ cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && cent->currentState.saberActive == qfalse) {
// if we are the saber and we have been dropped, do a glow so it can be spotted easier
- float wv;
- vec3_t org;
+ float wv;
+ vec3_t org;
- ent->customShader = cgi_R_RegisterShader( "gfx/effects/solidWhite_cull" );
+ ent->customShader = cgi_R_RegisterShader("gfx/effects/solidWhite_cull");
ent->renderfx = RF_RGB_TINT;
- wv = sin( cg.time * 0.003f ) * 0.08f + 0.1f;
+ wv = sin(cg.time * 0.003f) * 0.08f + 0.1f;
ent->shaderRGBA[0] = wv * 255;
ent->shaderRGBA[1] = wv * 255;
ent->shaderRGBA[2] = wv * 0;
- cgi_R_AddRefEntityToScene (ent);
+ cgi_R_AddRefEntityToScene(ent);
- for ( int i = -4; i < 10; i += 1 )
- {
- VectorMA( ent->origin, -i, ent->axis[2], org );
+ for (int i = -4; i < 10; i += 1) {
+ VectorMA(ent->origin, -i, ent->axis[2], org);
- FX_AddSprite( org, NULL, NULL, 5.5f, 5.5f, wv, wv, 0.0f, 0.0f, 1.0f, cgs.media.yellowDroppedSaberShader, 0x08000000 );
+ FX_AddSprite(org, NULL, NULL, 5.5f, 5.5f, wv, wv, 0.0f, 0.0f, 1.0f, cgs.media.yellowDroppedSaberShader, 0x08000000);
}
- if ( cent->gent->owner->s.weapon == WP_SABER )
- {//he's still controlling me
- FX_AddSprite( cent->gent->owner->client->renderInfo.handRPoint, NULL, NULL, 8.0f, 8.0f, wv, wv, 0.0f, 0.0f, 1.0f, cgs.media.yellowDroppedSaberShader, 0x08000000 );
+ if (cent->gent->owner->s.weapon == WP_SABER) { // he's still controlling me
+ FX_AddSprite(cent->gent->owner->client->renderInfo.handRPoint, NULL, NULL, 8.0f, 8.0f, wv, wv, 0.0f, 0.0f, 1.0f, cgs.media.yellowDroppedSaberShader,
+ 0x08000000);
}
}
}
-
/*
Ghoul2 Insert Start
*/
// Copy the ghoul2 data into the ref ent correctly
-void CG_SetGhoul2Info( refEntity_t *ent, centity_t *cent)
-{
+void CG_SetGhoul2Info(refEntity_t *ent, centity_t *cent) {
ent->ghoul2 = ¢->gent->ghoul2;
- VectorCopy( cent->currentState.modelScale, ent->modelScale);
+ VectorCopy(cent->currentState.modelScale, ent->modelScale);
ent->radius = cent->currentState.radius;
- VectorCopy (cent->lerpAngles, ent->angles);
+ VectorCopy(cent->lerpAngles, ent->angles);
}
-
// write in the axis and stuff
-void G2_BoltToGhoul2Model(centity_t *cent, refEntity_t *ent)
-{
- // extract the wraith ID from the bolt info
+void G2_BoltToGhoul2Model(centity_t *cent, refEntity_t *ent) {
+ // extract the wraith ID from the bolt info
int modelNum = cent->currentState.boltInfo >> MODEL_SHIFT;
modelNum &= MODEL_AND;
- int boltNum = cent->currentState.boltInfo >> BOLT_SHIFT;
+ int boltNum = cent->currentState.boltInfo >> BOLT_SHIFT;
boltNum &= BOLT_AND;
- int entNum = cent->currentState.boltInfo >> ENTITY_SHIFT;
+ int entNum = cent->currentState.boltInfo >> ENTITY_SHIFT;
entNum &= ENTITY_AND;
- mdxaBone_t boltMatrix;
+ mdxaBone_t boltMatrix;
- // go away and get me the bolt position for this frame please
- gi.G2API_GetBoltMatrix(cent->gent->ghoul2, modelNum, boltNum, &boltMatrix, cg_entities[entNum].currentState.angles, cg_entities[entNum].currentState.origin, cg.time, cgs.model_draw, cent->currentState.modelScale);
+ // go away and get me the bolt position for this frame please
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, modelNum, boltNum, &boltMatrix, cg_entities[entNum].currentState.angles, cg_entities[entNum].currentState.origin,
+ cg.time, cgs.model_draw, cent->currentState.modelScale);
// set up the axis and origin we need for the actual effect spawning
- ent->origin[0] = boltMatrix.matrix[0][3];
- ent->origin[1] = boltMatrix.matrix[1][3];
- ent->origin[2] = boltMatrix.matrix[2][3];
+ ent->origin[0] = boltMatrix.matrix[0][3];
+ ent->origin[1] = boltMatrix.matrix[1][3];
+ ent->origin[2] = boltMatrix.matrix[2][3];
- ent->axis[0][0] = boltMatrix.matrix[0][0];
- ent->axis[0][1] = boltMatrix.matrix[1][0];
- ent->axis[0][2] = boltMatrix.matrix[2][0];
+ ent->axis[0][0] = boltMatrix.matrix[0][0];
+ ent->axis[0][1] = boltMatrix.matrix[1][0];
+ ent->axis[0][2] = boltMatrix.matrix[2][0];
- ent->axis[1][0] = boltMatrix.matrix[0][1];
- ent->axis[1][1] = boltMatrix.matrix[1][1];
- ent->axis[1][2] = boltMatrix.matrix[2][1];
+ ent->axis[1][0] = boltMatrix.matrix[0][1];
+ ent->axis[1][1] = boltMatrix.matrix[1][1];
+ ent->axis[1][2] = boltMatrix.matrix[2][1];
- ent->axis[2][0] = boltMatrix.matrix[0][2];
- ent->axis[2][1] = boltMatrix.matrix[1][2];
- ent->axis[2][2] = boltMatrix.matrix[2][2];
+ ent->axis[2][0] = boltMatrix.matrix[0][2];
+ ent->axis[2][1] = boltMatrix.matrix[1][2];
+ ent->axis[2][2] = boltMatrix.matrix[2][2];
}
-void ScaleModelAxis(refEntity_t *ent)
+void ScaleModelAxis(refEntity_t *ent)
-{ // scale the model should we need to
- if (ent->modelScale[0] && ent->modelScale[0] != 1.0f)
- {
- VectorScale( ent->axis[0], ent->modelScale[0] , ent->axis[0] );
- ent->nonNormalizedAxes = qtrue;
- }
- if (ent->modelScale[1] && ent->modelScale[1] != 1.0f)
- {
- VectorScale( ent->axis[1], ent->modelScale[1] , ent->axis[1] );
- ent->nonNormalizedAxes = qtrue;
- }
- if (ent->modelScale[2] && ent->modelScale[2] != 1.0f)
- {
- VectorScale( ent->axis[2], ent->modelScale[2] , ent->axis[2] );
- ent->nonNormalizedAxes = qtrue;
- }
+{ // scale the model should we need to
+ if (ent->modelScale[0] && ent->modelScale[0] != 1.0f) {
+ VectorScale(ent->axis[0], ent->modelScale[0], ent->axis[0]);
+ ent->nonNormalizedAxes = qtrue;
+ }
+ if (ent->modelScale[1] && ent->modelScale[1] != 1.0f) {
+ VectorScale(ent->axis[1], ent->modelScale[1], ent->axis[1]);
+ ent->nonNormalizedAxes = qtrue;
+ }
+ if (ent->modelScale[2] && ent->modelScale[2] != 1.0f) {
+ VectorScale(ent->axis[2], ent->modelScale[2], ent->axis[2]);
+ ent->nonNormalizedAxes = qtrue;
+ }
}
/*
Ghoul2 Insert End
@@ -312,325 +285,255 @@ Ghoul2 Insert End
CG_General
==================
*/
-static void CG_General( centity_t *cent )
-{
- refEntity_t ent;
- entityState_t *s1;
+static void CG_General(centity_t *cent) {
+ refEntity_t ent;
+ entityState_t *s1;
s1 = ¢->currentState;
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
// if set to invisible, skip
- if (!s1->modelindex && !cent->gent->ghoul2.IsValid() ) {
+ if (!s1->modelindex && !cent->gent->ghoul2.IsValid()) {
return;
}
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
- if ( s1->eFlags & EF_NODRAW )
- {
+ if (s1->eFlags & EF_NODRAW) {
// If you don't like it doing NODRAW, then don't set the flag
return;
}
- memset (&ent, 0, sizeof(ent));
+ memset(&ent, 0, sizeof(ent));
// set frame
- if ( cent->currentState.eFlags & EF_DISABLE_SHADER_ANIM )
- {
+ if (cent->currentState.eFlags & EF_DISABLE_SHADER_ANIM) {
// by setting the shader time to the current time, we can force an animating shader to not animate
ent.shaderTime = cg.time * 0.001f;
}
- if ( s1->eFlags & EF_SHADER_ANIM )
- {
+ if (s1->eFlags & EF_SHADER_ANIM) {
// Deliberately setting it up so that shader anim will completely override any kind of model animation frame setting.
- ent.renderfx|=RF_SETANIMINDEX;
+ ent.renderfx |= RF_SETANIMINDEX;
ent.skinNum = s1->frame;
- }
- else if ( s1->eFlags & EF_ANIM_ONCE )
- {
- //s1->frame++;
- //ent.frame = s1->frame;
+ } else if (s1->eFlags & EF_ANIM_ONCE) {
+ // s1->frame++;
+ // ent.frame = s1->frame;
ent.frame = cent->gent->s.frame;
- ent.renderfx|=RF_CAP_FRAMES;
- }
- else if ( s1->eFlags & EF_ANIM_ALLFAST )
- {
+ ent.renderfx |= RF_CAP_FRAMES;
+ } else if (s1->eFlags & EF_ANIM_ALLFAST) {
ent.frame = (cg.time / 100);
- ent.renderfx|=RF_WRAP_FRAMES;
- }
- else
- {
+ ent.renderfx |= RF_WRAP_FRAMES;
+ } else {
ent.frame = s1->frame;
}
ent.oldframe = ent.frame;
ent.backlerp = 0;
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
CG_SetGhoul2Info(&ent, cent);
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
- VectorCopy( cent->lerpOrigin, ent.origin);
- VectorCopy( cent->lerpOrigin, ent.oldorigin);
+ VectorCopy(cent->lerpOrigin, ent.origin);
+ VectorCopy(cent->lerpOrigin, ent.oldorigin);
ent.hModel = cgs.model_draw[s1->modelindex];
- if ( !ent.radius )
- {// Set default g2 cull radius.
+ if (!ent.radius) { // Set default g2 cull radius.
ent.radius = 60;
}
- if ( s1->eFlags & EF_AUTO_SIZE && cent->gent )
- {
- cgi_R_ModelBounds( ent.hModel, cent->gent->mins, cent->gent->maxs );
- //Only do this once
+ if (s1->eFlags & EF_AUTO_SIZE && cent->gent) {
+ cgi_R_ModelBounds(ent.hModel, cent->gent->mins, cent->gent->maxs);
+ // Only do this once
cent->gent->s.eFlags &= ~EF_AUTO_SIZE;
}
// player model
- if (s1->number == cg.snap->ps.clientNum)
- {
- ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors
+ if (s1->number == cg.snap->ps.clientNum) {
+ ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors
}
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
// are we bolted to a Ghoul2 model?
- if (s1->boltInfo)
- {
+ if (s1->boltInfo) {
G2_BoltToGhoul2Model(cent, &ent);
- }
- else
- {
+ } else {
//-------------------------------------------------------
// Start of chair
//-------------------------------------------------------
- if ( cent->gent->s.weapon == WP_EMPLACED_GUN || ( cent->gent->activator && cent->gent->activator->owner &&
- cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON ))
- {
- vec3_t temp;
+ if (cent->gent->s.weapon == WP_EMPLACED_GUN ||
+ (cent->gent->activator && cent->gent->activator->owner && cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON)) {
+ vec3_t temp;
- if ( cent->gent->health <= 0 && cent->gent->e_ThinkFunc == thinkF_NULL )
- {
- if ( !cent->gent->bounceCount )
- {//not an EWeb
- ent.customShader = cgi_R_RegisterShader( "models/map_objects/imp_mine/turret_chair_dmg" );
+ if (cent->gent->health <= 0 && cent->gent->e_ThinkFunc == thinkF_NULL) {
+ if (!cent->gent->bounceCount) { // not an EWeb
+ ent.customShader = cgi_R_RegisterShader("models/map_objects/imp_mine/turret_chair_dmg");
}
- VectorSet( temp, 0, 0, 1 );
+ VectorSet(temp, 0, 0, 1);
// add a big scorch mark under the gun
- CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp,
- 0, 1,1,1, 1.0f, qfalse, 92, qtrue );
- CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp,
- 90, 1,1,1, 1.0f, qfalse, 48, qtrue );
- }
- else
- {
- VectorSet( temp, 0, 0, 1 );
-
- if ( !( cent->gent->svFlags & SVF_INACTIVE ))
- {
- if ( !cent->gent->bounceCount )
- {//not an EWeb
- ent.customShader = cgi_R_RegisterShader( "models/map_objects/imp_mine/turret_chair_on" );
+ CG_ImpactMark(cgs.media.scavMarkShader, cent->lerpOrigin, temp, 0, 1, 1, 1, 1.0f, qfalse, 92, qtrue);
+ CG_ImpactMark(cgs.media.scavMarkShader, cent->lerpOrigin, temp, 90, 1, 1, 1, 1.0f, qfalse, 48, qtrue);
+ } else {
+ VectorSet(temp, 0, 0, 1);
+
+ if (!(cent->gent->svFlags & SVF_INACTIVE)) {
+ if (!cent->gent->bounceCount) { // not an EWeb
+ ent.customShader = cgi_R_RegisterShader("models/map_objects/imp_mine/turret_chair_on");
}
}
// shadow under the gun
- CG_ImpactMark( cgs.media.shadowMarkShader, cent->lerpOrigin, temp,
- 0, 1,1,1, 1.0f, qfalse, 32, qtrue );
+ CG_ImpactMark(cgs.media.shadowMarkShader, cent->lerpOrigin, temp, 0, 1, 1, 1, 1.0f, qfalse, 32, qtrue);
}
}
- if ( cent->gent->activator && cent->gent->activator->owner &&
- cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON &&
- cent->gent->activator->owner->s.number == cent->currentState.number ) // gun number must be same as current entities number
+ if (cent->gent->activator && cent->gent->activator->owner && cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON &&
+ cent->gent->activator->owner->s.number == cent->currentState.number) // gun number must be same as current entities number
{
centity_t *cc = &cg_entities[cent->gent->activator->s.number];
-const weaponData_t *wData = NULL;
+ const weaponData_t *wData = NULL;
- if ( cc->currentState.weapon )
- {
+ if (cc->currentState.weapon) {
wData = &weaponData[cc->currentState.weapon];
}
- if ( !( cc->currentState.eFlags & EF_FIRING ) && !( cc->currentState.eFlags & EF_ALT_FIRING ))
- {
+ if (!(cc->currentState.eFlags & EF_FIRING) && !(cc->currentState.eFlags & EF_ALT_FIRING)) {
// not animating..pausing was leaving the barrels in a bad state
- gi.G2API_PauseBoneAnim( ¢->gent->ghoul2[cent->gent->playerModel], "model_root", cg.time );
+ gi.G2API_PauseBoneAnim(¢->gent->ghoul2[cent->gent->playerModel], "model_root", cg.time);
-// gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone,
-// 0, 0, BONE_ANIM_OVERRIDE, 1.0f, cg.time );
+ // gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone,
+ // 0, 0, BONE_ANIM_OVERRIDE, 1.0f, cg.time );
}
// get alternating muzzle end bolts
- int bolt = cent->gent->handRBolt;
- mdxaBone_t boltMatrix;
+ int bolt = cent->gent->handRBolt;
+ mdxaBone_t boltMatrix;
- if ( !cc->gent->fxID || bolt == -1 )
- {
+ if (!cc->gent->fxID || bolt == -1) {
bolt = cent->gent->handLBolt;
}
- if ( bolt == -1 )
- {
+ if (bolt == -1) {
bolt = 0;
}
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, 0, bolt,
- &boltMatrix, cent->lerpAngles, cent->lerpOrigin, cg.time,
- cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, 0, bolt, &boltMatrix, cent->lerpAngles, cent->lerpOrigin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
// store the muzzle point and direction so that we can fire in the right direction
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cc->gent->client->renderInfo.muzzlePoint );
- if ( cent->gent->bounceCount )
- {//EWeb - *sigh* the muzzle tag on this is not aligned like th eone on the emplaced gun... consistency anyone...?
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_X, cc->gent->client->renderInfo.muzzleDir );
- }
- else
- {//Emplaced gun
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_Y, cc->gent->client->renderInfo.muzzleDir );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cc->gent->client->renderInfo.muzzlePoint);
+ if (cent->gent->bounceCount) { // EWeb - *sigh* the muzzle tag on this is not aligned like th eone on the emplaced gun... consistency anyone...?
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, cc->gent->client->renderInfo.muzzleDir);
+ } else { // Emplaced gun
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Y, cc->gent->client->renderInfo.muzzleDir);
}
cc->gent->client->renderInfo.mPCalcTime = cg.time;
// HACK: adding in muzzle flashes
- if ( cc->muzzleFlashTime > 0 && wData )
- {
+ if (cc->muzzleFlashTime > 0 && wData) {
const char *effect = NULL;
cc->muzzleFlashTime = 0;
// Try and get a default muzzle so we have one to fall back on
- if ( wData->mMuzzleEffect[0] )
- {
+ if (wData->mMuzzleEffect[0]) {
effect = &wData->mMuzzleEffect[0];
}
- if ( cc->currentState.eFlags & EF_ALT_FIRING )
- {
+ if (cc->currentState.eFlags & EF_ALT_FIRING) {
// We're alt-firing, so see if we need to override with a custom alt-fire effect
- if ( wData->mAltMuzzleEffect[0] )
- {
+ if (wData->mAltMuzzleEffect[0]) {
effect = &wData->mAltMuzzleEffect[0];
}
}
- if ( cc->currentState.eFlags & EF_FIRING || cc->currentState.eFlags & EF_ALT_FIRING )
- {
- if ( cent->gent->bounceCount )
- {//EWeb
- gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone,
- 2, 4, BONE_ANIM_OVERRIDE_FREEZE, 0.6f, cg.time, -1, -1 );
- }
- else
- {//Emplaced Gun
- gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone,
- 0, 3, BONE_ANIM_OVERRIDE_FREEZE, 0.6f, cg.time, -1, -1 );
+ if (cc->currentState.eFlags & EF_FIRING || cc->currentState.eFlags & EF_ALT_FIRING) {
+ if (cent->gent->bounceCount) { // EWeb
+ gi.G2API_SetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, 2, 4, BONE_ANIM_OVERRIDE_FREEZE, 0.6f,
+ cg.time, -1, -1);
+ } else { // Emplaced Gun
+ gi.G2API_SetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, 0, 3, BONE_ANIM_OVERRIDE_FREEZE, 0.6f,
+ cg.time, -1, -1);
}
- if ( effect )
- {
+ if (effect) {
// We got an effect and we're firing, so let 'er rip.
- theFxScheduler.PlayEffect( effect, cc->gent->client->renderInfo.muzzlePoint,
- cc->gent->client->renderInfo.muzzleDir );
+ theFxScheduler.PlayEffect(effect, cc->gent->client->renderInfo.muzzlePoint, cc->gent->client->renderInfo.muzzleDir);
}
}
}
- VectorCopy( cent->gent->s.apos.trBase, cent->lerpAngles );
+ VectorCopy(cent->gent->s.apos.trBase, cent->lerpAngles);
}
//-------------------------------------------------------
// End of chair
//-------------------------------------------------------
- AnglesToAxis( cent->lerpAngles, ent.axis );
+ AnglesToAxis(cent->lerpAngles, ent.axis);
}
- //copy modelscale, if any
- VectorCopy( cent->currentState.modelScale, ent.modelScale );
- //apply modelscale, if any
+ // copy modelscale, if any
+ VectorCopy(cent->currentState.modelScale, ent.modelScale);
+ // apply modelscale, if any
ScaleModelAxis(&ent);
- if (cent->gent->ghoul2.size())
- {
- //FIXME: use a flag for this, not a strcmp
- if ( cent->gent->classname && Q_stricmp( "limb", cent->gent->classname ) == 0 )
- {//limb, copy RGB
+ if (cent->gent->ghoul2.size()) {
+ // FIXME: use a flag for this, not a strcmp
+ if (cent->gent->classname && Q_stricmp("limb", cent->gent->classname) == 0) { // limb, copy RGB
ent.shaderRGBA[0] = cent->gent->startRGBA[0];
ent.shaderRGBA[1] = cent->gent->startRGBA[1];
ent.shaderRGBA[2] = cent->gent->startRGBA[2];
}
- if ( s1->weapon == WP_SABER && cent->gent && cent->gent->owner && cent->gent->owner->inuse )
- {//flying lightsaber
- //FIXME: better way to tell what it is would be nice
- if ( cent->gent->classname && !Q_stricmp( "limb", cent->gent->classname ) )
- {//limb, just add blade
- if ( cent->gent->owner->client )
- {
- if ( cent->gent->owner->client->ps.saber[0].Length() > 0 )
- {
- CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number],
- &cg_entities[cent->gent->s.number], NULL, ent.renderfx,
- cent->gent->weaponModel[0], cent->lerpOrigin, cent->lerpAngles );
- }
- else if ( cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER )
- {
- CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number],
- &cg_entities[cent->gent->s.number], 0, cent->gent->weaponModel[0],
- cent->lerpOrigin, cent->lerpAngles );
+ if (s1->weapon == WP_SABER && cent->gent && cent->gent->owner && cent->gent->owner->inuse) { // flying lightsaber
+ // FIXME: better way to tell what it is would be nice
+ if (cent->gent->classname && !Q_stricmp("limb", cent->gent->classname)) { // limb, just add blade
+ if (cent->gent->owner->client) {
+ if (cent->gent->owner->client->ps.saber[0].Length() > 0) {
+ CG_AddSaberBlade(&cg_entities[cent->gent->owner->s.number], &cg_entities[cent->gent->s.number], NULL, ent.renderfx,
+ cent->gent->weaponModel[0], cent->lerpOrigin, cent->lerpAngles);
+ } else if (cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER) {
+ CG_CheckSaberInWater(&cg_entities[cent->gent->owner->s.number], &cg_entities[cent->gent->s.number], 0, cent->gent->weaponModel[0],
+ cent->lerpOrigin, cent->lerpAngles);
}
}
- }
- else
- {//thrown saber
- //light? sound?
- if ( cent->gent->owner->client && g_entities[cent->currentState.otherEntityNum].client && g_entities[cent->currentState.otherEntityNum].client->ps.saber[0].Active() )
- {//saber is in-flight and active, play a sound on it
- if ( cent->gent->owner->client->ps.saberEntityState == SES_RETURNING
- && cent->gent->owner->client->ps.saber[0].type != SABER_STAR )
- {
- cgi_S_AddLoopingSound( cent->currentState.number,
- cent->lerpOrigin, vec3_origin,
- cgs.sound_precache[g_entities[cent->currentState.clientNum].client->ps.saber[0].soundLoop] );
- }
- else
- {
+ } else { // thrown saber
+ // light? sound?
+ if (cent->gent->owner->client && g_entities[cent->currentState.otherEntityNum].client &&
+ g_entities[cent->currentState.otherEntityNum].client->ps.saber[0].Active()) { // saber is in-flight and active, play a sound on it
+ if (cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && cent->gent->owner->client->ps.saber[0].type != SABER_STAR) {
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin,
+ cgs.sound_precache[g_entities[cent->currentState.clientNum].client->ps.saber[0].soundLoop]);
+ } else {
int spinSound;
- if ( cent->gent->owner->client->ps.saber[0].spinSound
- && cgs.sound_precache[cent->gent->owner->client->ps.saber[0].spinSound] )
- {
+ if (cent->gent->owner->client->ps.saber[0].spinSound && cgs.sound_precache[cent->gent->owner->client->ps.saber[0].spinSound]) {
spinSound = cgs.sound_precache[cent->gent->owner->client->ps.saber[0].spinSound];
- }
- else if ( cent->gent->owner->client->ps.saber[0].type == SABER_SITH_SWORD )
- {
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspinoff.wav" );
- }
- else
- {
- switch ( cent->gent->owner->client->ps.forcePowerLevel[FP_SABERTHROW] )
- {
+ } else if (cent->gent->owner->client->ps.saber[0].type == SABER_SITH_SWORD) {
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspinoff.wav");
+ } else {
+ switch (cent->gent->owner->client->ps.forcePowerLevel[FP_SABERTHROW]) {
case FORCE_LEVEL_1:
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin3.wav" );
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin3.wav");
break;
case FORCE_LEVEL_2:
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin2.wav" );
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin2.wav");
break;
default:
case FORCE_LEVEL_3:
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" );
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin1.wav");
break;
}
}
- cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin,
- vec3_origin, spinSound );
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, spinSound);
/*
if ( cg_weapons[WP_SABER].missileSound )
{
@@ -639,75 +542,50 @@ const weaponData_t *wData = NULL;
*/
}
}
- if ( cent->gent->owner->client )
- {
- if ( cent->gent->owner->client->ps.saber[0].Length() > 0 )
- {//only add the blade if it's on
- CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number],
- &cg_entities[cent->gent->s.number], NULL, ent.renderfx,
- 0, cent->lerpOrigin, cent->lerpAngles );
- }
- else if ( cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER )
- {
- CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number],
- &cg_entities[cent->gent->s.number], 0, 0, cent->lerpOrigin,
- cent->lerpAngles );
+ if (cent->gent->owner->client) {
+ if (cent->gent->owner->client->ps.saber[0].Length() > 0) { // only add the blade if it's on
+ CG_AddSaberBlade(&cg_entities[cent->gent->owner->s.number], &cg_entities[cent->gent->s.number], NULL, ent.renderfx, 0, cent->lerpOrigin,
+ cent->lerpAngles);
+ } else if (cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER) {
+ CG_CheckSaberInWater(&cg_entities[cent->gent->owner->s.number], &cg_entities[cent->gent->s.number], 0, 0, cent->lerpOrigin,
+ cent->lerpAngles);
}
}
- if ( cent->gent->owner->health )
- {
- //make sure we can always be seen
+ if (cent->gent->owner->health) {
+ // make sure we can always be seen
ent.renderfx |= RF_PULSATE;
}
}
}
- }
- else
- {
- if ( s1->weapon == WP_SABER && cent->gent && cent->gent->owner )
- {//flying lightsaber
- //light? sound?
- if ( cent->gent->owner->client && cent->currentState.saberActive )
- {//saber is in-flight and active, play a sound on it
- if ( cent->gent->owner->client->ps.saberEntityState == SES_RETURNING
- && cent->gent->owner->client->ps.saber[0].type != SABER_STAR )
- {
- if ( cg_weapons[WP_SABER].firingSound )
- {
- cgi_S_AddLoopingSound( cent->currentState.number,
- cent->lerpOrigin, vec3_origin, cg_weapons[WP_SABER].firingSound );
+ } else {
+ if (s1->weapon == WP_SABER && cent->gent && cent->gent->owner) { // flying lightsaber
+ // light? sound?
+ if (cent->gent->owner->client && cent->currentState.saberActive) { // saber is in-flight and active, play a sound on it
+ if (cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && cent->gent->owner->client->ps.saber[0].type != SABER_STAR) {
+ if (cg_weapons[WP_SABER].firingSound) {
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, cg_weapons[WP_SABER].firingSound);
}
- }
- else
- {
+ } else {
int spinSound;
- if ( cent->gent->owner->client->ps.saber[0].spinSound
- && cgs.sound_precache[cent->gent->owner->client->ps.saber[0].spinSound] )
- {
+ if (cent->gent->owner->client->ps.saber[0].spinSound && cgs.sound_precache[cent->gent->owner->client->ps.saber[0].spinSound]) {
spinSound = cgs.sound_precache[cent->gent->owner->client->ps.saber[0].spinSound];
- }
- else if ( cent->gent->owner->client->ps.saber[0].type == SABER_SITH_SWORD )
- {
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspinoff.wav" );
- }
- else
- {
- switch ( cent->gent->owner->client->ps.forcePowerLevel[FP_SABERTHROW] )
- {
+ } else if (cent->gent->owner->client->ps.saber[0].type == SABER_SITH_SWORD) {
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspinoff.wav");
+ } else {
+ switch (cent->gent->owner->client->ps.forcePowerLevel[FP_SABERTHROW]) {
case FORCE_LEVEL_1:
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin3.wav" );
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin3.wav");
break;
case FORCE_LEVEL_2:
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin2.wav" );
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin2.wav");
break;
default:
case FORCE_LEVEL_3:
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" );
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin1.wav");
break;
}
}
- cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin,
- vec3_origin, spinSound );
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, spinSound);
/*
if ( cg_weapons[WP_SABER].missileSound )
{
@@ -716,152 +594,130 @@ const weaponData_t *wData = NULL;
*/
}
}
- CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number],
- NULL, &ent, ent.renderfx, 0, NULL, NULL );
+ CG_AddSaberBlade(&cg_entities[cent->gent->owner->s.number], NULL, &ent, ent.renderfx, 0, NULL, NULL);
- if ( cent->gent->owner->health )
- {
- //make sure we can always be seen
+ if (cent->gent->owner->health) {
+ // make sure we can always be seen
ent.renderfx |= RF_PULSATE;
}
}
}
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
- if ( cent->gent && cent->gent->forcePushTime > cg.time )
- {//FIXME: if I'm a rather large model, this will look kind of stupid...
- CG_ForcePushBlur( cent->lerpOrigin );
+ if (cent->gent && cent->gent->forcePushTime > cg.time) { // FIXME: if I'm a rather large model, this will look kind of stupid...
+ CG_ForcePushBlur(cent->lerpOrigin);
}
- CG_AddRefEntWithTransportEffect( cent, &ent );
+ CG_AddRefEntWithTransportEffect(cent, &ent);
- if ( cent->gent->health <= 0
- && cent->gent->s.weapon == WP_EMPLACED_GUN
- && cent->gent->e_ThinkFunc )
- {
+ if (cent->gent->health <= 0 && cent->gent->s.weapon == WP_EMPLACED_GUN && cent->gent->e_ThinkFunc) {
// make the gun pulse red to warn about it exploding
- float val = (1.0f - (float)(cent->gent->nextthink - cg.time) / 3200.0f ) * 0.3f;
+ float val = (1.0f - (float)(cent->gent->nextthink - cg.time) / 3200.0f) * 0.3f;
- ent.customShader = cgi_R_RegisterShader( "gfx/effects/solidWhite" );
- ent.shaderRGBA[0] = (sin( cg.time * 0.04f ) * val * 0.4f + val) * 255;
+ ent.customShader = cgi_R_RegisterShader("gfx/effects/solidWhite");
+ ent.shaderRGBA[0] = (sin(cg.time * 0.04f) * val * 0.4f + val) * 255;
ent.shaderRGBA[1] = ent.shaderRGBA[2] = 0;
ent.renderfx |= RF_RGB_TINT;
- cgi_R_AddRefEntityToScene( &ent );
+ cgi_R_AddRefEntityToScene(&ent);
}
//--------------------------
- if ( s1->eFlags & EF_FIRING && cent->gent->inuse )
- {
- //special code for adding the beam to the attached tripwire mine
- vec3_t beamOrg;
- int handle = 0;
- SEffectTemplate *temp;
+ if (s1->eFlags & EF_FIRING && cent->gent->inuse) {
+ // special code for adding the beam to the attached tripwire mine
+ vec3_t beamOrg;
+ int handle = 0;
+ SEffectTemplate *temp;
- VectorMA( ent.origin, 6.6f, ent.axis[0], beamOrg );// forward
+ VectorMA(ent.origin, 6.6f, ent.axis[0], beamOrg); // forward
// overriding the effect, so give us a copy first
- temp = theFxScheduler.GetEffectCopy( "tripMine/laser", &handle );
+ temp = theFxScheduler.GetEffectCopy("tripMine/laser", &handle);
- if ( temp )
- {
+ if (temp) {
// have a copy, so get the line element out of there
- CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy( temp, "line1" );
+ CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy(temp, "line1");
- if ( prim )
- {
+ if (prim) {
// we have the primitive, so modify the endpoint
- prim->mOrigin2X.SetRange( cent->gent->pos4[0], cent->gent->pos4[0] );
- prim->mOrigin2Y.SetRange( cent->gent->pos4[1], cent->gent->pos4[1] );
- prim->mOrigin2Z.SetRange( cent->gent->pos4[2], cent->gent->pos4[2] );
+ prim->mOrigin2X.SetRange(cent->gent->pos4[0], cent->gent->pos4[0]);
+ prim->mOrigin2Y.SetRange(cent->gent->pos4[1], cent->gent->pos4[1]);
+ prim->mOrigin2Z.SetRange(cent->gent->pos4[2], cent->gent->pos4[2]);
// have a copy, so get the line element out of there
- CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy( temp, "line2" );
+ CPrimitiveTemplate *prim = theFxScheduler.GetPrimitiveCopy(temp, "line2");
- if ( prim )
- {
+ if (prim) {
// we have the primitive, so modify the cent->gent->pos3point
- prim->mOrigin2X.SetRange( cent->gent->pos4[0], cent->gent->pos4[0] );
- prim->mOrigin2Y.SetRange( cent->gent->pos4[1], cent->gent->pos4[1] );
- prim->mOrigin2Z.SetRange( cent->gent->pos4[2], cent->gent->pos4[2] );
+ prim->mOrigin2X.SetRange(cent->gent->pos4[0], cent->gent->pos4[0]);
+ prim->mOrigin2Y.SetRange(cent->gent->pos4[1], cent->gent->pos4[1]);
+ prim->mOrigin2Z.SetRange(cent->gent->pos4[2], cent->gent->pos4[2]);
// play the modified effect
- theFxScheduler.PlayEffect( handle, beamOrg, ent.axis[0] );
+ theFxScheduler.PlayEffect(handle, beamOrg, ent.axis[0]);
}
}
}
- theFxScheduler.PlayEffect( "tripMine/laserImpactGlow", cent->gent->pos4, ent.axis[0] );
+ theFxScheduler.PlayEffect("tripMine/laserImpactGlow", cent->gent->pos4, ent.axis[0]);
}
+ if (s1->eFlags & EF_PROX_TRIP) {
+ // special code for adding the glow end to proximity tripmine
+ vec3_t beamOrg;
- if ( s1->eFlags & EF_PROX_TRIP )
- {
- //special code for adding the glow end to proximity tripmine
- vec3_t beamOrg;
-
- VectorMA( ent.origin, 6.6f, ent.axis[0], beamOrg );// forward
- theFxScheduler.PlayEffect( "tripMine/glowBit", beamOrg, ent.axis[0] );
+ VectorMA(ent.origin, 6.6f, ent.axis[0], beamOrg); // forward
+ theFxScheduler.PlayEffect("tripMine/glowBit", beamOrg, ent.axis[0]);
}
- if ( s1->eFlags & EF_ALT_FIRING )
- {
+ if (s1->eFlags & EF_ALT_FIRING) {
// hack for the spotlight
- vec3_t org, axis[3], dir;
+ vec3_t org, axis[3], dir;
- AngleVectors( cent->lerpAngles, dir, NULL, NULL );
+ AngleVectors(cent->lerpAngles, dir, NULL, NULL);
- CG_GetTagWorldPosition( &ent, "tag_flash", org, axis );
+ CG_GetTagWorldPosition(&ent, "tag_flash", org, axis);
- theFxScheduler.PlayEffect( "env/light_cone", org, axis[0] );
+ theFxScheduler.PlayEffect("env/light_cone", org, axis[0]);
- VectorMA( cent->lerpOrigin, cent->gent->radius - 5, dir, org ); // stay a bit back from the impact point...this may not be enough?
+ VectorMA(cent->lerpOrigin, cent->gent->radius - 5, dir, org); // stay a bit back from the impact point...this may not be enough?
- cgi_R_AddLightToScene( org, 225, 1.0f, 1.0f, 1.0f );
+ cgi_R_AddLightToScene(org, 225, 1.0f, 1.0f, 1.0f);
}
//-----------------------------------------------------------
- if ( cent->gent->flags & (FL_DMG_BY_HEAVY_WEAP_ONLY | FL_SHIELDED ))
- {
+ if (cent->gent->flags & (FL_DMG_BY_HEAVY_WEAP_ONLY | FL_SHIELDED)) {
// Dumb assumption, but I guess we must be a shielded ion_cannon?? We should probably verify
// if it's an ion_cannon that's Heavy Weapon only, we don't want to make it shielded do we...?
- if ( (!strcmp( "misc_ion_cannon", cent->gent->classname )) && (cent->gent->flags & FL_SHIELDED ))
- {
+ if ((!strcmp("misc_ion_cannon", cent->gent->classname)) && (cent->gent->flags & FL_SHIELDED)) {
// must be doing "pain"....er, impact
- if ( cent->gent->painDebounceTime > cg.time )
- {
- float t = (float)(cent->gent->painDebounceTime - cg.time ) / 1000.0f;
+ if (cent->gent->painDebounceTime > cg.time) {
+ float t = (float)(cent->gent->painDebounceTime - cg.time) / 1000.0f;
// Only display when we have damage
- if ( t >= 0.0f && t <= 1.0f )
- {
+ if (t >= 0.0f && t <= 1.0f) {
t *= Q_flrand(0.0f, 1.0f);
ent.shaderRGBA[0] = ent.shaderRGBA[1] = ent.shaderRGBA[2] = 255.0f * t;
ent.shaderRGBA[3] = 255;
ent.renderfx &= ~RF_ALPHA_FADE;
ent.renderfx |= RF_RGB_TINT;
- ent.customShader = cgi_R_RegisterShader( "gfx/misc/ion_shield" );
+ ent.customShader = cgi_R_RegisterShader("gfx/misc/ion_shield");
- cgi_R_AddRefEntityToScene( &ent );
+ cgi_R_AddRefEntityToScene(&ent);
}
}
}
}
- //draw force sight shell around it, too
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && CG_PlayerCanSeeCent( cent ) )
- {//so player can see dark missiles/explosives
- if ( s1->weapon == WP_THERMAL
- || s1->weapon == WP_DET_PACK
- || s1->weapon == WP_TRIP_MINE
- || (cent->gent&¢->gent->e_UseFunc==useF_ammo_power_converter_use)
- || (cent->gent&¢->gent->e_UseFunc==useF_shield_power_converter_use)
- || (s1->eFlags&EF_FORCE_VISIBLE) )
- {//really, we only need to do this for things like thermals, detpacks and tripmines, no?
- CG_AddForceSightShell( &ent, cent );
+ // draw force sight shell around it, too
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number &&
+ CG_PlayerCanSeeCent(cent)) { // so player can see dark missiles/explosives
+ if (s1->weapon == WP_THERMAL || s1->weapon == WP_DET_PACK || s1->weapon == WP_TRIP_MINE ||
+ (cent->gent && cent->gent->e_UseFunc == useF_ammo_power_converter_use) ||
+ (cent->gent && cent->gent->e_UseFunc == useF_shield_power_converter_use) ||
+ (s1->eFlags & EF_FORCE_VISIBLE)) { // really, we only need to do this for things like thermals, detpacks and tripmines, no?
+ CG_AddForceSightShell(&ent, cent);
}
}
}
@@ -873,16 +729,16 @@ CG_Speaker
Speaker entities can automatically play sounds
==================
*/
-static void CG_Speaker( centity_t *cent ) {
- if ( ! cent->currentState.clientNum ) { // FIXME: use something other than clientNum...
- return; // not auto triggering
+static void CG_Speaker(centity_t *cent) {
+ if (!cent->currentState.clientNum) { // FIXME: use something other than clientNum...
+ return; // not auto triggering
}
- if ( cg.time < cent->miscTime ) {
+ if (cg.time < cent->miscTime) {
return;
}
- cgi_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.sound_precache[cent->currentState.eventParm] );
+ cgi_S_StartSound(NULL, cent->currentState.number, CHAN_ITEM, cgs.sound_precache[cent->currentState.eventParm]);
// ent->s.frame = ent->wait * 10;
// ent->s.clientNum = ent->random * 10;
@@ -894,45 +750,40 @@ static void CG_Speaker( centity_t *cent ) {
CG_Item
==================
*/
-static void CG_Item( centity_t *cent )
-{
- refEntity_t ent;
- entityState_t *es;
- gitem_t *item;
-// int msec;
-// float frac;
- float scale;
+static void CG_Item(centity_t *cent) {
+ refEntity_t ent;
+ entityState_t *es;
+ gitem_t *item;
+ // int msec;
+ // float frac;
+ float scale;
es = ¢->currentState;
- if ( es->modelindex >= bg_numItems )
- {
- CG_Error( "Bad item index %i on entity", es->modelindex );
+ if (es->modelindex >= bg_numItems) {
+ CG_Error("Bad item index %i on entity", es->modelindex);
}
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
// if set to invisible, skip
- if ( (!es->modelindex && !cent->gent->ghoul2.IsValid() ) || ( es->eFlags & EF_NODRAW ) )
- {
+ if ((!es->modelindex && !cent->gent->ghoul2.IsValid()) || (es->eFlags & EF_NODRAW)) {
return;
}
-/*
-Ghoul2 Insert End
-*/
- if ( cent->gent && !cent->gent->inuse )
- {
+ /*
+ Ghoul2 Insert End
+ */
+ if (cent->gent && !cent->gent->inuse) {
// Yeah, I know....items were being freed on touch, but it could still get here and draw incorrectly...
return;
}
- item = &bg_itemlist[ es->modelindex ];
+ item = &bg_itemlist[es->modelindex];
- if ( cg_simpleItems.integer )
- {
- memset( &ent, 0, sizeof( ent ) );
+ if (cg_simpleItems.integer) {
+ memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
- VectorCopy( cent->lerpOrigin, ent.origin );
+ VectorCopy(cent->lerpOrigin, ent.origin);
ent.origin[2] += 16;
ent.radius = 14;
ent.customShader = cg_items[es->modelindex].icon;
@@ -945,153 +796,129 @@ Ghoul2 Insert End
return;
}
- memset (&ent, 0, sizeof(ent));
+ memset(&ent, 0, sizeof(ent));
// items bob up and down continuously
- if( item->giType == IT_HOLOCRON )
- {
+ if (item->giType == IT_HOLOCRON) {
scale = 0.005f + cent->currentState.number * 0.00001f;
- cent->lerpOrigin[2] += (float)(4 + cos( ( cg.time + 1000 ) * scale ) * 3)+8; // just raised them up a bit
+ cent->lerpOrigin[2] += (float)(4 + cos((cg.time + 1000) * scale) * 3) + 8; // just raised them up a bit
}
-
-
// autorotate at one of two speeds
-// if ( item->giType == IT_HEALTH ) {
-// VectorCopy( cg.autoAnglesFast, cent->lerpAngles );
-// AxisCopy( cg.autoAxisFast, ent.axis );
-// } else {
- if( item->giType == IT_HOLOCRON )
- {
- VectorCopy( cg.autoAngles, cent->lerpAngles );
- AxisCopy( cg.autoAxis, ent.axis );
+ // if ( item->giType == IT_HEALTH ) {
+ // VectorCopy( cg.autoAnglesFast, cent->lerpAngles );
+ // AxisCopy( cg.autoAxisFast, ent.axis );
+ // } else {
+ if (item->giType == IT_HOLOCRON) {
+ VectorCopy(cg.autoAngles, cent->lerpAngles);
+ AxisCopy(cg.autoAxis, ent.axis);
}
-
// the weapons have their origin where they attatch to player
// models, so we need to offset them or they will rotate
// eccentricly
-// if ( item->giType == IT_WEAPON ) {
-// weaponInfo_t *wi;
-//
-// wi = &cg_weapons[item->giTag];
-// cent->lerpOrigin[0] -=
-// wi->weaponMidpoint[0] * ent.axis[0][0] +
-// wi->weaponMidpoint[1] * ent.axis[1][0] +
-// wi->weaponMidpoint[2] * ent.axis[2][0];
-// cent->lerpOrigin[1] -=
-// wi->weaponMidpoint[0] * ent.axis[0][1] +
-// wi->weaponMidpoint[1] * ent.axis[1][1] +
-// wi->weaponMidpoint[2] * ent.axis[2][1];
-// cent->lerpOrigin[2] -=
-// wi->weaponMidpoint[0] * ent.axis[0][2] +
-// wi->weaponMidpoint[1] * ent.axis[1][2] +
-// wi->weaponMidpoint[2] * ent.axis[2][2];
-
-// cent->lerpOrigin[2] += 8; // an extra height boost
-// }
+ // if ( item->giType == IT_WEAPON ) {
+ // weaponInfo_t *wi;
+ //
+ // wi = &cg_weapons[item->giTag];
+ // cent->lerpOrigin[0] -=
+ // wi->weaponMidpoint[0] * ent.axis[0][0] +
+ // wi->weaponMidpoint[1] * ent.axis[1][0] +
+ // wi->weaponMidpoint[2] * ent.axis[2][0];
+ // cent->lerpOrigin[1] -=
+ // wi->weaponMidpoint[0] * ent.axis[0][1] +
+ // wi->weaponMidpoint[1] * ent.axis[1][1] +
+ // wi->weaponMidpoint[2] * ent.axis[2][1];
+ // cent->lerpOrigin[2] -=
+ // wi->weaponMidpoint[0] * ent.axis[0][2] +
+ // wi->weaponMidpoint[1] * ent.axis[1][2] +
+ // wi->weaponMidpoint[2] * ent.axis[2][2];
+
+ // cent->lerpOrigin[2] += 8; // an extra height boost
+ // }
vec3_t spinAngles;
- //AxisClear( ent.axis );
- VectorCopy( cent->gent->s.angles, spinAngles );
+ // AxisClear( ent.axis );
+ VectorCopy(cent->gent->s.angles, spinAngles);
- if ( cent->gent->ghoul2.IsValid()
- && cent->gent->ghoul2.size() )
- {//since modelindex is used by items as an index into items(not models), we need to ignore the hModel here to force it to use the ghoul2 model if we have one
+ if (cent->gent->ghoul2.IsValid() && cent->gent->ghoul2.size()) { // since modelindex is used by items as an index into items(not models), we need to ignore
+ // the hModel here to force it to use the ghoul2 model if we have one
ent.hModel = cgs.model_draw[0];
- }
- else
- {
+ } else {
ent.hModel = cg_items[es->modelindex].models;
}
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
CG_SetGhoul2Info(&ent, cent);
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
- VectorCopy( cent->lerpOrigin, ent.origin);
- VectorCopy( cent->lerpOrigin, ent.oldorigin);
+ VectorCopy(cent->lerpOrigin, ent.origin);
+ VectorCopy(cent->lerpOrigin, ent.oldorigin);
ent.nonNormalizedAxes = qfalse;
// lovely...this is for weapons that should be oriented vertically. For weapons lockers and such.
- if ( cent->gent->spawnflags & 16 )
- { //VectorClear( spinAngles );
- if ( item->giType == IT_WEAPON
- && item->giTag == WP_SABER )
- {
- if ( cent->gent->random )
- {//pitch specified
+ if (cent->gent->spawnflags & 16) { // VectorClear( spinAngles );
+ if (item->giType == IT_WEAPON && item->giTag == WP_SABER) {
+ if (cent->gent->random) { // pitch specified
spinAngles[PITCH] += cent->gent->random;
- }
- else
- {
+ } else {
spinAngles[PITCH] -= 20;
}
- }
- else
- {
+ } else {
spinAngles[PITCH] -= 75;
}
}
- if( item->giType != IT_HOLOCRON )
- {
- AnglesToAxis( spinAngles, ent.axis );
+ if (item->giType != IT_HOLOCRON) {
+ AnglesToAxis(spinAngles, ent.axis);
}
// items without glow textures need to keep a minimum light value
// so they are always visible
-/* if (( item->giType == IT_WEAPON ) || ( item->giType == IT_ARMOR ))
- {
- ent.renderfx |= RF_MINLIGHT;
- }
-*/
+ /* if (( item->giType == IT_WEAPON ) || ( item->giType == IT_ARMOR ))
+ {
+ ent.renderfx |= RF_MINLIGHT;
+ }
+ */
// increase the size of the weapons when they are presented as items
-// if ( item->giType == IT_WEAPON ) {
-// VectorScale( ent.axis[0], 1.5f, ent.axis[0] );
-// VectorScale( ent.axis[1], 1.5f, ent.axis[1] );
-// VectorScale( ent.axis[2], 1.5f, ent.axis[2] );
-// ent.nonNormalizedAxes = qtrue;
-// }
+ // if ( item->giType == IT_WEAPON ) {
+ // VectorScale( ent.axis[0], 1.5f, ent.axis[0] );
+ // VectorScale( ent.axis[1], 1.5f, ent.axis[1] );
+ // VectorScale( ent.axis[2], 1.5f, ent.axis[2] );
+ // ent.nonNormalizedAxes = qtrue;
+ // }
// add to refresh list
cgi_R_AddRefEntityToScene(&ent);
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && CG_PlayerCanSeeCent( cent ) )
- {
- CG_AddForceSightShell( &ent, cent );
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number && CG_PlayerCanSeeCent(cent)) {
+ CG_AddForceSightShell(&ent, cent);
}
- if ( item->giType == IT_WEAPON
- && item->giTag == WP_SABER
- && (!cent->gent || !(cent->gent->spawnflags&64/*ITMSF_NOGLOW*/)) )
- {
+ if (item->giType == IT_WEAPON && item->giTag == WP_SABER && (!cent->gent || !(cent->gent->spawnflags & 64 /*ITMSF_NOGLOW*/))) {
// saber pickup item needs to be more visible
- float wv;
- vec3_t org;
+ float wv;
+ vec3_t org;
- ent.customShader = cgi_R_RegisterShader( "gfx/effects/solidWhite_cull" );
+ ent.customShader = cgi_R_RegisterShader("gfx/effects/solidWhite_cull");
ent.renderfx = RF_RGB_TINT;
- wv = sin( cg.time * 0.002f ) * 0.08f + 0.2f;
+ wv = sin(cg.time * 0.002f) * 0.08f + 0.2f;
ent.shaderRGBA[0] = ent.shaderRGBA[1] = wv * 255;
ent.shaderRGBA[2] = 0;
cgi_R_AddRefEntityToScene(&ent);
- for ( int i = -4; i < 10; i += 1 )
- {
- VectorMA( ent.origin, -i, ent.axis[2], org );
+ for (int i = -4; i < 10; i += 1) {
+ VectorMA(ent.origin, -i, ent.axis[2], org);
- FX_AddSprite( org, NULL, NULL, 10.0f, 10.0f, wv * 0.5f, wv * 0.5f, 0.0f, 0.0f, 1.0f, cgs.media.yellowDroppedSaberShader, 0x08000000 );
+ FX_AddSprite(org, NULL, NULL, 10.0f, 10.0f, wv * 0.5f, wv * 0.5f, 0.0f, 0.0f, 1.0f, cgs.media.yellowDroppedSaberShader, 0x08000000);
}
// THIS light looks crappy...maybe it should just be removed...
- cgi_R_AddLightToScene( ent.origin, wv * 350 + 180, 1.0f, 1.0f, 0.0f );
+ cgi_R_AddLightToScene(ent.origin, wv * 350 + 180, 1.0f, 1.0f, 0.0f);
}
}
@@ -1102,181 +929,156 @@ Ghoul2 Insert End
CG_Missile
===============
*/
-static void CG_Missile( centity_t *cent ) {
- refEntity_t ent;
- entityState_t *s1;
- const weaponInfo_t *weapon;
- const weaponData_t *wData;
+static void CG_Missile(centity_t *cent) {
+ refEntity_t ent;
+ entityState_t *s1;
+ const weaponInfo_t *weapon;
+ const weaponData_t *wData;
- if ( !cent->gent->inuse )
+ if (!cent->gent->inuse)
return;
s1 = ¢->currentState;
- if ( s1->weapon >= WP_NUM_WEAPONS ) {
+ if (s1->weapon >= WP_NUM_WEAPONS) {
s1->weapon = 0;
}
weapon = &cg_weapons[s1->weapon];
wData = &weaponData[s1->weapon];
- if ( s1->pos.trType != TR_INTERPOLATE )
- {
+ if (s1->pos.trType != TR_INTERPOLATE) {
// calculate the axis
- VectorCopy( s1->angles, cent->lerpAngles );
+ VectorCopy(s1->angles, cent->lerpAngles);
}
- if ( s1->otherEntityNum2 && (g_vehWeaponInfo[s1->otherEntityNum2].iShotFX || g_vehWeaponInfo[s1->otherEntityNum2].iModel) )
- {
+ if (s1->otherEntityNum2 && (g_vehWeaponInfo[s1->otherEntityNum2].iShotFX || g_vehWeaponInfo[s1->otherEntityNum2].iModel)) {
vec3_t forward;
- if (s1->eFlags & EF_USE_ANGLEDELTA)
- {
+ if (s1->eFlags & EF_USE_ANGLEDELTA) {
AngleVectors(cent->currentState.angles, forward, 0, 0);
- }
- else
- {
- if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
- {
- if ( VectorNormalize2( s1->pos.trDelta, forward ) == 0.0f )
- {
+ } else {
+ if (VectorNormalize2(cent->gent->s.pos.trDelta, forward) == 0.0f) {
+ if (VectorNormalize2(s1->pos.trDelta, forward) == 0.0f) {
forward[2] = 1.0f;
}
}
}
- // hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
+ // hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so
+ // harshly
int dif = cg.time - cent->gent->s.pos.trTime;
- if ( dif < 75 )
- {
- if ( dif < 0 )
- {
+ if (dif < 75) {
+ if (dif < 0) {
dif = 0;
}
- float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
+ float scale = (dif / 75.0f) * 0.95f + 0.05f;
- VectorScale( forward, scale, forward );
+ VectorScale(forward, scale, forward);
}
CG_PlayEffectID(g_vehWeaponInfo[s1->otherEntityNum2].iShotFX, cent->lerpOrigin, forward);
- if ( g_vehWeaponInfo[s1->otherEntityNum2].iLoopSound )
- {
- vec3_t velocity;
- EvaluateTrajectoryDelta( ¢->currentState.pos, cg.time, velocity );
- if (cgs.sound_precache[g_vehWeaponInfo[s1->otherEntityNum2].iLoopSound] != NULL_SFX)
- {
- cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, velocity, cgs.sound_precache[g_vehWeaponInfo[s1->otherEntityNum2].iLoopSound] );
+ if (g_vehWeaponInfo[s1->otherEntityNum2].iLoopSound) {
+ vec3_t velocity;
+ EvaluateTrajectoryDelta(¢->currentState.pos, cg.time, velocity);
+ if (cgs.sound_precache[g_vehWeaponInfo[s1->otherEntityNum2].iLoopSound] != NULL_SFX) {
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, velocity,
+ cgs.sound_precache[g_vehWeaponInfo[s1->otherEntityNum2].iLoopSound]);
}
}
- //add custom model
- if ( !g_vehWeaponInfo[s1->otherEntityNum2].iModel )
- {
+ // add custom model
+ if (!g_vehWeaponInfo[s1->otherEntityNum2].iModel) {
return;
}
- }
- else if ( cent->gent->alt_fire )
- {
+ } else if (cent->gent->alt_fire) {
// add trails
- if ( weapon->alt_missileTrailFunc )
- weapon->alt_missileTrailFunc( cent, weapon );
+ if (weapon->alt_missileTrailFunc)
+ weapon->alt_missileTrailFunc(cent, weapon);
// add dynamic light
- if ( wData->alt_missileDlight )
- cgi_R_AddLightToScene(cent->lerpOrigin, wData->alt_missileDlight,
- wData->alt_missileDlightColor[0], wData->alt_missileDlightColor[1], wData->alt_missileDlightColor[2] );
+ if (wData->alt_missileDlight)
+ cgi_R_AddLightToScene(cent->lerpOrigin, wData->alt_missileDlight, wData->alt_missileDlightColor[0], wData->alt_missileDlightColor[1],
+ wData->alt_missileDlightColor[2]);
// add missile sound
- if ( weapon->alt_missileSound )
- cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->alt_missileSound );
+ if (weapon->alt_missileSound)
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->alt_missileSound);
- //Don't draw something without a model
- if ( weapon->alt_missileModel == NULL_HANDLE )
+ // Don't draw something without a model
+ if (weapon->alt_missileModel == NULL_HANDLE)
return;
- }
- else
- {
+ } else {
// add trails
- if ( weapon->missileTrailFunc )
- weapon->missileTrailFunc( cent, weapon );
+ if (weapon->missileTrailFunc)
+ weapon->missileTrailFunc(cent, weapon);
// add dynamic light
- if ( wData->missileDlight )
- cgi_R_AddLightToScene(cent->lerpOrigin, wData->missileDlight,
- wData->missileDlightColor[0], wData->missileDlightColor[1], wData->missileDlightColor[2] );
+ if (wData->missileDlight)
+ cgi_R_AddLightToScene(cent->lerpOrigin, wData->missileDlight, wData->missileDlightColor[0], wData->missileDlightColor[1],
+ wData->missileDlightColor[2]);
// add missile sound
- if ( weapon->missileSound )
- cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->missileSound );
+ if (weapon->missileSound)
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->missileSound);
- //Don't draw something without a model
- if ( weapon->missileModel == NULL_HANDLE )
+ // Don't draw something without a model
+ if (weapon->missileModel == NULL_HANDLE)
return;
}
// create the render entity
- memset (&ent, 0, sizeof(ent));
- VectorCopy( cent->lerpOrigin, ent.origin);
- VectorCopy( cent->lerpOrigin, ent.oldorigin);
-/*
-Ghoul2 Insert Start
-*/
+ memset(&ent, 0, sizeof(ent));
+ VectorCopy(cent->lerpOrigin, ent.origin);
+ VectorCopy(cent->lerpOrigin, ent.oldorigin);
+ /*
+ Ghoul2 Insert Start
+ */
CG_SetGhoul2Info(&ent, cent);
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
// flicker between two skins
ent.skinNum = cg.clientFrame & 1;
- ent.renderfx = /*weapon->missileRenderfx | */RF_NOSHADOW;
+ ent.renderfx = /*weapon->missileRenderfx | */ RF_NOSHADOW;
- if ( s1->otherEntityNum2 && g_vehWeaponInfo[s1->otherEntityNum2].iModel && cgs.model_draw[g_vehWeaponInfo[s1->otherEntityNum2].iModel] != NULL_HANDLE)
+ if (s1->otherEntityNum2 && g_vehWeaponInfo[s1->otherEntityNum2].iModel && cgs.model_draw[g_vehWeaponInfo[s1->otherEntityNum2].iModel] != NULL_HANDLE)
ent.hModel = cgs.model_draw[g_vehWeaponInfo[s1->otherEntityNum2].iModel];
- else if ( cent->gent->alt_fire )
+ else if (cent->gent->alt_fire)
ent.hModel = weapon->alt_missileModel;
else
ent.hModel = weapon->missileModel;
// spin as it moves
- if ( s1->apos.trType != TR_INTERPOLATE )
- {
+ if (s1->apos.trType != TR_INTERPOLATE) {
// convert direction of travel into axis
- if ( VectorNormalize2( s1->pos.trDelta, ent.axis[0] ) == 0 ) {
+ if (VectorNormalize2(s1->pos.trDelta, ent.axis[0]) == 0) {
ent.axis[0][2] = 1;
}
- if ( s1->pos.trType != TR_STATIONARY )
- {
- if ( s1->eFlags & EF_MISSILE_STICK )
- RotateAroundDirection( ent.axis, cg.time * 0.5f );//Did this so regular missiles don't get broken
+ if (s1->pos.trType != TR_STATIONARY) {
+ if (s1->eFlags & EF_MISSILE_STICK)
+ RotateAroundDirection(ent.axis, cg.time * 0.5f); // Did this so regular missiles don't get broken
else
- RotateAroundDirection( ent.axis, cg.time * 0.25f );//JFM:FLOAT FIX
- }
- else
- {
- if ( s1->eFlags & EF_MISSILE_STICK )
- RotateAroundDirection( ent.axis, (float)s1->pos.trTime * 0.5f );
+ RotateAroundDirection(ent.axis, cg.time * 0.25f); // JFM:FLOAT FIX
+ } else {
+ if (s1->eFlags & EF_MISSILE_STICK)
+ RotateAroundDirection(ent.axis, (float)s1->pos.trTime * 0.5f);
else
- RotateAroundDirection( ent.axis, (float)s1->time );
+ RotateAroundDirection(ent.axis, (float)s1->time);
}
- }
- else
- {
- AnglesToAxis( cent->lerpAngles, ent.axis );
+ } else {
+ AnglesToAxis(cent->lerpAngles, ent.axis);
}
// add to refresh list, possibly with quad glow
- CG_AddRefEntityWithPowerups( &ent, s1->powerups, NULL );
+ CG_AddRefEntityWithPowerups(&ent, s1->powerups, NULL);
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && CG_PlayerCanSeeCent( cent ) )
- {//so player can see dark missiles/explosives
- if ( s1->weapon == WP_THERMAL
- || s1->weapon == WP_DET_PACK
- || s1->weapon == WP_TRIP_MINE
- || (s1->eFlags&EF_FORCE_VISIBLE) )
- {//really, we only need to do this for things like thermals, detpacks and tripmines, no?
- CG_AddForceSightShell( &ent, cent );
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number &&
+ CG_PlayerCanSeeCent(cent)) { // so player can see dark missiles/explosives
+ if (s1->weapon == WP_THERMAL || s1->weapon == WP_DET_PACK || s1->weapon == WP_TRIP_MINE ||
+ (s1->eFlags & EF_FORCE_VISIBLE)) { // really, we only need to do this for things like thermals, detpacks and tripmines, no?
+ CG_AddForceSightShell(&ent, cent);
}
}
}
@@ -1287,121 +1089,107 @@ CG_Mover
===============
*/
-#define DOOR_OPENING 1
-#define DOOR_CLOSING 2
-#define DOOR_OPEN 3
-#define DOOR_CLOSED 4
+#define DOOR_OPENING 1
+#define DOOR_CLOSING 2
+#define DOOR_OPEN 3
+#define DOOR_CLOSED 4
-static void CG_Mover( centity_t *cent ) {
- refEntity_t ent;
- entityState_t *s1;
+static void CG_Mover(centity_t *cent) {
+ refEntity_t ent;
+ entityState_t *s1;
s1 = ¢->currentState;
// create the render entity
- memset (&ent, 0, sizeof(ent));
- //FIXME: why are these always 0, 0, 0???!
- VectorCopy( cent->lerpOrigin, ent.origin);
- VectorCopy( cent->lerpOrigin, ent.oldorigin);
- AnglesToAxis( cent->lerpAngles, ent.axis );
-/*
-Ghoul2 Insert Start
-*/
+ memset(&ent, 0, sizeof(ent));
+ // FIXME: why are these always 0, 0, 0???!
+ VectorCopy(cent->lerpOrigin, ent.origin);
+ VectorCopy(cent->lerpOrigin, ent.oldorigin);
+ AnglesToAxis(cent->lerpAngles, ent.axis);
+ /*
+ Ghoul2 Insert Start
+ */
CG_SetGhoul2Info(&ent, cent);
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
ent.renderfx = RF_NOSHADOW;
// flicker between two skins (FIXME?)
- ent.skinNum = ( cg.time >> 6 ) & 1;
+ ent.skinNum = (cg.time >> 6) & 1;
// get the model, either as a bmodel or a modelindex
- if ( s1->solid == SOLID_BMODEL ) {
+ if (s1->solid == SOLID_BMODEL) {
ent.hModel = cgs.inlineDrawModel[s1->modelindex];
} else {
ent.hModel = cgs.model_draw[s1->modelindex];
}
// If there isn't an hModel for this mover, an RGB axis model will get drawn.
- if ( !ent.hModel )
- {
+ if (!ent.hModel) {
return;
}
- if ( cent->currentState.eFlags & EF_DISABLE_SHADER_ANIM )
- {
+ if (cent->currentState.eFlags & EF_DISABLE_SHADER_ANIM) {
// by setting the shader time to the current time, we can force an animating shader to not animate
ent.shaderTime = cg.time * 0.001f;
}
// add the secondary model
- if ( s1->solid == SOLID_BMODEL && s1->modelindex2 )
- {
-// vec3_t org;
- if ( !(s1->eFlags & EF_NODRAW) )
- {
+ if (s1->solid == SOLID_BMODEL && s1->modelindex2) {
+ // vec3_t org;
+ if (!(s1->eFlags & EF_NODRAW)) {
// add to refresh list
- CG_AddRefEntWithTransportEffect( cent, &ent );
+ CG_AddRefEntWithTransportEffect(cent, &ent);
}
-/* // Um, this does not interpolate nicely? Not sure why it was here....
- VectorAdd(cent->gent->absmin, cent->gent->absmax, org);
- VectorScale(org, 0.5, org);
- VectorCopy( org, ent.origin);
- VectorCopy( org, ent.oldorigin);
-*/
- if ( !VectorCompare( vec3_origin, cent->gent->modelAngles ) )
- {//we have a rotational offset for the model for this brush
+ /* // Um, this does not interpolate nicely? Not sure why it was here....
+ VectorAdd(cent->gent->absmin, cent->gent->absmax, org);
+ VectorScale(org, 0.5, org);
+ VectorCopy( org, ent.origin);
+ VectorCopy( org, ent.oldorigin);
+ */
+ if (!VectorCompare(vec3_origin, cent->gent->modelAngles)) { // we have a rotational offset for the model for this brush
vec3_t modelAngles;
- VectorAdd( cent->lerpAngles, cent->gent->modelAngles, modelAngles );
- AnglesToAxis( modelAngles, ent.axis );
+ VectorAdd(cent->lerpAngles, cent->gent->modelAngles, modelAngles);
+ AnglesToAxis(modelAngles, ent.axis);
}
ent.hModel = cgs.model_draw[s1->modelindex2];
}
// I changed it to always do it because nodraw seemed like it should actually do what it says. Be aware that if you change this,
// the movers for the shooting gallery on doom_detention will break.
- if ( (s1->eFlags & EF_NODRAW) )
- {
+ if ((s1->eFlags & EF_NODRAW)) {
return;
}
- //fall through and render the hModel or...
+ // fall through and render the hModel or...
- //We're a normal model being moved, animate our model
+ // We're a normal model being moved, animate our model
ent.skinNum = 0;
- if ( s1->eFlags & EF_ANIM_ONCE )
- {//FIXME: needs to anim at once per 100 ms
+ if (s1->eFlags & EF_ANIM_ONCE) { // FIXME: needs to anim at once per 100 ms
ent.frame = cent->gent->s.frame;
- ent.renderfx|=RF_CAP_FRAMES;
- }
- else if ( s1->eFlags & EF_ANIM_ALLFAST )
- {
+ ent.renderfx |= RF_CAP_FRAMES;
+ } else if (s1->eFlags & EF_ANIM_ALLFAST) {
ent.frame = (cg.time / 100);
- ent.renderfx|=RF_WRAP_FRAMES;
- }
- else
- {
+ ent.renderfx |= RF_WRAP_FRAMES;
+ } else {
ent.frame = s1->frame;
}
- if ( s1->eFlags & EF_SHADER_ANIM )
- {
- ent.renderfx|=RF_SETANIMINDEX;
+ if (s1->eFlags & EF_SHADER_ANIM) {
+ ent.renderfx |= RF_SETANIMINDEX;
ent.skinNum = s1->frame;
- //ent.shaderTime = cg.time*0.001f - s1->frame/s1->time;//NOTE: s1->time is number of frames
+ // ent.shaderTime = cg.time*0.001f - s1->frame/s1->time;//NOTE: s1->time is number of frames
}
// add to refresh list
- CG_AddRefEntWithTransportEffect( cent, &ent );
+ CG_AddRefEntWithTransportEffect(cent, &ent);
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && (s1->eFlags&EF_FORCE_VISIBLE) )
- {//so player can see func_breakables
- CG_AddForceSightShell( &ent, cent );
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number &&
+ (s1->eFlags & EF_FORCE_VISIBLE)) { // so player can see func_breakables
+ CG_AddForceSightShell(&ent, cent);
}
}
@@ -1412,51 +1200,44 @@ CG_Beam
Also called as an event
===============
*/
-void CG_Beam( centity_t *cent, int color ) {
- refEntity_t ent;
- entityState_t *s1;
+void CG_Beam(centity_t *cent, int color) {
+ refEntity_t ent;
+ entityState_t *s1;
s1 = ¢->currentState;
// create the render entity
- memset (&ent, 0, sizeof(ent));
- VectorCopy( s1->pos.trBase, ent.origin );
- VectorCopy( s1->origin2, ent.oldorigin );
- AxisClear( ent.axis );
+ memset(&ent, 0, sizeof(ent));
+ VectorCopy(s1->pos.trBase, ent.origin);
+ VectorCopy(s1->origin2, ent.oldorigin);
+ AxisClear(ent.axis);
ent.reType = RT_BEAM;
ent.skinNum = color;
ent.renderfx = RF_NOSHADOW;
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
CG_SetGhoul2Info(&ent, cent);
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
// add to refresh list
cgi_R_AddRefEntityToScene(&ent);
}
-static vec2_t st[] =
-{
- { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f }
-};
+static vec2_t st[] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
-void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha )
-{
- vec3_t point[4], rot={0,0,0};
- int vec[3];
- int axis, i;
+void CG_Cube(vec3_t mins, vec3_t maxs, vec3_t color, float alpha) {
+ vec3_t point[4], rot = {0, 0, 0};
+ int vec[3];
+ int axis, i;
- for ( axis = 0, vec[0] = 0, vec[1] = 1, vec[2] = 2; axis < 3; axis++, vec[0]++, vec[1]++, vec[2]++ )
- {
- for ( i = 0; i < 3; i++ )
- {
- if ( vec[i] > 2 )
- {
+ for (axis = 0, vec[0] = 0, vec[1] = 1, vec[2] = 2; axis < 3; axis++, vec[0]++, vec[1]++, vec[2]++) {
+ for (i = 0; i < 3; i++) {
+ if (vec[i] > 2) {
vec[i] = 0;
}
}
@@ -1476,31 +1257,23 @@ void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha )
//- face
point[0][vec[0]] = point[1][vec[0]] = point[2][vec[0]] = point[3][vec[0]] = mins[vec[0]];
- FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f,
- color, color, 0.0f, rot, 0.0f, 0.0f,
- 100, cgs.media.solidWhiteShader, 0 );
+ FX_AddPoly(point, st, 4, NULL, NULL, alpha, alpha, 0.0f, color, color, 0.0f, rot, 0.0f, 0.0f, 100, cgs.media.solidWhiteShader, 0);
//+ face
point[0][vec[0]] = point[1][vec[0]] = point[2][vec[0]] = point[3][vec[0]] = maxs[vec[0]];
- FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f,
- color, color, 0.0f, rot, 0.0f, 0.0f,
- 100, cgs.media.solidWhiteShader, 0 );
+ FX_AddPoly(point, st, 4, NULL, NULL, alpha, alpha, 0.0f, color, color, 0.0f, rot, 0.0f, 0.0f, 100, cgs.media.solidWhiteShader, 0);
}
}
-void CG_CubeOutline( vec3_t mins, vec3_t maxs, int time, unsigned int color, float alpha )
-{
- vec3_t point1, point2, point3, point4;
- int vec[3];
- int axis, i;
+void CG_CubeOutline(vec3_t mins, vec3_t maxs, int time, unsigned int color, float alpha) {
+ vec3_t point1, point2, point3, point4;
+ int vec[3];
+ int axis, i;
- for ( axis = 0, vec[0] = 0, vec[1] = 1, vec[2] = 2; axis < 3; axis++, vec[0]++, vec[1]++, vec[2]++ )
- {
- for ( i = 0; i < 3; i++ )
- {
- if ( vec[i] > 2 )
- {
+ for (axis = 0, vec[0] = 0, vec[1] = 1, vec[2] = 2; axis < 3; axis++, vec[0]++, vec[1]++, vec[2]++) {
+ for (i = 0; i < 3; i++) {
+ if (vec[i] > 2) {
vec[i] = 0;
}
}
@@ -1520,23 +1293,22 @@ void CG_CubeOutline( vec3_t mins, vec3_t maxs, int time, unsigned int color, flo
//- face
point1[vec[0]] = point2[vec[0]] = point3[vec[0]] = point4[vec[0]] = mins[vec[0]];
- CG_TestLine( point1, point2, time, color, 1 );
- CG_TestLine( point2, point3, time, color, 1 );
- CG_TestLine( point1, point4, time, color, 1 );
- CG_TestLine( point4, point3, time, color, 1 );
+ CG_TestLine(point1, point2, time, color, 1);
+ CG_TestLine(point2, point3, time, color, 1);
+ CG_TestLine(point1, point4, time, color, 1);
+ CG_TestLine(point4, point3, time, color, 1);
//+ face
point1[vec[0]] = point2[vec[0]] = point3[vec[0]] = point4[vec[0]] = maxs[vec[0]];
- CG_TestLine( point1, point2, time, color, 1 );
- CG_TestLine( point2, point3, time, color, 1 );
- CG_TestLine( point1, point4, time, color, 1 );
- CG_TestLine( point4, point1, time, color, 1 );
+ CG_TestLine(point1, point2, time, color, 1);
+ CG_TestLine(point2, point3, time, color, 1);
+ CG_TestLine(point1, point4, time, color, 1);
+ CG_TestLine(point4, point1, time, color, 1);
}
}
-void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha )
-{
+void CG_Line(vec3_t start, vec3_t end, vec3_t color, float alpha) {
/*FX_AddLine( start,
end,
1.0f,
@@ -1555,47 +1327,45 @@ void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha )
CG_Portal
===============
*/
-static void CG_Portal( centity_t *cent ) {
- refEntity_t ent;
- entityState_t *s1;
+static void CG_Portal(centity_t *cent) {
+ refEntity_t ent;
+ entityState_t *s1;
s1 = ¢->currentState;
- //FIXME: this tends to give a bad axis[1], perhaps we
- //should just do the VectorSubtraction here rather than
- //on the game side. Would also allow camera to follow
- //a moving target.
+ // FIXME: this tends to give a bad axis[1], perhaps we
+ // should just do the VectorSubtraction here rather than
+ // on the game side. Would also allow camera to follow
+ // a moving target.
// create the render entity
- memset (&ent, 0, sizeof(ent));
- VectorCopy( cent->lerpOrigin, ent.origin );
- VectorCopy( s1->origin2, ent.oldorigin );
- ByteToDir( s1->eventParm, ent.axis[0] );
- PerpendicularVector( ent.axis[1], ent.axis[0] );
+ memset(&ent, 0, sizeof(ent));
+ VectorCopy(cent->lerpOrigin, ent.origin);
+ VectorCopy(s1->origin2, ent.oldorigin);
+ ByteToDir(s1->eventParm, ent.axis[0]);
+ PerpendicularVector(ent.axis[1], ent.axis[0]);
// negating this tends to get the directions like they want
// we really should have a camera roll value
- VectorSubtract( vec3_origin, ent.axis[1], ent.axis[1] );
+ VectorSubtract(vec3_origin, ent.axis[1], ent.axis[1]);
- CrossProduct( ent.axis[0], ent.axis[1], ent.axis[2] );
+ CrossProduct(ent.axis[0], ent.axis[1], ent.axis[2]);
ent.reType = RT_PORTALSURFACE;
- ent.frame = s1->frame; // rotation speed
- ent.skinNum = (int)(s1->clientNum/256.0 * 360); // roll offset
+ ent.frame = s1->frame; // rotation speed
+ ent.skinNum = (int)(s1->clientNum / 256.0 * 360); // roll offset
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
CG_SetGhoul2Info(&ent, cent);
-/*
-Ghoul2 Insert End
-*/
-
+ /*
+ Ghoul2 Insert End
+ */
// add to refresh list
cgi_R_AddRefEntityToScene(&ent);
}
-
/*
=========================
CG_AdjustPositionForMover
@@ -1603,33 +1373,32 @@ CG_AdjustPositionForMover
Also called by client movement prediction code
=========================
*/
-void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int atTime, vec3_t out ) {
- centity_t *cent;
- vec3_t oldOrigin, origin, deltaOrigin;
-// vec3_t oldAngles, angles, deltaAngles;
+void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int atTime, vec3_t out) {
+ centity_t *cent;
+ vec3_t oldOrigin, origin, deltaOrigin;
+ // vec3_t oldAngles, angles, deltaAngles;
- if ( moverNum <= 0 ) {
- VectorCopy( in, out );
+ if (moverNum <= 0) {
+ VectorCopy(in, out);
return;
}
- cent = &cg_entities[ moverNum ];
- if ( cent->currentState.eType != ET_MOVER ) {
- VectorCopy( in, out );
+ cent = &cg_entities[moverNum];
+ if (cent->currentState.eType != ET_MOVER) {
+ VectorCopy(in, out);
return;
}
- EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, oldOrigin );
-// EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, oldAngles );
+ EvaluateTrajectory(¢->currentState.pos, cg.snap->serverTime, oldOrigin);
+ // EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, oldAngles );
- EvaluateTrajectory( ¢->currentState.pos, atTime, origin );
-// EvaluateTrajectory( ¢->currentState.apos, atTime, angles );
+ EvaluateTrajectory(¢->currentState.pos, atTime, origin);
+ // EvaluateTrajectory( ¢->currentState.apos, atTime, angles );
- VectorSubtract( origin, oldOrigin, deltaOrigin );
-// VectorSubtract( angles, oldAngles, deltaAngles );
+ VectorSubtract(origin, oldOrigin, deltaOrigin);
+ // VectorSubtract( angles, oldAngles, deltaAngles );
-
- VectorAdd( in, deltaOrigin, out );
+ VectorAdd(in, deltaOrigin, out);
// FIXME: origin change when on a rotating object
}
@@ -1639,57 +1408,55 @@ CG_CalcEntityLerpPositions
===============
*/
-extern char *vtos( const vec3_t v );
+extern char *vtos(const vec3_t v);
#if 1
-void CG_CalcEntityLerpPositions( centity_t *cent ) {
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE && cent->nextState ) //cent->currentState.vehicleIndex != VEHICLE_NONE )
+void CG_CalcEntityLerpPositions(centity_t *cent) {
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE &&
+ cent->nextState) // cent->currentState.vehicleIndex != VEHICLE_NONE )
{
- float f = cg.frameInterpolation;
+ float f = cg.frameInterpolation;
- cent->currentState.vehicleAngles[0] = LerpAngle( cent->currentState.vehicleAngles[0], cent->nextState->vehicleAngles[0], f );
- cent->currentState.vehicleAngles[1] = LerpAngle( cent->currentState.vehicleAngles[1], cent->nextState->vehicleAngles[1], f );
- cent->currentState.vehicleAngles[2] = LerpAngle( cent->currentState.vehicleAngles[2], cent->nextState->vehicleAngles[2], f );
+ cent->currentState.vehicleAngles[0] = LerpAngle(cent->currentState.vehicleAngles[0], cent->nextState->vehicleAngles[0], f);
+ cent->currentState.vehicleAngles[1] = LerpAngle(cent->currentState.vehicleAngles[1], cent->nextState->vehicleAngles[1], f);
+ cent->currentState.vehicleAngles[2] = LerpAngle(cent->currentState.vehicleAngles[2], cent->nextState->vehicleAngles[2], f);
}
- if ( cent->currentState.number == cg.snap->ps.clientNum)
- {
+ if (cent->currentState.number == cg.snap->ps.clientNum) {
// if the player, take position from prediction
- VectorCopy( cg.predicted_player_state.origin, cent->lerpOrigin );
- VectorCopy( cg.predicted_player_state.viewangles, cent->lerpAngles );
-/*
-Ghoul2 Insert Start
-*/
-// LerpBoneAngleOverrides(cent);
-/*
-Ghoul2 Insert End
-*/
+ VectorCopy(cg.predicted_player_state.origin, cent->lerpOrigin);
+ VectorCopy(cg.predicted_player_state.viewangles, cent->lerpAngles);
+ /*
+ Ghoul2 Insert Start
+ */
+ // LerpBoneAngleOverrides(cent);
+ /*
+ Ghoul2 Insert End
+ */
return;
}
- //FIXME: prediction on clients in timescale results in jerky positional translation
- if ( cent->interpolate )
- {
+ // FIXME: prediction on clients in timescale results in jerky positional translation
+ if (cent->interpolate) {
// if the entity has a valid next state, interpolate a value between the frames
// unless it is a mover with a known start and stop
- vec3_t current, next;
- float f;
+ vec3_t current, next;
+ float f;
// it would be an internal error to find an entity that interpolates without
// a snapshot ahead of the current one
- if ( cg.nextSnap == NULL ) {
- CG_Error( "CG_AddCEntity: cg.nextSnap == NULL" );
+ if (cg.nextSnap == NULL) {
+ CG_Error("CG_AddCEntity: cg.nextSnap == NULL");
}
f = cg.frameInterpolation;
- if ( cent->currentState.apos.trType == TR_INTERPOLATE && cent->nextState )
- {
- EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, current );
- EvaluateTrajectory( ¢->nextState->apos, cg.nextSnap->serverTime, next );
+ if (cent->currentState.apos.trType == TR_INTERPOLATE && cent->nextState) {
+ EvaluateTrajectory(¢->currentState.apos, cg.snap->serverTime, current);
+ EvaluateTrajectory(¢->nextState->apos, cg.nextSnap->serverTime, next);
- cent->lerpAngles[0] = LerpAngle( current[0], next[0], f );
- cent->lerpAngles[1] = LerpAngle( current[1], next[1], f );
- cent->lerpAngles[2] = LerpAngle( current[2], next[2], f );
+ cent->lerpAngles[0] = LerpAngle(current[0], next[0], f);
+ cent->lerpAngles[1] = LerpAngle(current[1], next[1], f);
+ cent->lerpAngles[2] = LerpAngle(current[2], next[2], f);
/*
if(cent->gent && cent->currentState.clientNum != 0 && !VectorCompare(current, next))
@@ -1697,9 +1464,9 @@ Ghoul2 Insert End
Com_Printf("%s last/next/lerp apos %s/%s/%s, f = %4.2f\n", cent->gent->script_targetname, vtos(current), vtos(next), vtos(cent->lerpAngles), f);
}
*/
- /*
- Ghoul2 Insert Start
- */
+ /*
+ Ghoul2 Insert Start
+ */
// now the nasty stuff - this will interpolate all ghoul2 models bone angle overrides per model attached to this cent
/*
if (cent->gent->ghoul2.size())
@@ -1707,20 +1474,19 @@ Ghoul2 Insert End
LerpBoneAngleOverrides(cent);
}
*/
- /*
- Ghoul2 Insert End
- */
+ /*
+ Ghoul2 Insert End
+ */
}
- if ( cent->currentState.pos.trType == TR_INTERPOLATE && cent->nextState )
- {
+ if (cent->currentState.pos.trType == TR_INTERPOLATE && cent->nextState) {
// this will linearize a sine or parabolic curve, but it is important
// to not extrapolate player positions if more recent data is available
- EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, current );
- EvaluateTrajectory( ¢->nextState->pos, cg.nextSnap->serverTime, next );
+ EvaluateTrajectory(¢->currentState.pos, cg.snap->serverTime, current);
+ EvaluateTrajectory(¢->nextState->pos, cg.nextSnap->serverTime, next);
- cent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] );
- cent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] );
- cent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] );
+ cent->lerpOrigin[0] = current[0] + f * (next[0] - current[0]);
+ cent->lerpOrigin[1] = current[1] + f * (next[1] - current[1]);
+ cent->lerpOrigin[2] = current[2] + f * (next[2] - current[2]);
/*
if ( cent->gent && cent->currentState.clientNum != 0 )
@@ -1728,18 +1494,14 @@ Ghoul2 Insert End
Com_Printf("%s last/next/lerp pos %s/%s/%s, f = %4.2f\n", cent->gent->script_targetname, vtos(current), vtos(next), vtos(cent->lerpOrigin), f);
}
*/
- return;//FIXME: should this be outside this if?
+ return; // FIXME: should this be outside this if?
}
- }
- else
- {
- if ( cent->currentState.apos.trType == TR_INTERPOLATE )
- {
- EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, cent->lerpAngles );
+ } else {
+ if (cent->currentState.apos.trType == TR_INTERPOLATE) {
+ EvaluateTrajectory(¢->currentState.apos, cg.snap->serverTime, cent->lerpAngles);
}
- if ( cent->currentState.pos.trType == TR_INTERPOLATE )
- {
- EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );
+ if (cent->currentState.pos.trType == TR_INTERPOLATE) {
+ EvaluateTrajectory(¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin);
/*
if(cent->gent && cent->currentState.clientNum != 0 )
{
@@ -1758,115 +1520,88 @@ Ghoul2 Insert End
{
gentity_t *ent = &g_entities[cent->currentState.number];
- if ( ent && ent->inuse)
- {
- if ( ent->s.eFlags & EF_BLOCKED_MOVER || ent->s.pos.trType == TR_STATIONARY )
- {//this mover has stopped moving and is going to wig out if we predict it
- //based on last frame's info- cut across the network and use the currentOrigin
- VectorCopy( ent->currentOrigin, cent->lerpOrigin );
+ if (ent && ent->inuse) {
+ if (ent->s.eFlags & EF_BLOCKED_MOVER ||
+ ent->s.pos.trType == TR_STATIONARY) { // this mover has stopped moving and is going to wig out if we predict it
+ // based on last frame's info- cut across the network and use the currentOrigin
+ VectorCopy(ent->currentOrigin, cent->lerpOrigin);
posData = NULL;
- }
- else
- {
+ } else {
posData = &ent->s.pos;
}
}
}
- if ( posData )
- {
- EvaluateTrajectory( posData, cg.time, cent->lerpOrigin );
+ if (posData) {
+ EvaluateTrajectory(posData, cg.time, cent->lerpOrigin);
}
// FIXME: this will stomp an apos trType of TR_INTERPOLATE!!
- EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles );
+ EvaluateTrajectory(¢->currentState.apos, cg.time, cent->lerpAngles);
// adjust for riding a mover
- CG_AdjustPositionForMover( cent->lerpOrigin, cent->currentState.groundEntityNum, cg.time, cent->lerpOrigin );
-/*
-Ghoul2 Insert Start
-*/
- // now the nasty stuff - this will interpolate all ghoul2 models bone angle overrides per model attached to this cent
+ CG_AdjustPositionForMover(cent->lerpOrigin, cent->currentState.groundEntityNum, cg.time, cent->lerpOrigin);
+ /*
+ Ghoul2 Insert Start
+ */
+ // now the nasty stuff - this will interpolate all ghoul2 models bone angle overrides per model attached to this cent
/*
if (cent->gent->ghoul2.size())
{
LerpBoneAngleOverrides(cent);
}
*/
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
// FIXME: perform general error decay?
}
#else
-void CG_CalcEntityLerpPositions( centity_t *cent )
-{
- if ( cent->currentState.number == cg.snap->ps.clientNum)
- {
+void CG_CalcEntityLerpPositions(centity_t *cent) {
+ if (cent->currentState.number == cg.snap->ps.clientNum) {
// if the player, take position from prediction
- VectorCopy( cg.predicted_player_state.origin, cent->lerpOrigin );
- VectorCopy( cg.predicted_player_state.viewangles, cent->lerpAngles );
-OutputDebugString(va("b=(%6.2f,%6.2f,%6.2f)\n",cent->lerpOrigin[0],cent->lerpOrigin[1],cent->lerpOrigin[2]));
+ VectorCopy(cg.predicted_player_state.origin, cent->lerpOrigin);
+ VectorCopy(cg.predicted_player_state.viewangles, cent->lerpAngles);
+ OutputDebugString(va("b=(%6.2f,%6.2f,%6.2f)\n", cent->lerpOrigin[0], cent->lerpOrigin[1], cent->lerpOrigin[2]));
return;
}
-
-if (cent->currentState.number != cg.snap->ps.clientNum&¢->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE)
-{
- if (cent->interpolate)
- {
-OutputDebugString(va("[%3d] interp %4.2f t=%6d st = %6d nst = %6d b=%6.2f nb=%6.2f\n",
- cent->currentState.number,
- cg.frameInterpolation,
- cg.time,
- cg.snap->serverTime,
- cg.nextSnap->serverTime,
- cent->currentState.pos.trBase[0],
- cent->nextState.pos.trBase[0]));
- }
- else
- {
-OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f nb=%6.2f\n",
- cent->currentState.number,
- cg.frameInterpolation,
- cg.time,
- cg.snap->serverTime,
- 0,
- cent->currentState.pos.trBase[0],
- 0.0f));
+ if (cent->currentState.number != cg.snap->ps.clientNum && cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE) {
+ if (cent->interpolate) {
+ OutputDebugString(va("[%3d] interp %4.2f t=%6d st = %6d nst = %6d b=%6.2f nb=%6.2f\n", cent->currentState.number, cg.frameInterpolation,
+ cg.time, cg.snap->serverTime, cg.nextSnap->serverTime, cent->currentState.pos.trBase[0], cent->nextState.pos.trBase[0]));
+ } else {
+ OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f nb=%6.2f\n", cent->currentState.number, cg.frameInterpolation,
+ cg.time, cg.snap->serverTime, 0, cent->currentState.pos.trBase[0], 0.0f));
+ }
}
-}
- //FIXME: prediction on clients in timescale results in jerky positional translation
- if (cent->interpolate &&
- (cent->currentState.number == cg.snap->ps.clientNum ||
- cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) )
- {
- vec3_t current, next;
- float f;
+ // FIXME: prediction on clients in timescale results in jerky positional translation
+ if (cent->interpolate && (cent->currentState.number == cg.snap->ps.clientNum || cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE)) {
+ vec3_t current, next;
+ float f;
// it would be an internal error to find an entity that interpolates without
// a snapshot ahead of the current one
- if ( cg.nextSnap == NULL )
- {
- CG_Error( "CG_AddCEntity: cg.nextSnap == NULL" );
+ if (cg.nextSnap == NULL) {
+ CG_Error("CG_AddCEntity: cg.nextSnap == NULL");
}
f = cg.frameInterpolation;
- EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, current );
- EvaluateTrajectory( ¢->nextState.apos, cg.nextSnap->serverTime, next );
+ EvaluateTrajectory(¢->currentState.apos, cg.snap->serverTime, current);
+ EvaluateTrajectory(¢->nextState.apos, cg.nextSnap->serverTime, next);
- cent->lerpAngles[0] = LerpAngle( current[0], next[0], f );
- cent->lerpAngles[1] = LerpAngle( current[1], next[1], f );
- cent->lerpAngles[2] = LerpAngle( current[2], next[2], f );
+ cent->lerpAngles[0] = LerpAngle(current[0], next[0], f);
+ cent->lerpAngles[1] = LerpAngle(current[1], next[1], f);
+ cent->lerpAngles[2] = LerpAngle(current[2], next[2], f);
- EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, current );
- EvaluateTrajectory( ¢->nextState.pos, cg.nextSnap->serverTime, next );
+ EvaluateTrajectory(¢->currentState.pos, cg.snap->serverTime, current);
+ EvaluateTrajectory(¢->nextState.pos, cg.nextSnap->serverTime, next);
- cent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] );
- cent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] );
- cent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] );
+ cent->lerpOrigin[0] = current[0] + f * (next[0] - current[0]);
+ cent->lerpOrigin[1] = current[1] + f * (next[1] - current[1]);
+ cent->lerpOrigin[2] = current[2] + f * (next[2] - current[2]);
return;
}
// just use the current frame and evaluate as best we can
@@ -1874,29 +1609,24 @@ OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f
{
gentity_t *ent = &g_entities[cent->currentState.number];
- if ( ent && ent->inuse)
- {
- if ( ent->s.eFlags & EF_BLOCKED_MOVER || ent->s.pos.trType == TR_STATIONARY )
- {//this mover has stopped moving and is going to wig out if we predict it
- //based on last frame's info- cut across the network and use the currentOrigin
- VectorCopy( ent->currentOrigin, cent->lerpOrigin );
+ if (ent && ent->inuse) {
+ if (ent->s.eFlags & EF_BLOCKED_MOVER ||
+ ent->s.pos.trType == TR_STATIONARY) { // this mover has stopped moving and is going to wig out if we predict it
+ // based on last frame's info- cut across the network and use the currentOrigin
+ VectorCopy(ent->currentOrigin, cent->lerpOrigin);
posData = NULL;
- }
- else
- {
+ } else {
posData = &ent->s.pos;
- EvaluateTrajectory(&ent->s.pos,cg.time, cent->lerpOrigin );
+ EvaluateTrajectory(&ent->s.pos, cg.time, cent->lerpOrigin);
}
- }
- else
- {
- EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );
+ } else {
+ EvaluateTrajectory(¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin);
}
}
- EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles );
+ EvaluateTrajectory(¢->currentState.apos, cg.time, cent->lerpAngles);
// adjust for riding a mover
- CG_AdjustPositionForMover( cent->lerpOrigin, cent->currentState.groundEntityNum, cg.time, cent->lerpOrigin );
+ CG_AdjustPositionForMover(cent->lerpOrigin, cent->currentState.groundEntityNum, cg.time, cent->lerpOrigin);
}
#endif
/*
@@ -1905,9 +1635,8 @@ CG_AddLocalSet
===============
*/
-static void CG_AddLocalSet( centity_t *cent )
-{
- cent->gent->setTime = cgi_S_AddLocalSet( cent->gent->soundSet, cg.refdef.vieworg, cent->lerpOrigin, cent->gent->s.number, cent->gent->setTime );
+static void CG_AddLocalSet(centity_t *cent) {
+ cent->gent->setTime = cgi_S_AddLocalSet(cent->gent->soundSet, cg.refdef.vieworg, cent->lerpOrigin, cent->gent->s.number, cent->gent->setTime);
}
/*
@@ -1916,58 +1645,46 @@ CAS_GetBModelSound
-------------------------
*/
-sfxHandle_t CAS_GetBModelSound( const char *name, int stage )
-{
- return cgi_AS_GetBModelSound( name, stage );
-}
+sfxHandle_t CAS_GetBModelSound(const char *name, int stage) { return cgi_AS_GetBModelSound(name, stage); }
-void CG_DLightThink ( centity_t *cent )
-{
- if(cent->gent)
- {
- float tDelta = cg.time - cent->gent->painDebounceTime;
- float percentage = ( tDelta/((float)cent->gent->speed) );
- vec3_t org;
- vec4_t currentRGBA;
- gentity_t *owner = NULL;
- int i;
-
- if ( percentage >= 1.0f )
- {//We hit the end
+void CG_DLightThink(centity_t *cent) {
+ if (cent->gent) {
+ float tDelta = cg.time - cent->gent->painDebounceTime;
+ float percentage = (tDelta / ((float)cent->gent->speed));
+ vec3_t org;
+ vec4_t currentRGBA;
+ gentity_t *owner = NULL;
+ int i;
+
+ if (percentage >= 1.0f) { // We hit the end
percentage = 1.0f;
- switch( cent->gent->pushDebounceTime )
- {
- case 0://Fading from start to final
- if ( cent->gent->spawnflags & 8 )
- {//PULSER
- if ( tDelta - cent->gent->speed - cent->gent->wait >= 0 )
- {//Time to start fading down
+ switch (cent->gent->pushDebounceTime) {
+ case 0: // Fading from start to final
+ if (cent->gent->spawnflags & 8) { // PULSER
+ if (tDelta - cent->gent->speed - cent->gent->wait >= 0) { // Time to start fading down
cent->gent->painDebounceTime = cg.time;
cent->gent->pushDebounceTime = 1;
percentage = 0.0f;
}
- }
- else
- {//Stick on startRGBA
+ } else { // Stick on startRGBA
percentage = 0.0f;
}
break;
- case 1://Fading from final to start
- if ( tDelta - cent->gent->speed - cent->gent->radius >= 0 )
- {//Time to start fading up
+ case 1: // Fading from final to start
+ if (tDelta - cent->gent->speed - cent->gent->radius >= 0) { // Time to start fading up
cent->gent->painDebounceTime = cg.time;
cent->gent->pushDebounceTime = 0;
percentage = 0.0f;
}
break;
- case 2://Fading from 0 intensity to start intensity
- //Time to start fading from start to final
+ case 2: // Fading from 0 intensity to start intensity
+ // Time to start fading from start to final
cent->gent->painDebounceTime = cg.time;
cent->gent->pushDebounceTime = 0;
percentage = 0.0f;
break;
- case 3://Fading from current intensity to 0 intensity
- //Time to turn off
+ case 3: // Fading from current intensity to 0 intensity
+ // Time to turn off
cent->gent->misc_dlight_active = qfalse;
cent->gent->e_clThinkFunc = clThinkF_NULL;
cent->gent->s.eType = ET_GENERAL;
@@ -1979,30 +1696,25 @@ void CG_DLightThink ( centity_t *cent )
}
}
- switch( cent->gent->pushDebounceTime )
- {
- case 0://Fading from start to final
- for ( i = 0; i < 4; i++ )
- {
- currentRGBA[i] = cent->gent->startRGBA[i] + ( (cent->gent->finalRGBA[i] - cent->gent->startRGBA[i]) * percentage );
+ switch (cent->gent->pushDebounceTime) {
+ case 0: // Fading from start to final
+ for (i = 0; i < 4; i++) {
+ currentRGBA[i] = cent->gent->startRGBA[i] + ((cent->gent->finalRGBA[i] - cent->gent->startRGBA[i]) * percentage);
}
break;
- case 1://Fading from final to start
- for ( i = 0; i < 4; i++ )
- {
- currentRGBA[i] = cent->gent->finalRGBA[i] + ( (cent->gent->startRGBA[i] - cent->gent->finalRGBA[i]) * percentage );
+ case 1: // Fading from final to start
+ for (i = 0; i < 4; i++) {
+ currentRGBA[i] = cent->gent->finalRGBA[i] + ((cent->gent->startRGBA[i] - cent->gent->finalRGBA[i]) * percentage);
}
break;
- case 2://Fading from 0 intensity to start
- for ( i = 0; i < 3; i++ )
- {
+ case 2: // Fading from 0 intensity to start
+ for (i = 0; i < 3; i++) {
currentRGBA[i] = cent->gent->startRGBA[i];
}
currentRGBA[3] = cent->gent->startRGBA[3] * percentage;
break;
- case 3://Fading from current intensity to 0
- for ( i = 0; i < 3; i++ )
- {//FIXME: use last
+ case 3: // Fading from current intensity to 0
+ for (i = 0; i < 3; i++) { // FIXME: use last
currentRGBA[i] = cent->gent->startRGBA[i];
}
currentRGBA[3] = cent->gent->startRGBA[3] - (cent->gent->startRGBA[3] * percentage);
@@ -2012,48 +1724,36 @@ void CG_DLightThink ( centity_t *cent )
break;
}
- if ( cent->gent->owner )
- {
+ if (cent->gent->owner) {
owner = cent->gent->owner;
- }
- else
- {
+ } else {
owner = cent->gent;
}
- if ( owner->s.pos.trType == TR_INTERPOLATE )
- {
- VectorCopy( cg_entities[owner->s.number].lerpOrigin, org );
- }
- else
- {
- VectorCopy( owner->currentOrigin, org );
+ if (owner->s.pos.trType == TR_INTERPOLATE) {
+ VectorCopy(cg_entities[owner->s.number].lerpOrigin, org);
+ } else {
+ VectorCopy(owner->currentOrigin, org);
}
- cgi_R_AddLightToScene(org, currentRGBA[3]*10, currentRGBA[0], currentRGBA[1], currentRGBA[2] );
+ cgi_R_AddLightToScene(org, currentRGBA[3] * 10, currentRGBA[0], currentRGBA[1], currentRGBA[2]);
}
}
-void CG_Limb ( centity_t *cent )
-{//first time we're drawn, remove us from the owner ent
- if ( cent->gent && cent->gent->owner && cent->gent->owner->ghoul2.size() )
- {
- gentity_t *owner = cent->gent->owner;
- if ( cent->gent->aimDebounceTime )
- {//done with dismemberment, just waiting to mark owner dismemberable again
- if ( cent->gent->aimDebounceTime > cg.time )
- {//still waiting
+void CG_Limb(centity_t *cent) { // first time we're drawn, remove us from the owner ent
+ if (cent->gent && cent->gent->owner && cent->gent->owner->ghoul2.size()) {
+ gentity_t *owner = cent->gent->owner;
+ if (cent->gent->aimDebounceTime) { // done with dismemberment, just waiting to mark owner dismemberable again
+ if (cent->gent->aimDebounceTime > cg.time) { // still waiting
return;
}
- //done!
+ // done!
owner->client->dismembered = false;
- //done!
+ // done!
cent->gent->e_clThinkFunc = clThinkF_NULL;
- }
- else
- {
-extern cvar_t *g_saberRealisticCombat;
- //3) turn off w/descendants that surf in original model
+ } else {
+ extern cvar_t *g_saberRealisticCombat;
+ // 3) turn off w/descendants that surf in original model
#if 0
if ( cent->gent->target )//stubTagName )
{//add smoke to cap surf, spawn effect
@@ -2068,251 +1768,197 @@ extern cvar_t *g_saberRealisticCombat;
}
}
#endif
- if ( cent->gent->target2 )//limbName
- {//turn the limb off
- //NOTE: MUST use G2SURFACEFLAG_NODESCENDANTS
- gi.G2API_SetSurfaceOnOff( &owner->ghoul2[owner->playerModel], cent->gent->target2, 0x00000100 );//G2SURFACEFLAG_NODESCENDANTS
+ if (cent->gent->target2) // limbName
+ { // turn the limb off
+ // NOTE: MUST use G2SURFACEFLAG_NODESCENDANTS
+ gi.G2API_SetSurfaceOnOff(&owner->ghoul2[owner->playerModel], cent->gent->target2, 0x00000100); // G2SURFACEFLAG_NODESCENDANTS
}
- if ( cent->gent->target3 )//stubCapName )
- {//turn on caps
- gi.G2API_SetSurfaceOnOff( &owner->ghoul2[owner->playerModel], cent->gent->target3, 0 );
+ if (cent->gent->target3) // stubCapName )
+ { // turn on caps
+ gi.G2API_SetSurfaceOnOff(&owner->ghoul2[owner->playerModel], cent->gent->target3, 0);
}
- if ( owner->weaponModel[0] > 0 )
- {//the corpse hasn't dropped their weapon
- if ( cent->gent->count == BOTH_DISMEMBER_RARM || cent->gent->count == BOTH_DISMEMBER_TORSO1 )//&& ent->s.weapon == WP_SABER && ent->weaponModel[0] != -1 )
- {//FIXME: is this first check needed with this lower one?
- gi.G2API_RemoveGhoul2Model( owner->ghoul2, owner->weaponModel[0] );
+ if (owner->weaponModel[0] > 0) { // the corpse hasn't dropped their weapon
+ if (cent->gent->count == BOTH_DISMEMBER_RARM ||
+ cent->gent->count == BOTH_DISMEMBER_TORSO1) //&& ent->s.weapon == WP_SABER && ent->weaponModel[0] != -1 )
+ { // FIXME: is this first check needed with this lower one?
+ gi.G2API_RemoveGhoul2Model(owner->ghoul2, owner->weaponModel[0]);
owner->weaponModel[0] = -1;
}
}
- if ( owner->client->NPC_class == CLASS_PROTOCOL
- || debug_subdivision->integer
- || g_saberRealisticCombat->integer )
- {
- //wait 100ms before allowing owner to be dismembered again
+ if (owner->client->NPC_class == CLASS_PROTOCOL || debug_subdivision->integer || g_saberRealisticCombat->integer) {
+ // wait 100ms before allowing owner to be dismembered again
cent->gent->aimDebounceTime = cg.time + 100;
return;
- }
- else
- {
- //done!
+ } else {
+ // done!
cent->gent->e_clThinkFunc = clThinkF_NULL;
}
}
}
}
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
-qboolean MatrixMode = qfalse;
-extern cvar_t *g_skippingcin;
-void CG_MatrixEffect ( centity_t *cent )
-{
- float MATRIX_EFFECT_TIME = 1000.0f;
- if ( (cent->currentState.boltInfo&MEF_MULTI_SPIN) )
- {//multiple spins
- if ( cent->currentState.time2 > 0 )
- {//with a custom amount of time per spin
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
+qboolean MatrixMode = qfalse;
+extern cvar_t *g_skippingcin;
+void CG_MatrixEffect(centity_t *cent) {
+ float MATRIX_EFFECT_TIME = 1000.0f;
+ if ((cent->currentState.boltInfo & MEF_MULTI_SPIN)) { // multiple spins
+ if (cent->currentState.time2 > 0) { // with a custom amount of time per spin
MATRIX_EFFECT_TIME = cent->currentState.time2;
}
- }
- else
- {
- if ( cent->currentState.eventParm
- && cent->currentState.eventParm != MATRIX_EFFECT_TIME )
- {//not a falling multi-spin, so stretch out the effect over the whole desired length (or: condenses it, too)
+ } else {
+ if (cent->currentState.eventParm &&
+ cent->currentState.eventParm !=
+ MATRIX_EFFECT_TIME) { // not a falling multi-spin, so stretch out the effect over the whole desired length (or: condenses it, too)
MATRIX_EFFECT_TIME = cent->currentState.eventParm;
}
}
- //VectorCopy( cent->lerpOrigin, cg.refdef.vieworg );
+ // VectorCopy( cent->lerpOrigin, cg.refdef.vieworg );
float totalElapsedTime = (float)(cg.time - cent->currentState.time);
float elapsedTime = totalElapsedTime;
- bool stopEffect = ((totalElapsedTime > cent->currentState.eventParm) || cg.missionStatusShow || in_camera);
+ bool stopEffect = ((totalElapsedTime > cent->currentState.eventParm) || cg.missionStatusShow || in_camera);
- if (!stopEffect && (cent->currentState.boltInfo&MEF_HIT_GROUND_STOP) && g_entities[cent->currentState.otherEntityNum].client)
- {
- if (g_entities[cent->currentState.otherEntityNum].client->ps.groundEntityNum!=ENTITYNUM_NONE)
- {
+ if (!stopEffect && (cent->currentState.boltInfo & MEF_HIT_GROUND_STOP) && g_entities[cent->currentState.otherEntityNum].client) {
+ if (g_entities[cent->currentState.otherEntityNum].client->ps.groundEntityNum != ENTITYNUM_NONE) {
stopEffect = true;
- }
- else if (g_entities[cent->currentState.otherEntityNum].client->NPC_class == CLASS_VEHICLE)
- {
- Vehicle_t* pVeh = g_entities[cent->currentState.otherEntityNum].m_pVehicle;
- if (pVeh && !(pVeh->m_ulFlags&VEH_FLYING))
- {
+ } else if (g_entities[cent->currentState.otherEntityNum].client->NPC_class == CLASS_VEHICLE) {
+ Vehicle_t *pVeh = g_entities[cent->currentState.otherEntityNum].m_pVehicle;
+ if (pVeh && !(pVeh->m_ulFlags & VEH_FLYING)) {
stopEffect = true;
}
}
}
- if (!stopEffect && (cent->currentState.boltInfo&MEF_LOOK_AT_ENEMY))
- {
- if (!g_entities[cent->currentState.otherEntityNum].lastEnemy ||
- !g_entities[cent->currentState.otherEntityNum].lastEnemy->inuse)
- {
+ if (!stopEffect && (cent->currentState.boltInfo & MEF_LOOK_AT_ENEMY)) {
+ if (!g_entities[cent->currentState.otherEntityNum].lastEnemy || !g_entities[cent->currentState.otherEntityNum].lastEnemy->inuse) {
stopEffect = true;
}
}
- if (stopEffect)
- {//time is up or this is a falling spin and they hit the ground or mission end screen is up
- cg.overrides.active &= ~(/*CG_OVERRIDE_3RD_PERSON_ENT|*/CG_OVERRIDE_3RD_PERSON_RNG|CG_OVERRIDE_3RD_PERSON_ANG|CG_OVERRIDE_3RD_PERSON_POF);
- //cg.overrides.thirdPersonEntity = 0;
+ if (stopEffect) { // time is up or this is a falling spin and they hit the ground or mission end screen is up
+ cg.overrides.active &= ~(/*CG_OVERRIDE_3RD_PERSON_ENT|*/ CG_OVERRIDE_3RD_PERSON_RNG | CG_OVERRIDE_3RD_PERSON_ANG | CG_OVERRIDE_3RD_PERSON_POF);
+ // cg.overrides.thirdPersonEntity = 0;
cg.overrides.thirdPersonAngle = 0;
cg.overrides.thirdPersonPitchOffset = 0;
cg.overrides.thirdPersonRange = 0;
- if ( g_skippingcin->integer )
- {//skipping? don't mess with timescale
+ if (g_skippingcin->integer) { // skipping? don't mess with timescale
/*
if ( g_timescale->integer < 100 )
{//something messed up timescale, reset it?
cgi_Cvar_Set( "timescale", "100" );
}
*/
- }
- else
- {//set it back to 1
- cgi_Cvar_Set( "timescale", "1.0" );
+ } else { // set it back to 1
+ cgi_Cvar_Set("timescale", "1.0");
}
MatrixMode = qfalse;
cent->gent->e_clThinkFunc = clThinkF_NULL;
cent->gent->e_ThinkFunc = thinkF_G_FreeEntity;
cent->gent->nextthink = cg.time + 500;
return;
- }
- else
- {
- while ( elapsedTime > MATRIX_EFFECT_TIME )
- {
+ } else {
+ while (elapsedTime > MATRIX_EFFECT_TIME) {
elapsedTime -= MATRIX_EFFECT_TIME;
}
}
MatrixMode = qtrue;
- //FIXME: move the position towards them and back?
- //cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ENT;
- //cg.overrides.thirdPersonEntity = cent->currentState.otherEntityNum;
+ // FIXME: move the position towards them and back?
+ // cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ENT;
+ // cg.overrides.thirdPersonEntity = cent->currentState.otherEntityNum;
- if (cent->currentState.boltInfo&MEF_LOOK_AT_ENEMY)
- {
- vec3_t toEnemy;
- vec3_t toEnemyAngles;
+ if (cent->currentState.boltInfo & MEF_LOOK_AT_ENEMY) {
+ vec3_t toEnemy;
+ vec3_t toEnemyAngles;
VectorCopy(cg_entities[g_entities[cent->currentState.otherEntityNum].lastEnemy->s.number].lerpOrigin, toEnemy);
-// CG_DrawEdge(cg_entities[cent->currentState.otherEntityNum].lerpOrigin, toEnemy, EDGE_NORMAL);
+ // CG_DrawEdge(cg_entities[cent->currentState.otherEntityNum].lerpOrigin, toEnemy, EDGE_NORMAL);
VectorSubtract(cg_entities[cent->currentState.otherEntityNum].lerpOrigin, toEnemy, toEnemy);
vectoangles(toEnemy, toEnemyAngles);
+ cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ANG;
+ cg.overrides.thirdPersonAngle = toEnemyAngles[1] - cg_entities[cent->currentState.otherEntityNum].lerpAngles[1] + 145.0f;
+ cg.overrides.thirdPersonAngle = AngleNormalize180(cg.overrides.thirdPersonAngle);
- cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ANG;
- cg.overrides.thirdPersonAngle =
- toEnemyAngles[1] -
- cg_entities[cent->currentState.otherEntityNum].lerpAngles[1] +
- 145.0f;
- cg.overrides.thirdPersonAngle = AngleNormalize180(cg.overrides.thirdPersonAngle);
-
- float MATRIX_EFFECT_TIME_HALF = MATRIX_EFFECT_TIME/2.0f;
- float X = 1.0f;
- if (elapsedTime>MATRIX_EFFECT_TIME_HALF)
- {
- X -= ((elapsedTime - MATRIX_EFFECT_TIME_HALF)/MATRIX_EFFECT_TIME_HALF);
+ float MATRIX_EFFECT_TIME_HALF = MATRIX_EFFECT_TIME / 2.0f;
+ float X = 1.0f;
+ if (elapsedTime > MATRIX_EFFECT_TIME_HALF) {
+ X -= ((elapsedTime - MATRIX_EFFECT_TIME_HALF) / MATRIX_EFFECT_TIME_HALF);
}
- cg.overrides.thirdPersonAngle *= X;
+ cg.overrides.thirdPersonAngle *= X;
- // gi.Printf("%f\n", cg.overrides.thirdPersonAngle);
- cg.overrides.thirdPersonPitchOffset = 0.0f;
- cg.overrides.thirdPersonRange = cg_thirdPersonRange.value * 3.0f;
+ // gi.Printf("%f\n", cg.overrides.thirdPersonAngle);
+ cg.overrides.thirdPersonPitchOffset = 0.0f;
+ cg.overrides.thirdPersonRange = cg_thirdPersonRange.value * 3.0f;
}
- if ( !(cent->currentState.boltInfo&MEF_NO_SPIN) )
- {//rotate around them
- //rotate
+ if (!(cent->currentState.boltInfo & MEF_NO_SPIN)) { // rotate around them
+ // rotate
cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ANG;
- cg.overrides.thirdPersonAngle = 360.0f*elapsedTime/MATRIX_EFFECT_TIME;
- if ( (cent->currentState.boltInfo&MEF_REVERSE_SPIN) )
- {
+ cg.overrides.thirdPersonAngle = 360.0f * elapsedTime / MATRIX_EFFECT_TIME;
+ if ((cent->currentState.boltInfo & MEF_REVERSE_SPIN)) {
cg.overrides.thirdPersonAngle *= -1;
}
}
- //do all the slowdown and vert bob stuff
- if ( cent->currentState.angles2[0] )
- {
- cgi_Cvar_Set( "timescale", va("%4.2f",cent->currentState.angles2[0]) );
- }
- else if ( !(cent->currentState.boltInfo&MEF_NO_TIMESCALE) )
- {//ramp the timescale
- //slowdown
- float timescale = (elapsedTime/MATRIX_EFFECT_TIME);
- if ( timescale < 0.01f )
- {
+ // do all the slowdown and vert bob stuff
+ if (cent->currentState.angles2[0]) {
+ cgi_Cvar_Set("timescale", va("%4.2f", cent->currentState.angles2[0]));
+ } else if (!(cent->currentState.boltInfo & MEF_NO_TIMESCALE)) { // ramp the timescale
+ // slowdown
+ float timescale = (elapsedTime / MATRIX_EFFECT_TIME);
+ if (timescale < 0.01f) {
timescale = 0.01f;
}
- cgi_Cvar_Set( "timescale", va("%4.2f",timescale) );
- }
- else
- {//FIXME: MEF_HIT_GROUND_STOP: if they're on the ground, stop spinning and stop timescale
- //FIXME: if they go to the menu, restore timescale?
- //cgi_Cvar_Set( "timescale", "1.0ff" );
+ cgi_Cvar_Set("timescale", va("%4.2f", timescale));
+ } else { // FIXME: MEF_HIT_GROUND_STOP: if they're on the ground, stop spinning and stop timescale
+ // FIXME: if they go to the menu, restore timescale?
+ // cgi_Cvar_Set( "timescale", "1.0ff" );
}
- if ( !(cent->currentState.boltInfo&MEF_NO_VERTBOB) )
- {//bob the pitch
- //pitch
- //dip - FIXME: use pitchOffet?
+ if (!(cent->currentState.boltInfo & MEF_NO_VERTBOB)) { // bob the pitch
+ // pitch
+ // dip - FIXME: use pitchOffet?
cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_POF;
cg.overrides.thirdPersonPitchOffset = cg_thirdPersonPitchOffset.value;
- if ( elapsedTime < MATRIX_EFFECT_TIME*0.33f )
- {
- cg.overrides.thirdPersonPitchOffset -= 30.0f*elapsedTime/(MATRIX_EFFECT_TIME*0.33);
- }
- else if ( elapsedTime > MATRIX_EFFECT_TIME*0.66f )
- {
- cg.overrides.thirdPersonPitchOffset -= 30.0f*(MATRIX_EFFECT_TIME-elapsedTime)/(MATRIX_EFFECT_TIME*0.33);
- }
- else
- {
+ if (elapsedTime < MATRIX_EFFECT_TIME * 0.33f) {
+ cg.overrides.thirdPersonPitchOffset -= 30.0f * elapsedTime / (MATRIX_EFFECT_TIME * 0.33);
+ } else if (elapsedTime > MATRIX_EFFECT_TIME * 0.66f) {
+ cg.overrides.thirdPersonPitchOffset -= 30.0f * (MATRIX_EFFECT_TIME - elapsedTime) / (MATRIX_EFFECT_TIME * 0.33);
+ } else {
cg.overrides.thirdPersonPitchOffset -= 30.0f;
}
}
- if ( !(cent->currentState.boltInfo&MEF_NO_RANGEVAR) )
- {//vary the camera range
- //pull back
+ if (!(cent->currentState.boltInfo & MEF_NO_RANGEVAR)) { // vary the camera range
+ // pull back
cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_RNG;
cg.overrides.thirdPersonRange = cg_thirdPersonRange.value;
- if ( elapsedTime < MATRIX_EFFECT_TIME*0.33 )
- {
- cg.overrides.thirdPersonRange += 80.0f*elapsedTime/(MATRIX_EFFECT_TIME*0.33);
- }
- else if ( elapsedTime > MATRIX_EFFECT_TIME*0.66 )
- {
- cg.overrides.thirdPersonRange += 80.0f*(MATRIX_EFFECT_TIME-elapsedTime)/(MATRIX_EFFECT_TIME*0.33);
- }
- else
- {
+ if (elapsedTime < MATRIX_EFFECT_TIME * 0.33) {
+ cg.overrides.thirdPersonRange += 80.0f * elapsedTime / (MATRIX_EFFECT_TIME * 0.33);
+ } else if (elapsedTime > MATRIX_EFFECT_TIME * 0.66) {
+ cg.overrides.thirdPersonRange += 80.0f * (MATRIX_EFFECT_TIME - elapsedTime) / (MATRIX_EFFECT_TIME * 0.33);
+ } else {
cg.overrides.thirdPersonRange += 80.0f;
}
}
}
-static void CG_Think ( centity_t *cent )
-{
- if(!cent->gent)
- {
+static void CG_Think(centity_t *cent) {
+ if (!cent->gent) {
return;
}
- CEntity_ThinkFunc(cent); // cent->gent->clThink(cent);
+ CEntity_ThinkFunc(cent); // cent->gent->clThink(cent);
}
-static void CG_Clouds( centity_t *cent )
-{
- refEntity_t ent;
+static void CG_Clouds(centity_t *cent) {
+ refEntity_t ent;
// create the render entity
- memset( &ent, 0, sizeof( ent ));
+ memset(&ent, 0, sizeof(ent));
- VectorCopy( cent->lerpOrigin, ent.origin );
+ VectorCopy(cent->lerpOrigin, ent.origin);
ent.shaderRGBA[0] = ent.shaderRGBA[1] = ent.shaderRGBA[2] = ent.shaderRGBA[3] = 255;
@@ -2321,22 +1967,20 @@ static void CG_Clouds( centity_t *cent )
ent.reType = RT_CLOUDS;
- if ( cent->gent->spawnflags & 1 ) // TUBE type, the one with a hole in the middle
+ if (cent->gent->spawnflags & 1) // TUBE type, the one with a hole in the middle
{
ent.rotation = cent->gent->random;
- ent.renderfx = RF_GROW;// tube flag
+ ent.renderfx = RF_GROW; // tube flag
}
- if ( cent->gent->spawnflags & 2 ) // ALT type, uses a different shader
- {
- ent.customShader = cgi_R_RegisterShader( "gfx/world/haze2" );
- }
- else
+ if (cent->gent->spawnflags & 2) // ALT type, uses a different shader
{
- ent.customShader = cgi_R_RegisterShader( "gfx/world/haze" );
+ ent.customShader = cgi_R_RegisterShader("gfx/world/haze2");
+ } else {
+ ent.customShader = cgi_R_RegisterShader("gfx/world/haze");
}
- cgi_R_AddRefEntityToScene( &ent );
+ cgi_R_AddRefEntityToScene(&ent);
}
/*
@@ -2345,48 +1989,44 @@ CG_AddCEntity
===============
*/
-static void CG_AddCEntity( centity_t *cent )
-{
+static void CG_AddCEntity(centity_t *cent) {
// event-only entities will have been dealt with already
- if ( cent->currentState.eType >= ET_EVENTS ) {
+ if (cent->currentState.eType >= ET_EVENTS) {
return;
}
- //we must have restarted the game
- if (!cent->gent)
- {
+ // we must have restarted the game
+ if (!cent->gent) {
return;
}
cent->snapShotTime = cg.time;
// calculate the current origin
- CG_CalcEntityLerpPositions( cent );
+ CG_CalcEntityLerpPositions(cent);
// add automatic effects
- CG_EntityEffects( cent );
+ CG_EntityEffects(cent);
// add local sound set if any
- if ( cent->gent && cent->gent->soundSet && cent->gent->soundSet[0] && cent->currentState.eType != ET_MOVER )
- {
- CG_AddLocalSet( cent );
+ if (cent->gent && cent->gent->soundSet && cent->gent->soundSet[0] && cent->currentState.eType != ET_MOVER) {
+ CG_AddLocalSet(cent);
}
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
// do this before we copy the data to refEnts
- if (cent->gent->ghoul2.IsValid())
- {
+ if (cent->gent->ghoul2.IsValid()) {
trap_G2_SetGhoul2ModelIndexes(cent->gent->ghoul2, cgs.model_draw, cgs.skins);
}
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
- switch ( cent->currentState.eType ) {
+ switch (cent->currentState.eType) {
default:
- CG_Error( "Bad entity type: %i\n", cent->currentState.eType );
+ CG_Error("Bad entity type: %i\n", cent->currentState.eType);
break;
case ET_INVISIBLE:
case ET_PUSH_TRIGGER:
@@ -2394,39 +2034,38 @@ Ghoul2 Insert End
case ET_TERRAIN:
break;
case ET_GENERAL:
- CG_General( cent );
+ CG_General(cent);
break;
case ET_PLAYER:
- CG_Player( cent );
+ CG_Player(cent);
break;
case ET_ITEM:
- CG_Item( cent );
+ CG_Item(cent);
break;
case ET_MISSILE:
- CG_Missile( cent );
+ CG_Missile(cent);
break;
case ET_MOVER:
- CG_Mover( cent );
+ CG_Mover(cent);
break;
case ET_BEAM:
- CG_Beam( cent, 0 );
+ CG_Beam(cent, 0);
break;
case ET_PORTAL:
- CG_Portal( cent );
+ CG_Portal(cent);
break;
case ET_SPEAKER:
- if ( cent->gent && cent->gent->soundSet && cent->gent->soundSet[0] )
- {
+ if (cent->gent && cent->gent->soundSet && cent->gent->soundSet[0]) {
break;
}
- CG_Speaker( cent );
+ CG_Speaker(cent);
break;
case ET_THINKER:
- CG_General( cent );
- CG_Think( cent );
+ CG_General(cent);
+ CG_Think(cent);
break;
case ET_CLOUD: // dumb
- CG_Clouds( cent );
+ CG_Clouds(cent);
break;
}
}
@@ -2437,87 +2076,75 @@ CG_AddPacketEntities
===============
*/
-void CG_AddPacketEntities( qboolean isPortal ) {
- int num;
- centity_t *cent;
- playerState_t *ps;
+void CG_AddPacketEntities(qboolean isPortal) {
+ int num;
+ centity_t *cent;
+ playerState_t *ps;
- if (isPortal)
- {
- for ( num = 0 ; num < cg.snap->numEntities ; num++ )
- {
- cent = &cg_entities[ cg.snap->entities[ num ].number ];
+ if (isPortal) {
+ for (num = 0; num < cg.snap->numEntities; num++) {
+ cent = &cg_entities[cg.snap->entities[num].number];
- if (cent->currentState.isPortalEnt)
- {
- CG_AddCEntity( cent );
+ if (cent->currentState.isPortalEnt) {
+ CG_AddCEntity(cent);
}
}
return;
}
// set cg.frameInterpolation
- if ( cg.nextSnap )
- {
- int delta;
+ if (cg.nextSnap) {
+ int delta;
delta = (cg.nextSnap->serverTime - cg.snap->serverTime);
- if ( delta == 0 )
- {
+ if (delta == 0) {
cg.frameInterpolation = 0;
+ } else {
+ cg.frameInterpolation = (float)(cg.time - cg.snap->serverTime) / delta;
}
- else
- {
- cg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta;
- }
-//OutputDebugString(va("interp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,cg.nextSnap->serverTime,cg.snap->serverTime));
- }
- else
- {
- cg.frameInterpolation = 0; // actually, it should never be used, because
- // no entities should be marked as interpolating
-//OutputDebugString(va("noterp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,0,cg.snap->serverTime));
+ // OutputDebugString(va("interp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,cg.nextSnap->serverTime,cg.snap->serverTime));
+ } else {
+ cg.frameInterpolation = 0; // actually, it should never be used, because
+ // no entities should be marked as interpolating
+ // OutputDebugString(va("noterp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,0,cg.snap->serverTime));
}
// the auto-rotating items will all have the same axis
cg.autoAngles[0] = 0;
- cg.autoAngles[1] = ( cg.time & 2047 ) * 360 / 2048.0f;
+ cg.autoAngles[1] = (cg.time & 2047) * 360 / 2048.0f;
cg.autoAngles[2] = 0;
cg.autoAnglesFast[0] = 0;
- cg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f;
+ cg.autoAnglesFast[1] = (cg.time & 1023) * 360 / 1024.0f;
cg.autoAnglesFast[2] = 0;
- AnglesToAxis( cg.autoAngles, cg.autoAxis );
- AnglesToAxis( cg.autoAnglesFast, cg.autoAxisFast );
+ AnglesToAxis(cg.autoAngles, cg.autoAxis);
+ AnglesToAxis(cg.autoAnglesFast, cg.autoAxisFast);
// generate and add the entity from the playerstate
ps = &cg.predicted_player_state;
- PlayerStateToEntityState( ps, &cg_entities[ ps->clientNum ].currentState );
-// cent = &cg_entities[ ps->clientNum ]; // not needed now that player is in the snap packet
-// CG_AddCEntity( cent ); //
+ PlayerStateToEntityState(ps, &cg_entities[ps->clientNum].currentState);
+ // cent = &cg_entities[ ps->clientNum ]; // not needed now that player is in the snap packet
+ // CG_AddCEntity( cent ); //
// add each entity sent over by the server
- for ( num = 0 ; num < cg.snap->numEntities ; num++ ) {
- cent = &cg_entities[ cg.snap->entities[ num ].number ];
+ for (num = 0; num < cg.snap->numEntities; num++) {
+ cent = &cg_entities[cg.snap->entities[num].number];
- CG_AddCEntity( cent );
+ CG_AddCEntity(cent);
}
- for(num=0;numcurrentValid)
- {
- CG_AddCEntity( cent );
+ if (cent->currentValid) {
+ CG_AddCEntity(cent);
}
}
}
-//rww - This function is not currently called. Use it as the client-side ROFF
-//callback once that's implemented fully.
-void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
-{
+// rww - This function is not currently called. Use it as the client-side ROFF
+// callback once that's implemented fully.
+void CG_ROFF_NotetrackCallback(centity_t *cent, const char *notetrack) {
int i = 0, r = 0, objectID = 0, anglesGathered = 0, posoffsetGathered = 0;
char type[256];
char argument[512];
@@ -2527,49 +2154,42 @@ void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
int addlArgs = 0;
vec3_t parsedAngles, parsedOffset, useAngles, useOrigin, forward, right, up;
- if (!cent || !notetrack)
- {
+ if (!cent || !notetrack) {
return;
}
- //notetrack = "effect effects/explosion1.efx 0+0+64 0-0-1";
+ // notetrack = "effect effects/explosion1.efx 0+0+64 0-0-1";
- while (notetrack[i] && notetrack[i] != ' ')
- {
+ while (notetrack[i] && notetrack[i] != ' ') {
type[i] = notetrack[i];
i++;
}
type[i] = '\0';
- if (notetrack[i] != ' ')
- { //didn't pass in a valid notetrack type, or forgot the argument for it
+ if (notetrack[i] != ' ') { // didn't pass in a valid notetrack type, or forgot the argument for it
return;
}
i++;
- while (notetrack[i] && notetrack[i] != ' ')
- {
+ while (notetrack[i] && notetrack[i] != ' ') {
argument[r] = notetrack[i];
r++;
i++;
}
argument[r] = '\0';
- if (!r)
- {
+ if (!r) {
return;
}
- if (notetrack[i] == ' ')
- { //additional arguments...
+ if (notetrack[i] == ' ') { // additional arguments...
addlArgs = 1;
i++;
r = 0;
- while (notetrack[i])
- {
+ while (notetrack[i]) {
addlArg[r] = notetrack[i];
r++;
i++;
@@ -2577,33 +2197,28 @@ void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
addlArg[r] = '\0';
}
- if (strcmp(type, "effect") == 0)
- {
- if (!addlArgs)
- {
- //sprintf(errMsg, "Offset position argument for 'effect' type is invalid.");
- //goto functionend;
+ if (strcmp(type, "effect") == 0) {
+ if (!addlArgs) {
+ // sprintf(errMsg, "Offset position argument for 'effect' type is invalid.");
+ // goto functionend;
VectorClear(parsedOffset);
goto defaultoffsetposition;
}
i = 0;
- while (posoffsetGathered < 3)
- {
+ while (posoffsetGathered < 3) {
r = 0;
- while (addlArg[i] && addlArg[i] != '+' && addlArg[i] != ' ')
- {
+ while (addlArg[i] && addlArg[i] != '+' && addlArg[i] != ' ') {
t[r] = addlArg[i];
r++;
i++;
}
t[r] = '\0';
i++;
- if (!r)
- { //failure..
- //sprintf(errMsg, "Offset position argument for 'effect' type is invalid.");
- //goto functionend;
+ if (!r) { // failure..
+ // sprintf(errMsg, "Offset position argument for 'effect' type is invalid.");
+ // goto functionend;
VectorClear(parsedOffset);
i = 0;
goto defaultoffsetposition;
@@ -2612,33 +2227,27 @@ void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
posoffsetGathered++;
}
- if (posoffsetGathered < 3)
- {
+ if (posoffsetGathered < 3) {
Q_strncpyz(errMsg, "Offset position argument for 'effect' type is invalid.", sizeof(errMsg));
goto functionend;
}
i--;
- if (addlArg[i] != ' ')
- {
+ if (addlArg[i] != ' ') {
addlArgs = 0;
}
-defaultoffsetposition:
+ defaultoffsetposition:
objectID = theFxScheduler.RegisterEffect(argument);
- if (objectID)
- {
- if (addlArgs)
- { //if there is an additional argument for an effect it is expected to be XANGLE-YANGLE-ZANGLE
+ if (objectID) {
+ if (addlArgs) { // if there is an additional argument for an effect it is expected to be XANGLE-YANGLE-ZANGLE
i++;
- while (anglesGathered < 3)
- {
+ while (anglesGathered < 3) {
r = 0;
- while (addlArg[i] && addlArg[i] != '-')
- {
+ while (addlArg[i] && addlArg[i] != '-') {
t[r] = addlArg[i];
r++;
i++;
@@ -2646,8 +2255,7 @@ void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
t[r] = '\0';
i++;
- if (!r)
- { //failed to get a new part of the vector
+ if (!r) { // failed to get a new part of the vector
anglesGathered = 0;
break;
}
@@ -2656,17 +2264,12 @@ void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
anglesGathered++;
}
- if (anglesGathered)
- {
+ if (anglesGathered) {
VectorCopy(parsedAngles, useAngles);
- }
- else
- { //failed to parse angles from the extra argument provided..
+ } else { // failed to parse angles from the extra argument provided..
VectorCopy(cent->lerpAngles, useAngles);
}
- }
- else
- { //if no constant angles, play in direction entity is facing
+ } else { // if no constant angles, play in direction entity is facing
VectorCopy(cent->lerpAngles, useAngles);
}
@@ -2674,42 +2277,34 @@ void CG_ROFF_NotetrackCallback( centity_t *cent, const char *notetrack)
VectorCopy(cent->lerpOrigin, useOrigin);
- //forward
- useOrigin[0] += forward[0]*parsedOffset[0];
- useOrigin[1] += forward[1]*parsedOffset[0];
- useOrigin[2] += forward[2]*parsedOffset[0];
+ // forward
+ useOrigin[0] += forward[0] * parsedOffset[0];
+ useOrigin[1] += forward[1] * parsedOffset[0];
+ useOrigin[2] += forward[2] * parsedOffset[0];
- //right
- useOrigin[0] += right[0]*parsedOffset[1];
- useOrigin[1] += right[1]*parsedOffset[1];
- useOrigin[2] += right[2]*parsedOffset[1];
+ // right
+ useOrigin[0] += right[0] * parsedOffset[1];
+ useOrigin[1] += right[1] * parsedOffset[1];
+ useOrigin[2] += right[2] * parsedOffset[1];
- //up
- useOrigin[0] += up[0]*parsedOffset[2];
- useOrigin[1] += up[1]*parsedOffset[2];
- useOrigin[2] += up[2]*parsedOffset[2];
+ // up
+ useOrigin[0] += up[0] * parsedOffset[2];
+ useOrigin[1] += up[1] * parsedOffset[2];
+ useOrigin[2] += up[2] * parsedOffset[2];
theFxScheduler.PlayEffect(objectID, useOrigin, useAngles);
}
- }
- else if (strcmp(type, "sound") == 0)
- {
+ } else if (strcmp(type, "sound") == 0) {
objectID = cgi_S_RegisterSound(argument);
cgi_S_StartSound(cent->lerpOrigin, cent->currentState.number, CHAN_BODY, objectID);
- }
- else if (strcmp(type, "loop") == 0)
- { //handled server-side
+ } else if (strcmp(type, "loop") == 0) { // handled server-side
return;
}
- //else if ...
- else
- {
- if (type[0])
- {
+ // else if ...
+ else {
+ if (type[0]) {
Com_Printf("^3Warning: \"%s\" is an invalid ROFF notetrack function\n", type);
- }
- else
- {
+ } else {
Com_Printf("^3Warning: Notetrack is missing function and/or arguments\n");
}
}
diff --git a/code/cgame/cg_event.cpp b/code/cgame/cg_event.cpp
index 635dfe14d9..3a967f1b6f 100644
--- a/code/cgame/cg_event.cpp
+++ b/code/cgame/cg_event.cpp
@@ -30,58 +30,57 @@ along with this program; if not, see .
#include "../game/anims.h"
-extern qboolean CG_TryPlayCustomSound( vec3_t origin, int entityNum, soundChannel_t channel, const char *soundName, int customSoundSet );
-extern void FX_KothosBeam( vec3_t start, vec3_t end );
+extern qboolean CG_TryPlayCustomSound(vec3_t origin, int entityNum, soundChannel_t channel, const char *soundName, int customSoundSet);
+extern void FX_KothosBeam(vec3_t start, vec3_t end);
//==========================================================================
-qboolean CG_IsFemale( const char *infostring ) {
- const char *sex;
+qboolean CG_IsFemale(const char *infostring) {
+ const char *sex;
- sex = Info_ValueForKey( infostring, "s" );
+ sex = Info_ValueForKey(infostring, "s");
if (sex[0] == 'f' || sex[0] == 'F')
return qtrue;
return qfalse;
}
-const char *CG_PlaceString( int rank ) {
- static char str[64];
- char *s, *t;
+const char *CG_PlaceString(int rank) {
+ static char str[64];
+ char *s, *t;
- if ( rank & RANK_TIED_FLAG ) {
+ if (rank & RANK_TIED_FLAG) {
rank &= ~RANK_TIED_FLAG;
t = "Tied for ";
} else {
t = "";
}
- if ( rank == 1 ) {
- s = "\03341st\0337"; // draw in blue
- } else if ( rank == 2 ) {
- s = "\03312nd\0337"; // draw in red
- } else if ( rank == 3 ) {
- s = "\03333rd\0337"; // draw in yellow
- } else if ( rank == 11 ) {
+ if (rank == 1) {
+ s = "\03341st\0337"; // draw in blue
+ } else if (rank == 2) {
+ s = "\03312nd\0337"; // draw in red
+ } else if (rank == 3) {
+ s = "\03333rd\0337"; // draw in yellow
+ } else if (rank == 11) {
s = "11th";
- } else if ( rank == 12 ) {
+ } else if (rank == 12) {
s = "12th";
- } else if ( rank == 13 ) {
+ } else if (rank == 13) {
s = "13th";
- } else if ( rank % 10 == 1 ) {
+ } else if (rank % 10 == 1) {
s = va("%ist", rank);
- } else if ( rank % 10 == 2 ) {
+ } else if (rank % 10 == 2) {
s = va("%ind", rank);
- } else if ( rank % 10 == 3 ) {
+ } else if (rank % 10 == 3) {
s = va("%ird", rank);
} else {
s = va("%ith", rank);
}
- Com_sprintf( str, sizeof( str ), "%s%s", t, s );
+ Com_sprintf(str, sizeof(str), "%s%s", t, s);
return str;
}
-
/*
================
CG_ItemPickup
@@ -89,34 +88,29 @@ CG_ItemPickup
A new item was picked up this frame
================
*/
-void CG_ItemPickup( int itemNum, qboolean bHadItem ) {
+void CG_ItemPickup(int itemNum, qboolean bHadItem) {
cg.itemPickup = itemNum;
cg.itemPickupTime = cg.time;
cg.itemPickupBlendTime = cg.time;
- if (bg_itemlist[itemNum].classname && bg_itemlist[itemNum].classname[0])
- {
+ if (bg_itemlist[itemNum].classname && bg_itemlist[itemNum].classname[0]) {
char text[1024], data[1024];
- if (cgi_SP_GetStringTextString("SP_INGAME_PICKUPLINE",text, sizeof(text)) )
- {
- if ( cgi_SP_GetStringTextString( va("SP_INGAME_%s",bg_itemlist[itemNum].classname ), data, sizeof( data )))
- {
-// Com_Printf("%s %s\n", text, data );
- cgi_Cvar_Set( "cg_WeaponPickupText", va("%s %s\n", text, data));
- cg.weaponPickupTextTime = cg.time + 5000;
+ if (cgi_SP_GetStringTextString("SP_INGAME_PICKUPLINE", text, sizeof(text))) {
+ if (cgi_SP_GetStringTextString(va("SP_INGAME_%s", bg_itemlist[itemNum].classname), data, sizeof(data))) {
+ // Com_Printf("%s %s\n", text, data );
+ cgi_Cvar_Set("cg_WeaponPickupText", va("%s %s\n", text, data));
+ cg.weaponPickupTextTime = cg.time + 5000;
}
}
}
// see if it should be the grabbed weapon
- if ( bg_itemlist[itemNum].giType == IT_WEAPON )
- {
+ if (bg_itemlist[itemNum].giType == IT_WEAPON) {
const int nCurWpn = cg.predicted_player_state.weapon;
const int nNewWpn = bg_itemlist[itemNum].giTag;
- if ( nCurWpn == WP_SABER || bHadItem)
- {//never switch away from the saber!
+ if (nCurWpn == WP_SABER || bHadItem) { // never switch away from the saber!
return;
}
@@ -129,38 +123,25 @@ void CG_ItemPickup( int itemNum, qboolean bHadItem ) {
// NOTE: automatically switching to any weapon you pick up is stupid and annoying and we won't do it.
//
- if ( nNewWpn == WP_SABER )
- {//always switch to saber
+ if (nNewWpn == WP_SABER) { // always switch to saber
SetWeaponSelectTime();
cg.weaponSelect = nNewWpn;
- }
- else if (0 == cg_autoswitch.integer)
- {
+ } else if (0 == cg_autoswitch.integer) {
// don't switch
- }
- else if (1 == cg_autoswitch.integer)
- {
+ } else if (1 == cg_autoswitch.integer) {
// safe switching
- if ( (nNewWpn > nCurWpn) &&
- !(nNewWpn == WP_DET_PACK) &&
- !(nNewWpn == WP_TRIP_MINE) &&
- !(nNewWpn == WP_THERMAL) &&
- !(nNewWpn == WP_ROCKET_LAUNCHER) &&
- !(nNewWpn == WP_CONCUSSION) )
- {
+ if ((nNewWpn > nCurWpn) && !(nNewWpn == WP_DET_PACK) && !(nNewWpn == WP_TRIP_MINE) && !(nNewWpn == WP_THERMAL) &&
+ !(nNewWpn == WP_ROCKET_LAUNCHER) && !(nNewWpn == WP_CONCUSSION)) {
// switch to new wpn
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
SetWeaponSelectTime();
cg.weaponSelect = nNewWpn;
}
- }
- else if (2 == cg_autoswitch.integer)
- {
+ } else if (2 == cg_autoswitch.integer) {
// best
- if (nNewWpn > nCurWpn)
- {
+ if (nNewWpn > nCurWpn) {
// switch to new wpn
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
SetWeaponSelectTime();
cg.weaponSelect = nNewWpn;
}
@@ -168,23 +149,20 @@ void CG_ItemPickup( int itemNum, qboolean bHadItem ) {
}
}
-
/*
===============
UseItem
===============
*/
-extern void CG_ToggleBinoculars( void );
-extern void CG_ToggleLAGoggles( void );
+extern void CG_ToggleBinoculars(void);
+extern void CG_ToggleLAGoggles(void);
-void UseItem(int itemNum)
-{
- centity_t *cent;
+void UseItem(int itemNum) {
+ centity_t *cent;
cent = &cg_entities[cg.snap->ps.clientNum];
- switch ( itemNum )
- {
+ switch (itemNum) {
case INV_ELECTROBINOCULARS:
CG_ToggleBinoculars();
break;
@@ -192,14 +170,12 @@ void UseItem(int itemNum)
CG_ToggleLAGoggles();
break;
case INV_GOODIE_KEY:
- if (cent->gent->client->ps.inventory[INV_GOODIE_KEY])
- {
+ if (cent->gent->client->ps.inventory[INV_GOODIE_KEY]) {
cent->gent->client->ps.inventory[INV_GOODIE_KEY]--;
}
break;
case INV_SECURITY_KEY:
- if (cent->gent->client->ps.inventory[INV_SECURITY_KEY])
- {
+ if (cent->gent->client->ps.inventory[INV_SECURITY_KEY]) {
cent->gent->client->ps.inventory[INV_SECURITY_KEY]--;
}
break;
@@ -211,10 +187,9 @@ void UseItem(int itemNum)
CG_UseForce
===============
*/
-static void CG_UseForce( centity_t *cent )
-{
- //FIXME: sound or graphic change or something?
- //actual force power action is on game/pm side
+static void CG_UseForce(centity_t *cent) {
+ // FIXME: sound or graphic change or something?
+ // actual force power action is on game/pm side
}
/*
@@ -222,38 +197,30 @@ static void CG_UseForce( centity_t *cent )
CG_UseItem
===============
*/
-static void CG_UseItem( centity_t *cent )
-{
- int itemNum;
+static void CG_UseItem(centity_t *cent) {
+ int itemNum;
entityState_t *es;
es = ¢->currentState;
itemNum = cg.inventorySelect;
- if ( itemNum < 0 || itemNum > INV_MAX )
- {
+ if (itemNum < 0 || itemNum > INV_MAX) {
itemNum = 0;
}
// print a message if the local player
- if ( es->number == cg.snap->ps.clientNum )
- {
- if ( !itemNum )
- {
-// CG_CenterPrint( "No item to use", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
- }
- else
- {
-// item = BG_FindItemForHoldable( itemNum );
-// CG_CenterPrint( va("Use %s", item->pickup_name), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
+ if (es->number == cg.snap->ps.clientNum) {
+ if (!itemNum) {
+ // CG_CenterPrint( "No item to use", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
+ } else {
+ // item = BG_FindItemForHoldable( itemNum );
+ // CG_CenterPrint( va("Use %s", item->pickup_name), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
}
}
UseItem(itemNum);
-
}
-
/*
==============
CG_EntityEvent
@@ -261,223 +228,219 @@ CG_EntityEvent
An entity has an event value
==============
*/
-#define DEBUGNAME(x) if(cg_debugEvents.integer){CG_Printf(x"\n");}
-void CG_EntityEvent( centity_t *cent, vec3_t position ) {
- entityState_t *es;
- int event;
- vec3_t axis[3];
- const char *s, *s2;
- int clientNum;
- //clientInfo_t *ci;
+#define DEBUGNAME(x) \
+ if (cg_debugEvents.integer) { \
+ CG_Printf(x "\n"); \
+ }
+void CG_EntityEvent(centity_t *cent, vec3_t position) {
+ entityState_t *es;
+ int event;
+ vec3_t axis[3];
+ const char *s, *s2;
+ int clientNum;
+ // clientInfo_t *ci;
es = ¢->currentState;
event = es->event & ~EV_EVENT_BITS;
- if ( cg_debugEvents.integer ) {
- CG_Printf( "ent:%3i event:%3i ", es->number, event );
+ if (cg_debugEvents.integer) {
+ CG_Printf("ent:%3i event:%3i ", es->number, event);
}
- if ( !event ) {
+ if (!event) {
DEBUGNAME("ZEROEVENT");
return;
}
- if ( !cent->gent )//|| !cent->gent->client )
+ if (!cent->gent) //|| !cent->gent->client )
{
return;
}
- //ci = ¢->gent->client->clientInfo;
+ // ci = ¢->gent->client->clientInfo;
clientNum = cent->gent->s.number;
- switch ( event ) {
+ switch (event) {
//
// movement generated events
//
case EV_FOOTSPLASH:
DEBUGNAME("EV_FOOTSPLASH");
if (cg_footsteps.integer) {
- cgi_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );
+ cgi_S_StartSound(NULL, es->number, CHAN_BODY, cgs.media.footsteps[FOOTSTEP_SPLASH][rand() & 3]);
}
break;
case EV_FOOTWADE:
DEBUGNAME("EV_FOOTWADE");
if (cg_footsteps.integer) {
- cgi_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.footsteps[ FOOTSTEP_WADE ][rand()&3] );
+ cgi_S_StartSound(NULL, es->number, CHAN_BODY, cgs.media.footsteps[FOOTSTEP_WADE][rand() & 3]);
}
break;
case EV_SWIM:
DEBUGNAME("EV_SWIM");
if (cg_footsteps.integer) {
- cgi_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.footsteps[ FOOTSTEP_SWIM ][rand()&3] );
+ cgi_S_StartSound(NULL, es->number, CHAN_BODY, cgs.media.footsteps[FOOTSTEP_SWIM][rand() & 3]);
}
break;
-
case EV_FALL_SHORT:
DEBUGNAME("EV_FALL_SHORT");
- cgi_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.landSound );
- if ( clientNum == cg.predicted_player_state.clientNum ) {
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.landSound);
+ if (clientNum == cg.predicted_player_state.clientNum) {
// smooth landing z changes
cg.landChange = -8;
cg.landTime = cg.time;
}
- //FIXME: maybe kick up some dust?
+ // FIXME: maybe kick up some dust?
break;
case EV_FALL_MEDIUM:
DEBUGNAME("EV_FALL_MEDIUM");
// use normal pain sound -
- if ( g_entities[es->number].health <= 0 )
- {//dead
- cgi_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.landSound );
+ if (g_entities[es->number].health <= 0) { // dead
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.landSound);
+ } else if (g_entities[es->number].s.weapon == WP_SABER ||
+ (g_entities[es->number].client && (g_entities[es->number].client->ps.forcePowersKnown &
+ (1 << FP_LEVITATION)))) { // jedi or someone who has force jump (so probably took no damage)
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_BODY, "*land1.wav", CS_BASIC);
+ } else { // still alive
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_BODY, "*pain100.wav", CS_BASIC);
}
- else if ( g_entities[es->number].s.weapon == WP_SABER
- || (g_entities[es->number].client && (g_entities[es->number].client->ps.forcePowersKnown&(1<number, CHAN_BODY, "*land1.wav", CS_BASIC );
- }
- else
- {//still alive
- CG_TryPlayCustomSound( NULL, es->number, CHAN_BODY, "*pain100.wav", CS_BASIC );
- }
- if ( clientNum == cg.predicted_player_state.clientNum ) {
+ if (clientNum == cg.predicted_player_state.clientNum) {
// smooth landing z changes
cg.landChange = -16;
cg.landTime = cg.time;
}
- //FIXME: maybe kick up some dust?
+ // FIXME: maybe kick up some dust?
break;
case EV_FALL_FAR:
DEBUGNAME("EV_FALL_FAR");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_BODY, "*land1.wav", CS_BASIC );
- cgi_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.landSound );
- cent->pe.painTime = cg.time; // don't play a pain sound right after this
- if ( clientNum == cg.predicted_player_state.clientNum ) {
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_BODY, "*land1.wav", CS_BASIC);
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.landSound);
+ cent->pe.painTime = cg.time; // don't play a pain sound right after this
+ if (clientNum == cg.predicted_player_state.clientNum) {
// smooth landing z changes
cg.landChange = -24;
cg.landTime = cg.time;
}
- //FIXME: maybe kick up some dust?
+ // FIXME: maybe kick up some dust?
break;
case EV_STEP_4:
case EV_STEP_8:
case EV_STEP_12:
- case EV_STEP_16: // smooth out step up transitions
+ case EV_STEP_16: // smooth out step up transitions
DEBUGNAME("EV_STEP");
- {
- float oldStep;
- int delta;
- int step;
-
- if ( clientNum != cg.predicted_player_state.clientNum ) {
- break;
- }
- // if we are interpolating, we don't need to smooth steps
- if ( cg_timescale.value >= 1.0f )
{
- break;
- }
- // check for stepping up before a previous step is completed
- delta = cg.time - cg.stepTime;
- if (delta < STEP_TIME) {
- oldStep = cg.stepChange * (STEP_TIME - delta) / STEP_TIME;
- } else {
- oldStep = 0;
- }
+ float oldStep;
+ int delta;
+ int step;
- // add this amount
- step = 4 * (event - EV_STEP_4 + 1 );
- cg.stepChange = oldStep + step;
- if ( cg.stepChange > MAX_STEP_CHANGE ) {
- cg.stepChange = MAX_STEP_CHANGE;
+ if (clientNum != cg.predicted_player_state.clientNum) {
+ break;
+ }
+ // if we are interpolating, we don't need to smooth steps
+ if (cg_timescale.value >= 1.0f) {
+ break;
+ }
+ // check for stepping up before a previous step is completed
+ delta = cg.time - cg.stepTime;
+ if (delta < STEP_TIME) {
+ oldStep = cg.stepChange * (STEP_TIME - delta) / STEP_TIME;
+ } else {
+ oldStep = 0;
+ }
+
+ // add this amount
+ step = 4 * (event - EV_STEP_4 + 1);
+ cg.stepChange = oldStep + step;
+ if (cg.stepChange > MAX_STEP_CHANGE) {
+ cg.stepChange = MAX_STEP_CHANGE;
+ }
+ cg.stepTime = cg.time;
+ break;
}
- cg.stepTime = cg.time;
- break;
- }
case EV_JUMP:
DEBUGNAME("EV_JUMP");
- CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*jump1.wav", CS_BASIC );//CHAN_VOICE
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*jump1.wav", CS_BASIC); // CHAN_VOICE
break;
case EV_ROLL:
DEBUGNAME("EV_ROLL");
- CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*jump1.wav", CS_BASIC );//CHAN_VOICE
- cgi_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.rollSound );//CHAN_AUTO
- //FIXME: need some sort of body impact on ground sound and maybe kick up some dust?
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*jump1.wav", CS_BASIC); // CHAN_VOICE
+ cgi_S_StartSound(NULL, es->number, CHAN_BODY, cgs.media.rollSound); // CHAN_AUTO
+ // FIXME: need some sort of body impact on ground sound and maybe kick up some dust?
break;
case EV_LAVA_TOUCH:
DEBUGNAME("EV_LAVA_TOUCH");
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.lavaInSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.lavaInSound);
break;
case EV_LAVA_LEAVE:
DEBUGNAME("EV_LAVA_LEAVE");
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.lavaOutSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.lavaOutSound);
break;
case EV_LAVA_UNDER:
DEBUGNAME("EV_LAVA_UNDER");
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.lavaUnSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.lavaUnSound);
break;
case EV_WATER_TOUCH:
DEBUGNAME("EV_WATER_TOUCH");
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrInSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.watrInSound);
break;
case EV_WATER_LEAVE:
DEBUGNAME("EV_WATER_LEAVE");
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound);
break;
case EV_WATER_UNDER:
DEBUGNAME("EV_WATER_UNDER");
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound);
break;
case EV_WATER_CLEAR:
DEBUGNAME("EV_WATER_CLEAR");
- CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*gasp.wav", CS_BASIC );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*gasp.wav", CS_BASIC);
break;
case EV_WATER_GURP1:
case EV_WATER_GURP2:
DEBUGNAME("EV_WATER_GURPx");
- CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, va("*gurp%d.wav",event-EV_WATER_GURP1+1), CS_BASIC );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, va("*gurp%d.wav", event - EV_WATER_GURP1 + 1), CS_BASIC);
break;
case EV_WATER_DROWN:
DEBUGNAME("EV_WATER_DROWN");
- CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*drown.wav", CS_BASIC );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, "*drown.wav", CS_BASIC);
break;
case EV_ITEM_PICKUP:
DEBUGNAME("EV_ITEM_PICKUP");
{
- gitem_t *item;
- int index;
+ gitem_t *item;
+ int index;
qboolean bHadItem = qfalse;
- index = es->eventParm; // player predicted
+ index = es->eventParm; // player predicted
- if ( (char)index < 0 )
- {
+ if ((char)index < 0) {
index = -(char)index;
bHadItem = qtrue;
}
- if ( index >= bg_numItems ) {
+ if (index >= bg_numItems) {
break;
}
- item = &bg_itemlist[ index ];
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgi_S_RegisterSound( item->pickup_sound ) );
+ item = &bg_itemlist[index];
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgi_S_RegisterSound(item->pickup_sound));
// show icon and name on status bar
- if ( es->number == cg.snap->ps.clientNum ) {
- CG_ItemPickup( index, bHadItem );
+ if (es->number == cg.snap->ps.clientNum) {
+ CG_ItemPickup(index, bHadItem);
}
}
break;
@@ -487,105 +450,99 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
//
case EV_NOAMMO:
DEBUGNAME("EV_NOAMMO");
- //cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound );
- if ( es->number == cg.snap->ps.clientNum ) {
+ // cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound );
+ if (es->number == cg.snap->ps.clientNum) {
CG_OutOfAmmoChange();
}
break;
case EV_CHANGE_WEAPON:
DEBUGNAME("EV_CHANGE_WEAPON");
- if ( es->weapon == WP_SABER )
- {
+ if (es->weapon == WP_SABER) {
/*
if ( !cent->gent || !cent->gent->client || (cent->currentState.saberInFlight == qfalse && cent->currentState.saberActive == qtrue) )
{
cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/saber/saberoffquick.wav" ) );
}
*/
- if ( cent->gent && cent->gent->client )
- {
- //if ( cent->gent->client->ps.saberInFlight )
- {//if it's not in flight or lying around, turn it off!
+ if (cent->gent && cent->gent->client) {
+ // if ( cent->gent->client->ps.saberInFlight )
+ { // if it's not in flight or lying around, turn it off!
cent->currentState.saberActive = qfalse;
}
}
}
// FIXME: if it happens that you don't want the saber to play the switch sounds, feel free to modify this bit.
- if ( weaponData[cg.weaponSelect].selectSnd[0] )
- {
+ if (weaponData[cg.weaponSelect].selectSnd[0]) {
// custom select sound
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgi_S_RegisterSound( weaponData[cg.weaponSelect].selectSnd ));
- }
- else
- {
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgi_S_RegisterSound(weaponData[cg.weaponSelect].selectSnd));
+ } else {
// generic sound
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.selectSound );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.media.selectSound);
}
break;
case EV_FIRE_WEAPON:
DEBUGNAME("EV_FIRE_WEAPON");
- CG_FireWeapon( cent, qfalse );
+ CG_FireWeapon(cent, qfalse);
break;
case EV_ALT_FIRE:
DEBUGNAME("EV_ALT_FIRE");
- CG_FireWeapon( cent, qtrue );
+ CG_FireWeapon(cent, qtrue);
break;
case EV_DISRUPTOR_MAIN_SHOT:
DEBUGNAME("EV_DISRUPTOR_MAIN_SHOT");
- FX_DisruptorMainShot( cent->currentState.origin2, cent->lerpOrigin );
+ FX_DisruptorMainShot(cent->currentState.origin2, cent->lerpOrigin);
break;
case EV_DISRUPTOR_SNIPER_SHOT:
DEBUGNAME("EV_DISRUPTOR_SNIPER_SHOT");
- FX_DisruptorAltShot( cent->currentState.origin2, cent->lerpOrigin, cent->gent->alt_fire );
+ FX_DisruptorAltShot(cent->currentState.origin2, cent->lerpOrigin, cent->gent->alt_fire);
break;
case EV_DISRUPTOR_SNIPER_MISS:
DEBUGNAME("EV_DISRUPTOR_SNIPER_MISS");
- FX_DisruptorAltMiss( cent->lerpOrigin, cent->gent->pos1 );
+ FX_DisruptorAltMiss(cent->lerpOrigin, cent->gent->pos1);
break;
case EV_DEMP2_ALT_IMPACT:
- FX_DEMP2_AltDetonate( cent->lerpOrigin, es->eventParm );
+ FX_DEMP2_AltDetonate(cent->lerpOrigin, es->eventParm);
break;
case EV_CONC_ALT_SHOT:
DEBUGNAME("EV_CONC_ALT_SHOT");
- FX_ConcAltShot( cent->currentState.origin2, cent->lerpOrigin );
+ FX_ConcAltShot(cent->currentState.origin2, cent->lerpOrigin);
break;
case EV_CONC_ALT_MISS:
DEBUGNAME("EV_CONC_ALT_MISS");
- FX_ConcAltMiss( cent->lerpOrigin, cent->gent->pos1 );
+ FX_ConcAltMiss(cent->lerpOrigin, cent->gent->pos1);
break;
-// case EV_POWERUP_SEEKER_FIRE:
-// DEBUGNAME("EV_POWERUP_SEEKER_FIRE");
-// CG_FireSeeker( cent );
-// break;
+ // case EV_POWERUP_SEEKER_FIRE:
+ // DEBUGNAME("EV_POWERUP_SEEKER_FIRE");
+ // CG_FireSeeker( cent );
+ // break;
case EV_POWERUP_BATTLESUIT:
DEBUGNAME("EV_POWERUP_BATTLESUIT");
- if ( es->number == cg.snap->ps.clientNum ) {
+ if (es->number == cg.snap->ps.clientNum) {
cg.powerupActive = PW_BATTLESUIT;
cg.powerupTime = cg.time;
}
- //cgi_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.invulnoProtectSound );
+ // cgi_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.invulnoProtectSound );
break;
case EV_KOTHOS_BEAM:
DEBUGNAME("EV_KOTHOS_BEAM");
- if ( Q_irand( 0, 1 ) )
- {
- FX_KothosBeam( cg_entities[cent->currentState.otherEntityNum].gent->client->renderInfo.handRPoint, cg_entities[cent->currentState.otherEntityNum2].lerpOrigin );
- }
- else
- {
- FX_KothosBeam( cg_entities[cent->currentState.otherEntityNum].gent->client->renderInfo.handLPoint, cg_entities[cent->currentState.otherEntityNum2].lerpOrigin );
+ if (Q_irand(0, 1)) {
+ FX_KothosBeam(cg_entities[cent->currentState.otherEntityNum].gent->client->renderInfo.handRPoint,
+ cg_entities[cent->currentState.otherEntityNum2].lerpOrigin);
+ } else {
+ FX_KothosBeam(cg_entities[cent->currentState.otherEntityNum].gent->client->renderInfo.handLPoint,
+ cg_entities[cent->currentState.otherEntityNum2].lerpOrigin);
}
break;
//=================================================================
@@ -595,201 +552,176 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
//
case EV_REPLICATOR:
DEBUGNAME("EV_REPLICATOR");
-// FX_Replicator( cent, position );
+ // FX_Replicator( cent, position );
break;
case EV_BATTERIES_CHARGED:
cg.batteryChargeTime = cg.time + 3000;
- cgi_S_StartSound( vec3_origin, es->number, CHAN_AUTO, cgs.media.batteryChargeSound );
- break;
-
- case EV_DISINTEGRATION:
- {
- DEBUGNAME("EV_DISINTEGRATION");
- qboolean makeNotSolid = qfalse;
- int disintPW = es->eventParm;
- int disintEffect = 0;
- int disintLength = 0;
- qhandle_t disintSound1 = NULL_HANDLE;
- qhandle_t disintSound2 = NULL_HANDLE;
- //qhandle_t disintSound3 = NULL_HANDLE;
-
- switch( disintPW )
- {
- case PW_DISRUPTION:// sniper rifle
- disintEffect = EF_DISINTEGRATION;//ef_
- disintSound1 = cgs.media.disintegrateSound;//with scream
- disintSound2 = cgs.media.disintegrate2Sound;//no scream
- //disintSound3 = cgs.media.disintegrate3Sound;//with inhuman scream
- disintLength = 2000;
- makeNotSolid = qtrue;
- break;
-/* case PW_SHOCKED:// arc welder
- disintEffect = EF_DISINT_1;//ef_
- disintSound1 = NULL;//with scream
- disintSound2 = NULL;//no scream
- disintSound3 = NULL;//with inhuman scream
- disintLength = 4000;
- break;
-*/
- default:
- return;
- break;
- }
+ cgi_S_StartSound(vec3_origin, es->number, CHAN_AUTO, cgs.media.batteryChargeSound);
+ break;
+
+ case EV_DISINTEGRATION: {
+ DEBUGNAME("EV_DISINTEGRATION");
+ qboolean makeNotSolid = qfalse;
+ int disintPW = es->eventParm;
+ int disintEffect = 0;
+ int disintLength = 0;
+ qhandle_t disintSound1 = NULL_HANDLE;
+ qhandle_t disintSound2 = NULL_HANDLE;
+ // qhandle_t disintSound3 = NULL_HANDLE;
+
+ switch (disintPW) {
+ case PW_DISRUPTION: // sniper rifle
+ disintEffect = EF_DISINTEGRATION; // ef_
+ disintSound1 = cgs.media.disintegrateSound; // with scream
+ disintSound2 = cgs.media.disintegrate2Sound; // no scream
+ // disintSound3 = cgs.media.disintegrate3Sound;//with inhuman scream
+ disintLength = 2000;
+ makeNotSolid = qtrue;
+ break;
+ /* case PW_SHOCKED:// arc welder
+ disintEffect = EF_DISINT_1;//ef_
+ disintSound1 = NULL;//with scream
+ disintSound2 = NULL;//no scream
+ disintSound3 = NULL;//with inhuman scream
+ disintLength = 4000;
+ break;
+ */
+ default:
+ return;
+ break;
+ }
- if ( cent->gent->owner )
- {
- cent->gent->owner->fx_time = cg.time;
- if ( cent->gent->owner->client )
- {
- if ( disintSound1 && disintSound2 )
- {//play an extra sound
- // listed all the non-humanoids, because there's a lot more humanoids
- class_t npc_class = cent->gent->owner->client->NPC_class;
- if( npc_class != CLASS_ATST && npc_class != CLASS_GONK &&
- npc_class != CLASS_INTERROGATOR && npc_class != CLASS_MARK1 &&
- npc_class != CLASS_MARK2 && npc_class != CLASS_MOUSE &&
- npc_class != CLASS_PROBE && npc_class != CLASS_PROTOCOL &&
- npc_class != CLASS_R2D2 && npc_class != CLASS_R5D2 &&
- npc_class != CLASS_SEEKER && npc_class != CLASS_SENTRY)
- {//Only the humanoids scream
- cgi_S_StartSound ( NULL, cent->gent->owner->s.number, CHAN_VOICE, disintSound1 );
- }
- // no more forge or 8472
+ if (cent->gent->owner) {
+ cent->gent->owner->fx_time = cg.time;
+ if (cent->gent->owner->client) {
+ if (disintSound1 && disintSound2) { // play an extra sound
+ // listed all the non-humanoids, because there's a lot more humanoids
+ class_t npc_class = cent->gent->owner->client->NPC_class;
+ if (npc_class != CLASS_ATST && npc_class != CLASS_GONK && npc_class != CLASS_INTERROGATOR && npc_class != CLASS_MARK1 &&
+ npc_class != CLASS_MARK2 && npc_class != CLASS_MOUSE && npc_class != CLASS_PROBE && npc_class != CLASS_PROTOCOL &&
+ npc_class != CLASS_R2D2 && npc_class != CLASS_R5D2 && npc_class != CLASS_SEEKER &&
+ npc_class != CLASS_SENTRY) { // Only the humanoids scream
+ cgi_S_StartSound(NULL, cent->gent->owner->s.number, CHAN_VOICE, disintSound1);
+ }
+ // no more forge or 8472
// else if ( cent->gent->owner->client->playerTeam == TEAM_FORGE ||
// cent->gent->owner->client->playerTeam == TEAM_8472 )
// {
// cgi_S_StartSound ( NULL, cent->gent->s.number, CHAN_VOICE, disintSound3 );
// }
- else
- {
- cgi_S_StartSound ( NULL, cent->gent->s.number, CHAN_AUTO, disintSound2 );
- }
- }
- cent->gent->owner->s.powerups |= ( 1 << disintPW );
- cent->gent->owner->client->ps.powerups[disintPW] = cg.time + disintLength;
-
- // Things that are being disintegrated should probably not be solid...
- if ( makeNotSolid && cent->gent->owner->client->playerTeam != TEAM_NEUTRAL )
- {
- cent->gent->contents = CONTENTS_NONE;
+ else {
+ cgi_S_StartSound(NULL, cent->gent->s.number, CHAN_AUTO, disintSound2);
}
}
- else
- {
- cent->gent->owner->s.eFlags = disintEffect;//FIXME: |= ?
- cent->gent->owner->delay = cg.time + disintLength;
+ cent->gent->owner->s.powerups |= (1 << disintPW);
+ cent->gent->owner->client->ps.powerups[disintPW] = cg.time + disintLength;
+
+ // Things that are being disintegrated should probably not be solid...
+ if (makeNotSolid && cent->gent->owner->client->playerTeam != TEAM_NEUTRAL) {
+ cent->gent->contents = CONTENTS_NONE;
}
+ } else {
+ cent->gent->owner->s.eFlags = disintEffect; // FIXME: |= ?
+ cent->gent->owner->delay = cg.time + disintLength;
}
}
- break;
+ } break;
// This does not necessarily have to be from a grenade...
case EV_GRENADE_BOUNCE:
DEBUGNAME("EV_GRENADE_BOUNCE");
- CG_BounceEffect( cent, es->weapon, position, cent->gent->pos1 );
+ CG_BounceEffect(cent, es->weapon, position, cent->gent->pos1);
break;
- //
- // missile impacts
- //
+ //
+ // missile impacts
+ //
case EV_MISSILE_STICK:
DEBUGNAME("EV_MISSILE_STICK");
- CG_MissileStick( cent, es->weapon, position );
+ CG_MissileStick(cent, es->weapon, position);
break;
case EV_MISSILE_HIT:
DEBUGNAME("EV_MISSILE_HIT");
- if ( CG_VehicleWeaponImpact( cent ) )
- {
- }
- else
- {
- CG_MissileHitPlayer( cent, es->weapon, position, cent->gent->pos1, cent->gent->alt_fire );
+ if (CG_VehicleWeaponImpact(cent)) {
+ } else {
+ CG_MissileHitPlayer(cent, es->weapon, position, cent->gent->pos1, cent->gent->alt_fire);
}
break;
case EV_MISSILE_MISS:
DEBUGNAME("EV_MISSILE_MISS");
- if ( CG_VehicleWeaponImpact( cent ) )
- {
- }
- else
- {
- CG_MissileHitWall( cent, es->weapon, position, cent->gent->pos1, cent->gent->alt_fire );
+ if (CG_VehicleWeaponImpact(cent)) {
+ } else {
+ CG_MissileHitWall(cent, es->weapon, position, cent->gent->pos1, cent->gent->alt_fire);
}
break;
case EV_BMODEL_SOUND:
DEBUGNAME("EV_BMODEL_SOUND");
- cgi_S_StartSound( NULL, es->number, CHAN_AUTO, es->eventParm );
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, es->eventParm);
break;
case EV_GENERAL_SOUND:
DEBUGNAME("EV_GENERAL_SOUND");
- if ( cgs.sound_precache[ es->eventParm ] )
- {
- cgi_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.sound_precache[ es->eventParm ] );
- }
- else
- {
- s = CG_ConfigString( CS_SOUNDS + es->eventParm );
- CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, s, CS_BASIC );
+ if (cgs.sound_precache[es->eventParm]) {
+ cgi_S_StartSound(NULL, es->number, CHAN_AUTO, cgs.sound_precache[es->eventParm]);
+ } else {
+ s = CG_ConfigString(CS_SOUNDS + es->eventParm);
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_AUTO, s, CS_BASIC);
}
break;
- case EV_GLOBAL_SOUND: // play from the player's head so it never diminishes
+ case EV_GLOBAL_SOUND: // play from the player's head so it never diminishes
DEBUGNAME("EV_GLOBAL_SOUND");
- if ( cgs.sound_precache[ es->eventParm ] ) {
- cgi_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.sound_precache[ es->eventParm ] );
+ if (cgs.sound_precache[es->eventParm]) {
+ cgi_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.sound_precache[es->eventParm]);
} else {
- s = CG_ConfigString( CS_SOUNDS + es->eventParm );
- CG_TryPlayCustomSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, s, CS_BASIC );
+ s = CG_ConfigString(CS_SOUNDS + es->eventParm);
+ CG_TryPlayCustomSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, s, CS_BASIC);
}
break;
case EV_DRUGGED:
DEBUGNAME("EV_DRUGGED");
- if ( cent->gent && cent->gent->owner && cent->gent->owner->s.number == 0 )
- {
- // Only allow setting up the wonky vision on the player..do it for 10 seconds...must be synchronized with calcs done in cg_view. Just search for cg.wonkyTime to find 'em.
+ if (cent->gent && cent->gent->owner && cent->gent->owner->s.number == 0) {
+ // Only allow setting up the wonky vision on the player..do it for 10 seconds...must be synchronized with calcs done in cg_view. Just search for
+ // cg.wonkyTime to find 'em.
cg.wonkyTime = cg.time + 10000;
}
break;
- case EV_PAIN:
- {
- char *snd;
+ case EV_PAIN: {
+ char *snd;
const int health = es->eventParm;
- if ( cent->gent && cent->gent->NPC && (cent->gent->NPC->aiFlags & NPCAI_DIE_ON_IMPACT) )
- {
+ if (cent->gent && cent->gent->NPC && (cent->gent->NPC->aiFlags & NPCAI_DIE_ON_IMPACT)) {
return;
}
- //FIXME: don't do this if we're falling to our deaths...
+ // FIXME: don't do this if we're falling to our deaths...
DEBUGNAME("EV_PAIN");
// don't do more than two pain sounds a second
- if ( cg.time - cent->pe.painTime < 500 ) {
+ if (cg.time - cent->pe.painTime < 500) {
return;
}
- if ( health < 25 ) {
+ if (health < 25) {
snd = "*pain100.wav";
- } else if ( health < 50 ) {
+ } else if (health < 50) {
snd = "*pain75.wav";
- } else if ( health < 75 ) {
+ } else if (health < 75) {
snd = "*pain50.wav";
} else {
snd = "*pain25.wav";
}
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, snd, CS_BASIC );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, snd, CS_BASIC);
// save pain time for programitic twitch animation
cent->pe.painTime = cg.time;
cent->pe.painDirection ^= 1;
- }
- break;
+ } break;
case EV_DEATH1:
case EV_DEATH2:
@@ -801,48 +733,43 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
return;
}
*/
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*death%i.wav", event - EV_DEATH1 + 1), CS_BASIC );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*death%i.wav", event - EV_DEATH1 + 1), CS_BASIC);
break;
// Called by the FxRunner entity...usually for Environmental FX Events
case EV_PLAY_EFFECT:
DEBUGNAME("EV_PLAY_EFFECT");
{
- const bool portalEnt = !!es->isPortalEnt; //the fxrunner spawning this effect is within a skyportal, so only render this effect within that portal.
+ const bool portalEnt = !!es->isPortalEnt; // the fxrunner spawning this effect is within a skyportal, so only render this effect within that portal.
- s = CG_ConfigString( CS_EFFECTS + es->eventParm );
- // Ghoul2 Insert Start
- if (es->boltInfo != 0)
- {
+ s = CG_ConfigString(CS_EFFECTS + es->eventParm);
+ // Ghoul2 Insert Start
+ if (es->boltInfo != 0) {
const bool isRelative = !!es->weapon;
- theFxScheduler.PlayEffect( s, cent->lerpOrigin, axis, es->boltInfo, -1, portalEnt, es->loopSound, isRelative ); //loopSound 0 = not looping, 1 for infinite, else duration
- }
- else
- {
- VectorCopy( cent->gent->pos3, axis[0] );
- VectorCopy( cent->gent->pos4, axis[1] );
- CrossProduct( axis[0], axis[1], axis[2] );
+ theFxScheduler.PlayEffect(s, cent->lerpOrigin, axis, es->boltInfo, -1, portalEnt, es->loopSound,
+ isRelative); // loopSound 0 = not looping, 1 for infinite, else duration
+ } else {
+ VectorCopy(cent->gent->pos3, axis[0]);
+ VectorCopy(cent->gent->pos4, axis[1]);
+ CrossProduct(axis[0], axis[1], axis[2]);
// the entNum the effect may be attached to
- if ( es->otherEntityNum )
- {
- theFxScheduler.PlayEffect( s, cent->lerpOrigin, axis, -1, es->otherEntityNum, portalEnt );
- }
- else
- {
- theFxScheduler.PlayEffect( s, cent->lerpOrigin, axis, -1, -1, portalEnt );
+ if (es->otherEntityNum) {
+ theFxScheduler.PlayEffect(s, cent->lerpOrigin, axis, -1, es->otherEntityNum, portalEnt);
+ } else {
+ theFxScheduler.PlayEffect(s, cent->lerpOrigin, axis, -1, -1, portalEnt);
}
}
}
-// Ghoul2 Insert End
+ // Ghoul2 Insert End
break;
// play an effect bolted onto a muzzle
case EV_PLAY_MUZZLE_EFFECT:
DEBUGNAME("EV_PLAY_MUZZLE_EFFECT");
- s = CG_ConfigString( CS_EFFECTS + es->eventParm );
+ s = CG_ConfigString(CS_EFFECTS + es->eventParm);
- theFxScheduler.PlayEffect( s, es->otherEntityNum );
+ theFxScheduler.PlayEffect(s, es->otherEntityNum);
break;
case EV_STOP_EFFECT:
@@ -850,97 +777,90 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
{
bool portalEnt = false;
- if ( es->isPortalEnt )
- { //the fxrunner spawning this effect is within a skyportal, so only render this effect within that portal.
+ if (es->isPortalEnt) { // the fxrunner spawning this effect is within a skyportal, so only render this effect within that portal.
portalEnt = true;
}
- s = CG_ConfigString( CS_EFFECTS + es->eventParm );
- if ( es->boltInfo != 0 )
- {
- theFxScheduler.StopEffect( s, es->boltInfo, portalEnt );
+ s = CG_ConfigString(CS_EFFECTS + es->eventParm);
+ if (es->boltInfo != 0) {
+ theFxScheduler.StopEffect(s, es->boltInfo, portalEnt);
}
}
break;
case EV_TARGET_BEAM_DRAW:
DEBUGNAME("EV_TARGET_BEAM_DRAW");
- if ( cent->gent )
- {
- s = CG_ConfigString( CS_EFFECTS + es->eventParm );
+ if (cent->gent) {
+ s = CG_ConfigString(CS_EFFECTS + es->eventParm);
- if ( s && s[0] )
- {
- if ( cent->gent->delay )
- {
- s2 = CG_ConfigString( CS_EFFECTS + cent->gent->delay );
- }
- else
- {
+ if (s && s[0]) {
+ if (cent->gent->delay) {
+ s2 = CG_ConfigString(CS_EFFECTS + cent->gent->delay);
+ } else {
s2 = NULL;
}
- CG_DrawTargetBeam( cent->lerpOrigin, cent->gent->s.origin2, cent->gent->pos1, s, s2 );
- }
-/* else
- {
- int gack = 0; // this is bad if it get's here
+ CG_DrawTargetBeam(cent->lerpOrigin, cent->gent->s.origin2, cent->gent->pos1, s, s2);
}
-*/
+ /* else
+ {
+ int gack = 0; // this is bad if it get's here
+ }
+ */
}
break;
- case EV_ANGER1: //Say when acquire an enemy when didn't have one before
+ case EV_ANGER1: // Say when acquire an enemy when didn't have one before
case EV_ANGER2:
case EV_ANGER3:
DEBUGNAME("EV_ANGERx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*anger%i.wav", event - EV_ANGER1 + 1), CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*anger%i.wav", event - EV_ANGER1 + 1), CS_COMBAT);
break;
- case EV_VICTORY1: //Say when killed an enemy
+ case EV_VICTORY1: // Say when killed an enemy
case EV_VICTORY2:
case EV_VICTORY3:
DEBUGNAME("EV_VICTORYx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*victory%i.wav", event - EV_VICTORY1 + 1), CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*victory%i.wav", event - EV_VICTORY1 + 1), CS_COMBAT);
break;
- case EV_CONFUSE1: //Say when confused
+ case EV_CONFUSE1: // Say when confused
case EV_CONFUSE2:
case EV_CONFUSE3:
DEBUGNAME("EV_CONFUSEDx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*confuse%i.wav", event - EV_CONFUSE1 + 1), CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*confuse%i.wav", event - EV_CONFUSE1 + 1), CS_COMBAT);
break;
- case EV_PUSHED1: //Say when pushed
+ case EV_PUSHED1: // Say when pushed
case EV_PUSHED2:
case EV_PUSHED3:
DEBUGNAME("EV_PUSHEDx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*pushed%i.wav", event - EV_PUSHED1 + 1), CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*pushed%i.wav", event - EV_PUSHED1 + 1), CS_COMBAT);
break;
- case EV_CHOKE1: //Say when choking
+ case EV_CHOKE1: // Say when choking
case EV_CHOKE2:
case EV_CHOKE3:
DEBUGNAME("EV_CHOKEx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*choke%i.wav", event - EV_CHOKE1 + 1), CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*choke%i.wav", event - EV_CHOKE1 + 1), CS_COMBAT);
break;
- case EV_FFWARN: //Warn ally to stop shooting you
+ case EV_FFWARN: // Warn ally to stop shooting you
DEBUGNAME("EV_FFWARN");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, "*ffwarn.wav", CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, "*ffwarn.wav", CS_COMBAT);
break;
- case EV_FFTURN: //Turn on ally after being shot by them
+ case EV_FFTURN: // Turn on ally after being shot by them
DEBUGNAME("EV_FFTURN");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, "*ffturn.wav", CS_COMBAT );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, "*ffturn.wav", CS_COMBAT);
break;
- //extra sounds for ST
+ // extra sounds for ST
case EV_CHASE1:
case EV_CHASE2:
case EV_CHASE3:
DEBUGNAME("EV_CHASEx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*chase%i.wav", event - EV_CHASE1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*chase%i.wav", event - EV_CHASE1 + 1), CS_EXTRA);
break;
case EV_COVER1:
case EV_COVER2:
@@ -948,7 +868,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
case EV_COVER4:
case EV_COVER5:
DEBUGNAME("EV_COVERx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*cover%i.wav", event - EV_COVER1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*cover%i.wav", event - EV_COVER1 + 1), CS_EXTRA);
break;
case EV_DETECTED1:
case EV_DETECTED2:
@@ -956,46 +876,46 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
case EV_DETECTED4:
case EV_DETECTED5:
DEBUGNAME("EV_DETECTEDx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*detected%i.wav", event - EV_DETECTED1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*detected%i.wav", event - EV_DETECTED1 + 1), CS_EXTRA);
break;
case EV_GIVEUP1:
case EV_GIVEUP2:
case EV_GIVEUP3:
case EV_GIVEUP4:
DEBUGNAME("EV_GIVEUPx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*giveup%i.wav", event - EV_GIVEUP1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*giveup%i.wav", event - EV_GIVEUP1 + 1), CS_EXTRA);
break;
case EV_LOOK1:
case EV_LOOK2:
DEBUGNAME("EV_LOOKx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*look%i.wav", event - EV_LOOK1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*look%i.wav", event - EV_LOOK1 + 1), CS_EXTRA);
break;
case EV_LOST1:
DEBUGNAME("EV_LOST1");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, "*lost1.wav", CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, "*lost1.wav", CS_EXTRA);
break;
case EV_OUTFLANK1:
case EV_OUTFLANK2:
DEBUGNAME("EV_OUTFLANKx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*outflank%i.wav", event - EV_OUTFLANK1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*outflank%i.wav", event - EV_OUTFLANK1 + 1), CS_EXTRA);
break;
case EV_ESCAPING1:
case EV_ESCAPING2:
case EV_ESCAPING3:
DEBUGNAME("EV_ESCAPINGx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*escaping%i.wav", event - EV_ESCAPING1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*escaping%i.wav", event - EV_ESCAPING1 + 1), CS_EXTRA);
break;
case EV_SIGHT1:
case EV_SIGHT2:
case EV_SIGHT3:
DEBUGNAME("EV_SIGHTx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*sight%i.wav", event - EV_SIGHT1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*sight%i.wav", event - EV_SIGHT1 + 1), CS_EXTRA);
break;
case EV_SOUND1:
case EV_SOUND2:
case EV_SOUND3:
DEBUGNAME("EV_SOUNDx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*sound%i.wav", event - EV_SOUND1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*sound%i.wav", event - EV_SOUND1 + 1), CS_EXTRA);
break;
case EV_SUSPICIOUS1:
case EV_SUSPICIOUS2:
@@ -1003,89 +923,89 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
case EV_SUSPICIOUS4:
case EV_SUSPICIOUS5:
DEBUGNAME("EV_SUSPICIOUSx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*suspicious%i.wav", event - EV_SUSPICIOUS1 + 1), CS_EXTRA );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*suspicious%i.wav", event - EV_SUSPICIOUS1 + 1), CS_EXTRA);
break;
- //extra sounds for Jedi
+ // extra sounds for Jedi
case EV_COMBAT1:
case EV_COMBAT2:
case EV_COMBAT3:
DEBUGNAME("EV_COMBATx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*combat%i.wav", event - EV_COMBAT1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*combat%i.wav", event - EV_COMBAT1 + 1), CS_JEDI);
break;
case EV_JDETECTED1:
case EV_JDETECTED2:
case EV_JDETECTED3:
DEBUGNAME("EV_JDETECTEDx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*jdetected%i.wav", event - EV_JDETECTED1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*jdetected%i.wav", event - EV_JDETECTED1 + 1), CS_JEDI);
break;
case EV_TAUNT1:
case EV_TAUNT2:
case EV_TAUNT3:
DEBUGNAME("EV_TAUNTx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*taunt%i.wav", event - EV_TAUNT1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*taunt%i.wav", event - EV_TAUNT1 + 1), CS_JEDI);
break;
case EV_JCHASE1:
case EV_JCHASE2:
case EV_JCHASE3:
DEBUGNAME("EV_JCHASEx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*jchase%i.wav", event - EV_JCHASE1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*jchase%i.wav", event - EV_JCHASE1 + 1), CS_JEDI);
break;
case EV_JLOST1:
case EV_JLOST2:
case EV_JLOST3:
DEBUGNAME("EV_JLOSTx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*jlost%i.wav", event - EV_JLOST1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*jlost%i.wav", event - EV_JLOST1 + 1), CS_JEDI);
break;
case EV_DEFLECT1:
case EV_DEFLECT2:
case EV_DEFLECT3:
DEBUGNAME("EV_DEFLECTx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*deflect%i.wav", event - EV_DEFLECT1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*deflect%i.wav", event - EV_DEFLECT1 + 1), CS_JEDI);
break;
case EV_GLOAT1:
case EV_GLOAT2:
case EV_GLOAT3:
DEBUGNAME("EV_GLOATx");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, va("*gloat%i.wav", event - EV_GLOAT1 + 1), CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, va("*gloat%i.wav", event - EV_GLOAT1 + 1), CS_JEDI);
break;
case EV_PUSHFAIL:
DEBUGNAME("EV_PUSHFAIL");
- CG_TryPlayCustomSound( NULL, es->number, CHAN_VOICE, "*pushfail.wav", CS_JEDI );
+ CG_TryPlayCustomSound(NULL, es->number, CHAN_VOICE, "*pushfail.wav", CS_JEDI);
break;
case EV_USE_FORCE:
DEBUGNAME("EV_USE_FORCEITEM");
- CG_UseForce( cent );
+ CG_UseForce(cent);
break;
case EV_USE_ITEM:
DEBUGNAME("EV_USE_ITEM");
- CG_UseItem( cent );
+ CG_UseItem(cent);
break;
case EV_USE_INV_BINOCULARS:
DEBUGNAME("EV_USE_INV_BINOCULARS");
- UseItem(INV_ELECTROBINOCULARS );
+ UseItem(INV_ELECTROBINOCULARS);
break;
case EV_USE_INV_BACTA:
DEBUGNAME("EV_USE_INV_BACTA");
- UseItem(INV_BACTA_CANISTER );
+ UseItem(INV_BACTA_CANISTER);
break;
case EV_USE_INV_SEEKER:
DEBUGNAME("EV_USE_INV_SEEKER");
- UseItem(INV_SEEKER );
+ UseItem(INV_SEEKER);
break;
case EV_USE_INV_LIGHTAMP_GOGGLES:
DEBUGNAME("EV_USE_INV_LIGHTAMP_GOGGLES");
- UseItem(INV_LIGHTAMP_GOGGLES );
+ UseItem(INV_LIGHTAMP_GOGGLES);
break;
case EV_USE_INV_SENTRY:
DEBUGNAME("EV_USE_INV_SENTRY");
- UseItem(INV_SENTRY );
+ UseItem(INV_SENTRY);
break;
case EV_DEBUG_LINE:
@@ -1095,43 +1015,40 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
default:
DEBUGNAME("UNKNOWN");
- CG_Error( "Unknown event: %i", event );
+ CG_Error("Unknown event: %i", event);
break;
}
-
}
-
/*
==============
CG_CheckEvents
==============
*/
-void CG_CheckEvents( centity_t *cent ) {
+void CG_CheckEvents(centity_t *cent) {
// check for event-only entities
- if ( cent->currentState.eType > ET_EVENTS ) {
- if ( cent->previousEvent ) {
- return; // already fired
+ if (cent->currentState.eType > ET_EVENTS) {
+ if (cent->previousEvent) {
+ return; // already fired
}
cent->previousEvent = 1;
cent->currentState.event = cent->currentState.eType - ET_EVENTS;
} else {
// check for events riding with another entity
- if ( cent->currentState.event == cent->previousEvent ) {
+ if (cent->currentState.event == cent->previousEvent) {
return;
}
cent->previousEvent = cent->currentState.event;
- if ( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 ) {
+ if ((cent->currentState.event & ~EV_EVENT_BITS) == 0) {
return;
}
}
// calculate the position at exactly the frame time
- EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );
- CG_SetEntitySoundPosition( cent );
+ EvaluateTrajectory(¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin);
+ CG_SetEntitySoundPosition(cent);
- CG_EntityEvent( cent, cent->lerpOrigin );
+ CG_EntityEvent(cent, cent->lerpOrigin);
}
-
diff --git a/code/cgame/cg_headers.cpp b/code/cgame/cg_headers.cpp
index d39130e306..126fb51828 100644
--- a/code/cgame/cg_headers.cpp
+++ b/code/cgame/cg_headers.cpp
@@ -21,4 +21,3 @@ along with this program; if not, see .
*/
#include "cg_headers.h"
-
diff --git a/code/cgame/cg_info.cpp b/code/cgame/cg_info.cpp
index 17abcfee02..38cced8ea8 100644
--- a/code/cgame/cg_info.cpp
+++ b/code/cgame/cg_info.cpp
@@ -26,27 +26,15 @@ along with this program; if not, see .
#include "cg_media.h"
#include "../game/objectives.h"
-
// For printing objectives
-static const short objectiveStartingYpos = 75; // Y starting position for objective text
-static const short objectiveStartingXpos = 60; // X starting position for objective text
-static const int objectiveTextBoxWidth = 500; // Width (in pixels) of text box
-static const int objectiveTextBoxHeight = 300; // Height (in pixels) of text box
-
-const char *showLoadPowersName[] =
-{
- "SP_INGAME_HEAL2",
- "SP_INGAME_JUMP2",
- "SP_INGAME_SPEED2",
- "SP_INGAME_PUSH2",
- "SP_INGAME_PULL2",
- "SP_INGAME_MINDTRICK2",
- "SP_INGAME_GRIP2",
- "SP_INGAME_LIGHTNING2",
- "SP_INGAME_SABER_THROW2",
- "SP_INGAME_SABER_OFFENSE2",
- "SP_INGAME_SABER_DEFENSE2",
- NULL,
+static const short objectiveStartingYpos = 75; // Y starting position for objective text
+static const short objectiveStartingXpos = 60; // X starting position for objective text
+static const int objectiveTextBoxWidth = 500; // Width (in pixels) of text box
+static const int objectiveTextBoxHeight = 300; // Height (in pixels) of text box
+
+const char *showLoadPowersName[] = {
+ "SP_INGAME_HEAL2", "SP_INGAME_JUMP2", "SP_INGAME_SPEED2", "SP_INGAME_PUSH2", "SP_INGAME_PULL2", "SP_INGAME_MINDTRICK2",
+ "SP_INGAME_GRIP2", "SP_INGAME_LIGHTNING2", "SP_INGAME_SABER_THROW2", "SP_INGAME_SABER_OFFENSE2", "SP_INGAME_SABER_DEFENSE2", NULL,
};
#define MAX_OBJ_GRAPHICS 4
@@ -62,126 +50,102 @@ ObjectivePrint_Line
Print a single mission objective
====================
*/
-static void ObjectivePrint_Line(const int color, const int objectIndex, int &missionYcnt)
-{
- char *str,*strBegin;
- int y,pixelLen,charLen,i;
+static void ObjectivePrint_Line(const int color, const int objectIndex, int &missionYcnt) {
+ char *str, *strBegin;
+ int y, pixelLen, charLen, i;
const int maxHoldText = 1024;
char holdText[maxHoldText];
char finalText[2048];
- qhandle_t graphic;
+ qhandle_t graphic;
int iYPixelsPerLine = cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, 1.0f);
- cgi_SP_GetStringTextString( va("OBJECTIVES_%s",objectiveTable[objectIndex].name) , finalText, sizeof(finalText) );
+ cgi_SP_GetStringTextString(va("OBJECTIVES_%s", objectiveTable[objectIndex].name), finalText, sizeof(finalText));
// A hack to be able to count prisoners
- if (objectIndex==T2_RANCOR_OBJ5)
- {
+ if (objectIndex == T2_RANCOR_OBJ5) {
char value[64];
- int currTotal, minTotal;
+ int currTotal, minTotal;
- gi.Cvar_VariableStringBuffer("ui_prisonerobj_currtotal",value,sizeof(value));
+ gi.Cvar_VariableStringBuffer("ui_prisonerobj_currtotal", value, sizeof(value));
currTotal = atoi(value);
- gi.Cvar_VariableStringBuffer("ui_prisonerobj_maxtotal",value,sizeof(value));
+ gi.Cvar_VariableStringBuffer("ui_prisonerobj_maxtotal", value, sizeof(value));
minTotal = atoi(value);
- Q_strncpyz(finalText, va(finalText,currTotal,minTotal), sizeof(finalText));
+ Q_strncpyz(finalText, va(finalText, currTotal, minTotal), sizeof(finalText));
}
pixelLen = cgi_R_Font_StrLenPixels(finalText, cgs.media.qhFontMedium, 1.0f);
str = finalText;
- if (cgi_Language_IsAsian())
- {
+ if (cgi_Language_IsAsian()) {
// this is execrable, and should NOT have had to've been done now, but...
//
- extern const char *CG_DisplayBoxedText( int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight,
- const char *psText, int iFontHandle, float fScale,
- const vec4_t v4Color);
+ extern const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight, const char *psText, int iFontHandle, float fScale,
+ const vec4_t v4Color);
extern int giLinesOutput;
extern float gfAdvanceHack;
- gfAdvanceHack = 1.0f; // override internal vertical advance
+ gfAdvanceHack = 1.0f; // override internal vertical advance
y = objectiveStartingYpos + (iYPixelsPerLine * missionYcnt);
// Advance line if a graphic has printed
- for (i=0;i objectiveTextBoxWidth )
- { //Reached max length of this line
- //step back until we find a space
- while ((charLen>10) && (*str != ' ' ))
- {
+ if (pixelLen > objectiveTextBoxWidth) { // Reached max length of this line
+ // step back until we find a space
+ while ((charLen > 10) && (*str != ' ')) {
--str;
--charLen;
}
- if (*str==' ')
- {
- ++str; // To get past space
+ if (*str == ' ') {
+ ++str; // To get past space
}
- assert( charLengent->client->sess.mission_objectives[i].display)
- {
+ if (cent->gent->client->sess.mission_objectives[i].display) {
// Calculate the Y position
- totalY = objectiveStartingYpos + (iYPixelsPerLine * (missionYcnt))+(iYPixelsPerLine/2);
+ totalY = objectiveStartingYpos + (iYPixelsPerLine * (missionYcnt)) + (iYPixelsPerLine / 2);
// Draw graphics that show if mission has been accomplished or not
cgi_R_SetColor(colorTable[CT_BLUE3]);
- CG_DrawPic( (graphicXpos), (totalY-graphicYOffset), graphic_size, graphic_size, cgs.media.messageObjCircle); // Circle in front
- if (cent->gent->client->sess.mission_objectives[i].status == OBJECTIVE_STAT_SUCCEEDED)
- {
- CG_DrawPic( (graphicXpos), (totalY-graphicYOffset), graphic_size, graphic_size, cgs.media.messageLitOn); // Center Dot
+ CG_DrawPic((graphicXpos), (totalY - graphicYOffset), graphic_size, graphic_size, cgs.media.messageObjCircle); // Circle in front
+ if (cent->gent->client->sess.mission_objectives[i].status == OBJECTIVE_STAT_SUCCEEDED) {
+ CG_DrawPic((graphicXpos), (totalY - graphicYOffset), graphic_size, graphic_size, cgs.media.messageLitOn); // Center Dot
}
// Print current objective text
- ObjectivePrint_Line(CT_WHITE, i, missionYcnt );
+ ObjectivePrint_Line(CT_WHITE, i, missionYcnt);
}
}
// No mission text?
- if (!missionYcnt)
- {
+ if (!missionYcnt) {
// Set the message a quarter of the way down and in the center of the text box
int messageYPosition = objectiveStartingYpos + (objectiveTextBoxHeight / 4);
- cgi_SP_GetStringTextString( "SP_INGAME_OBJNONE", text, sizeof(text) );
- int messageXPosition = objectiveStartingXpos + (objectiveTextBoxWidth/2) - (cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.0f) /2);
+ cgi_SP_GetStringTextString("SP_INGAME_OBJNONE", text, sizeof(text));
+ int messageXPosition = objectiveStartingXpos + (objectiveTextBoxWidth / 2) - (cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.0f) / 2);
- cgi_R_Font_DrawString (
- messageXPosition,
- messageYPosition,
- text,
- colorTable[CT_WHITE],
- cgs.media.qhFontMedium,
- -1,
- 1.0f);
+ cgi_R_Font_DrawString(messageXPosition, messageYPosition, text, colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 1.0f);
}
}
@@ -409,16 +343,15 @@ static void CG_LoadScreen_PersonalInfo(void)
}
*/
-static void CG_LoadBar(void)
-{
+static void CG_LoadBar(void) {
const int numticks = 9, tickwidth = 40, tickheight = 8;
const int tickpadx = 20, tickpady = 12;
const int capwidth = 8;
- const int barwidth = numticks*tickwidth+tickpadx*2+capwidth*2, barleft = ((640-barwidth)/2);
- const int barheight = tickheight + tickpady*2, bartop = 475-barheight;
- const int capleft = barleft+tickpadx, tickleft = capleft+capwidth, ticktop = bartop+tickpady;
+ const int barwidth = numticks * tickwidth + tickpadx * 2 + capwidth * 2, barleft = ((640 - barwidth) / 2);
+ const int barheight = tickheight + tickpady * 2, bartop = 475 - barheight;
+ const int capleft = barleft + tickpadx, tickleft = capleft + capwidth, ticktop = bartop + tickpady;
- cgi_R_SetColor( colorTable[CT_WHITE]);
+ cgi_R_SetColor(colorTable[CT_WHITE]);
// Draw background
CG_DrawPic(barleft, bartop, barwidth, barheight, cgs.media.levelLoad);
@@ -426,82 +359,67 @@ static void CG_LoadBar(void)
CG_DrawPic(tickleft, ticktop, -capwidth, tickheight, cgs.media.loadTickCap);
// Draw bar
- CG_DrawPic(tickleft, ticktop, tickwidth*cg.loadLCARSStage, tickheight, cgs.media.loadTick);
+ CG_DrawPic(tickleft, ticktop, tickwidth * cg.loadLCARSStage, tickheight, cgs.media.loadTick);
// Draw right cap
- CG_DrawPic(tickleft+tickwidth*cg.loadLCARSStage, ticktop, capwidth, tickheight, cgs.media.loadTickCap);
+ CG_DrawPic(tickleft + tickwidth * cg.loadLCARSStage, ticktop, capwidth, tickheight, cgs.media.loadTickCap);
}
-int CG_WeaponCheck( int weaponIndex );
+int CG_WeaponCheck(int weaponIndex);
// For printing load screen icons
-const int MAXLOADICONSPERROW = 8; // Max icons displayed per row
-const int MAXLOADWEAPONS = 16;
-const int MAXLOAD_FORCEICONSIZE = 40; // Size of force power icons
-const int MAXLOAD_FORCEICONPAD = 12; // Padding space between icons
+const int MAXLOADICONSPERROW = 8; // Max icons displayed per row
+const int MAXLOADWEAPONS = 16;
+const int MAXLOAD_FORCEICONSIZE = 40; // Size of force power icons
+const int MAXLOAD_FORCEICONPAD = 12; // Padding space between icons
-static int CG_DrawLoadWeaponsPrintRow( const char *itemName, int weaponsBits,int rowIconCnt, int startIndex)
-{
- int i,endIndex=0, printedIconCnt=0;
- int iconSize;
- int holdX,x,y,pad;
- int yOffset = 0;
- int width,height;
- vec4_t color;
- qhandle_t background;
-
- if (!cgi_UI_GetMenuItemInfo(
- "loadScreen",
- itemName,
- &x,
- &y,
- &width,
- &height,
- color,
- &background))
- {
- return(0);
+static int CG_DrawLoadWeaponsPrintRow(const char *itemName, int weaponsBits, int rowIconCnt, int startIndex) {
+ int i, endIndex = 0, printedIconCnt = 0;
+ int iconSize;
+ int holdX, x, y, pad;
+ int yOffset = 0;
+ int width, height;
+ vec4_t color;
+ qhandle_t background;
+
+ if (!cgi_UI_GetMenuItemInfo("loadScreen", itemName, &x, &y, &width, &height, color, &background)) {
+ return (0);
}
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
iconSize = 60;
pad = 12;
// calculate placement of weapon icons
- holdX = x + (width - ((iconSize*rowIconCnt) + (pad * (rowIconCnt-1))))/2;
+ holdX = x + (width - ((iconSize * rowIconCnt) + (pad * (rowIconCnt - 1)))) / 2;
- for (i=startIndex;iweaponIconNoAmmo );
- // }
- // else
- {
- CG_DrawPic( holdX, y+yOffset, iconSize, iconSize, weaponInfo->weaponIcon );
- }
+ // NOTE : during loading screen always show the have ammo icon
+ // if (!CG_WeaponCheck(i))
+ // {
+ // CG_DrawPic( holdX, y+yOffset, iconSize, iconSize, weaponInfo->weaponIconNoAmmo );
+ // }
+ // else
+ { CG_DrawPic(holdX, y + yOffset, iconSize, iconSize, weaponInfo->weaponIcon); }
printedIconCnt++;
- if (printedIconCnt==MAXLOADICONSPERROW)
- {
+ if (printedIconCnt == MAXLOADICONSPERROW) {
break;
}
- holdX += (iconSize+pad);
+ holdX += (iconSize + pad);
}
}
@@ -510,110 +428,89 @@ static int CG_DrawLoadWeaponsPrintRow( const char *itemName, int weaponsBits,int
// Print weapons the player is carrying
// Two rows print if there are too many
-static void CG_DrawLoadWeapons( int weaponBits )
-{
- int i,endIndex=0;
- int iconCnt,rowIconCnt;
+static void CG_DrawLoadWeapons(int weaponBits) {
+ int i, endIndex = 0;
+ int iconCnt, rowIconCnt;
// count the number of weapons owned
iconCnt = 0;
- for ( i = 1 ; i < MAXLOADWEAPONS ; i++ )
- {
- if ( weaponBits & ( 1 << i ) )
- {
+ for (i = 1; i < MAXLOADWEAPONS; i++) {
+ if (weaponBits & (1 << i)) {
iconCnt++;
}
}
- if (!iconCnt) // If no weapons, don't display
+ if (!iconCnt) // If no weapons, don't display
{
return;
}
// Single line of icons
- if (iconCnt<=MAXLOADICONSPERROW)
- {
- CG_DrawLoadWeaponsPrintRow("weaponicons_singlerow", weaponBits, iconCnt,0);
+ if (iconCnt <= MAXLOADICONSPERROW) {
+ CG_DrawLoadWeaponsPrintRow("weaponicons_singlerow", weaponBits, iconCnt, 0);
}
// Two lines of icons
- else
- {
+ else {
// Print top row
- endIndex = CG_DrawLoadWeaponsPrintRow("weaponicons_row1", weaponBits, MAXLOADICONSPERROW,0);
+ endIndex = CG_DrawLoadWeaponsPrintRow("weaponicons_row1", weaponBits, MAXLOADICONSPERROW, 0);
// Print second row
rowIconCnt = iconCnt - MAXLOADICONSPERROW;
- CG_DrawLoadWeaponsPrintRow("weaponicons_row2", weaponBits, rowIconCnt,endIndex+1);
+ CG_DrawLoadWeaponsPrintRow("weaponicons_row2", weaponBits, rowIconCnt, endIndex + 1);
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
+static int CG_DrawLoadForcePrintRow(const char *itemName, int forceBits, int rowIconCnt, int startIndex) {
+ int i, endIndex = 0, printedIconCnt = 0;
+ int holdX, x, y;
+ int yOffset = 0;
+ int width, height;
+ vec4_t color;
+ qhandle_t background;
-static int CG_DrawLoadForcePrintRow( const char *itemName, int forceBits,int rowIconCnt, int startIndex)
-{
- int i,endIndex=0, printedIconCnt=0;
- int holdX,x,y;
- int yOffset = 0;
- int width,height;
- vec4_t color;
- qhandle_t background;
-
- if (!cgi_UI_GetMenuItemInfo(
- "loadScreen",
- itemName,
- &x,
- &y,
- &width,
- &height,
- color,
- &background))
- {
- return(0);
+ if (!cgi_UI_GetMenuItemInfo("loadScreen", itemName, &x, &y, &width, &height, color, &background)) {
+ return (0);
}
- cgi_R_SetColor( color );
+ cgi_R_SetColor(color);
// calculate placement of weapon icons
- holdX = x + (width - ((MAXLOAD_FORCEICONSIZE*rowIconCnt) + (MAXLOAD_FORCEICONPAD * (rowIconCnt-1))))/2;
+ holdX = x + (width - ((MAXLOAD_FORCEICONSIZE * rowIconCnt) + (MAXLOAD_FORCEICONPAD * (rowIconCnt - 1)))) / 2;
- for (i=startIndex;ips.stats[STAT_HEALTH],
- &iDummy, // &client->ps.stats[STAT_ARMOR],
- &*weaponBits,// &client->ps.stats[STAT_WEAPONS],
- &iDummy, // &client->ps.stats[STAT_ITEMS],
- &iDummy, // &client->ps.weapon,
- &iDummy, // &client->ps.weaponstate,
- &iDummy, // &client->ps.batteryCharge,
- &fDummy, // &client->ps.viewangles[0],
- &fDummy, // &client->ps.viewangles[1],
- &fDummy, // &client->ps.viewangles[2],
- //force power data
- &*forceBits, // &client->ps.forcePowersKnown,
- &iDummy // &client->ps.forcePower,
-
- );
+ if (s[0]) {
+ // |general info |-force powers
+ sscanf(s, "%i %i %i %i %i %i %i %f %f %f %i %i",
+ &iDummy, // &client->ps.stats[STAT_HEALTH],
+ &iDummy, // &client->ps.stats[STAT_ARMOR],
+ &*weaponBits, // &client->ps.stats[STAT_WEAPONS],
+ &iDummy, // &client->ps.stats[STAT_ITEMS],
+ &iDummy, // &client->ps.weapon,
+ &iDummy, // &client->ps.weaponstate,
+ &iDummy, // &client->ps.batteryCharge,
+ &fDummy, // &client->ps.viewangles[0],
+ &fDummy, // &client->ps.viewangles[1],
+ &fDummy, // &client->ps.viewangles[2],
+ // force power data
+ &*forceBits, // &client->ps.forcePowersKnown,
+ &iDummy // &client->ps.forcePower,
+
+ );
}
// the new JK2 stuff - force powers, etc...
//
- gi.Cvar_VariableStringBuffer( "playerfplvl", s, sizeof(s) );
- i=0;
- var = strtok( s, " " );
- while( var != NULL )
- {
+ gi.Cvar_VariableStringBuffer("playerfplvl", s, sizeof(s));
+ i = 0;
+ var = strtok(s, " ");
+ while (var != NULL) {
/* While there are tokens in "s" */
loadForcePowerLevel[i++] = atoi(var);
/* Get next token: */
- var = strtok( NULL, " " );
+ var = strtok(NULL, " ");
}
}
@@ -714,73 +603,49 @@ CG_DrawLoadingScreen
Load screen displays the map pic, the mission briefing and weapons/force powers
====================
*/
-static void CG_DrawLoadingScreen( qhandle_t levelshot ,const char *mapName)
-{
- int xPos,yPos,width,height;
- vec4_t color;
- qhandle_t background;
- int weapons=0, forcepowers=0;
+static void CG_DrawLoadingScreen(qhandle_t levelshot, const char *mapName) {
+ int xPos, yPos, width, height;
+ vec4_t color;
+ qhandle_t background;
+ int weapons = 0, forcepowers = 0;
// Get mission briefing for load screen
- if (cgi_SP_GetStringTextString( va("BRIEFINGS_%s",mapName), NULL, 0 ) == 0)
- {
- cgi_Cvar_Set( "ui_missionbriefing", "@BRIEFINGS_NONE" );
- }
- else
- {
- cgi_Cvar_Set( "ui_missionbriefing", va("@BRIEFINGS_%s",mapName) );
+ if (cgi_SP_GetStringTextString(va("BRIEFINGS_%s", mapName), NULL, 0) == 0) {
+ cgi_Cvar_Set("ui_missionbriefing", "@BRIEFINGS_NONE");
+ } else {
+ cgi_Cvar_Set("ui_missionbriefing", va("@BRIEFINGS_%s", mapName));
}
// Print background
- if (cgi_UI_GetMenuItemInfo(
- "loadScreen",
- "background",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, background );
+ if (cgi_UI_GetMenuItemInfo("loadScreen", "background", &xPos, &yPos, &width, &height, color, &background)) {
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, background);
}
// Print level pic
- if (cgi_UI_GetMenuItemInfo(
- "loadScreen",
- "mappic",
- &xPos,
- &yPos,
- &width,
- &height,
- color,
- &background))
- {
- //if (!levelshot)
+ if (cgi_UI_GetMenuItemInfo("loadScreen", "mappic", &xPos, &yPos, &width, &height, color, &background)) {
+ // if (!levelshot)
//{// No level shot so use screenshot.
- // CG_DrawPic( xPos, yPos, 1, 1, 0); //force the tess to flush
+ // CG_DrawPic( xPos, yPos, 1, 1, 0); //force the tess to flush
// cgi_R_DrawScreenShot( xPos, yPos+height, width, -height );
//}
- //else
+ // else
{
- cgi_R_SetColor( color );
- CG_DrawPic( xPos, yPos, width, height, levelshot );
+ cgi_R_SetColor(color);
+ CG_DrawPic(xPos, yPos, width, height, levelshot);
}
}
// Get player weapons and force power info
- CG_GetLoadScreenInfo(&weapons,&forcepowers);
+ CG_GetLoadScreenInfo(&weapons, &forcepowers);
// Print weapon icons
- if (weapons)
- {
+ if (weapons) {
CG_DrawLoadWeapons(weapons);
}
// Print force power icons
- if (forcepowers)
- {
+ if (forcepowers) {
CG_DrawLoadForcePowers(forcepowers);
}
}
@@ -792,66 +657,62 @@ CG_DrawInformation
Draw all the status / pacifier stuff during level loading
====================
*/
-void CG_DrawInformation( void ) {
- int y;
+void CG_DrawInformation(void) {
+ int y;
// draw the dialog background
- const char *info = CG_ConfigString( CS_SERVERINFO );
- const char *s = Info_ValueForKey( info, "mapname" );
-
- qhandle_t levelshot;
-
- extern SavedGameJustLoaded_e g_eSavedGameJustLoaded; // hack! (hey, it's the last week of coding, ok?
-// if ( g_eSavedGameJustLoaded == eFULL )
-// {
-// levelshot = 0; //use the loaded thumbnail instead of the levelshot
-// }
-// else
- {
- levelshot = cgi_R_RegisterShaderNoMip( va( "levelshots/%s", s ) );
- #ifndef FINAL_BUILD
- if (!levelshot && !strncmp(s, "work/",5) )
- {
- levelshot = cgi_R_RegisterShaderNoMip( va( "levelshots/%s", s+5 ) );
+ const char *info = CG_ConfigString(CS_SERVERINFO);
+ const char *s = Info_ValueForKey(info, "mapname");
+
+ qhandle_t levelshot;
+
+ extern SavedGameJustLoaded_e g_eSavedGameJustLoaded; // hack! (hey, it's the last week of coding, ok?
+ // if ( g_eSavedGameJustLoaded == eFULL )
+ // {
+ // levelshot = 0; //use the loaded thumbnail instead of the levelshot
+ // }
+ // else
+ {
+ levelshot = cgi_R_RegisterShaderNoMip(va("levelshots/%s", s));
+#ifndef FINAL_BUILD
+ if (!levelshot && !strncmp(s, "work/", 5)) {
+ levelshot = cgi_R_RegisterShaderNoMip(va("levelshots/%s", s + 5));
}
- #endif
+#endif
if (!levelshot) {
- levelshot = cgi_R_RegisterShaderNoMip( "menu/art/unknownmap" );
+ levelshot = cgi_R_RegisterShaderNoMip("menu/art/unknownmap");
}
}
- if ( g_eSavedGameJustLoaded != eFULL && !strcmp(s,"yavin1") )//special case for first map!
+ if (g_eSavedGameJustLoaded != eFULL && !strcmp(s, "yavin1")) // special case for first map!
{
- char text[1024]={0};
+ char text[1024] = {0};
//
- cgi_R_SetColor( colorTable[CT_BLACK] );
- CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, cgs.media.whiteShader );
+ cgi_R_SetColor(colorTable[CT_BLACK]);
+ CG_DrawPic(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, cgs.media.whiteShader);
- cgi_SP_GetStringTextString( "SP_INGAME_ALONGTIME", text, sizeof(text) );
+ cgi_SP_GetStringTextString("SP_INGAME_ALONGTIME", text, sizeof(text));
- int w = cgi_R_Font_StrLenPixels(text,cgs.media.qhFontMedium, 1.0f);
- cgi_R_Font_DrawString((320)-(w/2), 140, text, colorTable[CT_ICON_BLUE], cgs.media.qhFontMedium, -1, 1.0f);
- }
- else
- {
+ int w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.0f);
+ cgi_R_Font_DrawString((320) - (w / 2), 140, text, colorTable[CT_ICON_BLUE], cgs.media.qhFontMedium, -1, 1.0f);
+ } else {
CG_DrawLoadingScreen(levelshot, s);
- cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "loadscreen" ), qtrue );
- //cgi_UI_MenuPaintAll();
+ cgi_UI_Menu_Paint(cgi_UI_GetMenuByName("loadscreen"), qtrue);
+ // cgi_UI_MenuPaintAll();
}
CG_LoadBar();
-
// the first 150 rows are reserved for the client connection
// screen to write into
-// if ( cg.processedSnapshotNum == 0 )
+ // if ( cg.processedSnapshotNum == 0 )
{
// still loading
// print the current item being loaded
#ifdef _DEBUG
- cgi_R_Font_DrawString( 40, 416, va("LOADING ... %s",cg.infoScreenText),colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f );
+ cgi_R_Font_DrawString(40, 416, va("LOADING ... %s", cg.infoScreenText), colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f);
#endif
}
@@ -859,19 +720,15 @@ void CG_DrawInformation( void ) {
y = 20;
// map-specific message (long map name)
- s = CG_ConfigString( CS_MESSAGE );
-
- if ( s[0] )
- {
- if (s[0] == '@')
- {
- char text[1024]={0};
- cgi_SP_GetStringTextString( s+1, text, sizeof(text) );
- cgi_R_Font_DrawString( 15, y, va("\"%s\"",text),colorTable[CT_WHITE],cgs.media.qhFontMedium, -1, 1.0f );
- }
- else
- {
- cgi_R_Font_DrawString( 15, y, va("\"%s\"",s),colorTable[CT_WHITE],cgs.media.qhFontMedium, -1, 1.0f );
+ s = CG_ConfigString(CS_MESSAGE);
+
+ if (s[0]) {
+ if (s[0] == '@') {
+ char text[1024] = {0};
+ cgi_SP_GetStringTextString(s + 1, text, sizeof(text));
+ cgi_R_Font_DrawString(15, y, va("\"%s\"", text), colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 1.0f);
+ } else {
+ cgi_R_Font_DrawString(15, y, va("\"%s\"", s), colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 1.0f);
}
y += 20;
}
diff --git a/code/cgame/cg_lights.cpp b/code/cgame/cg_lights.cpp
index 4891e135af..7086a9583f 100644
--- a/code/cgame/cg_lights.cpp
+++ b/code/cgame/cg_lights.cpp
@@ -23,29 +23,27 @@ along with this program; if not, see .
#include "cg_headers.h"
typedef struct clightstyle_s {
- int length;
- color4ub_t value;
- color4ub_t map[MAX_QPATH];
+ int length;
+ color4ub_t value;
+ color4ub_t map[MAX_QPATH];
} clightstyle_t;
-static clightstyle_t cl_lightstyle[MAX_LIGHT_STYLES];
-static int lastofs;
+static clightstyle_t cl_lightstyle[MAX_LIGHT_STYLES];
+static int lastofs;
/*
================
FX_ClearLightStyles
================
*/
-void CG_ClearLightStyles (void)
-{
- int i;
+void CG_ClearLightStyles(void) {
+ int i;
- memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
+ memset(cl_lightstyle, 0, sizeof(cl_lightstyle));
lastofs = -1;
- for(i=0;ilength)
- {
+ for (i = 0, ls = cl_lightstyle; i < MAX_LIGHT_STYLES; i++, ls++) {
+ if (!ls->length) {
ls->value[0] = ls->value[1] = ls->value[2] = ls->value[3] = 255;
- }
- else if (ls->length == 1)
- {
+ } else if (ls->length == 1) {
ls->value[0] = ls->map[0][0];
ls->value[1] = ls->map[0][1];
ls->value[2] = ls->map[0][2];
- ls->value[3] = 255; //ls->map[0][3];
- }
- else
- {
- ls->value[0] = ls->map[ofs%ls->length][0];
- ls->value[1] = ls->map[ofs%ls->length][1];
- ls->value[2] = ls->map[ofs%ls->length][2];
- ls->value[3] = 255; //ls->map[ofs%ls->length][3];
+ ls->value[3] = 255; // ls->map[0][3];
+ } else {
+ ls->value[0] = ls->map[ofs % ls->length][0];
+ ls->value[1] = ls->map[ofs % ls->length][1];
+ ls->value[2] = ls->map[ofs % ls->length][2];
+ ls->value[3] = 255; // ls->map[ofs%ls->length][3];
}
const byteAlias_t *ba = (byteAlias_t *)&ls->value;
- trap_R_SetLightStyle( i, ba->i );
+ trap_R_SetLightStyle(i, ba->i);
}
}
-void CG_SetLightstyle (int i)
-{
- const char *s;
- int j, k;
+void CG_SetLightstyle(int i) {
+ const char *s;
+ int j, k;
- s = CG_ConfigString( i+CS_LIGHT_STYLES );
- j = strlen (s);
- if (j >= MAX_QPATH)
- {
- Com_Error (ERR_DROP, "svc_lightstyle length=%i", j);
+ s = CG_ConfigString(i + CS_LIGHT_STYLES);
+ j = strlen(s);
+ if (j >= MAX_QPATH) {
+ Com_Error(ERR_DROP, "svc_lightstyle length=%i", j);
}
- cl_lightstyle[(i/3)].length = j;
- for (k=0 ; k.
#include "cg_headers.h"
-
#include "cg_media.h"
-#define MAX_LOCAL_ENTITIES 512
-localEntity_t cg_localEntities[MAX_LOCAL_ENTITIES];
-localEntity_t cg_activeLocalEntities; // double linked list
-localEntity_t *cg_freeLocalEntities; // single linked list
+#define MAX_LOCAL_ENTITIES 512
+localEntity_t cg_localEntities[MAX_LOCAL_ENTITIES];
+localEntity_t cg_activeLocalEntities; // double linked list
+localEntity_t *cg_freeLocalEntities; // single linked list
/*
===================
@@ -42,27 +41,26 @@ This is called at startup and for tournement restarts
===================
*/
-void CG_InitLocalEntities( void ) {
- int i;
+void CG_InitLocalEntities(void) {
+ int i;
- memset( cg_localEntities, 0, sizeof( cg_localEntities ) );
+ memset(cg_localEntities, 0, sizeof(cg_localEntities));
cg_activeLocalEntities.next = &cg_activeLocalEntities;
cg_activeLocalEntities.prev = &cg_activeLocalEntities;
cg_freeLocalEntities = cg_localEntities;
- for ( i = 0 ; i < MAX_LOCAL_ENTITIES - 1 ; i++ ) {
- cg_localEntities[i].next = &cg_localEntities[i+1];
+ for (i = 0; i < MAX_LOCAL_ENTITIES - 1; i++) {
+ cg_localEntities[i].next = &cg_localEntities[i + 1];
}
}
-
/*
==================
CG_FreeLocalEntity
==================
*/
-void CG_FreeLocalEntity( localEntity_t *le ) {
- if ( !le->prev ) {
- CG_Error( "CG_FreeLocalEntity: not active" );
+void CG_FreeLocalEntity(localEntity_t *le) {
+ if (!le->prev) {
+ CG_Error("CG_FreeLocalEntity: not active");
}
// remove from the doubly linked active list
@@ -81,19 +79,19 @@ CG_AllocLocalEntity
Will allways succeed, even if it requires freeing an old active entity
===================
*/
-localEntity_t *CG_AllocLocalEntity( void ) {
- localEntity_t *le;
+localEntity_t *CG_AllocLocalEntity(void) {
+ localEntity_t *le;
- if ( !cg_freeLocalEntities ) {
+ if (!cg_freeLocalEntities) {
// no free entities, so free the one at the end of the chain
// remove the oldest active entity
- CG_FreeLocalEntity( cg_activeLocalEntities.prev );
+ CG_FreeLocalEntity(cg_activeLocalEntities.prev);
}
le = cg_freeLocalEntities;
cg_freeLocalEntities = cg_freeLocalEntities->next;
- memset( le, 0, sizeof( *le ) );
+ memset(le, 0, sizeof(*le));
// link into the active list
le->next = cg_activeLocalEntities.next;
@@ -104,7 +102,6 @@ localEntity_t *CG_AllocLocalEntity( void ) {
return le;
}
-
/*
====================================================================================
@@ -116,76 +113,64 @@ or generates more localentities along a trail.
====================================================================================
*/
-
/*
================
CG_FragmentBounceSound
================
*/
-void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace )
-{
+void CG_FragmentBounceSound(localEntity_t *le, trace_t *trace) {
// half the fragments will make a bounce sounds
- if ( rand() & 1 )
- {
- sfxHandle_t s = 0;
+ if (rand() & 1) {
+ sfxHandle_t s = 0;
- switch( le->leBounceSoundType )
- {
+ switch (le->leBounceSoundType) {
case LEBS_ROCK:
- s = cgs.media.rockBounceSound[Q_irand(0,1)];
+ s = cgs.media.rockBounceSound[Q_irand(0, 1)];
break;
case LEBS_METAL:
- s = cgs.media.metalBounceSound[Q_irand(0,1)];// FIXME: make sure that this sound is registered properly...might still be rock bounce sound....
+ s = cgs.media.metalBounceSound[Q_irand(0, 1)]; // FIXME: make sure that this sound is registered properly...might still be rock bounce sound....
break;
default:
break;
}
- if ( s )
- {
- cgi_S_StartSound( trace->endpos, ENTITYNUM_WORLD, CHAN_AUTO, s );
+ if (s) {
+ cgi_S_StartSound(trace->endpos, ENTITYNUM_WORLD, CHAN_AUTO, s);
}
// bouncers only make the sound once...
// FIXME: arbitrary...change if it bugs you
le->leBounceSoundType = LEBS_NONE;
- }
- else if ( rand() & 1 )
- {
+ } else if (rand() & 1) {
// we may end up bouncing again, but each bounce reduces the chance of playing the sound again or they may make a lot of noise when they settle
// FIXME: maybe just always do this??
le->leBounceSoundType = LEBS_NONE;
}
}
-
/*
================
CG_ReflectVelocity
================
*/
-void CG_ReflectVelocity( localEntity_t *le, trace_t *trace )
-{
- vec3_t velocity;
- float dot;
- int hitTime;
+void CG_ReflectVelocity(localEntity_t *le, trace_t *trace) {
+ vec3_t velocity;
+ float dot;
+ int hitTime;
// reflect the velocity on the trace plane
hitTime = cg.time - cg.frametime + cg.frametime * trace->fraction;
- EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );
- dot = DotProduct( velocity, trace->plane.normal );
- VectorMA( velocity, -2*dot, trace->plane.normal, le->pos.trDelta );
+ EvaluateTrajectoryDelta(&le->pos, hitTime, velocity);
+ dot = DotProduct(velocity, trace->plane.normal);
+ VectorMA(velocity, -2 * dot, trace->plane.normal, le->pos.trDelta);
- VectorScale( le->pos.trDelta, le->bounceFactor, le->pos.trDelta );
+ VectorScale(le->pos.trDelta, le->bounceFactor, le->pos.trDelta);
- VectorCopy( trace->endpos, le->pos.trBase );
+ VectorCopy(trace->endpos, le->pos.trBase);
le->pos.trTime = cg.time;
// check for stop, making sure that even on low FPS systems it doesn't bobble
- if ( trace->allsolid ||
- ( trace->plane.normal[2] > 0 &&
- ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) )
- {
+ if (trace->allsolid || (trace->plane.normal[2] > 0 && (le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2]))) {
le->pos.trType = TR_STATIONARY;
}
}
@@ -195,63 +180,57 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace )
CG_AddFragment
================
*/
-void CG_AddFragment( localEntity_t *le )
-{
- vec3_t newOrigin;
- trace_t trace;
+void CG_AddFragment(localEntity_t *le) {
+ vec3_t newOrigin;
+ trace_t trace;
// used to sink into the ground, but it looks better to maybe just fade them out
- int t;
+ int t;
t = le->endTime - cg.time;
- if ( t < FRAG_FADE_TIME )
- {
+ if (t < FRAG_FADE_TIME) {
le->refEntity.renderfx |= RF_ALPHA_FADE;
le->refEntity.shaderRGBA[0] = le->refEntity.shaderRGBA[1] = le->refEntity.shaderRGBA[2] = 255;
le->refEntity.shaderRGBA[3] = ((float)t / FRAG_FADE_TIME) * 255.0f;
}
- if ( le->pos.trType == TR_STATIONARY )
- {
- if ( !(cgi_CM_PointContents( le->refEntity.origin, 0 ) & CONTENTS_SOLID ))
- {
+ if (le->pos.trType == TR_STATIONARY) {
+ if (!(cgi_CM_PointContents(le->refEntity.origin, 0) & CONTENTS_SOLID)) {
// thing is no longer in solid, so let gravity take it back
- VectorCopy( le->refEntity.origin, le->pos.trBase );
- VectorClear( le->pos.trDelta );
+ VectorCopy(le->refEntity.origin, le->pos.trBase);
+ VectorClear(le->pos.trDelta);
le->pos.trTime = cg.time;
le->pos.trType = TR_GRAVITY;
}
- cgi_R_AddRefEntityToScene( &le->refEntity );
+ cgi_R_AddRefEntityToScene(&le->refEntity);
return;
}
// calculate new position
- EvaluateTrajectory( &le->pos, cg.time, newOrigin );
+ EvaluateTrajectory(&le->pos, cg.time, newOrigin);
le->refEntity.renderfx |= RF_LIGHTING_ORIGIN;
- VectorCopy( newOrigin, le->refEntity.lightingOrigin );
+ VectorCopy(newOrigin, le->refEntity.lightingOrigin);
// trace a line from previous position to new position
- CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, le->ownerGentNum, CONTENTS_SOLID );
- if ( trace.fraction == 1.0 ) {
+ CG_Trace(&trace, le->refEntity.origin, NULL, NULL, newOrigin, le->ownerGentNum, CONTENTS_SOLID);
+ if (trace.fraction == 1.0) {
// still in free fall
- VectorCopy( newOrigin, le->refEntity.origin );
+ VectorCopy(newOrigin, le->refEntity.origin);
- if ( le->leFlags & LEF_TUMBLE ) {
+ if (le->leFlags & LEF_TUMBLE) {
vec3_t angles;
- EvaluateTrajectory( &le->angles, cg.time, angles );
- AnglesToAxis( angles, le->refEntity.axis );
- for(int k = 0; k < 3; k++)
- {
+ EvaluateTrajectory(&le->angles, cg.time, angles);
+ AnglesToAxis(angles, le->refEntity.axis);
+ for (int k = 0; k < 3; k++) {
VectorScale(le->refEntity.axis[k], le->radius, le->refEntity.axis[k]);
}
-
}
- cgi_R_AddRefEntityToScene( &le->refEntity );
+ cgi_R_AddRefEntityToScene(&le->refEntity);
return;
}
@@ -259,20 +238,19 @@ void CG_AddFragment( localEntity_t *le )
// if it is in a nodrop zone, remove it
// this keeps gibs from waiting at the bottom of pits of death
// and floating levels
- if ( cgi_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP )
- {
- CG_FreeLocalEntity( le );
+ if (cgi_CM_PointContents(trace.endpos, 0) & CONTENTS_NODROP) {
+ CG_FreeLocalEntity(le);
return;
}
// do a bouncy sound
- CG_FragmentBounceSound( le, &trace );
+ CG_FragmentBounceSound(le, &trace);
// reflect the velocity on the trace plane
- CG_ReflectVelocity( le, &trace );
- //FIXME: if LEF_TUMBLE, change avelocity too?
+ CG_ReflectVelocity(le, &trace);
+ // FIXME: if LEF_TUMBLE, change avelocity too?
- cgi_R_AddRefEntityToScene( &le->refEntity );
+ cgi_R_AddRefEntityToScene(&le->refEntity);
}
/*
@@ -287,32 +265,29 @@ These only do simple scaling or modulation before passing to the renderer
/*
** CG_AddTeleporterEffect
*/
-void CG_AddTeleporterEffect( localEntity_t *le ) {
+void CG_AddTeleporterEffect(localEntity_t *le) {
refEntity_t *re;
float c;
re = &le->refEntity;
- c = ( le->endTime - cg.time ) / ( float ) ( le->endTime - le->startTime );
+ c = (le->endTime - cg.time) / (float)(le->endTime - le->startTime);
- re->shaderRGBA[0] =
- re->shaderRGBA[1] =
- re->shaderRGBA[2] =
- re->shaderRGBA[3] = 0xff * c;
+ re->shaderRGBA[0] = re->shaderRGBA[1] = re->shaderRGBA[2] = re->shaderRGBA[3] = 0xff * c;
- cgi_R_AddRefEntityToScene( re );
+ cgi_R_AddRefEntityToScene(re);
}
/*
** CG_AddFadeRGB
*/
-void CG_AddFadeRGB( localEntity_t *le ) {
+void CG_AddFadeRGB(localEntity_t *le) {
refEntity_t *re;
float c;
re = &le->refEntity;
- c = ( le->endTime - cg.time ) * le->lifeRate;
+ c = (le->endTime - cg.time) * le->lifeRate;
c *= 0xff;
re->shaderRGBA[0] = le->color[0] * c;
@@ -320,7 +295,7 @@ void CG_AddFadeRGB( localEntity_t *le ) {
re->shaderRGBA[2] = le->color[2] * c;
re->shaderRGBA[3] = le->color[3] * c;
- cgi_R_AddRefEntityToScene( re );
+ cgi_R_AddRefEntityToScene(re);
}
/*
@@ -328,37 +303,37 @@ void CG_AddFadeRGB( localEntity_t *le ) {
CG_AddPuff
==================
*/
-static void CG_AddPuff( localEntity_t *le ) {
- refEntity_t *re;
- float c;
- vec3_t delta;
- float len;
+static void CG_AddPuff(localEntity_t *le) {
+ refEntity_t *re;
+ float c;
+ vec3_t delta;
+ float len;
re = &le->refEntity;
// fade / grow time
- c = ( le->endTime - cg.time ) / (float)( le->endTime - le->startTime );
+ c = (le->endTime - cg.time) / (float)(le->endTime - le->startTime);
re->shaderRGBA[0] = le->color[0] * c;
re->shaderRGBA[1] = le->color[1] * c;
re->shaderRGBA[2] = le->color[2] * c;
- if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {
- re->radius = le->radius * ( 1.0 - c ) + 8;
+ if (!(le->leFlags & LEF_PUFF_DONT_SCALE)) {
+ re->radius = le->radius * (1.0 - c) + 8;
}
- EvaluateTrajectory( &le->pos, cg.time, re->origin );
+ EvaluateTrajectory(&le->pos, cg.time, re->origin);
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
- VectorSubtract( re->origin, cg.refdef.vieworg, delta );
- len = VectorLength( delta );
- if ( len < le->radius ) {
- CG_FreeLocalEntity( le );
+ VectorSubtract(re->origin, cg.refdef.vieworg, delta);
+ len = VectorLength(delta);
+ if (len < le->radius) {
+ CG_FreeLocalEntity(le);
return;
}
- cgi_R_AddRefEntityToScene( re );
+ cgi_R_AddRefEntityToScene(re);
}
/*
@@ -366,71 +341,63 @@ static void CG_AddPuff( localEntity_t *le ) {
CG_AddLocalLight
================
*/
-static void CG_AddLocalLight( localEntity_t *le )
-{
+static void CG_AddLocalLight(localEntity_t *le) {
// There should be a light if this is being used, but hey...
- if ( le->light )
- {
- float light;
+ if (le->light) {
+ float light;
- light = (float)( cg.time - le->startTime ) / ( le->endTime - le->startTime );
+ light = (float)(cg.time - le->startTime) / (le->endTime - le->startTime);
- if ( light < 0.5 )
- {
+ if (light < 0.5) {
light = 1.0;
- }
- else
- {
- light = 1.0 - ( light - 0.5 ) * 2;
+ } else {
+ light = 1.0 - (light - 0.5) * 2;
}
light = le->light * light;
- cgi_R_AddLightToScene( le->refEntity.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2] );
+ cgi_R_AddLightToScene(le->refEntity.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2]);
}
}
//---------------------------------------------------
-static void CG_AddFadeModel( localEntity_t *le )
-{
- refEntity_t *ent = &le->refEntity;
+static void CG_AddFadeModel(localEntity_t *le) {
+ refEntity_t *ent = &le->refEntity;
- if ( cg.time < le->startTime )
- {
- CG_FreeLocalEntity( le );
+ if (cg.time < le->startTime) {
+ CG_FreeLocalEntity(le);
return;
}
- float frac = 1.0f - ((float)( cg.time - le->startTime )/(float)( le->endTime - le->startTime ));
+ float frac = 1.0f - ((float)(cg.time - le->startTime) / (float)(le->endTime - le->startTime));
ent->shaderRGBA[0] = le->color[0] * frac;
ent->shaderRGBA[1] = le->color[1] * frac;
ent->shaderRGBA[2] = le->color[2] * frac;
ent->shaderRGBA[3] = le->color[3] * frac;
- EvaluateTrajectory( &le->pos, cg.time, ent->origin );
+ EvaluateTrajectory(&le->pos, cg.time, ent->origin);
// add the entity
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
}
// NOTE: this is 100% for the demp2 alt-fire effect, so changes to the visual effect will affect game side demp2 code
//---------------------------------------------------
-static void CG_AddFadeScaleModel( localEntity_t *le )
-{
- refEntity_t *ent = &le->refEntity;
+static void CG_AddFadeScaleModel(localEntity_t *le) {
+ refEntity_t *ent = &le->refEntity;
- float frac = ( cg.time - le->startTime )/((float)( le->endTime - le->startTime ));
+ float frac = (cg.time - le->startTime) / ((float)(le->endTime - le->startTime));
frac *= frac * frac; // yes, this is completely ridiculous...but it causes the shell to grow slowly then "explode" at the end
ent->nonNormalizedAxes = qtrue;
- AxisCopy( axisDefault, ent->axis );
+ AxisCopy(axisDefault, ent->axis);
- VectorScale( ent->axis[0], le->radius * frac, ent->axis[0] );
- VectorScale( ent->axis[1], le->radius * frac, ent->axis[1] );
- VectorScale( ent->axis[2], le->radius * 0.5f * frac, ent->axis[2] );
+ VectorScale(ent->axis[0], le->radius * frac, ent->axis[0]);
+ VectorScale(ent->axis[1], le->radius * frac, ent->axis[1]);
+ VectorScale(ent->axis[2], le->radius * 0.5f * frac, ent->axis[2]);
frac = 1.0f - frac;
@@ -440,89 +407,85 @@ static void CG_AddFadeScaleModel( localEntity_t *le )
ent->shaderRGBA[3] = le->color[3] * frac;
// add the entity
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
}
// create a quad that doesn't use a refEnt. Currently only for use with the DebugNav drawing so it doesn't have to use fx
//------------------------------------------
-static void CG_AddQuad( localEntity_t *le )
-{
- polyVert_t verts[4];
+static void CG_AddQuad(localEntity_t *le) {
+ polyVert_t verts[4];
- VectorCopy( le->refEntity.origin, verts[0].xyz );
+ VectorCopy(le->refEntity.origin, verts[0].xyz);
verts[0].xyz[0] -= le->radius;
verts[0].xyz[1] -= le->radius;
verts[0].st[0] = 0;
verts[0].st[1] = 0;
- for ( int i = 0; i < 4; i++ )
- {
+ for (int i = 0; i < 4; i++) {
verts[i].modulate[0] = le->color[0];
verts[i].modulate[1] = le->color[1];
verts[i].modulate[2] = le->color[2];
verts[i].modulate[3] = le->color[3];
}
- VectorCopy( le->refEntity.origin, verts[1].xyz );
+ VectorCopy(le->refEntity.origin, verts[1].xyz);
verts[1].xyz[0] -= le->radius;
verts[1].xyz[1] += le->radius;
verts[1].st[0] = 0;
verts[1].st[1] = 1;
- VectorCopy( le->refEntity.origin, verts[2].xyz );
+ VectorCopy(le->refEntity.origin, verts[2].xyz);
verts[2].xyz[0] += le->radius;
verts[2].xyz[1] += le->radius;
verts[2].st[0] = 1;
verts[2].st[1] = 1;
- VectorCopy( le->refEntity.origin, verts[3].xyz );
+ VectorCopy(le->refEntity.origin, verts[3].xyz);
verts[3].xyz[0] += le->radius;
verts[3].xyz[1] -= le->radius;
verts[3].st[0] = 1;
verts[3].st[1] = 0;
- cgi_R_AddPolyToScene( le->refEntity.customShader, 4, verts );
+ cgi_R_AddPolyToScene(le->refEntity.customShader, 4, verts);
}
// create a sprite that doesn't use a refEnt. Currently only for use with the DebugNav drawing so it doesn't have to use fx
//------------------------------------------
-static void CG_AddSprite( localEntity_t *le )
-{
- polyVert_t verts[4];
+static void CG_AddSprite(localEntity_t *le) {
+ polyVert_t verts[4];
- VectorCopy( le->refEntity.origin, verts[0].xyz );
- VectorMA( verts[0].xyz, -le->radius, cg.refdef.viewaxis[2], verts[0].xyz );
- VectorMA( verts[0].xyz, -le->radius, cg.refdef.viewaxis[1], verts[0].xyz );
+ VectorCopy(le->refEntity.origin, verts[0].xyz);
+ VectorMA(verts[0].xyz, -le->radius, cg.refdef.viewaxis[2], verts[0].xyz);
+ VectorMA(verts[0].xyz, -le->radius, cg.refdef.viewaxis[1], verts[0].xyz);
verts[0].st[0] = 0;
verts[0].st[1] = 0;
- for ( int i = 0; i < 4; i++ )
- {
+ for (int i = 0; i < 4; i++) {
verts[i].modulate[0] = le->color[0];
verts[i].modulate[1] = le->color[1];
verts[i].modulate[2] = le->color[2];
verts[i].modulate[3] = le->color[3];
}
- VectorCopy( le->refEntity.origin, verts[1].xyz );
- VectorMA( verts[1].xyz, -le->radius, cg.refdef.viewaxis[2], verts[1].xyz );
- VectorMA( verts[1].xyz, le->radius, cg.refdef.viewaxis[1], verts[1].xyz );
+ VectorCopy(le->refEntity.origin, verts[1].xyz);
+ VectorMA(verts[1].xyz, -le->radius, cg.refdef.viewaxis[2], verts[1].xyz);
+ VectorMA(verts[1].xyz, le->radius, cg.refdef.viewaxis[1], verts[1].xyz);
verts[1].st[0] = 0;
verts[1].st[1] = 1;
- VectorCopy( le->refEntity.origin, verts[2].xyz );
- VectorMA( verts[2].xyz, le->radius, cg.refdef.viewaxis[2], verts[2].xyz );
- VectorMA( verts[2].xyz, le->radius, cg.refdef.viewaxis[1], verts[2].xyz );
+ VectorCopy(le->refEntity.origin, verts[2].xyz);
+ VectorMA(verts[2].xyz, le->radius, cg.refdef.viewaxis[2], verts[2].xyz);
+ VectorMA(verts[2].xyz, le->radius, cg.refdef.viewaxis[1], verts[2].xyz);
verts[2].st[0] = 1;
verts[2].st[1] = 1;
- VectorCopy( le->refEntity.origin, verts[3].xyz );
- VectorMA( verts[3].xyz, le->radius, cg.refdef.viewaxis[2], verts[3].xyz );
- VectorMA( verts[3].xyz, -le->radius, cg.refdef.viewaxis[1], verts[3].xyz );
+ VectorCopy(le->refEntity.origin, verts[3].xyz);
+ VectorMA(verts[3].xyz, le->radius, cg.refdef.viewaxis[2], verts[3].xyz);
+ VectorMA(verts[3].xyz, -le->radius, cg.refdef.viewaxis[1], verts[3].xyz);
verts[3].st[0] = 1;
verts[3].st[1] = 0;
- cgi_R_AddPolyToScene( le->refEntity.customShader, 4, verts );
+ cgi_R_AddPolyToScene(le->refEntity.customShader, 4, verts);
}
/*
@@ -532,15 +495,14 @@ CG_AddLine
for beams and the like.
===================
*/
-void CG_AddLine( localEntity_t *le )
-{
- refEntity_t *re;
+void CG_AddLine(localEntity_t *le) {
+ refEntity_t *re;
re = &le->refEntity;
re->reType = RT_LINE;
- cgi_R_AddRefEntityToScene( re );
+ cgi_R_AddRefEntityToScene(re);
}
//==============================================================================
@@ -551,69 +513,64 @@ CG_AddLocalEntities
===================
*/
-void CG_AddLocalEntities( void )
-{
- localEntity_t *le, *next;
+void CG_AddLocalEntities(void) {
+ localEntity_t *le, *next;
// walk the list backwards, so any new local entities generated
// (trails, marks, etc) will be present this frame
le = cg_activeLocalEntities.prev;
- for ( ; le != &cg_activeLocalEntities ; le = next ) {
+ for (; le != &cg_activeLocalEntities; le = next) {
// grab next now, so if the local entity is freed we
// still have it
next = le->prev;
- if ( cg.time >= le->endTime ) {
- CG_FreeLocalEntity( le );
+ if (cg.time >= le->endTime) {
+ CG_FreeLocalEntity(le);
continue;
}
- switch ( le->leType ) {
+ switch (le->leType) {
default:
- CG_Error( "Bad leType: %i", le->leType );
+ CG_Error("Bad leType: %i", le->leType);
break;
case LE_MARK:
break;
case LE_FADE_MODEL:
- CG_AddFadeModel( le );
+ CG_AddFadeModel(le);
break;
case LE_FADE_SCALE_MODEL:
- CG_AddFadeScaleModel( le );
+ CG_AddFadeScaleModel(le);
break;
case LE_FRAGMENT:
- CG_AddFragment( le );
+ CG_AddFragment(le);
break;
case LE_PUFF:
- CG_AddPuff( le );
+ CG_AddPuff(le);
break;
- case LE_FADE_RGB: // teleporters, railtrails
- CG_AddFadeRGB( le );
+ case LE_FADE_RGB: // teleporters, railtrails
+ CG_AddFadeRGB(le);
break;
case LE_LIGHT:
- CG_AddLocalLight( le );
+ CG_AddLocalLight(le);
break;
- case LE_LINE: // oriented lines for FX
- CG_AddLine( le );
+ case LE_LINE: // oriented lines for FX
+ CG_AddLine(le);
break;
// Use for debug only
case LE_QUAD:
- CG_AddQuad( le );
+ CG_AddQuad(le);
break;
case LE_SPRITE:
- CG_AddSprite( le );
+ CG_AddSprite(le);
}
}
}
-
-
-
-
diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp
index 86bf1a0c78..15ebac05e0 100644
--- a/code/cgame/cg_main.cpp
+++ b/code/cgame/cg_main.cpp
@@ -30,25 +30,23 @@ along with this program; if not, see .
#include "../qcommon/sstring.h"
#include "qcommon/ojk_saved_game_helper.h"
-//NOTENOTE: Be sure to change the mirrored code in g_shared.h
-typedef std::map< sstring_t, unsigned char > namePrecache_m;
-extern namePrecache_m *as_preCacheMap;
-extern void CG_RegisterNPCCustomSounds( clientInfo_t *ci );
-extern qboolean G_AddSexToMunroString ( char *string, qboolean qDoBoth );
-extern int G_ParseAnimFileSet( const char *skeletonName, const char *modelName=0);
-extern void CG_DrawDataPadInventorySelect( void );
-
-void CG_Init( int serverCommandSequence );
-qboolean CG_ConsoleCommand( void );
-void CG_Shutdown( void );
-int CG_GetCameraPos( vec3_t camerapos );
-int CG_GetCameraAng( vec3_t cameraang );
+// NOTENOTE: Be sure to change the mirrored code in g_shared.h
+typedef std::map namePrecache_m;
+extern namePrecache_m *as_preCacheMap;
+extern void CG_RegisterNPCCustomSounds(clientInfo_t *ci);
+extern qboolean G_AddSexToMunroString(char *string, qboolean qDoBoth);
+extern int G_ParseAnimFileSet(const char *skeletonName, const char *modelName = 0);
+extern void CG_DrawDataPadInventorySelect(void);
+
+void CG_Init(int serverCommandSequence);
+qboolean CG_ConsoleCommand(void);
+void CG_Shutdown(void);
+int CG_GetCameraPos(vec3_t camerapos);
+int CG_GetCameraAng(vec3_t cameraang);
void UseItem(int itemNum);
-const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight,
- const char *psText, int iFontHandle, float fScale,
- const vec4_t v4Color);
+const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight, const char *psText, int iFontHandle, float fScale, const vec4_t v4Color);
-#define NUM_CHUNKS 6
+#define NUM_CHUNKS 6
/*
Ghoul2 Insert Start
*/
@@ -62,36 +60,20 @@ void CG_ResizeG2TempBone(mdxaBone_v *tempBone, int newCount);
Ghoul2 Insert End
*/
-
void CG_LoadHudMenu(void);
int inv_icons[INV_MAX];
-const char *inv_names[] =
-{
-"ELECTROBINOCULARS",
-"BACTA CANISTER",
-"SEEKER",
-"LIGHT AMP GOGGLES",
-"ASSAULT SENTRY",
-"GOODIE KEY",
-"GOODIE KEY",
-"GOODIE KEY",
-"GOODIE KEY",
-"GOODIE KEY",
-"SECURITY KEY",
-"SECURITY KEY",
-"SECURITY KEY",
-"SECURITY KEY",
-"SECURITY KEY",
+const char *inv_names[] = {
+ "ELECTROBINOCULARS", "BACTA CANISTER", "SEEKER", "LIGHT AMP GOGGLES", "ASSAULT SENTRY", "GOODIE KEY", "GOODIE KEY", "GOODIE KEY",
+ "GOODIE KEY", "GOODIE KEY", "SECURITY KEY", "SECURITY KEY", "SECURITY KEY", "SECURITY KEY", "SECURITY KEY",
};
-int force_icons[NUM_FORCE_POWERS];
-
+int force_icons[NUM_FORCE_POWERS];
-void CG_DrawDataPadHUD( centity_t *cent );
-void CG_DrawDataPadObjectives(const centity_t *cent );
+void CG_DrawDataPadHUD(centity_t *cent);
+void CG_DrawDataPadObjectives(const centity_t *cent);
void CG_DrawDataPadIconBackground(const int backgroundType);
-void CG_DrawDataPadWeaponSelect( void );
-void CG_DrawDataPadForceSelect( void );
+void CG_DrawDataPadWeaponSelect(void);
+void CG_DrawDataPadForceSelect(void);
/*
================
@@ -101,12 +83,13 @@ This is the only way control passes into the cgame module.
This must be the very first function compiled into the .q3vm file
================
*/
-extern "C" Q_EXPORT intptr_t QDECL vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) {
- centity_t *cent;
+extern "C" Q_EXPORT intptr_t QDECL vmMain(int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6,
+ intptr_t arg7) {
+ centity_t *cent;
- switch ( command ) {
+ switch (command) {
case CG_INIT:
- CG_Init( arg0 );
+ CG_Init(arg0);
return 0;
case CG_SHUTDOWN:
CG_Shutdown();
@@ -114,17 +97,17 @@ extern "C" Q_EXPORT intptr_t QDECL vmMain( int command, intptr_t arg0, intptr_t
case CG_CONSOLE_COMMAND:
return CG_ConsoleCommand();
case CG_DRAW_ACTIVE_FRAME:
- CG_DrawActiveFrame( arg0, (stereoFrame_t) arg1 );
+ CG_DrawActiveFrame(arg0, (stereoFrame_t)arg1);
return 0;
case CG_CROSSHAIR_PLAYER:
return CG_CrosshairPlayer();
case CG_CAMERA_POS:
- return CG_GetCameraPos( (float*)arg0);
+ return CG_GetCameraPos((float *)arg0);
case CG_CAMERA_ANG:
- return CG_GetCameraAng( (float*)arg0);
-/*
-Ghoul2 Insert Start
-*/
+ return CG_GetCameraAng((float *)arg0);
+ /*
+ Ghoul2 Insert Start
+ */
case CG_RESIZE_G2:
CG_ResizeG2((CGhoul2Info_v *)arg0, arg1);
return 0;
@@ -141,42 +124,37 @@ Ghoul2 Insert Start
CG_ResizeG2TempBone((mdxaBone_v *)arg0, arg1);
return 0;
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
case CG_DRAW_DATAPAD_HUD:
- if (cg.snap)
- {
+ if (cg.snap) {
cent = &cg_entities[cg.snap->ps.clientNum];
CG_DrawDataPadHUD(cent);
}
return 0;
case CG_DRAW_DATAPAD_OBJECTIVES:
- if (cg.snap)
- {
+ if (cg.snap) {
cent = &cg_entities[cg.snap->ps.clientNum];
CG_DrawDataPadObjectives(cent);
}
return 0;
case CG_DRAW_DATAPAD_WEAPONS:
- if (cg.snap)
- {
+ if (cg.snap) {
CG_DrawDataPadIconBackground(ICON_WEAPONS);
CG_DrawDataPadWeaponSelect();
}
return 0;
case CG_DRAW_DATAPAD_INVENTORY:
- if (cg.snap)
- {
+ if (cg.snap) {
CG_DrawDataPadIconBackground(ICON_INVENTORY);
CG_DrawDataPadInventorySelect();
}
return 0;
case CG_DRAW_DATAPAD_FORCEPOWERS:
- if (cg.snap)
- {
+ if (cg.snap) {
CG_DrawDataPadIconBackground(ICON_FORCE);
CG_DrawDataPadForceSelect();
}
@@ -189,291 +167,276 @@ Ghoul2 Insert End
Ghoul2 Insert Start
*/
-void CG_ResizeG2Bolt(boltInfo_v *bolt, int newCount)
-{
- bolt->resize(newCount);
-}
+void CG_ResizeG2Bolt(boltInfo_v *bolt, int newCount) { bolt->resize(newCount); }
-void CG_ResizeG2Surface(surfaceInfo_v *surface, int newCount)
-{
- surface->resize(newCount);
-}
+void CG_ResizeG2Surface(surfaceInfo_v *surface, int newCount) { surface->resize(newCount); }
-void CG_ResizeG2Bone(boneInfo_v *bone, int newCount)
-{
- bone->resize(newCount);
-}
+void CG_ResizeG2Bone(boneInfo_v *bone, int newCount) { bone->resize(newCount); }
-void CG_ResizeG2(CGhoul2Info_v *ghoul2, int newCount)
-{
- ghoul2->resize(newCount);
-}
+void CG_ResizeG2(CGhoul2Info_v *ghoul2, int newCount) { ghoul2->resize(newCount); }
-void CG_ResizeG2TempBone(mdxaBone_v *tempBone, int newCount)
-{
- tempBone->resize(newCount);
-}
+void CG_ResizeG2TempBone(mdxaBone_v *tempBone, int newCount) { tempBone->resize(newCount); }
/*
Ghoul2 Insert End
*/
-cg_t cg;
-cgs_t cgs;
-centity_t cg_entities[MAX_GENTITIES];
+cg_t cg;
+cgs_t cgs;
+centity_t cg_entities[MAX_GENTITIES];
-centity_t *cg_permanents[MAX_GENTITIES];
-int cg_numpermanents = 0;
+centity_t *cg_permanents[MAX_GENTITIES];
+int cg_numpermanents = 0;
-weaponInfo_t cg_weapons[MAX_WEAPONS];
-itemInfo_t cg_items[MAX_ITEMS];
+weaponInfo_t cg_weapons[MAX_WEAPONS];
+itemInfo_t cg_items[MAX_ITEMS];
typedef struct {
- qboolean registered; // Has the player picked it up
- qboolean active; // Is it the chosen inventory item
- int count; // Count of items.
- char description[128];
+ qboolean registered; // Has the player picked it up
+ qboolean active; // Is it the chosen inventory item
+ int count; // Count of items.
+ char description[128];
} inventoryInfo_t;
-inventoryInfo_t cg_inventory[INV_MAX];
-
-vmCvar_t cg_runpitch;
-vmCvar_t cg_runroll;
-vmCvar_t cg_bobup;
-vmCvar_t cg_bobpitch;
-vmCvar_t cg_bobroll;
-vmCvar_t cg_shadows;
-vmCvar_t cg_renderToTextureFX;
-vmCvar_t cg_shadowCullDistance;
-vmCvar_t cg_footsteps;
-vmCvar_t cg_saberEntMarks;
-vmCvar_t cg_paused;
-vmCvar_t cg_drawTimer;
-vmCvar_t cg_drawFPS;
-vmCvar_t cg_drawSnapshot;
-vmCvar_t cg_drawAmmoWarning;
-vmCvar_t cg_drawCrosshair;
-vmCvar_t cg_crosshairIdentifyTarget;
-vmCvar_t cg_dynamicCrosshair;
-vmCvar_t cg_crosshairForceHint;
-vmCvar_t cg_crosshairX;
-vmCvar_t cg_crosshairY;
-vmCvar_t cg_crosshairSize;
-vmCvar_t cg_draw2D;
-vmCvar_t cg_drawStatus;
-vmCvar_t cg_drawHUD;
-vmCvar_t cg_debugAnim;
+inventoryInfo_t cg_inventory[INV_MAX];
+
+vmCvar_t cg_runpitch;
+vmCvar_t cg_runroll;
+vmCvar_t cg_bobup;
+vmCvar_t cg_bobpitch;
+vmCvar_t cg_bobroll;
+vmCvar_t cg_shadows;
+vmCvar_t cg_renderToTextureFX;
+vmCvar_t cg_shadowCullDistance;
+vmCvar_t cg_footsteps;
+vmCvar_t cg_saberEntMarks;
+vmCvar_t cg_paused;
+vmCvar_t cg_drawTimer;
+vmCvar_t cg_drawFPS;
+vmCvar_t cg_drawSnapshot;
+vmCvar_t cg_drawAmmoWarning;
+vmCvar_t cg_drawCrosshair;
+vmCvar_t cg_crosshairIdentifyTarget;
+vmCvar_t cg_dynamicCrosshair;
+vmCvar_t cg_crosshairForceHint;
+vmCvar_t cg_crosshairX;
+vmCvar_t cg_crosshairY;
+vmCvar_t cg_crosshairSize;
+vmCvar_t cg_draw2D;
+vmCvar_t cg_drawStatus;
+vmCvar_t cg_drawHUD;
+vmCvar_t cg_debugAnim;
#ifndef FINAL_BUILD
-vmCvar_t cg_debugAnimTarget;
-vmCvar_t cg_gun_frame;
+vmCvar_t cg_debugAnimTarget;
+vmCvar_t cg_gun_frame;
#endif
-vmCvar_t cg_gun_x;
-vmCvar_t cg_gun_y;
-vmCvar_t cg_gun_z;
-vmCvar_t cg_debugSaber;
-vmCvar_t cg_debugEvents;
-vmCvar_t cg_errorDecay;
-vmCvar_t cg_addMarks;
-vmCvar_t cg_drawGun;
-vmCvar_t cg_autoswitch;
-vmCvar_t cg_simpleItems;
-vmCvar_t cg_fov;
-vmCvar_t cg_fovAspectAdjust;
-vmCvar_t cg_endcredits;
-vmCvar_t cg_updatedDataPadForcePower1;
-vmCvar_t cg_updatedDataPadForcePower2;
-vmCvar_t cg_updatedDataPadForcePower3;
-vmCvar_t cg_updatedDataPadObjective;
-vmCvar_t cg_drawBreath;
-vmCvar_t cg_roffdebug;
+vmCvar_t cg_gun_x;
+vmCvar_t cg_gun_y;
+vmCvar_t cg_gun_z;
+vmCvar_t cg_debugSaber;
+vmCvar_t cg_debugEvents;
+vmCvar_t cg_errorDecay;
+vmCvar_t cg_addMarks;
+vmCvar_t cg_drawGun;
+vmCvar_t cg_autoswitch;
+vmCvar_t cg_simpleItems;
+vmCvar_t cg_fov;
+vmCvar_t cg_fovAspectAdjust;
+vmCvar_t cg_endcredits;
+vmCvar_t cg_updatedDataPadForcePower1;
+vmCvar_t cg_updatedDataPadForcePower2;
+vmCvar_t cg_updatedDataPadForcePower3;
+vmCvar_t cg_updatedDataPadObjective;
+vmCvar_t cg_drawBreath;
+vmCvar_t cg_roffdebug;
#ifndef FINAL_BUILD
-vmCvar_t cg_roffval1;
-vmCvar_t cg_roffval2;
-vmCvar_t cg_roffval3;
-vmCvar_t cg_roffval4;
+vmCvar_t cg_roffval1;
+vmCvar_t cg_roffval2;
+vmCvar_t cg_roffval3;
+vmCvar_t cg_roffval4;
#endif
-vmCvar_t cg_thirdPerson;
-vmCvar_t cg_thirdPersonRange;
-vmCvar_t cg_thirdPersonMaxRange;
-vmCvar_t cg_thirdPersonAngle;
-vmCvar_t cg_thirdPersonPitchOffset;
-vmCvar_t cg_thirdPersonVertOffset;
-vmCvar_t cg_thirdPersonCameraDamp;
-vmCvar_t cg_thirdPersonTargetDamp;
-vmCvar_t cg_gunAutoFirst;
-
-vmCvar_t cg_thirdPersonAlpha;
-vmCvar_t cg_thirdPersonAutoAlpha;
-vmCvar_t cg_thirdPersonHorzOffset;
-
-vmCvar_t cg_stereoSeparation;
-vmCvar_t cg_developer;
-vmCvar_t cg_timescale;
-vmCvar_t cg_skippingcin;
-
-vmCvar_t cg_pano;
-vmCvar_t cg_panoNumShots;
-
-vmCvar_t fx_freeze;
-vmCvar_t fx_debug;
-
-vmCvar_t cg_missionInfoFlashTime;
-vmCvar_t cg_hudFiles;
-
-vmCvar_t cg_neverHearThatDumbBeepingSoundAgain;
-
-vmCvar_t cg_VariantSoundCap; // 0 = no capping, else cap to (n) max (typically just 1, but allows more)
-vmCvar_t cg_turnAnims;
-vmCvar_t cg_motionBoneComp;
-vmCvar_t cg_distributeMBCorrection;
-vmCvar_t cg_reliableAnimEvents;
-
-vmCvar_t cg_smoothPlayerPos;
-vmCvar_t cg_smoothPlayerPlat;
-vmCvar_t cg_smoothPlayerPlatAccel;
-vmCvar_t cg_g2Marks;
-vmCvar_t fx_expensivePhysics;
-vmCvar_t cg_debugHealthBars;
-
-vmCvar_t cg_smoothCamera;
-vmCvar_t cg_speedTrail;
-vmCvar_t cg_fovViewmodel;
-vmCvar_t cg_fovViewmodelAdjust;
-
-vmCvar_t cg_scaleVehicleSensitivity;
+vmCvar_t cg_thirdPerson;
+vmCvar_t cg_thirdPersonRange;
+vmCvar_t cg_thirdPersonMaxRange;
+vmCvar_t cg_thirdPersonAngle;
+vmCvar_t cg_thirdPersonPitchOffset;
+vmCvar_t cg_thirdPersonVertOffset;
+vmCvar_t cg_thirdPersonCameraDamp;
+vmCvar_t cg_thirdPersonTargetDamp;
+vmCvar_t cg_gunAutoFirst;
+
+vmCvar_t cg_thirdPersonAlpha;
+vmCvar_t cg_thirdPersonAutoAlpha;
+vmCvar_t cg_thirdPersonHorzOffset;
+
+vmCvar_t cg_stereoSeparation;
+vmCvar_t cg_developer;
+vmCvar_t cg_timescale;
+vmCvar_t cg_skippingcin;
+
+vmCvar_t cg_pano;
+vmCvar_t cg_panoNumShots;
+
+vmCvar_t fx_freeze;
+vmCvar_t fx_debug;
+
+vmCvar_t cg_missionInfoFlashTime;
+vmCvar_t cg_hudFiles;
+
+vmCvar_t cg_neverHearThatDumbBeepingSoundAgain;
+
+vmCvar_t cg_VariantSoundCap; // 0 = no capping, else cap to (n) max (typically just 1, but allows more)
+vmCvar_t cg_turnAnims;
+vmCvar_t cg_motionBoneComp;
+vmCvar_t cg_distributeMBCorrection;
+vmCvar_t cg_reliableAnimEvents;
+
+vmCvar_t cg_smoothPlayerPos;
+vmCvar_t cg_smoothPlayerPlat;
+vmCvar_t cg_smoothPlayerPlatAccel;
+vmCvar_t cg_g2Marks;
+vmCvar_t fx_expensivePhysics;
+vmCvar_t cg_debugHealthBars;
+
+vmCvar_t cg_smoothCamera;
+vmCvar_t cg_speedTrail;
+vmCvar_t cg_fovViewmodel;
+vmCvar_t cg_fovViewmodelAdjust;
+
+vmCvar_t cg_scaleVehicleSensitivity;
typedef struct {
- vmCvar_t *vmCvar;
- const char *cvarName;
- const char *defaultString;
- int cvarFlags;
+ vmCvar_t *vmCvar;
+ const char *cvarName;
+ const char *defaultString;
+ int cvarFlags;
} cvarTable_t;
static cvarTable_t cvarTable[] = {
- { &cg_autoswitch, "cg_autoswitch", "1", CVAR_ARCHIVE },
- { &cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE },
- { &cg_fov, "cg_fov", "80", CVAR_ARCHIVE },
- { &cg_fovAspectAdjust, "cg_fovAspectAdjust", "0", CVAR_ARCHIVE },
- { &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE },
- { &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
- { &cg_renderToTextureFX, "cg_renderToTextureFX", "1", CVAR_ARCHIVE },
- { &cg_shadowCullDistance, "r_shadowRange", "1000", CVAR_ARCHIVE },
- { &cg_footsteps, "cg_footsteps", "3", CVAR_ARCHIVE },//1 = sounds, 2 = sounds & effects, 3 = sounds, effects & marks, 4 = always
- { &cg_saberEntMarks, "cg_saberEntMarks", "1", CVAR_ARCHIVE },
-
- { &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
- { &cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE },
- { &cg_drawHUD, "cg_drawHUD", "1", 0 },
- { &cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE },
- { &cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE },
- { &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE },
- { &cg_drawAmmoWarning, "cg_drawAmmoWarning", "1", CVAR_ARCHIVE },
- { &cg_drawCrosshair, "cg_drawCrosshair", "1", CVAR_ARCHIVE },
- { &cg_dynamicCrosshair, "cg_dynamicCrosshair", "1", CVAR_ARCHIVE },
+ {&cg_autoswitch, "cg_autoswitch", "1", CVAR_ARCHIVE},
+ {&cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE},
+ {&cg_fov, "cg_fov", "80", CVAR_ARCHIVE},
+ {&cg_fovAspectAdjust, "cg_fovAspectAdjust", "0", CVAR_ARCHIVE},
+ {&cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE},
+ {&cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE},
+ {&cg_renderToTextureFX, "cg_renderToTextureFX", "1", CVAR_ARCHIVE},
+ {&cg_shadowCullDistance, "r_shadowRange", "1000", CVAR_ARCHIVE},
+ {&cg_footsteps, "cg_footsteps", "3", CVAR_ARCHIVE}, // 1 = sounds, 2 = sounds & effects, 3 = sounds, effects & marks, 4 = always
+ {&cg_saberEntMarks, "cg_saberEntMarks", "1", CVAR_ARCHIVE},
+
+ {&cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE},
+ {&cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE},
+ {&cg_drawHUD, "cg_drawHUD", "1", 0},
+ {&cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE},
+ {&cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE},
+ {&cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE},
+ {&cg_drawAmmoWarning, "cg_drawAmmoWarning", "1", CVAR_ARCHIVE},
+ {&cg_drawCrosshair, "cg_drawCrosshair", "1", CVAR_ARCHIVE},
+ {&cg_dynamicCrosshair, "cg_dynamicCrosshair", "1", CVAR_ARCHIVE},
// NOTE : I also create this in UI_Init()
- { &cg_crosshairIdentifyTarget, "cg_crosshairIdentifyTarget", "1", CVAR_ARCHIVE },
- { &cg_crosshairForceHint, "cg_crosshairForceHint", "1", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART },
- { &cg_endcredits, "cg_endcredits", "0", 0},
- { &cg_updatedDataPadForcePower1, "cg_updatedDataPadForcePower1", "0", 0},
- { &cg_updatedDataPadForcePower2, "cg_updatedDataPadForcePower2", "0", 0},
- { &cg_updatedDataPadForcePower3, "cg_updatedDataPadForcePower3", "0", 0},
- { &cg_updatedDataPadObjective, "cg_updatedDataPadObjective", "0", 0},
-
- { &cg_crosshairSize, "cg_crosshairSize", "24", CVAR_ARCHIVE },
- { &cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE },
- { &cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE },
- { &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE },
+ {&cg_crosshairIdentifyTarget, "cg_crosshairIdentifyTarget", "1", CVAR_ARCHIVE},
+ {&cg_crosshairForceHint, "cg_crosshairForceHint", "1", CVAR_ARCHIVE | CVAR_SAVEGAME | CVAR_NORESTART},
+ {&cg_endcredits, "cg_endcredits", "0", 0},
+ {&cg_updatedDataPadForcePower1, "cg_updatedDataPadForcePower1", "0", 0},
+ {&cg_updatedDataPadForcePower2, "cg_updatedDataPadForcePower2", "0", 0},
+ {&cg_updatedDataPadForcePower3, "cg_updatedDataPadForcePower3", "0", 0},
+ {&cg_updatedDataPadObjective, "cg_updatedDataPadObjective", "0", 0},
+
+ {&cg_crosshairSize, "cg_crosshairSize", "24", CVAR_ARCHIVE},
+ {&cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE},
+ {&cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE},
+ {&cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE},
// NOTE : I also create this in UI_Init()
- { &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE },
+ {&cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE},
// NOTE : I also create these weapon sway cvars in UI_Init()
- { &cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE},
- { &cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE },
- { &cg_bobup , "cg_bobup", "0.005", CVAR_ARCHIVE },
- { &cg_bobpitch, "cg_bobpitch", "0.002", CVAR_ARCHIVE },
- { &cg_bobroll, "cg_bobroll", "0.002", CVAR_ARCHIVE },
+ {&cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE},
+ {&cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE},
+ {&cg_bobup, "cg_bobup", "0.005", CVAR_ARCHIVE},
+ {&cg_bobpitch, "cg_bobpitch", "0.002", CVAR_ARCHIVE},
+ {&cg_bobroll, "cg_bobroll", "0.002", CVAR_ARCHIVE},
- { &cg_debugAnim, "cg_debuganim", "0", CVAR_CHEAT },
+ {&cg_debugAnim, "cg_debuganim", "0", CVAR_CHEAT},
#ifndef FINAL_BUILD
- { &cg_gun_frame, "gun_frame", "0", CVAR_CHEAT },
- { &cg_debugAnimTarget, "cg_debugAnimTarget", "0", CVAR_CHEAT },
+ {&cg_gun_frame, "gun_frame", "0", CVAR_CHEAT},
+ {&cg_debugAnimTarget, "cg_debugAnimTarget", "0", CVAR_CHEAT},
#endif
- { &cg_gun_x, "cg_gunX", "0", CVAR_ARCHIVE },
- { &cg_gun_y, "cg_gunY", "0", CVAR_ARCHIVE },
- { &cg_gun_z, "cg_gunZ", "0", CVAR_ARCHIVE },
- { &cg_debugSaber, "cg_debugsaber", "0", CVAR_CHEAT },
- { &cg_debugEvents, "cg_debugevents", "0", CVAR_CHEAT },
- { &cg_errorDecay, "cg_errordecay", "100", 0 },
-
- { &cg_drawBreath, "cg_drawBreath", "0", CVAR_ARCHIVE }, // Added 11/07/02
- { &cg_roffdebug, "cg_roffdebug", "0" },
+ {&cg_gun_x, "cg_gunX", "0", CVAR_ARCHIVE},
+ {&cg_gun_y, "cg_gunY", "0", CVAR_ARCHIVE},
+ {&cg_gun_z, "cg_gunZ", "0", CVAR_ARCHIVE},
+ {&cg_debugSaber, "cg_debugsaber", "0", CVAR_CHEAT},
+ {&cg_debugEvents, "cg_debugevents", "0", CVAR_CHEAT},
+ {&cg_errorDecay, "cg_errordecay", "100", 0},
+
+ {&cg_drawBreath, "cg_drawBreath", "0", CVAR_ARCHIVE}, // Added 11/07/02
+ {&cg_roffdebug, "cg_roffdebug", "0"},
#ifndef FINAL_BUILD
- { &cg_roffval1, "cg_roffval1", "0" },
- { &cg_roffval2, "cg_roffval2", "0" },
- { &cg_roffval3, "cg_roffval3", "0" },
- { &cg_roffval4, "cg_roffval4", "0" },
+ {&cg_roffval1, "cg_roffval1", "0"},
+ {&cg_roffval2, "cg_roffval2", "0"},
+ {&cg_roffval3, "cg_roffval3", "0"},
+ {&cg_roffval4, "cg_roffval4", "0"},
#endif
- { &cg_thirdPerson, "cg_thirdPerson", "1", CVAR_SAVEGAME },
- { &cg_thirdPersonRange, "cg_thirdPersonRange", "80", CVAR_ARCHIVE },
- { &cg_thirdPersonMaxRange, "cg_thirdPersonMaxRange", "150", 0 },
- { &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", 0 },
- { &cg_thirdPersonPitchOffset, "cg_thirdPersonPitchOffset", "0", 0 },
- { &cg_thirdPersonVertOffset, "cg_thirdPersonVertOffset", "16", 0},
- { &cg_thirdPersonCameraDamp, "cg_thirdPersonCameraDamp", "0.3", 0},
- { &cg_thirdPersonTargetDamp, "cg_thirdPersonTargetDamp", "0.5", 0},
-
- { &cg_thirdPersonHorzOffset, "cg_thirdPersonHorzOffset", "0", 0},
- { &cg_thirdPersonAlpha, "cg_thirdPersonAlpha", "1.0", CVAR_ARCHIVE },
- { &cg_thirdPersonAutoAlpha, "cg_thirdPersonAutoAlpha", "0", 0 },
+ {&cg_thirdPerson, "cg_thirdPerson", "1", CVAR_SAVEGAME},
+ {&cg_thirdPersonRange, "cg_thirdPersonRange", "80", CVAR_ARCHIVE},
+ {&cg_thirdPersonMaxRange, "cg_thirdPersonMaxRange", "150", 0},
+ {&cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", 0},
+ {&cg_thirdPersonPitchOffset, "cg_thirdPersonPitchOffset", "0", 0},
+ {&cg_thirdPersonVertOffset, "cg_thirdPersonVertOffset", "16", 0},
+ {&cg_thirdPersonCameraDamp, "cg_thirdPersonCameraDamp", "0.3", 0},
+ {&cg_thirdPersonTargetDamp, "cg_thirdPersonTargetDamp", "0.5", 0},
+
+ {&cg_thirdPersonHorzOffset, "cg_thirdPersonHorzOffset", "0", 0},
+ {&cg_thirdPersonAlpha, "cg_thirdPersonAlpha", "1.0", CVAR_ARCHIVE},
+ {&cg_thirdPersonAutoAlpha, "cg_thirdPersonAutoAlpha", "0", 0},
// NOTE: also declare this in UI_Init
- { &cg_gunAutoFirst, "cg_gunAutoFirst", "1", CVAR_ARCHIVE },
+ {&cg_gunAutoFirst, "cg_gunAutoFirst", "1", CVAR_ARCHIVE},
- { &cg_pano, "pano", "0", 0 },
- { &cg_panoNumShots, "panoNumShots", "10", 0 },
+ {&cg_pano, "pano", "0", 0},
+ {&cg_panoNumShots, "panoNumShots", "10", 0},
- { &fx_freeze, "fx_freeze", "0", 0 },
- { &fx_debug, "fx_debug", "0", 0 },
+ {&fx_freeze, "fx_freeze", "0", 0},
+ {&fx_debug, "fx_debug", "0", 0},
// the following variables are created in other parts of the system,
// but we also reference them here
- { &cg_paused, "cl_paused", "0", CVAR_ROM },
- { &cg_developer, "developer", "", 0 },
- { &cg_timescale, "timescale", "1", 0 },
- { &cg_skippingcin, "skippingCinematic", "0", CVAR_ROM},
- { &cg_missionInfoFlashTime, "cg_missionInfoFlashTime", "10000", 0 },
- { &cg_hudFiles, "cg_hudFiles", "ui/jahud.txt", CVAR_ARCHIVE},
-
- { &cg_VariantSoundCap, "cg_VariantSoundCap", "0", 0 },
- { &cg_turnAnims, "cg_turnAnims", "0", 0 },
- { &cg_motionBoneComp, "cg_motionBoneComp", "2", 0 },
- { &cg_distributeMBCorrection, "cg_distributeMBCorrection", "1", 0 },
- { &cg_reliableAnimEvents, "cg_reliableAnimEvents", "1", CVAR_ARCHIVE },
- { &cg_smoothPlayerPos, "cg_smoothPlayerPos", "0.5", 0},
- { &cg_smoothPlayerPlat, "cg_smoothPlayerPlat", "0.75", 0},
- { &cg_smoothPlayerPlatAccel, "cg_smoothPlayerPlatAccel", "3.25", 0},
- { &cg_g2Marks, "cg_g2Marks", "1", CVAR_ARCHIVE },
- { &fx_expensivePhysics, "fx_expensivePhysics", "1", CVAR_ARCHIVE },
- { &cg_debugHealthBars, "cg_debugHealthBars", "0", CVAR_CHEAT },
-
- { &cg_smoothCamera, "cg_smoothCamera", "1", CVAR_ARCHIVE },
- { &cg_speedTrail, "cg_speedTrail", "1", CVAR_ARCHIVE },
- { &cg_fovViewmodel, "cg_fovViewmodel", "0", CVAR_ARCHIVE },
- { &cg_fovViewmodelAdjust, "cg_fovViewmodelAdjust", "1", CVAR_ARCHIVE },
-
- { &cg_scaleVehicleSensitivity, "cg_scaleVehicleSensitivity", "1", CVAR_ARCHIVE },
+ {&cg_paused, "cl_paused", "0", CVAR_ROM},
+ {&cg_developer, "developer", "", 0},
+ {&cg_timescale, "timescale", "1", 0},
+ {&cg_skippingcin, "skippingCinematic", "0", CVAR_ROM},
+ {&cg_missionInfoFlashTime, "cg_missionInfoFlashTime", "10000", 0},
+ {&cg_hudFiles, "cg_hudFiles", "ui/jahud.txt", CVAR_ARCHIVE},
+
+ {&cg_VariantSoundCap, "cg_VariantSoundCap", "0", 0},
+ {&cg_turnAnims, "cg_turnAnims", "0", 0},
+ {&cg_motionBoneComp, "cg_motionBoneComp", "2", 0},
+ {&cg_distributeMBCorrection, "cg_distributeMBCorrection", "1", 0},
+ {&cg_reliableAnimEvents, "cg_reliableAnimEvents", "1", CVAR_ARCHIVE},
+ {&cg_smoothPlayerPos, "cg_smoothPlayerPos", "0.5", 0},
+ {&cg_smoothPlayerPlat, "cg_smoothPlayerPlat", "0.75", 0},
+ {&cg_smoothPlayerPlatAccel, "cg_smoothPlayerPlatAccel", "3.25", 0},
+ {&cg_g2Marks, "cg_g2Marks", "1", CVAR_ARCHIVE},
+ {&fx_expensivePhysics, "fx_expensivePhysics", "1", CVAR_ARCHIVE},
+ {&cg_debugHealthBars, "cg_debugHealthBars", "0", CVAR_CHEAT},
+
+ {&cg_smoothCamera, "cg_smoothCamera", "1", CVAR_ARCHIVE},
+ {&cg_speedTrail, "cg_speedTrail", "1", CVAR_ARCHIVE},
+ {&cg_fovViewmodel, "cg_fovViewmodel", "0", CVAR_ARCHIVE},
+ {&cg_fovViewmodelAdjust, "cg_fovViewmodelAdjust", "1", CVAR_ARCHIVE},
+
+ {&cg_scaleVehicleSensitivity, "cg_scaleVehicleSensitivity", "1", CVAR_ARCHIVE},
};
-static const size_t cvarTableSize = ARRAY_LEN( cvarTable );
+static const size_t cvarTableSize = ARRAY_LEN(cvarTable);
/*
=================
CG_RegisterCvars
=================
*/
-void CG_RegisterCvars( void ) {
- size_t i;
- cvarTable_t *cv;
+void CG_RegisterCvars(void) {
+ size_t i;
+ cvarTable_t *cv;
- for ( i=0, cv=cvarTable; ivmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
+ for (i = 0, cv = cvarTable; i < cvarTableSize; i++, cv++) {
+ cgi_Cvar_Register(cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags);
}
}
@@ -482,43 +445,38 @@ void CG_RegisterCvars( void ) {
CG_UpdateCvars
=================
*/
-void CG_UpdateCvars( void ) {
- size_t i;
- cvarTable_t *cv;
+void CG_UpdateCvars(void) {
+ size_t i;
+ cvarTable_t *cv;
- for ( i=0, cv=cvarTable; ivmCvar ) {
- cgi_Cvar_Update( cv->vmCvar );
+ for (i = 0, cv = cvarTable; i < cvarTableSize; i++, cv++) {
+ if (cv->vmCvar) {
+ cgi_Cvar_Update(cv->vmCvar);
}
}
}
-int CG_CrosshairPlayer( void )
-{
- if ( cg.time > ( cg.crosshairClientTime + 1000 ) )
- {
+int CG_CrosshairPlayer(void) {
+ if (cg.time > (cg.crosshairClientTime + 1000)) {
return -1;
}
return cg.crosshairClientNum;
}
-int CG_GetCameraPos( vec3_t camerapos ) {
- if ( in_camera) {
+int CG_GetCameraPos(vec3_t camerapos) {
+ if (in_camera) {
VectorCopy(client_camera.origin, camerapos);
return 1;
- }
- else if ( cg_entities[0].gent && cg_entities[0].gent->client && cg_entities[0].gent->client->ps.viewEntity > 0 && cg_entities[0].gent->client->ps.viewEntity < ENTITYNUM_WORLD )
- //else if ( cg.snap && cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {//in an entity camera view
- if ( g_entities[cg_entities[0].gent->client->ps.viewEntity].client && cg.renderingThirdPerson )
- {
- VectorCopy( g_entities[cg_entities[0].gent->client->ps.viewEntity].client->renderInfo.eyePoint, camerapos );
- }
- else
- {
- VectorCopy( g_entities[cg_entities[0].gent->client->ps.viewEntity].currentOrigin, camerapos );
- }
- //VectorCopy( cg_entities[cg_entities[0].gent->client->ps.viewEntity].lerpOrigin, camerapos );
+ } else if (cg_entities[0].gent && cg_entities[0].gent->client && cg_entities[0].gent->client->ps.viewEntity > 0 &&
+ cg_entities[0].gent->client->ps.viewEntity < ENTITYNUM_WORLD)
+ // else if ( cg.snap && cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
+ { // in an entity camera view
+ if (g_entities[cg_entities[0].gent->client->ps.viewEntity].client && cg.renderingThirdPerson) {
+ VectorCopy(g_entities[cg_entities[0].gent->client->ps.viewEntity].client->renderInfo.eyePoint, camerapos);
+ } else {
+ VectorCopy(g_entities[cg_entities[0].gent->client->ps.viewEntity].currentOrigin, camerapos);
+ }
+ // VectorCopy( cg_entities[cg_entities[0].gent->client->ps.viewEntity].lerpOrigin, camerapos );
/*
if ( g_entities[cg.snap->ps.viewEntity].client && cg.renderingThirdPerson )
{
@@ -530,55 +488,48 @@ int CG_GetCameraPos( vec3_t camerapos ) {
}
*/
return 1;
- }
- else if ( cg.renderingThirdPerson )
- {//in third person
- //FIXME: what about hacks that render in third person regardless of this value?
- VectorCopy( cg.refdef.vieworg, camerapos );
+ } else if (cg.renderingThirdPerson) { // in third person
+ // FIXME: what about hacks that render in third person regardless of this value?
+ VectorCopy(cg.refdef.vieworg, camerapos);
return 1;
- }
- else if (cg.snap && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) )//implied: !cg.renderingThirdPerson
- {//first person saber hack
- VectorCopy( cg.refdef.vieworg, camerapos );
+ } else if (cg.snap && (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)) // implied: !cg.renderingThirdPerson
+ { // first person saber hack
+ VectorCopy(cg.refdef.vieworg, camerapos);
return 1;
}
return 0;
}
-int CG_GetCameraAng( vec3_t cameraang )
-{
- if ( in_camera)
- {
+int CG_GetCameraAng(vec3_t cameraang) {
+ if (in_camera) {
VectorCopy(client_camera.angles, cameraang);
return 1;
- }
- else
- {
- VectorCopy( cg.refdefViewAngles, cameraang );
+ } else {
+ VectorCopy(cg.refdefViewAngles, cameraang);
return 1;
}
}
-void CG_Printf( const char *msg, ... ) {
- va_list argptr;
- char text[1024];
+void CG_Printf(const char *msg, ...) {
+ va_list argptr;
+ char text[1024];
- va_start (argptr, msg);
- Q_vsnprintf (text, sizeof(text), msg, argptr);
- va_end (argptr);
+ va_start(argptr, msg);
+ Q_vsnprintf(text, sizeof(text), msg, argptr);
+ va_end(argptr);
- cgi_Printf( text );
+ cgi_Printf(text);
}
-NORETURN void CG_Error( const char *msg, ... ) {
- va_list argptr;
- char text[1024];
+NORETURN void CG_Error(const char *msg, ...) {
+ va_list argptr;
+ char text[1024];
- va_start (argptr, msg);
- Q_vsnprintf (text, sizeof(text), msg, argptr);
- va_end (argptr);
+ va_start(argptr, msg);
+ Q_vsnprintf(text, sizeof(text), msg, argptr);
+ va_end(argptr);
- cgi_Error( text );
+ cgi_Error(text);
}
/*
@@ -586,10 +537,10 @@ NORETURN void CG_Error( const char *msg, ... ) {
CG_Argv
================
*/
-const char *CG_Argv( int arg ) {
- static char buffer[MAX_STRING_CHARS];
+const char *CG_Argv(int arg) {
+ static char buffer[MAX_STRING_CHARS];
- cgi_Argv( arg, buffer, sizeof( buffer ) );
+ cgi_Argv(arg, buffer, sizeof(buffer));
return buffer;
}
@@ -603,17 +554,16 @@ CG_RegisterItemSounds
The server says this item is used on this level
=================
*/
-void CG_RegisterItemSounds( int itemNum ) {
- gitem_t *item;
- char data[MAX_QPATH];
- const char *s, *start;
- int len;
+void CG_RegisterItemSounds(int itemNum) {
+ gitem_t *item;
+ char data[MAX_QPATH];
+ const char *s, *start;
+ int len;
- item = &bg_itemlist[ itemNum ];
+ item = &bg_itemlist[itemNum];
- if (item->pickup_sound)
- {
- cgi_S_RegisterSound( item->pickup_sound );
+ if (item->pickup_sound) {
+ cgi_S_RegisterSound(item->pickup_sound);
}
// parse the space seperated precache string for other media
@@ -627,20 +577,19 @@ void CG_RegisterItemSounds( int itemNum ) {
s++;
}
- len = s-start;
+ len = s - start;
if (len >= MAX_QPATH || len < 5) {
- CG_Error( "PrecacheItem: %s has bad precache string",
- item->classname);
+ CG_Error("PrecacheItem: %s has bad precache string", item->classname);
return;
}
- memcpy (data, start, len);
+ memcpy(data, start, len);
data[len] = 0;
- if ( *s ) {
+ if (*s) {
s++;
}
- if ( !strcmp(data+len-3, "wav" )) {
- cgi_S_RegisterSound( data );
+ if (!strcmp(data + len - 3, "wav")) {
+ cgi_S_RegisterSound(data);
}
}
}
@@ -651,26 +600,22 @@ CG_LoadingString
======================
*/
-void CG_LoadingString( const char *s ) {
- Q_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) );
+void CG_LoadingString(const char *s) {
+ Q_strncpyz(cg.infoScreenText, s, sizeof(cg.infoScreenText));
cgi_UpdateScreen();
}
-static inline void CG_AS_Register(void)
-{
- CG_LoadingString( "ambient sound sets" );
+static inline void CG_AS_Register(void) {
+ CG_LoadingString("ambient sound sets");
assert(as_preCacheMap);
- //Load the ambient sets
+ // Load the ambient sets
- cgi_AS_AddPrecacheEntry( "#clear" ); // ;-)
- //FIXME: Don't ask... I had to get around a really nasty MS error in the templates with this...
- namePrecache_m::iterator pi;
- STL_ITERATE( pi, (*as_preCacheMap) )
- {
- cgi_AS_AddPrecacheEntry( ((*pi).first).c_str() );
- }
+ cgi_AS_AddPrecacheEntry("#clear"); // ;-)
+ // FIXME: Don't ask... I had to get around a really nasty MS error in the templates with this...
+ namePrecache_m::iterator pi;
+ STL_ITERATE(pi, (*as_preCacheMap)) { cgi_AS_AddPrecacheEntry(((*pi).first).c_str()); }
cgi_AS_ParseSets();
}
@@ -682,160 +627,159 @@ CG_RegisterSounds
called during a precache command
=================
*/
-static void CG_RegisterSounds( void ) {
- int i;
- char name[MAX_QPATH];
- const char *soundName;
+static void CG_RegisterSounds(void) {
+ int i;
+ char name[MAX_QPATH];
+ const char *soundName;
CG_AS_Register();
- CG_LoadingString( "general sounds" );
+ CG_LoadingString("general sounds");
- //FIXME: add to cg.media?
- cgi_S_RegisterSound( "sound/player/fallsplat.wav" );
+ // FIXME: add to cg.media?
+ cgi_S_RegisterSound("sound/player/fallsplat.wav");
- cgs.media.selectSound = cgi_S_RegisterSound( "sound/weapons/change.wav" );
- cgs.media.selectSound2 = cgi_S_RegisterSound( "sound/interface/sub_select.wav" );
-// cgs.media.useNothingSound = cgi_S_RegisterSound( "sound/items/use_nothing.wav" );
+ cgs.media.selectSound = cgi_S_RegisterSound("sound/weapons/change.wav");
+ cgs.media.selectSound2 = cgi_S_RegisterSound("sound/interface/sub_select.wav");
+ // cgs.media.useNothingSound = cgi_S_RegisterSound( "sound/items/use_nothing.wav" );
- cgs.media.noAmmoSound = cgi_S_RegisterSound( "sound/weapons/noammo.wav" );
-// cgs.media.talkSound = cgi_S_RegisterSound( "sound/interface/communicator.wav" );
- cgs.media.landSound = cgi_S_RegisterSound( "sound/player/land1.wav");
- cgs.media.rollSound = cgi_S_RegisterSound( "sound/player/roll1.wav");
- theFxScheduler.RegisterEffect( "env/slide_dust" );
+ cgs.media.noAmmoSound = cgi_S_RegisterSound("sound/weapons/noammo.wav");
+ // cgs.media.talkSound = cgi_S_RegisterSound( "sound/interface/communicator.wav" );
+ cgs.media.landSound = cgi_S_RegisterSound("sound/player/land1.wav");
+ cgs.media.rollSound = cgi_S_RegisterSound("sound/player/roll1.wav");
+ theFxScheduler.RegisterEffect("env/slide_dust");
- cgs.media.overchargeFastSound = cgi_S_RegisterSound("sound/weapons/overchargeFast.wav" );
- cgs.media.overchargeSlowSound = cgi_S_RegisterSound("sound/weapons/overchargeSlow.wav" );
- cgs.media.overchargeLoopSound = cgi_S_RegisterSound("sound/weapons/overchargeLoop.wav");
- cgs.media.overchargeEndSound = cgi_S_RegisterSound("sound/weapons/overchargeEnd.wav");
+ cgs.media.overchargeFastSound = cgi_S_RegisterSound("sound/weapons/overchargeFast.wav");
+ cgs.media.overchargeSlowSound = cgi_S_RegisterSound("sound/weapons/overchargeSlow.wav");
+ cgs.media.overchargeLoopSound = cgi_S_RegisterSound("sound/weapons/overchargeLoop.wav");
+ cgs.media.overchargeEndSound = cgi_S_RegisterSound("sound/weapons/overchargeEnd.wav");
- cgs.media.batteryChargeSound = cgi_S_RegisterSound( "sound/interface/pickup_battery.wav" );
+ cgs.media.batteryChargeSound = cgi_S_RegisterSound("sound/interface/pickup_battery.wav");
-// cgs.media.tedTextSound = cgi_S_RegisterSound( "sound/interface/tedtext.wav" );
- cgs.media.messageLitSound = cgi_S_RegisterSound( "sound/interface/update" );
+ // cgs.media.tedTextSound = cgi_S_RegisterSound( "sound/interface/tedtext.wav" );
+ cgs.media.messageLitSound = cgi_S_RegisterSound("sound/interface/update");
- cgs.media.noforceSound = cgi_S_RegisterSound( "sound/weapons/force/noforce" );
+ cgs.media.noforceSound = cgi_S_RegisterSound("sound/weapons/force/noforce");
- cgs.media.watrInSound = cgi_S_RegisterSound ("sound/player/watr_in.wav");
- cgs.media.watrOutSound = cgi_S_RegisterSound ("sound/player/watr_out.wav");
- cgs.media.watrUnSound = cgi_S_RegisterSound ("sound/player/watr_un.wav");
+ cgs.media.watrInSound = cgi_S_RegisterSound("sound/player/watr_in.wav");
+ cgs.media.watrOutSound = cgi_S_RegisterSound("sound/player/watr_out.wav");
+ cgs.media.watrUnSound = cgi_S_RegisterSound("sound/player/watr_un.wav");
- if ( (gi.totalMapContents()&CONTENTS_LAVA) )
- {
- cgs.media.lavaInSound = cgi_S_RegisterSound ("sound/player/inlava.wav");
- cgs.media.lavaOutSound = cgi_S_RegisterSound ("sound/player/watr_out.wav");
- cgs.media.lavaUnSound = cgi_S_RegisterSound ("sound/player/muckexit.wav");
+ if ((gi.totalMapContents() & CONTENTS_LAVA)) {
+ cgs.media.lavaInSound = cgi_S_RegisterSound("sound/player/inlava.wav");
+ cgs.media.lavaOutSound = cgi_S_RegisterSound("sound/player/watr_out.wav");
+ cgs.media.lavaUnSound = cgi_S_RegisterSound("sound/player/muckexit.wav");
}
// Zoom
- cgs.media.zoomStart = cgi_S_RegisterSound( "sound/interface/zoomstart.wav" );
- cgs.media.zoomLoop = cgi_S_RegisterSound( "sound/interface/zoomloop.wav" );
- cgs.media.zoomEnd = cgi_S_RegisterSound( "sound/interface/zoomend.wav" );
-
- cgi_S_RegisterSound( "sound/chars/turret/startup.wav" );
- cgi_S_RegisterSound( "sound/chars/turret/shutdown.wav" );
- cgi_S_RegisterSound( "sound/chars/turret/ping.wav" );
- cgi_S_RegisterSound( "sound/chars/turret/move.wav" );
- cgi_S_RegisterSound( "sound/player/use_sentry" );
- cgi_R_RegisterModel( "models/items/psgun.glm" );
- theFxScheduler.RegisterEffect( "turret/explode" );
- theFxScheduler.RegisterEffect( "sparks/spark_exp_nosnd" );
-
- for (i=0 ; i<4 ; i++) {
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/stone_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_STONEWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/stone_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_STONERUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/metal_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_METALWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/metal_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_METALRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/pipe_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_PIPEWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/pipe_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_PIPERUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/water_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SPLASH][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/water_walk%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_WADE][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/water_wade_0%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SWIM][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/snow_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SNOWWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/snow_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SNOWRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/sand_walk%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SANDWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/sand_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SANDRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/grass_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_GRASSWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/grass_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_GRASSRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/dirt_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_DIRTWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/dirt_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_DIRTRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/mud_walk%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_MUDWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/mud_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_MUDRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/gravel_walk%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_GRAVELWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/gravel_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_GRAVELRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/rug_step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_RUGWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/rug_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_RUGRUN][i] = cgi_S_RegisterSound (name);
-
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/wood_walk%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_WOODWALK][i] = cgi_S_RegisterSound (name);
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/wood_run%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_WOODRUN][i] = cgi_S_RegisterSound (name);
+ cgs.media.zoomStart = cgi_S_RegisterSound("sound/interface/zoomstart.wav");
+ cgs.media.zoomLoop = cgi_S_RegisterSound("sound/interface/zoomloop.wav");
+ cgs.media.zoomEnd = cgi_S_RegisterSound("sound/interface/zoomend.wav");
+
+ cgi_S_RegisterSound("sound/chars/turret/startup.wav");
+ cgi_S_RegisterSound("sound/chars/turret/shutdown.wav");
+ cgi_S_RegisterSound("sound/chars/turret/ping.wav");
+ cgi_S_RegisterSound("sound/chars/turret/move.wav");
+ cgi_S_RegisterSound("sound/player/use_sentry");
+ cgi_R_RegisterModel("models/items/psgun.glm");
+ theFxScheduler.RegisterEffect("turret/explode");
+ theFxScheduler.RegisterEffect("sparks/spark_exp_nosnd");
+
+ for (i = 0; i < 4; i++) {
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/stone_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_STONEWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/stone_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_STONERUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/metal_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_METALWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/metal_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_METALRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/pipe_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_PIPEWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/pipe_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_PIPERUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/water_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_SPLASH][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/water_walk%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_WADE][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/water_wade_0%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_SWIM][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/snow_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_SNOWWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/snow_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_SNOWRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/sand_walk%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_SANDWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/sand_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_SANDRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/grass_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_GRASSWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/grass_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_GRASSRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/dirt_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_DIRTWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/dirt_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_DIRTRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/mud_walk%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_MUDWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/mud_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_MUDRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/gravel_walk%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_GRAVELWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/gravel_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_GRAVELRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/rug_step%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_RUGWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/rug_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_RUGRUN][i] = cgi_S_RegisterSound(name);
+
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/wood_walk%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_WOODWALK][i] = cgi_S_RegisterSound(name);
+ Com_sprintf(name, sizeof(name), "sound/player/footsteps/wood_run%i.wav", i + 1);
+ cgs.media.footsteps[FOOTSTEP_WOODRUN][i] = cgi_S_RegisterSound(name);
}
cg.loadLCARSStage = 1;
- CG_LoadingString( "item sounds" );
+ CG_LoadingString("item sounds");
// only register the items that the server says we need
- char items[MAX_ITEMS+1];
- //Raz: Fixed buffer overflow
+ char items[MAX_ITEMS + 1];
+ // Raz: Fixed buffer overflow
Q_strncpyz(items, CG_ConfigString(CS_ITEMS), sizeof(items));
- for ( i = 1 ; i < bg_numItems ; i++ ) {
- if ( items[ i ] == '1' ) //even with sound pooling, don't clutter it for low end machines
+ for (i = 1; i < bg_numItems; i++) {
+ if (items[i] == '1') // even with sound pooling, don't clutter it for low end machines
{
- CG_RegisterItemSounds( i );
+ CG_RegisterItemSounds(i);
}
}
cg.loadLCARSStage = 2;
- CG_LoadingString( "preregistered sounds" );
+ CG_LoadingString("preregistered sounds");
- for ( i = 1 ; i < MAX_SOUNDS ; i++ ) {
- soundName = CG_ConfigString( CS_SOUNDS+i );
- if ( !soundName[0] ) {
+ for (i = 1; i < MAX_SOUNDS; i++) {
+ soundName = CG_ConfigString(CS_SOUNDS + i);
+ if (!soundName[0]) {
break;
}
- if ( soundName[0] == '*' ) {
- continue; // custom sound
+ if (soundName[0] == '*') {
+ continue; // custom sound
}
- if (!(i&7)) {
- CG_LoadingString( soundName );
+ if (!(i & 7)) {
+ CG_LoadingString(soundName);
}
- cgs.sound_precache[i] = cgi_S_RegisterSound( soundName );
+ cgs.sound_precache[i] = cgi_S_RegisterSound(soundName);
}
}
@@ -852,44 +796,36 @@ CLIENT INFO
CG_RegisterClientSkin
==========================
*/
-qboolean CG_RegisterClientSkin( clientInfo_t *ci,
- const char *headModelName, const char *headSkinName,
- const char *torsoModelName, const char *torsoSkinName,
- const char *legsModelName, const char *legsSkinName)
-{
- char hfilename[MAX_QPATH];
- char tfilename[MAX_QPATH];
- char lfilename[MAX_QPATH];
-
- Com_sprintf( lfilename, sizeof( lfilename ), "models/players/%s/lower_%s.skin", legsModelName, legsSkinName );
- ci->legsSkin = cgi_R_RegisterSkin( lfilename );
-
- if ( !ci->legsSkin )
- {
-// Com_Printf( "Failed to load skin file: %s : %s\n", legsModelName, legsSkinName );
- //return qfalse;
+qboolean CG_RegisterClientSkin(clientInfo_t *ci, const char *headModelName, const char *headSkinName, const char *torsoModelName, const char *torsoSkinName,
+ const char *legsModelName, const char *legsSkinName) {
+ char hfilename[MAX_QPATH];
+ char tfilename[MAX_QPATH];
+ char lfilename[MAX_QPATH];
+
+ Com_sprintf(lfilename, sizeof(lfilename), "models/players/%s/lower_%s.skin", legsModelName, legsSkinName);
+ ci->legsSkin = cgi_R_RegisterSkin(lfilename);
+
+ if (!ci->legsSkin) {
+ // Com_Printf( "Failed to load skin file: %s : %s\n", legsModelName, legsSkinName );
+ // return qfalse;
}
- if(torsoModelName && torsoSkinName && torsoModelName[0] && torsoSkinName[0])
- {
- Com_sprintf( tfilename, sizeof( tfilename ), "models/players/%s/upper_%s.skin", torsoModelName, torsoSkinName );
- ci->torsoSkin = cgi_R_RegisterSkin( tfilename );
+ if (torsoModelName && torsoSkinName && torsoModelName[0] && torsoSkinName[0]) {
+ Com_sprintf(tfilename, sizeof(tfilename), "models/players/%s/upper_%s.skin", torsoModelName, torsoSkinName);
+ ci->torsoSkin = cgi_R_RegisterSkin(tfilename);
- if ( !ci->torsoSkin )
- {
- Com_Printf( "Failed to load skin file: %s : %s\n", torsoModelName, torsoSkinName );
+ if (!ci->torsoSkin) {
+ Com_Printf("Failed to load skin file: %s : %s\n", torsoModelName, torsoSkinName);
return qfalse;
}
}
- if(headModelName && headSkinName && headModelName[0] && headSkinName[0])
- {
- Com_sprintf( hfilename, sizeof( hfilename ), "models/players/%s/head_%s.skin", headModelName, headSkinName );
- ci->headSkin = cgi_R_RegisterSkin( hfilename );
+ if (headModelName && headSkinName && headModelName[0] && headSkinName[0]) {
+ Com_sprintf(hfilename, sizeof(hfilename), "models/players/%s/head_%s.skin", headModelName, headSkinName);
+ ci->headSkin = cgi_R_RegisterSkin(hfilename);
- if ( !ci->headSkin )
- {
- Com_Printf( "Failed to load skin file: %s : %s\n", headModelName, headSkinName );
+ if (!ci->headSkin) {
+ Com_Printf("Failed to load skin file: %s : %s\n", headModelName, headSkinName);
return qfalse;
}
}
@@ -902,174 +838,136 @@ qboolean CG_RegisterClientSkin( clientInfo_t *ci,
CG_RegisterClientModelname
==========================
*/
-qboolean CG_RegisterClientModelname( clientInfo_t *ci,
- const char *headModelName, const char *headSkinName,
- const char *torsoModelName, const char *torsoSkinName,
- const char *legsModelName, const char *legsSkinName )
-{
+qboolean CG_RegisterClientModelname(clientInfo_t *ci, const char *headModelName, const char *headSkinName, const char *torsoModelName,
+ const char *torsoSkinName, const char *legsModelName, const char *legsSkinName) {
/*
Ghoul2 Insert Start
*/
#if 1
- char filename[MAX_QPATH];
+ char filename[MAX_QPATH];
-
- if ( !legsModelName || !legsModelName[0] )
- {
+ if (!legsModelName || !legsModelName[0]) {
return qtrue;
}
- Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.mdr", legsModelName );
- ci->legsModel = cgi_R_RegisterModel( filename );
- if ( !ci->legsModel )
- {//he's not skeletal, try the old way
- Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", legsModelName );
- ci->legsModel = cgi_R_RegisterModel( filename );
- if ( !ci->legsModel )
- {
- Com_Printf( S_COLOR_RED"Failed to load model file %s\n", filename );
+ Com_sprintf(filename, sizeof(filename), "models/players/%s/lower.mdr", legsModelName);
+ ci->legsModel = cgi_R_RegisterModel(filename);
+ if (!ci->legsModel) { // he's not skeletal, try the old way
+ Com_sprintf(filename, sizeof(filename), "models/players/%s/lower.md3", legsModelName);
+ ci->legsModel = cgi_R_RegisterModel(filename);
+ if (!ci->legsModel) {
+ Com_Printf(S_COLOR_RED "Failed to load model file %s\n", filename);
return qfalse;
}
}
- if(torsoModelName && torsoModelName[0])
- {//You are trying to set one
- Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.mdr", torsoModelName );
- ci->torsoModel = cgi_R_RegisterModel( filename );
- if ( !ci->torsoModel )
- {//he's not skeletal, try the old way
- Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", torsoModelName );
- ci->torsoModel = cgi_R_RegisterModel( filename );
- if ( !ci->torsoModel )
- {
- Com_Printf( S_COLOR_RED"Failed to load model file %s\n", filename );
+ if (torsoModelName && torsoModelName[0]) { // You are trying to set one
+ Com_sprintf(filename, sizeof(filename), "models/players/%s/upper.mdr", torsoModelName);
+ ci->torsoModel = cgi_R_RegisterModel(filename);
+ if (!ci->torsoModel) { // he's not skeletal, try the old way
+ Com_sprintf(filename, sizeof(filename), "models/players/%s/upper.md3", torsoModelName);
+ ci->torsoModel = cgi_R_RegisterModel(filename);
+ if (!ci->torsoModel) {
+ Com_Printf(S_COLOR_RED "Failed to load model file %s\n", filename);
return qfalse;
}
}
- }
- else
- {
+ } else {
ci->torsoModel = 0;
}
- if(headModelName && headModelName[0])
- {//You are trying to set one
- Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", headModelName );
- ci->headModel = cgi_R_RegisterModel( filename );
- if ( !ci->headModel )
- {
- Com_Printf( S_COLOR_RED"Failed to load model file %s\n", filename );
+ if (headModelName && headModelName[0]) { // You are trying to set one
+ Com_sprintf(filename, sizeof(filename), "models/players/%s/head.md3", headModelName);
+ ci->headModel = cgi_R_RegisterModel(filename);
+ if (!ci->headModel) {
+ Com_Printf(S_COLOR_RED "Failed to load model file %s\n", filename);
return qfalse;
}
- }
- else
- {
+ } else {
ci->headModel = 0;
}
-
// if any skins failed to load, return failure
- if ( !CG_RegisterClientSkin( ci, headModelName, headSkinName, torsoModelName, torsoSkinName, legsModelName, legsSkinName ) )
- {
- //Com_Printf( "Failed to load skin file: %s : %s/%s : %s/%s : %s\n", headModelName, headSkinName, torsoModelName, torsoSkinName, legsModelName, legsSkinName );
+ if (!CG_RegisterClientSkin(ci, headModelName, headSkinName, torsoModelName, torsoSkinName, legsModelName, legsSkinName)) {
+ // Com_Printf( "Failed to load skin file: %s : %s/%s : %s/%s : %s\n", headModelName, headSkinName, torsoModelName, torsoSkinName, legsModelName,
+ // legsSkinName );
return qfalse;
}
- //FIXME: for now, uses the legs model dir for anim cfg, but should we set this in some sort of NPCs.cfg?
- // load the animation file set
+ // FIXME: for now, uses the legs model dir for anim cfg, but should we set this in some sort of NPCs.cfg?
+ // load the animation file set
ci->animFileIndex = G_ParseAnimFileSet(legsModelName);
- if (ci->animFileIndex<0)
- {
- Com_Printf( S_COLOR_RED"Failed to load animation file set models/players/%s\n", legsModelName );
+ if (ci->animFileIndex < 0) {
+ Com_Printf(S_COLOR_RED "Failed to load animation file set models/players/%s\n", legsModelName);
return qfalse;
}
#endif
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
return qtrue;
}
+void CG_RegisterClientRenderInfo(clientInfo_t *ci, renderInfo_t *ri) {
+ char *slash;
+ char headModelName[MAX_QPATH];
+ char torsoModelName[MAX_QPATH];
+ char legsModelName[MAX_QPATH];
+ char headSkinName[MAX_QPATH];
+ char torsoSkinName[MAX_QPATH];
+ char legsSkinName[MAX_QPATH];
-void CG_RegisterClientRenderInfo(clientInfo_t *ci, renderInfo_t *ri)
-{
- char *slash;
- char headModelName[MAX_QPATH];
- char torsoModelName[MAX_QPATH];
- char legsModelName[MAX_QPATH];
- char headSkinName[MAX_QPATH];
- char torsoSkinName[MAX_QPATH];
- char legsSkinName[MAX_QPATH];
-
- if(!ri->legsModelName[0])
- {//Must have at LEAST a legs model
+ if (!ri->legsModelName[0]) { // Must have at LEAST a legs model
return;
}
- Q_strncpyz( legsModelName, ri->legsModelName, sizeof( legsModelName ) );
- //Legs skin
- slash = strchr( legsModelName, '/' );
- if ( !slash )
- {
+ Q_strncpyz(legsModelName, ri->legsModelName, sizeof(legsModelName));
+ // Legs skin
+ slash = strchr(legsModelName, '/');
+ if (!slash) {
// modelName didn not include a skin name
- Q_strncpyz( legsSkinName, "default", sizeof( legsSkinName ) );
- }
- else
- {
- Q_strncpyz( legsSkinName, slash + 1, sizeof( legsSkinName ) );
+ Q_strncpyz(legsSkinName, "default", sizeof(legsSkinName));
+ } else {
+ Q_strncpyz(legsSkinName, slash + 1, sizeof(legsSkinName));
// truncate modelName
*slash = 0;
}
- if(ri->torsoModelName[0])
- {
- Q_strncpyz( torsoModelName, ri->torsoModelName, sizeof( torsoModelName ) );
- //Torso skin
- slash = strchr( torsoModelName, '/' );
- if ( !slash )
- {
+ if (ri->torsoModelName[0]) {
+ Q_strncpyz(torsoModelName, ri->torsoModelName, sizeof(torsoModelName));
+ // Torso skin
+ slash = strchr(torsoModelName, '/');
+ if (!slash) {
// modelName didn't include a skin name
- Q_strncpyz( torsoSkinName, "default", sizeof( torsoSkinName ) );
- }
- else
- {
- Q_strncpyz( torsoSkinName, slash + 1, sizeof( torsoSkinName ) );
+ Q_strncpyz(torsoSkinName, "default", sizeof(torsoSkinName));
+ } else {
+ Q_strncpyz(torsoSkinName, slash + 1, sizeof(torsoSkinName));
// truncate modelName
*slash = 0;
}
- }
- else
- {
+ } else {
torsoModelName[0] = 0;
}
- //Head
- if(ri->headModelName[0])
- {
- Q_strncpyz( headModelName, ri->headModelName, sizeof( headModelName ) );
- //Head skin
- slash = strchr( headModelName, '/' );
- if ( !slash )
- {
+ // Head
+ if (ri->headModelName[0]) {
+ Q_strncpyz(headModelName, ri->headModelName, sizeof(headModelName));
+ // Head skin
+ slash = strchr(headModelName, '/');
+ if (!slash) {
// modelName didn not include a skin name
- Q_strncpyz( headSkinName, "default", sizeof( headSkinName ) );
- }
- else
- {
- Q_strncpyz( headSkinName, slash + 1, sizeof( headSkinName ) );
+ Q_strncpyz(headSkinName, "default", sizeof(headSkinName));
+ } else {
+ Q_strncpyz(headSkinName, slash + 1, sizeof(headSkinName));
// truncate modelName
*slash = 0;
}
- }
- else
- {
+ } else {
headModelName[0] = 0;
}
- if ( !CG_RegisterClientModelname( ci, headModelName, headSkinName, torsoModelName, torsoSkinName, legsModelName, legsSkinName) )
- {
- if ( !CG_RegisterClientModelname( ci, DEFAULT_HEADMODEL, "default", DEFAULT_TORSOMODEL, "default", DEFAULT_LEGSMODEL, "default" ) )
- {
- CG_Error( "DEFAULT_MODELS failed to register");
+ if (!CG_RegisterClientModelname(ci, headModelName, headSkinName, torsoModelName, torsoSkinName, legsModelName, legsSkinName)) {
+ if (!CG_RegisterClientModelname(ci, DEFAULT_HEADMODEL, "default", DEFAULT_TORSOMODEL, "default", DEFAULT_LEGSMODEL, "default")) {
+ CG_Error("DEFAULT_MODELS failed to register");
}
}
}
@@ -1081,79 +979,69 @@ void CG_RegisterClientRenderInfo(clientInfo_t *ci, renderInfo_t *ri)
// and any shader, model, or sound
// files an effect may use.
//-------------------------------------
-extern void CG_InitGlass( void );
-extern void cgi_R_WorldEffectCommand( const char *command );
+extern void CG_InitGlass(void);
+extern void cgi_R_WorldEffectCommand(const char *command);
extern cvar_t *g_delayedShutdown;
-static void CG_RegisterEffects( void )
-{
- char *effectName;
- int i, numFailed=0;
+static void CG_RegisterEffects(void) {
+ char *effectName;
+ int i, numFailed = 0;
// Register external effects
- for ( i = 1 ; i < MAX_FX ; i++ )
- {
- effectName = ( char *)CG_ConfigString( CS_EFFECTS + i );
+ for (i = 1; i < MAX_FX; i++) {
+ effectName = (char *)CG_ConfigString(CS_EFFECTS + i);
- if ( !effectName[0] )
- {
+ if (!effectName[0]) {
break;
}
- if (!theFxScheduler.RegisterEffect( (const char*)effectName ))
- {
- //assert(0);
+ if (!theFxScheduler.RegisterEffect((const char *)effectName)) {
+ // assert(0);
numFailed++;
}
}
- if (numFailed && g_delayedShutdown->integer)
- {
- //assert(0);
- //CG_Error( "CG_RegisterEffects: %i Effects failed to load. Please fix, or ask Aurelio.", numFailed );
+ if (numFailed && g_delayedShutdown->integer) {
+ // assert(0);
+ // CG_Error( "CG_RegisterEffects: %i Effects failed to load. Please fix, or ask Aurelio.", numFailed );
}
// Start world effects
- for ( i = 1 ; i < MAX_WORLD_FX ; i++ )
- {
- effectName = ( char *)CG_ConfigString( CS_WORLD_FX + i );
+ for (i = 1; i < MAX_WORLD_FX; i++) {
+ effectName = (char *)CG_ConfigString(CS_WORLD_FX + i);
- if ( !effectName[0] )
- {
+ if (!effectName[0]) {
break;
}
- cgi_R_WorldEffectCommand( effectName );
+ cgi_R_WorldEffectCommand(effectName);
}
// Set up the glass effects mini-system.
CG_InitGlass();
- //footstep effects
- cgs.effects.footstepMud = theFxScheduler.RegisterEffect( "materials/mud" );
- cgs.effects.footstepSand = theFxScheduler.RegisterEffect( "materials/sand" );
- cgs.effects.footstepSnow = theFxScheduler.RegisterEffect( "materials/snow" );
- cgs.effects.footstepGravel = theFxScheduler.RegisterEffect( "materials/gravel" );
- //landing effects
- cgs.effects.landingMud = theFxScheduler.RegisterEffect( "materials/mud_large" );
- cgs.effects.landingSand = theFxScheduler.RegisterEffect( "materials/sand_large" );
- cgs.effects.landingDirt = theFxScheduler.RegisterEffect( "materials/dirt_large" );
- cgs.effects.landingSnow = theFxScheduler.RegisterEffect( "materials/snow_large" );
- cgs.effects.landingGravel = theFxScheduler.RegisterEffect( "materials/gravel_large" );
- //splashes
- if ( (gi.totalMapContents()&CONTENTS_WATER) )
- {
- theFxScheduler.RegisterEffect( "env/water_impact" );
- theFxScheduler.RegisterEffect( "misc/waterbreath" );
+ // footstep effects
+ cgs.effects.footstepMud = theFxScheduler.RegisterEffect("materials/mud");
+ cgs.effects.footstepSand = theFxScheduler.RegisterEffect("materials/sand");
+ cgs.effects.footstepSnow = theFxScheduler.RegisterEffect("materials/snow");
+ cgs.effects.footstepGravel = theFxScheduler.RegisterEffect("materials/gravel");
+ // landing effects
+ cgs.effects.landingMud = theFxScheduler.RegisterEffect("materials/mud_large");
+ cgs.effects.landingSand = theFxScheduler.RegisterEffect("materials/sand_large");
+ cgs.effects.landingDirt = theFxScheduler.RegisterEffect("materials/dirt_large");
+ cgs.effects.landingSnow = theFxScheduler.RegisterEffect("materials/snow_large");
+ cgs.effects.landingGravel = theFxScheduler.RegisterEffect("materials/gravel_large");
+ // splashes
+ if ((gi.totalMapContents() & CONTENTS_WATER)) {
+ theFxScheduler.RegisterEffect("env/water_impact");
+ theFxScheduler.RegisterEffect("misc/waterbreath");
}
- if ( (gi.totalMapContents()&CONTENTS_LAVA) )
- {
- theFxScheduler.RegisterEffect( "env/lava_splash" );
+ if ((gi.totalMapContents() & CONTENTS_LAVA)) {
+ theFxScheduler.RegisterEffect("env/lava_splash");
}
- if ( (gi.totalMapContents()&CONTENTS_SLIME) )
- {
- theFxScheduler.RegisterEffect( "env/acid_splash" );
+ if ((gi.totalMapContents() & CONTENTS_SLIME)) {
+ theFxScheduler.RegisterEffect("env/acid_splash");
}
- theFxScheduler.RegisterEffect( "misc/breath" );
+ theFxScheduler.RegisterEffect("misc/breath");
}
/*
@@ -1163,86 +1051,74 @@ Only call if clientInfo->infoValid is not true
For players and NPCs to register their models
*/
-void CG_RegisterClientModels (int entityNum)
-{
- gentity_t *ent;
+void CG_RegisterClientModels(int entityNum) {
+ gentity_t *ent;
- if(entityNum < 0 || entityNum > ENTITYNUM_WORLD)
- {
+ if (entityNum < 0 || entityNum > ENTITYNUM_WORLD) {
return;
}
ent = &g_entities[entityNum];
- if(!ent->client)
- {
+ if (!ent->client) {
return;
}
ent->client->clientInfo.infoValid = qtrue;
- if ( ent->playerModel != -1 && ent->ghoul2.size() )
- {
+ if (ent->playerModel != -1 && ent->ghoul2.size()) {
return;
}
CG_RegisterClientRenderInfo(&ent->client->clientInfo, &ent->client->renderInfo);
- if(entityNum < MAX_CLIENTS)
- {
+ if (entityNum < MAX_CLIENTS) {
memcpy(&cgs.clientinfo[entityNum], &ent->client->clientInfo, sizeof(clientInfo_t));
}
}
//===================================================================================
-
-HUDMenuItem_t forceTics[] =
-{
- { "rightHUD", "force_tic1", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "rightHUD", "force_tic2", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "rightHUD", "force_tic3", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "rightHUD", "force_tic4", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
+HUDMenuItem_t forceTics[] = {
+ {"rightHUD", "force_tic1", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"rightHUD", "force_tic2", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"rightHUD", "force_tic3", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"rightHUD", "force_tic4", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
};
-HUDMenuItem_t ammoTics[] =
-{
- { "rightHUD", "ammo_tic1", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "rightHUD", "ammo_tic2", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "rightHUD", "ammo_tic3", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "rightHUD", "ammo_tic4", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
+HUDMenuItem_t ammoTics[] = {
+ {"rightHUD", "ammo_tic1", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"rightHUD", "ammo_tic2", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"rightHUD", "ammo_tic3", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"rightHUD", "ammo_tic4", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
};
-HUDMenuItem_t armorTics[] =
-{
- { "leftHUD", "armor_tic1", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "leftHUD", "armor_tic2", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE },
- { "leftHUD", "armor_tic3", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE },
- { "leftHUD", "armor_tic4", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE },
+HUDMenuItem_t armorTics[] = {
+ {"leftHUD", "armor_tic1", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"leftHUD", "armor_tic2", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE},
+ {"leftHUD", "armor_tic3", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE},
+ {"leftHUD", "armor_tic4", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE},
};
-HUDMenuItem_t healthTics[] =
-{
- { "leftHUD", "health_tic1", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Top
- { "leftHUD", "health_tic2", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, //
- { "leftHUD", "health_tic3", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, //
- { "leftHUD", "health_tic4", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // Bottom
+HUDMenuItem_t healthTics[] = {
+ {"leftHUD", "health_tic1", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Top
+ {"leftHUD", "health_tic2", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, //
+ {"leftHUD", "health_tic3", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, //
+ {"leftHUD", "health_tic4", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // Bottom
};
-
-HUDMenuItem_t otherHUDBits[] =
-{
- { "lefthud", "healthamount", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_HEALTHAMOUNT
- { "lefthud", "armoramount", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_ARMORAMOUNT
- { "righthud", "forceamount", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_FORCEAMOUNT
- { "righthud", "ammoamount", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_AMMOAMOUNT
- { "righthud", "saberstyle_strong", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_SABERSTYLE_STRONG
- { "righthud", "saberstyle_medium", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_SABERSTYLE_MEDIUM
- { "righthud", "saberstyle_fast", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_SABERSTYLE_FAST
- { "lefthud", "scanline", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_SCANLINE_LEFT
- { "righthud", "scanline", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_SCANLINE_RIGHT
- { "lefthud", "frame", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_FRAME_LEFT
- { "righthud", "frame", 0, 0, 0, 0, { 0.0f, 0.0f, 0.0f, 0.0f }, NULL_HANDLE }, // OHB_FRAME_RIGHT
+HUDMenuItem_t otherHUDBits[] = {
+ {"lefthud", "healthamount", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_HEALTHAMOUNT
+ {"lefthud", "armoramount", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_ARMORAMOUNT
+ {"righthud", "forceamount", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_FORCEAMOUNT
+ {"righthud", "ammoamount", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_AMMOAMOUNT
+ {"righthud", "saberstyle_strong", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_SABERSTYLE_STRONG
+ {"righthud", "saberstyle_medium", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_SABERSTYLE_MEDIUM
+ {"righthud", "saberstyle_fast", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_SABERSTYLE_FAST
+ {"lefthud", "scanline", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_SCANLINE_LEFT
+ {"righthud", "scanline", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_SCANLINE_RIGHT
+ {"lefthud", "frame", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_FRAME_LEFT
+ {"righthud", "frame", 0, 0, 0, 0, {0.0f, 0.0f, 0.0f, 0.0f}, NULL_HANDLE}, // OHB_FRAME_RIGHT
};
/*const char *HolocronIcons[] = {
@@ -1266,7 +1142,7 @@ HUDMenuItem_t otherHUDBits[] =
"gfx/mp/f_icon_saber_throw" //FP_SABERTHROW
};
*/
-extern void CG_NPC_Precache ( gentity_t *spawner );
+extern void CG_NPC_Precache(gentity_t *spawner);
qboolean NPCsPrecached = qfalse;
/*
=================
@@ -1277,395 +1153,310 @@ This function may execute for a couple of minutes with a slow disk.
=================
*/
void CG_CreateMiscEnts(void);
-static void CG_RegisterGraphics( void ) {
- int i;
- char items[MAX_ITEMS+1];
- int breakPoint = 0;
- const char *sb_nums[11] = {
- "gfx/2d/numbers/zero",
- "gfx/2d/numbers/one",
- "gfx/2d/numbers/two",
- "gfx/2d/numbers/three",
- "gfx/2d/numbers/four",
- "gfx/2d/numbers/five",
- "gfx/2d/numbers/six",
- "gfx/2d/numbers/seven",
- "gfx/2d/numbers/eight",
- "gfx/2d/numbers/nine",
- "gfx/2d/numbers/minus",
+static void CG_RegisterGraphics(void) {
+ int i;
+ char items[MAX_ITEMS + 1];
+ int breakPoint = 0;
+ const char *sb_nums[11] = {
+ "gfx/2d/numbers/zero", "gfx/2d/numbers/one", "gfx/2d/numbers/two", "gfx/2d/numbers/three", "gfx/2d/numbers/four", "gfx/2d/numbers/five",
+ "gfx/2d/numbers/six", "gfx/2d/numbers/seven", "gfx/2d/numbers/eight", "gfx/2d/numbers/nine", "gfx/2d/numbers/minus",
};
- const char *sb_t_nums[11] = {
- "gfx/2d/numbers/t_zero",
- "gfx/2d/numbers/t_one",
- "gfx/2d/numbers/t_two",
- "gfx/2d/numbers/t_three",
- "gfx/2d/numbers/t_four",
- "gfx/2d/numbers/t_five",
- "gfx/2d/numbers/t_six",
- "gfx/2d/numbers/t_seven",
- "gfx/2d/numbers/t_eight",
- "gfx/2d/numbers/t_nine",
- "gfx/2d/numbers/t_minus",
+ const char *sb_t_nums[11] = {
+ "gfx/2d/numbers/t_zero", "gfx/2d/numbers/t_one", "gfx/2d/numbers/t_two", "gfx/2d/numbers/t_three",
+ "gfx/2d/numbers/t_four", "gfx/2d/numbers/t_five", "gfx/2d/numbers/t_six", "gfx/2d/numbers/t_seven",
+ "gfx/2d/numbers/t_eight", "gfx/2d/numbers/t_nine", "gfx/2d/numbers/t_minus",
};
- const char *sb_c_nums[11] = {
- "gfx/2d/numbers/c_zero",
- "gfx/2d/numbers/c_one",
- "gfx/2d/numbers/c_two",
- "gfx/2d/numbers/c_three",
- "gfx/2d/numbers/c_four",
- "gfx/2d/numbers/c_five",
- "gfx/2d/numbers/c_six",
- "gfx/2d/numbers/c_seven",
- "gfx/2d/numbers/c_eight",
- "gfx/2d/numbers/c_nine",
+ const char *sb_c_nums[11] = {
+ "gfx/2d/numbers/c_zero", "gfx/2d/numbers/c_one", "gfx/2d/numbers/c_two", "gfx/2d/numbers/c_three", "gfx/2d/numbers/c_four",
+ "gfx/2d/numbers/c_five", "gfx/2d/numbers/c_six", "gfx/2d/numbers/c_seven", "gfx/2d/numbers/c_eight", "gfx/2d/numbers/c_nine",
"gfx/2d/numbers/t_minus", //?????
};
// Clean, then register...rinse...repeat...
- CG_LoadingString( "effects" );
+ CG_LoadingString("effects");
FX_Init();
CG_RegisterEffects();
// clear any references to old media
- memset( &cg.refdef, 0, sizeof( cg.refdef ) );
+ memset(&cg.refdef, 0, sizeof(cg.refdef));
cgi_R_ClearScene();
cg.loadLCARSStage = 3;
- CG_LoadingString( cgs.mapname );
+ CG_LoadingString(cgs.mapname);
- cgi_R_LoadWorldMap( cgs.mapname );
+ cgi_R_LoadWorldMap(cgs.mapname);
cg.loadLCARSStage = 4;
- CG_LoadingString( "game media shaders" );
+ CG_LoadingString("game media shaders");
- for ( i=0; i < 11; i++ )
- {
- cgs.media.numberShaders[i] = cgi_R_RegisterShaderNoMip( sb_nums[i] );
- cgs.media.smallnumberShaders[i] = cgi_R_RegisterShaderNoMip( sb_t_nums[i] );
- cgs.media.chunkyNumberShaders[i] = cgi_R_RegisterShaderNoMip( sb_c_nums[i] );
+ for (i = 0; i < 11; i++) {
+ cgs.media.numberShaders[i] = cgi_R_RegisterShaderNoMip(sb_nums[i]);
+ cgs.media.smallnumberShaders[i] = cgi_R_RegisterShaderNoMip(sb_t_nums[i]);
+ cgs.media.chunkyNumberShaders[i] = cgi_R_RegisterShaderNoMip(sb_c_nums[i]);
}
// FIXME: conditionally do this?? Something must be wrong with inventory item caching..?
- cgi_R_RegisterModel( "models/items/remote.md3" );
+ cgi_R_RegisterModel("models/items/remote.md3");
- cgs.media.explosionModel = cgi_R_RegisterModel ( "models/weaphits/explosion.md3" );
- cgs.media.surfaceExplosionShader = cgi_R_RegisterShader( "surfaceExplosion" );
+ cgs.media.explosionModel = cgi_R_RegisterModel("models/weaphits/explosion.md3");
+ cgs.media.surfaceExplosionShader = cgi_R_RegisterShader("surfaceExplosion");
- cgs.media.halfShieldModel = cgi_R_RegisterModel( "models/weaphits/testboom.md3" );
+ cgs.media.halfShieldModel = cgi_R_RegisterModel("models/weaphits/testboom.md3");
- cgs.media.solidWhiteShader = cgi_R_RegisterShader( "gfx/effects/solidWhite" );
- cgs.media.refractShader = cgi_R_RegisterShader( "effects/refraction" );
+ cgs.media.solidWhiteShader = cgi_R_RegisterShader("gfx/effects/solidWhite");
+ cgs.media.refractShader = cgi_R_RegisterShader("effects/refraction");
- //on players
- cgs.media.personalShieldShader = cgi_R_RegisterShader( "gfx/misc/personalshield" );
- cgs.media.cloakedShader = cgi_R_RegisterShader( "gfx/effects/cloakedShader" );
- cgi_R_RegisterShader( "gfx/misc/ion_shield" );
+ // on players
+ cgs.media.personalShieldShader = cgi_R_RegisterShader("gfx/misc/personalshield");
+ cgs.media.cloakedShader = cgi_R_RegisterShader("gfx/effects/cloakedShader");
+ cgi_R_RegisterShader("gfx/misc/ion_shield");
- cgs.media.boltShader = cgi_R_RegisterShader( "gfx/misc/blueLine" );
+ cgs.media.boltShader = cgi_R_RegisterShader("gfx/misc/blueLine");
// FIXME: do these conditionally
- cgi_R_RegisterShader( "gfx/2d/workingCamera" );
- cgi_R_RegisterShader( "gfx/2d/brokenCamera" );
- //cgi_R_RegisterShader( "gfx/effects/irid_shield" ); // for galak, but he doesn't have his own weapon so I can't register the shader there.
+ cgi_R_RegisterShader("gfx/2d/workingCamera");
+ cgi_R_RegisterShader("gfx/2d/brokenCamera");
+ // cgi_R_RegisterShader( "gfx/effects/irid_shield" ); // for galak, but he doesn't have his own weapon so I can't register the shader there.
- //interface
- for ( i = 0 ; i < NUM_CROSSHAIRS ; i++ ) {
- cgs.media.crosshairShader[i] = cgi_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a'+i) );
+ // interface
+ for (i = 0; i < NUM_CROSSHAIRS; i++) {
+ cgs.media.crosshairShader[i] = cgi_R_RegisterShaderNoMip(va("gfx/2d/crosshair%c", 'a' + i));
}
- cgs.media.backTileShader = cgi_R_RegisterShader( "gfx/2d/backtile" );
-// cgs.media.noammoShader = cgi_R_RegisterShaderNoMip( "gfx/hud/noammo");
- cgs.media.weaponIconBackground = cgi_R_RegisterShaderNoMip( "gfx/hud/background");
- cgs.media.forceIconBackground = cgi_R_RegisterShaderNoMip( "gfx/hud/background_f");
- cgs.media.inventoryIconBackground= cgi_R_RegisterShaderNoMip( "gfx/hud/background_i");
- cgs.media.dataPadFrame = cgi_R_RegisterShaderNoMip( "gfx/menus/datapad");
+ cgs.media.backTileShader = cgi_R_RegisterShader("gfx/2d/backtile");
+ // cgs.media.noammoShader = cgi_R_RegisterShaderNoMip( "gfx/hud/noammo");
+ cgs.media.weaponIconBackground = cgi_R_RegisterShaderNoMip("gfx/hud/background");
+ cgs.media.forceIconBackground = cgi_R_RegisterShaderNoMip("gfx/hud/background_f");
+ cgs.media.inventoryIconBackground = cgi_R_RegisterShaderNoMip("gfx/hud/background_i");
+ cgs.media.dataPadFrame = cgi_R_RegisterShaderNoMip("gfx/menus/datapad");
- //gore decal shaders -rww
- cgs.media.bdecal_burnmark1 = cgi_R_RegisterShader( "gfx/damage/burnmark1" );
- cgs.media.bdecal_saberglowmark = cgi_R_RegisterShader( "gfx/damage/saberglowmark" );
+ // gore decal shaders -rww
+ cgs.media.bdecal_burnmark1 = cgi_R_RegisterShader("gfx/damage/burnmark1");
+ cgs.media.bdecal_saberglowmark = cgi_R_RegisterShader("gfx/damage/saberglowmark");
cg.loadLCARSStage = 5;
- CG_LoadingString( "game media models" );
+ CG_LoadingString("game media models");
// Chunk models
- //FIXME: jfm:? bother to conditionally load these if an ent has this material type?
- for ( i = 0; i < NUM_CHUNK_MODELS; i++ )
- {
- cgs.media.chunkModels[CHUNK_METAL2][i] = cgi_R_RegisterModel( va( "models/chunks/metal/metal1_%i.md3", i+1 ) ); //_ /switched\ _
- cgs.media.chunkModels[CHUNK_METAL1][i] = cgi_R_RegisterModel( va( "models/chunks/metal/metal2_%i.md3", i+1 ) ); // \switched/
- cgs.media.chunkModels[CHUNK_ROCK1][i] = cgi_R_RegisterModel( va( "models/chunks/rock/rock1_%i.md3", i+1 ) );
- cgs.media.chunkModels[CHUNK_ROCK2][i] = cgi_R_RegisterModel( va( "models/chunks/rock/rock2_%i.md3", i+1 ) );
- cgs.media.chunkModels[CHUNK_ROCK3][i] = cgi_R_RegisterModel( va( "models/chunks/rock/rock3_%i.md3", i+1 ) );
- cgs.media.chunkModels[CHUNK_CRATE1][i] = cgi_R_RegisterModel( va( "models/chunks/crate/crate1_%i.md3", i+1 ) );
- cgs.media.chunkModels[CHUNK_CRATE2][i] = cgi_R_RegisterModel( va( "models/chunks/crate/crate2_%i.md3", i+1 ) );
- cgs.media.chunkModels[CHUNK_WHITE_METAL][i] = cgi_R_RegisterModel( va( "models/chunks/metal/wmetal1_%i.md3", i+1 ) );
- }
-
- cgs.media.chunkSound = cgi_S_RegisterSound("sound/weapons/explosions/glasslcar");
- cgs.media.grateSound = cgi_S_RegisterSound( "sound/effects/grate_destroy" );
- cgs.media.rockBreakSound = cgi_S_RegisterSound("sound/effects/wall_smash");
- cgs.media.rockBounceSound[0] = cgi_S_RegisterSound("sound/effects/stone_bounce");
- cgs.media.rockBounceSound[1] = cgi_S_RegisterSound("sound/effects/stone_bounce2");
- cgs.media.metalBounceSound[0] = cgi_S_RegisterSound("sound/effects/metal_bounce");
- cgs.media.metalBounceSound[1] = cgi_S_RegisterSound("sound/effects/metal_bounce2");
- cgs.media.glassChunkSound = cgi_S_RegisterSound("sound/weapons/explosions/glassbreak1");
- cgs.media.crateBreakSound[0] = cgi_S_RegisterSound("sound/weapons/explosions/crateBust1" );
- cgs.media.crateBreakSound[1] = cgi_S_RegisterSound("sound/weapons/explosions/crateBust2" );
-
- cgs.media.weaponbox = cgi_R_RegisterShaderNoMip( "gfx/interface/weapon_box");
-
- //Models & Shaders
- cgs.media.damageBlendBlobShader = cgi_R_RegisterShader( "gfx/misc/borgeyeflare" );
+ // FIXME: jfm:? bother to conditionally load these if an ent has this material type?
+ for (i = 0; i < NUM_CHUNK_MODELS; i++) {
+ cgs.media.chunkModels[CHUNK_METAL2][i] = cgi_R_RegisterModel(va("models/chunks/metal/metal1_%i.md3", i + 1)); //_ /switched\ _
+ cgs.media.chunkModels[CHUNK_METAL1][i] = cgi_R_RegisterModel(va("models/chunks/metal/metal2_%i.md3", i + 1)); // \switched/
+ cgs.media.chunkModels[CHUNK_ROCK1][i] = cgi_R_RegisterModel(va("models/chunks/rock/rock1_%i.md3", i + 1));
+ cgs.media.chunkModels[CHUNK_ROCK2][i] = cgi_R_RegisterModel(va("models/chunks/rock/rock2_%i.md3", i + 1));
+ cgs.media.chunkModels[CHUNK_ROCK3][i] = cgi_R_RegisterModel(va("models/chunks/rock/rock3_%i.md3", i + 1));
+ cgs.media.chunkModels[CHUNK_CRATE1][i] = cgi_R_RegisterModel(va("models/chunks/crate/crate1_%i.md3", i + 1));
+ cgs.media.chunkModels[CHUNK_CRATE2][i] = cgi_R_RegisterModel(va("models/chunks/crate/crate2_%i.md3", i + 1));
+ cgs.media.chunkModels[CHUNK_WHITE_METAL][i] = cgi_R_RegisterModel(va("models/chunks/metal/wmetal1_%i.md3", i + 1));
+ }
+
+ cgs.media.chunkSound = cgi_S_RegisterSound("sound/weapons/explosions/glasslcar");
+ cgs.media.grateSound = cgi_S_RegisterSound("sound/effects/grate_destroy");
+ cgs.media.rockBreakSound = cgi_S_RegisterSound("sound/effects/wall_smash");
+ cgs.media.rockBounceSound[0] = cgi_S_RegisterSound("sound/effects/stone_bounce");
+ cgs.media.rockBounceSound[1] = cgi_S_RegisterSound("sound/effects/stone_bounce2");
+ cgs.media.metalBounceSound[0] = cgi_S_RegisterSound("sound/effects/metal_bounce");
+ cgs.media.metalBounceSound[1] = cgi_S_RegisterSound("sound/effects/metal_bounce2");
+ cgs.media.glassChunkSound = cgi_S_RegisterSound("sound/weapons/explosions/glassbreak1");
+ cgs.media.crateBreakSound[0] = cgi_S_RegisterSound("sound/weapons/explosions/crateBust1");
+ cgs.media.crateBreakSound[1] = cgi_S_RegisterSound("sound/weapons/explosions/crateBust2");
+
+ cgs.media.weaponbox = cgi_R_RegisterShaderNoMip("gfx/interface/weapon_box");
+
+ // Models & Shaders
+ cgs.media.damageBlendBlobShader = cgi_R_RegisterShader("gfx/misc/borgeyeflare");
cg.loadLCARSStage = 6;
- cgs.media.messageLitOn = cgi_R_RegisterShaderNoMip( "gfx/hud/message_on" );
- cgs.media.messageLitOff = cgi_R_RegisterShaderNoMip( "gfx/hud/message_off" );
- cgs.media.messageObjCircle = cgi_R_RegisterShaderNoMip( "gfx/hud/objective_circle" );
+ cgs.media.messageLitOn = cgi_R_RegisterShaderNoMip("gfx/hud/message_on");
+ cgs.media.messageLitOff = cgi_R_RegisterShaderNoMip("gfx/hud/message_off");
+ cgs.media.messageObjCircle = cgi_R_RegisterShaderNoMip("gfx/hud/objective_circle");
- cgs.media.DPForcePowerOverlay = cgi_R_RegisterShader( "gfx/hud/force_swirl" );
+ cgs.media.DPForcePowerOverlay = cgi_R_RegisterShader("gfx/hud/force_swirl");
- //NOTE: we should only cache this if there is a vehicle or emplaced gun somewhere on the map
- cgs.media.emplacedHealthBarShader = cgi_R_RegisterShaderNoMip( "gfx/hud/health_frame" );
+ // NOTE: we should only cache this if there is a vehicle or emplaced gun somewhere on the map
+ cgs.media.emplacedHealthBarShader = cgi_R_RegisterShaderNoMip("gfx/hud/health_frame");
// battery charge shader when using a gonk
- cgs.media.batteryChargeShader = cgi_R_RegisterShader( "gfx/2d/battery" );
- cgi_R_RegisterShader( "gfx/2d/droid_view" );
+ cgs.media.batteryChargeShader = cgi_R_RegisterShader("gfx/2d/battery");
+ cgi_R_RegisterShader("gfx/2d/droid_view");
cgs.media.useableHint = cgi_R_RegisterShader("gfx/hud/useableHint");
// Load up other HUD bits
- for (i=0;iclientInfo.infoValid)
- //We presume this
+ for (i = 0; i < ENTITYNUM_WORLD; i++) {
+ if (g_entities[i].inuse) {
+ if (g_entities[i].client) {
+ // if(!g_entities[i].client->clientInfo.infoValid)
+ // We presume this
{
- CG_LoadingString( va("client %s", g_entities[i].client->clientInfo.name ) );
+ CG_LoadingString(va("client %s", g_entities[i].client->clientInfo.name));
CG_RegisterClientModels(i);
- if ( i != 0 )
- {//Client weapons already precached
- CG_RegisterWeapon( g_entities[i].client->ps.weapon );
- if ( g_entities[i].client->ps.saber[0].g2MarksShader[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[0].g2MarksShader );
+ if (i != 0) { // Client weapons already precached
+ CG_RegisterWeapon(g_entities[i].client->ps.weapon);
+ if (g_entities[i].client->ps.saber[0].g2MarksShader[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[0].g2MarksShader);
}
- if ( g_entities[i].client->ps.saber[0].g2MarksShader2[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[0].g2MarksShader2 );
+ if (g_entities[i].client->ps.saber[0].g2MarksShader2[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[0].g2MarksShader2);
}
- if ( g_entities[i].client->ps.saber[0].g2WeaponMarkShader[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[0].g2WeaponMarkShader );
+ if (g_entities[i].client->ps.saber[0].g2WeaponMarkShader[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[0].g2WeaponMarkShader);
}
- if ( g_entities[i].client->ps.saber[0].g2WeaponMarkShader2[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[0].g2WeaponMarkShader2 );
+ if (g_entities[i].client->ps.saber[0].g2WeaponMarkShader2[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[0].g2WeaponMarkShader2);
}
- if ( g_entities[i].client->ps.saber[1].g2MarksShader[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[1].g2MarksShader );
+ if (g_entities[i].client->ps.saber[1].g2MarksShader[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[1].g2MarksShader);
}
- if ( g_entities[i].client->ps.saber[1].g2MarksShader2[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[1].g2MarksShader2 );
+ if (g_entities[i].client->ps.saber[1].g2MarksShader2[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[1].g2MarksShader2);
}
- if ( g_entities[i].client->ps.saber[1].g2WeaponMarkShader[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[1].g2WeaponMarkShader );
+ if (g_entities[i].client->ps.saber[1].g2WeaponMarkShader[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[1].g2WeaponMarkShader);
}
- if ( g_entities[i].client->ps.saber[1].g2WeaponMarkShader2[0] )
- {
- cgi_R_RegisterShader( g_entities[i].client->ps.saber[1].g2WeaponMarkShader2 );
+ if (g_entities[i].client->ps.saber[1].g2WeaponMarkShader2[0]) {
+ cgi_R_RegisterShader(g_entities[i].client->ps.saber[1].g2WeaponMarkShader2);
}
- CG_RegisterNPCCustomSounds( &g_entities[i].client->clientInfo );
- //CG_RegisterNPCEffects( g_entities[i].client->playerTeam );
+ CG_RegisterNPCCustomSounds(&g_entities[i].client->clientInfo);
+ // CG_RegisterNPCEffects( g_entities[i].client->playerTeam );
}
}
- }
- else if ( g_entities[i].svFlags & SVF_NPC_PRECACHE && g_entities[i].NPC_type && g_entities[i].NPC_type[0] )
- {//Precache the NPC_type
- //FIXME: make sure we didn't precache this NPC_type already
- CG_LoadingString( va("NPC %s", g_entities[i].NPC_type ) );
+ } else if (g_entities[i].svFlags & SVF_NPC_PRECACHE && g_entities[i].NPC_type && g_entities[i].NPC_type[0]) { // Precache the NPC_type
+ // FIXME: make sure we didn't precache this NPC_type already
+ CG_LoadingString(va("NPC %s", g_entities[i].NPC_type));
/*
if (g_entities[i].classname && g_entities[i].classname[0] && Q_stricmp( g_entities[i].classname, "NPC_Vehicle" ) == 0)
{
@@ -1674,77 +1465,67 @@ Ghoul2 Insert End
}
else
*/
- {
- CG_NPC_Precache( &g_entities[i] );
- }
+ { CG_NPC_Precache(&g_entities[i]); }
}
}
}
- CG_LoadingString( "static models" );
+ CG_LoadingString("static models");
CG_CreateMiscEnts();
cg.loadLCARSStage = 9;
NPCsPrecached = qtrue;
- extern cvar_t *com_buildScript;
+ extern cvar_t *com_buildScript;
if (com_buildScript->integer) {
- cgi_R_RegisterShader( "gfx/misc/nav_cpoint" );
- cgi_R_RegisterShader( "gfx/misc/nav_line" );
- cgi_R_RegisterShader( "gfx/misc/nav_arrow" );
- cgi_R_RegisterShader( "gfx/misc/nav_node" );
+ cgi_R_RegisterShader("gfx/misc/nav_cpoint");
+ cgi_R_RegisterShader("gfx/misc/nav_line");
+ cgi_R_RegisterShader("gfx/misc/nav_arrow");
+ cgi_R_RegisterShader("gfx/misc/nav_node");
}
- for(i = 1; i < MAX_SUB_BSP; i++)
- {
- const char *bspName = 0;
- vec3_t mins, maxs;
- int j = 0;
- int sub = 0;
- char temp[MAX_QPATH];
-
- bspName = CG_ConfigString( CS_BSP_MODELS+i );
- if ( !bspName[0] )
- {
+ for (i = 1; i < MAX_SUB_BSP; i++) {
+ const char *bspName = 0;
+ vec3_t mins, maxs;
+ int j = 0;
+ int sub = 0;
+ char temp[MAX_QPATH];
+
+ bspName = CG_ConfigString(CS_BSP_MODELS + i);
+ if (!bspName[0]) {
break;
}
- CG_LoadingString( "BSP instances" );
+ CG_LoadingString("BSP instances");
- cgi_CM_LoadMap( bspName, qtrue );
- cgs.inlineDrawModel[breakPoint] = cgi_R_RegisterModel( bspName );
- cgi_R_ModelBounds( cgs.inlineDrawModel[breakPoint], mins, maxs );
- for ( j = 0 ; j < 3 ; j++ )
- {
- cgs.inlineModelMidpoints[breakPoint][j] = mins[j] + 0.5 * ( maxs[j] - mins[j] );
+ cgi_CM_LoadMap(bspName, qtrue);
+ cgs.inlineDrawModel[breakPoint] = cgi_R_RegisterModel(bspName);
+ cgi_R_ModelBounds(cgs.inlineDrawModel[breakPoint], mins, maxs);
+ for (j = 0; j < 3; j++) {
+ cgs.inlineModelMidpoints[breakPoint][j] = mins[j] + 0.5 * (maxs[j] - mins[j]);
}
breakPoint++;
- for(sub=1;sub= MAX_CONFIGSTRINGS ) {
- CG_Error( "CG_ConfigString: bad index: %i", index );
+const char *CG_ConfigString(int index) {
+ if (index < 0 || index >= MAX_CONFIGSTRINGS) {
+ CG_Error("CG_ConfigString: bad index: %i", index);
}
- return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];
+ return cgs.gameState.stringData + cgs.gameState.stringOffsets[index];
}
//==================================================================
-void CG_LinkCentsToGents(void)
-{
- int i;
+void CG_LinkCentsToGents(void) {
+ int i;
- for(i = 0; i < MAX_GENTITIES; i++)
- {
+ for (i = 0; i < MAX_GENTITIES; i++) {
cg_entities[i].gent = &g_entities[i];
}
}
@@ -1790,18 +1569,18 @@ CG_StartMusic
======================
*/
-void CG_StartMusic( qboolean bForceStart ) {
- const char *s;
- char parm1[MAX_QPATH], parm2[MAX_QPATH];
+void CG_StartMusic(qboolean bForceStart) {
+ const char *s;
+ char parm1[MAX_QPATH], parm2[MAX_QPATH];
// start the background music
- s = (char *)CG_ConfigString( CS_MUSIC );
+ s = (char *)CG_ConfigString(CS_MUSIC);
COM_BeginParseSession();
- Q_strncpyz( parm1, COM_Parse( &s ), sizeof( parm1 ) );
- Q_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );
+ Q_strncpyz(parm1, COM_Parse(&s), sizeof(parm1));
+ Q_strncpyz(parm2, COM_Parse(&s), sizeof(parm2));
COM_EndParseSession();
- cgi_S_StartBackgroundTrack( parm1, parm2, (qboolean)!bForceStart );
+ cgi_S_StartBackgroundTrack(parm1, parm2, (qboolean)!bForceStart);
}
/*
@@ -1812,83 +1591,79 @@ Displays the info screen while loading media
======================
*/
-int iCGResetCount=0;
+int iCGResetCount = 0;
qboolean qbVidRestartOccured = qfalse;
//===================
-qboolean gbUseTheseValuesFromLoadSave = qfalse; // MUST default to this
+qboolean gbUseTheseValuesFromLoadSave = qfalse; // MUST default to this
int gi_cg_forcepowerSelect;
int gi_cg_inventorySelect;
//===================
-
-static void CG_GameStateReceived( void ) {
+static void CG_GameStateReceived(void) {
// clear everything
- extern void CG_ClearAnimEvtCache( void );
- CG_ClearAnimEvtCache(); // else sound handles wrong after vid_restart
+ extern void CG_ClearAnimEvtCache(void);
+ CG_ClearAnimEvtCache(); // else sound handles wrong after vid_restart
qbVidRestartOccured = qtrue;
iCGResetCount++;
- if (iCGResetCount == 1) // this will only equal 1 first time, after each vid_restart it just gets higher.
+ if (iCGResetCount == 1) // this will only equal 1 first time, after each vid_restart it just gets higher.
{ // This non-clear is so the user can vid_restart during scrolling text without losing it.
qbVidRestartOccured = qfalse;
}
- if (!qbVidRestartOccured)
- {
+ if (!qbVidRestartOccured) {
CG_Init_CG();
cg.weaponSelect = WP_NONE;
cg.forcepowerSelect = FP_HEAL;
}
- memset( cg_weapons, 0, sizeof(cg_weapons) );
- memset( cg_items, 0, sizeof(cg_items) );
+ memset(cg_weapons, 0, sizeof(cg_weapons));
+ memset(cg_items, 0, sizeof(cg_items));
CG_LinkCentsToGents();
- if (gbUseTheseValuesFromLoadSave)
- {
- gbUseTheseValuesFromLoadSave = qfalse; // ack
+ if (gbUseTheseValuesFromLoadSave) {
+ gbUseTheseValuesFromLoadSave = qfalse; // ack
cg.forcepowerSelect = gi_cg_forcepowerSelect;
- cg.inventorySelect = gi_cg_inventorySelect;
+ cg.inventorySelect = gi_cg_inventorySelect;
}
-
// get the rendering configuration from the client system
- cgi_GetGlconfig( &cgs.glconfig );
+ cgi_GetGlconfig(&cgs.glconfig);
-/* cgs.charScale = cgs.glconfig.vidHeight * (1.0/480.0);
- if ( cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640 ) {
- // wide screen
- cgs.bias = 0.5 * ( cgs.glconfig.vidWidth - ( cgs.glconfig.vidHeight * (640.0/480.0) ) );
- }
- else {
- // no wide screen
- cgs.bias = 0;
- }
-*/
+ /* cgs.charScale = cgs.glconfig.vidHeight * (1.0/480.0);
+ if ( cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640 ) {
+ // wide screen
+ cgs.bias = 0.5 * ( cgs.glconfig.vidWidth - ( cgs.glconfig.vidHeight * (640.0/480.0) ) );
+ }
+ else {
+ // no wide screen
+ cgs.bias = 0;
+ }
+ */
// get the gamestate from the client system
- cgi_GetGameState( &cgs.gameState );
+ cgi_GetGameState(&cgs.gameState);
CG_ParseServerinfo();
// load the new map
- cgs.media.levelLoad = cgi_R_RegisterShaderNoMip( "gfx/hud/mp_levelload" );
- CG_LoadingString( "collision map" );
+ cgs.media.levelLoad = cgi_R_RegisterShaderNoMip("gfx/hud/mp_levelload");
+ CG_LoadingString("collision map");
- cgi_CM_LoadMap( cgs.mapname, qfalse );
+ cgi_CM_LoadMap(cgs.mapname, qfalse);
CG_RegisterSounds();
CG_RegisterGraphics();
- //jfm: moved down to preinit
-// CG_InitLocalEntities();
-// CG_InitMarkPolys();
+ // jfm: moved down to preinit
+ // CG_InitLocalEntities();
+ // CG_InitMarkPolys();
- CG_LoadingString( "music" );
- CG_StartMusic( qfalse );
+ CG_LoadingString("music");
+ CG_StartMusic(qfalse);
// remove the last loading update
cg.infoScreenText[0] = 0;
@@ -1902,35 +1677,22 @@ static void CG_GameStateReceived( void ) {
cg.forceHUDActive = qtrue;
cg.forceHUDTotalFlashTime = 0;
cg.forceHUDNextFlashTime = 0;
-
}
-void CG_WriteTheEvilCGHackStuff()
-{
- ojk::SavedGameHelper saved_game(
- ::gi.saved_game);
+void CG_WriteTheEvilCGHackStuff() {
+ ojk::SavedGameHelper saved_game(::gi.saved_game);
- saved_game.write_chunk(
- INT_ID('F', 'P', 'S', 'L'),
- ::cg.forcepowerSelect);
+ saved_game.write_chunk(INT_ID('F', 'P', 'S', 'L'), ::cg.forcepowerSelect);
- saved_game.write_chunk(
- INT_ID('I', 'V', 'S', 'L'),
- ::cg.inventorySelect);
+ saved_game.write_chunk(INT_ID('I', 'V', 'S', 'L'), ::cg.inventorySelect);
}
-void CG_ReadTheEvilCGHackStuff()
-{
- ojk::SavedGameHelper saved_game(
- ::gi.saved_game);
+void CG_ReadTheEvilCGHackStuff() {
+ ojk::SavedGameHelper saved_game(::gi.saved_game);
- saved_game.read_chunk(
- INT_ID('F', 'P', 'S', 'L'),
- ::gi_cg_forcepowerSelect);
+ saved_game.read_chunk(INT_ID('F', 'P', 'S', 'L'), ::gi_cg_forcepowerSelect);
- saved_game.read_chunk(
- INT_ID('I', 'V', 'S', 'L'),
- ::gi_cg_inventorySelect);
+ saved_game.read_chunk(INT_ID('I', 'V', 'S', 'L'), ::gi_cg_inventorySelect);
gbUseTheseValuesFromLoadSave = qtrue;
}
@@ -1940,72 +1702,60 @@ Ghoul2 Insert Start
*/
// initialise the cg_entities structure
-void CG_Init_CG(void)
-{
- memset( &cg, 0, sizeof(cg));
-}
-
-
-#define MAX_MISC_ENTS 2000
-
-typedef struct cgMiscEntData_s
-{
- char model[MAX_QPATH];
- qhandle_t hModel;
- vec3_t origin;
- vec3_t angles;
- vec3_t scale;
- float radius;
- float zOffset; //some models need a z offset for culling, because of stupid wrong model origins
+void CG_Init_CG(void) { memset(&cg, 0, sizeof(cg)); }
+
+#define MAX_MISC_ENTS 2000
+
+typedef struct cgMiscEntData_s {
+ char model[MAX_QPATH];
+ qhandle_t hModel;
+ vec3_t origin;
+ vec3_t angles;
+ vec3_t scale;
+ float radius;
+ float zOffset; // some models need a z offset for culling, because of stupid wrong model origins
} cgMiscEntData_t;
-static cgMiscEntData_t MiscEnts[MAX_MISC_ENTS]; //statically allocated for now.
-static int NumMiscEnts=0;
+static cgMiscEntData_t MiscEnts[MAX_MISC_ENTS]; // statically allocated for now.
+static int NumMiscEnts = 0;
-void CG_CreateMiscEntFromGent(gentity_t *ent, const vec3_t scale, float zOff)
-{ //store the model data
- if (NumMiscEnts == MAX_MISC_ENTS)
- {
- Com_Error(ERR_DROP,"Maximum misc_model_static reached (%d)\n",MAX_MISC_ENTS);
+void CG_CreateMiscEntFromGent(gentity_t *ent, const vec3_t scale, float zOff) { // store the model data
+ if (NumMiscEnts == MAX_MISC_ENTS) {
+ Com_Error(ERR_DROP, "Maximum misc_model_static reached (%d)\n", MAX_MISC_ENTS);
return;
}
- if (!ent || !ent->model || !ent->model[0])
- {
+ if (!ent || !ent->model || !ent->model[0]) {
Com_Error(ERR_DROP, "misc_model_static with no model.");
return;
}
const size_t len = strlen(ent->model);
- if (len < 4 || Q_stricmp(&ent->model[len-4],".md3")!=0)
- {
- Com_Error(ERR_DROP, "misc_model_static model(%s) is not an md3.",ent->model);
+ if (len < 4 || Q_stricmp(&ent->model[len - 4], ".md3") != 0) {
+ Com_Error(ERR_DROP, "misc_model_static model(%s) is not an md3.", ent->model);
return;
}
- cgMiscEntData_t *MiscEnt = &MiscEnts[NumMiscEnts++];
+ cgMiscEntData_t *MiscEnt = &MiscEnts[NumMiscEnts++];
memset(MiscEnt, 0, sizeof(*MiscEnt));
strcpy(MiscEnt->model, ent->model);
- VectorCopy(ent->s.angles, MiscEnt->angles);
- VectorCopy(scale, MiscEnt->scale);
- VectorCopy(ent->s.origin, MiscEnt->origin);
+ VectorCopy(ent->s.angles, MiscEnt->angles);
+ VectorCopy(scale, MiscEnt->scale);
+ VectorCopy(ent->s.origin, MiscEnt->origin);
MiscEnt->zOffset = zOff;
}
-#define VectorScaleVector(a,b,c) (((c)[0]=(a)[0]*(b)[0]),((c)[1]=(a)[1]*(b)[1]),((c)[2]=(a)[2]*(b)[2]))
-//call on standard model load to spawn the queued stuff
-void CG_CreateMiscEnts(void)
-{
- vec3_t mins, maxs;
+#define VectorScaleVector(a, b, c) (((c)[0] = (a)[0] * (b)[0]), ((c)[1] = (a)[1] * (b)[1]), ((c)[2] = (a)[2] * (b)[2]))
+// call on standard model load to spawn the queued stuff
+void CG_CreateMiscEnts(void) {
+ vec3_t mins, maxs;
int i;
- for (i=0; i < NumMiscEnts; i++)
- {
- cgMiscEntData_t *MiscEnt = &MiscEnts[i];
+ for (i = 0; i < NumMiscEnts; i++) {
+ cgMiscEntData_t *MiscEnt = &MiscEnts[i];
MiscEnt->hModel = cgi_R_RegisterModel(MiscEnt->model);
- if (MiscEnt->hModel == 0)
- {
- Com_Error(ERR_DROP, "misc_model_static failed to load model '%s'",MiscEnt->model);
+ if (MiscEnt->hModel == 0) {
+ Com_Error(ERR_DROP, "misc_model_static failed to load model '%s'", MiscEnt->model);
continue;
}
@@ -2017,30 +1767,27 @@ void CG_CreateMiscEnts(void)
}
}
-void CG_DrawMiscEnts(void)
-{
- int i;
- cgMiscEntData_t *MiscEnt = MiscEnts;
- refEntity_t refEnt;
- vec3_t difference;
- vec3_t cullOrigin;
+void CG_DrawMiscEnts(void) {
+ int i;
+ cgMiscEntData_t *MiscEnt = MiscEnts;
+ refEntity_t refEnt;
+ vec3_t difference;
+ vec3_t cullOrigin;
- memset (&refEnt, 0, sizeof(refEnt));
+ memset(&refEnt, 0, sizeof(refEnt));
refEnt.reType = RT_MODEL;
refEnt.frame = 0;
refEnt.renderfx = RF_LIGHTING_ORIGIN;
- for(i=0;iorigin, cullOrigin);
- cullOrigin[2] += MiscEnt->zOffset+1.0f;
+ cullOrigin[2] += MiscEnt->zOffset + 1.0f;
- if (gi.inPVS(cg.refdef.vieworg, cullOrigin))
- {
+ if (gi.inPVS(cg.refdef.vieworg, cullOrigin)) {
VectorSubtract(MiscEnt->origin, cg.refdef.vieworg, difference);
- if (VectorLengthSquared(difference)-(MiscEnt->radius) <= 8192*8192/*RMG_distancecull.value*/)
- { //fixme: need access to the real cull dist here
+ if (VectorLengthSquared(difference) - (MiscEnt->radius) <= 8192 * 8192 /*RMG_distancecull.value*/) { // fixme: need access to the real cull dist
+ // here
refEnt.hModel = MiscEnt->hModel;
- AnglesToAxis( MiscEnt->angles, refEnt.axis );
+ AnglesToAxis(MiscEnt->angles, refEnt.axis);
VectorCopy(MiscEnt->scale, refEnt.modelScale);
VectorCopy(MiscEnt->origin, refEnt.origin);
VectorCopy(cullOrigin, refEnt.lightingOrigin);
@@ -2052,19 +1799,16 @@ void CG_DrawMiscEnts(void)
}
}
-void CG_TransitionPermanent(void)
-{
- centity_t *cent = cg_entities;
- int i;
+void CG_TransitionPermanent(void) {
+ centity_t *cent = cg_entities;
+ int i;
cg_numpermanents = 0;
- for(i=0;icurrentState))
- {
+ for (i = 0; i < MAX_GENTITIES; i++, cent++) {
+ if (cgi_GetDefaultState(i, ¢->currentState)) {
cent->nextState = ¢->currentState;
- VectorCopy (cent->currentState.origin, cent->lerpOrigin);
- VectorCopy (cent->currentState.angles, cent->lerpAngles);
+ VectorCopy(cent->currentState.origin, cent->lerpOrigin);
+ VectorCopy(cent->currentState.angles, cent->lerpAngles);
cent->currentValid = qtrue;
cg_permanents[cg_numpermanents++] = cent;
@@ -2076,7 +1820,6 @@ void CG_TransitionPermanent(void)
Ghoul2 Insert End
*/
-
/*
=================
CG_PreInit
@@ -2087,12 +1830,12 @@ Called when DLL loads (after subsystem restart, but before gamestate is received
void CG_PreInit() {
CG_Init_CG();
- memset( &cgs, 0, sizeof( cgs ) );
+ memset(&cgs, 0, sizeof(cgs));
iCGResetCount = 0;
CG_RegisterCvars();
-//moved from CG_GameStateReceived because it's loaded sooner now
+ // moved from CG_GameStateReceived because it's loaded sooner now
CG_InitLocalEntities();
CG_InitMarkPolys();
@@ -2105,61 +1848,59 @@ CG_Init
Called after every level change or subsystem restart
=================
*/
-void CG_Init( int serverCommandSequence ) {
+void CG_Init(int serverCommandSequence) {
cgs.serverCommandSequence = serverCommandSequence;
- cgi_Cvar_Set( "cg_drawHUD", "1" );
+ cgi_Cvar_Set("cg_drawHUD", "1");
// fonts...
//
cgs.media.charsetShader = cgi_R_RegisterShaderNoMip("gfx/2d/charsgrid_med");
cgs.media.qhFontSmall = cgi_R_RegisterFont("ocr_a");
- cgs.media.qhFontMedium= cgi_R_RegisterFont("ergoec");
-
- cgs.media.whiteShader = cgi_R_RegisterShader( "white" );
- cgs.media.loadTick = cgi_R_RegisterShaderNoMip( "gfx/hud/load_tick" );
- cgs.media.loadTickCap = cgi_R_RegisterShaderNoMip( "gfx/hud/load_tick_cap" );
-
- const char *force_icon_files[NUM_FORCE_POWERS] =
- {//icons matching enums forcePowers_t
- "gfx/mp/f_icon_lt_heal", //FP_HEAL,
- "gfx/mp/f_icon_levitation", //FP_LEVITATION,
- "gfx/mp/f_icon_speed", //FP_SPEED,
- "gfx/mp/f_icon_push", //FP_PUSH,
- "gfx/mp/f_icon_pull", //FP_PULL,
- "gfx/mp/f_icon_lt_telepathy", //FP_TELEPATHY,
- "gfx/mp/f_icon_dk_grip", //FP_GRIP,
- "gfx/mp/f_icon_dk_l1", //FP_LIGHTNING,
- "gfx/mp/f_icon_saber_throw", //FP_SABERTHROW
- "gfx/mp/f_icon_saber_defend", //FP_SABERDEFEND,
- "gfx/mp/f_icon_saber_attack", //FP_SABERATTACK,
- "gfx/mp/f_icon_dk_rage", //FP_RAGE,
- "gfx/mp/f_icon_lt_protect", //FP_PROTECT,
- "gfx/mp/f_icon_lt_absorb", //FP_ABSORB,
- "gfx/mp/f_icon_dk_drain", //FP_DRAIN,
- "gfx/mp/f_icon_sight", //FP_SEE,
+ cgs.media.qhFontMedium = cgi_R_RegisterFont("ergoec");
+
+ cgs.media.whiteShader = cgi_R_RegisterShader("white");
+ cgs.media.loadTick = cgi_R_RegisterShaderNoMip("gfx/hud/load_tick");
+ cgs.media.loadTickCap = cgi_R_RegisterShaderNoMip("gfx/hud/load_tick_cap");
+
+ const char *force_icon_files[NUM_FORCE_POWERS] = {
+ // icons matching enums forcePowers_t
+ "gfx/mp/f_icon_lt_heal", // FP_HEAL,
+ "gfx/mp/f_icon_levitation", // FP_LEVITATION,
+ "gfx/mp/f_icon_speed", // FP_SPEED,
+ "gfx/mp/f_icon_push", // FP_PUSH,
+ "gfx/mp/f_icon_pull", // FP_PULL,
+ "gfx/mp/f_icon_lt_telepathy", // FP_TELEPATHY,
+ "gfx/mp/f_icon_dk_grip", // FP_GRIP,
+ "gfx/mp/f_icon_dk_l1", // FP_LIGHTNING,
+ "gfx/mp/f_icon_saber_throw", // FP_SABERTHROW
+ "gfx/mp/f_icon_saber_defend", // FP_SABERDEFEND,
+ "gfx/mp/f_icon_saber_attack", // FP_SABERATTACK,
+ "gfx/mp/f_icon_dk_rage", // FP_RAGE,
+ "gfx/mp/f_icon_lt_protect", // FP_PROTECT,
+ "gfx/mp/f_icon_lt_absorb", // FP_ABSORB,
+ "gfx/mp/f_icon_dk_drain", // FP_DRAIN,
+ "gfx/mp/f_icon_sight", // FP_SEE,
};
// Precache inventory icons
- for ( int i=0;ileType = LE_SPRITE;
ex->startTime = cg.time;
ex->endTime = ex->startTime + 51;
- VectorCopy( origin, ex->refEntity.origin );
+ VectorCopy(origin, ex->refEntity.origin);
- ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/misc/nav_node" );
+ ex->refEntity.customShader = cgi_R_RegisterShader("gfx/misc/nav_node");
- float scale = 16.0f;
+ float scale = 16.0f;
- switch ( type )
- {
+ switch (type) {
case NODE_NORMAL:
ex->color[0] = 255;
ex->color[1] = 255;
@@ -2246,9 +1984,8 @@ CG_DrawRadius
-------------------------
*/
-void CG_DrawRadius( vec3_t origin, unsigned int radius, int type )
-{
- localEntity_t *ex;
+void CG_DrawRadius(vec3_t origin, unsigned int radius, int type) {
+ localEntity_t *ex;
ex = CG_AllocLocalEntity();
@@ -2256,12 +1993,11 @@ void CG_DrawRadius( vec3_t origin, unsigned int radius, int type )
ex->radius = radius;
ex->startTime = cg.time;
ex->endTime = ex->startTime + 51;
- VectorCopy( origin, ex->refEntity.origin );
+ VectorCopy(origin, ex->refEntity.origin);
- ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/misc/nav_radius" );
+ ex->refEntity.customShader = cgi_R_RegisterShader("gfx/misc/nav_radius");
- switch ( type )
- {
+ switch (type) {
case NODE_NORMAL:
ex->color[0] = 255;
ex->color[1] = 255;
@@ -2294,184 +2030,127 @@ CG_DrawEdge
-------------------------
*/
-void CG_DrawEdge( vec3_t start, vec3_t end, int type )
-{
- switch ( type )
- {
+void CG_DrawEdge(vec3_t start, vec3_t end, int type) {
+ switch (type) {
// NAVIGATION EDGES BETWEEN POINTS
//=====================================
- case EDGE_NORMAL:
- {
- FX_AddLine( start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, 51, cgi_R_RegisterShader( "gfx/misc/nav_line" ), 0 );
- }
- break;
- case EDGE_LARGE:
- {
- FX_AddLine( start, end, 8.0f, 15.0f, 0.0f, 0.5f, 0.5f, 51, cgi_R_RegisterShader( "gfx/misc/nav_line" ), 0 );
- }
- break;
- case EDGE_BLOCKED:
- {
- vec3_t color = { 255, 0, 0 }; // RED
- FX_AddLine( start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, color, color, 51, cgi_R_RegisterShader( "gfx/misc/nav_line" ), 0 );
- }
- break;
- case EDGE_FLY:
- {
- vec3_t color = { 0, 255, 255 };// GREEN
- FX_AddLine( start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, color, color, 51, cgi_R_RegisterShader( "gfx/misc/nav_line" ), 0 );
- }
- break;
- case EDGE_JUMP:
- {
- vec3_t color = { 0, 0, 255 }; // BLUE
- FX_AddLine( start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, color, color, 51, cgi_R_RegisterShader( "gfx/misc/nav_line" ), 0 );
- }
- break;
-
-
+ case EDGE_NORMAL: {
+ FX_AddLine(start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, 51, cgi_R_RegisterShader("gfx/misc/nav_line"), 0);
+ } break;
+ case EDGE_LARGE: {
+ FX_AddLine(start, end, 8.0f, 15.0f, 0.0f, 0.5f, 0.5f, 51, cgi_R_RegisterShader("gfx/misc/nav_line"), 0);
+ } break;
+ case EDGE_BLOCKED: {
+ vec3_t color = {255, 0, 0}; // RED
+ FX_AddLine(start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, color, color, 51, cgi_R_RegisterShader("gfx/misc/nav_line"), 0);
+ } break;
+ case EDGE_FLY: {
+ vec3_t color = {0, 255, 255}; // GREEN
+ FX_AddLine(start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, color, color, 51, cgi_R_RegisterShader("gfx/misc/nav_line"), 0);
+ } break;
+ case EDGE_JUMP: {
+ vec3_t color = {0, 0, 255}; // BLUE
+ FX_AddLine(start, end, 8.0f, 4.0f, 0.0f, 0.5f, 0.5f, color, color, 51, cgi_R_RegisterShader("gfx/misc/nav_line"), 0);
+ } break;
// EDGE NODES
//=====================================
- case EDGE_NODE_NORMAL:
- {
- vec3_t color = { 155, 155, 155 };
- FX_AddLine( start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_NODE_FLOATING:
- {
- vec3_t color = { 155, 155, 0 };
- FX_AddLine( start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_NODE_GOAL:
- {
- vec3_t color = { 0, 0, 155 };
- FX_AddLine( start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_NODE_COMBAT:
- {
- vec3_t color = { 155, 0, 0 };
- FX_AddLine( start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
-
-
-
+ case EDGE_NODE_NORMAL: {
+ vec3_t color = {155, 155, 155};
+ FX_AddLine(start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_NODE_FLOATING: {
+ vec3_t color = {155, 155, 0};
+ FX_AddLine(start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_NODE_GOAL: {
+ vec3_t color = {0, 0, 155};
+ FX_AddLine(start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_NODE_COMBAT: {
+ vec3_t color = {155, 0, 0};
+ FX_AddLine(start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
// NEAREST NAV
//=====================================
- case EDGE_NEARESTVALID:
- {
- vec3_t color = { 155, 155, 155 }; // WHITE
- FX_AddLine( -1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0, 0 );
- }
- break;
-
- case EDGE_NEARESTINVALID:
- {
- vec3_t color = { 155, 0, 0 }; // WHITE
- FX_AddLine( -1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0, 0 );
- }
- break;
+ case EDGE_NEARESTVALID: {
+ vec3_t color = {155, 155, 155}; // WHITE
+ FX_AddLine(-1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0, 0);
+ } break;
+ case EDGE_NEARESTINVALID: {
+ vec3_t color = {155, 0, 0}; // WHITE
+ FX_AddLine(-1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0, 0);
+ } break;
// NEAREST NAV CELLS
//=====================================
- case EDGE_CELL:
- {
- vec3_t color = { 155, 155, 155 }; // WHITE
- FX_AddLine( -1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0, 0 );
- }
- break;
- case EDGE_CELL_EMPTY:
- {
- vec3_t color = { 255, 0, 0 }; // RED
- FX_AddLine( -1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0, 0 );
- }
- break;
-
+ case EDGE_CELL: {
+ vec3_t color = {155, 155, 155}; // WHITE
+ FX_AddLine(-1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0, 0);
+ } break;
+ case EDGE_CELL_EMPTY: {
+ vec3_t color = {255, 0, 0}; // RED
+ FX_AddLine(-1, start, end, 1.0f, 1.0f, 0, 1.0f, 1.0f, FX_ALPHA_LINEAR, color, color, 0, 51, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0, 0);
+ } break;
// ACTOR PATHS
//=============
- case EDGE_PATH:
- {
- vec3_t color = { 0, 0, 155 }; // WHITE
- FX_AddLine( start, end, 5.0f, 5.0f, 0.0f, 0.5f, 0.5f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/nav_arrow_new" ), 0 );
- }
+ case EDGE_PATH: {
+ vec3_t color = {0, 0, 155}; // WHITE
+ FX_AddLine(start, end, 5.0f, 5.0f, 0.0f, 0.5f, 0.5f, color, color, 151, cgi_R_RegisterShader("gfx/misc/nav_arrow_new"), 0);
+ } break;
+
+ case EDGE_PATHBLOCKED: {
+ vec3_t color = {255, 0, 0}; // RED
+ FX_AddLine(start, end, 5.0f, 5.0f, 0.0f, 0.5f, 0.5f, color, color, 151, cgi_R_RegisterShader("gfx/misc/nav_arrow_new"), 0);
break;
+ }
- case EDGE_PATHBLOCKED:
- {
- vec3_t color = { 255, 0, 0 }; // RED
- FX_AddLine( start, end, 5.0f, 5.0f, 0.0f, 0.5f, 0.5f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/nav_arrow_new" ), 0 );
- break;
- }
-
- case EDGE_FOLLOWPOS:
- {
- vec3_t color = { 0, 255, 0 }; // GREEN
- FX_AddLine( start, end, 5.0f, 5.0f, 0.0f, 0.5f, 0.5f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/nav_arrow_new" ), 0 );
- break;
- }
-
+ case EDGE_FOLLOWPOS: {
+ vec3_t color = {0, 255, 0}; // GREEN
+ FX_AddLine(start, end, 5.0f, 5.0f, 0.0f, 0.5f, 0.5f, color, color, 151, cgi_R_RegisterShader("gfx/misc/nav_arrow_new"), 0);
+ break;
+ }
// STEERING
//=====================================
- case EDGE_IMPACT_SAFE:
- {
- vec3_t color = { 155, 155, 155 }; // WHITE
- FX_AddLine( start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_IMPACT_POSSIBLE:
- {
- vec3_t color = { 255, 0, 0 }; // RED
- FX_AddLine( start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_VELOCITY:
- {
- vec3_t color = { 0, 255, 0 }; // GREEN
- FX_AddLine( start, end, 4.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_THRUST:
- {
- vec3_t color = { 0, 0, 255 }; // BLUE
- FX_AddLine( start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
-
+ case EDGE_IMPACT_SAFE: {
+ vec3_t color = {155, 155, 155}; // WHITE
+ FX_AddLine(start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_IMPACT_POSSIBLE: {
+ vec3_t color = {255, 0, 0}; // RED
+ FX_AddLine(start, end, 2.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_VELOCITY: {
+ vec3_t color = {0, 255, 0}; // GREEN
+ FX_AddLine(start, end, 4.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_THRUST: {
+ vec3_t color = {0, 0, 255}; // BLUE
+ FX_AddLine(start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 151, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
// MISC Colored Lines
//=====================================
- case EDGE_WHITE_ONESECOND:
- {
- vec3_t color = { 155, 155, 155 }; // WHITE
- FX_AddLine( start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 1051, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_WHITE_TWOSECOND:
- {
- vec3_t color = { 155, 155, 155 }; // WHITE
- FX_AddLine( start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 1051, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_RED_ONESECOND:
- {
- vec3_t color = { 255, 0, 0 }; // RED
- FX_AddLine( start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 2051, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
- case EDGE_RED_TWOSECOND:
- {
- vec3_t color = { 255, 0, 0 }; // RED
- FX_AddLine( start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 2051, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), 0 );
- }
- break;
+ case EDGE_WHITE_ONESECOND: {
+ vec3_t color = {155, 155, 155}; // WHITE
+ FX_AddLine(start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 1051, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_WHITE_TWOSECOND: {
+ vec3_t color = {155, 155, 155}; // WHITE
+ FX_AddLine(start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 1051, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_RED_ONESECOND: {
+ vec3_t color = {255, 0, 0}; // RED
+ FX_AddLine(start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 2051, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
+ case EDGE_RED_TWOSECOND: {
+ vec3_t color = {255, 0, 0}; // RED
+ FX_AddLine(start, end, 3.0f, 1.0f, 0.0f, 1.0f, 1.0f, color, color, 2051, cgi_R_RegisterShader("gfx/misc/whiteline2"), 0);
+ } break;
default:
break;
@@ -2484,9 +2163,8 @@ CG_DrawCombatPoint
-------------------------
*/
-void CG_DrawCombatPoint( vec3_t origin, int type )
-{
- localEntity_t *ex;
+void CG_DrawCombatPoint(vec3_t origin, int type) {
+ localEntity_t *ex;
ex = CG_AllocLocalEntity();
@@ -2494,23 +2172,23 @@ void CG_DrawCombatPoint( vec3_t origin, int type )
ex->startTime = cg.time;
ex->radius = 8;
ex->endTime = ex->startTime + 51;
- VectorCopy( origin, ex->refEntity.origin );
+ VectorCopy(origin, ex->refEntity.origin);
- ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/misc/nav_cpoint" );
+ ex->refEntity.customShader = cgi_R_RegisterShader("gfx/misc/nav_cpoint");
ex->color[0] = 255;
- ex->color[1] = 0;
- ex->color[2] = 255;
-
-/*
- switch( type )
- {
- case 0: //FIXME: To shut up the compiler warning (more will be added here later of course)
- default:
- FX_AddSprite( origin, NULL, NULL, 8.0f, 0.0f, 1.0f, 1.0f, color, color, 0.0f, 0.0f, 51, cgi_R_RegisterShader( "gfx/misc/nav_cpoint" ) );
- break;
- }
-*/
+ ex->color[1] = 0;
+ ex->color[2] = 255;
+
+ /*
+ switch( type )
+ {
+ case 0: //FIXME: To shut up the compiler warning (more will be added here later of course)
+ default:
+ FX_AddSprite( origin, NULL, NULL, 8.0f, 0.0f, 1.0f, 1.0f, color, color, 0.0f, 0.0f, 51, cgi_R_RegisterShader( "gfx/misc/nav_cpoint" ) );
+ break;
+ }
+ */
}
/*
@@ -2519,226 +2197,194 @@ CG_DrawAlert
-------------------------
*/
-void CG_DrawAlert( vec3_t origin, float rating )
-{
- vec3_t drawPos;
+void CG_DrawAlert(vec3_t origin, float rating) {
+ vec3_t drawPos;
- VectorCopy( origin, drawPos );
+ VectorCopy(origin, drawPos);
drawPos[2] += 48;
- vec3_t startRGB;
+ vec3_t startRGB;
- //Fades from green at 0, to red at 1
+ // Fades from green at 0, to red at 1
startRGB[0] = rating;
startRGB[1] = 1 - rating;
startRGB[2] = 0;
- FX_AddSprite( drawPos, NULL, NULL, 16, 0.0f, 1.0f, 1.0f, startRGB, startRGB, 0, 0, 50, cgs.media.whiteShader );
+ FX_AddSprite(drawPos, NULL, NULL, 16, 0.0f, 1.0f, 1.0f, startRGB, startRGB, 0, 0, 50, cgs.media.whiteShader);
}
-
-#define MAX_MENUDEFFILE 4096
+#define MAX_MENUDEFFILE 4096
//
// ==============================
// new hud stuff ( mission pack )
// ==============================
//
-qboolean CG_Asset_Parse(const char **p)
-{
+qboolean CG_Asset_Parse(const char **p) {
const char *token;
const char *tempStr;
int pointSize;
token = COM_ParseExt(p, qtrue);
- if (!token)
- {
+ if (!token) {
return qfalse;
}
- if (Q_stricmp(token, "{") != 0)
- {
+ if (Q_stricmp(token, "{") != 0) {
return qfalse;
}
- while ( 1 )
- {
+ while (1) {
token = COM_ParseExt(p, qtrue);
- if (!token)
- {
+ if (!token) {
return qfalse;
}
- if (Q_stricmp(token, "}") == 0)
- {
+ if (Q_stricmp(token, "}") == 0) {
return qtrue;
}
// font
- if (Q_stricmp(token, "font") == 0)
- {
-/*
- int pointSize;
+ if (Q_stricmp(token, "font") == 0) {
+ /*
+ int pointSize;
- cgi_UI_Parse_String(tempStr);
- cgi_UI_Parse_Int(&pointSize);
+ cgi_UI_Parse_String(tempStr);
+ cgi_UI_Parse_Int(&pointSize);
- if (!tempStr || !pointSize)
- {
- return qfalse;
- }
-*/
-// cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.textFont);
+ if (!tempStr || !pointSize)
+ {
+ return qfalse;
+ }
+ */
+ // cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.textFont);
continue;
}
// smallFont
- if (Q_stricmp(token, "smallFont") == 0)
- {
- if (!COM_ParseString(p, &tempStr) || !COM_ParseInt(p, &pointSize))
- {
+ if (Q_stricmp(token, "smallFont") == 0) {
+ if (!COM_ParseString(p, &tempStr) || !COM_ParseInt(p, &pointSize)) {
return qfalse;
}
-// cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont);
+ // cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont);
continue;
}
// smallFont - because the HUD file needs it for MP.
- if (Q_stricmp(token, "small2Font") == 0)
- {
- if (!COM_ParseString(p, &tempStr) || !COM_ParseInt(p, &pointSize))
- {
+ if (Q_stricmp(token, "small2Font") == 0) {
+ if (!COM_ParseString(p, &tempStr) || !COM_ParseInt(p, &pointSize)) {
return qfalse;
}
-// cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont);
+ // cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont);
continue;
}
// font
- if (Q_stricmp(token, "bigfont") == 0)
- {
+ if (Q_stricmp(token, "bigfont") == 0) {
int pointSize;
- if (!COM_ParseString(p, &tempStr) || !COM_ParseInt(p, &pointSize))
- {
+ if (!COM_ParseString(p, &tempStr) || !COM_ParseInt(p, &pointSize)) {
return qfalse;
}
-// cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.bigFont);
+ // cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.bigFont);
continue;
}
// gradientbar
- if (Q_stricmp(token, "gradientbar") == 0)
- {
- if (!COM_ParseString(p, &tempStr))
- {
+ if (Q_stricmp(token, "gradientbar") == 0) {
+ if (!COM_ParseString(p, &tempStr)) {
return qfalse;
}
-// cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr);
+ // cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr);
continue;
}
// enterMenuSound
- if (Q_stricmp(token, "menuEnterSound") == 0)
- {
- if (!COM_ParseString(p, &tempStr))
- {
+ if (Q_stricmp(token, "menuEnterSound") == 0) {
+ if (!COM_ParseString(p, &tempStr)) {
return qfalse;
}
-// cgDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr );
+ // cgDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr );
continue;
}
// exitMenuSound
- if (Q_stricmp(token, "menuExitSound") == 0)
- {
- if (!COM_ParseString(p, &tempStr))
- {
+ if (Q_stricmp(token, "menuExitSound") == 0) {
+ if (!COM_ParseString(p, &tempStr)) {
return qfalse;
}
-// cgDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr );
+ // cgDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr );
continue;
}
// itemFocusSound
- if (Q_stricmp(token, "itemFocusSound") == 0)
- {
- if (!COM_ParseString(p, &tempStr))
- {
+ if (Q_stricmp(token, "itemFocusSound") == 0) {
+ if (!COM_ParseString(p, &tempStr)) {
return qfalse;
}
-// cgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr );
+ // cgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr );
continue;
}
// menuBuzzSound
- if (Q_stricmp(token, "menuBuzzSound") == 0)
- {
- if (!COM_ParseString(p, &tempStr))
- {
+ if (Q_stricmp(token, "menuBuzzSound") == 0) {
+ if (!COM_ParseString(p, &tempStr)) {
return qfalse;
}
-// cgDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr );
+ // cgDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr );
continue;
}
- if (Q_stricmp(token, "cursor") == 0)
- {
-// if (!COM_ParseString(p, &cgDC.Assets.cursorStr))
-// {
-// return qfalse;
-// }
-// cgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr);
+ if (Q_stricmp(token, "cursor") == 0) {
+ // if (!COM_ParseString(p, &cgDC.Assets.cursorStr))
+ // {
+ // return qfalse;
+ // }
+ // cgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr);
continue;
}
- if (Q_stricmp(token, "fadeClamp") == 0)
- {
-// if (!COM_ParseFloat(p, &cgDC.Assets.fadeClamp))
-// {
-// return qfalse;
-// }
+ if (Q_stricmp(token, "fadeClamp") == 0) {
+ // if (!COM_ParseFloat(p, &cgDC.Assets.fadeClamp))
+ // {
+ // return qfalse;
+ // }
continue;
}
- if (Q_stricmp(token, "fadeCycle") == 0)
- {
-// if (!COM_ParseInt(p, &cgDC.Assets.fadeCycle))
-// {
-// return qfalse;
-// }
+ if (Q_stricmp(token, "fadeCycle") == 0) {
+ // if (!COM_ParseInt(p, &cgDC.Assets.fadeCycle))
+ // {
+ // return qfalse;
+ // }
continue;
}
- if (Q_stricmp(token, "fadeAmount") == 0)
- {
-// if (!COM_ParseFloat(p, &cgDC.Assets.fadeAmount))
-// {
-// return qfalse;
-// }
+ if (Q_stricmp(token, "fadeAmount") == 0) {
+ // if (!COM_ParseFloat(p, &cgDC.Assets.fadeAmount))
+ // {
+ // return qfalse;
+ // }
continue;
}
- if (Q_stricmp(token, "shadowX") == 0)
- {
-// if (!COM_ParseFloat(p, &cgDC.Assets.shadowX))
-// {
-// return qfalse;
-// }
+ if (Q_stricmp(token, "shadowX") == 0) {
+ // if (!COM_ParseFloat(p, &cgDC.Assets.shadowX))
+ // {
+ // return qfalse;
+ // }
continue;
}
- if (Q_stricmp(token, "shadowY") == 0)
- {
-// if (!COM_ParseFloat(p, &cgDC.Assets.shadowY))
-// {
-// return qfalse;
-// }
+ if (Q_stricmp(token, "shadowY") == 0) {
+ // if (!COM_ParseFloat(p, &cgDC.Assets.shadowY))
+ // {
+ // return qfalse;
+ // }
continue;
}
- if (Q_stricmp(token, "shadowColor") == 0)
- {
+ if (Q_stricmp(token, "shadowColor") == 0) {
/*
if (!PC_Color_Parse(handle, &cgDC.Assets.shadowColor))
{
@@ -2759,55 +2405,50 @@ void cgi_UI_EndParseSession(char *buf);
CG_ParseMenu();
=================
*/
-void CG_ParseMenu(const char *menuFile)
-{
- char *token;
- int result;
- char *buf,*p;
+void CG_ParseMenu(const char *menuFile) {
+ char *token;
+ int result;
+ char *buf, *p;
- //Com_Printf("Parsing menu file:%s\n", menuFile);
+ // Com_Printf("Parsing menu file:%s\n", menuFile);
- result = cgi_UI_StartParseSession((char *) menuFile,&buf);
+ result = cgi_UI_StartParseSession((char *)menuFile, &buf);
- if (!result)
- {
+ if (!result) {
Com_Printf("Unable to load hud menu file:%s. Using default ui/testhud.menu.\n", menuFile);
- result = cgi_UI_StartParseSession("ui/testhud.menu",&buf);
- if (!result)
- {
+ result = cgi_UI_StartParseSession("ui/testhud.menu", &buf);
+ if (!result) {
Com_Printf("Unable to load default ui/testhud.menu.\n");
- cgi_UI_EndParseSession (buf);
+ cgi_UI_EndParseSession(buf);
return;
}
}
p = buf;
- while ( 1 )
- {
+ while (1) {
cgi_UI_ParseExt(&token);
- if (!*token) // All done?
+ if (!*token) // All done?
{
break;
}
- //if ( Q_stricmp( token, "{" ) ) {
+ // if ( Q_stricmp( token, "{" ) ) {
// Com_Printf( "Missing { in menu file\n" );
// break;
- //}
+ // }
- //if ( menuCount == MAX_MENUS ) {
+ // if ( menuCount == MAX_MENUS ) {
// Com_Printf( "Too many menus!\n" );
// break;
- //}
+ // }
-// if ( *token == '}' )
-// {
-// break;
-// }
+ // if ( *token == '}' )
+ // {
+ // break;
+ // }
- if (Q_stricmp(token, "assetGlobalDef") == 0)
- {
+ if (Q_stricmp(token, "assetGlobalDef") == 0) {
/*
if (CG_Asset_Parse(handle))
{
@@ -2820,16 +2461,13 @@ void CG_ParseMenu(const char *menuFile)
*/
}
-
- if (Q_stricmp(token, "menudef") == 0)
- {
+ if (Q_stricmp(token, "menudef") == 0) {
// start a new menu
cgi_UI_Menu_New(p);
}
}
cgi_UI_EndParseSession(buf);
-
}
/*
@@ -2838,29 +2476,24 @@ CG_Load_Menu();
=================
*/
-qboolean CG_Load_Menu( const char **p)
-{
+qboolean CG_Load_Menu(const char **p) {
const char *token;
token = COM_ParseExt(p, qtrue);
- if (token[0] != '{')
- {
+ if (token[0] != '{') {
return qfalse;
}
- while ( 1 )
- {
+ while (1) {
token = COM_ParseExt(p, qtrue);
- if (Q_stricmp(token, "}") == 0)
- {
+ if (Q_stricmp(token, "}") == 0) {
return qtrue;
}
- if ( !token || token[0] == 0 )
- {
+ if (!token || token[0] == 0) {
return qfalse;
}
@@ -2875,77 +2508,66 @@ CG_LoadMenus();
=================
*/
-void CG_LoadMenus(const char *menuFile)
-{
- const char *token;
- const char *p;
- int len/*, start*/;
- fileHandle_t f;
+void CG_LoadMenus(const char *menuFile) {
+ const char *token;
+ const char *p;
+ int len /*, start*/;
+ fileHandle_t f;
char buf[MAX_MENUDEFFILE];
- //start = cgi_Milliseconds();
+ // start = cgi_Milliseconds();
- len = cgi_FS_FOpenFile( menuFile, &f, FS_READ );
- if ( !f )
- {
- if ( Q_isanumber( menuFile ) ) // cg_hudFiles 1
- CG_Printf( S_COLOR_GREEN "hud menu file skipped, using default\n" );
+ len = cgi_FS_FOpenFile(menuFile, &f, FS_READ);
+ if (!f) {
+ if (Q_isanumber(menuFile)) // cg_hudFiles 1
+ CG_Printf(S_COLOR_GREEN "hud menu file skipped, using default\n");
else
- CG_Printf( S_COLOR_YELLOW "hud menu file not found: %s, using default\n", menuFile );
+ CG_Printf(S_COLOR_YELLOW "hud menu file not found: %s, using default\n", menuFile);
- len = cgi_FS_FOpenFile( "ui/jahud.txt", &f, FS_READ );
- if (!f)
- {
- cgi_Error( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n" );
+ len = cgi_FS_FOpenFile("ui/jahud.txt", &f, FS_READ);
+ if (!f) {
+ cgi_Error(S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n");
}
}
- if ( len >= MAX_MENUDEFFILE )
- {
- cgi_FS_FCloseFile( f );
- cgi_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", menuFile, len, MAX_MENUDEFFILE ) );
+ if (len >= MAX_MENUDEFFILE) {
+ cgi_FS_FCloseFile(f);
+ cgi_Error(va(S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", menuFile, len, MAX_MENUDEFFILE));
return;
}
- cgi_FS_Read( buf, len, f );
+ cgi_FS_Read(buf, len, f);
buf[len] = 0;
- cgi_FS_FCloseFile( f );
+ cgi_FS_FCloseFile(f);
-// COM_Compress(buf);
+ // COM_Compress(buf);
-// cgi_UI_Menu_Reset();
+ // cgi_UI_Menu_Reset();
p = buf;
COM_BeginParseSession();
- while ( 1 )
- {
- token = COM_ParseExt( &p, qtrue );
- if( !token || token[0] == 0 || token[0] == '}')
- {
+ while (1) {
+ token = COM_ParseExt(&p, qtrue);
+ if (!token || token[0] == 0 || token[0] == '}') {
break;
}
- if ( Q_stricmp( token, "}" ) == 0 )
- {
+ if (Q_stricmp(token, "}") == 0) {
break;
}
- if (Q_stricmp(token, "loadmenu") == 0)
- {
- if (CG_Load_Menu(&p))
- {
+ if (Q_stricmp(token, "loadmenu") == 0) {
+ if (CG_Load_Menu(&p)) {
continue;
- }
- else
- {
+ } else {
break;
}
}
}
COM_EndParseSession();
- //Com_Printf("UI menu load time = %d milli seconds\n", cgi_Milliseconds() - start);
+ // Com_Printf("UI menu load time = %d milli seconds\n", cgi_Milliseconds() - start);
}
/*
@@ -2954,69 +2576,66 @@ CG_LoadHudMenu();
=================
*/
-void CG_LoadHudMenu(void)
-{
+void CG_LoadHudMenu(void) {
const char *hudSet;
-/*
- cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
- cgDC.setColor = &trap_R_SetColor;
- cgDC.drawHandlePic = &CG_DrawPic;
- cgDC.drawStretchPic = &trap_R_DrawStretchPic;
- cgDC.drawText = &CG_Text_Paint;
- cgDC.textWidth = &CG_Text_Width;
- cgDC.textHeight = &CG_Text_Height;
- cgDC.registerModel = &trap_R_RegisterModel;
- cgDC.modelBounds = &trap_R_ModelBounds;
- cgDC.fillRect = &CG_FillRect;
- cgDC.drawRect = &CG_DrawRect;
- cgDC.drawSides = &CG_DrawSides;
- cgDC.drawTopBottom = &CG_DrawTopBottom;
- cgDC.clearScene = &trap_R_ClearScene;
- cgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
- cgDC.renderScene = &trap_R_RenderScene;
- cgDC.registerFont = &trap_R_RegisterFont;
- cgDC.ownerDrawItem = &CG_OwnerDraw;
- cgDC.getValue = &CG_GetValue;
- cgDC.ownerDrawVisible = &CG_OwnerDrawVisible;
- cgDC.runScript = &CG_RunMenuScript;
- cgDC.getTeamColor = &CG_GetTeamColor;
- cgDC.setCVar = trap_Cvar_Set;
- cgDC.getCVarString = trap_Cvar_VariableStringBuffer;
- cgDC.getCVarValue = CG_Cvar_Get;
- cgDC.drawTextWithCursor = &CG_Text_PaintWithCursor;
- cgDC.startLocalSound = &trap_S_StartLocalSound;
- cgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey;
- cgDC.feederCount = &CG_FeederCount;
- cgDC.feederItemImage = &CG_FeederItemImage;
- cgDC.feederItemText = &CG_FeederItemText;
- cgDC.feederSelection = &CG_FeederSelection;
- cgDC.Error = &Com_Error;
- cgDC.Print = &Com_Printf;
- cgDC.ownerDrawWidth = &CG_OwnerDrawWidth;
- cgDC.registerSound = &trap_S_RegisterSound;
- cgDC.startBackgroundTrack = &trap_S_StartBackgroundTrack;
- cgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;
- cgDC.playCinematic = &CG_PlayCinematic;
- cgDC.stopCinematic = &CG_StopCinematic;
- cgDC.drawCinematic = &CG_DrawCinematic;
- cgDC.runCinematicFrame = &CG_RunCinematicFrame;
-*/
-// Init_Display(&cgDC);
-
-// cgi_UI_String_Init();
-
-// cgi_UI_Menu_Reset();
+ /*
+ cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
+ cgDC.setColor = &trap_R_SetColor;
+ cgDC.drawHandlePic = &CG_DrawPic;
+ cgDC.drawStretchPic = &trap_R_DrawStretchPic;
+ cgDC.drawText = &CG_Text_Paint;
+ cgDC.textWidth = &CG_Text_Width;
+ cgDC.textHeight = &CG_Text_Height;
+ cgDC.registerModel = &trap_R_RegisterModel;
+ cgDC.modelBounds = &trap_R_ModelBounds;
+ cgDC.fillRect = &CG_FillRect;
+ cgDC.drawRect = &CG_DrawRect;
+ cgDC.drawSides = &CG_DrawSides;
+ cgDC.drawTopBottom = &CG_DrawTopBottom;
+ cgDC.clearScene = &trap_R_ClearScene;
+ cgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
+ cgDC.renderScene = &trap_R_RenderScene;
+ cgDC.registerFont = &trap_R_RegisterFont;
+ cgDC.ownerDrawItem = &CG_OwnerDraw;
+ cgDC.getValue = &CG_GetValue;
+ cgDC.ownerDrawVisible = &CG_OwnerDrawVisible;
+ cgDC.runScript = &CG_RunMenuScript;
+ cgDC.getTeamColor = &CG_GetTeamColor;
+ cgDC.setCVar = trap_Cvar_Set;
+ cgDC.getCVarString = trap_Cvar_VariableStringBuffer;
+ cgDC.getCVarValue = CG_Cvar_Get;
+ cgDC.drawTextWithCursor = &CG_Text_PaintWithCursor;
+ cgDC.startLocalSound = &trap_S_StartLocalSound;
+ cgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey;
+ cgDC.feederCount = &CG_FeederCount;
+ cgDC.feederItemImage = &CG_FeederItemImage;
+ cgDC.feederItemText = &CG_FeederItemText;
+ cgDC.feederSelection = &CG_FeederSelection;
+ cgDC.Error = &Com_Error;
+ cgDC.Print = &Com_Printf;
+ cgDC.ownerDrawWidth = &CG_OwnerDrawWidth;
+ cgDC.registerSound = &trap_S_RegisterSound;
+ cgDC.startBackgroundTrack = &trap_S_StartBackgroundTrack;
+ cgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;
+ cgDC.playCinematic = &CG_PlayCinematic;
+ cgDC.stopCinematic = &CG_StopCinematic;
+ cgDC.drawCinematic = &CG_DrawCinematic;
+ cgDC.runCinematicFrame = &CG_RunCinematicFrame;
+ */
+ // Init_Display(&cgDC);
+
+ // cgi_UI_String_Init();
+
+ // cgi_UI_Menu_Reset();
hudSet = cg_hudFiles.string;
- if (hudSet[0] == '\0')
- {
+ if (hudSet[0] == '\0') {
hudSet = "ui/jahud.txt";
}
CG_LoadMenus(hudSet);
}
-
/*
==============================================================================
@@ -3030,9 +2649,8 @@ INVENTORY SELECTION
CG_InventorySelectable
===============
*/
-static inline qboolean CG_InventorySelectable( int index)
-{
- if (cg.snap->ps.inventory[index]) // Is there any in the inventory?
+static inline qboolean CG_InventorySelectable(int index) {
+ if (cg.snap->ps.inventory[index]) // Is there any in the inventory?
{
return qtrue;
}
@@ -3040,23 +2658,19 @@ static inline qboolean CG_InventorySelectable( int index)
return qfalse;
}
-
/*
===============
SetInventoryTime
===============
*/
-static inline void SetInventoryTime(void)
-{
+static inline void SetInventoryTime(void) {
if (((cg.weaponSelectTime + WEAPON_SELECT_TIME) > cg.time) || // The Weapon HUD was currently active to just swap it out with Force HUD
- ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) > cg.time)) // The Force HUD was currently active to just swap it out with Force HUD
+ ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) > cg.time)) // The Force HUD was currently active to just swap it out with Force HUD
{
cg.weaponSelectTime = 0;
cg.forcepowerSelectTime = 0;
cg.inventorySelectTime = cg.time + 130.0f;
- }
- else
- {
+ } else {
cg.inventorySelectTime = cg.time;
}
}
@@ -3066,28 +2680,23 @@ static inline void SetInventoryTime(void)
CG_DPPrevInventory_f
===============
*/
-void CG_DPPrevInventory_f( void )
-{
- int i;
+void CG_DPPrevInventory_f(void) {
+ int i;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
const int original = cg.DataPadInventorySelect;
- for ( i = 0 ; i < INV_MAX ; i++ )
- {
+ for (i = 0; i < INV_MAX; i++) {
cg.DataPadInventorySelect--;
- if ((cg.DataPadInventorySelect < INV_ELECTROBINOCULARS) || (cg.DataPadInventorySelect >= INV_MAX))
- {
+ if ((cg.DataPadInventorySelect < INV_ELECTROBINOCULARS) || (cg.DataPadInventorySelect >= INV_MAX)) {
cg.DataPadInventorySelect = (INV_MAX - 1);
}
- if ( CG_InventorySelectable( cg.DataPadInventorySelect ) )
- {
+ if (CG_InventorySelectable(cg.DataPadInventorySelect)) {
return;
}
}
@@ -3099,28 +2708,23 @@ void CG_DPPrevInventory_f( void )
CG_DPNextInventory_f
===============
*/
-void CG_DPNextInventory_f( void )
-{
- int i;
+void CG_DPNextInventory_f(void) {
+ int i;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
const int original = cg.DataPadInventorySelect;
- for ( i = 0 ; i < INV_MAX ; i++ )
- {
+ for (i = 0; i < INV_MAX; i++) {
cg.DataPadInventorySelect++;
- if ((cg.DataPadInventorySelect < INV_ELECTROBINOCULARS) || (cg.DataPadInventorySelect >= INV_MAX))
- {
+ if ((cg.DataPadInventorySelect < INV_ELECTROBINOCULARS) || (cg.DataPadInventorySelect >= INV_MAX)) {
cg.DataPadInventorySelect = INV_ELECTROBINOCULARS;
}
- if ( CG_InventorySelectable( cg.DataPadInventorySelect ) && (inv_icons[cg.DataPadInventorySelect]))
- {
+ if (CG_InventorySelectable(cg.DataPadInventorySelect) && (inv_icons[cg.DataPadInventorySelect])) {
return;
}
}
@@ -3133,38 +2737,32 @@ void CG_DPNextInventory_f( void )
CG_NextInventory_f
===============
*/
-void CG_NextInventory_f( void )
-{
- int i;
- float *color;
+void CG_NextInventory_f(void) {
+ int i;
+ float *color;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
// The first time it's been hit so just show inventory but don't advance in inventory.
- color = CG_FadeColor( cg.inventorySelectTime, WEAPON_SELECT_TIME );
- if ( !color )
- {
+ color = CG_FadeColor(cg.inventorySelectTime, WEAPON_SELECT_TIME);
+ if (!color) {
SetInventoryTime();
return;
}
const int original = cg.inventorySelect;
- for ( i = 0 ; i < INV_MAX ; i++ )
- {
+ for (i = 0; i < INV_MAX; i++) {
cg.inventorySelect++;
- if ((cg.inventorySelect < INV_ELECTROBINOCULARS) || (cg.inventorySelect >= INV_MAX))
- {
+ if ((cg.inventorySelect < INV_ELECTROBINOCULARS) || (cg.inventorySelect >= INV_MAX)) {
cg.inventorySelect = INV_ELECTROBINOCULARS;
}
- if ( CG_InventorySelectable( cg.inventorySelect ) && (inv_icons[cg.inventorySelect]))
- {
- cgi_S_StartSound (NULL, 0, CHAN_AUTO, cgs.media.selectSound2 );
+ if (CG_InventorySelectable(cg.inventorySelect) && (inv_icons[cg.inventorySelect])) {
+ cgi_S_StartSound(NULL, 0, CHAN_AUTO, cgs.media.selectSound2);
SetInventoryTime();
return;
}
@@ -3187,38 +2785,32 @@ this func was moved to Cmd_UseInventory_f in g_cmds.cpp
CG_PrevInventory_f
===============
*/
-void CG_PrevInventory_f( void )
-{
- int i;
- float *color;
+void CG_PrevInventory_f(void) {
+ int i;
+ float *color;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
// The first time it's been hit so just show inventory but don't advance in inventory.
- color = CG_FadeColor( cg.inventorySelectTime, WEAPON_SELECT_TIME );
- if ( !color )
- {
+ color = CG_FadeColor(cg.inventorySelectTime, WEAPON_SELECT_TIME);
+ if (!color) {
SetInventoryTime();
return;
}
const int original = cg.inventorySelect;
- for ( i = 0 ; i < INV_MAX ; i++ )
- {
+ for (i = 0; i < INV_MAX; i++) {
cg.inventorySelect--;
- if ((cg.inventorySelect < INV_ELECTROBINOCULARS) || (cg.inventorySelect >= INV_MAX))
- {
+ if ((cg.inventorySelect < INV_ELECTROBINOCULARS) || (cg.inventorySelect >= INV_MAX)) {
cg.inventorySelect = (INV_MAX - 1);
}
- if ( CG_InventorySelectable( cg.inventorySelect ) && (inv_icons[cg.inventorySelect]))
- {
- cgi_S_StartSound (NULL, 0, CHAN_AUTO, cgs.media.selectSound2 );
+ if (CG_InventorySelectable(cg.inventorySelect) && (inv_icons[cg.inventorySelect])) {
+ cgi_S_StartSound(NULL, 0, CHAN_AUTO, cgs.media.selectSound2);
SetInventoryTime();
return;
}
@@ -3227,19 +2819,17 @@ void CG_PrevInventory_f( void )
cg.inventorySelect = original;
}
-
/*
===================
FindInventoryItemTag
===================
*/
-gitem_t *FindInventoryItemTag(int tag)
-{
- int i;
+gitem_t *FindInventoryItemTag(int tag) {
+ int i;
- for ( i = 1 ; i < bg_numItems ; i++ )
- {
- if ( bg_itemlist[i].giTag == tag && bg_itemlist[i].giType == IT_HOLDABLE ) // I guess giTag's aren't unique amongst items..must also make sure it's a holdable
+ for (i = 1; i < bg_numItems; i++) {
+ if (bg_itemlist[i].giTag == tag &&
+ bg_itemlist[i].giType == IT_HOLDABLE) // I guess giTag's aren't unique amongst items..must also make sure it's a holdable
{
return &bg_itemlist[i];
}
@@ -3248,41 +2838,35 @@ gitem_t *FindInventoryItemTag(int tag)
return (0);
}
-
-
-
/*
===================
CG_DrawInventorySelect
===================
*/
-void CG_DrawInventorySelect( void )
-{
- int i;
- int holdCount,iconCnt;
- int sideLeftIconCnt,sideRightIconCnt;
- int count;
- int holdX;
- //int height;
-// int tag;
- float addX;
- vec4_t textColor = { .312f, .75f, .621f, 1.0f };
- char text[1024]={0};
+void CG_DrawInventorySelect(void) {
+ int i;
+ int holdCount, iconCnt;
+ int sideLeftIconCnt, sideRightIconCnt;
+ int count;
+ int holdX;
+ // int height;
+ // int tag;
+ float addX;
+ vec4_t textColor = {.312f, .75f, .621f, 1.0f};
+ char text[1024] = {0};
// don't display if dead
- if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 || ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ))
- {
+ if (cg.predicted_player_state.stats[STAT_HEALTH] <= 0 || (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD)) {
return;
}
- if ((cg.inventorySelectTime+WEAPON_SELECT_TIME) (2*sideMax)) // Go to the max on each side
+ } else if (count > (2 * sideMax)) // Go to the max on each side
{
sideLeftIconCnt = sideMax;
sideRightIconCnt = sideMax;
- }
- else // Less than max, so do the calc
+ } else // Less than max, so do the calc
{
- sideLeftIconCnt = holdCount/2;
+ sideLeftIconCnt = holdCount / 2;
sideRightIconCnt = holdCount - sideLeftIconCnt;
}
i = cg.inventorySelect - 1;
- if (i<0)
- {
- i = INV_MAX-1;
+ if (i < 0) {
+ i = INV_MAX - 1;
}
const int smallIconSize = 40;
@@ -3345,188 +2923,154 @@ void CG_DrawInventorySelect( void )
// Left side ICONS
// Work backwards from current icon
- holdX = x - ((bigIconSize/2) + pad + smallIconSize);
- //height = smallIconSize * cg.iconHUDPercent;
- addX = (float) smallIconSize * .75;
+ holdX = x - ((bigIconSize / 2) + pad + smallIconSize);
+ // height = smallIconSize * cg.iconHUDPercent;
+ addX = (float)smallIconSize * .75;
- for (iconCnt=0;iconCntps.inventory[i], 6, 12,
- NUM_FONT_SMALL,qfalse);
+ CG_DrawNumField(holdX + addX, y + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, NUM_FONT_SMALL, qfalse);
- holdX -= (smallIconSize+pad);
+ holdX -= (smallIconSize + pad);
}
}
// Current Center Icon
- //height = bigIconSize * cg.iconHUDPercent;
- if (inv_icons[cg.inventorySelect])
- {
+ // height = bigIconSize * cg.iconHUDPercent;
+ if (inv_icons[cg.inventorySelect]) {
cgi_R_SetColor(NULL);
- CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10, bigIconSize, bigIconSize, inv_icons[cg.inventorySelect] );
- addX = (float) bigIconSize * .75;
+ CG_DrawPic(x - (bigIconSize / 2), (y - ((bigIconSize - smallIconSize) / 2)) + 10, bigIconSize, bigIconSize, inv_icons[cg.inventorySelect]);
+ addX = (float)bigIconSize * .75;
cgi_R_SetColor(colorTable[CT_ICON_BLUE]);
- CG_DrawNumField ((x-(bigIconSize/2)) + addX, y, 2, cg.snap->ps.inventory[cg.inventorySelect], 6, 12,
- NUM_FONT_SMALL,qfalse);
+ CG_DrawNumField((x - (bigIconSize / 2)) + addX, y, 2, cg.snap->ps.inventory[cg.inventorySelect], 6, 12, NUM_FONT_SMALL, qfalse);
- if (inv_names[cg.inventorySelect])
- {
+ if (inv_names[cg.inventorySelect]) {
// FIXME: This is ONLY a temp solution, the icon stuff, etc, should all just use items.dat for everything
- gitem_t *item = FindInventoryItemTag( cg.inventorySelect );
+ gitem_t *item = FindInventoryItemTag(cg.inventorySelect);
- if ( item && item->classname && item->classname[0] )
- {
+ if (item && item->classname && item->classname[0]) {
char itemName[256], data[1024]; // FIXME: do these really need to be this large?? does it matter?
- Com_sprintf( itemName, sizeof(itemName), "SP_INGAME_%s", item->classname );
+ Com_sprintf(itemName, sizeof(itemName), "SP_INGAME_%s", item->classname);
- if ( cgi_SP_GetStringTextString( itemName, data, sizeof( data )))
- {
- int w = cgi_R_Font_StrLenPixels( data, cgs.media.qhFontSmall, 1.0f );
- int x = ( SCREEN_WIDTH - w ) / 2;
+ if (cgi_SP_GetStringTextString(itemName, data, sizeof(data))) {
+ int w = cgi_R_Font_StrLenPixels(data, cgs.media.qhFontSmall, 1.0f);
+ int x = (SCREEN_WIDTH - w) / 2;
- cgi_R_Font_DrawString( x, (SCREEN_HEIGHT - 24), data, textColor, cgs.media.qhFontSmall, -1, 1.0f);
+ cgi_R_Font_DrawString(x, (SCREEN_HEIGHT - 24), data, textColor, cgs.media.qhFontSmall, -1, 1.0f);
}
}
}
}
i = cg.inventorySelect + 1;
- if (i> INV_MAX-1)
- {
+ if (i > INV_MAX - 1) {
i = 0;
}
// Right side ICONS
// Work forwards from current icon
- holdX = x + (bigIconSize/2) + pad;
- //height = smallIconSize * cg.iconHUDPercent;
- addX = (float) smallIconSize * .75;
- for (iconCnt=0;iconCnt INV_MAX-1)
- {
+ holdX = x + (bigIconSize / 2) + pad;
+ // height = smallIconSize * cg.iconHUDPercent;
+ addX = (float)smallIconSize * .75;
+ for (iconCnt = 0; iconCnt < sideRightIconCnt; i++) {
+ if (i > INV_MAX - 1) {
i = 0;
}
- if ((!CG_InventorySelectable(i)) || (!inv_icons[i]))
- {
+ if ((!CG_InventorySelectable(i)) || (!inv_icons[i])) {
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (inv_icons[i])
- {
+ if (inv_icons[i]) {
cgi_R_SetColor(NULL);
- CG_DrawPic( holdX, y+10, smallIconSize, smallIconSize, inv_icons[i] );
+ CG_DrawPic(holdX, y + 10, smallIconSize, smallIconSize, inv_icons[i]);
cgi_R_SetColor(colorTable[CT_ICON_BLUE]);
- CG_DrawNumField (holdX + addX, y + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12,
- NUM_FONT_SMALL,qfalse);
+ CG_DrawNumField(holdX + addX, y + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, NUM_FONT_SMALL, qfalse);
- holdX += (smallIconSize+pad);
+ holdX += (smallIconSize + pad);
}
}
}
-int cgi_UI_GetItemText(char *menuFile,char *itemName, char *text);
-
-const char *inventoryDesc[15] =
-{
-"NEURO_SAAV_DESC",
-"BACTA_DESC",
-"INQUISITOR_DESC",
-"LA_GOGGLES_DESC",
-"PORTABLE_SENTRY_DESC",
-"GOODIE_KEY_DESC",
-"SECURITY_KEY_DP_DESC",
-};
+int cgi_UI_GetItemText(char *menuFile, char *itemName, char *text);
+const char *inventoryDesc[15] = {
+ "NEURO_SAAV_DESC", "BACTA_DESC", "INQUISITOR_DESC", "LA_GOGGLES_DESC", "PORTABLE_SENTRY_DESC", "GOODIE_KEY_DESC", "SECURITY_KEY_DP_DESC",
+};
/*
===================
CG_DrawDataPadInventorySelect
===================
*/
-void CG_DrawDataPadInventorySelect( void )
-{
- int i;
- int holdCount,iconCnt;
- int sideLeftIconCnt,sideRightIconCnt;
- int count;
- int holdX;
- //int height;
- float addX;
- char text[1024]={0};
- vec4_t textColor = { .312f, .75f, .621f, 1.0f };
-
+void CG_DrawDataPadInventorySelect(void) {
+ int i;
+ int holdCount, iconCnt;
+ int sideLeftIconCnt, sideRightIconCnt;
+ int count;
+ int holdX;
+ // int height;
+ float addX;
+ char text[1024] = {0};
+ vec4_t textColor = {.312f, .75f, .621f, 1.0f};
// count the number of items owned
count = 0;
- for ( i = 0 ; i < INV_MAX ; i++ )
- {
- if (CG_InventorySelectable(i) && inv_icons[i])
- {
+ for (i = 0; i < INV_MAX; i++) {
+ if (CG_InventorySelectable(i) && inv_icons[i]) {
count++;
}
}
-
- if (!count)
- {
- cgi_SP_GetStringTextString("SP_INGAME_EMPTY_INV",text, sizeof(text) );
- int w = cgi_R_Font_StrLenPixels( text, cgs.media.qhFontSmall, 1.0f );
- int x = ( SCREEN_WIDTH - w ) / 2;
+ if (!count) {
+ cgi_SP_GetStringTextString("SP_INGAME_EMPTY_INV", text, sizeof(text));
+ int w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
+ int x = (SCREEN_WIDTH - w) / 2;
CG_DrawProportionalString(x, 300 + 22, text, CG_CENTER | CG_SMALLFONT, colorTable[CT_ICON_BLUE]);
return;
}
- const int sideMax = 3; // Max number of icons on the side
+ const int sideMax = 3; // Max number of icons on the side
// Calculate how many icons will appear to either side of the center one
- holdCount = count - 1; // -1 for the center icon
- if (holdCount == 0) // No icons to either side
+ holdCount = count - 1; // -1 for the center icon
+ if (holdCount == 0) // No icons to either side
{
sideLeftIconCnt = 0;
sideRightIconCnt = 0;
- }
- else if (count > (2*sideMax)) // Go to the max on each side
+ } else if (count > (2 * sideMax)) // Go to the max on each side
{
sideLeftIconCnt = sideMax;
sideRightIconCnt = sideMax;
- }
- else // Less than max, so do the calc
+ } else // Less than max, so do the calc
{
- sideLeftIconCnt = holdCount/2;
+ sideLeftIconCnt = holdCount / 2;
sideRightIconCnt = holdCount - sideLeftIconCnt;
}
i = cg.DataPadInventorySelect - 1;
- if (i<0)
- {
- i = INV_MAX-1;
+ if (i < 0) {
+ i = INV_MAX - 1;
}
-
const int smallIconSize = 40;
const int bigIconSize = 80;
const int bigPad = 64;
@@ -3535,103 +3079,84 @@ void CG_DrawDataPadInventorySelect( void )
const int centerXPos = 320;
const int graphicYPos = 340;
-
// Left side ICONS
// Work backwards from current icon
- holdX = centerXPos - ((bigIconSize/2) + bigPad + smallIconSize);
- //height = smallIconSize * cg.iconHUDPercent;
- addX = (float) smallIconSize * .75;
+ holdX = centerXPos - ((bigIconSize / 2) + bigPad + smallIconSize);
+ // height = smallIconSize * cg.iconHUDPercent;
+ addX = (float)smallIconSize * .75;
- for (iconCnt=0;iconCntps.inventory[i], 6, 12,
- NUM_FONT_SMALL,qfalse);
+ CG_DrawNumField(holdX + addX, graphicYPos + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, NUM_FONT_SMALL, qfalse);
- holdX -= (smallIconSize+pad);
+ holdX -= (smallIconSize + pad);
}
}
// Current Center Icon
- //height = bigIconSize * cg.iconHUDPercent;
- if (inv_icons[cg.DataPadInventorySelect])
- {
+ // height = bigIconSize * cg.iconHUDPercent;
+ if (inv_icons[cg.DataPadInventorySelect]) {
cgi_R_SetColor(colorTable[CT_WHITE]);
- CG_DrawPic( centerXPos-(bigIconSize/2), (graphicYPos-((bigIconSize-smallIconSize)/2))+10, bigIconSize, bigIconSize, inv_icons[cg.DataPadInventorySelect] );
- addX = (float) bigIconSize * .75;
+ CG_DrawPic(centerXPos - (bigIconSize / 2), (graphicYPos - ((bigIconSize - smallIconSize) / 2)) + 10, bigIconSize, bigIconSize,
+ inv_icons[cg.DataPadInventorySelect]);
+ addX = (float)bigIconSize * .75;
cgi_R_SetColor(colorTable[CT_ICON_BLUE]);
- CG_DrawNumField ((centerXPos-(bigIconSize/2)) + addX, graphicYPos, 2, cg.snap->ps.inventory[cg.DataPadInventorySelect], 6, 12,
- NUM_FONT_SMALL,qfalse);
-
+ CG_DrawNumField((centerXPos - (bigIconSize / 2)) + addX, graphicYPos, 2, cg.snap->ps.inventory[cg.DataPadInventorySelect], 6, 12, NUM_FONT_SMALL,
+ qfalse);
}
i = cg.DataPadInventorySelect + 1;
- if (i> INV_MAX-1)
- {
+ if (i > INV_MAX - 1) {
i = 0;
}
// Right side ICONS
// Work forwards from current icon
- holdX = centerXPos + (bigIconSize/2) + bigPad;
- //height = smallIconSize * cg.iconHUDPercent;
- addX = (float) smallIconSize * .75;
- for (iconCnt=0;iconCnt INV_MAX-1)
- {
+ holdX = centerXPos + (bigIconSize / 2) + bigPad;
+ // height = smallIconSize * cg.iconHUDPercent;
+ addX = (float)smallIconSize * .75;
+ for (iconCnt = 0; iconCnt < sideRightIconCnt; i++) {
+ if (i > INV_MAX - 1) {
i = 0;
}
- if ((!CG_InventorySelectable(i)) || (!inv_icons[i]))
- {
+ if ((!CG_InventorySelectable(i)) || (!inv_icons[i])) {
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (inv_icons[i])
- {
+ if (inv_icons[i]) {
cgi_R_SetColor(colorTable[CT_WHITE]);
- CG_DrawPic( holdX, graphicYPos+10, smallIconSize, smallIconSize, inv_icons[i] );
+ CG_DrawPic(holdX, graphicYPos + 10, smallIconSize, smallIconSize, inv_icons[i]);
cgi_R_SetColor(colorTable[CT_ICON_BLUE]);
- CG_DrawNumField (holdX + addX, graphicYPos + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12,
- NUM_FONT_SMALL,qfalse);
+ CG_DrawNumField(holdX + addX, graphicYPos + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, NUM_FONT_SMALL, qfalse);
- holdX += (smallIconSize+pad);
+ holdX += (smallIconSize + pad);
}
}
// draw the weapon description
- if ((cg.DataPadInventorySelect>=0) && (cg.DataPadInventorySelect<13))
- {
- cgi_SP_GetStringTextString( va("SP_INGAME_%s",inventoryDesc[cg.DataPadInventorySelect]), text, sizeof(text) );
+ if ((cg.DataPadInventorySelect >= 0) && (cg.DataPadInventorySelect < 13)) {
+ cgi_SP_GetStringTextString(va("SP_INGAME_%s", inventoryDesc[cg.DataPadInventorySelect]), text, sizeof(text));
- if (text[0])
- {
- CG_DisplayBoxedText(70,50,500,300,text,
- cgs.media.qhFontSmall,
- 0.7f,
- textColor
- );
+ if (text[0]) {
+ CG_DisplayBoxedText(70, 50, 500, 300, text, cgs.media.qhFontSmall, 0.7f, textColor);
}
}
}
@@ -3641,60 +3166,36 @@ void CG_DrawDataPadInventorySelect( void )
SetForcePowerTime
===============
*/
-void SetForcePowerTime(void)
-{
- if (((cg.weaponSelectTime + WEAPON_SELECT_TIME) > cg.time) || // The Weapon HUD was currently active to just swap it out with Force HUD
- ((cg.inventorySelectTime + WEAPON_SELECT_TIME) > cg.time)) // The Inventory HUD was currently active to just swap it out with Force HUD
+void SetForcePowerTime(void) {
+ if (((cg.weaponSelectTime + WEAPON_SELECT_TIME) > cg.time) || // The Weapon HUD was currently active to just swap it out with Force HUD
+ ((cg.inventorySelectTime + WEAPON_SELECT_TIME) > cg.time)) // The Inventory HUD was currently active to just swap it out with Force HUD
{
cg.weaponSelectTime = 0;
cg.inventorySelectTime = 0;
cg.forcepowerSelectTime = cg.time + 130.0f;
- }
- else
- {
+ } else {
cg.forcepowerSelectTime = cg.time;
}
}
-int showPowers[MAX_SHOWPOWERS] =
-{
- FP_ABSORB,
- FP_HEAL,
- FP_PROTECT,
- FP_TELEPATHY,
+int showPowers[MAX_SHOWPOWERS] = {
+ FP_ABSORB, FP_HEAL, FP_PROTECT, FP_TELEPATHY,
- FP_SPEED,
- FP_PUSH,
- FP_PULL,
- FP_SEE,
+ FP_SPEED, FP_PUSH, FP_PULL, FP_SEE,
- FP_DRAIN,
- FP_LIGHTNING,
- FP_RAGE,
- FP_GRIP,
+ FP_DRAIN, FP_LIGHTNING, FP_RAGE, FP_GRIP,
};
-const char *showPowersName[MAX_SHOWPOWERS] =
-{
- "SP_INGAME_ABSORB2",
- "SP_INGAME_HEAL2",
- "SP_INGAME_PROTECT2",
- "SP_INGAME_MINDTRICK2",
-
- "SP_INGAME_SPEED2",
- "SP_INGAME_PUSH2",
- "SP_INGAME_PULL2",
- "SP_INGAME_SEEING2",
-
- "SP_INGAME_DRAIN2",
- "SP_INGAME_LIGHTNING2",
- "SP_INGAME_DARK_RAGE2",
- "SP_INGAME_GRIP2",
+const char *showPowersName[MAX_SHOWPOWERS] = {
+ "SP_INGAME_ABSORB2", "SP_INGAME_HEAL2", "SP_INGAME_PROTECT2", "SP_INGAME_MINDTRICK2",
+
+ "SP_INGAME_SPEED2", "SP_INGAME_PUSH2", "SP_INGAME_PULL2", "SP_INGAME_SEEING2",
+
+ "SP_INGAME_DRAIN2", "SP_INGAME_LIGHTNING2", "SP_INGAME_DARK_RAGE2", "SP_INGAME_GRIP2",
};
// Keep these with groups light side, core, and dark side
-int showDataPadPowers[MAX_DPSHOWPOWERS] =
-{
+int showDataPadPowers[MAX_DPSHOWPOWERS] = {
// Light side
FP_ABSORB,
FP_HEAL,
@@ -3711,7 +3212,7 @@ int showDataPadPowers[MAX_DPSHOWPOWERS] =
FP_SABER_OFFENSE,
FP_SEE,
- //Dark Side
+ // Dark Side
FP_DRAIN,
FP_LIGHTNING,
FP_RAGE,
@@ -3723,14 +3224,13 @@ int showDataPadPowers[MAX_DPSHOWPOWERS] =
ForcePower_Valid
===============
*/
-qboolean ForcePower_Valid(int index)
-{
- gentity_t *player = &g_entities[0];
+qboolean ForcePower_Valid(int index) {
+ gentity_t *player = &g_entities[0];
- assert (MAX_SHOWPOWERS == ( sizeof(showPowers)/sizeof(showPowers[0]) ));
- assert (index < MAX_SHOWPOWERS ); //is this a valid index?
+ assert(MAX_SHOWPOWERS == (sizeof(showPowers) / sizeof(showPowers[0])));
+ assert(index < MAX_SHOWPOWERS); // is this a valid index?
if (player->client->ps.forcePowersKnown & (1 << showPowers[index]) &&
- player->client->ps.forcePowerLevel[showPowers[index]]) // Does he have the force power?
+ player->client->ps.forcePowerLevel[showPowers[index]]) // Does he have the force power?
{
return qtrue;
}
@@ -3743,36 +3243,31 @@ qboolean ForcePower_Valid(int index)
CG_NextForcePower_f
===============
*/
-void CG_NextForcePower_f( void )
-{
- int i;
+void CG_NextForcePower_f(void) {
+ int i;
- if ( !cg.snap || in_camera )
- {
+ if (!cg.snap || in_camera) {
return;
}
SetForcePowerTime();
- if ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) < cg.time)
- {
+ if ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) < cg.time) {
return;
}
const int original = cg.forcepowerSelect;
- for ( i = 0; i < MAX_SHOWPOWERS; i++ )
- {
+ for (i = 0; i < MAX_SHOWPOWERS; i++) {
cg.forcepowerSelect++;
- if (cg.forcepowerSelect >= MAX_SHOWPOWERS)
- {
+ if (cg.forcepowerSelect >= MAX_SHOWPOWERS) {
cg.forcepowerSelect = 0;
}
- if (ForcePower_Valid(cg.forcepowerSelect)) // Does he have the force power?
+ if (ForcePower_Valid(cg.forcepowerSelect)) // Does he have the force power?
{
- cgi_S_StartSound (NULL, 0, CHAN_AUTO, cgs.media.selectSound2 );
+ cgi_S_StartSound(NULL, 0, CHAN_AUTO, cgs.media.selectSound2);
return;
}
}
@@ -3785,41 +3280,35 @@ void CG_NextForcePower_f( void )
CG_PrevForcePower_f
===============
*/
-void CG_PrevForcePower_f( void )
-{
- int i;
+void CG_PrevForcePower_f(void) {
+ int i;
- if ( !cg.snap || in_camera )
- {
+ if (!cg.snap || in_camera) {
return;
}
SetForcePowerTime();
- if ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) < cg.time)
- {
+ if ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) < cg.time) {
return;
}
const int original = cg.forcepowerSelect;
- for ( i = 0; i < MAX_SHOWPOWERS; i++ )
- {
+ for (i = 0; i < MAX_SHOWPOWERS; i++) {
cg.forcepowerSelect--;
- if (cg.forcepowerSelect < 0)
- {
+ if (cg.forcepowerSelect < 0) {
cg.forcepowerSelect = MAX_SHOWPOWERS - 1;
}
- if (ForcePower_Valid(cg.forcepowerSelect)) // Does he have the force power?
+ if (ForcePower_Valid(cg.forcepowerSelect)) // Does he have the force power?
{
- cgi_S_StartSound (NULL, 0, CHAN_AUTO, cgs.media.selectSound2 );
+ cgi_S_StartSound(NULL, 0, CHAN_AUTO, cgs.media.selectSound2);
return;
}
}
-
cg.forcepowerSelect = original;
}
@@ -3828,24 +3317,21 @@ void CG_PrevForcePower_f( void )
CG_DrawForceSelect
===================
*/
-void CG_DrawForceSelect( void )
-{
- int i;
- int count;
- int holdX;
- int sideLeftIconCnt,sideRightIconCnt;
- int holdCount,iconCnt;
- char text[1024]={0};
- int yOffset = 0;
-
+void CG_DrawForceSelect(void) {
+ int i;
+ int count;
+ int holdX;
+ int sideLeftIconCnt, sideRightIconCnt;
+ int holdCount, iconCnt;
+ char text[1024] = {0};
+ int yOffset = 0;
// don't display if dead
- if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 || ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ))
- {
+ if (cg.predicted_player_state.stats[STAT_HEALTH] <= 0 || (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD)) {
return;
}
- if ((cg.forcepowerSelectTime+WEAPON_SELECT_TIME) (2*sideMax)) // Go to the max on each side
+ } else if (count > (2 * sideMax)) // Go to the max on each side
{
sideLeftIconCnt = sideMax;
sideRightIconCnt = sideMax;
- }
- else // Less than max, so do the calc
+ } else // Less than max, so do the calc
{
- sideLeftIconCnt = holdCount/2;
+ sideLeftIconCnt = holdCount / 2;
sideRightIconCnt = holdCount - sideLeftIconCnt;
}
@@ -3906,77 +3388,67 @@ void CG_DrawForceSelect( void )
const int y = 425;
i = cg.forcepowerSelect - 1;
- if (i < 0)
- {
- i = MAX_SHOWPOWERS-1;
+ if (i < 0) {
+ i = MAX_SHOWPOWERS - 1;
}
cgi_R_SetColor(NULL);
// Work backwards from current icon
- holdX = x - ((bigIconSize/2) + pad + smallIconSize);
- for (iconCnt=1;iconCnt<(sideLeftIconCnt+1);i--)
- {
- if (i < 0)
- {
- i = MAX_SHOWPOWERS-1;
+ holdX = x - ((bigIconSize / 2) + pad + smallIconSize);
+ for (iconCnt = 1; iconCnt < (sideLeftIconCnt + 1); i--) {
+ if (i < 0) {
+ i = MAX_SHOWPOWERS - 1;
}
- if (!ForcePower_Valid(i)) // Does he have this power?
+ if (!ForcePower_Valid(i)) // Does he have this power?
{
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (force_icons[showPowers[i]])
- {
- CG_DrawPic( holdX, y + yOffset, smallIconSize, smallIconSize, force_icons[showPowers[i]] );
- holdX -= (smallIconSize+pad);
+ if (force_icons[showPowers[i]]) {
+ CG_DrawPic(holdX, y + yOffset, smallIconSize, smallIconSize, force_icons[showPowers[i]]);
+ holdX -= (smallIconSize + pad);
}
}
// Current Center Icon
- if (force_icons[showPowers[cg.forcepowerSelect]])
- {
- CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2)) + yOffset, bigIconSize, bigIconSize, force_icons[showPowers[cg.forcepowerSelect]] );
+ if (force_icons[showPowers[cg.forcepowerSelect]]) {
+ CG_DrawPic(x - (bigIconSize / 2), (y - ((bigIconSize - smallIconSize) / 2)) + yOffset, bigIconSize, bigIconSize,
+ force_icons[showPowers[cg.forcepowerSelect]]);
}
-
i = cg.forcepowerSelect + 1;
- if (i>=MAX_SHOWPOWERS)
- {
+ if (i >= MAX_SHOWPOWERS) {
i = 0;
}
// Work forwards from current icon
- holdX = x + (bigIconSize/2) + pad;
- for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++)
- {
- if (i>=MAX_SHOWPOWERS)
- {
+ holdX = x + (bigIconSize / 2) + pad;
+ for (iconCnt = 1; iconCnt < (sideRightIconCnt + 1); i++) {
+ if (i >= MAX_SHOWPOWERS) {
i = 0;
}
- if (!ForcePower_Valid(i)) // Does he have this power?
+ if (!ForcePower_Valid(i)) // Does he have this power?
{
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (force_icons[showPowers[i]])
- {
- CG_DrawPic( holdX, y + yOffset, smallIconSize, smallIconSize, force_icons[showPowers[i]] );
- holdX += (smallIconSize+pad);
+ if (force_icons[showPowers[i]]) {
+ CG_DrawPic(holdX, y + yOffset, smallIconSize, smallIconSize, force_icons[showPowers[i]]);
+ holdX += (smallIconSize + pad);
}
}
// This only a temp solution.
- if (cgi_SP_GetStringTextString( showPowersName[cg.forcepowerSelect], text, sizeof(text) ))
- {
- int w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
- int x = ( SCREEN_WIDTH - w ) / 2;
- cgi_R_Font_DrawString(x, (SCREEN_HEIGHT - 24) + yOffset, text, colorTable[CT_ICON_BLUE], cgs.media.qhFontSmall, -1, 1.0f);
+ if (cgi_SP_GetStringTextString(showPowersName[cg.forcepowerSelect], text, sizeof(text))) {
+ int w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
+ int x = (SCREEN_WIDTH - w) / 2;
+ cgi_R_Font_DrawString(x, (SCREEN_HEIGHT - 24) + yOffset, text, colorTable[CT_ICON_BLUE], cgs.media.qhFontSmall, -1, 1.0f);
}
}
@@ -3985,13 +3457,12 @@ void CG_DrawForceSelect( void )
ForcePowerDataPad_Valid
===============
*/
-qboolean ForcePowerDataPad_Valid(int index)
-{
- gentity_t *player = &g_entities[0];
+qboolean ForcePowerDataPad_Valid(int index) {
+ gentity_t *player = &g_entities[0];
- assert (index < MAX_DPSHOWPOWERS);
+ assert(index < MAX_DPSHOWPOWERS);
if (player->client->ps.forcePowersKnown & (1 << showDataPadPowers[index]) &&
- player->client->ps.forcePowerLevel[showDataPadPowers[index]]) // Does he have the force power?
+ player->client->ps.forcePowerLevel[showDataPadPowers[index]]) // Does he have the force power?
{
return qtrue;
}
@@ -4004,28 +3475,24 @@ qboolean ForcePowerDataPad_Valid(int index)
CG_DPNextForcePower_f
===============
*/
-void CG_DPNextForcePower_f( void )
-{
- int i;
- int original;
+void CG_DPNextForcePower_f(void) {
+ int i;
+ int original;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
original = cg.DataPadforcepowerSelect;
- for ( i = 0; i= MAX_DPSHOWPOWERS)
- {
+ if (cg.DataPadforcepowerSelect >= MAX_DPSHOWPOWERS) {
cg.DataPadforcepowerSelect = 0;
}
- if (ForcePowerDataPad_Valid(cg.DataPadforcepowerSelect)) // Does he have the force power?
+ if (ForcePowerDataPad_Valid(cg.DataPadforcepowerSelect)) // Does he have the force power?
{
return;
}
@@ -4039,124 +3506,66 @@ void CG_DPNextForcePower_f( void )
CG_DPPrevForcePower_f
===============
*/
-void CG_DPPrevForcePower_f( void )
-{
- int i;
- int original;
+void CG_DPPrevForcePower_f(void) {
+ int i;
+ int original;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
original = cg.DataPadforcepowerSelect;
- for ( i = 0; i (2*sideMax)) // Go to the max on each side
+ } else if (count > (2 * sideMax)) // Go to the max on each side
{
sideLeftIconCnt = sideMax;
sideRightIconCnt = sideMax;
- }
- else // Less than max, so do the calc
+ } else // Less than max, so do the calc
{
- sideLeftIconCnt = holdCount/2;
+ sideLeftIconCnt = holdCount / 2;
sideRightIconCnt = holdCount - sideLeftIconCnt;
}
-
const int smallIconSize = 40;
const int bigIconSize = 70;
const int bigPad = 64;
@@ -4226,137 +3628,112 @@ void CG_DrawDataPadForceSelect( void )
const int graphicYPos = 340;
i = cg.DataPadforcepowerSelect - 1;
- if (i < 0)
- {
- i = MAX_DPSHOWPOWERS-1;
+ if (i < 0) {
+ i = MAX_DPSHOWPOWERS - 1;
}
// Print icons to the left of the center
cgi_R_SetColor(colorTable[CT_WHITE]);
// Work backwards from current icon
- holdX = centerXPos - ((bigIconSize/2) + bigPad + smallIconSize);
- for (iconCnt=1;iconCnt<(sideLeftIconCnt+1);i--)
- {
- if (i < 0)
- {
- i = MAX_DPSHOWPOWERS-1;
+ holdX = centerXPos - ((bigIconSize / 2) + bigPad + smallIconSize);
+ for (iconCnt = 1; iconCnt < (sideLeftIconCnt + 1); i--) {
+ if (i < 0) {
+ i = MAX_DPSHOWPOWERS - 1;
}
- if (!ForcePowerDataPad_Valid(i)) // Does he have this power?
+ if (!ForcePowerDataPad_Valid(i)) // Does he have this power?
{
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (force_icons[showDataPadPowers[i]])
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, force_icons[showDataPadPowers[i]] );
+ if (force_icons[showDataPadPowers[i]]) {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, force_icons[showDataPadPowers[i]]);
}
// A new force power
- if (((cg_updatedDataPadForcePower1.integer - 1) == showDataPadPowers[i]) ||
- ((cg_updatedDataPadForcePower2.integer - 1) == showDataPadPowers[i]) ||
- ((cg_updatedDataPadForcePower3.integer - 1) == showDataPadPowers[i]))
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, cgs.media.DPForcePowerOverlay );
+ if (((cg_updatedDataPadForcePower1.integer - 1) == showDataPadPowers[i]) || ((cg_updatedDataPadForcePower2.integer - 1) == showDataPadPowers[i]) ||
+ ((cg_updatedDataPadForcePower3.integer - 1) == showDataPadPowers[i])) {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, cgs.media.DPForcePowerOverlay);
}
- if (force_icons[showDataPadPowers[i]])
- {
- holdX -= (smallIconSize+pad);
+ if (force_icons[showDataPadPowers[i]]) {
+ holdX -= (smallIconSize + pad);
}
}
// Current Center Icon
- if (force_icons[showDataPadPowers[cg.DataPadforcepowerSelect]])
- {
+ if (force_icons[showDataPadPowers[cg.DataPadforcepowerSelect]]) {
cgi_R_SetColor(colorTable[CT_WHITE]);
- CG_DrawPic( centerXPos-(bigIconSize/2), (graphicYPos-((bigIconSize-smallIconSize)/2)), bigIconSize, bigIconSize, force_icons[showDataPadPowers[cg.DataPadforcepowerSelect]] );
+ CG_DrawPic(centerXPos - (bigIconSize / 2), (graphicYPos - ((bigIconSize - smallIconSize) / 2)), bigIconSize, bigIconSize,
+ force_icons[showDataPadPowers[cg.DataPadforcepowerSelect]]);
// New force power
if (((cg_updatedDataPadForcePower1.integer - 1) == showDataPadPowers[cg.DataPadforcepowerSelect]) ||
((cg_updatedDataPadForcePower2.integer - 1) == showDataPadPowers[cg.DataPadforcepowerSelect]) ||
- ((cg_updatedDataPadForcePower3.integer - 1) == showDataPadPowers[cg.DataPadforcepowerSelect]))
- {
- CG_DrawPic( centerXPos-(bigIconSize/2), (graphicYPos-((bigIconSize-smallIconSize)/2)), bigIconSize, bigIconSize, cgs.media.DPForcePowerOverlay );
+ ((cg_updatedDataPadForcePower3.integer - 1) == showDataPadPowers[cg.DataPadforcepowerSelect])) {
+ CG_DrawPic(centerXPos - (bigIconSize / 2), (graphicYPos - ((bigIconSize - smallIconSize) / 2)), bigIconSize, bigIconSize,
+ cgs.media.DPForcePowerOverlay);
}
}
-
i = cg.DataPadforcepowerSelect + 1;
- if (i>=MAX_DPSHOWPOWERS)
- {
+ if (i >= MAX_DPSHOWPOWERS) {
i = 0;
}
cgi_R_SetColor(colorTable[CT_WHITE]);
// Work forwards from current icon
- holdX = centerXPos + (bigIconSize/2) + bigPad;
- for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++)
- {
- if (i>=MAX_DPSHOWPOWERS)
- {
+ holdX = centerXPos + (bigIconSize / 2) + bigPad;
+ for (iconCnt = 1; iconCnt < (sideRightIconCnt + 1); i++) {
+ if (i >= MAX_DPSHOWPOWERS) {
i = 0;
}
- if (!ForcePowerDataPad_Valid(i)) // Does he have this power?
+ if (!ForcePowerDataPad_Valid(i)) // Does he have this power?
{
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (force_icons[showDataPadPowers[i]])
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, force_icons[showDataPadPowers[i]] );
+ if (force_icons[showDataPadPowers[i]]) {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, force_icons[showDataPadPowers[i]]);
}
// A new force power
- if (((cg_updatedDataPadForcePower1.integer - 1) == showDataPadPowers[i]) ||
- ((cg_updatedDataPadForcePower2.integer - 1) == showDataPadPowers[i]) ||
- ((cg_updatedDataPadForcePower3.integer - 1) == showDataPadPowers[i]))
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, cgs.media.DPForcePowerOverlay );
+ if (((cg_updatedDataPadForcePower1.integer - 1) == showDataPadPowers[i]) || ((cg_updatedDataPadForcePower2.integer - 1) == showDataPadPowers[i]) ||
+ ((cg_updatedDataPadForcePower3.integer - 1) == showDataPadPowers[i])) {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, cgs.media.DPForcePowerOverlay);
}
- if (force_icons[showDataPadPowers[i]])
- {
- holdX += (smallIconSize+pad);
+ if (force_icons[showDataPadPowers[i]]) {
+ holdX += (smallIconSize + pad);
}
}
- cgi_SP_GetStringTextString( va("SP_INGAME_%s",forcepowerDesc[cg.DataPadforcepowerSelect]), text, sizeof(text) );
+ cgi_SP_GetStringTextString(va("SP_INGAME_%s", forcepowerDesc[cg.DataPadforcepowerSelect]), text, sizeof(text));
- if (player->client->ps.forcePowerLevel[showDataPadPowers[cg.DataPadforcepowerSelect]]==1)
- {
- cgi_SP_GetStringTextString( va("SP_INGAME_%s",forcepowerLvl1Desc[cg.DataPadforcepowerSelect]), text2, sizeof(text2) );
- }
- else if (player->client->ps.forcePowerLevel[showDataPadPowers[cg.DataPadforcepowerSelect]]==2)
- {
- cgi_SP_GetStringTextString( va("SP_INGAME_%s",forcepowerLvl2Desc[cg.DataPadforcepowerSelect]), text2, sizeof(text2) );
- }
- else
- {
- cgi_SP_GetStringTextString( va("SP_INGAME_%s",forcepowerLvl3Desc[cg.DataPadforcepowerSelect]), text2, sizeof(text2) );
+ if (player->client->ps.forcePowerLevel[showDataPadPowers[cg.DataPadforcepowerSelect]] == 1) {
+ cgi_SP_GetStringTextString(va("SP_INGAME_%s", forcepowerLvl1Desc[cg.DataPadforcepowerSelect]), text2, sizeof(text2));
+ } else if (player->client->ps.forcePowerLevel[showDataPadPowers[cg.DataPadforcepowerSelect]] == 2) {
+ cgi_SP_GetStringTextString(va("SP_INGAME_%s", forcepowerLvl2Desc[cg.DataPadforcepowerSelect]), text2, sizeof(text2));
+ } else {
+ cgi_SP_GetStringTextString(va("SP_INGAME_%s", forcepowerLvl3Desc[cg.DataPadforcepowerSelect]), text2, sizeof(text2));
}
- if (text[0])
- {
+ if (text[0]) {
const short textboxXPos = 40;
const short textboxYPos = 60;
- const int textboxWidth = 560;
- const int textboxHeight = 300;
- const float textScale = 1.0f;
+ const int textboxWidth = 560;
+ const int textboxHeight = 300;
+ const float textScale = 1.0f;
- CG_DisplayBoxedText(textboxXPos,textboxYPos,textboxWidth,textboxHeight,va("%s%s",text,text2),
- 4,
- textScale,
- colorTable[CT_WHITE]
- );
+ CG_DisplayBoxedText(textboxXPos, textboxYPos, textboxWidth, textboxHeight, va("%s%s", text, text2), 4, textScale, colorTable[CT_WHITE]);
}
}
@@ -4384,7 +3761,3 @@ static void CG_RunCinematicFrame(int handle) {
}
#pragma warning ( default : 4505)
*/
-
-
-
-
diff --git a/code/cgame/cg_marks.cpp b/code/cgame/cg_marks.cpp
index 525e0e0790..1b1226d5a3 100644
--- a/code/cgame/cg_marks.cpp
+++ b/code/cgame/cg_marks.cpp
@@ -25,7 +25,6 @@ along with this program; if not, see .
#include "cg_headers.h"
-
#include "cg_media.h"
/*
@@ -36,10 +35,9 @@ MARK POLYS
===================================================================
*/
-
-markPoly_t cg_activeMarkPolys; // double linked list
-markPoly_t *cg_freeMarkPolys; // single linked list
-markPoly_t cg_markPolys[MAX_MARK_POLYS];
+markPoly_t cg_activeMarkPolys; // double linked list
+markPoly_t *cg_freeMarkPolys; // single linked list
+markPoly_t cg_markPolys[MAX_MARK_POLYS];
/*
===================
@@ -48,28 +46,27 @@ CG_InitMarkPolys
This is called at startup and for tournement restarts
===================
*/
-void CG_InitMarkPolys( void ) {
- int i;
+void CG_InitMarkPolys(void) {
+ int i;
- memset( cg_markPolys, 0, sizeof(cg_markPolys) );
+ memset(cg_markPolys, 0, sizeof(cg_markPolys));
cg_activeMarkPolys.nextMark = &cg_activeMarkPolys;
cg_activeMarkPolys.prevMark = &cg_activeMarkPolys;
cg_freeMarkPolys = cg_markPolys;
- for ( i = 0 ; i < MAX_MARK_POLYS - 1 ; i++ ) {
- cg_markPolys[i].nextMark = &cg_markPolys[i+1];
+ for (i = 0; i < MAX_MARK_POLYS - 1; i++) {
+ cg_markPolys[i].nextMark = &cg_markPolys[i + 1];
}
}
-
/*
==================
CG_FreeMarkPoly
==================
*/
-void CG_FreeMarkPoly( markPoly_t *le ) {
- if ( !le->prevMark ) {
- CG_Error( "CG_FreeLocalEntity: not active" );
+void CG_FreeMarkPoly(markPoly_t *le) {
+ if (!le->prevMark) {
+ CG_Error("CG_FreeLocalEntity: not active");
}
// remove from the doubly linked active list
@@ -88,23 +85,23 @@ CG_AllocMark
Will allways succeed, even if it requires freeing an old active mark
===================
*/
-markPoly_t *CG_AllocMark( void ) {
- markPoly_t *le;
+markPoly_t *CG_AllocMark(void) {
+ markPoly_t *le;
int time;
- if ( !cg_freeMarkPolys ) {
+ if (!cg_freeMarkPolys) {
// no free entities, so free the one at the end of the chain
// remove the oldest active entity
time = cg_activeMarkPolys.prevMark->time;
while (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) {
- CG_FreeMarkPoly( cg_activeMarkPolys.prevMark );
+ CG_FreeMarkPoly(cg_activeMarkPolys.prevMark);
}
}
le = cg_freeMarkPolys;
cg_freeMarkPolys = cg_freeMarkPolys->nextMark;
- memset( le, 0, sizeof( *le ) );
+ memset(le, 0, sizeof(*le));
// link into the active list
le->nextMark = cg_activeMarkPolys.nextMark;
@@ -114,8 +111,6 @@ markPoly_t *CG_AllocMark( void ) {
return le;
}
-
-
/*
=================
CG_ImpactMark
@@ -127,40 +122,39 @@ temporary marks will not be stored or randomly oriented, but immediately
passed to the renderer.
=================
*/
-#define MAX_MARK_FRAGMENTS 128
-#define MAX_MARK_POINTS 384
-
-void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, float orientation, float red,
- float green, float blue, float alpha, qboolean alphaFade, float radius, qboolean temporary )
-{
- vec3_t axis[3];
- float texCoordScale;
- vec3_t originalPoints[4];
- byte colors[4];
- int i, j;
- int numFragments;
- markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf;
- vec3_t markPoints[MAX_MARK_POINTS];
- vec3_t projection;
-
- if ( !cg_addMarks.integer ) {
+#define MAX_MARK_FRAGMENTS 128
+#define MAX_MARK_POINTS 384
+
+void CG_ImpactMark(qhandle_t markShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha,
+ qboolean alphaFade, float radius, qboolean temporary) {
+ vec3_t axis[3];
+ float texCoordScale;
+ vec3_t originalPoints[4];
+ byte colors[4];
+ int i, j;
+ int numFragments;
+ markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf;
+ vec3_t markPoints[MAX_MARK_POINTS];
+ vec3_t projection;
+
+ if (!cg_addMarks.integer) {
return;
}
- if ( radius <= 0 ) {
- CG_Error( "CG_ImpactMark called with <= 0 radius" );
+ if (radius <= 0) {
+ CG_Error("CG_ImpactMark called with <= 0 radius");
}
// create the texture axis
- VectorNormalize2( dir, axis[0] );
- PerpendicularVector( axis[1], axis[0] );
- RotatePointAroundVector( axis[2], axis[0], axis[1], orientation );
- CrossProduct( axis[0], axis[2], axis[1] );
+ VectorNormalize2(dir, axis[0]);
+ PerpendicularVector(axis[1], axis[0]);
+ RotatePointAroundVector(axis[2], axis[0], axis[1], orientation);
+ CrossProduct(axis[0], axis[2], axis[1]);
texCoordScale = 0.5 * 1.0 / radius;
// create the full polygon
- for ( i = 0 ; i < 3 ; i++ ) {
+ for (i = 0; i < 3; i++) {
originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i];
originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i];
originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i];
@@ -168,42 +162,40 @@ void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir,
}
// get the fragments
- VectorScale( dir, -20, projection );
- numFragments = cgi_CM_MarkFragments( 4, (const float (*)[3])originalPoints,
- projection, MAX_MARK_POINTS, markPoints[0],
- MAX_MARK_FRAGMENTS, markFragments );
+ VectorScale(dir, -20, projection);
+ numFragments = cgi_CM_MarkFragments(4, (const float(*)[3])originalPoints, projection, MAX_MARK_POINTS, markPoints[0], MAX_MARK_FRAGMENTS, markFragments);
colors[0] = red * 255;
colors[1] = green * 255;
colors[2] = blue * 255;
colors[3] = alpha * 255;
- for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) {
- polyVert_t *v;
- polyVert_t verts[MAX_VERTS_ON_POLY];
- markPoly_t *mark;
+ for (i = 0, mf = markFragments; i < numFragments; i++, mf++) {
+ polyVert_t *v;
+ polyVert_t verts[MAX_VERTS_ON_POLY];
+ markPoly_t *mark;
// we have an upper limit on the complexity of polygons
// that we store persistantly
- if ( mf->numPoints > MAX_VERTS_ON_POLY ) {
+ if (mf->numPoints > MAX_VERTS_ON_POLY) {
mf->numPoints = MAX_VERTS_ON_POLY;
}
- for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) {
+ for (j = 0, v = verts; j < mf->numPoints; j++, v++) {
vec3_t delta;
- VectorCopy( markPoints[mf->firstPoint + j], v->xyz );
+ VectorCopy(markPoints[mf->firstPoint + j], v->xyz);
- VectorSubtract( v->xyz, origin, delta );
- v->st[0] = 0.5f + DotProduct( delta, axis[1] ) * texCoordScale;
- v->st[1] = 0.5f + DotProduct( delta, axis[2] ) * texCoordScale;
- for ( int k = 0; k < 4; k++ ) {
+ VectorSubtract(v->xyz, origin, delta);
+ v->st[0] = 0.5f + DotProduct(delta, axis[1]) * texCoordScale;
+ v->st[1] = 0.5f + DotProduct(delta, axis[2]) * texCoordScale;
+ for (int k = 0; k < 4; k++) {
v->modulate[k] = colors[k];
}
}
// if it is a temporary (shadow) mark, add it immediately and forget about it
- if ( temporary ) {
- cgi_R_AddPolyToScene( markShader, mf->numPoints, verts );
+ if (temporary) {
+ cgi_R_AddPolyToScene(markShader, mf->numPoints, verts);
continue;
}
@@ -213,75 +205,68 @@ void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir,
mark->alphaFade = alphaFade;
mark->markShader = markShader;
mark->poly.numVerts = mf->numPoints;
- mark->color[0] = colors[0];//red;
- mark->color[1] = colors[1];//green;
- mark->color[2] = colors[2];//blue;
- mark->color[3] = colors[3];//alpha;
- memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );
+ mark->color[0] = colors[0]; // red;
+ mark->color[1] = colors[1]; // green;
+ mark->color[2] = colors[2]; // blue;
+ mark->color[3] = colors[3]; // alpha;
+ memcpy(mark->verts, verts, mf->numPoints * sizeof(verts[0]));
}
}
-
/*
===============
CG_AddMarks
===============
*/
-#define MARK_TOTAL_TIME 10000
-#define MARK_FADE_TIME 1000
+#define MARK_TOTAL_TIME 10000
+#define MARK_FADE_TIME 1000
-void CG_AddMarks( void ) {
- int j;
- markPoly_t *mp, *next;
- int t;
- int fade;
+void CG_AddMarks(void) {
+ int j;
+ markPoly_t *mp, *next;
+ int t;
+ int fade;
- if ( !cg_addMarks.integer ) {
+ if (!cg_addMarks.integer) {
return;
}
mp = cg_activeMarkPolys.nextMark;
- for ( ; mp != &cg_activeMarkPolys ; mp = next ) {
+ for (; mp != &cg_activeMarkPolys; mp = next) {
// grab next now, so if the local entity is freed we
// still have it
next = mp->nextMark;
// see if it is time to completely remove it
- if ( cg.time > mp->time + MARK_TOTAL_TIME ) {
- CG_FreeMarkPoly( mp );
+ if (cg.time > mp->time + MARK_TOTAL_TIME) {
+ CG_FreeMarkPoly(mp);
continue;
}
// fade all marks out with time
t = mp->time + MARK_TOTAL_TIME - cg.time;
- if ( t < MARK_FADE_TIME ) {
+ if (t < MARK_FADE_TIME) {
fade = 255 * t / MARK_FADE_TIME;
- if ( mp->alphaFade ) {
- for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
+ if (mp->alphaFade) {
+ for (j = 0; j < mp->poly.numVerts; j++) {
mp->verts[j].modulate[3] = fade;
}
- }
- else
- {
+ } else {
float f = (float)t / MARK_FADE_TIME;
- for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
+ for (j = 0; j < mp->poly.numVerts; j++) {
mp->verts[j].modulate[0] = mp->color[0] * f;
mp->verts[j].modulate[1] = mp->color[1] * f;
mp->verts[j].modulate[2] = mp->color[2] * f;
}
}
- }
- else
- {
- for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
+ } else {
+ for (j = 0; j < mp->poly.numVerts; j++) {
mp->verts[j].modulate[0] = mp->color[0];
mp->verts[j].modulate[1] = mp->color[1];
mp->verts[j].modulate[2] = mp->color[2];
}
}
-
- cgi_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );
+ cgi_R_AddPolyToScene(mp->markShader, mp->poly.numVerts, mp->verts);
}
}
-
diff --git a/code/cgame/cg_players.cpp b/code/cgame/cg_players.cpp
index 9a6e6aa4f8..9ba9eda39f 100644
--- a/code/cgame/cg_players.cpp
+++ b/code/cgame/cg_players.cpp
@@ -23,7 +23,7 @@ along with this program; if not, see .
#include "cg_headers.h"
-#define CG_PLAYERS_CPP
+#define CG_PLAYERS_CPP
#include "cg_media.h"
#include "FxScheduler.h"
#include "../game/ghoul2_shared.h"
@@ -32,15 +32,15 @@ along with this program; if not, see .
#include "../game/g_vehicles.h"
#include "../Rufl/hstring.h"
-#define LOOK_SWING_SCALE 0.5f
-#define CG_SWINGSPEED 0.3f
+#define LOOK_SWING_SCALE 0.5f
+#define CG_SWINGSPEED 0.3f
#include "animtable.h"
-extern qboolean WP_SaberBladeUseSecondBladeStyle( saberInfo_t *saber, int bladeNum );
-extern void WP_SaberSwingSound( gentity_t *ent, int saberNum, swingType_t swingType );
+extern qboolean WP_SaberBladeUseSecondBladeStyle(saberInfo_t *saber, int bladeNum);
+extern void WP_SaberSwingSound(gentity_t *ent, int saberNum, swingType_t swingType);
-extern vmCvar_t cg_debugHealthBars;
+extern vmCvar_t cg_debugHealthBars;
/*
player entities generate a great deal of information from implicit ques
@@ -48,24 +48,22 @@ taken from the entityState_t
*/
-//rww - generic function for applying a shader to the skin.
-extern vmCvar_t cg_g2Marks;
-void CG_AddGhoul2Mark(int type, float size, vec3_t hitloc, vec3_t hitdirection,
- int entnum, vec3_t entposition, float entangle, CGhoul2Info_v &ghoul2, vec3_t modelScale, int lifeTime, int firstModel, vec3_t uaxis )
-{
- if ( !cg_g2Marks.integer )
- {//don't want these
+// rww - generic function for applying a shader to the skin.
+extern vmCvar_t cg_g2Marks;
+void CG_AddGhoul2Mark(int type, float size, vec3_t hitloc, vec3_t hitdirection, int entnum, vec3_t entposition, float entangle, CGhoul2Info_v &ghoul2,
+ vec3_t modelScale, int lifeTime, int firstModel, vec3_t uaxis) {
+ if (!cg_g2Marks.integer) { // don't want these
return;
}
static SSkinGoreData goreSkin;
- memset ( &goreSkin, 0, sizeof(goreSkin) );
+ memset(&goreSkin, 0, sizeof(goreSkin));
- goreSkin.growDuration = -1; // do not grow
+ goreSkin.growDuration = -1; // do not grow
goreSkin.goreScaleStartFraction = 1.0; // default start scale
- goreSkin.frontFaces = true; // yes front
- goreSkin.backFaces = false; // no back
+ goreSkin.frontFaces = true; // yes front
+ goreSkin.backFaces = false; // no back
goreSkin.lifeTime = lifeTime;
goreSkin.firstModel = firstModel;
/*
@@ -78,227 +76,136 @@ void CG_AddGhoul2Mark(int type, float size, vec3_t hitloc, vec3_t hitdirection,
*/
goreSkin.currentTime = cg.time;
- goreSkin.entNum = entnum;
- goreSkin.SSize = size;
- goreSkin.TSize = size;
- goreSkin.shader = type;
- goreSkin.theta = flrand(0.0f,6.28f);
+ goreSkin.entNum = entnum;
+ goreSkin.SSize = size;
+ goreSkin.TSize = size;
+ goreSkin.shader = type;
+ goreSkin.theta = flrand(0.0f, 6.28f);
- if (uaxis)
- {
+ if (uaxis) {
goreSkin.backFaces = true;
- goreSkin.SSize = 6;
- goreSkin.TSize = 3;
- goreSkin.depthStart = -10; //arbitrary depths, just limiting marks to near hit loc
- goreSkin.depthEnd = 15;
+ goreSkin.SSize = 6;
+ goreSkin.TSize = 3;
+ goreSkin.depthStart = -10; // arbitrary depths, just limiting marks to near hit loc
+ goreSkin.depthEnd = 15;
goreSkin.useTheta = false;
VectorCopy(uaxis, goreSkin.uaxis);
- if( VectorNormalize(goreSkin.uaxis) < 0.001f )
- {//too short to make a mark
+ if (VectorNormalize(goreSkin.uaxis) < 0.001f) { // too short to make a mark
return;
}
- }
- else
- {
+ } else {
goreSkin.depthStart = -1000;
- goreSkin.depthEnd = 1000;
+ goreSkin.depthEnd = 1000;
goreSkin.useTheta = true;
}
VectorCopy(modelScale, goreSkin.scale);
- if ( VectorCompare( hitdirection, vec3_origin ) )
- {//wtf, no dir? Make one up
- VectorSubtract( entposition, hitloc, goreSkin.rayDirection);
- VectorNormalize( goreSkin.rayDirection );
- }
- else
- {//use passed in value
- VectorCopy ( hitdirection, goreSkin.rayDirection);
+ if (VectorCompare(hitdirection, vec3_origin)) { // wtf, no dir? Make one up
+ VectorSubtract(entposition, hitloc, goreSkin.rayDirection);
+ VectorNormalize(goreSkin.rayDirection);
+ } else { // use passed in value
+ VectorCopy(hitdirection, goreSkin.rayDirection);
}
- VectorCopy ( hitloc, goreSkin.hitLocation );
- VectorCopy ( entposition, goreSkin.position );
+ VectorCopy(hitloc, goreSkin.hitLocation);
+ VectorCopy(entposition, goreSkin.position);
goreSkin.angles[YAW] = entangle;
- gi.G2API_AddSkinGore(ghoul2,goreSkin);
+ gi.G2API_AddSkinGore(ghoul2, goreSkin);
}
-qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *headModelName, const char *headSkinName,
- const char *torsoModelName, const char *torsoSkinName,
- const char *legsModelName, const char *legsSkinName );
-
-static void CG_PlayerFootsteps( centity_t *const cent, footstepType_t footStepType );
-static void CG_PlayerAnimEvents( int animFileIndex, qboolean torso, int oldFrame, int frame, int entNum );
-extern void BG_G2SetBoneAngles( centity_t *cent, gentity_t *gent, int boneIndex, const vec3_t angles, const int flags,
- const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList );
-extern void FX_BorgDeathSparkParticles( vec3_t origin, vec3_t angles, vec3_t vel, vec3_t user );
-extern qboolean PM_SaberInSpecialAttack( int anim );
-extern qboolean PM_SaberInAttack( int move );
-extern qboolean PM_SaberInTransitionAny( int move );
-extern int PM_GetTurnAnim( gentity_t *gent, int anim );
-extern int PM_AnimLength( int index, animNumber_t anim );
-extern qboolean PM_InRoll( playerState_t *ps );
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
-extern qboolean PM_SuperBreakWinAnim( int anim );
-
-//Basic set of custom sounds that everyone needs
-// (keep numbers in ascending order in order for variant-capping to work)
-const char *cg_customBasicSoundNames[MAX_CUSTOM_BASIC_SOUNDS] =
-{
- "*death1.wav",
- "*death2.wav",
- "*death3.wav",
- "*jump1.wav",
- "*pain25.wav",
- "*pain50.wav",
- "*pain75.wav",
- "*pain100.wav",
- "*gurp1.wav",
- "*gurp2.wav",
- "*drown.wav",
- "*gasp.wav",
- "*land1.wav",
- "*falling1.wav",
+qboolean CG_RegisterClientModelname(clientInfo_t *ci, const char *headModelName, const char *headSkinName, const char *torsoModelName,
+ const char *torsoSkinName, const char *legsModelName, const char *legsSkinName);
+
+static void CG_PlayerFootsteps(centity_t *const cent, footstepType_t footStepType);
+static void CG_PlayerAnimEvents(int animFileIndex, qboolean torso, int oldFrame, int frame, int entNum);
+extern void BG_G2SetBoneAngles(centity_t *cent, gentity_t *gent, int boneIndex, const vec3_t angles, const int flags, const Eorientations up,
+ const Eorientations left, const Eorientations forward, qhandle_t *modelList);
+extern void FX_BorgDeathSparkParticles(vec3_t origin, vec3_t angles, vec3_t vel, vec3_t user);
+extern qboolean PM_SaberInSpecialAttack(int anim);
+extern qboolean PM_SaberInAttack(int move);
+extern qboolean PM_SaberInTransitionAny(int move);
+extern int PM_GetTurnAnim(gentity_t *gent, int anim);
+extern int PM_AnimLength(int index, animNumber_t anim);
+extern qboolean PM_InRoll(playerState_t *ps);
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
+extern qboolean PM_SuperBreakWinAnim(int anim);
+
+// Basic set of custom sounds that everyone needs
+// (keep numbers in ascending order in order for variant-capping to work)
+const char *cg_customBasicSoundNames[MAX_CUSTOM_BASIC_SOUNDS] = {
+ "*death1.wav", "*death2.wav", "*death3.wav", "*jump1.wav", "*pain25.wav", "*pain50.wav", "*pain75.wav",
+ "*pain100.wav", "*gurp1.wav", "*gurp2.wav", "*drown.wav", "*gasp.wav", "*land1.wav", "*falling1.wav",
};
-//Used as a supplement to the basic set for enemies and hazard team
-// (keep numbers in ascending order in order for variant-capping to work)
-const char *cg_customCombatSoundNames[MAX_CUSTOM_COMBAT_SOUNDS] =
-{
- "*anger1.wav", //Say when acquire an enemy when didn't have one before
- "*anger2.wav",
- "*anger3.wav",
- "*victory1.wav", //Say when killed an enemy
- "*victory2.wav",
- "*victory3.wav",
- "*confuse1.wav", //Say when confused
- "*confuse2.wav",
- "*confuse3.wav",
- "*pushed1.wav", //Say when force-pushed
- "*pushed2.wav",
- "*pushed3.wav",
- "*choke1.wav",
- "*choke2.wav",
- "*choke3.wav",
- "*ffwarn.wav",
- "*ffturn.wav",
+// Used as a supplement to the basic set for enemies and hazard team
+// (keep numbers in ascending order in order for variant-capping to work)
+const char *cg_customCombatSoundNames[MAX_CUSTOM_COMBAT_SOUNDS] = {
+ "*anger1.wav", // Say when acquire an enemy when didn't have one before
+ "*anger2.wav", "*anger3.wav",
+ "*victory1.wav", // Say when killed an enemy
+ "*victory2.wav", "*victory3.wav",
+ "*confuse1.wav", // Say when confused
+ "*confuse2.wav", "*confuse3.wav",
+ "*pushed1.wav", // Say when force-pushed
+ "*pushed2.wav", "*pushed3.wav", "*choke1.wav", "*choke2.wav", "*choke3.wav", "*ffwarn.wav", "*ffturn.wav",
};
-//Used as a supplement to the basic set for stormtroopers
-// (keep numbers in ascending order in order for variant-capping to work)
-const char *cg_customExtraSoundNames[MAX_CUSTOM_EXTRA_SOUNDS] =
-{
- "*chase1.wav",
- "*chase2.wav",
- "*chase3.wav",
- "*cover1.wav",
- "*cover2.wav",
- "*cover3.wav",
- "*cover4.wav",
- "*cover5.wav",
- "*detected1.wav",
- "*detected2.wav",
- "*detected3.wav",
- "*detected4.wav",
- "*detected5.wav",
- "*lost1.wav",
- "*outflank1.wav",
- "*outflank2.wav",
- "*escaping1.wav",
- "*escaping2.wav",
- "*escaping3.wav",
- "*giveup1.wav",
- "*giveup2.wav",
- "*giveup3.wav",
- "*giveup4.wav",
- "*look1.wav",
- "*look2.wav",
- "*sight1.wav",
- "*sight2.wav",
- "*sight3.wav",
- "*sound1.wav",
- "*sound2.wav",
- "*sound3.wav",
- "*suspicious1.wav",
- "*suspicious2.wav",
- "*suspicious3.wav",
- "*suspicious4.wav",
- "*suspicious5.wav",
+// Used as a supplement to the basic set for stormtroopers
+// (keep numbers in ascending order in order for variant-capping to work)
+const char *cg_customExtraSoundNames[MAX_CUSTOM_EXTRA_SOUNDS] = {
+ "*chase1.wav", "*chase2.wav", "*chase3.wav", "*cover1.wav", "*cover2.wav", "*cover3.wav", "*cover4.wav", "*cover5.wav",
+ "*detected1.wav", "*detected2.wav", "*detected3.wav", "*detected4.wav", "*detected5.wav", "*lost1.wav", "*outflank1.wav", "*outflank2.wav",
+ "*escaping1.wav", "*escaping2.wav", "*escaping3.wav", "*giveup1.wav", "*giveup2.wav", "*giveup3.wav", "*giveup4.wav", "*look1.wav",
+ "*look2.wav", "*sight1.wav", "*sight2.wav", "*sight3.wav", "*sound1.wav", "*sound2.wav", "*sound3.wav", "*suspicious1.wav",
+ "*suspicious2.wav", "*suspicious3.wav", "*suspicious4.wav", "*suspicious5.wav",
};
-//Used as a supplement to the basic set for jedi
-// (keep numbers in ascending order in order for variant-capping to work)
-const char *cg_customJediSoundNames[MAX_CUSTOM_JEDI_SOUNDS] =
-{
- "*combat1.wav",
- "*combat2.wav",
- "*combat3.wav",
- "*jdetected1.wav",
- "*jdetected2.wav",
- "*jdetected3.wav",
- "*taunt1.wav",
- "*taunt2.wav",
- "*taunt3.wav",
- "*jchase1.wav",
- "*jchase2.wav",
- "*jchase3.wav",
- "*jlost1.wav",
- "*jlost2.wav",
- "*jlost3.wav",
- "*deflect1.wav",
- "*deflect2.wav",
- "*deflect3.wav",
- "*gloat1.wav",
- "*gloat2.wav",
- "*gloat3.wav",
- "*pushfail.wav",
+// Used as a supplement to the basic set for jedi
+// (keep numbers in ascending order in order for variant-capping to work)
+const char *cg_customJediSoundNames[MAX_CUSTOM_JEDI_SOUNDS] = {
+ "*combat1.wav", "*combat2.wav", "*combat3.wav", "*jdetected1.wav", "*jdetected2.wav", "*jdetected3.wav", "*taunt1.wav", "*taunt2.wav",
+ "*taunt3.wav", "*jchase1.wav", "*jchase2.wav", "*jchase3.wav", "*jlost1.wav", "*jlost2.wav", "*jlost3.wav", "*deflect1.wav",
+ "*deflect2.wav", "*deflect3.wav", "*gloat1.wav", "*gloat2.wav", "*gloat3.wav", "*pushfail.wav",
};
-
// done at registration time only...
//
// cuts down on sound-variant registration for low end machines,
// eg *gloat1.wav (plus...2,...3) can be capped to all be just *gloat1.wav
//
-static const char *GetCustomSound_VariantCapped(const char *ppsTable[], int iEntryNum, qboolean bForceVariant1)
-{
- extern vmCvar_t cg_VariantSoundCap;
+static const char *GetCustomSound_VariantCapped(const char *ppsTable[], int iEntryNum, qboolean bForceVariant1) {
+ extern vmCvar_t cg_VariantSoundCap;
-// const int iVariantCap = 2; // test
+ // const int iVariantCap = 2; // test
const int &iVariantCap = cg_VariantSoundCap.integer;
- if (iVariantCap || bForceVariant1)
- {
- char *p = (char *)strchr(ppsTable[iEntryNum],'.');
- if (p && p-2 > ppsTable[iEntryNum] && isdigit(p[-1]) && !isdigit(p[-2]))
- {
- int iThisVariant = p[-1]-'0';
+ if (iVariantCap || bForceVariant1) {
+ char *p = (char *)strchr(ppsTable[iEntryNum], '.');
+ if (p && p - 2 > ppsTable[iEntryNum] && isdigit(p[-1]) && !isdigit(p[-2])) {
+ int iThisVariant = p[-1] - '0';
- if (iThisVariant > iVariantCap || bForceVariant1)
- {
+ if (iThisVariant > iVariantCap || bForceVariant1) {
// ok, let's not load this variant, so pick a random one below the cap value...
//
- for (int i=0; i<2; i++) // 1st pass, choose random, 2nd pass (if random not in list), choose xxx1, else fall through...
+ for (int i = 0; i < 2; i++) // 1st pass, choose random, 2nd pass (if random not in list), choose xxx1, else fall through...
{
char sName[MAX_QPATH];
Q_strncpyz(sName, ppsTable[iEntryNum], sizeof(sName));
- p = strchr(sName,'.');
- if (p)
- {
+ p = strchr(sName, '.');
+ if (p) {
*p = '\0';
- sName[strlen(sName)-1] = '\0'; // strip the digit
+ sName[strlen(sName) - 1] = '\0'; // strip the digit
- int iRandom = bForceVariant1 ? 1 : (!i ? Q_irand(1,iVariantCap) : 1);
+ int iRandom = bForceVariant1 ? 1 : (!i ? Q_irand(1, iVariantCap) : 1);
- strcat(sName,va("%d",iRandom));
+ strcat(sName, va("%d", iRandom));
// does this exist in the entries before the original one?...
//
- for (int iScanNum=0; iScanNumstring[0] == 'f' )
- {
- hSFX = cgi_S_RegisterSound( va("sound/chars/%s/misc/%s_f.wav", psDir, s + 1) );
+ if (g_sex->string[0] == 'f') {
+ hSFX = cgi_S_RegisterSound(va("sound/chars/%s/misc/%s_f.wav", psDir, s + 1));
}
- if (hSFX == 0 || com_buildScript->integer)
- {
- hSFX = cgi_S_RegisterSound( va("sound/chars/%s/misc/%s.wav", psDir, s + 1) );
+ if (hSFX == 0 || com_buildScript->integer) {
+ hSFX = cgi_S_RegisterSound(va("sound/chars/%s/misc/%s.wav", psDir, s + 1));
}
- if (hSFX == 0)
- {
+ if (hSFX == 0) {
// hmmm... variant in table was missing, so forcibly-retry with %1 version (which we may have just tried, but wtf?)...
//
- pS = GetCustomSound_VariantCapped(ppsTable,i, qtrue);
- COM_StripExtension( pS, s, sizeof(s) );
- if ( g_sex->string[0] == 'f' )
- {
- hSFX = cgi_S_RegisterSound( va("sound/chars/%s/misc/%s_f.wav", psDir, s + 1) );
+ pS = GetCustomSound_VariantCapped(ppsTable, i, qtrue);
+ COM_StripExtension(pS, s, sizeof(s));
+ if (g_sex->string[0] == 'f') {
+ hSFX = cgi_S_RegisterSound(va("sound/chars/%s/misc/%s_f.wav", psDir, s + 1));
}
- if (hSFX == 0 || com_buildScript->integer)
- {
- hSFX = cgi_S_RegisterSound( va("sound/chars/%s/misc/%s.wav", psDir, s + 1) );
+ if (hSFX == 0 || com_buildScript->integer) {
+ hSFX = cgi_S_RegisterSound(va("sound/chars/%s/misc/%s.wav", psDir, s + 1));
}
//
// and fall through regardless...
@@ -361,8 +259,6 @@ static void CG_RegisterCustomSounds(clientInfo_t *ci, int iSoundEntryBase,
}
}
-
-
/*
================
CG_CustomSound
@@ -373,41 +269,32 @@ CG_CustomSound
================
*/
-static sfxHandle_t CG_CustomSound( int entityNum, const char *soundName, int customSoundSet )
-{
+static sfxHandle_t CG_CustomSound(int entityNum, const char *soundName, int customSoundSet) {
clientInfo_t *ci;
- int i;
+ int i;
- if ( soundName[0] != '*' )
- {
- return cgi_S_RegisterSound( soundName );
+ if (soundName[0] != '*') {
+ return cgi_S_RegisterSound(soundName);
}
- if ( !g_entities[entityNum].client )
- {
+ if (!g_entities[entityNum].client) {
// No client, this should never happen, so just don't
#ifndef FINAL_BUILD
// CG_Printf( "custom sound not on client: %s", soundName );
#endif
return 0;
- }
- else
- {
+ } else {
ci = &g_entities[entityNum].client->clientInfo;
}
- //FIXME: if the sound you want to play could not be found, pick another from the same
- //general grouping? ie: if you want ff_2c and there is none, try ff_2b or ff_2a...
- switch ( customSoundSet )
- {
+ // FIXME: if the sound you want to play could not be found, pick another from the same
+ // general grouping? ie: if you want ff_2c and there is none, try ff_2b or ff_2a...
+ switch (customSoundSet) {
case CS_BASIC:
// There should always be a clientInfo structure if there is a client, but just make sure...
- if ( ci )
- {
- for ( i = 0 ; i < MAX_CUSTOM_BASIC_SOUNDS && cg_customBasicSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customBasicSoundNames[i] ) )
- {
+ if (ci) {
+ for (i = 0; i < MAX_CUSTOM_BASIC_SOUNDS && cg_customBasicSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customBasicSoundNames[i])) {
return ci->sounds[i];
}
}
@@ -415,74 +302,56 @@ static sfxHandle_t CG_CustomSound( int entityNum, const char *soundName, int cus
break;
case CS_COMBAT:
// There should always be a clientInfo structure if there is a client, but just make sure...
- if ( ci )
- {
- for ( i = 0 ; i < MAX_CUSTOM_COMBAT_SOUNDS && cg_customCombatSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customCombatSoundNames[i] ) )
- {
- return ci->sounds[i+MAX_CUSTOM_BASIC_SOUNDS];
+ if (ci) {
+ for (i = 0; i < MAX_CUSTOM_COMBAT_SOUNDS && cg_customCombatSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customCombatSoundNames[i])) {
+ return ci->sounds[i + MAX_CUSTOM_BASIC_SOUNDS];
}
}
}
break;
case CS_EXTRA:
// There should always be a clientInfo structure if there is a client, but just make sure...
- if ( ci )
- {
- for ( i = 0 ; i < MAX_CUSTOM_EXTRA_SOUNDS && cg_customExtraSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customExtraSoundNames[i] ) )
- {
- return ci->sounds[i+MAX_CUSTOM_BASIC_SOUNDS+MAX_CUSTOM_COMBAT_SOUNDS];
+ if (ci) {
+ for (i = 0; i < MAX_CUSTOM_EXTRA_SOUNDS && cg_customExtraSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customExtraSoundNames[i])) {
+ return ci->sounds[i + MAX_CUSTOM_BASIC_SOUNDS + MAX_CUSTOM_COMBAT_SOUNDS];
}
}
}
break;
case CS_JEDI:
// There should always be a clientInfo structure if there is a client, but just make sure...
- if ( ci )
- {
- for ( i = 0 ; i < MAX_CUSTOM_JEDI_SOUNDS && cg_customJediSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customJediSoundNames[i] ) )
- {
- return ci->sounds[i+MAX_CUSTOM_BASIC_SOUNDS+MAX_CUSTOM_COMBAT_SOUNDS+MAX_CUSTOM_EXTRA_SOUNDS];
+ if (ci) {
+ for (i = 0; i < MAX_CUSTOM_JEDI_SOUNDS && cg_customJediSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customJediSoundNames[i])) {
+ return ci->sounds[i + MAX_CUSTOM_BASIC_SOUNDS + MAX_CUSTOM_COMBAT_SOUNDS + MAX_CUSTOM_EXTRA_SOUNDS];
}
}
}
break;
case CS_TRY_ALL:
default:
- //no set specified, search all
- if ( ci )
- {
- for ( i = 0 ; i < MAX_CUSTOM_BASIC_SOUNDS && cg_customBasicSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customBasicSoundNames[i] ) )
- {
+ // no set specified, search all
+ if (ci) {
+ for (i = 0; i < MAX_CUSTOM_BASIC_SOUNDS && cg_customBasicSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customBasicSoundNames[i])) {
return ci->sounds[i];
}
}
- for ( i = 0 ; i < MAX_CUSTOM_COMBAT_SOUNDS && cg_customCombatSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customCombatSoundNames[i] ) )
- {
- return ci->sounds[i+MAX_CUSTOM_BASIC_SOUNDS];
+ for (i = 0; i < MAX_CUSTOM_COMBAT_SOUNDS && cg_customCombatSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customCombatSoundNames[i])) {
+ return ci->sounds[i + MAX_CUSTOM_BASIC_SOUNDS];
}
}
- for ( i = 0 ; i < MAX_CUSTOM_EXTRA_SOUNDS && cg_customExtraSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customExtraSoundNames[i] ) )
- {
- return ci->sounds[i+MAX_CUSTOM_BASIC_SOUNDS+MAX_CUSTOM_COMBAT_SOUNDS];
+ for (i = 0; i < MAX_CUSTOM_EXTRA_SOUNDS && cg_customExtraSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customExtraSoundNames[i])) {
+ return ci->sounds[i + MAX_CUSTOM_BASIC_SOUNDS + MAX_CUSTOM_COMBAT_SOUNDS];
}
}
- for ( i = 0 ; i < MAX_CUSTOM_JEDI_SOUNDS && cg_customJediSoundNames[i] ; i++ )
- {
- if ( !Q_stricmp( soundName, cg_customJediSoundNames[i] ) )
- {
- return ci->sounds[i+MAX_CUSTOM_BASIC_SOUNDS+MAX_CUSTOM_COMBAT_SOUNDS+MAX_CUSTOM_EXTRA_SOUNDS];
+ for (i = 0; i < MAX_CUSTOM_JEDI_SOUNDS && cg_customJediSoundNames[i]; i++) {
+ if (!Q_stricmp(soundName, cg_customJediSoundNames[i])) {
+ return ci->sounds[i + MAX_CUSTOM_BASIC_SOUNDS + MAX_CUSTOM_COMBAT_SOUNDS + MAX_CUSTOM_EXTRA_SOUNDS];
}
}
}
@@ -490,22 +359,20 @@ static sfxHandle_t CG_CustomSound( int entityNum, const char *soundName, int cus
}
#ifdef FINAL_BUILD
- CG_Printf( "Unknown custom sound: %s", soundName );
+ CG_Printf("Unknown custom sound: %s", soundName);
#else
- CG_Error( "Unknown custom sound: %s", soundName );
+ CG_Error("Unknown custom sound: %s", soundName);
#endif
return 0;
}
-qboolean CG_TryPlayCustomSound( vec3_t origin, int entityNum, soundChannel_t channel, const char *soundName, int customSoundSet )
-{
- sfxHandle_t soundIndex = CG_CustomSound( entityNum, soundName, customSoundSet );
- if ( !soundIndex )
- {
+qboolean CG_TryPlayCustomSound(vec3_t origin, int entityNum, soundChannel_t channel, const char *soundName, int customSoundSet) {
+ sfxHandle_t soundIndex = CG_CustomSound(entityNum, soundName, customSoundSet);
+ if (!soundIndex) {
return qfalse;
}
- cgi_S_StartSound( origin, entityNum, channel, soundIndex );
+ cgi_S_StartSound(origin, entityNum, channel, soundIndex);
return qtrue;
}
/*
@@ -515,127 +382,116 @@ CG_NewClientinfo
For player only, NPCs get them through NPC_stats and G_ModelIndex
======================
*/
-void CG_NewClientinfo( int clientNum )
-{
+void CG_NewClientinfo(int clientNum) {
clientInfo_t *ci;
- const char *configstring;
- const char *v;
-// const char *s;
-// int i;
+ const char *configstring;
+ const char *v;
+ // const char *s;
+ // int i;
- configstring = CG_ConfigString( clientNum + CS_PLAYERS );
+ configstring = CG_ConfigString(clientNum + CS_PLAYERS);
- if ( !configstring[0] )
- {
- return; // player just left
+ if (!configstring[0]) {
+ return; // player just left
}
- //ci = &cgs.clientinfo[clientNum];
- if ( !(g_entities[clientNum].client) )
- {
+ // ci = &cgs.clientinfo[clientNum];
+ if (!(g_entities[clientNum].client)) {
return;
}
ci = &g_entities[clientNum].client->clientInfo;
// isolate the player's name
v = Info_ValueForKey(configstring, "n");
- Q_strncpyz( ci->name, v, sizeof( ci->name ) );
+ Q_strncpyz(ci->name, v, sizeof(ci->name));
// handicap
- v = Info_ValueForKey( configstring, "hc" );
- ci->handicap = atoi( v );
+ v = Info_ValueForKey(configstring, "hc");
+ ci->handicap = atoi(v);
// team
- v = Info_ValueForKey( configstring, "t" );
- ci->team = (team_t) atoi( v );
+ v = Info_ValueForKey(configstring, "t");
+ ci->team = (team_t)atoi(v);
// legsModel
- v = Info_ValueForKey( configstring, "legsModel" );
+ v = Info_ValueForKey(configstring, "legsModel");
- Q_strncpyz( g_entities[clientNum].client->renderInfo.legsModelName, v,
- sizeof( g_entities[clientNum].client->renderInfo.legsModelName));
+ Q_strncpyz(g_entities[clientNum].client->renderInfo.legsModelName, v, sizeof(g_entities[clientNum].client->renderInfo.legsModelName));
// torsoModel
- v = Info_ValueForKey( configstring, "torsoModel" );
+ v = Info_ValueForKey(configstring, "torsoModel");
- Q_strncpyz( g_entities[clientNum].client->renderInfo.torsoModelName, v,
- sizeof( g_entities[clientNum].client->renderInfo.torsoModelName));
+ Q_strncpyz(g_entities[clientNum].client->renderInfo.torsoModelName, v, sizeof(g_entities[clientNum].client->renderInfo.torsoModelName));
// headModel
- v = Info_ValueForKey( configstring, "headModel" );
+ v = Info_ValueForKey(configstring, "headModel");
- Q_strncpyz( g_entities[clientNum].client->renderInfo.headModelName, v,
- sizeof( g_entities[clientNum].client->renderInfo.headModelName));
+ Q_strncpyz(g_entities[clientNum].client->renderInfo.headModelName, v, sizeof(g_entities[clientNum].client->renderInfo.headModelName));
// sounds
- v = Info_ValueForKey( configstring, "snd" );
+ v = Info_ValueForKey(configstring, "snd");
- ci->customBasicSoundDir = G_NewString( v );
+ ci->customBasicSoundDir = G_NewString(v);
- //player uses only the basic custom and combat sound sets, not the extra or jedi
+ // player uses only the basic custom and combat sound sets, not the extra or jedi
CG_RegisterCustomSounds(ci,
- 0, // int iSoundEntryBase,
- MAX_CUSTOM_BASIC_SOUNDS, // int iTableEntries,
- cg_customBasicSoundNames, // const char *ppsTable[],
- ci->customBasicSoundDir // const char *psDir
- );
+ 0, // int iSoundEntryBase,
+ MAX_CUSTOM_BASIC_SOUNDS, // int iTableEntries,
+ cg_customBasicSoundNames, // const char *ppsTable[],
+ ci->customBasicSoundDir // const char *psDir
+ );
CG_RegisterCustomSounds(ci,
- MAX_CUSTOM_BASIC_SOUNDS, // int iSoundEntryBase,
- MAX_CUSTOM_COMBAT_SOUNDS, // int iTableEntries,
- cg_customCombatSoundNames, // const char *ppsTable[],
- ci->customBasicSoundDir // const char *psDir
- );
+ MAX_CUSTOM_BASIC_SOUNDS, // int iSoundEntryBase,
+ MAX_CUSTOM_COMBAT_SOUNDS, // int iTableEntries,
+ cg_customCombatSoundNames, // const char *ppsTable[],
+ ci->customBasicSoundDir // const char *psDir
+ );
ci->infoValid = qfalse;
}
/*
CG_RegisterNPCCustomSounds
*/
-void CG_RegisterNPCCustomSounds( clientInfo_t *ci )
-{
-// const char *s;
-// int i;
+void CG_RegisterNPCCustomSounds(clientInfo_t *ci) {
+ // const char *s;
+ // int i;
// sounds
- if ( ci->customBasicSoundDir && ci->customBasicSoundDir[0] )
- {
+ if (ci->customBasicSoundDir && ci->customBasicSoundDir[0]) {
CG_RegisterCustomSounds(ci,
- 0, // int iSoundEntryBase,
- MAX_CUSTOM_BASIC_SOUNDS, // int iTableEntries,
- cg_customBasicSoundNames, // const char *ppsTable[],
- ci->customBasicSoundDir // const char *psDir
- );
+ 0, // int iSoundEntryBase,
+ MAX_CUSTOM_BASIC_SOUNDS, // int iTableEntries,
+ cg_customBasicSoundNames, // const char *ppsTable[],
+ ci->customBasicSoundDir // const char *psDir
+ );
}
- if ( ci->customCombatSoundDir && ci->customCombatSoundDir[0] )
- {
+ if (ci->customCombatSoundDir && ci->customCombatSoundDir[0]) {
CG_RegisterCustomSounds(ci,
- MAX_CUSTOM_BASIC_SOUNDS, // int iSoundEntryBase,
- MAX_CUSTOM_COMBAT_SOUNDS, // int iTableEntries,
- cg_customCombatSoundNames, // const char *ppsTable[],
- ci->customCombatSoundDir // const char *psDir
- );
+ MAX_CUSTOM_BASIC_SOUNDS, // int iSoundEntryBase,
+ MAX_CUSTOM_COMBAT_SOUNDS, // int iTableEntries,
+ cg_customCombatSoundNames, // const char *ppsTable[],
+ ci->customCombatSoundDir // const char *psDir
+ );
}
- if ( ci->customExtraSoundDir && ci->customExtraSoundDir[0] )
- {
+ if (ci->customExtraSoundDir && ci->customExtraSoundDir[0]) {
CG_RegisterCustomSounds(ci,
- MAX_CUSTOM_BASIC_SOUNDS+MAX_CUSTOM_COMBAT_SOUNDS, // int iSoundEntryBase,
- MAX_CUSTOM_EXTRA_SOUNDS, // int iTableEntries,
- cg_customExtraSoundNames, // const char *ppsTable[],
- ci->customExtraSoundDir // const char *psDir
- );
+ MAX_CUSTOM_BASIC_SOUNDS + MAX_CUSTOM_COMBAT_SOUNDS, // int iSoundEntryBase,
+ MAX_CUSTOM_EXTRA_SOUNDS, // int iTableEntries,
+ cg_customExtraSoundNames, // const char *ppsTable[],
+ ci->customExtraSoundDir // const char *psDir
+ );
}
- if ( ci->customJediSoundDir && ci->customJediSoundDir[0] )
- {
+ if (ci->customJediSoundDir && ci->customJediSoundDir[0]) {
CG_RegisterCustomSounds(ci,
- MAX_CUSTOM_BASIC_SOUNDS+MAX_CUSTOM_COMBAT_SOUNDS+MAX_CUSTOM_EXTRA_SOUNDS, // int iSoundEntryBase,
- MAX_CUSTOM_JEDI_SOUNDS, // int iTableEntries,
- cg_customJediSoundNames, // const char *ppsTable[],
- ci->customJediSoundDir // const char *psDir
- );
+ MAX_CUSTOM_BASIC_SOUNDS + MAX_CUSTOM_COMBAT_SOUNDS + MAX_CUSTOM_EXTRA_SOUNDS, // int iSoundEntryBase,
+ MAX_CUSTOM_JEDI_SOUNDS, // int iTableEntries,
+ cg_customJediSoundNames, // const char *ppsTable[],
+ ci->customJediSoundDir // const char *psDir
+ );
}
}
@@ -676,18 +532,15 @@ PLAYER ANIMATION
=============================================================================
*/
-qboolean ValidAnimFileIndex ( int index )
-{
- if ( index < 0 || index >= level.numKnownAnimFileSets )
- {
- Com_Printf( S_COLOR_RED "Bad animFileIndex: %d\n", index );
+qboolean ValidAnimFileIndex(int index) {
+ if (index < 0 || index >= level.numKnownAnimFileSets) {
+ Com_Printf(S_COLOR_RED "Bad animFileIndex: %d\n", index);
return qfalse;
}
return qtrue;
}
-
/*
======================
CG_ClearAnimEvtCache
@@ -695,13 +548,11 @@ CG_ClearAnimEvtCache
resets all the eventcache so that a vid restart will recache them
======================
*/
-void CG_ClearAnimEvtCache( void )
-{
+void CG_ClearAnimEvtCache(void) {
int i;
- for (i=0; i < level.numKnownAnimFileSets; i++)
- {
+ for (i = 0; i < level.numKnownAnimFileSets; i++) {
// TODO: Make this work again?
- // level.knownAnimFileSets[i].eventsParsed = qfalse;
+ // level.knownAnimFileSets[i].eventsParsed = qfalse;
}
}
@@ -710,31 +561,28 @@ void CG_ClearAnimEvtCache( void )
CG_SetLerpFrameAnimation
===============
*/
-static void CG_SetLerpFrameAnimation( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation )
-{
- animation_t *anim;
+static void CG_SetLerpFrameAnimation(clientInfo_t *ci, lerpFrame_t *lf, int newAnimation) {
+ animation_t *anim;
- if ( newAnimation < 0 || newAnimation >= MAX_ANIMATIONS )
- {
+ if (newAnimation < 0 || newAnimation >= MAX_ANIMATIONS) {
#ifdef FINAL_BUILD
newAnimation = 0;
#else
- CG_Error( "Bad animation number: %i for ", newAnimation, ci->name );
+ CG_Error("Bad animation number: %i for ", newAnimation, ci->name);
#endif
}
lf->animationNumber = newAnimation;
- if ( !ValidAnimFileIndex( ci->animFileIndex ) )
- {
+ if (!ValidAnimFileIndex(ci->animFileIndex)) {
#ifdef FINAL_BUILD
ci->animFileIndex = 0;
#else
- CG_Error( "Bad animFileIndex: %i for %s", ci->animFileIndex, ci->name);
+ CG_Error("Bad animFileIndex: %i for %s", ci->animFileIndex, ci->name);
#endif
}
- anim = &level.knownAnimFileSets[ci->animFileIndex].animations[ newAnimation ];
+ anim = &level.knownAnimFileSets[ci->animFileIndex].animations[newAnimation];
lf->animation = anim;
lf->animationTime = lf->frameTime + abs(anim->frameLerp);
@@ -748,33 +596,30 @@ Sets cg.snap, cg.oldFrame, and cg.backlerp
cg.time should be between oldFrameTime and frameTime after exit
===============
*/
-static qboolean CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float fpsMod, int entNum ) {
- int f, animFrameTime;
- animation_t *anim;
- qboolean newFrame = qfalse;
+static qboolean CG_RunLerpFrame(clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float fpsMod, int entNum) {
+ int f, animFrameTime;
+ animation_t *anim;
+ qboolean newFrame = qfalse;
- if(fpsMod > 2 || fpsMod < 0.5)
- {//should have been set right
+ if (fpsMod > 2 || fpsMod < 0.5) { // should have been set right
fpsMod = 1.0f;
}
// see if the animation sequence is switching
- //FIXME: allow multiple-frame overlapped lerping between sequences? - Possibly last 3 of last seq and first 3 of next seq?
- if ( newAnimation != lf->animationNumber || !lf->animation )
- {
- CG_SetLerpFrameAnimation( ci, lf, newAnimation );
+ // FIXME: allow multiple-frame overlapped lerping between sequences? - Possibly last 3 of last seq and first 3 of next seq?
+ if (newAnimation != lf->animationNumber || !lf->animation) {
+ CG_SetLerpFrameAnimation(ci, lf, newAnimation);
}
// if we have passed the current frame, move it to
// oldFrame and calculate a new frame
- if ( cg.time >= lf->frameTime )
- {
+ if (cg.time >= lf->frameTime) {
lf->oldFrame = lf->frame;
lf->oldFrameTime = lf->frameTime;
// get the next frame based on the animation
anim = lf->animation;
- //Do we need to speed up or slow down the anim?
+ // Do we need to speed up or slow down the anim?
/*if(fpsMod != 1.0)
{//Note! despite it's name, a higher fpsMod slows down the anim, a lower one speeds it up
animFrameTime = ceil(lf->frameTime * fpsMod);
@@ -783,47 +628,35 @@ static qboolean CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnima
{
animFrameTime = abs(anim->frameLerp);
- //special hack for player to ensure quick weapon change
- if ( entNum == 0 )
- {
- if ( lf->animationNumber == TORSO_DROPWEAP1 || lf->animationNumber == TORSO_RAISEWEAP1 )
- {
+ // special hack for player to ensure quick weapon change
+ if (entNum == 0) {
+ if (lf->animationNumber == TORSO_DROPWEAP1 || lf->animationNumber == TORSO_RAISEWEAP1) {
animFrameTime = 50;
}
}
}
- if ( cg.time < lf->animationTime )
- {
- lf->frameTime = lf->animationTime; // initial lerp
- }
- else
- {
+ if (cg.time < lf->animationTime) {
+ lf->frameTime = lf->animationTime; // initial lerp
+ } else {
lf->frameTime = lf->oldFrameTime + animFrameTime;
}
- f = ( lf->frameTime - lf->animationTime ) / animFrameTime;
- if ( f >= anim->numFrames )
- {//Reached the end of the anim
- //FIXME: Need to set a flag here to TASK_COMPLETE
+ f = (lf->frameTime - lf->animationTime) / animFrameTime;
+ if (f >= anim->numFrames) { // Reached the end of the anim
+ // FIXME: Need to set a flag here to TASK_COMPLETE
f -= anim->numFrames;
- if ( anim->loopFrames != -1 ) //Before 0 meant no loop
+ if (anim->loopFrames != -1) // Before 0 meant no loop
{
- if(anim->numFrames - anim->loopFrames == 0)
- {
+ if (anim->numFrames - anim->loopFrames == 0) {
f %= anim->numFrames;
- }
- else
- {
+ } else {
f %= (anim->numFrames - anim->loopFrames);
}
f += anim->loopFrames;
- }
- else
- {
+ } else {
f = anim->numFrames - 1;
- if (f<0)
- {
+ if (f < 0) {
f = 0;
}
// the animation is stuck at the end, so it
@@ -832,61 +665,47 @@ static qboolean CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnima
}
}
- if ( anim->frameLerp < 0 )
- {
+ if (anim->frameLerp < 0) {
lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
- }
- else
- {
+ } else {
lf->frame = anim->firstFrame + f;
}
- if ( cg.time > lf->frameTime )
- {
+ if (cg.time > lf->frameTime) {
lf->frameTime = cg.time;
}
newFrame = qtrue;
}
- if ( lf->frameTime > cg.time + 200 )
- {
+ if (lf->frameTime > cg.time + 200) {
lf->frameTime = cg.time;
}
- if ( lf->oldFrameTime > cg.time )
- {
+ if (lf->oldFrameTime > cg.time) {
lf->oldFrameTime = cg.time;
}
// calculate current lerp value
- if ( lf->frameTime == lf->oldFrameTime )
- {
+ if (lf->frameTime == lf->oldFrameTime) {
lf->backlerp = 0;
- }
- else
- {
- lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
+ } else {
+ lf->backlerp = 1.0 - (float)(cg.time - lf->oldFrameTime) / (lf->frameTime - lf->oldFrameTime);
}
return newFrame;
}
-
/*
===============
CG_ClearLerpFrame
===============
*/
-static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationNumber )
-{
+static void CG_ClearLerpFrame(clientInfo_t *ci, lerpFrame_t *lf, int animationNumber) {
lf->frameTime = lf->oldFrameTime = cg.time;
- CG_SetLerpFrameAnimation( ci, lf, animationNumber );
- if ( lf->animation->frameLerp < 0 )
- {//Plays backwards
+ CG_SetLerpFrameAnimation(ci, lf, animationNumber);
+ if (lf->animation->frameLerp < 0) { // Plays backwards
lf->oldFrame = lf->frame = (lf->animation->firstFrame + lf->animation->numFrames);
- }
- else
- {
+ } else {
lf->oldFrame = lf->frame = lf->animation->firstFrame;
}
}
@@ -896,264 +715,211 @@ static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationN
CG_PlayerAnimation
===============
*/
-static void CG_PlayerAnimation( centity_t *cent, int *legsOld, int *legs, float *legsBackLerp,
- int *torsoOld, int *torso, float *torsoBackLerp ) {
- clientInfo_t *ci;
- int legsAnim;
- int legsTurnAnim = -1;
- qboolean newLegsFrame = qfalse;
- qboolean newTorsoFrame = qfalse;
+static void CG_PlayerAnimation(centity_t *cent, int *legsOld, int *legs, float *legsBackLerp, int *torsoOld, int *torso, float *torsoBackLerp) {
+ clientInfo_t *ci;
+ int legsAnim;
+ int legsTurnAnim = -1;
+ qboolean newLegsFrame = qfalse;
+ qboolean newTorsoFrame = qfalse;
ci = ¢->gent->client->clientInfo;
- //Changed this from cent->currentState.legsAnim to cent->gent->client->ps.legsAnim because it was screwing up our timers when we've just changed anims while turning
+ // Changed this from cent->currentState.legsAnim to cent->gent->client->ps.legsAnim because it was screwing up our timers when we've just changed anims
+ // while turning
legsAnim = cent->gent->client->ps.legsAnim;
// do the shuffle turn frames locally (MAN this is an Fugly-ass hack!)
- if ( cent->pe.legs.yawing )
- {
- legsTurnAnim = PM_GetTurnAnim( cent->gent, legsAnim );
+ if (cent->pe.legs.yawing) {
+ legsTurnAnim = PM_GetTurnAnim(cent->gent, legsAnim);
}
- if ( legsTurnAnim != -1 )
- {
- newLegsFrame = CG_RunLerpFrame( ci, ¢->pe.legs, legsTurnAnim, cent->gent->client->renderInfo.legsFpsMod, cent->gent->s.number );
- //This line doesn't seem to serve any useful purpose, rather it
- //breaks things since any task waiting for a lower anim to complete
- //never will finish if this happens!!!
- //cent->gent->client->ps.legsAnimTimer = 0;
- }
- else
- {
- newLegsFrame = CG_RunLerpFrame( ci, ¢->pe.legs, legsAnim, cent->gent->client->renderInfo.legsFpsMod, cent->gent->s.number);
+ if (legsTurnAnim != -1) {
+ newLegsFrame = CG_RunLerpFrame(ci, ¢->pe.legs, legsTurnAnim, cent->gent->client->renderInfo.legsFpsMod, cent->gent->s.number);
+ // This line doesn't seem to serve any useful purpose, rather it
+ // breaks things since any task waiting for a lower anim to complete
+ // never will finish if this happens!!!
+ // cent->gent->client->ps.legsAnimTimer = 0;
+ } else {
+ newLegsFrame = CG_RunLerpFrame(ci, ¢->pe.legs, legsAnim, cent->gent->client->renderInfo.legsFpsMod, cent->gent->s.number);
}
*legsOld = cent->pe.legs.oldFrame;
*legs = cent->pe.legs.frame;
*legsBackLerp = cent->pe.legs.backlerp;
- if( newLegsFrame )
- {
- if ( ValidAnimFileIndex( ci->animFileIndex ) )
- {
- CG_PlayerAnimEvents( ci->animFileIndex, qfalse, cent->pe.legs.frame, cent->pe.legs.frame, cent->currentState.number );
+ if (newLegsFrame) {
+ if (ValidAnimFileIndex(ci->animFileIndex)) {
+ CG_PlayerAnimEvents(ci->animFileIndex, qfalse, cent->pe.legs.frame, cent->pe.legs.frame, cent->currentState.number);
}
}
- newTorsoFrame = CG_RunLerpFrame( ci, ¢->pe.torso, cent->gent->client->ps.torsoAnim, cent->gent->client->renderInfo.torsoFpsMod, cent->gent->s.number );
+ newTorsoFrame = CG_RunLerpFrame(ci, ¢->pe.torso, cent->gent->client->ps.torsoAnim, cent->gent->client->renderInfo.torsoFpsMod, cent->gent->s.number);
*torsoOld = cent->pe.torso.oldFrame;
*torso = cent->pe.torso.frame;
*torsoBackLerp = cent->pe.torso.backlerp;
- if( newTorsoFrame )
- {
- if ( ValidAnimFileIndex( ci->animFileIndex ) )
- {
- CG_PlayerAnimEvents(ci->animFileIndex, qtrue, cent->pe.torso.frame, cent->pe.torso.frame, cent->currentState.number );
+ if (newTorsoFrame) {
+ if (ValidAnimFileIndex(ci->animFileIndex)) {
+ CG_PlayerAnimEvents(ci->animFileIndex, qtrue, cent->pe.torso.frame, cent->pe.torso.frame, cent->currentState.number);
}
}
}
-
-extern int PM_LegsAnimForFrame( gentity_t *ent, int legsFrame );
-extern int PM_TorsoAnimForFrame( gentity_t *ent, int torsoFrame );
-static void CG_PlayerAnimEventDo( centity_t *cent, animevent_t *animEvent )
-{
- //FIXME: pass in event, switch off the type
- if ( cent == NULL || animEvent == NULL )
- {
+extern int PM_LegsAnimForFrame(gentity_t *ent, int legsFrame);
+extern int PM_TorsoAnimForFrame(gentity_t *ent, int torsoFrame);
+static void CG_PlayerAnimEventDo(centity_t *cent, animevent_t *animEvent) {
+ // FIXME: pass in event, switch off the type
+ if (cent == NULL || animEvent == NULL) {
return;
}
soundChannel_t channel = CHAN_AUTO;
- switch ( animEvent->eventType )
- {
+ switch (animEvent->eventType) {
case AEV_SOUNDCHAN:
channel = (soundChannel_t)animEvent->eventData[AED_SOUNDCHANNEL];
case AEV_SOUND:
// are there variations on the sound?
{
- const int holdSnd = animEvent->eventData[ AED_SOUNDINDEX_START+Q_irand( 0, animEvent->eventData[AED_SOUND_NUMRANDOMSNDS] ) ];
- if ( holdSnd > 0 )
- {
- if ( cgs.sound_precache[ holdSnd ] )
- {
- cgi_S_StartSound( NULL, cent->currentState.clientNum, channel, cgs.sound_precache[holdSnd ] );
- }
- else
- {//try a custom sound
- const char *s = CG_ConfigString( CS_SOUNDS + holdSnd );
- CG_TryPlayCustomSound(NULL, cent->currentState.clientNum, channel, va("%s.wav",s), CS_TRY_ALL );
+ const int holdSnd = animEvent->eventData[AED_SOUNDINDEX_START + Q_irand(0, animEvent->eventData[AED_SOUND_NUMRANDOMSNDS])];
+ if (holdSnd > 0) {
+ if (cgs.sound_precache[holdSnd]) {
+ cgi_S_StartSound(NULL, cent->currentState.clientNum, channel, cgs.sound_precache[holdSnd]);
+ } else { // try a custom sound
+ const char *s = CG_ConfigString(CS_SOUNDS + holdSnd);
+ CG_TryPlayCustomSound(NULL, cent->currentState.clientNum, channel, va("%s.wav", s), CS_TRY_ALL);
}
}
}
break;
case AEV_SABER_SWING:
- if ( cent->gent )
- {//cheat over to game side and play sound from there...
- WP_SaberSwingSound( cent->gent, animEvent->eventData[AED_SABER_SWING_SABERNUM], (swingType_t)animEvent->eventData[AED_SABER_SWING_TYPE] );
+ if (cent->gent) { // cheat over to game side and play sound from there...
+ WP_SaberSwingSound(cent->gent, animEvent->eventData[AED_SABER_SWING_SABERNUM], (swingType_t)animEvent->eventData[AED_SABER_SWING_TYPE]);
}
break;
case AEV_SABER_SPIN:
- if ( cent->gent
- && cent->gent->client )
- {
+ if (cent->gent && cent->gent->client) {
saberInfo_t *saber = ¢->gent->client->ps.saber[animEvent->eventData[AED_SABER_SPIN_SABERNUM]];
- if ( saber )
- {
+ if (saber) {
int spinSound = 0;
- if ( saber->spinSound
- && cgs.sound_precache[saber->spinSound] )
- {//use override
+ if (saber->spinSound && cgs.sound_precache[saber->spinSound]) { // use override
spinSound = cgs.sound_precache[saber->spinSound];
- }
- else
- {
- switch ( animEvent->eventData[AED_SABER_SPIN_TYPE] )
- {
- case 0://saberspinoff
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspinoff.wav" );
+ } else {
+ switch (animEvent->eventData[AED_SABER_SPIN_TYPE]) {
+ case 0: // saberspinoff
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspinoff.wav");
break;
- case 1://saberspin
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin.wav" );
+ case 1: // saberspin
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin.wav");
break;
- case 2://saberspin1
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" );
+ case 2: // saberspin1
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin1.wav");
break;
- case 3://saberspin2
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin2.wav" );
+ case 3: // saberspin2
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin2.wav");
break;
- case 4://saberspin3
- spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin3.wav" );
+ case 4: // saberspin3
+ spinSound = cgi_S_RegisterSound("sound/weapons/saber/saberspin3.wav");
break;
- default://random saberspin1-3
- spinSound = cgi_S_RegisterSound( va( "sound/weapons/saber/saberspin%d.wav", Q_irand(1,3)) );
+ default: // random saberspin1-3
+ spinSound = cgi_S_RegisterSound(va("sound/weapons/saber/saberspin%d.wav", Q_irand(1, 3)));
break;
}
}
- if ( spinSound )
- {
- cgi_S_StartSound( NULL, cent->currentState.clientNum, CHAN_AUTO, spinSound );
+ if (spinSound) {
+ cgi_S_StartSound(NULL, cent->currentState.clientNum, CHAN_AUTO, spinSound);
}
}
}
break;
case AEV_FOOTSTEP:
- CG_PlayerFootsteps( cent, (footstepType_t)animEvent->eventData[AED_FOOTSTEP_TYPE] );
+ CG_PlayerFootsteps(cent, (footstepType_t)animEvent->eventData[AED_FOOTSTEP_TYPE]);
break;
case AEV_EFFECT:
- if ( animEvent->eventData[AED_EFFECTINDEX] == -1 )
- {//invalid effect
- if ( animEvent->stringData != NULL
- && animEvent->stringData[0] )
- {//some sort of hard-coded effect
- if ( Q_stricmp( "push_l", animEvent->stringData ) == 0 )
- {
- cgi_S_StartSound ( cent->lerpOrigin, cent->currentState.clientNum, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/force/push.wav" ) );
- cent->gent->client->ps.powerups[PW_FORCE_PUSH] = cg.time + animEvent->eventData[AED_EFFECT_PROBABILITY];//AED_EFFECT_PROBABILITY in this case is the number of ms for the effect to last
+ if (animEvent->eventData[AED_EFFECTINDEX] == -1) { // invalid effect
+ if (animEvent->stringData != NULL && animEvent->stringData[0]) { // some sort of hard-coded effect
+ if (Q_stricmp("push_l", animEvent->stringData) == 0) {
+ cgi_S_StartSound(cent->lerpOrigin, cent->currentState.clientNum, CHAN_AUTO, cgi_S_RegisterSound("sound/weapons/force/push.wav"));
+ cent->gent->client->ps.powerups[PW_FORCE_PUSH] =
+ cg.time +
+ animEvent->eventData[AED_EFFECT_PROBABILITY]; // AED_EFFECT_PROBABILITY in this case is the number of ms for the effect to last
cent->gent->client->pushEffectFadeTime = 0;
- }
- else if ( Q_stricmp( "push_r", animEvent->stringData ) == 0 )
- {
- cgi_S_StartSound ( cent->lerpOrigin, cent->currentState.clientNum, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/force/push.wav" ) );
- cent->gent->client->ps.powerups[PW_FORCE_PUSH_RHAND] = cg.time + animEvent->eventData[AED_EFFECT_PROBABILITY];//AED_EFFECT_PROBABILITY in this case is the number of ms for the effect to last
+ } else if (Q_stricmp("push_r", animEvent->stringData) == 0) {
+ cgi_S_StartSound(cent->lerpOrigin, cent->currentState.clientNum, CHAN_AUTO, cgi_S_RegisterSound("sound/weapons/force/push.wav"));
+ cent->gent->client->ps.powerups[PW_FORCE_PUSH_RHAND] =
+ cg.time +
+ animEvent->eventData[AED_EFFECT_PROBABILITY]; // AED_EFFECT_PROBABILITY in this case is the number of ms for the effect to last
cent->gent->client->pushEffectFadeTime = 0;
- }
- else if ( Q_stricmp( "scepter_beam", animEvent->stringData ) == 0 )
- {
+ } else if (Q_stricmp("scepter_beam", animEvent->stringData) == 0) {
int modelIndex = cent->gent->weaponModel[1];
- if ( modelIndex <= 0 )
- {
+ if (modelIndex <= 0) {
modelIndex = cent->gent->cinematicModel;
}
- if ( modelIndex > 0 )
- {//we have a cinematic model
- int boltIndex = gi.G2API_AddBolt( ¢->gent->ghoul2[modelIndex], "*flash" );
- if ( boltIndex > -1 )
- {//cinematic model has a flash bolt
- CG_PlayEffectBolted( "scepter/beam.efx", modelIndex, boltIndex, cent->currentState.clientNum, cent->lerpOrigin, animEvent->eventData[AED_EFFECT_PROBABILITY], qtrue );//AED_EFFECT_PROBABILITY in this case is the number of ms for the effect to last
+ if (modelIndex > 0) { // we have a cinematic model
+ int boltIndex = gi.G2API_AddBolt(¢->gent->ghoul2[modelIndex], "*flash");
+ if (boltIndex > -1) { // cinematic model has a flash bolt
+ CG_PlayEffectBolted("scepter/beam.efx", modelIndex, boltIndex, cent->currentState.clientNum, cent->lerpOrigin,
+ animEvent->eventData[AED_EFFECT_PROBABILITY],
+ qtrue); // AED_EFFECT_PROBABILITY in this case is the number of ms for the effect to last
}
}
}
- //FIXME: add more
+ // FIXME: add more
}
- }
- else
- {
- //add bolt, play effect
- if ( animEvent->stringData != NULL && cent && cent->gent && cent->gent->ghoul2.size() )
- {//have a bolt name we want to use
+ } else {
+ // add bolt, play effect
+ if (animEvent->stringData != NULL && cent && cent->gent && cent->gent->ghoul2.size()) { // have a bolt name we want to use
animEvent->eventData[AED_MODELINDEX] = cent->gent->playerModel;
- if ( ( Q_stricmpn( "*blade", animEvent->stringData, 6 ) == 0
- || Q_stricmp( "*flash", animEvent->stringData ) == 0 )
- && cent->gent->weaponModel[0] > 0 )
- {//must be a weapon, try weapon 0?
- animEvent->eventData[AED_BOLTINDEX] = gi.G2API_AddBolt( ¢->gent->ghoul2[cent->gent->weaponModel[0]], animEvent->stringData );
- if ( animEvent->eventData[AED_BOLTINDEX] != -1 )
- {//found it!
+ if ((Q_stricmpn("*blade", animEvent->stringData, 6) == 0 || Q_stricmp("*flash", animEvent->stringData) == 0) &&
+ cent->gent->weaponModel[0] > 0) { // must be a weapon, try weapon 0?
+ animEvent->eventData[AED_BOLTINDEX] = gi.G2API_AddBolt(¢->gent->ghoul2[cent->gent->weaponModel[0]], animEvent->stringData);
+ if (animEvent->eventData[AED_BOLTINDEX] != -1) { // found it!
animEvent->eventData[AED_MODELINDEX] = cent->gent->weaponModel[0];
+ } else { // hmm, just try on the player model, then?
+ animEvent->eventData[AED_BOLTINDEX] = gi.G2API_AddBolt(¢->gent->ghoul2[cent->gent->playerModel], animEvent->stringData);
}
- else
- {//hmm, just try on the player model, then?
- animEvent->eventData[AED_BOLTINDEX] = gi.G2API_AddBolt( ¢->gent->ghoul2[cent->gent->playerModel], animEvent->stringData );
- }
- }
- else
- {
- animEvent->eventData[AED_BOLTINDEX] = gi.G2API_AddBolt( ¢->gent->ghoul2[cent->gent->playerModel], animEvent->stringData );
+ } else {
+ animEvent->eventData[AED_BOLTINDEX] = gi.G2API_AddBolt(¢->gent->ghoul2[cent->gent->playerModel], animEvent->stringData);
}
- animEvent->stringData = NULL;//so we don't try to do this again
- }
- if ( animEvent->eventData[AED_BOLTINDEX] != -1 )
- {//have a bolt we want to play the effect on
- CG_PlayEffectIDBolted( animEvent->eventData[AED_EFFECTINDEX],
- animEvent->eventData[AED_MODELINDEX],
- animEvent->eventData[AED_BOLTINDEX],
- cent->currentState.clientNum,
- cent->lerpOrigin );
+ animEvent->stringData = NULL; // so we don't try to do this again
}
- else
- {//play at origin? FIXME: maybe allow a fwd/rt/up offset?
- const vec3_t up = {0,0,1};
- CG_PlayEffectID( animEvent->eventData[AED_EFFECTINDEX], cent->lerpOrigin, up );
- //G_PlayEffect( animEvent->eventData[AED_EFFECTINDEX], cent->lerpOrigin, up );
- //theFxScheduler.PlayEffect( animEvent->eventData[AED_EFFECTINDEX], cent->lerpOrigin, qfalse );
+ if (animEvent->eventData[AED_BOLTINDEX] != -1) { // have a bolt we want to play the effect on
+ CG_PlayEffectIDBolted(animEvent->eventData[AED_EFFECTINDEX], animEvent->eventData[AED_MODELINDEX], animEvent->eventData[AED_BOLTINDEX],
+ cent->currentState.clientNum, cent->lerpOrigin);
+ } else { // play at origin? FIXME: maybe allow a fwd/rt/up offset?
+ const vec3_t up = {0, 0, 1};
+ CG_PlayEffectID(animEvent->eventData[AED_EFFECTINDEX], cent->lerpOrigin, up);
+ // G_PlayEffect( animEvent->eventData[AED_EFFECTINDEX], cent->lerpOrigin, up );
+ // theFxScheduler.PlayEffect( animEvent->eventData[AED_EFFECTINDEX], cent->lerpOrigin, qfalse );
}
}
break;
case AEV_FIRE:
- //add fire event
- if ( animEvent->eventData[AED_FIRE_ALT] )
- {
- G_AddEvent( cent->gent, EV_ALT_FIRE, 0 );
- }
- else
- {
- G_AddEvent( cent->gent, EV_FIRE_WEAPON, 0 );
+ // add fire event
+ if (animEvent->eventData[AED_FIRE_ALT]) {
+ G_AddEvent(cent->gent, EV_ALT_FIRE, 0);
+ } else {
+ G_AddEvent(cent->gent, EV_FIRE_WEAPON, 0);
}
break;
case AEV_MOVE:
- //make him jump
- if ( cent && cent->gent && cent->gent->client )
- {
- if ( cent->gent->client->ps.groundEntityNum != ENTITYNUM_NONE )
- {//on something
- vec3_t fwd, rt, up, angles = {0, cent->gent->client->ps.viewangles[YAW], 0};
- AngleVectors( angles, fwd, rt, up );
- //FIXME: set or add to velocity?
- VectorScale( fwd, animEvent->eventData[AED_MOVE_FWD], cent->gent->client->ps.velocity );
- VectorMA( cent->gent->client->ps.velocity, animEvent->eventData[AED_MOVE_RT], rt, cent->gent->client->ps.velocity );
- VectorMA( cent->gent->client->ps.velocity, animEvent->eventData[AED_MOVE_UP], up, cent->gent->client->ps.velocity );
-
- if ( animEvent->eventData[AED_MOVE_UP] > 0 )
- {//a jump
+ // make him jump
+ if (cent && cent->gent && cent->gent->client) {
+ if (cent->gent->client->ps.groundEntityNum != ENTITYNUM_NONE) { // on something
+ vec3_t fwd, rt, up, angles = {0, cent->gent->client->ps.viewangles[YAW], 0};
+ AngleVectors(angles, fwd, rt, up);
+ // FIXME: set or add to velocity?
+ VectorScale(fwd, animEvent->eventData[AED_MOVE_FWD], cent->gent->client->ps.velocity);
+ VectorMA(cent->gent->client->ps.velocity, animEvent->eventData[AED_MOVE_RT], rt, cent->gent->client->ps.velocity);
+ VectorMA(cent->gent->client->ps.velocity, animEvent->eventData[AED_MOVE_UP], up, cent->gent->client->ps.velocity);
+
+ if (animEvent->eventData[AED_MOVE_UP] > 0) { // a jump
cent->gent->client->ps.pm_flags |= PMF_JUMPING;
- G_AddEvent( cent->gent, EV_JUMP, 0 );
- //FIXME: if have force jump, do this? or specify sound in the event data?
- //cent->gent->client->ps.forceJumpZStart = cent->gent->client->ps.origin[2];//so we don't take damage if we land at same height
- //G_SoundOnEnt( cent->gent, CHAN_BODY, "sound/weapons/force/jump.wav" );
+ G_AddEvent(cent->gent, EV_JUMP, 0);
+ // FIXME: if have force jump, do this? or specify sound in the event data?
+ // cent->gent->client->ps.forceJumpZStart = cent->gent->client->ps.origin[2];//so we don't take damage if we land at same height
+ // G_SoundOnEnt( cent->gent, CHAN_BODY, "sound/weapons/force/jump.wav" );
}
}
}
@@ -1164,122 +930,86 @@ static void CG_PlayerAnimEventDo( centity_t *cent, animevent_t *animEvent )
}
}
-static void CG_PlayerAnimEvents( int animFileIndex, qboolean torso, int oldFrame, int frame, int entNum )
-{
- int i;
- int firstFrame = 0, lastFrame = 0;
- qboolean doEvent = qfalse, inSameAnim = qfalse, loopAnim = qfalse, match = qfalse, animBackward = qfalse;
+static void CG_PlayerAnimEvents(int animFileIndex, qboolean torso, int oldFrame, int frame, int entNum) {
+ int i;
+ int firstFrame = 0, lastFrame = 0;
+ qboolean doEvent = qfalse, inSameAnim = qfalse, loopAnim = qfalse, match = qfalse, animBackward = qfalse;
animevent_t *animEvents = NULL;
- int glaIndex = -1;
+ int glaIndex = -1;
- if ( g_entities[entNum].ghoul2.size() )
- {
+ if (g_entities[entNum].ghoul2.size()) {
glaIndex = gi.G2API_GetAnimIndex(&(g_entities[entNum].ghoul2[0]));
}
- if ( torso )
- {
+ if (torso) {
animEvents = level.knownAnimFileSets[animFileIndex].torsoAnimEvents;
- }
- else
- {
+ } else {
animEvents = level.knownAnimFileSets[animFileIndex].legsAnimEvents;
}
- if ( abs(oldFrame-frame) > 1 )
- {//given a range, see if keyFrame falls in that range
+ if (abs(oldFrame - frame) > 1) { // given a range, see if keyFrame falls in that range
int oldAnim, anim;
- if ( torso )
- {
- //more precise, slower
- oldAnim = PM_TorsoAnimForFrame( &g_entities[entNum], oldFrame );
- anim = PM_TorsoAnimForFrame( &g_entities[entNum], frame );
- }
- else
- {
- //more precise, slower
- oldAnim = PM_LegsAnimForFrame( &g_entities[entNum], oldFrame );
- anim = PM_LegsAnimForFrame( &g_entities[entNum], frame );
+ if (torso) {
+ // more precise, slower
+ oldAnim = PM_TorsoAnimForFrame(&g_entities[entNum], oldFrame);
+ anim = PM_TorsoAnimForFrame(&g_entities[entNum], frame);
+ } else {
+ // more precise, slower
+ oldAnim = PM_LegsAnimForFrame(&g_entities[entNum], oldFrame);
+ anim = PM_LegsAnimForFrame(&g_entities[entNum], frame);
}
- if ( anim != oldAnim )
- {//not in same anim
+ if (anim != oldAnim) { // not in same anim
inSameAnim = qfalse;
- //FIXME: we *could* see if the oldFrame was *just about* to play the keyframed sound...
- }
- else
- {//still in same anim, check for looping anim
+ // FIXME: we *could* see if the oldFrame was *just about* to play the keyframed sound...
+ } else { // still in same anim, check for looping anim
inSameAnim = qtrue;
animation_t *animation = &level.knownAnimFileSets[animFileIndex].animations[anim];
- animBackward = (qboolean)(animation->frameLerp<0);
- if ( animation->loopFrames != -1 )
- {//a looping anim!
+ animBackward = (qboolean)(animation->frameLerp < 0);
+ if (animation->loopFrames != -1) { // a looping anim!
loopAnim = qtrue;
firstFrame = animation->firstFrame;
- lastFrame = animation->firstFrame+animation->numFrames;
+ lastFrame = animation->firstFrame + animation->numFrames;
}
}
}
- hstring myModel = g_entities[entNum].NPC_type; //apparently NPC_type is always the same as the model name???
+ hstring myModel = g_entities[entNum].NPC_type; // apparently NPC_type is always the same as the model name???
// Check for anim event
- for ( i=0; i < MAX_ANIM_EVENTS; ++i )
- {
- if ( animEvents[i].eventType == AEV_NONE ) // No event, end of list
+ for (i = 0; i < MAX_ANIM_EVENTS; ++i) {
+ if (animEvents[i].eventType == AEV_NONE) // No event, end of list
{
break;
}
- if (glaIndex != -1 && animEvents[i].glaIndex!=glaIndex)
- {
+ if (glaIndex != -1 && animEvents[i].glaIndex != glaIndex) {
continue;
}
match = qfalse;
- if (animEvents[i].modelOnly==0 || animEvents[i].modelOnly==myModel.handle())
- {
- if ( animEvents[i].keyFrame == frame )
- {//exact match
+ if (animEvents[i].modelOnly == 0 || animEvents[i].modelOnly == myModel.handle()) {
+ if (animEvents[i].keyFrame == frame) { // exact match
match = qtrue;
- }
- else if ( abs(oldFrame-frame) > 1 )//&& cg_reliableAnimEvents.integer )
- {//given a range, see if keyFrame falls in that range
- if ( inSameAnim )
- {//if changed anims altogether, sorry, the sound is lost
- if ( abs(oldFrame-animEvents[i].keyFrame) <= 3
- || abs(frame-animEvents[i].keyFrame) <= 3 )
- {//must be at least close to the keyframe
- if ( animBackward )
- {//animation plays backwards
- if ( oldFrame > animEvents[i].keyFrame && frame < animEvents[i].keyFrame )
- {//old to new passed through keyframe
+ } else if (abs(oldFrame - frame) > 1) //&& cg_reliableAnimEvents.integer )
+ { // given a range, see if keyFrame falls in that range
+ if (inSameAnim) { // if changed anims altogether, sorry, the sound is lost
+ if (abs(oldFrame - animEvents[i].keyFrame) <= 3 || abs(frame - animEvents[i].keyFrame) <= 3) { // must be at least close to the keyframe
+ if (animBackward) { // animation plays backwards
+ if (oldFrame > animEvents[i].keyFrame && frame < animEvents[i].keyFrame) { // old to new passed through keyframe
match = qtrue;
- }
- else if ( loopAnim )
- {//hmm, didn't pass through it linearally, see if we looped
- if ( animEvents[i].keyFrame >= firstFrame && animEvents[i].keyFrame < lastFrame )
- {//keyframe is in this anim
- if ( oldFrame > animEvents[i].keyFrame
- && frame > oldFrame )
- {//old to new passed through keyframe
+ } else if (loopAnim) { // hmm, didn't pass through it linearally, see if we looped
+ if (animEvents[i].keyFrame >= firstFrame && animEvents[i].keyFrame < lastFrame) { // keyframe is in this anim
+ if (oldFrame > animEvents[i].keyFrame && frame > oldFrame) { // old to new passed through keyframe
match = qtrue;
}
}
}
- }
- else
- {//anim plays forwards
- if ( oldFrame < animEvents[i].keyFrame && frame > animEvents[i].keyFrame )
- {//old to new passed through keyframe
+ } else { // anim plays forwards
+ if (oldFrame < animEvents[i].keyFrame && frame > animEvents[i].keyFrame) { // old to new passed through keyframe
match = qtrue;
- }
- else if ( loopAnim )
- {//hmm, didn't pass through it linearally, see if we looped
- if ( animEvents[i].keyFrame >= firstFrame && animEvents[i].keyFrame < lastFrame )
- {//keyframe is in this anim
- if ( oldFrame < animEvents[i].keyFrame
- && frame < oldFrame )
- {//old to new passed through keyframe
+ } else if (loopAnim) { // hmm, didn't pass through it linearally, see if we looped
+ if (animEvents[i].keyFrame >= firstFrame && animEvents[i].keyFrame < lastFrame) { // keyframe is in this anim
+ if (oldFrame < animEvents[i].keyFrame && frame < oldFrame) { // old to new passed through keyframe
match = qtrue;
}
}
@@ -1288,75 +1018,62 @@ static void CG_PlayerAnimEvents( int animFileIndex, qboolean torso, int oldFrame
}
}
}
- if ( match )
- {
- switch ( animEvents[i].eventType )
- {
+ if (match) {
+ switch (animEvents[i].eventType) {
case AEV_SOUNDCHAN:
case AEV_SOUND:
// Determine probability of playing sound
- if (!animEvents[i].eventData[AED_SOUND_PROBABILITY]) // 100%
+ if (!animEvents[i].eventData[AED_SOUND_PROBABILITY]) // 100%
{
doEvent = qtrue;
- }
- else if (animEvents[i].eventData[AED_SOUND_PROBABILITY] > Q_irand(0, 99) )
- {
+ } else if (animEvents[i].eventData[AED_SOUND_PROBABILITY] > Q_irand(0, 99)) {
doEvent = qtrue;
}
break;
case AEV_SABER_SWING:
// Determine probability of playing sound
- if (!animEvents[i].eventData[AED_SABER_SWING_PROBABILITY]) // 100%
+ if (!animEvents[i].eventData[AED_SABER_SWING_PROBABILITY]) // 100%
{
doEvent = qtrue;
- }
- else if (animEvents[i].eventData[AED_SABER_SWING_PROBABILITY] > Q_irand(0, 99) )
- {
+ } else if (animEvents[i].eventData[AED_SABER_SWING_PROBABILITY] > Q_irand(0, 99)) {
doEvent = qtrue;
}
break;
case AEV_SABER_SPIN:
// Determine probability of playing sound
- if (!animEvents[i].eventData[AED_SABER_SPIN_PROBABILITY]) // 100%
+ if (!animEvents[i].eventData[AED_SABER_SPIN_PROBABILITY]) // 100%
{
doEvent = qtrue;
- }
- else if (animEvents[i].eventData[AED_SABER_SPIN_PROBABILITY] > Q_irand(0, 99) )
- {
+ } else if (animEvents[i].eventData[AED_SABER_SPIN_PROBABILITY] > Q_irand(0, 99)) {
doEvent = qtrue;
}
break;
case AEV_FOOTSTEP:
// Determine probability of playing sound
- //Com_Printf( "Footstep event on frame %d, even should be on frame %d, off by %d\n", frame, animEvents[i].keyFrame, frame-animEvents[i].keyFrame );
- if (!animEvents[i].eventData[AED_FOOTSTEP_PROBABILITY]) // 100%
+ // Com_Printf( "Footstep event on frame %d, even should be on frame %d, off by %d\n", frame, animEvents[i].keyFrame,
+ // frame-animEvents[i].keyFrame );
+ if (!animEvents[i].eventData[AED_FOOTSTEP_PROBABILITY]) // 100%
{
doEvent = qtrue;
- }
- else if (animEvents[i].eventData[AED_FOOTSTEP_PROBABILITY] > Q_irand(0, 99) )
- {
+ } else if (animEvents[i].eventData[AED_FOOTSTEP_PROBABILITY] > Q_irand(0, 99)) {
doEvent = qtrue;
}
break;
case AEV_EFFECT:
// Determine probability of playing sound
- if (!animEvents[i].eventData[AED_EFFECT_PROBABILITY]) // 100%
+ if (!animEvents[i].eventData[AED_EFFECT_PROBABILITY]) // 100%
{
doEvent = qtrue;
- }
- else if (animEvents[i].eventData[AED_EFFECT_PROBABILITY] > Q_irand(0, 99) )
- {
+ } else if (animEvents[i].eventData[AED_EFFECT_PROBABILITY] > Q_irand(0, 99)) {
doEvent = qtrue;
}
break;
case AEV_FIRE:
// Determine probability of playing sound
- if (!animEvents[i].eventData[AED_FIRE_PROBABILITY]) // 100%
+ if (!animEvents[i].eventData[AED_FIRE_PROBABILITY]) // 100%
{
doEvent = qtrue;
- }
- else if (animEvents[i].eventData[AED_FIRE_PROBABILITY] > Q_irand(0, 99) )
- {
+ } else if (animEvents[i].eventData[AED_FIRE_PROBABILITY] > Q_irand(0, 99)) {
doEvent = qtrue;
}
break;
@@ -1364,54 +1081,49 @@ static void CG_PlayerAnimEvents( int animFileIndex, qboolean torso, int oldFrame
doEvent = qtrue;
break;
default:
- //doEvent = qfalse;//implicit
+ // doEvent = qfalse;//implicit
break;
}
// do event
- if ( doEvent )
- {
- CG_PlayerAnimEventDo( &cg_entities[entNum], &animEvents[i] );
+ if (doEvent) {
+ CG_PlayerAnimEventDo(&cg_entities[entNum], &animEvents[i]);
}
- }// end if event matches
- }// end if model matches
- }// end for
+ } // end if event matches
+ } // end if model matches
+ } // end for
}
-static void CGG2_AnimEvents( centity_t *cent )
-{
- if ( !cent || !cent->gent || !cent->gent->client)
- {
+static void CGG2_AnimEvents(centity_t *cent) {
+ if (!cent || !cent->gent || !cent->gent->client) {
return;
}
- if ( !cent->gent->ghoul2.size() )
- {//sorry, ghoul2 models only
+ if (!cent->gent->ghoul2.size()) { // sorry, ghoul2 models only
return;
}
- assert(cent->gent->playerModel>=0&¢->gent->playerModelgent->ghoul2.size());
- if ( ValidAnimFileIndex( cent->gent->client->clientInfo.animFileIndex ) )
- {
- int junk, curFrame=0;
- float currentFrame=0, animSpeed;
+ assert(cent->gent->playerModel >= 0 && cent->gent->playerModel < cent->gent->ghoul2.size());
+ if (ValidAnimFileIndex(cent->gent->client->clientInfo.animFileIndex)) {
+ int junk, curFrame = 0;
+ float currentFrame = 0, animSpeed;
- if (cent->gent->rootBone>=0&&gi.G2API_GetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, cg.time, ¤tFrame, &junk, &junk, &junk, &animSpeed, cgs.model_draw ))
- {
+ if (cent->gent->rootBone >= 0 && gi.G2API_GetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, cg.time, ¤tFrame,
+ &junk, &junk, &junk, &animSpeed, cgs.model_draw)) {
// the above may have failed, not sure what to do about it, current frame will be zero in that case
- curFrame = floor( currentFrame );
+ curFrame = floor(currentFrame);
}
- if ( curFrame != cent->gent->client->renderInfo.legsFrame )
- {
- CG_PlayerAnimEvents( cent->gent->client->clientInfo.animFileIndex, qfalse, cent->gent->client->renderInfo.legsFrame, curFrame, cent->currentState.clientNum );
+ if (curFrame != cent->gent->client->renderInfo.legsFrame) {
+ CG_PlayerAnimEvents(cent->gent->client->clientInfo.animFileIndex, qfalse, cent->gent->client->renderInfo.legsFrame, curFrame,
+ cent->currentState.clientNum);
}
cent->gent->client->renderInfo.legsFrame = curFrame;
cent->pe.legs.frame = curFrame;
- if (cent->gent->lowerLumbarBone>=0&& gi.G2API_GetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->lowerLumbarBone, cg.time, ¤tFrame, &junk, &junk, &junk, &animSpeed, cgs.model_draw ) )
- {
- curFrame = floor( currentFrame );
+ if (cent->gent->lowerLumbarBone >= 0 && gi.G2API_GetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->lowerLumbarBone, cg.time,
+ ¤tFrame, &junk, &junk, &junk, &animSpeed, cgs.model_draw)) {
+ curFrame = floor(currentFrame);
}
- if ( curFrame != cent->gent->client->renderInfo.torsoFrame )
- {
- CG_PlayerAnimEvents( cent->gent->client->clientInfo.animFileIndex, qtrue, cent->gent->client->renderInfo.torsoFrame, curFrame, cent->currentState.clientNum );
+ if (curFrame != cent->gent->client->renderInfo.torsoFrame) {
+ CG_PlayerAnimEvents(cent->gent->client->clientInfo.animFileIndex, qtrue, cent->gent->client->renderInfo.torsoFrame, curFrame,
+ cent->currentState.clientNum);
}
cent->gent->client->renderInfo.torsoFrame = curFrame;
cent->pe.torso.frame = curFrame;
@@ -1431,91 +1143,65 @@ CG_UpdateAngleClamp
Turn curAngle toward destAngle at angleSpeed, but stay within clampMin and Max
==================
*/
-static void CG_UpdateAngleClamp( float destAngle, float clampMin, float clampMax, float angleSpeed, float *curAngle, float normalAngle)
-{
- float swing;
- float move;
- float scale;
- float actualSpeed;
+static void CG_UpdateAngleClamp(float destAngle, float clampMin, float clampMax, float angleSpeed, float *curAngle, float normalAngle) {
+ float swing;
+ float move;
+ float scale;
+ float actualSpeed;
- swing = AngleSubtract( destAngle, *curAngle );
+ swing = AngleSubtract(destAngle, *curAngle);
- if(swing == 0)
- {//Don't have to turn
+ if (swing == 0) { // Don't have to turn
return;
}
// modify the angleSpeed depending on the delta
// so it doesn't seem so linear
- scale = fabs( swing );
- if (swing > 0)
- {
- if ( swing < clampMax * 0.25 )
- {//Pretty small way to go
+ scale = fabs(swing);
+ if (swing > 0) {
+ if (swing < clampMax * 0.25) { // Pretty small way to go
scale = 0.25;
- }
- else if ( swing > clampMax * 2.0 )
- {//Way out of our range
+ } else if (swing > clampMax * 2.0) { // Way out of our range
scale = 2.0;
+ } else { // Scale it smoothly
+ scale = swing / clampMax;
}
- else
- {//Scale it smoothly
- scale = swing/clampMax;
- }
- }
- else// if (swing < 0)
+ } else // if (swing < 0)
{
- if ( swing > clampMin * 0.25 )
- {//Pretty small way to go
+ if (swing > clampMin * 0.25) { // Pretty small way to go
scale = 0.5;
- }
- else if ( swing < clampMin * 2.0 )
- {//Way out of our range
+ } else if (swing < clampMin * 2.0) { // Way out of our range
scale = 2.0;
- }
- else
- {//Scale it smoothly
- scale = swing/clampMin;
+ } else { // Scale it smoothly
+ scale = swing / clampMin;
}
}
actualSpeed = scale * angleSpeed;
// swing towards the destination angle
- if ( swing >= 0 )
- {
+ if (swing >= 0) {
move = cg.frametime * actualSpeed;
- if ( move >= swing )
- {//our turnspeed is so fast, no need to swing, just match
+ if (move >= swing) { // our turnspeed is so fast, no need to swing, just match
*curAngle = destAngle;
+ } else {
+ *curAngle = AngleNormalize360(*curAngle + move);
}
- else
- {
- *curAngle = AngleNormalize360( *curAngle + move );
- }
- }
- else if ( swing < 0 )
- {
+ } else if (swing < 0) {
move = cg.frametime * -actualSpeed;
- if ( move <= swing )
- {//our turnspeed is so fast, no need to swing, just match
+ if (move <= swing) { // our turnspeed is so fast, no need to swing, just match
*curAngle = destAngle;
- }
- else
- {
- *curAngle = AngleNormalize180( *curAngle + move );
+ } else {
+ *curAngle = AngleNormalize180(*curAngle + move);
}
}
- swing = AngleSubtract( *curAngle, normalAngle );
+ swing = AngleSubtract(*curAngle, normalAngle);
// clamp to no more than normalAngle + tolerance
- if ( swing > clampMax )
- {
- *curAngle = AngleNormalize180( normalAngle + clampMax );
- }
- else if ( swing < clampMin )
- {
- *curAngle = AngleNormalize180( normalAngle + clampMin );
+ if (swing > clampMax) {
+ *curAngle = AngleNormalize180(normalAngle + clampMax);
+ } else if (swing < clampMin) {
+ *curAngle = AngleNormalize180(normalAngle + clampMin);
}
}
/*
@@ -1535,107 +1221,77 @@ CG_SwingAngles
locked mode (Don't turn unless you exceed the swing/clamp tolerance)
==================
*/
-static void CG_SwingAngles( float destAngle,
- float swingTolMin, float swingTolMax,
- float clampMin, float clampMax,
- float angleSpeed, float *curAngle,
- qboolean *turning )
-{
- float swing;
- float move;
- float scale;
+static void CG_SwingAngles(float destAngle, float swingTolMin, float swingTolMax, float clampMin, float clampMax, float angleSpeed, float *curAngle,
+ qboolean *turning) {
+ float swing;
+ float move;
+ float scale;
- swing = AngleSubtract( destAngle, *curAngle );
+ swing = AngleSubtract(destAngle, *curAngle);
- if(swing == 0)
- {//Don't have to turn
+ if (swing == 0) { // Don't have to turn
*turning = qfalse;
- }
- else
- {
+ } else {
*turning = qtrue;
}
- //If we're not turning, then we're done
- if ( *turning == qfalse)
+ // If we're not turning, then we're done
+ if (*turning == qfalse)
return;
// modify the angleSpeed depending on the delta
// so it doesn't seem so linear
- scale = fabs( swing );
+ scale = fabs(swing);
- if (swing > 0)
- {
- if ( clampMax <= 0 )
- {
+ if (swing > 0) {
+ if (clampMax <= 0) {
*curAngle = destAngle;
return;
}
- if ( swing < swingTolMax * 0.5 )
- {//Pretty small way to go
+ if (swing < swingTolMax * 0.5) { // Pretty small way to go
scale = 0.5;
- }
- else if ( scale < swingTolMax )
- {//More than halfway to go
+ } else if (scale < swingTolMax) { // More than halfway to go
scale = 1.0;
- }
- else
- {//Way out of our range
+ } else { // Way out of our range
scale = 2.0;
}
- }
- else// if (swing < 0)
+ } else // if (swing < 0)
{
- if ( clampMin >= 0 )
- {
+ if (clampMin >= 0) {
*curAngle = destAngle;
return;
}
- if ( swing > swingTolMin * 0.5 )
- {//Pretty small way to go
+ if (swing > swingTolMin * 0.5) { // Pretty small way to go
scale = 0.5;
- }
- else if ( scale > swingTolMin )
- {//More than halfway to go
+ } else if (scale > swingTolMin) { // More than halfway to go
scale = 1.0;
- }
- else
- {//Way out of our range
+ } else { // Way out of our range
scale = 2.0;
}
}
// swing towards the destination angle
- if ( swing >= 0 )
- {
+ if (swing >= 0) {
move = cg.frametime * scale * angleSpeed;
- if ( move >= swing )
- {//our turnspeed is so fast, no need to swing, just match
+ if (move >= swing) { // our turnspeed is so fast, no need to swing, just match
move = swing;
}
- *curAngle = AngleNormalize360( *curAngle + move );
- }
- else if ( swing < 0 )
- {
+ *curAngle = AngleNormalize360(*curAngle + move);
+ } else if (swing < 0) {
move = cg.frametime * scale * -angleSpeed;
- if ( move <= swing )
- {//our turnspeed is so fast, no need to swing, just match
+ if (move <= swing) { // our turnspeed is so fast, no need to swing, just match
move = swing;
}
- *curAngle = AngleNormalize360( *curAngle + move );
+ *curAngle = AngleNormalize360(*curAngle + move);
}
-
// clamp to no more than tolerance
- if ( swing > clampMax )
- {
- *curAngle = AngleNormalize360( destAngle - (clampMax - 1) );
- }
- else if ( swing < clampMin )
- {
- *curAngle = AngleNormalize360( destAngle + (-clampMin - 1) );
+ if (swing > clampMax) {
+ *curAngle = AngleNormalize360(destAngle - (clampMax - 1));
+ } else if (swing < clampMin) {
+ *curAngle = AngleNormalize360(destAngle + (-clampMin - 1));
}
}
@@ -1646,9 +1302,8 @@ CG_BreathPuffs
Description: Makes the player appear to have breath puffs (from the cold).
Added 11/06/02 by Aurelio Reis.
*/
-extern vmCvar_t cg_drawBreath;
-static void CG_BreathPuffs( centity_t *cent, vec3_t angles, vec3_t origin )
-{
+extern vmCvar_t cg_drawBreath;
+static void CG_BreathPuffs(centity_t *cent, vec3_t angles, vec3_t origin) {
gclient_t *client = cent->gent->client;
/* cg_drawBreath.integer == 0 - Don't draw at all.
@@ -1656,148 +1311,116 @@ static void CG_BreathPuffs( centity_t *cent, vec3_t angles, vec3_t origin )
== 2 - Draw only cold breath.
== 3 - Draw only under water bubbles (when under water) */
- if ( !client
- || cg_drawBreath.integer == 0
- || !cg.renderingThirdPerson
- || client->ps.pm_type == PM_DEAD
- || client->breathPuffTime > cg.time )
- {
+ if (!client || cg_drawBreath.integer == 0 || !cg.renderingThirdPerson || client->ps.pm_type == PM_DEAD || client->breathPuffTime > cg.time) {
return;
}
// Get the head-front bolt/tag.
- int bolt = gi.G2API_AddBolt( ¢->gent->ghoul2[cent->gent->playerModel], "*head_front" );
- if ( bolt == -1 )
- {
+ int bolt = gi.G2API_AddBolt(¢->gent->ghoul2[cent->gent->playerModel], "*head_front");
+ if (bolt == -1) {
return;
}
vec3_t vEffectOrigin;
- mdxaBone_t boltMatrix;
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, vEffectOrigin );
+ mdxaBone_t boltMatrix;
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, vEffectOrigin);
- int contents = cgi_CM_PointContents( vEffectOrigin, 0 );
- if ( contents & ( CONTENTS_SLIME | CONTENTS_LAVA ) ) // If they're submerged in something bad, leave.
+ int contents = cgi_CM_PointContents(vEffectOrigin, 0);
+ if (contents & (CONTENTS_SLIME | CONTENTS_LAVA)) // If they're submerged in something bad, leave.
{
return;
}
// Show bubbles effect if we're under water.
- if ( (contents & CONTENTS_WATER) && ( cg_drawBreath.integer == 1 || cg_drawBreath.integer == 3 ) )
- {
- CG_PlayEffectBolted( "misc/waterbreath", cent->gent->playerModel, bolt, cent->currentState.clientNum, vEffectOrigin );
+ if ((contents & CONTENTS_WATER) && (cg_drawBreath.integer == 1 || cg_drawBreath.integer == 3)) {
+ CG_PlayEffectBolted("misc/waterbreath", cent->gent->playerModel, bolt, cent->currentState.clientNum, vEffectOrigin);
}
// Draw cold breath effect.
- else if ( cg_drawBreath.integer == 1 || cg_drawBreath.integer == 2 )
- {
- CG_PlayEffectBolted( "misc/breath", cent->gent->playerModel, bolt, cent->currentState.clientNum, vEffectOrigin );
+ else if (cg_drawBreath.integer == 1 || cg_drawBreath.integer == 2) {
+ CG_PlayEffectBolted("misc/breath", cent->gent->playerModel, bolt, cent->currentState.clientNum, vEffectOrigin);
}
// TODO: It'd be nice if they breath faster when they're more damaged or when running...
- if ( gi.VoiceVolume[cent->currentState.number] > 0 )
- {//make breath when talking
- client->breathPuffTime = cg.time + 300; // every 200 ms
- }
- else
- {
+ if (gi.VoiceVolume[cent->currentState.number] > 0) { // make breath when talking
+ client->breathPuffTime = cg.time + 300; // every 200 ms
+ } else {
client->breathPuffTime = cg.time + 3000; // every 3 seconds.
}
}
-#define LOOK_DEFAULT_SPEED 0.15f
-#define LOOK_TALKING_SPEED 0.15f
+#define LOOK_DEFAULT_SPEED 0.15f
+#define LOOK_TALKING_SPEED 0.15f
-static qboolean CG_CheckLookTarget( centity_t *cent, vec3_t lookAngles, float *lookingSpeed )
-{
- if ( !cent->gent->ghoul2.size() )
- {
- if ( !cent->gent->client->clientInfo.torsoModel || !cent->gent->client->clientInfo.headModel )
- {
+static qboolean CG_CheckLookTarget(centity_t *cent, vec3_t lookAngles, float *lookingSpeed) {
+ if (!cent->gent->ghoul2.size()) {
+ if (!cent->gent->client->clientInfo.torsoModel || !cent->gent->client->clientInfo.headModel) {
return qfalse;
}
}
- //FIXME: also clamp the lookAngles based on the clamp + the existing difference between
+ // FIXME: also clamp the lookAngles based on the clamp + the existing difference between
// headAngles and torsoAngles? But often the tag_torso is straight but the torso itself
// is deformed to not face straight... sigh...
- //Now calc head angle to lookTarget, if any
- if ( cent->gent->client->renderInfo.lookTarget >= 0 && cent->gent->client->renderInfo.lookTarget < ENTITYNUM_WORLD )
- {
- vec3_t lookDir, lookOrg = { 0.0f }, eyeOrg;
- if ( cent->gent->client->renderInfo.lookMode == LM_ENT )
- {
- centity_t *lookCent = &cg_entities[cent->gent->client->renderInfo.lookTarget];
- if ( lookCent && lookCent->gent )
- {
- if ( lookCent->gent != cent->gent->enemy )
- {//We turn heads faster than headbob speed, but not as fast as if watching an enemy
- if ( cent->gent->client->NPC_class == CLASS_ROCKETTROOPER )
- {//they look around slowly and deliberately
- *lookingSpeed = LOOK_DEFAULT_SPEED*0.25f;
- }
- else
- {
+ // Now calc head angle to lookTarget, if any
+ if (cent->gent->client->renderInfo.lookTarget >= 0 && cent->gent->client->renderInfo.lookTarget < ENTITYNUM_WORLD) {
+ vec3_t lookDir, lookOrg = {0.0f}, eyeOrg;
+ if (cent->gent->client->renderInfo.lookMode == LM_ENT) {
+ centity_t *lookCent = &cg_entities[cent->gent->client->renderInfo.lookTarget];
+ if (lookCent && lookCent->gent) {
+ if (lookCent->gent != cent->gent->enemy) { // We turn heads faster than headbob speed, but not as fast as if watching an enemy
+ if (cent->gent->client->NPC_class == CLASS_ROCKETTROOPER) { // they look around slowly and deliberately
+ *lookingSpeed = LOOK_DEFAULT_SPEED * 0.25f;
+ } else {
*lookingSpeed = LOOK_DEFAULT_SPEED;
}
}
- //FIXME: Ignore small deltas from current angles so we don't bob our head in synch with theirs?
+ // FIXME: Ignore small deltas from current angles so we don't bob our head in synch with theirs?
- if ( cent->gent->client->renderInfo.lookTarget == 0 && !cg.renderingThirdPerson )//!cg_thirdPerson.integer )
- {//Special case- use cg.refdef.vieworg if looking at player and not in third person view
- VectorCopy( cg.refdef.vieworg, lookOrg );
- }
- else if ( lookCent->gent->client )
- {
- VectorCopy( lookCent->gent->client->renderInfo.eyePoint, lookOrg );
+ if (cent->gent->client->renderInfo.lookTarget == 0 && !cg.renderingThirdPerson) //! cg_thirdPerson.integer )
+ { // Special case- use cg.refdef.vieworg if looking at player and not in third person view
+ VectorCopy(cg.refdef.vieworg, lookOrg);
+ } else if (lookCent->gent->client) {
+ VectorCopy(lookCent->gent->client->renderInfo.eyePoint, lookOrg);
+ } else if (lookCent->gent->s.pos.trType == TR_INTERPOLATE) {
+ VectorCopy(lookCent->lerpOrigin, lookOrg);
+ } else if (lookCent->gent->inuse && !VectorCompare(lookCent->gent->currentOrigin, vec3_origin)) {
+ VectorCopy(lookCent->gent->currentOrigin, lookOrg);
+ } else { // at origin of world
+ return qfalse;
}
- else if ( lookCent->gent->s.pos.trType == TR_INTERPOLATE )
- {
- VectorCopy( lookCent->lerpOrigin, lookOrg );
- }
- else if ( lookCent->gent->inuse && !VectorCompare( lookCent->gent->currentOrigin, vec3_origin ) )
- {
- VectorCopy( lookCent->gent->currentOrigin, lookOrg );
- }
- else
- {//at origin of world
- return qfalse;
- }
- //Look in dir of lookTarget
+ // Look in dir of lookTarget
}
- }
- else if ( cent->gent->client->renderInfo.lookMode == LM_INTEREST && cent->gent->client->renderInfo.lookTarget > -1 && cent->gent->client->renderInfo.lookTarget < MAX_INTEREST_POINTS )
- {
- VectorCopy( level.interestPoints[cent->gent->client->renderInfo.lookTarget].origin, lookOrg );
- }
- else
- {
+ } else if (cent->gent->client->renderInfo.lookMode == LM_INTEREST && cent->gent->client->renderInfo.lookTarget > -1 &&
+ cent->gent->client->renderInfo.lookTarget < MAX_INTEREST_POINTS) {
+ VectorCopy(level.interestPoints[cent->gent->client->renderInfo.lookTarget].origin, lookOrg);
+ } else {
return qfalse;
}
- VectorCopy( cent->gent->client->renderInfo.eyePoint, eyeOrg );
+ VectorCopy(cent->gent->client->renderInfo.eyePoint, eyeOrg);
- VectorSubtract( lookOrg, eyeOrg, lookDir );
+ VectorSubtract(lookOrg, eyeOrg, lookDir);
#if 1
- vectoangles( lookDir, lookAngles );
+ vectoangles(lookDir, lookAngles);
#else
- //FIXME: get the angle of the head tag and account for that when finding the lookAngles-
+ // FIXME: get the angle of the head tag and account for that when finding the lookAngles-
// so if they're lying on their back we get an accurate lookAngle...
- vec3_t headDirs[3];
- vec3_t finalDir;
+ vec3_t headDirs[3];
+ vec3_t finalDir;
- AnglesToAxis( cent->gent->client->renderInfo.headAngles, headDirs );
- VectorRotate( lookDir, headDirs, finalDir );
- vectoangles( finalDir, lookAngles );
+ AnglesToAxis(cent->gent->client->renderInfo.headAngles, headDirs);
+ VectorRotate(lookDir, headDirs, finalDir);
+ vectoangles(finalDir, lookAngles);
#endif
- for ( int i = 0; i < 3; i++ )
- {
- lookAngles[i] = AngleNormalize180( lookAngles[i] );
- cent->gent->client->renderInfo.eyeAngles[i] = AngleNormalize180( cent->gent->client->renderInfo.eyeAngles[i] );
+ for (int i = 0; i < 3; i++) {
+ lookAngles[i] = AngleNormalize180(lookAngles[i]);
+ cent->gent->client->renderInfo.eyeAngles[i] = AngleNormalize180(cent->gent->client->renderInfo.eyeAngles[i]);
}
- AnglesSubtract( lookAngles, cent->gent->client->renderInfo.eyeAngles, lookAngles );
+ AnglesSubtract(lookAngles, cent->gent->client->renderInfo.eyeAngles, lookAngles);
return qtrue;
}
@@ -1809,50 +1432,42 @@ static qboolean CG_CheckLookTarget( centity_t *cent, vec3_t lookAngles, float *l
CG_AddHeadBob
=================
*/
-static qboolean CG_AddHeadBob( centity_t *cent, vec3_t addTo )
-{
- renderInfo_t *renderInfo = ¢->gent->client->renderInfo;
- const int volume = gi.VoiceVolume[cent->gent->s.clientNum];
- const int volChange = volume - renderInfo->lastVoiceVolume;//was *3 because voice fromLA was too low
- int i;
+static qboolean CG_AddHeadBob(centity_t *cent, vec3_t addTo) {
+ renderInfo_t *renderInfo = ¢->gent->client->renderInfo;
+ const int volume = gi.VoiceVolume[cent->gent->s.clientNum];
+ const int volChange = volume - renderInfo->lastVoiceVolume; // was *3 because voice fromLA was too low
+ int i;
renderInfo->lastVoiceVolume = volume;
- if ( !volume )
- {
+ if (!volume) {
// Not talking, set our target to be the normal head position
- VectorClear( renderInfo->targetHeadBobAngles );
+ VectorClear(renderInfo->targetHeadBobAngles);
- if ( VectorLengthSquared( renderInfo->headBobAngles ) < 1.0f )
- {
+ if (VectorLengthSquared(renderInfo->headBobAngles) < 1.0f) {
// We are close enough to being back to our normal head position, so we are done for now
return qfalse;
}
- }
- else if ( volChange > 2 )
- {
+ } else if (volChange > 2) {
// a big positive change in volume
- for ( i = 0; i < 3; i++ )
- {
+ for (i = 0; i < 3; i++) {
// Move our head angle target a bit
- renderInfo->targetHeadBobAngles[i] += Q_flrand( -1.0 * volChange, 1.0 * volChange );
+ renderInfo->targetHeadBobAngles[i] += Q_flrand(-1.0 * volChange, 1.0 * volChange);
// Clamp so we don't get too out of hand
- if ( renderInfo->targetHeadBobAngles[i] > 7.0f )
+ if (renderInfo->targetHeadBobAngles[i] > 7.0f)
renderInfo->targetHeadBobAngles[i] = 7.0f;
- if ( renderInfo->targetHeadBobAngles[i] < -7.0f )
+ if (renderInfo->targetHeadBobAngles[i] < -7.0f)
renderInfo->targetHeadBobAngles[i] = -7.0f;
}
}
- for ( i = 0; i < 3; i++ )
- {
+ for (i = 0; i < 3; i++) {
// Always try to move head angles towards our target
- renderInfo->headBobAngles[i] += ( renderInfo->targetHeadBobAngles[i] - renderInfo->headBobAngles[i] ) * ( cg.frametime / 150.0f );
- if ( addTo )
- {
- addTo[i] = AngleNormalize180( addTo[i] + AngleNormalize180( renderInfo->headBobAngles[i] ) );
+ renderInfo->headBobAngles[i] += (renderInfo->targetHeadBobAngles[i] - renderInfo->headBobAngles[i]) * (cg.frametime / 150.0f);
+ if (addTo) {
+ addTo[i] = AngleNormalize180(addTo[i] + AngleNormalize180(renderInfo->headBobAngles[i]));
}
}
@@ -1860,170 +1475,129 @@ static qboolean CG_AddHeadBob( centity_t *cent, vec3_t addTo )
return qtrue;
}
-extern float vectoyaw( const vec3_t vec );
-static qboolean CG_PlayerLegsYawFromMovement( centity_t *cent, const vec3_t velocity, float *yaw, float fwdAngle, float swingTolMin, float swingTolMax, qboolean alwaysFace )
-{
+extern float vectoyaw(const vec3_t vec);
+static qboolean CG_PlayerLegsYawFromMovement(centity_t *cent, const vec3_t velocity, float *yaw, float fwdAngle, float swingTolMin, float swingTolMax,
+ qboolean alwaysFace) {
float newAddAngle, angleDiff, turnRate = 10, addAngle = 0;
- //figure out what the offset, if any, should be
- if ( velocity[0] || velocity[1] )
- {
- float moveYaw;
- moveYaw = vectoyaw( velocity );
- addAngle = AngleDelta( cent->lerpAngles[YAW], moveYaw )*-1;
- if ( addAngle > 150 || addAngle < -150 )
- {
+ // figure out what the offset, if any, should be
+ if (velocity[0] || velocity[1]) {
+ float moveYaw;
+ moveYaw = vectoyaw(velocity);
+ addAngle = AngleDelta(cent->lerpAngles[YAW], moveYaw) * -1;
+ if (addAngle > 150 || addAngle < -150) {
addAngle = 0;
- }
- else
- {
- //FIXME: use actual swing/clamp tolerances
- if ( addAngle > swingTolMax )
- {
+ } else {
+ // FIXME: use actual swing/clamp tolerances
+ if (addAngle > swingTolMax) {
addAngle = swingTolMax;
- }
- else if ( addAngle < swingTolMin )
- {
+ } else if (addAngle < swingTolMin) {
addAngle = swingTolMin;
}
- if ( cent->gent->client->ps.pm_flags&PMF_BACKWARDS_RUN )
- {
+ if (cent->gent->client->ps.pm_flags & PMF_BACKWARDS_RUN) {
addAngle *= -1;
}
turnRate = 5;
}
- }
- else if ( !alwaysFace )
- {
+ } else if (!alwaysFace) {
return qfalse;
}
- if ( cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive & (1 << FP_SPEED) )
- {//using force speed
- //scale up the turning speed
+ if (cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive & (1 << FP_SPEED)) { // using force speed
+ // scale up the turning speed
turnRate /= cg_timescale.value;
}
- //lerp the legs angle to the new angle
- angleDiff = AngleDelta( cent->pe.legs.yawAngle, (*yaw+addAngle) );
- newAddAngle = angleDiff*cg.frameInterpolation*-1;
- if ( fabs(newAddAngle) > fabs(angleDiff) )
- {
- newAddAngle = angleDiff*-1;
+ // lerp the legs angle to the new angle
+ angleDiff = AngleDelta(cent->pe.legs.yawAngle, (*yaw + addAngle));
+ newAddAngle = angleDiff * cg.frameInterpolation * -1;
+ if (fabs(newAddAngle) > fabs(angleDiff)) {
+ newAddAngle = angleDiff * -1;
}
- if ( newAddAngle > turnRate )
- {
+ if (newAddAngle > turnRate) {
newAddAngle = turnRate;
- }
- else if ( newAddAngle < -turnRate )
- {
+ } else if (newAddAngle < -turnRate) {
newAddAngle = -turnRate;
}
*yaw = cent->pe.legs.yawAngle + newAddAngle;
- //Now clamp
- angleDiff = AngleDelta( fwdAngle, *yaw );
- if ( angleDiff > swingTolMax )
- {
+ // Now clamp
+ angleDiff = AngleDelta(fwdAngle, *yaw);
+ if (angleDiff > swingTolMax) {
*yaw = fwdAngle - swingTolMax;
- }
- else if ( angleDiff < swingTolMin )
- {
+ } else if (angleDiff < swingTolMin) {
*yaw = fwdAngle - swingTolMin;
}
return qtrue;
}
-static void CG_ATSTLegsYaw( centity_t *cent, vec3_t trailingLegsAngles )
-{
+static void CG_ATSTLegsYaw(centity_t *cent, vec3_t trailingLegsAngles) {
float ATSTLegsYaw = cent->lerpAngles[YAW];
- CG_PlayerLegsYawFromMovement( cent, cent->gent->client->ps.velocity, &ATSTLegsYaw, cent->lerpAngles[YAW], -60, 60, qtrue );
+ CG_PlayerLegsYawFromMovement(cent, cent->gent->client->ps.velocity, &ATSTLegsYaw, cent->lerpAngles[YAW], -60, 60, qtrue);
float legAngleDiff = AngleNormalize180(ATSTLegsYaw) - AngleNormalize180(cent->pe.legs.yawAngle);
int legsAnim = cent->currentState.legsAnim;
qboolean moving = (qboolean)!VectorCompare(cent->gent->client->ps.velocity, vec3_origin);
- if ( moving || legsAnim == BOTH_TURN_LEFT1 || legsAnim == BOTH_TURN_RIGHT1 || fabs(legAngleDiff) > 45 )
- {//moving or turning or beyond the turn allowance
- if ( legsAnim == BOTH_STAND1 && !moving )
- {//standing
- if ( legAngleDiff > 0 )
- {
- NPC_SetAnim( cent->gent, SETANIM_LEGS, BOTH_TURN_LEFT1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
- }
- else
- {
- NPC_SetAnim( cent->gent, SETANIM_LEGS, BOTH_TURN_RIGHT1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
+ if (moving || legsAnim == BOTH_TURN_LEFT1 || legsAnim == BOTH_TURN_RIGHT1 || fabs(legAngleDiff) > 45) { // moving or turning or beyond the turn allowance
+ if (legsAnim == BOTH_STAND1 && !moving) { // standing
+ if (legAngleDiff > 0) {
+ NPC_SetAnim(cent->gent, SETANIM_LEGS, BOTH_TURN_LEFT1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD);
+ } else {
+ NPC_SetAnim(cent->gent, SETANIM_LEGS, BOTH_TURN_RIGHT1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD);
}
- VectorSet( trailingLegsAngles, 0, cent->pe.legs.yawAngle, 0 );
+ VectorSet(trailingLegsAngles, 0, cent->pe.legs.yawAngle, 0);
cent->gent->client->renderInfo.legsYaw = trailingLegsAngles[YAW];
- }
- else if ( legsAnim == BOTH_TURN_LEFT1 || legsAnim == BOTH_TURN_RIGHT1 )
- {//turning
- legAngleDiff = AngleSubtract( ATSTLegsYaw, cent->gent->client->renderInfo.legsYaw );
+ } else if (legsAnim == BOTH_TURN_LEFT1 || legsAnim == BOTH_TURN_RIGHT1) { // turning
+ legAngleDiff = AngleSubtract(ATSTLegsYaw, cent->gent->client->renderInfo.legsYaw);
float add = 0;
- if ( legAngleDiff > 50 )
- {
+ if (legAngleDiff > 50) {
cent->pe.legs.yawAngle += legAngleDiff - 50;
- }
- else if ( legAngleDiff < -50 )
- {
+ } else if (legAngleDiff < -50) {
cent->pe.legs.yawAngle += legAngleDiff + 50;
}
- float animLength = PM_AnimLength( cent->gent->client->clientInfo.animFileIndex, (animNumber_t)legsAnim );
- legAngleDiff *= ( animLength - cent->gent->client->ps.legsAnimTimer)/animLength;
- VectorSet( trailingLegsAngles, 0, cent->pe.legs.yawAngle+legAngleDiff+add, 0 );
- if ( !cent->gent->client->ps.legsAnimTimer )
- {//FIXME: if start turning in the middle of this, our legs pop back to the old cent->pe.legs.yawAngle...
+ float animLength = PM_AnimLength(cent->gent->client->clientInfo.animFileIndex, (animNumber_t)legsAnim);
+ legAngleDiff *= (animLength - cent->gent->client->ps.legsAnimTimer) / animLength;
+ VectorSet(trailingLegsAngles, 0, cent->pe.legs.yawAngle + legAngleDiff + add, 0);
+ if (!cent->gent->client->ps.legsAnimTimer) { // FIXME: if start turning in the middle of this, our legs pop back to the old
+ // cent->pe.legs.yawAngle...
cent->gent->client->renderInfo.legsYaw = trailingLegsAngles[YAW];
}
- }
- else
- {//moving
- legAngleDiff = AngleSubtract( ATSTLegsYaw, cent->pe.legs.yawAngle );
- //FIXME: framerate dependant!!!
- if ( legAngleDiff > 50 )
- {
+ } else { // moving
+ legAngleDiff = AngleSubtract(ATSTLegsYaw, cent->pe.legs.yawAngle);
+ // FIXME: framerate dependant!!!
+ if (legAngleDiff > 50) {
legAngleDiff -= 50;
- }
- else if ( legAngleDiff > 5 )
- {
+ } else if (legAngleDiff > 5) {
legAngleDiff = 5;
- }
- else if ( legAngleDiff < -50 )
- {
+ } else if (legAngleDiff < -50) {
legAngleDiff += 50;
- }
- else if ( legAngleDiff < -5 )
- {
+ } else if (legAngleDiff < -5) {
legAngleDiff = -5;
}
legAngleDiff *= cg.frameInterpolation;
- VectorSet( trailingLegsAngles, 0, AngleNormalize180(cent->pe.legs.yawAngle + legAngleDiff), 0 );
+ VectorSet(trailingLegsAngles, 0, AngleNormalize180(cent->pe.legs.yawAngle + legAngleDiff), 0);
cent->gent->client->renderInfo.legsYaw = trailingLegsAngles[YAW];
}
cent->gent->client->renderInfo.legsYaw = cent->pe.legs.yawAngle = trailingLegsAngles[YAW];
cent->pe.legs.yawing = qtrue;
- }
- else
- {
- VectorSet( trailingLegsAngles, 0, cent->pe.legs.yawAngle, 0 );
+ } else {
+ VectorSet(trailingLegsAngles, 0, cent->pe.legs.yawAngle, 0);
cent->gent->client->renderInfo.legsYaw = cent->pe.legs.yawAngle = trailingLegsAngles[YAW];
cent->pe.legs.yawing = qfalse;
}
return;
}
-extern qboolean G_ClassHasBadBones( int NPC_class );
-extern void G_BoneOrientationsForClass( int NPC_class, const char *boneName, Eorientations *oUp, Eorientations *oRt, Eorientations *oFwd );
-extern qboolean PM_FlippingAnim( int anim );
-extern qboolean PM_SpinningSaberAnim( int anim );
-static CGhoul2Info_v dummyGhoul2;
-static int dummyRootBone;
-static int dummyHipsBolt;
-static void CG_G2ClientSpineAngles( centity_t *cent, vec3_t viewAngles, const vec3_t angles, vec3_t thoracicAngles, vec3_t ulAngles, vec3_t llAngles )
-{
- vec3_t motionBoneCorrectAngles = {0};
+extern qboolean G_ClassHasBadBones(int NPC_class);
+extern void G_BoneOrientationsForClass(int NPC_class, const char *boneName, Eorientations *oUp, Eorientations *oRt, Eorientations *oFwd);
+extern qboolean PM_FlippingAnim(int anim);
+extern qboolean PM_SpinningSaberAnim(int anim);
+static CGhoul2Info_v dummyGhoul2;
+static int dummyRootBone;
+static int dummyHipsBolt;
+static void CG_G2ClientSpineAngles(centity_t *cent, vec3_t viewAngles, const vec3_t angles, vec3_t thoracicAngles, vec3_t ulAngles, vec3_t llAngles) {
+ vec3_t motionBoneCorrectAngles = {0};
cent->pe.torso.pitchAngle = viewAngles[PITCH];
- viewAngles[YAW] = AngleDelta( cent->lerpAngles[YAW], angles[YAW] );
+ viewAngles[YAW] = AngleDelta(cent->lerpAngles[YAW], angles[YAW]);
cent->pe.torso.yawAngle = viewAngles[YAW];
/*
@@ -2032,177 +1606,163 @@ static void CG_G2ClientSpineAngles( centity_t *cent, vec3_t viewAngles, const ve
VectorClear( thoracicAngles );
VectorClear( ulAngles );
VectorClear( llAngles );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->upperLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Y, POSITIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->lowerLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Y, POSITIVE_Z, cgs.model_draw );
- return;
+ BG_G2SetBoneAngles( cent, cent->gent, cent->gent->upperLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Y, POSITIVE_Z, cgs.model_draw
+ ); BG_G2SetBoneAngles( cent, cent->gent, cent->gent->lowerLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Y, POSITIVE_Z, cgs.model_draw
+ ); return;
}
*/
- if ( cent->gent->client->NPC_class == CLASS_SABER_DROID )
- {//don't use lower bones
- VectorClear( thoracicAngles );
- VectorClear( ulAngles );
- VectorClear( llAngles );
+ if (cent->gent->client->NPC_class == CLASS_SABER_DROID) { // don't use lower bones
+ VectorClear(thoracicAngles);
+ VectorClear(ulAngles);
+ VectorClear(llAngles);
return;
}
- if ( cg_motionBoneComp.integer
- && !PM_FlippingAnim( cent->currentState.legsAnim )
- && !PM_SpinningSaberAnim( cent->currentState.legsAnim )
- && !PM_SpinningSaberAnim( cent->currentState.torsoAnim )
- && cent->currentState.legsAnim != cent->currentState.torsoAnim //NOTE: presumes your legs & torso are on the same frame, though they *should* be because PM_SetAnimFinal tries to keep them in synch
- && !G_ClassHasBadBones( cent->gent->client->NPC_class ) )//these guys' bones are so fucked up we shouldn't even bother with this motion bone comp...
- {//FIXME: no need to do this if legs and torso on are same frame
- mdxaBone_t boltMatrix;
-
- if ( cg_motionBoneComp.integer > 2 && cent->gent->rootBone >= 0 && cent->gent->lowerLumbarBone >= 0 )
- {//expensive version
- //have a local ghoul2 instance to mess with for this stuff... :/
- //remember the frame the lower is on
- float upperFrame, animSpeed;
- int junk;
- vec3_t llFwd, llRt, destPAngles, curPAngles, tempAng;
-
- if ( !dummyGhoul2.size() )
- {//set it up
- int dummyHModel = cgi_R_RegisterModel( "models/players/_humanoid/_humanoid.glm" );
- gi.G2API_InitGhoul2Model( dummyGhoul2, "models/players/_humanoid/_humanoid.glm", dummyHModel, NULL_HANDLE, NULL_HANDLE, 0, 0 );
- dummyRootBone = gi.G2API_GetBoneIndex( &dummyGhoul2[0], "model_root", qtrue );
- dummyHipsBolt = gi.G2API_AddBolt( &dummyGhoul2[0], "pelvis" );
- }
-
- gi.G2API_GetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->lowerLumbarBone, cg.time, &upperFrame, &junk, &junk, &junk, &animSpeed, cgs.model_draw );
- //set the dummyGhoul2 lower body to same frame as upper
- gi.G2API_SetBoneAnimIndex(&dummyGhoul2[0], dummyRootBone, upperFrame, upperFrame, BONE_ANIM_OVERRIDE_FREEZE, 1, cg.time, upperFrame, 0 );
- //get the dummyGhoul2 lower_lumbar orientation
- gi.G2API_GetBoltMatrix( dummyGhoul2, 0, dummyHipsBolt, &boltMatrix, vec3_origin, vec3_origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Z, llFwd );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, llRt );
- vectoangles( llFwd, destPAngles );
- vectoangles( llRt, tempAng );
+ if (cg_motionBoneComp.integer && !PM_FlippingAnim(cent->currentState.legsAnim) && !PM_SpinningSaberAnim(cent->currentState.legsAnim) &&
+ !PM_SpinningSaberAnim(cent->currentState.torsoAnim) &&
+ cent->currentState.legsAnim != cent->currentState.torsoAnim // NOTE: presumes your legs & torso are on the same frame, though they *should* be because
+ // PM_SetAnimFinal tries to keep them in synch
+ && !G_ClassHasBadBones(cent->gent->client->NPC_class)) // these guys' bones are so fucked up we shouldn't even bother with this motion bone comp...
+ { // FIXME: no need to do this if legs and torso on are same frame
+ mdxaBone_t boltMatrix;
+
+ if (cg_motionBoneComp.integer > 2 && cent->gent->rootBone >= 0 && cent->gent->lowerLumbarBone >= 0) { // expensive version
+ // have a local ghoul2 instance to mess with for this stuff... :/
+ // remember the frame the lower is on
+ float upperFrame, animSpeed;
+ int junk;
+ vec3_t llFwd, llRt, destPAngles, curPAngles, tempAng;
+
+ if (!dummyGhoul2.size()) { // set it up
+ int dummyHModel = cgi_R_RegisterModel("models/players/_humanoid/_humanoid.glm");
+ gi.G2API_InitGhoul2Model(dummyGhoul2, "models/players/_humanoid/_humanoid.glm", dummyHModel, NULL_HANDLE, NULL_HANDLE, 0, 0);
+ dummyRootBone = gi.G2API_GetBoneIndex(&dummyGhoul2[0], "model_root", qtrue);
+ dummyHipsBolt = gi.G2API_AddBolt(&dummyGhoul2[0], "pelvis");
+ }
+
+ gi.G2API_GetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->lowerLumbarBone, cg.time, &upperFrame, &junk, &junk, &junk,
+ &animSpeed, cgs.model_draw);
+ // set the dummyGhoul2 lower body to same frame as upper
+ gi.G2API_SetBoneAnimIndex(&dummyGhoul2[0], dummyRootBone, upperFrame, upperFrame, BONE_ANIM_OVERRIDE_FREEZE, 1, cg.time, upperFrame, 0);
+ // get the dummyGhoul2 lower_lumbar orientation
+ gi.G2API_GetBoltMatrix(dummyGhoul2, 0, dummyHipsBolt, &boltMatrix, vec3_origin, vec3_origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Z, llFwd);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, llRt);
+ vectoangles(llFwd, destPAngles);
+ vectoangles(llRt, tempAng);
destPAngles[ROLL] = -tempAng[PITCH];
- //get my lower_lumbar
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->crotchBolt, &boltMatrix, vec3_origin, vec3_origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Z, llFwd );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, llRt );
- vectoangles( llFwd, curPAngles );
- vectoangles( llRt, tempAng );
+ // get my lower_lumbar
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->crotchBolt, &boltMatrix, vec3_origin, vec3_origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Z, llFwd);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, llRt);
+ vectoangles(llFwd, curPAngles);
+ vectoangles(llRt, tempAng);
curPAngles[ROLL] = -tempAng[PITCH];
- //get the difference
- for ( int ang = 0; ang < 3; ang++ )
- {
- motionBoneCorrectAngles[ang] = AngleNormalize180( AngleDelta( AngleNormalize180( destPAngles[ang] ), AngleNormalize180( curPAngles[ang]) ) );
+ // get the difference
+ for (int ang = 0; ang < 3; ang++) {
+ motionBoneCorrectAngles[ang] = AngleNormalize180(AngleDelta(AngleNormalize180(destPAngles[ang]), AngleNormalize180(curPAngles[ang])));
}
#ifdef _DEBUG
- Com_Printf( "motion bone correction: %4.2f %4.2f %4.2f\n", motionBoneCorrectAngles[PITCH], motionBoneCorrectAngles[YAW], motionBoneCorrectAngles[ROLL] );
-#endif// _DEBUG
+ Com_Printf("motion bone correction: %4.2f %4.2f %4.2f\n", motionBoneCorrectAngles[PITCH], motionBoneCorrectAngles[YAW],
+ motionBoneCorrectAngles[ROLL]);
+#endif // _DEBUG
/*
for ( int ang = 0; ang < 3; ang++ )
{
viewAngles[ang] = AngleNormalize180( viewAngles[ang] - AngleNormalize180( destLLAngles[ang] ) );
}
*/
- }
- else
- {
- //adjust for motion offset
- vec3_t motionFwd, motionAngles;
-
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->motionBolt, &boltMatrix, vec3_origin, cent->lerpOrigin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, motionFwd );
- vectoangles( motionFwd, motionAngles );
- if ( cg_motionBoneComp.integer > 1 )
- {//do roll, too
+ } else {
+ // adjust for motion offset
+ vec3_t motionFwd, motionAngles;
+
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->motionBolt, &boltMatrix, vec3_origin, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, motionFwd);
+ vectoangles(motionFwd, motionAngles);
+ if (cg_motionBoneComp.integer > 1) { // do roll, too
vec3_t motionRt, tempAng;
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_X, motionRt );
- vectoangles( motionRt, tempAng );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, motionRt);
+ vectoangles(motionRt, tempAng);
motionAngles[ROLL] = -tempAng[PITCH];
}
- for ( int ang = 0; ang < 3; ang++ )
- {
- viewAngles[ang] = AngleNormalize180( viewAngles[ang] - AngleNormalize180( motionAngles[ang] ) );
+ for (int ang = 0; ang < 3; ang++) {
+ viewAngles[ang] = AngleNormalize180(viewAngles[ang] - AngleNormalize180(motionAngles[ang]));
}
}
}
- //distribute the angles differently up the spine
- //NOTE: each of these distributions must add up to 1.0f
- if ( cent->gent->client->NPC_class == CLASS_HAZARD_TROOPER )
- {//only uses lower_lumbar and upper_lumbar to look around
- VectorClear( thoracicAngles );
- ulAngles[PITCH] = viewAngles[PITCH]*0.50f;
- llAngles[PITCH] = viewAngles[PITCH]*0.50f+motionBoneCorrectAngles[PITCH];
+ // distribute the angles differently up the spine
+ // NOTE: each of these distributions must add up to 1.0f
+ if (cent->gent->client->NPC_class == CLASS_HAZARD_TROOPER) { // only uses lower_lumbar and upper_lumbar to look around
+ VectorClear(thoracicAngles);
+ ulAngles[PITCH] = viewAngles[PITCH] * 0.50f;
+ llAngles[PITCH] = viewAngles[PITCH] * 0.50f + motionBoneCorrectAngles[PITCH];
- ulAngles[YAW] = viewAngles[YAW]*0.45f;
- llAngles[YAW] = viewAngles[YAW]*0.55f+motionBoneCorrectAngles[YAW];
+ ulAngles[YAW] = viewAngles[YAW] * 0.45f;
+ llAngles[YAW] = viewAngles[YAW] * 0.55f + motionBoneCorrectAngles[YAW];
- ulAngles[ROLL] = viewAngles[ROLL]*0.45f;
- llAngles[ROLL] = viewAngles[ROLL]*0.55f+motionBoneCorrectAngles[ROLL];
- }
- else if ( cent->gent->client->NPC_class == CLASS_ASSASSIN_DROID )
- {//each bone has only 1 axis of rotation!
- //upper lumbar does not pitch
- thoracicAngles[PITCH] = viewAngles[PITCH]*0.40f;
+ ulAngles[ROLL] = viewAngles[ROLL] * 0.45f;
+ llAngles[ROLL] = viewAngles[ROLL] * 0.55f + motionBoneCorrectAngles[ROLL];
+ } else if (cent->gent->client->NPC_class == CLASS_ASSASSIN_DROID) { // each bone has only 1 axis of rotation!
+ // upper lumbar does not pitch
+ thoracicAngles[PITCH] = viewAngles[PITCH] * 0.40f;
ulAngles[PITCH] = 0.0f;
- llAngles[PITCH] = viewAngles[PITCH]*0.60f+motionBoneCorrectAngles[PITCH];
- //only upper lumbar yaws
+ llAngles[PITCH] = viewAngles[PITCH] * 0.60f + motionBoneCorrectAngles[PITCH];
+ // only upper lumbar yaws
thoracicAngles[YAW] = 0.0f;
ulAngles[YAW] = viewAngles[YAW];
llAngles[YAW] = motionBoneCorrectAngles[YAW];
- //no bone is capable of rolling
+ // no bone is capable of rolling
thoracicAngles[ROLL] = 0.0f;
ulAngles[ROLL] = 0.0f;
llAngles[ROLL] = motionBoneCorrectAngles[ROLL];
- }
- else
- {//use all 3 bones
- thoracicAngles[PITCH] = viewAngles[PITCH]*0.20f;
- ulAngles[PITCH] = viewAngles[PITCH]*0.40f;
- llAngles[PITCH] = viewAngles[PITCH]*0.40f+motionBoneCorrectAngles[PITCH];
+ } else { // use all 3 bones
+ thoracicAngles[PITCH] = viewAngles[PITCH] * 0.20f;
+ ulAngles[PITCH] = viewAngles[PITCH] * 0.40f;
+ llAngles[PITCH] = viewAngles[PITCH] * 0.40f + motionBoneCorrectAngles[PITCH];
- thoracicAngles[YAW] = viewAngles[YAW]*0.20f;
- ulAngles[YAW] = viewAngles[YAW]*0.35f;
- llAngles[YAW] = viewAngles[YAW]*0.45f+motionBoneCorrectAngles[YAW];
+ thoracicAngles[YAW] = viewAngles[YAW] * 0.20f;
+ ulAngles[YAW] = viewAngles[YAW] * 0.35f;
+ llAngles[YAW] = viewAngles[YAW] * 0.45f + motionBoneCorrectAngles[YAW];
- thoracicAngles[ROLL] = viewAngles[ROLL]*0.20f;
- ulAngles[ROLL] = viewAngles[ROLL]*0.35f;
- llAngles[ROLL] = viewAngles[ROLL]*0.45f+motionBoneCorrectAngles[ROLL];
+ thoracicAngles[ROLL] = viewAngles[ROLL] * 0.20f;
+ ulAngles[ROLL] = viewAngles[ROLL] * 0.35f;
+ llAngles[ROLL] = viewAngles[ROLL] * 0.45f + motionBoneCorrectAngles[ROLL];
}
- if ( G_IsRidingVehicle( cent->gent ) )// && type == VH_SPEEDER ?
- {//aim torso forward too
+ if (G_IsRidingVehicle(cent->gent)) // && type == VH_SPEEDER ?
+ { // aim torso forward too
ulAngles[YAW] = llAngles[YAW] = 0;
// Only if they have weapon can they pitch forward/back.
- if ( cent->gent->client->ps.weapon == WP_NONE || cent->gent->client->ps.weapon == WP_SABER )
- {
+ if (cent->gent->client->ps.weapon == WP_NONE || cent->gent->client->ps.weapon == WP_SABER) {
ulAngles[PITCH] = llAngles[PITCH] = 0;
}
}
- //thoracic is added modified again by neckAngle calculations, so don't set it until then
- if ( G_ClassHasBadBones( cent->gent->client->NPC_class ) )
- {
+ // thoracic is added modified again by neckAngle calculations, so don't set it until then
+ if (G_ClassHasBadBones(cent->gent->client->NPC_class)) {
Eorientations oUp, oRt, oFwd;
- if ( cent->gent->client->NPC_class == CLASS_RANCOR )
- {
+ if (cent->gent->client->NPC_class == CLASS_RANCOR) {
llAngles[YAW] = llAngles[ROLL] = 0.0f;
ulAngles[YAW] = ulAngles[ROLL] = 0.0f;
}
- G_BoneOrientationsForClass( cent->gent->client->NPC_class, "upper_lumbar", &oUp, &oRt, &oFwd );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->upperLumbarBone, ulAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
- G_BoneOrientationsForClass( cent->gent->client->NPC_class, "lower_lumbar", &oUp, &oRt, &oFwd );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->lowerLumbarBone, llAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
- }
- else
- {
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->upperLumbarBone, ulAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->lowerLumbarBone, llAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ G_BoneOrientationsForClass(cent->gent->client->NPC_class, "upper_lumbar", &oUp, &oRt, &oFwd);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->upperLumbarBone, ulAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
+ G_BoneOrientationsForClass(cent->gent->client->NPC_class, "lower_lumbar", &oUp, &oRt, &oFwd);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->lowerLumbarBone, llAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
+ } else {
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->upperLumbarBone, ulAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->lowerLumbarBone, llAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
}
}
-static void CG_G2ClientNeckAngles( centity_t *cent, const vec3_t lookAngles, vec3_t headAngles, vec3_t neckAngles, vec3_t thoracicAngles, vec3_t headClampMinAngles, vec3_t headClampMaxAngles )
-{
+static void CG_G2ClientNeckAngles(centity_t *cent, const vec3_t lookAngles, vec3_t headAngles, vec3_t neckAngles, vec3_t thoracicAngles,
+ vec3_t headClampMinAngles, vec3_t headClampMaxAngles) {
/*
if ( G_ClassHasBadBones( cent->gent->client->NPC_class ) )
{//don't use lower bones
@@ -2215,101 +1775,74 @@ static void CG_G2ClientNeckAngles( centity_t *cent, const vec3_t lookAngles, vec
return;
}
*/
- if ( cent->gent->client->NPC_class == CLASS_HAZARD_TROOPER )
- {//don't use upper bones
+ if (cent->gent->client->NPC_class == CLASS_HAZARD_TROOPER) { // don't use upper bones
return;
}
- vec3_t lA;
- VectorCopy( lookAngles, lA );
- //clamp the headangles (which should now be relative to the cervical (neck) angles
- if ( lA[PITCH] < headClampMinAngles[PITCH] )
- {
+ vec3_t lA;
+ VectorCopy(lookAngles, lA);
+ // clamp the headangles (which should now be relative to the cervical (neck) angles
+ if (lA[PITCH] < headClampMinAngles[PITCH]) {
lA[PITCH] = headClampMinAngles[PITCH];
- }
- else if ( lA[PITCH] > headClampMaxAngles[PITCH] )
- {
+ } else if (lA[PITCH] > headClampMaxAngles[PITCH]) {
lA[PITCH] = headClampMaxAngles[PITCH];
}
- if ( lA[YAW] < headClampMinAngles[YAW] )
- {
+ if (lA[YAW] < headClampMinAngles[YAW]) {
lA[YAW] = headClampMinAngles[YAW];
- }
- else if ( lA[YAW] > headClampMaxAngles[YAW] )
- {
+ } else if (lA[YAW] > headClampMaxAngles[YAW]) {
lA[YAW] = headClampMaxAngles[YAW];
}
- if ( lA[ROLL] < headClampMinAngles[ROLL] )
- {
+ if (lA[ROLL] < headClampMinAngles[ROLL]) {
lA[ROLL] = headClampMinAngles[ROLL];
- }
- else if ( lA[ROLL] > headClampMaxAngles[ROLL] )
- {
+ } else if (lA[ROLL] > headClampMaxAngles[ROLL]) {
lA[ROLL] = headClampMaxAngles[ROLL];
}
- //split it up between the neck and cranium
- if ( cent->gent->client->NPC_class == CLASS_ASSASSIN_DROID )
- {//each bone has only 1 axis of rotation!
- //thoracic only pitches, split with cervical
- if ( thoracicAngles[PITCH] )
- {//already been set above, blend them
+ // split it up between the neck and cranium
+ if (cent->gent->client->NPC_class == CLASS_ASSASSIN_DROID) { // each bone has only 1 axis of rotation!
+ // thoracic only pitches, split with cervical
+ if (thoracicAngles[PITCH]) { // already been set above, blend them
thoracicAngles[PITCH] = (thoracicAngles[PITCH] + (lA[PITCH] * 0.5f)) * 0.5f;
- }
- else
- {
+ } else {
thoracicAngles[PITCH] = lA[PITCH] * 0.5f;
}
thoracicAngles[YAW] = thoracicAngles[ROLL] = 0.0f;
- //cervical only pitches, split with thoracis
+ // cervical only pitches, split with thoracis
neckAngles[PITCH] = lA[PITCH] * 0.5f;
neckAngles[YAW] = 0.0f;
neckAngles[ROLL] = 0.0f;
- //cranium only yaws
+ // cranium only yaws
headAngles[PITCH] = 0.0f;
headAngles[YAW] = lA[YAW];
headAngles[ROLL] = 0.0f;
- //no bones roll
- }
- else if ( cent->gent->client->NPC_class == CLASS_SABER_DROID )
- {//each bone has only 1 axis of rotation!
- //no thoracic
- VectorClear( thoracicAngles );
- //cervical only yaws
+ // no bones roll
+ } else if (cent->gent->client->NPC_class == CLASS_SABER_DROID) { // each bone has only 1 axis of rotation!
+ // no thoracic
+ VectorClear(thoracicAngles);
+ // cervical only yaws
neckAngles[PITCH] = 0.0f;
neckAngles[YAW] = lA[YAW];
neckAngles[ROLL] = 0.0f;
- //cranium only pitches
+ // cranium only pitches
headAngles[PITCH] = lA[PITCH];
headAngles[YAW] = 0.0f;
headAngles[ROLL] = 0.0f;
- //none of the bones roll
- }
- else
- {
- if ( thoracicAngles[PITCH] )
- {//already been set above, blend them
+ // none of the bones roll
+ } else {
+ if (thoracicAngles[PITCH]) { // already been set above, blend them
thoracicAngles[PITCH] = (thoracicAngles[PITCH] + (lA[PITCH] * 0.4f)) * 0.5f;
- }
- else
- {
+ } else {
thoracicAngles[PITCH] = lA[PITCH] * 0.4f;
}
- if ( thoracicAngles[YAW] )
- {//already been set above, blend them
+ if (thoracicAngles[YAW]) { // already been set above, blend them
thoracicAngles[YAW] = (thoracicAngles[YAW] + (lA[YAW] * 0.1f)) * 0.5f;
- }
- else
- {
+ } else {
thoracicAngles[YAW] = lA[YAW] * 0.1f;
}
- if ( thoracicAngles[ROLL] )
- {//already been set above, blend them
+ if (thoracicAngles[ROLL]) { // already been set above, blend them
thoracicAngles[ROLL] = (thoracicAngles[ROLL] + (lA[ROLL] * 0.1f)) * 0.5f;
- }
- else
- {
+ } else {
thoracicAngles[ROLL] = lA[ROLL] * 0.1f;
}
@@ -2322,13 +1855,12 @@ static void CG_G2ClientNeckAngles( centity_t *cent, const vec3_t lookAngles, vec
headAngles[ROLL] = lA[ROLL] * 0.6f;
}
- if ( G_IsRidingVehicle( cent->gent ) )// && type == VH_SPEEDER ?
- {//aim torso forward too
+ if (G_IsRidingVehicle(cent->gent)) // && type == VH_SPEEDER ?
+ { // aim torso forward too
headAngles[YAW] = neckAngles[YAW] = thoracicAngles[YAW] = 0;
// Only if they have weapon can they pitch forward/back.
- if ( cent->gent->client->ps.weapon == WP_NONE || cent->gent->client->ps.weapon == WP_SABER )
- {
+ if (cent->gent->client->ps.weapon == WP_NONE || cent->gent->client->ps.weapon == WP_SABER) {
thoracicAngles[PITCH] = 0;
}
@@ -2351,8 +1883,8 @@ static void CG_G2ClientNeckAngles( centity_t *cent, const vec3_t lookAngles, vec
mdxaBone_t boltMatrix;
vec3_t boltAngles;
- gi.G2API_GetBoltMatrix( actor->ghoul2, actor->playerModel, actor->humerusRBone, &boltMatrix, vec3_origin, cent->lerpOrigin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, actorPos );
+ gi.G2API_GetBoltMatrix( actor->ghoul2, actor->playerModel, actor->humerusRBone, &boltMatrix, vec3_origin, cent->lerpOrigin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale ); gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, actorPos );
VectorSubtract(actorPos, actor->enemy->currentOrigin, toEnemy);
toEnemyDistance = VectorNormalize(toEnemy);
@@ -2374,89 +1906,71 @@ static void CG_G2ClientNeckAngles( centity_t *cent, const vec3_t lookAngles, vec
}
}*/
}
- if ( G_ClassHasBadBones( cent->gent->client->NPC_class ) )
- {
+ if (G_ClassHasBadBones(cent->gent->client->NPC_class)) {
Eorientations oUp, oRt, oFwd;
- if ( cent->gent->client->NPC_class != CLASS_RANCOR )
- {//Rancor doesn't use cranium and cervical
- G_BoneOrientationsForClass( cent->gent->client->NPC_class, "cranium", &oUp, &oRt, &oFwd );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, headAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw );
- G_BoneOrientationsForClass( cent->gent->client->NPC_class, "cervical", &oUp, &oRt, &oFwd );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->cervicalBone, neckAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
- }
- if ( cent->gent->client->NPC_class != CLASS_SABER_DROID )
- {//saber droid doesn't use thoracic
- if ( cent->gent->client->NPC_class == CLASS_RANCOR )
- {
+ if (cent->gent->client->NPC_class != CLASS_RANCOR) { // Rancor doesn't use cranium and cervical
+ G_BoneOrientationsForClass(cent->gent->client->NPC_class, "cranium", &oUp, &oRt, &oFwd);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, headAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
+ G_BoneOrientationsForClass(cent->gent->client->NPC_class, "cervical", &oUp, &oRt, &oFwd);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->cervicalBone, neckAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
+ }
+ if (cent->gent->client->NPC_class != CLASS_SABER_DROID) { // saber droid doesn't use thoracic
+ if (cent->gent->client->NPC_class == CLASS_RANCOR) {
thoracicAngles[YAW] = thoracicAngles[ROLL] = 0.0f;
}
- G_BoneOrientationsForClass( cent->gent->client->NPC_class, "thoracic", &oUp, &oRt, &oFwd );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->thoracicBone, thoracicAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
+ G_BoneOrientationsForClass(cent->gent->client->NPC_class, "thoracic", &oUp, &oRt, &oFwd);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->thoracicBone, thoracicAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
}
- }
- else
- {
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, headAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->cervicalBone, neckAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->thoracicBone, thoracicAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ } else {
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, headAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->cervicalBone, neckAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->thoracicBone, thoracicAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
}
}
-static void CG_UpdateLookAngles( centity_t *cent, vec3_t lookAngles, float lookSpeed, float minPitch, float maxPitch, float minYaw, float maxYaw, float minRoll, float maxRoll )
-{
- if ( !cent || !cent->gent || !cent->gent->client )
- {
+static void CG_UpdateLookAngles(centity_t *cent, vec3_t lookAngles, float lookSpeed, float minPitch, float maxPitch, float minYaw, float maxYaw, float minRoll,
+ float maxRoll) {
+ if (!cent || !cent->gent || !cent->gent->client) {
return;
}
- if ( cent->gent->client->renderInfo.lookingDebounceTime > cg.time )
- {
- //clamp so don't get "Exorcist" effect
- if ( lookAngles[PITCH] > maxPitch )
- {
+ if (cent->gent->client->renderInfo.lookingDebounceTime > cg.time) {
+ // clamp so don't get "Exorcist" effect
+ if (lookAngles[PITCH] > maxPitch) {
lookAngles[PITCH] = maxPitch;
- }
- else if ( lookAngles[PITCH] < minPitch )
- {
+ } else if (lookAngles[PITCH] < minPitch) {
lookAngles[PITCH] = minPitch;
}
- if ( lookAngles[YAW] > maxYaw )
- {
+ if (lookAngles[YAW] > maxYaw) {
lookAngles[YAW] = maxYaw;
- }
- else if ( lookAngles[YAW] < minYaw )
- {
+ } else if (lookAngles[YAW] < minYaw) {
lookAngles[YAW] = minYaw;
}
- if ( lookAngles[ROLL] > maxRoll )
- {
+ if (lookAngles[ROLL] > maxRoll) {
lookAngles[ROLL] = maxRoll;
- }
- else if ( lookAngles[ROLL] < minRoll )
- {
+ } else if (lookAngles[ROLL] < minRoll) {
lookAngles[ROLL] = minRoll;
}
- //slowly lerp to this new value
- //Remember last headAngles
- vec3_t oldLookAngles;
- VectorCopy( cent->gent->client->renderInfo.lastHeadAngles, oldLookAngles );
+ // slowly lerp to this new value
+ // Remember last headAngles
+ vec3_t oldLookAngles;
+ VectorCopy(cent->gent->client->renderInfo.lastHeadAngles, oldLookAngles);
vec3_t lookAnglesDiff;
- VectorSubtract( lookAngles, oldLookAngles, lookAnglesDiff );
+ VectorSubtract(lookAngles, oldLookAngles, lookAnglesDiff);
- for ( int ang = 0; ang < 3; ang++ )
- {
- lookAnglesDiff[ang] = AngleNormalize180( lookAnglesDiff[ang] );
+ for (int ang = 0; ang < 3; ang++) {
+ lookAnglesDiff[ang] = AngleNormalize180(lookAnglesDiff[ang]);
}
- if( VectorLengthSquared( lookAnglesDiff ) )
- {
- lookAngles[PITCH] = AngleNormalize180( oldLookAngles[PITCH]+(lookAnglesDiff[PITCH]*cg.frameInterpolation*lookSpeed) );
- lookAngles[YAW] = AngleNormalize180( oldLookAngles[YAW]+(lookAnglesDiff[YAW]*cg.frameInterpolation*lookSpeed) );
- lookAngles[ROLL] = AngleNormalize180( oldLookAngles[ROLL]+(lookAnglesDiff[ROLL]*cg.frameInterpolation*lookSpeed) );
+ if (VectorLengthSquared(lookAnglesDiff)) {
+ lookAngles[PITCH] = AngleNormalize180(oldLookAngles[PITCH] + (lookAnglesDiff[PITCH] * cg.frameInterpolation * lookSpeed));
+ lookAngles[YAW] = AngleNormalize180(oldLookAngles[YAW] + (lookAnglesDiff[YAW] * cg.frameInterpolation * lookSpeed));
+ lookAngles[ROLL] = AngleNormalize180(oldLookAngles[ROLL] + (lookAnglesDiff[ROLL] * cg.frameInterpolation * lookSpeed));
}
}
- //Remember current lookAngles next time
- VectorCopy( lookAngles, cent->gent->client->renderInfo.lastHeadAngles );
+ // Remember current lookAngles next time
+ VectorCopy(lookAngles, cent->gent->client->renderInfo.lastHeadAngles);
}
/*
@@ -2474,15 +1988,14 @@ Handles seperate torso motion
===============
*/
-extern int PM_TurnAnimForLegsAnim( gentity_t *gent, int anim );
-extern float PM_GetTimeScaleMod( gentity_t *gent );
-static void CG_G2PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t angles )
-{
- vec3_t headAngles, neckAngles, chestAngles, thoracicAngles = {0,0,0};//legsAngles, torsoAngles,
- vec3_t ulAngles, llAngles;
- //float speed;
- //vec3_t velocity;
- vec3_t lookAngles, viewAngles;
+extern int PM_TurnAnimForLegsAnim(gentity_t *gent, int anim);
+extern float PM_GetTimeScaleMod(gentity_t *gent);
+static void CG_G2PlayerAngles(centity_t *cent, vec3_t legs[3], vec3_t angles) {
+ vec3_t headAngles, neckAngles, chestAngles, thoracicAngles = {0, 0, 0}; // legsAngles, torsoAngles,
+ vec3_t ulAngles, llAngles;
+ // float speed;
+ // vec3_t velocity;
+ vec3_t lookAngles, viewAngles;
/*
float headYawClampMin, headYawClampMax;
float headPitchClampMin, headPitchClampMax;
@@ -2493,150 +2006,120 @@ static void CG_G2PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t angles )
float legsYawSwingTolMin, legsYawSwingTolMax;
float yawSpeed, maxYawSpeed, lookingSpeed;
*/
- float lookAngleSpeed = LOOK_TALKING_SPEED;//shut up the compiler
- //float swing, scale;
- //int i;
- qboolean looking = qfalse, talking = qfalse;
-
- if ( cent->gent
- && (cent->gent->flags&FL_NO_ANGLES) )
- {//flatten out all bone angles we might have been overriding
+ float lookAngleSpeed = LOOK_TALKING_SPEED; // shut up the compiler
+ // float swing, scale;
+ // int i;
+ qboolean looking = qfalse, talking = qfalse;
+
+ if (cent->gent && (cent->gent->flags & FL_NO_ANGLES)) { // flatten out all bone angles we might have been overriding
cent->lerpAngles[PITCH] = cent->lerpAngles[ROLL] = 0;
- VectorCopy( cent->lerpAngles, angles );
+ VectorCopy(cent->lerpAngles, angles);
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->cervicalBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->thoracicBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->cervicalBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->thoracicBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
cent->pe.torso.pitchAngle = 0;
cent->pe.torso.yawAngle = 0;
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->upperLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->lowerLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->upperLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->lowerLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
cent->pe.legs.pitchAngle = angles[0];
cent->pe.legs.yawAngle = angles[1];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = angles[1];
}
- AnglesToAxis( angles, legs );
+ AnglesToAxis(angles, legs);
return;
}
// Dead entity
- if ( cent->gent && cent->gent->health <= 0 )
- {
- if ( cent->gent->hipsBone != -1 )
- {
- gi.G2API_StopBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone );
+ if (cent->gent && cent->gent->health <= 0) {
+ if (cent->gent->hipsBone != -1) {
+ gi.G2API_StopBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone);
}
- VectorCopy( cent->lerpAngles, angles );
+ VectorCopy(cent->lerpAngles, angles);
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->cervicalBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->thoracicBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->cervicalBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->thoracicBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
cent->pe.torso.pitchAngle = 0;
cent->pe.torso.yawAngle = 0;
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->upperLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->lowerLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw );
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->upperLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->lowerLumbarBone, vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
cent->pe.legs.pitchAngle = angles[0];
cent->pe.legs.yawAngle = angles[1];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = angles[1];
}
- AnglesToAxis( angles, legs );
+ AnglesToAxis(angles, legs);
return;
}
- if ( cent->gent && cent->gent->client
- && (cent->gent->client->NPC_class != CLASS_GONK )
- && (cent->gent->client->NPC_class != CLASS_INTERROGATOR)
- && (cent->gent->client->NPC_class != CLASS_SENTRY)
- && (cent->gent->client->NPC_class != CLASS_PROBE )
- && (cent->gent->client->NPC_class != CLASS_R2D2 )
- && (cent->gent->client->NPC_class != CLASS_R5D2)
- && (cent->gent->client->NPC_class != CLASS_ATST||!cent->gent->s.number) )
- {// If we are rendering third person, we should just force the player body to always fully face
+ if (cent->gent && cent->gent->client && (cent->gent->client->NPC_class != CLASS_GONK) && (cent->gent->client->NPC_class != CLASS_INTERROGATOR) &&
+ (cent->gent->client->NPC_class != CLASS_SENTRY) && (cent->gent->client->NPC_class != CLASS_PROBE) && (cent->gent->client->NPC_class != CLASS_R2D2) &&
+ (cent->gent->client->NPC_class != CLASS_R5D2) &&
+ (cent->gent->client->NPC_class != CLASS_ATST ||
+ !cent->gent->s.number)) { // If we are rendering third person, we should just force the player body to always fully face
// whatever way they are looking, otherwise, you can end up with gun shots coming off of the
// gun at angles that just look really wrong.
- //NOTENOTE: shots are coming out of the gun at ridiculous angles. The head & torso
- //should pitch *some* when looking up and down...
- VectorCopy( cent->lerpAngles, angles );
+ // NOTENOTE: shots are coming out of the gun at ridiculous angles. The head & torso
+ // should pitch *some* when looking up and down...
+ VectorCopy(cent->lerpAngles, angles);
angles[PITCH] = 0;
- if ( cent->gent->client )
- {
- if ( cent->gent->client->NPC_class != CLASS_ATST )
- {
- if ( !PM_SpinningSaberAnim( cent->currentState.legsAnim ) )
- {//don't turn legs if in a spinning saber transition
- //FIXME: use actual swing/clamp tolerances?
- if ( cent->gent->client->ps.groundEntityNum != ENTITYNUM_NONE && !PM_InRoll( ¢->gent->client->ps ) )
- {//on the ground
- CG_PlayerLegsYawFromMovement( cent, cent->gent->client->ps.velocity, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue );
- }
- else
- {//face legs to front
- CG_PlayerLegsYawFromMovement( cent, vec3_origin, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue );
+ if (cent->gent->client) {
+ if (cent->gent->client->NPC_class != CLASS_ATST) {
+ if (!PM_SpinningSaberAnim(cent->currentState.legsAnim)) { // don't turn legs if in a spinning saber transition
+ // FIXME: use actual swing/clamp tolerances?
+ if (cent->gent->client->ps.groundEntityNum != ENTITYNUM_NONE && !PM_InRoll(¢->gent->client->ps)) { // on the ground
+ CG_PlayerLegsYawFromMovement(cent, cent->gent->client->ps.velocity, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue);
+ } else { // face legs to front
+ CG_PlayerLegsYawFromMovement(cent, vec3_origin, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue);
}
}
}
}
- //VectorClear( viewAngles );
- VectorCopy( cent->lerpAngles, viewAngles );
+ // VectorClear( viewAngles );
+ VectorCopy(cent->lerpAngles, viewAngles);
viewAngles[YAW] = viewAngles[ROLL] = 0;
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_RANCOR )
- {//rancor uses full pitch
- if ( cent->gent->count )
- {//don't look up or down at enemy when he's in your hand...
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_RANCOR) { // rancor uses full pitch
+ if (cent->gent->count) { // don't look up or down at enemy when he's in your hand...
viewAngles[PITCH] = 0.0f;
- }
- else if ( cent->gent->enemy )
- {
- if ( cent->gent->enemy->s.solid == SOLID_BMODEL )
- {//don't look up or down at architecture?
+ } else if (cent->gent->enemy) {
+ if (cent->gent->enemy->s.solid == SOLID_BMODEL) { // don't look up or down at architecture?
viewAngles[PITCH] = 0.0f;
- }
- else if ( cent->gent->client->ps.legsAnim == BOTH_MELEE1 )
- {//don't look up or down when smashing the ground
+ } else if (cent->gent->client->ps.legsAnim == BOTH_MELEE1) { // don't look up or down when smashing the ground
viewAngles[PITCH] = 0.0f;
- }
- else
- {
+ } else {
vec3_t eDir, eAngles, lookFrom;
- VectorCopy( cent->lerpOrigin, lookFrom );
- lookFrom[2] += cent->gent->maxs[2]*0.6f;
- VectorSubtract( cg_entities[cent->gent->enemy->s.number].lerpOrigin, lookFrom, eDir );
- vectoangles( eDir, eAngles );
+ VectorCopy(cent->lerpOrigin, lookFrom);
+ lookFrom[2] += cent->gent->maxs[2] * 0.6f;
+ VectorSubtract(cg_entities[cent->gent->enemy->s.number].lerpOrigin, lookFrom, eDir);
+ vectoangles(eDir, eAngles);
viewAngles[PITCH] = AngleNormalize180(eAngles[0]);
- if ( cent->gent->client->ps.legsAnim == BOTH_ATTACK2 )
- {//swinging at something on the ground
- if ( viewAngles[PITCH] > 0.0f )
- {//don't look down
+ if (cent->gent->client->ps.legsAnim == BOTH_ATTACK2) { // swinging at something on the ground
+ if (viewAngles[PITCH] > 0.0f) { // don't look down
viewAngles[PITCH] = 0.0f;
}
- }
- else if ( cent->gent->client->ps.legsAnim == BOTH_ATTACK4 )
- {//in breath attack anim
- if ( viewAngles[PITCH] > 0.0f )
- {//don't look down
+ } else if (cent->gent->client->ps.legsAnim == BOTH_ATTACK4) { // in breath attack anim
+ if (viewAngles[PITCH] > 0.0f) { // don't look down
viewAngles[PITCH] = 0.0f;
- }
- else
- {//exaggerate looking up
+ } else { // exaggerate looking up
viewAngles[PITCH] *= 2.0f;
}
- }
- else if ( viewAngles[PITCH] > 0.0f )
- {//reduce looking down
+ } else if (viewAngles[PITCH] > 0.0f) { // reduce looking down
viewAngles[PITCH] *= 0.5f;
}
- //clamp?
+ // clamp?
/*
if ( viewAngles[PITCH] > 30.0f )
{
@@ -2648,74 +2131,60 @@ static void CG_G2PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t angles )
}
*/
}
- }
- else
- {
+ } else {
viewAngles[PITCH] = 0.0f;
}
- }
- else
- {
+ } else {
viewAngles[PITCH] *= 0.5;
}
- VectorCopy( viewAngles, lookAngles );
+ VectorCopy(viewAngles, lookAngles);
- // if ( cent->gent && !Q_stricmp( "atst", cent->gent->NPC_type ) )
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
- {
+ // if ( cent->gent && !Q_stricmp( "atst", cent->gent->NPC_type ) )
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST) {
lookAngles[YAW] = 0;
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
- VectorCopy( viewAngles, lookAngles );
- }
- else
- {
- if ( cg_turnAnims.integer && !in_camera && cent->gent->hipsBone >= 0 )
- {
- //override the hips bone with a turn anim when turning
- //and clear it when we're not... does blend from and to parent actually work?
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ VectorCopy(viewAngles, lookAngles);
+ } else {
+ if (cg_turnAnims.integer && !in_camera && cent->gent->hipsBone >= 0) {
+ // override the hips bone with a turn anim when turning
+ // and clear it when we're not... does blend from and to parent actually work?
int startFrame, endFrame;
- const qboolean animatingHips = gi.G2API_GetAnimRangeIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone, &startFrame, &endFrame );
-
- //FIXME: make legs lag behind when turning in place, only play turn anim when legs have to catch up
- if ( angles[YAW] == cent->pe.legs.yawAngle )
- {
- gi.G2API_StopBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone );
- }
- else if ( VectorCompare( vec3_origin, cent->gent->client->ps.velocity ) )
- {//FIXME: because of LegsYawFromMovement, we play the turnAnims when we stop running, which looks really bad.
- int turnAnim = PM_TurnAnimForLegsAnim( cent->gent, cent->gent->client->ps.legsAnim );
- if ( turnAnim != -1 && cent->gent->health > 0 )
- {
+ const qboolean animatingHips =
+ gi.G2API_GetAnimRangeIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone, &startFrame, &endFrame);
+
+ // FIXME: make legs lag behind when turning in place, only play turn anim when legs have to catch up
+ if (angles[YAW] == cent->pe.legs.yawAngle) {
+ gi.G2API_StopBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone);
+ } else if (VectorCompare(vec3_origin, cent->gent->client->ps.velocity)) { // FIXME: because of LegsYawFromMovement, we play the turnAnims when
+ // we stop running, which looks really bad.
+ int turnAnim = PM_TurnAnimForLegsAnim(cent->gent, cent->gent->client->ps.legsAnim);
+ if (turnAnim != -1 && cent->gent->health > 0) {
animation_t *animations = level.knownAnimFileSets[cent->gent->client->clientInfo.animFileIndex].animations;
- if ( !animatingHips || ( animations[turnAnim].firstFrame != startFrame ) )// only set the anim if we aren't going to do the same animation again
+ if (!animatingHips ||
+ (animations[turnAnim].firstFrame != startFrame)) // only set the anim if we aren't going to do the same animation again
{
- float animSpeed = 50.0f / animations[turnAnim].frameLerp * PM_GetTimeScaleMod( cent->gent );
+ float animSpeed = 50.0f / animations[turnAnim].frameLerp * PM_GetTimeScaleMod(cent->gent);
- gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone,
- animations[turnAnim].firstFrame, animations[turnAnim].firstFrame+animations[turnAnim].numFrames,
- BONE_ANIM_OVERRIDE_LOOP/*|BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND*/, animSpeed, cg.time, -1, 100 );
+ gi.G2API_SetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone, animations[turnAnim].firstFrame,
+ animations[turnAnim].firstFrame + animations[turnAnim].numFrames,
+ BONE_ANIM_OVERRIDE_LOOP /*|BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND*/, animSpeed, cg.time, -1, 100);
}
+ } else {
+ gi.G2API_StopBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone);
}
- else
- {
- gi.G2API_StopBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone );
- }
- }
- else
- {
- gi.G2API_StopBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone );
+ } else {
+ gi.G2API_StopBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone);
}
}
- CG_G2ClientSpineAngles( cent, viewAngles, angles, thoracicAngles, ulAngles, llAngles );
+ CG_G2ClientSpineAngles(cent, viewAngles, angles, thoracicAngles, ulAngles, llAngles);
}
- vec3_t trailingLegsAngles;
- if ( cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
- {
- CG_ATSTLegsYaw( cent, trailingLegsAngles );
- AnglesToAxis( trailingLegsAngles, legs );
+ vec3_t trailingLegsAngles;
+ if (cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST) {
+ CG_ATSTLegsYaw(cent, trailingLegsAngles);
+ AnglesToAxis(trailingLegsAngles, legs);
angles[YAW] = trailingLegsAngles[YAW];
}
/*
@@ -2727,201 +2196,154 @@ static void CG_G2PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t angles )
}
*/
// either riding a vehicle or we are a vehicle
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE )
- {//you are a vehicle, just use your lerpAngles which comes from m_vOrientation
+ if (cent->gent && cent->gent->client &&
+ cent->gent->client->NPC_class == CLASS_VEHICLE) { // you are a vehicle, just use your lerpAngles which comes from m_vOrientation
cent->pe.legs.yawing = qfalse;
cent->pe.legs.yawAngle = cent->lerpAngles[YAW];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = cent->lerpAngles[YAW];
}
- AnglesToAxis( cent->lerpAngles, legs );
- if ( cent->gent->m_pVehicle )
- {
- if ( cent->gent->m_pVehicle->m_pVehicleInfo )
- {
- if ( cent->gent->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER
- || cent->gent->m_pVehicle->m_pVehicleInfo->type == VH_SPEEDER )
- {
- VectorCopy( cent->lerpAngles, angles );
+ AnglesToAxis(cent->lerpAngles, legs);
+ if (cent->gent->m_pVehicle) {
+ if (cent->gent->m_pVehicle->m_pVehicleInfo) {
+ if (cent->gent->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER || cent->gent->m_pVehicle->m_pVehicleInfo->type == VH_SPEEDER) {
+ VectorCopy(cent->lerpAngles, angles);
}
}
}
- }
- else if ( G_IsRidingVehicle( cent->gent ) )
- {//riding a vehicle, get the vehicle's lerpAngles (which comes from m_vOrientation)
+ } else if (G_IsRidingVehicle(cent->gent)) { // riding a vehicle, get the vehicle's lerpAngles (which comes from m_vOrientation)
cent->pe.legs.yawing = qfalse;
cent->pe.legs.yawAngle = cg_entities[cent->gent->owner->s.number].lerpAngles[YAW];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = cg_entities[cent->gent->owner->s.number].lerpAngles[YAW];
}
- AnglesToAxis( cg_entities[cent->gent->owner->s.number].lerpAngles, legs );
- }
- else
- {
+ AnglesToAxis(cg_entities[cent->gent->owner->s.number].lerpAngles, legs);
+ } else {
- //set the legs.yawing field so we play the turning anim when turning in place
- if ( angles[YAW] == cent->pe.legs.yawAngle )
- {
+ // set the legs.yawing field so we play the turning anim when turning in place
+ if (angles[YAW] == cent->pe.legs.yawAngle) {
cent->pe.legs.yawing = qfalse;
- }
- else
- {
+ } else {
cent->pe.legs.yawing = qtrue;
}
cent->pe.legs.yawAngle = angles[YAW];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = angles[YAW];
}
- if ( ((cent->gent->client->ps.eFlags&EF_FORCE_GRIPPED)||((cent->gent->client->NPC_class == CLASS_BOBAFETT||cent->gent->client->NPC_class == CLASS_ROCKETTROOPER)&¢->gent->client->moveType==MT_FLYSWIM))
- && cent->gent->client->ps.groundEntityNum == ENTITYNUM_NONE )
- {
- vec3_t centFwd, centRt;
- float divFactor = 1.0f;
- if ( (cent->gent->client->NPC_class == CLASS_BOBAFETT||cent->gent->client->NPC_class == CLASS_ROCKETTROOPER)
- && cent->gent->client->moveType == MT_FLYSWIM )
- {
+ if (((cent->gent->client->ps.eFlags & EF_FORCE_GRIPPED) ||
+ ((cent->gent->client->NPC_class == CLASS_BOBAFETT || cent->gent->client->NPC_class == CLASS_ROCKETTROOPER) &&
+ cent->gent->client->moveType == MT_FLYSWIM)) &&
+ cent->gent->client->ps.groundEntityNum == ENTITYNUM_NONE) {
+ vec3_t centFwd, centRt;
+ float divFactor = 1.0f;
+ if ((cent->gent->client->NPC_class == CLASS_BOBAFETT || cent->gent->client->NPC_class == CLASS_ROCKETTROOPER) &&
+ cent->gent->client->moveType == MT_FLYSWIM) {
divFactor = 3.0f;
}
- AngleVectors( cent->lerpAngles, centFwd, centRt, NULL );
- angles[PITCH] = AngleNormalize180( DotProduct( cent->gent->client->ps.velocity, centFwd )/(2*divFactor) );
- if ( angles[PITCH] > 90 )
- {
+ AngleVectors(cent->lerpAngles, centFwd, centRt, NULL);
+ angles[PITCH] = AngleNormalize180(DotProduct(cent->gent->client->ps.velocity, centFwd) / (2 * divFactor));
+ if (angles[PITCH] > 90) {
angles[PITCH] = 90;
- }
- else if ( angles[PITCH] < -90 )
- {
+ } else if (angles[PITCH] < -90) {
angles[PITCH] = -90;
}
- angles[ROLL] = AngleNormalize180( DotProduct( cent->gent->client->ps.velocity, centRt )/(10*divFactor) );
- if ( angles[ROLL] > 90 )
- {
+ angles[ROLL] = AngleNormalize180(DotProduct(cent->gent->client->ps.velocity, centRt) / (10 * divFactor));
+ if (angles[ROLL] > 90) {
angles[ROLL] = 90;
- }
- else if ( angles[ROLL] < -90 )
- {
+ } else if (angles[ROLL] < -90) {
angles[ROLL] = -90;
}
}
- AnglesToAxis( angles, legs );
+ AnglesToAxis(angles, legs);
}
- //clamp relative to forward of cervical bone!
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
- {
+ // clamp relative to forward of cervical bone!
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST) {
looking = qfalse;
- VectorCopy( vec3_origin, chestAngles );
- }
- else
- {
- //look at lookTarget!
- float lookingSpeed = 0.3f;
- looking = CG_CheckLookTarget( cent, lookAngles, &lookingSpeed );
- //Now add head bob when talking
- talking = CG_AddHeadBob( cent, lookAngles );
-
- //NOTE: previously, lookAngleSpeed was always 0.25f for the player
- //Figure out how fast head should be turning
- if ( cent->pe.torso.yawing || cent->pe.torso.pitching )
- {//If torso is turning, we want to turn head just as fast
- if ( cent->gent->NPC )
- {
- lookAngleSpeed = cent->gent->NPC->stats.yawSpeed/150;//about 0.33 normally
- }
- else
- {
+ VectorCopy(vec3_origin, chestAngles);
+ } else {
+ // look at lookTarget!
+ float lookingSpeed = 0.3f;
+ looking = CG_CheckLookTarget(cent, lookAngles, &lookingSpeed);
+ // Now add head bob when talking
+ talking = CG_AddHeadBob(cent, lookAngles);
+
+ // NOTE: previously, lookAngleSpeed was always 0.25f for the player
+ // Figure out how fast head should be turning
+ if (cent->pe.torso.yawing || cent->pe.torso.pitching) { // If torso is turning, we want to turn head just as fast
+ if (cent->gent->NPC) {
+ lookAngleSpeed = cent->gent->NPC->stats.yawSpeed / 150; // about 0.33 normally
+ } else {
lookAngleSpeed = CG_SWINGSPEED;
}
- }
- else if ( talking )
- {//Slow for head bobbing
+ } else if (talking) { // Slow for head bobbing
lookAngleSpeed = LOOK_TALKING_SPEED;
- }
- else if ( looking )
- {//Not talking, set it up for looking at enemy, CheckLookTarget will scale it down if neccessary
+ } else if (looking) { // Not talking, set it up for looking at enemy, CheckLookTarget will scale it down if neccessary
lookAngleSpeed = lookingSpeed;
- }
- else if ( cent->gent->client->renderInfo.lookingDebounceTime > cg.time )
- {//Not looking, not talking, head is returning from a talking head bob, use talking speed
+ } else if (cent->gent->client->renderInfo.lookingDebounceTime >
+ cg.time) { // Not looking, not talking, head is returning from a talking head bob, use talking speed
lookAngleSpeed = LOOK_TALKING_SPEED;
}
- if ( looking || talking )
- {//want to keep doing this lerp behavior for a full second after stopped looking (so don't snap)
- //we should have a relative look angle, normalized to 180
+ if (looking || talking) { // want to keep doing this lerp behavior for a full second after stopped looking (so don't snap)
+ // we should have a relative look angle, normalized to 180
cent->gent->client->renderInfo.lookingDebounceTime = cg.time + 1000;
- }
- else
- {
- //still have a relative look angle from above
+ } else {
+ // still have a relative look angle from above
}
- if ( cent->gent->client->NPC_class == CLASS_RANCOR )
- {//always use the viewAngles we calced
- VectorCopy( viewAngles, lookAngles );
+ if (cent->gent->client->NPC_class == CLASS_RANCOR) { // always use the viewAngles we calced
+ VectorCopy(viewAngles, lookAngles);
}
- CG_UpdateLookAngles( cent, lookAngles, lookAngleSpeed, -50.0f, 50.0f, -70.0f, 70.0f, -30.0f, 30.0f );
+ CG_UpdateLookAngles(cent, lookAngles, lookAngleSpeed, -50.0f, 50.0f, -70.0f, 70.0f, -30.0f, 30.0f);
}
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
- {
- VectorCopy( cent->lerpAngles, lookAngles );
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST) {
+ VectorCopy(cent->lerpAngles, lookAngles);
lookAngles[0] = lookAngles[2] = 0;
lookAngles[YAW] -= trailingLegsAngles[YAW];
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->thoracicBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
- }
- else
- {
- vec3_t headClampMinAngles = {-25,-55,-10}, headClampMaxAngles = {50,50,10};
- CG_G2ClientNeckAngles( cent, lookAngles, headAngles, neckAngles, thoracicAngles, headClampMinAngles, headClampMaxAngles );
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->thoracicBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
+ } else {
+ vec3_t headClampMinAngles = {-25, -55, -10}, headClampMaxAngles = {50, 50, 10};
+ CG_G2ClientNeckAngles(cent, lookAngles, headAngles, neckAngles, thoracicAngles, headClampMinAngles, headClampMaxAngles);
}
return;
}
// All other entities
- else if ( cent->gent && cent->gent->client )
- {
- if ( (cent->gent->client->NPC_class == CLASS_PROBE )
- || (cent->gent->client->NPC_class == CLASS_R2D2 )
- || (cent->gent->client->NPC_class == CLASS_R5D2)
- || (cent->gent->client->NPC_class == CLASS_RANCOR)
- || (cent->gent->client->NPC_class == CLASS_WAMPA)
- || (cent->gent->client->NPC_class == CLASS_ATST) )
- {
- VectorCopy( cent->lerpAngles, angles );
+ else if (cent->gent && cent->gent->client) {
+ if ((cent->gent->client->NPC_class == CLASS_PROBE) || (cent->gent->client->NPC_class == CLASS_R2D2) || (cent->gent->client->NPC_class == CLASS_R5D2) ||
+ (cent->gent->client->NPC_class == CLASS_RANCOR) || (cent->gent->client->NPC_class == CLASS_WAMPA) ||
+ (cent->gent->client->NPC_class == CLASS_ATST)) {
+ VectorCopy(cent->lerpAngles, angles);
angles[PITCH] = 0;
- //FIXME: use actual swing/clamp tolerances?
- if ( cent->gent->client->ps.groundEntityNum != ENTITYNUM_NONE )
- {//on the ground
- CG_PlayerLegsYawFromMovement( cent, cent->gent->client->ps.velocity, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue );
- }
- else
- {//face legs to front
- CG_PlayerLegsYawFromMovement( cent, vec3_origin, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue );
+ // FIXME: use actual swing/clamp tolerances?
+ if (cent->gent->client->ps.groundEntityNum != ENTITYNUM_NONE) { // on the ground
+ CG_PlayerLegsYawFromMovement(cent, cent->gent->client->ps.velocity, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue);
+ } else { // face legs to front
+ CG_PlayerLegsYawFromMovement(cent, vec3_origin, &angles[YAW], cent->lerpAngles[YAW], -60, 60, qtrue);
}
- VectorCopy( cent->lerpAngles, viewAngles );
-// viewAngles[YAW] = viewAngles[ROLL] = 0;
+ VectorCopy(cent->lerpAngles, viewAngles);
+ // viewAngles[YAW] = viewAngles[ROLL] = 0;
viewAngles[PITCH] *= 0.5;
- VectorCopy( viewAngles, lookAngles );
+ VectorCopy(viewAngles, lookAngles);
lookAngles[1] = 0;
- if ( cent->gent->client->NPC_class == CLASS_ATST )
- {//body pitch
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->thoracicBone, lookAngles, BONE_ANGLES_POSTMULT,POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ if (cent->gent->client->NPC_class == CLASS_ATST) { // body pitch
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->thoracicBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
}
- VectorCopy( viewAngles, lookAngles );
+ VectorCopy(viewAngles, lookAngles);
- vec3_t trailingLegsAngles;
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
- {
- CG_ATSTLegsYaw( cent, trailingLegsAngles );
- AnglesToAxis( trailingLegsAngles, legs );
+ vec3_t trailingLegsAngles;
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST) {
+ CG_ATSTLegsYaw(cent, trailingLegsAngles);
+ AnglesToAxis(trailingLegsAngles, legs);
}
/*
else if ( cent->gent->client
@@ -2931,182 +2353,160 @@ static void CG_G2PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t angles )
AnglesToAxis( trailingLegsAngles, legs );
}
*/
- else
- {
- //FIXME: this needs to properly set the legs.yawing field so we don't erroneously play the turning anim, but we do play it when turning in place
- if ( angles[YAW] == cent->pe.legs.yawAngle )
- {
+ else {
+ // FIXME: this needs to properly set the legs.yawing field so we don't erroneously play the turning anim, but we do play it when turning in
+ // place
+ if (angles[YAW] == cent->pe.legs.yawAngle) {
cent->pe.legs.yawing = qfalse;
- }
- else
- {
+ } else {
cent->pe.legs.yawing = qtrue;
}
cent->pe.legs.yawAngle = angles[YAW];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = angles[YAW];
}
- AnglesToAxis( angles, legs );
- }
-
-// if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
-// {
-// looking = qfalse;
-// }
-// else
- { //look at lookTarget!
- //FIXME: snaps to side when lets go of lookTarget... ?
- float lookingSpeed = 0.3f;
- looking = CG_CheckLookTarget( cent, lookAngles, &lookingSpeed );
- lookAngles[PITCH] = lookAngles[ROLL] = 0;//droids can't pitch or roll their heads
- if ( looking )
- {//want to keep doing this lerp behavior for a full second after stopped looking (so don't snap)
+ AnglesToAxis(angles, legs);
+ }
+
+ // if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST )
+ // {
+ // looking = qfalse;
+ // }
+ // else
+ { // look at lookTarget!
+ // FIXME: snaps to side when lets go of lookTarget... ?
+ float lookingSpeed = 0.3f;
+ looking = CG_CheckLookTarget(cent, lookAngles, &lookingSpeed);
+ lookAngles[PITCH] = lookAngles[ROLL] = 0; // droids can't pitch or roll their heads
+ if (looking) { // want to keep doing this lerp behavior for a full second after stopped looking (so don't snap)
cent->gent->client->renderInfo.lookingDebounceTime = cg.time + 1000;
}
}
- if ( cent->gent->client->renderInfo.lookingDebounceTime > cg.time )
- { //adjust for current body orientation
+ if (cent->gent->client->renderInfo.lookingDebounceTime > cg.time) { // adjust for current body orientation
lookAngles[YAW] -= cent->pe.torso.yawAngle;
lookAngles[YAW] -= cent->pe.legs.yawAngle;
- //normalize
- lookAngles[YAW] = AngleNormalize180( lookAngles[YAW] );
-
- //slowly lerp to this new value
- //Remember last headAngles
- vec3_t oldLookAngles;
- VectorCopy( cent->gent->client->renderInfo.lastHeadAngles, oldLookAngles );
- if( VectorCompare( oldLookAngles, lookAngles ) == qfalse )
- {
- //FIXME: This clamp goes off viewAngles,
- //but really should go off the tag_torso's axis[0] angles, no?
- lookAngles[YAW] = oldLookAngles[YAW]+(lookAngles[YAW]-oldLookAngles[YAW])*cg.frameInterpolation*0.25;
- }
- //Remember current lookAngles next time
- VectorCopy( lookAngles, cent->gent->client->renderInfo.lastHeadAngles );
- }
- else
- {//Remember current lookAngles next time
- VectorCopy( lookAngles, cent->gent->client->renderInfo.lastHeadAngles );
- }
- if ( cent->gent->client->NPC_class == CLASS_ATST )
- {
- VectorCopy( cent->lerpAngles, lookAngles );
+ // normalize
+ lookAngles[YAW] = AngleNormalize180(lookAngles[YAW]);
+
+ // slowly lerp to this new value
+ // Remember last headAngles
+ vec3_t oldLookAngles;
+ VectorCopy(cent->gent->client->renderInfo.lastHeadAngles, oldLookAngles);
+ if (VectorCompare(oldLookAngles, lookAngles) == qfalse) {
+ // FIXME: This clamp goes off viewAngles,
+ // but really should go off the tag_torso's axis[0] angles, no?
+ lookAngles[YAW] = oldLookAngles[YAW] + (lookAngles[YAW] - oldLookAngles[YAW]) * cg.frameInterpolation * 0.25;
+ }
+ // Remember current lookAngles next time
+ VectorCopy(lookAngles, cent->gent->client->renderInfo.lastHeadAngles);
+ } else { // Remember current lookAngles next time
+ VectorCopy(lookAngles, cent->gent->client->renderInfo.lastHeadAngles);
+ }
+ if (cent->gent->client->NPC_class == CLASS_ATST) {
+ VectorCopy(cent->lerpAngles, lookAngles);
lookAngles[0] = lookAngles[2] = 0;
lookAngles[YAW] -= trailingLegsAngles[YAW];
- }
- else
- {
+ } else {
lookAngles[PITCH] = lookAngles[ROLL] = 0;
lookAngles[YAW] -= cent->pe.legs.yawAngle;
}
- if ( cent->gent->client->NPC_class == CLASS_WAMPA )
- {
+ if (cent->gent->client->NPC_class == CLASS_WAMPA) {
Eorientations oUp, oRt, oFwd;
- G_BoneOrientationsForClass( cent->gent->client->NPC_class, "cranium", &oUp, &oRt, &oFwd );
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, lookAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw );
- }
- else
- {
- BG_G2SetBoneAngles( cent, cent->gent, cent->gent->craniumBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, cgs.model_draw);
+ G_BoneOrientationsForClass(cent->gent->client->NPC_class, "cranium", &oUp, &oRt, &oFwd);
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, lookAngles, BONE_ANGLES_POSTMULT, oUp, oRt, oFwd, cgs.model_draw);
+ } else {
+ BG_G2SetBoneAngles(cent, cent->gent, cent->gent->craniumBone, lookAngles, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z,
+ cgs.model_draw);
}
- //return;
- }
- else//if ( (cent->gent->client->NPC_class == CLASS_GONK ) || (cent->gent->client->NPC_class == CLASS_INTERROGATOR) || (cent->gent->client->NPC_class == CLASS_SENTRY) )
+ // return;
+ } else // if ( (cent->gent->client->NPC_class == CLASS_GONK ) || (cent->gent->client->NPC_class == CLASS_INTERROGATOR) || (cent->gent->client->NPC_class
+ // == CLASS_SENTRY) )
{
- VectorCopy( cent->lerpAngles, angles );
+ VectorCopy(cent->lerpAngles, angles);
cent->pe.torso.pitchAngle = 0;
cent->pe.torso.yawAngle = 0;
cent->pe.legs.pitchAngle = angles[0];
cent->gent->client->renderInfo.legsYaw = cent->pe.legs.yawAngle = angles[1];
- AnglesToAxis( angles, legs );
- //return;
+ AnglesToAxis(angles, legs);
+ // return;
}
}
}
-static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] )
-{
- vec3_t legsAngles, torsoAngles, headAngles;
- vec3_t lookAngles, viewAngles;
- float headYawClampMin, headYawClampMax;
- float headPitchClampMin, headPitchClampMax;
- float torsoYawSwingTolMin, torsoYawSwingTolMax;
- float torsoYawClampMin, torsoYawClampMax;
- float torsoPitchSwingTolMin, torsoPitchSwingTolMax;
- float torsoPitchClampMin, torsoPitchClampMax;
- float legsYawSwingTolMin, legsYawSwingTolMax;
- float maxYawSpeed, yawSpeed, lookingSpeed;
- float lookAngleSpeed = LOOK_TALKING_SPEED;//shut up the compiler
- float swing, scale;
- int i;
- qboolean looking = qfalse, talking = qfalse;
+static void CG_PlayerAngles(centity_t *cent, vec3_t legs[3], vec3_t torso[3], vec3_t head[3]) {
+ vec3_t legsAngles, torsoAngles, headAngles;
+ vec3_t lookAngles, viewAngles;
+ float headYawClampMin, headYawClampMax;
+ float headPitchClampMin, headPitchClampMax;
+ float torsoYawSwingTolMin, torsoYawSwingTolMax;
+ float torsoYawClampMin, torsoYawClampMax;
+ float torsoPitchSwingTolMin, torsoPitchSwingTolMax;
+ float torsoPitchClampMin, torsoPitchClampMax;
+ float legsYawSwingTolMin, legsYawSwingTolMax;
+ float maxYawSpeed, yawSpeed, lookingSpeed;
+ float lookAngleSpeed = LOOK_TALKING_SPEED; // shut up the compiler
+ float swing, scale;
+ int i;
+ qboolean looking = qfalse, talking = qfalse;
- if ( cg.renderingThirdPerson && cent->gent && cent->gent->s.number == 0 )
- {
+ if (cg.renderingThirdPerson && cent->gent && cent->gent->s.number == 0) {
// If we are rendering third person, we should just force the player body to always fully face
// whatever way they are looking, otherwise, you can end up with gun shots coming off of the
// gun at angles that just look really wrong.
- //NOTENOTE: shots are coming out of the gun at ridiculous angles. The head & torso
- //should pitch *some* when looking up and down...
+ // NOTENOTE: shots are coming out of the gun at ridiculous angles. The head & torso
+ // should pitch *some* when looking up and down...
- //VectorClear( viewAngles );
- VectorCopy( cent->lerpAngles, viewAngles );
+ // VectorClear( viewAngles );
+ VectorCopy(cent->lerpAngles, viewAngles);
viewAngles[YAW] = viewAngles[ROLL] = 0;
viewAngles[PITCH] *= 0.5;
- AnglesToAxis( viewAngles, head );
+ AnglesToAxis(viewAngles, head);
viewAngles[PITCH] *= 0.75;
cent->pe.torso.pitchAngle = viewAngles[PITCH];
cent->pe.torso.yawAngle = viewAngles[YAW];
- AnglesToAxis( viewAngles, torso );
+ AnglesToAxis(viewAngles, torso);
- VectorCopy( cent->lerpAngles, lookAngles );
+ VectorCopy(cent->lerpAngles, lookAngles);
lookAngles[PITCH] = 0;
- //FIXME: this needs to properly set the legs.yawing field so we don't erroneously play the turning anim, but we do play it when turning in place
- if ( lookAngles[YAW] == cent->pe.legs.yawAngle )
- {
+ // FIXME: this needs to properly set the legs.yawing field so we don't erroneously play the turning anim, but we do play it when turning in place
+ if (lookAngles[YAW] == cent->pe.legs.yawAngle) {
cent->pe.legs.yawing = qfalse;
- }
- else
- {
+ } else {
cent->pe.legs.yawing = qtrue;
}
- if ( cent->gent->client->ps.velocity[0] || cent->gent->client->ps.velocity[1] )
- {
- float moveYaw;
- moveYaw = vectoyaw( cent->gent->client->ps.velocity );
- lookAngles[YAW] = cent->lerpAngles[YAW] + AngleDelta( cent->lerpAngles[YAW], moveYaw );
+ if (cent->gent->client->ps.velocity[0] || cent->gent->client->ps.velocity[1]) {
+ float moveYaw;
+ moveYaw = vectoyaw(cent->gent->client->ps.velocity);
+ lookAngles[YAW] = cent->lerpAngles[YAW] + AngleDelta(cent->lerpAngles[YAW], moveYaw);
}
cent->pe.legs.yawAngle = lookAngles[YAW];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = lookAngles[YAW];
}
- AnglesToAxis( lookAngles, legs );
+ AnglesToAxis(lookAngles, legs);
return;
}
- if ( cent->currentState.clientNum != 0 )
- {
+ if (cent->currentState.clientNum != 0) {
headYawClampMin = -cent->gent->client->renderInfo.headYawRangeLeft;
headYawClampMax = cent->gent->client->renderInfo.headYawRangeRight;
- //These next two are only used for a calc below- this clamp is done in PM_UpdateViewAngles
+ // These next two are only used for a calc below- this clamp is done in PM_UpdateViewAngles
headPitchClampMin = -cent->gent->client->renderInfo.headPitchRangeUp;
headPitchClampMax = cent->gent->client->renderInfo.headPitchRangeDown;
torsoYawSwingTolMin = headYawClampMin * 0.3;
torsoYawSwingTolMax = headYawClampMax * 0.3;
torsoPitchSwingTolMin = headPitchClampMin * 0.5;
- torsoPitchSwingTolMax = headPitchClampMax * 0.5;
+ torsoPitchSwingTolMax = headPitchClampMax * 0.5;
torsoYawClampMin = -cent->gent->client->renderInfo.torsoYawRangeLeft;
torsoYawClampMax = cent->gent->client->renderInfo.torsoYawRangeRight;
torsoPitchClampMin = -cent->gent->client->renderInfo.torsoPitchRangeUp;
@@ -3115,26 +2515,17 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], v
legsYawSwingTolMin = torsoYawClampMin * 0.5;
legsYawSwingTolMax = torsoYawClampMax * 0.5;
- if ( cent->gent && cent->gent->next_roff_time && cent->gent->next_roff_time >= cg.time )
- {//Following a roff, body must keep up with head, yaw-wise
- headYawClampMin =
- headYawClampMax =
- torsoYawSwingTolMin =
- torsoYawSwingTolMax =
- torsoYawClampMin =
- torsoYawClampMax =
- legsYawSwingTolMin =
- legsYawSwingTolMax = 0;
+ if (cent->gent && cent->gent->next_roff_time && cent->gent->next_roff_time >= cg.time) { // Following a roff, body must keep up with head, yaw-wise
+ headYawClampMin = headYawClampMax = torsoYawSwingTolMin = torsoYawSwingTolMax = torsoYawClampMin = torsoYawClampMax = legsYawSwingTolMin =
+ legsYawSwingTolMax = 0;
}
- yawSpeed = maxYawSpeed = cent->gent->NPC->stats.yawSpeed/150;//about 0.33 normally
- }
- else
- {
+ yawSpeed = maxYawSpeed = cent->gent->NPC->stats.yawSpeed / 150; // about 0.33 normally
+ } else {
headYawClampMin = -70;
headYawClampMax = 70;
- //These next two are only used for a calc below- this clamp is done in PM_UpdateViewAngles
+ // These next two are only used for a calc below- this clamp is done in PM_UpdateViewAngles
headPitchClampMin = -90;
headPitchClampMax = 90;
@@ -3153,70 +2544,56 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], v
yawSpeed = maxYawSpeed = CG_SWINGSPEED;
}
- if(yawSpeed <= 0)
- {//Just in case
- yawSpeed = 0.5f; //was 0.33
+ if (yawSpeed <= 0) { // Just in case
+ yawSpeed = 0.5f; // was 0.33
}
lookingSpeed = yawSpeed;
- VectorCopy( cent->lerpAngles, headAngles );
- headAngles[YAW] = AngleNormalize360( headAngles[YAW] );
- VectorClear( legsAngles );
- VectorClear( torsoAngles );
+ VectorCopy(cent->lerpAngles, headAngles);
+ headAngles[YAW] = AngleNormalize360(headAngles[YAW]);
+ VectorClear(legsAngles);
+ VectorClear(torsoAngles);
// --------- yaw -------------
- //Clamp and swing the legs
+ // Clamp and swing the legs
legsAngles[YAW] = headAngles[YAW];
- if(cent->gent->client->renderInfo.renderFlags & RF_LOCKEDANGLE)
- {
+ if (cent->gent->client->renderInfo.renderFlags & RF_LOCKEDANGLE) {
cent->gent->client->renderInfo.legsYaw = cent->pe.legs.yawAngle = cent->gent->client->renderInfo.lockYaw;
cent->pe.legs.yawing = qfalse;
legsAngles[YAW] = cent->pe.legs.yawAngle;
- }
- else
- {
+ } else {
qboolean alwaysFace = qfalse;
- if ( cent->gent && cent->gent->health > 0 )
- {
- if ( cent->gent->enemy )
- {
+ if (cent->gent && cent->gent->health > 0) {
+ if (cent->gent->enemy) {
alwaysFace = qtrue;
}
- if ( CG_PlayerLegsYawFromMovement( cent, cent->gent->client->ps.velocity, &legsAngles[YAW], headAngles[YAW], torsoYawClampMin, torsoYawClampMax, alwaysFace ) )
- {
- if ( legsAngles[YAW] == cent->pe.legs.yawAngle )
- {
+ if (CG_PlayerLegsYawFromMovement(cent, cent->gent->client->ps.velocity, &legsAngles[YAW], headAngles[YAW], torsoYawClampMin, torsoYawClampMax,
+ alwaysFace)) {
+ if (legsAngles[YAW] == cent->pe.legs.yawAngle) {
cent->pe.legs.yawing = qfalse;
- }
- else
- {
+ } else {
cent->pe.legs.yawing = qtrue;
}
cent->pe.legs.yawAngle = legsAngles[YAW];
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = legsAngles[YAW];
}
- }
- else
- {
- CG_SwingAngles( legsAngles[YAW], legsYawSwingTolMin, legsYawSwingTolMax, torsoYawClampMin, torsoYawClampMax, maxYawSpeed, ¢->pe.legs.yawAngle, ¢->pe.legs.yawing );
+ } else {
+ CG_SwingAngles(legsAngles[YAW], legsYawSwingTolMin, legsYawSwingTolMax, torsoYawClampMin, torsoYawClampMax, maxYawSpeed,
+ ¢->pe.legs.yawAngle, ¢->pe.legs.yawing);
legsAngles[YAW] = cent->pe.legs.yawAngle;
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = legsAngles[YAW];
}
}
- }
- else
- {
- CG_SwingAngles( legsAngles[YAW], legsYawSwingTolMin, legsYawSwingTolMax, torsoYawClampMin, torsoYawClampMax, maxYawSpeed, ¢->pe.legs.yawAngle, ¢->pe.legs.yawing );
+ } else {
+ CG_SwingAngles(legsAngles[YAW], legsYawSwingTolMin, legsYawSwingTolMax, torsoYawClampMin, torsoYawClampMax, maxYawSpeed, ¢->pe.legs.yawAngle,
+ ¢->pe.legs.yawing);
legsAngles[YAW] = cent->pe.legs.yawAngle;
- if ( cent->gent->client )
- {
+ if (cent->gent->client) {
cent->gent->client->renderInfo.legsYaw = legsAngles[YAW];
}
}
@@ -3232,140 +2609,123 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], v
// torso
// If applicable, swing the lower parts to catch up with the head
- CG_SwingAngles( headAngles[YAW], torsoYawSwingTolMin, torsoYawSwingTolMax, headYawClampMin, headYawClampMax, yawSpeed, ¢->pe.torso.yawAngle, ¢->pe.torso.yawing);
+ CG_SwingAngles(headAngles[YAW], torsoYawSwingTolMin, torsoYawSwingTolMax, headYawClampMin, headYawClampMax, yawSpeed, ¢->pe.torso.yawAngle,
+ ¢->pe.torso.yawing);
torsoAngles[YAW] = cent->pe.torso.yawAngle;
// ---------- pitch -----------
- //As the body twists to its extents, the back tends to arch backwards
-
+ // As the body twists to its extents, the back tends to arch backwards
float dest;
// only show a fraction of the pitch angle in the torso
- if ( headAngles[PITCH] > 180 )
- {
+ if (headAngles[PITCH] > 180) {
dest = (-360 + headAngles[PITCH]) * 0.75;
- }
- else
- {
+ } else {
dest = headAngles[PITCH] * 0.75;
}
- CG_SwingAngles( dest, torsoPitchSwingTolMin, torsoPitchSwingTolMax, torsoPitchClampMin, torsoPitchClampMax, 0.1f, ¢->pe.torso.pitchAngle, ¢->pe.torso.pitching );
+ CG_SwingAngles(dest, torsoPitchSwingTolMin, torsoPitchSwingTolMax, torsoPitchClampMin, torsoPitchClampMax, 0.1f, ¢->pe.torso.pitchAngle,
+ ¢->pe.torso.pitching);
torsoAngles[PITCH] = cent->pe.torso.pitchAngle;
// --------- roll -------------
// pain twitch - FIXME: don't do this if you have no head (like droids?)
// Maybe need to have clamp angles for roll as well as pitch and yaw?
- //CG_AddPainTwitch( cent, torsoAngles );
+ // CG_AddPainTwitch( cent, torsoAngles );
//----------- Special head looking ---------------
- //FIXME: to clamp the head angles, figure out tag_head's offset from tag_torso and add
+ // FIXME: to clamp the head angles, figure out tag_head's offset from tag_torso and add
// that to whatever offset we're getting here... so turning the head in an
// anim that also turns the head doesn't allow the head to turn out of range.
- //Start with straight ahead
- VectorCopy( headAngles, viewAngles );
- VectorCopy( headAngles, lookAngles );
+ // Start with straight ahead
+ VectorCopy(headAngles, viewAngles);
+ VectorCopy(headAngles, lookAngles);
- //Remember last headAngles
- VectorCopy( cent->gent->client->renderInfo.lastHeadAngles, headAngles );
+ // Remember last headAngles
+ VectorCopy(cent->gent->client->renderInfo.lastHeadAngles, headAngles);
- //See if we're looking at someone/thing
- looking = CG_CheckLookTarget( cent, lookAngles, &lookingSpeed );
+ // See if we're looking at someone/thing
+ looking = CG_CheckLookTarget(cent, lookAngles, &lookingSpeed);
- //Now add head bob when talking
-/* if ( cent->gent->client->clientInfo.extensions )
- {
- talking = CG_AddHeadBob( cent, lookAngles );
- }
-*/
- //Figure out how fast head should be turning
- if ( cent->pe.torso.yawing || cent->pe.torso.pitching )
- {//If torso is turning, we want to turn head just as fast
+ // Now add head bob when talking
+ /* if ( cent->gent->client->clientInfo.extensions )
+ {
+ talking = CG_AddHeadBob( cent, lookAngles );
+ }
+ */
+ // Figure out how fast head should be turning
+ if (cent->pe.torso.yawing || cent->pe.torso.pitching) { // If torso is turning, we want to turn head just as fast
lookAngleSpeed = yawSpeed;
- }
- else if ( talking )
- {//Slow for head bobbing
+ } else if (talking) { // Slow for head bobbing
lookAngleSpeed = LOOK_TALKING_SPEED;
- }
- else if ( looking )
- {//Not talking, set it up for looking at enemy, CheckLookTarget will scale it down if neccessary
+ } else if (looking) { // Not talking, set it up for looking at enemy, CheckLookTarget will scale it down if neccessary
lookAngleSpeed = lookingSpeed;
- }
- else if ( cent->gent->client->renderInfo.lookingDebounceTime > cg.time )
- {//Not looking, not talking, head is returning from a talking head bob, use talking speed
+ } else if (cent->gent->client->renderInfo.lookingDebounceTime >
+ cg.time) { // Not looking, not talking, head is returning from a talking head bob, use talking speed
lookAngleSpeed = LOOK_TALKING_SPEED;
}
- if ( looking || talking )
- {//Keep this type of looking for a second after stopped looking
+ if (looking || talking) { // Keep this type of looking for a second after stopped looking
cent->gent->client->renderInfo.lookingDebounceTime = cg.time + 1000;
}
- if ( cent->gent->client->renderInfo.lookingDebounceTime > cg.time )
- {
- //Calc our actual desired head angles
- for ( i = 0; i < 3; i++ )
- {
- lookAngles[i] = AngleNormalize360( cent->gent->client->renderInfo.headBobAngles[i] + lookAngles[i] );
+ if (cent->gent->client->renderInfo.lookingDebounceTime > cg.time) {
+ // Calc our actual desired head angles
+ for (i = 0; i < 3; i++) {
+ lookAngles[i] = AngleNormalize360(cent->gent->client->renderInfo.headBobAngles[i] + lookAngles[i]);
}
- if( VectorCompare( headAngles, lookAngles ) == qfalse )
- {
- //FIXME: This clamp goes off viewAngles,
- //but really should go off the tag_torso's axis[0] angles, no?
- CG_UpdateAngleClamp( lookAngles[PITCH], headPitchClampMin/1.25, headPitchClampMax/1.25, lookAngleSpeed, &headAngles[PITCH], viewAngles[PITCH] );
- CG_UpdateAngleClamp( lookAngles[YAW], headYawClampMin/1.25, headYawClampMax/1.25, lookAngleSpeed, &headAngles[YAW], viewAngles[YAW] );
- CG_UpdateAngleClamp( lookAngles[ROLL], -10, 10, lookAngleSpeed, &headAngles[ROLL], viewAngles[ROLL] );
+ if (VectorCompare(headAngles, lookAngles) == qfalse) {
+ // FIXME: This clamp goes off viewAngles,
+ // but really should go off the tag_torso's axis[0] angles, no?
+ CG_UpdateAngleClamp(lookAngles[PITCH], headPitchClampMin / 1.25, headPitchClampMax / 1.25, lookAngleSpeed, &headAngles[PITCH], viewAngles[PITCH]);
+ CG_UpdateAngleClamp(lookAngles[YAW], headYawClampMin / 1.25, headYawClampMax / 1.25, lookAngleSpeed, &headAngles[YAW], viewAngles[YAW]);
+ CG_UpdateAngleClamp(lookAngles[ROLL], -10, 10, lookAngleSpeed, &headAngles[ROLL], viewAngles[ROLL]);
}
- if ( !cent->gent->enemy || cent->gent->enemy->s.number != cent->gent->client->renderInfo.lookTarget )
- {
- //NOTE: Hacky, yes, I know, but necc.
- //We want to turn the body to follow the lookTarget
- //ONLY IF WE DON'T HAVE AN ENEMY OR OUR ENEMY IS NOT OUR LOOKTARGET
- //This is the piece of code that was making the enemies not face where
- //they were actually aiming.
+ if (!cent->gent->enemy || cent->gent->enemy->s.number != cent->gent->client->renderInfo.lookTarget) {
+ // NOTE: Hacky, yes, I know, but necc.
+ // We want to turn the body to follow the lookTarget
+ // ONLY IF WE DON'T HAVE AN ENEMY OR OUR ENEMY IS NOT OUR LOOKTARGET
+ // This is the piece of code that was making the enemies not face where
+ // they were actually aiming.
- //Yaw change
- swing = AngleSubtract( legsAngles[YAW], headAngles[YAW] );
- scale = fabs( swing ) / ( torsoYawClampMax + 0.01 ); //NOTENOTE: Some ents have a clamp of 0, which is bad for division
+ // Yaw change
+ swing = AngleSubtract(legsAngles[YAW], headAngles[YAW]);
+ scale = fabs(swing) / (torsoYawClampMax + 0.01); // NOTENOTE: Some ents have a clamp of 0, which is bad for division
scale *= LOOK_SWING_SCALE;
- torsoAngles[YAW] = legsAngles[YAW] - ( swing * scale );
+ torsoAngles[YAW] = legsAngles[YAW] - (swing * scale);
- //Pitch change
- swing = AngleSubtract( legsAngles[PITCH], headAngles[PITCH] );
- scale = fabs( swing ) / ( torsoPitchClampMax + 0.01 ); //NOTENOTE: Some ents have a clamp of 0, which is bad for division
+ // Pitch change
+ swing = AngleSubtract(legsAngles[PITCH], headAngles[PITCH]);
+ scale = fabs(swing) / (torsoPitchClampMax + 0.01); // NOTENOTE: Some ents have a clamp of 0, which is bad for division
scale *= LOOK_SWING_SCALE;
- torsoAngles[PITCH] = legsAngles[PITCH] - ( swing * scale );
+ torsoAngles[PITCH] = legsAngles[PITCH] - (swing * scale);
}
- }
- else
- {//Look straight ahead
- VectorCopy( viewAngles, headAngles );
+ } else { // Look straight ahead
+ VectorCopy(viewAngles, headAngles);
}
- //Remember current headAngles next time
- VectorCopy( headAngles, cent->gent->client->renderInfo.lastHeadAngles );
+ // Remember current headAngles next time
+ VectorCopy(headAngles, cent->gent->client->renderInfo.lastHeadAngles);
//-------------------------------------------------------------
// pull the angles back out of the hierarchial chain
- AnglesSubtract( headAngles, torsoAngles, headAngles );
- AnglesSubtract( torsoAngles, legsAngles, torsoAngles );
- AnglesToAxis( legsAngles, legs );
- AnglesToAxis( torsoAngles, torso );
- AnglesToAxis( headAngles, head );
+ AnglesSubtract(headAngles, torsoAngles, headAngles);
+ AnglesSubtract(torsoAngles, legsAngles, torsoAngles);
+ AnglesToAxis(legsAngles, legs);
+ AnglesToAxis(torsoAngles, torso);
+ AnglesToAxis(headAngles, head);
}
-
//==========================================================================
-
/*
===============
CG_TrailItem
@@ -3398,75 +2758,71 @@ static void CG_TrailItem( centity_t *cent, qhandle_t hModel ) {
CG_PlayerPowerups
===============
*/
-extern void CG_Seeker( centity_t *cent );
-static void CG_PlayerPowerups( centity_t *cent )
-{
- if ( !cent->currentState.powerups )
- {
+extern void CG_Seeker(centity_t *cent);
+static void CG_PlayerPowerups(centity_t *cent) {
+ if (!cent->currentState.powerups) {
return;
}
-/*
+ /*
- // quad gives a dlight
- if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) {
- cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2, 0.2, 1 );
- }
+ // quad gives a dlight
+ if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) {
+ cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2, 0.2, 1 );
+ }
- // redflag
- if ( cent->currentState.powerups & ( 1 << PW_REDFLAG ) ) {
- CG_TrailItem( cent, cgs.media.redFlagModel );
- cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1, 0.2, 0.2 );
- }
+ // redflag
+ if ( cent->currentState.powerups & ( 1 << PW_REDFLAG ) ) {
+ CG_TrailItem( cent, cgs.media.redFlagModel );
+ cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1, 0.2, 0.2 );
+ }
- // blueflag
- if ( cent->currentState.powerups & ( 1 << PW_BLUEFLAG ) ) {
- CG_TrailItem( cent, cgs.media.blueFlagModel );
- cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2, 0.2, 1 );
- }
-*/
+ // blueflag
+ if ( cent->currentState.powerups & ( 1 << PW_BLUEFLAG ) ) {
+ CG_TrailItem( cent, cgs.media.blueFlagModel );
+ cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2, 0.2, 1 );
+ }
+ */
// invul gives a dlight
-// if ( cent->currentState.powerups & ( 1 << PW_BATTLESUIT ) )
-// {
-// cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.8f, 0.8f, 0.2f );
-// }
+ // if ( cent->currentState.powerups & ( 1 << PW_BATTLESUIT ) )
+ // {
+ // cgi_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.8f, 0.8f, 0.2f );
+ // }
// seeker coolness
-/* if ( cent->currentState.powerups & ( 1 << PW_SEEKER ) )
- {
-// CG_Seeker(cent);
- }*/
+ /* if ( cent->currentState.powerups & ( 1 << PW_SEEKER ) )
+ {
+ // CG_Seeker(cent);
+ }*/
}
-#define SHADOW_DISTANCE 128
-static qboolean _PlayerShadow( const vec3_t origin, const float orientation, float *const shadowPlane, const float radius, qhandle_t markShader ) {
- vec3_t end, mins = {-7, -7, 0}, maxs = {7, 7, 2};
- trace_t trace;
- float alpha;
+#define SHADOW_DISTANCE 128
+static qboolean _PlayerShadow(const vec3_t origin, const float orientation, float *const shadowPlane, const float radius, qhandle_t markShader) {
+ vec3_t end, mins = {-7, -7, 0}, maxs = {7, 7, 2};
+ trace_t trace;
+ float alpha;
// send a trace down from the player to the ground
- VectorCopy( origin, end );
+ VectorCopy(origin, end);
end[2] -= SHADOW_DISTANCE;
- cgi_CM_BoxTrace( &trace, origin, end, mins, maxs, 0, MASK_PLAYERSOLID );
+ cgi_CM_BoxTrace(&trace, origin, end, mins, maxs, 0, MASK_PLAYERSOLID);
// no shadow if too high
- if ( trace.fraction == 1.0 || (trace.startsolid && trace.allsolid) ) {
+ if (trace.fraction == 1.0 || (trace.startsolid && trace.allsolid)) {
return qfalse;
}
*shadowPlane = trace.endpos[2] + 1;
// no mark for stencil or projection shadows
- if ( cg_shadows.integer == 1
- || (in_camera && cg_shadows.integer == 2) )//don't want stencil shadows during a cinematic
+ if (cg_shadows.integer == 1 || (in_camera && cg_shadows.integer == 2)) // don't want stencil shadows during a cinematic
{
// fade the shadow out with height
alpha = 1.0 - trace.fraction;
// add the mark as a temporary, so it goes directly to the renderer
// without taking a spot in the cg_marks array
- CG_ImpactMark( markShader, trace.endpos, trace.plane.normal,
- orientation, 1,1,1,alpha, qfalse, radius, qtrue );
+ CG_ImpactMark(markShader, trace.endpos, trace.plane.normal, orientation, 1, 1, 1, alpha, qfalse, radius, qtrue);
}
return qtrue;
}
@@ -3480,87 +2836,72 @@ Returns the Z component of the surface being shadowed
should it return a full plane instead of a Z?
===============
*/
-static qboolean CG_PlayerShadow( centity_t *const cent, float *const shadowPlane ) {
+static qboolean CG_PlayerShadow(centity_t *const cent, float *const shadowPlane) {
*shadowPlane = 0;
- if ( cg_shadows.integer == 0 ) {
+ if (cg_shadows.integer == 0) {
return qfalse;
}
// no shadows when cloaked
- if ( cent->currentState.powerups & ( 1 << PW_CLOAKED ))
- {
+ if (cent->currentState.powerups & (1 << PW_CLOAKED)) {
return qfalse;
}
- if ( cent->gent->client->NPC_class == CLASS_SAND_CREATURE )
- {//sand creatures have no shadow
+ if (cent->gent->client->NPC_class == CLASS_SAND_CREATURE) { // sand creatures have no shadow
return qfalse;
}
vec3_t rootOrigin;
vec3_t tempAngles;
- tempAngles[PITCH] = 0;
- tempAngles[YAW] = cent->pe.legs.yawAngle;
- tempAngles[ROLL] = 0;
- if (cent->gent->rootBone>=0 && cent->gent->ghoul2.IsValid() && cent->gent->ghoul2[0].animModelIndexOffset)//If it has an animOffset it's a cinematic anim
- { //i might be running out of my bounding box, so get my root origin
- mdxaBone_t boltMatrix;
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->rootBone,
- &boltMatrix, tempAngles, cent->lerpOrigin,
- cg.time, cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, rootOrigin );
- }
- else
- {
- VectorCopy(cent->lerpOrigin,rootOrigin);
- }
-
- if ( DistanceSquared( cg.refdef.vieworg, rootOrigin ) > cg_shadowCullDistance.value * cg_shadowCullDistance.value )
- {
+ tempAngles[PITCH] = 0;
+ tempAngles[YAW] = cent->pe.legs.yawAngle;
+ tempAngles[ROLL] = 0;
+ if (cent->gent->rootBone >= 0 && cent->gent->ghoul2.IsValid() &&
+ cent->gent->ghoul2[0].animModelIndexOffset) // If it has an animOffset it's a cinematic anim
+ { // i might be running out of my bounding box, so get my root origin
+ mdxaBone_t boltMatrix;
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->rootBone, &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, rootOrigin);
+ } else {
+ VectorCopy(cent->lerpOrigin, rootOrigin);
+ }
+
+ if (DistanceSquared(cg.refdef.vieworg, rootOrigin) > cg_shadowCullDistance.value * cg_shadowCullDistance.value) {
// Shadow is too far away, don't do any traces, don't do any marks...blah
return qfalse;
}
- if (cent->gent->client->NPC_class == CLASS_ATST)
- {
+ if (cent->gent->client->NPC_class == CLASS_ATST) {
qboolean bShadowed;
- mdxaBone_t boltMatrix;
+ mdxaBone_t boltMatrix;
vec3_t sideOrigin;
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footLBolt,
- &boltMatrix, tempAngles, cent->lerpOrigin,
- cg.time, cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, sideOrigin );
- sideOrigin[2] += 30; //fudge up a bit for coplaner
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footLBolt, &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, sideOrigin);
+ sideOrigin[2] += 30; // fudge up a bit for coplaner
bShadowed = _PlayerShadow(sideOrigin, 0, shadowPlane, 28, cgs.media.shadowMarkShader);
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footRBolt,
- &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, sideOrigin );
- sideOrigin[2] += 30; //fudge up a bit for coplaner
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footRBolt, &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, sideOrigin);
+ sideOrigin[2] += 30; // fudge up a bit for coplaner
bShadowed = (qboolean)(_PlayerShadow(sideOrigin, 0, shadowPlane, 28, cgs.media.shadowMarkShader) || bShadowed);
- bShadowed = (qboolean)( _PlayerShadow(rootOrigin, cent->pe.legs.yawAngle, shadowPlane, 64, cgs.media.shadowMarkShader) || bShadowed);
+ bShadowed = (qboolean)(_PlayerShadow(rootOrigin, cent->pe.legs.yawAngle, shadowPlane, 64, cgs.media.shadowMarkShader) || bShadowed);
return bShadowed;
- }
- else if ( cent->gent->client->NPC_class == CLASS_RANCOR )
- {
+ } else if (cent->gent->client->NPC_class == CLASS_RANCOR) {
return _PlayerShadow(rootOrigin, cent->pe.legs.yawAngle, shadowPlane, 64, cgs.media.shadowMarkShader);
- }
- else
- {
+ } else {
return _PlayerShadow(rootOrigin, cent->pe.legs.yawAngle, shadowPlane, 16, cgs.media.shadowMarkShader);
}
-
}
-void CG_LandingEffect( vec3_t origin, vec3_t normal, int material )
-{
- int effectID = -1;
- switch ( material )
- {
+void CG_LandingEffect(vec3_t origin, vec3_t normal, int material) {
+ int effectID = -1;
+ switch (material) {
case MATERIAL_MUD:
effectID = cgs.effects.landingMud;
break;
@@ -3578,180 +2919,168 @@ void CG_LandingEffect( vec3_t origin, vec3_t normal, int material )
break;
}
- if ( effectID != -1 )
- {
- theFxScheduler.PlayEffect( effectID, origin, normal );
+ if (effectID != -1) {
+ theFxScheduler.PlayEffect(effectID, origin, normal);
}
}
-#define FOOTSTEP_DISTANCE 32
-static void _PlayerFootStep( const vec3_t origin,
- const vec3_t traceDir,
- const float orientation,
- const float radius,
- centity_t *const cent, footstepType_t footStepType )
-{
- vec3_t end, mins = {-7, -7, 0}, maxs = {7, 7, 2};
- trace_t trace;
- footstep_t soundType = FOOTSTEP_TOTAL;
- bool bMark = false;
- int effectID = -1;
- //float alpha;
+#define FOOTSTEP_DISTANCE 32
+static void _PlayerFootStep(const vec3_t origin, const vec3_t traceDir, const float orientation, const float radius, centity_t *const cent,
+ footstepType_t footStepType) {
+ vec3_t end, mins = {-7, -7, 0}, maxs = {7, 7, 2};
+ trace_t trace;
+ footstep_t soundType = FOOTSTEP_TOTAL;
+ bool bMark = false;
+ int effectID = -1;
+ // float alpha;
// send a trace down from the player to the ground
- VectorCopy( origin, end );
- VectorMA( origin, FOOTSTEP_DISTANCE, traceDir, end );//was end[2] -= FOOTSTEP_DISTANCE;
+ VectorCopy(origin, end);
+ VectorMA(origin, FOOTSTEP_DISTANCE, traceDir, end); // was end[2] -= FOOTSTEP_DISTANCE;
- cgi_CM_BoxTrace( &trace, origin, end, mins, maxs, 0, MASK_PLAYERSOLID );
+ cgi_CM_BoxTrace(&trace, origin, end, mins, maxs, 0, MASK_PLAYERSOLID);
// no shadow if too high
- if ( trace.fraction >= 1.0f )
- {
+ if (trace.fraction >= 1.0f) {
return;
}
- //check for foot-steppable surface flag
- switch( trace.surfaceFlags & MATERIAL_MASK )
- {
- case MATERIAL_MUD:
- bMark = true;
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_MUDRUN;
- } else {
- soundType = FOOTSTEP_MUDWALK;
- }
- effectID = cgs.effects.footstepMud;
- break;
- case MATERIAL_DIRT:
- bMark = true;
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_DIRTRUN;
- } else {
- soundType = FOOTSTEP_DIRTWALK;
- }
- effectID = cgs.effects.footstepSand;
- break;
- case MATERIAL_SAND:
- bMark = true;
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_SANDRUN;
- } else {
- soundType = FOOTSTEP_SANDWALK;
- }
- effectID = cgs.effects.footstepSand;
- break;
- case MATERIAL_SNOW:
- bMark = true;
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_SNOWRUN;
- } else {
- soundType = FOOTSTEP_SNOWWALK;
- }
- effectID = cgs.effects.footstepSnow;
- break;
- case MATERIAL_SHORTGRASS:
- case MATERIAL_LONGGRASS:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_GRASSRUN;
- } else {
- soundType = FOOTSTEP_GRASSWALK;
- }
- break;
- case MATERIAL_SOLIDMETAL:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_METALRUN;
- } else {
- soundType = FOOTSTEP_METALWALK;
- }
- break;
- case MATERIAL_HOLLOWMETAL:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_PIPERUN;
- } else {
- soundType = FOOTSTEP_PIPEWALK;
- }
- break;
- case MATERIAL_GRAVEL:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_GRAVELRUN;
- } else {
- soundType = FOOTSTEP_GRAVELWALK;
- }
- effectID = cgs.effects.footstepGravel;
- break;
- case MATERIAL_CARPET:
- case MATERIAL_FABRIC:
- case MATERIAL_CANVAS:
- case MATERIAL_RUBBER:
- case MATERIAL_PLASTIC:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_RUGRUN;
- } else {
- soundType = FOOTSTEP_RUGWALK;
- }
- break;
- case MATERIAL_SOLIDWOOD:
- case MATERIAL_HOLLOWWOOD:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_WOODRUN;
- } else {
- soundType = FOOTSTEP_WOODWALK;
- }
- break;
+ // check for foot-steppable surface flag
+ switch (trace.surfaceFlags & MATERIAL_MASK) {
+ case MATERIAL_MUD:
+ bMark = true;
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_MUDRUN;
+ } else {
+ soundType = FOOTSTEP_MUDWALK;
+ }
+ effectID = cgs.effects.footstepMud;
+ break;
+ case MATERIAL_DIRT:
+ bMark = true;
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_DIRTRUN;
+ } else {
+ soundType = FOOTSTEP_DIRTWALK;
+ }
+ effectID = cgs.effects.footstepSand;
+ break;
+ case MATERIAL_SAND:
+ bMark = true;
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_SANDRUN;
+ } else {
+ soundType = FOOTSTEP_SANDWALK;
+ }
+ effectID = cgs.effects.footstepSand;
+ break;
+ case MATERIAL_SNOW:
+ bMark = true;
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_SNOWRUN;
+ } else {
+ soundType = FOOTSTEP_SNOWWALK;
+ }
+ effectID = cgs.effects.footstepSnow;
+ break;
+ case MATERIAL_SHORTGRASS:
+ case MATERIAL_LONGGRASS:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_GRASSRUN;
+ } else {
+ soundType = FOOTSTEP_GRASSWALK;
+ }
+ break;
+ case MATERIAL_SOLIDMETAL:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_METALRUN;
+ } else {
+ soundType = FOOTSTEP_METALWALK;
+ }
+ break;
+ case MATERIAL_HOLLOWMETAL:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_PIPERUN;
+ } else {
+ soundType = FOOTSTEP_PIPEWALK;
+ }
+ break;
+ case MATERIAL_GRAVEL:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_GRAVELRUN;
+ } else {
+ soundType = FOOTSTEP_GRAVELWALK;
+ }
+ effectID = cgs.effects.footstepGravel;
+ break;
+ case MATERIAL_CARPET:
+ case MATERIAL_FABRIC:
+ case MATERIAL_CANVAS:
+ case MATERIAL_RUBBER:
+ case MATERIAL_PLASTIC:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_RUGRUN;
+ } else {
+ soundType = FOOTSTEP_RUGWALK;
+ }
+ break;
+ case MATERIAL_SOLIDWOOD:
+ case MATERIAL_HOLLOWWOOD:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_WOODRUN;
+ } else {
+ soundType = FOOTSTEP_WOODWALK;
+ }
+ break;
- default:
- //fall through
- case MATERIAL_GLASS:
- case MATERIAL_WATER:
- case MATERIAL_FLESH:
- case MATERIAL_BPGLASS:
- case MATERIAL_DRYLEAVES:
- case MATERIAL_GREENLEAVES:
- case MATERIAL_TILES:
- case MATERIAL_PLASTER:
- case MATERIAL_SHATTERGLASS:
- case MATERIAL_ARMOR:
- case MATERIAL_COMPUTER:
-
- case MATERIAL_CONCRETE:
- case MATERIAL_ROCK:
- case MATERIAL_ICE:
- case MATERIAL_MARBLE:
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
- soundType = FOOTSTEP_STONERUN;
- } else {
- soundType = FOOTSTEP_STONEWALK;
- }
- break;
+ default:
+ // fall through
+ case MATERIAL_GLASS:
+ case MATERIAL_WATER:
+ case MATERIAL_FLESH:
+ case MATERIAL_BPGLASS:
+ case MATERIAL_DRYLEAVES:
+ case MATERIAL_GREENLEAVES:
+ case MATERIAL_TILES:
+ case MATERIAL_PLASTER:
+ case MATERIAL_SHATTERGLASS:
+ case MATERIAL_ARMOR:
+ case MATERIAL_COMPUTER:
+
+ case MATERIAL_CONCRETE:
+ case MATERIAL_ROCK:
+ case MATERIAL_ICE:
+ case MATERIAL_MARBLE:
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_HEAVY_L) {
+ soundType = FOOTSTEP_STONERUN;
+ } else {
+ soundType = FOOTSTEP_STONEWALK;
+ }
+ break;
}
- if (soundType < FOOTSTEP_TOTAL)
- {
- cgi_S_StartSound( NULL, cent->currentState.clientNum, CHAN_BODY, cgs.media.footsteps[soundType][Q_irand( 0, 3)] );
+ if (soundType < FOOTSTEP_TOTAL) {
+ cgi_S_StartSound(NULL, cent->currentState.clientNum, CHAN_BODY, cgs.media.footsteps[soundType][Q_irand(0, 3)]);
}
- if ( cg_footsteps.integer < 4 )
- {//debugging - 4 always does footstep effect
- if ( cg_footsteps.integer < 2 ) //1 for sounds, 2 for effects, 3 for marks
+ if (cg_footsteps.integer < 4) { // debugging - 4 always does footstep effect
+ if (cg_footsteps.integer < 2) // 1 for sounds, 2 for effects, 3 for marks
{
return;
}
}
- if ( effectID != -1 )
- {
- theFxScheduler.PlayEffect( effectID, trace.endpos, trace.plane.normal );
+ if (effectID != -1) {
+ theFxScheduler.PlayEffect(effectID, trace.endpos, trace.plane.normal);
}
- if ( cg_footsteps.integer < 4 )
- {//debugging - 4 always does footprint decal
- if (!bMark || cg_footsteps.integer < 3) //1 for sounds, 2 for effects, 3 for marks
+ if (cg_footsteps.integer < 4) { // debugging - 4 always does footprint decal
+ if (!bMark || cg_footsteps.integer < 3) // 1 for sounds, 2 for effects, 3 for marks
{
return;
}
}
qhandle_t footMarkShader;
- switch ( footStepType )
- {
+ switch (footStepType) {
case FOOTSTEP_HEAVY_R:
footMarkShader = cgs.media.fshrMarkShader;
break;
@@ -3768,135 +3097,109 @@ static void _PlayerFootStep( const vec3_t origin,
}
// fade the shadow out with height
-// alpha = 1.0 - trace.fraction;
+ // alpha = 1.0 - trace.fraction;
// add the mark as a temporary, so it goes directly to the renderer
// without taking a spot in the cg_marks array
- vec3_t projNormal;
- VectorCopy(trace.plane.normal,projNormal);
- if (projNormal[2]>0.5f)
- {
+ vec3_t projNormal;
+ VectorCopy(trace.plane.normal, projNormal);
+ if (projNormal[2] > 0.5f) {
// footsteps will not have the correct orientation for all surfaces, so punt and set the projection to Z
- projNormal[0]=0.0f;
- projNormal[1]=0.0f;
- projNormal[2]=1.0f;
+ projNormal[0] = 0.0f;
+ projNormal[1] = 0.0f;
+ projNormal[2] = 1.0f;
}
- CG_ImpactMark( footMarkShader, trace.endpos,projNormal,
- orientation, 1,1,1, 1.0f, qfalse, radius, qfalse );
+ CG_ImpactMark(footMarkShader, trace.endpos, projNormal, orientation, 1, 1, 1, 1.0f, qfalse, radius, qfalse);
}
-extern vmCvar_t cg_footsteps;
-static void CG_PlayerFootsteps( centity_t *const cent, footstepType_t footStepType )
-{
- if ( cg_footsteps.integer == 0 )
- {
+extern vmCvar_t cg_footsteps;
+static void CG_PlayerFootsteps(centity_t *const cent, footstepType_t footStepType) {
+ if (cg_footsteps.integer == 0) {
return;
}
- //FIXME: make this a feature of NPCs in the NPCs.cfg? Specify a footstep shader, if any?
- if ( cent->gent->client->NPC_class != CLASS_ATST
- && cent->gent->client->NPC_class != CLASS_CLAW
- && cent->gent->client->NPC_class != CLASS_FISH
- && cent->gent->client->NPC_class != CLASS_FLIER2
- && cent->gent->client->NPC_class != CLASS_GLIDER
- && cent->gent->client->NPC_class != CLASS_INTERROGATOR
- && cent->gent->client->NPC_class != CLASS_MURJJ
- && cent->gent->client->NPC_class != CLASS_PROBE
- && cent->gent->client->NPC_class != CLASS_R2D2
- && cent->gent->client->NPC_class != CLASS_R5D2
- && cent->gent->client->NPC_class != CLASS_REMOTE
- && cent->gent->client->NPC_class != CLASS_SEEKER
- && cent->gent->client->NPC_class != CLASS_SENTRY
- && cent->gent->client->NPC_class != CLASS_SWAMP )
- {
- mdxaBone_t boltMatrix;
+ // FIXME: make this a feature of NPCs in the NPCs.cfg? Specify a footstep shader, if any?
+ if (cent->gent->client->NPC_class != CLASS_ATST && cent->gent->client->NPC_class != CLASS_CLAW && cent->gent->client->NPC_class != CLASS_FISH &&
+ cent->gent->client->NPC_class != CLASS_FLIER2 && cent->gent->client->NPC_class != CLASS_GLIDER && cent->gent->client->NPC_class != CLASS_INTERROGATOR &&
+ cent->gent->client->NPC_class != CLASS_MURJJ && cent->gent->client->NPC_class != CLASS_PROBE && cent->gent->client->NPC_class != CLASS_R2D2 &&
+ cent->gent->client->NPC_class != CLASS_R5D2 && cent->gent->client->NPC_class != CLASS_REMOTE && cent->gent->client->NPC_class != CLASS_SEEKER &&
+ cent->gent->client->NPC_class != CLASS_SENTRY && cent->gent->client->NPC_class != CLASS_SWAMP) {
+ mdxaBone_t boltMatrix;
vec3_t tempAngles, sideOrigin, footDownDir;
- tempAngles[PITCH] = 0;
- tempAngles[YAW] = cent->pe.legs.yawAngle;
- tempAngles[ROLL] = 0;
+ tempAngles[PITCH] = 0;
+ tempAngles[YAW] = cent->pe.legs.yawAngle;
+ tempAngles[ROLL] = 0;
int footBolt = cent->gent->footLBolt;
- if ( footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_R)
- {
+ if (footStepType == FOOTSTEP_HEAVY_R || footStepType == FOOTSTEP_R) {
footBolt = cent->gent->footRBolt;
}
- //FIXME: get yaw orientation of the foot and use on decal
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, footBolt,
- &boltMatrix, tempAngles, cent->lerpOrigin,
- cg.time, cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, sideOrigin );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, footDownDir );
- VectorMA( sideOrigin, -8.0f, footDownDir, sideOrigin );//was [2] += 15; //fudge up a bit for coplanar
- _PlayerFootStep( sideOrigin, footDownDir, cent->pe.legs.yawAngle, 6, cent, footStepType );
+ // FIXME: get yaw orientation of the foot and use on decal
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, footBolt, &boltMatrix, tempAngles, cent->lerpOrigin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, sideOrigin);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, footDownDir);
+ VectorMA(sideOrigin, -8.0f, footDownDir, sideOrigin); // was [2] += 15; //fudge up a bit for coplanar
+ _PlayerFootStep(sideOrigin, footDownDir, cent->pe.legs.yawAngle, 6, cent, footStepType);
}
}
-static void _PlayerSplash( const vec3_t origin, const vec3_t velocity, const float radius, const int maxUp )
-{
- static vec3_t WHITE={1,1,1};
- vec3_t start, end;
- trace_t trace;
- int contents;
+static void _PlayerSplash(const vec3_t origin, const vec3_t velocity, const float radius, const int maxUp) {
+ static vec3_t WHITE = {1, 1, 1};
+ vec3_t start, end;
+ trace_t trace;
+ int contents;
- VectorCopy( origin, end );
+ VectorCopy(origin, end);
end[2] -= 24;
// if the feet aren't in liquid, don't make a mark
// this won't handle moving water brushes, but they wouldn't draw right anyway...
- contents = cgi_CM_PointContents( end, 0 );
- if ( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) )
- {
+ contents = cgi_CM_PointContents(end, 0);
+ if (!(contents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA))) {
return;
}
- VectorCopy( origin, start );
- if ( maxUp < 32 )
- {//our head may actually be lower than 32 above our origin
+ VectorCopy(origin, start);
+ if (maxUp < 32) { // our head may actually be lower than 32 above our origin
start[2] += maxUp;
- }
- else
- {
+ } else {
start[2] += 32;
}
// if the head isn't out of liquid, don't make a mark
- contents = cgi_CM_PointContents( start, 0 );
- if ( contents & ( CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
- {
+ contents = cgi_CM_PointContents(start, 0);
+ if (contents & (CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA)) {
return;
}
// trace down to find the surface
- cgi_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) );
+ cgi_CM_BoxTrace(&trace, start, end, NULL, NULL, 0, (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA));
- if ( trace.fraction == 1.0 )
- {
+ if (trace.fraction == 1.0) {
return;
}
- VectorCopy( trace.endpos, end );
+ VectorCopy(trace.endpos, end);
end[0] += Q_flrand(-1.0f, 1.0f) * 3.0f;
end[1] += Q_flrand(-1.0f, 1.0f) * 3.0f;
- end[2] += 1.0f; //fudge up
+ end[2] += 1.0f; // fudge up
- int t = VectorLengthSquared( velocity );
+ int t = VectorLengthSquared(velocity);
- if ( t > 8192 ) // oh, magic number
+ if (t > 8192) // oh, magic number
{
t = 8192;
}
- float alpha = ( t / 8192.0f ) * 0.6f + 0.2f;
+ float alpha = (t / 8192.0f) * 0.6f + 0.2f;
- FX_AddOrientedParticle( -1, end, trace.plane.normal, NULL, NULL,
- 6.0f, radius + Q_flrand(0.0f, 1.0f) * 48.0f, 0,
- alpha, 0.0f, 0.0f,
- WHITE, WHITE, 0.0f,
- Q_flrand(0.0f, 1.0f) * 360, Q_flrand(-1.0f, 1.0f) * 6.0f, NULL, NULL, 0.0f, 0 ,0, 1200,
- cgs.media.wakeMarkShader, FX_ALPHA_LINEAR | FX_SIZE_LINEAR );
+ FX_AddOrientedParticle(-1, end, trace.plane.normal, NULL, NULL, 6.0f, radius + Q_flrand(0.0f, 1.0f) * 48.0f, 0, alpha, 0.0f, 0.0f, WHITE, WHITE, 0.0f,
+ Q_flrand(0.0f, 1.0f) * 360, Q_flrand(-1.0f, 1.0f) * 6.0f, NULL, NULL, 0.0f, 0, 0, 1200, cgs.media.wakeMarkShader,
+ FX_ALPHA_LINEAR | FX_SIZE_LINEAR);
}
/*
@@ -3906,47 +3209,39 @@ CG_PlayerSplash
Draw a mark at the water surface
===============
*/
-static void CG_PlayerSplash( centity_t *cent )
-{
- if ( !cg_shadows.integer )
- {
+static void CG_PlayerSplash(centity_t *cent) {
+ if (!cg_shadows.integer) {
return;
}
- if ( cent->gent && cent->gent->client )
- {
+ if (cent->gent && cent->gent->client) {
gclient_t *cl = cent->gent->client;
- if ( cent->gent->disconnectDebounceTime < cg.time ) // can't do these expanding ripples all the time
+ if (cent->gent->disconnectDebounceTime < cg.time) // can't do these expanding ripples all the time
{
- if ( cl->NPC_class == CLASS_ATST )
- {
- mdxaBone_t boltMatrix;
- vec3_t tempAngles, sideOrigin;
+ if (cl->NPC_class == CLASS_ATST) {
+ mdxaBone_t boltMatrix;
+ vec3_t tempAngles, sideOrigin;
- tempAngles[PITCH] = 0;
- tempAngles[YAW] = cent->pe.legs.yawAngle;
- tempAngles[ROLL] = 0;
+ tempAngles[PITCH] = 0;
+ tempAngles[YAW] = cent->pe.legs.yawAngle;
+ tempAngles[ROLL] = 0;
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footLBolt,
- &boltMatrix, tempAngles, cent->lerpOrigin,
- cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, sideOrigin );
- sideOrigin[2] += 22; //fudge up a bit for coplaner
- _PlayerSplash( sideOrigin, cl->ps.velocity, 42, cent->gent->maxs[2] );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footLBolt, &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, sideOrigin);
+ sideOrigin[2] += 22; // fudge up a bit for coplaner
+ _PlayerSplash(sideOrigin, cl->ps.velocity, 42, cent->gent->maxs[2]);
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footRBolt,
- &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, sideOrigin );
- sideOrigin[2] += 22; //fudge up a bit for coplaner
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footRBolt, &boltMatrix, tempAngles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, sideOrigin);
+ sideOrigin[2] += 22; // fudge up a bit for coplaner
- _PlayerSplash( sideOrigin, cl->ps.velocity, 42, cent->gent->maxs[2] );
- }
- else
- {
+ _PlayerSplash(sideOrigin, cl->ps.velocity, 42, cent->gent->maxs[2]);
+ } else {
// player splash mark
- _PlayerSplash( cent->lerpOrigin, cl->ps.velocity, 36, cl->renderInfo.eyePoint[2] - cent->lerpOrigin[2] + 5 );
+ _PlayerSplash(cent->lerpOrigin, cl->ps.velocity, 36, cl->renderInfo.eyePoint[2] - cent->lerpOrigin[2] + 5);
}
cent->gent->disconnectDebounceTime = cg.time + 125 + Q_flrand(0.0f, 1.0f) * 50.0f;
@@ -3954,7 +3249,6 @@ static void CG_PlayerSplash( centity_t *cent )
}
}
-
/*
===============
CG_LightningBolt
@@ -4035,10 +3329,9 @@ extern void FX_DEMP2_AltBeam( vec3_t start, vec3_t end, vec3_t normal, //qboolea
#endif
//-------------------------------------------
-#define REFRACT_EFFECT_DURATION 500
-void CG_ForcePushBlur( const vec3_t org, qboolean darkSide = qfalse );
-static void CG_ForcePushRefraction( vec3_t org, centity_t *cent )
-{
+#define REFRACT_EFFECT_DURATION 500
+void CG_ForcePushBlur(const vec3_t org, qboolean darkSide = qfalse);
+static void CG_ForcePushRefraction(vec3_t org, centity_t *cent) {
refEntity_t ent;
vec3_t ang;
float scale;
@@ -4046,71 +3339,56 @@ static void CG_ForcePushRefraction( vec3_t org, centity_t *cent )
float alpha;
int tDif;
- if (!cg_renderToTextureFX.integer)
- {
+ if (!cg_renderToTextureFX.integer) {
CG_ForcePushBlur(org);
return;
}
- if (!cent->gent ||
- !cent->gent->client)
- { //can only do this for player/npc's
+ if (!cent->gent || !cent->gent->client) { // can only do this for player/npc's
return;
}
- if (!cent->gent->client->pushEffectFadeTime)
- { //the duration for the expansion and fade
+ if (!cent->gent->client->pushEffectFadeTime) { // the duration for the expansion and fade
cent->gent->client->pushEffectFadeTime = cg.time + REFRACT_EFFECT_DURATION;
}
- //closer tDif is to 0, the closer we are to
- //being "done"
+ // closer tDif is to 0, the closer we are to
+ // being "done"
tDif = (cent->gent->client->pushEffectFadeTime - cg.time);
- if ((REFRACT_EFFECT_DURATION-tDif) < 200)
- { //stop following the hand after a little and stay in a fixed spot
- //save the initial spot of the effect
+ if ((REFRACT_EFFECT_DURATION - tDif) < 200) { // stop following the hand after a little and stay in a fixed spot
+ // save the initial spot of the effect
VectorCopy(org, cent->gent->client->pushEffectOrigin);
}
- //scale from 1.0f to 0.1f then hold at 0.1 for the rest of the duration
- if (cent->gent->client->ps.forcePowersActive & ( 1 << FP_PULL ) )
- {
- scale = (float)(REFRACT_EFFECT_DURATION-tDif)*0.003f;
- }
- else
- {
+ // scale from 1.0f to 0.1f then hold at 0.1 for the rest of the duration
+ if (cent->gent->client->ps.forcePowersActive & (1 << FP_PULL)) {
+ scale = (float)(REFRACT_EFFECT_DURATION - tDif) * 0.003f;
+ } else {
scale = (float)(tDif)*0.003f;
}
- if (scale > 1.0f)
- {
+ if (scale > 1.0f) {
scale = 1.0f;
- }
- else if (scale < 0.2f)
- {
+ } else if (scale < 0.2f) {
scale = 0.2f;
}
- //start alpha at 244, fade to 10
- alpha = (float)tDif*0.488f;
+ // start alpha at 244, fade to 10
+ alpha = (float)tDif * 0.488f;
- if (alpha > 244.0f)
- {
+ if (alpha > 244.0f) {
alpha = 244.0f;
- }
- else if (alpha < 10.0f)
- {
+ } else if (alpha < 10.0f) {
alpha = 10.0f;
}
- memset( &ent, 0, sizeof( ent ) );
- ent.shaderTime = (cent->gent->client->pushEffectFadeTime-REFRACT_EFFECT_DURATION) / 1000.0f;
+ memset(&ent, 0, sizeof(ent));
+ ent.shaderTime = (cent->gent->client->pushEffectFadeTime - REFRACT_EFFECT_DURATION) / 1000.0f;
- VectorCopy( cent->gent->client->pushEffectOrigin, ent.origin );
+ VectorCopy(cent->gent->client->pushEffectOrigin, ent.origin);
VectorSubtract(ent.origin, cg.refdef.vieworg, ent.axis[0]);
vLen = VectorLength(ent.axis[0]);
- if (vLen <= 0.1f)
- { // Entity is right on vieworg. quit.
+ if (vLen <= 0.1f) { // Entity is right on vieworg. quit.
return;
}
@@ -4119,21 +3397,14 @@ static void CG_ForcePushRefraction( vec3_t org, centity_t *cent )
AnglesToAxis(ang, ent.axis);
- //radius must be a power of 2, and is the actual captured texture size
- if (vLen < 128)
- {
+ // radius must be a power of 2, and is the actual captured texture size
+ if (vLen < 128) {
ent.radius = 256;
- }
- else if (vLen < 256)
- {
+ } else if (vLen < 256) {
ent.radius = 128;
- }
- else if (vLen < 512)
- {
+ } else if (vLen < 512) {
ent.radius = 64;
- }
- else
- {
+ } else {
ent.radius = 32;
}
@@ -4145,20 +3416,18 @@ static void CG_ForcePushRefraction( vec3_t org, centity_t *cent )
ent.customShader = cgs.media.refractShader;
ent.nonNormalizedAxes = qtrue;
- //make it partially transparent so it blends with the background
- ent.renderfx = (RF_DISTORTION|RF_ALPHA_FADE);
+ // make it partially transparent so it blends with the background
+ ent.renderfx = (RF_DISTORTION | RF_ALPHA_FADE);
ent.shaderRGBA[0] = 255.0f;
ent.shaderRGBA[1] = 255.0f;
ent.shaderRGBA[2] = 255.0f;
ent.shaderRGBA[3] = alpha;
-
- cgi_R_AddRefEntityToScene( &ent );
+ cgi_R_AddRefEntityToScene(&ent);
}
-void CG_ForcePushBlur( const vec3_t org, qboolean darkSide )
-{
- localEntity_t *ex;
+void CG_ForcePushBlur(const vec3_t org, qboolean darkSide) {
+ localEntity_t *ex;
ex = CG_AllocLocalEntity();
ex->leType = LE_PUFF;
@@ -4166,24 +3435,21 @@ void CG_ForcePushBlur( const vec3_t org, qboolean darkSide )
ex->radius = 2.0f;
ex->startTime = cg.time;
ex->endTime = ex->startTime + 120;
- VectorCopy( org, ex->pos.trBase );
+ VectorCopy(org, ex->pos.trBase);
ex->pos.trTime = cg.time;
ex->pos.trType = TR_LINEAR;
- VectorScale( cg.refdef.viewaxis[1], 55, ex->pos.trDelta );
+ VectorScale(cg.refdef.viewaxis[1], 55, ex->pos.trDelta);
- if ( darkSide )
- {//make it red
+ if (darkSide) { // make it red
ex->color[0] = 60;
ex->color[1] = 8;
ex->color[2] = 8;
- }
- else
- {//blue
+ } else { // blue
ex->color[0] = 24;
ex->color[1] = 32;
ex->color[2] = 40;
}
- ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/effects/forcePush" );
+ ex->refEntity.customShader = cgi_R_RegisterShader("gfx/effects/forcePush");
ex = CG_AllocLocalEntity();
ex->leType = LE_PUFF;
@@ -4192,192 +3458,158 @@ void CG_ForcePushBlur( const vec3_t org, qboolean darkSide )
ex->radius = 2.0f;
ex->startTime = cg.time;
ex->endTime = ex->startTime + 120;
- VectorCopy( org, ex->pos.trBase );
+ VectorCopy(org, ex->pos.trBase);
ex->pos.trTime = cg.time;
ex->pos.trType = TR_LINEAR;
- VectorScale( cg.refdef.viewaxis[1], -55, ex->pos.trDelta );
+ VectorScale(cg.refdef.viewaxis[1], -55, ex->pos.trDelta);
- if ( darkSide )
- {//make it red
+ if (darkSide) { // make it red
ex->color[0] = 60;
ex->color[1] = 8;
ex->color[2] = 8;
- }
- else
- {//blue
+ } else { // blue
ex->color[0] = 24;
ex->color[1] = 32;
ex->color[2] = 40;
}
- ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/effects/forcePush" );
+ ex->refEntity.customShader = cgi_R_RegisterShader("gfx/effects/forcePush");
}
-static void CG_ForcePushBodyBlur( centity_t *cent, const vec3_t origin, vec3_t tempAngles )
-{
+static void CG_ForcePushBodyBlur(centity_t *cent, const vec3_t origin, vec3_t tempAngles) {
vec3_t fxOrg;
- mdxaBone_t boltMatrix;
+ mdxaBone_t boltMatrix;
// Head blur
- CG_ForcePushBlur( cent->gent->client->renderInfo.eyePoint );
+ CG_ForcePushBlur(cent->gent->client->renderInfo.eyePoint);
// Do a torso based blur
- if (cent->gent->torsoBolt>=0)
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->torsoBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ if (cent->gent->torsoBolt >= 0) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->torsoBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
- if (cent->gent->handRBolt>=0)
- {
+ if (cent->gent->handRBolt >= 0) {
// Do a right-hand based blur
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handRBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handRBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
- if (cent->gent->handLBolt>=0)
- {
+ if (cent->gent->handLBolt >= 0) {
// Do a left-hand based blur
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handLBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handLBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
// Do the knees
- if (cent->gent->kneeLBolt>=0)
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->kneeLBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ if (cent->gent->kneeLBolt >= 0) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->kneeLBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
- if (cent->gent->kneeRBolt>=0)
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->kneeRBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ if (cent->gent->kneeRBolt >= 0) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->kneeRBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
- if (cent->gent->elbowLBolt>=0)
- {
+ if (cent->gent->elbowLBolt >= 0) {
// Do the elbows
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->elbowLBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->elbowLBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
- if (cent->gent->elbowRBolt>=0)
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->elbowRBolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- CG_ForcePushBlur( fxOrg );
+ if (cent->gent->elbowRBolt >= 0) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->elbowRBolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ CG_ForcePushBlur(fxOrg);
}
}
-static void CG_ForceElectrocution( centity_t *cent, const vec3_t origin, vec3_t tempAngles, qhandle_t shader, qboolean alwaysDo = qfalse )
-{
+static void CG_ForceElectrocution(centity_t *cent, const vec3_t origin, vec3_t tempAngles, qhandle_t shader, qboolean alwaysDo = qfalse) {
// Undoing for now, at least this code should compile if I ( or anyone else ) decides to work on this effect
- qboolean found = qfalse;
- vec3_t fxOrg, fxOrg2, dir;
- vec3_t rgb = {1.0f,1.0f,1.0f};
- mdxaBone_t boltMatrix;
+ qboolean found = qfalse;
+ vec3_t fxOrg, fxOrg2, dir;
+ vec3_t rgb = {1.0f, 1.0f, 1.0f};
+ mdxaBone_t boltMatrix;
- int bolt=-1;
- int iter=0;
+ int bolt = -1;
+ int iter = 0;
// Pick a random start point
- while (bolt<0)
- {
+ while (bolt < 0) {
int test;
- if (iter>5)
- {
- test=iter-5;
- }
- else
- {
- test=Q_irand(0,6);
+ if (iter > 5) {
+ test = iter - 5;
+ } else {
+ test = Q_irand(0, 6);
}
- switch(test)
- {
+ switch (test) {
case 0:
// Right Elbow
- bolt=cent->gent->elbowRBolt;
+ bolt = cent->gent->elbowRBolt;
break;
case 1:
// Left Hand
- bolt=cent->gent->handLBolt;
+ bolt = cent->gent->handLBolt;
break;
case 2:
// Right hand
- bolt=cent->gent->handRBolt;
+ bolt = cent->gent->handRBolt;
break;
case 3:
// Left Foot
- bolt=cent->gent->footLBolt;
+ bolt = cent->gent->footLBolt;
break;
case 4:
// Right foot
- bolt=cent->gent->footRBolt;
+ bolt = cent->gent->footRBolt;
break;
case 5:
// Torso
- bolt=cent->gent->torsoBolt;
+ bolt = cent->gent->torsoBolt;
break;
case 6:
default:
// Left Elbow
- bolt=cent->gent->elbowLBolt;
+ bolt = cent->gent->elbowLBolt;
break;
}
- if (++iter==20)
+ if (++iter == 20)
break;
}
- if (bolt>=0)
- {
- found = gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt,
- &boltMatrix, tempAngles, origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale);
+ if (bolt >= 0) {
+ found = gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, tempAngles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
}
// Make sure that it's safe to even try and get these values out of the Matrix, otherwise the values could be garbage
- if ( found )
- {
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
- if ( Q_flrand(0.0f, 1.0f) > 0.5f )
- {
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_X, dir );
- }
- else
- {
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, dir );
+ if (found) {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
+ if (Q_flrand(0.0f, 1.0f) > 0.5f) {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, dir);
+ } else {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, dir);
}
// Add some fudge, makes us not normalized, but that isn't really important
dir[0] += Q_flrand(-1.0f, 1.0f) * 0.4f;
dir[1] += Q_flrand(-1.0f, 1.0f) * 0.4f;
dir[2] += Q_flrand(-1.0f, 1.0f) * 0.4f;
- }
- else
- {
+ } else {
// Just use the lerp Origin and a random direction
- VectorCopy( cent->lerpOrigin, fxOrg );
- VectorSet( dir, Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f) ); // Not normalized, but who cares.
- if ( cent->gent && cent->gent->client )
- {
- switch ( cent->gent->client->NPC_class )
- {
+ VectorCopy(cent->lerpOrigin, fxOrg);
+ VectorSet(dir, Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f), Q_flrand(-1.0f, 1.0f)); // Not normalized, but who cares.
+ if (cent->gent && cent->gent->client) {
+ switch (cent->gent->client->NPC_class) {
case CLASS_PROBE:
fxOrg[2] += 50;
break;
@@ -4393,33 +3625,24 @@ static void CG_ForceElectrocution( centity_t *cent, const vec3_t origin, vec3_t
}
}
- VectorMA( fxOrg, Q_flrand(0.0f, 1.0f) * 40 + 40, dir, fxOrg2 );
+ VectorMA(fxOrg, Q_flrand(0.0f, 1.0f) * 40 + 40, dir, fxOrg2);
- trace_t tr;
+ trace_t tr;
- CG_Trace( &tr, fxOrg, NULL, NULL, fxOrg2, -1, CONTENTS_SOLID );
+ CG_Trace(&tr, fxOrg, NULL, NULL, fxOrg2, -1, CONTENTS_SOLID);
- if ( tr.fraction < 1.0f || Q_flrand(0.0f, 1.0f) > 0.94f || alwaysDo )
- {
- FX_AddElectricity( -1, fxOrg, tr.endpos,
- 1.5f, 4.0f, 0.0f,
- 1.0f, 0.5f, 0.0f,
- rgb, rgb, 0.0f,
- 5.5f, Q_flrand(0.0f, 1.0f) * 50 + 100, shader, FX_ALPHA_LINEAR | FX_SIZE_LINEAR | FX_BRANCH | FX_GROW | FX_TAPER, -1, -1 );
+ if (tr.fraction < 1.0f || Q_flrand(0.0f, 1.0f) > 0.94f || alwaysDo) {
+ FX_AddElectricity(-1, fxOrg, tr.endpos, 1.5f, 4.0f, 0.0f, 1.0f, 0.5f, 0.0f, rgb, rgb, 0.0f, 5.5f, Q_flrand(0.0f, 1.0f) * 50 + 100, shader,
+ FX_ALPHA_LINEAR | FX_SIZE_LINEAR | FX_BRANCH | FX_GROW | FX_TAPER, -1, -1);
}
}
-static void CG_BoltedEffects( centity_t *cent, const vec3_t origin, vec3_t tempAngles )
-{
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE )
- {
+static void CG_BoltedEffects(centity_t *cent, const vec3_t origin, vec3_t tempAngles) {
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE) {
Vehicle_t *pVeh = cent->gent->m_pVehicle;
gentity_t *parent = cent->gent;
- if (pVeh->m_ulFlags&VEH_ARMORLOW
- && (pVeh->m_iLastFXTime<=cg.time)
- && Q_irand(0,1)==0 )
- {
- pVeh->m_iLastFXTime = cg.time + 50;//Q_irand(50, 100);
+ if (pVeh->m_ulFlags & VEH_ARMORLOW && (pVeh->m_iLastFXTime <= cg.time) && Q_irand(0, 1) == 0) {
+ pVeh->m_iLastFXTime = cg.time + 50; // Q_irand(50, 100);
CG_PlayEffectIDBolted(pVeh->m_pVehicleInfo->iArmorLowFX, parent->playerModel, parent->crotchBolt, parent->s.number, parent->currentOrigin);
}
}
@@ -4432,61 +3655,54 @@ CG_PlayerCanSeeCent
tests force sight level
===============
*/
-qboolean CG_PlayerCanSeeCent( centity_t *cent )
-{//return true if this cent is in view
- //NOTE: this is similar to the func SV_PlayerCanSeeEnt in sv_snapshot
- if ( (cent->currentState.eFlags&EF_FORCE_VISIBLE) )
- {//can always be seen
+qboolean CG_PlayerCanSeeCent(centity_t *cent) { // return true if this cent is in view
+ // NOTE: this is similar to the func SV_PlayerCanSeeEnt in sv_snapshot
+ if ((cent->currentState.eFlags & EF_FORCE_VISIBLE)) { // can always be seen
return qtrue;
}
- if ( g_entities[0].client->ps.forcePowerLevel[FP_SEE] < FORCE_LEVEL_2
- && cent->currentState.eType != ET_PLAYER )
- {//TEST: level 1 only sees force hints and enemies
+ if (g_entities[0].client->ps.forcePowerLevel[FP_SEE] < FORCE_LEVEL_2 &&
+ cent->currentState.eType != ET_PLAYER) { // TEST: level 1 only sees force hints and enemies
return qfalse;
}
- float dot = 0.25f;//1.0f;
+ float dot = 0.25f; // 1.0f;
float range = 512.0f;
- switch ( g_entities[0].client->ps.forcePowerLevel[FP_SEE] )
- {
+ switch (g_entities[0].client->ps.forcePowerLevel[FP_SEE]) {
case FORCE_LEVEL_1:
- //dot = 0.95f;
+ // dot = 0.95f;
range = 1024.0f;
break;
case FORCE_LEVEL_2:
- //dot = 0.7f;
+ // dot = 0.7f;
range = 2048.0f;
break;
case FORCE_LEVEL_3:
case FORCE_LEVEL_4:
case FORCE_LEVEL_5:
- //dot = 0.4f;
+ // dot = 0.4f;
range = 4096.0f;
break;
}
- vec3_t centDir, lookDir;
- VectorSubtract( cent->lerpOrigin, cg.refdef.vieworg, centDir );
- float centDist = VectorNormalize( centDir );
+ vec3_t centDir, lookDir;
+ VectorSubtract(cent->lerpOrigin, cg.refdef.vieworg, centDir);
+ float centDist = VectorNormalize(centDir);
- if ( centDist < 128.0f )
- {//can always see them if they're really close
+ if (centDist < 128.0f) { // can always see them if they're really close
return qtrue;
}
- if ( centDist > range )
- {//too far away to see them
+ if (centDist > range) { // too far away to see them
return qfalse;
}
- dot += (0.99f-dot)*centDist/range;//the farther away they are, the more in front they have to be
+ dot += (0.99f - dot) * centDist / range; // the farther away they are, the more in front they have to be
- AngleVectors( cg.refdefViewAngles, lookDir, NULL, NULL );
+ AngleVectors(cg.refdefViewAngles, lookDir, NULL, NULL);
- if ( DotProduct( centDir, lookDir ) < dot )
- {//not in force sight cone
+ if (DotProduct(centDir, lookDir) < dot) { // not in force sight cone
return qfalse;
}
@@ -4500,23 +3716,20 @@ CG_AddForceSightShell
Adds the special effect
===============
*/
-extern void CG_AddHealthBarEnt( int entNum );
-void CG_AddForceSightShell( refEntity_t *ent, centity_t *cent )
-{
+extern void CG_AddHealthBarEnt(int entNum);
+void CG_AddForceSightShell(refEntity_t *ent, centity_t *cent) {
ent->customShader = cgs.media.forceShell;
ent->renderfx &= ~RF_RGB_TINT;
// See through walls.
- ent->renderfx |= (RF_MORELIGHT|RF_NODEPTH);
+ ent->renderfx |= (RF_MORELIGHT | RF_NODEPTH);
- if ( (cent->currentState.eFlags&EF_FORCE_VISIBLE)
- || (cent->currentState.eType == ET_PLAYER && cent->gent && cent->gent->message) )
- {
+ if ((cent->currentState.eFlags & EF_FORCE_VISIBLE) || (cent->currentState.eType == ET_PLAYER && cent->gent && cent->gent->message)) {
ent->shaderRGBA[0] = 0;
ent->shaderRGBA[1] = 0;
ent->shaderRGBA[2] = 255;
ent->shaderRGBA[3] = 254;
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
return;
}
@@ -4524,59 +3737,46 @@ void CG_AddForceSightShell( refEntity_t *ent, centity_t *cent )
ent->shaderRGBA[1] = 255;
ent->shaderRGBA[2] = 0;
- //if ( g_entities[0].client->ps.forcePowerLevel[FP_SEE] > FORCE_LEVEL_2 )
+ // if ( g_entities[0].client->ps.forcePowerLevel[FP_SEE] > FORCE_LEVEL_2 )
//{TEST: level 3 identifies friend or foe with color
- team_t team = TEAM_NEUTRAL;
- if ( cent->gent && cent->gent->client )
- {
- team = cent->gent->client->playerTeam;
+ team_t team = TEAM_NEUTRAL;
+ if (cent->gent && cent->gent->client) {
+ team = cent->gent->client->playerTeam;
+ } else if (cent->gent && cent->gent->owner) {
+ if (cent->gent->owner->client) {
+ team = cent->gent->owner->client->playerTeam;
+ } else {
+ team = cent->gent->owner->noDamageTeam;
}
- else if ( cent->gent && cent->gent->owner )
- {
- if ( cent->gent->owner->client )
- {
- team = cent->gent->owner->client->playerTeam;
- }
- else
- {
- team = cent->gent->owner->noDamageTeam;
+ }
+ switch (team) {
+ case TEAM_ENEMY:
+ ent->shaderRGBA[0] = 255;
+ ent->shaderRGBA[1] = 0;
+ ent->shaderRGBA[2] = 0;
+ break;
+ case TEAM_PLAYER:
+ ent->shaderRGBA[0] = 0;
+ ent->shaderRGBA[1] = 255;
+ ent->shaderRGBA[2] = 0;
+ break;
+ case TEAM_FREE:
+ if (cent->gent && cent->gent->client) {
+ if (cent->gent->client->NPC_class == CLASS_TUSKEN || cent->gent->client->NPC_class == CLASS_RANCOR ||
+ cent->gent->client->NPC_class == CLASS_WAMPA || cent->gent->client->NPC_class == CLASS_SAND_CREATURE) {
+ ent->shaderRGBA[0] = 255;
+ ent->shaderRGBA[1] = 0;
+ ent->shaderRGBA[2] = 0;
}
}
- switch ( team )
- {
- case TEAM_ENEMY:
- ent->shaderRGBA[0] = 255;
- ent->shaderRGBA[1] = 0;
- ent->shaderRGBA[2] = 0;
- break;
- case TEAM_PLAYER:
- ent->shaderRGBA[0] = 0;
- ent->shaderRGBA[1] = 255;
- ent->shaderRGBA[2] = 0;
- break;
- case TEAM_FREE:
- if ( cent->gent && cent->gent->client )
- {
- if ( cent->gent->client->NPC_class == CLASS_TUSKEN
- || cent->gent->client->NPC_class == CLASS_RANCOR
- || cent->gent->client->NPC_class == CLASS_WAMPA
- || cent->gent->client->NPC_class == CLASS_SAND_CREATURE )
- {
- ent->shaderRGBA[0] = 255;
- ent->shaderRGBA[1] = 0;
- ent->shaderRGBA[2] = 0;
- }
- }
- break;
- default:
- break;
- }
+ break;
+ default:
+ break;
+ }
- if ( g_entities[0].client->ps.forcePowerLevel[FP_SEE] > FORCE_LEVEL_2 )
- {//TEST: level 3 also displays health
- if ( cent->gent && cent->gent->health > 0 && cent->gent->max_health > 0 )
- {//draw a health bar over them
- CG_AddHealthBarEnt( cent->currentState.clientNum );
+ if (g_entities[0].client->ps.forcePowerLevel[FP_SEE] > FORCE_LEVEL_2) { // TEST: level 3 also displays health
+ if (cent->gent && cent->gent->health > 0 && cent->gent->max_health > 0) { // draw a health bar over them
+ CG_AddHealthBarEnt(cent->currentState.clientNum);
}
}
@@ -4587,9 +3787,9 @@ void CG_AddForceSightShell( refEntity_t *ent, centity_t *cent )
}
*/
- //FIXME: make it darker or more translucent the further away it is?
+ // FIXME: make it darker or more translucent the further away it is?
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
}
/*
@@ -4599,90 +3799,78 @@ CG_AddRefEntityWithPowerups
Adds a piece with modifications or duplications for powerups
===============
*/
-void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cent )
-{
- if ( !cent )
- {
- cgi_R_AddRefEntityToScene( ent );
+void CG_AddRefEntityWithPowerups(refEntity_t *ent, int powerups, centity_t *cent) {
+ if (!cent) {
+ cgi_R_AddRefEntityToScene(ent);
return;
}
- gentity_t *gent = cent->gent;
- if ( !gent )
- {
- cgi_R_AddRefEntityToScene( ent );
+ gentity_t *gent = cent->gent;
+ if (!gent) {
+ cgi_R_AddRefEntityToScene(ent);
return;
}
- if ( gent->client->ps.powerups[PW_DISRUPTION] < cg.time )
- {//disruptor
- if (( powerups & ( 1 << PW_DISRUPTION )))
- {
- //stop drawing him after this effect
+ if (gent->client->ps.powerups[PW_DISRUPTION] < cg.time) { // disruptor
+ if ((powerups & (1 << PW_DISRUPTION))) {
+ // stop drawing him after this effect
gent->client->ps.eFlags |= EF_NODRAW;
return;
}
}
-// if ( gent->client->ps.powerups[PW_WEAPON_OVERCHARGE] > 0 )
-// {
-// centity_t *cent = &cg_entities[gent->s.number];
-// cgi_S_AddLoopingSound( 0, cent->lerpOrigin, vec3_origin, cgs.media.overchargeLoopSound );
-// }
+ // if ( gent->client->ps.powerups[PW_WEAPON_OVERCHARGE] > 0 )
+ // {
+ // centity_t *cent = &cg_entities[gent->s.number];
+ // cgi_S_AddLoopingSound( 0, cent->lerpOrigin, vec3_origin, cgs.media.overchargeLoopSound );
+ // }
- //get the dude's color choice in
+ // get the dude's color choice in
ent->shaderRGBA[0] = gent->client->renderInfo.customRGBA[0];
ent->shaderRGBA[1] = gent->client->renderInfo.customRGBA[1];
ent->shaderRGBA[2] = gent->client->renderInfo.customRGBA[2];
ent->shaderRGBA[3] = gent->client->renderInfo.customRGBA[3];
// If certain states are active, we don't want to add in the regular body
- if ( !gent->client->ps.powerups[PW_CLOAKED] &&
- !gent->client->ps.powerups[PW_UNCLOAKING] &&
- !gent->client->ps.powerups[PW_DISRUPTION] )
- {
- cgi_R_AddRefEntityToScene( ent );
+ if (!gent->client->ps.powerups[PW_CLOAKED] && !gent->client->ps.powerups[PW_UNCLOAKING] && !gent->client->ps.powerups[PW_DISRUPTION]) {
+ cgi_R_AddRefEntityToScene(ent);
}
// Disruptor Gun Alt-fire
- if ( gent->client->ps.powerups[PW_DISRUPTION] )
- {
+ if (gent->client->ps.powerups[PW_DISRUPTION]) {
// I guess when something dies, it looks like pos1 gets set to the impact point on death, we can do fun stuff with this
vec3_t tempAng;
- VectorSubtract( gent->pos1, ent->origin, ent->oldorigin );
- //er, adjust this to get the proper position in model space... account for yaw
- float tempLength = VectorNormalize( ent->oldorigin );
- vectoangles( ent->oldorigin, tempAng );
+ VectorSubtract(gent->pos1, ent->origin, ent->oldorigin);
+ // er, adjust this to get the proper position in model space... account for yaw
+ float tempLength = VectorNormalize(ent->oldorigin);
+ vectoangles(ent->oldorigin, tempAng);
tempAng[YAW] -= gent->client->ps.viewangles[YAW];
- AngleVectors( tempAng, ent->oldorigin, NULL, NULL );
- VectorScale( ent->oldorigin, tempLength, ent->oldorigin );
+ AngleVectors(tempAng, ent->oldorigin, NULL, NULL);
+ VectorScale(ent->oldorigin, tempLength, ent->oldorigin);
ent->endTime = gent->fx_time;
ent->renderfx |= (RF_DISINTEGRATE2);
- ent->customShader = cgi_R_RegisterShader( "gfx/effects/burn" );
- cgi_R_AddRefEntityToScene( ent );
+ ent->customShader = cgi_R_RegisterShader("gfx/effects/burn");
+ cgi_R_AddRefEntityToScene(ent);
ent->renderfx &= ~(RF_DISINTEGRATE2);
ent->renderfx |= (RF_DISINTEGRATE1);
ent->customShader = 0;
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
- if ( cg.time - ent->endTime < 1000 && (cg_timescale.value * cg_timescale.value * Q_flrand(0.0f, 1.0f)) > 0.05f )
- {
+ if (cg.time - ent->endTime < 1000 && (cg_timescale.value * cg_timescale.value * Q_flrand(0.0f, 1.0f)) > 0.05f) {
vec3_t fxOrg;
- mdxaBone_t boltMatrix;
+ mdxaBone_t boltMatrix;
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, gent->playerModel, gent->torsoBolt,
- &boltMatrix, gent->currentAngles, ent->origin, cg.time,
- cgs.model_draw, gent->s.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, fxOrg );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, gent->playerModel, gent->torsoBolt, &boltMatrix, gent->currentAngles, ent->origin, cg.time,
+ cgs.model_draw, gent->s.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, fxOrg);
- VectorMA( fxOrg, -18, cg.refdef.viewaxis[0], fxOrg );
+ VectorMA(fxOrg, -18, cg.refdef.viewaxis[0], fxOrg);
fxOrg[2] += Q_flrand(-1.0f, 1.0f) * 20;
- theFxScheduler.PlayEffect( "disruptor/death_smoke", fxOrg );
+ theFxScheduler.PlayEffect("disruptor/death_smoke", fxOrg);
- if ( Q_flrand(0.0f, 1.0f) > 0.5f )
- {
- theFxScheduler.PlayEffect( "disruptor/death_smoke", fxOrg );
+ if (Q_flrand(0.0f, 1.0f) > 0.5f) {
+ theFxScheduler.PlayEffect("disruptor/death_smoke", fxOrg);
}
}
}
@@ -4690,135 +3878,108 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
// Cloaking & Uncloaking Technology
//----------------------------------------
- if (( powerups & ( 1 << PW_UNCLOAKING )))
- {//in the middle of cloaking
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && CG_PlayerCanSeeCent( cent ))
- {//just draw him
- cgi_R_AddRefEntityToScene( ent );
- }
- else
- {
+ if ((powerups & (1 << PW_UNCLOAKING))) { // in the middle of cloaking
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number &&
+ CG_PlayerCanSeeCent(cent)) { // just draw him
+ cgi_R_AddRefEntityToScene(ent);
+ } else {
float perc = (float)(gent->client->ps.powerups[PW_UNCLOAKING] - cg.time) / 2000.0f;
- if (( powerups & ( 1 << PW_CLOAKED )))
- {//actually cloaking, so reverse it
+ if ((powerups & (1 << PW_CLOAKED))) { // actually cloaking, so reverse it
perc = 1.0f - perc;
}
- if ( perc >= 0.0f && perc <= 1.0f )
- {
+ if (perc >= 0.0f && perc <= 1.0f) {
ent->renderfx &= ~RF_ALPHA_FADE;
ent->renderfx |= RF_RGB_TINT;
ent->shaderRGBA[0] = ent->shaderRGBA[1] = ent->shaderRGBA[2] = 255.0f * perc;
ent->shaderRGBA[3] = 0;
ent->customShader = cgs.media.cloakedShader;
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
ent->shaderRGBA[0] = ent->shaderRGBA[1] = ent->shaderRGBA[2] = 255;
ent->shaderRGBA[3] = 255 * (1.0f - perc); // let model alpha in
- ent->customShader = 0; // use regular skin
+ ent->customShader = 0; // use regular skin
ent->renderfx &= ~RF_RGB_TINT;
ent->renderfx |= RF_ALPHA_FADE;
- cgi_R_AddRefEntityToScene( ent );
- }
- }
- }
- else if (( powerups & ( 1 << PW_CLOAKED )))
- {//fully cloaked
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && CG_PlayerCanSeeCent( cent ))
- {//just draw him
- cgi_R_AddRefEntityToScene( ent );
- }
- else
- {
- if (cg_renderToTextureFX.integer && cg_shadows.integer != 2 && cgs.glconfig.stencilBits >= 4)
- {
- cgi_R_SetRefractProp(1.0f, 0.0f, qfalse, qfalse); //don't need to do this every frame.. but..
- ent->customShader = 2; //crazy "refractive" shader
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
+ }
+ }
+ } else if ((powerups & (1 << PW_CLOAKED))) { // fully cloaked
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number &&
+ CG_PlayerCanSeeCent(cent)) { // just draw him
+ cgi_R_AddRefEntityToScene(ent);
+ } else {
+ if (cg_renderToTextureFX.integer && cg_shadows.integer != 2 && cgs.glconfig.stencilBits >= 4) {
+ cgi_R_SetRefractProp(1.0f, 0.0f, qfalse, qfalse); // don't need to do this every frame.. but..
+ ent->customShader = 2; // crazy "refractive" shader
+ cgi_R_AddRefEntityToScene(ent);
ent->customShader = 0;
- }
- else
- { //stencil buffer's in use, sorry
- ent->renderfx = 0;//&= ~(RF_RGB_TINT|RF_ALPHA_FADE);
+ } else { // stencil buffer's in use, sorry
+ ent->renderfx = 0; //&= ~(RF_RGB_TINT|RF_ALPHA_FADE);
ent->shaderRGBA[0] = ent->shaderRGBA[1] = ent->shaderRGBA[2] = ent->shaderRGBA[3] = 255;
ent->customShader = cgs.media.cloakedShader;
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
}
}
}
// Electricity
//------------------------------------------------
- if ( (powerups & ( 1 << PW_SHOCKED )) )
- {
- int dif = gent->client->ps.powerups[PW_SHOCKED] - cg.time;
+ if ((powerups & (1 << PW_SHOCKED))) {
+ int dif = gent->client->ps.powerups[PW_SHOCKED] - cg.time;
- if ( dif > 0 && Q_flrand(0.0f, 1.0f) > 0.4f )
- {
+ if (dif > 0 && Q_flrand(0.0f, 1.0f) > 0.4f) {
// fade out over the last 500 ms
int brightness = 255;
- if ( dif < 500 )
- {
- brightness = floor((dif - 500.0f) / 500.0f * 255.0f );
+ if (dif < 500) {
+ brightness = floor((dif - 500.0f) / 500.0f * 255.0f);
}
ent->renderfx |= RF_RGB_TINT;
ent->shaderRGBA[0] = ent->shaderRGBA[1] = ent->shaderRGBA[2] = brightness;
ent->shaderRGBA[3] = 255;
- if ( rand() & 1 )
- {
+ if (rand() & 1) {
ent->customShader = cgs.media.electricBodyShader;
- }
- else
- {
+ } else {
ent->customShader = cgs.media.electricBody2Shader;
}
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
- if ( Q_flrand(0.0f, 1.0f) > 0.9f )
- cgi_S_StartSound ( ent->origin, gent->s.number, CHAN_AUTO, cgi_S_RegisterSound( "sound/effects/energy_crackle.wav" ) );
+ if (Q_flrand(0.0f, 1.0f) > 0.9f)
+ cgi_S_StartSound(ent->origin, gent->s.number, CHAN_AUTO, cgi_S_RegisterSound("sound/effects/energy_crackle.wav"));
}
}
// FORCE speed does blur trails
//------------------------------------------------------
- if ( cg_speedTrail.integer
- && (gent->client->ps.forcePowersActive & (1 << FP_SPEED) //in force speed
- || cent->gent->client->ps.legsAnim == BOTH_FORCELONGLEAP_START//or force long jump - FIXME: only 1st half of that anim?
- || cent->gent->client->ps.legsAnim == BOTH_FORCELONGLEAP_ATTACK )//or force long jump attack
- && (gent->s.number || cg.renderingThirdPerson) ) // looks dumb doing this with first peron mode on
+ if (cg_speedTrail.integer &&
+ (gent->client->ps.forcePowersActive & (1 << FP_SPEED) // in force speed
+ || cent->gent->client->ps.legsAnim == BOTH_FORCELONGLEAP_START // or force long jump - FIXME: only 1st half of that anim?
+ || cent->gent->client->ps.legsAnim == BOTH_FORCELONGLEAP_ATTACK) // or force long jump attack
+ && (gent->s.number || cg.renderingThirdPerson)) // looks dumb doing this with first peron mode on
{
- //FIXME: debounce this
- localEntity_t *ex;
+ // FIXME: debounce this
+ localEntity_t *ex;
ex = CG_AllocLocalEntity();
ex->leType = LE_FADE_MODEL;
- memcpy( &ex->refEntity, ent, sizeof( refEntity_t ));
+ memcpy(&ex->refEntity, ent, sizeof(refEntity_t));
- ex->refEntity.renderfx |= (RF_ALPHA_FADE | RF_NOSHADOW | RF_G2MINLOD ) ;
- //ex->refEntity.renderfx |= RF_ALPHA_FADE;
+ ex->refEntity.renderfx |= (RF_ALPHA_FADE | RF_NOSHADOW | RF_G2MINLOD);
+ // ex->refEntity.renderfx |= RF_ALPHA_FADE;
ex->startTime = cg.time;
ex->endTime = ex->startTime + 75;
- VectorCopy( ex->refEntity.origin, ex->pos.trBase );
- VectorClear( ex->pos.trDelta );
+ VectorCopy(ex->refEntity.origin, ex->pos.trBase);
+ VectorClear(ex->pos.trDelta);
- if ( gent->client->renderInfo.customRGBA[0]
- || gent->client->renderInfo.customRGBA[1]
- || gent->client->renderInfo.customRGBA[2] )
- {
+ if (gent->client->renderInfo.customRGBA[0] || gent->client->renderInfo.customRGBA[1] || gent->client->renderInfo.customRGBA[2]) {
ex->color[0] = gent->client->renderInfo.customRGBA[0];
ex->color[1] = gent->client->renderInfo.customRGBA[1];
ex->color[2] = gent->client->renderInfo.customRGBA[2];
- }
- else
- {
+ } else {
ex->color[0] = ex->color[1] = ex->color[2] = 255.0f;
}
ex->color[3] = 50.0f;
@@ -4826,63 +3987,58 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
// Personal Shields
//------------------------
- if ( powerups & ( 1 << PW_BATTLESUIT ))
- {
+ if (powerups & (1 << PW_BATTLESUIT)) {
float diff = gent->client->ps.powerups[PW_BATTLESUIT] - cg.time;
float t;
- if ( diff > 0 )
- {
- t = 1.0f - ( diff / (ARMOR_EFFECT_TIME * 2.0f));
+ if (diff > 0) {
+ t = 1.0f - (diff / (ARMOR_EFFECT_TIME * 2.0f));
// Only display when we have damage
- if ( t < 0.0f || t > 1.0f )
- {
- }
- else
- {
+ if (t < 0.0f || t > 1.0f) {
+ } else {
ent->shaderRGBA[0] = ent->shaderRGBA[1] = ent->shaderRGBA[2] = 255.0f * t;
ent->shaderRGBA[3] = 255;
ent->renderfx &= ~RF_ALPHA_FADE;
ent->renderfx |= RF_RGB_TINT;
ent->customShader = cgs.media.personalShieldShader;
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
}
}
}
// Galak Mech shield bubble
//------------------------------------------------------
- if ( powerups & ( 1 << PW_GALAK_SHIELD ))
- {
-/* refEntity_t tent;
+ if (powerups & (1 << PW_GALAK_SHIELD)) {
+ /* refEntity_t tent;
- memset( &tent, 0, sizeof( refEntity_t ));
+ memset( &tent, 0, sizeof( refEntity_t ));
- tent.reType = RT_LATHE;
+ tent.reType = RT_LATHE;
- // Setting up the 2d control points, these get swept around to make a 3D lathed model
- VectorSet2( tent.axis[0], 0.5, 0 ); // start point of curve
- VectorSet2( tent.axis[1], 50, 85 ); // control point 1
- VectorSet2( tent.axis[2], 135, -100 ); // control point 2
- VectorSet2( tent.oldorigin, 0, -90 ); // end point of curve
+ // Setting up the 2d control points, these get swept around to make a 3D lathed model
+ VectorSet2( tent.axis[0], 0.5, 0 ); // start point of curve
+ VectorSet2( tent.axis[1], 50, 85 ); // control point 1
+ VectorSet2( tent.axis[2], 135, -100 ); // control point 2
+ VectorSet2( tent.oldorigin, 0, -90 ); // end point of curve
- if ( gent->client->poisonTime && gent->client->poisonTime + 1000 > cg.time )
- {
- VectorCopy( gent->pos4, tent.lightingOrigin );
- tent.frame = gent->client->poisonTime;
- }
+ if ( gent->client->poisonTime && gent->client->poisonTime + 1000 > cg.time )
+ {
+ VectorCopy( gent->pos4, tent.lightingOrigin );
+ tent.frame = gent->client->poisonTime;
+ }
- mdxaBone_t boltMatrix;
- vec3_t angles = {0,gent->client->ps.legsYaw,0};
+ mdxaBone_t boltMatrix;
+ vec3_t angles = {0,gent->client->ps.legsYaw,0};
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, gent->playerModel, gent->genericBolt1, &boltMatrix, angles, cent->lerpOrigin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, tent.origin );// pass in the emitter origin here
+ gi.G2API_GetBoltMatrix( cent->gent->ghoul2, gent->playerModel, gent->genericBolt1, &boltMatrix, angles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale ); gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, tent.origin );// pass in the emitter origin
+ here
- tent.endTime = gent->fx_time + 1000; // if you want the shell to build around the guy, pass in a time that is 1000ms after the start of the turn-on-effect
- tent.customShader = cgi_R_RegisterShader( "gfx/effects/irid_shield" );
+ tent.endTime = gent->fx_time + 1000; // if you want the shell to build around the guy, pass in a time that is 1000ms after the start
+ of the turn-on-effect tent.customShader = cgi_R_RegisterShader( "gfx/effects/irid_shield" );
- cgi_R_AddRefEntityToScene( &tent );*/
+ cgi_R_AddRefEntityToScene( &tent );*/
}
// Invincibility -- effect needs work
@@ -4896,192 +4052,155 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
// Healing -- could use some work....maybe also make it NOT be framerate dependant
//------------------------------------------------------
-/* if ( powerups & ( 1 << PW_HEALING ))
- {
- vec3_t axis[3];
+ /* if ( powerups & ( 1 << PW_HEALING ))
+ {
+ vec3_t axis[3];
- AngleVectors( cent->gent->client->renderInfo.eyeAngles, axis[0], axis[1], axis[2] );
+ AngleVectors( cent->gent->client->renderInfo.eyeAngles, axis[0], axis[1], axis[2] );
- theFxScheduler.PlayEffect( cgs.effects.forceHeal, cent->gent->client->renderInfo.eyePoint, axis );
- }
-*/
+ theFxScheduler.PlayEffect( cgs.effects.forceHeal, cent->gent->client->renderInfo.eyePoint, axis );
+ }
+ */
// Push Blur
- if ( gent->forcePushTime > cg.time && gi.G2API_HaveWeGhoul2Models( cent->gent->ghoul2 ) )
- {
- CG_ForcePushBlur( ent->origin );
+ if (gent->forcePushTime > cg.time && gi.G2API_HaveWeGhoul2Models(cent->gent->ghoul2)) {
+ CG_ForcePushBlur(ent->origin);
}
- //new Jedi Academy force powers
- //Rage effect
- if ((cent->gent->client->ps.forcePowersActive & (1 << FP_RAGE)) &&
- (cg.renderingThirdPerson || cent->currentState.number != cg.snap->ps.clientNum))
- {
- //ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
- //ent->renderfx &= ~RF_MINLIGHT;
+ // new Jedi Academy force powers
+ // Rage effect
+ if ((cent->gent->client->ps.forcePowersActive & (1 << FP_RAGE)) && (cg.renderingThirdPerson || cent->currentState.number != cg.snap->ps.clientNum)) {
+ // ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
+ // ent->renderfx &= ~RF_MINLIGHT;
ent->renderfx |= RF_RGB_TINT;
ent->shaderRGBA[0] = 255;
ent->shaderRGBA[1] = ent->shaderRGBA[2] = 0;
ent->shaderRGBA[3] = 255;
- if ( rand() & 1 )
- {
+ if (rand() & 1) {
ent->customShader = cgs.media.electricBodyShader;
- }
- else
- {
+ } else {
ent->customShader = cgs.media.electricBody2Shader;
}
- cgi_R_AddRefEntityToScene( ent);
+ cgi_R_AddRefEntityToScene(ent);
}
- //FIXME: Tavion possessed effect? White?
- //For now, these two are using the old shield shader. This is just so that you
- //can tell it apart from the JM/duel shaders, but it's still very obvious.
- if ( (cent->gent->client->ps.forcePowersActive & (1 << FP_PROTECT))
- && (cent->gent->client->ps.forcePowersActive & (1 << FP_ABSORB)) )
- {//using both at once, save ourselves some rendering
- //protect+absorb is represented by cyan..
+ // FIXME: Tavion possessed effect? White?
+ // For now, these two are using the old shield shader. This is just so that you
+ // can tell it apart from the JM/duel shaders, but it's still very obvious.
+ if ((cent->gent->client->ps.forcePowersActive & (1 << FP_PROTECT)) &&
+ (cent->gent->client->ps.forcePowersActive & (1 << FP_ABSORB))) { // using both at once, save ourselves some rendering
+ // protect+absorb is represented by cyan..
ent->shaderRGBA[0] = 0;
ent->shaderRGBA[1] = 255;
ent->shaderRGBA[2] = 255;
ent->shaderRGBA[3] = 254;
ent->renderfx &= ~RF_RGB_TINT;
- //ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
- if ( cent->gent->client->ps.forcePowerLevel[FP_PROTECT] > FORCE_LEVEL_1
- || cent->gent->client->ps.forcePowerLevel[FP_ABSORB] > FORCE_LEVEL_1 )
- {
+ // ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
+ if (cent->gent->client->ps.forcePowerLevel[FP_PROTECT] > FORCE_LEVEL_1 || cent->gent->client->ps.forcePowerLevel[FP_ABSORB] > FORCE_LEVEL_1) {
ent->customShader = cgs.media.forceShell;
- }
- else
- {
+ } else {
ent->customShader = cgs.media.playerShieldDamage;
}
- cgi_R_AddRefEntityToScene( ent );
- }
- else if ( cent->gent->client->ps.forcePowersActive & (1 << FP_PROTECT) )
- { //protect is represented by green..
+ cgi_R_AddRefEntityToScene(ent);
+ } else if (cent->gent->client->ps.forcePowersActive & (1 << FP_PROTECT)) { // protect is represented by green..
ent->shaderRGBA[0] = 0;
ent->shaderRGBA[1] = 255;
ent->shaderRGBA[2] = 0;
ent->shaderRGBA[3] = 254;
ent->renderfx &= ~RF_RGB_TINT;
- //ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
- if ( cent->gent->client->ps.forcePowerLevel[FP_PROTECT] > FORCE_LEVEL_1 )
- {
+ // ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
+ if (cent->gent->client->ps.forcePowerLevel[FP_PROTECT] > FORCE_LEVEL_1) {
ent->customShader = cgs.media.forceShell;
- }
- else
- {
+ } else {
ent->customShader = cgs.media.playerShieldDamage;
}
- cgi_R_AddRefEntityToScene( ent );
- }
- else if ( cent->gent->client->ps.forcePowersActive & (1 << FP_ABSORB))
- { //absorb is represented by blue..
+ cgi_R_AddRefEntityToScene(ent);
+ } else if (cent->gent->client->ps.forcePowersActive & (1 << FP_ABSORB)) { // absorb is represented by blue..
ent->shaderRGBA[0] = 0;
ent->shaderRGBA[1] = 0;
ent->shaderRGBA[2] = 255;
ent->shaderRGBA[3] = 254;
ent->renderfx &= ~RF_RGB_TINT;
- //ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
- if ( cent->gent->client->ps.forcePowerLevel[FP_ABSORB] > FORCE_LEVEL_1 )
- {
+ // ent->renderfx &= ~RF_FORCE_ENT_ALPHA;
+ if (cent->gent->client->ps.forcePowerLevel[FP_ABSORB] > FORCE_LEVEL_1) {
ent->customShader = cgs.media.forceShell;
- }
- else
- {
+ } else {
ent->customShader = cgs.media.playerShieldDamage;
}
- cgi_R_AddRefEntityToScene( ent );
+ cgi_R_AddRefEntityToScene(ent);
}
- if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE))
- && cg.snap->ps.clientNum != cent->currentState.number
- && (cent->currentState.eFlags&EF_FORCE_VISIBLE
- || ((cent->gent->health > 0 || cent->gent->message )
- && cent->currentState.eType == ET_PLAYER//other things handle this in their own render funcs
- && CG_PlayerCanSeeCent( cent ))
- )
- )
- {//force sight draws auras around living things
- CG_AddForceSightShell( ent, cent );
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SEE)) && cg.snap->ps.clientNum != cent->currentState.number &&
+ (cent->currentState.eFlags & EF_FORCE_VISIBLE ||
+ ((cent->gent->health > 0 || cent->gent->message) && cent->currentState.eType == ET_PLAYER // other things handle this in their own render funcs
+ && CG_PlayerCanSeeCent(cent)))) { // force sight draws auras around living things
+ CG_AddForceSightShell(ent, cent);
}
- //temp stuff for drain
- if ( ( (cent->gent->client->ps.eFlags&EF_FORCE_DRAINED) || cent->gent->client->ps.forcePowersActive&(1<currentState.number != cg.snap->ps.clientNum))
- {//draining or being drained
+ // temp stuff for drain
+ if (((cent->gent->client->ps.eFlags & EF_FORCE_DRAINED) || cent->gent->client->ps.forcePowersActive & (1 << FP_DRAIN)) &&
+ (cg.renderingThirdPerson || cent->currentState.number != cg.snap->ps.clientNum)) { // draining or being drained
ent->renderfx |= RF_RGB_TINT;
ent->shaderRGBA[0] = 255;
ent->shaderRGBA[1] = ent->shaderRGBA[2] = 0;
ent->shaderRGBA[3] = 255;
- if ( rand() & 1 )
- {
+ if (rand() & 1) {
ent->customShader = cgs.media.electricBodyShader;
- }
- else
- {
+ } else {
ent->customShader = cgs.media.electricBody2Shader;
}
- cgi_R_AddRefEntityToScene( ent);
+ cgi_R_AddRefEntityToScene(ent);
}
}
-
/*
-------------------------
CG_G2SetHeadBlink
-------------------------
*/
-static void CG_G2SetHeadBlink( centity_t *cent, qboolean bStart )
-{
- if ( !cent )
- {
+static void CG_G2SetHeadBlink(centity_t *cent, qboolean bStart) {
+ if (!cent) {
return;
}
gentity_t *gent = cent->gent;
- //FIXME: get these boneIndices game-side and pass it down?
- //FIXME: need a version of this that *doesn't* need the mFileName in the ghoul2
- const int hLeye = gi.G2API_GetBoneIndex( &gent->ghoul2[0], "leye", qtrue );
- if (hLeye == -1)
- {
+ // FIXME: get these boneIndices game-side and pass it down?
+ // FIXME: need a version of this that *doesn't* need the mFileName in the ghoul2
+ const int hLeye = gi.G2API_GetBoneIndex(&gent->ghoul2[0], "leye", qtrue);
+ if (hLeye == -1) {
return;
}
- vec3_t desiredAngles = {0};
+ vec3_t desiredAngles = {0};
int blendTime = 80;
qboolean bWink = qfalse;
- if (bStart)
- {
+ if (bStart) {
desiredAngles[YAW] = -38;
- if ( !in_camera && Q_flrand(0.0f, 1.0f) > 0.95f )
- {
+ if (!in_camera && Q_flrand(0.0f, 1.0f) > 0.95f) {
bWink = qtrue;
- blendTime /=3;
+ blendTime /= 3;
}
}
- gi.G2API_SetBoneAnglesIndex( &gent->ghoul2[gent->playerModel], hLeye, desiredAngles,
- BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, blendTime, cg.time );
- const int hReye = gi.G2API_GetBoneIndex( &gent->ghoul2[0], "reye", qtrue );
- if (hReye == -1)
- {
+ gi.G2API_SetBoneAnglesIndex(&gent->ghoul2[gent->playerModel], hLeye, desiredAngles, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL,
+ blendTime, cg.time);
+ const int hReye = gi.G2API_GetBoneIndex(&gent->ghoul2[0], "reye", qtrue);
+ if (hReye == -1) {
return;
}
if (!bWink)
- gi.G2API_SetBoneAnglesIndex( &gent->ghoul2[gent->playerModel], hReye, desiredAngles,
- BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, blendTime, cg.time );
+ gi.G2API_SetBoneAnglesIndex(&gent->ghoul2[gent->playerModel], hReye, desiredAngles, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL,
+ blendTime, cg.time);
}
/*
@@ -5089,145 +4208,114 @@ static void CG_G2SetHeadBlink( centity_t *cent, qboolean bStart )
CG_G2SetHeadAnims
-------------------------
*/
-static void CG_G2SetHeadAnim( centity_t *cent, int anim )
-{
- gentity_t *gent = cent->gent;
+static void CG_G2SetHeadAnim(centity_t *cent, int anim) {
+ gentity_t *gent = cent->gent;
const int blendTime = 50;
const animation_t *animations = level.knownAnimFileSets[gent->client->clientInfo.animFileIndex].animations;
- int animFlags = BONE_ANIM_OVERRIDE ;//| BONE_ANIM_BLEND;
+ int animFlags = BONE_ANIM_OVERRIDE; //| BONE_ANIM_BLEND;
// animSpeed is 1.0 if the frameLerp (ms/frame) is 50 (20 fps).
-// float timeScaleMod = (cg_timescale.value&&gent&&gent->s.clientNum==0&&!player_locked&&!MatrixMode&&gent->client->ps.forcePowersActive&(1<s.clientNum==0&&!player_locked&&!MatrixMode&&gent->client->ps.forcePowersActive&(1<ghoul2[gent->playerModel], cent->gent->faceBone, &startFrame, &endFrame);
+ // int startFrame, endFrame;
+ // const qboolean animatingHead = gi.G2API_GetAnimRangeIndex(&gent->ghoul2[gent->playerModel], cent->gent->faceBone, &startFrame, &endFrame);
-// if (!animatingHead || ( animations[anim].firstFrame != startFrame ) )// only set the anim if we aren't going to do the same animation again
- {
- gi.G2API_SetBoneAnimIndex(&gent->ghoul2[gent->playerModel], cent->gent->faceBone,
- firstFrame, lastFrame, animFlags, animSpeed, cg.time, -1, blendTime);
- }
+ // if (!animatingHead || ( animations[anim].firstFrame != startFrame ) )// only set the anim if we aren't going to do the same animation again
+ { gi.G2API_SetBoneAnimIndex(&gent->ghoul2[gent->playerModel], cent->gent->faceBone, firstFrame, lastFrame, animFlags, animSpeed, cg.time, -1, blendTime); }
}
-static qboolean CG_G2PlayerHeadAnims( centity_t *cent )
-{
- if(!ValidAnimFileIndex(cent->gent->client->clientInfo.animFileIndex))
- {
+static qboolean CG_G2PlayerHeadAnims(centity_t *cent) {
+ if (!ValidAnimFileIndex(cent->gent->client->clientInfo.animFileIndex)) {
return qfalse;
}
- if (cent->gent->faceBone == BONE_INDEX_INVALID)
- { // i don't have a face
+ if (cent->gent->faceBone == BONE_INDEX_INVALID) { // i don't have a face
return qfalse;
}
int anim = -1;
- if ( cent->gent->health <= 0 )
- {//Dead people close their eyes and don't make faces!
+ if (cent->gent->health <= 0) { // Dead people close their eyes and don't make faces!
anim = FACE_DEAD;
- }
- else
- {
- if (!cent->gent->client->facial_blink)
- { // set the timers
+ } else {
+ if (!cent->gent->client->facial_blink) { // set the timers
cent->gent->client->facial_blink = cg.time + Q_flrand(4000.0, 8000.0);
cent->gent->client->facial_timer = cg.time + Q_flrand(6000.0, 10000.0);
}
- //are we blinking?
- if (cent->gent->client->facial_blink < 0)
- { // yes, check if we are we done blinking ?
- if (-(cent->gent->client->facial_blink) < cg.time)
- { // yes, so reset blink timer
+ // are we blinking?
+ if (cent->gent->client->facial_blink < 0) { // yes, check if we are we done blinking ?
+ if (-(cent->gent->client->facial_blink) < cg.time) { // yes, so reset blink timer
cent->gent->client->facial_blink = cg.time + Q_flrand(4000.0, 8000.0);
- CG_G2SetHeadBlink( cent, qfalse ); //stop the blink
+ CG_G2SetHeadBlink(cent, qfalse); // stop the blink
}
- }
- else // no we aren't blinking
+ } else // no we aren't blinking
{
- if (cent->gent->client->facial_blink < cg.time)// but should we start ?
+ if (cent->gent->client->facial_blink < cg.time) // but should we start ?
{
- CG_G2SetHeadBlink( cent, qtrue );
- if (cent->gent->client->facial_blink == 1)
- {//requested to stay shut by SET_FACEEYESCLOSED
- cent->gent->client->facial_blink = -(cg.time + 99999999.0f);// set blink timer
- }
- else
- {
- cent->gent->client->facial_blink = -(cg.time + 300.0f);// set blink timer
+ CG_G2SetHeadBlink(cent, qtrue);
+ if (cent->gent->client->facial_blink == 1) { // requested to stay shut by SET_FACEEYESCLOSED
+ cent->gent->client->facial_blink = -(cg.time + 99999999.0f); // set blink timer
+ } else {
+ cent->gent->client->facial_blink = -(cg.time + 300.0f); // set blink timer
}
}
}
-
- if (gi.VoiceVolume[cent->gent->s.clientNum] > 0) // if we aren't talking, then it will be 0, -1 for talking but paused
+ if (gi.VoiceVolume[cent->gent->s.clientNum] > 0) // if we aren't talking, then it will be 0, -1 for talking but paused
{
- anim = FACE_TALK1 + gi.VoiceVolume[cent->gent->s.clientNum] -1;
+ anim = FACE_TALK1 + gi.VoiceVolume[cent->gent->s.clientNum] - 1;
cent->gent->client->facial_timer = cg.time + Q_flrand(2000.0, 7000.0);
- if ( cent->gent->client->breathPuffTime > cg.time + 300 )
- {//when talking, do breath puff
+ if (cent->gent->client->breathPuffTime > cg.time + 300) { // when talking, do breath puff
cent->gent->client->breathPuffTime = cg.time;
}
- }
- else if (gi.VoiceVolume[cent->gent->s.clientNum] == -1 )
- {//talking but silent
+ } else if (gi.VoiceVolume[cent->gent->s.clientNum] == -1) { // talking but silent
anim = FACE_TALK0;
cent->gent->client->facial_timer = cg.time + Q_flrand(2000.0, 7000.0);
- }
- else if (gi.VoiceVolume[cent->gent->s.clientNum] == 0) //don't do aux if in a slient part of speech
- {//not talking
- if (cent->gent->client->facial_timer < 0) // are we auxing ?
- { //yes
- if (-(cent->gent->client->facial_timer) < cg.time)// are we done auxing ?
- { // yes, reset aux timer
+ } else if (gi.VoiceVolume[cent->gent->s.clientNum] == 0) // don't do aux if in a slient part of speech
+ { // not talking
+ if (cent->gent->client->facial_timer < 0) // are we auxing ?
+ { // yes
+ if (-(cent->gent->client->facial_timer) < cg.time) // are we done auxing ?
+ { // yes, reset aux timer
cent->gent->client->facial_timer = cg.time + Q_flrand(7000.0, 10000.0);
- }
- else
- { // not yet, so choose anim
+ } else { // not yet, so choose anim
anim = cent->gent->client->facial_anim;
}
- }
- else // no we aren't auxing
- { // but should we start ?
- if (cent->gent->client->facial_timer < cg.time)
- {//yes
- cent->gent->client->facial_anim = FACE_ALERT + Q_irand(0,2); //alert, smile, frown
+ } else // no we aren't auxing
+ { // but should we start ?
+ if (cent->gent->client->facial_timer < cg.time) { // yes
+ cent->gent->client->facial_anim = FACE_ALERT + Q_irand(0, 2); // alert, smile, frown
// set aux timer
cent->gent->client->facial_timer = -(cg.time + 2000.0);
anim = cent->gent->client->facial_anim;
}
}
- }//talking
- }//dead
- if (anim != -1)
- {
- CG_G2SetHeadAnim( cent, anim );
+ } // talking
+ } // dead
+ if (anim != -1) {
+ CG_G2SetHeadAnim(cent, anim);
return qtrue;
}
return qfalse;
@@ -5371,7 +4459,7 @@ int CG_PlayerHeadExtension( centity_t *cent, refEntity_t *head )
{
add_in += 2;
// set blink timer
- cent->gent->client->facial_frown = -(cg.time + 3000.0);
+ cent->gent->client->facial_frown = -(cg.time + 3000.0);
}
}
}
@@ -5394,23 +4482,19 @@ int CG_PlayerHeadExtension( centity_t *cent, refEntity_t *head )
//
// Can pass in NULL for the axis
//--------------------------------------------------------------
-void CG_GetTagWorldPosition( refEntity_t *model, char *tag, vec3_t pos, vec3_t axis[3] )
-{
- orientation_t orientation;
+void CG_GetTagWorldPosition(refEntity_t *model, char *tag, vec3_t pos, vec3_t axis[3]) {
+ orientation_t orientation;
// Get the requested tag
- cgi_R_LerpTag( &orientation, model->hModel, model->oldframe, model->frame,
- 1.0f - model->backlerp, tag );
+ cgi_R_LerpTag(&orientation, model->hModel, model->oldframe, model->frame, 1.0f - model->backlerp, tag);
- VectorCopy( model->origin, pos );
- for ( int i = 0 ; i < 3 ; i++ )
- {
- VectorMA( pos, orientation.origin[i], model->axis[i], pos );
+ VectorCopy(model->origin, pos);
+ for (int i = 0; i < 3; i++) {
+ VectorMA(pos, orientation.origin[i], model->axis[i], pos);
}
- if ( axis )
- {
- MatrixMultiply( orientation.axis, model->axis, axis );
+ if (axis) {
+ MatrixMultiply(orientation.axis, model->axis, axis);
}
}
@@ -5422,29 +4506,26 @@ CG_GetPlayerLightLevel
-------------------------
*/
-static void CG_GetPlayerLightLevel( centity_t *cent )
-{
- vec3_t ambient={0}, directed, lightDir;
+static void CG_GetPlayerLightLevel(centity_t *cent) {
+ vec3_t ambient = {0}, directed, lightDir;
- //Poll the renderer for the light level
- if ( cent->currentState.clientNum == cg.snap->ps.clientNum )
- {//hAX0R
+ // Poll the renderer for the light level
+ if (cent->currentState.clientNum == cg.snap->ps.clientNum) { // hAX0R
ambient[0] = 666;
}
- cgi_R_GetLighting( cent->lerpOrigin, ambient, directed, lightDir );
+ cgi_R_GetLighting(cent->lerpOrigin, ambient, directed, lightDir);
- //Get the maximum value for the player
+ // Get the maximum value for the player
cent->gent->lightLevel = directed[0];
- if ( directed[1] > cent->gent->lightLevel )
+ if (directed[1] > cent->gent->lightLevel)
cent->gent->lightLevel = directed[1];
- if ( directed[2] > cent->gent->lightLevel )
+ if (directed[2] > cent->gent->lightLevel)
cent->gent->lightLevel = directed[2];
- if ( cent->gent->client->ps.weapon == WP_SABER && cent->gent->client->ps.SaberLength() > 0 )
- {
- cent->gent->lightLevel += (cent->gent->client->ps.SaberLength()/cent->gent->client->ps.SaberLengthMax())*200;
+ if (cent->gent->client->ps.weapon == WP_SABER && cent->gent->client->ps.SaberLength() > 0) {
+ cent->gent->lightLevel += (cent->gent->client->ps.SaberLength() / cent->gent->client->ps.SaberLengthMax()) * 200;
}
}
@@ -5455,50 +4536,35 @@ CG_StopWeaponSounds
Stops any weapon sounds as needed
===============
*/
-static void CG_StopWeaponSounds( centity_t *cent )
-{
- weaponInfo_t *weapon = &cg_weapons[ cent->currentState.weapon ];
+static void CG_StopWeaponSounds(centity_t *cent) {
+ weaponInfo_t *weapon = &cg_weapons[cent->currentState.weapon];
- if ( cent->currentState.weapon == WP_SABER )
- {
- if ( cent->gent && cent->gent->client )
- {
- if ( !cent->gent->client->ps.SaberActive() )
- {//neither saber is on
+ if (cent->currentState.weapon == WP_SABER) {
+ if (cent->gent && cent->gent->client) {
+ if (!cent->gent->client->ps.SaberActive()) { // neither saber is on
return;
- }
- else if ( cent->gent->client->ps.saberInFlight ) //cent->gent->client->ps.saberInFlight )
- {//throwing saber
- if ( !cent->gent->client->ps.dualSabers || !cent->gent->client->ps.saber[1].Active() )
- {//don't have a second saber or it's not on
+ } else if (cent->gent->client->ps.saberInFlight) // cent->gent->client->ps.saberInFlight )
+ { // throwing saber
+ if (!cent->gent->client->ps.dualSabers || !cent->gent->client->ps.saber[1].Active()) { // don't have a second saber or it's not on
return;
}
}
}
- cgi_S_AddLoopingSound( cent->currentState.number,
- cent->lerpOrigin,
- vec3_origin,
- cgs.sound_precache[g_entities[cent->currentState.clientNum].client->ps.saber[0].soundLoop] );
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin,
+ cgs.sound_precache[g_entities[cent->currentState.clientNum].client->ps.saber[0].soundLoop]);
return;
}
- if ( cent->currentState.weapon == WP_STUN_BATON || cent->currentState.weapon == WP_CONCUSSION )
- { //idling sounds
- cgi_S_AddLoopingSound( cent->currentState.number,
- cent->lerpOrigin,
- vec3_origin,
- weapon->firingSound );
+ if (cent->currentState.weapon == WP_STUN_BATON || cent->currentState.weapon == WP_CONCUSSION) { // idling sounds
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->firingSound);
return;
}
- if ( !( cent->currentState.eFlags & EF_FIRING ) )
- {
- if ( cent->pe.lightningFiring )
- {
- if ( weapon->stopSound )
- {
- cgi_S_StartSound( cent->lerpOrigin, cent->currentState.number, CHAN_WEAPON, weapon->stopSound );
+ if (!(cent->currentState.eFlags & EF_FIRING)) {
+ if (cent->pe.lightningFiring) {
+ if (weapon->stopSound) {
+ cgi_S_StartSound(cent->lerpOrigin, cent->currentState.number, CHAN_WEAPON, weapon->stopSound);
}
cent->pe.lightningFiring = qfalse;
@@ -5506,231 +4572,175 @@ static void CG_StopWeaponSounds( centity_t *cent )
return;
}
- if ( cent->currentState.eFlags & EF_ALT_FIRING )
- {
- if ( weapon->altFiringSound )
- {
- cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->altFiringSound );
+ if (cent->currentState.eFlags & EF_ALT_FIRING) {
+ if (weapon->altFiringSound) {
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->altFiringSound);
}
cent->pe.lightningFiring = qtrue;
}
}
-
//--------------- SABER STUFF --------
-extern void CG_Smoke( vec3_t origin, vec3_t dir, float radius, float speed, qhandle_t shader, int flags);
-void CG_SaberDoWeaponHitMarks( gclient_t *client, gentity_t *saberEnt, gentity_t *hitEnt, int saberNum, int bladeNum, vec3_t hitPos, vec3_t hitDir, vec3_t uaxis, vec3_t splashBackDir, float sizeTimeScale )
-{
- if ( client
- && sizeTimeScale > 0.0f
- && hitEnt
- && hitEnt->client
- && hitEnt->ghoul2.size() )
- {//burn mark with glow
- //FIXME: set the correct angle based on direction of swing
- //FIXME: keep a count of these on the ent and don't add too many
- int lifeTime = (1.01-(float)(hitEnt->health)/hitEnt->max_health) * (float)Q_irand( 5000, 10000 );
+extern void CG_Smoke(vec3_t origin, vec3_t dir, float radius, float speed, qhandle_t shader, int flags);
+void CG_SaberDoWeaponHitMarks(gclient_t *client, gentity_t *saberEnt, gentity_t *hitEnt, int saberNum, int bladeNum, vec3_t hitPos, vec3_t hitDir, vec3_t uaxis,
+ vec3_t splashBackDir, float sizeTimeScale) {
+ if (client && sizeTimeScale > 0.0f && hitEnt && hitEnt->client && hitEnt->ghoul2.size()) { // burn mark with glow
+ // FIXME: set the correct angle based on direction of swing
+ // FIXME: keep a count of these on the ent and don't add too many
+ int lifeTime = (1.01 - (float)(hitEnt->health) / hitEnt->max_health) * (float)Q_irand(5000, 10000);
float size = 0.0f;
int weaponMarkShader = 0, markShader = cgs.media.bdecal_saberglowmark;
- //First: do mark decal on hitEnt
- if ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) )
- {
- if ( client->ps.saber[saberNum].g2MarksShader2[0] )
- {//we have a shader to use instead of the standard mark shader
- markShader = cgi_R_RegisterShader( client->ps.saber[saberNum].g2MarksShader2 );
- lifeTime = Q_irand( 20000, 30000 );//last longer if overridden
+ // First: do mark decal on hitEnt
+ if (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum)) {
+ if (client->ps.saber[saberNum].g2MarksShader2[0]) { // we have a shader to use instead of the standard mark shader
+ markShader = cgi_R_RegisterShader(client->ps.saber[saberNum].g2MarksShader2);
+ lifeTime = Q_irand(20000, 30000); // last longer if overridden
}
- }
- else
- {
- if ( client->ps.saber[saberNum].g2MarksShader[0] )
- {//we have a shader to use instead of the standard mark shader
- markShader = cgi_R_RegisterShader( client->ps.saber[saberNum].g2MarksShader );
- lifeTime = Q_irand( 20000, 30000 );//last longer if overridden
+ } else {
+ if (client->ps.saber[saberNum].g2MarksShader[0]) { // we have a shader to use instead of the standard mark shader
+ markShader = cgi_R_RegisterShader(client->ps.saber[saberNum].g2MarksShader);
+ lifeTime = Q_irand(20000, 30000); // last longer if overridden
}
}
- if ( markShader )
- {
- lifeTime = ceil( (float)lifeTime * sizeTimeScale );
- size = Q_flrand( 2.0f, 3.0f ) * sizeTimeScale;
- CG_AddGhoul2Mark( markShader, size, hitPos, hitDir, hitEnt->s.number,
- hitEnt->client->ps.origin, hitEnt->client->renderInfo.legsYaw, hitEnt->ghoul2, hitEnt->s.modelScale,
- lifeTime, 0, uaxis );
+ if (markShader) {
+ lifeTime = ceil((float)lifeTime * sizeTimeScale);
+ size = Q_flrand(2.0f, 3.0f) * sizeTimeScale;
+ CG_AddGhoul2Mark(markShader, size, hitPos, hitDir, hitEnt->s.number, hitEnt->client->ps.origin, hitEnt->client->renderInfo.legsYaw, hitEnt->ghoul2,
+ hitEnt->s.modelScale, lifeTime, 0, uaxis);
}
- //now do weaponMarkShader - splashback decal on weapon
- if ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) )
- {
- if ( client->ps.saber[saberNum].g2WeaponMarkShader2[0] )
- {//we have a shader to use instead of the standard mark shader
- weaponMarkShader = cgi_R_RegisterShader( client->ps.saber[saberNum].g2WeaponMarkShader2 );
- lifeTime = Q_irand( 7000, 12000 );//last longer if overridden
+ // now do weaponMarkShader - splashback decal on weapon
+ if (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum)) {
+ if (client->ps.saber[saberNum].g2WeaponMarkShader2[0]) { // we have a shader to use instead of the standard mark shader
+ weaponMarkShader = cgi_R_RegisterShader(client->ps.saber[saberNum].g2WeaponMarkShader2);
+ lifeTime = Q_irand(7000, 12000); // last longer if overridden
}
- }
- else
- {
- if ( client->ps.saber[saberNum].g2WeaponMarkShader[0] )
- {//we have a shader to use instead of the standard mark shader
- weaponMarkShader = cgi_R_RegisterShader( client->ps.saber[saberNum].g2WeaponMarkShader );
- lifeTime = Q_irand( 7000, 12000 );//last longer if overridden
+ } else {
+ if (client->ps.saber[saberNum].g2WeaponMarkShader[0]) { // we have a shader to use instead of the standard mark shader
+ weaponMarkShader = cgi_R_RegisterShader(client->ps.saber[saberNum].g2WeaponMarkShader);
+ lifeTime = Q_irand(7000, 12000); // last longer if overridden
}
}
- if ( weaponMarkShader )
- {
- centity_t *splatterOnCent = (saberEnt&&client->ps.saberInFlight?&cg_entities[saberEnt->s.number]:&cg_entities[client->ps.clientNum]);
+ if (weaponMarkShader) {
+ centity_t *splatterOnCent = (saberEnt && client->ps.saberInFlight ? &cg_entities[saberEnt->s.number] : &cg_entities[client->ps.clientNum]);
float yawAngle = 0;
vec3_t backDir;
- VectorScale( hitDir, -1, backDir );
- if ( !splatterOnCent->gent->client )
- {
+ VectorScale(hitDir, -1, backDir);
+ if (!splatterOnCent->gent->client) {
yawAngle = splatterOnCent->lerpAngles[YAW];
- }
- else
- {
+ } else {
yawAngle = splatterOnCent->gent->client->renderInfo.legsYaw;
}
- lifeTime = ceil( (float)lifeTime * sizeTimeScale );
- size = Q_flrand( 1.0f, 3.0f ) * sizeTimeScale;
- if ( splatterOnCent->gent->ghoul2.size() > saberNum+1 )
- {
- CG_AddGhoul2Mark( weaponMarkShader, size, hitPos, backDir, splatterOnCent->currentState.number,
- splatterOnCent->lerpOrigin, yawAngle, splatterOnCent->gent->ghoul2, splatterOnCent->currentState.modelScale,
- lifeTime, saberNum+1, uaxis/*splashBackDir*/ );
+ lifeTime = ceil((float)lifeTime * sizeTimeScale);
+ size = Q_flrand(1.0f, 3.0f) * sizeTimeScale;
+ if (splatterOnCent->gent->ghoul2.size() > saberNum + 1) {
+ CG_AddGhoul2Mark(weaponMarkShader, size, hitPos, backDir, splatterOnCent->currentState.number, splatterOnCent->lerpOrigin, yawAngle,
+ splatterOnCent->gent->ghoul2, splatterOnCent->currentState.modelScale, lifeTime, saberNum + 1, uaxis /*splashBackDir*/);
}
}
}
}
-static void CG_RGBForSaberColor( saber_colors_t color, vec3_t rgb )
-{
- switch( color )
- {
- case SABER_RED:
- VectorSet( rgb, 1.0f, 0.2f, 0.2f );
- break;
- case SABER_ORANGE:
- VectorSet( rgb, 1.0f, 0.5f, 0.1f );
- break;
- case SABER_YELLOW:
- VectorSet( rgb, 1.0f, 1.0f, 0.2f );
- break;
- case SABER_GREEN:
- VectorSet( rgb, 0.2f, 1.0f, 0.2f );
- break;
- case SABER_BLUE:
- VectorSet( rgb, 0.2f, 0.4f, 1.0f );
- break;
- case SABER_PURPLE:
- VectorSet( rgb, 0.9f, 0.2f, 1.0f );
- break;
+static void CG_RGBForSaberColor(saber_colors_t color, vec3_t rgb) {
+ switch (color) {
+ case SABER_RED:
+ VectorSet(rgb, 1.0f, 0.2f, 0.2f);
+ break;
+ case SABER_ORANGE:
+ VectorSet(rgb, 1.0f, 0.5f, 0.1f);
+ break;
+ case SABER_YELLOW:
+ VectorSet(rgb, 1.0f, 1.0f, 0.2f);
+ break;
+ case SABER_GREEN:
+ VectorSet(rgb, 0.2f, 1.0f, 0.2f);
+ break;
+ case SABER_BLUE:
+ VectorSet(rgb, 0.2f, 0.4f, 1.0f);
+ break;
+ case SABER_PURPLE:
+ VectorSet(rgb, 0.9f, 0.2f, 1.0f);
+ break;
}
}
-static void CG_DoSaberLight( saberInfo_t *saber )
-{
+static void CG_DoSaberLight(saberInfo_t *saber) {
int firstBlade = 0;
int lastBlade;
- //RGB combine all the colors of the sabers you're using into one averaged color!
- if ( !saber )
- {
+ // RGB combine all the colors of the sabers you're using into one averaged color!
+ if (!saber) {
return;
}
lastBlade = saber->numBlades - 1;
- if ( (saber->saberFlags2&SFL2_NO_DLIGHT) )
- {
- if ( saber->bladeStyle2Start > 0 )
- {
- if ( (saber->saberFlags2&SFL2_NO_DLIGHT2) )
- {
+ if ((saber->saberFlags2 & SFL2_NO_DLIGHT)) {
+ if (saber->bladeStyle2Start > 0) {
+ if ((saber->saberFlags2 & SFL2_NO_DLIGHT2)) {
return;
- }
- else
- {
+ } else {
firstBlade = saber->bladeStyle2Start;
}
- }
- else
- {
+ } else {
return;
}
- }
- else if ( saber->bladeStyle2Start > 0 )
- {
- if ( (saber->saberFlags2&SFL2_NO_DLIGHT2) )
- {
+ } else if (saber->bladeStyle2Start > 0) {
+ if ((saber->saberFlags2 & SFL2_NO_DLIGHT2)) {
lastBlade = saber->bladeStyle2Start;
}
}
- vec3_t positions[MAX_BLADES*2], mid={0}, rgbs[MAX_BLADES*2], rgb={0};
- float lengths[MAX_BLADES*2]={0}, totallength = 0, numpositions = 0, dist, diameter = 0;
- int i, j;
+ vec3_t positions[MAX_BLADES * 2], mid = {0}, rgbs[MAX_BLADES * 2], rgb = {0};
+ float lengths[MAX_BLADES * 2] = {0}, totallength = 0, numpositions = 0, dist, diameter = 0;
+ int i, j;
- if ( saber )
- {
- for ( i = firstBlade; i <= lastBlade; i++ )
- {
- if ( saber->blade[i].length >= MIN_SABERBLADE_DRAW_LENGTH )
- {
- //FIXME: make RGB sabers
- CG_RGBForSaberColor( saber->blade[i].color, rgbs[i] );
+ if (saber) {
+ for (i = firstBlade; i <= lastBlade; i++) {
+ if (saber->blade[i].length >= MIN_SABERBLADE_DRAW_LENGTH) {
+ // FIXME: make RGB sabers
+ CG_RGBForSaberColor(saber->blade[i].color, rgbs[i]);
lengths[i] = saber->blade[i].length;
- if ( saber->blade[i].length*2.0f > diameter )
- {
- diameter = saber->blade[i].length*2.0f;
+ if (saber->blade[i].length * 2.0f > diameter) {
+ diameter = saber->blade[i].length * 2.0f;
}
totallength += saber->blade[i].length;
- VectorMA( saber->blade[i].muzzlePoint, saber->blade[i].length, saber->blade[i].muzzleDir, positions[i] );
- if ( !numpositions )
- {//first blade, store middle of that as midpoint
- VectorMA( saber->blade[i].muzzlePoint, saber->blade[i].length*0.5, saber->blade[i].muzzleDir, mid );
- VectorCopy( rgbs[i], rgb );
+ VectorMA(saber->blade[i].muzzlePoint, saber->blade[i].length, saber->blade[i].muzzleDir, positions[i]);
+ if (!numpositions) { // first blade, store middle of that as midpoint
+ VectorMA(saber->blade[i].muzzlePoint, saber->blade[i].length * 0.5, saber->blade[i].muzzleDir, mid);
+ VectorCopy(rgbs[i], rgb);
}
numpositions++;
}
}
}
- if ( totallength )
- {//actually have something to do
- if ( numpositions == 1 )
- {//only 1 blade, midpoint is already set (halfway between the start and end of that blade), rgb is already set, so it diameter
- }
- else
- {//multiple blades, calc averages
- VectorClear( mid );
- VectorClear( rgb );
- //now go through all the data and get the average RGB and middle position and the radius
- for ( i = 0; i < MAX_BLADES*2; i++ )
- {
- if ( lengths[i] )
- {
- VectorMA( rgb, lengths[i], rgbs[i], rgb );
- VectorAdd( mid, positions[i], mid );
+ if (totallength) { // actually have something to do
+ if (numpositions == 1) { // only 1 blade, midpoint is already set (halfway between the start and end of that blade), rgb is already set, so it diameter
+ } else { // multiple blades, calc averages
+ VectorClear(mid);
+ VectorClear(rgb);
+ // now go through all the data and get the average RGB and middle position and the radius
+ for (i = 0; i < MAX_BLADES * 2; i++) {
+ if (lengths[i]) {
+ VectorMA(rgb, lengths[i], rgbs[i], rgb);
+ VectorAdd(mid, positions[i], mid);
}
}
- //get middle rgb
- VectorScale( rgb, 1/totallength, rgb );//get the average, normalized RGB
- //get mid position
- VectorScale( mid, 1/numpositions, mid );
- //find the farthest distance between the blade tips, this will be our diameter
- for ( i = 0; i < MAX_BLADES*2; i++ )
- {
- if ( lengths[i] )
- {
- for ( j = 0; j < MAX_BLADES*2; j++ )
- {
- if ( lengths[j] )
- {
- dist = Distance( positions[i], positions[j] );
- if ( dist > diameter )
- {
+ // get middle rgb
+ VectorScale(rgb, 1 / totallength, rgb); // get the average, normalized RGB
+ // get mid position
+ VectorScale(mid, 1 / numpositions, mid);
+ // find the farthest distance between the blade tips, this will be our diameter
+ for (i = 0; i < MAX_BLADES * 2; i++) {
+ if (lengths[i]) {
+ for (j = 0; j < MAX_BLADES * 2; j++) {
+ if (lengths[j]) {
+ dist = Distance(positions[i], positions[j]);
+ if (dist > diameter) {
diameter = dist;
}
}
@@ -5739,63 +4749,59 @@ static void CG_DoSaberLight( saberInfo_t *saber )
}
}
- cgi_R_AddLightToScene( mid, diameter + (Q_flrand(0.0f, 1.0f)*8.0f), rgb[0], rgb[1], rgb[2] );
+ cgi_R_AddLightToScene(mid, diameter + (Q_flrand(0.0f, 1.0f) * 8.0f), rgb[0], rgb[1], rgb[2]);
}
}
-static void CG_DoSaber( vec3_t origin, vec3_t dir, float length, float lengthMax, float radius, saber_colors_t color, int rfx, qboolean doLight )
-{
- vec3_t mid;
- qhandle_t blade = 0, glow = 0;
+static void CG_DoSaber(vec3_t origin, vec3_t dir, float length, float lengthMax, float radius, saber_colors_t color, int rfx, qboolean doLight) {
+ vec3_t mid;
+ qhandle_t blade = 0, glow = 0;
refEntity_t saber;
float radiusmult;
- if ( length < MIN_SABERBLADE_DRAW_LENGTH )
- {
+ if (length < MIN_SABERBLADE_DRAW_LENGTH) {
// if the thing is so short, just forget even adding me.
return;
}
// Find the midpoint of the saber for lighting purposes
- VectorMA( origin, length * 0.5f, dir, mid );
+ VectorMA(origin, length * 0.5f, dir, mid);
- switch( color )
- {
- case SABER_RED:
- glow = cgs.media.redSaberGlowShader;
- blade = cgs.media.redSaberCoreShader;
- break;
- case SABER_ORANGE:
- glow = cgs.media.orangeSaberGlowShader;
- blade = cgs.media.orangeSaberCoreShader;
- break;
- case SABER_YELLOW:
- glow = cgs.media.yellowSaberGlowShader;
- blade = cgs.media.yellowSaberCoreShader;
- break;
- case SABER_GREEN:
- glow = cgs.media.greenSaberGlowShader;
- blade = cgs.media.greenSaberCoreShader;
- break;
- case SABER_BLUE:
- glow = cgs.media.blueSaberGlowShader;
- blade = cgs.media.blueSaberCoreShader;
- break;
- case SABER_PURPLE:
- glow = cgs.media.purpleSaberGlowShader;
- blade = cgs.media.purpleSaberCoreShader;
- break;
+ switch (color) {
+ case SABER_RED:
+ glow = cgs.media.redSaberGlowShader;
+ blade = cgs.media.redSaberCoreShader;
+ break;
+ case SABER_ORANGE:
+ glow = cgs.media.orangeSaberGlowShader;
+ blade = cgs.media.orangeSaberCoreShader;
+ break;
+ case SABER_YELLOW:
+ glow = cgs.media.yellowSaberGlowShader;
+ blade = cgs.media.yellowSaberCoreShader;
+ break;
+ case SABER_GREEN:
+ glow = cgs.media.greenSaberGlowShader;
+ blade = cgs.media.greenSaberCoreShader;
+ break;
+ case SABER_BLUE:
+ glow = cgs.media.blueSaberGlowShader;
+ blade = cgs.media.blueSaberCoreShader;
+ break;
+ case SABER_PURPLE:
+ glow = cgs.media.purpleSaberGlowShader;
+ blade = cgs.media.purpleSaberCoreShader;
+ break;
}
// always add a light because sabers cast a nice glow before they slice you in half!! or something...
- if ( doLight )
- {//FIXME: RGB combine all the colors of the sabers you're using into one averaged color!
- vec3_t rgb={1,1,1};
- CG_RGBForSaberColor( color, rgb );
- cgi_R_AddLightToScene( mid, (length*1.4f) + (Q_flrand(0.0f, 1.0f)*3.0f), rgb[0], rgb[1], rgb[2] );
+ if (doLight) { // FIXME: RGB combine all the colors of the sabers you're using into one averaged color!
+ vec3_t rgb = {1, 1, 1};
+ CG_RGBForSaberColor(color, rgb);
+ cgi_R_AddLightToScene(mid, (length * 1.4f) + (Q_flrand(0.0f, 1.0f) * 3.0f), rgb[0], rgb[1], rgb[2]);
}
- memset( &saber, 0, sizeof( refEntity_t ));
+ memset(&saber, 0, sizeof(refEntity_t));
// Saber glow is it's own ref type because it uses a ton of sprites, otherwise it would eat up too many
// refEnts to do each glow blob individually
@@ -5803,106 +4809,95 @@ static void CG_DoSaber( vec3_t origin, vec3_t dir, float length, float lengthMax
// Jeff, I did this because I foolishly wished to have a bright halo as the saber is unleashed.
// It's not quite what I'd hoped tho. If you have any ideas, go for it! --Pat
- if (length < lengthMax )
- {
- radiusmult = 1.0 + (2.0 / length); // Note this creates a curve, and length cannot be < 0.5.
- }
- else
- {
+ if (length < lengthMax) {
+ radiusmult = 1.0 + (2.0 / length); // Note this creates a curve, and length cannot be < 0.5.
+ } else {
radiusmult = 1.0;
}
float radiusRange = radius * 0.075f;
- float radiusStart = radius-radiusRange;
+ float radiusStart = radius - radiusRange;
- saber.radius = (radiusStart + Q_flrand(-1.0f, 1.0f) * radiusRange)*radiusmult;
- //saber.radius = (2.8f + Q_flrand(-1.0f, 1.0f) * 0.2f)*radiusmult;
+ saber.radius = (radiusStart + Q_flrand(-1.0f, 1.0f) * radiusRange) * radiusmult;
+ // saber.radius = (2.8f + Q_flrand(-1.0f, 1.0f) * 0.2f)*radiusmult;
-
- VectorCopy( origin, saber.origin );
- VectorCopy( dir, saber.axis[0] );
+ VectorCopy(origin, saber.origin);
+ VectorCopy(dir, saber.axis[0]);
saber.reType = RT_SABER_GLOW;
saber.customShader = glow;
saber.shaderRGBA[0] = saber.shaderRGBA[1] = saber.shaderRGBA[2] = saber.shaderRGBA[3] = 0xff;
saber.renderfx = rfx;
- cgi_R_AddRefEntityToScene( &saber );
+ cgi_R_AddRefEntityToScene(&saber);
// Do the hot core
- VectorMA( origin, length, dir, saber.origin );
- VectorMA( origin, -1, dir, saber.oldorigin );
+ VectorMA(origin, length, dir, saber.origin);
+ VectorMA(origin, -1, dir, saber.oldorigin);
saber.customShader = blade;
saber.reType = RT_LINE;
- radiusStart = radius/3.0f;
- saber.radius = (radiusStart + Q_flrand(-1.0f, 1.0f) * radiusRange)*radiusmult;
-// saber.radius = (1.0 + Q_flrand(-1.0f, 1.0f) * 0.2f)*radiusmult;
+ radiusStart = radius / 3.0f;
+ saber.radius = (radiusStart + Q_flrand(-1.0f, 1.0f) * radiusRange) * radiusmult;
+ // saber.radius = (1.0 + Q_flrand(-1.0f, 1.0f) * 0.2f)*radiusmult;
- cgi_R_AddRefEntityToScene( &saber );
+ cgi_R_AddRefEntityToScene(&saber);
}
-#define MAX_MARK_FRAGMENTS 128
-#define MAX_MARK_POINTS 384
+#define MAX_MARK_FRAGMENTS 128
+#define MAX_MARK_POINTS 384
extern markPoly_t *CG_AllocMark();
-static void CG_CreateSaberMarks( vec3_t start, vec3_t end, vec3_t normal )
-{
-// byte colors[4];
- int i, j, numFragments;
- vec3_t axis[3], originalPoints[4], mid;
- vec3_t markPoints[MAX_MARK_POINTS], projection;
- polyVert_t *v, verts[MAX_VERTS_ON_POLY];
- markPoly_t *mark;
- markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf;
-
- if ( !cg_addMarks.integer ) {
+static void CG_CreateSaberMarks(vec3_t start, vec3_t end, vec3_t normal) {
+ // byte colors[4];
+ int i, j, numFragments;
+ vec3_t axis[3], originalPoints[4], mid;
+ vec3_t markPoints[MAX_MARK_POINTS], projection;
+ polyVert_t *v, verts[MAX_VERTS_ON_POLY];
+ markPoly_t *mark;
+ markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf;
+
+ if (!cg_addMarks.integer) {
return;
}
- float radius = 0.65f;
+ float radius = 0.65f;
- VectorSubtract( end, start, axis[1] );
- VectorNormalizeFast( axis[1] );
+ VectorSubtract(end, start, axis[1]);
+ VectorNormalizeFast(axis[1]);
// create the texture axis
- VectorCopy( normal, axis[0] );
- CrossProduct( axis[1], axis[0], axis[2] );
+ VectorCopy(normal, axis[0]);
+ CrossProduct(axis[1], axis[0], axis[2]);
// create the full polygon that we'll project
- for ( i = 0 ; i < 3 ; i++ )
- {
+ for (i = 0; i < 3; i++) {
originalPoints[0][i] = start[i] - radius * axis[1][i] - radius * axis[2][i];
originalPoints[1][i] = end[i] + radius * axis[1][i] - radius * axis[2][i];
originalPoints[2][i] = end[i] + radius * axis[1][i] + radius * axis[2][i];
originalPoints[3][i] = start[i] - radius * axis[1][i] + radius * axis[2][i];
}
- VectorScale( normal, -1, projection );
+ VectorScale(normal, -1, projection);
// get the fragments
- numFragments = cgi_CM_MarkFragments( 4, (const float (*)[3])originalPoints,
- projection, MAX_MARK_POINTS, markPoints[0], MAX_MARK_FRAGMENTS, markFragments );
+ numFragments = cgi_CM_MarkFragments(4, (const float(*)[3])originalPoints, projection, MAX_MARK_POINTS, markPoints[0], MAX_MARK_FRAGMENTS, markFragments);
-
- for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ )
- {
+ for (i = 0, mf = markFragments; i < numFragments; i++, mf++) {
// we have an upper limit on the complexity of polygons that we store persistantly
- if ( mf->numPoints > MAX_VERTS_ON_POLY )
- {
+ if (mf->numPoints > MAX_VERTS_ON_POLY) {
mf->numPoints = MAX_VERTS_ON_POLY;
}
- for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ )
- {
+ for (j = 0, v = verts; j < mf->numPoints; j++, v++) {
vec3_t delta;
// Set up our texture coords, this may need some work
- VectorCopy( markPoints[mf->firstPoint + j], v->xyz );
- VectorAdd( end, start, mid );
- VectorScale( mid, 0.5f, mid );
- VectorSubtract( v->xyz, mid, delta );
+ VectorCopy(markPoints[mf->firstPoint + j], v->xyz);
+ VectorAdd(end, start, mid);
+ VectorScale(mid, 0.5f, mid);
+ VectorSubtract(v->xyz, mid, delta);
- v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * (0.05f + Q_flrand(0.0f, 1.0f) * 0.03f);
- v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * (0.15f + Q_flrand(0.0f, 1.0f) * 0.05f);
+ v->st[0] = 0.5 + DotProduct(delta, axis[1]) * (0.05f + Q_flrand(0.0f, 1.0f) * 0.03f);
+ v->st[1] = 0.5 + DotProduct(delta, axis[2]) * (0.15f + Q_flrand(0.0f, 1.0f) * 0.05f);
}
// save it persistantly, do burn first
@@ -5912,93 +4907,78 @@ static void CG_CreateSaberMarks( vec3_t start, vec3_t end, vec3_t normal )
mark->markShader = cgs.media.rivetMarkShader;
mark->poly.numVerts = mf->numPoints;
mark->color[0] = mark->color[1] = mark->color[2] = mark->color[3] = 255;
- memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );
+ memcpy(mark->verts, verts, mf->numPoints * sizeof(verts[0]));
// And now do a glow pass
// by moving the start time back, we can hack it to fade out way before the burn does
mark = CG_AllocMark();
mark->time = cg.time - 8500;
mark->alphaFade = qfalse;
- mark->markShader = cgi_R_RegisterShader("gfx/effects/saberDamageGlow" );
+ mark->markShader = cgi_R_RegisterShader("gfx/effects/saberDamageGlow");
mark->poly.numVerts = mf->numPoints;
mark->color[0] = 215 + Q_flrand(0.0f, 1.0f) * 40.0f;
mark->color[1] = 96 + Q_flrand(0.0f, 1.0f) * 32.0f;
- mark->color[2] = mark->color[3] = Q_flrand(0.0f, 1.0f)*15.0f;
- memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );
+ mark->color[2] = mark->color[3] = Q_flrand(0.0f, 1.0f) * 15.0f;
+ memcpy(mark->verts, verts, mf->numPoints * sizeof(verts[0]));
}
}
-extern void FX_AddPrimitive( CEffect **effect, int killTime );
+extern void FX_AddPrimitive(CEffect **effect, int killTime);
//-------------------------------------------------------
-void CG_CheckSaberInWater( centity_t *cent, centity_t *scent, int saberNum, int modelIndex, vec3_t origin, vec3_t angles )
-{
+void CG_CheckSaberInWater(centity_t *cent, centity_t *scent, int saberNum, int modelIndex, vec3_t origin, vec3_t angles) {
gclient_t *client = cent->gent->client;
- if ( !client )
- {
+ if (!client) {
return;
}
- if ( !scent ||
- modelIndex == -1 ||
- scent->gent->ghoul2.size() <= modelIndex ||
- scent->gent->ghoul2[modelIndex].mBltlist.size() <= 0 || //using a camera puts away your saber so you have no bolts
- scent->gent->ghoul2[modelIndex].mModelindex == -1 )
- {
+ if (!scent || modelIndex == -1 || scent->gent->ghoul2.size() <= modelIndex ||
+ scent->gent->ghoul2[modelIndex].mBltlist.size() <= 0 || // using a camera puts away your saber so you have no bolts
+ scent->gent->ghoul2[modelIndex].mModelindex == -1) {
return;
}
- if ( cent && cent->gent && cent->gent->client
- && (cent->gent->client->ps.saber[saberNum].saberFlags&SFL_ON_IN_WATER) )
- {//saber can stay on underwater
+ if (cent && cent->gent && cent->gent->client && (cent->gent->client->ps.saber[saberNum].saberFlags & SFL_ON_IN_WATER)) { // saber can stay on underwater
return;
}
- if (gi.totalMapContents() & (CONTENTS_WATER|CONTENTS_SLIME))
- {
- vec3_t saberOrg;
- mdxaBone_t boltMatrix;
+ if (gi.totalMapContents() & (CONTENTS_WATER | CONTENTS_SLIME)) {
+ vec3_t saberOrg;
+ mdxaBone_t boltMatrix;
// figure out where the actual model muzzle is
- gi.G2API_GetBoltMatrix( scent->gent->ghoul2, modelIndex, 0, &boltMatrix, angles, origin, cg.time, cgs.model_draw, scent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(scent->gent->ghoul2, modelIndex, 0, &boltMatrix, angles, origin, cg.time, cgs.model_draw, scent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, saberOrg );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, saberOrg);
- const int contents = gi.pointcontents( saberOrg, cent->currentState.clientNum );
- if ( contents & (CONTENTS_WATER|CONTENTS_SLIME) )
- {//still in water
+ const int contents = gi.pointcontents(saberOrg, cent->currentState.clientNum);
+ if (contents & (CONTENTS_WATER | CONTENTS_SLIME)) { // still in water
client->ps.saberEventFlags |= SEF_INWATER;
return;
}
}
- //not in water
+ // not in water
client->ps.saberEventFlags &= ~SEF_INWATER;
}
-static void CG_AddSaberBladeGo( centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles, int saberNum, int bladeNum )
-{
- vec3_t org_, end,//org_future,
- axis_[3] = {{0,0,0}, {0,0,0}, {0,0,0}};//, axis_future[3]={0,0,0, 0,0,0, 0,0,0}; // shut the compiler up
- trace_t trace;
- float length;
- int bolt;
- mdxaBone_t boltMatrix;
+static void CG_AddSaberBladeGo(centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles, int saberNum,
+ int bladeNum) {
+ vec3_t org_, end, // org_future,
+ axis_[3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; //, axis_future[3]={0,0,0, 0,0,0, 0,0,0}; // shut the compiler up
+ trace_t trace;
+ float length;
+ int bolt;
+ mdxaBone_t boltMatrix;
qboolean tagHack = qfalse;
gclient_t *client = cent->gent->client;
- if ( !client )
- {
+ if (!client) {
return;
}
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
-// if (scent->gent->ghoul2.size())
- if(1)
- {
- if ( !scent ||
- modelIndex == -1 ||
- scent->gent->ghoul2.size() <= modelIndex ||
- scent->gent->ghoul2[modelIndex].mModelindex == -1 )
- {
+ // if (scent->gent->ghoul2.size())
+ if (1) {
+ if (!scent || modelIndex == -1 || scent->gent->ghoul2.size() <= modelIndex || scent->gent->ghoul2[modelIndex].mModelindex == -1) {
return;
}
@@ -6032,7 +5012,8 @@ Ghoul2 Insert Start
}
tagHack = qtrue;//use the hacked switch statement below to position and orient the blades
// figure out where the actual model muzzle is
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale );
// work the matrix axis stuff into the original axis and origins used.
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, org_);
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, (Eorientations)fwdAxis, axis_[0]);
@@ -6044,46 +5025,43 @@ Ghoul2 Insert Start
{
// figure out where the actual model muzzle is
- //old way - only 1 tag ever in a saber:
- //gi.G2API_GetBoltMatrix(scent->gent->ghoul2, modelIndex, 0, &boltMatrix, angles, origin, cg.time, cgs.model_draw, scent->currentState.modelScale);
+ // old way - only 1 tag ever in a saber:
+ // gi.G2API_GetBoltMatrix(scent->gent->ghoul2, modelIndex, 0, &boltMatrix, angles, origin, cg.time, cgs.model_draw, scent->currentState.modelScale);
- //New way, multiple blade tags:
- char *tagName = va( "*blade%d", bladeNum+1 );
- bolt = gi.G2API_AddBolt( &scent->gent->ghoul2[modelIndex], tagName );
+ // New way, multiple blade tags:
+ char *tagName = va("*blade%d", bladeNum + 1);
+ bolt = gi.G2API_AddBolt(&scent->gent->ghoul2[modelIndex], tagName);
- if ( bolt == -1 )
- {
- tagHack = qtrue;//use the hacked switch statement below to position and orient the blades
- //hmm, just fall back to the most basic tag (this will also make it work with pre-JKA saber models
- bolt = gi.G2API_AddBolt( &scent->gent->ghoul2[modelIndex], "*flash" );
- if ( bolt == -1 )
- {//no tag_flash either?!!
+ if (bolt == -1) {
+ tagHack = qtrue; // use the hacked switch statement below to position and orient the blades
+ // hmm, just fall back to the most basic tag (this will also make it work with pre-JKA saber models
+ bolt = gi.G2API_AddBolt(&scent->gent->ghoul2[modelIndex], "*flash");
+ if (bolt == -1) { // no tag_flash either?!!
bolt = 0;
}
}
- //if there is an effect on this blade, play it
- if ( !WP_SaberBladeUseSecondBladeStyle( ¢->gent->client->ps.saber[saberNum], bladeNum )
- && cent->gent->client->ps.saber[saberNum].bladeEffect )
- {
- CG_PlayEffectIDBolted( cent->gent->client->ps.saber[saberNum].bladeEffect, modelIndex, bolt, scent->currentState.clientNum, scent->lerpOrigin, -1, qfalse );
- }
- else if ( WP_SaberBladeUseSecondBladeStyle( ¢->gent->client->ps.saber[saberNum], bladeNum )
- && cent->gent->client->ps.saber[saberNum].bladeEffect2 )
- {
- CG_PlayEffectIDBolted( cent->gent->client->ps.saber[saberNum].bladeEffect2, modelIndex, bolt, scent->currentState.clientNum, scent->lerpOrigin, -1, qfalse );
+ // if there is an effect on this blade, play it
+ if (!WP_SaberBladeUseSecondBladeStyle(¢->gent->client->ps.saber[saberNum], bladeNum) && cent->gent->client->ps.saber[saberNum].bladeEffect) {
+ CG_PlayEffectIDBolted(cent->gent->client->ps.saber[saberNum].bladeEffect, modelIndex, bolt, scent->currentState.clientNum, scent->lerpOrigin,
+ -1, qfalse);
+ } else if (WP_SaberBladeUseSecondBladeStyle(¢->gent->client->ps.saber[saberNum], bladeNum) &&
+ cent->gent->client->ps.saber[saberNum].bladeEffect2) {
+ CG_PlayEffectIDBolted(cent->gent->client->ps.saber[saberNum].bladeEffect2, modelIndex, bolt, scent->currentState.clientNum, scent->lerpOrigin,
+ -1, qfalse);
}
- //get the boltMatrix
+ // get the boltMatrix
gi.G2API_GetBoltMatrix(scent->gent->ghoul2, modelIndex, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw, scent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, org_);
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, axis_[0]);//front (was NEGATIVE_Y, but the md3->glm exporter screws up this tag somethin' awful)
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, axis_[1]);//right
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, axis_[2]);//up
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X,
+ axis_[0]); // front (was NEGATIVE_Y, but the md3->glm exporter screws up this tag somethin' awful)
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, axis_[1]); // right
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, axis_[2]); // up
}
- //Now figure out where this info will be next frame
+ // Now figure out where this info will be next frame
/*
{
vec3_t futureOrigin, futureAngles, orgDiff, angDiff;
@@ -6108,122 +5086,108 @@ Ghoul2 Insert Start
}
// figure out where the actual model muzzle will be after next server frame.
- gi.G2API_GetBoltMatrix(scent->gent->ghoul2, modelIndex, 0, &boltMatrix, futureAngles, futureOrigin, futuretime, cgs.model_draw, scent->currentState.modelScale);
+ gi.G2API_GetBoltMatrix(scent->gent->ghoul2, modelIndex, 0, &boltMatrix, futureAngles, futureOrigin, futuretime, cgs.model_draw,
+ scent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, org_future);
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, axis_future[0]);//was NEGATIVE_Y, but the md3->glm exporter screws up this tag somethin' awful
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, axis_future[0]);//was NEGATIVE_Y, but the md3->glm exporter screws up this tag somethin'
+ awful
}
*/
- }
- else
- {
- CG_GetTagWorldPosition( saber, "*flash", org_, axis_ );
+ } else {
+ CG_GetTagWorldPosition(saber, "*flash", org_, axis_);
}
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
-//====FIXMEFIXMEFIXMEFIXMEFIXME========================================================
-//FIXME: temp hack until we have a tag_flash2 for the second (3rd? 4th?) blade
- //FIXME: maybe fall back on this if the saber model has only 1 tag_flash?
+ //====FIXMEFIXMEFIXMEFIXMEFIXME========================================================
+ // FIXME: temp hack until we have a tag_flash2 for the second (3rd? 4th?) blade
+ // FIXME: maybe fall back on this if the saber model has only 1 tag_flash?
// or, better yet, if the saber info doesn't list tagnames for the blades?
- if ( tagHack )
- {
- switch ( cent->gent->client->ps.saber[saberNum].type )
- {
+ if (tagHack) {
+ switch (cent->gent->client->ps.saber[saberNum].type) {
case SABER_SINGLE:
case SABER_DAGGER:
case SABER_LANCE:
break;
case SABER_STAFF:
- if ( bladeNum == 1 )
- {
- VectorScale( axis_[0], -1, axis_[0] );
- VectorMA( org_, 16, axis_[0], org_ );
+ if (bladeNum == 1) {
+ VectorScale(axis_[0], -1, axis_[0]);
+ VectorMA(org_, 16, axis_[0], org_);
}
break;
case SABER_BROAD:
- if ( bladeNum == 0 )
- {
- VectorMA( org_, -1, axis_[1], org_ );
- }
- else if ( bladeNum == 1 )
- {
- VectorMA( org_, 1, axis_[1], org_ );
+ if (bladeNum == 0) {
+ VectorMA(org_, -1, axis_[1], org_);
+ } else if (bladeNum == 1) {
+ VectorMA(org_, 1, axis_[1], org_);
}
break;
case SABER_PRONG:
- if ( bladeNum == 0 )
- {
- VectorMA( org_, -3, axis_[1], org_ );
- }
- else if ( bladeNum == 1 )
- {
- VectorMA( org_, 3, axis_[1], org_ );
+ if (bladeNum == 0) {
+ VectorMA(org_, -3, axis_[1], org_);
+ } else if (bladeNum == 1) {
+ VectorMA(org_, 3, axis_[1], org_);
}
break;
case SABER_ARC:
- VectorSubtract( axis_[1], axis_[2], axis_[1] );
- VectorNormalizeFast( axis_[1] );
- switch ( bladeNum )
- {
+ VectorSubtract(axis_[1], axis_[2], axis_[1]);
+ VectorNormalizeFast(axis_[1]);
+ switch (bladeNum) {
case 0:
- VectorMA( org_, 8, axis_[0], org_ );
- VectorScale( axis_[0], 0.75f, axis_[0] );
- VectorScale( axis_[1], 0.25f, axis_[1] );
- VectorAdd( axis_[0], axis_[1], axis_[0] );
- //VectorNormalize( axis_[0] );
+ VectorMA(org_, 8, axis_[0], org_);
+ VectorScale(axis_[0], 0.75f, axis_[0]);
+ VectorScale(axis_[1], 0.25f, axis_[1]);
+ VectorAdd(axis_[0], axis_[1], axis_[0]);
+ // VectorNormalize( axis_[0] );
break;
case 1:
- //VectorMA( org_, 0, axis_[0], org_ );
- VectorScale( axis_[0], 0.25f, axis_[0] );
- VectorScale( axis_[1], 0.75f, axis_[1] );
- VectorAdd( axis_[0], axis_[1], axis_[0] );
- //VectorNormalize( axis_[0] );
+ // VectorMA( org_, 0, axis_[0], org_ );
+ VectorScale(axis_[0], 0.25f, axis_[0]);
+ VectorScale(axis_[1], 0.75f, axis_[1]);
+ VectorAdd(axis_[0], axis_[1], axis_[0]);
+ // VectorNormalize( axis_[0] );
break;
case 2:
- VectorMA( org_, -8, axis_[0], org_ );
- VectorScale( axis_[0], -0.25f, axis_[0] );
- VectorScale( axis_[1], 0.75f, axis_[1] );
- VectorAdd( axis_[0], axis_[1], axis_[0] );
- //VectorNormalize( axis_[0] );
+ VectorMA(org_, -8, axis_[0], org_);
+ VectorScale(axis_[0], -0.25f, axis_[0]);
+ VectorScale(axis_[1], 0.75f, axis_[1]);
+ VectorAdd(axis_[0], axis_[1], axis_[0]);
+ // VectorNormalize( axis_[0] );
break;
case 3:
- VectorMA( org_, -16, axis_[0], org_ );
- VectorScale( axis_[0], -0.75f, axis_[0] );
- VectorScale( axis_[1], 0.25f, axis_[1] );
- VectorAdd( axis_[0], axis_[1], axis_[0] );
- //VectorNormalize( axis_[0] );
+ VectorMA(org_, -16, axis_[0], org_);
+ VectorScale(axis_[0], -0.75f, axis_[0]);
+ VectorScale(axis_[1], 0.25f, axis_[1]);
+ VectorAdd(axis_[0], axis_[1], axis_[0]);
+ // VectorNormalize( axis_[0] );
break;
}
break;
case SABER_SAI:
- if ( bladeNum == 1 )
- {
- VectorMA( org_, -3, axis_[1], org_ );
- }
- else if ( bladeNum == 2 )
- {
- VectorMA( org_, 3, axis_[1], org_ );
+ if (bladeNum == 1) {
+ VectorMA(org_, -3, axis_[1], org_);
+ } else if (bladeNum == 2) {
+ VectorMA(org_, 3, axis_[1], org_);
}
break;
case SABER_CLAW:
- switch ( bladeNum )
- {
+ switch (bladeNum) {
case 0:
- VectorMA( org_, 2, axis_[0], org_ );
- VectorMA( org_, 2, axis_[2], org_ );
+ VectorMA(org_, 2, axis_[0], org_);
+ VectorMA(org_, 2, axis_[2], org_);
break;
case 1:
- VectorMA( org_, 2, axis_[0], org_ );
- VectorMA( org_, 2, axis_[2], org_ );
- VectorMA( org_, 2, axis_[1], org_ );
+ VectorMA(org_, 2, axis_[0], org_);
+ VectorMA(org_, 2, axis_[2], org_);
+ VectorMA(org_, 2, axis_[1], org_);
break;
case 2:
- VectorMA( org_, 2, axis_[0], org_ );
- VectorMA( org_, 2, axis_[2], org_ );
- VectorMA( org_, -2, axis_[1], org_ );
+ VectorMA(org_, 2, axis_[0], org_);
+ VectorMA(org_, 2, axis_[2], org_);
+ VectorMA(org_, -2, axis_[1], org_);
break;
}
/*
@@ -6251,7 +5215,8 @@ Ghoul2 Insert End
bolt = cent->gent->handLBolt;
}
// figure out where the actual model muzzle is
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, angles, origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale );
// work the matrix axis stuff into the original axis and origins used.
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, org_);
}
@@ -6262,255 +5227,219 @@ Ghoul2 Insert End
VectorCopy( axis_[1], axis_[2] );
}
*/
- switch ( bladeNum )
- {
+ switch (bladeNum) {
case 0:
- VectorMA( org_, 8, axis_[0], org_ );
+ VectorMA(org_, 8, axis_[0], org_);
break;
case 1:
- VectorScale( axis_[0], 0.33f, axis_[0] );
- VectorScale( axis_[2], 0.67f, axis_[2] );
- VectorAdd( axis_[0], axis_[2], axis_[0] );
- //VectorNormalize( axis_[0] );
- VectorMA( org_, 8, axis_[0], org_ );
+ VectorScale(axis_[0], 0.33f, axis_[0]);
+ VectorScale(axis_[2], 0.67f, axis_[2]);
+ VectorAdd(axis_[0], axis_[2], axis_[0]);
+ // VectorNormalize( axis_[0] );
+ VectorMA(org_, 8, axis_[0], org_);
break;
case 2:
- VectorScale( axis_[0], -0.33f, axis_[0] );
- VectorScale( axis_[2], 0.67f, axis_[2] );
- VectorAdd( axis_[0], axis_[2], axis_[0] );
- //VectorNormalize( axis_[0] );
- VectorMA( org_, 8, axis_[0], org_ );
+ VectorScale(axis_[0], -0.33f, axis_[0]);
+ VectorScale(axis_[2], 0.67f, axis_[2]);
+ VectorAdd(axis_[0], axis_[2], axis_[0]);
+ // VectorNormalize( axis_[0] );
+ VectorMA(org_, 8, axis_[0], org_);
break;
case 3:
- VectorScale( axis_[0], -1, axis_[0] );
- VectorMA( org_, 8, axis_[0], org_ );
+ VectorScale(axis_[0], -1, axis_[0]);
+ VectorMA(org_, 8, axis_[0], org_);
break;
case 4:
- VectorScale( axis_[0], -0.33f, axis_[0] );
- VectorScale( axis_[2], -0.67f, axis_[2] );
- VectorAdd( axis_[0], axis_[2], axis_[0] );
- //VectorNormalize( axis_[0] );
- VectorMA( org_, 8, axis_[0], org_ );
+ VectorScale(axis_[0], -0.33f, axis_[0]);
+ VectorScale(axis_[2], -0.67f, axis_[2]);
+ VectorAdd(axis_[0], axis_[2], axis_[0]);
+ // VectorNormalize( axis_[0] );
+ VectorMA(org_, 8, axis_[0], org_);
break;
case 5:
- VectorScale( axis_[0], 0.33f, axis_[0] );
- VectorScale( axis_[2], -0.67f, axis_[2] );
- VectorAdd( axis_[0], axis_[2], axis_[0] );
- //VectorNormalize( axis_[0] );
- VectorMA( org_, 8, axis_[0], org_ );
+ VectorScale(axis_[0], 0.33f, axis_[0]);
+ VectorScale(axis_[2], -0.67f, axis_[2]);
+ VectorAdd(axis_[0], axis_[2], axis_[0]);
+ // VectorNormalize( axis_[0] );
+ VectorMA(org_, 8, axis_[0], org_);
break;
}
break;
case SABER_TRIDENT:
- switch ( bladeNum )
- {
+ switch (bladeNum) {
case 0:
- VectorMA( org_, 24, axis_[0], org_ );
+ VectorMA(org_, 24, axis_[0], org_);
break;
case 1:
- VectorMA( org_, -6, axis_[1], org_ );
- VectorMA( org_, 24, axis_[0], org_ );
+ VectorMA(org_, -6, axis_[1], org_);
+ VectorMA(org_, 24, axis_[0], org_);
break;
case 2:
- VectorMA( org_, 6, axis_[1], org_ );
- VectorMA( org_, 24, axis_[0], org_ );
+ VectorMA(org_, 6, axis_[1], org_);
+ VectorMA(org_, 24, axis_[0], org_);
break;
case 3:
- VectorMA( org_, -32, axis_[0], org_ );
- VectorScale( axis_[0], -1, axis_[0] );
+ VectorMA(org_, -32, axis_[0], org_);
+ VectorScale(axis_[0], -1, axis_[0]);
break;
}
break;
case SABER_SITH_SWORD:
- //no blade
+ // no blade
break;
default:
break;
}
}
-//====FIXMEFIXMEFIXMEFIXMEFIXME========================================================
+ //====FIXMEFIXMEFIXMEFIXMEFIXME========================================================
- //store where saber is this frame
- VectorCopy( org_, cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzlePoint );
- VectorCopy( axis_[0], cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzleDir );
- if ( saberNum == 0 && bladeNum == 0 )
- {
- VectorCopy( org_, cent->gent->client->renderInfo.muzzlePoint );
- VectorCopy( axis_[0], cent->gent->client->renderInfo.muzzleDir );
+ // store where saber is this frame
+ VectorCopy(org_, cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzlePoint);
+ VectorCopy(axis_[0], cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzleDir);
+ if (saberNum == 0 && bladeNum == 0) {
+ VectorCopy(org_, cent->gent->client->renderInfo.muzzlePoint);
+ VectorCopy(axis_[0], cent->gent->client->renderInfo.muzzleDir);
cent->gent->client->renderInfo.mPCalcTime = cg.time;
}
- //length for purposes of rendering and marks trace will be longer than blade so we don't damage past a wall's surface
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax )
- {
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax - 8 )
- {
+ // length for purposes of rendering and marks trace will be longer than blade so we don't damage past a wall's surface
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax) {
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax - 8) {
length = cent->gent->client->ps.saber[saberNum].blade[bladeNum].length + 8;
- }
- else
- {
+ } else {
length = cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax;
}
- }
- else
- {
+ } else {
length = cent->gent->client->ps.saber[saberNum].blade[bladeNum].length;
}
- VectorMA( org_, length, axis_[0], end );
+ VectorMA(org_, length, axis_[0], end);
// Now store where the saber will be after next frame.
- //VectorCopy(org_future, cent->gent->client->renderInfo.muzzlePointNext);
- //VectorCopy(axis_future[0], cent->gent->client->renderInfo.muzzleDirNext);
+ // VectorCopy(org_future, cent->gent->client->renderInfo.muzzlePointNext);
+ // VectorCopy(axis_future[0], cent->gent->client->renderInfo.muzzleDirNext);
- VectorAdd( end, axis_[0], end );
+ VectorAdd(end, axis_[0], end);
// If the saber is in flight we shouldn't trace from the player to the muzzle point
- if ( cent->gent->client->ps.saberInFlight && saberNum == 0 )
- {
+ if (cent->gent->client->ps.saberInFlight && saberNum == 0) {
trace.fraction = 1.0f;
- }
- else
- {
+ } else {
vec3_t rootOrigin;
- if (cent->gent->rootBone>=0 && cent->gent->ghoul2.IsValid() && cent->gent->ghoul2[0].animModelIndexOffset)//If it has an animOffset it's a cinematic anim
- { //i might be running out of my bounding box, so get my root origin
- mdxaBone_t boltMatrix;
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->rootBone,
- &boltMatrix, angles, cent->lerpOrigin,
- cg.time, cgs.model_draw, cent->currentState.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, rootOrigin );
+ if (cent->gent->rootBone >= 0 && cent->gent->ghoul2.IsValid() &&
+ cent->gent->ghoul2[0].animModelIndexOffset) // If it has an animOffset it's a cinematic anim
+ { // i might be running out of my bounding box, so get my root origin
+ mdxaBone_t boltMatrix;
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->rootBone, &boltMatrix, angles, cent->lerpOrigin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, rootOrigin);
+ } else {
+ VectorCopy(cent->lerpOrigin, rootOrigin);
}
- else
- {
- VectorCopy( cent->lerpOrigin, rootOrigin );
- }
- gi.trace( &trace, rootOrigin, NULL, NULL, cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzlePoint, cent->currentState.number, CONTENTS_SOLID, (EG2_Collision)0, 0 );
+ gi.trace(&trace, rootOrigin, NULL, NULL, cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzlePoint, cent->currentState.number, CONTENTS_SOLID,
+ (EG2_Collision)0, 0);
}
- if ( trace.fraction < 1.0f )
- {
+ if (trace.fraction < 1.0f) {
// Saber is on the other side of a wall
cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = 0.1f;
cent->gent->client->ps.saberEventFlags &= ~SEF_INWATER;
- }
- else
- {
+ } else {
extern vmCvar_t cg_saberEntMarks;
int traceMask = MASK_SOLID;
qboolean noMarks = qfalse;
- if ( (!WP_SaberBladeUseSecondBladeStyle( ¢->gent->client->ps.saber[saberNum], bladeNum )
- && (cent->gent->client->ps.saber[saberNum].saberFlags2&SFL2_NO_IDLE_EFFECT) )
- || ( WP_SaberBladeUseSecondBladeStyle( ¢->gent->client->ps.saber[saberNum], bladeNum )
- && (cent->gent->client->ps.saber[saberNum].saberFlags2&SFL2_NO_IDLE_EFFECT2) )
- )
- {//do no effects when idle
- if ( !cent->gent->client->ps.saberInFlight
- && !PM_SaberInAttack( cent->gent->client->ps.saberMove )
- && !PM_SaberInTransitionAny( cent->gent->client->ps.saberMove )
- && !PM_SaberInSpecialAttack( cent->gent->client->ps.torsoAnim ) )
- {//idle, do no marks
+ if ((!WP_SaberBladeUseSecondBladeStyle(¢->gent->client->ps.saber[saberNum], bladeNum) &&
+ (cent->gent->client->ps.saber[saberNum].saberFlags2 & SFL2_NO_IDLE_EFFECT)) ||
+ (WP_SaberBladeUseSecondBladeStyle(¢->gent->client->ps.saber[saberNum], bladeNum) &&
+ (cent->gent->client->ps.saber[saberNum].saberFlags2 & SFL2_NO_IDLE_EFFECT2))) { // do no effects when idle
+ if (!cent->gent->client->ps.saberInFlight && !PM_SaberInAttack(cent->gent->client->ps.saberMove) &&
+ !PM_SaberInTransitionAny(cent->gent->client->ps.saberMove) && !PM_SaberInSpecialAttack(cent->gent->client->ps.torsoAnim)) { // idle, do no marks
noMarks = qtrue;
}
}
- if ( cg_saberEntMarks.integer )
- {
- if ( cent->gent->client->ps.saberInFlight
- || PM_SaberInAttack( cent->gent->client->ps.saberMove )
+ if (cg_saberEntMarks.integer) {
+ if (cent->gent->client->ps.saberInFlight ||
+ PM_SaberInAttack(cent->gent->client->ps.saberMove)
//|| PM_SaberInTransitionAny( cent->gent->client->ps.saberMove )
- || PM_SaberInSpecialAttack( cent->gent->client->ps.torsoAnim ) )
- {
- traceMask |= (CONTENTS_BODY|CONTENTS_CORPSE);
+ || PM_SaberInSpecialAttack(cent->gent->client->ps.torsoAnim)) {
+ traceMask |= (CONTENTS_BODY | CONTENTS_CORPSE);
}
}
- for ( int i = 0; i < 1; i++ )//was 2 because it would go through architecture and leave saber trails on either side of the brush - but still looks bad if we hit a corner, blade is still 8 longer than hit
+ for (int i = 0; i < 1; i++) // was 2 because it would go through architecture and leave saber trails on either side of the brush - but still looks bad
+ // if we hit a corner, blade is still 8 longer than hit
{
- if ( i )
- {//tracing from end to base
- gi.trace( &trace, end, NULL, NULL, org_, cent->currentState.clientNum, traceMask, (EG2_Collision)0, 0 );
- }
- else
- {//tracing from base to end
- gi.trace( &trace, org_, NULL, NULL, end, cent->currentState.clientNum, traceMask|CONTENTS_WATER|CONTENTS_SLIME, (EG2_Collision)0, 0 );
+ if (i) { // tracing from end to base
+ gi.trace(&trace, end, NULL, NULL, org_, cent->currentState.clientNum, traceMask, (EG2_Collision)0, 0);
+ } else { // tracing from base to end
+ gi.trace(&trace, org_, NULL, NULL, end, cent->currentState.clientNum, traceMask | CONTENTS_WATER | CONTENTS_SLIME, (EG2_Collision)0, 0);
}
- if ( trace.fraction < 1.0f )
- {
- if ( (trace.contents&CONTENTS_WATER) || (trace.contents&CONTENTS_SLIME) )
- {
- if ( !noMarks )
- {
+ if (trace.fraction < 1.0f) {
+ if ((trace.contents & CONTENTS_WATER) || (trace.contents & CONTENTS_SLIME)) {
+ if (!noMarks) {
/*
if ( !(cent->gent->client->ps.saberEventFlags&SEF_INWATER) )
{
}
*/
- if ( !Q_irand( 0, 10 ) )
- {//FIXME: don't do this this way.... :)
- vec3_t spot;
- VectorCopy( trace.endpos, spot );
+ if (!Q_irand(0, 10)) { // FIXME: don't do this this way.... :)
+ vec3_t spot;
+ VectorCopy(trace.endpos, spot);
spot[2] += 4;
- if ( Q_irand( 1, client->ps.saber[saberNum].numBlades ) == 1 )
- {
- theFxScheduler.PlayEffect( "saber/boil", spot );
- cgi_S_StartSound ( spot, -1, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/saber/hitwater.wav" ) );
+ if (Q_irand(1, client->ps.saber[saberNum].numBlades) == 1) {
+ theFxScheduler.PlayEffect("saber/boil", spot);
+ cgi_S_StartSound(spot, -1, CHAN_AUTO, cgi_S_RegisterSound("sound/weapons/saber/hitwater.wav"));
}
}
- //cent->gent->client->ps.saberEventFlags |= SEF_INWATER;
- //don't do other trace
+ // cent->gent->client->ps.saberEventFlags |= SEF_INWATER;
+ // don't do other trace
}
i = 1;
- }
- else
- {
- if ( !noMarks )
- {
- if ( ( !WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && !(client->ps.saber[saberNum].saberFlags2&SFL2_NO_WALL_MARKS) )
- || ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && !(client->ps.saber[saberNum].saberFlags2&SFL2_NO_WALL_MARKS2) ) )
- {
- if ( !(trace.surfaceFlags & SURF_NOIMPACT) // never spark on sky
- && (trace.entityNum == ENTITYNUM_WORLD || cg_entities[trace.entityNum].currentState.solid == SOLID_BMODEL)
- && Q_irand( 1, client->ps.saber[saberNum].numBlades ) == 1 )
- {
- //was "sparks/spark"
- theFxScheduler.PlayEffect( "sparks/spark_nosnd", trace.endpos, trace.plane.normal );
+ } else {
+ if (!noMarks) {
+ if ((!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ !(client->ps.saber[saberNum].saberFlags2 & SFL2_NO_WALL_MARKS)) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ !(client->ps.saber[saberNum].saberFlags2 & SFL2_NO_WALL_MARKS2))) {
+ if (!(trace.surfaceFlags & SURF_NOIMPACT) // never spark on sky
+ && (trace.entityNum == ENTITYNUM_WORLD || cg_entities[trace.entityNum].currentState.solid == SOLID_BMODEL) &&
+ Q_irand(1, client->ps.saber[saberNum].numBlades) == 1) {
+ // was "sparks/spark"
+ theFxScheduler.PlayEffect("sparks/spark_nosnd", trace.endpos, trace.plane.normal);
}
}
// All I need is a bool to mark whether I have a previous point to work with.
//....come up with something better..
- if ( client->ps.saber[saberNum].blade[bladeNum].trail.haveOldPos[i] )
- {
- if ( trace.entityNum == ENTITYNUM_WORLD || (cg_entities[trace.entityNum].currentState.eFlags & EF_PERMANENT) || cg_entities[trace.entityNum].currentState.eType == ET_TERRAIN )
- {//only put marks on architecture
- if ( (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && !(client->ps.saber[saberNum].saberFlags2&SFL2_NO_WALL_MARKS))
- || (WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && !(client->ps.saber[saberNum].saberFlags2&SFL2_NO_WALL_MARKS2)) )
- {
+ if (client->ps.saber[saberNum].blade[bladeNum].trail.haveOldPos[i]) {
+ if (trace.entityNum == ENTITYNUM_WORLD || (cg_entities[trace.entityNum].currentState.eFlags & EF_PERMANENT) ||
+ cg_entities[trace.entityNum].currentState.eType == ET_TERRAIN) { // only put marks on architecture
+ if ((!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ !(client->ps.saber[saberNum].saberFlags2 & SFL2_NO_WALL_MARKS)) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ !(client->ps.saber[saberNum].saberFlags2 & SFL2_NO_WALL_MARKS2))) {
// Let's do some cool burn/glowing mark bits!!!
- CG_CreateSaberMarks( client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i], trace.endpos, trace.plane.normal );
+ CG_CreateSaberMarks(client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i], trace.endpos, trace.plane.normal);
- if ( Q_irand( 1, client->ps.saber[saberNum].numBlades ) == 1 )
- {
- //make a sound
- if ( cg.time - cent->gent->client->ps.saberHitWallSoundDebounceTime >= 100 )
- {//ugh, need to have a real sound debouncer... or do this game-side
+ if (Q_irand(1, client->ps.saber[saberNum].numBlades) == 1) {
+ // make a sound
+ if (cg.time - cent->gent->client->ps.saberHitWallSoundDebounceTime >=
+ 100) { // ugh, need to have a real sound debouncer... or do this game-side
cent->gent->client->ps.saberHitWallSoundDebounceTime = cg.time;
- cgi_S_StartSound ( cent->lerpOrigin, cent->currentState.clientNum, CHAN_ITEM, cgi_S_RegisterSound( va ( "sound/weapons/saber/saberhitwall%d.wav", Q_irand( 1, 3 ) ) ) );
+ cgi_S_StartSound(cent->lerpOrigin, cent->currentState.clientNum, CHAN_ITEM,
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberhitwall%d.wav", Q_irand(1, 3))));
}
}
}
- }
- else if ( !i )
- {//can put marks on G2 clients (but only on base to tip trace)
+ } else if (!i) { // can put marks on G2 clients (but only on base to tip trace)
gentity_t *hitEnt = &g_entities[trace.entityNum];
vec3_t uaxis, splashBackDir;
VectorSubtract(client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i], trace.endpos, uaxis);
- VectorScale( axis_[0], -1, splashBackDir );
- //FIXME: if not hitting the first model on the enemy, don't do this!
- CG_SaberDoWeaponHitMarks( client, (scent!=NULL?scent->gent:NULL), hitEnt, saberNum, bladeNum, trace.endpos, axis_[0], uaxis, splashBackDir, 0.25f );
+ VectorScale(axis_[0], -1, splashBackDir);
+ // FIXME: if not hitting the first model on the enemy, don't do this!
+ CG_SaberDoWeaponHitMarks(client, (scent != NULL ? scent->gent : NULL), hitEnt, saberNum, bladeNum, trace.endpos, axis_[0],
+ uaxis, splashBackDir, 0.25f);
}
- }
- else
- {
+ } else {
// if we impact next frame, we'll mark a slash mark
client->ps.saber[saberNum].blade[bladeNum].trail.haveOldPos[i] = qtrue;
}
@@ -6518,34 +5447,34 @@ Ghoul2 Insert End
}
// stash point so we can connect-the-dots later
- VectorCopy( trace.endpos, client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i] );
- VectorCopy( trace.plane.normal, client->ps.saber[saberNum].blade[bladeNum].trail.oldNormal[i] );
-
- if ( !i && trace.contents&(CONTENTS_SOLID|CONTENTS_TERRAIN|CONTENTS_SHOTCLIP) )
- { //Now that we don't let the blade go through walls, we need to shorten the blade when it hits one
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = cent->gent->client->ps.saber[saberNum].blade[bladeNum].length * trace.fraction;//this will stop damage from going through walls
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length <= 0.1f )
- {//SIGH... hack so it doesn't play the saber turn-on sound that plays when you first turn the saber on (assumed when saber is active but length is zero)
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = 0.1f;//FIXME: may go through walls still??
+ VectorCopy(trace.endpos, client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i]);
+ VectorCopy(trace.plane.normal, client->ps.saber[saberNum].blade[bladeNum].trail.oldNormal[i]);
+
+ if (!i &&
+ trace.contents & (CONTENTS_SOLID | CONTENTS_TERRAIN |
+ CONTENTS_SHOTCLIP)) { // Now that we don't let the blade go through walls, we need to shorten the blade when it hits one
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length =
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length * trace.fraction; // this will stop damage from going through walls
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length <=
+ 0.1f) { // SIGH... hack so it doesn't play the saber turn-on sound that plays when you first turn the saber on (assumed when saber is
+ // active but length is zero)
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = 0.1f; // FIXME: may go through walls still??
}
- //FIXME: should probably re-extend instantly, not use the "turning-on" growth rate
+ // FIXME: should probably re-extend instantly, not use the "turning-on" growth rate
}
- }
- else
- {
+ } else {
cent->gent->client->ps.saberEventFlags &= ~SEF_INWATER;
- if ( client->ps.saber[saberNum].blade[bladeNum].trail.haveOldPos[i] )
- {
- if ( !noMarks )
- {
- if ( (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && !(client->ps.saber[saberNum].saberFlags2&SFL2_NO_WALL_MARKS))
- || (WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && !(client->ps.saber[saberNum].saberFlags2&SFL2_NO_WALL_MARKS2)) )
- {
+ if (client->ps.saber[saberNum].blade[bladeNum].trail.haveOldPos[i]) {
+ if (!noMarks) {
+ if ((!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ !(client->ps.saber[saberNum].saberFlags2 & SFL2_NO_WALL_MARKS)) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ !(client->ps.saber[saberNum].saberFlags2 & SFL2_NO_WALL_MARKS2))) {
// Hmmm, no impact this frame, but we have an old point
// Let's put the mark there, we should use an endcap mark to close the line, but we
// can probably just get away with a round mark
- //CG_ImpactMark( cgs.media.rivetMarkShader, client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i], client->ps.saber[saberNum].blade[bladeNum].trail.oldNormal[i],
- // 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, qfalse, 1.1f, qfalse );
+ // CG_ImpactMark( cgs.media.rivetMarkShader, client->ps.saber[saberNum].blade[bladeNum].trail.oldPos[i],
+ // client->ps.saber[saberNum].blade[bladeNum].trail.oldNormal[i], 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, qfalse, 1.1f, qfalse );
}
}
}
@@ -6558,104 +5487,93 @@ Ghoul2 Insert End
// Added 10/02/02 by Aurelio Reis.
// If the Blade is not active, leave here; we do not Render it!
-/* if ( cent->gent->client->ps.saber[saberNum].type == SABER_SITH_SWORD )
- {//draws no blade or trail
- //FIXME: draw some sort of energy halo and motion trail!
- return;
- }
-*/
- if ( !client->ps.saber[saberNum].blade[bladeNum].active && client->ps.saber[saberNum].blade[bladeNum].length <= 0 )
- {
+ /* if ( cent->gent->client->ps.saber[saberNum].type == SABER_SITH_SWORD )
+ {//draws no blade or trail
+ //FIXME: draw some sort of energy halo and motion trail!
+ return;
+ }
+ */
+ if (!client->ps.saber[saberNum].blade[bladeNum].active && client->ps.saber[saberNum].blade[bladeNum].length <= 0) {
return;
}
- if ( (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && client->ps.saber[saberNum].trailStyle < 2 )
- || ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && client->ps.saber[saberNum].trailStyle2 < 2 ) )
- {//okay to draw the trail
- saberTrail_t *saberTrail = &client->ps.saber[saberNum].blade[bladeNum].trail;
+ if ((!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && client->ps.saber[saberNum].trailStyle < 2) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && client->ps.saber[saberNum].trailStyle2 < 2)) { // okay to draw the trail
+ saberTrail_t *saberTrail = &client->ps.saber[saberNum].blade[bladeNum].trail;
-#define SABER_TRAIL_TIME 40.0f
+#define SABER_TRAIL_TIME 40.0f
// if we happen to be timescaled or running in a high framerate situation, we don't want to flood
// the system with very small trail slices...but perhaps doing it by distance would yield better results?
- if ( saberTrail->lastTime > cg.time )
- {//after a pause, cg.time jumps ahead in time for one frame
- //and lastTime gets set to that and will freak out, so, since
- //it's never valid for saberTrail->lastTime to be > cg.time,
- //cap it to cg.time here
+ if (saberTrail->lastTime > cg.time) { // after a pause, cg.time jumps ahead in time for one frame
+ // and lastTime gets set to that and will freak out, so, since
+ // it's never valid for saberTrail->lastTime to be > cg.time,
+ // cap it to cg.time here
saberTrail->lastTime = cg.time;
}
- if ( cg.time > saberTrail->lastTime + 2 && saberTrail->inAction ) // 2ms
+ if (cg.time > saberTrail->lastTime + 2 && saberTrail->inAction) // 2ms
{
- if ( saberTrail->inAction && cg.time < saberTrail->lastTime + 300 ) // if we have a stale segment, don't draw until we have a fresh one
+ if (saberTrail->inAction && cg.time < saberTrail->lastTime + 300) // if we have a stale segment, don't draw until we have a fresh one
{
- vec3_t rgb1={255,255,255};
+ vec3_t rgb1 = {255, 255, 255};
- if ( cent->gent->client->ps.saber[saberNum].type != SABER_SITH_SWORD
- && ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) || client->ps.saber[saberNum].trailStyle != 1 )
- && ( !WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) || client->ps.saber[saberNum].trailStyle2 != 1 )
- )
- {
- switch( client->ps.saber[saberNum].blade[bladeNum].color )
- {
- case SABER_RED:
- VectorSet( rgb1, 255.0f, 0.0f, 0.0f );
- break;
- case SABER_ORANGE:
- VectorSet( rgb1, 255.0f, 64.0f, 0.0f );
- break;
- case SABER_YELLOW:
- VectorSet( rgb1, 255.0f, 255.0f, 0.0f );
- break;
- case SABER_GREEN:
- VectorSet( rgb1, 0.0f, 255.0f, 0.0f );
- break;
- case SABER_BLUE:
- VectorSet( rgb1, 0.0f, 64.0f, 255.0f );
- break;
- case SABER_PURPLE:
- VectorSet( rgb1, 220.0f, 0.0f, 255.0f );
- break;
+ if (cent->gent->client->ps.saber[saberNum].type != SABER_SITH_SWORD &&
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) || client->ps.saber[saberNum].trailStyle != 1) &&
+ (!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) || client->ps.saber[saberNum].trailStyle2 != 1)) {
+ switch (client->ps.saber[saberNum].blade[bladeNum].color) {
+ case SABER_RED:
+ VectorSet(rgb1, 255.0f, 0.0f, 0.0f);
+ break;
+ case SABER_ORANGE:
+ VectorSet(rgb1, 255.0f, 64.0f, 0.0f);
+ break;
+ case SABER_YELLOW:
+ VectorSet(rgb1, 255.0f, 255.0f, 0.0f);
+ break;
+ case SABER_GREEN:
+ VectorSet(rgb1, 0.0f, 255.0f, 0.0f);
+ break;
+ case SABER_BLUE:
+ VectorSet(rgb1, 0.0f, 64.0f, 255.0f);
+ break;
+ case SABER_PURPLE:
+ VectorSet(rgb1, 220.0f, 0.0f, 255.0f);
+ break;
}
}
float diff = cg.time - saberTrail->lastTime;
// I'm not sure that clipping this is really the best idea
- if ( diff <= SABER_TRAIL_TIME * 2 )
- {
+ if (diff <= SABER_TRAIL_TIME * 2) {
// build a quad
CTrail *fx = new CTrail;
float duration;
- if ( cent->gent->client->ps.saber[saberNum].type == SABER_SITH_SWORD
- || (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && client->ps.saber[saberNum].trailStyle == 1 )
- || ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && client->ps.saber[saberNum].trailStyle2 == 1 )
- )
- {
+ if (cent->gent->client->ps.saber[saberNum].type == SABER_SITH_SWORD ||
+ (!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && client->ps.saber[saberNum].trailStyle == 1) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && client->ps.saber[saberNum].trailStyle2 == 1)) {
fx->mShader = cgs.media.swordTrailShader;
- duration = saberTrail->duration/2.0f; // stay around twice as long
- VectorSet( rgb1, 32.0f, 32.0f, 32.0f ); // make the sith sword trail pretty faint
- }
- else
- {
+ duration = saberTrail->duration / 2.0f; // stay around twice as long
+ VectorSet(rgb1, 32.0f, 32.0f, 32.0f); // make the sith sword trail pretty faint
+ } else {
fx->mShader = cgs.media.saberBlurShader;
- duration = saberTrail->duration/5.0f;
+ duration = saberTrail->duration / 5.0f;
}
- float oldAlpha = 1.0f - ( diff / duration );
+ float oldAlpha = 1.0f - (diff / duration);
// Go from new muzzle to new end...then to old end...back down to old muzzle...finally
// connect back to the new muzzle...this is our trail quad
- VectorCopy( org_, fx->mVerts[0].origin );
- VectorMA( end, 3.0f, axis_[0], fx->mVerts[1].origin );
+ VectorCopy(org_, fx->mVerts[0].origin);
+ VectorMA(end, 3.0f, axis_[0], fx->mVerts[1].origin);
- VectorCopy( saberTrail->tip, fx->mVerts[2].origin );
- VectorCopy( saberTrail->base, fx->mVerts[3].origin );
+ VectorCopy(saberTrail->tip, fx->mVerts[2].origin);
+ VectorCopy(saberTrail->base, fx->mVerts[3].origin);
// New muzzle
- VectorCopy( rgb1, fx->mVerts[0].rgb );
+ VectorCopy(rgb1, fx->mVerts[0].rgb);
fx->mVerts[0].alpha = 255.0f;
fx->mVerts[0].ST[0] = 0.0f;
@@ -6664,7 +5582,7 @@ Ghoul2 Insert End
fx->mVerts[0].destST[1] = 0.99f;
// new tip
- VectorCopy( rgb1, fx->mVerts[1].rgb );
+ VectorCopy(rgb1, fx->mVerts[1].rgb);
fx->mVerts[1].alpha = 255.0f;
fx->mVerts[1].ST[0] = 0.0f;
@@ -6673,7 +5591,7 @@ Ghoul2 Insert End
fx->mVerts[1].destST[1] = 0.0f;
// old tip
- VectorCopy( rgb1, fx->mVerts[2].rgb );
+ VectorCopy(rgb1, fx->mVerts[2].rgb);
fx->mVerts[2].alpha = 255.0f;
fx->mVerts[2].ST[0] = 0.99f - oldAlpha; // NOTE: this just happens to contain the value I want
@@ -6682,7 +5600,7 @@ Ghoul2 Insert End
fx->mVerts[2].destST[1] = 0.0f;
// old muzzle
- VectorCopy( rgb1, fx->mVerts[3].rgb );
+ VectorCopy(rgb1, fx->mVerts[3].rgb);
fx->mVerts[3].alpha = 255.0f;
fx->mVerts[3].ST[0] = 0.99f - oldAlpha; // NOTE: this just happens to contain the value I want
@@ -6690,64 +5608,52 @@ Ghoul2 Insert End
fx->mVerts[3].destST[0] = 0.99f + fx->mVerts[2].ST[0];
fx->mVerts[3].destST[1] = 0.99f;
- // fx->SetFlags( FX_USE_ALPHA );
- FX_AddPrimitive( (CEffect**)&fx, duration );//SABER_TRAIL_TIME );
+ // fx->SetFlags( FX_USE_ALPHA );
+ FX_AddPrimitive((CEffect **)&fx, duration); // SABER_TRAIL_TIME );
}
}
// we must always do this, even if we aren't active..otherwise we won't know where to pick up from
- VectorCopy( org_, saberTrail->base );
- VectorMA( end, 3.0f, axis_[0], saberTrail->tip );
+ VectorCopy(org_, saberTrail->base);
+ VectorMA(end, 3.0f, axis_[0], saberTrail->tip);
saberTrail->lastTime = cg.time;
}
}
- if ( cent->gent->client->ps.saber[saberNum].type == SABER_SITH_SWORD)
- {
+ if (cent->gent->client->ps.saber[saberNum].type == SABER_SITH_SWORD) {
// don't need to do nuthin else
return;
}
qboolean noDlight = qfalse;
- if ( client->ps.saber[saberNum].numBlades >= 3
- || (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && (client->ps.saber[saberNum].saberFlags2&SFL2_NO_DLIGHT) )
- || ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && (client->ps.saber[saberNum].saberFlags2&SFL2_NO_DLIGHT2) )
- )
- {
+ if (client->ps.saber[saberNum].numBlades >= 3 ||
+ (!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && (client->ps.saber[saberNum].saberFlags2 & SFL2_NO_DLIGHT)) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && (client->ps.saber[saberNum].saberFlags2 & SFL2_NO_DLIGHT2))) {
noDlight = qtrue;
}
- if ( (!WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && (client->ps.saber[saberNum].saberFlags2&SFL2_NO_BLADE) )
- || ( WP_SaberBladeUseSecondBladeStyle( &client->ps.saber[saberNum], bladeNum ) && (client->ps.saber[saberNum].saberFlags2&SFL2_NO_BLADE2) ) )
- {//don't draw a blade
- if ( !noDlight )
- {//but still do dlight
- CG_DoSaberLight( &client->ps.saber[saberNum] );
+ if ((!WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) && (client->ps.saber[saberNum].saberFlags2 & SFL2_NO_BLADE)) ||
+ (WP_SaberBladeUseSecondBladeStyle(&client->ps.saber[saberNum], bladeNum) &&
+ (client->ps.saber[saberNum].saberFlags2 & SFL2_NO_BLADE2))) { // don't draw a blade
+ if (!noDlight) { // but still do dlight
+ CG_DoSaberLight(&client->ps.saber[saberNum]);
}
return;
}
// Pass in the renderfx flags attached to the saber weapon model...this is done so that saber glows
// will get rendered properly in a mirror...not sure if this is necessary??
- CG_DoSaber(
- org_, axis_[0], length,
- client->ps.saber[saberNum].blade[bladeNum].lengthMax,
- client->ps.saber[saberNum].blade[bladeNum].radius,
- client->ps.saber[saberNum].blade[bladeNum].color,
- renderfx, (qboolean)!noDlight );
+ CG_DoSaber(org_, axis_[0], length, client->ps.saber[saberNum].blade[bladeNum].lengthMax, client->ps.saber[saberNum].blade[bladeNum].radius,
+ client->ps.saber[saberNum].blade[bladeNum].color, renderfx, (qboolean)!noDlight);
}
-void CG_AddSaberBlade( centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles )
-{
- //FIXME: if this is a dropped saber, it could be possible that it's the second saber?
- if ( cent->gent->client )
- {
- for ( int i = 0; i < cent->gent->client->ps.saber[0].numBlades;i++ )
- {
- CG_AddSaberBladeGo( cent, scent, saber, renderfx, modelIndex, origin, angles, 0, i );
+void CG_AddSaberBlade(centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles) {
+ // FIXME: if this is a dropped saber, it could be possible that it's the second saber?
+ if (cent->gent->client) {
+ for (int i = 0; i < cent->gent->client->ps.saber[0].numBlades; i++) {
+ CG_AddSaberBladeGo(cent, scent, saber, renderfx, modelIndex, origin, angles, 0, i);
}
- if ( cent->gent->client->ps.saber[0].numBlades > 2 )
- {// add blended light
- CG_DoSaberLight( ¢->gent->client->ps.saber[0] );
+ if (cent->gent->client->ps.saber[0].numBlades > 2) { // add blended light
+ CG_DoSaberLight(¢->gent->client->ps.saber[0]);
}
}
}
@@ -6811,360 +5717,314 @@ CG_Player
===============
*/
-extern qboolean G_GetRootSurfNameWithVariant( gentity_t *ent, const char *rootSurfName, char *returnSurfName, int returnSize );
-extern qboolean G_ControlledByPlayer( gentity_t *self );
+extern qboolean G_GetRootSurfNameWithVariant(gentity_t *ent, const char *rootSurfName, char *returnSurfName, int returnSize);
+extern qboolean G_ControlledByPlayer(gentity_t *self);
extern qboolean G_RagDoll(gentity_t *ent, vec3_t forcedAngles);
-int cg_saberOnSoundTime[MAX_GENTITIES] = {0};
+int cg_saberOnSoundTime[MAX_GENTITIES] = {0};
-void CG_Player( centity_t *cent ) {
- clientInfo_t *ci;
- qboolean shadow, staticScale = qfalse;
- float shadowPlane;
- const weaponData_t *wData = NULL;
+void CG_Player(centity_t *cent) {
+ clientInfo_t *ci;
+ qboolean shadow, staticScale = qfalse;
+ float shadowPlane;
+ const weaponData_t *wData = NULL;
- if ( cent->currentState.eFlags & EF_NODRAW )
- {
+ if (cent->currentState.eFlags & EF_NODRAW) {
return;
}
- //make sure this thing has a gent and client
- if(!cent->gent)
- {
+ // make sure this thing has a gent and client
+ if (!cent->gent) {
return;
}
- if(!cent->gent->client)
- {
+ if (!cent->gent->client) {
return;
}
- if( cent->gent->s.number == 0 && cg.weaponSelect == WP_NONE && cg.zoomMode == 1 )
- {
+ if (cent->gent->s.number == 0 && cg.weaponSelect == WP_NONE && cg.zoomMode == 1) {
// HACK
return;
}
calcedMp = qfalse;
- //Get the player's light level for stealth calculations
- CG_GetPlayerLightLevel( cent );
+ // Get the player's light level for stealth calculations
+ CG_GetPlayerLightLevel(cent);
- if ((in_camera) && cent->currentState.clientNum == 0 ) // If player in camera then no need for shadow
+ if ((in_camera) && cent->currentState.clientNum == 0) // If player in camera then no need for shadow
{
return;
}
- if(cent->currentState.number == 0 && !cg.renderingThirdPerson )//!cg_thirdPerson.integer )
+ if (cent->currentState.number == 0 && !cg.renderingThirdPerson) //! cg_thirdPerson.integer )
{
calcedMp = qtrue;
}
ci = ¢->gent->client->clientInfo;
- if ( !ci->infoValid )
- {
+ if (!ci->infoValid) {
return;
}
G_RagDoll(cent->gent, cent->lerpAngles);
- if ( cent->currentState.weapon )
- {
+ if (cent->currentState.weapon) {
wData = &weaponData[cent->currentState.weapon];
}
-/*
-Ghoul2 Insert Start
-*/
- if (cent->gent->ghoul2.size()) //do we have ghoul models attached?
+ /*
+ Ghoul2 Insert Start
+ */
+ if (cent->gent->ghoul2.size()) // do we have ghoul models attached?
{
- refEntity_t ent;
- vec3_t tempAngles;
- memset (&ent, 0, sizeof(ent));
+ refEntity_t ent;
+ vec3_t tempAngles;
+ memset(&ent, 0, sizeof(ent));
- //FIXME: if at all possible, do all our sets before our gets to do only *1* G2 skeleton transform per render frame
+ // FIXME: if at all possible, do all our sets before our gets to do only *1* G2 skeleton transform per render frame
CG_SetGhoul2Info(&ent, cent);
// Weapon sounds may need to be stopped, so check now
- CG_StopWeaponSounds( cent );
+ CG_StopWeaponSounds(cent);
// add powerups floating behind the player
- CG_PlayerPowerups( cent );
+ CG_PlayerPowerups(cent);
// add the shadow
- //FIXME: funcs that modify our origin below will cause the shadow to be in the wrong spot
- shadow = CG_PlayerShadow( cent, &shadowPlane );
+ // FIXME: funcs that modify our origin below will cause the shadow to be in the wrong spot
+ shadow = CG_PlayerShadow(cent, &shadowPlane);
// add a water splash if partially in and out of water
- CG_PlayerSplash( cent );
+ CG_PlayerSplash(cent);
// get the player model information
ent.renderfx = 0;
- if ( !cg.renderingThirdPerson || cg.zoomMode )
- {//in first person or zoomed in
- if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD)
- {//no viewentity
- if ( cent->currentState.number == cg.snap->ps.clientNum )
- {//I am the player
- if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
- {//not using saber or fists
- ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
+ if (!cg.renderingThirdPerson || cg.zoomMode) { // in first person or zoomed in
+ if (cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD) { // no viewentity
+ if (cent->currentState.number == cg.snap->ps.clientNum) { // I am the player
+ if (cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE) { // not using saber or fists
+ ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
}
- }
- else if ( cent->currentState.number == cg.snap->ps.viewEntity )
- {//I am the view entity
- if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
- {//not using first person saber test or, if so, not using saber
- ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
+ } else if (cent->currentState.number == cg.snap->ps.viewEntity) { // I am the view entity
+ if (cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE) { // not using first person saber test or, if so, not using saber
+ ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
}
}
- if ( cent->gent->client->ps.powerups[PW_DISINT_2] > cg.time )
- {//ghost!
- ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
- }
- else if (cg_shadows.integer == 2 && (ent.renderfx & RF_THIRD_PERSON))
- { //show stencil shadow in first person now because we can -rww
+ if (cent->gent->client->ps.powerups[PW_DISINT_2] > cg.time) { // ghost!
+ ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
+ } else if (cg_shadows.integer == 2 && (ent.renderfx & RF_THIRD_PERSON)) { // show stencil shadow in first person now because we can -rww
ent.renderfx |= RF_SHADOW_ONLY;
}
- if ( (cg_shadows.integer == 2 && !in_camera) || (cg_shadows.integer == 3 && shadow) )
- {
+ if ((cg_shadows.integer == 2 && !in_camera) || (cg_shadows.integer == 3 && shadow)) {
ent.renderfx |= RF_SHADOW_PLANE;
}
ent.shadowPlane = shadowPlane;
- ent.renderfx |= RF_LIGHTING_ORIGIN; // use the same origin for all
- if ( cent->gent->NPC && cent->gent->NPC->scriptFlags & SCF_MORELIGHT )
- {
- ent.renderfx |= RF_MORELIGHT; //bigger than normal min light
+ ent.renderfx |= RF_LIGHTING_ORIGIN; // use the same origin for all
+ if (cent->gent->NPC && cent->gent->NPC->scriptFlags & SCF_MORELIGHT) {
+ ent.renderfx |= RF_MORELIGHT; // bigger than normal min light
}
- CG_RegisterWeapon( cent->currentState.weapon );
+ CG_RegisterWeapon(cent->currentState.weapon);
-//---------------
+ //---------------
Vehicle_t *pVeh;
- if ( cent->currentState.eFlags & EF_LOCKED_TO_WEAPON && cent->gent && cent->gent->health > 0 && cent->gent->owner )
- {
- centity_t *chair = &cg_entities[cent->gent->owner->s.number];
- if ( chair && chair->gent )
- {
- vec3_t temp;
- mdxaBone_t boltMatrix;
+ if (cent->currentState.eFlags & EF_LOCKED_TO_WEAPON && cent->gent && cent->gent->health > 0 && cent->gent->owner) {
+ centity_t *chair = &cg_entities[cent->gent->owner->s.number];
+ if (chair && chair->gent) {
+ vec3_t temp;
+ mdxaBone_t boltMatrix;
- //NOTE: call this so it updates on the server and client
- if ( chair->gent->bounceCount )
- {//EWeb
+ // NOTE: call this so it updates on the server and client
+ if (chair->gent->bounceCount) { // EWeb
// We'll set the turret angles directly
- VectorClear( temp );
- VectorClear( chair->gent->pos1 );
+ VectorClear(temp);
+ VectorClear(chair->gent->pos1);
temp[PITCH] = cent->lerpAngles[PITCH];
- chair->gent->pos1[YAW] = AngleSubtract( cent->lerpAngles[YAW], chair->gent->s.angles[YAW] );//remember which dir our turret is facing for later
+ chair->gent->pos1[YAW] =
+ AngleSubtract(cent->lerpAngles[YAW], chair->gent->s.angles[YAW]); // remember which dir our turret is facing for later
cent->lerpAngles[ROLL] = 0;
- BG_G2SetBoneAngles( chair, chair->gent, chair->gent->lowerLumbarBone, chair->gent->pos1, BONE_ANGLES_POSTMULT, POSITIVE_Z, NEGATIVE_X, NEGATIVE_Y, cgs.model_draw );
- BG_G2SetBoneAngles( chair, chair->gent, chair->gent->upperLumbarBone, temp, BONE_ANGLES_POSTMULT, POSITIVE_Z, NEGATIVE_X, NEGATIVE_Y, cgs.model_draw );
- }
- else
- {
+ BG_G2SetBoneAngles(chair, chair->gent, chair->gent->lowerLumbarBone, chair->gent->pos1, BONE_ANGLES_POSTMULT, POSITIVE_Z, NEGATIVE_X,
+ NEGATIVE_Y, cgs.model_draw);
+ BG_G2SetBoneAngles(chair, chair->gent, chair->gent->upperLumbarBone, temp, BONE_ANGLES_POSTMULT, POSITIVE_Z, NEGATIVE_X, NEGATIVE_Y,
+ cgs.model_draw);
+ } else {
// We'll set the turret yaw directly
- VectorClear( chair->gent->s.apos.trBase );
- VectorClear( temp );
+ VectorClear(chair->gent->s.apos.trBase);
+ VectorClear(temp);
chair->gent->s.apos.trBase[YAW] = cent->lerpAngles[YAW];
temp[PITCH] = -cent->lerpAngles[PITCH];
cent->lerpAngles[ROLL] = 0;
- BG_G2SetBoneAngles( chair, chair->gent, chair->gent->lowerLumbarBone, temp, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, cgs.model_draw );
+ BG_G2SetBoneAngles(chair, chair->gent, chair->gent->lowerLumbarBone, temp, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X,
+ cgs.model_draw);
}
- //gi.G2API_SetBoneAngles( &chair->gent->ghoul2[0], "swivel_bone", temp, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, cgs.model_draw );
- VectorCopy( temp, chair->gent->lastAngles );
+ // gi.G2API_SetBoneAngles( &chair->gent->ghoul2[0], "swivel_bone", temp, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X,
+ // cgs.model_draw );
+ VectorCopy(temp, chair->gent->lastAngles);
- gi.G2API_StopBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone );
+ gi.G2API_StopBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->hipsBone);
// Getting the seat bolt here
- gi.G2API_GetBoltMatrix( chair->gent->ghoul2, chair->gent->playerModel, chair->gent->headBolt,
- &boltMatrix, chair->gent->s.apos.trBase, chair->gent->currentOrigin, cg.time,
- cgs.model_draw, chair->currentState.modelScale );
-
- if ( chair->gent->bounceCount )
- {//put behind it, not in chair
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, ent.origin );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, chair->gent->pos3 );
+ gi.G2API_GetBoltMatrix(chair->gent->ghoul2, chair->gent->playerModel, chair->gent->headBolt, &boltMatrix, chair->gent->s.apos.trBase,
+ chair->gent->currentOrigin, cg.time, cgs.model_draw, chair->currentState.modelScale);
+
+ if (chair->gent->bounceCount) { // put behind it, not in chair
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, ent.origin);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, chair->gent->pos3);
chair->gent->pos3[2] = 0;
- VectorNormalizeFast( chair->gent->pos3 );
- VectorMA( ent.origin, -44.0f, chair->gent->pos3, ent.origin );
+ VectorNormalizeFast(chair->gent->pos3);
+ VectorMA(ent.origin, -44.0f, chair->gent->pos3, ent.origin);
ent.origin[2] = cent->lerpOrigin[2];
- cent->lerpAngles[YAW] = vectoyaw( chair->gent->pos3 );
+ cent->lerpAngles[YAW] = vectoyaw(chair->gent->pos3);
cent->lerpAngles[ROLL] = 0;
- CG_G2PlayerAngles( cent, ent.axis, tempAngles);
+ CG_G2PlayerAngles(cent, ent.axis, tempAngles);
calcedMp = qtrue;
- }
- else
- {//sitting in it
+ } else { // sitting in it
// Storing ent position, bolt position, and bolt axis
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, ent.origin );
- VectorCopy( ent.origin, chair->gent->pos2 );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_Y, chair->gent->pos3 );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Z, chair->gent->pos4 );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, ent.origin);
+ VectorCopy(ent.origin, chair->gent->pos2);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Y, chair->gent->pos3);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Z, chair->gent->pos4);
- AnglesToAxis( cent->lerpAngles, ent.axis );
- VectorCopy( cent->lerpAngles, tempAngles);//tempAngles is needed a lot below
+ AnglesToAxis(cent->lerpAngles, ent.axis);
+ VectorCopy(cent->lerpAngles, tempAngles); // tempAngles is needed a lot below
}
- VectorCopy( ent.origin, ent.oldorigin );
- VectorCopy( ent.origin, ent.lightingOrigin );
+ VectorCopy(ent.origin, ent.oldorigin);
+ VectorCopy(ent.origin, ent.lightingOrigin);
// FIXME: Mike claims that hacking the eyepoint will make them shoot at me.......so,
// we move up from the seat bolt and store off that point.
- // VectorMA( ent.origin, -20, chair->gent->pos3, cent->gent->client->renderInfo.eyePoint );
- // VectorMA( cent->gent->client->renderInfo.eyePoint, 40, chair->gent->pos4, cent->gent->client->renderInfo.eyePoint );
+ // VectorMA( ent.origin, -20, chair->gent->pos3, cent->gent->client->renderInfo.eyePoint );
+ // VectorMA( cent->gent->client->renderInfo.eyePoint, 40, chair->gent->pos4, cent->gent->client->renderInfo.eyePoint );
}
- }
- else if ( ( pVeh = G_IsRidingVehicle( cent->gent ) ) != NULL )
- {//rider
- CG_G2PlayerAngles( cent, ent.axis, tempAngles);
- //Deal with facial expressions
- CG_G2PlayerHeadAnims( cent );
+ } else if ((pVeh = G_IsRidingVehicle(cent->gent)) != NULL) { // rider
+ CG_G2PlayerAngles(cent, ent.axis, tempAngles);
+ // Deal with facial expressions
+ CG_G2PlayerHeadAnims(cent);
centity_t *vehEnt = &cg_entities[cent->gent->owner->s.number];
- CG_CalcEntityLerpPositions( vehEnt );
+ CG_CalcEntityLerpPositions(vehEnt);
// Get the driver tag.
- mdxaBone_t boltMatrix;
- gi.G2API_GetBoltMatrix( vehEnt->gent->ghoul2, vehEnt->gent->playerModel, vehEnt->gent->crotchBolt,
- &boltMatrix, vehEnt->lerpAngles, vehEnt->lerpOrigin, (cg.time?cg.time:level.time), NULL, vehEnt->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, ent.origin );
+ mdxaBone_t boltMatrix;
+ gi.G2API_GetBoltMatrix(vehEnt->gent->ghoul2, vehEnt->gent->playerModel, vehEnt->gent->crotchBolt, &boltMatrix, vehEnt->lerpAngles,
+ vehEnt->lerpOrigin, (cg.time ? cg.time : level.time), NULL, vehEnt->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, ent.origin);
float savPitch = cent->lerpAngles[PITCH];
- VectorCopy( vehEnt->lerpAngles, cent->lerpAngles );
- AnglesToAxis( cent->lerpAngles, ent.axis );
+ VectorCopy(vehEnt->lerpAngles, cent->lerpAngles);
+ AnglesToAxis(cent->lerpAngles, ent.axis);
- VectorCopy( ent.origin, ent.oldorigin );
- VectorCopy( ent.origin, ent.lightingOrigin );
+ VectorCopy(ent.origin, ent.oldorigin);
+ VectorCopy(ent.origin, ent.lightingOrigin);
- VectorCopy( cent->lerpAngles, tempAngles );//tempAngles is needed a lot below
- VectorCopy( ent.origin, cent->lerpOrigin );
- VectorCopy( ent.origin, cent->gent->client->ps.origin );
- //bah, keep our pitch!
+ VectorCopy(cent->lerpAngles, tempAngles); // tempAngles is needed a lot below
+ VectorCopy(ent.origin, cent->lerpOrigin);
+ VectorCopy(ent.origin, cent->gent->client->ps.origin);
+ // bah, keep our pitch!
cent->lerpAngles[PITCH] = savPitch;
- }
- else if ( ( (cent->gent->client->ps.eFlags&EF_HELD_BY_RANCOR)||(cent->gent->client->ps.eFlags&EF_HELD_BY_WAMPA) )
- && cent->gent && cent->gent->activator )
- {
- centity_t *monster = &cg_entities[cent->gent->activator->s.number];
- if ( monster && monster->gent && monster->gent->inuse && monster->gent->health > 0 )
- {
- mdxaBone_t boltMatrix;
+ } else if (((cent->gent->client->ps.eFlags & EF_HELD_BY_RANCOR) || (cent->gent->client->ps.eFlags & EF_HELD_BY_WAMPA)) && cent->gent &&
+ cent->gent->activator) {
+ centity_t *monster = &cg_entities[cent->gent->activator->s.number];
+ if (monster && monster->gent && monster->gent->inuse && monster->gent->health > 0) {
+ mdxaBone_t boltMatrix;
// Getting the bolt here
- //in mouth
+ // in mouth
int boltIndex = monster->gent->gutBolt;
- if ( monster->gent->count == 1 )
- {//in hand
+ if (monster->gent->count == 1) { // in hand
boltIndex = monster->gent->handRBolt;
}
vec3_t rancAngles = {0};
rancAngles[YAW] = monster->lerpAngles[YAW];
- gi.G2API_GetBoltMatrix( monster->gent->ghoul2, monster->gent->playerModel, boltIndex,
- &boltMatrix, rancAngles, monster->lerpOrigin, cg.time,
- cgs.model_draw, monster->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(monster->gent->ghoul2, monster->gent->playerModel, boltIndex, &boltMatrix, rancAngles, monster->lerpOrigin, cg.time,
+ cgs.model_draw, monster->currentState.modelScale);
// Storing ent position, bolt position, and bolt axis
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, ent.origin );
- if ( (cent->gent->client->ps.eFlags&EF_HELD_BY_WAMPA) )
- {
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, ent.axis[0] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_X, ent.axis[1] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_Z, ent.axis[2] );
- }
- else if ( monster->gent->count == 1 )
- {
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, ent.axis[0] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_X, ent.axis[1] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_Z, ent.axis[2] );
- }
- else
- {
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_Z, ent.axis[0] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, ent.axis[1] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_X, ent.axis[2] );
- }
- //FIXME: this is messing up our axis and turning us inside-out
- if ( cent->gent->client->isRagging )
- {//hack, ragdoll has you way at bottom of bounding box
- VectorMA( ent.origin, 32, ent.axis[2], ent.origin );
- }
- VectorCopy( ent.origin, ent.oldorigin );
- VectorCopy( ent.origin, ent.lightingOrigin );
-
- vectoangles( ent.axis[0], cent->lerpAngles );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, ent.origin);
+ if ((cent->gent->client->ps.eFlags & EF_HELD_BY_WAMPA)) {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, ent.axis[0]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_X, ent.axis[1]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, ent.axis[2]);
+ } else if (monster->gent->count == 1) {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, ent.axis[0]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_X, ent.axis[1]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, ent.axis[2]);
+ } else {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, ent.axis[0]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, ent.axis[1]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, ent.axis[2]);
+ }
+ // FIXME: this is messing up our axis and turning us inside-out
+ if (cent->gent->client->isRagging) { // hack, ragdoll has you way at bottom of bounding box
+ VectorMA(ent.origin, 32, ent.axis[2], ent.origin);
+ }
+ VectorCopy(ent.origin, ent.oldorigin);
+ VectorCopy(ent.origin, ent.lightingOrigin);
+
+ vectoangles(ent.axis[0], cent->lerpAngles);
vec3_t temp;
- vectoangles( ent.axis[2], temp );
+ vectoangles(ent.axis[2], temp);
cent->lerpAngles[ROLL] = -temp[PITCH];
- VectorCopy( cent->lerpAngles, tempAngles );//tempAngles is needed a lot below
- VectorCopy( ent.origin, cent->lerpOrigin );
- VectorCopy( ent.origin, cent->gent->client->ps.origin );
- // if ( (cent->gent->client->ps.eFlags&EF_HELD_BY_WAMPA) )
- // {
- vectoangles( ent.axis[0], cent->lerpAngles );
- VectorCopy( cent->lerpAngles, tempAngles );//tempAngles is needed a lot below
- // }
- // else
- // {
- // //cent->gent->client->ps.viewangles[YAW] = cent->lerpAngles[YAW];
- // }
- }
- else
- {//wtf happened to the guy holding me? Better get out
+ VectorCopy(cent->lerpAngles, tempAngles); // tempAngles is needed a lot below
+ VectorCopy(ent.origin, cent->lerpOrigin);
+ VectorCopy(ent.origin, cent->gent->client->ps.origin);
+ // if ( (cent->gent->client->ps.eFlags&EF_HELD_BY_WAMPA) )
+ // {
+ vectoangles(ent.axis[0], cent->lerpAngles);
+ VectorCopy(cent->lerpAngles, tempAngles); // tempAngles is needed a lot below
+ // }
+ // else
+ // {
+ // //cent->gent->client->ps.viewangles[YAW] = cent->lerpAngles[YAW];
+ // }
+ } else { // wtf happened to the guy holding me? Better get out
cent->gent->activator = NULL;
- cent->gent->client->ps.eFlags &= ~(EF_HELD_BY_WAMPA|EF_HELD_BY_RANCOR);
+ cent->gent->client->ps.eFlags &= ~(EF_HELD_BY_WAMPA | EF_HELD_BY_RANCOR);
}
- }
- else if ( (cent->gent->client->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
- && cent->gent
- && cent->gent->activator )
- {
- centity_t *sand_creature = &cg_entities[cent->gent->activator->s.number];
- if ( sand_creature && sand_creature->gent )
- {
- mdxaBone_t boltMatrix;
+ } else if ((cent->gent->client->ps.eFlags & EF_HELD_BY_SAND_CREATURE) && cent->gent && cent->gent->activator) {
+ centity_t *sand_creature = &cg_entities[cent->gent->activator->s.number];
+ if (sand_creature && sand_creature->gent) {
+ mdxaBone_t boltMatrix;
// Getting the bolt here
- //in hand
+ // in hand
vec3_t scAngles = {0};
scAngles[YAW] = sand_creature->lerpAngles[YAW];
- gi.G2API_GetBoltMatrix( sand_creature->gent->ghoul2, sand_creature->gent->playerModel, sand_creature->gent->gutBolt,
- &boltMatrix, scAngles, sand_creature->lerpOrigin, cg.time,
- cgs.model_draw, sand_creature->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(sand_creature->gent->ghoul2, sand_creature->gent->playerModel, sand_creature->gent->gutBolt, &boltMatrix, scAngles,
+ sand_creature->lerpOrigin, cg.time, cgs.model_draw, sand_creature->currentState.modelScale);
// Storing ent position, bolt position, and bolt axis
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, ent.origin );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, ent.axis[0] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_X, ent.axis[1] );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, POSITIVE_Z, ent.axis[2] );
- //FIXME: this is messing up our axis and turning us inside-out
- if ( cent->gent->client->isRagging )
- {//hack, ragdoll has you way at bottom of bounding box
- VectorMA( ent.origin, 32, ent.axis[2], ent.origin );
- }
- VectorCopy( ent.origin, ent.oldorigin );
- VectorCopy( ent.origin, ent.lightingOrigin );
-
- vectoangles( ent.axis[0], cent->lerpAngles );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, ent.origin);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, ent.axis[0]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, ent.axis[1]);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, ent.axis[2]);
+ // FIXME: this is messing up our axis and turning us inside-out
+ if (cent->gent->client->isRagging) { // hack, ragdoll has you way at bottom of bounding box
+ VectorMA(ent.origin, 32, ent.axis[2], ent.origin);
+ }
+ VectorCopy(ent.origin, ent.oldorigin);
+ VectorCopy(ent.origin, ent.lightingOrigin);
+
+ vectoangles(ent.axis[0], cent->lerpAngles);
vec3_t temp;
- vectoangles( ent.axis[2], temp );
+ vectoangles(ent.axis[2], temp);
cent->lerpAngles[ROLL] = -temp[PITCH];
- VectorCopy( cent->lerpAngles, tempAngles );//tempAngles is needed a lot below
- VectorCopy( ent.origin, cent->lerpOrigin );
- VectorCopy( ent.origin, cent->gent->client->ps.origin );
+ VectorCopy(cent->lerpAngles, tempAngles); // tempAngles is needed a lot below
+ VectorCopy(ent.origin, cent->lerpOrigin);
+ VectorCopy(ent.origin, cent->gent->client->ps.origin);
cent->gent->client->ps.viewangles[YAW] = cent->lerpAngles[YAW];
}
- }
- else
- {
-//---------------
- CG_G2PlayerAngles( cent, ent.axis, tempAngles);
- //Deal with facial expressions
- CG_G2PlayerHeadAnims( cent );
+ } else {
+ //---------------
+ CG_G2PlayerAngles(cent, ent.axis, tempAngles);
+ // Deal with facial expressions
+ CG_G2PlayerHeadAnims(cent);
/*
if ( cent->gent->client->ps.eFlags & EF_FORCE_DRAINED
@@ -7174,25 +6034,21 @@ Ghoul2 Insert Start
}
else
*/
- {
- VectorCopy( cent->lerpOrigin, ent.origin);
- }
+ { VectorCopy(cent->lerpOrigin, ent.origin); }
- if (ent.modelScale[2] && ent.modelScale[2] != 1.0f)
- {
+ if (ent.modelScale[2] && ent.modelScale[2] != 1.0f) {
ent.origin[2] += 24 * (ent.modelScale[2] - 1);
}
- VectorCopy( ent.origin, ent.oldorigin);
- VectorCopy( ent.origin, ent.lightingOrigin );
+ VectorCopy(ent.origin, ent.oldorigin);
+ VectorCopy(ent.origin, ent.lightingOrigin);
}
- if ( cent->gent && cent->gent->client )
- {
+ if (cent->gent && cent->gent->client) {
cent->gent->client->ps.legsYaw = tempAngles[YAW];
}
ScaleModelAxis(&ent);
-//HACK - add swoop model
+ // HACK - add swoop model
/*
if ( cent->currentState.vehicleIndex != VEHICLE_NONE
&& g_vehicleInfo[cent->currentState.vehicleIndex].type == VH_SPEEDER )
@@ -7210,271 +6066,219 @@ Ghoul2 Insert Start
cgi_R_AddRefEntityToScene( &swoopEnt );
}
*/
-//HACK - add swoop model
+ // HACK - add swoop model
-extern vmCvar_t cg_thirdPersonAlpha;
+ extern vmCvar_t cg_thirdPersonAlpha;
- if ( (cent->gent->s.number == 0 || G_ControlledByPlayer( cent->gent )) )
- {
+ if ((cent->gent->s.number == 0 || G_ControlledByPlayer(cent->gent))) {
float alpha = 1.0f;
- if ( (cg.overrides.active&CG_OVERRIDE_3RD_PERSON_APH) )
- {
+ if ((cg.overrides.active & CG_OVERRIDE_3RD_PERSON_APH)) {
alpha = cg.overrides.thirdPersonAlpha;
- }
- else
- {
+ } else {
alpha = cg_thirdPersonAlpha.value;
}
- if ( alpha < 1.0f )
- {
+ if (alpha < 1.0f) {
ent.renderfx |= RF_ALPHA_FADE;
ent.shaderRGBA[3] = (unsigned char)(alpha * 255.0f);
}
}
- if ( cg_debugHealthBars.integer )
- {
- if ( cent->gent && cent->gent->health > 0 && cent->gent->max_health > 0 )
- {//draw a health bar over them
- CG_AddHealthBarEnt( cent->currentState.clientNum );
- }
- }
- CG_AddRefEntityWithPowerups( &ent, cent->currentState.powerups, cent );
- VectorCopy( tempAngles, cent->renderAngles );
-
- //Initialize all these to *some* valid data
- VectorCopy( ent.origin, cent->gent->client->renderInfo.headPoint );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.handRPoint );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.handLPoint );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.footRPoint );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.footLPoint );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.torsoPoint );
- VectorCopy( cent->lerpAngles, cent->gent->client->renderInfo.torsoAngles );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.crotchPoint );
- if ( cent->currentState.number != 0
- || cg.renderingThirdPerson
- || cg.snap->ps.stats[STAT_HEALTH] <= 0
- || ( !cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) )//First person saber
- )
- {//in some third person mode or NPC
- //we don't override thes in pure 1st person because they will be set before this func
- VectorCopy( ent.origin, cent->gent->client->renderInfo.eyePoint );
- VectorCopy( cent->lerpAngles, cent->gent->client->renderInfo.eyeAngles );
- if ( !cent->gent->client->ps.saberInFlight )
- {
- VectorCopy( ent.origin, cent->gent->client->renderInfo.muzzlePoint );
- VectorCopy( ent.axis[0], cent->gent->client->renderInfo.muzzleDir );
+ if (cg_debugHealthBars.integer) {
+ if (cent->gent && cent->gent->health > 0 && cent->gent->max_health > 0) { // draw a health bar over them
+ CG_AddHealthBarEnt(cent->currentState.clientNum);
}
}
- //now try to get the right data
+ CG_AddRefEntityWithPowerups(&ent, cent->currentState.powerups, cent);
+ VectorCopy(tempAngles, cent->renderAngles);
- mdxaBone_t boltMatrix;
- vec3_t tempAxis, G2Angles = {0, tempAngles[YAW], 0};
+ // Initialize all these to *some* valid data
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.headPoint);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.handRPoint);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.handLPoint);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.footRPoint);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.footLPoint);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.torsoPoint);
+ VectorCopy(cent->lerpAngles, cent->gent->client->renderInfo.torsoAngles);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.crotchPoint);
+ if (cent->currentState.number != 0 || cg.renderingThirdPerson || cg.snap->ps.stats[STAT_HEALTH] <= 0 ||
+ (!cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)) // First person saber
+ ) { // in some third person mode or NPC
+ // we don't override thes in pure 1st person because they will be set before this func
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.eyePoint);
+ VectorCopy(cent->lerpAngles, cent->gent->client->renderInfo.eyeAngles);
+ if (!cent->gent->client->ps.saberInFlight) {
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.muzzlePoint);
+ VectorCopy(ent.axis[0], cent->gent->client->renderInfo.muzzleDir);
+ }
+ }
+ // now try to get the right data
- if ( cent->gent->handRBolt != -1 )
- {
- //Get handRPoint
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handRBolt,
- &boltMatrix, G2Angles, ent.origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.handRPoint );
+ mdxaBone_t boltMatrix;
+ vec3_t tempAxis, G2Angles = {0, tempAngles[YAW], 0};
+
+ if (cent->gent->handRBolt != -1) {
+ // Get handRPoint
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handRBolt, &boltMatrix, G2Angles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.handRPoint);
}
- if ( cent->gent->handLBolt != -1 )
- {
- //always get handLPoint too...?
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handLBolt,
- &boltMatrix, G2Angles, ent.origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.handLPoint );
+ if (cent->gent->handLBolt != -1) {
+ // always get handLPoint too...?
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->handLBolt, &boltMatrix, G2Angles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.handLPoint);
}
- if ( cent->gent->footLBolt != -1 )
- {
- //get the feet
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footLBolt,
- &boltMatrix, G2Angles, ent.origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.footLPoint );
+ if (cent->gent->footLBolt != -1) {
+ // get the feet
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footLBolt, &boltMatrix, G2Angles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.footLPoint);
}
- if ( cent->gent->footRBolt != -1 )
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footRBolt,
- &boltMatrix, G2Angles, ent.origin, cg.time,
- cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.footRPoint );
- }
-
- //Handle saber
- if ( cent->gent
- && cent->gent->client
- && ( cent->currentState.weapon == WP_SABER || cent->gent->client->ps.saberInFlight )
- && cent->gent->client->NPC_class != CLASS_ATST )
- {//FIXME: somehow saberactive is getting lost over the network
- //loop this and do for both sabers
- int numSabers = 1;
- if ( cent->gent->client->ps.dualSabers )
- {
+ if (cent->gent->footRBolt != -1) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->footRBolt, &boltMatrix, G2Angles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.footRPoint);
+ }
+
+ // Handle saber
+ if (cent->gent && cent->gent->client && (cent->currentState.weapon == WP_SABER || cent->gent->client->ps.saberInFlight) &&
+ cent->gent->client->NPC_class != CLASS_ATST) { // FIXME: somehow saberactive is getting lost over the network
+ // loop this and do for both sabers
+ int numSabers = 1;
+ if (cent->gent->client->ps.dualSabers) {
numSabers = 2;
}
- for ( int saberNum = 0; saberNum < numSabers; saberNum++ )
- {
- if ( cent->gent->client->ps.saberEventFlags&SEF_INWATER )
- {
+ for (int saberNum = 0; saberNum < numSabers; saberNum++) {
+ if (cent->gent->client->ps.saberEventFlags & SEF_INWATER) {
cent->gent->client->ps.saber[saberNum].Deactivate();
}
- //loop this and do for both blades
- for ( int bladeNum = 0; bladeNum < cent->gent->client->ps.saber[saberNum].numBlades; bladeNum++ )
- {
- if ( !cent->gent->client->ps.saber[saberNum].blade[bladeNum].active ||
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax )//hack around network lag for now
- {//saber blade is off
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > 0 )
- {
- if ( cent->gent->client->ps.stats[STAT_HEALTH] <= 0 )
- {//dead, didn't actively turn it off
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length -= cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax/10 * cg.frametime/100;
- }
- else
- {//actively turned it off, shrink faster
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length -= cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax/10 * cg.frametime/100;
+ // loop this and do for both blades
+ for (int bladeNum = 0; bladeNum < cent->gent->client->ps.saber[saberNum].numBlades; bladeNum++) {
+ if (!cent->gent->client->ps.saber[saberNum].blade[bladeNum].active ||
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length >
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax) // hack around network lag for now
+ { // saber blade is off
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > 0) {
+ if (cent->gent->client->ps.stats[STAT_HEALTH] <= 0) { // dead, didn't actively turn it off
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length -=
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax / 10 * cg.frametime / 100;
+ } else { // actively turned it off, shrink faster
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length -=
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax / 10 * cg.frametime / 100;
}
}
- }
- else
- {//saber blade is on
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax )
- {
- if ( !cent->gent->client->ps.saber[saberNum].blade[bladeNum].length )
- {
+ } else { // saber blade is on
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax) {
+ if (!cent->gent->client->ps.saber[saberNum].blade[bladeNum].length) {
qhandle_t saberOnSound = cgs.sound_precache[g_entities[cent->currentState.clientNum].client->ps.saber[saberNum].soundOn];
- if ( !cent->gent->client->ps.weaponTime
- && !saberNum//first saber only
- && !bladeNum )//first blade only
- {//make us play the turn on anim
+ if (!cent->gent->client->ps.weaponTime && !saberNum // first saber only
+ && !bladeNum) // first blade only
+ { // make us play the turn on anim
cent->gent->client->ps.weaponstate = WEAPON_RAISING;
cent->gent->client->ps.weaponTime = 250;
}
- if ( cent->gent->client->ps.saberInFlight && saberNum == 0 )
- {//play it on the saber
- if ( cg_saberOnSoundTime[cent->currentState.number] < cg.time )
- {
- cgi_S_UpdateEntityPosition( cent->gent->client->ps.saberEntityNum, g_entities[cent->gent->client->ps.saberEntityNum].currentOrigin );
- cgi_S_StartSound (NULL, cent->gent->client->ps.saberEntityNum, CHAN_AUTO, saberOnSound );
- cg_saberOnSoundTime[cent->currentState.number] = cg.time;//so we don't play multiple on sounds at one time
+ if (cent->gent->client->ps.saberInFlight && saberNum == 0) { // play it on the saber
+ if (cg_saberOnSoundTime[cent->currentState.number] < cg.time) {
+ cgi_S_UpdateEntityPosition(cent->gent->client->ps.saberEntityNum,
+ g_entities[cent->gent->client->ps.saberEntityNum].currentOrigin);
+ cgi_S_StartSound(NULL, cent->gent->client->ps.saberEntityNum, CHAN_AUTO, saberOnSound);
+ cg_saberOnSoundTime[cent->currentState.number] = cg.time; // so we don't play multiple on sounds at one time
}
- }
- else
- {
- if ( cg_saberOnSoundTime[cent->currentState.number] < cg.time )
- {
- cgi_S_StartSound (NULL, cent->currentState.number, CHAN_AUTO, saberOnSound );
- cg_saberOnSoundTime[cent->currentState.number] = cg.time;//so we don't play multiple on sounds at one time
+ } else {
+ if (cg_saberOnSoundTime[cent->currentState.number] < cg.time) {
+ cgi_S_StartSound(NULL, cent->currentState.number, CHAN_AUTO, saberOnSound);
+ cg_saberOnSoundTime[cent->currentState.number] = cg.time; // so we don't play multiple on sounds at one time
}
}
}
- if ( cg.frametime > 0 )
- {
- if ( PM_SuperBreakWinAnim( cent->gent->client->ps.torsoAnim ) )
- {//just keep it full length!
- //NOTE: does this mean it will go through walls now...?
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax;
- }
- else
- {
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length += cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax/10 * cg.frametime/100;
+ if (cg.frametime > 0) {
+ if (PM_SuperBreakWinAnim(cent->gent->client->ps.torsoAnim)) { // just keep it full length!
+ // NOTE: does this mean it will go through walls now...?
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length =
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax;
+ } else {
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length +=
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax / 10 * cg.frametime / 100;
}
}
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax )
- {
- cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax;
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length >
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax) {
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].length =
+ cent->gent->client->ps.saber[saberNum].blade[bladeNum].lengthMax;
}
}
}
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > 0 )
- {
- if ( !cent->gent->client->ps.saberInFlight || saberNum != 0 )//&& cent->gent->client->ps.saberActive)
- {//holding the saber in-hand
- // CGhoul2Info *currentModel = ¢->gent->ghoul2[1];
- // CGhoul2Info *nextModel = ¢->gent->ghoul2[1];
- //FIXME: need a version of this that *doesn't* need the mFileName in the ghoul2
- //FIXME: use an actual surfaceIndex?
- char handName[MAX_QPATH];
- if ( saberNum == 0 )
- {
- //this returns qfalse if it doesn't exist or isn't being rendered
- if ( G_GetRootSurfNameWithVariant( cent->gent, "r_hand", handName, sizeof(handName) ) ) //!gi.G2API_GetSurfaceRenderStatus( ¢->gent->ghoul2[cent->gent->playerModel], "r_hand" ) )//surf is still on
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > 0) {
+ if (!cent->gent->client->ps.saberInFlight || saberNum != 0) //&& cent->gent->client->ps.saberActive)
+ { // holding the saber in-hand
+ // CGhoul2Info *currentModel = ¢->gent->ghoul2[1];
+ // CGhoul2Info *nextModel = ¢->gent->ghoul2[1];
+ // FIXME: need a version of this that *doesn't* need the mFileName in the ghoul2
+ // FIXME: use an actual surfaceIndex?
+ char handName[MAX_QPATH];
+ if (saberNum == 0) {
+ // this returns qfalse if it doesn't exist or isn't being rendered
+ if (G_GetRootSurfNameWithVariant(
+ cent->gent, "r_hand", handName,
+ sizeof(handName))) //! gi.G2API_GetSurfaceRenderStatus( ¢->gent->ghoul2[cent->gent->playerModel], "r_hand" ) )//surf
+ //! is still on
{
- CG_AddSaberBladeGo( cent, cent, NULL, ent.renderfx, cent->gent->weaponModel[saberNum], ent.origin, tempAngles, saberNum, bladeNum );
- //CG_AddSaberBlades( cent, ent.renderfx, ent.origin, tempAngles, saberNum );
- }//else, the limb will draw the blade itself
- }
- else if ( saberNum == 1 )
- {
- //this returns qfalse if it doesn't exist or isn't being rendered
- if ( G_GetRootSurfNameWithVariant( cent->gent, "l_hand", handName, sizeof(handName) ) ) //!gi.G2API_GetSurfaceRenderStatus( ¢->gent->ghoul2[cent->gent->playerModel], "l_hand" ) )//surf is still on
+ CG_AddSaberBladeGo(cent, cent, NULL, ent.renderfx, cent->gent->weaponModel[saberNum], ent.origin, tempAngles, saberNum,
+ bladeNum);
+ // CG_AddSaberBlades( cent, ent.renderfx, ent.origin, tempAngles, saberNum );
+ } // else, the limb will draw the blade itself
+ } else if (saberNum == 1) {
+ // this returns qfalse if it doesn't exist or isn't being rendered
+ if (G_GetRootSurfNameWithVariant(
+ cent->gent, "l_hand", handName,
+ sizeof(handName))) //! gi.G2API_GetSurfaceRenderStatus( ¢->gent->ghoul2[cent->gent->playerModel], "l_hand" ) )//surf
+ //! is still on
{
- CG_AddSaberBladeGo( cent, cent, NULL, ent.renderfx, cent->gent->weaponModel[saberNum], ent.origin, tempAngles, saberNum, bladeNum );
- //CG_AddSaberBlades( cent, ent.renderfx, ent.origin, tempAngles, saberNum );
- }//else, the limb will draw the blade itself
+ CG_AddSaberBladeGo(cent, cent, NULL, ent.renderfx, cent->gent->weaponModel[saberNum], ent.origin, tempAngles, saberNum,
+ bladeNum);
+ // CG_AddSaberBlades( cent, ent.renderfx, ent.origin, tempAngles, saberNum );
+ } // else, the limb will draw the blade itself
}
- }//in-flight saber draws it's own blade
- }
- else
- {
- if ( cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < 0 )
- {
+ } // in-flight saber draws it's own blade
+ } else {
+ if (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length < 0) {
cent->gent->client->ps.saber[saberNum].blade[bladeNum].length = 0;
}
- //if ( cent->gent->client->ps.saberEventFlags&SEF_INWATER )
- {
- CG_CheckSaberInWater( cent, cent, saberNum, cent->gent->weaponModel[saberNum], ent.origin, tempAngles );
- }
+ // if ( cent->gent->client->ps.saberEventFlags&SEF_INWATER )
+ { CG_CheckSaberInWater(cent, cent, saberNum, cent->gent->weaponModel[saberNum], ent.origin, tempAngles); }
}
- if ( cent->currentState.weapon == WP_SABER
- && (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > 0 || cent->gent->client->ps.saberInFlight) )
- {
+ if (cent->currentState.weapon == WP_SABER &&
+ (cent->gent->client->ps.saber[saberNum].blade[bladeNum].length > 0 || cent->gent->client->ps.saberInFlight)) {
calcedMp = qtrue;
}
}
}
- //add the light
- if ( cent->gent->client->ps.dualSabers )
- {
- if ( cent->gent->client->ps.saber[0].Length() > 0.0f
- && !cent->gent->client->ps.saberInFlight )
- {
- if ( cent->gent->client->ps.saber[0].numBlades > 2 )
- {// add blended light
- CG_DoSaberLight( ¢->gent->client->ps.saber[0] );
+ // add the light
+ if (cent->gent->client->ps.dualSabers) {
+ if (cent->gent->client->ps.saber[0].Length() > 0.0f && !cent->gent->client->ps.saberInFlight) {
+ if (cent->gent->client->ps.saber[0].numBlades > 2) { // add blended light
+ CG_DoSaberLight(¢->gent->client->ps.saber[0]);
}
}
- if ( cent->gent->client->ps.saber[1].Length() > 0.0f )
- {
- if ( cent->gent->client->ps.saber[1].numBlades > 2 )
- {// add blended light
- CG_DoSaberLight( ¢->gent->client->ps.saber[1] );
+ if (cent->gent->client->ps.saber[1].Length() > 0.0f) {
+ if (cent->gent->client->ps.saber[1].numBlades > 2) { // add blended light
+ CG_DoSaberLight(¢->gent->client->ps.saber[1]);
}
}
- }
- else if ( cent->gent->client->ps.saber[0].Length() > 0.0f
- && !cent->gent->client->ps.saberInFlight )
- {
- if ( cent->gent->client->ps.saber[0].numBlades > 2 )
- {// add blended light
- CG_DoSaberLight( ¢->gent->client->ps.saber[0] );
+ } else if (cent->gent->client->ps.saber[0].Length() > 0.0f && !cent->gent->client->ps.saberInFlight) {
+ if (cent->gent->client->ps.saber[0].numBlades > 2) { // add blended light
+ CG_DoSaberLight(¢->gent->client->ps.saber[0]);
}
}
}
- if ( cent->currentState.number != 0
- || cg.renderingThirdPerson
- || cg.snap->ps.stats[STAT_HEALTH] <= 0
- || ( !cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) )//First person saber
- )
- {//if NPC, third person, or dead, unless using saber
- //Get eyePoint & eyeAngles
+ if (cent->currentState.number != 0 || cg.renderingThirdPerson || cg.snap->ps.stats[STAT_HEALTH] <= 0 ||
+ (!cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)) // First person saber
+ ) { // if NPC, third person, or dead, unless using saber
+ // Get eyePoint & eyeAngles
/*
if ( cg.snap->ps.viewEntity > 0
&& cg.snap->ps.viewEntity < ENTITYNUM_WORLD
@@ -7485,235 +6289,194 @@ extern vmCvar_t cg_thirdPersonAlpha;
VectorCopy( ent.origin, cent->gent->client->renderInfo.headPoint );
}
else
- */if ( cent->gent->headBolt == -1 )
- {//no headBolt
- VectorCopy( ent.origin, cent->gent->client->renderInfo.eyePoint );
- VectorCopy( tempAngles, cent->gent->client->renderInfo.eyeAngles );
- VectorCopy( ent.origin, cent->gent->client->renderInfo.headPoint );
- }
- else
- {
- //FIXME: if head is missing, we should let the dismembered head set our eyePoint...
- gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->headBolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ */
+ if (cent->gent->headBolt == -1) { // no headBolt
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.eyePoint);
+ VectorCopy(tempAngles, cent->gent->client->renderInfo.eyeAngles);
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.headPoint);
+ } else {
+ // FIXME: if head is missing, we should let the dismembered head set our eyePoint...
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->headBolt, &boltMatrix, tempAngles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.eyePoint);
- if ( cent->gent->client->NPC_class == CLASS_RANCOR )
- {//temp hack
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_X, tempAxis);
- }
- else
- {
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, tempAxis);
+ if (cent->gent->client->NPC_class == CLASS_RANCOR) { // temp hack
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_X, tempAxis);
+ } else {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, tempAxis);
}
- vectoangles( tempAxis, cent->gent->client->renderInfo.eyeAngles );
- //estimate where the neck would be...
- gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Z, tempAxis);//go down to find neck
- VectorMA( cent->gent->client->renderInfo.eyePoint, 8, tempAxis, cent->gent->client->renderInfo.headPoint );
+ vectoangles(tempAxis, cent->gent->client->renderInfo.eyeAngles);
+ // estimate where the neck would be...
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Z, tempAxis); // go down to find neck
+ VectorMA(cent->gent->client->renderInfo.eyePoint, 8, tempAxis, cent->gent->client->renderInfo.headPoint);
// Play the breath puffs (or not).
- CG_BreathPuffs( cent, tempAngles, ent.origin );
- }
- //Get torsoPoint & torsoAngles
- if (cent->gent->chestBolt>=0)
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->chestBolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.torsoPoint );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Z, tempAxis );
- vectoangles( tempAxis, cent->gent->client->renderInfo.torsoAngles );
- }
- else
- {
- VectorCopy( ent.origin, cent->gent->client->renderInfo.torsoPoint);
+ CG_BreathPuffs(cent, tempAngles, ent.origin);
+ }
+ // Get torsoPoint & torsoAngles
+ if (cent->gent->chestBolt >= 0) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->chestBolt, &boltMatrix, tempAngles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.torsoPoint);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Z, tempAxis);
+ vectoangles(tempAxis, cent->gent->client->renderInfo.torsoAngles);
+ } else {
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.torsoPoint);
VectorClear(cent->gent->client->renderInfo.torsoAngles);
}
- //get crotchPoint
- if (cent->gent->crotchBolt>=0)
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->crotchBolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.crotchPoint );
- }
- else
- {
- VectorCopy( ent.origin, cent->gent->client->renderInfo.crotchPoint);
+ // get crotchPoint
+ if (cent->gent->crotchBolt >= 0) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->crotchBolt, &boltMatrix, tempAngles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.crotchPoint);
+ } else {
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.crotchPoint);
}
- //NOTE: these are used for any case where an NPC fires and the next shot needs to come out
+ // NOTE: these are used for any case where an NPC fires and the next shot needs to come out
// of a new barrel/point. That way the muzzleflash will draw on the old barrel/point correctly
- //NOTE: I'm only doing this for the saboteur right now - AT-STs might need this... others?
- vec3_t oldMP = {0,0,0};
- vec3_t oldMD = {0,0,0};
+ // NOTE: I'm only doing this for the saboteur right now - AT-STs might need this... others?
+ vec3_t oldMP = {0, 0, 0};
+ vec3_t oldMD = {0, 0, 0};
- if( !calcedMp )
- {
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_ATST)
- {//FIXME: different for the three different weapon positions
- mdxaBone_t boltMatrix;
- int bolt;
- entityState_t *es;
+ if (!calcedMp) {
+ if (cent->gent && cent->gent->client &&
+ cent->gent->client->NPC_class == CLASS_ATST) { // FIXME: different for the three different weapon positions
+ mdxaBone_t boltMatrix;
+ int bolt;
+ entityState_t *es;
es = ¢->currentState;
// figure out where the actual model muzzle is
- if (es->weapon == WP_ATST_MAIN)
- {
- if ( !es->number )
- {//player, just use left one, I guess
- if ( cent->gent->alt_fire )
- {
+ if (es->weapon == WP_ATST_MAIN) {
+ if (!es->number) { // player, just use left one, I guess
+ if (cent->gent->alt_fire) {
bolt = cent->gent->handRBolt;
- }
- else
- {
+ } else {
bolt = cent->gent->handLBolt;
}
- }
- else if (cent->gent->count > 0)
- {
+ } else if (cent->gent->count > 0) {
cent->gent->count = 0;
bolt = cent->gent->handLBolt;
- }
- else
- {
+ } else {
cent->gent->count = 1;
bolt = cent->gent->handRBolt;
}
- }
- else // ATST SIDE weapons
+ } else // ATST SIDE weapons
{
- if ( cent->gent->alt_fire)
- {
+ if (cent->gent->alt_fire) {
bolt = cent->gent->genericBolt2;
- }
- else
- {
+ } else {
bolt = cent->gent->genericBolt1;
}
}
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir );
- }
- else if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_GALAKMECH )
- {
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir);
+ } else if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_GALAKMECH) {
int bolt = -1;
- if ( cent->gent->lockCount )
- {//using the big laser beam
+ if (cent->gent->lockCount) { // using the big laser beam
bolt = cent->gent->handLBolt;
- }
- else//repeater
+ } else // repeater
{
- if ( cent->gent->alt_fire )
- {//fire from the lower barrel (not that anyone will ever notice this, but...)
+ if (cent->gent->alt_fire) { // fire from the lower barrel (not that anyone will ever notice this, but...)
bolt = cent->gent->genericBolt3;
- }
- else
- {
+ } else {
bolt = cent->gent->handRBolt;
}
}
- if ( bolt == -1 )
- {
- VectorCopy( ent.origin, cent->gent->client->renderInfo.muzzlePoint );
- AngleVectors( tempAngles, cent->gent->client->renderInfo.muzzleDir, NULL, NULL );
- }
- else
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ if (bolt == -1) {
+ VectorCopy(ent.origin, cent->gent->client->renderInfo.muzzlePoint);
+ AngleVectors(tempAngles, cent->gent->client->renderInfo.muzzleDir, NULL, NULL);
+ } else {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, bolt, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir);
}
}
// Set the Vehicle Muzzle Point and Direction.
- else if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE )
- {
+ else if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE) {
// Get the Position and Direction of the Tag and use that as our Muzzles Properties.
- mdxaBone_t boltMatrix;
- vec3_t velocity;
+ mdxaBone_t boltMatrix;
+ vec3_t velocity;
VectorCopy(cent->gent->client->ps.velocity, velocity);
velocity[2] = 0;
- for ( int i = 0; i < MAX_VEHICLE_MUZZLES; i++ )
- {
- if ( cent->gent->m_pVehicle->m_iMuzzleTag[i] != -1 )
- {
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->playerModel, cent->gent->m_pVehicle->m_iMuzzleTag[i], &boltMatrix, cent->lerpAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzleDir );
- VectorMA(cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos, 0.075f, velocity, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos);
- }
- else
- {
+ for (int i = 0; i < MAX_VEHICLE_MUZZLES; i++) {
+ if (cent->gent->m_pVehicle->m_iMuzzleTag[i] != -1) {
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->playerModel, cent->gent->m_pVehicle->m_iMuzzleTag[i], &boltMatrix,
+ cent->lerpAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzleDir);
+ VectorMA(cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos, 0.075f, velocity, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos);
+ } else {
break;
}
}
- }
- else if ( cent->gent->client && cent->gent->NPC//client NPC
- /*
- && cent->gent->client->NPC_class == CLASS_REBORN//cultist
- && cent->gent->NPC->rank >= RANK_LT_COMM//commando
- */
- && cent->gent->s.weapon == WP_BLASTER_PISTOL//using blaster pistol
- && cent->gent->weaponModel[1] )//one in each hand
+ } else if (cent->gent->client &&
+ cent->gent->NPC // client NPC
+ /*
+ && cent->gent->client->NPC_class == CLASS_REBORN//cultist
+ && cent->gent->NPC->rank >= RANK_LT_COMM//commando
+ */
+ && cent->gent->s.weapon == WP_BLASTER_PISTOL // using blaster pistol
+ && cent->gent->weaponModel[1]) // one in each hand
{
qboolean getBoth = qfalse;
- int oldOne = 0;
- if ( cent->muzzleFlashTime > 0 && wData && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON ))
- {//we need to get both muzzles since we're toggling and we fired recently
+ int oldOne = 0;
+ if (cent->muzzleFlashTime > 0 && wData &&
+ !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON)) { // we need to get both muzzles since we're toggling and we fired recently
getBoth = qtrue;
- oldOne = (cent->gent->count)?0:1;
+ oldOne = (cent->gent->count) ? 0 : 1;
}
- if ( ( cent->gent->weaponModel[cent->gent->count] != -1)
- && ( cent->gent->ghoul2.size() > cent->gent->weaponModel[cent->gent->count] )
- && ( cent->gent->ghoul2[cent->gent->weaponModel[cent->gent->count]].mModelindex != -1) )
- {//get whichever one we're using now
- mdxaBone_t boltMatrix;
+ if ((cent->gent->weaponModel[cent->gent->count] != -1) && (cent->gent->ghoul2.size() > cent->gent->weaponModel[cent->gent->count]) &&
+ (cent->gent->ghoul2[cent->gent->weaponModel[cent->gent->count]].mModelindex != -1)) { // get whichever one we're using now
+ mdxaBone_t boltMatrix;
// figure out where the actual model muzzle is
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->weaponModel[cent->gent->count], 0, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->weaponModel[cent->gent->count], 0, &boltMatrix, tempAngles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir);
}
- //get the old one too, if needbe, and store it in muzzle2
- if ( getBoth
- && ( cent->gent->weaponModel[oldOne] != -1) //have a second weapon
- && ( cent->gent->ghoul2.size() > cent->gent->weaponModel[oldOne] ) //have a valid ghoul model index
- && ( cent->gent->ghoul2[cent->gent->weaponModel[oldOne]].mModelindex != -1) )//model exists and was loaded
- {//saboteur commando, toggle the muzzle point back and forth between the two pistols each time he fires
- mdxaBone_t boltMatrix;
+ // get the old one too, if needbe, and store it in muzzle2
+ if (getBoth && (cent->gent->weaponModel[oldOne] != -1) // have a second weapon
+ && (cent->gent->ghoul2.size() > cent->gent->weaponModel[oldOne]) // have a valid ghoul model index
+ && (cent->gent->ghoul2[cent->gent->weaponModel[oldOne]].mModelindex != -1)) // model exists and was loaded
+ { // saboteur commando, toggle the muzzle point back and forth between the two pistols each time he fires
+ mdxaBone_t boltMatrix;
// figure out where the actual model muzzle is
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->weaponModel[oldOne], 0, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->weaponModel[oldOne], 0, &boltMatrix, tempAngles, ent.origin, cg.time,
+ cgs.model_draw, cent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, oldMP );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, oldMD );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, oldMP);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, oldMD);
}
- }
- else if (( cent->gent->weaponModel[0] != -1) &&
- ( cent->gent->ghoul2.size() > cent->gent->weaponModel[0] ) &&
- ( cent->gent->ghoul2[cent->gent->weaponModel[0]].mModelindex != -1))
- {
- mdxaBone_t boltMatrix;
+ } else if ((cent->gent->weaponModel[0] != -1) && (cent->gent->ghoul2.size() > cent->gent->weaponModel[0]) &&
+ (cent->gent->ghoul2[cent->gent->weaponModel[0]].mModelindex != -1)) {
+ mdxaBone_t boltMatrix;
// figure out where the actual model muzzle is
- gi.G2API_GetBoltMatrix( cent->gent->ghoul2, cent->gent->weaponModel[0], 0, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw, cent->currentState.modelScale );
+ gi.G2API_GetBoltMatrix(cent->gent->ghoul2, cent->gent->weaponModel[0], 0, &boltMatrix, tempAngles, ent.origin, cg.time, cgs.model_draw,
+ cent->currentState.modelScale);
// work the matrix axis stuff into the original axis and origins used.
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir );
- }
- else
- {
- VectorCopy( cent->gent->client->renderInfo.eyePoint, cent->gent->client->renderInfo.muzzlePoint );
- AngleVectors( cent->gent->client->renderInfo.eyeAngles, cent->gent->client->renderInfo.muzzleDir, NULL, NULL );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, cent->gent->client->renderInfo.muzzlePoint);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, cent->gent->client->renderInfo.muzzleDir);
+ } else {
+ VectorCopy(cent->gent->client->renderInfo.eyePoint, cent->gent->client->renderInfo.muzzlePoint);
+ AngleVectors(cent->gent->client->renderInfo.eyeAngles, cent->gent->client->renderInfo.muzzleDir, NULL, NULL);
}
cent->gent->client->renderInfo.mPCalcTime = cg.time;
}
// Draw Vehicle Muzzle Flashs.
- if ( cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE )
- {
- for ( int i = 0; i < MAX_VEHICLE_MUZZLES; i++ )
- {
+ if (cent->gent && cent->gent->client && cent->gent->client->NPC_class == CLASS_VEHICLE) {
+ for (int i = 0; i < MAX_VEHICLE_MUZZLES; i++) {
/*if ( cent->gent->m_pVehicle->m_pVehicleInfo->weap1ID == cent->gent->m_pVehicle->m_pVehicleInfo->weapMuzzle[i] )
{
iDelay = cent->gent->m_pVehicle->m_pVehicleInfo->weap1Delay;
@@ -7725,65 +6488,52 @@ extern vmCvar_t cg_thirdPersonAlpha;
if ( cent->gent->m_pVehicle->m_Muzzles[i].m_iMuzzleWait - cg.time > ( iDelay - 500 ) )*/
- if ( cent->gent->m_pVehicle->m_Muzzles[i].m_bFired )
- {
- const char *effect = &weaponData[ cent->gent->m_pVehicle->m_pVehicleInfo->weapMuzzle[i] ].mMuzzleEffect[0];
- if ( effect )
- {
- theFxScheduler.PlayEffect( effect, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzleDir );
+ if (cent->gent->m_pVehicle->m_Muzzles[i].m_bFired) {
+ const char *effect = &weaponData[cent->gent->m_pVehicle->m_pVehicleInfo->weapMuzzle[i]].mMuzzleEffect[0];
+ if (effect) {
+ theFxScheduler.PlayEffect(effect, cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzlePos,
+ cent->gent->m_pVehicle->m_Muzzles[i].m_vMuzzleDir);
}
cent->gent->m_pVehicle->m_Muzzles[i].m_bFired = false;
}
}
}
// Pick the right effect for the type of weapon we are, defaults to no effect unless explicitly specified
- else if ( cent->muzzleFlashTime > 0 && wData && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON ))
- {
+ else if (cent->muzzleFlashTime > 0 && wData && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON)) {
const char *effect = NULL;
- cent->muzzleFlashTime = 0;
+ cent->muzzleFlashTime = 0;
// Try and get a default muzzle so we have one to fall back on
- if ( wData->mMuzzleEffect[0] )
- {
+ if (wData->mMuzzleEffect[0]) {
effect = &wData->mMuzzleEffect[0];
}
- if ( cent->altFire )
- {
+ if (cent->altFire) {
// We're alt-firing, so see if we need to override with a custom alt-fire effect
- if ( wData->mAltMuzzleEffect[0] )
- {
+ if (wData->mAltMuzzleEffect[0]) {
effect = &wData->mAltMuzzleEffect[0];
}
}
- if (/*( cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING ) &&*/ effect )
- {
- if ( cent->gent && cent->gent->NPC )
- {
- if ( !VectorCompare( oldMP, vec3_origin )
- && !VectorCompare( oldMD, vec3_origin ) )
- {//we have an old muzzlePoint we want to use
- theFxScheduler.PlayEffect( effect, oldMP, oldMD );
- }
- else
- {//use the current one
- theFxScheduler.PlayEffect( effect, cent->gent->client->renderInfo.muzzlePoint,
- cent->gent->client->renderInfo.muzzleDir );
+ if (/*( cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING ) &&*/ effect) {
+ if (cent->gent && cent->gent->NPC) {
+ if (!VectorCompare(oldMP, vec3_origin) && !VectorCompare(oldMD, vec3_origin)) { // we have an old muzzlePoint we want to use
+ theFxScheduler.PlayEffect(effect, oldMP, oldMD);
+ } else { // use the current one
+ theFxScheduler.PlayEffect(effect, cent->gent->client->renderInfo.muzzlePoint, cent->gent->client->renderInfo.muzzleDir);
}
- }
- else
- {
+ } else {
// We got an effect and we're firing, so let 'er rip.
- theFxScheduler.PlayEffect( effect, cent->currentState.clientNum );
+ theFxScheduler.PlayEffect(effect, cent->currentState.clientNum);
}
}
}
- //play special force effects
+ // play special force effects
/*
- if ( cent->gent->NPC && ( cent->gent->NPC->confusionTime > cg.time || cent->gent->NPC->charmedTime > cg.time || cent->gent->NPC->controlledTime > cg.time) )
+ if ( cent->gent->NPC && ( cent->gent->NPC->confusionTime > cg.time || cent->gent->NPC->charmedTime > cg.time || cent->gent->NPC->controlledTime >
+ cg.time) )
{// we are currently confused, so play an effect at the headBolt position
if ( TIMER_Done( cent->gent, "confusionEffectDebounce" ) )
{//ARGH!!!
@@ -7793,615 +6543,537 @@ extern vmCvar_t cg_thirdPersonAlpha;
}
*/
- if ( cent->gent->client && cent->gent->forcePushTime > cg.time )
- {//being pushed
- CG_ForcePushBodyBlur( cent, ent.origin, tempAngles );
+ if (cent->gent->client && cent->gent->forcePushTime > cg.time) { // being pushed
+ CG_ForcePushBodyBlur(cent, ent.origin, tempAngles);
}
- //This is now being done via an effect and the animevents.cfg
- //if ( cent->gent->client->ps.powerups[PW_FORCE_PUSH] > cg.time ||
- if ( (cent->gent->client->ps.forcePowersActive & (1<gent->client->renderInfo.handLPoint, qtrue );
+ // This is now being done via an effect and the animevents.cfg
+ // if ( cent->gent->client->ps.powerups[PW_FORCE_PUSH] > cg.time ||
+ if ((cent->gent->client->ps.forcePowersActive & (1 << FP_GRIP))) { // doing the gripping
+ // FIXME: effect?
+ CG_ForcePushBlur(cent->gent->client->renderInfo.handLPoint, qtrue);
}
- if ( cent->gent->client->ps.eFlags & EF_FORCE_GRIPPED )
- {//being gripped
- CG_ForcePushBlur( cent->gent->client->renderInfo.headPoint, qtrue );
+ if (cent->gent->client->ps.eFlags & EF_FORCE_GRIPPED) { // being gripped
+ CG_ForcePushBlur(cent->gent->client->renderInfo.headPoint, qtrue);
}
- if ( cent->gent->client && cent->gent->client->ps.powerups[PW_SHOCKED] > cg.time )
- {//being electrocuted
- CG_ForceElectrocution( cent, ent.origin, tempAngles, cgs.media.boltShader );
+ if (cent->gent->client && cent->gent->client->ps.powerups[PW_SHOCKED] > cg.time) { // being electrocuted
+ CG_ForceElectrocution(cent, ent.origin, tempAngles, cgs.media.boltShader);
}
- if ( cent->gent->client->ps.eFlags & EF_FORCE_DRAINED
- || (cent->currentState.powerups&(1<gent->client->ps.eFlags & EF_FORCE_DRAINED || (cent->currentState.powerups & (1 << PW_DRAINED))) { // being drained
+ // do red electricity lines off them and red drain shell on them
+ CG_ForceElectrocution(cent, ent.origin, tempAngles, cgs.media.drainShader, qtrue);
}
- if ( cent->gent->client->ps.forcePowersActive&(1<gent->client->ps.forcePowersActive & (1 << FP_LIGHTNING)) { // doing the electrocuting
+ // FIXME: if the target is absorbing or blocking lightning w/saber, draw a beam from my hand to his (hand?chest?saber?)
vec3_t tAng, fxDir;
- VectorCopy( cent->lerpAngles, tAng );
- if ( cent->gent->client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_2 )
- {//arc
- vec3_t fxAxis[3];
- AnglesToAxis( tAng, fxAxis );
- theFxScheduler.PlayEffect( cgs.effects.forceLightningWide, cent->gent->client->renderInfo.handLPoint, fxAxis );
- if ( cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING
- || cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING_START
- || cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING_HOLD
- || cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING_RELEASE )
- {//jackin' 'em up, Palpatine-style
- theFxScheduler.PlayEffect( cgs.effects.forceLightningWide, cent->gent->client->renderInfo.handRPoint, fxAxis );
+ VectorCopy(cent->lerpAngles, tAng);
+ if (cent->gent->client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_2) { // arc
+ vec3_t fxAxis[3];
+ AnglesToAxis(tAng, fxAxis);
+ theFxScheduler.PlayEffect(cgs.effects.forceLightningWide, cent->gent->client->renderInfo.handLPoint, fxAxis);
+ if (cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING ||
+ cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING_START ||
+ cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING_HOLD ||
+ cent->gent->client->ps.torsoAnim == BOTH_FORCE_2HANDEDLIGHTNING_RELEASE) { // jackin' 'em up, Palpatine-style
+ theFxScheduler.PlayEffect(cgs.effects.forceLightningWide, cent->gent->client->renderInfo.handRPoint, fxAxis);
}
- }
- else
- {//line
- AngleVectors( tAng, fxDir, NULL, NULL );
- theFxScheduler.PlayEffect( cgs.effects.forceLightning, cent->gent->client->renderInfo.handLPoint, fxDir );
+ } else { // line
+ AngleVectors(tAng, fxDir, NULL, NULL);
+ theFxScheduler.PlayEffect(cgs.effects.forceLightning, cent->gent->client->renderInfo.handLPoint, fxDir);
}
}
- if ( (cent->gent->client->ps.eFlags&EF_POWERING_ROSH) )
- {
+ if ((cent->gent->client->ps.eFlags & EF_POWERING_ROSH)) {
vec3_t tAng, fxDir;
- VectorCopy( cent->lerpAngles, tAng );
- AngleVectors( tAng, fxDir, NULL, NULL );
- theFxScheduler.PlayEffect( cgs.effects.forceDrain, cent->gent->client->renderInfo.handLPoint, fxDir );//theFxScheduler.RegisterEffect( "force/dr1" )
+ VectorCopy(cent->lerpAngles, tAng);
+ AngleVectors(tAng, fxDir, NULL, NULL);
+ theFxScheduler.PlayEffect(cgs.effects.forceDrain, cent->gent->client->renderInfo.handLPoint,
+ fxDir); // theFxScheduler.RegisterEffect( "force/dr1" )
}
- if ( cent->gent->client->ps.forcePowersActive&(1<gent->client->ps.forceDrainEntityNum >= ENTITYNUM_WORLD )
- {//doing the draining and not on a single person
+ if (cent->gent->client->ps.forcePowersActive & (1 << FP_DRAIN) &&
+ cent->gent->client->ps.forceDrainEntityNum >= ENTITYNUM_WORLD) { // doing the draining and not on a single person
vec3_t tAng, fxDir;
- VectorCopy( cent->lerpAngles, tAng );
- if ( cent->gent->client->ps.forcePowerLevel[FP_DRAIN] > FORCE_LEVEL_2 )
- {//arc
- vec3_t fxAxis[3];
- AnglesToAxis( tAng, fxAxis );
- theFxScheduler.PlayEffect( cgs.effects.forceDrainWide, cent->gent->client->renderInfo.handLPoint, fxAxis );
- }
- else
- {//line
- AngleVectors( tAng, fxDir, NULL, NULL );
- theFxScheduler.PlayEffect( cgs.effects.forceDrain, cent->gent->client->renderInfo.handLPoint, fxDir );
- }
- }
- //spotlight?
- if ( (cent->currentState.eFlags&EF_SPOTLIGHT) )
- {//FIXME: player's view should glare/flare if look at this... maybe build into the effect?
+ VectorCopy(cent->lerpAngles, tAng);
+ if (cent->gent->client->ps.forcePowerLevel[FP_DRAIN] > FORCE_LEVEL_2) { // arc
+ vec3_t fxAxis[3];
+ AnglesToAxis(tAng, fxAxis);
+ theFxScheduler.PlayEffect(cgs.effects.forceDrainWide, cent->gent->client->renderInfo.handLPoint, fxAxis);
+ } else { // line
+ AngleVectors(tAng, fxDir, NULL, NULL);
+ theFxScheduler.PlayEffect(cgs.effects.forceDrain, cent->gent->client->renderInfo.handLPoint, fxDir);
+ }
+ }
+ // spotlight?
+ if ((cent->currentState.eFlags & EF_SPOTLIGHT)) { // FIXME: player's view should glare/flare if look at this... maybe build into the effect?
// hack for the spotlight
- vec3_t org, eyeFwd;
+ vec3_t org, eyeFwd;
- AngleVectors( cent->gent->client->renderInfo.eyeAngles, eyeFwd, NULL, NULL );
- theFxScheduler.PlayEffect( "rockettrooper/light_cone", cent->gent->client->renderInfo.eyePoint, eyeFwd );
+ AngleVectors(cent->gent->client->renderInfo.eyeAngles, eyeFwd, NULL, NULL);
+ theFxScheduler.PlayEffect("rockettrooper/light_cone", cent->gent->client->renderInfo.eyePoint, eyeFwd);
// stay a bit back from the server-side's trace impact point...this may not be enough?
- VectorMA( cent->gent->client->renderInfo.eyePoint, cent->gent->speed - 5, eyeFwd, org );
+ VectorMA(cent->gent->client->renderInfo.eyePoint, cent->gent->speed - 5, eyeFwd, org);
float radius = cent->gent->speed;
- if ( radius < 128.0f )
- {
+ if (radius < 128.0f) {
radius = 128.0f;
- }
- else if ( radius > 1024.0f )
- {
+ } else if (radius > 1024.0f) {
radius = 1024.0f;
}
- cgi_R_AddLightToScene( org, radius, 1.0f, 1.0f, 1.0f );
+ cgi_R_AddLightToScene(org, radius, 1.0f, 1.0f, 1.0f);
}
}
//"refraction" effect -rww
- if ( cent->gent->client->ps.powerups[PW_FORCE_PUSH] > cg.time )
- {
+ if (cent->gent->client->ps.powerups[PW_FORCE_PUSH] > cg.time) {
CG_ForcePushRefraction(cent->gent->client->renderInfo.handLPoint, cent);
- }
- else if ( cent->gent->client->ps.powerups[PW_FORCE_PUSH_RHAND] > cg.time )
- {
+ } else if (cent->gent->client->ps.powerups[PW_FORCE_PUSH_RHAND] > cg.time) {
CG_ForcePushRefraction(cent->gent->client->renderInfo.handRPoint, cent);
- }
- else
- {
- cent->gent->client->ps.forcePowersActive &= ~( 1 << FP_PULL );
- }
-
- //bolted effects
- CG_BoltedEffects( cent, ent.origin, tempAngles );
- //As good a place as any, I suppose, to do this keyframed sound thing
- CGG2_AnimEvents( cent );
- //setup old system for gun to look at
- //CG_RunLerpFrame( ci, ¢->pe.torso, cent->gent->client->ps.torsoAnim, cent->gent->client->renderInfo.torsoFpsMod, cent->gent->s.number );
- if ( cent->gent && cent->gent->client && cent->gent->client->ps.weapon == WP_SABER )
- {
-extern qboolean PM_KickingAnim( int anim );
- if ( !PM_KickingAnim( cent->gent->client->ps.torsoAnim )
- || cent->gent->client->ps.torsoAnim == BOTH_A7_KICK_S )
- {//not kicking (unless it's the spinning kick)
- if ( cg_timescale.value < 1.0f && (cent->gent->client->ps.forcePowersActive&(1<gent->client->ps.saberDamageDebounceTime - cg.time > wait )
- {//when you unpause the game with force speed on, the time gets *really* wiggy...
+ } else {
+ cent->gent->client->ps.forcePowersActive &= ~(1 << FP_PULL);
+ }
+
+ // bolted effects
+ CG_BoltedEffects(cent, ent.origin, tempAngles);
+ // As good a place as any, I suppose, to do this keyframed sound thing
+ CGG2_AnimEvents(cent);
+ // setup old system for gun to look at
+ // CG_RunLerpFrame( ci, ¢->pe.torso, cent->gent->client->ps.torsoAnim, cent->gent->client->renderInfo.torsoFpsMod, cent->gent->s.number );
+ if (cent->gent && cent->gent->client && cent->gent->client->ps.weapon == WP_SABER) {
+ extern qboolean PM_KickingAnim(int anim);
+ if (!PM_KickingAnim(cent->gent->client->ps.torsoAnim) ||
+ cent->gent->client->ps.torsoAnim == BOTH_A7_KICK_S) { // not kicking (unless it's the spinning kick)
+ if (cg_timescale.value < 1.0f && (cent->gent->client->ps.forcePowersActive & (1 << FP_SPEED))) {
+ int wait = floor((float)FRAMETIME / 2.0f);
+ // sanity check
+ if (cent->gent->client->ps.saberDamageDebounceTime - cg.time >
+ wait) { // when you unpause the game with force speed on, the time gets *really* wiggy...
cent->gent->client->ps.saberDamageDebounceTime = cg.time + wait;
}
- if ( cent->gent->client->ps.saberDamageDebounceTime <= cg.time )
- {
-extern void WP_SabersDamageTrace( gentity_t *ent, qboolean noEffects );
-extern void WP_SaberUpdateOldBladeData( gentity_t *ent );
- //FIXME: this causes an ASSLOAD of effects
- WP_SabersDamageTrace( cent->gent, qtrue );
- WP_SaberUpdateOldBladeData( cent->gent );
- cent->gent->client->ps.saberDamageDebounceTime = cg.time + floor((float)wait*cg_timescale.value);
+ if (cent->gent->client->ps.saberDamageDebounceTime <= cg.time) {
+ extern void WP_SabersDamageTrace(gentity_t * ent, qboolean noEffects);
+ extern void WP_SaberUpdateOldBladeData(gentity_t * ent);
+ // FIXME: this causes an ASSLOAD of effects
+ WP_SabersDamageTrace(cent->gent, qtrue);
+ WP_SaberUpdateOldBladeData(cent->gent);
+ cent->gent->client->ps.saberDamageDebounceTime = cg.time + floor((float)wait * cg_timescale.value);
}
}
}
}
- }
- else
- {
- refEntity_t legs;
- refEntity_t torso;
- refEntity_t head;
- refEntity_t gun;
- refEntity_t flash;
- refEntity_t flashlight;
- int renderfx, i;
- const weaponInfo_t *weapon;
-
+ } else {
+ refEntity_t legs;
+ refEntity_t torso;
+ refEntity_t head;
+ refEntity_t gun;
+ refEntity_t flash;
+ refEntity_t flashlight;
+ int renderfx, i;
+ const weaponInfo_t *weapon;
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
- memset( &legs, 0, sizeof(legs) );
- memset( &torso, 0, sizeof(torso) );
- memset( &head, 0, sizeof(head) );
- memset( &gun, 0, sizeof(gun) );
- memset( &flash, 0, sizeof(flash) );
- memset( &flashlight, 0, sizeof(flashlight) );
+ memset(&legs, 0, sizeof(legs));
+ memset(&torso, 0, sizeof(torso));
+ memset(&head, 0, sizeof(head));
+ memset(&gun, 0, sizeof(gun));
+ memset(&flash, 0, sizeof(flash));
+ memset(&flashlight, 0, sizeof(flashlight));
- // Weapon sounds may need to be stopped, so check now
- CG_StopWeaponSounds( cent );
+ // Weapon sounds may need to be stopped, so check now
+ CG_StopWeaponSounds(cent);
- //FIXME: pass in the axis/angles offset between the tag_torso and the tag_head?
- // get the rotation information
- CG_PlayerAngles( cent, legs.axis, torso.axis, head.axis );
- if ( cent->gent && cent->gent->client )
- {
- cent->gent->client->ps.legsYaw = cent->lerpAngles[YAW];
- }
+ // FIXME: pass in the axis/angles offset between the tag_torso and the tag_head?
+ // get the rotation information
+ CG_PlayerAngles(cent, legs.axis, torso.axis, head.axis);
+ if (cent->gent && cent->gent->client) {
+ cent->gent->client->ps.legsYaw = cent->lerpAngles[YAW];
+ }
- // get the animation state (after rotation, to allow feet shuffle)
- // NB: Also plays keyframed animSounds (Bob- hope you dont mind, I was here late and at about 5:30 Am i needed to do something to keep me awake and i figured you wouldn't mind- you might want to check it, though, to make sure I wasn't smoking crack and missed something important, it is pretty late and I'm getting pretty close to being up for 24 hours here, so i wouldn't doubt if I might have messed something up, but i tested it and it looked right.... noticed in old code base i was doing it wrong too, whic h explains why I was getting so many damn sounds all the time! I had to lower the probabilities because it seemed like i was getting way too many sounds, and that was the problem! Well, should be fixed now I think...)
- CG_PlayerAnimation( cent, &legs.oldframe, &legs.frame, &legs.backlerp,
- &torso.oldframe, &torso.frame, &torso.backlerp );
+ // get the animation state (after rotation, to allow feet shuffle)
+ // NB: Also plays keyframed animSounds (Bob- hope you dont mind, I was here late and at about 5:30 Am i needed to do something to keep me awake and i
+ // figured you wouldn't mind- you might want to check it, though, to make sure I wasn't smoking crack and missed something important, it is pretty late
+ // and I'm getting pretty close to being up for 24 hours here, so i wouldn't doubt if I might have messed something up, but i tested it and it looked
+ // right.... noticed in old code base i was doing it wrong too, whic h explains why I was getting so many damn sounds all the time! I had to
+ // lower the probabilities because it seemed like i was getting way too many sounds, and that was the problem! Well, should be fixed now I think...)
+ CG_PlayerAnimation(cent, &legs.oldframe, &legs.frame, &legs.backlerp, &torso.oldframe, &torso.frame, &torso.backlerp);
- cent->gent->client->renderInfo.legsFrame = cent->pe.legs.frame;
- cent->gent->client->renderInfo.torsoFrame = cent->pe.torso.frame;
+ cent->gent->client->renderInfo.legsFrame = cent->pe.legs.frame;
+ cent->gent->client->renderInfo.torsoFrame = cent->pe.torso.frame;
- // add powerups floating behind the player
- CG_PlayerPowerups( cent );
+ // add powerups floating behind the player
+ CG_PlayerPowerups(cent);
- // add the shadow
- shadow = CG_PlayerShadow( cent, &shadowPlane );
+ // add the shadow
+ shadow = CG_PlayerShadow(cent, &shadowPlane);
- // add a water splash if partially in and out of water
- CG_PlayerSplash( cent );
+ // add a water splash if partially in and out of water
+ CG_PlayerSplash(cent);
- // get the player model information
- renderfx = 0;
- if ( !cg.renderingThirdPerson || cg.zoomMode )
- {
- if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD)
- {//no viewentity
- if ( cent->currentState.number == cg.snap->ps.clientNum )
- {//I am the player
- if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
- {//not using saber or fists
- renderfx = RF_THIRD_PERSON; // only draw in mirrors
+ // get the player model information
+ renderfx = 0;
+ if (!cg.renderingThirdPerson || cg.zoomMode) {
+ if (cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD) { // no viewentity
+ if (cent->currentState.number == cg.snap->ps.clientNum) { // I am the player
+ if (cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE) { // not using saber or fists
+ renderfx = RF_THIRD_PERSON; // only draw in mirrors
+ }
+ }
+ } else if (cent->currentState.number == cg.snap->ps.viewEntity) { // I am the view entity
+ if (cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE) { // not using saber or fists
+ renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
}
}
- else if ( cent->currentState.number == cg.snap->ps.viewEntity )
- {//I am the view entity
- if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
- {//not using saber or fists
- renderfx = RF_THIRD_PERSON; // only draw in mirrors
- }
+
+ if ((cg_shadows.integer == 2) || (cg_shadows.integer == 3 && shadow)) {
+ renderfx |= RF_SHADOW_PLANE;
+ }
+ renderfx |= RF_LIGHTING_ORIGIN; // use the same origin for all
+ if (cent->gent->NPC && cent->gent->NPC->scriptFlags & SCF_MORELIGHT) {
+ renderfx |= RF_MORELIGHT; // bigger than normal min light
}
- }
- if ( (cg_shadows.integer == 2) || (cg_shadows.integer == 3 && shadow) )
- {
- renderfx |= RF_SHADOW_PLANE;
- }
- renderfx |= RF_LIGHTING_ORIGIN; // use the same origin for all
- if ( cent->gent->NPC && cent->gent->NPC->scriptFlags & SCF_MORELIGHT )
- {
- renderfx |= RF_MORELIGHT; //bigger than normal min light
- }
+ if (cent->gent && cent->gent->client) {
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.headPoint);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.handRPoint);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.handLPoint);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.footRPoint);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.footLPoint);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.torsoPoint);
+ VectorCopy(cent->lerpAngles, cent->gent->client->renderInfo.torsoAngles);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.crotchPoint);
+ }
+ if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD &&
+ cg.snap->ps.viewEntity == cent->currentState.clientNum) { // player is in an entity camera view, ME
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.eyePoint);
+ VectorCopy(cent->lerpAngles, cent->gent->client->renderInfo.eyeAngles);
+ VectorCopy(cent->lerpOrigin, cent->gent->client->renderInfo.headPoint);
+ }
+ //
+ // add the legs
+ //
+ legs.hModel = ci->legsModel;
+ legs.customSkin = ci->legsSkin;
- if ( cent->gent && cent->gent->client )
- {
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.headPoint );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.handRPoint );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.handLPoint );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.footRPoint );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.footLPoint );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.torsoPoint );
- VectorCopy( cent->lerpAngles, cent->gent->client->renderInfo.torsoAngles );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.crotchPoint );
- }
- if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD && cg.snap->ps.viewEntity == cent->currentState.clientNum )
- {//player is in an entity camera view, ME
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.eyePoint );
- VectorCopy( cent->lerpAngles, cent->gent->client->renderInfo.eyeAngles );
- VectorCopy( cent->lerpOrigin, cent->gent->client->renderInfo.headPoint );
- }
- //
- // add the legs
- //
- legs.hModel = ci->legsModel;
- legs.customSkin = ci->legsSkin;
-
- VectorCopy( cent->lerpOrigin, legs.origin );
-
- //Scale applied to a refEnt will apply to any models attached to it...
- //This seems to copy the scale to every piece attached, kinda cool, but doesn't
- //allow the body to be scaled up without scaling a bolt on or whatnot...
- //Only apply scale if it's not 100% scale...
- if(cent->currentState.modelScale[0] != 0.0f)
- {
- VectorScale( legs.axis[0], cent->currentState.modelScale[0], legs.axis[0] );
- legs.nonNormalizedAxes = qtrue;
- }
+ VectorCopy(cent->lerpOrigin, legs.origin);
- if(cent->currentState.modelScale[1] != 0.0f)
- {
- VectorScale( legs.axis[1], cent->currentState.modelScale[1], legs.axis[1] );
- legs.nonNormalizedAxes = qtrue;
- }
+ // Scale applied to a refEnt will apply to any models attached to it...
+ // This seems to copy the scale to every piece attached, kinda cool, but doesn't
+ // allow the body to be scaled up without scaling a bolt on or whatnot...
+ // Only apply scale if it's not 100% scale...
+ if (cent->currentState.modelScale[0] != 0.0f) {
+ VectorScale(legs.axis[0], cent->currentState.modelScale[0], legs.axis[0]);
+ legs.nonNormalizedAxes = qtrue;
+ }
- if(cent->currentState.modelScale[2] != 0.0f)
- {
- VectorScale( legs.axis[2], cent->currentState.modelScale[2], legs.axis[2] );
- legs.nonNormalizedAxes = qtrue;
- if ( !staticScale )
- {
- //FIXME:? need to know actual height of leg model bottom to origin, not hardcoded
- legs.origin[2] += 24 * (cent->currentState.modelScale[2] - 1);
+ if (cent->currentState.modelScale[1] != 0.0f) {
+ VectorScale(legs.axis[1], cent->currentState.modelScale[1], legs.axis[1]);
+ legs.nonNormalizedAxes = qtrue;
}
- }
- VectorCopy( legs.origin, legs.lightingOrigin );
- legs.shadowPlane = shadowPlane;
- legs.renderfx = renderfx;
- VectorCopy (legs.origin, legs.oldorigin); // don't positionally lerp at all
+ if (cent->currentState.modelScale[2] != 0.0f) {
+ VectorScale(legs.axis[2], cent->currentState.modelScale[2], legs.axis[2]);
+ legs.nonNormalizedAxes = qtrue;
+ if (!staticScale) {
+ // FIXME:? need to know actual height of leg model bottom to origin, not hardcoded
+ legs.origin[2] += 24 * (cent->currentState.modelScale[2] - 1);
+ }
+ }
- CG_AddRefEntityWithPowerups( &legs, cent->currentState.powerups, cent );
+ VectorCopy(legs.origin, legs.lightingOrigin);
+ legs.shadowPlane = shadowPlane;
+ legs.renderfx = renderfx;
+ VectorCopy(legs.origin, legs.oldorigin); // don't positionally lerp at all
- // if the model failed, allow the default nullmodel to be displayed
- if (!legs.hModel)
- {
- return;
- }
+ CG_AddRefEntityWithPowerups(&legs, cent->currentState.powerups, cent);
- //
- // add the torso
- //
- torso.hModel = ci->torsoModel;
- if (torso.hModel)
- {
- orientation_t tag_torso;
+ // if the model failed, allow the default nullmodel to be displayed
+ if (!legs.hModel) {
+ return;
+ }
- torso.customSkin = ci->torsoSkin;
+ //
+ // add the torso
+ //
+ torso.hModel = ci->torsoModel;
+ if (torso.hModel) {
+ orientation_t tag_torso;
- VectorCopy( cent->lerpOrigin, torso.lightingOrigin );
+ torso.customSkin = ci->torsoSkin;
- CG_PositionRotatedEntityOnTag( &torso, &legs, legs.hModel, "tag_torso", &tag_torso );
- VectorCopy( torso.origin, cent->gent->client->renderInfo.torsoPoint );
- vectoangles( tag_torso.axis[0], cent->gent->client->renderInfo.torsoAngles );
+ VectorCopy(cent->lerpOrigin, torso.lightingOrigin);
- torso.shadowPlane = shadowPlane;
- torso.renderfx = renderfx;
+ CG_PositionRotatedEntityOnTag(&torso, &legs, legs.hModel, "tag_torso", &tag_torso);
+ VectorCopy(torso.origin, cent->gent->client->renderInfo.torsoPoint);
+ vectoangles(tag_torso.axis[0], cent->gent->client->renderInfo.torsoAngles);
- CG_AddRefEntityWithPowerups( &torso, cent->currentState.powerups, cent );
+ torso.shadowPlane = shadowPlane;
+ torso.renderfx = renderfx;
- //
- // add the head
- //
- head.hModel = ci->headModel;
- if (head.hModel)
- {
- orientation_t tag_head;
+ CG_AddRefEntityWithPowerups(&torso, cent->currentState.powerups, cent);
+
+ //
+ // add the head
+ //
+ head.hModel = ci->headModel;
+ if (head.hModel) {
+ orientation_t tag_head;
- //Deal with facial expressions
- //CG_PlayerHeadExtension( cent, &head );
+ // Deal with facial expressions
+ // CG_PlayerHeadExtension( cent, &head );
- VectorCopy( cent->lerpOrigin, head.lightingOrigin );
+ VectorCopy(cent->lerpOrigin, head.lightingOrigin);
- CG_PositionRotatedEntityOnTag( &head, &torso, torso.hModel, "tag_head", &tag_head );
- VectorCopy( head.origin, cent->gent->client->renderInfo.headPoint );
- vectoangles( tag_head.axis[0], cent->gent->client->renderInfo.headAngles );
+ CG_PositionRotatedEntityOnTag(&head, &torso, torso.hModel, "tag_head", &tag_head);
+ VectorCopy(head.origin, cent->gent->client->renderInfo.headPoint);
+ vectoangles(tag_head.axis[0], cent->gent->client->renderInfo.headAngles);
- head.shadowPlane = shadowPlane;
- head.renderfx = renderfx;
+ head.shadowPlane = shadowPlane;
+ head.renderfx = renderfx;
- CG_AddRefEntityWithPowerups( &head, cent->currentState.powerups, cent );
+ CG_AddRefEntityWithPowerups(&head, cent->currentState.powerups, cent);
- if ( cent->gent && cent->gent->NPC && ( cent->gent->NPC->confusionTime > cg.time || cent->gent->NPC->charmedTime > cg.time || cent->gent->NPC->controlledTime > cg.time) )
- {
- // we are currently confused, so play an effect
- if ( TIMER_Done( cent->gent, "confusionEffectDebounce" ) )
- {//ARGH!!!
- theFxScheduler.PlayEffect( cgs.effects.forceConfusion, head.origin );
- TIMER_Set( cent->gent, "confusionEffectDebounce", 1000 );
+ if (cent->gent && cent->gent->NPC &&
+ (cent->gent->NPC->confusionTime > cg.time || cent->gent->NPC->charmedTime > cg.time || cent->gent->NPC->controlledTime > cg.time)) {
+ // we are currently confused, so play an effect
+ if (TIMER_Done(cent->gent, "confusionEffectDebounce")) { // ARGH!!!
+ theFxScheduler.PlayEffect(cgs.effects.forceConfusion, head.origin);
+ TIMER_Set(cent->gent, "confusionEffectDebounce", 1000);
+ }
}
- }
- if ( !calcedMp )
- {//First person player's eyePoint and eyeAngles should be copies from cg.refdef...
- //Calc this client's eyepoint
- VectorCopy( head.origin, cent->gent->client->renderInfo.eyePoint );
- // race is gone, eyepoint should refer to the tag/bolt on the model... if this breaks something let me know - dmv
- // VectorMA( cent->gent->client->renderInfo.eyePoint, CG_EyePointOfsForRace[cent->gent->client->race][1]*scaleFactor[2], head.axis[2], cent->gent->client->renderInfo.eyePoint );//up
- // VectorMA( cent->gent->client->renderInfo.eyePoint, CG_EyePointOfsForRace[cent->gent->client->race][0]*scaleFactor[0], head.axis[0], cent->gent->client->renderInfo.eyePoint );//forward
- //Calc this client's eyeAngles
- vectoangles( head.axis[0], cent->gent->client->renderInfo.eyeAngles );
+ if (!calcedMp) { // First person player's eyePoint and eyeAngles should be copies from cg.refdef...
+ // Calc this client's eyepoint
+ VectorCopy(head.origin, cent->gent->client->renderInfo.eyePoint);
+ // race is gone, eyepoint should refer to the tag/bolt on the model... if this breaks something let me know - dmv
+ // VectorMA( cent->gent->client->renderInfo.eyePoint, CG_EyePointOfsForRace[cent->gent->client->race][1]*scaleFactor[2], head.axis[2],
+ //cent->gent->client->renderInfo.eyePoint );//up VectorMA( cent->gent->client->renderInfo.eyePoint,
+ //CG_EyePointOfsForRace[cent->gent->client->race][0]*scaleFactor[0], head.axis[0], cent->gent->client->renderInfo.eyePoint );//forward Calc
+ // this client's eyeAngles
+ vectoangles(head.axis[0], cent->gent->client->renderInfo.eyeAngles);
+ }
+ } else {
+ VectorCopy(torso.origin, cent->gent->client->renderInfo.eyePoint);
+ cent->gent->client->renderInfo.eyePoint[2] += cent->gent->maxs[2] - 4;
+ vectoangles(torso.axis[0], cent->gent->client->renderInfo.eyeAngles);
}
- }
- else
- {
- VectorCopy( torso.origin, cent->gent->client->renderInfo.eyePoint );
- cent->gent->client->renderInfo.eyePoint[2] += cent->gent->maxs[2] - 4;
- vectoangles( torso.axis[0], cent->gent->client->renderInfo.eyeAngles );
- }
- //
- // add the gun
- //
- CG_RegisterWeapon( cent->currentState.weapon );
- weapon = &cg_weapons[cent->currentState.weapon];
+ //
+ // add the gun
+ //
+ CG_RegisterWeapon(cent->currentState.weapon);
+ weapon = &cg_weapons[cent->currentState.weapon];
- gun.hModel = weapon->weaponWorldModel;
- if (gun.hModel)
- {
- qboolean drawGun = qtrue;
- //FIXME: allow scale, animation and angle offsets
- VectorCopy( cent->lerpOrigin, gun.lightingOrigin );
+ gun.hModel = weapon->weaponWorldModel;
+ if (gun.hModel) {
+ qboolean drawGun = qtrue;
+ // FIXME: allow scale, animation and angle offsets
+ VectorCopy(cent->lerpOrigin, gun.lightingOrigin);
- //FIXME: allow it to be put anywhere and move this out of if(torso.hModel)
- //Will have to call CG_PositionRotatedEntityOnTag
+ // FIXME: allow it to be put anywhere and move this out of if(torso.hModel)
+ // Will have to call CG_PositionRotatedEntityOnTag
- CG_PositionEntityOnTag( &gun, &torso, torso.hModel, "tag_weapon");
+ CG_PositionEntityOnTag(&gun, &torso, torso.hModel, "tag_weapon");
-//--------------------- start saber hacks
-/*
- if ( cent->gent && cent->gent->client && ( cent->currentState.weapon == WP_SABER || cent->gent->client->ps.saberInFlight ) )
- {
- int numSabers = 1;
- if ( cent->gent->client->ps.dualSabers )
- {
- numSabers = 2;
- }
- for ( int saberNum = 0; saberNum < numSabers; saberNum++ )
- {
- if ( !cent->gent->client->ps.saber[saberNum].active )//!cent->gent->client->ps.saberActive )
- {//saber is off
- if ( cent->gent->client->ps.saber[saberNum].length > 0 )
- {
- if ( cent->gent->client->ps.stats[STAT_HEALTH] <= 0 )
- {//dead, didn't actively turn it off
- cent->gent->client->ps.saber[saberNum].length -= cent->gent->client->ps.saber[saberNum].lengthMax/10 * cg.frametime/100;
- }
- else
- {//actively turned it off, shrink faster
- cent->gent->client->ps.saber[saberNum].length -= cent->gent->client->ps.saber[saberNum].lengthMax/3 * cg.frametime/100;
- }
- }
- if ( cent->gent->client->ps.saber[saberNum].length < 0 )
- {
- cent->gent->client->ps.saber[saberNum].length = 0;
- }
- }
- else if ( cent->gent->client->ps.saber[saberNum].length < cent->gent->client->ps.saber[saberNum].lengthMax )
- {//saber is on
- if ( !cent->gent->client->ps.saber[saberNum].length )
- {
- if ( cent->gent->client->ps.saberInFlight )
- {//play it on the saber
- cgi_S_UpdateEntityPosition( cent->gent->client->ps.saberEntityNum, g_entities[cent->gent->client->ps.saberEntityNum].currentOrigin );
- cgi_S_StartSound (NULL, cent->gent->client->ps.saberEntityNum, CHAN_AUTO, cgs.sound_precache[cent->gent->client->ps.saber[0].soundOn] );
- }
- else
+ //--------------------- start saber hacks
+ /*
+ if ( cent->gent && cent->gent->client && ( cent->currentState.weapon == WP_SABER || cent->gent->client->ps.saberInFlight ) )
{
- cgi_S_StartSound (NULL, cent->currentState.number, CHAN_AUTO, cgs.sound_precache[cent->gent->client->ps.saber[0].soundOn] );
-#ifdef _IMMERSION
- cgi_FF_Start( cgi_FF_Register( "fffx/weapons/saber/saberon", FF_CHANNEL_WEAPON ), cent->currentState.number );
-#endif // _IMMERSION
- }
- }
- cent->gent->client->ps.saber[saberNum].length += cent->gent->client->ps.saber[saberNum].lengthMax/6 * cg.frametime/100;//= saber[saberNum].lengthMax;
- if ( cent->gent->client->ps.saber[saberNum].length > cent->gent->client->ps.saber[saberNum].lengthMax )
- {
- cent->gent->client->ps.saber[saberNum].length = cent->gent->client->ps.saber[saberNum].lengthMax;
- }
- }
+ int numSabers = 1;
+ if ( cent->gent->client->ps.dualSabers )
+ {
+ numSabers = 2;
+ }
+ for ( int saberNum = 0; saberNum < numSabers; saberNum++ )
+ {
+ if ( !cent->gent->client->ps.saber[saberNum].active )//!cent->gent->client->ps.saberActive )
+ {//saber is off
+ if ( cent->gent->client->ps.saber[saberNum].length > 0 )
+ {
+ if ( cent->gent->client->ps.stats[STAT_HEALTH] <= 0 )
+ {//dead, didn't actively turn it off
+ cent->gent->client->ps.saber[saberNum].length -= cent->gent->client->ps.saber[saberNum].lengthMax/10 *
+ cg.frametime/100;
+ }
+ else
+ {//actively turned it off, shrink faster
+ cent->gent->client->ps.saber[saberNum].length -= cent->gent->client->ps.saber[saberNum].lengthMax/3 *
+ cg.frametime/100;
+ }
+ }
+ if ( cent->gent->client->ps.saber[saberNum].length < 0 )
+ {
+ cent->gent->client->ps.saber[saberNum].length = 0;
+ }
+ }
+ else if ( cent->gent->client->ps.saber[saberNum].length < cent->gent->client->ps.saber[saberNum].lengthMax )
+ {//saber is on
+ if ( !cent->gent->client->ps.saber[saberNum].length )
+ {
+ if ( cent->gent->client->ps.saberInFlight )
+ {//play it on the saber
+ cgi_S_UpdateEntityPosition( cent->gent->client->ps.saberEntityNum,
+ g_entities[cent->gent->client->ps.saberEntityNum].currentOrigin ); cgi_S_StartSound (NULL, cent->gent->client->ps.saberEntityNum, CHAN_AUTO,
+ cgs.sound_precache[cent->gent->client->ps.saber[0].soundOn] );
+ }
+ else
+ {
+ cgi_S_StartSound (NULL, cent->currentState.number, CHAN_AUTO,
+ cgs.sound_precache[cent->gent->client->ps.saber[0].soundOn] ); #ifdef _IMMERSION cgi_FF_Start( cgi_FF_Register( "fffx/weapons/saber/saberon",
+ FF_CHANNEL_WEAPON ), cent->currentState.number ); #endif // _IMMERSION
+ }
+ }
+ cent->gent->client->ps.saber[saberNum].length += cent->gent->client->ps.saber[saberNum].lengthMax/6 *
+ cg.frametime/100;//= saber[saberNum].lengthMax; if ( cent->gent->client->ps.saber[saberNum].length >
+ cent->gent->client->ps.saber[saberNum].lengthMax )
+ {
+ cent->gent->client->ps.saber[saberNum].length = cent->gent->client->ps.saber[saberNum].lengthMax;
+ }
+ }
- if ( cent->gent->client->ps.saberInFlight )
- {//not holding the saber in-hand
- drawGun = qfalse;
- }
- if ( cent->gent->client->ps.saber[saberNum].length > 0 )
- {
- if ( !cent->gent->client->ps.saberInFlight )
- {//holding the saber in-hand
- CG_AddSaberBlade( cent, cent, &gun, renderfx, 0, NULL, NULL );
- calcedMp = qtrue;
- }
- }
- else
- {
- //if ( cent->gent->client->ps.saberEventFlags&SEF_INWATER )
- {
- CG_CheckSaberInWater( cent, cent, 0, 0, NULL, NULL );
- }
- }
- }
- }
+ if ( cent->gent->client->ps.saberInFlight )
+ {//not holding the saber in-hand
+ drawGun = qfalse;
+ }
+ if ( cent->gent->client->ps.saber[saberNum].length > 0 )
+ {
+ if ( !cent->gent->client->ps.saberInFlight )
+ {//holding the saber in-hand
+ CG_AddSaberBlade( cent, cent, &gun, renderfx, 0, NULL, NULL );
+ calcedMp = qtrue;
+ }
+ }
+ else
+ {
+ //if ( cent->gent->client->ps.saberEventFlags&SEF_INWATER )
+ {
+ CG_CheckSaberInWater( cent, cent, 0, 0, NULL, NULL );
+ }
+ }
+ }
+ }
-*/
-//--------------------- end saber hacks
+ */
+ //--------------------- end saber hacks
- gun.shadowPlane = shadowPlane;
- gun.renderfx = renderfx;
+ gun.shadowPlane = shadowPlane;
+ gun.renderfx = renderfx;
- if ( drawGun )
- {
- CG_AddRefEntityWithPowerups( &gun,
- (cent->currentState.powerups & ((1<currentState.powerups & ((1 << PW_CLOAKED) | (1 << PW_BATTLESUIT))), cent);
+ }
- //
- // add the flash (even if invisible)
- //
+ //
+ // add the flash (even if invisible)
+ //
- // impulse flash
- if ( cent->muzzleFlashTime > 0 && wData && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON ))
- {
- int effect = 0;
+ // impulse flash
+ if (cent->muzzleFlashTime > 0 && wData && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON)) {
+ int effect = 0;
- cent->muzzleFlashTime = 0;
+ cent->muzzleFlashTime = 0;
- CG_PositionEntityOnTag( &flash, &gun, gun.hModel, "tag_flash");
+ CG_PositionEntityOnTag(&flash, &gun, gun.hModel, "tag_flash");
- // Try and get a default muzzle so we have one to fall back on
- if ( wData->mMuzzleEffectID )
- {
- effect = wData->mMuzzleEffectID;
- }
+ // Try and get a default muzzle so we have one to fall back on
+ if (wData->mMuzzleEffectID) {
+ effect = wData->mMuzzleEffectID;
+ }
- if ( cent->currentState.eFlags & EF_ALT_FIRING )
- {
- // We're alt-firing, so see if we need to override with a custom alt-fire effect
- if ( wData->mAltMuzzleEffectID )
- {
- effect = wData->mAltMuzzleEffectID;
+ if (cent->currentState.eFlags & EF_ALT_FIRING) {
+ // We're alt-firing, so see if we need to override with a custom alt-fire effect
+ if (wData->mAltMuzzleEffectID) {
+ effect = wData->mAltMuzzleEffectID;
+ }
}
- }
- if (( cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING ) && effect )
- {
- vec3_t up={0,0,1}, ax[3];
+ if ((cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING) && effect) {
+ vec3_t up = {0, 0, 1}, ax[3];
- VectorCopy( flash.axis[0], ax[0] );
+ VectorCopy(flash.axis[0], ax[0]);
- CrossProduct( up, ax[0], ax[1] );
- CrossProduct( ax[0], ax[1], ax[2] );
+ CrossProduct(up, ax[0], ax[1]);
+ CrossProduct(ax[0], ax[1], ax[2]);
- if (( cent->gent && cent->gent->NPC ) || cg.renderingThirdPerson )
- {
- theFxScheduler.PlayEffect( effect, flash.origin, ax );
- }
- else
- {
- // We got an effect and we're firing, so let 'er rip.
- theFxScheduler.PlayEffect( effect, flash.origin, ax );
+ if ((cent->gent && cent->gent->NPC) || cg.renderingThirdPerson) {
+ theFxScheduler.PlayEffect(effect, flash.origin, ax);
+ } else {
+ // We got an effect and we're firing, so let 'er rip.
+ theFxScheduler.PlayEffect(effect, flash.origin, ax);
+ }
}
}
- }
- if ( !calcedMp && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON ))
- {// Set the muzzle point
- orientation_t orientation;
+ if (!calcedMp && !(cent->currentState.eFlags & EF_LOCKED_TO_WEAPON)) { // Set the muzzle point
+ orientation_t orientation;
- cgi_R_LerpTag( &orientation, weapon->weaponModel, gun.oldframe, gun.frame,
- 1.0f - gun.backlerp, "tag_flash" );
-
- // FIXME: allow origin offsets along tag?
- VectorCopy( gun.origin, cent->gent->client->renderInfo.muzzlePoint );
- for ( i = 0 ; i < 3 ; i++ )
- {
- VectorMA( cent->gent->client->renderInfo.muzzlePoint, orientation.origin[i], gun.axis[i], cent->gent->client->renderInfo.muzzlePoint );
- }
-// VectorCopy( gun.axis[0], cent->gent->client->renderInfo.muzzleDir );
-// VectorAdd( gun.axis[0], orientation.axis[0], cent->gent->client->renderInfo.muzzleDir );
-// VectorNormalize( cent->gent->client->renderInfo.muzzleDir );
+ cgi_R_LerpTag(&orientation, weapon->weaponModel, gun.oldframe, gun.frame, 1.0f - gun.backlerp, "tag_flash");
+ // FIXME: allow origin offsets along tag?
+ VectorCopy(gun.origin, cent->gent->client->renderInfo.muzzlePoint);
+ for (i = 0; i < 3; i++) {
+ VectorMA(cent->gent->client->renderInfo.muzzlePoint, orientation.origin[i], gun.axis[i], cent->gent->client->renderInfo.muzzlePoint);
+ }
+ // VectorCopy( gun.axis[0], cent->gent->client->renderInfo.muzzleDir );
+ // VectorAdd( gun.axis[0], orientation.axis[0], cent->gent->client->renderInfo.muzzleDir );
+ // VectorNormalize( cent->gent->client->renderInfo.muzzleDir );
- cent->gent->client->renderInfo.mPCalcTime = cg.time;
- // Weapon wasn't firing anymore, so ditch any weapon associated looping sounds.
- //cent->gent->s.loopSound = 0;
+ cent->gent->client->renderInfo.mPCalcTime = cg.time;
+ // Weapon wasn't firing anymore, so ditch any weapon associated looping sounds.
+ // cent->gent->s.loopSound = 0;
+ }
}
+ } else {
+ VectorCopy(legs.origin, cent->gent->client->renderInfo.eyePoint);
+ cent->gent->client->renderInfo.eyePoint[2] += cent->gent->maxs[2] - 4;
+ vectoangles(legs.axis[0], cent->gent->client->renderInfo.eyeAngles);
}
}
- else
- {
- VectorCopy( legs.origin, cent->gent->client->renderInfo.eyePoint );
- cent->gent->client->renderInfo.eyePoint[2] += cent->gent->maxs[2] - 4;
- vectoangles( legs.axis[0], cent->gent->client->renderInfo.eyeAngles );
- }
-
- }
- //FIXME: for debug, allow to draw a cone of the NPC's FOV...
- if ( cent->currentState.number == 0 && cg.renderingThirdPerson )
- {
+ // FIXME: for debug, allow to draw a cone of the NPC's FOV...
+ if (cent->currentState.number == 0 && cg.renderingThirdPerson) {
playerState_t *ps = &cg.predicted_player_state;
- if (( ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BRYAR_PISTOL )
- || ( ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BLASTER_PISTOL )
- || ( ps->weapon == WP_BOWCASTER && ps->weaponstate == WEAPON_CHARGING )
- || ( ps->weapon == WP_DEMP2 && ps->weaponstate == WEAPON_CHARGING_ALT ))
- {
- int shader = 0;
- float val = 0.0f, scale = 1.0f;
- vec3_t WHITE = {1.0f,1.0f,1.0f};
+ if ((ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BRYAR_PISTOL) ||
+ (ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BLASTER_PISTOL) || (ps->weapon == WP_BOWCASTER && ps->weaponstate == WEAPON_CHARGING) ||
+ (ps->weapon == WP_DEMP2 && ps->weaponstate == WEAPON_CHARGING_ALT)) {
+ int shader = 0;
+ float val = 0.0f, scale = 1.0f;
+ vec3_t WHITE = {1.0f, 1.0f, 1.0f};
- if ( ps->weapon == WP_BRYAR_PISTOL
- || ps->weapon == WP_BLASTER_PISTOL )
- {
+ if (ps->weapon == WP_BRYAR_PISTOL || ps->weapon == WP_BLASTER_PISTOL) {
// Hardcoded max charge time of 1 second
- val = ( cg.time - ps->weaponChargeTime ) * 0.001f;
- shader = cgi_R_RegisterShader( "gfx/effects/bryarFrontFlash" );
- }
- else if ( ps->weapon == WP_BOWCASTER )
- {
+ val = (cg.time - ps->weaponChargeTime) * 0.001f;
+ shader = cgi_R_RegisterShader("gfx/effects/bryarFrontFlash");
+ } else if (ps->weapon == WP_BOWCASTER) {
// Hardcoded max charge time of 1 second
- val = ( cg.time - ps->weaponChargeTime ) * 0.001f;
- shader = cgi_R_RegisterShader( "gfx/effects/greenFrontFlash" );
- }
- else if ( ps->weapon == WP_DEMP2 )
- {
+ val = (cg.time - ps->weaponChargeTime) * 0.001f;
+ shader = cgi_R_RegisterShader("gfx/effects/greenFrontFlash");
+ } else if (ps->weapon == WP_DEMP2) {
// Hardcoded max charge time of 1 second
- val = ( cg.time - ps->weaponChargeTime ) * 0.001f;
- shader = cgi_R_RegisterShader( "gfx/misc/lightningFlash" );
+ val = (cg.time - ps->weaponChargeTime) * 0.001f;
+ shader = cgi_R_RegisterShader("gfx/misc/lightningFlash");
scale = 1.75f;
}
- if ( val < 0.0f )
- {
+ if (val < 0.0f) {
val = 0.0f;
- }
- else if ( val > 1.0f )
- {
+ } else if (val > 1.0f) {
val = 1.0f;
- CGCam_Shake( 0.1f, 100 );
- }
- else
- {
- CGCam_Shake( val * val * 0.3f, 100 );
+ CGCam_Shake(0.1f, 100);
+ } else {
+ CGCam_Shake(val * val * 0.3f, 100);
}
val += Q_flrand(0.0f, 1.0f) * 0.5f;
- FX_AddSprite( cent->gent->client->renderInfo.muzzlePoint, NULL, NULL, 3.0f * val * scale, 0.0f, 0.7f, 0.7f, WHITE, WHITE, Q_flrand(0.0f, 1.0f) * 360, 0.0f, 1.0f, shader, FX_USE_ALPHA );
+ FX_AddSprite(cent->gent->client->renderInfo.muzzlePoint, NULL, NULL, 3.0f * val * scale, 0.0f, 0.7f, 0.7f, WHITE, WHITE, Q_flrand(0.0f, 1.0f) * 360,
+ 0.0f, 1.0f, shader, FX_USE_ALPHA);
}
}
}
@@ -8418,39 +7090,35 @@ FIXME: We do not need to do this, we can remember the last anim and frame they w
on and coontinue from there.
===============
*/
-void CG_ResetPlayerEntity( centity_t *cent ) {
-// cent->errorTime = -99999; // guarantee no error decay added
-// cent->extrapolated = qfalse;
+void CG_ResetPlayerEntity(centity_t *cent) {
+ // cent->errorTime = -99999; // guarantee no error decay added
+ // cent->extrapolated = qfalse;
- if ( cent->gent && cent->gent->ghoul2.size() )
- {
- if ( cent->currentState.clientNum < MAX_CLIENTS )
- {
- CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], ¢->pe.legs, cent->currentState.legsAnim );
- CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], ¢->pe.torso, cent->currentState.torsoAnim );
- }
- else if ( cent->gent && cent->gent->client )
- {
- CG_ClearLerpFrame( ¢->gent->client->clientInfo, ¢->pe.legs, cent->currentState.legsAnim );
- CG_ClearLerpFrame( ¢->gent->client->clientInfo, ¢->pe.torso, cent->currentState.torsoAnim );
+ if (cent->gent && cent->gent->ghoul2.size()) {
+ if (cent->currentState.clientNum < MAX_CLIENTS) {
+ CG_ClearLerpFrame(&cgs.clientinfo[cent->currentState.clientNum], ¢->pe.legs, cent->currentState.legsAnim);
+ CG_ClearLerpFrame(&cgs.clientinfo[cent->currentState.clientNum], ¢->pe.torso, cent->currentState.torsoAnim);
+ } else if (cent->gent && cent->gent->client) {
+ CG_ClearLerpFrame(¢->gent->client->clientInfo, ¢->pe.legs, cent->currentState.legsAnim);
+ CG_ClearLerpFrame(¢->gent->client->clientInfo, ¢->pe.torso, cent->currentState.torsoAnim);
}
}
- //else????
+ // else????
- EvaluateTrajectory( ¢->currentState.pos, cg.time, cent->lerpOrigin );
- EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles );
+ EvaluateTrajectory(¢->currentState.pos, cg.time, cent->lerpOrigin);
+ EvaluateTrajectory(¢->currentState.apos, cg.time, cent->lerpAngles);
-// Removed by BTO (VV) - These values are crap anyway. Also changed below to use lerp instead
-// VectorCopy( cent->lerpOrigin, cent->rawOrigin );
-// VectorCopy( cent->lerpAngles, cent->rawAngles );
+ // Removed by BTO (VV) - These values are crap anyway. Also changed below to use lerp instead
+ // VectorCopy( cent->lerpOrigin, cent->rawOrigin );
+ // VectorCopy( cent->lerpAngles, cent->rawAngles );
- memset( ¢->pe.legs, 0, sizeof( cent->pe.legs ) );
+ memset(¢->pe.legs, 0, sizeof(cent->pe.legs));
cent->pe.legs.yawAngle = cent->lerpAngles[YAW];
cent->pe.legs.yawing = qfalse;
cent->pe.legs.pitchAngle = 0;
cent->pe.legs.pitching = qfalse;
- memset( ¢->pe.torso, 0, sizeof( cent->pe.legs ) );
+ memset(¢->pe.torso, 0, sizeof(cent->pe.legs));
cent->pe.torso.yawAngle = cent->lerpAngles[YAW];
cent->pe.torso.yawing = qfalse;
cent->pe.torso.pitchAngle = cent->lerpAngles[PITCH];
diff --git a/code/cgame/cg_playerstate.cpp b/code/cgame/cg_playerstate.cpp
index 3d75db3e57..01e84bcb66 100644
--- a/code/cgame/cg_playerstate.cpp
+++ b/code/cgame/cg_playerstate.cpp
@@ -29,7 +29,6 @@ along with this program; if not, see .
// this line must stay at top so the whole PCH thing works...
#include "cg_headers.h"
-
#include "cg_media.h"
/*
@@ -39,12 +38,11 @@ CG_CheckAmmo
If the ammo has gone low enough to generate the warning, play a sound
==============
*/
-void CG_CheckAmmo( void )
-{
-// int i;
- int total;
- int previous;
-// int weapons;
+void CG_CheckAmmo(void) {
+ // int i;
+ int total;
+ int previous;
+ // int weapons;
#if 0
@@ -81,8 +79,7 @@ void CG_CheckAmmo( void )
#endif
// Don't bother drawing the ammo warning when have no weapon selected
- if ( cg.weaponSelect == WP_NONE )
- {
+ if (cg.weaponSelect == WP_NONE) {
return;
}
@@ -94,21 +91,19 @@ void CG_CheckAmmo( void )
return;
}
-
previous = cg.lowAmmoWarning;
- if (!total) // We're completely freak'in out!
+ if (!total) // We're completely freak'in out!
{
cg.lowAmmoWarning = 2;
- }
- else // Got a little left
+ } else // Got a little left
{
cg.lowAmmoWarning = 1;
}
// play a sound on transitions
- if ( cg.lowAmmoWarning != previous ) {
- cgi_S_StartLocalSound( cgs.media.noAmmoSound, CHAN_LOCAL_SOUND ); //"sound/weapons/noammo.wav"
+ if (cg.lowAmmoWarning != previous) {
+ cgi_S_StartLocalSound(cgs.media.noAmmoSound, CHAN_LOCAL_SOUND); //"sound/weapons/noammo.wav"
}
}
@@ -117,22 +112,22 @@ void CG_CheckAmmo( void )
CG_DamageFeedback
==============
*/
-void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
- float left, front, up;
- float kick;
- int health;
- float scale;
- vec3_t dir;
- vec3_t angles;
- float dist;
- float yaw, pitch;
-
- //FIXME: Based on MOD, do different kinds of damage effects,
+void CG_DamageFeedback(int yawByte, int pitchByte, int damage) {
+ float left, front, up;
+ float kick;
+ int health;
+ float scale;
+ vec3_t dir;
+ vec3_t angles;
+ float dist;
+ float yaw, pitch;
+
+ // FIXME: Based on MOD, do different kinds of damage effects,
// for example, Borg damage could progressively tint screen green and raise FOV?
// the lower on health you are, the greater the view kick will be
health = cg.snap->ps.stats[STAT_HEALTH];
- if ( health < 40 ) {
+ if (health < 40) {
scale = 1;
} else {
scale = 40.0 / health;
@@ -145,7 +140,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
kick = 10;
// if yaw and pitch are both 255, make the damage always centered (falling, etc)
- if ( yawByte == 255 && pitchByte == 255 ) {
+ if (yawByte == 255 && pitchByte == 255) {
cg.damageX = 0;
cg.damageY = 0;
cg.v_dmg_roll = 0;
@@ -159,18 +154,18 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
angles[YAW] = yaw;
angles[ROLL] = 0;
- AngleVectors( angles, dir, NULL, NULL );
- VectorSubtract( vec3_origin, dir, dir );
+ AngleVectors(angles, dir, NULL, NULL);
+ VectorSubtract(vec3_origin, dir, dir);
- front = DotProduct (dir, cg.refdef.viewaxis[0] );
- left = DotProduct (dir, cg.refdef.viewaxis[1] );
- up = DotProduct (dir, cg.refdef.viewaxis[2] );
+ front = DotProduct(dir, cg.refdef.viewaxis[0]);
+ left = DotProduct(dir, cg.refdef.viewaxis[1]);
+ up = DotProduct(dir, cg.refdef.viewaxis[2]);
dir[0] = front;
dir[1] = left;
dir[2] = 0;
- dist = VectorLength( dir );
- if ( dist < 0.1 ) {
+ dist = VectorLength(dir);
+ if (dist < 0.1) {
dist = 0.1f;
}
@@ -178,7 +173,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
cg.v_dmg_pitch = -kick * front;
- if ( front <= 0.1 ) {
+ if (front <= 0.1) {
front = 0.1f;
}
cg.damageX = -left / front;
@@ -186,22 +181,22 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
}
// clamp the position
- if ( cg.damageX > 1.0 ) {
+ if (cg.damageX > 1.0) {
cg.damageX = 1.0;
}
- if ( cg.damageX < - 1.0 ) {
+ if (cg.damageX < -1.0) {
cg.damageX = -1.0;
}
- if ( cg.damageY > 1.0 ) {
+ if (cg.damageY > 1.0) {
cg.damageY = 1.0;
}
- if ( cg.damageY < - 1.0 ) {
+ if (cg.damageY < -1.0) {
cg.damageY = -1.0;
}
// don't let the screen flashes vary as much
- if ( kick > 10 ) {
+ if (kick > 10) {
kick = 10;
}
cg.damageValue = kick;
@@ -209,9 +204,6 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
cg.damageTime = cg.snap->serverTime;
}
-
-
-
/*
================
CG_Respawn
@@ -219,12 +211,12 @@ CG_Respawn
A respawn happened this snapshot
================
*/
-void CG_Respawn( void ) {
+void CG_Respawn(void) {
// no error decay on player movement
cg.thisFrameTeleport = qtrue;
// display weapons available
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
SetWeaponSelectTime();
// select the weapon the server says we are using
@@ -232,17 +224,16 @@ void CG_Respawn( void ) {
cg.weaponSelect = cg.snap->ps.weapon;
}
-
/*
==============
CG_CheckPlayerstateEvents
==============
*/
-void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops ) {
- int i;
- int event;
- centity_t *cent;
+void CG_CheckPlayerstateEvents(playerState_t *ps, playerState_t *ops) {
+ int i;
+ int event;
+ centity_t *cent;
#if 0
if ( ps->externalEvent && ps->externalEvent != ops->externalEvent ) {
@@ -253,15 +244,14 @@ void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops ) {
}
#endif
- for ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) {
- if ( ps->events[i & (MAX_PS_EVENTS-1)] != ops->events[i & (MAX_PS_EVENTS-1)]
- || i >= ops->eventSequence ) {
- event = ps->events[ i & (MAX_PS_EVENTS-1) ];
+ for (i = ps->eventSequence - MAX_PS_EVENTS; i < ps->eventSequence; i++) {
+ if (ps->events[i & (MAX_PS_EVENTS - 1)] != ops->events[i & (MAX_PS_EVENTS - 1)] || i >= ops->eventSequence) {
+ event = ps->events[i & (MAX_PS_EVENTS - 1)];
- cent = &cg_entities[ ps->clientNum ];
+ cent = &cg_entities[ps->clientNum];
cent->currentState.event = event;
- cent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ];
- CG_EntityEvent( cent, cent->lerpOrigin );
+ cent->currentState.eventParm = ps->eventParms[i & (MAX_PS_EVENTS - 1)];
+ CG_EntityEvent(cent, cent->lerpOrigin);
}
}
}
@@ -331,28 +321,28 @@ CG_TransitionPlayerState
===============
*/
-void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) {
+void CG_TransitionPlayerState(playerState_t *ps, playerState_t *ops) {
// teleporting
- if ( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT ) {
+ if ((ps->eFlags ^ ops->eFlags) & EF_TELEPORT_BIT) {
cg.thisFrameTeleport = qtrue;
} else {
cg.thisFrameTeleport = qfalse;
}
// check for changing follow mode
- if ( ps->clientNum != ops->clientNum ) {
+ if (ps->clientNum != ops->clientNum) {
cg.thisFrameTeleport = qtrue;
// make sure we don't get any unwanted transition effects
*ops = *ps;
}
// damage events (player is getting wounded)
- if ( ps->damageEvent != ops->damageEvent && ps->damageCount ) {
- CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount );
+ if (ps->damageEvent != ops->damageEvent && ps->damageCount) {
+ CG_DamageFeedback(ps->damageYaw, ps->damagePitch, ps->damageCount);
}
// respawning
- if ( ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT] ) {
+ if (ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT]) {
CG_Respawn();
}
@@ -360,17 +350,14 @@ void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) {
CG_CheckAmmo();
// run events
- CG_CheckPlayerstateEvents( ps, ops );
+ CG_CheckPlayerstateEvents(ps, ops);
// smooth the ducking viewheight change
- if ( ps->viewheight != ops->viewheight )
- {
- if ( !cg.nextFrameTeleport )
- {//when we crouch/uncrouch in mid-air, our viewhieght doesn't actually change in
- //absolute world coordinates, just locally.
+ if (ps->viewheight != ops->viewheight) {
+ if (!cg.nextFrameTeleport) { // when we crouch/uncrouch in mid-air, our viewhieght doesn't actually change in
+ // absolute world coordinates, just locally.
cg.duckChange = ps->viewheight - ops->viewheight;
cg.duckTime = cg.time;
}
}
}
-
diff --git a/code/cgame/cg_predict.cpp b/code/cgame/cg_predict.cpp
index f0a55359ad..24320d7c6a 100644
--- a/code/cgame/cg_predict.cpp
+++ b/code/cgame/cg_predict.cpp
@@ -32,10 +32,10 @@ along with this program; if not, see .
#include "../game/g_vehicles.h"
-static pmove_t cg_pmove;
+static pmove_t cg_pmove;
-static int cg_numSolidEntities;
-static centity_t *cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT];
+static int cg_numSolidEntities;
+static centity_t *cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT];
/*
====================
@@ -46,53 +46,43 @@ of the entities that are actually solid, to make for more
efficient collision detection
====================
*/
-void CG_BuildSolidList( void )
-{
- int i;
- centity_t *cent;
- vec3_t difference;
- float dsquared;
+void CG_BuildSolidList(void) {
+ int i;
+ centity_t *cent;
+ vec3_t difference;
+ float dsquared;
cg_numSolidEntities = 0;
- if(!cg.snap)
- {
+ if (!cg.snap) {
return;
}
- for ( i = 0 ; i < cg.snap->numEntities ; i++ )
- {
- if ( cg.snap->entities[ i ].number < ENTITYNUM_WORLD )
- {
- cent = &cg_entities[ cg.snap->entities[ i ].number ];
+ for (i = 0; i < cg.snap->numEntities; i++) {
+ if (cg.snap->entities[i].number < ENTITYNUM_WORLD) {
+ cent = &cg_entities[cg.snap->entities[i].number];
- if ( cent->gent != NULL && cent->gent->s.solid )
- {
+ if (cent->gent != NULL && cent->gent->s.solid) {
cg_solidEntities[cg_numSolidEntities] = cent;
cg_numSolidEntities++;
}
}
}
- dsquared = 5000+500;
+ dsquared = 5000 + 500;
dsquared *= dsquared;
- for(i=0;ilerpOrigin, cg.snap->ps.origin, difference);
if (cent->currentState.eType == ET_TERRAIN ||
- ((difference[0]*difference[0]) + (difference[1]*difference[1]) + (difference[2]*difference[2])) <= dsquared)
- {
+ ((difference[0] * difference[0]) + (difference[1] * difference[1]) + (difference[2] * difference[2])) <= dsquared) {
cent->currentValid = qtrue;
- if ( cent->nextState && cent->nextState->solid )
- {
+ if (cent->nextState && cent->nextState->solid) {
cg_solidEntities[cg_numSolidEntities] = cent;
cg_numSolidEntities++;
}
- }
- else
- {
+ } else {
cent->currentValid = qfalse;
}
}
@@ -104,60 +94,57 @@ CG_ClipMoveToEntities
====================
*/
-void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
- int skipNumber, int mask, trace_t *tr ) {
- int i, x, zd, zu;
- trace_t trace;
- entityState_t *ent;
- clipHandle_t cmodel;
- vec3_t bmins, bmaxs;
- vec3_t origin, angles;
- centity_t *cent;
-
- for ( i = 0 ; i < cg_numSolidEntities ; i++ ) {
- cent = cg_solidEntities[ i ];
+void CG_ClipMoveToEntities(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask, trace_t *tr) {
+ int i, x, zd, zu;
+ trace_t trace;
+ entityState_t *ent;
+ clipHandle_t cmodel;
+ vec3_t bmins, bmaxs;
+ vec3_t origin, angles;
+ centity_t *cent;
+
+ for (i = 0; i < cg_numSolidEntities; i++) {
+ cent = cg_solidEntities[i];
ent = ¢->currentState;
- if ( ent->number == skipNumber ) {
+ if (ent->number == skipNumber) {
continue;
}
- if ( ent->eType == ET_PUSH_TRIGGER ) {
+ if (ent->eType == ET_PUSH_TRIGGER) {
continue;
}
- if ( ent->eType == ET_TELEPORT_TRIGGER ) {
+ if (ent->eType == ET_TELEPORT_TRIGGER) {
continue;
}
- if ( ent->solid == SOLID_BMODEL ) {
+ if (ent->solid == SOLID_BMODEL) {
// special value for bmodel
- cmodel = cgi_CM_InlineModel( ent->modelindex );
- VectorCopy( cent->lerpAngles, angles );
+ cmodel = cgi_CM_InlineModel(ent->modelindex);
+ VectorCopy(cent->lerpAngles, angles);
- //Hmm... this would cause traces against brush movers to snap at 20fps (as with the third person camera)...
- //Let's use the lerpOrigin for now and see if it breaks anything...
- //EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, origin );
- VectorCopy( cent->lerpOrigin, origin );
+ // Hmm... this would cause traces against brush movers to snap at 20fps (as with the third person camera)...
+ // Let's use the lerpOrigin for now and see if it breaks anything...
+ // EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, origin );
+ VectorCopy(cent->lerpOrigin, origin);
} else {
// encoded bbox
x = (ent->solid & 255);
- zd = ((ent->solid>>8) & 255);
- zu = ((ent->solid>>16) & 255) - 32;
+ zd = ((ent->solid >> 8) & 255);
+ zu = ((ent->solid >> 16) & 255) - 32;
bmins[0] = bmins[1] = -x;
bmaxs[0] = bmaxs[1] = x;
bmins[2] = -zd;
bmaxs[2] = zu;
- cmodel = cgi_CM_TempBoxModel( bmins, bmaxs );//, cent->gent->contents );
- VectorCopy( vec3_origin, angles );
- VectorCopy( cent->lerpOrigin, origin );
+ cmodel = cgi_CM_TempBoxModel(bmins, bmaxs); //, cent->gent->contents );
+ VectorCopy(vec3_origin, angles);
+ VectorCopy(cent->lerpOrigin, origin);
}
-
- cgi_CM_TransformedBoxTrace ( &trace, start, end,
- mins, maxs, cmodel, mask, origin, angles);
+ cgi_CM_TransformedBoxTrace(&trace, start, end, mins, maxs, cmodel, mask, origin, angles);
if (trace.allsolid || trace.fraction < tr->fraction) {
trace.entityNum = ent->number;
@@ -165,7 +152,7 @@ void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t
} else if (trace.startsolid) {
tr->startsolid = qtrue;
}
- if ( tr->allsolid ) {
+ if (tr->allsolid) {
return;
}
}
@@ -176,14 +163,14 @@ void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t
CG_Trace
================
*/
-void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
- const int skipNumber, const int mask, const EG2_Collision eG2TraceType/*=G2_NOCOLLIDE*/, const int useLod/*=0*/) {
- trace_t t;
+void CG_Trace(trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int skipNumber, const int mask,
+ const EG2_Collision eG2TraceType /*=G2_NOCOLLIDE*/, const int useLod /*=0*/) {
+ trace_t t;
- cgi_CM_BoxTrace ( &t, start, end, mins, maxs, 0, mask);
+ cgi_CM_BoxTrace(&t, start, end, mins, maxs, 0, mask);
t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
// check all other solid models
- CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t);
+ CG_ClipMoveToEntities(start, mins, maxs, end, skipNumber, mask, &t);
*result = t;
}
@@ -197,25 +184,23 @@ CG_PointContents
#define USE_SV_PNT_CONTENTS (1)
#if USE_SV_PNT_CONTENTS
-int CG_PointContents( const vec3_t point, int passEntityNum ) {
- return gi.pointcontents(point,passEntityNum );
-}
+int CG_PointContents(const vec3_t point, int passEntityNum) { return gi.pointcontents(point, passEntityNum); }
#else
-int CG_PointContents( const vec3_t point, int passEntityNum ) {
- int i;
- entityState_t *ent;
- centity_t *cent;
+int CG_PointContents(const vec3_t point, int passEntityNum) {
+ int i;
+ entityState_t *ent;
+ centity_t *cent;
clipHandle_t cmodel;
- int contents;
+ int contents;
- contents = cgi_CM_PointContents (point, 0);
+ contents = cgi_CM_PointContents(point, 0);
- for ( i = 0 ; i < cg_numSolidEntities ; i++ ) {
- cent = cg_solidEntities[ i ];
+ for (i = 0; i < cg_numSolidEntities; i++) {
+ cent = cg_solidEntities[i];
ent = ¢->currentState;
- if ( ent->number == passEntityNum ) {
+ if (ent->number == passEntityNum) {
continue;
}
@@ -223,56 +208,49 @@ int CG_PointContents( const vec3_t point, int passEntityNum ) {
continue;
}
- cmodel = cgi_CM_InlineModel( ent->modelindex );
- if ( !cmodel ) {
+ cmodel = cgi_CM_InlineModel(ent->modelindex);
+ if (!cmodel) {
continue;
}
- contents |= cgi_CM_TransformedPointContents( point, cmodel, ent->origin, ent->angles );
+ contents |= cgi_CM_TransformedPointContents(point, cmodel, ent->origin, ent->angles);
}
return contents;
}
#endif
-void CG_SetClientViewAngles( vec3_t angles, qboolean overrideViewEnt )
-{
- if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD || overrideViewEnt )
- {//don't clamp angles when looking through a viewEntity
- for( int i = 0; i < 3; i++ )
- {
+void CG_SetClientViewAngles(vec3_t angles, qboolean overrideViewEnt) {
+ if (cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD || overrideViewEnt) { // don't clamp angles when looking through a viewEntity
+ for (int i = 0; i < 3; i++) {
cg.predicted_player_state.viewangles[i] = angles[i];
cg.predicted_player_state.delta_angles[i] = 0;
cg.snap->ps.viewangles[i] = angles[i];
cg.snap->ps.delta_angles[i] = 0;
g_entities[0].client->pers.cmd_angles[i] = ANGLE2SHORT(angles[i]);
}
- cgi_SetUserCmdAngles( angles[PITCH], angles[YAW], angles[ROLL] );
+ cgi_SetUserCmdAngles(angles[PITCH], angles[YAW], angles[ROLL]);
}
}
-extern qboolean PM_AdjustAnglesToGripper( gentity_t *gent, usercmd_t *cmd );
-extern qboolean PM_AdjustAnglesForSpinningFlip( gentity_t *ent, usercmd_t *ucmd, qboolean anglesOnly );
-extern qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd );
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
-qboolean CG_CheckModifyUCmd( usercmd_t *cmd, vec3_t viewangles )
-{
+extern qboolean PM_AdjustAnglesToGripper(gentity_t *gent, usercmd_t *cmd);
+extern qboolean PM_AdjustAnglesForSpinningFlip(gentity_t *ent, usercmd_t *ucmd, qboolean anglesOnly);
+extern qboolean G_CheckClampUcmd(gentity_t *ent, usercmd_t *ucmd);
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
+qboolean CG_CheckModifyUCmd(usercmd_t *cmd, vec3_t viewangles) {
qboolean overridAngles = qfalse;
- if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {//controlling something else
- memset( cmd, 0, sizeof( usercmd_t ) );
+ if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) { // controlling something else
+ memset(cmd, 0, sizeof(usercmd_t));
/*
//to keep pointing in same dir, need to set cmd.angles
cmd->angles[PITCH] = ANGLE2SHORT( cg.snap->ps.viewangles[PITCH] ) - cg.snap->ps.delta_angles[PITCH];
cmd->angles[YAW] = ANGLE2SHORT( cg.snap->ps.viewangles[YAW] ) - cg.snap->ps.delta_angles[YAW];
cmd->angles[ROLL] = 0;
*/
- VectorCopy( g_entities[0].pos4, viewangles );
+ VectorCopy(g_entities[0].pos4, viewangles);
overridAngles = qtrue;
- //CG_SetClientViewAngles( g_entities[cg.snap->ps.viewEntity].client->ps.viewangles, qtrue );
- }
- else if ( G_IsRidingVehicle( &g_entities[0] ) )
- {
+ // CG_SetClientViewAngles( g_entities[cg.snap->ps.viewEntity].client->ps.viewangles, qtrue );
+ } else if (G_IsRidingVehicle(&g_entities[0])) {
overridAngles = qtrue;
/*
int vehIndex = g_entities[0].owner->client->ps.vehicleIndex;
@@ -291,35 +269,26 @@ qboolean CG_CheckModifyUCmd( usercmd_t *cmd, vec3_t viewangles )
*/
}
- if ( g_entities[0].inuse && g_entities[0].client )
- {
- if ( !PM_AdjustAnglesToGripper( &g_entities[0], cmd ) )
- {
- if ( PM_AdjustAnglesForSpinningFlip( &g_entities[0], cmd, qtrue ) )
- {
- CG_SetClientViewAngles( g_entities[0].client->ps.viewangles, qfalse );
- if ( viewangles )
- {
- VectorCopy( g_entities[0].client->ps.viewangles, viewangles );
+ if (g_entities[0].inuse && g_entities[0].client) {
+ if (!PM_AdjustAnglesToGripper(&g_entities[0], cmd)) {
+ if (PM_AdjustAnglesForSpinningFlip(&g_entities[0], cmd, qtrue)) {
+ CG_SetClientViewAngles(g_entities[0].client->ps.viewangles, qfalse);
+ if (viewangles) {
+ VectorCopy(g_entities[0].client->ps.viewangles, viewangles);
overridAngles = qtrue;
}
}
- }
- else
- {
- CG_SetClientViewAngles( g_entities[0].client->ps.viewangles, qfalse );
- if ( viewangles )
- {
- VectorCopy( g_entities[0].client->ps.viewangles, viewangles );
+ } else {
+ CG_SetClientViewAngles(g_entities[0].client->ps.viewangles, qfalse);
+ if (viewangles) {
+ VectorCopy(g_entities[0].client->ps.viewangles, viewangles);
overridAngles = qtrue;
}
}
- if ( G_CheckClampUcmd( &g_entities[0], cmd ) )
- {
- CG_SetClientViewAngles( g_entities[0].client->ps.viewangles, qfalse );
- if ( viewangles )
- {
- VectorCopy( g_entities[0].client->ps.viewangles, viewangles );
+ if (G_CheckClampUcmd(&g_entities[0], cmd)) {
+ CG_SetClientViewAngles(g_entities[0].client->ps.viewangles, qfalse);
+ if (viewangles) {
+ VectorCopy(g_entities[0].client->ps.viewangles, viewangles);
overridAngles = qtrue;
}
}
@@ -327,26 +296,17 @@ qboolean CG_CheckModifyUCmd( usercmd_t *cmd, vec3_t viewangles )
return overridAngles;
}
-qboolean CG_OnMovingPlat( playerState_t *ps )
-{
- if ( ps->groundEntityNum != ENTITYNUM_NONE )
- {
+qboolean CG_OnMovingPlat(playerState_t *ps) {
+ if (ps->groundEntityNum != ENTITYNUM_NONE) {
entityState_t *es = &cg_entities[ps->groundEntityNum].currentState;
- if ( es->eType == ET_MOVER )
- {//on a mover
- if ( es->pos.trType != TR_STATIONARY )
- {
- if ( es->pos.trType != TR_LINEAR_STOP && es->pos.trType != TR_NONLINEAR_STOP )
- {//a constant mover
- if ( !VectorCompare( vec3_origin, es->pos.trDelta ) )
- {//is moving
+ if (es->eType == ET_MOVER) { // on a mover
+ if (es->pos.trType != TR_STATIONARY) {
+ if (es->pos.trType != TR_LINEAR_STOP && es->pos.trType != TR_NONLINEAR_STOP) { // a constant mover
+ if (!VectorCompare(vec3_origin, es->pos.trDelta)) { // is moving
return qtrue;
}
- }
- else
- {//a linear-stop mover
- if ( es->pos.trTime+es->pos.trDuration > cg.time )
- {//still moving
+ } else { // a linear-stop mover
+ if (es->pos.trTime + es->pos.trDuration > cg.time) { // still moving
return qtrue;
}
}
@@ -363,141 +323,112 @@ Generates cg.predicted_player_state by interpolating between
cg.snap->player_state and cg.nextFrame->player_state
========================
*/
-void CG_InterpolatePlayerState( qboolean grabAngles ) {
- float f;
- int i;
- playerState_t *out;
- snapshot_t *prev, *next;
- qboolean skip = qfalse;
- vec3_t oldOrg;
+void CG_InterpolatePlayerState(qboolean grabAngles) {
+ float f;
+ int i;
+ playerState_t *out;
+ snapshot_t *prev, *next;
+ qboolean skip = qfalse;
+ vec3_t oldOrg;
out = &cg.predicted_player_state;
prev = cg.snap;
next = cg.nextSnap;
- VectorCopy(out->origin,oldOrg);
+ VectorCopy(out->origin, oldOrg);
*out = cg.snap->ps;
// if we are still allowing local input, short circuit the view angles
- if ( grabAngles ) {
- usercmd_t cmd;
- int cmdNum;
+ if (grabAngles) {
+ usercmd_t cmd;
+ int cmdNum;
cmdNum = cgi_GetCurrentCmdNumber();
- cgi_GetUserCmd( cmdNum, &cmd );
+ cgi_GetUserCmd(cmdNum, &cmd);
- skip = CG_CheckModifyUCmd( &cmd, out->viewangles );
+ skip = CG_CheckModifyUCmd(&cmd, out->viewangles);
- if ( !skip )
- {
- //NULL so that it doesn't execute a block of code that must be run from game
- PM_UpdateViewAngles( out, &cmd, NULL );
+ if (!skip) {
+ // NULL so that it doesn't execute a block of code that must be run from game
+ PM_UpdateViewAngles(out, &cmd, NULL);
}
}
// if the next frame is a teleport, we can't lerp to it
- if ( cg.nextFrameTeleport )
- {
+ if (cg.nextFrameTeleport) {
return;
}
- if (!( !next || next->serverTime <= prev->serverTime ) )
- {
+ if (!(!next || next->serverTime <= prev->serverTime)) {
- f = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime );
+ f = (float)(cg.time - prev->serverTime) / (next->serverTime - prev->serverTime);
i = next->ps.bobCycle;
- if ( i < prev->ps.bobCycle )
- {
- i += 256; // handle wraparound
+ if (i < prev->ps.bobCycle) {
+ i += 256; // handle wraparound
}
- out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle );
+ out->bobCycle = prev->ps.bobCycle + f * (i - prev->ps.bobCycle);
- for ( i = 0 ; i < 3 ; i++ )
- {
- out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i] );
- if ( !grabAngles )
- {
- out->viewangles[i] = LerpAngle(
- prev->ps.viewangles[i], next->ps.viewangles[i], f );
+ for (i = 0; i < 3; i++) {
+ out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i]);
+ if (!grabAngles) {
+ out->viewangles[i] = LerpAngle(prev->ps.viewangles[i], next->ps.viewangles[i], f);
}
- out->velocity[i] = prev->ps.velocity[i] +
- f * (next->ps.velocity[i] - prev->ps.velocity[i] );
+ out->velocity[i] = prev->ps.velocity[i] + f * (next->ps.velocity[i] - prev->ps.velocity[i]);
}
}
- bool onPlat=false;
- centity_t *pent=0;
- if (out->groundEntityNum>0)
- {
- pent=&cg_entities[out->groundEntityNum];
- if (pent->currentState.eType == ET_MOVER )
+ bool onPlat = false;
+ centity_t *pent = 0;
+ if (out->groundEntityNum > 0) {
+ pent = &cg_entities[out->groundEntityNum];
+ if (pent->currentState.eType == ET_MOVER)
{
- onPlat=true;
+ onPlat = true;
}
}
- if (
- cg.validPPS &&
- cg_smoothPlayerPos.value>0.0f &&
- cg_smoothPlayerPos.value<1.0f &&
- !onPlat
- )
- {
+ if (cg.validPPS && cg_smoothPlayerPos.value > 0.0f && cg_smoothPlayerPos.value < 1.0f && !onPlat) {
// 0 = no smoothing, 1 = no movement
- for (i=0;i<3;i++)
- {
- out->origin[i]=cg_smoothPlayerPos.value*(oldOrg[i]-out->origin[i])+out->origin[i];
+ for (i = 0; i < 3; i++) {
+ out->origin[i] = cg_smoothPlayerPos.value * (oldOrg[i] - out->origin[i]) + out->origin[i];
}
- }
- else if (onPlat&&cg_smoothPlayerPlat.value>0.0f&&cg_smoothPlayerPlat.value<1.0f)
- {
-// if (cg.frametime<150)
-// {
+ } else if (onPlat && cg_smoothPlayerPlat.value > 0.0f && cg_smoothPlayerPlat.value < 1.0f) {
+ // if (cg.frametime<150)
+ // {
assert(pent);
- vec3_t p1,p2,vel;
+ vec3_t p1, p2, vel;
float lerpTime;
-
- EvaluateTrajectory( &pent->currentState.pos,cg.snap->serverTime, p1 );
- if ( cg.nextSnap &&cg.nextSnap->serverTime > cg.snap->serverTime && pent->nextState)
- {
- EvaluateTrajectory( &pent->nextState->pos,cg.nextSnap->serverTime, p2 );
- lerpTime=float(cg.nextSnap->serverTime - cg.snap->serverTime);
- }
- else
- {
- EvaluateTrajectory( &pent->currentState.pos,cg.snap->serverTime+50, p2 );
- lerpTime=50.0f;
+ EvaluateTrajectory(&pent->currentState.pos, cg.snap->serverTime, p1);
+ if (cg.nextSnap && cg.nextSnap->serverTime > cg.snap->serverTime && pent->nextState) {
+ EvaluateTrajectory(&pent->nextState->pos, cg.nextSnap->serverTime, p2);
+ lerpTime = float(cg.nextSnap->serverTime - cg.snap->serverTime);
+ } else {
+ EvaluateTrajectory(&pent->currentState.pos, cg.snap->serverTime + 50, p2);
+ lerpTime = 50.0f;
}
- float accel=cg_smoothPlayerPlatAccel.value*cg.frametime/lerpTime;
+ float accel = cg_smoothPlayerPlatAccel.value * cg.frametime / lerpTime;
- if (accel>20.0f)
- {
- accel=20.0f;
+ if (accel > 20.0f) {
+ accel = 20.0f;
}
- for (i=0;i<3;i++)
- {
- vel[i]=accel*(p2[i]-p1[i]);
+ for (i = 0; i < 3; i++) {
+ vel[i] = accel * (p2[i] - p1[i]);
}
- VectorAdd(out->origin,vel,out->origin);
+ VectorAdd(out->origin, vel, out->origin);
- if (cg.validPPS &&
- cg_smoothPlayerPlat.value>0.0f &&
- cg_smoothPlayerPlat.value<1.0f
- )
- {
+ if (cg.validPPS && cg_smoothPlayerPlat.value > 0.0f && cg_smoothPlayerPlat.value < 1.0f) {
// 0 = no smoothing, 1 = no movement
- for (i=0;i<3;i++)
- {
- out->origin[i]=cg_smoothPlayerPlat.value*(oldOrg[i]-out->origin[i])+out->origin[i];
+ for (i = 0; i < 3; i++) {
+ out->origin[i] = cg_smoothPlayerPlat.value * (oldOrg[i] - out->origin[i]) + out->origin[i];
}
}
-// }
+ // }
}
}
@@ -506,26 +437,26 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) {
CG_TouchItem
===================
*/
-void CG_TouchItem( centity_t *cent ) {
- gitem_t *item;
+void CG_TouchItem(centity_t *cent) {
+ gitem_t *item;
// never pick an item up twice in a prediction
- if ( cent->miscTime == cg.time ) {
+ if (cent->miscTime == cg.time) {
return;
}
- if ( !BG_PlayerTouchesItem( &cg.predicted_player_state, ¢->currentState, cg.time ) ) {
+ if (!BG_PlayerTouchesItem(&cg.predicted_player_state, ¢->currentState, cg.time)) {
return;
}
- if ( !BG_CanItemBeGrabbed( ¢->currentState, &cg.predicted_player_state ) ) {
- return; // can't hold it
+ if (!BG_CanItemBeGrabbed(¢->currentState, &cg.predicted_player_state)) {
+ return; // can't hold it
}
- item = &bg_itemlist[ cent->currentState.modelindex ];
+ item = &bg_itemlist[cent->currentState.modelindex];
// grab it
- AddEventToPlayerstate( EV_ITEM_PICKUP, cent->currentState.modelindex , &cg.predicted_player_state);
+ AddEventToPlayerstate(EV_ITEM_PICKUP, cent->currentState.modelindex, &cg.predicted_player_state);
// remove it from the frame so it won't be drawn
cent->currentState.eFlags |= EF_NODRAW;
@@ -534,16 +465,15 @@ void CG_TouchItem( centity_t *cent ) {
cent->miscTime = cg.time;
// if its a weapon, give them some predicted ammo so the autoswitch will work
- if ( item->giType == IT_WEAPON ) {
+ if (item->giType == IT_WEAPON) {
int ammotype = weaponData[item->giTag].ammoIndex;
- cg.predicted_player_state.stats[ STAT_WEAPONS ] |= 1 << item->giTag;
- if ( !cg.predicted_player_state.ammo[ ammotype] ) {
- cg.predicted_player_state.ammo[ ammotype ] = 1;
+ cg.predicted_player_state.stats[STAT_WEAPONS] |= 1 << item->giTag;
+ if (!cg.predicted_player_state.ammo[ammotype]) {
+ cg.predicted_player_state.ammo[ammotype] = 1;
}
}
}
-
/*
=========================
CG_TouchTriggerPrediction
@@ -552,68 +482,66 @@ Predict push triggers and items
Only called for the last command
=========================
*/
-void CG_TouchTriggerPrediction( void ) {
- int i;
- trace_t trace;
- entityState_t *ent;
+void CG_TouchTriggerPrediction(void) {
+ int i;
+ trace_t trace;
+ entityState_t *ent;
clipHandle_t cmodel;
- centity_t *cent;
- qboolean spectator;
+ centity_t *cent;
+ qboolean spectator;
// dead clients don't activate triggers
- if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 ) {
+ if (cg.predicted_player_state.stats[STAT_HEALTH] <= 0) {
return;
}
- spectator = (qboolean)( cg.predicted_player_state.pm_type == PM_SPECTATOR );
+ spectator = (qboolean)(cg.predicted_player_state.pm_type == PM_SPECTATOR);
- if ( cg.predicted_player_state.pm_type != PM_NORMAL && !spectator ) {
+ if (cg.predicted_player_state.pm_type != PM_NORMAL && !spectator) {
return;
}
- for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
- cent = &cg_entities[ cg.snap->entities[ i ].number ];
+ for (i = 0; i < cg.snap->numEntities; i++) {
+ cent = &cg_entities[cg.snap->entities[i].number];
ent = ¢->currentState;
- if ( ent->eType == ET_ITEM && !spectator ) {
- CG_TouchItem( cent );
+ if (ent->eType == ET_ITEM && !spectator) {
+ CG_TouchItem(cent);
continue;
}
- if ( ent->eType != ET_PUSH_TRIGGER && ent->eType != ET_TELEPORT_TRIGGER ) {
+ if (ent->eType != ET_PUSH_TRIGGER && ent->eType != ET_TELEPORT_TRIGGER) {
continue;
}
- if ( ent->solid != SOLID_BMODEL ) {
+ if (ent->solid != SOLID_BMODEL) {
continue;
}
- cmodel = cgi_CM_InlineModel( ent->modelindex );
- if ( !cmodel ) {
+ cmodel = cgi_CM_InlineModel(ent->modelindex);
+ if (!cmodel) {
continue;
}
- cgi_CM_BoxTrace( &trace, cg.predicted_player_state.origin, cg.predicted_player_state.origin,
- cg_pmove.mins, cg_pmove.maxs, cmodel, -1 );
+ cgi_CM_BoxTrace(&trace, cg.predicted_player_state.origin, cg.predicted_player_state.origin, cg_pmove.mins, cg_pmove.maxs, cmodel, -1);
- if ( !trace.startsolid ) {
+ if (!trace.startsolid) {
continue;
}
- if ( ent->eType == ET_TELEPORT_TRIGGER ) {
+ if (ent->eType == ET_TELEPORT_TRIGGER) {
cg.hyperspace = qtrue;
} else {
// we hit this push trigger
- if ( spectator ) {
+ if (spectator) {
continue;
}
- VectorCopy( ent->origin2, cg.predicted_player_state.velocity );
+ VectorCopy(ent->origin2, cg.predicted_player_state.velocity);
}
}
}
-
/*
=================
CG_PredictPlayerState
@@ -636,23 +564,22 @@ We detect prediction errors and allow them to be decayed off over several frames
to ease the jerk.
=================
*/
-extern qboolean player_locked;
-void CG_PredictPlayerState( void ) {
- int cmdNum, current;
- playerState_t oldPlayerState;
+extern qboolean player_locked;
+void CG_PredictPlayerState(void) {
+ int cmdNum, current;
+ playerState_t oldPlayerState;
- cg.hyperspace = qfalse; // will be set if touching a trigger_teleport
+ cg.hyperspace = qfalse; // will be set if touching a trigger_teleport
// if this is the first frame we must guarantee
// predicted_player_state is valid even if there is some
// other error condition
- if ( !cg.validPPS ) {
+ if (!cg.validPPS) {
cg.validPPS = qtrue;
cg.predicted_player_state = cg.snap->ps;
}
-
- if ( 1 )//cg_timescale.value >= 1.0f )
+ if (1) // cg_timescale.value >= 1.0f )
{
// demo playback just copies the moves
/*
@@ -663,18 +590,18 @@ void CG_PredictPlayerState( void ) {
*/
// non-predicting local movement will grab the latest angles
- CG_InterpolatePlayerState( qtrue );
+ CG_InterpolatePlayerState(qtrue);
return;
}
// prepare for pmove
- //FIXME: is this bad???
+ // FIXME: is this bad???
cg_pmove.gent = NULL;
cg_pmove.ps = &cg.predicted_player_state;
cg_pmove.trace = CG_Trace;
cg_pmove.pointcontents = CG_PointContents;
cg_pmove.tracemask = MASK_PLAYERSOLID;
- cg_pmove.noFootsteps = qfalse;//( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0;
+ cg_pmove.noFootsteps = qfalse; //( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0;
// save the state before the pmove so we can detect transitions
oldPlayerState = cg.predicted_player_state;
@@ -683,7 +610,7 @@ void CG_PredictPlayerState( void ) {
cmdNum = cg.snap->cmdNum;
current = cgi_GetCurrentCmdNumber();
- if ( current - cmdNum >= CMD_BACKUP ) {
+ if (current - cmdNum >= CMD_BACKUP) {
return;
}
@@ -691,7 +618,7 @@ void CG_PredictPlayerState( void ) {
cg.predicted_player_state = cg.snap->ps;
// we should always be predicting at least one frame
- if ( cmdNum >= current ) {
+ if (cmdNum >= current) {
return;
}
@@ -702,36 +629,35 @@ void CG_PredictPlayerState( void ) {
// from the snapshot, but on a wan we will have
// to predict several commands to get to the point
// we want to compare
- if ( cmdNum == current - 1 ) {
- vec3_t delta;
- float len;
+ if (cmdNum == current - 1) {
+ vec3_t delta;
+ float len;
- if ( cg.thisFrameTeleport ) {
+ if (cg.thisFrameTeleport) {
// a teleport will not cause an error decay
- VectorClear( cg.predictedError );
+ VectorClear(cg.predictedError);
cg.thisFrameTeleport = qfalse;
} else {
- vec3_t adjusted;
- CG_AdjustPositionForMover( cg.predicted_player_state.origin,
- cg.predicted_player_state.groundEntityNum, cg.oldTime, adjusted );
+ vec3_t adjusted;
+ CG_AdjustPositionForMover(cg.predicted_player_state.origin, cg.predicted_player_state.groundEntityNum, cg.oldTime, adjusted);
- VectorSubtract( oldPlayerState.origin, adjusted, delta );
- len = VectorLength( delta );
- if ( len > 0.1 ) {
- if ( cg_errorDecay.integer ) {
- int t;
- float f;
+ VectorSubtract(oldPlayerState.origin, adjusted, delta);
+ len = VectorLength(delta);
+ if (len > 0.1) {
+ if (cg_errorDecay.integer) {
+ int t;
+ float f;
t = cg.time - cg.predictedErrorTime;
- f = ( cg_errorDecay.value - t ) / cg_errorDecay.value;
- if ( f < 0 ) {
+ f = (cg_errorDecay.value - t) / cg_errorDecay.value;
+ if (f < 0) {
f = 0;
}
- VectorScale( cg.predictedError, f, cg.predictedError );
+ VectorScale(cg.predictedError, f, cg.predictedError);
} else {
- VectorClear( cg.predictedError );
+ VectorClear(cg.predictedError);
}
- VectorAdd( delta, cg.predictedError, cg.predictedError );
+ VectorAdd(delta, cg.predictedError, cg.predictedError);
cg.predictedErrorTime = cg.oldTime;
}
}
@@ -742,38 +668,32 @@ void CG_PredictPlayerState( void ) {
// this should never happen, because we check ranges at
// the top of the function
cmdNum++;
- if ( !cgi_GetUserCmd( cmdNum, &cg_pmove.cmd ) ) {
+ if (!cgi_GetUserCmd(cmdNum, &cg_pmove.cmd)) {
break;
}
- gentity_t *ent = &g_entities[0];//cheating and dirty, I know, but this is a SP game so prediction can cheat
- if ( player_locked ||
- (ent && !ent->s.number&&ent->aimDebounceTime>level.time) ||
- (ent && ent->client && ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) ||
- (ent && ent->forcePushTime > level.time) )
- {//lock out player control unless dead
- //VectorClear( cg_pmove.cmd.angles );
+ gentity_t *ent = &g_entities[0]; // cheating and dirty, I know, but this is a SP game so prediction can cheat
+ if (player_locked || (ent && !ent->s.number && ent->aimDebounceTime > level.time) ||
+ (ent && ent->client && ent->client->ps.pm_time && (ent->client->ps.pm_flags & PMF_TIME_KNOCKBACK)) ||
+ (ent && ent->forcePushTime > level.time)) { // lock out player control unless dead
+ // VectorClear( cg_pmove.cmd.angles );
cg_pmove.cmd.forwardmove = 0;
cg_pmove.cmd.rightmove = 0;
cg_pmove.cmd.buttons = 0;
cg_pmove.cmd.upmove = 0;
}
- CG_CheckModifyUCmd( &cg_pmove.cmd, NULL );
- //FIXME: prediction on clients in timescale results in jerky positional translation
- Pmove( &cg_pmove );
+ CG_CheckModifyUCmd(&cg_pmove.cmd, NULL);
+ // FIXME: prediction on clients in timescale results in jerky positional translation
+ Pmove(&cg_pmove);
// add push trigger movement effects
CG_TouchTriggerPrediction();
- } while ( cmdNum < current );
+ } while (cmdNum < current);
// adjust for the movement of the groundentity
- CG_AdjustPositionForMover( cg.predicted_player_state.origin,
- cg.predicted_player_state.groundEntityNum,
- cg.time, cg.predicted_player_state.origin );
+ CG_AdjustPositionForMover(cg.predicted_player_state.origin, cg.predicted_player_state.groundEntityNum, cg.time, cg.predicted_player_state.origin);
// fire events and other transition triggered things
- CG_TransitionPlayerState( &cg.predicted_player_state, &oldPlayerState );
+ CG_TransitionPlayerState(&cg.predicted_player_state, &oldPlayerState);
}
-
-
diff --git a/code/cgame/cg_scoreboard.cpp b/code/cgame/cg_scoreboard.cpp
index b4e54e97fd..809f2350ac 100644
--- a/code/cgame/cg_scoreboard.cpp
+++ b/code/cgame/cg_scoreboard.cpp
@@ -27,8 +27,7 @@ along with this program; if not, see .
#include "../game/objectives.h"
#include "../game/b_local.h"
-#define SCOREBOARD_WIDTH (26*BIGCHAR_WIDTH)
-
+#define SCOREBOARD_WIDTH (26 * BIGCHAR_WIDTH)
/*
static void Scoreboard_Draw( void )
@@ -82,93 +81,87 @@ static void Scoreboard_Draw( void )
}
*/
-
-
/*
=================
CG_MissionFailed
=================
*/
int statusTextIndex = -1;
-void CG_MissionFailed(void)
-{
+void CG_MissionFailed(void) {
char *text;
- if (!cg.missionFailedScreen)
- {
+ if (!cg.missionFailedScreen) {
cgi_UI_SetActive_Menu("missionfailed_menu");
cg.missionFailedScreen = qtrue;
- switch (statusTextIndex)
- {
- case -1: //Our HERO DIED!!!
- text = "@SP_INGAME_MISSIONFAILED_PLAYER";
- break;
- case MISSIONFAILED_JAN:
- text = "@SP_INGAME_MISSIONFAILED_JAN";
- break;
- case MISSIONFAILED_LUKE:
- text = "@SP_INGAME_MISSIONFAILED_LUKE";
- break;
- case MISSIONFAILED_LANDO:
- text = "@SP_INGAME_MISSIONFAILED_LANDO";
- break;
- case MISSIONFAILED_R5D2:
- text = "@SP_INGAME_MISSIONFAILED_R5D2";
- break;
- case MISSIONFAILED_WARDEN:
- text = "@SP_INGAME_MISSIONFAILED_WARDEN";
- break;
- case MISSIONFAILED_PRISONERS:
- text = "@SP_INGAME_MISSIONFAILED_PRISONERS";
- break;
- case MISSIONFAILED_EMPLACEDGUNS:
- text = "@SP_INGAME_MISSIONFAILED_EMPLACEDGUNS";
- break;
- case MISSIONFAILED_LADYLUCK:
- text = "@SP_INGAME_MISSIONFAILED_LADYLUCK";
- break;
- case MISSIONFAILED_KYLECAPTURE:
- text = "@SP_INGAME_MISSIONFAILED_KYLECAPTURE";
- break;
- case MISSIONFAILED_TOOMANYALLIESDIED:
- text = "@SP_INGAME_MISSIONFAILED_TOOMANYALLIESDIED";
- break;
-
- case MISSIONFAILED_CHEWIE:
- text = "@SP_INGAME_MISSIONFAILED_CHEWIE";
- break;
-
- case MISSIONFAILED_KYLE:
- text = "@SP_INGAME_MISSIONFAILED_KYLE";
- break;
-
- case MISSIONFAILED_ROSH:
- text = "@SP_INGAME_MISSIONFAILED_ROSH";
- break;
-
- case MISSIONFAILED_WEDGE:
- text = "@SP_INGAME_MISSIONFAILED_WEDGE";
- break;
-
- case MISSIONFAILED_TURNED:
- text = "@SP_INGAME_MISSIONFAILED_TURNED";
- break;
-
- default:
- text = "@SP_INGAME_MISSIONFAILED_UNKNOWN";
- break;
+ switch (statusTextIndex) {
+ case -1: // Our HERO DIED!!!
+ text = "@SP_INGAME_MISSIONFAILED_PLAYER";
+ break;
+ case MISSIONFAILED_JAN:
+ text = "@SP_INGAME_MISSIONFAILED_JAN";
+ break;
+ case MISSIONFAILED_LUKE:
+ text = "@SP_INGAME_MISSIONFAILED_LUKE";
+ break;
+ case MISSIONFAILED_LANDO:
+ text = "@SP_INGAME_MISSIONFAILED_LANDO";
+ break;
+ case MISSIONFAILED_R5D2:
+ text = "@SP_INGAME_MISSIONFAILED_R5D2";
+ break;
+ case MISSIONFAILED_WARDEN:
+ text = "@SP_INGAME_MISSIONFAILED_WARDEN";
+ break;
+ case MISSIONFAILED_PRISONERS:
+ text = "@SP_INGAME_MISSIONFAILED_PRISONERS";
+ break;
+ case MISSIONFAILED_EMPLACEDGUNS:
+ text = "@SP_INGAME_MISSIONFAILED_EMPLACEDGUNS";
+ break;
+ case MISSIONFAILED_LADYLUCK:
+ text = "@SP_INGAME_MISSIONFAILED_LADYLUCK";
+ break;
+ case MISSIONFAILED_KYLECAPTURE:
+ text = "@SP_INGAME_MISSIONFAILED_KYLECAPTURE";
+ break;
+ case MISSIONFAILED_TOOMANYALLIESDIED:
+ text = "@SP_INGAME_MISSIONFAILED_TOOMANYALLIESDIED";
+ break;
+
+ case MISSIONFAILED_CHEWIE:
+ text = "@SP_INGAME_MISSIONFAILED_CHEWIE";
+ break;
+
+ case MISSIONFAILED_KYLE:
+ text = "@SP_INGAME_MISSIONFAILED_KYLE";
+ break;
+
+ case MISSIONFAILED_ROSH:
+ text = "@SP_INGAME_MISSIONFAILED_ROSH";
+ break;
+
+ case MISSIONFAILED_WEDGE:
+ text = "@SP_INGAME_MISSIONFAILED_WEDGE";
+ break;
+
+ case MISSIONFAILED_TURNED:
+ text = "@SP_INGAME_MISSIONFAILED_TURNED";
+ break;
+
+ default:
+ text = "@SP_INGAME_MISSIONFAILED_UNKNOWN";
+ break;
}
gi.cvar_set("ui_missionfailed_text", text);
}
-// w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f);
-// cgi_R_Font_DrawString(320 - w/2, y+30, text, colorTable[CT_HUD_RED], cgs.media.qhFontMedium, -1, 1.2f);
-
-// cgi_SP_GetStringTextString( "SP_INGAME_RELOADMISSION", text, sizeof(text) );
-// w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
-// cgi_R_Font_DrawString(320 - w/2, 450, text, colorTable[CT_CYAN], cgs.media.qhFontSmall, -1, 1.0f);
+ // w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f);
+ // cgi_R_Font_DrawString(320 - w/2, y+30, text, colorTable[CT_HUD_RED], cgs.media.qhFontMedium, -1, 1.2f);
+ // cgi_SP_GetStringTextString( "SP_INGAME_RELOADMISSION", text, sizeof(text) );
+ // w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
+ // cgi_R_Font_DrawString(320 - w/2, 450, text, colorTable[CT_CYAN], cgs.media.qhFontSmall, -1, 1.0f);
}
/*
@@ -367,18 +360,14 @@ Draw the normal in-game scoreboard
return value is bool to NOT draw centerstring
=================
*/
-qboolean CG_DrawScoreboard( void )
-{
+qboolean CG_DrawScoreboard(void) {
// don't draw anything if the menu is up
- if ( cg_paused.integer )
- {
+ if (cg_paused.integer) {
return qfalse;
}
// Character is either dead, or a script has brought up the screen
- if (((cg.predicted_player_state.pm_type == PM_DEAD) && (cg.missionStatusDeadTime < level.time))
- || (cg.missionStatusShow))
- {
+ if (((cg.predicted_player_state.pm_type == PM_DEAD) && (cg.missionStatusDeadTime < level.time)) || (cg.missionStatusShow)) {
CG_MissionFailed();
return qtrue;
}
@@ -386,9 +375,6 @@ qboolean CG_DrawScoreboard( void )
return qfalse;
}
-void ScoreBoardReset(void)
-{
-}
+void ScoreBoardReset(void) {}
//================================================================================
-
diff --git a/code/cgame/cg_servercmds.cpp b/code/cgame/cg_servercmds.cpp
index 390fe61141..295c274fdd 100644
--- a/code/cgame/cg_servercmds.cpp
+++ b/code/cgame/cg_servercmds.cpp
@@ -28,7 +28,6 @@ along with this program; if not, see .
#include "cg_media.h"
#include "FxScheduler.h"
-
/*
================
CG_ParseServerinfo
@@ -37,190 +36,168 @@ This is called explicitly when the gamestate is first received,
and whenever the server updates any serverinfo flagged cvars
================
*/
-void CG_ParseServerinfo( void ) {
- const char *info;
- const char *mapname;
-
- info = CG_ConfigString( CS_SERVERINFO );
- cgs.dmflags = atoi( Info_ValueForKey( info, "dmflags" ) );
- cgs.teamflags = atoi( Info_ValueForKey( info, "teamflags" ) );
- cgs.timelimit = atoi( Info_ValueForKey( info, "timelimit" ) );
+void CG_ParseServerinfo(void) {
+ const char *info;
+ const char *mapname;
+
+ info = CG_ConfigString(CS_SERVERINFO);
+ cgs.dmflags = atoi(Info_ValueForKey(info, "dmflags"));
+ cgs.teamflags = atoi(Info_ValueForKey(info, "teamflags"));
+ cgs.timelimit = atoi(Info_ValueForKey(info, "timelimit"));
cgs.maxclients = 1;
- mapname = Info_ValueForKey( info, "mapname" );
- Com_sprintf( cgs.mapname, sizeof( cgs.mapname ), "maps/%s.bsp", mapname );
- const char *p = strrchr(mapname,'/');
- Q_strncpyz( cgs.stripLevelName[0], p?p+1:mapname, sizeof(cgs.stripLevelName[0]) );
- Q_strupr( cgs.stripLevelName[0] );
- for (int i=1; i= CS_MODELS && num < CS_MODELS+MAX_MODELS ) {
- cgs.model_draw[ num-CS_MODELS ] = cgi_R_RegisterModel( str );
-// OutputDebugString(va("### CG_ConfigStringModified(): cgs.model_draw[%d] = \"%s\"\n",num-CS_MODELS,str));
-// GHOUL2 Insert start
- } else if ( num >= CS_CHARSKINS && num < CS_CHARSKINS+MAX_CHARSKINS ) {
- cgs.skins[ num-CS_CHARSKINS ] = cgi_R_RegisterSkin( str );
-// Ghoul2 Insert end
- } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) {
- if ( str[0] != '*' ) {
- cgs.sound_precache[ num-CS_SOUNDS] = cgi_S_RegisterSound( str );
+ } else if (num >= CS_MODELS && num < CS_MODELS + MAX_MODELS) {
+ cgs.model_draw[num - CS_MODELS] = cgi_R_RegisterModel(str);
+ // OutputDebugString(va("### CG_ConfigStringModified(): cgs.model_draw[%d] = \"%s\"\n",num-CS_MODELS,str));
+ // GHOUL2 Insert start
+ } else if (num >= CS_CHARSKINS && num < CS_CHARSKINS + MAX_CHARSKINS) {
+ cgs.skins[num - CS_CHARSKINS] = cgi_R_RegisterSkin(str);
+ // Ghoul2 Insert end
+ } else if (num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS) {
+ if (str[0] != '*') {
+ cgs.sound_precache[num - CS_SOUNDS] = cgi_S_RegisterSound(str);
}
- }
- else if ( num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX )
- {
- theFxScheduler.RegisterEffect( str );
- }
- else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) {
- CG_NewClientinfo( num - CS_PLAYERS );
- CG_RegisterClientModels( num - CS_PLAYERS );
- }
- else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES*3))
- {
+ } else if (num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX) {
+ theFxScheduler.RegisterEffect(str);
+ } else if (num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS) {
+ CG_NewClientinfo(num - CS_PLAYERS);
+ CG_RegisterClientModels(num - CS_PLAYERS);
+ } else if (num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3)) {
CG_SetLightstyle(num - CS_LIGHT_STYLES);
- }
- else if ( num >= CS_WORLD_FX && num < CS_WORLD_FX + MAX_WORLD_FX )
- {
- cgi_R_WorldEffectCommand( str );
+ } else if (num >= CS_WORLD_FX && num < CS_WORLD_FX + MAX_WORLD_FX) {
+ cgi_R_WorldEffectCommand(str);
}
}
-static void CG_CenterPrint_f( void ) {
- CG_CenterPrint( CG_Argv( 1 ), SCREEN_HEIGHT * 0.25 );
-}
+static void CG_CenterPrint_f(void) { CG_CenterPrint(CG_Argv(1), SCREEN_HEIGHT * 0.25); }
-static void CG_Print_f( void ) {
- CG_Printf( "%s", CG_Argv( 1 ) );
-}
+static void CG_Print_f(void) { CG_Printf("%s", CG_Argv(1)); }
-static void CG_CaptionText_f( void ) {
- sfxHandle_t sound = (sfxHandle_t)atoi( CG_Argv( 2 ) );
+static void CG_CaptionText_f(void) {
+ sfxHandle_t sound = (sfxHandle_t)atoi(CG_Argv(2));
- CG_CaptionText( CG_Argv( 1 ), sound >= 0 && sound < MAX_SOUNDS ? cgs.sound_precache[sound] : NULL_SOUND );
+ CG_CaptionText(CG_Argv(1), sound >= 0 && sound < MAX_SOUNDS ? cgs.sound_precache[sound] : NULL_SOUND);
}
-static void CG_ScrollText_f( void ) {
- CG_ScrollText( CG_Argv( 1 ), SCREEN_WIDTH - 16 );
-}
+static void CG_ScrollText_f(void) { CG_ScrollText(CG_Argv(1), SCREEN_WIDTH - 16); }
-static void CG_LCARSText_f( void ) {
- CG_Printf( "CG_LCARSText() being called. Tell Ste\n" "String: \"%s\"\n", CG_Argv( 1 ) );
+static void CG_LCARSText_f(void) {
+ CG_Printf("CG_LCARSText() being called. Tell Ste\n"
+ "String: \"%s\"\n",
+ CG_Argv(1));
}
-static void CG_ClientLevelShot_f( void ) {
+static void CG_ClientLevelShot_f(void) {
// clientLevelShot is sent before taking a special screenshot for
// the menu system during development
cg.levelShot = qtrue;
}
typedef struct serverCommand_s {
- const char *cmd;
- void (*func)(void);
+ const char *cmd;
+ void (*func)(void);
} serverCommand_t;
-static int svcmdcmp( const void *a, const void *b ) {
- return Q_stricmp( (const char *)a, ((serverCommand_t*)b)->cmd );
-}
+static int svcmdcmp(const void *a, const void *b) { return Q_stricmp((const char *)a, ((serverCommand_t *)b)->cmd); }
/* This array MUST be sorted correctly by alphabetical name field */
-static serverCommand_t commands[] = {
- { "chat", CG_Print_f },
- { "clientLevelShot", CG_ClientLevelShot_f },
- { "cp", CG_CenterPrint_f },
- { "cs", CG_ConfigStringModified },
- { "ct", CG_CaptionText_f },
- { "cts", CG_CaptionTextStop },
- { "lt", CG_LCARSText_f },
- { "print", CG_Print_f },
- { "st", CG_ScrollText_f },
+static serverCommand_t commands[] = {
+ {"chat", CG_Print_f}, {"clientLevelShot", CG_ClientLevelShot_f},
+ {"cp", CG_CenterPrint_f}, {"cs", CG_ConfigStringModified},
+ {"ct", CG_CaptionText_f}, {"cts", CG_CaptionTextStop},
+ {"lt", CG_LCARSText_f}, {"print", CG_Print_f},
+ {"st", CG_ScrollText_f},
};
-static const size_t numCommands = ARRAY_LEN( commands );
+static const size_t numCommands = ARRAY_LEN(commands);
/*
=================
@@ -230,26 +207,25 @@ The string has been tokenized and can be retrieved with
Cmd_Argc() / Cmd_Argv()
=================
*/
-static void CG_ServerCommand( void ) {
- const char *cmd = CG_Argv( 0 );
- serverCommand_t *command = NULL;
+static void CG_ServerCommand(void) {
+ const char *cmd = CG_Argv(0);
+ serverCommand_t *command = NULL;
- if ( !cmd[0] ) {
+ if (!cmd[0]) {
// server claimed the command
return;
}
- command = (serverCommand_t *)Q_LinearSearch( cmd, commands, numCommands, sizeof( commands[0] ), svcmdcmp );
+ command = (serverCommand_t *)Q_LinearSearch(cmd, commands, numCommands, sizeof(commands[0]), svcmdcmp);
- if ( command ) {
+ if (command) {
command->func();
return;
}
- CG_Printf( "Unknown client game command: %s\n", cmd );
+ CG_Printf("Unknown client game command: %s\n", cmd);
}
-
/*
====================
CG_ExecuteNewServerCommands
@@ -258,9 +234,9 @@ Execute all of the server commands that were received along
with this this snapshot.
====================
*/
-void CG_ExecuteNewServerCommands( int latestSequence ) {
- while ( cgs.serverCommandSequence < latestSequence ) {
- if ( cgi_GetServerCommand( ++cgs.serverCommandSequence ) ) {
+void CG_ExecuteNewServerCommands(int latestSequence) {
+ while (cgs.serverCommandSequence < latestSequence) {
+ if (cgi_GetServerCommand(++cgs.serverCommandSequence)) {
CG_ServerCommand();
}
}
diff --git a/code/cgame/cg_snapshot.cpp b/code/cgame/cg_snapshot.cpp
index 78f16f6908..fa9d0c9958 100644
--- a/code/cgame/cg_snapshot.cpp
+++ b/code/cgame/cg_snapshot.cpp
@@ -26,23 +26,22 @@ along with this program; if not, see .
#include "cg_headers.h"
-
/*
==================
CG_ResetEntity
==================
*/
-void CG_ResetEntity( centity_t *cent ) {
+void CG_ResetEntity(centity_t *cent) {
// if an event is set, assume it is new enough to use
// if the event had timed out, it would have been cleared
cent->previousEvent = 0;
-// cent->trailTime = cg.snap->serverTime;
+ // cent->trailTime = cg.snap->serverTime;
- VectorCopy (cent->currentState.origin, cent->lerpOrigin);
- VectorCopy (cent->currentState.angles, cent->lerpAngles);
- if ( cent->currentState.eType == ET_PLAYER ) {
- CG_ResetPlayerEntity( cent );
+ VectorCopy(cent->currentState.origin, cent->lerpOrigin);
+ VectorCopy(cent->currentState.angles, cent->lerpAngles);
+ if (cent->currentState.eType == ET_PLAYER) {
+ CG_ResetPlayerEntity(cent);
}
}
@@ -53,28 +52,26 @@ CG_TransitionEntity
cent->nextState is moved to cent->currentState and events are fired
===============
*/
-void CG_TransitionEntity( centity_t *cent ) {
+void CG_TransitionEntity(centity_t *cent) {
if (cent->nextState) {
cent->currentState = *cent->nextState;
}
cent->currentValid = qtrue;
// reset if the entity wasn't in the last frame or was teleported
- if ( !cent->interpolate ) {
- CG_ResetEntity( cent );
+ if (!cent->interpolate) {
+ CG_ResetEntity(cent);
}
// clear the next state. if will be set by the next CG_SetNextSnap
cent->interpolate = qfalse;
- if ( cent->currentState.number != 0 )
- {
+ if (cent->currentState.number != 0) {
// check for events
- CG_CheckEvents( cent );
+ CG_CheckEvents(cent);
}
}
-
/*
==================
CG_SetInitialSnapshot
@@ -84,38 +81,37 @@ on tourney restarts. All other times will use
CG_TransitionSnapshot instead.
==================
*/
-void CG_SetInitialSnapshot( snapshot_t *snap ) {
- int i;
- centity_t *cent;
- entityState_t *state;
+void CG_SetInitialSnapshot(snapshot_t *snap) {
+ int i;
+ centity_t *cent;
+ entityState_t *state;
cg.snap = snap;
// sort out solid entities
- //CG_BuildSolidList();
+ // CG_BuildSolidList();
- CG_ExecuteNewServerCommands( snap->serverCommandSequence );
+ CG_ExecuteNewServerCommands(snap->serverCommandSequence);
// set our local weapon selection pointer to
// what the server has indicated the current weapon is
CG_Respawn();
- for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
- state = &cg.snap->entities[ i ];
- cent = &cg_entities[ state->number ];
+ for (i = 0; i < cg.snap->numEntities; i++) {
+ state = &cg.snap->entities[i];
+ cent = &cg_entities[state->number];
cent->currentState = *state;
cent->interpolate = qfalse;
cent->currentValid = qtrue;
- CG_ResetEntity( cent );
+ CG_ResetEntity(cent);
// check for events
- CG_CheckEvents( cent );
+ CG_CheckEvents(cent);
}
}
-
/*
===================
CG_TransitionSnapshot
@@ -123,24 +119,24 @@ CG_TransitionSnapshot
The transition point from snap to nextSnap has passed
===================
*/
-void CG_TransitionSnapshot( void ) {
- centity_t *cent;
- snapshot_t *oldFrame;
- int i;
+void CG_TransitionSnapshot(void) {
+ centity_t *cent;
+ snapshot_t *oldFrame;
+ int i;
- if ( !cg.snap ) {
- CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
+ if (!cg.snap) {
+ CG_Error("CG_TransitionSnapshot: NULL cg.snap");
}
- if ( !cg.nextSnap ) {
- CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
+ if (!cg.nextSnap) {
+ CG_Error("CG_TransitionSnapshot: NULL cg.nextSnap");
}
// execute any server string commands before transitioning entities
- CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );
+ CG_ExecuteNewServerCommands(cg.nextSnap->serverCommandSequence);
// clear the currentValid flag for all entities in the existing snapshot
- for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
- cent = &cg_entities[ cg.snap->entities[ i ].number ];
+ for (i = 0; i < cg.snap->numEntities; i++) {
+ cent = &cg_entities[cg.snap->entities[i].number];
cent->currentValid = qfalse;
}
@@ -149,32 +145,28 @@ void CG_TransitionSnapshot( void ) {
cg.snap = cg.nextSnap;
// sort out solid entities
- //CG_BuildSolidList();
+ // CG_BuildSolidList();
- for ( i = 0 ; i < cg.snap->numEntities ; i++ )
- {
- if ( 1 ) //cg.snap->entities[ i ].number != 0 ) // I guess the player adds his/her events elsewhere, so doing this also gives us double events for the player!
+ for (i = 0; i < cg.snap->numEntities; i++) {
+ if (1) // cg.snap->entities[ i ].number != 0 ) // I guess the player adds his/her events elsewhere, so doing this also gives us double events for the
+ // player!
{
- cent = &cg_entities[ cg.snap->entities[ i ].number ];
- CG_TransitionEntity( cent );
+ cent = &cg_entities[cg.snap->entities[i].number];
+ CG_TransitionEntity(cent);
}
}
cg.nextSnap = NULL;
// check for playerstate transition events
- if ( oldFrame ) {
+ if (oldFrame) {
// if we are not doing client side movement prediction for any
// reason, then the client events and view changes will be issued now
- //if ( cg_timescale.value >= 1.0f )
- {
- CG_TransitionPlayerState( &cg.snap->ps, &oldFrame->ps );
- }
+ // if ( cg_timescale.value >= 1.0f )
+ { CG_TransitionPlayerState(&cg.snap->ps, &oldFrame->ps); }
}
-
}
-
/*
===============
CG_SetEntityNextState
@@ -183,25 +175,23 @@ Determine if the entity can be interpolated between the states
present in cg.snap and cg,nextSnap
===============
*/
-void CG_SetEntityNextState( centity_t *cent, entityState_t *state ) {
+void CG_SetEntityNextState(centity_t *cent, entityState_t *state) {
cent->nextState = state;
// since we can't interpolate ghoul2 stuff from one frame to another, I'm just going to copy the ghoul2 info directly into the current state now
-// CGhoul2Info *currentModel = &state->ghoul2[1];
-// cent->gent->ghoul2 = state->ghoul2;
-// CGhoul2Info *newModel = ¢->gent->ghoul2[1];
-
+ // CGhoul2Info *currentModel = &state->ghoul2[1];
+ // cent->gent->ghoul2 = state->ghoul2;
+ // CGhoul2Info *newModel = ¢->gent->ghoul2[1];
// if this frame is a teleport, or the entity wasn't in the
// previous frame, don't interpolate
- if ( !cent->currentValid || ( ( cent->currentState.eFlags ^ state->eFlags ) & EF_TELEPORT_BIT ) ) {
+ if (!cent->currentValid || ((cent->currentState.eFlags ^ state->eFlags) & EF_TELEPORT_BIT)) {
cent->interpolate = qfalse;
} else {
cent->interpolate = qtrue;
}
}
-
/*
===================
CG_SetNextSnap
@@ -209,29 +199,28 @@ CG_SetNextSnap
A new snapshot has just been read in from the client system.
===================
*/
-void CG_SetNextSnap( snapshot_t *snap ) {
- int num;
- entityState_t *es;
- centity_t *cent;
+void CG_SetNextSnap(snapshot_t *snap) {
+ int num;
+ entityState_t *es;
+ centity_t *cent;
cg.nextSnap = snap;
// check for extrapolation errors
- for ( num = 0 ; num < snap->numEntities ; num++ ) {
+ for (num = 0; num < snap->numEntities; num++) {
es = &snap->entities[num];
- cent = &cg_entities[ es->number ];
- CG_SetEntityNextState( cent, es );
+ cent = &cg_entities[es->number];
+ CG_SetEntityNextState(cent, es);
}
// if the next frame is a teleport for the playerstate,
- if ( cg.snap && ( ( snap->ps.eFlags ^ cg.snap->ps.eFlags ) & EF_TELEPORT_BIT ) ) {
+ if (cg.snap && ((snap->ps.eFlags ^ cg.snap->ps.eFlags) & EF_TELEPORT_BIT)) {
cg.nextFrameTeleport = qtrue;
} else {
cg.nextFrameTeleport = qfalse;
}
}
-
/*
========================
CG_ReadNextSnapshot
@@ -242,13 +231,13 @@ times if the client system fails to return a
valid snapshot.
========================
*/
-snapshot_t *CG_ReadNextSnapshot( void ) {
- qboolean r;
- snapshot_t *dest;
+snapshot_t *CG_ReadNextSnapshot(void) {
+ qboolean r;
+ snapshot_t *dest;
- while ( cg.processedSnapshotNum < cg.latestSnapshotNum ) {
+ while (cg.processedSnapshotNum < cg.latestSnapshotNum) {
// decide which of the two slots to load it into
- if ( cg.snap == &cg.activeSnapshots[0] ) {
+ if (cg.snap == &cg.activeSnapshots[0]) {
dest = &cg.activeSnapshots[1];
} else {
dest = &cg.activeSnapshots[0];
@@ -256,10 +245,10 @@ snapshot_t *CG_ReadNextSnapshot( void ) {
// try to read the snapshot from the client system
cg.processedSnapshotNum++;
- r = cgi_GetSnapshot( cg.processedSnapshotNum, dest );
+ r = cgi_GetSnapshot(cg.processedSnapshotNum, dest);
// if it succeeded, return
- if ( r ) {
+ if (r) {
return dest;
}
@@ -269,7 +258,7 @@ snapshot_t *CG_ReadNextSnapshot( void ) {
// buffer in the client system.
// record as a dropped packet
-// CG_AddLagometerSnapshotInfo( NULL );
+ // CG_AddLagometerSnapshotInfo( NULL );
// If there are additional snapshots, continue trying to
// read them.
@@ -288,13 +277,13 @@ require a reload of all the media
=================
*/
extern void CG_LinkCentsToGents(void);
-static void CG_RestartLevel( void ) {
- int snapshotNum;
- int r;
+static void CG_RestartLevel(void) {
+ int snapshotNum;
+ int r;
snapshotNum = cg.processedSnapshotNum;
- memset( cg_entities, 0, sizeof( cg_entities ) );
+ memset(cg_entities, 0, sizeof(cg_entities));
CG_Init_CG();
CG_LinkCentsToGents();
@@ -304,16 +293,15 @@ static void CG_RestartLevel( void ) {
// regrab the first snapshot of the restart
cg.processedSnapshotNum = snapshotNum;
- r = cgi_GetSnapshot( cg.processedSnapshotNum, &cg.activeSnapshots[0] );
- if ( !r ) {
- CG_Error( "cgi_GetSnapshot failed on restart" );
+ r = cgi_GetSnapshot(cg.processedSnapshotNum, &cg.activeSnapshots[0]);
+ if (!r) {
+ CG_Error("cgi_GetSnapshot failed on restart");
}
- CG_SetInitialSnapshot( &cg.activeSnapshots[0] );
+ CG_SetInitialSnapshot(&cg.activeSnapshots[0]);
cg.time = cg.snap->serverTime;
}
-
/*
============
CG_ProcessSnapshots
@@ -333,16 +321,16 @@ of an interpolating one)
============
*/
-void CG_ProcessSnapshots( void ) {
- snapshot_t *snap;
- int n;
+void CG_ProcessSnapshots(void) {
+ snapshot_t *snap;
+ int n;
// see what the latest snapshot the client system has is
- cgi_GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime );
- if ( n != cg.latestSnapshotNum ) {
- if ( n < cg.latestSnapshotNum ) {
+ cgi_GetCurrentSnapshotNumber(&n, &cg.latestSnapshotTime);
+ if (n != cg.latestSnapshotNum) {
+ if (n < cg.latestSnapshotNum) {
// this should never happen
- CG_Error( "CG_ProcessSnapshots: n < cg.latestSnapshotNum" );
+ CG_Error("CG_ProcessSnapshots: n < cg.latestSnapshotNum");
}
cg.latestSnapshotNum = n;
}
@@ -350,16 +338,16 @@ void CG_ProcessSnapshots( void ) {
// If we have yet to receive a snapshot, check for it.
// Once we have gotten the first snapshot, cg.snap will
// always have valid data for the rest of the game
- if ( !cg.snap ) {
+ if (!cg.snap) {
snap = CG_ReadNextSnapshot();
- if ( !snap ) {
+ if (!snap) {
// we can't continue until we get a snapshot
return;
}
// set our weapon selection to what
// the playerstate is currently using
- CG_SetInitialSnapshot( snap );
+ CG_SetInitialSnapshot(snap);
}
// loop until we either have a valid nextSnap with a serverTime
@@ -367,58 +355,54 @@ void CG_ProcessSnapshots( void ) {
// out of available snapshots
do {
// if we don't have a nextframe, try to read a new one in
- if ( !cg.nextSnap ) {
+ if (!cg.nextSnap) {
snap = CG_ReadNextSnapshot();
// if we still don't have a nextframe, we will just have to
// extrapolate
- if ( !snap ) {
+ if (!snap) {
break;
}
- CG_SetNextSnap( snap );
+ CG_SetNextSnap(snap);
// if time went backwards, we have a level restart
- if ( cg.nextSnap->serverTime < cg.snap->serverTime ) {
+ if (cg.nextSnap->serverTime < cg.snap->serverTime) {
// restart the level
CG_RestartLevel();
- continue; // we might also get a nextsnap
+ continue; // we might also get a nextsnap
}
}
// if our time is < nextFrame's, we have a nice interpolating state
- if ( cg.time < cg.nextSnap->serverTime ) {
+ if (cg.time < cg.nextSnap->serverTime) {
break;
}
// we have passed the transition from nextFrame to frame
CG_TransitionSnapshot();
- } while ( 1 );
+ } while (1);
- if ( cg.snap->serverTime > cg.time )
- {
- cg.time=cg.snap->serverTime;
+ if (cg.snap->serverTime > cg.time) {
+ cg.time = cg.snap->serverTime;
#if _DEBUG
Com_Printf("CG_ProcessSnapshots: cg.snap->serverTime > cg.time");
#endif
-
}
- if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time )
- {
- cg.time=cg.nextSnap->serverTime-1;
+ if (cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time) {
+ cg.time = cg.nextSnap->serverTime - 1;
#if _DEBUG
Com_Printf("CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time");
#endif
}
// assert our valid conditions upon exiting
- if ( cg.snap == NULL ) {
- CG_Error( "CG_ProcessSnapshots: cg.snap == NULL" );
+ if (cg.snap == NULL) {
+ CG_Error("CG_ProcessSnapshots: cg.snap == NULL");
}
- if ( cg.snap->serverTime > cg.time ) {
- CG_Error( "CG_ProcessSnapshots: cg.snap->serverTime > cg.time" );
+ if (cg.snap->serverTime > cg.time) {
+ CG_Error("CG_ProcessSnapshots: cg.snap->serverTime > cg.time");
}
- if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) {
- CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" );
+ if (cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time) {
+ CG_Error("CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time");
}
}
-
diff --git a/code/cgame/cg_syscalls.cpp b/code/cgame/cg_syscalls.cpp
index 7c20a9c2df..5c0cc2c300 100644
--- a/code/cgame/cg_syscalls.cpp
+++ b/code/cgame/cg_syscalls.cpp
@@ -25,569 +25,329 @@ along with this program; if not, see .
// this file is only included when building a dll
-//prototypes
+// prototypes
extern void CG_PreInit();
-static intptr_t (QDECL *Q_syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
+static intptr_t(QDECL *Q_syscall)(intptr_t arg, ...) = (intptr_t(QDECL *)(intptr_t, ...)) - 1;
-extern "C" Q_EXPORT void QDECL dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg, ... ) ) {
+extern "C" Q_EXPORT void QDECL dllEntry(intptr_t(QDECL *syscallptr)(intptr_t arg, ...)) {
Q_syscall = syscallptr;
CG_PreInit();
}
-
-inline int PASSFLOAT( float x ) {
+inline int PASSFLOAT(float x) {
byteAlias_t fi;
fi.f = x;
return fi.i;
}
-void cgi_Printf( const char *fmt ) {
- Q_syscall( CG_PRINT, fmt );
-}
+void cgi_Printf(const char *fmt) { Q_syscall(CG_PRINT, fmt); }
-NORETURN void cgi_Error( const char *fmt ) {
- Q_syscall( CG_ERROR, fmt );
+NORETURN void cgi_Error(const char *fmt) {
+ Q_syscall(CG_ERROR, fmt);
// shut up GCC warning about returning functions, because we know better
exit(1);
}
-int cgi_Milliseconds( void ) {
- return Q_syscall( CG_MILLISECONDS );
-}
+int cgi_Milliseconds(void) { return Q_syscall(CG_MILLISECONDS); }
-void cgi_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) {
- Q_syscall( CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags );
+void cgi_Cvar_Register(vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags) {
+ Q_syscall(CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags);
}
-void cgi_Cvar_Update( vmCvar_t *vmCvar ) {
- Q_syscall( CG_CVAR_UPDATE, vmCvar );
-}
+void cgi_Cvar_Update(vmCvar_t *vmCvar) { Q_syscall(CG_CVAR_UPDATE, vmCvar); }
-void cgi_Cvar_Set( const char *var_name, const char *value ) {
- Q_syscall( CG_CVAR_SET, var_name, value );
-}
+void cgi_Cvar_Set(const char *var_name, const char *value) { Q_syscall(CG_CVAR_SET, var_name, value); }
-int cgi_Argc( void ) {
- return Q_syscall( CG_ARGC );
-}
+int cgi_Argc(void) { return Q_syscall(CG_ARGC); }
-void cgi_Argv( int n, char *buffer, int bufferLength ) {
- Q_syscall( CG_ARGV, n, buffer, bufferLength );
-}
+void cgi_Argv(int n, char *buffer, int bufferLength) { Q_syscall(CG_ARGV, n, buffer, bufferLength); }
-void cgi_Args( char *buffer, int bufferLength ) {
- Q_syscall( CG_ARGS, buffer, bufferLength );
-}
+void cgi_Args(char *buffer, int bufferLength) { Q_syscall(CG_ARGS, buffer, bufferLength); }
-int cgi_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
- return Q_syscall( CG_FS_FOPENFILE, qpath, f, mode );
-}
+int cgi_FS_FOpenFile(const char *qpath, fileHandle_t *f, fsMode_t mode) { return Q_syscall(CG_FS_FOPENFILE, qpath, f, mode); }
-int cgi_FS_Read( void *buffer, int len, fileHandle_t f ) {
- return Q_syscall( CG_FS_READ, buffer, len, f );
-}
+int cgi_FS_Read(void *buffer, int len, fileHandle_t f) { return Q_syscall(CG_FS_READ, buffer, len, f); }
-int cgi_FS_Write( const void *buffer, int len, fileHandle_t f ) {
- return Q_syscall( CG_FS_WRITE, buffer, len, f );
-}
+int cgi_FS_Write(const void *buffer, int len, fileHandle_t f) { return Q_syscall(CG_FS_WRITE, buffer, len, f); }
-void cgi_FS_FCloseFile( fileHandle_t f ) {
- Q_syscall( CG_FS_FCLOSEFILE, f );
-}
+void cgi_FS_FCloseFile(fileHandle_t f) { Q_syscall(CG_FS_FCLOSEFILE, f); }
-void cgi_SendConsoleCommand( const char *text ) {
- Q_syscall( CG_SENDCONSOLECOMMAND, text );
-}
+void cgi_SendConsoleCommand(const char *text) { Q_syscall(CG_SENDCONSOLECOMMAND, text); }
-void cgi_AddCommand( const char *cmdName ) {
- Q_syscall( CG_ADDCOMMAND, cmdName );
-}
+void cgi_AddCommand(const char *cmdName) { Q_syscall(CG_ADDCOMMAND, cmdName); }
-void cgi_SendClientCommand( const char *s ) {
- Q_syscall( CG_SENDCLIENTCOMMAND, s );
-}
+void cgi_SendClientCommand(const char *s) { Q_syscall(CG_SENDCLIENTCOMMAND, s); }
-void cgi_UpdateScreen( void ) {
- Q_syscall( CG_UPDATESCREEN );
-}
+void cgi_UpdateScreen(void) { Q_syscall(CG_UPDATESCREEN); }
-//RMG BEGIN
-void cgi_RMG_Init(int terrainID, const char *terrainInfo)
-{
- Q_syscall( CG_RMG_INIT, terrainID, terrainInfo);
-}
+// RMG BEGIN
+void cgi_RMG_Init(int terrainID, const char *terrainInfo) { Q_syscall(CG_RMG_INIT, terrainID, terrainInfo); }
-int cgi_CM_RegisterTerrain(const char *terrainInfo)
-{
- return Q_syscall( CG_CM_REGISTER_TERRAIN, terrainInfo);
-}
+int cgi_CM_RegisterTerrain(const char *terrainInfo) { return Q_syscall(CG_CM_REGISTER_TERRAIN, terrainInfo); }
-void cgi_RE_InitRendererTerrain( const char *terrainInfo )
-{
- Q_syscall(CG_RE_INIT_RENDERER_TERRAIN, terrainInfo);
-}
-//RMG END
+void cgi_RE_InitRendererTerrain(const char *terrainInfo) { Q_syscall(CG_RE_INIT_RENDERER_TERRAIN, terrainInfo); }
+// RMG END
-void cgi_CM_LoadMap( const char *mapname, qboolean subBSP ) {
- Q_syscall( CG_CM_LOADMAP, mapname, subBSP );
-}
+void cgi_CM_LoadMap(const char *mapname, qboolean subBSP) { Q_syscall(CG_CM_LOADMAP, mapname, subBSP); }
-int cgi_CM_NumInlineModels( void ) {
- return Q_syscall( CG_CM_NUMINLINEMODELS );
-}
+int cgi_CM_NumInlineModels(void) { return Q_syscall(CG_CM_NUMINLINEMODELS); }
-clipHandle_t cgi_CM_InlineModel( int index ) {
- return Q_syscall( CG_CM_INLINEMODEL, index );
-}
+clipHandle_t cgi_CM_InlineModel(int index) { return Q_syscall(CG_CM_INLINEMODEL, index); }
-clipHandle_t cgi_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs ) {//, const int contents ) {
- return Q_syscall( CG_CM_TEMPBOXMODEL, mins, maxs );//, contents );
+clipHandle_t cgi_CM_TempBoxModel(const vec3_t mins, const vec3_t maxs) { //, const int contents ) {
+ return Q_syscall(CG_CM_TEMPBOXMODEL, mins, maxs); //, contents );
}
-int cgi_CM_PointContents( const vec3_t p, clipHandle_t model ) {
- return Q_syscall( CG_CM_POINTCONTENTS, p, model );
-}
+int cgi_CM_PointContents(const vec3_t p, clipHandle_t model) { return Q_syscall(CG_CM_POINTCONTENTS, p, model); }
-int cgi_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ) {
- return Q_syscall( CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles );
+int cgi_CM_TransformedPointContents(const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles) {
+ return Q_syscall(CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles);
}
-void cgi_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
- const vec3_t mins, const vec3_t maxs,
- clipHandle_t model, int brushmask ) {
- Q_syscall( CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask );
+void cgi_CM_BoxTrace(trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask) {
+ Q_syscall(CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask);
}
-void cgi_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
- const vec3_t mins, const vec3_t maxs,
- clipHandle_t model, int brushmask,
- const vec3_t origin, const vec3_t angles ) {
- Q_syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
+void cgi_CM_TransformedBoxTrace(trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask,
+ const vec3_t origin, const vec3_t angles) {
+ Q_syscall(CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles);
}
-int cgi_CM_MarkFragments( int numPoints, const vec3_t *points,
- const vec3_t projection,
- int maxPoints, vec3_t pointBuffer,
- int maxFragments, markFragment_t *fragmentBuffer ) {
- return Q_syscall( CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments, fragmentBuffer );
+int cgi_CM_MarkFragments(int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments,
+ markFragment_t *fragmentBuffer) {
+ return Q_syscall(CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments, fragmentBuffer);
}
-void cgi_CM_SnapPVS(vec3_t origin,byte *buffer)
-{
- Q_syscall(CG_CM_SNAPPVS,origin,buffer);
-}
+void cgi_CM_SnapPVS(vec3_t origin, byte *buffer) { Q_syscall(CG_CM_SNAPPVS, origin, buffer); }
-void cgi_S_StopSounds( void )
-{
- Q_syscall( CG_S_STOPSOUNDS);
-}
+void cgi_S_StopSounds(void) { Q_syscall(CG_S_STOPSOUNDS); }
-void cgi_S_StartSound( const vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ) {
- Q_syscall( CG_S_STARTSOUND, origin, entityNum, entchannel, sfx );
-}
+void cgi_S_StartSound(const vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx) { Q_syscall(CG_S_STARTSOUND, origin, entityNum, entchannel, sfx); }
-void cgi_AS_ParseSets( void ) {
- Q_syscall( CG_AS_PARSESETS );
-}
+void cgi_AS_ParseSets(void) { Q_syscall(CG_AS_PARSESETS); }
-void cgi_AS_AddPrecacheEntry( const char *name ) {
- Q_syscall( CG_AS_ADDENTRY, name );
-}
+void cgi_AS_AddPrecacheEntry(const char *name) { Q_syscall(CG_AS_ADDENTRY, name); }
-void cgi_S_UpdateAmbientSet( const char *name, vec3_t origin ) {
- Q_syscall( CG_S_UPDATEAMBIENTSET, name, origin );
-}
+void cgi_S_UpdateAmbientSet(const char *name, vec3_t origin) { Q_syscall(CG_S_UPDATEAMBIENTSET, name, origin); }
-int cgi_S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time ) {
- return Q_syscall( CG_S_ADDLOCALSET, name, listener_origin, origin, entID, time );
+int cgi_S_AddLocalSet(const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time) {
+ return Q_syscall(CG_S_ADDLOCALSET, name, listener_origin, origin, entID, time);
}
-sfxHandle_t cgi_AS_GetBModelSound( const char *name, int stage ) {
- return Q_syscall( CG_AS_GETBMODELSOUND, name, stage );
-}
+sfxHandle_t cgi_AS_GetBModelSound(const char *name, int stage) { return Q_syscall(CG_AS_GETBMODELSOUND, name, stage); }
-void cgi_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {
- Q_syscall( CG_S_STARTLOCALSOUND, sfx, channelNum );
-}
+void cgi_S_StartLocalSound(sfxHandle_t sfx, int channelNum) { Q_syscall(CG_S_STARTLOCALSOUND, sfx, channelNum); }
-void cgi_S_ClearLoopingSounds( void ) {
- Q_syscall( CG_S_CLEARLOOPINGSOUNDS );
-}
+void cgi_S_ClearLoopingSounds(void) { Q_syscall(CG_S_CLEARLOOPINGSOUNDS); }
-void cgi_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx, soundChannel_t chan ) {
- Q_syscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx, chan );
+void cgi_S_AddLoopingSound(int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx, soundChannel_t chan) {
+ Q_syscall(CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx, chan);
}
-void cgi_S_UpdateEntityPosition( int entityNum, const vec3_t origin ) {
- Q_syscall( CG_S_UPDATEENTITYPOSITION, entityNum, origin );
-}
+void cgi_S_UpdateEntityPosition(int entityNum, const vec3_t origin) { Q_syscall(CG_S_UPDATEENTITYPOSITION, entityNum, origin); }
-void cgi_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], qboolean inwater ) {
- Q_syscall( CG_S_RESPATIALIZE, entityNum, origin, axis, inwater );
+void cgi_S_Respatialize(int entityNum, const vec3_t origin, vec3_t axis[3], qboolean inwater) {
+ Q_syscall(CG_S_RESPATIALIZE, entityNum, origin, axis, inwater);
}
-sfxHandle_t cgi_S_RegisterSound( const char *sample ) {
- return Q_syscall( CG_S_REGISTERSOUND, sample );
-}
+sfxHandle_t cgi_S_RegisterSound(const char *sample) { return Q_syscall(CG_S_REGISTERSOUND, sample); }
-void cgi_S_StartBackgroundTrack( const char *intro, const char *loop, qboolean bForceStart ) {
- Q_syscall( CG_S_STARTBACKGROUNDTRACK, intro, loop, bForceStart );
-}
+void cgi_S_StartBackgroundTrack(const char *intro, const char *loop, qboolean bForceStart) { Q_syscall(CG_S_STARTBACKGROUNDTRACK, intro, loop, bForceStart); }
-float cgi_S_GetSampleLength( sfxHandle_t sfx ) {
- return Q_syscall( CG_S_GETSAMPLELENGTH, sfx);
-}
+float cgi_S_GetSampleLength(sfxHandle_t sfx) { return Q_syscall(CG_S_GETSAMPLELENGTH, sfx); }
-void cgi_R_LoadWorldMap( const char *mapname ) {
- Q_syscall( CG_R_LOADWORLDMAP, mapname );
-}
+void cgi_R_LoadWorldMap(const char *mapname) { Q_syscall(CG_R_LOADWORLDMAP, mapname); }
-qhandle_t cgi_R_RegisterModel( const char *name ) {
- return Q_syscall( CG_R_REGISTERMODEL, name );
-}
+qhandle_t cgi_R_RegisterModel(const char *name) { return Q_syscall(CG_R_REGISTERMODEL, name); }
-qhandle_t cgi_R_RegisterSkin( const char *name ) {
- return Q_syscall( CG_R_REGISTERSKIN, name );
-}
+qhandle_t cgi_R_RegisterSkin(const char *name) { return Q_syscall(CG_R_REGISTERSKIN, name); }
-qhandle_t cgi_R_RegisterShader( const char *name ) {
- return Q_syscall( CG_R_REGISTERSHADER, name );
-}
+qhandle_t cgi_R_RegisterShader(const char *name) { return Q_syscall(CG_R_REGISTERSHADER, name); }
-qhandle_t cgi_R_RegisterShaderNoMip( const char *name ) {
- return Q_syscall( CG_R_REGISTERSHADERNOMIP, name );
-}
+qhandle_t cgi_R_RegisterShaderNoMip(const char *name) { return Q_syscall(CG_R_REGISTERSHADERNOMIP, name); }
-qhandle_t cgi_R_RegisterFont( const char *name ) {
- return Q_syscall( CG_R_REGISTERFONT, name );
-}
+qhandle_t cgi_R_RegisterFont(const char *name) { return Q_syscall(CG_R_REGISTERFONT, name); }
int cgi_R_Font_StrLenPixels(const char *text, const int iFontIndex, const float scale /*= 1.0f*/) {
- return Q_syscall( CG_R_FONTSTRLENPIXELS, text, iFontIndex, PASSFLOAT(scale) ) ;
+ return Q_syscall(CG_R_FONTSTRLENPIXELS, text, iFontIndex, PASSFLOAT(scale));
}
-int cgi_R_Font_StrLenChars(const char *text) {
- return Q_syscall( CG_R_FONTSTRLENCHARS, text ) ;
-}
+int cgi_R_Font_StrLenChars(const char *text) { return Q_syscall(CG_R_FONTSTRLENCHARS, text); }
-int cgi_R_Font_HeightPixels(const int iFontIndex, const float scale /*= 1.0f*/) {
- return Q_syscall( CG_R_FONTHEIGHTPIXELS, iFontIndex, PASSFLOAT(scale) );
-}
+int cgi_R_Font_HeightPixels(const int iFontIndex, const float scale /*= 1.0f*/) { return Q_syscall(CG_R_FONTHEIGHTPIXELS, iFontIndex, PASSFLOAT(scale)); }
-qboolean cgi_Language_IsAsian( void )
-{
- return (qboolean)(Q_syscall( CG_LANGUAGE_ISASIAN ) != 0);
-}
+qboolean cgi_Language_IsAsian(void) { return (qboolean)(Q_syscall(CG_LANGUAGE_ISASIAN) != 0); }
-qboolean cgi_Language_UsesSpaces(void)
-{
- return (qboolean)(Q_syscall( CG_LANGUAGE_USESSPACES ) != 0);
-}
+qboolean cgi_Language_UsesSpaces(void) { return (qboolean)(Q_syscall(CG_LANGUAGE_USESSPACES) != 0); }
-unsigned int cgi_AnyLanguage_ReadCharFromString( const char *psText, int *piAdvanceCount, qboolean *pbIsTrailingPunctuation /* = NULL */ )
-{
- return Q_syscall( CG_ANYLANGUAGE_READFROMSTRING, psText, piAdvanceCount, pbIsTrailingPunctuation );
+unsigned int cgi_AnyLanguage_ReadCharFromString(const char *psText, int *piAdvanceCount, qboolean *pbIsTrailingPunctuation /* = NULL */) {
+ return Q_syscall(CG_ANYLANGUAGE_READFROMSTRING, psText, piAdvanceCount, pbIsTrailingPunctuation);
}
void cgi_R_Font_DrawString(int ox, int oy, const char *text, const float *rgba, const int setIndex, int iMaxPixelWidth, const float scale /*= 1.0f*/) {
- Q_syscall (CG_R_FONTDRAWSTRING, ox, oy, text, rgba, setIndex, iMaxPixelWidth, PASSFLOAT(scale) );
+ Q_syscall(CG_R_FONTDRAWSTRING, ox, oy, text, rgba, setIndex, iMaxPixelWidth, PASSFLOAT(scale));
}
-//set some properties for the draw layer for my refractive effect (here primarily for mod authors) -rww
-void cgi_R_SetRefractProp(float alpha, float stretch, qboolean prepost, qboolean negate)
-{
+// set some properties for the draw layer for my refractive effect (here primarily for mod authors) -rww
+void cgi_R_SetRefractProp(float alpha, float stretch, qboolean prepost, qboolean negate) {
Q_syscall(CG_R_SETREFRACTIONPROP, PASSFLOAT(alpha), PASSFLOAT(stretch), prepost, negate);
}
-void cgi_R_ClearScene( void ) {
- Q_syscall( CG_R_CLEARSCENE );
-}
+void cgi_R_ClearScene(void) { Q_syscall(CG_R_CLEARSCENE); }
-void cgi_R_AddRefEntityToScene( const refEntity_t *re ) {
- Q_syscall( CG_R_ADDREFENTITYTOSCENE, re );
-}
+void cgi_R_AddRefEntityToScene(const refEntity_t *re) { Q_syscall(CG_R_ADDREFENTITYTOSCENE, re); }
-qboolean cgi_R_inPVS( vec3_t p1, vec3_t p2 )
-{
- return (qboolean)(Q_syscall( CG_R_INPVS, p1, p2 ) != 0);
-}
+qboolean cgi_R_inPVS(vec3_t p1, vec3_t p2) { return (qboolean)(Q_syscall(CG_R_INPVS, p1, p2) != 0); }
-
-void cgi_R_GetLighting( const vec3_t origin, vec3_t ambientLight, vec3_t directedLight, vec3_t ligthDir ) {
- Q_syscall( CG_R_GETLIGHTING, origin, ambientLight, directedLight, ligthDir );
+void cgi_R_GetLighting(const vec3_t origin, vec3_t ambientLight, vec3_t directedLight, vec3_t ligthDir) {
+ Q_syscall(CG_R_GETLIGHTING, origin, ambientLight, directedLight, ligthDir);
}
-void cgi_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {
- Q_syscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
-}
+void cgi_R_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts) { Q_syscall(CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts); }
-void cgi_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
- Q_syscall( CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
+void cgi_R_AddLightToScene(const vec3_t org, float intensity, float r, float g, float b) {
+ Q_syscall(CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b));
}
-void cgi_R_RenderScene( const refdef_t *fd ) {
- Q_syscall( CG_R_RENDERSCENE, fd );
-}
+void cgi_R_RenderScene(const refdef_t *fd) { Q_syscall(CG_R_RENDERSCENE, fd); }
-void cgi_R_SetColor( const float *rgba ) {
- Q_syscall( CG_R_SETCOLOR, rgba );
-}
+void cgi_R_SetColor(const float *rgba) { Q_syscall(CG_R_SETCOLOR, rgba); }
-void cgi_R_DrawStretchPic( float x, float y, float w, float h,
- float s1, float t1, float s2, float t2, qhandle_t hShader ) {
- Q_syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
+void cgi_R_DrawStretchPic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader) {
+ Q_syscall(CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader);
}
-void cgi_R_ModelBounds( qhandle_t model, vec3_t mins, vec3_t maxs ) {
- Q_syscall( CG_R_MODELBOUNDS, model, mins, maxs );
-}
+void cgi_R_ModelBounds(qhandle_t model, vec3_t mins, vec3_t maxs) { Q_syscall(CG_R_MODELBOUNDS, model, mins, maxs); }
-void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame,
- float frac, const char *tagName ) {
- Q_syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );
+void cgi_R_LerpTag(orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, float frac, const char *tagName) {
+ Q_syscall(CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName);
}
-void cgi_R_DrawRotatePic( float x, float y, float w, float h,
- float s1, float t1, float s2, float t2,float a, qhandle_t hShader )
-{
- Q_syscall( CG_R_DRAWROTATEPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), PASSFLOAT(a), hShader );
+void cgi_R_DrawRotatePic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a, qhandle_t hShader) {
+ Q_syscall(CG_R_DRAWROTATEPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2),
+ PASSFLOAT(a), hShader);
}
-void cgi_R_DrawRotatePic2( float x, float y, float w, float h,
- float s1, float t1, float s2, float t2,float a, qhandle_t hShader )
-{
- Q_syscall( CG_R_DRAWROTATEPIC2, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), PASSFLOAT(a), hShader );
+void cgi_R_DrawRotatePic2(float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a, qhandle_t hShader) {
+ Q_syscall(CG_R_DRAWROTATEPIC2, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2),
+ PASSFLOAT(a), hShader);
}
-//linear fogging, with settable range -rww
-void cgi_R_SetRangeFog(float range)
-{
- Q_syscall(CG_R_SETRANGEFOG, PASSFLOAT(range));
-}
+// linear fogging, with settable range -rww
+void cgi_R_SetRangeFog(float range) { Q_syscall(CG_R_SETRANGEFOG, PASSFLOAT(range)); }
-void cgi_R_LAGoggles( void )
-{
- Q_syscall( CG_R_LA_GOGGLES );
-}
+void cgi_R_LAGoggles(void) { Q_syscall(CG_R_LA_GOGGLES); }
-void cgi_R_Scissor( float x, float y, float w, float h)
-{
- Q_syscall( CG_R_SCISSOR, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h));
-}
+void cgi_R_Scissor(float x, float y, float w, float h) { Q_syscall(CG_R_SCISSOR, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h)); }
-void cgi_GetGlconfig( glconfig_t *glconfig ) {
- Q_syscall( CG_GETGLCONFIG, glconfig );
-}
+void cgi_GetGlconfig(glconfig_t *glconfig) { Q_syscall(CG_GETGLCONFIG, glconfig); }
-void cgi_GetGameState( gameState_t *gamestate ) {
- Q_syscall( CG_GETGAMESTATE, gamestate );
-}
+void cgi_GetGameState(gameState_t *gamestate) { Q_syscall(CG_GETGAMESTATE, gamestate); }
-void cgi_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
- Q_syscall( CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime );
-}
+void cgi_GetCurrentSnapshotNumber(int *snapshotNumber, int *serverTime) { Q_syscall(CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime); }
-qboolean cgi_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {
- return (qboolean)(Q_syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot ) != 0);
-}
+qboolean cgi_GetSnapshot(int snapshotNumber, snapshot_t *snapshot) { return (qboolean)(Q_syscall(CG_GETSNAPSHOT, snapshotNumber, snapshot) != 0); }
-qboolean cgi_GetDefaultState(int entityIndex, entityState_t *state )
-{
- return (qboolean)(Q_syscall( CG_GETDEFAULTSTATE, entityIndex, state ) != 0);
-}
+qboolean cgi_GetDefaultState(int entityIndex, entityState_t *state) { return (qboolean)(Q_syscall(CG_GETDEFAULTSTATE, entityIndex, state) != 0); }
-qboolean cgi_GetServerCommand( int serverCommandNumber ) {
- return (qboolean)(Q_syscall( CG_GETSERVERCOMMAND, serverCommandNumber ) != 0);
-}
+qboolean cgi_GetServerCommand(int serverCommandNumber) { return (qboolean)(Q_syscall(CG_GETSERVERCOMMAND, serverCommandNumber) != 0); }
-int cgi_GetCurrentCmdNumber( void ) {
- return Q_syscall( CG_GETCURRENTCMDNUMBER );
-}
+int cgi_GetCurrentCmdNumber(void) { return Q_syscall(CG_GETCURRENTCMDNUMBER); }
-qboolean cgi_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {
- return (qboolean)(Q_syscall( CG_GETUSERCMD, cmdNumber, ucmd ) != 0);
-}
+qboolean cgi_GetUserCmd(int cmdNumber, usercmd_t *ucmd) { return (qboolean)(Q_syscall(CG_GETUSERCMD, cmdNumber, ucmd) != 0); }
-void cgi_SetUserCmdValue( int stateValue, float sensitivityScale, float mPitchOverride, float mYawOverride ) {
- Q_syscall( CG_SETUSERCMDVALUE, stateValue, PASSFLOAT(sensitivityScale), PASSFLOAT(mPitchOverride), PASSFLOAT(mYawOverride) );
+void cgi_SetUserCmdValue(int stateValue, float sensitivityScale, float mPitchOverride, float mYawOverride) {
+ Q_syscall(CG_SETUSERCMDVALUE, stateValue, PASSFLOAT(sensitivityScale), PASSFLOAT(mPitchOverride), PASSFLOAT(mYawOverride));
}
-void cgi_SetUserCmdAngles( float pitchOverride, float yawOverride, float rollOverride ) {
- Q_syscall( CG_SETUSERCMDANGLES, PASSFLOAT(pitchOverride), PASSFLOAT(yawOverride), PASSFLOAT(rollOverride) );
+void cgi_SetUserCmdAngles(float pitchOverride, float yawOverride, float rollOverride) {
+ Q_syscall(CG_SETUSERCMDANGLES, PASSFLOAT(pitchOverride), PASSFLOAT(yawOverride), PASSFLOAT(rollOverride));
}
/*
Ghoul2 Insert Start
*/
// CG Specific API calls
-void trap_G2_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList)
-{
- Q_syscall( CG_G2_SETMODELS, &ghoul2, modelList, skinList);
+void trap_G2_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList) {
+ Q_syscall(CG_G2_SETMODELS, &ghoul2, modelList, skinList);
}
/*
Ghoul2 Insert End
*/
-void trap_Com_SetOrgAngles(vec3_t org,vec3_t angles)
-{
- Q_syscall(COM_SETORGANGLES,org,angles);
-}
+void trap_Com_SetOrgAngles(vec3_t org, vec3_t angles) { Q_syscall(COM_SETORGANGLES, org, angles); }
-void trap_R_GetLightStyle(int style, color4ub_t color)
-{
- Q_syscall(CG_R_GET_LIGHT_STYLE, style, color);
-}
+void trap_R_GetLightStyle(int style, color4ub_t color) { Q_syscall(CG_R_GET_LIGHT_STYLE, style, color); }
-void trap_R_SetLightStyle(int style, int color)
-{
- Q_syscall(CG_R_SET_LIGHT_STYLE, style, color);
-}
+void trap_R_SetLightStyle(int style, int color) { Q_syscall(CG_R_SET_LIGHT_STYLE, style, color); }
-void cgi_R_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal )
-{
- Q_syscall( CG_R_GET_BMODEL_VERTS, bmodelIndex, verts, normal );
-}
+void cgi_R_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal) { Q_syscall(CG_R_GET_BMODEL_VERTS, bmodelIndex, verts, normal); }
-void cgi_R_WorldEffectCommand( const char *command )
-{
- Q_syscall( CG_R_WORLD_EFFECT_COMMAND, command );
-}
+void cgi_R_WorldEffectCommand(const char *command) { Q_syscall(CG_R_WORLD_EFFECT_COMMAND, command); }
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
-int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */) {
- return Q_syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits, psAudioFile);
+int trap_CIN_PlayCinematic(const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */) {
+ return Q_syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits, psAudioFile);
}
// stops playing the cinematic and ends it. should always return FMV_EOF
// cinematics must be stopped in reverse order of when they are started
-e_status trap_CIN_StopCinematic(int handle) {
- return (e_status) Q_syscall(CG_CIN_STOPCINEMATIC, handle);
-}
-
+e_status trap_CIN_StopCinematic(int handle) { return (e_status)Q_syscall(CG_CIN_STOPCINEMATIC, handle); }
// will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.
-e_status trap_CIN_RunCinematic (int handle) {
- return (e_status) Q_syscall(CG_CIN_RUNCINEMATIC, handle);
-}
-
+e_status trap_CIN_RunCinematic(int handle) { return (e_status)Q_syscall(CG_CIN_RUNCINEMATIC, handle); }
// draws the current frame
-void trap_CIN_DrawCinematic (int handle) {
- Q_syscall(CG_CIN_DRAWCINEMATIC, handle);
-}
-
+void trap_CIN_DrawCinematic(int handle) { Q_syscall(CG_CIN_DRAWCINEMATIC, handle); }
// allows you to resize the animation dynamically
-void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {
- Q_syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);
-}
+void trap_CIN_SetExtents(int handle, int x, int y, int w, int h) { Q_syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h); }
-void *cgi_Z_Malloc( int size, int tag )
-{
- return (void *)Q_syscall(CG_Z_MALLOC,size,tag);
-}
+void *cgi_Z_Malloc(int size, int tag) { return (void *)Q_syscall(CG_Z_MALLOC, size, tag); }
-void cgi_Z_Free( void *ptr )
-{
- Q_syscall(CG_Z_FREE,ptr);
-}
+void cgi_Z_Free(void *ptr) { Q_syscall(CG_Z_FREE, ptr); }
-void cgi_UI_SetActive_Menu(char *name)
-{
- Q_syscall(CG_UI_SETACTIVE_MENU,name);
-}
+void cgi_UI_SetActive_Menu(char *name) { Q_syscall(CG_UI_SETACTIVE_MENU, name); }
-void cgi_UI_Menu_OpenByName(char *buf)
-{
- Q_syscall(CG_UI_MENU_OPENBYNAME,buf);
-}
+void cgi_UI_Menu_OpenByName(char *buf) { Q_syscall(CG_UI_MENU_OPENBYNAME, buf); }
-void cgi_UI_Menu_Reset(void)
-{
- Q_syscall(CG_UI_MENU_RESET);
-}
+void cgi_UI_Menu_Reset(void) { Q_syscall(CG_UI_MENU_RESET); }
-void cgi_UI_Menu_New(char *buf)
-{
- Q_syscall(CG_UI_MENU_NEW,buf);
-}
+void cgi_UI_Menu_New(char *buf) { Q_syscall(CG_UI_MENU_NEW, buf); }
-void cgi_UI_Parse_Int(int *value)
-{
- Q_syscall(CG_UI_PARSE_INT,value);
-}
+void cgi_UI_Parse_Int(int *value) { Q_syscall(CG_UI_PARSE_INT, value); }
-void cgi_UI_Parse_String(char *buf)
-{
- Q_syscall(CG_UI_PARSE_STRING,buf);
-}
+void cgi_UI_Parse_String(char *buf) { Q_syscall(CG_UI_PARSE_STRING, buf); }
-void cgi_UI_Parse_Float(float *value)
-{
- Q_syscall(CG_UI_PARSE_FLOAT,value);
-}
+void cgi_UI_Parse_Float(float *value) { Q_syscall(CG_UI_PARSE_FLOAT, value); }
-int cgi_UI_StartParseSession(char *menuFile,char **buf)
-{
- return(int) Q_syscall(CG_UI_STARTPARSESESSION,menuFile,buf);
-}
+int cgi_UI_StartParseSession(char *menuFile, char **buf) { return (int)Q_syscall(CG_UI_STARTPARSESESSION, menuFile, buf); }
-void cgi_UI_EndParseSession(char *buf)
-{
- Q_syscall(CG_UI_ENDPARSESESSION,buf);
-}
+void cgi_UI_EndParseSession(char *buf) { Q_syscall(CG_UI_ENDPARSESESSION, buf); }
-void cgi_UI_ParseExt(char **token)
-{
- Q_syscall(CG_UI_PARSEEXT,token);
-}
+void cgi_UI_ParseExt(char **token) { Q_syscall(CG_UI_PARSEEXT, token); }
-void cgi_UI_MenuCloseAll(void)
-{
- Q_syscall(CG_UI_MENUCLOSE_ALL);
-}
+void cgi_UI_MenuCloseAll(void) { Q_syscall(CG_UI_MENUCLOSE_ALL); }
-void cgi_UI_MenuPaintAll(void)
-{
- Q_syscall(CG_UI_MENUPAINT_ALL);
-}
+void cgi_UI_MenuPaintAll(void) { Q_syscall(CG_UI_MENUPAINT_ALL); }
-void cgi_UI_String_Init(void)
-{
- Q_syscall(CG_UI_STRING_INIT);
-}
+void cgi_UI_String_Init(void) { Q_syscall(CG_UI_STRING_INIT); }
-int cgi_UI_GetMenuInfo(char *menuFile,int *x,int *y,int *w,int *h)
-{
- return(int) Q_syscall(CG_UI_GETMENUINFO,menuFile,x,y,w,h);
-}
+int cgi_UI_GetMenuInfo(char *menuFile, int *x, int *y, int *w, int *h) { return (int)Q_syscall(CG_UI_GETMENUINFO, menuFile, x, y, w, h); }
-int cgi_UI_GetMenuItemInfo(const char *menuFile,const char *itemName, int *x,int *y,int *w,int *h,vec4_t color,qhandle_t *background)
-{
- return(int) Q_syscall(CG_UI_GETITEMINFO,menuFile,itemName,x,y,w,h,color,background);
+int cgi_UI_GetMenuItemInfo(const char *menuFile, const char *itemName, int *x, int *y, int *w, int *h, vec4_t color, qhandle_t *background) {
+ return (int)Q_syscall(CG_UI_GETITEMINFO, menuFile, itemName, x, y, w, h, color, background);
}
-int cgi_UI_GetItemText(char *menuFile,char *itemName, char* text)
-{
- return(int) Q_syscall(CG_UI_GETITEMTEXT,menuFile,itemName,text);
-}
+int cgi_UI_GetItemText(char *menuFile, char *itemName, char *text) { return (int)Q_syscall(CG_UI_GETITEMTEXT, menuFile, itemName, text); }
-int cgi_SP_GetStringTextString(const char *text, char *buffer, int bufferLength)
-{
- return Q_syscall( CG_SP_GETSTRINGTEXTSTRING, text, buffer, bufferLength );
-}
+int cgi_SP_GetStringTextString(const char *text, char *buffer, int bufferLength) { return Q_syscall(CG_SP_GETSTRINGTEXTSTRING, text, buffer, bufferLength); }
/*
OpenJK Add
Since the modules are incompatible, might as well break base compat even further amirite?
*/
-void *cgi_UI_GetMenuByName( const char *menu )
-{
- return (void *)Q_syscall( CG_OPENJK_GETMENU_BYNAME, menu );
-}
+void *cgi_UI_GetMenuByName(const char *menu) { return (void *)Q_syscall(CG_OPENJK_GETMENU_BYNAME, menu); }
-void cgi_UI_Menu_Paint( void *menu, qboolean force )
-{
- Q_syscall( CG_OPENJK_MENU_PAINT, menu, force );
-}
+void cgi_UI_Menu_Paint(void *menu, qboolean force) { Q_syscall(CG_OPENJK_MENU_PAINT, menu, force); }
diff --git a/code/cgame/cg_text.cpp b/code/cgame/cg_text.cpp
index d535bcec2c..b2f3d85ce5 100644
--- a/code/cgame/cg_text.cpp
+++ b/code/cgame/cg_text.cpp
@@ -27,20 +27,16 @@ along with this program; if not, see .
#include "cg_media.h"
+// int precacheWav_i; // Current high index of precacheWav array
+// precacheWav_t precacheWav[MAX_PRECACHEWAV];
-//int precacheWav_i; // Current high index of precacheWav array
-//precacheWav_t precacheWav[MAX_PRECACHEWAV];
-
-
-//int precacheText_i; // Current high index of precacheText array
-//precacheText_t precacheText[MAX_PRECACHETEXT];
-
+// int precacheText_i; // Current high index of precacheText array
+// precacheText_t precacheText[MAX_PRECACHETEXT];
extern vec4_t textcolor_caption;
extern vec4_t textcolor_center;
extern vec4_t textcolor_scroll;
-
// display text in a supplied box, start at top left and going down by however many pixels I feel like internally,
// return value is NULL if all fitted, else char * of next char to continue from that didn't fit.
//
@@ -48,23 +44,20 @@ extern vec4_t textcolor_scroll;
//
// ( if you get the same char * returned as what you passed in, then none of it fitted at all (box too small) )
//
- // this is execrable, and should NOT have had to've been done now, but...
- //
- float gfAdvanceHack = 0.0f; // MUST default to this
- int giLinesOutput; // hack-city after release, only used by one function
+// this is execrable, and should NOT have had to've been done now, but...
+//
+float gfAdvanceHack = 0.0f; // MUST default to this
+int giLinesOutput; // hack-city after release, only used by one function
//
-const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight,
- const char *psText, int iFontHandle, float fScale,
- const vec4_t v4Color)
-{
+const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight, const char *psText, int iFontHandle, float fScale, const vec4_t v4Color) {
giLinesOutput = 0;
- cgi_R_SetColor( v4Color );
+ cgi_R_SetColor(v4Color);
// Setup a reasonable vertical spacing (taiwanese & japanese need 1.5 fontheight, so use that for all)...
//
- const int iFontHeight = cgi_R_Font_HeightPixels(iFontHandle, fScale);
- const int iFontHeightAdvance = (int) ( ((gfAdvanceHack == 0.0f) ? 1.5f : gfAdvanceHack) * (float) iFontHeight);
- int iYpos = iBoxY; // start print pos
+ const int iFontHeight = cgi_R_Font_HeightPixels(iFontHandle, fScale);
+ const int iFontHeightAdvance = (int)(((gfAdvanceHack == 0.0f) ? 1.5f : gfAdvanceHack) * (float)iFontHeight);
+ int iYpos = iBoxY; // start print pos
// this could probably be simplified now, but it was converted from something else I didn't originally write,
// and it works anyway so wtf...
@@ -72,17 +65,15 @@ const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHei
const char *psCurrentTextReadPos = psText;
const char *psReadPosAtLineStart = psCurrentTextReadPos;
const char *psBestLineBreakSrcPos = psCurrentTextReadPos;
- const char *psLastGood_s; // needed if we get a full screen of chars with no punctuation or space (see usage notes)
- while( *psCurrentTextReadPos && (iYpos + iFontHeight < (iBoxY + iBoxHeight)) )
- {
- char sLineForDisplay[2048]; // ott
+ const char *psLastGood_s; // needed if we get a full screen of chars with no punctuation or space (see usage notes)
+ while (*psCurrentTextReadPos && (iYpos + iFontHeight < (iBoxY + iBoxHeight))) {
+ char sLineForDisplay[2048]; // ott
// construct a line...
//
psCurrentTextReadPos = psReadPosAtLineStart;
sLineForDisplay[0] = '\0';
- while ( *psCurrentTextReadPos )
- {
+ while (*psCurrentTextReadPos) {
psLastGood_s = psCurrentTextReadPos;
// read letter...
@@ -94,45 +85,33 @@ const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHei
// concat onto string so far...
//
- if (uiLetter == 32 && sLineForDisplay[0] == '\0')
- {
+ if (uiLetter == 32 && sLineForDisplay[0] == '\0') {
psReadPosAtLineStart++;
- continue; // unless it's a space at the start of a line, in which case ignore it.
+ continue; // unless it's a space at the start of a line, in which case ignore it.
}
- if (uiLetter > 255)
- {
- Q_strcat(sLineForDisplay, sizeof(sLineForDisplay),va("%c%c",uiLetter >> 8, uiLetter & 0xFF));
- }
- else
- {
- Q_strcat(sLineForDisplay, sizeof(sLineForDisplay),va("%c",uiLetter & 0xFF));
+ if (uiLetter > 255) {
+ Q_strcat(sLineForDisplay, sizeof(sLineForDisplay), va("%c%c", uiLetter >> 8, uiLetter & 0xFF));
+ } else {
+ Q_strcat(sLineForDisplay, sizeof(sLineForDisplay), va("%c", uiLetter & 0xFF));
}
- if (uiLetter == '\n')
- {
+ if (uiLetter == '\n') {
// explicit new line...
//
- sLineForDisplay[ strlen(sLineForDisplay)-1 ] = '\0'; // kill the CR
+ sLineForDisplay[strlen(sLineForDisplay) - 1] = '\0'; // kill the CR
psReadPosAtLineStart = psCurrentTextReadPos;
psBestLineBreakSrcPos = psCurrentTextReadPos;
- break; // print this line
- }
- else
- if ( cgi_R_Font_StrLenPixels(sLineForDisplay, iFontHandle, fScale) >= iBoxWidth )
- {
+ break; // print this line
+ } else if (cgi_R_Font_StrLenPixels(sLineForDisplay, iFontHandle, fScale) >= iBoxWidth) {
// reached screen edge, so cap off string at bytepos after last good position...
//
- if (uiLetter > 255 && bIsTrailingPunctuation && !cgi_Language_UsesSpaces())
- {
+ if (uiLetter > 255 && bIsTrailingPunctuation && !cgi_Language_UsesSpaces()) {
// Special case, don't consider line breaking if you're on an asian punctuation char of
// a language that doesn't use spaces...
//
- }
- else
- {
- if (psBestLineBreakSrcPos == psReadPosAtLineStart)
- {
+ } else {
+ if (psBestLineBreakSrcPos == psReadPosAtLineStart) {
// aarrrggh!!!!! we'll only get here is someone has fed in a (probably) garbage string,
// since it doesn't have a single space or punctuation mark right the way across one line
// of the screen. So far, this has only happened in testing when I hardwired a taiwanese
@@ -140,19 +119,18 @@ const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHei
// normally). On the other hand I suppose it'psCurrentTextReadPos entirely possible that some taiwanese string
// might have no punctuation at all, so...
//
- psBestLineBreakSrcPos = psLastGood_s; // force a break after last good letter
+ psBestLineBreakSrcPos = psLastGood_s; // force a break after last good letter
}
- sLineForDisplay[ psBestLineBreakSrcPos - psReadPosAtLineStart ] = '\0';
+ sLineForDisplay[psBestLineBreakSrcPos - psReadPosAtLineStart] = '\0';
psReadPosAtLineStart = psCurrentTextReadPos = psBestLineBreakSrcPos;
- break; // print this line
+ break; // print this line
}
}
// record last-good linebreak pos... (ie if we've just concat'd a punctuation point (western or asian) or space)
//
- if (bIsTrailingPunctuation || uiLetter == ' ' || (uiLetter > 255 && !cgi_Language_UsesSpaces()))
- {
+ if (bIsTrailingPunctuation || uiLetter == ' ' || (uiLetter > 255 && !cgi_Language_UsesSpaces())) {
psBestLineBreakSrcPos = psCurrentTextReadPos;
}
}
@@ -165,16 +143,13 @@ const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHei
// and echo to console in dev mode...
//
- if ( cg_developer.integer )
- {
-// Com_Printf( "%psCurrentTextReadPos\n", sLineForDisplay );
+ if (cg_developer.integer) {
+ // Com_Printf( "%psCurrentTextReadPos\n", sLineForDisplay );
}
}
return psReadPosAtLineStart;
}
-
-
/*
===============================================================================
@@ -182,33 +157,26 @@ CAPTION TEXT
===============================================================================
*/
-void CG_CaptionTextStop(void)
-{
- cg.captionTextTime = 0;
-}
+void CG_CaptionTextStop(void) { cg.captionTextTime = 0; }
// try and get the correct StripEd text (with retry) for a given reference...
//
// returns 0 if failed, else strlen...
//
-static int cg_SP_GetStringTextStringWithRetry( const char *psReference, char *psDest, int iSizeofDest)
-{
+static int cg_SP_GetStringTextStringWithRetry(const char *psReference, char *psDest, int iSizeofDest) {
int iReturn;
- if (psReference[0] == '#')
- {
+ if (psReference[0] == '#') {
// then we know the striped package name is already built in, so do NOT try prepending anything else...
//
- return cgi_SP_GetStringTextString( va("%s",psReference+1), psDest, iSizeofDest );
+ return cgi_SP_GetStringTextString(va("%s", psReference + 1), psDest, iSizeofDest);
}
- for (int i=0; i 255)
- {
- Q_strcat(cg.captionText[i],sizeof(cg.captionText[i]),va("%c%c",uiLetter >> 8, uiLetter & 0xFF));
- }
- else
- {
- Q_strcat(cg.captionText[i],sizeof(cg.captionText[i]),va("%c",uiLetter & 0xFF));
+ if (uiLetter > 255) {
+ Q_strcat(cg.captionText[i], sizeof(cg.captionText[i]), va("%c%c", uiLetter >> 8, uiLetter & 0xFF));
+ } else {
+ Q_strcat(cg.captionText[i], sizeof(cg.captionText[i]), va("%c", uiLetter & 0xFF));
}
- if (uiLetter == '\n')
- {
+ if (uiLetter == '\n') {
// explicit new line...
//
- cg.captionText[i][ strlen(cg.captionText[i])-1 ] = '\0'; // kill the CR
+ cg.captionText[i][strlen(cg.captionText[i]) - 1] = '\0'; // kill the CR
i++;
holds = s;
psBestLineBreakSrcPos = s;
cg.scrollTextLines++;
- }
- else
- if ( cgi_R_Font_StrLenPixels(cg.captionText[i], cgs.media.qhFontMedium, fFontScale) >= SCREEN_WIDTH)
- {
+ } else if (cgi_R_Font_StrLenPixels(cg.captionText[i], cgs.media.qhFontMedium, fFontScale) >= SCREEN_WIDTH) {
// reached screen edge, so cap off string at bytepos after last good position...
//
- if (uiLetter > 255 && bIsTrailingPunctuation && !cgi_Language_UsesSpaces())
- {
+ if (uiLetter > 255 && bIsTrailingPunctuation && !cgi_Language_UsesSpaces()) {
// Special case, don't consider line breaking if you're on an asian punctuation char of
// a language that doesn't use spaces...
//
- }
- else
- {
- if (psBestLineBreakSrcPos == holds)
- {
+ } else {
+ if (psBestLineBreakSrcPos == holds) {
// aarrrggh!!!!! we'll only get here is someone has fed in a (probably) garbage string,
// since it doesn't have a single space or punctuation mark right the way across one line
// of the screen. So far, this has only happened in testing when I hardwired a taiwanese
@@ -351,10 +302,10 @@ void CG_CaptionText( const char *str, int sound)
// normally). On the other hand I suppose it's entirely possible that some taiwanese string
// might have no punctuation at all, so...
//
- psBestLineBreakSrcPos = psLastGood_s; // force a break after last good letter
+ psBestLineBreakSrcPos = psLastGood_s; // force a break after last good letter
}
- cg.captionText[i][ psBestLineBreakSrcPos - holds ] = '\0';
+ cg.captionText[i][psBestLineBreakSrcPos - holds] = '\0';
holds = s = psBestLineBreakSrcPos;
i++;
cg.scrollTextLines++;
@@ -363,102 +314,85 @@ void CG_CaptionText( const char *str, int sound)
// record last-good linebreak pos... (ie if we've just concat'd a punctuation point (western or asian) or space)
//
- if (bIsTrailingPunctuation || uiLetter == ' ' || (uiLetter > 255 && !cgi_Language_UsesSpaces()))
- {
+ if (bIsTrailingPunctuation || uiLetter == ' ' || (uiLetter > 255 && !cgi_Language_UsesSpaces())) {
psBestLineBreakSrcPos = s;
}
}
-
// calc the length of time to hold each 2 lines of text on the screen.... presumably this works?
//
holdTime = strlen(cg.captionText[0]);
- if (cg.scrollTextLines > 1)
- {
- holdTime += strlen(cg.captionText[1]); // strlen is also good for MBCS in this instance, since it's for timing
+ if (cg.scrollTextLines > 1) {
+ holdTime += strlen(cg.captionText[1]); // strlen is also good for MBCS in this instance, since it's for timing
}
cg.captionNextTextTime = cg.time + (holdTime * cg.captionLetterTime);
- cg.scrollTextTime = 0; // No scrolling during captions
+ cg.scrollTextTime = 0; // No scrolling during captions
- //Echo to console in dev mode
- if ( cg_developer.integer )
- {
- Com_Printf( "%s\n", cg.captionText[0] ); // ste: was [i], but surely sentence 0 is more useful than last?
+ // Echo to console in dev mode
+ if (cg_developer.integer) {
+ Com_Printf("%s\n", cg.captionText[0]); // ste: was [i], but surely sentence 0 is more useful than last?
}
}
+void CG_DrawCaptionText(void) {
+ int i;
+ int x, y, w;
+ int holdTime;
-void CG_DrawCaptionText(void)
-{
- int i;
- int x, y, w;
- int holdTime;
-
- if ( !cg.captionTextTime )
- {
+ if (!cg.captionTextTime) {
return;
}
const float fFontScale = cgi_Language_IsAsian() ? 0.8f : 1.0f;
- if (cg_skippingcin.integer != 0)
- {
+ if (cg_skippingcin.integer != 0) {
cg.captionTextTime = 0;
return;
}
- if ( cg.captionNextTextTime < cg.time )
- {
+ if (cg.captionNextTextTime < cg.time) {
cg.captionTextCurrentLine += 2;
- if (cg.captionTextCurrentLine >= cg.scrollTextLines)
- {
+ if (cg.captionTextCurrentLine >= cg.scrollTextLines) {
cg.captionTextTime = 0;
return;
- }
- else
- {
+ } else {
holdTime = strlen(cg.captionText[cg.captionTextCurrentLine]);
- if (cg.scrollTextLines >= cg.captionTextCurrentLine)
- {
+ if (cg.scrollTextLines >= cg.captionTextCurrentLine) {
// ( strlen is also good for MBCS in this instance, since it's for timing -ste)
//
holdTime += strlen(cg.captionText[cg.captionTextCurrentLine + 1]);
}
- cg.captionNextTextTime = cg.time + (holdTime * cg.captionLetterTime);//50);
+ cg.captionNextTextTime = cg.time + (holdTime * cg.captionLetterTime); // 50);
}
}
// Give a color if one wasn't given
- if((textcolor_caption[0] == 0) && (textcolor_caption[1] == 0) &&
- (textcolor_caption[2] == 0) && (textcolor_caption[3] == 0))
- {
- VectorCopy4( colorTable[CT_WHITE], textcolor_caption );
+ if ((textcolor_caption[0] == 0) && (textcolor_caption[1] == 0) && (textcolor_caption[2] == 0) && (textcolor_caption[3] == 0)) {
+ VectorCopy4(colorTable[CT_WHITE], textcolor_caption);
}
cgi_R_SetColor(textcolor_caption);
// Set Y of the first line (varies if only printing one line of text)
// (this all works, please don't mess with it)
- const int fontHeight = (int) ((cgi_Language_IsAsian() ? 1.4f : 1.0f) * (float) cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, fFontScale));
- const bool bPrinting2Lines = !!(cg.captionText[ cg.captionTextCurrentLine+1 ][0]);
- y = cg.captionTextY - ( (float)fontHeight * (bPrinting2Lines ? 1 : 0.5f)); // captionTextY was a centered Y pos, not a top one
+ const int fontHeight = (int)((cgi_Language_IsAsian() ? 1.4f : 1.0f) * (float)cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, fFontScale));
+ const bool bPrinting2Lines = !!(cg.captionText[cg.captionTextCurrentLine + 1][0]);
+ y = cg.captionTextY - ((float)fontHeight * (bPrinting2Lines ? 1 : 0.5f)); // captionTextY was a centered Y pos, not a top one
y -= cgi_Language_IsAsian() ? 0 : 4;
- for (i= cg.captionTextCurrentLine;i< cg.captionTextCurrentLine + 2;++i)
- {
+ for (i = cg.captionTextCurrentLine; i < cg.captionTextCurrentLine + 2; ++i) {
w = cgi_R_Font_StrLenPixels(cg.captionText[i], cgs.media.qhFontMedium, fFontScale);
- if (w)
- {
- x = (SCREEN_WIDTH-w) / 2;
+ if (w) {
+ x = (SCREEN_WIDTH - w) / 2;
cgi_R_Font_DrawString(x, y, cg.captionText[i], textcolor_caption, cgs.media.qhFontMedium, -1, fFontScale);
y += fontHeight;
}
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
/*
@@ -474,40 +408,37 @@ CG_ScrollText - split text up into seperate lines
*/
int giScrollTextPixelWidth = SCREEN_WIDTH;
-void CG_ScrollText( const char *str, int iPixelWidth )
-{
- const char *s,*holds;
- int i;//, len;//, numChars;
+void CG_ScrollText(const char *str, int iPixelWidth) {
+ const char *s, *holds;
+ int i; //, len;//, numChars;
giScrollTextPixelWidth = iPixelWidth;
// first, ask the strlen of the final string...
//
- i = cgi_SP_GetStringTextString( str, NULL, 0 );
+ i = cgi_SP_GetStringTextString(str, NULL, 0);
- //ensure we found a match
- if (!i)
- {
+ // ensure we found a match
+ if (!i) {
#ifndef FINAL_BUILD
- Com_Printf("WARNING: CG_ScrollText given invalid text key :'%s'\n",str);
+ Com_Printf("WARNING: CG_ScrollText given invalid text key :'%s'\n", str);
#endif
return;
}
//
// malloc space to hold it...
//
- char *psText = (char *) cgi_Z_Malloc( i+1, TAG_TEMP_WORKSPACE );
+ char *psText = (char *)cgi_Z_Malloc(i + 1, TAG_TEMP_WORKSPACE);
//
// now get the string...
//
- i = cgi_SP_GetStringTextString( str, psText, i+1 );
- //ensure we found a match
- if (!i)
- {
- assert(0); // should never get here now, but wtf?
+ i = cgi_SP_GetStringTextString(str, psText, i + 1);
+ // ensure we found a match
+ if (!i) {
+ assert(0); // should never get here now, but wtf?
cgi_Z_Free(psText);
#ifndef FINAL_BUILD
- Com_Printf("WARNING: CG_ScrollText given invalid text key :'%s'\n",str);
+ Com_Printf("WARNING: CG_ScrollText given invalid text key :'%s'\n", str);
#endif
return;
}
@@ -521,9 +452,8 @@ void CG_ScrollText( const char *str, int iPixelWidth )
holds = s;
const char *psBestLineBreakSrcPos = s;
- const char *psLastGood_s; // needed if we get a full screen of chars with no punctuation or space (see usage notes)
- while( *s )
- {
+ const char *psLastGood_s; // needed if we get a full screen of chars with no punctuation or space (see usage notes)
+ while (*s) {
psLastGood_s = s;
// read letter...
@@ -535,49 +465,38 @@ void CG_ScrollText( const char *str, int iPixelWidth )
// concat onto string so far...
//
- if (uiLetter == 32 && cg.printText[i][0] == '\0')
- {
+ if (uiLetter == 32 && cg.printText[i][0] == '\0') {
holds++;
- continue; // unless it's a space at the start of a line, in which case ignore it.
+ continue; // unless it's a space at the start of a line, in which case ignore it.
}
- if (uiLetter > 255)
- {
- Q_strcat(cg.printText[i],sizeof(cg.printText[i]),va("%c%c",uiLetter >> 8, uiLetter & 0xFF));
- }
- else
- {
- Q_strcat(cg.printText[i],sizeof(cg.printText[i]),va("%c",uiLetter & 0xFF));
+ if (uiLetter > 255) {
+ Q_strcat(cg.printText[i], sizeof(cg.printText[i]), va("%c%c", uiLetter >> 8, uiLetter & 0xFF));
+ } else {
+ Q_strcat(cg.printText[i], sizeof(cg.printText[i]), va("%c", uiLetter & 0xFF));
}
// record last-good linebreak pos... (ie if we've just concat'd a punctuation point (western or asian) or space)
//
- if (bIsTrailingPunctuation || uiLetter == ' ')
- {
+ if (bIsTrailingPunctuation || uiLetter == ' ') {
psBestLineBreakSrcPos = s;
}
- if (uiLetter == '\n')
- {
+ if (uiLetter == '\n') {
// explicit new line...
//
- cg.printText[i][ strlen(cg.printText[i])-1 ] = '\0'; // kill the CR
+ cg.printText[i][strlen(cg.printText[i]) - 1] = '\0'; // kill the CR
i++;
- assert (i < (int)(sizeof(cg.printText)/sizeof(cg.printText[0])) );
- if (i >= (int)(sizeof(cg.printText)/sizeof(cg.printText[0])) )
- {
+ assert(i < (int)(sizeof(cg.printText) / sizeof(cg.printText[0])));
+ if (i >= (int)(sizeof(cg.printText) / sizeof(cg.printText[0]))) {
break;
}
holds = s;
cg.scrollTextLines++;
- }
- else
- if ( cgi_R_Font_StrLenPixels(cg.printText[i], cgs.media.qhFontMedium, 1.0f) >= iPixelWidth)
- {
+ } else if (cgi_R_Font_StrLenPixels(cg.printText[i], cgs.media.qhFontMedium, 1.0f) >= iPixelWidth) {
// reached screen edge, so cap off string at bytepos after last good position...
//
- if (psBestLineBreakSrcPos == holds)
- {
+ if (psBestLineBreakSrcPos == holds) {
// aarrrggh!!!!! we'll only get here is someone has fed in a (probably) garbage string,
// since it doesn't have a single space or punctuation mark right the way across one line
// of the screen. So far, this has only happened in testing when I hardwired a taiwanese
@@ -585,77 +504,69 @@ void CG_ScrollText( const char *str, int iPixelWidth )
// normally). On the other hand I suppose it's entirely possible that some taiwanese string
// might have no punctuation at all, so...
//
- psBestLineBreakSrcPos = psLastGood_s; // force a break after last good letter
+ psBestLineBreakSrcPos = psLastGood_s; // force a break after last good letter
}
- cg.printText[i][ psBestLineBreakSrcPos - holds ] = '\0';
+ cg.printText[i][psBestLineBreakSrcPos - holds] = '\0';
holds = s = psBestLineBreakSrcPos;
i++;
- assert (i < (int)(sizeof(cg.printText)/sizeof(cg.printText[0])) );
+ assert(i < (int)(sizeof(cg.printText) / sizeof(cg.printText[0])));
cg.scrollTextLines++;
}
}
- cg.captionTextTime = 0; // No captions during scrolling
+ cg.captionTextTime = 0; // No captions during scrolling
cgi_Z_Free(psText);
}
-
// draws using [textcolor_scroll]...
//
-#define SCROLL_LPM (1/50.0) // 1 line per 50 ms
-void CG_DrawScrollText(void)
-{
- int i;
- int x,y;
- const int fontHeight = (int) (1.5f * (float) cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, 1.0f)); // taiwanese & japanese need 1.5 fontheight spacing
-
- if ( !cg.scrollTextTime )
- {
+#define SCROLL_LPM (1 / 50.0) // 1 line per 50 ms
+void CG_DrawScrollText(void) {
+ int i;
+ int x, y;
+ const int fontHeight = (int)(1.5f * (float)cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, 1.0f)); // taiwanese & japanese need 1.5 fontheight spacing
+
+ if (!cg.scrollTextTime) {
return;
}
- cgi_R_SetColor( textcolor_scroll );
+ cgi_R_SetColor(textcolor_scroll);
y = cg.printTextY - (cg.time - cg.scrollTextTime) * SCROLL_LPM;
-// cgi_R_Font_DrawString(320, 200, va("Scrolltext printing @ %d",y), colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
+ // cgi_R_Font_DrawString(320, 200, va("Scrolltext printing @ %d",y), colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f);
// See if text has finished scrolling off screen
- if ((y + cg.scrollTextLines * fontHeight) < 1)
- {
+ if ((y + cg.scrollTextLines * fontHeight) < 1) {
cg.scrollTextTime = 0;
return;
}
- for (i=0;i SCREEN_HEIGHT)
- {
+ else if (y > SCREEN_HEIGHT) {
break;
}
-// w = cgi_R_Font_StrLenPixels(cg.printText[i], cgs.media.qhFontMedium, 1.0f);
-// if (w)
+ // w = cgi_R_Font_StrLenPixels(cg.printText[i], cgs.media.qhFontMedium, 1.0f);
+ // if (w)
{
x = (SCREEN_WIDTH - giScrollTextPixelWidth) / 2;
- cgi_R_Font_DrawString(x,y, cg.printText[i], textcolor_scroll, cgs.media.qhFontMedium, -1, 1.0f);
+ cgi_R_Font_DrawString(x, y, cg.printText[i], textcolor_scroll, cgs.media.qhFontMedium, -1, 1.0f);
y += fontHeight;
}
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
-
/*
===============================================================================
@@ -664,7 +575,6 @@ CENTER PRINTING
===============================================================================
*/
-
/*
==============
CG_CenterPrint
@@ -673,25 +583,21 @@ Called for important messages that should stay in the center of the screen
for a few moments
==============
*/
-void CG_CenterPrint( const char *str, int y) {
- char *s;
+void CG_CenterPrint(const char *str, int y) {
+ char *s;
// Find text to match the str given
- if (*str == '@')
- {
+ if (*str == '@') {
int i;
- i = cgi_SP_GetStringTextString( str+1, cg.centerPrint, sizeof(cg.centerPrint) );
+ i = cgi_SP_GetStringTextString(str + 1, cg.centerPrint, sizeof(cg.centerPrint));
- if (!i)
- {
- Com_Printf (S_COLOR_RED"CG_CenterPrint: cannot find reference '%s' in StringPackage!\n",str);
- Q_strncpyz( cg.centerPrint, str, sizeof(cg.centerPrint) );
+ if (!i) {
+ Com_Printf(S_COLOR_RED "CG_CenterPrint: cannot find reference '%s' in StringPackage!\n", str);
+ Q_strncpyz(cg.centerPrint, str, sizeof(cg.centerPrint));
}
- }
- else
- {
- Q_strncpyz( cg.centerPrint, str, sizeof(cg.centerPrint) );
+ } else {
+ Q_strncpyz(cg.centerPrint, str, sizeof(cg.centerPrint));
}
cg.centerPrintTime = cg.time;
@@ -700,40 +606,35 @@ void CG_CenterPrint( const char *str, int y) {
// count the number of lines for centering
cg.centerPrintLines = 1;
s = cg.centerPrint;
- while( *s ) {
+ while (*s) {
if (*s == '\n')
cg.centerPrintLines++;
s++;
}
-
}
-
/*
===================
CG_DrawCenterString
===================
*/
-void CG_DrawCenterString( void )
-{
- char *start;
+void CG_DrawCenterString(void) {
+ char *start;
unsigned int l;
- int x, y, w;
- float *color;
+ int x, y, w;
+ float *color;
- if ( !cg.centerPrintTime ) {
+ if (!cg.centerPrintTime) {
return;
}
- color = CG_FadeColor( cg.centerPrintTime, 1000 * 3 );
- if ( !color ) {
+ color = CG_FadeColor(cg.centerPrintTime, 1000 * 3);
+ if (!color) {
return;
}
- if((textcolor_center[0] == 0) && (textcolor_center[1] == 0) &&
- (textcolor_center[2] == 0) && (textcolor_center[3] == 0))
- {
- VectorCopy4( colorTable[CT_WHITE], textcolor_center );
+ if ((textcolor_center[0] == 0) && (textcolor_center[1] == 0) && (textcolor_center[2] == 0) && (textcolor_center[3] == 0)) {
+ VectorCopy4(colorTable[CT_WHITE], textcolor_center);
}
start = cg.centerPrint;
@@ -741,27 +642,24 @@ void CG_DrawCenterString( void )
const int fontHeight = cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, 1.0f);
y = cg.centerPrintY - (cg.centerPrintLines * fontHeight) / 2;
- while ( 1 ) {
+ while (1) {
char linebuffer[1024];
// this is kind of unpleasant when dealing with MBCS, but...
//
const char *psString = start;
int iOutIndex = 0;
- for ( l = 0; l < sizeof(linebuffer)-1; l++ ) {
+ for (l = 0; l < sizeof(linebuffer) - 1; l++) {
int iAdvanceCount;
unsigned int uiLetter = cgi_AnyLanguage_ReadCharFromString(psString, &iAdvanceCount);
psString += iAdvanceCount;
- if (!uiLetter || uiLetter == '\n'){
+ if (!uiLetter || uiLetter == '\n') {
break;
}
- if (uiLetter > 255)
- {
+ if (uiLetter > 255) {
linebuffer[iOutIndex++] = uiLetter >> 8;
linebuffer[iOutIndex++] = uiLetter & 0xFF;
- }
- else
- {
+ } else {
linebuffer[iOutIndex++] = uiLetter & 0xFF;
}
}
@@ -769,19 +667,18 @@ void CG_DrawCenterString( void )
w = cgi_R_Font_StrLenPixels(linebuffer, cgs.media.qhFontMedium, 1.0f);
- x = ( SCREEN_WIDTH - w ) / 2;
+ x = (SCREEN_WIDTH - w) / 2;
- cgi_R_Font_DrawString(x,y,linebuffer, textcolor_center, cgs.media.qhFontMedium, -1, 1.0f);
+ cgi_R_Font_DrawString(x, y, linebuffer, textcolor_center, cgs.media.qhFontMedium, -1, 1.0f);
y += fontHeight;
- while ( *start && ( *start != '\n' ) ) {
+ while (*start && (*start != '\n')) {
start++;
}
- if ( !*start ) {
+ if (!*start) {
break;
}
start++;
}
-
}
diff --git a/code/cgame/cg_view.cpp b/code/cgame/cg_view.cpp
index 01cb293e07..9f09fb23b2 100644
--- a/code/cgame/cg_view.cpp
+++ b/code/cgame/cg_view.cpp
@@ -33,13 +33,13 @@ along with this program; if not, see .
#include "../game/g_vehicles.h"
#define MASK_CAMERACLIP (MASK_SOLID)
-#define CAMERA_SIZE 4
+#define CAMERA_SIZE 4
float cg_zoomFov;
//#define CG_CAM_ABOVE 2
-extern qboolean CG_OnMovingPlat( playerState_t *ps );
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
+extern qboolean CG_OnMovingPlat(playerState_t *ps);
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
extern int g_crosshairSameEntTime;
extern int g_crosshairEntNum;
@@ -91,83 +91,76 @@ Creates an entity in front of the current position, which
can then be moved around
=================
*/
-void CG_TestG2Model_f (void) {
- vec3_t angles;
+void CG_TestG2Model_f(void) {
+ vec3_t angles;
CGhoul2Info_v *ghoul2;
- memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) );
+ memset(&cg.testModelEntity, 0, sizeof(cg.testModelEntity));
ghoul2 = new CGhoul2Info_v;
cg.testModelEntity.ghoul2 = ghoul2;
- if ( cgi_Argc() < 2 ) {
+ if (cgi_Argc() < 2) {
return;
}
- Q_strncpyz (cg.testModelName, CG_Argv( 1 ), MAX_QPATH );
- cg.testModelEntity.hModel = cgi_R_RegisterModel( cg.testModelName );
+ Q_strncpyz(cg.testModelName, CG_Argv(1), MAX_QPATH);
+ cg.testModelEntity.hModel = cgi_R_RegisterModel(cg.testModelName);
- cg.testModel = gi.G2API_InitGhoul2Model(*((CGhoul2Info_v *)cg.testModelEntity.ghoul2), cg.testModelName, cg.testModelEntity.hModel, NULL_HANDLE, NULL_HANDLE,0,0);
+ cg.testModel =
+ gi.G2API_InitGhoul2Model(*((CGhoul2Info_v *)cg.testModelEntity.ghoul2), cg.testModelName, cg.testModelEntity.hModel, NULL_HANDLE, NULL_HANDLE, 0, 0);
cg.testModelEntity.radius = 100.0f;
- if ( cgi_Argc() == 3 ) {
- cg.testModelEntity.backlerp = atof( CG_Argv( 2 ) );
+ if (cgi_Argc() == 3) {
+ cg.testModelEntity.backlerp = atof(CG_Argv(2));
cg.testModelEntity.frame = 1;
cg.testModelEntity.oldframe = 0;
}
- if (! cg.testModelEntity.hModel ) {
- CG_Printf( "Can't register model\n" );
+ if (!cg.testModelEntity.hModel) {
+ CG_Printf("Can't register model\n");
return;
}
- VectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin );
+ VectorMA(cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin);
angles[PITCH] = 0;
angles[YAW] = 180 + cg.refdefViewAngles[1];
angles[ROLL] = 0;
- AnglesToAxis( angles, cg.testModelEntity.axis );
+ AnglesToAxis(angles, cg.testModelEntity.axis);
}
-void CG_ListModelSurfaces_f (void)
-{
- CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
+void CG_ListModelSurfaces_f(void) {
+ CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
- gi.G2API_ListSurfaces(&ghoul2[cg.testModel]);
+ gi.G2API_ListSurfaces(&ghoul2[cg.testModel]);
}
-
-void CG_ListModelBones_f (void)
-{
- // test to see if we got enough args
- if ( cgi_Argc() < 2 )
- {
+void CG_ListModelBones_f(void) {
+ // test to see if we got enough args
+ if (cgi_Argc() < 2) {
return;
}
- CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
+ CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
gi.G2API_ListBones(&ghoul2[cg.testModel], atoi(CG_Argv(1)));
}
-void CG_TestModelSurfaceOnOff_f(void)
-{
+void CG_TestModelSurfaceOnOff_f(void) {
// test to see if we got enough args
- if ( cgi_Argc() < 3 )
- {
+ if (cgi_Argc() < 3) {
return;
}
- CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
+ CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
gi.G2API_SetSurfaceOnOff(&ghoul2[cg.testModel], CG_Argv(1), atoi(CG_Argv(2)));
}
-void CG_TestModelSetAnglespre_f(void)
-{
- vec3_t angles;
+void CG_TestModelSetAnglespre_f(void) {
+ vec3_t angles;
- if ( cgi_Argc() < 3 )
- {
+ if (cgi_Argc() < 3) {
return;
}
- CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
+ CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
angles[0] = atof(CG_Argv(2));
angles[1] = atof(CG_Argv(3));
@@ -175,15 +168,13 @@ void CG_TestModelSetAnglespre_f(void)
gi.G2API_SetBoneAngles(&ghoul2[cg.testModel], CG_Argv(1), angles, BONE_ANGLES_PREMULT, POSITIVE_X, POSITIVE_Z, POSITIVE_Y, NULL, 0, 0);
}
-void CG_TestModelSetAnglespost_f(void)
-{
- vec3_t angles;
+void CG_TestModelSetAnglespost_f(void) {
+ vec3_t angles;
- if ( cgi_Argc() < 3 )
- {
+ if (cgi_Argc() < 3) {
return;
}
- CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
+ CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
angles[0] = atof(CG_Argv(2));
angles[1] = atof(CG_Argv(3));
@@ -191,21 +182,18 @@ void CG_TestModelSetAnglespost_f(void)
gi.G2API_SetBoneAngles(&ghoul2[cg.testModel], CG_Argv(1), angles, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Z, POSITIVE_Y, NULL, 0, 0);
}
-void CG_TestModelAnimate_f(void)
-{
- char boneName[100];
- CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
+void CG_TestModelAnimate_f(void) {
+ char boneName[100];
+ CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2);
strcpy(boneName, CG_Argv(1));
gi.G2API_SetBoneAnim(&ghoul2[cg.testModel], boneName, atoi(CG_Argv(2)), atoi(CG_Argv(3)), BONE_ANIM_OVERRIDE_LOOP, atof(CG_Argv(4)), cg.time, -1, -1);
-
}
/*
Ghoul2 Insert End
*/
-
/*
=================
CG_TestModel_f
@@ -214,79 +202,75 @@ Creates an entity in front of the current position, which
can then be moved around
=================
*/
-void CG_TestModel_f (void) {
- vec3_t angles;
+void CG_TestModel_f(void) {
+ vec3_t angles;
- memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) );
- if ( cgi_Argc() < 2 ) {
+ memset(&cg.testModelEntity, 0, sizeof(cg.testModelEntity));
+ if (cgi_Argc() < 2) {
return;
}
- Q_strncpyz (cg.testModelName, CG_Argv( 1 ), MAX_QPATH );
- cg.testModelEntity.hModel = cgi_R_RegisterModel( cg.testModelName );
+ Q_strncpyz(cg.testModelName, CG_Argv(1), MAX_QPATH);
+ cg.testModelEntity.hModel = cgi_R_RegisterModel(cg.testModelName);
- if ( cgi_Argc() == 3 ) {
- cg.testModelEntity.backlerp = atof( CG_Argv( 2 ) );
+ if (cgi_Argc() == 3) {
+ cg.testModelEntity.backlerp = atof(CG_Argv(2));
cg.testModelEntity.frame = 1;
cg.testModelEntity.oldframe = 0;
}
- if (! cg.testModelEntity.hModel ) {
- CG_Printf( "Can't register model\n" );
+ if (!cg.testModelEntity.hModel) {
+ CG_Printf("Can't register model\n");
return;
}
- VectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin );
+ VectorMA(cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin);
angles[PITCH] = 0;
angles[YAW] = 180 + cg.refdefViewAngles[1];
angles[ROLL] = 0;
- AnglesToAxis( angles, cg.testModelEntity.axis );
+ AnglesToAxis(angles, cg.testModelEntity.axis);
}
-
-void CG_TestModelNextFrame_f (void) {
+void CG_TestModelNextFrame_f(void) {
cg.testModelEntity.frame++;
- CG_Printf( "frame %i\n", cg.testModelEntity.frame );
+ CG_Printf("frame %i\n", cg.testModelEntity.frame);
}
-void CG_TestModelPrevFrame_f (void) {
+void CG_TestModelPrevFrame_f(void) {
cg.testModelEntity.frame--;
- if ( cg.testModelEntity.frame < 0 ) {
+ if (cg.testModelEntity.frame < 0) {
cg.testModelEntity.frame = 0;
}
- CG_Printf( "frame %i\n", cg.testModelEntity.frame );
+ CG_Printf("frame %i\n", cg.testModelEntity.frame);
}
-void CG_TestModelNextSkin_f (void) {
+void CG_TestModelNextSkin_f(void) {
cg.testModelEntity.skinNum++;
- CG_Printf( "skin %i\n", cg.testModelEntity.skinNum );
+ CG_Printf("skin %i\n", cg.testModelEntity.skinNum);
}
-void CG_TestModelPrevSkin_f (void) {
+void CG_TestModelPrevSkin_f(void) {
cg.testModelEntity.skinNum--;
- if ( cg.testModelEntity.skinNum < 0 ) {
+ if (cg.testModelEntity.skinNum < 0) {
cg.testModelEntity.skinNum = 0;
}
- CG_Printf( "skin %i\n", cg.testModelEntity.skinNum );
+ CG_Printf("skin %i\n", cg.testModelEntity.skinNum);
}
-static void CG_AddTestModel (void) {
+static void CG_AddTestModel(void) {
// re-register the model, because the level may have changed
-/* cg.testModelEntity.hModel = cgi_R_RegisterModel( cg.testModelName );
- if (! cg.testModelEntity.hModel ) {
- CG_Printf ("Can't register model\n");
- return;
- }
-*/
- cgi_R_AddRefEntityToScene( &cg.testModelEntity );
+ /* cg.testModelEntity.hModel = cgi_R_RegisterModel( cg.testModelName );
+ if (! cg.testModelEntity.hModel ) {
+ CG_Printf ("Can't register model\n");
+ return;
+ }
+ */
+ cgi_R_AddRefEntityToScene(&cg.testModelEntity);
}
-
-
//============================================================================
-
/*
=================
CG_CalcVrect
@@ -294,8 +278,8 @@ CG_CalcVrect
Sets the coordinates of the rendered window
=================
*/
-void CG_CalcVrect (void) {
- const int size = 100;
+void CG_CalcVrect(void) {
+ const int size = 100;
cg.refdef.width = cgs.glconfig.vidWidth * size * 0.01;
cg.refdef.width &= ~1;
@@ -309,22 +293,22 @@ void CG_CalcVrect (void) {
//==============================================================================
//==============================================================================
-#define CAMERA_DAMP_INTERVAL 50
+#define CAMERA_DAMP_INTERVAL 50
-#define CAMERA_CROUCH_NUDGE 6
+#define CAMERA_CROUCH_NUDGE 6
-static vec3_t cameramins = { -CAMERA_SIZE, -CAMERA_SIZE, -CAMERA_SIZE };
-static vec3_t cameramaxs = { CAMERA_SIZE, CAMERA_SIZE, CAMERA_SIZE };
-vec3_t camerafwd, cameraup, camerahorizdir;
+static vec3_t cameramins = {-CAMERA_SIZE, -CAMERA_SIZE, -CAMERA_SIZE};
+static vec3_t cameramaxs = {CAMERA_SIZE, CAMERA_SIZE, CAMERA_SIZE};
+vec3_t camerafwd, cameraup, camerahorizdir;
-vec3_t cameraFocusAngles, cameraFocusLoc;
-vec3_t cameraIdealTarget, cameraIdealLoc;
-vec3_t cameraCurTarget={0,0,0}, cameraCurLoc={0,0,0};
-vec3_t cameraOldLoc={0,0,0}, cameraNewLoc={0,0,0};
-int cameraLastFrame=0;
+vec3_t cameraFocusAngles, cameraFocusLoc;
+vec3_t cameraIdealTarget, cameraIdealLoc;
+vec3_t cameraCurTarget = {0, 0, 0}, cameraCurLoc = {0, 0, 0};
+vec3_t cameraOldLoc = {0, 0, 0}, cameraNewLoc = {0, 0, 0};
+int cameraLastFrame = 0;
-float cameraLastYaw=0;
-float cameraStiffFactor=0.0f;
+float cameraLastYaw = 0;
+float cameraStiffFactor = 0.0f;
/*
===============
@@ -346,156 +330,105 @@ CG_CalcIdealThirdPersonViewTarget
===============
*/
-static void CG_CalcIdealThirdPersonViewTarget(void)
-{
+static void CG_CalcIdealThirdPersonViewTarget(void) {
// Initialize IdealTarget
qboolean usesViewEntity = (qboolean)(cg.snap->ps.viewEntity && cg.snap->ps.viewEntity < ENTITYNUM_WORLD);
VectorCopy(cg.refdef.vieworg, cameraFocusLoc);
- if ( usesViewEntity )
- {
+ if (usesViewEntity) {
gentity_t *gent = &g_entities[cg.snap->ps.viewEntity];
- if ( gent->client && (gent->client->NPC_class == CLASS_GONK
- || gent->client->NPC_class == CLASS_INTERROGATOR
- || gent->client->NPC_class == CLASS_SENTRY
- || gent->client->NPC_class == CLASS_PROBE
- || gent->client->NPC_class == CLASS_MOUSE
- || gent->client->NPC_class == CLASS_R2D2
- || gent->client->NPC_class == CLASS_R5D2) )
- { // Droids use a generic offset
+ if (gent->client && (gent->client->NPC_class == CLASS_GONK || gent->client->NPC_class == CLASS_INTERROGATOR ||
+ gent->client->NPC_class == CLASS_SENTRY || gent->client->NPC_class == CLASS_PROBE || gent->client->NPC_class == CLASS_MOUSE ||
+ gent->client->NPC_class == CLASS_R2D2 || gent->client->NPC_class == CLASS_R5D2)) { // Droids use a generic offset
cameraFocusLoc[2] += 4;
- VectorCopy( cameraFocusLoc, cameraIdealTarget );
+ VectorCopy(cameraFocusLoc, cameraIdealTarget);
return;
}
- if( gent->client->ps.pm_flags & PMF_DUCKED )
- { // sort of a nasty hack in order to get this to work. Don't tell Ensiform, or I'll have to kill him. --eez
- cameraFocusLoc[2] -= CAMERA_CROUCH_NUDGE*4;
+ if (gent->client->ps.pm_flags & PMF_DUCKED) { // sort of a nasty hack in order to get this to work. Don't tell Ensiform, or I'll have to kill him. --eez
+ cameraFocusLoc[2] -= CAMERA_CROUCH_NUDGE * 4;
}
}
// Add in the new viewheight
cameraFocusLoc[2] += cg.predicted_player_state.viewheight;
- if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE) )
- {
- VectorCopy( cameraFocusLoc, cameraIdealTarget );
+ if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE)) {
+ VectorCopy(cameraFocusLoc, cameraIdealTarget);
cameraIdealTarget[2] += 192;
- }
- else if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_WAMPA) )
- {
- VectorCopy( cameraFocusLoc, cameraIdealTarget );
+ } else if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_WAMPA)) {
+ VectorCopy(cameraFocusLoc, cameraIdealTarget);
cameraIdealTarget[2] -= 48;
- }
- else if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_VOF )
- {
+ } else if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_VOF) {
// Add in a vertical offset from the viewpoint, which puts the actual target above the head, regardless of angle.
- VectorCopy( cameraFocusLoc, cameraIdealTarget );
+ VectorCopy(cameraFocusLoc, cameraIdealTarget);
cameraIdealTarget[2] += cg.overrides.thirdPersonVertOffset;
- //VectorMA(cameraFocusLoc, cg.overrides.thirdPersonVertOffset, cameraup, cameraIdealTarget);
- }
- else
- {
+ // VectorMA(cameraFocusLoc, cg.overrides.thirdPersonVertOffset, cameraup, cameraIdealTarget);
+ } else {
// Add in a vertical offset from the viewpoint, which puts the actual target above the head, regardless of angle.
- VectorCopy( cameraFocusLoc, cameraIdealTarget );
+ VectorCopy(cameraFocusLoc, cameraIdealTarget);
cameraIdealTarget[2] += cg_thirdPersonVertOffset.value;
- //VectorMA(cameraFocusLoc, cg_thirdPersonVertOffset.value, cameraup, cameraIdealTarget);
+ // VectorMA(cameraFocusLoc, cg_thirdPersonVertOffset.value, cameraup, cameraIdealTarget);
}
// Now, if the player is crouching, do a little special tweak. The problem is that the player's head is way out of his bbox.
- if (cg.predicted_player_state.pm_flags & PMF_DUCKED)
- { // Nudge to focus location up a tad.
+ if (cg.predicted_player_state.pm_flags & PMF_DUCKED) { // Nudge to focus location up a tad.
vec3_t nudgepos;
trace_t trace;
VectorCopy(cameraFocusLoc, nudgepos);
- nudgepos[2]+=CAMERA_CROUCH_NUDGE;
- CG_Trace(&trace, cameraFocusLoc, cameramins, cameramaxs, nudgepos,
- ( usesViewEntity ) ? cg.snap->ps.viewEntity : cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
- if (trace.fraction < 1.0)
- {
+ nudgepos[2] += CAMERA_CROUCH_NUDGE;
+ CG_Trace(&trace, cameraFocusLoc, cameramins, cameramaxs, nudgepos, (usesViewEntity) ? cg.snap->ps.viewEntity : cg.predicted_player_state.clientNum,
+ MASK_CAMERACLIP);
+ if (trace.fraction < 1.0) {
VectorCopy(trace.endpos, cameraFocusLoc);
- }
- else
- {
+ } else {
VectorCopy(nudgepos, cameraFocusLoc);
}
}
}
-
-
/*
===============
CG_CalcIdealThirdPersonViewLocation
===============
*/
-static void CG_CalcIdealThirdPersonViewLocation(void)
-{
- if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_RNG )
- {
+static void CG_CalcIdealThirdPersonViewLocation(void) {
+ if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_RNG) {
VectorMA(cameraIdealTarget, -(cg.overrides.thirdPersonRange), camerafwd, cameraIdealLoc);
- }
- else if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_RANCOR)
- && cg_entities[cg.snap->ps.clientNum].gent->activator )
- {//stay back
- VectorMA(cameraIdealTarget, -180.0f*cg_entities[cg.snap->ps.clientNum].gent->activator->s.modelScale[0], camerafwd, cameraIdealLoc);
- }
- else if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_WAMPA)
- && cg_entities[cg.snap->ps.clientNum].gent->activator
- && cg_entities[cg.snap->ps.clientNum].gent->activator->inuse )
- {//stay back
- VectorMA(cameraIdealTarget, -120.0f*cg_entities[cg.snap->ps.clientNum].gent->activator->s.modelScale[0], camerafwd, cameraIdealLoc);
- }
- else if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
- && cg_entities[cg.snap->ps.clientNum].gent->activator )
- {//stay back
+ } else if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_RANCOR) && cg_entities[cg.snap->ps.clientNum].gent->activator) { // stay back
+ VectorMA(cameraIdealTarget, -180.0f * cg_entities[cg.snap->ps.clientNum].gent->activator->s.modelScale[0], camerafwd, cameraIdealLoc);
+ } else if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_WAMPA) && cg_entities[cg.snap->ps.clientNum].gent->activator &&
+ cg_entities[cg.snap->ps.clientNum].gent->activator->inuse) { // stay back
+ VectorMA(cameraIdealTarget, -120.0f * cg_entities[cg.snap->ps.clientNum].gent->activator->s.modelScale[0], camerafwd, cameraIdealLoc);
+ } else if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE) && cg_entities[cg.snap->ps.clientNum].gent->activator) { // stay back
VectorMA(cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number].lerpOrigin, -180.0f, camerafwd, cameraIdealLoc);
- }
- else
- {
+ } else {
VectorMA(cameraIdealTarget, -(cg_thirdPersonRange.value), camerafwd, cameraIdealLoc);
}
- if ( cg.renderingThirdPerson && (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )
- {
+ if (cg.renderingThirdPerson && (cg.snap->ps.forcePowersActive & (1 << FP_SPEED)) && player->client->ps.forcePowerDuration[FP_SPEED]) {
float timeLeft = player->client->ps.forcePowerDuration[FP_SPEED] - cg.time;
- float length = FORCE_SPEED_DURATION*forceSpeedValue[player->client->ps.forcePowerLevel[FP_SPEED]];
+ float length = FORCE_SPEED_DURATION * forceSpeedValue[player->client->ps.forcePowerLevel[FP_SPEED]];
float amt = forceSpeedRangeMod[player->client->ps.forcePowerLevel[FP_SPEED]];
- if ( timeLeft < 500 )
- {//start going back
- VectorMA(cameraIdealLoc, (timeLeft)/500*amt, camerafwd, cameraIdealLoc);
- }
- else if ( length - timeLeft < 1000 )
- {//start zooming in
- VectorMA(cameraIdealLoc, (length - timeLeft)/1000*amt, camerafwd, cameraIdealLoc);
- }
- else
- {
+ if (timeLeft < 500) { // start going back
+ VectorMA(cameraIdealLoc, (timeLeft) / 500 * amt, camerafwd, cameraIdealLoc);
+ } else if (length - timeLeft < 1000) { // start zooming in
+ VectorMA(cameraIdealLoc, (length - timeLeft) / 1000 * amt, camerafwd, cameraIdealLoc);
+ } else {
VectorMA(cameraIdealLoc, amt, camerafwd, cameraIdealLoc);
}
}
}
-
-
-static void CG_ResetThirdPersonViewDamp(void)
-{
+static void CG_ResetThirdPersonViewDamp(void) {
trace_t trace;
// Cap the pitch within reasonable limits
- if (cameraFocusAngles[PITCH] > 89.0)
- {
+ if (cameraFocusAngles[PITCH] > 89.0) {
cameraFocusAngles[PITCH] = 89.0;
- }
- else if (cameraFocusAngles[PITCH] < -89.0)
- {
+ } else if (cameraFocusAngles[PITCH] < -89.0) {
cameraFocusAngles[PITCH] = -89.0;
}
@@ -513,15 +446,13 @@ static void CG_ResetThirdPersonViewDamp(void)
// First thing we do is trace from the first person viewpoint out to the new target location.
CG_Trace(&trace, cameraFocusLoc, cameramins, cameramaxs, cameraCurTarget, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
- if (trace.fraction <= 1.0)
- {
+ if (trace.fraction <= 1.0) {
VectorCopy(trace.endpos, cameraCurTarget);
}
// Now we trace from the new target location to the new view location, to make sure there is nothing in the way.
CG_Trace(&trace, cameraCurTarget, cameramins, cameramaxs, cameraCurLoc, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
- if (trace.fraction <= 1.0)
- {
+ if (trace.fraction <= 1.0) {
VectorCopy(trace.endpos, cameraCurLoc);
}
@@ -531,40 +462,36 @@ static void CG_ResetThirdPersonViewDamp(void)
}
// This is called every frame.
-static void CG_UpdateThirdPersonTargetDamp(void)
-{
+static void CG_UpdateThirdPersonTargetDamp(void) {
trace_t trace;
- vec3_t targetdiff;
- float dampfactor, dtime, ratio;
+ vec3_t targetdiff;
+ float dampfactor, dtime, ratio;
// Set the cameraIdealTarget
// Automatically get the ideal target, to avoid jittering.
CG_CalcIdealThirdPersonViewTarget();
- if ( CG_OnMovingPlat( &cg.snap->ps ) )
- {//if moving on a plat, camera is *tight*
+ if (CG_OnMovingPlat(&cg.snap->ps)) { // if moving on a plat, camera is *tight*
VectorCopy(cameraIdealTarget, cameraCurTarget);
- }
- else if (cg_thirdPersonTargetDamp.value>=1.0)//||cg.thisFrameTeleport)
- { // No damping.
+ } else if (cg_thirdPersonTargetDamp.value >= 1.0) //||cg.thisFrameTeleport)
+ { // No damping.
VectorCopy(cameraIdealTarget, cameraCurTarget);
- }
- else if (cg_thirdPersonTargetDamp.value>=0.0)
- {
+ } else if (cg_thirdPersonTargetDamp.value >= 0.0) {
// Calculate the difference from the current position to the new one.
VectorSubtract(cameraIdealTarget, cameraCurTarget, targetdiff);
// Now we calculate how much of the difference we cover in the time allotted.
// The equation is (Damp)^(time)
- dampfactor = 1.0-cg_thirdPersonTargetDamp.value; // We must exponent the amount LEFT rather than the amount bled off
- dtime = (float)(cg.time-cameraLastFrame) * (1.0/cg_timescale.value) * (1.0/(float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1".
+ dampfactor = 1.0 - cg_thirdPersonTargetDamp.value; // We must exponent the amount LEFT rather than the amount bled off
+ dtime = (float)(cg.time - cameraLastFrame) * (1.0 / cg_timescale.value) *
+ (1.0 / (float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1".
// Note that since there are a finite number of "practical" delta millisecond values possible,
// the ratio should be initialized into a chart ultimately.
- if ( cg_smoothCamera.integer )
- ratio = powf( dampfactor, dtime );
+ if (cg_smoothCamera.integer)
+ ratio = powf(dampfactor, dtime);
else
- ratio = Q_powf( dampfactor, dtime );
+ ratio = Q_powf(dampfactor, dtime);
// This value is how much distance is "left" from the ideal.
VectorMA(cameraIdealTarget, -ratio, targetdiff, cameraCurTarget);
@@ -574,18 +501,15 @@ static void CG_UpdateThirdPersonTargetDamp(void)
// Now we trace to see if the new location is cool or not.
// First thing we do is trace from the first person viewpoint out to the new target location.
- if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
- && cg_entities[cg.snap->ps.clientNum].gent->activator )
- {//if being held by a sand creature, trace from his actual origin, since we could be underground or otherwise in solid once he eats us
- CG_Trace(&trace, cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number].lerpOrigin, cameramins, cameramaxs, cameraCurTarget, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
- }
- else
- {
+ if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE) &&
+ cg_entities[cg.snap->ps.clientNum].gent->activator) { // if being held by a sand creature, trace from his actual origin, since we could be underground
+ // or otherwise in solid once he eats us
+ CG_Trace(&trace, cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number].lerpOrigin, cameramins, cameramaxs, cameraCurTarget,
+ cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
+ } else {
CG_Trace(&trace, cameraFocusLoc, cameramins, cameramaxs, cameraCurTarget, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
}
- if (trace.fraction < 1.0)
- {
+ if (trace.fraction < 1.0) {
VectorCopy(trace.endpos, cameraCurTarget);
}
@@ -597,40 +521,32 @@ static void CG_UpdateThirdPersonTargetDamp(void)
// This can be called every interval, at the user's discretion.
static int camWaterAdjust = 0;
-static void CG_UpdateThirdPersonCameraDamp(void)
-{
+static void CG_UpdateThirdPersonCameraDamp(void) {
trace_t trace;
- vec3_t locdiff;
+ vec3_t locdiff;
float dampfactor, dtime, ratio;
// Set the cameraIdealLoc
CG_CalcIdealThirdPersonViewLocation();
-
// First thing we do is calculate the appropriate damping factor for the camera.
- dampfactor=0.0f;
- if ( CG_OnMovingPlat( &cg.snap->ps ) )
- {//if moving on a plat, camera is *tight*
- dampfactor=1.0f;
- }
- else if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_CDP )
- {
- if ( cg.overrides.thirdPersonCameraDamp != 0.0f )
- {
+ dampfactor = 0.0f;
+ if (CG_OnMovingPlat(&cg.snap->ps)) { // if moving on a plat, camera is *tight*
+ dampfactor = 1.0f;
+ } else if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_CDP) {
+ if (cg.overrides.thirdPersonCameraDamp != 0.0f) {
float pitch;
// Note that the camera pitch has already been capped off to 89.
pitch = Q_fabs(cameraFocusAngles[PITCH]);
// The higher the pitch, the larger the factor, so as you look up, it damps a lot less.
- pitch /=115.0f;
- dampfactor = (1.0-cg.overrides.thirdPersonCameraDamp)*(pitch*pitch);
+ pitch /= 115.0f;
+ dampfactor = (1.0 - cg.overrides.thirdPersonCameraDamp) * (pitch * pitch);
dampfactor += cg.overrides.thirdPersonCameraDamp;
}
- }
- else if ( cg_thirdPersonCameraDamp.value != 0.0f )
- {
+ } else if (cg_thirdPersonCameraDamp.value != 0.0f) {
float pitch;
// Note that the camera pitch has already been capped off to 89.
@@ -638,37 +554,36 @@ static void CG_UpdateThirdPersonCameraDamp(void)
// The higher the pitch, the larger the factor, so as you look up, it damps a lot less.
pitch /= 115.0f;
- dampfactor = (1.0-cg_thirdPersonCameraDamp.value)*(pitch*pitch);
+ dampfactor = (1.0 - cg_thirdPersonCameraDamp.value) * (pitch * pitch);
dampfactor += cg_thirdPersonCameraDamp.value;
// Now we also multiply in the stiff factor, so that faster yaw changes are stiffer.
- if (cameraStiffFactor > 0.0f)
- { // The cameraStiffFactor is how much of the remaining damp below 1 should be shaved off, i.e. approach 1 as stiffening increases.
- dampfactor += (1.0-dampfactor)*cameraStiffFactor;
+ if (cameraStiffFactor >
+ 0.0f) { // The cameraStiffFactor is how much of the remaining damp below 1 should be shaved off, i.e. approach 1 as stiffening increases.
+ dampfactor += (1.0 - dampfactor) * cameraStiffFactor;
}
}
- if (dampfactor>=1.0)//||cg.thisFrameTeleport)
- { // No damping.
+ if (dampfactor >= 1.0) //||cg.thisFrameTeleport)
+ { // No damping.
VectorCopy(cameraIdealLoc, cameraCurLoc);
- }
- else if (dampfactor>=0.0)
- {
+ } else if (dampfactor >= 0.0) {
// Calculate the difference from the current position to the new one.
VectorSubtract(cameraIdealLoc, cameraCurLoc, locdiff);
// Now we calculate how much of the difference we cover in the time allotted.
// The equation is (Damp)^(time)
- dampfactor = 1.0-dampfactor; // We must exponent the amount LEFT rather than the amount bled off
- dtime = (float)(cg.time-cameraLastFrame) * (1.0/cg_timescale.value) * (1.0/(float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1".
+ dampfactor = 1.0 - dampfactor; // We must exponent the amount LEFT rather than the amount bled off
+ dtime = (float)(cg.time - cameraLastFrame) * (1.0 / cg_timescale.value) *
+ (1.0 / (float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1".
// Note that since there are a finite number of "practical" delta millisecond values possible,
// the ratio should be initialized into a chart ultimately.
- if ( cg_smoothCamera.integer )
- ratio = powf( dampfactor, dtime );
+ if (cg_smoothCamera.integer)
+ ratio = powf(dampfactor, dtime);
else
- ratio = Q_powf( dampfactor, dtime );
+ ratio = Q_powf(dampfactor, dtime);
// This value is how much distance is "left" from the ideal.
VectorMA(cameraIdealLoc, -ratio, locdiff, cameraCurLoc);
@@ -676,27 +591,24 @@ static void CG_UpdateThirdPersonCameraDamp(void)
}
// Now we trace from the first person viewpoint to the new view location, to make sure there is nothing in the way between the user and the camera...
-// CG_Trace(&trace, cameraFocusLoc, cameramins, cameramaxs, cameraCurLoc, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
+ // CG_Trace(&trace, cameraFocusLoc, cameramins, cameramaxs, cameraCurLoc, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
// (OLD) Now we trace from the new target location to the new view location, to make sure there is nothing in the way.
- if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
- && cg_entities[cg.snap->ps.clientNum].gent->activator )
- {//if being held by a sand creature, trace from his actual origin, since we could be underground or otherwise in solid once he eats us
- CG_Trace( &trace, cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number].lerpOrigin, cameramins, cameramaxs, cameraCurLoc, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
- }
- else
- {
- CG_Trace( &trace, cameraCurTarget, cameramins, cameramaxs, cameraCurLoc, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
+ if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE) &&
+ cg_entities[cg.snap->ps.clientNum].gent->activator) { // if being held by a sand creature, trace from his actual origin, since we could be underground
+ // or otherwise in solid once he eats us
+ CG_Trace(&trace, cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number].lerpOrigin, cameramins, cameramaxs, cameraCurLoc,
+ cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
+ } else {
+ CG_Trace(&trace, cameraCurTarget, cameramins, cameramaxs, cameraCurLoc, cg.predicted_player_state.clientNum, MASK_CAMERACLIP);
}
- if ( trace.fraction < 1.0f )
- {
- VectorCopy( trace.endpos, cameraCurLoc );
+ if (trace.fraction < 1.0f) {
+ VectorCopy(trace.endpos, cameraCurLoc);
// We didn't trace all the way back, so push down the target accordingly.
-// VectorSubtract(cameraCurTarget, cameraFocusLoc, locdiff);
-// VectorMA(cameraFocusLoc, trace.fraction, locdiff, cameraCurTarget);
+ // VectorSubtract(cameraCurTarget, cameraFocusLoc, locdiff);
+ // VectorMA(cameraFocusLoc, trace.fraction, locdiff, cameraCurTarget);
- //FIXME: when the trace hits movers, it gets very very jaggy... ?
+ // FIXME: when the trace hits movers, it gets very very jaggy... ?
/*
//this doesn't actually help any
if ( trace.entityNum != ENTITYNUM_WORLD )
@@ -722,18 +634,14 @@ static void CG_UpdateThirdPersonCameraDamp(void)
// however two full volume traces each frame is a bit scary to think about.
}
-
-
-
/*
===============
CG_OffsetThirdPersonView
===============
*/
-extern qboolean MatrixMode;
-static void CG_OffsetThirdPersonView( void )
-{
+extern qboolean MatrixMode;
+static void CG_OffsetThirdPersonView(void) {
vec3_t diff;
float deltayaw;
@@ -741,122 +649,83 @@ static void CG_OffsetThirdPersonView( void )
cameraStiffFactor = 0.0;
// Set camera viewing direction.
- VectorCopy( cg.refdefViewAngles, cameraFocusAngles );
-
- if ( cg.snap
- && (cg.snap->ps.eFlags&EF_HELD_BY_RANCOR)
- && cg_entities[cg.snap->ps.clientNum].gent->activator )
- {
- centity_t *monster = &cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number];
- VectorSet( cameraFocusAngles, 0, AngleNormalize180(monster->lerpAngles[YAW]+180), 0 );
- }
- else if ( cg.snap && (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE) )
- {
- centity_t *monster = &cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number];
- VectorSet( cameraFocusAngles, 0, AngleNormalize180(monster->lerpAngles[YAW]+180), 0 );
- cameraFocusAngles[PITCH] = 0.0f;//flatten it out
- }
- else if ( G_IsRidingVehicle( &g_entities[0] ) )
- {
+ VectorCopy(cg.refdefViewAngles, cameraFocusAngles);
+
+ if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_RANCOR) && cg_entities[cg.snap->ps.clientNum].gent->activator) {
+ centity_t *monster = &cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number];
+ VectorSet(cameraFocusAngles, 0, AngleNormalize180(monster->lerpAngles[YAW] + 180), 0);
+ } else if (cg.snap && (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE)) {
+ centity_t *monster = &cg_entities[cg_entities[cg.snap->ps.clientNum].gent->activator->s.number];
+ VectorSet(cameraFocusAngles, 0, AngleNormalize180(monster->lerpAngles[YAW] + 180), 0);
+ cameraFocusAngles[PITCH] = 0.0f; // flatten it out
+ } else if (G_IsRidingVehicle(&g_entities[0])) {
cameraFocusAngles[YAW] = cg_entities[g_entities[0].owner->s.number].lerpAngles[YAW];
- if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ANG )
- {
+ if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ANG) {
cameraFocusAngles[YAW] += cg.overrides.thirdPersonAngle;
- }
- else
- {
+ } else {
cameraFocusAngles[YAW] += cg_thirdPersonAngle.value;
}
- }
- else if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 )
- {// if dead, look at killer
- if ( MatrixMode )
- {
- if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ANG )
- {
+ } else if (cg.predicted_player_state.stats[STAT_HEALTH] <= 0) { // if dead, look at killer
+ if (MatrixMode) {
+ if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ANG) {
cameraFocusAngles[YAW] += cg.overrides.thirdPersonAngle;
- }
- else
- {
+ } else {
cameraFocusAngles[YAW] = cg.predicted_player_state.stats[STAT_DEAD_YAW];
cameraFocusAngles[YAW] += cg_thirdPersonAngle.value;
}
- }
- else
- {
+ } else {
cameraFocusAngles[YAW] = cg.predicted_player_state.stats[STAT_DEAD_YAW];
}
- }
- else
- { // Add in the third Person Angle.
- if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ANG )
- {
+ } else { // Add in the third Person Angle.
+ if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ANG) {
cameraFocusAngles[YAW] += cg.overrides.thirdPersonAngle;
- }
- else
- {
+ } else {
cameraFocusAngles[YAW] += cg_thirdPersonAngle.value;
}
- if ( cg.overrides.active & CG_OVERRIDE_3RD_PERSON_POF )
- {
+ if (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_POF) {
cameraFocusAngles[PITCH] += cg.overrides.thirdPersonPitchOffset;
- }
- else
- {
+ } else {
cameraFocusAngles[PITCH] += cg_thirdPersonPitchOffset.value;
}
}
- if ( !cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) )
- {// First person saber
+ if (!cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)) { // First person saber
// FIXME: use something network-friendly
- vec3_t org, viewDir;
- VectorCopy( cg_entities[0].gent->client->renderInfo.eyePoint, org );
- float blend = 1.0f - fabs(cg.refdefViewAngles[PITCH])/90.0f;
- AngleVectors( cg.refdefViewAngles, viewDir, NULL, NULL );
- VectorMA( org, -8, viewDir, org );
- VectorScale( org, 1.0f - blend, org );
- VectorMA( org, blend, cg.refdef.vieworg, cg.refdef.vieworg );
+ vec3_t org, viewDir;
+ VectorCopy(cg_entities[0].gent->client->renderInfo.eyePoint, org);
+ float blend = 1.0f - fabs(cg.refdefViewAngles[PITCH]) / 90.0f;
+ AngleVectors(cg.refdefViewAngles, viewDir, NULL, NULL);
+ VectorMA(org, -8, viewDir, org);
+ VectorScale(org, 1.0f - blend, org);
+ VectorMA(org, blend, cg.refdef.vieworg, cg.refdef.vieworg);
return;
}
// The next thing to do is to see if we need to calculate a new camera target location.
// If we went back in time for some reason, or if we just started, reset the sample.
- if (cameraLastFrame == 0 || cameraLastFrame > cg.time)
- {
+ if (cameraLastFrame == 0 || cameraLastFrame > cg.time) {
CG_ResetThirdPersonViewDamp();
- }
- else
- {
+ } else {
// Cap the pitch within reasonable limits
- if (cameraFocusAngles[PITCH] > 89.0)
- {
+ if (cameraFocusAngles[PITCH] > 89.0) {
cameraFocusAngles[PITCH] = 89.0;
- }
- else if (cameraFocusAngles[PITCH] < -89.0)
- {
+ } else if (cameraFocusAngles[PITCH] < -89.0) {
cameraFocusAngles[PITCH] = -89.0;
}
AngleVectors(cameraFocusAngles, camerafwd, NULL, cameraup);
deltayaw = fabs(cameraFocusAngles[YAW] - cameraLastYaw);
- if (deltayaw > 180.0f)
- { // Normalize this angle so that it is between 0 and 180.
+ if (deltayaw > 180.0f) { // Normalize this angle so that it is between 0 and 180.
deltayaw = fabs(deltayaw - 360.0f);
}
- cameraStiffFactor = deltayaw / (float)(cg.time-cameraLastFrame);
- if (cameraStiffFactor < 1.0)
- {
+ cameraStiffFactor = deltayaw / (float)(cg.time - cameraLastFrame);
+ if (cameraStiffFactor < 1.0) {
cameraStiffFactor = 0.0;
- }
- else if (cameraStiffFactor > 2.5)
- {
+ } else if (cameraStiffFactor > 2.5) {
cameraStiffFactor = 0.75;
- }
- else
- { // 1 to 2 scales from 0.0 to 0.5
- cameraStiffFactor = (cameraStiffFactor-1.0f)*0.5f;
+ } else { // 1 to 2 scales from 0.0 to 0.5
+ cameraStiffFactor = (cameraStiffFactor - 1.0f) * 0.5f;
}
cameraLastYaw = cameraFocusAngles[YAW];
@@ -870,35 +739,30 @@ static void CG_OffsetThirdPersonView( void )
// We must now take the angle taken from the camera target and location.
VectorSubtract(cameraCurTarget, cameraCurLoc, diff);
- //Com_Printf( "%s\n", vtos(diff) );
+ // Com_Printf( "%s\n", vtos(diff) );
float dist = VectorNormalize(diff);
- if ( dist < 1.0f )
- {//must be hitting something, need some value to calc angles, so use cam forward
- VectorCopy( camerafwd, diff );
+ if (dist < 1.0f) { // must be hitting something, need some value to calc angles, so use cam forward
+ VectorCopy(camerafwd, diff);
}
vectoangles(diff, cg.refdefViewAngles);
// Temp: just move the camera to the side a bit
extern vmCvar_t cg_thirdPersonHorzOffset;
- if ( cg_thirdPersonHorzOffset.value != 0.0f )
- {
- AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
- VectorMA( cameraCurLoc, cg_thirdPersonHorzOffset.value, cg.refdef.viewaxis[1], cameraCurLoc );
+ if (cg_thirdPersonHorzOffset.value != 0.0f) {
+ AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
+ VectorMA(cameraCurLoc, cg_thirdPersonHorzOffset.value, cg.refdef.viewaxis[1], cameraCurLoc);
}
// ...and of course we should copy the new view location to the proper spot too.
VectorCopy(cameraCurLoc, cg.refdef.vieworg);
- //if we hit the water, do a last-minute adjustment
- if ( camWaterAdjust )
- {
+ // if we hit the water, do a last-minute adjustment
+ if (camWaterAdjust) {
cg.refdef.vieworg[2] += camWaterAdjust;
}
- cameraLastFrame=cg.time;
+ cameraLastFrame = cg.time;
}
-
-
/*
===============
CG_OffsetThirdPersonView
@@ -1038,14 +902,13 @@ static void CG_OffsetThirdPersonOverheadView( void ) {
}
*/
// this causes a compiler bug on mac MrC compiler
-static void CG_StepOffset( void ) {
- int timeDelta;
+static void CG_StepOffset(void) {
+ int timeDelta;
// smooth out stair climbing
timeDelta = cg.time - cg.stepTime;
- if ( timeDelta < STEP_TIME ) {
- cg.refdef.vieworg[2] -= cg.stepChange
- * (STEP_TIME - timeDelta) / STEP_TIME;
+ if (timeDelta < STEP_TIME) {
+ cg.refdef.vieworg[2] -= cg.stepChange * (STEP_TIME - timeDelta) / STEP_TIME;
}
}
@@ -1055,22 +918,22 @@ CG_OffsetFirstPersonView
===============
*/
-extern qboolean PM_InForceGetUp( playerState_t *ps );
-extern qboolean PM_InGetUp( playerState_t *ps );
-extern qboolean PM_InKnockDown( playerState_t *ps );
-extern int PM_AnimLength( int index, animNumber_t anim );
-static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
- float *origin;
- float *angles;
- float bob;
- float ratio;
- float delta;
- float speed;
- float f;
- vec3_t predictedVelocity;
- int timeDelta;
-
- if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
+extern qboolean PM_InForceGetUp(playerState_t *ps);
+extern qboolean PM_InGetUp(playerState_t *ps);
+extern qboolean PM_InKnockDown(playerState_t *ps);
+extern int PM_AnimLength(int index, animNumber_t anim);
+static void CG_OffsetFirstPersonView(qboolean firstPersonSaber) {
+ float *origin;
+ float *angles;
+ float bob;
+ float ratio;
+ float delta;
+ float speed;
+ float f;
+ vec3_t predictedVelocity;
+ int timeDelta;
+
+ if (cg.snap->ps.pm_type == PM_INTERMISSION) {
return;
}
@@ -1078,8 +941,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
angles = cg.refdefViewAngles;
// if dead, fix the angle and don't add any kick
- if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 )
- {
+ if (cg.snap->ps.stats[STAT_HEALTH] <= 0) {
angles[ROLL] = 40;
angles[PITCH] = -15;
angles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW];
@@ -1087,52 +949,43 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
return;
}
- if ( g_entities[0].client && PM_InKnockDown( &g_entities[0].client->ps ) )
- {
- float perc, animLen = (float)PM_AnimLength( g_entities[0].client->clientInfo.animFileIndex, (animNumber_t)g_entities[0].client->ps.legsAnim );
- if ( PM_InGetUp( &g_entities[0].client->ps ) || PM_InForceGetUp( &g_entities[0].client->ps ) )
- {//start righting the view
- perc = (float)g_entities[0].client->ps.legsAnimTimer/animLen*2;
- }
- else
- {//tilt the view
- perc = (animLen-g_entities[0].client->ps.legsAnimTimer)/animLen*2;
+ if (g_entities[0].client && PM_InKnockDown(&g_entities[0].client->ps)) {
+ float perc, animLen = (float)PM_AnimLength(g_entities[0].client->clientInfo.animFileIndex, (animNumber_t)g_entities[0].client->ps.legsAnim);
+ if (PM_InGetUp(&g_entities[0].client->ps) || PM_InForceGetUp(&g_entities[0].client->ps)) { // start righting the view
+ perc = (float)g_entities[0].client->ps.legsAnimTimer / animLen * 2;
+ } else { // tilt the view
+ perc = (animLen - g_entities[0].client->ps.legsAnimTimer) / animLen * 2;
}
- if ( perc > 1.0f )
- {
+ if (perc > 1.0f) {
perc = 1.0f;
}
- angles[ROLL] = perc*40;
- angles[PITCH] = perc*-15;
+ angles[ROLL] = perc * 40;
+ angles[PITCH] = perc * -15;
}
// add angles based on weapon kick
int kickTime = (cg.time - cg.kick_time);
- if ( kickTime < 800 )
- {//kicks are always 1 second long. Deal with it.
+ if (kickTime < 800) { // kicks are always 1 second long. Deal with it.
float kickPerc = 0.0f;
- if ( kickTime <= 200 )
- {//winding up
- kickPerc = kickTime/200.0f;
- }
- else
- {//returning to normal
+ if (kickTime <= 200) { // winding up
+ kickPerc = kickTime / 200.0f;
+ } else { // returning to normal
kickTime = 800 - kickTime;
- kickPerc = kickTime/600.0f;
+ kickPerc = kickTime / 600.0f;
}
- VectorMA( angles, kickPerc, cg.kick_angles, angles );
+ VectorMA(angles, kickPerc, cg.kick_angles, angles);
}
// add angles based on damage kick
- if ( cg.damageTime ) {
+ if (cg.damageTime) {
ratio = cg.time - cg.damageTime;
- if ( ratio < DAMAGE_DEFLECT_TIME ) {
+ if (ratio < DAMAGE_DEFLECT_TIME) {
ratio /= DAMAGE_DEFLECT_TIME;
angles[PITCH] += ratio * cg.v_dmg_pitch;
angles[ROLL] += ratio * cg.v_dmg_roll;
} else {
- ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;
- if ( ratio > 0 ) {
+ ratio = 1.0 - (ratio - DAMAGE_DEFLECT_TIME) / DAMAGE_RETURN_TIME;
+ if (ratio > 0) {
angles[PITCH] += ratio * cg.v_dmg_pitch;
angles[ROLL] += ratio * cg.v_dmg_roll;
}
@@ -1148,12 +1001,12 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
#endif
// add angles based on velocity
- VectorCopy( cg.predicted_player_state.velocity, predictedVelocity );
+ VectorCopy(cg.predicted_player_state.velocity, predictedVelocity);
- delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[0]);
+ delta = DotProduct(predictedVelocity, cg.refdef.viewaxis[0]);
angles[PITCH] += delta * cg_runpitch.value;
- delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[1]);
+ delta = DotProduct(predictedVelocity, cg.refdef.viewaxis[1]);
angles[ROLL] -= delta * cg_runroll.value;
// add angles based on bob
@@ -1163,42 +1016,35 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
delta = cg.bobfracsin * cg_bobpitch.value * speed;
if (cg.predicted_player_state.pm_flags & PMF_DUCKED)
- delta *= 3; // crouching
+ delta *= 3; // crouching
angles[PITCH] += delta;
delta = cg.bobfracsin * cg_bobroll.value * speed;
if (cg.predicted_player_state.pm_flags & PMF_DUCKED)
- delta *= 3; // crouching accentuates roll
+ delta *= 3; // crouching accentuates roll
if (cg.bobcycle & 1)
delta = -delta;
angles[ROLL] += delta;
-//===================================
+ //===================================
- if ( !firstPersonSaber )//First person saber
+ if (!firstPersonSaber) // First person saber
{
// add view height
- if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {
- if ( g_entities[cg.snap->ps.viewEntity].inuse &&
- g_entities[cg.snap->ps.viewEntity].client &&
- g_entities[cg.snap->ps.viewEntity].client->ps.viewheight )
- {
+ if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) {
+ if (g_entities[cg.snap->ps.viewEntity].inuse && g_entities[cg.snap->ps.viewEntity].client &&
+ g_entities[cg.snap->ps.viewEntity].client->ps.viewheight) {
origin[2] += g_entities[cg.snap->ps.viewEntity].client->ps.viewheight;
+ } else {
+ origin[2] += 4; //???
}
- else
- {
- origin[2] += 4;//???
- }
- }
- else
- {
+ } else {
origin[2] += cg.predicted_player_state.viewheight;
}
}
// smooth out duck height changes
timeDelta = cg.time - cg.duckTime;
- if ( timeDelta < DUCK_TIME) {
+ if (timeDelta < DUCK_TIME) {
cg.refdef.vieworg[2] -= cg.duckChange * (DUCK_TIME - timeDelta) / DUCK_TIME;
}
@@ -1210,27 +1056,25 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
origin[2] += bob;
-
// add fall height
delta = cg.time - cg.landTime;
- if ( delta < LAND_DEFLECT_TIME ) {
+ if (delta < LAND_DEFLECT_TIME) {
f = delta / LAND_DEFLECT_TIME;
cg.refdef.vieworg[2] += cg.landChange * f;
- } else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) {
+ } else if (delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME) {
delta -= LAND_DEFLECT_TIME;
- f = 1.0 - ( delta / LAND_RETURN_TIME );
+ f = 1.0 - (delta / LAND_RETURN_TIME);
cg.refdef.vieworg[2] += cg.landChange * f;
}
// add step offset
CG_StepOffset();
- if(cg.snap->ps.leanofs != 0)
- {
- vec3_t right;
- //add leaning offset
- //FIXME: when crouching, this bounces up and down?!
- cg.refdefViewAngles[2] += (float)cg.snap->ps.leanofs/2;
+ if (cg.snap->ps.leanofs != 0) {
+ vec3_t right;
+ // add leaning offset
+ // FIXME: when crouching, this bounces up and down?!
+ cg.refdefViewAngles[2] += (float)cg.snap->ps.leanofs / 2;
AngleVectors(cg.refdefViewAngles, NULL, right, NULL);
VectorMA(cg.refdef.vieworg, (float)cg.snap->ps.leanofs, right, cg.refdef.vieworg);
}
@@ -1238,7 +1082,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
// pivot the eye based on a neck length
#if 0
{
-#define NECK_LENGTH 8
+#define NECK_LENGTH 8
vec3_t forward, up;
cg.refdef.vieworg[2] -= NECK_LENGTH;
@@ -1249,7 +1093,6 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) {
#endif
}
-
/*
====================
CG_CalcFovFromX
@@ -1257,24 +1100,23 @@ CG_CalcFovFromX
Calcs Y FOV from given X FOV
====================
*/
-qboolean CG_CalcFOVFromX( float fov_x )
-{
- float x;
- float fov_y;
- qboolean inwater;
+qboolean CG_CalcFOVFromX(float fov_x) {
+ float x;
+ float fov_y;
+ qboolean inwater;
- if ( cg_fovAspectAdjust.integer ) {
+ if (cg_fovAspectAdjust.integer) {
// Based on LordHavoc's code for Darkplaces
// http://www.quakeworld.nu/forum/topic/53/what-does-your-qw-look-like/page/30
const float baseAspect = 0.75f; // 3/4
- const float aspect = (float)cgs.glconfig.vidWidth/(float)cgs.glconfig.vidHeight;
+ const float aspect = (float)cgs.glconfig.vidWidth / (float)cgs.glconfig.vidHeight;
const float desiredFov = fov_x;
- fov_x = atan( tan( desiredFov*M_PI / 360.0f ) * baseAspect*aspect )*360.0f / M_PI;
+ fov_x = atan(tan(desiredFov * M_PI / 360.0f) * baseAspect * aspect) * 360.0f / M_PI;
}
- x = cg.refdef.width / tan( fov_x / 360 * M_PI );
- fov_y = atan2( cg.refdef.height, x );
+ x = cg.refdef.width / tan(fov_x / 360 * M_PI);
+ fov_y = atan2(cg.refdef.height, x);
fov_y = fov_y * 360 / M_PI;
// there's a problem with this, it only takes the leafbrushes into account, not the entity brushes,
@@ -1282,33 +1124,28 @@ qboolean CG_CalcFOVFromX( float fov_x )
// level up/down this doesn't take into account the door position, so warps the view the whole time
// whether the water is up or not.
// warp if underwater
- float phase;
- float v;
+ float phase;
+ float v;
cg.refdef.viewContents = 0;
- if (gi.totalMapContents() & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ))
- {
- cg.refdef.viewContents = CG_PointContents( cg.refdef.vieworg, -1 );
+ if (gi.totalMapContents() & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA)) {
+ cg.refdef.viewContents = CG_PointContents(cg.refdef.vieworg, -1);
}
- if ( cg.refdef.viewContents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
- {
+ if (cg.refdef.viewContents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA)) {
phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
- v = WAVE_AMPLITUDE * sin( phase );
+ v = WAVE_AMPLITUDE * sin(phase);
fov_x += v;
fov_y -= v;
inwater = qtrue;
- }
- else
- {
+ } else {
inwater = qfalse;
}
// see if we are drugged by an interrogator. We muck with the FOV here, a bit later, after viewangles are calc'ed, I muck with those too.
- if ( cg.wonkyTime > 0 && cg.wonkyTime > cg.time )
- {
+ if (cg.wonkyTime > 0 && cg.wonkyTime > cg.time) {
float perc = (float)(cg.wonkyTime - cg.time) / 10000.0f; // goes for 10 seconds
- fov_x += ( 25.0f * perc );
- fov_y -= ( cos( cg.time * 0.0008f ) * 5.0f * perc );
+ fov_x += (25.0f * perc);
+ fov_y -= (cos(cg.time * 0.0008f) * 5.0f * perc);
}
// set it
@@ -1318,23 +1155,17 @@ qboolean CG_CalcFOVFromX( float fov_x )
return (inwater);
}
-float CG_ForceSpeedFOV( void )
-{
+float CG_ForceSpeedFOV(void) {
float fov;
float timeLeft = player->client->ps.forcePowerDuration[FP_SPEED] - cg.time;
- float length = FORCE_SPEED_DURATION*forceSpeedValue[player->client->ps.forcePowerLevel[FP_SPEED]];
+ float length = FORCE_SPEED_DURATION * forceSpeedValue[player->client->ps.forcePowerLevel[FP_SPEED]];
float amt = forceSpeedFOVMod[player->client->ps.forcePowerLevel[FP_SPEED]];
- if ( timeLeft < 500 )
- {//start going back
- fov = cg_fov.value + (timeLeft)/500*amt;
- }
- else if ( length - timeLeft < 1000 )
- {//start zooming in
- fov = cg_fov.value + (length - timeLeft)/1000*amt;
- }
- else
- {//stay at this FOV
- fov = cg_fov.value+amt;
+ if (timeLeft < 500) { // start going back
+ fov = cg_fov.value + (timeLeft) / 500 * amt;
+ } else if (length - timeLeft < 1000) { // start zooming in
+ fov = cg_fov.value + (length - timeLeft) / 1000 * amt;
+ } else { // stay at this FOV
+ fov = cg_fov.value + amt;
}
return fov;
}
@@ -1345,110 +1176,81 @@ CG_CalcFov
Fixed fov at intermissions, otherwise account for fov variable and zooms.
====================
*/
-static qboolean CG_CalcFov( void ) {
- float fov_x;
- float f;
+static qboolean CG_CalcFov(void) {
+ float fov_x;
+ float f;
- if ( cg.predicted_player_state.pm_type == PM_INTERMISSION ) {
+ if (cg.predicted_player_state.pm_type == PM_INTERMISSION) {
// if in intermission, use a fixed value
fov_x = 80;
- }
- else if ( cg.snap
- && cg.snap->ps.viewEntity > 0
- && cg.snap->ps.viewEntity < ENTITYNUM_WORLD
- && (!cg.renderingThirdPerson || g_entities[cg.snap->ps.viewEntity].e_DieFunc == dieF_camera_die) )
- {
+ } else if (cg.snap && cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD &&
+ (!cg.renderingThirdPerson || g_entities[cg.snap->ps.viewEntity].e_DieFunc == dieF_camera_die)) {
// if in entity camera view, use a special FOV
- if ( g_entities[cg.snap->ps.viewEntity].inuse &&
- g_entities[cg.snap->ps.viewEntity].NPC )
- {//FIXME: looks bad when take over a jedi... but never really do that, do we?
+ if (g_entities[cg.snap->ps.viewEntity].inuse &&
+ g_entities[cg.snap->ps.viewEntity].NPC) { // FIXME: looks bad when take over a jedi... but never really do that, do we?
fov_x = g_entities[cg.snap->ps.viewEntity].NPC->stats.hfov;
- //sanity-cap?
- if ( fov_x > 120 )
- {
+ // sanity-cap?
+ if (fov_x > 120) {
fov_x = 120;
- }
- else if ( fov_x < 10 )
- {
+ } else if (fov_x < 10) {
fov_x = 10;
}
- }
- else
- {
- if ( cg.overrides.active & CG_OVERRIDE_FOV )
- {
+ } else {
+ if (cg.overrides.active & CG_OVERRIDE_FOV) {
fov_x = cg.overrides.fov;
- }
- else
- {
- fov_x = 120;//FIXME: read from the NPC's fov stats?
+ } else {
+ fov_x = 120; // FIXME: read from the NPC's fov stats?
}
}
- }
- else if ( (!cg.zoomMode || cg.zoomMode > 2) && (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )//cg.renderingThirdPerson &&
+ } else if ((!cg.zoomMode || cg.zoomMode > 2) && (cg.snap->ps.forcePowersActive & (1 << FP_SPEED)) &&
+ player->client->ps.forcePowerDuration[FP_SPEED]) // cg.renderingThirdPerson &&
{
fov_x = CG_ForceSpeedFOV();
} else {
// user selectable
- if ( cg.overrides.active & CG_OVERRIDE_FOV )
- {
+ if (cg.overrides.active & CG_OVERRIDE_FOV) {
fov_x = cg.overrides.fov;
- }
- else
- {
+ } else {
fov_x = cg_fov.value;
}
- if ( fov_x < 1 ) {
+ if (fov_x < 1) {
fov_x = 1;
- } else if ( fov_x > 160 ) {
+ } else if (fov_x > 160) {
fov_x = 160;
}
// Disable zooming when in third person
- if ( cg.zoomMode && cg.zoomMode < 3 )//&& !cg.renderingThirdPerson ) // light amp goggles do none of the zoom silliness
+ if (cg.zoomMode && cg.zoomMode < 3) //&& !cg.renderingThirdPerson ) // light amp goggles do none of the zoom silliness
{
- if ( !cg.zoomLocked )
- {
- if ( cg.zoomMode == 1 )
- {
+ if (!cg.zoomLocked) {
+ if (cg.zoomMode == 1) {
// binoculars zooming either in or out
cg_zoomFov += cg.zoomDir * cg.frametime * 0.05f;
- }
- else
- {
+ } else {
// disruptor zooming in faster
cg_zoomFov -= cg.frametime * 0.075f;
}
// Clamp zoomFov
- float actualFOV = (cg.overrides.active&CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
- if ( cg_zoomFov < MAX_ZOOM_FOV )
- {
+ float actualFOV = (cg.overrides.active & CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
+ if (cg_zoomFov < MAX_ZOOM_FOV) {
cg_zoomFov = MAX_ZOOM_FOV;
- }
- else if ( cg_zoomFov > actualFOV )
- {
+ } else if (cg_zoomFov > actualFOV) {
cg_zoomFov = actualFOV;
- }
- else
- {//still zooming
+ } else { // still zooming
static int zoomSoundTime = 0;
- if ( zoomSoundTime < cg.time )
- {
+ if (zoomSoundTime < cg.time) {
sfxHandle_t snd;
- if ( cg.zoomMode == 1 )
- {
+ if (cg.zoomMode == 1) {
snd = cgs.media.zoomLoop;
- }
- else
- {
+ } else {
snd = cgs.media.disruptorZoomLoop;
}
// huh? This could probably just be added as a looping sound??
- cgi_S_StartSound( cg.refdef.vieworg, ENTITYNUM_WORLD, CHAN_LOCAL, snd );
+ cgi_S_StartSound(cg.refdef.vieworg, ENTITYNUM_WORLD, CHAN_LOCAL, snd);
zoomSoundTime = cg.time + 150;
}
}
@@ -1456,57 +1258,54 @@ static qboolean CG_CalcFov( void ) {
fov_x = cg_zoomFov;
} else {
- f = ( cg.time - cg.zoomTime ) / ZOOM_OUT_TIME;
- if ( f <= 1.0 ) {
- fov_x = cg_zoomFov + f * ( fov_x - cg_zoomFov );
+ f = (cg.time - cg.zoomTime) / ZOOM_OUT_TIME;
+ if (f <= 1.0) {
+ fov_x = cg_zoomFov + f * (fov_x - cg_zoomFov);
}
}
}
-// g_fov = fov_x;
- return ( CG_CalcFOVFromX( fov_x ) );
+ // g_fov = fov_x;
+ return (CG_CalcFOVFromX(fov_x));
}
-
-
/*
===============
CG_DamageBlendBlob
===============
*/
-static void CG_DamageBlendBlob( void )
-{
- int t;
- int maxTime;
- refEntity_t ent;
+static void CG_DamageBlendBlob(void) {
+ int t;
+ int maxTime;
+ refEntity_t ent;
- if ( !cg.damageValue ) {
+ if (!cg.damageValue) {
return;
}
maxTime = DAMAGE_TIME;
t = cg.time - cg.damageTime;
- if ( t <= 0 || t >= maxTime ) {
+ if (t <= 0 || t >= maxTime) {
return;
}
- memset( &ent, 0, sizeof( ent ) );
+ memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
ent.renderfx = RF_FIRST_PERSON;
- VectorMA( cg.refdef.vieworg, 8, cg.refdef.viewaxis[0], ent.origin );
- VectorMA( ent.origin, cg.damageX * -8, cg.refdef.viewaxis[1], ent.origin );
- VectorMA( ent.origin, cg.damageY * 8, cg.refdef.viewaxis[2], ent.origin );
+ VectorMA(cg.refdef.vieworg, 8, cg.refdef.viewaxis[0], ent.origin);
+ VectorMA(ent.origin, cg.damageX * -8, cg.refdef.viewaxis[1], ent.origin);
+ VectorMA(ent.origin, cg.damageY * 8, cg.refdef.viewaxis[2], ent.origin);
- ent.radius = cg.damageValue * 3 * ( 1.0 - ((float)t / maxTime) );
+ ent.radius = cg.damageValue * 3 * (1.0 - ((float)t / maxTime));
ent.customShader = cgs.media.damageBlendBlobShader;
- ent.shaderRGBA[0] = 180 * ( 1.0 - ((float)t / maxTime) );
- ent.shaderRGBA[1] = 50 * ( 1.0 - ((float)t / maxTime) );
- ent.shaderRGBA[2] = 50 * ( 1.0 - ((float)t / maxTime) );
+ ent.shaderRGBA[0] = 180 * (1.0 - ((float)t / maxTime));
+ ent.shaderRGBA[1] = 50 * (1.0 - ((float)t / maxTime));
+ ent.shaderRGBA[2] = 50 * (1.0 - ((float)t / maxTime));
ent.shaderRGBA[3] = 255;
- cgi_R_AddRefEntityToScene( &ent );
+ cgi_R_AddRefEntityToScene(&ent);
}
/*
@@ -1517,56 +1316,49 @@ CG_SaberClashFlare
extern int g_saberFlashTime;
extern vec3_t g_saberFlashPos;
extern qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y);
-void CG_SaberClashFlare( void )
-{
- int t, maxTime = 150;
+void CG_SaberClashFlare(void) {
+ int t, maxTime = 150;
t = cg.time - g_saberFlashTime;
- if ( t <= 0 || t >= maxTime )
- {
+ if (t <= 0 || t >= maxTime) {
return;
}
vec3_t dif;
// Don't do clashes for things that are behind us
- VectorSubtract( g_saberFlashPos, cg.refdef.vieworg, dif );
+ VectorSubtract(g_saberFlashPos, cg.refdef.vieworg, dif);
- if ( DotProduct( dif, cg.refdef.viewaxis[0] ) < 0.2 )
- {
+ if (DotProduct(dif, cg.refdef.viewaxis[0]) < 0.2) {
return;
}
trace_t tr;
- CG_Trace( &tr, cg.refdef.vieworg, NULL, NULL, g_saberFlashPos, -1, CONTENTS_SOLID );
+ CG_Trace(&tr, cg.refdef.vieworg, NULL, NULL, g_saberFlashPos, -1, CONTENTS_SOLID);
- if ( tr.fraction < 1.0f )
- {
+ if (tr.fraction < 1.0f) {
return;
}
vec3_t color;
- int x,y;
- float v, len = VectorNormalize( dif );
+ int x, y;
+ float v, len = VectorNormalize(dif);
// clamp to a known range
- if ( len > 800 )
- {
+ if (len > 800) {
len = 800;
}
- v = ( 1.0f - ((float)t / maxTime )) * ((1.0f - ( len / 800.0f )) * 2.0f + 0.35f);
+ v = (1.0f - ((float)t / maxTime)) * ((1.0f - (len / 800.0f)) * 2.0f + 0.35f);
- CG_WorldCoordToScreenCoord( g_saberFlashPos, &x, &y );
+ CG_WorldCoordToScreenCoord(g_saberFlashPos, &x, &y);
- VectorSet( color, 0.8f, 0.8f, 0.8f );
- cgi_R_SetColor( color );
+ VectorSet(color, 0.8f, 0.8f, 0.8f);
+ cgi_R_SetColor(color);
- CG_DrawPic( x - ( v * 300 ), y - ( v * 300 ),
- v * 600, v * 600,
- cgi_R_RegisterShader( "gfx/effects/saberFlare" ));
+ CG_DrawPic(x - (v * 300), y - (v * 300), v * 600, v * 600, cgi_R_RegisterShader("gfx/effects/saberFlare"));
}
/*
@@ -1576,54 +1368,45 @@ CG_CalcViewValues
Sets cg.refdef view values
===============
*/
-static qboolean CG_CalcViewValues( void ) {
- playerState_t *ps;
- //qboolean viewEntIsHumanoid = qfalse;
- qboolean viewEntIsCam = qfalse;
+static qboolean CG_CalcViewValues(void) {
+ playerState_t *ps;
+ // qboolean viewEntIsHumanoid = qfalse;
+ qboolean viewEntIsCam = qfalse;
- memset( &cg.refdef, 0, sizeof( cg.refdef ) );
+ memset(&cg.refdef, 0, sizeof(cg.refdef));
// calculate size of 3D view
CG_CalcVrect();
- if( cg.snap->ps.viewEntity != 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD &&
- g_entities[cg.snap->ps.viewEntity].client)
- {
+ if (cg.snap->ps.viewEntity != 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD && g_entities[cg.snap->ps.viewEntity].client) {
ps = &g_entities[cg.snap->ps.viewEntity].client->ps;
- //viewEntIsHumanoid = qtrue;
- }
- else
- {
+ // viewEntIsHumanoid = qtrue;
+ } else {
ps = &cg.predicted_player_state;
}
#ifndef FINAL_BUILD
- trap_Com_SetOrgAngles(ps->origin,ps->viewangles);
+ trap_Com_SetOrgAngles(ps->origin, ps->viewangles);
#endif
// intermission view
- if ( ps->pm_type == PM_INTERMISSION ) {
- VectorCopy( ps->origin, cg.refdef.vieworg );
- VectorCopy( ps->viewangles, cg.refdefViewAngles );
- AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
+ if (ps->pm_type == PM_INTERMISSION) {
+ VectorCopy(ps->origin, cg.refdef.vieworg);
+ VectorCopy(ps->viewangles, cg.refdefViewAngles);
+ AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
return CG_CalcFov();
}
- cg.bobcycle = ( ps->bobCycle & 128 ) >> 7;
- cg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) );
- cg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] +
- ps->velocity[1] * ps->velocity[1] );
+ cg.bobcycle = (ps->bobCycle & 128) >> 7;
+ cg.bobfracsin = fabs(sin((ps->bobCycle & 127) / 127.0 * M_PI));
+ cg.xyspeed = sqrt(ps->velocity[0] * ps->velocity[0] + ps->velocity[1] * ps->velocity[1]);
- if ( G_IsRidingVehicle( &g_entities[0] ) )
- {
- VectorCopy( ps->origin, cg.refdef.vieworg );
- VectorCopy( cg_entities[g_entities[0].owner->s.number].lerpAngles, cg.refdefViewAngles );
- if ( !(ps->eFlags&EF_NODRAW) )
- {//riding it, not *inside* it
- //let us look up & down
+ if (G_IsRidingVehicle(&g_entities[0])) {
+ VectorCopy(ps->origin, cg.refdef.vieworg);
+ VectorCopy(cg_entities[g_entities[0].owner->s.number].lerpAngles, cg.refdefViewAngles);
+ if (!(ps->eFlags & EF_NODRAW)) { // riding it, not *inside* it
+ // let us look up & down
cg.refdefViewAngles[PITCH] = cg_entities[ps->clientNum].lerpAngles[PITCH] * 0.2f;
}
- }
- else if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {//in an entity camera view
+ } else if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) { // in an entity camera view
/*
if ( g_entities[cg.snap->ps.viewEntity].client && cg.renderingThirdPerson )
{
@@ -1631,100 +1414,80 @@ static qboolean CG_CalcViewValues( void ) {
}
else
*/
- {
- VectorCopy( cg_entities[cg.snap->ps.viewEntity].lerpOrigin, cg.refdef.vieworg );
- }
- VectorCopy( cg_entities[cg.snap->ps.viewEntity].lerpAngles, cg.refdefViewAngles );
- if ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname ) || g_entities[cg.snap->ps.viewEntity].s.weapon == WP_TURRET )
- {
+ { VectorCopy(cg_entities[cg.snap->ps.viewEntity].lerpOrigin, cg.refdef.vieworg); }
+ VectorCopy(cg_entities[cg.snap->ps.viewEntity].lerpAngles, cg.refdefViewAngles);
+ if (!Q_stricmp("misc_camera", g_entities[cg.snap->ps.viewEntity].classname) || g_entities[cg.snap->ps.viewEntity].s.weapon == WP_TURRET) {
viewEntIsCam = qtrue;
}
- }
- else if ( cg.renderingThirdPerson && !cg.zoomMode && (cg.overrides.active&CG_OVERRIDE_3RD_PERSON_ENT) )
- {//different center, same angle
- VectorCopy( cg_entities[cg.overrides.thirdPersonEntity].lerpOrigin, cg.refdef.vieworg );
- VectorCopy( ps->viewangles, cg.refdefViewAngles );
- }
- else
- {//player's center and angles
- VectorCopy( ps->origin, cg.refdef.vieworg );
- VectorCopy( ps->viewangles, cg.refdefViewAngles );
+ } else if (cg.renderingThirdPerson && !cg.zoomMode && (cg.overrides.active & CG_OVERRIDE_3RD_PERSON_ENT)) { // different center, same angle
+ VectorCopy(cg_entities[cg.overrides.thirdPersonEntity].lerpOrigin, cg.refdef.vieworg);
+ VectorCopy(ps->viewangles, cg.refdefViewAngles);
+ } else { // player's center and angles
+ VectorCopy(ps->origin, cg.refdef.vieworg);
+ VectorCopy(ps->viewangles, cg.refdefViewAngles);
}
// add error decay
- if ( cg_errorDecay.value > 0 ) {
- int t;
- float f;
+ if (cg_errorDecay.value > 0) {
+ int t;
+ float f;
t = cg.time - cg.predictedErrorTime;
- f = ( cg_errorDecay.value - t ) / cg_errorDecay.value;
- if ( f > 0 && f < 1 ) {
- VectorMA( cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg );
+ f = (cg_errorDecay.value - t) / cg_errorDecay.value;
+ if (f > 0 && f < 1) {
+ VectorMA(cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg);
} else {
cg.predictedErrorTime = 0;
}
}
- if ( (cg.renderingThirdPerson||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE)
- && !cg.zoomMode
- && !viewEntIsCam )
- {
+ if ((cg.renderingThirdPerson || cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE) && !cg.zoomMode && !viewEntIsCam) {
// back away from character
-// if ( cg_thirdPerson.integer == CG_CAM_ABOVE)
-// { `
-// CG_OffsetThirdPersonOverheadView();
-// }
-// else
-// {
+ // if ( cg_thirdPerson.integer == CG_CAM_ABOVE)
+ // { `
+ // CG_OffsetThirdPersonOverheadView();
+ // }
+ // else
+ // {
// First person saber
- if ( !cg.renderingThirdPerson )
- {
- if ( cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE )
- {
+ if (!cg.renderingThirdPerson) {
+ if (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE) {
vec3_t dir;
- CG_OffsetFirstPersonView( qtrue );
+ CG_OffsetFirstPersonView(qtrue);
cg.refdef.vieworg[2] += 32;
- AngleVectors( cg.refdefViewAngles, dir, NULL, NULL );
- VectorMA( cg.refdef.vieworg, -2, dir, cg.refdef.vieworg );
+ AngleVectors(cg.refdefViewAngles, dir, NULL, NULL);
+ VectorMA(cg.refdef.vieworg, -2, dir, cg.refdef.vieworg);
}
}
CG_OffsetThirdPersonView();
-// }
- }
- else
- {
+ // }
+ } else {
// offset for local bobbing and kicks
- CG_OffsetFirstPersonView( qfalse );
- centity_t *playerCent = &cg_entities[0];
- if ( playerCent && playerCent->gent && playerCent->gent->client )
- {
- VectorCopy( cg.refdef.vieworg, playerCent->gent->client->renderInfo.eyePoint );
- VectorCopy( cg.refdefViewAngles, playerCent->gent->client->renderInfo.eyeAngles );
- if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {//in an entity camera view
- if ( cg_entities[cg.snap->ps.viewEntity].gent->client )
- {//looking through a client's eyes
- VectorCopy( cg.refdef.vieworg, cg_entities[cg.snap->ps.viewEntity].gent->client->renderInfo.eyePoint );
- VectorCopy( cg.refdefViewAngles, cg_entities[cg.snap->ps.viewEntity].gent->client->renderInfo.eyeAngles );
- }
- else
- {//looking through a regular ent's eyes
- VectorCopy( cg.refdef.vieworg, cg_entities[cg.snap->ps.viewEntity].lerpOrigin );
- VectorCopy( cg.refdefViewAngles, cg_entities[cg.snap->ps.viewEntity].lerpAngles );
+ CG_OffsetFirstPersonView(qfalse);
+ centity_t *playerCent = &cg_entities[0];
+ if (playerCent && playerCent->gent && playerCent->gent->client) {
+ VectorCopy(cg.refdef.vieworg, playerCent->gent->client->renderInfo.eyePoint);
+ VectorCopy(cg.refdefViewAngles, playerCent->gent->client->renderInfo.eyeAngles);
+ if (cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) { // in an entity camera view
+ if (cg_entities[cg.snap->ps.viewEntity].gent->client) { // looking through a client's eyes
+ VectorCopy(cg.refdef.vieworg, cg_entities[cg.snap->ps.viewEntity].gent->client->renderInfo.eyePoint);
+ VectorCopy(cg.refdefViewAngles, cg_entities[cg.snap->ps.viewEntity].gent->client->renderInfo.eyeAngles);
+ } else { // looking through a regular ent's eyes
+ VectorCopy(cg.refdef.vieworg, cg_entities[cg.snap->ps.viewEntity].lerpOrigin);
+ VectorCopy(cg.refdefViewAngles, cg_entities[cg.snap->ps.viewEntity].lerpAngles);
}
}
- VectorCopy( playerCent->gent->client->renderInfo.eyePoint, playerCent->gent->client->renderInfo.headPoint );
- if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD )
- {//not in entity cam
+ VectorCopy(playerCent->gent->client->renderInfo.eyePoint, playerCent->gent->client->renderInfo.headPoint);
+ if (cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD) { // not in entity cam
playerCent->gent->client->renderInfo.headPoint[2] -= 8;
}
}
}
- //VectorCopy( cg.refdef.vieworg, cgRefdefVieworg );
- // shake the camera if necessary
- CGCam_UpdateSmooth( cg.refdef.vieworg, cg.refdefViewAngles );
- CGCam_UpdateShake( cg.refdef.vieworg, cg.refdefViewAngles );
+ // VectorCopy( cg.refdef.vieworg, cgRefdefVieworg );
+ // shake the camera if necessary
+ CGCam_UpdateSmooth(cg.refdef.vieworg, cg.refdefViewAngles);
+ CGCam_UpdateShake(cg.refdef.vieworg, cg.refdefViewAngles);
/*
if ( in_camera )
@@ -1734,18 +1497,16 @@ static qboolean CG_CalcViewValues( void ) {
*/
// see if we are drugged by an interrogator. We muck with the angles here, just a bit earlier, we mucked with the FOV
- if ( cg.wonkyTime > 0 && cg.wonkyTime > cg.time )
- {
+ if (cg.wonkyTime > 0 && cg.wonkyTime > cg.time) {
float perc = (float)(cg.wonkyTime - cg.time) / 10000.0f; // goes for 10 seconds
- cg.refdefViewAngles[ROLL] += ( sin( cg.time * 0.0004f ) * 7.0f * perc );
- cg.refdefViewAngles[PITCH] += ( 26.0f * perc + sin( cg.time * 0.0011f ) * 3.0f * perc );
+ cg.refdefViewAngles[ROLL] += (sin(cg.time * 0.0004f) * 7.0f * perc);
+ cg.refdefViewAngles[PITCH] += (26.0f * perc + sin(cg.time * 0.0011f) * 3.0f * perc);
}
- AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
+ AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
- if ( cg.hyperspace )
- {
+ if (cg.hyperspace) {
cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE;
}
@@ -1753,30 +1514,26 @@ static qboolean CG_CalcViewValues( void ) {
return CG_CalcFov();
}
-
/*
=====================
CG_PowerupTimerSounds
=====================
*/
-static void CG_PowerupTimerSounds( void )
-{
- int i, time;
+static void CG_PowerupTimerSounds(void) {
+ int i, time;
// powerup timers going away
- for ( i = 0 ; i < MAX_POWERUPS ; i++ )
- {
+ for (i = 0; i < MAX_POWERUPS; i++) {
time = cg.snap->ps.powerups[i];
- if ( time > 0 && time < cg.time )
- {
+ if (time > 0 && time < cg.time) {
// add any special powerup expiration sounds here
-// switch( i )
-// {
-// case PW_WEAPON_OVERCHARGE:
-// cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_ITEM, cgs.media.overchargeEndSound );
-// break;
-// }
+ // switch( i )
+ // {
+ // case PW_WEAPON_OVERCHARGE:
+ // cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_ITEM, cgs.media.overchargeEndSound );
+ // break;
+ // }
}
}
}
@@ -1786,18 +1543,16 @@ static void CG_PowerupTimerSounds( void )
CG_DrawSkyBoxPortal
==============
*/
-extern void cgi_CM_SnapPVS(vec3_t origin,byte *buffer);
+extern void cgi_CM_SnapPVS(vec3_t origin, byte *buffer);
-static void CG_DrawSkyBoxPortal(void)
-{
+static void CG_DrawSkyBoxPortal(void) {
refdef_t backuprefdef;
const char *cstr;
char *token;
cstr = CG_ConfigString(CS_SKYBOXORG);
- if (!cstr || !strlen(cstr))
- {
+ if (!cstr || !strlen(cstr)) {
// no skybox in this map
return;
}
@@ -1807,171 +1562,157 @@ static void CG_DrawSkyBoxPortal(void)
// asdf --eez
COM_BeginParseSession();
token = COM_ParseExt(&cstr, qfalse);
- if (!token || !token[0])
- {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n");
+ if (!token || !token[0]) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring\n");
}
cg.refdef.vieworg[0] = atof(token);
token = COM_ParseExt(&cstr, qfalse);
- if (!token || !token[0])
- {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n");
+ if (!token || !token[0]) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring\n");
}
cg.refdef.vieworg[1] = atof(token);
token = COM_ParseExt(&cstr, qfalse);
- if (!token || !token[0])
- {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n");
+ if (!token || !token[0]) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring\n");
}
cg.refdef.vieworg[2] = atof(token);
// setup fog the first time, ignore this part of the configstring after that
token = COM_ParseExt(&cstr, qfalse);
- if (!token || !token[0])
- {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog state\n");
- }
- else
- {
- if ( atoi( token ) ) {
+ if (!token || !token[0]) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog state\n");
+ } else {
+ if (atoi(token)) {
// this camera has fog
- token = COM_ParseExt( &cstr, qfalse );
- if ( !VALIDSTRING( token ) ) {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[0]\n");
+ token = COM_ParseExt(&cstr, qfalse);
+ if (!VALIDSTRING(token)) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[0]\n");
}
token = COM_ParseExt(&cstr, qfalse);
- if ( !VALIDSTRING( token ) ) {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[1]\n");
+ if (!VALIDSTRING(token)) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[1]\n");
}
token = COM_ParseExt(&cstr, qfalse);
- if ( !VALIDSTRING( token ) ) {
- CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[2]\n");
+ if (!VALIDSTRING(token)) {
+ CG_Error("CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[2]\n");
}
- COM_ParseExt( &cstr, qfalse );
- COM_ParseExt( &cstr, qfalse );
+ COM_ParseExt(&cstr, qfalse);
+ COM_ParseExt(&cstr, qfalse);
}
}
COM_EndParseSession();
-/*
- static float lastfov = cg_zoomFov; // for transitions back from zoomed in modes
- float fov_x;
- float fov_y;
- float x;
- float f = 0;
+ /*
+ static float lastfov = cg_zoomFov; // for transitions back from zoomed in modes
+ float fov_x;
+ float fov_y;
+ float x;
+ float f = 0;
- if ( cg.predicted_player_state.pm_type == PM_INTERMISSION )
- {
- // if in intermission, use a fixed value
- fov_x = (cg.overrides.active&CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
- }
- else
- {
- if (cg.zoomMode)
+ if ( cg.predicted_player_state.pm_type == PM_INTERMISSION )
{
- fov_x = cg_zoomFov;
+ // if in intermission, use a fixed value
+ fov_x = (cg.overrides.active&CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
}
else
{
- fov_x = (cg.overrides.active&CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
- if ( fov_x < 1 )
+ if (cg.zoomMode)
{
- fov_x = 1;
+ fov_x = cg_zoomFov;
}
- else if ( fov_x > 160 )
+ else
{
- fov_x = 160;
+ fov_x = (cg.overrides.active&CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
+ if ( fov_x < 1 )
+ {
+ fov_x = 1;
+ }
+ else if ( fov_x > 160 )
+ {
+ fov_x = 160;
+ }
}
- }
- // do smooth transitions for zooming
- if (cg.zoomMode)
- { //zoomed/zooming in
- f = ( cg.time - cg.zoomTime ) / (float)ZOOM_OUT_TIME;
- if ( f > 1.0 ) {
- fov_x = cg_zoomFov;
- } else {
- fov_x = fov_x + f * ( cg_zoomFov - fov_x );
+ // do smooth transitions for zooming
+ if (cg.zoomMode)
+ { //zoomed/zooming in
+ f = ( cg.time - cg.zoomTime ) / (float)ZOOM_OUT_TIME;
+ if ( f > 1.0 ) {
+ fov_x = cg_zoomFov;
+ } else {
+ fov_x = fov_x + f * ( cg_zoomFov - fov_x );
+ }
+ lastfov = fov_x;
}
- lastfov = fov_x;
- }
- else
- { //zooming out
- f = ( cg.time - cg.zoomTime ) / (float)ZOOM_OUT_TIME;
- if ( f > 1.0 ) {
- fov_x = fov_x;
- } else {
- fov_x = cg_zoomFov + f * ( fov_x - cg_zoomFov);
+ else
+ { //zooming out
+ f = ( cg.time - cg.zoomTime ) / (float)ZOOM_OUT_TIME;
+ if ( f > 1.0 ) {
+ fov_x = fov_x;
+ } else {
+ fov_x = cg_zoomFov + f * ( fov_x - cg_zoomFov);
+ }
}
}
- }
- x = cg.refdef.width / tan( fov_x / 360 * M_PI );
- fov_y = atan2( cg.refdef.height, x );
- fov_y = fov_y * 360 / M_PI;
+ x = cg.refdef.width / tan( fov_x / 360 * M_PI );
+ fov_y = atan2( cg.refdef.height, x );
+ fov_y = fov_y * 360 / M_PI;
- cg.refdef.fov_x = fov_x;
- cg.refdef.fov_y = fov_y;
-*/
- //inherit fov and axis from whatever the player is doing (regular, camera overrides or zoomed, whatever)
- if ( !cg.hyperspace )
- {
- CG_AddPacketEntities(qtrue); //rww - There was no proper way to put real entities inside the portal view before.
- //This will put specially flagged entities in the render.
- //Add effects flagged to play only in portals
- theFxScheduler.AddScheduledEffects( true );
+ cg.refdef.fov_x = fov_x;
+ cg.refdef.fov_y = fov_y;
+ */
+ // inherit fov and axis from whatever the player is doing (regular, camera overrides or zoomed, whatever)
+ if (!cg.hyperspace) {
+ CG_AddPacketEntities(qtrue); // rww - There was no proper way to put real entities inside the portal view before.
+ // This will put specially flagged entities in the render.
+ // Add effects flagged to play only in portals
+ theFxScheduler.AddScheduledEffects(true);
}
- cg.refdef.rdflags |= RDF_SKYBOXPORTAL; //mark portal scene specialness
- cg.refdef.rdflags |= RDF_DRAWSKYBOX; //drawk portal skies
+ cg.refdef.rdflags |= RDF_SKYBOXPORTAL; // mark portal scene specialness
+ cg.refdef.rdflags |= RDF_DRAWSKYBOX; // drawk portal skies
- cgi_CM_SnapPVS( cg.refdef.vieworg, cg.refdef.areamask ); //fill in my areamask for this view origin
+ cgi_CM_SnapPVS(cg.refdef.vieworg, cg.refdef.areamask); // fill in my areamask for this view origin
// draw the skybox
- cgi_R_RenderScene( &cg.refdef );
+ cgi_R_RenderScene(&cg.refdef);
cg.refdef = backuprefdef;
}
//----------------------------
-void CG_RunEmplacedWeapon()
-{
- gentity_t *player = &g_entities[0],
- *gun = player->owner;
+void CG_RunEmplacedWeapon() {
+ gentity_t *player = &g_entities[0], *gun = player->owner;
// Override the camera when we are locked onto the gun.
- if ( player
- && gun
- && !gun->bounceCount//not an eweb
- && ( player->s.eFlags & EF_LOCKED_TO_WEAPON ))
- {
-// float dist = -1; // default distance behind gun
+ if (player && gun && !gun->bounceCount // not an eweb
+ && (player->s.eFlags & EF_LOCKED_TO_WEAPON)) {
+ // float dist = -1; // default distance behind gun
// don't let the player try and change this
cg.renderingThirdPerson = qtrue;
-// cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
-// cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
+ // cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
+ // cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
- AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
+ AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
// Slide in behind the gun.
-// if ( gun->delay + 500 > cg.time )
-// {
-// dist -= (( gun->delay + 500 ) - cg.time ) * 0.02f;
-// }
-
- VectorCopy( gun->pos2, cg.refdef.vieworg );
- VectorMA( cg.refdef.vieworg, -20.0f, gun->pos3, cg.refdef.vieworg );
- if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD )
- {
- VectorMA( cg.refdef.vieworg, 35.0f, gun->pos4, cg.refdef.vieworg );
+ // if ( gun->delay + 500 > cg.time )
+ // {
+ // dist -= (( gun->delay + 500 ) - cg.time ) * 0.02f;
+ // }
+
+ VectorCopy(gun->pos2, cg.refdef.vieworg);
+ VectorMA(cg.refdef.vieworg, -20.0f, gun->pos3, cg.refdef.vieworg);
+ if (cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD) {
+ VectorMA(cg.refdef.vieworg, 35.0f, gun->pos4, cg.refdef.vieworg);
}
-
}
}
@@ -1984,12 +1725,12 @@ CG_DrawActiveFrame
Generates and draws a game scene and status information at the given time.
=================
*/
-extern void CG_BuildSolidList( void );
-extern void CG_ClearHealthBarEnts( void );
-extern vec3_t serverViewOrg;
-static qboolean cg_rangedFogging = qfalse; //so we know if we should go back to normal fog
-void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
- qboolean inwater = qfalse;
+extern void CG_BuildSolidList(void);
+extern void CG_ClearHealthBarEnts(void);
+extern vec3_t serverViewOrg;
+static qboolean cg_rangedFogging = qfalse; // so we know if we should go back to normal fog
+void CG_DrawActiveFrame(int serverTime, stereoFrame_t stereoView) {
+ qboolean inwater = qfalse;
cg.time = serverTime;
@@ -1998,7 +1739,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
// if we are only updating the screen as a loading
// pacifier, don't even try to read snapshots
- if ( cg.infoScreenText[0] != 0 ) {
+ if (cg.infoScreenText[0] != 0) {
CG_DrawInformation();
return;
}
@@ -2020,61 +1761,55 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
CG_ProcessSnapshots();
// if we haven't received any snapshots yet, all
// we can draw is the information screen
- if ( !cg.snap ) {
- //CG_DrawInformation();
+ if (!cg.snap) {
+ // CG_DrawInformation();
return;
}
// make sure the lagometerSample and frame timing isn't done twice when in stereo
- if ( stereoView != STEREO_RIGHT ) {
+ if (stereoView != STEREO_RIGHT) {
cg.frametime = cg.time - cg.oldTime;
cg.oldTime = cg.time;
}
// Make sure the helper has the updated time
- theFxHelper.AdjustTime( cg.frametime );
+ theFxHelper.AdjustTime(cg.frametime);
// let the client system know what our weapon and zoom settings are
- //FIXME: should really send forcePowersActive over network onto cg.snap->ps...
+ // FIXME: should really send forcePowersActive over network onto cg.snap->ps...
const int fpActive = cg_entities[0].gent->client->ps.forcePowersActive;
const bool matrixMode = !!(fpActive & ((1 << FP_SPEED) | (1 << FP_RAGE)));
float speed = cg.refdef.fov_y / 75.0 * (matrixMode ? 1.0f : cg_timescale.value);
-//FIXME: junk code, BUG:168
+ // FIXME: junk code, BUG:168
- static bool wasForceSpeed=false;
- bool isForceSpeed=cg_entities[0].gent->client->ps.forcePowersActive&(1<client->ps.forcePowersActive & (1 << FP_SPEED) ? true : false;
+ if (isForceSpeed && !wasForceSpeed) {
+ CGCam_Smooth(0.75f, 5000);
}
- wasForceSpeed=isForceSpeed;
+ wasForceSpeed = isForceSpeed;
-//
+ //
float mPitchOverride = 0.0f;
float mYawOverride = 0.0f;
- if ( cg.snap->ps.clientNum == 0 && cg_scaleVehicleSensitivity.integer )
- {//pointless check, but..
- if ( cg_entities[0].gent->s.eFlags & EF_LOCKED_TO_WEAPON )
- {
+ if (cg.snap->ps.clientNum == 0 && cg_scaleVehicleSensitivity.integer) { // pointless check, but..
+ if (cg_entities[0].gent->s.eFlags & EF_LOCKED_TO_WEAPON) {
speed *= 0.25f;
}
Vehicle_t *pVeh = NULL;
// Mouse turns slower.
- if ( ( pVeh = G_IsRidingVehicle( &g_entities[0] ) ) != NULL )
- {
- if ( pVeh->m_pVehicleInfo->mousePitch )
- {
+ if ((pVeh = G_IsRidingVehicle(&g_entities[0])) != NULL) {
+ if (pVeh->m_pVehicleInfo->mousePitch) {
mPitchOverride = pVeh->m_pVehicleInfo->mousePitch;
}
- if ( pVeh->m_pVehicleInfo->mouseYaw )
- {
+ if (pVeh->m_pVehicleInfo->mouseYaw) {
mYawOverride = pVeh->m_pVehicleInfo->mouseYaw;
}
}
}
- cgi_SetUserCmdValue( cg.weaponSelect, speed, mPitchOverride, mYawOverride );
+ cgi_SetUserCmdValue(cg.weaponSelect, speed, mPitchOverride, mYawOverride);
// this counter will be bumped for every valid scene we generate
cg.clientFrame++;
@@ -2082,45 +1817,34 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
// update cg.predicted_player_state
CG_PredictPlayerState();
- if (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
- {
+ if (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE) {
cg.zoomMode = 0;
}
// decide on third person view
- cg.renderingThirdPerson = (qboolean)(
- cg_thirdPerson.integer
- || (cg.snap->ps.stats[STAT_HEALTH] <= 0)
- || (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
- || ((g_entities[0].client&&g_entities[0].client->NPC_class==CLASS_ATST)
- || (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE) ));
-
- if ( cg.zoomMode )
- {
+ cg.renderingThirdPerson = (qboolean)(cg_thirdPerson.integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0) || (cg.snap->ps.eFlags & EF_HELD_BY_SAND_CREATURE) ||
+ ((g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST) ||
+ (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)));
+
+ if (cg.zoomMode) {
// zoomed characters should never do third person stuff??
cg.renderingThirdPerson = qfalse;
}
- if ( in_camera )
- {
+ if (in_camera) {
// The camera takes over the view
CGCam_RenderScene();
- }
- else
- {
- //Finish any fading that was happening
+ } else {
+ // Finish any fading that was happening
CGCam_UpdateFade();
// build cg.refdef
inwater = CG_CalcViewValues();
}
- if (cg.zoomMode)
- { //zooming with binoculars or sniper, set the fog range based on the zoom level -rww
+ if (cg.zoomMode) { // zooming with binoculars or sniper, set the fog range based on the zoom level -rww
cg_rangedFogging = qtrue;
- //smaller the fov the less fog we have between the view and cull dist
- cgi_R_SetRangeFog(cg.refdef.fov_x*64.0f);
- }
- else if (cg_rangedFogging)
- { //disable it
+ // smaller the fov the less fog we have between the view and cull dist
+ cgi_R_SetRangeFog(cg.refdef.fov_x * 64.0f);
+ } else if (cg_rangedFogging) { // disable it
cg_rangedFogging = qfalse;
cgi_R_SetRangeFog(0.0f);
}
@@ -2133,41 +1857,35 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
CG_RunEmplacedWeapon();
// first person blend blobs, done after AnglesToAxis
- if ( !cg.renderingThirdPerson ) {
+ if (!cg.renderingThirdPerson) {
CG_DamageBlendBlob();
}
// build the render lists
- if ( !cg.hyperspace ) {
- CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct
+ if (!cg.hyperspace) {
+ CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct
CG_AddMarks();
CG_AddLocalEntities();
CG_DrawMiscEnts();
}
- //check for opaque water
- // this game does not have opaque water
- if ( 0 )
- {
- vec3_t camTest;
- VectorCopy( cg.refdef.vieworg, camTest );
+ // check for opaque water
+ // this game does not have opaque water
+ if (0) {
+ vec3_t camTest;
+ VectorCopy(cg.refdef.vieworg, camTest);
camTest[2] += 6;
- if ( !(CG_PointContents( camTest, 0 )&CONTENTS_SOLID) && !gi.inPVS( cg.refdef.vieworg, camTest ) )
- {//crossed visible line into another room
+ if (!(CG_PointContents(camTest, 0) & CONTENTS_SOLID) && !gi.inPVS(cg.refdef.vieworg, camTest)) { // crossed visible line into another room
cg.refdef.vieworg[2] -= 6;
- //cgi_CM_SnapPVS(cg.refdef.vieworg,cg.snap->areamask);
- }
- else
- {
- VectorCopy( cg.refdef.vieworg, camTest );
+ // cgi_CM_SnapPVS(cg.refdef.vieworg,cg.snap->areamask);
+ } else {
+ VectorCopy(cg.refdef.vieworg, camTest);
camTest[2] -= 6;
- if ( !(CG_PointContents( camTest, 0 )&CONTENTS_SOLID) && !gi.inPVS( cg.refdef.vieworg, camTest ) )
- {
+ if (!(CG_PointContents(camTest, 0) & CONTENTS_SOLID) && !gi.inPVS(cg.refdef.vieworg, camTest)) {
cg.refdef.vieworg[2] += 6;
- //cgi_CM_SnapPVS(cg.refdef.vieworg,cg.snap->areamask);
- }
- else //if ( inwater )
- {//extra-special hack... sometimes when crouched in water with first person lightsaber, your PVS is wrong???
+ // cgi_CM_SnapPVS(cg.refdef.vieworg,cg.snap->areamask);
+ } else // if ( inwater )
+ { // extra-special hack... sometimes when crouched in water with first person lightsaber, your PVS is wrong???
/*
if ( !cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) )
{//pseudo first-person for saber and fists
@@ -2177,46 +1895,38 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
}
}
}
- //FIXME: first person crouch-uncrouch STILL FUCKS UP THE AREAMASK!!!
- //if ( !VectorCompare2( cg.refdef.vieworg, cg.snap->ps.serverViewOrg ) && !gi.inPVS( cg.refdef.vieworg, cg.snap->ps.serverViewOrg ) )
- {//actual view org and server's view org don't match and aren't same PVS, rebuild the areamask
- //Com_Printf( S_COLOR_RED"%s != %s\n", vtos(cg.refdef.vieworg), vtos(cg.snap->ps.serverViewOrg) );
- cgi_CM_SnapPVS( cg.refdef.vieworg, cg.snap->areamask );
+ // FIXME: first person crouch-uncrouch STILL FUCKS UP THE AREAMASK!!!
+ // if ( !VectorCompare2( cg.refdef.vieworg, cg.snap->ps.serverViewOrg ) && !gi.inPVS( cg.refdef.vieworg, cg.snap->ps.serverViewOrg ) )
+ { // actual view org and server's view org don't match and aren't same PVS, rebuild the areamask
+ // Com_Printf( S_COLOR_RED"%s != %s\n", vtos(cg.refdef.vieworg), vtos(cg.snap->ps.serverViewOrg) );
+ cgi_CM_SnapPVS(cg.refdef.vieworg, cg.snap->areamask);
}
// Don't draw the in-view weapon when in camera mode
- if ( !in_camera
- && !cg_pano.integer
- && cg.snap->ps.weapon != WP_SABER
- && ( cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD ) )
- {
- CG_AddViewWeapon( &cg.predicted_player_state );
- }
- else if( cg.snap->ps.viewEntity != 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )
- {
- if( g_entities[cg.snap->ps.viewEntity].client && g_entities[cg.snap->ps.viewEntity].NPC )
- {
- CG_AddViewWeapon( &g_entities[cg.snap->ps.viewEntity ].client->ps ); // HAX - because I wanted to --eez
+ if (!in_camera && !cg_pano.integer && cg.snap->ps.weapon != WP_SABER && (cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD)) {
+ CG_AddViewWeapon(&cg.predicted_player_state);
+ } else if (cg.snap->ps.viewEntity != 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD) {
+ if (g_entities[cg.snap->ps.viewEntity].client && g_entities[cg.snap->ps.viewEntity].NPC) {
+ CG_AddViewWeapon(&g_entities[cg.snap->ps.viewEntity].client->ps); // HAX - because I wanted to --eez
}
}
- if ( !cg.hyperspace && fx_freeze.integer<2 )
- {
- //Add all effects
- theFxScheduler.AddScheduledEffects( false );
+ if (!cg.hyperspace && fx_freeze.integer < 2) {
+ // Add all effects
+ theFxScheduler.AddScheduledEffects(false);
}
// finish up the rest of the refdef
- if ( cg.testModelEntity.hModel ) {
+ if (cg.testModelEntity.hModel) {
CG_AddTestModel();
}
- memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) );
+ memcpy(cg.refdef.areamask, cg.snap->areamask, sizeof(cg.refdef.areamask));
// update audio positions
- //This is done from the vieworg to get origin for non-attenuated sounds
- cgi_S_UpdateAmbientSet( CG_ConfigString( CS_AMBIENT_SET ), cg.refdef.vieworg );
- //NOTE: if we want to make you be able to hear far away sounds with electrobinoculars, add the hacked-in positional offset here (base on fov)
+ // This is done from the vieworg to get origin for non-attenuated sounds
+ cgi_S_UpdateAmbientSet(CG_ConfigString(CS_AMBIENT_SET), cg.refdef.vieworg);
+ // NOTE: if we want to make you be able to hear far away sounds with electrobinoculars, add the hacked-in positional offset here (base on fov)
/*
vec3_t listener_origin;
VectorCopy( cg.refdef.vieworg, listener_origin );
@@ -2237,21 +1947,21 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
}
cgi_S_Respatialize( cg.snap->ps.clientNum, listener_origin, cg.refdef.viewaxis, inwater );
*/
- cgi_S_Respatialize( cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater );
+ cgi_S_Respatialize(cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater);
// warning sounds when powerup is wearing off
CG_PowerupTimerSounds();
- if ( cg_pano.integer ) { // let's grab a panorama!
- cg.levelShot = qtrue; //hide the 2d
+ if (cg_pano.integer) { // let's grab a panorama!
+ cg.levelShot = qtrue; // hide the 2d
VectorClear(cg.refdefViewAngles);
- cg.refdefViewAngles[YAW] = -360 * cg_pano.integer/cg_panoNumShots.integer; //choose angle
- AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
- CG_DrawActive( stereoView );
+ cg.refdefViewAngles[YAW] = -360 * cg_pano.integer / cg_panoNumShots.integer; // choose angle
+ AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
+ CG_DrawActive(stereoView);
cg.levelShot = qfalse;
- } else {
+ } else {
// actually issue the rendering calls
- CG_DrawActive( stereoView );
+ CG_DrawActive(stereoView);
}
/*
if ( in_camera && !cg_skippingcin.integer )
@@ -2260,4 +1970,3 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
}
*/
}
-
diff --git a/code/cgame/cg_weapons.cpp b/code/cgame/cg_weapons.cpp
index dc90ee497e..f854097780 100644
--- a/code/cgame/cg_weapons.cpp
+++ b/code/cgame/cg_weapons.cpp
@@ -30,13 +30,11 @@ along with this program; if not, see .
#include "../game/anims.h"
-extern void CG_LightningBolt( centity_t *cent, vec3_t origin );
+extern void CG_LightningBolt(centity_t *cent, vec3_t origin);
-#define PHASER_HOLDFRAME 2
-extern void G_SoundOnEnt( gentity_t *ent, soundChannel_t channel, const char *soundPath );
-const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight,
- const char *psText, int iFontHandle, float fScale,
- const vec4_t v4Color);
+#define PHASER_HOLDFRAME 2
+extern void G_SoundOnEnt(gentity_t *ent, soundChannel_t channel, const char *soundPath);
+const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight, const char *psText, int iFontHandle, float fScale, const vec4_t v4Color);
/*
=================
@@ -45,227 +43,212 @@ CG_RegisterWeapon
The server says this item is used on this level
=================
*/
-void CG_RegisterWeapon( int weaponNum ) {
- weaponInfo_t *weaponInfo;
- gitem_t *item, *ammo;
- char path[MAX_QPATH];
- vec3_t mins, maxs;
- int i;
+void CG_RegisterWeapon(int weaponNum) {
+ weaponInfo_t *weaponInfo;
+ gitem_t *item, *ammo;
+ char path[MAX_QPATH];
+ vec3_t mins, maxs;
+ int i;
weaponInfo = &cg_weapons[weaponNum];
// error checking
- if ( weaponNum == 0 ) {
+ if (weaponNum == 0) {
return;
}
- if ( weaponInfo->registered ) {
+ if (weaponInfo->registered) {
return;
}
// clear out the memory we use
- memset( weaponInfo, 0, sizeof( *weaponInfo ) );
+ memset(weaponInfo, 0, sizeof(*weaponInfo));
weaponInfo->registered = qtrue;
// find the weapon in the item list
- for ( item = bg_itemlist + 1 ; item->classname ; item++ ) {
- if ( item->giType == IT_WEAPON && item->giTag == weaponNum ) {
+ for (item = bg_itemlist + 1; item->classname; item++) {
+ if (item->giType == IT_WEAPON && item->giTag == weaponNum) {
weaponInfo->item = item;
break;
}
}
// if we couldn't find which weapon this is, give us an error
- if ( !item->classname ) {
- CG_Error( "Couldn't find item for weapon %s\nNeed to update Items.dat!", weaponData[weaponNum].classname);
+ if (!item->classname) {
+ CG_Error("Couldn't find item for weapon %s\nNeed to update Items.dat!", weaponData[weaponNum].classname);
}
- CG_RegisterItemVisuals( item - bg_itemlist );
+ CG_RegisterItemVisuals(item - bg_itemlist);
// set up in view weapon model
- weaponInfo->weaponModel = cgi_R_RegisterModel( weaponData[weaponNum].weaponMdl );
- {//in case the weaponmodel isn't _w, precache the _w.glm
+ weaponInfo->weaponModel = cgi_R_RegisterModel(weaponData[weaponNum].weaponMdl);
+ { // in case the weaponmodel isn't _w, precache the _w.glm
char weaponModel[64];
- Q_strncpyz (weaponModel, weaponData[weaponNum].weaponMdl, sizeof(weaponModel));
- if (char *spot = strstr(weaponModel, ".md3") )
- {
+ Q_strncpyz(weaponModel, weaponData[weaponNum].weaponMdl, sizeof(weaponModel));
+ if (char *spot = strstr(weaponModel, ".md3")) {
*spot = 0;
- spot = strstr(weaponModel, "_w");//i'm using the in view weapon array instead of scanning the item list, so put the _w back on
- if (!spot)
- {
- Q_strcat (weaponModel, sizeof(weaponModel), "_w");
+ spot = strstr(weaponModel, "_w"); // i'm using the in view weapon array instead of scanning the item list, so put the _w back on
+ if (!spot) {
+ Q_strcat(weaponModel, sizeof(weaponModel), "_w");
}
- Q_strcat (weaponModel, sizeof(weaponModel), ".glm"); //and change to ghoul2
+ Q_strcat(weaponModel, sizeof(weaponModel), ".glm"); // and change to ghoul2
}
- gi.G2API_PrecacheGhoul2Model( weaponModel ); // correct way is item->world_model
+ gi.G2API_PrecacheGhoul2Model(weaponModel); // correct way is item->world_model
}
- if ( weaponInfo->weaponModel == 0 )
- {
- CG_Error( "Couldn't find weapon model %s for weapon %s\n", weaponData[weaponNum].weaponMdl, weaponData[weaponNum].classname);
+ if (weaponInfo->weaponModel == 0) {
+ CG_Error("Couldn't find weapon model %s for weapon %s\n", weaponData[weaponNum].weaponMdl, weaponData[weaponNum].classname);
return;
}
// calc midpoint for rotation
- cgi_R_ModelBounds( weaponInfo->weaponModel, mins, maxs );
- for ( i = 0 ; i < 3 ; i++ ) {
- weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * ( maxs[i] - mins[i] );
+ cgi_R_ModelBounds(weaponInfo->weaponModel, mins, maxs);
+ for (i = 0; i < 3; i++) {
+ weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * (maxs[i] - mins[i]);
}
// setup the shader we will use for the icon
- if (weaponData[weaponNum].weaponIcon[0])
- {
- weaponInfo->weaponIcon = cgi_R_RegisterShaderNoMip( weaponData[weaponNum].weaponIcon);
- weaponInfo->weaponIconNoAmmo = cgi_R_RegisterShaderNoMip( va("%s_na",weaponData[weaponNum].weaponIcon));
+ if (weaponData[weaponNum].weaponIcon[0]) {
+ weaponInfo->weaponIcon = cgi_R_RegisterShaderNoMip(weaponData[weaponNum].weaponIcon);
+ weaponInfo->weaponIconNoAmmo = cgi_R_RegisterShaderNoMip(va("%s_na", weaponData[weaponNum].weaponIcon));
}
- for ( ammo = bg_itemlist + 1 ; ammo->classname ; ammo++ ) {
- if ( ammo->giType == IT_AMMO && ammo->giTag == weaponData[weaponNum].ammoIndex) {
+ for (ammo = bg_itemlist + 1; ammo->classname; ammo++) {
+ if (ammo->giType == IT_AMMO && ammo->giTag == weaponData[weaponNum].ammoIndex) {
break;
}
}
- if ( ammo->classname && ammo->world_model ) {
- weaponInfo->ammoModel = cgi_R_RegisterModel( ammo->world_model );
+ if (ammo->classname && ammo->world_model) {
+ weaponInfo->ammoModel = cgi_R_RegisterModel(ammo->world_model);
}
- for (i=0; i< weaponData[weaponNum].numBarrels; i++) {
- Q_strncpyz( path, weaponData[weaponNum].weaponMdl, sizeof(path) );
- COM_StripExtension( path, path, sizeof(path) );
- if (i)
- {
- //char crap[50];
- //Com_sprintf(crap, sizeof(crap), "_barrel%d.md3", i+1 );
- //strcat ( path, crap );
- Q_strcat( path, sizeof(path), va("_barrel%d.md3", i+1) );
- }
- else
- Q_strcat( path, sizeof(path), "_barrel.md3" );
- weaponInfo->barrelModel[i] = cgi_R_RegisterModel( path );
+ for (i = 0; i < weaponData[weaponNum].numBarrels; i++) {
+ Q_strncpyz(path, weaponData[weaponNum].weaponMdl, sizeof(path));
+ COM_StripExtension(path, path, sizeof(path));
+ if (i) {
+ // char crap[50];
+ // Com_sprintf(crap, sizeof(crap), "_barrel%d.md3", i+1 );
+ // strcat ( path, crap );
+ Q_strcat(path, sizeof(path), va("_barrel%d.md3", i + 1));
+ } else
+ Q_strcat(path, sizeof(path), "_barrel.md3");
+ weaponInfo->barrelModel[i] = cgi_R_RegisterModel(path);
}
-
// set up the world model for the weapon
- weaponInfo->weaponWorldModel = cgi_R_RegisterModel( item->world_model );
- if ( !weaponInfo->weaponWorldModel) {
+ weaponInfo->weaponWorldModel = cgi_R_RegisterModel(item->world_model);
+ if (!weaponInfo->weaponWorldModel) {
weaponInfo->weaponWorldModel = weaponInfo->weaponModel;
}
// set up the hand that holds the in view weapon - assuming we have one
- Q_strncpyz( path, weaponData[weaponNum].weaponMdl, sizeof(path) );
- COM_StripExtension( path, path, sizeof(path) );
- Q_strcat( path, sizeof(path), "_hand.md3" );
- weaponInfo->handsModel = cgi_R_RegisterModel( path );
+ Q_strncpyz(path, weaponData[weaponNum].weaponMdl, sizeof(path));
+ COM_StripExtension(path, path, sizeof(path));
+ Q_strcat(path, sizeof(path), "_hand.md3");
+ weaponInfo->handsModel = cgi_R_RegisterModel(path);
- if ( !weaponInfo->handsModel ) {
- weaponInfo->handsModel = cgi_R_RegisterModel( "models/weapons2/briar_pistol/briar_pistol_hand.md3" );
+ if (!weaponInfo->handsModel) {
+ weaponInfo->handsModel = cgi_R_RegisterModel("models/weapons2/briar_pistol/briar_pistol_hand.md3");
}
// register the sounds for the weapon
if (weaponData[weaponNum].firingSnd[0]) {
- weaponInfo->firingSound = cgi_S_RegisterSound( weaponData[weaponNum].firingSnd );
+ weaponInfo->firingSound = cgi_S_RegisterSound(weaponData[weaponNum].firingSnd);
}
if (weaponData[weaponNum].altFiringSnd[0]) {
- weaponInfo->altFiringSound = cgi_S_RegisterSound( weaponData[weaponNum].altFiringSnd );
+ weaponInfo->altFiringSound = cgi_S_RegisterSound(weaponData[weaponNum].altFiringSnd);
}
if (weaponData[weaponNum].stopSnd[0]) {
- weaponInfo->stopSound = cgi_S_RegisterSound( weaponData[weaponNum].stopSnd );
+ weaponInfo->stopSound = cgi_S_RegisterSound(weaponData[weaponNum].stopSnd);
}
if (weaponData[weaponNum].chargeSnd[0]) {
- weaponInfo->chargeSound = cgi_S_RegisterSound( weaponData[weaponNum].chargeSnd );
+ weaponInfo->chargeSound = cgi_S_RegisterSound(weaponData[weaponNum].chargeSnd);
}
if (weaponData[weaponNum].altChargeSnd[0]) {
- weaponInfo->altChargeSound = cgi_S_RegisterSound( weaponData[weaponNum].altChargeSnd );
+ weaponInfo->altChargeSound = cgi_S_RegisterSound(weaponData[weaponNum].altChargeSnd);
}
if (weaponData[weaponNum].selectSnd[0]) {
- weaponInfo->selectSound = cgi_S_RegisterSound( weaponData[weaponNum].selectSnd );
+ weaponInfo->selectSound = cgi_S_RegisterSound(weaponData[weaponNum].selectSnd);
}
// give us missile models if we should
- if (weaponData[weaponNum].missileMdl[0]) {
- weaponInfo->missileModel = cgi_R_RegisterModel(weaponData[weaponNum].missileMdl );
+ if (weaponData[weaponNum].missileMdl[0]) {
+ weaponInfo->missileModel = cgi_R_RegisterModel(weaponData[weaponNum].missileMdl);
}
- if (weaponData[weaponNum].alt_missileMdl[0]) {
- weaponInfo->alt_missileModel = cgi_R_RegisterModel(weaponData[weaponNum].alt_missileMdl );
+ if (weaponData[weaponNum].alt_missileMdl[0]) {
+ weaponInfo->alt_missileModel = cgi_R_RegisterModel(weaponData[weaponNum].alt_missileMdl);
}
if (weaponData[weaponNum].missileSound[0]) {
- weaponInfo->missileSound = cgi_S_RegisterSound( weaponData[weaponNum].missileSound );
+ weaponInfo->missileSound = cgi_S_RegisterSound(weaponData[weaponNum].missileSound);
}
if (weaponData[weaponNum].alt_missileSound[0]) {
- weaponInfo->alt_missileSound = cgi_S_RegisterSound( weaponData[weaponNum].alt_missileSound );
+ weaponInfo->alt_missileSound = cgi_S_RegisterSound(weaponData[weaponNum].alt_missileSound);
}
if (weaponData[weaponNum].missileHitSound[0]) {
- weaponInfo->missileHitSound = cgi_S_RegisterSound( weaponData[weaponNum].missileHitSound );
+ weaponInfo->missileHitSound = cgi_S_RegisterSound(weaponData[weaponNum].missileHitSound);
}
if (weaponData[weaponNum].altmissileHitSound[0]) {
- weaponInfo->altmissileHitSound = cgi_S_RegisterSound( weaponData[weaponNum].altmissileHitSound );
+ weaponInfo->altmissileHitSound = cgi_S_RegisterSound(weaponData[weaponNum].altmissileHitSound);
}
- if ( weaponData[weaponNum].mMuzzleEffect[0] )
- {
- weaponData[weaponNum].mMuzzleEffectID = theFxScheduler.RegisterEffect( weaponData[weaponNum].mMuzzleEffect );
+ if (weaponData[weaponNum].mMuzzleEffect[0]) {
+ weaponData[weaponNum].mMuzzleEffectID = theFxScheduler.RegisterEffect(weaponData[weaponNum].mMuzzleEffect);
}
- if ( weaponData[weaponNum].mAltMuzzleEffect[0] )
- {
- weaponData[weaponNum].mAltMuzzleEffectID = theFxScheduler.RegisterEffect( weaponData[weaponNum].mAltMuzzleEffect );
+ if (weaponData[weaponNum].mAltMuzzleEffect[0]) {
+ weaponData[weaponNum].mAltMuzzleEffectID = theFxScheduler.RegisterEffect(weaponData[weaponNum].mAltMuzzleEffect);
}
- //fixme: don't really need to copy these, should just use directly
- // give ourselves the functions if we can
- if (weaponData[weaponNum].func)
- {
- weaponInfo->missileTrailFunc = (void (*)(struct centity_s *,const struct weaponInfo_s *))weaponData[weaponNum].func;
+ // fixme: don't really need to copy these, should just use directly
+ // give ourselves the functions if we can
+ if (weaponData[weaponNum].func) {
+ weaponInfo->missileTrailFunc = (void (*)(struct centity_s *, const struct weaponInfo_s *))weaponData[weaponNum].func;
}
- if (weaponData[weaponNum].altfunc)
- {
- weaponInfo->alt_missileTrailFunc = (void (*)(struct centity_s *,const struct weaponInfo_s *))weaponData[weaponNum].altfunc;
+ if (weaponData[weaponNum].altfunc) {
+ weaponInfo->alt_missileTrailFunc = (void (*)(struct centity_s *, const struct weaponInfo_s *))weaponData[weaponNum].altfunc;
}
- switch ( weaponNum ) //extra client only stuff
+ switch (weaponNum) // extra client only stuff
{
case WP_SABER:
- //saber/force FX
- theFxScheduler.RegisterEffect( "sparks/spark_nosnd" );//was "sparks/spark"
- theFxScheduler.RegisterEffect( "sparks/blood_sparks2" );
- theFxScheduler.RegisterEffect( "force/force_touch" );
- theFxScheduler.RegisterEffect( "saber/saber_block" );
- theFxScheduler.RegisterEffect( "saber/saber_cut" );
- //theFxScheduler.RegisterEffect( "saber/limb_bolton" );
- theFxScheduler.RegisterEffect( "saber/fizz" );
- theFxScheduler.RegisterEffect( "saber/boil" );
- //theFxScheduler.RegisterEffect( "saber/fire" );//was "sparks/spark"
-
- cgs.effects.forceHeal = theFxScheduler.RegisterEffect( "force/heal" );
- //cgs.effects.forceInvincibility = theFxScheduler.RegisterEffect( "force/invin" );
- cgs.effects.forceConfusion = theFxScheduler.RegisterEffect( "force/confusion" );
- cgs.effects.forceLightning = theFxScheduler.RegisterEffect( "force/lightning" );
- cgs.effects.forceLightningWide = theFxScheduler.RegisterEffect( "force/lightningwide" );
- //new Jedi Academy force power effects
- cgs.effects.forceDrain = theFxScheduler.RegisterEffect( "mp/drain" );
- cgs.effects.forceDrainWide = theFxScheduler.RegisterEffect( "mp/drainwide" );
- //cgs.effects.forceDrained = theFxScheduler.RegisterEffect( "mp/drainhit");
-
- //saber sounds
- //cgi_S_RegisterSound( "sound/weapons/saber/saberon.wav" );
- //cgi_S_RegisterSound( "sound/weapons/saber/enemy_saber_on.wav" );
- cgi_S_RegisterSound( "sound/weapons/saber/saberonquick.wav" );
- //cgi_S_RegisterSound( "sound/weapons/saber/saberoff.wav" );
- //cgi_S_RegisterSound( "sound/weapons/saber/enemy_saber_off.wav" );
- cgi_S_RegisterSound( "sound/weapons/saber/saberspinoff.wav" );
- cgi_S_RegisterSound( "sound/weapons/saber/saberoffquick.wav" );
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/saberbounce%d.wav", i ) );
- }
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/saberhit%d.wav", i ) );
- }
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/saberhitwall%d.wav", i ) );
- }
- for ( i = 1; i < 10; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/saberblock%d.wav", i ) );
+ // saber/force FX
+ theFxScheduler.RegisterEffect("sparks/spark_nosnd"); // was "sparks/spark"
+ theFxScheduler.RegisterEffect("sparks/blood_sparks2");
+ theFxScheduler.RegisterEffect("force/force_touch");
+ theFxScheduler.RegisterEffect("saber/saber_block");
+ theFxScheduler.RegisterEffect("saber/saber_cut");
+ // theFxScheduler.RegisterEffect( "saber/limb_bolton" );
+ theFxScheduler.RegisterEffect("saber/fizz");
+ theFxScheduler.RegisterEffect("saber/boil");
+ // theFxScheduler.RegisterEffect( "saber/fire" );//was "sparks/spark"
+
+ cgs.effects.forceHeal = theFxScheduler.RegisterEffect("force/heal");
+ // cgs.effects.forceInvincibility = theFxScheduler.RegisterEffect( "force/invin" );
+ cgs.effects.forceConfusion = theFxScheduler.RegisterEffect("force/confusion");
+ cgs.effects.forceLightning = theFxScheduler.RegisterEffect("force/lightning");
+ cgs.effects.forceLightningWide = theFxScheduler.RegisterEffect("force/lightningwide");
+ // new Jedi Academy force power effects
+ cgs.effects.forceDrain = theFxScheduler.RegisterEffect("mp/drain");
+ cgs.effects.forceDrainWide = theFxScheduler.RegisterEffect("mp/drainwide");
+ // cgs.effects.forceDrained = theFxScheduler.RegisterEffect( "mp/drainhit");
+
+ // saber sounds
+ // cgi_S_RegisterSound( "sound/weapons/saber/saberon.wav" );
+ // cgi_S_RegisterSound( "sound/weapons/saber/enemy_saber_on.wav" );
+ cgi_S_RegisterSound("sound/weapons/saber/saberonquick.wav");
+ // cgi_S_RegisterSound( "sound/weapons/saber/saberoff.wav" );
+ // cgi_S_RegisterSound( "sound/weapons/saber/enemy_saber_off.wav" );
+ cgi_S_RegisterSound("sound/weapons/saber/saberspinoff.wav");
+ cgi_S_RegisterSound("sound/weapons/saber/saberoffquick.wav");
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberbounce%d.wav", i));
+ }
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberhit%d.wav", i));
+ }
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberhitwall%d.wav", i));
+ }
+ for (i = 1; i < 10; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberblock%d.wav", i));
}
/*
for ( i = 1; i < 6; i++ )
@@ -273,332 +256,326 @@ void CG_RegisterWeapon( int weaponNum ) {
cgi_S_RegisterSound( va( "sound/weapons/saber/saberhum%d.wav", i ) );
}
*/
- for ( i = 1; i < 10; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/saberhup%d.wav", i ) );
- }
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/saberspin%d.wav", i ) );
- }
- cgi_S_RegisterSound( "sound/weapons/saber/saber_catch.wav" );
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/bounce%d.wav", i ) );
- }
- cgi_S_RegisterSound( "sound/weapons/saber/hitwater.wav" );
- cgi_S_RegisterSound( "sound/weapons/saber/boiling.wav" );
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/saber/rainfizz%d.wav", i ) );
- }
- cgi_S_RegisterSound( "sound/movers/objects/saber_slam" );
-
- //force sounds
- cgi_S_RegisterSound( "sound/weapons/force/heal.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/speed.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/speedloop.mp3" );
- for ( i = 1; i < 5; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_m.mp3", i ) );
- cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_f.mp3", i ) );
- }
- cgi_S_RegisterSound( "sound/weapons/force/lightning.wav" );
- cgi_S_RegisterSound( "sound/weapons/force/lightning2.wav" );
- for ( i = 1; i < 4; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/force/lightninghit%d.wav", i ) );
- }
- cgi_S_RegisterSound( "sound/weapons/force/push.wav" );
- cgi_S_RegisterSound( "sound/weapons/force/pull.wav" );
- cgi_S_RegisterSound( "sound/weapons/force/jump.wav" );
- cgi_S_RegisterSound( "sound/weapons/force/jumpbuild.wav" );
- cgi_S_RegisterSound( "sound/weapons/force/grip.mp3" );
- //new Jedi Academy force sounds
- cgi_S_RegisterSound( "sound/weapons/force/absorb.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/absorbhit.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/absorbloop.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/protect.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/protecthit.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/protectloop.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/rage.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/ragehit.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/rageloop.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/see.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/seeloop.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/drain.mp3" );
- cgi_S_RegisterSound( "sound/weapons/force/drained.mp3" );
- //force graphics
+ for (i = 1; i < 10; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberhup%d.wav", i));
+ }
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/saberspin%d.wav", i));
+ }
+ cgi_S_RegisterSound("sound/weapons/saber/saber_catch.wav");
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/bounce%d.wav", i));
+ }
+ cgi_S_RegisterSound("sound/weapons/saber/hitwater.wav");
+ cgi_S_RegisterSound("sound/weapons/saber/boiling.wav");
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/saber/rainfizz%d.wav", i));
+ }
+ cgi_S_RegisterSound("sound/movers/objects/saber_slam");
+
+ // force sounds
+ cgi_S_RegisterSound("sound/weapons/force/heal.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/speed.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/speedloop.mp3");
+ for (i = 1; i < 5; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/force/heal%d_m.mp3", i));
+ cgi_S_RegisterSound(va("sound/weapons/force/heal%d_f.mp3", i));
+ }
+ cgi_S_RegisterSound("sound/weapons/force/lightning.wav");
+ cgi_S_RegisterSound("sound/weapons/force/lightning2.wav");
+ for (i = 1; i < 4; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/force/lightninghit%d.wav", i));
+ }
+ cgi_S_RegisterSound("sound/weapons/force/push.wav");
+ cgi_S_RegisterSound("sound/weapons/force/pull.wav");
+ cgi_S_RegisterSound("sound/weapons/force/jump.wav");
+ cgi_S_RegisterSound("sound/weapons/force/jumpbuild.wav");
+ cgi_S_RegisterSound("sound/weapons/force/grip.mp3");
+ // new Jedi Academy force sounds
+ cgi_S_RegisterSound("sound/weapons/force/absorb.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/absorbhit.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/absorbloop.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/protect.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/protecthit.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/protectloop.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/rage.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/ragehit.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/rageloop.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/see.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/seeloop.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/drain.mp3");
+ cgi_S_RegisterSound("sound/weapons/force/drained.mp3");
+ // force graphics
cgs.media.playerShieldDamage = cgi_R_RegisterShader("gfx/misc/personalshield");
- //cgs.media.forceSightBubble = cgi_R_RegisterShader("gfx/misc/sightbubble");
- //cgs.media.forceShell = cgi_R_RegisterShader("powerups/forceshell");
+ // cgs.media.forceSightBubble = cgi_R_RegisterShader("gfx/misc/sightbubble");
+ // cgs.media.forceShell = cgi_R_RegisterShader("powerups/forceshell");
cgs.media.forceShell = cgi_R_RegisterShader("gfx/misc/forceprotect");
cgs.media.sightShell = cgi_R_RegisterShader("powerups/sightshell");
- cgi_R_RegisterShader( "gfx/2d/jsense" );
- //force effects - FIXME: only if someone has these powers?
- theFxScheduler.RegisterEffect( "force/rage2" );
- //theFxScheduler.RegisterEffect( "force/heal_joint" );
- theFxScheduler.RegisterEffect( "force/heal2" );
- theFxScheduler.RegisterEffect( "force/drain_hand" );
-
- //saber graphics
- cgs.media.saberBlurShader = cgi_R_RegisterShader("gfx/effects/sabers/saberBlur");
- cgs.media.swordTrailShader = cgi_R_RegisterShader("gfx/effects/sabers/swordTrail");
- cgs.media.yellowDroppedSaberShader = cgi_R_RegisterShader("gfx/effects/yellow_glow");
- cgi_R_RegisterShader( "gfx/effects/saberDamageGlow" );
- cgi_R_RegisterShader( "gfx/effects/solidWhite_cull" );
- cgi_R_RegisterShader( "gfx/effects/forcePush" );
- cgi_R_RegisterShader( "gfx/effects/saberFlare" );
- cgs.media.redSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/red_glow" );
- cgs.media.redSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/red_line" );
- cgs.media.orangeSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/orange_glow" );
- cgs.media.orangeSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/orange_line" );
- cgs.media.yellowSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/yellow_glow" );
- cgs.media.yellowSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/yellow_line" );
- cgs.media.greenSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/green_glow" );
- cgs.media.greenSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/green_line" );
- cgs.media.blueSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/blue_glow" );
- cgs.media.blueSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/blue_line" );
- cgs.media.purpleSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/purple_glow" );
- cgs.media.purpleSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/purple_line" );
-
- cgs.media.forceCoronaShader = cgi_R_RegisterShaderNoMip( "gfx/hud/force_swirl" );
-
- //new Jedi Academy force graphics
- cgs.media.drainShader = cgi_R_RegisterShader( "gfx/misc/redLine" );
-
- //for grip slamming into walls
- theFxScheduler.RegisterEffect( "env/impact_dustonly" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
-
- //For kicks with saber staff...
- theFxScheduler.RegisterEffect( "melee/kick_impact" );
-
- //Kothos beam
- cgi_R_RegisterShader( "gfx/misc/dr1" );
+ cgi_R_RegisterShader("gfx/2d/jsense");
+ // force effects - FIXME: only if someone has these powers?
+ theFxScheduler.RegisterEffect("force/rage2");
+ // theFxScheduler.RegisterEffect( "force/heal_joint" );
+ theFxScheduler.RegisterEffect("force/heal2");
+ theFxScheduler.RegisterEffect("force/drain_hand");
+
+ // saber graphics
+ cgs.media.saberBlurShader = cgi_R_RegisterShader("gfx/effects/sabers/saberBlur");
+ cgs.media.swordTrailShader = cgi_R_RegisterShader("gfx/effects/sabers/swordTrail");
+ cgs.media.yellowDroppedSaberShader = cgi_R_RegisterShader("gfx/effects/yellow_glow");
+ cgi_R_RegisterShader("gfx/effects/saberDamageGlow");
+ cgi_R_RegisterShader("gfx/effects/solidWhite_cull");
+ cgi_R_RegisterShader("gfx/effects/forcePush");
+ cgi_R_RegisterShader("gfx/effects/saberFlare");
+ cgs.media.redSaberGlowShader = cgi_R_RegisterShader("gfx/effects/sabers/red_glow");
+ cgs.media.redSaberCoreShader = cgi_R_RegisterShader("gfx/effects/sabers/red_line");
+ cgs.media.orangeSaberGlowShader = cgi_R_RegisterShader("gfx/effects/sabers/orange_glow");
+ cgs.media.orangeSaberCoreShader = cgi_R_RegisterShader("gfx/effects/sabers/orange_line");
+ cgs.media.yellowSaberGlowShader = cgi_R_RegisterShader("gfx/effects/sabers/yellow_glow");
+ cgs.media.yellowSaberCoreShader = cgi_R_RegisterShader("gfx/effects/sabers/yellow_line");
+ cgs.media.greenSaberGlowShader = cgi_R_RegisterShader("gfx/effects/sabers/green_glow");
+ cgs.media.greenSaberCoreShader = cgi_R_RegisterShader("gfx/effects/sabers/green_line");
+ cgs.media.blueSaberGlowShader = cgi_R_RegisterShader("gfx/effects/sabers/blue_glow");
+ cgs.media.blueSaberCoreShader = cgi_R_RegisterShader("gfx/effects/sabers/blue_line");
+ cgs.media.purpleSaberGlowShader = cgi_R_RegisterShader("gfx/effects/sabers/purple_glow");
+ cgs.media.purpleSaberCoreShader = cgi_R_RegisterShader("gfx/effects/sabers/purple_line");
+
+ cgs.media.forceCoronaShader = cgi_R_RegisterShaderNoMip("gfx/hud/force_swirl");
+
+ // new Jedi Academy force graphics
+ cgs.media.drainShader = cgi_R_RegisterShader("gfx/misc/redLine");
+
+ // for grip slamming into walls
+ theFxScheduler.RegisterEffect("env/impact_dustonly");
+ cgi_S_RegisterSound("sound/weapons/melee/punch1.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch2.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch3.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch4.mp3");
+
+ // For kicks with saber staff...
+ theFxScheduler.RegisterEffect("melee/kick_impact");
+
+ // Kothos beam
+ cgi_R_RegisterShader("gfx/misc/dr1");
break;
case WP_BRYAR_PISTOL:
case WP_BLASTER_PISTOL: // enemy version
case WP_JAWA:
- cgs.effects.bryarShotEffect = theFxScheduler.RegisterEffect( "bryar/shot" );
- theFxScheduler.RegisterEffect( "bryar/NPCshot" );
- cgs.effects.bryarPowerupShotEffect = theFxScheduler.RegisterEffect( "bryar/crackleShot" );
- cgs.effects.bryarWallImpactEffect = theFxScheduler.RegisterEffect( "bryar/wall_impact" );
- cgs.effects.bryarWallImpactEffect2 = theFxScheduler.RegisterEffect( "bryar/wall_impact2" );
- cgs.effects.bryarWallImpactEffect3 = theFxScheduler.RegisterEffect( "bryar/wall_impact3" );
- cgs.effects.bryarFleshImpactEffect = theFxScheduler.RegisterEffect( "bryar/flesh_impact" );
+ cgs.effects.bryarShotEffect = theFxScheduler.RegisterEffect("bryar/shot");
+ theFxScheduler.RegisterEffect("bryar/NPCshot");
+ cgs.effects.bryarPowerupShotEffect = theFxScheduler.RegisterEffect("bryar/crackleShot");
+ cgs.effects.bryarWallImpactEffect = theFxScheduler.RegisterEffect("bryar/wall_impact");
+ cgs.effects.bryarWallImpactEffect2 = theFxScheduler.RegisterEffect("bryar/wall_impact2");
+ cgs.effects.bryarWallImpactEffect3 = theFxScheduler.RegisterEffect("bryar/wall_impact3");
+ cgs.effects.bryarFleshImpactEffect = theFxScheduler.RegisterEffect("bryar/flesh_impact");
// Note....these are temp shared effects
- theFxScheduler.RegisterEffect( "blaster/deflect" );
- theFxScheduler.RegisterEffect( "blaster/smoke_bolton" ); // note: this will be called game side
+ theFxScheduler.RegisterEffect("blaster/deflect");
+ theFxScheduler.RegisterEffect("blaster/smoke_bolton"); // note: this will be called game side
break;
case WP_BLASTER:
- cgs.effects.blasterShotEffect = theFxScheduler.RegisterEffect( "blaster/shot" );
- theFxScheduler.RegisterEffect( "blaster/NPCshot" );
-// cgs.effects.blasterOverchargeEffect = theFxScheduler.RegisterEffect( "blaster/overcharge" );
- cgs.effects.blasterWallImpactEffect = theFxScheduler.RegisterEffect( "blaster/wall_impact" );
- cgs.effects.blasterFleshImpactEffect = theFxScheduler.RegisterEffect( "blaster/flesh_impact" );
- theFxScheduler.RegisterEffect( "blaster/deflect" );
- theFxScheduler.RegisterEffect( "blaster/smoke_bolton" ); // note: this will be called game side
+ cgs.effects.blasterShotEffect = theFxScheduler.RegisterEffect("blaster/shot");
+ theFxScheduler.RegisterEffect("blaster/NPCshot");
+ // cgs.effects.blasterOverchargeEffect = theFxScheduler.RegisterEffect( "blaster/overcharge" );
+ cgs.effects.blasterWallImpactEffect = theFxScheduler.RegisterEffect("blaster/wall_impact");
+ cgs.effects.blasterFleshImpactEffect = theFxScheduler.RegisterEffect("blaster/flesh_impact");
+ theFxScheduler.RegisterEffect("blaster/deflect");
+ theFxScheduler.RegisterEffect("blaster/smoke_bolton"); // note: this will be called game side
break;
case WP_DISRUPTOR:
- theFxScheduler.RegisterEffect( "disruptor/wall_impact" );
- theFxScheduler.RegisterEffect( "disruptor/flesh_impact" );
- theFxScheduler.RegisterEffect( "disruptor/alt_miss" );
- theFxScheduler.RegisterEffect( "disruptor/alt_hit" );
- theFxScheduler.RegisterEffect( "disruptor/line_cap" );
- theFxScheduler.RegisterEffect( "disruptor/death_smoke" );
+ theFxScheduler.RegisterEffect("disruptor/wall_impact");
+ theFxScheduler.RegisterEffect("disruptor/flesh_impact");
+ theFxScheduler.RegisterEffect("disruptor/alt_miss");
+ theFxScheduler.RegisterEffect("disruptor/alt_hit");
+ theFxScheduler.RegisterEffect("disruptor/line_cap");
+ theFxScheduler.RegisterEffect("disruptor/death_smoke");
- cgi_R_RegisterShader( "gfx/effects/redLine" );
- cgi_R_RegisterShader( "gfx/misc/whiteline2" );
- cgi_R_RegisterShader( "gfx/effects/smokeTrail" );
- cgi_R_RegisterShader( "gfx/effects/burn" );
+ cgi_R_RegisterShader("gfx/effects/redLine");
+ cgi_R_RegisterShader("gfx/misc/whiteline2");
+ cgi_R_RegisterShader("gfx/effects/smokeTrail");
+ cgi_R_RegisterShader("gfx/effects/burn");
- cgi_R_RegisterShaderNoMip( "gfx/2d/crop_charge" );
+ cgi_R_RegisterShaderNoMip("gfx/2d/crop_charge");
// zoom sounds
- cgi_S_RegisterSound( "sound/weapons/disruptor/zoomstart.wav" );
- cgi_S_RegisterSound( "sound/weapons/disruptor/zoomend.wav" );
- cgs.media.disruptorZoomLoop = cgi_S_RegisterSound( "sound/weapons/disruptor/zoomloop.wav" );
+ cgi_S_RegisterSound("sound/weapons/disruptor/zoomstart.wav");
+ cgi_S_RegisterSound("sound/weapons/disruptor/zoomend.wav");
+ cgs.media.disruptorZoomLoop = cgi_S_RegisterSound("sound/weapons/disruptor/zoomloop.wav");
// Disruptor gun zoom interface
- cgs.media.disruptorMask = cgi_R_RegisterShader( "gfx/2d/cropCircle2");
- cgs.media.disruptorInsert = cgi_R_RegisterShader( "gfx/2d/cropCircle");
- cgs.media.disruptorLight = cgi_R_RegisterShader( "gfx/2d/cropCircleGlow" );
- cgs.media.disruptorInsertTick = cgi_R_RegisterShader( "gfx/2d/insertTick" );
+ cgs.media.disruptorMask = cgi_R_RegisterShader("gfx/2d/cropCircle2");
+ cgs.media.disruptorInsert = cgi_R_RegisterShader("gfx/2d/cropCircle");
+ cgs.media.disruptorLight = cgi_R_RegisterShader("gfx/2d/cropCircleGlow");
+ cgs.media.disruptorInsertTick = cgi_R_RegisterShader("gfx/2d/insertTick");
break;
case WP_BOWCASTER:
- cgs.effects.bowcasterShotEffect = theFxScheduler.RegisterEffect( "bowcaster/shot" );
- cgs.effects.bowcasterBounceEffect = theFxScheduler.RegisterEffect( "bowcaster/bounce_wall" );
- cgs.effects.bowcasterImpactEffect = theFxScheduler.RegisterEffect( "bowcaster/explosion" );
- theFxScheduler.RegisterEffect( "bowcaster/deflect" );
+ cgs.effects.bowcasterShotEffect = theFxScheduler.RegisterEffect("bowcaster/shot");
+ cgs.effects.bowcasterBounceEffect = theFxScheduler.RegisterEffect("bowcaster/bounce_wall");
+ cgs.effects.bowcasterImpactEffect = theFxScheduler.RegisterEffect("bowcaster/explosion");
+ theFxScheduler.RegisterEffect("bowcaster/deflect");
break;
case WP_REPEATER:
- theFxScheduler.RegisterEffect( "repeater/muzzle_smoke" );
- theFxScheduler.RegisterEffect( "repeater/projectile" );
- theFxScheduler.RegisterEffect( "repeater/alt_projectile" );
- theFxScheduler.RegisterEffect( "repeater/wall_impact" );
-// theFxScheduler.RegisterEffect( "repeater/alt_wall_impact2" );
-// theFxScheduler.RegisterEffect( "repeater/flesh_impact" );
- theFxScheduler.RegisterEffect( "repeater/concussion" );
+ theFxScheduler.RegisterEffect("repeater/muzzle_smoke");
+ theFxScheduler.RegisterEffect("repeater/projectile");
+ theFxScheduler.RegisterEffect("repeater/alt_projectile");
+ theFxScheduler.RegisterEffect("repeater/wall_impact");
+ // theFxScheduler.RegisterEffect( "repeater/alt_wall_impact2" );
+ // theFxScheduler.RegisterEffect( "repeater/flesh_impact" );
+ theFxScheduler.RegisterEffect("repeater/concussion");
break;
case WP_DEMP2:
- theFxScheduler.RegisterEffect( "demp2/projectile" );
- theFxScheduler.RegisterEffect( "demp2/wall_impact" );
- theFxScheduler.RegisterEffect( "demp2/flesh_impact" );
- theFxScheduler.RegisterEffect( "demp2/altDetonate" );
- cgi_R_RegisterModel( "models/items/sphere.md3" );
- cgi_R_RegisterShader( "gfx/effects/demp2shell" );
+ theFxScheduler.RegisterEffect("demp2/projectile");
+ theFxScheduler.RegisterEffect("demp2/wall_impact");
+ theFxScheduler.RegisterEffect("demp2/flesh_impact");
+ theFxScheduler.RegisterEffect("demp2/altDetonate");
+ cgi_R_RegisterModel("models/items/sphere.md3");
+ cgi_R_RegisterShader("gfx/effects/demp2shell");
break;
case WP_ATST_MAIN:
- theFxScheduler.RegisterEffect( "atst/shot" );
- theFxScheduler.RegisterEffect( "atst/wall_impact" );
- theFxScheduler.RegisterEffect( "atst/flesh_impact" );
- theFxScheduler.RegisterEffect( "atst/droid_impact" );
+ theFxScheduler.RegisterEffect("atst/shot");
+ theFxScheduler.RegisterEffect("atst/wall_impact");
+ theFxScheduler.RegisterEffect("atst/flesh_impact");
+ theFxScheduler.RegisterEffect("atst/droid_impact");
break;
case WP_ATST_SIDE:
// For the ALT fire
- theFxScheduler.RegisterEffect( "atst/side_alt_shot" );
- theFxScheduler.RegisterEffect( "atst/side_alt_explosion" );
+ theFxScheduler.RegisterEffect("atst/side_alt_shot");
+ theFxScheduler.RegisterEffect("atst/side_alt_explosion");
// For the regular fire
- theFxScheduler.RegisterEffect( "atst/side_main_shot" );
- theFxScheduler.RegisterEffect( "atst/side_main_impact" );
+ theFxScheduler.RegisterEffect("atst/side_main_shot");
+ theFxScheduler.RegisterEffect("atst/side_main_impact");
break;
case WP_FLECHETTE:
- cgs.effects.flechetteShotEffect = theFxScheduler.RegisterEffect( "flechette/shot" );
- cgs.effects.flechetteAltShotEffect = theFxScheduler.RegisterEffect( "flechette/alt_shot" );
- cgs.effects.flechetteShotDeathEffect = theFxScheduler.RegisterEffect( "flechette/wall_impact" ); // shot death
- cgs.effects.flechetteFleshImpactEffect = theFxScheduler.RegisterEffect( "flechette/flesh_impact" );
- cgs.effects.flechetteRicochetEffect = theFxScheduler.RegisterEffect( "flechette/ricochet" );
+ cgs.effects.flechetteShotEffect = theFxScheduler.RegisterEffect("flechette/shot");
+ cgs.effects.flechetteAltShotEffect = theFxScheduler.RegisterEffect("flechette/alt_shot");
+ cgs.effects.flechetteShotDeathEffect = theFxScheduler.RegisterEffect("flechette/wall_impact"); // shot death
+ cgs.effects.flechetteFleshImpactEffect = theFxScheduler.RegisterEffect("flechette/flesh_impact");
+ cgs.effects.flechetteRicochetEffect = theFxScheduler.RegisterEffect("flechette/ricochet");
-// theFxScheduler.RegisterEffect( "flechette/explosion" );
- theFxScheduler.RegisterEffect( "flechette/alt_blow" );
+ // theFxScheduler.RegisterEffect( "flechette/explosion" );
+ theFxScheduler.RegisterEffect("flechette/alt_blow");
break;
case WP_ROCKET_LAUNCHER:
- theFxScheduler.RegisterEffect( "rocket/shot" );
- theFxScheduler.RegisterEffect( "rocket/explosion" );
+ theFxScheduler.RegisterEffect("rocket/shot");
+ theFxScheduler.RegisterEffect("rocket/explosion");
- cgi_R_RegisterShaderNoMip( "gfx/2d/wedge" );
- cgi_R_RegisterShaderNoMip( "gfx/2d/lock" );
+ cgi_R_RegisterShaderNoMip("gfx/2d/wedge");
+ cgi_R_RegisterShaderNoMip("gfx/2d/lock");
- cgi_S_RegisterSound( "sound/weapons/rocket/lock.wav" );
- cgi_S_RegisterSound( "sound/weapons/rocket/tick.wav" );
+ cgi_S_RegisterSound("sound/weapons/rocket/lock.wav");
+ cgi_S_RegisterSound("sound/weapons/rocket/tick.wav");
break;
case WP_CONCUSSION:
- //Primary
- theFxScheduler.RegisterEffect( "concussion/shot" );
- theFxScheduler.RegisterEffect( "concussion/explosion" );
- //Alt
- theFxScheduler.RegisterEffect( "concussion/alt_miss" );
- theFxScheduler.RegisterEffect( "concussion/alt_hit" );
- theFxScheduler.RegisterEffect( "concussion/alt_ring" );
- //not used (eventually)?
- cgi_R_RegisterShader( "gfx/effects/blueLine" );
- cgi_R_RegisterShader( "gfx/misc/whiteline2" );
+ // Primary
+ theFxScheduler.RegisterEffect("concussion/shot");
+ theFxScheduler.RegisterEffect("concussion/explosion");
+ // Alt
+ theFxScheduler.RegisterEffect("concussion/alt_miss");
+ theFxScheduler.RegisterEffect("concussion/alt_hit");
+ theFxScheduler.RegisterEffect("concussion/alt_ring");
+ // not used (eventually)?
+ cgi_R_RegisterShader("gfx/effects/blueLine");
+ cgi_R_RegisterShader("gfx/misc/whiteline2");
break;
case WP_THERMAL:
- cgs.media.grenadeBounce1 = cgi_S_RegisterSound( "sound/weapons/thermal/bounce1.wav" );
- cgs.media.grenadeBounce2 = cgi_S_RegisterSound( "sound/weapons/thermal/bounce2.wav" );
+ cgs.media.grenadeBounce1 = cgi_S_RegisterSound("sound/weapons/thermal/bounce1.wav");
+ cgs.media.grenadeBounce2 = cgi_S_RegisterSound("sound/weapons/thermal/bounce2.wav");
- cgi_S_RegisterSound( "sound/weapons/thermal/thermloop.wav" );
- cgi_S_RegisterSound( "sound/weapons/thermal/warning.wav" );
- theFxScheduler.RegisterEffect( "thermal/explosion" );
- theFxScheduler.RegisterEffect( "thermal/shockwave" );
+ cgi_S_RegisterSound("sound/weapons/thermal/thermloop.wav");
+ cgi_S_RegisterSound("sound/weapons/thermal/warning.wav");
+ theFxScheduler.RegisterEffect("thermal/explosion");
+ theFxScheduler.RegisterEffect("thermal/shockwave");
break;
case WP_TRIP_MINE:
- theFxScheduler.RegisterEffect( "tripMine/explosion" );
- theFxScheduler.RegisterEffect( "tripMine/laser" );
- theFxScheduler.RegisterEffect( "tripMine/laserImpactGlow" );
- theFxScheduler.RegisterEffect( "tripMine/glowBit" );
+ theFxScheduler.RegisterEffect("tripMine/explosion");
+ theFxScheduler.RegisterEffect("tripMine/laser");
+ theFxScheduler.RegisterEffect("tripMine/laserImpactGlow");
+ theFxScheduler.RegisterEffect("tripMine/glowBit");
- cgs.media.tripMineStickSound = cgi_S_RegisterSound( "sound/weapons/laser_trap/stick.wav" );
- cgi_S_RegisterSound( "sound/weapons/laser_trap/warning.wav" );
- cgi_S_RegisterSound( "sound/weapons/laser_trap/hum_loop.wav" );
+ cgs.media.tripMineStickSound = cgi_S_RegisterSound("sound/weapons/laser_trap/stick.wav");
+ cgi_S_RegisterSound("sound/weapons/laser_trap/warning.wav");
+ cgi_S_RegisterSound("sound/weapons/laser_trap/hum_loop.wav");
break;
case WP_DET_PACK:
- theFxScheduler.RegisterEffect( "detpack/explosion.efx" );
+ theFxScheduler.RegisterEffect("detpack/explosion.efx");
- cgs.media.detPackStickSound = cgi_S_RegisterSound( "sound/weapons/detpack/stick.wav" );
- cgi_R_RegisterModel( "models/weapons2/detpack/detpack.md3" );
- cgi_S_RegisterSound( "sound/weapons/detpack/warning.wav" );
- cgi_S_RegisterSound( "sound/weapons/explosions/explode5.wav" );
+ cgs.media.detPackStickSound = cgi_S_RegisterSound("sound/weapons/detpack/stick.wav");
+ cgi_R_RegisterModel("models/weapons2/detpack/detpack.md3");
+ cgi_S_RegisterSound("sound/weapons/detpack/warning.wav");
+ cgi_S_RegisterSound("sound/weapons/explosions/explode5.wav");
break;
case WP_EMPLACED_GUN:
- theFxScheduler.RegisterEffect( "emplaced/shot" );
- theFxScheduler.RegisterEffect( "emplaced/shotNPC" );
- theFxScheduler.RegisterEffect( "emplaced/wall_impact" );
- //E-Web, too, can't tell here which one you wanted, so...
- theFxScheduler.RegisterEffect( "eweb/shot" );
- theFxScheduler.RegisterEffect( "eweb/shotNPC" );
- theFxScheduler.RegisterEffect( "eweb/wall_impact" );
- theFxScheduler.RegisterEffect( "eweb/flesh_impact" );
+ theFxScheduler.RegisterEffect("emplaced/shot");
+ theFxScheduler.RegisterEffect("emplaced/shotNPC");
+ theFxScheduler.RegisterEffect("emplaced/wall_impact");
+ // E-Web, too, can't tell here which one you wanted, so...
+ theFxScheduler.RegisterEffect("eweb/shot");
+ theFxScheduler.RegisterEffect("eweb/shotNPC");
+ theFxScheduler.RegisterEffect("eweb/wall_impact");
+ theFxScheduler.RegisterEffect("eweb/flesh_impact");
- cgi_R_RegisterShader( "models/map_objects/imp_mine/turret_chair_dmg" );
- cgi_R_RegisterShader( "models/map_objects/imp_mine/turret_chair_on" );
+ cgi_R_RegisterShader("models/map_objects/imp_mine/turret_chair_dmg");
+ cgi_R_RegisterShader("models/map_objects/imp_mine/turret_chair_on");
- cgs.media.emplacedHealthBarShader = cgi_R_RegisterShaderNoMip( "gfx/hud/health_frame" );
- cgs.media.turretComputerOverlayShader = cgi_R_RegisterShaderNoMip( "gfx/hud/generic_target" );
- cgs.media.turretCrossHairShader = cgi_R_RegisterShaderNoMip( "gfx/2d/panel_crosshair" );
+ cgs.media.emplacedHealthBarShader = cgi_R_RegisterShaderNoMip("gfx/hud/health_frame");
+ cgs.media.turretComputerOverlayShader = cgi_R_RegisterShaderNoMip("gfx/hud/generic_target");
+ cgs.media.turretCrossHairShader = cgi_R_RegisterShaderNoMip("gfx/2d/panel_crosshair");
break;
case WP_MELEE:
case WP_TUSKEN_STAFF:
- //TEMP
- theFxScheduler.RegisterEffect( "melee/punch_impact" );
- theFxScheduler.RegisterEffect( "melee/kick_impact" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
+ // TEMP
+ theFxScheduler.RegisterEffect("melee/punch_impact");
+ theFxScheduler.RegisterEffect("melee/kick_impact");
+ cgi_S_RegisterSound("sound/weapons/melee/punch1.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch2.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch3.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch4.mp3");
break;
case WP_STUN_BATON:
- cgi_R_RegisterShader( "gfx/effects/stunPass" );
- theFxScheduler.RegisterEffect( "stunBaton/flesh_impact" );
- //TEMP
- cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
- cgi_S_RegisterSound( "sound/weapons/baton/fire" );
+ cgi_R_RegisterShader("gfx/effects/stunPass");
+ theFxScheduler.RegisterEffect("stunBaton/flesh_impact");
+ // TEMP
+ cgi_S_RegisterSound("sound/weapons/melee/punch1.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch2.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch3.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch4.mp3");
+ cgi_S_RegisterSound("sound/weapons/baton/fire");
break;
case WP_TURRET:
- theFxScheduler.RegisterEffect( "turret/shot" );
- theFxScheduler.RegisterEffect( "turret/wall_impact" );
- theFxScheduler.RegisterEffect( "turret/flesh_impact" );
+ theFxScheduler.RegisterEffect("turret/shot");
+ theFxScheduler.RegisterEffect("turret/wall_impact");
+ theFxScheduler.RegisterEffect("turret/flesh_impact");
break;
case WP_TUSKEN_RIFLE:
- //melee
- theFxScheduler.RegisterEffect( "melee/punch_impact" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
- cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
- //fire
- theFxScheduler.RegisterEffect( "tusken/shot" );
- theFxScheduler.RegisterEffect( "tusken/hit" );
- theFxScheduler.RegisterEffect( "tusken/hitwall" );
+ // melee
+ theFxScheduler.RegisterEffect("melee/punch_impact");
+ cgi_S_RegisterSound("sound/weapons/melee/punch1.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch2.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch3.mp3");
+ cgi_S_RegisterSound("sound/weapons/melee/punch4.mp3");
+ // fire
+ theFxScheduler.RegisterEffect("tusken/shot");
+ theFxScheduler.RegisterEffect("tusken/hit");
+ theFxScheduler.RegisterEffect("tusken/hitwall");
break;
@@ -607,16 +584,16 @@ void CG_RegisterWeapon( int weaponNum ) {
break;
case WP_NOGHRI_STICK:
- //fire
- theFxScheduler.RegisterEffect( "noghri_stick/shot" );
- theFxScheduler.RegisterEffect( "noghri_stick/flesh_impact" );
- //explosion
- theFxScheduler.RegisterEffect( "noghri_stick/gas_cloud" );
- //cgi_S_RegisterSound("sound/weapons/noghri/smoke.wav");
+ // fire
+ theFxScheduler.RegisterEffect("noghri_stick/shot");
+ theFxScheduler.RegisterEffect("noghri_stick/flesh_impact");
+ // explosion
+ theFxScheduler.RegisterEffect("noghri_stick/gas_cloud");
+ // cgi_S_RegisterSound("sound/weapons/noghri/smoke.wav");
break;
case WP_TIE_FIGHTER:
- theFxScheduler.RegisterEffect( "ships/imp_blastershot" );
+ theFxScheduler.RegisterEffect("ships/imp_blastershot");
break;
}
}
@@ -628,103 +605,92 @@ CG_RegisterItemVisuals
The server says this item is used on this level
=================
*/
-void CG_RegisterItemVisuals( int itemNum ) {
- itemInfo_t *itemInfo;
- gitem_t *item;
+void CG_RegisterItemVisuals(int itemNum) {
+ itemInfo_t *itemInfo;
+ gitem_t *item;
- itemInfo = &cg_items[ itemNum ];
- if ( itemInfo->registered ) {
+ itemInfo = &cg_items[itemNum];
+ if (itemInfo->registered) {
return;
}
- item = &bg_itemlist[ itemNum ];
+ item = &bg_itemlist[itemNum];
- memset( itemInfo, 0, sizeof( *itemInfo ) );
+ memset(itemInfo, 0, sizeof(*itemInfo));
itemInfo->registered = qtrue;
- itemInfo->models = cgi_R_RegisterModel( item->world_model );
+ itemInfo->models = cgi_R_RegisterModel(item->world_model);
- if ( item->icon && item->icon[0] )
- {
- itemInfo->icon = cgi_R_RegisterShaderNoMip( item->icon );
- }
- else
- {
+ if (item->icon && item->icon[0]) {
+ itemInfo->icon = cgi_R_RegisterShaderNoMip(item->icon);
+ } else {
itemInfo->icon = -1;
}
- if ( item->giType == IT_WEAPON )
- {
- CG_RegisterWeapon( item->giTag );
+ if (item->giType == IT_WEAPON) {
+ CG_RegisterWeapon(item->giTag);
}
// some ammo types are actually the weapon, like in the case of explosives
- if ( item->giType == IT_AMMO )
- {
- switch( item->giTag )
- {
+ if (item->giType == IT_AMMO) {
+ switch (item->giTag) {
case AMMO_THERMAL:
- CG_RegisterWeapon( WP_THERMAL );
+ CG_RegisterWeapon(WP_THERMAL);
break;
case AMMO_TRIPMINE:
- CG_RegisterWeapon( WP_TRIP_MINE );
+ CG_RegisterWeapon(WP_TRIP_MINE);
break;
case AMMO_DETPACK:
- CG_RegisterWeapon( WP_DET_PACK );
+ CG_RegisterWeapon(WP_DET_PACK);
break;
}
}
-
- if ( item->giType == IT_HOLDABLE )
- {
+ if (item->giType == IT_HOLDABLE) {
// This should be set up to actually work.
- switch( item->giTag )
- {
+ switch (item->giTag) {
case INV_SEEKER:
cgi_S_RegisterSound("sound/chars/seeker/misc/fire.wav");
- cgi_S_RegisterSound( "sound/chars/seeker/misc/hiss.wav");
- theFxScheduler.RegisterEffect( "env/small_explode");
+ cgi_S_RegisterSound("sound/chars/seeker/misc/hiss.wav");
+ theFxScheduler.RegisterEffect("env/small_explode");
- CG_RegisterWeapon( WP_BLASTER );
+ CG_RegisterWeapon(WP_BLASTER);
break;
case INV_SENTRY:
- CG_RegisterWeapon( WP_TURRET );
- cgi_S_RegisterSound( "sound/player/use_sentry" );
+ CG_RegisterWeapon(WP_TURRET);
+ cgi_S_RegisterSound("sound/player/use_sentry");
break;
case INV_ELECTROBINOCULARS:
// Binocular interface
- cgs.media.binocularCircle = cgi_R_RegisterShader( "gfx/2d/binCircle" );
- cgs.media.binocularMask = cgi_R_RegisterShader( "gfx/2d/binMask" );
- cgs.media.binocularArrow = cgi_R_RegisterShader( "gfx/2d/binSideArrow" );
- cgs.media.binocularTri = cgi_R_RegisterShader( "gfx/2d/binTopTri" );
- cgs.media.binocularStatic = cgi_R_RegisterShader( "gfx/2d/binocularWindow" );
- cgs.media.binocularOverlay = cgi_R_RegisterShader( "gfx/2d/binocularNumOverlay" );
+ cgs.media.binocularCircle = cgi_R_RegisterShader("gfx/2d/binCircle");
+ cgs.media.binocularMask = cgi_R_RegisterShader("gfx/2d/binMask");
+ cgs.media.binocularArrow = cgi_R_RegisterShader("gfx/2d/binSideArrow");
+ cgs.media.binocularTri = cgi_R_RegisterShader("gfx/2d/binTopTri");
+ cgs.media.binocularStatic = cgi_R_RegisterShader("gfx/2d/binocularWindow");
+ cgs.media.binocularOverlay = cgi_R_RegisterShader("gfx/2d/binocularNumOverlay");
break;
case INV_LIGHTAMP_GOGGLES:
// LA Goggles Shaders
- cgs.media.laGogglesStatic = cgi_R_RegisterShader( "gfx/2d/lagogglesWindow" );
- cgs.media.laGogglesMask = cgi_R_RegisterShader( "gfx/2d/amp_mask" );
- cgs.media.laGogglesSideBit = cgi_R_RegisterShader( "gfx/2d/side_bit" );
- cgs.media.laGogglesBracket = cgi_R_RegisterShader( "gfx/2d/bracket" );
- cgs.media.laGogglesArrow = cgi_R_RegisterShader( "gfx/2d/bracket2" );
+ cgs.media.laGogglesStatic = cgi_R_RegisterShader("gfx/2d/lagogglesWindow");
+ cgs.media.laGogglesMask = cgi_R_RegisterShader("gfx/2d/amp_mask");
+ cgs.media.laGogglesSideBit = cgi_R_RegisterShader("gfx/2d/side_bit");
+ cgs.media.laGogglesBracket = cgi_R_RegisterShader("gfx/2d/bracket");
+ cgs.media.laGogglesArrow = cgi_R_RegisterShader("gfx/2d/bracket2");
break;
case INV_BACTA_CANISTER:
- for ( int i = 1; i < 5; i++ )
- {
- cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_m.mp3", i ) );
- cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_f.mp3", i ) );
+ for (int i = 1; i < 5; i++) {
+ cgi_S_RegisterSound(va("sound/weapons/force/heal%d_m.mp3", i));
+ cgi_S_RegisterSound(va("sound/weapons/force/heal%d_f.mp3", i));
}
break;
}
}
}
-
/*
========================================================================================
@@ -746,19 +712,16 @@ the weapon hand animation has 3 anims,
if the torso anim does not match these lengths, it will not animate correctly!
=================
*/
-extern qboolean ValidAnimFileIndex ( int index );
-int CG_MapTorsoToWeaponFrame( const clientInfo_t *ci, int frame, int animNum, int weaponNum, int firing )
-{
+extern qboolean ValidAnimFileIndex(int index);
+int CG_MapTorsoToWeaponFrame(const clientInfo_t *ci, int frame, int animNum, int weaponNum, int firing) {
// we should use the animNum to map a weapon frame instead of relying on the torso frame
- if ( !ValidAnimFileIndex( ci->animFileIndex ) )
- {
+ if (!ValidAnimFileIndex(ci->animFileIndex)) {
return 0;
}
animation_t *animations = level.knownAnimFileSets[ci->animFileIndex].animations;
- int ret=0;
+ int ret = 0;
- switch( animNum )
- {
+ switch (animNum) {
case TORSO_WEAPONREADY1:
case TORSO_WEAPONREADY2:
case TORSO_WEAPONREADY3:
@@ -768,24 +731,18 @@ int CG_MapTorsoToWeaponFrame( const clientInfo_t *ci, int frame, int animNum, in
break;
case TORSO_DROPWEAP1:
- if ( frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 5 )
- {
+ if (frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 5) {
ret = frame - animations[animNum].firstFrame + 6;
- }
- else
- {
-// assert(0);
+ } else {
+ // assert(0);
}
break;
case TORSO_RAISEWEAP1:
- if ( frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 4 )
- {
+ if (frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 4) {
ret = frame - animations[animNum].firstFrame + 6 + 5;
- }
- else
- {
-// assert(0);
+ } else {
+ // assert(0);
}
break;
@@ -793,13 +750,10 @@ int CG_MapTorsoToWeaponFrame( const clientInfo_t *ci, int frame, int animNum, in
case BOTH_ATTACK2:
case BOTH_ATTACK3:
case BOTH_ATTACK4:
- if ( frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 6 )
- {
- ret = 1 + ( frame - animations[animNum].firstFrame );
- }
- else
- {
-// assert(0);
+ if (frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 6) {
+ ret = 1 + (frame - animations[animNum].firstFrame);
+ } else {
+ // assert(0);
}
break;
default:
@@ -814,17 +768,16 @@ int CG_MapTorsoToWeaponFrame( const clientInfo_t *ci, int frame, int animNum, in
CG_CalculateWeaponPosition
==============
*/
-void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles )
-{
- float scale;
- int delta;
- float fracsin;
+void CG_CalculateWeaponPosition(vec3_t origin, vec3_t angles) {
+ float scale;
+ int delta;
+ float fracsin;
- VectorCopy( cg.refdef.vieworg, origin );
- VectorCopy( cg.refdefViewAngles, angles );
+ VectorCopy(cg.refdef.vieworg, origin);
+ VectorCopy(cg.refdefViewAngles, angles);
// on odd legs, invert some angles
- if ( cg.bobcycle & 1 ) {
+ if (cg.bobcycle & 1) {
scale = -cg.xyspeed;
} else {
scale = cg.xyspeed;
@@ -837,11 +790,10 @@ void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles )
// drop the weapon when landing
delta = cg.time - cg.landTime;
- if ( delta < LAND_DEFLECT_TIME ) {
- origin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;
- } else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) {
- origin[2] += cg.landChange*0.25 *
- (LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME;
+ if (delta < LAND_DEFLECT_TIME) {
+ origin[2] += cg.landChange * 0.25 * delta / LAND_DEFLECT_TIME;
+ } else if (delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME) {
+ origin[2] += cg.landChange * 0.25 * (LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME;
}
#if 0
@@ -855,11 +807,11 @@ void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles )
#endif
// idle drift
- scale = /*cg.xyspeed + */40;
- fracsin = sin( cg.time * 0.001 );
+ scale = /*cg.xyspeed + */ 40;
+ fracsin = sin(cg.time * 0.001);
angles[ROLL] += scale * fracsin * 0.01;
angles[YAW] += scale * fracsin * 0.01;
- angles[PITCH] += (scale * 0.5f ) * fracsin * 0.01;
+ angles[PITCH] += (scale * 0.5f) * fracsin * 0.01;
}
/*
@@ -900,57 +852,44 @@ static float CG_MachinegunSpinAngle( centity_t *cent ) {
Ghoul2 Insert Start
*/
// set up the appropriate ghoul2 info to a refent
-void CG_SetGhoul2InfoRef( refEntity_t *ent, refEntity_t *s1)
-{
+void CG_SetGhoul2InfoRef(refEntity_t *ent, refEntity_t *s1) {
ent->ghoul2 = s1->ghoul2;
- VectorCopy( s1->modelScale, ent->modelScale);
+ VectorCopy(s1->modelScale, ent->modelScale);
ent->radius = s1->radius;
- VectorCopy( s1->angles, ent->angles);
+ VectorCopy(s1->angles, ent->angles);
}
-
//--------------------------------------------------------------------------
-static void CG_DoMuzzleFlash( centity_t *cent, vec3_t org, vec3_t dir, weaponData_t *wData )
-{
+static void CG_DoMuzzleFlash(centity_t *cent, vec3_t org, vec3_t dir, weaponData_t *wData) {
// Handle muzzle flashes, really this could just be a qboolean instead of a time.......
- if ( cent->muzzleFlashTime > 0 )
- {
- cent->muzzleFlashTime = 0;
+ if (cent->muzzleFlashTime > 0) {
+ cent->muzzleFlashTime = 0;
const char *effect = NULL;
-// CG_PositionEntityOnTag( &flash, &gun, gun.hModel, "tag_flash");
+ // CG_PositionEntityOnTag( &flash, &gun, gun.hModel, "tag_flash");
// Try and get a default muzzle so we have one to fall back on
- if ( wData->mMuzzleEffect[0] )
- {
+ if (wData->mMuzzleEffect[0]) {
effect = &wData->mMuzzleEffect[0];
}
- if ( cent->altFire )
- {
+ if (cent->altFire) {
// We're alt-firing, so see if we need to override with a custom alt-fire effect
- if ( wData->mAltMuzzleEffect[0] )
- {
+ if (wData->mAltMuzzleEffect[0]) {
effect = &wData->mAltMuzzleEffect[0];
}
}
- if (/*( cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING ) &&*/ effect )
- {
- if (( cent->gent && cent->gent->NPC ) || cg.renderingThirdPerson )
- {
- theFxScheduler.PlayEffect( effect, org, dir );
- }
- else
- {
+ if (/*( cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING ) &&*/ effect) {
+ if ((cent->gent && cent->gent->NPC) || cg.renderingThirdPerson) {
+ theFxScheduler.PlayEffect(effect, org, dir);
+ } else {
// We got an effect and we're firing, so let 'er rip.
- theFxScheduler.PlayEffect( effect, cent->currentState.clientNum );
+ theFxScheduler.PlayEffect(effect, cent->currentState.clientNum);
}
}
- }
- else
- {
-// CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash", NULL);
+ } else {
+ // CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash", NULL);
}
}
@@ -965,95 +904,84 @@ CG_AddViewWeapon
Add the weapon, and flash for the player's view
==============
*/
-extern int PM_TorsoAnimForFrame( gentity_t *ent, int torsoFrame );
-extern float CG_ForceSpeedFOV( void );
-
-void CG_AddViewWeapon( playerState_t *ps )
-{
- refEntity_t hand;
- refEntity_t flash;
- vec3_t angles;
- const weaponInfo_t *weapon;
- weaponData_t *wData;
- centity_t *cent;
- float fovOffset, leanOffset;
+extern int PM_TorsoAnimForFrame(gentity_t *ent, int torsoFrame);
+extern float CG_ForceSpeedFOV(void);
+
+void CG_AddViewWeapon(playerState_t *ps) {
+ refEntity_t hand;
+ refEntity_t flash;
+ vec3_t angles;
+ const weaponInfo_t *weapon;
+ weaponData_t *wData;
+ centity_t *cent;
+ float fovOffset, leanOffset;
// no gun if in third person view
- if ( cg.renderingThirdPerson )
+ if (cg.renderingThirdPerson)
return;
- if ( ps->pm_type == PM_INTERMISSION )
+ if (ps->pm_type == PM_INTERMISSION)
return;
cent = &cg_entities[ps->clientNum];
- if ( ps->eFlags & EF_LOCKED_TO_WEAPON )
- {
+ if (ps->eFlags & EF_LOCKED_TO_WEAPON) {
return;
}
- if ( cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive&(1<pe.torso.pitchAngle, cent->pe.torso.yawAngle, 0 );
+ if (cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive & (1 << FP_LIGHTNING)) { // doing the electrocuting
+ vec3_t temp; // tAng, fxDir,
+ // VectorSet( tAng, cent->pe.torso.pitchAngle, cent->pe.torso.yawAngle, 0 );
- VectorCopy( cent->gent->client->renderInfo.handLPoint, temp );
- VectorMA( temp, -5, cg.refdef.viewaxis[0], temp );
- if ( cent->gent->client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_2 )
- {//arc
- //vec3_t fxAxis[3];
- //AnglesToAxis( tAng, fxAxis );
- theFxScheduler.PlayEffect( cgs.effects.forceLightningWide, temp, cg.refdef.viewaxis );
- }
- else
- {//line
- //AngleVectors( tAng, fxDir, NULL, NULL );
- theFxScheduler.PlayEffect( cgs.effects.forceLightning, temp, cg.refdef.viewaxis[0] );
+ VectorCopy(cent->gent->client->renderInfo.handLPoint, temp);
+ VectorMA(temp, -5, cg.refdef.viewaxis[0], temp);
+ if (cent->gent->client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_2) { // arc
+ // vec3_t fxAxis[3];
+ // AnglesToAxis( tAng, fxAxis );
+ theFxScheduler.PlayEffect(cgs.effects.forceLightningWide, temp, cg.refdef.viewaxis);
+ } else { // line
+ // AngleVectors( tAng, fxDir, NULL, NULL );
+ theFxScheduler.PlayEffect(cgs.effects.forceLightning, temp, cg.refdef.viewaxis[0]);
}
}
- if ( cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive&(1<pe.torso.pitchAngle, cent->pe.torso.yawAngle, 0 );
+ if (cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive & (1 << FP_DRAIN)) { // doing the draining
+ vec3_t temp; // tAng, fxDir,
+ // VectorSet( tAng, cent->pe.torso.pitchAngle, cent->pe.torso.yawAngle, 0 );
- VectorCopy( cent->gent->client->renderInfo.handLPoint, temp );
- VectorMA( temp, -5, cg.refdef.viewaxis[0], temp );
- if ( cent->gent->client->ps.forcePowerLevel[FP_DRAIN] > FORCE_LEVEL_2 )
- {//arc
- //vec3_t fxAxis[3];
- //AnglesToAxis( tAng, fxAxis );
- theFxScheduler.PlayEffect( cgs.effects.forceDrainWide, temp, cg.refdef.viewaxis );
- }
- else
- {//line
- //AngleVectors( tAng, fxDir, NULL, NULL );
- theFxScheduler.PlayEffect( cgs.effects.forceDrain, temp, cg.refdef.viewaxis[0] );
+ VectorCopy(cent->gent->client->renderInfo.handLPoint, temp);
+ VectorMA(temp, -5, cg.refdef.viewaxis[0], temp);
+ if (cent->gent->client->ps.forcePowerLevel[FP_DRAIN] > FORCE_LEVEL_2) { // arc
+ // vec3_t fxAxis[3];
+ // AnglesToAxis( tAng, fxAxis );
+ theFxScheduler.PlayEffect(cgs.effects.forceDrainWide, temp, cg.refdef.viewaxis);
+ } else { // line
+ // AngleVectors( tAng, fxDir, NULL, NULL );
+ theFxScheduler.PlayEffect(cgs.effects.forceDrain, temp, cg.refdef.viewaxis[0]);
}
}
// allow the gun to be completely removed
- if ( !cg_drawGun.integer || cg.zoomMode )
- {
- vec3_t origin;
+ if (!cg_drawGun.integer || cg.zoomMode) {
+ vec3_t origin;
// special hack for lightning guns...
- VectorCopy( cg.refdef.vieworg, origin );
- VectorMA( origin, -10, cg.refdef.viewaxis[2], origin );
- VectorMA( origin, 16, cg.refdef.viewaxis[0], origin );
-// Doesn't look like we'll have lightning style guns. Clean this crap up when we are sure about this.
-// CG_LightningBolt( cent, origin );
+ VectorCopy(cg.refdef.vieworg, origin);
+ VectorMA(origin, -10, cg.refdef.viewaxis[2], origin);
+ VectorMA(origin, 16, cg.refdef.viewaxis[0], origin);
+ // Doesn't look like we'll have lightning style guns. Clean this crap up when we are sure about this.
+ // CG_LightningBolt( cent, origin );
// We should still do muzzle flashes though...
- CG_RegisterWeapon( ps->weapon );
+ CG_RegisterWeapon(ps->weapon);
weapon = &cg_weapons[ps->weapon];
- wData = &weaponData[ps->weapon];
+ wData = &weaponData[ps->weapon];
- CG_DoMuzzleFlash( cent, origin, cg.refdef.viewaxis[0], wData );
+ CG_DoMuzzleFlash(cent, origin, cg.refdef.viewaxis[0], wData);
// If we don't update this, the muzzle flash point won't even be updated properly
- VectorCopy( origin, cent->gent->client->renderInfo.muzzlePoint );
- VectorCopy( cg.refdef.viewaxis[0], cent->gent->client->renderInfo.muzzleDir );
+ VectorCopy(origin, cent->gent->client->renderInfo.muzzlePoint);
+ VectorCopy(cg.refdef.viewaxis[0], cent->gent->client->renderInfo.muzzleDir);
cent->gent->client->renderInfo.mPCalcTime = cg.time;
return;
@@ -1061,305 +989,258 @@ void CG_AddViewWeapon( playerState_t *ps )
// drop gun lower at higher fov
float actualFOV;
- if ( (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )//cg.renderingThirdPerson &&
+ if ((cg.snap->ps.forcePowersActive & (1 << FP_SPEED)) && player->client->ps.forcePowerDuration[FP_SPEED]) // cg.renderingThirdPerson &&
{
actualFOV = CG_ForceSpeedFOV();
- }
- else
- {
- if ( cg.overrides.active & CG_OVERRIDE_FOV )
+ } else {
+ if (cg.overrides.active & CG_OVERRIDE_FOV)
actualFOV = cg.overrides.fov;
else {
actualFOV = cg_fovViewmodel.integer ? cg_fovViewmodel.value : cg_fov.value;
}
}
- if ( cg_fovViewmodelAdjust.integer && actualFOV > 90 )
- fovOffset = -0.1 * ( actualFOV - 80 );
+ if (cg_fovViewmodelAdjust.integer && actualFOV > 90)
+ fovOffset = -0.1 * (actualFOV - 80);
else
fovOffset = 0;
- if ( ps->leanofs != 0 )
- { //add leaning offset
+ if (ps->leanofs != 0) { // add leaning offset
leanOffset = ps->leanofs * 0.25f;
fovOffset += abs(ps->leanofs) * -0.1f;
- }
- else
- {
+ } else {
leanOffset = 0;
}
- CG_RegisterWeapon( ps->weapon );
+ CG_RegisterWeapon(ps->weapon);
weapon = &cg_weapons[ps->weapon];
- wData = &weaponData[ps->weapon];
+ wData = &weaponData[ps->weapon];
- memset (&hand, 0, sizeof(hand));
+ memset(&hand, 0, sizeof(hand));
- if ( ps->weapon == WP_STUN_BATON || ps->weapon == WP_CONCUSSION )
- {
- cgi_S_AddLoopingSound( cent->currentState.number,
- cent->lerpOrigin,
- vec3_origin,
- weapon->firingSound );
+ if (ps->weapon == WP_STUN_BATON || ps->weapon == WP_CONCUSSION) {
+ cgi_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->firingSound);
}
// set up gun position
- CG_CalculateWeaponPosition( hand.origin, angles );
+ CG_CalculateWeaponPosition(hand.origin, angles);
vec3_t extraOffset;
extraOffset[0] = extraOffset[1] = extraOffset[2] = 0.0f;
- if( ps->weapon == WP_TUSKEN_RIFLE || ps->weapon == WP_NOGHRI_STICK || ps->weapon == WP_TUSKEN_STAFF )
- {
+ if (ps->weapon == WP_TUSKEN_RIFLE || ps->weapon == WP_NOGHRI_STICK || ps->weapon == WP_TUSKEN_STAFF) {
extraOffset[0] = 2;
extraOffset[1] = -3;
extraOffset[2] = -6;
}
- VectorMA( hand.origin, cg_gun_x.value+extraOffset[0], cg.refdef.viewaxis[0], hand.origin );
- VectorMA( hand.origin, (cg_gun_y.value+leanOffset+extraOffset[1]), cg.refdef.viewaxis[1], hand.origin );
- VectorMA( hand.origin, (cg_gun_z.value+fovOffset+extraOffset[2]), cg.refdef.viewaxis[2], hand.origin );
- //VectorMA( hand.origin, 0, cg.refdef.viewaxis[0], hand.origin );
- //VectorMA( hand.origin, (0+leanOffset), cg.refdef.viewaxis[1], hand.origin );
- //VectorMA( hand.origin, (0+fovOffset), cg.refdef.viewaxis[2], hand.origin );
-
- AnglesToAxis( angles, hand.axis );
+ VectorMA(hand.origin, cg_gun_x.value + extraOffset[0], cg.refdef.viewaxis[0], hand.origin);
+ VectorMA(hand.origin, (cg_gun_y.value + leanOffset + extraOffset[1]), cg.refdef.viewaxis[1], hand.origin);
+ VectorMA(hand.origin, (cg_gun_z.value + fovOffset + extraOffset[2]), cg.refdef.viewaxis[2], hand.origin);
+ // VectorMA( hand.origin, 0, cg.refdef.viewaxis[0], hand.origin );
+ // VectorMA( hand.origin, (0+leanOffset), cg.refdef.viewaxis[1], hand.origin );
+ // VectorMA( hand.origin, (0+fovOffset), cg.refdef.viewaxis[2], hand.origin );
+ AnglesToAxis(angles, hand.axis);
- if ( cg_fovViewmodel.integer ) {
- float fracDistFOV = tanf( cg.refdef.fov_x * ( M_PI/180 ) * 0.5f );
- float fracWeapFOV = (1.0f / fracDistFOV) * tanf( actualFOV * (M_PI / 180) * 0.5f );
- VectorScale( hand.axis[0], fracWeapFOV, hand.axis[0] );
+ if (cg_fovViewmodel.integer) {
+ float fracDistFOV = tanf(cg.refdef.fov_x * (M_PI / 180) * 0.5f);
+ float fracWeapFOV = (1.0f / fracDistFOV) * tanf(actualFOV * (M_PI / 180) * 0.5f);
+ VectorScale(hand.axis[0], fracWeapFOV, hand.axis[0]);
}
// map torso animations to weapon animations
#ifndef FINAL_BUILD
- if ( cg_gun_frame.integer )
- {
+ if (cg_gun_frame.integer) {
// development tool
hand.frame = hand.oldframe = cg_gun_frame.integer;
hand.backlerp = 0;
- }
- else
+ } else
#endif
{
// get clientinfo for animation map
- const clientInfo_t *ci = ¢->gent->client->clientInfo;
- int torsoAnim = cent->gent->client->ps.torsoAnim;//pe.torso.animationNumber;
+ const clientInfo_t *ci = ¢->gent->client->clientInfo;
+ int torsoAnim = cent->gent->client->ps.torsoAnim; // pe.torso.animationNumber;
float currentFrame;
- int startFrame,endFrame,flags;
+ int startFrame, endFrame, flags;
float animSpeed;
- if (cent->gent->lowerLumbarBone>=0&& gi.G2API_GetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->lowerLumbarBone, cg.time, ¤tFrame, &startFrame, &endFrame, &flags, &animSpeed,0) )
- {
- hand.oldframe = CG_MapTorsoToWeaponFrame( ci,floor(currentFrame), torsoAnim, cent->currentState.weapon, ( cent->currentState.eFlags & EF_FIRING ) );
- hand.frame = CG_MapTorsoToWeaponFrame( ci,ceil(currentFrame), torsoAnim, cent->currentState.weapon, ( cent->currentState.eFlags & EF_FIRING ) );
- hand.backlerp=1.0f-(currentFrame-floor(currentFrame));
- if ( cg_debugAnim.integer == 1 && cent->currentState.clientNum == 0 )
- {
- Com_Printf( "Torso frame %d to %d makes Weapon frame %d to %d\n", cent->pe.torso.oldFrame, cent->pe.torso.frame, hand.oldframe, hand.frame );
+ if (cent->gent->lowerLumbarBone >= 0 && gi.G2API_GetBoneAnimIndex(¢->gent->ghoul2[cent->gent->playerModel], cent->gent->lowerLumbarBone, cg.time,
+ ¤tFrame, &startFrame, &endFrame, &flags, &animSpeed, 0)) {
+ hand.oldframe = CG_MapTorsoToWeaponFrame(ci, floor(currentFrame), torsoAnim, cent->currentState.weapon, (cent->currentState.eFlags & EF_FIRING));
+ hand.frame = CG_MapTorsoToWeaponFrame(ci, ceil(currentFrame), torsoAnim, cent->currentState.weapon, (cent->currentState.eFlags & EF_FIRING));
+ hand.backlerp = 1.0f - (currentFrame - floor(currentFrame));
+ if (cg_debugAnim.integer == 1 && cent->currentState.clientNum == 0) {
+ Com_Printf("Torso frame %d to %d makes Weapon frame %d to %d\n", cent->pe.torso.oldFrame, cent->pe.torso.frame, hand.oldframe, hand.frame);
}
- }
- else
- {
-// assert(0); // no idea what to do here
- hand.oldframe=0;
- hand.frame=0;
- hand.backlerp=0.0f;
+ } else {
+ // assert(0); // no idea what to do here
+ hand.oldframe = 0;
+ hand.frame = 0;
+ hand.backlerp = 0.0f;
}
}
// add the weapon(s) - FIXME: allow for 2 weapons generically, not just 2 sabers?
- int numSabers = 1;
- if ( cent->gent->client->ps.dualSabers )
- {
+ int numSabers = 1;
+ if (cent->gent->client->ps.dualSabers) {
numSabers = 2;
}
- for ( int saberNum = 0; saberNum < numSabers; saberNum++ )
- {
- refEntity_t gun;
- memset (&gun, 0, sizeof(gun));
+ for (int saberNum = 0; saberNum < numSabers; saberNum++) {
+ refEntity_t gun;
+ memset(&gun, 0, sizeof(gun));
gun.hModel = weapon->weaponModel;
- if (!gun.hModel)
- {
+ if (!gun.hModel) {
return;
}
- AnglesToAxis( angles, gun.axis );
- CG_PositionEntityOnTag( &gun, &hand, weapon->handsModel, "tag_weapon");
+ AnglesToAxis(angles, gun.axis);
+ CG_PositionEntityOnTag(&gun, &hand, weapon->handsModel, "tag_weapon");
gun.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON;
- //---------
+ //---------
// OK, we are making an assumption here that if we have the phaser that it is always on....
- //FIXME: if saberInFlight, need to draw empty hand guiding it
- if ( cent->gent && cent->gent->client && cent->currentState.weapon == WP_SABER )
- {
+ // FIXME: if saberInFlight, need to draw empty hand guiding it
+ if (cent->gent && cent->gent->client && cent->currentState.weapon == WP_SABER) {
vec3_t org_, axis_[3];
- for ( int bladeNum = 0; bladeNum < cent->gent->client->ps.saber[saberNum].numBlades; bladeNum++ )
- {
- //FIXME: need to get from tag_flash2 for saberstaff's second blade?
- CG_GetTagWorldPosition( &gun, "tag_flash", org_, axis_ );
- //loop this and do for both blades
- if ( cent->gent->client->ps.saber[0].blade[0].active && cent->gent->client->ps.saber[0].blade[0].length < cent->gent->client->ps.saber[0].blade[0].lengthMax )
- {
- cent->gent->client->ps.saber[0].blade[0].length += cg.frametime*0.03;
- if ( cent->gent->client->ps.saber[0].blade[0].length > cent->gent->client->ps.saber[0].blade[0].lengthMax )
- {
+ for (int bladeNum = 0; bladeNum < cent->gent->client->ps.saber[saberNum].numBlades; bladeNum++) {
+ // FIXME: need to get from tag_flash2 for saberstaff's second blade?
+ CG_GetTagWorldPosition(&gun, "tag_flash", org_, axis_);
+ // loop this and do for both blades
+ if (cent->gent->client->ps.saber[0].blade[0].active &&
+ cent->gent->client->ps.saber[0].blade[0].length < cent->gent->client->ps.saber[0].blade[0].lengthMax) {
+ cent->gent->client->ps.saber[0].blade[0].length += cg.frametime * 0.03;
+ if (cent->gent->client->ps.saber[0].blade[0].length > cent->gent->client->ps.saber[0].blade[0].lengthMax) {
cent->gent->client->ps.saber[0].blade[0].length = cent->gent->client->ps.saber[0].blade[0].lengthMax;
}
}
- // FX_Saber( org_, axis_[0], cent->gent->client->ps.saberLength, 2.0 + Q_flrand(-1.0f, 1.0f) * 0.2f, cent->gent->client->ps.saberColor );
- if ( saberNum == 0 && bladeNum == 0 )
- {
- VectorCopy( axis_[0], cent->gent->client->renderInfo.muzzleDir );
- }
- else
- {//need these points stored here when in 1st person saber
+ // FX_Saber( org_, axis_[0], cent->gent->client->ps.saberLength, 2.0 + Q_flrand(-1.0f, 1.0f) * 0.2f, cent->gent->client->ps.saberColor );
+ if (saberNum == 0 && bladeNum == 0) {
+ VectorCopy(axis_[0], cent->gent->client->renderInfo.muzzleDir);
+ } else { // need these points stored here when in 1st person saber
VectorCopy(org_, cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzlePoint);
}
- VectorCopy( axis_[0], cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzleDir );
+ VectorCopy(axis_[0], cent->gent->client->ps.saber[saberNum].blade[bladeNum].muzzleDir);
}
}
//---------
// CG_AddRefEntityWithPowerups( &gun, cent->currentState.powerups, cent->gent );
- cgi_R_AddRefEntityToScene( &gun );
+ cgi_R_AddRefEntityToScene(&gun);
- /* if ( ps->weapon == WP_STUN_BATON )
- {
- gun.shaderRGBA[0] = gun.shaderRGBA[1] = gun.shaderRGBA[2] = 25;
+ /* if ( ps->weapon == WP_STUN_BATON )
+ {
+ gun.shaderRGBA[0] = gun.shaderRGBA[1] = gun.shaderRGBA[2] = 25;
- gun.customShader = cgi_R_RegisterShader( "gfx/effects/stunPass" );
- gun.renderfx = RF_RGB_TINT | RF_FIRST_PERSON | RF_DEPTHHACK;
- cgi_R_AddRefEntityToScene( &gun );
- }
- */
+ gun.customShader = cgi_R_RegisterShader( "gfx/effects/stunPass" );
+ gun.renderfx = RF_RGB_TINT | RF_FIRST_PERSON | RF_DEPTHHACK;
+ cgi_R_AddRefEntityToScene( &gun );
+ }
+ */
// add the spinning barrel[s]
- for (int i = 0; (i < wData->numBarrels); i++)
- {
- refEntity_t barrel;
- memset( &barrel, 0, sizeof( barrel ) );
+ for (int i = 0; (i < wData->numBarrels); i++) {
+ refEntity_t barrel;
+ memset(&barrel, 0, sizeof(barrel));
barrel.hModel = weapon->barrelModel[i];
- //VectorCopy( parent->lightingOrigin, barrel.lightingOrigin );
- //barrel.shadowPlane = parent->shadowPlane;
+ // VectorCopy( parent->lightingOrigin, barrel.lightingOrigin );
+ // barrel.shadowPlane = parent->shadowPlane;
barrel.renderfx = gun.renderfx;
angles[YAW] = 0;
angles[PITCH] = 0;
- // if ( ps->weapon == WP_TETRION_DISRUPTOR) {
- // angles[ROLL] = CG_MachinegunSpinAngle( cent );
- // } else {
- angles[ROLL] = 0;//CG_MachinegunSpinAngle( cent );
- // }
-
- AnglesToAxis( angles, barrel.axis );
- if (!i)
- {
- CG_PositionRotatedEntityOnTag( &barrel, &hand, weapon->handsModel, "tag_barrel", NULL );
- } else
- {
- CG_PositionRotatedEntityOnTag( &barrel, &hand, weapon->handsModel, va("tag_barrel%d",i+1), NULL );
+ // if ( ps->weapon == WP_TETRION_DISRUPTOR) {
+ // angles[ROLL] = CG_MachinegunSpinAngle( cent );
+ // } else {
+ angles[ROLL] = 0; // CG_MachinegunSpinAngle( cent );
+ // }
+
+ AnglesToAxis(angles, barrel.axis);
+ if (!i) {
+ CG_PositionRotatedEntityOnTag(&barrel, &hand, weapon->handsModel, "tag_barrel", NULL);
+ } else {
+ CG_PositionRotatedEntityOnTag(&barrel, &hand, weapon->handsModel, va("tag_barrel%d", i + 1), NULL);
}
- cgi_R_AddRefEntityToScene( &barrel );
+ cgi_R_AddRefEntityToScene(&barrel);
}
- memset (&flash, 0, sizeof(flash));
+ memset(&flash, 0, sizeof(flash));
// Seems like we should always do this in case we have an animating muzzle flash....that way we can always store the correct muzzle dir, etc.
- CG_PositionEntityOnTag( &flash, &gun, gun.hModel, "tag_flash");
+ CG_PositionEntityOnTag(&flash, &gun, gun.hModel, "tag_flash");
- CG_DoMuzzleFlash( cent, flash.origin, flash.axis[0], wData );
+ CG_DoMuzzleFlash(cent, flash.origin, flash.axis[0], wData);
- if ( cent->gent && cent->gent->client )
- {
- if ( saberNum == 0 )
- {
+ if (cent->gent && cent->gent->client) {
+ if (saberNum == 0) {
VectorCopy(flash.origin, cent->gent->client->renderInfo.muzzlePoint);
VectorCopy(flash.axis[0], cent->gent->client->renderInfo.muzzleDir);
}
- // VectorNormalize( cent->gent->client->renderInfo.muzzleDir );
+ // VectorNormalize( cent->gent->client->renderInfo.muzzleDir );
cent->gent->client->renderInfo.mPCalcTime = cg.time;
- //CG_LightningBolt( cent, flash.origin );
+ // CG_LightningBolt( cent, flash.origin );
}
}
// Do special charge bits
//-----------------------
- if (( ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BRYAR_PISTOL )
- || ( ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BLASTER_PISTOL )
- || ( ps->weapon == WP_BOWCASTER && ps->weaponstate == WEAPON_CHARGING )
- || ( ps->weapon == WP_DEMP2 && ps->weaponstate == WEAPON_CHARGING_ALT ))
- {
- int shader = 0;
- float val = 0.0f, scale = 1.0f;
- vec3_t WHITE = {1.0f,1.0f,1.0f};
-
- if ( ps->weapon == WP_BRYAR_PISTOL
- || ps->weapon == WP_BLASTER_PISTOL )
- {
+ if ((ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BRYAR_PISTOL) ||
+ (ps->weaponstate == WEAPON_CHARGING_ALT && ps->weapon == WP_BLASTER_PISTOL) || (ps->weapon == WP_BOWCASTER && ps->weaponstate == WEAPON_CHARGING) ||
+ (ps->weapon == WP_DEMP2 && ps->weaponstate == WEAPON_CHARGING_ALT)) {
+ int shader = 0;
+ float val = 0.0f, scale = 1.0f;
+ vec3_t WHITE = {1.0f, 1.0f, 1.0f};
+
+ if (ps->weapon == WP_BRYAR_PISTOL || ps->weapon == WP_BLASTER_PISTOL) {
// Hardcoded max charge time of 1 second
- val = ( cg.time - ps->weaponChargeTime ) * 0.001f;
- shader = cgi_R_RegisterShader( "gfx/effects/bryarFrontFlash" );
- }
- else if ( ps->weapon == WP_BOWCASTER )
- {
+ val = (cg.time - ps->weaponChargeTime) * 0.001f;
+ shader = cgi_R_RegisterShader("gfx/effects/bryarFrontFlash");
+ } else if (ps->weapon == WP_BOWCASTER) {
// Hardcoded max charge time of 1 second
- val = ( cg.time - ps->weaponChargeTime ) * 0.001f;
- shader = cgi_R_RegisterShader( "gfx/effects/greenFrontFlash" );
- }
- else if ( ps->weapon == WP_DEMP2 )
- {
+ val = (cg.time - ps->weaponChargeTime) * 0.001f;
+ shader = cgi_R_RegisterShader("gfx/effects/greenFrontFlash");
+ } else if (ps->weapon == WP_DEMP2) {
// Hardcoded max charge time of 1 second
- val = ( cg.time - ps->weaponChargeTime ) * 0.001f;
- shader = cgi_R_RegisterShader( "gfx/misc/lightningFlash" );
+ val = (cg.time - ps->weaponChargeTime) * 0.001f;
+ shader = cgi_R_RegisterShader("gfx/misc/lightningFlash");
scale = 1.75f;
}
- if ( val < 0.0f )
- {
+ if (val < 0.0f) {
val = 0.0f;
- }
- else if ( val > 1.0f )
- {
+ } else if (val > 1.0f) {
val = 1.0f;
- CGCam_Shake( 0.1f, 100 );
- }
- else
- {
- CGCam_Shake( val * val * 0.3f, 100 );
+ CGCam_Shake(0.1f, 100);
+ } else {
+ CGCam_Shake(val * val * 0.3f, 100);
}
val += Q_flrand(0.0f, 1.0f) * 0.5f;
- FX_AddSprite( flash.origin, NULL, NULL, 3.0f * val * scale, 0.0f, 0.7f, 0.7f, WHITE, WHITE, Q_flrand(0.0f, 1.0f) * 360, 0.0f, 1.0f, shader, FX_USE_ALPHA | FX_DEPTH_HACK );
+ FX_AddSprite(flash.origin, NULL, NULL, 3.0f * val * scale, 0.0f, 0.7f, 0.7f, WHITE, WHITE, Q_flrand(0.0f, 1.0f) * 360, 0.0f, 1.0f, shader,
+ FX_USE_ALPHA | FX_DEPTH_HACK);
}
// Check if the heavy repeater is finishing up a sustained burst
//-------------------------------
- if ( ps->weapon == WP_REPEATER && ps->weaponstate == WEAPON_FIRING )
- {
- if ( cent->gent && cent->gent->client && cent->gent->client->ps.weaponstate != WEAPON_FIRING )
- {
- int ct = 0;
+ if (ps->weapon == WP_REPEATER && ps->weaponstate == WEAPON_FIRING) {
+ if (cent->gent && cent->gent->client && cent->gent->client->ps.weaponstate != WEAPON_FIRING) {
+ int ct = 0;
// the more continuous shots we've got, the more smoke we spawn
- if ( cent->gent->client->ps.weaponShotCount > 60 ) {
+ if (cent->gent->client->ps.weaponShotCount > 60) {
ct = 5;
- }
- else if ( cent->gent->client->ps.weaponShotCount > 35 ) {
+ } else if (cent->gent->client->ps.weaponShotCount > 35) {
ct = 3;
- }
- else if ( cent->gent->client->ps.weaponShotCount > 15 ) {
+ } else if (cent->gent->client->ps.weaponShotCount > 15) {
ct = 1;
}
- for ( int i = 0; i < ct; i++ )
- {
- theFxScheduler.PlayEffect( "repeater/muzzle_smoke", cent->currentState.clientNum );
+ for (int i = 0; i < ct; i++) {
+ theFxScheduler.PlayEffect("repeater/muzzle_smoke", cent->currentState.clientNum);
}
cent->gent->client->ps.weaponShotCount = 0;
@@ -1380,55 +1261,35 @@ WEAPON SELECTION
CG_WeaponCheck
===================
*/
-int CG_WeaponCheck( int weaponIndex )
-{
- int value;
+int CG_WeaponCheck(int weaponIndex) {
+ int value;
- if ( weaponIndex == WP_SABER)
- {
+ if (weaponIndex == WP_SABER) {
return qtrue;
}
+ value = weaponData[weaponIndex].energyPerShot < weaponData[weaponIndex].altEnergyPerShot ? weaponData[weaponIndex].energyPerShot
+ : weaponData[weaponIndex].altEnergyPerShot;
- value = weaponData[weaponIndex].energyPerShot < weaponData[weaponIndex].altEnergyPerShot
- ? weaponData[weaponIndex].energyPerShot
- : weaponData[weaponIndex].altEnergyPerShot;
-
- if( !cg.snap )
- {
+ if (!cg.snap) {
return qfalse;
}
// check how much energy(ammo) it takes to fire this weapon against how much ammo we have
- if ( value > cg.snap->ps.ammo[weaponData[weaponIndex].ammoIndex] )
- {
+ if (value > cg.snap->ps.ammo[weaponData[weaponIndex].ammoIndex]) {
value = qfalse;
- }
- else
- {
+ } else {
value = qtrue;
}
return value;
}
-int cgi_UI_GetItemText(char *menuFile,char *itemName, char *text);
+int cgi_UI_GetItemText(char *menuFile, char *itemName, char *text);
-const char *weaponDesc[13] =
-{
-"SABER_DESC",
-"NEW_BLASTER_PISTOL_DESC",
-"BLASTER_RIFLE_DESC",
-"DISRUPTOR_RIFLE_DESC",
-"BOWCASTER_DESC",
-"HEAVYREPEATER_DESC",
-"DEMP2_DESC",
-"FLECHETTE_DESC",
-"MERR_SONN_DESC",
-"THERMAL_DETONATOR_DESC",
-"TRIP_MINE_DESC",
-"DET_PACK_DESC",
-"CONCUSSION_DESC",
+const char *weaponDesc[13] = {
+ "SABER_DESC", "NEW_BLASTER_PISTOL_DESC", "BLASTER_RIFLE_DESC", "DISRUPTOR_RIFLE_DESC", "BOWCASTER_DESC", "HEAVYREPEATER_DESC", "DEMP2_DESC",
+ "FLECHETTE_DESC", "MERR_SONN_DESC", "THERMAL_DETONATOR_DESC", "TRIP_MINE_DESC", "DET_PACK_DESC", "CONCUSSION_DESC",
};
/*
@@ -1438,77 +1299,65 @@ CG_DrawDataPadWeaponSelect
Allows user to cycle through the various weapons currently owned and view the description
===================
*/
-void CG_DrawDataPadWeaponSelect( void )
-{
- int i;
- int weaponBitFlag,weaponCount,weaponSelectI;
- int holdX;
- int sideLeftIconCnt,sideRightIconCnt;
- int holdCount,iconCnt;
- char text[1024]={0};
+void CG_DrawDataPadWeaponSelect(void) {
+ int i;
+ int weaponBitFlag, weaponCount, weaponSelectI;
+ int holdX;
+ int sideLeftIconCnt, sideRightIconCnt;
+ int holdCount, iconCnt;
+ char text[1024] = {0};
qboolean drewConc = qfalse;
// showing weapon select clears pickup item display, but not the blend blob
cg.itemPickupTime = 0;
- weaponBitFlag = cg.snap->ps.stats[ STAT_WEAPONS ];
+ weaponBitFlag = cg.snap->ps.stats[STAT_WEAPONS];
// count the number of weapons owned
weaponCount = 0;
- for ( i = 1 ; i < 16 ; i++ )
- {
- if ( weaponBitFlag & ( 1 << i ) )
- {
+ for (i = 1; i < 16; i++) {
+ if (weaponBitFlag & (1 << i)) {
weaponCount++;
}
}
- if (weaponCount == 0) // If no weapons, don't display
+ if (weaponCount == 0) // If no weapons, don't display
{
return;
}
- const short sideMax = 3; // Max number of icons on the side
+ const short sideMax = 3; // Max number of icons on the side
// Calculate how many icons will appear to either side of the center one
- holdCount = weaponCount - 1; // -1 for the center icon
- if (holdCount == 0) // No icons to either side
+ holdCount = weaponCount - 1; // -1 for the center icon
+ if (holdCount == 0) // No icons to either side
{
sideLeftIconCnt = 0;
sideRightIconCnt = 0;
- }
- else if (weaponCount > (2*sideMax)) // Go to the max on each side
+ } else if (weaponCount > (2 * sideMax)) // Go to the max on each side
{
sideLeftIconCnt = sideMax;
sideRightIconCnt = sideMax;
- }
- else // Less than max, so do the calc
+ } else // Less than max, so do the calc
{
- sideLeftIconCnt = holdCount/2;
+ sideLeftIconCnt = holdCount / 2;
sideRightIconCnt = holdCount - sideLeftIconCnt;
}
// This seems to be a problem if datapad comes up too early
- if (cg.DataPadWeaponSelect13)
- {
+ } else if (cg.DataPadWeaponSelect > 13) {
cg.DataPadWeaponSelect = 13;
}
// What weapon does the player currently have selected
- if ( cg.DataPadWeaponSelect == WP_CONCUSSION )
- {
+ if (cg.DataPadWeaponSelect == WP_CONCUSSION) {
weaponSelectI = WP_FLECHETTE;
- }
- else
- {
+ } else {
weaponSelectI = cg.DataPadWeaponSelect - 1;
}
- if (weaponSelectI<1)
- {
+ if (weaponSelectI < 1) {
weaponSelectI = 13;
}
@@ -1520,60 +1369,48 @@ void CG_DrawDataPadWeaponSelect( void )
const int centerXPos = 320;
const int graphicYPos = 340;
-
// Left side ICONS
// Work backwards from current icon
- holdX = centerXPos - ((bigIconSize/2) + bigPad + smallIconSize);
+ holdX = centerXPos - ((bigIconSize / 2) + bigPad + smallIconSize);
- cgi_R_SetColor( colorTable[CT_WHITE] );
- for (iconCnt=1;iconCnt<(sideLeftIconCnt+1);weaponSelectI--)
- {
- if ( weaponSelectI == WP_CONCUSSION )
- {
+ cgi_R_SetColor(colorTable[CT_WHITE]);
+ for (iconCnt = 1; iconCnt < (sideLeftIconCnt + 1); weaponSelectI--) {
+ if (weaponSelectI == WP_CONCUSSION) {
weaponSelectI--;
- }
- else if ( weaponSelectI == WP_FLECHETTE && !drewConc && cg.DataPadWeaponSelect != WP_CONCUSSION )
- {
+ } else if (weaponSelectI == WP_FLECHETTE && !drewConc && cg.DataPadWeaponSelect != WP_CONCUSSION) {
weaponSelectI = WP_CONCUSSION;
}
- if (weaponSelectI<1)
- {
+ if (weaponSelectI < 1) {
weaponSelectI = 13;
}
- if ( !(weaponBitFlag & ( 1 << weaponSelectI ))) // Does he have this weapon?
+ if (!(weaponBitFlag & (1 << weaponSelectI))) // Does he have this weapon?
{
- if ( weaponSelectI == WP_CONCUSSION )
- {
+ if (weaponSelectI == WP_CONCUSSION) {
drewConc = qtrue;
weaponSelectI = WP_ROCKET_LAUNCHER;
}
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (weaponData[weaponSelectI].weaponIcon[0])
- {
- weaponInfo_t *weaponInfo;
- CG_RegisterWeapon( weaponSelectI );
+ if (weaponData[weaponSelectI].weaponIcon[0]) {
+ weaponInfo_t *weaponInfo;
+ CG_RegisterWeapon(weaponSelectI);
weaponInfo = &cg_weapons[weaponSelectI];
- if (!CG_WeaponCheck(weaponSelectI))
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo );
- }
- else
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIcon );
+ if (!CG_WeaponCheck(weaponSelectI)) {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo);
+ } else {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIcon);
}
- holdX -= (smallIconSize+pad);
+ holdX -= (smallIconSize + pad);
}
- if ( weaponSelectI == WP_CONCUSSION )
- {
+ if (weaponSelectI == WP_CONCUSSION) {
drewConc = qtrue;
weaponSelectI = WP_ROCKET_LAUNCHER;
}
@@ -1582,116 +1419,90 @@ void CG_DrawDataPadWeaponSelect( void )
// Current Center Icon
cgi_R_SetColor(colorTable[CT_WHITE]);
- if (weaponData[cg.DataPadWeaponSelect].weaponIcon[0])
- {
- weaponInfo_t *weaponInfo;
- CG_RegisterWeapon( cg.DataPadWeaponSelect );
+ if (weaponData[cg.DataPadWeaponSelect].weaponIcon[0]) {
+ weaponInfo_t *weaponInfo;
+ CG_RegisterWeapon(cg.DataPadWeaponSelect);
weaponInfo = &cg_weapons[cg.DataPadWeaponSelect];
- // Draw graphic to show weapon has ammo or no ammo
- if (!CG_WeaponCheck(cg.DataPadWeaponSelect))
- {
- CG_DrawPic( centerXPos-(bigIconSize/2), (graphicYPos-((bigIconSize-smallIconSize)/2))+10, bigIconSize, bigIconSize, weaponInfo->weaponIconNoAmmo );
- }
- else
- {
- CG_DrawPic( centerXPos-(bigIconSize/2), (graphicYPos-((bigIconSize-smallIconSize)/2))+10, bigIconSize, bigIconSize, weaponInfo->weaponIcon );
+ // Draw graphic to show weapon has ammo or no ammo
+ if (!CG_WeaponCheck(cg.DataPadWeaponSelect)) {
+ CG_DrawPic(centerXPos - (bigIconSize / 2), (graphicYPos - ((bigIconSize - smallIconSize) / 2)) + 10, bigIconSize, bigIconSize,
+ weaponInfo->weaponIconNoAmmo);
+ } else {
+ CG_DrawPic(centerXPos - (bigIconSize / 2), (graphicYPos - ((bigIconSize - smallIconSize) / 2)) + 10, bigIconSize, bigIconSize,
+ weaponInfo->weaponIcon);
}
}
- if ( cg.DataPadWeaponSelect == WP_CONCUSSION )
- {
+ if (cg.DataPadWeaponSelect == WP_CONCUSSION) {
weaponSelectI = WP_ROCKET_LAUNCHER;
- }
- else
- {
+ } else {
weaponSelectI = cg.DataPadWeaponSelect + 1;
}
- if (weaponSelectI> 13)
- {
+ if (weaponSelectI > 13) {
weaponSelectI = 1;
}
// Right side ICONS
// Work forwards from current icon
cgi_R_SetColor(colorTable[CT_WHITE]);
- holdX = centerXPos + (bigIconSize/2) + bigPad;
- for (iconCnt=1;iconCnt<(sideRightIconCnt+1);weaponSelectI++)
- {
- if ( weaponSelectI == WP_CONCUSSION )
- {
+ holdX = centerXPos + (bigIconSize / 2) + bigPad;
+ for (iconCnt = 1; iconCnt < (sideRightIconCnt + 1); weaponSelectI++) {
+ if (weaponSelectI == WP_CONCUSSION) {
weaponSelectI++;
- }
- else if ( weaponSelectI == WP_ROCKET_LAUNCHER && !drewConc && cg.DataPadWeaponSelect != WP_CONCUSSION )
- {
+ } else if (weaponSelectI == WP_ROCKET_LAUNCHER && !drewConc && cg.DataPadWeaponSelect != WP_CONCUSSION) {
weaponSelectI = WP_CONCUSSION;
}
- if (weaponSelectI>13)
- {
+ if (weaponSelectI > 13) {
weaponSelectI = 1;
}
- if ( !(weaponBitFlag & ( 1 << weaponSelectI ))) // Does he have this weapon?
+ if (!(weaponBitFlag & (1 << weaponSelectI))) // Does he have this weapon?
{
- if ( weaponSelectI == WP_CONCUSSION )
- {
+ if (weaponSelectI == WP_CONCUSSION) {
drewConc = qtrue;
weaponSelectI = WP_FLECHETTE;
}
continue;
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (weaponData[weaponSelectI].weaponIcon[0])
- {
- weaponInfo_t *weaponInfo;
- CG_RegisterWeapon( weaponSelectI );
+ if (weaponData[weaponSelectI].weaponIcon[0]) {
+ weaponInfo_t *weaponInfo;
+ CG_RegisterWeapon(weaponSelectI);
weaponInfo = &cg_weapons[weaponSelectI];
// Draw graphic to show weapon has ammo or no ammo
- if (!CG_WeaponCheck(i))
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo );
- }
- else
- {
- CG_DrawPic( holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIcon );
+ if (!CG_WeaponCheck(i)) {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo);
+ } else {
+ CG_DrawPic(holdX, graphicYPos, smallIconSize, smallIconSize, weaponInfo->weaponIcon);
}
-
- holdX += (smallIconSize+pad);
+ holdX += (smallIconSize + pad);
}
- if ( weaponSelectI == WP_CONCUSSION )
- {
+ if (weaponSelectI == WP_CONCUSSION) {
drewConc = qtrue;
weaponSelectI = WP_FLECHETTE;
}
}
// Print the weapon description
- cgi_SP_GetStringTextString( va("SP_INGAME_%s",weaponDesc[cg.DataPadWeaponSelect-1]), text, sizeof(text) );
+ cgi_SP_GetStringTextString(va("SP_INGAME_%s", weaponDesc[cg.DataPadWeaponSelect - 1]), text, sizeof(text));
- if (text[0])
- {
+ if (text[0]) {
const short textboxXPos = 40;
const short textboxYPos = 60;
- const int textboxWidth = 560;
- const int textboxHeight = 300;
- const float textScale = 1.0f;
+ const int textboxWidth = 560;
+ const int textboxHeight = 300;
+ const float textScale = 1.0f;
- CG_DisplayBoxedText(
- textboxXPos, textboxYPos,
- textboxWidth, textboxHeight,
- text,
- 4,
- textScale,
- colorTable[CT_WHITE]
- );
+ CG_DisplayBoxedText(textboxXPos, textboxYPos, textboxWidth, textboxHeight, text, 4, textScale, colorTable[CT_WHITE]);
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
/*
@@ -1701,43 +1512,42 @@ CG_DrawDataPadIconBackground
Draw the proper background graphic for the icons being displayed on the datapad
===================
*/
-void CG_DrawDataPadIconBackground(const int backgroundType)
-{
-// const int graphicXPos = 40;
-// const int graphicYPos = 340;
-// const short graphicHeight = 60;
-// const short graphicWidth = 560;
-// qhandle_t background;
+void CG_DrawDataPadIconBackground(const int backgroundType) {
+ // const int graphicXPos = 40;
+ // const int graphicYPos = 340;
+ // const short graphicHeight = 60;
+ // const short graphicWidth = 560;
+ // qhandle_t background;
-/*
- if (backgroundType == ICON_INVENTORY) // Display inventory background?
- {
- background = cgs.media.inventoryIconBackground;
- }
- else if (backgroundType == ICON_WEAPONS) // Display weapon background?
- {
- background = cgs.media.weaponIconBackground;
- }
- else // Display force background?
- {
- background = cgs.media.forceIconBackground;
- }
+ /*
+ if (backgroundType == ICON_INVENTORY) // Display inventory background?
+ {
+ background = cgs.media.inventoryIconBackground;
+ }
+ else if (backgroundType == ICON_WEAPONS) // Display weapon background?
+ {
+ background = cgs.media.weaponIconBackground;
+ }
+ else // Display force background?
+ {
+ background = cgs.media.forceIconBackground;
+ }
- cgi_R_SetColor( colorTable[CT_WHITE] ); // Let the graphic set the color
+ cgi_R_SetColor( colorTable[CT_WHITE] ); // Let the graphic set the color
- CG_DrawPic( graphicXPos,
- graphicYPos+(graphicHeight/2),
- graphicWidth,
- -graphicHeight,
- background); // Top half
+ CG_DrawPic( graphicXPos,
+ graphicYPos+(graphicHeight/2),
+ graphicWidth,
+ -graphicHeight,
+ background); // Top half
- CG_DrawPic( graphicXPos,
- graphicYPos+(graphicHeight/2),
- graphicWidth,
- graphicHeight,
- background); // Bottom half
+ CG_DrawPic( graphicXPos,
+ graphicYPos+(graphicHeight/2),
+ graphicWidth,
+ graphicHeight,
+ background); // Bottom half
-*/
+ */
}
/*
@@ -1745,18 +1555,15 @@ void CG_DrawDataPadIconBackground(const int backgroundType)
SetWeaponSelectTime
===============
*/
-void SetWeaponSelectTime(void)
-{
+void SetWeaponSelectTime(void) {
- if (((cg.inventorySelectTime + WEAPON_SELECT_TIME) > cg.time) || // The Inventory HUD was currently active to just swap it out with Force HUD
- ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) > cg.time)) // The Force HUD was currently active to just swap it out with Force HUD
+ if (((cg.inventorySelectTime + WEAPON_SELECT_TIME) > cg.time) || // The Inventory HUD was currently active to just swap it out with Force HUD
+ ((cg.forcepowerSelectTime + WEAPON_SELECT_TIME) > cg.time)) // The Force HUD was currently active to just swap it out with Force HUD
{
cg.inventorySelectTime = 0;
cg.forcepowerSelectTime = 0;
cg.weaponSelectTime = cg.time + 130.0f;
- }
- else
- {
+ } else {
cg.weaponSelectTime = cg.time;
}
}
@@ -1766,90 +1573,79 @@ void SetWeaponSelectTime(void)
CG_DrawWeaponSelect
===================
*/
-extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent );
-extern bool G_IsRidingTurboVehicle( gentity_t *ent );
-
-void CG_DrawWeaponSelect( void )
-{
- int i;
- int bits;
- int count;
- int smallIconSize,bigIconSize;
- int holdX,x,y,x2,y2,w2,h2,pad;
- int sideLeftIconCnt,sideRightIconCnt;
- int sideMax,holdCount,iconCnt;
- //int height;
- vec4_t calcColor;
- vec4_t textColor = { .875f, .718f, .121f, 1.0f };
- int yOffset = 0;
- bool isOnVeh = false;
+extern Vehicle_t *G_IsRidingVehicle(gentity_t *ent);
+extern bool G_IsRidingTurboVehicle(gentity_t *ent);
+
+void CG_DrawWeaponSelect(void) {
+ int i;
+ int bits;
+ int count;
+ int smallIconSize, bigIconSize;
+ int holdX, x, y, x2, y2, w2, h2, pad;
+ int sideLeftIconCnt, sideRightIconCnt;
+ int sideMax, holdCount, iconCnt;
+ // int height;
+ vec4_t calcColor;
+ vec4_t textColor = {.875f, .718f, .121f, 1.0f};
+ int yOffset = 0;
+ bool isOnVeh = false;
qboolean drewConc = qfalse;
- if ((cg.weaponSelectTime+WEAPON_SELECT_TIME)ps.stats[ STAT_WEAPONS ];
+ bits = cg.snap->ps.stats[STAT_WEAPONS];
// count the number of weapons owned
count = 0;
- isOnVeh = (G_IsRidingVehicle(cg_entities[0].gent)!=0);
- for ( i = 1 ; i < MAX_PLAYER_WEAPONS ; i++ )
- {
- if ((bits & ( 1 << i )) &&
- (!isOnVeh || i==WP_NONE || i==WP_SABER || i==WP_BLASTER))
- {
+ isOnVeh = (G_IsRidingVehicle(cg_entities[0].gent) != 0);
+ for (i = 1; i < MAX_PLAYER_WEAPONS; i++) {
+ if ((bits & (1 << i)) && (!isOnVeh || i == WP_NONE || i == WP_SABER || i == WP_BLASTER)) {
count++;
}
}
- if (count == 0) // If no weapons, don't display
+ if (count == 0) // If no weapons, don't display
{
return;
}
- sideMax = 3; // Max number of icons on the side
+ sideMax = 3; // Max number of icons on the side
// Calculate how many icons will appear to either side of the center one
- holdCount = count - 1; // -1 for the center icon
- if (holdCount == 0) // No icons to either side
+ holdCount = count - 1; // -1 for the center icon
+ if (holdCount == 0) // No icons to either side
{
sideLeftIconCnt = 0;
sideRightIconCnt = 0;
- }
- else if (count > (2*sideMax)) // Go to the max on each side
+ } else if (count > (2 * sideMax)) // Go to the max on each side
{
sideLeftIconCnt = sideMax;
sideRightIconCnt = sideMax;
- }
- else // Less than max, so do the calc
+ } else // Less than max, so do the calc
{
- sideLeftIconCnt = holdCount/2;
+ sideLeftIconCnt = holdCount / 2;
sideRightIconCnt = holdCount - sideLeftIconCnt;
}
- if ( cg.weaponSelect == WP_CONCUSSION )
- {
+ if (cg.weaponSelect == WP_CONCUSSION) {
i = WP_FLECHETTE;
- }
- else
- {
+ } else {
i = cg.weaponSelect - 1;
}
- if (i<1)
- {
+ if (i < 1) {
i = MAX_PLAYER_WEAPONS;
}
@@ -1857,8 +1653,7 @@ void CG_DrawWeaponSelect( void )
bigIconSize = 80;
pad = 12;
- if (!cgi_UI_GetMenuInfo("weaponselecthud",&x2,&y2,&w2,&h2))
- {
+ if (!cgi_UI_GetMenuInfo("weaponselecthud", &x2, &y2, &w2, &h2)) {
return;
}
x = 320;
@@ -1867,244 +1662,194 @@ void CG_DrawWeaponSelect( void )
// Background
memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t));
calcColor[3] = .60f;
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
// Left side ICONS
- cgi_R_SetColor( calcColor);
+ cgi_R_SetColor(calcColor);
// Work backwards from current icon
- holdX = x - ((bigIconSize/2) + pad + smallIconSize);
- //height = smallIconSize * cg.iconHUDPercent;
+ holdX = x - ((bigIconSize / 2) + pad + smallIconSize);
+ // height = smallIconSize * cg.iconHUDPercent;
drewConc = qfalse;
- for (iconCnt=1;iconCnt<(sideLeftIconCnt+1);i--)
- {
- if ( i == WP_CONCUSSION )
- {
+ for (iconCnt = 1; iconCnt < (sideLeftIconCnt + 1); i--) {
+ if (i == WP_CONCUSSION) {
i--;
- }
- else if ( i == WP_FLECHETTE && !drewConc && cg.weaponSelect != WP_CONCUSSION )
- {
+ } else if (i == WP_FLECHETTE && !drewConc && cg.weaponSelect != WP_CONCUSSION) {
i = WP_CONCUSSION;
}
- if (i<1)
- {
+ if (i < 1) {
i = MAX_PLAYER_WEAPONS;
}
- if ( !(bits & ( 1 << i ))) // Does he have this weapon?
+ if (!(bits & (1 << i))) // Does he have this weapon?
{
- if ( i == WP_CONCUSSION )
- {
+ if (i == WP_CONCUSSION) {
drewConc = qtrue;
i = WP_ROCKET_LAUNCHER;
}
continue;
}
- if (isOnVeh)
- {
- if ( i != WP_NONE && i!=WP_SABER && i!=WP_BLASTER )
- {
- if ( i == WP_CONCUSSION )
- {
+ if (isOnVeh) {
+ if (i != WP_NONE && i != WP_SABER && i != WP_BLASTER) {
+ if (i == WP_CONCUSSION) {
drewConc = qtrue;
i = WP_ROCKET_LAUNCHER;
}
- continue; // Don't draw anything else if on a vehicle
+ continue; // Don't draw anything else if on a vehicle
}
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (weaponData[i].weaponIcon[0])
- {
- weaponInfo_t *weaponInfo;
- CG_RegisterWeapon( i );
+ if (weaponData[i].weaponIcon[0]) {
+ weaponInfo_t *weaponInfo;
+ CG_RegisterWeapon(i);
weaponInfo = &cg_weapons[i];
- if (!CG_WeaponCheck(i))
- {
- CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo );
- }
- else
- {
- CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIcon );
+ if (!CG_WeaponCheck(i)) {
+ CG_DrawPic(holdX, y + 10 + yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo);
+ } else {
+ CG_DrawPic(holdX, y + 10 + yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIcon);
}
- holdX -= (smallIconSize+pad);
+ holdX -= (smallIconSize + pad);
}
- if ( i == WP_CONCUSSION )
- {
+ if (i == WP_CONCUSSION) {
drewConc = qtrue;
i = WP_ROCKET_LAUNCHER;
}
}
// Current Center Icon
- //height = bigIconSize * cg.iconHUDPercent;
+ // height = bigIconSize * cg.iconHUDPercent;
cgi_R_SetColor(NULL);
- if (weaponData[cg.weaponSelect].weaponIcon[0])
- {
- weaponInfo_t *weaponInfo;
- CG_RegisterWeapon( cg.weaponSelect );
+ if (weaponData[cg.weaponSelect].weaponIcon[0]) {
+ weaponInfo_t *weaponInfo;
+ CG_RegisterWeapon(cg.weaponSelect);
weaponInfo = &cg_weapons[cg.weaponSelect];
- if (!CG_WeaponCheck(cg.weaponSelect))
- {
- CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10+yOffset, bigIconSize, bigIconSize, weaponInfo->weaponIconNoAmmo );
- }
- else
- {
- CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10+yOffset, bigIconSize, bigIconSize, weaponInfo->weaponIcon );
+ if (!CG_WeaponCheck(cg.weaponSelect)) {
+ CG_DrawPic(x - (bigIconSize / 2), (y - ((bigIconSize - smallIconSize) / 2)) + 10 + yOffset, bigIconSize, bigIconSize, weaponInfo->weaponIconNoAmmo);
+ } else {
+ CG_DrawPic(x - (bigIconSize / 2), (y - ((bigIconSize - smallIconSize) / 2)) + 10 + yOffset, bigIconSize, bigIconSize, weaponInfo->weaponIcon);
}
}
- if ( cg.weaponSelect == WP_CONCUSSION )
- {
+ if (cg.weaponSelect == WP_CONCUSSION) {
i = WP_ROCKET_LAUNCHER;
- }
- else
- {
+ } else {
i = cg.weaponSelect + 1;
}
- if (i> MAX_PLAYER_WEAPONS)
- {
+ if (i > MAX_PLAYER_WEAPONS) {
i = 1;
}
// Right side ICONS
// Work forwards from current icon
- cgi_R_SetColor( calcColor);
- holdX = x + (bigIconSize/2) + pad;
- //height = smallIconSize * cg.iconHUDPercent;
+ cgi_R_SetColor(calcColor);
+ holdX = x + (bigIconSize / 2) + pad;
+ // height = smallIconSize * cg.iconHUDPercent;
drewConc = qfalse;
- for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++)
- {
- if ( i == WP_CONCUSSION )
- {
+ for (iconCnt = 1; iconCnt < (sideRightIconCnt + 1); i++) {
+ if (i == WP_CONCUSSION) {
i++;
- }
- else if ( i == WP_ROCKET_LAUNCHER && !drewConc && cg.weaponSelect != WP_CONCUSSION )
- {
+ } else if (i == WP_ROCKET_LAUNCHER && !drewConc && cg.weaponSelect != WP_CONCUSSION) {
i = WP_CONCUSSION;
}
- if (i>MAX_PLAYER_WEAPONS)
- {
+ if (i > MAX_PLAYER_WEAPONS) {
i = 1;
}
- if ( !(bits & ( 1 << i ))) // Does he have this weapon?
+ if (!(bits & (1 << i))) // Does he have this weapon?
{
- if ( i == WP_CONCUSSION )
- {
+ if (i == WP_CONCUSSION) {
drewConc = qtrue;
i = WP_FLECHETTE;
}
continue;
}
- if (isOnVeh)
- {
- if ( i != WP_NONE && i!=WP_SABER && i!=WP_BLASTER )
- {
- if ( i == WP_CONCUSSION )
- {
+ if (isOnVeh) {
+ if (i != WP_NONE && i != WP_SABER && i != WP_BLASTER) {
+ if (i == WP_CONCUSSION) {
drewConc = qtrue;
i = WP_FLECHETTE;
}
- continue; // Don't draw anything else if on a vehicle
+ continue; // Don't draw anything else if on a vehicle
}
}
- ++iconCnt; // Good icon
+ ++iconCnt; // Good icon
- if (weaponData[i].weaponIcon[0])
- {
- weaponInfo_t *weaponInfo;
- CG_RegisterWeapon( i );
+ if (weaponData[i].weaponIcon[0]) {
+ weaponInfo_t *weaponInfo;
+ CG_RegisterWeapon(i);
weaponInfo = &cg_weapons[i];
// No ammo for this weapon?
- if (!CG_WeaponCheck(i))
- {
- CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo );
- }
- else
- {
- CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIcon );
+ if (!CG_WeaponCheck(i)) {
+ CG_DrawPic(holdX, y + 10 + yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo);
+ } else {
+ CG_DrawPic(holdX, y + 10 + yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIcon);
}
-
- holdX += (smallIconSize+pad);
+ holdX += (smallIconSize + pad);
}
- if ( i == WP_CONCUSSION )
- {
+ if (i == WP_CONCUSSION) {
drewConc = qtrue;
i = WP_FLECHETTE;
}
}
- gitem_t *item = cg_weapons[ cg.weaponSelect ].item;
+ gitem_t *item = cg_weapons[cg.weaponSelect].item;
// draw the selected name
- if ( item && item->classname && item->classname[0] )
- {
+ if (item && item->classname && item->classname[0]) {
char text[1024];
- if ( cgi_SP_GetStringTextString( va("SP_INGAME_%s",item->classname), text, sizeof( text )))
- {
+ if (cgi_SP_GetStringTextString(va("SP_INGAME_%s", item->classname), text, sizeof(text))) {
int w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f);
- int x = ( SCREEN_WIDTH - w ) / 2;
- cgi_R_Font_DrawString(x, (SCREEN_HEIGHT - 24)+yOffset, text, textColor, cgs.media.qhFontSmall, -1, 1.0f);
+ int x = (SCREEN_WIDTH - w) / 2;
+ cgi_R_Font_DrawString(x, (SCREEN_HEIGHT - 24) + yOffset, text, textColor, cgs.media.qhFontSmall, -1, 1.0f);
}
}
- cgi_R_SetColor( NULL );
+ cgi_R_SetColor(NULL);
}
-
/*
===============
CG_WeaponSelectable
===============
*/
-qboolean CG_WeaponSelectable( int i, int original, qboolean dpMode )
-{
- int usage_for_weap;
+qboolean CG_WeaponSelectable(int i, int original, qboolean dpMode) {
+ int usage_for_weap;
- if (i > MAX_PLAYER_WEAPONS)
- {
+ if (i > MAX_PLAYER_WEAPONS) {
#ifndef FINAL_BUILD
- Com_Printf("CG_WeaponSelectable() passed illegal index of %d!\n",i);
+ Com_Printf("CG_WeaponSelectable() passed illegal index of %d!\n", i);
#endif
return qfalse;
}
- if ( cg.weaponSelectTime + 200 > cg.time )
- {//TEMP standard weapon cycle debounce for E3 because G2 can't keep up with fast weapon changes
+ if (cg.weaponSelectTime + 200 > cg.time) { // TEMP standard weapon cycle debounce for E3 because G2 can't keep up with fast weapon changes
return qfalse;
}
- //FIXME: this doesn't work below, can still cycle too fast!
- if ( original == WP_SABER && cg.weaponSelectTime + 500 > cg.time )
- {//when switch to lightsaber, have to stay there for at least half a second!
+ // FIXME: this doesn't work below, can still cycle too fast!
+ if (original == WP_SABER && cg.weaponSelectTime + 500 > cg.time) { // when switch to lightsaber, have to stay there for at least half a second!
return qfalse;
}
- if ( G_IsRidingVehicle(cg_entities[0].gent) )
- {
- if (G_IsRidingTurboVehicle(cg_entities[0].gent) || (i!=WP_NONE && i!=WP_SABER && i!=WP_BLASTER) )
- {
+ if (G_IsRidingVehicle(cg_entities[0].gent)) {
+ if (G_IsRidingTurboVehicle(cg_entities[0].gent) || (i != WP_NONE && i != WP_SABER && i != WP_BLASTER)) {
return qfalse;
}
}
- if (( weaponData[i].ammoIndex != AMMO_NONE ) && !dpMode )
- {//weapon uses ammo, see if we have any
- usage_for_weap = weaponData[i].energyPerShot < weaponData[i].altEnergyPerShot
- ? weaponData[i].energyPerShot
- : weaponData[i].altEnergyPerShot;
+ if ((weaponData[i].ammoIndex != AMMO_NONE) && !dpMode) { // weapon uses ammo, see if we have any
+ usage_for_weap = weaponData[i].energyPerShot < weaponData[i].altEnergyPerShot ? weaponData[i].energyPerShot : weaponData[i].altEnergyPerShot;
- if ( cg.snap->ps.ammo[weaponData[i].ammoIndex] - usage_for_weap < 0 )
- {
- if ( i != WP_DET_PACK ) // detpack can be switched to...should possibly check if there are any stuck to a wall somewhere?
+ if (cg.snap->ps.ammo[weaponData[i].ammoIndex] - usage_for_weap < 0) {
+ if (i != WP_DET_PACK) // detpack can be switched to...should possibly check if there are any stuck to a wall somewhere?
{
// This weapon doesn't have enough ammo to shoot either the main or the alt-fire
return qfalse;
@@ -2112,8 +1857,7 @@ qboolean CG_WeaponSelectable( int i, int original, qboolean dpMode )
}
}
- if (!(cg.snap->ps.stats[ STAT_WEAPONS ] & ( 1 << i )))
- {
+ if (!(cg.snap->ps.stats[STAT_WEAPONS] & (1 << i))) {
// Don't have this weapon to start with.
return qfalse;
}
@@ -2121,44 +1865,30 @@ qboolean CG_WeaponSelectable( int i, int original, qboolean dpMode )
return qtrue;
}
-void CG_ToggleATSTWeapon( void )
-{
- if ( cg.weaponSelect == WP_ATST_MAIN )
- {
+void CG_ToggleATSTWeapon(void) {
+ if (cg.weaponSelect == WP_ATST_MAIN) {
cg.weaponSelect = WP_ATST_SIDE;
- }
- else
- {
+ } else {
cg.weaponSelect = WP_ATST_MAIN;
}
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
SetWeaponSelectTime();
}
-void CG_PlayerLockedWeaponSpeech( int jumping )
-{
-extern qboolean Q3_TaskIDPending( gentity_t *ent, taskID_t taskType );
+void CG_PlayerLockedWeaponSpeech(int jumping) {
+ extern qboolean Q3_TaskIDPending(gentity_t * ent, taskID_t taskType);
static int speechDebounceTime = 0;
- if ( !in_camera )
- {//not in a cinematic
- if ( speechDebounceTime < cg.time )
- {//spoke more than 3 seconds ago
- if ( !Q3_TaskIDPending( &g_entities[0], TID_CHAN_VOICE ) )
- {//not waiting on a scripted sound to finish
- if( !jumping )
- {
- if( Q_flrand(0.0f, 1.0f) > 0.5 )
- {
- G_SoundOnEnt( player, CHAN_VOICE, va( "sound/chars/kyle/09kyk015.wav" ));
- }
- else
- {
- G_SoundOnEnt( player, CHAN_VOICE, va( "sound/chars/kyle/09kyk016.wav" ));
+ if (!in_camera) { // not in a cinematic
+ if (speechDebounceTime < cg.time) { // spoke more than 3 seconds ago
+ if (!Q3_TaskIDPending(&g_entities[0], TID_CHAN_VOICE)) { // not waiting on a scripted sound to finish
+ if (!jumping) {
+ if (Q_flrand(0.0f, 1.0f) > 0.5) {
+ G_SoundOnEnt(player, CHAN_VOICE, va("sound/chars/kyle/09kyk015.wav"));
+ } else {
+ G_SoundOnEnt(player, CHAN_VOICE, va("sound/chars/kyle/09kyk016.wav"));
}
- }
- else
- {
- G_SoundOnEnt( player, CHAN_VOICE, va( "sound/chars/kyle/16kyk007.wav" ));
+ } else {
+ G_SoundOnEnt(player, CHAN_VOICE, va("sound/chars/kyle/16kyk007.wav"));
}
speechDebounceTime = cg.time + 3000;
}
@@ -2170,11 +1900,11 @@ extern qboolean Q3_TaskIDPending( gentity_t *ent, taskID_t taskType );
CG_NextWeapon_f
===============
*/
-void CG_NextWeapon_f( void ) {
- int i;
- int original;
+void CG_NextWeapon_f(void) {
+ int i;
+ int original;
- if ( !cg.snap ) {
+ if (!cg.snap) {
return;
}
/*
@@ -2183,31 +1913,26 @@ void CG_NextWeapon_f( void ) {
}
*/
- if( g_entities[0].flags & FL_LOCK_PLAYER_WEAPONS )
- {
- CG_PlayerLockedWeaponSpeech( qfalse );
+ if (g_entities[0].flags & FL_LOCK_PLAYER_WEAPONS) {
+ CG_PlayerLockedWeaponSpeech(qfalse);
return;
}
- if( g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST )
- {
+ if (g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST) {
CG_ToggleATSTWeapon();
return;
}
- if ( cg.snap->ps.eFlags & EF_LOCKED_TO_WEAPON )
- {
+ if (cg.snap->ps.eFlags & EF_LOCKED_TO_WEAPON) {
// can't do any sort of weapon switching when in the emplaced gun
return;
}
- if ( cg.snap->ps.viewEntity )
- {
+ if (cg.snap->ps.viewEntity) {
// yeah, probably need a better check here
- if ( g_entities[cg.snap->ps.viewEntity].client && ( g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R5D2
- || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R2D2
- || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_MOUSE ))
- {
+ if (g_entities[cg.snap->ps.viewEntity].client &&
+ (g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R5D2 || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R2D2 ||
+ g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_MOUSE)) {
return;
}
}
@@ -2215,39 +1940,29 @@ void CG_NextWeapon_f( void ) {
original = cg.weaponSelect;
int firstWeapon = FIRST_WEAPON;
- if (G_IsRidingVehicle(&g_entities[cg.snap->ps.viewEntity]))
- {
- firstWeapon = 0; // include WP_NONE here
+ if (G_IsRidingVehicle(&g_entities[cg.snap->ps.viewEntity])) {
+ firstWeapon = 0; // include WP_NONE here
}
- for ( i = 0 ; i <= MAX_PLAYER_WEAPONS ; i++ )
- {
+ for (i = 0; i <= MAX_PLAYER_WEAPONS; i++) {
//*SIGH*... Hack to put concussion rifle before rocketlauncher
- if ( cg.weaponSelect == WP_FLECHETTE )
- {
+ if (cg.weaponSelect == WP_FLECHETTE) {
cg.weaponSelect = WP_CONCUSSION;
- }
- else if ( cg.weaponSelect == WP_CONCUSSION )
- {
+ } else if (cg.weaponSelect == WP_CONCUSSION) {
cg.weaponSelect = WP_ROCKET_LAUNCHER;
- }
- else if ( cg.weaponSelect == WP_DET_PACK )
- {
+ } else if (cg.weaponSelect == WP_DET_PACK) {
cg.weaponSelect = firstWeapon;
- }
- else
- {
+ } else {
cg.weaponSelect++;
}
- if ( cg.weaponSelect < firstWeapon || cg.weaponSelect > MAX_PLAYER_WEAPONS) {
+ if (cg.weaponSelect < firstWeapon || cg.weaponSelect > MAX_PLAYER_WEAPONS) {
cg.weaponSelect = firstWeapon;
}
- if ( CG_WeaponSelectable( cg.weaponSelect, original, qfalse ) )
- {
-// cg.weaponSelectTime = cg.time;
+ if (CG_WeaponSelectable(cg.weaponSelect, original, qfalse)) {
+ // cg.weaponSelectTime = cg.time;
SetWeaponSelectTime();
return;
}
@@ -2261,11 +1976,11 @@ void CG_NextWeapon_f( void ) {
CG_DPNextWeapon_f
===============
*/
-void CG_DPNextWeapon_f( void ) {
- int i;
- int original;
+void CG_DPNextWeapon_f(void) {
+ int i;
+ int original;
- if ( !cg.snap ) {
+ if (!cg.snap) {
return;
}
/*
@@ -2276,33 +1991,24 @@ void CG_DPNextWeapon_f( void ) {
original = cg.DataPadWeaponSelect;
- for ( i = 0 ; i <= MAX_PLAYER_WEAPONS ; i++ )
- {
+ for (i = 0; i <= MAX_PLAYER_WEAPONS; i++) {
//*SIGH*... Hack to put concussion rifle before rocketlauncher
- if ( cg.DataPadWeaponSelect == WP_FLECHETTE )
- {
+ if (cg.DataPadWeaponSelect == WP_FLECHETTE) {
cg.DataPadWeaponSelect = WP_CONCUSSION;
- }
- else if ( cg.DataPadWeaponSelect == WP_CONCUSSION )
- {
+ } else if (cg.DataPadWeaponSelect == WP_CONCUSSION) {
cg.DataPadWeaponSelect = WP_ROCKET_LAUNCHER;
- }
- else if ( cg.DataPadWeaponSelect == WP_DET_PACK )
- {
+ } else if (cg.DataPadWeaponSelect == WP_DET_PACK) {
cg.DataPadWeaponSelect = FIRST_WEAPON;
- }
- else
- {
+ } else {
cg.DataPadWeaponSelect++;
}
- if ( cg.DataPadWeaponSelect < FIRST_WEAPON || cg.DataPadWeaponSelect > MAX_PLAYER_WEAPONS) {
+ if (cg.DataPadWeaponSelect < FIRST_WEAPON || cg.DataPadWeaponSelect > MAX_PLAYER_WEAPONS) {
cg.DataPadWeaponSelect = FIRST_WEAPON;
}
- if ( CG_WeaponSelectable( cg.DataPadWeaponSelect, original, qtrue ) )
- {
+ if (CG_WeaponSelectable(cg.DataPadWeaponSelect, original, qtrue)) {
return;
}
}
@@ -2315,13 +2021,11 @@ void CG_DPNextWeapon_f( void ) {
CG_DPPrevWeapon_f
===============
*/
-void CG_DPPrevWeapon_f( void )
-{
- int i;
- int original;
+void CG_DPPrevWeapon_f(void) {
+ int i;
+ int original;
- if ( !cg.snap )
- {
+ if (!cg.snap) {
return;
}
@@ -2334,34 +2038,24 @@ void CG_DPPrevWeapon_f( void )
original = cg.DataPadWeaponSelect;
- for ( i = 0 ; i <= MAX_PLAYER_WEAPONS ; i++ )
- {
+ for (i = 0; i <= MAX_PLAYER_WEAPONS; i++) {
//*SIGH*... Hack to put concussion rifle before rocketlauncher
- if ( cg.DataPadWeaponSelect == WP_ROCKET_LAUNCHER )
- {
+ if (cg.DataPadWeaponSelect == WP_ROCKET_LAUNCHER) {
cg.DataPadWeaponSelect = WP_CONCUSSION;
- }
- else if ( cg.DataPadWeaponSelect == WP_CONCUSSION )
- {
+ } else if (cg.DataPadWeaponSelect == WP_CONCUSSION) {
cg.DataPadWeaponSelect = WP_FLECHETTE;
- }
- else if ( cg.DataPadWeaponSelect == WP_MELEE )
- {
+ } else if (cg.DataPadWeaponSelect == WP_MELEE) {
cg.DataPadWeaponSelect = WP_DET_PACK;
- }
- else
- {
+ } else {
cg.DataPadWeaponSelect--;
}
- if ( cg.DataPadWeaponSelect < FIRST_WEAPON || cg.DataPadWeaponSelect > MAX_PLAYER_WEAPONS)
- {
+ if (cg.DataPadWeaponSelect < FIRST_WEAPON || cg.DataPadWeaponSelect > MAX_PLAYER_WEAPONS) {
cg.DataPadWeaponSelect = MAX_PLAYER_WEAPONS;
}
- if ( CG_WeaponSelectable( cg.DataPadWeaponSelect, original, qtrue ) )
- {
+ if (CG_WeaponSelectable(cg.DataPadWeaponSelect, original, qtrue)) {
return;
}
}
@@ -2374,11 +2068,11 @@ void CG_DPPrevWeapon_f( void )
CG_PrevWeapon_f
===============
*/
-void CG_PrevWeapon_f( void ) {
- int i;
- int original;
+void CG_PrevWeapon_f(void) {
+ int i;
+ int original;
- if ( !cg.snap ) {
+ if (!cg.snap) {
return;
}
/*
@@ -2387,31 +2081,26 @@ void CG_PrevWeapon_f( void ) {
}
*/
- if( g_entities[0].flags & FL_LOCK_PLAYER_WEAPONS )
- {
- CG_PlayerLockedWeaponSpeech( qfalse );
+ if (g_entities[0].flags & FL_LOCK_PLAYER_WEAPONS) {
+ CG_PlayerLockedWeaponSpeech(qfalse);
return;
}
- if( g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST )
- {
+ if (g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST) {
CG_ToggleATSTWeapon();
return;
}
- if ( cg.snap->ps.eFlags & EF_LOCKED_TO_WEAPON )
- {
+ if (cg.snap->ps.eFlags & EF_LOCKED_TO_WEAPON) {
// can't do any sort of weapon switching when in the emplaced gun
return;
}
- if ( cg.snap->ps.viewEntity )
- {
+ if (cg.snap->ps.viewEntity) {
// yeah, probably need a better check here
- if ( g_entities[cg.snap->ps.viewEntity].client && ( g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R5D2
- || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R2D2
- || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_MOUSE ))
- {
+ if (g_entities[cg.snap->ps.viewEntity].client &&
+ (g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R5D2 || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R2D2 ||
+ g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_MOUSE)) {
return;
}
}
@@ -2419,40 +2108,30 @@ void CG_PrevWeapon_f( void ) {
original = cg.weaponSelect;
int firstWeapon = FIRST_WEAPON;
- if (G_IsRidingVehicle(&g_entities[cg.snap->ps.viewEntity]))
- {
- firstWeapon = 0; // include WP_NONE here
+ if (G_IsRidingVehicle(&g_entities[cg.snap->ps.viewEntity])) {
+ firstWeapon = 0; // include WP_NONE here
}
- for ( i = 0 ; i <= MAX_PLAYER_WEAPONS ; i++ ) {
+ for (i = 0; i <= MAX_PLAYER_WEAPONS; i++) {
//*SIGH*... Hack to put concussion rifle before rocketlauncher
- if ( cg.weaponSelect == WP_ROCKET_LAUNCHER )
- {
+ if (cg.weaponSelect == WP_ROCKET_LAUNCHER) {
cg.weaponSelect = WP_CONCUSSION;
- }
- else if ( cg.weaponSelect == WP_CONCUSSION )
- {
+ } else if (cg.weaponSelect == WP_CONCUSSION) {
cg.weaponSelect = WP_FLECHETTE;
- }
- else if ( cg.weaponSelect == WP_MELEE )
- {
+ } else if (cg.weaponSelect == WP_MELEE) {
cg.weaponSelect = WP_DET_PACK;
- }
- else
- {
+ } else {
cg.weaponSelect--;
}
-
- if ( cg.weaponSelect < firstWeapon || cg.weaponSelect > MAX_PLAYER_WEAPONS) {
+ if (cg.weaponSelect < firstWeapon || cg.weaponSelect > MAX_PLAYER_WEAPONS) {
cg.weaponSelect = MAX_PLAYER_WEAPONS;
}
- if ( CG_WeaponSelectable( cg.weaponSelect, original, qfalse ) )
- {
+ if (CG_WeaponSelectable(cg.weaponSelect, original, qfalse)) {
SetWeaponSelectTime();
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
return;
}
}
@@ -2465,46 +2144,38 @@ void CG_ChangeWeapon( int num )
Meant to be called from the normal game, so checks the game-side weapon inventory data
*/
-void CG_ChangeWeapon( int num )
-{
- gentity_t *player = &g_entities[0];
+void CG_ChangeWeapon(int num) {
+ gentity_t *player = &g_entities[0];
- if ( num < WP_NONE || num >= WP_NUM_WEAPONS )
- {
+ if (num < WP_NONE || num >= WP_NUM_WEAPONS) {
return;
}
- if( player->flags & FL_LOCK_PLAYER_WEAPONS )
- {
- CG_PlayerLockedWeaponSpeech( qfalse );
+ if (player->flags & FL_LOCK_PLAYER_WEAPONS) {
+ CG_PlayerLockedWeaponSpeech(qfalse);
return;
}
- if ( player->client != NULL && !(player->client->ps.stats[STAT_WEAPONS] & ( 1 << num )) )
- {
- return; // don't have the weapon
+ if (player->client != NULL && !(player->client->ps.stats[STAT_WEAPONS] & (1 << num))) {
+ return; // don't have the weapon
}
// because we don't have an empty hand model for the thermal, don't allow selecting that weapon if it has no ammo
- if ( num == WP_THERMAL )
- {
- if ( cg.snap && cg.snap->ps.ammo[AMMO_THERMAL] <= 0 )
- {
+ if (num == WP_THERMAL) {
+ if (cg.snap && cg.snap->ps.ammo[AMMO_THERMAL] <= 0) {
return;
}
}
// because we don't have an empty hand model for the thermal, don't allow selecting that weapon if it has no ammo
- if ( num == WP_TRIP_MINE )
- {
- if ( cg.snap && cg.snap->ps.ammo[AMMO_TRIPMINE] <= 0 )
- {
+ if (num == WP_TRIP_MINE) {
+ if (cg.snap && cg.snap->ps.ammo[AMMO_TRIPMINE] <= 0) {
return;
}
}
SetWeaponSelectTime();
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
cg.weaponSelect = num;
}
@@ -2513,16 +2184,14 @@ void CG_ChangeWeapon( int num )
CG_Weapon_f
===============
*/
-void CG_Weapon_f( void )
-{
- int num;
+void CG_Weapon_f(void) {
+ int num;
- if ( cg.weaponSelectTime + 200 > cg.time )
- {
+ if (cg.weaponSelectTime + 200 > cg.time) {
return;
}
- if ( !cg.snap ) {
+ if (!cg.snap) {
return;
}
/*
@@ -2531,114 +2200,90 @@ void CG_Weapon_f( void )
}
*/
- if( g_entities[0].flags & FL_LOCK_PLAYER_WEAPONS )
- {
- CG_PlayerLockedWeaponSpeech( qfalse );
+ if (g_entities[0].flags & FL_LOCK_PLAYER_WEAPONS) {
+ CG_PlayerLockedWeaponSpeech(qfalse);
return;
}
- if( g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST )
- {
+ if (g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST) {
CG_ToggleATSTWeapon();
return;
}
- if ( cg.snap->ps.eFlags & EF_LOCKED_TO_WEAPON )
- {
+ if (cg.snap->ps.eFlags & EF_LOCKED_TO_WEAPON) {
// can't do any sort of weapon switching when in the emplaced gun
return;
}
- if ( cg.snap->ps.viewEntity )
- {
+ if (cg.snap->ps.viewEntity) {
// yeah, probably need a better check here
- if ( g_entities[cg.snap->ps.viewEntity].client && ( g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R5D2
- || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R2D2
- || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_MOUSE ))
- {
+ if (g_entities[cg.snap->ps.viewEntity].client &&
+ (g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R5D2 || g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_R2D2 ||
+ g_entities[cg.snap->ps.viewEntity].client->NPC_class == CLASS_MOUSE)) {
return;
}
}
- num = atoi( CG_Argv( 1 ) );
+ num = atoi(CG_Argv(1));
- if ( num < WP_NONE || num >= WP_NUM_WEAPONS ) {
+ if (num < WP_NONE || num >= WP_NUM_WEAPONS) {
return;
}
- if ( num == WP_SABER )
- {//lightsaber
- if ( ! ( cg.snap->ps.stats[STAT_WEAPONS] & ( 1 << num ) ) )
- {//don't have saber, try stun baton
- if ( ( cg.snap->ps.stats[STAT_WEAPONS] & ( 1 << WP_STUN_BATON ) ) )
- {
+ if (num == WP_SABER) { // lightsaber
+ if (!(cg.snap->ps.stats[STAT_WEAPONS] & (1 << num))) { // don't have saber, try stun baton
+ if ((cg.snap->ps.stats[STAT_WEAPONS] & (1 << WP_STUN_BATON))) {
num = WP_STUN_BATON;
- }
- else
- {//don't have stun baton, use fists
+ } else { // don't have stun baton, use fists
num = WP_MELEE;
}
- }
- else if ( num == cg.snap->ps.weapon )
- {//already have it up, let's try to toggle it
- if ( !in_camera )
- {//player can't activate/deactivate saber when in a cinematic
- //can't toggle it if not holding it and not controlling it or dead
- if ( cg.predicted_player_state.stats[STAT_HEALTH] > 0 && (!cg_entities[0].gent->client->ps.saberInFlight || (&g_entities[cg_entities[0].gent->client->ps.saberEntityNum] != NULL && g_entities[cg_entities[0].gent->client->ps.saberEntityNum].s.pos.trType == TR_LINEAR) ) )
- {//it's either in-hand or it's under telekinetic control
- if ( cg_entities[0].gent->client->ps.SaberActive() )
- {//a saber is on
- if ( cg_entities[0].gent->client->ps.dualSabers
- && cg_entities[0].gent->client->ps.saber[1].Active() )
- {//2nd saber is on, turn it off, too
+ } else if (num == cg.snap->ps.weapon) { // already have it up, let's try to toggle it
+ if (!in_camera) { // player can't activate/deactivate saber when in a cinematic
+ // can't toggle it if not holding it and not controlling it or dead
+ if (cg.predicted_player_state.stats[STAT_HEALTH] > 0 &&
+ (!cg_entities[0].gent->client->ps.saberInFlight || (&g_entities[cg_entities[0].gent->client->ps.saberEntityNum] != NULL &&
+ g_entities[cg_entities[0].gent->client->ps.saberEntityNum].s.pos.trType ==
+ TR_LINEAR))) { // it's either in-hand or it's under telekinetic control
+ if (cg_entities[0].gent->client->ps.SaberActive()) { // a saber is on
+ if (cg_entities[0].gent->client->ps.dualSabers &&
+ cg_entities[0].gent->client->ps.saber[1].Active()) { // 2nd saber is on, turn it off, too
cg_entities[0].gent->client->ps.saber[1].Deactivate();
}
cg_entities[0].gent->client->ps.saber[0].Deactivate();
- if ( cg_entities[0].gent->client->ps.saberInFlight )
- {//play it on the saber
- cgi_S_UpdateEntityPosition( cg_entities[0].gent->client->ps.saberEntityNum, g_entities[cg_entities[0].gent->client->ps.saberEntityNum].currentOrigin );
- cgi_S_StartSound (NULL, cg_entities[0].gent->client->ps.saberEntityNum, CHAN_AUTO, cgs.sound_precache[cg_entities[0].gent->client->ps.saber[0].soundOff] );
- }
- else
- {
- cgi_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.sound_precache[cg_entities[0].gent->client->ps.saber[0].soundOff] );
+ if (cg_entities[0].gent->client->ps.saberInFlight) { // play it on the saber
+ cgi_S_UpdateEntityPosition(cg_entities[0].gent->client->ps.saberEntityNum,
+ g_entities[cg_entities[0].gent->client->ps.saberEntityNum].currentOrigin);
+ cgi_S_StartSound(NULL, cg_entities[0].gent->client->ps.saberEntityNum, CHAN_AUTO,
+ cgs.sound_precache[cg_entities[0].gent->client->ps.saber[0].soundOff]);
+ } else {
+ cgi_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.sound_precache[cg_entities[0].gent->client->ps.saber[0].soundOff]);
}
- }
- else
- {//turn them both on
+ } else { // turn them both on
cg_entities[0].gent->client->ps.SaberActivate();
}
}
}
}
- }
- else if ( num >= WP_THERMAL && num <= WP_DET_PACK ) // these weapons cycle
+ } else if (num >= WP_THERMAL && num <= WP_DET_PACK) // these weapons cycle
{
int weap, i = 0;
- if ( cg.snap->ps.weapon >= WP_THERMAL && cg.snap->ps.weapon <= WP_DET_PACK )
- {
+ if (cg.snap->ps.weapon >= WP_THERMAL && cg.snap->ps.weapon <= WP_DET_PACK) {
// already in cycle range so start with next cycle item
weap = cg.snap->ps.weapon + 1;
- }
- else
- {
+ } else {
// not in cycle range, so start with thermal detonator
weap = WP_THERMAL;
}
// prevent an endless loop
- while ( i <= 4 )
- {
- if ( weap > WP_DET_PACK )
- {
+ while (i <= 4) {
+ if (weap > WP_DET_PACK) {
weap = WP_THERMAL;
}
- if ( cg.snap->ps.ammo[weaponData[weap].ammoIndex] > 0 || weap == WP_DET_PACK )
- {
- if ( CG_WeaponSelectable( weap, cg.snap->ps.weapon, qfalse ) )
- {
+ if (cg.snap->ps.ammo[weaponData[weap].ammoIndex] > 0 || weap == WP_DET_PACK) {
+ if (CG_WeaponSelectable(weap, cg.snap->ps.weapon, qfalse)) {
num = weap;
break;
}
@@ -2649,13 +2294,12 @@ void CG_Weapon_f( void )
}
}
- if (!CG_WeaponSelectable(num, cg.snap->ps.weapon, qfalse))
- {
+ if (!CG_WeaponSelectable(num, cg.snap->ps.weapon, qfalse)) {
return;
}
SetWeaponSelectTime();
-// cg.weaponSelectTime = cg.time;
+ // cg.weaponSelectTime = cg.time;
cg.weaponSelect = num;
}
@@ -2666,46 +2310,37 @@ CG_OutOfAmmoChange
The current weapon has just run out of ammo
===================
*/
-void CG_OutOfAmmoChange( void ) {
- int i;
- int original;
+void CG_OutOfAmmoChange(void) {
+ int i;
+ int original;
- if ( cg.weaponSelectTime + 200 > cg.time )
+ if (cg.weaponSelectTime + 200 > cg.time)
return;
- if( g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST )
- {
+ if (g_entities[0].client && g_entities[0].client->NPC_class == CLASS_ATST) {
CG_ToggleATSTWeapon();
return;
}
original = cg.weaponSelect;
- for ( i = WP_ROCKET_LAUNCHER; i > 0 ; i-- )
- {
+ for (i = WP_ROCKET_LAUNCHER; i > 0; i--) {
// We don't want the emplaced, melee, or explosive devices here
- if ( original != i && CG_WeaponSelectable( i, original, qfalse ) )
- {
+ if (original != i && CG_WeaponSelectable(i, original, qfalse)) {
SetWeaponSelectTime();
cg.weaponSelect = i;
break;
}
}
- if ( cg_autoswitch.integer != 1 )
- {
+ if (cg_autoswitch.integer != 1) {
// didn't have that, so try these. Start with thermal...
- for ( i = WP_THERMAL; i <= WP_DET_PACK; i++ )
- {
+ for (i = WP_THERMAL; i <= WP_DET_PACK; i++) {
// We don't want the emplaced, or melee here
- if ( original != i && CG_WeaponSelectable( i, original, qfalse ) )
- {
- if ( i == WP_DET_PACK && cg.snap->ps.ammo[weaponData[i].ammoIndex] <= 0 )
- {
+ if (original != i && CG_WeaponSelectable(i, original, qfalse)) {
+ if (i == WP_DET_PACK && cg.snap->ps.ammo[weaponData[i].ammoIndex] <= 0) {
// crap, no point in switching to this
- }
- else
- {
+ } else {
SetWeaponSelectTime();
cg.weaponSelect = i;
break;
@@ -2715,15 +2350,12 @@ void CG_OutOfAmmoChange( void ) {
}
// try stun baton as a last ditch effort
- if ( CG_WeaponSelectable( WP_STUN_BATON, original, qfalse ))
- {
+ if (CG_WeaponSelectable(WP_STUN_BATON, original, qfalse)) {
SetWeaponSelectTime();
cg.weaponSelect = WP_STUN_BATON;
}
}
-
-
/*
===================================================================================================
@@ -2739,31 +2371,26 @@ CG_FireWeapon
Caused by an EV_FIRE_WEAPON event
================
*/
-void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
-{
+void CG_FireWeapon(centity_t *cent, qboolean alt_fire) {
entityState_t *ent;
- //weaponInfo_t *weap;
+ // weaponInfo_t *weap;
ent = ¢->currentState;
- if ( ent->weapon == WP_NONE ) {
+ if (ent->weapon == WP_NONE) {
return;
}
- if ( ent->weapon >= WP_NUM_WEAPONS ) {
- CG_Error( "CG_FireWeapon: ent->weapon >= WP_NUM_WEAPONS" );
+ if (ent->weapon >= WP_NUM_WEAPONS) {
+ CG_Error("CG_FireWeapon: ent->weapon >= WP_NUM_WEAPONS");
return;
}
- if ( ent->weapon == WP_TUSKEN_RIFLE && cent->gent->client)
- {
- if (cent->gent->client->ps.torsoAnim==BOTH_TUSKENATTACK1 ||
- cent->gent->client->ps.torsoAnim==BOTH_TUSKENATTACK2 ||
- cent->gent->client->ps.torsoAnim==BOTH_TUSKENATTACK3 ||
- cent->gent->client->ps.torsoAnim==BOTH_TUSKENLUNGE1)
- {
+ if (ent->weapon == WP_TUSKEN_RIFLE && cent->gent->client) {
+ if (cent->gent->client->ps.torsoAnim == BOTH_TUSKENATTACK1 || cent->gent->client->ps.torsoAnim == BOTH_TUSKENATTACK2 ||
+ cent->gent->client->ps.torsoAnim == BOTH_TUSKENATTACK3 || cent->gent->client->ps.torsoAnim == BOTH_TUSKENLUNGE1) {
return;
}
}
- //weap = &cg_weapons[ ent->weapon ];
+ // weap = &cg_weapons[ ent->weapon ];
// mark the entity as muzzle flashing, so when it is added it will
// append the flash to the weapon model
@@ -2771,64 +2398,62 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
cent->altFire = alt_fire;
// lightning type guns only does this this on initial press
- if ( ent->weapon == WP_SABER )
- {
- if ( cent->pe.lightningFiring )
- {
-/* if ( ent->weapon == WP_DREADNOUGHT )
- {
- cgi_FF_EnsureFX( fffx_Laser3 );
- }
-*/
+ if (ent->weapon == WP_SABER) {
+ if (cent->pe.lightningFiring) {
+ /* if ( ent->weapon == WP_DREADNOUGHT )
+ {
+ cgi_FF_EnsureFX( fffx_Laser3 );
+ }
+ */
return;
}
}
// Do overcharge sound that get's added to the top
-/* if (( ent->powerups & ( 1<powerups & ( 1<weapon )
+ if ( alt_fire )
{
- case WP_THERMAL:
- case WP_DET_PACK:
- case WP_TRIP_MINE:
- case WP_ROCKET_LAUNCHER:
- case WP_FLECHETTE:
- // these weapon fires don't overcharge
- break;
-
- case WP_BLASTER:
- cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
- break;
-
- default:
- cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
- break;
+ switch( ent->weapon )
+ {
+ case WP_THERMAL:
+ case WP_DET_PACK:
+ case WP_TRIP_MINE:
+ case WP_ROCKET_LAUNCHER:
+ case WP_FLECHETTE:
+ // these weapon fires don't overcharge
+ break;
+
+ case WP_BLASTER:
+ cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
+ break;
+
+ default:
+ cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
+ break;
+ }
}
- }
- else
- {
- switch( ent->weapon )
+ else
{
- case WP_THERMAL:
- case WP_DET_PACK:
- case WP_TRIP_MINE:
- case WP_ROCKET_LAUNCHER:
- // these weapon fires don't overcharge
- break;
-
- case WP_REPEATER:
- cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
- break;
-
- default:
- cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
- break;
+ switch( ent->weapon )
+ {
+ case WP_THERMAL:
+ case WP_DET_PACK:
+ case WP_TRIP_MINE:
+ case WP_ROCKET_LAUNCHER:
+ // these weapon fires don't overcharge
+ break;
+
+ case WP_REPEATER:
+ cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
+ break;
+
+ default:
+ cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
+ break;
+ }
}
- }
- }*/
+ }*/
}
/*
@@ -2838,44 +2463,41 @@ CG_BounceEffect
Caused by an EV_BOUNCE | EV_BOUNCE_HALF event
=================
*/
-void CG_BounceEffect( centity_t *cent, int weapon, vec3_t origin, vec3_t normal )
-{
- switch( weapon )
- {
+void CG_BounceEffect(centity_t *cent, int weapon, vec3_t origin, vec3_t normal) {
+ switch (weapon) {
case WP_THERMAL:
- if ( rand() & 1 ) {
- cgi_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce1 );
+ if (rand() & 1) {
+ cgi_S_StartSound(origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce1);
} else {
- cgi_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce2 );
+ cgi_S_StartSound(origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce2);
}
break;
case WP_BOWCASTER:
- theFxScheduler.PlayEffect( cgs.effects.bowcasterBounceEffect, origin, normal );
+ theFxScheduler.PlayEffect(cgs.effects.bowcasterBounceEffect, origin, normal);
break;
case WP_FLECHETTE:
- theFxScheduler.PlayEffect( "flechette/ricochet", origin, normal );
+ theFxScheduler.PlayEffect("flechette/ricochet", origin, normal);
break;
default:
- if ( rand() & 1 ) {
- cgi_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce1 );
+ if (rand() & 1) {
+ cgi_S_StartSound(origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce1);
} else {
- cgi_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce2 );
+ cgi_S_StartSound(origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.grenadeBounce2);
}
break;
}
}
//----------------------------------------------------------------------
-void CG_MissileStick( centity_t *cent, int weapon, vec3_t position )
+void CG_MissileStick(centity_t *cent, int weapon, vec3_t position)
//----------------------------------------------------------------------
{
sfxHandle_t snd = 0;
- switch( weapon )
- {
+ switch (weapon) {
case WP_FLECHETTE:
snd = cgs.media.flechetteStickSound;
break;
@@ -2889,17 +2511,14 @@ void CG_MissileStick( centity_t *cent, int weapon, vec3_t position )
break;
}
- if ( snd )
- {
- cgi_S_StartSound( NULL, cent->currentState.number, CHAN_AUTO, snd );
+ if (snd) {
+ cgi_S_StartSound(NULL, cent->currentState.number, CHAN_AUTO, snd);
}
}
-qboolean CG_VehicleWeaponImpact( centity_t *cent )
-{//see if this is a missile entity that's owned by a vehicle and should do a special, overridden impact effect
- if (cent->currentState.otherEntityNum2
- && g_vehWeaponInfo[cent->currentState.otherEntityNum2].iImpactFX)
- {//missile is from a special vehWeapon
+qboolean CG_VehicleWeaponImpact(centity_t *cent) { // see if this is a missile entity that's owned by a vehicle and should do a special, overridden impact
+ // effect
+ if (cent->currentState.otherEntityNum2 && g_vehWeaponInfo[cent->currentState.otherEntityNum2].iImpactFX) { // missile is from a special vehWeapon
CG_PlayEffectID(g_vehWeaponInfo[cent->currentState.otherEntityNum2].iImpactFX, cent->lerpOrigin, cent->gent->pos1);
return qtrue;
}
@@ -2913,122 +2532,104 @@ CG_MissileHitWall
Caused by an EV_MISSILE_MISS event, or directly by local bullet tracing
=================
*/
-void CG_MissileHitWall( centity_t *cent, int weapon, vec3_t origin, vec3_t dir, qboolean altFire )
-{
+void CG_MissileHitWall(centity_t *cent, int weapon, vec3_t origin, vec3_t dir, qboolean altFire) {
int parm;
- switch( weapon )
- {
+ switch (weapon) {
case WP_BRYAR_PISTOL:
case WP_BLASTER_PISTOL:
case WP_JAWA:
- if ( altFire )
- {
+ if (altFire) {
parm = 0;
- if ( cent->gent )
- {
+ if (cent->gent) {
parm += cent->gent->count;
}
- FX_BryarAltHitWall( origin, dir, parm );
- }
- else
- {
- FX_BryarHitWall( origin, dir );
+ FX_BryarAltHitWall(origin, dir, parm);
+ } else {
+ FX_BryarHitWall(origin, dir);
}
break;
case WP_BLASTER:
- FX_BlasterWeaponHitWall( origin, dir );
+ FX_BlasterWeaponHitWall(origin, dir);
break;
case WP_BOWCASTER:
- FX_BowcasterHitWall( origin, dir );
+ FX_BowcasterHitWall(origin, dir);
break;
case WP_REPEATER:
- if ( altFire )
- {
- FX_RepeaterAltHitWall( origin, dir );
- }
- else
- {
- FX_RepeaterHitWall( origin, dir );
+ if (altFire) {
+ FX_RepeaterAltHitWall(origin, dir);
+ } else {
+ FX_RepeaterHitWall(origin, dir);
}
break;
case WP_DEMP2:
- if ( altFire )
- {
- }
- else
- {
- FX_DEMP2_HitWall( origin, dir );
+ if (altFire) {
+ } else {
+ FX_DEMP2_HitWall(origin, dir);
}
break;
case WP_FLECHETTE:
- if ( altFire )
- {
- theFxScheduler.PlayEffect( "flechette/alt_blow", origin, dir );
- }
- else
- {
- FX_FlechetteWeaponHitWall( origin, dir );
+ if (altFire) {
+ theFxScheduler.PlayEffect("flechette/alt_blow", origin, dir);
+ } else {
+ FX_FlechetteWeaponHitWall(origin, dir);
}
break;
case WP_ROCKET_LAUNCHER:
- FX_RocketHitWall( origin, dir );
+ FX_RocketHitWall(origin, dir);
break;
case WP_CONCUSSION:
- FX_ConcHitWall( origin, dir );
+ FX_ConcHitWall(origin, dir);
break;
case WP_THERMAL:
- theFxScheduler.PlayEffect( "thermal/explosion", origin, dir );
- theFxScheduler.PlayEffect( "thermal/shockwave", origin );
+ theFxScheduler.PlayEffect("thermal/explosion", origin, dir);
+ theFxScheduler.PlayEffect("thermal/shockwave", origin);
break;
case WP_EMPLACED_GUN:
- FX_EmplacedHitWall( origin, dir, (qboolean)(cent->gent&¢->gent->alt_fire) );
+ FX_EmplacedHitWall(origin, dir, (qboolean)(cent->gent && cent->gent->alt_fire));
break;
case WP_ATST_MAIN:
- FX_ATSTMainHitWall( origin, dir );
+ FX_ATSTMainHitWall(origin, dir);
break;
case WP_ATST_SIDE:
- if ( altFire )
- {
- theFxScheduler.PlayEffect( "atst/side_alt_explosion", origin, dir );
- }
- else
- {
- theFxScheduler.PlayEffect( "atst/side_main_impact", origin, dir );
+ if (altFire) {
+ theFxScheduler.PlayEffect("atst/side_alt_explosion", origin, dir);
+ } else {
+ theFxScheduler.PlayEffect("atst/side_main_impact", origin, dir);
}
break;
case WP_TRIP_MINE:
- theFxScheduler.PlayEffect( "tripmine/explosion", origin, dir );
+ theFxScheduler.PlayEffect("tripmine/explosion", origin, dir);
break;
case WP_DET_PACK:
- theFxScheduler.PlayEffect( "detpack/explosion", origin, dir );
+ theFxScheduler.PlayEffect("detpack/explosion", origin, dir);
break;
case WP_TURRET:
- theFxScheduler.PlayEffect( "turret/wall_impact", origin, dir );
+ theFxScheduler.PlayEffect("turret/wall_impact", origin, dir);
break;
case WP_TUSKEN_RIFLE:
- FX_TuskenShotWeaponHitWall( origin, dir );
+ FX_TuskenShotWeaponHitWall(origin, dir);
break;
case WP_NOGHRI_STICK:
- FX_NoghriShotWeaponHitWall( origin, dir );
+ FX_NoghriShotWeaponHitWall(origin, dir);
break;
}
}
@@ -3039,136 +2640,116 @@ CG_MissileHitPlayer
-------------------------
*/
-void CG_MissileHitPlayer( centity_t *cent, int weapon, vec3_t origin, vec3_t dir, qboolean altFire )
-{
+void CG_MissileHitPlayer(centity_t *cent, int weapon, vec3_t origin, vec3_t dir, qboolean altFire) {
gentity_t *other = NULL;
- qboolean humanoid = qtrue;
+ qboolean humanoid = qtrue;
- if ( cent->gent )
- {
+ if (cent->gent) {
other = &g_entities[cent->gent->s.otherEntityNum];
- if( other->client )
- {
- class_t npc_class = other->client->NPC_class;
+ if (other->client) {
+ class_t npc_class = other->client->NPC_class;
// check for all droids, maybe check for certain monsters if they're considered non-humanoid..?
- if ( npc_class == CLASS_SEEKER || npc_class == CLASS_PROBE || npc_class == CLASS_MOUSE ||
- npc_class == CLASS_GONK || npc_class == CLASS_R2D2 || npc_class == CLASS_R5D2 ||
- npc_class == CLASS_PROTOCOL || npc_class == CLASS_MARK1 || npc_class == CLASS_MARK2 ||
- npc_class == CLASS_INTERROGATOR || npc_class == CLASS_ATST || npc_class == CLASS_SENTRY )
- {
+ if (npc_class == CLASS_SEEKER || npc_class == CLASS_PROBE || npc_class == CLASS_MOUSE || npc_class == CLASS_GONK || npc_class == CLASS_R2D2 ||
+ npc_class == CLASS_R5D2 || npc_class == CLASS_PROTOCOL || npc_class == CLASS_MARK1 || npc_class == CLASS_MARK2 ||
+ npc_class == CLASS_INTERROGATOR || npc_class == CLASS_ATST || npc_class == CLASS_SENTRY) {
humanoid = qfalse;
}
}
}
- switch( weapon )
- {
+ switch (weapon) {
case WP_BRYAR_PISTOL:
case WP_BLASTER_PISTOL:
case WP_JAWA:
- if ( altFire )
- {
- FX_BryarAltHitPlayer( origin, dir, humanoid );
- }
- else
- {
- FX_BryarHitPlayer( origin, dir, humanoid );
+ if (altFire) {
+ FX_BryarAltHitPlayer(origin, dir, humanoid);
+ } else {
+ FX_BryarHitPlayer(origin, dir, humanoid);
}
break;
case WP_BLASTER:
- FX_BlasterWeaponHitPlayer( other, origin, dir, humanoid );
+ FX_BlasterWeaponHitPlayer(other, origin, dir, humanoid);
break;
case WP_BOWCASTER:
- FX_BowcasterHitPlayer( origin, dir, humanoid );
+ FX_BowcasterHitPlayer(origin, dir, humanoid);
break;
case WP_REPEATER:
- if ( altFire )
- {
- FX_RepeaterAltHitPlayer( origin, dir, humanoid );
- }
- else
- {
- FX_RepeaterHitPlayer( origin, dir, humanoid );
+ if (altFire) {
+ FX_RepeaterAltHitPlayer(origin, dir, humanoid);
+ } else {
+ FX_RepeaterHitPlayer(origin, dir, humanoid);
}
break;
case WP_DEMP2:
- if ( !altFire )
- {
- FX_DEMP2_HitPlayer( origin, dir, humanoid );
+ if (!altFire) {
+ FX_DEMP2_HitPlayer(origin, dir, humanoid);
}
// Do a full body effect here for some more feedback
- if ( other && other->client )
- {
- other->s.powerups |= ( 1 << PW_SHOCKED );
+ if (other && other->client) {
+ other->s.powerups |= (1 << PW_SHOCKED);
other->client->ps.powerups[PW_SHOCKED] = cg.time + 1000;
}
break;
case WP_FLECHETTE:
- if ( altFire )
- {
- theFxScheduler.PlayEffect( "flechette/alt_blow", origin, dir );
- }
- else
- {
- FX_FlechetteWeaponHitPlayer( origin, dir, humanoid );
+ if (altFire) {
+ theFxScheduler.PlayEffect("flechette/alt_blow", origin, dir);
+ } else {
+ FX_FlechetteWeaponHitPlayer(origin, dir, humanoid);
}
break;
case WP_ROCKET_LAUNCHER:
- FX_RocketHitPlayer( origin, dir, humanoid );
+ FX_RocketHitPlayer(origin, dir, humanoid);
break;
case WP_CONCUSSION:
- FX_ConcHitPlayer( origin, dir, humanoid );
+ FX_ConcHitPlayer(origin, dir, humanoid);
break;
case WP_THERMAL:
- theFxScheduler.PlayEffect( "thermal/explosion", origin, dir );
- theFxScheduler.PlayEffect( "thermal/shockwave", origin );
+ theFxScheduler.PlayEffect("thermal/explosion", origin, dir);
+ theFxScheduler.PlayEffect("thermal/shockwave", origin);
break;
case WP_EMPLACED_GUN:
- FX_EmplacedHitPlayer( origin, dir, (qboolean)(cent->gent&¢->gent->alt_fire) );
+ FX_EmplacedHitPlayer(origin, dir, (qboolean)(cent->gent && cent->gent->alt_fire));
break;
case WP_TRIP_MINE:
- theFxScheduler.PlayEffect( "tripmine/explosion", origin, dir );
+ theFxScheduler.PlayEffect("tripmine/explosion", origin, dir);
break;
case WP_DET_PACK:
- theFxScheduler.PlayEffect( "detpack/explosion", origin, dir );
+ theFxScheduler.PlayEffect("detpack/explosion", origin, dir);
break;
case WP_TURRET:
- theFxScheduler.PlayEffect( "turret/flesh_impact", origin, dir );
+ theFxScheduler.PlayEffect("turret/flesh_impact", origin, dir);
break;
case WP_ATST_MAIN:
- FX_EmplacedHitWall( origin, dir, qfalse );
+ FX_EmplacedHitWall(origin, dir, qfalse);
break;
case WP_ATST_SIDE:
- if ( altFire )
- {
- theFxScheduler.PlayEffect( "atst/side_alt_explosion", origin, dir );
- }
- else
- {
- theFxScheduler.PlayEffect( "atst/side_main_impact", origin, dir );
+ if (altFire) {
+ theFxScheduler.PlayEffect("atst/side_alt_explosion", origin, dir);
+ } else {
+ theFxScheduler.PlayEffect("atst/side_main_impact", origin, dir);
}
break;
case WP_TUSKEN_RIFLE:
- FX_TuskenShotWeaponHitPlayer( other, origin, dir, humanoid );
+ FX_TuskenShotWeaponHitPlayer(other, origin, dir, humanoid);
break;
case WP_NOGHRI_STICK:
- FX_NoghriShotWeaponHitPlayer( other, origin, dir, humanoid );
+ FX_NoghriShotWeaponHitPlayer(other, origin, dir, humanoid);
break;
}
}
diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp
index b9d7b6fc11..26e4d04851 100644
--- a/code/client/cl_cgame.cpp
+++ b/code/client/cl_cgame.cpp
@@ -33,56 +33,54 @@ along with this program; if not, see .
#include "qcommon/stringed_ingame.h"
#include "sys/sys_loadlib.h"
-vm_t cgvm;
+vm_t cgvm;
/*
Ghoul2 Insert Start
*/
#if !defined(G2_H_INC)
- #include "../ghoul2/G2.h"
+#include "../ghoul2/G2.h"
#endif
/*
Ghoul2 Insert End
*/
-//FIXME: Temp
-extern void S_UpdateAmbientSet ( const char *name, vec3_t origin );
-extern int S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time );
-extern void AS_ParseSets( void );
-extern sfxHandle_t AS_GetBModelSound( const char *name, int stage );
-extern void AS_AddPrecacheEntry( const char *name );
+// FIXME: Temp
+extern void S_UpdateAmbientSet(const char *name, vec3_t origin);
+extern int S_AddLocalSet(const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time);
+extern void AS_ParseSets(void);
+extern sfxHandle_t AS_GetBModelSound(const char *name, int stage);
+extern void AS_AddPrecacheEntry(const char *name);
extern menuDef_t *Menus_FindByName(const char *p);
-extern qboolean R_inPVS( vec3_t p1, vec3_t p2 );
+extern qboolean R_inPVS(vec3_t p1, vec3_t p2);
-void UI_SetActiveMenu( const char* menuname,const char *menuID );
+void UI_SetActiveMenu(const char *menuname, const char *menuID);
-qboolean CL_InitCGameVM( void *gameLibrary )
-{
- typedef intptr_t SyscallProc( intptr_t, ... );
- typedef void DllEntryProc( SyscallProc * );
+qboolean CL_InitCGameVM(void *gameLibrary) {
+ typedef intptr_t SyscallProc(intptr_t, ...);
+ typedef void DllEntryProc(SyscallProc *);
- DllEntryProc *dllEntry = (DllEntryProc *)Sys_LoadFunction( gameLibrary, "dllEntry" );
+ DllEntryProc *dllEntry = (DllEntryProc *)Sys_LoadFunction(gameLibrary, "dllEntry");
// NOTE: arm64 mac has a different calling convention for fixed parameters vs. variadic parameters.
// As the cgame entryPoints (vmMain) in jk2 and jka use fixed arg0 to arg7 we can't use "..." around here or we end up with undefined behavior.
// See: https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code
- cgvm.entryPoint = (intptr_t (*)(int,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))Sys_LoadFunction( gameLibrary, "vmMain" );
+ cgvm.entryPoint = (intptr_t(*)(int, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))Sys_LoadFunction(gameLibrary, "vmMain");
- if ( !cgvm.entryPoint || !dllEntry ) {
+ if (!cgvm.entryPoint || !dllEntry) {
#ifdef JK2_MODE
const char *gamename = "jospgame";
#else
const char *gamename = "jagame";
#endif
- Com_Printf( "CL_InitCGameVM: client game entry point not found in %s" ARCH_STRING DLL_EXT ": %s\n",
- gamename, Sys_LibraryError() );
+ Com_Printf("CL_InitCGameVM: client game entry point not found in %s" ARCH_STRING DLL_EXT ": %s\n", gamename, Sys_LibraryError());
return qfalse;
}
- dllEntry( VM_DllSyscall );
+ dllEntry(VM_DllSyscall);
return qtrue;
}
@@ -92,48 +90,40 @@ qboolean CL_InitCGameVM( void *gameLibrary )
CL_GetGameState
====================
*/
-void CL_GetGameState( gameState_t *gs ) {
- *gs = cl.gameState;
-}
+void CL_GetGameState(gameState_t *gs) { *gs = cl.gameState; }
/*
====================
CL_GetGlconfig
====================
*/
-void CL_GetGlconfig( glconfig_t *glconfig ) {
- *glconfig = cls.glconfig;
-}
-
+void CL_GetGlconfig(glconfig_t *glconfig) { *glconfig = cls.glconfig; }
/*
====================
CL_GetUserCmd
====================
*/
-qboolean CL_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {
+qboolean CL_GetUserCmd(int cmdNumber, usercmd_t *ucmd) {
// cmds[cmdNumber] is the last properly generated command
// can't return anything that we haven't created yet
- if ( cmdNumber > cl.cmdNumber ) {
- Com_Error( ERR_DROP, "CL_GetUserCmd: %i >= %i", cmdNumber, cl.cmdNumber );
+ if (cmdNumber > cl.cmdNumber) {
+ Com_Error(ERR_DROP, "CL_GetUserCmd: %i >= %i", cmdNumber, cl.cmdNumber);
}
// the usercmd has been overwritten in the wrapping
// buffer because it is too far out of date
- if ( cmdNumber <= cl.cmdNumber - CMD_BACKUP ) {
+ if (cmdNumber <= cl.cmdNumber - CMD_BACKUP) {
return qfalse;
}
- *ucmd = cl.cmds[ cmdNumber & CMD_MASK ];
+ *ucmd = cl.cmds[cmdNumber & CMD_MASK];
return qtrue;
}
-int CL_GetCurrentCmdNumber( void ) {
- return cl.cmdNumber;
-}
-
+int CL_GetCurrentCmdNumber(void) { return cl.cmdNumber; }
/*
====================
@@ -163,7 +153,7 @@ qboolean CL_GetParseEntityState( int parseEntityNumber, entityState_t *state ) {
CL_GetCurrentSnapshotNumber
====================
*/
-void CL_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
+void CL_GetCurrentSnapshotNumber(int *snapshotNumber, int *serverTime) {
*snapshotNumber = cl.frame.messageNum;
*serverTime = cl.frame.serverTime;
}
@@ -173,28 +163,28 @@ void CL_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
CL_GetSnapshot
====================
*/
-qboolean CL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {
- clSnapshot_t *clSnap;
- int i, count;
+qboolean CL_GetSnapshot(int snapshotNumber, snapshot_t *snapshot) {
+ clSnapshot_t *clSnap;
+ int i, count;
- if ( snapshotNumber > cl.frame.messageNum ) {
- Com_Error( ERR_DROP, "CL_GetSnapshot: snapshotNumber > cl.frame.messageNum" );
+ if (snapshotNumber > cl.frame.messageNum) {
+ Com_Error(ERR_DROP, "CL_GetSnapshot: snapshotNumber > cl.frame.messageNum");
}
// if the frame has fallen out of the circular buffer, we can't return it
- if ( cl.frame.messageNum - snapshotNumber >= PACKET_BACKUP ) {
+ if (cl.frame.messageNum - snapshotNumber >= PACKET_BACKUP) {
return qfalse;
}
// if the frame is not valid, we can't return it
clSnap = &cl.frames[snapshotNumber & PACKET_MASK];
- if ( !clSnap->valid ) {
+ if (!clSnap->valid) {
return qfalse;
}
// if the entities in the frame have fallen out of their
// circular buffer, we can't return it
- if ( cl.parseEntitiesNum - clSnap->parseEntitiesNum >= MAX_PARSE_ENTITIES ) {
+ if (cl.parseEntitiesNum - clSnap->parseEntitiesNum >= MAX_PARSE_ENTITIES) {
return qfalse;
}
@@ -202,60 +192,56 @@ qboolean CL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {
snapshot->snapFlags = clSnap->snapFlags;
snapshot->serverCommandSequence = clSnap->serverCommandNum;
snapshot->serverTime = clSnap->serverTime;
- memcpy( snapshot->areamask, clSnap->areamask, sizeof( snapshot->areamask ) );
+ memcpy(snapshot->areamask, clSnap->areamask, sizeof(snapshot->areamask));
snapshot->cmdNum = clSnap->cmdNum;
snapshot->ps = clSnap->ps;
count = clSnap->numEntities;
- if ( count > MAX_ENTITIES_IN_SNAPSHOT ) {
- Com_DPrintf( "CL_GetSnapshot: truncated %i entities to %i\n", count, MAX_ENTITIES_IN_SNAPSHOT );
+ if (count > MAX_ENTITIES_IN_SNAPSHOT) {
+ Com_DPrintf("CL_GetSnapshot: truncated %i entities to %i\n", count, MAX_ENTITIES_IN_SNAPSHOT);
count = MAX_ENTITIES_IN_SNAPSHOT;
}
snapshot->numEntities = count;
-/*
-Ghoul2 Insert Start
-*/
- for ( i = 0 ; i < count ; i++ )
- {
+ /*
+ Ghoul2 Insert Start
+ */
+ for (i = 0; i < count; i++) {
- int entNum = ( clSnap->parseEntitiesNum + i ) & (MAX_PARSE_ENTITIES-1) ;
- snapshot->entities[i] = cl.parseEntities[ entNum ];
+ int entNum = (clSnap->parseEntitiesNum + i) & (MAX_PARSE_ENTITIES - 1);
+ snapshot->entities[i] = cl.parseEntities[entNum];
}
-/*
-Ghoul2 Insert End
-*/
-
+ /*
+ Ghoul2 Insert End
+ */
// FIXME: configstring changes and server commands!!!
return qtrue;
}
-//bg_public.h won't cooperate in here
-#define EF_PERMANENT 0x00080000
+// bg_public.h won't cooperate in here
+#define EF_PERMANENT 0x00080000
-qboolean CL_GetDefaultState(int index, entityState_t *state)
-{
- if (index < 0 || index >= MAX_GENTITIES)
- {
+qboolean CL_GetDefaultState(int index, entityState_t *state) {
+ if (index < 0 || index >= MAX_GENTITIES) {
return qfalse;
}
// Is this safe? I think so. But it's still ugly as sin.
if (!(sv.svEntities[index].baseline.eFlags & EF_PERMANENT))
-// if (!(cl.entityBaselines[index].eFlags & EF_PERMANENT))
+ // if (!(cl.entityBaselines[index].eFlags & EF_PERMANENT))
{
return qfalse;
}
*state = sv.svEntities[index].baseline;
-// *state = cl.entityBaselines[index];
+ // *state = cl.entityBaselines[index];
return qtrue;
}
extern float cl_mPitchOverride;
extern float cl_mYawOverride;
-void CL_SetUserCmdValue( int userCmdValue, float sensitivityScale, float mPitchOverride, float mYawOverride ) {
+void CL_SetUserCmdValue(int userCmdValue, float sensitivityScale, float mPitchOverride, float mYawOverride) {
cl.cgameUserCmdValue = userCmdValue;
cl.cgameSensitivity = sensitivityScale;
cl_mPitchOverride = mPitchOverride;
@@ -264,79 +250,75 @@ void CL_SetUserCmdValue( int userCmdValue, float sensitivityScale, float mPitchO
extern vec3_t cl_overriddenAngles;
extern qboolean cl_overrideAngles;
-void CL_SetUserCmdAngles( float pitchOverride, float yawOverride, float rollOverride ) {
+void CL_SetUserCmdAngles(float pitchOverride, float yawOverride, float rollOverride) {
cl_overriddenAngles[PITCH] = pitchOverride;
cl_overriddenAngles[YAW] = yawOverride;
cl_overriddenAngles[ROLL] = rollOverride;
cl_overrideAngles = qtrue;
}
-void CL_AddCgameCommand( const char *cmdName ) {
- Cmd_AddCommand( cmdName, NULL );
-}
+void CL_AddCgameCommand(const char *cmdName) { Cmd_AddCommand(cmdName, NULL); }
/*
=====================
CL_ConfigstringModified
=====================
*/
-void CL_ConfigstringModified( void ) {
+void CL_ConfigstringModified(void) {
const char *s;
- char *old;
- int i, index;
- const char *dup;
- gameState_t oldGs;
- int len;
-
- index = atoi( Cmd_Argv(1) );
- if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
- Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" );
+ char *old;
+ int i, index;
+ const char *dup;
+ gameState_t oldGs;
+ int len;
+
+ index = atoi(Cmd_Argv(1));
+ if (index < 0 || index >= MAX_CONFIGSTRINGS) {
+ Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS");
}
s = Cmd_Argv(2);
- old = cl.gameState.stringData + cl.gameState.stringOffsets[ index ];
- if ( !strcmp( old, s ) ) {
- return; // unchanged
+ old = cl.gameState.stringData + cl.gameState.stringOffsets[index];
+ if (!strcmp(old, s)) {
+ return; // unchanged
}
// build the new gameState_t
oldGs = cl.gameState;
- memset( &cl.gameState, 0, sizeof( cl.gameState ) );
+ memset(&cl.gameState, 0, sizeof(cl.gameState));
// leave the first 0 for uninitialized strings
cl.gameState.dataCount = 1;
- for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
- if ( i == index ) {
+ for (i = 0; i < MAX_CONFIGSTRINGS; i++) {
+ if (i == index) {
dup = s;
} else {
- dup = oldGs.stringData + oldGs.stringOffsets[ i ];
+ dup = oldGs.stringData + oldGs.stringOffsets[i];
}
- if ( !dup[0] ) {
- continue; // leave with the default empty string
+ if (!dup[0]) {
+ continue; // leave with the default empty string
}
- len = strlen( dup );
+ len = strlen(dup);
- if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
- Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
+ if (len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS) {
+ Com_Error(ERR_DROP, "MAX_GAMESTATE_CHARS exceeded");
}
// append it to the gameState string buffer
- cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;
- memcpy( cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1 );
+ cl.gameState.stringOffsets[i] = cl.gameState.dataCount;
+ memcpy(cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1);
cl.gameState.dataCount += len + 1;
}
- if ( index == CS_SYSTEMINFO ) {
+ if (index == CS_SYSTEMINFO) {
// parse serverId and other cvars
CL_SystemInfoChanged();
}
-
}
-
/*
===================
CL_GetServerCommand
@@ -344,36 +326,36 @@ CL_GetServerCommand
Set up argc/argv for the given command
===================
*/
-qboolean CL_GetServerCommand( int serverCommandNumber ) {
- char *s;
- const char *cmd;
+qboolean CL_GetServerCommand(int serverCommandNumber) {
+ char *s;
+ const char *cmd;
// if we have irretrievably lost a reliable command, drop the connection
- if ( serverCommandNumber <= clc.serverCommandSequence - MAX_RELIABLE_COMMANDS ) {
- Com_Error( ERR_DROP, "CL_GetServerCommand: a reliable command was cycled out" );
+ if (serverCommandNumber <= clc.serverCommandSequence - MAX_RELIABLE_COMMANDS) {
+ Com_Error(ERR_DROP, "CL_GetServerCommand: a reliable command was cycled out");
return qfalse;
}
- if ( serverCommandNumber > clc.serverCommandSequence ) {
- Com_Error( ERR_DROP, "CL_GetServerCommand: requested a command not received" );
+ if (serverCommandNumber > clc.serverCommandSequence) {
+ Com_Error(ERR_DROP, "CL_GetServerCommand: requested a command not received");
return qfalse;
}
- s = clc.serverCommands[ serverCommandNumber & ( MAX_RELIABLE_COMMANDS - 1 ) ];
+ s = clc.serverCommands[serverCommandNumber & (MAX_RELIABLE_COMMANDS - 1)];
- Com_DPrintf( "serverCommand: %i : %s\n", serverCommandNumber, s );
+ Com_DPrintf("serverCommand: %i : %s\n", serverCommandNumber, s);
- Cmd_TokenizeString( s );
+ Cmd_TokenizeString(s);
cmd = Cmd_Argv(0);
- if ( !strcmp( cmd, "disconnect" ) ) {
- Com_Error (ERR_DISCONNECT,"Server disconnected\n");
+ if (!strcmp(cmd, "disconnect")) {
+ Com_Error(ERR_DISCONNECT, "Server disconnected\n");
}
- if ( !strcmp( cmd, "cs" ) ) {
+ if (!strcmp(cmd, "cs")) {
CL_ConfigstringModified();
// reparse the string, because CL_ConfigstringModified may have done another Cmd_TokenizeString()
- Cmd_TokenizeString( s );
+ Cmd_TokenizeString(s);
return qtrue;
}
@@ -382,17 +364,17 @@ qboolean CL_GetServerCommand( int serverCommandNumber ) {
// point of levels for the menu system to use
// we pass it along to the cgame to make apropriate adjustments,
// but we also clear the console and notify lines here
- if ( !strcmp( cmd, "clientLevelShot" ) ) {
+ if (!strcmp(cmd, "clientLevelShot")) {
// don't do it if we aren't running the server locally,
// otherwise malicious remote servers could overwrite
// the existing thumbnails
- if ( !com_sv_running->integer ) {
+ if (!com_sv_running->integer) {
return qfalse;
}
// close the console
Con_Close();
// take a special screenshot next frame
- Cbuf_AddText( "wait ; wait ; wait ; wait ; screenshot levelshot\n" );
+ Cbuf_AddText("wait ; wait ; wait ; wait ; screenshot levelshot\n");
return qtrue;
}
@@ -402,7 +384,6 @@ qboolean CL_GetServerCommand( int serverCommandNumber ) {
return qtrue;
}
-
/*
====================
CL_CM_LoadMap
@@ -410,10 +391,10 @@ CL_CM_LoadMap
Just adds default parameters that cgame doesn't need to know about
====================
*/
-void CL_CM_LoadMap( const char *mapname, qboolean subBSP ) {
- int checksum;
+void CL_CM_LoadMap(const char *mapname, qboolean subBSP) {
+ int checksum;
- CM_LoadMap( mapname, qtrue, &checksum, subBSP );
+ CM_LoadMap(mapname, qtrue, &checksum, subBSP);
}
/*
@@ -422,16 +403,16 @@ CL_ShutdonwCGame
====================
*/
-void CL_ShutdownCGame( void ) {
+void CL_ShutdownCGame(void) {
cls.cgameStarted = qfalse;
- if ( !cgvm.entryPoint) {
+ if (!cgvm.entryPoint) {
return;
}
- VM_Call( CG_SHUTDOWN );
+ VM_Call(CG_SHUTDOWN);
-// VM_Free( cgvm );
-// cgvm = NULL;
+ // VM_Free( cgvm );
+ // cgvm = NULL;
}
#ifdef JK2_MODE
@@ -443,356 +424,354 @@ Converts a JK2 syscall to a JKA syscall
====================
*/
-cgameImport_t CL_ConvertJK2SysCall( cgameJK2Import_t import )
-{
+cgameImport_t CL_ConvertJK2SysCall(cgameJK2Import_t import) {
// FIXME: This was a 5-minute slap-hack job in order to test if this really works. CLEAN ME UP! --eez
- switch(import)
- {
- case CG_PRINT_JK2:
- return CG_PRINT;
- break;
- case CG_ERROR_JK2:
- return CG_ERROR;
- break;
- case CG_MILLISECONDS_JK2:
- return CG_MILLISECONDS;
- break;
- case CG_CVAR_REGISTER_JK2:
- return CG_CVAR_REGISTER;
- break;
- case CG_CVAR_UPDATE_JK2:
- return CG_CVAR_UPDATE;
- break;
- case CG_CVAR_SET_JK2:
- return CG_CVAR_SET;
- break;
- case CG_ARGC_JK2:
- return CG_ARGC;
- break;
- case CG_ARGV_JK2:
- return CG_ARGV;
- break;
- case CG_ARGS_JK2:
- return CG_ARGS;
- break;
- case CG_FS_FOPENFILE_JK2:
- return CG_FS_FOPENFILE;
- break;
- case CG_FS_READ_JK2:
- return CG_FS_READ;
- break;
- case CG_FS_WRITE_JK2:
- return CG_FS_WRITE;
- break;
- case CG_FS_FCLOSEFILE_JK2:
- return CG_FS_FCLOSEFILE;
- break;
- case CG_SENDCONSOLECOMMAND_JK2:
- return CG_SENDCONSOLECOMMAND;
- break;
- case CG_ADDCOMMAND_JK2:
- return CG_ADDCOMMAND;
- break;
- case CG_SENDCLIENTCOMMAND_JK2:
- return CG_SENDCLIENTCOMMAND;
- break;
- case CG_UPDATESCREEN_JK2:
- return CG_UPDATESCREEN;
- break;
- case CG_CM_LOADMAP_JK2:
- return CG_CM_LOADMAP;
- break;
- case CG_CM_NUMINLINEMODELS_JK2:
- return CG_CM_NUMINLINEMODELS;
- break;
- case CG_CM_INLINEMODEL_JK2:
- return CG_CM_INLINEMODEL;
- break;
- case CG_CM_TEMPBOXMODEL_JK2:
- return CG_CM_TEMPBOXMODEL;
- break;
- case CG_CM_POINTCONTENTS_JK2:
- return CG_CM_POINTCONTENTS;
- break;
- case CG_CM_TRANSFORMEDPOINTCONTENTS_JK2:
- return CG_CM_TRANSFORMEDPOINTCONTENTS;
- break;
- case CG_CM_BOXTRACE_JK2:
- return CG_CM_BOXTRACE;
- break;
- case CG_CM_TRANSFORMEDBOXTRACE_JK2:
- return CG_CM_TRANSFORMEDBOXTRACE;
- break;
- case CG_CM_MARKFRAGMENTS_JK2:
- return CG_CM_MARKFRAGMENTS;
- break;
- case CG_CM_SNAPPVS_JK2:
- return CG_CM_SNAPPVS;
- break;
- case CG_S_STARTSOUND_JK2:
- return CG_S_STARTSOUND;
- break;
- case CG_S_STARTLOCALSOUND_JK2:
- return CG_S_STARTLOCALSOUND;
- break;
- case CG_S_CLEARLOOPINGSOUNDS_JK2:
- return CG_S_CLEARLOOPINGSOUNDS;
- break;
- case CG_S_ADDLOOPINGSOUND_JK2:
- return CG_S_ADDLOOPINGSOUND;
- break;
- case CG_S_UPDATEENTITYPOSITION_JK2:
- return CG_S_UPDATEENTITYPOSITION;
- break;
- case CG_S_RESPATIALIZE_JK2:
- return CG_S_RESPATIALIZE;
- break;
- case CG_S_REGISTERSOUND_JK2:
- return CG_S_REGISTERSOUND;
- break;
- case CG_S_STARTBACKGROUNDTRACK_JK2:
- return CG_S_STARTBACKGROUNDTRACK;
- break;
- case CG_R_LOADWORLDMAP_JK2:
- return CG_R_LOADWORLDMAP;
- break;
- case CG_R_REGISTERMODEL_JK2:
- return CG_R_REGISTERMODEL;
- break;
- case CG_R_REGISTERSKIN_JK2:
- return CG_R_REGISTERSKIN;
- break;
- case CG_R_REGISTERSHADER_JK2:
- return CG_R_REGISTERSHADER;
- break;
- case CG_R_REGISTERSHADERNOMIP_JK2:
- return CG_R_REGISTERSHADERNOMIP;
- break;
- case CG_R_REGISTERFONT_JK2:
- return CG_R_REGISTERFONT;
- break;
- case CG_R_FONTSTRLENPIXELS_JK2:
- return CG_R_FONTSTRLENPIXELS;
- break;
- case CG_R_FONTSTRLENCHARS_JK2:
- return CG_R_FONTSTRLENCHARS;
- break;
- case CG_R_FONTHEIGHTPIXELS_JK2:
- return CG_R_FONTHEIGHTPIXELS;
- break;
- case CG_R_FONTDRAWSTRING_JK2:
- return CG_R_FONTDRAWSTRING;
- break;
- case CG_LANGUAGE_ISASIAN_JK2:
- return CG_LANGUAGE_ISASIAN;
- break;
- case CG_LANGUAGE_USESSPACES_JK2:
- return CG_LANGUAGE_USESSPACES;
- break;
- case CG_ANYLANGUAGE_READFROMSTRING_JK2:
- return CG_ANYLANGUAGE_READFROMSTRING;
- break;
- case CG_R_CLEARSCENE_JK2:
- return CG_R_CLEARSCENE;
- break;
- case CG_R_ADDREFENTITYTOSCENE_JK2:
- return CG_R_ADDREFENTITYTOSCENE;
- break;
- case CG_R_GETLIGHTING_JK2:
- return CG_R_GETLIGHTING;
- break;
- case CG_R_ADDPOLYTOSCENE_JK2:
- return CG_R_ADDPOLYTOSCENE;
- break;
- case CG_R_ADDLIGHTTOSCENE_JK2:
- return CG_R_ADDLIGHTTOSCENE;
- break;
- case CG_R_RENDERSCENE_JK2:
- return CG_R_RENDERSCENE;
- break;
- case CG_R_SETCOLOR_JK2:
- return CG_R_SETCOLOR;
- break;
- case CG_R_DRAWSTRETCHPIC_JK2:
- return CG_R_DRAWSTRETCHPIC;
- break;
- case CG_R_DRAWSCREENSHOT_JK2:
- return CG_R_DRAWSCREENSHOT;
- break;
- case CG_R_MODELBOUNDS_JK2:
- return CG_R_MODELBOUNDS;
- break;
- case CG_R_LERPTAG_JK2:
- return CG_R_LERPTAG;
- break;
- case CG_R_DRAWROTATEPIC_JK2:
- return CG_R_DRAWROTATEPIC;
- break;
- case CG_R_DRAWROTATEPIC2_JK2:
- return CG_R_DRAWROTATEPIC2;
- break;
- case CG_R_LA_GOGGLES_JK2:
- return CG_R_LA_GOGGLES;
- break;
- case CG_R_SCISSOR_JK2:
- return CG_R_SCISSOR;
- break;
- case CG_GETGLCONFIG_JK2:
- return CG_GETGLCONFIG;
- break;
- case CG_GETGAMESTATE_JK2:
- return CG_GETGAMESTATE;
- break;
- case CG_GETCURRENTSNAPSHOTNUMBER_JK2:
- return CG_GETCURRENTSNAPSHOTNUMBER;
- break;
- case CG_GETSNAPSHOT_JK2:
- return CG_GETSNAPSHOT;
- break;
- case CG_GETSERVERCOMMAND_JK2:
- return CG_GETSERVERCOMMAND;
- break;
- case CG_GETCURRENTCMDNUMBER_JK2:
- return CG_GETCURRENTCMDNUMBER;
- break;
- case CG_GETUSERCMD_JK2:
- return CG_GETUSERCMD;
- break;
- case CG_SETUSERCMDVALUE_JK2:
- return CG_SETUSERCMDVALUE;
- break;
- case CG_SETUSERCMDANGLES_JK2:
- return CG_SETUSERCMDANGLES;
- break;
- case CG_S_UPDATEAMBIENTSET_JK2:
- return CG_S_UPDATEAMBIENTSET;
- break;
- case CG_S_ADDLOCALSET_JK2:
- return CG_S_ADDLOCALSET;
- break;
- case CG_AS_PARSESETS_JK2:
- return CG_AS_PARSESETS;
- break;
- case CG_AS_ADDENTRY_JK2:
- return CG_AS_ADDENTRY;
- break;
- case CG_AS_GETBMODELSOUND_JK2:
- return CG_AS_GETBMODELSOUND;
- break;
- case CG_S_GETSAMPLELENGTH_JK2:
- return CG_S_GETSAMPLELENGTH;
- break;
- case COM_SETORGANGLES_JK2:
- return COM_SETORGANGLES;
- break;
-/*
-Ghoul2 Insert Start
-*/
- case CG_G2_LISTBONES_JK2:
- return CG_G2_LISTBONES;
- break;
- case CG_G2_LISTSURFACES_JK2:
- return CG_G2_LISTSURFACES;
- break;
- case CG_G2_HAVEWEGHOULMODELS_JK2:
- return CG_G2_HAVEWEGHOULMODELS;
- break;
- case CG_G2_SETMODELS_JK2:
- return CG_G2_SETMODELS;
- break;
-/*
-Ghoul2 Insert End
-*/
+ switch (import) {
+ case CG_PRINT_JK2:
+ return CG_PRINT;
+ break;
+ case CG_ERROR_JK2:
+ return CG_ERROR;
+ break;
+ case CG_MILLISECONDS_JK2:
+ return CG_MILLISECONDS;
+ break;
+ case CG_CVAR_REGISTER_JK2:
+ return CG_CVAR_REGISTER;
+ break;
+ case CG_CVAR_UPDATE_JK2:
+ return CG_CVAR_UPDATE;
+ break;
+ case CG_CVAR_SET_JK2:
+ return CG_CVAR_SET;
+ break;
+ case CG_ARGC_JK2:
+ return CG_ARGC;
+ break;
+ case CG_ARGV_JK2:
+ return CG_ARGV;
+ break;
+ case CG_ARGS_JK2:
+ return CG_ARGS;
+ break;
+ case CG_FS_FOPENFILE_JK2:
+ return CG_FS_FOPENFILE;
+ break;
+ case CG_FS_READ_JK2:
+ return CG_FS_READ;
+ break;
+ case CG_FS_WRITE_JK2:
+ return CG_FS_WRITE;
+ break;
+ case CG_FS_FCLOSEFILE_JK2:
+ return CG_FS_FCLOSEFILE;
+ break;
+ case CG_SENDCONSOLECOMMAND_JK2:
+ return CG_SENDCONSOLECOMMAND;
+ break;
+ case CG_ADDCOMMAND_JK2:
+ return CG_ADDCOMMAND;
+ break;
+ case CG_SENDCLIENTCOMMAND_JK2:
+ return CG_SENDCLIENTCOMMAND;
+ break;
+ case CG_UPDATESCREEN_JK2:
+ return CG_UPDATESCREEN;
+ break;
+ case CG_CM_LOADMAP_JK2:
+ return CG_CM_LOADMAP;
+ break;
+ case CG_CM_NUMINLINEMODELS_JK2:
+ return CG_CM_NUMINLINEMODELS;
+ break;
+ case CG_CM_INLINEMODEL_JK2:
+ return CG_CM_INLINEMODEL;
+ break;
+ case CG_CM_TEMPBOXMODEL_JK2:
+ return CG_CM_TEMPBOXMODEL;
+ break;
+ case CG_CM_POINTCONTENTS_JK2:
+ return CG_CM_POINTCONTENTS;
+ break;
+ case CG_CM_TRANSFORMEDPOINTCONTENTS_JK2:
+ return CG_CM_TRANSFORMEDPOINTCONTENTS;
+ break;
+ case CG_CM_BOXTRACE_JK2:
+ return CG_CM_BOXTRACE;
+ break;
+ case CG_CM_TRANSFORMEDBOXTRACE_JK2:
+ return CG_CM_TRANSFORMEDBOXTRACE;
+ break;
+ case CG_CM_MARKFRAGMENTS_JK2:
+ return CG_CM_MARKFRAGMENTS;
+ break;
+ case CG_CM_SNAPPVS_JK2:
+ return CG_CM_SNAPPVS;
+ break;
+ case CG_S_STARTSOUND_JK2:
+ return CG_S_STARTSOUND;
+ break;
+ case CG_S_STARTLOCALSOUND_JK2:
+ return CG_S_STARTLOCALSOUND;
+ break;
+ case CG_S_CLEARLOOPINGSOUNDS_JK2:
+ return CG_S_CLEARLOOPINGSOUNDS;
+ break;
+ case CG_S_ADDLOOPINGSOUND_JK2:
+ return CG_S_ADDLOOPINGSOUND;
+ break;
+ case CG_S_UPDATEENTITYPOSITION_JK2:
+ return CG_S_UPDATEENTITYPOSITION;
+ break;
+ case CG_S_RESPATIALIZE_JK2:
+ return CG_S_RESPATIALIZE;
+ break;
+ case CG_S_REGISTERSOUND_JK2:
+ return CG_S_REGISTERSOUND;
+ break;
+ case CG_S_STARTBACKGROUNDTRACK_JK2:
+ return CG_S_STARTBACKGROUNDTRACK;
+ break;
+ case CG_R_LOADWORLDMAP_JK2:
+ return CG_R_LOADWORLDMAP;
+ break;
+ case CG_R_REGISTERMODEL_JK2:
+ return CG_R_REGISTERMODEL;
+ break;
+ case CG_R_REGISTERSKIN_JK2:
+ return CG_R_REGISTERSKIN;
+ break;
+ case CG_R_REGISTERSHADER_JK2:
+ return CG_R_REGISTERSHADER;
+ break;
+ case CG_R_REGISTERSHADERNOMIP_JK2:
+ return CG_R_REGISTERSHADERNOMIP;
+ break;
+ case CG_R_REGISTERFONT_JK2:
+ return CG_R_REGISTERFONT;
+ break;
+ case CG_R_FONTSTRLENPIXELS_JK2:
+ return CG_R_FONTSTRLENPIXELS;
+ break;
+ case CG_R_FONTSTRLENCHARS_JK2:
+ return CG_R_FONTSTRLENCHARS;
+ break;
+ case CG_R_FONTHEIGHTPIXELS_JK2:
+ return CG_R_FONTHEIGHTPIXELS;
+ break;
+ case CG_R_FONTDRAWSTRING_JK2:
+ return CG_R_FONTDRAWSTRING;
+ break;
+ case CG_LANGUAGE_ISASIAN_JK2:
+ return CG_LANGUAGE_ISASIAN;
+ break;
+ case CG_LANGUAGE_USESSPACES_JK2:
+ return CG_LANGUAGE_USESSPACES;
+ break;
+ case CG_ANYLANGUAGE_READFROMSTRING_JK2:
+ return CG_ANYLANGUAGE_READFROMSTRING;
+ break;
+ case CG_R_CLEARSCENE_JK2:
+ return CG_R_CLEARSCENE;
+ break;
+ case CG_R_ADDREFENTITYTOSCENE_JK2:
+ return CG_R_ADDREFENTITYTOSCENE;
+ break;
+ case CG_R_GETLIGHTING_JK2:
+ return CG_R_GETLIGHTING;
+ break;
+ case CG_R_ADDPOLYTOSCENE_JK2:
+ return CG_R_ADDPOLYTOSCENE;
+ break;
+ case CG_R_ADDLIGHTTOSCENE_JK2:
+ return CG_R_ADDLIGHTTOSCENE;
+ break;
+ case CG_R_RENDERSCENE_JK2:
+ return CG_R_RENDERSCENE;
+ break;
+ case CG_R_SETCOLOR_JK2:
+ return CG_R_SETCOLOR;
+ break;
+ case CG_R_DRAWSTRETCHPIC_JK2:
+ return CG_R_DRAWSTRETCHPIC;
+ break;
+ case CG_R_DRAWSCREENSHOT_JK2:
+ return CG_R_DRAWSCREENSHOT;
+ break;
+ case CG_R_MODELBOUNDS_JK2:
+ return CG_R_MODELBOUNDS;
+ break;
+ case CG_R_LERPTAG_JK2:
+ return CG_R_LERPTAG;
+ break;
+ case CG_R_DRAWROTATEPIC_JK2:
+ return CG_R_DRAWROTATEPIC;
+ break;
+ case CG_R_DRAWROTATEPIC2_JK2:
+ return CG_R_DRAWROTATEPIC2;
+ break;
+ case CG_R_LA_GOGGLES_JK2:
+ return CG_R_LA_GOGGLES;
+ break;
+ case CG_R_SCISSOR_JK2:
+ return CG_R_SCISSOR;
+ break;
+ case CG_GETGLCONFIG_JK2:
+ return CG_GETGLCONFIG;
+ break;
+ case CG_GETGAMESTATE_JK2:
+ return CG_GETGAMESTATE;
+ break;
+ case CG_GETCURRENTSNAPSHOTNUMBER_JK2:
+ return CG_GETCURRENTSNAPSHOTNUMBER;
+ break;
+ case CG_GETSNAPSHOT_JK2:
+ return CG_GETSNAPSHOT;
+ break;
+ case CG_GETSERVERCOMMAND_JK2:
+ return CG_GETSERVERCOMMAND;
+ break;
+ case CG_GETCURRENTCMDNUMBER_JK2:
+ return CG_GETCURRENTCMDNUMBER;
+ break;
+ case CG_GETUSERCMD_JK2:
+ return CG_GETUSERCMD;
+ break;
+ case CG_SETUSERCMDVALUE_JK2:
+ return CG_SETUSERCMDVALUE;
+ break;
+ case CG_SETUSERCMDANGLES_JK2:
+ return CG_SETUSERCMDANGLES;
+ break;
+ case CG_S_UPDATEAMBIENTSET_JK2:
+ return CG_S_UPDATEAMBIENTSET;
+ break;
+ case CG_S_ADDLOCALSET_JK2:
+ return CG_S_ADDLOCALSET;
+ break;
+ case CG_AS_PARSESETS_JK2:
+ return CG_AS_PARSESETS;
+ break;
+ case CG_AS_ADDENTRY_JK2:
+ return CG_AS_ADDENTRY;
+ break;
+ case CG_AS_GETBMODELSOUND_JK2:
+ return CG_AS_GETBMODELSOUND;
+ break;
+ case CG_S_GETSAMPLELENGTH_JK2:
+ return CG_S_GETSAMPLELENGTH;
+ break;
+ case COM_SETORGANGLES_JK2:
+ return COM_SETORGANGLES;
+ break;
+ /*
+ Ghoul2 Insert Start
+ */
+ case CG_G2_LISTBONES_JK2:
+ return CG_G2_LISTBONES;
+ break;
+ case CG_G2_LISTSURFACES_JK2:
+ return CG_G2_LISTSURFACES;
+ break;
+ case CG_G2_HAVEWEGHOULMODELS_JK2:
+ return CG_G2_HAVEWEGHOULMODELS;
+ break;
+ case CG_G2_SETMODELS_JK2:
+ return CG_G2_SETMODELS;
+ break;
+ /*
+ Ghoul2 Insert End
+ */
- case CG_R_GET_LIGHT_STYLE_JK2:
- return CG_R_GET_LIGHT_STYLE;
- break;
- case CG_R_SET_LIGHT_STYLE_JK2:
- return CG_R_SET_LIGHT_STYLE;
- break;
- case CG_R_GET_BMODEL_VERTS_JK2:
- return CG_R_GET_BMODEL_VERTS;
- break;
- case CG_R_WORLD_EFFECT_COMMAND_JK2:
- return CG_R_WORLD_EFFECT_COMMAND;
- break;
-
- case CG_CIN_PLAYCINEMATIC_JK2:
- return CG_CIN_PLAYCINEMATIC;
- break;
- case CG_CIN_STOPCINEMATIC_JK2:
- return CG_CIN_STOPCINEMATIC;
- break;
- case CG_CIN_RUNCINEMATIC_JK2:
- return CG_CIN_RUNCINEMATIC;
- break;
- case CG_CIN_DRAWCINEMATIC_JK2:
- return CG_CIN_DRAWCINEMATIC;
- break;
- case CG_CIN_SETEXTENTS_JK2:
- return CG_CIN_SETEXTENTS;
- break;
- case CG_Z_MALLOC_JK2:
- return CG_Z_MALLOC;
- break;
- case CG_Z_FREE_JK2:
- return CG_Z_FREE;
- break;
- case CG_UI_MENU_RESET_JK2:
- return CG_UI_MENU_RESET;
- break;
- case CG_UI_MENU_NEW_JK2:
- return CG_UI_MENU_NEW;
- break;
- case CG_UI_PARSE_INT_JK2:
- return CG_UI_PARSE_INT;
- break;
- case CG_UI_PARSE_STRING_JK2:
- return CG_UI_PARSE_STRING;
- break;
- case CG_UI_PARSE_FLOAT_JK2:
- return CG_UI_PARSE_FLOAT;
- break;
- case CG_UI_STARTPARSESESSION_JK2:
- return CG_UI_STARTPARSESESSION;
- break;
- case CG_UI_ENDPARSESESSION_JK2:
- return CG_UI_ENDPARSESESSION;
- break;
- case CG_UI_PARSEEXT_JK2:
- return CG_UI_PARSEEXT;
- break;
- case CG_UI_MENUPAINT_ALL_JK2:
- return CG_UI_MENUPAINT_ALL;
- break;
- case CG_UI_STRING_INIT_JK2:
- return CG_UI_STRING_INIT;
- break;
- case CG_UI_GETMENUINFO_JK2:
- return CG_UI_GETMENUINFO;
- break;
- case CG_SP_REGISTER_JK2:
- return CG_SP_REGISTER;
- break;
- case CG_SP_GETSTRINGTEXT_JK2:
- return CG_SP_GETSTRINGTEXT;
- break;
- case CG_SP_GETSTRINGTEXTSTRING_JK2:
- // Both of these do the same thing --eez
- return CG_SP_GETSTRINGTEXTSTRING;
- break;
- case CG_UI_GETITEMTEXT_JK2:
- return CG_UI_GETITEMTEXT;
- break;
- case CG_ANYLANGUAGE_READFROMSTRING2_JK2:
- return CG_ANYLANGUAGE_READFROMSTRING2;
- break;
- case CG_OPENJK_MENU_PAINT_JK2:
- return CG_OPENJK_MENU_PAINT;
- break;
- case CG_OPENJK_GETMENU_BYNAME_JK2:
- return CG_OPENJK_GETMENU_BYNAME;
- break;
+ case CG_R_GET_LIGHT_STYLE_JK2:
+ return CG_R_GET_LIGHT_STYLE;
+ break;
+ case CG_R_SET_LIGHT_STYLE_JK2:
+ return CG_R_SET_LIGHT_STYLE;
+ break;
+ case CG_R_GET_BMODEL_VERTS_JK2:
+ return CG_R_GET_BMODEL_VERTS;
+ break;
+ case CG_R_WORLD_EFFECT_COMMAND_JK2:
+ return CG_R_WORLD_EFFECT_COMMAND;
+ break;
+
+ case CG_CIN_PLAYCINEMATIC_JK2:
+ return CG_CIN_PLAYCINEMATIC;
+ break;
+ case CG_CIN_STOPCINEMATIC_JK2:
+ return CG_CIN_STOPCINEMATIC;
+ break;
+ case CG_CIN_RUNCINEMATIC_JK2:
+ return CG_CIN_RUNCINEMATIC;
+ break;
+ case CG_CIN_DRAWCINEMATIC_JK2:
+ return CG_CIN_DRAWCINEMATIC;
+ break;
+ case CG_CIN_SETEXTENTS_JK2:
+ return CG_CIN_SETEXTENTS;
+ break;
+ case CG_Z_MALLOC_JK2:
+ return CG_Z_MALLOC;
+ break;
+ case CG_Z_FREE_JK2:
+ return CG_Z_FREE;
+ break;
+ case CG_UI_MENU_RESET_JK2:
+ return CG_UI_MENU_RESET;
+ break;
+ case CG_UI_MENU_NEW_JK2:
+ return CG_UI_MENU_NEW;
+ break;
+ case CG_UI_PARSE_INT_JK2:
+ return CG_UI_PARSE_INT;
+ break;
+ case CG_UI_PARSE_STRING_JK2:
+ return CG_UI_PARSE_STRING;
+ break;
+ case CG_UI_PARSE_FLOAT_JK2:
+ return CG_UI_PARSE_FLOAT;
+ break;
+ case CG_UI_STARTPARSESESSION_JK2:
+ return CG_UI_STARTPARSESESSION;
+ break;
+ case CG_UI_ENDPARSESESSION_JK2:
+ return CG_UI_ENDPARSESESSION;
+ break;
+ case CG_UI_PARSEEXT_JK2:
+ return CG_UI_PARSEEXT;
+ break;
+ case CG_UI_MENUPAINT_ALL_JK2:
+ return CG_UI_MENUPAINT_ALL;
+ break;
+ case CG_UI_STRING_INIT_JK2:
+ return CG_UI_STRING_INIT;
+ break;
+ case CG_UI_GETMENUINFO_JK2:
+ return CG_UI_GETMENUINFO;
+ break;
+ case CG_SP_REGISTER_JK2:
+ return CG_SP_REGISTER;
+ break;
+ case CG_SP_GETSTRINGTEXT_JK2:
+ return CG_SP_GETSTRINGTEXT;
+ break;
+ case CG_SP_GETSTRINGTEXTSTRING_JK2:
+ // Both of these do the same thing --eez
+ return CG_SP_GETSTRINGTEXTSTRING;
+ break;
+ case CG_UI_GETITEMTEXT_JK2:
+ return CG_UI_GETITEMTEXT;
+ break;
+ case CG_ANYLANGUAGE_READFROMSTRING2_JK2:
+ return CG_ANYLANGUAGE_READFROMSTRING2;
+ break;
+ case CG_OPENJK_MENU_PAINT_JK2:
+ return CG_OPENJK_MENU_PAINT;
+ break;
+ case CG_OPENJK_GETMENU_BYNAME_JK2:
+ return CG_OPENJK_GETMENU_BYNAME;
+ break;
}
return (cgameImport_t)-1;
}
@@ -805,62 +784,62 @@ CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
-void CM_SnapPVS(vec3_t origin,byte *buffer);
-extern void Menu_Paint(menuDef_t *menu, qboolean forcePaint);
+void CM_SnapPVS(vec3_t origin, byte *buffer);
+extern void Menu_Paint(menuDef_t *menu, qboolean forcePaint);
extern menuDef_t *Menus_FindByName(const char *p);
-intptr_t CL_CgameSystemCalls( intptr_t *args ) {
+intptr_t CL_CgameSystemCalls(intptr_t *args) {
#ifdef JK2_MODE
args[0] = (intptr_t)CL_ConvertJK2SysCall((cgameJK2Import_t)args[0]);
#endif
- switch( args[0] ) {
+ switch (args[0]) {
case CG_PRINT:
- Com_Printf( "%s", VMA(1) );
+ Com_Printf("%s", VMA(1));
return 0;
case CG_ERROR:
- Com_Error( ERR_DROP, S_COLOR_RED"%s", VMA(1) );
+ Com_Error(ERR_DROP, S_COLOR_RED "%s", VMA(1));
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
- Cvar_Register( (vmCvar_t *) VMA(1), (const char *) VMA(2), (const char *) VMA(3), args[4] );
+ Cvar_Register((vmCvar_t *)VMA(1), (const char *)VMA(2), (const char *)VMA(3), args[4]);
return 0;
case CG_CVAR_UPDATE:
- Cvar_Update( (vmCvar_t *) VMA(1) );
+ Cvar_Update((vmCvar_t *)VMA(1));
return 0;
case CG_CVAR_SET:
- Cvar_Set( (const char *) VMA(1), (const char *) VMA(2) );
+ Cvar_Set((const char *)VMA(1), (const char *)VMA(2));
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
- Cmd_ArgvBuffer( args[1], (char *) VMA(2), args[3] );
+ Cmd_ArgvBuffer(args[1], (char *)VMA(2), args[3]);
return 0;
case CG_ARGS:
- Cmd_ArgsBuffer( (char *) VMA(1), args[2] );
+ Cmd_ArgsBuffer((char *)VMA(1), args[2]);
return 0;
case CG_FS_FOPENFILE:
- return FS_FOpenFileByMode( (const char *) VMA(1), (int *) VMA(2), (fsMode_t) args[3] );
+ return FS_FOpenFileByMode((const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3]);
case CG_FS_READ:
- FS_Read( VMA(1), args[2], args[3] );
+ FS_Read(VMA(1), args[2], args[3]);
return 0;
case CG_FS_WRITE:
- FS_Write( VMA(1), args[2], args[3] );
+ FS_Write(VMA(1), args[2], args[3]);
return 0;
case CG_FS_FCLOSEFILE:
- FS_FCloseFile( args[1] );
+ FS_FCloseFile(args[1]);
return 0;
case CG_SENDCONSOLECOMMAND:
- Cbuf_AddText( (const char *) VMA(1) );
+ Cbuf_AddText((const char *)VMA(1));
return 0;
case CG_ADDCOMMAND:
- CL_AddCgameCommand( (const char *) VMA(1) );
+ CL_AddCgameCommand((const char *)VMA(1));
return 0;
case CG_SENDCLIENTCOMMAND:
- CL_AddReliableCommand( (const char *) VMA(1) );
+ CL_AddReliableCommand((const char *)VMA(1));
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
- Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
+ Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
SCR_UpdateScreen();
return 0;
case CG_RMG_INIT:
@@ -872,31 +851,32 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
return 0;
case CG_CM_LOADMAP:
- CL_CM_LoadMap( (const char *) VMA(1), (qboolean)(args[2] != 0) );
+ CL_CM_LoadMap((const char *)VMA(1), (qboolean)(args[2] != 0));
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
- return CM_InlineModel( args[1] );
+ return CM_InlineModel(args[1]);
case CG_CM_TEMPBOXMODEL:
- return CM_TempBoxModel( (const float *) VMA(1), (const float *) VMA(2) );//, (int) VMA(3) );
+ return CM_TempBoxModel((const float *)VMA(1), (const float *)VMA(2)); //, (int) VMA(3) );
case CG_CM_POINTCONTENTS:
- return CM_PointContents( (float *)VMA(1), args[2] );
+ return CM_PointContents((float *)VMA(1), args[2]);
case CG_CM_TRANSFORMEDPOINTCONTENTS:
- return CM_TransformedPointContents( (const float *) VMA(1), args[2], (const float *) VMA(3), (const float *) VMA(4) );
+ return CM_TransformedPointContents((const float *)VMA(1), args[2], (const float *)VMA(3), (const float *)VMA(4));
case CG_CM_BOXTRACE:
- CM_BoxTrace( (trace_t *) VMA(1), (const float *) VMA(2), (const float *) VMA(3), (const float *) VMA(4), (const float *) VMA(5), args[6], args[7] );
+ CM_BoxTrace((trace_t *)VMA(1), (const float *)VMA(2), (const float *)VMA(3), (const float *)VMA(4), (const float *)VMA(5), args[6], args[7]);
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
- CM_TransformedBoxTrace( (trace_t *) VMA(1), (const float *) VMA(2), (const float *) VMA(3), (const float *) VMA(4), (const float *) VMA(5), args[6], args[7], (const float *) VMA(8), (const float *) VMA(9) );
+ CM_TransformedBoxTrace((trace_t *)VMA(1), (const float *)VMA(2), (const float *)VMA(3), (const float *)VMA(4), (const float *)VMA(5), args[6], args[7],
+ (const float *)VMA(8), (const float *)VMA(9));
return 0;
case CG_CM_MARKFRAGMENTS:
- return re.MarkFragments( args[1], (float(*)[3]) VMA(2), (const float *) VMA(3), args[4], (float *) VMA(5), args[6], (markFragment_t *) VMA(7) );
+ return re.MarkFragments(args[1], (float(*)[3])VMA(2), (const float *)VMA(3), args[4], (float *)VMA(5), args[6], (markFragment_t *)VMA(7));
case CG_CM_SNAPPVS:
- CM_SnapPVS((float(*))VMA(1),(byte *) VMA(2));
+ CM_SnapPVS((float(*))VMA(1), (byte *)VMA(2));
return 0;
case CG_S_STOPSOUNDS:
- S_StopSounds( );
+ S_StopSounds();
return 0;
case CG_S_STARTSOUND:
@@ -905,7 +885,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
if (!cls.cgameStarted) {
return 0;
}
- S_StartSound( (float *) VMA(1), args[2], (soundChannel_t)args[3], args[4] );
+ S_StartSound((float *)VMA(1), args[2], (soundChannel_t)args[3], args[4]);
return 0;
case CG_S_UPDATEAMBIENTSET:
// stops an ERR_DROP internally if called illegally from game side, but note that it also gets here
@@ -913,25 +893,25 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
if (!cls.cgameStarted) {
return 0;
}
- S_UpdateAmbientSet( (const char *) VMA(1), (float *) VMA(2) );
+ S_UpdateAmbientSet((const char *)VMA(1), (float *)VMA(2));
return 0;
case CG_S_ADDLOCALSET:
- return S_AddLocalSet( (const char *) VMA(1), (float *) VMA(2), (float *) VMA(3), args[4], args[5] );
+ return S_AddLocalSet((const char *)VMA(1), (float *)VMA(2), (float *)VMA(3), args[4], args[5]);
case CG_AS_PARSESETS:
AS_ParseSets();
return 0;
case CG_AS_ADDENTRY:
- AS_AddPrecacheEntry( (const char *) VMA(1) );
+ AS_AddPrecacheEntry((const char *)VMA(1));
return 0;
case CG_AS_GETBMODELSOUND:
- return AS_GetBModelSound( (const char *) VMA(1), args[2] );
+ return AS_GetBModelSound((const char *)VMA(1), args[2]);
case CG_S_STARTLOCALSOUND:
// stops an ERR_DROP internally if called illegally from game side, but note that it also gets here
// legally during level start where normally the internal s_soundStarted check would return. So ok to hit this.
if (!cls.cgameStarted) {
return 0;
}
- S_StartLocalSound( args[1], args[2] );
+ S_StartLocalSound(args[1], args[2]);
return 0;
case CG_S_CLEARLOOPINGSOUNDS:
S_ClearLoopingSounds();
@@ -942,51 +922,51 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
if (!cls.cgameStarted) {
return 0;
}
- S_AddLoopingSound( args[1], (const float *) VMA(2), (const float *) VMA(3), args[4], (soundChannel_t)args[5] );
+ S_AddLoopingSound(args[1], (const float *)VMA(2), (const float *)VMA(3), args[4], (soundChannel_t)args[5]);
return 0;
case CG_S_UPDATEENTITYPOSITION:
- S_UpdateEntityPosition( args[1], (const float *) VMA(2) );
+ S_UpdateEntityPosition(args[1], (const float *)VMA(2));
return 0;
case CG_S_RESPATIALIZE:
- S_Respatialize( args[1], (const float *) VMA(2), (float(*)[3]) VMA(3), (qboolean)(args[4] != 0) );
+ S_Respatialize(args[1], (const float *)VMA(2), (float(*)[3])VMA(3), (qboolean)(args[4] != 0));
return 0;
case CG_S_REGISTERSOUND:
- return S_RegisterSound( (const char *) VMA(1) );
+ return S_RegisterSound((const char *)VMA(1));
case CG_S_STARTBACKGROUNDTRACK:
- S_StartBackgroundTrack( (const char *) VMA(1), (const char *) VMA(2), (qboolean)(args[3] != 0) );
+ S_StartBackgroundTrack((const char *)VMA(1), (const char *)VMA(2), (qboolean)(args[3] != 0));
return 0;
case CG_S_GETSAMPLELENGTH:
- return S_GetSampleLengthInMilliSeconds( args[1]);
+ return S_GetSampleLengthInMilliSeconds(args[1]);
case CG_R_LOADWORLDMAP:
- re.LoadWorld( (const char *) VMA(1) );
+ re.LoadWorld((const char *)VMA(1));
return 0;
case CG_R_REGISTERMODEL:
- return re.RegisterModel( (const char *) VMA(1) );
+ return re.RegisterModel((const char *)VMA(1));
case CG_R_REGISTERSKIN:
- return re.RegisterSkin( (const char *) VMA(1) );
+ return re.RegisterSkin((const char *)VMA(1));
case CG_R_REGISTERSHADER:
- return re.RegisterShader( (const char *) VMA(1) );
+ return re.RegisterShader((const char *)VMA(1));
case CG_R_REGISTERSHADERNOMIP:
- return re.RegisterShaderNoMip( (const char *) VMA(1) );
+ return re.RegisterShaderNoMip((const char *)VMA(1));
case CG_R_REGISTERFONT:
- return re.RegisterFont( (const char *) VMA(1) );
+ return re.RegisterFont((const char *)VMA(1));
case CG_R_FONTSTRLENPIXELS:
- return re.Font_StrLenPixels( (const char *) VMA(1), args[2], VMF(3) );
+ return re.Font_StrLenPixels((const char *)VMA(1), args[2], VMF(3));
case CG_R_FONTSTRLENCHARS:
- return re.Font_StrLenChars( (const char *) VMA(1) );
+ return re.Font_StrLenChars((const char *)VMA(1));
case CG_R_FONTHEIGHTPIXELS:
- return re.Font_HeightPixels( args[1], VMF(2) );
+ return re.Font_HeightPixels(args[1], VMF(2));
case CG_R_FONTDRAWSTRING:
- re.Font_DrawString(args[1],args[2], (const char *) VMA(3), (float*)args[4], args[5], args[6], VMF(7));
+ re.Font_DrawString(args[1], args[2], (const char *)VMA(3), (float *)args[4], args[5], args[6], VMF(7));
return 0;
case CG_LANGUAGE_ISASIAN:
return re.Language_IsAsian();
case CG_LANGUAGE_USESSPACES:
return re.Language_UsesSpaces();
case CG_ANYLANGUAGE_READFROMSTRING:
- return re.AnyLanguage_ReadCharFromString( (char *) VMA(1), (int *) VMA(2), (qboolean *) VMA(3) );
+ return re.AnyLanguage_ReadCharFromString((char *)VMA(1), (int *)VMA(2), (qboolean *)VMA(3));
case CG_ANYLANGUAGE_READFROMSTRING2:
- return re.AnyLanguage_ReadCharFromString2( (char **) VMA(1), (qboolean *) VMA(3) );
+ return re.AnyLanguage_ReadCharFromString2((char **)VMA(1), (qboolean *)VMA(3));
case CG_R_SETREFRACTIONPROP:
*(re.tr_distortionAlpha()) = VMF(1);
*(re.tr_distortionStretch()) = VMF(2);
@@ -997,152 +977,152 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
re.ClearScene();
return 0;
case CG_R_ADDREFENTITYTOSCENE:
- re.AddRefEntityToScene( (const refEntity_t *) VMA(1) );
+ re.AddRefEntityToScene((const refEntity_t *)VMA(1));
return 0;
case CG_R_INPVS:
- return re.R_inPVS((float *) VMA(1), (float *) VMA(2));
+ return re.R_inPVS((float *)VMA(1), (float *)VMA(2));
case CG_R_GETLIGHTING:
- return re.GetLighting( (const float * ) VMA(1), (float *) VMA(2), (float *) VMA(3), (float *) VMA(4) );
+ return re.GetLighting((const float *)VMA(1), (float *)VMA(2), (float *)VMA(3), (float *)VMA(4));
case CG_R_ADDPOLYTOSCENE:
- re.AddPolyToScene( args[1], args[2], (const polyVert_t *) VMA(3) );
+ re.AddPolyToScene(args[1], args[2], (const polyVert_t *)VMA(3));
return 0;
case CG_R_ADDLIGHTTOSCENE:
- re.AddLightToScene( (const float *) VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );
+ re.AddLightToScene((const float *)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5));
return 0;
case CG_R_RENDERSCENE:
- re.RenderScene( (const refdef_t *) VMA(1) );
+ re.RenderScene((const refdef_t *)VMA(1));
return 0;
case CG_R_SETCOLOR:
- re.SetColor( (const float *) VMA(1) );
+ re.SetColor((const float *)VMA(1));
return 0;
case CG_R_DRAWSTRETCHPIC:
- re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );
+ re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]);
return 0;
// The below was commented out for whatever reason... /me shrugs --eez
case CG_R_DRAWSCREENSHOT:
- re.DrawStretchRaw( VMF(1), VMF(2), VMF(3), VMF(4), SG_SCR_WIDTH, SG_SCR_HEIGHT, SCR_GetScreenshot(0), 0, qtrue);
+ re.DrawStretchRaw(VMF(1), VMF(2), VMF(3), VMF(4), SG_SCR_WIDTH, SG_SCR_HEIGHT, SCR_GetScreenshot(0), 0, qtrue);
return 0;
case CG_R_MODELBOUNDS:
- re.ModelBounds( args[1], (float *) VMA(2), (float *) VMA(3) );
+ re.ModelBounds(args[1], (float *)VMA(2), (float *)VMA(3));
return 0;
case CG_R_LERPTAG:
- re.LerpTag( (orientation_t *) VMA(1), args[2], args[3], args[4], VMF(5), (const char *) VMA(6) );
+ re.LerpTag((orientation_t *)VMA(1), args[2], args[3], args[4], VMF(5), (const char *)VMA(6));
return 0;
case CG_R_DRAWROTATEPIC:
- re.DrawRotatePic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), VMF(9), args[10] );
+ re.DrawRotatePic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), VMF(9), args[10]);
return 0;
case CG_R_DRAWROTATEPIC2:
- re.DrawRotatePic2( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), VMF(9), args[10] );
+ re.DrawRotatePic2(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), VMF(9), args[10]);
return 0;
case CG_R_SETRANGEFOG:
- re.SetRangedFog( VMF( 1 ) );
+ re.SetRangedFog(VMF(1));
return 0;
case CG_R_LA_GOGGLES:
re.LAGoggles();
return 0;
case CG_R_SCISSOR:
- re.Scissor( VMF(1), VMF(2), VMF(3), VMF(4));
+ re.Scissor(VMF(1), VMF(2), VMF(3), VMF(4));
return 0;
case CG_GETGLCONFIG:
- CL_GetGlconfig( (glconfig_t *) VMA(1) );
+ CL_GetGlconfig((glconfig_t *)VMA(1));
return 0;
case CG_GETGAMESTATE:
- CL_GetGameState( (gameState_t *) VMA(1) );
+ CL_GetGameState((gameState_t *)VMA(1));
return 0;
case CG_GETCURRENTSNAPSHOTNUMBER:
- CL_GetCurrentSnapshotNumber( (int *) VMA(1), (int *) VMA(2) );
+ CL_GetCurrentSnapshotNumber((int *)VMA(1), (int *)VMA(2));
return 0;
case CG_GETSNAPSHOT:
- return CL_GetSnapshot( args[1], (snapshot_t *) VMA(2) );
+ return CL_GetSnapshot(args[1], (snapshot_t *)VMA(2));
case CG_GETDEFAULTSTATE:
return CL_GetDefaultState(args[1], (entityState_t *)VMA(2));
case CG_GETSERVERCOMMAND:
- return CL_GetServerCommand( args[1] );
+ return CL_GetServerCommand(args[1]);
case CG_GETCURRENTCMDNUMBER:
return CL_GetCurrentCmdNumber();
case CG_GETUSERCMD:
- return CL_GetUserCmd( args[1], (usercmd_s *) VMA(2) );
+ return CL_GetUserCmd(args[1], (usercmd_s *)VMA(2));
case CG_SETUSERCMDVALUE:
- CL_SetUserCmdValue( args[1], VMF(2), VMF(3), VMF(4) );
+ CL_SetUserCmdValue(args[1], VMF(2), VMF(3), VMF(4));
return 0;
case CG_SETUSERCMDANGLES:
- CL_SetUserCmdAngles( VMF(1), VMF(2), VMF(3) );
+ CL_SetUserCmdAngles(VMF(1), VMF(2), VMF(3));
return 0;
case COM_SETORGANGLES:
- Com_SetOrgAngles((float *)VMA(1),(float *)VMA(2));
+ Com_SetOrgAngles((float *)VMA(1), (float *)VMA(2));
return 0;
-/*
-Ghoul2 Insert Start
-*/
+ /*
+ Ghoul2 Insert Start
+ */
case CG_G2_LISTSURFACES:
- re.G2API_ListSurfaces( (CGhoul2Info *) VMA(1) );
+ re.G2API_ListSurfaces((CGhoul2Info *)VMA(1));
return 0;
case CG_G2_LISTBONES:
- re.G2API_ListBones( (CGhoul2Info *) VMA(1), args[2]);
+ re.G2API_ListBones((CGhoul2Info *)VMA(1), args[2]);
return 0;
case CG_G2_HAVEWEGHOULMODELS:
- return re.G2API_HaveWeGhoul2Models( *((CGhoul2Info_v *)VMA(1)) );
+ return re.G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)VMA(1)));
case CG_G2_SETMODELS:
- re.G2API_SetGhoul2ModelIndexes( *((CGhoul2Info_v *)VMA(1)),(qhandle_t *)VMA(2),(qhandle_t *)VMA(3));
+ re.G2API_SetGhoul2ModelIndexes(*((CGhoul2Info_v *)VMA(1)), (qhandle_t *)VMA(2), (qhandle_t *)VMA(3));
return 0;
-/*
-Ghoul2 Insert End
-*/
+ /*
+ Ghoul2 Insert End
+ */
case CG_R_GET_LIGHT_STYLE:
- re.GetLightStyle(args[1], (byte*) VMA(2) );
+ re.GetLightStyle(args[1], (byte *)VMA(2));
return 0;
case CG_R_SET_LIGHT_STYLE:
- re.SetLightStyle(args[1], args[2] );
+ re.SetLightStyle(args[1], args[2]);
return 0;
case CG_R_GET_BMODEL_VERTS:
- re.GetBModelVerts( args[1], (float (*)[3])VMA(2), (float *)VMA(3) );
+ re.GetBModelVerts(args[1], (float(*)[3])VMA(2), (float *)VMA(3));
return 0;
case CG_R_WORLD_EFFECT_COMMAND:
- re.WorldEffectCommand( (const char *) VMA(1) );
+ re.WorldEffectCommand((const char *)VMA(1));
return 0;
case CG_CIN_PLAYCINEMATIC:
- return CIN_PlayCinematic( (const char *) VMA(1), args[2], args[3], args[4], args[5], args[6], (const char *) VMA(7));
+ return CIN_PlayCinematic((const char *)VMA(1), args[2], args[3], args[4], args[5], args[6], (const char *)VMA(7));
case CG_CIN_STOPCINEMATIC:
- return CIN_StopCinematic(args[1]);
+ return CIN_StopCinematic(args[1]);
case CG_CIN_RUNCINEMATIC:
- return CIN_RunCinematic(args[1]);
+ return CIN_RunCinematic(args[1]);
case CG_CIN_DRAWCINEMATIC:
- CIN_DrawCinematic(args[1]);
- return 0;
+ CIN_DrawCinematic(args[1]);
+ return 0;
case CG_CIN_SETEXTENTS:
- CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
- return 0;
+ CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
+ return 0;
case CG_Z_MALLOC:
- return (intptr_t)Z_Malloc(args[1], (memtag_t) args[2], qfalse);
+ return (intptr_t)Z_Malloc(args[1], (memtag_t)args[2], qfalse);
case CG_Z_FREE:
- Z_Free((void *) VMA(1));
+ Z_Free((void *)VMA(1));
return 0;
case CG_UI_SETACTIVE_MENU:
- UI_SetActiveMenu((const char *) VMA(1),NULL);
+ UI_SetActiveMenu((const char *)VMA(1), NULL);
return 0;
case CG_UI_MENU_OPENBYNAME:
- Menus_OpenByName((const char *) VMA(1));
+ Menus_OpenByName((const char *)VMA(1));
return 0;
case CG_UI_MENU_RESET:
@@ -1150,35 +1130,34 @@ Ghoul2 Insert End
return 0;
case CG_UI_MENU_NEW:
- Menu_New((char *) VMA(1));
+ Menu_New((char *)VMA(1));
return 0;
case CG_UI_PARSE_INT:
- PC_ParseInt((int *) VMA(1));
+ PC_ParseInt((int *)VMA(1));
return 0;
case CG_UI_PARSE_STRING:
- PC_ParseString((const char **) VMA(1));
+ PC_ParseString((const char **)VMA(1));
return 0;
case CG_UI_PARSE_FLOAT:
- PC_ParseFloat((float *) VMA(1));
+ PC_ParseFloat((float *)VMA(1));
return 0;
case CG_UI_STARTPARSESESSION:
- return(PC_StartParseSession((char *) VMA(1),(char **) VMA(2)));
+ return (PC_StartParseSession((char *)VMA(1), (char **)VMA(2)));
case CG_UI_ENDPARSESESSION:
- PC_EndParseSession((char *) VMA(1));
+ PC_EndParseSession((char *)VMA(1));
return 0;
case CG_UI_PARSEEXT:
char **holdPtr;
- holdPtr = (char **) VMA(1);
+ holdPtr = (char **)VMA(1);
- if(!holdPtr)
- {
+ if (!holdPtr) {
Com_Error(ERR_FATAL, "CG_UI_PARSEEXT: NULL holdPtr");
}
@@ -1194,11 +1173,11 @@ Ghoul2 Insert End
return 0;
case CG_OPENJK_MENU_PAINT:
- Menu_Paint( (menuDef_t *)VMA(1), (qboolean)(args[2] != 0) );
+ Menu_Paint((menuDef_t *)VMA(1), (qboolean)(args[2] != 0));
return 0;
case CG_OPENJK_GETMENU_BYNAME:
- return (intptr_t)Menus_FindByName( (const char *)VMA(1) );
+ return (intptr_t)Menus_FindByName((const char *)VMA(1));
case CG_UI_STRING_INIT:
String_Init();
@@ -1206,39 +1185,33 @@ Ghoul2 Insert End
case CG_UI_GETMENUINFO:
menuDef_t *menu;
- int *xPos,*yPos,*w,*h,result;
+ int *xPos, *yPos, *w, *h, result;
#ifndef JK2_MODE
- menu = Menus_FindByName((char *) VMA(1)); // Get menu
- if (menu)
- {
- xPos = (int *) VMA(2);
- *xPos = (int) menu->window.rect.x;
- yPos = (int *) VMA(3);
- *yPos = (int) menu->window.rect.y;
- w = (int *) VMA(4);
- *w = (int) menu->window.rect.w;
- h = (int *) VMA(5);
- *h = (int) menu->window.rect.h;
+ menu = Menus_FindByName((char *)VMA(1)); // Get menu
+ if (menu) {
+ xPos = (int *)VMA(2);
+ *xPos = (int)menu->window.rect.x;
+ yPos = (int *)VMA(3);
+ *yPos = (int)menu->window.rect.y;
+ w = (int *)VMA(4);
+ *w = (int)menu->window.rect.w;
+ h = (int *)VMA(5);
+ *h = (int)menu->window.rect.h;
result = qtrue;
- }
- else
- {
+ } else {
result = qfalse;
}
return result;
#else
- menu = Menus_FindByName((char *) VMA(1)); // Get menu
- if (menu)
- {
- xPos = (int *) VMA(2);
- *xPos = (int) menu->window.rect.x;
- yPos = (int *) VMA(3);
- *yPos = (int) menu->window.rect.y;
+ menu = Menus_FindByName((char *)VMA(1)); // Get menu
+ if (menu) {
+ xPos = (int *)VMA(2);
+ *xPos = (int)menu->window.rect.x;
+ yPos = (int *)VMA(3);
+ *yPos = (int)menu->window.rect.y;
result = qtrue;
- }
- else
- {
+ } else {
result = qfalse;
}
@@ -1248,75 +1221,61 @@ Ghoul2 Insert End
case CG_UI_GETITEMTEXT:
itemDef_t *item;
- menu = Menus_FindByName((char *) VMA(1)); // Get menu
+ menu = Menus_FindByName((char *)VMA(1)); // Get menu
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, (char *) VMA(2));
- if (item)
- {
- Q_strncpyz( (char *) VMA(3), item->text, 256 );
+ if (menu) {
+ item = (itemDef_s *)Menu_FindItemByName((menuDef_t *)menu, (char *)VMA(2));
+ if (item) {
+ Q_strncpyz((char *)VMA(3), item->text, 256);
result = qtrue;
- }
- else
- {
+ } else {
result = qfalse;
}
- }
- else
- {
+ } else {
result = qfalse;
}
return result;
case CG_UI_GETITEMINFO:
- menu = Menus_FindByName((char *) VMA(1)); // Get menu
+ menu = Menus_FindByName((char *)VMA(1)); // Get menu
- if (menu)
- {
+ if (menu) {
qhandle_t *background;
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, (char *) VMA(2));
- if (item)
- {
- xPos = (int *) VMA(3);
- *xPos = (int) item->window.rect.x;
- yPos = (int *) VMA(4);
- *yPos = (int) item->window.rect.y;
- w = (int *) VMA(5);
- *w = (int) item->window.rect.w;
- h = (int *) VMA(6);
- *h = (int) item->window.rect.h;
+ item = (itemDef_s *)Menu_FindItemByName((menuDef_t *)menu, (char *)VMA(2));
+ if (item) {
+ xPos = (int *)VMA(3);
+ *xPos = (int)item->window.rect.x;
+ yPos = (int *)VMA(4);
+ *yPos = (int)item->window.rect.y;
+ w = (int *)VMA(5);
+ *w = (int)item->window.rect.w;
+ h = (int *)VMA(6);
+ *h = (int)item->window.rect.h;
vec4_t *color;
- color = (vec4_t *) VMA(7);
- if (!color)
- {
+ color = (vec4_t *)VMA(7);
+ if (!color) {
return qfalse;
}
- (*color)[0] = (float) item->window.foreColor[0];
- (*color)[1] = (float) item->window.foreColor[1];
- (*color)[2] = (float) item->window.foreColor[2];
- (*color)[3] = (float) item->window.foreColor[3];
- background = (qhandle_t *) VMA(8);
- if (!background)
- {
+ (*color)[0] = (float)item->window.foreColor[0];
+ (*color)[1] = (float)item->window.foreColor[1];
+ (*color)[2] = (float)item->window.foreColor[2];
+ (*color)[3] = (float)item->window.foreColor[3];
+ background = (qhandle_t *)VMA(8);
+ if (!background) {
return qfalse;
}
*background = item->window.background;
result = qtrue;
- }
- else
- {
+ } else {
result = qfalse;
}
- }
- else
- {
+ } else {
result = qfalse;
}
@@ -1325,29 +1284,23 @@ Ghoul2 Insert End
#ifdef JK2_MODE
case CG_SP_GETSTRINGTEXTSTRING:
case CG_SP_GETSTRINGTEXT:
- const char* text;
+ const char *text;
assert(VMA(1));
-// assert(VMA(2)); // can now pass in NULL to just query the size
+ // assert(VMA(2)); // can now pass in NULL to just query the size
- if (args[0] == CG_SP_GETSTRINGTEXT)
- {
- text = JK2SP_GetStringText( args[1] );
- }
- else
- {
- text = JK2SP_GetStringTextString( (const char *) VMA(1) );
+ if (args[0] == CG_SP_GETSTRINGTEXT) {
+ text = JK2SP_GetStringText(args[1]);
+ } else {
+ text = JK2SP_GetStringTextString((const char *)VMA(1));
}
- if (VMA(2)) // only if dest buffer supplied...
+ if (VMA(2)) // only if dest buffer supplied...
{
- if ( text[0] )
- {
- Q_strncpyz( (char *) VMA(2), text, args[3] );
- }
- else
- {
- Q_strncpyz( (char *) VMA(2), "??", args[3] );
+ if (text[0]) {
+ Q_strncpyz((char *)VMA(2), text, args[3]);
+ } else {
+ Q_strncpyz((char *)VMA(2), "??", args[3]);
}
}
return strlen(text);
@@ -1356,32 +1309,28 @@ Ghoul2 Insert End
return JK2SP_Register((const char *)VMA(1), args[2] ? (SP_REGISTER_MENU | SP_REGISTER_REQUIRED) : SP_REGISTER_CLIENT);
#else
case CG_SP_GETSTRINGTEXTSTRING:
- const char* text;
+ const char *text;
assert(VMA(1));
- text = SE_GetString( (const char *) VMA(1) );
+ text = SE_GetString((const char *)VMA(1));
- if (VMA(2)) // only if dest buffer supplied...
+ if (VMA(2)) // only if dest buffer supplied...
{
- if ( text[0] )
- {
- Q_strncpyz( (char *) VMA(2), text, args[3] );
- }
- else
- {
- Com_sprintf( (char *) VMA(2), args[3], "??%s", VMA(1) );
+ if (text[0]) {
+ Q_strncpyz((char *)VMA(2), text, args[3]);
+ } else {
+ Com_sprintf((char *)VMA(2), args[3], "??%s", VMA(1));
}
}
return strlen(text);
#endif
default:
- Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] );
+ Com_Error(ERR_DROP, "Bad cgame system trap: %ld", (long int)args[0]);
}
return 0;
}
-
/*
====================
CL_InitCGame
@@ -1390,52 +1339,49 @@ Should only be called by CL_StartHunkUsers
====================
*/
extern qboolean Sys_LowPhysicalMemory();
-void CL_InitCGame( void ) {
- const char *info;
- const char *mapname;
- //int t1, t2;
+void CL_InitCGame(void) {
+ const char *info;
+ const char *mapname;
+ // int t1, t2;
- //t1 = Sys_Milliseconds();
+ // t1 = Sys_Milliseconds();
// put away the console
Con_Close();
// find the current mapname
- info = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ];
- mapname = Info_ValueForKey( info, "mapname" );
- Com_sprintf( cl.mapname, sizeof( cl.mapname ), "maps/%s.bsp", mapname );
+ info = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO];
+ mapname = Info_ValueForKey(info, "mapname");
+ Com_sprintf(cl.mapname, sizeof(cl.mapname), "maps/%s.bsp", mapname);
cls.state = CA_LOADING;
// init for this gamestate
- VM_Call( CG_INIT, clc.serverCommandSequence );
+ VM_Call(CG_INIT, clc.serverCommandSequence);
// reset any CVAR_CHEAT cvars registered by cgame
- if ( !cl_connectedToCheatServer )
+ if (!cl_connectedToCheatServer)
Cvar_SetCheatState();
// we will send a usercmd this frame, which
// will cause the server to send us the first snapshot
cls.state = CA_PRIMED;
- //t2 = Sys_Milliseconds();
+ // t2 = Sys_Milliseconds();
- //Com_Printf( "CL_InitCGame: %5.2f seconds\n", (t2-t1)/1000.0 );
- // have the renderer touch all its images, so they are present
- // on the card even if the driver does deferred loading
+ // Com_Printf( "CL_InitCGame: %5.2f seconds\n", (t2-t1)/1000.0 );
+ // have the renderer touch all its images, so they are present
+ // on the card even if the driver does deferred loading
re.EndRegistration();
// make sure everything is paged in
-// if (!Sys_LowPhysicalMemory())
- {
- Com_TouchMemory();
- }
+ // if (!Sys_LowPhysicalMemory())
+ { Com_TouchMemory(); }
// clear anything that got printed
- Con_ClearNotify ();
+ Con_ClearNotify();
}
-
/*
====================
CL_GameCommand
@@ -1443,22 +1389,20 @@ CL_GameCommand
See if the current console command is claimed by the cgame
====================
*/
-qboolean CL_GameCommand( void ) {
- if ( cls.state != CA_ACTIVE ) {
+qboolean CL_GameCommand(void) {
+ if (cls.state != CA_ACTIVE) {
return qfalse;
}
- return (qboolean)(VM_Call( CG_CONSOLE_COMMAND ) != 0);
+ return (qboolean)(VM_Call(CG_CONSOLE_COMMAND) != 0);
}
-
-
/*
=====================
CL_CGameRendering
=====================
*/
-void CL_CGameRendering( stereoFrame_t stereo ) {
+void CL_CGameRendering(stereoFrame_t stereo) {
#if 0
if ( cls.state == CA_ACTIVE ) {
static int counter;
@@ -1468,17 +1412,15 @@ void CL_CGameRendering( stereoFrame_t stereo ) {
}
}
#endif
- int timei=cl.serverTime;
- if (timei>60)
- {
- timei-=0;
+ int timei = cl.serverTime;
+ if (timei > 60) {
+ timei -= 0;
}
- re.G2API_SetTime(cl.serverTime,G2T_CG_TIME);
- VM_Call( CG_DRAW_ACTIVE_FRAME,timei, stereo, qfalse );
-// VM_Debug( 0 );
+ re.G2API_SetTime(cl.serverTime, G2T_CG_TIME);
+ VM_Call(CG_DRAW_ACTIVE_FRAME, timei, stereo, qfalse);
+ // VM_Debug( 0 );
}
-
/*
=================
CL_AdjustTimeDelta
@@ -1498,64 +1440,64 @@ during times of significant packet loss.
=================
*/
-#define RESET_TIME 300
-
-void CL_AdjustTimeDelta( void ) {
-/*
- cl.newSnapshots = qfalse;
- // if the current time is WAY off, just correct to the current value
- if ( cls.realtime + cl.serverTimeDelta < cl.frame.serverTime - RESET_TIME
- || cls.realtime + cl.serverTimeDelta > cl.frame.serverTime + RESET_TIME ) {
- cl.serverTimeDelta = cl.frame.serverTime - cls.realtime;
- cl.oldServerTime = cl.frame.serverTime;
- if ( cl_showTimeDelta->integer ) {
- Com_Printf( " " );
+#define RESET_TIME 300
+
+void CL_AdjustTimeDelta(void) {
+ /*
+ cl.newSnapshots = qfalse;
+ // if the current time is WAY off, just correct to the current value
+ if ( cls.realtime + cl.serverTimeDelta < cl.frame.serverTime - RESET_TIME
+ || cls.realtime + cl.serverTimeDelta > cl.frame.serverTime + RESET_TIME ) {
+ cl.serverTimeDelta = cl.frame.serverTime - cls.realtime;
+ cl.oldServerTime = cl.frame.serverTime;
+ if ( cl_showTimeDelta->integer ) {
+ Com_Printf( " " );
+ }
}
- }
- // if any of the frames between this and the previous snapshot
- // had to be extrapolated, nudge our sense of time back a little
- if ( cl.extrapolatedSnapshot ) {
- cl.extrapolatedSnapshot = qfalse;
- cl.serverTimeDelta -= 2;
- } else {
- // otherwise, move our sense of time forward to minimize total latency
- cl.serverTimeDelta++;
- }
+ // if any of the frames between this and the previous snapshot
+ // had to be extrapolated, nudge our sense of time back a little
+ if ( cl.extrapolatedSnapshot ) {
+ cl.extrapolatedSnapshot = qfalse;
+ cl.serverTimeDelta -= 2;
+ } else {
+ // otherwise, move our sense of time forward to minimize total latency
+ cl.serverTimeDelta++;
+ }
- if ( cl_showTimeDelta->integer ) {
- Com_Printf( "%i ", cl.serverTimeDelta );
- }
-*/
- int newDelta;
- int deltaDelta;
+ if ( cl_showTimeDelta->integer ) {
+ Com_Printf( "%i ", cl.serverTimeDelta );
+ }
+ */
+ int newDelta;
+ int deltaDelta;
cl.newSnapshots = qfalse;
newDelta = cl.frame.serverTime - cls.realtime;
- deltaDelta = abs( newDelta - cl.serverTimeDelta );
+ deltaDelta = abs(newDelta - cl.serverTimeDelta);
- if ( deltaDelta > RESET_TIME ) {
+ if (deltaDelta > RESET_TIME) {
cl.serverTimeDelta = newDelta;
- cl.oldServerTime = cl.frame.serverTime; // FIXME: is this a problem for cgame?
+ cl.oldServerTime = cl.frame.serverTime; // FIXME: is this a problem for cgame?
cl.serverTime = cl.frame.serverTime;
- if ( cl_showTimeDelta->integer ) {
- Com_Printf( " " );
+ if (cl_showTimeDelta->integer) {
+ Com_Printf(" ");
}
- } else if ( deltaDelta > 100 ) {
+ } else if (deltaDelta > 100) {
// fast adjust, cut the difference in half
- if ( cl_showTimeDelta->integer ) {
- Com_Printf( " " );
+ if (cl_showTimeDelta->integer) {
+ Com_Printf(" ");
}
- cl.serverTimeDelta = ( cl.serverTimeDelta + newDelta ) >> 1;
+ cl.serverTimeDelta = (cl.serverTimeDelta + newDelta) >> 1;
} else {
// slow drift adjust, only move 1 or 2 msec
// if any of the frames between this and the previous snapshot
// had to be extrapolated, nudge our sense of time back a little
// the granularity of +1 / -2 is too high for timescale modified frametimes
- if ( com_timescale->value == 0 || com_timescale->value == 1 ) {
- if ( cl.extrapolatedSnapshot ) {
+ if (com_timescale->value == 0 || com_timescale->value == 1) {
+ if (cl.extrapolatedSnapshot) {
cl.extrapolatedSnapshot = qfalse;
cl.serverTimeDelta -= 2;
} else {
@@ -1565,18 +1507,17 @@ void CL_AdjustTimeDelta( void ) {
}
}
- if ( cl_showTimeDelta->integer ) {
- Com_Printf( "%i ", cl.serverTimeDelta );
+ if (cl_showTimeDelta->integer) {
+ Com_Printf("%i ", cl.serverTimeDelta);
}
}
-
/*
==================
CL_FirstSnapshot
==================
*/
-void CL_FirstSnapshot( void ) {
+void CL_FirstSnapshot(void) {
re.RegisterMedia_LevelLoadEnd();
@@ -1590,9 +1531,9 @@ void CL_FirstSnapshot( void ) {
// execute the contents of activeAction now
// this is to allow scripting a timedemo to start right
// after loading
- if ( cl_activeAction->string[0] ) {
- Cbuf_AddText( cl_activeAction->string );
- Cvar_Set( "activeAction", "" );
+ if (cl_activeAction->string[0]) {
+ Cbuf_AddText(cl_activeAction->string);
+ Cvar_Set("activeAction", "");
}
}
@@ -1601,40 +1542,39 @@ void CL_FirstSnapshot( void ) {
CL_SetCGameTime
==================
*/
-void CL_SetCGameTime( void ) {
+void CL_SetCGameTime(void) {
// getting a valid frame message ends the connection process
- if ( cls.state != CA_ACTIVE ) {
- if ( cls.state != CA_PRIMED ) {
+ if (cls.state != CA_ACTIVE) {
+ if (cls.state != CA_PRIMED) {
return;
}
- if ( cl.newSnapshots ) {
+ if (cl.newSnapshots) {
cl.newSnapshots = qfalse;
CL_FirstSnapshot();
}
- if ( cls.state != CA_ACTIVE ) {
+ if (cls.state != CA_ACTIVE) {
return;
}
}
// if we have gotten to this point, cl.frame is guaranteed to be valid
- if ( !cl.frame.valid ) {
- Com_Error( ERR_DROP, "CL_SetCGameTime: !cl.snap.valid" );
+ if (!cl.frame.valid) {
+ Com_Error(ERR_DROP, "CL_SetCGameTime: !cl.snap.valid");
}
// allow pause in single player
- if ( sv_paused->integer && CL_CheckPaused() && com_sv_running->integer ) {
+ if (sv_paused->integer && CL_CheckPaused() && com_sv_running->integer) {
// paused
return;
}
- if ( cl.frame.serverTime < cl.oldFrameServerTime ) {
- Com_Error( ERR_DROP, "cl.frame.serverTime < cl.oldFrameServerTime" );
+ if (cl.frame.serverTime < cl.oldFrameServerTime) {
+ Com_Error(ERR_DROP, "cl.frame.serverTime < cl.oldFrameServerTime");
}
cl.oldFrameServerTime = cl.frame.serverTime;
-
// get our current view of time
// cl_timeNudge is a user adjustable cvar that allows more
@@ -1644,22 +1584,21 @@ void CL_SetCGameTime( void ) {
// guarantee that time will never flow backwards, even if
// serverTimeDelta made an adjustment or cl_timeNudge was changed
- if ( cl.serverTime < cl.oldServerTime ) {
+ if (cl.serverTime < cl.oldServerTime) {
cl.serverTime = cl.oldServerTime;
}
cl.oldServerTime = cl.serverTime;
// note if we are almost past the latest frame (without timeNudge),
// so we will try and adjust back a bit when the next snapshot arrives
- if ( cls.realtime + cl.serverTimeDelta >= cl.frame.serverTime - 5 ) {
+ if (cls.realtime + cl.serverTimeDelta >= cl.frame.serverTime - 5) {
cl.extrapolatedSnapshot = qtrue;
}
// if we have gotten new snapshots, drift serverTimeDelta
// don't do this every frame, or a period of packet loss would
// make a huge adjustment
- if ( cl.newSnapshots ) {
+ if (cl.newSnapshots) {
CL_AdjustTimeDelta();
}
}
-
diff --git a/code/client/cl_cin.cpp b/code/client/cl_cin.cpp
index 7cf2db8c2f..812983d31b 100644
--- a/code/client/cl_cin.cpp
+++ b/code/client/cl_cin.cpp
@@ -40,140 +40,135 @@ along with this program; if not, see .
*****************************************************************************/
#include "client.h"
-#include "client_ui.h" // CHC
+#include "client_ui.h" // CHC
#include "snd_local.h"
#include "qcommon/stringed_ingame.h"
-#define MAXSIZE 8
-#define MINSIZE 4
+#define MAXSIZE 8
+#define MINSIZE 4
-#define DEFAULT_CIN_WIDTH 512
-#define DEFAULT_CIN_HEIGHT 512
+#define DEFAULT_CIN_WIDTH 512
+#define DEFAULT_CIN_HEIGHT 512
-#define ROQ_QUAD 0x1000
-#define ROQ_QUAD_INFO 0x1001
-#define ROQ_CODEBOOK 0x1002
-#define ROQ_QUAD_VQ 0x1011
-#define ROQ_QUAD_JPEG 0x1012
-#define ROQ_QUAD_HANG 0x1013
-#define ROQ_PACKET 0x1030
-#define ZA_SOUND_MONO 0x1020
-#define ZA_SOUND_STEREO 0x1021
+#define ROQ_QUAD 0x1000
+#define ROQ_QUAD_INFO 0x1001
+#define ROQ_CODEBOOK 0x1002
+#define ROQ_QUAD_VQ 0x1011
+#define ROQ_QUAD_JPEG 0x1012
+#define ROQ_QUAD_HANG 0x1013
+#define ROQ_PACKET 0x1030
+#define ZA_SOUND_MONO 0x1020
+#define ZA_SOUND_STEREO 0x1021
-#define MAX_VIDEO_HANDLES 16
+#define MAX_VIDEO_HANDLES 16
extern void S_CIN_StopSound(sfxHandle_t sfxHandle);
-static void RoQ_init( void );
+static void RoQ_init(void);
/******************************************************************************
-*
-* Class: trFMV
-*
-* Description: RoQ/RnR manipulation routines
-* not entirely complete for first run
-*
-******************************************************************************/
-
-static long ROQ_YY_tab[256];
-static long ROQ_UB_tab[256];
-static long ROQ_UG_tab[256];
-static long ROQ_VG_tab[256];
-static long ROQ_VR_tab[256];
-static unsigned short vq2[256*16*4];
-static unsigned short vq4[256*64*4];
-static unsigned short vq8[256*256*4];
+ *
+ * Class: trFMV
+ *
+ * Description: RoQ/RnR manipulation routines
+ * not entirely complete for first run
+ *
+ ******************************************************************************/
+
+static long ROQ_YY_tab[256];
+static long ROQ_UB_tab[256];
+static long ROQ_UG_tab[256];
+static long ROQ_VG_tab[256];
+static long ROQ_VR_tab[256];
+static unsigned short vq2[256 * 16 * 4];
+static unsigned short vq4[256 * 64 * 4];
+static unsigned short vq8[256 * 256 * 4];
typedef struct {
- byte linbuf[DEFAULT_CIN_WIDTH*DEFAULT_CIN_HEIGHT*4*2];
- byte file[65536];
- short sqrTable[256];
+ byte linbuf[DEFAULT_CIN_WIDTH * DEFAULT_CIN_HEIGHT * 4 * 2];
+ byte file[65536];
+ short sqrTable[256];
- int mcomp[256];
- byte *qStatus[2][32768];
+ int mcomp[256];
+ byte *qStatus[2][32768];
- long oldXOff, oldYOff, oldysize, oldxsize;
+ long oldXOff, oldYOff, oldysize, oldxsize;
- int currentHandle;
+ int currentHandle;
} cinematics_t;
typedef struct {
- char fileName[MAX_OSPATH];
- int CIN_WIDTH, CIN_HEIGHT;
- int xpos, ypos, width, height;
- qboolean looping, holdAtEnd, dirty, alterGameState, silent, shader;
- fileHandle_t iFile; // 0 = none
- e_status status;
- unsigned int startTime;
- unsigned int lastTime;
- long tfps;
- long RoQPlayed;
- long ROQSize;
- unsigned int RoQFrameSize;
- long onQuad;
- long numQuads;
- long samplesPerLine;
- unsigned int roq_id;
- long screenDelta;
-
- void ( *VQ0)(byte *status, void *qdata );
- void ( *VQ1)(byte *status, void *qdata );
- void ( *VQNormal)(byte *status, void *qdata );
- void ( *VQBuffer)(byte *status, void *qdata );
-
- long samplesPerPixel; // defaults to 2
- byte* gray;
- unsigned int xsize, ysize, maxsize, minsize;
-
- qboolean half, smootheddouble, inMemory;
- long normalBuffer0;
- long roq_flags;
- long roqF0;
- long roqF1;
- long t[2];
- long roqFPS;
- int playonwalls;
- byte* buf;
- long drawX, drawY;
- sfxHandle_t hSFX; // 0 = none
- qhandle_t hCRAWLTEXT; // 0 = none
+ char fileName[MAX_OSPATH];
+ int CIN_WIDTH, CIN_HEIGHT;
+ int xpos, ypos, width, height;
+ qboolean looping, holdAtEnd, dirty, alterGameState, silent, shader;
+ fileHandle_t iFile; // 0 = none
+ e_status status;
+ unsigned int startTime;
+ unsigned int lastTime;
+ long tfps;
+ long RoQPlayed;
+ long ROQSize;
+ unsigned int RoQFrameSize;
+ long onQuad;
+ long numQuads;
+ long samplesPerLine;
+ unsigned int roq_id;
+ long screenDelta;
+
+ void (*VQ0)(byte *status, void *qdata);
+ void (*VQ1)(byte *status, void *qdata);
+ void (*VQNormal)(byte *status, void *qdata);
+ void (*VQBuffer)(byte *status, void *qdata);
+
+ long samplesPerPixel; // defaults to 2
+ byte *gray;
+ unsigned int xsize, ysize, maxsize, minsize;
+
+ qboolean half, smootheddouble, inMemory;
+ long normalBuffer0;
+ long roq_flags;
+ long roqF0;
+ long roqF1;
+ long t[2];
+ long roqFPS;
+ int playonwalls;
+ byte *buf;
+ long drawX, drawY;
+ sfxHandle_t hSFX; // 0 = none
+ qhandle_t hCRAWLTEXT; // 0 = none
} cin_cache;
-static cinematics_t cin;
-static cin_cache cinTable[MAX_VIDEO_HANDLES];
-static int currentHandle = -1;
-static int CL_handle = -1;
-static int CL_iPlaybackStartTime; // so I can stop users quitting playback <1 second after it starts
-
-extern int s_soundtime; // sample PAIRS
-extern int s_paintedtime; // sample PAIRS
+static cinematics_t cin;
+static cin_cache cinTable[MAX_VIDEO_HANDLES];
+static int currentHandle = -1;
+static int CL_handle = -1;
+static int CL_iPlaybackStartTime; // so I can stop users quitting playback <1 second after it starts
+extern int s_soundtime; // sample PAIRS
+extern int s_paintedtime; // sample PAIRS
void CIN_CloseAllVideos(void) {
- int i;
+ int i;
- for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {
- if (cinTable[i].fileName[0] != 0 ) {
+ for (i = 0; i < MAX_VIDEO_HANDLES; i++) {
+ if (cinTable[i].fileName[0] != 0) {
CIN_StopCinematic(i);
}
}
}
-
static int CIN_HandleForVideo(void) {
- int i;
+ int i;
- for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {
- if ( cinTable[i].fileName[0] == 0 ) {
+ for (i = 0; i < MAX_VIDEO_HANDLES; i++) {
+ if (cinTable[i].fileName[0] == 0) {
return i;
}
}
- Com_Error( ERR_DROP, "CIN_HandleForVideo: none free" );
+ Com_Error(ERR_DROP, "CIN_HandleForVideo: none free");
return -1;
}
-
-
-
//-----------------------------------------------------------------------------
// RllSetupTable
//
@@ -183,18 +178,15 @@ static int CIN_HandleForVideo(void) {
//
// Returns: Nothing
//-----------------------------------------------------------------------------
-static void RllSetupTable( void )
-{
+static void RllSetupTable(void) {
int z;
- for (z=0;z<128;z++) {
- cin.sqrTable[z] = (short)(z*z);
- cin.sqrTable[z+128] = (short)(-cin.sqrTable[z]);
+ for (z = 0; z < 128; z++) {
+ cin.sqrTable[z] = (short)(z * z);
+ cin.sqrTable[z + 128] = (short)(-cin.sqrTable[z]);
}
}
-
-
//-----------------------------------------------------------------------------
// RllDecodeMonoToMono
//
@@ -240,25 +232,23 @@ static long RllDecodeMonoToMono(unsigned char *from,short *to,unsigned int size,
//
// Returns: Number of samples placed in output buffer
//-----------------------------------------------------------------------------
-static long RllDecodeMonoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput,unsigned short flag)
-{
+static long RllDecodeMonoToStereo(unsigned char *from, short *to, unsigned int size, char signedOutput, unsigned short flag) {
unsigned int z;
int prev;
if (signedOutput)
- prev = flag - 0x8000;
+ prev = flag - 0x8000;
else
prev = flag;
for (z = 0; z < size; z++) {
prev = (short)(prev + cin.sqrTable[from[z]]);
- to[z*2+0] = to[z*2+1] = (short)(prev);
+ to[z * 2 + 0] = to[z * 2 + 1] = (short)(prev);
}
- return size; // * 2 * sizeof(short));
+ return size; // * 2 * sizeof(short));
}
-
//-----------------------------------------------------------------------------
// RllDecodeStereoToStereo
//
@@ -272,11 +262,10 @@ static long RllDecodeMonoToStereo(unsigned char *from,short *to,unsigned int siz
//
// Returns: Number of samples placed in output buffer
//-----------------------------------------------------------------------------
-static long RllDecodeStereoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag)
-{
+static long RllDecodeStereoToStereo(unsigned char *from, short *to, unsigned int size, char signedOutput, unsigned short flag) {
unsigned int z;
unsigned char *zz = from;
- int prevL, prevR;
+ int prevL, prevR;
if (signedOutput) {
prevL = (flag & 0xff00) - 0x8000;
@@ -286,17 +275,16 @@ static long RllDecodeStereoToStereo(unsigned char *from,short *to,unsigned int s
prevR = (flag & 0x00ff) << 8;
}
- for (z=0;z>1); //*sizeof(short));
+ return (size >> 1); //*sizeof(short));
}
-
//-----------------------------------------------------------------------------
// RllDecodeStereoToMono
//
@@ -334,19 +322,17 @@ static long RllDecodeStereoToMono(unsigned char *from,short *to,unsigned int siz
}
*/
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void move8_32( byte *src, byte *dst, int spl )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void move8_32(byte *src, byte *dst, int spl) {
int i;
- for(i = 0; i < 8; ++i)
- {
+ for (i = 0; i < 8; ++i) {
memcpy(dst, src, 32);
src += spl;
dst += spl;
@@ -354,19 +340,17 @@ static void move8_32( byte *src, byte *dst, int spl )
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void move4_32( byte *src, byte *dst, int spl )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void move4_32(byte *src, byte *dst, int spl) {
int i;
- for(i = 0; i < 4; ++i)
- {
+ for (i = 0; i < 4; ++i) {
memcpy(dst, src, 16);
src += spl;
dst += spl;
@@ -374,19 +358,17 @@ static void move4_32( byte *src, byte *dst, int spl )
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void blit8_32( byte *src, byte *dst, int spl )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void blit8_32(byte *src, byte *dst, int spl) {
int i;
- for(i = 0; i < 8; ++i)
- {
+ for (i = 0; i < 8; ++i) {
memcpy(dst, src, 32);
src += 32;
dst += spl;
@@ -394,18 +376,16 @@ static void blit8_32( byte *src, byte *dst, int spl )
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-static void blit4_32( byte *src, byte *dst, int spl )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+static void blit4_32(byte *src, byte *dst, int spl) {
int i;
- for(i = 0; i < 4; ++i)
- {
+ for (i = 0; i < 4; ++i) {
memmove(dst, src, 16);
src += 16;
dst += spl;
@@ -413,190 +393,193 @@ static void blit4_32( byte *src, byte *dst, int spl )
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void blit2_32( byte *src, byte *dst, int spl )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void blit2_32(byte *src, byte *dst, int spl) {
memcpy(dst, src, 8);
- memcpy(dst+spl, src+8, 8);
+ memcpy(dst + spl, src + 8, 8);
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void blitVQQuad32fs( byte **status, unsigned char *data )
-{
-unsigned short newd, celdata, code;
-unsigned int index, i;
-int spl;
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void blitVQQuad32fs(byte **status, unsigned char *data) {
+ unsigned short newd, celdata, code;
+ unsigned int index, i;
+ int spl;
- newd = 0;
+ newd = 0;
celdata = 0;
- index = 0;
+ index = 0;
- spl = cinTable[currentHandle].samplesPerLine;
+ spl = cinTable[currentHandle].samplesPerLine;
do {
if (!newd) {
newd = 7;
- celdata = data[0] + data[1]*256;
+ celdata = data[0] + data[1] * 256;
data += 2;
} else {
newd--;
}
- code = (unsigned short)(celdata&0xc000);
+ code = (unsigned short)(celdata & 0xc000);
celdata <<= 2;
switch (code) {
- case 0x8000: // vq code
- blit8_32( (byte *)&vq8[(*data)*128], status[index], spl );
- data++;
- index += 5;
- break;
- case 0xc000: // drop
- index++; // skip 8x8
- for(i=0;i<4;i++) {
- if (!newd) {
- newd = 7;
- celdata = data[0] + data[1]*256;
- data += 2;
- } else {
- newd--;
- }
+ case 0x8000: // vq code
+ blit8_32((byte *)&vq8[(*data) * 128], status[index], spl);
+ data++;
+ index += 5;
+ break;
+ case 0xc000: // drop
+ index++; // skip 8x8
+ for (i = 0; i < 4; i++) {
+ if (!newd) {
+ newd = 7;
+ celdata = data[0] + data[1] * 256;
+ data += 2;
+ } else {
+ newd--;
+ }
- code = (unsigned short)(celdata&0xc000); celdata <<= 2;
-
- switch (code) { // code in top two bits of code
- case 0x8000: // 4x4 vq code
- blit4_32( (byte *)&vq4[(*data)*32], status[index], spl );
- data++;
- break;
- case 0xc000: // 2x2 vq code
- blit2_32( (byte *)&vq2[(*data)*8], status[index], spl );
- data++;
- blit2_32( (byte *)&vq2[(*data)*8], status[index]+8, spl );
- data++;
- blit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2, spl );
- data++;
- blit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2+8, spl );
- data++;
- break;
- case 0x4000: // motion compensation
- move4_32( status[index] + cin.mcomp[(*data)], status[index], spl );
- data++;
- break;
- }
- index++;
+ code = (unsigned short)(celdata & 0xc000);
+ celdata <<= 2;
+
+ switch (code) { // code in top two bits of code
+ case 0x8000: // 4x4 vq code
+ blit4_32((byte *)&vq4[(*data) * 32], status[index], spl);
+ data++;
+ break;
+ case 0xc000: // 2x2 vq code
+ blit2_32((byte *)&vq2[(*data) * 8], status[index], spl);
+ data++;
+ blit2_32((byte *)&vq2[(*data) * 8], status[index] + 8, spl);
+ data++;
+ blit2_32((byte *)&vq2[(*data) * 8], status[index] + spl * 2, spl);
+ data++;
+ blit2_32((byte *)&vq2[(*data) * 8], status[index] + spl * 2 + 8, spl);
+ data++;
+ break;
+ case 0x4000: // motion compensation
+ move4_32(status[index] + cin.mcomp[(*data)], status[index], spl);
+ data++;
+ break;
}
- break;
- case 0x4000: // motion compensation
- move8_32( status[index] + cin.mcomp[(*data)], status[index], spl );
- data++;
- index += 5;
- break;
- case 0x0000:
- index += 5;
- break;
+ index++;
+ }
+ break;
+ case 0x4000: // motion compensation
+ move8_32(status[index] + cin.mcomp[(*data)], status[index], spl);
+ data++;
+ index += 5;
+ break;
+ case 0x0000:
+ index += 5;
+ break;
}
- } while ( status[index] != NULL );
+ } while (status[index] != NULL);
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void ROQ_GenYUVTables( void )
-{
- float t_ub,t_vr,t_ug,t_vg;
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void ROQ_GenYUVTables(void) {
+ float t_ub, t_vr, t_ug, t_vg;
long i;
- t_ub = (1.77200f/2.0f) * (float)(1<<6) + 0.5f;
- t_vr = (1.40200f/2.0f) * (float)(1<<6) + 0.5f;
- t_ug = (0.34414f/2.0f) * (float)(1<<6) + 0.5f;
- t_vg = (0.71414f/2.0f) * (float)(1<<6) + 0.5f;
- for(i=0;i<256;i++) {
+ t_ub = (1.77200f / 2.0f) * (float)(1 << 6) + 0.5f;
+ t_vr = (1.40200f / 2.0f) * (float)(1 << 6) + 0.5f;
+ t_ug = (0.34414f / 2.0f) * (float)(1 << 6) + 0.5f;
+ t_vg = (0.71414f / 2.0f) * (float)(1 << 6) + 0.5f;
+ for (i = 0; i < 256; i++) {
float x = (float)(2 * i - 255);
- ROQ_UB_tab[i] = (long)( ( t_ub * x) + (1<<5));
- ROQ_VR_tab[i] = (long)( ( t_vr * x) + (1<<5));
- ROQ_UG_tab[i] = (long)( (-t_ug * x) );
- ROQ_VG_tab[i] = (long)( (-t_vg * x) + (1<<5));
- ROQ_YY_tab[i] = (long)( (i << 6) | (i >> 2) );
+ ROQ_UB_tab[i] = (long)((t_ub * x) + (1 << 5));
+ ROQ_VR_tab[i] = (long)((t_vr * x) + (1 << 5));
+ ROQ_UG_tab[i] = (long)((-t_ug * x));
+ ROQ_VG_tab[i] = (long)((-t_vg * x) + (1 << 5));
+ ROQ_YY_tab[i] = (long)((i << 6) | (i >> 2));
}
}
-#define VQ2TO4(a,b,c,d) { \
- *c++ = a[0]; \
- *d++ = a[0]; \
- *d++ = a[0]; \
- *c++ = a[1]; \
- *d++ = a[1]; \
- *d++ = a[1]; \
- *c++ = b[0]; \
- *d++ = b[0]; \
- *d++ = b[0]; \
- *c++ = b[1]; \
- *d++ = b[1]; \
- *d++ = b[1]; \
- *d++ = a[0]; \
- *d++ = a[0]; \
- *d++ = a[1]; \
- *d++ = a[1]; \
- *d++ = b[0]; \
- *d++ = b[0]; \
- *d++ = b[1]; \
- *d++ = b[1]; \
- a += 2; b += 2; }
-
-#define VQ2TO2(a,b,c,d) { \
- *c++ = *a; \
- *d++ = *a; \
- *d++ = *a; \
- *c++ = *b; \
- *d++ = *b; \
- *d++ = *b; \
- *d++ = *a; \
- *d++ = *a; \
- *d++ = *b; \
- *d++ = *b; \
- a++; b++; }
+#define VQ2TO4(a, b, c, d) \
+ { \
+ *c++ = a[0]; \
+ *d++ = a[0]; \
+ *d++ = a[0]; \
+ *c++ = a[1]; \
+ *d++ = a[1]; \
+ *d++ = a[1]; \
+ *c++ = b[0]; \
+ *d++ = b[0]; \
+ *d++ = b[0]; \
+ *c++ = b[1]; \
+ *d++ = b[1]; \
+ *d++ = b[1]; \
+ *d++ = a[0]; \
+ *d++ = a[0]; \
+ *d++ = a[1]; \
+ *d++ = a[1]; \
+ *d++ = b[0]; \
+ *d++ = b[0]; \
+ *d++ = b[1]; \
+ *d++ = b[1]; \
+ a += 2; \
+ b += 2; \
+ }
+
+#define VQ2TO2(a, b, c, d) \
+ { \
+ *c++ = *a; \
+ *d++ = *a; \
+ *d++ = *a; \
+ *c++ = *b; \
+ *d++ = *b; \
+ *d++ = *b; \
+ *d++ = *a; \
+ *d++ = *a; \
+ *d++ = *b; \
+ *d++ = *b; \
+ a++; \
+ b++; \
+ }
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static unsigned short yuv_to_rgb( long y, long u, long v )
-{
- long r,g,b,YY = (long)(ROQ_YY_tab[(y)]);
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static unsigned short yuv_to_rgb(long y, long u, long v) {
+ long r, g, b, YY = (long)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 9;
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8;
b = (YY + ROQ_UB_tab[u]) >> 9;
- if (r<0)
+ if (r < 0)
r = 0;
- if (g<0)
+ if (g < 0)
g = 0;
- if (b<0)
+ if (b < 0)
b = 0;
if (r > 31)
r = 31;
@@ -605,30 +588,29 @@ static unsigned short yuv_to_rgb( long y, long u, long v )
if (b > 31)
b = 31;
- return (unsigned short)((r<<11)+(g<<5)+(b));
+ return (unsigned short)((r << 11) + (g << 5) + (b));
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static unsigned int yuv_to_rgb24( long y, long u, long v )
-{
- long r,g,b,YY = (long)(ROQ_YY_tab[(y)]);
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static unsigned int yuv_to_rgb24(long y, long u, long v) {
+ long r, g, b, YY = (long)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 6;
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6;
b = (YY + ROQ_UB_tab[u]) >> 6;
- if (r<0)
+ if (r < 0)
r = 0;
- if (g<0)
+ if (g < 0)
g = 0;
- if (b<0)
+ if (b < 0)
b = 0;
if (r > 255)
r = 255;
@@ -637,23 +619,22 @@ static unsigned int yuv_to_rgb24( long y, long u, long v )
if (b > 255)
b = 255;
- return LittleLong ((r)|(g<<8)|(b<<16)|(255<<24));
+ return LittleLong((r) | (g << 8) | (b << 16) | (255 << 24));
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void decodeCodeBook( byte *input, unsigned short roq_flags )
-{
- long i, j, two, four;
- unsigned short *aptr, *bptr, *cptr, *dptr;
- long y0,y1,y2,y3,cr,cb;
- byte *bbptr, *baptr, *bcptr, *bdptr;
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void decodeCodeBook(byte *input, unsigned short roq_flags) {
+ long i, j, two, four;
+ unsigned short *aptr, *bptr, *cptr, *dptr;
+ long y0, y1, y2, y3, cr, cb;
+ byte *bbptr, *baptr, *bcptr, *bdptr;
union {
unsigned int *i;
unsigned short *s;
@@ -662,9 +643,10 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
if (!roq_flags) {
two = four = 256;
} else {
- two = roq_flags>>8;
- if (!two) two = 256;
- four = roq_flags&0xff;
+ two = roq_flags >> 8;
+ if (!two)
+ two = 256;
+ four = roq_flags & 0xff;
}
four *= 2;
@@ -673,155 +655,157 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags )
if (!cinTable[currentHandle].half) {
if (!cinTable[currentHandle].smootheddouble) {
-//
-// normal height
-//
- if (cinTable[currentHandle].samplesPerPixel==2) {
- for(i=0;i cinTable[currentHandle].CIN_WIDTH) bigx = cinTable[currentHandle].CIN_WIDTH;
- if (bigy > cinTable[currentHandle].CIN_HEIGHT) bigy = cinTable[currentHandle].CIN_HEIGHT;
+ if (bigx > cinTable[currentHandle].CIN_WIDTH)
+ bigx = cinTable[currentHandle].CIN_WIDTH;
+ if (bigy > cinTable[currentHandle].CIN_HEIGHT)
+ bigy = cinTable[currentHandle].CIN_HEIGHT;
- if ( (startX >= lowx) && (startX+quadSize) <= (bigx) && (startY+quadSize) <= (bigy) && (startY >= lowy) && quadSize <= MAXSIZE) {
+ if ((startX >= lowx) && (startX + quadSize) <= (bigx) && (startY + quadSize) <= (bigy) && (startY >= lowy) && quadSize <= MAXSIZE) {
useY = startY;
- scroff = cin.linbuf + (useY+((cinTable[currentHandle].CIN_HEIGHT-bigy)>>1)+yOff)*(cinTable[currentHandle].samplesPerLine) + (((startX+xOff))*cinTable[currentHandle].samplesPerPixel);
+ scroff = cin.linbuf + (useY + ((cinTable[currentHandle].CIN_HEIGHT - bigy) >> 1) + yOff) * (cinTable[currentHandle].samplesPerLine) +
+ (((startX + xOff)) * cinTable[currentHandle].samplesPerPixel);
- cin.qStatus[0][cinTable[currentHandle].onQuad ] = scroff;
- cin.qStatus[1][cinTable[currentHandle].onQuad++] = scroff+offset;
+ cin.qStatus[0][cinTable[currentHandle].onQuad] = scroff;
+ cin.qStatus[1][cinTable[currentHandle].onQuad++] = scroff + offset;
}
- if ( quadSize != MINSIZE ) {
+ if (quadSize != MINSIZE) {
quadSize >>= 1;
- recurseQuad( startX, startY , quadSize, xOff, yOff );
- recurseQuad( startX+quadSize, startY , quadSize, xOff, yOff );
- recurseQuad( startX, startY+quadSize , quadSize, xOff, yOff );
- recurseQuad( startX+quadSize, startY+quadSize , quadSize, xOff, yOff );
+ recurseQuad(startX, startY, quadSize, xOff, yOff);
+ recurseQuad(startX + quadSize, startY, quadSize, xOff, yOff);
+ recurseQuad(startX, startY + quadSize, quadSize, xOff, yOff);
+ recurseQuad(startX + quadSize, startY + quadSize, quadSize, xOff, yOff);
}
}
-
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void setupQuad( long xOff, long yOff )
-{
- long numQuadCels, i,x,y;
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void setupQuad(long xOff, long yOff) {
+ long numQuadCels, i, x, y;
byte *temp;
- if (xOff == cin.oldXOff && yOff == cin.oldYOff && cinTable[currentHandle].ysize == (unsigned)cin.oldysize && cinTable[currentHandle].xsize == (unsigned)cin.oldxsize) {
+ if (xOff == cin.oldXOff && yOff == cin.oldYOff && cinTable[currentHandle].ysize == (unsigned)cin.oldysize &&
+ cinTable[currentHandle].xsize == (unsigned)cin.oldxsize) {
return;
}
@@ -970,53 +961,52 @@ static void setupQuad( long xOff, long yOff )
cin.oldYOff = yOff;
cin.oldysize = cinTable[currentHandle].ysize;
cin.oldxsize = cinTable[currentHandle].xsize;
-/* Enisform: Not in q3 source
- numQuadCels = (cinTable[currentHandle].CIN_WIDTH*cinTable[currentHandle].CIN_HEIGHT) / (16);
- numQuadCels += numQuadCels/4 + numQuadCels/16;
- numQuadCels += 64; // for overflow
-*/
+ /* Enisform: Not in q3 source
+ numQuadCels = (cinTable[currentHandle].CIN_WIDTH*cinTable[currentHandle].CIN_HEIGHT) / (16);
+ numQuadCels += numQuadCels/4 + numQuadCels/16;
+ numQuadCels += 64; // for overflow
+ */
- numQuadCels = (cinTable[currentHandle].xsize*cinTable[currentHandle].ysize) / (16);
- numQuadCels += numQuadCels/4;
- numQuadCels += 64; // for overflow
+ numQuadCels = (cinTable[currentHandle].xsize * cinTable[currentHandle].ysize) / (16);
+ numQuadCels += numQuadCels / 4;
+ numQuadCels += 64; // for overflow
cinTable[currentHandle].onQuad = 0;
- for(y=0;y<(long)cinTable[currentHandle].ysize;y+=16)
- for(x=0;x<(long)cinTable[currentHandle].xsize;x+=16)
- recurseQuad( x, y, 16, xOff, yOff );
+ for (y = 0; y < (long)cinTable[currentHandle].ysize; y += 16)
+ for (x = 0; x < (long)cinTable[currentHandle].xsize; x += 16)
+ recurseQuad(x, y, 16, xOff, yOff);
temp = NULL;
- for(i=(numQuadCels-64);i256) {
- cinTable[currentHandle].drawX = 256;
- }
- if (cinTable[currentHandle].drawY>256) {
- cinTable[currentHandle].drawY = 256;
- }
+ if (cls.glconfig.maxTextureSize <= 256) {
+ if (cinTable[currentHandle].drawX > 256) {
+ cinTable[currentHandle].drawX = 256;
+ }
+ if (cinTable[currentHandle].drawY > 256) {
+ cinTable[currentHandle].drawY = 256;
+ }
if (cinTable[currentHandle].CIN_WIDTH != 256 || cinTable[currentHandle].CIN_HEIGHT != 256) {
Com_Printf("HACK: approxmimating cinematic for Rage Pro or Voodoo\n");
}
@@ -1044,40 +1034,43 @@ static void readQuadInfo( byte *qData )
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void RoQPrepMcomp( long xoff, long yoff )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void RoQPrepMcomp(long xoff, long yoff) {
long i, j, x, y, temp, temp2;
- i=cinTable[currentHandle].samplesPerLine; j=cinTable[currentHandle].samplesPerPixel;
- if ( cinTable[currentHandle].xsize == (cinTable[currentHandle].ysize*4) && !cinTable[currentHandle].half ) { j = j+j; i = i+i; }
+ i = cinTable[currentHandle].samplesPerLine;
+ j = cinTable[currentHandle].samplesPerPixel;
+ if (cinTable[currentHandle].xsize == (cinTable[currentHandle].ysize * 4) && !cinTable[currentHandle].half) {
+ j = j + j;
+ i = i + i;
+ }
- for(y=0;y<16;y++) {
- temp2 = (y+yoff-8)*i;
- for(x=0;x<16;x++) {
- temp = (x+xoff-8)*j;
- cin.mcomp[(x*16)+y] = cinTable[currentHandle].normalBuffer0-(temp2+temp);
+ for (y = 0; y < 16; y++) {
+ temp2 = (y + yoff - 8) * i;
+ for (x = 0; x < 16; x++) {
+ temp = (x + xoff - 8) * j;
+ cin.mcomp[(x * 16) + y] = cinTable[currentHandle].normalBuffer0 - (temp2 + temp);
}
}
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void initRoQ( void )
-{
- if (currentHandle < 0) return;
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void initRoQ(void) {
+ if (currentHandle < 0)
+ return;
cinTable[currentHandle].VQNormal = (void (*)(byte *, void *))blitVQQuad32fs;
cinTable[currentHandle].VQBuffer = (void (*)(byte *, void *))blitVQQuad32fs;
@@ -1087,12 +1080,12 @@ static void initRoQ( void )
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
/*
static byte* RoQFetchInterlaced( byte *source ) {
int x, *src, *dst;
@@ -1109,37 +1102,38 @@ static byte* RoQFetchInterlaced( byte *source ) {
return cinTable[currentHandle].buf2;
}
*/
-static void RoQReset( void ) {
+static void RoQReset(void) {
- if (currentHandle < 0) return;
+ if (currentHandle < 0)
+ return;
- FS_FCloseFile( cinTable[currentHandle].iFile );
- FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);
+ FS_FCloseFile(cinTable[currentHandle].iFile);
+ FS_FOpenFileRead(cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);
// let the background thread start reading ahead
- FS_Read (cin.file, 16, cinTable[currentHandle].iFile);
+ FS_Read(cin.file, 16, cinTable[currentHandle].iFile);
RoQ_init();
cinTable[currentHandle].status = FMV_LOOPED;
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void RoQInterrupt(void)
-{
- byte *framedata;
- short sbuf[32768];
- int ssize;
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void RoQInterrupt(void) {
+ byte *framedata;
+ short sbuf[32768];
+ int ssize;
- if (currentHandle < 0) return;
+ if (currentHandle < 0)
+ return;
- FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile );
- if ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) {
- if (cinTable[currentHandle].holdAtEnd==qfalse) {
+ FS_Read(cin.file, cinTable[currentHandle].RoQFrameSize + 8, cinTable[currentHandle].iFile);
+ if (cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize) {
+ if (cinTable[currentHandle].holdAtEnd == qfalse) {
if (cinTable[currentHandle].looping) {
RoQReset();
} else {
@@ -1156,71 +1150,71 @@ static void RoQInterrupt(void)
// new frame is ready
//
redump:
- switch(cinTable[currentHandle].roq_id)
- {
- case ROQ_QUAD_VQ:
- if ((cinTable[currentHandle].numQuads&1)) {
- cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[1];
- RoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 );
- cinTable[currentHandle].VQ1( (byte *)cin.qStatus[1], framedata);
- cinTable[currentHandle].buf = cin.linbuf + cinTable[currentHandle].screenDelta;
- } else {
- cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[0];
- RoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 );
- cinTable[currentHandle].VQ0( (byte *)cin.qStatus[0], framedata );
- cinTable[currentHandle].buf = cin.linbuf;
- }
- if (cinTable[currentHandle].numQuads == 0) { // first frame
- Com_Memcpy(cin.linbuf+cinTable[currentHandle].screenDelta, cin.linbuf, cinTable[currentHandle].samplesPerLine*cinTable[currentHandle].ysize);
- }
- cinTable[currentHandle].numQuads++;
- cinTable[currentHandle].dirty = qtrue;
- break;
- case ROQ_CODEBOOK:
- decodeCodeBook( framedata, (unsigned short)cinTable[currentHandle].roq_flags );
- break;
- case ZA_SOUND_MONO:
- if (!cinTable[currentHandle].silent) {
- ssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
- S_RawSamples( ssize, 22050, 2, 1, (byte *)sbuf, s_volume->value, qtrue );
- }
- break;
- case ZA_SOUND_STEREO:
- if (!cinTable[currentHandle].silent) {
- if (cinTable[currentHandle].numQuads == -1) {
- S_Update();
- s_rawend = s_soundtime;
- }
- ssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
- S_RawSamples( ssize, 22050, 2, 2, (byte *)sbuf, s_volume->value, qtrue );
- }
- break;
- case ROQ_QUAD_INFO:
+ switch (cinTable[currentHandle].roq_id) {
+ case ROQ_QUAD_VQ:
+ if ((cinTable[currentHandle].numQuads & 1)) {
+ cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[1];
+ RoQPrepMcomp(cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1);
+ cinTable[currentHandle].VQ1((byte *)cin.qStatus[1], framedata);
+ cinTable[currentHandle].buf = cin.linbuf + cinTable[currentHandle].screenDelta;
+ } else {
+ cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[0];
+ RoQPrepMcomp(cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1);
+ cinTable[currentHandle].VQ0((byte *)cin.qStatus[0], framedata);
+ cinTable[currentHandle].buf = cin.linbuf;
+ }
+ if (cinTable[currentHandle].numQuads == 0) { // first frame
+ Com_Memcpy(cin.linbuf + cinTable[currentHandle].screenDelta, cin.linbuf, cinTable[currentHandle].samplesPerLine * cinTable[currentHandle].ysize);
+ }
+ cinTable[currentHandle].numQuads++;
+ cinTable[currentHandle].dirty = qtrue;
+ break;
+ case ROQ_CODEBOOK:
+ decodeCodeBook(framedata, (unsigned short)cinTable[currentHandle].roq_flags);
+ break;
+ case ZA_SOUND_MONO:
+ if (!cinTable[currentHandle].silent) {
+ ssize = RllDecodeMonoToStereo(framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
+ S_RawSamples(ssize, 22050, 2, 1, (byte *)sbuf, s_volume->value, qtrue);
+ }
+ break;
+ case ZA_SOUND_STEREO:
+ if (!cinTable[currentHandle].silent) {
if (cinTable[currentHandle].numQuads == -1) {
- readQuadInfo( framedata );
- setupQuad( 0, 0 );
- cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = Sys_Milliseconds()*com_timescale->value;
+ S_Update();
+ s_rawend = s_soundtime;
}
- if (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0;
- break;
- case ROQ_PACKET:
- cinTable[currentHandle].inMemory = (qboolean)cinTable[currentHandle].roq_flags;
- cinTable[currentHandle].RoQFrameSize = 0; // for header
- break;
- case ROQ_QUAD_HANG:
- cinTable[currentHandle].RoQFrameSize = 0;
- break;
- case ROQ_QUAD_JPEG:
- break;
- default:
- cinTable[currentHandle].status = FMV_EOF;
- break;
+ ssize = RllDecodeStereoToStereo(framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
+ S_RawSamples(ssize, 22050, 2, 2, (byte *)sbuf, s_volume->value, qtrue);
+ }
+ break;
+ case ROQ_QUAD_INFO:
+ if (cinTable[currentHandle].numQuads == -1) {
+ readQuadInfo(framedata);
+ setupQuad(0, 0);
+ cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = Sys_Milliseconds() * com_timescale->value;
+ }
+ if (cinTable[currentHandle].numQuads != 1)
+ cinTable[currentHandle].numQuads = 0;
+ break;
+ case ROQ_PACKET:
+ cinTable[currentHandle].inMemory = (qboolean)cinTable[currentHandle].roq_flags;
+ cinTable[currentHandle].RoQFrameSize = 0; // for header
+ break;
+ case ROQ_QUAD_HANG:
+ cinTable[currentHandle].RoQFrameSize = 0;
+ break;
+ case ROQ_QUAD_JPEG:
+ break;
+ default:
+ cinTable[currentHandle].status = FMV_EOF;
+ break;
}
-//
-// read in next frame data
-//
- if ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) {
- if (cinTable[currentHandle].holdAtEnd==qfalse) {
+ //
+ // read in next frame data
+ //
+ if (cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize) {
+ if (cinTable[currentHandle].holdAtEnd == qfalse) {
if (cinTable[currentHandle].looping) {
RoQReset();
} else {
@@ -1232,14 +1226,14 @@ static void RoQInterrupt(void)
return;
}
- framedata += cinTable[currentHandle].RoQFrameSize;
- cinTable[currentHandle].roq_id = framedata[0] + framedata[1]*256;
- cinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3]*256 + framedata[4]*65536;
- cinTable[currentHandle].roq_flags = framedata[6] + framedata[7]*256;
- cinTable[currentHandle].roqF0 = (signed char)framedata[7];
- cinTable[currentHandle].roqF1 = (signed char)framedata[6];
+ framedata += cinTable[currentHandle].RoQFrameSize;
+ cinTable[currentHandle].roq_id = framedata[0] + framedata[1] * 256;
+ cinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3] * 256 + framedata[4] * 65536;
+ cinTable[currentHandle].roq_flags = framedata[6] + framedata[7] * 256;
+ cinTable[currentHandle].roqF0 = (signed char)framedata[7];
+ cinTable[currentHandle].roqF1 = (signed char)framedata[6];
- if (cinTable[currentHandle].RoQFrameSize>65536||cinTable[currentHandle].roq_id==0x1084) {
+ if (cinTable[currentHandle].RoQFrameSize > 65536 || cinTable[currentHandle].roq_id == 0x1084) {
Com_DPrintf("roq_size>65536||roq_id==0x1084\n");
cinTable[currentHandle].status = FMV_EOF;
if (cinTable[currentHandle].looping) {
@@ -1247,75 +1241,72 @@ static void RoQInterrupt(void)
}
return;
}
- if (cinTable[currentHandle].inMemory && (cinTable[currentHandle].status != FMV_EOF))
- {
- cinTable[currentHandle].inMemory = (qboolean)(((int)cinTable[currentHandle].inMemory)-1);
+ if (cinTable[currentHandle].inMemory && (cinTable[currentHandle].status != FMV_EOF)) {
+ cinTable[currentHandle].inMemory = (qboolean)(((int)cinTable[currentHandle].inMemory) - 1);
framedata += 8;
goto redump;
}
-//
-// one more frame hits the dust
-//
-// assert(cinTable[currentHandle].RoQFrameSize <= 65536);
-// r = FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile );
- cinTable[currentHandle].RoQPlayed += cinTable[currentHandle].RoQFrameSize+8;
+ //
+ // one more frame hits the dust
+ //
+ // assert(cinTable[currentHandle].RoQFrameSize <= 65536);
+ // r = FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile );
+ cinTable[currentHandle].RoQPlayed += cinTable[currentHandle].RoQFrameSize + 8;
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void RoQ_init( void )
-{
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
- cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = Sys_Milliseconds()*com_timescale->value;
+static void RoQ_init(void) {
- cinTable[currentHandle].RoQPlayed = 24;
+ cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = Sys_Milliseconds() * com_timescale->value;
-/* get frame rate */
- cinTable[currentHandle].roqFPS = cin.file[ 6] + cin.file[ 7]*256;
+ cinTable[currentHandle].RoQPlayed = 24;
- if (!cinTable[currentHandle].roqFPS) cinTable[currentHandle].roqFPS = 30;
+ /* get frame rate */
+ cinTable[currentHandle].roqFPS = cin.file[6] + cin.file[7] * 256;
+ if (!cinTable[currentHandle].roqFPS)
+ cinTable[currentHandle].roqFPS = 30;
cinTable[currentHandle].numQuads = -1;
- cinTable[currentHandle].roq_id = cin.file[ 8] + cin.file[ 9]*256;
- cinTable[currentHandle].RoQFrameSize = cin.file[10] + cin.file[11]*256 + cin.file[12]*65536;
- cinTable[currentHandle].roq_flags = cin.file[14] + cin.file[15]*256;
+ cinTable[currentHandle].roq_id = cin.file[8] + cin.file[9] * 256;
+ cinTable[currentHandle].RoQFrameSize = cin.file[10] + cin.file[11] * 256 + cin.file[12] * 65536;
+ cinTable[currentHandle].roq_flags = cin.file[14] + cin.file[15] * 256;
if (cinTable[currentHandle].RoQFrameSize > 65536 || !cinTable[currentHandle].RoQFrameSize) {
return;
}
- if (cinTable[currentHandle].hSFX)
- {
+ if (cinTable[currentHandle].hSFX) {
S_StartLocalSound(cinTable[currentHandle].hSFX, CHAN_AUTO);
}
}
/******************************************************************************
-*
-* Function:
-*
-* Description:
-*
-******************************************************************************/
-
-static void RoQShutdown( void ) {
+ *
+ * Function:
+ *
+ * Description:
+ *
+ ******************************************************************************/
+
+static void RoQShutdown(void) {
const char *s;
if (!cinTable[currentHandle].buf) {
if (cinTable[currentHandle].iFile) {
-// assert( 0 && "ROQ handle leak-prevention WAS needed!");
- FS_FCloseFile( cinTable[currentHandle].iFile );
+ // assert( 0 && "ROQ handle leak-prevention WAS needed!");
+ FS_FCloseFile(cinTable[currentHandle].iFile);
cinTable[currentHandle].iFile = 0;
if (cinTable[currentHandle].hSFX) {
- S_CIN_StopSound( cinTable[currentHandle].hSFX );
+ S_CIN_StopSound(cinTable[currentHandle].hSFX);
}
}
return;
@@ -1329,10 +1320,10 @@ static void RoQShutdown( void ) {
cinTable[currentHandle].status = FMV_IDLE;
if (cinTable[currentHandle].iFile) {
- FS_FCloseFile( cinTable[currentHandle].iFile );
+ FS_FCloseFile(cinTable[currentHandle].iFile);
cinTable[currentHandle].iFile = 0;
if (cinTable[currentHandle].hSFX) {
- S_CIN_StopSound( cinTable[currentHandle].hSFX );
+ S_CIN_StopSound(cinTable[currentHandle].hSFX);
}
}
@@ -1342,10 +1333,10 @@ static void RoQShutdown( void ) {
// if we are aborting the intro cinematic with
// a devmap command, nextmap would be valid by
// the time it was referenced
- s = Cvar_VariableString( "nextmap" );
- if ( s[0] ) {
- Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", s) );
- Cvar_Set( "nextmap", "" );
+ s = Cvar_VariableString("nextmap");
+ if (s[0]) {
+ Cbuf_ExecuteText(EXEC_APPEND, va("%s\n", s));
+ Cvar_Set("nextmap", "");
}
CL_handle = -1;
}
@@ -1361,26 +1352,27 @@ CIN_StopCinematic
e_status CIN_StopCinematic(int handle) {
- if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF;
+ if (handle < 0 || handle >= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF)
+ return FMV_EOF;
currentHandle = handle;
Com_DPrintf("trFMV::stop(), closing %s\n", cinTable[currentHandle].fileName);
if (!cinTable[currentHandle].buf) {
if (cinTable[currentHandle].iFile) {
-// assert( 0 && "ROQ handle leak-prevention WAS needed!");
- FS_FCloseFile( cinTable[currentHandle].iFile );
+ // assert( 0 && "ROQ handle leak-prevention WAS needed!");
+ FS_FCloseFile(cinTable[currentHandle].iFile);
cinTable[currentHandle].iFile = 0;
cinTable[currentHandle].fileName[0] = 0;
if (cinTable[currentHandle].hSFX) {
- S_CIN_StopSound( cinTable[currentHandle].hSFX );
+ S_CIN_StopSound(cinTable[currentHandle].hSFX);
}
}
return FMV_EOF;
}
if (cinTable[currentHandle].alterGameState) {
- if ( cls.state != CA_CINEMATIC ) {
+ if (cls.state != CA_CINEMATIC) {
return cinTable[currentHandle].status;
}
}
@@ -1398,13 +1390,12 @@ Fetch and decompress the pending frame
==================
*/
+e_status CIN_RunCinematic(int handle) {
+ int start = 0;
+ int thisTime = 0;
-e_status CIN_RunCinematic (int handle)
-{
- int start = 0;
- int thisTime = 0;
-
- if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF;
+ if (handle < 0 || handle >= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF)
+ return FMV_EOF;
if (cin.currentHandle != handle) {
currentHandle = handle;
@@ -1413,15 +1404,14 @@ e_status CIN_RunCinematic (int handle)
RoQReset();
}
- if (cinTable[handle].playonwalls < -1)
- {
+ if (cinTable[handle].playonwalls < -1) {
return cinTable[handle].status;
}
currentHandle = handle;
if (cinTable[currentHandle].alterGameState) {
- if ( cls.state != CA_CINEMATIC ) {
+ if (cls.state != CA_CINEMATIC) {
return cinTable[currentHandle].status;
}
}
@@ -1430,20 +1420,19 @@ e_status CIN_RunCinematic (int handle)
return cinTable[currentHandle].status;
}
- thisTime = Sys_Milliseconds()*com_timescale->value;
- if (cinTable[currentHandle].shader && (abs(thisTime - (double)cinTable[currentHandle].lastTime))>100) {
+ thisTime = Sys_Milliseconds() * com_timescale->value;
+ if (cinTable[currentHandle].shader && (abs(thisTime - (double)cinTable[currentHandle].lastTime)) > 100) {
cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime;
}
- cinTable[currentHandle].tfps = ((((Sys_Milliseconds()*com_timescale->value) - cinTable[currentHandle].startTime)*cinTable[currentHandle].roqFPS)/1000);
+ cinTable[currentHandle].tfps =
+ ((((Sys_Milliseconds() * com_timescale->value) - cinTable[currentHandle].startTime) * cinTable[currentHandle].roqFPS) / 1000);
start = cinTable[currentHandle].startTime;
- while( (cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads)
- && (cinTable[currentHandle].status == FMV_PLAY) )
- {
+ while ((cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads) && (cinTable[currentHandle].status == FMV_PLAY)) {
RoQInterrupt();
if ((unsigned)start != cinTable[currentHandle].startTime) {
- cinTable[currentHandle].tfps = ((((Sys_Milliseconds()*com_timescale->value)
- - cinTable[currentHandle].startTime)*cinTable[currentHandle].roqFPS)/1000);
+ cinTable[currentHandle].tfps =
+ ((((Sys_Milliseconds() * com_timescale->value) - cinTable[currentHandle].startTime) * cinTable[currentHandle].roqFPS) / 1000);
start = cinTable[currentHandle].startTime;
}
}
@@ -1455,18 +1444,18 @@ e_status CIN_RunCinematic (int handle)
}
if (cinTable[currentHandle].status == FMV_EOF) {
- if (cinTable[currentHandle].looping) {
- RoQReset();
- } else {
- RoQShutdown();
- }
+ if (cinTable[currentHandle].looping) {
+ RoQReset();
+ } else {
+ RoQShutdown();
+ }
}
return cinTable[currentHandle].status;
}
-void Menus_CloseAll(void);
-void UI_Cursor_Show(qboolean flag);
+void Menus_CloseAll(void);
+void UI_Cursor_Show(qboolean flag);
/*
==================
@@ -1474,22 +1463,21 @@ CL_PlayCinematic
==================
*/
-int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits, const char *psAudioFile /* = NULL */ )
-{
+int CIN_PlayCinematic(const char *arg, int x, int y, int w, int h, int systemBits, const char *psAudioFile /* = NULL */) {
unsigned short RoQID;
- char name[MAX_OSPATH];
- int i;
+ char name[MAX_OSPATH];
+ int i;
if (strstr(arg, "/") == NULL && strstr(arg, "\\") == NULL) {
- Com_sprintf (name, sizeof(name), "video/%s", arg);
+ Com_sprintf(name, sizeof(name), "video/%s", arg);
} else {
- Com_sprintf (name, sizeof(name), "%s", arg);
+ Com_sprintf(name, sizeof(name), "%s", arg);
}
- COM_DefaultExtension(name,sizeof(name),".roq");
+ COM_DefaultExtension(name, sizeof(name), ".roq");
if (!(systemBits & CIN_system)) {
- for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {
- if (!strcmp(cinTable[i].fileName, name) ) {
+ for (i = 0; i < MAX_VIDEO_HANDLES; i++) {
+ if (!strcmp(cinTable[i].fileName, name)) {
return i;
}
}
@@ -1497,7 +1485,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
Com_DPrintf("CIN_PlayCinematic( %s )\n", arg);
- memset(&cin, 0, sizeof(cinematics_t) );
+ memset(&cin, 0, sizeof(cinematics_t));
currentHandle = CIN_HandleForVideo();
cin.currentHandle = currentHandle;
@@ -1505,10 +1493,10 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
Q_strncpyz(cinTable[currentHandle].fileName, name, MAX_OSPATH);
cinTable[currentHandle].ROQSize = 0;
- cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);
+ cinTable[currentHandle].ROQSize = FS_FOpenFileRead(cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);
- if (cinTable[currentHandle].ROQSize<=0) {
- Com_Printf(S_COLOR_RED"ERROR: playCinematic: %s not found!\n", arg);
+ if (cinTable[currentHandle].ROQSize <= 0) {
+ Com_Printf(S_COLOR_RED "ERROR: playCinematic: %s not found!\n", arg);
cinTable[currentHandle].fileName[0] = 0;
return -1;
}
@@ -1517,46 +1505,38 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
CIN_SetLooping(currentHandle, (qboolean)((systemBits & CIN_loop) != 0));
cinTable[currentHandle].CIN_HEIGHT = DEFAULT_CIN_HEIGHT;
- cinTable[currentHandle].CIN_WIDTH = DEFAULT_CIN_WIDTH;
+ cinTable[currentHandle].CIN_WIDTH = DEFAULT_CIN_WIDTH;
cinTable[currentHandle].holdAtEnd = (qboolean)((systemBits & CIN_hold) != 0);
cinTable[currentHandle].alterGameState = (qboolean)((systemBits & CIN_system) != 0);
cinTable[currentHandle].playonwalls = 1;
cinTable[currentHandle].silent = (qboolean)((systemBits & CIN_silent) != 0);
cinTable[currentHandle].shader = (qboolean)((systemBits & CIN_shader) != 0);
- if (psAudioFile)
- {
+ if (psAudioFile) {
cinTable[currentHandle].hSFX = S_RegisterSound(psAudioFile);
- }
- else
- {
+ } else {
cinTable[currentHandle].hSFX = 0;
}
cinTable[currentHandle].hCRAWLTEXT = 0;
- if (cinTable[currentHandle].alterGameState)
- {
+ if (cinTable[currentHandle].alterGameState) {
// close the menu
Con_Close();
- if (cls.uiStarted)
- {
+ if (cls.uiStarted) {
UI_Cursor_Show(qfalse);
Menus_CloseAll();
}
- }
- else
- {
+ } else {
cinTable[currentHandle].playonwalls = cl_inGameVideo->integer;
}
initRoQ();
- FS_Read (cin.file, 16, cinTable[currentHandle].iFile);
+ FS_Read(cin.file, 16, cinTable[currentHandle].iFile);
- RoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1])*256;
- if (RoQID == 0x1084)
- {
+ RoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1]) * 256;
+ if (RoQID == 0x1084) {
RoQ_init();
-// FS_Read (cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile);
+ // FS_Read (cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile);
cinTable[currentHandle].status = FMV_PLAY;
Com_DPrintf("trFMV::play(), playing %s\n", arg);
@@ -1567,7 +1547,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
Con_Close();
- if ( !cinTable[currentHandle].silent )
+ if (!cinTable[currentHandle].silent)
s_rawend = s_soundtime;
return currentHandle;
@@ -1578,8 +1558,9 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
return -1;
}
-void CIN_SetExtents (int handle, int x, int y, int w, int h) {
- if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;
+void CIN_SetExtents(int handle, int x, int y, int w, int h) {
+ if (handle < 0 || handle >= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF)
+ return;
cinTable[handle].xpos = x;
cinTable[handle].ypos = y;
cinTable[handle].width = w;
@@ -1588,29 +1569,29 @@ void CIN_SetExtents (int handle, int x, int y, int w, int h) {
}
void CIN_SetLooping(int handle, qboolean loop) {
- if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;
+ if (handle < 0 || handle >= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF)
+ return;
cinTable[handle].looping = loop;
}
// Text crawl defines
-#define TC_PLANE_WIDTH 250
-#define TC_PLANE_NEAR 90
-#define TC_PLANE_FAR 715
-#define TC_PLANE_TOP 0
-#define TC_PLANE_BOTTOM 1100
+#define TC_PLANE_WIDTH 250
+#define TC_PLANE_NEAR 90
+#define TC_PLANE_FAR 715
+#define TC_PLANE_TOP 0
+#define TC_PLANE_BOTTOM 1100
#define TC_DELAY 9000
#define TC_STOPTIME 81000
-static void CIN_AddTextCrawl()
-{
- refdef_t refdef;
- polyVert_t verts[4];
+static void CIN_AddTextCrawl() {
+ refdef_t refdef;
+ polyVert_t verts[4];
// Set up refdef
- memset( &refdef, 0, sizeof( refdef ));
+ memset(&refdef, 0, sizeof(refdef));
refdef.rdflags = RDF_NOWORLDMODEL;
- AxisClear( refdef.viewaxis );
+ AxisClear(refdef.viewaxis);
refdef.fov_x = 130;
refdef.fov_y = 130;
@@ -1625,58 +1606,53 @@ static void CIN_AddTextCrawl()
// Set up the poly verts
float fadeDown = 1.0;
- if (cls.realtime-CL_iPlaybackStartTime >= (TC_STOPTIME-2500))
- {
- fadeDown = (TC_STOPTIME - (cls.realtime-CL_iPlaybackStartTime))/ 2480.0f;
- if (fadeDown < 0)
- {
+ if (cls.realtime - CL_iPlaybackStartTime >= (TC_STOPTIME - 2500)) {
+ fadeDown = (TC_STOPTIME - (cls.realtime - CL_iPlaybackStartTime)) / 2480.0f;
+ if (fadeDown < 0) {
fadeDown = 0;
}
- if (fadeDown > 1)
- {
+ if (fadeDown > 1) {
fadeDown = 1;
}
}
- for ( int i = 0; i < 4; i++ )
- {
- verts[i].modulate[0] = 255*fadeDown; // gold color?
- verts[i].modulate[1] = 235*fadeDown;
- verts[i].modulate[2] = 127*fadeDown;
- verts[i].modulate[3] = 255*fadeDown;
+ for (int i = 0; i < 4; i++) {
+ verts[i].modulate[0] = 255 * fadeDown; // gold color?
+ verts[i].modulate[1] = 235 * fadeDown;
+ verts[i].modulate[2] = 127 * fadeDown;
+ verts[i].modulate[3] = 255 * fadeDown;
}
- VectorScaleM( verts[2].modulate, 0.1f, verts[2].modulate ); // darken at the top??
- VectorScaleM( verts[3].modulate, 0.1f, verts[3].modulate );
+ VectorScaleM(verts[2].modulate, 0.1f, verts[2].modulate); // darken at the top??
+ VectorScaleM(verts[3].modulate, 0.1f, verts[3].modulate);
-#define TIMEOFFSET +(cls.realtime-CL_iPlaybackStartTime-TC_DELAY)*0.000015f -1
- VectorSet( verts[0].xyz, TC_PLANE_NEAR, -TC_PLANE_WIDTH, TC_PLANE_TOP );
+#define TIMEOFFSET +(cls.realtime - CL_iPlaybackStartTime - TC_DELAY) * 0.000015f - 1
+ VectorSet(verts[0].xyz, TC_PLANE_NEAR, -TC_PLANE_WIDTH, TC_PLANE_TOP);
verts[0].st[0] = 1;
verts[0].st[1] = 1 TIMEOFFSET;
- VectorSet( verts[1].xyz, TC_PLANE_NEAR, TC_PLANE_WIDTH, TC_PLANE_TOP );
+ VectorSet(verts[1].xyz, TC_PLANE_NEAR, TC_PLANE_WIDTH, TC_PLANE_TOP);
verts[1].st[0] = 0;
verts[1].st[1] = 1 TIMEOFFSET;
- VectorSet( verts[2].xyz, TC_PLANE_FAR, TC_PLANE_WIDTH, TC_PLANE_BOTTOM );
+ VectorSet(verts[2].xyz, TC_PLANE_FAR, TC_PLANE_WIDTH, TC_PLANE_BOTTOM);
verts[2].st[0] = 0;
verts[2].st[1] = 0 TIMEOFFSET;
- VectorSet( verts[3].xyz, TC_PLANE_FAR, -TC_PLANE_WIDTH, TC_PLANE_BOTTOM );
+ VectorSet(verts[3].xyz, TC_PLANE_FAR, -TC_PLANE_WIDTH, TC_PLANE_BOTTOM);
verts[3].st[0] = 1;
verts[3].st[1] = 0 TIMEOFFSET;
// render it out
re.ClearScene();
- re.AddPolyToScene( cinTable[CL_handle].hCRAWLTEXT, 4, verts );
- re.RenderScene( &refdef );
+ re.AddPolyToScene(cinTable[CL_handle].hCRAWLTEXT, 4, verts);
+ re.RenderScene(&refdef);
- //time's up
- if (cls.realtime-CL_iPlaybackStartTime >= TC_STOPTIME)
- {
-// cinTable[currentHandle].holdAtEnd = qfalse;
+ // time's up
+ if (cls.realtime - CL_iPlaybackStartTime >= TC_STOPTIME) {
+ // cinTable[currentHandle].holdAtEnd = qfalse;
cinTable[CL_handle].status = FMV_EOF;
RoQShutdown();
- SCR_StopCinematic(); // change ROQ from FMV_IDLE to FMV_EOF, and clear some other vars
+ SCR_StopCinematic(); // change ROQ from FMV_IDLE to FMV_EOF, and clear some other vars
}
}
@@ -1689,52 +1665,52 @@ Resample cinematic to 256x256 and store in buf2
*/
void CIN_ResampleCinematic(int handle, int *buf2) {
int ix, iy, *buf3, xm, ym, ll;
- byte *buf;
+ byte *buf;
buf = cinTable[handle].buf;
- xm = cinTable[handle].CIN_WIDTH/256;
- ym = cinTable[handle].CIN_HEIGHT/256;
+ xm = cinTable[handle].CIN_WIDTH / 256;
+ ym = cinTable[handle].CIN_HEIGHT / 256;
ll = 8;
- if (cinTable[handle].CIN_WIDTH==512) {
+ if (cinTable[handle].CIN_WIDTH == 512) {
ll = 9;
}
- buf3 = (int*)buf;
- if (xm==2 && ym==2) {
+ buf3 = (int *)buf;
+ if (xm == 2 && ym == 2) {
byte *bc2, *bc3;
- int ic, iiy;
+ int ic, iiy;
bc2 = (byte *)buf2;
bc3 = (byte *)buf3;
- for (iy = 0; iy<256; iy++) {
- iiy = iy<<12;
- for (ix = 0; ix<2048; ix+=8) {
- for(ic = ix;ic<(ix+4);ic++) {
- *bc2=(bc3[iiy+ic]+bc3[iiy+4+ic]+bc3[iiy+2048+ic]+bc3[iiy+2048+4+ic])>>2;
+ for (iy = 0; iy < 256; iy++) {
+ iiy = iy << 12;
+ for (ix = 0; ix < 2048; ix += 8) {
+ for (ic = ix; ic < (ix + 4); ic++) {
+ *bc2 = (bc3[iiy + ic] + bc3[iiy + 4 + ic] + bc3[iiy + 2048 + ic] + bc3[iiy + 2048 + 4 + ic]) >> 2;
bc2++;
}
}
}
- } else if (xm==2 && ym==1) {
+ } else if (xm == 2 && ym == 1) {
byte *bc2, *bc3;
- int ic, iiy;
+ int ic, iiy;
bc2 = (byte *)buf2;
bc3 = (byte *)buf3;
- for (iy = 0; iy<256; iy++) {
- iiy = iy<<11;
- for (ix = 0; ix<2048; ix+=8) {
- for(ic = ix;ic<(ix+4);ic++) {
- *bc2=(bc3[iiy+ic]+bc3[iiy+4+ic])>>1;
+ for (iy = 0; iy < 256; iy++) {
+ iiy = iy << 11;
+ for (ix = 0; ix < 2048; ix += 8) {
+ for (ic = ix; ic < (ix + 4); ic++) {
+ *bc2 = (bc3[iiy + ic] + bc3[iiy + 4 + ic]) >> 1;
bc2++;
}
}
}
} else {
- for (iy = 0; iy<256; iy++) {
- for (ix = 0; ix<256; ix++) {
- buf2[(iy<<8)+ix] = buf3[((iy*ym)<= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;
+ if (handle < 0 || handle >= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF)
+ return;
if (!cinTable[handle].buf) {
return;
@@ -1765,211 +1742,172 @@ void CIN_DrawCinematic (int handle) {
if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) {
int *buf2;
- //buf2 = (int *)Hunk_AllocateTempMemory( 256*256*4 );
- buf2 = (int*)Z_Malloc( 256*256*4, TAG_TEMP_WORKSPACE, qfalse );
+ // buf2 = (int *)Hunk_AllocateTempMemory( 256*256*4 );
+ buf2 = (int *)Z_Malloc(256 * 256 * 4, TAG_TEMP_WORKSPACE, qfalse);
CIN_ResampleCinematic(handle, buf2);
- re.DrawStretchRaw( x, y, w, h, 256, 256, (byte *)buf2, handle, qtrue);
+ re.DrawStretchRaw(x, y, w, h, 256, 256, (byte *)buf2, handle, qtrue);
cinTable[handle].dirty = qfalse;
- Z_Free(buf2); //Hunk_FreeTempMemory(buf2);
+ Z_Free(buf2); // Hunk_FreeTempMemory(buf2);
return;
}
- re.DrawStretchRaw( x, y, w, h, cinTable[handle].drawX, cinTable[handle].drawY, buf, handle, cinTable[handle].dirty);
+ re.DrawStretchRaw(x, y, w, h, cinTable[handle].drawX, cinTable[handle].drawY, buf, handle, cinTable[handle].dirty);
cinTable[handle].dirty = qfalse;
}
// external vars so I can check if the game is setup enough that I can play the intro video...
//
-extern qboolean com_fullyInitialized;
+extern qboolean com_fullyInitialized;
extern qboolean s_soundStarted, s_soundMuted;
//
// ... and if the app isn't ready yet (which should only apply for the intro video), then I use these...
//
-static char sPendingCinematic_Arg [256]={0};
-static char sPendingCinematic_s [256]={0};
+static char sPendingCinematic_Arg[256] = {0};
+static char sPendingCinematic_s[256] = {0};
static qboolean gbPendingCinematic = qfalse;
//
// This stuff is for EF1-type ingame cinematics...
//
static qboolean qbPlayingInGameCinematic = qfalse;
static qboolean qbInGameCinematicOnStandBy = qfalse;
-static char sInGameCinematicStandingBy[MAX_QPATH];
-static char sTextCrawlFixedCinematic[MAX_QPATH];
+static char sInGameCinematicStandingBy[MAX_QPATH];
+static char sTextCrawlFixedCinematic[MAX_QPATH];
static qboolean qbTextCrawlFixed = qfalse;
-static int stopCinematicCallCount = 0;
-
+static int stopCinematicCallCount = 0;
-
-static qboolean CIN_HardwareReadyToPlayVideos(void)
-{
- if (com_fullyInitialized && cls.rendererStarted &&
- cls.soundStarted &&
- cls.soundRegistered
- )
- {
+static qboolean CIN_HardwareReadyToPlayVideos(void) {
+ if (com_fullyInitialized && cls.rendererStarted && cls.soundStarted && cls.soundRegistered) {
return qtrue;
}
return qfalse;
}
-
-static void PlayCinematic(const char *arg, const char *s, qboolean qbInGame)
-{
+static void PlayCinematic(const char *arg, const char *s, qboolean qbInGame) {
qboolean bFailed = qfalse;
- Cvar_Set( "timescale", "1" ); // jic we were skipping a scripted cinematic, return to normal after playing video
- Cvar_Set( "skippingCinematic", "0" ); // ""
+ Cvar_Set("timescale", "1"); // jic we were skipping a scripted cinematic, return to normal after playing video
+ Cvar_Set("skippingCinematic", "0"); // ""
- if(qbInGameCinematicOnStandBy == qfalse)
- {
+ if (qbInGameCinematicOnStandBy == qfalse) {
qbTextCrawlFixed = qfalse;
- }
- else
- {
+ } else {
qbInGameCinematicOnStandBy = qfalse;
}
- int bits = qbInGame?0:CIN_system;
+ int bits = qbInGame ? 0 : CIN_system;
Com_DPrintf("CL_PlayCinematic_f\n");
char sTemp[1024];
if (strstr(arg, "/") == NULL && strstr(arg, "\\") == NULL) {
- Com_sprintf (sTemp, sizeof(sTemp), "video/%s", arg);
+ Com_sprintf(sTemp, sizeof(sTemp), "video/%s", arg);
} else {
- Com_sprintf (sTemp, sizeof(sTemp), "%s", arg);
+ Com_sprintf(sTemp, sizeof(sTemp), "%s", arg);
}
- COM_DefaultExtension(sTemp,sizeof(sTemp),".roq");
+ COM_DefaultExtension(sTemp, sizeof(sTemp), ".roq");
arg = &sTemp[0];
- extern qboolean S_FileExists( const char *psFilename );
- if (S_FileExists( arg ))
- {
+ extern qboolean S_FileExists(const char *psFilename);
+ if (S_FileExists(arg)) {
SCR_StopCinematic();
// command-line hack to avoid problems when playing intro video before app is fully setup...
//
- if (!CIN_HardwareReadyToPlayVideos())
- {
- Q_strncpyz(sPendingCinematic_Arg,arg, 256);
- Q_strncpyz(sPendingCinematic_s , (s&&s[0])?s:"", 256);
+ if (!CIN_HardwareReadyToPlayVideos()) {
+ Q_strncpyz(sPendingCinematic_Arg, arg, 256);
+ Q_strncpyz(sPendingCinematic_s, (s && s[0]) ? s : "", 256);
gbPendingCinematic = qtrue;
return;
}
qbPlayingInGameCinematic = qbInGame;
- if ((s && s[0] == '1') || Q_stricmp(arg,"video/end.roq")==0) {
+ if ((s && s[0] == '1') || Q_stricmp(arg, "video/end.roq") == 0) {
bits |= CIN_hold;
}
if (s && s[0] == '2') {
bits |= CIN_loop;
}
- S_StopAllSounds ();
-
+ S_StopAllSounds();
////////////////////////////////////////////////////////////////////
//
// work out associated audio-overlay file, if any...
//
extern cvar_t *s_language;
- qboolean bIsForeign = (qboolean)(s_language && Q_stricmp(s_language->string,"english") && Q_stricmp(s_language->string,""));
- const char *psAudioFile = NULL;
- qhandle_t hCrawl = 0;
- if (!Q_stricmp(arg,"video/jk0101_sw.roq"))
- {
+ qboolean bIsForeign = (qboolean)(s_language && Q_stricmp(s_language->string, "english") && Q_stricmp(s_language->string, ""));
+ const char *psAudioFile = NULL;
+ qhandle_t hCrawl = 0;
+ if (!Q_stricmp(arg, "video/jk0101_sw.roq")) {
psAudioFile = "music/cinematic_1";
#ifdef JK2_MODE
- hCrawl = re.RegisterShaderNoMip( va("menu/video/tc_%d", sp_language->integer) );
- if(!hCrawl)
- {
+ hCrawl = re.RegisterShaderNoMip(va("menu/video/tc_%d", sp_language->integer));
+ if (!hCrawl) {
// failed, so go back to english
- hCrawl = re.RegisterShaderNoMip( "menu/video/tc_0" );
+ hCrawl = re.RegisterShaderNoMip("menu/video/tc_0");
}
#else
- hCrawl = re.RegisterShaderNoMip( va("menu/video/tc_%s",se_language->string) );
- if (!hCrawl)
- {
- hCrawl = re.RegisterShaderNoMip( "menu/video/tc_english" );//failed, so go back to english
+ hCrawl = re.RegisterShaderNoMip(va("menu/video/tc_%s", se_language->string));
+ if (!hCrawl) {
+ hCrawl = re.RegisterShaderNoMip("menu/video/tc_english"); // failed, so go back to english
}
#endif
bits |= CIN_hold;
- }
- else
- if (bIsForeign)
- {
- if (!Q_stricmp(arg,"video/jk05.roq"))
- {
+ } else if (bIsForeign) {
+ if (!Q_stricmp(arg, "video/jk05.roq")) {
psAudioFile = "sound/chars/video/cinematic_5";
- bits |= CIN_silent; // knock out existing english track
- }
- else
- if (!Q_stricmp(arg,"video/jk06.roq"))
- {
+ bits |= CIN_silent; // knock out existing english track
+ } else if (!Q_stricmp(arg, "video/jk06.roq")) {
psAudioFile = "sound/chars/video/cinematic_6";
- bits |= CIN_silent; // knock out existing english track
+ bits |= CIN_silent; // knock out existing english track
}
}
//
////////////////////////////////////////////////////////////////////
- CL_handle = CIN_PlayCinematic( arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits, psAudioFile );
- if (CL_handle >= 0)
- {
+ CL_handle = CIN_PlayCinematic(arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits, psAudioFile);
+ if (CL_handle >= 0) {
cinTable[CL_handle].hCRAWLTEXT = hCrawl;
- do
- {
+ do {
SCR_RunCinematic();
- }
- while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY); // wait for first frame (load codebook and sound)
+ } while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY); // wait for first frame (load codebook and sound)
- if (qbInGame)
- {
- Cvar_SetValue( "cl_paused", 1); // remove-menu call will have unpaused us, so we sometimes need to re-pause
+ if (qbInGame) {
+ Cvar_SetValue("cl_paused", 1); // remove-menu call will have unpaused us, so we sometimes need to re-pause
}
- CL_iPlaybackStartTime = cls.realtime; // special use to avoid accidentally skipping ingame videos via fast-firing
- }
- else
- {
+ CL_iPlaybackStartTime = cls.realtime; // special use to avoid accidentally skipping ingame videos via fast-firing
+ } else {
// failed to open video...
//
bFailed = qtrue;
}
- }
- else
- {
+ } else {
// failed to open video...
//
bFailed = qtrue;
}
- if (bFailed)
- {
- Com_Printf(S_COLOR_RED "PlayCinematic(): Failed to open \"%s\"\n",arg);
- //S_RestartMusic(); //restart the level music
- SCR_StopCinematic(); // I know this seems pointless, but it clears a bunch of vars as well
- }
- else
- {
+ if (bFailed) {
+ Com_Printf(S_COLOR_RED "PlayCinematic(): Failed to open \"%s\"\n", arg);
+ // S_RestartMusic(); //restart the level music
+ SCR_StopCinematic(); // I know this seems pointless, but it clears a bunch of vars as well
+ } else {
// this doesn't work for now...
//
-// if (cls.state == CA_ACTIVE){
-// re.InitDissolve(qfalse); // so we get a dissolve between previous screen image and cinematic
-// }
+ // if (cls.state == CA_ACTIVE){
+ // re.InitDissolve(qfalse); // so we get a dissolve between previous screen image and cinematic
+ // }
}
}
-
-qboolean CL_CheckPendingCinematic(void)
-{
- if ( gbPendingCinematic && CIN_HardwareReadyToPlayVideos() )
- {
- gbPendingCinematic = qfalse; // BEFORE next line, or we get recursion
- PlayCinematic(sPendingCinematic_Arg,sPendingCinematic_s[0]?sPendingCinematic_s:NULL,qfalse);
+qboolean CL_CheckPendingCinematic(void) {
+ if (gbPendingCinematic && CIN_HardwareReadyToPlayVideos()) {
+ gbPendingCinematic = qfalse; // BEFORE next line, or we get recursion
+ PlayCinematic(sPendingCinematic_Arg, sPendingCinematic_s[0] ? sPendingCinematic_s : NULL, qfalse);
return qtrue;
}
return qfalse;
@@ -1980,144 +1918,113 @@ qboolean CL_CheckPendingCinematic(void)
CL_CompleteCinematic
==================
*/
-void CL_CompleteCinematic( char *args, int argNum ) {
- if ( argNum == 2 )
- Field_CompleteFilename( "video", "roq", qtrue, qfalse );
+void CL_CompleteCinematic(char *args, int argNum) {
+ if (argNum == 2)
+ Field_CompleteFilename("video", "roq", qtrue, qfalse);
}
-void CL_PlayCinematic_f(void)
-{
- const char *arg, *s;
+void CL_PlayCinematic_f(void) {
+ const char *arg, *s;
- arg = Cmd_Argv( 1 );
+ arg = Cmd_Argv(1);
s = Cmd_Argv(2);
- PlayCinematic(arg,s,qfalse);
+ PlayCinematic(arg, s, qfalse);
}
-void CL_PlayInGameCinematic_f(void)
-{
- const char *arg = Cmd_Argv( 1 );
- if (cls.state == CA_ACTIVE)
- {
- PlayCinematic(arg,NULL,qtrue);
- }
- else if( !qbInGameCinematicOnStandBy )
- {
+void CL_PlayInGameCinematic_f(void) {
+ const char *arg = Cmd_Argv(1);
+ if (cls.state == CA_ACTIVE) {
+ PlayCinematic(arg, NULL, qtrue);
+ } else if (!qbInGameCinematicOnStandBy) {
Q_strncpyz(sInGameCinematicStandingBy, arg, MAX_QPATH);
qbInGameCinematicOnStandBy = qtrue;
- }
- else
- {
+ } else {
// hack in order to fix text crawl --eez
Q_strncpyz(sTextCrawlFixedCinematic, arg, MAX_QPATH);
qbTextCrawlFixed = qtrue;
}
}
-
// Externally-called only, and only if cls.state == CA_CINEMATIC (or CL_IsRunningInGameCinematic() == true now)
//
-void SCR_DrawCinematic (void)
-{
- if (CL_InGameCinematicOnStandBy())
- {
- PlayCinematic(sInGameCinematicStandingBy,NULL,qtrue);
- }
- else if( qbTextCrawlFixed && stopCinematicCallCount > 1)
- {
+void SCR_DrawCinematic(void) {
+ if (CL_InGameCinematicOnStandBy()) {
+ PlayCinematic(sInGameCinematicStandingBy, NULL, qtrue);
+ } else if (qbTextCrawlFixed && stopCinematicCallCount > 1) {
PlayCinematic(sTextCrawlFixedCinematic, NULL, qtrue);
}
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {
CIN_DrawCinematic(CL_handle);
- if (cinTable[CL_handle].hCRAWLTEXT && (cls.realtime - CL_iPlaybackStartTime >= TC_DELAY))
- {
+ if (cinTable[CL_handle].hCRAWLTEXT && (cls.realtime - CL_iPlaybackStartTime >= TC_DELAY)) {
CIN_AddTextCrawl();
}
}
}
-void SCR_RunCinematic (void)
-{
+void SCR_RunCinematic(void) {
CL_CheckPendingCinematic();
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {
e_status Status = CIN_RunCinematic(CL_handle);
- if (CL_IsRunningInGameCinematic() && Status == FMV_IDLE && !cinTable[CL_handle].holdAtEnd)
- {
- SCR_StopCinematic(); // change ROQ from FMV_IDLE to FMV_EOF, and clear some other vars
+ if (CL_IsRunningInGameCinematic() && Status == FMV_IDLE && !cinTable[CL_handle].holdAtEnd) {
+ SCR_StopCinematic(); // change ROQ from FMV_IDLE to FMV_EOF, and clear some other vars
}
}
}
-void SCR_StopCinematic( qboolean bAllowRefusal /* = qfalse */ )
-{
- if (bAllowRefusal)
- {
- if ( (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES)
- &&
- cls.realtime < CL_iPlaybackStartTime + 1200 // 1.2 seconds have to have elapsed
- )
- {
+void SCR_StopCinematic(qboolean bAllowRefusal /* = qfalse */) {
+ if (bAllowRefusal) {
+ if ((CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) && cls.realtime < CL_iPlaybackStartTime + 1200 // 1.2 seconds have to have elapsed
+ ) {
return;
}
}
- if ( CL_IsRunningInGameCinematic())
- {
+ if (CL_IsRunningInGameCinematic()) {
Com_DPrintf("In-game Cinematic Stopped\n");
}
- if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES &&
- stopCinematicCallCount != 1) { // hello no, don't want this plz
+ if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES && stopCinematicCallCount != 1) { // hello no, don't want this plz
CIN_StopCinematic(CL_handle);
- S_StopAllSounds ();
+ S_StopAllSounds();
CL_handle = -1;
- if (CL_IsRunningInGameCinematic()){
- re.InitDissolve(qfalse); // dissolve from cinematic to underlying ingame
+ if (CL_IsRunningInGameCinematic()) {
+ re.InitDissolve(qfalse); // dissolve from cinematic to underlying ingame
}
}
- if (cls.state == CA_CINEMATIC)
- {
+ if (cls.state == CA_CINEMATIC) {
Com_DPrintf("Cinematic Stopped\n");
- cls.state = CA_DISCONNECTED;
+ cls.state = CA_DISCONNECTED;
}
- if(sInGameCinematicStandingBy[0] &&
- qbTextCrawlFixed)
- {
+ if (sInGameCinematicStandingBy[0] && qbTextCrawlFixed) {
// Hacky fix to help deal with broken text crawl..
// If we are skipping past the one on standby, DO NOT SKIP THE OTHER ONES!
stopCinematicCallCount++;
- }
- else if(stopCinematicCallCount == 1)
- {
+ } else if (stopCinematicCallCount == 1) {
stopCinematicCallCount++;
- }
- else
- {
+ } else {
// Skipping the last one in the list, go ahead and kill it.
qbTextCrawlFixed = qfalse;
sTextCrawlFixedCinematic[0] = 0;
stopCinematicCallCount = 0;
}
- if(stopCinematicCallCount != 2)
- {
+ if (stopCinematicCallCount != 2) {
qbPlayingInGameCinematic = qfalse;
qbInGameCinematicOnStandBy = qfalse;
- sInGameCinematicStandingBy[0]=0;
- Cvar_SetValue( "cl_paused", 0 );
+ sInGameCinematicStandingBy[0] = 0;
+ Cvar_SetValue("cl_paused", 0);
}
- if (cls.state != CA_DISCONNECTED) // cut down on needless calls to music code
+ if (cls.state != CA_DISCONNECTED) // cut down on needless calls to music code
{
- S_RestartMusic(); //restart the level music
+ S_RestartMusic(); // restart the level music
}
}
-
void CIN_UploadCinematic(int handle) {
if (handle >= 0 && handle < MAX_VIDEO_HANDLES) {
if (!cinTable[handle].buf) {
@@ -2136,41 +2043,30 @@ void CIN_UploadCinematic(int handle) {
}
// Resample the video if needed
- if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) {
+ if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) {
int *buf2;
- buf2 = (int *)Z_Malloc(256*256*4, TAG_TEMP_WORKSPACE, qfalse);
+ buf2 = (int *)Z_Malloc(256 * 256 * 4, TAG_TEMP_WORKSPACE, qfalse);
CIN_ResampleCinematic(handle, buf2);
- re.UploadCinematic( 256, 256, (byte *)buf2, handle, qtrue);
+ re.UploadCinematic(256, 256, (byte *)buf2, handle, qtrue);
cinTable[handle].dirty = qfalse;
Z_Free(buf2);
} else {
// Upload video at normal resolution
- re.UploadCinematic( cinTable[handle].drawX, cinTable[handle].drawY,
- cinTable[handle].buf, handle, cinTable[handle].dirty);
+ re.UploadCinematic(cinTable[handle].drawX, cinTable[handle].drawY, cinTable[handle].buf, handle, cinTable[handle].dirty);
cinTable[handle].dirty = qfalse;
}
if (cl_inGameVideo->integer == 0 && cinTable[handle].playonwalls == 1) {
cinTable[handle].playonwalls--;
- }
- else if (cl_inGameVideo->integer != 0 && cinTable[handle].playonwalls != 1) {
+ } else if (cl_inGameVideo->integer != 0 && cinTable[handle].playonwalls != 1) {
cinTable[handle].playonwalls = 1;
}
}
}
+qboolean CL_IsRunningInGameCinematic(void) { return qbPlayingInGameCinematic; }
-qboolean CL_IsRunningInGameCinematic(void)
-{
- return qbPlayingInGameCinematic;
-}
-
-qboolean CL_InGameCinematicOnStandBy(void)
-{
- return qbInGameCinematicOnStandBy;
-}
-
-
+qboolean CL_InGameCinematicOnStandBy(void) { return qbInGameCinematicOnStandBy; }
diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp
index f175cbcaf5..b80c6a3867 100644
--- a/code/client/cl_console.cpp
+++ b/code/client/cl_console.cpp
@@ -32,48 +32,47 @@ along with this program; if not, see .
int g_console_field_width = 78;
-console_t con;
+console_t con;
-cvar_t *con_conspeed;
-cvar_t *con_notifytime;
-cvar_t *con_opacity; // background alpha multiplier
-cvar_t *con_autoclear;
-cvar_t *con_height;
-cvar_t *con_scale;
-cvar_t *con_timestamps;
+cvar_t *con_conspeed;
+cvar_t *con_notifytime;
+cvar_t *con_opacity; // background alpha multiplier
+cvar_t *con_autoclear;
+cvar_t *con_height;
+cvar_t *con_scale;
+cvar_t *con_timestamps;
-#define DEFAULT_CONSOLE_WIDTH 78
+#define DEFAULT_CONSOLE_WIDTH 78
-#define CON_BLANK_CHAR ' '
-#define CON_SCROLL_L_CHAR '$'
-#define CON_SCROLL_R_CHAR '$'
-#define CON_TIMESTAMP_LEN 11 // "[13:37:00] "
-#define CON_MIN_WIDTH 20
+#define CON_BLANK_CHAR ' '
+#define CON_SCROLL_L_CHAR '$'
+#define CON_SCROLL_R_CHAR '$'
+#define CON_TIMESTAMP_LEN 11 // "[13:37:00] "
+#define CON_MIN_WIDTH 20
+static const conChar_t CON_WRAP = {{ColorIndex(COLOR_GREY), '\\'}};
+static const conChar_t CON_BLANK = {{ColorIndex(COLOR_WHITE), CON_BLANK_CHAR}};
-static const conChar_t CON_WRAP = { { ColorIndex(COLOR_GREY), '\\' } };
-static const conChar_t CON_BLANK = { { ColorIndex(COLOR_WHITE), CON_BLANK_CHAR } };
-
-vec4_t console_color = {0.509f, 0.609f, 0.847f, 1.0f};
+vec4_t console_color = {0.509f, 0.609f, 0.847f, 1.0f};
/*
================
Con_ToggleConsole_f
================
*/
-void Con_ToggleConsole_f (void) {
+void Con_ToggleConsole_f(void) {
// closing a full screen console restarts the demo loop
- if ( cls.state == CA_DISCONNECTED && Key_GetCatcher( ) == KEYCATCH_CONSOLE ) {
-// CL_StartDemoLoop();
+ if (cls.state == CA_DISCONNECTED && Key_GetCatcher() == KEYCATCH_CONSOLE) {
+ // CL_StartDemoLoop();
return;
}
- if( con_autoclear->integer )
- Field_Clear( &g_consoleField );
+ if (con_autoclear->integer)
+ Field_Clear(&g_consoleField);
g_consoleField.widthInChars = g_console_field_width;
- Con_ClearNotify ();
- Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_CONSOLE );
+ Con_ClearNotify();
+ Key_SetCatcher(Key_GetCatcher() ^ KEYCATCH_CONSOLE);
}
/*
@@ -81,9 +80,9 @@ void Con_ToggleConsole_f (void) {
Con_ToggleMenu_f
===================
*/
-void Con_ToggleMenu_f( void ) {
- CL_KeyEvent( A_ESCAPE, qtrue, Sys_Milliseconds() );
- CL_KeyEvent( A_ESCAPE, qfalse, Sys_Milliseconds() );
+void Con_ToggleMenu_f(void) {
+ CL_KeyEvent(A_ESCAPE, qtrue, Sys_Milliseconds());
+ CL_KeyEvent(A_ESCAPE, qfalse, Sys_Milliseconds());
}
/*
@@ -91,14 +90,14 @@ void Con_ToggleMenu_f( void ) {
Con_Clear_f
================
*/
-void Con_Clear_f (void) {
- int i;
+void Con_Clear_f(void) {
+ int i;
- for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) {
+ for (i = 0; i < CON_TEXTSIZE; i++) {
con.text[i] = CON_BLANK;
}
- Con_Bottom(); // go to end
+ Con_Bottom(); // go to end
}
/*
@@ -108,56 +107,50 @@ Con_Dump_f
Save the console contents out to a file
================
*/
-void Con_Dump_f (void)
-{
- char filename[MAX_QPATH];
- qboolean empty;
- int l, i, j;
- int line;
- int lineLen;
- fileHandle_t f;
+void Con_Dump_f(void) {
+ char filename[MAX_QPATH];
+ qboolean empty;
+ int l, i, j;
+ int line;
+ int lineLen;
+ fileHandle_t f;
#ifdef WIN32
- char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 2];
+ char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 2];
#else
- char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 1];
+ char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 1];
#endif
- if (Cmd_Argc() != 2)
- {
- Com_Printf ("%s\n", SE_GetString("CON_TEXT_DUMP_USAGE"));
+ if (Cmd_Argc() != 2) {
+ Com_Printf("%s\n", SE_GetString("CON_TEXT_DUMP_USAGE"));
return;
}
- Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
- COM_DefaultExtension( filename, sizeof( filename ), ".txt" );
+ Q_strncpyz(filename, Cmd_Argv(1), sizeof(filename));
+ COM_DefaultExtension(filename, sizeof(filename), ".txt");
- if(!COM_CompareExtension(filename, ".txt"))
- {
- Com_Printf( "Con_Dump_f: Only the \".txt\" extension is supported by this command!\n" );
+ if (!COM_CompareExtension(filename, ".txt")) {
+ Com_Printf("Con_Dump_f: Only the \".txt\" extension is supported by this command!\n");
return;
}
- f = FS_FOpenFileWrite( filename );
- if (!f)
- {
- Com_Printf ("ERROR: couldn't open %s.\n", filename);
+ f = FS_FOpenFileWrite(filename);
+ if (!f) {
+ Com_Printf("ERROR: couldn't open %s.\n", filename);
return;
}
- Com_Printf ("Dumped console text to %s.\n", filename );
+ Com_Printf("Dumped console text to %s.\n", filename);
// skip empty lines
- for (l = 1, empty = qtrue ; l < con.totallines && empty ; l++)
- {
+ for (l = 1, empty = qtrue; l < con.totallines && empty; l++) {
line = ((con.current + l) % con.totallines) * con.rowwidth;
- for (j = CON_TIMESTAMP_LEN ; j < con.rowwidth - 1 ; j++)
+ for (j = CON_TIMESTAMP_LEN; j < con.rowwidth - 1; j++)
if (con.text[line + j].f.character != CON_BLANK_CHAR)
empty = qfalse;
}
- for ( ; l < con.totallines ; l++)
- {
+ for (; l < con.totallines; l++) {
lineLen = 0;
i = 0;
@@ -172,8 +165,7 @@ void Con_Dump_f (void)
}
// Concatenate wrapped lines
- for ( ; l < con.totallines ; l++)
- {
+ for (; l < con.totallines; l++) {
line = ((con.current + l) % con.totallines) * con.rowwidth;
for (j = CON_TIMESTAMP_LEN; j < con.rowwidth - 1 && i < (int)sizeof(buffer) - 1; j++, i++) {
@@ -192,7 +184,7 @@ void Con_Dump_f (void)
#ifdef WIN32 // I really don't like this inconsistency, but OpenJK has been doing this since April 2013
buffer[lineLen] = '\r';
- buffer[lineLen+1] = '\n';
+ buffer[lineLen + 1] = '\n';
FS_Write(buffer, lineLen + 2, f);
#else
buffer[lineLen] = '\n';
@@ -200,19 +192,18 @@ void Con_Dump_f (void)
#endif
}
- FS_FCloseFile( f );
+ FS_FCloseFile(f);
}
-
/*
================
Con_ClearNotify
================
*/
-void Con_ClearNotify( void ) {
- int i;
+void Con_ClearNotify(void) {
+ int i;
- for ( i = 0 ; i < NUM_CON_TIMES ; i++ ) {
+ for (i = 0; i < NUM_CON_TIMES; i++) {
con.times[i] = 0;
}
}
@@ -224,9 +215,8 @@ Con_Initialize
Initialize console for the first time.
================
*/
-void Con_Initialize(void)
-{
- int i;
+void Con_Initialize(void) {
+ int i;
VectorCopy4(colorWhite, con.color);
con.charWidth = SMALLCHAR_WIDTH;
@@ -238,16 +228,13 @@ void Con_Initialize(void)
con.display = con.current;
con.xadjust = 1.0f;
con.yadjust = 1.0f;
- for(i=0; i= SMALLCHAR_WIDTH);
@@ -387,21 +370,19 @@ void Con_CheckResize (void)
con.yadjust = ((float)SCREEN_HEIGHT) / cls.glconfig.vidHeight;
g_consoleField.widthInChars = width - 1; // Command prompt
- if (con.rowwidth != rowwidth)
- {
+ if (con.rowwidth != rowwidth) {
Con_Resize(rowwidth);
}
}
-
/*
==================
Cmd_CompleteTxtName
==================
*/
-void Cmd_CompleteTxtName( char *args, int argNum ) {
- if ( argNum == 2 )
- Field_CompleteFilename( "", "txt", qfalse, qtrue );
+void Cmd_CompleteTxtName(char *args, int argNum) {
+ if (argNum == 2)
+ Field_CompleteFilename("", "txt", qfalse, qtrue);
}
/*
@@ -409,60 +390,57 @@ void Cmd_CompleteTxtName( char *args, int argNum ) {
Con_Init
================
*/
-void Con_Init (void) {
- int i;
+void Con_Init(void) {
+ int i;
- con_notifytime = Cvar_Get ("con_notifytime", "3", 0);
- con_conspeed = Cvar_Get ("scr_conspeed", "3", 0);
- Cvar_CheckRange (con_conspeed, 1.0f, 100.0f, qfalse);
+ con_notifytime = Cvar_Get("con_notifytime", "3", 0);
+ con_conspeed = Cvar_Get("scr_conspeed", "3", 0);
+ Cvar_CheckRange(con_conspeed, 1.0f, 100.0f, qfalse);
- con_opacity = Cvar_Get ("con_opacity", "0.8", CVAR_ARCHIVE_ND);
- con_autoclear = Cvar_Get ("con_autoclear", "1", CVAR_ARCHIVE_ND);
- con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND);
+ con_opacity = Cvar_Get("con_opacity", "0.8", CVAR_ARCHIVE_ND);
+ con_autoclear = Cvar_Get("con_autoclear", "1", CVAR_ARCHIVE_ND);
+ con_height = Cvar_Get("con_height", "0.5", CVAR_ARCHIVE_ND);
- con_scale = Cvar_Get ("con_scale", "1", CVAR_ARCHIVE_ND);
- con_timestamps = Cvar_Get ("con_timestamps", "0", CVAR_ARCHIVE_ND);
+ con_scale = Cvar_Get("con_scale", "1", CVAR_ARCHIVE_ND);
+ con_timestamps = Cvar_Get("con_timestamps", "0", CVAR_ARCHIVE_ND);
- Field_Clear( &g_consoleField );
+ Field_Clear(&g_consoleField);
g_consoleField.widthInChars = g_console_field_width;
- for ( i = 0 ; i < COMMAND_HISTORY ; i++ ) {
- Field_Clear( &historyEditLines[i] );
+ for (i = 0; i < COMMAND_HISTORY; i++) {
+ Field_Clear(&historyEditLines[i]);
historyEditLines[i].widthInChars = g_console_field_width;
}
- Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
- Cmd_AddCommand ("togglemenu", Con_ToggleMenu_f);
- Cmd_AddCommand ("clear", Con_Clear_f);
- Cmd_AddCommand ("condump", Con_Dump_f);
- Cmd_SetCommandCompletionFunc( "condump", Cmd_CompleteTxtName );
+ Cmd_AddCommand("toggleconsole", Con_ToggleConsole_f);
+ Cmd_AddCommand("togglemenu", Con_ToggleMenu_f);
+ Cmd_AddCommand("clear", Con_Clear_f);
+ Cmd_AddCommand("condump", Con_Dump_f);
+ Cmd_SetCommandCompletionFunc("condump", Cmd_CompleteTxtName);
- //Initialize values on first print
+ // Initialize values on first print
con.initialized = qfalse;
}
-
/*
===============
Con_Linefeed
===============
*/
-void Con_Linefeed (void)
-{
- int i;
- int line = (con.current % con.totallines) * con.rowwidth;
+void Con_Linefeed(void) {
+ int i;
+ int line = (con.current % con.totallines) * con.rowwidth;
// print timestamp on the PREVIOUS line
{
- time_t t = time( NULL );
- struct tm *tms = localtime( &t );
+ time_t t = time(NULL);
+ struct tm *tms = localtime(&t);
char timestamp[CON_TIMESTAMP_LEN + 1];
const unsigned char color = ColorIndex(COLOR_GREY);
- Com_sprintf(timestamp, sizeof(timestamp), "[%02d:%02d:%02d] ",
- tms->tm_hour, tms->tm_min, tms->tm_sec);
+ Com_sprintf(timestamp, sizeof(timestamp), "[%02d:%02d:%02d] ", tms->tm_hour, tms->tm_min, tms->tm_sec);
- for ( i = 0; i < CON_TIMESTAMP_LEN; i++ ) {
- con.text[line + i].f = { color, timestamp[i] };
+ for (i = 0; i < CON_TIMESTAMP_LEN; i++) {
+ con.text[line + i].f = {color, timestamp[i]};
}
}
@@ -478,7 +456,7 @@ void Con_Linefeed (void)
line = (con.current % con.totallines) * con.rowwidth;
- for ( i = 0; i < con.rowwidth; i++ )
+ for (i = 0; i < con.rowwidth; i++)
con.text[line + i] = CON_BLANK;
}
@@ -491,13 +469,13 @@ All console printing must go through this in order to be logged to disk
If no console is visible, the text will appear at the top of the game window
================
*/
-void CL_ConsolePrint( const char *txt) {
- int y;
- char c;
- unsigned char color;
+void CL_ConsolePrint(const char *txt) {
+ int y;
+ char c;
+ unsigned char color;
// for some demos we don't want to ever show anything on the console
- if ( cl_noprint && cl_noprint->integer ) {
+ if (cl_noprint && cl_noprint->integer) {
return;
}
@@ -507,24 +485,23 @@ void CL_ConsolePrint( const char *txt) {
color = ColorIndex(COLOR_WHITE);
- while ( (c = (unsigned char) *txt) != 0 ) {
- if ( Q_IsColorString( (unsigned char*) txt ) ) {
- color = ColorIndex( *(txt+1) );
+ while ((c = (unsigned char)*txt) != 0) {
+ if (Q_IsColorString((unsigned char *)txt)) {
+ color = ColorIndex(*(txt + 1));
txt += 2;
continue;
}
txt++;
- switch (c)
- {
+ switch (c) {
case '\n':
- Con_Linefeed ();
+ Con_Linefeed();
break;
case '\r':
con.x = 0;
break;
- default: // display character and advance
+ default: // display character and advance
y = con.current % con.totallines;
if (con.x == con.rowwidth - CON_TIMESTAMP_LEN - 1) {
@@ -533,20 +510,18 @@ void CL_ConsolePrint( const char *txt) {
y = con.current % con.totallines;
}
- con.text[y * con.rowwidth + CON_TIMESTAMP_LEN + con.x].f = { color, c };
+ con.text[y * con.rowwidth + CON_TIMESTAMP_LEN + con.x].f = {color, c};
con.x++;
break;
}
}
-
// mark time for transparent overlay
if (con.current >= 0)
con.times[con.current % NUM_CON_TIMES] = cls.realtime;
}
-
/*
==============================================================================
@@ -555,7 +530,6 @@ DRAWING
==============================================================================
*/
-
/*
================
Con_DrawInput
@@ -563,33 +537,32 @@ Con_DrawInput
Draw the editline after a ] prompt
================
*/
-void Con_DrawInput (void) {
- int y;
+void Con_DrawInput(void) {
+ int y;
- if ( cls.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) {
+ if (cls.state != CA_DISCONNECTED && !(Key_GetCatcher() & KEYCATCH_CONSOLE)) {
return;
}
- y = con.vislines - ( con.charHeight * (re.Language_IsAsian() ? 1.5 : 2) );
+ y = con.vislines - (con.charHeight * (re.Language_IsAsian() ? 1.5 : 2));
- re.SetColor( con.color );
+ re.SetColor(con.color);
- Field_Draw( &g_consoleField, 2 * con.charWidth, y, qtrue, qtrue );
+ Field_Draw(&g_consoleField, 2 * con.charWidth, y, qtrue, qtrue);
- SCR_DrawSmallChar( con.charWidth, y, CONSOLE_PROMPT_CHAR );
+ SCR_DrawSmallChar(con.charWidth, y, CONSOLE_PROMPT_CHAR);
- re.SetColor( g_color_table[ColorIndex(COLOR_GREY)] );
+ re.SetColor(g_color_table[ColorIndex(COLOR_GREY)]);
- if ( g_consoleField.scroll > 0 )
- SCR_DrawSmallChar( 0, y, CON_SCROLL_L_CHAR );
+ if (g_consoleField.scroll > 0)
+ SCR_DrawSmallChar(0, y, CON_SCROLL_L_CHAR);
- int len = Q_PrintStrlen( g_consoleField.buffer );
- int pos = Q_PrintStrLenTo( g_consoleField.buffer, g_consoleField.scroll, NULL );
- if ( pos + g_consoleField.widthInChars < len )
- SCR_DrawSmallChar( cls.glconfig.vidWidth - con.charWidth, y, CON_SCROLL_R_CHAR );
+ int len = Q_PrintStrlen(g_consoleField.buffer);
+ int pos = Q_PrintStrLenTo(g_consoleField.buffer, g_consoleField.scroll, NULL);
+ if (pos + g_consoleField.widthInChars < len)
+ SCR_DrawSmallChar(cls.glconfig.vidWidth - con.charWidth, y, CON_SCROLL_R_CHAR);
}
-
/*
================
Con_DrawNotify
@@ -597,40 +570,36 @@ Con_DrawNotify
Draws the last few lines of output transparently over the game top
================
*/
-void Con_DrawNotify (void)
-{
- int x, v;
- conChar_t *text;
- int i;
- int time;
- int currentColor;
+void Con_DrawNotify(void) {
+ int x, v;
+ conChar_t *text;
+ int i;
+ int time;
+ int currentColor;
currentColor = 7;
- re.SetColor( g_color_table[currentColor] );
+ re.SetColor(g_color_table[currentColor]);
int iFontIndex = cls.consoleFont;
float fFontScale = 1.0f;
int iPixelHeightToAdvance = 0;
- if (re.Language_IsAsian())
- {
- fFontScale = con.charWidth * 10.0f /
- re.Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f);
+ if (re.Language_IsAsian()) {
+ fFontScale = con.charWidth * 10.0f / re.Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f);
fFontScale *= con.yadjust;
- iPixelHeightToAdvance = 2+(1.3/con.yadjust) * re.Font_HeightPixels(iFontIndex, fFontScale);
+ iPixelHeightToAdvance = 2 + (1.3 / con.yadjust) * re.Font_HeightPixels(iFontIndex, fFontScale);
}
v = 0;
- for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++)
- {
+ for (i = con.current - NUM_CON_TIMES + 1; i <= con.current; i++) {
if (i < 0)
continue;
time = con.times[i % NUM_CON_TIMES];
if (time == 0)
continue;
time = cls.realtime - time;
- if (time > con_notifytime->value*1000)
+ if (time > con_notifytime->value * 1000)
continue;
- text = con.text + (i % con.totallines)*con.rowwidth;
+ text = con.text + (i % con.totallines) * con.rowwidth;
if (!con_timestamps->integer)
text += CON_TIMESTAMP_LEN;
@@ -638,46 +607,41 @@ void Con_DrawNotify (void)
//
// (ignore colours since we're going to print the whole thing as one string)
//
- if (re.Language_IsAsian())
- {
+ if (re.Language_IsAsian()) {
// concat the text to be printed...
//
- char sTemp[4096]; // ott
+ char sTemp[4096]; // ott
sTemp[0] = '\0';
- for (x = 0 ; x < con.linewidth ; x++)
- {
- if ( text[x].f.color != currentColor ) {
+ for (x = 0; x < con.linewidth; x++) {
+ if (text[x].f.color != currentColor) {
currentColor = text[x].f.color;
- strcat(sTemp,va("^%i", currentColor ));
+ strcat(sTemp, va("^%i", currentColor));
}
- strcat(sTemp,va("%c",text[x].f.character));
+ strcat(sTemp, va("%c", text[x].f.character));
}
//
// and print...
//
- re.Font_DrawString(con.xadjust * (con.xadjust + con.charWidth), con.yadjust * v, sTemp,
- g_color_table[currentColor], iFontIndex, -1, fFontScale);
+ re.Font_DrawString(con.xadjust * (con.xadjust + con.charWidth), con.yadjust * v, sTemp, g_color_table[currentColor], iFontIndex, -1, fFontScale);
- v += iPixelHeightToAdvance;
- }
- else
- {
- for (x = 0 ; x < con.linewidth ; x++) {
- if ( text[x].f.character == ' ' ) {
+ v += iPixelHeightToAdvance;
+ } else {
+ for (x = 0; x < con.linewidth; x++) {
+ if (text[x].f.character == ' ') {
continue;
}
- if ( text[x].f.color != currentColor ) {
+ if (text[x].f.color != currentColor) {
currentColor = text[x].f.color;
- re.SetColor( g_color_table[currentColor] );
+ re.SetColor(g_color_table[currentColor]);
}
- SCR_DrawSmallChar( (x+1)*con.charWidth, v, text[x].f.character );
+ SCR_DrawSmallChar((x + 1) * con.charWidth, v, text[x].f.character);
}
v += con.charHeight;
}
}
- re.SetColor( NULL );
+ re.SetColor(NULL);
}
/*
@@ -687,97 +651,87 @@ Con_DrawSolidConsole
Draws the console with the solid background
================
*/
-void Con_DrawSolidConsole( float frac )
-{
- int i, x, y;
- int rows;
- conChar_t *text;
- int row;
- int lines;
-// qhandle_t conShader;
- int currentColor;
+void Con_DrawSolidConsole(float frac) {
+ int i, x, y;
+ int rows;
+ conChar_t *text;
+ int row;
+ int lines;
+ // qhandle_t conShader;
+ int currentColor;
lines = cls.glconfig.vidHeight * frac;
if (lines <= 0)
return;
- if (lines > cls.glconfig.vidHeight )
+ if (lines > cls.glconfig.vidHeight)
lines = cls.glconfig.vidHeight;
// draw the background
y = frac * SCREEN_HEIGHT - 2;
- if ( y < 1 ) {
+ if (y < 1) {
y = 0;
- }
- else {
+ } else {
// draw the background at full opacity only if fullscreen
- if (frac < 1.0f)
- {
+ if (frac < 1.0f) {
vec4_t con_color;
MAKERGBA(con_color, 1.0f, 1.0f, 1.0f, Com_Clamp(0.0f, 1.0f, con_opacity->value));
re.SetColor(con_color);
- }
- else
- {
+ } else {
re.SetColor(NULL);
}
- SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader );
+ SCR_DrawPic(0, 0, SCREEN_WIDTH, y, cls.consoleShader);
}
// draw the bottom bar and version number
- re.SetColor( console_color );
- re.DrawStretchPic( 0, y, SCREEN_WIDTH, 2, 0, 0, 0, 0, cls.whiteShader );
+ re.SetColor(console_color);
+ re.DrawStretchPic(0, y, SCREEN_WIDTH, 2, 0, 0, 0, 0, cls.whiteShader);
- i = strlen( Q3_VERSION );
+ i = strlen(Q3_VERSION);
- for (x=0 ; x= con.totallines) {
@@ -785,7 +739,7 @@ void Con_DrawSolidConsole( float frac )
continue;
}
- text = con.text + (row % con.totallines)*con.rowwidth;
+ text = con.text + (row % con.totallines) * con.rowwidth;
if (!con_timestamps->integer)
text += CON_TIMESTAMP_LEN;
@@ -793,70 +747,63 @@ void Con_DrawSolidConsole( float frac )
//
// (ignore colours since we're going to print the whole thing as one string)
//
- if (re.Language_IsAsian())
- {
+ if (re.Language_IsAsian()) {
// concat the text to be printed...
//
- char sTemp[4096]; // ott
+ char sTemp[4096]; // ott
sTemp[0] = '\0';
- for (x = 0 ; x < con.linewidth + 1 ; x++)
- {
- if ( text[x].f.color != currentColor ) {
+ for (x = 0; x < con.linewidth + 1; x++) {
+ if (text[x].f.color != currentColor) {
currentColor = text[x].f.color;
- strcat(sTemp,va("^%i", currentColor ));
+ strcat(sTemp, va("^%i", currentColor));
}
- strcat(sTemp,va("%c",text[x].f.character));
+ strcat(sTemp, va("%c", text[x].f.character));
}
//
// and print...
//
- re.Font_DrawString(con.xadjust*(con.xadjust + con.charWidth), con.yadjust * y, sTemp, g_color_table[currentColor],
- iFontIndex, -1, fFontScale);
- }
- else
- {
- for (x = 0; x < con.linewidth + 1 ; x++) {
- if ( text[x].f.character == ' ' ) {
+ re.Font_DrawString(con.xadjust * (con.xadjust + con.charWidth), con.yadjust * y, sTemp, g_color_table[currentColor], iFontIndex, -1, fFontScale);
+ } else {
+ for (x = 0; x < con.linewidth + 1; x++) {
+ if (text[x].f.character == ' ') {
continue;
}
- if ( text[x].f.color != currentColor ) {
+ if (text[x].f.color != currentColor) {
currentColor = text[x].f.color;
- re.SetColor( g_color_table[currentColor] );
+ re.SetColor(g_color_table[currentColor]);
}
- SCR_DrawSmallChar( (x+1)*con.charWidth, y, text[x].f.character );
+ SCR_DrawSmallChar((x + 1) * con.charWidth, y, text[x].f.character);
}
}
}
- re.SetColor( NULL );
+ re.SetColor(NULL);
}
-
-
/*
==================
Con_DrawConsole
==================
*/
-void Con_DrawConsole( void ) {
+void Con_DrawConsole(void) {
// check for console width changes from a vid mode change
- Con_CheckResize ();
+ Con_CheckResize();
// if disconnected, render console full screen
- if ( cls.state == CA_DISCONNECTED ) {
- if ( !( Key_GetCatcher( ) & KEYCATCH_UI) ) {
- Con_DrawSolidConsole( 1.0 );
+ if (cls.state == CA_DISCONNECTED) {
+ if (!(Key_GetCatcher() & KEYCATCH_UI)) {
+ Con_DrawSolidConsole(1.0);
return;
}
}
- if ( con.displayFrac ) {
- Con_DrawSolidConsole( con.displayFrac );
+ if (con.displayFrac) {
+ Con_DrawSolidConsole(con.displayFrac);
} else {
// draw notify lines
- if ( cls.state == CA_ACTIVE ) {
- Con_DrawNotify ();
+ if (cls.state == CA_ACTIVE) {
+ Con_DrawNotify();
}
}
}
@@ -870,61 +817,53 @@ Con_RunConsole
Scroll it up or down
==================
*/
-void Con_RunConsole (void) {
+void Con_RunConsole(void) {
// decide on the destination height of the console
- if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
+ if (Key_GetCatcher() & KEYCATCH_CONSOLE)
con.finalFrac = con_height->value;
else
- con.finalFrac = 0; // none visible
+ con.finalFrac = 0; // none visible
// scroll towards the destination height
- if (con.finalFrac < con.displayFrac)
- {
- con.displayFrac -= con_conspeed->value*cls.realFrametime*0.001;
+ if (con.finalFrac < con.displayFrac) {
+ con.displayFrac -= con_conspeed->value * cls.realFrametime * 0.001;
if (con.finalFrac > con.displayFrac)
con.displayFrac = con.finalFrac;
- }
- else if (con.finalFrac > con.displayFrac)
- {
- con.displayFrac += con_conspeed->value*cls.realFrametime*0.001;
+ } else if (con.finalFrac > con.displayFrac) {
+ con.displayFrac += con_conspeed->value * cls.realFrametime * 0.001;
if (con.finalFrac < con.displayFrac)
con.displayFrac = con.finalFrac;
}
-
}
-
-void Con_PageUp( void ) {
+void Con_PageUp(void) {
con.display -= 2;
- if ( con.current - con.display >= con.totallines ) {
+ if (con.current - con.display >= con.totallines) {
con.display = con.current - con.totallines + 1;
}
}
-void Con_PageDown( void ) {
+void Con_PageDown(void) {
con.display += 2;
if (con.display > con.current) {
con.display = con.current;
}
}
-void Con_Top( void ) {
+void Con_Top(void) {
con.display = con.totallines;
- if ( con.current - con.display >= con.totallines ) {
+ if (con.current - con.display >= con.totallines) {
con.display = con.current - con.totallines + 1;
}
}
-void Con_Bottom( void ) {
- con.display = con.current;
-}
-
+void Con_Bottom(void) { con.display = con.current; }
-void Con_Close( void ) {
- Field_Clear( &g_consoleField );
- Con_ClearNotify ();
- Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CONSOLE );
- con.finalFrac = 0; // none visible
+void Con_Close(void) {
+ Field_Clear(&g_consoleField);
+ Con_ClearNotify();
+ Key_SetCatcher(Key_GetCatcher() & ~KEYCATCH_CONSOLE);
+ con.finalFrac = 0; // none visible
con.displayFrac = 0;
}
diff --git a/code/client/cl_input.cpp b/code/client/cl_input.cpp
index 940517600b..412b022dc0 100644
--- a/code/client/cl_input.cpp
+++ b/code/client/cl_input.cpp
@@ -32,8 +32,8 @@ along with this program; if not, see .
#include
#endif
-unsigned frame_msec;
-int old_com_frameTime;
+unsigned frame_msec;
+int old_com_frameTime;
float cl_mPitchOverride = 0.0f;
float cl_mYawOverride = 0.0f;
@@ -57,32 +57,29 @@ at the same time.
===============================================================================
*/
+kbutton_t in_left, in_right, in_forward, in_back;
+kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
+kbutton_t in_strafe, in_speed;
+kbutton_t in_up, in_down;
-kbutton_t in_left, in_right, in_forward, in_back;
-kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
-kbutton_t in_strafe, in_speed;
-kbutton_t in_up, in_down;
+kbutton_t in_buttons[32];
-kbutton_t in_buttons[32];
+qboolean in_mlooking;
+extern cvar_t *in_joystick;
-qboolean in_mlooking;
-
-extern cvar_t *in_joystick;
-
-static void IN_UseGivenForce(void)
-{
+static void IN_UseGivenForce(void) {
const char *c = Cmd_Argv(1);
- int forceNum=-1;
+ int forceNum = -1;
int genCmdNum = 0;
- if(c) {
+ if (c) {
forceNum = atoi(c);
} else {
return;
}
- switch(forceNum) {
+ switch (forceNum) {
#ifndef JK2_MODE
case FP_DRAIN:
genCmdNum = GENCMD_FORCE_DRAIN;
@@ -131,51 +128,48 @@ static void IN_UseGivenForce(void)
break;
}
- if(genCmdNum) {
+ if (genCmdNum) {
cl.gcmdSendValue = qtrue;
cl.gcmdValue = genCmdNum;
}
}
+void IN_MLookDown(void) { in_mlooking = qtrue; }
-void IN_MLookDown( void ) {
- in_mlooking = qtrue;
-}
-
-void IN_CenterView( void );
-void IN_MLookUp( void ) {
+void IN_CenterView(void);
+void IN_MLookUp(void) {
in_mlooking = qfalse;
- if ( !cl_freelook->integer ) {
- IN_CenterView ();
+ if (!cl_freelook->integer) {
+ IN_CenterView();
}
}
-void IN_KeyDown( kbutton_t *b ) {
- int k;
- const char *c;
+void IN_KeyDown(kbutton_t *b) {
+ int k;
+ const char *c;
c = Cmd_Argv(1);
- if ( c[0] ) {
+ if (c[0]) {
k = atoi(c);
} else {
- k = -1; // typed manually at the console for continuous down
+ k = -1; // typed manually at the console for continuous down
}
- if ( k == b->down[0] || k == b->down[1] ) {
- return; // repeating key
+ if (k == b->down[0] || k == b->down[1]) {
+ return; // repeating key
}
- if ( !b->down[0] ) {
+ if (!b->down[0]) {
b->down[0] = k;
- } else if ( !b->down[1] ) {
+ } else if (!b->down[1]) {
b->down[1] = k;
} else {
- Com_Printf ("Three keys down for a button!\n");
+ Com_Printf("Three keys down for a button!\n");
return;
}
- if ( b->active ) {
- return; // still down
+ if (b->active) {
+ return; // still down
}
// save timestamp for partial frame summing
@@ -186,13 +180,13 @@ void IN_KeyDown( kbutton_t *b ) {
b->wasPressed = qtrue;
}
-void IN_KeyUp( kbutton_t *b ) {
- int k;
- const char *c;
- unsigned uptime;
+void IN_KeyUp(kbutton_t *b) {
+ int k;
+ const char *c;
+ unsigned uptime;
c = Cmd_Argv(1);
- if ( c[0] ) {
+ if (c[0]) {
k = atoi(c);
} else {
// typed manually at the console, assume for unsticking, so clear all
@@ -201,15 +195,15 @@ void IN_KeyUp( kbutton_t *b ) {
return;
}
- if ( b->down[0] == k ) {
+ if (b->down[0] == k) {
b->down[0] = 0;
- } else if ( b->down[1] == k ) {
+ } else if (b->down[1] == k) {
b->down[1] = 0;
} else {
- return; // key up without coresponding down (menu pass through)
+ return; // key up without coresponding down (menu pass through)
}
- if ( b->down[0] || b->down[1] ) {
- return; // some other key is still holding it down
+ if (b->down[0] || b->down[1]) {
+ return; // some other key is still holding it down
}
b->active = qfalse;
@@ -217,7 +211,7 @@ void IN_KeyUp( kbutton_t *b ) {
// save timestamp for partial frame summing
c = Cmd_Argv(2);
uptime = atoi(c);
- if ( uptime ) {
+ if (uptime) {
b->msec += uptime - b->downtime;
} else {
b->msec += frame_msec / 2;
@@ -226,8 +220,6 @@ void IN_KeyUp( kbutton_t *b ) {
b->active = qfalse;
}
-
-
/*
===============
CL_KeyState
@@ -235,16 +227,16 @@ CL_KeyState
Returns the fraction of the frame that the key was down
===============
*/
-float CL_KeyState( kbutton_t *key ) {
- float val;
- int msec;
+float CL_KeyState(kbutton_t *key) {
+ float val;
+ int msec;
msec = key->msec;
key->msec = 0;
- if ( key->active ) {
+ if (key->active) {
// still down
- if ( !key->downtime ) {
+ if (!key->downtime) {
msec = com_frameTime;
} else {
msec += com_frameTime - key->downtime;
@@ -259,96 +251,89 @@ float CL_KeyState( kbutton_t *key ) {
#endif
val = (float)msec / frame_msec;
- if ( val < 0 ) {
+ if (val < 0) {
val = 0;
}
- if ( val > 1 ) {
+ if (val > 1) {
val = 1;
}
return val;
}
-
-
-void IN_UpDown(void) {IN_KeyDown(&in_up);}
-void IN_UpUp(void) {IN_KeyUp(&in_up);}
-void IN_DownDown(void) {IN_KeyDown(&in_down);}
-void IN_DownUp(void) {IN_KeyUp(&in_down);}
-void IN_LeftDown(void) {IN_KeyDown(&in_left);}
-void IN_LeftUp(void) {IN_KeyUp(&in_left);}
-void IN_RightDown(void) {IN_KeyDown(&in_right);}
-void IN_RightUp(void) {IN_KeyUp(&in_right);}
-void IN_ForwardDown(void) {IN_KeyDown(&in_forward);}
-void IN_ForwardUp(void) {IN_KeyUp(&in_forward);}
-void IN_BackDown(void) {IN_KeyDown(&in_back);}
-void IN_BackUp(void) {IN_KeyUp(&in_back);}
-void IN_LookupDown(void) {IN_KeyDown(&in_lookup);}
-void IN_LookupUp(void) {IN_KeyUp(&in_lookup);}
-void IN_LookdownDown(void) {IN_KeyDown(&in_lookdown);}
-void IN_LookdownUp(void) {IN_KeyUp(&in_lookdown);}
-void IN_MoveleftDown(void) {IN_KeyDown(&in_moveleft);}
-void IN_MoveleftUp(void) {IN_KeyUp(&in_moveleft);}
-void IN_MoverightDown(void) {IN_KeyDown(&in_moveright);}
-void IN_MoverightUp(void) {IN_KeyUp(&in_moveright);}
-
-void IN_SpeedDown(void) {IN_KeyDown(&in_speed);}
-void IN_SpeedUp(void) {IN_KeyUp(&in_speed);}
-void IN_StrafeDown(void) {IN_KeyDown(&in_strafe);}
-void IN_StrafeUp(void) {IN_KeyUp(&in_strafe);}
-
-void IN_Button0Down(void) {IN_KeyDown(&in_buttons[0]);}
-void IN_Button0Up(void) {IN_KeyUp(&in_buttons[0]);}
-void IN_Button1Down(void) {IN_KeyDown(&in_buttons[1]);}
-void IN_Button1Up(void) {IN_KeyUp(&in_buttons[1]);}
-void IN_Button2Down(void) {IN_KeyDown(&in_buttons[2]);}
-void IN_Button2Up(void) {IN_KeyUp(&in_buttons[2]);}
-void IN_Button3Down(void) {IN_KeyDown(&in_buttons[3]);}
-void IN_Button3Up(void) {IN_KeyUp(&in_buttons[3]);}
-void IN_Button4Down(void) {IN_KeyDown(&in_buttons[4]);}
-void IN_Button4Up(void) {IN_KeyUp(&in_buttons[4]);}
-void IN_Button5Down(void) {IN_KeyDown(&in_buttons[5]);}
-void IN_Button5Up(void) {IN_KeyUp(&in_buttons[5]);}
-void IN_Button6Down(void) {IN_KeyDown(&in_buttons[6]);}
-void IN_Button6Up(void) {IN_KeyUp(&in_buttons[6]);}
-void IN_Button7Down(void) {IN_KeyDown(&in_buttons[7]);}
-void IN_Button7Up(void) {IN_KeyUp(&in_buttons[7]);}
-void IN_Button8Down(void) {IN_KeyDown(&in_buttons[8]);}
-void IN_Button8Up(void) {IN_KeyUp(&in_buttons[8]);}
-void IN_Button9Down(void) {IN_KeyDown(&in_buttons[9]);}
-void IN_Button9Up(void) {IN_KeyUp(&in_buttons[9]);}
-void IN_Button10Down(void) {IN_KeyDown(&in_buttons[10]);}
-void IN_Button10Up(void) {IN_KeyUp(&in_buttons[10]);}
-void IN_Button11Down(void) {IN_KeyDown(&in_buttons[11]);}
-void IN_Button11Up(void) {IN_KeyUp(&in_buttons[11]);}
-void IN_Button12Down(void) {IN_KeyDown(&in_buttons[12]);}
-void IN_Button12Up(void) {IN_KeyUp(&in_buttons[12]);}
-void IN_Button13Down(void) {IN_KeyDown(&in_buttons[13]);}
-void IN_Button13Up(void) {IN_KeyUp(&in_buttons[13]);}
-void IN_Button14Down(void) {IN_KeyDown(&in_buttons[14]);}
-void IN_Button14Up(void) {IN_KeyUp(&in_buttons[14]);}
-void IN_Button15Down(void) {IN_KeyDown(&in_buttons[15]);}
-void IN_Button15Up(void) {IN_KeyUp(&in_buttons[15]);}
-
-
-void IN_CenterView (void) {
- cl.viewangles[PITCH] = -SHORT2ANGLE(cl.frame.ps.delta_angles[PITCH]);
-}
-
+void IN_UpDown(void) { IN_KeyDown(&in_up); }
+void IN_UpUp(void) { IN_KeyUp(&in_up); }
+void IN_DownDown(void) { IN_KeyDown(&in_down); }
+void IN_DownUp(void) { IN_KeyUp(&in_down); }
+void IN_LeftDown(void) { IN_KeyDown(&in_left); }
+void IN_LeftUp(void) { IN_KeyUp(&in_left); }
+void IN_RightDown(void) { IN_KeyDown(&in_right); }
+void IN_RightUp(void) { IN_KeyUp(&in_right); }
+void IN_ForwardDown(void) { IN_KeyDown(&in_forward); }
+void IN_ForwardUp(void) { IN_KeyUp(&in_forward); }
+void IN_BackDown(void) { IN_KeyDown(&in_back); }
+void IN_BackUp(void) { IN_KeyUp(&in_back); }
+void IN_LookupDown(void) { IN_KeyDown(&in_lookup); }
+void IN_LookupUp(void) { IN_KeyUp(&in_lookup); }
+void IN_LookdownDown(void) { IN_KeyDown(&in_lookdown); }
+void IN_LookdownUp(void) { IN_KeyUp(&in_lookdown); }
+void IN_MoveleftDown(void) { IN_KeyDown(&in_moveleft); }
+void IN_MoveleftUp(void) { IN_KeyUp(&in_moveleft); }
+void IN_MoverightDown(void) { IN_KeyDown(&in_moveright); }
+void IN_MoverightUp(void) { IN_KeyUp(&in_moveright); }
+
+void IN_SpeedDown(void) { IN_KeyDown(&in_speed); }
+void IN_SpeedUp(void) { IN_KeyUp(&in_speed); }
+void IN_StrafeDown(void) { IN_KeyDown(&in_strafe); }
+void IN_StrafeUp(void) { IN_KeyUp(&in_strafe); }
+
+void IN_Button0Down(void) { IN_KeyDown(&in_buttons[0]); }
+void IN_Button0Up(void) { IN_KeyUp(&in_buttons[0]); }
+void IN_Button1Down(void) { IN_KeyDown(&in_buttons[1]); }
+void IN_Button1Up(void) { IN_KeyUp(&in_buttons[1]); }
+void IN_Button2Down(void) { IN_KeyDown(&in_buttons[2]); }
+void IN_Button2Up(void) { IN_KeyUp(&in_buttons[2]); }
+void IN_Button3Down(void) { IN_KeyDown(&in_buttons[3]); }
+void IN_Button3Up(void) { IN_KeyUp(&in_buttons[3]); }
+void IN_Button4Down(void) { IN_KeyDown(&in_buttons[4]); }
+void IN_Button4Up(void) { IN_KeyUp(&in_buttons[4]); }
+void IN_Button5Down(void) { IN_KeyDown(&in_buttons[5]); }
+void IN_Button5Up(void) { IN_KeyUp(&in_buttons[5]); }
+void IN_Button6Down(void) { IN_KeyDown(&in_buttons[6]); }
+void IN_Button6Up(void) { IN_KeyUp(&in_buttons[6]); }
+void IN_Button7Down(void) { IN_KeyDown(&in_buttons[7]); }
+void IN_Button7Up(void) { IN_KeyUp(&in_buttons[7]); }
+void IN_Button8Down(void) { IN_KeyDown(&in_buttons[8]); }
+void IN_Button8Up(void) { IN_KeyUp(&in_buttons[8]); }
+void IN_Button9Down(void) { IN_KeyDown(&in_buttons[9]); }
+void IN_Button9Up(void) { IN_KeyUp(&in_buttons[9]); }
+void IN_Button10Down(void) { IN_KeyDown(&in_buttons[10]); }
+void IN_Button10Up(void) { IN_KeyUp(&in_buttons[10]); }
+void IN_Button11Down(void) { IN_KeyDown(&in_buttons[11]); }
+void IN_Button11Up(void) { IN_KeyUp(&in_buttons[11]); }
+void IN_Button12Down(void) { IN_KeyDown(&in_buttons[12]); }
+void IN_Button12Up(void) { IN_KeyUp(&in_buttons[12]); }
+void IN_Button13Down(void) { IN_KeyDown(&in_buttons[13]); }
+void IN_Button13Up(void) { IN_KeyUp(&in_buttons[13]); }
+void IN_Button14Down(void) { IN_KeyDown(&in_buttons[14]); }
+void IN_Button14Up(void) { IN_KeyUp(&in_buttons[14]); }
+void IN_Button15Down(void) { IN_KeyDown(&in_buttons[15]); }
+void IN_Button15Up(void) { IN_KeyUp(&in_buttons[15]); }
+
+void IN_CenterView(void) { cl.viewangles[PITCH] = -SHORT2ANGLE(cl.frame.ps.delta_angles[PITCH]); }
//==========================================================================
-cvar_t *cl_upspeed;
-cvar_t *cl_forwardspeed;
-cvar_t *cl_sidespeed;
-
-cvar_t *cl_yawspeed;
-cvar_t *cl_pitchspeed;
+cvar_t *cl_upspeed;
+cvar_t *cl_forwardspeed;
+cvar_t *cl_sidespeed;
-cvar_t *cl_run;
+cvar_t *cl_yawspeed;
+cvar_t *cl_pitchspeed;
-cvar_t *cl_anglespeedkey;
+cvar_t *cl_run;
+cvar_t *cl_anglespeedkey;
/*
================
@@ -357,37 +342,31 @@ CL_AdjustAngles
Moves the local angle positions
================
*/
-void CL_AdjustAngles( void ) {
- float speed;
+void CL_AdjustAngles(void) {
+ float speed;
- if ( in_speed.active ) {
+ if (in_speed.active) {
speed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
speed = 0.001 * cls.frametime;
}
- if ( !in_strafe.active ) {
- if ( cl_mYawOverride )
- {
- cl.viewangles[YAW] -= cl_mYawOverride*5.0f*speed*cl_yawspeed->value*CL_KeyState (&in_right);
- cl.viewangles[YAW] += cl_mYawOverride*5.0f*speed*cl_yawspeed->value*CL_KeyState (&in_left);
- }
- else
- {
- cl.viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right);
- cl.viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left);
+ if (!in_strafe.active) {
+ if (cl_mYawOverride) {
+ cl.viewangles[YAW] -= cl_mYawOverride * 5.0f * speed * cl_yawspeed->value * CL_KeyState(&in_right);
+ cl.viewangles[YAW] += cl_mYawOverride * 5.0f * speed * cl_yawspeed->value * CL_KeyState(&in_left);
+ } else {
+ cl.viewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState(&in_right);
+ cl.viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState(&in_left);
}
}
- if ( cl_mPitchOverride )
- {
- cl.viewangles[PITCH] -= cl_mPitchOverride*5.0f*speed*cl_pitchspeed->value * CL_KeyState (&in_lookup);
- cl.viewangles[PITCH] += cl_mPitchOverride*5.0f*speed*cl_pitchspeed->value * CL_KeyState (&in_lookdown);
- }
- else
- {
- cl.viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_lookup);
- cl.viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_lookdown);
+ if (cl_mPitchOverride) {
+ cl.viewangles[PITCH] -= cl_mPitchOverride * 5.0f * speed * cl_pitchspeed->value * CL_KeyState(&in_lookup);
+ cl.viewangles[PITCH] += cl_mPitchOverride * 5.0f * speed * cl_pitchspeed->value * CL_KeyState(&in_lookdown);
+ } else {
+ cl.viewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState(&in_lookup);
+ cl.viewangles[PITCH] += speed * cl_pitchspeed->value * CL_KeyState(&in_lookdown);
}
}
@@ -398,16 +377,16 @@ CL_KeyMove
Sets the usercmd_t based on key states
================
*/
-void CL_KeyMove( usercmd_t *cmd ) {
- int movespeed;
- int forward, side, up;
+void CL_KeyMove(usercmd_t *cmd) {
+ int movespeed;
+ int forward, side, up;
//
// adjust for speed key / running
// the walking flag is to keep animations consistant
// even during acceleration and develeration
//
- if ( in_speed.active ^ cl_run->integer ) {
+ if (in_speed.active ^ cl_run->integer) {
movespeed = 127;
cmd->buttons &= ~BUTTON_WALKING;
} else {
@@ -418,38 +397,36 @@ void CL_KeyMove( usercmd_t *cmd ) {
forward = 0;
side = 0;
up = 0;
- if ( in_strafe.active ) {
- side += movespeed * CL_KeyState (&in_right);
- side -= movespeed * CL_KeyState (&in_left);
+ if (in_strafe.active) {
+ side += movespeed * CL_KeyState(&in_right);
+ side -= movespeed * CL_KeyState(&in_left);
}
- side += movespeed * CL_KeyState (&in_moveright);
- side -= movespeed * CL_KeyState (&in_moveleft);
-
+ side += movespeed * CL_KeyState(&in_moveright);
+ side -= movespeed * CL_KeyState(&in_moveleft);
- up += movespeed * CL_KeyState (&in_up);
- up -= movespeed * CL_KeyState (&in_down);
+ up += movespeed * CL_KeyState(&in_up);
+ up -= movespeed * CL_KeyState(&in_down);
- forward += movespeed * CL_KeyState (&in_forward);
- forward -= movespeed * CL_KeyState (&in_back);
+ forward += movespeed * CL_KeyState(&in_forward);
+ forward -= movespeed * CL_KeyState(&in_back);
- cmd->forwardmove = ClampChar( forward );
- cmd->rightmove = ClampChar( side );
- cmd->upmove = ClampChar( up );
+ cmd->forwardmove = ClampChar(forward);
+ cmd->rightmove = ClampChar(side);
+ cmd->upmove = ClampChar(up);
}
-void _UI_MouseEvent( int dx, int dy );
+void _UI_MouseEvent(int dx, int dy);
/*
=================
CL_MouseEvent
=================
*/
-void CL_MouseEvent( int dx, int dy, int time ) {
- if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
- _UI_MouseEvent( dx, dy );
- }
- else {
+void CL_MouseEvent(int dx, int dy, int time) {
+ if (Key_GetCatcher() & KEYCATCH_UI) {
+ _UI_MouseEvent(dx, dy);
+ } else {
cl.mouseDx[cl.mouseIndex] += dx;
cl.mouseDy[cl.mouseIndex] += dy;
}
@@ -462,9 +439,9 @@ CL_JoystickEvent
Joystick values stay set until changed
=================
*/
-void CL_JoystickEvent( int axis, int value, int time ) {
- if ( axis < 0 || axis >= MAX_JOYSTICK_AXIS ) {
- Com_Error( ERR_DROP, "CL_JoystickEvent: bad axis %i", axis );
+void CL_JoystickEvent(int axis, int value, int time) {
+ if (axis < 0 || axis >= MAX_JOYSTICK_AXIS) {
+ Com_Error(ERR_DROP, "CL_JoystickEvent: bad axis %i", axis);
}
cl.joystickAxis[axis] = value;
}
@@ -474,53 +451,44 @@ void CL_JoystickEvent( int axis, int value, int time ) {
CL_JoystickMove
=================
*/
-void CL_JoystickMove( usercmd_t *cmd ) {
- float anglespeed;
+void CL_JoystickMove(usercmd_t *cmd) {
+ float anglespeed;
- if ( !in_joystick->integer )
- {
+ if (!in_joystick->integer) {
return;
}
- if ( !(in_speed.active ^ cl_run->integer) ) {
+ if (!(in_speed.active ^ cl_run->integer)) {
cmd->buttons |= BUTTON_WALKING;
}
- if ( in_speed.active ) {
+ if (in_speed.active) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
- if ( !in_strafe.active ) {
- if ( cl_mYawOverride )
- {
+ if (!in_strafe.active) {
+ if (cl_mYawOverride) {
cl.viewangles[YAW] += 5.0f * cl_mYawOverride * cl.joystickAxis[AXIS_SIDE];
- }
- else
- {
+ } else {
cl.viewangles[YAW] += anglespeed * (cl_yawspeed->value / 100.0f) * cl.joystickAxis[AXIS_SIDE];
}
- }
- else
- {
- cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
+ } else {
+ cmd->rightmove = ClampChar(cmd->rightmove + cl.joystickAxis[AXIS_SIDE]);
}
- if ( in_mlooking ) {
- if ( cl_mPitchOverride )
- {
+ if (in_mlooking) {
+ if (cl_mPitchOverride) {
cl.viewangles[PITCH] += 5.0f * cl_mPitchOverride * cl.joystickAxis[AXIS_FORWARD];
- }
- else
- {
+ } else {
cl.viewangles[PITCH] += anglespeed * (cl_pitchspeed->value / 100.0f) * cl.joystickAxis[AXIS_FORWARD];
}
} else {
- cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
+ cmd->forwardmove = ClampChar(cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD]);
}
- cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
+ cmd->upmove = ClampChar(cmd->upmove + cl.joystickAxis[AXIS_UP]);
}
/*
@@ -528,17 +496,17 @@ void CL_JoystickMove( usercmd_t *cmd ) {
CL_MouseMove
=================
*/
-void CL_MouseMove( usercmd_t *cmd ) {
- float mx, my;
- float accelSensitivity;
- float rate;
- const float speed = static_cast(frame_msec);
+void CL_MouseMove(usercmd_t *cmd) {
+ float mx, my;
+ float accelSensitivity;
+ float rate;
+ const float speed = static_cast(frame_msec);
const float pitch = m_pitch->value;
// allow mouse smoothing
- if ( m_filter->integer ) {
- mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
- my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
+ if (m_filter->integer) {
+ mx = (cl.mouseDx[0] + cl.mouseDx[1]) * 0.5;
+ my = (cl.mouseDy[0] + cl.mouseDy[1]) * 0.5;
} else {
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
@@ -548,14 +516,14 @@ void CL_MouseMove( usercmd_t *cmd ) {
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
- rate = SQRTFAST( mx * mx + my * my ) / speed;
+ rate = SQRTFAST(mx * mx + my * my) / speed;
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
// scale by FOV
accelSensitivity *= cl.cgameSensitivity;
- if ( rate && cl_showMouseRate->integer ) {
- Com_Printf( "%f : %f\n", rate, accelSensitivity );
+ if (rate && cl_showMouseRate->integer) {
+ Com_Printf("%f : %f\n", rate, accelSensitivity);
}
mx *= accelSensitivity;
@@ -566,65 +534,55 @@ void CL_MouseMove( usercmd_t *cmd ) {
}
// add mouse X/Y movement to cmd
- if ( in_strafe.active ) {
- cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
+ if (in_strafe.active) {
+ cmd->rightmove = ClampChar(cmd->rightmove + m_side->value * mx);
} else {
- if ( cl_mYawOverride )
- {
+ if (cl_mYawOverride) {
cl.viewangles[YAW] -= cl_mYawOverride * mx;
- }
- else
- {
+ } else {
cl.viewangles[YAW] -= m_yaw->value * mx;
}
}
- if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
+ if ((in_mlooking || cl_freelook->integer) && !in_strafe.active) {
// VVFIXME - This is supposed to be a CVAR
const float cl_pitchSensitivity = 1.0f;
- if ( cl_mPitchOverride )
- {
- if ( pitch > 0 )
- {
+ if (cl_mPitchOverride) {
+ if (pitch > 0) {
cl.viewangles[PITCH] += cl_mPitchOverride * my * cl_pitchSensitivity;
- }
- else
- {
+ } else {
cl.viewangles[PITCH] -= cl_mPitchOverride * my * cl_pitchSensitivity;
}
- }
- else
- {
+ } else {
cl.viewangles[PITCH] += pitch * my * cl_pitchSensitivity;
}
} else {
- cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
+ cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward->value * my);
}
}
-
/*
==============
CL_CmdButtons
==============
*/
-void CL_CmdButtons( usercmd_t *cmd ) {
- int i;
+void CL_CmdButtons(usercmd_t *cmd) {
+ int i;
//
// figure button bits
// send a button bit even if the key was pressed and released in
// less than a frame
//
- for (i = 0 ; i < 32 ; i++) {
- if ( in_buttons[i].active || in_buttons[i].wasPressed ) {
+ for (i = 0; i < 32; i++) {
+ if (in_buttons[i].active || in_buttons[i].wasPressed) {
cmd->buttons |= 1 << i;
}
in_buttons[i].wasPressed = qfalse;
}
- if ( Key_GetCatcher( ) ) {
- //cmd->buttons |= BUTTON_TALK;
+ if (Key_GetCatcher()) {
+ // cmd->buttons |= BUTTON_TALK;
}
// allow the game to know if any key at all is
@@ -636,25 +594,21 @@ void CL_CmdButtons( usercmd_t *cmd ) {
*/
}
-
/*
==============
CL_FinishMove
==============
*/
-void CL_FinishMove( usercmd_t *cmd ) {
- int i;
+void CL_FinishMove(usercmd_t *cmd) {
+ int i;
// copy the state that the cgame is currently sending
cmd->weapon = cl.cgameUserCmdValue;
- if (cl.gcmdSendValue)
- {
+ if (cl.gcmdSendValue) {
cmd->generic_cmd = cl.gcmdValue;
cl.gcmdSendValue = qfalse;
- }
- else
- {
+ } else {
cmd->generic_cmd = 0;
}
@@ -662,7 +616,7 @@ void CL_FinishMove( usercmd_t *cmd ) {
// can be determined without allowing cheating
cmd->serverTime = cl.serverTime;
- for (i=0 ; i<3 ; i++) {
+ for (i = 0; i < 3; i++) {
cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]);
}
}
@@ -672,59 +626,57 @@ void CL_FinishMove( usercmd_t *cmd ) {
CL_CreateCmd
=================
*/
-vec3_t cl_overriddenAngles = {0,0,0};
+vec3_t cl_overriddenAngles = {0, 0, 0};
qboolean cl_overrideAngles = qfalse;
-usercmd_t CL_CreateCmd( void ) {
- usercmd_t cmd;
- vec3_t oldAngles;
+usercmd_t CL_CreateCmd(void) {
+ usercmd_t cmd;
+ vec3_t oldAngles;
- VectorCopy( cl.viewangles, oldAngles );
+ VectorCopy(cl.viewangles, oldAngles);
// keyboard angle adjustment
- CL_AdjustAngles ();
+ CL_AdjustAngles();
- memset( &cmd, 0, sizeof( cmd ) );
+ memset(&cmd, 0, sizeof(cmd));
- CL_CmdButtons( &cmd );
+ CL_CmdButtons(&cmd);
// get basic movement from keyboard
- CL_KeyMove (&cmd);
+ CL_KeyMove(&cmd);
// get basic movement from mouse
- CL_MouseMove( &cmd );
+ CL_MouseMove(&cmd);
// get basic movement from joystick
- CL_JoystickMove( &cmd );
+ CL_JoystickMove(&cmd);
// check to make sure the angles haven't wrapped
- if ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) {
+ if (cl.viewangles[PITCH] - oldAngles[PITCH] > 90) {
cl.viewangles[PITCH] = oldAngles[PITCH] + 90;
- } else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) {
+ } else if (oldAngles[PITCH] - cl.viewangles[PITCH] > 90) {
cl.viewangles[PITCH] = oldAngles[PITCH] - 90;
}
- if ( cl_overrideAngles )
- {
- VectorCopy( cl_overriddenAngles, cl.viewangles );
+ if (cl_overrideAngles) {
+ VectorCopy(cl_overriddenAngles, cl.viewangles);
cl_overrideAngles = qfalse;
}
// store out the final values
- CL_FinishMove( &cmd );
+ CL_FinishMove(&cmd);
// draw debug graphs of turning for mouse testing
- if ( cl_debugMove->integer ) {
- if ( cl_debugMove->integer == 1 ) {
- SCR_DebugGraph( abs(cl.viewangles[YAW] - oldAngles[YAW]), 0 );
+ if (cl_debugMove->integer) {
+ if (cl_debugMove->integer == 1) {
+ SCR_DebugGraph(abs(cl.viewangles[YAW] - oldAngles[YAW]), 0);
}
- if ( cl_debugMove->integer == 2 ) {
- SCR_DebugGraph( abs(cl.viewangles[PITCH] - oldAngles[PITCH]), 0 );
+ if (cl_debugMove->integer == 2) {
+ SCR_DebugGraph(abs(cl.viewangles[PITCH] - oldAngles[PITCH]), 0);
}
}
return cmd;
}
-
/*
=================
CL_CreateNewCommands
@@ -732,23 +684,23 @@ CL_CreateNewCommands
Create a new usercmd_t structure for this frame
=================
*/
-void CL_CreateNewCommands( void ) {
- int cmdNum;
+void CL_CreateNewCommands(void) {
+ int cmdNum;
// no need to create usercmds until we have a gamestate
-// if ( cls.state < CA_PRIMED )
-// return;
+ // if ( cls.state < CA_PRIMED )
+ // return;
frame_msec = com_frameTime - old_com_frameTime;
// if running over 1000fps, act as if each frame is 1ms
// prevents divisions by zero
- if ( frame_msec < 1 )
+ if (frame_msec < 1)
frame_msec = 1;
// if running less than 5fps, truncate the extra time to prevent
// unexpected moves after a hitch
- if ( frame_msec > 200 )
+ if (frame_msec > 200)
frame_msec = 200;
old_com_frameTime = com_frameTime;
@@ -770,18 +722,16 @@ delivered in the next packet, but saving a header and
getting more delta compression will reduce total bandwidth.
=================
*/
-qboolean CL_ReadyToSendPacket( void ) {
+qboolean CL_ReadyToSendPacket(void) {
// don't send anything if playing back a demo
-// if ( cls.state == CA_CINEMATIC )
- if ( cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic())
- {
+ // if ( cls.state == CA_CINEMATIC )
+ if (cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic()) {
return qfalse;
}
// if we don't have a valid gamestate yet, only send
// one packet a second
- if ( cls.state != CA_ACTIVE && cls.state != CA_PRIMED
- && cls.realtime - clc.lastPacketSentTime < 1000 ) {
+ if (cls.state != CA_ACTIVE && cls.state != CA_PRIMED && cls.realtime - clc.lastPacketSentTime < 1000) {
return qfalse;
}
@@ -810,84 +760,83 @@ During normal gameplay, a client packet will contain something like:
===================
*/
-void CL_WritePacket( void ) {
- msg_t buf;
- byte data[MAX_MSGLEN];
- int i, j;
- usercmd_t *cmd, *oldcmd;
- usercmd_t nullcmd;
- int packetNum;
- int oldPacketNum;
- int count;
+void CL_WritePacket(void) {
+ msg_t buf;
+ byte data[MAX_MSGLEN];
+ int i, j;
+ usercmd_t *cmd, *oldcmd;
+ usercmd_t nullcmd;
+ int packetNum;
+ int oldPacketNum;
+ int count;
// don't send anything if playing back a demo
-// if ( cls.state == CA_CINEMATIC )
- if ( cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic())
- {
+ // if ( cls.state == CA_CINEMATIC )
+ if (cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic()) {
return;
}
- MSG_Init( &buf, data, sizeof(data) );
+ MSG_Init(&buf, data, sizeof(data));
// write any unacknowledged clientCommands
- for ( i = clc.reliableAcknowledge + 1 ; i <= clc.reliableSequence ; i++ ) {
- MSG_WriteByte( &buf, clc_clientCommand );
- MSG_WriteLong( &buf, i );
- MSG_WriteString( &buf, clc.reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] );
+ for (i = clc.reliableAcknowledge + 1; i <= clc.reliableSequence; i++) {
+ MSG_WriteByte(&buf, clc_clientCommand);
+ MSG_WriteLong(&buf, i);
+ MSG_WriteString(&buf, clc.reliableCommands[i & (MAX_RELIABLE_COMMANDS - 1)]);
}
// we want to send all the usercmds that were generated in the last
// few packet, so even if a couple packets are dropped in a row,
// all the cmds will make it to the server
- if ( cl_packetdup->integer < 0 ) {
- Cvar_Set( "cl_packetdup", "0" );
- } else if ( cl_packetdup->integer > 5 ) {
- Cvar_Set( "cl_packetdup", "5" );
+ if (cl_packetdup->integer < 0) {
+ Cvar_Set("cl_packetdup", "0");
+ } else if (cl_packetdup->integer > 5) {
+ Cvar_Set("cl_packetdup", "5");
}
oldPacketNum = (clc.netchan.outgoingSequence - 1 - cl_packetdup->integer) & PACKET_MASK;
- count = cl.cmdNumber - cl.packetCmdNumber[ oldPacketNum ];
- if ( count > MAX_PACKET_USERCMDS ) {
+ count = cl.cmdNumber - cl.packetCmdNumber[oldPacketNum];
+ if (count > MAX_PACKET_USERCMDS) {
count = MAX_PACKET_USERCMDS;
Com_Printf("MAX_PACKET_USERCMDS\n");
}
- if ( count >= 1 ) {
+ if (count >= 1) {
// begin a client move command
- MSG_WriteByte (&buf, clc_move);
+ MSG_WriteByte(&buf, clc_move);
// write the last reliable message we received
- MSG_WriteLong( &buf, clc.serverCommandSequence );
+ MSG_WriteLong(&buf, clc.serverCommandSequence);
// write the current serverId so the server
// can tell if this is from the current gameState
- MSG_WriteLong (&buf, cl.serverId);
+ MSG_WriteLong(&buf, cl.serverId);
// write the current time
- MSG_WriteLong (&buf, cls.realtime);
+ MSG_WriteLong(&buf, cls.realtime);
// let the server know what the last messagenum we
// got was, so the next message can be delta compressed
// FIXME: this could just be a bit flag, with the message implicit
// from the unreliable ack of the netchan
if (cl_nodelta->integer || !cl.frame.valid) {
- MSG_WriteLong (&buf, -1); // no compression
+ MSG_WriteLong(&buf, -1); // no compression
} else {
- MSG_WriteLong (&buf, cl.frame.messageNum);
+ MSG_WriteLong(&buf, cl.frame.messageNum);
}
// write the cmdNumber so the server can determine which ones it
// has already received
- MSG_WriteLong( &buf, cl.cmdNumber );
+ MSG_WriteLong(&buf, cl.cmdNumber);
// write the command count
- MSG_WriteByte( &buf, count );
+ MSG_WriteByte(&buf, count);
// write all the commands, including the predicted command
- memset( &nullcmd, 0, sizeof(nullcmd) );
+ memset(&nullcmd, 0, sizeof(nullcmd));
oldcmd = &nullcmd;
- for ( i = 0 ; i < count ; i++ ) {
+ for (i = 0; i < count; i++) {
j = (cl.cmdNumber - count + i + 1) & CMD_MASK;
cmd = &cl.cmds[j];
- MSG_WriteDeltaUsercmd (&buf, oldcmd, cmd);
+ MSG_WriteDeltaUsercmd(&buf, oldcmd, cmd);
oldcmd = cmd;
}
}
@@ -896,10 +845,10 @@ void CL_WritePacket( void ) {
// deliver the message
//
packetNum = clc.netchan.outgoingSequence & PACKET_MASK;
- cl.packetTime[ packetNum ] = cls.realtime;
- cl.packetCmdNumber[ packetNum ] = cl.cmdNumber;
+ cl.packetTime[packetNum] = cls.realtime;
+ cl.packetCmdNumber[packetNum] = cl.cmdNumber;
clc.lastPacketSentTime = cls.realtime;
- Netchan_Transmit (&clc.netchan, buf.cursize, buf.data);
+ Netchan_Transmit(&clc.netchan, buf.cursize, buf.data);
}
/*
@@ -909,14 +858,14 @@ CL_SendCmd
Called every frame to builds and sends a command packet to the server.
=================
*/
-void CL_SendCmd( void ) {
+void CL_SendCmd(void) {
// don't send any message if not connected
- if ( cls.state < CA_CONNECTED ) {
+ if (cls.state < CA_CONNECTED) {
return;
}
// don't send commands if paused
- if ( com_sv_running->integer && sv_paused->integer && cl_paused->integer ) {
+ if (com_sv_running->integer && sv_paused->integer && cl_paused->integer) {
return;
}
@@ -924,116 +873,114 @@ void CL_SendCmd( void ) {
CL_CreateNewCommands();
// don't send a packet if the last packet was sent too recently
- if ( !CL_ReadyToSendPacket() ) {
+ if (!CL_ReadyToSendPacket()) {
return;
}
CL_WritePacket();
}
-
/*
============
CL_InitInput
============
*/
-void CL_InitInput( void ) {
- Cmd_AddCommand ("centerview",IN_CenterView);
-
- Cmd_AddCommand ("+moveup",IN_UpDown);
- Cmd_AddCommand ("-moveup",IN_UpUp);
- Cmd_AddCommand ("+movedown",IN_DownDown);
- Cmd_AddCommand ("-movedown",IN_DownUp);
- Cmd_AddCommand ("+left",IN_LeftDown);
- Cmd_AddCommand ("-left",IN_LeftUp);
- Cmd_AddCommand ("+right",IN_RightDown);
- Cmd_AddCommand ("-right",IN_RightUp);
- Cmd_AddCommand ("+forward",IN_ForwardDown);
- Cmd_AddCommand ("-forward",IN_ForwardUp);
- Cmd_AddCommand ("+back",IN_BackDown);
- Cmd_AddCommand ("-back",IN_BackUp);
- Cmd_AddCommand ("+lookup", IN_LookupDown);
- Cmd_AddCommand ("-lookup", IN_LookupUp);
- Cmd_AddCommand ("+lookdown", IN_LookdownDown);
- Cmd_AddCommand ("-lookdown", IN_LookdownUp);
- Cmd_AddCommand ("+strafe", IN_StrafeDown);
- Cmd_AddCommand ("-strafe", IN_StrafeUp);
- Cmd_AddCommand ("+moveleft", IN_MoveleftDown);
- Cmd_AddCommand ("-moveleft", IN_MoveleftUp);
- Cmd_AddCommand ("+moveright", IN_MoverightDown);
- Cmd_AddCommand ("-moveright", IN_MoverightUp);
- Cmd_AddCommand ("+speed", IN_SpeedDown);
- Cmd_AddCommand ("-speed", IN_SpeedUp);
- Cmd_AddCommand ("useGivenForce", IN_UseGivenForce);
- //buttons
- Cmd_AddCommand ("+attack", IN_Button0Down);//attack
- Cmd_AddCommand ("-attack", IN_Button0Up);
- Cmd_AddCommand ("+force_lightning", IN_Button1Down);//force lightning
- Cmd_AddCommand ("-force_lightning", IN_Button1Up);
- Cmd_AddCommand ("+useforce", IN_Button2Down); //use current force power
- Cmd_AddCommand ("-useforce", IN_Button2Up);
+void CL_InitInput(void) {
+ Cmd_AddCommand("centerview", IN_CenterView);
+
+ Cmd_AddCommand("+moveup", IN_UpDown);
+ Cmd_AddCommand("-moveup", IN_UpUp);
+ Cmd_AddCommand("+movedown", IN_DownDown);
+ Cmd_AddCommand("-movedown", IN_DownUp);
+ Cmd_AddCommand("+left", IN_LeftDown);
+ Cmd_AddCommand("-left", IN_LeftUp);
+ Cmd_AddCommand("+right", IN_RightDown);
+ Cmd_AddCommand("-right", IN_RightUp);
+ Cmd_AddCommand("+forward", IN_ForwardDown);
+ Cmd_AddCommand("-forward", IN_ForwardUp);
+ Cmd_AddCommand("+back", IN_BackDown);
+ Cmd_AddCommand("-back", IN_BackUp);
+ Cmd_AddCommand("+lookup", IN_LookupDown);
+ Cmd_AddCommand("-lookup", IN_LookupUp);
+ Cmd_AddCommand("+lookdown", IN_LookdownDown);
+ Cmd_AddCommand("-lookdown", IN_LookdownUp);
+ Cmd_AddCommand("+strafe", IN_StrafeDown);
+ Cmd_AddCommand("-strafe", IN_StrafeUp);
+ Cmd_AddCommand("+moveleft", IN_MoveleftDown);
+ Cmd_AddCommand("-moveleft", IN_MoveleftUp);
+ Cmd_AddCommand("+moveright", IN_MoverightDown);
+ Cmd_AddCommand("-moveright", IN_MoverightUp);
+ Cmd_AddCommand("+speed", IN_SpeedDown);
+ Cmd_AddCommand("-speed", IN_SpeedUp);
+ Cmd_AddCommand("useGivenForce", IN_UseGivenForce);
+ // buttons
+ Cmd_AddCommand("+attack", IN_Button0Down); // attack
+ Cmd_AddCommand("-attack", IN_Button0Up);
+ Cmd_AddCommand("+force_lightning", IN_Button1Down); // force lightning
+ Cmd_AddCommand("-force_lightning", IN_Button1Up);
+ Cmd_AddCommand("+useforce", IN_Button2Down); // use current force power
+ Cmd_AddCommand("-useforce", IN_Button2Up);
#ifdef JK2_MODE
- Cmd_AddCommand ("+block", IN_Button3Down);//manual blocking
- Cmd_AddCommand ("-block", IN_Button3Up);
+ Cmd_AddCommand("+block", IN_Button3Down); // manual blocking
+ Cmd_AddCommand("-block", IN_Button3Up);
#else
- Cmd_AddCommand ("+force_drain", IN_Button3Down);//force drain
- Cmd_AddCommand ("-force_drain", IN_Button3Up);
+ Cmd_AddCommand("+force_drain", IN_Button3Down); // force drain
+ Cmd_AddCommand("-force_drain", IN_Button3Up);
#endif
- Cmd_AddCommand ("+walk", IN_Button4Down);//walking
- Cmd_AddCommand ("-walk", IN_Button4Up);
- Cmd_AddCommand ("+use", IN_Button5Down);//use object
- Cmd_AddCommand ("-use", IN_Button5Up);
- Cmd_AddCommand ("+force_grip", IN_Button6Down);//force jump
- Cmd_AddCommand ("-force_grip", IN_Button6Up);
- Cmd_AddCommand ("+altattack", IN_Button7Down);//altattack
- Cmd_AddCommand ("-altattack", IN_Button7Up);
+ Cmd_AddCommand("+walk", IN_Button4Down); // walking
+ Cmd_AddCommand("-walk", IN_Button4Up);
+ Cmd_AddCommand("+use", IN_Button5Down); // use object
+ Cmd_AddCommand("-use", IN_Button5Up);
+ Cmd_AddCommand("+force_grip", IN_Button6Down); // force jump
+ Cmd_AddCommand("-force_grip", IN_Button6Up);
+ Cmd_AddCommand("+altattack", IN_Button7Down); // altattack
+ Cmd_AddCommand("-altattack", IN_Button7Up);
#ifndef JK2_MODE
- Cmd_AddCommand ("+forcefocus", IN_Button8Down);//special saber attacks
- Cmd_AddCommand ("-forcefocus", IN_Button8Up);
- Cmd_AddCommand ("+block", IN_Button8Down);//manual blocking
- Cmd_AddCommand ("-block", IN_Button8Up);
+ Cmd_AddCommand("+forcefocus", IN_Button8Down); // special saber attacks
+ Cmd_AddCommand("-forcefocus", IN_Button8Up);
+ Cmd_AddCommand("+block", IN_Button8Down); // manual blocking
+ Cmd_AddCommand("-block", IN_Button8Up);
#endif
- Cmd_AddCommand ("+button0", IN_Button0Down);
- Cmd_AddCommand ("-button0", IN_Button0Up);
- Cmd_AddCommand ("+button1", IN_Button1Down);
- Cmd_AddCommand ("-button1", IN_Button1Up);
- Cmd_AddCommand ("+button2", IN_Button2Down);
- Cmd_AddCommand ("-button2", IN_Button2Up);
- Cmd_AddCommand ("+button3", IN_Button3Down);
- Cmd_AddCommand ("-button3", IN_Button3Up);
- Cmd_AddCommand ("+button4", IN_Button4Down);
- Cmd_AddCommand ("-button4", IN_Button4Up);
- Cmd_AddCommand ("+button5", IN_Button5Down);
- Cmd_AddCommand ("-button5", IN_Button5Up);
- Cmd_AddCommand ("+button6", IN_Button6Down);
- Cmd_AddCommand ("-button6", IN_Button6Up);
- Cmd_AddCommand ("+button7", IN_Button7Down);
- Cmd_AddCommand ("-button7", IN_Button7Up);
- Cmd_AddCommand ("+button8", IN_Button8Down);
- Cmd_AddCommand ("-button8", IN_Button8Up);
- Cmd_AddCommand ("+button9", IN_Button9Down);
- Cmd_AddCommand ("-button9", IN_Button9Up);
- Cmd_AddCommand ("+button10", IN_Button10Down);
- Cmd_AddCommand ("-button10", IN_Button10Up);
- Cmd_AddCommand ("+button11", IN_Button11Down);
- Cmd_AddCommand ("-button11", IN_Button11Up);
- Cmd_AddCommand ("+button12", IN_Button12Down);
- Cmd_AddCommand ("-button12", IN_Button12Up);
- Cmd_AddCommand ("+button13", IN_Button13Down);
- Cmd_AddCommand ("-button13", IN_Button13Up);
- Cmd_AddCommand ("+button14", IN_Button14Down);
- Cmd_AddCommand ("-button14", IN_Button14Up);
- Cmd_AddCommand ("+button15", IN_Button15Down);
- Cmd_AddCommand ("-button15", IN_Button15Up);
+ Cmd_AddCommand("+button0", IN_Button0Down);
+ Cmd_AddCommand("-button0", IN_Button0Up);
+ Cmd_AddCommand("+button1", IN_Button1Down);
+ Cmd_AddCommand("-button1", IN_Button1Up);
+ Cmd_AddCommand("+button2", IN_Button2Down);
+ Cmd_AddCommand("-button2", IN_Button2Up);
+ Cmd_AddCommand("+button3", IN_Button3Down);
+ Cmd_AddCommand("-button3", IN_Button3Up);
+ Cmd_AddCommand("+button4", IN_Button4Down);
+ Cmd_AddCommand("-button4", IN_Button4Up);
+ Cmd_AddCommand("+button5", IN_Button5Down);
+ Cmd_AddCommand("-button5", IN_Button5Up);
+ Cmd_AddCommand("+button6", IN_Button6Down);
+ Cmd_AddCommand("-button6", IN_Button6Up);
+ Cmd_AddCommand("+button7", IN_Button7Down);
+ Cmd_AddCommand("-button7", IN_Button7Up);
+ Cmd_AddCommand("+button8", IN_Button8Down);
+ Cmd_AddCommand("-button8", IN_Button8Up);
+ Cmd_AddCommand("+button9", IN_Button9Down);
+ Cmd_AddCommand("-button9", IN_Button9Up);
+ Cmd_AddCommand("+button10", IN_Button10Down);
+ Cmd_AddCommand("-button10", IN_Button10Up);
+ Cmd_AddCommand("+button11", IN_Button11Down);
+ Cmd_AddCommand("-button11", IN_Button11Up);
+ Cmd_AddCommand("+button12", IN_Button12Down);
+ Cmd_AddCommand("-button12", IN_Button12Up);
+ Cmd_AddCommand("+button13", IN_Button13Down);
+ Cmd_AddCommand("-button13", IN_Button13Up);
+ Cmd_AddCommand("+button14", IN_Button14Down);
+ Cmd_AddCommand("-button14", IN_Button14Up);
+ Cmd_AddCommand("+button15", IN_Button15Down);
+ Cmd_AddCommand("-button15", IN_Button15Up);
// can add up to button31 this just brings the number of available binds up to par with MP
- //end buttons
- Cmd_AddCommand ("+mlook", IN_MLookDown);
- Cmd_AddCommand ("-mlook", IN_MLookUp);
+ // end buttons
+ Cmd_AddCommand("+mlook", IN_MLookDown);
+ Cmd_AddCommand("-mlook", IN_MLookUp);
- cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0);
- cl_debugMove = Cvar_Get ("cl_debugMove", "0", 0);
+ cl_nodelta = Cvar_Get("cl_nodelta", "0", 0);
+ cl_debugMove = Cvar_Get("cl_debugMove", "0", 0);
}
-
diff --git a/code/client/cl_keys.cpp b/code/client/cl_keys.cpp
index 768c135937..83c80fbfc9 100644
--- a/code/client/cl_keys.cpp
+++ b/code/client/cl_keys.cpp
@@ -24,7 +24,6 @@ along with this program; if not, see .
#include "../server/exe_headers.h"
-
#include "client.h"
#include "client_ui.h"
@@ -35,351 +34,346 @@ key up events are sent even if in console mode
*/
// console
-field_t g_consoleField;
-int nextHistoryLine; // the last line in the history buffer, not masked
-int historyLine; // the line being displayed from history buffer will be <= nextHistoryLine
-field_t historyEditLines[COMMAND_HISTORY];
+field_t g_consoleField;
+int nextHistoryLine; // the last line in the history buffer, not masked
+int historyLine; // the line being displayed from history buffer will be <= nextHistoryLine
+field_t historyEditLines[COMMAND_HISTORY];
-keyGlobals_t kg;
+keyGlobals_t kg;
// do NOT blithely change any of the key names (3rd field) here, since they have to match the key binds
// in the CFG files, they're also prepended with "KEYNAME_" when looking up StripEd references
//
-keyname_t keynames[MAX_KEYS] =
-{
- { 0x00, 0x00, NULL, A_NULL, false },
- { 0x01, 0x01, "SHIFT", A_SHIFT, false },
- { 0x02, 0x02, "CTRL", A_CTRL, false },
- { 0x03, 0x03, "ALT", A_ALT, false },
- { 0x04, 0x04, "CAPSLOCK", A_CAPSLOCK, false },
- { 0x05, 0x05, "KP_NUMLOCK", A_NUMLOCK, false },
- { 0x06, 0x06, "SCROLLLOCK", A_SCROLLLOCK, false },
- { 0x07, 0x07, "PAUSE", A_PAUSE, false },
- { 0x08, 0x08, "BACKSPACE", A_BACKSPACE, false },
- { 0x09, 0x09, "TAB", A_TAB, false },
- { 0x0a, 0x0a, "ENTER", A_ENTER, false },
- { 0x0b, 0x0b, "KP_PLUS", A_KP_PLUS, false },
- { 0x0c, 0x0c, "KP_MINUS", A_KP_MINUS, false },
- { 0x0d, 0x0d, "KP_ENTER", A_KP_ENTER, false },
- { 0x0e, 0x0e, "KP_DEL", A_KP_PERIOD, false },
- { 0x0f, 0x0f, NULL, A_PRINTSCREEN, false },
- { 0x10, 0x10, "KP_INS", A_KP_0, false },
- { 0x11, 0x11, "KP_END", A_KP_1, false },
- { 0x12, 0x12, "KP_DOWNARROW", A_KP_2, false },
- { 0x13, 0x13, "KP_PGDN", A_KP_3, false },
- { 0x14, 0x14, "KP_LEFTARROW", A_KP_4, false },
- { 0x15, 0x15, "KP_5", A_KP_5, false },
- { 0x16, 0x16, "KP_RIGHTARROW", A_KP_6, false },
- { 0x17, 0x17, "KP_HOME", A_KP_7, false },
- { 0x18, 0x18, "KP_UPARROW", A_KP_8, false },
- { 0x19, 0x19, "KP_PGUP", A_KP_9, false },
- { 0x1a, 0x1a, "CONSOLE", A_CONSOLE, false },
- { 0x1b, 0x1b, "ESCAPE", A_ESCAPE, false },
- { 0x1c, 0x1c, "F1", A_F1, true },
- { 0x1d, 0x1d, "F2", A_F2, true },
- { 0x1e, 0x1e, "F3", A_F3, true },
- { 0x1f, 0x1f, "F4", A_F4, true },
-
- { 0x20, 0x20, "SPACE", A_SPACE, false },
- { (word)'!', (word)'!', NULL, A_PLING, false },
- { (word)'"', (word)'"', NULL, A_DOUBLE_QUOTE, false },
- { (word)'#', (word)'#', NULL, A_HASH, false },
- { (word)'$', (word)'$', NULL, A_STRING, false },
- { (word)'%', (word)'%', NULL, A_PERCENT, false },
- { (word)'&', (word)'&', NULL, A_AND, false },
- { 0x27, 0x27, NULL, A_SINGLE_QUOTE, false },
- { (word)'(', (word)'(', NULL, A_OPEN_BRACKET, false },
- { (word)')', (word)')', NULL, A_CLOSE_BRACKET, false },
- { (word)'*', (word)'*', NULL, A_STAR, false },
- { (word)'+', (word)'+', NULL, A_PLUS, false },
- { (word)',', (word)',', NULL, A_COMMA, false },
- { (word)'-', (word)'-', NULL, A_MINUS, false },
- { (word)'.', (word)'.', NULL, A_PERIOD, false },
- { (word)'/', (word)'/', NULL, A_FORWARD_SLASH, false },
- { (word)'0', (word)'0', NULL, A_0, false },
- { (word)'1', (word)'1', NULL, A_1, false },
- { (word)'2', (word)'2', NULL, A_2, false },
- { (word)'3', (word)'3', NULL, A_3, false },
- { (word)'4', (word)'4', NULL, A_4, false },
- { (word)'5', (word)'5', NULL, A_5, false },
- { (word)'6', (word)'6', NULL, A_6, false },
- { (word)'7', (word)'7', NULL, A_7, false },
- { (word)'8', (word)'8', NULL, A_8, false },
- { (word)'9', (word)'9', NULL, A_9, false },
- { (word)':', (word)':', NULL, A_COLON, false },
- { (word)';', (word)';', "SEMICOLON", A_SEMICOLON, false },
- { (word)'<', (word)'<', NULL, A_LESSTHAN, false },
- { (word)'=', (word)'=', NULL, A_EQUALS, false },
- { (word)'>', (word)'>', NULL, A_GREATERTHAN, false },
- { (word)'?', (word)'?', NULL, A_QUESTION, false },
-
- { (word)'@', (word)'@', NULL, A_AT, false },
- { (word)'A', (word)'a', NULL, A_CAP_A, false },
- { (word)'B', (word)'b', NULL, A_CAP_B, false },
- { (word)'C', (word)'c', NULL, A_CAP_C, false },
- { (word)'D', (word)'d', NULL, A_CAP_D, false },
- { (word)'E', (word)'e', NULL, A_CAP_E, false },
- { (word)'F', (word)'f', NULL, A_CAP_F, false },
- { (word)'G', (word)'g', NULL, A_CAP_G, false },
- { (word)'H', (word)'h', NULL, A_CAP_H, false },
- { (word)'I', (word)'i', NULL, A_CAP_I, false },
- { (word)'J', (word)'j', NULL, A_CAP_J, false },
- { (word)'K', (word)'k', NULL, A_CAP_K, false },
- { (word)'L', (word)'l', NULL, A_CAP_L, false },
- { (word)'M', (word)'m', NULL, A_CAP_M, false },
- { (word)'N', (word)'n', NULL, A_CAP_N, false },
- { (word)'O', (word)'o', NULL, A_CAP_O, false },
- { (word)'P', (word)'p', NULL, A_CAP_P, false },
- { (word)'Q', (word)'q', NULL, A_CAP_Q, false },
- { (word)'R', (word)'r', NULL, A_CAP_R, false },
- { (word)'S', (word)'s', NULL, A_CAP_S, false },
- { (word)'T', (word)'t', NULL, A_CAP_T, false },
- { (word)'U', (word)'u', NULL, A_CAP_U, false },
- { (word)'V', (word)'v', NULL, A_CAP_V, false },
- { (word)'W', (word)'w', NULL, A_CAP_W, false },
- { (word)'X', (word)'x', NULL, A_CAP_X, false },
- { (word)'Y', (word)'y', NULL, A_CAP_Y, false },
- { (word)'Z', (word)'z', NULL, A_CAP_Z, false },
- { (word)'[', (word)'[', NULL, A_OPEN_SQUARE, false },
- { 0x5c, 0x5c, NULL, A_BACKSLASH, false },
- { (word)']', (word)']', NULL, A_CLOSE_SQUARE, false },
- { (word)'^', (word)'^', NULL, A_CARET, false },
- { (word)'_', (word)'_', NULL, A_UNDERSCORE, false },
-
- { 0x60, 0x60, NULL, A_LEFT_SINGLE_QUOTE, false },
- { (word)'A', (word)'a', NULL, A_LOW_A, false },
- { (word)'B', (word)'b', NULL, A_LOW_B, false },
- { (word)'C', (word)'c', NULL, A_LOW_C, false },
- { (word)'D', (word)'d', NULL, A_LOW_D, false },
- { (word)'E', (word)'e', NULL, A_LOW_E, false },
- { (word)'F', (word)'f', NULL, A_LOW_F, false },
- { (word)'G', (word)'g', NULL, A_LOW_G, false },
- { (word)'H', (word)'h', NULL, A_LOW_H, false },
- { (word)'I', (word)'i', NULL, A_LOW_I, false },
- { (word)'J', (word)'j', NULL, A_LOW_J, false },
- { (word)'K', (word)'k', NULL, A_LOW_K, false },
- { (word)'L', (word)'l', NULL, A_LOW_L, false },
- { (word)'M', (word)'m', NULL, A_LOW_M, false },
- { (word)'N', (word)'n', NULL, A_LOW_N, false },
- { (word)'O', (word)'o', NULL, A_LOW_O, false },
- { (word)'P', (word)'p', NULL, A_LOW_P, false },
- { (word)'Q', (word)'q', NULL, A_LOW_Q, false },
- { (word)'R', (word)'r', NULL, A_LOW_R, false },
- { (word)'S', (word)'s', NULL, A_LOW_S, false },
- { (word)'T', (word)'t', NULL, A_LOW_T, false },
- { (word)'U', (word)'u', NULL, A_LOW_U, false },
- { (word)'V', (word)'v', NULL, A_LOW_V, false },
- { (word)'W', (word)'w', NULL, A_LOW_W, false },
- { (word)'X', (word)'x', NULL, A_LOW_X, false },
- { (word)'Y', (word)'y', NULL, A_LOW_Y, false },
- { (word)'Z', (word)'z', NULL, A_LOW_Z, false },
- { (word)'{', (word)'{', NULL, A_OPEN_BRACE, false },
- { (word)'|', (word)'|', NULL, A_BAR, false },
- { (word)'}', (word)'}', NULL, A_CLOSE_BRACE, false },
- { (word)'~', (word)'~', NULL, A_TILDE, false },
- { 0x7f, 0x7f, "DEL", A_DELETE, false },
-
- { 0x80, 0x80, "EURO", A_EURO, false },
- { 0x81, 0x81, "SHIFT", A_SHIFT2, false },
- { 0x82, 0x82, "CTRL", A_CTRL2, false },
- { 0x83, 0x83, "ALT", A_ALT2, false },
- { 0x84, 0x84, "F5", A_F5, true },
- { 0x85, 0x85, "F6", A_F6, true },
- { 0x86, 0x86, "F7", A_F7, true },
- { 0x87, 0x87, "F8", A_F8, true },
- { 0x88, 0x88, "CIRCUMFLEX", A_CIRCUMFLEX, false },
- { 0x89, 0x89, "MWHEELUP", A_MWHEELUP, false },
- { 0x8a, 0x9a, NULL, A_CAP_SCARON, false }, // ******
- { 0x8b, 0x8b, "MWHEELDOWN", A_MWHEELDOWN, false },
- { 0x8c, 0x9c, NULL, A_CAP_OE, false }, // ******
- { 0x8d, 0x8d, "MOUSE1", A_MOUSE1, false },
- { 0x8e, 0x8e, "MOUSE2", A_MOUSE2, false },
- { 0x8f, 0x8f, "INS", A_INSERT, false },
- { 0x90, 0x90, "HOME", A_HOME, false },
- { 0x91, 0x91, "PGUP", A_PAGE_UP, false },
- { 0x92, 0x92, NULL, A_RIGHT_SINGLE_QUOTE, false },
- { 0x93, 0x93, NULL, A_LEFT_DOUBLE_QUOTE, false },
- { 0x94, 0x94, NULL, A_RIGHT_DOUBLE_QUOTE, false },
- { 0x95, 0x95, "F9", A_F9, true },
- { 0x96, 0x96, "F10", A_F10, true },
- { 0x97, 0x97, "F11", A_F11, true },
- { 0x98, 0x98, "F12", A_F12, true },
- { 0x99, 0x99, NULL, A_TRADEMARK, false },
- { 0x8a, 0x9a, NULL, A_LOW_SCARON, false }, // ******
- { 0x9b, 0x9b, "SHIFT_ENTER", A_ENTER, false },
- { 0x8c, 0x9c, NULL, A_LOW_OE, false }, // ******
- { 0x9d, 0x9d, "END", A_END, false },
- { 0x9e, 0x9e, "PGDN", A_PAGE_DOWN, false },
- { 0x9f, 0xff, NULL, A_CAP_YDIERESIS, false }, // ******
-
- { 0xa0, 0, "SHIFT_SPACE", A_SPACE, false },
- { 0xa1, 0xa1, NULL, A_EXCLAMDOWN, false }, // upside down '!' - undisplayable
- { L'\u00A2', L'\u00A2', NULL, A_CENT, false }, // cent sign
- { L'\u00A3', L'\u00A3', NULL, A_POUND, false }, // pound (as in currency) symbol
- { 0xa4, 0, "SHIFT_KP_ENTER", A_KP_ENTER, false },
- { L'\u00A5', L'\u00A5', NULL, A_YEN, false }, // yen symbol
- { 0xa6, 0xa6, "MOUSE3", A_MOUSE3, false },
- { 0xa7, 0xa7, "MOUSE4", A_MOUSE4, false },
- { 0xa8, 0xa8, "MOUSE5", A_MOUSE5, false },
- { L'\u00A9', L'\u00A9', NULL, A_COPYRIGHT, false }, // copyright symbol
- { 0xaa, 0xaa, "UPARROW", A_CURSOR_UP, false },
- { 0xab, 0xab, "DOWNARROW", A_CURSOR_DOWN, false },
- { 0xac, 0xac, "LEFTARROW", A_CURSOR_LEFT, false },
- { 0xad, 0xad, "RIGHTARROW", A_CURSOR_RIGHT, false },
- { L'\u00AE', L'\u00AE', NULL, A_REGISTERED, false }, // registered trademark symbol
- { 0xaf, 0, NULL, A_UNDEFINED_7, false },
- { 0xb0, 0, NULL, A_UNDEFINED_8, false },
- { 0xb1, 0, NULL, A_UNDEFINED_9, false },
- { 0xb2, 0, NULL, A_UNDEFINED_10, false },
- { 0xb3, 0, NULL, A_UNDEFINED_11, false },
- { 0xb4, 0, NULL, A_UNDEFINED_12, false },
- { 0xb5, 0, NULL, A_UNDEFINED_13, false },
- { 0xb6, 0, NULL, A_UNDEFINED_14, false },
- { 0xb7, 0, NULL, A_UNDEFINED_15, false },
- { 0xb8, 0, NULL, A_UNDEFINED_16, false },
- { 0xb9, 0, NULL, A_UNDEFINED_17, false },
- { 0xba, 0, NULL, A_UNDEFINED_18, false },
- { 0xbb, 0, NULL, A_UNDEFINED_19, false },
- { 0xbc, 0, NULL, A_UNDEFINED_20, false },
- { 0xbd, 0, NULL, A_UNDEFINED_21, false },
- { 0xbe, 0, NULL, A_UNDEFINED_22, false },
- { L'\u00BF', L'\u00BF', NULL, A_QUESTION_DOWN, false }, // upside-down question mark
-
- { L'\u00C0', L'\u00E0', NULL, A_CAP_AGRAVE, false },
- { L'\u00C1', L'\u00E1', NULL, A_CAP_AACUTE, false },
- { L'\u00C2', L'\u00E2', NULL, A_CAP_ACIRCUMFLEX, false },
- { L'\u00C3', L'\u00E3', NULL, A_CAP_ATILDE, false },
- { L'\u00C4', L'\u00E4', NULL, A_CAP_ADIERESIS, false },
- { L'\u00C5', L'\u00E5', NULL, A_CAP_ARING, false },
- { L'\u00C6', L'\u00E6', NULL, A_CAP_AE, false },
- { L'\u00C7', L'\u00E7', NULL, A_CAP_CCEDILLA, false },
- { L'\u00C8', L'\u00E8', NULL, A_CAP_EGRAVE, false },
- { L'\u00C9', L'\u00E9', NULL, A_CAP_EACUTE, false },
- { L'\u00CA', L'\u00EA', NULL, A_CAP_ECIRCUMFLEX, false },
- { L'\u00CB', L'\u00EB', NULL, A_CAP_EDIERESIS, false },
- { L'\u00CC', L'\u00EC', NULL, A_CAP_IGRAVE, false },
- { L'\u00CD', L'\u00ED', NULL, A_CAP_IACUTE, false },
- { L'\u00CE', L'\u00EE', NULL, A_CAP_ICIRCUMFLEX, false },
- { L'\u00CF', L'\u00EF', NULL, A_CAP_IDIERESIS, false },
- { L'\u00D0', L'\u00F0', NULL, A_CAP_ETH, false },
- { L'\u00D1', L'\u00F1', NULL, A_CAP_NTILDE, false },
- { L'\u00D2', L'\u00F2', NULL, A_CAP_OGRAVE, false },
- { L'\u00D3', L'\u00F3', NULL, A_CAP_OACUTE, false },
- { L'\u00D4', L'\u00F4', NULL, A_CAP_OCIRCUMFLEX, false },
- { L'\u00D5', L'\u00F5', NULL, A_CAP_OTILDE, false },
- { L'\u00D6', L'\u00F6', NULL, A_CAP_ODIERESIS, false },
- { L'\u00D7', L'\u00D7', "KP_STAR", A_MULTIPLY, false },
- { L'\u00D8', L'\u00F8', NULL, A_CAP_OSLASH, false },
- { L'\u00D9', L'\u00F9', NULL, A_CAP_UGRAVE, false },
- { L'\u00DA', L'\u00FA', NULL, A_CAP_UACUTE, false },
- { L'\u00DB', L'\u00FB', NULL, A_CAP_UCIRCUMFLEX, false },
- { L'\u00DC', L'\u00FC', NULL, A_CAP_UDIERESIS, false },
- { L'\u00DD', L'\u00FD', NULL, A_CAP_YACUTE, false },
- { L'\u00DE', L'\u00FE', NULL, A_CAP_THORN, false },
- { L'\u00DF', L'\u00DF', NULL, A_GERMANDBLS, false },
-
- { L'\u00C0', L'\u00E0', NULL, A_LOW_AGRAVE, false },
- { L'\u00C1', L'\u00E1', NULL, A_LOW_AACUTE, false },
- { L'\u00C2', L'\u00E2', NULL, A_LOW_ACIRCUMFLEX, false },
- { L'\u00C3', L'\u00E3', NULL, A_LOW_ATILDE, false },
- { L'\u00C4', L'\u00E4', NULL, A_LOW_ADIERESIS, false },
- { L'\u00C5', L'\u00E5', NULL, A_LOW_ARING, false },
- { L'\u00C6', L'\u00E6', NULL, A_LOW_AE, false },
- { L'\u00C7', L'\u00E7', NULL, A_LOW_CCEDILLA, false },
- { L'\u00C8', L'\u00E8', NULL, A_LOW_EGRAVE, false },
- { L'\u00C9', L'\u00E9', NULL, A_LOW_EACUTE, false },
- { L'\u00CA', L'\u00EA', NULL, A_LOW_ECIRCUMFLEX, false },
- { L'\u00CB', L'\u00EB', NULL, A_LOW_EDIERESIS, false },
- { L'\u00CC', L'\u00EC', NULL, A_LOW_IGRAVE, false },
- { L'\u00CD', L'\u00ED', NULL, A_LOW_IACUTE, false },
- { L'\u00CE', L'\u00EE', NULL, A_LOW_ICIRCUMFLEX, false },
- { L'\u00CF', L'\u00EF', NULL, A_LOW_IDIERESIS, false },
- { L'\u00D0', L'\u00F0', NULL, A_LOW_ETH, false },
- { L'\u00D1', L'\u00F1', NULL, A_LOW_NTILDE, false },
- { L'\u00D2', L'\u00F2', NULL, A_LOW_OGRAVE, false },
- { L'\u00D3', L'\u00F3', NULL, A_LOW_OACUTE, false },
- { L'\u00D4', L'\u00F4', NULL, A_LOW_OCIRCUMFLEX, false },
- { L'\u00D5', L'\u00F5', NULL, A_LOW_OTILDE, false },
- { L'\u00D6', L'\u00F6', NULL, A_LOW_ODIERESIS, false },
- { L'\u00F7', L'\u00F7', "KP_SLASH", A_DIVIDE, false },
- { L'\u00D8', L'\u00F8', NULL, A_LOW_OSLASH, false },
- { L'\u00D9', L'\u00F9', NULL, A_LOW_UGRAVE, false },
- { L'\u00DA', L'\u00FA', NULL, A_LOW_UACUTE, false },
- { L'\u00DB', L'\u00FB', NULL, A_LOW_UCIRCUMFLEX, false },
- { L'\u00DC', L'\u00FC', NULL, A_LOW_UDIERESIS, false },
- { L'\u00DD', L'\u00FD', NULL, A_LOW_YACUTE, false },
- { L'\u00DE', L'\u00FE', NULL, A_LOW_THORN, false },
- { 0x9f, 0xff, NULL, A_LOW_YDIERESIS, false }, // *******
-
- { 0x100, 0x100, "JOY0", A_JOY0, false },
- { 0x101, 0x101, "JOY1", A_JOY1, false },
- { 0x102, 0x102, "JOY2", A_JOY2, false },
- { 0x103, 0x103, "JOY3", A_JOY3, false },
- { 0x104, 0x104, "JOY4", A_JOY4, false },
- { 0x105, 0x105, "JOY5", A_JOY5, false },
- { 0x106, 0x106, "JOY6", A_JOY6, false },
- { 0x107, 0x107, "JOY7", A_JOY7, false },
- { 0x108, 0x108, "JOY8", A_JOY8, false },
- { 0x109, 0x109, "JOY9", A_JOY9, false },
- { 0x10a, 0x10a, "JOY10", A_JOY10, false },
- { 0x10b, 0x10b, "JOY11", A_JOY11, false },
- { 0x10c, 0x10c, "JOY12", A_JOY12, false },
- { 0x10d, 0x10d, "JOY13", A_JOY13, false },
- { 0x10e, 0x10e, "JOY14", A_JOY14, false },
- { 0x10f, 0x10f, "JOY15", A_JOY15, false },
- { 0x110, 0x110, "JOY16", A_JOY16, false },
- { 0x111, 0x111, "JOY17", A_JOY17, false },
- { 0x112, 0x112, "JOY18", A_JOY18, false },
- { 0x113, 0x113, "JOY19", A_JOY19, false },
- { 0x114, 0x114, "JOY20", A_JOY20, false },
- { 0x115, 0x115, "JOY21", A_JOY21, false },
- { 0x116, 0x116, "JOY22", A_JOY22, false },
- { 0x117, 0x117, "JOY23", A_JOY23, false },
- { 0x118, 0x118, "JOY24", A_JOY24, false },
- { 0x119, 0x119, "JOY25", A_JOY25, false },
- { 0x11a, 0x11a, "JOY26", A_JOY26, false },
- { 0x11b, 0x11b, "JOY27", A_JOY27, false },
- { 0x11c, 0x11c, "JOY28", A_JOY28, false },
- { 0x11d, 0x11d, "JOY29", A_JOY29, false },
- { 0x11e, 0x11e, "JOY30", A_JOY30, false },
- { 0x11f, 0x11f, "JOY31", A_JOY31, false },
-
- { 0x120, 0x120, "AUX0", A_AUX0, false },
- { 0x121, 0x121, "AUX1", A_AUX1, false },
- { 0x122, 0x122, "AUX2", A_AUX2, false },
- { 0x123, 0x123, "AUX3", A_AUX3, false },
- { 0x124, 0x124, "AUX4", A_AUX4, false },
- { 0x125, 0x125, "AUX5", A_AUX5, false },
- { 0x126, 0x126, "AUX6", A_AUX6, false },
- { 0x127, 0x127, "AUX7", A_AUX7, false },
- { 0x128, 0x128, "AUX8", A_AUX8, false },
- { 0x129, 0x129, "AUX9", A_AUX9, false },
- { 0x12a, 0x12a, "AUX10", A_AUX10, false },
- { 0x12b, 0x12b, "AUX11", A_AUX11, false },
- { 0x12c, 0x12c, "AUX12", A_AUX12, false },
- { 0x12d, 0x12d, "AUX13", A_AUX13, false },
- { 0x12e, 0x12e, "AUX14", A_AUX14, false },
- { 0x12f, 0x12f, "AUX15", A_AUX15, false },
- { 0x130, 0x130, "AUX16", A_AUX16, false },
- { 0x131, 0x131, "AUX17", A_AUX17, false },
- { 0x132, 0x132, "AUX18", A_AUX18, false },
- { 0x133, 0x133, "AUX19", A_AUX19, false },
- { 0x134, 0x134, "AUX20", A_AUX20, false },
- { 0x135, 0x135, "AUX21", A_AUX21, false },
- { 0x136, 0x136, "AUX22", A_AUX22, false },
- { 0x137, 0x137, "AUX23", A_AUX23, false },
- { 0x138, 0x138, "AUX24", A_AUX24, false },
- { 0x139, 0x139, "AUX25", A_AUX25, false },
- { 0x13a, 0x13a, "AUX26", A_AUX26, false },
- { 0x13b, 0x13b, "AUX27", A_AUX27, false },
- { 0x13c, 0x13c, "AUX28", A_AUX28, false },
- { 0x13d, 0x13d, "AUX29", A_AUX29, false },
- { 0x13e, 0x13e, "AUX30", A_AUX30, false },
- { 0x13f, 0x13f, "AUX31", A_AUX31, false }
-};
-static const size_t numKeynames = ARRAY_LEN( keynames );
-
-
+keyname_t keynames[MAX_KEYS] = {{0x00, 0x00, NULL, A_NULL, false},
+ {0x01, 0x01, "SHIFT", A_SHIFT, false},
+ {0x02, 0x02, "CTRL", A_CTRL, false},
+ {0x03, 0x03, "ALT", A_ALT, false},
+ {0x04, 0x04, "CAPSLOCK", A_CAPSLOCK, false},
+ {0x05, 0x05, "KP_NUMLOCK", A_NUMLOCK, false},
+ {0x06, 0x06, "SCROLLLOCK", A_SCROLLLOCK, false},
+ {0x07, 0x07, "PAUSE", A_PAUSE, false},
+ {0x08, 0x08, "BACKSPACE", A_BACKSPACE, false},
+ {0x09, 0x09, "TAB", A_TAB, false},
+ {0x0a, 0x0a, "ENTER", A_ENTER, false},
+ {0x0b, 0x0b, "KP_PLUS", A_KP_PLUS, false},
+ {0x0c, 0x0c, "KP_MINUS", A_KP_MINUS, false},
+ {0x0d, 0x0d, "KP_ENTER", A_KP_ENTER, false},
+ {0x0e, 0x0e, "KP_DEL", A_KP_PERIOD, false},
+ {0x0f, 0x0f, NULL, A_PRINTSCREEN, false},
+ {0x10, 0x10, "KP_INS", A_KP_0, false},
+ {0x11, 0x11, "KP_END", A_KP_1, false},
+ {0x12, 0x12, "KP_DOWNARROW", A_KP_2, false},
+ {0x13, 0x13, "KP_PGDN", A_KP_3, false},
+ {0x14, 0x14, "KP_LEFTARROW", A_KP_4, false},
+ {0x15, 0x15, "KP_5", A_KP_5, false},
+ {0x16, 0x16, "KP_RIGHTARROW", A_KP_6, false},
+ {0x17, 0x17, "KP_HOME", A_KP_7, false},
+ {0x18, 0x18, "KP_UPARROW", A_KP_8, false},
+ {0x19, 0x19, "KP_PGUP", A_KP_9, false},
+ {0x1a, 0x1a, "CONSOLE", A_CONSOLE, false},
+ {0x1b, 0x1b, "ESCAPE", A_ESCAPE, false},
+ {0x1c, 0x1c, "F1", A_F1, true},
+ {0x1d, 0x1d, "F2", A_F2, true},
+ {0x1e, 0x1e, "F3", A_F3, true},
+ {0x1f, 0x1f, "F4", A_F4, true},
+
+ {0x20, 0x20, "SPACE", A_SPACE, false},
+ {(word)'!', (word)'!', NULL, A_PLING, false},
+ {(word)'"', (word)'"', NULL, A_DOUBLE_QUOTE, false},
+ {(word)'#', (word)'#', NULL, A_HASH, false},
+ {(word)'$', (word)'$', NULL, A_STRING, false},
+ {(word)'%', (word)'%', NULL, A_PERCENT, false},
+ {(word)'&', (word)'&', NULL, A_AND, false},
+ {0x27, 0x27, NULL, A_SINGLE_QUOTE, false},
+ {(word)'(', (word)'(', NULL, A_OPEN_BRACKET, false},
+ {(word)')', (word)')', NULL, A_CLOSE_BRACKET, false},
+ {(word)'*', (word)'*', NULL, A_STAR, false},
+ {(word)'+', (word)'+', NULL, A_PLUS, false},
+ {(word)',', (word)',', NULL, A_COMMA, false},
+ {(word)'-', (word)'-', NULL, A_MINUS, false},
+ {(word)'.', (word)'.', NULL, A_PERIOD, false},
+ {(word)'/', (word)'/', NULL, A_FORWARD_SLASH, false},
+ {(word)'0', (word)'0', NULL, A_0, false},
+ {(word)'1', (word)'1', NULL, A_1, false},
+ {(word)'2', (word)'2', NULL, A_2, false},
+ {(word)'3', (word)'3', NULL, A_3, false},
+ {(word)'4', (word)'4', NULL, A_4, false},
+ {(word)'5', (word)'5', NULL, A_5, false},
+ {(word)'6', (word)'6', NULL, A_6, false},
+ {(word)'7', (word)'7', NULL, A_7, false},
+ {(word)'8', (word)'8', NULL, A_8, false},
+ {(word)'9', (word)'9', NULL, A_9, false},
+ {(word)':', (word)':', NULL, A_COLON, false},
+ {(word)';', (word)';', "SEMICOLON", A_SEMICOLON, false},
+ {(word)'<', (word)'<', NULL, A_LESSTHAN, false},
+ {(word)'=', (word)'=', NULL, A_EQUALS, false},
+ {(word)'>', (word)'>', NULL, A_GREATERTHAN, false},
+ {(word)'?', (word)'?', NULL, A_QUESTION, false},
+
+ {(word)'@', (word)'@', NULL, A_AT, false},
+ {(word)'A', (word)'a', NULL, A_CAP_A, false},
+ {(word)'B', (word)'b', NULL, A_CAP_B, false},
+ {(word)'C', (word)'c', NULL, A_CAP_C, false},
+ {(word)'D', (word)'d', NULL, A_CAP_D, false},
+ {(word)'E', (word)'e', NULL, A_CAP_E, false},
+ {(word)'F', (word)'f', NULL, A_CAP_F, false},
+ {(word)'G', (word)'g', NULL, A_CAP_G, false},
+ {(word)'H', (word)'h', NULL, A_CAP_H, false},
+ {(word)'I', (word)'i', NULL, A_CAP_I, false},
+ {(word)'J', (word)'j', NULL, A_CAP_J, false},
+ {(word)'K', (word)'k', NULL, A_CAP_K, false},
+ {(word)'L', (word)'l', NULL, A_CAP_L, false},
+ {(word)'M', (word)'m', NULL, A_CAP_M, false},
+ {(word)'N', (word)'n', NULL, A_CAP_N, false},
+ {(word)'O', (word)'o', NULL, A_CAP_O, false},
+ {(word)'P', (word)'p', NULL, A_CAP_P, false},
+ {(word)'Q', (word)'q', NULL, A_CAP_Q, false},
+ {(word)'R', (word)'r', NULL, A_CAP_R, false},
+ {(word)'S', (word)'s', NULL, A_CAP_S, false},
+ {(word)'T', (word)'t', NULL, A_CAP_T, false},
+ {(word)'U', (word)'u', NULL, A_CAP_U, false},
+ {(word)'V', (word)'v', NULL, A_CAP_V, false},
+ {(word)'W', (word)'w', NULL, A_CAP_W, false},
+ {(word)'X', (word)'x', NULL, A_CAP_X, false},
+ {(word)'Y', (word)'y', NULL, A_CAP_Y, false},
+ {(word)'Z', (word)'z', NULL, A_CAP_Z, false},
+ {(word)'[', (word)'[', NULL, A_OPEN_SQUARE, false},
+ {0x5c, 0x5c, NULL, A_BACKSLASH, false},
+ {(word)']', (word)']', NULL, A_CLOSE_SQUARE, false},
+ {(word)'^', (word)'^', NULL, A_CARET, false},
+ {(word)'_', (word)'_', NULL, A_UNDERSCORE, false},
+
+ {0x60, 0x60, NULL, A_LEFT_SINGLE_QUOTE, false},
+ {(word)'A', (word)'a', NULL, A_LOW_A, false},
+ {(word)'B', (word)'b', NULL, A_LOW_B, false},
+ {(word)'C', (word)'c', NULL, A_LOW_C, false},
+ {(word)'D', (word)'d', NULL, A_LOW_D, false},
+ {(word)'E', (word)'e', NULL, A_LOW_E, false},
+ {(word)'F', (word)'f', NULL, A_LOW_F, false},
+ {(word)'G', (word)'g', NULL, A_LOW_G, false},
+ {(word)'H', (word)'h', NULL, A_LOW_H, false},
+ {(word)'I', (word)'i', NULL, A_LOW_I, false},
+ {(word)'J', (word)'j', NULL, A_LOW_J, false},
+ {(word)'K', (word)'k', NULL, A_LOW_K, false},
+ {(word)'L', (word)'l', NULL, A_LOW_L, false},
+ {(word)'M', (word)'m', NULL, A_LOW_M, false},
+ {(word)'N', (word)'n', NULL, A_LOW_N, false},
+ {(word)'O', (word)'o', NULL, A_LOW_O, false},
+ {(word)'P', (word)'p', NULL, A_LOW_P, false},
+ {(word)'Q', (word)'q', NULL, A_LOW_Q, false},
+ {(word)'R', (word)'r', NULL, A_LOW_R, false},
+ {(word)'S', (word)'s', NULL, A_LOW_S, false},
+ {(word)'T', (word)'t', NULL, A_LOW_T, false},
+ {(word)'U', (word)'u', NULL, A_LOW_U, false},
+ {(word)'V', (word)'v', NULL, A_LOW_V, false},
+ {(word)'W', (word)'w', NULL, A_LOW_W, false},
+ {(word)'X', (word)'x', NULL, A_LOW_X, false},
+ {(word)'Y', (word)'y', NULL, A_LOW_Y, false},
+ {(word)'Z', (word)'z', NULL, A_LOW_Z, false},
+ {(word)'{', (word)'{', NULL, A_OPEN_BRACE, false},
+ {(word)'|', (word)'|', NULL, A_BAR, false},
+ {(word)'}', (word)'}', NULL, A_CLOSE_BRACE, false},
+ {(word)'~', (word)'~', NULL, A_TILDE, false},
+ {0x7f, 0x7f, "DEL", A_DELETE, false},
+
+ {0x80, 0x80, "EURO", A_EURO, false},
+ {0x81, 0x81, "SHIFT", A_SHIFT2, false},
+ {0x82, 0x82, "CTRL", A_CTRL2, false},
+ {0x83, 0x83, "ALT", A_ALT2, false},
+ {0x84, 0x84, "F5", A_F5, true},
+ {0x85, 0x85, "F6", A_F6, true},
+ {0x86, 0x86, "F7", A_F7, true},
+ {0x87, 0x87, "F8", A_F8, true},
+ {0x88, 0x88, "CIRCUMFLEX", A_CIRCUMFLEX, false},
+ {0x89, 0x89, "MWHEELUP", A_MWHEELUP, false},
+ {0x8a, 0x9a, NULL, A_CAP_SCARON, false}, // ******
+ {0x8b, 0x8b, "MWHEELDOWN", A_MWHEELDOWN, false},
+ {0x8c, 0x9c, NULL, A_CAP_OE, false}, // ******
+ {0x8d, 0x8d, "MOUSE1", A_MOUSE1, false},
+ {0x8e, 0x8e, "MOUSE2", A_MOUSE2, false},
+ {0x8f, 0x8f, "INS", A_INSERT, false},
+ {0x90, 0x90, "HOME", A_HOME, false},
+ {0x91, 0x91, "PGUP", A_PAGE_UP, false},
+ {0x92, 0x92, NULL, A_RIGHT_SINGLE_QUOTE, false},
+ {0x93, 0x93, NULL, A_LEFT_DOUBLE_QUOTE, false},
+ {0x94, 0x94, NULL, A_RIGHT_DOUBLE_QUOTE, false},
+ {0x95, 0x95, "F9", A_F9, true},
+ {0x96, 0x96, "F10", A_F10, true},
+ {0x97, 0x97, "F11", A_F11, true},
+ {0x98, 0x98, "F12", A_F12, true},
+ {0x99, 0x99, NULL, A_TRADEMARK, false},
+ {0x8a, 0x9a, NULL, A_LOW_SCARON, false}, // ******
+ {0x9b, 0x9b, "SHIFT_ENTER", A_ENTER, false},
+ {0x8c, 0x9c, NULL, A_LOW_OE, false}, // ******
+ {0x9d, 0x9d, "END", A_END, false},
+ {0x9e, 0x9e, "PGDN", A_PAGE_DOWN, false},
+ {0x9f, 0xff, NULL, A_CAP_YDIERESIS, false}, // ******
+
+ {0xa0, 0, "SHIFT_SPACE", A_SPACE, false},
+ {0xa1, 0xa1, NULL, A_EXCLAMDOWN, false}, // upside down '!' - undisplayable
+ {L'\u00A2', L'\u00A2', NULL, A_CENT, false}, // cent sign
+ {L'\u00A3', L'\u00A3', NULL, A_POUND, false}, // pound (as in currency) symbol
+ {0xa4, 0, "SHIFT_KP_ENTER", A_KP_ENTER, false},
+ {L'\u00A5', L'\u00A5', NULL, A_YEN, false}, // yen symbol
+ {0xa6, 0xa6, "MOUSE3", A_MOUSE3, false},
+ {0xa7, 0xa7, "MOUSE4", A_MOUSE4, false},
+ {0xa8, 0xa8, "MOUSE5", A_MOUSE5, false},
+ {L'\u00A9', L'\u00A9', NULL, A_COPYRIGHT, false}, // copyright symbol
+ {0xaa, 0xaa, "UPARROW", A_CURSOR_UP, false},
+ {0xab, 0xab, "DOWNARROW", A_CURSOR_DOWN, false},
+ {0xac, 0xac, "LEFTARROW", A_CURSOR_LEFT, false},
+ {0xad, 0xad, "RIGHTARROW", A_CURSOR_RIGHT, false},
+ {L'\u00AE', L'\u00AE', NULL, A_REGISTERED, false}, // registered trademark symbol
+ {0xaf, 0, NULL, A_UNDEFINED_7, false},
+ {0xb0, 0, NULL, A_UNDEFINED_8, false},
+ {0xb1, 0, NULL, A_UNDEFINED_9, false},
+ {0xb2, 0, NULL, A_UNDEFINED_10, false},
+ {0xb3, 0, NULL, A_UNDEFINED_11, false},
+ {0xb4, 0, NULL, A_UNDEFINED_12, false},
+ {0xb5, 0, NULL, A_UNDEFINED_13, false},
+ {0xb6, 0, NULL, A_UNDEFINED_14, false},
+ {0xb7, 0, NULL, A_UNDEFINED_15, false},
+ {0xb8, 0, NULL, A_UNDEFINED_16, false},
+ {0xb9, 0, NULL, A_UNDEFINED_17, false},
+ {0xba, 0, NULL, A_UNDEFINED_18, false},
+ {0xbb, 0, NULL, A_UNDEFINED_19, false},
+ {0xbc, 0, NULL, A_UNDEFINED_20, false},
+ {0xbd, 0, NULL, A_UNDEFINED_21, false},
+ {0xbe, 0, NULL, A_UNDEFINED_22, false},
+ {L'\u00BF', L'\u00BF', NULL, A_QUESTION_DOWN, false}, // upside-down question mark
+
+ {L'\u00C0', L'\u00E0', NULL, A_CAP_AGRAVE, false},
+ {L'\u00C1', L'\u00E1', NULL, A_CAP_AACUTE, false},
+ {L'\u00C2', L'\u00E2', NULL, A_CAP_ACIRCUMFLEX, false},
+ {L'\u00C3', L'\u00E3', NULL, A_CAP_ATILDE, false},
+ {L'\u00C4', L'\u00E4', NULL, A_CAP_ADIERESIS, false},
+ {L'\u00C5', L'\u00E5', NULL, A_CAP_ARING, false},
+ {L'\u00C6', L'\u00E6', NULL, A_CAP_AE, false},
+ {L'\u00C7', L'\u00E7', NULL, A_CAP_CCEDILLA, false},
+ {L'\u00C8', L'\u00E8', NULL, A_CAP_EGRAVE, false},
+ {L'\u00C9', L'\u00E9', NULL, A_CAP_EACUTE, false},
+ {L'\u00CA', L'\u00EA', NULL, A_CAP_ECIRCUMFLEX, false},
+ {L'\u00CB', L'\u00EB', NULL, A_CAP_EDIERESIS, false},
+ {L'\u00CC', L'\u00EC', NULL, A_CAP_IGRAVE, false},
+ {L'\u00CD', L'\u00ED', NULL, A_CAP_IACUTE, false},
+ {L'\u00CE', L'\u00EE', NULL, A_CAP_ICIRCUMFLEX, false},
+ {L'\u00CF', L'\u00EF', NULL, A_CAP_IDIERESIS, false},
+ {L'\u00D0', L'\u00F0', NULL, A_CAP_ETH, false},
+ {L'\u00D1', L'\u00F1', NULL, A_CAP_NTILDE, false},
+ {L'\u00D2', L'\u00F2', NULL, A_CAP_OGRAVE, false},
+ {L'\u00D3', L'\u00F3', NULL, A_CAP_OACUTE, false},
+ {L'\u00D4', L'\u00F4', NULL, A_CAP_OCIRCUMFLEX, false},
+ {L'\u00D5', L'\u00F5', NULL, A_CAP_OTILDE, false},
+ {L'\u00D6', L'\u00F6', NULL, A_CAP_ODIERESIS, false},
+ {L'\u00D7', L'\u00D7', "KP_STAR", A_MULTIPLY, false},
+ {L'\u00D8', L'\u00F8', NULL, A_CAP_OSLASH, false},
+ {L'\u00D9', L'\u00F9', NULL, A_CAP_UGRAVE, false},
+ {L'\u00DA', L'\u00FA', NULL, A_CAP_UACUTE, false},
+ {L'\u00DB', L'\u00FB', NULL, A_CAP_UCIRCUMFLEX, false},
+ {L'\u00DC', L'\u00FC', NULL, A_CAP_UDIERESIS, false},
+ {L'\u00DD', L'\u00FD', NULL, A_CAP_YACUTE, false},
+ {L'\u00DE', L'\u00FE', NULL, A_CAP_THORN, false},
+ {L'\u00DF', L'\u00DF', NULL, A_GERMANDBLS, false},
+
+ {L'\u00C0', L'\u00E0', NULL, A_LOW_AGRAVE, false},
+ {L'\u00C1', L'\u00E1', NULL, A_LOW_AACUTE, false},
+ {L'\u00C2', L'\u00E2', NULL, A_LOW_ACIRCUMFLEX, false},
+ {L'\u00C3', L'\u00E3', NULL, A_LOW_ATILDE, false},
+ {L'\u00C4', L'\u00E4', NULL, A_LOW_ADIERESIS, false},
+ {L'\u00C5', L'\u00E5', NULL, A_LOW_ARING, false},
+ {L'\u00C6', L'\u00E6', NULL, A_LOW_AE, false},
+ {L'\u00C7', L'\u00E7', NULL, A_LOW_CCEDILLA, false},
+ {L'\u00C8', L'\u00E8', NULL, A_LOW_EGRAVE, false},
+ {L'\u00C9', L'\u00E9', NULL, A_LOW_EACUTE, false},
+ {L'\u00CA', L'\u00EA', NULL, A_LOW_ECIRCUMFLEX, false},
+ {L'\u00CB', L'\u00EB', NULL, A_LOW_EDIERESIS, false},
+ {L'\u00CC', L'\u00EC', NULL, A_LOW_IGRAVE, false},
+ {L'\u00CD', L'\u00ED', NULL, A_LOW_IACUTE, false},
+ {L'\u00CE', L'\u00EE', NULL, A_LOW_ICIRCUMFLEX, false},
+ {L'\u00CF', L'\u00EF', NULL, A_LOW_IDIERESIS, false},
+ {L'\u00D0', L'\u00F0', NULL, A_LOW_ETH, false},
+ {L'\u00D1', L'\u00F1', NULL, A_LOW_NTILDE, false},
+ {L'\u00D2', L'\u00F2', NULL, A_LOW_OGRAVE, false},
+ {L'\u00D3', L'\u00F3', NULL, A_LOW_OACUTE, false},
+ {L'\u00D4', L'\u00F4', NULL, A_LOW_OCIRCUMFLEX, false},
+ {L'\u00D5', L'\u00F5', NULL, A_LOW_OTILDE, false},
+ {L'\u00D6', L'\u00F6', NULL, A_LOW_ODIERESIS, false},
+ {L'\u00F7', L'\u00F7', "KP_SLASH", A_DIVIDE, false},
+ {L'\u00D8', L'\u00F8', NULL, A_LOW_OSLASH, false},
+ {L'\u00D9', L'\u00F9', NULL, A_LOW_UGRAVE, false},
+ {L'\u00DA', L'\u00FA', NULL, A_LOW_UACUTE, false},
+ {L'\u00DB', L'\u00FB', NULL, A_LOW_UCIRCUMFLEX, false},
+ {L'\u00DC', L'\u00FC', NULL, A_LOW_UDIERESIS, false},
+ {L'\u00DD', L'\u00FD', NULL, A_LOW_YACUTE, false},
+ {L'\u00DE', L'\u00FE', NULL, A_LOW_THORN, false},
+ {0x9f, 0xff, NULL, A_LOW_YDIERESIS, false}, // *******
+
+ {0x100, 0x100, "JOY0", A_JOY0, false},
+ {0x101, 0x101, "JOY1", A_JOY1, false},
+ {0x102, 0x102, "JOY2", A_JOY2, false},
+ {0x103, 0x103, "JOY3", A_JOY3, false},
+ {0x104, 0x104, "JOY4", A_JOY4, false},
+ {0x105, 0x105, "JOY5", A_JOY5, false},
+ {0x106, 0x106, "JOY6", A_JOY6, false},
+ {0x107, 0x107, "JOY7", A_JOY7, false},
+ {0x108, 0x108, "JOY8", A_JOY8, false},
+ {0x109, 0x109, "JOY9", A_JOY9, false},
+ {0x10a, 0x10a, "JOY10", A_JOY10, false},
+ {0x10b, 0x10b, "JOY11", A_JOY11, false},
+ {0x10c, 0x10c, "JOY12", A_JOY12, false},
+ {0x10d, 0x10d, "JOY13", A_JOY13, false},
+ {0x10e, 0x10e, "JOY14", A_JOY14, false},
+ {0x10f, 0x10f, "JOY15", A_JOY15, false},
+ {0x110, 0x110, "JOY16", A_JOY16, false},
+ {0x111, 0x111, "JOY17", A_JOY17, false},
+ {0x112, 0x112, "JOY18", A_JOY18, false},
+ {0x113, 0x113, "JOY19", A_JOY19, false},
+ {0x114, 0x114, "JOY20", A_JOY20, false},
+ {0x115, 0x115, "JOY21", A_JOY21, false},
+ {0x116, 0x116, "JOY22", A_JOY22, false},
+ {0x117, 0x117, "JOY23", A_JOY23, false},
+ {0x118, 0x118, "JOY24", A_JOY24, false},
+ {0x119, 0x119, "JOY25", A_JOY25, false},
+ {0x11a, 0x11a, "JOY26", A_JOY26, false},
+ {0x11b, 0x11b, "JOY27", A_JOY27, false},
+ {0x11c, 0x11c, "JOY28", A_JOY28, false},
+ {0x11d, 0x11d, "JOY29", A_JOY29, false},
+ {0x11e, 0x11e, "JOY30", A_JOY30, false},
+ {0x11f, 0x11f, "JOY31", A_JOY31, false},
+
+ {0x120, 0x120, "AUX0", A_AUX0, false},
+ {0x121, 0x121, "AUX1", A_AUX1, false},
+ {0x122, 0x122, "AUX2", A_AUX2, false},
+ {0x123, 0x123, "AUX3", A_AUX3, false},
+ {0x124, 0x124, "AUX4", A_AUX4, false},
+ {0x125, 0x125, "AUX5", A_AUX5, false},
+ {0x126, 0x126, "AUX6", A_AUX6, false},
+ {0x127, 0x127, "AUX7", A_AUX7, false},
+ {0x128, 0x128, "AUX8", A_AUX8, false},
+ {0x129, 0x129, "AUX9", A_AUX9, false},
+ {0x12a, 0x12a, "AUX10", A_AUX10, false},
+ {0x12b, 0x12b, "AUX11", A_AUX11, false},
+ {0x12c, 0x12c, "AUX12", A_AUX12, false},
+ {0x12d, 0x12d, "AUX13", A_AUX13, false},
+ {0x12e, 0x12e, "AUX14", A_AUX14, false},
+ {0x12f, 0x12f, "AUX15", A_AUX15, false},
+ {0x130, 0x130, "AUX16", A_AUX16, false},
+ {0x131, 0x131, "AUX17", A_AUX17, false},
+ {0x132, 0x132, "AUX18", A_AUX18, false},
+ {0x133, 0x133, "AUX19", A_AUX19, false},
+ {0x134, 0x134, "AUX20", A_AUX20, false},
+ {0x135, 0x135, "AUX21", A_AUX21, false},
+ {0x136, 0x136, "AUX22", A_AUX22, false},
+ {0x137, 0x137, "AUX23", A_AUX23, false},
+ {0x138, 0x138, "AUX24", A_AUX24, false},
+ {0x139, 0x139, "AUX25", A_AUX25, false},
+ {0x13a, 0x13a, "AUX26", A_AUX26, false},
+ {0x13b, 0x13b, "AUX27", A_AUX27, false},
+ {0x13c, 0x13c, "AUX28", A_AUX28, false},
+ {0x13d, 0x13d, "AUX29", A_AUX29, false},
+ {0x13e, 0x13e, "AUX30", A_AUX30, false},
+ {0x13f, 0x13f, "AUX31", A_AUX31, false}};
+static const size_t numKeynames = ARRAY_LEN(keynames);
/*
=============================================================================
@@ -389,7 +383,6 @@ EDIT FIELDS
=============================================================================
*/
-
/*
===================
Field_Draw
@@ -399,84 +392,82 @@ x, y, amd width are in pixels
===================
*/
extern console_t con;
-void Field_VariableSizeDraw( field_t *edit, int x, int y, int size, qboolean showCursor, qboolean noColorEscape ) {
- int len;
- int drawLen;
- int prestep;
- int cursorChar;
- char str[MAX_STRING_CHARS];
- int i;
+void Field_VariableSizeDraw(field_t *edit, int x, int y, int size, qboolean showCursor, qboolean noColorEscape) {
+ int len;
+ int drawLen;
+ int prestep;
+ int cursorChar;
+ char str[MAX_STRING_CHARS];
+ int i;
drawLen = edit->widthInChars - 1; // - 1 so there is always a space for the cursor
- len = strlen( edit->buffer );
+ len = strlen(edit->buffer);
// guarantee that cursor will be visible
- if ( len <= drawLen ) {
+ if (len <= drawLen) {
prestep = 0;
} else {
- if ( edit->scroll + drawLen > len ) {
+ if (edit->scroll + drawLen > len) {
edit->scroll = len - drawLen;
- if ( edit->scroll < 0 ) {
+ if (edit->scroll < 0) {
edit->scroll = 0;
}
}
prestep = edit->scroll;
}
- if ( prestep + drawLen > len ) {
+ if (prestep + drawLen > len) {
drawLen = len - prestep;
}
// extract characters from the field at
- if ( drawLen >= MAX_STRING_CHARS ) {
- Com_Error( ERR_DROP, "drawLen >= MAX_STRING_CHARS" );
+ if (drawLen >= MAX_STRING_CHARS) {
+ Com_Error(ERR_DROP, "drawLen >= MAX_STRING_CHARS");
}
- memcpy( str, edit->buffer + prestep, drawLen );
- str[ drawLen ] = 0;
+ memcpy(str, edit->buffer + prestep, drawLen);
+ str[drawLen] = 0;
// draw it
- if ( size == con.charWidth ) {
- float color[4];
+ if (size == con.charWidth) {
+ float color[4];
color[0] = color[1] = color[2] = color[3] = 1.0;
- SCR_DrawSmallStringExt( x, y, str, color, qfalse, noColorEscape );
+ SCR_DrawSmallStringExt(x, y, str, color, qfalse, noColorEscape);
} else {
// draw big string with drop shadow
- SCR_DrawBigString( x, y, str, 1.0, noColorEscape );
+ SCR_DrawBigString(x, y, str, 1.0, noColorEscape);
}
// draw the cursor
- if ( showCursor ) {
- if ( (int)( cls.realtime >> 8 ) & 1 ) {
- return; // off blink
+ if (showCursor) {
+ if ((int)(cls.realtime >> 8) & 1) {
+ return; // off blink
}
- if ( kg.key_overstrikeMode ) {
+ if (kg.key_overstrikeMode) {
cursorChar = 11;
} else {
cursorChar = 10;
}
- i = drawLen - strlen( str );
+ i = drawLen - strlen(str);
- if ( size == con.charWidth ) {
- SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
+ if (size == con.charWidth) {
+ SCR_DrawSmallChar(x + (edit->cursor - prestep - i) * size, y, cursorChar);
} else {
str[0] = cursorChar;
str[1] = 0;
- SCR_DrawBigString( x + ( edit->cursor - prestep - i ) * size, y, str, 1.0, qfalse );
+ SCR_DrawBigString(x + (edit->cursor - prestep - i) * size, y, str, 1.0, qfalse);
}
}
}
-void Field_Draw( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape )
-{
- Field_VariableSizeDraw( edit, x, y, con.charWidth, showCursor, noColorEscape );
+void Field_Draw(field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape) {
+ Field_VariableSizeDraw(edit, x, y, con.charWidth, showCursor, noColorEscape);
}
-void Field_BigDraw( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape )
-{
- Field_VariableSizeDraw( edit, x, y, BIGCHAR_WIDTH, showCursor, noColorEscape );
+void Field_BigDraw(field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape) {
+ Field_VariableSizeDraw(edit, x, y, BIGCHAR_WIDTH, showCursor, noColorEscape);
}
/*
@@ -484,24 +475,23 @@ void Field_BigDraw( field_t *edit, int x, int y, qboolean showCursor, qboolean n
Field_Paste
================
*/
-void Field_CharEvent( field_t *edit, int ch );
-void Field_Paste( field_t *edit ) {
- char *cbd, *c;
+void Field_CharEvent(field_t *edit, int ch);
+void Field_Paste(field_t *edit) {
+ char *cbd, *c;
c = cbd = Sys_GetClipboardData();
- if ( !cbd ) {
+ if (!cbd) {
return;
}
// send as if typed, so insert / overstrike works properly
- while( *c )
- {
- uint32_t utf32 = ConvertUTF8ToUTF32( c, &c );
- Field_CharEvent( edit, ConvertUTF32ToExpectedCharset( utf32 ) );
+ while (*c) {
+ uint32_t utf32 = ConvertUTF8ToUTF32(c, &c);
+ Field_CharEvent(edit, ConvertUTF32ToExpectedCharset(utf32));
}
- Z_Free( cbd );
+ Z_Free(cbd);
}
/*
@@ -514,64 +504,55 @@ in-game talk, and menu fields
Key events are used for non-printable characters, others are gotten from char events.
=================
*/
-void Field_KeyDownEvent( field_t *edit, int key ) {
- int len;
+void Field_KeyDownEvent(field_t *edit, int key) {
+ int len;
// shift-insert is paste
- if ( ( key == A_INSERT ) && kg.keys[A_SHIFT].down )
- {
- Field_Paste( edit );
+ if ((key == A_INSERT) && kg.keys[A_SHIFT].down) {
+ Field_Paste(edit);
return;
}
- len = strlen( edit->buffer );
+ len = strlen(edit->buffer);
- if ( key == A_DELETE ) {
- if ( edit->cursor < len ) {
- memmove( edit->buffer + edit->cursor,
- edit->buffer + edit->cursor + 1, len - edit->cursor );
+ if (key == A_DELETE) {
+ if (edit->cursor < len) {
+ memmove(edit->buffer + edit->cursor, edit->buffer + edit->cursor + 1, len - edit->cursor);
}
return;
}
- if ( key == A_CURSOR_RIGHT )
- {
- if ( edit->cursor < len ) {
+ if (key == A_CURSOR_RIGHT) {
+ if (edit->cursor < len) {
edit->cursor++;
}
- if ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )
- {
+ if (edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len) {
edit->scroll++;
}
return;
}
- if ( key == A_CURSOR_LEFT )
- {
- if ( edit->cursor > 0 ) {
+ if (key == A_CURSOR_LEFT) {
+ if (edit->cursor > 0) {
edit->cursor--;
}
- if ( edit->cursor < edit->scroll )
- {
+ if (edit->cursor < edit->scroll) {
edit->scroll--;
}
return;
}
- if ( key == A_HOME || ( keynames[key].lower == 'a' && kg.keys[A_CTRL].down ) )
- {
+ if (key == A_HOME || (keynames[key].lower == 'a' && kg.keys[A_CTRL].down)) {
edit->cursor = 0;
return;
}
- if ( key == A_END || ( keynames[key].lower == 'e' && kg.keys[A_CTRL].down ) )
- {
+ if (key == A_END || (keynames[key].lower == 'e' && kg.keys[A_CTRL].down)) {
edit->cursor = len;
return;
}
- if ( key == A_INSERT )
- {
+ if (key == A_INSERT) {
kg.key_overstrikeMode = (qboolean)!kg.key_overstrikeMode;
return;
}
@@ -582,41 +563,39 @@ void Field_KeyDownEvent( field_t *edit, int key ) {
Field_CharEvent
==================
*/
-void Field_CharEvent( field_t *edit, int ch ) {
- int len;
+void Field_CharEvent(field_t *edit, int ch) {
+ int len;
- if ( ch == 'v' - 'a' + 1 ) { // ctrl-v is paste
- Field_Paste( edit );
+ if (ch == 'v' - 'a' + 1) { // ctrl-v is paste
+ Field_Paste(edit);
return;
}
- if ( ch == 'c' - 'a' + 1 ) { // ctrl-c clears the field
- Field_Clear( edit );
+ if (ch == 'c' - 'a' + 1) { // ctrl-c clears the field
+ Field_Clear(edit);
return;
}
- len = strlen( edit->buffer );
+ len = strlen(edit->buffer);
- if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace
- if ( edit->cursor > 0 ) {
- memmove( edit->buffer + edit->cursor - 1,
- edit->buffer + edit->cursor, len + 1 - edit->cursor );
+ if (ch == 'h' - 'a' + 1) { // ctrl-h is backspace
+ if (edit->cursor > 0) {
+ memmove(edit->buffer + edit->cursor - 1, edit->buffer + edit->cursor, len + 1 - edit->cursor);
edit->cursor--;
- if ( edit->cursor < edit->scroll )
- {
+ if (edit->cursor < edit->scroll) {
edit->scroll--;
}
}
return;
}
- if ( ch == 'a' - 'a' + 1 ) { // ctrl-a is home
+ if (ch == 'a' - 'a' + 1) { // ctrl-a is home
edit->cursor = 0;
edit->scroll = 0;
return;
}
- if ( ch == 'e' - 'a' + 1 ) { // ctrl-e is end
+ if (ch == 'e' - 'a' + 1) { // ctrl-e is end
edit->cursor = len;
edit->scroll = edit->cursor - edit->widthInChars;
return;
@@ -625,33 +604,31 @@ void Field_CharEvent( field_t *edit, int ch ) {
//
// ignore any other non printable chars
//
- if ( ch < 32 ) {
+ if (ch < 32) {
return;
}
- if ( kg.key_overstrikeMode ) {
+ if (kg.key_overstrikeMode) {
// - 2 to leave room for the leading slash and trailing \0
- if ( edit->cursor == MAX_EDIT_LINE - 2 )
+ if (edit->cursor == MAX_EDIT_LINE - 2)
return;
edit->buffer[edit->cursor] = ch;
edit->cursor++;
- } else { // insert mode
+ } else { // insert mode
// - 2 to leave room for the leading slash and trailing \0
- if ( len == MAX_EDIT_LINE - 2 ) {
+ if (len == MAX_EDIT_LINE - 2) {
return; // all full
}
- memmove( edit->buffer + edit->cursor + 1,
- edit->buffer + edit->cursor, len + 1 - edit->cursor );
+ memmove(edit->buffer + edit->cursor + 1, edit->buffer + edit->cursor, len + 1 - edit->cursor);
edit->buffer[edit->cursor] = ch;
edit->cursor++;
}
- if ( edit->cursor >= edit->widthInChars )
- {
+ if (edit->cursor >= edit->widthInChars) {
edit->scroll++;
}
- if ( edit->cursor == len + 1) {
+ if (edit->cursor == len + 1) {
edit->buffer[edit->cursor] = 0;
}
}
@@ -663,33 +640,31 @@ Console_Key
Handles history and console scrollback
====================
*/
-void Console_Key (int key) {
+void Console_Key(int key) {
// ctrl-L clears screen
- if ( keynames[ key ].lower == 'l' && kg.keys[A_CTRL].down ) {
- Cbuf_AddText ("clear\n");
+ if (keynames[key].lower == 'l' && kg.keys[A_CTRL].down) {
+ Cbuf_AddText("clear\n");
return;
}
// enter finishes the line
- if ( key == A_ENTER || key == A_KP_ENTER ) {
+ if (key == A_ENTER || key == A_KP_ENTER) {
// legacy hack: strip any prepended slashes. they're not necessary anymore
- if ( g_consoleField.buffer[0] &&
- (g_consoleField.buffer[0] == '\\' || g_consoleField.buffer[0] == '/') ) {
- char temp[MAX_EDIT_LINE-1];
+ if (g_consoleField.buffer[0] && (g_consoleField.buffer[0] == '\\' || g_consoleField.buffer[0] == '/')) {
+ char temp[MAX_EDIT_LINE - 1];
- Q_strncpyz( temp, g_consoleField.buffer+1, sizeof( temp ) );
- Com_sprintf( g_consoleField.buffer, sizeof( g_consoleField.buffer ), "%s", temp );
+ Q_strncpyz(temp, g_consoleField.buffer + 1, sizeof(temp));
+ Com_sprintf(g_consoleField.buffer, sizeof(g_consoleField.buffer), "%s", temp);
g_consoleField.cursor--;
}
// print executed command
- Com_Printf( "%c%s\n", CONSOLE_PROMPT_CHAR, g_consoleField.buffer );
+ Com_Printf("%c%s\n", CONSOLE_PROMPT_CHAR, g_consoleField.buffer);
- Cbuf_AddText( g_consoleField.buffer ); // valid command
- Cbuf_AddText ("\n");
+ Cbuf_AddText(g_consoleField.buffer); // valid command
+ Cbuf_AddText("\n");
- if (!g_consoleField.buffer[0])
- {
+ if (!g_consoleField.buffer[0]) {
return; // empty lines just scroll the console without adding to history
}
@@ -698,14 +673,14 @@ void Console_Key (int key) {
nextHistoryLine++;
historyLine = nextHistoryLine;
- Field_Clear( &g_consoleField );
+ Field_Clear(&g_consoleField);
g_consoleField.widthInChars = g_console_field_width;
- //CL_SaveConsoleHistory();
+ // CL_SaveConsoleHistory();
- if ( cls.state == CA_DISCONNECTED )
- SCR_UpdateScreen (); // force an update, because the command may take some time
+ if (cls.state == CA_DISCONNECTED)
+ SCR_UpdateScreen(); // force an update, because the command may take some time
return;
}
@@ -713,30 +688,26 @@ void Console_Key (int key) {
// command completion
if (key == A_TAB) {
- Field_AutoComplete( &g_consoleField );
+ Field_AutoComplete(&g_consoleField);
return;
}
// history scrolling
- if ( key == A_CURSOR_UP || key == A_KP_8
- || (kg.keys[A_SHIFT].down && key == A_MWHEELUP)
- || (kg.keys[A_CTRL].down && keynames[key].lower == 'p') )
- {// scroll up: arrow-up, numpad-up, shift + mwheelup, ctrl + p
- if ( nextHistoryLine - historyLine < COMMAND_HISTORY && historyLine > 0 )
+ if (key == A_CURSOR_UP || key == A_KP_8 || (kg.keys[A_SHIFT].down && key == A_MWHEELUP) ||
+ (kg.keys[A_CTRL].down && keynames[key].lower == 'p')) { // scroll up: arrow-up, numpad-up, shift + mwheelup, ctrl + p
+ if (nextHistoryLine - historyLine < COMMAND_HISTORY && historyLine > 0)
historyLine--;
g_consoleField = historyEditLines[historyLine % COMMAND_HISTORY];
return;
}
- if ( key == A_CURSOR_DOWN || key == A_KP_2
- || (kg.keys[A_SHIFT].down && key == A_MWHEELDOWN)
- || (kg.keys[A_CTRL].down && keynames[key].lower == 'n') )
- {// scroll down: arrow-down, numpad-down, shift + mwheeldown, ctrl + n
+ if (key == A_CURSOR_DOWN || key == A_KP_2 || (kg.keys[A_SHIFT].down && key == A_MWHEELDOWN) ||
+ (kg.keys[A_CTRL].down && keynames[key].lower == 'n')) { // scroll down: arrow-down, numpad-down, shift + mwheeldown, ctrl + n
historyLine++;
if (historyLine >= nextHistoryLine) {
historyLine = nextHistoryLine;
- Field_Clear( &g_consoleField );
+ Field_Clear(&g_consoleField);
g_consoleField.widthInChars = g_console_field_width;
return;
}
@@ -745,53 +716,49 @@ void Console_Key (int key) {
}
// console scrolling (ctrl to scroll fast)
- if ( key == A_PAGE_UP || key == A_MWHEELUP ) {
+ if (key == A_PAGE_UP || key == A_MWHEELUP) {
int count = kg.keys[A_CTRL].down ? 5 : 1;
- for ( int i=0; i= MAX_KEYS )
+qboolean Key_IsDown(int keynum) {
+ if (keynum < 0 || keynum >= MAX_KEYS)
return qfalse;
return kg.keys[keynames[keynum].upper].down;
@@ -809,25 +776,25 @@ the K_* names are matched up.
to be configured even if they don't have defined names.
===================
*/
-int Key_StringToKeynum( char *str ) {
- if ( !VALIDSTRING( str ) )
+int Key_StringToKeynum(char *str) {
+ if (!VALIDSTRING(str))
return -1;
// If single char bind, presume ascii char bind
- if ( !str[1] )
+ if (!str[1])
return keynames[(unsigned char)str[0]].upper;
// scan for a text match
- for ( int i=0; i= 0 )
+ if (n >= 0)
return n;
}
@@ -835,33 +802,34 @@ int Key_StringToKeynum( char *str ) {
}
static char tinyString[16];
-static const char *Key_KeynumValid( int keynum ) {
- if ( keynum == -1 )
+static const char *Key_KeynumValid(int keynum) {
+ if (keynum == -1)
return "";
- if ( keynum < 0 || keynum >= MAX_KEYS )
+ if (keynum < 0 || keynum >= MAX_KEYS)
return "";
return NULL;
}
-static const char *Key_KeyToName( int keynum )
-{
- return keynames[keynum].name;
-}
+static const char *Key_KeyToName(int keynum) { return keynames[keynum].name; }
-static const char *Key_KeyToAscii( int keynum ) {
- if ( !keynames[keynum].lower )
+static const char *Key_KeyToAscii(int keynum) {
+ if (!keynames[keynum].lower)
return NULL;
- if ( keynum == A_SPACE ) tinyString[0] = (char)A_SHIFT_SPACE;
- else if ( keynum == A_ENTER ) tinyString[0] = (char)A_SHIFT_ENTER;
- else if ( keynum == A_KP_ENTER ) tinyString[0] = (char)A_SHIFT_KP_ENTER;
- else tinyString[0] = keynames[keynum].upper;
+ if (keynum == A_SPACE)
+ tinyString[0] = (char)A_SHIFT_SPACE;
+ else if (keynum == A_ENTER)
+ tinyString[0] = (char)A_SHIFT_ENTER;
+ else if (keynum == A_KP_ENTER)
+ tinyString[0] = (char)A_SHIFT_KP_ENTER;
+ else
+ tinyString[0] = keynames[keynum].upper;
tinyString[1] = '\0';
return tinyString;
}
-static const char *Key_KeyToHex( int keynum ) {
+static const char *Key_KeyToHex(int keynum) {
int i = keynum >> 4;
int j = keynum & 15;
@@ -875,20 +843,20 @@ static const char *Key_KeyToHex( int keynum ) {
}
// Returns the ascii code of the keynum
-const char *Key_KeynumToAscii( int keynum ) {
+const char *Key_KeynumToAscii(int keynum) {
const char *name = Key_KeynumValid(keynum);
// check for printable ascii
- if ( !name && keynum > 0 && keynum < 256 )
- name = Key_KeyToAscii( keynum );
+ if (!name && keynum > 0 && keynum < 256)
+ name = Key_KeyToAscii(keynum);
// Check for name (for JOYx and AUXx buttons)
- if ( !name )
- name = Key_KeyToName( keynum );
+ if (!name)
+ name = Key_KeyToName(keynum);
// Fallback to hex number
- if ( !name )
- name = Key_KeyToHex( keynum );
+ if (!name)
+ name = Key_KeyToHex(keynum);
return name;
}
@@ -902,22 +870,22 @@ given keynum.
===================
*/
// Returns a console/config file friendly name for the key
-const char *Key_KeynumToString( int keynum ) {
+const char *Key_KeynumToString(int keynum) {
const char *name;
- name = Key_KeynumValid( keynum );
+ name = Key_KeynumValid(keynum);
// Check for friendly name
- if ( !name )
- name = Key_KeyToName( keynum );
+ if (!name)
+ name = Key_KeyToName(keynum);
// check for printable ascii
- if ( !name && keynum > 0 && keynum < 256)
- name = Key_KeyToAscii( keynum );
+ if (!name && keynum > 0 && keynum < 256)
+ name = Key_KeyToAscii(keynum);
// Fallback to hex number
- if ( !name )
- name = Key_KeyToHex( keynum );
+ if (!name)
+ name = Key_KeyToHex(keynum);
return name;
}
@@ -927,19 +895,19 @@ const char *Key_KeynumToString( int keynum ) {
Key_SetBinding
===================
*/
-void Key_SetBinding( int keynum, const char *binding ) {
- if ( keynum < 0 || keynum >= MAX_KEYS )
+void Key_SetBinding(int keynum, const char *binding) {
+ if (keynum < 0 || keynum >= MAX_KEYS)
return;
// free old bindings
- if ( kg.keys[keynames[keynum].upper].binding ) {
- Z_Free( kg.keys[keynames[keynum].upper].binding );
+ if (kg.keys[keynames[keynum].upper].binding) {
+ Z_Free(kg.keys[keynames[keynum].upper].binding);
kg.keys[keynames[keynum].upper].binding = NULL;
}
// allocate memory for new binding
- if ( binding )
- kg.keys[keynames[keynum].upper].binding = CopyString( binding );
+ if (binding)
+ kg.keys[keynames[keynum].upper].binding = CopyString(binding);
// consider this like modifying an archived cvar, so the
// file write will be triggered at the next oportunity
@@ -951,8 +919,8 @@ void Key_SetBinding( int keynum, const char *binding ) {
Key_GetBinding
===================
*/
-const char *Key_GetBinding( int keynum ) {
- if ( keynum < 0 || keynum >= MAX_KEYS )
+const char *Key_GetBinding(int keynum) {
+ if (keynum < 0 || keynum >= MAX_KEYS)
return "";
return kg.keys[keynum].binding;
@@ -963,10 +931,10 @@ const char *Key_GetBinding( int keynum ) {
Key_GetKey
===================
*/
-int Key_GetKey( const char *binding ) {
- if ( binding ) {
- for ( int i=0; i : remove commands from a key\n" );
+void Key_Unbind_f(void) {
+ if (Cmd_Argc() != 2) {
+ Com_Printf("unbind : remove commands from a key\n");
return;
}
- int b = Key_StringToKeynum( Cmd_Argv( 1 ) );
- if ( b == -1 ) {
- Com_Printf( "\"%s\" isn't a valid key\n", Cmd_Argv( 1 ) );
+ int b = Key_StringToKeynum(Cmd_Argv(1));
+ if (b == -1) {
+ Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
return;
}
- Key_SetBinding( b, "" );
+ Key_SetBinding(b, "");
}
/*
@@ -999,10 +967,10 @@ void Key_Unbind_f( void ) {
Key_Unbindall_f
===================
*/
-void Key_Unbindall_f( void ) {
- for ( int i=0; i [command] : attach a command to a key\n" );
+ if (c < 2) {
+ Com_Printf("bind [command] : attach a command to a key\n");
return;
}
- int b = Key_StringToKeynum( Cmd_Argv( 1 ) );
- if ( b == -1 ) {
- Com_Printf( "\"%s\" isn't a valid key\n", Cmd_Argv( 1 ) );
+ int b = Key_StringToKeynum(Cmd_Argv(1));
+ if (b == -1) {
+ Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
return;
}
- if ( c == 2 ) {
- if ( kg.keys[b].binding && kg.keys[b].binding[0] )
- Com_Printf( S_COLOR_GREY "Bind " S_COLOR_WHITE "%s = " S_COLOR_GREY "\"" S_COLOR_WHITE "%s" S_COLOR_GREY "\"" S_COLOR_WHITE "\n", Key_KeynumToString( b ), kg.keys[b].binding );
+ if (c == 2) {
+ if (kg.keys[b].binding && kg.keys[b].binding[0])
+ Com_Printf(S_COLOR_GREY "Bind " S_COLOR_WHITE "%s = " S_COLOR_GREY "\"" S_COLOR_WHITE "%s" S_COLOR_GREY "\"" S_COLOR_WHITE "\n",
+ Key_KeynumToString(b), kg.keys[b].binding);
else
- Com_Printf( "\"%s\" is not bound\n", Key_KeynumToString( b ) );
+ Com_Printf("\"%s\" is not bound\n", Key_KeynumToString(b));
return;
}
- Key_SetBinding( b, Cmd_ArgsFrom( 2 ) );
+ Key_SetBinding(b, Cmd_ArgsFrom(2));
}
/*
@@ -1043,17 +1012,17 @@ Key_WriteBindings
Writes lines containing "bind key value"
============
*/
-void Key_WriteBindings( fileHandle_t f ) {
- FS_Printf( f, "unbindall\n" );
- for ( size_t i=0; i args )
+ char *p = Com_SkipTokens(args, 1, " ");
+ if (p > args)
Field_CompleteKeyname();
}
}
@@ -1102,22 +1072,21 @@ static void Key_CompleteUnbind( char *args, int argNum ) {
Key_CompleteBind
====================
*/
-static void Key_CompleteBind( char *args, int argNum ) {
+static void Key_CompleteBind(char *args, int argNum) {
char *p;
- if ( argNum == 2 ) {
+ if (argNum == 2) {
// Skip "bind "
- p = Com_SkipTokens( args, 1, " " );
+ p = Com_SkipTokens(args, 1, " ");
- if ( p > args )
+ if (p > args)
Field_CompleteKeyname();
- }
- else if ( argNum >= 3 ) {
+ } else if (argNum >= 3) {
// Skip "bind "
- p = Com_SkipTokens( args, 2, " " );
+ p = Com_SkipTokens(args, 2, " ");
- if ( p > args )
- Field_CompleteCommand( p, qtrue, qtrue );
+ if (p > args)
+ Field_CompleteCommand(p, qtrue, qtrue);
}
}
@@ -1126,14 +1095,14 @@ static void Key_CompleteBind( char *args, int argNum ) {
CL_InitKeyCommands
===================
*/
-void CL_InitKeyCommands( void ) {
+void CL_InitKeyCommands(void) {
// register our functions
- Cmd_AddCommand( "bind", Key_Bind_f );
- Cmd_SetCommandCompletionFunc( "bind", Key_CompleteBind );
- Cmd_AddCommand( "unbind", Key_Unbind_f );
- Cmd_SetCommandCompletionFunc( "unbind", Key_CompleteUnbind );
- Cmd_AddCommand( "unbindall", Key_Unbindall_f );
- Cmd_AddCommand( "bindlist", Key_Bindlist_f );
+ Cmd_AddCommand("bind", Key_Bind_f);
+ Cmd_SetCommandCompletionFunc("bind", Key_CompleteBind);
+ Cmd_AddCommand("unbind", Key_Unbind_f);
+ Cmd_SetCommandCompletionFunc("unbind", Key_CompleteUnbind);
+ Cmd_AddCommand("unbindall", Key_Unbindall_f);
+ Cmd_AddCommand("bindlist", Key_Bindlist_f);
}
/*
@@ -1143,13 +1112,13 @@ CL_BindUICommand
Returns qtrue if bind command should be executed while user interface is shown
===================
*/
-static qboolean CL_BindUICommand( const char *cmd ) {
- if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
+static qboolean CL_BindUICommand(const char *cmd) {
+ if (Key_GetCatcher() & KEYCATCH_CONSOLE)
return qfalse;
- if ( !Q_stricmp( cmd, "toggleconsole" ) )
+ if (!Q_stricmp(cmd, "toggleconsole"))
return qtrue;
- if ( !Q_stricmp( cmd, "togglemenu" ) )
+ if (!Q_stricmp(cmd, "togglemenu"))
return qtrue;
return qfalse;
@@ -1162,51 +1131,45 @@ CL_ParseBinding
Execute the commands in the bind string
===================
*/
-void CL_ParseBinding( int key, qboolean down, unsigned time )
-{
- char buf[ MAX_STRING_CHARS ], *p = buf, *end;
+void CL_ParseBinding(int key, qboolean down, unsigned time) {
+ char buf[MAX_STRING_CHARS], *p = buf, *end;
qboolean allCommands, allowUpCmds;
- if( cls.state == CA_DISCONNECTED && Key_GetCatcher( ) == 0 )
+ if (cls.state == CA_DISCONNECTED && Key_GetCatcher() == 0)
return;
- if( !kg.keys[keynames[key].upper].binding || !kg.keys[keynames[key].upper].binding[0] )
+ if (!kg.keys[keynames[key].upper].binding || !kg.keys[keynames[key].upper].binding[0])
return;
- Q_strncpyz( buf, kg.keys[keynames[key].upper].binding, sizeof( buf ) );
+ Q_strncpyz(buf, kg.keys[keynames[key].upper].binding, sizeof(buf));
// run all bind commands if console, ui, etc aren't reading keys
- allCommands = (qboolean)( Key_GetCatcher( ) == 0 );
+ allCommands = (qboolean)(Key_GetCatcher() == 0);
// allow button up commands if in game even if key catcher is set
- allowUpCmds = (qboolean)( cls.state != CA_DISCONNECTED );
+ allowUpCmds = (qboolean)(cls.state != CA_DISCONNECTED);
- while( 1 )
- {
- while( isspace( *p ) )
+ while (1) {
+ while (isspace(*p))
p++;
- end = strchr( p, ';' );
- if( end )
+ end = strchr(p, ';');
+ if (end)
*end = '\0';
- if( *p == '+' )
- {
+ if (*p == '+') {
// button commands add keynum and time as parameters
// so that multiple sources can be discriminated and
// subframe corrected
- if ( allCommands || ( allowUpCmds && !down ) ) {
+ if (allCommands || (allowUpCmds && !down)) {
char cmd[1024];
- Com_sprintf( cmd, sizeof( cmd ), "%c%s %d %d\n",
- ( down ) ? '+' : '-', p + 1, key, time );
- Cbuf_AddText( cmd );
+ Com_sprintf(cmd, sizeof(cmd), "%c%s %d %d\n", (down) ? '+' : '-', p + 1, key, time);
+ Cbuf_AddText(cmd);
}
- }
- else if( down )
- {
+ } else if (down) {
// normal commands only execute on key press
- if ( allCommands || CL_BindUICommand( p ) ) {
- Cbuf_AddText( p );
- Cbuf_AddText( "\n" );
+ if (allCommands || CL_BindUICommand(p)) {
+ Cbuf_AddText(p);
+ Cbuf_AddText("\n");
}
}
- if( !end )
+ if (!end)
break;
p = end + 1;
}
@@ -1219,68 +1182,65 @@ CL_KeyDownEvent
Called by CL_KeyEvent to handle a keypress
===================
*/
-void CL_KeyDownEvent( int key, unsigned time )
-{
+void CL_KeyDownEvent(int key, unsigned time) {
kg.keys[keynames[key].upper].down = qtrue;
kg.keys[keynames[key].upper].repeats++;
- if( kg.keys[keynames[key].upper].repeats == 1 ) {
+ if (kg.keys[keynames[key].upper].repeats == 1) {
kg.keyDownCount++;
kg.anykeydown = qtrue;
}
- if ( cl_allowAltEnter->integer && kg.keys[A_ALT].down && key == A_ENTER )
- {
- Cvar_SetValue( "r_fullscreen", !Cvar_VariableIntegerValue( "r_fullscreen" ) );
+ if (cl_allowAltEnter->integer && kg.keys[A_ALT].down && key == A_ENTER) {
+ Cvar_SetValue("r_fullscreen", !Cvar_VariableIntegerValue("r_fullscreen"));
return;
}
// console key is hardcoded, so the user can never unbind it
- if ( key == A_CONSOLE || (kg.keys[A_SHIFT].down && key == A_ESCAPE) ) {
+ if (key == A_CONSOLE || (kg.keys[A_SHIFT].down && key == A_ESCAPE)) {
Con_ToggleConsole_f();
- Key_ClearStates ();
+ Key_ClearStates();
return;
}
// keys can still be used for bound actions
- if ( ( cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic()) && !Key_GetCatcher() )
- {
+ if ((cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic()) && !Key_GetCatcher()) {
SCR_StopCinematic(qtrue);
return;
-// key = A_ESCAPE;
+ // key = A_ESCAPE;
}
// escape is always handled special
- if ( key == A_ESCAPE ) {
- if ( !kg.keys[A_SHIFT].down && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) {
- Con_ToggleConsole_f ();
- Key_ClearStates ();
+ if (key == A_ESCAPE) {
+ if (!kg.keys[A_SHIFT].down && (Key_GetCatcher() & KEYCATCH_CONSOLE)) {
+ Con_ToggleConsole_f();
+ Key_ClearStates();
return;
}
- if ( !( Key_GetCatcher( ) & KEYCATCH_UI ) ) {
- if ( cls.state == CA_ACTIVE )
- UI_SetActiveMenu( "ingame", NULL );
+ if (!(Key_GetCatcher() & KEYCATCH_UI)) {
+ if (cls.state == CA_ACTIVE)
+ UI_SetActiveMenu("ingame", NULL);
else {
CL_Disconnect_f();
- UI_SetActiveMenu( "mainMenu", NULL );
+ UI_SetActiveMenu("mainMenu", NULL);
}
return;
}
- _UI_KeyEvent( key, qtrue );
+ _UI_KeyEvent(key, qtrue);
return;
}
// send the bound action
- CL_ParseBinding( key, qtrue, time );
+ CL_ParseBinding(key, qtrue, time);
// distribute the key down event to the apropriate handler
- if ( Key_GetCatcher() & KEYCATCH_CONSOLE ) {
- Console_Key( key );
- } else if ( Key_GetCatcher() & KEYCATCH_UI ) {
- _UI_KeyEvent( key, qtrue );
- } else if ( cls.state == CA_DISCONNECTED ) {
- Console_Key( key );
+ if (Key_GetCatcher() & KEYCATCH_CONSOLE) {
+ Console_Key(key);
+ } else if (Key_GetCatcher() & KEYCATCH_UI) {
+ _UI_KeyEvent(key, qtrue);
+ } else if (cls.state == CA_DISCONNECTED) {
+ Console_Key(key);
}
}
@@ -1291,8 +1251,7 @@ CL_KeyUpEvent
Called by CL_KeyEvent to handle a keyrelease
===================
*/
-void CL_KeyUpEvent( int key, unsigned time )
-{
+void CL_KeyUpEvent(int key, unsigned time) {
kg.keys[keynames[key].upper].repeats = 0;
kg.keys[keynames[key].upper].down = qfalse;
kg.keyDownCount--;
@@ -1303,7 +1262,7 @@ void CL_KeyUpEvent( int key, unsigned time )
}
// don't process key-up events for the console key
- if ( key == A_CONSOLE || ( key == A_ESCAPE && kg.keys[A_SHIFT].down ) )
+ if (key == A_CONSOLE || (key == A_ESCAPE && kg.keys[A_SHIFT].down))
return;
//
@@ -1312,10 +1271,10 @@ void CL_KeyUpEvent( int key, unsigned time )
// console mode and menu mode, to keep the character from continuing
// an action started before a mode switch.
//
- CL_ParseBinding( key, qfalse, time );
+ CL_ParseBinding(key, qfalse, time);
- if ( Key_GetCatcher( ) & KEYCATCH_UI )
- _UI_KeyEvent( key, qfalse );
+ if (Key_GetCatcher() & KEYCATCH_UI)
+ _UI_KeyEvent(key, qfalse);
}
/*
@@ -1325,11 +1284,11 @@ CL_KeyEvent
Called by the system for both key up and key down events
===================
*/
-void CL_KeyEvent (int key, qboolean down, unsigned time) {
- if( down )
- CL_KeyDownEvent( key, time );
+void CL_KeyEvent(int key, qboolean down, unsigned time) {
+ if (down)
+ CL_KeyDownEvent(key, time);
else
- CL_KeyUpEvent( key, time );
+ CL_KeyUpEvent(key, time);
}
/*
@@ -1339,15 +1298,18 @@ CL_CharEvent
Normal keyboard characters, already shifted / capslocked / etc
===================
*/
-void CL_CharEvent( int key ) {
+void CL_CharEvent(int key) {
// delete is not a printable character and is otherwise handled by Field_KeyDownEvent
- if ( key == 127 )
+ if (key == 127)
return;
// distribute the key down event to the apropriate handler
- if ( Key_GetCatcher() & KEYCATCH_CONSOLE ) Field_CharEvent( &g_consoleField, key );
- else if ( Key_GetCatcher() & KEYCATCH_UI ) _UI_KeyEvent( key|K_CHAR_FLAG, qtrue );
- else if ( cls.state == CA_DISCONNECTED ) Field_CharEvent( &g_consoleField, key );
+ if (Key_GetCatcher() & KEYCATCH_CONSOLE)
+ Field_CharEvent(&g_consoleField, key);
+ else if (Key_GetCatcher() & KEYCATCH_UI)
+ _UI_KeyEvent(key | K_CHAR_FLAG, qtrue);
+ else if (cls.state == CA_DISCONNECTED)
+ Field_CharEvent(&g_consoleField, key);
}
/*
@@ -1355,13 +1317,13 @@ void CL_CharEvent( int key ) {
Key_ClearStates
===================
*/
-void Key_ClearStates( void ) {
+void Key_ClearStates(void) {
kg.anykeydown = qfalse;
kg.keyDownCount = 0;
- for ( int i=0; i.
#include "sys/sys_loadlib.h"
#include "qcommon/ojk_saved_game.h"
-#define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits
+#define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits
-cvar_t *cl_renderer;
+cvar_t *cl_renderer;
-cvar_t *cl_nodelta;
-cvar_t *cl_debugMove;
+cvar_t *cl_nodelta;
+cvar_t *cl_debugMove;
-cvar_t *cl_noprint;
+cvar_t *cl_noprint;
-cvar_t *cl_timeout;
-cvar_t *cl_packetdup;
-cvar_t *cl_timeNudge;
-cvar_t *cl_showTimeDelta;
-cvar_t *cl_newClock=0;
+cvar_t *cl_timeout;
+cvar_t *cl_packetdup;
+cvar_t *cl_timeNudge;
+cvar_t *cl_showTimeDelta;
+cvar_t *cl_newClock = 0;
-cvar_t *cl_shownet;
-cvar_t *cl_avidemo;
+cvar_t *cl_shownet;
+cvar_t *cl_avidemo;
-cvar_t *cl_pano;
-cvar_t *cl_panoNumShots;
-cvar_t *cl_skippingcin;
-cvar_t *cl_endcredits;
+cvar_t *cl_pano;
+cvar_t *cl_panoNumShots;
+cvar_t *cl_skippingcin;
+cvar_t *cl_endcredits;
-cvar_t *cl_freelook;
-cvar_t *cl_sensitivity;
+cvar_t *cl_freelook;
+cvar_t *cl_sensitivity;
-cvar_t *cl_mouseAccel;
-cvar_t *cl_showMouseRate;
-cvar_t *cl_framerate;
+cvar_t *cl_mouseAccel;
+cvar_t *cl_showMouseRate;
+cvar_t *cl_framerate;
-cvar_t *m_pitch;
-cvar_t *m_yaw;
-cvar_t *m_forward;
-cvar_t *m_side;
-cvar_t *m_filter;
+cvar_t *m_pitch;
+cvar_t *m_yaw;
+cvar_t *m_forward;
+cvar_t *m_side;
+cvar_t *m_filter;
-cvar_t *cl_activeAction;
+cvar_t *cl_activeAction;
-cvar_t *cl_allowAltEnter;
+cvar_t *cl_allowAltEnter;
-cvar_t *cl_inGameVideo;
+cvar_t *cl_inGameVideo;
-cvar_t *cl_consoleKeys;
-cvar_t *cl_consoleUseScanCode;
-cvar_t *cl_consoleShiftRequirement;
+cvar_t *cl_consoleKeys;
+cvar_t *cl_consoleUseScanCode;
+cvar_t *cl_consoleShiftRequirement;
-clientActive_t cl;
-clientConnection_t clc;
-clientStatic_t cls;
+clientActive_t cl;
+clientConnection_t clc;
+clientStatic_t cls;
// Structure containing functions exported from refresh DLL
-refexport_t re;
+refexport_t re;
static void *rendererLib = NULL;
-//RAZFIXME: BAD BAD, maybe? had to move it out of ghoul2_shared.h -> CGhoul2Info_v at the least..
-IGhoul2InfoArray &_TheGhoul2InfoArray( void ) {
- return re.TheGhoul2InfoArray();
-}
+// RAZFIXME: BAD BAD, maybe? had to move it out of ghoul2_shared.h -> CGhoul2Info_v at the least..
+IGhoul2InfoArray &_TheGhoul2InfoArray(void) { return re.TheGhoul2InfoArray(); }
-static void CL_ShutdownRef( qboolean restarting );
-void CL_InitRef( void );
-void CL_CheckForResend( void );
+static void CL_ShutdownRef(qboolean restarting);
+void CL_InitRef(void);
+void CL_CheckForResend(void);
/*
=======================================================================
@@ -113,20 +111,20 @@ The given command will be transmitted to the server, and is gauranteed to
not have future usercmd_t executed before it is executed
======================
*/
-void CL_AddReliableCommand( const char *cmd ) {
- int index;
+void CL_AddReliableCommand(const char *cmd) {
+ int index;
// if we would be losing an old command that hasn't been acknowledged,
// we must drop the connection
- if ( clc.reliableSequence - clc.reliableAcknowledge > MAX_RELIABLE_COMMANDS ) {
- Com_Error( ERR_DROP, "Client command overflow" );
+ if (clc.reliableSequence - clc.reliableAcknowledge > MAX_RELIABLE_COMMANDS) {
+ Com_Error(ERR_DROP, "Client command overflow");
}
clc.reliableSequence++;
- index = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 );
- if ( clc.reliableCommands[ index ] ) {
- Z_Free( clc.reliableCommands[ index ] );
+ index = clc.reliableSequence & (MAX_RELIABLE_COMMANDS - 1);
+ if (clc.reliableCommands[index]) {
+ Z_Free(clc.reliableCommands[index]);
}
- clc.reliableCommands[ index ] = CopyString( cmd );
+ clc.reliableCommands[index] = CopyString(cmd);
}
//======================================================================
@@ -140,7 +138,7 @@ ways a client gets into a game
Also called by Com_Error
=================
*/
-void CL_FlushMemory( void ) {
+void CL_FlushMemory(void) {
// clear sounds (moved higher up within this func to avoid the odd sound stutter)
S_DisableSounds();
@@ -150,11 +148,11 @@ void CL_FlushMemory( void ) {
CL_ShutdownUI();
- if ( re.Shutdown ) {
- re.Shutdown( qfalse, qfalse ); // don't destroy window or context
+ if (re.Shutdown) {
+ re.Shutdown(qfalse, qfalse); // don't destroy window or context
}
- //rwwFIXMEFIXME: The game server appears to continue running, so clearing common bsp data causes crashing and other bad things
+ // rwwFIXMEFIXME: The game server appears to continue running, so clearing common bsp data causes crashing and other bad things
/*
CM_ClearMap();
*/
@@ -172,32 +170,32 @@ screen to let the user know about it, then dump all client
memory on the hunk from cgame, ui, and renderer
=====================
*/
-void CL_MapLoading( void ) {
- if ( !com_cl_running->integer ) {
+void CL_MapLoading(void) {
+ if (!com_cl_running->integer) {
return;
}
Con_Close();
- Key_SetCatcher( 0 );
+ Key_SetCatcher(0);
// if we are already connected to the local host, stay connected
- if ( cls.state >= CA_CONNECTED && !Q_stricmp( cls.servername, "localhost" ) ) {
- cls.state = CA_CONNECTED; // so the connect screen is drawn
- memset( cls.updateInfoString, 0, sizeof( cls.updateInfoString ) );
-// memset( clc.serverMessage, 0, sizeof( clc.serverMessage ) );
- memset( &cl.gameState, 0, sizeof( cl.gameState ) );
+ if (cls.state >= CA_CONNECTED && !Q_stricmp(cls.servername, "localhost")) {
+ cls.state = CA_CONNECTED; // so the connect screen is drawn
+ memset(cls.updateInfoString, 0, sizeof(cls.updateInfoString));
+ // memset( clc.serverMessage, 0, sizeof( clc.serverMessage ) );
+ memset(&cl.gameState, 0, sizeof(cl.gameState));
clc.lastPacketSentTime = -9999;
SCR_UpdateScreen();
} else {
// clear nextmap so the cinematic shutdown doesn't execute it
- Cvar_Set( "nextmap", "" );
+ Cvar_Set("nextmap", "");
CL_Disconnect();
- Q_strncpyz( cls.servername, "localhost", sizeof(cls.servername) );
- cls.state = CA_CHALLENGING; // so the connect screen is drawn
- Key_SetCatcher( 0 );
+ Q_strncpyz(cls.servername, "localhost", sizeof(cls.servername));
+ cls.state = CA_CHALLENGING; // so the connect screen is drawn
+ Key_SetCatcher(0);
SCR_UpdateScreen();
clc.connectTime = -RETRANSMIT_TIMEOUT;
- NET_StringToAdr( cls.servername, &clc.serverAddress);
+ NET_StringToAdr(cls.servername, &clc.serverAddress);
// we don't need a challenge on the localhost
CL_CheckForResend();
@@ -213,12 +211,12 @@ CL_ClearState
Called before parsing a gamestate
=====================
*/
-void CL_ClearState (void) {
+void CL_ClearState(void) {
CL_ShutdownCGame();
S_StopAllSounds();
- memset( &cl, 0, sizeof( cl ) );
+ memset(&cl, 0, sizeof(cl));
}
/*
@@ -228,18 +226,16 @@ CL_FreeReliableCommands
Wipes all reliableCommands strings from clc
=====================
*/
-void CL_FreeReliableCommands( void )
-{
+void CL_FreeReliableCommands(void) {
// wipe the client connection
- for ( int i = 0 ; i < MAX_RELIABLE_COMMANDS ; i++ ) {
- if ( clc.reliableCommands[i] ) {
- Z_Free( clc.reliableCommands[i] );
- clc.reliableCommands[i] = NULL;
+ for (int i = 0; i < MAX_RELIABLE_COMMANDS; i++) {
+ if (clc.reliableCommands[i]) {
+ Z_Free(clc.reliableCommands[i]);
+ clc.reliableCommands[i] = NULL;
}
}
}
-
/*
=====================
CL_Disconnect
@@ -250,43 +246,42 @@ Sends a disconnect message to the server
This is also called on Com_Error and Com_Quit, so it shouldn't cause any errors
=====================
*/
-void CL_Disconnect( void ) {
- if ( !com_cl_running || !com_cl_running->integer ) {
+void CL_Disconnect(void) {
+ if (!com_cl_running || !com_cl_running->integer) {
return;
}
if (cls.uiStarted)
- UI_SetActiveMenu( NULL,NULL );
+ UI_SetActiveMenu(NULL, NULL);
- SCR_StopCinematic ();
+ SCR_StopCinematic();
S_ClearSoundBuffer();
// send a disconnect message to the server
// send it a few times in case one is dropped
- if ( cls.state >= CA_CONNECTED ) {
- CL_AddReliableCommand( "disconnect" );
+ if (cls.state >= CA_CONNECTED) {
+ CL_AddReliableCommand("disconnect");
CL_WritePacket();
CL_WritePacket();
CL_WritePacket();
}
- CL_ClearState ();
+ CL_ClearState();
CL_FreeReliableCommands();
extern void CL_FreeServerCommands(void);
CL_FreeServerCommands();
- memset( &clc, 0, sizeof( clc ) );
+ memset(&clc, 0, sizeof(clc));
cls.state = CA_DISCONNECTED;
// allow cheats locally
- Cvar_Set( "timescale", "1" );//jic we were skipping
- Cvar_Set( "skippingCinematic", "0" );//jic we were skipping
+ Cvar_Set("timescale", "1"); // jic we were skipping
+ Cvar_Set("skippingCinematic", "0"); // jic we were skipping
}
-
/*
===================
CL_ForwardCommandToServer
@@ -296,32 +291,31 @@ things like godmode, noclip, etc, are commands directed to the server,
so when they are typed in at the console, they will need to be forwarded.
===================
*/
-void CL_ForwardCommandToServer( void ) {
- const char *cmd;
- char string[MAX_STRING_CHARS];
+void CL_ForwardCommandToServer(void) {
+ const char *cmd;
+ char string[MAX_STRING_CHARS];
cmd = Cmd_Argv(0);
// ignore key up commands
- if ( cmd[0] == '-' ) {
+ if (cmd[0] == '-') {
return;
}
- if ( cls.state != CA_ACTIVE || cmd[0] == '+' ) {
- Com_Printf ("Unknown command \"%s\"\n", cmd);
+ if (cls.state != CA_ACTIVE || cmd[0] == '+') {
+ Com_Printf("Unknown command \"%s\"\n", cmd);
return;
}
- if ( Cmd_Argc() > 1 ) {
- Com_sprintf( string, sizeof(string), "%s %s", cmd, Cmd_Args() );
+ if (Cmd_Argc() > 1) {
+ Com_sprintf(string, sizeof(string), "%s %s", cmd, Cmd_Args());
} else {
- Q_strncpyz( string, cmd, sizeof(string) );
+ Q_strncpyz(string, cmd, sizeof(string));
}
- CL_AddReliableCommand( string );
+ CL_AddReliableCommand(string);
}
-
/*
======================================================================
@@ -335,15 +329,15 @@ CONSOLE COMMANDS
CL_ForwardToServer_f
==================
*/
-void CL_ForwardToServer_f( void ) {
- if ( cls.state != CA_ACTIVE ) {
- Com_Printf ("Not connected to a server.\n");
+void CL_ForwardToServer_f(void) {
+ if (cls.state != CA_ACTIVE) {
+ Com_Printf("Not connected to a server.\n");
return;
}
// don't forward the first argument
- if ( Cmd_Argc() > 1 ) {
- CL_AddReliableCommand( Cmd_Args() );
+ if (Cmd_Argc() > 1) {
+ CL_AddReliableCommand(Cmd_Args());
}
}
@@ -352,20 +346,19 @@ void CL_ForwardToServer_f( void ) {
CL_Disconnect_f
==================
*/
-void CL_Disconnect_f( void ) {
+void CL_Disconnect_f(void) {
SCR_StopCinematic();
- //FIXME:
- // TA codebase added additional CA_CINEMATIC check below, presumably so they could play cinematics
+ // FIXME:
+ // TA codebase added additional CA_CINEMATIC check below, presumably so they could play cinematics
// in the menus when disconnected, although having the SCR_StopCinematic() call above is weird.
- // Either there's a bug, or the new version of that function conditionally-doesn't stop cinematics...
+ // Either there's a bug, or the new version of that function conditionally-doesn't stop cinematics...
//
- if ( cls.state != CA_DISCONNECTED && cls.state != CA_CINEMATIC ) {
- Com_Error (ERR_DISCONNECT, "Disconnected from server");
+ if (cls.state != CA_DISCONNECTED && cls.state != CA_CINEMATIC) {
+ Com_Error(ERR_DISCONNECT, "Disconnected from server");
}
}
-
/*
=================
CL_Vid_Restart_f
@@ -373,15 +366,15 @@ CL_Vid_Restart_f
Restart the video subsystem
=================
*/
-void CL_Vid_Restart_f( void ) {
- S_StopAllSounds(); // don't let them loop during the restart
- S_BeginRegistration(); // all sound handles are now invalid
+void CL_Vid_Restart_f(void) {
+ S_StopAllSounds(); // don't let them loop during the restart
+ S_BeginRegistration(); // all sound handles are now invalid
CL_ShutdownRef(qtrue);
CL_ShutdownUI();
CL_ShutdownCGame();
- //rww - sof2mp does this here, but it seems to cause problems in this codebase.
-// CM_ClearMap();
+ // rww - sof2mp does this here, but it seems to cause problems in this codebase.
+ // CM_ClearMap();
cls.rendererStarted = qfalse;
cls.uiStarted = qfalse;
@@ -393,7 +386,7 @@ void CL_Vid_Restart_f( void ) {
CL_StartHunkUsers();
// unpause so the cgame definately gets a snapshot and renders a frame
- Cvar_Set( "cl_paused", "0" );
+ Cvar_Set("cl_paused", "0");
}
/*
@@ -405,15 +398,15 @@ The cgame and game must also be forced to restart because
handles will be invalid
=================
*/
-void CL_Snd_Restart_f( void ) {
+void CL_Snd_Restart_f(void) {
S_Shutdown();
S_Init();
-// CL_Vid_Restart_f();
+ // CL_Vid_Restart_f();
- extern qboolean s_soundMuted;
- s_soundMuted = qfalse; // we can play again
+ extern qboolean s_soundMuted;
+ s_soundMuted = qfalse; // we can play again
S_RestartMusic();
@@ -428,21 +421,21 @@ void CL_Snd_Restart_f( void ) {
CL_Configstrings_f
==================
*/
-void CL_Configstrings_f( void ) {
- int i;
- int ofs;
+void CL_Configstrings_f(void) {
+ int i;
+ int ofs;
- if ( cls.state != CA_ACTIVE ) {
- Com_Printf( "Not connected to a server.\n");
+ if (cls.state != CA_ACTIVE) {
+ Com_Printf("Not connected to a server.\n");
return;
}
- for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
- ofs = cl.gameState.stringOffsets[ i ];
- if ( !ofs ) {
+ for (i = 0; i < MAX_CONFIGSTRINGS; i++) {
+ ofs = cl.gameState.stringOffsets[i];
+ if (!ofs) {
continue;
}
- Com_Printf( "%4i: %s\n", i, cl.gameState.stringData + ofs );
+ Com_Printf("%4i: %s\n", i, cl.gameState.stringData + ofs);
}
}
@@ -451,19 +444,18 @@ void CL_Configstrings_f( void ) {
CL_Clientinfo_f
==============
*/
-void CL_Clientinfo_f( void ) {
- Com_Printf( "--------- Client Information ---------\n" );
- Com_Printf( "state: %i\n", cls.state );
- Com_Printf( "Server: %s\n", cls.servername );
- Com_Printf ("User info settings:\n");
- Info_Print( Cvar_InfoString( CVAR_USERINFO ) );
- Com_Printf( "--------------------------------------\n" );
+void CL_Clientinfo_f(void) {
+ Com_Printf("--------- Client Information ---------\n");
+ Com_Printf("state: %i\n", cls.state);
+ Com_Printf("Server: %s\n", cls.servername);
+ Com_Printf("User info settings:\n");
+ Info_Print(Cvar_InfoString(CVAR_USERINFO));
+ Com_Printf("--------------------------------------\n");
}
-
//====================================================================
-void UI_UpdateConnectionString( const char *string );
+void UI_UpdateConnectionString(const char *string);
/*
=================
@@ -472,58 +464,56 @@ CL_CheckForResend
Resend a connect message if the last one has timed out
=================
*/
-void CL_CheckForResend( void ) {
- int port;
- char info[MAX_INFO_STRING];
+void CL_CheckForResend(void) {
+ int port;
+ char info[MAX_INFO_STRING];
-// if ( cls.state == CA_CINEMATIC )
- if ( cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic())
- {
+ // if ( cls.state == CA_CINEMATIC )
+ if (cls.state == CA_CINEMATIC || CL_IsRunningInGameCinematic()) {
return;
}
// resend if we haven't gotten a reply yet
- if ( cls.state < CA_CONNECTING || cls.state > CA_CHALLENGING ) {
+ if (cls.state < CA_CONNECTING || cls.state > CA_CHALLENGING) {
return;
}
- if ( cls.realtime - clc.connectTime < RETRANSMIT_TIMEOUT ) {
+ if (cls.realtime - clc.connectTime < RETRANSMIT_TIMEOUT) {
return;
}
- clc.connectTime = cls.realtime; // for retransmit requests
+ clc.connectTime = cls.realtime; // for retransmit requests
clc.connectPacketCount++;
// requesting a challenge
- switch ( cls.state ) {
+ switch (cls.state) {
case CA_CONNECTING:
- UI_UpdateConnectionString( va("(%i)", clc.connectPacketCount ) );
+ UI_UpdateConnectionString(va("(%i)", clc.connectPacketCount));
NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "getchallenge");
break;
case CA_CHALLENGING:
- // sending back the challenge
+ // sending back the challenge
port = Cvar_VariableIntegerValue("net_qport");
- UI_UpdateConnectionString( va("(%i)", clc.connectPacketCount ) );
+ UI_UpdateConnectionString(va("(%i)", clc.connectPacketCount));
- Q_strncpyz( info, Cvar_InfoString( CVAR_USERINFO ), sizeof( info ) );
- Info_SetValueForKey( info, "protocol", va("%i", PROTOCOL_VERSION ) );
- Info_SetValueForKey( info, "qport", va("%i", port ) );
- Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) );
- NET_OutOfBandPrint( NS_CLIENT, clc.serverAddress, "connect \"%s\"", info );
+ Q_strncpyz(info, Cvar_InfoString(CVAR_USERINFO), sizeof(info));
+ Info_SetValueForKey(info, "protocol", va("%i", PROTOCOL_VERSION));
+ Info_SetValueForKey(info, "qport", va("%i", port));
+ Info_SetValueForKey(info, "challenge", va("%i", clc.challenge));
+ NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "connect \"%s\"", info);
// the most current userinfo has been sent, so watch for any
// newer changes to userinfo variables
cvar_modifiedFlags &= ~CVAR_USERINFO;
break;
default:
- Com_Error( ERR_FATAL, "CL_CheckForResend: bad cls.state" );
+ Com_Error(ERR_FATAL, "CL_CheckForResend: bad cls.state");
}
}
-
/*
===================
CL_DisconnectPacket
@@ -534,28 +524,27 @@ to the server, the server will send out of band disconnect packets
to the client so it doesn't have to wait for the full timeout period.
===================
*/
-void CL_DisconnectPacket( netadr_t from ) {
- if ( cls.state != CA_ACTIVE ) {
+void CL_DisconnectPacket(netadr_t from) {
+ if (cls.state != CA_ACTIVE) {
return;
}
// if not from our server, ignore it
- if ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) {
+ if (!NET_CompareAdr(from, clc.netchan.remoteAddress)) {
return;
}
// if we have received packets within three seconds, ignore it
// (it might be a malicious spoof)
- if ( cls.realtime - clc.lastPacketTime < 3000 ) {
+ if (cls.realtime - clc.lastPacketTime < 3000) {
return;
}
// drop the connection (FIXME: connection dropped dialog)
- Com_Printf( "Server disconnected for unknown reason\n" );
+ Com_Printf("Server disconnected for unknown reason\n");
CL_Disconnect();
}
-
/*
=================
CL_ConnectionlessPacket
@@ -563,25 +552,25 @@ CL_ConnectionlessPacket
Responses to broadcasts, etc
=================
*/
-void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
- char *s;
- const char *c;
+void CL_ConnectionlessPacket(netadr_t from, msg_t *msg) {
+ char *s;
+ const char *c;
- MSG_BeginReading( msg );
- MSG_ReadLong( msg ); // skip the -1
+ MSG_BeginReading(msg);
+ MSG_ReadLong(msg); // skip the -1
- s = MSG_ReadStringLine( msg );
+ s = MSG_ReadStringLine(msg);
- Cmd_TokenizeString( s );
+ Cmd_TokenizeString(s);
c = Cmd_Argv(0);
- Com_DPrintf ("CL packet %s: %s\n", NET_AdrToString(from), c);
+ Com_DPrintf("CL packet %s: %s\n", NET_AdrToString(from), c);
// challenge from the server we are connecting to
- if ( !strcmp(c, "challengeResponse") ) {
- if ( cls.state != CA_CONNECTING ) {
- Com_Printf( "Unwanted challenge response received. Ignored.\n" );
+ if (!strcmp(c, "challengeResponse")) {
+ if (cls.state != CA_CONNECTING) {
+ Com_Printf("Unwanted challenge response received. Ignored.\n");
} else {
// start sending challenge repsonse instead of challenge request packets
clc.challenge = atoi(Cmd_Argv(1));
@@ -597,53 +586,50 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
}
// server connection
- if ( !strcmp(c, "connectResponse") ) {
- if ( cls.state >= CA_CONNECTED ) {
- Com_Printf ("Dup connect received. Ignored.\n");
+ if (!strcmp(c, "connectResponse")) {
+ if (cls.state >= CA_CONNECTED) {
+ Com_Printf("Dup connect received. Ignored.\n");
return;
}
- if ( cls.state != CA_CHALLENGING ) {
- Com_Printf ("connectResponse packet while not connecting. Ignored.\n");
+ if (cls.state != CA_CHALLENGING) {
+ Com_Printf("connectResponse packet while not connecting. Ignored.\n");
return;
}
- if ( !NET_CompareBaseAdr( from, clc.serverAddress ) ) {
- Com_Printf( "connectResponse from a different address. Ignored.\n" );
- Com_Printf( "%s should have been %s\n", NET_AdrToString( from ),
- NET_AdrToString( clc.serverAddress ) );
+ if (!NET_CompareBaseAdr(from, clc.serverAddress)) {
+ Com_Printf("connectResponse from a different address. Ignored.\n");
+ Com_Printf("%s should have been %s\n", NET_AdrToString(from), NET_AdrToString(clc.serverAddress));
return;
}
- Netchan_Setup (NS_CLIENT, &clc.netchan, from, Cvar_VariableIntegerValue( "net_qport" ) );
+ Netchan_Setup(NS_CLIENT, &clc.netchan, from, Cvar_VariableIntegerValue("net_qport"));
cls.state = CA_CONNECTED;
- clc.lastPacketSentTime = -9999; // send first packet immediately
+ clc.lastPacketSentTime = -9999; // send first packet immediately
return;
}
// a disconnect message from the server, which will happen if the server
// dropped the connection but it is still getting packets from us
if (!strcmp(c, "disconnect")) {
- CL_DisconnectPacket( from );
+ CL_DisconnectPacket(from);
return;
}
// echo request from server
- if ( !strcmp(c, "echo") ) {
- NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) );
+ if (!strcmp(c, "echo")) {
+ NET_OutOfBandPrint(NS_CLIENT, from, "%s", Cmd_Argv(1));
return;
}
// print request from server
- if ( !strcmp(c, "print") ) {
- s = MSG_ReadString( msg );
- UI_UpdateConnectionMessageString( s );
- Com_Printf( "%s", s );
+ if (!strcmp(c, "print")) {
+ s = MSG_ReadString(msg);
+ UI_UpdateConnectionMessageString(s);
+ Com_Printf("%s", s);
return;
}
-
- Com_DPrintf ("Unknown connectionless packet command.\n");
+ Com_DPrintf("Unknown connectionless packet command.\n");
}
-
/*
=================
CL_PacketEvent
@@ -651,39 +637,38 @@ CL_PacketEvent
A packet has arrived from the main event loop
=================
*/
-void CL_PacketEvent( netadr_t from, msg_t *msg ) {
+void CL_PacketEvent(netadr_t from, msg_t *msg) {
clc.lastPacketTime = cls.realtime;
- if ( msg->cursize >= 4 && *(int *)msg->data == -1 ) {
- CL_ConnectionlessPacket( from, msg );
+ if (msg->cursize >= 4 && *(int *)msg->data == -1) {
+ CL_ConnectionlessPacket(from, msg);
return;
}
- if ( cls.state < CA_CONNECTED ) {
- return; // can't be a valid sequenced packet
+ if (cls.state < CA_CONNECTED) {
+ return; // can't be a valid sequenced packet
}
- if ( msg->cursize < 8 ) {
- Com_Printf ("%s: Runt packet\n",NET_AdrToString( from ));
+ if (msg->cursize < 8) {
+ Com_Printf("%s: Runt packet\n", NET_AdrToString(from));
return;
}
//
// packet from server
//
- if ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) {
- Com_DPrintf ("%s:sequenced packet without connection\n"
- ,NET_AdrToString( from ) );
+ if (!NET_CompareAdr(from, clc.netchan.remoteAddress)) {
+ Com_DPrintf("%s:sequenced packet without connection\n", NET_AdrToString(from));
// FIXME: send a client disconnect?
return;
}
- if (!Netchan_Process( &clc.netchan, msg) ) {
- return; // out of order, duplicated, etc
+ if (!Netchan_Process(&clc.netchan, msg)) {
+ return; // out of order, duplicated, etc
}
clc.lastPacketTime = cls.realtime;
- CL_ParseServerMessage( msg );
+ CL_ParseServerMessage(msg);
}
/*
@@ -692,17 +677,17 @@ CL_CheckTimeout
==================
*/
-void CL_CheckTimeout( void ) {
+void CL_CheckTimeout(void) {
//
// check timeout
//
- if ( ( !CL_CheckPaused() || !sv_paused->integer )
-// && cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC
- && cls.state >= CA_CONNECTED && (cls.state != CA_CINEMATIC && !CL_IsRunningInGameCinematic())
- && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) {
- if (++cl.timeoutcount > 5) { // timeoutcount saves debugger
- Com_Printf ("\nServer connection timed out.\n");
- CL_Disconnect ();
+ if ((!CL_CheckPaused() || !sv_paused->integer)
+ // && cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC
+ && cls.state >= CA_CONNECTED && (cls.state != CA_CINEMATIC && !CL_IsRunningInGameCinematic()) &&
+ cls.realtime - clc.lastPacketTime > cl_timeout->value * 1000) {
+ if (++cl.timeoutcount > 5) { // timeoutcount saves debugger
+ Com_Printf("\nServer connection timed out.\n");
+ CL_Disconnect();
return;
}
} else {
@@ -716,12 +701,11 @@ CL_CheckPaused
Check whether client has been paused.
==================
*/
-qboolean CL_CheckPaused(void)
-{
+qboolean CL_CheckPaused(void) {
// if cl_paused->modified is set, the cvar has only been changed in
// this frame. Keep paused in this frame to ensure the server doesn't
// lag behind.
- if(cl_paused->integer || cl_paused->modified)
+ if (cl_paused->integer || cl_paused->modified)
return qtrue;
return qfalse;
@@ -735,59 +719,55 @@ CL_CheckUserinfo
==================
*/
-void CL_CheckUserinfo( void ) {
- if ( cls.state < CA_CHALLENGING ) {
+void CL_CheckUserinfo(void) {
+ if (cls.state < CA_CHALLENGING) {
return;
}
// don't overflow the reliable command buffer when paused
- if ( CL_CheckPaused() ) {
+ if (CL_CheckPaused()) {
return;
}
// send a reliable userinfo update if needed
- if ( cvar_modifiedFlags & CVAR_USERINFO ) {
+ if (cvar_modifiedFlags & CVAR_USERINFO) {
cvar_modifiedFlags &= ~CVAR_USERINFO;
- CL_AddReliableCommand( va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ) );
+ CL_AddReliableCommand(va("userinfo \"%s\"", Cvar_InfoString(CVAR_USERINFO)));
}
-
}
-
/*
==================
CL_Frame
==================
*/
-extern cvar_t *cl_newClock;
+extern cvar_t *cl_newClock;
static unsigned int frameCount;
-float avgFrametime=0.0;
-void CL_Frame ( int msec,float fractionMsec ) {
+float avgFrametime = 0.0;
+void CL_Frame(int msec, float fractionMsec) {
- if ( !com_cl_running->integer ) {
+ if (!com_cl_running->integer) {
return;
}
// load the ref / cgame if needed
CL_StartHunkUsers();
- if ( cls.state == CA_DISCONNECTED && !( Key_GetCatcher( ) & KEYCATCH_UI )
- && !com_sv_running->integer ) {
+ if (cls.state == CA_DISCONNECTED && !(Key_GetCatcher() & KEYCATCH_UI) && !com_sv_running->integer) {
// if disconnected, bring up the menu
- if (!CL_CheckPendingCinematic()) // this avoid having the menu flash for one frame before pending cinematics
+ if (!CL_CheckPendingCinematic()) // this avoid having the menu flash for one frame before pending cinematics
{
- UI_SetActiveMenu( "mainMenu",NULL );
+ UI_SetActiveMenu("mainMenu", NULL);
}
}
-
// if recording an avi, lock to a fixed fps
- if ( cl_avidemo->integer ) {
+ if (cl_avidemo->integer) {
// save the current screen
- if ( cls.state == CA_ACTIVE ) {
+ if (cls.state == CA_ACTIVE) {
if (cl_avidemo->integer > 0) {
- Cbuf_ExecuteText( EXEC_NOW, "screenshot silent\n" );
+ Cbuf_ExecuteText(EXEC_NOW, "screenshot silent\n");
} else {
- Cbuf_ExecuteText( EXEC_NOW, "screenshot_tga silent\n" );
+ Cbuf_ExecuteText(EXEC_NOW, "screenshot_tga silent\n");
}
}
// fixed time for next frame
@@ -803,32 +783,28 @@ void CL_Frame ( int msec,float fractionMsec ) {
// decide the simulation time
cls.frametime = msec;
- if(cl_framerate->integer)
- {
- avgFrametime+=msec;
+ if (cl_framerate->integer) {
+ avgFrametime += msec;
char mess[256];
- if(!(frameCount&0x1f))
- {
- sprintf(mess,"Frame rate=%f\n\n",1000.0f*(1.0/(avgFrametime/32.0f)));
- // OutputDebugString(mess);
+ if (!(frameCount & 0x1f)) {
+ sprintf(mess, "Frame rate=%f\n\n", 1000.0f * (1.0 / (avgFrametime / 32.0f)));
+ // OutputDebugString(mess);
Com_Printf(mess);
- avgFrametime=0.0f;
+ avgFrametime = 0.0f;
}
frameCount++;
}
- cls.frametimeFraction=fractionMsec;
+ cls.frametimeFraction = fractionMsec;
cls.realtime += msec;
- cls.realtimeFraction+=fractionMsec;
- if (cls.realtimeFraction>=1.0f)
- {
- if (cl_newClock&&cl_newClock->integer)
- {
+ cls.realtimeFraction += fractionMsec;
+ if (cls.realtimeFraction >= 1.0f) {
+ if (cl_newClock && cl_newClock->integer) {
cls.realtime++;
}
- cls.realtimeFraction-=1.0f;
+ cls.realtimeFraction -= 1.0f;
}
- if ( cl_timegraph->integer ) {
- SCR_DebugGraph ( cls.realFrametime * 0.25, 0 );
+ if (cl_timegraph->integer) {
+ SCR_DebugGraph(cls.realFrametime * 0.25, 0);
}
// see if we need to update any userinfo
@@ -847,26 +823,26 @@ void CL_Frame ( int msec,float fractionMsec ) {
// decide on the serverTime to render
CL_SetCGameTime();
- if (cl_pano->integer && cls.state == CA_ACTIVE) { //grab some panoramic shots
+ if (cl_pano->integer && cls.state == CA_ACTIVE) { // grab some panoramic shots
int i = 1;
int pref = cl_pano->integer;
int oldnoprint = cl_noprint->integer;
Con_Close();
- cl_noprint->integer = 1; //hide the screen shot msgs
+ cl_noprint->integer = 1; // hide the screen shot msgs
for (; i <= cl_panoNumShots->integer; i++) {
- Cvar_SetValue( "pano", i );
- SCR_UpdateScreen();// update the screen
- Cbuf_ExecuteText( EXEC_NOW, va("screenshot %dpano%02d\n", pref, i) ); //grab this screen
+ Cvar_SetValue("pano", i);
+ SCR_UpdateScreen(); // update the screen
+ Cbuf_ExecuteText(EXEC_NOW, va("screenshot %dpano%02d\n", pref, i)); // grab this screen
}
- Cvar_SetValue( "pano", 0 ); //done
+ Cvar_SetValue("pano", 0); // done
cl_noprint->integer = oldnoprint;
}
- if (cl_skippingcin->integer && !cl_endcredits->integer && !com_developer->integer ) {
- if (cl_skippingcin->modified){
- S_StopSounds(); //kill em all but music
- cl_skippingcin->modified=qfalse;
- Com_Printf (S_COLOR_YELLOW "%s", SE_GetString("CON_TEXT_SKIPPING"));
+ if (cl_skippingcin->integer && !cl_endcredits->integer && !com_developer->integer) {
+ if (cl_skippingcin->modified) {
+ S_StopSounds(); // kill em all but music
+ cl_skippingcin->modified = qfalse;
+ Com_Printf(S_COLOR_YELLOW "%s", SE_GetString("CON_TEXT_SKIPPING"));
SCR_UpdateScreen();
}
} else {
@@ -891,15 +867,15 @@ void CL_Frame ( int msec,float fractionMsec ) {
CL_ShutdownRef
============
*/
-static void CL_ShutdownRef( qboolean restarting ) {
- if ( re.Shutdown ) {
- re.Shutdown( qtrue, restarting );
+static void CL_ShutdownRef(qboolean restarting) {
+ if (re.Shutdown) {
+ re.Shutdown(qtrue, restarting);
}
- memset( &re, 0, sizeof( re ) );
+ memset(&re, 0, sizeof(re));
- if ( rendererLib != NULL ) {
- Sys_UnloadDll (rendererLib);
+ if (rendererLib != NULL) {
+ Sys_UnloadDll(rendererLib);
rendererLib = NULL;
}
}
@@ -912,13 +888,13 @@ Convenience function for the sound system to be started
REALLY early on Xbox, helps with memory fragmentation.
============================
*/
-void CL_StartSound( void ) {
- if ( !cls.soundStarted ) {
+void CL_StartSound(void) {
+ if (!cls.soundStarted) {
cls.soundStarted = qtrue;
S_Init();
}
- if ( !cls.soundRegistered ) {
+ if (!cls.soundRegistered) {
cls.soundRegistered = qtrue;
S_BeginRegistration();
}
@@ -929,15 +905,15 @@ void CL_StartSound( void ) {
CL_InitRenderer
============
*/
-void CL_InitRenderer( void ) {
+void CL_InitRenderer(void) {
// this sets up the renderer and calls R_Init
- re.BeginRegistration( &cls.glconfig );
+ re.BeginRegistration(&cls.glconfig);
// load character sets
cls.charSetShader = re.RegisterShaderNoMip("gfx/2d/charsgrid_med");
- cls.consoleFont = re.RegisterFont( "ocr_a" );
- cls.whiteShader = re.RegisterShader( "white" );
- cls.consoleShader = re.RegisterShader( "console" );
+ cls.consoleFont = re.RegisterFont("ocr_a");
+ cls.whiteShader = re.RegisterShader("white");
+ cls.consoleShader = re.RegisterShader("console");
g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2;
g_consoleField.widthInChars = g_console_field_width;
}
@@ -950,35 +926,34 @@ After the server has cleared the hunk, these will need to be restarted
This is the only place that any of these functions are called from
============================
*/
-void CL_StartHunkUsers( void ) {
- if ( !com_cl_running->integer ) {
+void CL_StartHunkUsers(void) {
+ if (!com_cl_running->integer) {
return;
}
- if ( !cls.rendererStarted ) {
+ if (!cls.rendererStarted) {
cls.rendererStarted = qtrue;
CL_InitRenderer();
}
- if ( !cls.soundStarted ) {
+ if (!cls.soundStarted) {
cls.soundStarted = qtrue;
S_Init();
}
- if ( !cls.soundRegistered ) {
+ if (!cls.soundRegistered) {
cls.soundRegistered = qtrue;
S_BeginRegistration();
}
- //we require the ui to be loaded here or else it crashes trying to access the ui on command line map loads
- if ( !cls.uiStarted ) {
+ // we require the ui to be loaded here or else it crashes trying to access the ui on command line map loads
+ if (!cls.uiStarted) {
cls.uiStarted = qtrue;
CL_InitUI();
}
-// if ( !cls.cgameStarted && cls.state > CA_CONNECTED && cls.state != CA_CINEMATIC ) {
- if ( !cls.cgameStarted && cls.state > CA_CONNECTED && (cls.state != CA_CINEMATIC && !CL_IsRunningInGameCinematic()) )
- {
+ // if ( !cls.cgameStarted && cls.state > CA_CONNECTED && cls.state != CA_CINEMATIC ) {
+ if (!cls.cgameStarted && cls.state > CA_CONNECTED && (cls.state != CA_CINEMATIC && !CL_IsRunningInGameCinematic())) {
cls.cgameStarted = qtrue;
CL_InitCGame();
}
@@ -991,20 +966,20 @@ CL_RefPrintf
DLL glue
================
*/
-void QDECL CL_RefPrintf( int print_level, const char *fmt, ...) {
- va_list argptr;
- char msg[MAXPRINTMSG];
+void QDECL CL_RefPrintf(int print_level, const char *fmt, ...) {
+ va_list argptr;
+ char msg[MAXPRINTMSG];
- va_start (argptr,fmt);
+ va_start(argptr, fmt);
Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
- va_end (argptr);
-
- if ( print_level == PRINT_ALL ) {
- Com_Printf ("%s", msg);
- } else if ( print_level == PRINT_WARNING ) {
- Com_Printf (S_COLOR_YELLOW "%s", msg); // yellow
- } else if ( print_level == PRINT_DEVELOPER ) {
- Com_DPrintf (S_COLOR_RED "%s", msg); // red
+ va_end(argptr);
+
+ if (print_level == PRINT_ALL) {
+ Com_Printf("%s", msg);
+ } else if (print_level == PRINT_WARNING) {
+ Com_Printf(S_COLOR_YELLOW "%s", msg); // yellow
+ } else if (print_level == PRINT_DEVELOPER) {
+ Com_DPrintf(S_COLOR_RED "%s", msg); // red
}
}
@@ -1016,8 +991,7 @@ DLL glue, but highly reusuable DLL glue at that
============
*/
-const char *String_GetStringValue( const char *reference )
-{
+const char *String_GetStringValue(const char *reference) {
#ifndef JK2_MODE
return SE_GetString(reference);
#else
@@ -1027,91 +1001,70 @@ const char *String_GetStringValue( const char *reference )
extern qboolean gbAlreadyDoingLoad;
extern void *gpvCachedMapDiskImage;
-extern char gsCachedMapDiskImage[MAX_QPATH];
+extern char gsCachedMapDiskImage[MAX_QPATH];
extern qboolean gbUsingCachedMapDataRightNow;
-char *get_gsCachedMapDiskImage( void )
-{
- return gsCachedMapDiskImage;
-}
+char *get_gsCachedMapDiskImage(void) { return gsCachedMapDiskImage; }
-void *get_gpvCachedMapDiskImage( void )
-{
- return gpvCachedMapDiskImage;
-}
+void *get_gpvCachedMapDiskImage(void) { return gpvCachedMapDiskImage; }
-qboolean *get_gbUsingCachedMapDataRightNow( void )
-{
- return &gbUsingCachedMapDataRightNow;
-}
+qboolean *get_gbUsingCachedMapDataRightNow(void) { return &gbUsingCachedMapDataRightNow; }
-qboolean *get_gbAlreadyDoingLoad( void )
-{
- return &gbAlreadyDoingLoad;
-}
+qboolean *get_gbAlreadyDoingLoad(void) { return &gbAlreadyDoingLoad; }
-int get_com_frameTime( void )
-{
- return com_frameTime;
-}
+int get_com_frameTime(void) { return com_frameTime; }
-void *CL_Malloc(int iSize, memtag_t eTag, qboolean bZeroit, int iAlign)
-{
- return Z_Malloc(iSize, eTag, bZeroit);
-}
+void *CL_Malloc(int iSize, memtag_t eTag, qboolean bZeroit, int iAlign) { return Z_Malloc(iSize, eTag, bZeroit); }
/*
============
CL_InitRef
============
*/
-extern qboolean S_FileExists( const char *psFilename );
-extern bool CM_CullWorldBox (const cplane_t *frustum, const vec3pair_t bounds);
+extern qboolean S_FileExists(const char *psFilename);
+extern bool CM_CullWorldBox(const cplane_t *frustum, const vec3pair_t bounds);
extern qboolean SND_RegisterAudio_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLevel /* 99% qfalse */);
-extern cvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force);
+extern cvar_t *Cvar_Set2(const char *var_name, const char *value, qboolean force);
extern CMiniHeap *G2VertSpaceServer;
-static CMiniHeap *GetG2VertSpaceServer( void ) {
- return G2VertSpaceServer;
-}
+static CMiniHeap *GetG2VertSpaceServer(void) { return G2VertSpaceServer; }
// NOTENOTE: If you change the output name of rd-vanilla, change this define too!
#ifdef JK2_MODE
-#define DEFAULT_RENDER_LIBRARY "rdjosp-vanilla"
+#define DEFAULT_RENDER_LIBRARY "rdjosp-vanilla"
#else
-#define DEFAULT_RENDER_LIBRARY "rdsp-vanilla"
+#define DEFAULT_RENDER_LIBRARY "rdsp-vanilla"
#endif
-void CL_InitRef( void ) {
- refexport_t *ret;
+void CL_InitRef(void) {
+ refexport_t *ret;
static refimport_t rit;
- char dllName[MAX_OSPATH];
- GetRefAPI_t GetRefAPI;
+ char dllName[MAX_OSPATH];
+ GetRefAPI_t GetRefAPI;
- Com_Printf( "----- Initializing Renderer ----\n" );
- cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH );
+ Com_Printf("----- Initializing Renderer ----\n");
+ cl_renderer = Cvar_Get("cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE | CVAR_LATCH);
- Com_sprintf( dllName, sizeof( dllName ), "%s_" ARCH_STRING DLL_EXT, cl_renderer->string );
+ Com_sprintf(dllName, sizeof(dllName), "%s_" ARCH_STRING DLL_EXT, cl_renderer->string);
- if( !(rendererLib = Sys_LoadDll( dllName, qfalse )) && strcmp( cl_renderer->string, cl_renderer->resetString ) )
- {
- Com_Printf( "failed: trying to load fallback renderer\n" );
- Cvar_ForceReset( "cl_renderer" );
+ if (!(rendererLib = Sys_LoadDll(dllName, qfalse)) && strcmp(cl_renderer->string, cl_renderer->resetString)) {
+ Com_Printf("failed: trying to load fallback renderer\n");
+ Cvar_ForceReset("cl_renderer");
- Com_sprintf( dllName, sizeof( dllName ), DEFAULT_RENDER_LIBRARY "_" ARCH_STRING DLL_EXT );
- rendererLib = Sys_LoadDll( dllName, qfalse );
+ Com_sprintf(dllName, sizeof(dllName), DEFAULT_RENDER_LIBRARY "_" ARCH_STRING DLL_EXT);
+ rendererLib = Sys_LoadDll(dllName, qfalse);
}
- if ( !rendererLib ) {
- Com_Error( ERR_FATAL, "Failed to load renderer\n" );
+ if (!rendererLib) {
+ Com_Error(ERR_FATAL, "Failed to load renderer\n");
}
- memset( &rit, 0, sizeof( rit ) );
+ memset(&rit, 0, sizeof(rit));
- GetRefAPI = (GetRefAPI_t)Sys_LoadFunction( rendererLib, "GetRefAPI" );
- if ( !GetRefAPI )
- Com_Error( ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError() );
+ GetRefAPI = (GetRefAPI_t)Sys_LoadFunction(rendererLib, "GetRefAPI");
+ if (!GetRefAPI)
+ Com_Error(ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError());
-#define RIT(y) rit.y = y
+#define RIT(y) rit.y = y
RIT(CIN_PlayCinematic);
RIT(CIN_RunCinematic);
RIT(CIN_UploadCinematic);
@@ -1149,20 +1102,20 @@ void CL_InitRef( void ) {
RIT(FS_WriteFile);
RIT(Hunk_ClearToMark);
RIT(SND_RegisterAudio_LevelLoadEnd);
- //RIT(SV_PointContents);
+ // RIT(SV_PointContents);
RIT(SV_Trace);
RIT(S_RestartMusic);
RIT(Z_Free);
- rit.Malloc=CL_Malloc;
+ rit.Malloc = CL_Malloc;
RIT(Z_MemSize);
RIT(Z_MorphMallocTag);
RIT(Hunk_ClearToMark);
- rit.WIN_Init = WIN_Init;
+ rit.WIN_Init = WIN_Init;
rit.WIN_SetGamma = WIN_SetGamma;
- rit.WIN_Shutdown = WIN_Shutdown;
- rit.WIN_Present = WIN_Present;
+ rit.WIN_Shutdown = WIN_Shutdown;
+ rit.WIN_Present = WIN_Present;
rit.GL_GetProcAddress = WIN_GL_GetProcAddress;
rit.GL_ExtensionSupported = WIN_GL_ExtensionSupported;
@@ -1189,165 +1142,164 @@ void CL_InitRef( void ) {
rit.saved_game = &ojk::SavedGame::get_instance();
- ret = GetRefAPI( REF_API_VERSION, &rit );
+ ret = GetRefAPI(REF_API_VERSION, &rit);
- if ( !ret ) {
- Com_Error (ERR_FATAL, "Couldn't initialize refresh" );
+ if (!ret) {
+ Com_Error(ERR_FATAL, "Couldn't initialize refresh");
}
re = *ret;
- Com_Printf( "-------------------------------\n");
+ Com_Printf("-------------------------------\n");
// unpause so the cgame definately gets a snapshot and renders a frame
- Cvar_Set( "cl_paused", "0" );
+ Cvar_Set("cl_paused", "0");
}
-
//===========================================================================================
-void CL_CompleteCinematic( char *args, int argNum );
+void CL_CompleteCinematic(char *args, int argNum);
/*
====================
CL_Init
====================
*/
-void CL_Init( void ) {
- Com_Printf( "----- Client Initialization -----\n" );
+void CL_Init(void) {
+ Com_Printf("----- Client Initialization -----\n");
#ifdef JK2_MODE
- JK2SP_Register("con_text", SP_REGISTER_REQUIRED); //reference is CON_TEXT
- JK2SP_Register("keynames", SP_REGISTER_REQUIRED); // reference is KEYNAMES
+ JK2SP_Register("con_text", SP_REGISTER_REQUIRED); // reference is CON_TEXT
+ JK2SP_Register("keynames", SP_REGISTER_REQUIRED); // reference is KEYNAMES
#endif
- Con_Init ();
+ Con_Init();
- CL_ClearState ();
+ CL_ClearState();
- cls.state = CA_DISCONNECTED; // no longer CA_UNINITIALIZED
- //cls.keyCatchers = KEYCATCH_CONSOLE;
+ cls.state = CA_DISCONNECTED; // no longer CA_UNINITIALIZED
+ // cls.keyCatchers = KEYCATCH_CONSOLE;
cls.realtime = 0;
- cls.realtimeFraction=0.0f; // fraction of a msec accumulated
+ cls.realtimeFraction = 0.0f; // fraction of a msec accumulated
- CL_InitInput ();
+ CL_InitInput();
//
// register our variables
//
- cl_noprint = Cvar_Get( "cl_noprint", "0", 0 );
+ cl_noprint = Cvar_Get("cl_noprint", "0", 0);
- cl_timeout = Cvar_Get ("cl_timeout", "125", 0);
+ cl_timeout = Cvar_Get("cl_timeout", "125", 0);
- cl_timeNudge = Cvar_Get ("cl_timeNudge", "0", CVAR_TEMP );
- cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_TEMP );
- cl_showTimeDelta = Cvar_Get ("cl_showTimeDelta", "0", CVAR_TEMP );
- cl_newClock = Cvar_Get ("cl_newClock", "1", 0);
- cl_activeAction = Cvar_Get( "activeAction", "", CVAR_TEMP );
+ cl_timeNudge = Cvar_Get("cl_timeNudge", "0", CVAR_TEMP);
+ cl_shownet = Cvar_Get("cl_shownet", "0", CVAR_TEMP);
+ cl_showTimeDelta = Cvar_Get("cl_showTimeDelta", "0", CVAR_TEMP);
+ cl_newClock = Cvar_Get("cl_newClock", "1", 0);
+ cl_activeAction = Cvar_Get("activeAction", "", CVAR_TEMP);
- cl_avidemo = Cvar_Get ("cl_avidemo", "0", 0);
- cl_pano = Cvar_Get ("pano", "0", 0);
- cl_panoNumShots= Cvar_Get ("panoNumShots", "10", CVAR_ARCHIVE_ND);
- cl_skippingcin = Cvar_Get ("skippingCinematic", "0", CVAR_ROM);
- cl_endcredits = Cvar_Get ("cg_endcredits", "0", 0);
+ cl_avidemo = Cvar_Get("cl_avidemo", "0", 0);
+ cl_pano = Cvar_Get("pano", "0", 0);
+ cl_panoNumShots = Cvar_Get("panoNumShots", "10", CVAR_ARCHIVE_ND);
+ cl_skippingcin = Cvar_Get("skippingCinematic", "0", CVAR_ROM);
+ cl_endcredits = Cvar_Get("cg_endcredits", "0", 0);
- cl_yawspeed = Cvar_Get ("cl_yawspeed", "140", CVAR_ARCHIVE_ND);
- cl_pitchspeed = Cvar_Get ("cl_pitchspeed", "140", CVAR_ARCHIVE_ND);
- cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_ARCHIVE_ND);
+ cl_yawspeed = Cvar_Get("cl_yawspeed", "140", CVAR_ARCHIVE_ND);
+ cl_pitchspeed = Cvar_Get("cl_pitchspeed", "140", CVAR_ARCHIVE_ND);
+ cl_anglespeedkey = Cvar_Get("cl_anglespeedkey", "1.5", CVAR_ARCHIVE_ND);
- cl_packetdup = Cvar_Get ("cl_packetdup", "1", CVAR_ARCHIVE_ND );
+ cl_packetdup = Cvar_Get("cl_packetdup", "1", CVAR_ARCHIVE_ND);
- cl_run = Cvar_Get ("cl_run", "1", CVAR_ARCHIVE_ND);
- cl_sensitivity = Cvar_Get ("sensitivity", "5", CVAR_ARCHIVE);
- cl_mouseAccel = Cvar_Get ("cl_mouseAccel", "0", CVAR_ARCHIVE_ND);
- cl_freelook = Cvar_Get( "cl_freelook", "1", CVAR_ARCHIVE_ND );
+ cl_run = Cvar_Get("cl_run", "1", CVAR_ARCHIVE_ND);
+ cl_sensitivity = Cvar_Get("sensitivity", "5", CVAR_ARCHIVE);
+ cl_mouseAccel = Cvar_Get("cl_mouseAccel", "0", CVAR_ARCHIVE_ND);
+ cl_freelook = Cvar_Get("cl_freelook", "1", CVAR_ARCHIVE_ND);
- cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
+ cl_showMouseRate = Cvar_Get("cl_showmouserate", "0", 0);
- cl_allowAltEnter = Cvar_Get ("cl_allowAltEnter", "1", CVAR_ARCHIVE_ND);
- cl_inGameVideo = Cvar_Get ("cl_inGameVideo", "1", CVAR_ARCHIVE_ND);
- cl_framerate = Cvar_Get ("cl_framerate", "0", CVAR_TEMP);
+ cl_allowAltEnter = Cvar_Get("cl_allowAltEnter", "1", CVAR_ARCHIVE_ND);
+ cl_inGameVideo = Cvar_Get("cl_inGameVideo", "1", CVAR_ARCHIVE_ND);
+ cl_framerate = Cvar_Get("cl_framerate", "0", CVAR_TEMP);
// init autoswitch so the ui will have it correctly even
// if the cgame hasn't been started
- Cvar_Get ("cg_autoswitch", "1", CVAR_ARCHIVE);
+ Cvar_Get("cg_autoswitch", "1", CVAR_ARCHIVE);
- m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE_ND);
- m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_ARCHIVE_ND);
- m_forward = Cvar_Get ("m_forward", "0.25", CVAR_ARCHIVE_ND);
- m_side = Cvar_Get ("m_side", "0.25", CVAR_ARCHIVE_ND);
- m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE_ND);
+ m_pitch = Cvar_Get("m_pitch", "0.022", CVAR_ARCHIVE_ND);
+ m_yaw = Cvar_Get("m_yaw", "0.022", CVAR_ARCHIVE_ND);
+ m_forward = Cvar_Get("m_forward", "0.25", CVAR_ARCHIVE_ND);
+ m_side = Cvar_Get("m_side", "0.25", CVAR_ARCHIVE_ND);
+ m_filter = Cvar_Get("m_filter", "0", CVAR_ARCHIVE_ND);
// ~ and `, as keys and characters
- cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE);
- cl_consoleUseScanCode = Cvar_Get( "cl_consoleUseScanCode", "1", CVAR_ARCHIVE );
- cl_consoleShiftRequirement = Cvar_Get( "cl_consoleShiftRequirement", "0", CVAR_ARCHIVE );
+ cl_consoleKeys = Cvar_Get("cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE);
+ cl_consoleUseScanCode = Cvar_Get("cl_consoleUseScanCode", "1", CVAR_ARCHIVE);
+ cl_consoleShiftRequirement = Cvar_Get("cl_consoleShiftRequirement", "0", CVAR_ARCHIVE);
// userinfo
#ifdef JK2_MODE
- Cvar_Get ("name", "Kyle", CVAR_USERINFO | CVAR_ARCHIVE_ND );
+ Cvar_Get("name", "Kyle", CVAR_USERINFO | CVAR_ARCHIVE_ND);
#else
- Cvar_Get ("name", "Jaden", CVAR_USERINFO | CVAR_ARCHIVE_ND );
+ Cvar_Get("name", "Jaden", CVAR_USERINFO | CVAR_ARCHIVE_ND);
#endif
#ifdef JK2_MODE
// this is required for savegame compatibility - not ever actually used
- Cvar_Get ("snaps", "20", CVAR_USERINFO );
- Cvar_Get ("sex", "male", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("handicap", "100", CVAR_USERINFO | CVAR_SAVEGAME );
+ Cvar_Get("snaps", "20", CVAR_USERINFO);
+ Cvar_Get("sex", "male", CVAR_USERINFO | CVAR_ARCHIVE);
+ Cvar_Get("handicap", "100", CVAR_USERINFO | CVAR_SAVEGAME);
#else
- Cvar_Get ("sex", "f", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_SAVEGAME | CVAR_NORESTART );
- Cvar_Get ("snd", "jaden_fmle", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_SAVEGAME | CVAR_NORESTART );//UI_SetSexandSoundForModel changes to match sounds.cfg for model
- Cvar_Get ("handicap", "100", CVAR_USERINFO | CVAR_SAVEGAME | CVAR_NORESTART);
+ Cvar_Get("sex", "f", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_SAVEGAME | CVAR_NORESTART);
+ Cvar_Get("snd", "jaden_fmle",
+ CVAR_USERINFO | CVAR_ARCHIVE | CVAR_SAVEGAME | CVAR_NORESTART); // UI_SetSexandSoundForModel changes to match sounds.cfg for model
+ Cvar_Get("handicap", "100", CVAR_USERINFO | CVAR_SAVEGAME | CVAR_NORESTART);
#endif
//
// register our commands
//
- Cmd_AddCommand ("cmd", CL_ForwardToServer_f);
- Cmd_AddCommand ("configstrings", CL_Configstrings_f);
- Cmd_AddCommand ("clientinfo", CL_Clientinfo_f);
- Cmd_AddCommand ("snd_restart", CL_Snd_Restart_f);
- Cmd_AddCommand ("vid_restart", CL_Vid_Restart_f);
- Cmd_AddCommand ("disconnect", CL_Disconnect_f);
- Cmd_AddCommand ("cinematic", CL_PlayCinematic_f);
- Cmd_SetCommandCompletionFunc( "cinematic", CL_CompleteCinematic );
- Cmd_AddCommand ("ingamecinematic", CL_PlayInGameCinematic_f);
- Cmd_AddCommand ("uimenu", CL_GenericMenu_f);
- Cmd_AddCommand ("datapad", CL_DataPad_f);
- Cmd_AddCommand ("endscreendissolve", CL_EndScreenDissolve_f);
+ Cmd_AddCommand("cmd", CL_ForwardToServer_f);
+ Cmd_AddCommand("configstrings", CL_Configstrings_f);
+ Cmd_AddCommand("clientinfo", CL_Clientinfo_f);
+ Cmd_AddCommand("snd_restart", CL_Snd_Restart_f);
+ Cmd_AddCommand("vid_restart", CL_Vid_Restart_f);
+ Cmd_AddCommand("disconnect", CL_Disconnect_f);
+ Cmd_AddCommand("cinematic", CL_PlayCinematic_f);
+ Cmd_SetCommandCompletionFunc("cinematic", CL_CompleteCinematic);
+ Cmd_AddCommand("ingamecinematic", CL_PlayInGameCinematic_f);
+ Cmd_AddCommand("uimenu", CL_GenericMenu_f);
+ Cmd_AddCommand("datapad", CL_DataPad_f);
+ Cmd_AddCommand("endscreendissolve", CL_EndScreenDissolve_f);
CL_InitRef();
CL_StartHunkUsers();
- SCR_Init ();
+ SCR_Init();
- Cbuf_Execute ();
+ Cbuf_Execute();
- Cvar_Set( "cl_running", "1" );
+ Cvar_Set("cl_running", "1");
- Com_Printf( "----- Client Initialization Complete -----\n" );
+ Com_Printf("----- Client Initialization Complete -----\n");
}
-
/*
===============
CL_Shutdown
===============
*/
-void CL_Shutdown( void ) {
+void CL_Shutdown(void) {
static qboolean recursive = qfalse;
- if ( !com_cl_running || !com_cl_running->integer ) {
+ if (!com_cl_running || !com_cl_running->integer) {
return;
}
- Com_Printf( "----- CL_Shutdown -----\n" );
+ Com_Printf("----- CL_Shutdown -----\n");
- if ( recursive ) {
- Com_Printf( "WARNING: Recursive CL_Shutdown called!\n" );
+ if (recursive) {
+ Com_Printf("WARNING: Recursive CL_Shutdown called!\n");
return;
}
recursive = qtrue;
@@ -1358,24 +1310,23 @@ void CL_Shutdown( void ) {
S_Shutdown();
CL_ShutdownRef(qfalse);
- Cmd_RemoveCommand ("cmd");
- Cmd_RemoveCommand ("configstrings");
- Cmd_RemoveCommand ("clientinfo");
- Cmd_RemoveCommand ("snd_restart");
- Cmd_RemoveCommand ("vid_restart");
- Cmd_RemoveCommand ("disconnect");
- Cmd_RemoveCommand ("cinematic");
- Cmd_RemoveCommand ("ingamecinematic");
- Cmd_RemoveCommand ("uimenu");
- Cmd_RemoveCommand ("datapad");
- Cmd_RemoveCommand ("endscreendissolve");
+ Cmd_RemoveCommand("cmd");
+ Cmd_RemoveCommand("configstrings");
+ Cmd_RemoveCommand("clientinfo");
+ Cmd_RemoveCommand("snd_restart");
+ Cmd_RemoveCommand("vid_restart");
+ Cmd_RemoveCommand("disconnect");
+ Cmd_RemoveCommand("cinematic");
+ Cmd_RemoveCommand("ingamecinematic");
+ Cmd_RemoveCommand("uimenu");
+ Cmd_RemoveCommand("datapad");
+ Cmd_RemoveCommand("endscreendissolve");
- Cvar_Set( "cl_running", "0" );
+ Cvar_Set("cl_running", "0");
recursive = qfalse;
- memset( &cls, 0, sizeof( cls ) );
+ memset(&cls, 0, sizeof(cls));
- Com_Printf( "-----------------------\n" );
+ Com_Printf("-----------------------\n");
}
-
diff --git a/code/client/cl_mp3.cpp b/code/client/cl_mp3.cpp
index c397a494f4..b8ae13cbd8 100644
--- a/code/client/cl_mp3.cpp
+++ b/code/client/cl_mp3.cpp
@@ -26,46 +26,42 @@ along with this program; if not, see .
#include "../server/exe_headers.h"
#include "client.h"
-#include "cl_mp3.h" // only included directly by a few snd_xxxx.cpp files plus this one
-#include "../mp3code/mp3struct.h" // keep this rather awful file secret from the rest of the program
+#include "cl_mp3.h" // only included directly by a few snd_xxxx.cpp files plus this one
+#include "../mp3code/mp3struct.h" // keep this rather awful file secret from the rest of the program
// expects data already loaded, filename arg is for error printing only
//
// returns success/fail
//
-qboolean MP3_IsValid( const char *psLocalFilename, void *pvData, int iDataLen, qboolean bStereoDesired /* = qfalse */)
-{
+qboolean MP3_IsValid(const char *psLocalFilename, void *pvData, int iDataLen, qboolean bStereoDesired /* = qfalse */) {
char *psError = C_MP3_IsValid(pvData, iDataLen, bStereoDesired);
- if (psError)
- {
- Com_Printf(va(S_COLOR_RED"%s(%s)\n",psError, psLocalFilename));
+ if (psError) {
+ Com_Printf(va(S_COLOR_RED "%s(%s)\n", psError, psLocalFilename));
}
return (qboolean)(!psError);
}
-
-
// expects data already loaded, filename arg is for error printing only
//
// returns unpacked length, or 0 for errors (which will be printed internally)
//
-int MP3_GetUnpackedSize( const char *psLocalFilename, void *pvData, int iDataLen, qboolean qbIgnoreID3Tag /* = qfalse */
- , qboolean bStereoDesired /* = qfalse */
- )
-{
- int iUnpackedSize = 0;
-
- // always do this now that we have fast-unpack code for measuring output size... (much safer than relying on tags that may have been edited, or if MP3 has been re-saved with same tag)
+int MP3_GetUnpackedSize(const char *psLocalFilename, void *pvData, int iDataLen, qboolean qbIgnoreID3Tag /* = qfalse */
+ ,
+ qboolean bStereoDesired /* = qfalse */
+) {
+ int iUnpackedSize = 0;
+
+ // always do this now that we have fast-unpack code for measuring output size... (much safer than relying on tags that may have been edited, or if MP3 has
+ // been re-saved with same tag)
//
- if (1)//qbIgnoreID3Tag || !MP3_ReadSpecialTagInfo((byte *)pvData, iDataLen, NULL, &iUnpackedSize))
+ if (1) // qbIgnoreID3Tag || !MP3_ReadSpecialTagInfo((byte *)pvData, iDataLen, NULL, &iUnpackedSize))
{
- char *psError = C_MP3_GetUnpackedSize( pvData, iDataLen, &iUnpackedSize, bStereoDesired);
+ char *psError = C_MP3_GetUnpackedSize(pvData, iDataLen, &iUnpackedSize, bStereoDesired);
- if (psError)
- {
- Com_Printf(va(S_COLOR_RED"%s\n(File: %s)\n",psError, psLocalFilename));
+ if (psError) {
+ Com_Printf(va(S_COLOR_RED "%s\n(File: %s)\n", psError, psLocalFilename));
return 0;
}
}
@@ -73,50 +69,41 @@ int MP3_GetUnpackedSize( const char *psLocalFilename, void *pvData, int iDataLen
return iUnpackedSize;
}
-
-
// expects data already loaded, filename arg is for error printing only
//
// returns byte count of unpacked data (effectively a success/fail bool)
//
-int MP3_UnpackRawPCM( const char *psLocalFilename, void *pvData, int iDataLen, byte *pbUnpackBuffer, qboolean bStereoDesired /* = qfalse */)
-{
+int MP3_UnpackRawPCM(const char *psLocalFilename, void *pvData, int iDataLen, byte *pbUnpackBuffer, qboolean bStereoDesired /* = qfalse */) {
int iUnpackedSize;
- char *psError = C_MP3_UnpackRawPCM( pvData, iDataLen, &iUnpackedSize, pbUnpackBuffer, bStereoDesired);
+ char *psError = C_MP3_UnpackRawPCM(pvData, iDataLen, &iUnpackedSize, pbUnpackBuffer, bStereoDesired);
- if (psError)
- {
- Com_Printf(va(S_COLOR_RED"%s\n(File: %s)\n",psError, psLocalFilename));
+ if (psError) {
+ Com_Printf(va(S_COLOR_RED "%s\n(File: %s)\n", psError, psLocalFilename));
return 0;
}
return iUnpackedSize;
}
-
// psLocalFilename is just for error reporting (if any)...
//
-qboolean MP3Stream_InitPlayingTimeFields( LP_MP3STREAM lpMP3Stream, const char *psLocalFilename, void *pvData, int iDataLen, qboolean bStereoDesired /* = qfalse */)
-{
+qboolean MP3Stream_InitPlayingTimeFields(LP_MP3STREAM lpMP3Stream, const char *psLocalFilename, void *pvData, int iDataLen,
+ qboolean bStereoDesired /* = qfalse */) {
qboolean bRetval = qfalse;
int iRate, iWidth, iChannels;
- char *psError = C_MP3_GetHeaderData(pvData, iDataLen, &iRate, &iWidth, &iChannels, bStereoDesired );
- if (psError)
- {
- Com_Printf(va(S_COLOR_RED"MP3Stream_InitPlayingTimeFields(): %s\n(File: %s)\n",psError, psLocalFilename));
- }
- else
- {
- int iUnpackLength = MP3_GetUnpackedSize( psLocalFilename, pvData, iDataLen, qfalse, // qboolean qbIgnoreID3Tag
- bStereoDesired);
- if (iUnpackLength)
- {
- lpMP3Stream->iTimeQuery_UnpackedLength = iUnpackLength;
- lpMP3Stream->iTimeQuery_SampleRate = iRate;
- lpMP3Stream->iTimeQuery_Channels = iChannels;
- lpMP3Stream->iTimeQuery_Width = iWidth;
+ char *psError = C_MP3_GetHeaderData(pvData, iDataLen, &iRate, &iWidth, &iChannels, bStereoDesired);
+ if (psError) {
+ Com_Printf(va(S_COLOR_RED "MP3Stream_InitPlayingTimeFields(): %s\n(File: %s)\n", psError, psLocalFilename));
+ } else {
+ int iUnpackLength = MP3_GetUnpackedSize(psLocalFilename, pvData, iDataLen, qfalse, // qboolean qbIgnoreID3Tag
+ bStereoDesired);
+ if (iUnpackLength) {
+ lpMP3Stream->iTimeQuery_UnpackedLength = iUnpackLength;
+ lpMP3Stream->iTimeQuery_SampleRate = iRate;
+ lpMP3Stream->iTimeQuery_Channels = iChannels;
+ lpMP3Stream->iTimeQuery_Width = iWidth;
bRetval = qtrue;
}
@@ -125,84 +112,72 @@ qboolean MP3Stream_InitPlayingTimeFields( LP_MP3STREAM lpMP3Stream, const char *
return bRetval;
}
-float MP3Stream_GetPlayingTimeInSeconds( LP_MP3STREAM lpMP3Stream )
-{
- if (lpMP3Stream->iTimeQuery_UnpackedLength) // fields initialised?
- return (float)((((double)lpMP3Stream->iTimeQuery_UnpackedLength / (double)lpMP3Stream->iTimeQuery_SampleRate) / (double)lpMP3Stream->iTimeQuery_Channels) / (double)lpMP3Stream->iTimeQuery_Width);
+float MP3Stream_GetPlayingTimeInSeconds(LP_MP3STREAM lpMP3Stream) {
+ if (lpMP3Stream->iTimeQuery_UnpackedLength) // fields initialised?
+ return (
+ float)((((double)lpMP3Stream->iTimeQuery_UnpackedLength / (double)lpMP3Stream->iTimeQuery_SampleRate) / (double)lpMP3Stream->iTimeQuery_Channels) /
+ (double)lpMP3Stream->iTimeQuery_Width);
return 0.0f;
}
-float MP3Stream_GetRemainingTimeInSeconds( LP_MP3STREAM lpMP3Stream )
-{
- if (lpMP3Stream->iTimeQuery_UnpackedLength) // fields initialised?
- return (float)(((((double)(lpMP3Stream->iTimeQuery_UnpackedLength - (lpMP3Stream->iBytesDecodedTotal * (lpMP3Stream->iTimeQuery_SampleRate / dma.speed)))) / (double)lpMP3Stream->iTimeQuery_SampleRate) / (double)lpMP3Stream->iTimeQuery_Channels) / (double)lpMP3Stream->iTimeQuery_Width);
+float MP3Stream_GetRemainingTimeInSeconds(LP_MP3STREAM lpMP3Stream) {
+ if (lpMP3Stream->iTimeQuery_UnpackedLength) // fields initialised?
+ return (
+ float)(((((double)(lpMP3Stream->iTimeQuery_UnpackedLength - (lpMP3Stream->iBytesDecodedTotal * (lpMP3Stream->iTimeQuery_SampleRate / dma.speed)))) /
+ (double)lpMP3Stream->iTimeQuery_SampleRate) /
+ (double)lpMP3Stream->iTimeQuery_Channels) /
+ (double)lpMP3Stream->iTimeQuery_Width);
return 0.0f;
}
-
-
-
// expects data already loaded, filename arg is for error printing only
//
-qboolean MP3_FakeUpWAVInfo( const char *psLocalFilename, void *pvData, int iDataLen, int iUnpackedDataLength,
- int &format, int &rate, int &width, int &channels, int &samples, int &dataofs,
- qboolean bStereoDesired /* = qfalse */
- )
-{
+qboolean MP3_FakeUpWAVInfo(const char *psLocalFilename, void *pvData, int iDataLen, int iUnpackedDataLength, int &format, int &rate, int &width, int &channels,
+ int &samples, int &dataofs, qboolean bStereoDesired /* = qfalse */
+) {
// some things can be done instantly...
//
- format = 1; // 1 for MS format
- dataofs= 0; // will be 0 for me (since there's no header in the unpacked data)
+ format = 1; // 1 for MS format
+ dataofs = 0; // will be 0 for me (since there's no header in the unpacked data)
// some things need to be read... (though the whole stereo flag thing is crap)
//
- char *psError = C_MP3_GetHeaderData(pvData, iDataLen, &rate, &width, &channels, bStereoDesired );
- if (psError)
- {
- Com_Printf(va(S_COLOR_RED"%s\n(File: %s)\n",psError, psLocalFilename));
+ char *psError = C_MP3_GetHeaderData(pvData, iDataLen, &rate, &width, &channels, bStereoDesired);
+ if (psError) {
+ Com_Printf(va(S_COLOR_RED "%s\n(File: %s)\n", psError, psLocalFilename));
}
// and some stuff needs calculating...
//
- samples = iUnpackedDataLength / width;
+ samples = iUnpackedDataLength / width;
return (qboolean)(!psError);
}
-
-
-const char sKEY_MAXVOL[]="#MAXVOL"; // formerly #defines
-const char sKEY_UNCOMP[]="#UNCOMP"; // " "
+const char sKEY_MAXVOL[] = "#MAXVOL"; // formerly #defines
+const char sKEY_UNCOMP[] = "#UNCOMP"; // " "
// returns qtrue for success...
//
-qboolean MP3_ReadSpecialTagInfo(byte *pbLoadedFile, int iLoadedFileLen,
- id3v1_1** ppTAG /* = NULL */,
- int *piUncompressedSize /* = NULL */,
+qboolean MP3_ReadSpecialTagInfo(byte *pbLoadedFile, int iLoadedFileLen, id3v1_1 **ppTAG /* = NULL */, int *piUncompressedSize /* = NULL */,
float *pfMaxVol /* = NULL */
- )
-{
+) {
qboolean qbError = qfalse;
- id3v1_1* pTAG = (id3v1_1*) ((pbLoadedFile+iLoadedFileLen)-sizeof(id3v1_1)); // sizeof = 128
+ id3v1_1 *pTAG = (id3v1_1 *)((pbLoadedFile + iLoadedFileLen) - sizeof(id3v1_1)); // sizeof = 128
- if (!strncmp(pTAG->id, "TAG", 3))
- {
+ if (!strncmp(pTAG->id, "TAG", 3)) {
// TAG found...
//
// read MAXVOL key...
//
- if (strncmp(pTAG->comment, sKEY_MAXVOL, strlen(sKEY_MAXVOL)))
- {
+ if (strncmp(pTAG->comment, sKEY_MAXVOL, strlen(sKEY_MAXVOL))) {
qbError = qtrue;
- }
- else
- {
- if ( pfMaxVol)
- {
+ } else {
+ if (pfMaxVol) {
*pfMaxVol = atof(pTAG->comment + strlen(sKEY_MAXVOL));
}
}
@@ -210,42 +185,30 @@ qboolean MP3_ReadSpecialTagInfo(byte *pbLoadedFile, int iLoadedFileLen,
//
// read UNCOMP key...
//
- if (strncmp(pTAG->album, sKEY_UNCOMP, strlen(sKEY_UNCOMP)))
- {
+ if (strncmp(pTAG->album, sKEY_UNCOMP, strlen(sKEY_UNCOMP))) {
qbError = qtrue;
- }
- else
- {
- if ( piUncompressedSize)
- {
+ } else {
+ if (piUncompressedSize) {
*piUncompressedSize = atoi(pTAG->album + strlen(sKEY_UNCOMP));
}
}
- }
- else
- {
+ } else {
pTAG = NULL;
}
- if (ppTAG)
- {
+ if (ppTAG) {
*ppTAG = pTAG;
}
return (qboolean)(pTAG && !qbError);
}
+#define FUZZY_AMOUNT \
+ (5 * 1024) // so it has to be significantly over, not just break even, because of
+ // the xtra CPU time versus memory saving
-
-#define FUZZY_AMOUNT (5*1024) // so it has to be significantly over, not just break even, because of
- // the xtra CPU time versus memory saving
-
-cvar_t* cv_MP3overhead = NULL;
-void MP3_InitCvars(void)
-{
- cv_MP3overhead = Cvar_Get("s_mp3overhead", va("%d", sizeof(MP3STREAM) + FUZZY_AMOUNT), CVAR_ARCHIVE );
-}
-
+cvar_t *cv_MP3overhead = NULL;
+void MP3_InitCvars(void) { cv_MP3overhead = Cvar_Get("s_mp3overhead", va("%d", sizeof(MP3STREAM) + FUZZY_AMOUNT), CVAR_ARCHIVE); }
// a file has been loaded in memory, see if we want to keep it as MP3, else as normal WAV...
//
@@ -253,55 +216,47 @@ void MP3_InitCvars(void)
//
// (note: the reason I pass in the unpacked size rather than working it out here is simply because I already have it)
//
-qboolean MP3Stream_InitFromFile( sfx_t* sfx, byte *pbSrcData, int iSrcDatalen, const char *psSrcDataFilename,
- int iMP3UnPackedSize, qboolean bStereoDesired /* = qfalse */
- )
-{
+qboolean MP3Stream_InitFromFile(sfx_t *sfx, byte *pbSrcData, int iSrcDatalen, const char *psSrcDataFilename, int iMP3UnPackedSize,
+ qboolean bStereoDesired /* = qfalse */
+) {
// first, make a decision based on size here as to whether or not it's worth it because of MP3 buffer space
// making small files much bigger (and therefore best left as WAV)...
//
- if (cv_MP3overhead &&
- (
- //iSrcDatalen + sizeof(MP3STREAM) + FUZZY_AMOUNT < iMP3UnPackedSize
- iSrcDatalen + cv_MP3overhead->integer < iMP3UnPackedSize
- )
- )
- {
+ if (cv_MP3overhead && (
+ // iSrcDatalen + sizeof(MP3STREAM) + FUZZY_AMOUNT < iMP3UnPackedSize
+ iSrcDatalen + cv_MP3overhead->integer < iMP3UnPackedSize)) {
// ok, let's keep it as MP3 then...
//
- float fMaxVol = 128; // seems to be a reasonable typical default for maxvol (for lip synch). Naturally there's no #define I can use instead...
+ float fMaxVol = 128; // seems to be a reasonable typical default for maxvol (for lip synch). Naturally there's no #define I can use instead...
- MP3_ReadSpecialTagInfo(pbSrcData, iSrcDatalen, NULL, NULL, &fMaxVol ); // try and read a read maxvol from MP3 header
+ MP3_ReadSpecialTagInfo(pbSrcData, iSrcDatalen, NULL, NULL, &fMaxVol); // try and read a read maxvol from MP3 header
// fill in some sfx_t fields...
//
-// Q_strncpyz( sfx->name, psSrcDataFilename, sizeof(sfx->name) );
+ // Q_strncpyz( sfx->name, psSrcDataFilename, sizeof(sfx->name) );
sfx->eSoundCompressionMethod = ct_MP3;
sfx->fVolRange = fMaxVol;
- //sfx->width = 2;
- sfx->iSoundLengthInSamples = ((iMP3UnPackedSize / 2/*sfx->width*/) / (44100 / dma.speed)) / (bStereoDesired?2:1);
+ // sfx->width = 2;
+ sfx->iSoundLengthInSamples = ((iMP3UnPackedSize / 2 /*sfx->width*/) / (44100 / dma.speed)) / (bStereoDesired ? 2 : 1);
//
// alloc mem for data and store it (raw MP3 in this case)...
//
- sfx->pSoundData = (short *) SND_malloc( iSrcDatalen, sfx );
- memcpy( sfx->pSoundData, pbSrcData, iSrcDatalen );
+ sfx->pSoundData = (short *)SND_malloc(iSrcDatalen, sfx);
+ memcpy(sfx->pSoundData, pbSrcData, iSrcDatalen);
// now init the low-level MP3 stuff...
//
- MP3STREAM SFX_MP3Stream = {}; // important to init to all zeroes!
- char *psError = C_MP3Stream_DecodeInit( &SFX_MP3Stream, /*sfx->data*/ /*sfx->soundData*/ pbSrcData, iSrcDatalen,
- dma.speed,//(s_khz->value == 44)?44100:(s_khz->value == 22)?22050:11025,
- 2/*sfx->width*/ * 8,
- bStereoDesired
- );
- SFX_MP3Stream.pbSourceData = (byte *) sfx->pSoundData;
- if (psError)
- {
+ MP3STREAM SFX_MP3Stream = {}; // important to init to all zeroes!
+ char *psError = C_MP3Stream_DecodeInit(&SFX_MP3Stream, /*sfx->data*/ /*sfx->soundData*/ pbSrcData, iSrcDatalen,
+ dma.speed, //(s_khz->value == 44)?44100:(s_khz->value == 22)?22050:11025,
+ 2 /*sfx->width*/ * 8, bStereoDesired);
+ SFX_MP3Stream.pbSourceData = (byte *)sfx->pSoundData;
+ if (psError) {
// This should never happen, since any errors or problems with the MP3 file would have stopped us getting
// to this whole function, but just in case...
//
- Com_Printf(va(S_COLOR_YELLOW"File \"%s\": %s\n",psSrcDataFilename,psError));
+ Com_Printf(va(S_COLOR_YELLOW "File \"%s\": %s\n", psSrcDataFilename, psError));
// This will leave iSrcDatalen bytes on the hunk stack (since you can't dealloc that), but MP3 files are
// usually small, and like I say, it should never happen.
@@ -317,8 +272,8 @@ qboolean MP3Stream_InitFromFile( sfx_t* sfx, byte *pbSrcData, int iSrcDatalen, c
//
// make a copy of the filled-in stream struct and attach to the sfx_t struct...
//
- sfx->pMP3StreamHeader = (MP3STREAM *) Z_Malloc( sizeof(MP3STREAM), TAG_SND_MP3STREAMHDR, qfalse );
- memcpy( sfx->pMP3StreamHeader, &SFX_MP3Stream, sizeof(MP3STREAM) );
+ sfx->pMP3StreamHeader = (MP3STREAM *)Z_Malloc(sizeof(MP3STREAM), TAG_SND_MP3STREAMHDR, qfalse);
+ memcpy(sfx->pMP3StreamHeader, &SFX_MP3Stream, sizeof(MP3STREAM));
//
return qtrue;
}
@@ -326,17 +281,14 @@ qboolean MP3Stream_InitFromFile( sfx_t* sfx, byte *pbSrcData, int iSrcDatalen, c
return qfalse;
}
-
-
// decode one packet of MP3 data only (typical output size is 2304, or 2304*2 for stereo, so input size is less
//
// return is decoded byte count, else 0 for finished
//
-int MP3Stream_Decode( LP_MP3STREAM lpMP3Stream, qboolean bDoingMusic )
-{
+int MP3Stream_Decode(LP_MP3STREAM lpMP3Stream, qboolean bDoingMusic) {
lpMP3Stream->iCopyOffset = 0;
- if (0)//!bDoingMusic)
+ if (0) //! bDoingMusic)
{
/*
// SOF2: need to make a local buffer up so we can decode the piece we want from a contiguous bitstream rather than
@@ -408,164 +360,140 @@ int MP3Stream_Decode( LP_MP3STREAM lpMP3Stream, qboolean bDoingMusic )
}
}
*/
- }
- else
- {
+ } else {
// SOF2 music, or EF1 anything...
//
- return C_MP3Stream_Decode( lpMP3Stream, qfalse ); // bFastForwarding
+ return C_MP3Stream_Decode(lpMP3Stream, qfalse); // bFastForwarding
}
}
+qboolean MP3Stream_SeekTo(channel_t *ch, float fTimeToSeekTo) {
+ const float fEpsilon = 0.05f; // accurate to 1/50 of a second, but plus or minus this gives 1/10 of second
-qboolean MP3Stream_SeekTo( channel_t *ch, float fTimeToSeekTo )
-{
- const float fEpsilon = 0.05f; // accurate to 1/50 of a second, but plus or minus this gives 1/10 of second
-
- MP3Stream_Rewind( ch );
+ MP3Stream_Rewind(ch);
//
// sanity... :-)
//
- const float fTrackLengthInSeconds = MP3Stream_GetPlayingTimeInSeconds( &ch->MP3StreamHeader );
- if (fTimeToSeekTo > fTrackLengthInSeconds)
- {
+ const float fTrackLengthInSeconds = MP3Stream_GetPlayingTimeInSeconds(&ch->MP3StreamHeader);
+ if (fTimeToSeekTo > fTrackLengthInSeconds) {
fTimeToSeekTo = fTrackLengthInSeconds;
}
// now do the seek...
//
- while (1)
- {
- float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds( &ch->MP3StreamHeader ) - MP3Stream_GetRemainingTimeInSeconds( &ch->MP3StreamHeader );
+ while (1) {
+ float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds(&ch->MP3StreamHeader) - MP3Stream_GetRemainingTimeInSeconds(&ch->MP3StreamHeader);
float fAbsTimeDiff = fabs(fTimeToSeekTo - fPlayingTimeElapsed);
- if ( fAbsTimeDiff <= fEpsilon)
+ if (fAbsTimeDiff <= fEpsilon)
return qtrue;
// when decoding, use fast-forward until within 3 seconds, then slow-decode (which should init stuff properly?)...
//
- int iBytesDecodedThisPacket = C_MP3Stream_Decode( &ch->MP3StreamHeader, (fAbsTimeDiff > 3.0f) ); // bFastForwarding
+ int iBytesDecodedThisPacket = C_MP3Stream_Decode(&ch->MP3StreamHeader, (fAbsTimeDiff > 3.0f)); // bFastForwarding
if (iBytesDecodedThisPacket == 0)
- break; // EOS
+ break; // EOS
}
return qfalse;
}
-
// returns qtrue for all ok
//
-qboolean MP3Stream_Rewind( channel_t *ch )
-{
+qboolean MP3Stream_Rewind(channel_t *ch) {
ch->iMP3SlidingDecodeWritePos = 0;
- ch->iMP3SlidingDecodeWindowPos= 0;
+ ch->iMP3SlidingDecodeWindowPos = 0;
-/*
- char *psError = C_MP3Stream_Rewind( &ch->MP3StreamHeader );
+ /*
+ char *psError = C_MP3Stream_Rewind( &ch->MP3StreamHeader );
- if (psError)
- {
- Com_Printf(S_COLOR_YELLOW"%s\n",psError);
- return qfalse;
- }
+ if (psError)
+ {
+ Com_Printf(S_COLOR_YELLOW"%s\n",psError);
+ return qfalse;
+ }
- return qtrue;
-*/
+ return qtrue;
+ */
// speed opt, since I know I already have the right data setup here...
//
memcpy(&ch->MP3StreamHeader, ch->thesfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
return qtrue;
-
}
-
// returns qtrue while still playing normally, else qfalse for either finished or request-offset-error
//
-qboolean MP3Stream_GetSamples( channel_t *ch, int startingSampleNum, int count, short *buf, qboolean bStereo )
-{
+qboolean MP3Stream_GetSamples(channel_t *ch, int startingSampleNum, int count, short *buf, qboolean bStereo) {
qboolean qbStreamStillGoing = qtrue;
- const int iQuarterOfSlidingBuffer = sizeof(ch->MP3SlidingDecodeBuffer)/4;
- const int iThreeQuartersOfSlidingBuffer = (sizeof(ch->MP3SlidingDecodeBuffer)*3)/4;
+ const int iQuarterOfSlidingBuffer = sizeof(ch->MP3SlidingDecodeBuffer) / 4;
+ const int iThreeQuartersOfSlidingBuffer = (sizeof(ch->MP3SlidingDecodeBuffer) * 3) / 4;
-// Com_Printf("startingSampleNum %d\n",startingSampleNum);
+ // Com_Printf("startingSampleNum %d\n",startingSampleNum);
- count *= 2/* <- = SOF2; ch->sfx->width*/; // count arg was for words, so double it for bytes;
+ count *= 2 /* <- = SOF2; ch->sfx->width*/; // count arg was for words, so double it for bytes;
// convert sample number into a byte offset... (make new variable for clarity?)
//
- startingSampleNum *= 2 /* <- = SOF2; ch->sfx->width*/ * (bStereo?2:1);
+ startingSampleNum *= 2 /* <- = SOF2; ch->sfx->width*/ * (bStereo ? 2 : 1);
- if ( startingSampleNum < ch->iMP3SlidingDecodeWindowPos)
- {
+ if (startingSampleNum < ch->iMP3SlidingDecodeWindowPos) {
// what?!?!?! smegging time travel needed or something?, forget it
- memset(buf,0,count);
+ memset(buf, 0, count);
return qfalse;
}
-// OutputDebugString(va("\nRequest: startingSampleNum %d, count %d\n",startingSampleNum,count));
-// OutputDebugString(va("WindowPos %d, WindowWritePos %d\n",ch->iMP3SlidingDecodeWindowPos,ch->iMP3SlidingDecodeWritePos));
+ // OutputDebugString(va("\nRequest: startingSampleNum %d, count %d\n",startingSampleNum,count));
+ // OutputDebugString(va("WindowPos %d, WindowWritePos %d\n",ch->iMP3SlidingDecodeWindowPos,ch->iMP3SlidingDecodeWritePos));
-// qboolean _bDecoded = qfalse;
+ // qboolean _bDecoded = qfalse;
- while (!
- (
- (startingSampleNum >= ch->iMP3SlidingDecodeWindowPos)
- &&
- (startingSampleNum + count < ch->iMP3SlidingDecodeWindowPos + ch->iMP3SlidingDecodeWritePos)
- )
- )
- {
-// if (!_bDecoded)
-// {
-// Com_Printf(S_COLOR_YELLOW"Decode needed!\n");
-// }
-// _bDecoded = qtrue;
-// OutputDebugString("Scrolling...");
-
- int _iBytesDecoded = MP3Stream_Decode( (LP_MP3STREAM) &ch->MP3StreamHeader, bStereo ); // stereo only for music, so this is safe
-// OutputDebugString(va("%d bytes decoded\n",_iBytesDecoded));
- if (_iBytesDecoded == 0)
- {
+ while (!((startingSampleNum >= ch->iMP3SlidingDecodeWindowPos) &&
+ (startingSampleNum + count < ch->iMP3SlidingDecodeWindowPos + ch->iMP3SlidingDecodeWritePos))) {
+ // if (!_bDecoded)
+ // {
+ // Com_Printf(S_COLOR_YELLOW"Decode needed!\n");
+ // }
+ // _bDecoded = qtrue;
+ // OutputDebugString("Scrolling...");
+
+ int _iBytesDecoded = MP3Stream_Decode((LP_MP3STREAM)&ch->MP3StreamHeader, bStereo); // stereo only for music, so this is safe
+ // OutputDebugString(va("%d bytes decoded\n",_iBytesDecoded));
+ if (_iBytesDecoded == 0) {
// no more source data left so clear the remainder of the buffer...
//
- memset(ch->MP3SlidingDecodeBuffer + ch->iMP3SlidingDecodeWritePos, 0, sizeof(ch->MP3SlidingDecodeBuffer)-ch->iMP3SlidingDecodeWritePos);
-// OutputDebugString("Finished\n");
+ memset(ch->MP3SlidingDecodeBuffer + ch->iMP3SlidingDecodeWritePos, 0, sizeof(ch->MP3SlidingDecodeBuffer) - ch->iMP3SlidingDecodeWritePos);
+ // OutputDebugString("Finished\n");
qbStreamStillGoing = qfalse;
break;
- }
- else
- {
- memcpy(ch->MP3SlidingDecodeBuffer + ch->iMP3SlidingDecodeWritePos,ch->MP3StreamHeader.bDecodeBuffer,_iBytesDecoded);
+ } else {
+ memcpy(ch->MP3SlidingDecodeBuffer + ch->iMP3SlidingDecodeWritePos, ch->MP3StreamHeader.bDecodeBuffer, _iBytesDecoded);
ch->iMP3SlidingDecodeWritePos += _iBytesDecoded;
// if reached 3/4 of buffer pos, backscroll the decode window by one quarter...
//
- if (ch->iMP3SlidingDecodeWritePos > iThreeQuartersOfSlidingBuffer)
- {
+ if (ch->iMP3SlidingDecodeWritePos > iThreeQuartersOfSlidingBuffer) {
memmove(ch->MP3SlidingDecodeBuffer, ((byte *)ch->MP3SlidingDecodeBuffer + iQuarterOfSlidingBuffer), iThreeQuartersOfSlidingBuffer);
ch->iMP3SlidingDecodeWritePos -= iQuarterOfSlidingBuffer;
- ch->iMP3SlidingDecodeWindowPos+= iQuarterOfSlidingBuffer;
+ ch->iMP3SlidingDecodeWindowPos += iQuarterOfSlidingBuffer;
}
}
-// OutputDebugString(va("WindowPos %d, WindowWritePos %d\n",ch->iMP3SlidingDecodeWindowPos,ch->iMP3SlidingDecodeWritePos));
+ // OutputDebugString(va("WindowPos %d, WindowWritePos %d\n",ch->iMP3SlidingDecodeWindowPos,ch->iMP3SlidingDecodeWritePos));
}
-// if (!_bDecoded)
-// {
-// Com_Printf(S_COLOR_YELLOW"No decode needed\n");
-// }
+ // if (!_bDecoded)
+ // {
+ // Com_Printf(S_COLOR_YELLOW"No decode needed\n");
+ // }
assert(startingSampleNum >= ch->iMP3SlidingDecodeWindowPos);
- memcpy( buf, ch->MP3SlidingDecodeBuffer + (startingSampleNum-ch->iMP3SlidingDecodeWindowPos), count);
+ memcpy(buf, ch->MP3SlidingDecodeBuffer + (startingSampleNum - ch->iMP3SlidingDecodeWindowPos), count);
-// OutputDebugString("OK\n\n");
+ // OutputDebugString("OK\n\n");
return qbStreamStillGoing;
}
-
///////////// eof /////////////
-
diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp
index 81c702dc8e..2b1ae476cd 100644
--- a/code/client/cl_parse.cpp
+++ b/code/client/cl_parse.cpp
@@ -28,25 +28,16 @@ along with this program; if not, see .
#include "client.h"
#include "client_ui.h"
-const char *svc_strings[256] = {
- "svc_bad",
-
- "svc_nop",
- "svc_gamestate",
- "svc_configstring",
- "svc_baseline",
- "svc_serverCommand",
- "svc_download",
- "svc_snapshot"
-};
-
-void SHOWNET( msg_t *msg, const char *s) {
- if ( cl_shownet->integer >= 2) {
- Com_Printf ("%3i:%s\n", msg->readcount-1, s);
+const char *svc_strings[256] = {"svc_bad",
+
+ "svc_nop", "svc_gamestate", "svc_configstring", "svc_baseline", "svc_serverCommand", "svc_download", "svc_snapshot"};
+
+void SHOWNET(msg_t *msg, const char *s) {
+ if (cl_shownet->integer >= 2) {
+ Com_Printf("%3i:%s\n", msg->readcount - 1, s);
}
}
-
/*
=========================================================================
@@ -63,18 +54,17 @@ Parses deltas from the given base and adds the resulting entity
to the current frame
==================
*/
-void CL_DeltaEntity (msg_t *msg, clSnapshot_t *frame)
-{
- entityState_t *state;
+void CL_DeltaEntity(msg_t *msg, clSnapshot_t *frame) {
+ entityState_t *state;
// save the parsed entity state into the big circular buffer so
// it can be used as the source for a later delta
- state = &cl.parseEntities[cl.parseEntitiesNum & (MAX_PARSE_ENTITIES-1)];
+ state = &cl.parseEntities[cl.parseEntitiesNum & (MAX_PARSE_ENTITIES - 1)];
- MSG_ReadEntity( msg, state);
+ MSG_ReadEntity(msg, state);
- if ( state->number == (MAX_GENTITIES-1) ) {
- return; // entity was delta removed
+ if (state->number == (MAX_GENTITIES - 1)) {
+ return; // entity was delta removed
}
cl.parseEntitiesNum++;
frame->numEntities++;
@@ -86,10 +76,10 @@ CL_ParsePacketEntities
==================
*/
-void CL_ParsePacketEntities( msg_t *msg, clSnapshot_t *oldframe, clSnapshot_t *newframe) {
- int newnum;
- entityState_t *oldstate;
- int oldindex, oldnum;
+void CL_ParsePacketEntities(msg_t *msg, clSnapshot_t *oldframe, clSnapshot_t *newframe) {
+ int newnum;
+ entityState_t *oldstate;
+ int oldindex, oldnum;
newframe->parseEntitiesNum = cl.parseEntitiesNum;
newframe->numEntities = 0;
@@ -100,95 +90,89 @@ void CL_ParsePacketEntities( msg_t *msg, clSnapshot_t *oldframe, clSnapshot_t *n
if (!oldframe) {
oldnum = 99999;
} else {
- if ( oldindex >= oldframe->numEntities ) {
+ if (oldindex >= oldframe->numEntities) {
oldnum = 99999;
} else {
- oldstate = &cl.parseEntities[
- (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
+ oldstate = &cl.parseEntities[(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES - 1)];
oldnum = oldstate->number;
}
}
- while ( 1 ) {
+ while (1) {
// read the entity index number
- newnum = MSG_ReadBits( msg, GENTITYNUM_BITS );
+ newnum = MSG_ReadBits(msg, GENTITYNUM_BITS);
- if ( newnum == (MAX_GENTITIES-1) ) {
+ if (newnum == (MAX_GENTITIES - 1)) {
break;
}
- if ( msg->readcount > msg->cursize ) {
- Com_Error (ERR_DROP,"CL_ParsePacketEntities: end of message");
+ if (msg->readcount > msg->cursize) {
+ Com_Error(ERR_DROP, "CL_ParsePacketEntities: end of message");
}
- while ( oldnum < newnum ) {
+ while (oldnum < newnum) {
// one or more entities from the old packet are unchanged
- if ( cl_shownet->integer == 3 ) {
- Com_Printf ("%3i: unchanged: %i\n", msg->readcount, oldnum);
+ if (cl_shownet->integer == 3) {
+ Com_Printf("%3i: unchanged: %i\n", msg->readcount, oldnum);
}
- CL_DeltaEntity( msg, newframe );
+ CL_DeltaEntity(msg, newframe);
oldindex++;
- if ( oldindex >= oldframe->numEntities ) {
+ if (oldindex >= oldframe->numEntities) {
oldnum = 99999;
} else {
- oldstate = &cl.parseEntities[
- (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
+ oldstate = &cl.parseEntities[(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES - 1)];
oldnum = oldstate->number;
}
}
if (oldnum == newnum) {
// delta from previous state
- if ( cl_shownet->integer == 3 ) {
- Com_Printf ("%3i: delta: %i\n", msg->readcount, newnum);
+ if (cl_shownet->integer == 3) {
+ Com_Printf("%3i: delta: %i\n", msg->readcount, newnum);
}
- CL_DeltaEntity( msg, newframe );
+ CL_DeltaEntity(msg, newframe);
oldindex++;
- if ( oldindex >= oldframe->numEntities ) {
+ if (oldindex >= oldframe->numEntities) {
oldnum = 99999;
} else {
- oldstate = &cl.parseEntities[
- (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
+ oldstate = &cl.parseEntities[(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES - 1)];
oldnum = oldstate->number;
}
continue;
}
- if ( oldnum > newnum ) {
+ if (oldnum > newnum) {
// delta from baseline
- if ( cl_shownet->integer == 3 ) {
- Com_Printf ("%3i: baseline: %i\n", msg->readcount, newnum);
+ if (cl_shownet->integer == 3) {
+ Com_Printf("%3i: baseline: %i\n", msg->readcount, newnum);
}
- CL_DeltaEntity( msg, newframe );
+ CL_DeltaEntity(msg, newframe);
continue;
}
-
}
// any remaining entities in the old frame are copied over
- while ( oldnum != 99999 ) {
+ while (oldnum != 99999) {
// one or more entities from the old packet are unchanged
- if ( cl_shownet->integer == 3 ) {
- Com_Printf ("%3i: unchanged: %i\n", msg->readcount, oldnum);
+ if (cl_shownet->integer == 3) {
+ Com_Printf("%3i: unchanged: %i\n", msg->readcount, oldnum);
}
- CL_DeltaEntity( msg, newframe );
+ CL_DeltaEntity(msg, newframe);
oldindex++;
- if ( oldindex >= oldframe->numEntities ) {
+ if (oldindex >= oldframe->numEntities) {
oldnum = 99999;
} else {
- oldstate = &cl.parseEntities[
- (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];
+ oldstate = &cl.parseEntities[(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES - 1)];
oldnum = oldstate->number;
}
}
}
-
/*
================
CL_ParseSnapshot
@@ -198,81 +182,81 @@ cl.frame and saved in cl.frames[]. If the snapshot is invalid
for any reason, no changes to the state will be made at all.
================
*/
-void CL_ParseSnapshot( msg_t *msg ) {
- int len;
- clSnapshot_t *old;
- clSnapshot_t newSnap;
- int deltaNum;
- int oldMessageNum;
- int i, packetNum;
+void CL_ParseSnapshot(msg_t *msg) {
+ int len;
+ clSnapshot_t *old;
+ clSnapshot_t newSnap;
+ int deltaNum;
+ int oldMessageNum;
+ int i, packetNum;
// get the reliable sequence acknowledge number
- clc.reliableAcknowledge = MSG_ReadLong( msg );
+ clc.reliableAcknowledge = MSG_ReadLong(msg);
// read in the new snapshot to a temporary buffer
// we will only copy to cl.frame if it is valid
- memset (&newSnap, 0, sizeof(newSnap));
+ memset(&newSnap, 0, sizeof(newSnap));
newSnap.serverCommandNum = clc.serverCommandSequence;
- newSnap.serverTime = MSG_ReadLong( msg );
+ newSnap.serverTime = MSG_ReadLong(msg);
// if we were just unpaused, we can only *now* really let the
// change come into effect or the client hangs.
cl_paused->modified = qfalse;
- newSnap.messageNum = MSG_ReadLong( msg );
- deltaNum = MSG_ReadByte( msg );
- if ( !deltaNum ) {
+ newSnap.messageNum = MSG_ReadLong(msg);
+ deltaNum = MSG_ReadByte(msg);
+ if (!deltaNum) {
newSnap.deltaNum = -1;
} else {
newSnap.deltaNum = newSnap.messageNum - deltaNum;
}
- newSnap.cmdNum = MSG_ReadLong( msg );
- newSnap.snapFlags = MSG_ReadByte( msg );
+ newSnap.cmdNum = MSG_ReadLong(msg);
+ newSnap.snapFlags = MSG_ReadByte(msg);
// If the frame is delta compressed from data that we
// no longer have available, we must suck up the rest of
// the frame, but not use it, then ask for a non-compressed
// message
- if ( newSnap.deltaNum <= 0 ) {
- newSnap.valid = qtrue; // uncompressed frame
+ if (newSnap.deltaNum <= 0) {
+ newSnap.valid = qtrue; // uncompressed frame
old = NULL;
} else {
old = &cl.frames[newSnap.deltaNum & PACKET_MASK];
- if ( !old->valid ) {
+ if (!old->valid) {
// should never happen
- Com_Printf ("Delta from invalid frame (not supposed to happen!).\n");
- } else if ( old->messageNum != newSnap.deltaNum ) {
+ Com_Printf("Delta from invalid frame (not supposed to happen!).\n");
+ } else if (old->messageNum != newSnap.deltaNum) {
// The frame that the server did the delta from
// is too old, so we can't reconstruct it properly.
- Com_Printf ("Delta frame too old.\n");
- } else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES ) {
- Com_Printf ("Delta parseEntitiesNum too old.\n");
+ Com_Printf("Delta frame too old.\n");
+ } else if (cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES) {
+ Com_Printf("Delta parseEntitiesNum too old.\n");
} else {
- newSnap.valid = qtrue; // valid delta parse
+ newSnap.valid = qtrue; // valid delta parse
}
}
// read areamask
- len = MSG_ReadByte( msg );
- MSG_ReadData( msg, &newSnap.areamask, len);
+ len = MSG_ReadByte(msg);
+ MSG_ReadData(msg, &newSnap.areamask, len);
// read playerinfo
- SHOWNET( msg, "playerstate" );
- if ( old ) {
- MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );
+ SHOWNET(msg, "playerstate");
+ if (old) {
+ MSG_ReadDeltaPlayerstate(msg, &old->ps, &newSnap.ps);
} else {
- MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );
+ MSG_ReadDeltaPlayerstate(msg, NULL, &newSnap.ps);
}
// read packet entities
- SHOWNET( msg, "packet entities" );
- CL_ParsePacketEntities( msg, old, &newSnap );
+ SHOWNET(msg, "packet entities");
+ CL_ParsePacketEntities(msg, old, &newSnap);
// if not valid, dump the entire thing now that it has
// been properly read
- if ( !newSnap.valid ) {
+ if (!newSnap.valid) {
return;
}
@@ -280,10 +264,10 @@ void CL_ParseSnapshot( msg_t *msg ) {
// received and this one
oldMessageNum = cl.frame.messageNum + 1;
- if ( cl.frame.messageNum - oldMessageNum >= PACKET_BACKUP ) {
- oldMessageNum = cl.frame.messageNum - ( PACKET_BACKUP - 1 );
+ if (cl.frame.messageNum - oldMessageNum >= PACKET_BACKUP) {
+ oldMessageNum = cl.frame.messageNum - (PACKET_BACKUP - 1);
}
- for ( ; oldMessageNum < newSnap.messageNum ; oldMessageNum++ ) {
+ for (; oldMessageNum < newSnap.messageNum; oldMessageNum++) {
cl.frames[oldMessageNum & PACKET_MASK].valid = qfalse;
}
@@ -291,10 +275,10 @@ void CL_ParseSnapshot( msg_t *msg ) {
cl.frame = newSnap;
// calculate ping time
- for ( i = 0 ; i < PACKET_BACKUP ; i++ ) {
- packetNum = ( clc.netchan.outgoingSequence - 1 - i ) & PACKET_MASK;
- if ( cl.frame.cmdNum == cl.packetCmdNumber[ packetNum ] ) {
- cl.frame.ping = cls.realtime - cl.packetTime[ packetNum ];
+ for (i = 0; i < PACKET_BACKUP; i++) {
+ packetNum = (clc.netchan.outgoingSequence - 1 - i) & PACKET_MASK;
+ if (cl.frame.cmdNum == cl.packetCmdNumber[packetNum]) {
+ cl.frame.ping = cls.realtime - cl.packetTime[packetNum];
break;
}
}
@@ -302,15 +286,13 @@ void CL_ParseSnapshot( msg_t *msg ) {
cl.frames[cl.frame.messageNum & PACKET_MASK] = cl.frame;
if (cl_shownet->integer == 3) {
- Com_Printf (" frame:%i delta:%i\n", cl.frame.messageNum,
- cl.frame.deltaNum);
+ Com_Printf(" frame:%i delta:%i\n", cl.frame.messageNum, cl.frame.deltaNum);
}
// actions for valid frames
cl.newSnapshots = qtrue;
}
-
//=====================================================================
int cl_connectedToCheatServer;
@@ -324,94 +306,93 @@ new information out of it. This will happen at every
gamestate, and possibly during gameplay.
==================
*/
-void CL_SystemInfoChanged( void ) {
- char *systemInfo;
- const char *s;
- char key[MAX_INFO_KEY];
- char value[MAX_INFO_VALUE];
-
- systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ];
- cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );
-
- s = Info_ValueForKey( systemInfo, "helpUsObi" );
- cl_connectedToCheatServer = atoi( s );
- if ( !cl_connectedToCheatServer )
- {
+void CL_SystemInfoChanged(void) {
+ char *systemInfo;
+ const char *s;
+ char key[MAX_INFO_KEY];
+ char value[MAX_INFO_VALUE];
+
+ systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SYSTEMINFO];
+ cl.serverId = atoi(Info_ValueForKey(systemInfo, "sv_serverid"));
+
+ s = Info_ValueForKey(systemInfo, "helpUsObi");
+ cl_connectedToCheatServer = atoi(s);
+ if (!cl_connectedToCheatServer) {
Cvar_SetCheatState();
}
// scan through all the variables in the systeminfo and locally set cvars to match
s = systemInfo;
- while ( s ) {
- Info_NextPair( &s, key, value );
- if ( !key[0] ) {
+ while (s) {
+ Info_NextPair(&s, key, value);
+ if (!key[0]) {
break;
}
- Cvar_Set( key, value );
+ Cvar_Set(key, value);
}
- //if ( Cvar_VariableIntegerValue("ui_iscensored") == 1 )
+ // if ( Cvar_VariableIntegerValue("ui_iscensored") == 1 )
//{
// Cvar_Set( "g_dismemberment", "0");
- //}
+ // }
}
-void UI_UpdateConnectionString( const char *string );
+void UI_UpdateConnectionString(const char *string);
/*
==================
CL_ParseGamestate
==================
*/
-void CL_ParseGamestate( msg_t *msg ) {
- int i;
- int cmd;
- char *s;
+void CL_ParseGamestate(msg_t *msg) {
+ int i;
+ int cmd;
+ char *s;
Con_Close();
- UI_UpdateConnectionString( "" );
+ UI_UpdateConnectionString("");
// wipe local client state
CL_ClearState();
// a gamestate always marks a server command sequence
- clc.serverCommandSequence = MSG_ReadLong( msg );
+ clc.serverCommandSequence = MSG_ReadLong(msg);
// parse all the configstrings and baselines
- cl.gameState.dataCount = 1; // leave a 0 at the beginning for uninitialized configstrings
- while ( 1 ) {
- cmd = MSG_ReadByte( msg );
+ cl.gameState.dataCount = 1; // leave a 0 at the beginning for uninitialized configstrings
+ while (1) {
+ cmd = MSG_ReadByte(msg);
- if ( cmd <= 0 ) {
+ if (cmd <= 0) {
break;
}
- if ( cmd == svc_configstring ) {
- int len;
+ if (cmd == svc_configstring) {
+ int len;
- i = MSG_ReadShort( msg );
- if ( i < 0 || i >= MAX_CONFIGSTRINGS ) {
- Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" );
+ i = MSG_ReadShort(msg);
+ if (i < 0 || i >= MAX_CONFIGSTRINGS) {
+ Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS");
}
- s = MSG_ReadString( msg );
- len = strlen( s );
+ s = MSG_ReadString(msg);
+ len = strlen(s);
- if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
- Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
+ if (len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS) {
+ Com_Error(ERR_DROP, "MAX_GAMESTATE_CHARS exceeded");
}
// append it to the gameState string buffer
- cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;
- memcpy( cl.gameState.stringData + cl.gameState.dataCount, s, len + 1 );
+ cl.gameState.stringOffsets[i] = cl.gameState.dataCount;
+ memcpy(cl.gameState.stringData + cl.gameState.dataCount, s, len + 1);
cl.gameState.dataCount += len + 1;
- if ( cl_shownet->integer == 3 ) {
- Com_Printf ("%3i: CS# %d %s (%d)\n",msg->readcount, i,s,len);
+ if (cl_shownet->integer == 3) {
+ Com_Printf("%3i: CS# %d %s (%d)\n", msg->readcount, i, s, len);
}
- } else if ( cmd == svc_baseline ) {
+ } else if (cmd == svc_baseline) {
assert(0);
} else {
- Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte" );
+ Com_Error(ERR_DROP, "CL_ParseGamestate: bad command byte");
}
}
@@ -430,25 +411,22 @@ void CL_ParseGamestate( msg_t *msg ) {
CL_StartHunkUsers();
// make sure the game starts
- Cvar_Set( "cl_paused", "0" );
+ Cvar_Set("cl_paused", "0");
}
-
//=====================================================================
-void CL_FreeServerCommands(void)
-{
+void CL_FreeServerCommands(void) {
int i;
- for(i=0; i= seq ) {
+ if (clc.serverCommandSequence >= seq) {
return;
}
clc.serverCommandSequence = seq;
- index = seq & (MAX_RELIABLE_COMMANDS-1);
- if ( clc.serverCommands[ index ] ) {
- Z_Free( clc.serverCommands[ index ] );
+ index = seq & (MAX_RELIABLE_COMMANDS - 1);
+ if (clc.serverCommands[index]) {
+ Z_Free(clc.serverCommands[index]);
}
- clc.serverCommands[ index ] = CopyString( s );
+ clc.serverCommands[index] = CopyString(s);
}
-
/*
=====================
CL_ParseServerMessage
=====================
*/
-void CL_ParseServerMessage( msg_t *msg ) {
- int cmd;
+void CL_ParseServerMessage(msg_t *msg) {
+ int cmd;
- if ( cl_shownet->integer == 1 ) {
- Com_Printf ("%i ",msg->cursize);
- } else if ( cl_shownet->integer >= 2 ) {
- Com_Printf ("------------------\n");
+ if (cl_shownet->integer == 1) {
+ Com_Printf("%i ", msg->cursize);
+ } else if (cl_shownet->integer >= 2) {
+ Com_Printf("------------------\n");
}
//
// parse the message
//
- while ( 1 ) {
- if ( msg->readcount > msg->cursize ) {
- Com_Error (ERR_DROP,"CL_ParseServerMessage: read past end of server message");
+ while (1) {
+ if (msg->readcount > msg->cursize) {
+ Com_Error(ERR_DROP, "CL_ParseServerMessage: read past end of server message");
break;
}
- cmd = MSG_ReadByte( msg );
+ cmd = MSG_ReadByte(msg);
- if ( cmd == -1 ) {
- SHOWNET( msg, "END OF MESSAGE" );
+ if (cmd == -1) {
+ SHOWNET(msg, "END OF MESSAGE");
break;
}
- if ( cl_shownet->integer >= 2 ) {
- if ( !svc_strings[cmd] ) {
- Com_Printf( "%3i:BAD CMD %i\n", msg->readcount-1, cmd );
+ if (cl_shownet->integer >= 2) {
+ if (!svc_strings[cmd]) {
+ Com_Printf("%3i:BAD CMD %i\n", msg->readcount - 1, cmd);
} else {
- SHOWNET( msg, svc_strings[cmd] );
+ SHOWNET(msg, svc_strings[cmd]);
}
}
- // other commands
- switch ( cmd ) {
+ // other commands
+ switch (cmd) {
default:
- Com_Error (ERR_DROP,"CL_ParseServerMessage: Illegible server message\n");
+ Com_Error(ERR_DROP, "CL_ParseServerMessage: Illegible server message\n");
break;
case svc_nop:
break;
case svc_serverCommand:
- CL_ParseCommandString( msg );
+ CL_ParseCommandString(msg);
break;
case svc_gamestate:
- CL_ParseGamestate( msg );
+ CL_ParseGamestate(msg);
break;
case svc_snapshot:
- CL_ParseSnapshot( msg );
+ CL_ParseSnapshot(msg);
break;
}
}
}
-
-
diff --git a/code/client/cl_scrn.cpp b/code/client/cl_scrn.cpp
index 730ee7d466..38d044e5a9 100644
--- a/code/client/cl_scrn.cpp
+++ b/code/client/cl_scrn.cpp
@@ -31,13 +31,13 @@ along with this program; if not, see .
extern console_t con;
-qboolean scr_initialized; // ready to draw
+qboolean scr_initialized; // ready to draw
-cvar_t *cl_timegraph;
-cvar_t *cl_debuggraph;
-cvar_t *cl_graphheight;
-cvar_t *cl_graphscale;
-cvar_t *cl_graphshift;
+cvar_t *cl_timegraph;
+cvar_t *cl_debuggraph;
+cvar_t *cl_graphheight;
+cvar_t *cl_graphscale;
+cvar_t *cl_graphshift;
/*
================
@@ -46,16 +46,15 @@ SCR_DrawNamedPic
Coordinates are 640*480 virtual values
=================
*/
-void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {
- qhandle_t hShader;
+void SCR_DrawNamedPic(float x, float y, float width, float height, const char *picname) {
+ qhandle_t hShader;
- assert( width != 0 );
+ assert(width != 0);
- hShader = re.RegisterShader( picname );
- re.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
+ hShader = re.RegisterShader(picname);
+ re.DrawStretchPic(x, y, width, height, 0, 0, 1, 1, hShader);
}
-
/*
================
SCR_FillRect
@@ -63,15 +62,14 @@ SCR_FillRect
Coordinates are 640*480 virtual values
=================
*/
-void SCR_FillRect( float x, float y, float width, float height, const float *color ) {
- re.SetColor( color );
+void SCR_FillRect(float x, float y, float width, float height, const float *color) {
+ re.SetColor(color);
- re.DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cls.whiteShader );
+ re.DrawStretchPic(x, y, width, height, 0, 0, 0, 0, cls.whiteShader);
- re.SetColor( NULL );
+ re.SetColor(NULL);
}
-
/*
================
SCR_DrawPic
@@ -80,28 +78,25 @@ Coordinates are 640*480 virtual values
A width of 0 will draw with the original image width
=================
*/
-void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) {
- re.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
-}
-
+void SCR_DrawPic(float x, float y, float width, float height, qhandle_t hShader) { re.DrawStretchPic(x, y, width, height, 0, 0, 1, 1, hShader); }
/*
** SCR_DrawBigChar
** big chars are drawn at 640*480 virtual screen size
*/
-void SCR_DrawBigChar( int x, int y, int ch ) {
+void SCR_DrawBigChar(int x, int y, int ch) {
int row, col;
float frow, fcol;
float size;
- float ax, ay, aw, ah;
+ float ax, ay, aw, ah;
ch &= 255;
- if ( ch == ' ' ) {
+ if (ch == ' ') {
return;
}
- if ( y < -BIGCHAR_HEIGHT ) {
+ if (y < -BIGCHAR_HEIGHT) {
return;
}
@@ -110,81 +105,71 @@ void SCR_DrawBigChar( int x, int y, int ch ) {
aw = BIGCHAR_WIDTH;
ah = BIGCHAR_HEIGHT;
- row = ch>>4;
- col = ch&15;
+ row = ch >> 4;
+ col = ch & 15;
- frow = row*0.0625;
- fcol = col*0.0625;
+ frow = row * 0.0625;
+ fcol = col * 0.0625;
size = 0.0625;
-/*
- re.DrawStretchPic( ax, ay, aw, ah,
- fcol, frow,
- fcol + size, frow + size,
- cls.charSetShader );
-*/
+ /*
+ re.DrawStretchPic( ax, ay, aw, ah,
+ fcol, frow,
+ fcol + size, frow + size,
+ cls.charSetShader );
+ */
float size2;
- frow = row*0.0625;
- fcol = col*0.0625;
+ frow = row * 0.0625;
+ fcol = col * 0.0625;
size = 0.03125;
size2 = 0.0625;
- re.DrawStretchPic( ax, ay, aw, ah,
- fcol, frow,
- fcol + size, frow + size2,
- cls.charSetShader );
-
+ re.DrawStretchPic(ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, cls.charSetShader);
}
/*
** SCR_DrawSmallChar
** small chars are drawn at native screen resolution
*/
-void SCR_DrawSmallChar( int x, int y, int ch ) {
+void SCR_DrawSmallChar(int x, int y, int ch) {
int row, col;
float frow, fcol;
float size;
ch &= 255;
- if ( ch == ' ' ) {
+ if (ch == ' ') {
return;
}
- if ( y < -con.charHeight ) {
+ if (y < -con.charHeight) {
return;
}
- row = ch>>4;
- col = ch&15;
-/*
- frow = row*0.0625;
- fcol = col*0.0625;
- size = 0.0625;
+ row = ch >> 4;
+ col = ch & 15;
+ /*
+ frow = row*0.0625;
+ fcol = col*0.0625;
+ size = 0.0625;
- re.DrawStretchPic( x, y, con.charWidth, con.charHeight,
- fcol, frow,
- fcol + size, frow + size,
- cls.charSetShader );
-*/
+ re.DrawStretchPic( x, y, con.charWidth, con.charHeight,
+ fcol, frow,
+ fcol + size, frow + size,
+ cls.charSetShader );
+ */
float size2;
- frow = row*0.0625;
- fcol = col*0.0625;
+ frow = row * 0.0625;
+ fcol = col * 0.0625;
size = 0.03125;
size2 = 0.0625;
- re.DrawStretchPic( x * con.xadjust, y * con.yadjust,
- con.charWidth * con.xadjust, con.charHeight * con.yadjust,
- fcol, frow,
- fcol + size, frow + size2,
- cls.charSetShader );
-
+ re.DrawStretchPic(x * con.xadjust, y * con.yadjust, con.charWidth * con.xadjust, con.charHeight * con.yadjust, fcol, frow, fcol + size, frow + size2,
+ cls.charSetShader);
}
-
-
/*
==================
SCR_DrawBigString[Color]
@@ -195,63 +180,59 @@ to a fixed color.
Coordinates are at 640 by 480 virtual resolution
==================
*/
-void SCR_DrawBigStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape ) {
- vec4_t color;
- const char *s;
- int xx;
+void SCR_DrawBigStringExt(int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape) {
+ vec4_t color;
+ const char *s;
+ int xx;
// draw the drop shadow
color[0] = color[1] = color[2] = 0;
color[3] = setColor[3];
- re.SetColor( color );
+ re.SetColor(color);
s = string;
xx = x;
- while ( *s ) {
- if ( !noColorEscape && Q_IsColorString( s ) ) {
+ while (*s) {
+ if (!noColorEscape && Q_IsColorString(s)) {
s += 2;
continue;
}
- SCR_DrawBigChar( xx+2, y+2, *s );
+ SCR_DrawBigChar(xx + 2, y + 2, *s);
xx += BIGCHAR_WIDTH;
s++;
}
-
// draw the colored text
s = string;
xx = x;
- re.SetColor( setColor );
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
- if ( !forceColor ) {
- memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
+ re.SetColor(setColor);
+ while (*s) {
+ if (Q_IsColorString(s)) {
+ if (!forceColor) {
+ memcpy(color, g_color_table[ColorIndex(*(s + 1))], sizeof(color));
color[3] = setColor[3];
- re.SetColor( color );
+ re.SetColor(color);
}
- if ( !noColorEscape ) {
+ if (!noColorEscape) {
s += 2;
continue;
}
}
- SCR_DrawBigChar( xx, y, *s );
+ SCR_DrawBigChar(xx, y, *s);
xx += BIGCHAR_WIDTH;
s++;
}
- re.SetColor( NULL );
+ re.SetColor(NULL);
}
-
-void SCR_DrawBigString( int x, int y, const char *s, float alpha, qboolean noColorEscape ) {
- float color[4];
+void SCR_DrawBigString(int x, int y, const char *s, float alpha, qboolean noColorEscape) {
+ float color[4];
color[0] = color[1] = color[2] = 1.0;
color[3] = alpha;
- SCR_DrawBigStringExt( x, y, s, color, qfalse, noColorEscape );
+ SCR_DrawBigStringExt(x, y, s, color, qfalse, noColorEscape);
}
-void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color, qboolean noColorEscape ) {
- SCR_DrawBigStringExt( x, y, s, color, qtrue, noColorEscape );
-}
+void SCR_DrawBigStringColor(int x, int y, const char *s, vec4_t color, qboolean noColorEscape) { SCR_DrawBigStringExt(x, y, s, color, qtrue, noColorEscape); }
/*
==================
@@ -261,44 +242,43 @@ Draws a multi-colored string with a drop shadow, optionally forcing
to a fixed color.
==================
*/
-void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor,
- qboolean noColorEscape ) {
- vec4_t color;
- const char *s;
- int xx;
+void SCR_DrawSmallStringExt(int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape) {
+ vec4_t color;
+ const char *s;
+ int xx;
// draw the colored text
s = string;
xx = x;
- re.SetColor( setColor );
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
- if ( !forceColor ) {
- memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
+ re.SetColor(setColor);
+ while (*s) {
+ if (Q_IsColorString(s)) {
+ if (!forceColor) {
+ memcpy(color, g_color_table[ColorIndex(*(s + 1))], sizeof(color));
color[3] = setColor[3];
- re.SetColor( color );
+ re.SetColor(color);
}
- if ( !noColorEscape ) {
+ if (!noColorEscape) {
s += 2;
continue;
}
}
- SCR_DrawSmallChar( xx, y, *s );
+ SCR_DrawSmallChar(xx, y, *s);
xx += con.charWidth;
s++;
}
- re.SetColor( NULL );
+ re.SetColor(NULL);
}
/*
** SCR_Strlen -- skips color escape codes
*/
-static int SCR_Strlen( const char *str ) {
+static int SCR_Strlen(const char *str) {
const char *s = str;
int count = 0;
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
+ while (*s) {
+ if (Q_IsColorString(s)) {
s += 2;
} else {
count++;
@@ -312,13 +292,10 @@ static int SCR_Strlen( const char *str ) {
/*
** SCR_GetBigStringWidth
*/
-int SCR_GetBigStringWidth( const char *str ) {
- return SCR_Strlen( str ) * BIGCHAR_WIDTH;
-}
+int SCR_GetBigStringWidth(const char *str) { return SCR_Strlen(str) * BIGCHAR_WIDTH; }
//===============================================================================
-
/*
===============================================================================
@@ -326,24 +303,22 @@ DEBUG GRAPH
===============================================================================
*/
-typedef struct
-{
- float value;
- int color;
+typedef struct {
+ float value;
+ int color;
} graphsamp_t;
-static int current;
-static graphsamp_t values[1024];
+static int current;
+static graphsamp_t values[1024];
/*
==============
SCR_DebugGraph
==============
*/
-void SCR_DebugGraph (float value, int color)
-{
- values[current&1023].value = value;
- values[current&1023].color = color;
+void SCR_DebugGraph(float value, int color) {
+ values[current & 1023].value = value;
+ values[current & 1023].color = color;
current++;
}
@@ -352,10 +327,9 @@ void SCR_DebugGraph (float value, int color)
SCR_DrawDebugGraph
==============
*/
-void SCR_DrawDebugGraph (void)
-{
- int a, x, y, w, i, h;
- float v;
+void SCR_DrawDebugGraph(void) {
+ int a, x, y, w, i, h;
+ float v;
//
// draw the graph
@@ -363,21 +337,19 @@ void SCR_DrawDebugGraph (void)
w = cls.glconfig.vidWidth;
x = 0;
y = cls.glconfig.vidHeight;
- re.SetColor( g_color_table[0] );
- re.DrawStretchPic(x, y - cl_graphheight->integer,
- w, cl_graphheight->integer, 0, 0, 0, 0, 0 );
- re.SetColor( NULL );
-
- for (a=0 ; ainteger, w, cl_graphheight->integer, 0, 0, 0, 0, 0);
+ re.SetColor(NULL);
+
+ for (a = 0; a < w; a++) {
+ i = (current - 1 - a + 1024) & 1023;
v = values[i].value;
v = v * cl_graphscale->integer + cl_graphshift->integer;
if (v < 0)
- v += cl_graphheight->integer * (1+(int)(-v / cl_graphheight->integer));
+ v += cl_graphheight->integer * (1 + (int)(-v / cl_graphheight->integer));
h = (int)v % cl_graphheight->integer;
- re.DrawStretchPic( x+w-1-a, y - h, 1, h, 0, 0, 0, 0, 0 );
+ re.DrawStretchPic(x + w - 1 - a, y - h, 1, h, 0, 0, 0, 0, 0);
}
}
//=============================================================================
@@ -387,22 +359,21 @@ void SCR_DrawDebugGraph (void)
SCR_Init
==================
*/
-void SCR_Init( void ) {
- cl_timegraph = Cvar_Get ("timegraph", "0", CVAR_CHEAT);
- cl_debuggraph = Cvar_Get ("debuggraph", "0", CVAR_CHEAT);
- cl_graphheight = Cvar_Get ("graphheight", "32", CVAR_CHEAT);
- cl_graphscale = Cvar_Get ("graphscale", "1", CVAR_CHEAT);
- cl_graphshift = Cvar_Get ("graphshift", "0", CVAR_CHEAT);
+void SCR_Init(void) {
+ cl_timegraph = Cvar_Get("timegraph", "0", CVAR_CHEAT);
+ cl_debuggraph = Cvar_Get("debuggraph", "0", CVAR_CHEAT);
+ cl_graphheight = Cvar_Get("graphheight", "32", CVAR_CHEAT);
+ cl_graphscale = Cvar_Get("graphscale", "1", CVAR_CHEAT);
+ cl_graphshift = Cvar_Get("graphshift", "0", CVAR_CHEAT);
scr_initialized = qtrue;
}
-
//=======================================================
-void UI_SetActiveMenu( const char* menuname,const char *menuID );
-void _UI_Refresh( int realtime );
-void UI_DrawConnect( const char *servername, const char * updateInfoString );
+void UI_SetActiveMenu(const char *menuname, const char *menuID);
+void _UI_Refresh(int realtime);
+void UI_DrawConnect(const char *servername, const char *updateInfoString);
/*
==================
@@ -411,45 +382,42 @@ SCR_DrawScreenField
This will be called twice if rendering in stereo mode
==================
*/
-void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
+void SCR_DrawScreenField(stereoFrame_t stereoFrame) {
- re.BeginFrame( stereoFrame );
+ re.BeginFrame(stereoFrame);
qboolean uiFullscreen = _UI_IsFullscreen();
// if the menu is going to cover the entire screen, we
// don't need to render anything under it
- if ( !uiFullscreen ) {
- switch( cls.state ) {
+ if (!uiFullscreen) {
+ switch (cls.state) {
default:
- Com_Error( ERR_FATAL, "SCR_DrawScreenField: bad cls.state" );
+ Com_Error(ERR_FATAL, "SCR_DrawScreenField: bad cls.state");
break;
case CA_CINEMATIC:
SCR_DrawCinematic();
break;
case CA_DISCONNECTED:
// force menu up
- UI_SetActiveMenu( "mainMenu", NULL );
+ UI_SetActiveMenu("mainMenu", NULL);
break;
case CA_CONNECTING:
case CA_CHALLENGING:
case CA_CONNECTED:
// connecting clients will only show the connection dialog
- UI_DrawConnect( clc.servername, cls.updateInfoString );
+ UI_DrawConnect(clc.servername, cls.updateInfoString);
break;
case CA_LOADING:
case CA_PRIMED:
// draw the game information screen and loading progress
- CL_CGameRendering( stereoFrame );
+ CL_CGameRendering(stereoFrame);
break;
case CA_ACTIVE:
- if (CL_IsRunningInGameCinematic() || CL_InGameCinematicOnStandBy())
- {
+ if (CL_IsRunningInGameCinematic() || CL_InGameCinematicOnStandBy()) {
SCR_DrawCinematic();
- }
- else
- {
- CL_CGameRendering( stereoFrame );
+ } else {
+ CL_CGameRendering(stereoFrame);
}
break;
}
@@ -460,14 +428,14 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
// draw downloading progress bar
// the menu draws next
- _UI_Refresh( cls.realtime );
+ _UI_Refresh(cls.realtime);
// console draws next
- Con_DrawConsole ();
+ Con_DrawConsole();
// debug graph can be drawn on top of anything
- if ( cl_debuggraph->integer || cl_timegraph->integer ) {
- SCR_DrawDebugGraph ();
+ if (cl_debuggraph->integer || cl_timegraph->integer) {
+ SCR_DrawDebugGraph();
}
}
@@ -479,37 +447,36 @@ This is called every frame, and can also be called explicitly to flush
text to the screen.
==================
*/
-void SCR_UpdateScreen( void ) {
- static int recursive;
+void SCR_UpdateScreen(void) {
+ static int recursive;
- if ( !scr_initialized ) {
- return; // not initialized yet
+ if (!scr_initialized) {
+ return; // not initialized yet
}
// load the ref / ui / cgame if needed
CL_StartHunkUsers();
- if ( ++recursive > 2 ) {
- Com_Error( ERR_FATAL, "SCR_UpdateScreen: recursively called" );
+ if (++recursive > 2) {
+ Com_Error(ERR_FATAL, "SCR_UpdateScreen: recursively called");
}
recursive = qtrue;
// If there is no VM, there are also no rendering commands issued. Stop the renderer in
// that case.
- if ( cls.uiStarted )
- {
+ if (cls.uiStarted) {
// if running in stereo, we need to draw the frame twice
- if ( cls.glconfig.stereoEnabled ) {
- SCR_DrawScreenField( STEREO_LEFT );
- SCR_DrawScreenField( STEREO_RIGHT );
+ if (cls.glconfig.stereoEnabled) {
+ SCR_DrawScreenField(STEREO_LEFT);
+ SCR_DrawScreenField(STEREO_RIGHT);
} else {
- SCR_DrawScreenField( STEREO_CENTER );
+ SCR_DrawScreenField(STEREO_CENTER);
}
- if ( com_speeds->integer ) {
- re.EndFrame( &time_frontend, &time_backend );
+ if (com_speeds->integer) {
+ re.EndFrame(&time_frontend, &time_backend);
} else {
- re.EndFrame( NULL, NULL );
+ re.EndFrame(NULL, NULL);
}
}
@@ -519,43 +486,33 @@ void SCR_UpdateScreen( void ) {
// this stuff is only used by the savegame (SG) code for screenshots...
//
-
-static byte bScreenData[SG_SCR_WIDTH * SG_SCR_HEIGHT * 4];
+static byte bScreenData[SG_SCR_WIDTH * SG_SCR_HEIGHT * 4];
static qboolean screenDataValid = qfalse;
-void SCR_UnprecacheScreenshot()
-{
- screenDataValid = qfalse;
-}
+void SCR_UnprecacheScreenshot() { screenDataValid = qfalse; }
-
-void SCR_PrecacheScreenshot()
-{
+void SCR_PrecacheScreenshot() {
// No screenshots unless connected to single player local server...
//
-// char *psInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ];
-// int iMaxClients = atoi(Info_ValueForKey( psInfo, "sv_maxclients" ));
+ // char *psInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ];
+ // int iMaxClients = atoi(Info_ValueForKey( psInfo, "sv_maxclients" ));
// (no need to check single-player status in voyager, this code base is all singleplayer)
- if ( cls.state != CA_ACTIVE )
- {
+ if (cls.state != CA_ACTIVE) {
return;
}
- if (!Key_GetCatcher( ))
- {
+ if (!Key_GetCatcher()) {
// in-game...
//
-// SCR_UnprecacheScreenshot();
-// pbScreenData = (byte *)Z_Malloc(SG_SCR_WIDTH * SG_SCR_HEIGHT * 4);
- S_ClearSoundBuffer(); // clear DMA etc because the following glReadPixels() call can take ages
- re.GetScreenShot( (byte *) &bScreenData, SG_SCR_WIDTH, SG_SCR_HEIGHT);
+ // SCR_UnprecacheScreenshot();
+ // pbScreenData = (byte *)Z_Malloc(SG_SCR_WIDTH * SG_SCR_HEIGHT * 4);
+ S_ClearSoundBuffer(); // clear DMA etc because the following glReadPixels() call can take ages
+ re.GetScreenShot((byte *)&bScreenData, SG_SCR_WIDTH, SG_SCR_HEIGHT);
screenDataValid = qtrue;
}
-
}
-byte *SCR_GetScreenshot(qboolean *qValid)
-{
+byte *SCR_GetScreenshot(qboolean *qValid) {
if (!screenDataValid) {
SCR_PrecacheScreenshot();
}
@@ -567,36 +524,25 @@ byte *SCR_GetScreenshot(qboolean *qValid)
// called from save-game code to set the lo-res loading screen to be the one from the save file...
//
-void SCR_SetScreenshot(const byte *pbData, int w, int h)
-{
- if (w == SG_SCR_WIDTH && h == SG_SCR_HEIGHT)
- {
+void SCR_SetScreenshot(const byte *pbData, int w, int h) {
+ if (w == SG_SCR_WIDTH && h == SG_SCR_HEIGHT) {
screenDataValid = qtrue;
- memcpy(&bScreenData, pbData, SG_SCR_WIDTH*SG_SCR_HEIGHT*4);
- }
- else
- {
+ memcpy(&bScreenData, pbData, SG_SCR_WIDTH * SG_SCR_HEIGHT * 4);
+ } else {
screenDataValid = qfalse;
- memset(&bScreenData, 0, SG_SCR_WIDTH*SG_SCR_HEIGHT*4);
+ memset(&bScreenData, 0, SG_SCR_WIDTH * SG_SCR_HEIGHT * 4);
}
}
-
#ifdef JK2_MODE
// This is just a client-side wrapper for the function RE_TempRawImage_ReadFromFile() in the renderer code...
//
-byte* SCR_TempRawImage_ReadFromFile(const char *psLocalFilename, int *piWidth, int *piHeight, byte *pbReSampleBuffer, qboolean qbVertFlip)
-{
+byte *SCR_TempRawImage_ReadFromFile(const char *psLocalFilename, int *piWidth, int *piHeight, byte *pbReSampleBuffer, qboolean qbVertFlip) {
return re.TempRawImage_ReadFromFile(psLocalFilename, piWidth, piHeight, pbReSampleBuffer, qbVertFlip);
}
//
// ditto (sort of)...
//
-void SCR_TempRawImage_CleanUp()
-{
- re.TempRawImage_CleanUp();
-}
+void SCR_TempRawImage_CleanUp() { re.TempRawImage_CleanUp(); }
#endif
-
-
diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp
index 80d002f1f3..ac1703c7e0 100644
--- a/code/client/cl_ui.cpp
+++ b/code/client/cl_ui.cpp
@@ -29,17 +29,16 @@ along with this program; if not, see .
#include "vmachine.h"
-intptr_t CL_UISystemCalls( intptr_t *args );
+intptr_t CL_UISystemCalls(intptr_t *args);
-//prototypes
+// prototypes
#ifdef JK2_MODE
-extern qboolean SG_GetSaveImage( const char *psPathlessBaseName, void *pvAddress );
+extern qboolean SG_GetSaveImage(const char *psPathlessBaseName, void *pvAddress);
#endif
extern int SG_GetSaveGameComment(const char *psPathlessBaseName, char *sComment, char *sMapName);
extern qboolean SG_GameAllowedToSaveHere(qboolean inCamera);
extern void SG_StoreSaveGameComment(const char *sComment);
-extern byte *SCR_GetScreenshot(qboolean *qValid); // uncommented --eez
-
+extern byte *SCR_GetScreenshot(qboolean *qValid); // uncommented --eez
/*
====================
@@ -52,40 +51,35 @@ Helper functions for User Interface
GetClientState
====================
*/
-static connstate_t GetClientState( void ) {
- return cls.state;
-}
+static connstate_t GetClientState(void) { return cls.state; }
/*
====================
CL_GetGlConfig
====================
*/
-static void UI_GetGlconfig( glconfig_t *config ) {
- *config = cls.glconfig;
-}
+static void UI_GetGlconfig(glconfig_t *config) { *config = cls.glconfig; }
/*
====================
GetClipboardData
====================
*/
-static void GetClipboardData( char *buf, int buflen ) {
- char *cbd, *c;
+static void GetClipboardData(char *buf, int buflen) {
+ char *cbd, *c;
c = cbd = Sys_GetClipboardData();
- if ( !cbd ) {
+ if (!cbd) {
*buf = 0;
return;
}
- for ( int i = 0, end = buflen - 1; *c && i < end; i++ )
- {
- uint32_t utf32 = ConvertUTF8ToUTF32( c, &c );
- buf[i] = ConvertUTF32ToExpectedCharset( utf32 );
+ for (int i = 0, end = buflen - 1; *c && i < end; i++) {
+ uint32_t utf32 = ConvertUTF8ToUTF32(c, &c);
+ buf[i] = ConvertUTF32ToExpectedCharset(utf32);
}
- Z_Free( cbd );
+ Z_Free(cbd);
}
/*
@@ -96,15 +90,14 @@ Key_KeynumToStringBuf
// only ever called by binding-display code, therefore returns non-technical "friendly" names
// in any language that don't necessarily match those in the config file...
//
-void Key_KeynumToStringBuf( int keynum, char *buf, int buflen )
-{
- const char *psKeyName = Key_KeynumToString( keynum/*, qtrue */);
+void Key_KeynumToStringBuf(int keynum, char *buf, int buflen) {
+ const char *psKeyName = Key_KeynumToString(keynum /*, qtrue */);
// see if there's a more friendly (or localised) name...
//
- const char *psKeyNameFriendly = SE_GetString( va("KEYNAMES_KEYNAME_%s",psKeyName) );
+ const char *psKeyNameFriendly = SE_GetString(va("KEYNAMES_KEYNAME_%s", psKeyName));
- Q_strncpyz( buf, (psKeyNameFriendly && psKeyNameFriendly[0]) ? psKeyNameFriendly : psKeyName, buflen );
+ Q_strncpyz(buf, (psKeyNameFriendly && psKeyNameFriendly[0]) ? psKeyNameFriendly : psKeyName, buflen);
}
/*
@@ -112,14 +105,13 @@ void Key_KeynumToStringBuf( int keynum, char *buf, int buflen )
Key_GetBindingBuf
====================
*/
-void Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
- const char *value;
+void Key_GetBindingBuf(int keynum, char *buf, int buflen) {
+ const char *value;
- value = Key_GetBinding( keynum );
- if ( value ) {
- Q_strncpyz( buf, value, buflen );
- }
- else {
+ value = Key_GetBinding(keynum);
+ if (value) {
+ Q_strncpyz(buf, value, buflen);
+ } else {
*buf = 0;
}
}
@@ -129,20 +121,16 @@ void Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
FloatAsInt
====================
*/
-static int FloatAsInt( float f )
-{
+static int FloatAsInt(float f) {
byteAlias_t fi;
fi.f = f;
return fi.i;
}
-static void UI_Cvar_Create( const char *var_name, const char *var_value, int flags ) {
- Cvar_Register( NULL, var_name, var_value, flags );
-}
+static void UI_Cvar_Create(const char *var_name, const char *var_value, int flags) { Cvar_Register(NULL, var_name, var_value, flags); }
-static int GetConfigString(int index, char *buf, int size)
-{
- int offset;
+static int GetConfigString(int index, char *buf, int size) {
+ int offset;
if (index < 0 || index >= MAX_CONFIGSTRINGS)
return qfalse;
@@ -151,7 +139,7 @@ static int GetConfigString(int index, char *buf, int size)
if (!offset)
return qfalse;
- Q_strncpyz( buf, cl.gameState.stringData+offset, size);
+ Q_strncpyz(buf, cl.gameState.stringData + offset, size);
return qtrue;
}
@@ -161,189 +149,177 @@ static int GetConfigString(int index, char *buf, int size)
CL_ShutdownUI
====================
*/
-void UI_Shutdown( void );
-void CL_ShutdownUI( void ) {
+void UI_Shutdown(void);
+void CL_ShutdownUI(void) {
UI_Shutdown();
- Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_UI );
+ Key_SetCatcher(Key_GetCatcher() & ~KEYCATCH_UI);
cls.uiStarted = qfalse;
}
-void CL_DrawDatapad(int HUDType)
-{
- switch(HUDType)
- {
+void CL_DrawDatapad(int HUDType) {
+ switch (HUDType) {
case DP_HUD:
- VM_Call( CG_DRAW_DATAPAD_HUD );
+ VM_Call(CG_DRAW_DATAPAD_HUD);
break;
case DP_OBJECTIVES:
- VM_Call( CG_DRAW_DATAPAD_OBJECTIVES );
+ VM_Call(CG_DRAW_DATAPAD_OBJECTIVES);
break;
case DP_WEAPONS:
- VM_Call( CG_DRAW_DATAPAD_WEAPONS );
+ VM_Call(CG_DRAW_DATAPAD_WEAPONS);
break;
case DP_INVENTORY:
- VM_Call( CG_DRAW_DATAPAD_INVENTORY );
+ VM_Call(CG_DRAW_DATAPAD_INVENTORY);
break;
case DP_FORCEPOWERS:
- VM_Call( CG_DRAW_DATAPAD_FORCEPOWERS );
+ VM_Call(CG_DRAW_DATAPAD_FORCEPOWERS);
break;
default:
break;
}
-
-
}
-void UI_Init( int apiVersion, uiimport_t *uiimport, qboolean inGameLoad );
+void UI_Init(int apiVersion, uiimport_t *uiimport, qboolean inGameLoad);
/*
====================
CL_InitUI
====================
*/
-void CL_InitUI( void ) {
+void CL_InitUI(void) {
#ifdef JK2_MODE
- JK2SP_Register("keynames", 0 /*SP_REGISTER_REQUIRED*/); // reference is KEYNAMES
+ JK2SP_Register("keynames", 0 /*SP_REGISTER_REQUIRED*/); // reference is KEYNAMES
#endif
- uiimport_t uii;
+ uiimport_t uii;
- memset( &uii, 0, sizeof( uii ) );
+ memset(&uii, 0, sizeof(uii));
uii.Printf = Com_Printf;
uii.Error = Com_Error;
- uii.Cvar_Set = Cvar_Set;
- uii.Cvar_VariableValue = Cvar_VariableValue;
+ uii.Cvar_Set = Cvar_Set;
+ uii.Cvar_VariableValue = Cvar_VariableValue;
uii.Cvar_VariableStringBuffer = Cvar_VariableStringBuffer;
- uii.Cvar_SetValue = Cvar_SetValue;
- uii.Cvar_Reset = Cvar_Reset;
- uii.Cvar_Create = UI_Cvar_Create;
- uii.Cvar_InfoStringBuffer = Cvar_InfoStringBuffer;
-
- uii.Draw_DataPad = CL_DrawDatapad;
-
- uii.Argc = Cmd_Argc;
- uii.Argv = Cmd_ArgvBuffer;
- uii.Cmd_TokenizeString = Cmd_TokenizeString;
-
- uii.Cmd_ExecuteText = Cbuf_ExecuteText;
-
- uii.FS_FOpenFile = FS_FOpenFileByMode;
- uii.FS_Read = FS_Read;
- uii.FS_Write = FS_Write;
- uii.FS_FCloseFile = FS_FCloseFile;
- uii.FS_GetFileList = FS_GetFileList;
- uii.FS_ReadFile = FS_ReadFile;
- uii.FS_FreeFile = FS_FreeFile;
-
- uii.R_RegisterModel = re.RegisterModel;
- uii.R_RegisterSkin = re.RegisterSkin;
- uii.R_RegisterShader = re.RegisterShader;
- uii.R_RegisterShaderNoMip = re.RegisterShaderNoMip;
- uii.R_RegisterFont = re.RegisterFont;
- uii.R_Font_StrLenPixels = re.Font_StrLenPixels;
- uii.R_Font_HeightPixels = re.Font_HeightPixels;
- uii.R_Font_DrawString = re.Font_DrawString;
- uii.R_Font_StrLenChars = re.Font_StrLenChars;
- uii.Language_IsAsian = re.Language_IsAsian;
- uii.Language_UsesSpaces = re.Language_UsesSpaces;
+ uii.Cvar_SetValue = Cvar_SetValue;
+ uii.Cvar_Reset = Cvar_Reset;
+ uii.Cvar_Create = UI_Cvar_Create;
+ uii.Cvar_InfoStringBuffer = Cvar_InfoStringBuffer;
+
+ uii.Draw_DataPad = CL_DrawDatapad;
+
+ uii.Argc = Cmd_Argc;
+ uii.Argv = Cmd_ArgvBuffer;
+ uii.Cmd_TokenizeString = Cmd_TokenizeString;
+
+ uii.Cmd_ExecuteText = Cbuf_ExecuteText;
+
+ uii.FS_FOpenFile = FS_FOpenFileByMode;
+ uii.FS_Read = FS_Read;
+ uii.FS_Write = FS_Write;
+ uii.FS_FCloseFile = FS_FCloseFile;
+ uii.FS_GetFileList = FS_GetFileList;
+ uii.FS_ReadFile = FS_ReadFile;
+ uii.FS_FreeFile = FS_FreeFile;
+
+ uii.R_RegisterModel = re.RegisterModel;
+ uii.R_RegisterSkin = re.RegisterSkin;
+ uii.R_RegisterShader = re.RegisterShader;
+ uii.R_RegisterShaderNoMip = re.RegisterShaderNoMip;
+ uii.R_RegisterFont = re.RegisterFont;
+ uii.R_Font_StrLenPixels = re.Font_StrLenPixels;
+ uii.R_Font_HeightPixels = re.Font_HeightPixels;
+ uii.R_Font_DrawString = re.Font_DrawString;
+ uii.R_Font_StrLenChars = re.Font_StrLenChars;
+ uii.Language_IsAsian = re.Language_IsAsian;
+ uii.Language_UsesSpaces = re.Language_UsesSpaces;
uii.AnyLanguage_ReadCharFromString = re.AnyLanguage_ReadCharFromString;
#ifdef JK2_MODE
- uii.SG_GetSaveImage = SG_GetSaveImage;
+ uii.SG_GetSaveImage = SG_GetSaveImage;
#endif
- uii.SG_GetSaveGameComment = SG_GetSaveGameComment;
+ uii.SG_GetSaveGameComment = SG_GetSaveGameComment;
uii.SG_StoreSaveGameComment = SG_StoreSaveGameComment;
- uii.SG_GameAllowedToSaveHere= SG_GameAllowedToSaveHere;
+ uii.SG_GameAllowedToSaveHere = SG_GameAllowedToSaveHere;
- //uii.SCR_GetScreenshot = SCR_GetScreenshot;
+ // uii.SCR_GetScreenshot = SCR_GetScreenshot;
#ifdef JK2_MODE
- uii.DrawStretchRaw = re.DrawStretchRaw;
+ uii.DrawStretchRaw = re.DrawStretchRaw;
#endif
- uii.R_ClearScene = re.ClearScene;
- uii.R_AddRefEntityToScene = re.AddRefEntityToScene;
- uii.R_AddPolyToScene = re.AddPolyToScene;
- uii.R_AddLightToScene = re.AddLightToScene;
- uii.R_RenderScene = re.RenderScene;
+ uii.R_ClearScene = re.ClearScene;
+ uii.R_AddRefEntityToScene = re.AddRefEntityToScene;
+ uii.R_AddPolyToScene = re.AddPolyToScene;
+ uii.R_AddLightToScene = re.AddLightToScene;
+ uii.R_RenderScene = re.RenderScene;
- uii.R_ModelBounds = re.ModelBounds;
+ uii.R_ModelBounds = re.ModelBounds;
- uii.R_SetColor = re.SetColor;
- uii.R_DrawStretchPic = re.DrawStretchPic;
- uii.UpdateScreen = SCR_UpdateScreen;
+ uii.R_SetColor = re.SetColor;
+ uii.R_DrawStretchPic = re.DrawStretchPic;
+ uii.UpdateScreen = SCR_UpdateScreen;
#ifdef JK2_MODE
- uii.PrecacheScreenshot = SCR_PrecacheScreenshot;
+ uii.PrecacheScreenshot = SCR_PrecacheScreenshot;
#endif
- uii.R_LerpTag = re.LerpTag;
-
- uii.S_StartLocalLoopingSound= S_StartLocalLoopingSound;
- uii.S_StartLocalSound = S_StartLocalSound;
- uii.S_RegisterSound = S_RegisterSound;
-
- uii.Key_KeynumToStringBuf = Key_KeynumToStringBuf;
- uii.Key_GetBindingBuf = Key_GetBindingBuf;
- uii.Key_SetBinding = Key_SetBinding;
- uii.Key_IsDown = Key_IsDown;
- uii.Key_GetOverstrikeMode = Key_GetOverstrikeMode;
- uii.Key_SetOverstrikeMode = Key_SetOverstrikeMode;
- uii.Key_ClearStates = Key_ClearStates;
- uii.Key_GetCatcher = Key_GetCatcher;
- uii.Key_SetCatcher = Key_SetCatcher;
+ uii.R_LerpTag = re.LerpTag;
+
+ uii.S_StartLocalLoopingSound = S_StartLocalLoopingSound;
+ uii.S_StartLocalSound = S_StartLocalSound;
+ uii.S_RegisterSound = S_RegisterSound;
+
+ uii.Key_KeynumToStringBuf = Key_KeynumToStringBuf;
+ uii.Key_GetBindingBuf = Key_GetBindingBuf;
+ uii.Key_SetBinding = Key_SetBinding;
+ uii.Key_IsDown = Key_IsDown;
+ uii.Key_GetOverstrikeMode = Key_GetOverstrikeMode;
+ uii.Key_SetOverstrikeMode = Key_SetOverstrikeMode;
+ uii.Key_ClearStates = Key_ClearStates;
+ uii.Key_GetCatcher = Key_GetCatcher;
+ uii.Key_SetCatcher = Key_SetCatcher;
#ifdef JK2_MODE
- uii.SP_Register = JK2SP_Register;
- uii.SP_GetStringText = JK2SP_GetStringText;
- uii.SP_GetStringTextString = JK2SP_GetStringTextString;
+ uii.SP_Register = JK2SP_Register;
+ uii.SP_GetStringText = JK2SP_GetStringText;
+ uii.SP_GetStringTextString = JK2SP_GetStringTextString;
#endif
- uii.GetClipboardData = GetClipboardData;
+ uii.GetClipboardData = GetClipboardData;
- uii.GetClientState = GetClientState;
+ uii.GetClientState = GetClientState;
- uii.GetGlconfig = UI_GetGlconfig;
+ uii.GetGlconfig = UI_GetGlconfig;
- uii.GetConfigString = (void (*)(int, char *, int))GetConfigString;
+ uii.GetConfigString = (void (*)(int, char *, int))GetConfigString;
- uii.Milliseconds = Sys_Milliseconds2;
+ uii.Milliseconds = Sys_Milliseconds2;
UI_Init(UI_API_VERSION, &uii, (qboolean)(cls.state > CA_DISCONNECTED && cls.state <= CA_ACTIVE));
-// uie->UI_Init( UI_API_VERSION, &uii );
-
+ // uie->UI_Init( UI_API_VERSION, &uii );
}
-
-qboolean UI_GameCommand( void ) {
- if (!cls.uiStarted)
- {
+qboolean UI_GameCommand(void) {
+ if (!cls.uiStarted) {
return qfalse;
}
return UI_ConsoleCommand();
}
-
-void CL_GenericMenu_f(void)
-{
- const char *arg = Cmd_Argv( 1 );
+void CL_GenericMenu_f(void) {
+ const char *arg = Cmd_Argv(1);
if (cls.uiStarted) {
- UI_SetActiveMenu("ingame",arg);
+ UI_SetActiveMenu("ingame", arg);
}
}
-
-void CL_EndScreenDissolve_f(void)
-{
- re.InitDissolve(qtrue); // dissolve from cinematic to underlying ingame
+void CL_EndScreenDissolve_f(void) {
+ re.InitDissolve(qtrue); // dissolve from cinematic to underlying ingame
}
-void CL_DataPad_f(void)
-{
- if (cls.uiStarted && cls.cgameStarted && (cls.state == CA_ACTIVE) ) {
- UI_SetActiveMenu("datapad",NULL);
+void CL_DataPad_f(void) {
+ if (cls.uiStarted && cls.cgameStarted && (cls.state == CA_ACTIVE)) {
+ UI_SetActiveMenu("datapad", NULL);
}
}
@@ -352,10 +328,7 @@ void CL_DataPad_f(void)
CL_GetGlConfig
====================
*/
-static void CL_GetGlconfig( glconfig_t *config )
-{
- *config = cls.glconfig;
-}
+static void CL_GetGlconfig(glconfig_t *config) { *config = cls.glconfig; }
/*
int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
int PC_SourceFileAndLine(int handle, char *filename, int *line);
@@ -367,53 +340,51 @@ CL_UISystemCalls
The ui module is making a system call
====================
*/
-intptr_t CL_UISystemCalls( intptr_t *args )
-{
+intptr_t CL_UISystemCalls(intptr_t *args) {
- switch( args[0] )
- {
+ switch (args[0]) {
case UI_ERROR:
- Com_Error( ERR_DROP, "%s", VMA(1) );
+ Com_Error(ERR_DROP, "%s", VMA(1));
return 0;
case UI_CVAR_REGISTER:
- Cvar_Register( (vmCvar_t *)VMA(1),(const char *) VMA(2),(const char *) VMA(3), args[4] );
+ Cvar_Register((vmCvar_t *)VMA(1), (const char *)VMA(2), (const char *)VMA(3), args[4]);
return 0;
case UI_CVAR_SET:
- Cvar_Set( (const char *) VMA(1), (const char *) VMA(2) );
+ Cvar_Set((const char *)VMA(1), (const char *)VMA(2));
return 0;
case UI_CVAR_SETVALUE:
- Cvar_SetValue( (const char *) VMA(1), VMF(2) );
+ Cvar_SetValue((const char *)VMA(1), VMF(2));
return 0;
case UI_CVAR_UPDATE:
- Cvar_Update( (vmCvar_t *) VMA(1) );
+ Cvar_Update((vmCvar_t *)VMA(1));
return 0;
case UI_R_REGISTERMODEL:
- return re.RegisterModel((const char *) VMA(1) );
+ return re.RegisterModel((const char *)VMA(1));
case UI_R_REGISTERSHADERNOMIP:
- return re.RegisterShaderNoMip((const char *) VMA(1) );
+ return re.RegisterShaderNoMip((const char *)VMA(1));
case UI_GETGLCONFIG:
- CL_GetGlconfig( ( glconfig_t *) VMA(1) );
+ CL_GetGlconfig((glconfig_t *)VMA(1));
return 0;
case UI_CMD_EXECUTETEXT:
- Cbuf_ExecuteText( args[1], (const char *) VMA(2) );
+ Cbuf_ExecuteText(args[1], (const char *)VMA(2));
return 0;
case UI_CVAR_VARIABLEVALUE:
- return FloatAsInt( Cvar_VariableValue( (const char *) VMA(1) ) );
+ return FloatAsInt(Cvar_VariableValue((const char *)VMA(1)));
case UI_FS_GETFILELIST:
- return FS_GetFileList( (const char *) VMA(1), (const char *) VMA(2), (char *) VMA(3), args[4] );
+ return FS_GetFileList((const char *)VMA(1), (const char *)VMA(2), (char *)VMA(3), args[4]);
case UI_KEY_SETCATCHER:
- Key_SetCatcher( args[1] );
+ Key_SetCatcher(args[1]);
return 0;
case UI_KEY_CLEARSTATES:
@@ -421,34 +392,34 @@ intptr_t CL_UISystemCalls( intptr_t *args )
return 0;
case UI_R_SETCOLOR:
- re.SetColor( (const float *) VMA(1) );
+ re.SetColor((const float *)VMA(1));
return 0;
case UI_R_DRAWSTRETCHPIC:
- re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );
+ re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]);
return 0;
case UI_CVAR_VARIABLESTRINGBUFFER:
- Cvar_VariableStringBuffer( (const char *) VMA(1), (char *) VMA(2), args[3] );
+ Cvar_VariableStringBuffer((const char *)VMA(1), (char *)VMA(2), args[3]);
return 0;
- case UI_R_MODELBOUNDS:
- re.ModelBounds( args[1], (float *) VMA(2),(float *) VMA(3) );
+ case UI_R_MODELBOUNDS:
+ re.ModelBounds(args[1], (float *)VMA(2), (float *)VMA(3));
return 0;
case UI_R_CLEARSCENE:
re.ClearScene();
return 0;
-// case UI_KEY_GETOVERSTRIKEMODE:
-// return Key_GetOverstrikeMode();
-// return 0;
+ // case UI_KEY_GETOVERSTRIKEMODE:
+ // return Key_GetOverstrikeMode();
+ // return 0;
-// case UI_PC_READ_TOKEN:
-// return PC_ReadTokenHandle( args[1], VMA(2) );
+ // case UI_PC_READ_TOKEN:
+ // return PC_ReadTokenHandle( args[1], VMA(2) );
-// case UI_PC_SOURCE_FILE_AND_LINE:
-// return PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );
+ // case UI_PC_SOURCE_FILE_AND_LINE:
+ // return PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );
case UI_KEY_GETCATCHER:
return Key_GetCatcher();
@@ -457,52 +428,49 @@ intptr_t CL_UISystemCalls( intptr_t *args )
return Sys_Milliseconds();
case UI_S_REGISTERSOUND:
- return S_RegisterSound((const char *) VMA(1));
+ return S_RegisterSound((const char *)VMA(1));
case UI_S_STARTLOCALSOUND:
- S_StartLocalSound( args[1], args[2] );
+ S_StartLocalSound(args[1], args[2]);
return 0;
-// case UI_R_REGISTERFONT:
-// re.RegisterFont( VMA(1), args[2], VMA(3));
-// return 0;
+ // case UI_R_REGISTERFONT:
+ // re.RegisterFont( VMA(1), args[2], VMA(3));
+ // return 0;
case UI_CIN_PLAYCINEMATIC:
- Com_DPrintf("UI_CIN_PlayCinematic\n");
- return CIN_PlayCinematic((const char *)VMA(1), args[2], args[3], args[4], args[5], args[6], (const char *)VMA(7));
+ Com_DPrintf("UI_CIN_PlayCinematic\n");
+ return CIN_PlayCinematic((const char *)VMA(1), args[2], args[3], args[4], args[5], args[6], (const char *)VMA(7));
case UI_CIN_STOPCINEMATIC:
- return CIN_StopCinematic(args[1]);
+ return CIN_StopCinematic(args[1]);
case UI_CIN_RUNCINEMATIC:
- return CIN_RunCinematic(args[1]);
+ return CIN_RunCinematic(args[1]);
case UI_CIN_DRAWCINEMATIC:
- CIN_DrawCinematic(args[1]);
- return 0;
+ CIN_DrawCinematic(args[1]);
+ return 0;
case UI_KEY_SETBINDING:
- Key_SetBinding( args[1], (const char *) VMA(2) );
+ Key_SetBinding(args[1], (const char *)VMA(2));
return 0;
case UI_KEY_KEYNUMTOSTRINGBUF:
- Key_KeynumToStringBuf( args[1],(char *) VMA(2), args[3] );
+ Key_KeynumToStringBuf(args[1], (char *)VMA(2), args[3]);
return 0;
case UI_CIN_SETEXTENTS:
- CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
- return 0;
+ CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
+ return 0;
case UI_KEY_GETBINDINGBUF:
- Key_GetBindingBuf( args[1], (char *) VMA(2), args[3] );
+ Key_GetBindingBuf(args[1], (char *)VMA(2), args[3]);
return 0;
-
default:
- Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] );
-
+ Com_Error(ERR_DROP, "Bad UI system trap: %i", args[0]);
}
return 0;
}
-
diff --git a/code/client/snd_ambient.cpp b/code/client/snd_ambient.cpp
index 6e2c612d3d..763d7d46a2 100644
--- a/code/client/snd_ambient.cpp
+++ b/code/client/snd_ambient.cpp
@@ -27,77 +27,62 @@ along with this program; if not, see .
#include "snd_ambient.h"
#include "snd_local.h"
-static const int MAX_SET_VOLUME = 255;
+static const int MAX_SET_VOLUME = 255;
-static void AS_GetGeneralSet( ambientSet_t & );
-static void AS_GetLocalSet( ambientSet_t & );
-static void AS_GetBModelSet( ambientSet_t & );
+static void AS_GetGeneralSet(ambientSet_t &);
+static void AS_GetLocalSet(ambientSet_t &);
+static void AS_GetBModelSet(ambientSet_t &);
-//Current set and old set for crossfading
-static int currentSet = -1;
-static int oldSet = -1;
-static int crossDelay = 1000; //1 second
+// Current set and old set for crossfading
+static int currentSet = -1;
+static int oldSet = -1;
+static int crossDelay = 1000; // 1 second
static int currentSetTime = 0;
static int oldSetTime = 0;
// Globals for debug purposes
-static int numSets = 0;
+static int numSets = 0;
// Main ambient sound group
-static CSetGroup* aSets = NULL;
+static CSetGroup *aSets = NULL;
// Globals for speed, blech
-static char *parseBuffer = NULL;
-static int parseSize = 0;
-static int parsePos = 0;
-static char tempBuffer[1024];
+static char *parseBuffer = NULL;
+static int parseSize = 0;
+static int parsePos = 0;
+static char tempBuffer[1024];
-//NOTENOTE: Be sure to change the mirrored code in g_spawn.cpp, and cg_main.cpp
-typedef std::map namePrecache_m;
-static namePrecache_m *pMap;
+// NOTENOTE: Be sure to change the mirrored code in g_spawn.cpp, and cg_main.cpp
+typedef std::map namePrecache_m;
+static namePrecache_m *pMap;
// Used for enum / string matching
-static const char *setNames[NUM_AS_SETS] =
- {
- "generalSet",
- "localSet",
- "bmodelSet",
- };
+static const char *setNames[NUM_AS_SETS] = {
+ "generalSet",
+ "localSet",
+ "bmodelSet",
+};
// Used for enum / function matching
-static const parseFunc_t parseFuncs[NUM_AS_SETS] =
- {
- AS_GetGeneralSet,
- AS_GetLocalSet,
- AS_GetBModelSet,
- };
+static const parseFunc_t parseFuncs[NUM_AS_SETS] = {
+ AS_GetGeneralSet,
+ AS_GetLocalSet,
+ AS_GetBModelSet,
+};
// Used for keyword / enum matching
-static const char *keywordNames[NUM_AS_KEYWORDS]=
- {
- "timeBetweenWaves",
- "subWaves",
- "loopedWave",
- "volRange",
- "radius",
- "type",
- "amsdir",
- "outdir",
- "basedir",
- };
-
-
-CSetGroup::CSetGroup(void)
-{
- m_ambientSets = new std::vector;
- m_setMap = new std::map;
+static const char *keywordNames[NUM_AS_KEYWORDS] = {
+ "timeBetweenWaves", "subWaves", "loopedWave", "volRange", "radius", "type", "amsdir", "outdir", "basedir",
+};
+
+CSetGroup::CSetGroup(void) {
+ m_ambientSets = new std::vector;
+ m_setMap = new std::map;
m_numSets = 0;
}
-
-CSetGroup::~CSetGroup(void)
-{
+CSetGroup::~CSetGroup(void) {
delete m_ambientSets;
delete m_setMap;
}
@@ -108,20 +93,18 @@ Free
-------------------------
*/
-void CSetGroup::Free( void )
-{
- std::vector::iterator ai;
+void CSetGroup::Free(void) {
+ std::vector::iterator ai;
- for ( ai = m_ambientSets->begin(); ai != m_ambientSets->end(); ++ai )
- {
- Z_Free ( (*ai) );
+ for (ai = m_ambientSets->begin(); ai != m_ambientSets->end(); ++ai) {
+ Z_Free((*ai));
}
- //Do this in place of clear() so it *really* frees the memory.
+ // Do this in place of clear() so it *really* frees the memory.
delete m_ambientSets;
delete m_setMap;
- m_ambientSets = new std::vector;
- m_setMap = new std::map;
+ m_ambientSets = new std::vector;
+ m_setMap = new std::map;
m_numSets = 0;
}
@@ -132,29 +115,28 @@ AddSet
-------------------------
*/
-ambientSet_t *CSetGroup::AddSet( const char *name )
-{
- ambientSet_t *set;
+ambientSet_t *CSetGroup::AddSet(const char *name) {
+ ambientSet_t *set;
- //Allocate the memory
- set = (ambientSet_t *) Z_Malloc( sizeof( ambientSet_t ), TAG_AMBIENTSET, qtrue);
+ // Allocate the memory
+ set = (ambientSet_t *)Z_Malloc(sizeof(ambientSet_t), TAG_AMBIENTSET, qtrue);
- //Set up some defaults
- Q_strncpyz(set->name,name,sizeof(set->name));
+ // Set up some defaults
+ Q_strncpyz(set->name, name, sizeof(set->name));
set->loopedVolume = MAX_SET_VOLUME;
set->masterVolume = MAX_SET_VOLUME;
set->radius = 250;
set->time_start = 10;
- set->time_end = 25;
+ set->time_end = 25;
set->volRange_start = MAX_SET_VOLUME;
- set->volRange_end = MAX_SET_VOLUME;
+ set->volRange_end = MAX_SET_VOLUME;
- m_ambientSets->insert( m_ambientSets->end(), set );
+ m_ambientSets->insert(m_ambientSets->end(), set);
set->id = m_numSets++;
- //Map the name to the pointer for reference later
+ // Map the name to the pointer for reference later
(*m_setMap)[name] = set;
return set;
@@ -166,36 +148,33 @@ GetSet
-------------------------
*/
-ambientSet_t *CSetGroup::GetSet( const char *name )
-{
- std::map::iterator mi;
+ambientSet_t *CSetGroup::GetSet(const char *name) {
+ std::map::iterator mi;
- if ( name == NULL )
+ if (name == NULL)
return NULL;
- mi = m_setMap->find( name );
+ mi = m_setMap->find(name);
- if ( mi == m_setMap->end() )
+ if (mi == m_setMap->end())
return NULL;
return (*mi).second;
}
-ambientSet_t *CSetGroup::GetSet( int ID )
-{
- if ( m_ambientSets->empty() )
+ambientSet_t *CSetGroup::GetSet(int ID) {
+ if (m_ambientSets->empty())
return NULL;
- if ( ID < 0 )
+ if (ID < 0)
return NULL;
- if ( ID >= m_numSets )
+ if (ID >= m_numSets)
return NULL;
return (*m_ambientSets)[ID];
}
-
/*
===============================================
@@ -210,15 +189,13 @@ AS_GetSetNameIDForString
-------------------------
*/
-static int AS_GetSetNameIDForString( const char *name )
-{
- //Make sure it's valid
- if ( name == NULL || name[0] == '\0' )
+static int AS_GetSetNameIDForString(const char *name) {
+ // Make sure it's valid
+ if (name == NULL || name[0] == '\0')
return -1;
- for ( int i = 0; i < NUM_AS_SETS; i++ )
- {
- if ( Q_stricmp( name, setNames[i] ) == 0 )
+ for (int i = 0; i < NUM_AS_SETS; i++) {
+ if (Q_stricmp(name, setNames[i]) == 0)
return i;
}
@@ -231,15 +208,13 @@ AS_GetKeywordIDForString
-------------------------
*/
-static int AS_GetKeywordIDForString( const char *name )
-{
- //Make sure it's valid
- if ( name == NULL || name[0] == '\0' )
+static int AS_GetKeywordIDForString(const char *name) {
+ // Make sure it's valid
+ if (name == NULL || name[0] == '\0')
return -1;
- for ( int i = 0; i < NUM_AS_KEYWORDS; i++ )
- {
- if ( Q_stricmp( name, keywordNames[i] ) == 0 )
+ for (int i = 0; i < NUM_AS_KEYWORDS; i++) {
+ if (Q_stricmp(name, keywordNames[i]) == 0)
return i;
}
@@ -254,16 +229,14 @@ Skips a line in the character buffer
-------------------------
*/
-static void AS_SkipLine( void )
-{
- if ( parsePos > parseSize ) // needed to avoid a crash because of some OOR access that shouldn't be done
+static void AS_SkipLine(void) {
+ if (parsePos > parseSize) // needed to avoid a crash because of some OOR access that shouldn't be done
return;
- while ( (parseBuffer[parsePos] != '\n') && (parseBuffer[parsePos] != '\r') )
- {
+ while ((parseBuffer[parsePos] != '\n') && (parseBuffer[parsePos] != '\r')) {
parsePos++;
- if ( parsePos > parseSize )
+ if (parsePos > parseSize)
return;
}
@@ -278,28 +251,26 @@ getTimeBetweenWaves
-------------------------
*/
-static void AS_GetTimeBetweenWaves( ambientSet_t &set )
-{
- int startTime, endTime;
+static void AS_GetTimeBetweenWaves(ambientSet_t &set) {
+ int startTime, endTime;
- //Get the data
- sscanf( parseBuffer+parsePos, "%s %d %d", tempBuffer, &startTime, &endTime );
+ // Get the data
+ sscanf(parseBuffer + parsePos, "%s %d %d", tempBuffer, &startTime, &endTime);
- //Check for swapped start / end
- if ( startTime > endTime )
- {
- #ifndef FINAL_BUILD
- Com_Printf(S_COLOR_YELLOW"WARNING: Corrected swapped start / end times in a \"timeBetweenWaves\" keyword\n");
- #endif
+ // Check for swapped start / end
+ if (startTime > endTime) {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "WARNING: Corrected swapped start / end times in a \"timeBetweenWaves\" keyword\n");
+#endif
int swap = startTime;
startTime = endTime;
endTime = swap;
}
- //Store it
- set.time_start = startTime;
- set.time_end = endTime;
+ // Store it
+ set.time_start = startTime;
+ set.time_end = endTime;
AS_SkipLine();
}
@@ -312,48 +283,42 @@ subWaves ...
-------------------------
*/
-static void AS_GetSubWaves( ambientSet_t &set )
-{
- char dirBuffer[512], waveBuffer[256], waveName[1024];
+static void AS_GetSubWaves(ambientSet_t &set) {
+ char dirBuffer[512], waveBuffer[256], waveName[1024];
- //Get the directory for these sets
- sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, dirBuffer );
+ // Get the directory for these sets
+ sscanf(parseBuffer + parsePos, "%s %s", tempBuffer, dirBuffer);
- //Move the pointer past these two strings
- parsePos += ((strlen(keywordNames[SET_KEYWORD_SUBWAVES])+1) + (strlen(dirBuffer)+1));
+ // Move the pointer past these two strings
+ parsePos += ((strlen(keywordNames[SET_KEYWORD_SUBWAVES]) + 1) + (strlen(dirBuffer) + 1));
- //Get all the subwaves
- while ( parsePos <= parseSize )
- {
- //Get the data
- sscanf( parseBuffer+parsePos, "%s", waveBuffer );
+ // Get all the subwaves
+ while (parsePos <= parseSize) {
+ // Get the data
+ sscanf(parseBuffer + parsePos, "%s", waveBuffer);
- if ( set.numSubWaves >= MAX_WAVES_PER_GROUP )
- {
- #ifndef FINAL_BUILD
- Com_Printf(S_COLOR_YELLOW"WARNING: Too many subwaves on set \"%s\"\n", set.name );
- #endif
- }
- else
- {
- //Construct the wave name (pretty, huh?)
- Com_sprintf( waveName, sizeof(waveName), "sound/%s/%s.wav", dirBuffer, waveBuffer );
-
- //Place this onto the sound directory name
-
- //Precache the file at this point and store off the ID instead of the name
- if ( ( set.subWaves[set.numSubWaves++] = S_RegisterSound( waveName ) ) <= 0 )
- {
- #ifndef FINAL_BUILD
- Com_Printf(S_COLOR_RED"ERROR: Unable to load ambient sound \"%s\"\n", waveName);
- #endif
+ if (set.numSubWaves >= MAX_WAVES_PER_GROUP) {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "WARNING: Too many subwaves on set \"%s\"\n", set.name);
+#endif
+ } else {
+ // Construct the wave name (pretty, huh?)
+ Com_sprintf(waveName, sizeof(waveName), "sound/%s/%s.wav", dirBuffer, waveBuffer);
+
+ // Place this onto the sound directory name
+
+ // Precache the file at this point and store off the ID instead of the name
+ if ((set.subWaves[set.numSubWaves++] = S_RegisterSound(waveName)) <= 0) {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_RED "ERROR: Unable to load ambient sound \"%s\"\n", waveName);
+#endif
}
}
- //Move the pointer past this string
- parsePos += strlen(waveBuffer)+1;
+ // Move the pointer past this string
+ parsePos += strlen(waveBuffer) + 1;
- if ( ( (parseBuffer+parsePos)[0] == '\n') || ( (parseBuffer+parsePos)[0] == '\r') )
+ if (((parseBuffer + parsePos)[0] == '\n') || ((parseBuffer + parsePos)[0] == '\r'))
break;
}
@@ -368,22 +333,20 @@ loopedWave
-------------------------
*/
-static void AS_GetLoopedWave( ambientSet_t &set )
-{
- char waveBuffer[256], waveName[1024];
+static void AS_GetLoopedWave(ambientSet_t &set) {
+ char waveBuffer[256], waveName[1024];
- //Get the looped wave name
- sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, waveBuffer );
+ // Get the looped wave name
+ sscanf(parseBuffer + parsePos, "%s %s", tempBuffer, waveBuffer);
- //Construct the wave name
- Com_sprintf( waveName, sizeof(waveName), "sound/%s.wav", waveBuffer );
+ // Construct the wave name
+ Com_sprintf(waveName, sizeof(waveName), "sound/%s.wav", waveBuffer);
- //Precache the file at this point and store off the ID instead of the name
- if ( ( set.loopedWave = S_RegisterSound( waveName ) ) <= 0 )
- {
- #ifndef FINAL_BUILD
- Com_Printf(S_COLOR_RED"ERROR: Unable to load ambient sound \"%s\"\n", waveName);
- #endif
+ // Precache the file at this point and store off the ID instead of the name
+ if ((set.loopedWave = S_RegisterSound(waveName)) <= 0) {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_RED "ERROR: Unable to load ambient sound \"%s\"\n", waveName);
+#endif
}
AS_SkipLine();
@@ -395,28 +358,26 @@ AS_GetVolumeRange
-------------------------
*/
-static void AS_GetVolumeRange( ambientSet_t &set )
-{
- int min, max;
+static void AS_GetVolumeRange(ambientSet_t &set) {
+ int min, max;
- //Get the data
- sscanf( parseBuffer+parsePos, "%s %d %d", tempBuffer, &min, &max );
+ // Get the data
+ sscanf(parseBuffer + parsePos, "%s %d %d", tempBuffer, &min, &max);
- //Check for swapped min / max
- if ( min > max )
- {
- #ifndef FINAL_BUILD
- Com_Printf(S_COLOR_YELLOW"WARNING: Corrected swapped min / max range in a \"volRange\" keyword\n");
- #endif
+ // Check for swapped min / max
+ if (min > max) {
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "WARNING: Corrected swapped min / max range in a \"volRange\" keyword\n");
+#endif
- int swap = min;
- min = max;
- max = swap;
+ int swap = min;
+ min = max;
+ max = swap;
}
- //Store the data
- set.volRange_start = min;
- set.volRange_end = max;
+ // Store the data
+ set.volRange_start = min;
+ set.volRange_end = max;
AS_SkipLine();
}
@@ -427,10 +388,9 @@ AS_GetRadius
-------------------------
*/
-static void AS_GetRadius( ambientSet_t &set )
-{
- //Get the data
- sscanf( parseBuffer+parsePos, "%s %d", tempBuffer, &set.radius );
+static void AS_GetRadius(ambientSet_t &set) {
+ // Get the data
+ sscanf(parseBuffer + parsePos, "%s %d", tempBuffer, &set.radius);
AS_SkipLine();
}
@@ -441,51 +401,47 @@ AS_GetGeneralSet
-------------------------
*/
-static void AS_GetGeneralSet( ambientSet_t &set )
-{
- int keywordID;
+static void AS_GetGeneralSet(ambientSet_t &set) {
+ int keywordID;
- //The other parameters of the set come in a specific order
- while ( parsePos <= parseSize )
- {
- int iFieldsScanned = sscanf( parseBuffer+parsePos, "%s", tempBuffer );
+ // The other parameters of the set come in a specific order
+ while (parsePos <= parseSize) {
+ int iFieldsScanned = sscanf(parseBuffer + parsePos, "%s", tempBuffer);
if (iFieldsScanned <= 0)
return;
- keywordID = AS_GetKeywordIDForString( (const char *) &tempBuffer );
+ keywordID = AS_GetKeywordIDForString((const char *)&tempBuffer);
- //Find and parse the keyword info
- switch ( keywordID )
- {
+ // Find and parse the keyword info
+ switch (keywordID) {
case SET_KEYWORD_TIMEBETWEENWAVES:
- AS_GetTimeBetweenWaves( set );
+ AS_GetTimeBetweenWaves(set);
break;
case SET_KEYWORD_SUBWAVES:
- AS_GetSubWaves( set );
+ AS_GetSubWaves(set);
break;
case SET_KEYWORD_LOOPEDWAVE:
- AS_GetLoopedWave( set );
+ AS_GetLoopedWave(set);
break;
case SET_KEYWORD_VOLRANGE:
- AS_GetVolumeRange( set );
+ AS_GetVolumeRange(set);
break;
default:
- //Check to see if we've finished this group
- if ( AS_GetSetNameIDForString( (const char *) &tempBuffer ) == -1 )
- {
- //Ignore comments
- if ( tempBuffer[0] == ';' )
+ // Check to see if we've finished this group
+ if (AS_GetSetNameIDForString((const char *)&tempBuffer) == -1) {
+ // Ignore comments
+ if (tempBuffer[0] == ';')
return;
- //This wasn't a set name, so it's an error
- #ifndef FINAL_BUILD
- Com_Printf( S_COLOR_YELLOW"WARNING: Unknown ambient set keyword \"%s\"\n", tempBuffer );
- #endif
+// This wasn't a set name, so it's an error
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "WARNING: Unknown ambient set keyword \"%s\"\n", tempBuffer);
+#endif
}
return;
@@ -500,55 +456,51 @@ AS_GetLocalSet
-------------------------
*/
-static void AS_GetLocalSet( ambientSet_t &set )
-{
- int keywordID;
+static void AS_GetLocalSet(ambientSet_t &set) {
+ int keywordID;
- //The other parameters of the set come in a specific order
- while ( parsePos <= parseSize )
- {
- int iFieldsScanned = sscanf( parseBuffer+parsePos, "%s", tempBuffer );
+ // The other parameters of the set come in a specific order
+ while (parsePos <= parseSize) {
+ int iFieldsScanned = sscanf(parseBuffer + parsePos, "%s", tempBuffer);
if (iFieldsScanned <= 0)
return;
- keywordID = AS_GetKeywordIDForString( (const char *) &tempBuffer );
+ keywordID = AS_GetKeywordIDForString((const char *)&tempBuffer);
- //Find and parse the keyword info
- switch ( keywordID )
- {
+ // Find and parse the keyword info
+ switch (keywordID) {
case SET_KEYWORD_TIMEBETWEENWAVES:
- AS_GetTimeBetweenWaves( set );
+ AS_GetTimeBetweenWaves(set);
break;
case SET_KEYWORD_SUBWAVES:
- AS_GetSubWaves( set );
+ AS_GetSubWaves(set);
break;
case SET_KEYWORD_LOOPEDWAVE:
- AS_GetLoopedWave( set );
+ AS_GetLoopedWave(set);
break;
case SET_KEYWORD_VOLRANGE:
- AS_GetVolumeRange( set );
+ AS_GetVolumeRange(set);
break;
case SET_KEYWORD_RADIUS:
- AS_GetRadius( set );
+ AS_GetRadius(set);
break;
default:
- //Check to see if we've finished this group
- if ( AS_GetSetNameIDForString( (const char *) &tempBuffer ) == -1 )
- {
- //Ignore comments
- if ( tempBuffer[0] == ';' )
+ // Check to see if we've finished this group
+ if (AS_GetSetNameIDForString((const char *)&tempBuffer) == -1) {
+ // Ignore comments
+ if (tempBuffer[0] == ';')
return;
- //This wasn't a set name, so it's an error
- #ifndef FINAL_BUILD
- Com_Printf( S_COLOR_YELLOW"WARNING: Unknown ambient set keyword \"%s\"\n", tempBuffer );
- #endif
+// This wasn't a set name, so it's an error
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "WARNING: Unknown ambient set keyword \"%s\"\n", tempBuffer);
+#endif
}
return;
@@ -563,39 +515,35 @@ AS_GetBModelSet
-------------------------
*/
-static void AS_GetBModelSet( ambientSet_t &set )
-{
- int keywordID;
+static void AS_GetBModelSet(ambientSet_t &set) {
+ int keywordID;
- //The other parameters of the set come in a specific order
- while ( parsePos <= parseSize )
- {
- int iFieldsScanned = sscanf( parseBuffer+parsePos, "%s", tempBuffer );
+ // The other parameters of the set come in a specific order
+ while (parsePos <= parseSize) {
+ int iFieldsScanned = sscanf(parseBuffer + parsePos, "%s", tempBuffer);
if (iFieldsScanned <= 0)
return;
- keywordID = AS_GetKeywordIDForString( (const char *) &tempBuffer );
+ keywordID = AS_GetKeywordIDForString((const char *)&tempBuffer);
- //Find and parse the keyword info
- switch ( keywordID )
- {
+ // Find and parse the keyword info
+ switch (keywordID) {
case SET_KEYWORD_SUBWAVES:
- AS_GetSubWaves( set );
+ AS_GetSubWaves(set);
break;
default:
- //Check to see if we've finished this group
- if ( AS_GetSetNameIDForString( (const char *) &tempBuffer ) == -1 )
- {
- //Ignore comments
- if ( tempBuffer[0] == ';' )
+ // Check to see if we've finished this group
+ if (AS_GetSetNameIDForString((const char *)&tempBuffer) == -1) {
+ // Ignore comments
+ if (tempBuffer[0] == ';')
return;
- //This wasn't a set name, so it's an error
- #ifndef FINAL_BUILD
- Com_Printf( S_COLOR_YELLOW"WARNING: Unknown ambient set keyword \"%s\"\n", tempBuffer );
- #endif
+// This wasn't a set name, so it's an error
+#ifndef FINAL_BUILD
+ Com_Printf(S_COLOR_YELLOW "WARNING: Unknown ambient set keyword \"%s\"\n", tempBuffer);
+#endif
}
return;
@@ -612,53 +560,49 @@ Parses an individual set group out of a set file buffer
-------------------------
*/
-static qboolean AS_ParseSet( int setID, CSetGroup *sg )
-{
- ambientSet_t *set;
- const char *name;
+static qboolean AS_ParseSet(int setID, CSetGroup *sg) {
+ ambientSet_t *set;
+ const char *name;
- //Make sure we're not overstepping the name array
- if ( setID >= NUM_AS_SETS )
+ // Make sure we're not overstepping the name array
+ if (setID >= NUM_AS_SETS)
return qfalse;
- //Reset the pointers for this run through
+ // Reset the pointers for this run through
parsePos = 0;
name = setNames[setID];
- //Iterate through the whole file and find every occurance of a set
- while ( parsePos <= parseSize )
- {
- //Check for a valid set group
- if ( Q_strncmp( parseBuffer+parsePos, name, strlen(name) ) == 0 )
- {
- //Update the debug info
+ // Iterate through the whole file and find every occurance of a set
+ while (parsePos <= parseSize) {
+ // Check for a valid set group
+ if (Q_strncmp(parseBuffer + parsePos, name, strlen(name)) == 0) {
+ // Update the debug info
numSets++;
- //Push past the set specifier and on to the name
- parsePos+=strlen(name)+1; //Also take the following space out
+ // Push past the set specifier and on to the name
+ parsePos += strlen(name) + 1; // Also take the following space out
- //Get the set name (this MUST be first)
- sscanf( parseBuffer+parsePos, "%s", tempBuffer );
+ // Get the set name (this MUST be first)
+ sscanf(parseBuffer + parsePos, "%s", tempBuffer);
AS_SkipLine();
- //Test the string against the precaches
- if ( tempBuffer[0] )
- {
- //Not in our precache listings, so skip it
- if ( ( pMap->find( (const char *) &tempBuffer ) == pMap->end() ) )
+ // Test the string against the precaches
+ if (tempBuffer[0]) {
+ // Not in our precache listings, so skip it
+ if ((pMap->find((const char *)&tempBuffer) == pMap->end()))
continue;
}
- //Create a new set
- set = sg->AddSet( (const char *) &tempBuffer );
+ // Create a new set
+ set = sg->AddSet((const char *)&tempBuffer);
- //Run the function to parse the data out
- parseFuncs[setID]( *set );
+ // Run the function to parse the data out
+ parseFuncs[setID](*set);
continue;
}
- //If not found on this line, go down another and check again
+ // If not found on this line, go down another and check again
AS_SkipLine();
}
@@ -673,40 +617,36 @@ Parses the directory information out of the beginning of the file
-------------------------
*/
-static void AS_ParseHeader( void )
-{
- char typeBuffer[128];
- int keywordID;
+static void AS_ParseHeader(void) {
+ char typeBuffer[128];
+ int keywordID;
- while ( parsePos <= parseSize )
- {
- sscanf( parseBuffer+parsePos, "%s", tempBuffer );
+ while (parsePos <= parseSize) {
+ sscanf(parseBuffer + parsePos, "%s", tempBuffer);
- keywordID = AS_GetKeywordIDForString( (const char *) &tempBuffer );
+ keywordID = AS_GetKeywordIDForString((const char *)&tempBuffer);
- switch ( keywordID )
- {
+ switch (keywordID) {
case SET_KEYWORD_TYPE:
- sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, typeBuffer );
+ sscanf(parseBuffer + parsePos, "%s %s", tempBuffer, typeBuffer);
- if ( !Q_stricmp( (const char *) typeBuffer, "ambientSet" ) )
- {
+ if (!Q_stricmp((const char *)typeBuffer, "ambientSet")) {
return;
}
- Com_Error( ERR_DROP, "AS_ParseHeader: Set type \"%s\" is not a valid set type!\n", typeBuffer );
+ Com_Error(ERR_DROP, "AS_ParseHeader: Set type \"%s\" is not a valid set type!\n", typeBuffer);
break;
case SET_KEYWORD_AMSDIR:
- //TODO: Implement
+ // TODO: Implement
break;
case SET_KEYWORD_OUTDIR:
- //TODO: Implement
+ // TODO: Implement
break;
case SET_KEYWORD_BASEDIR:
- //TODO: Implement
+ // TODO: Implement
break;
}
@@ -722,23 +662,22 @@ Opens and parses a sound set file
-------------------------
*/
-static qboolean AS_ParseFile( const char *filename, CSetGroup *sg )
-{
- //Open the file and read the information from it
- parseSize = FS_ReadFile( filename, (void **) &parseBuffer );
+static qboolean AS_ParseFile(const char *filename, CSetGroup *sg) {
+ // Open the file and read the information from it
+ parseSize = FS_ReadFile(filename, (void **)&parseBuffer);
- if ( parseSize <= 0 )
+ if (parseSize <= 0)
return qfalse;
- //Parse the directory information out of the file
+ // Parse the directory information out of the file
AS_ParseHeader();
- //Parse all the relevent sets out of it
- for ( int i = 0; i < NUM_AS_SETS; i++ )
- AS_ParseSet( i, sg );
+ // Parse all the relevent sets out of it
+ for (int i = 0; i < NUM_AS_SETS; i++)
+ AS_ParseSet(i, sg);
- //Free the memory and close the file
- FS_FreeFile( parseBuffer );
+ // Free the memory and close the file
+ FS_FreeFile(parseBuffer);
return qtrue;
}
@@ -759,8 +698,7 @@ Loads the ambient sound sets and prepares to play them when needed
-------------------------
*/
-static namePrecache_m *TheNamePrecache()
-{
+static namePrecache_m *TheNamePrecache() {
// we use these singletons so we can find memory leaks
// if you let things like this leak, you never can tell
// what is really leaking and what is merely not ever freed
@@ -768,15 +706,13 @@ static namePrecache_m *TheNamePrecache()
return &singleton;
}
-void AS_Init( void )
-{
- if (!aSets)
- {
+void AS_Init(void) {
+ if (!aSets) {
numSets = 0;
pMap = TheNamePrecache();
- //Setup the structure
+ // Setup the structure
aSets = new CSetGroup();
aSets->Init();
}
@@ -788,19 +724,16 @@ AS_AddPrecacheEntry
-------------------------
*/
-void AS_AddPrecacheEntry( const char *name ) {
- if ( !pMap ) { // s_initsound 0 probably
+void AS_AddPrecacheEntry(const char *name) {
+ if (!pMap) { // s_initsound 0 probably
return;
}
- if (!Q_stricmp(name,"#clear"))
- {
+ if (!Q_stricmp(name, "#clear")) {
pMap->clear();
- currentSet = -1;
- oldSet = -1;
- }
- else
- {
- (*pMap)[ name ] = 1;
+ currentSet = -1;
+ oldSet = -1;
+ } else {
+ (*pMap)[name] = 1;
}
}
@@ -812,42 +745,37 @@ Called on the client side to load and precache all the ambient sound sets
-------------------------
*/
-void AS_ParseSets( void )
-{
- if ( !s_initsound->integer ) {
+void AS_ParseSets(void) {
+ if (!s_initsound->integer) {
return;
}
AS_Init();
- //Parse all the sets
- if ( AS_ParseFile( AMBIENT_SET_FILENAME, aSets ) == qfalse )
- {
- Com_Error ( ERR_FATAL, S_COLOR_RED"ERROR: Couldn't load ambient sound sets from %s", AMBIENT_SET_FILENAME );
+ // Parse all the sets
+ if (AS_ParseFile(AMBIENT_SET_FILENAME, aSets) == qfalse) {
+ Com_Error(ERR_FATAL, S_COLOR_RED "ERROR: Couldn't load ambient sound sets from %s", AMBIENT_SET_FILENAME);
}
- //Com_Printf( "AS_ParseFile: Loaded %d of %d ambient set(s)\n", pMap.size(), numSets );
+ // Com_Printf( "AS_ParseFile: Loaded %d of %d ambient set(s)\n", pMap.size(), numSets );
int iErrorsOccured = 0;
- for (namePrecache_m::iterator it = pMap->begin(); it != pMap->end(); ++it)
- {
- const char* str = (*it).first.c_str();
- ambientSet_t *aSet = aSets->GetSet( str );
- if (!aSet)
- {
+ for (namePrecache_m::iterator it = pMap->begin(); it != pMap->end(); ++it) {
+ const char *str = (*it).first.c_str();
+ ambientSet_t *aSet = aSets->GetSet(str);
+ if (!aSet) {
// I print these red instead of yellow because they're going to cause an ERR_DROP if they occur
- Com_Printf( S_COLOR_RED"ERROR: AS_ParseSets: Unable to find ambient soundset \"%s\"!\n",str);
+ Com_Printf(S_COLOR_RED "ERROR: AS_ParseSets: Unable to find ambient soundset \"%s\"!\n", str);
iErrorsOccured++;
}
}
- if (iErrorsOccured)
- {
- Com_Error( ERR_DROP, "....%d missing sound sets! (see above)\n", iErrorsOccured);
+ if (iErrorsOccured) {
+ Com_Error(ERR_DROP, "....%d missing sound sets! (see above)\n", iErrorsOccured);
}
-// //Done with the precache info, it will be rebuilt on a restart
-// pMap->clear(); // do NOT do this here now
+ // //Done with the precache info, it will be rebuilt on a restart
+ // pMap->clear(); // do NOT do this here now
}
/*
@@ -858,37 +786,32 @@ Frees up the ambient sound system
-------------------------
*/
-void AS_Free( void )
-{
- if (aSets)
- {
+void AS_Free(void) {
+ if (aSets) {
aSets->Free();
delete aSets;
aSets = NULL;
- currentSet = -1;
- oldSet = -1;
+ currentSet = -1;
+ oldSet = -1;
currentSetTime = 0;
oldSetTime = 0;
- numSets = 0;
+ numSets = 0;
}
}
-
-void AS_FreePartial(void)
-{
- if (aSets)
- {
+void AS_FreePartial(void) {
+ if (aSets) {
aSets->Free();
- currentSet = -1;
- oldSet = -1;
+ currentSet = -1;
+ oldSet = -1;
currentSetTime = 0;
oldSetTime = 0;
- numSets = 0;
+ numSets = 0;
pMap = TheNamePrecache();
pMap->clear();
@@ -911,47 +834,47 @@ Fades volumes up or down depending on the action being taken on them.
-------------------------
*/
-static void AS_UpdateSetVolumes( void ) {
- if ( !aSets ) {
+static void AS_UpdateSetVolumes(void) {
+ if (!aSets) {
return;
}
- //Get the sets and validate them
- ambientSet_t *current = aSets->GetSet( currentSet );
- if ( !current ) {
+ // Get the sets and validate them
+ ambientSet_t *current = aSets->GetSet(currentSet);
+ if (!current) {
return;
}
float scale;
int deltaTime;
- if ( current->masterVolume < MAX_SET_VOLUME ) {
+ if (current->masterVolume < MAX_SET_VOLUME) {
deltaTime = cls.realtime - current->fadeTime;
- scale = ((float)(deltaTime)/(float)(crossDelay));
+ scale = ((float)(deltaTime) / (float)(crossDelay));
current->masterVolume = (int)((scale) * (float)MAX_SET_VOLUME);
}
- if ( current->masterVolume > MAX_SET_VOLUME ) {
+ if (current->masterVolume > MAX_SET_VOLUME) {
current->masterVolume = MAX_SET_VOLUME;
}
- //Only update the old set if it's still valid
- if ( oldSet == -1 ) {
+ // Only update the old set if it's still valid
+ if (oldSet == -1) {
return;
}
- ambientSet_t *old = aSets->GetSet( oldSet );
- if ( !old ) {
+ ambientSet_t *old = aSets->GetSet(oldSet);
+ if (!old) {
return;
}
- //Update the volumes
- if ( old->masterVolume > 0 ) {
+ // Update the volumes
+ if (old->masterVolume > 0) {
deltaTime = cls.realtime - old->fadeTime;
- scale = ((float)(deltaTime)/(float)(crossDelay));
+ scale = ((float)(deltaTime) / (float)(crossDelay));
old->masterVolume = MAX_SET_VOLUME - (int)((scale) * (float)MAX_SET_VOLUME);
}
- if ( old->masterVolume <= 0 ) {
+ if (old->masterVolume <= 0) {
old->masterVolume = 0;
oldSet = -1;
}
@@ -965,36 +888,36 @@ Does internal maintenance to keep track of changing sets.
-------------------------
*/
-static void AS_UpdateCurrentSet( int id ) {
- if ( !aSets ) {
+static void AS_UpdateCurrentSet(int id) {
+ if (!aSets) {
return;
}
- //Check for a change
- if ( id != currentSet ) {
- //This is new, so start the fading
+ // Check for a change
+ if (id != currentSet) {
+ // This is new, so start the fading
oldSet = currentSet;
currentSet = id;
- ambientSet_t *current = aSets->GetSet( currentSet );
+ ambientSet_t *current = aSets->GetSet(currentSet);
// Ste, I just put this null check in for now, not sure if there's a more graceful way to exit this function - dmv
- if ( !current ) {
+ if (!current) {
return;
}
- ambientSet_t *old = aSets->GetSet( oldSet );
- if ( old ) {
+ ambientSet_t *old = aSets->GetSet(oldSet);
+ if (old) {
old->masterVolume = MAX_SET_VOLUME;
old->fadeTime = cls.realtime;
}
current->masterVolume = 0;
- //Set the fading starts
+ // Set the fading starts
current->fadeTime = cls.realtime;
}
- //Update their volumes if fading
+ // Update their volumes if fading
AS_UpdateSetVolumes();
}
@@ -1007,41 +930,41 @@ Alters lastTime to reflect the time updates.
-------------------------
*/
-static void AS_PlayLocalSet( vec3_t listener_origin, vec3_t origin, const ambientSet_t *set, int entID, int *lastTime ) {
- //Make sure it's valid
- if ( !set ) {
+static void AS_PlayLocalSet(vec3_t listener_origin, vec3_t origin, const ambientSet_t *set, int entID, int *lastTime) {
+ // Make sure it's valid
+ if (!set) {
return;
}
vec3_t dir;
- VectorSubtract( origin, listener_origin, dir );
- float dist = VectorLength( dir );
+ VectorSubtract(origin, listener_origin, dir);
+ float dist = VectorLength(dir);
- //Determine the volume based on distance (NOTE: This sits on top of what SpatializeOrigin does)
- float distScale = ( dist < ( set->radius * 0.5f ) ) ? 1 : ( set->radius - dist ) / ( set->radius * 0.5f );
- unsigned char volume = ( distScale > 1.0f || distScale < 0.0f ) ? 0 : (unsigned char) ( set->masterVolume * distScale );
+ // Determine the volume based on distance (NOTE: This sits on top of what SpatializeOrigin does)
+ float distScale = (dist < (set->radius * 0.5f)) ? 1 : (set->radius - dist) / (set->radius * 0.5f);
+ unsigned char volume = (distScale > 1.0f || distScale < 0.0f) ? 0 : (unsigned char)(set->masterVolume * distScale);
- //Add the looping sound
- if ( set->loopedWave ) {
- S_AddAmbientLoopingSound( origin, volume, set->loopedWave );
+ // Add the looping sound
+ if (set->loopedWave) {
+ S_AddAmbientLoopingSound(origin, volume, set->loopedWave);
}
- //Check the time to start another one-shot subwave
+ // Check the time to start another one-shot subwave
int time = cl.serverTime;
- if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) {
+ if ((time - *lastTime) < ((Q_irand(set->time_start, set->time_end)) * 1000)) {
return;
}
- //Update the time
+ // Update the time
*lastTime = time;
- //Scale the volume ranges for the subwaves based on the overall master volume
- float volScale = (float) volume / (float) MAX_SET_VOLUME;
- volume = (unsigned char) Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) );
+ // Scale the volume ranges for the subwaves based on the overall master volume
+ float volScale = (float)volume / (float)MAX_SET_VOLUME;
+ volume = (unsigned char)Q_irand((int)(volScale * set->volRange_start), (int)(volScale * set->volRange_end));
- //Add the random subwave
- if ( set->numSubWaves ) {
- S_StartAmbientSound( origin, entID, volume, set->subWaves[Q_irand( 0, set->numSubWaves-1)] );
+ // Add the random subwave
+ if (set->numSubWaves) {
+ S_StartAmbientSound(origin, entID, volume, set->subWaves[Q_irand(0, set->numSubWaves - 1)]);
}
}
@@ -1054,38 +977,38 @@ Alters lastTime to reflect the time updates.
-------------------------
*/
-static void AS_PlayAmbientSet( vec3_t origin, const ambientSet_t *set, int *lastTime ) {
- //Make sure it's valid
- if ( !set ) {
+static void AS_PlayAmbientSet(vec3_t origin, const ambientSet_t *set, int *lastTime) {
+ // Make sure it's valid
+ if (!set) {
return;
}
- //Add the looping sound
- if ( set->loopedWave ) {
- S_AddAmbientLoopingSound( origin, (unsigned char) set->masterVolume, set->loopedWave );
+ // Add the looping sound
+ if (set->loopedWave) {
+ S_AddAmbientLoopingSound(origin, (unsigned char)set->masterVolume, set->loopedWave);
}
- //Check the time to start another one-shot subwave
+ // Check the time to start another one-shot subwave
int time = cls.realtime;
- if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) {
+ if ((time - *lastTime) < ((Q_irand(set->time_start, set->time_end)) * 1000)) {
return;
}
- //Update the time
+ // Update the time
*lastTime = time;
- //Scale the volume ranges for the subwaves based on the overall master volume
- float volScale = (float) set->masterVolume / (float) MAX_SET_VOLUME;
- unsigned char volume = Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) );
+ // Scale the volume ranges for the subwaves based on the overall master volume
+ float volScale = (float)set->masterVolume / (float)MAX_SET_VOLUME;
+ unsigned char volume = Q_irand((int)(volScale * set->volRange_start), (int)(volScale * set->volRange_end));
- //Allow for softer noises than the masterVolume, but not louder
- if ( volume > set->masterVolume ) {
+ // Allow for softer noises than the masterVolume, but not louder
+ if (volume > set->masterVolume) {
volume = set->masterVolume;
}
- //Add the random subwave
- if ( set->numSubWaves ) {
- S_StartAmbientSound( origin, 0, volume, set->subWaves[Q_irand( 0, set->numSubWaves-1)] );
+ // Add the random subwave
+ if (set->numSubWaves) {
+ S_StartAmbientSound(origin, 0, volume, set->subWaves[Q_irand(0, set->numSubWaves - 1)]);
}
}
@@ -1097,27 +1020,27 @@ Does maintenance and plays the ambient sets (two if crossfading)
-------------------------
*/
-void S_UpdateAmbientSet( const char *name, vec3_t origin ) {
- if ( !aSets ) {
+void S_UpdateAmbientSet(const char *name, vec3_t origin) {
+ if (!aSets) {
return;
}
- const ambientSet_t *set = aSets->GetSet( name );
- if ( !set ) {
+ const ambientSet_t *set = aSets->GetSet(name);
+ if (!set) {
return;
}
- //Update the current and old set for crossfading
- AS_UpdateCurrentSet( set->id );
+ // Update the current and old set for crossfading
+ AS_UpdateCurrentSet(set->id);
- const ambientSet_t *current = aSets->GetSet( currentSet );
- if ( current ) {
- AS_PlayAmbientSet( origin, set, ¤tSetTime );
+ const ambientSet_t *current = aSets->GetSet(currentSet);
+ if (current) {
+ AS_PlayAmbientSet(origin, set, ¤tSetTime);
}
- const ambientSet_t *old = aSets->GetSet( oldSet );
- if ( old ) {
- AS_PlayAmbientSet( origin, old, &oldSetTime );
+ const ambientSet_t *old = aSets->GetSet(oldSet);
+ if (old) {
+ AS_PlayAmbientSet(origin, old, &oldSetTime);
}
}
@@ -1127,18 +1050,18 @@ S_AddLocalSet
-------------------------
*/
-int S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time ) {
- if ( !aSets ) {
+int S_AddLocalSet(const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time) {
+ if (!aSets) {
return cl.serverTime;
}
- const ambientSet_t *set = aSets->GetSet( name );
- if ( !set ) {
+ const ambientSet_t *set = aSets->GetSet(name);
+ if (!set) {
return cl.serverTime;
}
int currentTime = time;
- AS_PlayLocalSet( listener_origin, origin, set, entID, ¤tTime );
+ AS_PlayLocalSet(listener_origin, origin, set, entID, ¤tTime);
return currentTime;
}
@@ -1148,14 +1071,14 @@ AS_GetBModelSound
-------------------------
*/
-sfxHandle_t AS_GetBModelSound( const char *name, int stage ) {
- if ( !aSets ) {
+sfxHandle_t AS_GetBModelSound(const char *name, int stage) {
+ if (!aSets) {
return -1;
}
- //Stage must be within a valid range
- const ambientSet_t *set = aSets->GetSet( name );
- if ( !set || stage < 0 || stage > (set->numSubWaves - 1) ) {
+ // Stage must be within a valid range
+ const ambientSet_t *set = aSets->GetSet(name);
+ if (!set || stage < 0 || stage > (set->numSubWaves - 1)) {
return -1;
}
diff --git a/code/client/snd_dma.cpp b/code/client/snd_dma.cpp
index bb539e4cd6..0d1aece01c 100644
--- a/code/client/snd_dma.cpp
+++ b/code/client/snd_dma.cpp
@@ -48,8 +48,8 @@ static void S_SetDynamicMusic_f(void);
void S_Update_();
void S_StopAllSounds(void);
-static void S_UpdateBackgroundTrack( void );
-sfx_t *S_FindName( const char *name );
+static void S_UpdateBackgroundTrack(void);
+sfx_t *S_FindName(const char *name);
static int SND_FreeSFXMem(sfx_t *sfx);
extern qboolean Sys_LowPhysicalMemory();
@@ -58,127 +58,123 @@ extern qboolean Sys_LowPhysicalMemory();
//
// vars for bgrnd music track...
//
-const int iMP3MusicStream_DiskBytesToRead = 10000;//4096;
-const int iMP3MusicStream_DiskBufferSize = iMP3MusicStream_DiskBytesToRead*2; //*10;
+const int iMP3MusicStream_DiskBytesToRead = 10000; // 4096;
+const int iMP3MusicStream_DiskBufferSize = iMP3MusicStream_DiskBytesToRead * 2; //*10;
-typedef struct
-{
- qboolean bIsMP3;
+typedef struct {
+ qboolean bIsMP3;
//
// MP3 specific...
//
- sfx_t sfxMP3_Bgrnd;
- MP3STREAM streamMP3_Bgrnd; // this one is pointed at by the sfx_t's ptr, and is NOT the one the decoder uses every cycle
- channel_t chMP3_Bgrnd; // ... but the one in this struct IS.
+ sfx_t sfxMP3_Bgrnd;
+ MP3STREAM streamMP3_Bgrnd; // this one is pointed at by the sfx_t's ptr, and is NOT the one the decoder uses every cycle
+ channel_t chMP3_Bgrnd; // ... but the one in this struct IS.
//
// MP3 disk streamer stuff... (if music is non-dynamic)
//
- byte byMP3MusicStream_DiskBuffer[iMP3MusicStream_DiskBufferSize];
- int iMP3MusicStream_DiskReadPos;
- int iMP3MusicStream_DiskWindowPos;
+ byte byMP3MusicStream_DiskBuffer[iMP3MusicStream_DiskBufferSize];
+ int iMP3MusicStream_DiskReadPos;
+ int iMP3MusicStream_DiskWindowPos;
//
// MP3 disk-load stuff (for use during dynamic music, which is mem-resident)
//
- byte *pLoadedData; // Z_Malloc, Z_Free // these two MUST be kept as valid/invalid together
- char sLoadedDataName[MAX_QPATH]; // " " " " "
- int iLoadedDataLen;
+ byte *pLoadedData; // Z_Malloc, Z_Free // these two MUST be kept as valid/invalid together
+ char sLoadedDataName[MAX_QPATH]; // " " " " "
+ int iLoadedDataLen;
//
// remaining dynamic fields...
//
- int iXFadeVolumeSeekTime;
- int iXFadeVolumeSeekTo; // when changing this, set the above timer to Sys_Milliseconds().
- // Note that this should be thought of more as an up/down bool rather than as a
- // number now, in other words set it only to 0 or 255. I'll probably change this
- // to actually be a bool later.
- int iXFadeVolume; // 0 = silent, 255 = max mixer vol, though still modulated via overall music_volume
- float fSmoothedOutVolume;
- qboolean bActive; // whether playing or not
- qboolean bExists; // whether was even loaded for this level (ie don't try and start playing it)
+ int iXFadeVolumeSeekTime;
+ int iXFadeVolumeSeekTo; // when changing this, set the above timer to Sys_Milliseconds().
+ // Note that this should be thought of more as an up/down bool rather than as a
+ // number now, in other words set it only to 0 or 255. I'll probably change this
+ // to actually be a bool later.
+ int iXFadeVolume; // 0 = silent, 255 = max mixer vol, though still modulated via overall music_volume
+ float fSmoothedOutVolume;
+ qboolean bActive; // whether playing or not
+ qboolean bExists; // whether was even loaded for this level (ie don't try and start playing it)
//
// new dynamic fields...
//
- qboolean bTrackSwitchPending;
+ qboolean bTrackSwitchPending;
MusicState_e eTS_NewState;
- float fTS_NewTime;
+ float fTS_NewTime;
//
// Generic...
//
- fileHandle_t s_backgroundFile; // valid handle, else -1 if an MP3 (so that NZ compares still work)
- wavinfo_t s_backgroundInfo;
- int s_backgroundSamples;
+ fileHandle_t s_backgroundFile; // valid handle, else -1 if an MP3 (so that NZ compares still work)
+ wavinfo_t s_backgroundInfo;
+ int s_backgroundSamples;
- void Rewind()
- {
- MP3Stream_Rewind( &chMP3_Bgrnd );
+ void Rewind() {
+ MP3Stream_Rewind(&chMP3_Bgrnd);
s_backgroundSamples = sfxMP3_Bgrnd.iSoundLengthInSamples;
}
- void SeekTo(float fTime)
- {
+ void SeekTo(float fTime) {
chMP3_Bgrnd.iMP3SlidingDecodeWindowPos = 0;
chMP3_Bgrnd.iMP3SlidingDecodeWritePos = 0;
- MP3Stream_SeekTo( &chMP3_Bgrnd, fTime );
+ MP3Stream_SeekTo(&chMP3_Bgrnd, fTime);
s_backgroundSamples = sfxMP3_Bgrnd.iSoundLengthInSamples;
}
} MusicInfo_t;
-static void S_SetDynamicMusicState( MusicState_e musicState );
+static void S_SetDynamicMusicState(MusicState_e musicState);
#define fDYNAMIC_XFADE_SECONDS (1.0f)
-static MusicInfo_t tMusic_Info[eBGRNDTRACK_NUMBEROF] = {};
-static qboolean bMusic_IsDynamic = qfalse;
-static MusicState_e eMusic_StateActual = eBGRNDTRACK_EXPLORE; // actual state, can be any enum
-static MusicState_e eMusic_StateRequest = eBGRNDTRACK_EXPLORE; // requested state, can only be explore, action, boss, or silence
-static char sMusic_BackgroundLoop[MAX_QPATH] = {0}; // only valid for non-dynamic music
-static char sInfoOnly_CurrentDynamicMusicSet[64]; // any old reasonable size, only has to fit stuff like "kejim_post"
+static MusicInfo_t tMusic_Info[eBGRNDTRACK_NUMBEROF] = {};
+static qboolean bMusic_IsDynamic = qfalse;
+static MusicState_e eMusic_StateActual = eBGRNDTRACK_EXPLORE; // actual state, can be any enum
+static MusicState_e eMusic_StateRequest = eBGRNDTRACK_EXPLORE; // requested state, can only be explore, action, boss, or silence
+static char sMusic_BackgroundLoop[MAX_QPATH] = {0}; // only valid for non-dynamic music
+static char sInfoOnly_CurrentDynamicMusicSet[64]; // any old reasonable size, only has to fit stuff like "kejim_post"
//
//////////////////////////
-
// =======================================================================
// Internal sound data & structures
// =======================================================================
// only begin attenuating sound volumes when outside the FULLVOLUME range
-#define SOUND_FULLVOLUME 256
+#define SOUND_FULLVOLUME 256
-#define SOUND_ATTENUATE 0.0008f
-#define VOICE_ATTENUATE 0.004f
+#define SOUND_ATTENUATE 0.0008f
+#define VOICE_ATTENUATE 0.004f
-const float SOUND_FMAXVOL=0.75;//1.0;
-const int SOUND_MAXVOL=255;
+const float SOUND_FMAXVOL = 0.75; // 1.0;
+const int SOUND_MAXVOL = 255;
-channel_t s_channels[MAX_CHANNELS];
+channel_t s_channels[MAX_CHANNELS];
-int s_soundStarted;
-qboolean s_soundMuted;
+int s_soundStarted;
+qboolean s_soundMuted;
-dma_t dma;
+dma_t dma;
-int listener_number;
-vec3_t listener_origin;
-vec3_t listener_axis[3];
+int listener_number;
+vec3_t listener_origin;
+vec3_t listener_axis[3];
-int s_soundtime; // sample PAIRS
-int s_paintedtime; // sample PAIRS
+int s_soundtime; // sample PAIRS
+int s_paintedtime; // sample PAIRS
// MAX_SFX may be larger than MAX_SOUNDS because
// of custom player sounds
-#define MAX_SFX 10000 //512 * 2
-sfx_t s_knownSfx[MAX_SFX];
-int s_numSfx;
+#define MAX_SFX 10000 // 512 * 2
+sfx_t s_knownSfx[MAX_SFX];
+int s_numSfx;
-#define LOOP_HASH 128
-static sfx_t *sfxHash[LOOP_HASH];
+#define LOOP_HASH 128
+static sfx_t *sfxHash[LOOP_HASH];
cvar_t *s_allowDynamicMusic;
cvar_t *s_debugdynamic;
cvar_t *s_dynamix;
cvar_t *s_initsound;
cvar_t *s_khz;
-cvar_t *s_language; // note that this is distinct from "g_language"
+cvar_t *s_language; // note that this is distinct from "g_language"
cvar_t *s_lip_threshold_1;
cvar_t *s_lip_threshold_2;
cvar_t *s_lip_threshold_3;
@@ -192,32 +188,31 @@ cvar_t *s_testsound;
cvar_t *s_volume;
cvar_t *s_volumeVoice;
-typedef struct
-{
- unsigned char volume;
- vec3_t origin;
-// vec3_t velocity;
-/* const*/ sfx_t *sfx;
- int mergeFrame;
- int entnum;
- soundChannel_t entchan;
+typedef struct {
+ unsigned char volume;
+ vec3_t origin;
+ // vec3_t velocity;
+ /* const*/ sfx_t *sfx;
+ int mergeFrame;
+ int entnum;
+ soundChannel_t entchan;
// For Open AL
- qboolean bProcessed;
- qboolean bRelative;
+ qboolean bProcessed;
+ qboolean bRelative;
} loopSound_t;
-#define MAX_LOOP_SOUNDS 64
-int numLoopSounds;
-loopSound_t loopSounds[MAX_LOOP_SOUNDS];
+#define MAX_LOOP_SOUNDS 64
+int numLoopSounds;
+loopSound_t loopSounds[MAX_LOOP_SOUNDS];
-int s_rawend;
-portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
-vec3_t s_entityPosition[MAX_GENTITIES];
-int s_entityWavVol[MAX_GENTITIES];
-int s_entityWavVol_back[MAX_GENTITIES];
+int s_rawend;
+portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
+vec3_t s_entityPosition[MAX_GENTITIES];
+int s_entityWavVol[MAX_GENTITIES];
+int s_entityWavVol_back[MAX_GENTITIES];
-int s_numChannels; // Number of AL Sources == Num of Channels
+int s_numChannels; // Number of AL Sources == Num of Channels
#ifdef USE_OPENAL
@@ -227,23 +222,23 @@ int s_numChannels; // Number of AL Sources == Num of Channels
*
\**************************************************************************************************/
-#define sqr(a) ((a)*(a))
-#define ENV_UPDATE_RATE 100 // Environmental audio update rate (in ms)
+#define sqr(a) ((a) * (a))
+#define ENV_UPDATE_RATE 100 // Environmental audio update rate (in ms)
//#define DISPLAY_CLOSEST_ENVS // Displays the closest env. zones (including the one the listener is in)
-#define DEFAULT_REF_DISTANCE 300.0f // Default reference distance
-#define DEFAULT_VOICE_REF_DISTANCE 1500.0f // Default voice reference distance
+#define DEFAULT_REF_DISTANCE 300.0f // Default reference distance
+#define DEFAULT_VOICE_REF_DISTANCE 1500.0f // Default voice reference distance
-int s_UseOpenAL = 0; // Determines if using Open AL or the default software mixer
+int s_UseOpenAL = 0; // Determines if using Open AL or the default software mixer
-ALfloat listener_pos[3]; // Listener Position
-ALfloat listener_ori[6]; // Listener Orientation
+ALfloat listener_pos[3]; // Listener Position
+ALfloat listener_ori[6]; // Listener Orientation
-short s_rawdata[MAX_RAW_SAMPLES*2]; // Used for Raw Samples (Music etc...)
+short s_rawdata[MAX_RAW_SAMPLES * 2]; // Used for Raw Samples (Music etc...)
channel_t *S_OpenALPickChannel(int entnum, int entchannel);
-int S_MP3PreProcessLipSync(channel_t *ch, short *data);
+int S_MP3PreProcessLipSync(channel_t *ch, short *data);
void UpdateSingleShotSounds();
void UpdateLoopingSounds();
void AL_UpdateRawSamples();
@@ -251,46 +246,42 @@ void S_SetLipSyncs();
// EAX Related
-typedef struct
-{
- ALuint ulNumApertures;
- ALint lFXSlotID;
- ALboolean bUsed;
- struct
- {
+typedef struct {
+ ALuint ulNumApertures;
+ ALint lFXSlotID;
+ ALboolean bUsed;
+ struct {
ALfloat vPos1[3];
ALfloat vPos2[3];
ALfloat vCenter[3];
} Aperture[64];
} ENVTABLE, *LPENVTABLE;
-typedef struct
-{
+typedef struct {
long lEnvID;
long lApertureNum;
float flDist;
} REVERBDATA, *LPREVERBDATA;
-typedef struct
-{
- GUID FXSlotGuid;
- ALint lEnvID;
+typedef struct {
+ GUID FXSlotGuid;
+ ALint lEnvID;
} FXSLOTINFO, *LPFXSLOTINFO;
-ALboolean s_bEAX; // Is EAX 4.0 support available
-bool s_bEALFileLoaded; // Has an .eal file been loaded for the current level
-bool s_bInWater; // Underwater effect currently active
-int s_EnvironmentID; // EAGLE ID of current environment
-LPEAXMANAGER s_lpEAXManager; // Pointer to EAXManager object
-HINSTANCE s_hEAXManInst; // Handle of EAXManager DLL
-EAXSet s_eaxSet; // EAXSet() function
-EAXGet s_eaxGet; // EAXGet() function
-EAXREVERBPROPERTIES s_eaxLPCur; // Current EAX Parameters
-LPENVTABLE s_lpEnvTable=NULL; // Stores information about each environment zone
-long s_lLastEnvUpdate; // Time of last EAX update
-long s_lNumEnvironments; // Number of environment zones
-long s_NumFXSlots; // Number of EAX 4.0 FX Slots
-FXSLOTINFO s_FXSlotInfo[EAX_MAX_FXSLOTS]; // Stores information about the EAX 4.0 FX Slots
+ALboolean s_bEAX; // Is EAX 4.0 support available
+bool s_bEALFileLoaded; // Has an .eal file been loaded for the current level
+bool s_bInWater; // Underwater effect currently active
+int s_EnvironmentID; // EAGLE ID of current environment
+LPEAXMANAGER s_lpEAXManager; // Pointer to EAXManager object
+HINSTANCE s_hEAXManInst; // Handle of EAXManager DLL
+EAXSet s_eaxSet; // EAXSet() function
+EAXGet s_eaxGet; // EAXGet() function
+EAXREVERBPROPERTIES s_eaxLPCur; // Current EAX Parameters
+LPENVTABLE s_lpEnvTable = NULL; // Stores information about each environment zone
+long s_lLastEnvUpdate; // Time of last EAX update
+long s_lNumEnvironments; // Number of environment zones
+long s_NumFXSlots; // Number of EAX 4.0 FX Slots
+FXSLOTINFO s_FXSlotInfo[EAX_MAX_FXSLOTS]; // Stores information about the EAX 4.0 FX Slots
static void InitEAXManager();
static void ReleaseEAXManager();
@@ -301,8 +292,7 @@ static void UpdateEAXBuffer(channel_t *ch);
static void EALFileInit(const char *level);
float CalcDistance(EMPOINT A, EMPOINT B);
-void Normalize(EAXVECTOR *v)
-{
+void Normalize(EAXVECTOR *v) {
float flMagnitude;
flMagnitude = (float)sqrt(sqr(v->x) + sqr(v->y) + sqr(v->z));
@@ -314,23 +304,23 @@ void Normalize(EAXVECTOR *v)
// EAX 4.0 GUIDS ... confidential information ...
-const GUID EAXPROPERTYID_EAX40_FXSlot0 = { 0xc4d79f1e, 0xf1ac, 0x436b, { 0xa8, 0x1d, 0xa7, 0x38, 0xe7, 0x4, 0x54, 0x69} };
+const GUID EAXPROPERTYID_EAX40_FXSlot0 = {0xc4d79f1e, 0xf1ac, 0x436b, {0xa8, 0x1d, 0xa7, 0x38, 0xe7, 0x4, 0x54, 0x69}};
-const GUID EAXPROPERTYID_EAX40_FXSlot1 = { 0x8c00e96, 0x74be, 0x4491, { 0x93, 0xaa, 0xe8, 0xad, 0x35, 0xa4, 0x91, 0x17} };
+const GUID EAXPROPERTYID_EAX40_FXSlot1 = {0x8c00e96, 0x74be, 0x4491, {0x93, 0xaa, 0xe8, 0xad, 0x35, 0xa4, 0x91, 0x17}};
-const GUID EAXPROPERTYID_EAX40_FXSlot2 = { 0x1d433b88, 0xf0f6, 0x4637, { 0x91, 0x9f, 0x60, 0xe7, 0xe0, 0x6b, 0x5e, 0xdd} };
+const GUID EAXPROPERTYID_EAX40_FXSlot2 = {0x1d433b88, 0xf0f6, 0x4637, {0x91, 0x9f, 0x60, 0xe7, 0xe0, 0x6b, 0x5e, 0xdd}};
-const GUID EAXPROPERTYID_EAX40_FXSlot3 = { 0xefff08ea, 0xc7d8, 0x44ab, { 0x93, 0xad, 0x6d, 0xbd, 0x5f, 0x91, 0x0, 0x64} };
+const GUID EAXPROPERTYID_EAX40_FXSlot3 = {0xefff08ea, 0xc7d8, 0x44ab, {0x93, 0xad, 0x6d, 0xbd, 0x5f, 0x91, 0x0, 0x64}};
-const GUID EAXPROPERTYID_EAX40_Context = { 0x1d4870ad, 0xdef, 0x43c0, { 0xa4, 0xc, 0x52, 0x36, 0x32, 0x29, 0x63, 0x42} };
+const GUID EAXPROPERTYID_EAX40_Context = {0x1d4870ad, 0xdef, 0x43c0, {0xa4, 0xc, 0x52, 0x36, 0x32, 0x29, 0x63, 0x42}};
-const GUID EAXPROPERTYID_EAX40_Source = { 0x1b86b823, 0x22df, 0x4eae, { 0x8b, 0x3c, 0x12, 0x78, 0xce, 0x54, 0x42, 0x27} };
+const GUID EAXPROPERTYID_EAX40_Source = {0x1b86b823, 0x22df, 0x4eae, {0x8b, 0x3c, 0x12, 0x78, 0xce, 0x54, 0x42, 0x27}};
-const GUID EAX_NULL_GUID = { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
+const GUID EAX_NULL_GUID = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
-const GUID EAX_PrimaryFXSlotID = { 0xf317866d, 0x924c, 0x450c, { 0x86, 0x1b, 0xe6, 0xda, 0xa2, 0x5e, 0x7c, 0x20} };
+const GUID EAX_PrimaryFXSlotID = {0xf317866d, 0x924c, 0x450c, {0x86, 0x1b, 0xe6, 0xda, 0xa2, 0x5e, 0x7c, 0x20}};
-const GUID EAX_REVERB_EFFECT = { 0xcf95c8f, 0xa3cc, 0x4849, { 0xb0, 0xb6, 0x83, 0x2e, 0xcc, 0x18, 0x22, 0xdf} };
+const GUID EAX_REVERB_EFFECT = {0xcf95c8f, 0xa3cc, 0x4849, {0xb0, 0xb6, 0x83, 0x2e, 0xcc, 0x18, 0x22, 0xdf}};
/**************************************************************************************************\
*
@@ -345,132 +335,114 @@ const GUID EAX_REVERB_EFFECT = { 0xcf95c8f, 0xa3cc, 0x4849, { 0xb0, 0xb6, 0x83,
#ifndef offsetof
#include
#endif
-static inline void Channel_Clear(channel_t *ch)
-{
+static inline void Channel_Clear(channel_t *ch) {
// memset (ch, 0, sizeof(*ch));
- memset(ch,0,offsetof(channel_t,MP3SlidingDecodeBuffer));
+ memset(ch, 0, offsetof(channel_t, MP3SlidingDecodeBuffer));
- byte *const p = (byte *)ch + offsetof(channel_t,MP3SlidingDecodeBuffer) + sizeof(ch->MP3SlidingDecodeBuffer);
+ byte *const p = (byte *)ch + offsetof(channel_t, MP3SlidingDecodeBuffer) + sizeof(ch->MP3SlidingDecodeBuffer);
- memset(p,0,(sizeof(*ch) - offsetof(channel_t,MP3SlidingDecodeBuffer)) - sizeof(ch->MP3SlidingDecodeBuffer));
+ memset(p, 0, (sizeof(*ch) - offsetof(channel_t, MP3SlidingDecodeBuffer)) - sizeof(ch->MP3SlidingDecodeBuffer));
}
// ====================================================================
// User-setable variables
// ====================================================================
-static void DynamicMusicInfoPrint(void)
-{
- if (bMusic_IsDynamic)
- {
+static void DynamicMusicInfoPrint(void) {
+ if (bMusic_IsDynamic) {
// horribly lazy... ;-)
//
- const char *psRequestMusicState = Music_BaseStateToString( eMusic_StateRequest );
- const char *psActualMusicState = Music_BaseStateToString( eMusic_StateActual, qtrue );
- if (psRequestMusicState == NULL)
- {
+ const char *psRequestMusicState = Music_BaseStateToString(eMusic_StateRequest);
+ const char *psActualMusicState = Music_BaseStateToString(eMusic_StateActual, qtrue);
+ if (psRequestMusicState == NULL) {
psRequestMusicState = "";
}
- if (psActualMusicState == NULL)
- {
- psActualMusicState = "";
+ if (psActualMusicState == NULL) {
+ psActualMusicState = "";
}
- Com_Printf("( Dynamic music ON, request state: '%s'(%d), actual: '%s' (%d) )\n", psRequestMusicState, eMusic_StateRequest, psActualMusicState, eMusic_StateActual);
- }
- else
- {
+ Com_Printf("( Dynamic music ON, request state: '%s'(%d), actual: '%s' (%d) )\n", psRequestMusicState, eMusic_StateRequest, psActualMusicState,
+ eMusic_StateActual);
+ } else {
Com_Printf("( Dynamic music OFF )\n");
}
}
void S_SoundInfo_f(void) {
- Com_Printf("----- Sound Info -----\n" );
+ Com_Printf("----- Sound Info -----\n");
if (!s_soundStarted) {
- Com_Printf ("sound system not started\n");
+ Com_Printf("sound system not started\n");
} else {
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
- Com_Printf("EAX 4.0 %s supported\n",s_bEAX?"is":"not");
- Com_Printf("Eal file %s loaded\n",s_bEALFileLoaded?"is":"not");
- Com_Printf("s_EnvironmentID = %d\n",s_EnvironmentID);
- Com_Printf("s_bInWater = %s\n",s_bInWater?"true":"false");
- }
- else
- {
+ if (s_UseOpenAL) {
+ Com_Printf("EAX 4.0 %s supported\n", s_bEAX ? "is" : "not");
+ Com_Printf("Eal file %s loaded\n", s_bEALFileLoaded ? "is" : "not");
+ Com_Printf("s_EnvironmentID = %d\n", s_EnvironmentID);
+ Com_Printf("s_bInWater = %s\n", s_bInWater ? "true" : "false");
+ } else {
#endif
Com_Printf("%5d stereo\n", dma.channels - 1);
Com_Printf("%5d samples\n", dma.samples);
Com_Printf("%5d samplebits\n", dma.samplebits);
Com_Printf("%5d submission_chunk\n", dma.submission_chunk);
Com_Printf("%5d speed\n", dma.speed);
- Com_Printf( "0x%" PRIxPTR " dma buffer\n", dma.buffer );
+ Com_Printf("0x%" PRIxPTR " dma buffer\n", dma.buffer);
#ifdef USE_OPENAL
}
#endif
- if (bMusic_IsDynamic)
- {
+ if (bMusic_IsDynamic) {
DynamicMusicInfoPrint();
- Com_Printf("( Dynamic music set name: \"%s\" )\n",sInfoOnly_CurrentDynamicMusicSet);
- }
- else
- {
- if (!s_allowDynamicMusic->integer)
- {
- Com_Printf("( Dynamic music inhibited (s_allowDynamicMusic == 0) )\n", sMusic_BackgroundLoop );
- }
- if ( tMusic_Info[eBGRNDTRACK_NONDYNAMIC].s_backgroundFile )
- {
- Com_Printf("Background file: %s\n", sMusic_BackgroundLoop );
+ Com_Printf("( Dynamic music set name: \"%s\" )\n", sInfoOnly_CurrentDynamicMusicSet);
+ } else {
+ if (!s_allowDynamicMusic->integer) {
+ Com_Printf("( Dynamic music inhibited (s_allowDynamicMusic == 0) )\n", sMusic_BackgroundLoop);
}
- else
- {
- Com_Printf("No background file.\n" );
+ if (tMusic_Info[eBGRNDTRACK_NONDYNAMIC].s_backgroundFile) {
+ Com_Printf("Background file: %s\n", sMusic_BackgroundLoop);
+ } else {
+ Com_Printf("No background file.\n");
}
}
}
S_DisplayFreeMemory();
- Com_Printf("----------------------\n" );
+ Com_Printf("----------------------\n");
}
-
-
/*
================
S_Init
================
*/
-void S_Init( void ) {
- qboolean r;
+void S_Init(void) {
+ qboolean r;
Com_Printf("\n------- sound initialization -------\n");
- s_allowDynamicMusic = Cvar_Get( "s_allowDynamicMusic", "1", CVAR_ARCHIVE_ND );
- s_debugdynamic = Cvar_Get( "s_debugdynamic", "0", 0 );
- s_initsound = Cvar_Get( "s_initsound", "1", CVAR_ARCHIVE | CVAR_LATCH );
- s_khz = Cvar_Get( "s_khz", "44", CVAR_ARCHIVE | CVAR_LATCH );
- s_language = Cvar_Get( "s_language", "english", CVAR_ARCHIVE | CVAR_NORESTART );
- s_lip_threshold_1 = Cvar_Get( "s_threshold1", "0.3", 0 );
- s_lip_threshold_2 = Cvar_Get( "s_threshold2", "4", 0 );
- s_lip_threshold_3 = Cvar_Get( "s_threshold3", "6", 0 );
- s_lip_threshold_4 = Cvar_Get( "s_threshold4", "8", 0 );
- s_mixahead = Cvar_Get( "s_mixahead", "0.2", CVAR_ARCHIVE );
- s_mixPreStep = Cvar_Get( "s_mixPreStep", "0.05", CVAR_ARCHIVE );
- s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE );
- s_separation = Cvar_Get( "s_separation", "0.5", CVAR_ARCHIVE );
- s_show = Cvar_Get( "s_show", "0", CVAR_CHEAT );
- s_testsound = Cvar_Get( "s_testsound", "0", CVAR_CHEAT );
- s_volume = Cvar_Get( "s_volume", "0.5", CVAR_ARCHIVE );
- s_volumeVoice = Cvar_Get( "s_volumeVoice", "1.0", CVAR_ARCHIVE );
+ s_allowDynamicMusic = Cvar_Get("s_allowDynamicMusic", "1", CVAR_ARCHIVE_ND);
+ s_debugdynamic = Cvar_Get("s_debugdynamic", "0", 0);
+ s_initsound = Cvar_Get("s_initsound", "1", CVAR_ARCHIVE | CVAR_LATCH);
+ s_khz = Cvar_Get("s_khz", "44", CVAR_ARCHIVE | CVAR_LATCH);
+ s_language = Cvar_Get("s_language", "english", CVAR_ARCHIVE | CVAR_NORESTART);
+ s_lip_threshold_1 = Cvar_Get("s_threshold1", "0.3", 0);
+ s_lip_threshold_2 = Cvar_Get("s_threshold2", "4", 0);
+ s_lip_threshold_3 = Cvar_Get("s_threshold3", "6", 0);
+ s_lip_threshold_4 = Cvar_Get("s_threshold4", "8", 0);
+ s_mixahead = Cvar_Get("s_mixahead", "0.2", CVAR_ARCHIVE);
+ s_mixPreStep = Cvar_Get("s_mixPreStep", "0.05", CVAR_ARCHIVE);
+ s_musicVolume = Cvar_Get("s_musicvolume", "0.25", CVAR_ARCHIVE);
+ s_separation = Cvar_Get("s_separation", "0.5", CVAR_ARCHIVE);
+ s_show = Cvar_Get("s_show", "0", CVAR_CHEAT);
+ s_testsound = Cvar_Get("s_testsound", "0", CVAR_CHEAT);
+ s_volume = Cvar_Get("s_volume", "0.5", CVAR_ARCHIVE);
+ s_volumeVoice = Cvar_Get("s_volumeVoice", "1.0", CVAR_ARCHIVE);
MP3_InitCvars();
- if ( !s_initsound->integer ) {
- s_soundStarted = 0; // needed in case you set s_initsound to 0 midgame then snd_restart (div0 err otherwise later)
- Com_Printf ("not initializing.\n");
+ if (!s_initsound->integer) {
+ s_soundStarted = 0; // needed in case you set s_initsound to 0 midgame then snd_restart (div0 err otherwise later)
+ Com_Printf("not initializing.\n");
Com_Printf("------------------------------------\n");
return;
}
@@ -485,23 +457,22 @@ void S_Init( void ) {
Cmd_AddCommand("s_dynamic", S_SetDynamicMusic_f);
#ifdef USE_OPENAL
- cvar_t *cv = Cvar_Get("s_UseOpenAL" , "0",CVAR_ARCHIVE|CVAR_LATCH);
+ cvar_t *cv = Cvar_Get("s_UseOpenAL", "0", CVAR_ARCHIVE | CVAR_LATCH);
s_UseOpenAL = !!(cv->integer);
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
int i, j;
- ALCdevice *ALCDevice = alcOpenDevice((ALubyte*)"DirectSound3D");
+ ALCdevice *ALCDevice = alcOpenDevice((ALubyte *)"DirectSound3D");
if (!ALCDevice)
return;
- //Create context(s)
+ // Create context(s)
ALCcontext *ALCContext = alcCreateContext(ALCDevice, NULL);
if (!ALCContext)
return;
- //Set active context
+ // Set active context
alcMakeContextCurrent(ALCContext);
if (alcGetError(ALCDevice) != ALC_NO_ERROR)
return;
@@ -514,15 +485,15 @@ void S_Init( void ) {
S_StopAllSounds();
- //S_SoundInfo_f();
+ // S_SoundInfo_f();
// Set Listener attributes
- ALfloat listenerPos[]={0.0,0.0,0.0};
- ALfloat listenerVel[]={0.0,0.0,0.0};
- ALfloat listenerOri[]={0.0,0.0,-1.0, 0.0,1.0,0.0};
- alListenerfv(AL_POSITION,listenerPos);
- alListenerfv(AL_VELOCITY,listenerVel);
- alListenerfv(AL_ORIENTATION,listenerOri);
+ ALfloat listenerPos[] = {0.0, 0.0, 0.0};
+ ALfloat listenerVel[] = {0.0, 0.0, 0.0};
+ ALfloat listenerOri[] = {0.0, 0.0, -1.0, 0.0, 1.0, 0.0};
+ alListenerfv(AL_POSITION, listenerPos);
+ alListenerfv(AL_VELOCITY, listenerVel);
+ alListenerfv(AL_ORIENTATION, listenerOri);
InitEAXManager();
@@ -531,25 +502,21 @@ void S_Init( void ) {
s_numChannels = 0;
// Create as many AL Sources (up to Max) as possible
- for (i = 0; i < MAX_CHANNELS; i++)
- {
+ for (i = 0; i < MAX_CHANNELS; i++) {
alGenSources(1, &s_channels[i].alSource); // &g_Sources[i]);
- if (alGetError() != AL_NO_ERROR)
- {
+ if (alGetError() != AL_NO_ERROR) {
// Reached limit of sources
break;
}
alSourcef(s_channels[i].alSource, AL_REFERENCE_DISTANCE, DEFAULT_REF_DISTANCE);
- if (alGetError() != AL_NO_ERROR)
- {
+ if (alGetError() != AL_NO_ERROR) {
break;
}
// Sources / Channels are not sending to any Slots (other than the Listener / Primary FX Slot)
s_channels[i].lSlotID = -1;
- if (s_bEAX)
- {
+ if (s_bEAX) {
// Remove the RoomAuto flag from each Source (to remove Reverb Engine Statistical
// model that is assuming units are in metres)
// Without this call reverb sends from the sources will attenuate too quickly
@@ -557,9 +524,7 @@ void S_Init( void ) {
unsigned long ulFlags = 0;
- if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_FLAGS,
- s_channels[i].alSource, &ulFlags, sizeof(ulFlags))!=AL_NO_ERROR)
- {
+ if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_FLAGS, s_channels[i].alSource, &ulFlags, sizeof(ulFlags)) != AL_NO_ERROR) {
#ifdef _WIN32
OutputDebugString("Failed to to remove Source flags\n");
#endif
@@ -571,10 +536,8 @@ void S_Init( void ) {
// Generate AL Buffers for streaming audio playback (used for MP3s)
channel_t *ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- for (j = 0; j < NUM_STREAMING_BUFFERS; j++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ for (j = 0; j < NUM_STREAMING_BUFFERS; j++) {
alGenBuffers(1, &(ch->buffers[j].BufferID));
ch->buffers[j].Status = UNQUEUED;
ch->buffers[j].Data = (char *)Z_Malloc(STREAMING_BUFFER_SIZE, TAG_SND_RAWDATA, qfalse);
@@ -611,51 +574,47 @@ void S_Init( void ) {
// s_init could be called in game, if so there may be an .eal file
// for this level
- const char *mapname = Cvar_VariableString( "mapname" );
+ const char *mapname = Cvar_VariableString("mapname");
EALFileInit(mapname);
- }
- else
- {
+ } else {
#endif
r = SNDDMA_Init(s_khz->integer);
- if ( r ) {
+ if (r) {
s_soundStarted = 1;
s_soundMuted = qtrue;
- // s_numSfx = 0; // do NOT do this here now!!!
+ // s_numSfx = 0; // do NOT do this here now!!!
s_soundtime = 0;
s_paintedtime = 0;
- S_StopAllSounds ();
+ S_StopAllSounds();
- //S_SoundInfo_f();
+ // S_SoundInfo_f();
}
#ifdef USE_OPENAL
}
#endif
-// Com_Printf("------------------------------------\n");
+ // Com_Printf("------------------------------------\n");
-// Com_Printf("\n--- ambient sound initialization ---\n");
+ // Com_Printf("\n--- ambient sound initialization ---\n");
AS_Init();
}
// only called from snd_restart. QA request...
//
-void S_ReloadAllUsedSounds(void)
-{
- if (s_soundStarted && !s_soundMuted )
- {
+void S_ReloadAllUsedSounds(void) {
+ if (s_soundStarted && !s_soundMuted) {
// new bit, reload all soundsthat are used on the current level...
//
- for (int i=1 ; i < s_numSfx ; i++) // start @ 1 to skip freeing default sound
+ for (int i = 1; i < s_numSfx; i++) // start @ 1 to skip freeing default sound
{
sfx_t *sfx = &s_knownSfx[i];
- if (!sfx->bInMemory && !sfx->bDefaultSound && sfx->iLastLevelUsedOn == re.RegisterMedia_GetLevel()){
+ if (!sfx->bInMemory && !sfx->bDefaultSound && sfx->iLastLevelUsedOn == re.RegisterMedia_GetLevel()) {
S_memoryLoad(sfx);
}
}
@@ -666,9 +625,8 @@ void S_ReloadAllUsedSounds(void)
// Shutdown sound engine
// =======================================================================
-void S_Shutdown( void )
-{
- if ( !s_soundStarted ) {
+void S_Shutdown(void) {
+ if (!s_soundStarted) {
return;
}
@@ -676,26 +634,21 @@ void S_Shutdown( void )
S_UnCacheDynamicMusic();
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
int i, j;
// Release all the AL Sources (including Music channel (Source 0))
- for (i = 0; i < s_numChannels; i++)
- {
+ for (i = 0; i < s_numChannels; i++) {
alDeleteSources(1, &(s_channels[i].alSource));
}
// Release Streaming AL Buffers
channel_t *ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- for (j = 0; j < NUM_STREAMING_BUFFERS; j++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ for (j = 0; j < NUM_STREAMING_BUFFERS; j++) {
alDeleteBuffers(1, &(ch->buffers[j].BufferID));
ch->buffers[j].BufferID = 0;
ch->buffers[j].Status = UNQUEUED;
- if (ch->buffers[j].Data)
- {
+ if (ch->buffers[j].Data) {
Z_Free(ch->buffers[j].Data);
ch->buffers[j].Data = NULL;
}
@@ -715,9 +668,7 @@ void S_Shutdown( void )
s_numChannels = 0;
- }
- else
- {
+ } else {
#endif
SNDDMA_Shutdown();
#ifdef USE_OPENAL
@@ -742,22 +693,18 @@ void S_Shutdown( void )
Mutes / Unmutes all OpenAL sound
*/
#ifdef USE_OPENAL
-void S_AL_MuteAllSounds(qboolean bMute)
-{
- if (!s_soundStarted)
- return;
-
- if (!s_UseOpenAL)
- return;
-
- if (bMute)
- {
- alListenerf(AL_GAIN, 0.0f);
- }
- else
- {
- alListenerf(AL_GAIN, 1.0f);
- }
+void S_AL_MuteAllSounds(qboolean bMute) {
+ if (!s_soundStarted)
+ return;
+
+ if (!s_UseOpenAL)
+ return;
+
+ if (bMute) {
+ alListenerf(AL_GAIN, 0.0f);
+ } else {
+ alListenerf(AL_GAIN, 1.0f);
+ }
}
#endif
@@ -770,20 +717,22 @@ return a hash value for the sfx name
================
*/
static long S_HashSFXName(const char *name) {
- int i;
- long hash;
- char letter;
+ int i;
+ long hash;
+ char letter;
hash = 0;
i = 0;
while (name[i] != '\0') {
letter = tolower(name[i]);
- if (letter =='.') break; // don't include extension
- if (letter =='\\') letter = '/'; // damn path names
- hash+=(long)(letter)*(i+119);
+ if (letter == '.')
+ break; // don't include extension
+ if (letter == '\\')
+ letter = '/'; // damn path names
+ hash += (long)(letter) * (i + 119);
i++;
}
- hash &= (LOOP_HASH-1);
+ hash &= (LOOP_HASH - 1);
return hash;
}
@@ -794,59 +743,57 @@ S_FindName
Will allocate a new sfx if it isn't found
==================
*/
-sfx_t *S_FindName( const char *name ) {
- int i;
- int hash;
+sfx_t *S_FindName(const char *name) {
+ int i;
+ int hash;
- sfx_t *sfx;
+ sfx_t *sfx;
if (!name) {
- Com_Error (ERR_FATAL, "S_FindName: NULL");
+ Com_Error(ERR_FATAL, "S_FindName: NULL");
}
if (!name[0]) {
- Com_Error (ERR_FATAL, "S_FindName: empty name");
+ Com_Error(ERR_FATAL, "S_FindName: empty name");
}
if (strlen(name) >= MAX_QPATH) {
- Com_Error (ERR_FATAL, "Sound name too long: %s", name);
+ Com_Error(ERR_FATAL, "Sound name too long: %s", name);
}
char sSoundNameNoExt[MAX_QPATH];
- COM_StripExtension(name,sSoundNameNoExt, sizeof(sSoundNameNoExt));
+ COM_StripExtension(name, sSoundNameNoExt, sizeof(sSoundNameNoExt));
hash = S_HashSFXName(sSoundNameNoExt);
sfx = sfxHash[hash];
// see if already loaded
while (sfx) {
- if (!Q_stricmp(sfx->sSoundName, sSoundNameNoExt) ) {
+ if (!Q_stricmp(sfx->sSoundName, sSoundNameNoExt)) {
return sfx;
}
sfx = sfx->next;
}
-/*
- // find a free sfx
- for (i=0 ; i < s_numSfx ; i++) {
- if (!s_knownSfx[i].soundName[0]) {
- break;
+ /*
+ // find a free sfx
+ for (i=0 ; i < s_numSfx ; i++) {
+ if (!s_knownSfx[i].soundName[0]) {
+ break;
+ }
}
- }
-*/
- i = s_numSfx; //we don't clear the soundName after failed loads any more, so it'll always be the last entry
+ */
+ i = s_numSfx; // we don't clear the soundName after failed loads any more, so it'll always be the last entry
- if (s_numSfx == MAX_SFX)
- {
+ if (s_numSfx == MAX_SFX) {
// ok, no sfx's free, but are there any with defaultSound set? (which the registering ent will never
// see because he gets zero returned if it's default...)
//
- for (i=0 ; i < s_numSfx ; i++) {
+ for (i = 0; i < s_numSfx; i++) {
if (s_knownSfx[i].bDefaultSound) {
break;
}
}
- if (i==s_numSfx)
- {
+ if (i == s_numSfx) {
// genuinely out of handles...
// if we ever reach this, let me know and I'll either boost the array or put in a map-used-on
@@ -855,18 +802,16 @@ sfx_t *S_FindName( const char *name ) {
// events, so current MAX_SFX limit should do, or only need a small boost... -ste
//
- Com_Error (ERR_FATAL, "S_FindName: out of sfx_t");
+ Com_Error(ERR_FATAL, "S_FindName: out of sfx_t");
}
- }
- else
- {
+ } else {
s_numSfx++;
}
sfx = &s_knownSfx[i];
- memset (sfx, 0, sizeof(*sfx));
+ memset(sfx, 0, sizeof(*sfx));
Q_strncpyz(sfx->sSoundName, sSoundNameNoExt, sizeof(sfx->sSoundName));
- Q_strlwr(sfx->sSoundName);//force it down low
+ Q_strlwr(sfx->sSoundName); // force it down low
sfx->next = sfxHash[hash];
sfxHash[hash] = sfx;
@@ -880,16 +825,15 @@ S_DefaultSound
=================
*/
#ifdef _DEBUG
-static void S_DefaultSound( sfx_t *sfx ) {
+static void S_DefaultSound(sfx_t *sfx) {
- int i;
+ int i;
- sfx->iSoundLengthInSamples = 512; // #samples, ie shorts
- sfx->pSoundData = (short *) SND_malloc(512*2, sfx); // ... so *2 for alloc bytes
- sfx->bInMemory = true;
+ sfx->iSoundLengthInSamples = 512; // #samples, ie shorts
+ sfx->pSoundData = (short *)SND_malloc(512 * 2, sfx); // ... so *2 for alloc bytes
+ sfx->bInMemory = true;
- for ( i=0 ; i < sfx->iSoundLengthInSamples ; i++ )
- {
+ for (i = 0; i < sfx->iSoundLengthInSamples; i++) {
sfx->pSoundData[i] = i;
}
}
@@ -904,7 +848,7 @@ This is called when the hunk is cleared and the sounds
are no longer valid.
===================
*/
-void S_DisableSounds( void ) {
+void S_DisableSounds(void) {
S_StopAllSounds();
s_soundMuted = qtrue;
}
@@ -915,19 +859,16 @@ S_BeginRegistration
=====================
*/
-void S_BeginRegistration( void )
-{
- s_soundMuted = qfalse; // we can play again
+void S_BeginRegistration(void) {
+ s_soundMuted = qfalse; // we can play again
#ifdef USE_OPENAL
// Find name of level so we can load in the appropriate EAL file
- if (s_UseOpenAL)
- {
- const char *mapname = Cvar_VariableString( "mapname" );
+ if (s_UseOpenAL) {
+ const char *mapname = Cvar_VariableString("mapname");
EALFileInit(mapname);
// clear carry crap from previous map
- for (int i = 0; i < EAX_MAX_FXSLOTS; i++)
- {
+ for (int i = 0; i < EAX_MAX_FXSLOTS; i++) {
s_FXSlotInfo[i].lEnvID = -1;
}
}
@@ -937,12 +878,12 @@ void S_BeginRegistration( void )
SND_setup();
s_numSfx = 0;
- memset( s_knownSfx, 0, sizeof( s_knownSfx ) );
- memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH);
+ memset(s_knownSfx, 0, sizeof(s_knownSfx));
+ memset(sfxHash, 0, sizeof(sfx_t *) * LOOP_HASH);
#ifdef _DEBUG
- sfx_t *sfx = S_FindName( "***DEFAULT***" );
- S_DefaultSound( sfx );
+ sfx_t *sfx = S_FindName("***DEFAULT***");
+ S_DefaultSound(sfx);
#else
S_RegisterSound("sound/null.wav");
#endif
@@ -950,11 +891,9 @@ void S_BeginRegistration( void )
}
#ifdef USE_OPENAL
-static void EALFileInit(const char *level)
-{
+static void EALFileInit(const char *level) {
// If an EAL File is already unloaded, remove it
- if (s_bEALFileLoaded)
- {
+ if (s_bEALFileLoaded) {
UnloadEALFile();
}
@@ -962,34 +901,27 @@ static void EALFileInit(const char *level)
s_bInWater = false;
// Try and load an EAL file for the new level
- char name[MAX_QPATH];
+ char name[MAX_QPATH];
COM_StripExtension(level, name, sizeof(name));
- char szEALFilename[MAX_QPATH];
+ char szEALFilename[MAX_QPATH];
Com_sprintf(szEALFilename, MAX_QPATH, "eagle/%s.eal", name);
s_bEALFileLoaded = LoadEALFile(szEALFilename);
- if (!s_bEALFileLoaded)
- {
+ if (!s_bEALFileLoaded) {
Com_sprintf(szEALFilename, MAX_QPATH, "base/eagle/%s.eal", name);
s_bEALFileLoaded = LoadEALFile(szEALFilename);
}
- if (s_bEALFileLoaded)
- {
+ if (s_bEALFileLoaded) {
s_lLastEnvUpdate = timeGetTime();
- }
- else
- {
+ } else {
// Mute reverbs if no EAL file is found
- if ((s_bEAX)&&(s_eaxSet))
- {
+ if ((s_bEAX) && (s_eaxSet)) {
long lRoom = -10000;
- for (int i = 0; i < s_NumFXSlots; i++)
- {
- s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_ROOM, NULL,
- &lRoom, sizeof(long));
+ for (int i = 0; i < s_NumFXSlots; i++) {
+ s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_ROOM, NULL, &lRoom, sizeof(long));
}
}
}
@@ -1003,37 +935,33 @@ S_RegisterSound
Creates a default buzz sound if the file can't be loaded
==================
*/
-sfxHandle_t S_RegisterSound( const char *name)
-{
- sfx_t *sfx;
+sfxHandle_t S_RegisterSound(const char *name) {
+ sfx_t *sfx;
if (!s_soundStarted) {
return 0;
}
- if ( strlen( name ) >= MAX_QPATH ) {
- Com_Printf( S_COLOR_RED"Sound name exceeds MAX_QPATH - %s\n", name );
+ if (strlen(name) >= MAX_QPATH) {
+ Com_Printf(S_COLOR_RED "Sound name exceeds MAX_QPATH - %s\n", name);
return 0;
}
- sfx = S_FindName( name );
+ sfx = S_FindName(name);
SND_TouchSFX(sfx);
- if ( sfx->bDefaultSound )
+ if (sfx->bDefaultSound)
return 0;
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
if ((sfx->pSoundData) || (sfx->Buffer))
return sfx - s_knownSfx;
- }
- else
+ } else
#endif
{
- if ( sfx->pSoundData )
- {
+ if (sfx->pSoundData) {
return sfx - s_knownSfx;
}
}
@@ -1042,9 +970,9 @@ sfxHandle_t S_RegisterSound( const char *name)
S_memoryLoad(sfx);
- if ( sfx->bDefaultSound ) {
+ if (sfx->bDefaultSound) {
#ifndef FINAL_BUILD
- Com_DPrintf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->sSoundName );
+ Com_DPrintf(S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->sSoundName);
#endif
return 0;
}
@@ -1052,33 +980,29 @@ sfxHandle_t S_RegisterSound( const char *name)
return sfx - s_knownSfx;
}
-void S_memoryLoad(sfx_t *sfx)
-{
+void S_memoryLoad(sfx_t *sfx) {
// load the sound file...
//
- if ( !S_LoadSound( sfx ) )
- {
-// Com_Printf( S_COLOR_YELLOW "WARNING: couldn't load sound: %s\n", sfx->sSoundName );
+ if (!S_LoadSound(sfx)) {
+ // Com_Printf( S_COLOR_YELLOW "WARNING: couldn't load sound: %s\n", sfx->sSoundName );
sfx->bDefaultSound = true;
}
sfx->bInMemory = true;
}
//=============================================================================
-static qboolean S_CheckChannelStomp( int chan1, int chan2 )
-{
+static qboolean S_CheckChannelStomp(int chan1, int chan2) {
#ifdef USE_OPENAL
if (!s_UseOpenAL)
#endif
{
- if ( chan1 == chan2 )
- {
+ if (chan1 == chan2) {
return qtrue;
}
}
- if ( ( chan1 == CHAN_VOICE || chan1 == CHAN_VOICE_ATTEN || chan1 == CHAN_VOICE_GLOBAL ) && ( chan2 == CHAN_VOICE || chan2 == CHAN_VOICE_ATTEN || chan2 == CHAN_VOICE_GLOBAL ) )
- {
+ if ((chan1 == CHAN_VOICE || chan1 == CHAN_VOICE_ATTEN || chan1 == CHAN_VOICE_GLOBAL) &&
+ (chan2 == CHAN_VOICE || chan2 == CHAN_VOICE_ATTEN || chan2 == CHAN_VOICE_GLOBAL)) {
return qtrue;
}
@@ -1090,44 +1014,37 @@ static qboolean S_CheckChannelStomp( int chan1, int chan2 )
S_PickChannel
=================
*/
-channel_t *S_PickChannel(int entnum, int entchannel)
-{
- int ch_idx;
- channel_t *ch, *firstToDie;
- qboolean foundChan = qfalse;
+channel_t *S_PickChannel(int entnum, int entchannel) {
+ int ch_idx;
+ channel_t *ch, *firstToDie;
+ qboolean foundChan = qfalse;
#ifdef USE_OPENAL
if (s_UseOpenAL)
return S_OpenALPickChannel(entnum, entchannel);
#endif
- if ( entchannel<0 ) {
- Com_Error (ERR_DROP, "S_PickChannel: entchannel<0");
+ if (entchannel < 0) {
+ Com_Error(ERR_DROP, "S_PickChannel: entchannel<0");
}
// Check for replacement sound, or find the best one to replace
- firstToDie = &s_channels[0];
+ firstToDie = &s_channels[0];
- for ( int pass = 0; (pass < ((entchannel == CHAN_AUTO || entchannel == CHAN_LESS_ATTEN)?1:2)) && !foundChan; pass++ )
- {
- for (ch_idx = 0, ch = &s_channels[0]; ch_idx < MAX_CHANNELS ; ch_idx++, ch++ )
- {
- if ( entchannel == CHAN_AUTO || entchannel == CHAN_LESS_ATTEN || pass > 0 )
- {//if we're on the second pass, just find the first open chan
- if ( !ch->thesfx )
- {//grab the first open channel
+ for (int pass = 0; (pass < ((entchannel == CHAN_AUTO || entchannel == CHAN_LESS_ATTEN) ? 1 : 2)) && !foundChan; pass++) {
+ for (ch_idx = 0, ch = &s_channels[0]; ch_idx < MAX_CHANNELS; ch_idx++, ch++) {
+ if (entchannel == CHAN_AUTO || entchannel == CHAN_LESS_ATTEN || pass > 0) { // if we're on the second pass, just find the first open chan
+ if (!ch->thesfx) { // grab the first open channel
firstToDie = ch;
break;
}
- }
- else if ( ch->entnum == entnum && S_CheckChannelStomp( ch->entchannel, entchannel ) )
- {
+ } else if (ch->entnum == entnum && S_CheckChannelStomp(ch->entchannel, entchannel)) {
// always override sound from same entity
- if ( s_show->integer == 1 && ch->thesfx ) {
- Com_Printf( S_COLOR_YELLOW"...overrides %s\n", ch->thesfx->sSoundName );
- ch->thesfx = 0; //just to clear the next error msg
+ if (s_show->integer == 1 && ch->thesfx) {
+ Com_Printf(S_COLOR_YELLOW "...overrides %s\n", ch->thesfx->sSoundName);
+ ch->thesfx = 0; // just to clear the next error msg
}
firstToDie = ch;
foundChan = qtrue;
@@ -1135,26 +1052,26 @@ channel_t *S_PickChannel(int entnum, int entchannel)
}
// don't let anything else override local player sounds
- if ( ch->entnum == listener_number && entnum != listener_number && ch->thesfx) {
+ if (ch->entnum == listener_number && entnum != listener_number && ch->thesfx) {
continue;
}
// don't override loop sounds
- if ( ch->loopSound ) {
+ if (ch->loopSound) {
continue;
}
- if ( ch->startSample < firstToDie->startSample ) {
+ if (ch->startSample < firstToDie->startSample) {
firstToDie = ch;
}
}
}
- if ( s_show->integer == 1 && firstToDie->thesfx ) {
- Com_Printf( S_COLOR_RED"***kicking %s\n", firstToDie->thesfx->sSoundName );
+ if (s_show->integer == 1 && firstToDie->thesfx) {
+ Com_Printf(S_COLOR_RED "***kicking %s\n", firstToDie->thesfx->sSoundName);
}
- Channel_Clear(firstToDie); // memset(firstToDie, 0, sizeof(*firstToDie));
+ Channel_Clear(firstToDie); // memset(firstToDie, 0, sizeof(*firstToDie));
return firstToDie;
}
@@ -1166,30 +1083,26 @@ channel_t *S_PickChannel(int entnum, int entchannel)
on hardware this way esp. rapid fire modes of weapons!
*/
#ifdef USE_OPENAL
-channel_t *S_OpenALPickChannel(int entnum, int entchannel)
-{
- int ch_idx;
- channel_t *ch, *ch_firstToDie;
- bool foundChan = false;
- float source_pos[3];
-
- if ( entchannel < 0 )
- {
- Com_Error (ERR_DROP, "S_PickChannel: entchannel<0");
+channel_t *S_OpenALPickChannel(int entnum, int entchannel) {
+ int ch_idx;
+ channel_t *ch, *ch_firstToDie;
+ bool foundChan = false;
+ float source_pos[3];
+
+ if (entchannel < 0) {
+ Com_Error(ERR_DROP, "S_PickChannel: entchannel<0");
}
// Check for replacement sound, or find the best one to replace
- ch_firstToDie = s_channels + 1; // channel 0 is reserved for Music
+ ch_firstToDie = s_channels + 1; // channel 0 is reserved for Music
- for (ch_idx = 1, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++)
- {
- if ( ch->entnum == entnum && S_CheckChannelStomp( ch->entchannel, entchannel ) )
- {
+ for (ch_idx = 1, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++) {
+ if (ch->entnum == entnum && S_CheckChannelStomp(ch->entchannel, entchannel)) {
// always override sound from same entity
- if ( s_show->integer == 1 && ch->thesfx ) {
- Com_Printf( S_COLOR_YELLOW"...overrides %s\n", ch->thesfx->sSoundName );
- ch->thesfx = 0; //just to clear the next error msg
+ if (s_show->integer == 1 && ch->thesfx) {
+ Com_Printf(S_COLOR_YELLOW "...overrides %s\n", ch->thesfx->sSoundName);
+ ch->thesfx = 0; // just to clear the next error msg
}
ch_firstToDie = ch;
foundChan = true;
@@ -1198,24 +1111,18 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
}
if (!foundChan)
- for (ch_idx = 1, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++)
- {
- // See if the channel is free
- if (!ch->thesfx)
- {
- ch_firstToDie = ch;
- foundChan = true;
- break;
+ for (ch_idx = 1, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++) {
+ // See if the channel is free
+ if (!ch->thesfx) {
+ ch_firstToDie = ch;
+ foundChan = true;
+ break;
+ }
}
- }
- if (!foundChan)
- {
- for (ch_idx = 1, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++)
- {
- if ( (ch->entnum == entnum) && (ch->entchannel == entchannel) && (ch->entchannel != CHAN_AMBIENT)
- && (ch->entnum != listener_number) )
- {
+ if (!foundChan) {
+ for (ch_idx = 1, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++) {
+ if ((ch->entnum == entnum) && (ch->entchannel == entchannel) && (ch->entchannel != CHAN_AMBIENT) && (ch->entnum != listener_number)) {
// Same entity and same type of sound effect (entchannel)
ch_firstToDie = ch;
foundChan = true;
@@ -1227,13 +1134,11 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
int longestDist;
int dist;
- if (!foundChan)
- {
+ if (!foundChan) {
// Find sound effect furthest from listener
ch = s_channels + 1;
- if (ch->fixed_origin)
- {
+ if (ch->fixed_origin) {
// Convert to Open AL co-ordinates
source_pos[0] = ch->origin[0];
source_pos[1] = ch->origin[2];
@@ -1242,22 +1147,16 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
longestDist = ((listener_pos[0] - source_pos[0]) * (listener_pos[0] - source_pos[0])) +
((listener_pos[1] - source_pos[1]) * (listener_pos[1] - source_pos[1])) +
((listener_pos[2] - source_pos[2]) * (listener_pos[2] - source_pos[2]));
- }
- else
- {
+ } else {
if (ch->entnum == listener_number)
longestDist = 0;
- else
- {
- if (ch->bLooping)
- {
+ else {
+ if (ch->bLooping) {
// Convert to Open AL co-ordinates
source_pos[0] = loopSounds[ch->entnum].origin[0];
source_pos[1] = loopSounds[ch->entnum].origin[2];
source_pos[2] = -loopSounds[ch->entnum].origin[1];
- }
- else
- {
+ } else {
// Convert to Open AL co-ordinates
source_pos[0] = s_entityPosition[ch->entnum][0];
source_pos[1] = s_entityPosition[ch->entnum][2];
@@ -1270,10 +1169,8 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
}
}
- for (ch_idx = 2, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++)
- {
- if (ch->fixed_origin)
- {
+ for (ch_idx = 2, ch = s_channels + ch_idx; ch_idx < s_numChannels; ch_idx++, ch++) {
+ if (ch->fixed_origin) {
// Convert to Open AL co-ordinates
source_pos[0] = ch->origin[0];
source_pos[1] = ch->origin[2];
@@ -1282,22 +1179,16 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
dist = ((listener_pos[0] - source_pos[0]) * (listener_pos[0] - source_pos[0])) +
((listener_pos[1] - source_pos[1]) * (listener_pos[1] - source_pos[1])) +
((listener_pos[2] - source_pos[2]) * (listener_pos[2] - source_pos[2]));
- }
- else
- {
+ } else {
if (ch->entnum == listener_number)
dist = 0;
- else
- {
- if (ch->bLooping)
- {
+ else {
+ if (ch->bLooping) {
// Convert to Open AL co-ordinates
source_pos[0] = loopSounds[ch->entnum].origin[0];
source_pos[1] = loopSounds[ch->entnum].origin[2];
source_pos[2] = -loopSounds[ch->entnum].origin[1];
- }
- else
- {
+ } else {
// Convert to Open AL co-ordinates
source_pos[0] = s_entityPosition[ch->entnum][0];
source_pos[1] = s_entityPosition[ch->entnum][2];
@@ -1305,24 +1196,21 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
}
dist = ((listener_pos[0] - source_pos[0]) * (listener_pos[0] - source_pos[0])) +
- ((listener_pos[1] - source_pos[1]) * (listener_pos[1] - source_pos[1])) +
+ ((listener_pos[1] - source_pos[1]) * (listener_pos[1] - source_pos[1])) +
((listener_pos[2] - source_pos[2]) * (listener_pos[2] - source_pos[2]));
}
}
- if (dist > longestDist)
- {
+ if (dist > longestDist) {
longestDist = dist;
ch_firstToDie = ch;
}
}
}
- if (ch_firstToDie->bPlaying)
- {
- if (s_show->integer == 1 && ch_firstToDie->thesfx )
- {
- Com_Printf(S_COLOR_RED"***kicking %s\n", ch_firstToDie->thesfx->sSoundName );
+ if (ch_firstToDie->bPlaying) {
+ if (s_show->integer == 1 && ch_firstToDie->thesfx) {
+ Com_Printf(S_COLOR_RED "***kicking %s\n", ch_firstToDie->thesfx->sSoundName);
}
// Stop sound
@@ -1336,7 +1224,7 @@ channel_t *S_OpenALPickChannel(int entnum, int entchannel)
ch_firstToDie->bProcessed = false;
ch_firstToDie->bStreaming = false;
- return ch_firstToDie;
+ return ch_firstToDie;
}
#endif
@@ -1347,82 +1235,67 @@ S_SpatializeOrigin
Used for spatializing s_channels
=================
*/
-static void S_SpatializeOrigin (const vec3_t origin, float master_vol, int *left_vol, int *right_vol, soundChannel_t channel)
-{
- vec_t dot;
- vec_t dist;
- vec_t lscale, rscale, scale;
- vec3_t source_vec;
- float dist_mult = SOUND_ATTENUATE;
+static void S_SpatializeOrigin(const vec3_t origin, float master_vol, int *left_vol, int *right_vol, soundChannel_t channel) {
+ vec_t dot;
+ vec_t dist;
+ vec_t lscale, rscale, scale;
+ vec3_t source_vec;
+ float dist_mult = SOUND_ATTENUATE;
// calculate stereo seperation and distance attenuation
VectorSubtract(origin, listener_origin, source_vec);
dist = VectorNormalize(source_vec);
- if ( channel == CHAN_VOICE )
- {
+ if (channel == CHAN_VOICE) {
dist -= SOUND_FULLVOLUME * 3.0f;
-// dist_mult = VOICE_ATTENUATE; // tweak added (this fixes an NPC dialogue "in your ears" bug, but we're not sure if it'll make a bunch of others fade too early. Too close to shipping...)
- }
- else if ( channel == CHAN_LESS_ATTEN )
- {
+ // dist_mult = VOICE_ATTENUATE; // tweak added (this fixes an NPC dialogue "in your ears" bug, but we're not sure if it'll make a bunch of others
+ //fade too early. Too close to shipping...)
+ } else if (channel == CHAN_LESS_ATTEN) {
dist -= SOUND_FULLVOLUME * 5.0f; // maybe is too large
- }
- else if ( channel == CHAN_VOICE_ATTEN )
- {
+ } else if (channel == CHAN_VOICE_ATTEN) {
dist -= SOUND_FULLVOLUME * 1.35f; // used to be 0.15f, dropped off too sharply - dmv
dist_mult = VOICE_ATTENUATE;
- }
- else if ( channel == CHAN_VOICE_GLOBAL )
- {
+ } else if (channel == CHAN_VOICE_GLOBAL) {
dist = -1;
- }
- else // use normal attenuation.
+ } else // use normal attenuation.
{
dist -= SOUND_FULLVOLUME;
}
- if (dist < 0)
- {
- dist = 0; // close enough to be at full volume
+ if (dist < 0) {
+ dist = 0; // close enough to be at full volume
}
- dist *= dist_mult; // different attenuation levels
+ dist *= dist_mult; // different attenuation levels
dot = -DotProduct(listener_axis[1], source_vec);
- if (dma.channels == 1) // || !dist_mult)
- { // no attenuation = no spatialization
+ if (dma.channels == 1) // || !dist_mult)
+ { // no attenuation = no spatialization
rscale = SOUND_FMAXVOL;
lscale = SOUND_FMAXVOL;
- }
- else
- {
- //rscale = 0.5 * (1.0 + dot);
- //lscale = 0.5 * (1.0 - dot);
- rscale = s_separation->value + ( 1.0f - s_separation->value ) * dot;
- lscale = s_separation->value - ( 1.0f - s_separation->value ) * dot;
- if ( rscale < 0 )
- {
+ } else {
+ // rscale = 0.5 * (1.0 + dot);
+ // lscale = 0.5 * (1.0 - dot);
+ rscale = s_separation->value + (1.0f - s_separation->value) * dot;
+ lscale = s_separation->value - (1.0f - s_separation->value) * dot;
+ if (rscale < 0) {
rscale = 0;
}
- if ( lscale < 0 )
- {
+ if (lscale < 0) {
lscale = 0;
}
}
// add in distance effect
scale = (1.0f - dist) * rscale;
- *right_vol = (int) (master_vol * scale);
- if (*right_vol < 0)
- {
+ *right_vol = (int)(master_vol * scale);
+ if (*right_vol < 0) {
*right_vol = 0;
}
scale = (1.0f - dist) * lscale;
- *left_vol = (int) (master_vol * scale);
- if (*left_vol < 0)
- {
+ *left_vol = (int)(master_vol * scale);
+ if (*left_vol < 0) {
*left_vol = 0;
}
}
@@ -1439,51 +1312,46 @@ Starts an ambient, 'one-shot" sound.
====================
*/
-void S_StartAmbientSound( const vec3_t origin, int entityNum, unsigned char volume, sfxHandle_t sfxHandle )
-{
- channel_t *ch;
+void S_StartAmbientSound(const vec3_t origin, int entityNum, unsigned char volume, sfxHandle_t sfxHandle) {
+ channel_t *ch;
/*const*/ sfx_t *sfx;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
- if ( !origin && ( entityNum < 0 || entityNum >= MAX_GENTITIES ) )
- Com_Error( ERR_DROP, "S_StartAmbientSound: bad entitynum %i", entityNum );
+ if (!origin && (entityNum < 0 || entityNum >= MAX_GENTITIES))
+ Com_Error(ERR_DROP, "S_StartAmbientSound: bad entitynum %i", entityNum);
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx )
- Com_Error( ERR_DROP, "S_StartAmbientSound: handle %i out of range", sfxHandle );
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx)
+ Com_Error(ERR_DROP, "S_StartAmbientSound: handle %i out of range", sfxHandle);
- sfx = &s_knownSfx[ sfxHandle ];
- if (sfx->bInMemory == qfalse){
+ sfx = &s_knownSfx[sfxHandle];
+ if (sfx->bInMemory == qfalse) {
S_memoryLoad(sfx);
}
SND_TouchSFX(sfx);
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
- if (volume==0)
+ if (s_UseOpenAL) {
+ if (volume == 0)
return;
}
#endif
- if ( s_show->integer == 1 ) {
- Com_Printf( "%i : %s on (%d) Ambient\n", s_paintedtime, sfx->sSoundName, entityNum );
+ if (s_show->integer == 1) {
+ Com_Printf("%i : %s on (%d) Ambient\n", s_paintedtime, sfx->sSoundName, entityNum);
}
// pick a channel to play on
- ch = S_PickChannel( entityNum, CHAN_AMBIENT );
+ ch = S_PickChannel(entityNum, CHAN_AMBIENT);
if (!ch) {
return;
}
- if (origin)
- {
- VectorCopy (origin, ch->origin);
+ if (origin) {
+ VectorCopy(origin, ch->origin);
ch->fixed_origin = qtrue;
- }
- else
- {
+ } else {
ch->fixed_origin = qfalse;
}
@@ -1493,18 +1361,15 @@ void S_StartAmbientSound( const vec3_t origin, int entityNum, unsigned char volu
ch->thesfx = sfx;
ch->startSample = START_SAMPLE_IMMEDIATE;
- ch->leftvol = ch->master_vol; // these will get calced at next spatialize
- ch->rightvol = ch->master_vol; // unless the game isn't running
+ ch->leftvol = ch->master_vol; // these will get calced at next spatialize
+ ch->rightvol = ch->master_vol; // unless the game isn't running
- if (sfx->pMP3StreamHeader)
- {
- memcpy(&ch->MP3StreamHeader,sfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
- //ch->iMP3SlidingDecodeWritePos = 0; // These will be zero from the memset in S_PickChannel(), but keep them here for reference...
- //ch->iMP3SlidingDecodeWindowPos= 0; //
- }
- else
- {
- memset(&ch->MP3StreamHeader,0, sizeof(ch->MP3StreamHeader));
+ if (sfx->pMP3StreamHeader) {
+ memcpy(&ch->MP3StreamHeader, sfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
+ // ch->iMP3SlidingDecodeWritePos = 0; // These will be zero from the memset in S_PickChannel(), but keep them here for reference...
+ // ch->iMP3SlidingDecodeWindowPos= 0; //
+ } else {
+ memset(&ch->MP3StreamHeader, 0, sizeof(ch->MP3StreamHeader));
}
}
@@ -1517,53 +1382,46 @@ if pos is NULL, the sound will be dynamically sourced from the entity
Entchannel 0 will never override a playing sound
====================
*/
-void S_StartSound(const vec3_t origin, int entityNum, soundChannel_t entchannel, sfxHandle_t sfxHandle )
-{
- channel_t *ch;
+void S_StartSound(const vec3_t origin, int entityNum, soundChannel_t entchannel, sfxHandle_t sfxHandle) {
+ channel_t *ch;
/*const*/ sfx_t *sfx;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
- if ( !origin && ( entityNum < 0 || entityNum >= MAX_GENTITIES ) ) {
- Com_Error( ERR_DROP, "S_StartSound: bad entitynum %i", entityNum );
+ if (!origin && (entityNum < 0 || entityNum >= MAX_GENTITIES)) {
+ Com_Error(ERR_DROP, "S_StartSound: bad entitynum %i", entityNum);
}
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Error( ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle );
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx) {
+ Com_Error(ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle);
}
- sfx = &s_knownSfx[ sfxHandle ];
- if (sfx->bInMemory == qfalse){
+ sfx = &s_knownSfx[sfxHandle];
+ if (sfx->bInMemory == qfalse) {
S_memoryLoad(sfx);
}
SND_TouchSFX(sfx);
- if ( s_show->integer == 1 ) {
- Com_Printf( "%i : %s for ent %d, chan=%d\n", s_paintedtime, sfx->sSoundName, entityNum, entchannel );
+ if (s_show->integer == 1) {
+ Com_Printf("%i : %s for ent %d, chan=%d\n", s_paintedtime, sfx->sSoundName, entityNum, entchannel);
}
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
int i;
- if (entchannel == CHAN_VOICE)
- {
+ if (entchannel == CHAN_VOICE) {
// Make howlers and sand_creature VOICE effects use the normal fall-off (they will still be affected
// by the Voice Volume)
- if ((strstr(sfx->sSoundName, "sand_creature")!=NULL) || (strstr(sfx->sSoundName, "howler")!=NULL))
- {
+ if ((strstr(sfx->sSoundName, "sand_creature") != NULL) || (strstr(sfx->sSoundName, "howler") != NULL)) {
entchannel = CHAN_VOICE_ATTEN;
}
}
- if (entchannel == CHAN_WEAPON)
- {
+ if (entchannel == CHAN_WEAPON) {
// Check if we are playing a 'charging' sound, if so, stop it now ..
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- if ((ch->entnum == entityNum) && (ch->entchannel == CHAN_WEAPON) && (ch->thesfx) && (strstr(ch->thesfx->sSoundName, "altcharge") != NULL))
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ if ((ch->entnum == entityNum) && (ch->entchannel == CHAN_WEAPON) && (ch->thesfx) && (strstr(ch->thesfx->sSoundName, "altcharge") != NULL)) {
// Stop this sound
alSourceStop(ch->alSource);
alSourcei(ch->alSource, AL_BUFFER, NULL);
@@ -1572,14 +1430,10 @@ void S_StartSound(const vec3_t origin, int entityNum, soundChannel_t entchannel,
break;
}
}
- }
- else
- {
+ } else {
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- if ((ch->entnum == entityNum) && (ch->thesfx) && (strstr(ch->thesfx->sSoundName, "falling") != NULL))
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ if ((ch->entnum == entityNum) && (ch->thesfx) && (strstr(ch->thesfx->sSoundName, "falling") != NULL)) {
// Stop this sound
alSourceStop(ch->alSource);
alSourcei(ch->alSource, AL_BUFFER, NULL);
@@ -1594,44 +1448,40 @@ void S_StartSound(const vec3_t origin, int entityNum, soundChannel_t entchannel,
// pick a channel to play on
- ch = S_PickChannel( entityNum, entchannel );
+ ch = S_PickChannel(entityNum, entchannel);
if (!ch) {
return;
}
if (origin) {
- VectorCopy (origin, ch->origin);
+ VectorCopy(origin, ch->origin);
ch->fixed_origin = qtrue;
} else {
ch->fixed_origin = qfalse;
}
- ch->master_vol = SOUND_MAXVOL; //FIXME: Um.. control?
+ ch->master_vol = SOUND_MAXVOL; // FIXME: Um.. control?
ch->entnum = entityNum;
ch->entchannel = entchannel;
ch->thesfx = sfx;
ch->startSample = START_SAMPLE_IMMEDIATE;
- ch->leftvol = ch->master_vol; // these will get calced at next spatialize
- ch->rightvol = ch->master_vol; // unless the game isn't running
+ ch->leftvol = ch->master_vol; // these will get calced at next spatialize
+ ch->rightvol = ch->master_vol; // unless the game isn't running
- if (entchannel < CHAN_AMBIENT && entityNum == listener_number) { //only do it for body sounds not local sounds
- ch->master_vol = SOUND_MAXVOL * SOUND_FMAXVOL; //this won't be attenuated so let it scale down
+ if (entchannel < CHAN_AMBIENT && entityNum == listener_number) { // only do it for body sounds not local sounds
+ ch->master_vol = SOUND_MAXVOL * SOUND_FMAXVOL; // this won't be attenuated so let it scale down
}
- if ( entchannel == CHAN_VOICE || entchannel == CHAN_VOICE_ATTEN || entchannel == CHAN_VOICE_GLOBAL )
- {
- s_entityWavVol[ ch->entnum ] = -1; //we've started the sound but it's silent for now
+ if (entchannel == CHAN_VOICE || entchannel == CHAN_VOICE_ATTEN || entchannel == CHAN_VOICE_GLOBAL) {
+ s_entityWavVol[ch->entnum] = -1; // we've started the sound but it's silent for now
}
- if (sfx->pMP3StreamHeader)
- {
- memcpy(&ch->MP3StreamHeader,sfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
- //ch->iMP3SlidingDecodeWritePos = 0; // These will be zero from the memset in S_PickChannel(), but keep them here for reference...
- //ch->iMP3SlidingDecodeWindowPos= 0; //
- }
- else
- {
- memset(&ch->MP3StreamHeader,0, sizeof(ch->MP3StreamHeader));
+ if (sfx->pMP3StreamHeader) {
+ memcpy(&ch->MP3StreamHeader, sfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
+ // ch->iMP3SlidingDecodeWritePos = 0; // These will be zero from the memset in S_PickChannel(), but keep them here for reference...
+ // ch->iMP3SlidingDecodeWindowPos= 0; //
+ } else {
+ memset(&ch->MP3StreamHeader, 0, sizeof(ch->MP3StreamHeader));
}
}
@@ -1640,16 +1490,16 @@ void S_StartSound(const vec3_t origin, int entityNum, soundChannel_t entchannel,
S_StartLocalSound
==================
*/
-void S_StartLocalSound( sfxHandle_t sfxHandle, int channelNum ) {
- if ( !s_soundStarted || s_soundMuted ) {
+void S_StartLocalSound(sfxHandle_t sfxHandle, int channelNum) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Error( ERR_DROP, "S_StartLocalSound: handle %i out of range", sfxHandle );
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx) {
+ Com_Error(ERR_DROP, "S_StartLocalSound: handle %i out of range", sfxHandle);
}
- S_StartSound (NULL, listener_number, (soundChannel_t)channelNum, sfxHandle );
+ S_StartSound(NULL, listener_number, (soundChannel_t)channelNum, sfxHandle);
}
/*
@@ -1657,36 +1507,33 @@ void S_StartLocalSound( sfxHandle_t sfxHandle, int channelNum ) {
S_StartLocalLoopingSound
==================
*/
-void S_StartLocalLoopingSound( sfxHandle_t sfxHandle) {
- vec3_t nullVec = {0,0,0};
+void S_StartLocalLoopingSound(sfxHandle_t sfxHandle) {
+ vec3_t nullVec = {0, 0, 0};
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Error( ERR_DROP, "S_StartLocalLoopingSound: handle %i out of range", sfxHandle );
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx) {
+ Com_Error(ERR_DROP, "S_StartLocalLoopingSound: handle %i out of range", sfxHandle);
}
- S_AddLoopingSound( listener_number, nullVec, nullVec, sfxHandle );
-
+ S_AddLoopingSound(listener_number, nullVec, nullVec, sfxHandle);
}
// returns length in milliseconds of supplied sound effect... (else 0 for bad handle now)
//
-float S_GetSampleLengthInMilliSeconds( sfxHandle_t sfxHandle)
-{
+float S_GetSampleLengthInMilliSeconds(sfxHandle_t sfxHandle) {
sfx_t *sfx;
- if (!s_soundStarted)
- { //we have no sound, so let's just make a reasonable guess
+ if (!s_soundStarted) { // we have no sound, so let's just make a reasonable guess
return 512 * 1000;
}
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx )
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx)
return 0.0f;
- sfx = &s_knownSfx[ sfxHandle ];
+ sfx = &s_knownSfx[sfxHandle];
float f = (float)sfx->iSoundLengthInSamples / (float)dma.speed;
@@ -1701,13 +1548,13 @@ If we are about to perform file access, clear the buffer
so sound doesn't stutter.
==================
*/
-void S_ClearSoundBuffer( void ) {
- int clear;
+void S_ClearSoundBuffer(void) {
+ int clear;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
-#if 0 //this causes scripts to freak when the sounds get cut...
+#if 0 // this causes scripts to freak when the sounds get cut...
// clear all the sounds so they don't
// start back up after the load finishes
memset( s_channels, 0, sizeof( s_channels ) );
@@ -1725,14 +1572,13 @@ void S_ClearSoundBuffer( void ) {
else
clear = 0;
- SNDDMA_BeginPainting ();
+ SNDDMA_BeginPainting();
if (dma.buffer)
- memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
- SNDDMA_Submit ();
+ memset(dma.buffer, clear, dma.samples * dma.samplebits / 8);
+ SNDDMA_Submit();
}
#ifdef USE_OPENAL
- else
- {
+ else {
s_paintedtime = 0;
s_soundtime = 0;
}
@@ -1741,30 +1587,26 @@ void S_ClearSoundBuffer( void ) {
// kinda kludgy way to stop a special-use sfx_t playing...
//
-void S_CIN_StopSound(sfxHandle_t sfxHandle)
-{
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Error( ERR_DROP, "S_CIN_StopSound: handle %i out of range", sfxHandle );
+void S_CIN_StopSound(sfxHandle_t sfxHandle) {
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx) {
+ Com_Error(ERR_DROP, "S_CIN_StopSound: handle %i out of range", sfxHandle);
}
- sfx_t *sfx = &s_knownSfx[ sfxHandle ];
+ sfx_t *sfx = &s_knownSfx[sfxHandle];
channel_t *ch = s_channels;
int i;
- for ( i = 0; i < MAX_CHANNELS ; i++, ch++ )
- {
- if ( !ch->thesfx || (ch->leftvol<0.25 && ch->rightvol<0.25 )) {
+ for (i = 0; i < MAX_CHANNELS; i++, ch++) {
+ if (!ch->thesfx || (ch->leftvol < 0.25 && ch->rightvol < 0.25)) {
continue;
}
- if (ch->thesfx == sfx)
- {
+ if (ch->thesfx == sfx) {
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
alSourceStop(s_channels[i].alSource);
}
#endif
- SND_FreeSFXMem(ch->thesfx); // heh, may as well...
+ SND_FreeSFXMem(ch->thesfx); // heh, may as well...
ch->thesfx = NULL;
memset(&ch->MP3StreamHeader, 0, sizeof(MP3STREAM));
ch->bLooping = false;
@@ -1781,9 +1623,8 @@ void S_CIN_StopSound(sfxHandle_t sfxHandle)
S_StopAllSounds
==================
*/
-void S_StopSounds(void)
-{
- if ( !s_soundStarted ) {
+void S_StopSounds(void) {
+ if (!s_soundStarted) {
return;
}
@@ -1792,12 +1633,10 @@ void S_StopSounds(void)
#ifdef USE_OPENAL
// clear all the s_channels
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
channel_t *ch = s_channels;
int i;
- for (i = 0; i < s_numChannels; i++, ch++)
- {
+ for (i = 0; i < s_numChannels; i++, ch++) {
alSourceStop(s_channels[i].alSource);
alSourcei(s_channels[i].alSource, AL_BUFFER, NULL);
ch->thesfx = NULL;
@@ -1807,9 +1646,7 @@ void S_StopSounds(void)
ch->bPlaying = false;
ch->bStreaming = false;
}
- }
- else
- {
+ } else {
#endif
memset(s_channels, 0, sizeof(s_channels));
#ifdef USE_OPENAL
@@ -1817,9 +1654,9 @@ void S_StopSounds(void)
#endif
// clear out the lip synching override array
- memset(s_entityWavVol, 0,sizeof(s_entityWavVol));
+ memset(s_entityWavVol, 0, sizeof(s_entityWavVol));
- S_ClearSoundBuffer ();
+ S_ClearSoundBuffer();
}
/*
@@ -1829,7 +1666,7 @@ S_StopAllSounds
==================
*/
void S_StopAllSounds(void) {
- if ( !s_soundStarted ) {
+ if (!s_soundStarted) {
return;
}
// stop the background music
@@ -1852,11 +1689,9 @@ S_ClearLoopingSounds
==================
*/
-void S_ClearLoopingSounds( void )
-{
+void S_ClearLoopingSounds(void) {
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
for (int i = 0; i < MAX_LOOP_SOUNDS; i++)
loopSounds[i].bProcessed = qfalse;
}
@@ -1872,36 +1707,36 @@ Called during entity generation for a frame
Include velocity in case I get around to doing doppler...
==================
*/
-void S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, soundChannel_t chan ) {
+void S_AddLoopingSound(int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, soundChannel_t chan) {
/*const*/ sfx_t *sfx;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
- if ( numLoopSounds >= MAX_LOOP_SOUNDS ) {
- //assert(numLoopSounds= MAX_LOOP_SOUNDS) {
+ // assert(numLoopSounds= s_numSfx ) {
- Com_Error( ERR_DROP, "S_AddLoopingSound: handle %i out of range", sfxHandle );
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx) {
+ Com_Error(ERR_DROP, "S_AddLoopingSound: handle %i out of range", sfxHandle);
}
- sfx = &s_knownSfx[ sfxHandle ];
- if (!sfx->bInMemory){
+ sfx = &s_knownSfx[sfxHandle];
+ if (!sfx->bInMemory) {
S_memoryLoad(sfx);
}
SND_TouchSFX(sfx);
- if ( !sfx->iSoundLengthInSamples ) {
- Com_Error( ERR_DROP, "%s has length 0", sfx->sSoundName );
+ if (!sfx->iSoundLengthInSamples) {
+ Com_Error(ERR_DROP, "%s has length 0", sfx->sSoundName);
}
assert(!sfx->pMP3StreamHeader);
- VectorCopy( origin, loopSounds[numLoopSounds].origin );
-// VectorCopy( velocity, loopSounds[numLoopSounds].velocity );
+ VectorCopy(origin, loopSounds[numLoopSounds].origin);
+ // VectorCopy( velocity, loopSounds[numLoopSounds].velocity );
loopSounds[numLoopSounds].sfx = sfx;
loopSounds[numLoopSounds].volume = SOUND_MAXVOL;
loopSounds[numLoopSounds].entnum = entityNum;
@@ -1914,43 +1749,41 @@ void S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocit
S_AddAmbientLoopingSound
==================
*/
-void S_AddAmbientLoopingSound( const vec3_t origin, unsigned char volume, sfxHandle_t sfxHandle )
-{
+void S_AddAmbientLoopingSound(const vec3_t origin, unsigned char volume, sfxHandle_t sfxHandle) {
/*const*/ sfx_t *sfx;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
- if ( numLoopSounds >= MAX_LOOP_SOUNDS ) {
+ if (numLoopSounds >= MAX_LOOP_SOUNDS) {
return;
}
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
if (volume == 0)
return;
}
#endif
- if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Error( ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle );
+ if (sfxHandle < 0 || sfxHandle >= s_numSfx) {
+ Com_Error(ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle);
}
- sfx = &s_knownSfx[ sfxHandle ];
- if (sfx->bInMemory == qfalse){
+ sfx = &s_knownSfx[sfxHandle];
+ if (sfx->bInMemory == qfalse) {
S_memoryLoad(sfx);
}
SND_TouchSFX(sfx);
- if ( !sfx->iSoundLengthInSamples ) {
- Com_Error( ERR_DROP, "%s has length 0", sfx->sSoundName );
+ if (!sfx->iSoundLengthInSamples) {
+ Com_Error(ERR_DROP, "%s has length 0", sfx->sSoundName);
}
- VectorCopy( origin, loopSounds[numLoopSounds].origin );
+ VectorCopy(origin, loopSounds[numLoopSounds].origin);
loopSounds[numLoopSounds].sfx = sfx;
assert(!sfx->pMP3StreamHeader);
- //TODO: Calculate the distance falloff
+ // TODO: Calculate the distance falloff
loopSounds[numLoopSounds].volume = volume;
numLoopSounds++;
}
@@ -1964,39 +1797,38 @@ All sounds are on the same cycle, so any duplicates can just
sum up the channel multipliers.
==================
*/
-void S_AddLoopSounds (void)
-{
- int i, j;
- int left, right, left_total, right_total;
- channel_t *ch;
- loopSound_t *loop, *loop2;
- static int loopFrame;
+void S_AddLoopSounds(void) {
+ int i, j;
+ int left, right, left_total, right_total;
+ channel_t *ch;
+ loopSound_t *loop, *loop2;
+ static int loopFrame;
loopFrame++;
- for ( i = 0 ; i < numLoopSounds ; i++) {
+ for (i = 0; i < numLoopSounds; i++) {
loop = &loopSounds[i];
- if ( loop->mergeFrame == loopFrame ) {
- continue; // already merged into an earlier sound
+ if (loop->mergeFrame == loopFrame) {
+ continue; // already merged into an earlier sound
}
// find the total contribution of all sounds of this type
left_total = right_total = 0;
- for ( j = i ; j < numLoopSounds ; j++) {
+ for (j = i; j < numLoopSounds; j++) {
loop2 = &loopSounds[j];
- if ( loop2->sfx != loop->sfx ) {
+ if (loop2->sfx != loop->sfx) {
continue;
}
- loop2->mergeFrame = loopFrame; // don't check this again later
+ loop2->mergeFrame = loopFrame; // don't check this again later
- S_SpatializeOrigin( loop2->origin, loop2->volume, &left, &right, loop2->entchan);
+ S_SpatializeOrigin(loop2->origin, loop2->volume, &left, &right, loop2->entchan);
left_total += left;
right_total += right;
}
if (left_total == 0 && right_total == 0)
- continue; // not audible
+ continue; // not audible
// allocate a channel
ch = S_PickChannel(0, 0);
@@ -2009,18 +1841,15 @@ void S_AddLoopSounds (void)
right_total = SOUND_MAXVOL;
ch->leftvol = left_total;
ch->rightvol = right_total;
- ch->loopSound = qtrue; // remove next frame
+ ch->loopSound = qtrue; // remove next frame
ch->thesfx = loop->sfx;
// you cannot use MP3 files here because they offer only streaming access, not random
//
- if (loop->sfx->pMP3StreamHeader)
- {
- Com_Error( ERR_DROP, "S_AddLoopSounds(): Cannot use streamed MP3 files here for random access (%s)\n",loop->sfx->sSoundName );
- }
- else
- {
- memset(&ch->MP3StreamHeader,0, sizeof(ch->MP3StreamHeader));
+ if (loop->sfx->pMP3StreamHeader) {
+ Com_Error(ERR_DROP, "S_AddLoopSounds(): Cannot use streamed MP3 files here for random access (%s)\n", loop->sfx->sSoundName);
+ } else {
+ memset(&ch->MP3StreamHeader, 0, sizeof(ch->MP3StreamHeader));
}
}
}
@@ -2035,27 +1864,25 @@ If raw data has been loaded in little endien binary form, this must be done.
If raw data was calculated, as with ADPCM, this should not be called.
=================
*/
-static void S_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *data ) {
- int i;
+static void S_ByteSwapRawSamples(int samples, int width, int s_channels, const byte *data) {
+ int i;
- if ( width != 2 ) {
+ if (width != 2) {
return;
}
- if ( LittleShort( 256 ) == 256 ) {
+ if (LittleShort(256) == 256) {
return;
}
- if ( s_channels == 2 ) {
+ if (s_channels == 2) {
samples <<= 1;
}
- for ( i = 0 ; i < samples ; i++ ) {
- ((short *)data)[i] = LittleShort( ((short *)data)[i] );
+ for (i = 0; i < samples; i++) {
+ ((short *)data)[i] = LittleShort(((short *)data)[i]);
}
}
-portable_samplepair_t *S_GetRawSamplePointer() {
- return s_rawsamples;
-}
+portable_samplepair_t *S_GetRawSamplePointer() { return s_rawsamples; }
/*
============
@@ -2064,22 +1891,21 @@ S_RawSamples
Music streaming
============
*/
-void S_RawSamples( int samples, int rate, int width, int channels, const byte *data, float volume, qboolean bFirstOrOnlyUpdateThisFrame )
-{
- int i;
- int src, dst;
- float scale;
- int intVolume;
- int rawEndStart;
-
- if ( !s_soundStarted || s_soundMuted ) {
+void S_RawSamples(int samples, int rate, int width, int channels, const byte *data, float volume, qboolean bFirstOrOnlyUpdateThisFrame) {
+ int i;
+ int src, dst;
+ float scale;
+ int intVolume;
+ int rawEndStart;
+
+ if (!s_soundStarted || s_soundMuted) {
return;
}
intVolume = 256 * volume;
- if ( s_rawend < s_soundtime ) {
- Com_DPrintf( "S_RawSamples: resetting minimum: %i < %i\n", s_rawend, s_soundtime );
+ if (s_rawend < s_soundtime) {
+ Com_DPrintf("S_RawSamples: resetting minimum: %i < %i\n", s_rawend, s_soundtime);
s_rawend = s_soundtime;
}
@@ -2087,180 +1913,145 @@ void S_RawSamples( int samples, int rate, int width, int channels, const byte *d
scale = (float)rate / dma.speed;
-//Com_Printf ("%i < %i < %i\n", s_soundtime, s_paintedtime, s_rawend);
- if (channels == 2 && width == 2)
- {
- if (scale == 1.0)
- { // optimized case
- if (bFirstOrOnlyUpdateThisFrame)
- {
- for (i=0 ; i= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left = ((short *)data)[src*2] * intVolume;
- s_rawsamples[dst].right = ((short *)data)[src*2+1] * intVolume;
+ s_rawsamples[dst].left = ((short *)data)[src * 2] * intVolume;
+ s_rawsamples[dst].right = ((short *)data)[src * 2 + 1] * intVolume;
}
- }
- else
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ } else {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left += ((short *)data)[src*2] * intVolume;
- s_rawsamples[dst].right += ((short *)data)[src*2+1] * intVolume;
+ s_rawsamples[dst].left += ((short *)data)[src * 2] * intVolume;
+ s_rawsamples[dst].right += ((short *)data)[src * 2 + 1] * intVolume;
}
}
}
- }
- else if (channels == 1 && width == 2)
- {
- if (bFirstOrOnlyUpdateThisFrame)
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ } else if (channels == 1 && width == 2) {
+ if (bFirstOrOnlyUpdateThisFrame) {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
s_rawsamples[dst].left = ((short *)data)[src] * intVolume;
s_rawsamples[dst].right = ((short *)data)[src] * intVolume;
}
- }
- else
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ } else {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left += ((short *)data)[src] * intVolume;
+ s_rawsamples[dst].left += ((short *)data)[src] * intVolume;
s_rawsamples[dst].right += ((short *)data)[src] * intVolume;
}
}
- }
- else if (channels == 2 && width == 1)
- {
+ } else if (channels == 2 && width == 1) {
intVolume *= 256;
- if (bFirstOrOnlyUpdateThisFrame)
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ if (bFirstOrOnlyUpdateThisFrame) {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left = ((char *)data)[src*2] * intVolume;
- s_rawsamples[dst].right = ((char *)data)[src*2+1] * intVolume;
+ s_rawsamples[dst].left = ((char *)data)[src * 2] * intVolume;
+ s_rawsamples[dst].right = ((char *)data)[src * 2 + 1] * intVolume;
}
- }
- else
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ } else {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left += ((char *)data)[src*2] * intVolume;
- s_rawsamples[dst].right += ((char *)data)[src*2+1] * intVolume;
+ s_rawsamples[dst].left += ((char *)data)[src * 2] * intVolume;
+ s_rawsamples[dst].right += ((char *)data)[src * 2 + 1] * intVolume;
}
}
- }
- else if (channels == 1 && width == 1)
- {
+ } else if (channels == 1 && width == 1) {
intVolume *= 256;
- if (bFirstOrOnlyUpdateThisFrame)
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ if (bFirstOrOnlyUpdateThisFrame) {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left = (((byte *)data)[src]-128) * intVolume;
- s_rawsamples[dst].right = (((byte *)data)[src]-128) * intVolume;
+ s_rawsamples[dst].left = (((byte *)data)[src] - 128) * intVolume;
+ s_rawsamples[dst].right = (((byte *)data)[src] - 128) * intVolume;
}
- }
- else
- {
- for (i=0 ; ; i++)
- {
- src = i*scale;
+ } else {
+ for (i = 0;; i++) {
+ src = i * scale;
if (src >= samples)
break;
- dst = s_rawend&(MAX_RAW_SAMPLES-1);
+ dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
- //Don't overflow if resampling.
+ // Don't overflow if resampling.
if (s_rawend > rawEndStart + MAX_RAW_SAMPLES)
break;
- s_rawsamples[dst].left += (((byte *)data)[src]-128) * intVolume;
- s_rawsamples[dst].right += (((byte *)data)[src]-128) * intVolume;
+ s_rawsamples[dst].left += (((byte *)data)[src] - 128) * intVolume;
+ s_rawsamples[dst].right += (((byte *)data)[src] - 128) * intVolume;
}
}
}
- if ( s_rawend > s_soundtime + MAX_RAW_SAMPLES ) {
- Com_DPrintf( "S_RawSamples: overflowed %i > %i\n", s_rawend, s_soundtime );
+ if (s_rawend > s_soundtime + MAX_RAW_SAMPLES) {
+ Com_DPrintf("S_RawSamples: overflowed %i > %i\n", s_rawend, s_soundtime);
}
}
@@ -2273,26 +2064,21 @@ S_UpdateEntityPosition
let the sound system know where an entity currently is
======================
*/
-void S_UpdateEntityPosition( int entityNum, const vec3_t origin )
-{
- if ( entityNum < 0 || entityNum >= MAX_GENTITIES ) {
- Com_Error( ERR_DROP, "S_UpdateEntityPosition: bad entitynum %i", entityNum );
+void S_UpdateEntityPosition(int entityNum, const vec3_t origin) {
+ if (entityNum < 0 || entityNum >= MAX_GENTITIES) {
+ Com_Error(ERR_DROP, "S_UpdateEntityPosition: bad entitynum %i", entityNum);
}
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
if (entityNum == 0)
return;
channel_t *ch = s_channels + 1;
- for (int i = 1; i < s_numChannels; i++, ch++)
- {
- if ((s_channels[i].bPlaying) && (s_channels[i].entnum == entityNum) && (!s_channels[i].bLooping))
- {
+ for (int i = 1; i < s_numChannels; i++, ch++) {
+ if ((s_channels[i].bPlaying) && (s_channels[i].entnum == entityNum) && (!s_channels[i].bLooping)) {
// Ignore position updates for CHAN_VOICE_GLOBAL
- if (ch->entchannel != CHAN_VOICE_GLOBAL && ch->entchannel != CHAN_ANNOUNCER)
- {
+ if (ch->entchannel != CHAN_VOICE_GLOBAL && ch->entchannel != CHAN_ANNOUNCER) {
ALfloat pos[3];
pos[0] = origin[0];
pos[1] = origin[2];
@@ -2302,22 +2088,23 @@ void S_UpdateEntityPosition( int entityNum, const vec3_t origin )
UpdateEAXBuffer(ch);
}
-/* pos[0] = origin[0];
- pos[1] = origin[2];
- pos[2] = -origin[1];
- alSourcefv(s_channels[i].alSource, AL_POSITION, pos);
+ /* pos[0] = origin[0];
+ pos[1] = origin[2];
+ pos[2] = -origin[1];
+ alSourcefv(s_channels[i].alSource, AL_POSITION, pos);
- if ((s_bEALFileLoaded) && !( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL ) )
- {
- UpdateEAXBuffer(ch);
- }
-*/
+ if ((s_bEALFileLoaded) && !( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel ==
+ CHAN_VOICE_GLOBAL ) )
+ {
+ UpdateEAXBuffer(ch);
+ }
+ */
}
}
}
#endif
- VectorCopy( origin, s_entityPosition[entityNum] );
+ VectorCopy(origin, s_entityPosition[entityNum]);
}
// Given a current wav we are playing, and our position within it, lets figure out its volume...
@@ -2325,76 +2112,66 @@ void S_UpdateEntityPosition( int entityNum, const vec3_t origin )
// (this is mostly Jake's code from EF1, which explains a lot...:-)
//
static int next_amplitude = 0;
-static int S_CheckAmplitude(channel_t *ch, const int s_oldpaintedtime )
-{
+static int S_CheckAmplitude(channel_t *ch, const int s_oldpaintedtime) {
// now, is this a cycle - or have we just started a new sample - where we should update the backup table, and write this value
// into the new table? or should we just take the value FROM the back up table and feed it out.
- assert( ch->startSample != START_SAMPLE_IMMEDIATE );
- if ( ch->startSample == s_oldpaintedtime || (next_amplitude < s_soundtime) )//(ch->startSample == START_SAMPLE_IMMEDIATE)//!s_entityWavVol_back[ch->entnum]
+ assert(ch->startSample != START_SAMPLE_IMMEDIATE);
+ if (ch->startSample == s_oldpaintedtime || (next_amplitude < s_soundtime)) //(ch->startSample == START_SAMPLE_IMMEDIATE)//!s_entityWavVol_back[ch->entnum]
{
- int sample;
- int sample_total = 0;
- int count = 0;
+ int sample;
+ int sample_total = 0;
+ int count = 0;
short *current_pos_s;
-// char *current_pos_c;
- int offset = 0;
+ // char *current_pos_c;
+ int offset = 0;
// if we haven't started the sample yet, we must be at the beginning
- current_pos_s = ((short*)ch->thesfx->pSoundData);
-// current_pos_c = ((char*)ch->thesfx->data);
+ current_pos_s = ((short *)ch->thesfx->pSoundData);
+ // current_pos_c = ((char*)ch->thesfx->data);
- //if (ch->startSample != START_SAMPLE_IMMEDIATE)
+ // if (ch->startSample != START_SAMPLE_IMMEDIATE)
//{
- // figure out where we are in the sample right now.
- offset = s_oldpaintedtime - ch->startSample;//s_paintedtime
- current_pos_s += offset;
-// current_pos_c += offset;
+ // figure out where we are in the sample right now.
+ offset = s_oldpaintedtime - ch->startSample; // s_paintedtime
+ current_pos_s += offset;
+ // current_pos_c += offset;
//}
// scan through 10 samples 100( at 11hz or 200 at 22hz) samples apart.
//
- for (int i=0; i<10; i++)
- {
+ for (int i = 0; i < 10; i++) {
//
// have we run off the end?
- if ((offset + (i*100)) > ch->thesfx->iSoundLengthInSamples)
- {
+ if ((offset + (i * 100)) > ch->thesfx->iSoundLengthInSamples) {
break;
}
-// if (ch->thesfx->width == 1)
-// {
-// sample = current_pos_c[i*100];
-// }
-// else
+ // if (ch->thesfx->width == 1)
+ // {
+ // sample = current_pos_c[i*100];
+ // }
+ // else
{
- switch (ch->thesfx->eSoundCompressionMethod)
- {
- case ct_16:
- {
- sample = current_pos_s[i*100];
- }
- break;
-
- case ct_MP3:
- {
- const int iIndex = (i*100) + ((offset * /*ch->thesfx->width*/2) - ch->iMP3SlidingDecodeWindowPos);
- const short* pwSamples = (short*) (ch->MP3SlidingDecodeBuffer + iIndex);
-
- sample = *pwSamples;
- }
- break;
-
- default:
- {
- assert(0);
- sample = 0;
- }
- break;
+ switch (ch->thesfx->eSoundCompressionMethod) {
+ case ct_16: {
+ sample = current_pos_s[i * 100];
+ } break;
+
+ case ct_MP3: {
+ const int iIndex = (i * 100) + ((offset * /*ch->thesfx->width*/ 2) - ch->iMP3SlidingDecodeWindowPos);
+ const short *pwSamples = (short *)(ch->MP3SlidingDecodeBuffer + iIndex);
+
+ sample = *pwSamples;
+ } break;
+
+ default: {
+ assert(0);
+ sample = 0;
+ } break;
}
-// if (sample < 0)
-// sample = -sample;
- sample = sample>>8;
+ // if (sample < 0)
+ // sample = -sample;
+ sample = sample >> 8;
}
// square it for better accuracy
sample_total += (sample * sample);
@@ -2402,35 +2179,22 @@ static int S_CheckAmplitude(channel_t *ch, const int s_oldpaintedtime )
}
// if we are already done with this sample, then its silence
- if (!count)
- {
- return(0);
+ if (!count) {
+ return (0);
}
sample_total /= count;
// I hate doing this, but its the simplest way
- if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_1->value)
- {
- // tell the scripts that are relying on this that we are still going, but actually silent right now.
+ if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_1->value) {
+ // tell the scripts that are relying on this that we are still going, but actually silent right now.
sample = -1;
- }
- else
- if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_2->value)
- {
+ } else if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_2->value) {
sample = 1;
- }
- else
- if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_3->value)
- {
+ } else if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_3->value) {
sample = 2;
- }
- else
- if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_4->value)
- {
+ } else if (sample_total < ch->thesfx->fVolRange * s_lip_threshold_4->value) {
sample = 3;
- }
- else
- {
+ } else {
sample = 4;
}
@@ -2439,12 +2203,12 @@ static int S_CheckAmplitude(channel_t *ch, const int s_oldpaintedtime )
#endif
// store away the value we got into the back up table
- s_entityWavVol_back[ ch->entnum ] = sample;
+ s_entityWavVol_back[ch->entnum] = sample;
return (sample);
}
// no, just get last value calculated from backup table
- assert( s_entityWavVol_back[ch->entnum] );
- return (s_entityWavVol_back[ ch->entnum]);
+ assert(s_entityWavVol_back[ch->entnum]);
+ return (s_entityWavVol_back[ch->entnum]);
}
/*
@@ -2454,22 +2218,20 @@ S_Respatialize
Change the volumes of all the playing sounds for changes in their positions
============
*/
-void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean inwater )
-{
+void S_Respatialize(int entityNum, const vec3_t head, vec3_t axis[3], qboolean inwater) {
#ifdef USE_OPENAL
EAXOCCLUSIONPROPERTIES eaxOCProp;
EAXACTIVEFXSLOTS eaxActiveSlots;
#endif
- int i;
- channel_t *ch;
+ int i;
+ channel_t *ch;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
listener_pos[0] = head[0];
listener_pos[1] = head[2];
listener_pos[2] = -head[1];
@@ -2484,28 +2246,22 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean
alListenerfv(AL_ORIENTATION, listener_ori);
// Update EAX effects here
- if (s_bEALFileLoaded)
- {
+ if (s_bEALFileLoaded) {
// Check if the Listener is underwater
- if (inwater)
- {
+ if (inwater) {
// Check if we have already applied Underwater effect
- if (!s_bInWater)
- {
+ if (!s_bInWater) {
// New underwater fix
- for (i = 0; i < EAX_MAX_FXSLOTS; i++)
- {
+ for (i = 0; i < EAX_MAX_FXSLOTS; i++) {
s_FXSlotInfo[i].lEnvID = -1;
}
// Load underwater reverb effect into FX Slot 0, and set this as the Primary FX Slot
unsigned int ulEnvironment = EAX_ENVIRONMENT_UNDERWATER;
- s_eaxSet(&EAXPROPERTYID_EAX40_FXSlot0, EAXREVERB_ENVIRONMENT,
- NULL, &ulEnvironment, sizeof(unsigned int));
+ s_eaxSet(&EAXPROPERTYID_EAX40_FXSlot0, EAXREVERB_ENVIRONMENT, NULL, &ulEnvironment, sizeof(unsigned int));
s_EnvironmentID = 999;
- s_eaxSet(&EAXPROPERTYID_EAX40_Context, EAXCONTEXT_PRIMARYFXSLOTID, NULL, (ALvoid*)&EAXPROPERTYID_EAX40_FXSlot0,
- sizeof(GUID));
+ s_eaxSet(&EAXPROPERTYID_EAX40_Context, EAXCONTEXT_PRIMARYFXSLOTID, NULL, (ALvoid *)&EAXPROPERTYID_EAX40_FXSlot0, sizeof(GUID));
// Occlude all sounds into this environment, and mute all their sends to other reverbs
eaxOCProp.lOcclusion = -3000;
@@ -2517,46 +2273,35 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean
eaxActiveSlots.guidActiveFXSlots[1] = EAX_PrimaryFXSlotID;
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
// New underwater fix
s_channels[i].lSlotID = -1;
- s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OCCLUSIONPARAMETERS,
- ch->alSource, &eaxOCProp, sizeof(EAXOCCLUSIONPROPERTIES));
+ s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OCCLUSIONPARAMETERS, ch->alSource, &eaxOCProp, sizeof(EAXOCCLUSIONPROPERTIES));
- s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, ch->alSource,
- &eaxActiveSlots, 2*sizeof(GUID));
+ s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, ch->alSource, &eaxActiveSlots, 2 * sizeof(GUID));
}
s_bInWater = true;
}
- }
- else
- {
+ } else {
// Not underwater ... check if the underwater effect is still present
- if (s_bInWater)
- {
+ if (s_bInWater) {
s_bInWater = false;
// Remove underwater Reverb effect, and reset Occlusion / Obstruction amount on all Sources
UpdateEAXListener();
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
UpdateEAXBuffer(ch);
}
- }
- else
- {
+ } else {
UpdateEAXListener();
}
}
}
- }
- else
- {
+ } else {
#endif
listener_number = entityNum;
VectorCopy(head, listener_origin);
@@ -2566,12 +2311,12 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean
// update spatialization for dynamic sounds
ch = s_channels;
- for ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {
- if ( !ch->thesfx ) {
+ for (i = 0; i < MAX_CHANNELS; i++, ch++) {
+ if (!ch->thesfx) {
continue;
}
- if ( ch->loopSound ) { // loopSounds are regenerated fresh each frame
- Channel_Clear(ch); // memset (ch, 0, sizeof(*ch));
+ if (ch->loopSound) { // loopSounds are regenerated fresh each frame
+ Channel_Clear(ch); // memset (ch, 0, sizeof(*ch));
continue;
}
@@ -2580,26 +2325,26 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean
ch->leftvol = ch->master_vol;
ch->rightvol = ch->master_vol;
} else {
- const vec3_t *origin;
+ const vec3_t *origin;
if (ch->fixed_origin) {
origin = &ch->origin;
} else {
- origin = &s_entityPosition[ ch->entnum ];
+ origin = &s_entityPosition[ch->entnum];
}
- S_SpatializeOrigin (*origin, (float)ch->master_vol, &ch->leftvol, &ch->rightvol, ch->entchannel);
+ S_SpatializeOrigin(*origin, (float)ch->master_vol, &ch->leftvol, &ch->rightvol, ch->entchannel);
}
- //NOTE: Made it so that voice sounds keep playing, even out of range
+ // NOTE: Made it so that voice sounds keep playing, even out of range
// so that tasks waiting for sound completion keep proper timing
- if ( !( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL ) && !ch->leftvol && !ch->rightvol ) {
- Channel_Clear(ch); // memset (ch, 0, sizeof(*ch));
+ if (!(ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) && !ch->leftvol && !ch->rightvol) {
+ Channel_Clear(ch); // memset (ch, 0, sizeof(*ch));
continue;
}
}
// add loopsounds
- S_AddLoopSounds ();
+ S_AddLoopSounds();
#ifdef USE_OPENAL
}
#endif
@@ -2614,32 +2359,32 @@ S_ScanChannelStarts
Returns qtrue if any new sounds were started since the last mix
========================
*/
-qboolean S_ScanChannelStarts( void ) {
- channel_t *ch;
- int i;
- qboolean newSamples;
+qboolean S_ScanChannelStarts(void) {
+ channel_t *ch;
+ int i;
+ qboolean newSamples;
newSamples = qfalse;
ch = s_channels;
- for (i=0; ithesfx ) {
+ for (i = 0; i < MAX_CHANNELS; i++, ch++) {
+ if (!ch->thesfx) {
continue;
}
- if ( ch->loopSound ) {
+ if (ch->loopSound) {
continue;
}
// if this channel was just started this frame,
// set the sample count to it begins mixing
// into the very first sample
- if ( ch->startSample == START_SAMPLE_IMMEDIATE ) {
+ if (ch->startSample == START_SAMPLE_IMMEDIATE) {
ch->startSample = s_paintedtime;
newSamples = qtrue;
continue;
}
// if it is completely finished by now, clear it
- if ( ch->startSample + ch->thesfx->iSoundLengthInSamples <= s_paintedtime ) {
+ if (ch->startSample + ch->thesfx->iSoundLengthInSamples <= s_paintedtime) {
ch->thesfx = NULL;
continue;
}
@@ -2651,36 +2396,34 @@ qboolean S_ScanChannelStarts( void ) {
// this is now called AFTER the DMA painting, since it's only the painter calls that cause the MP3s to be unpacked,
// and therefore to have data readable by the lip-sync volume calc code.
//
-void S_DoLipSynchs( const int s_oldpaintedtime )
-{
- channel_t *ch;
- int i;
+void S_DoLipSynchs(const int s_oldpaintedtime) {
+ channel_t *ch;
+ int i;
// clear out the lip synching override array for this frame
- memset(s_entityWavVol, 0,(MAX_GENTITIES * 4));
+ memset(s_entityWavVol, 0, (MAX_GENTITIES * 4));
ch = s_channels;
- for (i=0; ithesfx ) {
+ for (i = 0; i < MAX_CHANNELS; i++, ch++) {
+ if (!ch->thesfx) {
continue;
}
- if ( ch->loopSound ) {
+ if (ch->loopSound) {
continue;
}
// if we are playing a sample that should override the lip texture on its owning model, lets figure out
// what the amplitude is, stick it in a table, then return it
- if ( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
- {
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) {
// go away and work out amplitude for this sound we are playing right now.
- s_entityWavVol[ ch->entnum ] = S_CheckAmplitude( ch, s_oldpaintedtime );
- if ( s_show->integer == 3 ) {
- Com_Printf( "(%i)%i %s vol = %i\n", ch->entnum, i, ch->thesfx->sSoundName, s_entityWavVol[ ch->entnum ] );
+ s_entityWavVol[ch->entnum] = S_CheckAmplitude(ch, s_oldpaintedtime);
+ if (s_show->integer == 3) {
+ Com_Printf("(%i)%i %s vol = %i\n", ch->entnum, i, ch->thesfx->sSoundName, s_entityWavVol[ch->entnum]);
}
}
}
- if (next_amplitude < s_soundtime) {
+ if (next_amplitude < s_soundtime) {
next_amplitude = s_soundtime + 800;
}
}
@@ -2692,34 +2435,34 @@ S_Update
Called once each time through the main loop
============
*/
-void S_Update( void ) {
- int i;
- channel_t *ch;
+void S_Update(void) {
+ int i;
+ channel_t *ch;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
//
// debugging output
//
- if ( s_show->integer == 2 ) {
- //int total = 0;
- //int totalMeg =0;
+ if (s_show->integer == 2) {
+ // int total = 0;
+ // int totalMeg =0;
ch = s_channels;
- for (i=0 ; ithesfx && (ch->leftvol || ch->rightvol) ) {
- Com_Printf ("(%i) %3i %3i %s\n", ch->entnum, ch->leftvol, ch->rightvol, ch->thesfx->sSoundName);
- //total++;
- //totalMeg += Z_Size(ch->thesfx->pSoundData);
- //if (ch->thesfx->pMP3StreamHeader)
+ for (i = 0; i < MAX_CHANNELS; i++, ch++) {
+ if (ch->thesfx && (ch->leftvol || ch->rightvol)) {
+ Com_Printf("(%i) %3i %3i %s\n", ch->entnum, ch->leftvol, ch->rightvol, ch->thesfx->sSoundName);
+ // total++;
+ // totalMeg += Z_Size(ch->thesfx->pSoundData);
+ // if (ch->thesfx->pMP3StreamHeader)
//{
// totalMeg += sizeof(*ch->thesfx->pMP3StreamHeader);
- //}
+ // }
}
}
- //if (total)
+ // if (total)
// Com_Printf ("----(%i)---- painted: %i, SND %.2fMB\n", total, s_paintedtime, totalMeg/1024.0f/1024.0f);
}
@@ -2736,32 +2479,29 @@ void S_Update( void ) {
S_Update_();
}
-void S_GetSoundtime(void)
-{
- int samplepos;
- static int buffers;
- static int oldsamplepos;
- int fullsamples;
+void S_GetSoundtime(void) {
+ int samplepos;
+ static int buffers;
+ static int oldsamplepos;
+ int fullsamples;
fullsamples = dma.samples / dma.channels;
// it is possible to miscount buffers if it has wrapped twice between
// calls to S_Update. Oh well.
samplepos = SNDDMA_GetDMAPos();
- if (samplepos < oldsamplepos)
- {
- buffers++; // buffer wrapped
+ if (samplepos < oldsamplepos) {
+ buffers++; // buffer wrapped
- if (s_paintedtime > 0x40000000)
- { // time to chop things off to avoid 32 bit limits
+ if (s_paintedtime > 0x40000000) { // time to chop things off to avoid 32 bit limits
buffers = 0;
s_paintedtime = fullsamples;
- S_StopAllSounds ();
+ S_StopAllSounds();
}
}
oldsamplepos = samplepos;
- s_soundtime = buffers*fullsamples + samplepos/dma.channels;
+ s_soundtime = buffers * fullsamples + samplepos / dma.channels;
#if 0
// check to make sure that we haven't overshot
@@ -2772,41 +2512,37 @@ void S_GetSoundtime(void)
}
#endif
- if ( dma.submission_chunk < 256 ) {
+ if (dma.submission_chunk < 256) {
s_paintedtime = (int)(s_soundtime + s_mixPreStep->value * dma.speed);
} else {
s_paintedtime = s_soundtime + dma.submission_chunk;
}
}
-
void S_Update_(void) {
- unsigned endtime;
- int samps;
+ unsigned endtime;
+ int samps;
- if ( !s_soundStarted || s_soundMuted ) {
+ if (!s_soundStarted || s_soundMuted) {
return;
}
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
- int i,j;
- int source;
+ if (s_UseOpenAL) {
+ int i, j;
+ int source;
UpdateSingleShotSounds();
channel_t *ch = s_channels + 1;
- for ( i = 1; i < MAX_CHANNELS ; i++, ch++ )
- {
- float pos[3];
+ for (i = 1; i < MAX_CHANNELS; i++, ch++) {
+ float pos[3];
- if ( !ch->thesfx || (ch->bPlaying))
+ if (!ch->thesfx || (ch->bPlaying))
continue;
source = ch - s_channels;
- if (ch->entchannel == CHAN_VOICE_GLOBAL || ch->entchannel == CHAN_ANNOUNCER)
- {
+ if (ch->entchannel == CHAN_VOICE_GLOBAL || ch->entchannel == CHAN_ANNOUNCER) {
// Always play these sounds at 0,0,-1 (in front of listener)
pos[0] = 0.0f;
pos[1] = 0.0f;
@@ -2815,45 +2551,31 @@ void S_Update_(void) {
alSourcefv(s_channels[source].alSource, AL_POSITION, pos);
alSourcei(s_channels[source].alSource, AL_LOOPING, AL_FALSE);
alSourcei(s_channels[source].alSource, AL_SOURCE_RELATIVE, AL_TRUE);
- if (ch->entchannel == CHAN_ANNOUNCER)
- {
+ if (ch->entchannel == CHAN_ANNOUNCER) {
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.0f);
- }
- else
- {
+ } else {
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volumeVoice->value) / 255.0f);
}
- }
- else
- {
+ } else {
// Get position of source
- if (ch->fixed_origin)
- {
+ if (ch->fixed_origin) {
pos[0] = ch->origin[0];
pos[1] = ch->origin[2];
pos[2] = -ch->origin[1];
alSourcei(s_channels[source].alSource, AL_SOURCE_RELATIVE, AL_FALSE);
- }
- else
- {
- if (ch->entnum == listener_number)
- {
+ } else {
+ if (ch->entnum == listener_number) {
pos[0] = 0.0f;
pos[1] = 0.0f;
pos[2] = 0.0f;
alSourcei(s_channels[source].alSource, AL_SOURCE_RELATIVE, AL_TRUE);
- }
- else
- {
+ } else {
// Get position of Entity
- if (ch->bLooping)
- {
- pos[0] = loopSounds[ ch->entnum ].origin[0];
- pos[1] = loopSounds[ ch->entnum ].origin[2];
- pos[2] = -loopSounds[ ch->entnum ].origin[1];
- }
- else
- {
+ if (ch->bLooping) {
+ pos[0] = loopSounds[ch->entnum].origin[0];
+ pos[1] = loopSounds[ch->entnum].origin[2];
+ pos[2] = -loopSounds[ch->entnum].origin[1];
+ } else {
pos[0] = s_entityPosition[ch->entnum][0];
pos[1] = s_entityPosition[ch->entnum][2];
pos[2] = -s_entityPosition[ch->entnum][1];
@@ -2865,26 +2587,19 @@ void S_Update_(void) {
alSourcefv(s_channels[source].alSource, AL_POSITION, pos);
alSourcei(s_channels[source].alSource, AL_LOOPING, AL_FALSE);
- if (ch->entchannel == CHAN_VOICE)
- {
+ if (ch->entchannel == CHAN_VOICE) {
// Reduced fall-off (Large Reference Distance), affected by Voice Volume
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_VOICE_REF_DISTANCE);
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volumeVoice->value) / 255.0f);
- }
- else if (ch->entchannel == CHAN_VOICE_ATTEN)
- {
+ } else if (ch->entchannel == CHAN_VOICE_ATTEN) {
// Normal fall-off, affected by Voice Volume
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_REF_DISTANCE);
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volumeVoice->value) / 255.0f);
- }
- else if (ch->entchannel == CHAN_LESS_ATTEN)
- {
+ } else if (ch->entchannel == CHAN_LESS_ATTEN) {
// Reduced fall-off, affected by Sound Effect Volume
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_VOICE_REF_DISTANCE);
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
- }
- else
- {
+ } else {
// Normal fall-off, affect by Sound Effect Volume
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_REF_DISTANCE);
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
@@ -2898,33 +2613,27 @@ void S_Update_(void) {
int nTotalBytesDecoded = 0;
int nBuffersToAdd = 0;
- if (ch->thesfx->pMP3StreamHeader)
- {
- memcpy(&ch->MP3StreamHeader, ch->thesfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
+ if (ch->thesfx->pMP3StreamHeader) {
+ memcpy(&ch->MP3StreamHeader, ch->thesfx->pMP3StreamHeader, sizeof(ch->MP3StreamHeader));
ch->iMP3SlidingDecodeWritePos = 0;
- ch->iMP3SlidingDecodeWindowPos= 0;
+ ch->iMP3SlidingDecodeWindowPos = 0;
// Reset streaming buffers status's
for (i = 0; i < NUM_STREAMING_BUFFERS; i++)
ch->buffers[i].Status = UNQUEUED;
// Decode (STREAMING_BUFFER_SIZE / 1152) MP3 frames for each of the NUM_STREAMING_BUFFERS AL Buffers
- for (i = 0; i < NUM_STREAMING_BUFFERS; i++)
- {
+ for (i = 0; i < NUM_STREAMING_BUFFERS; i++) {
nTotalBytesDecoded = 0;
- for (j = 0; j < (STREAMING_BUFFER_SIZE / 1152); j++)
- {
- nBytesDecoded = C_MP3Stream_Decode(&ch->MP3StreamHeader, 0); // added ,0 ?
+ for (j = 0; j < (STREAMING_BUFFER_SIZE / 1152); j++) {
+ nBytesDecoded = C_MP3Stream_Decode(&ch->MP3StreamHeader, 0); // added ,0 ?
memcpy(ch->buffers[i].Data + nTotalBytesDecoded, ch->MP3StreamHeader.bDecodeBuffer, nBytesDecoded);
- if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
- {
- if (ch->thesfx->lipSyncData)
- {
- ch->thesfx->lipSyncData[(i*NUM_STREAMING_BUFFERS)+j] = S_MP3PreProcessLipSync(ch, (short *)(ch->MP3StreamHeader.bDecodeBuffer));
- }
- else
- {
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) {
+ if (ch->thesfx->lipSyncData) {
+ ch->thesfx->lipSyncData[(i * NUM_STREAMING_BUFFERS) + j] =
+ S_MP3PreProcessLipSync(ch, (short *)(ch->MP3StreamHeader.bDecodeBuffer));
+ } else {
#ifdef _DEBUG
#ifdef _MSC_VER
char szString[256];
@@ -2937,8 +2646,7 @@ void S_Update_(void) {
nTotalBytesDecoded += nBytesDecoded;
}
- if (nTotalBytesDecoded != STREAMING_BUFFER_SIZE)
- {
+ if (nTotalBytesDecoded != STREAMING_BUFFER_SIZE) {
memset(ch->buffers[i].Data + nTotalBytesDecoded, 0, (STREAMING_BUFFER_SIZE - nTotalBytesDecoded));
break;
}
@@ -2952,15 +2660,13 @@ void S_Update_(void) {
// Make sure queue is empty first
alSourcei(s_channels[source].alSource, AL_BUFFER, NULL);
- for (i = 0; i < nBuffersToAdd; i++)
- {
+ for (i = 0; i < nBuffersToAdd; i++) {
// Copy decoded data to AL Buffer
alBufferData(ch->buffers[i].BufferID, AL_FORMAT_MONO16, ch->buffers[i].Data, STREAMING_BUFFER_SIZE, 22050);
// Queue AL Buffer on Source
alSourceQueueBuffers(s_channels[source].alSource, 1, &(ch->buffers[i].BufferID));
- if (alGetError() == AL_NO_ERROR)
- {
+ if (alGetError() == AL_NO_ERROR) {
ch->buffers[i].Status = QUEUED;
}
}
@@ -2973,18 +2679,14 @@ void S_Update_(void) {
ch->bStreaming = true;
- if ( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
- {
- if (ch->thesfx->lipSyncData)
- {
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) {
+ if (ch->thesfx->lipSyncData) {
// Record start time for Lip-syncing
s_channels[source].iStartTime = timeGetTime();
// Prepare lipsync value(s)
- s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[0];
- }
- else
- {
+ s_entityWavVol[ch->entnum] = ch->thesfx->lipSyncData[0];
+ } else {
#ifdef _DEBUG
#ifdef _MSC_VER
char szString[256];
@@ -2996,9 +2698,7 @@ void S_Update_(void) {
}
return;
- }
- else
- {
+ } else {
// Attach buffer to source
alSourcei(s_channels[source].alSource, AL_BUFFER, ch->thesfx->Buffer);
@@ -3010,18 +2710,14 @@ void S_Update_(void) {
if (alGetError() == AL_NO_ERROR)
s_channels[source].bPlaying = true;
- if ( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
- {
- if (ch->thesfx->lipSyncData)
- {
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) {
+ if (ch->thesfx->lipSyncData) {
// Record start time for Lip-syncing
s_channels[source].iStartTime = timeGetTime();
// Prepare lipsync value(s)
- s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[0];
- }
- else
- {
+ s_entityWavVol[ch->entnum] = ch->thesfx->lipSyncData[0];
+ } else {
#ifdef _DEBUG
char szString[256];
sprintf(szString, "Missing lip-sync info. for %s\n", ch->thesfx->sSoundName);
@@ -3037,9 +2733,7 @@ void S_Update_(void) {
UpdateLoopingSounds();
AL_UpdateRawSamples();
- }
- else
- {
+ } else {
#endif
// Updates s_soundtime
S_GetSoundtime();
@@ -3054,30 +2748,27 @@ void S_Update_(void) {
endtime = (int)(s_soundtime + s_mixahead->value * dma.speed);
// mix to an even submission block size
- endtime = (endtime + dma.submission_chunk-1)
- & ~(dma.submission_chunk-1);
+ endtime = (endtime + dma.submission_chunk - 1) & ~(dma.submission_chunk - 1);
// never mix more than the complete buffer
- samps = dma.samples >> (dma.channels-1);
+ samps = dma.samples >> (dma.channels - 1);
if (endtime - s_soundtime > (unsigned)samps)
endtime = s_soundtime + samps;
+ SNDDMA_BeginPainting();
- SNDDMA_BeginPainting ();
+ S_PaintChannels(endtime);
- S_PaintChannels (endtime);
+ SNDDMA_Submit();
- SNDDMA_Submit ();
-
- S_DoLipSynchs( s_oldpaintedtime );
+ S_DoLipSynchs(s_oldpaintedtime);
#ifdef USE_OPENAL
}
#endif
}
#ifdef USE_OPENAL
-void UpdateSingleShotSounds()
-{
+void UpdateSingleShotSounds() {
int i, j, k;
ALint state;
ALint processed;
@@ -3089,23 +2780,17 @@ void UpdateSingleShotSounds()
// Firstly, check if any single-shot sounds have completed, or if they need more data (for streaming Sources),
// and/or if any of the currently playing (non-Ambient) looping sounds need to be stopped
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
ch->bProcessed = false;
- if ((s_channels[i].bPlaying) && (!ch->bLooping))
- {
+ if ((s_channels[i].bPlaying) && (!ch->bLooping)) {
// Single-shot
- if (s_channels[i].bStreaming == false)
- {
+ if (s_channels[i].bStreaming == false) {
alGetSourcei(s_channels[i].alSource, AL_SOURCE_STATE, &state);
- if (state == AL_STOPPED)
- {
+ if (state == AL_STOPPED) {
s_channels[i].thesfx = NULL;
s_channels[i].bPlaying = false;
}
- }
- else
- {
+ } else {
// Process streaming sample
// Procedure :-
@@ -3121,14 +2806,11 @@ void UpdateSingleShotSounds()
int nBytesDecoded;
- if (ch->thesfx->pMP3StreamHeader)
- {
- if (ch->MP3StreamHeader.iSourceBytesRemaining == 0)
- {
+ if (ch->thesfx->pMP3StreamHeader) {
+ if (ch->MP3StreamHeader.iSourceBytesRemaining == 0) {
// Finished decoding data - if the source has finished playing then we're done
alGetSourcei(ch->alSource, AL_SOURCE_STATE, &state);
- if (state == AL_STOPPED)
- {
+ if (state == AL_STOPPED) {
// Attach NULL buffer to Source to remove any buffers left in the queue
alSourcei(ch->alSource, AL_BUFFER, NULL);
ch->thesfx = NULL;
@@ -3142,13 +2824,10 @@ void UpdateSingleShotSounds()
alGetSourcei(ch->alSource, AL_BUFFERS_PROCESSED, &processed);
ALuint buffer;
- while (processed)
- {
+ while (processed) {
alSourceUnqueueBuffers(ch->alSource, 1, &buffer);
- for (j = 0; j < NUM_STREAMING_BUFFERS; j++)
- {
- if (ch->buffers[j].BufferID == buffer)
- {
+ for (j = 0; j < NUM_STREAMING_BUFFERS; j++) {
+ if (ch->buffers[j].BufferID == buffer) {
ch->buffers[j].Status = UNQUEUED;
break;
}
@@ -3158,28 +2837,20 @@ void UpdateSingleShotSounds()
int nTotalBytesDecoded = 0;
- for (j = 0; j < NUM_STREAMING_BUFFERS; j++)
- {
- if ((ch->buffers[j].Status == UNQUEUED) && (ch->MP3StreamHeader.iSourceBytesRemaining > 0))
- {
+ for (j = 0; j < NUM_STREAMING_BUFFERS; j++) {
+ if ((ch->buffers[j].Status == UNQUEUED) && (ch->MP3StreamHeader.iSourceBytesRemaining > 0)) {
nTotalBytesDecoded = 0;
- for (k = 0; k < (STREAMING_BUFFER_SIZE / 1152); k++)
- {
+ for (k = 0; k < (STREAMING_BUFFER_SIZE / 1152); k++) {
nBytesDecoded = C_MP3Stream_Decode(&ch->MP3StreamHeader, 0); // added ,0
- if (nBytesDecoded > 0)
- {
+ if (nBytesDecoded > 0) {
memcpy(ch->buffers[j].Data + nTotalBytesDecoded, ch->MP3StreamHeader.bDecodeBuffer, nBytesDecoded);
- if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
- {
- if (ch->thesfx->lipSyncData)
- {
- ch->thesfx->lipSyncData[(j*4)+k] = S_MP3PreProcessLipSync(ch, (short *)(ch->buffers[j].Data));
- }
- else
- {
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) {
+ if (ch->thesfx->lipSyncData) {
+ ch->thesfx->lipSyncData[(j * 4) + k] = S_MP3PreProcessLipSync(ch, (short *)(ch->buffers[j].Data));
+ } else {
#ifdef _DEBUG
sprintf(szString, "Missing lip-sync info. for %s\n", ch->thesfx->sSoundName);
OutputDebugString(szString);
@@ -3187,20 +2858,16 @@ void UpdateSingleShotSounds()
}
}
nTotalBytesDecoded += nBytesDecoded;
- }
- else
- {
+ } else {
// Make sure that iSourceBytesRemaining is 0
- if (ch->MP3StreamHeader.iSourceBytesRemaining != 0)
- {
+ if (ch->MP3StreamHeader.iSourceBytesRemaining != 0) {
ch->MP3StreamHeader.iSourceBytesRemaining = 0;
break;
}
}
}
- if (nTotalBytesDecoded != STREAMING_BUFFER_SIZE)
- {
+ if (nTotalBytesDecoded != STREAMING_BUFFER_SIZE) {
memset(ch->buffers[j].Data + nTotalBytesDecoded, 0, (STREAMING_BUFFER_SIZE - nTotalBytesDecoded));
// Move data to buffer
@@ -3213,9 +2880,7 @@ void UpdateSingleShotSounds()
ch->buffers[j].Status = QUEUED;
break;
- }
- else
- {
+ } else {
// Move data to buffer
alBufferData(ch->buffers[j].BufferID, AL_FORMAT_MONO16, ch->buffers[j].Data, STREAMING_BUFFER_SIZE, 22050);
@@ -3230,12 +2895,12 @@ void UpdateSingleShotSounds()
// Get state of Buffer
alGetSourcei(ch->alSource, AL_SOURCE_STATE, &state);
- if (state != AL_PLAYING)
- {
+ if (state != AL_PLAYING) {
alSourcePlay(ch->alSource);
#ifdef _DEBUG
char szString[256];
- sprintf(szString,"[%d] Restarting playback of single-shot streaming MP3 sample - still have %d bytes to decode\n", i, ch->MP3StreamHeader.iSourceBytesRemaining);
+ sprintf(szString, "[%d] Restarting playback of single-shot streaming MP3 sample - still have %d bytes to decode\n", i,
+ ch->MP3StreamHeader.iSourceBytesRemaining);
OutputDebugString(szString);
#endif
}
@@ -3245,34 +2910,26 @@ void UpdateSingleShotSounds()
}
}
-void UpdateLoopingSounds()
-{
- int i,j;
+void UpdateLoopingSounds() {
+ int i, j;
ALuint source;
channel_t *ch;
- loopSound_t *loop;
+ loopSound_t *loop;
float pos[3];
// First check to see if any of the looping sounds are already playing at the correct positions
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- if (ch->bLooping && s_channels[i].bPlaying)
- {
- for (j = 0; j < numLoopSounds; j++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ if (ch->bLooping && s_channels[i].bPlaying) {
+ for (j = 0; j < numLoopSounds; j++) {
loop = &loopSounds[j];
// If this channel is playing the right sound effect at the right position then mark this channel and looping sound
// as processed
- if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx) )
- {
- if ( (loop->origin[0] == listener_pos[0]) && (loop->origin[1] == -listener_pos[2])
- && (loop->origin[2] == listener_pos[1]) )
- {
+ if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx)) {
+ if ((loop->origin[0] == listener_pos[0]) && (loop->origin[1] == -listener_pos[2]) && (loop->origin[2] == listener_pos[1])) {
// Assume that this sound is head relative
- if (!loop->bRelative)
- {
+ if (!loop->bRelative) {
// Set position to 0,0,0 and turn on Head Relative Mode
float pos[3];
pos[0] = 0.f;
@@ -3285,24 +2942,20 @@ void UpdateLoopingSounds()
}
// Make sure Gain is set correctly
- if (ch->master_vol != loop->volume)
- {
+ if (ch->master_vol != loop->volume) {
ch->master_vol = loop->volume;
alSourcef(s_channels[i].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
}
ch->bProcessed = true;
loop->bProcessed = qtrue;
- }
- else if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx) && (!memcmp(ch->origin, loop->origin, sizeof(ch->origin))))
- {
+ } else if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx) && (!memcmp(ch->origin, loop->origin, sizeof(ch->origin)))) {
// Match !
ch->bProcessed = true;
loop->bProcessed = qtrue;
// Make sure Gain is set correctly
- if (ch->master_vol != loop->volume)
- {
+ if (ch->master_vol != loop->volume) {
ch->master_vol = loop->volume;
alSourcef(s_channels[i].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
}
@@ -3316,16 +2969,12 @@ void UpdateLoopingSounds()
// Next check if the correct looping sound is playing, but at the wrong position
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- if ((ch->bLooping) && (ch->bProcessed == false) && s_channels[i].bPlaying)
- {
- for (j = 0; j < numLoopSounds; j++)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ if ((ch->bLooping) && (ch->bProcessed == false) && s_channels[i].bPlaying) {
+ for (j = 0; j < numLoopSounds; j++) {
loop = &loopSounds[j];
- if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx))
- {
+ if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx)) {
// Same sound - wrong position
ch->origin[0] = loop->origin[0];
ch->origin[1] = loop->origin[1];
@@ -3353,10 +3002,8 @@ void UpdateLoopingSounds()
// If any non-procesed looping sounds are still playing on a channel, they can be removed as they are no longer
// required
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- if (s_channels[i].bPlaying && ch->bLooping && !ch->bProcessed)
- {
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ if (s_channels[i].bPlaying && ch->bLooping && !ch->bProcessed) {
// Sound no longer needed
alSourceStop(s_channels[i].alSource);
ch->thesfx = NULL;
@@ -3368,13 +3015,11 @@ void UpdateLoopingSounds()
alGetError();
#endif
// Finally if there are any non-processed sounds left, we need to try and play them
- for (j = 0; j < numLoopSounds; j++)
- {
+ for (j = 0; j < numLoopSounds; j++) {
loop = &loopSounds[j];
- if (!loop->bProcessed)
- {
- ch = S_PickChannel(0,0);
+ if (!loop->bProcessed) {
+ ch = S_PickChannel(0, 0);
ch->master_vol = loop->volume;
ch->entnum = loop->entnum;
@@ -3383,17 +3028,13 @@ void UpdateLoopingSounds()
ch->bLooping = true;
// Check if the Source is positioned at exactly the same location as the listener
- if ( (loop->origin[0] == listener_pos[0]) && (loop->origin[1] == -listener_pos[2])
- && (loop->origin[2] == listener_pos[1]) )
- {
+ if ((loop->origin[0] == listener_pos[0]) && (loop->origin[1] == -listener_pos[2]) && (loop->origin[2] == listener_pos[1])) {
// Assume that this sound is head relative
loop->bRelative = qtrue;
ch->origin[0] = 0.f;
ch->origin[1] = 0.f;
ch->origin[2] = 0.f;
- }
- else
- {
+ } else {
ch->origin[0] = loop->origin[0];
ch->origin[1] = loop->origin[1];
ch->origin[2] = loop->origin[2];
@@ -3411,12 +3052,9 @@ void UpdateLoopingSounds()
alSourcei(s_channels[source].alSource, AL_LOOPING, AL_TRUE);
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.0f);
alSourcei(s_channels[source].alSource, AL_SOURCE_RELATIVE, ch->fixed_origin ? AL_TRUE : AL_FALSE);
- if (ch->entchannel == CHAN_LESS_ATTEN)
- { // Reduced fall-off
+ if (ch->entchannel == CHAN_LESS_ATTEN) { // Reduced fall-off
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_VOICE_REF_DISTANCE);
- }
- else
- {
+ } else {
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_REF_DISTANCE);
}
if (s_bEALFileLoaded)
@@ -3430,13 +3068,12 @@ void UpdateLoopingSounds()
}
}
-void AL_UpdateRawSamples()
-{
+void AL_UpdateRawSamples() {
ALuint buffer;
ALint size;
ALint processed;
ALint state;
- int i,j,src;
+ int i, j, src;
#ifdef _DEBUG
// Clear Open AL Error
@@ -3448,8 +3085,7 @@ void AL_UpdateRawSamples()
// Find out how many buffers have been processed (played) by the Source
alGetSourcei(s_channels[0].alSource, AL_BUFFERS_PROCESSED, &processed);
- while (processed)
- {
+ while (processed) {
// Unqueue each buffer, determine the length of the buffer, and then delete it
alSourceUnqueueBuffers(s_channels[0].alSource, 1, &buffer);
alGetBufferi(buffer, AL_SIZE, &size);
@@ -3462,22 +3098,19 @@ void AL_UpdateRawSamples()
}
// Add new data to a new Buffer and queue it on the Source
- if (s_rawend > s_paintedtime)
- {
- size = (s_rawend - s_paintedtime)<<2;
- if (size > (MAX_RAW_SAMPLES<<2))
- {
+ if (s_rawend > s_paintedtime) {
+ size = (s_rawend - s_paintedtime) << 2;
+ if (size > (MAX_RAW_SAMPLES << 2)) {
OutputDebugString("UpdateRawSamples :- Raw Sample buffer has overflowed !!!\n");
- size = MAX_RAW_SAMPLES<<2;
+ size = MAX_RAW_SAMPLES << 2;
s_paintedtime = s_rawend - MAX_RAW_SAMPLES;
}
// Copy samples from RawSamples to audio buffer (sg.rawdata)
- for (i = s_paintedtime, j = 0; i < s_rawend; i++, j+=2)
- {
+ for (i = s_paintedtime, j = 0; i < s_rawend; i++, j += 2) {
src = i & (MAX_RAW_SAMPLES - 1);
- s_rawdata[j] = (short)(s_rawsamples[src].left>>8);
- s_rawdata[j+1] = (short)(s_rawsamples[src].right>>8);
+ s_rawdata[j] = (short)(s_rawsamples[src].left >> 8);
+ s_rawdata[j + 1] = (short)(s_rawsamples[src].right >> 8);
}
// Need to generate more than 1 buffer for music playback
@@ -3495,19 +3128,15 @@ void AL_UpdateRawSamples()
// iterations++;
int iterations = 0;
- int largestBufferSize = MAX_RAW_SAMPLES; // in bytes (== quarter of Raw Samples data)
- while (size)
- {
+ int largestBufferSize = MAX_RAW_SAMPLES; // in bytes (== quarter of Raw Samples data)
+ while (size) {
alGenBuffers(1, &buffer);
- if (size > largestBufferSize)
- {
- alBufferData(buffer, AL_FORMAT_STEREO16, (char*)(s_rawdata + ((iterations * largestBufferSize)>>1)), largestBufferSize, 22050);
+ if (size > largestBufferSize) {
+ alBufferData(buffer, AL_FORMAT_STEREO16, (char *)(s_rawdata + ((iterations * largestBufferSize) >> 1)), largestBufferSize, 22050);
size -= largestBufferSize;
- }
- else
- {
- alBufferData(buffer, AL_FORMAT_STEREO16, (char*)(s_rawdata + ((iterations * largestBufferSize)>>1)), size, 22050);
+ } else {
+ alBufferData(buffer, AL_FORMAT_STEREO16, (char *)(s_rawdata + ((iterations * largestBufferSize) >> 1)), size, 22050);
size = 0;
}
@@ -3520,13 +3149,11 @@ void AL_UpdateRawSamples()
// Check that the Source is actually playing
alGetSourcei(s_channels[0].alSource, AL_SOURCE_STATE, &state);
- if (state != AL_PLAYING)
- {
+ if (state != AL_PLAYING) {
// Stopped playing ... due to buffer underrun
// Unqueue any buffers still on the Source (they will be PROCESSED), and restart playback
alGetSourcei(s_channels[0].alSource, AL_BUFFERS_PROCESSED, &processed);
- while (processed)
- {
+ while (processed) {
alSourceUnqueueBuffers(s_channels[0].alSource, 1, &buffer);
processed--;
alGetBufferi(buffer, AL_SIZE, &size);
@@ -3550,14 +3177,12 @@ void AL_UpdateRawSamples()
}
#endif
-int S_MP3PreProcessLipSync(channel_t *ch, short *data)
-{
+int S_MP3PreProcessLipSync(channel_t *ch, short *data) {
int i;
int sample;
int sampleTotal = 0;
- for (i = 0; i < 576; i += 100)
- {
+ for (i = 0; i < 576; i += 100) {
sample = LittleShort(data[i]);
sample = sample >> 8;
sampleTotal += sample * sample;
@@ -3579,9 +3204,7 @@ int S_MP3PreProcessLipSync(channel_t *ch, short *data)
return sample;
}
-
-void S_SetLipSyncs()
-{
+void S_SetLipSyncs() {
int i;
unsigned int samples;
int currentTime, timePlayed;
@@ -3595,31 +3218,27 @@ void S_SetLipSyncs()
#ifdef _WIN32
currentTime = timeGetTime();
#else
- // FIXME: alternative to timeGetTime ?
- currentTime = 0;
+ // FIXME: alternative to timeGetTime ?
+ currentTime = 0;
#endif
memset(s_entityWavVol, 0, sizeof(s_entityWavVol));
ch = s_channels + 1;
- for (i = 1; i < s_numChannels; i++, ch++)
- {
- if ((!ch->thesfx)||(!ch->bPlaying))
+ for (i = 1; i < s_numChannels; i++, ch++) {
+ if ((!ch->thesfx) || (!ch->bPlaying))
continue;
- if ( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
- {
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL) {
// Calculate how much time has passed since the sample was started
timePlayed = currentTime - ch->iStartTime;
- if (ch->thesfx->eSoundCompressionMethod==ct_16)
- {
+ if (ch->thesfx->eSoundCompressionMethod == ct_16) {
// There is a new computed lip-sync value every 1000 samples - so find out how many samples
// have been played and lookup the value in the lip-sync table
samples = (timePlayed * 22050) / 1000;
- if (ch->thesfx->lipSyncData == NULL)
- {
+ if (ch->thesfx->lipSyncData == NULL) {
#ifdef _DEBUG
#ifdef _MSC_VER
sprintf(szString, "Missing lip-sync info. for %s\n", ch->thesfx->sSoundName);
@@ -3628,27 +3247,23 @@ void S_SetLipSyncs()
#endif
}
- if ((ch->thesfx->lipSyncData) && (samples < (unsigned)ch->thesfx->iSoundLengthInSamples))
- {
- s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[samples / 1000];
+ if ((ch->thesfx->lipSyncData) && (samples < (unsigned)ch->thesfx->iSoundLengthInSamples)) {
+ s_entityWavVol[ch->entnum] = ch->thesfx->lipSyncData[samples / 1000];
-// Com_Printf("%s, total samples = %d, current sample = %d, lip type = %d \n", ch->thesfx->sSoundName, ch->thesfx->iSoundLengthInSamples, samples, s_entityWavVol[ ch->entnum ] );
- if ( s_show->integer == 3 )
- {
- Com_Printf( "(%i)%i %s vol = %i\n", ch->entnum, i, ch->thesfx->sSoundName, s_entityWavVol[ ch->entnum ] );
+ // Com_Printf("%s, total samples = %d, current sample = %d, lip type = %d \n", ch->thesfx->sSoundName,
+ //ch->thesfx->iSoundLengthInSamples, samples, s_entityWavVol[ ch->entnum ] );
+ if (s_show->integer == 3) {
+ Com_Printf("(%i)%i %s vol = %i\n", ch->entnum, i, ch->thesfx->sSoundName, s_entityWavVol[ch->entnum]);
}
}
- }
- else
- {
+ } else {
// MP3
// There is a new computed lip-sync value every 576 samples - so find out how many samples
// have been played and lookup the value in the lip-sync table
samples = (timePlayed * 22050) / 1000;
- if (ch->thesfx->lipSyncData == NULL)
- {
+ if (ch->thesfx->lipSyncData == NULL) {
#ifdef _DEBUG
#ifdef _MSC_VER
sprintf(szString, "Missing lip-sync info. for %s\n", ch->thesfx->sSoundName);
@@ -3657,13 +3272,11 @@ void S_SetLipSyncs()
#endif
}
- if ((ch->thesfx->lipSyncData) && (samples < (unsigned)ch->thesfx->iSoundLengthInSamples))
- {
- s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[(samples / 576) % 16];
+ if ((ch->thesfx->lipSyncData) && (samples < (unsigned)ch->thesfx->iSoundLengthInSamples)) {
+ s_entityWavVol[ch->entnum] = ch->thesfx->lipSyncData[(samples / 576) % 16];
- if ( s_show->integer == 3 )
- {
- Com_Printf( "(%i)%i %s vol = %i\n", ch->entnum, i, ch->thesfx->sSoundName, s_entityWavVol[ ch->entnum ] );
+ if (s_show->integer == 3) {
+ Com_Printf("(%i)%i %s vol = %i\n", ch->entnum, i, ch->thesfx->sSoundName, s_entityWavVol[ch->entnum]);
}
}
}
@@ -3671,7 +3284,6 @@ void S_SetLipSyncs()
}
}
-
/*
===============================================================================
@@ -3680,105 +3292,79 @@ console functions
===============================================================================
*/
-static void S_Play_f( void ) {
- int i;
- sfxHandle_t h;
+static void S_Play_f(void) {
+ int i;
+ sfxHandle_t h;
char name[256];
i = 1;
- while ( i [loopfile]\n");
+ Com_Printf("music [loopfile]\n");
return;
}
}
-static void S_StopMusic_f( void ) {
- S_StopBackgroundTrack();
-}
+static void S_StopMusic_f(void) { S_StopBackgroundTrack(); }
// a debug function, but no harm to leave in...
//
-static void S_SetDynamicMusic_f(void)
-{
+static void S_SetDynamicMusic_f(void) {
int c = Cmd_Argc();
- if ( c == 2 )
- {
- if (bMusic_IsDynamic)
- {
+ if (c == 2) {
+ if (bMusic_IsDynamic) {
// don't need to check existance of 'explore' or 'action' music, since music wouldn't
// be counted as dynamic if either were missing, but other types are optional...
//
- if (!Q_stricmp(Cmd_Argv(1),"explore"))
- {
- S_SetDynamicMusicState( eBGRNDTRACK_EXPLORE );
+ if (!Q_stricmp(Cmd_Argv(1), "explore")) {
+ S_SetDynamicMusicState(eBGRNDTRACK_EXPLORE);
return;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1),"action"))
- {
- S_SetDynamicMusicState( eBGRNDTRACK_ACTION );
+ } else if (!Q_stricmp(Cmd_Argv(1), "action")) {
+ S_SetDynamicMusicState(eBGRNDTRACK_ACTION);
return;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1),"silence"))
- {
- S_SetDynamicMusicState( eBGRNDTRACK_SILENCE );
+ } else if (!Q_stricmp(Cmd_Argv(1), "silence")) {
+ S_SetDynamicMusicState(eBGRNDTRACK_SILENCE);
return;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1),"boss"))
- {
- if (tMusic_Info[ eBGRNDTRACK_BOSS ].bExists)
- {
- S_SetDynamicMusicState( eBGRNDTRACK_BOSS );
- }
- else
- {
+ } else if (!Q_stricmp(Cmd_Argv(1), "boss")) {
+ if (tMusic_Info[eBGRNDTRACK_BOSS].bExists) {
+ S_SetDynamicMusicState(eBGRNDTRACK_BOSS);
+ } else {
Com_Printf("No 'boss' music defined in current dynamic set\n");
}
return;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1),"death"))
- {
- if (tMusic_Info[ eBGRNDTRACK_DEATH ].bExists)
- {
- S_SetDynamicMusicState( eBGRNDTRACK_DEATH );
- }
- else
- {
+ } else if (!Q_stricmp(Cmd_Argv(1), "death")) {
+ if (tMusic_Info[eBGRNDTRACK_DEATH].bExists) {
+ S_SetDynamicMusicState(eBGRNDTRACK_DEATH);
+ } else {
Com_Printf("No 'death' music defined in current dynamic set\n");
}
return;
}
- }
- else
- {
- DynamicMusicInfoPrint(); // print "inactive" string
+ } else {
+ DynamicMusicInfoPrint(); // print "inactive" string
return;
}
}
@@ -3789,60 +3375,40 @@ static void S_SetDynamicMusic_f(void)
DynamicMusicInfoPrint();
}
-
// this table needs to be in-sync with the typedef'd enum "SoundCompressionMethod_t"... -ste
//
-static const char *sSoundCompressionMethodStrings[ct_NUMBEROF] =
-{
- "16b", // ct_16
- "mp3" // ct_MP3
+static const char *sSoundCompressionMethodStrings[ct_NUMBEROF] = {
+ "16b", // ct_16
+ "mp3" // ct_MP3
};
-void S_SoundList_f( void ) {
- int i;
- sfx_t *sfx;
- int size, total;
- int iVariantCap = -1; // for %d-inquiry stuff
- int iTotalBytes = 0;
+void S_SoundList_f(void) {
+ int i;
+ sfx_t *sfx;
+ int size, total;
+ int iVariantCap = -1; // for %d-inquiry stuff
+ int iTotalBytes = 0;
qboolean bWavOnly = qfalse;
qboolean bShouldBeMP3 = qfalse;
- if ( Cmd_Argc() == 2 )
- {
- if (!Q_stricmp(Cmd_Argv(1), "shouldbeMP3"))
- {
+ if (Cmd_Argc() == 2) {
+ if (!Q_stricmp(Cmd_Argv(1), "shouldbeMP3")) {
bShouldBeMP3 = qtrue;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1), "wavonly"))
- {
+ } else if (!Q_stricmp(Cmd_Argv(1), "wavonly")) {
bWavOnly = qtrue;
- }
- else
- {
- if (!Q_stricmp(Cmd_Argv(1), "1"))
- {
+ } else {
+ if (!Q_stricmp(Cmd_Argv(1), "1")) {
iVariantCap = 1;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1), "2"))
- {
+ } else if (!Q_stricmp(Cmd_Argv(1), "2")) {
iVariantCap = 2;
- }
- else
- if (!Q_stricmp(Cmd_Argv(1), "3"))
- {
+ } else if (!Q_stricmp(Cmd_Argv(1), "3")) {
iVariantCap = 3;
}
}
- }
- else
- {
- Com_Printf("( additional (mutually exclusive) options available:\n'wavonly', 'ShouldBeMP3', '1'/'2'/'3' for %%d-variant capping )\n" );
+ } else {
+ Com_Printf("( additional (mutually exclusive) options available:\n'wavonly', 'ShouldBeMP3', '1'/'2'/'3' for %%d-variant capping )\n");
}
-
-
total = 0;
Com_Printf("\n");
@@ -3852,44 +3418,33 @@ void S_SoundList_f( void ) {
Com_Printf(" | |\n");
Com_Printf(" | |\n");
Com_Printf(" Slot Smpls Type | | Name\n");
-// Com_Printf(" Slot Smpls Type InMem? Name\n");
+ // Com_Printf(" Slot Smpls Type InMem? Name\n");
- for (sfx=s_knownSfx, i=0 ; ibDefaultSound &&
- !sfx->pMP3StreamHeader &&
- sfx->pSoundData &&
- (Z_Size(sfx->pSoundData) > cv_MP3overhead->integer));
-
- if (bMP3DumpOverride || (!bShouldBeMP3 && (!bWavOnly || sfx->eSoundCompressionMethod == ct_16)))
- {
+ qboolean bMP3DumpOverride = (qboolean)(bShouldBeMP3 && cv_MP3overhead && !sfx->bDefaultSound && !sfx->pMP3StreamHeader && sfx->pSoundData &&
+ (Z_Size(sfx->pSoundData) > cv_MP3overhead->integer));
+
+ if (bMP3DumpOverride || (!bShouldBeMP3 && (!bWavOnly || sfx->eSoundCompressionMethod == ct_16))) {
qboolean bDumpThisOne = qtrue;
- if (iVariantCap >= 1 && iVariantCap <= 3)
- {
+ if (iVariantCap >= 1 && iVariantCap <= 3) {
int iStrLen = strlen(sfx->sSoundName);
- if (iStrLen > 2) // crash-safety, jic.
+ if (iStrLen > 2) // crash-safety, jic.
{
- char c = sfx->sSoundName[iStrLen-1];
- char c2 = sfx->sSoundName[iStrLen-2];
+ char c = sfx->sSoundName[iStrLen - 1];
+ char c2 = sfx->sSoundName[iStrLen - 2];
if (!isdigit(c2) // quick-avoid of stuff like "pain75"
- && isdigit(c) && atoi(va("%c",c)) > iVariantCap)
- {
+ && isdigit(c) && atoi(va("%c", c)) > iVariantCap) {
// need to see if this %d-variant should be omitted, in other words if there's a %1 version then skip this...
//
char sFindName[MAX_QPATH];
- Q_strncpyz(sFindName,sfx->sSoundName,sizeof(sFindName));
- sFindName[iStrLen-1] = '1';
+ Q_strncpyz(sFindName, sfx->sSoundName, sizeof(sFindName));
+ sFindName[iStrLen - 1] = '1';
int i2;
sfx_t *sfx2;
- for (sfx2 = s_knownSfx, i2=0 ; i2sSoundName))
- {
- bDumpThisOne = qfalse; // found a %1-variant of this, so use variant capping and ignore this sfx_t
+ for (sfx2 = s_knownSfx, i2 = 0; i2 < s_numSfx; i2++, sfx2++) {
+ if (!Q_stricmp(sFindName, sfx2->sSoundName)) {
+ bDumpThisOne = qfalse; // found a %1-variant of this, so use variant capping and ignore this sfx_t
break;
}
}
@@ -3898,24 +3453,20 @@ void S_SoundList_f( void ) {
}
size = sfx->iSoundLengthInSamples;
- if (sfx->bDefaultSound)
- {
- Com_Printf("%5d Missing file: \"%s\"\n", i, sfx->sSoundName );
- }
- else
- {
- if (bDumpThisOne)
- {
+ if (sfx->bDefaultSound) {
+ Com_Printf("%5d Missing file: \"%s\"\n", i, sfx->sSoundName);
+ } else {
+ if (bDumpThisOne) {
iTotalBytes += (sfx->bInMemory && sfx->pSoundData) ? Z_Size(sfx->pSoundData) : 0;
iTotalBytes += (sfx->bInMemory && sfx->pMP3StreamHeader) ? sizeof(*sfx->pMP3StreamHeader) : 0;
- total += sfx->bInMemory ? size : 0;
+ total += sfx->bInMemory ? size : 0;
}
- Com_Printf("%5d %7i [%s] %s %2d %s", i, size, sSoundCompressionMethodStrings[sfx->eSoundCompressionMethod], sfx->bInMemory?"y":"n", sfx->iLastLevelUsedOn, sfx->sSoundName );
+ Com_Printf("%5d %7i [%s] %s %2d %s", i, size, sSoundCompressionMethodStrings[sfx->eSoundCompressionMethod], sfx->bInMemory ? "y" : "n",
+ sfx->iLastLevelUsedOn, sfx->sSoundName);
- if (!bDumpThisOne)
- {
+ if (!bDumpThisOne) {
Com_Printf(" ( Skipping, variant capped )");
- //OutputDebugString(va("Variant capped: %s\n",sfx->sSoundName));
+ // OutputDebugString(va("Variant capped: %s\n",sfx->sSoundName));
}
Com_Printf("\n");
}
@@ -3923,14 +3474,12 @@ void S_SoundList_f( void ) {
}
Com_Printf(" Slot Smpls Type In? Lev Name\n");
-
- Com_Printf ("Total resident samples: %i %s ( not mem usage, see 'meminfo' ).\n", total, bWavOnly?"(WAV only)":"");
- Com_Printf ("%d out of %d sfx_t slots used\n", s_numSfx, MAX_SFX);
- Com_Printf ("%.2fMB bytes used when counting sfx_t->pSoundData + MP3 headers (if any)\n", (float)iTotalBytes / 1024.0f / 1024.0f);
+ Com_Printf("Total resident samples: %i %s ( not mem usage, see 'meminfo' ).\n", total, bWavOnly ? "(WAV only)" : "");
+ Com_Printf("%d out of %d sfx_t slots used\n", s_numSfx, MAX_SFX);
+ Com_Printf("%.2fMB bytes used when counting sfx_t->pSoundData + MP3 headers (if any)\n", (float)iTotalBytes / 1024.0f / 1024.0f);
S_DisplayFreeMemory();
}
-
/*
===============================================================================
@@ -3939,43 +3488,43 @@ background music functions
===============================================================================
*/
-int FGetLittleLong( fileHandle_t f ) {
- int v;
+int FGetLittleLong(fileHandle_t f) {
+ int v;
- FS_Read( &v, sizeof(v), f );
+ FS_Read(&v, sizeof(v), f);
- return LittleLong( v);
+ return LittleLong(v);
}
-int FGetLittleShort( fileHandle_t f ) {
- short v;
+int FGetLittleShort(fileHandle_t f) {
+ short v;
- FS_Read( &v, sizeof(v), f );
+ FS_Read(&v, sizeof(v), f);
- return LittleShort( v);
+ return LittleShort(v);
}
// returns the length of the data in the chunk, or 0 if not found
-int S_FindWavChunk( fileHandle_t f, const char *chunk ) {
- char name[5];
- int len;
- int r;
+int S_FindWavChunk(fileHandle_t f, const char *chunk) {
+ char name[5];
+ int len;
+ int r;
name[4] = 0;
len = 0;
- r = FS_Read( name, 4, f );
- if ( r != 4 ) {
+ r = FS_Read(name, 4, f);
+ if (r != 4) {
return 0;
}
- len = FGetLittleLong( f );
- if ( len < 0 || len > 0xfffffff ) {
+ len = FGetLittleLong(f);
+ if (len < 0 || len > 0xfffffff) {
len = 0;
return 0;
}
- len = (len + 1 ) & ~1; // pad to word boundary
-// s_nextWavChunk += len + 8;
+ len = (len + 1) & ~1; // pad to word boundary
+ // s_nextWavChunk += len + 8;
- if ( strcmp( name, chunk ) ) {
+ if (strcmp(name, chunk)) {
return 0;
}
return len;
@@ -3986,11 +3535,10 @@ int S_FindWavChunk( fileHandle_t f, const char *chunk ) {
//
// DO NOT replace this with a call to FS_FileExists, that's for checking about writing out, and doesn't work for this.
//
-qboolean S_FileExists( const char *psFilename )
-{
+qboolean S_FileExists(const char *psFilename) {
fileHandle_t fhTemp;
- FS_FOpenFileRead (psFilename, &fhTemp, qtrue); // qtrue so I can fclose the handle without closing a PAK
+ FS_FOpenFileRead(psFilename, &fhTemp, qtrue); // qtrue so I can fclose the handle without closing a PAK
if (!fhTemp)
return qfalse;
@@ -4000,145 +3548,125 @@ qboolean S_FileExists( const char *psFilename )
// some stuff for streaming MP3 files from disk (not pleasant, but nothing about MP3 is, other than compression ratios...)
//
-static void MP3MusicStream_Reset(MusicInfo_t *pMusicInfo)
-{
- pMusicInfo->iMP3MusicStream_DiskReadPos = 0;
- pMusicInfo->iMP3MusicStream_DiskWindowPos = 0;
+static void MP3MusicStream_Reset(MusicInfo_t *pMusicInfo) {
+ pMusicInfo->iMP3MusicStream_DiskReadPos = 0;
+ pMusicInfo->iMP3MusicStream_DiskWindowPos = 0;
}
//
// return is where the decoder should read from...
//
-static byte *MP3MusicStream_ReadFromDisk(MusicInfo_t *pMusicInfo, int iReadOffset, int iReadBytesNeeded)
-{
- if (iReadOffset < pMusicInfo->iMP3MusicStream_DiskWindowPos)
- {
- assert(0); // should never happen
- return pMusicInfo->byMP3MusicStream_DiskBuffer; // ...but return something safe anyway
+static byte *MP3MusicStream_ReadFromDisk(MusicInfo_t *pMusicInfo, int iReadOffset, int iReadBytesNeeded) {
+ if (iReadOffset < pMusicInfo->iMP3MusicStream_DiskWindowPos) {
+ assert(0); // should never happen
+ return pMusicInfo->byMP3MusicStream_DiskBuffer; // ...but return something safe anyway
}
- while (iReadOffset + iReadBytesNeeded > pMusicInfo->iMP3MusicStream_DiskReadPos)
- {
- int iBytesRead = FS_Read( pMusicInfo->byMP3MusicStream_DiskBuffer + (pMusicInfo->iMP3MusicStream_DiskReadPos - pMusicInfo->iMP3MusicStream_DiskWindowPos), iMP3MusicStream_DiskBytesToRead, pMusicInfo->s_backgroundFile );
+ while (iReadOffset + iReadBytesNeeded > pMusicInfo->iMP3MusicStream_DiskReadPos) {
+ int iBytesRead =
+ FS_Read(pMusicInfo->byMP3MusicStream_DiskBuffer + (pMusicInfo->iMP3MusicStream_DiskReadPos - pMusicInfo->iMP3MusicStream_DiskWindowPos),
+ iMP3MusicStream_DiskBytesToRead, pMusicInfo->s_backgroundFile);
pMusicInfo->iMP3MusicStream_DiskReadPos += iBytesRead;
- if (iBytesRead != iMP3MusicStream_DiskBytesToRead) // quietly ignore any requests to read past file end
+ if (iBytesRead != iMP3MusicStream_DiskBytesToRead) // quietly ignore any requests to read past file end
{
- break; // we need to do this because the disk read code can't know how much source data we need to
- // read for a given number of requested output bytes, so we'll always be asking for too many
+ break; // we need to do this because the disk read code can't know how much source data we need to
+ // read for a given number of requested output bytes, so we'll always be asking for too many
}
}
// if reached halfway point in buffer (approx 20k), backscroll it...
//
- if (pMusicInfo->iMP3MusicStream_DiskReadPos - pMusicInfo->iMP3MusicStream_DiskWindowPos > iMP3MusicStream_DiskBufferSize/2)
- {
+ if (pMusicInfo->iMP3MusicStream_DiskReadPos - pMusicInfo->iMP3MusicStream_DiskWindowPos > iMP3MusicStream_DiskBufferSize / 2) {
int iMoveSrcOffset = iReadOffset - pMusicInfo->iMP3MusicStream_DiskWindowPos;
- int iMoveCount = (pMusicInfo->iMP3MusicStream_DiskReadPos - pMusicInfo->iMP3MusicStream_DiskWindowPos ) - iMoveSrcOffset;
- memmove( &pMusicInfo->byMP3MusicStream_DiskBuffer, &pMusicInfo->byMP3MusicStream_DiskBuffer[iMoveSrcOffset], iMoveCount);
+ int iMoveCount = (pMusicInfo->iMP3MusicStream_DiskReadPos - pMusicInfo->iMP3MusicStream_DiskWindowPos) - iMoveSrcOffset;
+ memmove(&pMusicInfo->byMP3MusicStream_DiskBuffer, &pMusicInfo->byMP3MusicStream_DiskBuffer[iMoveSrcOffset], iMoveCount);
pMusicInfo->iMP3MusicStream_DiskWindowPos += iMoveSrcOffset;
}
return pMusicInfo->byMP3MusicStream_DiskBuffer + (iReadOffset - pMusicInfo->iMP3MusicStream_DiskWindowPos);
}
-
// does NOT set s_rawend!...
//
-static void S_StopBackgroundTrack_Actual( MusicInfo_t *pMusicInfo )
-{
- if ( pMusicInfo->s_backgroundFile )
- {
- if ( pMusicInfo->s_backgroundFile != -1)
- {
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
+static void S_StopBackgroundTrack_Actual(MusicInfo_t *pMusicInfo) {
+ if (pMusicInfo->s_backgroundFile) {
+ if (pMusicInfo->s_backgroundFile != -1) {
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
}
pMusicInfo->s_backgroundFile = 0;
}
}
-static void FreeMusic( MusicInfo_t *pMusicInfo )
-{
- if (pMusicInfo->pLoadedData)
- {
+static void FreeMusic(MusicInfo_t *pMusicInfo) {
+ if (pMusicInfo->pLoadedData) {
Z_Free(pMusicInfo->pLoadedData);
- pMusicInfo->pLoadedData = NULL; // these two MUST be kept as valid/invalid together
- pMusicInfo->sLoadedDataName[0]= '\0'; //
- pMusicInfo->iLoadedDataLen = 0;
+ pMusicInfo->pLoadedData = NULL; // these two MUST be kept as valid/invalid together
+ pMusicInfo->sLoadedDataName[0] = '\0'; //
+ pMusicInfo->iLoadedDataLen = 0;
}
}
// called only by snd_shutdown (from snd_restart or app exit)
//
-void S_UnCacheDynamicMusic( void )
-{
- for (int i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++)
- {
- FreeMusic( &tMusic_Info[i]);
+void S_UnCacheDynamicMusic(void) {
+ for (int i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++) {
+ FreeMusic(&tMusic_Info[i]);
}
}
-static qboolean S_StartBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolean qbDynamic, const char *intro, const char *loop )
-{
- int len;
- char dump[16];
- char name[MAX_QPATH];
+static qboolean S_StartBackgroundTrack_Actual(MusicInfo_t *pMusicInfo, qboolean qbDynamic, const char *intro, const char *loop) {
+ int len;
+ char dump[16];
+ char name[MAX_QPATH];
- Q_strncpyz( sMusic_BackgroundLoop, loop, sizeof( sMusic_BackgroundLoop ));
+ Q_strncpyz(sMusic_BackgroundLoop, loop, sizeof(sMusic_BackgroundLoop));
- Q_strncpyz( name, intro, sizeof( name ) - 4 ); // this seems to be so that if the filename hasn't got an extension
- // but doesn't have the room to append on either then you'll just
- // get the "soft" fopen() error, rather than the ERR_DROP you'd get
- // if COM_DefaultExtension didn't have room to add it on.
- COM_DefaultExtension( name, sizeof( name ), ".mp3" );
+ Q_strncpyz(name, intro, sizeof(name) - 4); // this seems to be so that if the filename hasn't got an extension
+ // but doesn't have the room to append on either then you'll just
+ // get the "soft" fopen() error, rather than the ERR_DROP you'd get
+ // if COM_DefaultExtension didn't have room to add it on.
+ COM_DefaultExtension(name, sizeof(name), ".mp3");
// close the background track, but DON'T reset s_rawend (or remaining music bits that haven't been output yet will be cut off)
//
- S_StopBackgroundTrack_Actual( pMusicInfo );
+ S_StopBackgroundTrack_Actual(pMusicInfo);
pMusicInfo->bIsMP3 = qfalse;
- if ( !intro[0] ) {
+ if (!intro[0]) {
return qfalse;
}
// new bit, if file requested is not same any loaded one (if prev was in-mem), ditch it...
//
- if (Q_stricmp(name, pMusicInfo->sLoadedDataName))
- {
- FreeMusic( pMusicInfo );
+ if (Q_stricmp(name, pMusicInfo->sLoadedDataName)) {
+ FreeMusic(pMusicInfo);
}
- if (!Q_stricmpn(name+(strlen(name)-4),".mp3",4))
- {
- if (pMusicInfo->pLoadedData)
- {
+ if (!Q_stricmpn(name + (strlen(name) - 4), ".mp3", 4)) {
+ if (pMusicInfo->pLoadedData) {
pMusicInfo->s_backgroundFile = -1;
- }
- else
- {
- pMusicInfo->iLoadedDataLen = FS_FOpenFileRead( name, &pMusicInfo->s_backgroundFile, qtrue );
+ } else {
+ pMusicInfo->iLoadedDataLen = FS_FOpenFileRead(name, &pMusicInfo->s_backgroundFile, qtrue);
}
- if (!pMusicInfo->s_backgroundFile)
- {
- Com_Printf( S_COLOR_RED"Couldn't open music file %s\n", name );
+ if (!pMusicInfo->s_backgroundFile) {
+ Com_Printf(S_COLOR_RED "Couldn't open music file %s\n", name);
return qfalse;
}
- MP3MusicStream_Reset( pMusicInfo );
+ MP3MusicStream_Reset(pMusicInfo);
- byte *pbMP3DataSegment = NULL;
- int iInitialMP3ReadSize = 8192; // fairly arbitrary, whatever size this is then the decoder is allowed to
- // scan up to halfway of it to find floating headers, so don't make it
- // too small. 8k works fine.
+ byte *pbMP3DataSegment = NULL;
+ int iInitialMP3ReadSize = 8192; // fairly arbitrary, whatever size this is then the decoder is allowed to
+ // scan up to halfway of it to find floating headers, so don't make it
+ // too small. 8k works fine.
qboolean bMusicSucceeded = qfalse;
- if (qbDynamic)
- {
- if (!pMusicInfo->pLoadedData)
- {
- pMusicInfo->pLoadedData = (byte *) Z_Malloc(pMusicInfo->iLoadedDataLen, TAG_SND_DYNAMICMUSIC, qfalse);
+ if (qbDynamic) {
+ if (!pMusicInfo->pLoadedData) {
+ pMusicInfo->pLoadedData = (byte *)Z_Malloc(pMusicInfo->iLoadedDataLen, TAG_SND_DYNAMICMUSIC, qfalse);
S_ClearSoundBuffer();
FS_Read(pMusicInfo->pLoadedData, pMusicInfo->iLoadedDataLen, pMusicInfo->s_backgroundFile);
@@ -4147,95 +3675,79 @@ static qboolean S_StartBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolean
// enable the rest of the code to work as before...
//
- pbMP3DataSegment = pMusicInfo->pLoadedData;
+ pbMP3DataSegment = pMusicInfo->pLoadedData;
iInitialMP3ReadSize = pMusicInfo->iLoadedDataLen;
- }
- else
- {
+ } else {
pbMP3DataSegment = MP3MusicStream_ReadFromDisk(pMusicInfo, 0, iInitialMP3ReadSize);
}
- if (MP3_IsValid(name, pbMP3DataSegment, iInitialMP3ReadSize, qtrue /*bStereoDesired*/))
- {
+ if (MP3_IsValid(name, pbMP3DataSegment, iInitialMP3ReadSize, qtrue /*bStereoDesired*/)) {
// init stream struct...
//
- memset(&pMusicInfo->streamMP3_Bgrnd,0,sizeof(pMusicInfo->streamMP3_Bgrnd));
- char *psError = C_MP3Stream_DecodeInit( &pMusicInfo->streamMP3_Bgrnd, pbMP3DataSegment, pMusicInfo->iLoadedDataLen,
- dma.speed,
- 16, // sfx->width * 8,
- qtrue // bStereoDesired
- );
+ memset(&pMusicInfo->streamMP3_Bgrnd, 0, sizeof(pMusicInfo->streamMP3_Bgrnd));
+ char *psError = C_MP3Stream_DecodeInit(&pMusicInfo->streamMP3_Bgrnd, pbMP3DataSegment, pMusicInfo->iLoadedDataLen, dma.speed,
+ 16, // sfx->width * 8,
+ qtrue // bStereoDesired
+ );
-
- if (psError == NULL)
- {
+ if (psError == NULL) {
// init sfx struct & setup the few fields I actually need...
//
- memset( &pMusicInfo->sfxMP3_Bgrnd,0,sizeof(pMusicInfo->sfxMP3_Bgrnd));
+ memset(&pMusicInfo->sfxMP3_Bgrnd, 0, sizeof(pMusicInfo->sfxMP3_Bgrnd));
// pMusicInfo->sfxMP3_Bgrnd.width = 2; // read by MP3_GetSamples()
- pMusicInfo->sfxMP3_Bgrnd.iSoundLengthInSamples = 0x7FFFFFFF; // max possible +ve int, since music finishes when decoder stops
- pMusicInfo->sfxMP3_Bgrnd.pMP3StreamHeader = &pMusicInfo->streamMP3_Bgrnd;
- Q_strncpyz( pMusicInfo->sfxMP3_Bgrnd.sSoundName, name, sizeof(pMusicInfo->sfxMP3_Bgrnd.sSoundName) );
+ pMusicInfo->sfxMP3_Bgrnd.iSoundLengthInSamples = 0x7FFFFFFF; // max possible +ve int, since music finishes when decoder stops
+ pMusicInfo->sfxMP3_Bgrnd.pMP3StreamHeader = &pMusicInfo->streamMP3_Bgrnd;
+ Q_strncpyz(pMusicInfo->sfxMP3_Bgrnd.sSoundName, name, sizeof(pMusicInfo->sfxMP3_Bgrnd.sSoundName));
- if (qbDynamic)
- {
- MP3Stream_InitPlayingTimeFields ( &pMusicInfo->streamMP3_Bgrnd, name, pbMP3DataSegment, pMusicInfo->iLoadedDataLen, qtrue);
+ if (qbDynamic) {
+ MP3Stream_InitPlayingTimeFields(&pMusicInfo->streamMP3_Bgrnd, name, pbMP3DataSegment, pMusicInfo->iLoadedDataLen, qtrue);
}
- pMusicInfo->s_backgroundInfo.format = WAV_FORMAT_MP3; // not actually used this way, but just ensures we don't match one of the legit formats
- pMusicInfo->s_backgroundInfo.channels = 2; // always, for our MP3s when used for music (else 1 for FX)
- pMusicInfo->s_backgroundInfo.rate = dma.speed;
- pMusicInfo->s_backgroundInfo.width = 2; // always, for our MP3s
- pMusicInfo->s_backgroundInfo.samples = pMusicInfo->sfxMP3_Bgrnd.iSoundLengthInSamples;
- pMusicInfo->s_backgroundSamples = pMusicInfo->sfxMP3_Bgrnd.iSoundLengthInSamples;
+ pMusicInfo->s_backgroundInfo.format = WAV_FORMAT_MP3; // not actually used this way, but just ensures we don't match one of the legit formats
+ pMusicInfo->s_backgroundInfo.channels = 2; // always, for our MP3s when used for music (else 1 for FX)
+ pMusicInfo->s_backgroundInfo.rate = dma.speed;
+ pMusicInfo->s_backgroundInfo.width = 2; // always, for our MP3s
+ pMusicInfo->s_backgroundInfo.samples = pMusicInfo->sfxMP3_Bgrnd.iSoundLengthInSamples;
+ pMusicInfo->s_backgroundSamples = pMusicInfo->sfxMP3_Bgrnd.iSoundLengthInSamples;
- memset(&pMusicInfo->chMP3_Bgrnd,0,sizeof(pMusicInfo->chMP3_Bgrnd));
- pMusicInfo->chMP3_Bgrnd.thesfx = &pMusicInfo->sfxMP3_Bgrnd;
+ memset(&pMusicInfo->chMP3_Bgrnd, 0, sizeof(pMusicInfo->chMP3_Bgrnd));
+ pMusicInfo->chMP3_Bgrnd.thesfx = &pMusicInfo->sfxMP3_Bgrnd;
memcpy(&pMusicInfo->chMP3_Bgrnd.MP3StreamHeader, pMusicInfo->sfxMP3_Bgrnd.pMP3StreamHeader, sizeof(*pMusicInfo->sfxMP3_Bgrnd.pMP3StreamHeader));
- if (qbDynamic)
- {
- if (pMusicInfo->s_backgroundFile != -1)
- {
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
- pMusicInfo->s_backgroundFile = -1; // special mp3 value for "valid, but not a real file"
+ if (qbDynamic) {
+ if (pMusicInfo->s_backgroundFile != -1) {
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
+ pMusicInfo->s_backgroundFile = -1; // special mp3 value for "valid, but not a real file"
}
}
pMusicInfo->bIsMP3 = qtrue;
bMusicSucceeded = qtrue;
- }
- else
- {
- Com_Printf(S_COLOR_RED"Error streaming file %s: %s\n", name, psError);
- if (pMusicInfo->s_backgroundFile != -1)
- {
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
+ } else {
+ Com_Printf(S_COLOR_RED "Error streaming file %s: %s\n", name, psError);
+ if (pMusicInfo->s_backgroundFile != -1) {
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
}
pMusicInfo->s_backgroundFile = 0;
}
- }
- else
- {
+ } else {
// MP3_IsValid() will already have printed any errors via Com_Printf at this point...
//
- if (pMusicInfo->s_backgroundFile != -1)
- {
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
+ if (pMusicInfo->s_backgroundFile != -1) {
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
}
pMusicInfo->s_backgroundFile = 0;
}
return bMusicSucceeded;
- }
- else // not an mp3 file
+ } else // not an mp3 file
{
//
// open up a wav file and get all the info
//
- FS_FOpenFileRead( name, &pMusicInfo->s_backgroundFile, qtrue );
- if ( !pMusicInfo->s_backgroundFile ) {
- Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", name );
+ FS_FOpenFileRead(name, &pMusicInfo->s_backgroundFile, qtrue);
+ if (!pMusicInfo->s_backgroundFile) {
+ Com_Printf(S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", name);
return qfalse;
}
@@ -4243,34 +3755,34 @@ static qboolean S_StartBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolean
FS_Read(dump, 12, pMusicInfo->s_backgroundFile);
- if ( !S_FindWavChunk( pMusicInfo->s_backgroundFile, "fmt " ) ) {
- Com_Printf( S_COLOR_YELLOW "WARNING: No fmt chunk in %s\n", name );
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
+ if (!S_FindWavChunk(pMusicInfo->s_backgroundFile, "fmt ")) {
+ Com_Printf(S_COLOR_YELLOW "WARNING: No fmt chunk in %s\n", name);
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
pMusicInfo->s_backgroundFile = 0;
return qfalse;
}
// save name for soundinfo
- pMusicInfo->s_backgroundInfo.format = FGetLittleShort( pMusicInfo->s_backgroundFile );
- pMusicInfo->s_backgroundInfo.channels = FGetLittleShort( pMusicInfo->s_backgroundFile );
- pMusicInfo->s_backgroundInfo.rate = FGetLittleLong( pMusicInfo->s_backgroundFile );
- FGetLittleLong( pMusicInfo->s_backgroundFile );
- FGetLittleShort( pMusicInfo->s_backgroundFile );
- pMusicInfo->s_backgroundInfo.width = FGetLittleShort( pMusicInfo->s_backgroundFile ) / 8;
-
- if ( pMusicInfo->s_backgroundInfo.format != WAV_FORMAT_PCM ) {
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
+ pMusicInfo->s_backgroundInfo.format = FGetLittleShort(pMusicInfo->s_backgroundFile);
+ pMusicInfo->s_backgroundInfo.channels = FGetLittleShort(pMusicInfo->s_backgroundFile);
+ pMusicInfo->s_backgroundInfo.rate = FGetLittleLong(pMusicInfo->s_backgroundFile);
+ FGetLittleLong(pMusicInfo->s_backgroundFile);
+ FGetLittleShort(pMusicInfo->s_backgroundFile);
+ pMusicInfo->s_backgroundInfo.width = FGetLittleShort(pMusicInfo->s_backgroundFile) / 8;
+
+ if (pMusicInfo->s_backgroundInfo.format != WAV_FORMAT_PCM) {
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
pMusicInfo->s_backgroundFile = 0;
Com_Printf(S_COLOR_YELLOW "WARNING: Not a microsoft PCM format wav: %s\n", name);
return qfalse;
}
- if ( pMusicInfo->s_backgroundInfo.channels != 2 || pMusicInfo->s_backgroundInfo.rate != 22050 ) {
- Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", name );
+ if (pMusicInfo->s_backgroundInfo.channels != 2 || pMusicInfo->s_backgroundInfo.rate != 22050) {
+ Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", name);
}
- if ( ( len = S_FindWavChunk( pMusicInfo->s_backgroundFile, "data" ) ) == 0 ) {
- FS_FCloseFile( pMusicInfo->s_backgroundFile );
+ if ((len = S_FindWavChunk(pMusicInfo->s_backgroundFile, "data")) == 0) {
+ FS_FCloseFile(pMusicInfo->s_backgroundFile);
pMusicInfo->s_backgroundFile = 0;
Com_Printf(S_COLOR_YELLOW "WARNING: No data chunk in %s\n", name);
return qfalse;
@@ -4284,37 +3796,33 @@ static qboolean S_StartBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolean
return qtrue;
}
-
-static void S_SwitchDynamicTracks( MusicState_e eOldState, MusicState_e eNewState, qboolean bNewTrackStartsFullVolume )
-{
+static void S_SwitchDynamicTracks(MusicState_e eOldState, MusicState_e eNewState, qboolean bNewTrackStartsFullVolume) {
// copy old track into fader...
//
- tMusic_Info[ eBGRNDTRACK_FADE ] = tMusic_Info[ eOldState ];
-// tMusic_Info[ eBGRNDTRACK_FADE ].bActive = qtrue; // inherent
-// tMusic_Info[ eBGRNDTRACK_FADE ].bExists = qtrue; // inherent
- tMusic_Info[ eBGRNDTRACK_FADE ].iXFadeVolumeSeekTime= Sys_Milliseconds();
- tMusic_Info[ eBGRNDTRACK_FADE ].iXFadeVolumeSeekTo = 0;
+ tMusic_Info[eBGRNDTRACK_FADE] = tMusic_Info[eOldState];
+ // tMusic_Info[ eBGRNDTRACK_FADE ].bActive = qtrue; // inherent
+ // tMusic_Info[ eBGRNDTRACK_FADE ].bExists = qtrue; // inherent
+ tMusic_Info[eBGRNDTRACK_FADE].iXFadeVolumeSeekTime = Sys_Milliseconds();
+ tMusic_Info[eBGRNDTRACK_FADE].iXFadeVolumeSeekTo = 0;
//
// ... and deactivate...
//
- tMusic_Info[ eOldState ].bActive = qfalse;
+ tMusic_Info[eOldState].bActive = qfalse;
//
// set new track to either full volume or fade up...
//
- tMusic_Info[eNewState].bActive = qtrue;
- tMusic_Info[eNewState].iXFadeVolumeSeekTime = Sys_Milliseconds();
- tMusic_Info[eNewState].iXFadeVolumeSeekTo = 255;
- tMusic_Info[eNewState].iXFadeVolume = bNewTrackStartsFullVolume ? 255 : 0;
+ tMusic_Info[eNewState].bActive = qtrue;
+ tMusic_Info[eNewState].iXFadeVolumeSeekTime = Sys_Milliseconds();
+ tMusic_Info[eNewState].iXFadeVolumeSeekTo = 255;
+ tMusic_Info[eNewState].iXFadeVolume = bNewTrackStartsFullVolume ? 255 : 0;
eMusic_StateActual = eNewState;
+ if (s_debugdynamic->integer) {
+ const char *psNewStateString = Music_BaseStateToString(eNewState, qtrue);
+ psNewStateString = psNewStateString ? psNewStateString : "";
- if (s_debugdynamic->integer)
- {
- const char *psNewStateString = Music_BaseStateToString( eNewState, qtrue );
- psNewStateString = psNewStateString?psNewStateString:"";
-
- Com_Printf( S_COLOR_MAGENTA "S_SwitchDynamicTracks( \"%s\" )\n", psNewStateString );
+ Com_Printf(S_COLOR_MAGENTA "S_SwitchDynamicTracks( \"%s\" )\n", psNewStateString);
}
}
@@ -4323,188 +3831,159 @@ static void S_SwitchDynamicTracks( MusicState_e eOldState, MusicState_e eNewStat
// This either changes the music right now (copying track structures etc), or leaves the new state as pending
// so it gets picked up by the general music player if in a transition that can't be overridden...
//
-static void S_SetDynamicMusicState( MusicState_e eNewState )
-{
- if (eMusic_StateRequest != eNewState)
- {
- eMusic_StateRequest = eNewState;
+static void S_SetDynamicMusicState(MusicState_e eNewState) {
+ if (eMusic_StateRequest != eNewState) {
+ eMusic_StateRequest = eNewState;
- if (s_debugdynamic->integer)
- {
- const char *psNewStateString = Music_BaseStateToString( eNewState, qtrue );
- psNewStateString = psNewStateString?psNewStateString:"";
+ if (s_debugdynamic->integer) {
+ const char *psNewStateString = Music_BaseStateToString(eNewState, qtrue);
+ psNewStateString = psNewStateString ? psNewStateString : "";
- Com_Printf( S_COLOR_MAGENTA "S_SetDynamicMusicState( Request: \"%s\" )\n", psNewStateString );
+ Com_Printf(S_COLOR_MAGENTA "S_SetDynamicMusicState( Request: \"%s\" )\n", psNewStateString);
}
}
}
-
-static void S_HandleDynamicMusicStateChange( void )
-{
- if (eMusic_StateRequest != eMusic_StateActual)
- {
+static void S_HandleDynamicMusicStateChange(void) {
+ if (eMusic_StateRequest != eMusic_StateActual) {
// check whether or not the new request can be honoured, given what's currently playing...
//
- if (Music_StateCanBeInterrupted( eMusic_StateActual, eMusic_StateRequest ))
- {
- LP_MP3STREAM pMP3StreamActual = &tMusic_Info[ eMusic_StateActual ].chMP3_Bgrnd.MP3StreamHeader;
+ if (Music_StateCanBeInterrupted(eMusic_StateActual, eMusic_StateRequest)) {
+ LP_MP3STREAM pMP3StreamActual = &tMusic_Info[eMusic_StateActual].chMP3_Bgrnd.MP3StreamHeader;
- switch (eMusic_StateRequest)
+ switch (eMusic_StateRequest) {
+ case eBGRNDTRACK_EXPLORE: // ... from action or silence
{
- case eBGRNDTRACK_EXPLORE: // ... from action or silence
+ switch (eMusic_StateActual) {
+ case eBGRNDTRACK_ACTION: // action->explore
{
- switch (eMusic_StateActual)
- {
- case eBGRNDTRACK_ACTION: // action->explore
- {
- // find the transition track to play, and the entry point for explore when we get there,
- // and also see if we're at a permitted exit point to switch at all...
- //
- float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds( pMP3StreamActual ) - MP3Stream_GetRemainingTimeInSeconds( pMP3StreamActual );
-
- // supply:
- //
- // playing point in float seconds
- // enum of track being queried
- //
- // get:
- //
- // enum of transition track to switch to
- // float time of entry point of new track *after* transition
-
- MusicState_e eTransition;
- float fNewTrackEntryTime = 0.0f;
- if (Music_AllowedToTransition( fPlayingTimeElapsed, eBGRNDTRACK_ACTION, &eTransition, &fNewTrackEntryTime))
- {
- S_SwitchDynamicTracks( eMusic_StateActual, eTransition, qfalse ); // qboolean bNewTrackStartsFullVolume
+ // find the transition track to play, and the entry point for explore when we get there,
+ // and also see if we're at a permitted exit point to switch at all...
+ //
+ float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds(pMP3StreamActual) - MP3Stream_GetRemainingTimeInSeconds(pMP3StreamActual);
- tMusic_Info[eTransition].Rewind();
- tMusic_Info[eTransition].bTrackSwitchPending = qtrue;
- tMusic_Info[eTransition].eTS_NewState = eMusic_StateRequest;
- tMusic_Info[eTransition].fTS_NewTime = fNewTrackEntryTime;
- }
- }
- break;
+ // supply:
+ //
+ // playing point in float seconds
+ // enum of track being queried
+ //
+ // get:
+ //
+ // enum of transition track to switch to
+ // float time of entry point of new track *after* transition
+
+ MusicState_e eTransition;
+ float fNewTrackEntryTime = 0.0f;
+ if (Music_AllowedToTransition(fPlayingTimeElapsed, eBGRNDTRACK_ACTION, &eTransition, &fNewTrackEntryTime)) {
+ S_SwitchDynamicTracks(eMusic_StateActual, eTransition, qfalse); // qboolean bNewTrackStartsFullVolume
+
+ tMusic_Info[eTransition].Rewind();
+ tMusic_Info[eTransition].bTrackSwitchPending = qtrue;
+ tMusic_Info[eTransition].eTS_NewState = eMusic_StateRequest;
+ tMusic_Info[eTransition].fTS_NewTime = fNewTrackEntryTime;
+ }
+ } break;
- case eBGRNDTRACK_SILENCE: // silence->explore
- {
- S_SwitchDynamicTracks( eMusic_StateActual, eMusic_StateRequest, qfalse ); // qboolean bNewTrackStartsFullVolume
+ case eBGRNDTRACK_SILENCE: // silence->explore
+ {
+ S_SwitchDynamicTracks(eMusic_StateActual, eMusic_StateRequest, qfalse); // qboolean bNewTrackStartsFullVolume
-// float fEntryTime = Music_GetRandomEntryTime( eMusic_StateRequest );
-// tMusic_Info[ eMusic_StateRequest ].SeekTo(fEntryTime);
- tMusic_Info[ eMusic_StateRequest ].Rewind();
- }
- break;
+ // float fEntryTime = Music_GetRandomEntryTime( eMusic_StateRequest );
+ // tMusic_Info[ eMusic_StateRequest ].SeekTo(fEntryTime);
+ tMusic_Info[eMusic_StateRequest].Rewind();
+ } break;
- default: // trying to transition from some state I wasn't aware you could transition from (shouldn't happen), so ignore
- {
- assert(0);
- S_SwitchDynamicTracks( eMusic_StateActual, eBGRNDTRACK_SILENCE, qfalse ); // qboolean bNewTrackStartsFullVolume
- }
- break;
- }
+ default: // trying to transition from some state I wasn't aware you could transition from (shouldn't happen), so ignore
+ {
+ assert(0);
+ S_SwitchDynamicTracks(eMusic_StateActual, eBGRNDTRACK_SILENCE, qfalse); // qboolean bNewTrackStartsFullVolume
+ } break;
}
- break;
+ } break;
- case eBGRNDTRACK_SILENCE: // from explore or action
+ case eBGRNDTRACK_SILENCE: // from explore or action
+ {
+ switch (eMusic_StateActual) {
+ case eBGRNDTRACK_ACTION: // action->silence
+ case eBGRNDTRACK_EXPLORE: // explore->silence
{
- switch (eMusic_StateActual)
- {
- case eBGRNDTRACK_ACTION: // action->silence
- case eBGRNDTRACK_EXPLORE: // explore->silence
- {
- // find the transition track to play, and the entry point for explore when we get there,
- // and also see if we're at a permitted exit point to switch at all...
- //
- float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds( pMP3StreamActual ) - MP3Stream_GetRemainingTimeInSeconds( pMP3StreamActual );
-
- MusicState_e eTransition;
- float fNewTrackEntryTime = 0.0f;
- if (Music_AllowedToTransition( fPlayingTimeElapsed, eMusic_StateActual, &eTransition, &fNewTrackEntryTime))
- {
- S_SwitchDynamicTracks( eMusic_StateActual, eTransition, qfalse ); // qboolean bNewTrackStartsFullVolume
-
- tMusic_Info[eTransition].Rewind();
- tMusic_Info[eTransition].bTrackSwitchPending = qtrue;
- tMusic_Info[eTransition].eTS_NewState = eMusic_StateRequest;
- tMusic_Info[eTransition].fTS_NewTime = 0.0f; //fNewTrackEntryTime; irrelevant when switching to silence
- }
- }
- break;
+ // find the transition track to play, and the entry point for explore when we get there,
+ // and also see if we're at a permitted exit point to switch at all...
+ //
+ float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds(pMP3StreamActual) - MP3Stream_GetRemainingTimeInSeconds(pMP3StreamActual);
- default: // some unhandled type switching to silence
- assert(0); // fall through since boss case just does silence->switch anyway
+ MusicState_e eTransition;
+ float fNewTrackEntryTime = 0.0f;
+ if (Music_AllowedToTransition(fPlayingTimeElapsed, eMusic_StateActual, &eTransition, &fNewTrackEntryTime)) {
+ S_SwitchDynamicTracks(eMusic_StateActual, eTransition, qfalse); // qboolean bNewTrackStartsFullVolume
- case eBGRNDTRACK_BOSS: // boss->silence
- {
- S_SwitchDynamicTracks( eMusic_StateActual, eBGRNDTRACK_SILENCE, qfalse ); // qboolean bNewTrackStartsFullVolume
- }
- break;
+ tMusic_Info[eTransition].Rewind();
+ tMusic_Info[eTransition].bTrackSwitchPending = qtrue;
+ tMusic_Info[eTransition].eTS_NewState = eMusic_StateRequest;
+ tMusic_Info[eTransition].fTS_NewTime = 0.0f; // fNewTrackEntryTime; irrelevant when switching to silence
}
- }
- break;
+ } break;
- case eBGRNDTRACK_ACTION: // anything->action
- {
- switch (eMusic_StateActual)
- {
- case eBGRNDTRACK_SILENCE: // silence->action
- {
- S_SwitchDynamicTracks( eMusic_StateActual, eMusic_StateRequest, qfalse ); // qboolean bNewTrackStartsFullVolume
- tMusic_Info[ eMusic_StateRequest ].Rewind();
- }
- break;
+ default: // some unhandled type switching to silence
+ assert(0); // fall through since boss case just does silence->switch anyway
- default: // !silence->action
- {
- S_SwitchDynamicTracks( eMusic_StateActual, eMusic_StateRequest, qtrue ); // qboolean bNewTrackStartsFullVolume
- float fEntryTime = Music_GetRandomEntryTime( eMusic_StateRequest );
- tMusic_Info[ eMusic_StateRequest ].SeekTo(fEntryTime);
- }
- break;
- }
+ case eBGRNDTRACK_BOSS: // boss->silence
+ {
+ S_SwitchDynamicTracks(eMusic_StateActual, eBGRNDTRACK_SILENCE, qfalse); // qboolean bNewTrackStartsFullVolume
+ } break;
}
- break;
+ } break;
- case eBGRNDTRACK_BOSS:
+ case eBGRNDTRACK_ACTION: // anything->action
+ {
+ switch (eMusic_StateActual) {
+ case eBGRNDTRACK_SILENCE: // silence->action
{
- S_SwitchDynamicTracks( eMusic_StateActual, eMusic_StateRequest, qfalse ); // qboolean bNewTrackStartsFullVolume
- //
- // ( no need to fast forward or rewind, boss track is only entered into once, at start, and can't exit )
- //
- }
- break;
+ S_SwitchDynamicTracks(eMusic_StateActual, eMusic_StateRequest, qfalse); // qboolean bNewTrackStartsFullVolume
+ tMusic_Info[eMusic_StateRequest].Rewind();
+ } break;
- case eBGRNDTRACK_DEATH:
+ default: // !silence->action
{
- S_SwitchDynamicTracks( eMusic_StateActual, eMusic_StateRequest, qtrue ); // qboolean bNewTrackStartsFullVolume
- //
- // ( no need to fast forward or rewind, death track is only entered into once, at start, and can't exit or loop)
- //
+ S_SwitchDynamicTracks(eMusic_StateActual, eMusic_StateRequest, qtrue); // qboolean bNewTrackStartsFullVolume
+ float fEntryTime = Music_GetRandomEntryTime(eMusic_StateRequest);
+ tMusic_Info[eMusic_StateRequest].SeekTo(fEntryTime);
+ } break;
}
- break;
+ } break;
+
+ case eBGRNDTRACK_BOSS: {
+ S_SwitchDynamicTracks(eMusic_StateActual, eMusic_StateRequest, qfalse); // qboolean bNewTrackStartsFullVolume
+ //
+ // ( no need to fast forward or rewind, boss track is only entered into once, at start, and can't exit )
+ //
+ } break;
+
+ case eBGRNDTRACK_DEATH: {
+ S_SwitchDynamicTracks(eMusic_StateActual, eMusic_StateRequest, qtrue); // qboolean bNewTrackStartsFullVolume
+ //
+ // ( no need to fast forward or rewind, death track is only entered into once, at start, and can't exit or loop)
+ //
+ } break;
- default: assert(0); break; // unknown new mode request, so just ignore it
+ default:
+ assert(0);
+ break; // unknown new mode request, so just ignore it
}
}
}
}
+static char gsIntroMusic[MAX_QPATH] = {0};
+static char gsLoopMusic[MAX_QPATH] = {0};
-
-static char gsIntroMusic[MAX_QPATH]={0};
-static char gsLoopMusic [MAX_QPATH]={0};
-
-void S_RestartMusic( void )
-{
- if (s_soundStarted && !s_soundMuted )
- {
- //if (gsIntroMusic[0] || gsLoopMusic[0]) // dont test this anymore (but still *use* them), they're blank for JK2 dynamic-music levels anyway
+void S_RestartMusic(void) {
+ if (s_soundStarted && !s_soundMuted) {
+ // if (gsIntroMusic[0] || gsLoopMusic[0]) // dont test this anymore (but still *use* them), they're blank for JK2 dynamic-music levels anyway
{
- MusicState_e ePrevState = eMusic_StateRequest;
- S_StartBackgroundTrack( gsIntroMusic, gsLoopMusic, qfalse ); // ( default music start will set the state to EXPLORE )
- S_SetDynamicMusicState( ePrevState ); // restore to prev state
+ MusicState_e ePrevState = eMusic_StateRequest;
+ S_StartBackgroundTrack(gsIntroMusic, gsLoopMusic, qfalse); // ( default music start will set the state to EXPLORE )
+ S_SetDynamicMusicState(ePrevState); // restore to prev state
}
}
}
@@ -4516,94 +3995,83 @@ void S_RestartMusic( void )
// to be honest, although the code still plays WAVs some of the file-check logic only works for MP3s, so if you ever want
// to use WAV music you'll have to do some tweaking below (but I've got other things to do so it'll have to wait - Ste)
//
-void S_StartBackgroundTrack( const char *intro, const char *loop, qboolean bCalledByCGameStart )
-{
+void S_StartBackgroundTrack(const char *intro, const char *loop, qboolean bCalledByCGameStart) {
bMusic_IsDynamic = qfalse;
- if (!s_soundStarted)
- { //we have no sound, so don't even bother trying
+ if (!s_soundStarted) { // we have no sound, so don't even bother trying
return;
}
- if ( !intro ) {
+ if (!intro) {
intro = "";
}
- if ( !loop || !loop[0] ) {
+ if (!loop || !loop[0]) {
loop = intro;
}
- if ( intro != gsIntroMusic ) {
- Q_strncpyz( gsIntroMusic, intro, sizeof(gsIntroMusic) );
+ if (intro != gsIntroMusic) {
+ Q_strncpyz(gsIntroMusic, intro, sizeof(gsIntroMusic));
}
- if ( loop != gsLoopMusic ) {
- Q_strncpyz( gsLoopMusic, loop, sizeof(gsLoopMusic) );
+ if (loop != gsLoopMusic) {
+ Q_strncpyz(gsLoopMusic, loop, sizeof(gsLoopMusic));
}
char sNameIntro[MAX_QPATH];
- char sNameLoop [MAX_QPATH];
- Q_strncpyz(sNameIntro, intro, sizeof(sNameIntro));
- Q_strncpyz(sNameLoop, loop, sizeof(sNameLoop));
+ char sNameLoop[MAX_QPATH];
+ Q_strncpyz(sNameIntro, intro, sizeof(sNameIntro));
+ Q_strncpyz(sNameLoop, loop, sizeof(sNameLoop));
- COM_DefaultExtension( sNameIntro, sizeof( sNameIntro ), ".mp3" );
- COM_DefaultExtension( sNameLoop, sizeof( sNameLoop), ".mp3" );
+ COM_DefaultExtension(sNameIntro, sizeof(sNameIntro), ".mp3");
+ COM_DefaultExtension(sNameLoop, sizeof(sNameLoop), ".mp3");
// if dynamic music not allowed, then just stream the explore music instead of playing dynamic...
//
- if (!s_allowDynamicMusic->integer && Music_DynamicDataAvailable(intro)) // "intro", NOT "sName" (i.e. don't use version with ".mp3" extension)
+ if (!s_allowDynamicMusic->integer && Music_DynamicDataAvailable(intro)) // "intro", NOT "sName" (i.e. don't use version with ".mp3" extension)
{
- const char *psMusicName = Music_GetFileNameForState( eBGRNDTRACK_DATABEGIN );
- if (psMusicName && S_FileExists( psMusicName ))
- {
- Q_strncpyz(sNameIntro,psMusicName,sizeof(sNameIntro));
- Q_strncpyz(sNameLoop, psMusicName,sizeof(sNameLoop ));
+ const char *psMusicName = Music_GetFileNameForState(eBGRNDTRACK_DATABEGIN);
+ if (psMusicName && S_FileExists(psMusicName)) {
+ Q_strncpyz(sNameIntro, psMusicName, sizeof(sNameIntro));
+ Q_strncpyz(sNameLoop, psMusicName, sizeof(sNameLoop));
}
}
// conceptually we always play the 'intro'[/sName] track, intro-to-loop transition is handled in UpdateBackGroundTrack().
//
- if ( (strstr(sNameIntro,"/") && S_FileExists( sNameIntro )) ) // strstr() check avoids extra file-exists check at runtime if reverting from streamed music to dynamic since literal files all need at least one slash in their name (eg "music/blah")
+ if ((strstr(sNameIntro, "/") && S_FileExists(sNameIntro))) // strstr() check avoids extra file-exists check at runtime if reverting from streamed music to
+ // dynamic since literal files all need at least one slash in their name (eg "music/blah")
{
- const char *psLoopName = S_FileExists( sNameLoop ) ? sNameLoop : sNameIntro;
+ const char *psLoopName = S_FileExists(sNameLoop) ? sNameLoop : sNameIntro;
Com_DPrintf("S_StartBackgroundTrack: Found/using non-dynamic music track '%s' (loop: '%s')\n", sNameIntro, psLoopName);
- S_StartBackgroundTrack_Actual( &tMusic_Info[eBGRNDTRACK_NONDYNAMIC], bMusic_IsDynamic, sNameIntro, psLoopName );
- }
- else
- {
- if (Music_DynamicDataAvailable(intro)) // "intro", NOT "sName" (i.e. don't use version with ".mp3" extension)
+ S_StartBackgroundTrack_Actual(&tMusic_Info[eBGRNDTRACK_NONDYNAMIC], bMusic_IsDynamic, sNameIntro, psLoopName);
+ } else {
+ if (Music_DynamicDataAvailable(intro)) // "intro", NOT "sName" (i.e. don't use version with ".mp3" extension)
{
extern const char *Music_GetLevelSetName(void);
Q_strncpyz(sInfoOnly_CurrentDynamicMusicSet, Music_GetLevelSetName(), sizeof(sInfoOnly_CurrentDynamicMusicSet));
- for (int i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++)
- {
+ for (int i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++) {
qboolean bOk = qfalse;
- const char *psMusicName = Music_GetFileNameForState( (MusicState_e) i);
- if (psMusicName && (!Q_stricmp(tMusic_Info[i].sLoadedDataName, psMusicName) || S_FileExists( psMusicName )) )
- {
- bOk = S_StartBackgroundTrack_Actual( &tMusic_Info[i], qtrue, psMusicName, loop );
+ const char *psMusicName = Music_GetFileNameForState((MusicState_e)i);
+ if (psMusicName && (!Q_stricmp(tMusic_Info[i].sLoadedDataName, psMusicName) || S_FileExists(psMusicName))) {
+ bOk = S_StartBackgroundTrack_Actual(&tMusic_Info[i], qtrue, psMusicName, loop);
}
tMusic_Info[i].bExists = bOk;
- if (!tMusic_Info[i].bExists)
- {
- FreeMusic( &tMusic_Info[i] );
+ if (!tMusic_Info[i].bExists) {
+ FreeMusic(&tMusic_Info[i]);
}
}
//
// default all tracks to OFF first (and set any other vars)
//
- for (int i = 0; ibActive = qtrue;
- pMusicInfo->iXFadeVolumeSeekTime= Sys_Milliseconds();
- pMusicInfo->iXFadeVolumeSeekTo = 255;
- pMusicInfo->iXFadeVolume = 0;
+ pMusicInfo->bActive = qtrue;
+ pMusicInfo->iXFadeVolumeSeekTime = Sys_Milliseconds();
+ pMusicInfo->iXFadeVolumeSeekTo = 255;
+ pMusicInfo->iXFadeVolume = 0;
- //#ifdef _DEBUG
- // float fRemaining = MP3Stream_GetPlayingTimeInSeconds( &pMusicInfo->chMP3_Bgrnd.MP3StreamHeader);
- //#endif
- }
- else
- {
- Com_Printf( S_COLOR_RED "Dynamic music did not have both 'action' and 'explore' versions, inhibiting...\n");
+ //#ifdef _DEBUG
+ // float fRemaining = MP3Stream_GetPlayingTimeInSeconds( &pMusicInfo->chMP3_Bgrnd.MP3StreamHeader);
+ //#endif
+ } else {
+ Com_Printf(S_COLOR_RED "Dynamic music did not have both 'action' and 'explore' versions, inhibiting...\n");
S_StopBackgroundTrack();
}
- }
- else
- {
- if (sNameIntro[0]!='.') // blank name with ".mp3" or whatever attached - no error print out
+ } else {
+ if (sNameIntro[0] != '.') // blank name with ".mp3" or whatever attached - no error print out
{
- Com_Printf( S_COLOR_RED "Unable to find music \"%s\" as explicit track or dynamic music entry!\n",sNameIntro);
+ Com_Printf(S_COLOR_RED "Unable to find music \"%s\" as explicit track or dynamic music entry!\n", sNameIntro);
S_StopBackgroundTrack();
}
}
}
- if (bCalledByCGameStart)
- {
+ if (bCalledByCGameStart) {
S_StopBackgroundTrack();
}
}
-void S_StopBackgroundTrack( void )
-{
- for (int i=0; ivalue;
- if (bMusic_IsDynamic)
- {
+ if (bMusic_IsDynamic) {
// step xfade volume...
//
- if ( pMusicInfo->iXFadeVolume != pMusicInfo->iXFadeVolumeSeekTo )
- {
+ if (pMusicInfo->iXFadeVolume != pMusicInfo->iXFadeVolumeSeekTo) {
int iFadeMillisecondsElapsed = Sys_Milliseconds() - pMusicInfo->iXFadeVolumeSeekTime;
- if (iFadeMillisecondsElapsed > (fDYNAMIC_XFADE_SECONDS * 1000))
- {
+ if (iFadeMillisecondsElapsed > (fDYNAMIC_XFADE_SECONDS * 1000)) {
pMusicInfo->iXFadeVolume = pMusicInfo->iXFadeVolumeSeekTo;
- }
- else
- {
- pMusicInfo->iXFadeVolume = (int) (255.0f * ((float)iFadeMillisecondsElapsed/(fDYNAMIC_XFADE_SECONDS * 1000.0f)));
- if (pMusicInfo->iXFadeVolumeSeekTo == 0) // bleurgh
+ } else {
+ pMusicInfo->iXFadeVolume = (int)(255.0f * ((float)iFadeMillisecondsElapsed / (fDYNAMIC_XFADE_SECONDS * 1000.0f)));
+ if (pMusicInfo->iXFadeVolumeSeekTo == 0) // bleurgh
pMusicInfo->iXFadeVolume = 255 - pMusicInfo->iXFadeVolume;
}
}
@@ -4697,27 +4150,26 @@ static qboolean S_UpdateBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolea
// normal sfx buffer painting, and allowing sufficient sliding room, even though the music file never goes back in time.
//
#define SIZEOF_RAW_BUFFER_FOR_MP3 4096
-#define RAWSIZE (pMusicInfo->bIsMP3?SIZEOF_RAW_BUFFER_FOR_MP3:sizeof(raw))
+#define RAWSIZE (pMusicInfo->bIsMP3 ? SIZEOF_RAW_BUFFER_FOR_MP3 : sizeof(raw))
- if ( !pMusicInfo->s_backgroundFile ) {
+ if (!pMusicInfo->s_backgroundFile) {
return qfalse;
}
- pMusicInfo->fSmoothedOutVolume = (pMusicInfo->fSmoothedOutVolume + fMasterVol)/2.0f;
-// OutputDebugString(va("%f\n",pMusicInfo->fSmoothedOutVolume));
+ pMusicInfo->fSmoothedOutVolume = (pMusicInfo->fSmoothedOutVolume + fMasterVol) / 2.0f;
+ // OutputDebugString(va("%f\n",pMusicInfo->fSmoothedOutVolume));
// don't bother playing anything if musicvolume is 0
- if ( pMusicInfo->fSmoothedOutVolume <= 0 ) {
+ if (pMusicInfo->fSmoothedOutVolume <= 0) {
return qfalse;
}
// see how many samples should be copied into the raw buffer
- if ( s_rawend < s_soundtime ) {
+ if (s_rawend < s_soundtime) {
s_rawend = s_soundtime;
}
- while ( s_rawend < s_soundtime + MAX_RAW_SAMPLES )
- {
+ while (s_rawend < s_soundtime + MAX_RAW_SAMPLES) {
bufferSamples = MAX_RAW_SAMPLES - (s_rawend - s_soundtime);
// decide how much data needs to be read from the file
@@ -4729,34 +4181,30 @@ static qboolean S_UpdateBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolea
}
// don't try and read past the end of the file
- if ( fileSamples > pMusicInfo->s_backgroundSamples ) {
+ if (fileSamples > pMusicInfo->s_backgroundSamples) {
fileSamples = pMusicInfo->s_backgroundSamples;
}
// our max buffer size
fileBytes = fileSamples * (pMusicInfo->s_backgroundInfo.width * pMusicInfo->s_backgroundInfo.channels);
- if ((unsigned)fileBytes > RAWSIZE ) {
+ if ((unsigned)fileBytes > RAWSIZE) {
fileBytes = RAWSIZE;
fileSamples = fileBytes / (pMusicInfo->s_backgroundInfo.width * pMusicInfo->s_backgroundInfo.channels);
}
qboolean qbForceFinish = qfalse;
- if (pMusicInfo->bIsMP3)
- {
- int iStartingSampleNum = pMusicInfo->chMP3_Bgrnd.thesfx->iSoundLengthInSamples - pMusicInfo->s_backgroundSamples; // but this IS relevant
+ if (pMusicInfo->bIsMP3) {
+ int iStartingSampleNum = pMusicInfo->chMP3_Bgrnd.thesfx->iSoundLengthInSamples - pMusicInfo->s_backgroundSamples; // but this IS relevant
// Com_Printf(S_COLOR_YELLOW "Requesting MP3 samples: sample %d\n",iStartingSampleNum);
-
- if (pMusicInfo->s_backgroundFile == -1)
- {
+ if (pMusicInfo->s_backgroundFile == -1) {
// in-mem...
//
- qbForceFinish = (MP3Stream_GetSamples( &pMusicInfo->chMP3_Bgrnd, iStartingSampleNum, fileBytes/2, (short*) raw, qtrue ))?qfalse:qtrue;
+ qbForceFinish = (MP3Stream_GetSamples(&pMusicInfo->chMP3_Bgrnd, iStartingSampleNum, fileBytes / 2, (short *)raw, qtrue)) ? qfalse : qtrue;
- //Com_Printf(S_COLOR_YELLOW "Music time remaining: %f seconds\n", MP3Stream_GetRemainingTimeInSeconds( &pMusicInfo->chMP3_Bgrnd.MP3StreamHeader ));
- }
- else
- {
+ // Com_Printf(S_COLOR_YELLOW "Music time remaining: %f seconds\n", MP3Stream_GetRemainingTimeInSeconds( &pMusicInfo->chMP3_Bgrnd.MP3StreamHeader
+ // ));
+ } else {
// streaming an MP3 file instead... (note that the 'fileBytes' request size isn't that relevant for MP3s,
// since code here can't know how much the MP3 needs to decompress)
//
@@ -4764,67 +4212,56 @@ static qboolean S_UpdateBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolea
pMusicInfo->chMP3_Bgrnd.MP3StreamHeader.pbSourceData = pbScrolledStreamData - pMusicInfo->chMP3_Bgrnd.MP3StreamHeader.iSourceReadIndex;
- qbForceFinish = (MP3Stream_GetSamples( &pMusicInfo->chMP3_Bgrnd, iStartingSampleNum, fileBytes/2, (short*) raw, qtrue ))?qfalse:qtrue;
+ qbForceFinish = (MP3Stream_GetSamples(&pMusicInfo->chMP3_Bgrnd, iStartingSampleNum, fileBytes / 2, (short *)raw, qtrue)) ? qfalse : qtrue;
}
- }
- else
- {
+ } else {
// streaming a WAV off disk...
//
- r = FS_Read( raw, fileBytes, pMusicInfo->s_backgroundFile );
- if ( r != fileBytes ) {
- Com_Printf(S_COLOR_RED"StreamedRead failure on music track\n");
+ r = FS_Read(raw, fileBytes, pMusicInfo->s_backgroundFile);
+ if (r != fileBytes) {
+ Com_Printf(S_COLOR_RED "StreamedRead failure on music track\n");
S_StopBackgroundTrack();
return qfalse;
}
// byte swap if needed (do NOT do for MP3 decoder, that has an internal big/little endian handler)
//
- S_ByteSwapRawSamples( fileSamples, pMusicInfo->s_backgroundInfo.width, pMusicInfo->s_backgroundInfo.channels, raw );
+ S_ByteSwapRawSamples(fileSamples, pMusicInfo->s_backgroundInfo.width, pMusicInfo->s_backgroundInfo.channels, raw);
}
// add to raw buffer
- S_RawSamples( fileSamples, pMusicInfo->s_backgroundInfo.rate,
- pMusicInfo->s_backgroundInfo.width, pMusicInfo->s_backgroundInfo.channels, raw, pMusicInfo->fSmoothedOutVolume,
- bFirstOrOnlyMusicTrack
- );
+ S_RawSamples(fileSamples, pMusicInfo->s_backgroundInfo.rate, pMusicInfo->s_backgroundInfo.width, pMusicInfo->s_backgroundInfo.channels, raw,
+ pMusicInfo->fSmoothedOutVolume, bFirstOrOnlyMusicTrack);
pMusicInfo->s_backgroundSamples -= fileSamples;
- if ( !pMusicInfo->s_backgroundSamples || qbForceFinish )
- {
+ if (!pMusicInfo->s_backgroundSamples || qbForceFinish) {
// loop the music, or play the next piece if we were on the intro...
// (but not for dynamic, that can only be used for loop music)
//
- if (bMusic_IsDynamic) // needs special logic for this, different call
+ if (bMusic_IsDynamic) // needs special logic for this, different call
{
pMusicInfo->Rewind();
- }
- else
- {
+ } else {
// for non-dynamic music we need to check if "sMusic_BackgroundLoop" is an actual filename,
// or if it's a dynamic music specifier (which can't literally exist), in which case it should set
// a return flag then exit...
//
- char sTestName[MAX_QPATH*2];// *2 so COM_DefaultExtension doesn't do an ERR_DROP if there was no space
- // for an extension, since this is a "soft" test
- Q_strncpyz( sTestName, sMusic_BackgroundLoop, sizeof(sTestName));
+ char sTestName[MAX_QPATH * 2]; // *2 so COM_DefaultExtension doesn't do an ERR_DROP if there was no space
+ // for an extension, since this is a "soft" test
+ Q_strncpyz(sTestName, sMusic_BackgroundLoop, sizeof(sTestName));
COM_DefaultExtension(sTestName, sizeof(sTestName), ".mp3");
- if (S_FileExists( sTestName ))
- {
- S_StartBackgroundTrack_Actual( pMusicInfo, qfalse, sMusic_BackgroundLoop, sMusic_BackgroundLoop );
- }
- else
- {
+ if (S_FileExists(sTestName)) {
+ S_StartBackgroundTrack_Actual(pMusicInfo, qfalse, sMusic_BackgroundLoop, sMusic_BackgroundLoop);
+ } else {
// proposed file doesn't exist, but this may be a dynamic track we're wanting to loop,
// so exit with a special flag...
//
return qtrue;
}
}
- if ( !pMusicInfo->s_backgroundFile )
- {
- return qfalse; // loop failed to restart
+ if (!pMusicInfo->s_backgroundFile) {
+ return qfalse; // loop failed to restart
}
}
}
@@ -4835,15 +4272,12 @@ static qboolean S_UpdateBackgroundTrack_Actual( MusicInfo_t *pMusicInfo, qboolea
return qfalse;
}
-
// used to be just for dynamic, but now even non-dynamic music has to know whether it should be silent or not...
//
-static const char *S_Music_GetRequestedState(void)
-{
+static const char *S_Music_GetRequestedState(void) {
int iStringOffset = cl.gameState.stringOffsets[CS_DYNAMIC_MUSIC_STATE];
- if (iStringOffset)
- {
- const char *psCommand = cl.gameState.stringData+iStringOffset;
+ if (iStringOffset) {
+ const char *psCommand = cl.gameState.stringData + iStringOffset;
return psCommand;
}
@@ -4851,235 +4285,189 @@ static const char *S_Music_GetRequestedState(void)
return NULL;
}
-
// scan the configstring to see if there's been a state-change requested...
// (note that even if the state doesn't change it still gets here, so do a same-state check for applying)
//
// then go on to do transition handling etc...
//
-static void S_CheckDynamicMusicState(void)
-{
+static void S_CheckDynamicMusicState(void) {
const char *psCommand = S_Music_GetRequestedState();
- if (psCommand)
- {
+ if (psCommand) {
MusicState_e eNewState;
- if ( !Q_stricmpn( psCommand, "silence", 7) )
- {
+ if (!Q_stricmpn(psCommand, "silence", 7)) {
eNewState = eBGRNDTRACK_SILENCE;
- }
- else if ( !Q_stricmpn( psCommand, "action", 6) )
- {
+ } else if (!Q_stricmpn(psCommand, "action", 6)) {
eNewState = eBGRNDTRACK_ACTION;
- }
- else if ( !Q_stricmpn( psCommand, "boss", 4) )
- {
+ } else if (!Q_stricmpn(psCommand, "boss", 4)) {
// special case, boss music is optional and may not be defined...
//
- if (tMusic_Info[ eBGRNDTRACK_BOSS ].bExists)
- {
+ if (tMusic_Info[eBGRNDTRACK_BOSS].bExists) {
eNewState = eBGRNDTRACK_BOSS;
- }
- else
- {
+ } else {
// ( leave it playing current track )
//
eNewState = eMusic_StateActual;
}
- }
- else if ( !Q_stricmpn( psCommand, "death", 5) )
- {
+ } else if (!Q_stricmpn(psCommand, "death", 5)) {
// special case, death music is optional and may not be defined...
//
- if (tMusic_Info[ eBGRNDTRACK_DEATH ].bExists)
- {
+ if (tMusic_Info[eBGRNDTRACK_DEATH].bExists) {
eNewState = eBGRNDTRACK_DEATH;
- }
- else
- {
+ } else {
// ( leave it playing current track, typically either boss or action )
//
eNewState = eMusic_StateActual;
}
- }
- else
- {
+ } else {
// seems a reasonable default...
//
eNewState = eBGRNDTRACK_EXPLORE;
}
- S_SetDynamicMusicState( eNewState );
+ S_SetDynamicMusicState(eNewState);
}
S_HandleDynamicMusicStateChange();
}
-static void S_UpdateBackgroundTrack( void )
-{
- if (bMusic_IsDynamic)
- {
- if (s_debugdynamic->integer == 2)
- {
+static void S_UpdateBackgroundTrack(void) {
+ if (bMusic_IsDynamic) {
+ if (s_debugdynamic->integer == 2) {
DynamicMusicInfoPrint();
}
S_CheckDynamicMusicState();
- if (eMusic_StateActual != eBGRNDTRACK_SILENCE)
- {
- MusicInfo_t *pMusicInfoCurrent = &tMusic_Info[ (eMusic_StateActual == eBGRNDTRACK_FADE)?eBGRNDTRACK_EXPLORE:eMusic_StateActual ];
- MusicInfo_t *pMusicInfoFadeOut = &tMusic_Info[ eBGRNDTRACK_FADE ];
+ if (eMusic_StateActual != eBGRNDTRACK_SILENCE) {
+ MusicInfo_t *pMusicInfoCurrent = &tMusic_Info[(eMusic_StateActual == eBGRNDTRACK_FADE) ? eBGRNDTRACK_EXPLORE : eMusic_StateActual];
+ MusicInfo_t *pMusicInfoFadeOut = &tMusic_Info[eBGRNDTRACK_FADE];
- if ( pMusicInfoCurrent->s_backgroundFile == -1)
- {
+ if (pMusicInfoCurrent->s_backgroundFile == -1) {
int iRawEnd = s_rawend;
- S_UpdateBackgroundTrack_Actual( pMusicInfoCurrent, qtrue, s_musicVolume->value );
+ S_UpdateBackgroundTrack_Actual(pMusicInfoCurrent, qtrue, s_musicVolume->value);
- /* static int iPrevFrontVol = 0;
- if (iPrevFrontVol != pMusicInfoCurrent->iXFadeVolume)
- {
- iPrevFrontVol = pMusicInfoCurrent->iXFadeVolume;
- Com_Printf("front vol = %d\n",pMusicInfoCurrent->iXFadeVolume);
- }
- */
- if (pMusicInfoFadeOut->bActive)
- {
+ /* static int iPrevFrontVol = 0;
+ if (iPrevFrontVol != pMusicInfoCurrent->iXFadeVolume)
+ {
+ iPrevFrontVol = pMusicInfoCurrent->iXFadeVolume;
+ Com_Printf("front vol = %d\n",pMusicInfoCurrent->iXFadeVolume);
+ }
+ */
+ if (pMusicInfoFadeOut->bActive) {
s_rawend = iRawEnd;
- S_UpdateBackgroundTrack_Actual( pMusicInfoFadeOut, qfalse, s_musicVolume->value ); // inactive-checked internally
- /*
- static int iPrevFadeVol = 0;
- if (iPrevFadeVol != pMusicInfoFadeOut->iXFadeVolume)
- {
- iPrevFadeVol = pMusicInfoFadeOut->iXFadeVolume;
- Com_Printf("fade vol = %d\n",pMusicInfoFadeOut->iXFadeVolume);
- }
- */
+ S_UpdateBackgroundTrack_Actual(pMusicInfoFadeOut, qfalse, s_musicVolume->value); // inactive-checked internally
+ /*
+ static int iPrevFadeVol = 0;
+ if (iPrevFadeVol != pMusicInfoFadeOut->iXFadeVolume)
+ {
+ iPrevFadeVol = pMusicInfoFadeOut->iXFadeVolume;
+ Com_Printf("fade vol = %d\n",pMusicInfoFadeOut->iXFadeVolume);
+ }
+ */
//
// only do this for the fader!...
//
- if (pMusicInfoFadeOut->iXFadeVolume == 0)
- {
+ if (pMusicInfoFadeOut->iXFadeVolume == 0) {
pMusicInfoFadeOut->bActive = qfalse;
}
}
- float fRemainingTimeInSeconds = MP3Stream_GetRemainingTimeInSeconds( &pMusicInfoCurrent->chMP3_Bgrnd.MP3StreamHeader );
+ float fRemainingTimeInSeconds = MP3Stream_GetRemainingTimeInSeconds(&pMusicInfoCurrent->chMP3_Bgrnd.MP3StreamHeader);
// Com_Printf("Remaining: %3.3f\n",fRemainingTimeInSeconds);
- if ( fRemainingTimeInSeconds < fDYNAMIC_XFADE_SECONDS*2 )
- {
+ if (fRemainingTimeInSeconds < fDYNAMIC_XFADE_SECONDS * 2) {
// now either loop current track, switch if finishing a transition, or stop if finished a death...
//
- if (pMusicInfoCurrent->bTrackSwitchPending)
- {
- pMusicInfoCurrent->bTrackSwitchPending = qfalse; // ack
- S_SwitchDynamicTracks( eMusic_StateActual, pMusicInfoCurrent->eTS_NewState, qfalse); // qboolean bNewTrackStartsFullVolume
- if (tMusic_Info[ pMusicInfoCurrent->eTS_NewState ].bExists) // don't do this if switching to silence
+ if (pMusicInfoCurrent->bTrackSwitchPending) {
+ pMusicInfoCurrent->bTrackSwitchPending = qfalse; // ack
+ S_SwitchDynamicTracks(eMusic_StateActual, pMusicInfoCurrent->eTS_NewState, qfalse); // qboolean bNewTrackStartsFullVolume
+ if (tMusic_Info[pMusicInfoCurrent->eTS_NewState].bExists) // don't do this if switching to silence
{
- tMusic_Info[ pMusicInfoCurrent->eTS_NewState ].SeekTo(pMusicInfoCurrent->fTS_NewTime);
+ tMusic_Info[pMusicInfoCurrent->eTS_NewState].SeekTo(pMusicInfoCurrent->fTS_NewTime);
}
- }
- else
- {
+ } else {
// normal looping, so set rewind current track, set volume to 0 and fade up to full (unless death track playing, then stays quiet)
// (while fader copy of end-section fades down)
//
// copy current track to fader...
//
- *pMusicInfoFadeOut = *pMusicInfoCurrent; // struct copy
- pMusicInfoFadeOut->iXFadeVolumeSeekTime = Sys_Milliseconds();
- pMusicInfoFadeOut->iXFadeVolumeSeekTo = 0;
+ *pMusicInfoFadeOut = *pMusicInfoCurrent; // struct copy
+ pMusicInfoFadeOut->iXFadeVolumeSeekTime = Sys_Milliseconds();
+ pMusicInfoFadeOut->iXFadeVolumeSeekTo = 0;
//
pMusicInfoCurrent->Rewind();
- pMusicInfoCurrent->iXFadeVolumeSeekTime = Sys_Milliseconds();
- pMusicInfoCurrent->iXFadeVolumeSeekTo = (eMusic_StateActual == eBGRNDTRACK_DEATH) ? 0: 255;
- pMusicInfoCurrent->iXFadeVolume = 0;
+ pMusicInfoCurrent->iXFadeVolumeSeekTime = Sys_Milliseconds();
+ pMusicInfoCurrent->iXFadeVolumeSeekTo = (eMusic_StateActual == eBGRNDTRACK_DEATH) ? 0 : 255;
+ pMusicInfoCurrent->iXFadeVolume = 0;
}
}
}
- }
- else
- {
+ } else {
// special case, when foreground music is shut off but fader still running to fade off previous track...
//
- MusicInfo_t *pMusicInfoFadeOut = &tMusic_Info[ eBGRNDTRACK_FADE ];
- if (pMusicInfoFadeOut->bActive)
- {
- S_UpdateBackgroundTrack_Actual( pMusicInfoFadeOut, qtrue, s_musicVolume->value );
- if (pMusicInfoFadeOut->iXFadeVolume == 0)
- {
+ MusicInfo_t *pMusicInfoFadeOut = &tMusic_Info[eBGRNDTRACK_FADE];
+ if (pMusicInfoFadeOut->bActive) {
+ S_UpdateBackgroundTrack_Actual(pMusicInfoFadeOut, qtrue, s_musicVolume->value);
+ if (pMusicInfoFadeOut->iXFadeVolume == 0) {
pMusicInfoFadeOut->bActive = qfalse;
}
}
}
- }
- else
- {
+ } else {
// standard / non-dynamic one-track music...
//
- const char *psCommand = S_Music_GetRequestedState(); // special check just for "silence" case...
- qboolean bShouldBeSilent = (qboolean)(psCommand && !Q_stricmp(psCommand,"silence"));
+ const char *psCommand = S_Music_GetRequestedState(); // special check just for "silence" case...
+ qboolean bShouldBeSilent = (qboolean)(psCommand && !Q_stricmp(psCommand, "silence"));
float fDesiredVolume = bShouldBeSilent ? 0.0f : s_musicVolume->value;
//
// internal to this code is a volume-smoother...
//
qboolean bNewTrackDesired = S_UpdateBackgroundTrack_Actual(&tMusic_Info[eBGRNDTRACK_NONDYNAMIC], qtrue, fDesiredVolume);
- if (bNewTrackDesired)
- {
- S_StartBackgroundTrack( sMusic_BackgroundLoop, sMusic_BackgroundLoop, qfalse );
+ if (bNewTrackDesired) {
+ S_StartBackgroundTrack(sMusic_BackgroundLoop, sMusic_BackgroundLoop, qfalse);
}
}
}
-
cvar_t *s_soundpoolmegs = NULL;
-
// currently passing in sfx as a param in case I want to do something with it later.
//
-byte *SND_malloc(int iSize, sfx_t *sfx)
-{
- byte *pData = (byte *) Z_Malloc(iSize, TAG_SND_RAWDATA, qfalse); // don't bother asking for zeroed mem
+byte *SND_malloc(int iSize, sfx_t *sfx) {
+ byte *pData = (byte *)Z_Malloc(iSize, TAG_SND_RAWDATA, qfalse); // don't bother asking for zeroed mem
// if "s_soundpoolmegs" is < 0, then the -ve of the value is the maximum amount of sounds we're allowed to have loaded...
//
- if (s_soundpoolmegs && s_soundpoolmegs->integer < 0)
- {
- while ( (Z_MemSize(TAG_SND_RAWDATA) + Z_MemSize(TAG_SND_MP3STREAMHDR)) > ((-s_soundpoolmegs->integer) * 1024 * 1024))
- {
+ if (s_soundpoolmegs && s_soundpoolmegs->integer < 0) {
+ while ((Z_MemSize(TAG_SND_RAWDATA) + Z_MemSize(TAG_SND_MP3STREAMHDR)) > ((-s_soundpoolmegs->integer) * 1024 * 1024)) {
int iBytesFreed = SND_FreeOldestSound(sfx);
if (iBytesFreed == 0)
- break; // sanity
+ break; // sanity
}
}
return pData;
}
-
// called once-only in EXE lifetime...
//
-void SND_setup()
-{
+void SND_setup() {
s_soundpoolmegs = Cvar_Get("s_soundpoolmegs", "25", CVAR_ARCHIVE);
- if (Sys_LowPhysicalMemory() )
- {
+ if (Sys_LowPhysicalMemory()) {
Cvar_Set("s_soundpoolmegs", "0");
}
-// Com_Printf("Sound memory manager started\n");
+ // Com_Printf("Sound memory manager started\n");
}
-
// ask how much mem an sfx has allocated...
//
-static int SND_MemUsed(sfx_t *sfx)
-{
+static int SND_MemUsed(sfx_t *sfx) {
int iSize = 0;
- if (sfx->pSoundData){
+ if (sfx->pSoundData) {
iSize += Z_Size(sfx->pSoundData);
}
@@ -5094,22 +4482,18 @@ static int SND_MemUsed(sfx_t *sfx)
//
// now returns # bytes freed to help with z_malloc()-fail recovery
//
-static int SND_FreeSFXMem(sfx_t *sfx)
-{
+static int SND_FreeSFXMem(sfx_t *sfx) {
int iBytesFreed = 0;
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
alGetError();
- if (sfx->Buffer)
- {
+ if (sfx->Buffer) {
alDeleteBuffers(1, &(sfx->Buffer));
#ifdef _DEBUG
#ifdef _MSC_VER
char szString[256];
- if (alGetError() != AL_NO_ERROR)
- {
+ if (alGetError() != AL_NO_ERROR) {
sprintf(szString, "Failed to delete AL Buffer (%s) ... !\n", sfx->sSoundName);
OutputDebugString(szString);
}
@@ -5118,70 +4502,60 @@ static int SND_FreeSFXMem(sfx_t *sfx)
sfx->Buffer = 0;
}
- if (sfx->lipSyncData)
- {
- iBytesFreed += Z_Free( sfx->lipSyncData);
- sfx->lipSyncData = NULL;
+ if (sfx->lipSyncData) {
+ iBytesFreed += Z_Free(sfx->lipSyncData);
+ sfx->lipSyncData = NULL;
}
}
#endif
- if ( sfx->pSoundData) {
- iBytesFreed += Z_Free( sfx->pSoundData );
- sfx->pSoundData = NULL;
+ if (sfx->pSoundData) {
+ iBytesFreed += Z_Free(sfx->pSoundData);
+ sfx->pSoundData = NULL;
}
sfx->bInMemory = false;
- if ( sfx->pMP3StreamHeader) {
- iBytesFreed += Z_Free( sfx->pMP3StreamHeader );
- sfx->pMP3StreamHeader = NULL;
+ if (sfx->pMP3StreamHeader) {
+ iBytesFreed += Z_Free(sfx->pMP3StreamHeader);
+ sfx->pMP3StreamHeader = NULL;
}
return iBytesFreed;
}
-void S_DisplayFreeMemory()
-{
- int iSoundDataSize = Z_MemSize ( TAG_SND_RAWDATA ) + Z_MemSize( TAG_SND_MP3STREAMHDR );
- int iMusicDataSize = Z_MemSize ( TAG_SND_DYNAMICMUSIC );
+void S_DisplayFreeMemory() {
+ int iSoundDataSize = Z_MemSize(TAG_SND_RAWDATA) + Z_MemSize(TAG_SND_MP3STREAMHDR);
+ int iMusicDataSize = Z_MemSize(TAG_SND_DYNAMICMUSIC);
- if (iSoundDataSize || iMusicDataSize)
- {
- Com_Printf("\n%.2fMB audio data: ( %.2fMB WAV/MP3 ) + ( %.2fMB Music )\n",
- ((float)(iSoundDataSize+iMusicDataSize))/1024.0f/1024.0f,
- ((float)(iSoundDataSize))/1024.0f/1024.0f,
- ((float)(iMusicDataSize))/1024.0f/1024.0f
- );
+ if (iSoundDataSize || iMusicDataSize) {
+ Com_Printf("\n%.2fMB audio data: ( %.2fMB WAV/MP3 ) + ( %.2fMB Music )\n", ((float)(iSoundDataSize + iMusicDataSize)) / 1024.0f / 1024.0f,
+ ((float)(iSoundDataSize)) / 1024.0f / 1024.0f, ((float)(iMusicDataSize)) / 1024.0f / 1024.0f);
// now count up amount used on this level...
//
iSoundDataSize = 0;
- for (int i=1; iiLastLevelUsedOn == re.RegisterMedia_GetLevel()){
+ if (sfx->iLastLevelUsedOn == re.RegisterMedia_GetLevel()) {
iSoundDataSize += SND_MemUsed(sfx);
}
}
- Com_Printf("%.2fMB in sfx_t alloc data (WAV/MP3) loaded this level\n",(float)iSoundDataSize/1024.0f/1024.0f);
+ Com_Printf("%.2fMB in sfx_t alloc data (WAV/MP3) loaded this level\n", (float)iSoundDataSize / 1024.0f / 1024.0f);
}
}
-void SND_TouchSFX(sfx_t *sfx)
-{
- sfx->iLastTimeUsed = Com_Milliseconds()+1;
- sfx->iLastLevelUsedOn = re.RegisterMedia_GetLevel();
+void SND_TouchSFX(sfx_t *sfx) {
+ sfx->iLastTimeUsed = Com_Milliseconds() + 1;
+ sfx->iLastLevelUsedOn = re.RegisterMedia_GetLevel();
}
-
// currently this is only called during snd_shutdown or snd_restart
//
-void S_FreeAllSFXMem(void)
-{
- for (int i=1 ; i < s_numSfx ; i++) // start @ 1 to skip freeing default sound
+void S_FreeAllSFXMem(void) {
+ for (int i = 1; i < s_numSfx; i++) // start @ 1 to skip freeing default sound
{
SND_FreeSFXMem(&s_knownSfx[i]);
}
@@ -5191,36 +4565,30 @@ void S_FreeAllSFXMem(void)
//
// new param is so we can be usre of not freeing ourselves (without having to rely on possible uninitialised timers etc)
//
-int SND_FreeOldestSound(sfx_t *pButNotThisOne /* = NULL */)
-{
+int SND_FreeOldestSound(sfx_t *pButNotThisOne /* = NULL */) {
int iBytesFreed = 0;
sfx_t *sfx;
- int iOldest = Com_Milliseconds();
- int iUsed = 0;
+ int iOldest = Com_Milliseconds();
+ int iUsed = 0;
// start on 1 so we never dump the default sound...
//
- for (int i=1 ; i < s_numSfx ; i++)
- {
+ for (int i = 1; i < s_numSfx; i++) {
sfx = &s_knownSfx[i];
- if (sfx != pButNotThisOne)
- {
- if (!sfx->bDefaultSound && sfx->bInMemory && sfx->iLastTimeUsed < iOldest)
- {
+ if (sfx != pButNotThisOne) {
+ if (!sfx->bDefaultSound && sfx->bInMemory && sfx->iLastTimeUsed < iOldest) {
// new bit, we can't throw away any sfx_t struct in use by a channel, else the paint code will crash...
//
int iChannel = 0;
- for (iChannel=0; iChannelthesfx == sfx)
- break; // damn, being used
+ break; // damn, being used
}
- if (iChannel == MAX_CHANNELS)
- {
+ if (iChannel == MAX_CHANNELS) {
// this sfx_t struct wasn't used by any channels, so we can lose it...
//
iUsed = i;
@@ -5230,9 +4598,8 @@ int SND_FreeOldestSound(sfx_t *pButNotThisOne /* = NULL */)
}
}
- if (iUsed)
- {
- sfx = &s_knownSfx[ iUsed ];
+ if (iUsed) {
+ sfx = &s_knownSfx[iUsed];
Com_DPrintf("SND_FreeOldestSound: freeing sound %s\n", sfx->sSoundName);
@@ -5241,71 +4608,59 @@ int SND_FreeOldestSound(sfx_t *pButNotThisOne /* = NULL */)
return iBytesFreed;
}
-int SND_FreeOldestSound(void)
-{
- return SND_FreeOldestSound(NULL); // I had to add a void-arg version of this because of link issues, sigh
+int SND_FreeOldestSound(void) {
+ return SND_FreeOldestSound(NULL); // I had to add a void-arg version of this because of link issues, sigh
}
-
// just before we drop into a level, ensure the audio pool is under whatever the maximum
// pool size is (but not by dropping out sounds used by the current level)...
//
// returns qtrue if at least one sound was dropped out, so z_malloc-fail recovery code knows if anything changed
//
extern qboolean gbInsideLoadSound;
-qboolean SND_RegisterAudio_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLevel /* 99% qfalse */)
-{
+qboolean SND_RegisterAudio_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLevel /* 99% qfalse */) {
qboolean bAtLeastOneSoundDropped = qfalse;
- Com_DPrintf( "SND_RegisterAudio_LevelLoadEnd():\n");
+ Com_DPrintf("SND_RegisterAudio_LevelLoadEnd():\n");
- if (gbInsideLoadSound)
- {
- Com_DPrintf( "(Inside S_LoadSound (z_malloc recovery?), exiting...\n");
- }
- else
- {
- int iLoadedAudioBytes = Z_MemSize ( TAG_SND_RAWDATA ) + Z_MemSize( TAG_SND_MP3STREAMHDR );
+ if (gbInsideLoadSound) {
+ Com_DPrintf("(Inside S_LoadSound (z_malloc recovery?), exiting...\n");
+ } else {
+ int iLoadedAudioBytes = Z_MemSize(TAG_SND_RAWDATA) + Z_MemSize(TAG_SND_MP3STREAMHDR);
const int iMaxAudioBytes = s_soundpoolmegs->integer * 1024 * 1024;
- for (int i=1; i iMaxAudioBytes || bDeleteEverythingNotUsedThisLevel) ; i++) // i=1 so we never page out default sound
+ for (int i = 1; i < s_numSfx && (iLoadedAudioBytes > iMaxAudioBytes || bDeleteEverythingNotUsedThisLevel);
+ i++) // i=1 so we never page out default sound
{
sfx_t *sfx = &s_knownSfx[i];
- if (sfx->bInMemory)
- {
+ if (sfx->bInMemory) {
qboolean bDeleteThis = qfalse;
- if (bDeleteEverythingNotUsedThisLevel)
- {
+ if (bDeleteEverythingNotUsedThisLevel) {
bDeleteThis = (qboolean)(sfx->iLastLevelUsedOn != re.RegisterMedia_GetLevel());
- }
- else
- {
+ } else {
bDeleteThis = (qboolean)(sfx->iLastLevelUsedOn < re.RegisterMedia_GetLevel());
}
- if (bDeleteThis)
- {
- Com_DPrintf( "Dumping sfx_t \"%s\"\n",sfx->sSoundName);
+ if (bDeleteThis) {
+ Com_DPrintf("Dumping sfx_t \"%s\"\n", sfx->sSoundName);
- if (SND_FreeSFXMem(sfx))
- {
+ if (SND_FreeSFXMem(sfx)) {
bAtLeastOneSoundDropped = qtrue;
}
- iLoadedAudioBytes = Z_MemSize ( TAG_SND_RAWDATA ) + Z_MemSize( TAG_SND_MP3STREAMHDR );
+ iLoadedAudioBytes = Z_MemSize(TAG_SND_RAWDATA) + Z_MemSize(TAG_SND_MP3STREAMHDR);
}
}
}
}
- Com_DPrintf( "SND_RegisterAudio_LevelLoadEnd(): Ok\n");
+ Com_DPrintf("SND_RegisterAudio_LevelLoadEnd(): Ok\n");
return bAtLeastOneSoundDropped;
}
-
/****************************************************************************************************\
*
* EAX Related
@@ -5315,60 +4670,49 @@ qboolean SND_RegisterAudio_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLev
/*
Initialize the EAX Manager
*/
-void InitEAXManager()
-{
+void InitEAXManager() {
#ifdef USE_OPENAL
LPEAXMANAGERCREATE lpEAXManagerCreateFn;
EAXFXSLOTPROPERTIES FXSlotProp;
- GUID Effect;
- GUID FXSlotGuids[4];
+ GUID Effect;
+ GUID FXSlotGuids[4];
int i;
s_bEALFileLoaded = false;
// Check for EAX 4.0 support
- s_bEAX = alIsExtensionPresent((ALubyte*)"EAX4.0");
+ s_bEAX = alIsExtensionPresent((ALubyte *)"EAX4.0");
- if (s_bEAX)
- {
+ if (s_bEAX) {
Com_Printf("Found EAX 4.0 native support\n");
- }
- else
- {
+ } else {
// Support for EAXUnified (automatic translation of EAX 4.0 calls into EAX 3.0)
- if ((alIsExtensionPresent((ALubyte*)"EAX3.0")) && (alIsExtensionPresent((ALubyte*)"EAX4.0Emulated")))
- {
+ if ((alIsExtensionPresent((ALubyte *)"EAX3.0")) && (alIsExtensionPresent((ALubyte *)"EAX4.0Emulated"))) {
s_bEAX = AL_TRUE;
Com_Printf("Found EAX 4.0 EMULATION support\n");
}
}
- if (s_bEAX)
- {
- s_eaxSet = (EAXSet)alGetProcAddress((ALubyte*)"EAXSet");
+ if (s_bEAX) {
+ s_eaxSet = (EAXSet)alGetProcAddress((ALubyte *)"EAXSet");
if (s_eaxSet == NULL)
s_bEAX = false;
- s_eaxGet = (EAXGet)alGetProcAddress((ALubyte*)"EAXGet");
+ s_eaxGet = (EAXGet)alGetProcAddress((ALubyte *)"EAXGet");
if (s_eaxGet == NULL)
s_bEAX = false;
}
// If we have detected EAX support, then try and load the EAX Manager DLL
- if (s_bEAX)
- {
+ if (s_bEAX) {
s_hEAXManInst = LoadLibrary("EAXMan.dll");
- if (s_hEAXManInst)
- {
+ if (s_hEAXManInst) {
lpEAXManagerCreateFn = (LPEAXMANAGERCREATE)GetProcAddress(s_hEAXManInst, "EaxManagerCreate");
- if (lpEAXManagerCreateFn)
- {
- if (lpEAXManagerCreateFn(&s_lpEAXManager)==EM_OK)
- {
+ if (lpEAXManagerCreateFn) {
+ if (lpEAXManagerCreateFn(&s_lpEAXManager) == EM_OK) {
// Configure our EAX 4.0 Effect Slots
s_NumFXSlots = 0;
- for (i = 0; i < EAX_MAX_FXSLOTS; i++)
- {
+ for (i = 0; i < EAX_MAX_FXSLOTS; i++) {
s_FXSlotInfo[i].FXSlotGuid = EAX_NULL_GUID;
s_FXSlotInfo[i].lEnvID = -1;
}
@@ -5384,22 +4728,16 @@ void InitEAXManager()
FXSlotProp.lLock = EAXFXSLOT_LOCKED;
FXSlotProp.ulFlags = EAXFXSLOTFLAGS_ENVIRONMENT;
- for (i = 0; i < EAX_MAX_FXSLOTS; i++)
- {
- if (s_eaxSet(&FXSlotGuids[i], EAXFXSLOT_ALLPARAMETERS, NULL, &FXSlotProp, sizeof(EAXFXSLOTPROPERTIES))==AL_NO_ERROR)
- {
+ for (i = 0; i < EAX_MAX_FXSLOTS; i++) {
+ if (s_eaxSet(&FXSlotGuids[i], EAXFXSLOT_ALLPARAMETERS, NULL, &FXSlotProp, sizeof(EAXFXSLOTPROPERTIES)) == AL_NO_ERROR) {
// We can use this slot
s_FXSlotInfo[s_NumFXSlots].FXSlotGuid = FXSlotGuids[i];
s_NumFXSlots++;
- }
- else
- {
+ } else {
// If this slot already contains a reverb, then we will use it anyway (Slot 0 will
// be in this category). (It probably means that Slot 0 is locked)
- if (s_eaxGet(&FXSlotGuids[i], EAXFXSLOT_LOADEFFECT, NULL, &Effect, sizeof(GUID))==AL_NO_ERROR)
- {
- if (Effect == EAX_REVERB_EFFECT)
- {
+ if (s_eaxGet(&FXSlotGuids[i], EAXFXSLOT_LOADEFFECT, NULL, &Effect, sizeof(GUID)) == AL_NO_ERROR) {
+ if (Effect == EAX_REVERB_EFFECT) {
// We can use this slot
// Make sure the environment flag is on
s_eaxSet(&FXSlotGuids[i], EAXFXSLOT_FLAGS, NULL, &FXSlotProp.ulFlags, sizeof(unsigned long));
@@ -5417,8 +4755,7 @@ void InitEAXManager()
}
// If the EAXManager library was loaded (and there was a problem), then unload it
- if (s_hEAXManInst)
- {
+ if (s_hEAXManInst) {
FreeLibrary(s_hEAXManInst);
s_hEAXManInst = NULL;
}
@@ -5433,44 +4770,39 @@ void InitEAXManager()
/*
Release the EAX Manager
*/
-void ReleaseEAXManager()
-{
+void ReleaseEAXManager() {
#ifdef USE_OPENAL
s_bEAX = false;
UnloadEALFile();
- if (s_lpEAXManager)
- {
+ if (s_lpEAXManager) {
s_lpEAXManager->Release();
s_lpEAXManager = NULL;
}
- if (s_hEAXManInst)
- {
+ if (s_hEAXManInst) {
FreeLibrary(s_hEAXManInst);
s_hEAXManInst = NULL;
}
#endif
}
-
#ifdef USE_OPENAL
/*
Try to load the given .eal file
*/
-static bool LoadEALFile(char *szEALFilename)
-{
- char *ealData = NULL;
- HRESULT hr;
- long i, j, lID, lEnvID;
- EMPOINT EMPoint;
- char szAperture[128];
- char szFullEALFilename[MAX_QPATH];
- long lNumInst, lNumInstA, lNumInstB;
- bool bLoaded = false;
- bool bValid = true;
- int result;
- char szString[256];
+static bool LoadEALFile(char *szEALFilename) {
+ char *ealData = NULL;
+ HRESULT hr;
+ long i, j, lID, lEnvID;
+ EMPOINT EMPoint;
+ char szAperture[128];
+ char szFullEALFilename[MAX_QPATH];
+ long lNumInst, lNumInstA, lNumInstB;
+ bool bLoaded = false;
+ bool bValid = true;
+ int result;
+ char szString[256];
if ((!s_lpEAXManager) || (!s_bEAX))
return false;
@@ -5486,198 +4818,148 @@ static bool LoadEALFile(char *szEALFilename)
// Load EAL file from PAK file
result = FS_ReadFile(szEALFilename, (void **)&ealData);
- if ((ealData) && (result != -1))
- {
+ if ((ealData) && (result != -1)) {
hr = s_lpEAXManager->LoadDataSet(ealData, EMFLAG_LOADFROMMEMORY);
// Unload EAL file
- FS_FreeFile (ealData);
+ FS_FreeFile(ealData);
- if (hr == EM_OK)
- {
+ if (hr == EM_OK) {
Com_DPrintf("Loaded %s by Quake loader\n", szEALFilename);
bLoaded = true;
}
- }
- else
- {
+ } else {
// Failed to load via Quake loader, try manually
Com_sprintf(szFullEALFilename, MAX_QPATH, "base/%s", szEALFilename);
- if (SUCCEEDED(s_lpEAXManager->LoadDataSet(szFullEALFilename, 0)))
- {
+ if (SUCCEEDED(s_lpEAXManager->LoadDataSet(szFullEALFilename, 0))) {
Com_DPrintf("Loaded %s by EAXManager\n", szEALFilename);
bLoaded = true;
}
}
- if (bLoaded)
- {
+ if (bLoaded) {
// For a valid eal file ... need to find 'Center' tag, record num of instances, and then find
// the right number of instances of 'Aperture0a' and 'Aperture0b'.
- if (s_lpEAXManager->GetSourceID("Center", &lID)==EM_OK)
- {
- if (s_lpEAXManager->GetSourceNumInstances(lID, &s_lNumEnvironments)==EM_OK)
- {
- if (s_lpEAXManager->GetSourceID("Aperture0a", &lID)==EM_OK)
- {
- if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst)==EM_OK)
- {
- if (lNumInst == s_lNumEnvironments)
- {
- if (s_lpEAXManager->GetSourceID("Aperture0b", &lID)==EM_OK)
- {
- if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst)==EM_OK)
- {
- if (lNumInst == s_lNumEnvironments)
- {
+ if (s_lpEAXManager->GetSourceID("Center", &lID) == EM_OK) {
+ if (s_lpEAXManager->GetSourceNumInstances(lID, &s_lNumEnvironments) == EM_OK) {
+ if (s_lpEAXManager->GetSourceID("Aperture0a", &lID) == EM_OK) {
+ if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst) == EM_OK) {
+ if (lNumInst == s_lNumEnvironments) {
+ if (s_lpEAXManager->GetSourceID("Aperture0b", &lID) == EM_OK) {
+ if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst) == EM_OK) {
+ if (lNumInst == s_lNumEnvironments) {
// Check equal numbers of ApertureXa and ApertureXb
i = 1;
- while (true)
- {
+ while (true) {
lNumInstA = lNumInstB = 0;
- sprintf(szAperture,"Aperture%da",i);
- if ((s_lpEAXManager->GetSourceID(szAperture, &lID)==EM_OK) && (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInstA)==EM_OK))
- {
- sprintf(szAperture,"Aperture%db",i);
+ sprintf(szAperture, "Aperture%da", i);
+ if ((s_lpEAXManager->GetSourceID(szAperture, &lID) == EM_OK) &&
+ (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInstA) == EM_OK)) {
+ sprintf(szAperture, "Aperture%db", i);
s_lpEAXManager->GetSourceID(szAperture, &lID);
s_lpEAXManager->GetSourceNumInstances(lID, &lNumInstB);
- if (lNumInstA!=lNumInstB)
- {
- Com_DPrintf( S_COLOR_YELLOW "Invalid EAL file - %d Aperture%da tags, and %d Aperture%db tags\n", lNumInstA, i, lNumInstB, i);
+ if (lNumInstA != lNumInstB) {
+ Com_DPrintf(S_COLOR_YELLOW "Invalid EAL file - %d Aperture%da tags, and %d Aperture%db tags\n", lNumInstA,
+ i, lNumInstB, i);
bValid = false;
}
- }
- else
- {
+ } else {
break;
}
i++;
}
- if (bValid)
- {
+ if (bValid) {
s_lpEnvTable = (LPENVTABLE)Z_Malloc(s_lNumEnvironments * sizeof(ENVTABLE), TAG_NEWDEL, qtrue);
}
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "Invalid EAL File - expected %d instances of Aperture0b, found %d\n", s_lNumEnvironments, lNumInst);
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "EAXManager- failed GetSourceNumInstances()\n");
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "Invalid EAL File - no instances of 'Aperture0b' source-tag\n");
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "Invalid EAL File - found %d instances of the 'Center' tag, but only %d instances of 'Aperture0a'\n", s_lNumEnvironments, lNumInst);
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "EAXManager- failed GetSourceNumInstances()\n");
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "Invalid EAL File - no instances of 'Aperture0a' source-tag\n");
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "EAXManager- failed GetSourceNumInstances()\n");
- }
- else
- Com_DPrintf( S_COLOR_YELLOW "Invalid EAL File - no instances of 'Center' source-tag\n");
-
-
- if (s_lpEnvTable)
- {
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "Invalid EAL File - expected %d instances of Aperture0b, found %d\n", s_lNumEnvironments,
+ lNumInst);
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "EAXManager- failed GetSourceNumInstances()\n");
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "Invalid EAL File - no instances of 'Aperture0b' source-tag\n");
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "Invalid EAL File - found %d instances of the 'Center' tag, but only %d instances of 'Aperture0a'\n",
+ s_lNumEnvironments, lNumInst);
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "EAXManager- failed GetSourceNumInstances()\n");
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "Invalid EAL File - no instances of 'Aperture0a' source-tag\n");
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "EAXManager- failed GetSourceNumInstances()\n");
+ } else
+ Com_DPrintf(S_COLOR_YELLOW "Invalid EAL File - no instances of 'Center' source-tag\n");
+
+ if (s_lpEnvTable) {
i = 0;
- while (true)
- {
+ while (true) {
sprintf(szAperture, "Aperture%da", i);
- if (s_lpEAXManager->GetSourceID(szAperture, &lID)==EM_OK)
- {
- if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst)==EM_OK)
- {
- for (j = 0; j < s_lNumEnvironments; j++)
- {
+ if (s_lpEAXManager->GetSourceID(szAperture, &lID) == EM_OK) {
+ if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst) == EM_OK) {
+ for (j = 0; j < s_lNumEnvironments; j++) {
s_lpEnvTable[j].bUsed = false;
}
- for (j = 0; j < lNumInst; j++)
- {
- if (s_lpEAXManager->GetSourceInstancePos(lID, j, &EMPoint)==EM_OK)
- {
- if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMPoint, &lEnvID, 0)==EM_OK)
- {
- if ((lEnvID >= 0) && (lEnvID < s_lNumEnvironments))
- {
+ for (j = 0; j < lNumInst; j++) {
+ if (s_lpEAXManager->GetSourceInstancePos(lID, j, &EMPoint) == EM_OK) {
+ if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMPoint, &lEnvID, 0) == EM_OK) {
+ if ((lEnvID >= 0) && (lEnvID < s_lNumEnvironments)) {
assert(s_lpEnvTable[lEnvID].ulNumApertures < 64);
- if (!s_lpEnvTable[lEnvID].bUsed)
- {
+ if (!s_lpEnvTable[lEnvID].bUsed) {
s_lpEnvTable[lEnvID].bUsed = true;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[0] = EMPoint.fX;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[1] = EMPoint.fY;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[2] = EMPoint.fZ;
- }
- else
- {
+ } else {
s_lpEAXManager->GetEnvironmentName(lEnvID, szString, 256);
- Com_DPrintf( S_COLOR_YELLOW "Found more than one occurance of Aperture%da in %s sub-space\n", i, szString);
- Com_DPrintf( S_COLOR_YELLOW "One tag at %.3f,%.3f,%.3f, other at %.3f,%.3f,%.3f\n", EMPoint.fX, EMPoint.fY, EMPoint.fZ,
- s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[0], s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[1],
- s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[2]);
+ Com_DPrintf(S_COLOR_YELLOW "Found more than one occurance of Aperture%da in %s sub-space\n", i, szString);
+ Com_DPrintf(S_COLOR_YELLOW "One tag at %.3f,%.3f,%.3f, other at %.3f,%.3f,%.3f\n", EMPoint.fX, EMPoint.fY,
+ EMPoint.fZ, s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[0],
+ s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[1],
+ s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[2]);
bValid = false;
}
- }
- else
- {
- if (lEnvID==-1)
- Com_DPrintf( S_COLOR_YELLOW "%s (%.3f,%.3f,%.3f) in Default Environment - please remove\n", szAperture, EMPoint.fX, EMPoint.fY, EMPoint.fZ);
+ } else {
+ if (lEnvID == -1)
+ Com_DPrintf(S_COLOR_YELLOW "%s (%.3f,%.3f,%.3f) in Default Environment - please remove\n", szAperture, EMPoint.fX,
+ EMPoint.fY, EMPoint.fZ);
else
- Com_DPrintf( S_COLOR_YELLOW "Detected more reverb presets than zones - please delete unused presets\n");
+ Com_DPrintf(S_COLOR_YELLOW "Detected more reverb presets than zones - please delete unused presets\n");
bValid = false;
}
}
}
}
}
- }
- else
- {
+ } else {
break;
}
- if (bValid)
- {
+ if (bValid) {
sprintf(szAperture, "Aperture%db", i);
- if (s_lpEAXManager->GetSourceID(szAperture, &lID)==EM_OK)
- {
- if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst)==EM_OK)
- {
- for (j = 0; j < s_lNumEnvironments; j++)
- {
+ if (s_lpEAXManager->GetSourceID(szAperture, &lID) == EM_OK) {
+ if (s_lpEAXManager->GetSourceNumInstances(lID, &lNumInst) == EM_OK) {
+ for (j = 0; j < s_lNumEnvironments; j++) {
s_lpEnvTable[j].bUsed = false;
}
- for (j = 0; j < lNumInst; j++)
- {
- if (s_lpEAXManager->GetSourceInstancePos(lID, j, &EMPoint)==EM_OK)
- {
- if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMPoint, &lEnvID, 0)==EM_OK)
- {
- if ((lEnvID >= 0) && (lEnvID < s_lNumEnvironments))
- {
- if (!s_lpEnvTable[lEnvID].bUsed)
- {
+ for (j = 0; j < lNumInst; j++) {
+ if (s_lpEAXManager->GetSourceInstancePos(lID, j, &EMPoint) == EM_OK) {
+ if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMPoint, &lEnvID, 0) == EM_OK) {
+ if ((lEnvID >= 0) && (lEnvID < s_lNumEnvironments)) {
+ if (!s_lpEnvTable[lEnvID].bUsed) {
s_lpEnvTable[lEnvID].bUsed = true;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[0] = EMPoint.fX;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[1] = EMPoint.fY;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[2] = EMPoint.fZ;
- }
- else
- {
+ } else {
s_lpEAXManager->GetEnvironmentName(lEnvID, szString, 256);
- Com_DPrintf( S_COLOR_YELLOW "Found more than one occurance of Aperture%db in %s sub-space\n", i, szString);
+ Com_DPrintf(S_COLOR_YELLOW "Found more than one occurance of Aperture%db in %s sub-space\n", i, szString);
bValid = false;
}
@@ -5685,25 +4967,27 @@ static bool LoadEALFile(char *szEALFilename)
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vCenter[0] =
(s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[0] +
- s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[0]) / 2;
+ s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[0]) /
+ 2;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vCenter[1] =
(s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[1] +
- s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[1]) / 2;
+ s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[1]) /
+ 2;
s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vCenter[2] =
(s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos1[2] +
- s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[2]) / 2;
+ s_lpEnvTable[lEnvID].Aperture[s_lpEnvTable[lEnvID].ulNumApertures].vPos2[2]) /
+ 2;
s_lpEnvTable[lEnvID].ulNumApertures++;
assert(s_lpEnvTable[lEnvID].ulNumApertures < 64);
- }
- else
- {
- if (lEnvID==-1)
- Com_DPrintf( S_COLOR_YELLOW "%s (%.3f,%.3f,%.3f) in Default Environment - please remove\n", szAperture, EMPoint.fX, EMPoint.fY, EMPoint.fZ);
+ } else {
+ if (lEnvID == -1)
+ Com_DPrintf(S_COLOR_YELLOW "%s (%.3f,%.3f,%.3f) in Default Environment - please remove\n", szAperture,
+ EMPoint.fX, EMPoint.fY, EMPoint.fZ);
else
- Com_DPrintf( S_COLOR_YELLOW "Detected more reverb presets than zones - please delete unused presets\n");
+ Com_DPrintf(S_COLOR_YELLOW "Detected more reverb presets than zones - please delete unused presets\n");
bValid = false;
}
}
@@ -5713,10 +4997,9 @@ static bool LoadEALFile(char *szEALFilename)
}
}
- if (!bValid)
- {
+ if (!bValid) {
// Found a problem
- Com_DPrintf( S_COLOR_YELLOW "EAX legacy behaviour invoked (one reverb)\n");
+ Com_DPrintf(S_COLOR_YELLOW "EAX legacy behaviour invoked (one reverb)\n");
Z_Free(s_lpEnvTable);
s_lpEnvTable = NULL;
@@ -5725,16 +5008,14 @@ static bool LoadEALFile(char *szEALFilename)
i++;
}
- }
- else
- {
- Com_DPrintf( S_COLOR_YELLOW "EAX legacy behaviour invoked (one reverb)\n");
+ } else {
+ Com_DPrintf(S_COLOR_YELLOW "EAX legacy behaviour invoked (one reverb)\n");
}
return true;
}
- Com_DPrintf( S_COLOR_YELLOW "Failed to load %s\n", szEALFilename);
+ Com_DPrintf(S_COLOR_YELLOW "Failed to load %s\n", szEALFilename);
return false;
}
#endif
@@ -5743,8 +5024,7 @@ static bool LoadEALFile(char *szEALFilename)
/*
Unload current .eal file
*/
-static void UnloadEALFile()
-{
+static void UnloadEALFile() {
HRESULT hr;
if ((!s_lpEAXManager) || (!s_bEAX))
@@ -5753,8 +5033,7 @@ static void UnloadEALFile()
hr = s_lpEAXManager->FreeDataSet(0);
s_bEALFileLoaded = false;
- if (s_lpEnvTable)
- {
+ if (s_lpEnvTable) {
Z_Free(s_lpEnvTable);
s_lpEnvTable = NULL;
}
@@ -5767,8 +5046,7 @@ static void UnloadEALFile()
/*
Updates the current EAX Reverb setting, based on the location of the listener
*/
-static void UpdateEAXListener()
-{
+static void UpdateEAXListener() {
EMPOINT ListPos, ListOri;
EMPOINT EMAperture;
EMPOINT EMSourcePoint;
@@ -5779,8 +5057,8 @@ static void UpdateEAXListener()
bool bFound;
long lVolume;
long lCurTime;
- channel_t *ch;
- EAXVECTOR LR, LP1, LP2, Pan;
+ channel_t *ch;
+ EAXVECTOR LR, LP1, LP2, Pan;
REVERBDATA ReverbData[3]; // Hardcoded to three (maximum no of reverbs)
#ifdef DISPLAY_CLOSEST_ENVS
char szEnvName[256];
@@ -5791,37 +5069,31 @@ static void UpdateEAXListener()
lCurTime = timeGetTime();
- if ((s_lLastEnvUpdate + ENV_UPDATE_RATE) < lCurTime)
- {
+ if ((s_lLastEnvUpdate + ENV_UPDATE_RATE) < lCurTime) {
// Update closest reverbs
s_lLastEnvUpdate = lCurTime;
// No panning information in .eal file, or we only have 1 FX Slot to use, revert to legacy
// behaviour (i.e only one reverb)
- if ((!s_lpEnvTable) || (s_NumFXSlots==1))
- {
+ if ((!s_lpEnvTable) || (s_NumFXSlots == 1)) {
// Convert Listener co-ordinate to left-handed system
ListPos.fX = listener_pos[0];
ListPos.fY = listener_pos[1];
ListPos.fZ = -listener_pos[2];
- if (SUCCEEDED(s_lpEAXManager->GetListenerDynamicAttributes(0, &ListPos, &lID, EMFLAG_LOCKPOSITION)))
- {
- if (lID != s_EnvironmentID)
- {
+ if (SUCCEEDED(s_lpEAXManager->GetListenerDynamicAttributes(0, &ListPos, &lID, EMFLAG_LOCKPOSITION))) {
+ if (lID != s_EnvironmentID) {
#ifdef DISPLAY_CLOSEST_ENVS
if (SUCCEEDED(s_lpEAXManager->GetEnvironmentName(lID, szEnvName, 256)))
Com_Printf("Changing to '%s' zone !\n", szEnvName);
#endif
// Get EAX Preset info.
- if (SUCCEEDED(s_lpEAXManager->GetEnvironmentAttributes(lID, &s_eaxLPCur)))
- {
+ if (SUCCEEDED(s_lpEAXManager->GetEnvironmentAttributes(lID, &s_eaxLPCur))) {
// Override
s_eaxLPCur.flAirAbsorptionHF = 0.0f;
// Set Environment
- s_eaxSet(&EAXPROPERTYID_EAX40_FXSlot0, EAXREVERB_ALLPARAMETERS,
- NULL, &s_eaxLPCur, sizeof(EAXREVERBPROPERTIES));
+ s_eaxSet(&EAXPROPERTYID_EAX40_FXSlot0, EAXREVERB_ALLPARAMETERS, NULL, &s_eaxLPCur, sizeof(EAXREVERBPROPERTIES));
s_EnvironmentID = lID;
}
@@ -5842,12 +5114,10 @@ static void UpdateEAXListener()
// Need to find closest s_NumFXSlots (including the Listener's slot)
- if (s_lpEAXManager->GetListenerDynamicAttributes(0, &ListPos, &lID, EMFLAG_LOCKPOSITION)==EM_OK)
- {
- if (lID == -1)
- {
+ if (s_lpEAXManager->GetListenerDynamicAttributes(0, &ListPos, &lID, EMFLAG_LOCKPOSITION) == EM_OK) {
+ if (lID == -1) {
// Found default environment
-// Com_Printf( S_COLOR_YELLOW "Listener in default environment - ignoring zone !\n");
+ // Com_Printf( S_COLOR_YELLOW "Listener in default environment - ignoring zone !\n");
return;
}
@@ -5863,24 +5133,20 @@ static void UpdateEAXListener()
ReverbData[2].lApertureNum = -1;
ReverbData[2].flDist = 0.0f;
- for (i = 0; i < s_lNumEnvironments; i++)
- {
+ for (i = 0; i < s_lNumEnvironments; i++) {
// Ignore Environment id lID as this one will always be used
- if (i != lID)
- {
+ if (i != lID) {
flNearest = FLT_MAX;
- lApertureNum = 0; //shut up compile warning
+ lApertureNum = 0; // shut up compile warning
- for (j = 0; j < s_lpEnvTable[i].ulNumApertures; j++)
- {
+ for (j = 0; j < s_lpEnvTable[i].ulNumApertures; j++) {
EMAperture.fX = s_lpEnvTable[i].Aperture[j].vCenter[0];
EMAperture.fY = s_lpEnvTable[i].Aperture[j].vCenter[1];
EMAperture.fZ = s_lpEnvTable[i].Aperture[j].vCenter[2];
flDistance = CalcDistance(EMAperture, ListPos);
- if (flDistance < flNearest)
- {
+ if (flDistance < flNearest) {
flNearest = flDistance;
lApertureNum = j;
}
@@ -5888,17 +5154,13 @@ static void UpdateEAXListener()
// Now have closest point for this Environment - see if this is closer than any others
- if (flNearest < ReverbData[1].flDist)
- {
- if (flNearest < ReverbData[0].flDist)
- {
+ if (flNearest < ReverbData[1].flDist) {
+ if (flNearest < ReverbData[0].flDist) {
ReverbData[1] = ReverbData[0];
ReverbData[0].flDist = flNearest;
ReverbData[0].lApertureNum = lApertureNum;
ReverbData[0].lEnvID = i;
- }
- else
- {
+ } else {
ReverbData[1].flDist = flNearest;
ReverbData[1].lApertureNum = lApertureNum;
ReverbData[1].lEnvID = i;
@@ -5906,7 +5168,6 @@ static void UpdateEAXListener()
}
}
}
-
}
#ifdef DISPLAY_CLOSEST_ENVS
@@ -5918,31 +5179,26 @@ static void UpdateEAXListener()
s_lpEAXManager->GetEnvironmentName(ReverbData[1].lEnvID, szEnvName2, 256);
s_lpEAXManager->GetEnvironmentName(ReverbData[2].lEnvID, szEnvName3, 256);
- Com_Printf("Closest zones are %s, %s (Listener in %s)\n", szEnvName1,
- szEnvName2, szEnvName3);
+ Com_Printf("Closest zones are %s, %s (Listener in %s)\n", szEnvName1, szEnvName2, szEnvName3);
#endif
// Mute any reverbs no longer required ...
- for (i = 0; i < s_NumFXSlots; i++)
- {
- if ((s_FXSlotInfo[i].lEnvID != -1) && (s_FXSlotInfo[i].lEnvID != ReverbData[0].lEnvID) && (s_FXSlotInfo[i].lEnvID != ReverbData[1].lEnvID)
- && (s_FXSlotInfo[i].lEnvID != ReverbData[2].lEnvID))
- {
+ for (i = 0; i < s_NumFXSlots; i++) {
+ if ((s_FXSlotInfo[i].lEnvID != -1) && (s_FXSlotInfo[i].lEnvID != ReverbData[0].lEnvID) && (s_FXSlotInfo[i].lEnvID != ReverbData[1].lEnvID) &&
+ (s_FXSlotInfo[i].lEnvID != ReverbData[2].lEnvID)) {
// This environment is no longer needed
// Mute it
lVolume = -10000;
- if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXFXSLOT_VOLUME, NULL, &lVolume, sizeof(long))!=AL_NO_ERROR)
+ if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXFXSLOT_VOLUME, NULL, &lVolume, sizeof(long)) != AL_NO_ERROR)
OutputDebugString("Failed to Mute FX Slot\n");
// If any source is sending to this Slot ID then we need to stop them sending to the slot
- for (j = 1; j < s_numChannels; j++)
- {
- if (s_channels[j].lSlotID == i)
- {
- if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, s_channels[j].alSource, (void*)&EAX_NULL_GUID, sizeof(GUID))!=AL_NO_ERROR)
- {
+ for (j = 1; j < s_numChannels; j++) {
+ if (s_channels[j].lSlotID == i) {
+ if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, s_channels[j].alSource, (void *)&EAX_NULL_GUID, sizeof(GUID)) !=
+ AL_NO_ERROR) {
OutputDebugString("Failed to set Source ActiveFXSlotID to NULL\n");
}
@@ -5951,44 +5207,35 @@ static void UpdateEAXListener()
}
assert(s_FXSlotInfo[i].lEnvID < s_lNumEnvironments && s_FXSlotInfo[i].lEnvID >= 0);
- if (s_FXSlotInfo[i].lEnvID < s_lNumEnvironments && s_FXSlotInfo[i].lEnvID >= 0)
- {
+ if (s_FXSlotInfo[i].lEnvID < s_lNumEnvironments && s_FXSlotInfo[i].lEnvID >= 0) {
s_lpEnvTable[s_FXSlotInfo[i].lEnvID].lFXSlotID = -1;
}
s_FXSlotInfo[i].lEnvID = -1;
}
}
-
// Make sure all the reverbs we want are being rendered, if not, find an empty slot
// and apply appropriate reverb settings
- for (j = 0; j < 3; j++)
- {
+ for (j = 0; j < 3; j++) {
bFound = false;
- for (i = 0; i < s_NumFXSlots; i++)
- {
- if (s_FXSlotInfo[i].lEnvID == ReverbData[j].lEnvID)
- {
+ for (i = 0; i < s_NumFXSlots; i++) {
+ if (s_FXSlotInfo[i].lEnvID == ReverbData[j].lEnvID) {
bFound = true;
break;
}
}
- if (!bFound)
- {
+ if (!bFound) {
// Find the first available slot and use that one
- for (i = 0; i < s_NumFXSlots; i++)
- {
- if (s_FXSlotInfo[i].lEnvID == -1)
- {
+ for (i = 0; i < s_NumFXSlots; i++) {
+ if (s_FXSlotInfo[i].lEnvID == -1) {
// Found slot
// load reverb here
// Retrieve reverb properties from EAX Manager
- if (s_lpEAXManager->GetEnvironmentAttributes(ReverbData[j].lEnvID, &Reverb)==EM_OK)
- {
+ if (s_lpEAXManager->GetEnvironmentAttributes(ReverbData[j].lEnvID, &Reverb) == EM_OK) {
// Override Air Absorption HF
Reverb.flAirAbsorptionHF = 0.0f;
@@ -5996,44 +5243,36 @@ static void UpdateEAXListener()
// See if any Sources are in this environment, if they are, enable their sends
ch = s_channels + 1;
- for (k = 1; k < s_numChannels; k++, ch++)
- {
- if (ch->fixed_origin)
- {
+ for (k = 1; k < s_numChannels; k++, ch++) {
+ if (ch->fixed_origin) {
// Converting from Quake -> DS3D (for EAGLE) ... swap Y and Z
EMSourcePoint.fX = ch->origin[0];
EMSourcePoint.fY = ch->origin[2];
EMSourcePoint.fZ = ch->origin[1];
- }
- else
- {
- if (ch->entnum == listener_number)
- {
+ } else {
+ if (ch->entnum == listener_number) {
// Source at same position as listener
// Probably won't be any Occlusion / Obstruction effect -- unless the listener is underwater
// Converting from Open AL -> DS3D (for EAGLE) ... invert Z
EMSourcePoint.fX = listener_pos[0];
EMSourcePoint.fY = listener_pos[1];
EMSourcePoint.fZ = -listener_pos[2];
- }
- else
- {
+ } else {
// Get position of Entity
// Converting from Quake -> DS3D (for EAGLE) ... swap Y and Z
- EMSourcePoint.fX = loopSounds[ ch->entnum ].origin[0];
- EMSourcePoint.fY = loopSounds[ ch->entnum ].origin[2];
- EMSourcePoint.fZ = loopSounds[ ch->entnum ].origin[1];
+ EMSourcePoint.fX = loopSounds[ch->entnum].origin[0];
+ EMSourcePoint.fY = loopSounds[ch->entnum].origin[2];
+ EMSourcePoint.fZ = loopSounds[ch->entnum].origin[1];
}
}
// Get Source Environment point
- if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMSourcePoint, &lSourceID, 0)!=EM_OK)
+ if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMSourcePoint, &lSourceID, 0) != EM_OK)
OutputDebugString("Failed to get environment zone for Source\n");
- if (lSourceID == i)
- {
- if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, ch->alSource, (void*)&(s_FXSlotInfo[i].FXSlotGuid), sizeof(GUID))!=AL_NO_ERROR)
- {
+ if (lSourceID == i) {
+ if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, ch->alSource, (void *)&(s_FXSlotInfo[i].FXSlotGuid),
+ sizeof(GUID)) != AL_NO_ERROR) {
OutputDebugString("Failed to set Source ActiveFXSlotID to new environment\n");
}
@@ -6042,8 +5281,7 @@ static void UpdateEAXListener()
}
assert(ReverbData[j].lEnvID < s_lNumEnvironments && ReverbData[j].lEnvID >= 0);
- if (ReverbData[j].lEnvID < s_lNumEnvironments && ReverbData[j].lEnvID >= 0)
- {
+ if (ReverbData[j].lEnvID < s_lNumEnvironments && ReverbData[j].lEnvID >= 0) {
s_FXSlotInfo[i].lEnvID = ReverbData[j].lEnvID;
s_lpEnvTable[ReverbData[j].lEnvID].lFXSlotID = i;
}
@@ -6056,15 +5294,14 @@ static void UpdateEAXListener()
}
// Make sure Primary FX Slot ID is set correctly
- if (s_EnvironmentID != ReverbData[2].lEnvID)
- {
- s_eaxSet(&EAXPROPERTYID_EAX40_Context, EAXCONTEXT_PRIMARYFXSLOTID, NULL, &(s_FXSlotInfo[s_lpEnvTable[ReverbData[2].lEnvID].lFXSlotID].FXSlotGuid), sizeof(GUID));
+ if (s_EnvironmentID != ReverbData[2].lEnvID) {
+ s_eaxSet(&EAXPROPERTYID_EAX40_Context, EAXCONTEXT_PRIMARYFXSLOTID, NULL, &(s_FXSlotInfo[s_lpEnvTable[ReverbData[2].lEnvID].lFXSlotID].FXSlotGuid),
+ sizeof(GUID));
s_EnvironmentID = ReverbData[2].lEnvID;
}
// Have right reverbs loaded ... now to pan them and adjust volume
-
// We need to rotate the vector from the Listener to the reverb Aperture by minus the listener
// orientation
@@ -6082,27 +5319,23 @@ static void UpdateEAXListener()
float flSin = (float)sin(-flTheta);
float flCos = (float)cos(-flTheta);
- for (i = 0; i < Q_min(s_NumFXSlots,s_lNumEnvironments); i++)
- {
- if (s_FXSlotInfo[i].lEnvID == s_EnvironmentID)
- {
+ for (i = 0; i < Q_min(s_NumFXSlots, s_lNumEnvironments); i++) {
+ if (s_FXSlotInfo[i].lEnvID == s_EnvironmentID) {
// Listener's environment
// Find the closest Aperture in *this* environment
flNearest = FLT_MAX;
- lApertureNum = 0; //shut up compile warning
+ lApertureNum = 0; // shut up compile warning
- for (j = 0; j < s_lpEnvTable[s_EnvironmentID].ulNumApertures; j++)
- {
+ for (j = 0; j < s_lpEnvTable[s_EnvironmentID].ulNumApertures; j++) {
EMAperture.fX = s_lpEnvTable[s_EnvironmentID].Aperture[j].vCenter[0];
EMAperture.fY = s_lpEnvTable[s_EnvironmentID].Aperture[j].vCenter[1];
EMAperture.fZ = s_lpEnvTable[s_EnvironmentID].Aperture[j].vCenter[2];
flDistance = CalcDistance(EMAperture, ListPos);
- if (flDistance < flNearest)
- {
+ if (flDistance < flNearest) {
flNearest = flDistance;
lApertureNum = j;
}
@@ -6120,14 +5353,12 @@ static void UpdateEAXListener()
Normalize(&Pan);
-
// Adjust magnitude ...
// Magnitude is based on the angle subtended by the aperture, so compute the angle between
// the vector from the Listener to Pos1 of the aperture, and the vector from the
// Listener to Pos2 of the aperture.
-
LP1.x = s_lpEnvTable[s_EnvironmentID].Aperture[lApertureNum].vPos1[0] - ListPos.fX;
LP1.y = s_lpEnvTable[s_EnvironmentID].Aperture[lApertureNum].vPos1[1] - ListPos.fY;
LP1.z = s_lpEnvTable[s_EnvironmentID].Aperture[lApertureNum].vPos1[2] - ListPos.fZ;
@@ -6142,21 +5373,19 @@ static void UpdateEAXListener()
float flGamma = acos((LP1.x * LP2.x) + (LP1.y * LP2.y) + (LP1.z * LP2.z));
// We want opposite magnitude (because we are 'in' this environment)
- float flMagnitude = 1.0f - ((2.0f * (float)sin(flGamma/2.0f)) / flGamma);
+ float flMagnitude = 1.0f - ((2.0f * (float)sin(flGamma / 2.0f)) / flGamma);
// Negative (because pan should be 180 degrees)
Pan.x *= -flMagnitude;
Pan.y *= -flMagnitude;
Pan.z *= -flMagnitude;
- if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REVERBPAN, NULL, &Pan, sizeof(EAXVECTOR))!=AL_NO_ERROR)
+ if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REVERBPAN, NULL, &Pan, sizeof(EAXVECTOR)) != AL_NO_ERROR)
OutputDebugString("Failed to set Listener Reverb Pan\n");
- if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REFLECTIONSPAN, NULL, &Pan, sizeof(EAXVECTOR))!=AL_NO_ERROR)
+ if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REFLECTIONSPAN, NULL, &Pan, sizeof(EAXVECTOR)) != AL_NO_ERROR)
OutputDebugString("Failed to set Listener Reflections Pan\n");
- }
- else
- {
+ } else {
// Find out which Reverb this is
if (ReverbData[0].lEnvID == s_FXSlotInfo[i].lEnvID)
k = 0;
@@ -6181,7 +5410,6 @@ static void UpdateEAXListener()
// the vector from the Listener to Pos1 of the aperture, and the vector from the
// Listener to Pos2 of the aperture.
-
LP1.x = s_lpEnvTable[ReverbData[k].lEnvID].Aperture[ReverbData[k].lApertureNum].vPos1[0] - ListPos.fX;
LP1.y = s_lpEnvTable[ReverbData[k].lEnvID].Aperture[ReverbData[k].lApertureNum].vPos1[1] - ListPos.fY;
LP1.z = s_lpEnvTable[ReverbData[k].lEnvID].Aperture[ReverbData[k].lApertureNum].vPos1[2] - ListPos.fZ;
@@ -6194,24 +5422,23 @@ static void UpdateEAXListener()
Normalize(&LP2);
float flGamma = acos((LP1.x * LP2.x) + (LP1.y * LP2.y) + (LP1.z * LP2.z));
- float flMagnitude = (2.0f * (float)sin(flGamma/2.0f)) / flGamma;
+ float flMagnitude = (2.0f * (float)sin(flGamma / 2.0f)) / flGamma;
Pan.x *= flMagnitude;
Pan.y *= flMagnitude;
Pan.z *= flMagnitude;
- if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REVERBPAN, NULL, &Pan, sizeof(EAXVECTOR))!=AL_NO_ERROR)
+ if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REVERBPAN, NULL, &Pan, sizeof(EAXVECTOR)) != AL_NO_ERROR)
OutputDebugString("Failed to set Reverb Pan\n");
- if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REFLECTIONSPAN, NULL, &Pan, sizeof(EAXVECTOR))!=AL_NO_ERROR)
+ if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXREVERB_REFLECTIONSPAN, NULL, &Pan, sizeof(EAXVECTOR)) != AL_NO_ERROR)
OutputDebugString("Failed to set Reflections Pan\n");
}
}
lVolume = 0;
- for (i = 0; i < s_NumFXSlots; i++)
- {
- if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXFXSLOT_VOLUME, NULL, &lVolume, sizeof(long))!=AL_NO_ERROR)
+ for (i = 0; i < s_NumFXSlots; i++) {
+ if (s_eaxSet(&s_FXSlotInfo[i].FXSlotGuid, EAXFXSLOT_VOLUME, NULL, &lVolume, sizeof(long)) != AL_NO_ERROR)
OutputDebugString("Failed to set FX Slot Volume to 0\n");
}
}
@@ -6222,8 +5449,7 @@ static void UpdateEAXListener()
/*
Updates the EAX Buffer related effects on the given Source
*/
-static void UpdateEAXBuffer(channel_t *ch)
-{
+static void UpdateEAXBuffer(channel_t *ch) {
HRESULT hr;
EMPOINT EMSourcePoint;
EMPOINT EMVirtualSourcePoint;
@@ -6242,36 +5468,27 @@ static void UpdateEAXBuffer(channel_t *ch)
eaxOCProp.flOcclusionDirectRatio = EAXSOURCE_DEFAULTOCCLUSIONDIRECTRATIO;
// Convert Source co-ordinate to left-handed system
- if (ch->fixed_origin)
- {
+ if (ch->fixed_origin) {
// Converting from Quake -> DS3D (for EAGLE) ... swap Y and Z
EMSourcePoint.fX = ch->origin[0];
EMSourcePoint.fY = ch->origin[2];
EMSourcePoint.fZ = ch->origin[1];
- }
- else
- {
- if (ch->entnum == listener_number)
- {
+ } else {
+ if (ch->entnum == listener_number) {
// Source at same position as listener
// Probably won't be any Occlusion / Obstruction effect -- unless the listener is underwater
// Converting from Open AL -> DS3D (for EAGLE) ... invert Z
EMSourcePoint.fX = listener_pos[0];
EMSourcePoint.fY = listener_pos[1];
EMSourcePoint.fZ = -listener_pos[2];
- }
- else
- {
+ } else {
// Get position of Entity
// Converting from Quake -> DS3D (for EAGLE) ... swap Y and Z
- if (ch->bLooping)
- {
- EMSourcePoint.fX = loopSounds[ ch->entnum ].origin[0];
- EMSourcePoint.fY = loopSounds[ ch->entnum ].origin[2];
- EMSourcePoint.fZ = loopSounds[ ch->entnum ].origin[1];
- }
- else
- {
+ if (ch->bLooping) {
+ EMSourcePoint.fX = loopSounds[ch->entnum].origin[0];
+ EMSourcePoint.fY = loopSounds[ch->entnum].origin[2];
+ EMSourcePoint.fZ = loopSounds[ch->entnum].origin[1];
+ } else {
EMSourcePoint.fX = s_entityPosition[ch->entnum][0];
EMSourcePoint.fY = s_entityPosition[ch->entnum][2];
EMSourcePoint.fZ = s_entityPosition[ch->entnum][1];
@@ -6282,18 +5499,14 @@ static void UpdateEAXBuffer(channel_t *ch)
long lExclusion;
// Just determine what environment the source is in
- if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMSourcePoint, &lSourceID, 0)==EM_OK)
- {
+ if (s_lpEAXManager->GetListenerDynamicAttributes(0, &EMSourcePoint, &lSourceID, 0) == EM_OK) {
// See if a Slot is rendering this environment
- for (i = 0; i < s_NumFXSlots; i++)
- {
- if (s_FXSlotInfo[i].lEnvID == lSourceID)
- {
+ for (i = 0; i < s_NumFXSlots; i++) {
+ if (s_FXSlotInfo[i].lEnvID == lSourceID) {
// If the Source is not sending to this slot, then enable the send now
- if (ch->lSlotID != i)
- {
+ if (ch->lSlotID != i) {
// Set this
- if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, ch->alSource, &s_FXSlotInfo[i].FXSlotGuid, sizeof(GUID))!=AL_NO_ERROR)
+ if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_ACTIVEFXSLOTID, ch->alSource, &s_FXSlotInfo[i].FXSlotGuid, sizeof(GUID)) != AL_NO_ERROR)
OutputDebugString("UpdateEAXBuffer = failed to set ActiveFXSlotID\n");
ch->lSlotID = i;
@@ -6302,28 +5515,22 @@ static void UpdateEAXBuffer(channel_t *ch)
break;
}
}
- }
- else
- {
+ } else {
OutputDebugString("UpdateEAXBuffer::Failed to get Source environment zone\n");
}
// Add some Exclusion to sounds that are not located in the Listener's environment
- if (s_FXSlotInfo[ch->lSlotID].lEnvID == s_EnvironmentID)
- {
+ if (s_FXSlotInfo[ch->lSlotID].lEnvID == s_EnvironmentID) {
lExclusion = 0;
- if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_EXCLUSION, ch->alSource, &lExclusion, sizeof(long))!=AL_NO_ERROR)
+ if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_EXCLUSION, ch->alSource, &lExclusion, sizeof(long)) != AL_NO_ERROR)
OutputDebugString("UpdateEAXBuffer : Failed to set exclusion to 0\n");
- }
- else
- {
+ } else {
lExclusion = -1000;
- if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_EXCLUSION, ch->alSource, &lExclusion, sizeof(long))!=AL_NO_ERROR)
+ if (s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_EXCLUSION, ch->alSource, &lExclusion, sizeof(long)) != AL_NO_ERROR)
OutputDebugString("UpdateEAXBuffer : Failed to set exclusion to -1000\n");
}
- if ((ch->entchannel == CHAN_VOICE) || (ch->entchannel == CHAN_VOICE_ATTEN) || (ch->entchannel == CHAN_VOICE_GLOBAL))
- {
+ if ((ch->entchannel == CHAN_VOICE) || (ch->entchannel == CHAN_VOICE_ATTEN) || (ch->entchannel == CHAN_VOICE_GLOBAL)) {
// Remove any Occlusion + Obstruction
eaxOBProp.lObstruction = EAXSOURCE_DEFAULTOBSTRUCTION;
eaxOBProp.flObstructionLFRatio = EAXSOURCE_DEFAULTOBSTRUCTIONLFRATIO;
@@ -6333,33 +5540,23 @@ static void UpdateEAXBuffer(channel_t *ch)
eaxOCProp.flOcclusionRoomRatio = EAXSOURCE_DEFAULTOCCLUSIONROOMRATIO;
eaxOCProp.flOcclusionDirectRatio = EAXSOURCE_DEFAULTOCCLUSIONDIRECTRATIO;
- s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OBSTRUCTIONPARAMETERS,
- ch->alSource, &eaxOBProp, sizeof(EAXOBSTRUCTIONPROPERTIES));
+ s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OBSTRUCTIONPARAMETERS, ch->alSource, &eaxOBProp, sizeof(EAXOBSTRUCTIONPROPERTIES));
- s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OCCLUSIONPARAMETERS,
- ch->alSource, &eaxOCProp, sizeof(EAXOCCLUSIONPROPERTIES));
- }
- else
- {
+ s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OCCLUSIONPARAMETERS, ch->alSource, &eaxOCProp, sizeof(EAXOCCLUSIONPROPERTIES));
+ } else {
// Check for Occlusion + Obstruction
- hr = s_lpEAXManager->GetSourceDynamicAttributes(0, &EMSourcePoint, &eaxOBProp.lObstruction, &eaxOBProp.flObstructionLFRatio,
- &eaxOCProp.lOcclusion, &eaxOCProp.flOcclusionLFRatio, &eaxOCProp.flOcclusionRoomRatio, &EMVirtualSourcePoint, 0);
- if (hr == EM_OK)
- {
+ hr = s_lpEAXManager->GetSourceDynamicAttributes(0, &EMSourcePoint, &eaxOBProp.lObstruction, &eaxOBProp.flObstructionLFRatio, &eaxOCProp.lOcclusion,
+ &eaxOCProp.flOcclusionLFRatio, &eaxOCProp.flOcclusionRoomRatio, &EMVirtualSourcePoint, 0);
+ if (hr == EM_OK) {
// Set EAX effect !
- s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OBSTRUCTIONPARAMETERS,
- ch->alSource, &eaxOBProp, sizeof(EAXOBSTRUCTIONPROPERTIES));
+ s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OBSTRUCTIONPARAMETERS, ch->alSource, &eaxOBProp, sizeof(EAXOBSTRUCTIONPROPERTIES));
- s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OCCLUSIONPARAMETERS,
- ch->alSource, &eaxOCProp, sizeof(EAXOCCLUSIONPROPERTIES));
+ s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_OCCLUSIONPARAMETERS, ch->alSource, &eaxOCProp, sizeof(EAXOCCLUSIONPROPERTIES));
}
}
return;
}
-float CalcDistance(EMPOINT A, EMPOINT B)
-{
- return (float)sqrt(sqr(A.fX - B.fX)+sqr(A.fY - B.fY) + sqr(A.fZ - B.fZ));
-}
+float CalcDistance(EMPOINT A, EMPOINT B) { return (float)sqrt(sqr(A.fX - B.fX) + sqr(A.fY - B.fY) + sqr(A.fZ - B.fZ)); }
#endif
diff --git a/code/client/snd_mem.cpp b/code/client/snd_mem.cpp
index 97b4f4b4d1..37e6b5413a 100644
--- a/code/client/snd_mem.cpp
+++ b/code/client/snd_mem.cpp
@@ -42,84 +42,74 @@ WAV loading
===============================================================================
*/
-byte *data_p;
-byte *iff_end;
-byte *last_chunk;
-byte *iff_data;
-int iff_chunk_len;
-extern sfx_t s_knownSfx[];
-extern int s_numSfx;
-
-extern cvar_t *s_lip_threshold_1;
-extern cvar_t *s_lip_threshold_2;
-extern cvar_t *s_lip_threshold_3;
-extern cvar_t *s_lip_threshold_4;
-
-short GetLittleShort(void)
-{
+byte *data_p;
+byte *iff_end;
+byte *last_chunk;
+byte *iff_data;
+int iff_chunk_len;
+extern sfx_t s_knownSfx[];
+extern int s_numSfx;
+
+extern cvar_t *s_lip_threshold_1;
+extern cvar_t *s_lip_threshold_2;
+extern cvar_t *s_lip_threshold_3;
+extern cvar_t *s_lip_threshold_4;
+
+short GetLittleShort(void) {
short val = 0;
val = *data_p;
- val = (short)(val + (*(data_p+1)<<8));
+ val = (short)(val + (*(data_p + 1) << 8));
data_p += 2;
return val;
}
-int GetLittleLong(void)
-{
+int GetLittleLong(void) {
int val = 0;
val = *data_p;
- val = val + (*(data_p+1)<<8);
- val = val + (*(data_p+2)<<16);
- val = val + (*(data_p+3)<<24);
+ val = val + (*(data_p + 1) << 8);
+ val = val + (*(data_p + 2) << 16);
+ val = val + (*(data_p + 3) << 24);
data_p += 4;
return val;
}
-void FindNextChunk(const char *name)
-{
- while (1)
- {
- data_p=last_chunk;
+void FindNextChunk(const char *name) {
+ while (1) {
+ data_p = last_chunk;
- if (data_p >= iff_end)
- { // didn't find the chunk
+ if (data_p >= iff_end) { // didn't find the chunk
data_p = NULL;
return;
}
data_p += 4;
iff_chunk_len = GetLittleLong();
- if (iff_chunk_len < 0)
- {
+ if (iff_chunk_len < 0) {
data_p = NULL;
return;
}
data_p -= 8;
- last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );
+ last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1);
if (!strncmp((char *)data_p, name, 4))
return;
}
}
-void FindChunk(const char *name)
-{
+void FindChunk(const char *name) {
last_chunk = iff_data;
- FindNextChunk (name);
+ FindNextChunk(name);
}
-
-void DumpChunks(void)
-{
- char str[5];
+void DumpChunks(void) {
+ char str[5];
str[4] = 0;
- data_p=iff_data;
- do
- {
- memcpy (str, data_p, 4);
+ data_p = iff_data;
+ do {
+ memcpy(str, data_p, 4);
data_p += 4;
iff_chunk_len = GetLittleLong();
- Com_Printf ("0x%x : %s (%d)\n", (intptr_t)(data_p - 4), str, iff_chunk_len);
+ Com_Printf("0x%x : %s (%d)\n", (intptr_t)(data_p - 4), str, iff_chunk_len);
data_p += (iff_chunk_len + 1) & ~1;
} while (data_p < iff_end);
}
@@ -129,12 +119,11 @@ void DumpChunks(void)
GetWavinfo
============
*/
-wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength)
-{
- wavinfo_t info;
- int samples;
+wavinfo_t GetWavinfo(const char *name, byte *wav, int wavlength) {
+ wavinfo_t info;
+ int samples;
- memset (&info, 0, sizeof(info));
+ memset(&info, 0, sizeof(info));
if (!wav)
return info;
@@ -142,21 +131,19 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength)
iff_data = wav;
iff_end = wav + wavlength;
-// find "RIFF" chunk
+ // find "RIFF" chunk
FindChunk("RIFF");
- if (!(data_p && !strncmp((char *)data_p+8, "WAVE", 4)))
- {
+ if (!(data_p && !strncmp((char *)data_p + 8, "WAVE", 4))) {
Com_Printf("Missing RIFF/WAVE chunks\n");
return info;
}
-// get "fmt " chunk
+ // get "fmt " chunk
iff_data = data_p + 12;
-// DumpChunks ();
+ // DumpChunks ();
FindChunk("fmt ");
- if (!data_p)
- {
+ if (!data_p) {
Com_Printf("Missing fmt chunk\n");
return info;
}
@@ -164,42 +151,35 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength)
info.format = GetLittleShort();
info.channels = GetLittleShort();
info.rate = GetLittleLong();
- data_p += 4+2;
+ data_p += 4 + 2;
info.width = GetLittleShort() / 8;
- if (info.format != 1)
- {
+ if (info.format != 1) {
Com_Printf("Microsoft PCM format only\n");
return info;
}
-
-// find data chunk
+ // find data chunk
FindChunk("data");
- if (!data_p)
- {
+ if (!data_p) {
Com_Printf("Missing data chunk\n");
return info;
}
data_p += 4;
- samples = GetLittleLong () / info.width;
+ samples = GetLittleLong() / info.width;
- if (info.samples)
- {
+ if (info.samples) {
if (samples < info.samples)
- Com_Error (ERR_DROP, "Sound %s has a bad loop length", name);
- }
- else
+ Com_Error(ERR_DROP, "Sound %s has a bad loop length", name);
+ } else
info.samples = samples;
info.dataofs = data_p - wav;
-
return info;
}
-
/*
================
ResampleSfx
@@ -207,36 +187,34 @@ ResampleSfx
resample / decimate to the current source rate
================
*/
-void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData)
-{
- int iOutCount;
- int iSrcSample;
- float fStepScale;
- int i;
- int iSample;
- unsigned int uiSampleFrac, uiFracStep; // uiSampleFrac MUST be unsigned, or large samples (eg music tracks) crash
+void ResampleSfx(sfx_t *sfx, int iInRate, int iInWidth, byte *pData) {
+ int iOutCount;
+ int iSrcSample;
+ float fStepScale;
+ int i;
+ int iSample;
+ unsigned int uiSampleFrac, uiFracStep; // uiSampleFrac MUST be unsigned, or large samples (eg music tracks) crash
- fStepScale = (float)iInRate / dma.speed; // this is usually 0.5, 1, or 2
+ fStepScale = (float)iInRate / dma.speed; // this is usually 0.5, 1, or 2
// When stepscale is > 1 (we're downsampling), we really ought to run a low pass filter on the samples
iOutCount = (int)(sfx->iSoundLengthInSamples / fStepScale);
sfx->iSoundLengthInSamples = iOutCount;
- sfx->pSoundData = (short *) SND_malloc( sfx->iSoundLengthInSamples*2 ,sfx );
+ sfx->pSoundData = (short *)SND_malloc(sfx->iSoundLengthInSamples * 2, sfx);
- sfx->fVolRange = 0;
- uiSampleFrac = 0;
- uiFracStep = (int)(fStepScale*256);
+ sfx->fVolRange = 0;
+ uiSampleFrac = 0;
+ uiFracStep = (int)(fStepScale * 256);
- for (i=0 ; iiSoundLengthInSamples ; i++)
- {
+ for (i = 0; i < sfx->iSoundLengthInSamples; i++) {
iSrcSample = uiSampleFrac >> 8;
uiSampleFrac += uiFracStep;
if (iInWidth == 2) {
- iSample = LittleShort ( ((short *)pData)[iSrcSample] );
+ iSample = LittleShort(((short *)pData)[iSrcSample]);
} else {
- iSample = (unsigned int)( (unsigned char)(pData[iSrcSample]) - 128) << 8;
+ iSample = (unsigned int)((unsigned char)(pData[iSrcSample]) - 128) << 8;
}
sfx->pSoundData[i] = (short)iSample;
@@ -245,71 +223,57 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData)
//
if (iSample < 0)
iSample = -iSample;
- if (sfx->fVolRange < (iSample >> 8) )
- {
- sfx->fVolRange = iSample >> 8;
+ if (sfx->fVolRange < (iSample >> 8)) {
+ sfx->fVolRange = iSample >> 8;
}
}
}
-
//=============================================================================
+void S_LoadSound_Finalize(wavinfo_t *info, sfx_t *sfx, byte *data) {
+ // float stepscale = (float)info->rate / dma.speed;
+ // int len = (int)(info->samples / stepscale);
-void S_LoadSound_Finalize(wavinfo_t *info, sfx_t *sfx, byte *data)
-{
- //float stepscale = (float)info->rate / dma.speed;
- //int len = (int)(info->samples / stepscale);
-
- //len *= info->width;
+ // len *= info->width;
sfx->eSoundCompressionMethod = ct_16;
- sfx->iSoundLengthInSamples = info->samples;
- ResampleSfx( sfx, info->rate, info->width, data + info->dataofs );
+ sfx->iSoundLengthInSamples = info->samples;
+ ResampleSfx(sfx, info->rate, info->width, data + info->dataofs);
}
-
-
-
-
// maybe I'm re-inventing the wheel, here, but I can't see any functions that already do this, so...
//
-char *Filename_WithoutPath(const char *psFilename)
-{
- static char sString[MAX_QPATH]; // !!
- const char *p = strrchr(psFilename,'\\');
+char *Filename_WithoutPath(const char *psFilename) {
+ static char sString[MAX_QPATH]; // !!
+ const char *p = strrchr(psFilename, '\\');
- if (!p++)
- p=psFilename;
+ if (!p++)
+ p = psFilename;
- strcpy(sString,p);
+ strcpy(sString, p);
return sString;
-
}
// returns (eg) "\dir\name" for "\dir\name.bmp"
//
-char *Filename_WithoutExt(const char *psFilename)
-{
- static char sString[MAX_QPATH]; // !
+char *Filename_WithoutExt(const char *psFilename) {
+ static char sString[MAX_QPATH]; // !
- strcpy(sString,psFilename);
+ strcpy(sString, psFilename);
- char *p = strrchr(sString,'.');
- char *p2= strrchr(sString,'\\');
+ char *p = strrchr(sString, '.');
+ char *p2 = strrchr(sString, '\\');
// special check, make sure the first suffix we found from the end wasn't just a directory suffix (eg on a path'd filename with no extension anyway)
//
- if (p && (p2==0 || (p2 && p>p2)))
- *p=0;
+ if (p && (p2 == 0 || (p2 && p > p2)))
+ *p = 0;
return sString;
-
}
-
-
int iFilesFound;
int iFilesUpdated;
int iErrors;
@@ -317,50 +281,44 @@ qboolean qbForceRescan;
qboolean qbForceStereo;
std::string strErrors;
-void R_CheckMP3s( const char *psDir )
-{
-// Com_Printf(va("Scanning Dir: %s\n",psDir));
- Com_Printf("."); // stops useful info scrolling off screen
+void R_CheckMP3s(const char *psDir) {
+ // Com_Printf(va("Scanning Dir: %s\n",psDir));
+ Com_Printf("."); // stops useful info scrolling off screen
- char **sysFiles, **dirFiles;
- int numSysFiles, i, numdirs;
+ char **sysFiles, **dirFiles;
+ int numSysFiles, i, numdirs;
- dirFiles = FS_ListFiles( psDir, "/", &numdirs);
- if (numdirs > 2)
- {
- for (i=2;i 2) {
+ for (i = 2; i < numdirs; i++) {
+ char sDirName[MAX_QPATH];
sprintf(sDirName, "%s\\%s", psDir, dirFiles[i]);
R_CheckMP3s(sDirName);
}
}
- sysFiles = FS_ListFiles( psDir, ".mp3", &numSysFiles );
- for(i=0; ifVolRange;
// free sfx->data...
//
{
- #ifndef INT_MIN
- #define INT_MIN (-2147483647 - 1) /* minimum (signed) int value */
- #endif
+#ifndef INT_MIN
+#define INT_MIN (-2147483647 - 1) /* minimum (signed) int value */
+#endif
//
- pSFX->iLastTimeUsed = INT_MIN; // force this to be oldest sound file, therefore disposable...
+ pSFX->iLastTimeUsed = INT_MIN; // force this to be oldest sound file, therefore disposable...
pSFX->bInMemory = true;
- SND_FreeOldestSound(); // ... and do the disposal
+ SND_FreeOldestSound(); // ... and do the disposal
// now set our temp SFX struct back to default name so nothing else accidentally uses it...
//
@@ -429,7 +385,7 @@ void R_CheckMP3s( const char *psDir )
pSFX->bDefaultSound = false;
}
-// OutputDebugString(va("File: \"%s\" MaxVol %f\n",sFilename,pSFX->fVolRange));
+ // OutputDebugString(va("File: \"%s\" MaxVol %f\n",sFilename,pSFX->fVolRange));
// other stuff...
//
@@ -438,90 +394,74 @@ void R_CheckMP3s( const char *psDir )
// well, time to update the file now...
//
- fileHandle_t f = FS_FOpenFileWrite( sFilename );
- if (f)
- {
+ fileHandle_t f = FS_FOpenFileWrite(sFilename);
+ if (f) {
// write the file back out, but omitting the tag if there was one...
//
- int iWritten = FS_Write(pbData, iSize-(pTAG?sizeof(*pTAG):0), f);
+ int iWritten = FS_Write(pbData, iSize - (pTAG ? sizeof(*pTAG) : 0), f);
- if (iWritten)
- {
+ if (iWritten) {
// make up a new tag if we didn't find one in the original file...
//
id3v1_1 TAG;
- if (!pTAG)
- {
+ if (!pTAG) {
pTAG = &TAG;
- memset(&TAG,0,sizeof(TAG));
- strncpy(pTAG->id,"TAG",3);
+ memset(&TAG, 0, sizeof(TAG));
+ strncpy(pTAG->id, "TAG", 3);
}
- strncpy(pTAG->title, Filename_WithoutPath(Filename_WithoutExt(sFilename)), sizeof(pTAG->title));
- strncpy(pTAG->artist, "Raven Software", sizeof(pTAG->artist) );
- strncpy(pTAG->year, "2002", sizeof(pTAG->year) );
- strncpy(pTAG->comment, va("%s %g",sKEY_MAXVOL,fMaxVol), sizeof(pTAG->comment) );
- strncpy(pTAG->album, va("%s %d",sKEY_UNCOMP,iActualUnpackedSize),sizeof(pTAG->album) );
+ strncpy(pTAG->title, Filename_WithoutPath(Filename_WithoutExt(sFilename)), sizeof(pTAG->title));
+ strncpy(pTAG->artist, "Raven Software", sizeof(pTAG->artist));
+ strncpy(pTAG->year, "2002", sizeof(pTAG->year));
+ strncpy(pTAG->comment, va("%s %g", sKEY_MAXVOL, fMaxVol), sizeof(pTAG->comment));
+ strncpy(pTAG->album, va("%s %d", sKEY_UNCOMP, iActualUnpackedSize), sizeof(pTAG->album));
- if (FS_Write( pTAG, sizeof(*pTAG), f )) // NZ = success
+ if (FS_Write(pTAG, sizeof(*pTAG), f)) // NZ = success
{
iFilesUpdated++;
- }
- else
- {
- Com_Printf("*********** Failed write to file \"%s\"!\n",sFilename);
+ } else {
+ Com_Printf("*********** Failed write to file \"%s\"!\n", sFilename);
iErrors++;
- strErrors += va("Failed to write: \"%s\"\n",sFilename);
+ strErrors += va("Failed to write: \"%s\"\n", sFilename);
}
- }
- else
- {
- Com_Printf("*********** Failed write to file \"%s\"!\n",sFilename);
+ } else {
+ Com_Printf("*********** Failed write to file \"%s\"!\n", sFilename);
iErrors++;
- strErrors += va("Failed to write: \"%s\"\n",sFilename);
+ strErrors += va("Failed to write: \"%s\"\n", sFilename);
}
- FS_FCloseFile( f );
- }
- else
- {
- Com_Printf("*********** Failed to re-open for write \"%s\"!\n",sFilename);
+ FS_FCloseFile(f);
+ } else {
+ Com_Printf("*********** Failed to re-open for write \"%s\"!\n", sFilename);
iErrors++;
- strErrors += va("Failed to re-open for write: \"%s\"\n",sFilename);
+ strErrors += va("Failed to re-open for write: \"%s\"\n", sFilename);
}
+ } else {
+ Com_Error(ERR_DROP, "******* This MP3 should be deleted: \"%s\"\n", sFilename);
}
- else
- {
- Com_Error(ERR_DROP, "******* This MP3 should be deleted: \"%s\"\n",sFilename);
- }
- }
- else
- {
- Com_Printf("*********** File was not a valid MP3!: \"%s\"\n",sFilename);
+ } else {
+ Com_Printf("*********** File was not a valid MP3!: \"%s\"\n", sFilename);
iErrors++;
- strErrors += va("Not game-legal MP3 format: \"%s\"\n",sFilename);
+ strErrors += va("Not game-legal MP3 format: \"%s\"\n", sFilename);
}
- }
- else
- {
+ } else {
Com_Printf(" ( OK )\n");
}
- FS_FreeFile( pbData );
+ FS_FreeFile(pbData);
}
}
- FS_FreeFileList( sysFiles );
- FS_FreeFileList( dirFiles );
+ FS_FreeFileList(sysFiles);
+ FS_FreeFileList(dirFiles);
}
// this console-function is for development purposes, and makes sure that sound/*.mp3 /s have tags in them
// specifying stuff like their max volume (and uncompressed size) etc...
//
-void S_MP3_CalcVols_f( void )
-{
+void S_MP3_CalcVols_f(void) {
char sStartDir[MAX_QPATH] = {"sound"};
const char sUsage[] = "Usage: mp3_calcvols [-rescan] \ne.g. mp3_calcvols sound/chars";
- if (Cmd_Argc() == 1 || Cmd_Argc()>4) // 3 optional arguments
+ if (Cmd_Argc() == 1 || Cmd_Argc() > 4) // 3 optional arguments
{
Com_Printf(sUsage);
return;
@@ -529,29 +469,20 @@ void S_MP3_CalcVols_f( void )
S_StopAllSounds();
-
qbForceRescan = qfalse;
qbForceStereo = qfalse;
- iFilesFound = 0;
- iFilesUpdated = 0;
- iErrors = 0;
- strErrors = "";
-
- for (int i=1; iinteger)
- {
+ if (com_buildScript->integer) {
fileHandle_t hFile;
- //German
- strncpy(psVoice,"chr_d",5); // same number of letters as "chars"
- FS_FOpenFileRead(psFilename, &hFile, qfalse); //cache the wav
- if (!hFile)
- {
- strcpy(&psFilename[iNameStrlen-3],"mp3"); //not there try mp3
- FS_FOpenFileRead(psFilename, &hFile, qfalse); //cache the mp3
+ // German
+ strncpy(psVoice, "chr_d", 5); // same number of letters as "chars"
+ FS_FOpenFileRead(psFilename, &hFile, qfalse); // cache the wav
+ if (!hFile) {
+ strcpy(&psFilename[iNameStrlen - 3], "mp3"); // not there try mp3
+ FS_FOpenFileRead(psFilename, &hFile, qfalse); // cache the mp3
}
- if (hFile)
- {
+ if (hFile) {
FS_FCloseFile(hFile);
}
- strcpy(&psFilename[iNameStrlen-3],"wav"); //put it back to wav
-
- //French
- strncpy(psVoice,"chr_f",5); // same number of letters as "chars"
- FS_FOpenFileRead(psFilename, &hFile, qfalse); //cache the wav
- if (!hFile)
- {
- strcpy(&psFilename[iNameStrlen-3],"mp3"); //not there try mp3
- FS_FOpenFileRead(psFilename, &hFile, qfalse); //cache the mp3
+ strcpy(&psFilename[iNameStrlen - 3], "wav"); // put it back to wav
+
+ // French
+ strncpy(psVoice, "chr_f", 5); // same number of letters as "chars"
+ FS_FOpenFileRead(psFilename, &hFile, qfalse); // cache the wav
+ if (!hFile) {
+ strcpy(&psFilename[iNameStrlen - 3], "mp3"); // not there try mp3
+ FS_FOpenFileRead(psFilename, &hFile, qfalse); // cache the mp3
}
- if (hFile)
- {
+ if (hFile) {
FS_FCloseFile(hFile);
}
- strcpy(&psFilename[iNameStrlen-3],"wav"); //put it back to wav
-
- //Spanish
- strncpy(psVoice,"chr_e",5); // same number of letters as "chars"
- FS_FOpenFileRead(psFilename, &hFile, qfalse); //cache the wav
- if (!hFile)
- {
- strcpy(&psFilename[iNameStrlen-3],"mp3"); //not there try mp3
- FS_FOpenFileRead(psFilename, &hFile, qfalse); //cache the mp3
+ strcpy(&psFilename[iNameStrlen - 3], "wav"); // put it back to wav
+
+ // Spanish
+ strncpy(psVoice, "chr_e", 5); // same number of letters as "chars"
+ FS_FOpenFileRead(psFilename, &hFile, qfalse); // cache the wav
+ if (!hFile) {
+ strcpy(&psFilename[iNameStrlen - 3], "mp3"); // not there try mp3
+ FS_FOpenFileRead(psFilename, &hFile, qfalse); // cache the mp3
}
- if (hFile)
- {
+ if (hFile) {
FS_FCloseFile(hFile);
}
- strcpy(&psFilename[iNameStrlen-3],"wav"); //put it back to wav
+ strcpy(&psFilename[iNameStrlen - 3], "wav"); // put it back to wav
- strncpy(psVoice,"chars",5); //put it back to chars
+ strncpy(psVoice, "chars", 5); // put it back to chars
}
// account for foreign voices...
//
- extern cvar_t* s_language;
- if (s_language && Q_stricmp("DEUTSCH",s_language->string)==0)
- {
- strncpy(psVoice,"chr_d",5); // same number of letters as "chars"
- }
- else if (s_language && Q_stricmp("FRANCAIS",s_language->string)==0)
- {
- strncpy(psVoice,"chr_f",5); // same number of letters as "chars"
- }
- else if (s_language && Q_stricmp("ESPANOL",s_language->string)==0)
- {
- strncpy(psVoice,"chr_e",5); // same number of letters as "chars"
- }
- else
- {
- psVoice = NULL; // use this ptr as a flag as to whether or not we substituted with a foreign version
+ extern cvar_t *s_language;
+ if (s_language && Q_stricmp("DEUTSCH", s_language->string) == 0) {
+ strncpy(psVoice, "chr_d", 5); // same number of letters as "chars"
+ } else if (s_language && Q_stricmp("FRANCAIS", s_language->string) == 0) {
+ strncpy(psVoice, "chr_f", 5); // same number of letters as "chars"
+ } else if (s_language && Q_stricmp("ESPANOL", s_language->string) == 0) {
+ strncpy(psVoice, "chr_e", 5); // same number of letters as "chars"
+ } else {
+ psVoice = NULL; // use this ptr as a flag as to whether or not we substituted with a foreign version
}
}
- *piSize = FS_ReadFile( psFilename, (void **)pData ); // try WAV
- if ( !*pData ) {
- psFilename[iNameStrlen-3] = 'm';
- psFilename[iNameStrlen-2] = 'p';
- psFilename[iNameStrlen-1] = '3';
- *piSize = FS_ReadFile( psFilename, (void **)pData ); // try MP3
+ *piSize = FS_ReadFile(psFilename, (void **)pData); // try WAV
+ if (!*pData) {
+ psFilename[iNameStrlen - 3] = 'm';
+ psFilename[iNameStrlen - 2] = 'p';
+ psFilename[iNameStrlen - 1] = '3';
+ *piSize = FS_ReadFile(psFilename, (void **)pData); // try MP3
- if ( !*pData )
- {
- //hmmm, not found, ok, maybe we were trying a foreign noise ("arghhhhh.mp3" that doesn't matter?) but it
- // was missing? Can't tell really, since both types are now in sound/chars. Oh well, fall back to English for now...
+ if (!*pData) {
+ // hmmm, not found, ok, maybe we were trying a foreign noise ("arghhhhh.mp3" that doesn't matter?) but it
+ // was missing? Can't tell really, since both types are now in sound/chars. Oh well, fall back to English for now...
- if (psVoice) // were we trying to load foreign?
+ if (psVoice) // were we trying to load foreign?
{
// yep, so fallback to re-try the english...
//
#ifndef FINAL_BUILD
- Com_Printf(S_COLOR_YELLOW "Foreign file missing: \"%s\"! (using English...)\n",psFilename);
+ Com_Printf(S_COLOR_YELLOW "Foreign file missing: \"%s\"! (using English...)\n", psFilename);
#endif
- strncpy(psVoice,"chars",5);
-
- psFilename[iNameStrlen-3] = 'w';
- psFilename[iNameStrlen-2] = 'a';
- psFilename[iNameStrlen-1] = 'v';
- *piSize = FS_ReadFile( psFilename, (void **)pData ); // try English WAV
- if ( !*pData )
- {
- psFilename[iNameStrlen-3] = 'm';
- psFilename[iNameStrlen-2] = 'p';
- psFilename[iNameStrlen-1] = '3';
- *piSize = FS_ReadFile( psFilename, (void **)pData ); // try English MP3
+ strncpy(psVoice, "chars", 5);
+
+ psFilename[iNameStrlen - 3] = 'w';
+ psFilename[iNameStrlen - 2] = 'a';
+ psFilename[iNameStrlen - 1] = 'v';
+ *piSize = FS_ReadFile(psFilename, (void **)pData); // try English WAV
+ if (!*pData) {
+ psFilename[iNameStrlen - 3] = 'm';
+ psFilename[iNameStrlen - 2] = 'p';
+ psFilename[iNameStrlen - 1] = '3';
+ *piSize = FS_ReadFile(psFilename, (void **)pData); // try English MP3
}
}
- if (!*pData)
- {
- return qfalse; // sod it, give up...
+ if (!*pData) {
+ return qfalse; // sod it, give up...
}
}
}
@@ -714,10 +621,9 @@ static qboolean S_LoadSound_FileLoadAndNameAdjuster(char *psFilename, byte **pDa
//
#define SOUND_CHARS_DIR "sound/chars/"
#define SOUND_CHARS_DIR_LENGTH 12 // strlen( SOUND_CHARS_DIR )
-static qboolean S_LoadSound_DirIsAllowedToKeepMP3s( const char *psFilename )
-{
- if ( Q_stricmpn( psFilename, SOUND_CHARS_DIR, SOUND_CHARS_DIR_LENGTH ) == 0 )
- return qtrue; // found a dir that's allowed to keep MP3s
+static qboolean S_LoadSound_DirIsAllowedToKeepMP3s(const char *psFilename) {
+ if (Q_stricmpn(psFilename, SOUND_CHARS_DIR, SOUND_CHARS_DIR_LENGTH) == 0)
+ return qtrue; // found a dir that's allowed to keep MP3s
return qfalse;
}
@@ -731,119 +637,103 @@ of a forced fallback of a player specific sound (or of a wav/mp3 substitution no
==============
*/
qboolean gbInsideLoadSound = qfalse;
-static qboolean S_LoadSound_Actual( sfx_t *sfx )
-{
- byte *data;
- short *samples;
- wavinfo_t info;
- int size;
- char *psExt;
- char sLoadName[MAX_QPATH];
-
- int len = strlen(sfx->sSoundName);
- if (len<5)
- {
+static qboolean S_LoadSound_Actual(sfx_t *sfx) {
+ byte *data;
+ short *samples;
+ wavinfo_t info;
+ int size;
+ char *psExt;
+ char sLoadName[MAX_QPATH];
+
+ int len = strlen(sfx->sSoundName);
+ if (len < 5) {
return qfalse;
}
// player specific sounds are never directly loaded...
//
- if ( sfx->sSoundName[0] == '*') {
+ if (sfx->sSoundName[0] == '*') {
return qfalse;
}
// make up a local filename to try wav/mp3 substitutes...
//
Q_strncpyz(sLoadName, sfx->sSoundName, sizeof(sLoadName));
- Q_strlwr( sLoadName );
+ Q_strlwr(sLoadName);
//
// Ensure name has an extension (which it must have, but you never know), and get ptr to it...
//
- psExt = &sLoadName[strlen(sLoadName)-4];
- if (*psExt != '.')
- {
- //Com_Printf( "WARNING: soundname '%s' does not have 3-letter extension\n",sLoadName);
- COM_DefaultExtension(sLoadName,sizeof(sLoadName),".wav"); // so psExt below is always valid
- psExt = &sLoadName[strlen(sLoadName)-4];
+ psExt = &sLoadName[strlen(sLoadName) - 4];
+ if (*psExt != '.') {
+ // Com_Printf( "WARNING: soundname '%s' does not have 3-letter extension\n",sLoadName);
+ COM_DefaultExtension(sLoadName, sizeof(sLoadName), ".wav"); // so psExt below is always valid
+ psExt = &sLoadName[strlen(sLoadName) - 4];
len = strlen(sLoadName);
}
- if (!S_LoadSound_FileLoadAndNameAdjuster(sLoadName, &data, &size, len))
- {
+ if (!S_LoadSound_FileLoadAndNameAdjuster(sLoadName, &data, &size, len)) {
return qfalse;
}
SND_TouchSFX(sfx);
-//=========
- if (Q_stricmpn(psExt,".mp3",4)==0)
- {
+ //=========
+ if (Q_stricmpn(psExt, ".mp3", 4) == 0) {
// load MP3 file instead...
//
- if (MP3_IsValid(sLoadName,data, size, qfalse))
- {
- int iRawPCMDataSize = MP3_GetUnpackedSize(sLoadName,data,size,qfalse,qfalse);
-
- if (S_LoadSound_DirIsAllowedToKeepMP3s(sfx->sSoundName) // NOT sLoadName, this uses original un-languaged name
- &&
- MP3Stream_InitFromFile(sfx, data, size, sLoadName, iRawPCMDataSize + 2304 /* + 1 MP3 frame size, jic */,qfalse)
- )
- {
-// Com_DPrintf("(Keeping file \"%s\" as MP3)\n",sLoadName);
+ if (MP3_IsValid(sLoadName, data, size, qfalse)) {
+ int iRawPCMDataSize = MP3_GetUnpackedSize(sLoadName, data, size, qfalse, qfalse);
+
+ if (S_LoadSound_DirIsAllowedToKeepMP3s(sfx->sSoundName) // NOT sLoadName, this uses original un-languaged name
+ && MP3Stream_InitFromFile(sfx, data, size, sLoadName, iRawPCMDataSize + 2304 /* + 1 MP3 frame size, jic */, qfalse)) {
+ // Com_DPrintf("(Keeping file \"%s\" as MP3)\n",sLoadName);
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
+ if (s_UseOpenAL) {
// Create space for lipsync data (4 lip sync values per streaming AL buffer)
- if (strstr(sfx->sSoundName, "chars") )
+ if (strstr(sfx->sSoundName, "chars"))
sfx->lipSyncData = (char *)Z_Malloc(16, TAG_SND_RAWDATA, qfalse);
else
sfx->lipSyncData = NULL;
}
#endif
- }
- else
- {
+ } else {
// small file, not worth keeping as MP3 since it would increase in size (with MP3 header etc)...
//
- Com_DPrintf("S_LoadSound: Unpacking MP3 file \"%s\" to wav.\n",sLoadName);
+ Com_DPrintf("S_LoadSound: Unpacking MP3 file \"%s\" to wav.\n", sLoadName);
//
// unpack and convert into WAV...
//
{
- byte *pbUnpackBuffer = (byte *) Z_Malloc( iRawPCMDataSize+10 +2304 /* */, TAG_TEMP_WORKSPACE, qfalse ); // won't return if fails
+ byte *pbUnpackBuffer = (byte *)Z_Malloc(iRawPCMDataSize + 10 + 2304 /* */, TAG_TEMP_WORKSPACE, qfalse); // won't return if fails
{
- int iResultBytes = MP3_UnpackRawPCM( sLoadName, data, size, pbUnpackBuffer, qfalse );
+ int iResultBytes = MP3_UnpackRawPCM(sLoadName, data, size, pbUnpackBuffer, qfalse);
- if (iResultBytes!= iRawPCMDataSize){
- Com_Printf(S_COLOR_YELLOW"**** MP3 %s final unpack size %d different to previous value %d\n",sLoadName,iResultBytes,iRawPCMDataSize);
- //assert (iResultBytes == iRawPCMDataSize);
+ if (iResultBytes != iRawPCMDataSize) {
+ Com_Printf(S_COLOR_YELLOW "**** MP3 %s final unpack size %d different to previous value %d\n", sLoadName, iResultBytes,
+ iRawPCMDataSize);
+ // assert (iResultBytes == iRawPCMDataSize);
}
-
// fake up a WAV structure so I can use the other post-load sound code such as volume calc for lip-synching
//
// (this is a bit crap really, but it lets me drop through into existing code)...
//
- MP3_FakeUpWAVInfo( sLoadName, data, size, iResultBytes,
- // these params are all references...
- info.format, info.rate, info.width, info.channels, info.samples, info.dataofs,
- qfalse
- );
+ MP3_FakeUpWAVInfo(sLoadName, data, size, iResultBytes,
+ // these params are all references...
+ info.format, info.rate, info.width, info.channels, info.samples, info.dataofs, qfalse);
- S_LoadSound_Finalize(&info,sfx,pbUnpackBuffer);
+ S_LoadSound_Finalize(&info, sfx, pbUnpackBuffer);
#ifdef Q3_BIG_ENDIAN
// the MP3 decoder returns the samples in the correct endianness, but ResampleSfx byteswaps them,
// so we have to swap them again...
- sfx->fVolRange = 0;
+ sfx->fVolRange = 0;
- for (int i = 0; i < sfx->iSoundLengthInSamples; i++)
- {
+ for (int i = 0; i < sfx->iSoundLengthInSamples; i++) {
sfx->pSoundData[i] = LittleShort(sfx->pSoundData[i]);
// C++11 defines double abs(short) which is not what we want here,
// because double >> int is not defined. Force interpretation as int
- if (sfx->fVolRange < (abs(static_cast(sfx->pSoundData[i])) >> 8))
- {
+ if (sfx->fVolRange < (abs(static_cast(sfx->pSoundData[i])) >> 8)) {
sfx->fVolRange = abs(static_cast(sfx->pSoundData[i])) >> 8;
}
}
@@ -851,14 +741,11 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
// Open AL
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
- if (strstr(sfx->sSoundName, "chars"))
- {
+ if (s_UseOpenAL) {
+ if (strstr(sfx->sSoundName, "chars")) {
sfx->lipSyncData = (char *)Z_Malloc((sfx->iSoundLengthInSamples / 1000) + 1, TAG_SND_RAWDATA, qfalse);
S_PreProcessLipSync(sfx);
- }
- else
+ } else
sfx->lipSyncData = NULL;
// Clear Open AL Error state
@@ -867,12 +754,10 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
// Generate AL Buffer
ALuint Buffer;
alGenBuffers(1, &Buffer);
- if (alGetError() == AL_NO_ERROR)
- {
+ if (alGetError() == AL_NO_ERROR) {
// Copy audio data to AL Buffer
- alBufferData(Buffer, AL_FORMAT_MONO16, sfx->pSoundData, sfx->iSoundLengthInSamples*2, 22050);
- if (alGetError() == AL_NO_ERROR)
- {
+ alBufferData(Buffer, AL_FORMAT_MONO16, sfx->pSoundData, sfx->iSoundLengthInSamples * 2, 22050);
+ if (alGetError() == AL_NO_ERROR) {
sfx->Buffer = Buffer;
Z_Free(sfx->pSoundData);
sfx->pSoundData = NULL;
@@ -885,53 +770,46 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
}
}
}
- }
- else
- {
+ } else {
// MP3_IsValid() will already have printed any errors via Com_Printf at this point...
//
- FS_FreeFile (data);
+ FS_FreeFile(data);
return qfalse;
}
- }
- else
- {
+ } else {
// loading a WAV, presumably...
-//=========
+ //=========
- info = GetWavinfo( sLoadName, data, size );
- if ( info.channels != 1 ) {
- Com_Printf ("%s is a stereo wav file\n", sLoadName);
- FS_FreeFile (data);
+ info = GetWavinfo(sLoadName, data, size);
+ if (info.channels != 1) {
+ Com_Printf("%s is a stereo wav file\n", sLoadName);
+ FS_FreeFile(data);
return qfalse;
}
-/* if ( info.width == 1 ) {
- Com_Printf(S_COLOR_YELLOW "WARNING: %s is a 8 bit wav file\n", sLoadName);
- }
+ /* if ( info.width == 1 ) {
+ Com_Printf(S_COLOR_YELLOW "WARNING: %s is a 8 bit wav file\n", sLoadName);
+ }
- if ( info.rate != 22050 ) {
- Com_Printf(S_COLOR_YELLOW "WARNING: %s is not a 22kHz wav file\n", sLoadName);
- }
-*/
+ if ( info.rate != 22050 ) {
+ Com_Printf(S_COLOR_YELLOW "WARNING: %s is not a 22kHz wav file\n", sLoadName);
+ }
+ */
samples = (short *)Z_Malloc(info.samples * sizeof(short) * 2, TAG_TEMP_WORKSPACE, qfalse);
sfx->eSoundCompressionMethod = ct_16;
- sfx->iSoundLengthInSamples = info.samples;
+ sfx->iSoundLengthInSamples = info.samples;
sfx->pSoundData = NULL;
- ResampleSfx( sfx, info.rate, info.width, data + info.dataofs );
+ ResampleSfx(sfx, info.rate, info.width, data + info.dataofs);
// Open AL
#ifdef USE_OPENAL
- if (s_UseOpenAL)
- {
- if ((strstr(sfx->sSoundName, "chars")) || (strstr(sfx->sSoundName, "CHARS")))
- {
+ if (s_UseOpenAL) {
+ if ((strstr(sfx->sSoundName, "chars")) || (strstr(sfx->sSoundName, "CHARS"))) {
sfx->lipSyncData = (char *)Z_Malloc((sfx->iSoundLengthInSamples / 1000) + 1, TAG_SND_RAWDATA, qfalse);
S_PreProcessLipSync(sfx);
- }
- else
+ } else
sfx->lipSyncData = NULL;
// Clear Open AL Error State
@@ -940,12 +818,10 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
// Generate AL Buffer
ALuint Buffer;
alGenBuffers(1, &Buffer);
- if (alGetError() == AL_NO_ERROR)
- {
+ if (alGetError() == AL_NO_ERROR) {
// Copy audio data to AL Buffer
- alBufferData(Buffer, AL_FORMAT_MONO16, sfx->pSoundData, sfx->iSoundLengthInSamples*2, 22050);
- if (alGetError() == AL_NO_ERROR)
- {
+ alBufferData(Buffer, AL_FORMAT_MONO16, sfx->pSoundData, sfx->iSoundLengthInSamples * 2, 22050);
+ if (alGetError() == AL_NO_ERROR) {
// Store AL Buffer in sfx struct, and release sample data
sfx->Buffer = Buffer;
Z_Free(sfx->pSoundData);
@@ -958,22 +834,20 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
Z_Free(samples);
}
- FS_FreeFile( data );
+ FS_FreeFile(data);
return qtrue;
}
-
// wrapper function for above so I can guarantee that we don't attempt any audio-dumping during this call because
// of a z_malloc() fail recovery...
//
-qboolean S_LoadSound( sfx_t *sfx )
-{
- gbInsideLoadSound = qtrue; // !!!!!!!!!!!!!
+qboolean S_LoadSound(sfx_t *sfx) {
+ gbInsideLoadSound = qtrue; // !!!!!!!!!!!!!
- qboolean bReturn = S_LoadSound_Actual( sfx );
+ qboolean bReturn = S_LoadSound_Actual(sfx);
- gbInsideLoadSound = qfalse; // !!!!!!!!!!!!!
+ gbInsideLoadSound = qfalse; // !!!!!!!!!!!!!
return bReturn;
}
@@ -982,29 +856,24 @@ qboolean S_LoadSound( sfx_t *sfx )
/*
Precalculate the lipsync values for the whole sample
*/
-void S_PreProcessLipSync(sfx_t *sfx)
-{
+void S_PreProcessLipSync(sfx_t *sfx) {
int i, j;
int sample;
int sampleTotal = 0;
j = 0;
- for (i = 0; i < sfx->iSoundLengthInSamples; i += 100)
- {
+ for (i = 0; i < sfx->iSoundLengthInSamples; i += 100) {
sample = LittleShort(sfx->pSoundData[i]);
sample = sample >> 8;
sampleTotal += sample * sample;
- if (((i + 100) % 1000) == 0)
- {
+ if (((i + 100) % 1000) == 0) {
sampleTotal /= 10;
- if (sampleTotal < sfx->fVolRange * s_lip_threshold_1->value)
- {
+ if (sampleTotal < sfx->fVolRange * s_lip_threshold_1->value) {
// tell the scripts that are relying on this that we are still going, but actually silent right now.
sample = -1;
- }
- else if (sampleTotal < sfx->fVolRange * s_lip_threshold_2->value)
+ } else if (sampleTotal < sfx->fVolRange * s_lip_threshold_2->value)
sample = 1;
else if (sampleTotal < sfx->fVolRange * s_lip_threshold_3->value)
sample = 2;
@@ -1032,12 +901,10 @@ void S_PreProcessLipSync(sfx_t *sfx)
else
sampleTotal = 0;
- if (sampleTotal < sfx->fVolRange * s_lip_threshold_1->value)
- {
+ if (sampleTotal < sfx->fVolRange * s_lip_threshold_1->value) {
// tell the scripts that are relying on this that we are still going, but actually silent right now.
sample = -1;
- }
- else if (sampleTotal < sfx->fVolRange * s_lip_threshold_2->value)
+ } else if (sampleTotal < sfx->fVolRange * s_lip_threshold_2->value)
sample = 1;
else if (sampleTotal < sfx->fVolRange * s_lip_threshold_3->value)
sample = 2;
diff --git a/code/client/snd_mix.cpp b/code/client/snd_mix.cpp
index d245590db1..8e8863504c 100644
--- a/code/client/snd_mix.cpp
+++ b/code/client/snd_mix.cpp
@@ -28,17 +28,15 @@ along with this program; if not, see .
#include "snd_local.h"
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
-int *snd_p, snd_linear_count, snd_vol;
-short *snd_out;
+int *snd_p, snd_linear_count, snd_vol;
+short *snd_out;
-void S_WriteLinearBlastStereo16 (void)
-{
- int i;
- int val;
+void S_WriteLinearBlastStereo16(void) {
+ int i;
+ int val;
- for (i=0 ; i>8;
+ for (i = 0; i < snd_linear_count; i += 2) {
+ val = snd_p[i] >> 8;
if (val > 0x7fff)
snd_out[i] = 0x7fff;
else if (val < (short)0x8000)
@@ -46,42 +44,40 @@ void S_WriteLinearBlastStereo16 (void)
else
snd_out[i] = val;
- val = snd_p[i+1]>>8;
+ val = snd_p[i + 1] >> 8;
if (val > 0x7fff)
- snd_out[i+1] = 0x7fff;
+ snd_out[i + 1] = 0x7fff;
else if (val < (short)0x8000)
- snd_out[i+1] = (short)0x8000;
+ snd_out[i + 1] = (short)0x8000;
else
- snd_out[i+1] = val;
+ snd_out[i + 1] = val;
}
}
-void S_TransferStereo16 (unsigned long *pbuf, int endtime)
-{
- int lpos;
- int ls_paintedtime;
+void S_TransferStereo16(unsigned long *pbuf, int endtime) {
+ int lpos;
+ int ls_paintedtime;
- snd_p = (int *) paintbuffer;
+ snd_p = (int *)paintbuffer;
ls_paintedtime = s_paintedtime;
- while (ls_paintedtime < endtime)
- {
- // handle recirculating buffer issues
- lpos = ls_paintedtime & ((dma.samples>>1)-1);
+ while (ls_paintedtime < endtime) {
+ // handle recirculating buffer issues
+ lpos = ls_paintedtime & ((dma.samples >> 1) - 1);
- snd_out = (short *) pbuf + (lpos<<1);
+ snd_out = (short *)pbuf + (lpos << 1);
- snd_linear_count = (dma.samples>>1) - lpos;
+ snd_linear_count = (dma.samples >> 1) - lpos;
if (ls_paintedtime + snd_linear_count > endtime)
snd_linear_count = endtime - ls_paintedtime;
snd_linear_count <<= 1;
- // write a linear blast of samples
- S_WriteLinearBlastStereo16 ();
+ // write a linear blast of samples
+ S_WriteLinearBlastStereo16();
snd_p += snd_linear_count;
- ls_paintedtime += (snd_linear_count>>1);
+ ls_paintedtime += (snd_linear_count >> 1);
}
}
@@ -91,49 +87,41 @@ S_TransferPaintBuffer
===================
*/
-void S_TransferPaintBuffer(int endtime)
-{
- int out_idx;
- int count;
- int out_mask;
- int *p;
- int step;
- int val;
+void S_TransferPaintBuffer(int endtime) {
+ int out_idx;
+ int count;
+ int out_mask;
+ int *p;
+ int step;
+ int val;
unsigned long *pbuf;
pbuf = (unsigned long *)dma.buffer;
-
- if ( s_testsound->integer ) {
- int i;
- int count;
+ if (s_testsound->integer) {
+ int i;
+ int count;
// write a fixed sine wave
count = (endtime - s_paintedtime);
- for (i=0 ; i> 8;
- p+= step;
+ p += step;
if (val > 0x7fff)
val = 0x7fff;
else if (val < (short)0x8000)
@@ -141,26 +129,22 @@ void S_TransferPaintBuffer(int endtime)
out[out_idx] = (short)val;
out_idx = (out_idx + 1) & out_mask;
}
- }
- else if (dma.samplebits == 8)
- {
- unsigned char *out = (unsigned char *) pbuf;
- while (count--)
- {
+ } else if (dma.samplebits == 8) {
+ unsigned char *out = (unsigned char *)pbuf;
+ while (count--) {
val = *p >> 8;
- p+= step;
+ p += step;
if (val > 0x7fff)
val = 0x7fff;
else if (val < (short)0x8000)
val = (short)0x8000;
- out[out_idx] = (short)((val>>8) + 128);
+ out[out_idx] = (short)((val >> 8) + 128);
out_idx = (out_idx + 1) & out_mask;
}
}
}
}
-
/*
===============================================================================
@@ -168,156 +152,144 @@ CHANNEL MIXING
===============================================================================
*/
-static void S_PaintChannelFrom16( channel_t *ch, const sfx_t *sfx, int count, int sampleOffset, int bufferOffset )
-{
- portable_samplepair_t *pSamplesDest;
+static void S_PaintChannelFrom16(channel_t *ch, const sfx_t *sfx, int count, int sampleOffset, int bufferOffset) {
+ portable_samplepair_t *pSamplesDest;
int iData;
+ int iLeftVol = ch->leftvol * snd_vol;
+ int iRightVol = ch->rightvol * snd_vol;
- int iLeftVol = ch->leftvol * snd_vol;
- int iRightVol = ch->rightvol * snd_vol;
-
- pSamplesDest = &paintbuffer[ bufferOffset ];
+ pSamplesDest = &paintbuffer[bufferOffset];
- for ( int i=0 ; ipSoundData[ sampleOffset++ ];
+ for (int i = 0; i < count; i++) {
+ iData = sfx->pSoundData[sampleOffset++];
- pSamplesDest[i].left += (iData * iLeftVol )>>8;
- pSamplesDest[i].right += (iData * iRightVol)>>8;
+ pSamplesDest[i].left += (iData * iLeftVol) >> 8;
+ pSamplesDest[i].right += (iData * iRightVol) >> 8;
}
}
-
-void S_PaintChannelFromMP3( channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset )
-{
+void S_PaintChannelFromMP3(channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset) {
int data;
int leftvol, rightvol;
signed short *sfx;
- int i;
- portable_samplepair_t *samp;
+ int i;
+ portable_samplepair_t *samp;
static short tempMP3Buffer[PAINTBUFFER_SIZE];
- MP3Stream_GetSamples( ch, sampleOffset, count, tempMP3Buffer, qfalse ); // qfalse = not stereo
+ MP3Stream_GetSamples(ch, sampleOffset, count, tempMP3Buffer, qfalse); // qfalse = not stereo
- leftvol = ch->leftvol*snd_vol;
- rightvol = ch->rightvol*snd_vol;
+ leftvol = ch->leftvol * snd_vol;
+ rightvol = ch->rightvol * snd_vol;
sfx = tempMP3Buffer;
- samp = &paintbuffer[ bufferOffset ];
-
+ samp = &paintbuffer[bufferOffset];
- while ( count & 3 ) {
+ while (count & 3) {
data = *sfx;
- samp->left += (data * leftvol)>>8;
- samp->right += (data * rightvol)>>8;
+ samp->left += (data * leftvol) >> 8;
+ samp->right += (data * rightvol) >> 8;
sfx++;
samp++;
count--;
}
- for ( i=0 ; i>8;
- samp[i].right += (data * rightvol)>>8;
+ samp[i].left += (data * leftvol) >> 8;
+ samp[i].right += (data * rightvol) >> 8;
- data = sfx[i+1];
- samp[i+1].left += (data * leftvol)>>8;
- samp[i+1].right += (data * rightvol)>>8;
+ data = sfx[i + 1];
+ samp[i + 1].left += (data * leftvol) >> 8;
+ samp[i + 1].right += (data * rightvol) >> 8;
- data = sfx[i+2];
- samp[i+2].left += (data * leftvol)>>8;
- samp[i+2].right += (data * rightvol)>>8;
+ data = sfx[i + 2];
+ samp[i + 2].left += (data * leftvol) >> 8;
+ samp[i + 2].right += (data * rightvol) >> 8;
- data = sfx[i+3];
- samp[i+3].left += (data * leftvol)>>8;
- samp[i+3].right += (data * rightvol)>>8;
+ data = sfx[i + 3];
+ samp[i + 3].left += (data * leftvol) >> 8;
+ samp[i + 3].right += (data * rightvol) >> 8;
}
}
-
// subroutinised to save code dup (called twice) -ste
//
-void ChannelPaint(channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset)
-{
- switch (sc->eSoundCompressionMethod)
- {
- case ct_16:
+void ChannelPaint(channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset) {
+ switch (sc->eSoundCompressionMethod) {
+ case ct_16:
- S_PaintChannelFrom16 (ch, sc, count, sampleOffset, bufferOffset);
- break;
+ S_PaintChannelFrom16(ch, sc, count, sampleOffset, bufferOffset);
+ break;
- case ct_MP3:
+ case ct_MP3:
- S_PaintChannelFromMP3 (ch, sc, count, sampleOffset, bufferOffset);
- break;
+ S_PaintChannelFromMP3(ch, sc, count, sampleOffset, bufferOffset);
+ break;
- default:
+ default:
- assert(0); // debug aid, ignored in release. FIXME: Should we ERR_DROP here for badness-catch?
- break;
+ assert(0); // debug aid, ignored in release. FIXME: Should we ERR_DROP here for badness-catch?
+ break;
}
}
-
-
-void S_PaintChannels( int endtime ) {
- int i;
- int end;
+void S_PaintChannels(int endtime) {
+ int i;
+ int end;
channel_t *ch;
- sfx_t *sc;
- int ltime, count;
- int sampleOffset;
- int normal_vol,voice_vol;
+ sfx_t *sc;
+ int ltime, count;
+ int sampleOffset;
+ int normal_vol, voice_vol;
- snd_vol = normal_vol = s_volume->value*256.0f;
- voice_vol = (s_volumeVoice->value*256.0f);
+ snd_vol = normal_vol = s_volume->value * 256.0f;
+ voice_vol = (s_volumeVoice->value * 256.0f);
-//Com_Printf ("%i to %i\n", s_paintedtime, endtime);
- while ( s_paintedtime < endtime ) {
+ // Com_Printf ("%i to %i\n", s_paintedtime, endtime);
+ while (s_paintedtime < endtime) {
// if paintbuffer is smaller than DMA buffer
// we may need to fill it multiple times
end = endtime;
- if ( endtime - s_paintedtime > PAINTBUFFER_SIZE ) {
+ if (endtime - s_paintedtime > PAINTBUFFER_SIZE) {
end = s_paintedtime + PAINTBUFFER_SIZE;
}
// clear the paint buffer to either music or zeros
- if ( s_rawend < s_paintedtime ) {
- if ( s_rawend ) {
- //Com_DPrintf ("background sound underrun\n");
+ if (s_rawend < s_paintedtime) {
+ if (s_rawend) {
+ // Com_DPrintf ("background sound underrun\n");
}
memset(paintbuffer, 0, (end - s_paintedtime) * sizeof(portable_samplepair_t));
} else {
// copy from the streaming sound source
- int s;
- int stop;
+ int s;
+ int stop;
stop = (end < s_rawend) ? end : s_rawend;
- for ( i = s_paintedtime ; i < stop ; i++ ) {
- s = i&(MAX_RAW_SAMPLES-1);
- paintbuffer[i-s_paintedtime] = s_rawsamples[s];
+ for (i = s_paintedtime; i < stop; i++) {
+ s = i & (MAX_RAW_SAMPLES - 1);
+ paintbuffer[i - s_paintedtime] = s_rawsamples[s];
}
-// if (i != end)
-// Com_Printf ("partial stream\n");
-// else
-// Com_Printf ("full stream\n");
- for ( ; i < end ; i++ ) {
- paintbuffer[i-s_paintedtime].left =
- paintbuffer[i-s_paintedtime].right = 0;
+ // if (i != end)
+ // Com_Printf ("partial stream\n");
+ // else
+ // Com_Printf ("full stream\n");
+ for (; i < end; i++) {
+ paintbuffer[i - s_paintedtime].left = paintbuffer[i - s_paintedtime].right = 0;
}
}
// paint in the channels.
ch = s_channels;
- for ( i = 0; i < MAX_CHANNELS ; i++, ch++ ) {
- if ( !ch->thesfx || (ch->leftvol<0.25 && ch->rightvol<0.25 )) {
+ for (i = 0; i < MAX_CHANNELS; i++, ch++) {
+ if (!ch->thesfx || (ch->leftvol < 0.25 && ch->rightvol < 0.25)) {
continue;
}
- if ( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL )
+ if (ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL)
snd_vol = voice_vol;
else
snd_vol = normal_vol;
@@ -329,8 +301,7 @@ void S_PaintChannels( int endtime ) {
// a looping sound effect and the end of
// the sameple is hit...
//
- do
- {
+ do {
if (ch->loopSound) {
sampleOffset = ltime % sc->iSoundLengthInSamples;
} else {
@@ -338,55 +309,55 @@ void S_PaintChannels( int endtime ) {
}
count = end - ltime;
- if ( sampleOffset + count > sc->iSoundLengthInSamples ) {
+ if (sampleOffset + count > sc->iSoundLengthInSamples) {
count = sc->iSoundLengthInSamples - sampleOffset;
}
- if ( count > 0 ) {
+ if (count > 0) {
ChannelPaint(ch, sc, count, sampleOffset, ltime - s_paintedtime);
ltime += count;
}
- } while ( ltime < end && ch->loopSound );
+ } while (ltime < end && ch->loopSound);
}
-/* temprem
- // paint in the looped channels.
- ch = loop_channels;
- for ( i = 0; i < numLoopChannels ; i++, ch++ ) {
- if ( !ch->thesfx || (!ch->leftvol && !ch->rightvol )) {
- continue;
- }
-
- {
-
- ltime = s_paintedtime;
- sc = ch->thesfx;
-
- if (sc->soundData==NULL || sc->soundLength==0) {
- continue;
- }
- // we might have to make two passes if it
- // is a looping sound effect and the end of
- // the sample is hit
- do {
- sampleOffset = (ltime % sc->soundLength);
-
- count = end - ltime;
- if ( sampleOffset + count > sc->soundLength ) {
- count = sc->soundLength - sampleOffset;
+ /* temprem
+ // paint in the looped channels.
+ ch = loop_channels;
+ for ( i = 0; i < numLoopChannels ; i++, ch++ ) {
+ if ( !ch->thesfx || (!ch->leftvol && !ch->rightvol )) {
+ continue;
}
- if ( count > 0 )
{
- ChannelPaint(ch, sc, count, sampleOffset, ltime - s_paintedtime);
- ltime += count;
- }
- } while ( ltime < end);
- }
- }
-*/
+ ltime = s_paintedtime;
+ sc = ch->thesfx;
+
+ if (sc->soundData==NULL || sc->soundLength==0) {
+ continue;
+ }
+ // we might have to make two passes if it
+ // is a looping sound effect and the end of
+ // the sample is hit
+ do {
+ sampleOffset = (ltime % sc->soundLength);
+
+ count = end - ltime;
+ if ( sampleOffset + count > sc->soundLength ) {
+ count = sc->soundLength - sampleOffset;
+ }
+
+ if ( count > 0 )
+ {
+ ChannelPaint(ch, sc, count, sampleOffset, ltime - s_paintedtime);
+ ltime += count;
+ }
+
+ } while ( ltime < end);
+ }
+ }
+ */
// transfer out according to DMA format
- S_TransferPaintBuffer( end );
+ S_TransferPaintBuffer(end);
s_paintedtime = end;
}
}
diff --git a/code/client/snd_music.cpp b/code/client/snd_music.cpp
index 5bebe9cdee..0855bcedab 100644
--- a/code/client/snd_music.cpp
+++ b/code/client/snd_music.cpp
@@ -24,7 +24,7 @@ along with this program; if not, see .
//
// Stuff to parse in special x-fade music format and handle blending etc
-//Anything above this #include will be ignored by the compiler
+// Anything above this #include will be ignored by the compiler
#include "../server/exe_headers.h"
#include "../qcommon/sstring.h"
@@ -40,119 +40,102 @@ along with this program; if not, see .
#include "../game/genericparser2.h"
-extern qboolean S_FileExists( const char *psFilename );
+extern qboolean S_FileExists(const char *psFilename);
-#define sKEY_MUSICFILES CSTRING_VIEW( "musicfiles" )
-#define sKEY_ENTRY CSTRING_VIEW( "entry" )
-#define sKEY_EXIT CSTRING_VIEW( "exit" )
-#define sKEY_MARKER CSTRING_VIEW( "marker" )
-#define sKEY_TIME CSTRING_VIEW( "time" )
-#define sKEY_NEXTFILE CSTRING_VIEW( "nextfile" )
-#define sKEY_NEXTMARK CSTRING_VIEW( "nextmark" )
-#define sKEY_LEVELMUSIC CSTRING_VIEW( "levelmusic" )
-#define sKEY_EXPLORE CSTRING_VIEW( "explore" )
-#define sKEY_ACTION CSTRING_VIEW( "action" )
-#define sKEY_BOSS CSTRING_VIEW( "boss" )
-#define sKEY_DEATH CSTRING_VIEW( "death" )
-#define sKEY_USES CSTRING_VIEW( "uses" )
-#define sKEY_USEBOSS CSTRING_VIEW( "useboss" )
+#define sKEY_MUSICFILES CSTRING_VIEW("musicfiles")
+#define sKEY_ENTRY CSTRING_VIEW("entry")
+#define sKEY_EXIT CSTRING_VIEW("exit")
+#define sKEY_MARKER CSTRING_VIEW("marker")
+#define sKEY_TIME CSTRING_VIEW("time")
+#define sKEY_NEXTFILE CSTRING_VIEW("nextfile")
+#define sKEY_NEXTMARK CSTRING_VIEW("nextmark")
+#define sKEY_LEVELMUSIC CSTRING_VIEW("levelmusic")
+#define sKEY_EXPLORE CSTRING_VIEW("explore")
+#define sKEY_ACTION CSTRING_VIEW("action")
+#define sKEY_BOSS CSTRING_VIEW("boss")
+#define sKEY_DEATH CSTRING_VIEW("death")
+#define sKEY_USES CSTRING_VIEW("uses")
+#define sKEY_USEBOSS CSTRING_VIEW("useboss")
-#define sKEY_PLACEHOLDER "placeholder" // ignore these
+#define sKEY_PLACEHOLDER "placeholder" // ignore these
-#define sFILENAME_DMS "ext_data/dms.dat"
+#define sFILENAME_DMS "ext_data/dms.dat"
-typedef struct
-{
- sstring_t sNextFile;
- sstring_t sNextMark; // blank if used for an explore piece, name of marker point to enter new file at
+typedef struct {
+ sstring_t sNextFile;
+ sstring_t sNextMark; // blank if used for an explore piece, name of marker point to enter new file at
} MusicExitPoint_t;
-struct MusicExitTime_t // need to declare this way for operator < below
+struct MusicExitTime_t // need to declare this way for operator < below
{
- float fTime;
- int iExitPoint;
+ float fTime;
+ int iExitPoint;
// I'm defining this '<' operator so STL's sort algorithm will work
//
- bool operator < (const MusicExitTime_t& X) const {return (fTime < X.fTime);}
+ bool operator<(const MusicExitTime_t &X) const { return (fTime < X.fTime); }
};
// it's possible for all 3 of these to be empty if it's boss or death music
//
-typedef std::vector MusicExitPoints_t;
-typedef std::vector MusicExitTimes_t;
-typedef std::map MusicEntryTimes_t; // key eg "marker1"
+typedef std::vector MusicExitPoints_t;
+typedef std::vector MusicExitTimes_t;
+typedef std::map MusicEntryTimes_t; // key eg "marker1"
-typedef struct
-{
- sstring_t sFileNameBase;
- MusicEntryTimes_t MusicEntryTimes;
- MusicExitPoints_t MusicExitPoints;
- MusicExitTimes_t MusicExitTimes;
+typedef struct {
+ sstring_t sFileNameBase;
+ MusicEntryTimes_t MusicEntryTimes;
+ MusicExitPoints_t MusicExitPoints;
+ MusicExitTimes_t MusicExitTimes;
} MusicFile_t;
-typedef std::map MusicData_t; // string is "explore", "action", "boss" etc
- MusicData_t* MusicData = NULL;
+typedef std::map MusicData_t; // string is "explore", "action", "boss" etc
+MusicData_t *MusicData = NULL;
// there are now 2 of these, because of the new "uses" keyword...
//
-sstring_t gsLevelNameForLoad; // eg "kejim_base", formed from literal BSP name, but also used as dir name for music paths
-sstring_t gsLevelNameForCompare; // eg "kejim_base", formed from literal BSP name, but also used as dir name for music paths
-sstring_t gsLevelNameForBossLoad; // eg "kejim_base', special case for enabling boss music to come from a different dir - sigh....
+sstring_t gsLevelNameForLoad; // eg "kejim_base", formed from literal BSP name, but also used as dir name for music paths
+sstring_t gsLevelNameForCompare; // eg "kejim_base", formed from literal BSP name, but also used as dir name for music paths
+sstring_t gsLevelNameForBossLoad; // eg "kejim_base', special case for enabling boss music to come from a different dir - sigh....
-void Music_Free(void)
-{
- if (MusicData)
- {
+void Music_Free(void) {
+ if (MusicData) {
MusicData->clear();
}
MusicData = NULL;
}
-namespace detail
-{
- static void build_string( std::ostream& stream )
- {
- }
+namespace detail {
+static void build_string(std::ostream &stream) {}
- template< typename T, typename... Tail >
- static void build_string( std::ostream& stream, const T& head, Tail... tail )
- {
- stream << head;
- build_string( stream, tail... );
- }
+template static void build_string(std::ostream &stream, const T &head, Tail... tail) {
+ stream << head;
+ build_string(stream, tail...);
}
+} // namespace detail
-template< typename... Tail >
-static std::string build_string( Tail... tail )
-{
+template static std::string build_string(Tail... tail) {
std::ostringstream os;
- detail::build_string( os, tail... );
+ detail::build_string(os, tail...);
return os.str();
}
// some sort of error in the music data...
// only use during parse, not run-time use, and bear in mid that data is zapped after error message, so exit any loops immediately
//
-static void Music_Parse_Error( gsl::czstring filename, const std::string& error )
-{
- std::string message = build_string(
- S_COLOR_RED "Error parsing music data (in \"", filename, "\"):\n",
- error , "\n"
- );
- Com_Printf( "%s", message.c_str() );
+static void Music_Parse_Error(gsl::czstring filename, const std::string &error) {
+ std::string message = build_string(S_COLOR_RED "Error parsing music data (in \"", filename, "\"):\n", error, "\n");
+ Com_Printf("%s", message.c_str());
MusicData->clear();
}
// something to just mention if interested...
//
-static void Music_Parse_Warning( const std::string& error )
-{
+static void Music_Parse_Warning(const std::string &error) {
extern cvar_t *s_debugdynamic;
- if( s_debugdynamic && s_debugdynamic->integer )
- {
- Com_Printf( S_COLOR_YELLOW "%s", error.c_str() );
+ if (s_debugdynamic && s_debugdynamic->integer) {
+ Com_Printf(S_COLOR_YELLOW "%s", error.c_str());
}
}
@@ -160,58 +143,77 @@ static void Music_Parse_Warning( const std::string& error )
// Unfortunately two of the places that calls this doesn't have much other access to the state other than
// a string, not an enum, so for those cases they only pass in BOSS or EXPLORE, so don't rely on it totally.
//
-static const char *Music_BuildFileName(const char *psFileNameBase, MusicState_e eMusicState )
-{
+static const char *Music_BuildFileName(const char *psFileNameBase, MusicState_e eMusicState) {
static sstring_t sFileName;
- //HACK!
- if (eMusicState == eBGRNDTRACK_DEATH)
- {
+ // HACK!
+ if (eMusicState == eBGRNDTRACK_DEATH) {
return "music/death_music.mp3";
}
const char *psDirName = (eMusicState == eBGRNDTRACK_BOSS) ? gsLevelNameForBossLoad.c_str() : gsLevelNameForLoad.c_str();
- sFileName = va("music/%s/%s.mp3",psDirName,psFileNameBase);
+ sFileName = va("music/%s/%s.mp3", psDirName, psFileNameBase);
return sFileName.c_str();
}
// this MUST return NULL for non-base states unless doing debug-query
-const char *Music_BaseStateToString( MusicState_e eMusicState, qboolean bDebugPrintQuery /* = qfalse */ )
-{
- switch (eMusicState)
- {
- case eBGRNDTRACK_EXPLORE: return "explore";
- case eBGRNDTRACK_ACTION: return "action";
- case eBGRNDTRACK_BOSS: return "boss";
- case eBGRNDTRACK_SILENCE: return "silence"; // not used in this module, but snd_dma uses it now it's de-static'd
- case eBGRNDTRACK_DEATH: return "death";
-
- // info only, not map<> lookup keys (unlike above)...
- //
- case eBGRNDTRACK_ACTIONTRANS0: if (bDebugPrintQuery) return "action_tr0";
- case eBGRNDTRACK_ACTIONTRANS1: if (bDebugPrintQuery) return "action_tr1";
- case eBGRNDTRACK_ACTIONTRANS2: if (bDebugPrintQuery) return "action_tr2";
- case eBGRNDTRACK_ACTIONTRANS3: if (bDebugPrintQuery) return "action_tr3";
- case eBGRNDTRACK_EXPLORETRANS0: if (bDebugPrintQuery) return "explore_tr0";
- case eBGRNDTRACK_EXPLORETRANS1: if (bDebugPrintQuery) return "explore_tr1";
- case eBGRNDTRACK_EXPLORETRANS2: if (bDebugPrintQuery) return "explore_tr2";
- case eBGRNDTRACK_EXPLORETRANS3: if (bDebugPrintQuery) return "explore_tr3";
- case eBGRNDTRACK_FADE: if (bDebugPrintQuery) return "fade";
- default: break;
+const char *Music_BaseStateToString(MusicState_e eMusicState, qboolean bDebugPrintQuery /* = qfalse */) {
+ switch (eMusicState) {
+ case eBGRNDTRACK_EXPLORE:
+ return "explore";
+ case eBGRNDTRACK_ACTION:
+ return "action";
+ case eBGRNDTRACK_BOSS:
+ return "boss";
+ case eBGRNDTRACK_SILENCE:
+ return "silence"; // not used in this module, but snd_dma uses it now it's de-static'd
+ case eBGRNDTRACK_DEATH:
+ return "death";
+
+ // info only, not map<> lookup keys (unlike above)...
+ //
+ case eBGRNDTRACK_ACTIONTRANS0:
+ if (bDebugPrintQuery)
+ return "action_tr0";
+ case eBGRNDTRACK_ACTIONTRANS1:
+ if (bDebugPrintQuery)
+ return "action_tr1";
+ case eBGRNDTRACK_ACTIONTRANS2:
+ if (bDebugPrintQuery)
+ return "action_tr2";
+ case eBGRNDTRACK_ACTIONTRANS3:
+ if (bDebugPrintQuery)
+ return "action_tr3";
+ case eBGRNDTRACK_EXPLORETRANS0:
+ if (bDebugPrintQuery)
+ return "explore_tr0";
+ case eBGRNDTRACK_EXPLORETRANS1:
+ if (bDebugPrintQuery)
+ return "explore_tr1";
+ case eBGRNDTRACK_EXPLORETRANS2:
+ if (bDebugPrintQuery)
+ return "explore_tr2";
+ case eBGRNDTRACK_EXPLORETRANS3:
+ if (bDebugPrintQuery)
+ return "explore_tr3";
+ case eBGRNDTRACK_FADE:
+ if (bDebugPrintQuery)
+ return "fade";
+ default:
+ break;
}
return NULL;
}
-static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2& Parser, MusicData_t* MusicData, const CGPGroup& pgMusicFiles, const gsl::cstring_span& psMusicName, const gsl::cstring_span& psMusicNameKey, MusicState_e eMusicState )
-{
+static qboolean Music_ParseMusic(gsl::czstring filename, const CGenericParser2 &Parser, MusicData_t *MusicData, const CGPGroup &pgMusicFiles,
+ const gsl::cstring_span &psMusicName, const gsl::cstring_span &psMusicNameKey, MusicState_e eMusicState) {
bool bReturn = false;
MusicFile_t MusicFile;
- const CGPGroup* const pgMusicFile = pgMusicFiles.FindSubGroup( psMusicName );
- if( pgMusicFile )
- {
+ const CGPGroup *const pgMusicFile = pgMusicFiles.FindSubGroup(psMusicName);
+ if (pgMusicFile) {
// read subgroups...
//
bool bEntryFound = false;
@@ -219,96 +221,80 @@ static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2&
//
// (read entry points first, so I can check exit points aren't too close in time)
//
- const CGPGroup* pEntryGroup = pgMusicFile->FindSubGroup( sKEY_ENTRY );
- if( pEntryGroup )
- {
+ const CGPGroup *pEntryGroup = pgMusicFile->FindSubGroup(sKEY_ENTRY);
+ if (pEntryGroup) {
// read entry points...
//
- for( auto& prop : pEntryGroup->GetProperties() )
- {
- //if( Q::substr( prop.GetName(), 0, sKEY_MARKER.size() ) == sKEY_MARKER ) // for now, assume anything is a marker
+ for (auto &prop : pEntryGroup->GetProperties()) {
+ // if( Q::substr( prop.GetName(), 0, sKEY_MARKER.size() ) == sKEY_MARKER ) // for now, assume anything is a marker
{
- MusicFile.MusicEntryTimes[ prop.GetName() ] = Q::svtoi( prop.GetTopValue() );
+ MusicFile.MusicEntryTimes[prop.GetName()] = Q::svtoi(prop.GetTopValue());
bEntryFound = true;
}
}
}
- for( auto& group : pgMusicFile->GetSubGroups() )
- {
- auto& groupName = group.GetName();
+ for (auto &group : pgMusicFile->GetSubGroups()) {
+ auto &groupName = group.GetName();
- if( groupName == sKEY_ENTRY )
- {
+ if (groupName == sKEY_ENTRY) {
// skip entry points, I've already read them in above
//
- }
- else if( groupName == sKEY_EXIT )
- {
- int iThisExitPointIndex = MusicFile.MusicExitPoints.size(); // must eval this first, so unaffected by push_back etc
+ } else if (groupName == sKEY_EXIT) {
+ int iThisExitPointIndex = MusicFile.MusicExitPoints.size(); // must eval this first, so unaffected by push_back etc
//
// read this set of exit points...
//
MusicExitPoint_t MusicExitPoint;
- for( auto& prop : group.GetProperties() )
- {
- auto& key = prop.GetName();
- auto& value = prop.GetTopValue();
+ for (auto &prop : group.GetProperties()) {
+ auto &key = prop.GetName();
+ auto &value = prop.GetTopValue();
- if( key == sKEY_NEXTFILE )
- {
+ if (key == sKEY_NEXTFILE) {
MusicExitPoint.sNextFile = value;
- bExitFound = true; // harmless to keep setting
- }
- else if( key == sKEY_NEXTMARK )
- {
+ bExitFound = true; // harmless to keep setting
+ } else if (key == sKEY_NEXTMARK) {
MusicExitPoint.sNextMark = value;
- }
- else if( Q::substr( key, 0, sKEY_TIME.size() ) == sKEY_TIME )
- {
+ } else if (Q::substr(key, 0, sKEY_TIME.size()) == sKEY_TIME) {
MusicExitTime_t MusicExitTime;
- MusicExitTime.fTime = Q::svtof( value );
+ MusicExitTime.fTime = Q::svtof(value);
MusicExitTime.iExitPoint = iThisExitPointIndex;
// new check, don't keep this this exit point if it's within 1.5 seconds either way of an entry point...
//
bool bTooCloseToEntryPoint = false;
- for( auto& item : MusicFile.MusicEntryTimes )
- {
+ for (auto &item : MusicFile.MusicEntryTimes) {
float fThisEntryTime = item.second;
- if( Q_fabs( fThisEntryTime - MusicExitTime.fTime ) < 1.5f )
- {
+ if (Q_fabs(fThisEntryTime - MusicExitTime.fTime) < 1.5f) {
// bTooCloseToEntryPoint = true; // not sure about this, ignore for now
break;
}
}
- if( !bTooCloseToEntryPoint )
- {
- MusicFile.MusicExitTimes.push_back( MusicExitTime );
+ if (!bTooCloseToEntryPoint) {
+ MusicFile.MusicExitTimes.push_back(MusicExitTime);
}
}
}
- MusicFile.MusicExitPoints.push_back( MusicExitPoint );
+ MusicFile.MusicExitPoints.push_back(MusicExitPoint);
int iNumExitPoints = MusicFile.MusicExitPoints.size();
// error checking...
//
- switch( eMusicState )
- {
+ switch (eMusicState) {
case eBGRNDTRACK_EXPLORE:
- if( iNumExitPoints > iMAX_EXPLORE_TRANSITIONS )
- {
- Music_Parse_Error( filename, build_string( "\"", psMusicName, "\" has > ", iMAX_EXPLORE_TRANSITIONS, " ", psMusicNameKey, " transitions defined!\n" ) );
+ if (iNumExitPoints > iMAX_EXPLORE_TRANSITIONS) {
+ Music_Parse_Error(
+ filename, build_string("\"", psMusicName, "\" has > ", iMAX_EXPLORE_TRANSITIONS, " ", psMusicNameKey, " transitions defined!\n"));
return qfalse;
}
break;
case eBGRNDTRACK_ACTION:
- if( iNumExitPoints > iMAX_ACTION_TRANSITIONS )
- {
- Music_Parse_Error( filename, build_string( "\"", psMusicName, "\" has > ", iMAX_ACTION_TRANSITIONS, " ", psMusicNameKey, " transitions defined!\n" ) );
+ if (iNumExitPoints > iMAX_ACTION_TRANSITIONS) {
+ Music_Parse_Error(
+ filename, build_string("\"", psMusicName, "\" has > ", iMAX_ACTION_TRANSITIONS, " ", psMusicNameKey, " transitions defined!\n"));
return qfalse;
}
break;
@@ -316,7 +302,7 @@ static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2&
case eBGRNDTRACK_BOSS:
case eBGRNDTRACK_DEATH:
- Music_Parse_Error( filename, build_string( "\"", psMusicName, "\" has ", psMusicNameKey, " transitions defined, this is not allowed!\n" ) );
+ Music_Parse_Error(filename, build_string("\"", psMusicName, "\" has ", psMusicNameKey, " transitions defined, this is not allowed!\n"));
return qfalse;
default:
break;
@@ -329,29 +315,23 @@ static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2&
bReturn = true;
// boss & death pieces can omit entry/exit stuff
- if( eMusicState != eBGRNDTRACK_BOSS && eMusicState != eBGRNDTRACK_DEATH )
- {
- if( !bEntryFound )
- {
- Music_Parse_Error( filename, build_string( "Unable to find subgroup \"", sKEY_ENTRY, "\" in group \"", psMusicName, "\"\n" ) );
+ if (eMusicState != eBGRNDTRACK_BOSS && eMusicState != eBGRNDTRACK_DEATH) {
+ if (!bEntryFound) {
+ Music_Parse_Error(filename, build_string("Unable to find subgroup \"", sKEY_ENTRY, "\" in group \"", psMusicName, "\"\n"));
bReturn = false;
}
- if( !bExitFound )
- {
- Music_Parse_Error( filename, build_string( "Unable to find subgroup \"", sKEY_EXIT, "\" in group \"", psMusicName, "\"\n" ) );
+ if (!bExitFound) {
+ Music_Parse_Error(filename, build_string("Unable to find subgroup \"", sKEY_EXIT, "\" in group \"", psMusicName, "\"\n"));
bReturn = false;
}
}
- }
- else
- {
- Music_Parse_Error( filename, build_string( "Unable to find musicfiles entry \"", psMusicName, "\"\n" ) );
+ } else {
+ Music_Parse_Error(filename, build_string("Unable to find musicfiles entry \"", psMusicName, "\"\n"));
}
- if( bReturn )
- {
+ if (bReturn) {
MusicFile.sFileNameBase = psMusicName;
- ( *MusicData )[ psMusicNameKey ] = MusicFile;
+ (*MusicData)[psMusicNameKey] = MusicFile;
}
return (qboolean)bReturn;
@@ -362,17 +342,12 @@ static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2&
// This just initialises the Lucas music structs so the background music player can interrogate them...
//
sstring_t gsLevelNameFromServer;
-void Music_SetLevelName(const char *psLevelName)
-{
- gsLevelNameFromServer = psLevelName;
-}
+void Music_SetLevelName(const char *psLevelName) { gsLevelNameFromServer = psLevelName; }
-static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
-{
+static qboolean Music_ParseLeveldata(gsl::czstring psLevelName) {
qboolean bReturn = qfalse;
- if (MusicData == NULL)
- {
+ if (MusicData == NULL) {
// sorry vv, false leaks make it hard to find true leaks
static MusicData_t singleton;
MusicData = &singleton;
@@ -380,8 +355,7 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
// already got this data?
//
- if (MusicData->size() && !Q_stricmp(psLevelName,gsLevelNameForCompare.c_str()))
- {
+ if (MusicData->size() && !Q_stricmp(psLevelName, gsLevelNameForCompare.c_str())) {
return qtrue;
}
@@ -389,70 +363,54 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
// shorten level name to MAX_QPATH so sstring's assignment assertion is satisfied.
char sLevelName[MAX_QPATH];
- Q_strncpyz(sLevelName,psLevelName,sizeof(sLevelName));
+ Q_strncpyz(sLevelName, psLevelName, sizeof(sLevelName));
- gsLevelNameForLoad = sLevelName; // harmless to init here even if we fail to parse dms.dat file
- gsLevelNameForCompare = sLevelName; // harmless to init here even if we fail to parse dms.dat file
- gsLevelNameForBossLoad = sLevelName; // harmless to init here even if we fail to parse dms.dat file
+ gsLevelNameForLoad = sLevelName; // harmless to init here even if we fail to parse dms.dat file
+ gsLevelNameForCompare = sLevelName; // harmless to init here even if we fail to parse dms.dat file
+ gsLevelNameForBossLoad = sLevelName; // harmless to init here even if we fail to parse dms.dat file
gsl::czstring filename = sFILENAME_DMS;
CGenericParser2 Parser;
- if( !Parser.Parse( filename ) )
- {
- Music_Parse_Error( filename, "Error using GP to parse file\n" );
- }
- else
- {
- const CGPGroup& pFileGroup = Parser.GetBaseParseGroup();
- const CGPGroup* pgMusicFiles = pFileGroup.FindSubGroup( sKEY_MUSICFILES );
- if( !pgMusicFiles )
- {
- Music_Parse_Error(filename, build_string( "Unable to find subgroup \"", sKEY_MUSICFILES ,"\"\n" ) );
- }
- else
- {
- const CGPGroup* pgLevelMusic = pFileGroup.FindSubGroup( sKEY_LEVELMUSIC );
-
- if( !pgLevelMusic )
- {
- Music_Parse_Error( filename, build_string( "Unable to find subgroup \"", sKEY_MUSICFILES, "\"\n" ) );
- }
- else
- {
+ if (!Parser.Parse(filename)) {
+ Music_Parse_Error(filename, "Error using GP to parse file\n");
+ } else {
+ const CGPGroup &pFileGroup = Parser.GetBaseParseGroup();
+ const CGPGroup *pgMusicFiles = pFileGroup.FindSubGroup(sKEY_MUSICFILES);
+ if (!pgMusicFiles) {
+ Music_Parse_Error(filename, build_string("Unable to find subgroup \"", sKEY_MUSICFILES, "\"\n"));
+ } else {
+ const CGPGroup *pgLevelMusic = pFileGroup.FindSubGroup(sKEY_LEVELMUSIC);
+
+ if (!pgLevelMusic) {
+ Music_Parse_Error(filename, build_string("Unable to find subgroup \"", sKEY_MUSICFILES, "\"\n"));
+ } else {
const CGPGroup *pgThisLevelMusic = nullptr;
//
// check for new USE keyword...
//
int steps = 0;
- gsl::cstring_span searchName{ &sLevelName[ 0 ], &sLevelName[ strlen( &sLevelName[ 0 ] ) ] };
+ gsl::cstring_span searchName{&sLevelName[0], &sLevelName[strlen(&sLevelName[0])]};
const int sanityLimit = 10;
- while( !searchName.empty() && steps < sanityLimit )
- {
+ while (!searchName.empty() && steps < sanityLimit) {
gsLevelNameForLoad = searchName;
gsLevelNameForBossLoad = gsLevelNameForLoad;
- pgThisLevelMusic = pgLevelMusic->FindSubGroup( searchName );
+ pgThisLevelMusic = pgLevelMusic->FindSubGroup(searchName);
- if( pgThisLevelMusic )
- {
- const CGPProperty* pValue = pgThisLevelMusic->FindProperty( sKEY_USES );
- if( pValue )
- {
+ if (pgThisLevelMusic) {
+ const CGPProperty *pValue = pgThisLevelMusic->FindProperty(sKEY_USES);
+ if (pValue) {
// re-search using the USE param...
//
searchName = pValue->GetTopValue();
steps++;
// Com_DPrintf("Using \"%s\"\n",sSearchName.c_str());
- }
- else
- {
+ } else {
// no new USE keyword found...
//
searchName = {};
}
- }
- else
- {
+ } else {
// level entry not found...
//
break;
@@ -461,12 +419,9 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
// now go ahead and use the final music set we've decided on...
//
- if( !pgThisLevelMusic || steps >= sanityLimit )
- {
- Music_Parse_Warning( build_string( "Unable to find entry for \"", sLevelName, "\" in \"", filename, "\"\n" ) );
- }
- else
- {
+ if (!pgThisLevelMusic || steps >= sanityLimit) {
+ Music_Parse_Warning(build_string("Unable to find entry for \"", sLevelName, "\" in \"", filename, "\"\n"));
+ } else {
// these are optional fields, so see which ones we find...
//
gsl::cstring_span psName_Explore;
@@ -474,153 +429,128 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
gsl::cstring_span psName_Boss;
gsl::cstring_span psName_UseBoss;
- for( auto& prop : pgThisLevelMusic->GetProperties() )
- {
- auto& key = prop.GetName();
- auto& value = prop.GetTopValue();
+ for (auto &prop : pgThisLevelMusic->GetProperties()) {
+ auto &key = prop.GetName();
+ auto &value = prop.GetTopValue();
- if( Q::stricmp( value, sKEY_PLACEHOLDER ) == Q::Ordering::EQ )
- {
+ if (Q::stricmp(value, sKEY_PLACEHOLDER) == Q::Ordering::EQ) {
// ignore "placeholder" items
continue;
}
- if( Q::stricmp( key, sKEY_EXPLORE ) == Q::Ordering::EQ )
- {
+ if (Q::stricmp(key, sKEY_EXPLORE) == Q::Ordering::EQ) {
psName_Explore = value;
- }
- else if( Q::stricmp( key, sKEY_ACTION ) == Q::Ordering::EQ )
- {
+ } else if (Q::stricmp(key, sKEY_ACTION) == Q::Ordering::EQ) {
psName_Action = value;
- }
- else if( Q::stricmp( key, sKEY_USEBOSS ) == Q::Ordering::EQ )
- {
+ } else if (Q::stricmp(key, sKEY_USEBOSS) == Q::Ordering::EQ) {
psName_UseBoss = value;
- }
- else if( Q::stricmp( key, sKEY_BOSS ) == Q::Ordering::EQ )
- {
+ } else if (Q::stricmp(key, sKEY_BOSS) == Q::Ordering::EQ) {
psName_Boss = value;
}
}
- bReturn = qtrue; // defualt to ON now, so I can turn it off if "useboss" fails
+ bReturn = qtrue; // defualt to ON now, so I can turn it off if "useboss" fails
- if( !psName_UseBoss.empty() )
- {
- const CGPGroup *pgLevelMusicOfBoss = pgLevelMusic->FindSubGroup( psName_UseBoss );
- if( !pgLevelMusicOfBoss )
- {
- Music_Parse_Error( filename, build_string( "Unable to find 'useboss' entry \"", psName_UseBoss, "\"\n", psName_UseBoss ) );
+ if (!psName_UseBoss.empty()) {
+ const CGPGroup *pgLevelMusicOfBoss = pgLevelMusic->FindSubGroup(psName_UseBoss);
+ if (!pgLevelMusicOfBoss) {
+ Music_Parse_Error(filename, build_string("Unable to find 'useboss' entry \"", psName_UseBoss, "\"\n", psName_UseBoss));
bReturn = qfalse;
- }
- else
- {
- const CGPProperty *pValueBoss = pgLevelMusicOfBoss->FindProperty( sKEY_BOSS );
- if( !pValueBoss )
- {
- Music_Parse_Error( filename, build_string( "'useboss' \"", psName_UseBoss, "\" has no \"boss\" entry!\n" ) );
+ } else {
+ const CGPProperty *pValueBoss = pgLevelMusicOfBoss->FindProperty(sKEY_BOSS);
+ if (!pValueBoss) {
+ Music_Parse_Error(filename, build_string("'useboss' \"", psName_UseBoss, "\" has no \"boss\" entry!\n"));
bReturn = qfalse;
- }
- else
- {
+ } else {
psName_Boss = pValueBoss->GetTopValue();
gsLevelNameForBossLoad = psName_UseBoss;
}
}
}
-
// done this way in case I want to conditionally pass any bools depending on music type...
//
- if( bReturn && psName_Explore.length() )
- {
- bReturn = Music_ParseMusic( filename, Parser, MusicData, *pgMusicFiles, psName_Explore, sKEY_EXPLORE, eBGRNDTRACK_EXPLORE );
+ if (bReturn && psName_Explore.length()) {
+ bReturn = Music_ParseMusic(filename, Parser, MusicData, *pgMusicFiles, psName_Explore, sKEY_EXPLORE, eBGRNDTRACK_EXPLORE);
}
- if( bReturn && psName_Action.length() )
- {
- bReturn = Music_ParseMusic( filename, Parser, MusicData, *pgMusicFiles, psName_Action, sKEY_ACTION, eBGRNDTRACK_ACTION );
+ if (bReturn && psName_Action.length()) {
+ bReturn = Music_ParseMusic(filename, Parser, MusicData, *pgMusicFiles, psName_Action, sKEY_ACTION, eBGRNDTRACK_ACTION);
}
- if( bReturn && psName_Boss.length() )
- {
- bReturn = Music_ParseMusic( filename, Parser, MusicData, *pgMusicFiles, psName_Boss, sKEY_BOSS, eBGRNDTRACK_BOSS );
+ if (bReturn && psName_Boss.length()) {
+ bReturn = Music_ParseMusic(filename, Parser, MusicData, *pgMusicFiles, psName_Boss, sKEY_BOSS, eBGRNDTRACK_BOSS);
}
- if( bReturn /*&& psName_Death*/ ) // LAST MINUTE HACK!!, always force in some death music!!!!
+ if (bReturn /*&& psName_Death*/) // LAST MINUTE HACK!!, always force in some death music!!!!
{
- //bReturn = Music_ParseMusic(Parser, MusicData, pgMusicFiles, psName_Death, sKEY_DEATH, eBGRNDTRACK_DEATH);
+ // bReturn = Music_ParseMusic(Parser, MusicData, pgMusicFiles, psName_Death, sKEY_DEATH, eBGRNDTRACK_DEATH);
MusicFile_t m;
m.sFileNameBase = "death_music";
- ( *MusicData )[ sKEY_DEATH ] = m;
+ (*MusicData)[sKEY_DEATH] = m;
}
}
}
}
}
- if (bReturn)
- {
+ if (bReturn) {
// sort exit points, and do some error checking...
//
- for (MusicData_t::iterator itMusicData = MusicData->begin(); itMusicData != MusicData->end(); ++itMusicData)
- {
- const char *psMusicStateType = (*itMusicData).first.c_str();
- MusicFile_t &MusicFile = (*itMusicData).second;
+ for (MusicData_t::iterator itMusicData = MusicData->begin(); itMusicData != MusicData->end(); ++itMusicData) {
+ const char *psMusicStateType = (*itMusicData).first.c_str();
+ MusicFile_t &MusicFile = (*itMusicData).second;
// kludge up an enum, only interested in boss or not at the moment, so...
//
- MusicState_e eMusicState = !Q_stricmp(psMusicStateType,"boss") ? eBGRNDTRACK_BOSS : !Q_stricmp(psMusicStateType,"death") ? eBGRNDTRACK_DEATH : eBGRNDTRACK_EXPLORE;
+ MusicState_e eMusicState = !Q_stricmp(psMusicStateType, "boss") ? eBGRNDTRACK_BOSS
+ : !Q_stricmp(psMusicStateType, "death") ? eBGRNDTRACK_DEATH
+ : eBGRNDTRACK_EXPLORE;
- if (!MusicFile.MusicExitTimes.empty())
- {
- sort(MusicFile.MusicExitTimes.begin(),MusicFile.MusicExitTimes.end());
+ if (!MusicFile.MusicExitTimes.empty()) {
+ sort(MusicFile.MusicExitTimes.begin(), MusicFile.MusicExitTimes.end());
}
// check music exists...
//
- const char *psMusicFileName = Music_BuildFileName( MusicFile.sFileNameBase.c_str(), eMusicState );
- if (!S_FileExists( psMusicFileName ))
- {
- Music_Parse_Error( filename, build_string( "Music file \"", psMusicFileName, "\" not found!\n" ) );
- return qfalse; // have to return, because music data destroyed now
+ const char *psMusicFileName = Music_BuildFileName(MusicFile.sFileNameBase.c_str(), eMusicState);
+ if (!S_FileExists(psMusicFileName)) {
+ Music_Parse_Error(filename, build_string("Music file \"", psMusicFileName, "\" not found!\n"));
+ return qfalse; // have to return, because music data destroyed now
}
// check all transition music pieces exist, and that entry points into new pieces after transitions also exist...
//
- for (size_t iExitPoint=0; iExitPoint < MusicFile.MusicExitPoints.size(); iExitPoint++)
- {
- MusicExitPoint_t &MusicExitPoint = MusicFile.MusicExitPoints[ iExitPoint ];
-
- const char *psTransitionFileName = Music_BuildFileName( MusicExitPoint.sNextFile.c_str(), eMusicState );
- if (!S_FileExists( psTransitionFileName ))
- {
- Music_Parse_Error( filename, build_string( "Transition file \"", psTransitionFileName, "\" (entry \"", MusicExitPoint.sNextFile.c_str(), "\" ) not found!\n" ) );
- return qfalse; // have to return, because music data destroyed now
+ for (size_t iExitPoint = 0; iExitPoint < MusicFile.MusicExitPoints.size(); iExitPoint++) {
+ MusicExitPoint_t &MusicExitPoint = MusicFile.MusicExitPoints[iExitPoint];
+
+ const char *psTransitionFileName = Music_BuildFileName(MusicExitPoint.sNextFile.c_str(), eMusicState);
+ if (!S_FileExists(psTransitionFileName)) {
+ Music_Parse_Error(filename, build_string("Transition file \"", psTransitionFileName, "\" (entry \"", MusicExitPoint.sNextFile.c_str(),
+ "\" ) not found!\n"));
+ return qfalse; // have to return, because music data destroyed now
}
const char *psNextMark = MusicExitPoint.sNextMark.c_str();
- if (strlen(psNextMark)) // always NZ ptr
+ if (strlen(psNextMark)) // always NZ ptr
{
// then this must be "action" music under current rules...
//
- assert( !strcmp(psMusicStateType, Music_BaseStateToString(eBGRNDTRACK_ACTION) ? Music_BaseStateToString(eBGRNDTRACK_ACTION):"") );
+ assert(!strcmp(psMusicStateType, Music_BaseStateToString(eBGRNDTRACK_ACTION) ? Music_BaseStateToString(eBGRNDTRACK_ACTION) : ""));
//
// does this marker exist in the explore piece?
//
- MusicData_t::iterator itExploreMusicData = MusicData->find( Music_BaseStateToString(eBGRNDTRACK_EXPLORE) );
- if (itExploreMusicData != MusicData->end())
- {
+ MusicData_t::iterator itExploreMusicData = MusicData->find(Music_BaseStateToString(eBGRNDTRACK_EXPLORE));
+ if (itExploreMusicData != MusicData->end()) {
MusicFile_t &MusicFile_Explore = (*itExploreMusicData).second;
- if (!MusicFile_Explore.MusicEntryTimes.count(psNextMark))
- {
- Music_Parse_Error( filename, build_string( "Unable to find entry point \"", psNextMark, "\" in description for \"", MusicFile_Explore.sFileNameBase.c_str(), "\"\n" ) );
- return qfalse; // have to return, because music data destroyed now
+ if (!MusicFile_Explore.MusicEntryTimes.count(psNextMark)) {
+ Music_Parse_Error(filename, build_string("Unable to find entry point \"", psNextMark, "\" in description for \"",
+ MusicFile_Explore.sFileNameBase.c_str(), "\"\n"));
+ return qfalse; // have to return, because music data destroyed now
}
- }
- else
- {
- Music_Parse_Error( filename, build_string( "Unable to find ", Music_BaseStateToString( eBGRNDTRACK_EXPLORE ), " piece to match \"", MusicFile.sFileNameBase.c_str(), "\"\n" ) );
- return qfalse; // have to return, because music data destroyed now
+ } else {
+ Music_Parse_Error(filename, build_string("Unable to find ", Music_BaseStateToString(eBGRNDTRACK_EXPLORE), " piece to match \"",
+ MusicFile.sFileNameBase.c_str(), "\"\n"));
+ return qfalse; // have to return, because music data destroyed now
}
}
}
@@ -630,14 +560,12 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
return bReturn;
}
-
// returns ptr to music file, or NULL for error/missing...
//
-static MusicFile_t *Music_GetBaseMusicFile( const char *psMusicState ) // where psMusicState is (eg) "explore", "action" or "boss"
+static MusicFile_t *Music_GetBaseMusicFile(const char *psMusicState) // where psMusicState is (eg) "explore", "action" or "boss"
{
- MusicData_t::iterator it = MusicData->find( psMusicState );
- if (it != MusicData->end())
- {
+ MusicData_t::iterator it = MusicData->find(psMusicState);
+ if (it != MusicData->end()) {
MusicFile_t *pMusicFile = &(*it).second;
return pMusicFile;
}
@@ -645,109 +573,92 @@ static MusicFile_t *Music_GetBaseMusicFile( const char *psMusicState ) // where
return NULL;
}
-static MusicFile_t *Music_GetBaseMusicFile( MusicState_e eMusicState )
-{
- const char *psMusicStateString = Music_BaseStateToString( eMusicState );
- if ( psMusicStateString )
- {
- return Music_GetBaseMusicFile( psMusicStateString );
+static MusicFile_t *Music_GetBaseMusicFile(MusicState_e eMusicState) {
+ const char *psMusicStateString = Music_BaseStateToString(eMusicState);
+ if (psMusicStateString) {
+ return Music_GetBaseMusicFile(psMusicStateString);
}
return NULL;
}
-
// where label is (eg) "kejim_base"...
//
-qboolean Music_DynamicDataAvailable(const char *psDynamicMusicLabel)
-{
+qboolean Music_DynamicDataAvailable(const char *psDynamicMusicLabel) {
char sLevelName[MAX_QPATH];
- Q_strncpyz(sLevelName,COM_SkipPath( const_cast( (psDynamicMusicLabel&&psDynamicMusicLabel[0])?psDynamicMusicLabel:gsLevelNameFromServer.c_str() ) ),sizeof(sLevelName));
+ Q_strncpyz(sLevelName,
+ COM_SkipPath(const_cast((psDynamicMusicLabel && psDynamicMusicLabel[0]) ? psDynamicMusicLabel : gsLevelNameFromServer.c_str())),
+ sizeof(sLevelName));
Q_strlwr(sLevelName);
- if (strlen(sLevelName)) // avoid error messages when there's no music waiting to be played and we try and restart it...
+ if (strlen(sLevelName)) // avoid error messages when there's no music waiting to be played and we try and restart it...
{
- if (Music_ParseLeveldata(sLevelName))
- {
- return (qboolean)(Music_GetBaseMusicFile(eBGRNDTRACK_EXPLORE) &&
- Music_GetBaseMusicFile(eBGRNDTRACK_ACTION));
+ if (Music_ParseLeveldata(sLevelName)) {
+ return (qboolean)(Music_GetBaseMusicFile(eBGRNDTRACK_EXPLORE) && Music_GetBaseMusicFile(eBGRNDTRACK_ACTION));
}
}
return qfalse;
}
-const char *Music_GetFileNameForState( MusicState_e eMusicState)
-{
+const char *Music_GetFileNameForState(MusicState_e eMusicState) {
MusicFile_t *pMusicFile = NULL;
- switch (eMusicState)
- {
- case eBGRNDTRACK_EXPLORE:
- case eBGRNDTRACK_ACTION:
- case eBGRNDTRACK_BOSS:
- case eBGRNDTRACK_DEATH:
-
- pMusicFile = Music_GetBaseMusicFile( eMusicState );
- if (pMusicFile)
- {
- return Music_BuildFileName( pMusicFile->sFileNameBase.c_str(), eMusicState );
- }
- break;
-
- case eBGRNDTRACK_ACTIONTRANS0:
- case eBGRNDTRACK_ACTIONTRANS1:
- case eBGRNDTRACK_ACTIONTRANS2:
- case eBGRNDTRACK_ACTIONTRANS3:
-
- pMusicFile = Music_GetBaseMusicFile( eBGRNDTRACK_ACTION );
- if (pMusicFile)
- {
- size_t iTransNum = eMusicState - eBGRNDTRACK_ACTIONTRANS0;
- if (iTransNum < pMusicFile->MusicExitPoints.size())
- {
- return Music_BuildFileName( pMusicFile->MusicExitPoints[iTransNum].sNextFile.c_str(), eMusicState );
- }
+ switch (eMusicState) {
+ case eBGRNDTRACK_EXPLORE:
+ case eBGRNDTRACK_ACTION:
+ case eBGRNDTRACK_BOSS:
+ case eBGRNDTRACK_DEATH:
+
+ pMusicFile = Music_GetBaseMusicFile(eMusicState);
+ if (pMusicFile) {
+ return Music_BuildFileName(pMusicFile->sFileNameBase.c_str(), eMusicState);
+ }
+ break;
+
+ case eBGRNDTRACK_ACTIONTRANS0:
+ case eBGRNDTRACK_ACTIONTRANS1:
+ case eBGRNDTRACK_ACTIONTRANS2:
+ case eBGRNDTRACK_ACTIONTRANS3:
+
+ pMusicFile = Music_GetBaseMusicFile(eBGRNDTRACK_ACTION);
+ if (pMusicFile) {
+ size_t iTransNum = eMusicState - eBGRNDTRACK_ACTIONTRANS0;
+ if (iTransNum < pMusicFile->MusicExitPoints.size()) {
+ return Music_BuildFileName(pMusicFile->MusicExitPoints[iTransNum].sNextFile.c_str(), eMusicState);
}
- break;
-
- case eBGRNDTRACK_EXPLORETRANS0:
- case eBGRNDTRACK_EXPLORETRANS1:
- case eBGRNDTRACK_EXPLORETRANS2:
- case eBGRNDTRACK_EXPLORETRANS3:
-
- pMusicFile = Music_GetBaseMusicFile( eBGRNDTRACK_EXPLORE );
- if (pMusicFile)
- {
- size_t iTransNum = eMusicState - eBGRNDTRACK_EXPLORETRANS0;
- if (iTransNum < pMusicFile->MusicExitPoints.size())
- {
- return Music_BuildFileName( pMusicFile->MusicExitPoints[iTransNum].sNextFile.c_str(), eMusicState );
- }
+ }
+ break;
+
+ case eBGRNDTRACK_EXPLORETRANS0:
+ case eBGRNDTRACK_EXPLORETRANS1:
+ case eBGRNDTRACK_EXPLORETRANS2:
+ case eBGRNDTRACK_EXPLORETRANS3:
+
+ pMusicFile = Music_GetBaseMusicFile(eBGRNDTRACK_EXPLORE);
+ if (pMusicFile) {
+ size_t iTransNum = eMusicState - eBGRNDTRACK_EXPLORETRANS0;
+ if (iTransNum < pMusicFile->MusicExitPoints.size()) {
+ return Music_BuildFileName(pMusicFile->MusicExitPoints[iTransNum].sNextFile.c_str(), eMusicState);
}
- break;
-
- default:
- #ifndef FINAL_BUILD
- assert(0); // duh....what state are they asking for?
- Com_Printf( S_COLOR_RED "Music_GetFileNameForState( %d ) unhandled case!\n",eMusicState );
- #endif
- break;
+ }
+ break;
+
+ default:
+#ifndef FINAL_BUILD
+ assert(0); // duh....what state are they asking for?
+ Com_Printf(S_COLOR_RED "Music_GetFileNameForState( %d ) unhandled case!\n", eMusicState);
+#endif
+ break;
}
return NULL;
}
-
-
-qboolean Music_StateIsTransition( MusicState_e eMusicState )
-{
- return (qboolean)(eMusicState >= eBGRNDTRACK_FIRSTTRANSITION &&
- eMusicState <= eBGRNDTRACK_LASTTRANSITION);
+qboolean Music_StateIsTransition(MusicState_e eMusicState) {
+ return (qboolean)(eMusicState >= eBGRNDTRACK_FIRSTTRANSITION && eMusicState <= eBGRNDTRACK_LASTTRANSITION);
}
-
-qboolean Music_StateCanBeInterrupted( MusicState_e eMusicState, MusicState_e eProposedMusicState )
-{
+qboolean Music_StateCanBeInterrupted(MusicState_e eMusicState, MusicState_e eProposedMusicState) {
// death music can interrupt anything...
//
if (eProposedMusicState == eBGRNDTRACK_DEATH)
@@ -755,8 +666,7 @@ qboolean Music_StateCanBeInterrupted( MusicState_e eMusicState, MusicState_e ePr
//
// ... and can't be interrupted once started...(though it will internally-switch to silence at the end, rather than loop)
//
- if (eMusicState == eBGRNDTRACK_DEATH)
- {
+ if (eMusicState == eBGRNDTRACK_DEATH) {
return qfalse;
}
@@ -767,8 +677,7 @@ qboolean Music_StateCanBeInterrupted( MusicState_e eMusicState, MusicState_e ePr
//
// ... and can't be interrupted once started...
//
- if (eMusicState == eBGRNDTRACK_BOSS)
- {
+ if (eMusicState == eBGRNDTRACK_BOSS) {
// ...except by silence (or death, but again, that's already handled above)
//
if (eProposedMusicState == eBGRNDTRACK_SILENCE)
@@ -784,7 +693,7 @@ qboolean Music_StateCanBeInterrupted( MusicState_e eMusicState, MusicState_e ePr
// nothing can interrupt a transition (after above filters)...
//
- if (Music_StateIsTransition( eMusicState ))
+ if (Music_StateIsTransition(eMusicState))
return qfalse;
// current state is therefore interruptable...
@@ -792,8 +701,6 @@ qboolean Music_StateCanBeInterrupted( MusicState_e eMusicState, MusicState_e ePr
return qtrue;
}
-
-
// returns qtrue if music is allowed to transition out of current state, based on current play position...
// (doesn't bother returning final state after transition (eg action->transition->explore) becuase it's fairly obvious)
//
@@ -807,143 +714,119 @@ qboolean Music_StateCanBeInterrupted( MusicState_e eMusicState, MusicState_e ePr
// enum of transition track to switch to
// float time of entry point of new track *after* transition
//
-qboolean Music_AllowedToTransition( float fPlayingTimeElapsed,
- MusicState_e eMusicState,
- //
- MusicState_e *peTransition /* = NULL */,
- float *pfNewTrackEntryTime /* = NULL */
- )
-{
- const float fTimeEpsilon = 0.3f; // arb., how close we have to be to an exit point to take it.
- // if set too high then music change is sloppy
- // if set too low[/precise] then we might miss an exit if client fps is poor
-
-
- MusicFile_t *pMusicFile = Music_GetBaseMusicFile( eMusicState );
- if (pMusicFile && !pMusicFile->MusicExitTimes.empty())
- {
- MusicExitTime_t T;
- T.fTime = fPlayingTimeElapsed;
+qboolean Music_AllowedToTransition(float fPlayingTimeElapsed, MusicState_e eMusicState,
+ //
+ MusicState_e *peTransition /* = NULL */, float *pfNewTrackEntryTime /* = NULL */
+) {
+ const float fTimeEpsilon = 0.3f; // arb., how close we have to be to an exit point to take it.
+ // if set too high then music change is sloppy
+ // if set too low[/precise] then we might miss an exit if client fps is poor
+
+ MusicFile_t *pMusicFile = Music_GetBaseMusicFile(eMusicState);
+ if (pMusicFile && !pMusicFile->MusicExitTimes.empty()) {
+ MusicExitTime_t T;
+ T.fTime = fPlayingTimeElapsed;
// since a MusicExitTimes_t item is a sorted array, we can use the equal_range algorithm...
//
- std::pair itp = equal_range( pMusicFile->MusicExitTimes.begin(), pMusicFile->MusicExitTimes.end(), T);
+ std::pair itp =
+ equal_range(pMusicFile->MusicExitTimes.begin(), pMusicFile->MusicExitTimes.end(), T);
if (itp.first != pMusicFile->MusicExitTimes.begin())
- itp.first--; // encompass the one before, in case we've just missed an exit point by < fTimeEpsilon
- if (itp.second!= pMusicFile->MusicExitTimes.end())
- itp.second++; // increase range to one beyond, so we can do normal STL being/end looping below
- for (MusicExitTimes_t::iterator it = itp.first; it != itp.second; ++it)
- {
+ itp.first--; // encompass the one before, in case we've just missed an exit point by < fTimeEpsilon
+ if (itp.second != pMusicFile->MusicExitTimes.end())
+ itp.second++; // increase range to one beyond, so we can do normal STL being/end looping below
+ for (MusicExitTimes_t::iterator it = itp.first; it != itp.second; ++it) {
MusicExitTimes_t::iterator pExitTime = it;
- if ( Q_fabs(pExitTime->fTime - fPlayingTimeElapsed) <= fTimeEpsilon )
- {
+ if (Q_fabs(pExitTime->fTime - fPlayingTimeElapsed) <= fTimeEpsilon) {
// got an exit point!, work out feedback params...
//
size_t iExitPoint = pExitTime->iExitPoint;
//
// the two params to give back...
//
- MusicState_e eFeedBackTransition = eBGRNDTRACK_EXPLORETRANS0; // any old default
- float fFeedBackNewTrackEntryTime = 0.0f;
+ MusicState_e eFeedBackTransition = eBGRNDTRACK_EXPLORETRANS0; // any old default
+ float fFeedBackNewTrackEntryTime = 0.0f;
//
// check legality in case of crap data...
//
- if (iExitPoint < pMusicFile->MusicExitPoints.size())
- {
- MusicExitPoint_t &ExitPoint = pMusicFile->MusicExitPoints[ iExitPoint ];
+ if (iExitPoint < pMusicFile->MusicExitPoints.size()) {
+ MusicExitPoint_t &ExitPoint = pMusicFile->MusicExitPoints[iExitPoint];
- switch (eMusicState)
- {
- case eBGRNDTRACK_EXPLORE:
- {
- assert(iExitPoint < iMAX_EXPLORE_TRANSITIONS); // already been checked, but sanity
- assert(!ExitPoint.sNextMark.c_str()[0]); // simple error checking, but harmless if tripped. explore transitions go to silence, hence no entry time for [silence] state after transition
+ switch (eMusicState) {
+ case eBGRNDTRACK_EXPLORE: {
+ assert(iExitPoint < iMAX_EXPLORE_TRANSITIONS); // already been checked, but sanity
+ assert(!ExitPoint.sNextMark.c_str()[0]); // simple error checking, but harmless if tripped. explore transitions go to silence, hence no
+ // entry time for [silence] state after transition
- eFeedBackTransition = (MusicState_e) (eBGRNDTRACK_EXPLORETRANS0 + iExitPoint);
- }
- break;
+ eFeedBackTransition = (MusicState_e)(eBGRNDTRACK_EXPLORETRANS0 + iExitPoint);
+ } break;
- case eBGRNDTRACK_ACTION:
- {
- assert(iExitPoint < iMAX_ACTION_TRANSITIONS); // already been checked, but sanity
+ case eBGRNDTRACK_ACTION: {
+ assert(iExitPoint < iMAX_ACTION_TRANSITIONS); // already been checked, but sanity
- // if there's an entry marker point defined...
+ // if there's an entry marker point defined...
+ //
+ if (ExitPoint.sNextMark.c_str()[0]) {
+ MusicData_t::iterator itExploreMusicData = MusicData->find(Music_BaseStateToString(eBGRNDTRACK_EXPLORE));
+ //
+ // find "explore" music...
//
- if (ExitPoint.sNextMark.c_str()[0])
- {
- MusicData_t::iterator itExploreMusicData = MusicData->find( Music_BaseStateToString(eBGRNDTRACK_EXPLORE) );
+ if (itExploreMusicData != MusicData->end()) {
+ MusicFile_t &MusicFile_Explore = (*itExploreMusicData).second;
//
- // find "explore" music...
+ // find the entry marker within the music and read the time there...
//
- if (itExploreMusicData != MusicData->end())
- {
- MusicFile_t &MusicFile_Explore = (*itExploreMusicData).second;
- //
- // find the entry marker within the music and read the time there...
- //
- MusicEntryTimes_t::iterator itEntryTime = MusicFile_Explore.MusicEntryTimes.find( ExitPoint.sNextMark.c_str() );
- if (itEntryTime != MusicFile_Explore.MusicEntryTimes.end())
- {
- fFeedBackNewTrackEntryTime = (*itEntryTime).second;
- eFeedBackTransition = (MusicState_e) (eBGRNDTRACK_ACTIONTRANS0 + iExitPoint);
- }
- else
- {
- #ifndef FINAL_BUILD
- assert(0); // sanity, should have been caught elsewhere, but harmless to do this
- Com_Printf( S_COLOR_RED "Music_AllowedToTransition() unable to find entry marker \"%s\" in \"%s\"",ExitPoint.sNextMark.c_str(), MusicFile_Explore.sFileNameBase.c_str());
- #endif
- return qfalse;
- }
- }
- else
- {
- #ifndef FINAL_BUILD
- assert(0); // sanity, should have been caught elsewhere, but harmless to do this
- Com_Printf( S_COLOR_RED "Music_AllowedToTransition() unable to find %s version of \"%s\"\n",Music_BaseStateToString(eBGRNDTRACK_EXPLORE), pMusicFile->sFileNameBase.c_str());
- #endif
+ MusicEntryTimes_t::iterator itEntryTime = MusicFile_Explore.MusicEntryTimes.find(ExitPoint.sNextMark.c_str());
+ if (itEntryTime != MusicFile_Explore.MusicEntryTimes.end()) {
+ fFeedBackNewTrackEntryTime = (*itEntryTime).second;
+ eFeedBackTransition = (MusicState_e)(eBGRNDTRACK_ACTIONTRANS0 + iExitPoint);
+ } else {
+#ifndef FINAL_BUILD
+ assert(0); // sanity, should have been caught elsewhere, but harmless to do this
+ Com_Printf(S_COLOR_RED "Music_AllowedToTransition() unable to find entry marker \"%s\" in \"%s\"",
+ ExitPoint.sNextMark.c_str(), MusicFile_Explore.sFileNameBase.c_str());
+#endif
return qfalse;
}
+ } else {
+#ifndef FINAL_BUILD
+ assert(0); // sanity, should have been caught elsewhere, but harmless to do this
+ Com_Printf(S_COLOR_RED "Music_AllowedToTransition() unable to find %s version of \"%s\"\n",
+ Music_BaseStateToString(eBGRNDTRACK_EXPLORE), pMusicFile->sFileNameBase.c_str());
+#endif
+ return qfalse;
}
- else
- {
- eFeedBackTransition = eBGRNDTRACK_ACTIONTRANS0;
- fFeedBackNewTrackEntryTime = 0.0f; // already set to this, but FYI
- }
+ } else {
+ eFeedBackTransition = eBGRNDTRACK_ACTIONTRANS0;
+ fFeedBackNewTrackEntryTime = 0.0f; // already set to this, but FYI
}
- break;
+ } break;
- default:
- {
- #ifndef FINAL_BUILD
- assert(0);
- Com_Printf( S_COLOR_RED "Music_AllowedToTransition(): No code to transition from music type %d\n",eMusicState);
- #endif
- return qfalse;
- }
- break;
+ default: {
+#ifndef FINAL_BUILD
+ assert(0);
+ Com_Printf(S_COLOR_RED "Music_AllowedToTransition(): No code to transition from music type %d\n", eMusicState);
+#endif
+ return qfalse;
+ } break;
}
- }
- else
- {
- #ifndef FINAL_BUILD
+ } else {
+#ifndef FINAL_BUILD
assert(0);
- Com_Printf( S_COLOR_RED "Music_AllowedToTransition(): Illegal exit point %d, max = %d (music: \"%s\")\n",iExitPoint, pMusicFile->MusicExitPoints.size()-1, pMusicFile->sFileNameBase.c_str() );
- #endif
+ Com_Printf(S_COLOR_RED "Music_AllowedToTransition(): Illegal exit point %d, max = %d (music: \"%s\")\n", iExitPoint,
+ pMusicFile->MusicExitPoints.size() - 1, pMusicFile->sFileNameBase.c_str());
+#endif
return qfalse;
}
-
// feed back answers...
//
- if ( peTransition)
- {
+ if (peTransition) {
*peTransition = eFeedBackTransition;
}
- if ( pfNewTrackEntryTime )
- {
+ if (pfNewTrackEntryTime) {
*pfNewTrackEntryTime = fFeedBackNewTrackEntryTime;
}
@@ -955,18 +838,15 @@ qboolean Music_AllowedToTransition( float fPlayingTimeElapsed,
return qfalse;
}
-
// typically used to get a (predefined) random entry point for the action music, but will work on any defined type with entry points,
// defaults safely to 0.0f if no info available...
//
-float Music_GetRandomEntryTime( MusicState_e eMusicState )
-{
- MusicData_t::iterator itMusicData = MusicData->find( Music_BaseStateToString( eMusicState ) );
- if (itMusicData != MusicData->end())
- {
+float Music_GetRandomEntryTime(MusicState_e eMusicState) {
+ MusicData_t::iterator itMusicData = MusicData->find(Music_BaseStateToString(eMusicState));
+ if (itMusicData != MusicData->end()) {
MusicFile_t &MusicFile = (*itMusicData).second;
- if (MusicFile.MusicEntryTimes.size()) // make sure at least one defined, else default to start
+ if (MusicFile.MusicEntryTimes.size()) // make sure at least one defined, else default to start
{
// Quake's random number generator isn't very good, so instead of this:
//
@@ -974,23 +854,20 @@ float Music_GetRandomEntryTime( MusicState_e eMusicState )
//
// ... I'll do this (ensuring we don't get the same result on two consecutive calls, but without while-loop)...
//
- static int iPrevRandomNumber = -1;
- static int iCallCount = 0;
- iCallCount++;
- int iRandomEntryNum = (rand()+iCallCount) % (MusicFile.MusicEntryTimes.size()); // legal range
- if (iRandomEntryNum == iPrevRandomNumber && MusicFile.MusicEntryTimes.size()>1)
- {
+ static int iPrevRandomNumber = -1;
+ static int iCallCount = 0;
+ iCallCount++;
+ int iRandomEntryNum = (rand() + iCallCount) % (MusicFile.MusicEntryTimes.size()); // legal range
+ if (iRandomEntryNum == iPrevRandomNumber && MusicFile.MusicEntryTimes.size() > 1) {
iRandomEntryNum += 1;
iRandomEntryNum %= (MusicFile.MusicEntryTimes.size());
}
iPrevRandomNumber = iRandomEntryNum;
-// OutputDebugString(va("Music_GetRandomEntryTime(): Entry %d\n",iRandomEntryNum));
+ // OutputDebugString(va("Music_GetRandomEntryTime(): Entry %d\n",iRandomEntryNum));
- for (MusicEntryTimes_t::iterator itEntryTime = MusicFile.MusicEntryTimes.begin(); itEntryTime != MusicFile.MusicEntryTimes.end(); ++itEntryTime)
- {
- if (!iRandomEntryNum--)
- {
+ for (MusicEntryTimes_t::iterator itEntryTime = MusicFile.MusicEntryTimes.begin(); itEntryTime != MusicFile.MusicEntryTimes.end(); ++itEntryTime) {
+ if (!iRandomEntryNum--) {
return (*itEntryTime).second;
}
}
@@ -1002,17 +879,14 @@ float Music_GetRandomEntryTime( MusicState_e eMusicState )
// info only, used in "soundinfo" command...
//
-const char *Music_GetLevelSetName(void)
-{
- if (Q_stricmp(gsLevelNameForCompare.c_str(), gsLevelNameForLoad.c_str()))
- {
+const char *Music_GetLevelSetName(void) {
+ if (Q_stricmp(gsLevelNameForCompare.c_str(), gsLevelNameForLoad.c_str())) {
// music remap via USES command...
//
- return va("%s -> %s",gsLevelNameForCompare.c_str(), gsLevelNameForLoad.c_str());
+ return va("%s -> %s", gsLevelNameForCompare.c_str(), gsLevelNameForLoad.c_str());
}
return gsLevelNameForLoad.c_str();
}
///////////////// eof /////////////////////
-
diff --git a/code/client/vmachine.cpp b/code/client/vmachine.cpp
index 0ee1464468..3df78c536f 100644
--- a/code/client/vmachine.cpp
+++ b/code/client/vmachine.cpp
@@ -32,18 +32,17 @@ VIRTUAL MACHINE
==============================================================
*/
-intptr_t VM_Call( int callnum, ... )
-{
- intptr_t args[8] = { 0 };
+intptr_t VM_Call(int callnum, ...) {
+ intptr_t args[8] = {0};
va_list ap;
- if ( cgvm.entryPoint ) {
- va_start( ap, callnum );
- for ( size_t i = 0; i < ARRAY_LEN( args ); i++ )
- args[i] = va_arg( ap, intptr_t );
+ if (cgvm.entryPoint) {
+ va_start(ap, callnum);
+ for (size_t i = 0; i < ARRAY_LEN(args); i++)
+ args[i] = va_arg(ap, intptr_t);
va_end(ap);
- return cgvm.entryPoint( callnum, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] );
+ return cgvm.entryPoint(callnum, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
}
return -1;
}
@@ -63,9 +62,9 @@ intptr_t VM_Call( int callnum, ... )
// works on. Rather than add the performance hit for those platforms, the original code is still in use there.
// For speed, we just grab 9 arguments, and don't worry about exactly how many the syscall actually needs; the extra is
// thrown away.
-extern intptr_t CL_CgameSystemCalls( intptr_t *args );
+extern intptr_t CL_CgameSystemCalls(intptr_t *args);
-intptr_t VM_DllSyscall( intptr_t arg, ... ) {
+intptr_t VM_DllSyscall(intptr_t arg, ...) {
#if !id386 || defined __clang__ || defined MACOS_X
// rcg010206 - see commentary above
intptr_t args[16];
@@ -73,13 +72,13 @@ intptr_t VM_DllSyscall( intptr_t arg, ... ) {
args[0] = arg;
- va_start( ap, arg );
- for (size_t i = 1; i < ARRAY_LEN (args); i++)
- args[i] = va_arg( ap, intptr_t );
- va_end( ap );
+ va_start(ap, arg);
+ for (size_t i = 1; i < ARRAY_LEN(args); i++)
+ args[i] = va_arg(ap, intptr_t);
+ va_end(ap);
- return CL_CgameSystemCalls( args );
+ return CL_CgameSystemCalls(args);
#else // original id code
- return CL_CgameSystemCalls( &arg );
+ return CL_CgameSystemCalls(&arg);
#endif
}
diff --git a/code/game/AI_Animal.cpp b/code/game/AI_Animal.cpp
index 4626ff4d1f..1039888040 100644
--- a/code/game/AI_Animal.cpp
+++ b/code/game/AI_Animal.cpp
@@ -28,44 +28,38 @@ along with this program; if not, see .
#endif
#include "../Ratl/vector_vs.h"
-#define MAX_PACKS 10
+#define MAX_PACKS 10
-#define LEAVE_PACK_DISTANCE 1000
-#define JOIN_PACK_DISTANCE 800
-#define WANDER_RANGE 1000
-#define FRIGHTEN_DISTANCE 300
+#define LEAVE_PACK_DISTANCE 1000
+#define JOIN_PACK_DISTANCE 800
+#define WANDER_RANGE 1000
+#define FRIGHTEN_DISTANCE 300
-extern qboolean G_PlayerSpawned( void );
-
-ratl::vector_vs mPacks;
+extern qboolean G_PlayerSpawned(void);
+ratl::vector_vs mPacks;
////////////////////////////////////////////////////////////////////////////////////////
// Update The Packs, Delete Dead Leaders, Join / Split Packs, Find MY Leader
////////////////////////////////////////////////////////////////////////////////////////
-gentity_t* NPC_AnimalUpdateLeader(void)
-{
+gentity_t *NPC_AnimalUpdateLeader(void) {
// Find The Closest Pack Leader, Not Counting Myself
//---------------------------------------------------
- gentity_t* closestLeader = 0;
- float closestDist = 0;
- int myLeaderNum = 0;
+ gentity_t *closestLeader = 0;
+ float closestDist = 0;
+ int myLeaderNum = 0;
- for (int i=0; ihealth<=0)
- {
- if (mPacks[i]==NPC->client->leader)
- {
+ if (mPacks[i] == 0 || mPacks[i]->health <= 0) {
+ if (mPacks[i] == NPC->client->leader) {
NPC->client->leader = 0;
}
mPacks.erase_swap(i);
- if (i>=mPacks.size())
- {
+ if (i >= mPacks.size()) {
closestLeader = 0;
break;
}
@@ -73,15 +67,13 @@ gentity_t* NPC_AnimalUpdateLeader(void)
// Don't Count Self
//------------------
- if (mPacks[i]==NPC)
- {
+ if (mPacks[i] == NPC) {
myLeaderNum = i;
continue;
}
- float Dist = Distance(mPacks[i]->currentOrigin, NPC->currentOrigin);
- if (!closestLeader || DistcurrentOrigin, NPC->currentOrigin);
+ if (!closestLeader || Dist < closestDist) {
closestDist = Dist;
closestLeader = mPacks[i];
}
@@ -89,13 +81,11 @@ gentity_t* NPC_AnimalUpdateLeader(void)
// In Joining Distance?
//----------------------
- if (closestLeader && closestDistclient->leader==NPC)
- {
- mPacks.erase_swap(myLeaderNum); // Erase Myself From The Leader List
+ if (NPC->client->leader == NPC) {
+ mPacks.erase_swap(myLeaderNum); // Erase Myself From The Leader List
}
// Join The Pack!
@@ -103,34 +93,28 @@ gentity_t* NPC_AnimalUpdateLeader(void)
NPC->client->leader = closestLeader;
}
-
// Do I Have A Leader?
//---------------------
- if (NPC->client->leader)
- {
+ if (NPC->client->leader) {
// AM I A Leader?
//----------------
- if (NPC->client->leader!=NPC)
- {
+ if (NPC->client->leader != NPC) {
// If Our Leader Is Dead, Clear Him Out
- if ( NPC->client->leader->health<=0 || NPC->client->leader->inuse == 0)
- {
+ if (NPC->client->leader->health <= 0 || NPC->client->leader->inuse == 0) {
NPC->client->leader = 0;
}
// If My Leader Isn't His Own Leader, Then, Use His Leader
//---------------------------------------------------------
- else if (NPC->client->leader->client->leader!=NPC->client->leader)
- {
+ else if (NPC->client->leader->client->leader != NPC->client->leader) {
// Eh. Can this get more confusing?
NPC->client->leader = NPC->client->leader->client->leader;
}
// If Our Leader Is Too Far Away, Clear Him Out
//------------------------------------------------------
- else if ( Distance(NPC->client->leader->currentOrigin, NPC->currentOrigin)>LEAVE_PACK_DISTANCE)
- {
+ else if (Distance(NPC->client->leader->currentOrigin, NPC->currentOrigin) > LEAVE_PACK_DISTANCE) {
NPC->client->leader = 0;
}
}
@@ -139,164 +123,133 @@ gentity_t* NPC_AnimalUpdateLeader(void)
// If We Couldn't Find A Leader, Then Become One
//-----------------------------------------------
- else if (!mPacks.full())
- {
+ else if (!mPacks.full()) {
NPC->client->leader = NPC;
mPacks.push_back(NPC);
}
return NPC->client->leader;
}
-
-
-
/*
-------------------------
NPC_BSAnimal_Default
-------------------------
*/
-void NPC_BSAnimal_Default( void )
-{
- if (!NPC || !NPC->client)
- {
+void NPC_BSAnimal_Default(void) {
+ if (!NPC || !NPC->client) {
return;
}
// Update Some Positions
//-----------------------
- CVec3 CurrentLocation(NPC->currentOrigin);
-
+ CVec3 CurrentLocation(NPC->currentOrigin);
// Update The Leader
//-------------------
- gentity_t* leader = NPC_AnimalUpdateLeader();
-
+ gentity_t *leader = NPC_AnimalUpdateLeader();
// Select Closest Threat Location
//--------------------------------
- CVec3 ThreatLocation(0,0,0);
+ CVec3 ThreatLocation(0, 0, 0);
qboolean PlayerSpawned = G_PlayerSpawned();
- if ( PlayerSpawned )
- {//player is actually in the level now
+ if (PlayerSpawned) { // player is actually in the level now
ThreatLocation = player->currentOrigin;
}
- int alertEvent = NPC_CheckAlertEvents(qtrue, qtrue, -1, qfalse, AEL_MINOR, qfalse);
- if ( alertEvent >= 0 )
- {
+ int alertEvent = NPC_CheckAlertEvents(qtrue, qtrue, -1, qfalse, AEL_MINOR, qfalse);
+ if (alertEvent >= 0) {
alertEvent_t *event = &level.alertEvents[alertEvent];
- if (event->owner!=NPC && Distance(event->position, CurrentLocation.v)radius)
- {
+ if (event->owner != NPC && Distance(event->position, CurrentLocation.v) < event->radius) {
ThreatLocation = event->position;
}
}
+ // float DistToThreat = CurrentLocation.Dist(ThreatLocation);
+ // float DistFromHome = CurrentLocation.Dist(mHome);
-
-// float DistToThreat = CurrentLocation.Dist(ThreatLocation);
-// float DistFromHome = CurrentLocation.Dist(mHome);
-
-
-
- bool EvadeThreat = (level.timeinvestigateSoundDebounceTime);
- bool CharmedDocile = (level.timeconfusionTime);
- bool CharmedApproach = (level.timecharmedTime);
-
-
+ bool EvadeThreat = (level.time < NPCInfo->investigateSoundDebounceTime);
+ bool CharmedDocile = (level.time < NPCInfo->confusionTime);
+ bool CharmedApproach = (level.time < NPCInfo->charmedTime);
// If Not Already Evading, Test To See If We Should "Know" About The Threat
//--------------------------------------------------------------------------
-/* if (false && !EvadeThreat && PlayerSpawned && (DistToThreatcurrentAngles);
- LookAim.AngToVec();
- CVec3 MyPos(CurrentLocation);
- MyPos -= ThreatLocation;
- MyPos.SafeNorm();
-
- float DirectionSimilarity = MyPos.Dot(LookAim);
-
- if (fabsf(DirectionSimilarity)<0.8f)
+ /* if (false && !EvadeThreat && PlayerSpawned && (DistToThreatinvestigateSoundDebounceTime = level.time + Q_irand(0, 1000);
- VectorCopy(ThreatLocation.v, NPCInfo->investigateGoal);
- }
- }*/
-
-
+ CVec3 LookAim(NPC->currentAngles);
+ LookAim.AngToVec();
+ CVec3 MyPos(CurrentLocation);
+ MyPos -= ThreatLocation;
+ MyPos.SafeNorm();
+ float DirectionSimilarity = MyPos.Dot(LookAim);
+ if (fabsf(DirectionSimilarity)<0.8f)
+ {
+ EvadeThreat = true;
+ NPCInfo->investigateSoundDebounceTime = level.time + Q_irand(0, 1000);
+ VectorCopy(ThreatLocation.v, NPCInfo->investigateGoal);
+ }
+ }*/
STEER::Activate(NPC);
{
// Charmed Approach - Walk TOWARD The Threat Location
//----------------------------------------------------
- if (CharmedApproach)
- {
+ if (CharmedApproach) {
NAV::GoTo(NPC, NPCInfo->investigateGoal);
}
// Charmed Docile - Stay Put
//---------------------------
- else if (CharmedDocile)
- {
+ else if (CharmedDocile) {
NAV::ClearPath(NPC);
STEER::Stop(NPC);
}
// Run Away From This Threat
//---------------------------
- else if (EvadeThreat)
- {
+ else if (EvadeThreat) {
NAV::ClearPath(NPC);
STEER::Flee(NPC, NPCInfo->investigateGoal);
}
// Normal Behavior
//-----------------
- else
- {
+ else {
// Follow Our Pack Leader!
//-------------------------
- if (leader && leader!=NPC)
- {
- float followDist = 100.0f;
- float curDist = Distance(NPC->currentOrigin, leader->followPos);
-
+ if (leader && leader != NPC) {
+ float followDist = 100.0f;
+ float curDist = Distance(NPC->currentOrigin, leader->followPos);
// Update The Leader's Follow Position
//-------------------------------------
STEER::FollowLeader(NPC, leader, followDist);
- bool inSeekRange = (curDistfollowPosWaypoint));
- bool leaderStop = ((level.time - leader->lastMoveTime)>500);
+ bool inSeekRange = (curDist < followDist * 10.0f);
+ bool onNbrPoints = (NAV::OnNeighboringPoints(NAV::GetNearestNode(NPC), leader->followPosWaypoint));
+ bool leaderStop = ((level.time - leader->lastMoveTime) > 500);
// If Close Enough, Dump Any Existing Path
//-----------------------------------------
- if (inSeekRange || onNbrPoints)
- {
+ if (inSeekRange || onNbrPoints) {
NAV::ClearPath(NPC);
// If The Leader Isn't Moving, Stop
//----------------------------------
- if (leaderStop)
- {
+ if (leaderStop) {
STEER::Stop(NPC);
}
// Otherwise, Try To Get To The Follow Position
//----------------------------------------------
- else
- {
- STEER::Seek(NPC, leader->followPos, fabsf(followDist)/2.0f/*slowing distance*/, 1.0f/*wight*/, leader->resultspeed);
+ else {
+ STEER::Seek(NPC, leader->followPos, fabsf(followDist) / 2.0f /*slowing distance*/, 1.0f /*wight*/, leader->resultspeed);
}
}
// Otherwise, Get A Path To The Follow Position
//----------------------------------------------
- else
- {
+ else {
NAV::GoTo(NPC, leader->followPosWaypoint);
}
STEER::Separation(NPC, 4.0f);
@@ -305,66 +258,54 @@ void NPC_BSAnimal_Default( void )
// Leader AI - Basically Wander
//------------------------------
- else
- {
+ else {
// Are We Doing A Path?
//----------------------
- bool HasPath = NAV::HasPath(NPC);
- if (HasPath)
- {
+ bool HasPath = NAV::HasPath(NPC);
+ if (HasPath) {
HasPath = NAV::UpdatePath(NPC);
- if (HasPath)
- {
- STEER::Path(NPC); // Follow The Path
+ if (HasPath) {
+ STEER::Path(NPC); // Follow The Path
STEER::AvoidCollisions(NPC);
}
}
- if (!HasPath)
- {
+ if (!HasPath) {
// If Debounce Time Has Expired, Choose A New Sub State
//------------------------------------------------------
- if (NPCInfo->investigateDebounceTimeinvestigateDebounceTime < level.time) {
// Clear Out Flags From The Previous Substate
//--------------------------------------------
- NPCInfo->aiFlags &= ~NPCAI_OFF_PATH;
- NPCInfo->aiFlags &= ~NPCAI_WALKING;
-
+ NPCInfo->aiFlags &= ~NPCAI_OFF_PATH;
+ NPCInfo->aiFlags &= ~NPCAI_WALKING;
// Pick Another Spot
//-------------------
- int NEXTSUBSTATE = Q_irand(0, 10);
-
- bool RandomPathNode = (NEXTSUBSTATE<8); //(NEXTSUBSTATE<9);
- bool PathlessWander = (NEXTSUBSTATE<9); //false;
-
+ int NEXTSUBSTATE = Q_irand(0, 10);
+ bool RandomPathNode = (NEXTSUBSTATE < 8); //(NEXTSUBSTATE<9);
+ bool PathlessWander = (NEXTSUBSTATE < 9); // false;
// Random Path Node
//------------------
- if (RandomPathNode)
- {
+ if (RandomPathNode) {
// Sometimes, Walk
//-----------------
- if (Q_irand(0, 1)==0)
- {
- NPCInfo->aiFlags |= NPCAI_WALKING;
+ if (Q_irand(0, 1) == 0) {
+ NPCInfo->aiFlags |= NPCAI_WALKING;
}
NPCInfo->investigateDebounceTime = level.time + Q_irand(3000, 10000);
- NAV::FindPath(NPC, NAV::ChooseRandomNeighbor(NAV::GetNearestNode(NPC)));//, mHome.v, WANDER_RANGE));
+ NAV::FindPath(NPC, NAV::ChooseRandomNeighbor(NAV::GetNearestNode(NPC))); //, mHome.v, WANDER_RANGE));
}
// Pathless Wandering
//--------------------
- else if (PathlessWander)
- {
+ else if (PathlessWander) {
// Sometimes, Walk
//-----------------
- if (Q_irand(0, 1)==0)
- {
- NPCInfo->aiFlags |= NPCAI_WALKING;
+ if (Q_irand(0, 1) == 0) {
+ NPCInfo->aiFlags |= NPCAI_WALKING;
}
NPCInfo->investigateDebounceTime = level.time + Q_irand(3000, 10000);
@@ -373,30 +314,25 @@ void NPC_BSAnimal_Default( void )
// Just Stand Here
//-----------------
- else
- {
+ else {
NPCInfo->investigateDebounceTime = level.time + Q_irand(2000, 6000);
- //NPC_SetAnim(NPC, SETANIM_BOTH, ((Q_irand(0, 1)==0)?(BOTH_GUARD_LOOKAROUND1):(BOTH_GUARD_IDLE1)), SETANIM_FLAG_NORMAL);
+ // NPC_SetAnim(NPC, SETANIM_BOTH, ((Q_irand(0, 1)==0)?(BOTH_GUARD_LOOKAROUND1):(BOTH_GUARD_IDLE1)), SETANIM_FLAG_NORMAL);
}
}
// Ok, So We Don't Have A Path, And Debounce Time Is Still Active, So We Are Either Wandering Or Looking Around
//--------------------------------------------------------------------------------------------------------------
- else
- {
- // if (DistFromHome>(WANDER_RANGE))
- // {
- // STEER::Seek(NPC, mHome);
- // }
- // else
+ else {
+ // if (DistFromHome>(WANDER_RANGE))
+ // {
+ // STEER::Seek(NPC, mHome);
+ // }
+ // else
{
- if (NPCInfo->aiFlags & NPCAI_OFF_PATH)
- {
+ if (NPCInfo->aiFlags & NPCAI_OFF_PATH) {
STEER::Wander(NPC);
STEER::AvoidCollisions(NPC);
- }
- else
- {
+ } else {
STEER::Stop(NPC);
}
}
@@ -407,6 +343,5 @@ void NPC_BSAnimal_Default( void )
}
STEER::DeActivate(NPC, &ucmd);
- NPC_UpdateAngles( qtrue, qtrue );
+ NPC_UpdateAngles(qtrue, qtrue);
}
-
diff --git a/code/game/AI_AssassinDroid.cpp b/code/game/AI_AssassinDroid.cpp
index 26368d9463..7d36d090b7 100644
--- a/code/game/AI_AssassinDroid.cpp
+++ b/code/game/AI_AssassinDroid.cpp
@@ -23,68 +23,56 @@ along with this program; if not, see .
#include "bg_public.h"
#include "b_local.h"
-//custom anims:
- //both_attack1 - running attack
- //both_attack2 - crouched attack
- //both_attack3 - standing attack
- //both_stand1idle1 - idle
- //both_crouch2stand1 - uncrouch
- //both_death4 - running death
-
-#define ASSASSIN_SHIELD_SIZE 75
-#define TURN_ON 0x00000000
-#define TURN_OFF 0x00000100
-
-
+// custom anims:
+// both_attack1 - running attack
+// both_attack2 - crouched attack
+// both_attack3 - standing attack
+// both_stand1idle1 - idle
+// both_crouch2stand1 - uncrouch
+// both_death4 - running death
+
+#define ASSASSIN_SHIELD_SIZE 75
+#define TURN_ON 0x00000000
+#define TURN_OFF 0x00000100
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-bool BubbleShield_IsOn()
-{
- return (NPC->flags&FL_SHIELDED);
-}
+bool BubbleShield_IsOn() { return (NPC->flags & FL_SHIELDED); }
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void BubbleShield_TurnOn()
-{
- if (!BubbleShield_IsOn())
- {
+void BubbleShield_TurnOn() {
+ if (!BubbleShield_IsOn()) {
NPC->flags |= FL_SHIELDED;
NPC->client->ps.powerups[PW_GALAK_SHIELD] = Q3_INFINITE;
- gi.G2API_SetSurfaceOnOff( &NPC->ghoul2[NPC->playerModel], "force_shield", TURN_ON );
+ gi.G2API_SetSurfaceOnOff(&NPC->ghoul2[NPC->playerModel], "force_shield", TURN_ON);
}
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void BubbleShield_TurnOff()
-{
- if ( BubbleShield_IsOn())
- {
+void BubbleShield_TurnOff() {
+ if (BubbleShield_IsOn()) {
NPC->flags &= ~FL_SHIELDED;
NPC->client->ps.powerups[PW_GALAK_SHIELD] = 0;
- gi.G2API_SetSurfaceOnOff( &NPC->ghoul2[NPC->playerModel], "force_shield", TURN_OFF );
+ gi.G2API_SetSurfaceOnOff(&NPC->ghoul2[NPC->playerModel], "force_shield", TURN_OFF);
}
}
-
////////////////////////////////////////////////////////////////////////////////////////
// Push A Particular Ent
////////////////////////////////////////////////////////////////////////////////////////
-void BubbleShield_PushEnt(gentity_t* pushed, vec3_t smackDir)
-{
- G_Damage(pushed, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE);
+void BubbleShield_PushEnt(gentity_t *pushed, vec3_t smackDir) {
+ G_Damage(pushed, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer + 1) * Q_irand(5, 10), DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE);
G_Throw(pushed, smackDir, 10);
// Make Em Electric
//------------------
- pushed->s.powerups |= (1 << PW_SHOCKED);
- if (pushed->client)
- {
+ pushed->s.powerups |= (1 << PW_SHOCKED);
+ if (pushed->client) {
pushed->client->ps.powerups[PW_SHOCKED] = level.time + 1000;
}
}
@@ -92,42 +80,36 @@ void BubbleShield_PushEnt(gentity_t* pushed, vec3_t smackDir)
////////////////////////////////////////////////////////////////////////////////////////
// Go Through All The Ents Within The Radius Of The Shield And Push Them
////////////////////////////////////////////////////////////////////////////////////////
-void BubbleShield_PushRadiusEnts()
-{
- int numEnts;
- gentity_t* radiusEnts[128];
- const float radius = ASSASSIN_SHIELD_SIZE;
- vec3_t mins, maxs;
- vec3_t smackDir;
- float smackDist;
-
- for (int i = 0; i < 3; i++ )
- {
+void BubbleShield_PushRadiusEnts() {
+ int numEnts;
+ gentity_t *radiusEnts[128];
+ const float radius = ASSASSIN_SHIELD_SIZE;
+ vec3_t mins, maxs;
+ vec3_t smackDir;
+ float smackDist;
+
+ for (int i = 0; i < 3; i++) {
mins[i] = NPC->currentOrigin[i] - radius;
maxs[i] = NPC->currentOrigin[i] + radius;
}
numEnts = gi.EntitiesInBox(mins, maxs, radiusEnts, 128);
- for (int entIndex=0; entIndexclient)
- {
+ if (!radiusEnts[entIndex] || !radiusEnts[entIndex]->client) {
continue;
}
// Don't Push Away Other Assassin Droids
//---------------------------------------
- if (radiusEnts[entIndex]->client->NPC_class==NPC->client->NPC_class)
- {
+ if (radiusEnts[entIndex]->client->NPC_class == NPC->client->NPC_class) {
continue;
}
// Should Have Already Pushed The Enemy If He Touched Us
//-------------------------------------------------------
- if (NPC->enemy && NPCInfo->touchedByPlayer==NPC->enemy && radiusEnts[entIndex]==NPC->enemy)
- {
+ if (NPC->enemy && NPCInfo->touchedByPlayer == NPC->enemy && radiusEnts[entIndex] == NPC->enemy) {
continue;
}
@@ -135,8 +117,7 @@ void BubbleShield_PushRadiusEnts()
//-----------------------------
VectorSubtract(radiusEnts[entIndex]->currentOrigin, NPC->currentOrigin, smackDir);
smackDist = VectorNormalize(smackDir);
- if (smackDisthealth<=0)
- {
- if (BubbleShield_IsOn())
- {
+ if (NPC->health <= 0) {
+ if (BubbleShield_IsOn()) {
BubbleShield_TurnOff();
}
return;
}
-
// Recharge Shields
//------------------
- NPC->client->ps.stats[STAT_ARMOR] += 1;
- if (NPC->client->ps.stats[STAT_ARMOR]>250)
- {
+ NPC->client->ps.stats[STAT_ARMOR] += 1;
+ if (NPC->client->ps.stats[STAT_ARMOR] > 250) {
NPC->client->ps.stats[STAT_ARMOR] = 250;
}
-
-
-
// If We Have Enough Armor And Are Not Shooting Right Now, Kick The Shield On
//----------------------------------------------------------------------------
- if (NPC->client->ps.stats[STAT_ARMOR]>100 && TIMER_Done(NPC, "ShieldsDown"))
- {
+ if (NPC->client->ps.stats[STAT_ARMOR] > 100 && TIMER_Done(NPC, "ShieldsDown")) {
// Check On Timers To Raise And Lower Shields
//--------------------------------------------
- if ((level.time - NPCInfo->enemyLastSeenTime)<1000 && TIMER_Done(NPC, "ShieldsUp"))
- {
- TIMER_Set(NPC, "ShieldsDown", 2000); // Drop Shields
- TIMER_Set(NPC, "ShieldsUp", Q_irand(4000, 5000)); // Then Bring Them Back Up For At Least 3 sec
+ if ((level.time - NPCInfo->enemyLastSeenTime) < 1000 && TIMER_Done(NPC, "ShieldsUp")) {
+ TIMER_Set(NPC, "ShieldsDown", 2000); // Drop Shields
+ TIMER_Set(NPC, "ShieldsUp", Q_irand(4000, 5000)); // Then Bring Them Back Up For At Least 3 sec
}
BubbleShield_TurnOn();
- if (BubbleShield_IsOn())
- {
+ if (BubbleShield_IsOn()) {
// Update Our Shader Value
//-------------------------
- NPC->client->renderInfo.customRGBA[0] =
- NPC->client->renderInfo.customRGBA[1] =
- NPC->client->renderInfo.customRGBA[2] =
- NPC->client->renderInfo.customRGBA[3] = (NPC->client->ps.stats[STAT_ARMOR] - 100);
-
+ NPC->client->renderInfo.customRGBA[0] = NPC->client->renderInfo.customRGBA[1] = NPC->client->renderInfo.customRGBA[2] =
+ NPC->client->renderInfo.customRGBA[3] = (NPC->client->ps.stats[STAT_ARMOR] - 100);
// If Touched By An Enemy, ALWAYS Shove Them
//-------------------------------------------
- if (NPC->enemy && NPCInfo->touchedByPlayer==NPC->enemy)
- {
+ if (NPC->enemy && NPCInfo->touchedByPlayer == NPC->enemy) {
vec3_t dir;
VectorSubtract(NPC->enemy->currentOrigin, NPC->currentOrigin, dir);
VectorNormalize(dir);
@@ -209,11 +175,9 @@ void BubbleShield_Update()
}
}
-
// Shields Gone
//--------------
- else
- {
+ else {
BubbleShield_TurnOff();
}
}
\ No newline at end of file
diff --git a/code/game/AI_Atst.cpp b/code/game/AI_Atst.cpp
index 26ce45cdfd..8c9d80126d 100644
--- a/code/game/AI_Atst.cpp
+++ b/code/game/AI_Atst.cpp
@@ -24,14 +24,13 @@ along with this program; if not, see .
#include "g_functions.h"
#include "../cgame/cg_local.h"
+#define MIN_MELEE_RANGE 640
+#define MIN_MELEE_RANGE_SQR (MIN_MELEE_RANGE * MIN_MELEE_RANGE)
-#define MIN_MELEE_RANGE 640
-#define MIN_MELEE_RANGE_SQR ( MIN_MELEE_RANGE * MIN_MELEE_RANGE )
+#define MIN_DISTANCE 128
+#define MIN_DISTANCE_SQR (MIN_DISTANCE * MIN_DISTANCE)
-#define MIN_DISTANCE 128
-#define MIN_DISTANCE_SQR ( MIN_DISTANCE * MIN_DISTANCE )
-
-#define TURN_OFF 0x00000100//G2SURFACEFLAG_NODESCENDANTS
+#define TURN_OFF 0x00000100 // G2SURFACEFLAG_NODESCENDANTS
#define LEFT_ARM_HEALTH 40
#define RIGHT_ARM_HEALTH 40
@@ -41,38 +40,33 @@ along with this program; if not, see .
NPC_ATST_Precache
-------------------------
*/
-void NPC_ATST_Precache(void)
-{
- G_SoundIndex( "sound/chars/atst/atst_damaged1" );
- G_SoundIndex( "sound/chars/atst/atst_damaged2" );
-
- RegisterItem( FindItemForWeapon( WP_ATST_MAIN )); //precache the weapon
- RegisterItem( FindItemForWeapon( WP_BOWCASTER )); //precache the weapon
- RegisterItem( FindItemForWeapon( WP_ROCKET_LAUNCHER )); //precache the weapon
-
- G_EffectIndex( "env/med_explode2" );
-// G_EffectIndex( "smaller_chunks" );
- G_EffectIndex( "blaster/smoke_bolton" );
- G_EffectIndex( "explosions/droidexplosion1" );
+void NPC_ATST_Precache(void) {
+ G_SoundIndex("sound/chars/atst/atst_damaged1");
+ G_SoundIndex("sound/chars/atst/atst_damaged2");
+
+ RegisterItem(FindItemForWeapon(WP_ATST_MAIN)); // precache the weapon
+ RegisterItem(FindItemForWeapon(WP_BOWCASTER)); // precache the weapon
+ RegisterItem(FindItemForWeapon(WP_ROCKET_LAUNCHER)); // precache the weapon
+
+ G_EffectIndex("env/med_explode2");
+ // G_EffectIndex( "smaller_chunks" );
+ G_EffectIndex("blaster/smoke_bolton");
+ G_EffectIndex("explosions/droidexplosion1");
}
//-----------------------------------------------------------------
-static void ATST_PlayEffect( gentity_t *self, const int boltID, const char *fx )
-{
- if ( boltID >=0 && fx && fx[0] )
- {
- mdxaBone_t boltMatrix;
- vec3_t org, dir;
+static void ATST_PlayEffect(gentity_t *self, const int boltID, const char *fx) {
+ if (boltID >= 0 && fx && fx[0]) {
+ mdxaBone_t boltMatrix;
+ vec3_t org, dir;
- gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel,
- boltID,
- &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time),
- NULL, self->s.modelScale );
+ gi.G2API_GetBoltMatrix(self->ghoul2, self->playerModel, boltID, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time ? cg.time : level.time),
+ NULL, self->s.modelScale);
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, org );
- gi.G2API_GiveMeVectorFromMatrix( boltMatrix, NEGATIVE_Y, dir );
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, org);
+ gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, dir);
- G_PlayEffect( fx, org, dir );
+ G_PlayEffect(fx, org, dir);
}
}
@@ -84,47 +78,38 @@ Called by NPC's and player in an ATST
-------------------------
*/
-void G_ATSTCheckPain( gentity_t *self, gentity_t *other, const vec3_t point, int damage, int mod,int hitLoc )
-{
+void G_ATSTCheckPain(gentity_t *self, gentity_t *other, const vec3_t point, int damage, int mod, int hitLoc) {
int newBolt;
- if ( rand() & 1 )
- {
- G_SoundOnEnt( self, CHAN_LESS_ATTEN, "sound/chars/atst/atst_damaged1" );
- }
- else
- {
- G_SoundOnEnt( self, CHAN_LESS_ATTEN, "sound/chars/atst/atst_damaged2" );
+ if (rand() & 1) {
+ G_SoundOnEnt(self, CHAN_LESS_ATTEN, "sound/chars/atst/atst_damaged1");
+ } else {
+ G_SoundOnEnt(self, CHAN_LESS_ATTEN, "sound/chars/atst/atst_damaged2");
}
- if ((hitLoc==HL_ARM_LT) && (self->locationDamage[HL_ARM_LT] > LEFT_ARM_HEALTH))
- {
- if (self->locationDamage[hitLoc] >= LEFT_ARM_HEALTH) // Blow it up?
+ if ((hitLoc == HL_ARM_LT) && (self->locationDamage[HL_ARM_LT] > LEFT_ARM_HEALTH)) {
+ if (self->locationDamage[hitLoc] >= LEFT_ARM_HEALTH) // Blow it up?
{
- newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*flash3" );
- if ( newBolt != -1 )
- {
-// G_PlayEffect( "small_chunks", self->playerModel, self->genericBolt1, self->s.number);
- ATST_PlayEffect( self, self->genericBolt1, "env/med_explode2" );
- G_PlayEffect( G_EffectIndex("blaster/smoke_bolton"), self->playerModel, newBolt, self->s.number, point);
+ newBolt = gi.G2API_AddBolt(&self->ghoul2[self->playerModel], "*flash3");
+ if (newBolt != -1) {
+ // G_PlayEffect( "small_chunks", self->playerModel, self->genericBolt1, self->s.number);
+ ATST_PlayEffect(self, self->genericBolt1, "env/med_explode2");
+ G_PlayEffect(G_EffectIndex("blaster/smoke_bolton"), self->playerModel, newBolt, self->s.number, point);
}
- gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "head_light_blaster_cann", TURN_OFF );
+ gi.G2API_SetSurfaceOnOff(&self->ghoul2[self->playerModel], "head_light_blaster_cann", TURN_OFF);
}
- }
- else if ((hitLoc==HL_ARM_RT) && (self->locationDamage[HL_ARM_RT] > RIGHT_ARM_HEALTH)) // Blow it up?
+ } else if ((hitLoc == HL_ARM_RT) && (self->locationDamage[HL_ARM_RT] > RIGHT_ARM_HEALTH)) // Blow it up?
{
- if (self->locationDamage[hitLoc] >= RIGHT_ARM_HEALTH)
- {
- newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*flash4" );
- if ( newBolt != -1 )
- {
-// G_PlayEffect( "small_chunks", self->playerModel, self->genericBolt2, self->s.number);
- ATST_PlayEffect( self, self->genericBolt2, "env/med_explode2" );
- G_PlayEffect( G_EffectIndex("blaster/smoke_bolton"), self->playerModel, newBolt, self->s.number, point);
+ if (self->locationDamage[hitLoc] >= RIGHT_ARM_HEALTH) {
+ newBolt = gi.G2API_AddBolt(&self->ghoul2[self->playerModel], "*flash4");
+ if (newBolt != -1) {
+ // G_PlayEffect( "small_chunks", self->playerModel, self->genericBolt2, self->s.number);
+ ATST_PlayEffect(self, self->genericBolt2, "env/med_explode2");
+ G_PlayEffect(G_EffectIndex("blaster/smoke_bolton"), self->playerModel, newBolt, self->s.number, point);
}
- gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "head_concussion_charger", TURN_OFF );
+ gi.G2API_SetSurfaceOnOff(&self->ghoul2[self->playerModel], "head_concussion_charger", TURN_OFF);
}
}
}
@@ -133,10 +118,9 @@ void G_ATSTCheckPain( gentity_t *self, gentity_t *other, const vec3_t point, int
NPC_ATST_Pain
-------------------------
*/
-void NPC_ATST_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, const vec3_t point, int damage, int mod,int hitLoc )
-{
- G_ATSTCheckPain( self, other, point, damage, mod, hitLoc );
- NPC_Pain( self, inflictor, other, point, damage, mod );
+void NPC_ATST_Pain(gentity_t *self, gentity_t *inflictor, gentity_t *other, const vec3_t point, int damage, int mod, int hitLoc) {
+ G_ATSTCheckPain(self, other, point, damage, mod, hitLoc);
+ NPC_Pain(self, inflictor, other, point, damage, mod);
}
/*
@@ -144,18 +128,15 @@ void NPC_ATST_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, con
ATST_Hunt
-------------------------`
*/
-void ATST_Hunt( qboolean visible, qboolean advance )
-{
+void ATST_Hunt(qboolean visible, qboolean advance) {
- if ( NPCInfo->goalEntity == NULL )
- {//hunt
+ if (NPCInfo->goalEntity == NULL) { // hunt
NPCInfo->goalEntity = NPC->enemy;
}
NPCInfo->combatMove = qtrue;
- NPC_MoveToGoal( qtrue );
-
+ NPC_MoveToGoal(qtrue);
}
/*
@@ -163,26 +144,21 @@ void ATST_Hunt( qboolean visible, qboolean advance )
ATST_Ranged
-------------------------
*/
-void ATST_Ranged( qboolean visible, qboolean advance, qboolean altAttack )
-{
+void ATST_Ranged(qboolean visible, qboolean advance, qboolean altAttack) {
- if ( TIMER_Done( NPC, "atkDelay" ) && visible ) // Attack?
+ if (TIMER_Done(NPC, "atkDelay") && visible) // Attack?
{
- TIMER_Set( NPC, "atkDelay", Q_irand( 500, 3000 ) );
+ TIMER_Set(NPC, "atkDelay", Q_irand(500, 3000));
- if (altAttack)
- {
- ucmd.buttons |= BUTTON_ATTACK|BUTTON_ALT_ATTACK;
- }
- else
- {
+ if (altAttack) {
+ ucmd.buttons |= BUTTON_ATTACK | BUTTON_ALT_ATTACK;
+ } else {
ucmd.buttons |= BUTTON_ATTACK;
}
}
- if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
- {
- ATST_Hunt( visible, advance );
+ if (NPCInfo->scriptFlags & SCF_CHASE_ENEMIES) {
+ ATST_Hunt(visible, advance);
}
}
@@ -191,83 +167,72 @@ void ATST_Ranged( qboolean visible, qboolean advance, qboolean altAttack )
ATST_Attack
-------------------------
*/
-void ATST_Attack( void )
-{
- qboolean altAttack=qfalse;
- int blasterTest,chargerTest,weapon;
+void ATST_Attack(void) {
+ qboolean altAttack = qfalse;
+ int blasterTest, chargerTest, weapon;
- if ( NPC_CheckEnemyExt() == qfalse )//!NPC->enemy )//
+ if (NPC_CheckEnemyExt() == qfalse) //! NPC->enemy )//
{
NPC->enemy = NULL;
return;
}
- NPC_FaceEnemy( qtrue );
+ NPC_FaceEnemy(qtrue);
// Rate our distance to the target, and our visibilty
- float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin );
- distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE;
- qboolean visible = NPC_ClearLOS( NPC->enemy );
- qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR);
+ float distance = (int)DistanceHorizontalSquared(NPC->currentOrigin, NPC->enemy->currentOrigin);
+ distance_e distRate = (distance > MIN_MELEE_RANGE_SQR) ? DIST_LONG : DIST_MELEE;
+ qboolean visible = NPC_ClearLOS(NPC->enemy);
+ qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR);
// If we cannot see our target, move to see it
- if ( visible == qfalse )
- {
- if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
- {
- ATST_Hunt( visible, advance );
+ if (visible == qfalse) {
+ if (NPCInfo->scriptFlags & SCF_CHASE_ENEMIES) {
+ ATST_Hunt(visible, advance);
return;
}
}
// Decide what type of attack to do
- switch ( distRate )
- {
+ switch (distRate) {
case DIST_MELEE:
- NPC_ChangeWeapon( WP_ATST_MAIN );
+ NPC_ChangeWeapon(WP_ATST_MAIN);
break;
case DIST_LONG:
- NPC_ChangeWeapon( WP_ATST_SIDE );
+ NPC_ChangeWeapon(WP_ATST_SIDE);
// See if the side weapons are there
- blasterTest = gi.G2API_GetSurfaceRenderStatus( &NPC->ghoul2[NPC->playerModel], "head_light_blaster_cann" );
- chargerTest = gi.G2API_GetSurfaceRenderStatus( &NPC->ghoul2[NPC->playerModel], "head_concussion_charger" );
+ blasterTest = gi.G2API_GetSurfaceRenderStatus(&NPC->ghoul2[NPC->playerModel], "head_light_blaster_cann");
+ chargerTest = gi.G2API_GetSurfaceRenderStatus(&NPC->ghoul2[NPC->playerModel], "head_concussion_charger");
// It has both side weapons
- if (!(blasterTest & TURN_OFF) && !(chargerTest & TURN_OFF))
- {
- weapon = Q_irand( 0, 1); // 0 is blaster, 1 is charger (ALT SIDE)
+ if (!(blasterTest & TURN_OFF) && !(chargerTest & TURN_OFF)) {
+ weapon = Q_irand(0, 1); // 0 is blaster, 1 is charger (ALT SIDE)
- if (weapon) // Fire charger
+ if (weapon) // Fire charger
{
altAttack = qtrue;
- }
- else
- {
+ } else {
altAttack = qfalse;
}
- }
- else if (!(blasterTest & TURN_OFF)) // Blaster is on
+ } else if (!(blasterTest & TURN_OFF)) // Blaster is on
{
altAttack = qfalse;
- }
- else if (!(chargerTest & TURN_OFF)) // Blaster is on
+ } else if (!(chargerTest & TURN_OFF)) // Blaster is on
{
altAttack = qtrue;
- }
- else
- {
- NPC_ChangeWeapon( WP_NONE );
+ } else {
+ NPC_ChangeWeapon(WP_NONE);
}
break;
}
- NPC_FaceEnemy( qtrue );
+ NPC_FaceEnemy(qtrue);
- ATST_Ranged( visible, advance,altAttack );
+ ATST_Ranged(visible, advance, altAttack);
}
/*
@@ -275,25 +240,20 @@ void ATST_Attack( void )
ATST_Patrol
-------------------------
*/
-void ATST_Patrol( void )
-{
- if ( NPC_CheckPlayerTeamStealth() )
- {
- NPC_UpdateAngles( qtrue, qtrue );
+void ATST_Patrol(void) {
+ if (NPC_CheckPlayerTeamStealth()) {
+ NPC_UpdateAngles(qtrue, qtrue);
return;
}
- //If we have somewhere to go, then do that
- if (!NPC->enemy)
- {
- if ( UpdateGoal() )
- {
+ // If we have somewhere to go, then do that
+ if (!NPC->enemy) {
+ if (UpdateGoal()) {
ucmd.buttons |= BUTTON_WALKING;
- NPC_MoveToGoal( qtrue );
- NPC_UpdateAngles( qtrue, qtrue );
+ NPC_MoveToGoal(qtrue);
+ NPC_UpdateAngles(qtrue, qtrue);
}
}
-
}
/*
@@ -301,12 +261,11 @@ void ATST_Patrol( void )
ATST_Idle
-------------------------
*/
-void ATST_Idle( void )
-{
+void ATST_Idle(void) {
NPC_BSIdle();
- NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_STAND1, SETANIM_FLAG_NORMAL );
+ NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_STAND1, SETANIM_FLAG_NORMAL);
}
/*
@@ -314,22 +273,15 @@ void ATST_Idle( void )
NPC_BSDroid_Default
-------------------------
*/
-void NPC_BSATST_Default( void )
-{
- if ( NPC->enemy )
- {
- if( (NPCInfo->scriptFlags & SCF_CHASE_ENEMIES) )
- {
+void NPC_BSATST_Default(void) {
+ if (NPC->enemy) {
+ if ((NPCInfo->scriptFlags & SCF_CHASE_ENEMIES)) {
NPCInfo->goalEntity = NPC->enemy;
}
ATST_Attack();
- }
- else if ( NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES )
- {
+ } else if (NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES) {
ATST_Patrol();
- }
- else
- {
+ } else {
ATST_Idle();
}
}
diff --git a/code/game/AI_BobaFett.cpp b/code/game/AI_BobaFett.cpp
index 8c5925e254..08535389a7 100644
--- a/code/game/AI_BobaFett.cpp
+++ b/code/game/AI_BobaFett.cpp
@@ -35,245 +35,213 @@ along with this program; if not, see .
#include "b_local.h"
#include "../Ravl/CVec.h"
-
////////////////////////////////////////////////////////////////////////////////////////
// Forward References Of Functions
////////////////////////////////////////////////////////////////////////////////////////
-void Boba_Precache( void );
-void Boba_DustFallNear(const vec3_t origin, int dustcount);
-void Boba_ChangeWeapon(int wp);
-qboolean Boba_StopKnockdown(gentity_t *self, gentity_t *pusher, const vec3_t pushDir, qboolean forceKnockdown = qfalse);
+void Boba_Precache(void);
+void Boba_DustFallNear(const vec3_t origin, int dustcount);
+void Boba_ChangeWeapon(int wp);
+qboolean Boba_StopKnockdown(gentity_t *self, gentity_t *pusher, const vec3_t pushDir, qboolean forceKnockdown = qfalse);
// Flight Related Functions (also used by Rocket Trooper)
//--------------------------------------------------------
-qboolean Boba_Flying( gentity_t *self );
-void Boba_FlyStart( gentity_t *self );
-void Boba_FlyStop( gentity_t *self );
+qboolean Boba_Flying(gentity_t *self);
+void Boba_FlyStart(gentity_t *self);
+void Boba_FlyStop(gentity_t *self);
// Called From NPC_Pain()
//-----------------------------
-void Boba_Pain( gentity_t *self, gentity_t *inflictor, int damage, int mod);
-
+void Boba_Pain(gentity_t *self, gentity_t *inflictor, int damage, int mod);
// Local: Flame Thrower Weapon
//-----------------------------
-void Boba_FireFlameThrower( gentity_t *self );
-void Boba_StopFlameThrower( gentity_t *self );
-void Boba_StartFlameThrower( gentity_t *self );
-void Boba_DoFlameThrower( gentity_t *self );
+void Boba_FireFlameThrower(gentity_t *self);
+void Boba_StopFlameThrower(gentity_t *self);
+void Boba_StartFlameThrower(gentity_t *self);
+void Boba_DoFlameThrower(gentity_t *self);
// Local: Other Tactics
//----------------------
-void Boba_DoAmbushWait( gentity_t *self);
-void Boba_DoSniper( gentity_t *self);
+void Boba_DoAmbushWait(gentity_t *self);
+void Boba_DoSniper(gentity_t *self);
// Local: Respawning
//-------------------
-bool Boba_Respawn();
+bool Boba_Respawn();
// Called From Within AI_Jedi && AI_Seeker
//-----------------------------------------
-void Boba_Fire();
-void Boba_FireDecide();
+void Boba_Fire();
+void Boba_FireDecide();
// Local: Called From Tactics()
//----------------------------
-void Boba_TacticsSelect();
-bool Boba_CanSeeEnemy( gentity_t *self );
-
+void Boba_TacticsSelect();
+bool Boba_CanSeeEnemy(gentity_t *self);
// Called From NPC_RunBehavior()
//-------------------------------
-void Boba_Update(); // Always Called First, Before Any Other Thinking
-bool Boba_Tactics(); // If returns true, Jedi and Seeker AI not used
-bool Boba_Flee(); // If returns true, Jedi and Seeker AI not used
-
-
+void Boba_Update(); // Always Called First, Before Any Other Thinking
+bool Boba_Tactics(); // If returns true, Jedi and Seeker AI not used
+bool Boba_Flee(); // If returns true, Jedi and Seeker AI not used
////////////////////////////////////////////////////////////////////////////////////////
// External Functions
////////////////////////////////////////////////////////////////////////////////////////
-extern void G_SoundAtSpot( vec3_t org, int soundIndex, qboolean broadcast );
-extern void G_CreateG2AttachedWeaponModel( gentity_t *ent, const char *weaponModel, int boltNum, int weaponNum );
-extern void ChangeWeapon( gentity_t *ent, int newWeapon );
-extern void WP_ResistForcePush( gentity_t *self, gentity_t *pusher, qboolean noPenalty );
-extern void ForceJump( gentity_t *self, usercmd_t *ucmd );
-extern void G_Knockdown( gentity_t *self, gentity_t *attacker, const vec3_t pushDir, float strength, qboolean breakSaberLock );
+extern void G_SoundAtSpot(vec3_t org, int soundIndex, qboolean broadcast);
+extern void G_CreateG2AttachedWeaponModel(gentity_t *ent, const char *weaponModel, int boltNum, int weaponNum);
+extern void ChangeWeapon(gentity_t *ent, int newWeapon);
+extern void WP_ResistForcePush(gentity_t *self, gentity_t *pusher, qboolean noPenalty);
+extern void ForceJump(gentity_t *self, usercmd_t *ucmd);
+extern void G_Knockdown(gentity_t *self, gentity_t *attacker, const vec3_t pushDir, float strength, qboolean breakSaberLock);
-extern void CG_DrawEdge( vec3_t start, vec3_t end, int type );
+extern void CG_DrawEdge(vec3_t start, vec3_t end, int type);
////////////////////////////////////////////////////////////////////////////////////////
// External Data
////////////////////////////////////////////////////////////////////////////////////////
-extern cvar_t* g_bobaDebug;
-
-
+extern cvar_t *g_bobaDebug;
////////////////////////////////////////////////////////////////////////////////////////
// Boba Debug Output
////////////////////////////////////////////////////////////////////////////////////////
#ifndef FINAL_BUILD
#if !defined(CTYPE_H_INC)
- #include
- #define CTYPE_H_INC
+#include
+#define CTYPE_H_INC
#endif
#if !defined(STDARG_H_INC)
- #include
- #define STDARG_H_INC
+#include
+#define STDARG_H_INC
#endif
#if !defined(STDIO_H_INC)
- #include
- #define STDIO_H_INC
+#include
+#define STDIO_H_INC
#endif
-void Boba_Printf(const char * format, ...)
-{
- if (g_bobaDebug->integer==0)
- {
+void Boba_Printf(const char *format, ...) {
+ if (g_bobaDebug->integer == 0) {
return;
}
- static char string[2][1024]; // in case this is called by nested functions
- static int index = 0;
- static char nFormat[300];
- char* buf;
+ static char string[2][1024]; // in case this is called by nested functions
+ static int index = 0;
+ static char nFormat[300];
+ char *buf;
// Tack On The Standard Format Around The Given Format
//-----------------------------------------------------
Com_sprintf(nFormat, sizeof(nFormat), "[BOBA %8d] %s\n", level.time, format);
-
// Resolve Remaining Elipsis Parameters Into Newly Formated String
//-----------------------------------------------------------------
buf = string[index & 1];
index++;
- va_list argptr;
- va_start (argptr, format);
- Q_vsnprintf (buf, sizeof(*string), nFormat, argptr);
- va_end (argptr);
+ va_list argptr;
+ va_start(argptr, format);
+ Q_vsnprintf(buf, sizeof(*string), nFormat, argptr);
+ va_end(argptr);
// Print It To Debug Output Console
//----------------------------------
gi.Printf(buf);
}
#else
-void Boba_Printf(const char * format, ...)
-{
-}
+void Boba_Printf(const char *format, ...) {}
#endif
-
////////////////////////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////////////////////////
-#define BOBA_FLAMEDURATION 3000
-#define BOBA_FLAMETHROWRANGE 128
-#define BOBA_FLAMETHROWSIZE 40
-#define BOBA_FLAMETHROWDAMAGEMIN 1//10
-#define BOBA_FLAMETHROWDAMAGEMAX 5//40
-#define BOBA_ROCKETRANGEMIN 300
-#define BOBA_ROCKETRANGEMAX 2000
-
+#define BOBA_FLAMEDURATION 3000
+#define BOBA_FLAMETHROWRANGE 128
+#define BOBA_FLAMETHROWSIZE 40
+#define BOBA_FLAMETHROWDAMAGEMIN 1 // 10
+#define BOBA_FLAMETHROWDAMAGEMAX 5 // 40
+#define BOBA_ROCKETRANGEMIN 300
+#define BOBA_ROCKETRANGEMAX 2000
////////////////////////////////////////////////////////////////////////////////////////
// Global Data
////////////////////////////////////////////////////////////////////////////////////////
-bool BobaHadDeathScript = false;
-bool BobaActive = false;
-vec3_t BobaFootStepLoc;
-int BobaFootStepCount = 0;
-
-vec3_t AverageEnemyDirection;
-int AverageEnemyDirectionSamples;
+bool BobaHadDeathScript = false;
+bool BobaActive = false;
+vec3_t BobaFootStepLoc;
+int BobaFootStepCount = 0;
+vec3_t AverageEnemyDirection;
+int AverageEnemyDirectionSamples;
////////////////////////////////////////////////////////////////////////////////////////
// Enums
////////////////////////////////////////////////////////////////////////////////////////
-enum EBobaTacticsState
-{
+enum EBobaTacticsState {
BTS_NONE,
// Attack
//--------
- BTS_RIFLE, // Uses Jedi / Seeker Movement
- BTS_MISSILE, // Uses Jedi / Seeker Movement
- BTS_SNIPER, // Uses Special Movement Internal To This File
- BTS_FLAMETHROW, // Locked In Place
+ BTS_RIFLE, // Uses Jedi / Seeker Movement
+ BTS_MISSILE, // Uses Jedi / Seeker Movement
+ BTS_SNIPER, // Uses Special Movement Internal To This File
+ BTS_FLAMETHROW, // Locked In Place
// Waiting
//---------
- BTS_AMBUSHWAIT, // Goto CP & Wait
+ BTS_AMBUSHWAIT, // Goto CP & Wait
BTS_MAX
};
-
-
-
-
-
-
-
-
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void Boba_Precache( void )
-{
- G_SoundIndex( "sound/chars/boba/bf_blast-off.wav" );
- G_SoundIndex( "sound/chars/boba/bf_jetpack_lp.wav" );
- G_SoundIndex( "sound/chars/boba/bf_land.wav" );
- G_SoundIndex( "sound/weapons/boba/bf_flame.mp3" );
- G_SoundIndex( "sound/player/footsteps/boot1" );
- G_SoundIndex( "sound/player/footsteps/boot2" );
- G_SoundIndex( "sound/player/footsteps/boot3" );
- G_SoundIndex( "sound/player/footsteps/boot4" );
- G_EffectIndex( "boba/jetSP" );
- G_EffectIndex( "boba/fthrw" );
- G_EffectIndex( "volumetric/black_smoke" );
- G_EffectIndex( "chunks/dustFall" );
+void Boba_Precache(void) {
+ G_SoundIndex("sound/chars/boba/bf_blast-off.wav");
+ G_SoundIndex("sound/chars/boba/bf_jetpack_lp.wav");
+ G_SoundIndex("sound/chars/boba/bf_land.wav");
+ G_SoundIndex("sound/weapons/boba/bf_flame.mp3");
+ G_SoundIndex("sound/player/footsteps/boot1");
+ G_SoundIndex("sound/player/footsteps/boot2");
+ G_SoundIndex("sound/player/footsteps/boot3");
+ G_SoundIndex("sound/player/footsteps/boot4");
+ G_EffectIndex("boba/jetSP");
+ G_EffectIndex("boba/fthrw");
+ G_EffectIndex("volumetric/black_smoke");
+ G_EffectIndex("chunks/dustFall");
AverageEnemyDirectionSamples = 0;
VectorClear(AverageEnemyDirection);
- BobaHadDeathScript = false;
- BobaActive = true;
- BobaFootStepCount = 0;
+ BobaHadDeathScript = false;
+ BobaActive = true;
+ BobaFootStepCount = 0;
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
-void Boba_DustFallNear(const vec3_t origin, int dustcount)
-{
- if (!BobaActive)
- {
+void Boba_DustFallNear(const vec3_t origin, int dustcount) {
+ if (!BobaActive) {
return;
}
- trace_t testTrace;
- vec3_t testDirection;
- vec3_t testStartPos;
- vec3_t testEndPos;
+ trace_t testTrace;
+ vec3_t testDirection;
+ vec3_t testStartPos;
+ vec3_t testEndPos;
VectorCopy(origin, testStartPos);
- for (int i=0; i