/* bind accept the following input formats: 1 - [S].slide.[L]{.[C]} 2 - [L]{.[C]} where: [S] is the slide to be shown [L] is the location to switch to (immediately in case 2, or right after slide [S] in case 1) [C] is the character to be selected, and is optional The routine tells one form from the other by searching for the '.slide.' NOTE: there exists one script in which [L] is not used in the case 1, but its use is commented out, and would definitely crash the current implementation. */ void LocationName::bind(const char *s) { free(_buf); _buf = strdup(s); _hasSlide = false; _hasCharacter = false; Common::StringArray list; char *tok = strtok(_buf, "."); while (tok) { list.push_back(tok); tok = strtok(NULL, "."); } if (list.size() < 1 || list.size() > 4) error("changeLocation: ill-formed location name '%s'", s); if (list.size() > 1) { if (list[1] == "slide") { _hasSlide = true; _slide = list[0]; list.remove_at(0); // removes slide name list.remove_at(0); // removes 'slide' } if (list.size() == 2) { _hasCharacter = true; _character = list[1]; } } _location = list[0]; strcpy(_buf, s); // kept as reference }