[nexuiz-commits] r6186 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Mar 16 03:20:02 EDT 2009
Author: div0
Date: 2009-03-16 03:19:57 -0400 (Mon, 16 Mar 2009)
New Revision: 6186
Modified:
trunk/data/qcsrc/server/cl_weaponsystem.qc
trunk/data/qcsrc/server/havocbot.qc
trunk/data/qcsrc/server/w_shotgun.qc
Log:
cleanup: remove code to load w_*.zym weapon models;
instead make the loading of the v_ model only happen if the h_ model defines the "weapon" tag.
That way, the h_ model can be both an "invisible hand" model, or an old-style "full weapon" model.
Also, note that the engine loads ZYM models properly as ZYM even if renamed to dpm, so there is no need to try all extensions.
All in all, this saves quite some file open calls and should help with dedicated server performance, especially on operating systems with slow file opening (e.g. Windows with a running on-access virus scanner).
Modified: trunk/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weaponsystem.qc 2009-03-15 21:14:56 UTC (rev 6185)
+++ trunk/data/qcsrc/server/cl_weaponsystem.qc 2009-03-16 07:19:57 UTC (rev 6186)
@@ -307,7 +307,6 @@
string animfilename;
float animfile;
- float modelfile;
if (self.owner.weaponname != "")
{
// if there is a child entity, hide it until we're sure we use it
@@ -317,60 +316,35 @@
setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // precision set below
else
{
- animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".zym");
- modelfile = fopen(animfilename, FILE_READ);
- if (modelfile >= 0)
+ setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".dpm")); // precision set below
+ animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".dpm.animinfo");
+ animfile = fopen(animfilename, FILE_READ);
+ // preset some defaults that work great for renamed zym files (which don't need an animinfo)
+ self.anim_fire1 = '0 1 0.01';
+ self.anim_fire2 = '1 1 0.01';
+ self.anim_idle = '2 1 0.01';
+ self.anim_reload = '3 1 0.01';
+ if (animfile >= 0)
{
- fclose(modelfile);
- self.anim_fire1 = '0 1 0.01';
- self.anim_fire2 = '1 1 0.01';
- self.anim_idle = '2 1 0.01';
- self.anim_reload = '3 1 0.01';
if (!self.weaponentity)
self.weaponentity = spawn();
- setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".zym")); // precision set below
+ animparseerror = FALSE;
+ self.anim_fire1 = animparseline(animfile);
+ self.anim_fire2 = animparseline(animfile);
+ self.anim_idle = animparseline(animfile);
+ self.anim_reload = animparseline(animfile);
+ fclose(animfile);
+ if (animparseerror)
+ print("Parse error in ", animfilename, ", some player animations are broken\n");
+ }
+
+ // if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model)
+ // if we don't, this is a "real" animated model
+ if(gettagindex(self, "weapon"))
+ {
setmodel(self.weaponentity, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // precision does not matter
setattachment(self.weaponentity, self, "weapon");
}
- else
- {
- animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".dpm.animinfo");
- animfile = fopen(animfilename, FILE_READ);
- if (animfile >= 0)
- {
- if (!self.weaponentity)
- self.weaponentity = spawn();
- setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".dpm")); // precision set below
- setmodel(self.weaponentity, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // precision does not matter
- setattachment(self.weaponentity, self, "weapon");
- }
- else
- {
- animfilename = strcat("models/weapons/w_", self.owner.weaponname, ".dpm.animinfo");
- animfile = fopen(animfilename, FILE_READ);
- if (animfile >= 0)
- setmodel(self, strcat("models/weapons/w_", self.owner.weaponname, ".dpm")); // precision set below
- }
- if (animfile >= 0)
- {
- animparseerror = FALSE;
- self.anim_fire1 = animparseline(animfile);
- self.anim_fire2 = animparseline(animfile);
- self.anim_idle = animparseline(animfile);
- self.anim_reload = animparseline(animfile);
- fclose(animfile);
- if (animparseerror)
- print("Parse error in ", animfilename, ", some player animations are broken\n");
- }
- else
- {
- self.anim_fire1 = '0 1 0.01';
- self.anim_fire2 = '1 1 0.01';
- self.anim_idle = '2 1 0.01';
- self.anim_reload = '3 1 0.01';
- setmodel(self, strcat("models/weapons/w_", self.owner.weaponname, ".zym")); // precision set below
- }
- }
}
}
else
@@ -452,7 +426,8 @@
}
tb = (self.effects & EF_TELEPORT_BIT);
- self.effects = self.owner.effects - (self.owner.effects & EF_LOWPRECISION);// | EF_LOWPRECISION;
+ self.effects = self.owner.effects;
+ self.effects &~= EF_LOWPRECISION;
self.effects &~= EF_FULLBRIGHT; // can mask team color, so get rid of it
self.effects &~= EF_TELEPORT_BIT;
self.effects |= tb;
@@ -465,7 +440,7 @@
self.colormap = self.owner.colormap;
if (self.weaponentity)
{
- self.weaponentity.effects = self.effects & EF_ADDITIVE;
+ self.weaponentity.effects = self.effects;
self.weaponentity.alpha = self.alpha;
self.weaponentity.colormap = self.colormap;
}
Modified: trunk/data/qcsrc/server/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot.qc 2009-03-15 21:14:56 UTC (rev 6185)
+++ trunk/data/qcsrc/server/havocbot.qc 2009-03-16 07:19:57 UTC (rev 6186)
@@ -140,7 +140,7 @@
.float bot_canruntogoal;
void havocbot_bunnyhop(vector dir)
{
- local float distance;
+ local float bunnyhopdistance;
local vector deviation;
if(self.goalcurrent.classname == "player")
@@ -165,7 +165,7 @@
self.bot_timelastseengoal = 0;
}
- distance = vlen(self.origin - self.goalcurrent.origin);
+ bunnyhopdistance = vlen(self.origin - self.goalcurrent.origin);
// Run only to visible goals
traceline(self.origin + self.view_ofs , self.goalcurrent.origin, TRUE, world);
@@ -186,7 +186,7 @@
// don't run if it is too close
if(self.bot_canruntogoal==0)
{
- if(distance > cvar("bot_ai_bunnyhop_startdistance"))
+ if(bunnyhopdistance > cvar("bot_ai_bunnyhop_startdistance"))
self.bot_canruntogoal = 1;
else
self.bot_canruntogoal = -1;
@@ -206,7 +206,7 @@
while (deviation_y > 180) deviation_y = deviation_y - 360;
if(fabs(deviation_y) < 15)
- if(distance < vlen(self.origin - self.goalstack01.origin))
+ if(bunnyhopdistance < vlen(self.origin - self.goalstack01.origin))
if(fabs(self.goalstack01.origin_z - self.goalcurrent.origin_z) < self.maxs_z - self.mins_z)
{
traceline(self.origin + self.view_ofs , self.goalstack01.origin, TRUE, world);
@@ -220,7 +220,7 @@
if(checkdistance)
{
self.aistatus &~= AI_STATUS_RUNNING;
- if(distance > cvar("bot_ai_bunnyhop_stopdistance"))
+ if(bunnyhopdistance > cvar("bot_ai_bunnyhop_stopdistance"))
self.BUTTON_JUMP = TRUE;
}
else
@@ -970,15 +970,15 @@
self.aistatus &~= AI_STATUS_ATTACKING;
local vector now,v,next;//,heading;
- local float distance,skillblend,distanceblend,blend;
+ local float aimdistance,skillblend,distanceblend,blend;
next = now = self.goalcurrent.origin - (self.origin + self.view_ofs);
- distance = vlen(now);
+ aimdistance = vlen(now);
//heading = self.velocity;
//dprint(self.goalstack01.classname,etos(self.goalstack01),"\n");
if(self.goalstack01 != self && self.goalstack01 != world && self.aistatus & AI_STATUS_RUNNING == 0)
next = self.goalstack01.origin - (self.origin + self.view_ofs);
skillblend=bound(0,(skill-2.5)*0.5,1); //lower skill player can't preturn
- distanceblend=bound(0,distance/cvar("bot_ai_keyboard_distance"),1);
+ distanceblend=bound(0,aimdistance/cvar("bot_ai_keyboard_distance"),1);
blend = skillblend * (1-distanceblend);
//v = (now * (distanceblend) + next * (1-distanceblend)) * (skillblend) + now * (1-skillblend);
//v = now * (distanceblend) * (skillblend) + next * (1-distanceblend) * (skillblend) + now * (1-skillblend);
Modified: trunk/data/qcsrc/server/w_shotgun.qc
===================================================================
--- trunk/data/qcsrc/server/w_shotgun.qc 2009-03-15 21:14:56 UTC (rev 6185)
+++ trunk/data/qcsrc/server/w_shotgun.qc 2009-03-16 07:19:57 UTC (rev 6186)
@@ -2,7 +2,7 @@
void W_Shotgun_Attack (void)
{
float sc;
- float ammo;
+ float ammoamount;
float bullets;
float d;
float f;
@@ -11,7 +11,7 @@
float bulletconstant;
local entity flash;
- ammo = cvar("g_balance_shotgun_primary_ammo");
+ ammoamount = cvar("g_balance_shotgun_primary_ammo");
bullets = cvar("g_balance_shotgun_primary_bullets");
d = cvar("g_balance_shotgun_primary_damage");
f = cvar("g_balance_shotgun_primary_force");
@@ -23,13 +23,13 @@
for (sc = 0;sc < bullets;sc = sc + 1)
fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_SHOTGUN, 0, 1, bulletconstant);
if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- self.ammo_shells = self.ammo_shells - ammo;
+ self.ammo_shells = self.ammo_shells - ammoamount;
pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_primary_ammo"));
// casing code
if (cvar("g_casings") >= 1)
- for (sc = 0;sc < ammo;sc = sc + 1)
+ for (sc = 0;sc < ammoamount;sc = sc + 1)
SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
// muzzle flash for 1st person view
@@ -51,7 +51,7 @@
void W_Shotgun_Attack2 (void)
{
float sc;
- float ammo;
+ float ammoamount;
float bullets;
float d;
float f;
@@ -60,7 +60,7 @@
float bulletconstant;
local entity flash;
- ammo = cvar("g_balance_shotgun_secondary_ammo");
+ ammoamount = cvar("g_balance_shotgun_secondary_ammo");
bullets = cvar("g_balance_shotgun_secondary_bullets");
d = cvar("g_balance_shotgun_secondary_damage");
f = cvar("g_balance_shotgun_secondary_force");
@@ -72,13 +72,13 @@
for (sc = 0;sc < bullets;sc = sc + 1)
fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_SHOTGUN | HITTYPE_SECONDARY, 0, 1, bulletconstant);
if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- self.ammo_shells = self.ammo_shells - ammo;
+ self.ammo_shells = self.ammo_shells - ammoamount;
pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_secondary_ammo"));
// casing code
if (cvar("g_casings") >= 1)
- for (sc = 0;sc < ammo;sc = sc + 1)
+ for (sc = 0;sc < ammoamount;sc = sc + 1)
SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
flash = spawn();
More information about the nexuiz-commits
mailing list