FAILED QC coding by me: Segfault!
I tried to implement a suggested feature (downwardly floating cherry blossoms), but since I am a garbage crap coder, who lives off the government dole because he has no talents and no future, I failed because I suck.
Here's the segfault when loading a map containing 4 func_cherryblossompetal (s):
Nexuiz wrote:Mod_Q3BSP_LoadTriangles: invalid vertexindex 0 (0 vertices), setting to 0
Mod_Q3BSP_LoadTriangles: invalid vertexindex 1 (0 vertices), setting to 0
Mod_Q3BSP_LoadTriangles: invalid vertexindex 2 (0 vertices), setting to 0
Mod_Q3BSP_LoadTriangles: invalid vertexindex 0 (0 vertices), setting to 0
Mod_Q3BSP_LoadTriangles: invalid vertexindex 2 (0 vertices), setting to 0
Mod_Q3BSP_LoadTriangles: invalid vertexindex 3 (0 vertices), setting to 0
sh: line 1: 11482 Segmentation fault ~/stuff/nexuiz/Nexuiz/../darkplaces/nexuiz-sdl -game temp
Addition to effectsinfo.txt:
- Code: Select all
// func_cherryblossompetal effect, used to inditcate japan.
// used in qcsrc/server/g_triggers.qc: self.effects = EF_CHERRYBLOSSOMPETAL
effect EF_CHERRYBLOSSOMPETAL
count 75
type static
color 0xf12353 0xf12353
size 1.0 2.0
alpha 64 128 128
gravity 0.1
airfriction 0.2
liquidfriction 0.8
originjitter 16 16 64
velocityjitter 32 32 0
//lightradius 200
//lighttime 0
//lightcolor 0.4 0.9 0.9
Diff of the qcsrc dir:
- Code: Select all
Index: server/g_triggers.qc
===================================================================
--- server/g_triggers.qc (revision 6583)
+++ server/g_triggers.qc (working copy)
@@ -1624,3 +1624,11 @@
{
self.use = trigger_disablerelay_use;
}
+
+
+void spawnfunc_func_cherryblossompetal()
+{
+ self.effects = EF_CHERRYBLOSSOMPETAL;
+}
+
+
Index: server/extensions.qh
===================================================================
--- server/extensions.qh (revision 6583)
+++ server/extensions.qh (working copy)
@@ -183,6 +183,14 @@
//description:
//entity emits bouncing sparkles in every direction
+//DP_EF_CHERRYBLOSSOMPETAL
+//idea: DivVerent
+//darkplaces implementation: a04191b92fbd93aa67214ef7e72d6d2e
+//effects bit:
+float EF_CHERRYBLOSSOMPETAL = 4294967296;
+//description:
+//entity emits cherry blossom petals in a downwardly direction, as is prudent
+
//DP_EF_TELEPORT_BIT
//idea: id software
//darkplaces implementation: div0
Index: client/csqc_constants.qc
===================================================================
--- client/csqc_constants.qc (revision 6583)
+++ client/csqc_constants.qc (working copy)
@@ -107,6 +107,7 @@
const float EF_STARDUST = 2048;
const float EF_NOSHADOW = 4096;
const float EF_NODEPTHTEST = 8192;
+const float EF_CHERRYBLOSSOMPETAL = 4294967296;
// Quake Player Flag Constants
const float PFL_ONGROUND = 1;
Diff of the darkplaces dir:
- Code: Select all
Index: sv_main.c
===================================================================
--- sv_main.c (revision 8939)
+++ sv_main.c (working copy)
@@ -196,6 +196,7 @@
"TE_TEI_BIGEXPLOSION",
"TE_TEI_PLASMAHIT",
"EF_STARDUST",
+ "EF_CHERRYBLOSSOMPETAL",
"TR_ROCKET",
"TR_GRENADE",
"TR_BLOOD",
@@ -1042,7 +1043,7 @@
specialvisibilityradius = max(specialvisibilityradius, glowsize * 4);
if (flags & RENDER_GLOWTRAIL)
specialvisibilityradius = max(specialvisibilityradius, 100);
- if (effects & (EF_BRIGHTFIELD | EF_MUZZLEFLASH | EF_BRIGHTLIGHT | EF_DIMLIGHT | EF_RED | EF_BLUE | EF_FLAME | EF_STARDUST))
+ if (effects & (EF_BRIGHTFIELD | EF_MUZZLEFLASH | EF_BRIGHTLIGHT | EF_DIMLIGHT | EF_RED | EF_BLUE | EF_FLAME | EF_STARDUST | EF_CHERRYBLOSSOMPETAL))
{
if (effects & EF_BRIGHTFIELD)
specialvisibilityradius = max(specialvisibilityradius, 80);
@@ -1060,6 +1061,8 @@
specialvisibilityradius = max(specialvisibilityradius, 250);
if (effects & EF_STARDUST)
specialvisibilityradius = max(specialvisibilityradius, 100);
+ if (effects & EF_CHERRYBLOSSOMPETAL)
+ specialvisibilityradius = max(specialvisibilityradius, 250);
}
// early culling checks
Index: cl_main.c
===================================================================
--- cl_main.c (revision 8939)
+++ cl_main.c (working copy)
@@ -1079,7 +1079,7 @@
// entity is in the world...
trailtype = EFFECT_NONE;
// LordHavoc: if the entity has no effects, don't check each
- if (e->render.effects & (EF_BRIGHTFIELD | EF_FLAME | EF_STARDUST))
+ if (e->render.effects & (EF_BRIGHTFIELD | EF_FLAME | EF_STARDUST | EF_CHERRYBLOSSOMPETAL))
{
if (e->render.effects & EF_BRIGHTFIELD)
{
@@ -1090,6 +1090,8 @@
}
if (e->render.effects & EF_FLAME)
CL_ParticleTrail(EFFECT_EF_FLAME, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true);
+ if (e->render.effects & EF_CHERRYBLOSSOMPETAL)
+ CL_ParticleTrail(EFFECT_EF_CHERRYBLOSSOMPETAL, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true);
if (e->render.effects & EF_STARDUST)
CL_ParticleTrail(EFFECT_EF_STARDUST, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0, false, true);
}
@@ -1293,7 +1295,7 @@
dlightcolor[1] = 0;
dlightcolor[2] = 0;
// LordHavoc: if the entity has no effects, don't check each
- if (e->render.effects & (EF_BRIGHTFIELD | EF_DIMLIGHT | EF_BRIGHTLIGHT | EF_RED | EF_BLUE | EF_FLAME | EF_STARDUST))
+ if (e->render.effects & (EF_BRIGHTFIELD | EF_DIMLIGHT | EF_BRIGHTLIGHT | EF_RED | EF_BLUE | EF_FLAME | EF_STARDUST | EF_CHERRYBLOSSOMPETAL))
{
if (e->render.effects & EF_BRIGHTFIELD)
{
@@ -1331,6 +1333,8 @@
}
if (e->render.effects & EF_FLAME)
CL_ParticleTrail(EFFECT_EF_FLAME, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
+ if (e->render.effects & EF_CHERRYBLOSSOMPETAL)
+ CL_ParticleTrail(EFFECT_EF_CHERRYBLOSSOMPETAL, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
if (e->render.effects & EF_STARDUST)
CL_ParticleTrail(EFFECT_EF_STARDUST, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
}
Index: protocol.h
===================================================================
--- protocol.h (revision 8939)
+++ protocol.h (working copy)
@@ -73,6 +73,7 @@
#define EF_ZOMGIB 536870912 // small blood trail
#define EF_TRACER2 1073741824 // orange split trail + rotate
#define EF_TRACER3 0x80000000 // purple trail
+#define EF_CHERRYBLOSSOMPETAL 0x100000000 // cherry blossom petals
// internaleffects bits (no overlap with EF_ bits):
#define INTEF_FLAG1QW 1
Index: cl_particles.c
===================================================================
--- cl_particles.c (revision 8939)
+++ cl_particles.c (working copy)
@@ -409,6 +409,7 @@
"TE_TEI_BIGEXPLOSION",
"TE_TEI_PLASMAHIT",
"EF_STARDUST",
+ "EF_CHERRYBLOSSOMPETAL",
"TR_ROCKET",
"TR_GRENADE",
"TR_BLOOD",
@@ -954,6 +955,13 @@
CL_NewParticle(pt_static, 0x903010, 0xFFD030, tex_particle, 4, 0, lhrandom(64, 128), 128, 1, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0.2, 0.8, 16, 128, true, 0, 1, PBLEND_ADD, PARTICLE_BILLBOARD);
CL_AllocLightFlash(NULL, &tempmatrix, 200, 1.0f, 0.7f, 0.3f, 0, 0, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
+ else if (effectnameindex == EFFECT_EF_CHERRYBLOSSOMPETAL)
+ {
+ count *= 200 * cl_particles_quality.value;
+ while (count-- > 0)
+ CL_NewParticle(pt_static, 0x903010, 0xFFD030, tex_particle, 4, 0, lhrandom(64, 128), 128, 1, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0.2, 0.8, 16, 128, true, 0, 1, PBLEND_ADD, PARTICLE_BILLBOARD);
+ CL_AllocLightFlash(NULL, &tempmatrix, 200, 1.0f, 0.7f, 0.3f, 0, 0, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ }
else if (!strncmp(particleeffectname[effectnameindex], "TR_", 3))
{
vec3_t dir, pos;
Index: client.h
===================================================================
--- client.h (revision 8939)
+++ client.h (working copy)
@@ -1332,6 +1332,7 @@
EFFECT_TE_TEI_BIGEXPLOSION,
EFFECT_TE_TEI_PLASMAHIT,
EFFECT_EF_STARDUST,
+ EFFECT_EF_CHERRYBLOSSOMPETAL,
EFFECT_TR_ROCKET,
EFFECT_TR_GRENADE,
EFFECT_TR_BLOOD,
I am a failure.