PropData: Breakmodels now spawn fully client-side! This will remove a lot of network overhead.
This commit is contained in:
parent
cbc8fda92a
commit
ecf5988584
5 changed files with 72 additions and 10 deletions
|
@ -135,6 +135,9 @@ Event_Parse(float type)
|
|||
pSeat->m_flShakeFreq = readfloat();
|
||||
pSeat->m_flShakeTime = pSeat->m_flShakeDuration;
|
||||
break;
|
||||
case EV_BREAKMODEL:
|
||||
BreakModel_Receive();
|
||||
break;
|
||||
default:
|
||||
error("event not recognized. abort immediately.\n");
|
||||
}
|
||||
|
|
|
@ -548,6 +548,10 @@ void
|
|||
NSRenderableEntity::SetBody(int newBody)
|
||||
{
|
||||
m_iBody = newBody;
|
||||
|
||||
#ifdef CLIENT
|
||||
setcustomskin(this, "", sprintf("geomset 0 %i\ngeomset 1 %i\n", m_iBody, m_iBody));
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -51,5 +51,6 @@ enum
|
|||
EV_CLEARDECALS,
|
||||
EV_SURFIMPACT,
|
||||
EV_DECALGROUP,
|
||||
EV_BREAKMODEL,
|
||||
EV_SEPARATOR
|
||||
};
|
||||
|
|
|
@ -128,7 +128,13 @@ breakmodel_t *g_breakmodel;
|
|||
int g_breakmodel_count;
|
||||
var hashtable g_hashbreakmodel;
|
||||
|
||||
|
||||
#ifdef CLIENT
|
||||
void BreakModel_SpawnID(vector smins, vector smaxs, vector dir, float speed, int count, int index);
|
||||
void BreakModel_Receive(void);
|
||||
#else
|
||||
void BreakModel_Spawn(vector pos, vector dir, vector spread, float speed, int count, string type);
|
||||
#endif
|
||||
|
||||
/* necessary API functions */
|
||||
//void BreakModel_Init(void);
|
||||
|
|
|
@ -485,17 +485,10 @@ PropData_Finish(void)
|
|||
}
|
||||
|
||||
/* BreakModel related helper API */
|
||||
#ifdef CLIENT
|
||||
void
|
||||
BreakModel_Spawn(vector smins, vector smaxs, vector dir, float speed, int count, string type)
|
||||
BreakModel_SpawnID(vector smins, vector smaxs, vector dir, float speed, int count, int index)
|
||||
{
|
||||
int index;
|
||||
index = (int)hash_get(g_hashbreakmodel, type, -1);
|
||||
|
||||
if (index < 0) {
|
||||
crossprint(sprintf("^1BreakModel_Spawn: type %s is not defined\n", type));
|
||||
return;
|
||||
}
|
||||
|
||||
float x = tokenize(g_breakmodel[index].data);
|
||||
int modelcount = x / 2;
|
||||
|
||||
|
@ -591,4 +584,59 @@ BreakModel_Spawn(vector smins, vector smaxs, vector dir, float speed, int count,
|
|||
/* re-calculate the tokenization */
|
||||
x = tokenize(g_breakmodel[index].data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BreakModel_Receive(void)
|
||||
{
|
||||
vector smins, smaxs, dir;
|
||||
float speed;
|
||||
int count;
|
||||
int index;
|
||||
|
||||
index = readbyte();
|
||||
smins[0] = readcoord();
|
||||
smins[1] = readcoord();
|
||||
smins[2] = readcoord();
|
||||
|
||||
smaxs[0] = readcoord();
|
||||
smaxs[1] = readcoord();
|
||||
smaxs[2] = readcoord();
|
||||
|
||||
dir[0] = readcoord();
|
||||
dir[1] = readcoord();
|
||||
dir[2] = readcoord();
|
||||
|
||||
speed = readfloat();
|
||||
count = readbyte();
|
||||
|
||||
BreakModel_SpawnID(smins, smaxs, dir, speed, count, index);
|
||||
}
|
||||
|
||||
#else
|
||||
void
|
||||
BreakModel_Spawn(vector smins, vector smaxs, vector dir, float speed, int count, string type)
|
||||
{
|
||||
int index;
|
||||
index = (int)hash_get(g_hashbreakmodel, type, -1);
|
||||
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EV_BREAKMODEL);
|
||||
WriteByte(MSG_MULTICAST, index);
|
||||
WriteCoord(MSG_MULTICAST, smins[0]);
|
||||
WriteCoord(MSG_MULTICAST, smins[1]);
|
||||
WriteCoord(MSG_MULTICAST, smins[2]);
|
||||
WriteCoord(MSG_MULTICAST, smaxs[0]);
|
||||
WriteCoord(MSG_MULTICAST, smaxs[1]);
|
||||
WriteCoord(MSG_MULTICAST, smaxs[2]);
|
||||
WriteCoord(MSG_MULTICAST, dir[0]);
|
||||
WriteCoord(MSG_MULTICAST, dir[1]);
|
||||
WriteCoord(MSG_MULTICAST, dir[2]);
|
||||
WriteFloat(MSG_MULTICAST, speed);
|
||||
WriteByte(MSG_MULTICAST, count);
|
||||
multicast((smins - smaxs), MULTICAST_PVS);
|
||||
}
|
||||
#endif
|
Loading…
Reference in a new issue