Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ private List<PhotoData> parsePhotoList(ByteBuffer buffer) {
photoData.PhotoFilename = UnrealUtils.readString(buffer);

// skip time field
// unclear how this field works
// the first two bytes seem meaningful but the last two bytes are always 0x00 and 0x01
// possibly the game is bugged and is clobbering the last two bytes with other data
buffer.position(buffer.position() + 4);

photoData.Favorite = buffer.getInt() != 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.rcd47.x2data.lib.unreal.mapper;

class IXComRawStateObjectReferenceMapperFactory implements IUnrealFieldMapperFactory {

private Class<?> referencedObjectType;

IXComRawStateObjectReferenceMapperFactory(Class<?> referencedObjectType) {
this.referencedObjectType = referencedObjectType;
}

@Override
public IUnrealFieldMapper create(UnrealObjectMapperContext context, Object currentValue) {
return new IXComRawStateObjectReferenceMapper(context);
}

class IXComRawStateObjectReferenceMapper extends UnrealPrimitiveMapperBase {
IXComRawStateObjectReferenceMapper(UnrealObjectMapperContext context) {
super(context);
}

@Override
public void visitIntValue(int value) {
visitValue(context.referenceResolver.createStateReference(referencedObjectType, value));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComIndexObjectReference;
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComNameObjectReference;
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComObjectReferenceResolver;
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComRawStateObjectReference;
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComStateObjectReference;
import com.github.rcd47.x2data.lib.unreal.mappings.UnrealName;

Expand Down Expand Up @@ -94,6 +95,8 @@ private <E extends Enum<E>> IUnrealFieldMapperFactory getOrCreateMapperFactory(T
refFactory = new IXComNameObjectReferenceMapperFactory(referencedObjectType);
} else if (IXComStateObjectReference.class.equals(rawClass)) {
refFactory = new IXComStateObjectReferenceMapperFactory(referencedObjectType);
} else if (IXComRawStateObjectReference.class.equals(rawClass)) {
refFactory = new IXComRawStateObjectReferenceMapperFactory(referencedObjectType);
} else if (IXComIndexObjectReference.class.equals(rawClass)) {
refFactory = new IXComIndexObjectReferenceMapperFactory(referencedObjectType);
} else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public interface IXComObjectReferenceResolver {

<T> IXComStateObjectReference<T> createStateReference(Class<T> referencedObjectType, int objectId);

<T> IXComRawStateObjectReference<T> createRawStateReference(Class<T> referencedObjectType, int objectId);

<T> IXComNameObjectReference<T> createNameReference(Class<T> referencedObjectType, UnrealName objectName);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.github.rcd47.x2data.lib.unreal.mapper.ref;

/**
* Sometimes, state objects just have an int field to point to another state object instead of using StateObjectReference.
*/
public interface IXComRawStateObjectReference<T> extends IXComObjectReference<T> {

int id();

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ public int id() {
};
}

@Override
public <T> IXComRawStateObjectReference<T> createRawStateReference(Class<T> referencedObjectType, int objectId) {
return new IXComRawStateObjectReference<T>() {
@Override
public T get() {
return null;
}

@Override
public int id() {
return objectId;
}
};
}

@Override
public <T> IXComNameObjectReference<T> createNameReference(Class<T> referencedObjectType, UnrealName objectName) {
return new IXComNameObjectReference<T>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

import java.util.List;

import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComStateObjectReference;

public class ReserveSquad {

public List<IXComStateObjectReference<XComGameState_Unit>> SquadMembers;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class TDateTime {

public float m_fTime;
public int m_iDay;
public int m_iMonth;
public int m_iYear;

public LocalDateTime toLocalDateTime() {
return LocalDateTime.of(LocalDate.of(m_iYear, m_iMonth, m_iDay), LocalTime.ofSecondOfDay((int) m_fTime));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

public class X2ContinentTemplate extends X2StrategyElementTemplate {

public String DisplayName;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

public class X2WorldRegionTemplate extends X2StrategyElementTemplate {

public String DisplayName;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComRawStateObjectReference;
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComStateObjectReference;
import com.github.rcd47.x2data.lib.unreal.mappings.UnrealName;

Expand All @@ -15,8 +16,12 @@ public class XComGameState_BattleData extends XComGameState_BaseObject {
public DirectTransferInformation DirectTransferInfo;
public List<UnrealName> DisallowedAbilities;
public List<UnrealName> HighlightedObjectiveAbilities;
public TDateTime LocalTime;
public List<UnrealName> LostSwarmIDs;
public List<Integer> m_arrSecondWave;
public IXComRawStateObjectReference<XComGameState_MissionSite> m_iMissionID;
public String m_strDesc;
public String m_strLocation;
public String m_strOpName;
public List<Integer> MaxLostSpawnTurnCooldown;
public List<Integer> MinLostSpawnTurnCooldown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class XComGameState_CampaignSettings extends XComGameState_BaseObject {

public List<UnrealName> EnabledOptionalNarrativeDLC;
public int GameIndex;
public List<UnrealName> RequiredDLC;
public List<UnrealName> SecondWaveOptions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

import java.util.List;

import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComNameObjectReference;
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComStateObjectReference;

public class XComGameState_Continent extends XComGameState_GeoscapeEntity {

public List<IXComStateObjectReference<XComGameState_WorldRegion>> Regions;
public IXComNameObjectReference<X2ContinentTemplate> m_TemplateName;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

public class XComGameState_GeoscapeEntity extends XComGameState_BaseObject {
import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComStateObjectReference;

public class XComGameState_GeoscapeEntity extends XComGameState_BaseObject {

public IXComStateObjectReference<XComGameState_Continent> Continent;
public IXComStateObjectReference<XComGameState_WorldRegion> Region;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
import java.util.List;
import java.util.Map;

import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComStateObjectReference;
import com.github.rcd47.x2data.lib.unreal.mappings.UnrealName;
import com.github.rcd47.x2data.lib.unreal.mappings.UnrealUntypedProperty;

public class XComGameState_HeadquartersXCom extends XComGameState_Airship {

public List<ReserveSquad> AllSquads;
public List<GeneratedMissionData> arrGeneratedMissionData;
public List<IXComStateObjectReference<XComGameState_Unit>> Crew;
public List<HQOrder> CurrentOrders;
public List<Integer> EverAcquiredInventoryCounts;
public List<UnrealName> EverAcquiredInventoryTypes;
public List<UnrealName> ExtraUpgradeWeaponCats;
@UnrealUntypedProperty(1)
public Map<String, Integer> GenericKVP;
public List<IXComStateObjectReference<XComGameState_Item>> Inventory;
public List<PendingFacilityDiscount> PendingFacilityDiscounts;
public List<AmbientNarrativeInfo> PlayedAmbientNarrativeMoments;
public List<UnrealName> PlayedAmbientSpeakers;
Expand All @@ -32,6 +35,7 @@ public class XComGameState_HeadquartersXCom extends XComGameState_Airship {
public List<UnrealName> SoldierClassDeck;
public List<SoldierClassCount> SoldierClassDistribution;
public List<UnrealName> SoldierUnlockTemplates;
public List<IXComStateObjectReference<XComGameState_Unit>> Squad;
public List<UnrealName> TacticalGameplayTags;
public List<UnrealName> UnlockedItems;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.github.rcd47.x2data.lib.unreal.mappings.base;

import com.github.rcd47.x2data.lib.unreal.mapper.ref.IXComNameObjectReference;

public class XComGameState_WorldRegion extends XComGameState_ScanningSite {

public IXComNameObjectReference<X2WorldRegionTemplate> m_TemplateName;

}