1 // CampaignFileLoad(offset, n)
2 // - Loads campaign level data (up to n entries starting at offset)
4 // - Returns the number of entries successfully read
5 float CampaignFile_Load(float offset, float n)
13 if(n > CAMPAIGN_MAX_ENTRIES)
14 n = CAMPAIGN_MAX_ENTRIES;
16 campaign_offset = offset;
19 fh = fopen("maps/campaign.txt", FILE_READ);
22 for(lineno = 0; (l = fgets(fh)); )
25 continue; // empty line
26 if(substring(l, 0, 2) == "//")
32 error("syntax error in campaign file");
35 campaign_gametype[campaign_entries] = strzone(argv(i++));
36 campaign_mapname[campaign_entries] = strzone(argv(i++));
37 campaign_bots[campaign_entries] = stof(argv(i++));
38 campaign_botskill[campaign_entries] = stof(argv(i++));
39 campaign_fraglimit[campaign_entries] = stof(argv(i++));
40 campaign_mutators[campaign_entries] = strzone(argv(i++));
41 campaign_shortdesc[campaign_entries] = strzone(argv(i++));
42 campaign_longdesc[campaign_entries] = strzone(argv(i++));
43 campaign_entries = campaign_entries + 1;
45 if(campaign_entries >= n)
53 return campaign_entries;
56 void CampaignFile_Unload()
59 for(i = 0; i < campaign_entries; ++i)
61 strunzone(campaign_gametype[i]);
62 strunzone(campaign_mapname[i]);
63 strunzone(campaign_mutators[i]);
64 strunzone(campaign_shortdesc[i]);
65 strunzone(campaign_longdesc[i]);
71 // stuff to handle the campaign_longdesc field
72 string fstrunzone(string s)
80 // NOTE: s may not be a tempstring here
81 string Campaign_wordwrap(string s, float l)
96 for(i = 0; i <= strlen(s); ++i)
98 if(i != strlen(s) && substring(s, i, 1) != " ")
101 word = substring(s, startidx, i - startidx);
107 t = strzone(strcat(t, "\n\n"));
110 else if(!l || (strlen(word) < lleft))
118 t = strzone(strcat(t, word));
119 lleft = lleft - strlen(word);
124 t = strzone(strcat(t, "\n", word));
125 lleft = l - strlen(word);