]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
campaign test run mode
authorRudolf Polzer <divverent@xonotic.org>
Sat, 10 Mar 2012 19:46:44 +0000 (20:46 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 10 Mar 2012 19:46:44 +0000 (20:46 +0100)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/campaign.qc

index 2c17e78a57b761b0886eec1bab209e1168949325..b4da7c8a66776a0160aabb29e61029156e0dab93 100644 (file)
@@ -1696,6 +1696,7 @@ set _origin "0 0 0"
 // campaign internal, set when loading a campaign map1G
 set _campaign_index ""
 set _campaign_name ""
+set _campaign_testrun 0 "when 1, all levels of campaign are hit from start to end and tested if they load"
 
 // debug
 set _independent_players 0 "DO NOT TOUCH"
index a7959af46781aff6fc03ba2e9c5bf1c47ce48dd8..002cce33082a26cd1b68b0862d6065fb7fc3db3c 100644 (file)
@@ -1,5 +1,6 @@
 float autocvar__notarget;
 float autocvar__independent_players;
+float autocvar__campaign_testrun;
 float autocvar__campaign_index;
 string autocvar__campaign_name;
 float autocvar__sv_init;
index 5a68e96058ce0acd36724480d955d9a7213fb44f..7c2509d21a514c550e2d453e106573cc49ae3333 100644 (file)
@@ -15,7 +15,9 @@ float CampaignBailout(string s)
        cvar_string = cvar_string_normal;
        cvar_set = cvar_set_normal;
        cvar_set("g_campaign", "0");
-       print("campaign initialization failed: ", s, "\n");
+       print("^4campaign initialization failed: ", s, "\n");
+       if(autocvar__campaign_testrun)
+               error("CAMPAIGN FAIL AHAHAHAHAHAHAHAHAH))");
        return 1;
 }
 
@@ -118,10 +120,20 @@ void CampaignPostInit()
        // now some sanity checks
        if(Campaign_Invalid())
                return;
-       cvar_set("fraglimit", ftos(campaign_fraglimit[0]));
-       cvar_set("timelimit", ftos(campaign_timelimit[0]));
-       cvar_set_normal("fraglimit", ftos(campaign_fraglimit[0]));
-       cvar_set_normal("timelimit", ftos(campaign_timelimit[0]));
+       if(autocvar__campaign_testrun)
+       {
+               cvar_set("fraglimit", "0");
+               cvar_set("timelimit", "0.01");
+               cvar_set_normal("fraglimit", "0");
+               cvar_set_normal("timelimit", "0.01");
+       }
+       else
+       {
+               cvar_set("fraglimit", ftos(campaign_fraglimit[0]));
+               cvar_set("timelimit", ftos(campaign_timelimit[0]));
+               cvar_set_normal("fraglimit", ftos(campaign_fraglimit[0]));
+               cvar_set_normal("timelimit", ftos(campaign_timelimit[0]));
+       }
 }
 
 void CampaignSaveCvar(string cvarname, float value)
@@ -186,7 +198,12 @@ void CampaignPreIntermission()
                head = head.chain;
        }
 
-       if(won == 1 && lost == 0 && checkrules_equality == 0 && cheatcount_total == 0)
+       if(autocvar__campaign_testrun)
+       {
+               campaign_won = 1;
+               bprint("Campaign test run, advancing level.\n");
+       }
+       else if(won == 1 && lost == 0 && checkrules_equality == 0)
        {
                if(autocvar_timelimit != 0 && autocvar_fraglimit != 0 && time > autocvar_timelimit * 60) // checks if the timelimit has expired.
                {
@@ -214,23 +231,23 @@ void CampaignPreIntermission()
                // sound!
        }
 
-       if(campaign_won)
+       if(campaign_won && cheatcount_total == 0 && !autocvar__campaign_testrun)
        {
-               if(campaign_entries < 2)
+               if(campaign_level == cvar_normal(campaign_index_var))
                {
-                       // I have won
-                       if(campaign_level == cvar_normal(campaign_index_var))
+                       if(campaign_entries < 2)
                        {
+                               // I have won
                                savevar = strcat("g_campaign", campaign_name, "_won");
                                CampaignSaveCvar(savevar, 1);
                                // advance level (for menu to show it right)
                                CampaignSaveCvar(campaign_index_var, campaign_level + 1);
                        }
-               }
-               else if(campaign_level == cvar_normal(campaign_index_var))
-               {
-                       // advance level
-                       CampaignSaveCvar(campaign_index_var, campaign_level + 1);
+                       else
+                       {
+                               // advance level
+                               CampaignSaveCvar(campaign_index_var, campaign_level + 1);
+                       }
                }
        }
 }
@@ -242,6 +259,7 @@ void CampaignPostIntermission()
        if(campaign_won && campaign_entries < 2)
        {
                // last map won!
+               print("^2test run: campaign looks GOOD\n");
                localcmd("togglemenu 1\n");
                CampaignFile_Unload();
                return;