]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/main.qc
cl_multijump: default to opt-in
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / main.qc
index a1cb0c3ee0e877d06b5d352e47b184fb9e5f8900..0d195fbdfece228650a95e670a78742dc7c5a556 100644 (file)
 
 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
 
+void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
+{
+       ofs = eX * (ofs.x * SIZE_CURSOR.x) + eY * (ofs.y * SIZE_CURSOR.y);
+       drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL);
+}
+
+void draw_cursor_normal(vector pos, vector col, float a)
+{
+       draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a);
+}
+
+void LoadMenuSkinValues()
+{
+       int fh = -1;
+       if(cvar_string("menu_skin") != "")
+       {
+               draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
+               fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+       }
+       if(fh < 0 && cvar_defstring("menu_skin") != "")
+       {
+               cvar_set("menu_skin", cvar_defstring("menu_skin"));
+               draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
+               fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+       }
+       if(fh < 0)
+       {
+               draw_currentSkin = "gfx/menu/default";
+               fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+       }
+
+       draw_currentSkin = strzone(draw_currentSkin);
+
+       if(fh >= 0)
+       {
+               string s;
+               while((s = fgets(fh)))
+               {
+                       int n = tokenize_console(s);
+                       if (n < 2)
+                               continue;
+                       if(substring(argv(0), 0, 2) == "//")
+                               continue;
+                       if(argv(0) == "SIZE_CURSOR")
+                               SIZE_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+                       else if(argv(0) == "OFFSET_CURSOR")
+                               OFFSET_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+               }
+               fclose(fh);
+       }
+}
+
 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
 // Useful for precaching things
 
@@ -75,7 +127,7 @@ void CSQC_Init()
        registercvar("cl_jumpspeedcap_min", "");
        registercvar("cl_jumpspeedcap_max", "");
 
-       registercvar("cl_multijump", "0");
+       registercvar("cl_multijump", "1");
 
        registercvar("cl_spawn_near_teammate", "1");
 
@@ -125,7 +177,7 @@ void CSQC_Init()
        }
 
        hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
-       draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
+       LoadMenuSkinValues();
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
@@ -150,6 +202,8 @@ void Shutdown()
        if(autocvar_chase_active < 0)
                cvar_set("chase_active", "0");
 
+       cvar_set("slowmo", cvar_defstring("slowmo")); // reset it back to 'default'
+
        if (!isdemo())
        {
                if (!(calledhooks & HOOK_START))
@@ -261,8 +315,7 @@ void Playerchecker_Think()
                                // player connected
                                if (!e)
                                {
-                                       playerslots[i] = e = new(playerslot);
-                                       make_pure(e);
+                                       playerslots[i] = e = new_pure(playerslot);
                                }
                                e.sv_entnum = i;
                                e.ping = 0;
@@ -283,8 +336,7 @@ void Porto_Init();
 void TrueAim_Init();
 void PostInit()
 {
-       entity playerchecker = new(playerchecker);
-       make_pure(playerchecker);
+       entity playerchecker = new_pure(playerchecker);
        playerchecker.think = Playerchecker_Think;
        playerchecker.nextthink = time + 0.2;
 
@@ -327,11 +379,23 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 // --------------------------------------------------------------------------
 // BEGIN OPTIONAL CSQC FUNCTIONS
 
-void Ent_Remove();
-
-void Ent_RemovePlayerScore()
+.void(entity) predraw_qc;
+void PreDraw_self()
 {
        SELFPARAM();
+       if (this.predraw_qc) this.predraw_qc(this);
+}
+
+void setpredraw(entity this, void(entity) pdfunc)
+{
+       this.predraw = PreDraw_self;
+       this.predraw_qc = pdfunc;
+}
+
+void Ent_Remove(entity this);
+
+void Ent_RemovePlayerScore(entity this)
+{
        if(this.owner) {
                SetTeam(this.owner, -1);
                this.owner.gotscores = 0;
@@ -359,7 +423,7 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
                //print("A CSQC entity changed its owner!\n");
                LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", etof(this), this.classname);
                isNew = true;
-               Ent_Remove();
+               Ent_Remove(this);
        }
 #endif
 
@@ -368,8 +432,7 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
        o = playerslots[this.sv_entnum];
        if (!o)
        {
-               o = playerslots[this.sv_entnum] = new(playerslot);
-               make_pure(o);
+               o = playerslots[this.sv_entnum] = new_pure(playerslot);
        }
        this.owner = o;
        o.sv_entnum = this.sv_entnum;
@@ -610,13 +673,29 @@ void Spawn_Draw(entity this)
        __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
 }
 
+void Spawn_PreDraw(entity this)
+{
+       float alph;
+       vector org = getpropertyvec(VF_ORIGIN);
+       if(this.fade_start)
+               alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+       else
+               alph = 1;
+       //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
+       this.alpha = alph;
+       if(alph <= 0)
+               this.drawmask = 0;
+       else
+               this.drawmask = MASK_NORMAL;
+}
+
 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
 {
        float teamnum = (ReadByte() - 1);
        vector spn_origin;
-       spn_origin.x = ReadShort();
-       spn_origin.y = ReadShort();
-       spn_origin.z = ReadShort();
+       spn_origin.x = ReadCoord();
+       spn_origin.y = ReadCoord();
+       spn_origin.z = ReadCoord();
 
        //if(is_new)
        //{
@@ -650,6 +729,9 @@ NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
                        else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
 
                        this.draw = Spawn_Draw;
+                       setpredraw(this, Spawn_PreDraw);
+                       this.fade_start = autocvar_cl_spawn_point_dist_min;
+                       this.fade_end = autocvar_cl_spawn_point_dist_max;
                }
        //}
 
@@ -666,9 +748,9 @@ NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
 
        if(entnum)
        {
-               this.origin_x = ReadShort();
-               this.origin_y = ReadShort();
-               this.origin_z = ReadShort();
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
 
                if(is_new)
                {
@@ -736,7 +818,7 @@ void CSQC_Ent_Update(bool isnew)
                if (t != this.enttype || isnew)
                {
                        LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", etof(this), this.entnum, this.enttype, t);
-                       Ent_Remove();
+                       Ent_Remove(this);
                        clearentity(this);
                        isnew = true;
                }
@@ -769,10 +851,9 @@ void CSQC_Ent_Update(bool isnew)
 // Destructor, but does NOT deallocate the entity by calling remove(). Also
 // used when an entity changes its type. For an entity that someone interacts
 // with others, make sure it can no longer do so.
-void Ent_Remove()
+void Ent_Remove(entity this)
 {
-       SELFPARAM();
-       if(this.entremove) this.entremove();
+       if(this.entremove) this.entremove(this);
 
        if(this.skeletonindex)
        {
@@ -802,7 +883,7 @@ void CSQC_Ent_Remove()
                LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
                return;
        }
-       if (this.enttype) Ent_Remove();
+       if (this.enttype) Ent_Remove(this);
        remove(this);
 }
 
@@ -856,7 +937,6 @@ bool CSQC_Parse_TempEntity()
        return false;
 }
 
-/** TODO somehow thwart prvm_globalset client ... */
 string forcefog;
 void Fog_Force()
 {