summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/constants.h8
-rw-r--r--java/javautils.cpp86
-rw-r--r--java/javautils.h4
3 files changed, 49 insertions, 49 deletions
diff --git a/java/constants.h b/java/constants.h
index 80697ebe..61aa5687 100644
--- a/java/constants.h
+++ b/java/constants.h
@@ -7,7 +7,7 @@ namespace java
class constant
{
public:
- enum type_t : uint8_t
+ enum type_t : uint8_t
{
j_hole = 0, // HACK: this is a hole in the array, because java is crazy
j_string_data = 1,
@@ -145,7 +145,7 @@ namespace java
uint16_t descriptor_index;
} name_and_type;
};
- };
+ };
/**
* A helper class that represents the custom container used in Java class file for storage of constants
@@ -185,7 +185,7 @@ namespace java
index++;
}
}
- }
+ }
typedef std::vector<java::constant> container_type;
/**
* Access constants based on jar file index numbers (index of the first element is 1)
@@ -208,5 +208,5 @@ namespace java
}
private:
container_type constants;
- };
+ };
}
diff --git a/java/javautils.cpp b/java/javautils.cpp
index bf4b5cdf..4a359031 100644
--- a/java/javautils.cpp
+++ b/java/javautils.cpp
@@ -26,56 +26,56 @@ namespace javautils
QString GetMinecraftJarVersion(QString jarName)
{
- QString version = MCVer_Unknown;
+ QString version = MCVer_Unknown;
- // check if minecraft.jar exists
- QFile jar(jarName);
- if (!jar.exists())
- return version;
+ // check if minecraft.jar exists
+ QFile jar(jarName);
+ if (!jar.exists())
+ return version;
- // open minecraft.jar
- QuaZip zip(&jar);
- if (!zip.open(QuaZip::mdUnzip))
- return version;
+ // open minecraft.jar
+ QuaZip zip(&jar);
+ if (!zip.open(QuaZip::mdUnzip))
+ return version;
- // open Minecraft.class
- zip.setCurrentFile("net/minecraft/client/Minecraft.class", QuaZip::csSensitive);
- QuaZipFile Minecraft(&zip);
- if (!Minecraft.open(QuaZipFile::ReadOnly))
- return version;
+ // open Minecraft.class
+ zip.setCurrentFile("net/minecraft/client/Minecraft.class", QuaZip::csSensitive);
+ QuaZipFile Minecraft(&zip);
+ if (!Minecraft.open(QuaZipFile::ReadOnly))
+ return version;
- // read Minecraft.class
- qint64 size = Minecraft.size();
- char *classfile = new char[size];
- Minecraft.read(classfile, size);
+ // read Minecraft.class
+ qint64 size = Minecraft.size();
+ char *classfile = new char[size];
+ Minecraft.read(classfile, size);
- // parse Minecraft.class
- try {
- char *temp = classfile;
- java::classfile MinecraftClass(temp, size);
- java::constant_pool constants = MinecraftClass.constants;
- for(java::constant_pool::container_type::const_iterator iter=constants.begin();
- iter != constants.end(); iter++)
- {
- const java::constant & constant = *iter;
- if (constant.type != java::constant::j_string_data)
- continue;
- const std::string & str = constant.str_data;
- if (str.compare(0, 20, "Minecraft Minecraft ") == 0)
- {
- version = str.substr(20).data();
- break;
- }
- }
- } catch(java::classfile_exception &) {}
+ // parse Minecraft.class
+ try {
+ char *temp = classfile;
+ java::classfile MinecraftClass(temp, size);
+ java::constant_pool constants = MinecraftClass.constants;
+ for(java::constant_pool::container_type::const_iterator iter=constants.begin();
+ iter != constants.end(); iter++)
+ {
+ const java::constant & constant = *iter;
+ if (constant.type != java::constant::j_string_data)
+ continue;
+ const std::string & str = constant.str_data;
+ if (str.compare(0, 20, "Minecraft Minecraft ") == 0)
+ {
+ version = str.substr(20).data();
+ break;
+ }
+ }
+ } catch(java::classfile_exception &) {}
- // clean up
- delete[] classfile;
- Minecraft.close();
- zip.close();
- jar.close();
+ // clean up
+ delete[] classfile;
+ Minecraft.close();
+ zip.close();
+ jar.close();
- return version;
+ return version;
}
}
diff --git a/java/javautils.h b/java/javautils.h
index 7f9b6d89..883eff1d 100644
--- a/java/javautils.h
+++ b/java/javautils.h
@@ -21,8 +21,8 @@
namespace javautils
{
- /**
- * @brief Get the version from a minecraft.jar by parsing its class files. Expensive!
+ /**
+ * @brief Get the version from a minecraft.jar by parsing its class files. Expensive!
*/
QString GetMinecraftJarVersion(QString jar);
}