]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
Merge branch 'master' into terencehill/quickmenu
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index f8748e94935fe62f005c8d7b0c4c41d055b619ff..15c1ae68deebc79c6ede8126f218c3f4febb7c59 100644 (file)
 #include "race.qh"
 #include "scores.qh"
 #include "teamplay.qh"
-#include "waypointsprites.qh"
 #include "weapons/weaponstats.qh"
 #include "../common/buffs.qh"
 #include "../common/constants.qh"
 #include "../common/deathtypes.qh"
+#include "../common/effects.qh"
 #include "../common/mapinfo.qh"
 #include "../common/monsters/all.qh"
 #include "../common/monsters/sv_monsters.qh"
+#include "../common/vehicles/all.qh"
 #include "../common/notifications.qh"
 #include "../common/playerstats.qh"
 #include "../common/stats.qh"
@@ -145,7 +146,7 @@ void GotoFirstMap()
        else
        {
                self.nextthink = time + 1;
-               print("Waiting for _sv_init being set to 1 by initialization scripts...\n");
+               LOG_INFO("Waiting for _sv_init being set to 1 by initialization scripts...\n");
        }
 }
 
@@ -334,7 +335,6 @@ void cvar_changes_init()
                BADCVAR("pausable");
                BADCVAR("sv_allow_fullbright");
                BADCVAR("sv_checkforpacketsduringsleep");
-               BADCVAR("sv_fraginfo");
                BADCVAR("sv_timeout");
                BADPREFIX("sv_timeout_");
                BADPREFIX("crypto_");
@@ -345,12 +345,13 @@ void cvar_changes_init()
                BADPREFIX("prvm_");
                BADPREFIX("skill_");
                BADPREFIX("sv_cullentities_");
-               BADPREFIX("sv_fraginfo_");
                BADPREFIX("sv_maxidle_");
                BADPREFIX("sv_vote_");
                BADPREFIX("timelimit_");
                BADCVAR("gameversion");
                BADPREFIX("gameversion_");
+               BADCVAR("sv_minigames");
+               BADPREFIX("sv_minigames_");
                BADCVAR("sv_namechangetimer");
 
                // allowed changes to server admins (please sync this to server.cfg)
@@ -502,7 +503,7 @@ void detect_maptype()
                        tracebox(o, '-1 -1 -1' * i, '1 1 1' * i, o - '0 0 32768', MOVE_WORLDONLY, world);
        if(trace_fraction == 1)
                continue;
-                       print(ftos(i), " -> ", vtos(trace_endpos), "\n");
+                       LOG_INFO(ftos(i), " -> ", vtos(trace_endpos), "\n");
                }
 
                break;
@@ -560,7 +561,7 @@ void spawnfunc___init_dedicated_server(void)
 
        // needs to be done so early because of the constants they create
        static_init();
-       CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
+       CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
 
@@ -571,7 +572,6 @@ void spawnfunc___init_dedicated_server(void)
 void Map_MarkAsRecent(string m);
 float world_already_spawned;
 void Nagger_Init();
-void Item_ItemsTime_Init();
 void ClientInit_Spawn();
 void WeaponStats_Init();
 void WeaponStats_Shutdown();
@@ -608,10 +608,12 @@ void spawnfunc_worldspawn (void)
 
        // needs to be done so early because of the constants they create
        static_init();
-       CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
+       CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
 
+       initialize_minigames();
+
        ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));
 
        TemporaryDB = db_create();
@@ -692,8 +694,7 @@ void spawnfunc_worldspawn (void)
                GameLogEcho(strcat(":gamestart:", GetGametype(), "_", GetMapname(), ":", s));
                s = ":gameinfo:mutators:LIST";
 
-               ret_string = s;
-               MUTATOR_CALLHOOK(BuildMutatorsString);
+               MUTATOR_CALLHOOK(BuildMutatorsString, s);
                s = ret_string;
 
                // simple, probably not good in the mutator system
@@ -754,23 +755,23 @@ void spawnfunc_worldspawn (void)
                                        continue;
                                if(argv(0) == "cd")
                                {
-                                       print("Found ^1UNSUPPORTED^7 cd loop command in .cfg file; put this line in mapinfo instead:\n");
-                                       print("  cdtrack ", argv(2), "\n");
+                                       LOG_INFO("Found ^1UNSUPPORTED^7 cd loop command in .cfg file; put this line in mapinfo instead:\n");
+                                       LOG_INFO("  cdtrack ", argv(2), "\n");
                                }
                                else if(argv(0) == "fog")
                                {
-                                       print("Found ^1UNSUPPORTED^7 fog command in .cfg file; put this line in worldspawn in the .map/.bsp/.ent file instead:\n");
-                                       print("  \"fog\" \"", s, "\"\n");
+                                       LOG_INFO("Found ^1UNSUPPORTED^7 fog command in .cfg file; put this line in worldspawn in the .map/.bsp/.ent file instead:\n");
+                                       LOG_INFO("  \"fog\" \"", s, "\"\n");
                                }
                                else if(argv(0) == "set")
                                {
-                                       print("Found ^1UNSUPPORTED^7 set command in .cfg file; put this line in mapinfo instead:\n");
-                                       print("  clientsettemp_for_type all ", argv(1), " ", argv(2), "\n");
+                                       LOG_INFO("Found ^1UNSUPPORTED^7 set command in .cfg file; put this line in mapinfo instead:\n");
+                                       LOG_INFO("  clientsettemp_for_type all ", argv(1), " ", argv(2), "\n");
                                }
                                else if(argv(0) != "//")
                                {
-                                       print("Found ^1UNSUPPORTED^7 set command in .cfg file; put this line in mapinfo instead:\n");
-                                       print("  clientsettemp_for_type all ", argv(0), " ", argv(1), "\n");
+                                       LOG_INFO("Found ^1UNSUPPORTED^7 set command in .cfg file; put this line in mapinfo instead:\n");
+                                       LOG_INFO("  clientsettemp_for_type all ", argv(0), " ", argv(1), "\n");
                                }
                        }
                        fclose(fd);
@@ -811,19 +812,6 @@ void spawnfunc_worldspawn (void)
 
        addstat(STAT_ARC_HEAT, AS_FLOAT, arc_heat_percent);
 
-       // items time
-       addstat(STAT_ARMOR_LARGE_TIME, AS_FLOAT, item_armor_large_time);
-       addstat(STAT_HEALTH_MEGA_TIME, AS_FLOAT, item_health_mega_time);
-       addstat(STAT_INVISIBLE_TIME, AS_FLOAT, item_invisible_time);
-       addstat(STAT_SPEED_TIME, AS_FLOAT, item_speed_time);
-       addstat(STAT_EXTRALIFE_TIME, AS_FLOAT, item_extralife_time);
-       addstat(STAT_STRENGTH_TIME, AS_FLOAT, item_strength_time);
-       addstat(STAT_SHIELD_TIME, AS_FLOAT, item_shield_time);
-       addstat(STAT_FUELREGEN_TIME, AS_FLOAT, item_fuelregen_time);
-       addstat(STAT_JETPACK_TIME, AS_FLOAT, item_jetpack_time);
-       addstat(STAT_SUPERWEAPONS_TIME, AS_FLOAT, item_superweapons_time);
-       Item_ItemsTime_Init();
-
        // freeze attacks
        addstat(STAT_FROZEN, AS_INT, frozen);
        addstat(STAT_REVIVE_PROGRESS, AS_FLOAT, revive_progress);
@@ -984,39 +972,39 @@ float MapHasRightSize(string map)
        if(currentbots || autocvar_bot_number || player_count < autocvar_minplayers)
        if(autocvar_g_maplist_check_waypoints)
        {
-               dprint("checkwp "); dprint(map);
+               LOG_TRACE("checkwp "); LOG_TRACE(map);
                if(!fexists(strcat("maps/", map, ".waypoints")))
                {
-                       dprint(": no waypoints\n");
+                       LOG_TRACE(": no waypoints\n");
                        return false;
                }
-               dprint(": has waypoints\n");
+               LOG_TRACE(": has waypoints\n");
        }
 
        // open map size restriction file
-       dprint("opensize "); dprint(map);
+       LOG_TRACE("opensize "); LOG_TRACE(map);
        fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
        if(fh >= 0)
        {
                float mapmin, mapmax;
-               dprint(": ok, ");
+               LOG_TRACE(": ok, ");
                mapmin = stof(fgets(fh));
                mapmax = stof(fgets(fh));
                fclose(fh);
                if(player_count < mapmin)
                {
-                       dprint("not enough\n");
+                       LOG_TRACE("not enough\n");
                        return false;
                }
                if(player_count > mapmax)
                {
-                       dprint("too many\n");
+                       LOG_TRACE("too many\n");
                        return false;
                }
-               dprint("right size\n");
+               LOG_TRACE("right size\n");
                return true;
        }
-       dprint(": not found\n");
+       LOG_TRACE(": not found\n");
        return true;
 }
 
@@ -1071,7 +1059,7 @@ float Map_Check(float position, float pass)
                return 0;
        }
        else
-               dprint( "Couldn't select '", filename, "'..\n" );
+               LOG_TRACE( "Couldn't select '", filename, "'..\n" );
 
        return 0;
 }
@@ -1104,7 +1092,7 @@ float() MaplistMethod_Iterate = // usual method
 {
        float pass, i;
 
-       dprint("Trying MaplistMethod_Iterate\n");
+       LOG_TRACE("Trying MaplistMethod_Iterate\n");
 
        for(pass = 1; pass <= 2; ++pass)
        {
@@ -1121,7 +1109,7 @@ float() MaplistMethod_Iterate = // usual method
 
 float() MaplistMethod_Repeat = // fallback method
 {
-       dprint("Trying MaplistMethod_Repeat\n");
+       LOG_TRACE("Trying MaplistMethod_Repeat\n");
 
        if(Map_Check(Map_Current, 2))
                return Map_Current;
@@ -1132,7 +1120,7 @@ float() MaplistMethod_Random = // random map selection
 {
        float i, imax;
 
-       dprint("Trying MaplistMethod_Random\n");
+       LOG_TRACE("Trying MaplistMethod_Random\n");
 
        imax = 42;
 
@@ -1152,7 +1140,7 @@ float(float exponent) MaplistMethod_Shuffle = // more clever shuffling
 {
        float i, j, imax, insertpos;
 
-       dprint("Trying MaplistMethod_Shuffle\n");
+       LOG_TRACE("Trying MaplistMethod_Shuffle\n");
 
        imax = 42;
 
@@ -1164,7 +1152,7 @@ float(float exponent) MaplistMethod_Shuffle = // more clever shuffling
                insertpos = pow(random(), 1 / exponent);       // ]0, 1]
                insertpos = insertpos * (Map_Count - 1);       // ]0, Map_Count - 1]
                insertpos = ceil(insertpos) + 1;               // {2, 3, 4, ..., Map_Count}
-               dprint("SHUFFLE: insert pos = ", ftos(insertpos), "\n");
+               LOG_TRACE("SHUFFLE: insert pos = ", ftos(insertpos), "\n");
 
                // insert the current map there
                newlist = "";
@@ -1440,7 +1428,7 @@ void DumpStats(float final)
        s = strcat(s, GetGametype(), "_", GetMapname(), ":", ftos(rint(time)));
 
        if(to_console)
-               print(s, "\n");
+               LOG_INFO(s, "\n");
        if(to_eventlog)
                GameLogEcho(s);
 
@@ -1456,7 +1444,7 @@ void DumpStats(float final)
 
        s = strcat(":labels:player:", GetPlayerScoreString(world, 0));
        if(to_console)
-               print(s, "\n");
+               LOG_INFO(s, "\n");
        if(to_eventlog)
                GameLogEcho(s);
        if(to_file)
@@ -1474,7 +1462,7 @@ void DumpStats(float final)
                                s = strcat(s, "spectator:");
 
                        if(to_console)
-                               print(s, other.netname, "\n");
+                               LOG_INFO(s, other.netname, "\n");
                        if(to_eventlog)
                                GameLogEcho(strcat(s, ftos(other.playerid), ":", other.netname));
                        if(to_file)
@@ -1486,7 +1474,7 @@ void DumpStats(float final)
        {
                s = strcat(":labels:teamscores:", GetTeamScoreString(0, 0));
                if(to_console)
-                       print(s, "\n");
+                       LOG_INFO(s, "\n");
                if(to_eventlog)
                        GameLogEcho(s);
                if(to_file)
@@ -1497,7 +1485,7 @@ void DumpStats(float final)
                        s = strcat(":teamscores:see-labels:", GetTeamScoreString(i, 0));
                        s = strcat(s, ":", ftos(i));
                        if(to_console)
-                               print(s, "\n");
+                               LOG_INFO(s, "\n");
                        if(to_eventlog)
                                GameLogEcho(s);
                        if(to_file)
@@ -1506,7 +1494,7 @@ void DumpStats(float final)
        }
 
        if(to_console)
-               print(":end\n");
+               LOG_INFO(":end\n");
        if(to_eventlog)
                GameLogEcho(":end");
        if(to_file)
@@ -1811,7 +1799,7 @@ float WinningCondition_LMS()
                {
                        // SNAFU (maybe a draw game?)
                        ClearWinners();
-                       dprint("No players, ending game.\n");
+                       LOG_TRACE("No players, ending game.\n");
                        return WINNING_YES;
                }
        }
@@ -1867,7 +1855,7 @@ float WinningCondition_Scores(float limit, float leadlimit)
        if(WinningConditionHelper_zeroisworst)
                leadlimit = 0; // not supported in this mode
 
-       if(g_dm || g_tdm || g_ca || g_freezetag || (g_race && !g_race_qualifying) || g_nexball)
+       if(MUTATOR_CALLHOOK(Scores_CountFragsRemaining))
        // these modes always score in increments of 1, thus this makes sense
        {
                if(leaderfrags != WinningConditionHelper_topscore)
@@ -2278,7 +2266,7 @@ float RedirectionThink()
        FOR_EACH_REALCLIENT(self)
        {
                // TODO add timer
-               print("Redirecting: sending connect command to ", self.netname, "\n");
+               LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
                if(redirection_target == "self")
                        stuffcmd(self, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
                else
@@ -2286,7 +2274,7 @@ float RedirectionThink()
                ++clients_found;
        }
 
-       print("Redirecting: ", ftos(clients_found), " clients left.\n");
+       LOG_INFO("Redirecting: ", ftos(clients_found), " clients left.\n");
 
        if(time > redirection_timeout || clients_found == 0)
                localcmd("\nwait; wait; wait; quit\n");
@@ -2319,7 +2307,7 @@ void Shutdown()
        if(world_initialized > 0)
        {
                world_initialized = 0;
-               print("Saving persistent data...\n");
+               LOG_INFO("Saving persistent data...\n");
                Ban_SaveBans();
 
                // playerstats with unfinished match
@@ -2342,7 +2330,7 @@ void Shutdown()
                CheatShutdown(); // must be after cheatcount check
                db_close(ServerProgsDB);
                db_close(TemporaryDB);
-               print("done!\n");
+               LOG_INFO("done!\n");
                // tell the bot system the game is ending now
                bot_endgame();
 
@@ -2351,6 +2339,6 @@ void Shutdown()
        }
        else if(world_initialized == 0)
        {
-               print("NOTE: crashed before even initializing the world, not saving persistent data\n");
+               LOG_INFO("NOTE: crashed before even initializing the world, not saving persistent data\n");
        }
 }