Initalize a room, allocating memory and filling in fields Parameters: rp - the room to be initialized nverts - how many vertices this room will have nfaces - how many faces this room wil have nportals - how many portals this room will have
| 530 | // nfaces - how many faces this room wil have |
| 531 | // nportals - how many portals this room will have |
| 532 | void InitRoom(room *rp, int nverts, int nfaces, int nportals) { |
| 533 | // initialize room fields |
| 534 | rp->flags = 0; |
| 535 | rp->objects = -1; |
| 536 | rp->vis_effects = -1; |
| 537 | rp->volume_lights = NULL; |
| 538 | rp->mirror_face = -1; |
| 539 | rp->num_mirror_faces = 0; |
| 540 | rp->mirror_faces_list = NULL; |
| 541 | rp->room_change_flags = 0; |
| 542 | |
| 543 | #ifndef NEWEDITOR // the new editor must allow users to create a room from scratch |
| 544 | ASSERT(nverts > 0); |
| 545 | ASSERT(nfaces > 0); |
| 546 | #endif |
| 547 | |
| 548 | rp->wind = Zero_vector; |
| 549 | |
| 550 | rp->num_faces = nfaces; |
| 551 | rp->num_verts = nverts; |
| 552 | rp->num_portals = nportals; |
| 553 | rp->last_render_time = 0; |
| 554 | rp->fog_depth = 100.0; |
| 555 | rp->fog_r = 1.0; |
| 556 | rp->fog_g = 1.0; |
| 557 | rp->fog_b = 1.0; |
| 558 | |
| 559 | rp->faces = (face *)RoomMemAlloc(nfaces * sizeof(*rp->faces)); |
| 560 | ASSERT(rp->faces != NULL); |
| 561 | |
| 562 | rp->num_bbf_regions = 0; |
| 563 | |
| 564 | rp->verts = (vector *)RoomMemAlloc(nverts * sizeof(*rp->verts)); |
| 565 | ASSERT(rp->verts != NULL); |
| 566 | |
| 567 | if (Katmai) { |
| 568 | rp->verts4 = (vector4 *)mem_malloc(nverts * sizeof(*rp->verts4)); |
| 569 | ASSERT(rp->verts4 != NULL); |
| 570 | } |
| 571 | |
| 572 | rp->pulse_time = 0; |
| 573 | rp->pulse_offset = 0; |
| 574 | |
| 575 | if (nportals) { |
| 576 | rp->portals = (portal *)RoomMemAlloc(nportals * sizeof(*rp->portals)); |
| 577 | ASSERT(rp->portals != NULL); |
| 578 | } else |
| 579 | rp->portals = NULL; |
| 580 | |
| 581 | // Default to no ambient sound |
| 582 | rp->ambient_sound = -1; |
| 583 | |
| 584 | rp->name = NULL; |
| 585 | rp->doorway_data = NULL; |
| 586 | |
| 587 | rp->env_reverb = 0; // reverb for sound system. |
| 588 | |
| 589 | rp->damage = 0.0; // room damage |
no test coverage detected