| 830 | } |
| 831 | |
| 832 | S32 xPsyche::TranGoal(F32 dt, void* updCtxt) |
| 833 | { |
| 834 | S32 halfway = 0; |
| 835 | S32 just_switched = 0; |
| 836 | xGoal* topgoal; |
| 837 | |
| 838 | if (this->staktop < 0 && this->pendgoal != NULL) |
| 839 | { |
| 840 | this->staktop = 0; |
| 841 | this->goalstak[this->staktop] = this->pendgoal; |
| 842 | this->pendgoal->SetState(GOAL_STAT_ENTER); |
| 843 | this->DBG_HistAdd(this->pendgoal->GetID()); |
| 844 | this->pendgoal = NULL; |
| 845 | this->pendtype = PEND_TRAN_INPROG; |
| 846 | } |
| 847 | |
| 848 | if (this->staktop < 0) |
| 849 | { |
| 850 | return 0; |
| 851 | } |
| 852 | |
| 853 | if ((this->pendtype != 0) && (this->pendtype != 7)) |
| 854 | { |
| 855 | S32 moretodo = 0; |
| 856 | topgoal = this->goalstak[this->staktop]; |
| 857 | switch (topgoal->GetState()) |
| 858 | { |
| 859 | case GOAL_STAT_SUSPEND: |
| 860 | moretodo = topgoal->Suspend(dt, updCtxt); |
| 861 | if (moretodo == 0) |
| 862 | { |
| 863 | topgoal->SetState(GOAL_STAT_PAUSED); |
| 864 | } |
| 865 | break; |
| 866 | case GOAL_STAT_EXIT: |
| 867 | moretodo = topgoal->Exit(dt, updCtxt); |
| 868 | if (moretodo == 0) |
| 869 | { |
| 870 | topgoal->SetState(GOAL_STAT_DONE); |
| 871 | } |
| 872 | break; |
| 873 | default: |
| 874 | topgoal->GetState(); |
| 875 | break; |
| 876 | } |
| 877 | |
| 878 | if (moretodo != 0) |
| 879 | { |
| 880 | return moretodo; |
| 881 | } |
| 882 | halfway = 1; |
| 883 | } |
| 884 | |
| 885 | if (halfway != 0) |
| 886 | { |
| 887 | // FIXME: Unhandled enum values 'PEND_TRAN_NONE', 'PEND_TRAN_INPROG', and 'PEND_TRAN_NOMORE' |
| 888 | switch (this->pendtype) |
| 889 | { |