| 2568 | } |
| 2569 | |
| 2570 | int osipf_ObjCreate(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient, int parent_handle, |
| 2571 | vector *initial_velocity) { |
| 2572 | object *obj; |
| 2573 | int objnum; |
| 2574 | |
| 2575 | if (id == 65535) // since it is a uint16_t, this is == -1 |
| 2576 | return OBJECT_HANDLE_NONE; |
| 2577 | |
| 2578 | if (((roomnum >= 0) && (roomnum <= Highest_room_index) && (Rooms[roomnum].used)) || (ROOMNUM_OUTSIDE(roomnum))) { |
| 2579 | if (IS_GENERIC(type)) { |
| 2580 | // Make sure the scripts aren't creating objects that have lightmaps! |
| 2581 | ASSERT(Object_info[id].lighting_info.lighting_render_type != LRT_LIGHTMAPS); |
| 2582 | } |
| 2583 | |
| 2584 | objnum = ObjCreate(type, id, roomnum, pos, orient, parent_handle); |
| 2585 | |
| 2586 | if (objnum == -1) { |
| 2587 | return OBJECT_HANDLE_NONE; |
| 2588 | } |
| 2589 | |
| 2590 | obj = &Objects[objnum]; |
| 2591 | |
| 2592 | // if there was an initial velocity, set it |
| 2593 | if (initial_velocity) { |
| 2594 | ASSERT(obj->movement_type == MT_PHYSICS); |
| 2595 | obj->mtype.phys_info.velocity = *initial_velocity; |
| 2596 | } |
| 2597 | |
| 2598 | if (Game_mode & GM_MULTI) { |
| 2599 | // ASSERT (Netgame.local_role==LR_SERVER); |
| 2600 | if (Netgame.local_role == LR_SERVER) { |
| 2601 | MultiSendObject(obj, 0); |
| 2602 | } |
| 2603 | } |
| 2604 | |
| 2605 | InitObjectScripts(obj); |
| 2606 | |
| 2607 | if (IS_GENERIC(obj->type)) { |
| 2608 | int ambient_sound = Object_info[obj->id].sounds[GSI_AMBIENT]; |
| 2609 | if (ambient_sound != SOUND_NONE_INDEX) { |
| 2610 | Sound_system.Play3dSound(ambient_sound, SND_PRIORITY_LOWEST, obj); |
| 2611 | if (Game_mode & GM_MULTI) |
| 2612 | MultiPlay3dSound(ambient_sound, objnum, SND_PRIORITY_LOW); |
| 2613 | if (Demo_flags == DF_RECORDING) |
| 2614 | DemoWrite3DSound(ambient_sound, objnum, SND_PRIORITY_LOW); |
| 2615 | } |
| 2616 | } |
| 2617 | } else { |
| 2618 | return OBJECT_HANDLE_NONE; |
| 2619 | } |
| 2620 | |
| 2621 | return obj->handle; |
| 2622 | } |
| 2623 | |
| 2624 | // OBJECT Properties. |
| 2625 | bool osipf_IsObjectVisible(object *obj) { |
no test coverage detected