| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Routines to parse bitmaps.tbl |
| 23 |
* Only used for editor, since the registered version of descent 1. |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
#include "dxxsconf.h" |
| 28 |
#include <algorithm> |
| 29 |
#include <string> |
| 30 |
#include <stdio.h> |
| 31 |
#include <stdlib.h> |
| 32 |
#include <stdarg.h> |
| 33 |
#include <string.h> |
| 34 |
#include <ctype.h> |
| 35 |
#include <inttypes.h> |
| 36 |
|
| 37 |
#include "pstypes.h" |
| 38 |
#include "gr.h" |
| 39 |
#include "bm.h" |
| 40 |
#include "u_mem.h" |
| 41 |
#include "dxxerror.h" |
| 42 |
#include "object.h" |
| 43 |
#include "physfsx.h" |
| 44 |
#include "vclip.h" |
| 45 |
#include "effects.h" |
| 46 |
#include "polyobj.h" |
| 47 |
#include "wall.h" |
| 48 |
#include "textures.h" |
| 49 |
#include "game.h" |
| 50 |
#include "iff.h" |
| 51 |
#include "hostage.h" |
| 52 |
#include "powerup.h" |
| 53 |
#include "sounds.h" |
| 54 |
#include "piggy.h" |
| 55 |
#include "aistruct.h" |
| 56 |
#include "ai.h" |
| 57 |
#include "weapon.h" |
| 58 |
#include "gauges.h" |
| 59 |
#include "player.h" |
| 60 |
#include "endlevel.h" |
| 61 |
#include "cntrlcen.h" |
| 62 |
#include "physfs-serial.h" |
| 63 |
#include "args.h" |
| 64 |
#include "text.h" |
| 65 |
#if DXX_BUILD_DESCENT == 1 |
| 66 |
#include "fuelcen.h" |
| 67 |
#elif DXX_BUILD_DESCENT == 2 |
| 68 |
#include "gamepal.h" |
| 69 |
#include "interp.h" |
| 70 |
#endif |
| 71 |
#include "strutil.h" |
| 72 |
#if DXX_USE_EDITOR |
| 73 |
#include "editor/texpage.h" |
| 74 |
#endif |
| 75 |
|
| 76 |
#include "compiler-cf_assert.h" |
| 77 |
#include "compiler-range_for.h" |
| 78 |
#include "partial_range.h" |
| 79 |
#include "d_construct.h" |
| 80 |
#include "d_enumerate.h" |
| 81 |
#include "d_range.h" |
| 82 |
#include "d_zip.h" |
| 83 |
|
| 84 |
using std::min; |
| 85 |
|
| 86 |
namespace dcx { |
| 87 |
|
| 88 |
namespace { |
| 89 |
|
| 90 |
enum class bm_type : uint8_t |
| 91 |
{ |
| 92 |
none = 0xff, |
| 93 |
cockpit = 0, |
| 94 |
textures = 2, |
| 95 |
vclip = 4, |
| 96 |
effects = 5, |
| 97 |
eclip = 6, |
| 98 |
wall_anims = 12, |
| 99 |
wclip = 13, |
| 100 |
robot = 14, |
| 101 |
gauges = 20, |
| 102 |
/* if DXX_BUILD_DESCENT == 2 */ |
| 103 |
gauges_hires = 21, |
| 104 |
/* endif */ |
| 105 |
}; |
| 106 |
|
| 107 |
static bm_type current_bm_type = bm_type::none; |
| 108 |
|
| 109 |
uint8_t wall_explodes_flag; |
| 110 |
uint8_t wall_blastable_flag; |
| 111 |
uint8_t wall_hidden_flag; |
| 112 |
uint8_t tmap1_flag; //flag if this is used as tmap_num (not tmap_num2) |
| 113 |
|
| 114 |
struct get_texture_result |
| 115 |
{ |
| 116 |
std::size_t texture_count; |
| 117 |
std::size_t idx_updated_texture; |
| 118 |
bool reuse_texture; |
| 119 |
}; |
| 120 |
|
| 121 |
// remove extension from filename, doesn't work with paths. |
| 122 |
[[nodiscard]] |
| 123 |
static std::array<char, 20> removeext(const char *const filename) |
| 124 |
{ |
| 125 |
auto i = filename; |
| 126 |
auto p = i; |
| 127 |
for (; const char c = *i; ++i) |
| 128 |
{ |
| 129 |
if (c == '.') |
| 130 |
p = i; |
| 131 |
/* No break - find the last '.', not the first. */ |
| 132 |
} |
| 133 |
const std::size_t rawlen = p - filename; |
| 134 |
std::array<char, 20> out{}; |
| 135 |
const std::size_t copy_len = rawlen < out.size() ? rawlen : 0; |
| 136 |
memcpy(out.data(), filename, copy_len); |
| 137 |
return out; |
| 138 |
} |
| 139 |
|
| 140 |
} |
| 141 |
|
| 142 |
} |
| 143 |
|
| 144 |
namespace dsx { |
| 145 |
namespace { |
| 146 |
#if DXX_BUILD_DESCENT == 1 |
| 147 |
static short N_ObjBitmaps=0; |
| 148 |
#endif |
| 149 |
} |
| 150 |
|
| 151 |
#if DXX_USE_EDITOR |
| 152 |
powerup_names_array Powerup_names; |
| 153 |
robot_names_array Robot_names; |
| 154 |
#endif |
| 155 |
} |
| 156 |
|
| 157 |
namespace dcx { |
| 158 |
namespace { |
| 159 |
static short N_ObjBitmapPtrs; |
| 160 |
static int Num_robot_ais; |
| 161 |
//---------------- Internal variables --------------------------- |
| 162 |
static int SuperX = -1; |
| 163 |
static int Installed=0; |
| 164 |
static short tmap_count = 0; |
| 165 |
} |
| 166 |
} |
| 167 |
namespace dsx { |
| 168 |
namespace { |
| 169 |
#if DXX_BUILD_DESCENT == 1 |
| 170 |
static unsigned clip_count; |
| 171 |
static unsigned clip_num; |
| 172 |
static uint16_t frames; |
| 173 |
#elif DXX_BUILD_DESCENT == 2 |
| 174 |
static char *arg; |
| 175 |
static short clip_count = 0; |
| 176 |
static short clip_num; |
| 177 |
static short frames; |
| 178 |
static char *dest_bm; //clip number to play when destroyed |
| 179 |
#endif |
| 180 |
} |
| 181 |
} |
| 182 |
namespace dcx { |
| 183 |
namespace { |
| 184 |
static sound_effect sound_num; |
| 185 |
static sound_effect wall_open_sound, wall_close_sound; |
| 186 |
static float play_time; |
| 187 |
static int hit_sound = -1; |
| 188 |
static int abm_flag = 0; |
| 189 |
static int rod_flag = 0; |
| 190 |
static float vlighting=0; |
| 191 |
static int obj_eclip; |
| 192 |
static vclip_index dest_vclip; //what vclip to play when exploding |
| 193 |
static int dest_eclip; //what eclip to play when exploding |
| 194 |
static fix dest_size; //3d size of explosion |
| 195 |
static int crit_clip; //clip number to play when destroyed |
| 196 |
static int crit_flag; //flag if this is a destroyed eclip |
| 197 |
static int num_sounds=0; |
| 198 |
|
| 199 |
static int linenum; //line int table currently being parsed |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
//------------------- Useful macros and variables --------------- |
| 204 |
|
| 205 |
#define IFTOK(str) if (!strcmp(arg, str)) |
| 206 |
|
| 207 |
namespace dsx { |
| 208 |
namespace { |
| 209 |
// For the sake of LINT, defining prototypes to module's functions |
| 210 |
#if DXX_BUILD_DESCENT == 1 |
| 211 |
static void bm_read_sound(char *&arg, int skip, int pc_shareware); |
| 212 |
static void bm_read_robot_ai(d_robot_info_array &Robot_info, char *&arg, int skip); |
| 213 |
static void bm_read_robot(d_level_shared_robot_info_state &LevelSharedRobotInfoState, char *&arg, int skip); |
| 214 |
static void bm_read_object(char *&arg, int skip); |
| 215 |
static void bm_read_player_ship(char *&arg, int skip); |
| 216 |
static std::size_t bm_read_some_file(d_vclip_array &Vclip, std::size_t texture_count, const std::string &dest_bm, char *&arg, int skip); |
| 217 |
static void bm_read_weapon(char *&arg, int skip, int unused_flag); |
| 218 |
static void bm_read_powerup(char *&arg, int unused_flag); |
| 219 |
static void bm_read_hostage(char *&arg); |
| 220 |
static void verify_textures(); |
| 221 |
#elif DXX_BUILD_DESCENT == 2 |
| 222 |
#if DXX_USE_EDITOR |
| 223 |
static void bm_read_alias(void); |
| 224 |
#endif |
| 225 |
static void bm_read_marker(void); |
| 226 |
static void bm_read_robot_ai(d_robot_info_array &Robot_info, int skip); |
| 227 |
static void bm_read_powerup(int unused_flag); |
| 228 |
static void bm_read_hostage(void); |
| 229 |
static void bm_read_robot(d_level_shared_robot_info_state &LevelSharedRobotInfoState, int skip); |
| 230 |
static void bm_read_weapon(int skip, int unused_flag); |
| 231 |
static void bm_read_reactor(void); |
| 232 |
static void bm_read_exitmodel(void); |
| 233 |
static void bm_read_player_ship(void); |
| 234 |
static std::size_t bm_read_some_file(d_vclip_array &Vclip, std::size_t texture_count, int skip); |
| 235 |
static void bm_read_sound(int skip); |
| 236 |
static void clear_to_end_of_line(void); |
| 237 |
static void verify_textures(void); |
| 238 |
#endif |
| 239 |
} |
| 240 |
|
| 241 |
//--------------------------------------------------------------- |
| 242 |
int compute_average_pixel(grs_bitmap *n) |
| 243 |
{ |
| 244 |
int total_red, total_green, total_blue; |
| 245 |
|
| 246 |
#if DXX_BUILD_DESCENT == 2 |
| 247 |
auto pptr = n->bm_data; |
| 248 |
#endif |
| 249 |
const unsigned bm_h = n->bm_h, bm_w = n->bm_w; |
| 250 |
|
| 251 |
total_red = 0; |
| 252 |
total_green = 0; |
| 253 |
total_blue = 0; |
| 254 |
|
| 255 |
const auto product = (bm_h * bm_w); |
| 256 |
#if DXX_BUILD_DESCENT == 1 |
| 257 |
for (unsigned row = 0; row < bm_h; row++) |
| 258 |
for (unsigned column = 0; column < bm_w; column++) |
| 259 |
#elif DXX_BUILD_DESCENT == 2 |
| 260 |
for (auto counter = product; counter--;) |
| 261 |
#endif |
| 262 |
{ |
| 263 |
#if DXX_BUILD_DESCENT == 1 |
| 264 |
const auto color = gr_gpixel (*n, column, row); |
| 265 |
const auto &p = gr_palette[color]; |
| 266 |
#elif DXX_BUILD_DESCENT == 2 |
| 267 |
const auto &p = gr_palette[*pptr++]; |
| 268 |
#endif |
| 269 |
total_red += p.r; |
| 270 |
total_green += p.g; |
| 271 |
total_blue += p.b; |
| 272 |
} |
| 273 |
|
| 274 |
total_red /= product; |
| 275 |
total_green /= product; |
| 276 |
total_blue /= product; |
| 277 |
|
| 278 |
return BM_XRGB(total_red/2, total_green/2, total_blue/2); |
| 279 |
} |
| 280 |
|
| 281 |
namespace { |
| 282 |
|
| 283 |
//--------------------------------------------------------------- |
| 284 |
// Loads a bitmap from either the piggy file, a r64 file, or a |
| 285 |
// whatever extension is passed. |
| 286 |
|
| 287 |
static bitmap_index bm_load_sub(const int skip, const char *const filename) |
| 288 |
{ |
| 289 |
palette_array_t newpal; |
| 290 |
|
| 291 |
if (skip) { |
| 292 |
return bitmap_index{}; |
| 293 |
} |
| 294 |
|
| 295 |
#if DXX_BUILD_DESCENT == 1 |
| 296 |
const auto &&fname = removeext(filename); |
| 297 |
#elif DXX_BUILD_DESCENT == 2 |
| 298 |
std::array<char, 20> fname{}; |
| 299 |
const auto path = d_splitpath(filename); |
| 300 |
if (path.base_end - path.base_start >= fname.size()) |
| 301 |
Error("File <%s> - bitmap error, filename too long", filename); |
| 302 |
memcpy(fname.data(), path.base_start, path.base_end - path.base_start); |
| 303 |
#endif |
| 304 |
|
| 305 |
if (const auto bitmap_num = piggy_find_bitmap(fname); bitmap_num != bitmap_index{}) |
| 306 |
{ |
| 307 |
return bitmap_num; |
| 308 |
} |
| 309 |
|
| 310 |
grs_bitmap n; |
| 311 |
if (const auto iff_error{iff_read_bitmap(filename, n, &newpal)}; iff_error != iff_status_code::no_error) |
| 312 |
{ |
| 313 |
Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum); |
| 314 |
} |
| 315 |
|
| 316 |
gr_remap_bitmap_good(n, newpal, iff_has_transparency ? iff_transparent_color : -1, SuperX); |
| 317 |
|
| 318 |
#if !DXX_USE_OGL |
| 319 |
n.avg_color = compute_average_pixel(&n); |
| 320 |
#endif |
| 321 |
return piggy_register_bitmap(n, fname, 0); |
| 322 |
} |
| 323 |
|
| 324 |
static void ab_load(int skip, const char * filename, std::array<bitmap_index, MAX_BITMAPS_PER_BRUSH> &bmp, unsigned *nframes ) |
| 325 |
{ |
| 326 |
if (skip) { |
| 327 |
Assert( bogus_bitmap_initialized != 0 ); |
| 328 |
#if DXX_BUILD_DESCENT == 1 |
| 329 |
bmp[0] = piggy_register_bitmap(bogus_bitmap, "bogus", 0); |
| 330 |
#elif DXX_BUILD_DESCENT == 2 |
| 331 |
bmp[0] = {}; //index of bogus bitmap==0 (I think) //&bogus_bitmap; |
| 332 |
#endif |
| 333 |
*nframes = 1; |
| 334 |
return; |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
#if DXX_BUILD_DESCENT == 1 |
| 339 |
const auto &&fname = removeext(filename); |
| 340 |
#elif DXX_BUILD_DESCENT == 2 |
| 341 |
const auto path = d_splitpath(filename); |
| 342 |
#endif |
| 343 |
|
| 344 |
{ |
| 345 |
unsigned i; |
| 346 |
for (i=0; i<MAX_BITMAPS_PER_BRUSH; i++ ) { |
| 347 |
std::array<char, 24> tempname; |
| 348 |
#if DXX_BUILD_DESCENT == 1 |
| 349 |
const auto len = snprintf(tempname.data(), tempname.size(), "%.16s#%d", fname.data(), i); |
| 350 |
#elif DXX_BUILD_DESCENT == 2 |
| 351 |
const auto len = snprintf(tempname.data(), tempname.size(), "%.*s#%d", DXX_ptrdiff_cast_int(path.base_end - path.base_start), path.base_start, i); |
| 352 |
#endif |
| 353 |
const auto bi = piggy_find_bitmap(std::span<const char>(tempname.data(), len)); |
| 354 |
if (bi == bitmap_index{}) |
| 355 |
break; |
| 356 |
bmp[i] = bi; |
| 357 |
} |
| 358 |
|
| 359 |
if (i) { |
| 360 |
*nframes = i; |
| 361 |
return; |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
auto read_result{iff_read_animbrush(filename)}; |
| 366 |
auto &bm = read_result.bm; |
| 367 |
auto &newpal = read_result.palette; |
| 368 |
*nframes = read_result.n_bitmaps; |
| 369 |
if (const auto iff_error{read_result.status}; iff_error != iff_status_code::no_error) |
| 370 |
{ |
| 371 |
Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum); |
| 372 |
} |
| 373 |
|
| 374 |
const auto nf = *nframes; |
| 375 |
#if DXX_BUILD_DESCENT == 1 |
| 376 |
if (nf >= bm.size()) |
| 377 |
return; |
| 378 |
#endif |
| 379 |
range_for (const uint_fast32_t i, xrange(nf)) |
| 380 |
{ |
| 381 |
std::array<char, 24> tempname; |
| 382 |
cf_assert(i < bm.size()); |
| 383 |
#if DXX_BUILD_DESCENT == 1 |
| 384 |
snprintf(tempname.data(), tempname.size(), "%s#%" PRIuFAST32, fname.data(), i); |
| 385 |
#elif DXX_BUILD_DESCENT == 2 |
| 386 |
snprintf(tempname.data(), tempname.size(), "%.*s#%" PRIuFAST32, DXX_ptrdiff_cast_int(path.base_end - path.base_start), path.base_start, i ); |
| 387 |
#endif |
| 388 |
gr_remap_bitmap_good(*bm[i].get(), newpal, iff_has_transparency ? iff_transparent_color : -1, SuperX); |
| 389 |
#if !DXX_USE_OGL |
| 390 |
bm[i]->avg_color = compute_average_pixel(bm[i].get()); |
| 391 |
#endif |
| 392 |
bmp[i] = piggy_register_bitmap(*bm[i].get(), tempname, 0); |
| 393 |
} |
| 394 |
} |
| 395 |
|
| 396 |
} |
| 397 |
|
| 398 |
int ds_load(int skip, const char * filename ) { |
| 399 |
char rawname[100]; |
| 400 |
|
| 401 |
if (skip) { |
| 402 |
// We tell piggy_register_sound it's in the pig file, when in actual fact it's in no file |
| 403 |
// This just tells piggy_close not to attempt to free it |
| 404 |
return piggy_register_sound(bogus_sound, "bogus"); |
| 405 |
} |
| 406 |
|
| 407 |
const auto &&fname = removeext(filename); |
| 408 |
#if DXX_BUILD_DESCENT == 1 |
| 409 |
snprintf(rawname, sizeof(rawname), "Sounds/%s.raw", fname.data()); |
| 410 |
#elif DXX_BUILD_DESCENT == 2 |
| 411 |
snprintf(rawname, sizeof(rawname), "Sounds/%s.r%s", fname.data(), (GameArg.SndDigiSampleRate == sound_sample_rate::_22k) ? "22" : "aw"); |
| 412 |
#endif |
| 413 |
|
| 414 |
const auto i = piggy_find_sound(fname); |
| 415 |
if (i!=255) { |
| 416 |
return i; |
| 417 |
} |
| 418 |
if (auto cfp{PHYSFSX_openReadBuffered_updateCase(rawname).first}) |
| 419 |
{ |
| 420 |
digi_sound n; |
| 421 |
n.length = PHYSFS_fileLength( cfp ); |
| 422 |
n.data = digi_sound::allocated_data{std::make_unique<uint8_t[]>(n.length), game_sound_offset{}}; |
| 423 |
PHYSFSX_readBytes(cfp, n.data.get(), n.length); |
| 424 |
n.freq = 11025; |
| 425 |
return piggy_register_sound(n, fname); |
| 426 |
} else { |
| 427 |
return 255; |
| 428 |
} |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
namespace dcx { |
| 433 |
namespace { |
| 434 |
|
| 435 |
//parse a float |
| 436 |
static float get_float() |
| 437 |
{ |
| 438 |
char *xarg; |
| 439 |
|
| 440 |
xarg = strtok( NULL, space_tab ); |
| 441 |
return atof( xarg ); |
| 442 |
} |
| 443 |
|
| 444 |
//parse an int |
| 445 |
static int get_int() |
| 446 |
{ |
| 447 |
char *xarg; |
| 448 |
|
| 449 |
xarg = strtok( NULL, space_tab ); |
| 450 |
return atoi( xarg ); |
| 451 |
} |
| 452 |
|
| 453 |
static void set_texture_fname(d_fname &fname, const char *name) |
| 454 |
{ |
| 455 |
fname.copy_if(name, FILENAME_LEN); |
| 456 |
REMOVE_DOTS(fname.data()); |
| 457 |
} |
| 458 |
|
| 459 |
} |
| 460 |
} |
| 461 |
|
| 462 |
namespace dsx { |
| 463 |
namespace { |
| 464 |
|
| 465 |
//loads a texture and returns the texture num |
| 466 |
static get_texture_result get_texture(d_level_unique_tmap_info_state::TmapInfo_array &TmapInfo, const int skip, const char *const name, std::size_t texture_count) |
| 467 |
{ |
| 468 |
d_fname short_name; |
| 469 |
short_name.copy_if(name, FILENAME_LEN); |
| 470 |
REMOVE_DOTS(short_name.data()); |
| 471 |
const unsigned t = texture_count; |
| 472 |
for (const auto &&[i, ti] : enumerate(partial_range(TmapInfo, t))) |
| 473 |
{ |
| 474 |
if (!d_stricmp(ti.filename, short_name)) |
| 475 |
return { |
| 476 |
.texture_count = texture_count, |
| 477 |
.idx_updated_texture = i, |
| 478 |
.reuse_texture = true |
| 479 |
}; |
| 480 |
} |
| 481 |
Textures[t] = bm_load_sub(skip, name); |
| 482 |
TmapInfo[t].filename.copy_if(short_name); |
| 483 |
++texture_count; |
| 484 |
NumTextures = texture_count; |
| 485 |
return { |
| 486 |
.texture_count = texture_count, |
| 487 |
.idx_updated_texture = t, |
| 488 |
.reuse_texture = false |
| 489 |
}; |
| 490 |
} |
| 491 |
|
| 492 |
} |
| 493 |
|
| 494 |
#define LINEBUF_SIZE 600 |
| 495 |
|
| 496 |
#if DXX_BUILD_DESCENT == 1 || (DXX_BUILD_DESCENT == 2 && DXX_USE_EDITOR) |
| 497 |
//----------------------------------------------------------------- |
| 498 |
// Initializes all properties and bitmaps from BITMAPS.TBL file. |
| 499 |
// This is called when the editor is IN. |
| 500 |
// If no editor, properties_read_cmp() is called. |
| 501 |
int gamedata_read_tbl(d_level_shared_robot_info_state &LevelSharedRobotInfoState, d_vclip_array &Vclip, int pc_shareware) |
| 502 |
{ |
| 503 |
std::size_t texture_count{}; |
| 504 |
auto &Effects = LevelUniqueEffectsClipState.Effects; |
| 505 |
auto &TmapInfo = LevelUniqueTmapInfoState.TmapInfo; |
| 506 |
auto &WallAnims = GameSharedState.WallAnims; |
| 507 |
int have_bin_tbl; |
| 508 |
|
| 509 |
#if DXX_BUILD_DESCENT == 1 |
| 510 |
std::string dest_bm; |
| 511 |
ObjType[0] = OL_PLAYER; |
| 512 |
ObjId[0] = {}; |
| 513 |
Num_total_object_types = 1; |
| 514 |
#elif DXX_BUILD_DESCENT == 2 |
| 515 |
// Open BITMAPS.TBL for reading. |
| 516 |
have_bin_tbl = 0; |
| 517 |
auto InfoFile = PHYSFSX_openReadBuffered("BITMAPS.TBL").first; |
| 518 |
if (!InfoFile) |
| 519 |
{ |
| 520 |
InfoFile = PHYSFSX_openReadBuffered("BITMAPS.BIN").first; |
| 521 |
if (!InfoFile) |
| 522 |
return 0; //missing BITMAPS.TBL and BITMAPS.BIN file |
| 523 |
have_bin_tbl = 1; |
| 524 |
} |
| 525 |
|
| 526 |
#define DEFAULT_PIG_PALETTE "groupa.256" |
| 527 |
gr_use_palette_table(DEFAULT_PIG_PALETTE); |
| 528 |
load_palette_for_pig(DEFAULT_PIG_PALETTE); //special: tell palette code which pig is loaded |
| 529 |
#endif |
| 530 |
|
| 531 |
Sounds.fill(sound_effect::None); |
| 532 |
AltSounds.fill(sound_effect::None); |
| 533 |
|
| 534 |
DXX_MAKE_VAR_UNDEFINED(TmapInfo); |
| 535 |
range_for (auto &ti, TmapInfo) |
| 536 |
{ |
| 537 |
ti.eclip_num = eclip_none; |
| 538 |
ti.flags = {}; |
| 539 |
#if DXX_BUILD_DESCENT == 2 |
| 540 |
ti.slide_u = ti.slide_v = 0; |
| 541 |
ti.destroyed = -1; |
| 542 |
#endif |
| 543 |
} |
| 544 |
|
| 545 |
#if DXX_BUILD_DESCENT == 2 |
| 546 |
DXX_MAKE_VAR_UNDEFINED(Reactors); |
| 547 |
range_for (auto &i, Reactors) |
| 548 |
i.model_num = polygon_model_index::None; |
| 549 |
#endif |
| 550 |
|
| 551 |
Num_effects = 0; |
| 552 |
DXX_MAKE_VAR_UNDEFINED(Effects); |
| 553 |
range_for (auto &ec, Effects) |
| 554 |
{ |
| 555 |
//Effects[i].bm_ptr = (grs_bitmap **) -1; |
| 556 |
ec.changing_wall_texture = -1; |
| 557 |
ec.changing_object_texture = object_bitmap_index::None; |
| 558 |
ec.segnum = segment_none; |
| 559 |
ec.vc.num_frames = -1; //another mark of being unused |
| 560 |
} |
| 561 |
|
| 562 |
for (auto &&[dying, dead] : zip(Dying_modelnums, Dead_modelnums)) |
| 563 |
dying = dead = polygon_model_index::None; |
| 564 |
|
| 565 |
Num_vclips = 0; |
| 566 |
DXX_MAKE_VAR_UNDEFINED(Vclip); |
| 567 |
range_for (auto &vc, Vclip) |
| 568 |
{ |
| 569 |
vc.num_frames = -1; |
| 570 |
vc.flags = 0; |
| 571 |
} |
| 572 |
|
| 573 |
DXX_MAKE_VAR_UNDEFINED(WallAnims); |
| 574 |
range_for (auto &wa, WallAnims) |
| 575 |
wa.num_frames = wclip_frames_none; |
| 576 |
Num_wall_anims = 0; |
| 577 |
|
| 578 |
if (Installed) |
| 579 |
return 1; |
| 580 |
|
| 581 |
Installed = 1; |
| 582 |
|
| 583 |
#if DXX_BUILD_DESCENT == 1 |
| 584 |
// Open BITMAPS.TBL for reading. |
| 585 |
have_bin_tbl = 0; |
| 586 |
auto &&[InfoFile, physfserr] = PHYSFSX_openReadBuffered("BITMAPS.TBL"); |
| 587 |
if (!InfoFile) |
| 588 |
{ |
| 589 |
auto &&[InfoFileBin, physfserr2] = PHYSFSX_openReadBuffered("BITMAPS.BIN"); |
| 590 |
if (!InfoFileBin) |
| 591 |
Error("Failed to open BITMAPS.TBL and BITMAPS.BIN: \"%s\", \"%s\"\n", PHYSFS_getErrorByCode(physfserr), PHYSFS_getErrorByCode(physfserr2)); |
| 592 |
InfoFile = std::move(InfoFileBin); |
| 593 |
have_bin_tbl = 1; |
| 594 |
} |
| 595 |
#endif |
| 596 |
linenum = 0; |
| 597 |
|
| 598 |
PHYSFS_seek(InfoFile, 0L); |
| 599 |
|
| 600 |
for (PHYSFSX_gets_line_t<LINEBUF_SIZE> inputline; PHYSFSX_fgets(inputline, InfoFile);) |
| 601 |
{ |
| 602 |
const char *temp_ptr; |
| 603 |
int skip; |
| 604 |
|
| 605 |
linenum++; |
| 606 |
if (have_bin_tbl) { // is this a binary tbl file |
| 607 |
decode_text_line (inputline); |
| 608 |
} else { |
| 609 |
for (std::size_t l; inputline[(l=strlen(inputline))-2]=='\\';) |
| 610 |
{ |
| 611 |
if (!isspace(inputline[l-3])) { //if not space before backslash... |
| 612 |
inputline[l-2] = ' '; //add one |
| 613 |
l++; |
| 614 |
} |
| 615 |
if (!PHYSFSX_fgets(inputline, InfoFile, l - 2)) |
| 616 |
break; |
| 617 |
linenum++; |
| 618 |
} |
| 619 |
} |
| 620 |
|
| 621 |
REMOVE_EOL(inputline); |
| 622 |
if (strchr(inputline, ';')!=NULL) REMOVE_COMMENTS(inputline); |
| 623 |
|
| 624 |
if (strlen(inputline) == LINEBUF_SIZE-1) |
| 625 |
Error("Possible line truncation in BITMAPS.TBL on line %d\n",linenum); |
| 626 |
|
| 627 |
SuperX = -1; |
| 628 |
|
| 629 |
if ( (temp_ptr=strstr( inputline, "superx=" )) ) { |
| 630 |
/* Historically, this was done with atoi, so the input |
| 631 |
* source was allowed to have unconvertible characters. |
| 632 |
* Accept such lines by ignoring any trailing content. |
| 633 |
*/ |
| 634 |
SuperX = strtol(&temp_ptr[7], nullptr, 10); |
| 635 |
#if DXX_BUILD_DESCENT == 2 |
| 636 |
Assert(SuperX == 254); |
| 637 |
//the superx color isn't kept around, so the new piggy regeneration |
| 638 |
//code doesn't know what it is, so it assumes that it's 254, so |
| 639 |
//this code requires that it be 254 |
| 640 |
#endif |
| 641 |
} |
| 642 |
|
| 643 |
#if DXX_BUILD_DESCENT == 1 |
| 644 |
char *arg = strtok( inputline, space_tab ); |
| 645 |
#elif DXX_BUILD_DESCENT == 2 |
| 646 |
arg = strtok( inputline, space_tab ); |
| 647 |
#endif |
| 648 |
if (arg && arg[0] == '@') |
| 649 |
{ |
| 650 |
arg++; |
| 651 |
skip = pc_shareware; |
| 652 |
} else |
| 653 |
skip = 0; |
| 654 |
|
| 655 |
while (arg != NULL ) |
| 656 |
{ |
| 657 |
// Check all possible flags and defines. |
| 658 |
if (*arg == '$') current_bm_type = bm_type::none; // reset to no flags as default. |
| 659 |
|
| 660 |
IFTOK("$COCKPIT") current_bm_type = bm_type::cockpit; |
| 661 |
else IFTOK("$GAUGES") {current_bm_type = bm_type::gauges; clip_count = 0;} |
| 662 |
#if DXX_BUILD_DESCENT == 1 |
| 663 |
else IFTOK("$SOUND") bm_read_sound(arg, skip, pc_shareware); |
| 664 |
#elif DXX_BUILD_DESCENT == 2 |
| 665 |
else IFTOK("$GAUGES_HIRES"){current_bm_type = bm_type::gauges_hires; clip_count = 0;} |
| 666 |
else IFTOK("$ALIAS") bm_read_alias(); |
| 667 |
else IFTOK("$SOUND") bm_read_sound(skip); |
| 668 |
#endif |
| 669 |
else IFTOK("$DOOR_ANIMS") current_bm_type = bm_type::wall_anims; |
| 670 |
else IFTOK("$WALL_ANIMS") current_bm_type = bm_type::wall_anims; |
| 671 |
else IFTOK("$TEXTURES") current_bm_type = bm_type::textures; |
| 672 |
else IFTOK("$VCLIP") {current_bm_type = bm_type::vclip; vlighting = 0; clip_count = 0;} |
| 673 |
else IFTOK("$ECLIP") |
| 674 |
{ |
| 675 |
current_bm_type = bm_type::eclip; |
| 676 |
vlighting = 0; |
| 677 |
clip_count = 0; |
| 678 |
obj_eclip=0; |
| 679 |
#if DXX_BUILD_DESCENT == 1 |
| 680 |
dest_bm.clear(); |
| 681 |
#elif DXX_BUILD_DESCENT == 2 |
| 682 |
dest_bm=NULL; |
| 683 |
#endif |
| 684 |
dest_vclip = vclip_index::None; |
| 685 |
dest_eclip=eclip_none; |
| 686 |
dest_size=-1; |
| 687 |
crit_clip=-1; |
| 688 |
crit_flag=0; |
| 689 |
sound_num = sound_effect::None; |
| 690 |
} |
| 691 |
else IFTOK("$WCLIP") |
| 692 |
{ |
| 693 |
current_bm_type = bm_type::wclip; |
| 694 |
vlighting = 0; |
| 695 |
clip_count = 0; |
| 696 |
wall_open_sound = wall_close_sound = sound_effect::None; |
| 697 |
wall_explodes_flag = 0; |
| 698 |
wall_blastable_flag = 0; |
| 699 |
tmap1_flag=0; |
| 700 |
wall_hidden_flag = 0; |
| 701 |
} |
| 702 |
|
| 703 |
else IFTOK("$EFFECTS") {current_bm_type = bm_type::effects; clip_num = 0;} |
| 704 |
|
| 705 |
#if DXX_USE_EDITOR |
| 706 |
else IFTOK("!METALS_FLAG") TextureMetals = texture_count; |
| 707 |
else IFTOK("!LIGHTS_FLAG") TextureLights = texture_count; |
| 708 |
else IFTOK("!EFFECTS_FLAG") TextureEffects = texture_count; |
| 709 |
#else |
| 710 |
#if DXX_BUILD_DESCENT == 1 |
| 711 |
else IFTOK("!METALS_FLAG") ; |
| 712 |
else IFTOK("!LIGHTS_FLAG") ; |
| 713 |
else IFTOK("!EFFECTS_FLAG") ; |
| 714 |
#endif |
| 715 |
#endif |
| 716 |
|
| 717 |
else IFTOK("lighting") TmapInfo[texture_count-1].lighting = fl2f(get_float()); |
| 718 |
else IFTOK("damage") TmapInfo[texture_count-1].damage = fl2f(get_float()); |
| 719 |
else IFTOK("volatile") TmapInfo[texture_count-1].flags |= tmapinfo_flag::lava; |
| 720 |
#if DXX_BUILD_DESCENT == 2 |
| 721 |
else IFTOK("goal_blue") TmapInfo[texture_count-1].flags |= tmapinfo_flag::goal_blue; |
| 722 |
else IFTOK("goal_red") TmapInfo[texture_count-1].flags |= tmapinfo_flag::goal_red; |
| 723 |
else IFTOK("water") TmapInfo[texture_count-1].flags |= tmapinfo_flag::water; |
| 724 |
else IFTOK("force_field") TmapInfo[texture_count-1].flags |= tmapinfo_flag::force_field; |
| 725 |
else IFTOK("slide") {TmapInfo[texture_count-1].slide_u = fl2f(get_float())>>8; TmapInfo[texture_count-1].slide_v = fl2f(get_float())>>8;} |
| 726 |
else IFTOK("destroyed") |
| 727 |
{ |
| 728 |
const auto t = texture_count - 1; |
| 729 |
const auto &&r = get_texture(LevelUniqueTmapInfoState.TmapInfo, 0, strtok(nullptr, space_tab), texture_count); |
| 730 |
texture_count = r.texture_count; |
| 731 |
TmapInfo[t].destroyed = r.idx_updated_texture; |
| 732 |
} |
| 733 |
#endif |
| 734 |
//else IFTOK("Num_effects") Num_effects = get_int(); |
| 735 |
else IFTOK("Num_wall_anims") Num_wall_anims = get_int(); |
| 736 |
else IFTOK("clip_num") clip_num = get_int(); |
| 737 |
#if DXX_BUILD_DESCENT == 1 |
| 738 |
else IFTOK("dest_bm") |
| 739 |
{ |
| 740 |
char *p = strtok( NULL, space_tab ); |
| 741 |
if (p) |
| 742 |
dest_bm = p; |
| 743 |
else |
| 744 |
dest_bm.clear(); |
| 745 |
} |
| 746 |
#elif DXX_BUILD_DESCENT == 2 |
| 747 |
else IFTOK("dest_bm") dest_bm = strtok( NULL, space_tab ); |
| 748 |
#endif |
| 749 |
else IFTOK("dest_vclip") dest_vclip = build_vclip_index_from_untrusted(get_int()); |
| 750 |
else IFTOK("dest_eclip") dest_eclip = get_int(); |
| 751 |
else IFTOK("dest_size") dest_size = fl2f(get_float()); |
| 752 |
else IFTOK("crit_clip") crit_clip = get_int(); |
| 753 |
else IFTOK("crit_flag") crit_flag = get_int(); |
| 754 |
else IFTOK("sound_num") sound_num = static_cast<sound_effect>(get_int()); |
| 755 |
else IFTOK("frames") frames = get_int(); |
| 756 |
else IFTOK("time") play_time = get_float(); |
| 757 |
else IFTOK("obj_eclip") obj_eclip = get_int(); |
| 758 |
else IFTOK("hit_sound") hit_sound = get_int(); |
| 759 |
else IFTOK("abm_flag") abm_flag = get_int(); |
| 760 |
else IFTOK("tmap1_flag") tmap1_flag = get_int() ? WCF_TMAP1 : 0; |
| 761 |
else IFTOK("vlighting") vlighting = get_float(); |
| 762 |
else IFTOK("rod_flag") rod_flag = get_int(); |
| 763 |
else IFTOK("superx") get_int(); |
| 764 |
else IFTOK("open_sound") wall_open_sound = static_cast<sound_effect>(get_int()); |
| 765 |
else IFTOK("close_sound") wall_close_sound = static_cast<sound_effect>(get_int()); |
| 766 |
else IFTOK("explodes") wall_explodes_flag = get_int() ? WCF_EXPLODES : 0; |
| 767 |
else IFTOK("blastable") wall_blastable_flag = get_int() ? WCF_BLASTABLE : 0; |
| 768 |
else IFTOK("hidden") wall_hidden_flag = get_int() ? WCF_HIDDEN : 0; |
| 769 |
#if DXX_BUILD_DESCENT == 1 |
| 770 |
else IFTOK("$ROBOT_AI") bm_read_robot_ai(LevelSharedRobotInfoState.Robot_info, arg, skip); |
| 771 |
|
| 772 |
else IFTOK("$POWERUP") {bm_read_powerup(arg, 0); continue;} |
| 773 |
else IFTOK("$POWERUP_UNUSED") {bm_read_powerup(arg, 1); continue;} |
| 774 |
else IFTOK("$HOSTAGE") {bm_read_hostage(arg); continue;} |
| 775 |
else IFTOK("$ROBOT") {bm_read_robot(LevelSharedRobotInfoState, arg, skip); continue;} |
| 776 |
else IFTOK("$WEAPON") {bm_read_weapon(arg, skip, 0); continue;} |
| 777 |
else IFTOK("$WEAPON_UNUSED") {bm_read_weapon(arg, skip, 1); continue;} |
| 778 |
else IFTOK("$OBJECT") {bm_read_object(arg, skip); continue;} |
| 779 |
else IFTOK("$PLAYER_SHIP") {bm_read_player_ship(arg, skip); continue;} |
| 780 |
#elif DXX_BUILD_DESCENT == 2 |
| 781 |
else IFTOK("$ROBOT_AI") bm_read_robot_ai(LevelSharedRobotInfoState.Robot_info, skip); |
| 782 |
|
| 783 |
else IFTOK("$POWERUP") {bm_read_powerup(0); continue;} |
| 784 |
else IFTOK("$POWERUP_UNUSED") {bm_read_powerup(1); continue;} |
| 785 |
else IFTOK("$HOSTAGE") {bm_read_hostage(); continue;} |
| 786 |
else IFTOK("$ROBOT") {bm_read_robot(LevelSharedRobotInfoState, skip); continue;} |
| 787 |
else IFTOK("$WEAPON") {bm_read_weapon(skip, 0); continue;} |
| 788 |
else IFTOK("$WEAPON_UNUSED") {bm_read_weapon(skip, 1); continue;} |
| 789 |
else IFTOK("$REACTOR") {bm_read_reactor(); continue;} |
| 790 |
else IFTOK("$MARKER") {bm_read_marker(); continue;} |
| 791 |
else IFTOK("$PLAYER_SHIP") {bm_read_player_ship(); continue;} |
| 792 |
else IFTOK("$EXIT") { |
| 793 |
if (pc_shareware) |
| 794 |
bm_read_exitmodel(); |
| 795 |
else |
| 796 |
clear_to_end_of_line(); |
| 797 |
continue; |
| 798 |
} |
| 799 |
#endif |
| 800 |
else { //not a special token, must be a bitmap! |
| 801 |
|
| 802 |
// Remove any illegal/unwanted spaces and tabs at this point. |
| 803 |
while ((*arg=='\t') || (*arg==' ')) arg++; |
| 804 |
if (*arg == '\0') { break; } |
| 805 |
|
| 806 |
#if DXX_BUILD_DESCENT == 2 |
| 807 |
//check for '=' in token, indicating error |
| 808 |
if (strchr(arg,'=')) |
| 809 |
Error("Unknown token <'%s'> on line %d of BITMAPS.TBL",arg,linenum); |
| 810 |
#endif |
| 811 |
|
| 812 |
// Otherwise, 'arg' is apparently a bitmap filename. |
| 813 |
// Load bitmap and process it below: |
| 814 |
#if DXX_BUILD_DESCENT == 1 |
| 815 |
texture_count = bm_read_some_file(Vclip, texture_count, dest_bm, arg, skip); |
| 816 |
#elif DXX_BUILD_DESCENT == 2 |
| 817 |
texture_count = bm_read_some_file(Vclip, texture_count, skip); |
| 818 |
#endif |
| 819 |
|
| 820 |
} |
| 821 |
|
| 822 |
arg = strtok( NULL, equal_space ); |
| 823 |
continue; |
| 824 |
} |
| 825 |
} |
| 826 |
|
| 827 |
NumTextures = texture_count; |
| 828 |
LevelUniqueTmapInfoState.Num_tmaps = tmap_count; |
| 829 |
|
| 830 |
#if DXX_BUILD_DESCENT == 2 |
| 831 |
Textures[NumTextures++] = {}; //entry for bogus tmap |
| 832 |
InfoFile.reset(); |
| 833 |
#endif |
| 834 |
assert(LevelSharedRobotInfoState.N_robot_types == Num_robot_ais); //should be one ai info per robot |
| 835 |
|
| 836 |
verify_textures(); |
| 837 |
|
| 838 |
//check for refereced but unused clip count |
| 839 |
for (auto &&[idx, e] : enumerate(Effects)) |
| 840 |
{ |
| 841 |
if ((e.changing_wall_texture != -1 || e.changing_object_texture != object_bitmap_index::None) && e.vc.num_frames == ~0u) |
| 842 |
Error("EClip %" DXX_PRI_size_type " referenced (by polygon object?), but not defined", idx); |
| 843 |
} |
| 844 |
|
| 845 |
#if DXX_BUILD_DESCENT == 2 |
| 846 |
#ifndef NDEBUG |
| 847 |
{ |
| 848 |
//make sure all alt sounds refer to valid main sounds |
| 849 |
for (unsigned i = 0; i < num_sounds; ++i) |
| 850 |
{ |
| 851 |
int alt = AltSounds[i]; |
| 852 |
Assert(alt==0 || alt==-1 || Sounds[alt]!=255); |
| 853 |
} |
| 854 |
} |
| 855 |
#endif |
| 856 |
|
| 857 |
gr_use_palette_table(D2_DEFAULT_PALETTE); |
| 858 |
#endif |
| 859 |
|
| 860 |
return 0; |
| 861 |
} |
| 862 |
#endif |
| 863 |
|
| 864 |
namespace { |
| 865 |
|
| 866 |
void verify_textures() |
| 867 |
{ |
| 868 |
#if DXX_BUILD_DESCENT == 2 |
| 869 |
auto &Effects = LevelUniqueEffectsClipState.Effects; |
| 870 |
#endif |
| 871 |
grs_bitmap * bmp; |
| 872 |
int j; |
| 873 |
j=0; |
| 874 |
const auto Num_tmaps = LevelUniqueTmapInfoState.Num_tmaps; |
| 875 |
for (uint_fast32_t i = 0; i < Num_tmaps; ++i) |
| 876 |
{ |
| 877 |
bmp = &GameBitmaps[Textures[i]]; |
| 878 |
if ( (bmp->bm_w!=64)||(bmp->bm_h!=64)||(bmp->bm_rowsize!=64) ) { |
| 879 |
j++; |
| 880 |
} |
| 881 |
} |
| 882 |
if (j) |
| 883 |
Error("%d textures were not 64x64.",j); |
| 884 |
|
| 885 |
#if DXX_BUILD_DESCENT == 2 |
| 886 |
for (uint_fast32_t i = 0; i < Num_effects; ++i) |
| 887 |
if (const auto changing_object_texture = Effects[i].changing_object_texture; changing_object_texture != object_bitmap_index::None) |
| 888 |
{ |
| 889 |
const auto o = ObjBitmaps[changing_object_texture]; |
| 890 |
auto &gbo = GameBitmaps[o]; |
| 891 |
if (gbo.bm_w != 64 || gbo.bm_h != 64) |
| 892 |
Error("Effect %" PRIuFAST32 " is used on object, but is not 64x64",i); |
| 893 |
} |
| 894 |
#endif |
| 895 |
} |
| 896 |
|
| 897 |
#if DXX_BUILD_DESCENT == 2 && DXX_USE_EDITOR |
| 898 |
void bm_read_alias() |
| 899 |
{ |
| 900 |
Assert(Num_aliases < MAX_ALIASES); |
| 901 |
auto &a = alias_list[Num_aliases]; |
| 902 |
a = {}; |
| 903 |
|
| 904 |
for (const auto b : {&a.alias_name, &a.file_name}) |
| 905 |
{ |
| 906 |
const auto t = strtok(nullptr, space_tab); |
| 907 |
if (!t) |
| 908 |
return; |
| 909 |
const auto c = std::min(strlen(t), std::size(*b) - 1); |
| 910 |
std::memcpy(std::data(*b), t, c); |
| 911 |
} |
| 912 |
Num_aliases++; |
| 913 |
} |
| 914 |
#endif |
| 915 |
|
| 916 |
} |
| 917 |
|
| 918 |
} |
| 919 |
|
| 920 |
namespace { |
| 921 |
|
| 922 |
static void set_lighting_flag(grs_bitmap &bmp) |
| 923 |
{ |
| 924 |
bmp.set_flag_mask(vlighting < 0, BM_FLAG_NO_LIGHTING); |
| 925 |
} |
| 926 |
|
| 927 |
} |
| 928 |
|
| 929 |
namespace dsx { |
| 930 |
namespace { |
| 931 |
|
| 932 |
static void set_texture_name(d_level_unique_tmap_info_state::TmapInfo_array &TmapInfo, const unsigned texture_idx, const char *name) |
| 933 |
{ |
| 934 |
set_texture_fname(TmapInfo[texture_idx].filename, name); |
| 935 |
} |
| 936 |
|
| 937 |
#if DXX_BUILD_DESCENT == 1 |
| 938 |
static std::size_t bm_read_eclip(std::size_t texture_count, const std::string &dest_bm, const char *const arg, int skip) |
| 939 |
#elif DXX_BUILD_DESCENT == 2 |
| 940 |
static std::size_t bm_read_eclip(std::size_t texture_count, int skip) |
| 941 |
#endif |
| 942 |
{ |
| 943 |
auto &Effects = LevelUniqueEffectsClipState.Effects; |
| 944 |
auto &TmapInfo = LevelUniqueTmapInfoState.TmapInfo; |
| 945 |
|
| 946 |
assert(clip_num < Effects.size()); |
| 947 |
|
| 948 |
if (clip_num+1 > Num_effects) |
| 949 |
Num_effects = clip_num+1; |
| 950 |
|
| 951 |
Effects[clip_num].flags = 0; |
| 952 |
|
| 953 |
#if DXX_BUILD_DESCENT == 2 |
| 954 |
unsigned dest_bm_num{0}; |
| 955 |
//load the dest bitmap first, so that after this routine, the last-loaded |
| 956 |
//texture will be the monitor, so that lighting parameter will be applied |
| 957 |
//to the correct texture |
| 958 |
if (dest_bm) { //deal with bitmap for blown up clip |
| 959 |
const auto &&r = get_texture(LevelUniqueTmapInfoState.TmapInfo, skip, dest_bm, texture_count); |
| 960 |
texture_count = r.texture_count; |
| 961 |
if (!r.reuse_texture) |
| 962 |
{ |
| 963 |
} |
| 964 |
else if (auto &t = Textures[r.idx_updated_texture]; t == bitmap_index{}) //was found, but registered out |
| 965 |
t = bm_load_sub(skip, dest_bm); |
| 966 |
dest_bm_num = r.idx_updated_texture; |
| 967 |
} |
| 968 |
#endif |
| 969 |
|
| 970 |
if (!abm_flag) |
| 971 |
{ |
| 972 |
const auto bitmap = bm_load_sub(skip, arg); |
| 973 |
|
| 974 |
Effects[clip_num].vc.play_time = fl2f(play_time); |
| 975 |
Effects[clip_num].vc.num_frames = frames; |
| 976 |
Effects[clip_num].vc.frame_time = fl2f(play_time)/frames; |
| 977 |
|
| 978 |
Assert(clip_count < frames); |
| 979 |
Effects[clip_num].vc.frames[clip_count] = bitmap; |
| 980 |
set_lighting_flag(GameBitmaps[bitmap]); |
| 981 |
|
| 982 |
Assert(!obj_eclip); //obj eclips for non-abm files not supported! |
| 983 |
Assert(crit_flag==0); |
| 984 |
|
| 985 |
if (clip_count == 0) { |
| 986 |
Effects[clip_num].changing_wall_texture = texture_count; |
| 987 |
Assert(tmap_count < MAX_TEXTURES); |
| 988 |
tmap_count++; |
| 989 |
Textures[texture_count] = bitmap; |
| 990 |
set_texture_name(LevelUniqueTmapInfoState.TmapInfo, texture_count, arg); |
| 991 |
Assert(texture_count < MAX_TEXTURES); |
| 992 |
texture_count++; |
| 993 |
TmapInfo[texture_count].eclip_num = clip_num; |
| 994 |
NumTextures = texture_count; |
| 995 |
} |
| 996 |
|
| 997 |
clip_count++; |
| 998 |
|
| 999 |
} else { |
| 1000 |
std::array<bitmap_index, MAX_BITMAPS_PER_BRUSH> bm; |
| 1001 |
abm_flag = 0; |
| 1002 |
|
| 1003 |
ab_load(skip, arg, bm, &Effects[clip_num].vc.num_frames ); |
| 1004 |
|
| 1005 |
Effects[clip_num].vc.play_time = fl2f(play_time); |
| 1006 |
Effects[clip_num].vc.frame_time = Effects[clip_num].vc.play_time/Effects[clip_num].vc.num_frames; |
| 1007 |
|
| 1008 |
clip_count = 0; |
| 1009 |
set_lighting_flag(GameBitmaps[bm[clip_count]]); |
| 1010 |
Effects[clip_num].vc.frames[clip_count] = bm[clip_count]; |
| 1011 |
|
| 1012 |
if (!obj_eclip && !crit_flag) { |
| 1013 |
Effects[clip_num].changing_wall_texture = texture_count; |
| 1014 |
Assert(tmap_count < MAX_TEXTURES); |
| 1015 |
tmap_count++; |
| 1016 |
Textures[texture_count] = bm[clip_count]; |
| 1017 |
set_texture_name(LevelUniqueTmapInfoState.TmapInfo, texture_count, arg); |
| 1018 |
Assert(texture_count < MAX_TEXTURES); |
| 1019 |
TmapInfo[texture_count].eclip_num = clip_num; |
| 1020 |
texture_count++; |
| 1021 |
NumTextures = texture_count; |
| 1022 |
} |
| 1023 |
|
| 1024 |
if (obj_eclip) { |
| 1025 |
|
| 1026 |
if (Effects[clip_num].changing_object_texture == object_bitmap_index::None) |
| 1027 |
{ //first time referenced |
| 1028 |
Effects[clip_num].changing_object_texture = static_cast<object_bitmap_index>(N_ObjBitmaps); // XChange ObjectBitmaps |
| 1029 |
N_ObjBitmaps++; |
| 1030 |
} |
| 1031 |
|
| 1032 |
ObjBitmaps[Effects[clip_num].changing_object_texture] = Effects[clip_num].vc.frames[0]; |
| 1033 |
} |
| 1034 |
|
| 1035 |
//if for an object, Effects_bm_ptrs set in object load |
| 1036 |
|
| 1037 |
for(clip_count=1;clip_count < Effects[clip_num].vc.num_frames; clip_count++) { |
| 1038 |
set_lighting_flag(GameBitmaps[bm[clip_count]]); |
| 1039 |
Effects[clip_num].vc.frames[clip_count] = bm[clip_count]; |
| 1040 |
} |
| 1041 |
|
| 1042 |
} |
| 1043 |
|
| 1044 |
Effects[clip_num].crit_clip = crit_clip; |
| 1045 |
Effects[clip_num].sound_num = sound_num; |
| 1046 |
|
| 1047 |
#if DXX_BUILD_DESCENT == 1 |
| 1048 |
if (!dest_bm.empty()) |
| 1049 |
#elif DXX_BUILD_DESCENT == 2 |
| 1050 |
if (dest_bm) |
| 1051 |
#endif |
| 1052 |
{ //deal with bitmap for blown up clip |
| 1053 |
#if DXX_BUILD_DESCENT == 1 |
| 1054 |
{ |
| 1055 |
const auto &&r = get_texture(LevelUniqueTmapInfoState.TmapInfo, skip, dest_bm.c_str(), texture_count); |
| 1056 |
texture_count = r.texture_count; |
| 1057 |
Effects[clip_num].dest_bm_num = r.idx_updated_texture; |
| 1058 |
} |
| 1059 |
#elif DXX_BUILD_DESCENT == 2 |
| 1060 |
Effects[clip_num].dest_bm_num = dest_bm_num; |
| 1061 |
#endif |
| 1062 |
|
| 1063 |
if (dest_vclip == vclip_index::None) |
| 1064 |
Error("Destruction vclip missing on line %d", linenum); |
| 1065 |
if (dest_size==-1) |
| 1066 |
Error("Desctuction vclip missing on line %d",linenum); |
| 1067 |
|
| 1068 |
Effects[clip_num].dest_vclip = dest_vclip; |
| 1069 |
Effects[clip_num].dest_size = dest_size; |
| 1070 |
|
| 1071 |
Effects[clip_num].dest_eclip = dest_eclip; |
| 1072 |
} |
| 1073 |
else { |
| 1074 |
Effects[clip_num].dest_bm_num = ~0u; |
| 1075 |
Effects[clip_num].dest_eclip = eclip_none; |
| 1076 |
} |
| 1077 |
|
| 1078 |
if (crit_flag) |
| 1079 |
Effects[clip_num].flags |= EF_CRITICAL; |
| 1080 |
return texture_count; |
| 1081 |
} |
| 1082 |
|
| 1083 |
#if DXX_BUILD_DESCENT == 1 |
| 1084 |
static void bm_read_gauges(const char *const arg, int skip) |
| 1085 |
#elif DXX_BUILD_DESCENT == 2 |
| 1086 |
static void bm_read_gauges(int skip) |
| 1087 |
#endif |
| 1088 |
{ |
| 1089 |
unsigned i, num_abm_frames; |
| 1090 |
|
| 1091 |
if (!abm_flag) { |
| 1092 |
const auto bitmap = bm_load_sub(skip, arg); |
| 1093 |
Assert(clip_count < MAX_GAUGE_BMS); |
| 1094 |
Gauges[clip_count] = bitmap; |
| 1095 |
clip_count++; |
| 1096 |
} else { |
| 1097 |
std::array<bitmap_index, MAX_BITMAPS_PER_BRUSH> bm; |
| 1098 |
abm_flag = 0; |
| 1099 |
ab_load(skip, arg, bm, &num_abm_frames ); |
| 1100 |
for (i=clip_count; i<clip_count+num_abm_frames; i++) { |
| 1101 |
Assert(i < MAX_GAUGE_BMS); |
| 1102 |
Gauges[i] = bm[i-clip_count]; |
| 1103 |
} |
| 1104 |
clip_count += num_abm_frames; |
| 1105 |
} |
| 1106 |
} |
| 1107 |
|
| 1108 |
#if DXX_BUILD_DESCENT == 1 |
| 1109 |
static std::size_t bm_read_wclip(std::size_t texture_count, char *const arg, int skip) |
| 1110 |
#elif DXX_BUILD_DESCENT == 2 |
| 1111 |
static void bm_read_gauges_hires() |
| 1112 |
{ |
| 1113 |
unsigned i, num_abm_frames; |
| 1114 |
|
| 1115 |
if (!abm_flag) { |
| 1116 |
const auto bitmap = bm_load_sub(0, arg); |
| 1117 |
Assert(clip_count < MAX_GAUGE_BMS); |
| 1118 |
Gauges_hires[clip_count] = bitmap; |
| 1119 |
clip_count++; |
| 1120 |
} else { |
| 1121 |
std::array<bitmap_index, MAX_BITMAPS_PER_BRUSH> bm; |
| 1122 |
abm_flag = 0; |
| 1123 |
ab_load(0, arg, bm, &num_abm_frames ); |
| 1124 |
for (i=clip_count; i<clip_count+num_abm_frames; i++) { |
| 1125 |
Assert(i < MAX_GAUGE_BMS); |
| 1126 |
Gauges_hires[i] = bm[i-clip_count]; |
| 1127 |
} |
| 1128 |
clip_count += num_abm_frames; |
| 1129 |
} |
| 1130 |
} |
| 1131 |
|
| 1132 |
static std::size_t bm_read_wclip(std::size_t texture_count, int skip) |
| 1133 |
#endif |
| 1134 |
{ |
| 1135 |
auto &TmapInfo = LevelUniqueTmapInfoState.TmapInfo; |
| 1136 |
auto &WallAnims = GameSharedState.WallAnims; |
| 1137 |
Assert(clip_num < MAX_WALL_ANIMS); |
| 1138 |
|
| 1139 |
auto &wa = WallAnims[clip_num]; |
| 1140 |
wa.flags = wall_explodes_flag | wall_blastable_flag | wall_hidden_flag | tmap1_flag; |
| 1141 |
|
| 1142 |
if (!abm_flag) { |
| 1143 |
const auto bitmap = bm_load_sub(skip, arg); |
| 1144 |
if (wa.num_frames != wclip_frames_none && clip_count == 0) |
| 1145 |
Error( "Wall Clip %d is already used!", clip_num ); |
| 1146 |
wa.play_time = fl2f(play_time); |
| 1147 |
wa.num_frames = frames; |
| 1148 |
//WallAnims[clip_num].frame_time = fl2f(play_time)/frames; |
| 1149 |
Assert(clip_count < frames); |
| 1150 |
wa.frames[clip_count++] = texture_count; |
| 1151 |
wa.open_sound = wall_open_sound; |
| 1152 |
wa.close_sound = wall_close_sound; |
| 1153 |
Textures[texture_count] = bitmap; |
| 1154 |
set_lighting_flag(GameBitmaps[bitmap]); |
| 1155 |
set_texture_name(LevelUniqueTmapInfoState.TmapInfo, texture_count, arg); |
| 1156 |
Assert(texture_count < MAX_TEXTURES); |
| 1157 |
texture_count++; |
| 1158 |
NumTextures = texture_count; |
| 1159 |
if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1; |
| 1160 |
} else { |
| 1161 |
std::array<bitmap_index, MAX_BITMAPS_PER_BRUSH> bm; |
| 1162 |
unsigned nframes; |
| 1163 |
if (wa.num_frames != wclip_frames_none) |
| 1164 |
Error( "AB_Wall clip %d is already used!", clip_num ); |
| 1165 |
abm_flag = 0; |
| 1166 |
#if DXX_BUILD_DESCENT == 1 |
| 1167 |
ab_load(skip, arg, bm, &nframes ); |
| 1168 |
#elif DXX_BUILD_DESCENT == 2 |
| 1169 |
ab_load(0, arg, bm, &nframes ); |
| 1170 |
#endif |
| 1171 |
wa.num_frames = nframes; |
| 1172 |
wa.play_time = fl2f(play_time); |
| 1173 |
//WallAnims[clip_num].frame_time = fl2f(play_time)/nframes; |
| 1174 |
wa.open_sound = wall_open_sound; |
| 1175 |
wa.close_sound = wall_close_sound; |
| 1176 |
strcpy(&wa.filename[0], arg); |
| 1177 |
REMOVE_DOTS(&wa.filename[0]); |
| 1178 |
|
| 1179 |
if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1; |
| 1180 |
|
| 1181 |
set_lighting_flag(GameBitmaps[bm[clip_count]]); |
| 1182 |
|
| 1183 |
for (clip_count=0;clip_count < wa.num_frames; clip_count++) { |
| 1184 |
Textures[texture_count] = bm[clip_count]; |
| 1185 |
set_lighting_flag(GameBitmaps[bm[clip_count]]); |
| 1186 |
wa.frames[clip_count] = texture_count; |
| 1187 |
REMOVE_DOTS(arg); |
| 1188 |
snprintf(&TmapInfo[texture_count].filename[0u], TmapInfo[texture_count].filename.size(), "%s#%d", arg, clip_count); |
| 1189 |
Assert(texture_count < MAX_TEXTURES); |
| 1190 |
texture_count++; |
| 1191 |
NumTextures = texture_count; |
| 1192 |
} |
| 1193 |
} |
| 1194 |
return texture_count; |
| 1195 |
} |
| 1196 |
|
| 1197 |
#if DXX_BUILD_DESCENT == 1 |
| 1198 |
static void bm_read_vclip(d_vclip_array &Vclip, const char *const arg, int skip) |
| 1199 |
#elif DXX_BUILD_DESCENT == 2 |
| 1200 |
static void bm_read_vclip(d_vclip_array &Vclip, int skip) |
| 1201 |
#endif |
| 1202 |
{ |
| 1203 |
const std::size_t c = clip_num; |
| 1204 |
assert(Vclip.valid_index(c)); |
| 1205 |
if (!Vclip.valid_index(c)) |
| 1206 |
return; |
| 1207 |
const vclip_index vci{static_cast<uint8_t>(c)}; |
| 1208 |
auto &vc = Vclip[vci]; |
| 1209 |
|
| 1210 |
#if DXX_BUILD_DESCENT == 2 |
| 1211 |
if (Num_vclips <= c) |
| 1212 |
Num_vclips = c + 1; |
| 1213 |
#endif |
| 1214 |
|
| 1215 |
if (!abm_flag) { |
| 1216 |
if (vc.num_frames != ~0u && clip_count == 0) |
| 1217 |
Error( "Vclip %d is already used!", clip_num ); |
| 1218 |
const auto bi = bm_load_sub(skip, arg); |
| 1219 |
vc.play_time = fl2f(play_time); |
| 1220 |
vc.num_frames = frames; |
| 1221 |
vc.frame_time = fl2f(play_time) / frames; |
| 1222 |
vc.light_value = fl2f(vlighting); |
| 1223 |
vc.sound_num = sound_num; |
| 1224 |
set_lighting_flag(GameBitmaps[bi]); |
| 1225 |
Assert(clip_count < frames); |
| 1226 |
vc.frames[clip_count++] = bi; |
| 1227 |
if (rod_flag) { |
| 1228 |
rod_flag=0; |
| 1229 |
vc.flags |= VF_ROD; |
| 1230 |
} |
| 1231 |
|
| 1232 |
} else { |
| 1233 |
std::array<bitmap_index, MAX_BITMAPS_PER_BRUSH> bm; |
| 1234 |
abm_flag = 0; |
| 1235 |
if (vc.num_frames != ~0u) |
| 1236 |
Error( "AB_Vclip %d is already used!", clip_num ); |
| 1237 |
ab_load(skip, arg, bm, &vc.num_frames); |
| 1238 |
|
| 1239 |
if (rod_flag) { |
| 1240 |
//int i; |
| 1241 |
rod_flag=0; |
| 1242 |
vc.flags |= VF_ROD; |
| 1243 |
} |
| 1244 |
vc.play_time = fl2f(play_time); |
| 1245 |
vc.frame_time = fl2f(play_time) / vc.num_frames; |
| 1246 |
vc.light_value = fl2f(vlighting); |
| 1247 |
vc.sound_num = sound_num; |
| 1248 |
set_lighting_flag(GameBitmaps[bm[clip_count]]); |
| 1249 |
|
| 1250 |
for (clip_count = 0; clip_count < vc.num_frames; ++clip_count) |
| 1251 |
{ |
| 1252 |
set_lighting_flag(GameBitmaps[bm[clip_count]]); |
| 1253 |
vc.frames[clip_count] = bm[clip_count]; |
| 1254 |
} |
| 1255 |
} |
| 1256 |
} |
| 1257 |
|
| 1258 |
} |
| 1259 |
|
| 1260 |
} |
| 1261 |
|
| 1262 |
namespace dcx { |
| 1263 |
namespace { |
| 1264 |
|
| 1265 |
// ------------------------------------------------------------------------------ |
| 1266 |
static void get4fix(enumerated_array<fix, NDL, Difficulty_level_type> &fixp) |
| 1267 |
{ |
| 1268 |
char *curtext; |
| 1269 |
range_for (auto &i, fixp) |
| 1270 |
{ |
| 1271 |
curtext = strtok(NULL, space_tab); |
| 1272 |
i = fl2f(atof(curtext)); |
| 1273 |
} |
| 1274 |
} |
| 1275 |
|
| 1276 |
// ------------------------------------------------------------------------------ |
| 1277 |
static void get4byte(enumerated_array<int8_t, NDL, Difficulty_level_type> &bytep) |
| 1278 |
{ |
| 1279 |
char *curtext; |
| 1280 |
range_for (auto &i, bytep) |
| 1281 |
{ |
| 1282 |
curtext = strtok(NULL, space_tab); |
| 1283 |
i = atoi(curtext); |
| 1284 |
} |
| 1285 |
} |
| 1286 |
|
| 1287 |
// ------------------------------------------------------------------------------ |
| 1288 |
// Convert field of view from an angle in 0..360 to cosine. |
| 1289 |
static void adjust_field_of_view(enumerated_array<fix, NDL, Difficulty_level_type> &fovp) |
| 1290 |
{ |
| 1291 |
fixang tt; |
| 1292 |
float ff; |
| 1293 |
range_for (auto &i, fovp) |
| 1294 |
{ |
| 1295 |
ff = - f2fl(i); |
| 1296 |
if (ff > 179) { |
| 1297 |
ff = 179; |
| 1298 |
} |
| 1299 |
ff = ff/360; |
| 1300 |
tt = fl2f(ff); |
| 1301 |
i = fix_cos(tt); |
| 1302 |
} |
| 1303 |
} |
| 1304 |
|
| 1305 |
static polygon_simpler_model_index build_polygon_simpler_model_index_from_polygon_model_index(const polygon_model_index i) |
| 1306 |
{ |
| 1307 |
const auto ii = underlying_value(i) + 1; |
| 1308 |
if (ii > MAX_POLYGON_MODELS) |
| 1309 |
return polygon_simpler_model_index::None; |
| 1310 |
return static_cast<polygon_simpler_model_index>(ii); |
| 1311 |
} |
| 1312 |
|
| 1313 |
} |
| 1314 |
} |
| 1315 |
|
| 1316 |
namespace dsx { |
| 1317 |
namespace { |
| 1318 |
|
| 1319 |
#if DXX_BUILD_DESCENT == 1 |
| 1320 |
static void clear_to_end_of_line(char *&arg) |
| 1321 |
{ |
| 1322 |
arg = NULL; |
| 1323 |
} |
| 1324 |
#elif DXX_BUILD_DESCENT == 2 |
| 1325 |
static void clear_to_end_of_line() |
| 1326 |
{ |
| 1327 |
arg = strtok( NULL, space_tab ); |
| 1328 |
while (arg != NULL) |
| 1329 |
arg = strtok( NULL, space_tab ); |
| 1330 |
} |
| 1331 |
#endif |
| 1332 |
|
| 1333 |
#if DXX_BUILD_DESCENT == 1 |
| 1334 |
static void bm_read_sound(char *&arg, int skip, int pc_shareware) |
| 1335 |
#elif DXX_BUILD_DESCENT == 2 |
| 1336 |
void bm_read_sound(int skip) |
| 1337 |
#endif |
| 1338 |
{ |
| 1339 |
const int read_sound_num{get_int()}; |
| 1340 |
const int alt_sound_num{ |
| 1341 |
#if DXX_BUILD_DESCENT == 1 |
| 1342 |
pc_shareware |
| 1343 |
? read_sound_num |
| 1344 |
: |
| 1345 |
#endif |
| 1346 |
get_int() |
| 1347 |
}; |
| 1348 |
|
| 1349 |
if ( read_sound_num>=MAX_SOUNDS ) |
| 1350 |
Error( "Too many sound files.\n" ); |
| 1351 |
|
| 1352 |
if (read_sound_num >= num_sounds) |
| 1353 |
num_sounds = read_sound_num+1; |
| 1354 |
|
| 1355 |
#if DXX_BUILD_DESCENT == 2 |
| 1356 |
if (Sounds[read_sound_num] != 255) |
| 1357 |
Error("Sound num %d already used, bitmaps.tbl, line %d\n",read_sound_num,linenum); |
| 1358 |
#endif |
| 1359 |
|
| 1360 |
arg = strtok(NULL, space_tab); |
| 1361 |
|
| 1362 |
Sounds[read_sound_num] = build_sound_effect_from_untrusted(ds_load(skip, arg)); |
| 1363 |
|
| 1364 |
AltSounds[read_sound_num] = ( |
| 1365 |
alt_sound_num == 0 |
| 1366 |
? build_sound_effect_from_untrusted(sound_num) |
| 1367 |
: ( |
| 1368 |
alt_sound_num < 0 |
| 1369 |
? sound_effect::None |
| 1370 |
: build_sound_effect_from_untrusted(alt_sound_num) |
| 1371 |
) |
| 1372 |
); |
| 1373 |
|
| 1374 |
if (Sounds[read_sound_num] == sound_effect::None) |
| 1375 |
Error("Can't load soundfile <%s>",arg); |
| 1376 |
} |
| 1377 |
|
| 1378 |
// ------------------------------------------------------------------------------ |
| 1379 |
#if DXX_BUILD_DESCENT == 1 |
| 1380 |
static void bm_read_robot_ai(d_robot_info_array &Robot_info, char *&arg, const int skip) |
| 1381 |
#elif DXX_BUILD_DESCENT == 2 |
| 1382 |
void bm_read_robot_ai(d_robot_info_array &Robot_info, const int skip) |
| 1383 |
#endif |
| 1384 |
{ |
| 1385 |
char *robotnum_text; |
| 1386 |
|
| 1387 |
robotnum_text = strtok(NULL, space_tab); |
| 1388 |
const auto l = strtoul(robotnum_text, nullptr, 10); |
| 1389 |
const auto o = Robot_info.valid_index(l); |
| 1390 |
if (!o) |
| 1391 |
return; |
| 1392 |
const auto robotnum = *o; |
| 1393 |
auto &robptr = Robot_info[robotnum]; |
| 1394 |
|
| 1395 |
assert(l == Num_robot_ais); //make sure valid number |
| 1396 |
|
| 1397 |
if (skip) { |
| 1398 |
Num_robot_ais++; |
| 1399 |
#if DXX_BUILD_DESCENT == 1 |
| 1400 |
clear_to_end_of_line(arg); |
| 1401 |
#elif DXX_BUILD_DESCENT == 2 |
| 1402 |
clear_to_end_of_line(); |
| 1403 |
#endif |
| 1404 |
return; |
| 1405 |
} |
| 1406 |
|
| 1407 |
Num_robot_ais++; |
| 1408 |
|
| 1409 |
get4fix(robptr.field_of_view); |
| 1410 |
get4fix(robptr.firing_wait); |
| 1411 |
#if DXX_BUILD_DESCENT == 2 |
| 1412 |
get4fix(robptr.firing_wait2); |
| 1413 |
#endif |
| 1414 |
get4byte(robptr.rapidfire_count); |
| 1415 |
get4fix(robptr.turn_time); |
| 1416 |
#if DXX_BUILD_DESCENT == 1 |
| 1417 |
enumerated_array<fix, NDL, Difficulty_level_type> fire_power, // damage done by a hit from this robot |
| 1418 |
shield; // shield strength of this robot |
| 1419 |
get4fix(fire_power); |
| 1420 |
get4fix(shield); |
| 1421 |
#elif DXX_BUILD_DESCENT == 2 |
| 1422 |
// get4fix(robptr->fire_power); |
| 1423 |
// get4fix(robptr->shield); |
| 1424 |
#endif |
| 1425 |
get4fix(robptr.max_speed); |
| 1426 |
get4fix(robptr.circle_distance); |
| 1427 |
get4byte(robptr.evade_speed); |
| 1428 |
|
| 1429 |
robptr.always_0xabcd = 0xabcd; |
| 1430 |
adjust_field_of_view(robptr.field_of_view); |
| 1431 |
} |
| 1432 |
|
| 1433 |
// ---------------------------------------------------------------------------------------------- |
| 1434 |
//this will load a bitmap for a polygon models. it puts the bitmap into |
| 1435 |
//the array ObjBitmaps[], and also deals with animating bitmaps |
| 1436 |
//returns a pointer to the bitmap |
| 1437 |
static grs_bitmap *load_polymodel_bitmap(int skip, const char *name) |
| 1438 |
{ |
| 1439 |
auto &Effects = LevelUniqueEffectsClipState.Effects; |
| 1440 |
assert(N_ObjBitmaps < ObjBitmaps.size()); |
| 1441 |
|
| 1442 |
// Assert( N_ObjBitmaps == N_ObjBitmapPtrs ); |
| 1443 |
|
| 1444 |
if (name[0] == '%') { //an animating bitmap! |
| 1445 |
const unsigned eclip_num = atoi(name+1); |
| 1446 |
|
| 1447 |
auto &changing_object_texture = Effects[eclip_num].changing_object_texture; |
| 1448 |
// On first reference, changing_object_texture will be None. |
| 1449 |
// Assign it a value. |
| 1450 |
if (changing_object_texture == object_bitmap_index::None) |
| 1451 |
changing_object_texture = static_cast<object_bitmap_index>(N_ObjBitmaps++); |
| 1452 |
ObjBitmapPtrs[N_ObjBitmapPtrs++] = changing_object_texture; |
| 1453 |
#if DXX_BUILD_DESCENT == 2 |
| 1454 |
assert(N_ObjBitmaps < ObjBitmaps.size()); |
| 1455 |
assert(N_ObjBitmapPtrs < ObjBitmapPtrs.size()); |
| 1456 |
#endif |
| 1457 |
return NULL; |
| 1458 |
} |
| 1459 |
else { |
| 1460 |
const auto loaded_value = bm_load_sub(skip, name); |
| 1461 |
const auto oi = static_cast<object_bitmap_index>(N_ObjBitmaps); |
| 1462 |
auto &ob = ObjBitmaps[oi]; |
| 1463 |
ob = loaded_value; |
| 1464 |
#if DXX_BUILD_DESCENT == 2 |
| 1465 |
auto &gbo = GameBitmaps[ob]; |
| 1466 |
if (gbo.bm_w != 64 || gbo.bm_h != 64) |
| 1467 |
Error("Bitmap <%s> is not 64x64",name); |
| 1468 |
#endif |
| 1469 |
ObjBitmapPtrs[N_ObjBitmapPtrs++] = oi; |
| 1470 |
N_ObjBitmaps++; |
| 1471 |
#if DXX_BUILD_DESCENT == 2 |
| 1472 |
assert(N_ObjBitmaps < ObjBitmaps.size()); |
| 1473 |
assert(N_ObjBitmapPtrs < ObjBitmapPtrs.size()); |
| 1474 |
#endif |
| 1475 |
return &GameBitmaps[ob]; |
| 1476 |
} |
| 1477 |
} |
| 1478 |
|
| 1479 |
#define MAX_MODEL_VARIANTS 4 |
| 1480 |
|
| 1481 |
// ------------------------------------------------------------------------------ |
| 1482 |
#if DXX_BUILD_DESCENT == 1 |
| 1483 |
static void bm_read_robot(d_level_shared_robot_info_state &LevelSharedRobotInfoState, char *&arg, int skip) |
| 1484 |
#elif DXX_BUILD_DESCENT == 2 |
| 1485 |
void bm_read_robot(d_level_shared_robot_info_state &LevelSharedRobotInfoState, int skip) |
| 1486 |
#endif |
| 1487 |
{ |
| 1488 |
char *model_name[MAX_MODEL_VARIANTS]; |
| 1489 |
int n_models,i; |
| 1490 |
int first_bitmap_num[MAX_MODEL_VARIANTS]; |
| 1491 |
char *equal_ptr; |
| 1492 |
auto exp1_vclip_num{vclip_index::None}; |
| 1493 |
auto exp1_sound_num{sound_effect::None}; |
| 1494 |
auto exp2_vclip_num{vclip_index::None}; |
| 1495 |
auto exp2_sound_num{sound_effect::None}; |
| 1496 |
fix lighting = F1_0/2; // Default |
| 1497 |
fix strength = F1_0*10; // Default strength |
| 1498 |
fix mass = f1_0*4; |
| 1499 |
fix drag = f1_0/2; |
| 1500 |
weapon_id_type weapon_type = weapon_id_type::LASER_ID_L1; |
| 1501 |
int contains_count{0}, contains_id=0, contains_prob=0, contains_type=0; |
| 1502 |
#if DXX_BUILD_DESCENT == 2 |
| 1503 |
weapon_id_type weapon_type2 = weapon_id_type::unspecified; |
| 1504 |
auto behavior = ai_behavior::AIB_NORMAL; |
| 1505 |
int companion{0}, smart_blobs=0, energy_blobs=0, badass=0, energy_drain=0, kamikaze=0, thief=0, pursuit=0, lightcast=0, death_roll=0; |
| 1506 |
fix glow{0}, aim=F1_0; |
| 1507 |
auto deathroll_sound{sound_effect::SOUND_BOSS_SHARE_DIE}; //default |
| 1508 |
auto taunt_sound{sound_effect::ROBOT_SEE_SOUND_DEFAULT}; |
| 1509 |
ubyte flags{0}; |
| 1510 |
#endif |
| 1511 |
int score_value{1000}; |
| 1512 |
int cloak_type{0}; // Default = this robot does not cloak |
| 1513 |
int attack_type{0}; // Default = this robot attacks by firing (1=lunge) |
| 1514 |
boss_robot_id boss_flag{}; // Default = robot is not a boss. |
| 1515 |
auto see_sound{sound_effect::ROBOT_SEE_SOUND_DEFAULT}; |
| 1516 |
auto attack_sound{sound_effect::ROBOT_ATTACK_SOUND_DEFAULT}; |
| 1517 |
auto claw_sound{sound_effect::ROBOT_CLAW_SOUND_DEFAULT}; |
| 1518 |
|
| 1519 |
assert(LevelSharedRobotInfoState.N_robot_types < MAX_ROBOT_TYPES); |
| 1520 |
|
| 1521 |
auto &Robot_info = LevelSharedRobotInfoState.Robot_info; |
| 1522 |
if (skip) { |
| 1523 |
const auto N_robot_types = LevelSharedRobotInfoState.N_robot_types; |
| 1524 |
if (const auto o = Robot_info.valid_index(N_robot_types)) |
| 1525 |
{ |
| 1526 |
const auto rid = *o; |
| 1527 |
++ LevelSharedRobotInfoState.N_robot_types; |
| 1528 |
auto &ri = Robot_info[rid]; |
| 1529 |
ri.model_num = polygon_model_index::None; |
| 1530 |
} |
| 1531 |
#if DXX_BUILD_DESCENT == 1 |
| 1532 |
Num_total_object_types++; |
| 1533 |
clear_to_end_of_line(arg); |
| 1534 |
#elif DXX_BUILD_DESCENT == 2 |
| 1535 |
clear_to_end_of_line(); |
| 1536 |
#endif |
| 1537 |
return; |
| 1538 |
} |
| 1539 |
|
| 1540 |
model_name[0] = strtok( NULL, space_tab ); |
| 1541 |
first_bitmap_num[0] = N_ObjBitmapPtrs; |
| 1542 |
n_models = 1; |
| 1543 |
|
| 1544 |
// Process bitmaps |
| 1545 |
current_bm_type=bm_type::robot; |
| 1546 |
arg = strtok( NULL, space_tab ); |
| 1547 |
while (arg!=NULL) { |
| 1548 |
equal_ptr = strchr( arg, '=' ); |
| 1549 |
if ( equal_ptr ) { |
| 1550 |
*equal_ptr='\0'; |
| 1551 |
equal_ptr++; |
| 1552 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 1553 |
if (!d_stricmp( arg, "exp1_vclip" )) { |
| 1554 |
exp1_vclip_num = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 1555 |
} else if (!d_stricmp( arg, "exp2_vclip" )) { |
| 1556 |
exp2_vclip_num = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 1557 |
} else if (!d_stricmp( arg, "exp1_sound" )) { |
| 1558 |
exp1_sound_num = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1559 |
} else if (!d_stricmp( arg, "exp2_sound" )) { |
| 1560 |
exp2_sound_num = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1561 |
} else if (!d_stricmp( arg, "lighting" )) { |
| 1562 |
lighting = fl2f(atof(equal_ptr)); |
| 1563 |
if ( (lighting < 0) || (lighting > F1_0 )) { |
| 1564 |
Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)); |
| 1565 |
} |
| 1566 |
} else if (!d_stricmp( arg, "weapon_type" )) { |
| 1567 |
weapon_type = static_cast<weapon_id_type>(atoi(equal_ptr)); |
| 1568 |
} |
| 1569 |
#if DXX_BUILD_DESCENT == 2 |
| 1570 |
else if (!d_stricmp( arg, "weapon_type2")) |
| 1571 |
{ |
| 1572 |
weapon_type2 = static_cast<weapon_id_type>(atoi(equal_ptr)); |
| 1573 |
} |
| 1574 |
#endif |
| 1575 |
else if (!d_stricmp( arg, "strength" )) { |
| 1576 |
strength = i2f(atoi(equal_ptr)); |
| 1577 |
} else if (!d_stricmp( arg, "mass" )) { |
| 1578 |
mass = fl2f(atof(equal_ptr)); |
| 1579 |
} else if (!d_stricmp( arg, "drag" )) { |
| 1580 |
drag = fl2f(atof(equal_ptr)); |
| 1581 |
} else if (!d_stricmp( arg, "contains_id" )) { |
| 1582 |
contains_id = atoi(equal_ptr); |
| 1583 |
} else if (!d_stricmp( arg, "contains_type" )) { |
| 1584 |
contains_type = atoi(equal_ptr); |
| 1585 |
} else if (!d_stricmp( arg, "contains_count" )) { |
| 1586 |
contains_count = atoi(equal_ptr); |
| 1587 |
} |
| 1588 |
#if DXX_BUILD_DESCENT == 2 |
| 1589 |
else if (!d_stricmp( arg, "companion" )) { |
| 1590 |
companion = atoi(equal_ptr); |
| 1591 |
} else if (!d_stricmp( arg, "badass" )) { |
| 1592 |
badass = atoi(equal_ptr); |
| 1593 |
} else if (!d_stricmp( arg, "lightcast" )) { |
| 1594 |
lightcast = atoi(equal_ptr); |
| 1595 |
} else if (!d_stricmp( arg, "glow" )) { |
| 1596 |
glow = fl2f(atof(equal_ptr)); |
| 1597 |
} else if (!d_stricmp( arg, "death_roll" )) { |
| 1598 |
death_roll = atoi(equal_ptr); |
| 1599 |
} else if (!d_stricmp( arg, "deathroll_sound" )) { |
| 1600 |
deathroll_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1601 |
} else if (!d_stricmp( arg, "thief" )) { |
| 1602 |
thief = atoi(equal_ptr); |
| 1603 |
} else if (!d_stricmp( arg, "kamikaze" )) { |
| 1604 |
kamikaze = atoi(equal_ptr); |
| 1605 |
} else if (!d_stricmp( arg, "pursuit" )) { |
| 1606 |
pursuit = atoi(equal_ptr); |
| 1607 |
} else if (!d_stricmp( arg, "smart_blobs" )) { |
| 1608 |
smart_blobs = atoi(equal_ptr); |
| 1609 |
} else if (!d_stricmp( arg, "energy_blobs" )) { |
| 1610 |
energy_blobs = atoi(equal_ptr); |
| 1611 |
} else if (!d_stricmp( arg, "energy_drain" )) { |
| 1612 |
energy_drain = atoi(equal_ptr); |
| 1613 |
} |
| 1614 |
#endif |
| 1615 |
else if (!d_stricmp( arg, "contains_prob" )) { |
| 1616 |
contains_prob = atoi(equal_ptr); |
| 1617 |
} else if (!d_stricmp( arg, "cloak_type" )) { |
| 1618 |
cloak_type = atoi(equal_ptr); |
| 1619 |
} else if (!d_stricmp( arg, "attack_type" )) { |
| 1620 |
attack_type = atoi(equal_ptr); |
| 1621 |
} else if (!d_stricmp( arg, "boss" )) { |
| 1622 |
const auto i = strtoul(equal_ptr, nullptr, 10); |
| 1623 |
boss_flag = (i == static_cast<uint8_t>(boss_robot_id::d1_1) || i == static_cast<uint8_t>(boss_robot_id::d1_superboss)) ? static_cast<boss_robot_id>(i) : boss_robot_id::None; |
| 1624 |
} else if (!d_stricmp( arg, "score_value" )) { |
| 1625 |
score_value = atoi(equal_ptr); |
| 1626 |
} else if (!d_stricmp( arg, "see_sound" )) { |
| 1627 |
see_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1628 |
} else if (!d_stricmp( arg, "attack_sound" )) { |
| 1629 |
attack_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1630 |
} else if (!d_stricmp( arg, "claw_sound" )) { |
| 1631 |
claw_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1632 |
} |
| 1633 |
#if DXX_BUILD_DESCENT == 2 |
| 1634 |
else if (!d_stricmp( arg, "taunt_sound" )) { |
| 1635 |
taunt_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 1636 |
} else if (!d_stricmp( arg, "aim" )) { |
| 1637 |
aim = fl2f(atof(equal_ptr)); |
| 1638 |
} else if (!d_stricmp( arg, "big_radius" )) { |
| 1639 |
/* No longer used. As of 1996-01-12, this is a write-only |
| 1640 |
* field, because the code in gamesave.c to read it was |
| 1641 |
* commented out. |
| 1642 |
* |
| 1643 |
* Retain the test for it, so that the `Int3` on the final |
| 1644 |
* `else` path does not trigger for a robot with this field |
| 1645 |
* set. |
| 1646 |
*/ |
| 1647 |
} else if (!d_stricmp( arg, "behavior" )) { |
| 1648 |
if (!d_stricmp(equal_ptr, "STILL")) |
| 1649 |
behavior = ai_behavior::AIB_STILL; |
| 1650 |
else if (!d_stricmp(equal_ptr, "NORMAL")) |
| 1651 |
behavior = ai_behavior::AIB_NORMAL; |
| 1652 |
else if (!d_stricmp(equal_ptr, "BEHIND")) |
| 1653 |
behavior = ai_behavior::AIB_BEHIND; |
| 1654 |
else if (!d_stricmp(equal_ptr, "RUN_FROM")) |
| 1655 |
behavior = ai_behavior::AIB_RUN_FROM; |
| 1656 |
else if (!d_stricmp(equal_ptr, "SNIPE")) |
| 1657 |
behavior = ai_behavior::AIB_SNIPE; |
| 1658 |
else if (!d_stricmp(equal_ptr, "STATION")) |
| 1659 |
behavior = ai_behavior::AIB_STATION; |
| 1660 |
else if (!d_stricmp(equal_ptr, "FOLLOW")) |
| 1661 |
behavior = ai_behavior::AIB_FOLLOW; |
| 1662 |
else |
| 1663 |
Int3(); // Error. Illegal behavior type for current robot. |
| 1664 |
} |
| 1665 |
#endif |
| 1666 |
else if (!d_stricmp( arg, "name" )) { |
| 1667 |
#if DXX_USE_EDITOR |
| 1668 |
auto &name = Robot_names[static_cast<robot_id>(LevelSharedRobotInfoState.N_robot_types)]; |
| 1669 |
const auto len = strlen(equal_ptr); |
| 1670 |
assert(len < name.size()); // Oops, name too long. |
| 1671 |
memcpy(name.data(), &equal_ptr[1], len - 2); |
| 1672 |
name[len - 2] = 0; |
| 1673 |
#endif |
| 1674 |
} else if (!d_stricmp( arg, "simple_model" )) { |
| 1675 |
model_name[n_models] = equal_ptr; |
| 1676 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 1677 |
n_models++; |
| 1678 |
#if DXX_BUILD_DESCENT == 2 |
| 1679 |
Assert(n_models < MAX_MODEL_VARIANTS); |
| 1680 |
#endif |
| 1681 |
} |
| 1682 |
#if DXX_BUILD_DESCENT == 2 |
| 1683 |
else |
| 1684 |
{ |
| 1685 |
Int3(); |
| 1686 |
} |
| 1687 |
#endif |
| 1688 |
} else { // Must be a texture specification... |
| 1689 |
load_polymodel_bitmap(skip, arg); |
| 1690 |
} |
| 1691 |
arg = strtok( NULL, space_tab ); |
| 1692 |
} |
| 1693 |
|
| 1694 |
auto ¤t_robot_info = Robot_info[static_cast<robot_id>(LevelSharedRobotInfoState.N_robot_types)]; |
| 1695 |
//clear out anim info |
| 1696 |
current_robot_info.anim_states = {}; |
| 1697 |
|
| 1698 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 1699 |
|
| 1700 |
auto &Polygon_models = LevelSharedPolygonModelState.Polygon_models; |
| 1701 |
for (i=0;i<n_models;i++) { |
| 1702 |
int n_textures; |
| 1703 |
|
| 1704 |
n_textures = first_bitmap_num[i+1] - first_bitmap_num[i]; |
| 1705 |
|
| 1706 |
const auto model_num = load_polygon_model(model_name[i], n_textures, first_bitmap_num[i], (i == 0) ? ¤t_robot_info : nullptr); |
| 1707 |
|
| 1708 |
if (i==0) |
| 1709 |
current_robot_info.model_num = model_num; |
| 1710 |
else |
| 1711 |
Polygon_models.front().simpler_model = build_polygon_simpler_model_index_from_polygon_model_index(model_num); |
| 1712 |
} |
| 1713 |
|
| 1714 |
#if DXX_BUILD_DESCENT == 1 |
| 1715 |
ObjType[Num_total_object_types] = OL_ROBOT; |
| 1716 |
ObjId[Num_total_object_types] = static_cast<polygon_model_index>(LevelSharedRobotInfoState.N_robot_types); |
| 1717 |
#elif DXX_BUILD_DESCENT == 2 |
| 1718 |
if ((glow > i2f(15)) || (glow < 0) || (glow != 0 && glow < 0x1000)) { |
| 1719 |
Int3(); |
| 1720 |
} |
| 1721 |
#endif |
| 1722 |
|
| 1723 |
current_robot_info.exp1_vclip_num = exp1_vclip_num; |
| 1724 |
current_robot_info.exp2_vclip_num = exp2_vclip_num; |
| 1725 |
current_robot_info.exp1_sound_num = exp1_sound_num; |
| 1726 |
current_robot_info.exp2_sound_num = exp2_sound_num; |
| 1727 |
current_robot_info.lighting = lighting; |
| 1728 |
current_robot_info.weapon_type = weapon_type; |
| 1729 |
#if DXX_BUILD_DESCENT == 2 |
| 1730 |
current_robot_info.weapon_type2 = weapon_type2; |
| 1731 |
#endif |
| 1732 |
current_robot_info.strength = strength; |
| 1733 |
current_robot_info.mass = mass; |
| 1734 |
current_robot_info.drag = drag; |
| 1735 |
current_robot_info.cloak_type = cloak_type; |
| 1736 |
current_robot_info.attack_type = attack_type; |
| 1737 |
current_robot_info.boss_flag = boss_flag; |
| 1738 |
|
| 1739 |
/* The input file uses zero/non-zero to pick powerup/robot. Other input |
| 1740 |
* sources store robot as OBJ_ROBOT and powerup as OBJ_POWERUP, so |
| 1741 |
* build_contained_object_parameters_from_untrusted expects those values. |
| 1742 |
* Convert the type here. |
| 1743 |
*/ |
| 1744 |
current_robot_info.contains = build_contained_object_parameters_from_untrusted(contains_type ? underlying_value(contained_object_type::robot) : underlying_value(contained_object_type::powerup), contains_id, contains_count); |
| 1745 |
current_robot_info.contains_prob = contains_prob; |
| 1746 |
#if DXX_BUILD_DESCENT == 2 |
| 1747 |
current_robot_info.companion = companion; |
| 1748 |
current_robot_info.badass = badass; |
| 1749 |
current_robot_info.lightcast = lightcast; |
| 1750 |
current_robot_info.glow = (glow>>12); //convert to 4:4 |
| 1751 |
current_robot_info.death_roll = death_roll; |
| 1752 |
current_robot_info.deathroll_sound = deathroll_sound; |
| 1753 |
current_robot_info.thief = thief; |
| 1754 |
current_robot_info.flags = flags; |
| 1755 |
current_robot_info.kamikaze = kamikaze; |
| 1756 |
current_robot_info.pursuit = pursuit; |
| 1757 |
current_robot_info.smart_blobs = smart_blobs; |
| 1758 |
current_robot_info.energy_blobs = energy_blobs; |
| 1759 |
current_robot_info.energy_drain = energy_drain; |
| 1760 |
#endif |
| 1761 |
current_robot_info.score_value = score_value; |
| 1762 |
current_robot_info.see_sound = see_sound; |
| 1763 |
current_robot_info.attack_sound = attack_sound; |
| 1764 |
current_robot_info.claw_sound = claw_sound; |
| 1765 |
#if DXX_BUILD_DESCENT == 2 |
| 1766 |
current_robot_info.taunt_sound = taunt_sound; |
| 1767 |
current_robot_info.behavior = behavior; // Default behavior for this robot, if coming out of matcen. |
| 1768 |
current_robot_info.aim = min(f2i(aim*255), 255); // how well this robot type can aim. 255=perfect |
| 1769 |
#endif |
| 1770 |
|
| 1771 |
++LevelSharedRobotInfoState.N_robot_types; |
| 1772 |
#if DXX_BUILD_DESCENT == 1 |
| 1773 |
Num_total_object_types++; |
| 1774 |
#elif DXX_BUILD_DESCENT == 2 |
| 1775 |
current_bm_type = bm_type::none; |
| 1776 |
#endif |
| 1777 |
} |
| 1778 |
|
| 1779 |
#if DXX_BUILD_DESCENT == 1 |
| 1780 |
//read a polygon object of some sort |
| 1781 |
void bm_read_object(char *&arg, int skip) |
| 1782 |
#elif DXX_BUILD_DESCENT == 2 |
| 1783 |
//read a reactor model |
| 1784 |
void bm_read_reactor(void) |
| 1785 |
#endif |
| 1786 |
{ |
| 1787 |
char *model_name, *model_name_dead=NULL; |
| 1788 |
int first_bitmap_num, first_bitmap_num_dead=0, n_normal_bitmaps; |
| 1789 |
char *equal_ptr; |
| 1790 |
fix lighting = F1_0/2; // Default |
| 1791 |
#if DXX_BUILD_DESCENT == 1 |
| 1792 |
int type = -1; |
| 1793 |
fix strength{0}; |
| 1794 |
#elif DXX_BUILD_DESCENT == 2 |
| 1795 |
assert(Num_reactors < Reactors.size()); |
| 1796 |
#endif |
| 1797 |
|
| 1798 |
model_name = strtok( NULL, space_tab ); |
| 1799 |
|
| 1800 |
// Process bitmaps |
| 1801 |
current_bm_type = bm_type::none; |
| 1802 |
arg = strtok( NULL, space_tab ); |
| 1803 |
first_bitmap_num = N_ObjBitmapPtrs; |
| 1804 |
|
| 1805 |
while (arg!=NULL) { |
| 1806 |
|
| 1807 |
equal_ptr = strchr( arg, '=' ); |
| 1808 |
|
| 1809 |
if ( equal_ptr ) { |
| 1810 |
*equal_ptr='\0'; |
| 1811 |
equal_ptr++; |
| 1812 |
|
| 1813 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 1814 |
|
| 1815 |
#if DXX_BUILD_DESCENT == 1 |
| 1816 |
if (!d_stricmp(arg,"type")) { |
| 1817 |
if (!d_stricmp(equal_ptr,"controlcen")) |
| 1818 |
type = OL_CONTROL_CENTER; |
| 1819 |
else if (!d_stricmp(equal_ptr,"clutter")) |
| 1820 |
type = OL_CLUTTER; |
| 1821 |
else if (!d_stricmp(equal_ptr,"exit")) |
| 1822 |
type = OL_EXIT; |
| 1823 |
} |
| 1824 |
else |
| 1825 |
#endif |
| 1826 |
if (!d_stricmp( arg, "dead_pof" )) { |
| 1827 |
model_name_dead = equal_ptr; |
| 1828 |
first_bitmap_num_dead=N_ObjBitmapPtrs; |
| 1829 |
} else if (!d_stricmp( arg, "lighting" )) { |
| 1830 |
lighting = fl2f(atof(equal_ptr)); |
| 1831 |
if ( (lighting < 0) || (lighting > F1_0 )) { |
| 1832 |
Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)); |
| 1833 |
} |
| 1834 |
} |
| 1835 |
#if DXX_BUILD_DESCENT == 1 |
| 1836 |
else if (!d_stricmp( arg, "strength" )) { |
| 1837 |
strength = fl2f(atof(equal_ptr)); |
| 1838 |
} |
| 1839 |
#elif DXX_BUILD_DESCENT == 2 |
| 1840 |
else { |
| 1841 |
Int3(); |
| 1842 |
} |
| 1843 |
#endif |
| 1844 |
} else { // Must be a texture specification... |
| 1845 |
#if DXX_BUILD_DESCENT == 1 |
| 1846 |
load_polymodel_bitmap(skip, arg); |
| 1847 |
#elif DXX_BUILD_DESCENT == 2 |
| 1848 |
load_polymodel_bitmap(0, arg); |
| 1849 |
#endif |
| 1850 |
} |
| 1851 |
arg = strtok( NULL, space_tab ); |
| 1852 |
} |
| 1853 |
|
| 1854 |
if ( model_name_dead ) |
| 1855 |
n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num; |
| 1856 |
else |
| 1857 |
n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num; |
| 1858 |
|
| 1859 |
const auto model_num = load_polygon_model(model_name, n_normal_bitmaps, first_bitmap_num, nullptr); |
| 1860 |
|
| 1861 |
#if DXX_BUILD_DESCENT == 1 |
| 1862 |
if (type == OL_CONTROL_CENTER) |
| 1863 |
reconstruct_at(Reactors[0], read_model_guns, model_name); |
| 1864 |
#endif |
| 1865 |
if ( model_name_dead ) |
| 1866 |
Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL); |
| 1867 |
else |
| 1868 |
Dead_modelnums[model_num] = polygon_model_index::None; |
| 1869 |
|
| 1870 |
#if DXX_BUILD_DESCENT == 1 |
| 1871 |
if (type == -1) |
| 1872 |
Error("No object type specified for object in BITMAPS.TBL on line %d\n",linenum); |
| 1873 |
|
| 1874 |
ObjType[Num_total_object_types] = type; |
| 1875 |
ObjId[Num_total_object_types] = model_num; |
| 1876 |
ObjStrength[Num_total_object_types] = strength; |
| 1877 |
|
| 1878 |
Num_total_object_types++; |
| 1879 |
|
| 1880 |
if (type == OL_EXIT) { |
| 1881 |
exit_modelnum = model_num; |
| 1882 |
destroyed_exit_modelnum = Dead_modelnums[model_num]; |
| 1883 |
} |
| 1884 |
#elif DXX_BUILD_DESCENT == 2 |
| 1885 |
reconstruct_at(Reactors[Num_reactors], read_model_guns, model_name); |
| 1886 |
Reactors[Num_reactors].model_num = model_num; |
| 1887 |
|
| 1888 |
Num_reactors++; |
| 1889 |
#endif |
| 1890 |
} |
| 1891 |
|
| 1892 |
#if DXX_BUILD_DESCENT == 2 |
| 1893 |
//read the marker object |
| 1894 |
void bm_read_marker() |
| 1895 |
{ |
| 1896 |
char *model_name; |
| 1897 |
int first_bitmap_num, n_normal_bitmaps; |
| 1898 |
char *equal_ptr; |
| 1899 |
|
| 1900 |
model_name = strtok( NULL, space_tab ); |
| 1901 |
|
| 1902 |
// Process bitmaps |
| 1903 |
current_bm_type = bm_type::none; |
| 1904 |
arg = strtok( NULL, space_tab ); |
| 1905 |
first_bitmap_num = N_ObjBitmapPtrs; |
| 1906 |
|
| 1907 |
while (arg!=NULL) { |
| 1908 |
|
| 1909 |
equal_ptr = strchr( arg, '=' ); |
| 1910 |
|
| 1911 |
if ( equal_ptr ) { |
| 1912 |
*equal_ptr='\0'; |
| 1913 |
equal_ptr++; |
| 1914 |
|
| 1915 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 1916 |
Int3(); |
| 1917 |
|
| 1918 |
} else { // Must be a texture specification... |
| 1919 |
load_polymodel_bitmap(0, arg); |
| 1920 |
} |
| 1921 |
arg = strtok( NULL, space_tab ); |
| 1922 |
} |
| 1923 |
|
| 1924 |
n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num; |
| 1925 |
|
| 1926 |
LevelSharedPolygonModelState.Marker_model_num = load_polygon_model(model_name, n_normal_bitmaps, first_bitmap_num, NULL); |
| 1927 |
} |
| 1928 |
|
| 1929 |
//read the exit model |
| 1930 |
void bm_read_exitmodel() |
| 1931 |
{ |
| 1932 |
char *model_name, *model_name_dead=NULL; |
| 1933 |
int first_bitmap_num{0}, first_bitmap_num_dead=0, n_normal_bitmaps; |
| 1934 |
char *equal_ptr; |
| 1935 |
|
| 1936 |
model_name = strtok( NULL, space_tab ); |
| 1937 |
|
| 1938 |
// Process bitmaps |
| 1939 |
current_bm_type = bm_type::none; |
| 1940 |
arg = strtok( NULL, space_tab ); |
| 1941 |
first_bitmap_num = N_ObjBitmapPtrs; |
| 1942 |
|
| 1943 |
while (arg!=NULL) { |
| 1944 |
|
| 1945 |
equal_ptr = strchr( arg, '=' ); |
| 1946 |
|
| 1947 |
if ( equal_ptr ) { |
| 1948 |
*equal_ptr='\0'; |
| 1949 |
equal_ptr++; |
| 1950 |
|
| 1951 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 1952 |
|
| 1953 |
if (!d_stricmp( arg, "dead_pof" )) { |
| 1954 |
model_name_dead = equal_ptr; |
| 1955 |
first_bitmap_num_dead=N_ObjBitmapPtrs; |
| 1956 |
} else { |
| 1957 |
Int3(); |
| 1958 |
} |
| 1959 |
} else { // Must be a texture specification... |
| 1960 |
load_polymodel_bitmap(0, arg); |
| 1961 |
} |
| 1962 |
arg = strtok( NULL, space_tab ); |
| 1963 |
} |
| 1964 |
|
| 1965 |
if ( model_name_dead ) |
| 1966 |
n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num; |
| 1967 |
else |
| 1968 |
n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num; |
| 1969 |
|
| 1970 |
const auto model_num = load_polygon_model(model_name, n_normal_bitmaps, first_bitmap_num, nullptr); |
| 1971 |
|
| 1972 |
if ( model_name_dead ) |
| 1973 |
Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL); |
| 1974 |
else |
| 1975 |
Dead_modelnums[model_num] = polygon_model_index::None; |
| 1976 |
|
| 1977 |
exit_modelnum = model_num; |
| 1978 |
destroyed_exit_modelnum = Dead_modelnums[model_num]; |
| 1979 |
|
| 1980 |
} |
| 1981 |
#endif |
| 1982 |
|
| 1983 |
#if DXX_BUILD_DESCENT == 1 |
| 1984 |
void bm_read_player_ship(char *&arg, int skip) |
| 1985 |
#elif DXX_BUILD_DESCENT == 2 |
| 1986 |
void bm_read_player_ship(void) |
| 1987 |
#endif |
| 1988 |
{ |
| 1989 |
char *model_name_dying=NULL; |
| 1990 |
char *model_name[MAX_MODEL_VARIANTS]; |
| 1991 |
int n_models{0},i; |
| 1992 |
int first_bitmap_num[MAX_MODEL_VARIANTS]; |
| 1993 |
char *equal_ptr; |
| 1994 |
robot_info ri; |
| 1995 |
int last_multi_bitmap_num=-1; |
| 1996 |
|
| 1997 |
// Process bitmaps |
| 1998 |
current_bm_type = bm_type::none; |
| 1999 |
|
| 2000 |
arg = strtok( NULL, space_tab ); |
| 2001 |
|
| 2002 |
Player_ship->mass = Player_ship->drag = 0; //stupid defaults |
| 2003 |
Player_ship->expl_vclip_num = vclip_index::None; |
| 2004 |
|
| 2005 |
while (arg!=NULL) { |
| 2006 |
|
| 2007 |
equal_ptr = strchr( arg, '=' ); |
| 2008 |
|
| 2009 |
if ( equal_ptr ) { |
| 2010 |
|
| 2011 |
*equal_ptr='\0'; |
| 2012 |
equal_ptr++; |
| 2013 |
|
| 2014 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 2015 |
|
| 2016 |
if (!d_stricmp( arg, "model" )) { |
| 2017 |
Assert(n_models==0); |
| 2018 |
model_name[0] = equal_ptr; |
| 2019 |
first_bitmap_num[0] = N_ObjBitmapPtrs; |
| 2020 |
n_models = 1; |
| 2021 |
} else if (!d_stricmp( arg, "simple_model" )) { |
| 2022 |
model_name[n_models] = equal_ptr; |
| 2023 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 2024 |
n_models++; |
| 2025 |
#if DXX_BUILD_DESCENT == 2 |
| 2026 |
Assert(n_models < MAX_MODEL_VARIANTS); |
| 2027 |
#endif |
| 2028 |
|
| 2029 |
if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1) |
| 2030 |
last_multi_bitmap_num=N_ObjBitmapPtrs; |
| 2031 |
} |
| 2032 |
else if (!d_stricmp( arg, "mass" )) |
| 2033 |
Player_ship->mass = fl2f(atof(equal_ptr)); |
| 2034 |
else if (!d_stricmp( arg, "drag" )) |
| 2035 |
Player_ship->drag = fl2f(atof(equal_ptr)); |
| 2036 |
// else if (!d_stricmp( arg, "low_thrust" )) |
| 2037 |
// Player_ship->low_thrust = fl2f(atof(equal_ptr)); |
| 2038 |
else if (!d_stricmp( arg, "max_thrust" )) |
| 2039 |
Player_ship->max_thrust = fl2f(atof(equal_ptr)); |
| 2040 |
else if (!d_stricmp( arg, "reverse_thrust" )) |
| 2041 |
Player_ship->reverse_thrust = fl2f(atof(equal_ptr)); |
| 2042 |
else if (!d_stricmp( arg, "brakes" )) |
| 2043 |
Player_ship->brakes = fl2f(atof(equal_ptr)); |
| 2044 |
else if (!d_stricmp( arg, "wiggle" )) |
| 2045 |
Player_ship->wiggle = fl2f(atof(equal_ptr)); |
| 2046 |
else if (!d_stricmp( arg, "max_rotthrust" )) |
| 2047 |
Player_ship->max_rotthrust = fl2f(atof(equal_ptr)); |
| 2048 |
else if (!d_stricmp( arg, "dying_pof" )) |
| 2049 |
model_name_dying = equal_ptr; |
| 2050 |
else if (!d_stricmp( arg, "expl_vclip_num" )) |
| 2051 |
Player_ship->expl_vclip_num = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2052 |
#if DXX_BUILD_DESCENT == 2 |
| 2053 |
else { |
| 2054 |
Int3(); |
| 2055 |
} |
| 2056 |
#endif |
| 2057 |
} |
| 2058 |
else if (!d_stricmp( arg, "multi_textures" )) { |
| 2059 |
|
| 2060 |
First_multi_bitmap_num = N_ObjBitmapPtrs; |
| 2061 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 2062 |
|
| 2063 |
} |
| 2064 |
else // Must be a texture specification... |
| 2065 |
{ |
| 2066 |
#if DXX_BUILD_DESCENT == 1 |
| 2067 |
load_polymodel_bitmap(skip, arg); |
| 2068 |
#elif DXX_BUILD_DESCENT == 2 |
| 2069 |
load_polymodel_bitmap(0, arg); |
| 2070 |
#endif |
| 2071 |
} |
| 2072 |
|
| 2073 |
arg = strtok( NULL, space_tab ); |
| 2074 |
} |
| 2075 |
if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1) |
| 2076 |
last_multi_bitmap_num=N_ObjBitmapPtrs; |
| 2077 |
|
| 2078 |
if (First_multi_bitmap_num==-1) |
| 2079 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 2080 |
|
| 2081 |
Assert(last_multi_bitmap_num-First_multi_bitmap_num == (MAX_PLAYERS-1)*2); |
| 2082 |
|
| 2083 |
auto &Polygon_models = LevelSharedPolygonModelState.Polygon_models; |
| 2084 |
for (i=0;i<n_models;i++) { |
| 2085 |
int n_textures; |
| 2086 |
|
| 2087 |
n_textures = first_bitmap_num[i+1] - first_bitmap_num[i]; |
| 2088 |
const auto model_num = load_polygon_model(model_name[i], n_textures, first_bitmap_num[i], (i == 0) ? &ri : nullptr); |
| 2089 |
|
| 2090 |
if (i==0) |
| 2091 |
Player_ship->model_num = model_num; |
| 2092 |
else |
| 2093 |
Polygon_models.front().simpler_model = build_polygon_simpler_model_index_from_polygon_model_index(model_num); |
| 2094 |
} |
| 2095 |
|
| 2096 |
if ( model_name_dying ) { |
| 2097 |
Assert(n_models); |
| 2098 |
Dying_modelnums[Player_ship->model_num] = load_polygon_model(model_name_dying,first_bitmap_num[1]-first_bitmap_num[0],first_bitmap_num[0],NULL); |
| 2099 |
} |
| 2100 |
|
| 2101 |
assert(ri.n_guns == MAX_GUNS); |
| 2102 |
|
| 2103 |
//calc player gun positions |
| 2104 |
|
| 2105 |
{ |
| 2106 |
const auto &r = ri; |
| 2107 |
const auto &pm = Polygon_models[Player_ship->model_num]; |
| 2108 |
|
| 2109 |
/* Binding to the zip iterator produces references. For r.gun_points |
| 2110 |
* and r.gun_submodels, a mutable local is desired instead. |
| 2111 |
* |
| 2112 |
* If there are no submodels, copy directly from `r.gun_points` to |
| 2113 |
* `plr_gun_point` (bound to an element of `Player_ship->gun_points`). |
| 2114 |
* |
| 2115 |
* If there are submodels: |
| 2116 |
* - Copy the submodel index into a local `gun_submodel_idx` |
| 2117 |
* - Copy the r.gun_points vector into a local `pnt` |
| 2118 |
* - Redirect `ppnt` to the local. |
| 2119 |
* - Update the local as needed from the polygon models. |
| 2120 |
* - Copy that local to `plr_gun_point`. |
| 2121 |
* |
| 2122 |
* This minimizes unnecessary copying. |
| 2123 |
*/ |
| 2124 |
for (auto &&[ref_gun_point, ref_gun_submodel_idx, plr_gun_point] : zip(partial_range(r.gun_points, r.n_guns), r.gun_submodels, Player_ship->gun_points)) |
| 2125 |
{ |
| 2126 |
auto ppnt{&ref_gun_point}; |
| 2127 |
/* Create a local copy to be modified by inner `for` loop. */ |
| 2128 |
vms_vector pnt; |
| 2129 |
if (auto gun_submodel_idx{ref_gun_submodel_idx}) |
| 2130 |
{ |
| 2131 |
//instance up the tree for this gun |
| 2132 |
pnt = ref_gun_point; |
| 2133 |
ppnt = &pnt; |
| 2134 |
for (; gun_submodel_idx && gun_submodel_idx < pm.submodel_offsets.size(); gun_submodel_idx = pm.submodel_parents[gun_submodel_idx]) |
| 2135 |
vm_vec_add2(pnt, pm.submodel_offsets[gun_submodel_idx]); |
| 2136 |
} |
| 2137 |
plr_gun_point = *ppnt; |
| 2138 |
} |
| 2139 |
} |
| 2140 |
} |
| 2141 |
|
| 2142 |
#if DXX_BUILD_DESCENT == 1 |
| 2143 |
std::size_t bm_read_some_file(d_vclip_array &Vclip, std::size_t texture_count, const std::string &dest_bm, char *&arg, int skip) |
| 2144 |
#elif DXX_BUILD_DESCENT == 2 |
| 2145 |
std::size_t bm_read_some_file(d_vclip_array &Vclip, std::size_t texture_count, int skip) |
| 2146 |
#endif |
| 2147 |
{ |
| 2148 |
|
| 2149 |
switch (current_bm_type) { |
| 2150 |
#if DXX_BUILD_DESCENT == 2 |
| 2151 |
case bm_type::none: |
| 2152 |
Error("Trying to read bitmap <%s> with current_bm_type==BM_NONE on line %d of BITMAPS.TBL",arg,linenum); |
| 2153 |
break; |
| 2154 |
#endif |
| 2155 |
case bm_type::cockpit: { |
| 2156 |
const auto bitmap = bm_load_sub(skip, arg); |
| 2157 |
if (const auto cp_idx{cockpit_bitmap.valid_index(Num_cockpits++)}) |
| 2158 |
cockpit_bitmap[*cp_idx] = bitmap; |
| 2159 |
else |
| 2160 |
throw std::runtime_error("too many cockpit bitmaps"); |
| 2161 |
return texture_count; |
| 2162 |
} |
| 2163 |
case bm_type::gauges: |
| 2164 |
#if DXX_BUILD_DESCENT == 1 |
| 2165 |
bm_read_gauges(arg, skip); |
| 2166 |
#elif DXX_BUILD_DESCENT == 2 |
| 2167 |
bm_read_gauges(skip); |
| 2168 |
return texture_count; |
| 2169 |
case bm_type::gauges_hires: |
| 2170 |
bm_read_gauges_hires(); |
| 2171 |
#endif |
| 2172 |
return texture_count; |
| 2173 |
case bm_type::vclip: |
| 2174 |
#if DXX_BUILD_DESCENT == 1 |
| 2175 |
bm_read_vclip(Vclip, arg, skip); |
| 2176 |
#elif DXX_BUILD_DESCENT == 2 |
| 2177 |
bm_read_vclip(Vclip, skip); |
| 2178 |
#endif |
| 2179 |
return texture_count; |
| 2180 |
case bm_type::eclip: |
| 2181 |
#if DXX_BUILD_DESCENT == 1 |
| 2182 |
texture_count = bm_read_eclip(texture_count, dest_bm, arg, skip); |
| 2183 |
#elif DXX_BUILD_DESCENT == 2 |
| 2184 |
texture_count = bm_read_eclip(texture_count, skip); |
| 2185 |
#endif |
| 2186 |
return texture_count; |
| 2187 |
case bm_type::textures: { |
| 2188 |
const auto bitmap = bm_load_sub(skip, arg); |
| 2189 |
Assert(tmap_count < MAX_TEXTURES); |
| 2190 |
tmap_count++; |
| 2191 |
Textures[texture_count] = bitmap; |
| 2192 |
set_texture_name(LevelUniqueTmapInfoState.TmapInfo, texture_count, arg); |
| 2193 |
Assert(texture_count < MAX_TEXTURES); |
| 2194 |
texture_count++; |
| 2195 |
NumTextures = texture_count; |
| 2196 |
return texture_count; |
| 2197 |
} |
| 2198 |
case bm_type::wclip: |
| 2199 |
#if DXX_BUILD_DESCENT == 1 |
| 2200 |
texture_count = bm_read_wclip(texture_count, arg, skip); |
| 2201 |
return texture_count; |
| 2202 |
default: |
| 2203 |
#elif DXX_BUILD_DESCENT == 2 |
| 2204 |
texture_count = bm_read_wclip(texture_count, skip); |
| 2205 |
return texture_count; |
| 2206 |
#endif |
| 2207 |
case bm_type::effects: |
| 2208 |
case bm_type::wall_anims: |
| 2209 |
case bm_type::robot: |
| 2210 |
return texture_count; |
| 2211 |
} |
| 2212 |
#if DXX_BUILD_DESCENT == 2 |
| 2213 |
Error("Trying to read bitmap <%s> with unknown current_bm_type <%x> on line %d of BITMAPS.TBL",arg,static_cast<unsigned>(current_bm_type), linenum); |
| 2214 |
#endif |
| 2215 |
} |
| 2216 |
|
| 2217 |
// ------------------------------------------------------------------------------ |
| 2218 |
// If unused_flag is set, then this is just a placeholder. Don't actually reference vclips or load bbms. |
| 2219 |
#if DXX_BUILD_DESCENT == 1 |
| 2220 |
void bm_read_weapon(char *&arg, int skip, int unused_flag) |
| 2221 |
#elif DXX_BUILD_DESCENT == 2 |
| 2222 |
void bm_read_weapon(int skip, int unused_flag) |
| 2223 |
#endif |
| 2224 |
{ |
| 2225 |
int i,n; |
| 2226 |
int n_models{0}; |
| 2227 |
char *equal_ptr; |
| 2228 |
char *pof_file_inner=NULL; |
| 2229 |
char *model_name[MAX_MODEL_VARIANTS]; |
| 2230 |
int first_bitmap_num[MAX_MODEL_VARIANTS]; |
| 2231 |
int lighted; //flag for whether is a texture is lighted |
| 2232 |
|
| 2233 |
Assert(N_weapon_types < MAX_WEAPON_TYPES); |
| 2234 |
|
| 2235 |
n = N_weapon_types; |
| 2236 |
N_weapon_types++; |
| 2237 |
#if DXX_BUILD_DESCENT == 2 |
| 2238 |
Assert(N_weapon_types <= MAX_WEAPON_TYPES); |
| 2239 |
#endif |
| 2240 |
|
| 2241 |
if (unused_flag) { |
| 2242 |
#if DXX_BUILD_DESCENT == 1 |
| 2243 |
clear_to_end_of_line(arg); |
| 2244 |
#elif DXX_BUILD_DESCENT == 2 |
| 2245 |
clear_to_end_of_line(); |
| 2246 |
#endif |
| 2247 |
return; |
| 2248 |
} |
| 2249 |
|
| 2250 |
if (skip) { |
| 2251 |
#if DXX_BUILD_DESCENT == 1 |
| 2252 |
clear_to_end_of_line(arg); |
| 2253 |
#elif DXX_BUILD_DESCENT == 2 |
| 2254 |
clear_to_end_of_line(); |
| 2255 |
#endif |
| 2256 |
return; |
| 2257 |
} |
| 2258 |
|
| 2259 |
// Initialize weapon array |
| 2260 |
Weapon_info[n].render = WEAPON_RENDER_NONE; // 0=laser, 1=blob, 2=object |
| 2261 |
Weapon_info[n].bitmap = {}; |
| 2262 |
Weapon_info[n].model_num = polygon_model_index::None; |
| 2263 |
Weapon_info[n].model_num_inner = polygon_model_index::None; |
| 2264 |
Weapon_info[n].blob_size = 0x1000; // size of blob |
| 2265 |
Weapon_info[n].flash_vclip = vclip_index::None; |
| 2266 |
Weapon_info[n].flash_sound = sound_effect::SOUND_LASER_FIRED; |
| 2267 |
Weapon_info[n].flash_size = 0; |
| 2268 |
Weapon_info[n].robot_hit_vclip = vclip_index::None; |
| 2269 |
Weapon_info[n].robot_hit_sound = sound_effect::None; |
| 2270 |
Weapon_info[n].wall_hit_vclip = vclip_index::None; |
| 2271 |
Weapon_info[n].wall_hit_sound = sound_effect::None; |
| 2272 |
Weapon_info[n].impact_size = 0; |
| 2273 |
for (auto &i : Weapon_info[n].strength) |
| 2274 |
i = F1_0; |
| 2275 |
for (auto &i : Weapon_info[n].speed) |
| 2276 |
i = F1_0*10; |
| 2277 |
Weapon_info[n].mass = F1_0; |
| 2278 |
Weapon_info[n].thrust = 0; |
| 2279 |
Weapon_info[n].drag = 0; |
| 2280 |
Weapon_info[n].persistent = weapon_info::persistence_flag::terminate_on_impact; |
| 2281 |
|
| 2282 |
Weapon_info[n].energy_usage = 0; // How much fuel is consumed to fire this weapon. |
| 2283 |
Weapon_info[n].ammo_usage = 0; // How many units of ammunition it uses. |
| 2284 |
Weapon_info[n].fire_wait = F1_0/4; // Time until this weapon can be fired again. |
| 2285 |
Weapon_info[n].fire_count = 1; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. |
| 2286 |
Weapon_info[n].damage_radius = 0; // Radius of damage for missiles, not lasers. Does damage to objects within this radius of hit point. |
| 2287 |
//--01/19/95, mk-- Weapon_info[n].damage_force = 0; // Force (movement) due to explosion |
| 2288 |
Weapon_info[n].destroyable = 1; // Weapons default to destroyable |
| 2289 |
Weapon_info[n].matter = weapon_info::matter_flag::energy; // Weapons default to not being constructed of matter (they are energy!) |
| 2290 |
Weapon_info[n].bounce = weapon_info::bounce_type::never; // Weapons default to not bouncing off walls |
| 2291 |
|
| 2292 |
#if DXX_BUILD_DESCENT == 2 |
| 2293 |
Weapon_info[n].flags = 0; |
| 2294 |
#endif |
| 2295 |
|
| 2296 |
Weapon_info[n].lifetime = WEAPON_DEFAULT_LIFETIME; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. |
| 2297 |
|
| 2298 |
Weapon_info[n].po_len_to_width_ratio = F1_0*10; |
| 2299 |
|
| 2300 |
Weapon_info[n].picture = {}; |
| 2301 |
#if DXX_BUILD_DESCENT == 2 |
| 2302 |
Weapon_info[n].hires_picture = {}; |
| 2303 |
#endif |
| 2304 |
Weapon_info[n].homing_flag = 0; |
| 2305 |
|
| 2306 |
#if DXX_BUILD_DESCENT == 2 |
| 2307 |
Weapon_info[n].flash = 0; |
| 2308 |
Weapon_info[n].multi_damage_scale = F1_0; |
| 2309 |
Weapon_info[n].afterburner_size = 0; |
| 2310 |
Weapon_info[n].children = weapon_id_type::unspecified; |
| 2311 |
#endif |
| 2312 |
|
| 2313 |
// Process arguments |
| 2314 |
arg = strtok( NULL, space_tab ); |
| 2315 |
|
| 2316 |
lighted = 1; //assume first texture is lighted |
| 2317 |
|
| 2318 |
#if DXX_BUILD_DESCENT == 2 |
| 2319 |
Weapon_info[n].speedvar = 128; |
| 2320 |
#endif |
| 2321 |
|
| 2322 |
while (arg!=NULL) { |
| 2323 |
equal_ptr = strchr( arg, '=' ); |
| 2324 |
if ( equal_ptr ) { |
| 2325 |
*equal_ptr='\0'; |
| 2326 |
equal_ptr++; |
| 2327 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 2328 |
if (!d_stricmp( arg, "laser_bmp" )) { |
| 2329 |
// Load bitmap with name equal_ptr |
| 2330 |
|
| 2331 |
Weapon_info[n].bitmap = bm_load_sub(skip, equal_ptr); //load_polymodel_bitmap(equal_ptr); |
| 2332 |
Weapon_info[n].render = WEAPON_RENDER_LASER; |
| 2333 |
|
| 2334 |
} else if (!d_stricmp( arg, "blob_bmp" )) { |
| 2335 |
// Load bitmap with name equal_ptr |
| 2336 |
|
| 2337 |
Weapon_info[n].bitmap = bm_load_sub(skip, equal_ptr); //load_polymodel_bitmap(equal_ptr); |
| 2338 |
Weapon_info[n].render = WEAPON_RENDER_BLOB; |
| 2339 |
|
| 2340 |
} else if (!d_stricmp( arg, "weapon_vclip" )) { |
| 2341 |
// Set vclip to play for this weapon. |
| 2342 |
Weapon_info[n].bitmap = {}; |
| 2343 |
Weapon_info[n].render = WEAPON_RENDER_VCLIP; |
| 2344 |
Weapon_info[n].weapon_vclip = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2345 |
|
| 2346 |
} else if (!d_stricmp( arg, "none_bmp" )) { |
| 2347 |
Weapon_info[n].bitmap = bm_load_sub(skip, equal_ptr); |
| 2348 |
Weapon_info[n].render = WEAPON_RENDER_NONE; |
| 2349 |
|
| 2350 |
} else if (!d_stricmp( arg, "weapon_pof" )) { |
| 2351 |
// Load pof file |
| 2352 |
Assert(n_models==0); |
| 2353 |
model_name[0] = equal_ptr; |
| 2354 |
first_bitmap_num[0] = N_ObjBitmapPtrs; |
| 2355 |
n_models=1; |
| 2356 |
} else if (!d_stricmp( arg, "simple_model" )) { |
| 2357 |
model_name[n_models] = equal_ptr; |
| 2358 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 2359 |
n_models++; |
| 2360 |
#if DXX_BUILD_DESCENT == 2 |
| 2361 |
Assert(n_models < MAX_MODEL_VARIANTS); |
| 2362 |
#endif |
| 2363 |
} else if (!d_stricmp( arg, "weapon_pof_inner" )) { |
| 2364 |
// Load pof file |
| 2365 |
pof_file_inner = equal_ptr; |
| 2366 |
} else if (!d_stricmp( arg, "strength" )) { |
| 2367 |
for (auto &i : unchecked_partial_range(Weapon_info[n].strength, Weapon_info[n].strength.size() - 1)) |
| 2368 |
{ |
| 2369 |
#if DXX_BUILD_DESCENT == 1 |
| 2370 |
i = i2f(atoi(equal_ptr)); |
| 2371 |
#elif DXX_BUILD_DESCENT == 2 |
| 2372 |
i = fl2f(atof(equal_ptr)); |
| 2373 |
#endif |
| 2374 |
equal_ptr = strtok(NULL, space_tab); |
| 2375 |
} |
| 2376 |
Weapon_info[n].strength.back() = i2f(atoi(equal_ptr)); |
| 2377 |
} else if (!d_stricmp( arg, "mass" )) { |
| 2378 |
Weapon_info[n].mass = fl2f(atof(equal_ptr)); |
| 2379 |
} else if (!d_stricmp( arg, "drag" )) { |
| 2380 |
Weapon_info[n].drag = fl2f(atof(equal_ptr)); |
| 2381 |
} else if (!d_stricmp( arg, "thrust" )) { |
| 2382 |
Weapon_info[n].thrust = fl2f(atof(equal_ptr)); |
| 2383 |
} else if (!d_stricmp( arg, "matter" )) { |
| 2384 |
Weapon_info[n].matter = static_cast<weapon_info::matter_flag>(atoi(equal_ptr)); |
| 2385 |
} else if (!d_stricmp( arg, "bounce" )) { |
| 2386 |
Weapon_info[n].bounce = static_cast<weapon_info::bounce_type>(atoi(equal_ptr)); |
| 2387 |
} else if (!d_stricmp( arg, "speed" )) { |
| 2388 |
for (auto &i : unchecked_partial_range(Weapon_info[n].speed, Weapon_info[n].speed.size() - 1)) |
| 2389 |
{ |
| 2390 |
i = i2f(atoi(equal_ptr)); |
| 2391 |
equal_ptr = strtok(NULL, space_tab); |
| 2392 |
} |
| 2393 |
Weapon_info[n].speed.back() = i2f(atoi(equal_ptr)); |
| 2394 |
} |
| 2395 |
#if DXX_BUILD_DESCENT == 2 |
| 2396 |
else if (!d_stricmp( arg, "speedvar" )) { |
| 2397 |
Weapon_info[n].speedvar = (atoi(equal_ptr) * 128) / 100; |
| 2398 |
} |
| 2399 |
#endif |
| 2400 |
else if (!d_stricmp( arg, "flash_vclip" )) { |
| 2401 |
Weapon_info[n].flash_vclip = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2402 |
} else if (!d_stricmp( arg, "flash_sound" )) { |
| 2403 |
Weapon_info[n].flash_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 2404 |
} else if (!d_stricmp( arg, "flash_size" )) { |
| 2405 |
Weapon_info[n].flash_size = fl2f(atof(equal_ptr)); |
| 2406 |
} else if (!d_stricmp( arg, "blob_size" )) { |
| 2407 |
Weapon_info[n].blob_size = fl2f(atof(equal_ptr)); |
| 2408 |
} else if (!d_stricmp( arg, "robot_hit_vclip" )) { |
| 2409 |
Weapon_info[n].robot_hit_vclip = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2410 |
} else if (!d_stricmp( arg, "robot_hit_sound" )) { |
| 2411 |
Weapon_info[n].robot_hit_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 2412 |
} else if (!d_stricmp( arg, "wall_hit_vclip" )) { |
| 2413 |
Weapon_info[n].wall_hit_vclip = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2414 |
} else if (!d_stricmp( arg, "wall_hit_sound" )) { |
| 2415 |
Weapon_info[n].wall_hit_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 2416 |
} else if (!d_stricmp( arg, "impact_size" )) { |
| 2417 |
Weapon_info[n].impact_size = fl2f(atof(equal_ptr)); |
| 2418 |
} else if (!d_stricmp( arg, "lighted" )) { |
| 2419 |
lighted = atoi(equal_ptr); |
| 2420 |
} else if (!d_stricmp( arg, "lw_ratio" )) { |
| 2421 |
Weapon_info[n].po_len_to_width_ratio = fl2f(atof(equal_ptr)); |
| 2422 |
} else if (!d_stricmp( arg, "lightcast" )) { |
| 2423 |
Weapon_info[n].light = fl2f(atof(equal_ptr)); |
| 2424 |
} else if (!d_stricmp( arg, "persistent" )) { |
| 2425 |
Weapon_info[n].persistent = atoi(equal_ptr) ? weapon_info::persistence_flag::persistent : weapon_info::persistence_flag::terminate_on_impact; |
| 2426 |
} else if (!d_stricmp(arg, "energy_usage" )) { |
| 2427 |
Weapon_info[n].energy_usage = fl2f(atof(equal_ptr)); |
| 2428 |
} else if (!d_stricmp(arg, "ammo_usage" )) { |
| 2429 |
Weapon_info[n].ammo_usage = atoi(equal_ptr); |
| 2430 |
} else if (!d_stricmp(arg, "fire_wait" )) { |
| 2431 |
Weapon_info[n].fire_wait = fl2f(atof(equal_ptr)); |
| 2432 |
} else if (!d_stricmp(arg, "fire_count" )) { |
| 2433 |
Weapon_info[n].fire_count = atoi(equal_ptr); |
| 2434 |
} else if (!d_stricmp(arg, "damage_radius" )) { |
| 2435 |
Weapon_info[n].damage_radius = fl2f(atof(equal_ptr)); |
| 2436 |
//--01/19/95, mk-- } else if (!d_stricmp(arg, "damage_force" )) { |
| 2437 |
//--01/19/95, mk-- Weapon_info[n].damage_force = fl2f(atof(equal_ptr)); |
| 2438 |
} else if (!d_stricmp(arg, "lifetime" )) { |
| 2439 |
Weapon_info[n].lifetime = fl2f(atof(equal_ptr)); |
| 2440 |
} else if (!d_stricmp(arg, "destroyable" )) { |
| 2441 |
Weapon_info[n].destroyable = atoi(equal_ptr); |
| 2442 |
} else if (!d_stricmp(arg, "picture" )) { |
| 2443 |
Weapon_info[n].picture = bm_load_sub(skip, equal_ptr); |
| 2444 |
} |
| 2445 |
#if DXX_BUILD_DESCENT == 2 |
| 2446 |
else if (!d_stricmp(arg, "hires_picture" )) { |
| 2447 |
Weapon_info[n].hires_picture = bm_load_sub(skip, equal_ptr); |
| 2448 |
} |
| 2449 |
#endif |
| 2450 |
else if (!d_stricmp(arg, "homing" )) { |
| 2451 |
Weapon_info[n].homing_flag = !!atoi(equal_ptr); |
| 2452 |
} |
| 2453 |
#if DXX_BUILD_DESCENT == 2 |
| 2454 |
else if (!d_stricmp(arg, "flash" )) { |
| 2455 |
Weapon_info[n].flash = atoi(equal_ptr); |
| 2456 |
} else if (!d_stricmp(arg, "multi_damage_scale" )) { |
| 2457 |
Weapon_info[n].multi_damage_scale = fl2f(atof(equal_ptr)); |
| 2458 |
} else if (!d_stricmp(arg, "afterburner_size" )) { |
| 2459 |
Weapon_info[n].afterburner_size = f2i(16*fl2f(atof(equal_ptr))); |
| 2460 |
} else if (!d_stricmp(arg, "children" )) { |
| 2461 |
Weapon_info[n].children = static_cast<weapon_id_type>(atoi(equal_ptr)); |
| 2462 |
} else if (!d_stricmp(arg, "placable" )) { |
| 2463 |
if (atoi(equal_ptr)) { |
| 2464 |
Weapon_info[n].flags |= WIF_PLACABLE; |
| 2465 |
} |
| 2466 |
} else { |
| 2467 |
Int3(); |
| 2468 |
} |
| 2469 |
#endif |
| 2470 |
} else { // Must be a texture specification... |
| 2471 |
grs_bitmap *bm; |
| 2472 |
|
| 2473 |
bm = load_polymodel_bitmap(skip, arg); |
| 2474 |
#if DXX_BUILD_DESCENT == 1 |
| 2475 |
if (bm && ! lighted) |
| 2476 |
#elif DXX_BUILD_DESCENT == 2 |
| 2477 |
if (! lighted) |
| 2478 |
#endif |
| 2479 |
bm->add_flags(BM_FLAG_NO_LIGHTING); |
| 2480 |
|
| 2481 |
lighted = 1; //default for next bitmap is lighted |
| 2482 |
} |
| 2483 |
arg = strtok( NULL, space_tab ); |
| 2484 |
} |
| 2485 |
|
| 2486 |
first_bitmap_num[n_models] = N_ObjBitmapPtrs; |
| 2487 |
|
| 2488 |
auto &Polygon_models = LevelSharedPolygonModelState.Polygon_models; |
| 2489 |
for (i=0;i<n_models;i++) { |
| 2490 |
int n_textures; |
| 2491 |
|
| 2492 |
n_textures = first_bitmap_num[i+1] - first_bitmap_num[i]; |
| 2493 |
|
| 2494 |
const auto model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],NULL); |
| 2495 |
|
| 2496 |
if (i==0) { |
| 2497 |
Weapon_info[n].render = WEAPON_RENDER_POLYMODEL; |
| 2498 |
Weapon_info[n].model_num = model_num; |
| 2499 |
} |
| 2500 |
else |
| 2501 |
Polygon_models.front().simpler_model = build_polygon_simpler_model_index_from_polygon_model_index(model_num); |
| 2502 |
} |
| 2503 |
|
| 2504 |
if ( pof_file_inner ) { |
| 2505 |
Assert(n_models); |
| 2506 |
Weapon_info[n].model_num_inner = load_polygon_model(pof_file_inner,first_bitmap_num[1]-first_bitmap_num[0],first_bitmap_num[0],NULL); |
| 2507 |
} |
| 2508 |
} |
| 2509 |
|
| 2510 |
// ------------------------------------------------------------------------------ |
| 2511 |
#define DEFAULT_POWERUP_SIZE i2f(3) |
| 2512 |
|
| 2513 |
#if DXX_BUILD_DESCENT == 1 |
| 2514 |
void bm_read_powerup(char *&arg, int unused_flag) |
| 2515 |
#elif DXX_BUILD_DESCENT == 2 |
| 2516 |
void bm_read_powerup(int unused_flag) |
| 2517 |
#endif |
| 2518 |
{ |
| 2519 |
char *equal_ptr; |
| 2520 |
|
| 2521 |
Assert(N_powerup_types < MAX_POWERUP_TYPES); |
| 2522 |
|
| 2523 |
const auto n{N_powerup_types}; |
| 2524 |
N_powerup_types++; |
| 2525 |
|
| 2526 |
if (unused_flag) { |
| 2527 |
#if DXX_BUILD_DESCENT == 1 |
| 2528 |
clear_to_end_of_line(arg); |
| 2529 |
#elif DXX_BUILD_DESCENT == 2 |
| 2530 |
clear_to_end_of_line(); |
| 2531 |
#endif |
| 2532 |
return; |
| 2533 |
} |
| 2534 |
|
| 2535 |
// Initialize powerup array |
| 2536 |
const powerup_type_t pn{n}; |
| 2537 |
auto &pin = Powerup_info[pn]; |
| 2538 |
pin.light = F1_0 / 3; // Default lighting value. |
| 2539 |
pin.vclip_num = vclip_index::None; |
| 2540 |
pin.hit_sound = sound_effect::None; |
| 2541 |
pin.size = DEFAULT_POWERUP_SIZE; |
| 2542 |
#if DXX_USE_EDITOR |
| 2543 |
auto &name = Powerup_names[pn]; |
| 2544 |
name[0] = 0; |
| 2545 |
#endif |
| 2546 |
|
| 2547 |
// Process arguments |
| 2548 |
arg = strtok( NULL, space_tab ); |
| 2549 |
|
| 2550 |
while (arg!=NULL) { |
| 2551 |
equal_ptr = strchr( arg, '=' ); |
| 2552 |
if ( equal_ptr ) { |
| 2553 |
*equal_ptr='\0'; |
| 2554 |
equal_ptr++; |
| 2555 |
// if we have john=cool, arg is 'john' and equal_ptr is 'cool' |
| 2556 |
if (!d_stricmp( arg, "vclip_num" )) { |
| 2557 |
pin.vclip_num = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2558 |
} else if (!d_stricmp( arg, "light" )) { |
| 2559 |
pin.light = fl2f(atof(equal_ptr)); |
| 2560 |
} else if (!d_stricmp( arg, "hit_sound" )) { |
| 2561 |
pin.hit_sound = static_cast<sound_effect>(atoi(equal_ptr)); |
| 2562 |
} else if (!d_stricmp( arg, "name" )) { |
| 2563 |
#if DXX_USE_EDITOR |
| 2564 |
const auto len = strlen(equal_ptr); |
| 2565 |
assert(len < name.size()); // Oops, name too long. |
| 2566 |
memcpy(name.data(), &equal_ptr[1], len - 2); |
| 2567 |
name[len - 2] = 0; |
| 2568 |
#endif |
| 2569 |
} else if (!d_stricmp( arg, "size" )) { |
| 2570 |
pin.size = fl2f(atof(equal_ptr)); |
| 2571 |
} |
| 2572 |
#if DXX_BUILD_DESCENT == 2 |
| 2573 |
else { |
| 2574 |
Int3(); |
| 2575 |
} |
| 2576 |
#endif |
| 2577 |
} |
| 2578 |
#if DXX_BUILD_DESCENT == 2 |
| 2579 |
else { // Must be a texture specification... |
| 2580 |
Int3(); |
| 2581 |
} |
| 2582 |
#endif |
| 2583 |
arg = strtok( NULL, space_tab ); |
| 2584 |
} |
| 2585 |
#if DXX_BUILD_DESCENT == 1 |
| 2586 |
ObjType[Num_total_object_types] = OL_POWERUP; |
| 2587 |
ObjId[Num_total_object_types] = static_cast<polygon_model_index>(n); |
| 2588 |
Num_total_object_types++; |
| 2589 |
#endif |
| 2590 |
} |
| 2591 |
|
| 2592 |
#if DXX_BUILD_DESCENT == 1 |
| 2593 |
void bm_read_hostage(char *&arg) |
| 2594 |
#elif DXX_BUILD_DESCENT == 2 |
| 2595 |
void bm_read_hostage() |
| 2596 |
#endif |
| 2597 |
{ |
| 2598 |
char *equal_ptr; |
| 2599 |
|
| 2600 |
Assert(N_hostage_types < MAX_HOSTAGE_TYPES); |
| 2601 |
|
| 2602 |
const auto n{N_hostage_types}; |
| 2603 |
N_hostage_types++; |
| 2604 |
|
| 2605 |
// Process arguments |
| 2606 |
arg = strtok( NULL, space_tab ); |
| 2607 |
|
| 2608 |
while (arg!=NULL) { |
| 2609 |
equal_ptr = strchr( arg, '=' ); |
| 2610 |
if ( equal_ptr ) { |
| 2611 |
*equal_ptr='\0'; |
| 2612 |
equal_ptr++; |
| 2613 |
|
| 2614 |
if (!d_stricmp( arg, "vclip_num" )) |
| 2615 |
|
| 2616 |
Hostage_vclip_num[n] = build_vclip_index_from_untrusted(atoi(equal_ptr)); |
| 2617 |
|
| 2618 |
#if DXX_BUILD_DESCENT == 2 |
| 2619 |
else { |
| 2620 |
Int3(); |
| 2621 |
} |
| 2622 |
#endif |
| 2623 |
} |
| 2624 |
#if DXX_BUILD_DESCENT == 2 |
| 2625 |
else { |
| 2626 |
Int3(); |
| 2627 |
} |
| 2628 |
#endif |
| 2629 |
arg = strtok( NULL, space_tab ); |
| 2630 |
} |
| 2631 |
#if DXX_BUILD_DESCENT == 1 |
| 2632 |
ObjType[Num_total_object_types] = OL_HOSTAGE; |
| 2633 |
ObjId[Num_total_object_types] = static_cast<polygon_model_index>(n); |
| 2634 |
Num_total_object_types++; |
| 2635 |
#endif |
| 2636 |
} |
| 2637 |
|
| 2638 |
} |
| 2639 |
|
| 2640 |
} |
| 2641 |
|
| 2642 |
#if DXX_BUILD_DESCENT == 1 |
| 2643 |
DEFINE_SERIAL_UDT_TO_MESSAGE(tmap_info, t, (static_cast<const std::array<char, 13> &>(t.filename), t.flags, t.lighting, t.damage, t.eclip_num)); |
| 2644 |
ASSERT_SERIAL_UDT_MESSAGE_SIZE(tmap_info, 26); |
| 2645 |
#elif DXX_BUILD_DESCENT == 2 |
| 2646 |
DEFINE_SERIAL_UDT_TO_MESSAGE(tmap_info, t, (t.flags, serial::pad<3>(), t.lighting, t.damage, t.eclip_num, t.destroyed, t.slide_u, t.slide_v)); |
| 2647 |
ASSERT_SERIAL_UDT_MESSAGE_SIZE(tmap_info, 20); |
| 2648 |
#endif |