| 671 | |
| 672 | #ifndef STANDALONE |
| 673 | bool exechook(int context, const char *ident, const char *body,...) // execute cubescript hook if available and allowed in current context/gamemode |
| 674 | { // always use one of HOOK_SP_MP, HOOK_SP or HOOK_MP and then OR them (as needed) with HOOK_TEAM, HOOK_NOTEAM, HOOK_BOTMODE, HOOK_FLAGMODE, HOOK_ARENA |
| 675 | if(multiplayer(NULL) && (context & HOOK_FLAGMASK) != HOOK_MP && (context & HOOK_FLAGMASK) != HOOK_SP_MP) return false; // hook is singleplayer-only |
| 676 | if(((context & HOOK_TEAM) && !m_teammode) || |
| 677 | ((context & HOOK_NOTEAM) && m_teammode) || |
| 678 | ((context & HOOK_BOTMODE) && !m_botmode) || |
| 679 | ((context & HOOK_FLAGMODE) && m_flags_) || |
| 680 | ((context & HOOK_ARENA) && m_arena)) return false; // wrong gamemode |
| 681 | if(identexists(ident)) |
| 682 | { |
| 683 | defvformatstring(arglist, body, body); |
| 684 | defformatstring(execbody)("%s%c%s", ident, *arglist ? ' ' : '\0', arglist); |
| 685 | setcontext("hook", execbody); |
| 686 | execute(execbody); |
| 687 | resetcontext(); |
| 688 | return true; |
| 689 | } |
| 690 | return false; |
| 691 | } |
| 692 | |
| 693 | void identhash(uint64_t *d) |
| 694 | { |
no test coverage detected