]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/itemstime
authorterencehill <piuntn@gmail.com>
Sun, 18 Dec 2011 15:27:37 +0000 (16:27 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 18 Dec 2011 15:27:37 +0000 (16:27 +0100)
42 files changed:
defaultXonotic.cfg
menu.dat.es.po
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/csqcmodel_hooks.qc [new file with mode: 0644]
qcsrc/client/gibs.qc
qcsrc/client/interpolate.qc [deleted file]
qcsrc/client/interpolate.qh [deleted file]
qcsrc/client/miscfunctions.qc
qcsrc/client/progs.src
qcsrc/common/constants.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/csqcmodel/cl_model.qc [new file with mode: 0644]
qcsrc/csqcmodel/cl_model.qh [new file with mode: 0644]
qcsrc/csqcmodel/cl_player.qc [new file with mode: 0644]
qcsrc/csqcmodel/cl_player.qh [new file with mode: 0644]
qcsrc/csqcmodel/common.qh [new file with mode: 0644]
qcsrc/csqcmodel/interpolate.qc [new file with mode: 0644]
qcsrc/csqcmodel/interpolate.qh [new file with mode: 0644]
qcsrc/csqcmodel/settings.qh [new file with mode: 0644]
qcsrc/csqcmodel/sv_model.qc [new file with mode: 0644]
qcsrc/csqcmodel/sv_model.qh [new file with mode: 0644]
qcsrc/dpdefs/csprogsdefs.qc
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.c
qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c
qcsrc/server/autocvars.qh
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/cl_weapons.qc
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/constants.qh
qcsrc/server/defs.qh
qcsrc/server/g_subs.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/portals.qc
qcsrc/server/progs.src
qcsrc/server/t_items.qc
qcsrc/server/teamplay.qc

index a2f732f5b9fff53a2fef89a8e22a3f787e7c021d..d5fc82aa243304d88ba5419c2d94684ebfec2065 100644 (file)
@@ -498,14 +498,11 @@ set g_shootfromeye 0 "shots are fired from your eye/crosshair; visual gun positi
 set g_shootfromcenter 0 "weapon gets moved to the center, shots still come from the barrel of your weapon; visual gun position can still be influenced by cl_gunalign 1 and 2"
 set g_shootfromfixedorigin "" "if set to a string like 0 y z, the gun is moved to the given y and z coordinates. If set to a string like x y z, the whole shot origin is used"
 set g_pinata 0 "if set to 1 you will not only drop your current weapon when you are killed, but you will drop all weapons that you possessed"
-set g_weapon_stay 0 "if set to 1 or 2, weapons stay after they were picked up (1: weapons you don't have yet give you ammo of their type and they can not be dropped, 2: weapons don't give ammo, but instead players start with one pickup-load of ammo by default, 3: weapons give ammo, weapons only stay as ammo-less ghosts)"
+set g_weapon_stay 0 "1: ghost weapons can be picked up too but give no ammo, 2: ghost weapons refill ammo to one pickup size, thrown guns have no ammo"
 set g_weapon_throwable 1 "if set to 1, weapons can be dropped"
-set g_powerup_superhealth 1 "if set to 0 the mega health powerup will not spawn on the map"
-set g_powerup_strength 1 "if set to 0 the strength powerup will not spawn on the map"
-set g_powerup_shield 1 "if set to 0 the shield (invincibility) powerup will not spawn on the map"
-set g_balance_powerup_timer 1 "if set to 0 the powerups dont wear off"
+set g_powerups -1 "if set to 0 the strength and shield (invincibility) will not spawn on the map, if 1 they will spawn in all game modes, -1 is game mode default"
 set g_use_ammunition 1 "if set to 0 all weapons have unlimited ammunition"
-set g_pickup_items 1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map"
+set g_pickup_items -1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map, if 1 they are forced to spawn"
 set g_minstagib 0      "enable minstagib"
 set g_minstagib_extralives 2   "how many extra lives you will get per powerup"
 set g_minstagib_ammo_start 10  "starting ammo"
@@ -689,7 +686,7 @@ set g_cts_respawn_waves 0
 set g_cts_respawn_delay 0
 set g_cts_selfdamage 1 "0 = disable all selfdamage and falldamage in cts"
 set g_cts_finish_kill_delay 10 "prevent cheating by running back to the start line, and starting out with more speed than otherwise possible"
-set g_cts_weapon_stay 1
+set g_cts_weapon_stay 2
 set g_freezetag_respawn_waves 0
 set g_freezetag_respawn_delay 0
 set g_freezetag_weapon_stay 0
@@ -838,7 +835,6 @@ set g_arena 0 "Arena: many one-on-one rounds are played to find the winner"
 set g_arena_maxspawned 2       "maximum number of players to spawn at once (the rest is spectating, waiting for their turn)"
 set g_arena_roundbased 1       "if disabled, the next player will spawn as soon as someone dies"
 set g_arena_warmup 5   "time, newly spawned players have to prepare themselves in round based matches"
-set g_arena_powerups 0 "enables powerups (superhealth, strength and shield), which are removed by default"
 
 // ca
 set g_ca 0 "Clan Arena: Played in rounds, once you're dead you're out! The team with survivors wins the round."
@@ -1806,11 +1802,6 @@ set menu_updatecheck 1
 set bot_navigation_ignoreplayers 0 // FIXME remove this once the issue is solved
 set bot_sound_monopoly 0 "when enabled, only bots can make any noise"
 
-// broken, sorry (cannot handle weapon attachment properly)
-//seta cl_forceplayermodels 0 "force all players to look like you; WARNING: animations can look very bad with this"
-//seta cl_forceplayermodelsfromxonotic 0 "force models coming from xonotic; WARNING: animations can look very bad with this"
-//set sv_clforceplayermodels 1 "allow clients to use cl_forcemodels"
-
 set sv_loddistance1 1024
 set sv_loddistance2 4096
 seta cl_playerdetailreduction 0        "the higher, the less detailed player models are displayed (LOD)"
@@ -1920,6 +1911,9 @@ set developer_shtest 0 "experimental speedhack detection"
 set waypoint_benchmark 0 "quit after waypoint loading to benchmark bot navigation code"
 set g_debug_bot_commands 0 "print scripted bot commands before executing"
 set g_debug_defaultsounds 0 "always use default sounds"
+set sv_use_csqc_players 1 "set to 0 to disable CSQC players for better Xonotic 0.5 compat"
+set cl_forceplayermodels 0 "set to 1 to make everyone look like yourself (requires server to have sv_use_csqc_players 1)"
+set cl_precacheplayermodels 0 "TODO please check if this needs to be 1 or if precaching a model the server already requested is fast enough to do it at runtime"
 
 // debug cvars for keyhunt attaching
 set _angles "0 0 0"
index 47ba9ac194d249a281b9ffddab4668f9c5d98155..65636cfccf65d6e119114112b0160f6aec01e31b 100644 (file)
@@ -8,7 +8,8 @@ msgstr ""
 "Project-Id-Version: Xonotic 0.1preview\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2011-09-02 07:51+0200\n"
-"Last-Translator: Rodrigo Mouton Laudin <ratogenesis@gmail.com>\n"
+"Author: Rodrigo Mouton Laudin <ratogenesis@gmail.com>\n"
+"Last-Translator: mand1nga <mand1nga@xonotic.org>\n"
 "Language: es\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
index 2252f6f61cec427d69ebe63d9a26eca8394955f3..8c7c6bc0c7a47509695dd131d48682dca0fdf4f8 100644 (file)
@@ -41,6 +41,55 @@ void menu_sub_null()
 float __engine_check;
 #endif
 
+void precache_playermodel(string m)
+{
+       string f;
+
+       if(substring(m, -9,5) == "_lod1")
+               return;
+       if(substring(m, -9,5) == "_lod2")
+               return;
+       precache_model(m);
+       f = strcat(substring(m, 0, -5), "_lod1", substring(m, -4, -1));
+       if(fexists(f))
+               precache_model(f);
+       f = strcat(substring(m, 0, -5), "_lod2", substring(m, -4, -1));
+       if(fexists(f))
+               precache_model(f);
+
+       /*
+       float globhandle, i, n;
+       globhandle = search_begin(strcat(m, "_*.sounds"), TRUE, FALSE);
+       if (globhandle < 0)
+               return;
+       n = search_getsize(globhandle);
+       for (i = 0; i < n; ++i)
+       {
+               //print(search_getfilename(globhandle, i), "\n");
+               f = search_getfilename(globhandle, i);
+               PrecachePlayerSounds(f);
+       }
+       search_end(globhandle);
+       */
+}
+void precache_all_playermodels(string pattern)
+{
+       float globhandle, i, n;
+       string f;
+
+       globhandle = search_begin(pattern, TRUE, FALSE);
+       if (globhandle < 0)
+               return;
+       n = search_getsize(globhandle);
+       for (i = 0; i < n; ++i)
+       {
+               //print(search_getfilename(globhandle, i), "\n");
+               f = search_getfilename(globhandle, i);
+               precache_playermodel(f);
+       }
+       search_end(globhandle);
+}
+
 string forcefog;
 void WaypointSprite_Load();
 void CSQC_Init(void)
@@ -135,6 +184,15 @@ void CSQC_Init(void)
        precache_model("null");
        precache_sound("misc/hit.wav");
        precache_sound("misc/typehit.wav");
+       if (autocvar_cl_precacheplayermodels)
+       {
+               precache_all_playermodels("models/player/*.zym");
+               precache_all_playermodels("models/player/*.dpm");
+               precache_all_playermodels("models/player/*.md3");
+               precache_all_playermodels("models/player/*.psk");
+               precache_all_playermodels("models/player/*.iqm");
+       }
+
        Projectile_Precache();
        Hook_Precache();
        GibSplash_Precache();
@@ -1016,6 +1074,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
                case ENT_CLIENT_TURRET: ent_turret(); break; 
+               case ENT_CLIENT_MODEL: CSQCModel_Read(); break; 
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
index d9f6df7ee77281fdf2e52b650d25680dec5f72a9..ac2f12cb52a9eba1196579b8616b4a6631d6d53a 100644 (file)
@@ -408,6 +408,8 @@ void CSQC_UpdateView(float w, float h)
 
        WaypointSprite_Load();
 
+       CSQCPlayer_SetCamera();
+
 #ifdef COMPAT_XON050_ENGINE
        if(spectatee_status)
                myteam = GetPlayerColor(spectatee_status - 1);
index 28f37d6f035af738432a3ecf043de9d40842e43c..af8f96d99f5efeb530a449f84b4fb62ee450e055 100644 (file)
@@ -381,3 +381,10 @@ var float autocvar_cl_eventchase_distance = 140;
 var float autocvar_cl_eventchase_speed = 1.3;
 float autocvar_cl_lerpexcess;
 string autocvar__togglezoom;
+float autocvar_cl_playerdetailreduction;
+float autocvar_cl_loddistance1 = 1024;
+float autocvar_cl_loddistance2 = 4096;
+float autocvar_cl_forceplayermodels;
+float autocvar__cl_playerskin;
+string autocvar__cl_playermodel;
+float autocvar_cl_precacheplayermodels;
diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc
new file mode 100644 (file)
index 0000000..26299d3
--- /dev/null
@@ -0,0 +1,302 @@
+
+
+// FEATURE: LOD
+.float lodmodelindex0;
+.float lodmodelindex1;
+.float lodmodelindex2;
+void CSQCPlayer_LOD_Apply(void)
+{
+       // LOD model loading
+       if(self.lodmodelindex0 != self.modelindex)
+       {
+               string modelname = self.model;
+               string s;
+
+               if(!fexists(modelname))
+               {
+                       print(sprintf(_("Trying to use non existing model %s. "), modelname));
+                       modelname = cvar_defstring("_cl_playermodel");
+                       print(sprintf(_("Reverted to %s."), modelname));
+               }
+
+               // set modelindex
+               self.lodmodelindex0 = self.modelindex;
+               self.lodmodelindex1 = self.modelindex;
+               self.lodmodelindex2 = self.modelindex;
+
+               // FIXME: this only supports 3-letter extensions
+               s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
+               if(fexists(s))
+               {
+                       precache_model(s);
+                       setmodel(self, s);
+                       if(self.modelindex)
+                               self.lodmodelindex1 = self.modelindex;
+               }
+
+               s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
+               if(fexists(s))
+               {
+                       precache_model(s);
+                       setmodel(self, s);
+                       if(self.modelindex)
+                               self.lodmodelindex2 = self.modelindex;
+               }
+
+               setmodel(self, modelname); // make everything normal again
+       }
+
+       // apply LOD
+       if(autocvar_cl_playerdetailreduction <= 0)
+       {
+               if(autocvar_cl_playerdetailreduction <= -2)
+                       self.modelindex = self.lodmodelindex2;
+               else if(autocvar_cl_playerdetailreduction <= -1)
+                       self.modelindex = self.lodmodelindex1;
+               else
+                       self.modelindex = self.lodmodelindex0;
+       }
+       else
+       {
+               float distance = vlen(self.origin - other.origin);
+               float f = (distance + 100.0) * autocvar_cl_playerdetailreduction;
+               f *= 1.0 / bound(0.01, view_quality, 1);
+               if(f > autocvar_cl_loddistance2)
+                       self.modelindex = self.lodmodelindex2;
+               else if(f > autocvar_cl_loddistance1)
+                       self.modelindex = self.lodmodelindex1;
+               else
+                       self.modelindex = self.lodmodelindex0;
+       }
+}
+
+// FEATURE: forcemodel (MUST be called BEFORE LOD!)
+string forceplayermodels_model;
+float forceplayermodels_modelindex;
+float forceplayermodels_skin;
+float forceplayermodels_attempted;
+.string forceplayermodels_savemodel;
+.float forceplayermodels_savemodelindex;
+.float forceplayermodels_saveskin;
+void CSQCPlayer_ForceModel_PreUpdate(void)
+{
+       self.model = self.forceplayermodels_savemodel;
+       self.modelindex = self.forceplayermodels_savemodelindex;
+       self.skin = self.forceplayermodels_saveskin;
+}
+void CSQCPlayer_ForceModel_PostUpdate(void)
+{
+       self.forceplayermodels_savemodel = self.model;
+       self.forceplayermodels_savemodelindex = self.modelindex;
+       self.forceplayermodels_saveskin = self.skin;
+}
+void CSQCPlayer_ForceModel_Apply(float islocalplayer)
+{
+       // first, try finding it from the server
+
+       if(self.forceplayermodels_savemodelindex && self.forceplayermodels_savemodel != "null")
+       {
+               if(islocalplayer)
+               {
+                       // trust server's idea of "own player model"
+                       forceplayermodels_model = self.model;
+                       forceplayermodels_modelindex = self.modelindex;
+                       forceplayermodels_skin = self.skin;
+                       forceplayermodels_attempted = 1;
+               }
+       }
+
+       // forcemodel finding
+       if(!forceplayermodels_attempted)
+       {
+               // only if this failed, find it out on our own
+               entity e;
+               e = spawn();
+               setmodel(e, autocvar__cl_playermodel); // this is harmless, see below
+               forceplayermodels_model = e.model;
+               forceplayermodels_modelindex = e.modelindex;
+               forceplayermodels_skin = autocvar__cl_playerskin;
+               forceplayermodels_attempted = 1;
+               remove(e);
+       }
+
+       // apply it
+       if(autocvar_cl_forceplayermodels && forceplayermodels_modelindex)
+       {
+               self.model = forceplayermodels_model;
+               self.modelindex = forceplayermodels_modelindex;
+               self.skin = forceplayermodels_skin;
+       }
+       else
+       {
+               self.model = self.forceplayermodels_savemodel;
+               self.modelindex = self.forceplayermodels_savemodelindex;
+               self.skin = self.forceplayermodels_saveskin;
+       }
+}
+
+// FEATURE: fallback frames
+.float csqcmodel_saveframe;
+.float csqcmodel_saveframe2;
+.float csqcmodel_saveframe3;
+.float csqcmodel_saveframe4;
+.float csqcmodel_framecount;
+void CSQCPlayer_FallbackFrame_PreUpdate(void)
+{
+       self.frame = self.csqcmodel_saveframe;
+       self.frame2 = self.csqcmodel_saveframe2;
+       self.frame3 = self.csqcmodel_saveframe3;
+       self.frame4 = self.csqcmodel_saveframe4;
+}
+void CSQCPlayer_FallbackFrame_PostUpdate(void)
+{
+       self.csqcmodel_saveframe = self.frame;
+       self.csqcmodel_saveframe2 = self.frame2;
+       self.csqcmodel_saveframe3 = self.frame3;
+       self.csqcmodel_saveframe4 = self.frame4;
+}
+float CSQCPlayer_FallbackFrame(float f)
+{
+       if(frameduration(self.modelindex, f) > 0)
+               return f; // goooooood
+       switch(f)
+       {
+               case 23: return 11; // anim_melee -> anim_shoot
+               case 24: return 4; // anim_duckwalkbackwards -> anim_duckwalk
+               case 25: return 4; // anim_duckwalkstrafeleft -> anim_duckwalk
+               case 26: return 4; // anim_duckwalkstraferight -> anim_duckwalk
+               case 27: return 4; // anim_duckwalkforwardright -> anim_duckwalk
+               case 28: return 4; // anim_duckwalkforwardleft -> anim_duckwalk
+               case 29: return 4; // anim_duckwalkbackright -> anim_duckwalk
+               case 30: return 4; // anim_duckwalkbackleft -> anim_duckwalk
+       }
+       print(sprintf("Frame %d missing in model %s, and we have no fallback - FAIL!\n", f, self.model));
+       return f;
+}
+void CSQCPlayer_FallbackFrame_Apply(void)
+{
+       self.frame = CSQCPlayer_FallbackFrame(self.frame);
+       self.frame2 = CSQCPlayer_FallbackFrame(self.frame2);
+       self.frame3 = CSQCPlayer_FallbackFrame(self.frame3);
+       self.frame4 = CSQCPlayer_FallbackFrame(self.frame4);
+}
+
+// FEATURE: auto glowmod
+.vector glowmod;
+void CSQCPlayer_GlowMod_Apply(void)
+{
+       if(self.colormap > 0)
+               self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? self.colormap : stof(getplayerkeyvalue(self.colormap - 1, "colors"))) & 0x0F, TRUE) * 2;
+       else
+               self.glowmod = '1 1 1';
+}
+
+// FEATURE: auto tag_index
+.entity tag_entity;
+.float tag_entity_lastmodelindex;
+.float tag_index;
+void CSQCModel_AutoTagIndex_Apply(void)
+{
+       if(self.tag_entity && wasfreed(self.tag_entity))
+               self.tag_entity = world;
+
+       if(self.tag_networkentity)
+       {
+               // we are ATTACHED!
+               float changed = 0;
+               if(self.tag_entity.entnum != self.tag_networkentity)
+               {
+                       self.tag_entity = findfloat(world, entnum, self.tag_networkentity);
+                       changed = 1;
+               }
+               if(self.tag_entity.modelindex != self.tag_entity_lastmodelindex)
+               {
+                       self.tag_entity_lastmodelindex = self.tag_entity.modelindex;
+                       changed = 1;
+               }
+               if(changed)
+               {
+                       if(self.tag_entity)
+                       {
+                               // the best part is: IT EXISTS
+                               if(substring(self.model, 0, 17) == "models/weapons/v_")
+                                       if(substring(self.tag_entity.model, 0, 17) == "models/weapons/h_")
+                                       {
+                                               self.tag_index = gettagindex(self.tag_entity, "weapon");
+                                               if(!self.tag_index)
+                                                       self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
+                                               if(!self.tag_index)
+                                               {
+                                                       // we need to prevent this from 'appening
+                                                       self.tag_entity = world;
+                                                       self.drawmask = 0;
+                                                       dprint("h_ model lacks weapon attachment, but v_ model is attached to it\n");
+                                               }
+                                       }
+
+                               if(substring(self.model, 0, 17) == "models/weapons/v_")
+                                       if(substring(self.tag_entity.model, 0, 14) == "models/player/")
+                                       {
+                                               self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
+                                               if(!self.tag_index)
+                                                       self.tag_index = gettagindex(self.tag_entity, "bip01 r hand");
+                                       }
+
+                               if(substring(self.tag_entity.model, 0, 17) == "models/weapons/v_")
+                               {
+                                       self.tag_index = gettagindex(self.tag_entity, "shot");
+                                       if(!self.tag_index)
+                                               self.tag_index = gettagindex(self.tag_entity, "tag_shot");
+                               }
+                       }
+                       else
+                       {
+                               // damn, see you next frame
+                               self.drawmask = 0;
+                       }
+               }
+       }
+}
+
+// general functions
+void CSQCModel_Hook_PreDraw(float isplayer, float islocalplayer)
+{
+       if(!self.modelindex || self.model == "null")
+       {
+               self.drawmask = 0;
+               return;
+       }
+       else
+               self.drawmask = MASK_NORMAL;
+
+       if(isplayer)
+       {
+               CSQCPlayer_GlowMod_Apply();
+               CSQCPlayer_ForceModel_Apply(islocalplayer);
+               CSQCPlayer_LOD_Apply();
+               CSQCPlayer_FallbackFrame_Apply();
+       }
+
+       if(!isplayer)
+               CSQCModel_AutoTagIndex_Apply();
+}
+
+void CSQCModel_Hook_PreUpdate(float isplayer, float islocalplayer)
+{
+       if(isplayer)
+       {
+               // revert to values from server
+               CSQCPlayer_ForceModel_PreUpdate();
+               CSQCPlayer_FallbackFrame_PreUpdate();
+       }
+}
+
+void CSQCModel_Hook_PostUpdate(float isplayer, float islocalplayer)
+{
+       if(isplayer)
+       {
+               // save values set by server
+               CSQCPlayer_ForceModel_PostUpdate();
+               CSQCPlayer_FallbackFrame_PostUpdate();
+       }
+}
index 67fa4b3b9ab8f93020918530322cd981ee7f84a1..6f6316bec1d4c46e2fd474e874316b8563f0af29 100644 (file)
@@ -89,6 +89,7 @@ void Gib_Draw()
                return;
 
        if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
+               // TODO somehow make it spray in a direction dependent on self.angles
                trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_SLIGHTBLOOD")), oldorg, self.origin);
        else
                trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_BLOOD")), oldorg, self.origin);
diff --git a/qcsrc/client/interpolate.qc b/qcsrc/client/interpolate.qc
deleted file mode 100644 (file)
index 3d6a103..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-// FIXME make this generic code, to be used for other entities too?
-.vector iorigin1, iorigin2;
-.vector ivelocity1, ivelocity2;
-.vector iforward1, iforward2;
-.vector iup1, iup2;
-.float itime1, itime2;
-void InterpolateOrigin_Reset()
-{
-       self.iflags &~= IFLAG_INTERNALMASK;
-       self.itime1 = self.itime2 = 0;
-}
-void InterpolateOrigin_Note()
-{
-       float dt;
-       float f0;
-
-       dt = time - self.itime2;
-
-       f0 = self.iflags;
-       if(self.iflags & IFLAG_PREVALID)
-               self.iflags |= IFLAG_VALID;
-       else
-               self.iflags |= IFLAG_PREVALID;
-
-       self.iorigin1 = self.iorigin2;
-       self.iorigin2 = self.origin;
-
-       if(self.iflags & IFLAG_AUTOANGLES)
-               if(self.iorigin2 != self.iorigin1)
-                       self.angles = vectoangles(self.iorigin2 - self.iorigin1);
-
-       if(self.iflags & IFLAG_ANGLES)
-       {
-               fixedmakevectors(self.angles);
-               if(f0 & IFLAG_VALID)
-               {
-                       self.iforward1 = self.iforward2;
-                       self.iup1 = self.iup2;
-               }
-               else
-               {
-                       self.iforward1 = v_forward;
-                       self.iup1 = v_up;
-               }
-               self.iforward2 = v_forward;
-               self.iup2 = v_up;
-       }
-
-       if(self.iflags & IFLAG_VELOCITY)
-       {
-               self.ivelocity1 = self.ivelocity2;
-               self.ivelocity2 = self.velocity;
-       }
-
-       if(vlen(self.iorigin2 - self.iorigin1) > 1000)
-       {
-               self.itime1 = self.itime2 = time; // don't lerp
-       }
-
-       if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000))
-       {
-               self.itime1 = self.itime2 = time; // don't lerp
-       }
-
-       if(dt < 0.2)
-       {
-               self.itime1 = serverprevtime;
-               self.itime2 = time;
-       }
-       else
-       {
-               // don't lerp
-               self.itime1 = self.itime2 = time;
-       }
-}
-void InterpolateOrigin_Do()
-{
-       vector forward, up;
-       if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
-       {
-               float f;
-               f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1 + autocvar_cl_lerpexcess);
-               self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2;
-               if(self.iflags & IFLAG_ANGLES)
-               {
-                       forward = (1 - f) * self.iforward1 + f * self.iforward2;
-                       up = (1 - f) * self.iup1 + f * self.iup2;
-                       self.angles = fixedvectoangles2(forward, up);
-               }
-               if(self.iflags & IFLAG_VELOCITY)
-                       self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
-       }
-}
-void InterpolateOrigin_Undo()
-{
-       self.origin = self.iorigin2;
-       if(self.iflags & IFLAG_ANGLES)
-               self.angles = fixedvectoangles2(self.iforward2, self.iup2);
-       if(self.iflags & IFLAG_VELOCITY)
-               self.velocity = self.ivelocity2;
-}
-
diff --git a/qcsrc/client/interpolate.qh b/qcsrc/client/interpolate.qh
deleted file mode 100644 (file)
index a048803..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-.float iflags;
-#define IFLAG_VELOCITY 1
-#define IFLAG_ANGLES 2
-#define IFLAG_AUTOANGLES 4
-#define IFLAG_VALID 8
-#define IFLAG_PREVALID 16
-#define IFLAG_INTERNALMASK (IFLAG_VALID | IFLAG_PREVALID)
-
-// call this BEFORE reading an entity update
-void InterpolateOrigin_Undo();
-
-// call this AFTER receiving an entity update
-void InterpolateOrigin_Note();
-
-// call this when the entity got teleported, before InterpolateOrigin_Note
-void InterpolateOrigin_Reset();
-
-// call this BEFORE drawing
-void InterpolateOrigin_Do();
index 5ed3ab2e78fc6184186f1d43faeb58e32c0ca096..6ad35331ea5e67423a75c51afca8e5c197843fcf 100644 (file)
@@ -575,9 +575,15 @@ vector getplayerorigin(float pl)
        string s;
        entity e;
 
+       e = CSQCPlayer_GetPlayer(pl + 1);
+       if(e)
+               return e.origin;
+
+#ifndef NO_LEGACY_NETWORKING
        s = getplayerkeyvalue(pl, "TEMPHACK_origin");
        if(s != "")
                return stov(s);
+#endif
 
        e = entcs_receiver[pl];
        if(e)
index 06b3e8b7b751469e5d126a7aeb22bb9f3cb8e552..1a303f4f42d57916214aa3db15c804fce89f4294 100644 (file)
@@ -22,7 +22,7 @@ Defs.qc
 
 autocvars.qh
 
-interpolate.qh
+../csqcmodel/interpolate.qh
 teamradar.qh
 hud.qh
 scoreboard.qh
@@ -37,6 +37,10 @@ tturrets.qh
 ../server/movelib.qc
 main.qh
 vehicles/vehicles.qh
+../csqcmodel/settings.qh
+../csqcmodel/common.qh
+../csqcmodel/cl_model.qh
+../csqcmodel/cl_player.qh
 
 sortlist.qc
 miscfunctions.qc
@@ -47,6 +51,7 @@ hud_config.qc
 hud.qc
 scoreboard.qc
 mapvoting.qc
+csqcmodel_hooks.qc
 
 rubble.qc
 hook.qc
@@ -56,6 +61,8 @@ projectile.qc
 gibs.qc
 damage.qc
 casings.qc
+../csqcmodel/cl_model.qc
+../csqcmodel/cl_player.qc
 effects.qc
 wall.qc
 modeleffects.qc
@@ -69,7 +76,7 @@ shownames.qc
 announcer.qc
 Main.qc
 View.qc
-interpolate.qc
+../csqcmodel/interpolate.qc
 waypointsprites.qc
 movetypes.qc
 prandom.qc
index c0637fbe14c18b461ad30ae1871886d31fde3059..f7d97c5aa58f79a9b477c4cab1043799db2f3f93 100644 (file)
@@ -114,6 +114,7 @@ const float ENT_CLIENT_GAUNTLET = 29;
 const float ENT_CLIENT_ACCURACY = 30;
 const float ENT_CLIENT_SHOWNAMES = 31;
 const float ENT_CLIENT_WARPZONE_TELEPORTED = 32;
+const float ENT_CLIENT_MODEL = 33;
 
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
@@ -588,6 +589,32 @@ float HUD_MENU_ENABLE              = 0;
 #define SERVERFLAG_TEAMPLAY 2
 #define SERVERFLAG_PLAYERSTATS 4
 
+var vector autocvar_sv_player_maxs = '16 16 45';
+var vector autocvar_sv_player_mins = '-16 -16 -24';
+var vector autocvar_sv_player_viewoffset = '0 0 20';
+var vector autocvar_sv_player_crouch_maxs = '16 16 25';
+var vector autocvar_sv_player_crouch_mins = '-16 -16 -24';
+var vector autocvar_sv_player_crouch_viewoffset = '0 0 20';
+noref var vector autocvar_sv_player_headsize = '24 24 12';
+
+#define PL_VIEW_OFS autocvar_sv_player_viewoffset
+#define PL_MIN autocvar_sv_player_mins
+#define PL_MAX autocvar_sv_player_maxs
+#define PL_CROUCH_VIEW_OFS autocvar_sv_player_crouch_viewoffset
+#define PL_CROUCH_MIN autocvar_sv_player_crouch_mins
+#define PL_CROUCH_MAX autocvar_sv_player_crouch_maxs
+#define PL_HEAD autocvar_sv_player_headsize
+
+// helpers
+#define PL_VIEW_OFS_z autocvar_sv_player_viewoffset_z
+#define PL_MIN_z autocvar_sv_player_mins_z
+#define PL_MAX_z autocvar_sv_player_maxs_z
+#define PL_CROUCH_VIEW_OFS_z autocvar_sv_player_crouch_viewoffset_z
+#define PL_CROUCH_MIN_z autocvar_sv_player_mins_z
+#define PL_HEAD_x autocvar_sv_player_headsize_x
+#define PL_HEAD_y autocvar_sv_player_headsize_y
+#define PL_HEAD_z autocvar_sv_player_headsize_z
+
 // spawnpoint prios
 #define SPAWN_PRIO_NEAR_TEAMMATE_FOUND    200
 #define SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM 100
index 10e4e345b28298ead91a5420e4c0c11da92dc36b..10f77b6cdfedeb59629f375f4ca5cd9f9a4da2bd 100644 (file)
@@ -2107,3 +2107,14 @@ float lowestbit(float f)
        f &~= f * 65536;
        return f;
 }
+
+#ifdef CSQC
+entity ReadCSQCEntity()
+{
+       float f;
+       f = ReadShort();
+       if(f == 0)
+               return world;
+       return findfloat(world, entnum, f);
+}
+#endif
index 461cfd9b23876195f8731210e432a14d51d376b2..c4dabf296c5583079b2b7e9202b71ee771bbe767 100644 (file)
@@ -271,3 +271,7 @@ float xdecode(string s);
 #ifndef COMPAT_XON010_CHANNELS
 #define sound(e,c,s,v,a) sound7(e,c,s,v,a,0,0)
 #endif
+
+#ifdef CSQC
+entity ReadCSQCEntity()
+#endif
diff --git a/qcsrc/csqcmodel/cl_model.qc b/qcsrc/csqcmodel/cl_model.qc
new file mode 100644 (file)
index 0000000..c6d2923
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+var float autocvar_cl_lerpanim_maxdelta_framegroups = 0.1;
+var float autocvar_cl_nolerp = 0;
+
+.float csqcmodel_lerpfrac;
+.float csqcmodel_lerpfrac2;
+.float csqcmodel_lerpfractime;
+.float csqcmodel_lerpfrac2time;
+.float csqcmodel_teleported;
+
+void CSQCModel_InterpolateAnimation_PreNote(float sf)
+{
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+       if(sf & CSQCMODEL_PROPERTY_FRAME)
+       {
+               self.frame3 = self.frame;
+               self.frame3time = self.frame1time;
+       }
+       if(sf & CSQCMODEL_PROPERTY_FRAME2)
+       {
+               self.frame4 = self.frame2;
+               self.frame4time = self.frame2time;
+       }
+       if(sf & CSQCMODEL_PROPERTY_LERPFRAC)
+       {
+               self.csqcmodel_lerpfrac2 = self.csqcmodel_lerpfrac;
+               self.csqcmodel_lerpfrac2time = self.csqcmodel_lerpfractime;
+               self.lerpfrac = self.csqcmodel_lerpfrac;
+       }
+#else
+       if(sf & CSQCMODEL_PROPERTY_FRAME)
+       {
+               self.frame2 = self.frame;
+               self.frame2time = self.frame1time;
+       }
+#endif
+}
+
+void CSQCModel_InterpolateAnimation_Note(float sf)
+{
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+       if(sf & CSQCMODEL_PROPERTY_FRAME)
+       {
+               self.frame1time = time;
+       }
+       if(sf & CSQCMODEL_PROPERTY_FRAME2)
+       {
+               self.frame2time = time;
+       }
+       if(sf & CSQCMODEL_PROPERTY_LERPFRAC)
+       {
+               self.csqcmodel_lerpfrac = self.lerpfrac;
+               self.csqcmodel_lerpfractime = time;
+       }
+#else
+       if(sf & CSQCMODEL_PROPERTY_FRAME)
+       {
+               self.frame1time = time;
+       }
+#endif
+}
+
+void CSQCModel_InterpolateAnimation_Do()
+{
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+       if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
+       {
+               self.lerpfrac = self.csqcmodel_lerpfrac;
+               self.lerpfrac3 = 0;
+               self.lerpfrac4 = 0;
+       }
+       else
+       {
+               float l13, l24, llf;
+               float l24_13;
+
+               if(self.frame3time == 0) // if frame1/3 were not previously displayed, only frame1 can make sense
+                       l13 = 1;
+               else
+                       l13 = bound(0, (time - self.frame1time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+
+               if(self.frame4time == 0) // if frame2/4 were not previously displayed, only frame2 can make sense
+                       l24 = 1;
+               else
+                       l24 = bound(0, (time - self.frame2time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+
+               if(self.csqcmodel_lerpfrac2time == 0) // if there is no old lerpfrac (newly displayed model), only lerpfrac makes sense
+                       llf = 1;
+               else
+                       llf = bound(0, (time - self.csqcmodel_lerpfractime) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+
+               l24_13 = self.csqcmodel_lerpfrac * llf + self.csqcmodel_lerpfrac2 * (1 - llf);
+
+               self.lerpfrac  = l24 * l24_13;
+               self.lerpfrac4 = (1 - l24) * l24_13;
+               self.lerpfrac3 = (1 - l13) * (1 - l24_13);
+
+               if(l24_13 == 0) // if frames 2/4 are not displayed, clear their frametime
+               {
+                       self.frame2time = 0;
+                       self.frame4time = 0;
+               }
+
+               if(l24_13 == 1) // if frames 1/3 are not displayed, clear their frametime
+               {
+                       self.frame1time = 0;
+                       self.frame3time = 0;
+               }
+       }
+#else
+       if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
+       {
+               self.lerpfrac = 0;
+       }
+       else
+       {
+               self.lerpfrac = 1 - bound(0, (time - self.frame1time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+       }
+#endif
+}
+
+void CSQCModel_Draw()
+{
+       // some nice flags for CSQCMODEL_IF and the hooks
+       float isplayer = (self.entnum >= 1 && self.entnum <= maxclients);
+       float islocalplayer = (self.entnum == player_localnum + 1);
+       float isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1));
+
+       // we don't do this for the local player as that one is already handled
+       // by CSQCPlayer_SetCamera()
+       if(!CSQCPlayer_IsLocalPlayer())
+               InterpolateOrigin_Do();
+
+       // TODO csqcplayers: run prediction here too
+       CSQCModel_InterpolateAnimation_Do();
+
+       { CSQCMODEL_HOOK_PREDRAW }
+
+       // inherit draw flags easily
+       entity root = self;
+       while(root.tag_entity)
+               root = root.tag_entity;
+       if(self != root)
+       {
+               self.renderflags &~= RF_EXTERNALMODEL | RF_VIEWMODEL;
+               self.renderflags |= (root.renderflags & (RF_EXTERNALMODEL | RF_VIEWMODEL));
+       }
+}
+
+void CSQCModel_Read()
+{
+       float sf;
+       sf = ReadShort();
+
+       // some nice flags for CSQCMODEL_IF and the hooks
+       float isplayer = (self.entnum >= 1 && self.entnum <= maxclients);
+       float islocalplayer = (self.entnum == player_localnum + 1);
+       float isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1));
+
+       self.iflags |= IFLAG_ANGLES; // interpolate angles too
+
+       { CSQCMODEL_HOOK_PREUPDATE }
+
+       CSQCPlayer_PreUpdate();
+       InterpolateOrigin_Undo();
+       CSQCModel_InterpolateAnimation_PreNote(sf);
+
+#define CSQCMODEL_IF(cond) if(cond) {
+#define CSQCMODEL_ENDIF }
+#define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
+       if(sf & flag) \
+               self.f = r();
+#define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) \
+       if(sf & flag) \
+               self.f = r() / s;
+       ALLPROPERTIES
+#undef CSQCMODEL_PROPERTY_SCALED
+#undef CSQCMODEL_PROPERTY
+#undef CSQCMODEL_ENDIF
+#undef CSQCMODEL_IF
+
+       if(sf & CSQCMODEL_PROPERTY_MODELINDEX)
+               setmodelindex(self, self.modelindex); // this retrieves the .model key and sets mins/maxs/absmin/absmax
+
+       if(sf & CSQCMODEL_PROPERTY_TELEPORTED)
+       {
+               self.iflags |= IFLAG_TELEPORTED;
+               self.csqcmodel_teleported = 1;
+       }
+       
+       CSQCModel_InterpolateAnimation_Note(sf);
+       InterpolateOrigin_Note();
+       CSQCPlayer_PostUpdate();
+
+       { CSQCMODEL_HOOK_POSTUPDATE }
+
+#ifdef CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW
+       InterpolateOrigin_Do();
+       CSQCModel_InterpolateAnimation_Do();
+#endif
+
+       // relink
+       setorigin(self, self.origin);
+
+       // set obvious render flags
+#ifdef COMPAT_XON050_ENGINE
+       if(self.entnum == player_localentnum || self.entnum == spectatee_status)
+#else
+       if(self.entnum == player_localentnum)
+#endif
+               self.renderflags |= RF_EXTERNALMODEL;
+       else
+               self.renderflags &~= RF_EXTERNALMODEL;
+
+       // draw it
+       self.drawmask = MASK_NORMAL;
+       self.predraw = CSQCModel_Draw;
+}
diff --git a/qcsrc/csqcmodel/cl_model.qh b/qcsrc/csqcmodel/cl_model.qh
new file mode 100644 (file)
index 0000000..fba2151
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+void CSQCModel_Read();
+
+#define CSQCMODEL_IF(cond)
+#define CSQCMODEL_ENDIF
+#define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
+       .t f;
+#define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) CSQCMODEL_PROPERTY(flag,t,r,w,f)
+       ALLPROPERTIES
+#undef CSQCMODEL_PROPERTY_SCALED
+#undef CSQCMODEL_PROPERTY
+#undef CSQCMODEL_ENDIF
+#undef CSQCMODEL_IF
diff --git a/qcsrc/csqcmodel/cl_player.qc b/qcsrc/csqcmodel/cl_player.qc
new file mode 100644 (file)
index 0000000..4a7cf2e
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+var float autocvar_cl_predictionerrorcompensation = 0;
+
+// engine stuff
+.float pmove_flags;
+float pmove_onground; // weird engine flag we shouldn't really use but have to for now
+#define PMF_DUCKED 4
+#define PMF_ONGROUND 8
+#define REFDEFFLAG_TELEPORTED 1
+#define REFDEFFLAG_JUMPING 2
+
+entity csqcplayer;
+vector csqcplayer_origin, csqcplayer_velocity;
+float csqcplayer_sequence, player_pmflags;
+float csqcplayer_moveframe;
+vector csqcplayer_predictionerror;
+float csqcplayer_predictionerrortime;
+
+vector CSQCPlayer_GetPredictionError()
+{
+       if(!autocvar_cl_predictionerrorcompensation)
+               return '0 0 0';
+       if(time < csqcplayer_predictionerrortime)
+               return csqcplayer_predictionerror * (csqcplayer_predictionerrortime - time) * autocvar_cl_predictionerrorcompensation;
+       return '0 0 0';
+}
+
+void CSQCPlayer_SetPredictionError(vector v)
+{
+       if(!autocvar_cl_predictionerrorcompensation)
+               return;
+       csqcplayer_predictionerror = (csqcplayer_predictionerrortime - time) * autocvar_cl_predictionerrorcompensation * csqcplayer_predictionerror + v;
+       csqcplayer_predictionerrortime = time + 1.0 / autocvar_cl_predictionerrorcompensation;
+}
+
+void CSQCPlayer_Unpredict()
+{
+       if(csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED)
+               return;
+       if(csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED)
+               error("Cannot unpredict in current status");
+       self.origin = csqcplayer_origin;
+       self.velocity = csqcplayer_velocity;
+       csqcplayer_moveframe = csqcplayer_sequence+1; //+1 because the recieved frame has the move already done (server side)
+       self.pmove_flags = player_pmflags;
+}
+
+void CSQCPlayer_SetMinsMaxs()
+{
+       if(self.pmove_flags & PMF_DUCKED)
+       {
+               self.mins = PL_CROUCH_MIN;
+               self.maxs = PL_CROUCH_MAX;
+               self.view_ofs = PL_CROUCH_VIEW_OFS;
+       }
+       else
+       {
+               self.mins = PL_MIN;
+               self.maxs = PL_MAX;
+               self.view_ofs = PL_VIEW_OFS;
+       }
+}
+
+void CSQCPlayer_SavePrediction()
+{
+       player_pmflags = self.pmove_flags;
+       csqcplayer_origin = self.origin;
+       csqcplayer_velocity = self.velocity;
+       csqcplayer_sequence = servercommandframe;
+       csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
+}
+
+void CSQCPlayer_PredictTo(float endframe)
+{
+       CSQCPlayer_Unpredict();
+       CSQCPlayer_SetMinsMaxs();
+
+       csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
+
+       if (getstatf(STAT_HEALTH) <= 0)
+       {
+               csqcplayer_moveframe = clientcommandframe;
+               getinputstate(csqcplayer_moveframe-1);
+               return;
+       }
+
+       while(csqcplayer_moveframe < endframe)
+       {
+               if (!getinputstate(csqcplayer_moveframe))
+               {
+                       break;
+               }
+               runstandardplayerphysics(self);
+               CSQCPlayer_SetMinsMaxs();
+               csqcplayer_moveframe++;
+       }
+
+       //add in anything that was applied after (for low packet rate protocols)
+       input_angles = view_angles;
+}
+
+float CSQCPlayer_IsLocalPlayer()
+{
+       return (self == csqcplayer);
+}
+
+void(entity e, float fl) V_CalcRefdef = #640; // DP_CSQC_V_CALCREFDEF
+
+void CSQCPlayer_SetCamera()
+{
+       if(csqcplayer)
+       {
+               entity oldself;
+               oldself = self;
+               self = csqcplayer;
+
+#ifdef COMPAT_XON050_ENGINE
+               if(servercommandframe == 0 || !(checkextension("DP_CSQC_V_CALCREFDEF") || checkextension("DP_CSQC_V_CALCREFDEF_WIP1")))
+#else
+               if(servercommandframe == 0)
+#endif
+               {
+                       InterpolateOrigin_Do();
+                       self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+
+                       // get crouch state from the server
+                       if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
+                               self.pmove_flags &~= PMF_DUCKED;
+                       else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z)
+                               self.pmove_flags |= PMF_DUCKED;
+
+                       // get onground state from the server
+                       if(pmove_onground)
+                               self.pmove_flags |= PMF_ONGROUND;
+                       else
+                               self.pmove_flags &~= PMF_ONGROUND;
+
+                       CSQCPlayer_SetMinsMaxs();
+
+                       // override it back just in case
+                       self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+               }
+               else
+               {
+                       if(csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER)
+                       {
+                               vector o, v;
+                               o = self.origin;
+                               v = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
+                               csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
+                               CSQCPlayer_PredictTo(servercommandframe + 1);
+                               CSQCPlayer_SetPredictionError(o - self.origin);
+                               self.origin = o;
+                               self.velocity = v;
+
+                               // get crouch state from the server
+                               if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
+                                       self.pmove_flags &~= PMF_DUCKED;
+                               else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z)
+                                       self.pmove_flags |= PMF_DUCKED;
+
+                               // get onground state from the server
+                               if(pmove_onground)
+                                       self.pmove_flags |= PMF_ONGROUND;
+                               else
+                                       self.pmove_flags &~= PMF_ONGROUND;
+
+                               CSQCPlayer_SavePrediction();
+                       }
+                       CSQCPlayer_PredictTo(clientcommandframe);
+
+                       CSQCPlayer_SetMinsMaxs();
+               }
+
+               // relink
+               setorigin(self, self.origin);
+
+               // FIXME support svc_setview?
+
+               if(checkextension("DP_CSQC_V_CALCREFDEF") || checkextension("DP_CSQC_V_CALCREFDEF_WIP1"))
+               {
+                       var float refdefflags = 0;
+
+                       if(self.csqcmodel_teleported)
+                       {
+                               refdefflags |= REFDEFFLAG_TELEPORTED;
+                               self.csqcmodel_teleported = 0;
+                       }
+
+                       if(input_buttons & 4)
+                               refdefflags |= REFDEFFLAG_JUMPING;
+
+                       V_CalcRefdef(self, refdefflags);
+               }
+               else
+                       setproperty(VF_ORIGIN, self.origin + self.view_ofs);
+               self.angles_y = input_angles_y;
+
+               { CSQCPLAYER_HOOK_POSTCAMERASETUP }
+
+               self = oldself;
+       }
+}
+
+void CSQCPlayer_Remove()
+{
+       if(self.entnum != player_localnum + 1)
+               return;
+       csqcplayer = world;
+       cvar_clientsettemp("cl_movement_replay", "1");
+}
+
+float CSQCPlayer_PreUpdate()
+{
+       if(self.entnum != player_localnum + 1)
+               return 0;
+       cvar_clientsettemp("cl_movement_replay", "0");
+       if(csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER)
+               CSQCPlayer_Unpredict();
+       return 1;
+}
+
+float CSQCPlayer_PostUpdate()
+{
+       if(self.entnum != player_localentnum)
+               return 0;
+       csqcplayer_status = CSQCPLAYERSTATUS_FROMSERVER;
+       csqcplayer = self;
+       self.entremove = CSQCPlayer_Remove;
+       return 1;
+}
+
+entity CSQCPlayer_GetPlayer(float pl)
+{
+       return findfloat(world, entnum, pl); // FIXME optimize this using an array
+}
diff --git a/qcsrc/csqcmodel/cl_player.qh b/qcsrc/csqcmodel/cl_player.qh
new file mode 100644 (file)
index 0000000..f85c4e7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+float csqcplayer_status;
+#define CSQCPLAYERSTATUS_UNPREDICTED 0
+#define CSQCPLAYERSTATUS_FROMSERVER 1
+#define CSQCPLAYERSTATUS_PREDICTED 2
+
+void CSQCPlayer_SetCamera();
+float CSQCPlayer_PreUpdate();
+float CSQCPlayer_PostUpdate();
+float CSQCPlayer_IsLocalPlayer();
+entity CSQCPlayer_GetPlayer(float pl);
diff --git a/qcsrc/csqcmodel/common.qh b/qcsrc/csqcmodel/common.qh
new file mode 100644 (file)
index 0000000..587645c
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+noref string csqcmodel_license = "\
+Copyright (c) 2011 Rudolf Polzer\
+\
+Permission is hereby granted, free of charge, to any person obtaining a copy\
+of this software and associated documentation files (the \"Software\"), to\
+deal in the Software without restriction, including without limitation the\
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\
+sell copies of the Software, and to permit persons to whom the Software is\
+furnished to do so, subject to the following conditions:\
+\
+The above copyright notice and this permission notice shall be included in\
+all copies or substantial portions of the Software.\
+\
+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
+IN THE SOFTWARE.\
+";
+
+.vector glowmod;
+.vector view_ofs;
+.float frame;
+.float frame1time;
+.float frame2;
+.float frame2time;
+.float lerpfrac;
+
+#define CSQCMODEL_PROPERTY_FRAME 32768
+#define CSQCMODEL_PROPERTY_FRAME2 16384
+#define CSQCMODEL_PROPERTY_LERPFRAC 8192
+#define CSQCMODEL_PROPERTY_TELEPORTED 4096 // the "teleport bit" cancelling interpolation
+#define CSQCMODEL_PROPERTY_MODELINDEX 2048
+#define CSQCMODEL_PROPERTY_ORIGIN 1024
+#define CSQCMODEL_PROPERTY_YAW 512
+#define CSQCMODEL_PROPERTY_PITCHROLL 256
+
+#define ALLPROPERTIES_COMMON \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_FRAME, float, ReadByte, WriteByte, frame) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_MODELINDEX, float, ReadShort, WriteShort, modelindex) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_ORIGIN, float, ReadCoord, WriteCoord, origin_x) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_ORIGIN, float, ReadCoord, WriteCoord, origin_y) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_ORIGIN, float, ReadCoord, WriteCoord, origin_z) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_PITCHROLL, float, ReadAngle, WriteAngle, angles_x) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_YAW, float, ReadAngle, WriteAngle, angles_y) \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_PITCHROLL, float, ReadAngle, WriteAngle, angles_z) \
+       CSQCMODEL_EXTRAPROPERTIES
+
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+.float frame3;
+.float frame3time;
+.float lerpfrac3;
+.float frame4;
+.float frame4time;
+.float lerpfrac4;
+#define ALLPROPERTIES ALLPROPERTIES_COMMON \
+       CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_FRAME2, float, ReadByte, WriteByte, frame2) \
+       CSQCMODEL_PROPERTY_SCALED(CSQCMODEL_PROPERTY_LERPFRAC, float, ReadByte, WriteByte, lerpfrac, 255, 0, 255)
+#else
+#define ALLPROPERTIES ALLPROPERTIES_COMMON
+#endif
diff --git a/qcsrc/csqcmodel/interpolate.qc b/qcsrc/csqcmodel/interpolate.qc
new file mode 100644 (file)
index 0000000..ac0ba6e
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+.vector iorigin1, iorigin2;
+.vector ivelocity1, ivelocity2;
+.vector iforward1, iforward2;
+.vector iup1, iup2;
+.float itime1, itime2;
+void InterpolateOrigin_Reset()
+{
+       self.iflags &~= IFLAG_INTERNALMASK;
+       self.itime1 = self.itime2 = 0;
+}
+void InterpolateOrigin_Note()
+{
+       float dt;
+       float f0;
+
+       dt = time - self.itime2;
+
+       f0 = self.iflags;
+       if(self.iflags & IFLAG_PREVALID)
+               self.iflags |= IFLAG_VALID;
+       else
+               self.iflags |= IFLAG_PREVALID;
+
+       self.iorigin1 = self.iorigin2;
+       self.iorigin2 = self.origin;
+
+       if(self.iflags & IFLAG_AUTOANGLES)
+               if(self.iorigin2 != self.iorigin1)
+                       self.angles = vectoangles(self.iorigin2 - self.iorigin1);
+
+       if(self.iflags & IFLAG_ANGLES)
+       {
+               fixedmakevectors(self.angles);
+               if(f0 & IFLAG_VALID)
+               {
+                       self.iforward1 = self.iforward2;
+                       self.iup1 = self.iup2;
+               }
+               else
+               {
+                       self.iforward1 = v_forward;
+                       self.iup1 = v_up;
+               }
+               self.iforward2 = v_forward;
+               self.iup2 = v_up;
+       }
+
+       if(self.iflags & IFLAG_VELOCITY)
+       {
+               self.ivelocity1 = self.ivelocity2;
+               self.ivelocity2 = self.velocity;
+       }
+
+       if(self.iflags & IFLAG_TELEPORTED)
+       {
+               self.iflags &~= IFLAG_TELEPORTED;
+               self.itime1 = self.itime2 = time; // don't lerp
+       }
+       else if(vlen(self.iorigin2 - self.iorigin1) > 1000)
+       {
+               self.itime1 = self.itime2 = time; // don't lerp
+       }
+       else if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000))
+       {
+               self.itime1 = self.itime2 = time; // don't lerp
+       }
+       else if(dt >= 0.2)
+       {
+               self.itime1 = self.itime2 = time;
+       }
+       else
+       {
+               self.itime1 = serverprevtime;
+               self.itime2 = time;
+       }
+}
+void InterpolateOrigin_Do()
+{
+       vector forward, up;
+       if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
+       {
+               float f;
+               f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1 + autocvar_cl_lerpexcess);
+               self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2;
+               if(self.iflags & IFLAG_ANGLES)
+               {
+                       forward = (1 - f) * self.iforward1 + f * self.iforward2;
+                       up = (1 - f) * self.iup1 + f * self.iup2;
+                       self.angles = fixedvectoangles2(forward, up);
+               }
+               if(self.iflags & IFLAG_VELOCITY)
+                       self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
+       }
+}
+void InterpolateOrigin_Undo()
+{
+       self.origin = self.iorigin2;
+       if(self.iflags & IFLAG_ANGLES)
+               self.angles = fixedvectoangles2(self.iforward2, self.iup2);
+       if(self.iflags & IFLAG_VELOCITY)
+               self.velocity = self.ivelocity2;
+}
+
diff --git a/qcsrc/csqcmodel/interpolate.qh b/qcsrc/csqcmodel/interpolate.qh
new file mode 100644 (file)
index 0000000..8254fae
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+.float iflags;
+#define IFLAG_VELOCITY 1
+#define IFLAG_ANGLES 2
+#define IFLAG_AUTOANGLES 4
+#define IFLAG_VALID 8
+#define IFLAG_PREVALID 16
+#define IFLAG_TELEPORTED 32
+#define IFLAG_INTERNALMASK (IFLAG_VALID | IFLAG_PREVALID)
+
+// call this BEFORE reading an entity update
+void InterpolateOrigin_Undo();
+
+// call this AFTER receiving an entity update
+void InterpolateOrigin_Note();
+
+// call this when the entity got teleported, before InterpolateOrigin_Note
+void InterpolateOrigin_Reset();
+
+// call this BEFORE drawing
+void InterpolateOrigin_Do();
diff --git a/qcsrc/csqcmodel/settings.qh b/qcsrc/csqcmodel/settings.qh
new file mode 100644 (file)
index 0000000..a91385a
--- /dev/null
@@ -0,0 +1,80 @@
+// define this if svqc code wants to use .frame2 and .lerpfrac
+#define CSQCMODEL_HAVE_TWO_FRAMES
+
+// don't define this ever
+//#define CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW
+
+// a hack for Xonotic
+#ifdef CSQC
+# define TAG_ENTITY_NAME tag_networkentity
+# define TAG_ENTITY_TYPE float
+.float tag_networkentity;
+#else
+# define TAG_ENTITY_NAME tag_entity
+# define TAG_ENTITY_TYPE entity
+#endif
+
+// add properties you want networked to CSQC here
+#define CSQCMODEL_EXTRAPROPERTIES \
+       CSQCMODEL_PROPERTY(1, float, ReadShort, WriteShort, colormap) \
+       CSQCMODEL_PROPERTY(2, float, ReadInt24_t, WriteInt24_t, effects) \
+       CSQCMODEL_PROPERTY(4, float, ReadByte, WriteByte, modelflags) \
+       CSQCMODEL_PROPERTY_SCALED(8, float, ReadByte, WriteByte, alpha, 255, 0, 255) \
+       CSQCMODEL_PROPERTY(16, float, ReadByte, WriteByte, skin) \
+       CSQCMODEL_IF(isplayer) \
+       CSQCMODEL_ENDIF \
+       CSQCMODEL_IF(!isplayer) \
+               CSQCMODEL_PROPERTY(32, TAG_ENTITY_TYPE, ReadShort, WriteEntity, TAG_ENTITY_NAME) \
+               CSQCMODEL_PROPERTY_SCALED(64, float, ReadByte, WriteByte, glowmod_x, 255, 0, 255) \
+               CSQCMODEL_PROPERTY_SCALED(64, float, ReadByte, WriteByte, glowmod_y, 255, 0, 255) \
+               CSQCMODEL_PROPERTY_SCALED(64, float, ReadByte, WriteByte, glowmod_z, 255, 0, 255) \
+       CSQCMODEL_ENDIF
+// TODO get rid of colormod/glowmod here, find good solution for nex charge glowmod hack; also get rid of some useless properties on non-players that only exist for CopyBody
+
+// add hook function calls here
+#define CSQCMODEL_HOOK_PREUPDATE \
+       CSQCModel_Hook_PreUpdate(isplayer, islocalplayer);
+#define CSQCMODEL_HOOK_POSTUPDATE \
+       CSQCModel_Hook_PostUpdate(isplayer, islocalplayer);
+#define CSQCMODEL_HOOK_PREDRAW \
+       CSQCModel_Hook_PreDraw(isplayer, islocalplayer);
+#define CSQCPLAYER_HOOK_POSTCAMERASETUP
+
+// mod must define:
+//vector PL_MIN  = ...;
+//vector PL_MAX  = ...;
+//vector PL_VIEW_OFS  = ...;
+//vector PL_CROUCH_MIN  = ...;
+//vector PL_CROUCH_MAX  = ...;
+//vector PL_CROUCH_VIEW_OFS  = ...;
+
+#ifdef SVQC
+# ifdef NO_LEGACY_NETWORKING
+#  define CSQCMODEL_AUTOINIT() CSQCModel_LinkEntity()
+#  define CSQCMODEL_AUTOUPDATE() CSQCModel_CheckUpdate()
+# else
+.float iscsqcmodel;
+float autocvar_sv_use_csqc_players;
+#  define CSQCMODEL_AUTOINIT() \
+       if(autocvar_sv_use_csqc_players) \
+       { \
+               CSQCModel_LinkEntity(); \
+               self.iscsqcmodel = 1; \
+       } \
+       else \
+               self.iscsqcmodel = 0
+#  define CSQCMODEL_AUTOUPDATE() \
+       if(autocvar_sv_use_csqc_players && !self.iscsqcmodel) \
+       { \
+               CSQCModel_LinkEntity(); \
+               self.iscsqcmodel = 1; \
+       } \
+       if(!autocvar_sv_use_csqc_players && self.iscsqcmodel) \
+       { \
+               CSQCModel_UnlinkEntity(); \
+               self.iscsqcmodel = 0; \
+       } \
+       if(self.iscsqcmodel) \
+               CSQCModel_CheckUpdate()
+# endif
+#endif
diff --git a/qcsrc/csqcmodel/sv_model.qc b/qcsrc/csqcmodel/sv_model.qc
new file mode 100644 (file)
index 0000000..164c547
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+// generic CSQC model code
+
+float CSQCModel_Send(entity to, float sf)
+{
+       // some nice flags for CSQCMODEL_IF
+       float isplayer = (self.flags & FL_CLIENT);
+       float islocalplayer = (self == to);
+       float isnolocalplayer = (isplayer && (self != to));
+
+       WriteByte(MSG_ENTITY, ENT_CLIENT_MODEL);
+       WriteShort(MSG_ENTITY, sf);
+
+#define CSQCMODEL_IF(cond) if(cond) {
+#define CSQCMODEL_ENDIF }
+#define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
+       if(sf & flag) \
+       { \
+               w(MSG_ENTITY, self.csqcmodel_##f); \
+       }
+#define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) CSQCMODEL_PROPERTY(flag,t,r,w,f)
+       ALLPROPERTIES
+#undef CSQCMODEL_PROPERTY_SCALED
+#undef CSQCMODEL_PROPERTY
+#undef CSQCMODEL_ENDIF
+#undef CSQCMODEL_IF
+
+       return TRUE;
+}
+
+void CSQCModel_CheckUpdate()
+{
+       // some nice flags for CSQCMODEL_IF
+       float isplayer = (self.flags & FL_CLIENT);
+       float islocalplayer = isplayer; // we set BOTH to 1 here as we need the sendflags
+       float isnolocalplayer = isplayer; // we set BOTH to 1 here as we need the sendflags
+
+       if(self.effects & EF_RESTARTANIM_BIT)
+       {
+               self.SendFlags |= CSQCMODEL_PROPERTY_FRAME | CSQCMODEL_PROPERTY_FRAME2; // full anim resend please
+               self.effects &~= EF_RESTARTANIM_BIT;
+       }
+
+       if(self.effects & EF_TELEPORT_BIT)
+       {
+               self.SendFlags |= CSQCMODEL_PROPERTY_TELEPORTED; // no interpolation please
+               self.effects &~= EF_TELEPORT_BIT;
+       }
+
+#define CSQCMODEL_IF(cond) if(cond) {
+#define CSQCMODEL_ENDIF }
+#define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
+       { \
+               t tmp = self.f; \
+               if(tmp != self.csqcmodel_##f) \
+               { \
+                       self.csqcmodel_##f = tmp; \
+                       self.SendFlags |= flag; \
+               } \
+       }
+#define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) \
+       { \
+               t tmp = bound(mi, s * self.f, ma); \
+               if(tmp != self.csqcmodel_##f) \
+               { \
+                       self.csqcmodel_##f = tmp; \
+                       self.SendFlags |= flag; \
+               } \
+       }
+       ALLPROPERTIES
+#undef CSQCMODEL_PROPERTY_SCALED
+#undef CSQCMODEL_PROPERTY
+#undef CSQCMODEL_ENDIF
+#undef CSQCMODEL_IF
+}
+
+void CSQCModel_LinkEntity()
+{
+       self.SendEntity = CSQCModel_Send;
+       self.SendFlags = 0xFFFFFF;
+}
+
+void CSQCModel_UnlinkEntity()
+{
+       self.SendEntity = func_null;
+}
diff --git a/qcsrc/csqcmodel/sv_model.qh b/qcsrc/csqcmodel/sv_model.qh
new file mode 100644 (file)
index 0000000..3c4ce2b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+// generic CSQC model code
+
+void CSQCModel_CheckUpdate();
+void CSQCModel_LinkEntity();
+void CSQCModel_UnlinkEntity();
+
+#define CSQCMODEL_IF(cond)
+#define CSQCMODEL_ENDIF
+#define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
+       .t f; \
+       .t csqcmodel_##f;
+#define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) CSQCMODEL_PROPERTY(flag,t,r,w,f)
+       ALLPROPERTIES
+#undef CSQCMODEL_PROPERTY_SCALED
+#undef CSQCMODEL_PROPERTY
+#undef CSQCMODEL_ENDIF
+#undef CSQCMODEL_IF
index bb5f2137f47a19c5872ef2e8e6feb7fbaeec0501..3ebb09ad3954c8307a787c45673ebcf2a674f563 100644 (file)
@@ -1204,6 +1204,191 @@ float log(float f) = #532;
 //description:
 //logarithm
 
+//FTE_CSQC_SKELETONOBJECTS
+//idea: Spike, LordHavoc
+//darkplaces implementation: LordHavoc
+//builtin definitions:
+// all skeleton numbers are 1-based (0 being no skeleton)
+// all bone numbers are 1-based (0 being invalid)
+float(float modlindex) skel_create = #263; // create a skeleton (be sure to assign this value into .skeletonindex for use), returns skeleton index (1 or higher) on success, returns 0 on failure (for example if the modelindex is not skeletal), it is recommended that you create a new skeleton if you change modelindex, as the skeleton uses the hierarchy from the model.
+float(float skel, entity ent, float modlindex, float retainfrac, float firstbone, float lastbone) skel_build = #264; // blend in a percentage of standard animation, 0 replaces entirely, 1 does nothing, 0.5 blends half, etc, and this only alters the bones in the specified range for which out of bounds values like 0,100000 are safe (uses .frame, .frame2, .frame3, .frame4, .lerpfrac, .lerpfrac3, .lerpfrac4, .frame1time, .frame2time, .frame3time, .frame4time), returns skel on success, 0 on failure
+float(float skel) skel_get_numbones = #265; // returns how many bones exist in the created skeleton, 0 if skeleton does not exist
+string(float skel, float bonenum) skel_get_bonename = #266; // returns name of bone (as a tempstring), "" if invalid bonenum (< 1 for example) or skeleton does not exist
+float(float skel, float bonenum) skel_get_boneparent = #267; // returns parent num for supplied bonenum, 0 if bonenum has no parent or bone does not exist (returned value is always less than bonenum, you can loop on this)
+float(float skel, string tagname) skel_find_bone = #268; // get number of bone with specified name, 0 on failure, bonenum (1-based) on success, same as using gettagindex but takes modelindex instead of entity
+vector(float skel, float bonenum) skel_get_bonerel = #269; // get matrix of bone in skeleton relative to its parent - sets v_forward, v_right, v_up, returns origin (relative to parent bone)
+vector(float skel, float bonenum) skel_get_boneabs = #270; // get matrix of bone in skeleton in model space - sets v_forward, v_right, v_up, returns origin (relative to entity)
+void(float skel, float bonenum, vector org) skel_set_bone = #271; // set matrix of bone relative to its parent, reads v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
+void(float skel, float bonenum, vector org) skel_mul_bone = #272; // transform bone matrix (relative to its parent) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
+void(float skel, float startbone, float endbone, vector org) skel_mul_bones = #273; // transform bone matrices (relative to their parents) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bones)
+void(float skeldst, float skelsrc, float startbone, float endbone) skel_copybones = #274; // copy bone matrices (relative to their parents) from one skeleton to another, useful for copying a skeleton to a corpse
+void(float skel) skel_delete = #275; // deletes skeleton at the beginning of the next frame (you can add the entity, delete the skeleton, renderscene, and it will still work)
+float(float modlindex, string framename) frameforname = #276; // finds number of a specified frame in the animation, returns -1 if no match found
+float(float modlindex, float framenum) frameduration = #277; // returns the intended play time (in seconds) of the specified framegroup, if it does not exist the result is 0, if it is a single frame it may be a small value around 0.1 or 0.
+//fields:
+.float skeletonindex; // active skeleton overriding standard animation on model
+.float frame; // primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
+.float frame2; // secondary framegroup animation (strength = lerpfrac)
+.float frame3; // tertiary framegroup animation (strength = lerpfrac3)
+.float frame4; // quaternary framegroup animation (strength = lerpfrac4)
+.float lerpfrac; // strength of framegroup blend
+.float lerpfrac3; // strength of framegroup blend
+.float lerpfrac4; // strength of framegroup blend
+.float frame1time; // start time of framegroup animation
+.float frame2time; // start time of framegroup animation
+.float frame3time; // start time of framegroup animation
+.float frame4time; // start time of framegroup animation
+//description:
+//this extension provides a way to do complex skeletal animation on an entity.
+//
+//see also DP_SKELETONOBJECTS (this extension implemented on server as well as client)
+//
+//notes:
+//each model contains its own skeleton, reusing a skeleton with incompatible models will yield garbage (or not render).
+//each model contains its own animation data, you can use animations from other model files (for example saving out all character animations as separate model files).
+//if an engine supports loading an animation-only file format such as .md5anim in FTEQW, it can be used to animate any model with a compatible skeleton.
+//proper use of this extension may require understanding matrix transforms (v_forward, v_right, v_up, origin), and you must keep in mind that v_right is negative for this purpose.
+//
+//features include:
+//multiple animations blended together.
+//animating a model with animations from another model with a compatible skeleton.
+//restricting animation blends to certain bones of a model - for example independent animation of legs, torso, head.
+//custom bone controllers - for example making eyes track a target location.
+//
+//
+//
+//example code follows...
+//
+//this helper function lets you identify (by parentage) what group a bone
+//belongs to - for example "torso", "leftarm", would return 1 ("torso") for
+//all children of the bone named "torso", unless they are children of
+//"leftarm" (which is a child of "torso") which would return 2 instead...
+float(float skel, float bonenum, string g1, string g2, string g3, string g4, string g5, string g6) example_skel_findbonegroup =
+{
+       local string bonename;
+       while (bonenum >= 0)
+       {
+               bonename = skel_get_bonename(skel, bonenum);
+               if (bonename == g1) return 1;
+               if (bonename == g2) return 2;
+               if (bonename == g3) return 3;
+               if (bonename == g4) return 4;
+               if (bonename == g5) return 5;
+               if (bonename == g6) return 6;
+               bonenum = skel_get_boneparent(skel, bonenum);
+       }
+       return 0;
+};
+// create a skeletonindex for our player using current modelindex
+void() example_skel_player_setup =
+{
+       self.skeletonindex = skel_create(self.modelindex);
+};
+// setup bones of skeleton based on an animation
+// note: animmodelindex can be a different model than self.modelindex
+void(float animmodelindex, float framegroup, float framegroupstarttime) example_skel_player_update_begin =
+{
+       // start with our standard animation
+       self.frame = framegroup;
+       self.frame2 = 0;
+       self.frame3 = 0;
+       self.frame4 = 0;
+       self.frame1time = framegroupstarttime;
+       self.frame2time = 0;
+       self.frame3time = 0;
+       self.frame4time = 0;
+       self.lerpfrac = 0;
+       self.lerpfrac3 = 0;
+       self.lerpfrac4 = 0;
+       skel_build(self.skeletonindex, self, animmodelindex, 0, 0, 100000);
+};
+// apply a different framegroup animation to bones with a specified parent
+void(float animmodelindex, float framegroup, float framegroupstarttime, float blendalpha, string groupbonename, string excludegroupname1, string excludegroupname2) example_skel_player_update_applyoverride =
+{
+       local float bonenum;
+       local float numbones;
+       self.frame = framegroup;
+       self.frame2 = 0;
+       self.frame3 = 0;
+       self.frame4 = 0;
+       self.frame1time = framegroupstarttime;
+       self.frame2time = 0;
+       self.frame3time = 0;
+       self.frame4time = 0;
+       self.lerpfrac = 0;
+       self.lerpfrac3 = 0;
+       self.lerpfrac4 = 0;
+       bonenum = 0;
+       numbones = skel_get_numbones(self.skeletonindex);
+       while (bonenum < numbones)
+       {
+               if (example_skel_findbonegroup(self.skeletonindex, bonenum, groupbonename, excludegroupname1, excludegroupname2, "", "", "") == 1)
+                       skel_build(self.skeletonindex, self, animmodelindex, 1 - blendalpha, bonenum, bonenum + 1);
+               bonenum = bonenum + 1;
+       }
+};
+// make eyes point at a target location, be sure v_forward, v_right, v_up are set correctly before calling
+void(vector eyetarget, string bonename) example_skel_player_update_eyetarget =
+{
+       local float bonenum;
+       local vector ang;
+       local vector oldforward, oldright, oldup;
+       local vector relforward, relright, relup, relorg;
+       local vector boneforward, boneright, boneup, boneorg;
+       local vector parentforward, parentright, parentup, parentorg;
+       local vector u, v;
+       local vector modeleyetarget;
+       bonenum = skel_find_bone(self.skeletonindex, bonename) - 1;
+       if (bonenum < 0)
+               return;
+       oldforward = v_forward;
+       oldright = v_right;
+       oldup = v_up;
+       v = eyetarget - self.origin;
+       modeleyetarget_x =   v * v_forward;
+       modeleyetarget_y = 0-v * v_right;
+       modeleyetarget_z =   v * v_up;
+       // this is an eyeball, make it point at the target location
+       // first get all the data we can...
+       relorg = skel_get_bonerel(self.skeletonindex, bonenum);
+       relforward = v_forward;
+       relright = v_right;
+       relup = v_up;
+       boneorg = skel_get_boneabs(self.skeletonindex, bonenum);
+       boneforward = v_forward;
+       boneright = v_right;
+       boneup = v_up;
+       parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum));
+       parentforward = v_forward;
+       parentright = v_right;
+       parentup = v_up;
+       // get the vector from the eyeball to the target
+       u = modeleyetarget - boneorg;
+       // now transform it inversely by the parent matrix to produce new rel vectors
+       v_x = u * parentforward;
+       v_y = u * parentright;
+       v_z = u * parentup;
+       ang = vectoangles2(v, relup);
+       ang_x = 0 - ang_x;
+       makevectors(ang);
+       // set the relative bone matrix
+       skel_set_bone(self.skeletonindex, bonenum, relorg);
+       // restore caller's v_ vectors
+       v_forward = oldforward;
+       v_right = oldright;
+       v_up = oldup;
+};
+// delete skeleton when we're done with it
+// note: skeleton remains valid until next frame when it is really deleted
+void() example_skel_player_delete =
+{
+       skel_delete(self.skeletonindex);
+       self.skeletonindex = 0;
+};
+//
+// END OF EXAMPLES FOR FTE_CSQC_SKELETONOBJECTS
+//
+
 // assorted builtins
 const float            STAT_MOVEVARS_TICRATE           = 240;
 const float            STAT_MOVEVARS_TIMESCALE         = 241;
index 2711c57e7f1eb53789d075a560557c870e5fdddc..ac2d71e4811aed58b51f6954b6e6e04afd29b8e0 100644 (file)
@@ -96,6 +96,10 @@ string XonoticMutatorsDialog_toString(entity me)
                s = strcat(s, ", ", _("Blood loss"));
        if(cvar("g_jetpack"))
                s = strcat(s, ", ", _("Jet pack"));
+       if(cvar("g_powerups") == 0)
+               s = strcat(s, ", ", _("No powerups"));
+       if(cvar("g_powerups") > 0)
+               s = strcat(s, ", ", _("Powerups"));
        if(s == "")
                return ZCTX(_("MUT^None"));
        else
@@ -212,7 +216,7 @@ void XonoticMutatorsDialog_fill(entity me)
                me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_pinata", _("Piñata")));
        me.TR(me);
                me.TDempty(me, 0.2);
-               me.TD(me, 1, 2, e = makeXonoticCheckBoxEx(2, 0, "g_weapon_stay", _("Weapons stay")));
+               me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "g_weapon_stay", _("Weapons stay")));
        me.TR(me);
 
        me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
index 6748ef875f75f9e1627dda3b7c8d2072e70f6450..760eff311164f88efd228caa26b565c9c39d2166 100644 (file)
@@ -64,13 +64,13 @@ void XonoticPlayerSettingsTab_fill(entity me)
                me.TD(me, 1, 0.3, e = makeXonoticButton("<<", '0 0 0'));
                        e.onClick = PlayerModelSelector_Prev_Click;
                        e.onClickEntity = pms;
-               me.TD(me, me.rows - me.currentRow - 1, 1.8, pms);
+               me.TD(me, me.rows - me.currentRow - 2, 1.8, pms);
                me.TD(me, 1, 0.3, e = makeXonoticButton(">>", '0 0 0'));
                        e.onClick = PlayerModelSelector_Next_Click;
                        e.onClickEntity = pms;
        me.TR(me);
                r = me.currentRow;
-               m = me.rows - r - 2;
+               m = me.rows - r - 3;
                n = 16 - !cvar("developer");
                m = m / (n - 1);
                for(i = 0; i < n; ++i)
@@ -83,6 +83,8 @@ void XonoticPlayerSettingsTab_fill(entity me)
                        me.gotoRC(me, r + i * m, 0.4);
                        me.TDNoMargin(me, m, 0.2, e = makeXonoticColorButton(2, 1, i), '0 1 0');
                }
+       me.gotoRC(me, me.rows - 2, 0);
+               me.TD(me, 1, 3, e = makeXonoticCheckBox(0, "cl_forceplayermodels", _("Force player models to mine")));
 
        me.gotoRC(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Field of view:")));
index 8f45f5367e2ae88756d0fef15a65ea961cb5ab87..c6c29817aed4a806509796e7fa28d07e4cf6d043 100644 (file)
@@ -73,7 +73,6 @@ float autocvar_g_antilag_nudge;
 float autocvar_g_arena_maxspawned;
 float autocvar_g_arena_point_leadlimit;
 float autocvar_g_arena_point_limit;
-float autocvar_g_arena_powerups;
 float autocvar_g_arena_roundbased;
 float autocvar_g_arena_warmup;
 float autocvar_g_assault;
@@ -566,7 +565,6 @@ float autocvar_g_balance_powerup_strength_force;
 float autocvar_g_balance_powerup_strength_selfdamage;
 float autocvar_g_balance_powerup_strength_selfforce;
 float autocvar_g_balance_powerup_strength_time;
-float autocvar_g_balance_powerup_timer;
 float autocvar_g_balance_rocketlauncher_ammo;
 float autocvar_g_balance_rocketlauncher_animtime;
 float autocvar_g_balance_rocketlauncher_damage;
@@ -779,7 +777,6 @@ float autocvar_g_ctf_shield_max_ratio;
 float autocvar_g_ctf_shield_min_negscore;
 float autocvar_g_cts_finish_kill_delay;
 float autocvar_g_cts_selfdamage;
-float autocvar_g_deathglow;
 float autocvar_g_debug_bot_commands;
 float autocvar_g_domination_default_teams;
 float autocvar_g_domination_disable_frags;
@@ -925,9 +922,7 @@ float autocvar_g_player_alpha;
 float autocvar_g_player_brightness;
 float autocvar_g_playerclip_collisions;
 string autocvar_g_playerstats_uri;
-float autocvar_g_powerup_shield;
-float autocvar_g_powerup_strength;
-float autocvar_g_powerup_superhealth;
+float autocvar_g_powerups;
 float autocvar_g_projectiles_damage;
 float autocvar_g_projectiles_newton_style;
 float autocvar_g_projectiles_newton_style_2_maxfactor;
@@ -1129,13 +1124,6 @@ float autocvar_sv_maxairspeed;
 float autocvar_sv_maxairstrafespeed;
 float autocvar_sv_maxspeed;
 string autocvar_sv_motd;
-string autocvar_sv_player_crouch_maxs;
-string autocvar_sv_player_crouch_mins;
-string autocvar_sv_player_crouch_viewoffset;
-string autocvar_sv_player_headsize;
-string autocvar_sv_player_maxs;
-string autocvar_sv_player_mins;
-string autocvar_sv_player_viewoffset;
 float autocvar_sv_player_jumpanim_minfall;
 float autocvar_sv_precacheplayermodels;
 float autocvar_sv_precacheweapons;
index fc484066d5d7a0268dec4bf971fa8402239f20ba..57a09fe3808ac8997b2a557010fb442e24827dc8 100644 (file)
@@ -228,7 +228,7 @@ float CheatImpulse(float i)
                        IS_CHEAT(i, 0, 0);
                        FOR_EACH_PLAYER(e)
                        {
-                               get_model_parameters(e.playermodel, e.skinindex);
+                               get_model_parameters(e.playermodel, e.skin);
                                if(get_model_parameters_sex == "Female")
                                {
                                        makevectors(e.angles);
index a29742a335e4e7047b7dcdeded0366acbb4fc7b8..bcba20cc1b023e01ed1089a43872cbdc17ede50e 100644 (file)
@@ -341,160 +341,36 @@ string CheckPlayerModel(string plyermodel) {
                // to change a cvar default, we'll have a small leak here.
                FallbackPlayerModel = strzone(cvar_defstring("_cl_playermodel"));
        }
-       if(strlen(plyermodel) < 4)
-               return FallbackPlayerModel;
+       // only in right path
        if( substring(plyermodel,0,14) != "models/player/")
                return FallbackPlayerModel;
-       else if(autocvar_sv_servermodelsonly)
+       // only good file extensions
+       if(substring(plyermodel,-4,4) != ".zym")
+       if(substring(plyermodel,-4,4) != ".dpm")
+       if(substring(plyermodel,-4,4) != ".iqm")
+       if(substring(plyermodel,-4,4) != ".md3")
+       if(substring(plyermodel,-4,4) != ".psk")
+               return FallbackPlayerModel;
+       // forbid the LOD models
+       if(substring(plyermodel, -9,5) == "_lod1")
+               return FallbackPlayerModel;
+       if(substring(plyermodel, -9,5) == "_lod2")
+               return FallbackPlayerModel;
+       if(plyermodel != strtolower(plyermodel))
+               return FallbackPlayerModel;
+       // also, restrict to server models
+       if(autocvar_sv_servermodelsonly)
        {
-               if(substring(plyermodel,-4,4) != ".zym")
-               if(substring(plyermodel,-4,4) != ".dpm")
-               if(substring(plyermodel,-4,4) != ".iqm")
-               if(substring(plyermodel,-4,4) != ".md3")
-               if(substring(plyermodel,-4,4) != ".psk")
-                       return FallbackPlayerModel;
-               // forbid the LOD models
-               if(substring(plyermodel, -9,5) == "_lod1")
-                       return FallbackPlayerModel;
-               if(substring(plyermodel, -9,5) == "_lod2")
-                       return FallbackPlayerModel;
-               if(plyermodel != strtolower(plyermodel))
-                       return FallbackPlayerModel;
                if(!fexists(plyermodel))
                        return FallbackPlayerModel;
        }
        return plyermodel;
 }
 
-/*
-=============
-Client_customizeentityforclient
-
-LOD reduction
-=============
-*/
-void Client_uncustomizeentityforclient()
-{
-       if(self.modelindex == 0) // no need to uncustomize then
-               return;
-       self.modelindex = self.modelindex_lod0;
-       self.skin = self.skinindex;
-}
-
-float Client_customizeentityforclient()
-{
-       entity modelsource;
-
-       if(self.modelindex == 0)
-               return TRUE;
-
-       // forcemodel stuff
-
-#ifdef PROFILING
-       float t0;
-       t0 = gettime(GETTIME_HIRES); // reference
-#endif
-
-       modelsource = self;
-
-#ifdef ALLOW_FORCEMODELS
-       if(other.cvar_cl_forceplayermodelsfromxonotic)
-               if not(self.modelindex_lod0_from_xonotic)
-                       modelsource = other;
-       if(other.cvar_cl_forceplayermodels && sv_clforceplayermodels)
-               modelsource = other;
-#endif
-
-       self.skin = modelsource.skinindex;
-
-#if 0
-       if(modelsource == self)
-               self.skin = modelsource.skinindex;
-       else
-               self.skin = mod(modelsource.skinindex, 3); // forbid the fbskins as forced skins
-#endif
-
-       // self: me
-       // other: the player viewing me
-       float distance;
-       float f;
-
-       if(other.cvar_cl_playerdetailreduction <= 0)
-       {
-               if(other.cvar_cl_playerdetailreduction <= -2)
-                       self.modelindex = modelsource.modelindex_lod2;
-               else if(other.cvar_cl_playerdetailreduction <= -1)
-                       self.modelindex = modelsource.modelindex_lod1;
-               else
-                       self.modelindex = modelsource.modelindex_lod0;
-       }
-       else
-       {
-               distance = vlen(self.origin - other.origin);
-               f = (distance + 100.0) * other.cvar_cl_playerdetailreduction;
-               if(f > sv_loddistance2)
-                       self.modelindex = modelsource.modelindex_lod2;
-               else if(f > sv_loddistance1)
-                       self.modelindex = modelsource.modelindex_lod1;
-               else
-                       self.modelindex = modelsource.modelindex_lod0;
-       }
-
-#ifdef PROFILING
-       float t1;
-       t1 = gettime(GETTIME_HIRES); // reference
-       client_cefc_accumulator += (t1 - t0);
-#endif
-
-       return TRUE;
-}
-
-void setmodel_lod(entity e, string modelname)
+void setplayermodel(entity e, string modelname)
 {
-       string s;
-
-       if(sv_loddistance1)
-       {
-               // FIXME: this only supports 3-letter extensions
-               s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
-               if(fexists(s))
-               {
-                       setmodel(e, s); // players have high precision
-                       self.modelindex_lod1 = self.modelindex;
-               }
-               else
-                       self.modelindex_lod1 = -1;
-
-               s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
-               if(fexists(s))
-               {
-                       setmodel(e, s); // players have high precision
-                       self.modelindex_lod2 = self.modelindex;
-               }
-               else
-                       self.modelindex_lod2 = -1;
-
-               precache_model(modelname);
-               setmodel(e, modelname); // players have high precision
-               self.modelindex_lod0 = self.modelindex;
-
-               if(self.modelindex_lod1 < 0)
-                       self.modelindex_lod1 = self.modelindex;
-
-               if(self.modelindex_lod2 < 0)
-                       self.modelindex_lod2 = self.modelindex;
-       }
-       else
-       {
-               precache_model(modelname);
-               setmodel(e, modelname); // players have high precision
-               self.modelindex_lod0 = self.modelindex;
-                       // save it for possible player model forcing
-       }
-
-       s = whichpack(self.model);
-       self.modelindex_lod0_from_xonotic = ((s == "") || (substring(s, 0, 4) == "data"));
-
+       precache_model(modelname);
+       setmodel(e, modelname);
        player_setupanimsformodel();
        UpdatePlayerSounds();
 }
@@ -610,16 +486,18 @@ void PutObserverInServer (void)
        self.fixangle = TRUE;
        self.crouch = FALSE;
 
-       self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
        setorigin (self, spot.origin);
-       setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
        self.prevorigin = self.origin;
        self.items = 0;
        self.weapons = 0;
        self.model = "";
        FixPlayermodel();
-       self.model = "";
-       self.modelindex = 0;
+       setmodel(self, "null");
+       self.drawonlytoclient = self;
+
+       setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
+       self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
+
        self.weapon = 0;
        self.weaponname = "";
        self.switchingweapon = 0;
@@ -634,9 +512,6 @@ void PutObserverInServer (void)
        self.oldvelocity = self.velocity;
        self.fire_endtime = -1;
 
-       if(sv_loddistance1)
-               SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
-
        if(g_arena)
        {
                if(self.version_mismatch)
@@ -723,29 +598,29 @@ void FixPlayermodel()
                {
                        m1 = self.mins;
                        m2 = self.maxs;
-                       setmodel_lod (self, defaultmodel);
+                       setplayermodel (self, defaultmodel);
                        setsize (self, m1, m2);
                        chmdl = TRUE;
                }
 
-               oldskin = self.skinindex;
-               self.skinindex = defaultskin;
+               oldskin = self.skin;
+               self.skin = defaultskin;
        } else {
                if (self.playermodel != self.model || self.playermodel == "")
                {
                        self.playermodel = CheckPlayerModel(self.playermodel); // this is never "", so no endless loop
                        m1 = self.mins;
                        m2 = self.maxs;
-                       setmodel_lod (self, self.playermodel);
+                       setplayermodel (self, self.playermodel);
                        setsize (self, m1, m2);
                        chmdl = TRUE;
                }
 
-               oldskin = self.skinindex;
-               self.skinindex = stof(self.playerskin);
+               oldskin = self.skin;
+               self.skin = stof(self.playerskin);
        }
 
-       if(chmdl || oldskin != self.skinindex)
+       if(chmdl || oldskin != self.skin)
                self.species = player_getspecies(); // model or skin has changed
 
        if(!teamplay)
@@ -852,6 +727,7 @@ void PutClientInServer (void)
                        self.effects = EF_FULLBRIGHT;
                else
                        self.effects = 0;
+               self.effects |= EF_TELEPORT_BIT | EF_RESTARTANIM_BIT;
                self.air_finished = time + 12;
                self.dmg = 2;
                if(autocvar_g_balance_nex_charge)
@@ -949,11 +825,9 @@ void PutClientInServer (void)
                        WriteByte(MSG_ONE, TE_CSQC_SPAWN);
                });
 
-               if(sv_loddistance1)
-                       SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
-
                self.model = "";
                FixPlayermodel();
+               self.drawonlytoclient = world;
 
                self.crouch = FALSE;
                self.view_ofs = PL_VIEW_OFS;
@@ -1318,7 +1192,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                        self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
                }
 
-               if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
+               if(killtime <= 0 || self.classname != "player" || self.deadflag != DEAD_NO)
                {
                        ClientKill_Now();
                }
@@ -1726,6 +1600,8 @@ void ClientConnect (void)
        if(!autocvar_g_campaign)
                Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), autocvar_welcome_message_time, 0);
 
+       CSQCMODEL_AUTOINIT();
+
        self.model_randomizer = random();
 }
 
@@ -1979,7 +1855,7 @@ void player_powerups (void)
                if (self.items & IT_INVINCIBLE)
                {
                        play_countdown(self.invincible_finished, "misc/poweroff.wav");
-                       if (time > self.invincible_finished && autocvar_g_balance_powerup_timer)
+                       if (time > self.invincible_finished)
                        {
                                self.items = self.items - (self.items & IT_INVINCIBLE);
                                sprint(self, "^3Speed has worn off\n");
@@ -2000,7 +1876,7 @@ void player_powerups (void)
                {
                        play_countdown(self.strength_finished, "misc/poweroff.wav");
                        self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
-                       if (time > self.strength_finished && autocvar_g_balance_powerup_timer)
+                       if (time > self.strength_finished)
                        {
                                self.items = self.items - (self.items & IT_STRENGTH);
                                sprint(self, "^3Strength has worn off\n");
@@ -2018,7 +1894,7 @@ void player_powerups (void)
                {
                        play_countdown(self.invincible_finished, "misc/poweroff.wav");
                        self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
-                       if (time > self.invincible_finished && autocvar_g_balance_powerup_timer)
+                       if (time > self.invincible_finished)
                        {
                                self.items = self.items - (self.items & IT_INVINCIBLE);
                                sprint(self, "^3Shield has worn off\n");
@@ -2746,42 +2622,26 @@ void PlayerPreThink (void)
 
                if(frametime)
                {
-                       if(self.health <= 0 && autocvar_g_deathglow)
-                       {
-                               if(self.glowmod_x > 0)
-                                       self.glowmod_x -= autocvar_g_deathglow * frametime;
-                               else
-                                       self.glowmod_x = -1;
-                               if(self.glowmod_y > 0)
-                                       self.glowmod_y -= autocvar_g_deathglow * frametime;
-                               else
-                                       self.glowmod_y = -1;
-                               if(self.glowmod_z > 0)
-                                       self.glowmod_z -= autocvar_g_deathglow * frametime;
-                               else
-                                       self.glowmod_z = -1;
-                       }
-                       else
+#ifndef NO_LEGACY_NETWORKING
+                       self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
+#endif
+
+                       if(self.weapon == WEP_NEX && autocvar_g_balance_nex_charge)
                        {
-                               // set weapon and player glowmod
-                               self.glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
+                               self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
+                               self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
+                               self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
 
-                               if(self.weapon == WEP_NEX && autocvar_g_balance_nex_charge)
+                               if(self.nex_charge > autocvar_g_balance_nex_charge_animlimit)
                                {
-                                       self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
-                                       self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
-                                       self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
-
-                                       if(self.nex_charge > autocvar_g_balance_nex_charge_animlimit)
-                                       {
-                                               self.weaponentity_glowmod_x = self.weaponentity_glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
-                                               self.weaponentity_glowmod_y = self.weaponentity_glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
-                                               self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
-                                       }
+                                       self.weaponentity_glowmod_x = self.weaponentity_glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
+                                       self.weaponentity_glowmod_y = self.weaponentity_glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
+                                       self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
                                }
-                               else
-                                       self.weaponentity_glowmod = self.glowmod;
                        }
+                       else
+                               self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
+
                        player_powerups();
                }
 
@@ -3194,4 +3054,6 @@ void PlayerPostThink (void)
        if(g_race)
                dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));
        */
+
+       CSQCMODEL_AUTOUPDATE();
 }
index 2b3e4d4db1995400d26feaeeaa73af814b8c8e74..8ff9fe7b2a17a0e726dd8a2fede7e5b7040f0fec 100644 (file)
@@ -134,7 +134,6 @@ void CopyBody(float keepvelocity)
        self.enemy = oldself;
        self.lip = oldself.lip;
        self.colormap = oldself.colormap;
-       self.glowmod = oldself.glowmod;
        self.iscreature = oldself.iscreature;
        self.damagedbycontents = oldself.damagedbycontents;
        self.angles = oldself.angles;
@@ -142,6 +141,7 @@ void CopyBody(float keepvelocity)
        self.classname = "body";
        self.damageforcescale = oldself.damageforcescale;
        self.effects = oldself.effects;
+       self.glowmod = oldself.glowmod;
        self.event_damage = oldself.event_damage;
        self.animstate_startframe = oldself.animstate_startframe;
        self.animstate_numframes = oldself.animstate_numframes;
@@ -158,11 +158,7 @@ void CopyBody(float keepvelocity)
        self.armortype = oldself.armortype;
        self.model = oldself.model;
        self.modelindex = oldself.modelindex;
-       self.modelindex_lod0 = oldself.modelindex_lod0;
-       self.modelindex_lod0_from_xonotic = oldself.modelindex_lod0_from_xonotic;
-       self.modelindex_lod1 = oldself.modelindex_lod1;
-       self.modelindex_lod2 = oldself.modelindex_lod2;
-       self.skinindex = oldself.skinindex;
+       self.skin = oldself.skin;
        self.species = oldself.species;
        self.movetype = oldself.movetype;
        self.nextthink = oldself.nextthink;
@@ -195,7 +191,7 @@ void CopyBody(float keepvelocity)
 float player_getspecies()
 {
        float s;
-       get_model_parameters(self.model, self.skinindex);
+       get_model_parameters(self.model, self.skin);
        s = get_model_parameters_species;
        get_model_parameters(string_null, 0);
        if(s < 0)
@@ -229,14 +225,14 @@ void player_setupanimsformodel()
        self.anim_forwardleft = animfixfps(self, '20 1 1');
        self.anim_backright = animfixfps(self, '21 1 1');
        self.anim_backleft  = animfixfps(self, '22 1 1');
-       self.anim_melee = animfixfps2(self, '23 1 1', '11 1 5');
-       self.anim_duckwalkbackwards = animfixfps2(self, '24 1 1', '4 1 1');
-       self.anim_duckwalkstrafeleft = animfixfps2(self, '25 1 1', '4 1 1');
-       self.anim_duckwalkstraferight = animfixfps2(self, '26 1 1', '4 1 1');
-       self.anim_duckwalkforwardright = animfixfps2(self, '27 1 1', '4 1 1');
-       self.anim_duckwalkforwardleft = animfixfps2(self, '28 1 1', '4 1 1');
-       self.anim_duckwalkbackright = animfixfps2(self, '29 1 1', '4 1 1');
-       self.anim_duckwalkbackleft  = animfixfps2(self, '30 1 1', '4 1 1');
+       self.anim_melee = animfixfps(self, '23 1 1');
+       self.anim_duckwalkbackwards = animfixfps(self, '24 1 1');
+       self.anim_duckwalkstrafeleft = animfixfps(self, '25 1 1');
+       self.anim_duckwalkstraferight = animfixfps(self, '26 1 1');
+       self.anim_duckwalkforwardright = animfixfps(self, '27 1 1');
+       self.anim_duckwalkforwardleft = animfixfps(self, '28 1 1');
+       self.anim_duckwalkbackright = animfixfps(self, '29 1 1');
+       self.anim_duckwalkbackleft  = animfixfps(self, '30 1 1');
        // TODO introspect models for finding right "fps" value (1/duration)
        // reset animstate now
        setanim(self, self.anim_idle, TRUE, FALSE, TRUE);
@@ -1170,18 +1166,18 @@ float LoadPlayerSounds(string f, float first)
 }
 
 .float modelindex_for_playersound;
-.float skinindex_for_playersound;
+.float skin_for_playersound;
 void UpdatePlayerSounds()
 {
        if(self.modelindex == self.modelindex_for_playersound)
-       if(self.skinindex == self.skinindex_for_playersound)
+       if(self.skin == self.skin_for_playersound)
                return;
        self.modelindex_for_playersound = self.modelindex;
-       self.skinindex_for_playersound = self.skinindex;
+       self.skin_for_playersound = self.skin;
        ClearPlayerSounds();
        LoadPlayerSounds("sound/player/default.sounds", 1);
        if(!autocvar_g_debug_defaultsounds)
-               if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skinindex, "sounds"), 0))
+               if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skin, "sounds"), 0))
                        LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0);
 }
 
index edf5b1f5e5c697d07087509075ef53edc2af5bd0..b1f6aabba106d9728c27f967dab608f6a365a0ad 100644 (file)
@@ -220,7 +220,25 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                self = oldself;
                if(startitem_failed)
                        return string_null;
-               if(doreduce)
+               if(doreduce && g_weapon_stay == 2)
+               {
+                       for(i = 0, j = 1; i < 24; ++i, j *= 2)
+                       {
+                               if(wa & j)
+                               {
+                                       ammofield = Item_CounterField(j);
+                                       wep.ammofield = 0;
+
+                                       // if our weapon is loaded, give its load back to the player
+                                       if(self.(weapon_load[self.weapon]) > 0)
+                                       {
+                                               own.ammofield += self.(weapon_load[self.weapon]);
+                                               self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
+                                       }
+                               }
+                       }
+               }
+               else if(doreduce)
                {
                        for(i = 0, j = 1; i < 24; ++i, j *= 2)
                        {
@@ -245,6 +263,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                wep.glowmod = own.weaponentity_glowmod;
                wep.think = thrown_wep_think;
                wep.nextthink = time + 0.5;
+               wep.pickup_anyway = TRUE; // these are ALWAYS pickable
                return s;
        }
 }
@@ -297,8 +316,6 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
                return;
        if(!autocvar_g_weapon_throwable)
                return;
-       if(autocvar_g_weapon_stay == 1)
-               return;
        if(self.weaponentity.state != WS_READY)
                return;
        if(!W_IsWeaponThrowable(w))
index 4acb8da891fa4fa4158b5ef01b7026a176cced5e..ae275ac679b6786a094f380577d602ea1d37388a 100644 (file)
@@ -681,6 +681,8 @@ void CL_ExteriorWeaponentity_Think()
 
        self.glowmod = self.owner.weaponentity_glowmod;
        self.colormap = self.owner.colormap;
+
+       CSQCMODEL_AUTOUPDATE();
 }
 
 // spawning weaponentity for client
@@ -708,6 +710,13 @@ void CL_SpawnWeaponentity()
        self.exteriorweaponentity.angles = '0 0 0';
        self.exteriorweaponentity.think = CL_ExteriorWeaponentity_Think;
        self.exteriorweaponentity.nextthink = time;
+
+       {
+               entity oldself = self;
+               self = self.exteriorweaponentity;
+               CSQCMODEL_AUTOINIT();
+               self = oldself;
+       }
 }
 
 void Send_WeaponComplain (entity e, float wpn, string wpnname, float type)
index 5e18a5cc60c55bb4936887ab9fab6f8b80153105..7cefb530d9f14be48ec3fb4f657fd1a07b0bbe3f 100644 (file)
@@ -125,13 +125,6 @@ float      MSG_ALL                                 = 2; // reliable
 float  MSG_INIT                                = 3; // initialization
 float  MSG_ENTITY                              = 5; // csqc
 
-vector PL_VIEW_OFS                             = '0 0 35';
-vector PL_MIN                                  = '-16 -16 -24';
-vector PL_MAX                                  = '16 16 45';
-vector PL_CROUCH_VIEW_OFS                      = '0 0 15';
-vector PL_CROUCH_MIN                           = '-16 -16 -24';
-vector PL_CROUCH_MAX                           = '16 16 25';
-
 // Sajt - added these, just as constants. Not sure how you want them actually put in the game, but I just
 // did this so at least they worked
 // NOTE: instagib IS NOT compatible with rocket-arena, so make sure to prevent selecting both in a menu
index be30ca3bec48057280980083f2fad82602e1ddbb..d70dd193777bb5a004b0269274acc0efb28b494a 100644 (file)
@@ -328,7 +328,6 @@ float default_weapon_alpha;
 
 .float() customizeentityforclient;
 .float cvar_cl_handicap;
-.float cvar_cl_playerdetailreduction;
 .float cvar_cl_clippedspectating;
 .float cvar_cl_autoscreenshot;
 .float cvar_cl_movement_track_canjump;
@@ -342,8 +341,6 @@ float default_weapon_alpha;
 .float cvar_cl_forceplayermodelsfromxonotic;
 float sv_clforceplayermodels;
 #endif
-float sv_loddistance1;
-float sv_loddistance2;
 .float cvar_cl_gunalign;
 .float cvar_cl_noantilag;
 
@@ -358,12 +355,6 @@ void AnnounceTo(entity e, string snd);
 
 .float version_nagtime;
 
-.float modelindex_lod0;
-.float modelindex_lod0_from_xonotic;
-.float skinindex;
-.float modelindex_lod1;
-.float modelindex_lod2;
-
 #define NUM_JUMPPADSUSED 3
 .float jumppadcount;
 .entity jumppadsused[NUM_JUMPPADSUSED];
index a331da4f0961676e43a7d0ab90f76b6059322861..6a62d61b5d423e43debf69ab9461e031c427142c 100644 (file)
@@ -71,24 +71,6 @@ vector animfixfps(entity e, vector a)
        return a;
 }
 
-vector animfixfps2(entity e, vector a, vector b)
-{
-       // multi-frame anim: keep as-is
-       float dur;
-       dur = frameduration(e.modelindex, a_x);
-       if(dur <= 0)
-       {
-               a = b;
-               dur = frameduration(e.modelindex, a_x);
-       }
-       if(a_y == 1)
-       {
-               if(dur > 0)
-                       a_z = 1.0 / dur;
-       }
-       return a;
-}
-
 /*
 ==================
 SUB_Remove
index 3d3cd582cc9476a220482dfc87ab8e2861cef3d2..d65a74e4a1a4229aa7891741c4c48d343aa73928 100644 (file)
@@ -402,6 +402,9 @@ void cvar_changes_init()
                BADCVAR("gameversion");
                BADPREFIX("gameversion_");
                BADCVAR("sv_namechangetimer");
+#ifndef NO_LEGACY_NETWORKING
+               BADCVAR("sv_use_csqc_players"); // transition
+#endif
 
                // allowed changes to server admins (please sync this to server.cfg)
                // vi commands:
@@ -410,10 +413,10 @@ void cvar_changes_init()
                //   :%s,//\([^ ]*\).*,BADCVAR("\1");,
                //   :%!sort
                // yes, this does contain some redundant stuff, don't really care
+               BADCVAR("bot_config_file");
                BADCVAR("bot_number");
                BADCVAR("bot_prefix");
                BADCVAR("bot_suffix");
-               BADCVAR("bot_config_file");
                BADCVAR("capturelimit_override");
                BADCVAR("fraglimit_override");
                BADCVAR("gametype");
@@ -444,6 +447,7 @@ void cvar_changes_init()
                BADCVAR("g_minstagib");
                BADCVAR("g_mirrordamage");
                BADCVAR("g_nexball_goallimit");
+               BADCVAR("g_powerups");
                BADCVAR("g_runematch_point_limit");
                BADCVAR("g_start_delay");
                BADCVAR("g_warmup");
@@ -460,6 +464,7 @@ void cvar_changes_init()
                BADCVAR("skill");
                BADCVAR("sv_adminnick");
                BADCVAR("sv_autoscreenshot");
+               BADCVAR("sv_autotaunt");
                BADCVAR("sv_curl_defaulturl");
                BADCVAR("sv_defaultcharacter");
                BADCVAR("sv_defaultplayercolors");
@@ -471,6 +476,7 @@ void cvar_changes_init()
                BADCVAR("sv_public");
                BADCVAR("sv_ready_restart");
                BADCVAR("sv_status_privacy");
+               BADCVAR("sv_taunt");
                BADCVAR("sv_vote_call");
                BADCVAR("sv_vote_commands");
                BADCVAR("sv_vote_majority_factor");
@@ -482,6 +488,7 @@ void cvar_changes_init()
                BADCVAR("teamplay_mode");
                BADCVAR("timelimit_override");
                BADPREFIX("g_warmup_");
+               BADPREFIX("sv_ready_restart_");
 
                if(autocvar_g_minstagib)
                {
@@ -743,8 +750,10 @@ void spawnfunc_worldspawn (void)
                        s = strcat(s, ":no_use_ammunition");
 
                // initialiation stuff, not good in the mutator system
-               if(!autocvar_g_pickup_items)
+               if(autocvar_g_pickup_items == 0)
                        s = strcat(s, ":no_pickup_items");
+               if(autocvar_g_pickup_items > 0)
+                       s = strcat(s, ":pickup_items");
 
                // initialiation stuff, not good in the mutator system
                if(autocvar_g_weaponarena != "0")
@@ -762,6 +771,12 @@ void spawnfunc_worldspawn (void)
                if(autocvar_g_minstagib)
                        s = strcat(s, ":minstagib");
 
+               // TODO to mutator system
+               if(autocvar_g_powerups == 0)
+                       s = strcat(s, ":no_powerups");
+               if(autocvar_g_powerups > 0)
+                       s = strcat(s, ":powerups");
+
                GameLogEcho(s);
                GameLogEcho(":gameinfo:end");
        }
@@ -945,8 +960,17 @@ void spawnfunc_worldspawn (void)
                s = "";
                n = tokenize_console(cvar_string("sv_curl_serverpackages"));
                for(i = 0; i < n; ++i)
-                       if(substring(argv(i), -14, -1) != ".serverpackage")
+                       if(substring(argv(i), -14, -1) != "-serverpackage.txt")
+                       if(substring(argv(i), -14, -1) != ".serverpackage") // OLD legacy
                                s = strcat(s, " ", argv(i));
+               fd = search_begin("*-serverpackage.txt", TRUE, FALSE);
+               if(fd >= 0)
+               {
+                       j = search_getsize(fd);
+                       for(i = 0; i < j; ++i)
+                               s = strcat(s, " ", search_getfilename(fd, i));
+                       search_end(fd);
+               }
                fd = search_begin("*.serverpackage", TRUE, FALSE);
                if(fd >= 0)
                {
index 60644e6f20a4c1e6fda54f09532602865e1b36e5..2fa2b6705d9ad66b8a583fd4d0246ed7280a7d7b 100644 (file)
@@ -151,25 +151,9 @@ void GameLogClose()
     }
 }
 
-vector PL_VIEW_OFS;
-vector PL_MIN;
-vector PL_MAX;
-vector PL_HEAD;
-vector PL_CROUCH_VIEW_OFS;
-vector PL_CROUCH_MIN;
-vector PL_CROUCH_MAX;
-
 float spawnpoint_nag;
 void relocate_spawnpoint()
 {
-    PL_VIEW_OFS                             = stov(autocvar_sv_player_viewoffset);
-    PL_MIN                                  = stov(autocvar_sv_player_mins);
-    PL_MAX                                  = stov(autocvar_sv_player_maxs);
-    PL_HEAD                                 = stov(autocvar_sv_player_headsize);
-    PL_CROUCH_VIEW_OFS                      = stov(autocvar_sv_player_crouch_viewoffset);
-    PL_CROUCH_MIN                           = stov(autocvar_sv_player_crouch_mins);
-    PL_CROUCH_MAX                           = stov(autocvar_sv_player_crouch_maxs);
-
     // nudge off the floor
     setorigin(self, self.origin + '0 0 1');
 
@@ -552,7 +536,6 @@ void GetCvars(float f)
        MUTATOR_CALLHOOK(GetCvars);
        GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch");
        GetCvars_handleFloat(s, f, cvar_cl_autoscreenshot, "cl_autoscreenshot");
-       GetCvars_handleFloat(s, f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
        GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion");
        GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap");
        GetCvars_handleFloat(s, f, cvar_cl_clippedspectating, "cl_clippedspectating");
@@ -1022,20 +1005,6 @@ void readplayerstartcvars()
        if (g_jetpack)
                start_items |= IT_JETPACK;
 
-       if (g_weapon_stay == 2)
-       {
-               if (!start_ammo_shells) start_ammo_shells = g_pickup_shells;
-               if (!start_ammo_nails) start_ammo_nails = g_pickup_nails;
-               if (!start_ammo_cells) start_ammo_cells = g_pickup_cells;
-               if (!start_ammo_rockets) start_ammo_rockets = g_pickup_rockets;
-               if (!start_ammo_fuel) start_ammo_fuel = g_pickup_fuel;
-               if (!warmup_start_ammo_shells) warmup_start_ammo_shells = g_pickup_shells;
-               if (!warmup_start_ammo_nails) warmup_start_ammo_nails = g_pickup_nails;
-               if (!warmup_start_ammo_cells) warmup_start_ammo_cells = g_pickup_cells;
-               if (!warmup_start_ammo_rockets) warmup_start_ammo_rockets = g_pickup_rockets;
-               if (!warmup_start_ammo_fuel) warmup_start_ammo_fuel = g_pickup_fuel;
-       }
-
        MUTATOR_CALLHOOK(SetStartItems);
 
        for (i = WEP_FIRST; i <= WEP_LAST; ++i)
@@ -1136,11 +1105,6 @@ void readlevelcvars(void)
 #ifdef ALLOW_FORCEMODELS
        sv_clforceplayermodels = cvar("sv_clforceplayermodels");
 #endif
-       sv_loddistance1 = cvar("sv_loddistance1");
-       sv_loddistance2 = cvar("sv_loddistance2");
-
-       if(sv_loddistance2 <= sv_loddistance1)
-               sv_loddistance2 = 1073741824; // enough to turn off LOD 2 reliably
 
        sv_clones = cvar("sv_clones");
        sv_gentle = cvar("sv_gentle");
@@ -1466,15 +1430,12 @@ void precache_playermodel(string m)
        if(substring(m, -9,5) == "_lod2")
                return;
        precache_model(m);
-       if(sv_loddistance1)
-       {
-               f = strcat(substring(m, 0, -5), "_lod1", substring(m, -4, -1));
-               if(fexists(f))
-                       precache_model(f);
-               f = strcat(substring(m, 0, -5), "_lod2", substring(m, -4, -1));
-               if(fexists(f))
-                       precache_model(f);
-       }
+       f = strcat(substring(m, 0, -5), "_lod1", substring(m, -4, -1));
+       if(fexists(f))
+               precache_model(f);
+       f = strcat(substring(m, 0, -5), "_lod2", substring(m, -4, -1));
+       if(fexists(f))
+               precache_model(f);
 
        globhandle = search_begin(strcat(m, "_*.sounds"), TRUE, FALSE);
        if (globhandle < 0)
index 461f475c7818787f113386378b1a4e09159fa46d..bf50c9d3cada867c7d4d2034244a5a75a0d8caa4 100644 (file)
@@ -7,6 +7,7 @@
 .vector portal_safe_origin;
 .float portal_wants_to_vanish;
 .float portal_activatetime;
+.float savemodelindex;
 
 float PlayerEdgeDistance(entity p, vector v)
 {
@@ -479,7 +480,7 @@ float Portal_Customize()
                other = other.enemy;
        if(other == self.aiment)
        {
-               self.modelindex = self.modelindex_lod0;
+               self.modelindex = self.savemodelindex;
        }
        else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
        {
@@ -487,7 +488,7 @@ float Portal_Customize()
        }
        else
        {
-               self.modelindex = self.modelindex_lod0;
+               self.modelindex = self.savemodelindex;
        }
        return TRUE;
 }
@@ -617,7 +618,7 @@ entity Portal_Spawn(entity own, vector org, vector ang)
        portal.fade_time = time + autocvar_g_balance_portal_lifetime;
        portal.health = autocvar_g_balance_portal_health;
        setmodel(portal, "models/portal.md3");
-       portal.modelindex_lod0 = portal.modelindex;
+       portal.savemodelindex = portal.modelindex;
        portal.customizeentityforclient = Portal_Customize;
 
        if(!Portal_FindSafeOrigin(portal))
index 6dd08bb1bcab2f0cee10cb2963da90edd8475478..45d83116f46295b910aadfb84c0d1ceb694f3dfd 100644 (file)
@@ -38,6 +38,9 @@ campaign.qh
 
 accuracy.qh
 csqcprojectile.qh
+../csqcmodel/settings.qh
+../csqcmodel/common.qh
+../csqcmodel/sv_model.qh
 csqceffects.qc
 
 anticheat.qh
@@ -176,6 +179,7 @@ target_music.qc
 
 
 accuracy.qc
+../csqcmodel/sv_model.qc
 csqcprojectile.qc
 
 playerdemo.qc
index c74c8b5722c5112a32c4f7b14aea01be7de24b34..3846af4bca478403d51bb226f2f0e3f8ab56b4a2 100644 (file)
@@ -1,3 +1,40 @@
+float have_pickup_item(void)
+{
+       // minstagib: only allow filtered items
+       if(g_minstagib)
+               if(self.classname != "minstagib")
+                       return FALSE;
+
+       if(self.items == IT_STRENGTH || self.items == IT_INVINCIBLE)
+       {
+               if(autocvar_g_powerups > 0)
+                       return TRUE;
+               if(autocvar_g_powerups == 0)
+                       return FALSE;
+               if(g_lms)
+                       return FALSE;
+               if(g_ca)
+                       return FALSE;
+               if(g_arena)
+                       return FALSE;
+       }
+       else
+       {
+               if(autocvar_g_pickup_items > 0)
+                       return TRUE;
+               if(autocvar_g_pickup_items == 0)
+                       return FALSE;
+               if(g_lms)
+                       return FALSE;
+               if(g_ca)
+                       return FALSE;
+               if(g_weaponarena)
+                       if((self.weapons & WEPBIT_ALL) || (self.items & IT_AMMO))
+                               return FALSE;
+       }
+       return TRUE;
+}
+
 #define ITEM_RESPAWN_TICKS 10
 
 #define ITEM_RESPAWNTIME(i)         ((i).respawntime + crandom() * (i).respawntimejitter)
@@ -94,7 +131,7 @@ void Item_Show (entity e, float mode)
 
                e.spawnshieldtime = 1;
        }
-       else if((e.flags & FL_WEAPON) && (g_weapon_stay == 3))
+       else if((e.flags & FL_WEAPON) && g_weapon_stay)
        {
                // make the item translucent and not touchable
                e.model = e.mdl;
@@ -389,6 +426,53 @@ void Item_ScheduleInitialRespawn(entity e)
        Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
 }
 
+float ITEM_MODE_NONE = 0;
+float ITEM_MODE_HEALTH = 1;
+float ITEM_MODE_ARMOR = 2;
+float ITEM_MODE_FUEL = 3;
+float Item_GiveAmmoTo(entity item, entity player, .float ammofield, float ammomax, float mode)
+{
+       if (!item.ammofield)
+               return FALSE;
+
+       if (item.spawnshieldtime)
+       {
+               if ((player.ammofield < ammomax) || item.pickup_anyway)
+               {
+                       player.ammofield = bound(player.ammofield, ammomax, player.ammofield + item.ammofield);
+                       goto YEAH;
+               }
+       }
+       else if(g_weapon_stay == 2)
+       {
+               float mi = min(item.ammofield, ammomax);
+               if (player.ammofield < mi)
+               {
+                       player.ammofield = mi;
+                       goto YEAH;
+               }
+       }
+
+       return FALSE;
+
+:YEAH
+       switch(mode)
+       {
+               case ITEM_MODE_FUEL:
+                       player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
+                       break;
+               case ITEM_MODE_HEALTH:
+                       player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
+                       break;
+               case ITEM_MODE_ARMOR:
+                       player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
+                       break;
+               default:
+                       break;
+       }
+       return TRUE;
+}
+
 float Item_GiveTo(entity item, entity player)
 {
        float _switchweapon;
@@ -403,92 +487,71 @@ float Item_GiveTo(entity item, entity player)
 
        if (g_minstagib)
        {
-               if(item.spawnshieldtime)
+               float prevcells = player.ammo_cells;
+
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, 999, ITEM_MODE_NONE);
+
+               if(player.ammo_cells > prevcells)
                {
-                       if (item.ammo_fuel)
-                       if (player.ammo_fuel < g_pickup_fuel_max)
-                       {
-                               pickedup = TRUE;
-                               player.ammo_fuel = bound(player.ammo_fuel, g_pickup_fuel_max, player.ammo_fuel + item.ammo_fuel);
-                               player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
-                       }
-                       if((it = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
+                       _switchweapon = TRUE;
+
+                       // play some cool sounds ;)
+                       if (clienttype(player) == CLIENTTYPE_REAL)
                        {
-                               pickedup = TRUE;
-                               player.items |= it;
-                               sprint (player, strcat("You got the ^2", item.netname, "\n"));
+                               if(player.health <= 5)
+                                       AnnounceTo(player, "lastsecond");
+                               else if(player.health < 50)
+                                       AnnounceTo(player, "narrowly");
                        }
+                       // sound not available
+                       // else if(item.items == IT_CELLS)
+                       //      AnnounceTo(player, "ammo");
 
-                       _switchweapon = TRUE;
+                       if (item.weapons & WEPBIT_MINSTANEX)
+                               W_GiveWeapon (player, WEP_MINSTANEX, item.netname);
                        if (item.ammo_cells)
-                       {
-                               pickedup = TRUE;
-                               // play some cool sounds ;)
-                               if (clienttype(player) == CLIENTTYPE_REAL)
-                               {
-                                       if(player.health <= 5)
-                                               AnnounceTo(player, "lastsecond");
-                                       else if(player.health < 50)
-                                               AnnounceTo(player, "narrowly");
-                               }
-                               // sound not available
-                               // else if(item.items == IT_CELLS)
-                               //      AnnounceTo(player, "ammo");
-
-                               if (item.weapons & WEPBIT_MINSTANEX)
-                                       W_GiveWeapon (player, WEP_MINSTANEX, item.netname);
-                               if (item.ammo_cells)
-                                       player.ammo_cells = bound(player.ammo_cells, 999, player.ammo_cells + autocvar_g_minstagib_ammo_drop);
-                               player.health = 100;
-                       }
+                               player.ammo_cells = bound(player.ammo_cells, 999, player.ammo_cells + autocvar_g_minstagib_ammo_drop);
+                       player.health = 100;
+               }
 
-                       // extralife powerup
-                       if (item.max_health)
-                       {
-                               pickedup = TRUE;
-                               // sound not available
-                               // AnnounceTo(player, "_lives");
-                               player.armorvalue = bound(player.armorvalue, 999, player.armorvalue + autocvar_g_minstagib_extralives);
-                               sprint(player, "^3You picked up some extra lives\n");
-                       }
+               if((it = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
+               {
+                       pickedup = TRUE;
+                       player.items |= it;
+                       sprint (player, strcat("You got the ^2", item.netname, "\n"));
+               }
 
-                       // invis powerup
-                       if (item.strength_finished)
-                       {
-                               pickedup = TRUE;
-                               // sound not available
-                               // AnnounceTo(player, "invisible");
-                               player.strength_finished = max(player.strength_finished, time) + autocvar_g_balance_powerup_strength_time;
-                       }
+               // extralife powerup
+               if (item.max_health)
+               {
+                       pickedup = TRUE;
+                       // sound not available
+                       // AnnounceTo(player, "_lives");
+                       player.armorvalue = bound(player.armorvalue, 999, player.armorvalue + autocvar_g_minstagib_extralives);
+                       sprint(player, "^3You picked up some extra lives\n");
+               }
 
-                       // speed powerup
-                       if (item.invincible_finished)
-                       {
-                               pickedup = TRUE;
-                               // sound not available
-                               // AnnounceTo(player, "speed");
-                               player.invincible_finished = max(player.invincible_finished, time) + autocvar_g_balance_powerup_strength_time;
-                       }
+               // invis powerup
+               if (item.strength_finished)
+               {
+                       pickedup = TRUE;
+                       // sound not available
+                       // AnnounceTo(player, "invisible");
+                       player.strength_finished = max(player.strength_finished, time) + autocvar_g_balance_powerup_strength_time;
+               }
+
+               // speed powerup
+               if (item.invincible_finished)
+               {
+                       pickedup = TRUE;
+                       // sound not available
+                       // AnnounceTo(player, "speed");
+                       player.invincible_finished = max(player.invincible_finished, time) + autocvar_g_balance_powerup_strength_time;
                }
        }
        else
        {
-               if (g_weapon_stay == 1)
-               if not(item.flags & FL_NO_WEAPON_STAY)
-               if (item.flags & FL_WEAPON)
-               {
-                       if(item.classname == "droppedweapon")
-                       {
-                               if (player.weapons & item.weapons)      // don't let players stack ammo by tossing weapons
-                                       goto skip;
-                       }
-                       else
-                       {
-                               if (player.weapons & item.weapons)
-                                       goto skip;
-                       }
-               }
-
                // in case the player has autoswitch enabled do the following:
                // if the player is using their best weapon before items are given, they
                // probably want to switch to an even better weapon after items are given
@@ -499,43 +562,16 @@ float Item_GiveTo(entity item, entity player)
                if not(player.weapons & W_WeaponBit(player.switchweapon))
                        _switchweapon = TRUE;
 
-               if(item.spawnshieldtime)
-               {
-                       if (item.ammo_shells)
-                       if ((player.ammo_shells < g_pickup_shells_max) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.ammo_shells = bound(player.ammo_shells, g_pickup_shells_max, player.ammo_shells + item.ammo_shells);
-                       }
-                       if (item.ammo_nails)
-                       if ((player.ammo_nails < g_pickup_nails_max) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.ammo_nails = bound(player.ammo_nails, g_pickup_nails_max, player.ammo_nails + item.ammo_nails);
-                       }
-                       if (item.ammo_rockets)
-                       if ((player.ammo_rockets < g_pickup_rockets_max) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.ammo_rockets = bound(player.ammo_rockets, g_pickup_rockets_max, player.ammo_rockets + item.ammo_rockets);
-                       }
-                       if (item.ammo_cells)
-                       if ((player.ammo_cells < g_pickup_cells_max) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.ammo_cells = bound(player.ammo_cells, g_pickup_cells_max, player.ammo_cells + item.ammo_cells);
-                       }
-                       if (item.ammo_fuel)
-                       if ((player.ammo_fuel < g_pickup_fuel_max) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.ammo_fuel = bound(player.ammo_fuel, g_pickup_fuel_max, player.ammo_fuel + item.ammo_fuel);
-                               player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
-                       }
-               }
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max, ITEM_MODE_NONE);
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max, ITEM_MODE_NONE);
+               pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max, ITEM_MODE_NONE);
+               pickedup |= Item_GiveAmmoTo(item, player, health, item.max_health, ITEM_MODE_HEALTH);
+               pickedup |= Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue, ITEM_MODE_ARMOR);
 
                if (item.flags & FL_WEAPON)
-                       if ((it = item.weapons - (item.weapons & player.weapons)) || (g_pickup_weapons_anyway && g_weapon_stay == 0))
+               if ((it = item.weapons - (item.weapons & player.weapons)) || (item.spawnshieldtime && g_pickup_weapons_anyway))
                {
                        pickedup = TRUE;
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
@@ -553,33 +589,15 @@ float Item_GiveTo(entity item, entity player)
                        sprint (player, strcat("You got the ^2", item.netname, "\n"));
                }
 
-               if(item.spawnshieldtime)
+               if (item.strength_finished)
                {
-                       if (item.strength_finished)
-                       {
-                               pickedup = TRUE;
-                               player.strength_finished = max(player.strength_finished, time) + autocvar_g_balance_powerup_strength_time;
-                       }
-                       if (item.invincible_finished)
-                       {
-                               pickedup = TRUE;
-                               player.invincible_finished = max(player.invincible_finished, time) + autocvar_g_balance_powerup_invincible_time;
-                       }
-
-                       if (item.health)
-                       if ((player.health < item.max_health) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.health = bound(player.health, item.max_health, player.health + item.health);
-                               player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
-                       }
-                       if (item.armorvalue)
-                       if ((player.armorvalue < item.max_armorvalue) || item.pickup_anyway)
-                       {
-                               pickedup = TRUE;
-                               player.armorvalue = bound(player.armorvalue, item.max_armorvalue, player.armorvalue + item.armorvalue);
-                               player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
-                       }
+                       pickedup = TRUE;
+                       player.strength_finished = max(player.strength_finished, time) + autocvar_g_balance_powerup_strength_time;
+               }
+               if (item.invincible_finished)
+               {
+                       pickedup = TRUE;
+                       player.invincible_finished = max(player.invincible_finished, time) + autocvar_g_balance_powerup_invincible_time;
                }
        }
 
@@ -629,8 +647,6 @@ void Item_Touch (void)
                remove (self);
        else if not(self.spawnshieldtime)
                return;
-       else if((self.flags & FL_WEAPON) && !(self.flags & FL_NO_WEAPON_STAY) && (g_weapon_stay == 1 || g_weapon_stay == 2))
-               return;
        else
        {
                if(self.team)
@@ -714,7 +730,7 @@ float weapon_pickupevalfunc(entity player, entity item)
        if(player.weapons & item.weapons == item.weapons)
        {
                // If I can pick it up
-               if(g_weapon_stay == 1 || g_weapon_stay == 2 || !item.spawnshieldtime)
+               if(!item.spawnshieldtime)
                        c = 0;
                else if(player.ammo_cells || player.ammo_shells || player.ammo_nails || player.ammo_rockets)
                {
@@ -852,6 +868,13 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                        return;
                }
 
+               if(!have_pickup_item())
+               {
+                       startitem_failed = TRUE;
+                       remove (self);
+                       return;
+               }
+
                self.reset = Item_Reset;
                // it's a level item
                if(self.spawnflags & 1)
@@ -904,35 +927,6 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                        self.is_item = TRUE;
                }
 
-               if(g_lms || g_ca)
-               {
-                       startitem_failed = TRUE;
-                       remove(self);
-                       return;
-               }
-               else if (g_weaponarena && ((weaponid & WEPBIT_ALL) || (itemid & IT_AMMO)))
-               {
-                       startitem_failed = TRUE;
-                       remove(self);
-                       return;
-               }
-               else if (g_minstagib)
-               {
-                       // don't remove dropped items and powerups
-                       if (self.classname != "minstagib")
-                       {
-                               startitem_failed = TRUE;
-                               remove (self);
-                               return;
-                       }
-               }
-               else if (!autocvar_g_pickup_items && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
-               {
-                       startitem_failed = TRUE;
-                       remove (self);
-                       return;
-               }
-
                weaponsInMap |= weaponid;
 
                precache_model (itemmodel);
@@ -1006,7 +1000,7 @@ void minstagib_items (float itemid)
        // replace rocket launchers and nex guns with ammo cells
        if (itemid == IT_CELLS)
        {
-               self.ammo_cells = 1;
+               self.ammo_cells = autocvar_g_minstagib_ammo_drop;
                StartItem ("models/items/a_cells.md3",
                        "misc/itempickup.wav", 45, 0,
                        "MinstaNex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
@@ -1169,16 +1163,6 @@ void weapon_defaultspawnfunc(float wpn)
        if(self.team)
                self.flags |= FL_NO_WEAPON_STAY;
 
-       if(g_weapon_stay == 2 && self.classname != "droppedweapon")
-       {
-               self.ammo_shells = 0;
-               self.ammo_nails = 0;
-               self.ammo_cells = 0;
-               self.ammo_rockets = 0;
-               // weapon stay 2: don't use ammo on weapon pickups; instead
-               // initialize all ammo types to the pickup ammo unless set by g_start_ammo_*
-       }
-
        StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, e.bot_pickupbasevalue);
        if (self.modelindex) // don't precache if self was removed
                weapon_action(e.weapon, WR_PRECACHE);
@@ -1365,12 +1349,6 @@ void spawnfunc_item_health_large (void) {
 }
 
 void spawnfunc_item_health_mega (void) {
-       if(!autocvar_g_powerup_superhealth)
-               return;
-
-       if((g_arena || g_ca) && !autocvar_g_arena_powerups)
-               return;
-
        if(g_minstagib) {
                minstagib_items(IT_NAILS);
        } else {
@@ -1392,12 +1370,6 @@ void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
 
 void spawnfunc_item_strength (void) {
-       if(!autocvar_g_powerup_strength)
-               return;
-
-       if((g_arena || g_ca) && !autocvar_g_arena_powerups)
-               return;
-
        if(g_minstagib) {
                minstagib_items(IT_STRENGTH);
        } else {
@@ -1408,12 +1380,6 @@ void spawnfunc_item_strength (void) {
 }
 
 void spawnfunc_item_invincible (void) {
-       if(!autocvar_g_powerup_shield)
-               return;
-
-       if((g_arena || g_ca) && !autocvar_g_arena_powerups)
-               return;
-
        if(g_minstagib) {
                minstagib_items(IT_INVINCIBLE);
        } else {
index 3d65d760d3af9604921342e4b811dc6619329d0c..66e909eec3ce9e5d26ee161a7729a9dd70462768 100644 (file)
@@ -478,6 +478,10 @@ string getwelcomemessage(void)
                modifications = strcat(modifications, ", Blood loss");
        if(g_jetpack)
                modifications = strcat(modifications, ", Jet pack");
+       if(autocvar_g_powerups == 0)
+               modifications = strcat(modifications, ", No powerups");
+       if(autocvar_g_powerups > 0)
+               modifications = strcat(modifications, ", Powerups");
        modifications = substring(modifications, 2, strlen(modifications) - 2);
 
        string versionmessage;