X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmiscfunctions.qc;h=cb74c8d3a8a926148704766a302c6ab9004284b1;hb=cdf8d22631c0acdf97bd69bdd00ab86e96b30b73;hp=b65b8f17dedc4232f0354fcce07b07e07da092d4;hpb=b67dccc0a893a9301f87ac122a80abe9f5ff66de;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index b65b8f17d..cb74c8d3a 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -181,6 +181,7 @@ 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; @@ -191,6 +192,7 @@ void relocate_spawnpoint() PL_VIEW_OFS = stov(cvar_string("sv_player_viewoffset")); PL_MIN = stov(cvar_string("sv_player_mins")); PL_MAX = stov(cvar_string("sv_player_maxs")); + PL_HEAD = stov(cvar_string("sv_player_headsize")); PL_CROUCH_VIEW_OFS = stov(cvar_string("sv_player_crouch_viewoffset")); PL_CROUCH_MIN = stov(cvar_string("sv_player_crouch_mins")); PL_CROUCH_MAX = stov(cvar_string("sv_player_crouch_maxs")); @@ -466,28 +468,6 @@ string formatmessage(string msg) replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1')); else if (escape == "S") replacement = ftos(vlen(self.velocity)); - else if (escape == "v") { - float weapon_number; - local entity stats; - - if(self.classname == "spectator") - stats = self.enemy; - else - stats = self; - - weapon_number = stats.weapon; - - if (!weapon_number) - weapon_number = stats.switchweapon; - - if (!weapon_number) - weapon_number = stats.cnt; - - if(stats.cvar_cl_accuracy_data_share && stats.stats_fired[weapon_number - 1]) - replacement = ftos(bound(0, floor(100 * stats.stats_hit[weapon_number - 1] / stats.stats_fired[weapon_number - 1]), 100)); - else - replacement = "~"; // or something to indicate NULL, not available - } msg = strcat(substring(msg, 0, p), replacement, substring(msg, p+2, strlen(msg) - (p+2))); p = p + strlen(replacement); @@ -578,9 +558,19 @@ void GetCvars_handleFloatOnce(string thisname, float f, .float field, string nam stuffcmd(self, strcat("cl_cmd sendcvar ", name, "\n")); } } -string W_FixWeaponOrder_ForceComplete(string s); -string W_FixWeaponOrder_AllowIncomplete(string s); float w_getbestweapon(entity e); +string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(string wo) +{ + string o; + o = W_FixWeaponOrder_ForceComplete(wo); + if(self.weaponorder_byimpulse) + { + strunzone(self.weaponorder_byimpulse); + self.weaponorder_byimpulse = string_null; + } + self.weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(o)); + return o; +} void GetCvars(float f) { string s; @@ -597,7 +587,7 @@ void GetCvars(float f) GetCvars_handleFloat(s, f, cvar_cl_shownames, "cl_shownames"); GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion"); GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap"); - GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete); + GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[2], "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete); @@ -625,6 +615,7 @@ void GetCvars(float f) GetCvars_handleFloat(s, f, cvar_cl_forceplayermodelsfromxonotic, "cl_forceplayermodelsfromxonotic"); #endif GetCvars_handleFloatOnce(s, f, cvar_cl_gunalign, "cl_gunalign"); + GetCvars_handleFloat(s, f, cvar_cl_allow_uid2name, "cl_allow_uid2name"); // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early) if (f > 0) @@ -842,6 +833,7 @@ float g_pickup_ammo_anyway; float g_pickup_weapons_anyway; float g_weaponarena; float g_weaponarena_random; +float g_weaponarena_random_with_laser; string g_weaponarena_list; float g_weaponspeedfactor; float g_weaponratefactor; @@ -982,6 +974,7 @@ void readplayerstartcvars() g_weaponarena_random = cvar("g_weaponarena_random"); else g_weaponarena_random = 0; + g_weaponarena_random_with_laser = cvar("g_weaponarena_random_with_laser"); if (g_weaponarena) { @@ -1171,8 +1164,14 @@ void readlevelcvars(void) MUTATOR_ADD(mutator_nix); if(cvar("g_dodging")) MUTATOR_ADD(mutator_dodging); - if(cvar("g_rocket_flying") || (cvar("g_balance_rocketlauncher_detonatedelay") == 0 && stof(cvar_defstring("g_balance_rocketlauncher_detonatedelay")) != 0)) + if(cvar("g_rocket_flying")) MUTATOR_ADD(mutator_rocketflying); + if(cvar("g_vampire")) + MUTATOR_ADD(mutator_vampire); + + serverflags = 0; + if(cvar("sv_allow_fullbright")) + serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT; g_bugrigs = cvar("g_bugrigs"); g_bugrigs_planar_movement = cvar("g_bugrigs_planar_movement"); @@ -1213,11 +1212,9 @@ void readlevelcvars(void) g_footsteps = cvar("g_footsteps"); g_grappling_hook = cvar("g_grappling_hook"); g_jetpack = cvar("g_jetpack"); - g_laserguided_missile = cvar("g_laserguided_missile"); g_midair = cvar("g_midair"); g_minstagib = cvar("g_minstagib"); g_norecoil = cvar("g_norecoil"); - g_vampire = cvar("g_vampire"); g_bloodloss = cvar("g_bloodloss"); sv_maxidle = cvar("sv_maxidle"); sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle"); @@ -1719,7 +1716,6 @@ void precache() #define INITPRIO_FIRST 0 #define INITPRIO_GAMETYPE 0 #define INITPRIO_GAMETYPE_FALLBACK 1 -#define INITPRIO_CVARS 5 #define INITPRIO_FINDTARGET 10 #define INITPRIO_DROPTOFLOOR 20 #define INITPRIO_SETLOCATION 90 @@ -2031,11 +2027,12 @@ float WarpZone_Projectile_Touch_ImpactFilter_Callback() } #define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return -float MAX_IPBAN_URIS = 16; - -float URI_GET_DISCARD = 0; -float URI_GET_IPBAN = 1; -float URI_GET_IPBAN_END = 16; +float MAX_IPBAN_URIS = 16; + +float URI_GET_DISCARD = 0; +float URI_GET_IPBAN = 1; +float URI_GET_IPBAN_END = 16; +float URI_GET_PLAYERSTATS_SENT = 17; void URI_Get_Callback(float id, float status, string data) { @@ -2052,6 +2049,10 @@ void URI_Get_Callback(float id, float status, string data) // online ban list OnlineBanList_URI_Get_Callback(id, status, data); } + else if (id == URI_GET_PLAYERSTATS_SENT) + { + PlayerStats_Sent_URI_Get_Callback(id, status, data); + } else { print("Received HTTP request data for an invalid id ", ftos(id), ".\n"); @@ -2067,10 +2068,6 @@ void print_to(entity e, string s) } string uid2name(string myuid) { - // TODO TODO TODO! - // store uid in separate uid2name db IF CLIENT ALLOWS THIS - // - make it global for all mods - // perhaps show 10 first digits here if missing name? string s; s = db_get(ServerProgsDB, strcat("uid2name", myuid)); @@ -2118,13 +2115,30 @@ void race_writeTime(string map, float t, string myuid) else rr = RACE_RECORD; - float pos; - pos = race_readPos(map, t); + float newpos; + newpos = race_readPos(map, t); - if(pos) { // don't even ALLOW writing unranked times into the db, less stuff to worry about in other code then :-) - db_put(ServerProgsDB, strcat(map, rr, "time", ftos(pos)), ftos(t)); - db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(pos)), myuid); + float i, prevpos; + for(i = 1; i <= RANKINGS_CNT; ++i) + { + if(race_readUID(map, i) == myuid) + prevpos = i; + } + if (prevpos) { // player improved his existing record, only have to iterate on ranks between new and old recs + for (i = prevpos; i > newpos; --i) { + db_put(ServerProgsDB, strcat(map, rr, "time", ftos(i)), ftos(race_readTime(map, i - 1))); + db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(i)), race_readUID(map, i - 1)); + } + } else { // player has no ranked record yet + for (i = RANKINGS_CNT; i > newpos; --i) { + db_put(ServerProgsDB, strcat(map, rr, "time", ftos(i)), ftos(race_readTime(map, i - 1))); + db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(i)), race_readUID(map, i - 1)); + } } + + // store new time itself + db_put(ServerProgsDB, strcat(map, rr, "time", ftos(newpos)), ftos(t)); + db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(newpos)), myuid); } string race_readName(string map, float pos) @@ -2253,15 +2267,16 @@ string getrankings() return strcat("Records for ", map, ":\n", s); } -const float LADDER_FIRSTPOINT = 100; -const float LADDER_CNT = 10; // position X still gives LADDER_FIRSTPOINT/X points -const float LADDER_SIZE = 30; // ladder shows the top X players +#define LADDER_FIRSTPOINT 100 +#define LADDER_CNT 10 + // position X still gives LADDER_FIRSTPOINT/X points +#define LADDER_SIZE 30 + // ladder shows the top X players string top_uids[LADDER_SIZE]; float top_scores[LADDER_SIZE]; -float UIDCNT; string getladder() { - float i, j, k; + float i, j, k, uidcnt; string s, temp_s; s = ""; @@ -2282,17 +2297,17 @@ string getladder() for (i = 0; i <= LADDER_CNT; ++i) { // i = 0 because it is the speed award if(i == 0) // speed award { - if(stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"))) == 0); - break; + if(stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/speed"))) == 0) + continue; - myuid = db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp")); + myuid = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/crypto_idfp")); } else // normal record, if it exists (else break) { - if(race_readTime(GetMapname(), i) == 0) - break; + if(race_readTime(MapInfo_Map_bspname, i) == 0) + continue; - myuid = race_readUID(GetMapname(), i); + myuid = race_readUID(MapInfo_Map_bspname, i); } // string s contains: @@ -2305,8 +2320,8 @@ string getladder() temp_s = db_get(TemporaryDB, strcat("ladder", myuid)); if (temp_s == "") { - db_put(TemporaryDB, strcat("uid", ftos(UIDCNT)), myuid); - ++UIDCNT; + db_put(TemporaryDB, strcat("uid", ftos(uidcnt)), myuid); + ++uidcnt; for (j = 0; j <= LADDER_CNT + 1; ++j) { if(j != LADDER_CNT + 1) @@ -2359,7 +2374,7 @@ string getladder() float thiscnt; string thisuid; - for (i = 0; i <= UIDCNT; ++i) // for each known uid + for (i = 0; i <= uidcnt; ++i) // for each known uid { thisuid = db_get(TemporaryDB, strcat("uid", ftos(i))); temp_s = db_get(TemporaryDB, strcat("ladder", thisuid)); @@ -2398,11 +2413,12 @@ string getladder() { s = strcat(s, "+-----"); } - if(LADDER_CNT > 9) - for (i = 1; i <= LADDER_CNT - 9; ++i) - { - s = strcat(s, "+------"); - } +#if LADDER_CNT > 9 + for (i = 1; i <= LADDER_CNT - 9; ++i) + { + s = strcat(s, "+------"); + } +#endif s = strcat(s, "+--------------+--------------------\n"); @@ -2414,10 +2430,17 @@ string getladder() continue; s = strcat(s, strpad(4, race_placeName(i+1)), "^3| ^7"); // pos s = strcat(s, strpad(7, argv(LADDER_CNT+1)), "^3| ^7"); // total - for (j = 1; j <= LADDER_CNT; ++j) + for (j = 1; j <= min(9, LADDER_CNT); ++j) { s = strcat(s, strpad(4, argv(j)), "^3| ^7"); // 1st, 2nd, 3rd etc cnt } +#if LADDER_CNT > 9 + for (j = 10; j <= LADDER_CNT; ++j) + { + s = strcat(s, strpad(4, argv(j)), " ^3| ^7"); // 1st, 2nd, 3rd etc cnt + } +#endif + s = strcat(s, strpad(13, argv(0)), "^3| ^7"); // speed award cnt s = strcat(s, uid2name(top_uids[i]), "\n"); // name }