예제 #1
0
파일: waypoints.cpp 프로젝트: TheSumm/rme
Waypoint* Waypoints::getWaypoint(std::string name)
{
	to_lower_str(name);
	WaypointMap::iterator iter = waypoints.find(name);
	if(iter == waypoints.end())
		return nullptr;
	return iter->second;
}
예제 #2
0
파일: waypoints.cpp 프로젝트: TheSumm/rme
void Waypoints::removeWaypoint(std::string name)
{
	to_lower_str(name);
	WaypointMap::iterator iter = waypoints.find(name);
	if(iter == waypoints.end())
		return;
	delete iter->second;
	waypoints.erase(iter);
}
예제 #3
0
파일: creature.cpp 프로젝트: Codex-NG/rme
uint16_t Creature::DirName2ID(std::string dir)
{
	to_lower_str(dir);
	if(dir == "north") return NORTH;
	if(dir == "east") return EAST;
	if(dir == "south") return SOUTH;
	if(dir == "west") return WEST;
	return SOUTH;
}
예제 #4
0
파일: item.cpp 프로젝트: Codex-NG/rme
uint16_t Item::LiquidName2ID(std::string liquid)
{
	to_lower_str(liquid);
	if(liquid == "none") return LIQUID_NONE;
	if(liquid == "water") return LIQUID_WATER;
	if(liquid == "blood") return LIQUID_BLOOD;
	if(liquid == "beer") return LIQUID_BEER;
	if(liquid == "slime") return LIQUID_SLIME;
	if(liquid == "lemonade") return LIQUID_LEMONADE;
	if(liquid == "milk") return LIQUID_MILK;
	if(liquid == "manafluid") return LIQUID_MANAFLUID;
	if(liquid == "lifefluid") return LIQUID_LIFEFLUID;
	if(liquid == "oil") return LIQUID_OIL;
	if(liquid == "urine") return LIQUID_URINE;
	if(liquid == "coconut milk") return LIQUID_COCONUT_MILK;
	if(liquid == "wine") return LIQUID_WINE;
	if(liquid == "mud") return LIQUID_MUD;
	if(liquid == "fruit juice") return LIQUID_FRUIT_JUICE;
	if(liquid == "lava") return LIQUID_LAVA;
	if(liquid == "rum") return LIQUID_RUM;
	if(liquid == "swamp") return LIQUID_SWAMP;
	return LIQUID_NONE;
}
예제 #5
0
파일: items.cpp 프로젝트: Codex-NG/rme
bool ItemDatabase::loadItemFromGameXml(pugi::xml_node itemNode, int id)
{
	ClientVersionID clientVersion = gui.GetCurrentVersionID();
	if(clientVersion < CLIENT_VERSION_980 && id > 20000 && id < 20100) {
		itemNode = itemNode.next_sibling();
		return true;
	} else if(id > 30000 && id < 30100) {
		itemNode = itemNode.next_sibling();
		return true;
	}

	ItemType& it = getItemType(id);

	it.name = itemNode.attribute("name").as_string();
	it.editorsuffix = itemNode.attribute("editorsuffix").as_string();

	pugi::xml_attribute attribute;
	for(pugi::xml_node itemAttributesNode = itemNode.first_child(); itemAttributesNode; itemAttributesNode = itemAttributesNode.next_sibling()) {
		if(!(attribute = itemAttributesNode.attribute("key"))) {
			continue;
		}

		std::string key = attribute.as_string();
		to_lower_str(key);
		if(key == "type") {
			if(!(attribute = itemAttributesNode.attribute("value"))) {
				continue;
			}

			std::string typeValue = attribute.as_string();
			to_lower_str(key);
			if(typeValue == "magicfield") {
				it.group = ITEM_GROUP_MAGICFIELD;
				it.type = ITEM_TYPE_MAGICFIELD;
			} else if(typeValue == "key") {
				it.type = ITEM_TYPE_KEY;
			} else if(typeValue == "depot") {
				it.type = ITEM_TYPE_DEPOT;
			} else if(typeValue == "teleport") {
				it.type = ITEM_TYPE_TELEPORT;
			} else if(typeValue == "bed") {
				it.type = ITEM_TYPE_BED;
			} else if(typeValue == "door") {
				it.type = ITEM_TYPE_DOOR;
			} else {
				// We ignore many types, no need to complain
				//warnings.push_back("items.xml: Unknown type " + typeValue);
			}
		} else if(key == "name") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.name = attribute.as_string();
			}
		} else if(key == "description") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.description = attribute.as_string();
			}
		}else if(key == "runespellName") {
			/*if((attribute = itemAttributesNode.attribute("value"))) {
				it.runeSpellName = attribute.as_string();
			}*/
		} else if(key == "weight") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.weight = pugi::cast<int32_t>(attribute.value()) / 100.f;
			}
		} else if(key == "armor") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.armor = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "defense") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.defense = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "rotateto") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.rotateTo = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "containersize") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.volume = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "readable") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.canReadText = attribute.as_bool();
			}
		} else if(key == "writeable") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.canWriteText = it.canReadText = attribute.as_bool();
			}
		} else if(key == "decayto") {
			it.decays = true;
		} else if(key == "maxtextlen" || key == "maxtextlength") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.maxTextLen = pugi::cast<int32_t>(attribute.value());
				it.canReadText = it.maxTextLen > 0;
			}
		} else if(key == "writeonceitemid") {
			/*if((attribute = itemAttributesNode.attribute("value"))) {
				it.writeOnceItemId = pugi::cast<int32_t>(attribute.value());
			}*/
		} else if(key == "allowdistread") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.allowDistRead = attribute.as_bool();
			}
		} else if(key == "charges") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.charges = pugi::cast<int32_t>(attribute.value());
				it.extra_chargeable = true;
			}
		}
	}
	return true;
}
예제 #6
0
static void
load_property (void *cls,
               const char *section)
{
  struct GNUNET_CONFIGURATION_Handle *properties = cls;
  struct SysmonProperty *sp;
  char *tmp;

  if (NULL == strstr (section, "sysmon-"))
    return;

  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading section `%s'\n", section);

  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section, "TYPE"))
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
        "TYPE", section);
    return;
  }
  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section,"VALUE"))
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
        "VALUE", section);
    return;
  }
  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section,"DESCRIPTION"))
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
        "DESCRIPTION", section);
    return;
  }
  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section,"CMD"))
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
        "CMD", section);
    return;
  }
  sp = GNUNET_malloc (sizeof (struct SysmonProperty));

  /* description */
  GNUNET_CONFIGURATION_get_value_string (properties, section, "DESCRIPTION", &sp->desc);

  /* cmd */
  GNUNET_CONFIGURATION_get_value_string (properties, section, "CMD", &tmp);
  char *args = "";
  if (NULL != strchr (tmp, ' '))
  {
      args = strchr (tmp, ' ');
      if (strlen (args) > 1)
      {
          args[0] = '\0';
          args++;
      }
  }
  sp->cmd = GNUNET_strdup (tmp);
  sp->cmd_args = GNUNET_strdup (args);
  GNUNET_free (tmp);
  sp->task = &exec_cmd;

  /* type */
  GNUNET_CONFIGURATION_get_value_string (properties, section, "TYPE", &tmp);
  to_lower_str (tmp);
  if (0 == strcasecmp(tmp, "static"))
    sp->type = t_static;
  else if (0 == strcasecmp(tmp, "continous"))
    sp->type = t_continous;
  else
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid value %s for %s in section `%s'\n",
        tmp, "TYPE", section);
    GNUNET_free (tmp);
    GNUNET_free (sp);
    return;
  }
  GNUNET_free (tmp);

  /* value */
  GNUNET_CONFIGURATION_get_value_string (properties, section, "VALUE", &tmp);
  to_lower_str (tmp);
  if (0 == strcasecmp(tmp, "numeric"))
    sp->value_type = v_numeric;
  else if (0 == strcasecmp(tmp, "string"))
    sp->value_type = v_string;
  else
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid value %s for %s in section `%s'\n",
        tmp, "VALUE", section);
    GNUNET_free (tmp);
    GNUNET_free (sp);
    return;
  }
  GNUNET_free (tmp);

  /* interval */
  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section,"INTERVAL"))
    sp->interval = GNUNET_TIME_UNIT_MINUTES;
  else
  {
    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (properties, section, "INTERVAL", &sp->interval))
    {
        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
            _("Could not parse execution interval for `%s', set to default 60 sec.\n"), section);
        sp->interval = GNUNET_TIME_UNIT_MINUTES;
    }
  }

  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded property `%s': %s, %s, interval %llu\n",
      (NULL != sp->desc) ? sp->desc: "<undefined>",
      (t_continous == sp->type) ? "continious" : "static",
      (v_numeric == sp->value_type) ? "numeric" : "string",
      sp->interval.rel_value);

  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);

}