Compare commits

..

2 Commits

Author SHA1 Message Date
OMGeeky
c10f5006a7 remove some more usages
these ones look kinda weird in my diff view. idk
2024-09-11 21:15:17 +02:00
OMGeeky
0e56e59d06 remove usages in data 2024-09-11 21:10:31 +02:00
389 changed files with 125621 additions and 288331 deletions

View File

@@ -3,8 +3,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gpl.rpg.AndorsTrail"
android:versionCode="80"
android:versionName="0.8.13dev"
android:versionCode="78"
android:versionName="0.8.12dev"
android:installLocation="auto"
>

View File

@@ -28,11 +28,11 @@ public final class AndorsTrailApplication extends Application {
public static final boolean DEVELOPMENT_FASTSPEED = false;
public static final boolean DEVELOPMENT_VALIDATEDATA = true;
public static final boolean DEVELOPMENT_DEBUGMESSAGES = true;
public static final String CURRENT_VERSION_DISPLAY = "0.8.13dev";
public static final String CURRENT_VERSION_DISPLAY = "0.8.12dev";
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED || !IS_RELEASE_VERSION;
public static final int DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 81;
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 78;
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
private WorldContext world = new WorldContext();

View File

@@ -38,10 +38,6 @@ public final class ActorConditionInfoActivity extends AndorsTrailBaseActivity {
tv.setText(conditionType.name);
world.tileManager.setImageViewTile(getResources(), tv, conditionType);
TextView descriptionTv = (TextView) findViewById(R.id.actorconditioninfo_description);
if(conditionType.description != null && !conditionType.description.isEmpty()) descriptionTv.setText(conditionType.description);
else descriptionTv.setVisibility(View.GONE);
Button b = (Button) findViewById(R.id.actorconditioninfo_close);
b.setOnClickListener(new OnClickListener() {
@Override

View File

@@ -387,35 +387,35 @@ public final class DebugInterface {
,new DebugButton("#5", new OnClickListener() {
@Override
public void onClick(View arg0) {
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "waytogalmore1", "entrance2", 0, 0);
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "island1", "south2", 0, 0);
}
})
,new DebugButton("#6", new OnClickListener() {
@Override
public void onClick(View arg0) {
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "galmore_32", "south", 19, 0);
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "laerothmanor1", "down2", 0, 0);
}
})
,new DebugButton("#7", new OnClickListener() {
@Override
public void onClick(View arg0) {
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "cabin_norcity_road1", "north", 5, 0);
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "final_cave1", "up", 0, 0);
}
})
,new DebugButton("#8", new OnClickListener() {
@Override
public void onClick(View arg0) {
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "galmore_86", "west", 0, 5);
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "bwmfill3", "north2", 0, 0);
}
})
,new DebugButton("#9", new OnClickListener() {
@Override
public void onClick(View arg0) {
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "galmore_68", "north", 5, 0);
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "island2", "down", 0, 0);
}
})

View File

@@ -1,6 +1,5 @@
package com.gpl.rpg.AndorsTrail.context;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionTypeCollection;
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
@@ -14,8 +13,6 @@ import com.gpl.rpg.AndorsTrail.resource.ConversationLoader;
import com.gpl.rpg.AndorsTrail.resource.VisualEffectCollection;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
import java.security.DigestException;
public final class WorldContext {
//Objectcollections
public final ConversationLoader conversationLoader;
@@ -65,11 +62,4 @@ public final class WorldContext {
public void resetForNewGame() {
maps.resetForNewGame();
}
public byte[] getChecksum() throws DigestException {
ChecksumBuilder checksumBuilder = new ChecksumBuilder();
model.addToChecksum(checksumBuilder);
maps.addToChecksum(checksumBuilder, this);
return checksumBuilder.build();
}
}

View File

@@ -76,7 +76,8 @@ public final class ActorStatsController {
c.magnitude -= magnitude;
actorConditionListeners.onActorConditionMagnitudeChanged(actor, c);
} else {
actorConditionsRemove(actor, c, i);
actor.conditions.remove(i);
actorConditionListeners.onActorConditionRemoved(actor, c);
}
break;
}
@@ -231,9 +232,9 @@ public final class ActorStatsController {
public void removeAllTemporaryConditions(final Actor actor) {
for(int i = actor.conditions.size() - 1; i >= 0; --i) {
ActorCondition c = actor.conditions.get(i);
if (c.isTemporaryEffect() || c.isDurationForeverUntilSleep()) {
actorConditionsRemove(actor, c, i);
}
if (!c.isTemporaryEffect()) continue;
actor.conditions.remove(i);
actorConditionListeners.onActorConditionRemoved(actor, c);
}
}
@@ -241,7 +242,8 @@ public final class ActorStatsController {
for(int i = actor.conditions.size() - 1; i >= 0; --i) {
ActorCondition c = actor.conditions.get(i);
if (!c.conditionType.conditionTypeID.equals(conditionTypeID)) continue;
actorConditionsRemove(actor, c, i);
actor.conditions.remove(i);
actorConditionListeners.onActorConditionRemoved(actor, c);
}
}
@@ -404,14 +406,14 @@ public final class ActorStatsController {
ActorCondition c = actor.conditions.get(i);
if (!c.isTemporaryEffect()) continue;
if (c.duration <= 1) {
actorConditionsRemove(actor, c, i);
actor.conditions.remove(i);
actorConditionListeners.onActorConditionRemoved(actor, c);
removedAnyConditions = true;
} else {
c.duration -= 1;
actorConditionListeners.onActorConditionDurationChanged(actor, c);
}
}
// Immunities
for(int i = actor.immunities.size() - 1; i >= 0; --i) {
ActorCondition c = actor.immunities.get(i);
if (!c.isTemporaryEffect()) continue;
@@ -455,50 +457,6 @@ public final class ActorStatsController {
}
}
int actorConditionsRemove(Actor actor, ActorCondition c, int i) {
int magnitude = 0; //default: No condition from worn items
if (actor instanceof Player) {
Player player = (Player) actor;
magnitude = gotConditionFromWornItem(player, c);
if (magnitude > 0) { //condition from worn items?
c.magnitude = magnitude; // -> readd condition
actorConditionListeners.onActorConditionMagnitudeChanged(actor, c);
c.duration = ActorCondition.DURATION_FOREVER;
actorConditionListeners.onActorConditionDurationChanged(actor, c);
}
}
if (magnitude == 0) {
actor.conditions.remove(i);
actorConditionListeners.onActorConditionRemoved(actor, c);
}
return magnitude;
}
int gotConditionFromWornItem(Player player, ActorCondition c) {
int magnitude = 0; //Default: No worn item with this condition
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
ItemType t = player.inventory.getItemTypeInWearSlot(slot);
if (t == null) continue;
ItemTraits_OnEquip equipEffects = t.effects_equip;
if (equipEffects == null) continue;
if (equipEffects.addedConditions == null) continue;
for (ActorConditionEffect e : equipEffects.addedConditions) {
if (e.conditionType.conditionTypeID.equals(c.conditionType.conditionTypeID)) {
if (e.magnitude == ActorCondition.MAGNITUDE_REMOVE_ALL) {
return 0; //On an item-based immunity the result is always 0
}
if (magnitude < e.magnitude) {
magnitude = e.magnitude;
}
}
}
}
return magnitude;
}
public void applyUseEffect(Actor source, Actor target, ItemTraits_OnUse effect) {
if (effect == null) return;

View File

@@ -21,21 +21,14 @@ import com.gpl.rpg.AndorsTrail.util.Coord;
import com.gpl.rpg.AndorsTrail.util.CoordRect;
import com.gpl.rpg.AndorsTrail.util.Size;
import java.util.ArrayList;
import java.util.List;
public final class VisualEffectController {
private static final long EFFECT_UPDATE_INTERVAL = 25;
private int effectCount = 0;
private final ControllerContext controllers;
private final WorldContext world;
private final VisualEffectCollection effectTypes;
private final Handler animationHandler = new Handler();
private final List<VisualEffectAnimation> activeAnimations = new ArrayList<>();
public final VisualEffectFrameListeners visualEffectFrameListeners = new VisualEffectFrameListeners();
private long getEffectUpdateInterval() {
return EFFECT_UPDATE_INTERVAL * controllers.preferences.attackspeed_milliseconds / AndorsTrailPreferences.ATTACKSPEED_DEFAULT_MILLISECONDS;
}
public VisualEffectController(ControllerContext controllers, WorldContext world) {
this.controllers = controllers;
@@ -44,41 +37,11 @@ public final class VisualEffectController {
}
public void startEffect(Coord position, VisualEffectCollection.VisualEffectID effectID, String displayValue, VisualEffectCompletedCallback callback, int callbackValue) {
VisualEffectAnimation animation = new VisualEffectAnimation(effectTypes.getVisualEffect(effectID), position, displayValue, callback, callbackValue);
animation.start();
++effectCount;
(new VisualEffectAnimation(effectTypes.getVisualEffect(effectID), position, displayValue, callback, callbackValue))
.start();
}
private void startAnimation(VisualEffectAnimation animation) {
activeAnimations.add(animation);
animation.update();
if (activeAnimations.size() == 1) {
animationHandler.postDelayed(animationRunnable, 0);
}
}
private final Runnable animationRunnable = new Runnable() {
@Override
public void run() {
if(!activeAnimations.isEmpty()) {
long updateInterval = getEffectUpdateInterval();
if(updateInterval > 0) animationHandler.postDelayed(this, updateInterval);
for (int i = 0; i < activeAnimations.size(); i++) {
VisualEffectAnimation animation = activeAnimations.get(i);
animation.durationPassed += updateInterval;
animation.updateFrame();
animation.update();
if (controllers.preferences.attackspeed_milliseconds <= 0 || animation.currentFrame >= animation.effect.lastFrame) {
animation.onCompleted();
activeAnimations.remove(i);
i--;
}
}
visualEffectFrameListeners.onNewAnimationFrames(activeAnimations);
}
}
};
private VisualEffectCollection.VisualEffectID enqueuedEffectID = null;
private int enqueuedEffectValue = 0;
public void enqueueEffect(VisualEffectCollection.VisualEffectID effectID, int displayValue) {
@@ -97,13 +60,15 @@ public final class VisualEffectController {
}
public void startActorMoveEffect(Actor actor, PredefinedMap map, Coord origin, Coord destination, int duration, VisualEffectCompletedCallback callback, int callbackValue) {
++effectCount;
(new SpriteMoveAnimation(origin, destination, duration, actor, map, callback, callbackValue))
.start();
}
public final class SpriteMoveAnimation implements Runnable {
private final Handler handler = new Handler();
public final class SpriteMoveAnimation extends Handler implements Runnable {
// private static final int millisecondsPerFrame=25;
private final VisualEffectCompletedCallback callback;
private final int callbackValue;
@@ -117,6 +82,11 @@ public final class VisualEffectController {
@Override
public void run() {
onCompleted();
// update();
// if (System.currentTimeMillis() - actor.vfxStartTime >= duration) {
// } else {
// postDelayed(this, millisecondsPerFrame);
// }
}
public SpriteMoveAnimation(Coord origin, Coord destination, int duration, Actor actor, PredefinedMap map, VisualEffectCompletedCallback callback, int callbackValue) {
@@ -129,12 +99,19 @@ public final class VisualEffectController {
this.destination = destination;
}
// private void update() {
//
// visualEffectFrameListeners.onNewSpriteMoveFrame(this);
// }
private void onCompleted() {
--effectCount;
actor.hasVFXRunning = false;
if (callback != null) callback.onVisualEffectCompleted(callbackValue);
visualEffectFrameListeners.onSpriteMoveCompleted(this);
}
public void start() {
actor.hasVFXRunning = true;
@@ -143,9 +120,12 @@ public final class VisualEffectController {
visualEffectFrameListeners.onSpriteMoveStarted(this);
if (duration == 0 || !controllers.preferences.enableUiAnimations) onCompleted();
else {
handler.postDelayed(this, duration);
postDelayed(this, duration);
}
}
}
public static final Paint textPaint = new Paint();
@@ -154,45 +134,41 @@ public final class VisualEffectController {
textPaint.setAlpha(255);
textPaint.setTextAlign(Align.CENTER);
}
public final class VisualEffectAnimation extends Handler implements Runnable {
/// only for combat effects, movement & blood splatters etc. are handled elsewhere.
public final class VisualEffectAnimation {
public int tileID;
public int textYOffset;
public long durationPassed = 0;
private void updateFrame() {
long frameDuration = (long) effect.millisecondPerFrame * controllers.preferences.attackspeed_milliseconds / AndorsTrailPreferences.ATTACKSPEED_DEFAULT_MILLISECONDS;
while (frameDuration > 0 && durationPassed > frameDuration) {
currentFrame++;
durationPassed -= frameDuration;
@Override
public void run() {
if (currentFrame >= effect.lastFrame) {
onCompleted();
} else {
postDelayed(this, effect.millisecondPerFrame * controllers.preferences.attackspeed_milliseconds / AndorsTrailPreferences.ATTACKSPEED_DEFAULT_MILLISECONDS);
update();
}
}
private void update() {
if (currentFrame >= effect.lastFrame) {
return;
++currentFrame;
int frame = currentFrame;
int tileID = effect.frameIconIDs[frame];
int textYOffset = -2 * (frame);
if (frame >= beginFadeAtFrame && displayText != null) {
textPaint.setAlpha(255 * (effect.lastFrame - frame) / (effect.lastFrame - beginFadeAtFrame));
}
tileID = effect.frameIconIDs[currentFrame];
textYOffset = -2 * (currentFrame);
if (currentFrame >= beginFadeAtFrame && displayText != null) {
textPaint.setAlpha(255 * (effect.lastFrame - currentFrame) / (effect.lastFrame - beginFadeAtFrame));
}
area.topLeft.y = position.y - 1;
visualEffectFrameListeners.onNewAnimationFrame(this, tileID, textYOffset);
}
private void onCompleted() {
--effectCount;
visualEffectFrameListeners.onAnimationCompleted(this);
if (callback != null) callback.onVisualEffectCompleted(callbackValue);
}
public void start() {
if (!controllers.preferences.enableUiAnimations
|| effect.duration == 0
|| controllers.preferences.attackspeed_milliseconds <= 0) onCompleted();
else startAnimation(this);
if (!controllers.preferences.enableUiAnimations) onCompleted();
else postDelayed(this, 0);
}
private int currentFrame = 0;
@@ -221,7 +197,7 @@ public final class VisualEffectController {
this.area = new CoordRect(new Coord(position.x - (widthNeededInTiles / 2), position.y - 1), new Size(widthNeededInTiles, 2));
this.beginFadeAtFrame = effect.lastFrame / 2;
}
public Paint getTextPaint(){
return textPaint;
}
@@ -232,7 +208,7 @@ public final class VisualEffectController {
}
public boolean isRunningVisualEffect() {
return !activeAnimations.isEmpty();
return effectCount > 0;
}
@@ -292,10 +268,10 @@ public final class VisualEffectController {
return -1;
}
}
public void asyncUpdateArea(CoordRect area) {
visualEffectFrameListeners.onAsyncAreaUpdate(area);
}
}

View File

@@ -25,7 +25,6 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
import com.gpl.rpg.AndorsTrail.model.map.MapLayer;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
import com.gpl.rpg.AndorsTrail.model.map.TMXMapTranslator;
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.NamedWorldMapArea;
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
@@ -315,32 +314,4 @@ public final class WorldMapController {
return true;
}
public static void populateWorldMap(Context context, WorldContext world, Resources res) throws IOException {
ensureWorldmapDirectoryExists(context);
File dir = getWorldmapDirectory(context);
File idFile = new File(dir, world.model.player.id);
if (idFile.exists()) return;
idFile.createNewFile();
for (PredefinedMap map : world.maps.getAllMaps()) {
if (!map.visited) continue;
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(map.name);
if (worldMapSegmentName == null) continue;
boolean mapFileExists = fileForMapExists(context, map);
File worldMapFile = getCombinedWorldMapFile(context, worldMapSegmentName);
if (mapFileExists && worldMapFile.exists()) continue;
LayeredTileMap mapTiles = TMXMapTranslator.readLayeredTileMap(res, world.tileManager.tileCache, map);
mapTiles.changeColorFilter(map.currentColorFilter);
TileCollection cachedTiles = world.tileManager.loadTilesFor(map, mapTiles, world, res);
MapRenderer renderer = new MapRenderer(world, map, mapTiles, cachedTiles);
updateCachedBitmap(context, map, renderer);
updateWorldMapSegment(context, res, world, worldMapSegmentName);
}
}
}

View File

@@ -4,10 +4,8 @@ import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.SpriteMoveAnima
import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.VisualEffectAnimation;
import com.gpl.rpg.AndorsTrail.util.CoordRect;
import java.util.List;
public interface VisualEffectFrameListener {
void onNewAnimationFrames(List<VisualEffectAnimation> effects);
void onNewAnimationFrame(VisualEffectAnimation animation, int tileID, int textYOffset);
void onAnimationCompleted(VisualEffectAnimation animation);
void onSpriteMoveStarted(SpriteMoveAnimation animation);
void onNewSpriteMoveFrame(SpriteMoveAnimation animation);

View File

@@ -5,12 +5,10 @@ import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.VisualEffectAni
import com.gpl.rpg.AndorsTrail.util.CoordRect;
import com.gpl.rpg.AndorsTrail.util.ListOfListeners;
import java.util.List;
public final class VisualEffectFrameListeners extends ListOfListeners<VisualEffectFrameListener> implements VisualEffectFrameListener {
private final Function1<VisualEffectFrameListener, List<VisualEffectAnimation>> onNewAnimationFrames = new Function1<VisualEffectFrameListener, List<VisualEffectAnimation>>() {
@Override public void call(VisualEffectFrameListener listener, List<VisualEffectAnimation> effects) { listener.onNewAnimationFrames(effects); }
private final Function3<VisualEffectFrameListener, VisualEffectAnimation, Integer, Integer> onNewAnimationFrame = new Function3<VisualEffectFrameListener, VisualEffectAnimation, Integer, Integer>() {
@Override public void call(VisualEffectFrameListener listener, VisualEffectAnimation animation, Integer tileID, Integer textYOffset) { listener.onNewAnimationFrame(animation, tileID, textYOffset); }
};
private final Function1<VisualEffectFrameListener, VisualEffectAnimation> onAnimationCompleted = new Function1<VisualEffectFrameListener, VisualEffectAnimation>() {
@@ -32,10 +30,10 @@ public final class VisualEffectFrameListeners extends ListOfListeners<VisualEffe
private final Function1<VisualEffectFrameListener, CoordRect> onAsyncAreaUpdate = new Function1<VisualEffectFrameListener, CoordRect>() {
@Override public void call(VisualEffectFrameListener listener, CoordRect area) { listener.onAsyncAreaUpdate(area); }
};
@Override
public void onNewAnimationFrames(List<VisualEffectAnimation> effects) {
callAllListeners(this.onNewAnimationFrames, effects);
public void onNewAnimationFrame(VisualEffectAnimation animation, int tileID, int textYOffset) {
callAllListeners(this.onNewAnimationFrame, animation, tileID, textYOffset);
}
@Override

View File

@@ -1,115 +0,0 @@
package com.gpl.rpg.AndorsTrail.model;
import android.os.Build;
import com.gpl.rpg.AndorsTrail.util.L;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.security.DigestException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class ChecksumBuilder {
public static final int CHECKSUM_LENGTH = 32;// 256 bits (depends on the hash algorithm)
public static final String CHECKSUM_ALGORITHM = "SHA-256"; //Should be available in all Android versions
private ByteBuffer buffer;
private final MessageDigest digest;
private ChecksumBuilder(int initialCapacity, ByteOrder byteOrder) {
buffer = ByteBuffer.allocate(initialCapacity);
buffer.order(byteOrder);
try {
digest = MessageDigest.getInstance(CHECKSUM_ALGORITHM); // Or SHA-512 for even stronger hash
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Hash algorithm not found", e);
}
}
private ChecksumBuilder(int initialCapacity) {
this(initialCapacity, ByteOrder.BIG_ENDIAN); // Default to big-endian
}
public ChecksumBuilder() {
this(1024*10); // A reasonable default initial capacity
}
// --- Methods for adding different data types ---
public ChecksumBuilder add(String value) {
if (value != null) {
byte[] bytes;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
bytes = value.getBytes(StandardCharsets.UTF_8);
} else {
bytes = value.getBytes();
}
add(bytes);
} else {
add(-1); // Use -1 to represent a null string
}
return this;
}
public ChecksumBuilder add(byte[] bytes) {
add(bytes.length); // Add length prefix
ensureCapacity(bytes.length + 4); // +4 for length prefix (int)
buffer.put(bytes);
return this;
}
public ChecksumBuilder add(boolean value) {
ensureCapacity(1);
buffer.put(value ? (byte) 1 : (byte) 0);
return this;
}
public ChecksumBuilder add(long value) {
ensureCapacity(8);
buffer.putLong(value);
return this;
}
public ChecksumBuilder add(int value) {
ensureCapacity(4);
buffer.putInt(value);
return this;
}
public ChecksumBuilder add(float value) {
ensureCapacity(8);
buffer.putFloat(value);
return this;
}
public ChecksumBuilder add(double value) {
ensureCapacity(4);
buffer.putDouble(value);
return this;
}
// --- Method to finalize and get the checksum ---
public byte[] build() throws DigestException {
buffer.flip(); // Prepare for reading
digest.update(buffer);// Only use the actually used part of the buffer
buffer.flip(); // Prepare for further writing
return digest.digest();
}
// --- Utility method to ensure sufficient capacity ---
private void ensureCapacity(int required) {
if (buffer.remaining() < required) {
int newCapacity = Math.max(buffer.capacity() * 2, buffer.capacity() + required);
ByteBuffer newBuffer = ByteBuffer.allocate(newCapacity);
newBuffer.order(buffer.order());
buffer.flip(); // Prepare for reading
newBuffer.put(buffer); // Copy existing data
buffer = newBuffer; // Assign the new buffer to the field
}
}
}

View File

@@ -3,7 +3,6 @@ package com.gpl.rpg.AndorsTrail.model;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -23,8 +22,6 @@ import com.gpl.rpg.AndorsTrail.model.quest.Quest;
import com.gpl.rpg.AndorsTrail.util.HashMapHelper;
public final class GameStatistics {
private boolean isAlteredSavegame = false;
private byte[] checksum = new byte[ChecksumBuilder.CHECKSUM_LENGTH];
private int deaths = 0;
private final HashMap<String, Integer> killedMonstersByTypeID = new HashMap<String, Integer>();
private final HashMap<String, Integer> killedMonstersByName = new HashMap<String, Integer>();
@@ -70,7 +67,6 @@ public final class GameStatistics {
public boolean hasUnlimitedLives() { return startLives == -1; }
public int getStartLives() { return startLives; }
public boolean getIsAlteredSavegame() { return isAlteredSavegame; }
public int getLivesLeft() { return hasUnlimitedLives() ? -1 : startLives - deaths; }
@@ -162,18 +158,6 @@ public final class GameStatistics {
}
};
public void setChecksum(byte[] checksum) {
if (checksum.length != ChecksumBuilder.CHECKSUM_LENGTH) throw new IllegalArgumentException("Invalid checksum length.");
this.checksum = checksum;
}
public boolean compareChecksum(byte[] checksum) {
return this.checksum.length == checksum.length && MessageDigest.isEqual(this.checksum, checksum);
}
public void markAsAlteredSavegame() {
isAlteredSavegame = true;
}
// ====== PARCELABLE ===================================================================
@@ -210,11 +194,6 @@ public final class GameStatistics {
this.startLives = src.readInt();
this.unlimitedSaves = src.readBoolean();
if (fileversion < 81) return;
this.isAlteredSavegame = src.readBoolean();
final int checksumLength = src.readInt();
this.checksum = new byte[checksumLength];
if( src.read(checksum) != checksumLength) throw new IOException("Failed to read full checksum.");
}
public void writeToParcel(DataOutputStream dest) throws IOException {
@@ -234,29 +213,5 @@ public final class GameStatistics {
dest.writeInt(spentGold);
dest.writeInt(startLives);
dest.writeBoolean(unlimitedSaves);
dest.writeBoolean(isAlteredSavegame);
dest.writeInt(checksum.length);
dest.write(checksum);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(deaths);
Set<Entry<String, Integer> > set = killedMonstersByTypeID.entrySet();
builder.add(set.size());
for (Entry<String, Integer> e : set) {
builder.add(e.getKey());
builder.add(e.getValue());
}
set = usedItems.entrySet();
builder.add(set.size());
for (Entry<String, Integer> e : set) {
builder.add(e.getKey());
builder.add(e.getValue());
}
builder.add(spentGold);
builder.add(startLives);
builder.add(unlimitedSaves);
builder.add(isAlteredSavegame);
}
}

View File

@@ -51,12 +51,4 @@ public final class InterfaceData {
}
dest.writeUTF(selectedTabHeroInfo);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(isMainActivityVisible);
builder.add(isInCombat);
builder.add(selectedPosition != null);
if (selectedPosition != null) selectedPosition.addToChecksum(builder);
builder.add(selectedTabHeroInfo);
}
}

View File

@@ -49,11 +49,4 @@ public final class ModelContainer {
statistics.writeToParcel(dest);
worldData.writeToParcel(dest);
}
public void addToChecksum(ChecksumBuilder builder){
player.addToChecksum(builder);
builder.add(currentMaps.map.name);
uiSelections.addToChecksum(builder);
statistics.addToChecksum(builder);
worldData.addToChecksum(builder);
}
}

View File

@@ -114,13 +114,4 @@ public final class WorldData {
dest.writeLong(e.getValue());
}
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(worldTime);
builder.add(timers.size());
for(Map.Entry<String, Long> e : timers.entrySet()) {
builder.add(e.getKey());
builder.add(e.getValue());
}
}
}

View File

@@ -5,12 +5,10 @@ import java.io.DataOutputStream;
import java.io.IOException;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
public final class ActorCondition {
public static final int MAGNITUDE_REMOVE_ALL = -99;
public static final int DURATION_FOREVER = 999;
public static final int DURATION_FOREVER_UNTIL_SLEEP = 998;
public static final int DURATION_NONE = 0;
public final ActorConditionType conditionType;
@@ -29,12 +27,7 @@ public final class ActorCondition {
public boolean isTemporaryEffect() { return isTemporaryEffect(duration); }
public static boolean isTemporaryEffect(int duration) {
return ( duration != DURATION_FOREVER && duration != DURATION_FOREVER_UNTIL_SLEEP );
}
public boolean isDurationForeverUntilSleep() { return isDurationForeverUntilSleep(duration); }
public static boolean isDurationForeverUntilSleep(int duration) {
return ( duration == DURATION_FOREVER_UNTIL_SLEEP );
return duration != DURATION_FOREVER;
}
@@ -52,11 +45,4 @@ public final class ActorCondition {
dest.writeInt(magnitude);
dest.writeInt(duration);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(conditionType.conditionTypeID);
builder.add(magnitude);
builder.add(duration);
}
}

View File

@@ -10,7 +10,6 @@ public final class ActorConditionType {
public final String conditionTypeID;
public final String name;
public final String description;
public final int iconID;
public final ConditionCategory conditionCategory;
public final boolean isStacking;
@@ -22,7 +21,6 @@ public final class ActorConditionType {
public ActorConditionType(
String conditionTypeID
, String name
, String description
, int iconID
, ConditionCategory conditionCategory
, boolean isStacking
@@ -33,7 +31,6 @@ public final class ActorConditionType {
) {
this.conditionTypeID = conditionTypeID;
this.name = name;
this.description = description;
this.iconID = iconID;
this.conditionCategory = conditionCategory;
this.isStacking = isStacking;

View File

@@ -187,12 +187,12 @@ public final class SkillCollection {
initializeSkill(new SkillInfo(SkillID.resistanceBlood, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null, position++));
initializeSkill(new SkillInfo(SkillID.shadowBless, 1, SkillInfo.LevelUpType.onlyByQuests, SkillCategory.immunity, null, position++));
initializeSkill(new SkillInfo(SkillID.crit1, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 2)
,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 2)
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 3)
,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3)
}, position++));
initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 4)
,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 4)
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6)
,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 6)
,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1)
}, position++));
initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] {

View File

@@ -6,7 +6,6 @@ import java.io.IOException;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.Constants;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
import com.gpl.rpg.AndorsTrail.model.item.DropList;
@@ -194,43 +193,4 @@ public final class Monster extends Actor {
dest.writeBoolean(false);
}
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(getMonsterTypeID());
if (attackCost == monsterType.attackCost
&& attackChance == monsterType.attackChance
&& criticalSkill == monsterType.criticalSkill
&& criticalMultiplier == monsterType.criticalMultiplier
&& damagePotential.equals(monsterType.damagePotential)
&& blockChance == monsterType.blockChance
&& damageResistance == monsterType.damageResistance
) {
builder.add(false);
} else {
builder.add(true);
builder.add(attackCost);
builder.add(attackChance);
builder.add(criticalSkill);
builder.add(criticalMultiplier);
damagePotential.addToChecksum(builder);
builder.add(blockChance);
builder.add(damageResistance);
}
ap.addToChecksum(builder);
health.addToChecksum(builder);
position.addToChecksum(builder);
builder.add(conditions.size());
for (ActorCondition c : conditions) {
c.addToChecksum(builder);
}
builder.add(moveCost);
builder.add(forceAggressive);
if (shopItems != null) {
builder.add(true);
shopItems.addToChecksum(builder);
} else {
builder.add(false);
}
}
}

View File

@@ -19,7 +19,6 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.Constants;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
import com.gpl.rpg.AndorsTrail.model.item.DropListCollection;
@@ -476,62 +475,5 @@ public final class Player extends Actor {
dest.writeUTF(id);
dest.writeLong(savedVersion);
}
public void addToChecksum(ChecksumBuilder builder) {
//builder.add(baseTraits.iconID);// Do not add to checksum so that it can be changed without invalidating checksums
builder.add(baseTraits.maxAP);
builder.add(baseTraits.maxHP);
//builder.add(name);// Do not add to checksum so that it can be changed without invalidating checksums
builder.add(moveCost); // TODO: Should we really write this?
builder.add(baseTraits.attackCost);
builder.add(baseTraits.attackChance);
builder.add(baseTraits.criticalSkill);
builder.add(baseTraits.criticalMultiplier);
baseTraits.damagePotential.addToChecksum(builder);
builder.add(baseTraits.blockChance);
builder.add(baseTraits.damageResistance);
builder.add(baseTraits.moveCost);
ap.addToChecksum(builder);
health.addToChecksum(builder);
position.addToChecksum(builder);
builder.add(conditions.size());
for (ActorCondition c : conditions) {
c.addToChecksum(builder);
}
builder.add(immunities.size());
for (ActorCondition c : immunities) {
c.addToChecksum(builder);
}
lastPosition.addToChecksum(builder);
nextPosition.addToChecksum(builder);
builder.add(level);
builder.add(totalExperience);
inventory.addToChecksum(builder);
builder.add(baseTraits.useItemCost);
builder.add(baseTraits.reequipCost);
builder.add(skillLevels.size());
for (int i = 0; i < skillLevels.size(); ++i) {
builder.add(skillLevels.keyAt(i));
builder.add(skillLevels.valueAt(i));
}
builder.add(spawnMap);
builder.add(spawnPlace);
builder.add(questProgress.size());
for(Entry<String, LinkedHashSet<Integer> > e : questProgress.entrySet()) {
builder.add(e.getKey());
builder.add(e.getValue().size());
for(int progress : e.getValue()) {
builder.add(progress);
}
}
builder.add(availableSkillIncreases);
builder.add(alignments.size());
for(Entry<String, Integer> e : alignments.entrySet()) {
builder.add(e.getKey());
builder.add(e.getValue());
}
builder.add(id);
builder.add(savedVersion);
}
}

View File

@@ -5,7 +5,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer;
public final class Inventory extends ItemContainer {
@@ -209,21 +208,4 @@ public final class Inventory extends ItemContainer {
}
}
}
public void addToChecksum(ChecksumBuilder builder) {
super.addToChecksum(builder);
builder.add(gold);
builder.add(NUM_WORN_SLOTS);
for(int i = 0; i < NUM_WORN_SLOTS; ++i) {
if (wear[i] != null) {
builder.add(wear[i].id);
}
}
builder.add(NUM_QUICK_SLOTS);
for(int i = 0; i < NUM_QUICK_SLOTS; ++i) {
if (quickitem[i] != null) {
builder.add(quickitem[i].id);
}
}
}
}

View File

@@ -8,7 +8,6 @@ import java.util.Collections;
import java.util.Comparator;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
public class ItemContainer {
@@ -43,10 +42,6 @@ public class ItemContainer {
dest.writeUTF(itemType.id);
dest.writeInt(quantity);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(itemType.id);
builder.add(quantity);
}
}
public void addItem(ItemType itemType, int quantity) {
@@ -285,10 +280,4 @@ public class ItemContainer {
e.writeToParcel(dest);
}
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(items.size());
for (ItemEntry e : items) {
e.addToChecksum(builder);
}
}
}

View File

@@ -5,7 +5,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer;
import com.gpl.rpg.AndorsTrail.util.Coord;
@@ -89,12 +88,4 @@ public final class Loot {
position.writeToParcel(dest);
dest.writeBoolean(isVisible);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(exp);
builder.add(gold);
items.addToChecksum(builder);
position.addToChecksum(builder);
builder.add(isVisible);
}
}

View File

@@ -11,7 +11,6 @@ import java.util.List;
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForMap;
import com.gpl.rpg.AndorsTrail.util.L;
@@ -100,16 +99,4 @@ public final class MapCollection {
map.writeToParcel(dest, world);
}
}
public void addToChecksum(ChecksumBuilder checksumBuilder, WorldContext world) {
List<PredefinedMap> mapsToExport = new ArrayList<PredefinedMap>();
for(PredefinedMap map : getAllMaps()) {
if (shouldSaveMap(world, map)) mapsToExport.add(map);
}
checksumBuilder.add(mapsToExport.size());
for(PredefinedMap map : mapsToExport) {
checksumBuilder.add(map.name);
map.addToChecksum(checksumBuilder, world);
}
}
}

View File

@@ -8,7 +8,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.Constants;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
import com.gpl.rpg.AndorsTrail.util.Coord;
@@ -141,12 +140,4 @@ public final class MonsterSpawnArea {
m.writeToParcel(dest);
}
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(isSpawning);
builder.add(monsters.size());
for (Monster m : monsters) {
m.addToChecksum(builder);
}
}
}

View File

@@ -12,7 +12,6 @@ import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.Constants;
import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.BloodSplatter;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
@@ -399,30 +398,4 @@ public final class PredefinedMap {
dest.writeBoolean(visited);
dest.writeUTF(lastSeenLayoutHash);
}
public void addToChecksum(ChecksumBuilder builder, WorldContext world) {
if (shouldSaveMapData(world)) {
builder.add(true);
builder.add(spawnAreas.length);
for(MonsterSpawnArea a : spawnAreas) {
builder.add(a.areaID);
a.addToChecksum(builder);
}
builder.add(activeMapObjectGroups.size());
for(String s : activeMapObjectGroups) {
builder.add(s);
}
builder.add(groundBags.size());
for(Loot l : groundBags) {
l.addToChecksum(builder);
}
builder.add(currentColorFilter != null);
if (currentColorFilter != null) builder.add(currentColorFilter);
builder.add(lastVisitTime);
} else {
builder.add(false);
}
builder.add(visited);
builder.add(lastSeenLayoutHash);
}
}

View File

@@ -256,14 +256,11 @@ public final class ResourceLoader {
final Size sz2x2 = new Size(2, 2);
final Size sz2x3 = new Size(2, 3);
final Size sz3x1 = new Size(3, 1);
final Size sz4x1 = new Size(4, 1);
final Size sz5x1 = new Size(5, 1);
final Size sz6x1 = new Size(6, 1);
final Size sz7x1 = new Size(7, 1);
final Size sz7x4 = new Size(7, 4);
final Size sz8x3 = new Size(8, 3);
final Size sz16x8 = new Size(16, 8);
final Size sz16x10 = new Size(16, 10);
final Size sz20x12 = new Size(20, 12);
final Size mapTileSize = new Size(16, 8);
final Size sz8x8 = new Size(8, 8);
@@ -283,7 +280,6 @@ public final class ResourceLoader {
loader.prepareTileset(R.drawable.actorconditions_1, "actorconditions_1", new Size(14, 8), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.actorconditions_2, "actorconditions_2", sz3x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.actorconditions_japozero, "actorconditions_japozero", new Size(16, 4), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.actorconditions_newb, "actorconditions_newb", new Size(20, 1), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.actorconditions_omi1, "actorconditions_omi1", sz2x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.actorconditions_omi2, "actorconditions_omi2", sz5x1, sz1x1, mTileSize);
/*INSERT_ACTORCONDITIONS_TILESETS_HERE*/
@@ -325,7 +321,7 @@ public final class ResourceLoader {
loader.prepareTileset(R.drawable.monsters_cyclops, "monsters_cyclops", sz1x1, sz2x3, mTileSize);
loader.prepareTileset(R.drawable.monsters_demon1, "monsters_demon1", sz1x1, sz2x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_demon2, "monsters_demon2", sz1x1, sz2x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_dogs, "monsters_dogs", sz7x4, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_dogs, "monsters_dogs", sz7x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_eye1, "monsters_eye1", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_eye2, "monsters_eye2", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_eye3, "monsters_eye3", sz1x1, sz1x1, mTileSize);
@@ -333,11 +329,10 @@ public final class ResourceLoader {
loader.prepareTileset(R.drawable.monsters_ghost1, "monsters_ghost1", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_hydra1, "monsters_hydra1", sz1x1, sz2x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_insects, "monsters_insects", sz6x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_johny, "monsters_johny", sz20x12, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_karvis1, "monsters_karvis1", sz2x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_karvis2, "monsters_karvis2", new Size(9, 1), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_ld1, "monsters_ld1", sz20x12, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_ld2, "monsters_ld2", sz20x12, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_ld1, "monsters_ld1", new Size(20, 12), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_ld2, "monsters_ld2", new Size(20, 12), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_liches, "monsters_liches", new Size(4, 1), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_mage, "monsters_mage", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_mage2, "monsters_mage2", sz1x1, sz1x1, mTileSize);
@@ -347,7 +342,7 @@ public final class ResourceLoader {
loader.prepareTileset(R.drawable.monsters_misc, "monsters_misc", new Size(13, 1), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_newb_1, "monsters_newb_1", new Size(40, 34), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_newb_2, "monsters_newb_2", new Size(8, 2), sz1x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_newb_3, "monsters_newb_3", new Size(10, 10), sz2x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_newb_3, "monsters_newb_3", new Size(10, 2), sz2x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_newb_4, "monsters_newb_4", new Size(4, 1), sz2x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_rats, "monsters_rats", new Size(5, 1), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_redshrike1, "monsters_redshrike1", sz7x1, sz1x1, mTileSize);
@@ -378,7 +373,7 @@ public final class ResourceLoader {
loader.prepareTileset(R.drawable.monsters_omi1_b, "monsters_omi1_b", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_unknown, "monsters_unknown", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_arulirs, "monsters_arulirs", new Size(8, 2), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_fatboy73, "monsters_fatboy73", sz20x12, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_fatboy73, "monsters_fatboy73", new Size(20, 12), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_giantbasilisk, "monsters_giantbasilisk", sz1x1, sz2x2, mTileSize);
loader.prepareTileset(R.drawable.monsters_gisons, "monsters_gisons", new Size(8, 2), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.monsters_bosses_2x2, "monsters_bosses_2x2", sz1x1, sz2x2, mTileSize);
@@ -387,12 +382,12 @@ public final class ResourceLoader {
loader.prepareTileset(R.drawable.monsters_cats, "monsters_cats", new Size(10, 2), sz1x1, mTileSize);
/*INSERT_NPCS_TILESETS_HERE*/
loader.prepareTileset(R.drawable.map_bed_1, "map_bed_1", sz16x10, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_boats_1, "map_boats_1", new Size(16, 9), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_bed_1, "map_bed_1", mapTileSize, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_boats_1, "map_boats_1", mapTileSize, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_border_1, "map_border_1", mapTileSize, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_bridge_1, "map_bridge_1", mapTileSize, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_bridge_2, "map_bridge_2", mapTileSize, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_brightport, "map_brightport", new Size(16, 7), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_brightport, "map_brightport", new Size(7, 5), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_broken_1, "map_broken_1", mapTileSize, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_cavewall_1, "map_cavewall_1", new Size(18, 6), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.map_cavewall_2, "map_cavewall_2", new Size(18, 6), sz1x1, mTileSize);

View File

@@ -26,7 +26,6 @@ public final class ActorConditionsTypeParser extends JsonCollectionParserFor<Act
ActorConditionType result = new ActorConditionType(
conditionTypeID
,translationLoader.translateActorConditionName(o.getString(JsonFieldNames.ActorCondition.name))
,translationLoader.translateActorConditionName(o.optString(JsonFieldNames.ActorCondition.description))
,ResourceParserUtils.parseImageID(tileLoader, o.getString(JsonFieldNames.ActorCondition.iconID))
,ActorConditionType.ConditionCategory.valueOf(o.getString(JsonFieldNames.ActorCondition.category))
,o.optInt(JsonFieldNames.ActorCondition.isStacking) > 0

View File

@@ -4,7 +4,6 @@ public final class JsonFieldNames {
public static final class ActorCondition {
public static final String conditionTypeID = "id";
public static final String name = "name";
public static final String description = "description";
public static final String iconID = "iconID";
public static final String category = "category";
public static final String isStacking = "isStacking";

View File

@@ -76,17 +76,14 @@ public final class TileCache {
ResourceFileTile tile = resourceTiles[tileID];
if(tile == null && AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES){
L.log("could not find resourceTiles for id: " + tileID);
L.log("iconIDs: " + iconIDs);
}
if(tile != null || AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA){
SparseArray<ResourceFileTile> tiles = tilesToLoadPerSourceFile.get(tile.tileset);
if (tiles == null) {
tiles = new SparseArray<TileCache.ResourceFileTile>();
tilesToLoadPerSourceFile.put(tile.tileset, tiles);
}
tiles.put(tileID, tile);
maxTileID = Math.max(maxTileID, tileID);
SparseArray<ResourceFileTile> tiles = tilesToLoadPerSourceFile.get(tile.tileset);
if (tiles == null) {
tiles = new SparseArray<TileCache.ResourceFileTile>();
tilesToLoadPerSourceFile.put(tile.tileset, tiles);
}
tiles.put(tileID, tile);
maxTileID = Math.max(maxTileID, tileID);
}
boolean hasLoadedTiles = false;

View File

@@ -12,7 +12,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.security.DigestException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -28,7 +27,6 @@ import com.gpl.rpg.AndorsTrail.R;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.Constants;
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
@@ -80,7 +78,7 @@ public final class Savegames {
}
return true;
} catch (IOException | DigestException e) {
} catch (IOException e) {
L.log("Error saving world: " + e.toString());
return false;
}
@@ -88,7 +86,7 @@ public final class Savegames {
private static void writeBackup(Context androidContext, byte[] savegame, String playerId) throws IOException {
File cheatDetectionFolder = AndroidStorage.getStorageDirectory(androidContext, Constants.CHEAT_DETECTION_FOLDER);
ensureDirExists(cheatDetectionFolder);
ensureDirExists(cheatDetectionFolder);
File backupFile = new File(cheatDetectionFolder, playerId + "X");
FileOutputStream fileOutputStream = new FileOutputStream(backupFile);
fileOutputStream.write(savegame);
@@ -106,18 +104,18 @@ public final class Savegames {
}
FileInputStream fos = getInputFile(androidContext, slot);
LoadSavegameResult result = loadWorld(androidContext.getResources(), world, controllers, androidContext, fos, fh);
LoadSavegameResult result = loadWorld(androidContext.getResources(), world, controllers, fos, fh);
fos.close();
if (result == LoadSavegameResult.success && slot != SLOT_QUICKSAVE && !world.model.statistics.hasUnlimitedSaves()) {
// save to the quicksave slot before deleting the file
if (!saveWorld(world, androidContext, SLOT_QUICKSAVE)) {
// save to the quicksave slot before deleting the file
if (!saveWorld(world, androidContext, SLOT_QUICKSAVE)) {
return LoadSavegameResult.unknownError;
}
getSlotFile(slot, androidContext).delete();
writeCheatCheck(androidContext, DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED, fh.playerId);
}
return result;
} catch (IOException | DigestException e) {
} catch (IOException e) {
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
L.log("Error loading world: " + e.toString());
StringWriter sw = new StringWriter();
@@ -129,33 +127,33 @@ public final class Savegames {
}
}
private static boolean triedToCheat(Context androidContext, FileHeader fh) throws IOException {
long savedVersionToCheck = 0;
File cheatDetectionFolder = AndroidStorage.getStorageDirectory(androidContext, Constants.CHEAT_DETECTION_FOLDER);
ensureDirExists(cheatDetectionFolder);
File cheatDetectionFile = new File(cheatDetectionFolder, fh.playerId);
if (cheatDetectionFile.exists()) {
FileInputStream fileInputStream = new FileInputStream(cheatDetectionFile);
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
final CheatDetection cheatDetection = new CheatDetection(dataInputStream);
savedVersionToCheck = cheatDetection.savedVersion;
dataInputStream.close();
fileInputStream.close();
}
private static boolean triedToCheat(Context androidContext, FileHeader fh) throws IOException {
long savedVersionToCheck = 0;
File cheatDetectionFolder = AndroidStorage.getStorageDirectory(androidContext, Constants.CHEAT_DETECTION_FOLDER);
ensureDirExists(cheatDetectionFolder);
File cheatDetectionFile = new File(cheatDetectionFolder, fh.playerId);
if (cheatDetectionFile.exists()) {
FileInputStream fileInputStream = new FileInputStream(cheatDetectionFile);
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
final CheatDetection cheatDetection = new CheatDetection(dataInputStream);
savedVersionToCheck = cheatDetection.savedVersion;
dataInputStream.close();
fileInputStream.close();
}
if (savedVersionToCheck == DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED) {
return true;
}
if (androidContext.getFileStreamPath(fh.playerId).exists()) {
FileInputStream fileInputStream = androidContext.openFileInput(fh.playerId);
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
final CheatDetection cheatDetection = new CheatDetection(dataInputStream);
if (cheatDetection.savedVersion == DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED) {
savedVersionToCheck = DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED;
} else if (cheatDetection.savedVersion > savedVersionToCheck) {
savedVersionToCheck = cheatDetection.savedVersion;
}
if (androidContext.getFileStreamPath(fh.playerId).exists()) {
FileInputStream fileInputStream = androidContext.openFileInput(fh.playerId);
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
final CheatDetection cheatDetection = new CheatDetection(dataInputStream);
if (cheatDetection.savedVersion == DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED) {
savedVersionToCheck = DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED;
} else if (cheatDetection.savedVersion > savedVersionToCheck) {
savedVersionToCheck = cheatDetection.savedVersion;
}
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
L.log("Internal cheatcheck file savedVersion: " + cheatDetection.savedVersion);
@@ -168,98 +166,82 @@ public final class Savegames {
return (savedVersionToCheck == DENY_LOADING_BECAUSE_GAME_IS_CURRENTLY_PLAYED || fh.savedVersion < savedVersionToCheck);
}
private static FileOutputStream getOutputFile(Context androidContext, int slot) throws IOException {
if (slot == SLOT_QUICKSAVE) {
return androidContext.openFileOutput(Constants.FILENAME_SAVEGAME_QUICKSAVE, Context.MODE_PRIVATE);
} else {
ensureSavegameDirectoryExists(androidContext);
return new FileOutputStream(getSlotFile(slot, androidContext));
}
}
private static FileOutputStream getOutputFile(Context androidContext, int slot) throws IOException {
if (slot == SLOT_QUICKSAVE) {
return androidContext.openFileOutput(Constants.FILENAME_SAVEGAME_QUICKSAVE, Context.MODE_PRIVATE);
} else {
ensureSavegameDirectoryExists(androidContext);
return new FileOutputStream(getSlotFile(slot, androidContext));
}
}
private static void ensureSavegameDirectoryExists(Context context) {
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
ensureDirExists(dir);
}
private static void ensureSavegameDirectoryExists(Context context) {
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
ensureDirExists(dir);
}
public static boolean ensureDirExists(File dir) {
if (!dir.exists()) {
boolean worked = dir.mkdir();
return worked;
}
return true;
}
public static boolean ensureDirExists(File dir) {
if (!dir.exists()) {
boolean worked = dir.mkdir();
return worked;
}
return true;
}
private static FileInputStream getInputFile(Context androidContext, int slot) throws IOException {
if (slot == SLOT_QUICKSAVE) {
return androidContext.openFileInput(Constants.FILENAME_SAVEGAME_QUICKSAVE);
} else {
return new FileInputStream(getSlotFile(slot, androidContext));
}
}
private static FileInputStream getInputFile(Context androidContext, int slot) throws IOException {
if (slot == SLOT_QUICKSAVE) {
return androidContext.openFileInput(Constants.FILENAME_SAVEGAME_QUICKSAVE);
} else {
return new FileInputStream(getSlotFile(slot, androidContext));
}
}
public static File getSlotFile(int slot, Context context) {
File root = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
return getSlotFile(slot, root);
}
public static File getSlotFile(int slot, Context context) {
File root = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
return getSlotFile(slot, root);
}
public static File getSlotFile(int slot, File directory) {
return new File(directory, getSlotFileName(slot));
}
public static File getSlotFile(int slot, File directory) {
return new File(directory, getSlotFileName(slot));
}
public static String getSlotFileName(int slot) {
return Constants.FILENAME_SAVEGAME_FILENAME_PREFIX + slot;
}
public static String getSlotFileName(int slot) {
return Constants.FILENAME_SAVEGAME_FILENAME_PREFIX + slot;
}
public static void saveWorld(WorldContext world, OutputStream outStream, String displayInfo) throws IOException, DigestException {
public static void saveWorld(WorldContext world, OutputStream outStream, String displayInfo) throws IOException {
DataOutputStream dest = new DataOutputStream(outStream);
FileHeader.writeToParcel(dest, world.model.player.getName(),
displayInfo, world.model.player.iconID,
world.model.statistics.isDead(),
world.model.statistics.hasUnlimitedSaves(),
world.model.player.id,
world.model.player.savedVersion,
world.model.statistics.getIsAlteredSavegame());
byte[] checksum = world.getChecksum();
world.model.statistics.setChecksum(checksum);
world.model.player.savedVersion);
world.maps.writeToParcel(dest, world);
world.model.writeToParcel(dest);
dest.close();
}
public static LoadSavegameResult loadWorld(Resources res, WorldContext world, ControllerContext controllers, Context androidContext, InputStream inState, FileHeader fh) throws IOException, DigestException {
DataInputStream src = new DataInputStream(inState);
final FileHeader header = new FileHeader(src, fh.skipIcon);
if (header.fileversion > AndorsTrailApplication.CURRENT_VERSION)
return LoadSavegameResult.savegameIsFromAFutureVersion;
public static LoadSavegameResult loadWorld(Resources res, WorldContext world, ControllerContext controllers, InputStream inState, FileHeader fh) throws IOException {
DataInputStream src = new DataInputStream(inState);
final FileHeader header = new FileHeader(src, fh.skipIcon);
if (header.fileversion > AndorsTrailApplication.CURRENT_VERSION)
return LoadSavegameResult.savegameIsFromAFutureVersion;
world.maps.readFromParcel(src, world, controllers, header.fileversion);
world.model = new ModelContainer(src, world, controllers, header.fileversion);
src.close();
if (header.fileversion >= 81) {
checkChecksum(world);
}
WorldMapController.populateWorldMap(androidContext, world, controllers.getResources());
if (header.fileversion < 45) {
LegacySavegamesContentAdaptations.adaptToNewContentForVersion45(world, controllers, res);
}
onWorldLoaded(res, world, controllers);
return LoadSavegameResult.success;
}
private static void checkChecksum(WorldContext world) throws DigestException {
byte[] checksum = world.getChecksum();
if (!world.model.statistics.compareChecksum(checksum)) {
world.model.statistics.markAsAlteredSavegame();
}
}
private static void onWorldLoaded(Resources res, WorldContext world, ControllerContext controllers) {
controllers.actorStatsController.recalculatePlayerStats(world.model.player);
controllers.mapController.resetMapsNotRecentlyVisited();
@@ -284,15 +266,15 @@ public final class Savegames {
}
}
private static void writeCheatCheck(Context androidContext, long savedVersion, String playerId) throws IOException {
File cheatDetectionFolder = AndroidStorage.getStorageDirectory(androidContext, Constants.CHEAT_DETECTION_FOLDER);
ensureDirExists(cheatDetectionFolder);
File cheatDetectionFile = new File(cheatDetectionFolder, playerId);
FileOutputStream fileOutputStream = new FileOutputStream(cheatDetectionFile);
DataOutputStream dataOutputStream = new DataOutputStream(fileOutputStream);
CheatDetection.writeToParcel(dataOutputStream, savedVersion);
dataOutputStream.close();
fileOutputStream.close();
private static void writeCheatCheck(Context androidContext, long savedVersion, String playerId) throws IOException {
File cheatDetectionFolder = AndroidStorage.getStorageDirectory(androidContext, Constants.CHEAT_DETECTION_FOLDER);
ensureDirExists(cheatDetectionFolder);
File cheatDetectionFile = new File(cheatDetectionFolder, playerId);
FileOutputStream fileOutputStream = new FileOutputStream(cheatDetectionFile);
DataOutputStream dataOutputStream = new DataOutputStream(fileOutputStream);
CheatDetection.writeToParcel(dataOutputStream, savedVersion);
dataOutputStream.close();
fileOutputStream.close();
fileOutputStream = androidContext.openFileOutput(playerId, Context.MODE_PRIVATE);
dataOutputStream = new DataOutputStream(fileOutputStream);
@@ -303,26 +285,26 @@ public final class Savegames {
private static final Pattern savegameFilenamePattern = Pattern.compile(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX + "(\\d+)");
public static List<Integer> getUsedSavegameSlots(Context context) {
try {
final List<Integer> result = new ArrayList<Integer>();
AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY).listFiles(new FilenameFilter() {
@Override
public boolean accept(File f, String filename) {
Matcher m = savegameFilenamePattern.matcher(filename);
if (m != null && m.matches()) {
result.add(Integer.parseInt(m.group(1)));
return true;
}
return false;
}
});
Collections.sort(result);
return result;
} catch (Exception e) {
return new ArrayList<Integer>();
}
}
public static List<Integer> getUsedSavegameSlots(Context context) {
try {
final List<Integer> result = new ArrayList<Integer>();
AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY).listFiles(new FilenameFilter() {
@Override
public boolean accept(File f, String filename) {
Matcher m = savegameFilenamePattern.matcher(filename);
if (m != null && m.matches()) {
result.add(Integer.parseInt(m.group(1)));
return true;
}
return false;
}
});
Collections.sort(result);
return result;
} catch (Exception e) {
return new ArrayList<Integer>();
}
}
private static final class CheatDetection {
public final int fileversion;
@@ -342,17 +324,16 @@ public final class Savegames {
}
public static final class FileHeader {
public final int fileversion;
public final String playerName;
public final String displayInfo;
public final int iconID;
public final boolean isAlteredSavegame;
public boolean skipIcon = false;
public final boolean isDead;
public final boolean hasUnlimitedSaves;
public final String playerId;
public final long savedVersion;
public static final class FileHeader {
public final int fileversion;
public final String playerName;
public final String displayInfo;
public final int iconID;
public boolean skipIcon = false;
public final boolean isDead;
public final boolean hasUnlimitedSaves;
public final String playerId;
public final long savedVersion;
public String describe() {
return (fileversion == AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION ? "(D) " : "") + playerName + ", " + displayInfo;
@@ -361,18 +342,18 @@ public final class Savegames {
// ====== PARCELABLE ===================================================================
public FileHeader(DataInputStream src, boolean skipIcon) throws IOException {
int fileversion = src.readInt();
if (fileversion == 11)
fileversion = 5; // Fileversion 5 had no version identifier, but the first byte was 11.
this.fileversion = fileversion;
if (fileversion >= 14) { // Before fileversion 14 (0.6.7), we had no file header.
this.playerName = src.readUTF();
this.displayInfo = src.readUTF();
} else {
this.playerName = null;
this.displayInfo = null;
}
public FileHeader(DataInputStream src, boolean skipIcon) throws IOException {
int fileversion = src.readInt();
if (fileversion == 11)
fileversion = 5; // Fileversion 5 had no version identifier, but the first byte was 11.
this.fileversion = fileversion;
if (fileversion >= 14) { // Before fileversion 14 (0.6.7), we had no file header.
this.playerName = src.readUTF();
this.displayInfo = src.readUTF();
} else {
this.playerName = null;
this.displayInfo = null;
}
if (fileversion >= 43) {
int id = src.readInt();
@@ -397,14 +378,9 @@ public final class Savegames {
this.playerId = "";
this.savedVersion = 0;
}
if(fileversion >= 81){
this.isAlteredSavegame = src.readBoolean();
}else{
this.isAlteredSavegame = false;
}
}
public static void writeToParcel(DataOutputStream dest, String playerName, String displayInfo, int iconID, boolean isDead, boolean hasUnlimitedSaves, String playerId, long savedVersion, boolean isAlteredSavegame) throws IOException {
public static void writeToParcel(DataOutputStream dest, String playerName, String displayInfo, int iconID, boolean isDead, boolean hasUnlimitedSaves, String playerId, long savedVersion) throws IOException {
dest.writeInt(AndorsTrailApplication.CURRENT_VERSION);
dest.writeUTF(playerName);
dest.writeUTF(displayInfo);
@@ -413,7 +389,6 @@ public final class Savegames {
dest.writeBoolean(hasUnlimitedSaves);
dest.writeUTF(playerId);
dest.writeLong(savedVersion);
dest.writeBoolean(isAlteredSavegame);
}
}
}

View File

@@ -1,7 +1,5 @@
package com.gpl.rpg.AndorsTrail.util;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -49,9 +47,4 @@ public final class Coord {
dest.writeInt(x);
dest.writeInt(y);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(x);
builder.add(y);
}
}

View File

@@ -30,18 +30,6 @@ public final class CoordRect {
return true;
}
public static CoordRect union(CoordRect r1, CoordRect r2) {
int left = Math.min(r1.topLeft.x, r2.topLeft.x);
int top = Math.min(r1.topLeft.y, r2.topLeft.y);
int right = Math.max(r1.topLeft.x + r1.size.width, r2.topLeft.x + r2.size.width);
int bottom = Math.max(r1.topLeft.y + r1.size.height, r2.topLeft.y + r2.size.height);
int width = right - left;
int height = bottom - top;
return new CoordRect(new Coord(left, top), new Size(width, height));
}
/*
public static boolean contains(final int x, final int y, final Size size, final Coord p) {
if (p.x < x) return false;

View File

@@ -1,7 +1,5 @@
package com.gpl.rpg.AndorsTrail.util;
import com.gpl.rpg.AndorsTrail.model.ChecksumBuilder;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -101,9 +99,4 @@ public final class Range {
dest.writeInt(max);
dest.writeInt(current);
}
public void addToChecksum(ChecksumBuilder builder) {
builder.add(max);
builder.add(current);
}
}

View File

@@ -292,8 +292,6 @@ public final class DisplayActiveActorConditionIcons implements ActorConditionLis
}
if (condition.duration == ActorCondition.DURATION_FOREVER || condition.duration == ActorCondition.DURATION_NONE) {
duration = "\u221e";
} else if (condition.duration == ActorCondition.DURATION_FOREVER_UNTIL_SLEEP) {
duration = "";
} else {
duration = Integer.toString(condition.duration);
}

View File

@@ -1,7 +1,6 @@
package com.gpl.rpg.AndorsTrail.view;
import java.lang.ref.WeakReference;
import java.util.List;
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
@@ -159,8 +158,8 @@ public final class MainView extends SurfaceView
// this.surfaceSize = new Size(w, h);
this.surfaceSize = new Size((int) (getWidth() / scale), (int) (getHeight() / scale));
this.screenSizeTileCount = new Size(
getWidth() / scaledTileSize
,getHeight() / scaledTileSize
(int) Math.floor(getWidth() / scaledTileSize)
,(int) Math.floor(getHeight() / scaledTileSize)
);
if (sh.getSurfaceFrame().right != surfaceSize.width || sh.getSurfaceFrame().bottom != surfaceSize.height) {
@@ -227,28 +226,28 @@ public final class MainView extends SurfaceView
if (scrolling && why != RedrawAllDebugReason.MapScrolling) return;
if (!scrolling && movingSprites > 0 && why != RedrawAllDebugReason.SpriteMoved) return;
}
redrawArea_(mapViewArea, null);
redrawArea_(mapViewArea, null, 0, 0);
}
private void redrawTile(final Coord p, RedrawTileDebugReason why) {
if (scrolling) return;
p1x1.topLeft.set(p);
redrawArea_(p1x1, null);
redrawArea_(p1x1, null, 0, 0);
}
private void redrawArea(final CoordRect area, RedrawAreaDebugReason why) {
if (scrolling) return;
redrawArea_(area, null);
redrawArea_(area, null, 0, 0);
}
private void redrawArea_(CoordRect area, final List<VisualEffectAnimation> effects) {
private void redrawArea_(CoordRect area, final VisualEffectAnimation effect, int tileID, int textYOffset) {
if (!hasSurface) return;
if (!currentMap.intersects(area)) return;
if (!mapViewArea.intersects(area)) return;
if (shouldRedrawEverything()) {
area = mapViewArea;
}
calculateRedrawRect(area);
redrawRect.intersect(redrawClip);
Canvas c = null;
@@ -264,7 +263,7 @@ public final class MainView extends SurfaceView
if (area == mapViewArea) {
area = adaptAreaToScrolling(area);
}
synchronized (holder) { synchronized (tiles) {
int xScroll = 0;
int yScroll = 0;
@@ -276,25 +275,32 @@ public final class MainView extends SurfaceView
}
c.clipRect(redrawClip);
c.translate(screenOffset.x + xScroll, screenOffset.y + yScroll);
// c.scale(scale, scale);
doDrawRect(c, area);
renderEffects(c, effects);
if (effect != null) {
drawFromMapPosition(c, area, effect.position, tileID);
if (effect.displayText != null) {
drawEffectText(c, area, effect, textYOffset, effect.getTextPaint());
}
}
// c.drawRect(new Rect(
// (area.topLeft.x - mapViewArea.topLeft.x) * tileSize,
// (area.topLeft.y - mapViewArea.topLeft.y) * tileSize,
// (area.topLeft.x - mapViewArea.topLeft.x + area.size.width) * tileSize - 1,
// (area.topLeft.y - mapViewArea.topLeft.y + area.size.height) * tileSize - 1),
// redrawHighlight);
// if (touchedTile != null) c.drawRect(new Rect(
// (touchedTile.x - mapViewArea.topLeft.x) * tileSize,
// (touchedTile.y - mapViewArea.topLeft.y) * tileSize,
// (touchedTile.x - mapViewArea.topLeft.x + 1) * tileSize - 1,
// (touchedTile.y - mapViewArea.topLeft.y + 1) * tileSize - 1),
// touchHighlight);
} }
} finally {
if (c != null) holder.unlockCanvasAndPost(c);
}
}
private void renderEffects(Canvas canvas ,List<VisualEffectAnimation> effects) {
if(effects == null) return;
for (VisualEffectAnimation effect : effects) {
int tileID = effect.tileID;
int textYOffset = effect.textYOffset;
drawFromMapPosition(canvas, effect.area, effect.position, tileID);
if (effect.displayText != null) {
drawEffectText(canvas, effect.area, effect, textYOffset, effect.getTextPaint());
}
}
}
private boolean isRedrawRectWholeScreen(Rect redrawRect) {
// if (redrawRect.width() < mapViewArea.size.width * scaledTileSize) return false;
@@ -311,21 +317,11 @@ public final class MainView extends SurfaceView
return true;
}
private final Rect redrawRect = new Rect();
private void redrawAreaWithEffect(List<VisualEffectAnimation> effects) {
CoordRect area = null;
for (int i = 0; i < effects.size(); i++) {
VisualEffectAnimation effect = effects.get(i);
if (area == null) {
area = effect.area;
} else {
area = CoordRect.union(area, effect.area);
}
}
if (area != null) {
redrawArea_(area, effects);
}
private void redrawAreaWithEffect(final VisualEffectAnimation effect, int tileID, int textYOffset) {
CoordRect area = effect.area;
// if (shouldRedrawEverythingForVisualEffect()) area = mapViewArea;
redrawArea_(area, effect, tileID, textYOffset);
}
private void clearCanvas() {
if (!hasSurface) return;
Canvas c = null;
@@ -798,8 +794,8 @@ public final class MainView extends SurfaceView
}
@Override
public void onNewAnimationFrames(List<VisualEffectAnimation> effects) {
redrawAreaWithEffect(effects);
public void onNewAnimationFrame(VisualEffectAnimation animation, int tileID, int textYOffset) {
redrawAreaWithEffect(animation, tileID, textYOffset);
}
@Override

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More