MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / InitProcedurals

Function InitProcedurals

Descent3/procedurals.cpp:151–251  ·  view source on GitHub ↗

Goes through our array and clears the slots out

Source from the content-addressed store, hash-verified

149int Easter_egg_handle = -1;
150// Goes through our array and clears the slots out
151void InitProcedurals() {
152 int t;
153 int i;
154
155 // Load easter egg bitmap
156 Easter_egg_handle = bm_AllocLoadFileBitmap("FreakyEye.ogf", 0);
157 if (Easter_egg_handle == -1) {
158 mprintf(0, "Failed to load easter egg!\n");
159 }
160 for (i = 0; i < MAX_PROC_ELEMENTS; i++) {
161 DynamicProcElements[i].type = PROC_NONE;
162 Proc_free_list[i] = i;
163 }
164
165 Num_proc_elements = 0;
166
167 // Init our fade table
168 for (i = 0; i < 32768; i++) {
169 int r = (i >> 10) & 0x1f;
170 int g = (i >> 5) & 0x1f;
171 int b = (i) & 0x1f;
172 r = std::max(0, r - 1);
173 g = std::max(0, g - 1);
174 b = std::max(0, b - 1);
175 ProcFadeTable[i] = OPAQUE_FLAG | (r << 10) | (g << 5) | b;
176 }
177 // Init our palette
178 for (i = 0; i < 128; i++) {
179 float fr = (float)i / 127.0;
180 int ib = fr * 31.0;
181 int ig = fr * 16.0;
182 DefaultProcPalette[i] = OPAQUE_FLAG | (ig << 5) | (ib);
183 }
184 // Do lower part of table
185 for (i = 0; i < (NUM_WATER_SHADES); i++) {
186 float norm = ((float)i / (float)(NUM_WATER_SHADES - 1));
187 float lo_norm = std::min((norm / .5) * 1.0, 1.0);
188 float hi_norm = std::max(((norm - .5) / .5) * 1.0, 0.0);
189
190 for (int rcount = 0; rcount < 32; rcount++) {
191 for (int gcount = 0; gcount < 4; gcount++) {
192 int r = rcount;
193
194 int index = (rcount * 4) + gcount;
195
196 float fr = r;
197
198 r = std::min(fr * lo_norm + (31.0 * hi_norm), 31.0);
199
200 WaterProcTableHi[i][index] = OPAQUE_FLAG | (r << 10);
201 }
202 }
203 for (int bcount = 0; bcount < 32; bcount++) {
204 for (int gcount = 0; gcount < 8; gcount++) {
205 int b = bcount;
206 int index = gcount * 32 + bcount;
207
208 float fb = b;

Callers 1

InitTexturesFunction · 0.85

Calls 2

bm_AllocLoadFileBitmapFunction · 0.85
InitNoiseFunction · 0.85

Tested by

no test coverage detected