Compare commits

...
42 Commits
Author SHA1 Message Date
smallmodel 60faa9dd9b Updated the version number 2023-11-29 17:57:47 +01:00
smallmodel 75f8f86f86 Fixed compilation error on some compilers 2023-11-29 00:08:35 +01:00
smallmodel 0ee1307e75 Fixed missing m_Thread archive 2023-11-28 20:26:40 +01:00
smallmodel f0c38305b5 Fixed defaultEntry having a NULL value even if there are elements 2023-11-28 20:13:55 +01:00
smallmodel e07dda6991 Fixed defaultEntry not being initialized after archiving 2023-11-28 20:10:23 +01:00
smallmodel b10ce9a426 Added GetKey() / SetKey() in con_set's Entry, so ScriptVariable can override it and set the key appropriately 2023-11-28 19:50:19 +01:00
smallmodel 2ac2800ecb Only archive used variables on the local VM stack 2023-11-28 19:14:09 +01:00
smallmodel e59200a7de Fixed cSpline archiving bad values 2023-11-27 20:35:23 +01:00
smallmodel a7902a8837 Added FollowPathRelativeYaw and NormalAngles 2023-11-27 20:30:36 +01:00
smallmodel 615726cc75 Added FollowPathRelativeYaw 2023-11-27 20:22:37 +01:00
smallmodel 839abf6076 Added missing variables to archive 2023-11-27 20:20:00 +01:00
smallmodel c7c8d4580d Added missed archived variables and using a ScriptThreadLabel instead of an event for the killed handler 2023-11-27 20:07:57 +01:00
smallmodel 2cc47e10f9 Added missing iNextLandTime archived variable 2023-11-27 20:06:19 +01:00
smallmodel 8fc5dacebf Removed bBindChilds unused variable + added more variables to archive 2023-11-27 20:06:05 +01:00
smallmodel cb23f3bb70 Added missing weapon_class archived variable 2023-11-27 20:05:36 +01:00
smallmodel d7350d8629 Added Clear() method in ScriptThreadLabel 2023-11-27 20:05:21 +01:00
smallmodel ac6b5ef1f7 Fixed wrong area portal writing 2023-11-27 19:37:29 +01:00
smallmodel 7fdd26c59e Added m_fHealRate archived variable 2023-11-27 19:37:26 +01:00
smallmodel fad555308b Archive ScriptVM and ScriptThread appropriately 2023-11-27 19:30:40 +01:00
smallmodel 969255c48e Fixed areaPortals being broken after reading from archive 2023-11-26 20:44:21 +01:00
smallmodel 433305617c IsAlive: check if the given listener is an actual entity 2023-11-26 20:38:14 +01:00
smallmodel 5418d84c7e Fixed m_fpsTiki being uninitialized when archiving 2023-11-26 20:36:23 +01:00
smallmodel cca37e3dfe Added and using SAVEGAME_STRUCT_VERSION 2023-11-26 20:33:07 +01:00
smallmodel 0e9d83ee14 Added a check to debug the total of archived items 2023-11-26 20:31:58 +01:00
smallmodel ecbf7f6caa Fixed Archive method not calling parent class archive method 2023-11-26 20:00:12 +01:00
smallmodel 5a3638fa68 Better for loop clarity 2023-11-26 19:55:07 +01:00
smallmodel 111088b540 Formatted document 2023-11-26 19:54:07 +01:00
smallmodel ba1703ebf0 When loading an entity from archive, set the model only if the entity allows model to be archived 2023-11-26 19:49:51 +01:00
smallmodel 825df20a72 Fixed game being stuck on mission stats screen in single-player 2023-11-26 19:30:54 +01:00
smallmodel 0a42fd79d2 Clear radar on cgame shutdown 2023-11-26 19:30:28 +01:00
smallmodel e50a041c12 SimpleEntity subclass flags name now starts with ECF_ prefix 2023-11-16 23:17:06 +01:00
smallmodel ce0e9fe77e Added portable turret anim blends + fixed anim blends 2023-11-16 23:03:04 +01:00
smallmodel 5105dcce04 Updated version patch number 2023-11-15 23:17:37 +01:00
smallmodel 58b4a9a676 Added bullet alpha (from moh 2.0 and above) 2023-11-15 21:02:34 +01:00
smallmodel 1146c834fb Fixed bad bullet coords being sent 2023-11-15 21:02:23 +01:00
smallmodel 9068264132 Make sure to remove the view model and detach the player when the turret gun is being removed 2023-11-15 20:42:16 +01:00
smallmodel 59ac8ea437 Clear the partial immobile flag when initializing the player's physics 2023-11-15 20:41:41 +01:00
smallmodel afafacaeec Fixed bullet tracer issues with multiple bullets 2023-11-15 20:41:35 +01:00
smallmodel baf451d2a2 Cleaned up bg_public 2023-11-15 20:39:09 +01:00
smallmodel d588012168 Don't use ANIM_MASK 2023-11-15 19:45:58 +01:00
smallmodel a3ed25cb2e Use WEAPON_CLASS_ITEM1 instead of raw 256 constant value 2023-11-15 19:36:29 +01:00
smallmodel c399f45841 Weapon::SetItemSlot() fixed missing bitwise negate 2023-11-15 19:36:09 +01:00
54 changed files with 1235 additions and 911 deletions

No files matched your search

+4 -1
View File
@@ -689,11 +689,14 @@ Called before every level change or subsystem restart
void CG_Shutdown(void)
{
L_ShutdownEvents();
// Shutdown radar
cgi.CL_InitRadar(NULL, NULL, -1);
// some mods may need to do cleanup work here,
// like closing files or archiving session data
// hide the stats screen
cgi.UI_HideMenu("StatsScreen", 1);
cgi.UI_HideMenu("StatsScreen", qtrue);
// reset the scoreboard
CG_PrepScoreBoardInfo();
+183 -224
View File
@@ -37,6 +37,7 @@ typedef struct {
vec3_t *i_vEnd;
int i_iNumBullets;
qboolean iLarge;
float alpha;
int iTracerVisible;
qboolean bIgnoreEntities;
} bullet_tracer_t;
@@ -60,21 +61,22 @@ static vec3_t flesh_impact_pos[MAX_IMPACTS];
static vec3_t flesh_impact_norm[MAX_IMPACTS];
static int flesh_impact_large[MAX_IMPACTS];
void CG_MakeBulletHoleSound(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t* pPreTrace) {
int iSurfType;
float fVolume;
str sSoundName;
vec3_t vFrom, vDest;
void CG_MakeBulletHoleSound(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t *pPreTrace)
{
int iSurfType;
float fVolume;
str sSoundName;
vec3_t vFrom, vDest;
trace_t trace;
if (pPreTrace) {
trace = *pPreTrace;
}
else {
} else {
VectorMA(i_vPos, 2.0f, i_vNorm, vFrom);
VectorMA(i_vPos, -4.0f, i_vNorm, vDest);
CG_Trace(&trace, vFrom, vec_zero, vec_zero, vDest, ENTITYNUM_NONE, MASK_SHOT, qfalse, qtrue, "CG_MakeBulletHole");
CG_Trace(
&trace, vFrom, vec_zero, vec_zero, vDest, ENTITYNUM_NONE, MASK_SHOT, qfalse, qtrue, "CG_MakeBulletHole"
);
}
iSurfType = trace.surfaceFlags & MASK_SURF_TYPE;
@@ -149,9 +151,12 @@ void CG_MakeBulletHoleSound(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarg
commandManager.PlaySound(sSoundName, vFrom, -1, fVolume, -1.f, -1.f, 1);
}
static void CG_MakeBulletHoleType(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, int iEffectNum, float fRadius, qboolean bMakeSound) {
static void CG_MakeBulletHoleType(
const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, int iEffectNum, float fRadius, qboolean bMakeSound
)
{
if (bMakeSound) {
str sBulletHole = "snd_bh_";
str sBulletHole = "snd_bh_";
float fVolume;
switch (iEffectNum) {
@@ -221,14 +226,15 @@ static void CG_MakeBulletHoleType(const vec3_t i_vPos, const vec3_t i_vNorm, int
sfxManager.MakeEffect_Normal(iEffectNum, i_vPos, i_vNorm);
}
static void CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t *pPreTrace, qboolean bMakeSound)
static void
CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t *pPreTrace, qboolean bMakeSound)
{
int iSurfType;
int iEffect;
float fRadius;
str sEffectModel;
str sBulletHole;
vec3_t vFrom, vDest;
int iSurfType;
int iEffect;
float fRadius;
str sEffectModel;
str sBulletHole;
vec3_t vFrom, vDest;
trace_t trace;
if (pPreTrace) {
@@ -236,7 +242,9 @@ static void CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLa
} else {
VectorMA(i_vPos, 2.0f, i_vNorm, vFrom);
VectorMA(i_vPos, -4.0f, i_vNorm, vDest);
CG_Trace(&trace, vFrom, vec_zero, vec_zero, vDest, ENTITYNUM_NONE, MASK_SHOT, qfalse, qtrue, "CG_MakeBulletHole");
CG_Trace(
&trace, vFrom, vec_zero, vec_zero, vDest, ENTITYNUM_NONE, MASK_SHOT, qfalse, qtrue, "CG_MakeBulletHole"
);
}
iSurfType = trace.surfaceFlags & MASK_SURF_TYPE;
@@ -249,7 +257,7 @@ static void CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLa
}
VectorAdd(trace.endpos, trace.plane.normal, vFrom);
fRadius = 2.0f;
fRadius = 2.0f;
sBulletHole = "bhole_";
switch (iSurfType) {
@@ -347,36 +355,48 @@ static void CG_MakeBubbleTrail(const vec3_t i_vStart, const vec3_t i_vEnd, int i
{
vec3_t vDir;
vec3_t vPos;
float fDist;
float fMove;
float fDist;
float fMove;
VectorSubtract(i_vEnd, i_vStart, vDir);
fDist = VectorNormalize(vDir);
VectorCopy(i_vStart, vPos);
fMove = random() * 8.f;
fMove = random() * 8.f * alpha;
fDist -= fMove;
while (fDist > 0.f) {
VectorMA(vPos, fMove, vDir, vPos);
sfxManager.MakeEffect_Angles(32, vPos, vec_zero);
fMove = 16.f + crandom() * 8.f;
fMove = 16.f + crandom() * 8.f * alpha;
fDist -= fMove;
}
}
static void CG_BulletTracerEffect(const vec3_t i_vStart, const vec3_t i_vEnd)
static void CG_BulletTracerEffect(const vec3_t i_vStart, const vec3_t i_vEnd, int iLarge, float alpha)
{
int iLife;
int iTracerLength;
float fLength, fDist;
int iLife;
int iTracerLength;
float fLength, fDist;
vec4_t fTracerColor;
vec3_t vDir, vNewStart;
float alphaMult;
float scale;
iTracerLength = 450.0f + random() * 150.f;
VectorSubtract(i_vEnd, i_vStart, vDir);
fLength = VectorNormalize(vDir);
if (iLarge > 1) {
alphaMult = random() * 0.2f + 0.9f;
scale = iLarge * 2;
} else {
alphaMult = 1;
scale = 1;
}
fDist = 450.0f + random() * 150.f;
if (fLength < fDist + 150.f) {
float fFrac;
@@ -384,13 +404,15 @@ static void CG_BulletTracerEffect(const vec3_t i_vStart, const vec3_t i_vEnd)
return;
}
fFrac = fLength / (fDist + 150.0);
fFrac = fLength / (fDist + 150.0);
iTracerLength = (int)((float)iTracerLength * fFrac + 0.5f);
fDist *= fFrac;
}
iLife = (int)((fLength - fDist) / 12000.f * 1000.f);
if (iLife < 20) iLife = 20;
iLife = (int)((fLength - fDist) / 12000.f * 1000.f / (alpha * alphaMult));
if (iLife < 20) {
iLife = 20;
}
VectorMA(i_vStart, fDist, vDir, vNewStart);
fTracerColor[0] = 1.f;
@@ -427,53 +449,54 @@ static void CG_BulletTracerEffect(const vec3_t i_vStart, const vec3_t i_vEnd)
}
static void CG_MakeBulletTracerInternal(
const vec3_t i_vBarrel,
const vec3_t i_vStart,
const vec3_t *i_vEnd,
int i_iNumBullets,
qboolean iLarge,
int iTracerVisible,
qboolean bIgnoreEntities
const vec3_t i_vBarrel,
const vec3_t i_vStart,
const vec3_t *i_vEnd,
int i_iNumBullets,
qboolean iLarge,
int iTracerVisible,
qboolean bIgnoreEntities,
float alpha
)
{
vec3_t vPos;
int iBullet;
int iContinueCount;
int iDist;
int iHeadDist;
int iTravelDist;
float fLen, fDist;
trace_t trace;
qboolean bStartInWater, bInWater;
qboolean bBulletDone;
qboolean bMadeTracer;
vec3_t vDir;
vec3_t vTrailStart;
vec3_t vTraceStart;
vec3_t vTraceEnd;
vec3_t vTmp;
int iNumImpacts;
trace_t tImpacts[128];
float fImpSndDistRA;
vec3_t vPos;
int iBullet;
int iContinueCount;
int iDist;
int iHeadDist;
int iTravelDist;
float fLen, fDist;
trace_t trace;
qboolean bStartInWater, bInWater;
qboolean bBulletDone;
qboolean bMadeTracer;
vec3_t vDir;
vec3_t vTrailStart;
vec3_t vTraceStart;
vec3_t vTraceEnd;
vec3_t vTmp;
int iNumImpacts;
trace_t tImpacts[128];
float fImpSndDistRA;
static float fImpSndDistLA;
float fImpSndDistRB;
float fImpSndDistLB;
int iImpSndIndexRA;
int iImpSndIndexRB;
int iImpSndIndexLB;
float fVolume;
float fPitch;
float fZingDistA, fZingDistB, fZingDistC;
vec3_t vZingPosA, vZingPosB, vZingPosC;
float fImpSndDistRB;
float fImpSndDistLB;
int iImpSndIndexRA;
int iImpSndIndexRB;
int iImpSndIndexLB;
float fVolume;
float fPitch;
float fZingDistA, fZingDistB, fZingDistC;
vec3_t vZingPosA, vZingPosB, vZingPosC;
fZingDistB = 9999.0;
fZingDistA = 9999.0;
fZingDistC = 9999.0;
fZingDistB = 9999.0;
fZingDistA = 9999.0;
fZingDistC = 9999.0;
iNumImpacts = 0;
// check to see if it starts in water
bStartInWater = (cgi.CM_PointContents(i_vStart, 0) & CONTENTS_FLUID) != 0;
for (iBullet = 0; iBullet < i_iNumBullets; iBullet++) {
bInWater = bStartInWater;
VectorCopy(i_vBarrel, vTrailStart);
@@ -481,8 +504,8 @@ static void CG_MakeBulletTracerInternal(
fLen = VectorNormalize(vDir);
trace.fraction = 0;
iDist = (int)fLen + 32;
bBulletDone = qfalse;
iDist = (int)fLen + 32;
bBulletDone = qfalse;
iContinueCount = 0;
if (bStartInWater) {
@@ -501,8 +524,7 @@ static void CG_MakeBulletTracerInternal(
if (iDist > BULLET_TRAVEL_DIST) {
iTravelDist += BULLET_TRAVEL_DIST;
iDist -= BULLET_TRAVEL_DIST;
}
else {
} else {
iTravelDist += iDist;
iDist = 0;
}
@@ -513,16 +535,7 @@ static void CG_MakeBulletTracerInternal(
while (trace.fraction < 1) {
if (bIgnoreEntities) {
cgi.CM_BoxTrace(
&trace,
vTraceStart,
vTraceEnd,
vec_zero,
vec_zero,
0,
MASK_SHOT,
qfalse
);
cgi.CM_BoxTrace(&trace, vTraceStart, vTraceEnd, vec_zero, vec_zero, 0, MASK_SHOT, qfalse);
if (trace.fraction == 1.0f) {
trace.entityNum = ENTITYNUM_NONE;
@@ -533,8 +546,7 @@ static void CG_MakeBulletTracerInternal(
if (trace.startsolid) {
trace.entityNum = ENTITYNUM_WORLD;
}
}
else {
} else {
CG_Trace(
&trace,
vTraceStart,
@@ -556,35 +568,29 @@ static void CG_MakeBulletTracerInternal(
VectorNormalizeFast(trace.plane.normal);
}
if (!bInWater && trace.fraction < 1.0f && iNumImpacts <= 127)
{
if (!bInWater && trace.fraction < 1.0f && iNumImpacts <= 127) {
memcpy(&tImpacts[iNumImpacts], &trace, sizeof(trace_t));
iNumImpacts++;
}
if (iTracerVisible && !bMadeTracer)
{
CG_BulletTracerEffect(vTrailStart, trace.endpos);
if (iTracerVisible && !bMadeTracer) {
CG_BulletTracerEffect(vTrailStart, trace.endpos, iLarge, alpha);
bMadeTracer = qtrue;
}
if (trace.fraction < 1.0f) {
if (((trace.surfaceFlags & (SURF_HINT | SURF_NODLIGHT | SURF_SNOW | SURF_FOLIAGE | SURF_DIRT)) || (trace.contents & CONTENTS_WATER))
&& iContinueCount < 5)
{
if (bInWater)
{
if (((trace.surfaceFlags & (SURF_HINT | SURF_NODLIGHT | SURF_SNOW | SURF_FOLIAGE | SURF_DIRT))
|| (trace.contents & CONTENTS_WATER))
&& iContinueCount < 5) {
if (bInWater) {
VectorSubtract(trace.endpos, vDir, vTmp);
if (!(trace.contents & CONTENTS_FLUID)
&& !(trace.surfaceFlags & SURF_PUDDLE)
&& !(cgi.CM_PointContents(vTmp, 0) & CONTENTS_FLUID))
{
CG_MakeBubbleTrail(vTrailStart, trace.endpos, iLarge);
if (!(trace.contents & CONTENTS_FLUID) && !(trace.surfaceFlags & SURF_PUDDLE)
&& !(cgi.CM_PointContents(vTmp, 0) & CONTENTS_FLUID)) {
CG_MakeBubbleTrail(vTrailStart, trace.endpos, iLarge, alpha);
VectorCopy(trace.endpos, vTrailStart);
bInWater = qfalse;
}
}
else if ((trace.contents & CONTENTS_FLUID) || (trace.surfaceFlags & SURF_PUDDLE)) {
} else if ((trace.contents & CONTENTS_FLUID) || (trace.surfaceFlags & SURF_PUDDLE)) {
VectorCopy(trace.endpos, vTrailStart);
bInWater = qtrue;
}
@@ -593,11 +599,9 @@ static void CG_MakeBulletTracerInternal(
VectorAdd(vTraceStart, vTraceStart, trace.endpos);
iContinueCount++;
}
else
{
} else {
trace.fraction = 1.0f;
bBulletDone = qtrue;
bBulletDone = qtrue;
}
}
}
@@ -605,14 +609,14 @@ static void CG_MakeBulletTracerInternal(
}
if (bInWater) {
CG_MakeBubbleTrail(vTraceStart, trace.endpos, iLarge);
CG_MakeBubbleTrail(vTraceStart, trace.endpos, iLarge, alpha);
}
if (iTracerVisible) {
iTracerVisible--;
}
fLen = ProjectPointOnLine(i_vStart, i_vEnd[iBullet], cg.SoundOrg, vPos);
fLen = ProjectPointOnLine(i_vStart, i_vEnd[iBullet], cg.SoundOrg, vPos);
iHeadDist = (int)Distance(vPos, cg.SoundOrg);
if (iHeadDist > 255) {
continue;
@@ -629,7 +633,7 @@ static void CG_MakeBulletTracerInternal(
if (fLen < 0.f) {
VectorCopy(i_vStart, vPos);
} else if(fDist >= fLen) {
} else if (fDist >= fLen) {
VectorCopy(i_vEnd[iBullet], vPos);
}
@@ -652,11 +656,11 @@ static void CG_MakeBulletTracerInternal(
}
if (iNumImpacts > 2) {
fImpSndDistRA = 9999.0f;
fImpSndDistRB = 9999.0f;
fImpSndDistRA = 9999.0f;
fImpSndDistRB = 9999.0f;
iImpSndIndexRA = 0;
iImpSndIndexRB = 0;
fImpSndDistLB = 9999.0f;
fImpSndDistLB = 9999.0f;
iImpSndIndexLB = 0;
for (iBullet = 0; iBullet < iNumImpacts; iBullet++) {
@@ -671,27 +675,23 @@ static void CG_MakeBulletTracerInternal(
VectorSubtract(tImpacts[iImpSndIndexLB].endpos, cg.SoundOrg, vTmp);
iHeadDist = VectorLength(vTmp);
if (DotProduct(vTmp, cg.SoundAxis[1]) <= 0.f)
{
if (DotProduct(vTmp, cg.SoundAxis[1]) <= 0.f) {
if (iHeadDist < 9999.0f || iHeadDist < fImpSndDistLB) {
if (iHeadDist < 9999.0f) {
fImpSndDistRA = iHeadDist;
fImpSndDistLB = 9999.0;
fImpSndDistRA = iHeadDist;
fImpSndDistLB = 9999.0;
iImpSndIndexRA = iBullet;
} else if (iHeadDist < fImpSndDistLB) {
fImpSndDistLB = iHeadDist;
}
}
}
else
{
if (iHeadDist < fImpSndDistRA || iHeadDist < fImpSndDistRB)
{
} else {
if (iHeadDist < fImpSndDistRA || iHeadDist < fImpSndDistRB) {
if (iHeadDist < fImpSndDistRA) {
iImpSndIndexRB = iImpSndIndexRA;
iImpSndIndexRA = iBullet;
} else if (iHeadDist < fImpSndDistRB) {
fImpSndDistRB = iHeadDist;
fImpSndDistRB = iHeadDist;
iImpSndIndexRB = iBullet;
}
}
@@ -720,11 +720,7 @@ static void CG_MakeBulletTracerInternal(
} else {
for (iBullet = 0; iBullet < iNumImpacts; iBullet++) {
CG_MakeBulletHole(
tImpacts[iBullet].endpos,
tImpacts[iBullet].plane.normal,
iNumImpacts,
&tImpacts[iBullet],
qtrue
tImpacts[iBullet].endpos, tImpacts[iBullet].plane.normal, iNumImpacts, &tImpacts[iBullet], qtrue
);
}
}
@@ -732,10 +728,10 @@ static void CG_MakeBulletTracerInternal(
if (fZingDistA < 9999.0f) {
if (iLarge) {
fVolume = 1.0f;
fPitch = 0.8f;
fPitch = 0.8f;
} else {
fVolume = 0.8f;
fPitch = 1.0f;
fPitch = 1.0f;
}
commandManager.PlaySound("snd_b_zing", vZingPosA, -1, fVolume, -1.0f, fPitch, 1);
@@ -774,13 +770,14 @@ static void CG_MakeBulletTracer(
bullet_tracer->i_vEnd = &bullet_tracer_bullets[bullet_tracers_count];
bullet_tracer->i_iNumBullets = i_iNumBullets;
for (i = 0; i < i_iNumBullets; ++i) {
bullet_tracer_bullets[bullet_tracers_count][0] = (*i_vEnd)[i];
bullet_tracer_bullets[bullet_tracers_count][1] = (*i_vEnd)[i + 1];
bullet_tracer_bullets[bullet_tracers_count++][2] = (*i_vEnd)[i + 2];
for (i = 0; i < i_iNumBullets; i++, bullet_tracers_count++) {
bullet_tracer_bullets[bullet_tracers_count][0] = i_vEnd[i][0];
bullet_tracer_bullets[bullet_tracers_count][1] = i_vEnd[i][1];
bullet_tracer_bullets[bullet_tracers_count][2] = i_vEnd[i][2];
}
bullet_tracer->iLarge = iLarge;
bullet_tracer->alpha = alpha;
bullet_tracer->iTracerVisible = iTracerVisible;
bullet_tracer->bIgnoreEntities = bIgnoreEntities;
}
@@ -797,7 +794,8 @@ void CG_AddBulletTracers()
bullet_tracers[i].i_iNumBullets,
bullet_tracers[i].iLarge,
bullet_tracers[i].iTracerVisible,
bullet_tracers[i].bIgnoreEntities
bullet_tracers[i].bIgnoreEntities,
bullet_tracers[i].alpha
);
}
@@ -807,26 +805,24 @@ void CG_AddBulletTracers()
void CG_AddBulletImpacts()
{
int i;
int iHeadDist;
float fVolume;
float fImpSndDistRA;
int i;
int iHeadDist;
float fVolume;
float fImpSndDistRA;
static float fImpSndDistLA = 9999.f;
float fImpSndDistRB;
float fImpSndDistLB;
int iImpSndIndexRA;
int iImpSndIndexRB;
int iImpSndIndexLB;
vec3_t vTmp;
str sSoundName;
float fImpSndDistRB;
float fImpSndDistLB;
int iImpSndIndexRA;
int iImpSndIndexRB;
int iImpSndIndexLB;
vec3_t vTmp;
str sSoundName;
if (wall_impact_count)
{
if (wall_impact_count > 4)
{
fImpSndDistRA = fImpSndDistLA;
fImpSndDistRB = fImpSndDistLA;
fImpSndDistLB = fImpSndDistLA;
if (wall_impact_count) {
if (wall_impact_count > 4) {
fImpSndDistRA = fImpSndDistLA;
fImpSndDistRB = fImpSndDistLA;
fImpSndDistLB = fImpSndDistLA;
iImpSndIndexRA = 0;
iImpSndIndexRB = 0;
iImpSndIndexLB = 0;
@@ -834,33 +830,28 @@ void CG_AddBulletImpacts()
for (i = 0; i < wall_impact_count; i++) {
VectorSubtract(wall_impact_pos[i], cg.SoundOrg, vTmp);
iHeadDist = VectorLength(vTmp);
if (DotProduct(vTmp, cg.SoundAxis[1]) > 0.f)
{
if (iHeadDist < fImpSndDistRA || iHeadDist < fImpSndDistRB)
{
if (DotProduct(vTmp, cg.SoundAxis[1]) > 0.f) {
if (iHeadDist < fImpSndDistRA || iHeadDist < fImpSndDistRB) {
if (iHeadDist < fImpSndDistRA) {
fImpSndDistRB = fImpSndDistRA;
fImpSndDistRA = iHeadDist;
fImpSndDistRB = fImpSndDistRA;
fImpSndDistRA = iHeadDist;
iImpSndIndexRB = iImpSndIndexRA;
iImpSndIndexRA = i;
} else if (iHeadDist < fImpSndDistRB) {
fImpSndDistRB = iHeadDist;
fImpSndDistRB = iHeadDist;
iImpSndIndexRB = i;
}
}
}
else
{
if (iHeadDist < fImpSndDistLA || iHeadDist < fImpSndDistLB)
{
} else {
if (iHeadDist < fImpSndDistLA || iHeadDist < fImpSndDistLB) {
if (iHeadDist < fImpSndDistLA) {
fImpSndDistRA = iHeadDist;
fImpSndDistLB = fImpSndDistLA;
fImpSndDistRA = iHeadDist;
fImpSndDistLB = fImpSndDistLA;
iImpSndIndexLB = 0;
iImpSndIndexRA = i;
} else if (iHeadDist < fImpSndDistLB) {
fImpSndDistLB = iHeadDist;
fImpSndDistLB = iHeadDist;
iImpSndIndexLB = i;
}
}
@@ -908,8 +899,7 @@ void CG_AddBulletImpacts()
if (wall_impact_type[iImpSndIndexRB] == 2 || wall_impact_type[iImpSndIndexRB] == 3) {
sSoundName = "snd_bh_metal";
}
else {
} else {
sSoundName = "snd_bh_wood";
}
@@ -942,26 +932,15 @@ void CG_AddBulletImpacts()
if (wall_impact_type[0] == 2 || wall_impact_type[0] == 3) {
sSoundName = "snd_bh_metal";
}
else {
} else {
sSoundName = "snd_bh_wood";
}
commandManager.PlaySound(sSoundName, wall_impact_pos[0], -1, fVolume, -1, -1, 1);
sfxManager.MakeEffect_Normal(
wall_impact_type[0],
wall_impact_pos[0],
wall_impact_norm[0]
);
sfxManager.MakeEffect_Normal(wall_impact_type[0], wall_impact_pos[0], wall_impact_norm[0]);
} else {
CG_MakeBulletHole(
wall_impact_pos[0],
wall_impact_norm[0],
wall_impact_large[0],
NULL,
qtrue
);
CG_MakeBulletHole(wall_impact_pos[0], wall_impact_norm[0], wall_impact_large[0], NULL, qtrue);
}
}
@@ -969,15 +948,13 @@ void CG_AddBulletImpacts()
if (wall_impact_type[iImpSndIndexLB]) {
if (wall_impact_large[iImpSndIndexLB]) {
fVolume = 1.f;
}
else {
} else {
fVolume = 0.75f;
}
if (wall_impact_type[iImpSndIndexLB] == 2 || wall_impact_type[iImpSndIndexLB] == 3) {
sSoundName = "snd_bh_metal";
}
else {
} else {
sSoundName = "snd_bh_wood";
}
@@ -998,45 +975,31 @@ void CG_AddBulletImpacts()
);
}
}
}
else
{
} else {
for (i = 0; i < wall_impact_count; i++) {
CG_MakeBulletHole(
wall_impact_pos[i],
wall_impact_norm[i],
wall_impact_large[i],
NULL,
qtrue
);
CG_MakeBulletHole(wall_impact_pos[i], wall_impact_norm[i], wall_impact_large[i], NULL, qtrue);
}
}
wall_impact_count = 0;
}
if (flesh_impact_count)
{
if (flesh_impact_count > 1)
{
fImpSndDistRA = 9999.0;
if (flesh_impact_count) {
if (flesh_impact_count > 1) {
fImpSndDistRA = 9999.0;
iImpSndIndexRA = 0;
for (i = 0; i < flesh_impact_count; i++) {
VectorSubtract(wall_impact_pos[i], cg.SoundOrg, vTmp);
iHeadDist = VectorLength(vTmp);
if (DotProduct(vTmp, cg.SoundAxis[1]) > 0.f)
{
if (iHeadDist < fImpSndDistRA)
{
fImpSndDistRA = iHeadDist;
if (DotProduct(vTmp, cg.SoundAxis[1]) > 0.f) {
if (iHeadDist < fImpSndDistRA) {
fImpSndDistRA = iHeadDist;
iImpSndIndexRA = i;
}
}
else if (iHeadDist < fImpSndDistLA)
{
fImpSndDistRA = iHeadDist;
} else if (iHeadDist < fImpSndDistLA) {
fImpSndDistRA = iHeadDist;
iImpSndIndexRA = i;
}
}
@@ -1105,8 +1068,7 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType)
fRadius = 0;
break;
case SURF_SNOW:
switch (iBaseEffect)
{
switch (iBaseEffect) {
case SFX_EXP_TANK_BASE:
iSurfEffect = SFX_EXP_TANK_SNOW;
break;
@@ -1122,7 +1084,7 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType)
iBaseEffect = -1;
break;
}
fRadius = 0;
fRadius = 0;
break;
case SURF_CARPET:
iSurfEffect = SFX_EXP_GREN_CARPET;
@@ -1147,8 +1109,7 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType)
fRadius = 0;
break;
case SURF_DIRT:
switch (iBaseEffect)
{
switch (iBaseEffect) {
case SFX_EXP_TANK_BASE:
iSurfEffect = SFX_EXP_TANK_DIRT;
break;
@@ -1164,15 +1125,14 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType)
iBaseEffect = -1;
break;
}
fRadius = 0;
fRadius = 0;
break;
case SURF_GRILL:
iSurfEffect = SFX_EXP_GREN_GRILL;
fRadius = 0;
break;
case SURF_GRASS:
switch (iBaseEffect)
{
switch (iBaseEffect) {
case SFX_EXP_TANK_BASE:
iSurfEffect = SFX_EXP_TANK_DIRT;
break;
@@ -1190,8 +1150,7 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType)
fRadius = 0;
break;
case SURF_ROCK:
switch (iBaseEffect)
{
switch (iBaseEffect) {
case SFX_EXP_TANK_BASE:
iSurfEffect = SFX_EXP_TANK_STONE;
break;
+8 -8
View File
@@ -882,13 +882,13 @@ void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView,
{
default:
case 0:
cgi.UI_ShowMenu("mission_success_1", CVAR_ARCHIVE);
cgi.UI_HideMenu("mission_success_1", CVAR_ARCHIVE);
break;
case 2:
cgi.UI_ShowMenu("mission_success_2", CVAR_ARCHIVE);
cgi.UI_HideMenu("mission_success_2", CVAR_ARCHIVE);
break;
case 3:
cgi.UI_ShowMenu("mission_success_3", CVAR_ARCHIVE);
cgi.UI_HideMenu("mission_success_3", CVAR_ARCHIVE);
break;
}
} else {
@@ -896,21 +896,21 @@ void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView,
{
default:
case 0:
cgi.UI_ShowMenu("mission_failed_1", CVAR_ARCHIVE);
cgi.UI_HideMenu("mission_failed_1", CVAR_ARCHIVE);
break;
case 2:
cgi.UI_ShowMenu("mission_failed_2", CVAR_ARCHIVE);
cgi.UI_HideMenu("mission_failed_2", CVAR_ARCHIVE);
break;
case 3:
cgi.UI_ShowMenu("mission_failed_3", CVAR_ARCHIVE);
cgi.UI_HideMenu("mission_failed_3", CVAR_ARCHIVE);
break;
}
}
} else {
if (cgi.Cvar_Get("g_success", "", 0)->integer) {
cgi.UI_ShowMenu("StatsScreen_Success", qfalse);
cgi.UI_HideMenu("StatsScreen_Success", qfalse);
} else {
cgi.UI_ShowMenu("StatsScreen_Failed", qfalse);
cgi.UI_HideMenu("StatsScreen_Failed", qfalse);
}
}
}
+2 -2
View File
@@ -2710,7 +2710,7 @@ Constructor
Actor::Actor()
: mVoiceType(-1)
{
entflags |= EF_ACTOR;
entflags |= ECF_ACTOR;
m_pszDebugState = "";
m_pFallPath = NULL;
@@ -2963,7 +2963,7 @@ Actor::~Actor()
ClearPointEntity();
ClearTurnEntity();
entflags &= ~EF_ACTOR;
entflags &= ~ECF_ACTOR;
}
/*
+2 -2
View File
@@ -167,7 +167,7 @@ static size_t GetLongestClientCmdAllFramesLength(dtiki_t *tiki, int animnum, int
Animate::Animate()
{
entflags |= EF_ANIMATE;
entflags |= ECF_ANIMATE;
syncTime = 0.0f;
syncRate = 1.0f;
@@ -198,7 +198,7 @@ Animate::Animate()
Animate::~Animate()
{
entflags &= ~EF_ANIMATE;
entflags &= ~ECF_ANIMATE;
}
void Animate::ForwardExec(Event *ev)
+6 -4
View File
@@ -169,22 +169,24 @@ inline void Animate::PauseSyncTime(int pause)
inline void Animate::Archive(Archiver& arc)
{
int i;
Entity::Archive(arc);
for (int i = MAX_FRAMEINFOS - 1; i >= 0; i--) {
for (i = 0; i < MAX_FRAMEINFOS; i++) {
arc.ArchiveInteger(&animFlags[i]);
}
arc.ArchiveFloat(&syncTime);
arc.ArchiveFloat(&syncRate);
arc.ArchiveInteger(&pauseSyncTime);
arc.ArchiveBool(&is_paused);
for (int i = MAX_FRAMEINFOS - 1; i >= 0; i--) {
for (i = 0; i < MAX_FRAMEINFOS; i++) {
arc.ArchiveEventPointer(&doneEvents[i]);
}
for (int i = MAX_FRAMEINFOS - 1; i >= 0; i--) {
for (i = 0; i < MAX_FRAMEINFOS; i++) {
arc.ArchiveFloat(&animtimes[i]);
}
for (int i = MAX_FRAMEINFOS - 1; i >= 0; i--) {
for (i = 0; i < MAX_FRAMEINFOS; i++) {
arc.ArchiveFloat(&frametimes[i]);
}
arc.ArchiveVector(&frame_delta);
+20 -3
View File
@@ -276,7 +276,7 @@ void Container<Type>::Archive(Archiver& arc)
template<typename key, typename value>
void con_set<key, value>::Archive(Archiver& arc)
{
Entry *e;
Entry *e = NULL;
int hash;
int i;
@@ -295,17 +295,34 @@ void con_set<key, value>::Archive(Archiver& arc)
e = new Entry;
e->Archive(arc);
hash = HashCode<key>(e->key) % tableLength;
hash = HashCode<key>(e->GetKey()) % tableLength;
e->next = table[hash];
table[hash] = e;
}
defaultEntry = e;
} else {
for (i = tableLength - 1; i >= 0; i--) {
#ifndef NDEBUG
int total;
total = 0;
for (i = 0; i < tableLength; i++) {
for (e = table[i]; e != NULL; e = e->next) {
e->Archive(arc);
total++;
}
}
// it must match the number of elements
assert(total == count);
#else
for (i = 0; i < tableLength; i++) {
for (e = table[i]; e != NULL; e = e->next) {
e->Archive(arc);
}
}
#endif
}
}
+92 -167
View File
@@ -27,31 +27,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#pragma once
#define GAME_VERSION "mohaa-base-1"
#define GAME_VERSION "mohaa-base-1"
#define DEFAULT_GRAVITY 800
static const unsigned int MINS_X = -15;
static const unsigned int MINS_Y = -15;
static const unsigned int MINS_Z = 0; // IneQuation: bounding box and viewheights to match MoHAA
static const unsigned int MAXS_X = 15;
static const unsigned int MAXS_Y = 15;
static const unsigned int MAXS_Z = 96;
#define SCORE_NOT_PRESENT -9999 // for the CS_SCORES[12] when only one player is present
#define VOTE_TIME 30000 // 30 seconds before vote times out
#define MINS_Z 0
#define MINS_X -15
#define MINS_Y -15
#define MAXS_X 15
#define MAXS_Y 15
#define MINS_Z 0 // IneQuation: bounding box and viewheights to match MoHAA
#define MAXS_Z 96
#define DEAD_MINS_Z 32
#define CROUCH_MAXS_Z 49
#define DEFAULT_VIEWHEIGHT 82
#define CROUCH_RUN_VIEWHEIGHT 64
#define JUMP_START_VIEWHEIGHT 52
#define CROUCH_VIEWHEIGHT 48
#define PRONE_VIEWHEIGHT 16
#define DEAD_VIEWHEIGHT 8
static const unsigned int DEAD_MINS_Z = 32;
static const unsigned int CROUCH_MAXS_Z = 49;
static const unsigned int DEFAULT_VIEWHEIGHT = 82;
static const unsigned int CROUCH_RUN_VIEWHEIGHT = 64;
static const unsigned int JUMP_START_VIEWHEIGHT = 52;
static const unsigned int CROUCH_VIEWHEIGHT = 48;
static const unsigned int PRONE_VIEWHEIGHT = 16;
static const unsigned int DEAD_VIEWHEIGHT = 8;
//
// config strings are a general means of communicating variable length strings
@@ -139,10 +131,10 @@ extern "C" {
GT_MAX_GAME_TYPE
} gametype_t;
//
// scale to use when evaluating entityState_t::constantLight scale
//
#define CONSTANTLIGHT_RADIUS_SCALE 8
//
// scale to use when evaluating entityState_t::constantLight scale
//
static const float CONSTANTLIGHT_RADIUS_SCALE = 8;
typedef enum {
GENDER_MALE,
@@ -150,30 +142,31 @@ extern "C" {
GENDER_NEUTER
} gender_t;
// su44: vma indexes are sent as 4 bits
// see playerState_t::iViewModelAnim
typedef enum {
VMA_IDLE,
VMA_CHARGE,
VMA_FIRE,
VMA_FIRE_SECONDARY,
VMA_RECHAMBER,
VMA_RELOAD,
VMA_RELOAD_SINGLE,
VMA_RELOAD_END,
VMA_PULLOUT,
VMA_PUTAWAY,
VMA_LADDERSTEP,
VMA_ENABLE,
VMA_CUSTOMANIMATION,
VMA_NUMANIMATIONS
} viewmodelanim_t;
enum vmAnim_e {
VM_ANIM_DISABLED,
VM_ANIM_IDLE,
VM_ANIM_CHARGE,
VM_ANIM_FIRE,
VM_ANIM_FIRE_SECONDARY,
VM_ANIM_RECHAMBER,
VM_ANIM_RELOAD,
VM_ANIM_RELOAD_SINGLE,
VM_ANIM_RELOAD_END,
VM_ANIM_PULLOUT,
VM_ANIM_PUTAWAY,
VM_ANIM_LADDERSTEP,
VM_ANIM_IDLE_0,
VM_ANIM_IDLE_1,
VM_ANIM_IDLE_2,
};
// su44: playerState_t::activeItems[8] slots
// they are sent as 16 bits
// TODO: find out rest of them
#define ITEM_AMMO 0 // current ammo
#define ITEM_WEAPON 1 // current mainhand weapon
// su44: playerState_t::activeItems[8] slots
// they are sent as 16 bits
// TODO: find out rest of them
enum itemtype_e {
ITEM_AMMO,
ITEM_WEAPON
};
/*
===================================================================================
@@ -186,17 +179,12 @@ movement on the server game.
===================================================================================
*/
#define MAX_CLIP_PLANES 5
#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes
static const unsigned int MAX_CLIP_PLANES = 5;
static const float MIN_WALK_NORMAL = 0.7f; // can't walk on very steep slopes
#define STEPSIZE 18
static const float STEPSIZE = 18;
#define WATER_TURBO_SPEED 1.35f
#define WATER_TURBO_TIME 1200
#define MINIMUM_RUNNING_TIME 800
#define MINIMUM_WATER_FOR_TURBO 90
#define OVERCLIP 1.001f
static const float OVERCLIP = 1.001f;
// su44: our pmtype_t enum must be the same
// as in MoHAA, because playerState_t::pm_type
@@ -272,22 +260,25 @@ movement on the server game.
#define PMF_UNKNOWN (1 << 14)
#define PMF_NO_LEAN (1 << 15)
// moveposflags
#define MPF_POSITION_STANDING (1 << 0)
#define MPF_POSITION_CROUCHING (1 << 1)
#define MPF_POSITION_PRONE (1 << 2)
#define MPF_POSITION_OFFGROUND (1 << 3)
// moveposflags
enum moveposflags_e {
MPF_POSITION_STANDING = (1 << 0),
MPF_POSITION_CROUCHING = (1 << 1),
MPF_POSITION_PRONE = (1 << 2),
MPF_POSITION_OFFGROUND = (1 << 3),
MPF_MOVEMENT_WALKING = (1 << 4),
MPF_MOVEMENT_RUNNING = (1 << 5),
MPF_MOVEMENT_FALLING = (1 << 6),
};
#define MPF_MOVEMENT_WALKING (1 << 4)
#define MPF_MOVEMENT_RUNNING (1 << 5)
#define MPF_MOVEMENT_FALLING (1 << 6)
#define MAXTOUCH 32
#define MAXTOUCH 32
#define MOVERESULT_NONE 0 // nothing blocking
#define MOVERESULT_TURNED 1 // move blocked, but player turned to avoid it
#define MOVERESULT_BLOCKED 2 // move blocked by slope or wall
#define MOVERESULT_HITWALL 3 // player ran into wall
enum moveresult_e {
MOVERESULT_NONE, // nothing blocking
MOVERESULT_TURNED, // move blocked, but player turned to avoid it
MOVERESULT_BLOCKED, // move blocked by slope or wall
MOVERESULT_HITWALL // player ran into wall
};
typedef struct {
// state (in / out)
@@ -359,36 +350,33 @@ movement on the server game.
//===================================================================================
#define MAX_LETTERBOX_SIZE 0x7fff
static const unsigned int MAX_LETTERBOX_SIZE = 0x7fff;
#define ITEM_NAME_AMMO 0
#define ITEM_NAME_WEAPON 1
#define WEAPON_CLASS_PISTOL (1 << 0)
#define WEAPON_CLASS_RIFLE (1 << 1)
#define WEAPON_CLASS_SMG (1 << 2)
#define WEAPON_CLASS_MG (1 << 3)
#define WEAPON_CLASS_GRENADE (1 << 4)
#define WEAPON_CLASS_HEAVY (1 << 5)
#define WEAPON_CLASS_CANNON (1 << 6)
#define WEAPON_CLASS_ITEM (1 << 7)
#define WEAPON_CLASS_ITEM1 (1 << 8)
#define WEAPON_CLASS_ITEM2 (1 << 9)
#define WEAPON_CLASS_ITEM3 (1 << 10)
#define WEAPON_CLASS_ITEM4 (1 << 11)
#define WEAPON_CLASS_ANY_ITEM \
(WEAPON_CLASS_ITEM | WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 | WEAPON_CLASS_ITEM4)
#define WEAPON_CLASS_ITEM_SLOT_BITS (WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 | WEAPON_CLASS_ITEM4)
#define WEAPON_CLASS_PRIMARY (!(WEAPON_CLASS_PISTOL | WEAPON_CLASS_GRENADE))
#define WEAPON_CLASS_SECONDARY (WEAPON_CLASS_PISTOL | WEAPON_CLASS_GRENADE)
#define WEAPON_CLASS_THROWABLE (WEAPON_CLASS_GRENADE | WEAPON_CLASS_ITEM)
#define WEAPON_CLASS_MISC \
(WEAPON_CLASS_CANNON | WEAPON_CLASS_ITEM | WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 \
| WEAPON_CLASS_ITEM4)
#define WEAPON_CLASS_ITEMINDEX (WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 | WEAPON_CLASS_ITEM4)
#define STAT_DEAD_YAW 5 // su44: Is there a DEAD_YAW stat in MoHAA?
enum weaponclass_e {
WEAPON_CLASS_PISTOL = (1 << 0),
WEAPON_CLASS_RIFLE = (1 << 1),
WEAPON_CLASS_SMG = (1 << 2),
WEAPON_CLASS_MG = (1 << 3),
WEAPON_CLASS_GRENADE = (1 << 4),
WEAPON_CLASS_HEAVY = (1 << 5),
WEAPON_CLASS_CANNON = (1 << 6),
WEAPON_CLASS_ITEM = (1 << 7),
WEAPON_CLASS_ITEM1 = (1 << 8),
WEAPON_CLASS_ITEM2 = (1 << 9),
WEAPON_CLASS_ITEM3 = (1 << 10),
WEAPON_CLASS_ITEM4 = (1 << 11),
WEAPON_CLASS_ANY_ITEM =
(WEAPON_CLASS_ITEM | WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 | WEAPON_CLASS_ITEM4),
WEAPON_CLASS_ITEM_SLOT_BITS =
(WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 | WEAPON_CLASS_ITEM4),
WEAPON_CLASS_PRIMARY = (!(WEAPON_CLASS_PISTOL | WEAPON_CLASS_GRENADE)),
WEAPON_CLASS_SECONDARY = (WEAPON_CLASS_PISTOL | WEAPON_CLASS_GRENADE),
WEAPON_CLASS_THROWABLE = (WEAPON_CLASS_GRENADE | WEAPON_CLASS_ITEM),
WEAPON_CLASS_MISC =
(WEAPON_CLASS_CANNON | WEAPON_CLASS_ITEM | WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3
| WEAPON_CLASS_ITEM4),
WEAPON_CLASS_ITEMINDEX = (WEAPON_CLASS_ITEM1 | WEAPON_CLASS_ITEM2 | WEAPON_CLASS_ITEM3 | WEAPON_CLASS_ITEM4)
};
// player_state->persistant[] indexes
// these fields are the only part of player_state that isn't
@@ -401,6 +389,7 @@ movement on the server game.
// entityState_t->eFlags
// su44: eFlags used in MoHAA
#define EF_EVERYFRAME 0x00000008
#define EF_CLIMBWALL 0x00000010
#define EF_UNARMED 0x00000020 // su44: this player has his weapon holstered
#define EF_LINKANGLES 0x00000040
@@ -434,33 +423,11 @@ movement on the server game.
#define EF_AWARD_ASSIST 0x00020000 // draw a assist sprite
#define EF_AWARD_DENIED 0x00040000 // denied
#define EF_TEAMVOTED 0x00080000 // already cast a team vote
#define EF_EVERYFRAME 0x00100000 // def commands will be run every client frame
#define EF_ANTISBJUICE 0x00200000 // anti sucknblow juice
#define EF_DONT_PROCESS_COMMANDS 0x00400000 // don't process client commands for this entity
// these defines could be deleted sometime when code/game/ is cleared of Q3A stuff
#define TEAM_FREE 0
#define TEAM_RED 4
#define TEAM_BLUE 3
#define TEAM_NUM_TEAMS 5
//===================================================================================
// flip the togglebit every time an animation
// changes so a restart of the same anim can be detected
#define ANIM_TOGGLEBIT (1 << 9)
#define ANIM_BLEND (1 << 10)
#define ANIM_NUMBITS 11
// server side anim bits
#define ANIM_SERVER_EXITCOMMANDS_PROCESSED (1 << 12)
#define ANIM_MASK (~(ANIM_TOGGLEBIT | ANIM_BLEND | ANIM_SERVER_EXITCOMMANDS_PROCESSED))
// if FRAME_EXPLICIT is set, don't auto animate
#define FRAME_EXPLICIT 512
#define FRAME_MASK (~FRAME_EXPLICIT)
//
// Tag specific flags
//
@@ -601,9 +568,6 @@ movement on the server game.
SWT_FUSE_WET
} stopWatchType_t;
// How many players on the overlay
#define TEAM_MAXOVERLAY 32
//---------------------------------------------------------
// g_dmflags->integer flags
@@ -638,7 +602,7 @@ movement on the server game.
#define DF_WEAPON_NO_SHOTGUN (1 << 27)
#define DF_WEAPON_NO_LANDMINE (1 << 28)
#define DM_FLAG(flag) (g_gametype->integer && ((int)dmflags->integer & (flag)))
#define DM_FLAG(flag) (g_gametype->integer != GT_SINGLE_PLAYER && ((int)dmflags->integer & (flag)))
// content masks
#define MASK_ALL (-1)
@@ -736,50 +700,11 @@ movement on the server game.
#define MASK_CORNER_NODE \
(CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_UNKNOWN2 | CONTENTS_WEAPONCLIP | CONTENTS_BODY)
// mohaa mask
/*
#define MASK_ALL -1
#define MASK_SOLID 1
#define MASK_COLLISION 0x26000B21
#define MASK_PERMANENTMARK 0x40000001
#define MASK_AUTOCALCLIFE 0x40002021
#define MASK_EXPLOSION 0x40040001
#define MASK_TREADMARK 0x42012B01
#define MASK_THIRDPERSON 0x42012B39
#define MASK_FOOTSTEP 0x42022901
#define MASK_BEAM 0x42042B01
#define MASK_VISIBLE 0x42042B01
#define MASK_VEHICLE 0x42042B01
#define MASK_BULLET 0x42042B21
#define MASK_SHOT 0x42042BA1
#define MASK_CROSSHAIRSHADER 0x42092B01
#define MASK_TRACER 0x42142B21
*/
void BG_EvaluateTrajectoryDelta(const trajectory_t *tr, int atTime, vec3_t result);
void BG_PlayerStateToEntityState(playerState_t *ps, entityState_t *s, qboolean snap);
void BG_PlayerStateToEntityStateExtraPolate(playerState_t *ps, entityState_t *s, int time, qboolean snap);
enum vmAnim_e {
VM_ANIM_DISABLED,
VM_ANIM_IDLE,
VM_ANIM_CHARGE,
VM_ANIM_FIRE,
VM_ANIM_FIRE_SECONDARY,
VM_ANIM_RECHAMBER,
VM_ANIM_RELOAD,
VM_ANIM_RELOAD_SINGLE,
VM_ANIM_RELOAD_END,
VM_ANIM_PULLOUT,
VM_ANIM_PUTAWAY,
VM_ANIM_LADDERSTEP,
VM_ANIM_IDLE_0,
VM_ANIM_IDLE_1,
VM_ANIM_IDLE_2,
};
enum cg_message_ver_15_e {
CGM_NONE,
CGM_BULLET_1,
+1 -1
View File
@@ -542,7 +542,7 @@ CLASS_DECLARATION(Entity, SplinePath, "info_splinepath") {
SplinePath::SplinePath()
{
entflags |= EF_SPLINEPATH;
entflags |= ECF_SPLINEPATH;
AddWaitTill(STRING_REACH);
+1 -1
View File
@@ -702,7 +702,7 @@ Camera::Camera()
{
Vector ang;
entflags |= EF_CAMERA;
entflags |= ECF_CAMERA;
AddWaitTill(STRING_START);
AddWaitTill(STRING_TRIGGER);
+1 -1
View File
@@ -101,7 +101,7 @@ CLASS_DECLARATION(Entity, CrateObject, "func_crate") {
CrateObject::CrateObject()
{
entflags |= EF_CRATEOBJECT;
entflags |= ECF_CRATEOBJECT;
AddWaitTill(STRING_DEATH);
+2
View File
@@ -310,6 +310,8 @@ void DamageModel::EventSetKillThread(Event *ev)
void DamageModel::Archive(Archiver& arc)
{
Animate::Archive(arc);
label.Archive(arc);
arc.ArchiveSafePointer(&boundingBoxEnt);
}
+1 -1
View File
@@ -321,7 +321,7 @@ Door::Door()
{
float t;
entflags |= EF_DOOR;
entflags |= ECF_DOOR;
if (LoadingSavegame) {
return;
}
+17 -18
View File
@@ -1686,7 +1686,7 @@ Entity::Entity()
entnum = edict->s.number;
radnum = -1;
entflags |= EF_ENTITY;
entflags |= ECF_ENTITY;
AddWaitTill(STRING_DAMAGE);
AddWaitTill(STRING_SPAWN);
@@ -1780,9 +1780,6 @@ Entity::Entity()
m_BlockedPaths = NULL;
m_bHintRequiresLookAt = true;
// Misc
m_bBindChilds = false;
}
Entity::~Entity()
@@ -1852,7 +1849,7 @@ Entity::~Entity()
level.FreeEdict(edict);
entflags &= ~EF_ENTITY;
entflags &= ~ECF_ENTITY;
}
void Entity::ClassnameEvent(Event *ev)
@@ -4704,7 +4701,7 @@ qboolean Entity::isBoundTo(Entity *master)
return false;
}
void Entity::bind(Entity *master, qboolean use_my_angles, qboolean bBindChilds)
void Entity::bind(Entity *master, qboolean use_my_angles)
{
float mat[3][3];
float local[3][3];
@@ -4721,8 +4718,6 @@ void Entity::bind(Entity *master, qboolean use_my_angles, qboolean bBindChilds)
return;
}
m_bBindChilds = bBindChilds;
// unbind myself from my master
unbind();
@@ -4885,17 +4880,10 @@ void Entity::EventUnbind(Event *ev)
void Entity::BindEvent(Event *ev)
{
Entity *ent;
bool bBindChilds;
ent = ev->GetEntity(1);
if (ent) {
if (ev->NumArgs() > 1) {
bBindChilds = ev->GetBoolean(2);
} else {
bBindChilds = false;
}
bind(ent, false, bBindChilds);
bind(ent, false);
}
}
@@ -5783,8 +5771,13 @@ void Entity::Archive(Archiver& arc)
arc.ArchiveInteger(&spawnflags);
arc.ArchiveString(&model);
if (arc.Loading() && model.length()) {
setModel(model);
if (arc.Loading() && AutoArchiveModel()) {
if (model.length() && model[0] == '*') {
// set the brush model
edict->s.modelindex = atoi(model.c_str() + 1);
} else {
setModel(model);
}
}
arc.ArchiveVector(&mins);
@@ -5849,6 +5842,11 @@ void Entity::Archive(Archiver& arc)
ArchiveEnum(takedamage, damage_t);
arc.ArchiveSafePointer(&enemy);
arc.ArchiveFloat(&pain_finished);
arc.ArchiveFloat(&damage_debounce_time);
arc.ArchiveInteger(&damage_type);
arc.ArchiveInteger(&m_iNumGlues);
for (i = 0; i < MAX_GLUE_CHILDREN; i++) {
@@ -5858,6 +5856,7 @@ void Entity::Archive(Archiver& arc)
arc.ArchiveObjectPointer((Class **)&m_pGlueMaster);
arc.ArchiveBool(&m_bGlueAngles);
arc.ArchiveBool(&m_bGlueDuckable);
arc.ArchiveBoolean(&detach_at_death);
arc.ArchiveFloat(&stealthMovementScale);
+5 -2
View File
@@ -285,10 +285,13 @@ public:
// immune list
Container<int> immunities;
//
// Openmohaa additions
//====
// miscellaneous
qboolean m_bBindChilds;
bool m_bHintRequiresLookAt;
str m_HintString;
//====
Entity();
virtual ~Entity();
@@ -538,7 +541,7 @@ public:
void joinTeam(Entity *teammember);
void quitTeam(void);
qboolean isBoundTo(Entity *master);
virtual void bind(Entity *master, qboolean use_my_angles = qfalse, qboolean bBindChilds = qfalse);
virtual void bind(Entity *master, qboolean use_my_angles = qfalse);
virtual void unbind(void);
virtual void glue(Entity *master, qboolean use_my_angles = qtrue, qboolean can_duck = qfalse);
virtual void unglue(void);
+6
View File
@@ -904,6 +904,12 @@ void ScriptThreadLabel::Execute(const SafePtr<Listener>& listener, const SafePtr
}
}
void ScriptThreadLabel::Clear()
{
m_Script = NULL;
m_Label = STRING_EMPTY;
}
void ScriptThreadLabel::Set(const char *label)
{
str script;
+1
View File
@@ -165,6 +165,7 @@ public:
void Execute(Listener *listener, Event *ev);
void Execute(const SafePtr<Listener> &listener, const SafePtr<Listener> &param);
void Clear();
void Set(const char *label);
void Set(const_str label);
void SetScript(const ScriptVariable& label);
+2 -2
View File
@@ -53,7 +53,7 @@ CLASS_DECLARATION( Weapon, InventoryItem, NULL )
InventoryItem::InventoryItem()
{
entflags |= EF_INVENTORYITEM;
entflags |= ECF_INVENTORYITEM;
if ( LoadingSavegame )
{
@@ -65,7 +65,7 @@ InventoryItem::InventoryItem()
InventoryItem::~InventoryItem()
{
entflags &= ~EF_INVENTORYITEM;
entflags &= ~ECF_INVENTORYITEM;
}
void InventoryItem::ActivateItem
+2 -2
View File
@@ -341,7 +341,7 @@ Item::Item()
{
str fullname;
entflags |= EF_ITEM;
entflags |= ECF_ITEM;
AddWaitTill(STRING_PICKUP);
@@ -403,7 +403,7 @@ Item::~Item()
owner = NULL;
}
entflags &= ~EF_ITEM;
entflags &= ~ECF_ITEM;
}
void Item::RemoveFromOwner(void)
+3 -3
View File
@@ -1960,7 +1960,7 @@ CLASS_DECLARATION(SimpleArchivedEntity, Waypoint, "info_waypoint") {
Waypoint::Waypoint()
{
entflags |= EF_WAYPOINT;
entflags |= ECF_WAYPOINT;
}
CLASS_DECLARATION(SimpleArchivedEntity, TempWaypoint, NULL) {
@@ -1969,7 +1969,7 @@ CLASS_DECLARATION(SimpleArchivedEntity, TempWaypoint, NULL) {
TempWaypoint::TempWaypoint()
{
entflags |= EF_TEMPWAYPOINT;
entflags |= ECF_TEMPWAYPOINT;
}
/*****************************************************************************/
@@ -1988,7 +1988,7 @@ CLASS_DECLARATION(Waypoint, VehiclePoint, "info_vehiclepoint") {
VehiclePoint::VehiclePoint()
{
entflags |= EF_VEHICLEPOINT;
entflags |= ECF_VEHICLEPOINT;
spawnflags = 0;
}
+2 -2
View File
@@ -1166,7 +1166,7 @@ void PathNode::operator delete(void *ptr)
PathNode::PathNode()
{
entflags |= EF_PATHNODE;
entflags |= ECF_PATHNODE;
findCount = 0;
pLastClaimer = NULL;
numChildren = 0;
@@ -1186,7 +1186,7 @@ PathNode::PathNode()
PathNode::~PathNode()
{
entflags &= ~EF_PATHNODE;
entflags &= ~ECF_PATHNODE;
}
void PathNode::Remove(Event *ev)
+36 -26
View File
@@ -1950,7 +1950,7 @@ Player::Player()
//
// set the entity type
//
entflags |= EF_PLAYER;
entflags |= ECF_PLAYER;
mCurTrailOrigin = 0;
mLastTrailTime = 0;
@@ -1992,6 +1992,16 @@ Player::Player()
m_iInvulnerableTimeRemaining = 0;
m_fLastVoteTime = 0;
//
// Openmohaa additions
//====
m_bShowingHint = false;
disable_spectate = false;
disable_team_change = false;
m_fpsTiki = NULL;
m_bConnected = false;
//====
if (LoadingSavegame) {
return;
}
@@ -2134,21 +2144,15 @@ Player::Player()
//
// Openmohaa additions
//
m_bShowingHint = false;
disable_spectate = false;
disable_team_change = false;
//====
m_bFrozen = false;
animDoneVM = true;
m_fVMAtime = 0;
m_fpsTiki = NULL;
//====
for (int i = 0; i < MAX_SPEED_MULTIPLIERS; i++) {
speed_multiplier[i] = 1.0f;
}
m_pKilledEvent = NULL;
m_bConnected = false;
}
Player::~Player()
@@ -2171,7 +2175,7 @@ Player::~Player()
legs_conditionals.FreeObjectList();
torso_conditionals.FreeObjectList();
entflags &= ~EF_PLAYER;
entflags &= ~ECF_PLAYER;
}
static qboolean logfile_started = qfalse;
@@ -2480,6 +2484,11 @@ void Player::InitModel(void)
}
}
InitModelFps();
}
void Player::InitModelFps(void)
{
char model_name[MAX_STRING_TOKENS];
char *model_replace;
@@ -2508,6 +2517,10 @@ void Player::InitPhysics(void)
memset(&last_ucmd, 0, sizeof(last_ucmd));
client->ps.groundTrace.fraction = 1.0f;
// Added in OPM
// Prevent the player from being stuck
flags &= ~FL_PARTIAL_IMMOBILE;
}
void Player::InitPowerups(void)
@@ -3032,18 +3045,19 @@ void Player::Killed(Event *ev)
Entity *inflictor;
int meansofdeath;
int location;
Event *event;
Event *event;
//
// This one is openmohaa-specific
// Custom killed event will do the job
//
if (m_pKilledEvent) {
event = new Event(*m_pKilledEvent);
if (m_killedLabel.IsSet()) {
event = new Event(0, ev->NumArgs());
for (int i = 1; i <= ev->NumArgs(); i++) {
event->AddValue(ev->GetValue(i));
}
ProcessEvent(event);
m_killedLabel.Execute(this, event);
delete event;
Unregister(STRING_DEATH);
return;
@@ -3073,7 +3087,7 @@ void Player::Killed(Event *ev)
deadflag = DEAD_DYING;
health = 0;
event = new Event(EV_Pain);
event = new Event(EV_Pain, 10);
event->AddEntity(attacker);
event->AddFloat(ev->GetFloat(2));
@@ -3141,7 +3155,7 @@ void Player::Killed(Event *ev)
//
// Openmohaa scripted events
//
event = new Event;
event = new Event(0, 11);
event->AddEntity(ev->GetEntity(1));
event->AddFloat(ev->GetFloat(2));
@@ -7268,10 +7282,10 @@ void Player::UpdateStats(void)
weapon->SetItemSlot(0);
} else {
client->ps.activeItems[iItem + 2] = weapon->getIndex();
weapon->SetItemSlot(256 << iItem);
weapon->SetItemSlot(WEAPON_CLASS_ITEM1 << iItem);
if (activeweap && weapon == activeweap) {
client->ps.stats[STAT_EQUIPPED_WEAPON] = 256 << iItem;
client->ps.stats[STAT_EQUIPPED_WEAPON] = WEAPON_CLASS_ITEM1 << iItem;
}
iItem++;
@@ -11738,8 +11752,8 @@ void Player::GetDeaths(Event *ev)
void Player::GetKillHandler(Event *ev)
{
if (m_pKilledEvent) {
ev->AddValue(m_pKilledEvent->GetValue(1));
if (m_killedLabel.IsSet()) {
m_killedLabel.GetScriptValue(&ev->GetValue());
} else {
ev->AddNil();
}
@@ -12025,13 +12039,9 @@ void Player::SetEntityShader(Event *ev)
void Player::SetKillHandler(Event *ev)
{
if (ev->IsNilAt(1) || (ev->IsStringAt(1) && !ev->GetString(1).icmp("none"))) {
if (m_pKilledEvent != NULL) {
delete m_pKilledEvent;
m_pKilledEvent = NULL;
}
m_killedLabel.Clear();
} else {
m_pKilledEvent = new Event(EV_Listener_ExecuteScript);
m_pKilledEvent->AddValue(ev->GetValue(1));
m_killedLabel.SetScript(ev->GetValue(1));
}
}
+17 -4
View File
@@ -350,7 +350,7 @@ public:
bool m_bFrozen; // if player is frozen
bool animDoneVM;
float speed_multiplier[MAX_SPEED_MULTIPLIERS];
Event *m_pKilledEvent;
ScriptThreadLabel m_killedLabel;
con_map<str, vma_t> vmalist;
str m_sVMAcurrent;
str m_sVMcurrent;
@@ -514,6 +514,7 @@ public:
void InitWeapons(void);
void InitView(void);
void InitModel(void);
void InitModelFps(void); // Added in openmohaa
void InitState(void);
void InitHealth(void);
void InitInventory(void);
@@ -1014,6 +1015,7 @@ inline void Player::Archive(Archiver& arc)
arc.ArchiveInteger(&buttons);
arc.ArchiveInteger(&new_buttons);
arc.ArchiveInteger(&server_new_buttons);
arc.ArchiveFloat(&respawn_time);
arc.ArchiveInteger(&last_attack_button);
@@ -1053,6 +1055,8 @@ inline void Player::Archive(Archiver& arc)
arc.ArchiveBool(&take_pain);
arc.ArchiveInteger(&nextpaintime);
arc.ArchiveFloat(&m_fHealRate);
arc.ArchiveBool(&knockdown);
arc.ArchiveBool(&canfall);
arc.ArchiveBool(&falling);
@@ -1157,17 +1161,27 @@ inline void Player::Archive(Archiver& arc)
if (arc.Loading()) {
UpdateWeapons();
InitModelFps();
}
//
// Openmohaa additions
//
arc.ArchiveBool(&m_bFrozen);
arc.ArchiveBool(&animDoneVM);
arc.ArchiveFloat(&m_fVMAtime);
for (int i = 0; i < MAX_SPEED_MULTIPLIERS; i++) {
arc.ArchiveFloat(&speed_multiplier[i]);
}
}
inline Camera *Player::CurrentCamera(void)
{
return camera;
}
inline void Player::CameraCut(void)
{
//
// toggle the camera cut bit
@@ -1177,7 +1191,6 @@ inline void Player::CameraCut(void)
}
inline void Player::CameraCut(Camera *ent)
{
if (ent == camera) {
// if the camera we are currently looking through cut, than toggle the cut bits
+216 -39
View File
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "player.h"
#include "g_phys.h"
#include "portableturret.h"
extern Event EV_Player_AnimLoop_Torso;
extern Event EV_Player_AnimLoop_Legs;
@@ -32,7 +33,7 @@ extern Event EV_Player_AnimLoop_Legs;
void Player::EndAnim_Legs(Event *ev)
{
animdone_Legs = true;
if (IsRepeatType(m_iPartSlot[legs])) {
SetAnimDoneEvent(EV_Player_AnimLoop_Legs, m_iPartSlot[legs]);
}
@@ -51,7 +52,7 @@ void Player::EndAnim_Torso(Event *ev)
EvaluateState();
}
void Player::EndAnim_Pain(Event* ev)
void Player::EndAnim_Pain(Event *ev)
{
animdone_Pain = true;
}
@@ -166,15 +167,173 @@ int Player::CurrentPartAnim(bodypart_t part) const
void Player::AdjustAnimBlends(void)
{
int iPartSlot;
int iOldPartSlot;
float fWeightTotal;
int iPartSlot;
int iOldPartSlot;
float fWeightTotal;
qboolean playTurretAnim = false;
if (movetype == MOVETYPE_PORTABLE_TURRET) {
PortableTurret *turret = static_cast<PortableTurret *>(m_pTurret.Pointer());
if (turret->IsReloading()) {
if (partAnim[legs] != "mg42tripod_reload") {
SetPartAnim("mg42tripod_reload", legs);
StopAnimating(m_iPartSlot[torso]);
StopAnimating(m_iPartSlot[torso] ^ 1);
partAnim[torso] = "";
}
} else if (turret->IsSettingUp()) {
if (partAnim[legs] != "mg42tripod_setup") {
SetPartAnim("mg42tripod_setup", legs);
StopAnimating(m_iPartSlot[torso]);
StopAnimating(m_iPartSlot[torso] ^ 1);
partAnim[torso] = "";
}
} else if (turret->IsPackingUp()) {
if (partAnim[legs] != "mg42tripod_packup") {
SetPartAnim("mg42tripod_packup", legs);
StopAnimating(m_iPartSlot[torso]);
StopAnimating(m_iPartSlot[torso] ^ 1);
partAnim[torso] = "";
}
} else {
playTurretAnim = true;
}
}
if (playTurretAnim) {
PortableTurret *turret = static_cast<PortableTurret *>(m_pTurret.Pointer());
if (partAnim[legs] != "mg42tripod_aim") {
StopPartAnimating(legs);
}
if (partAnim[torso] != "mg42tripod_aim") {
StopPartAnimating(torso);
}
partAnim[legs] = "mg42tripod_aim";
partAnim[torso] = "mg42tripod_aim";
float pitch, yaw;
float legsPitchAngle, torsoPitchAngle;
float pitchAlpha, yawAlpha;
float legsYawAngle, torsoYawAngle;
float weight;
int animNum;
str vertLegsStr, vertTorsoStr;
str horzLegsStr, horzTorsoStr;
str anim;
pitch = AngleSubtract(turret->GetGroundPitch(), turret->angles[0]);
yaw = AngleSubtract(turret->GetStartYaw(), turret->angles[1]);
if (pitch >= 0) {
legsPitchAngle = 0.0;
torsoPitchAngle = 15.0;
vertLegsStr = "_straight";
vertTorsoStr = "_up15";
} else {
legsPitchAngle = -15.0;
torsoPitchAngle = 0.0;
vertLegsStr = "_down15";
vertTorsoStr = "_straight";
}
pitchAlpha = (pitch - legsPitchAngle) / (torsoPitchAngle - legsPitchAngle);
pitchAlpha = Q_clamp_float(pitchAlpha, 0, 1);
if (yaw < -20) {
legsYawAngle = -40.0;
torsoYawAngle = -20.0;
horzLegsStr = "_left40";
horzTorsoStr = "_left20";
} else if (yaw < 0) {
legsYawAngle = -20.0;
torsoYawAngle = 0.0;
horzLegsStr = "_left20";
horzTorsoStr = "_straight";
} else if (yaw <= 20) {
legsYawAngle = 0.0;
torsoYawAngle = 20.0;
horzLegsStr = "_straight";
horzTorsoStr = "_right20";
} else {
legsYawAngle = 20.0;
torsoYawAngle = 40.0;
horzLegsStr = "_right20";
horzTorsoStr = "_right40";
}
yawAlpha = (yaw - legsYawAngle) / (torsoYawAngle - legsYawAngle);
yawAlpha = Q_clamp_float(yawAlpha, 0, 1);
anim = "mg42tripod_aim" + horzLegsStr + vertLegsStr;
weight = (1 - pitchAlpha) * (1 - yawAlpha);
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
if (animNum == -1) {
gi.DPrintf("^~^~^ Warning: Can't find player animation '%s'.\n", anim.c_str());
anim = "mg42tripod_aim_straight_straight";
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
}
if (animNum == CurrentAnim(0)) {
SetWeight(0, weight);
} else {
NewAnim(animNum, 0, weight);
}
anim = "mg42tripod_aim" + horzLegsStr + vertTorsoStr;
weight = (1.0 - yawAlpha) * pitchAlpha;
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
if (animNum == -1) {
gi.DPrintf("^~^~^ Warning: Can't find player animation '%s'.\n", anim.c_str());
anim = "mg42tripod_aim_straight_straight";
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
}
if (animNum == CurrentAnim(1)) {
SetWeight(1, weight);
} else {
NewAnim(animNum, 1, weight);
}
anim = "mg42tripod_aim" + horzTorsoStr + vertTorsoStr;
weight = pitchAlpha * yawAlpha;
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
if (animNum == -1) {
gi.DPrintf("^~^~^ Warning: Can't find player animation '%s'.\n", anim.c_str());
anim = "mg42tripod_aim_straight_straight";
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
}
if (animNum == CurrentAnim(2)) {
SetWeight(2, weight);
} else {
NewAnim(animNum, 2, weight);
}
anim = "mg42tripod_aim" + horzTorsoStr + vertTorsoStr;
weight = (1.0 - pitchAlpha) * yawAlpha;
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
if (animNum == -1) {
gi.DPrintf("^~^~^ Warning: Can't find player animation '%s'.\n", anim.c_str());
anim = "mg42tripod_aim_straight_straight";
animNum = gi.Anim_NumForName(edict->tiki, anim.c_str());
}
if (animNum == CurrentAnim(3)) {
SetWeight(3, weight);
} else {
NewAnim(animNum, 3, weight);
}
}
if (deadflag == DEAD_DEAD) {
if (m_fPainBlend) {
StopAnimating(ANIMSLOT_PAIN);
edict->s.frameInfo[ANIMSLOT_PAIN].weight = 0;
m_fPainBlend = 0;
SetWeight(ANIMSLOT_PAIN, 0);
m_fPainBlend = 0;
animdone_Pain = false;
}
return;
@@ -184,44 +343,56 @@ void Player::AdjustAnimBlends(void)
iOldPartSlot = m_iPartSlot[legs] ^ 1;
if (m_fPartBlends[legs] <= 0.0f) {
if (partOldAnim[legs] == "") {
goto __blend_torso;
}
if (partOldAnim[legs] != "") {
StopAnimating(iOldPartSlot);
StopAnimating(iOldPartSlot);
if (partAnim[legs] == "") {
SetWeight(iPartSlot, 0.0);
} else {
SetWeight(iPartSlot, 1.0);
}
} else {
if (partAnim[legs] == "") {
SetWeight(iPartSlot, 0.0);
} else {
SetWeight(iPartSlot, 1.0);
}
}
} else {
m_fPartBlends[legs] = m_fPartBlends[legs] - level.frametime * partBlendMult[legs];
m_fPartBlends[legs] -= level.frametime * partBlendMult[legs];
if (m_fPartBlends[legs] >= 0.01f) {
if (partOldAnim[legs] != "") {
edict->s.frameInfo[iOldPartSlot].weight = m_fPartBlends[legs];
SetWeight(iOldPartSlot, m_fPartBlends[legs]);
}
if (partAnim[legs] != "") {
edict->s.frameInfo[iPartSlot].weight = 1.0f - m_fPartBlends[legs];
SetWeight(iPartSlot, 1.0f - m_fPartBlends[legs]);
}
} else {
m_fPartBlends[legs] = 0.0f;
StopAnimating(iOldPartSlot);
partOldAnim[legs] = "";
goto __blend_torso;
if (partAnim[legs] == "") {
SetWeight(iPartSlot, 0.0);
} else {
SetWeight(iPartSlot, 1.0);
}
}
m_fPartBlends[legs] = 0.0f;
StopAnimating(iOldPartSlot);
partOldAnim[legs] = "";
}
if (partAnim[legs] != "") {
edict->s.frameInfo[iPartSlot].weight = 1.0f;
} else {
edict->s.frameInfo[iPartSlot].weight = 0.0f;
}
__blend_torso:
iPartSlot = m_iPartSlot[torso];
iOldPartSlot = m_iPartSlot[torso] ^ 1;
if (m_fPartBlends[torso] <= 0.0f) {
if (partOldAnim[torso] != "") {
StopAnimating(iOldPartSlot);
partOldAnim[torso] = "";
if (partAnim[torso] == "") {
SetWeight(iPartSlot, 0.0);
} else {
SetWeight(iPartSlot, 1.0);
}
}
} else {
m_fPartBlends[torso] = m_fPartBlends[torso] - level.frametime * partBlendMult[torso];
@@ -229,11 +400,11 @@ __blend_torso:
fWeightTotal = 0.0f;
if (partOldAnim[torso] != "") {
edict->s.frameInfo[iOldPartSlot].weight = m_fPartBlends[torso];
SetWeight(iOldPartSlot, m_fPartBlends[torso]);
fWeightTotal += m_fPartBlends[torso];
}
if (partAnim[torso] != "") {
edict->s.frameInfo[iPartSlot].weight = 1.0f - m_fPartBlends[torso];
SetWeight(iPartSlot, m_fPartBlends[torso]);
fWeightTotal += 1.0f - m_fPartBlends[torso];
}
@@ -241,9 +412,15 @@ __blend_torso:
} else {
m_fPartBlends[torso] = 0.0f;
StopAnimating(iOldPartSlot);
partOldAnim[torso] = "";
edict->s.frameInfo[iPartSlot].weight = partAnim[torso] != "" ? 1.0f : 0.0f;
edict->s.actionWeight = partAnim[torso] != "" ? 1.0f : 0.0f;
partOldAnim[torso] = "";
if (partAnim[torso] == "") {
SetWeight(iPartSlot, 0.0);
edict->s.actionWeight = 0.0;
} else {
SetWeight(iPartSlot, 1.0);
edict->s.actionWeight = 1.0;
}
}
}
@@ -251,24 +428,24 @@ __blend_torso:
if (m_sPainAnim == "") {
StopAnimating(ANIMSLOT_PAIN);
edict->s.frameInfo[ANIMSLOT_PAIN].weight = 0;
m_fPainBlend = 0;
animdone_Pain = false;
m_fPainBlend = 0;
animdone_Pain = false;
} else if (animdone_Pain) {
m_fPainBlend -= level.frametime * (10.0 / 3.0);
if (m_fPainBlend < 0.01f) {
StopAnimating(ANIMSLOT_PAIN);
edict->s.frameInfo[ANIMSLOT_PAIN].weight = 0;
m_fPainBlend = 0;
animdone_Pain = false;
m_fPainBlend = 0;
animdone_Pain = false;
}
}
if (m_fPainBlend) {
int i;
int i;
float w;
edict->s.frameInfo[ANIMSLOT_PAIN].weight = m_fPainBlend;
w = 1.0 - m_fPainBlend * 0.5;
w = 1.0 - m_fPainBlend * 0.5;
for (i = 0; i < ANIMSLOT_PAIN; i++) {
if (edict->s.frameInfo[i].weight) {
@@ -336,7 +513,7 @@ void Player::PlayerAnimDelta(float *vDelta)
}
}
void Player::EventTestAnim(Event* ev)
void Player::EventTestAnim(Event *ev)
{
// FIXME: unimplemented
}
+1 -1
View File
@@ -95,7 +95,7 @@ void Player::WhatIs(Event *ev)
animname = NULL;
if (gi.modeltiki(ent->model)) {
animname = gi.Anim_NameForNum(ent->edict->tiki, ent->edict->s.frameInfo[0].index & ANIM_MASK);
animname = gi.Anim_NameForNum(ent->edict->tiki, ent->edict->s.frameInfo[0].index);
}
if (!animname) {
+1 -1
View File
@@ -44,7 +44,7 @@ PlayerBot::botfunc_t PlayerBot::botfuncs[MAX_BOT_FUNCTIONS];
PlayerBot::PlayerBot()
{
entflags |= EF_BOT;
entflags |= ECF_BOT;
if (LoadingSavegame) {
return;
+40 -25
View File
@@ -925,44 +925,59 @@ void ScriptMaster::ArchiveString(Archiver& arc, const_str& s)
void ScriptMaster::Archive(Archiver& arc)
{
ScriptClass *scr;
ScriptVM *m_current;
ScriptThread *m_thread;
int numClasses;
int numThreads;
int i, j;
int count;
int i, j;
ScriptClass *c;
int num;
ScriptVM *scriptVM;
ScriptVM *prevScriptVM;
if (arc.Saving()) {
numClasses = (int)ScriptClass_allocator.Count();
arc.ArchiveInteger(&numClasses);
count = (int)ScriptClass_allocator.Count();
arc.ArchiveInteger(&count);
MEM_BlockAlloc_enum<ScriptClass> en = ScriptClass_allocator;
for (scr = en.NextElement(); scr != NULL; scr = en.NextElement()) {
scr->ArchiveInternal(arc);
for (c = en.NextElement(); c != NULL; c = en.NextElement()) {
c->ArchiveInternal(arc);
numThreads = 0;
for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next) {
numThreads++;
num = 0;
for (scriptVM = c->m_Threads; scriptVM != NULL; scriptVM = scriptVM->next) {
num++;
}
arc.ArchiveInteger(&numThreads);
arc.ArchiveInteger(&num);
for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next) {
m_current->m_Thread->ArchiveInternal(arc);
for (scriptVM = c->m_Threads; scriptVM != NULL; scriptVM = scriptVM->next) {
scriptVM->m_Thread->ArchiveInternal(arc);
}
}
} else {
arc.ArchiveInteger(&numClasses);
arc.ArchiveInteger(&count);
for (i = 0; i < numClasses; i++) {
scr = new ScriptClass();
scr->ArchiveInternal(arc);
for (i = 0; i < count; i++) {
c = new ScriptClass();
c->ArchiveInternal(arc);
arc.ArchiveInteger(&numThreads);
arc.ArchiveInteger(&num);
for (j = 0; j < numThreads; j++) {
m_thread = new ScriptThread(scr, NULL);
m_thread->ArchiveInternal(arc);
c->m_Threads = NULL;
prevScriptVM = NULL;
for (j = 0; j < num; j++) {
scriptVM = new ScriptVM;
scriptVM->m_Thread = new ScriptThread;
scriptVM->m_Thread->m_ScriptVM = scriptVM;
scriptVM->m_ScriptClass = c;
scriptVM->next = NULL;
if (prevScriptVM) {
prevScriptVM->next = scriptVM;
} else {
c->m_Threads = scriptVM;
}
prevScriptVM = scriptVM;
scriptVM->m_Thread->ArchiveInternal(arc);
}
}
}
@@ -1184,7 +1199,7 @@ void ScriptMaster::PrintThread(int iThreadNum)
int i = 0;
for (entry = en.NextElement(); entry != NULL; entry = en.NextElement()) {
str& name = Director.GetString(entry->key);
str& name = Director.GetString(entry->GetKey());
if (i > 0) {
status += ", ";
+107 -75
View File
@@ -465,6 +465,15 @@ Event EV_ScriptSlave_FollowPath
"normalangles, loop, and a number specifying the start time.",
EV_NORMAL
);
Event EV_ScriptSlave_FollowPath_RelativeYaw(
"path_relativeyaw",
EV_DEFAULT,
"f"
"f",
"relativeYaw",
"Makes the script slave follow the specified path with a yaw offset,",
EV_NORMAL
);
Event EV_ScriptSlave_EndPath
(
"endpath",
@@ -584,72 +593,83 @@ Event EV_ScriptSlave_ModifyFlyPath
EV_NORMAL
);
CLASS_DECLARATION(Mover, ScriptSlave, "script_object") {
{&EV_Bind, &ScriptSlave::BindEvent },
{&EV_Unbind, &ScriptSlave::EventUnbind },
{&EV_ScriptSlave_DoMove, &ScriptSlave::DoMove },
{&EV_ScriptSlave_WaitMove, &ScriptSlave::WaitMove },
{&EV_ScriptSlave_Angles, &ScriptSlave::SetAnglesEvent },
{&EV_SetAngle, &ScriptSlave::SetAngleEvent },
{&EV_Model, &ScriptSlave::SetModelEvent },
{&EV_ScriptSlave_Trigger, &ScriptSlave::TriggerEvent },
{&EV_ScriptSlave_Next, &ScriptSlave::GotoNextWaypoint },
{&EV_ScriptSlave_JumpTo, &ScriptSlave::JumpTo },
{&EV_ScriptSlave_MoveTo, &ScriptSlave::MoveToEvent },
{&EV_ScriptSlave_Speed, &ScriptSlave::SetSpeed },
{&EV_ScriptSlave_Time, &ScriptSlave::SetTime },
{&EV_ScriptSlave_MoveUp, &ScriptSlave::MoveUp },
{&EV_ScriptSlave_MoveDown, &ScriptSlave::MoveDown },
{&EV_ScriptSlave_MoveNorth, &ScriptSlave::MoveNorth },
{&EV_ScriptSlave_MoveSouth, &ScriptSlave::MoveSouth },
{&EV_ScriptSlave_MoveEast, &ScriptSlave::MoveEast },
{&EV_ScriptSlave_MoveWest, &ScriptSlave::MoveWest },
{&EV_ScriptSlave_MoveForward, &ScriptSlave::MoveForward },
{&EV_ScriptSlave_MoveBackward, &ScriptSlave::MoveBackward },
{&EV_ScriptSlave_MoveLeft, &ScriptSlave::MoveLeft },
{&EV_ScriptSlave_MoveRight, &ScriptSlave::MoveRight },
{&EV_ScriptSlave_RotateXDownTo, &ScriptSlave::RotateXdownto },
{&EV_ScriptSlave_RotateYDownTo, &ScriptSlave::RotateYdownto },
{&EV_ScriptSlave_RotateZDownTo, &ScriptSlave::RotateZdownto },
{&EV_ScriptSlave_RotateXUpTo, &ScriptSlave::RotateXupto },
{&EV_ScriptSlave_RotateYUpTo, &ScriptSlave::RotateYupto },
{&EV_ScriptSlave_RotateZUpTo, &ScriptSlave::RotateZupto },
{&EV_ScriptSlave_RotateXDown, &ScriptSlave::RotateXdown },
{&EV_ScriptSlave_RotateYDown, &ScriptSlave::RotateYdown },
{&EV_ScriptSlave_RotateZDown, &ScriptSlave::RotateZdown },
{&EV_ScriptSlave_RotateXUp, &ScriptSlave::RotateXup },
{&EV_ScriptSlave_RotateYUp, &ScriptSlave::RotateYup },
{&EV_ScriptSlave_RotateZUp, &ScriptSlave::RotateZup },
{&EV_ScriptSlave_RotateX, &ScriptSlave::RotateX },
{&EV_ScriptSlave_RotateY, &ScriptSlave::RotateY },
{&EV_ScriptSlave_RotateZ, &ScriptSlave::RotateZ },
{&EV_ScriptSlave_RotateAxisDownTo, &ScriptSlave::RotateAxisdownto },
{&EV_ScriptSlave_RotateAxisUpTo, &ScriptSlave::RotateAxisupto },
{&EV_ScriptSlave_RotateAxisDown, &ScriptSlave::RotateAxisdown },
{&EV_ScriptSlave_RotateAxisUp, &ScriptSlave::RotateAxisup },
{&EV_ScriptSlave_RotateAxis, &ScriptSlave::RotateZ },
{&EV_ScriptSlave_SetDamage, &ScriptSlave::SetDamage },
{&EV_ScriptSlave_SetMeansOfDeath, &ScriptSlave::SetMeansOfDeath },
{&EV_ScriptSlave_SetDamageSpawn, &ScriptSlave::SetDamage },
{&EV_ScriptSlave_FollowPath, &ScriptSlave::FollowPath },
{&EV_ScriptSlave_EndPath, &ScriptSlave::EndPath },
{&EV_ScriptSlave_FollowingPath, &ScriptSlave::FollowingPath },
{&EV_ScriptSlave_MoveDone, &ScriptSlave::MoveEnd },
{&EV_Damage, &ScriptSlave::DamageFunc },
{&EV_ScriptSlave_RotateDownTo, &ScriptSlave::Rotatedownto },
{&EV_ScriptSlave_RotateUpTo, &ScriptSlave::Rotateupto },
{&EV_ScriptSlave_RotateTo, &ScriptSlave::Rotateto },
{&EV_ScriptSlave_Explode, &ScriptSlave::Explode },
{&EV_ScriptSlave_NotShootable, &ScriptSlave::NotShootable },
{&EV_ScriptSlave_OpenAreaPortal, &ScriptSlave::OpenPortal },
{&EV_ScriptSlave_CloseAreaPortal, &ScriptSlave::ClosePortal },
{&EV_ScriptSlave_PhysicsOn, &ScriptSlave::PhysicsOn },
{&EV_ScriptSlave_PhysicsOff, &ScriptSlave::PhysicsOff },
{&EV_ScriptSlave_PhysicsVelocity, &ScriptSlave::PhysicsVelocity },
{&EV_ScriptSlave_FlyPath, &ScriptSlave::EventFlyPath },
{&EV_ScriptSlave_ModifyFlyPath, &ScriptSlave::EventModifyFlyPath},
Event EV_ScriptSlave_NormalAngles
(
"normalangles",
EV_DEFAULT,
"b",
"bUseNormalAngles",
"Sets the object to use normal angles when travelling on a spline path",
EV_NORMAL
);
{NULL, NULL }
CLASS_DECLARATION(Mover, ScriptSlave, "script_object") {
{&EV_Bind, &ScriptSlave::BindEvent },
{&EV_Unbind, &ScriptSlave::EventUnbind },
{&EV_ScriptSlave_DoMove, &ScriptSlave::DoMove },
{&EV_ScriptSlave_WaitMove, &ScriptSlave::WaitMove },
{&EV_ScriptSlave_Angles, &ScriptSlave::SetAnglesEvent },
{&EV_SetAngle, &ScriptSlave::SetAngleEvent },
{&EV_Model, &ScriptSlave::SetModelEvent },
{&EV_ScriptSlave_Trigger, &ScriptSlave::TriggerEvent },
{&EV_ScriptSlave_Next, &ScriptSlave::GotoNextWaypoint },
{&EV_ScriptSlave_JumpTo, &ScriptSlave::JumpTo },
{&EV_ScriptSlave_MoveTo, &ScriptSlave::MoveToEvent },
{&EV_ScriptSlave_Speed, &ScriptSlave::SetSpeed },
{&EV_ScriptSlave_Time, &ScriptSlave::SetTime },
{&EV_ScriptSlave_MoveUp, &ScriptSlave::MoveUp },
{&EV_ScriptSlave_MoveDown, &ScriptSlave::MoveDown },
{&EV_ScriptSlave_MoveNorth, &ScriptSlave::MoveNorth },
{&EV_ScriptSlave_MoveSouth, &ScriptSlave::MoveSouth },
{&EV_ScriptSlave_MoveEast, &ScriptSlave::MoveEast },
{&EV_ScriptSlave_MoveWest, &ScriptSlave::MoveWest },
{&EV_ScriptSlave_MoveForward, &ScriptSlave::MoveForward },
{&EV_ScriptSlave_MoveBackward, &ScriptSlave::MoveBackward },
{&EV_ScriptSlave_MoveLeft, &ScriptSlave::MoveLeft },
{&EV_ScriptSlave_MoveRight, &ScriptSlave::MoveRight },
{&EV_ScriptSlave_RotateXDownTo, &ScriptSlave::RotateXdownto },
{&EV_ScriptSlave_RotateYDownTo, &ScriptSlave::RotateYdownto },
{&EV_ScriptSlave_RotateZDownTo, &ScriptSlave::RotateZdownto },
{&EV_ScriptSlave_RotateXUpTo, &ScriptSlave::RotateXupto },
{&EV_ScriptSlave_RotateYUpTo, &ScriptSlave::RotateYupto },
{&EV_ScriptSlave_RotateZUpTo, &ScriptSlave::RotateZupto },
{&EV_ScriptSlave_RotateXDown, &ScriptSlave::RotateXdown },
{&EV_ScriptSlave_RotateYDown, &ScriptSlave::RotateYdown },
{&EV_ScriptSlave_RotateZDown, &ScriptSlave::RotateZdown },
{&EV_ScriptSlave_RotateXUp, &ScriptSlave::RotateXup },
{&EV_ScriptSlave_RotateYUp, &ScriptSlave::RotateYup },
{&EV_ScriptSlave_RotateZUp, &ScriptSlave::RotateZup },
{&EV_ScriptSlave_RotateX, &ScriptSlave::RotateX },
{&EV_ScriptSlave_RotateY, &ScriptSlave::RotateY },
{&EV_ScriptSlave_RotateZ, &ScriptSlave::RotateZ },
{&EV_ScriptSlave_RotateAxisDownTo, &ScriptSlave::RotateAxisdownto },
{&EV_ScriptSlave_RotateAxisUpTo, &ScriptSlave::RotateAxisupto },
{&EV_ScriptSlave_RotateAxisDown, &ScriptSlave::RotateAxisdown },
{&EV_ScriptSlave_RotateAxisUp, &ScriptSlave::RotateAxisup },
{&EV_ScriptSlave_RotateAxis, &ScriptSlave::RotateZ },
{&EV_ScriptSlave_SetDamage, &ScriptSlave::SetDamage },
{&EV_ScriptSlave_SetMeansOfDeath, &ScriptSlave::SetMeansOfDeath },
{&EV_ScriptSlave_SetDamageSpawn, &ScriptSlave::SetDamage },
{&EV_ScriptSlave_FollowPath, &ScriptSlave::FollowPath },
{&EV_ScriptSlave_FollowPath_RelativeYaw, &ScriptSlave::FollowPathRelativeYaw},
{&EV_ScriptSlave_EndPath, &ScriptSlave::EndPath },
{&EV_ScriptSlave_FollowingPath, &ScriptSlave::FollowingPath },
{&EV_ScriptSlave_MoveDone, &ScriptSlave::MoveEnd },
{&EV_Damage, &ScriptSlave::DamageFunc },
{&EV_ScriptSlave_RotateDownTo, &ScriptSlave::Rotatedownto },
{&EV_ScriptSlave_RotateUpTo, &ScriptSlave::Rotateupto },
{&EV_ScriptSlave_RotateTo, &ScriptSlave::Rotateto },
{&EV_ScriptSlave_Explode, &ScriptSlave::Explode },
{&EV_ScriptSlave_NotShootable, &ScriptSlave::NotShootable },
{&EV_ScriptSlave_OpenAreaPortal, &ScriptSlave::OpenPortal },
{&EV_ScriptSlave_CloseAreaPortal, &ScriptSlave::ClosePortal },
{&EV_ScriptSlave_PhysicsOn, &ScriptSlave::PhysicsOn },
{&EV_ScriptSlave_PhysicsOff, &ScriptSlave::PhysicsOff },
{&EV_ScriptSlave_PhysicsVelocity, &ScriptSlave::PhysicsVelocity },
{&EV_ScriptSlave_FlyPath, &ScriptSlave::EventFlyPath },
{&EV_ScriptSlave_ModifyFlyPath, &ScriptSlave::EventModifyFlyPath },
{&EV_ScriptSlave_NormalAngles, &ScriptSlave::EventNormalAngles },
{NULL, NULL }
};
cvar_t *g_showflypath;
@@ -689,16 +709,17 @@ ScriptSlave::ScriptSlave()
edict->s.renderfx = RF_ALWAYSDRAW;
}
splinePath = NULL;
m_pCurPath = NULL;
m_iCurNode = 0;
m_fLookAhead = 0;
m_fCurSpeed = 0;
m_fIdealSpeed = 0;
m_fIdealAccel = 0;
m_fIdealDistance = 100;
splineangles = false;
attack_finished = 0;
splinePath = NULL;
m_pCurPath = NULL;
m_iCurNode = 0;
m_fLookAhead = 0;
m_fCurSpeed = 0;
m_fIdealSpeed = 0;
m_fIdealAccel = 0;
m_fIdealDistance = 100;
splineangles = false;
m_fFollowRelativeYaw = 0;
attack_finished = 0;
setSolidType(SOLID_NOT);
@@ -1367,6 +1388,11 @@ void ScriptSlave::FollowPath(Event *ev)
}
}
void ScriptSlave::FollowPathRelativeYaw(Event *ev)
{
m_fFollowRelativeYaw = ev->GetFloat(1);
}
void ScriptSlave::EndPath(Event *ev)
{
if (!splinePath) {
@@ -1723,6 +1749,12 @@ void ScriptSlave::EventModifyFlyPath(Event *ev)
}
}
void ScriptSlave::EventNormalAngles(Event *ev)
{
splineangles = !ev->GetBoolean(1);
ignoreangles = false;
}
void ScriptSlave::SetupPath(cSpline<4, 512> *pPath, SimpleEntity *se)
{
str name;
+13
View File
@@ -77,6 +77,7 @@ public:
qboolean splineangles;
qboolean ignoreangles;
qboolean ignorevelocity;
float m_fFollowRelativeYaw;
qboolean moving; // is the script object currently moving?
protected:
@@ -138,6 +139,7 @@ protected:
void SetDamage(Event *ev);
void SetMeansOfDeath(Event *ev);
void FollowPath(Event *ev);
void FollowPathRelativeYaw(Event *ev); // Added in 2.0
void EndPath(Event *ev);
void FollowingPath(Event *ev);
void CreatePath(SplinePath *path, splinetype_t type);
@@ -151,6 +153,7 @@ protected:
void DamageFunc(Event *ev);
void EventFlyPath(Event *ev);
void EventModifyFlyPath(Event *ev);
void EventNormalAngles(Event *ev); // Added in 2.0
void SetupPath(cSpline<4, 512> *pPath, SimpleEntity *se);
void Archive(Archiver& arc) override;
@@ -220,6 +223,16 @@ inline void ScriptSlave::Archive(Archiver& arc)
m_pCurPath = NULL;
}
}
arc.ArchiveInteger(&m_iCurNode);
arc.ArchiveFloat(&m_fCurSpeed);
arc.ArchiveFloat(&m_fIdealSpeed);
arc.ArchiveVector(&m_vIdealPosition);
arc.ArchiveVector(&m_vIdealDir);
arc.ArchiveFloat(&m_fIdealAccel);
arc.ArchiveFloat(&m_fIdealDistance);
arc.ArchiveFloat(&m_fLookAhead);
arc.ArchiveFloat(&m_fFollowRelativeYaw);
}
class ScriptModel : public ScriptSlave
+12 -5
View File
@@ -3576,13 +3576,20 @@ void ScriptThread::Angles_PointAt(Event *ev)
void ScriptThread::EventIsAlive(Event *ev)
{
Entity *ent = ev->GetEntity(1);
Entity* ent;
if (ent) {
ev->AddInteger(!ent->IsDead());
} else {
ev->AddInteger(0);
if (!ev->IsEntityAt(1)) {
ev->AddInteger(false);
return;
}
ent = ev->GetEntity(1);
if (!ent) {
ev->AddInteger(false);
return;
}
ev->AddInteger(ent->health > 0);
}
void ScriptThread::EventPopmenu(Event *ev)
+7 -2
View File
@@ -693,7 +693,7 @@ Sentient::Sentient()
: m_bIsAnimal(false)
{
SentientList.AddObject((Sentient *)this);
entflags |= EF_SENTIENT;
entflags |= ECF_SENTIENT;
m_bOvercookDied = false;
@@ -824,7 +824,7 @@ Sentient::~Sentient()
SentientList.RemoveObject((Sentient *)this);
FreeInventory();
entflags &= ~EF_SENTIENT;
entflags &= ~ECF_SENTIENT;
}
void Sentient::Link()
@@ -2128,6 +2128,11 @@ void Sentient::Archive(Archiver& arc)
Holster(true);
}
}
//
// Openmohaa additions
//
arc.ArchiveInteger(&iNextLandTime);
}
static bool IsItemName(const char *name)
+3
View File
@@ -219,6 +219,9 @@ public:
bool m_bFootOnGround_Right;
bool m_bFootOnGround_Left;
//
// Openmohaa additions
//
int iNextLandTime;
CLASS_PROTOTYPE(Sentient);
+22 -22
View File
@@ -253,112 +253,112 @@ SimpleEntity::~SimpleEntity()
int SimpleEntity::IsSubclassOfEntity(void) const
{
return (entflags & EF_ENTITY);
return (entflags & ECF_ENTITY);
}
int SimpleEntity::IsSubclassOfAnimate(void) const
{
return (entflags & EF_ANIMATE);
return (entflags & ECF_ANIMATE);
}
int SimpleEntity::IsSubclassOfSentient(void) const
{
return (entflags & EF_SENTIENT);
return (entflags & ECF_SENTIENT);
}
int SimpleEntity::IsSubclassOfPlayer(void) const
{
return (entflags & EF_PLAYER);
return (entflags & ECF_PLAYER);
}
int SimpleEntity::IsSubclassOfActor(void) const
{
return (entflags & EF_ACTOR);
return (entflags & ECF_ACTOR);
}
int SimpleEntity::IsSubclassOfItem(void) const
{
return (entflags & EF_ITEM);
return (entflags & ECF_ITEM);
}
int SimpleEntity::IsSubclassOfInventoryItem(void) const
{
return (entflags & EF_INVENTORYITEM);
return (entflags & ECF_INVENTORYITEM);
}
int SimpleEntity::IsSubclassOfWeapon(void) const
{
return (entflags & EF_WEAPON);
return (entflags & ECF_WEAPON);
}
int SimpleEntity::IsSubclassOfProjectile(void) const
{
return (entflags & EF_PROJECTILE);
return (entflags & ECF_PROJECTILE);
}
int SimpleEntity::IsSubclassOfDoor(void) const
{
return (entflags & EF_DOOR);
return (entflags & ECF_DOOR);
}
int SimpleEntity::IsSubclassOfCamera(void) const
{
return (entflags & EF_CAMERA);
return (entflags & ECF_CAMERA);
}
int SimpleEntity::IsSubclassOfVehicle(void) const
{
return (entflags & EF_VEHICLE);
return (entflags & ECF_VEHICLE);
}
int SimpleEntity::IsSubclassOfVehicleTank(void) const
{
return (entflags & EF_VEHICLETANK);
return (entflags & ECF_VEHICLETANK);
}
int SimpleEntity::IsSubclassOfVehicleTurretGun(void) const
{
return (entflags & EF_VEHICLETURRET);
return (entflags & ECF_VEHICLETURRET);
}
int SimpleEntity::IsSubclassOfTurretGun(void) const
{
return (entflags & EF_TURRET);
return (entflags & ECF_TURRET);
}
int SimpleEntity::IsSubclassOfPathNode(void) const
{
return (entflags & EF_PATHNODE);
return (entflags & ECF_PATHNODE);
}
int SimpleEntity::IsSubclassOfWaypoint(void) const
{
return (entflags & EF_WAYPOINT);
return (entflags & ECF_WAYPOINT);
}
int SimpleEntity::IsSubclassOfTempWaypoint(void) const
{
return (entflags & EF_TEMPWAYPOINT);
return (entflags & ECF_TEMPWAYPOINT);
}
int SimpleEntity::IsSubclassOfVehiclePoint(void) const
{
return (entflags & EF_VEHICLEPOINT);
return (entflags & ECF_VEHICLEPOINT);
}
int SimpleEntity::IsSubclassOfSplinePath(void) const
{
return (entflags & EF_SPLINEPATH);
return (entflags & ECF_SPLINEPATH);
}
int SimpleEntity::IsSubclassOfCrateObject(void) const
{
return (entflags & EF_CRATEOBJECT);
return (entflags & ECF_CRATEOBJECT);
}
int SimpleEntity::IsSubclassOfBot(void) const
{
return (entflags & EF_BOT);
return (entflags & ECF_BOT);
}
void SimpleEntity::SetTargetName(str targetname)
+1 -1
View File
@@ -64,7 +64,7 @@ void cSpline<cGrids, cPoints>::Archive(Archiver& arc)
arc.ArchiveInteger(&m_iPoints);
for (int i = 0; i < cPoints; i++) {
for (int j = 0; i < cGrids; i++) {
for (int j = 0; j < cGrids; j++) {
arc.ArchiveFloat(&m_vPoints[i][j]);
}
+1
View File
@@ -810,6 +810,7 @@ void Trigger::Archive(Archiver& arc)
SetNoise(Director.GetString(noise).c_str());
}
Director.ArchiveString(arc, message);
m_Thread.Archive(arc);
arc.ArchiveSafePointer(&activator);
arc.ArchiveInteger(&respondto);
arc.ArchiveBoolean(&useTriggerDir);
+2 -2
View File
@@ -960,7 +960,7 @@ Vehicle::Vehicle()
{
int i;
entflags |= EF_VEHICLE;
entflags |= ECF_VEHICLE;
AddWaitTill(STRING_DRIVE);
AddWaitTill(STRING_VEHICLEANIMDONE);
@@ -1204,7 +1204,7 @@ Vehicle::~Vehicle()
m_pCollisionEntity->ProcessEvent(EV_Remove);
}
entflags &= ~EF_VEHICLE;
entflags &= ~ECF_VEHICLE;
}
/*
+2 -2
View File
@@ -210,7 +210,7 @@ CLASS_DECLARATION(TurretGun, VehicleTurretGun, NULL) {
VehicleTurretGun::VehicleTurretGun()
{
entflags |= EF_VEHICLETURRET;
entflags |= ECF_VEHICLETURRET;
AddWaitTill(STRING_DEATH);
@@ -300,7 +300,7 @@ VehicleTurretGun::~VehicleTurretGun()
m_pCollisionEntity->PostEvent(EV_Remove, 0);
}
entflags &= ~EF_VEHICLETURRET;
entflags &= ~ECF_VEHICLETURRET;
}
void VehicleTurretGun::Think(void)
+3 -3
View File
@@ -974,7 +974,7 @@ CLASS_DECLARATION(Item, Weapon, NULL) {
//======================
Weapon::Weapon()
{
entflags |= EF_WEAPON;
entflags |= ECF_WEAPON;
mAIRange = RANGE_SHORT;
@@ -1192,7 +1192,7 @@ Weapon::~Weapon()
RemoveFromOwner();
}
entflags &= ~EF_WEAPON;
entflags &= ~ECF_WEAPON;
}
//======================
@@ -4373,7 +4373,7 @@ const_str Weapon::GetWeaponGroup(void) const
//======================
void Weapon::SetItemSlot(int slot)
{
weapon_class &= WEAPON_CLASS_ITEM_SLOT_BITS;
weapon_class &= ~WEAPON_CLASS_ITEM_SLOT_BITS;
weapon_class |= slot & WEAPON_CLASS_ITEM_SLOT_BITS;
}
+1
View File
@@ -590,6 +590,7 @@ inline void Weapon::Archive(Archiver& arc)
ArchiveEnum(firemodeindex, firemode_t);
arc.ArchiveInteger(&weapon_class);
Director.ArchiveString(arc, m_csWeaponGroup);
arc.ArchiveFloat(&m_fMovementSpeed);
arc.ArchiveFloat(&m_fMaxFireMovement);
+21 -4
View File
@@ -394,7 +394,7 @@ CLASS_DECLARATION(Weapon, TurretGun, NULL) {
TurretGun::TurretGun()
{
entflags |= EF_TURRET;
entflags |= ECF_TURRET;
AddWaitTill(STRING_ONTARGET);
@@ -501,11 +501,28 @@ TurretGun::~TurretGun()
// Remove the user camera if any.
//
if (m_pUserCamera) {
m_pUserCamera->PostEvent(EV_Remove, 0);
m_pUserCamera = NULL;
RemoveUserCamera();
}
entflags &= ~EF_TURRET;
//
// Added in OPM:
// Remove the view model.
//
if (m_pViewModel) {
m_pViewModel->Delete();
m_pViewModel = NULL;
}
//
// Added in OPM:
// Detach the owner from the turret.
//
if (owner && owner->IsSubclassOfPlayer()) {
Player *player = static_cast<Player *>(owner.Pointer());
player->ExitTurret();
}
entflags &= ~ECF_TURRET;
}
void TurretGun::PlaceTurret(Event *ev)
+2 -2
View File
@@ -595,7 +595,7 @@ CLASS_DECLARATION(Animate, Projectile, NULL) {
Projectile::Projectile()
{
entflags |= EF_PROJECTILE;
entflags |= ECF_PROJECTILE;
if (LoadingSavegame) {
// Archive function will setup all necessary data
@@ -2496,7 +2496,7 @@ float BulletAttack(
gi.MSG_WriteBits(count, 6);
for (int i = count; i > 0; i--) {
for (int i = 0; i < count; i++) {
gi.MSG_WriteCoord(vEndArray[i][0]);
gi.MSG_WriteCoord(vEndArray[i][1]);
gi.MSG_WriteCoord(vEndArray[i][2]);
+98 -107
View File
@@ -29,162 +29,153 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Event EV_Window_Setup
(
"_Windowsetup",
EV_CODEONLY,
NULL,
NULL,
"Does the post spawn setup of the Window"
"_Windowsetup",
EV_CODEONLY,
NULL,
NULL,
"Does the post spawn setup of the Window"
);
Event EV_Window_SetDebris
(
"debristype",
EV_DEFAULT,
"i",
"type",
"Sets the debris type of the Window"
"debristype",
EV_DEFAULT,
"i",
"type",
"Sets the debris type of the Window"
);
CLASS_DECLARATION( Entity, WindowObject, "func_window" )
{
{ &EV_Window_Setup, &WindowObject::WindowSetup },
{ &EV_Damage, &WindowObject::WindowDamaged },
{ &EV_Killed, &WindowObject::WindowKilled },
{ &EV_Window_SetDebris, &WindowObject::WindowDebrisType },
{ NULL, NULL }
CLASS_DECLARATION(Entity, WindowObject, "func_window") {
{&EV_Window_Setup, &WindowObject::WindowSetup },
{&EV_Damage, &WindowObject::WindowDamaged },
{&EV_Killed, &WindowObject::WindowKilled },
{&EV_Window_SetDebris, &WindowObject::WindowDebrisType},
{NULL, NULL }
};
WindowObject::WindowObject()
{
m_iDebrisType = WINDOW_GLASS;
m_iDebrisType = WINDOW_GLASS;
PostEvent( EV_Window_Setup, EV_POSTSPAWN );
PostEvent(EV_Window_Setup, EV_POSTSPAWN);
}
void WindowObject::Archive( Archiver& arc )
void WindowObject::Archive(Archiver& arc)
{
arc.ArchiveInteger( &m_iDebrisType );
arc.ArchiveString( &m_sBrokenModel );
Entity::Archive(arc);
arc.ArchiveInteger(&m_iDebrisType);
arc.ArchiveString(&m_sBrokenModel);
}
void WindowObject::WindowSetup( Event *ev )
void WindowObject::WindowSetup(Event *ev)
{
Entity *pEnt;
Entity *pEnt;
setSolidType( SOLID_BSP );
setSolidType(SOLID_BSP);
if( Target().length() )
{
pEnt = ( Entity * )G_FindTarget( NULL, Target() );
if (Target().length()) {
pEnt = (Entity *)G_FindTarget(NULL, Target());
if( pEnt )
{
// set the broken model to the target model
m_sBrokenModel = pEnt->model;
if (pEnt) {
// set the broken model to the target model
m_sBrokenModel = pEnt->model;
pEnt->PostEvent( EV_Remove, 0 );
}
}
pEnt->PostEvent(EV_Remove, 0);
}
}
takedamage = DAMAGE_YES;
takedamage = DAMAGE_YES;
if( health <= 0.1f ) {
health = 100.0f;
}
if (health <= 0.1f) {
health = 100.0f;
}
}
void WindowObject::WindowDebrisType( Event *ev )
void WindowObject::WindowDebrisType(Event *ev)
{
m_iDebrisType = ev->GetInteger( 1 );
m_iDebrisType = ev->GetInteger(1);
}
void WindowObject::WindowDamaged( Event *ev )
void WindowObject::WindowDamaged(Event *ev)
{
int iMeansOfDeath;
int iDamage;
Vector vRight;
Vector vForward;
Vector vDir;
Event *event;
int iMeansOfDeath;
int iDamage;
Vector vRight;
Vector vForward;
Vector vDir;
Event *event;
if( !takedamage ) {
return;
}
if (!takedamage) {
return;
}
iDamage = ev->GetInteger( 2 );
iMeansOfDeath = ev->GetInteger( 9 );
iDamage = ev->GetInteger(2);
iMeansOfDeath = ev->GetInteger(9);
if( iMeansOfDeath == MOD_BASH )
{
// double damage for bash
iDamage *= 2;
}
else if( iMeansOfDeath == MOD_EXPLOSION )
{
// instant break
iDamage = health;
}
if (iMeansOfDeath == MOD_BASH) {
// double damage for bash
iDamage *= 2;
} else if (iMeansOfDeath == MOD_EXPLOSION) {
// instant break
iDamage = health;
}
health -= iDamage;
health -= iDamage;
if( health <= 0.0f )
{
event = new Event( EV_Killed );
if (health <= 0.0f) {
event = new Event(EV_Killed);
event->AddEntity( ev->GetEntity( 1 ) );
event->AddInteger( ev->GetInteger( 2 ) );
event->AddEntity( ev->GetEntity( 3 ) );
event->AddEntity(ev->GetEntity(1));
event->AddInteger(ev->GetInteger(2));
event->AddEntity(ev->GetEntity(3));
ProcessEvent( event );
}
ProcessEvent(event);
}
}
void WindowObject::WindowKilled( Event *ev )
void WindowObject::WindowKilled(Event *ev)
{
Vector vCenter;
Vector vCenter;
setSolidType( SOLID_NOT );
setSolidType(SOLID_NOT);
hideModel();
takedamage = DAMAGE_NO;
hideModel();
takedamage = DAMAGE_NO;
vCenter = origin + mins + maxs;
vCenter = origin + mins + maxs;
gi.SetBroadcastVisible( vCenter, vCenter );
gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_WINDOW_DEBRIS));
gi.MSG_WriteCoord( vCenter[ 0 ] );
gi.MSG_WriteCoord( vCenter[ 1 ] );
gi.MSG_WriteCoord( vCenter[ 2 ] );
gi.MSG_WriteByte( m_iDebrisType );
gi.MSG_EndCGM();
gi.SetBroadcastVisible(vCenter, vCenter);
gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_WINDOW_DEBRIS));
gi.MSG_WriteCoord(vCenter[0]);
gi.MSG_WriteCoord(vCenter[1]);
gi.MSG_WriteCoord(vCenter[2]);
gi.MSG_WriteByte(m_iDebrisType);
gi.MSG_EndCGM();
if( m_sBrokenModel.length() )
{
Entity *ent = new Entity;
if (m_sBrokenModel.length()) {
Entity *ent = new Entity;
ent->takedamage = DAMAGE_NO;
ent->setModel( m_sBrokenModel );
ent->takedamage = DAMAGE_NO;
ent->setModel(m_sBrokenModel);
ent->setMoveType( MOVETYPE_NONE );
ent->setSolidType( SOLID_BSP );
ent->setMoveType(MOVETYPE_NONE);
ent->setSolidType(SOLID_BSP);
setModel( m_sBrokenModel );
setModel(m_sBrokenModel);
if( spawnflags & WINDOW_BROKEN_BLOCK )
{
ent->setContents( CONTENTS_MONSTERCLIP | CONTENTS_PLAYERCLIP );
}
else
{
ent->setContents( CONTENTS_SHOOTONLY );
}
if (spawnflags & WINDOW_BROKEN_BLOCK) {
ent->setContents(CONTENTS_MONSTERCLIP | CONTENTS_PLAYERCLIP);
} else {
ent->setContents(CONTENTS_SHOOTONLY);
}
ent->setOrigin( origin );
ent->showModel();
}
ent->setOrigin(origin);
ent->showModel();
}
deadflag = DEAD_DEAD;
deadflag = DEAD_DEAD;
// remove the window
PostEvent( EV_Remove, 0 );
// remove the window
PostEvent(EV_Remove, 0);
}
+16 -14
View File
@@ -23,29 +23,31 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// windows.h: Window class
//
#pragma once
#include "entity.h"
#define WINDOW_BROKEN_BLOCK 1
#define WINDOW_BROKEN_BLOCK 1
enum
{
WINDOW_GLASS
enum {
WINDOW_GLASS
};
class WindowObject : public Entity {
class WindowObject : public Entity
{
private:
int m_iDebrisType;
str m_sBrokenModel;
int m_iDebrisType;
str m_sBrokenModel;
public:
CLASS_PROTOTYPE( WindowObject );
CLASS_PROTOTYPE(WindowObject);
WindowObject();
WindowObject();
void Archive( Archiver& arc ) override;
void Archive(Archiver& arc) override;
void WindowSetup( Event *ev );
void WindowDebrisType( Event *ev );
void WindowDamaged( Event *ev );
void WindowKilled( Event *ev );
void WindowSetup(Event *ev);
void WindowDebrisType(Event *ev);
void WindowDamaged(Event *ev);
void WindowKilled(Event *ev);
};
+2 -2
View File
@@ -479,7 +479,7 @@ CM_WritePortalState
void CM_WritePortalState( fileHandle_t f )
{
FS_Write( &cm.numAreas, sizeof( int ), f );
FS_Write( &cm.areaPortals, cm.numAreas * cm.numAreas * sizeof( *cm.areaPortals ), f );
FS_Write( cm.areaPortals, cm.numAreas * cm.numAreas * sizeof( *cm.areaPortals ), f );
}
/*
@@ -494,7 +494,7 @@ void CM_ReadPortalState( fileHandle_t f )
if (numareaportals != cm.numAreas) {
Com_Error(ERR_DROP, "numareaportals differs from save game");
}
FS_Read(&cm.areaPortals, cm.numAreas * cm.numAreas * sizeof(*cm.areaPortals), f);
FS_Read(cm.areaPortals, cm.numAreas * cm.numAreas * sizeof(*cm.areaPortals), f);
CM_FloodAreaConnections();
}
+87 -55
View File
@@ -29,6 +29,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class Class;
class Archiver;
template<typename k, typename v>
class con_set;
template<typename key, typename value>
class con_map;
template<typename key, typename value>
class con_map_enum;
@@ -45,30 +51,51 @@ struct con_set_is_pointer<T *> {
static const bool con_value = true;
};
/**
* This class was originally inside con_set (con_set::Entry).
* But because GCC is being extremely annoying and is moaning
* because of specialization after instantiation,
* the class is now laying there.
*/
template<typename k, typename v>
class con_set_Entry
{
friend con_set<k, v>;
friend con_set_enum<k, v>;
private:
con_set_Entry *next;
k key;
public:
v value;
public:
void *operator new(size_t size) { return con_set<k, v>::NewEntry(size); }
void operator delete(void *ptr) { con_set<k, v>::DeleteEntry(ptr); }
con_set_Entry()
: key(k())
, value(v())
, next(NULL)
{}
#ifdef ARCHIVE_SUPPORTED
void Archive(Archiver& arc);
#endif
k& GetKey() { return key; }
void SetKey(const k& newKey) { key = newKey; }
};
template<typename k, typename v>
class con_set
{
friend class con_set_enum<k, v>;
public:
class Entry
{
public:
k key;
v value;
Entry *next;
public:
void *operator new(size_t size);
void operator delete(void *ptr);
Entry();
#ifdef ARCHIVE_SUPPORTED
void Archive(Archiver& arc);
#endif
};
using Entry = con_set_Entry<k, v>;
public:
static MEM_BlockAlloc<Entry> Entry_allocator;
@@ -86,6 +113,10 @@ protected:
Entry *addKeyEntry(const k& key);
Entry *addNewKeyEntry(const k& key);
public:
static void *NewEntry(size_t size);
static void DeleteEntry(void *entry);
public:
con_set();
~con_set();
@@ -113,29 +144,20 @@ public:
template<typename k, typename v>
MEM_BlockAlloc<typename con_set<k, v>::Entry> con_set<k, v>::Entry_allocator;
template<typename k>
int HashCode(const k& key);
template<typename k, typename v>
void *con_set<k, v>::Entry::operator new(size_t size)
void *con_set<k, v>::NewEntry(size_t size)
{
return Entry_allocator.Alloc();
}
template<typename k, typename v>
void con_set<k, v>::Entry::operator delete(void *ptr)
void con_set<k, v>::DeleteEntry(void *entry)
{
Entry_allocator.Free(ptr);
Entry_allocator.Free(entry);
}
template<typename k, typename v>
con_set<k, v>::Entry::Entry()
{
this->key = k();
this->value = v();
next = NULL;
}
template<typename k>
int HashCode(const k& key);
template<typename key, typename value>
con_set<key, value>::con_set()
@@ -217,7 +239,7 @@ void con_set<key, value>::resize(int count)
old = e->next;
// insert the old entry to the table hashindex
index = HashCode<key>(e->key) % tableLength;
index = HashCode<key>(e->GetKey()) % tableLength;
e->next = table[index];
table[index] = e;
@@ -238,7 +260,7 @@ typename con_set<k, v>::Entry *con_set<k, v>::findKeyEntry(const k& key) const
entry = table[HashCode<k>(key) % tableLength];
for (; entry != NULL; entry = entry->next) {
if (entry->key == key) {
if (entry->GetKey() == key) {
return entry;
}
}
@@ -264,28 +286,25 @@ template<typename k, typename v>
typename con_set<k, v>::Entry *con_set<k, v>::addNewKeyEntry(const k& key)
{
Entry *entry;
int index;
int hash;
if (count >= threshold) {
resize();
}
index = HashCode<k>(key) % tableLength;
count++;
entry = new Entry;
entry->SetKey(key);
hash = HashCode<k>(entry->GetKey()) % tableLength;
if (defaultEntry == NULL) {
defaultEntry = entry;
entry->next = NULL;
} else {
entry->next = table[index];
entry->next = table[hash];
}
entry->key = key;
table[index] = entry;
table[hash] = entry;
return entry;
}
@@ -299,25 +318,38 @@ bool con_set<key, value>::isEmpty(void)
template<typename k, typename v>
bool con_set<k, v>::remove(const k& key)
{
int index = HashCode<k>(key) % tableLength;
Entry *prev = NULL;
Entry *entry;
int hash;
int i;
Entry *prev = NULL;
Entry *entry, *e;
for (entry = table[index]; entry != NULL; entry = entry->next) {
// just to make sure we're using the correct overloaded operator
if (!(entry->key == key)) {
hash = HashCode<k>(key) % tableLength;
for (entry = table[hash]; entry != NULL; entry = entry->next) {
// just to make sure we're using the correct overloaded operator for the key
if (!(entry->GetKey() == key)) {
prev = entry;
continue;
}
if (defaultEntry == entry) {
defaultEntry = prev;
defaultEntry = prev ? prev : table[hash];
// find a default entry
for (i = 0; i < tableLength && !defaultEntry; i++) {
for (e = table[i]; e; e = e->next) {
if (e == entry) {
continue;
}
defaultEntry = e;
break;
}
}
}
if (prev) {
prev->next = entry->next;
} else {
table[index] = entry->next;
table[hash] = entry->next;
}
count--;
@@ -345,7 +377,7 @@ template<typename key, typename value>
key *con_set<key, value>::firstKeyValue(void)
{
if (defaultEntry) {
return &defaultEntry->key;
return &defaultEntry->GetKey();
} else {
return NULL;
}
@@ -373,7 +405,7 @@ bool con_set<k, v>::keyExists(const k& key)
Entry *entry;
for (entry = table; entry != NULL; entry = entry->next) {
if (entry->key == key) {
if (entry->GetKey() == key) {
return true;
}
}
@@ -491,7 +523,7 @@ public:
value& operator[](const key& index);
value *find(const key& index);
bool remove(const key &index);
bool remove(const key& index);
unsigned int size();
};
@@ -582,7 +614,7 @@ key *con_map_enum<key, value>::CurrentKey(void)
Entry *entry = m_Set_Enum.CurrentElement();
if (entry) {
return &entry->key;
return &entry->GetKey();
} else {
return NULL;
}
@@ -606,7 +638,7 @@ key *con_map_enum<key, value>::NextKey(void)
Entry *entry = m_Set_Enum.NextElement();
if (entry) {
return &entry->key;
return &entry->GetKey();
} else {
return NULL;
}
+2 -2
View File
@@ -3204,7 +3204,7 @@ void Listener::CancelWaitingAll()
ConList stoppedListeners;
for (e = en.NextElement(); e != NULL; e = en.NextElement()) {
CancelWaitingSources(e->key, e->value, stoppedListeners);
CancelWaitingSources(e->GetKey(), e->value, stoppedListeners);
}
delete m_WaitForList;
@@ -3504,7 +3504,7 @@ void Listener::UnregisterAll(void)
en = *m_NotifyList;
for (e = en.NextElement(); e != NULL; e = en.NextElement()) {
UnregisterTargets(e->key, e->value, stoppedListeners, stoppedNames);
UnregisterTargets(e->GetKey(), e->value, stoppedListeners, stoppedNames);
}
delete m_NotifyList;
+22 -22
View File
@@ -42,28 +42,28 @@ class Archiver;
class EventQueueNode;
// entity subclass
#define EF_ENTITY (1 << 0)
#define EF_ANIMATE (1 << 1)
#define EF_SENTIENT (1 << 2)
#define EF_PLAYER (1 << 3)
#define EF_ACTOR (1 << 4)
#define EF_ITEM (1 << 5)
#define EF_INVENTORYITEM (1 << 6)
#define EF_WEAPON (1 << 7)
#define EF_PROJECTILE (1 << 8)
#define EF_DOOR (1 << 9)
#define EF_CAMERA (1 << 10)
#define EF_VEHICLE (1 << 11)
#define EF_VEHICLETANK (1 << 12)
#define EF_VEHICLETURRET (1 << 13)
#define EF_TURRET (1 << 14)
#define EF_PATHNODE (1 << 15)
#define EF_WAYPOINT (1 << 16)
#define EF_TEMPWAYPOINT (1 << 17)
#define EF_VEHICLEPOINT (1 << 18)
#define EF_SPLINEPATH (1 << 19)
#define EF_CRATEOBJECT (1 << 20)
#define EF_BOT (1 << 21)
#define ECF_ENTITY (1 << 0)
#define ECF_ANIMATE (1 << 1)
#define ECF_SENTIENT (1 << 2)
#define ECF_PLAYER (1 << 3)
#define ECF_ACTOR (1 << 4)
#define ECF_ITEM (1 << 5)
#define ECF_INVENTORYITEM (1 << 6)
#define ECF_WEAPON (1 << 7)
#define ECF_PROJECTILE (1 << 8)
#define ECF_DOOR (1 << 9)
#define ECF_CAMERA (1 << 10)
#define ECF_VEHICLE (1 << 11)
#define ECF_VEHICLETANK (1 << 12)
#define ECF_VEHICLETURRET (1 << 13)
#define ECF_TURRET (1 << 14)
#define ECF_PATHNODE (1 << 15)
#define ECF_WAYPOINT (1 << 16)
#define ECF_TEMPWAYPOINT (1 << 17)
#define ECF_VEHICLEPOINT (1 << 18)
#define ECF_SPLINEPATH (1 << 19)
#define ECF_CRATEOBJECT (1 << 20)
#define ECF_BOT (1 << 21)
// Event flags
#define EV_CONSOLE (1 << 0) // Allow entry from console
+2
View File
@@ -1453,6 +1453,8 @@ typedef struct {
// trace->entityNum can also be 0 to (MAX_GENTITIES-1)
// or ENTITYNUM_NONE, ENTITYNUM_WORLD
#define SAVEGAME_STRUCT_VERSION 4
typedef struct {
int version;
int time;
+1 -1
View File
@@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// These values are the only one that must be set for the version
#define PRODUCT_VERSION_MAJOR 0
#define PRODUCT_VERSION_MINOR 60
#define PRODUCT_VERSION_PATCH 0
#define PRODUCT_VERSION_PATCH 2
#define PRODUCT_VERSION_SUFFIX "alpha"
//
+2 -14
View File
@@ -1,6 +1,6 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
Copyright (C) 2023 the OpenMoHAA team
This file is part of OpenMoHAA source code.
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "scriptvariable.h"
#include "scriptexception.h"
#include "../qcommon/str.h"
#include "../qcommon/con_set.h"
#ifdef GAME_DLL
# include "../fgame/archive.h"
@@ -77,19 +78,6 @@ void con_set<ScriptVariable, ScriptVariable>::Entry::Archive(Archiver& arc)
value.ArchiveInternal(arc);
}
template<>
void con_set<short3, ScriptVariable>::Entry::Archive(Archiver& arc)
{
if (arc.Loading()) {
value.Archive(arc);
# ifdef WITH_SCRIPT_ENGINE
key = value.GetKey();
# endif
} else {
value.Archive(arc);
}
}
void ScriptArrayHolder::Archive(Archiver& arc)
{
arc.ArchiveUnsigned(&refCount);
+43 -19
View File
@@ -1,6 +1,6 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
Copyright (C) 2023 the OpenMoHAA team
This file is part of OpenMoHAA source code.
@@ -64,7 +64,8 @@ static const char *typenames[] = {
"array",
"pointer",
"vector",
"double"};
"double"
};
class ScriptArrayHolder;
class ScriptConstArrayHolder;
@@ -110,9 +111,9 @@ public:
~ScriptVariable();
void Archive(Archiver &arc);
void Archive(Archiver& arc);
static void Archive(Archiver& arc, ScriptVariable **obj);
void ArchiveInternal(Archiver &arc);
void ArchiveInternal(Archiver& arc);
void CastBoolean(void);
void CastConstArrayValue(void);
@@ -152,7 +153,7 @@ public:
str& getName(void);
short3& GetKey();
void SetKey(const short3 &key);
void SetKey(const short3& key);
#endif
Entity *entityValue(void);
@@ -201,7 +202,7 @@ public:
#endif
Vector vectorValue(void) const;
void setVectorValue(const Vector &newvector);
void setVectorValue(const Vector& newvector);
class PathNode *pathNodeValue(void) const;
class Waypoint *waypointValue(void) const;
@@ -218,16 +219,16 @@ public:
ScriptVariable& operator[](ScriptVariable& index);
ScriptVariable *operator[](unsigned index) const;
ScriptVariable *operator*();
void operator+=(const ScriptVariable &value);
void operator-=(const ScriptVariable &value);
void operator*=(const ScriptVariable &value);
void operator/=(const ScriptVariable &value);
void operator%=(const ScriptVariable &value);
void operator&=(const ScriptVariable &value);
void operator^=(const ScriptVariable &value);
void operator|=(const ScriptVariable &value);
void operator<<=(const ScriptVariable &value);
void operator>>=(const ScriptVariable &value);
void operator+=(const ScriptVariable& value);
void operator-=(const ScriptVariable& value);
void operator*=(const ScriptVariable& value);
void operator/=(const ScriptVariable& value);
void operator%=(const ScriptVariable& value);
void operator&=(const ScriptVariable& value);
void operator^=(const ScriptVariable& value);
void operator|=(const ScriptVariable& value);
void operator<<=(const ScriptVariable& value);
void operator>>=(const ScriptVariable& value);
bool operator!=(const ScriptVariable& value);
bool operator==(const ScriptVariable& value);
@@ -245,7 +246,7 @@ public:
public:
ScriptArrayHolder();
void Archive(Archiver &arc);
void Archive(Archiver& arc);
static void Archive(Archiver& arc, ScriptArrayHolder *& arrayValue);
};
@@ -257,7 +258,7 @@ public:
unsigned int size;
public:
void Archive(Archiver &arc);
void Archive(Archiver& arc);
static void Archive(Archiver& arc, ScriptConstArrayHolder *& constArrayValue);
ScriptConstArrayHolder(ScriptVariable *pVar, unsigned int size);
@@ -272,7 +273,7 @@ public:
Container<ScriptVariable *> list;
public:
void Archive(Archiver &arc);
void Archive(Archiver& arc);
static void Archive(Archiver& arc, ScriptPointer *& pointerValue);
void Clear();
@@ -284,6 +285,29 @@ public:
#ifdef WITH_SCRIPT_ENGINE
template<>
class con_set_Entry<short3, ScriptVariable>
{
friend con_set<short3, ScriptVariable>;
friend con_set_enum<short3, ScriptVariable>;
private:
con_set_Entry *next;
ScriptVariable value;
public:
void *operator new(size_t size) { return con_set<short3, ScriptVariable>::NewEntry(size); }
void operator delete(void *ptr) { con_set<short3, ScriptVariable>::DeleteEntry(ptr); }
# ifdef ARCHIVE_SUPPORTED
void Archive(Archiver& arc) { value.Archive(arc); }
# endif
short3& GetKey() { return value.GetKey(); }
void SetKey(const short3& newKey) { value.SetKey(newKey); }
};
class ScriptVariableList : public Class
{
private:
+78 -11
View File
@@ -82,18 +82,9 @@ ScriptVMStack::ScriptVMStack()
{}
ScriptVMStack::ScriptVMStack(size_t stackSize)
: ScriptVMStack()
{
if (!stackSize) {
stackSize = 1;
}
// allocate at once
uint8_t *data = (uint8_t *)gi.Malloc((sizeof(ScriptVariable) + sizeof(ScriptVariable *)) * stackSize);
localStack = new (data) ScriptVariable[stackSize];
data += sizeof(ScriptVariable) * stackSize;
pTop = localStack;
stackBottom = localStack + stackSize;
Allocate(stackSize);
}
ScriptVMStack::ScriptVMStack(ScriptVMStack&& other)
@@ -117,6 +108,31 @@ ScriptVMStack& ScriptVMStack::operator=(ScriptVMStack&& other)
}
ScriptVMStack::~ScriptVMStack()
{
Free();
}
void ScriptVMStack::Allocate(size_t stackSize)
{
if (localStack) {
// free the current local stack
Free();
}
if (!stackSize) {
stackSize = 1;
}
// allocate at once
uint8_t *data = (uint8_t *)gi.Malloc((sizeof(ScriptVariable) + sizeof(ScriptVariable *)) * stackSize);
localStack = new (data) ScriptVariable[stackSize];
data += sizeof(ScriptVariable) * stackSize;
pTop = localStack;
stackBottom = localStack + stackSize;
}
void ScriptVMStack::Free()
{
const size_t localStackSize = GetStackSize();
for (uintptr_t i = 0; i < localStackSize; ++i) {
@@ -215,6 +231,36 @@ ScriptVariable& ScriptVMStack::PushAndGet(size_t offset)
return *pTop;
}
void ScriptVMStack::Archive(Archiver& arc)
{
unsigned int size;
unsigned int offset;
unsigned int numVars;
unsigned int i;
if (arc.Saving()) {
size = stackBottom - localStack;
offset = pTop - localStack;
numVars = offset + 1;
arc.ArchiveUnsigned(&size);
arc.ArchiveUnsigned(&offset);
} else {
arc.ArchiveUnsigned(&size);
arc.ArchiveUnsigned(&offset);
numVars = offset + 1;
Allocate(size);
pTop = localStack + offset;
}
if (localStack) {
for (i = 0; i < numVars; i++) {
localStack[i].ArchiveInternal(arc);
}
}
}
void ScriptVMStack::MoveTop(ScriptVariable&& other)
{
*pTop = std::move(other);
@@ -246,6 +292,23 @@ void ScriptVM::operator delete(void *ptr)
ScriptVM_allocator.Free(ptr);
}
/*
====================
ScriptVM
====================
*/
ScriptVM::ScriptVM()
{
m_Stack = NULL;
m_PrevCodePos = NULL;
m_pOldData = NULL;
m_OldDataSize = 0;
m_bMarkStack = false;
m_StackPos = NULL;
}
/*
====================
ScriptVM
@@ -318,6 +381,8 @@ void ScriptVM::Archive(Archiver& arc)
m_Stack = new ScriptStack;
m_Stack->m_Array = new ScriptVariable[stack];
m_Stack->m_Count = stack;
} else {
m_Stack = NULL;
}
}
@@ -330,6 +395,8 @@ void ScriptVM::Archive(Archiver& arc)
m_ScriptClass->ArchiveCodePos(arc, &m_CodePos);
arc.ArchiveByte(&state);
arc.ArchiveByte(&m_ThreadState);
m_VMStack.Archive(arc);
}
/*
+9 -2
View File
@@ -98,7 +98,7 @@ public:
ScriptVariable *GetTopPtr(size_t offset) const;
ScriptVariable *GetTopArray(size_t offset = 0) const;
uintptr_t GetIndex() const;
void MoveTop(ScriptVariable &&other);
void MoveTop(ScriptVariable&& other);
/** Pop and return the previous value. */
ScriptVariable& Pop();
@@ -111,6 +111,12 @@ public:
ScriptVariable& PushAndGet();
ScriptVariable& PushAndGet(size_t offset);
void Archive(Archiver& arc);
private:
void Allocate(size_t stackSize);
void Free();
private:
/** The VM's local stack. */
ScriptVariable *localStack;
@@ -181,12 +187,13 @@ private:
bool Switch(StateScript *stateScript, ScriptVariable& var);
unsigned char *ProgBuffer();
void HandleScriptException(ScriptException &exc);
void HandleScriptException(ScriptException& exc);
public:
void *operator new(size_t size);
void operator delete(void *ptr);
ScriptVM();
ScriptVM(ScriptClass *scriptClass, unsigned char *pCodePos, ScriptThread *thread);
~ScriptVM();
+4 -4
View File
@@ -1884,7 +1884,7 @@ qboolean SV_ArchiveLevelFile(qboolean loading, qboolean autosave)
if (f)
{
FS_Read(&save, sizeof(savegamestruct_t), f);
if (save.version != 4)
if (save.version != SAVEGAME_STRUCT_VERSION)
{
FS_FCloseFile(f);
return qfalse;
@@ -1986,7 +1986,7 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
SV_SetConfigstring( CS_SAVENAME, "" );
save.version = 3;
save.version = SAVEGAME_STRUCT_VERSION;
save.time = aclock;
strncpy( save.mapName, svs.mapName, sizeof( save.mapName ) );
strncpy( save.saveName, svs.gameName, sizeof( save.saveName ) );
@@ -2010,8 +2010,8 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
return qfalse;
}
FS_Read( &save, sizeof( savegamestruct_t ), f );
if( save.version != 3 )
FS_Read(&save, sizeof(savegamestruct_t), f);
if (save.version != SAVEGAME_STRUCT_VERSION)
{
Com_Printf("Invalid or Old Server SaveGame Version\n");
return qfalse;