| 1800 | } |
| 1801 | |
| 1802 | bool call::next() |
| 1803 | { |
| 1804 | msgvec * msgs = &call_scenario->messages; |
| 1805 | if (initCall) { |
| 1806 | msgs = &call_scenario->initmessages; |
| 1807 | } |
| 1808 | |
| 1809 | int test; |
| 1810 | /* What is the next message index? */ |
| 1811 | /* Default without branching: use the next message */ |
| 1812 | int new_msg_index = msg_index + 1; |
| 1813 | /* If branch needed, overwrite this default */ |
| 1814 | if (msg_index >= 0 && ((*msgs)[msg_index]->next >= 0) && |
| 1815 | (((test = ((*msgs)[msg_index]->test)) == -1) || |
| 1816 | M_callVariableTable->getVar(test)->isSet())) { |
| 1817 | /* Branching possible, check the probability */ |
| 1818 | int chance = (*msgs)[msg_index]->chance; |
| 1819 | if ((chance <= 0) || (rand() > chance )) { |
| 1820 | /* Branch == overwrite with the 'next' attribute value */ |
| 1821 | new_msg_index = (*msgs)[msg_index]->next; |
| 1822 | } |
| 1823 | } |
| 1824 | msg_index = new_msg_index; |
| 1825 | recv_timeout = 0; |
| 1826 | if (msg_index >= (int)((*msgs).size())) { |
| 1827 | terminate(CStat::E_CALL_SUCCESSFULLY_ENDED); |
| 1828 | return false; |
| 1829 | } |
| 1830 | |
| 1831 | return true; |
| 1832 | } |
| 1833 | |
| 1834 | bool call::executeMessage(message *curmsg) |
| 1835 | { |