Browse Source

XML IfVariableNotSet now has support for array based variables in structure parsing

Image 3 years ago
parent
commit
23898ae6d5
1 changed files with 16 additions and 1 deletions
  1. 16 1
      EQ2/source/common/PacketStruct.cpp

+ 16 - 1
EQ2/source/common/PacketStruct.cpp

@@ -1531,7 +1531,22 @@ void PacketStruct::serializePacket(bool clear){
 					}
 				}
 				else{
-					if(!GetVariableIsNotSet(varname.c_str()))
+					// Check to see if the variable contains %i, if it does assume we are in an array
+					// and get the current index from the end of the data struct's name
+					char name[250] = { 0 };
+					if (varname.find("%i") < 0xFFFFFFFF) {
+						vector<string>* varnames = SplitString(varname, '_');
+						vector<string>* indexes = SplitString(data->GetName(), '_');
+						int index = 0;
+						if (indexes->size() > 0 )
+							index = atoi(indexes->at(indexes->size() - 1).c_str());
+
+						sprintf(name, varname.c_str(), index);
+					}
+					else
+						strcpy(name, varname.c_str());
+
+					if(!GetVariableIsNotSet(name))
 						continue;
 				}
 			}