mirror of https://github.com/FreeCol/freecol.git
0.10.x compat removal: Drop role compatibility code.
This commit is contained in:
parent
6397379897
commit
14bc672fe1
|
@ -52,7 +52,7 @@
|
|||
<xs:element name="abstractUnit">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="UnitTypeId" use="required"/>
|
||||
<xs:attribute name="role" type="xs:string" use="required"/>
|
||||
<xs:attribute name="role" type="RoleId" use="required"/>
|
||||
<xs:attribute name="number" type="xs:int" use="optional"
|
||||
default="1"/>
|
||||
</xs:complexType>
|
||||
|
|
|
@ -999,22 +999,6 @@ public class FreeColXMLReader extends StreamReaderDelegate
|
|||
: spec.getType(attrib, returnClass);
|
||||
}
|
||||
|
||||
// @compat 0.10.7
|
||||
public <T extends FreeColSpecObjectType> T getRole(Specification spec,
|
||||
String attributeName, Class<T> returnClass, T defaultValue) {
|
||||
|
||||
String attrib =
|
||||
(FreeColObject.ID_ATTRIBUTE_TAG.equals(attributeName)) ? readId() :
|
||||
getAttribute(attributeName, (String)null);
|
||||
|
||||
if (attrib == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
attrib = Role.fixRoleId(attrib);
|
||||
return spec.getType(attrib, returnClass);
|
||||
}
|
||||
// end @compat
|
||||
|
||||
/**
|
||||
* Copy a FreeColObject by serializing it and reading back the result
|
||||
* with a non-interning stream.
|
||||
|
|
|
@ -241,9 +241,6 @@ public class AbstractUnit extends FreeColObject {
|
|||
super.readAttributes(xr);
|
||||
|
||||
roleId = xr.getAttribute(ROLE_TAG, Specification.DEFAULT_ROLE_ID);
|
||||
// @compat 0.10.7
|
||||
roleId = Role.fixRoleId(roleId);
|
||||
// end @compat
|
||||
|
||||
number = xr.getAttribute(NUMBER_TAG, 1);
|
||||
}
|
||||
|
|
|
@ -251,10 +251,6 @@ public class EuropeanNationType extends NationType {
|
|||
String roleId = xr.getAttribute(ROLE_TAG,
|
||||
Specification.DEFAULT_ROLE_ID);
|
||||
|
||||
// @compat 0.10.7
|
||||
roleId = Role.fixRoleId(roleId);
|
||||
// end @compat
|
||||
|
||||
boolean ex = xr.getAttribute(EXPERT_STARTING_UNITS_TAG, false);
|
||||
|
||||
addStartingUnit(id, new AbstractUnit(type, roleId, 1), ex);
|
||||
|
|
|
@ -220,29 +220,6 @@ public class Force extends FreeColSpecObject {
|
|||
(naval) ? this.navalUnits : this.landUnits);
|
||||
}
|
||||
|
||||
// @compat 0.10.x
|
||||
public void fixOldREFRoles() {
|
||||
Iterator<AbstractUnit> aui = landUnits.iterator();
|
||||
List<AbstractUnit> todo = new ArrayList<>();
|
||||
while (aui.hasNext()) {
|
||||
AbstractUnit au = aui.next();
|
||||
if ("SOLDIER".equals(au.getRoleId())
|
||||
|| "model.role.soldier".equals(au.getRoleId())) {
|
||||
au.setRoleId("model.role.infantry");
|
||||
aui.remove();
|
||||
todo.add(au);
|
||||
} else if ("DRAGOON".equals(au.getRoleId())
|
||||
|| "model.role.dragoon".equals(au.getRoleId())) {
|
||||
au.setRoleId("model.role.cavalry");
|
||||
aui.remove();
|
||||
todo.add(au);
|
||||
}
|
||||
}
|
||||
while (!todo.isEmpty()) add(todo.remove(0));
|
||||
updateSpaceAndCapacity();
|
||||
}
|
||||
// end @compat 0.10.x
|
||||
|
||||
|
||||
// Serialization
|
||||
|
||||
|
|
|
@ -774,48 +774,6 @@ public final class Monarch extends FreeColGameObject implements Named {
|
|||
}
|
||||
|
||||
|
||||
// Override FreeColGameObject
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int checkIntegrity(boolean fix) {
|
||||
int result = super.checkIntegrity(fix);
|
||||
// @compat 0.10.x
|
||||
// Detects/fixes bogus expeditionary force roles
|
||||
List<AbstractUnit> todo = new ArrayList<>();
|
||||
Force ref = getExpeditionaryForce();
|
||||
Iterator<AbstractUnit> it = ref.getLandUnitsList().iterator();
|
||||
while (it.hasNext()) {
|
||||
AbstractUnit au = it.next();
|
||||
if ("model.role.soldier".equals(au.getRoleId())) {
|
||||
if (fix) {
|
||||
au.setRoleId("model.role.infantry");
|
||||
result = 0;
|
||||
it.remove();
|
||||
todo.add(au);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if ("model.role.dragoon".equals(au.getRoleId())) {
|
||||
if (fix) {
|
||||
au.setRoleId("model.role.cavalry");
|
||||
result = 0;
|
||||
it.remove();
|
||||
todo.add(au);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AbstractUnit au : todo) ref.add(au);
|
||||
// end @compat 0.10.x
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Serialization
|
||||
|
||||
private static final String DISPLEASURE_TAG = "displeasure";
|
||||
|
@ -900,9 +858,6 @@ public final class Monarch extends FreeColGameObject implements Named {
|
|||
|
||||
if (EXPEDITIONARY_FORCE_TAG.equals(tag)) {
|
||||
expeditionaryForce.readFromXML(xr);
|
||||
// @compat 0.11.3
|
||||
expeditionaryForce.fixOldREFRoles();
|
||||
// end @compat 0.11.3
|
||||
|
||||
} else if (INTERVENTION_FORCE_TAG.equals(tag)) {
|
||||
interventionForce.readFromXML(xr);
|
||||
|
|
|
@ -142,21 +142,6 @@ public class Role extends BuildableType {
|
|||
return lastPart(roleId, ".");
|
||||
}
|
||||
|
||||
// @compat 0.10.7
|
||||
/**
|
||||
* Fix a role id.
|
||||
*
|
||||
* @param roleId The role id to fix.
|
||||
* @return The fixed role id.
|
||||
*/
|
||||
public static String fixRoleId(String roleId) {
|
||||
if (roleId.indexOf('.') < 0) {
|
||||
roleId = "model.role." + roleId.toLowerCase(Locale.US);
|
||||
}
|
||||
return roleId;
|
||||
}
|
||||
// end @compat
|
||||
|
||||
/**
|
||||
* Get the downgraded role from this one.
|
||||
*
|
||||
|
|
|
@ -4414,47 +4414,9 @@ public class Unit extends GoodsLocation
|
|||
|
||||
state = xr.getAttribute(STATE_TAG, UnitState.class, UnitState.ACTIVE);
|
||||
|
||||
role = xr.getRole(spec, ROLE_TAG, Role.class,
|
||||
spec.getDefaultRole());
|
||||
// @compat 0.10.x
|
||||
// Fix roles
|
||||
if (owner.isIndian()) {
|
||||
if ("model.role.scout".equals(role.getId())) {
|
||||
role = spec.getRole("model.role.mountedBrave");
|
||||
} else if ("model.role.soldier".equals(role.getId())) {
|
||||
role = spec.getRole("model.role.armedBrave");
|
||||
} else if ("model.role.dragoon".equals(role.getId())) {
|
||||
role = spec.getRole("model.role.nativeDragoon");
|
||||
}
|
||||
} else if (owner.isREF()) {
|
||||
if ("model.role.soldier".equals(role.getId())
|
||||
&& unitType.hasAbility(Ability.REF_UNIT)) {
|
||||
role = spec.getRole("model.role.infantry");
|
||||
} else if ("model.role.dragoon".equals(role.getId())
|
||||
&& unitType.hasAbility(Ability.REF_UNIT)) {
|
||||
role = spec.getRole("model.role.cavalry");
|
||||
} else if ("model.role.infantry".equals(role.getId())
|
||||
&& !unitType.hasAbility(Ability.REF_UNIT)) {
|
||||
role = spec.getRole("model.role.soldier");
|
||||
} else if ("model.role.cavalry".equals(role.getId())
|
||||
&& !unitType.hasAbility(Ability.REF_UNIT)) {
|
||||
role = spec.getRole("model.role.dragoon");
|
||||
}
|
||||
} else {
|
||||
if ("model.role.infantry".equals(role.getId())) {
|
||||
role = spec.getRole("model.role.soldier");
|
||||
} else if ("model.role.cavalry".equals(role.getId())) {
|
||||
role = spec.getRole("model.role.dragoon");
|
||||
}
|
||||
}
|
||||
// end @compat 0.10.x
|
||||
role = xr.getType(spec, ROLE_TAG, Role.class, spec.getDefaultRole());
|
||||
|
||||
roleCount = xr.getAttribute(ROLE_COUNT_TAG,
|
||||
// @compat 0.10.x
|
||||
-1
|
||||
// Should be role.getMaximumCount()
|
||||
// end @compat 0.10.x
|
||||
);
|
||||
roleCount = xr.getAttribute(ROLE_COUNT_TAG, role.getMaximumCount());
|
||||
|
||||
setLocationNoUpdate(xr.getLocationAttribute(game, LOCATION_TAG, true));
|
||||
|
||||
|
|
Loading…
Reference in New Issue