VERSION 0: Parses a script node line, and if it's valid, adds it to the given parent
| 8206 | |
| 8207 | // VERSION 0: Parses a script node line, and if it's valid, adds it to the given parent |
| 8208 | HTREEITEM CDallasMainDlg::ParseScriptNodeLine_v0(char *line, int linenum, HTREEITEM parent, bool &skip_all_children, |
| 8209 | HTREEITEM insert_before /*=TVI_LAST*/) { |
| 8210 | tTreeNodeData node_data; |
| 8211 | bool add_node; |
| 8212 | int index; |
| 8213 | |
| 8214 | // Make sure given data is ok |
| 8215 | if (line == NULL || parent == NULL || skip_all_children) |
| 8216 | return NULL; |
| 8217 | |
| 8218 | // Read in the node type |
| 8219 | line = strtok(line, ":"); |
| 8220 | if (line == NULL) |
| 8221 | return NULL; |
| 8222 | node_data.type = atoi(line); |
| 8223 | |
| 8224 | // Read in the rest of this node's data |
| 8225 | add_node = FALSE; |
| 8226 | switch (node_data.type) { |
| 8227 | case SCRIPT_HEADER_NODE: |
| 8228 | if ((line = strtok(NULL, ":")) == NULL) |
| 8229 | return NULL; |
| 8230 | node_data.ID = atoi(line); |
| 8231 | if ((line = strtok(NULL, "")) == NULL) |
| 8232 | return NULL; |
| 8233 | strcpy(node_data.name, line); |
| 8234 | add_node = TRUE; |
| 8235 | break; |
| 8236 | case SCRIPT_OWNER_NODE: |
| 8237 | if ((line = strtok(NULL, ":")) == NULL) |
| 8238 | return NULL; |
| 8239 | node_data.ID = atoi(line); |
| 8240 | if ((line = strtok(NULL, "")) == NULL) |
| 8241 | return NULL; |
| 8242 | node_data.int_val = atoi(line); |
| 8243 | |
| 8244 | // Verify object name |
| 8245 | if (node_data.ID == OBJECT_TYPE) { |
| 8246 | object *objp = ObjGet(node_data.int_val); |
| 8247 | if (objp == NULL || objp->type == OBJ_NONE || objp->name == NULL) { |
| 8248 | node_data.int_val = OBJECT_HANDLE_NONE; |
| 8249 | strcpy(node_data.str_val, ""); |
| 8250 | } else { |
| 8251 | strcpy(node_data.str_val, objp->name); |
| 8252 | } |
| 8253 | } |
| 8254 | |
| 8255 | // Verify trigger name |
| 8256 | if (node_data.ID == TRIGGER_TYPE) { |
| 8257 | int t = node_data.int_val; |
| 8258 | if (t < 0 || t >= Num_triggers || t >= MAX_NAMED_TRIGGERS || strlen(Triggers[t].name) == 0) { |
| 8259 | node_data.int_val = NOT_SPECIFIED_TYPE; |
| 8260 | strcpy(node_data.str_val, ""); |
| 8261 | } else { |
| 8262 | strcpy(node_data.str_val, Triggers[t].name); |
| 8263 | } |
| 8264 | } |
| 8265 |
nothing calls this directly
no test coverage detected