int CProxyConfParser::set_value(const char *pkey, const char *pvalue, void *pconf) { CProxyServerConf *pproxy_conf = (CProxyServerConf *)pconf; #ifdef _DEBUG assert(pproxy_conf); #endif //_DEBUG if(strcmp(pkey, "master_flag") == 0) { pproxy_conf->bmaster_flag = get_bool_value(pvalue); } else if(strcmp(pkey, "vnode_count") == 0) { pproxy_conf->nvnode_count = get_int_value(pvalue); } else if(strcmp(pkey, "replica_count") == 0) { pproxy_conf->nreplica_count = get_int_value(pvalue); } else if(strcmp(pkey, "namespace_power") == 0) { pproxy_conf->nnamespace_power = get_int_value(pvalue); } else { return CBaseConfParser::set_value(pkey, pvalue, pconf); } return 0; }
int parse_actor_script (xmlNode *cfg) { xmlNode *item; char errmsg[120]; int ok, act_idx; actor_types *act; if (cfg == NULL || cfg->children == NULL) return 0; act_idx = get_property (cfg, "type", "actor type", actor_type_dict); if (act_idx < 0) return 0; act = &(actors_defs[act_idx]); ok = 1; for (item = cfg->children; item; item = item->next) { if (item->type == XML_ELEMENT_NODE) { if (xmlStrcasecmp (item->name, "ghost") == 0) { act->ghost = get_bool_value (item); } else if (xmlStrcasecmp (item->name, "skin") == 0) { get_string_value (act->skin_name, sizeof (act->skin_name), item); } else if (xmlStrcasecmp (item->name, "model") == 0) { get_string_value (act->file_name, sizeof (act->file_name), item); } else if (xmlStrcasecmp (item->name, "frames") == 0) { ok &= parse_actor_frames (act, item->children); } else if (xmlStrcasecmp (item->name, "shirt") == 0) { ok &= parse_actor_shirt (act, item); } else if (xmlStrcasecmp (item->name, "hskin") == 0) { ok &= parse_actor_skin (act, item); } else if (xmlStrcasecmp (item->name, "hair") == 0) { ok &= parse_actor_hair (act, item); } else if (xmlStrcasecmp (item->name, "boots") == 0) { ok &= parse_actor_boots (act, item); } else if (xmlStrcasecmp (item->name, "legs") == 0) { ok &= parse_actor_legs (act, item); } else if (xmlStrcasecmp (item->name, "cape") == 0) { ok &= parse_actor_cape (act, item); } else if (xmlStrcasecmp (item->name, "head") == 0) { ok &= parse_actor_head (act, item); } else if (xmlStrcasecmp (item->name, "shield") == 0) { ok &= parse_actor_shield (act, item); } else if (xmlStrcasecmp (item->name, "weapon") == 0) { ok &= parse_actor_weapon (act, item); } else if (xmlStrcasecmp (item->name, "helmet") == 0) { ok &= parse_actor_helmet (act, item); } else if (xmlStrcasecmp (item->name, "walk_speed") == 0) { act->walk_speed = get_float_value (item); } else if (xmlStrcasecmp (item->name, "run_speed") == 0) { act->run_speed = get_float_value (item); } else { snprintf (errmsg, sizeof (errmsg), "Unknown actor attribute \"%s\"", item->name); LogError (errmsg); ok = 0; } } } return ok; }
int security_get_boolean_pending(const char *name) { char *buf; int val; if (get_bool_value(name, &buf)) return -1; if (atoi(&buf[1])) val = 1; else val = 0; free(buf); return val; }
int security_get_boolean_active(const char *name) { char *buf; int val; if (get_bool_value(name, &buf)) return -1; buf[1] = '\0'; if (atoi(buf)) val = 1; else val = 0; free(buf); return val; }
int weather_parse_effect(xmlNode *node) { xmlNode *item; xmlAttr *attr; int ok = 1; int id = -1; for (attr = node->properties; attr; attr = attr->next) { if (attr->type == XML_ATTRIBUTE_NODE) { if (!xmlStrcasecmp (attr->name, (xmlChar*)"id")) id = atoi((char*)attr->children->content); else { LOG_ERROR_OLD("unknown attribute for effect: %s", (char*)attr->name); ok = 0; } } } if (id < 1) { LOG_ERROR_OLD("wrong or missing id for weather effect"); return 0; } for(item = node->children; item; item = item->next) { if(item->type == XML_ELEMENT_NODE) { if (xmlStrcasecmp(item->name, (xmlChar*)"sprites") == 0) { weather_defs[id].use_sprites = get_bool_value(item); } else if (xmlStrcasecmp(item->name, (xmlChar*)"density") == 0) { weather_defs[id].density = get_float_value(item); } else if (xmlStrcasecmp(item->name, (xmlChar*)"color") == 0) { weather_defs[id].color[0] = 0.0; weather_defs[id].color[1] = 0.0; weather_defs[id].color[2] = 0.0; weather_defs[id].color[3] = 0.0; for (attr = item->properties; attr; attr = attr->next) { if (attr->type == XML_ATTRIBUTE_NODE) { if (!xmlStrcasecmp (attr->name, (xmlChar*)"r")) weather_defs[id].color[0] = atof((char*)attr->children->content); else if (!xmlStrcasecmp (attr->name, (xmlChar*)"g")) weather_defs[id].color[1] = atof((char*)attr->children->content); else if (!xmlStrcasecmp (attr->name, (xmlChar*)"b")) weather_defs[id].color[2] = atof((char*)attr->children->content); else if (!xmlStrcasecmp (attr->name, (xmlChar*)"a")) weather_defs[id].color[3] = atof((char*)attr->children->content); else { LOG_ERROR_OLD("unknown attribute for weather effect color: %s", (char*)attr->name); ok = 0; } } } weather_defs[id].color[0] /= 255.0; weather_defs[id].color[1] /= 255.0; weather_defs[id].color[2] /= 255.0; weather_defs[id].color[3] /= 255.0; } else if (xmlStrcasecmp(item->name, (xmlChar*)"size") == 0) { weather_defs[id].size = get_float_value(item); } else if (xmlStrcasecmp(item->name, (xmlChar*)"speed") == 0) { weather_defs[id].speed = get_float_value(item); } else if (xmlStrcasecmp(item->name, (xmlChar*)"wind_effect") == 0) { weather_defs[id].wind_effect = get_float_value(item); } else if (xmlStrcasecmp(item->name, (xmlChar*)"texture") == 0) { #ifdef NEW_TEXTURES weather_defs[id].texture = load_texture_cached((char*)item->children->content, tt_mesh); #else /* NEW_TEXTURES */ weather_defs[id].texture = load_texture_cache((char*)item->children->content, 0); #endif /* NEW_TEXTURES */ } else { LOG_ERROR_OLD("unknown node for weather effect: %s", item->name); ok = 0; } } else if (item->type == XML_ENTITY_REF_NODE) { ok &= weather_parse_effect(item->children); } } return ok; }
/* * script_type_parse parse the script object type and parse the data * data, the data will be parsed * * return the data offset */ int script_type_parse(unsigned char *data) { int ret = 0; unsigned char *p = data; unsigned char string_output[512]; unsigned long long number = 0; double double_number = 0.0; switch (*p) { case Number: p++; number = get_double(p); double_number = int2double(number); fprintf(stdout, "number = [%.2f]\n", double_number); p += 8; break; case Boolean: p++; ret = get_bool_value(p); p++; break; case String: p++; memset(string_output, 0, sizeof(string_output)); ret = get_string_len(p); p += 2; strncpy((char *)string_output, (const char *)p, ret); fprintf(stdout, "String = [%s]\n", string_output); p += ret; break; case Object: p++; break; case MovieClip: p++; break; case Null: p++; break; case Undefined: p++; break; case Reference: p++; break; case EcmaArray: p++; ret = process_ecma_array(p); p += ret; break; case ObjectEndMarker: p++; break; case StringArray: p++; break; case Date: p++; break; case LongString: p++; break; default: break; } return p - data; }