Gets a value for the calling party
| 722 | |
| 723 | // Gets a value for the calling party |
| 724 | void msafe_GetValue(int type, msafe_struct *mstruct) { |
| 725 | object *objp; |
| 726 | switch (type) { |
| 727 | case MSAFE_SHOW_ENABLED_CONTROLS: |
| 728 | objp = ObjGet(mstruct->objhandle); |
| 729 | if (objp && (objp->type == OBJ_PLAYER)) |
| 730 | mstruct->state = Hud_show_controls; |
| 731 | else |
| 732 | mstruct->state = false; |
| 733 | break; |
| 734 | break; |
| 735 | case MSAFE_OBJECT_PLAYER_CMASK: |
| 736 | objp = ObjGet(mstruct->objhandle); |
| 737 | if (objp && (objp->type == OBJ_PLAYER)) |
| 738 | mstruct->control_mask = Players[objp->id].controller_bitflags; |
| 739 | else |
| 740 | mstruct->control_mask = 0; |
| 741 | break; |
| 742 | case MSAFE_OBJECT_POS: |
| 743 | objp = ObjGet(mstruct->objhandle); |
| 744 | if (!objp) |
| 745 | mstruct->pos = Zero_vector; |
| 746 | else |
| 747 | mstruct->pos = objp->pos; |
| 748 | break; |
| 749 | case MSAFE_OBJECT_ORIENT: |
| 750 | objp = ObjGet(mstruct->objhandle); |
| 751 | if (!objp) |
| 752 | mstruct->orient = Identity_matrix; |
| 753 | else |
| 754 | mstruct->orient = objp->orient; |
| 755 | break; |
| 756 | case MSAFE_OBJECT_ROOMNUM: |
| 757 | objp = ObjGet(mstruct->objhandle); |
| 758 | if (!objp) |
| 759 | mstruct->roomnum = -1; |
| 760 | else |
| 761 | mstruct->roomnum = objp->roomnum; |
| 762 | break; |
| 763 | case MSAFE_OBJECT_WORLD_POSITION: |
| 764 | objp = ObjGet(mstruct->objhandle); |
| 765 | if (!objp) { |
| 766 | mstruct->pos = Zero_vector; |
| 767 | mstruct->orient = Identity_matrix; |
| 768 | mstruct->roomnum = -1; |
| 769 | } else { |
| 770 | mstruct->orient = objp->orient; |
| 771 | mstruct->roomnum = objp->roomnum; |
| 772 | mstruct->pos = objp->pos; |
| 773 | } |
| 774 | break; |
| 775 | case MSAFE_OBJECT_VELOCITY: |
| 776 | objp = ObjGet(mstruct->objhandle); |
| 777 | if (!objp || (objp->movement_type != MT_WALKING && objp->movement_type != MT_PHYSICS)) |
| 778 | mstruct->velocity = Zero_vector; |
| 779 | else |
| 780 | mstruct->velocity = objp->mtype.phys_info.velocity; |
| 781 | break; |
no test coverage detected