#include #include #include #include "Aw.h" /** * Creates and initializes a new PE structure with an asset list and * tag name. * * The initialized structure must be manually destroyed using free(). * The remaining fields of the PE are to be set by yourself. * * The value NULL may be specified for one or both strings to indicate * that string is not to be used. * * @param asset_list String containing asset list. * @param tag_name String containing the PE's tag name. * @return An initialized aw_object_data_particles structure. */ aw_object_data_particles* new_particle(const char* asset_list, const char* tag_name) { size_t alen = (asset_list == NULL)? 0 : strlen(asset_list); size_t tlen = (tag_name == NULL)? 0 : strlen(tag_name); size_t psiz = alen + tlen + sizeof(aw_object_data_particles); aw_object_data_particles* pe = NULL; pe = (aw_object_data_particles*)malloc(psiz); memset(pe, 0, psiz); pe->asset_list_len = (unsigned short)(alen); pe->name_len = (unsigned char)(tlen); if (alen != 0) memcpy(pe->str_data, asset_list, alen); if (tlen != 0) memcpy(pe->str_data + alen, tag_name, tlen); return pe; } /** * Prepares an initialized PE structure to be built in the world. * * This function also accounts for the bug where the object * action field may be used by the world server if it was * last set by a previous SDK method. * * After calling this function use either the aw_object_add or * aw_object_load SDK methods after setting additional attributes * defining the PE location, etc. * * @param pe The particle emitter to be built. */ void prepare_particle(const aw_object_data_particles* pe) { unsigned int psiz = 0; psiz = sizeof(aw_object_data_particles); psiz += pe->asset_list_len; psiz += pe->name_len; aw_string_set(AW_OBJECT_DESCRIPTION, ""); aw_string_set(AW_OBJECT_ACTION, ""); aw_int_set(AW_OBJECT_TYPE, AW_OBJECT_TYPE_PARTICLES); aw_data_set(AW_OBJECT_DATA, (char*)pe, psiz); }