Debian Codegraph @

src/cdogs/campaigns.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4
5 Copyright (c) 2013-2014, 2016-2017, 2020-2023 Cong Xu
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11 Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
13 Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 */
29 #pragma once
30
31 #include "c_array.h"
32 #include "campaign_entry.h"
33 #include "character.h"
34 #include "mission.h"
35 #include "sys_config.h"
36
37 typedef struct
38 {
39 char *Name;
40 CArray subFolders; // of CampaignList
41 CArray list; // of CampaignEntry
42 } CampaignList;
43
44 typedef struct
45 {
46 CampaignList campaignList;
47 CampaignList dogfightList;
48 CampaignEntry quickPlayEntry;
49 } CustomCampaigns;
50
51 typedef struct
52 {
53 char *Title;
54 char *Author;
55 char *Description;
56 bool Ammo;
57 bool SkipWeaponMenu;
58 bool BuyAndSell;
59 bool RandomPickups;
60 int DoorOpenTicks;
61 int Lives;
62 int MaxLives;
63 int PlayerHP;
64 int PlayerMaxHP;
65 int PlayerExcessHP;
66 CArray Missions; // of Mission
67 CharacterStore characters;
68 MusicChunk CustomSongs[MUSIC_COUNT];
69 void *CustomData;
70 void (*CustomDataTerminate)(void *);
71 } CampaignSetting;
72
73 typedef struct
74 {
75 CampaignSetting Setting;
76 CampaignEntry Entry;
77 int MissionIndex;
78 bool IsLoaded;
79 // TODO: it may be possible to completely remove IsClient and rely on
80 // protocol definitions
81 bool IsClient;
82 bool IsError;
83 bool OptionsSet;
84 bool IsComplete;
85 bool IsQuit;
86 } Campaign;
87 extern Campaign gCampaign;
88
89 void CampaignInit(Campaign *campaign);
90 void CampaignTerminate(Campaign *campaign);
91 void CampaignSettingInit(CampaignSetting *setting);
92 void CampaignSettingTerminate(CampaignSetting *c);
93 void CampaignSettingTerminateAll(CampaignSetting *setting);
94
95 int CampaignGetMaxLives(const Campaign *c);
96 int CampaignGetLives(const Campaign *c);
97 int CampaignGetMaxHP(const Campaign *c);
98 int CampaignGetExcessHP(const Campaign *c);
99 int CampaignGetHP(const Campaign *c);
100
101 bool CampaignListIsEmpty(const CampaignList *c);
102
103 void LoadAllCampaigns(CustomCampaigns *campaigns);
104 void UnloadAllCampaigns(CustomCampaigns *campaigns);
105
106 Mission *CampaignGetCurrentMission(Campaign *campaign);
107 void CampaignSeedRandom(const Campaign *campaign);
108
109 void CampaignAndMissionSetup(Campaign *campaign, struct MissionOptions *mo);
110 void CampaignDeleteMission(Campaign *c, const size_t idx);