Ejemplo n.º 1
0
bool XML_ItemParser::HandleAttribute(const char *Tag, const char *Value)
{
	if (StringsEqual(Tag,"index"))
	{
		if (ReadBoundedInt16Value(Value,Index,0,NUMBER_OF_DEFINED_ITEMS-1))
		{
			IndexPresent = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"singular"))
	{
		if (ReadInt16Value(Value,Data.singular_name_id))
		{
			IsPresent[0] = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"plural"))
	{
		if (ReadInt16Value(Value,Data.plural_name_id))
		{
			IsPresent[1] = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"maximum"))
	{
		if (ReadBoundedInt16Value(Value,Data.maximum_count_per_player,0,SHRT_MAX))
		{
			IsPresent[2] = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"invalid"))
	{
		if (ReadInt16Value(Value,Data.invalid_environments))
		{
			IsPresent[3] = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"type"))
	{
		if (ReadBoundedInt16Value(Value,Data.item_kind,0,NUMBER_OF_ITEM_TYPES))
		{
			IsPresent[4] = true;
			return true;
		}
		else return false;
	}
	UnrecognizedTag();
	return false;
}
Ejemplo n.º 2
0
bool XML_LineWidthParser::HandleAttribute(const char *Tag, const char *Value)
{
	if (StringsEqual(Tag,"type"))
	{
		// The permissible values, 0, 1, and 2, are line, elevation, and control panel
		if (ReadBoundedInt16Value(Value,Type,0,NUMBER_OF_LINE_DEFINITIONS-1))
		{
			IsPresent[0] = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"scale"))
	{
		if (ReadBoundedInt16Value(Value,Scale,0,OVERHEAD_MAP_MAXIMUM_SCALE-OVERHEAD_MAP_MINIMUM_SCALE))
		{
			IsPresent[1] = true;
			return true;
		}
		else return false;
	}
	else if (StringsEqual(Tag,"width"))
	{
		if (ReadInt16Value(Value,Width))
		{
			IsPresent[2] = true;
			return true;
		}
		else return false;
	}
	UnrecognizedTag();
	return false;
}
bool XML_LandscapeParser::HandleAttribute(const char *Tag, const char *Value)
{
    if (StringsEqual(Tag,"coll"))
    {
        if (ReadBoundedInt16Value(Value,Collection,short(AnyFrame),short(NUMBER_OF_COLLECTIONS-1)))
        {
            IsPresent = true;
            return true;
        }
        else return false;
    }
    else if (StringsEqual(Tag,"frame"))
    {
        return ReadBoundedInt16Value(Value,Frame,0,MAXIMUM_SHAPES_PER_COLLECTION-1);
    }
    else if (StringsEqual(Tag,"horiz_exp"))
    {
        return ReadInt16Value(Value,Data.HorizExp);
    }
    else if (StringsEqual(Tag,"vert_exp"))
    {
        return ReadInt16Value(Value,Data.VertExp);
    }
    else if (StringsEqual(Tag,"vert_repeat"))
    {
        return ReadBooleanValueAsBool(Value,Data.VertRepeat);
    }
    else if (StringsEqual(Tag,"ogl_asprat_exp"))
    {
        return ReadInt16Value(Value,Data.OGL_AspRatExp);
    }
    else if (StringsEqual(Tag,"azimuth"))
    {
        float Azimuth;
        if (ReadFloatValue(Value,Azimuth))
        {
            Azimuth = Azimuth - 360*int(Azimuth/360);
            if (Azimuth < 0) Azimuth += 360;
            Data.Azimuth = angle(FULL_CIRCLE*(Azimuth/360) + 0.5);
            return true;
        }
        return false;
    }
    UnrecognizedTag();
    return false;
}
Ejemplo n.º 4
0
bool XML_StringParser::HandleAttribute(const char *Tag, const char *Value)
{
  if (StringsEqual(Tag,"index")) {
    if (ReadInt16Value(Value,Index)) {
      IndexPresent = true;
      return true;
    }
    else{ return false; }
  }
  UnrecognizedTag();
  return false;
}
Ejemplo n.º 5
0
bool XML_OvhdMapParser::HandleAttribute(const char *Tag, const char *Value)
{
  if (StringsEqual(Tag,"mode")) {
    return ReadBoundedInt16Value(Value,OverheadMapMode,0,
                                 NUMBER_OF_OVERHEAD_MAP_MODES-1);
  }
  else if (StringsEqual(Tag,"title_offset")) {
    return ReadInt16Value(Value,OvhdMap_ConfigData.map_name_data.offset_down);
  }
  UnrecognizedTag();
  return false;
}
Ejemplo n.º 6
0
bool XML_StringSetParser::HandleAttribute(const char *Tag, const char *Value)
{
  if (StringsEqual(Tag,"index")) {
    short ID;
    if (ReadInt16Value(Value,ID)) {
      CurrStringSet = FindStringSet(ID);
      return true;
    }
    else{ return false; }
  }
  UnrecognizedTag();
  return false;
}
Ejemplo n.º 7
0
bool XML_ShaderParser::HandleAttribute(const char *Tag, const char *Value) {
  if(StringsEqual(Tag,"name")) {
    _name = Value;
    return true;
  }
  else if(StringsEqual(Tag,"vert")) {
    _vert.SetNameWithPath(Value);
    return true;
  }
  else if(StringsEqual(Tag,"frag")) {
    _frag.SetNameWithPath(Value);
    return true;
  }
  else if(StringsEqual(Tag,"passes")) {
    return ReadInt16Value(Value,_passes);
  }
  UnrecognizedTag();
  return true;
};
Ejemplo n.º 8
0
bool XML_KeyParser::HandleAttribute(const char *Tag, const char *Value)
{
	if (StringsEqual(Tag,"index"))
	{
		if (ReadBoundedInt16Value(Value,Index,0,NUMBER_OF_STANDARD_KEY_DEFINITIONS-1))
		{
			IsPresent[0] = true;
			return true;
		}
		else return false;
	}
	// Select whether to accept a SDL or a Macintosh key definition
#ifdef SDL
	else if (StringsEqual(Tag,"sdl"))
#else
	else if (StringsEqual(Tag,"mac"))
#endif
	{
		if (ReadInt16Value(Value,Key))
		{
			IsPresent[1] = true;
			return true;
		}
		else return false;
	}
	// Do nothing in case of the opposite sort of key
#ifdef SDL
	else if (StringsEqual(Tag,"mac"))
#else
	else if (StringsEqual(Tag,"sdl"))
#endif
	{
		// OK no matter what
		return true;
	}
	UnrecognizedTag();
	return false;
}
Ejemplo n.º 9
0
bool XML_ModelDataParser::HandleAttribute(const char *Tag, const char *Value)
{
  if (StringsEqual(Tag,"coll")) {
    if (ReadBoundedInt16Value(Value,Collection,0,NUMBER_OF_COLLECTIONS-1)) {
      CollIsPresent = true;
      return true;
    }
    else{ return false; }
  }
  else if (StringsEqual(Tag,"seq")) {
    return (ReadBoundedInt16Value(Value,Sequence,0,
                                  MAXIMUM_SHAPES_PER_COLLECTION-1));
  }
  else if (StringsEqual(Tag,"scale")) {
    return ReadFloatValue(Value,Data.Scale);
  }
  else if (StringsEqual(Tag,"x_rot")) {
    return ReadFloatValue(Value,Data.XRot);
  }
  else if (StringsEqual(Tag,"y_rot")) {
    return ReadFloatValue(Value,Data.YRot);
  }
  else if (StringsEqual(Tag,"z_rot")) {
    return ReadFloatValue(Value,Data.ZRot);
  }
  else if (StringsEqual(Tag,"x_shift")) {
    return ReadFloatValue(Value,Data.XShift);
  }
  else if (StringsEqual(Tag,"y_shift")) {
    return ReadFloatValue(Value,Data.YShift);
  }
  else if (StringsEqual(Tag,"z_shift")) {
    return ReadFloatValue(Value,Data.ZShift);
  }
  else if (StringsEqual(Tag,"side")) {
    return ReadInt16Value(Value,Data.Sidedness);
  }
  else if (StringsEqual(Tag,"norm_type")) {
    return ReadBoundedInt16Value(Value,Data.NormalType,0,
                                 Model3D::NUMBER_OF_NORMAL_TYPES-1);
  }
  else if (StringsEqual(Tag,"norm_split")) {
    return ReadFloatValue(Value,Data.NormalSplit);
  }
  else if (StringsEqual(Tag,"light_type")) {
    return ReadBoundedInt16Value(Value,Data.LightType,0,
                                 NUMBER_OF_MODEL_LIGHT_TYPES-1);
  }
  else if (StringsEqual(Tag,"depth_type")) {
    return ReadInt16Value(Value,Data.DepthType);
  }
  else if (StringsEqual(Tag,"force_sprite_depth")) {
    return ReadBooleanValue(Value,Data.ForceSpriteDepth);
  }
  else if (StringsEqual(Tag,"file")) {
    Data.ModelFile.SetNameWithPath(Value);
    return true;
  }
  else if (StringsEqual(Tag,"file1")) {
    Data.ModelFile1.SetNameWithPath(Value);
    return true;
  }
  else if (StringsEqual(Tag,"file2")) {
    Data.ModelFile2.SetNameWithPath(Value);
    return true;
  }
  else if (StringsEqual(Tag,"type")) {
    size_t nchars = strlen(Value)+1;
    Data.ModelType.resize(nchars);
    memcpy(&Data.ModelType[0],Value,nchars);
    return true;
  }
  UnrecognizedTag();
  return false;
}