Completed implementation of Rabi-Race module. All intended functions are

now working.
dev
sigonasr2 7 years ago
parent b5277a8d8b
commit 776bedf358
  1. BIN
      sigIRCv2.jar
  2. 6
      src/sig/modules/Controller/ControlConfigurationWindow.java
  3. 3
      src/sig/modules/RabiRace/CreateButton.java
  4. 19
      src/sig/modules/RabiRace/JoinButton.java
  5. 129
      src/sig/modules/RabiRace/Profile.java
  6. 18
      src/sig/modules/RabiRace/Session.java
  7. 226
      src/sig/modules/RabiRace/SessionCreateWindow.java
  8. 13
      src/sig/modules/RabiRace/SessionListData.java
  9. 223
      src/sig/modules/RabiRace/SessionListWindow.java
  10. 136
      src/sig/modules/RabiRaceModule.java
  11. 1
      src/sig/modules/RabiRibi/MemoryOffset.java
  12. 18
      src/sig/sigIRC.java
  13. 6
      src/sig/utils/DebugUtils.java
  14. 6
      src/sig/utils/TextUtils.java

Binary file not shown.

@ -252,11 +252,7 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
this.twowayAxis_range1 = new LinkedTextField(twowayAxis_range1);
this.twowayAxis_range2 = new LinkedTextField(twowayAxis_range2);
this.setTitle("Axis Configuration Window");
try {
this.setIconImage(ImageIO.read(new File(sigIRC.BASEDIR+"/sigIRC/sigIRCicon.png")));
} catch (IOException e1) {
e1.printStackTrace();
}
this.setIconImage(sigIRC.programIcon);
switch (dialog) {
case AXIS_OPTIONS:

@ -4,6 +4,7 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import sig.Module;
import sig.modules.RabiRaceModule;
import sig.modules.Controller.ClickableButton;
public class CreateButton extends ClickableButton{
@ -13,6 +14,6 @@ public class CreateButton extends ClickableButton{
}
public void onClickEvent(MouseEvent ev) {
RabiRaceModule.createwindow.setVisible(true);
}
}

@ -2,8 +2,13 @@ package sig.modules.RabiRace;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import sig.Module;
import sig.sigIRC;
import sig.modules.RabiRaceModule;
import sig.modules.Controller.ClickableButton;
@ -14,6 +19,18 @@ public class JoinButton extends ClickableButton{
}
public void onClickEvent(MouseEvent ev) {
RabiRaceModule.module.window.setVisible(true);
if (RabiRaceModule.mySession==null) {
RabiRaceModule.module.window.setVisible(true);
} else {
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data");
try {
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=leavesession&name="+RabiRaceModule.module.myProfile.username+"&session="+RabiRaceModule.mySession.id),file);
RabiRaceModule.mySession=null;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@ -27,7 +27,7 @@ import sig.utils.TextUtils;
public class Profile {
public String username = sigIRC.nickname.toLowerCase();
public String displayName = sigIRC.nickname.toLowerCase();
public String displayName = sigIRC.nickname;
public int avatar = 0;
public int playtime = 0;
public int healthUps = 0;
@ -46,12 +46,98 @@ public class Profile {
public List<String> updates = new ArrayList<String>();
RabiRaceModule parent;
public long lastWebUpdate = System.currentTimeMillis();
DecimalFormat df = new DecimalFormat("00.0");
DecimalFormat df = new DecimalFormat("0.0");
Profile oldProfile;
public boolean isArchive = false;
public Profile(RabiRaceModule module) {
this(module,true);
}
public Profile(RabiRaceModule module, boolean archive) {
this.isArchive = archive;
if (!isArchive) {
oldProfile = new Profile(module,true);
}
this.parent = module;
}
public void archiveAllValues() {
oldProfile.healthUps = healthUps;
oldProfile.attackUps = attackUps;
oldProfile.manaUps = manaUps;
oldProfile.regenUps = regenUps;
oldProfile.packUps = packUps;
oldProfile.rainbowEggCount = rainbowEggCount;
oldProfile.key_items = (HashMap<MemoryData, Integer>)key_items.clone();
oldProfile.badges = (HashMap<MemoryData, Integer>)badges.clone();
}
public void compareAndAnnounceAllChangedValues() {
//System.out.println(oldProfile.key_items.get(MemoryData.HAMMER)+","+key_items.get(MemoryData.HAMMER));
String announcement = "";
int count=0;
if (oldProfile.healthUps==healthUps-1) {
announcement = "has obtained a Health Up! ("+healthUps+" total)";
count++;
}
if (oldProfile.attackUps==attackUps-1) {
announcement = "has obtained an Attack Up! ("+attackUps+" total)";
count++;
}
if (oldProfile.manaUps==manaUps-1) {
announcement = "has obtained a Mana Up! ("+manaUps+" total)";
count++;
}
if (oldProfile.regenUps==regenUps-1) {
announcement = "has obtained a Regen Up! ("+regenUps+" total)";
count++;
}
if (oldProfile.packUps==packUps-1) {
announcement = "has obtained a Pack Up! ("+packUps+" total)";
count++;
}
if (oldProfile.rainbowEggCount==rainbowEggCount-1) {
if (5-rainbowEggCount==0) {
announcement = "has obtained 5 Rainbow Eggs! (NAME) has completed the race!";
count++;
} else if (5-rainbowEggCount>0)
{
announcement = "has obtained a Rainbow Egg! ("+Math.max(5-rainbowEggCount, 0)+" to go!)";
count++;
}
}
for (MemoryData md : key_items.keySet()) {
if (!oldProfile.key_items.containsKey(md) &&
key_items.containsKey(md)) {
announcement = "has obtained "+md.name+"!";
count++;
}
}
for (MemoryData md : badges.keySet()) {
if (!oldProfile.badges.containsKey(md) &&
badges.containsKey(md)) {
announcement = "has obtained the "+md.name+" badge!";
count++;
}
}
if (count==1) {
SendAnnouncement(announcement);
}
}
private void SendAnnouncement(String string) {
string = displayName+" "+string.replaceAll("(NAME)", displayName);
string = string.replaceAll(" ", "%20");
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data");
try {
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=addupdate&session="+RabiRaceModule.mySession.id+"&message="+string),file);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void updateClientValues() {
for (MemoryData md : RabiRaceModule.key_items_list) {
//System.out.println("Checking "+md.getDisplayName());
@ -187,6 +273,7 @@ public class Profile {
g2.fillRect(1, 1, 32, 32);
g2.setColor(ScrollingText.GetUserNameColor(displayName));
DrawUtils.drawOutlineText(g2, sigIRC.panel.rabiRibiMoneyDisplayFont, 36, 26, 1, g2.getColor(), Color.BLACK, displayName);
DrawUtils.drawCenteredOutlineText(g2, sigIRC.panel.rabiRibiTinyDisplayFont, (int)(tmp.getWidth()*0.2), 50, 1, GetDifficultyColor(), Color.BLACK, GetDifficultyName());
String text = TextUtils.convertSecondsToTimeFormat(playtime/60);
if (isPaused) {
g2.setColor(new Color(128,96,0));
@ -201,6 +288,44 @@ public class Profile {
return tmp.getScaledInstance(w, -1, Image.SCALE_AREA_AVERAGING);
}
private Color GetDifficultyColor() {
Color[] color_list = new Color[]{
new Color(99, 159, 255),
new Color(119, 98, 255),
new Color(60, 201, 112),
new Color(200, 209, 100),
new Color(209, 159, 12),
new Color(209, 54, 11),
new Color(68, 24, 12),
};
Color colorval = Color.BLACK;
if (difficulty<color_list.length) {
colorval = color_list[difficulty];
} else {
colorval = color_list[color_list.length-1];
}
return colorval;
}
private String GetDifficultyName() {
String[] difficulty_list = new String[]{
"Casual",
"Novice",
"Normal",
"Hard",
"Hell",
"BEX",
"???",
};
String diffstring = "";
if (difficulty<difficulty_list.length) {
diffstring = difficulty_list[difficulty]+((loop>0)?" Loop "+loop:"");
} else {
diffstring = difficulty_list[difficulty_list.length-1]+((loop>0)?" Loop "+loop:"");
}
return diffstring;
}
public Image getStatPanel(int w) {
//DrawUtils.drawTextFont(g, sigIRC.panel.userFont, parent.position.getX(), parent.position.getY()+26, Color.BLACK, "Values: "+readIntFromMemory(MemoryOffset.DLC_ITEM1)+","+readIntFromMemory(MemoryOffset.DLC_ITEM2)+","+readIntFromMemory(MemoryOffset.DLC_ITEM3)+","+readIntFromMemory(MemoryOffset.DLC_ITEM4));
BufferedImage tmp = new BufferedImage(400,175,BufferedImage.TYPE_INT_ARGB);

@ -35,24 +35,38 @@ public class Session {
//System.out.println(Arrays.toString(playerlist));
if (playerlist.length>0) {
for (String s : playerlist) {
Profile p = new Profile(RabiRaceModule.module);
Profile p = new Profile(RabiRaceModule.module,true);
p.username=s;
//System.out.println("Player "+p.username);
p.downloadProfile();
if (RabiRaceModule.mySession==null && p.username.equalsIgnoreCase(RabiRaceModule.module.myProfile.username)) {
RabiRaceModule.mySession = this;
}
//System.out.println("Adding Player "+p);
players.add(p);
}
} else {
Profile p = new Profile(RabiRaceModule.module);
Profile p = new Profile(RabiRaceModule.module,true);
p.username=val;
//System.out.println("Player "+p.username);
p.downloadProfile();
if (RabiRaceModule.mySession==null && p.username.equalsIgnoreCase(RabiRaceModule.module.myProfile.username)) {
RabiRaceModule.mySession = this;
}
//System.out.println("Adding Player "+p);
players.add(p);
}
}
}
public int getID() {
return id;
}
public List<Profile> getPlayers() {
return players;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.getClass().getName()+"(");

@ -0,0 +1,226 @@
package sig.modules.RabiRace;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import sig.sigIRC;
import sig.modules.RabiRaceModule;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class SessionCreateWindow extends JFrame{
JPanel container = new JPanel();
LengthValidationField session_name = new LengthValidationField(16);
NumberValidationField maxplayers = new NumberValidationField();
JPasswordField pass = new JPasswordField();
JButton create = new JButton("Create");
public SessionCreateWindow() {
this.setTitle("Create Rabi-Race Session");
this.setIconImage(sigIRC.programIcon);
this.setVisible(false);
JPanel namepanel = new JPanel();
JPanel playerpanel = new JPanel();
JPanel passwordpanel = new JPanel();
JPanel[] panel_list = new JPanel[]{
namepanel,playerpanel,passwordpanel
};
for (JPanel panel : panel_list) {
panel.setLayout(new BoxLayout(panel,BoxLayout.LINE_AXIS));
panel.setSize(400, 24);
panel.setMinimumSize(new Dimension(400, 24));
panel.add(Box.createRigidArea(new Dimension(24,24)));
}
JLabel nameLabel = new JLabel("Session Name: ");
String label = RabiRaceModule.module.myProfile.displayName+"'s Race";
if (label.length()>16) {
label = "My Rabi-Race!";
}
session_name.setText(label);
namepanel.add(nameLabel);
namepanel.add(session_name);
JLabel playerLabel = new JLabel("Max Players: ");
maxplayers.setText("4");
playerpanel.add(playerLabel);
playerpanel.add(maxplayers);
JLabel passwordLabel = new JLabel("🔑 Password (Optional): ");
playerpanel.add(passwordLabel);
playerpanel.add(pass);
for (JPanel panel : panel_list) {
panel.add(Box.createRigidArea(new Dimension(24,24)));
}
create.setSize(164,24);
create.setMinimumSize(new Dimension(164,24));
create.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent ev) {
if (session_name.getText().length()>session_name.length) {
JOptionPane.showMessageDialog(RabiRaceModule.createwindow, "Your session name is too long!", "Error!", JOptionPane.WARNING_MESSAGE);
return;
}
if (session_name.getText().length()<=2) {
JOptionPane.showMessageDialog(RabiRaceModule.createwindow, "Your session name is too short!", "Error!", JOptionPane.WARNING_MESSAGE);
return;
}
if (!TextUtils.isAlphanumeric(session_name.getText())) {
JOptionPane.showMessageDialog(RabiRaceModule.createwindow, "Your session name has invalid characters! Only A-Z,0-9,!,-,.,? and spaces allowed!", "Error!", JOptionPane.WARNING_MESSAGE);
return;
}
if (!TextUtils.isInteger(maxplayers.getText(), 10)) {
JOptionPane.showMessageDialog(RabiRaceModule.createwindow, "Your max player count is invalid!", "Error!", JOptionPane.WARNING_MESSAGE);
return;
}
if (Integer.parseInt(maxplayers.getText())>48 || Integer.parseInt(maxplayers.getText())<2) {
JOptionPane.showMessageDialog(RabiRaceModule.createwindow, "Your max player count needs to be between 2-48!", "Error!", JOptionPane.WARNING_MESSAGE);
return;
}
String hashpass = "";
if (String.copyValueOf(pass.getPassword()).length()>0) {
hashpass = SessionListWindow.GetHashedPassword(String.copyValueOf(pass.getPassword()));
}
session_name.setText(session_name.getText().replaceAll(" ", "%20"));
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data");
try {
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=sessioncreate&name="+session_name.getText()+"&players="+maxplayers.getText()+"&password="+((hashpass.length()>0)?hashpass:"none")),file);
String[] contents = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/tmp.data");
int sessionID=-1;
if (contents.length>=2) {
sessionID=Integer.parseInt(contents[0]);
}
if (sessionID!=-1) {
RabiRaceModule.module.getSessionList();
//RabiRaceModule.module.session_listing.data.put(sessionID, new Session());
Session session = RabiRaceModule.module.session_listing.data.get(sessionID);
SessionListWindow.ConnectToSession(session, hashpass);
setVisible(false);
}
//SessionListWindow.ConnectToSession(session, hashedPass);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
//create.add(Box.createRigidArea(new Dimension(24,24)));
container.setLayout(new BoxLayout(container,BoxLayout.PAGE_AXIS));
container.add(Box.createRigidArea(new Dimension(24,24)));
container.add(namepanel);
container.add(playerpanel);
container.add(passwordpanel);
container.add(create);
container.add(Box.createRigidArea(new Dimension(24,24)));
this.add(container);
this.setSize(400, 192);
this.setMinimumSize(new Dimension(400, 192));
this.setMaximumSize(new Dimension(400, 192));
this.setResizable(false);
}
class LengthValidationField extends JTextField implements DocumentListener{
int length = 10;
public LengthValidationField(int maxLength) {
this.length = maxLength;
getDocument().addDocumentListener(this);
}
@Override
public void changedUpdate(DocumentEvent arg0) {
}
@Override
public void insertUpdate(DocumentEvent arg0) {
ValidateForm();
}
protected void ValidateForm() {
if (fieldIsInvalid()) {
setBackground(Color.RED);
} else {
setBackground(Color.WHITE);
}
}
@Override
public void removeUpdate(DocumentEvent arg0) {
ValidateForm();
}
protected boolean fieldIsInvalid() {
return getText().length()>length || getText().length()<=2 || !TextUtils.isAlphanumeric(getText());
}
}
class NumberValidationField extends JTextField implements DocumentListener{
public NumberValidationField() {
getDocument().addDocumentListener(this);
}
@Override
public void changedUpdate(DocumentEvent arg0) {
}
@Override
public void insertUpdate(DocumentEvent arg0) {
ValidateForm();
}
protected void ValidateForm() {
if (fieldIsInvalid()) {
setBackground(Color.RED);
} else {
setBackground(Color.WHITE);
}
}
@Override
public void removeUpdate(DocumentEvent arg0) {
ValidateForm();
}
protected boolean fieldIsInvalid() {
if (!TextUtils.isInteger(getText(), 10)) {
return true;
}
int val = Integer.parseInt(getText());
if (val>48 || val<2) {
return true;
}
return false;
}
}
}

@ -1,27 +1,28 @@
package sig.modules.RabiRace;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
public class SessionListData {
List<Session> data = new ArrayList<Session>();
HashMap<Integer,Session> data = new HashMap<Integer,Session>();
public SessionListData() {
}
public void UpdateData(String[] data) {
this.data.clear();
//this.data.clear();
for (String session : data) {
if (session.length()>0) {
//System.out.println("Adding session "+session);
this.data.add(new Session(session));
//this.data.add(new Session(session));
int sessionID = Integer.parseInt(session.split(",")[0]);
this.data.put(sessionID, new Session(session));
}
}
//System.out.println(this.data);
}
public List<Session> getSessions() {
public HashMap<Integer,Session> getSessions() {
return data;
}
}

@ -2,14 +2,36 @@ package sig.modules.RabiRace;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import sig.sigIRC;
import sig.modules.RabiRaceModule;
import sig.utils.DebugUtils;
import sig.utils.FileUtils;
public class SessionListWindow extends JFrame{
JPanel container = new JPanel();
@ -17,20 +39,99 @@ public class SessionListWindow extends JFrame{
public DefaultListModel<String> sessionlist_model = new DefaultListModel<String>();
public int selected = -1;
public DataPanel previewPanel = new DataPanel();
public JButton joinButton = new JButton("Join");
public JScrollPane scrolllist = new JScrollPane();
public PasswordBox box = new PasswordBox();
public String enteredPassword = "";
public SessionListWindow(){
this.setTitle("Rabi-Race Sessions List");
this.setIconImage(sigIRC.programIcon);
previewPanel.setWindow(this);
scrolllist.setViewportView(sessionlist);
scrolllist.setPreferredSize(new Dimension(160,150));
scrolllist.setMinimumSize(new Dimension(160,150));
scrolllist.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JPanel sessionPanel = new JPanel();
sessionlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
sessionlist.setLayoutOrientation(JList.VERTICAL);
sessionlist.setPreferredSize(new Dimension(120,150));
sessionlist.setVisibleRowCount(6);
sessionPanel.setLayout(new BoxLayout(sessionPanel,BoxLayout.PAGE_AXIS));
sessionPanel.setSize(130,200);
sessionPanel.setMinimumSize(new Dimension(130,200));
sessionPanel.add(scrolllist);
sessionPanel.add(Box.createRigidArea(new Dimension(10,10)));
sessionPanel.add(joinButton);
UpdateSessionList();
joinButton.setEnabled(false);
joinButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
if (sessionlist.getSelectedIndex()!=-1) {
selected = sessionlist.getSelectedIndex();
Session session = RabiRaceModule.module.session_listing.data.get(getSelectedID());
if (!session.password.equalsIgnoreCase("none")) {
box.displayPasswordBox();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleWithFixedDelay(()->{
if (enteredPassword.length()!=0) {
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data");
String hashedPass = GetHashedPassword(enteredPassword);
ConnectToSession(session, hashedPass);
enteredPassword="";
scheduler.shutdownNow();
}
}, 1000l, 1000l, TimeUnit.MILLISECONDS);
} else {
ConnectToSession(session, "");
}
if (RabiRaceModule.mySession!=null) {
setVisible(false);
}
//Attempt to join the session.
}
}
});
sessionlist.setModel(sessionlist_model);
sessionlist.addListSelectionListener(new ListSelectionListener() {
container.add(sessionlist);
@Override
public void valueChanged(ListSelectionEvent arg0) {
if (sessionlist.getSelectedIndex()!=-1) {
selected = sessionlist.getSelectedIndex();
Session session = RabiRaceModule.module.session_listing.data.get(getSelectedID());
if (RabiRaceModule.module.mySession==null &&
session.maxPlayers!=session.players.size()) {
joinButton.setEnabled(true);
} else {
joinButton.setEnabled(false);
}
} else {
joinButton.setEnabled(false);
}
}
});
container.add(Box.createRigidArea(new Dimension(10,1)));
container.add(sessionPanel);
container.add(Box.createRigidArea(new Dimension(10,1)));
container.add(previewPanel);
previewPanel.setPreferredSize(new Dimension(400,300));
@ -39,21 +140,81 @@ public class SessionListWindow extends JFrame{
this.setMinimumSize(new Dimension(640,480));
}
public static void ConnectToSession(Session session, String hashedPass) {
try {
if (hashedPass.length()==0) {
hashedPass="none";
}
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data");
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=joinsession&name="+RabiRaceModule.module.myProfile.username+"&session="+session.id+"&password="+hashedPass),file);
String[] data = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/tmp.data");
if (data.length==1) {
int errorCode = Integer.parseInt(data[0]);
switch (errorCode) {
case 400:
case 404:{
JOptionPane.showMessageDialog(RabiRaceModule.module.window, "Invalid format sent. Please contact the dev! This should not be happening! \n"+DebugUtils.getStackTrace(), "Error "+errorCode, JOptionPane.WARNING_MESSAGE);
}break;
case 403:{
JOptionPane.showMessageDialog(RabiRaceModule.module.window, "Session does not exist!", "Error "+errorCode, JOptionPane.WARNING_MESSAGE);
}break;
case 405:{
JOptionPane.showMessageDialog(RabiRaceModule.module.window, "Session room is full!", "Error "+errorCode, JOptionPane.WARNING_MESSAGE);
}break;
case 406:{
JOptionPane.showMessageDialog(RabiRaceModule.module.window, "Incorrect Password! "+hashedPass, "Error "+errorCode, JOptionPane.WARNING_MESSAGE);
}break;
case 0:{
RabiRaceModule.mySession = session;
}break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void run() {
this.repaint();
}
public static String GetHashedPassword(String input) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(input.getBytes());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
}
return sb.toString();
} catch (java.security.NoSuchAlgorithmException e) {
return null;
}
}
public void UpdateSessionList() {
selected = sessionlist.getSelectedIndex();
int selectedID = getSelectedID();
sessionlist_model.clear();
int count=0;
for (Session session : RabiRaceModule.module.session_listing.data) {
sessionlist_model.addElement(session.id+" - "+session.name+" ("+session.players.size()+"/"+session.maxPlayers+")");
for (Integer id : RabiRaceModule.module.session_listing.data.keySet()) {
Session session = RabiRaceModule.module.session_listing.data.get(id);
sessionlist_model.addElement((session.password.equalsIgnoreCase("none")?"":"🔑 ")+session.id+" - "+session.name+" ("+session.players.size()+"/"+session.maxPlayers+")");
if (id == selectedID && sessionlist_model.getSize()>count) {
sessionlist.setSelectedIndex(count);
}
count++;
}
if (count>=selected) {
sessionlist.setSelectedIndex(selected);
//System.out.println("Selected is "+selected);
//Try to find ID in list.
}
public int getSelectedID() {
if (selected!=-1) {
return Integer.parseInt(sessionlist_model.getElementAt(selected).replaceAll("🔑", "").split(" - ")[0].trim());
}
return -1;
}
class DataPanel extends JPanel{
@ -67,11 +228,59 @@ public class SessionListWindow extends JFrame{
//Axis.GetAxisIndicatorDisplay(g,window.ConstructTemporaryAxis(),0,0,window.axis_width,window.axis_height);
if (selected!=-1 &&
RabiRaceModule.module.session_listing.data.size()>selected) {
int selectedID = getSelectedID();
//Get the players from that session.
Session s = RabiRaceModule.module.session_listing.data.get(selected);
Session s = RabiRaceModule.module.session_listing.data.get(selectedID);
Profile.DrawMultiPanel(g,0,0,400,s.players);
}
}
}
class PasswordBox extends JFrame{
JPasswordField pass = new JPasswordField();
JButton okay = new JButton("Submit");
JPanel container = new JPanel();
public PasswordBox(){
this.setVisible(false);
container.setLayout(new BoxLayout(container,BoxLayout.PAGE_AXIS));
container.add(Box.createRigidArea(new Dimension(240,20)));
JPanel label_panel = new JPanel();
label_panel.setLayout(new BoxLayout(label_panel,BoxLayout.LINE_AXIS));
label_panel.add(Box.createRigidArea(new Dimension(20,5)));
JLabel label = new JLabel("Please enter the password required to join this session:");
label_panel.add(label);
label_panel.add(Box.createRigidArea(new Dimension(20,5)));
label.setLayout(new BoxLayout(label,BoxLayout.LINE_AXIS));
container.add(label_panel);
container.add(Box.createRigidArea(new Dimension(240,5)));
JPanel pass_row = new JPanel();
pass_row.setLayout(new BoxLayout(pass_row,BoxLayout.LINE_AXIS));
pass.setMinimumSize(new Dimension(120,20));
pass.setPreferredSize(new Dimension(120,20));
pass_row.setSize(240,20);
pass_row.add(Box.createRigidArea(new Dimension(20,5)));
pass_row.add(pass);
pass_row.add(Box.createRigidArea(new Dimension(20,5)));
okay.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent ev) {
enteredPassword = String.copyValueOf(pass.getPassword());
box.setVisible(false);
}
});
container.add(pass_row);
container.add(okay);
container.add(Box.createRigidArea(new Dimension(240,20)));
this.add(container);
this.pack();
}
public void displayPasswordBox() {
this.setVisible(true);
pass.setText("");
}
}
}

@ -9,6 +9,7 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@ -36,6 +37,8 @@ import sig.modules.RabiRace.CreateButton;
import sig.modules.RabiRace.JoinButton;
import sig.modules.RabiRace.MemoryData;
import sig.modules.RabiRace.Profile;
import sig.modules.RabiRace.Session;
import sig.modules.RabiRace.SessionCreateWindow;
import sig.modules.RabiRace.SessionListData;
import sig.modules.RabiRace.SessionListWindow;
import sig.modules.RabiRibi.MemoryOffset;
@ -43,6 +46,7 @@ import sig.modules.RabiRibi.MemoryType;
import sig.modules.utils.PsapiTools;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class RabiRaceModule extends Module{
final static String ITEMS_DIRECTORY = sigIRC.BASEDIR+"sigIRC/rabi-ribi/items/";
@ -53,9 +57,15 @@ public class RabiRaceModule extends Module{
public HANDLE rabiribiProcess = null;
public static HashMap<String,Image> image_map = new HashMap<String,Image>();
public static ColorCycler rainbowcycler = new ColorCycler(new Color(255,0,0,96),8);
Profile myProfile = new Profile(this);
public Profile myProfile = new Profile(this,false);
public static RabiRaceModule module;
public static SessionListWindow window;
public static SessionCreateWindow createwindow;
public static Session mySession;
boolean firstCheck=false;
public List<ScrollingText> messages = new ArrayList<ScrollingText>();
public static int lastScrollX = 0;
boolean firstUpdate=true;
public SessionListData session_listing = new SessionListData();
@ -71,6 +81,8 @@ public class RabiRaceModule extends Module{
module = this;
window = new SessionListWindow();
window.setVisible(false);
createwindow = new SessionCreateWindow();
createwindow.setVisible(false);
//System.out.println("Money value is: "+readIntFromMemory(MemoryOffset.MONEY));
}
@ -83,7 +95,19 @@ public class RabiRaceModule extends Module{
if (foundRabiRibi) {
myProfile.uploadProfile();
getSessionList();
getMessageUpdates();
//trimeadProfile.downloadProfile();
firstCheck=true;
if (mySession!=null) {
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data");
try {
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=keepalivesession&session="+mySession.getID()),file);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}, 5000, 5000, TimeUnit.MILLISECONDS);
ScheduledExecutorService scheduler2 = Executors.newScheduledThreadPool(1);
@ -138,7 +162,24 @@ public class RabiRaceModule extends Module{
create_button = new CreateButton(new Rectangle(122,(int)(position.getHeight()-18),120,18),"Create Session",this);
}
private void getSessionList() {
private void getMessageUpdates() {
File file = new File(sigIRC.BASEDIR+"sigIRC/messages");
try {
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=getupdates&name="+myProfile.username),file);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String[] data = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/messages");
for (String s : data) {
if (s.length()>0) {
messages.add(new ScrollingText(s,(int)(lastScrollX+position.getWidth()+24),(int)(position.getHeight()-28)));
}
}
}
public void getSessionList() {
File file = new File(sigIRC.BASEDIR+"sessions");
try {
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=getsessions"),file);
@ -148,15 +189,19 @@ public class RabiRaceModule extends Module{
} catch (IOException e) {
e.printStackTrace();
}
join_button.setButtonLabel("Join Session ("+session_listing.getSessions().size()+")");
if (mySession==null) {
join_button.setButtonLabel("Join Session ("+session_listing.getSessions().size()+")");
} else {
join_button.setButtonLabel("Leave Session");
}
window.UpdateSessionList();
}
public void mousePressed(MouseEvent ev) {
if (join_button.mouseInsideBounds(ev)) {
if (firstCheck && join_button.mouseInsideBounds(ev)) {
join_button.onClickEvent(ev);
}
if (create_button.mouseInsideBounds(ev)) {
if (firstCheck && mySession==null && create_button.mouseInsideBounds(ev)) {
create_button.onClickEvent(ev);
}
}
@ -211,26 +256,45 @@ public class RabiRaceModule extends Module{
if (window!=null) {
window.run();
}
for (int i=0;i<messages.size();i++) {
if (!messages.get(i).run()) {
messages.remove(i--);
}
}
if (lastScrollX>0) {
lastScrollX-=ScrollingText.SCROLLSPD;
}
}
}
private void UpdateMyProfile() {
if (foundRabiRibi) {
//System.out.println("Called.");
//int warp_counter = readIntFromMemory(MemoryOffset.WARP_TRANSITION_COUNTER);
//if (warp_counter==203 || warp_counter==141) {
int paused = readIntFromMemory(MemoryOffset.PAUSED);
float itempct = readFloatFromMemory(MemoryOffset.ITEM_PERCENT);
myProfile.isPaused = paused==1;
//System.out.println(itempct+","+paused);
if (paused==0 && itempct>=0) {
if (mySession!=null) {
myProfile.archiveAllValues();
}
myProfile.rainbowEggCount = readIntFromMemory(MemoryOffset.RAINBOW_EGG_COUNT);
myProfile.attackUps = readItemCountFromMemory(MemoryOffset.ATTACKUP_START,MemoryOffset.ATTACKUP_END);
myProfile.healthUps = readItemCountFromMemory(MemoryOffset.HEALTHUP_START,MemoryOffset.HEALTHUP_END);
myProfile.manaUps = readItemCountFromMemory(MemoryOffset.MANAUP_START,MemoryOffset.MANAUP_END);
myProfile.regenUps = readItemCountFromMemory(MemoryOffset.REGENUP_START,MemoryOffset.REGENUP_END);
myProfile.packUps = readItemCountFromMemory(MemoryOffset.PACKUP_START,MemoryOffset.PACKUP_END);
//myProfile.isPaused = readIntFromMemory(MemoryOffset.WARP_TRANSITION_COUNTER)==141;
myProfile.itempct = readFloatFromMemory(MemoryOffset.ITEM_PERCENT);
myProfile.itempct = itempct;
myProfile.mappct = readFloatFromMemory(MemoryOffset.MAP_PERCENT);
myProfile.playtime = readIntFromMemory(MemoryOffset.PLAYTIME);
myProfile.difficulty = readIntFromMemory(MemoryOffset.GAME_DIFFICULTY);
myProfile.loop = readIntFromMemory(MemoryOffset.GAME_LOOP);
myProfile.updateClientValues();
//}
if (mySession!=null && !firstUpdate) {
myProfile.compareAndAnnounceAllChangedValues();
}
firstUpdate=false;
}
}
}
@ -342,9 +406,57 @@ public class RabiRaceModule extends Module{
g.drawImage(myProfile.getStatText((int)position.getWidth()), (int)position.getX(), (int)position.getY(), sigIRC.panel);
//Profile.DrawMultiPanel(g, (int)(position.getX()), (int)(position.getY())+panel.getHeight(sigIRC.panel), (int)position.getWidth(), testing);
if (mySession!=null) {
List<Profile> sessionPlayers = new ArrayList<Profile>();
for (Profile p : mySession.getPlayers()) {
if (!p.username.equalsIgnoreCase(myProfile.username)) {
sessionPlayers.add(p);
}
}
Profile.DrawMultiPanel(g, (int)(position.getX()), (int)(position.getY())+panel.getHeight(sigIRC.panel), (int)position.getWidth(), sessionPlayers);
}
join_button.draw(g);
create_button.draw(g);
if (firstCheck) {
join_button.draw(g);
if (mySession==null) {
create_button.draw(g);
}
}
g.setColor(Color.BLACK);
g.fillRect((int)(position.getX()), (int)(position.getY()+position.getHeight()-28-20), (int)(position.getWidth()), 20);
for (int i=0;i<messages.size();i++) {
messages.get(i).draw(g);
}
}
}
class ScrollingText{
String msg;
int x;
int y;
Rectangle2D bounds;
final static int SCROLLSPD = 4;
public ScrollingText(String message, int x, int y) {
this.msg = message;
this.x = x;
this.y = y;
this.bounds = TextUtils.calculateStringBoundsFont(message, sigIRC.panel.rabiRibiTinyDisplayFont);
RabiRaceModule.lastScrollX += bounds.getWidth() + 96;
}
public boolean run() {
x-=SCROLLSPD;
if (x+bounds.getWidth()<0) {
return false;
}
return true;
}
public void draw(Graphics g) {
if (x<position.getWidth()) {
DrawUtils.drawOutlineText(g, sigIRC.panel.rabiRibiTinyDisplayFont, position.getX()+x, position.getY()+y-6, 2, Color.WHITE, Color.GRAY, msg);
}
}
}
}

@ -141,6 +141,7 @@ public enum MemoryOffset {
ITEM_PERCENT(0,0x13413E8),
MAP_PERCENT(0,0x13413E4),
RAINBOW_EGG_COUNT(0xD65FD4,0xD65FD4+OffsetHelper.KEY_ITEM_OFFSET_V175_TO_V1851),
PAUSED(0,0xC969A0),
;
long offset;

@ -43,6 +43,7 @@ import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
@ -157,6 +158,7 @@ public class sigIRC{
public static long channel_id = -1;
public static int lastSubEmoteUpdate = -1;
public static boolean autoUpdateProgram = true;
public static Image programIcon;
public static int subchannelCount = 0;
public static HashMap<Long,String> subchannelIds = new HashMap<Long,String>();
@ -242,6 +244,8 @@ public class sigIRC{
final String oauth = filedata[0];
Initialize();
WriteBreakToLogFile();
programClock.start();
@ -261,6 +265,14 @@ public class sigIRC{
InitializeIRCConnection(server, nickname, channel, oauth);
}
private static void Initialize() {
try {
programIcon = ImageIO.read(new File(sigIRC.BASEDIR+"/sigIRC/sigIRCicon.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
private static ConfigFile InitializeConfigurationFile() {
ConfigFile.configureDefaultConfiguration();
final String configname = "sigIRCv2.conf";
@ -607,11 +619,7 @@ public class sigIRC{
f.setLocation(windowX, windowY);
f.setSize(windowWidth, windowHeight);
try {
f.setIconImage(ImageIO.read(new File(sigIRC.BASEDIR+"/sigIRC/sigIRCicon.png")));
} catch (IOException e) {
e.printStackTrace();
}
f.setIconImage(programIcon);
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,64+rowobj.size()*rowSpacing);
if (sigIRC.overlayMode) {

@ -3,11 +3,15 @@ package sig.utils;
public class DebugUtils {
public static void showStackTrace() {
System.out.println("Trace:"+getStackTrace());
}
public static String getStackTrace() {
StackTraceElement[] stacktrace = new Throwable().getStackTrace();
StringBuilder stack = new StringBuilder("Mini stack tracer:");
for (int i=0;i<Math.min(10, stacktrace.length);i++) {
stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber());
}
System.out.println("Trace:"+stack);
return stack.toString();
}
}

@ -27,6 +27,10 @@ public class TextUtils {
return sourcestring;
}
public static boolean isAlphanumeric(String str) {
return str.matches("^[a-zA-Z0-9!\\-.? ]+$");
}
public static boolean isNumeric(String str)
{
return str.matches("-?\\d+(\\.\\d+)?"); //match a number with optional '-' and decimal.
@ -48,7 +52,7 @@ public class TextUtils {
StringBuilder sb = new StringBuilder();
int sec = seconds%60;
int min = (seconds/60)%60;
int hrs = (min/60)%60;
int hrs = (seconds/3600)%24;
if (hrs>0) {
if (hrs>=10) {
sb.append(hrs);

Loading…
Cancel
Save