Debian Codegraph @

src/cdogs/pickup_class.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4 Copyright (c) 2015-2016, 2018, 2020-2024 Cong Xu
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
27 */
28 #pragma once
29
30 #include <json/json.h>
31
32 #include "ammo.h"
33 #include "utils.h"
34 #include "weapon.h"
35
36 // Effects for "pick up" objects
37 typedef enum
38 {
39 PICKUP_NONE,
40 PICKUP_JEWEL,
41 PICKUP_HEALTH,
42 PICKUP_AMMO,
43 PICKUP_KEYCARD,
44 PICKUP_GUN,
45 PICKUP_SHOW_MAP,
46 PICKUP_LIVES,
47 PICKUP_SOUND,
48 PICKUP_MENU,
49 } PickupType;
50 PickupType StrPickupType(const char *s);
51 const char *PickupTypeStr(const PickupType pt);
52
53 typedef struct
54 {
55 char *Text;
56 CArray Effects; // of PickupEffect
57 } PickupMenuItem;
58
59 typedef struct
60 {
61 PickupType Type;
62 union {
63 int Score;
64 struct
65 {
66 int Amount;
67 bool ExceedMax;
68 } Heal;
69 NAmmo Ammo;
70 int Keys; // Refer to flags in mission.h
71 int GunId;
72 int Lives;
73 char *Sound;
74 struct
75 {
76 char *Text;
77 CArray Items; // of PickupMenuItem
78 } Menu;
79 } u;
80 } PickupEffect;
81
82 typedef struct
83 {
84 char *Name;
85 CArray Effects; // of PickupEffect
86 CPic Pic;
87 char *Sound;
88 } PickupClass;
89 typedef struct
90 {
91 CArray Classes; // of PickupClass
92 CArray CustomClasses; // of PickupClass
93 CArray KeyClasses; // of PickupClass
94 } PickupClasses;
95 extern PickupClasses gPickupClasses;
96
97 PickupClass *StrPickupClass(const char *s);
98 // Legacy pickup classes, integer based
99 PickupClass *IntPickupClass(const int i);
100 // Legacy exit styles, integer based
101 const char *IntExitStyle(const int i);
102 // Legacy key classes, style+integer based
103 const char *IntKeyStyle(const int style);
104 PickupClass *IntKeyPickupClass(const int style, const int i);
105 // Semi-legacy key classes, style+integer colour
106 PickupClass *KeyPickupClass(const char *style, const int i);
107 PickupClass *PickupClassGetById(PickupClasses *classes, const int id);
108 int StrPickupClassId(const char *s);
109
110 void PickupMenuItemInit(PickupMenuItem *m);
111 PickupEffect PickupEffectCopy(const PickupEffect *e);
112 void PickupClassInit(PickupClass *c);
113
114 void PickupEffectTerminate(PickupEffect *e);
115
116 void PickupClassesInit(
117 PickupClasses *classes, const char *filename, const AmmoClasses *ammo,
118 const WeaponClasses *guns);
119 void PickupClassesLoadJSON(CArray *classes, json_t *root);
120 void PickupClassesLoadAmmo(CArray *classes, const CArray *ammoClasses);
121 void PickupClassesLoadGuns(CArray *classes, const CArray *gunClasses);
122 void PickupClassesLoadKeys(CArray *classes);
123 void PickupClassesClear(CArray *classes);
124 void PickupClassesTerminate(PickupClasses *classes);
125 int PickupClassesCount(const PickupClasses *classes);
126
127 // Get the ith "Score" type pickup
128 PickupClass *IntScorePickupClass(const int i);
129
130 bool PickupClassHasAmmoEffect(const PickupClass *p);
131 bool PickupClassHasKeyEffect(const PickupClass *p);
132 int PickupClassGetKeys(const PickupClass *p);
133 const char *PickupClassGetName(const PickupClass *p);
134
135 // Score for picking up an objective
136 #define PICKUP_SCORE 10