X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fcampaign_file.qc;h=a8bbe8e856c430a7fdfaf85e9ab5a4988c96a13d;hb=d1a97798d78d4a04f19c9f94b9f4cb501ce7fa50;hp=08cec8092813b76653c9d8d33af5d94be4a52361;hpb=8d484c93801393279f8956b7d8806d78b50f6de9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/campaign_file.qc b/qcsrc/common/campaign_file.qc index 08cec8092..a8bbe8e85 100644 --- a/qcsrc/common/campaign_file.qc +++ b/qcsrc/common/campaign_file.qc @@ -1,8 +1,15 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "util.qh" + #include "campaign_common.qh" +#endif + // CampaignFileLoad(offset, n) // - Loads campaign level data (up to n entries starting at offset) // into the globals // - Returns the number of entries successfully read -float CampaignFile_Load(float offset, float n) +float CampaignFile_Load(int offset, float n) { float fh; float lineno; @@ -18,7 +25,7 @@ float CampaignFile_Load(float offset, float n) campaign_entries = 0; campaign_title = string_null; - fn = strcat("maps/campaign", campaign_name, ".txt"); + fn = language_filename(strcat("maps/campaign", campaign_name, ".txt")); fh = fopen(fn, FILE_READ); if(fh >= 0) { @@ -38,13 +45,12 @@ float CampaignFile_Load(float offset, float n) { entlen = tokenize(l); // using insane tokenizer for CSV -#define CAMPAIGN_GETARG0 if(i >= entlen) -#define CAMPAIGN_GETARG1 CAMPAIGN_GETARG0 error("syntax error in campaign file: line has not enough fields"); -#define CAMPAIGN_GETARG2 CAMPAIGN_GETARG1 a = argv(++i); -#define CAMPAIGN_GETARG3 CAMPAIGN_GETARG2 if(a == ",") -#define CAMPAIGN_GETARG4 CAMPAIGN_GETARG3 a = ""; -#define CAMPAIGN_GETARG5 CAMPAIGN_GETARG4 else -#define CAMPAIGN_GETARG CAMPAIGN_GETARG5 ++i +#define CAMPAIGN_GETARG \ + a = argv(++i); \ + if(a == ",") \ + a = ""; \ + else \ + ++i // What you're seeing here is what people will do when your compiler supports // C-style macros but no line continuations. @@ -58,9 +64,13 @@ float CampaignFile_Load(float offset, float n) CAMPAIGN_GETARG; campaign_mutators[campaign_entries] = strzone(a); CAMPAIGN_GETARG; campaign_shortdesc[campaign_entries] = strzone(a); CAMPAIGN_GETARG; campaign_longdesc[campaign_entries] = strzone(strreplace("\\n", "\n", a)); + + if(i > entlen) + error("syntax error in campaign file: line has not enough fields"); + campaign_entries = campaign_entries + 1; - if(campaign_entries >= n) + if(campaign_entries >= n) break; } lineno = lineno + 1; @@ -75,10 +85,10 @@ float CampaignFile_Load(float offset, float n) void CampaignFile_Unload() { - float i; if(campaign_title) { strunzone(campaign_title); + int i; for(i = 0; i < campaign_entries; ++i) { strunzone(campaign_gametype[i]);