From f3690ebbacc9379af2dfc16789174f8532118c89 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 10 Mar 2012 20:46:44 +0100 Subject: [PATCH] campaign test run mode --- defaultXonotic.cfg | 1 + qcsrc/server/autocvars.qh | 1 + qcsrc/server/campaign.qc | 48 +++++++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 2c17e78a5..b4da7c8a6 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index a7959af46..002cce330 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index 5a68e9605..7c2509d21 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -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; -- 2.39.2