| 2948 | } |
| 2949 | |
| 2950 | void TextSourceScript::handleTextSourceScript(Entity& src, std::string input) |
| 2951 | { |
| 2952 | bool statOnlyUpdateNeeded = false; |
| 2953 | |
| 2954 | std::vector<std::string> tokens; |
| 2955 | std::string searchString = input; |
| 2956 | size_t findToken = searchString.find("@"); |
| 2957 | while ( findToken != std::string::npos ) |
| 2958 | { |
| 2959 | std::string token = "@"; |
| 2960 | ++findToken; |
| 2961 | while ( findToken < searchString.length() |
| 2962 | && searchString.at(findToken) != ' ' |
| 2963 | && searchString.at(findToken) != '@' |
| 2964 | && searchString.at(findToken) != '\0' |
| 2965 | ) |
| 2966 | { |
| 2967 | token = token + searchString.at(findToken); |
| 2968 | ++findToken; |
| 2969 | } |
| 2970 | searchString.erase(searchString.find(token), token.length()); |
| 2971 | tokens.push_back(token); |
| 2972 | findToken = searchString.find("@"); |
| 2973 | } |
| 2974 | |
| 2975 | printlog("[SCRIPT]: Starting Execution..."); |
| 2976 | std::string executionLog = "[SCRIPT]: Processed tokens:"; |
| 2977 | std::vector<Entity*> attachedEntities = textSourceScript.getScriptAttachedEntities(src); |
| 2978 | |
| 2979 | for ( auto it = tokens.begin(); it != tokens.end(); ++it ) |
| 2980 | { |
| 2981 | executionLog.append(" ").append(*it); |
| 2982 | |
| 2983 | bool processOnAttachedEntity = false; |
| 2984 | size_t foundAttachedTag = (*it).find("@attached."); |
| 2985 | if ( foundAttachedTag != std::string::npos ) |
| 2986 | { |
| 2987 | processOnAttachedEntity = true; |
| 2988 | // erase "attached." in token, pass the information on to the tag contents. |
| 2989 | (*it).erase(foundAttachedTag + 1, strlen("attached.")); |
| 2990 | size_t foundAttachedTag = input.find("@attached."); |
| 2991 | if ( foundAttachedTag != std::string::npos ) |
| 2992 | { |
| 2993 | input.erase(foundAttachedTag + 1, strlen("attached.")); |
| 2994 | } |
| 2995 | } |
| 2996 | |
| 2997 | if ( (*it).find("@reattachto=") != std::string::npos ) |
| 2998 | { |
| 2999 | int attachTo = textSourceProcessScriptTag(input, "@reattachto=", src); |
| 3000 | if ( attachTo == k_ScriptError ) |
| 3001 | { |
| 3002 | return; |
| 3003 | } |
| 3004 | attachedEntities.clear(); |
| 3005 | list_FreeAll(&src.children); // reattach all the entities again. |
| 3006 | |
| 3007 | textSourceScript.setScriptType(src.textSourceIsScript, textSourceScript.SCRIPT_ATTACHED); |
no test coverage detected