From cff7ca4683c5fcdf3b7e644fea2c6d68c6850aeb Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 15 Mar 2020 02:18:25 +0900 Subject: [PATCH] Added Event Syncing --- .settings/org.eclipse.core.resources.prefs | 1 + src/sig/modules/RabiRace/Profile.java | 36 ++++++++++++++++++---- src/sig/modules/RabiRaceModule.java | 9 +++++- src/sig/modules/RabiRibi/MemoryOffset.java | 3 ++ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 4a83177..06a641d 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding//src/sig/modules/RabiRace/SessionCreateWindow.java=UTF-8 encoding//src/sig/modules/RabiRace/SessionListWindow.java=UTF-8 +encoding//src/sig/modules/RabiRibi/MemoryOffset.java=UTF-8 diff --git a/src/sig/modules/RabiRace/Profile.java b/src/sig/modules/RabiRace/Profile.java index 4536456..67b9fb9 100644 --- a/src/sig/modules/RabiRace/Profile.java +++ b/src/sig/modules/RabiRace/Profile.java @@ -24,11 +24,13 @@ import java.util.Random; import sig.ScrollingText; import sig.sigIRC; import sig.modules.RabiRaceModule; +import sig.modules.RabiRibi.MemoryOffset; import sig.utils.DrawUtils; import sig.utils.FileUtils; import sig.utils.TextUtils; public class Profile { + public static final int EVENT_COUNT = 265; public String username = sigIRC.nickname.toLowerCase(); public String displayName = sigIRC.nickname; public Avatar avatar; @@ -38,6 +40,7 @@ public class Profile { public String manaUps = "0000000000000000000000000000000000000000000000000000000000000000"; public String regenUps = "0000000000000000000000000000000000000000000000000000000000000000"; public String packUps = "0000000000000000000000000000000000000000000000000000000000000000"; + public String eventStruct = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; public int rainbowEggs = 0; public boolean isPaused = false; public int difficulty = 0; @@ -192,19 +195,19 @@ public class Profile { } String announcement = ""; if (GetHealthUpCount(oldProfile)==GetHealthUpCount(this)-1) { - announcement = "has obtained a Health Up! ("+healthUps+" total)"; + announcement = "has obtained a Health Up! ("+GetHealthUpCount(this)+" total)"; } if (GetAttackUpCount(oldProfile)==GetAttackUpCount(this)-1) { - announcement = "has obtained an Attack Up! ("+attackUps+" total)"; + announcement = "has obtained an Attack Up! ("+GetAttackUpCount(this)+" total)"; } if (GetManaUpCount(oldProfile)==GetManaUpCount(this)-1) { - announcement = "has obtained a Mana Up! ("+manaUps+" total)"; + announcement = "has obtained a Mana Up! ("+GetManaUpCount(this)+" total)"; } if (GetRegenUpCount(oldProfile)==GetRegenUpCount(this)-1) { - announcement = "has obtained a Regen Up! ("+regenUps+" total)"; + announcement = "has obtained a Regen Up! ("+GetRegenUpCount(this)+" total)"; } if (GetPackUpCount(oldProfile)==GetPackUpCount(this)-1) { - announcement = "has obtained a Pack Up! ("+packUps+" total)"; + announcement = "has obtained a Pack Up! ("+GetPackUpCount(this)+" total)"; } if (GetRainbowEggCount(oldProfile)==GetRainbowEggCount(this)-1) { if (RabiRaceModule.mySession!=null && @@ -270,6 +273,17 @@ public class Profile { badges.remove(md); } } + StringBuilder events = new StringBuilder(); + for (int i=0;i9 || val<0) { + System.out.println("WARNING! Event "+(256+i)+" has a value greater than 9 or negative number! Truncating to 1 value."); + events.append(Integer.toString(val).charAt(0)); + } else { + events.append(val); + } + } + eventStruct = events.toString(); } public void uploadProfile() { @@ -300,7 +314,7 @@ public class Profile { } String[] data = FileUtils.readFromFile(sigIRC.BASEDIR+"tmp_profile"); //System.out.println(Arrays.toString(data)); - if (data.length>=19) { + if (data.length>=21) { int i=0; displayName = data[i++]; try { @@ -343,6 +357,14 @@ public class Profile { } while (!nextval.equalsIgnoreCase("UPDATES:")); } + nextval = data[i++]; + if (!nextval.equalsIgnoreCase("END")) { + do { + eventStruct = nextval; + nextval = data[i++]; + } + while (!nextval.equalsIgnoreCase("END")); + } lastWebUpdate = System.currentTimeMillis(); return true; @@ -380,6 +402,8 @@ public class Profile { appendData(data.name()+";"+val,sb); } appendData("UPDATES:",sb); + appendData(eventStruct,sb); + appendData("END",sb); return sb.toString(); } diff --git a/src/sig/modules/RabiRaceModule.java b/src/sig/modules/RabiRaceModule.java index 7377ae9..34dba46 100644 --- a/src/sig/modules/RabiRaceModule.java +++ b/src/sig/modules/RabiRaceModule.java @@ -245,7 +245,7 @@ public class RabiRaceModule extends Module{ boolean soundPlayed=false; if (mySession!=null) { for (Profile p : mySession.getPlayers()) { - if (p!=myProfile && !p.isPaused) { + if (p!=myProfile && !p.isPaused && !myProfile.isPaused) { boolean updateRequired=false; for (MemoryData m : p.key_items.keySet()) { if (p.key_items.get(m)!=0 && (!myProfile.key_items.containsKey(m) || myProfile.key_items.get(m)==0)) { @@ -286,6 +286,13 @@ public class RabiRaceModule extends Module{ UpdateRange(MemoryOffset.ATTACKUP_START,MemoryOffset.ATTACKUP_END,p.attackUps); updateRequired=true; } + if (!p.eventStruct.equalsIgnoreCase(myProfile.eventStruct)) { + StringBuilder finalevents = new StringBuilder(); + for (int i=0;i