mirror of
https://github.com/skogaby/butterfly.git
synced 2026-04-24 23:46:57 -05:00
Save the 'LAST' CSV values to the database as-is and return them as-is until we figure out more offsets. This resolves the issue of sort option not saving correctly.
This commit is contained in:
parent
e02d74fafa
commit
6c8ae17bae
|
|
@ -80,4 +80,22 @@ public class UserSongRecordDao extends AbstractHibernateDao<UserSongRecord> {
|
|||
this.closeCurrentSession();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the latest score for a given user, so we can make sure they start on the last song they played
|
||||
* @param user The user of the records
|
||||
* @return The latest record
|
||||
*/
|
||||
public UserSongRecord findLatestScoreForUser(final UserProfile user) {
|
||||
this.openCurrentSession();
|
||||
|
||||
final Query<UserSongRecord> query = this.currentSession.createQuery(
|
||||
"from UserSongRecord r where r.user = :user order by r.endtime desc")
|
||||
.setMaxResults(1);
|
||||
query.setParameter("user", user);
|
||||
final UserSongRecord result = query.uniqueResult();
|
||||
|
||||
this.closeCurrentSession();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ public class PlayerDataRequestHandler extends BaseRequestHandler {
|
|||
private static final int GAME_OPTION_COMBO_POSITION_OFFSET = 15;
|
||||
private static final int GAME_OPTION_FAST_SLOW_OFFSET = 16;
|
||||
|
||||
private static final int GAME_LAST_SONG_OFFSET = 3;
|
||||
private static final int GAME_LAST_CALORIES_OFFSET = 10;
|
||||
|
||||
private static final int GAME_RIVAL_SLOT_1_ACTIVE_OFFSET = 1;
|
||||
|
|
@ -485,12 +486,15 @@ public class PlayerDataRequestHandler extends BaseRequestHandler {
|
|||
final int dancerCode = new Random().nextInt(99999999);
|
||||
String dancerCodeStr = String.format("%08d", dancerCode);
|
||||
dancerCodeStr = dancerCodeStr.substring(0, 4) + "-" + dancerCodeStr.substring(4, 8);
|
||||
// TODO: Figure out what all these are. Right now we're just saving it as-is and sending it back as-is for the
|
||||
// next session and that seems to be working...
|
||||
final String defaultLastCsv = "1,6c76656c,3431766c,1ad,3,1,3,4,1,7753ba,b65b5,8000000000000001,8000000000000001,0,0,5c2d1455,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,,,,,,,";
|
||||
|
||||
profile = new UserProfile(card.getUser(), null, dancerCode, 33, true, 0, 0, 0, -1, 0.0, DancerOption.RANDOM,
|
||||
SpeedOption.X_1_00, BoostOption.NORMAL, AppearanceOption.VISIBLE, TurnOption.OFF, StepZoneOption.ON,
|
||||
ScrollOption.NORMAL, ArrowColorOption.RAINBOW, CutOption.OFF, FreezeArrowOption.ON, JumpsOption.ON,
|
||||
ArrowSkinOption.NORMAL, ScreenFilterOption.OFF, GuideLinesOption.ARROW_CENTER, LifeGaugeOption.NORMAL,
|
||||
JudgementLayerOption.BACKGROUND, true, 0, null, null, null);
|
||||
JudgementLayerOption.BACKGROUND, true, 0, null, null, null, defaultLastCsv);
|
||||
this.profileDao.create(profile);
|
||||
|
||||
// send the response
|
||||
|
|
@ -695,10 +699,14 @@ public class PlayerDataRequestHandler extends BaseRequestHandler {
|
|||
* @return The CSV string.
|
||||
*/
|
||||
private String buildLastCsv(final UserProfile profile) {
|
||||
final String[] elems = "1,6c76656c,3431766c,9440,3,1,3,4,1,7753ba,b65b5,8000000000000001,8000000000000001,0,0,5c2d1455,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,,,,,,,".split(",", -1);
|
||||
final String[] elems = profile.getUnkLast().split(",", -1);
|
||||
|
||||
// modify the contents to send back
|
||||
elems[GAME_LAST_CALORIES_OFFSET] = Integer.toHexString(profile.getLastCalories());
|
||||
// modify the last song to be whatever they last played
|
||||
final UserSongRecord lastScore = this.songRecordDao.findLatestScoreForUser(profile);
|
||||
|
||||
if (lastScore != null) {
|
||||
elems[GAME_LAST_SONG_OFFSET] = Integer.toHexString(lastScore.getSongId());
|
||||
}
|
||||
|
||||
return String.join(",", elems);
|
||||
}
|
||||
|
|
@ -819,6 +827,7 @@ public class PlayerDataRequestHandler extends BaseRequestHandler {
|
|||
final int lastCalories = Integer.parseInt(last[GAME_LAST_CALORIES_OFFSET], 16);
|
||||
|
||||
profile.setLastCalories(lastCalories);
|
||||
profile.setUnkLast(String.join(",", last));
|
||||
}
|
||||
|
||||
// parse out RIVAL values
|
||||
|
|
|
|||
|
|
@ -193,6 +193,10 @@ public class UserProfile implements Externalizable {
|
|||
@JoinColumn(name = "rival_3_id")
|
||||
private UserProfile rival3;
|
||||
|
||||
/** The rest of the CSV values for the LAST column in the profile response that we don't know, but they're probably important to save */
|
||||
@Column(name = "unk_last", columnDefinition = "TEXT")
|
||||
private String unkLast;
|
||||
|
||||
public UserProfile() { }
|
||||
|
||||
public UserProfile(ButterflyUser user, String name, int dancerCode, int area, boolean displayWeight, int extraCharge,
|
||||
|
|
@ -202,7 +206,8 @@ public class UserProfile implements Externalizable {
|
|||
ArrowColorOption arrowColorOption, CutOption cutOption, FreezeArrowOption freezeArrowOption,
|
||||
JumpsOption jumpsOption, ArrowSkinOption arrowSkinOption, ScreenFilterOption screenFilterOption,
|
||||
GuideLinesOption guideLinesOption, LifeGaugeOption lifeGaugeOption, JudgementLayerOption judgementLayerOption,
|
||||
boolean showFastSlow, int lastCalories, UserProfile rival1, UserProfile rival2, UserProfile rival3) {
|
||||
boolean showFastSlow, int lastCalories, UserProfile rival1, UserProfile rival2, UserProfile rival3,
|
||||
String unkLast) {
|
||||
this.user = user;
|
||||
this.name = name;
|
||||
this.dancerCode = dancerCode;
|
||||
|
|
@ -234,6 +239,7 @@ public class UserProfile implements Externalizable {
|
|||
this.rival1 = rival1;
|
||||
this.rival2 = rival2;
|
||||
this.rival3 = rival3;
|
||||
this.unkLast = unkLast;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -270,6 +276,7 @@ public class UserProfile implements Externalizable {
|
|||
out.writeObject(this.rival1);
|
||||
out.writeObject(this.rival2);
|
||||
out.writeObject(this.rival3);
|
||||
out.writeUTF(this.unkLast);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -306,6 +313,7 @@ public class UserProfile implements Externalizable {
|
|||
this.setRival1((UserProfile) in.readObject());
|
||||
this.setRival2((UserProfile) in.readObject());
|
||||
this.setRival3((UserProfile) in.readObject());
|
||||
this.setUnkLast(in.readUTF());
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
|
|
@ -563,4 +571,12 @@ public class UserProfile implements Externalizable {
|
|||
public void setRival3(UserProfile rival3) {
|
||||
this.rival3 = rival3;
|
||||
}
|
||||
|
||||
public String getUnkLast() {
|
||||
return unkLast;
|
||||
}
|
||||
|
||||
public void setUnkLast(String unkLast) {
|
||||
this.unkLast = unkLast;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user