Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
campaign_file.qc File Reference
#include "campaign_file.qh"
Include dependency graph for campaign_file.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CAMPAIGN_GETARG

Functions

float CampaignFile_Load (int offset, float n)
void CampaignFile_Unload ()

Macro Definition Documentation

◆ CAMPAIGN_GETARG

#define CAMPAIGN_GETARG
Value:
a = argv(++i); \
if(a == ",") \
a = ""; \
else \
++i
string argv(float n)

Referenced by CampaignFile_Load().

Function Documentation

◆ CampaignFile_Load()

float CampaignFile_Load ( int offset,
float n )

Definition at line 14 of file campaign_file.qc.

15{
16 float fh;
17 float lineno;
18 float entlen;
19 float i;
20 string l, a;
21 string fn;
22
25
26 campaign_offset = offset;
29
30 fn = language_filename(strcat("maps/campaign", campaign_name, ".txt"));
31 fh = fopen(fn, FILE_READ);
32 if(fh >= 0)
33 {
34 for(lineno = 0; (l = fgets(fh)); )
35 {
36 if(strlen(l) == 0)
37 continue; // empty line
38 if(substring(l, 0, 11) == "//campaign:")
39 campaign_title = substring(l, 11, strlen(l) - 11);
40 if(substring(l, 0, 2) == "//")
41 continue; // comment
42 if(substring(l, 0, 12) == "\"//campaign:")
43 campaign_title = substring(l, 12, strlen(l) - 13);
44 if(substring(l, 0, 3) == "\"//")
45 continue; // comment
46 if(lineno >= offset)
47 {
48 entlen = tokenize(l); // using insane tokenizer for CSV
49
50#define CAMPAIGN_GETARG \
51 a = argv(++i); \
52 if(a == ",") \
53 a = ""; \
54 else \
55 ++i
56
57 i = -1; // starts at -1 so I don't need postincrement; that is, i points to BEFORE the current arg!
65 #ifdef SVQC
68 #else
69 CAMPAIGN_GETARG; campaign_shortdesc[campaign_entries] = strzone(a);
70 CAMPAIGN_GETARG; campaign_longdesc[campaign_entries] = strzone(strreplace("\\n", "\n", a));
71 #endif
72
73 if(i > entlen)
74 error("syntax error in campaign file: line has not enough fields");
75
77
78 if(campaign_entries >= n)
79 break;
80 }
81 lineno = lineno + 1;
82 }
83 fclose(fh);
84 }
85
87
88 return campaign_entries;
89}
string campaign_mutators[CAMPAIGN_MAX_ENTRIES]
int campaign_offset
string campaign_title
string campaign_name
float campaign_bots[CAMPAIGN_MAX_ENTRIES]
float campaign_botskill[CAMPAIGN_MAX_ENTRIES]
string campaign_gametype[CAMPAIGN_MAX_ENTRIES]
#define CAMPAIGN_MAX_ENTRIES
string campaign_fraglimit[CAMPAIGN_MAX_ENTRIES]
string campaign_mapname[CAMPAIGN_MAX_ENTRIES]
int campaign_entries
string campaign_timelimit[CAMPAIGN_MAX_ENTRIES]
#define CAMPAIGN_GETARG
const float FILE_READ
#define strlen
ERASEABLE string language_filename(string s)
Definition i18n.qh:14
string fgets(float fhandle)
void fclose(float fhandle)
float stof(string val,...)
string substring(string s, float start, float length)
float fopen(string filename, float mode)
float tokenize(string s)
string strzone(string s)
string string_null
Definition nil.qh:9
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define error
Definition pre.qh:6

References campaign_bots, campaign_botskill, campaign_entries, campaign_fraglimit, campaign_gametype, CAMPAIGN_GETARG, campaign_mapname, CAMPAIGN_MAX_ENTRIES, campaign_mutators, campaign_name, campaign_offset, campaign_timelimit, campaign_title, error, fclose(), fgets(), FILE_READ, fopen(), language_filename(), stof(), strcat(), string_null, strlen, strzone(), substring(), and tokenize().

◆ CampaignFile_Unload()

void CampaignFile_Unload ( )

Definition at line 91 of file campaign_file.qc.

92{
94 {
96 for(int i = 0; i < campaign_entries; ++i)
97 {
103 #ifndef SVQC
104 strfree(campaign_shortdesc[i]);
105 strfree(campaign_longdesc[i]);
106 #endif
107 }
109 }
110}
#define strfree(this)
Definition string.qh:59

References campaign_entries, campaign_fraglimit, campaign_gametype, campaign_mapname, campaign_mutators, campaign_timelimit, campaign_title, and strfree.

Referenced by CampaignLevelWarp(), CampaignPostIntermission(), CampaignPreInit(), and XonoticCampaignList_loadCvars().