Fix wrong hashtable creation call for materials.

Tweaked a lot of gs-entbase entities.
This commit is contained in:
Marco Cawthorne 2019-10-19 04:30:29 +02:00
parent 5f41894f02
commit 7048e0add0
14 changed files with 233 additions and 46 deletions

View file

@ -11,6 +11,7 @@ server/func_ladder.cpp
server/trigger_gravity.cpp
client/info_notnull.cpp
client/point_message.cpp
client/func_physbox.cpp
client/prop_dynamic.cpp
client/prop_rope.cpp
client/worldspawn.cpp

View file

@ -0,0 +1,40 @@
/*class func_physbox:CBaseEntity
{
int m_iShape;
void() func_physbox;
virtual void() Respawn;
virtual void() touch;
};
void func_physbox::touch(void)
{
//physics_addforce(this, other.velocity, other.origin);
}
void func_physbox::Respawn(void)
{
movetype = MOVETYPE_PHYSICS;
solid = SOLID_PHYSICS_BOX; // SOLID_PHYSICS_TRIMESH
setmodel(this, m_oldModel);
setorigin(this, m_oldOrigin);
physics_enable(this, TRUE);
}
void prop_rope::SpawnKey(string strField, string strKey)
{
switch (strField) {
case "material":
//m_iMaterial = stof(argv(i + 1));
break;
default:
CBaseEntity::SpawnKey(strField, strKey);
}
}
void func_physbox::func_physbox(void)
{
drawmask = MASK_ENGINE;
Init();
}*/

View file

@ -25,10 +25,12 @@ Client-side decorative model entity.
*/
class prop_dynamic:CBaseEntity {
class prop_dynamic:CBaseEntity
{
void() prop_dynamic;
virtual void() Init;
virtual void() PhysicsFrame;
/*virtual float() predraw;*/
virtual void(string, string) SpawnKey;
};
@ -46,14 +48,6 @@ void prop_dynamic::SpawnKey(string strField, string strKey)
}
}
/*float prop_dynamic::predraw(void)
{
if (checkpvs(viewClient.vecPlayerOrigin, this) == TRUE) {
addentity(this);
}
return PREDRAW_NEXT;
}*/
void prop_dynamic::Init(void)
{
CBaseEntity::Init();
@ -65,6 +59,11 @@ void prop_dynamic::Init(void)
drawmask = MASK_ENGINE;
}
void prop_dynamic::prop_dynamic(void)
{
scale = 1.0f;
}
void prop_dynamic::PhysicsFrame(void)
{
//angles[1] += clframetime * 60;

View file

@ -24,11 +24,11 @@ class prop_rope:CBaseEntity
void() prop_rope;
virtual float() predraw;
virtual void(vector, vector) draw_segment;
virtual void(vector, vector, int) draw_segment;
virtual void(string, string) SpawnKey;
};
void prop_rope::draw_segment(vector start, vector end)
void prop_rope::draw_segment(vector start, vector end, int flip)
{
vector fsize = [2,2];
vector lit1 = /*[0.1,0.1,0.1] */ getlight(start) / 255;
@ -59,14 +59,23 @@ void prop_rope::draw_segment(vector start, vector end)
tex3 = end - tangent * fsize[0];
tex4 = end + tangent * fsize[1];
R_BeginPolygon(m_strShader, 0, 0);
R_PolygonVertex(tex1, [1,1], lit1, 1.0f);
R_PolygonVertex(tex2, [0,1], lit1, 1.0f);
if (!flip) {
R_BeginPolygon(m_strShader, 0, 0);
R_PolygonVertex(tex1, [0,1], lit1, 1.0f);
R_PolygonVertex(tex2, [1,1], lit1, 1.0f);
R_PolygonVertex(tex3, [1,0], lit2, 1.0f);
R_PolygonVertex(tex4, [0,0], lit2, 1.0f);
R_EndPolygon();
R_PolygonVertex(tex3, [1,0], lit2, 1.0f);
R_PolygonVertex(tex4, [0,0], lit2, 1.0f);
R_EndPolygon();
} else {
R_BeginPolygon(m_strShader, 0, 0);
R_PolygonVertex(tex1, [1,0], lit1, 1.0f);
R_PolygonVertex(tex2, [0,0], lit1, 1.0f);
R_PolygonVertex(tex3, [0,1], lit2, 1.0f);
R_PolygonVertex(tex4, [1,1], lit2, 1.0f);
R_EndPolygon();
}
}
float prop_rope::predraw(void)
@ -78,7 +87,7 @@ float prop_rope::predraw(void)
float sc;
if (checkpvs(getproperty(VF_ORIGIN), this) == FALSE) {
return;
return PREDRAW_NEXT;
}
entity x = find(world, ::targetname, target);
@ -104,7 +113,7 @@ float prop_rope::predraw(void)
sc = 0;
pos1 = origin;
for (float i = 0; i < segments / 2; i++) {
float sag = cos(sc) * m_flSag - 1;
float sag = cos(sc) * m_flSag;
/* get the direction */
makevectors(vectoangles(x.origin - origin));
@ -112,7 +121,7 @@ float prop_rope::predraw(void)
/* travel further and sag */
pos2 = pos1 + (v_forward * travel) + (v_up * -sag) + ((v_right * sin(time)) * m_flSwingFactor);
draw_segment(pos1, pos2);
draw_segment(pos1, pos2, 0);
pos1 = pos2;
sc += (M_PI * (1 / segments));
@ -121,7 +130,7 @@ float prop_rope::predraw(void)
sc = 0;
pos1 = x.origin;
for (float i = 0; i < segments / 2; i++) {
float sag = cos(sc) * m_flSag - 1;
float sag = cos(sc) * m_flSag;
/* get the direction */
makevectors(vectoangles(origin - x.origin));
@ -129,7 +138,7 @@ float prop_rope::predraw(void)
/* travel further and sag */
pos2 = pos1 + (v_forward * travel) + (v_up * -sag) - ((v_right * sin(time)) * m_flSwingFactor);
draw_segment(pos1, pos2);
draw_segment(pos1, pos2, 1);
pos1 = pos2;
sc += (M_PI * (1 / segments));
@ -161,6 +170,7 @@ void prop_rope::prop_rope(void)
{
m_flSwingFactor = random();
m_flSag = 15.0f;
m_strShader = "textures/props/wire_default";
drawmask = MASK_ENGINE;
Init();
}

View file

@ -17,14 +17,14 @@
// Submodel materials
enum
{
MATERIAL_GLASS,
MATERIAL_WOOD,
MATERIAL_METAL,
MATERIAL_FLESH,
MATERIAL_CINDER,
MATERIAL_TILE,
MATERIAL_COMPUTER,
MATERIAL_GLASS_UNBREAKABLE,
MATERIAL_ROCK,
MATERIAL_NONE
GSMATERIAL_GLASS,
GSMATERIAL_WOOD,
GSMATERIAL_METAL,
GSMATERIAL_FLESH,
GSMATERIAL_CINDER,
GSMATERIAL_TILE,
GSMATERIAL_COMPUTER,
GSMATERIAL_GLASS_UNBREAKABLE,
GSMATERIAL_ROCK,
GSMATERIAL_NONE
};

View file

@ -4,6 +4,7 @@ server/defs.h
server/baseentity.cpp
server/basetrigger.cpp
server/basemonster.cpp
server/basephysics.cpp
server/ambient_generic.cpp
server/cycler.cpp
server/cycler_sprite.cpp

View file

@ -0,0 +1,75 @@
enum {
PHYSM_BOX,
PHYSM_SPHERE,
PHYSM_CAPSULE,
PHYSM_TRIMESH,
PHYSM_CYLINDER
};
class CBasePhysics:CBaseEntity
{
int m_iShape;
int m_iMaterial;
void() CBasePhysics;
virtual void() Respawn;
virtual void() touch;
virtual void(entity, int, int) vPain;
};
void CBasePhysics::touch(void)
{
makevectors(vectoangles(origin - other.origin));
physics_addforce(this, v_forward * 128, other.origin);
physics_enable(this, TRUE);
}
void CBasePhysics::vPain(entity eAttacker, int iType, int iDamage)
{
iDamage *= 5;
makevectors(vectoangles(origin - trace_endpos));
physics_addforce(this, v_forward * iDamage, trace_endpos);
health = 100000;
physics_enable(this, TRUE);
}
void CBasePhysics::Respawn(void)
{
movetype = MOVETYPE_PHYSICS;
solid = SOLID_PHYSICS_BOX + m_iShape; // SOLID_PHYSICS_TRIMESH
setmodel(this, m_oldModel);
setorigin(this, m_oldOrigin);
physics_enable(this, FALSE);
takedamage = DAMAGE_YES;
health = 100000;
}
void CBasePhysics::CBasePhysics(void)
{
CBaseEntity::CBaseEntity();
precache_model(m_oldModel);
for (int i = 1; i < (tokenize(__fullspawndata) - 1); i += 2) {
switch (argv(i)) {
case "physmodel":
m_iShape = stoi(argv(i + 1));
if ( m_iShape > PHYSM_CYLINDER ) {
m_iShape = 0;
}
break;
case "material":
m_iMaterial = stof(argv(i + 1));
break;
default:
break;
}
}
CBasePhysics::Respawn();
}
CLASSEXPORT(prop_physics, CBasePhysics)
CLASSEXPORT(prop_physics_multiplayer, CBasePhysics)

View file

@ -42,6 +42,20 @@ enumflags
SF_PRESSURE
};
enum
{
BREAKMT_GLASS,
BREAKMT_WOOD,
BREAKMT_METAL,
BREAKMT_FLESH,
BREAKMT_CINDER,
BREAKMT_TILE,
BREAKMT_COMPUTER,
BREAKMT_GLASS_UNBREAKABLE,
BREAKMT_ROCK,
BREAKMT_NONE
};
class func_breakable:CBaseTrigger
{
float m_iMaterial;
@ -71,18 +85,18 @@ void func_breakable::vPain (entity attacker, int type, int damage)
}
switch (m_iMaterial) {
case MATERIAL_GLASS:
case MATERIAL_COMPUTER:
case MATERIAL_GLASS_UNBREAKABLE:
case BREAKMT_GLASS:
case BREAKMT_COMPUTER:
case BREAKMT_GLASS_UNBREAKABLE:
sound(self, CHAN_VOICE, sprintf("debris/glass%d.wav", random(1, 4)), 1.0, ATTN_NORM);
break;
case MATERIAL_WOOD:
case BREAKMT_WOOD:
sound(self, CHAN_VOICE, sprintf("debris/wood%d.wav", random(1, 4)), 1.0, ATTN_NORM);
break;
case MATERIAL_METAL:
case BREAKMT_METAL:
sound(self, CHAN_VOICE, sprintf("debris/metal%d.wav", random(1, 4)), 1.0, ATTN_NORM);
break;
case MATERIAL_FLESH:
case BREAKMT_FLESH:
float fRand = floor(random(1, 8));
/* There never was a flesh4.wav */
if (fRand == 4) {
@ -90,8 +104,8 @@ void func_breakable::vPain (entity attacker, int type, int damage)
}
sound(self, CHAN_VOICE, sprintf("debris/flesh%d.wav", fRand), 1.0, ATTN_NORM);
break;
case MATERIAL_CINDER:
case MATERIAL_ROCK:
case BREAKMT_CINDER:
case BREAKMT_ROCK:
sound(self, CHAN_VOICE, sprintf("debris/concrete%d.wav", random(1, 4)), 1.0, ATTN_NORM);
break;
}
@ -113,7 +127,7 @@ void func_breakable::Explode(void)
void func_breakable::vDeath (entity attacker, int type, int damage)
{
if (m_iMaterial == MATERIAL_GLASS_UNBREAKABLE) {
if (m_iMaterial == BREAKMT_GLASS_UNBREAKABLE) {
return;
}
health = 0;
@ -159,7 +173,7 @@ void func_breakable::PlayerTouch(void)
touch = __NULL__;
Damage_Apply(this, other, fDamage, 0, DMG_CRUSH);
if ((m_iMaterial == MATERIAL_GLASS) || (m_iMaterial == MATERIAL_COMPUTER)) {
if ((m_iMaterial == BREAKMT_GLASS) || (m_iMaterial == BREAKMT_COMPUTER)) {
Damage_Apply(other, this, fDamage / 4, 0, DMG_CRUSH);
}
}

View file

@ -36,6 +36,7 @@ void func_illusionary :: func_illusionary ( void )
movetype = MOVETYPE_PUSH;
solid = SOLID_NOT;
setmodel( this, model );
setorigin(this, origin);
// TODO: Add support for (skin) -1 = Empty, -7 = Volumetric light
if (skin < 0 ) {

View file

@ -0,0 +1,42 @@
class func_physbox:CBaseEntity
{
int m_iShape;
void() func_physbox;
virtual void() Respawn;
virtual void() touch;
};
void func_physbox::touch(void)
{
//physics_addforce(this, other.velocity, other.origin);
}
void func_physbox::Respawn(void)
{
movetype = MOVETYPE_PHYSICS;
solid = SOLID_PHYSICS_BOX; // SOLID_PHYSICS_TRIMESH
setmodel(this, m_oldModel);
setorigin(this, m_oldOrigin);
physics_enable(this, TRUE);
}
void func_physbox::func_physbox(void)
{
CBaseEntity::CBaseEntity();
precache_model(m_oldModel);
func_physbox::Respawn();
for (int i = 1; i < (tokenize(__fullspawndata) - 1); i += 2) {
switch (argv(i)) {
case "material":
//m_iMaterial = stof(argv(i + 1));
break;
default:
break;
}
}
}
CLASSEXPORT(func_physbox_multiplayer, func_physbox)

View file

@ -34,6 +34,7 @@ void func_wall :: func_wall ( void )
movetype = MOVETYPE_PUSH;
solid = SOLID_BSP;
setmodel( this, model );
setorigin(this, origin);
CBaseTrigger::CBaseTrigger();
}
@ -42,3 +43,5 @@ void func_wall :: Trigger ( void )
frame = 1 - frame;
}
CLASSEXPORT(func_physbox, func_wall)
CLASSEXPORT(func_physbox_multiplayer, func_wall)

View file

@ -41,6 +41,7 @@ void func_wall_toggle::func_wall_toggle(void)
solid = SOLID_BSP;
setmodel(this, model);
CBaseTrigger::CBaseTrigger();
setorigin(this, origin);
if (spawnflags & FTW_STARTHIDDEN) {
Trigger();

View file

@ -97,7 +97,7 @@ void init(float prevprogs)
// Let's load materials.txt because someone thought this was the best idea
filestream fileMaterial = fopen("sound/materials.txt", FILE_READ);
hashMaterials = hash_createtab(512, HASH_ADD);
hashMaterials = hash_createtab(2, HASH_ADD);
if (fileMaterial >= 0) {
while ((sTemp = fgets(fileMaterial))) {

View file

@ -34,7 +34,7 @@ varying mat3 invsurface;
void main ( void )
{
vec4 diffuse_f = texture2D(s_diffuse, tex_c);
vec3 light = texture2D(s_lightmap, lm_c).rgb;
vec3 light = texture2D(s_lightmap, lm_c).rgb * e_lmscale.rgb;
#ifdef REFLECTCUBE
#ifdef BUMP
@ -54,7 +54,7 @@ varying mat3 invsurface;
#endif
vec3 cube_c;
vec4 out_f = vec4( 1.0, 1.0, 1.0, 1.0 );
diffuse_f.rgb *= light.rgb * e_lmscale.rgb;
diffuse_f.rgb *= light.rgb;
cube_c = reflect( normalize(-eyevector), normal_f);
cube_c = cube_c.x * invsurface[0] + cube_c.y * invsurface[1] + cube_c.z * invsurface[2];