Skip to content
Open
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
6 changes: 5 additions & 1 deletion code/src/java/pcgen/core/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ public static Campaign getCampaignKeyed(final String aKey)
final Campaign campaign = getCampaignKeyedSilently(aKey);
if (campaign == null)
{
Logging.errorPrint("Could not find campaign: " + aKey);
Logging.errorPrint("Could not find campaign: " + aKey
+ " - no loaded .pcc file declares CAMPAIGN:" + aKey + "."
+ " If this is third-party (non-OGL) data, install the .pcc into the"
+ " vendor data dir (" + PCGenSettings.getVendorDataDir()
+ ") or homebrew data dir (" + PCGenSettings.getHomebrewDataDir() + ").");
}

return campaign;
Expand Down
15 changes: 15 additions & 0 deletions code/src/java/pcgen/core/PlayerCharacter.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
import pcgen.core.analysis.ChooseActivation;
import pcgen.core.analysis.DomainApplication;
import pcgen.core.analysis.RaceUtilities;
import pcgen.core.analysis.SizeUtilities;
import pcgen.core.analysis.SkillModifier;
import pcgen.core.analysis.SkillRankControl;
import pcgen.core.analysis.SpellCountCalc;
Expand Down Expand Up @@ -542,6 +543,20 @@ private PlayerCharacter(PlayerCharacter from)
public PlayerCharacter(Collection<Campaign> loadedCampaigns)
{
LoadContext context = Globals.getContext();
// Fail fast on a half-loaded dataset: without a SizeAdjustment flagged
// ISDEFAULTSIZE:YES, damage scaling, equipment sizing and the size facet
// would all NPE deep in facet wiring.
if (SizeUtilities.getDefaultSizeAdjustment() == null)
{
String gameModeName = SettingsHandler.getGameAsProperty().get().getName();
Logging.errorPrint("Game mode '" + gameModeName
+ "' has no default size: no SizeAdjustment was loaded with ISDEFAULTSIZE:YES."
+ " Sizes are typically defined in a *__sizes.lst file inside the gamemode's"
+ " Core Rules data source (e.g. data/pathfinder/.../core_essentials/ce__sizes.lst)."
+ " Exactly one size in that file must be flagged ISDEFAULTSIZE:YES.");
throw new IllegalStateException("Game mode '" + gameModeName
+ "' has no default size. Check earlier log errors for the missing data source.");
}
id = CharID.getID(context.getDataSetID());
AbstractReferenceContext refContext = context.getReferenceContext();
controller = refContext.constructNowIfNecessary(CodeControl.class, "Controller");
Expand Down
11 changes: 10 additions & 1 deletion code/src/java/pcgen/persistence/lst/LstObjectFileLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Observable;
import java.util.Optional;
import java.util.Set;

import pcgen.cdom.base.CDOMObject;
Expand Down Expand Up @@ -281,7 +282,15 @@ protected void loadLstFile(LoadContext context, CampaignSourceEntry sourceEntry)
String aString;
try
{
aString = LstFileLoader.readFromURI(uri).get();
// readFromURI returns Optional.empty() when it logs a non-fatal IO/decode error
// (e.g. a non-UTF-8 .lst). Skip the file rather than aborting the whole load.
Optional<String> read = LstFileLoader.readFromURI(uri);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karianna, I gave a chance to @Nylanfs to load files that are non-UTF-8.
Previously, the loading failed, and the logs wrote that a non-UTF-8 file was detected (from BahamutDragon/pcgen repo).
Now we load the campaign, but it can be barely playable, because not all files were in a proper codepage.

But if you prefer us to be stricter (I like it, actually), I can revert this part. I don't want to have a situation, where PCGen has to assume a lot, when a human can correct an error...

if (read.isEmpty())
{
setChanged();
return;
}
aString = read.get();
}
catch (PersistenceLayerException ple)
{
Expand Down
16 changes: 16 additions & 0 deletions code/src/java/pcgen/system/CharacterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ private CharacterManager()
*/
public static CharacterFacade createNewCharacter(UIDelegate delegate, DataSetFacade dataset)
{
if (dataset == null)
{
Logging.errorPrint("Unable to create character: data sources failed to load (see earlier errors)");
delegate.showErrorMessage(LanguageBundle.getString("in_cmCreateErrorTitle"),
LanguageBundle.getFormattedString("in_cmCreateErrorMessage",
"data sources failed to load - see earlier errors in the log"));
return null;
}
@SuppressWarnings("rawtypes")
List campaigns = ListFacades.wrap(dataset.getCampaigns());
try
Expand Down Expand Up @@ -169,6 +177,14 @@ public static PlayerCharacter openPlayerCharacter(File file, UIDelegate delegate
private static PlayerCharacter openPcInternal(File file, UIDelegate delegate, DataSetFacade dataset,
boolean blockLoadedMessage)
{
if (dataset == null)
{
Logging.errorPrint("Unable to load character " + file + ": data sources failed to load (see earlier errors)");
delegate.showErrorMessage(LanguageBundle.getString("in_cmLoadErrorTitle"),
LanguageBundle.getFormattedString("in_cmLoadErrorMessage",
file, "data sources failed to load - see earlier errors in the log"));
return null;
}
@SuppressWarnings("rawtypes")
List campaigns = ListFacades.wrap(dataset.getCampaigns());
try
Expand Down
Loading