OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MaterialList.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* A primitive list to store one amount value per mapped material */
19 
20 #include "C4Include.h"
22 
24 {
25  Default();
26 }
27 
29 {
30  Clear();
31 }
32 
34 {
35  Reset();
36 }
37 
39 {
40 
41 }
42 
44 {
45  for (int & cnt : Amount)
46  cnt=0;
47 }
48 
49 void C4MaterialList::Set(int32_t iMaterial, int32_t iAmount)
50 {
51  if (!Inside<int32_t>(iMaterial,0,C4MaxMaterial)) return;
52  Amount[iMaterial]=iAmount;
53 }
54 
55 void C4MaterialList::Add(int32_t iMaterial, int32_t iAmount)
56 {
57  if (!Inside<int32_t>(iMaterial,0,C4MaxMaterial)) return;
58  Amount[iMaterial]+=iAmount;
59 }
60 
61 int32_t C4MaterialList::Get(int32_t iMaterial)
62 {
63  if (!Inside<int32_t>(iMaterial,0,C4MaxMaterial)) return 0;
64  return Amount[iMaterial];
65 }
void Set(int32_t iMaterial, int32_t iAmount)
int32_t Get(int32_t iMaterial)
int32_t Amount[C4MaxMaterial]
const int32_t C4MaxMaterial
Definition: C4Landscape.h:25
void Add(int32_t iMaterial, int32_t iAmount)