Code Coupons + Worldmap update + Mini-games + Player Interaction wrap

Fixed several cases on the Cash Shop that would freeze some player actions when triggered, requiring exit Cash Shop to unstuck.
Implemented Code Coupons, supporting several items bundled on the same code, and also devised a way to automate code generation.
Added a current status on-demand option on the Buyback command. Info such as "current fee" or "time remaining" are available now.
Reviewed several cases where non-owned items would get stacked with owner-tagged items.
Added Door support for Happyville, Crimsonwood Keep.
Added worldmap tooltip support for some maps in Masteria's C. Keep and H. House.
Added Masteria region to the world map.
C. Keep interiors no longer relocates players to entrance after actions such as logout.
Overhauled minigame mechanics: from player boxes tooltip and in-match improvements to deploy different minigame types, accordingly with item description or player choice.
Fixed Amoria outskirts not relocating players to city after getting KO'ed.
Fixed issues with pets, rings and cash items being assigned the same cash unique ids leading to some quirks on the cash shop inventory.
Fixed an issue with the recently added HP/MP ratio update, arbitrarily taking off 1 point in certain cases.
Answer positions on the explorer's 3rd job quiz are now randomed.
Fixed several issues that showed up when the bcrypt system is disabled.
DOT from maps such as El Nath and Aqua Road now procs at a 5sec interval, GMS-like.
Improved performance of Whodrops and Search commands.
Concurrently protected player interaction handlers, thus mitigating several exploits on these lines.
Adjusted several expedition timers, such as Horntail, now having a more sane deadline.
Concurrently protected chair modules.
Fixed "seduce" debuff not working on chairs.
This commit is contained in:
ronancpl
2018-10-09 22:39:36 -03:00
parent 3a8377c283
commit 2b44b4baa2
213 changed files with 16547 additions and 11031 deletions

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="MapleCodeCouponGenerator" default="default" basedir=".">
<description>Builds, tests, and runs the project MapleCodeCouponGenerator.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="MapleCodeCouponGenerator-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<imgdir name="CouponCodes.img">
<imgdir name="0">
<short name="active" value="0"/>
<int name="quantity" value="100"/>
<int name="duration" value="1848"/>
<int name="maplePoint" value="7777">
<int name="nxCredit" value="1000">
<int name="nxPrepaid" value="100">
<imgdir name="items">
<imgdir name="0">
<int name="id" value="4000001">
<int name="count" value="100">
</imgdir>
<imgdir name="1">
<int name="id" value="2030100">
<int name="count" value="12">
</imgdir>
</imgdir>
</imgdir>
<imgdir name="1">
<short name="active" value="1"/>
<int name="quantity" value="100"/>
<int name="duration" value="960"/>
<int name="maplePoint" value="5000">
<int name="nxCredit" value="14">
<int name="nxPrepaid" value="77">
<imgdir name="items">
<imgdir name="0">
<int name="id" value="1302000">
<int name="count" value="1">
</imgdir>
<imgdir name="1">
<int name="id" value="5000001">
<int name="count" value="20">
</imgdir>
</imgdir>
</imgdir>
</imgdir>

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

View File

@@ -0,0 +1,398 @@
/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2018 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package maplecodecoupongenerator;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author RonanLana
This application parses the coupon descriptor XML file and automatically generates
code entries on the DB reflecting the descriptions found. Parse time relies on the
sum of coupon codes created and amount of current codes on DB.
Estimated parse time: 2 minutes (for 100 code entries)
*/
public class MapleCodeCouponGenerator {
static String host = "jdbc:mysql://localhost:3306/heavenms";
static String driver = "com.mysql.jdbc.Driver";
static String username = "root";
static String password = "";
static Connection con = null;
static InputStreamReader fileReader = null;
static BufferedReader bufferedReader = null;
static String fileName = "lib/CouponCodes.img.xml";
static long currentTime;
static int initialStringLength = 250;
static String name;
static boolean active;
static int quantity, duration;
static int maplePoint, nxCredit, nxPrepaid;
static List<Pair<Integer, Integer>> itemList = new ArrayList<>();
static Pair<Integer, Integer> item;
static List<CodeCouponDescriptor> activeCoupons = new ArrayList<>();
static List<Integer> generatedKeys;
static Set<String> usedCodes = new HashSet<>();
static byte status;
private static void resetCouponPackage() {
name = null;
active = false;
quantity = 1;
duration = 7;
maplePoint = 0;
nxCredit = 0;
nxPrepaid = 0;
itemList.clear();
}
private static String getName(String token) {
int i, j;
char[] dest;
String d;
i = token.lastIndexOf("name");
i = token.indexOf("\"", i) + 1; //lower bound of the string
j = token.indexOf("\"", i); //upper bound
dest = new char[initialStringLength];
try {
token.getChars(i, j, dest, 0);
} catch (StringIndexOutOfBoundsException e) {
// do nothing
return "";
} catch (Exception e) {
System.out.println("error in: " + token + "");
e.printStackTrace();
try {
Thread.sleep(100000000);
} catch (Exception ex) {}
}
d = new String(dest);
return(d.trim());
}
private static String getValue(String token) {
int i, j;
char[] dest;
String d;
i = token.lastIndexOf("value");
i = token.indexOf("\"", i) + 1; //lower bound of the string
j = token.indexOf("\"", i); //upper bound
dest = new char[initialStringLength];
token.getChars(i, j, dest, 0);
d = new String(dest);
return(d.trim());
}
private static void forwardCursor(int st) {
String line = null;
try {
while(status >= st && (line = bufferedReader.readLine()) != null) {
simpleToken(line);
}
}
catch(Exception e) {
e.printStackTrace();
}
}
private static void simpleToken(String token) {
if(token.contains("/imgdir")) {
status -= 1;
}
else if(token.contains("imgdir")) {
status += 1;
}
}
private static void translateToken(String token) {
if(token.contains("/imgdir")) {
status -= 1;
if (status == 1) {
if (active) {
activeCoupons.add(new CodeCouponDescriptor(name, quantity, duration, maplePoint, nxCredit, nxPrepaid, itemList));
}
resetCouponPackage();
} else if (status == 3) {
itemList.add(item);
}
}
else if(token.contains("imgdir")) {
status += 1;
if (status == 4) {
item = new Pair<>(-1, -1);
} else if (status == 2) {
String d = getName(token);
System.out.println(" Reading coupon '" + d + "'");
name = d;
}
}
else {
String d = getName(token);
if (status == 2) {
switch (d) {
case "active":
if (Integer.valueOf(getValue(token)) == 0) {
forwardCursor(status);
resetCouponPackage();
} else {
active = true;
}
break;
case "quantity":
quantity = Integer.valueOf(getValue(token));
break;
case "duration":
duration = Integer.valueOf(getValue(token));
break;
case "maplePoint":
maplePoint = Integer.valueOf(getValue(token));
break;
case "nxCredit":
nxCredit = Integer.valueOf(getValue(token));
break;
case "nxPrepaid":
nxPrepaid = Integer.valueOf(getValue(token));
break;
}
} else if (status == 4) {
switch (d) {
case "count":
item.right = Integer.valueOf(getValue(token));
break;
case "id":
item.left = Integer.valueOf(getValue(token));
break;
}
}
}
}
private static class CodeCouponDescriptor {
protected String name;
protected int quantity, duration;
protected int nxCredit, maplePoint, nxPrepaid;
protected List<Pair<Integer, Integer>> itemList;
protected CodeCouponDescriptor(String name, int quantity, int duration, int maplePoint, int nxCredit, int nxPrepaid, List<Pair<Integer, Integer>> itemList) {
this.name = name;
this.quantity = quantity;
this.duration = duration;
this.maplePoint = maplePoint;
this.nxCredit = nxCredit;
this.nxPrepaid = nxPrepaid;
this.itemList = new ArrayList<>(itemList);
}
}
private static String randomizeCouponCode() {
StringBuilder rnd = new StringBuilder(Long.toHexString(Double.doubleToLongBits(Math.random())));
rnd.setCharAt(5, '-');
rnd.insert(11, '-');
return rnd.toString();
}
private static String generateCouponCode() {
String newCode;
do {
newCode = randomizeCouponCode();
} while (usedCodes.contains(newCode));
usedCodes.add(newCode);
return newCode;
}
private static List<Integer> getGeneratedKeys(PreparedStatement ps) throws SQLException {
if (generatedKeys == null) {
generatedKeys = new ArrayList<>();
ResultSet rs = ps.getGeneratedKeys();
while (rs.next()) {
generatedKeys.add(rs.getInt(1));
}
rs.close();
}
return generatedKeys;
}
private static void commitCodeCouponDescription(CodeCouponDescriptor recipe) throws SQLException {
if (recipe.quantity < 1) return;
System.out.println(" Generating coupon '" + recipe.name + "'");
generatedKeys = null;
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO `nxcode` (`code`, `expiration`) VALUES (?, ?)", Statement.RETURN_GENERATED_KEYS);
ps.setLong(2, currentTime + (recipe.duration * 60 * 60 * 1000));
for(int i = 0; i < recipe.quantity; i++) {
ps.setString(1, generateCouponCode());
ps.addBatch();
}
ps.executeBatch();
PreparedStatement ps2 = con.prepareStatement("INSERT IGNORE INTO `nxcode_items` (`codeid`, `type`, `item`, `quantity`) VALUES (?, ?, ?, ?)");
if (!recipe.itemList.isEmpty()) {
ps2.setInt(2, 5);
List<Integer> keys = getGeneratedKeys(ps);
for (Pair<Integer, Integer> p : recipe.itemList) {
ps2.setInt(3, p.getLeft());
ps2.setInt(4, p.getRight());
for (Integer codeid : keys) {
ps2.setInt(1, codeid);
ps2.addBatch();
}
}
}
ps2.setInt(4, 0);
if (recipe.nxCredit > 0) {
ps2.setInt(2, 0);
ps2.setInt(3, recipe.nxCredit);
List<Integer> keys = getGeneratedKeys(ps);
for(Integer codeid : keys) {
ps2.setInt(1, codeid);
ps2.addBatch();
}
}
if (recipe.maplePoint > 0) {
ps2.setInt(2, 1);
ps2.setInt(3, recipe.maplePoint);
List<Integer> keys = getGeneratedKeys(ps);
for(Integer codeid : keys) {
ps2.setInt(1, codeid);
ps2.addBatch();
}
}
if (recipe.nxPrepaid > 0) {
ps2.setInt(2, 2);
ps2.setInt(3, recipe.nxPrepaid);
List<Integer> keys = getGeneratedKeys(ps);
for(Integer codeid : keys) {
ps2.setInt(1, codeid);
ps2.addBatch();
}
}
ps2.executeBatch();
ps2.close();
ps.close();
}
private static void loadUsedCouponCodes() throws SQLException {
PreparedStatement ps = con.prepareStatement("SELECT code FROM nxcode", Statement.RETURN_GENERATED_KEYS);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
usedCodes.add(rs.getString("code"));
}
rs.close();
ps.close();
}
private static void generateCodeCoupons(String fileName) throws IOException {
fileReader = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
bufferedReader = new BufferedReader(fileReader);
resetCouponPackage();
status = 0;
System.out.println("Reading XML coupon information...");
String line;
while((line = bufferedReader.readLine()) != null) {
translateToken(line);
}
bufferedReader.close();
fileReader.close();
System.out.println();
try {
Class.forName(driver).newInstance();
con = DriverManager.getConnection(host, username, password);
System.out.println("Loading DB coupon codes...");
loadUsedCouponCodes();
System.out.println();
System.out.println("Saving generated coupons...");
currentTime = System.currentTimeMillis();
for (CodeCouponDescriptor ccd : activeCoupons) {
commitCodeCouponDescription(ccd);
}
System.out.println();
con.close();
System.out.println("Done.");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
generateCodeCoupons(fileName);
} catch(IOException ex) {
System.out.println("Error reading file '" + fileName + "'");
}
}
}

View File

@@ -0,0 +1,121 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package maplecodecoupongenerator;
/**
* Represents a pair of values.
*
* @author Frz
* @since Revision 333
* @version 1.0
*
* @param <E> The type of the left value.
* @param <F> The type of the right value.
*/
public class Pair<E, F> {
public E left;
public F right;
/**
* Class constructor - pairs two objects together.
*
* @param left The left object.
* @param right The right object.
*/
public Pair(E left, F right) {
this.left = left;
this.right = right;
}
/**
* Gets the left value.
*
* @return The left value.
*/
public E getLeft() {
return left;
}
/**
* Gets the right value.
*
* @return The right value.
*/
public F getRight() {
return right;
}
/**
* Turns the pair into a string.
*
* @return Each value of the pair as a string joined by a colon.
*/
@Override
public String toString() {
return left.toString() + ":" + right.toString();
}
/**
* Gets the hash code of this pair.
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((left == null) ? 0 : left.hashCode());
result = prime * result + ((right == null) ? 0 : right.hashCode());
return result;
}
/**
* Checks to see if two pairs are equal.
*/
@SuppressWarnings("unchecked")
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Pair other = (Pair) obj;
if (left == null) {
if (other.left != null) {
return false;
}
} else if (!left.equals(other.left)) {
return false;
}
if (right == null) {
if (other.right != null) {
return false;
}
} else if (!right.equals(other.right)) {
return false;
}
return true;
}
}