static void CL_ParseActorSkin (const char* name, const char** text) { /* NOTE: first skin is special cause we don't get the skin with suffix */ if (CL_GetActorSkinCount() == 0) { if (!Q_streq(name, "default") != 0) { Com_Error(ERR_DROP, "CL_ParseActorSkin: First actorskin read from script must be \"default\" skin."); } } actorSkin_t* skin = CL_AllocateActorSkin(name); Com_ParseBlock(name, text, skin, actorskin_vals, nullptr); }
/** * @sa CL_ParseScriptFirst * @note write into cp_campaignPool - free on every game restart and reparse */ void CL_ParseEventMails (const char *name, const char **text) { eventMail_t *eventMail; if (ccs.numEventMails >= MAX_EVENTMAILS) { Com_Printf("CL_ParseEventMails: mail def \"%s\" with same name found, second ignored\n", name); return; } /* initialize the eventMail */ eventMail = &ccs.eventMails[ccs.numEventMails++]; OBJZERO(*eventMail); Com_DPrintf(DEBUG_CLIENT, "...found eventMail %s\n", name); eventMail->id = Mem_PoolStrDup(name, cp_campaignPool, 0); Com_ParseBlock(name, text, eventMail, eventMail_vals, cp_campaignPool); }
/** * @brief Parse the salaries from campaign definition * @param[in] name Name or ID of the found character skill and ability definition * @param[in] text The text of the nation node * @param[out] s Pointer to the campaign salaries data structure to parse into * @note Example: * <code>salary { * soldier_base 3000 * }</code> */ static void CP_ParseSalary (const char *name, const char **text, salary_t *s) { Com_ParseBlock(name, text, s, salary_vals, cp_campaignPool); }
/** * @brief Parses one "components" entry in a .ufo file and writes it into the next free entry in xxxxxxxx (components_t). * @param[in] name The unique id of a components_t array entry. * @param[in] text the whole following text after the "components" definition. * @sa CP_ParseScriptFirst */ static void CP_ParseComponents (const char *name, const char **text) { components_t *comp; const char *errhead = "CP_ParseComponents: unexpected end of file."; const char *token; /* get body */ token = Com_Parse(text); if (!*text || *token != '{') { Com_Printf("CP_ParseComponents: \"%s\" components def without body ignored.\n", name); return; } if (ccs.numComponents >= MAX_ASSEMBLIES) { Com_Printf("CP_ParseComponents: too many technology entries. limit is %i.\n", MAX_ASSEMBLIES); return; } /* New components-entry (next free entry in global comp-list) */ comp = &ccs.components[ccs.numComponents]; ccs.numComponents++; OBJZERO(*comp); /* name is not used */ do { /* get the name type */ token = cgi->Com_EParse(text, errhead, name); if (!*text) break; if (*token == '}') break; /* get values */ if (Q_streq(token, "aircraft")) { token = cgi->Com_EParse(text, errhead, name); if (!*text) break; /* set standard values */ Q_strncpyz(comp->assemblyId, token, sizeof(comp->assemblyId)); comp->assemblyItem = INVSH_GetItemByIDSilent(comp->assemblyId); if (comp->assemblyItem) Com_DPrintf(DEBUG_CLIENT, "CP_ParseComponents: linked item: %s with components: %s\n", token, comp->assemblyId); } else if (Q_streq(token, "item")) { /* Defines what items need to be collected for this item to be researchable. */ if (comp->numItemtypes < MAX_COMP) { /* Parse block */ component_type_data_t itemTokens; OBJZERO(itemTokens); if (Com_ParseBlock ("item", text, &itemTokens, components_type_vals, NULL)) { if (itemTokens.id[0] == '\0') cgi->Com_Error(ERR_DROP, "CP_ParseComponents: \"item\" token id is missing.\n"); if (itemTokens.amount[0] == '\0') cgi->Com_Error(ERR_DROP, "CP_ParseComponents: \"amount\" token id is missing.\n"); if (itemTokens.numbercrash[0] == '\0') cgi->Com_Error(ERR_DROP, "CP_ParseComponents: \"numbercrash\" token id is missing.\n"); comp->items[comp->numItemtypes] = INVSH_GetItemByID(itemTokens.id); /* item id -> item pointer */ /* Parse number of items. */ comp->itemAmount[comp->numItemtypes] = atoi(itemTokens.amount); /* If itemcount needs to be scaled */ if (itemTokens.numbercrash[0] == '%') comp->itemAmount2[comp->numItemtypes] = COMP_ITEMCOUNT_SCALED; else comp->itemAmount2[comp->numItemtypes] = atoi(itemTokens.numbercrash); /** @todo Set item links to NONE if needed */ /* comp->item_idx[comp->numItemtypes] = xxx */ comp->numItemtypes++; } } else { Com_Printf("CP_ParseComponents: \"%s\" Too many 'items' defined. Limit is %i - ignored.\n", name, MAX_COMP); } } else if (Q_streq(token, "time")) { /* Defines how long disassembly lasts. */ token = Com_Parse(text); comp->time = atoi(token); } else { Com_Printf("CP_ParseComponents: Error in \"%s\" - unknown token: \"%s\".\n", name, token); } } while (*text); if (comp->assemblyId[0] == '\0') { cgi->Com_Error(ERR_DROP, "CP_ParseComponents: component \"%s\" is not applied to any aircraft.\n", name); } }