3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
13 /* Compiled through wmapset.cpp */
15 uChar
** continent::TypeBuffer
;
16 short** continent::AltitudeBuffer
;
17 uChar
** continent::ContinentBuffer
;
19 continent::continent() { }
20 continent::continent(int Index
) : Index(Index
) { }
21 sLong
continent::GetSize() const { return Member
.size(); }
22 int continent::GetGTerrainAmount(int Type
) const { return GTerrainAmount
[Type
]; }
23 v2
continent::GetMember(int I
) const { return Member
[I
]; }
25 void continent::Save(outputfile
& SaveFile
) const
27 SaveFile
<< Name
<< Member
<< Index
;
30 void continent::Load(inputfile
& SaveFile
)
32 SaveFile
>> Name
>> Member
>> Index
;
35 void continent::AttachTo(continent
* Continent
)
37 for(feuLong c
= 0; c
< Member
.size(); ++c
)
38 ContinentBuffer
[Member
[c
].X
][Member
[c
].Y
] = Continent
->Index
;
40 if(!Continent
->Member
.size())
41 Continent
->Member
.swap(Member
);
44 Continent
->Member
.insert(Continent
->Member
.end(), Member
.begin(), Member
.end());
49 void continent::GenerateInfo()
51 GTerrainAmount
.resize(protocontainer
<gwterrain
>::GetSize() + 1);
53 for(feuLong c
= 0; c
< Member
.size(); ++c
)
54 ++GTerrainAmount
[TypeBuffer
[Member
[c
].X
][Member
[c
].Y
]];
56 Name
= CONST_S("number ");
60 v2
continent::GetRandomMember(int Type
)
62 if(!GTerrainAmount
[Type
])
63 ABORT("Shortage of terrain!");
65 v2
* TypeContainer
= new v2
[Member
.size()];
68 for(feuLong c
= 0; c
< Member
.size(); ++c
)
69 if(TypeBuffer
[Member
[c
].X
][Member
[c
].Y
] == Type
)
71 TypeContainer
[Index
++] = Member
[c
];
73 if(Index
== GetGTerrainAmount(Type
))
77 v2 Return
= TypeContainer
[RAND() % Index
];
78 delete [] TypeContainer
;
82 outputfile
& operator<<(outputfile
& SaveFile
, const continent
* Continent
)
87 Continent
->Save(SaveFile
);
95 inputfile
& operator>>(inputfile
& SaveFile
, continent
*& Continent
)
99 Continent
= new continent
;
100 Continent
->Load(SaveFile
);
106 void continent::Add(v2 Pos
)
108 Member
.push_back(Pos
);
109 ContinentBuffer
[Pos
.X
][Pos
.Y
] = Index
;