The validation is now done in two steps:
- First we get the list of parameters in the same order they used to be in encoded string
- Then we validate the parameter types like FormatString would use them while encoding the string
if(cur_idx>=this->paramc)throwScript_FatalError(fmt::format("{}: Not enough parameters",name));
if(prev_string!=-1){
/* The previous substring added more parameters than expected, means we will consume them but can't properly validate them. */
for(inti=0;i<cur_param.consumes;i++){
if(prev_idx<prev_count){
ScriptLog::Warning(fmt::format("{}: Parameter {} uses parameter {} from substring {} and cannot be validated",name,param_count+i,prev_idx++,prev_string));
}else{
/* No more extra parameters, assume SQInteger are expected. */
if(cur_idx>=this->paramc)throwScript_FatalError(fmt::format("{}: Not enough parameters",name));
if(!std::holds_alternative<SQInteger>(this->param[cur_idx]))throwScript_FatalError(fmt::format("{}: Parameter {} expects an integer",name,param_count+i));
if(!std::holds_alternative<std::string>(*p))throwScript_FatalError(fmt::format("{}({}): {{{}}} expects a raw string",name,param_count+1,cur_param.cmd));
if(!std::holds_alternative<std::string>(this->param[cur_idx]))throwScript_FatalError(fmt::format("{}: Parameter {} expects a raw string",name,param_count));
ScriptLog::Error(fmt::format("{}({}): {{{}}} expects {} to be consumed, but {} consumes {}",name,param_count+1,cur_param.cmd,cur_param.consumes-1,GetGameStringName(ref->string),count-1));