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"
21 #include "landscape/C4MaterialList.h"
22 
C4MaterialList()23 C4MaterialList::C4MaterialList()
24 {
25 	Default();
26 }
27 
~C4MaterialList()28 C4MaterialList::~C4MaterialList()
29 {
30 	Clear();
31 }
32 
Default()33 void C4MaterialList::Default()
34 {
35 	Reset();
36 }
37 
Clear()38 void C4MaterialList::Clear()
39 {
40 
41 }
42 
Reset()43 void C4MaterialList::Reset()
44 {
45 	for (int & cnt : Amount)
46 		cnt=0;
47 }
48 
Set(int32_t iMaterial,int32_t iAmount)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 
Add(int32_t iMaterial,int32_t iAmount)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 
Get(int32_t iMaterial)61 int32_t C4MaterialList::Get(int32_t iMaterial)
62 {
63 	if (!Inside<int32_t>(iMaterial,0,C4MaxMaterial)) return 0;
64 	return Amount[iMaterial];
65 }
66