| 932 | } |
| 933 | |
| 934 | void LoadActorFromXML(EntityDescription& desc, const TiXmlElement* el, EntityType type) { |
| 935 | const char* type_file_raw = el->Attribute("type_file"); |
| 936 | std::string type_file; |
| 937 | if (type_file_raw && strlen(type_file_raw) > 0) { |
| 938 | type_file = SanitizePath(type_file_raw); |
| 939 | } |
| 940 | |
| 941 | desc.AddEntityType(EDF_ENTITY_TYPE, type); |
| 942 | const char* name = el->Attribute("name"); |
| 943 | if (name) { |
| 944 | desc.AddString(EDF_NAME, name); |
| 945 | } |
| 946 | desc.AddString(EDF_FILE_PATH, type_file); |
| 947 | |
| 948 | if (type == _movement_object) { |
| 949 | std::string script_path; |
| 950 | if (el->QueryStringAttribute("npc_script_path", &script_path) == TIXML_SUCCESS) { |
| 951 | desc.AddString(EDF_NPC_SCRIPT_PATH, script_path); |
| 952 | } |
| 953 | if (el->QueryStringAttribute("pc_script_path", &script_path) == TIXML_SUCCESS) { |
| 954 | desc.AddString(EDF_PC_SCRIPT_PATH, script_path); |
| 955 | } |
| 956 | |
| 957 | int the_id = -1; |
| 958 | const TiXmlElement* connections = el->FirstChildElement("Connections"); |
| 959 | if (connections) { |
| 960 | const TiXmlElement* connection = connections->FirstChildElement("Connection"); |
| 961 | int id; |
| 962 | while (connection) { |
| 963 | if (connection->QueryIntAttribute("id", &id) == TIXML_SUCCESS) { |
| 964 | the_id = id; |
| 965 | } |
| 966 | connection = connection->NextSiblingElement(); |
| 967 | } |
| 968 | } |
| 969 | std::vector<int> connection_vec; |
| 970 | connection_vec.push_back(the_id); |
| 971 | desc.AddIntVec(EDF_CONNECTIONS, connection_vec); |
| 972 | int is_player = 0; |
| 973 | el->QueryIntAttribute("is_player", &is_player); |
| 974 | desc.AddInt(EDF_IS_PLAYER, is_player); |
| 975 | |
| 976 | std::vector<AttachedEnvObject> aeo_vec; |
| 977 | const TiXmlElement* env_object_attachments = el->FirstChildElement("EnvObjectAttachments"); |
| 978 | if (env_object_attachments) { |
| 979 | const TiXmlElement* connection = env_object_attachments->FirstChildElement("EnvObjectAttachment"); |
| 980 | while (connection) { |
| 981 | AttachedEnvObject aeo; |
| 982 | if (connection->QueryIntAttribute("obj_id", &aeo.legacy_obj_id) == TIXML_NO_ATTRIBUTE) { |
| 983 | aeo.legacy_obj_id = -1; |
| 984 | } |
| 985 | const TiXmlElement* bone_connect_el = connection->FirstChildElement("BoneConnect"); |
| 986 | unsigned num = 0; |
| 987 | while (bone_connect_el) { |
| 988 | BoneConnect bone_connect; |
| 989 | bone_connect_el->QueryIntAttribute("bone_id", &bone_connect.bone_id); |
| 990 | bone_connect_el->QueryIntAttribute("num_connections", &bone_connect.num_connections); |
| 991 | int index; |
no test coverage detected