X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fmain.qc;h=37027d25cd35570419c819179b207311580f157e;hp=ae624ef85c88c1a7c2b6a09d0fb7617629cfb089;hb=bc50c2d7ca3e0a44ed1712400ef8e170e6df8210;hpb=b2d3d16a9a3e5df1c518ecd2fce0bfa741db190a diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index ae624ef85..37027d25c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -134,6 +134,8 @@ void CSQC_Init() registercvar("cl_jumpspeedcap_min", ""); registercvar("cl_jumpspeedcap_max", ""); + registercvar("cl_shootfromfixedorigin", ""); + registercvar("cl_multijump", "1"); registercvar("cl_spawn_near_teammate", "1"); @@ -435,11 +437,10 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew) // RegisterPlayer(o); //playerchecker will do this for us later, if it has not already done so - int sf, lf; - sf = ReadShort(); - lf = ReadShort(); + int sf = ReadShort(); + int lf = ReadShort(); FOREACH(Scores, true, { - int p = 1 << (i % 16); + int p = 1 << (i % 16); if (sf & p) { if (lf & p) @@ -447,7 +448,7 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew) else o.(scores(it)) = ReadChar(); } - }); + }); return = true; @@ -461,24 +462,21 @@ NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew) { make_pure(this); int i; - entity o; this.team = ReadByte(); - o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted + entity o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted - int sf, lf; #if MAX_TEAMSCORE <= 8 - sf = ReadByte(); - lf = ReadByte(); + int sf = ReadByte(); + int lf = ReadByte(); #else - sf = ReadShort(); - lf = ReadShort(); + int sf = ReadShort(); + int lf = ReadShort(); #endif - int p; - for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2) - if(sf & p) + for(i = 0; i < MAX_TEAMSCORE; ++i) + if(sf & BIT(i)) { - if(lf & p) + if(lf & BIT(i)) o.(teamscores(i)) = ReadInt24_t(); else o.(teamscores(i)) = ReadChar(); @@ -494,7 +492,7 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew) make_pure(this); float newspectatee_status; - int f = ReadByte(); + int f = ReadByte(); scoreboard_showscores_force = (f & BIT(0)); @@ -551,15 +549,13 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew) NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) { make_pure(this); - int i, j, b, f; + int i, j, b, f; - int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS + int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS if(!(nags & BIT(2))) { - if(vote_called_vote) - strunzone(vote_called_vote); - vote_called_vote = string_null; + strfree(vote_called_vote); vote_active = 0; } else @@ -577,9 +573,7 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) if(nags & BIT(7)) { - if(vote_called_vote) - strunzone(vote_called_vote); - vote_called_vote = strzone(ReadString()); + strcpy(vote_called_vote, ReadString()); } if(nags & 1) @@ -590,7 +584,7 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) for(i = 1; i <= maxclients; i += 8) { f = ReadByte(); - for(j = i-1, b = 1; b < 256; b *= 2, ++j) + for(j = i-1, b = BIT(0); b < BIT(8); b <<= 1, ++j) if (!(f & b)) if(playerslots[j]) playerslots[j].ready = 0; @@ -609,21 +603,24 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew) { make_pure(this); - int i, j, b, f; - - int sf = ReadByte(); - if(sf & 1) - { - for(j = 0; j < maxclients; ++j) - if(playerslots[j]) + int sf = 0; + serialize(byte, 0, sf); + if (sf & 1) { + for (int j = 0; j < maxclients; ++j) { + if (playerslots[j]) { playerslots[j].eliminated = 1; - for(i = 1; i <= maxclients; i += 8) - { - f = ReadByte(); - for(j = i-1, b = 1; b < 256; b *= 2, ++j) - if (!(f & b)) - if(playerslots[j]) - playerslots[j].eliminated = 0; + } + } + for (int i = 1; i <= maxclients; i += 8) { + int f = 0; + serialize(byte, 0, f); + for (int b = 0; b < 8; ++b) { + if (f & BIT(b)) continue; + int j = i - 1 + b; + if (playerslots[j]) { + playerslots[j].eliminated = 0; + } + } } } return true; @@ -641,7 +638,7 @@ NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew) NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew) { make_pure(this); - int sf = ReadInt24_t(); + int sf = ReadInt24_t(); if (sf == 0) { for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) weapon_accuracy[w] = -1; @@ -651,7 +648,7 @@ NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew) int f = 1; for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) { if (sf & f) { - int b = ReadByte(); + int b = ReadByte(); if (b == 0) weapon_accuracy[w] = -1; else if (b == 255) @@ -698,10 +695,7 @@ void Spawn_PreDraw(entity this) NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new) { float teamnum = (ReadByte() - 1); - vector spn_origin; - spn_origin.x = ReadCoord(); - spn_origin.y = ReadCoord(); - spn_origin.z = ReadCoord(); + vector spn_origin = ReadVector(); this.team = (teamnum + 1); @@ -758,9 +752,7 @@ NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new) if(entnum) { - this.origin_x = ReadCoord(); - this.origin_y = ReadCoord(); - this.origin_z = ReadCoord(); + this.origin = ReadVector(); if(is_new) { @@ -963,14 +955,12 @@ NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew) teamplay = _MapInfo_GetTeamPlayBool(gametype); HUD_ModIcons_SetFunc(); FOREACH(Scores, true, { - if (scores_label(it)) strunzone(scores_label(it)); - scores_label(it) = strzone(ReadString()); + strcpy(scores_label(it), ReadString()); scores_flags(it) = ReadByte(); }); for (int i = 0; i < MAX_TEAMSCORE; ++i) { - if (teamscores_label(i)) strunzone(teamscores_label(i)); - teamscores_label(i) = strzone(ReadString()); + strcpy(teamscores_label(i), ReadString()); teamscores_flags(i) = ReadByte(); } return = true; @@ -991,8 +981,7 @@ NET_HANDLE(ENT_CLIENT_INIT, bool isnew) arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); - if (forcefog) strunzone(forcefog); - forcefog = strzone(ReadString()); + strcpy(forcefog, ReadString()); armorblockpercent = ReadByte() / 255.0; damagepush_speedfactor = ReadByte() / 255.0; @@ -1055,17 +1044,15 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_time = ReadInt24_t(); race_previousbesttime = ReadInt24_t(); race_mypreviousbesttime = ReadInt24_t(); - if(race_previousbestname) - strunzone(race_previousbestname); string pbestname = ReadString(); if(autocvar_cl_race_cptimes_onlyself) { race_previousbesttime = race_mypreviousbesttime; race_mypreviousbesttime = 0; - race_previousbestname = strzone(""); + strcpy(race_previousbestname, ""); } else - race_previousbestname = strzone(pbestname); + strcpy(race_previousbestname, pbestname); race_checkpointtime = time; @@ -1091,17 +1078,15 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_nextbesttime = ReadInt24_t(); if(b != RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING) // not while spectating (matches server) race_mybesttime = ReadInt24_t(); - if(race_nextbestname) - strunzone(race_nextbestname); string newname = ReadString(); if(autocvar_cl_race_cptimes_onlyself && b != RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING) { race_nextbesttime = race_mybesttime; race_mybesttime = 0; - race_nextbestname = strzone(""); + strcpy(race_nextbestname, ""); } else - race_nextbestname = strzone(newname); + strcpy(race_nextbestname, newname); break; case RACE_NET_CHECKPOINT_HIT_RACE: @@ -1111,13 +1096,11 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_mycheckpointlapsdelta = ReadByte(); if(race_mycheckpointlapsdelta >= 128) race_mycheckpointlapsdelta -= 256; - if(race_mycheckpointenemy) - strunzone(race_mycheckpointenemy); int who = ReadByte(); if(who) - race_mycheckpointenemy = strzone(entcs_GetName(who - 1)); + strcpy(race_mycheckpointenemy, entcs_GetName(who - 1)); else - race_mycheckpointenemy = strzone(""); // TODO: maybe string_null works fine here? + strcpy(race_mycheckpointenemy, ""); // TODO: maybe string_null works fine here? break; case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT: @@ -1127,31 +1110,25 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_othercheckpointlapsdelta = ReadByte(); if(race_othercheckpointlapsdelta >= 128) race_othercheckpointlapsdelta -= 256; - if(race_othercheckpointenemy) - strunzone(race_othercheckpointenemy); int what = ReadByte(); if(what) - race_othercheckpointenemy = strzone(entcs_GetName(what - 1)); + strcpy(race_othercheckpointenemy, entcs_GetName(what - 1)); else - race_othercheckpointenemy = strzone(""); // TODO: maybe string_null works fine here? + strcpy(race_othercheckpointenemy, ""); // TODO: maybe string_null works fine here? break; case RACE_NET_PENALTY_RACE: race_penaltyeventtime = time; race_penaltytime = ReadShort(); //race_penaltyaccumulator += race_penaltytime; - if(race_penaltyreason) - strunzone(race_penaltyreason); - race_penaltyreason = strzone(ReadString()); + strcpy(race_penaltyreason, ReadString()); break; case RACE_NET_PENALTY_QUALIFYING: race_penaltyeventtime = time; race_penaltytime = ReadShort(); race_penaltyaccumulator += race_penaltytime; - if(race_penaltyreason) - strunzone(race_penaltyreason); - race_penaltyreason = strzone(ReadString()); + strcpy(race_penaltyreason, ReadString()); break; case RACE_NET_SERVER_RECORD: @@ -1159,21 +1136,13 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) break; case RACE_NET_SPEED_AWARD: race_speedaward = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit); - if(race_speedaward_holder) - strunzone(race_speedaward_holder); - race_speedaward_holder = strzone(ReadString()); - if(race_speedaward_unit) - strunzone(race_speedaward_unit); - race_speedaward_unit = strzone(GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); + strcpy(race_speedaward_holder, ReadString()); + strcpy(race_speedaward_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); break; case RACE_NET_SPEED_AWARD_BEST: race_speedaward_alltimebest = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit); - if(race_speedaward_alltimebest_holder) - strunzone(race_speedaward_alltimebest_holder); - race_speedaward_alltimebest_holder = strzone(ReadString()); - if(race_speedaward_alltimebest_unit) - strunzone(race_speedaward_alltimebest_unit); - race_speedaward_alltimebest_unit = strzone(GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); + strcpy(race_speedaward_alltimebest_holder, ReadString()); + strcpy(race_speedaward_alltimebest_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); break; case RACE_NET_SERVER_RANKINGS: float prevpos, del; @@ -1186,47 +1155,35 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) if (prevpos) { for (i=prevpos-1;i>pos-1;--i) { grecordtime[i] = grecordtime[i-1]; - if(grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = strzone(grecordholder[i-1]); + strcpy(grecordholder[i], grecordholder[i-1]); } } else if (del) { // a record has been deleted by the admin for (i=pos-1; i<= RANKINGS_CNT-1; ++i) { if (i == RANKINGS_CNT-1) { // clear out last record grecordtime[i] = 0; - if (grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = string_null; + strfree(grecordholder[i]); } else { grecordtime[i] = grecordtime[i+1]; - if (grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = strzone(grecordholder[i+1]); + strcpy(grecordholder[i], grecordholder[i+1]); } } } else { // player has no ranked record yet for (i=RANKINGS_CNT-1;i>pos-1;--i) { grecordtime[i] = grecordtime[i-1]; - if(grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = strzone(grecordholder[i-1]); + strcpy(grecordholder[i], grecordholder[i-1]); } } // store new ranking - if(grecordholder[pos-1] != "") - strunzone(grecordholder[pos-1]); - grecordholder[pos-1] = strzone(ReadString()); + strcpy(grecordholder[pos-1], ReadString()); grecordtime[pos-1] = ReadInt24_t(); if(strdecolorize(grecordholder[pos-1]) == strdecolorize(entcs_GetName(player_localnum))) race_myrank = pos; break; case RACE_NET_SERVER_STATUS: race_status = ReadShort(); - if(race_status_name) - strunzone(race_status_name); - race_status_name = strzone(ReadString()); + strcpy(race_status_name, ReadString()); } return true; }