Skip to content

Commit

Permalink
Merge pull request #64 from extremeCrazyCoder/master
Browse files Browse the repository at this point in the history
Div bugfixes
  • Loading branch information
Torridity authored Jul 19, 2019
2 parents 11bcdad + 36b8535 commit 9869f40
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.tor.dswb</groupId>
<artifactId>dsworkbench</artifactId>
<version>3.7</version>
<version>3.71</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[560, 500]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[560, 500]"/>
</Property>
<Property name="resizable" type="boolean" value="false"/>
</Properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,8 @@ private void fireDSWorkbenchClosingEvent(java.awt.event.WindowEvent evt) {//GEN-
logger.error("Failed to store profile settings on shutdown");
}
dispose();
MainShutdownHook.getSingleton().run();
new Thread(MainShutdownHook.getSingleton()).run();
JOptionPaneHelper.showInformationBox(this, "Beende ...", "Beende ...");
}//GEN-LAST:event_fireDSWorkbenchClosingEvent

private void fireGraphicPackChangedEvent(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fireGraphicPackChangedEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,16 @@
</Container>
<Container class="javax.swing.JPanel" name="jFinalDistributionPanel">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[200, 46]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[314, 100]"/>
<Dimension value="[350, 100]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.3"/>
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.8" weightY="0.3"/>
</Constraint>
</Constraints>

Expand Down Expand Up @@ -298,15 +301,15 @@
</Border>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[195, 100]"/>
<Dimension value="[220, 100]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[195, 100]"/>
<Dimension value="[220, 100]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.3"/>
<GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.2" weightY="0.3"/>
</Constraint>
</Constraints>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
gridBagConstraints.weighty = 0.7;
jPanel1.add(jTransportsPanel, gridBagConstraints);

jFinalDistributionPanel.setPreferredSize(new java.awt.Dimension(314, 100));
jFinalDistributionPanel.setMinimumSize(new java.awt.Dimension(200, 46));
jFinalDistributionPanel.setPreferredSize(new java.awt.Dimension(350, 100));
jFinalDistributionPanel.setLayout(new java.awt.BorderLayout());

jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultierende Rohstoffverteilung"));
Expand All @@ -344,13 +345,13 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weightx = 0.8;
gridBagConstraints.weighty = 0.3;
jPanel1.add(jFinalDistributionPanel, gridBagConstraints);

jFinalStatusPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Sonstige Informationen"));
jFinalStatusPanel.setMinimumSize(new java.awt.Dimension(195, 100));
jFinalStatusPanel.setPreferredSize(new java.awt.Dimension(195, 100));
jFinalStatusPanel.setMinimumSize(new java.awt.Dimension(220, 100));
jFinalStatusPanel.setPreferredSize(new java.awt.Dimension(220, 100));
jFinalStatusPanel.setLayout(new java.awt.GridBagLayout());

jLabel2.setText("Errechnete Transporte");
Expand Down Expand Up @@ -424,7 +425,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.2;
gridBagConstraints.weighty = 0.3;
jPanel1.add(jFinalStatusPanel, gridBagConstraints);

Expand Down
10 changes: 8 additions & 2 deletions Core/src/main/java/de/tor/tribes/util/BuildingSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,14 @@ public static boolean isBuildingLevelValid(String pBuilding, int pLevel) {
* returns false if building was not found
*/
public static boolean isBuildingLevelValid(int pBuildingID, int pLevel) {
if(pLevel > MAX_LEVEL[pBuildingID]) return false;
if(pLevel < MIN_LEVEL[pBuildingID]) return false;
if(pLevel > MAX_LEVEL[pBuildingID]) {
logger.debug("Level too hight {} / {} / {}", pBuildingID, pLevel, MAX_LEVEL[pBuildingID]);
return false;
}
if(pLevel < MIN_LEVEL[pBuildingID]) {
logger.debug("Level too low {} / {} / {}", pBuildingID, pLevel, MIN_LEVEL[pBuildingID]);
return false;
}
return true;
}

Expand Down
9 changes: 4 additions & 5 deletions Core/src/main/java/de/tor/tribes/util/ClipboardWatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.Timer;
import java.util.TimerTask;
import java.util.zip.CRC32;
Expand Down Expand Up @@ -54,7 +56,6 @@ public static synchronized ClipboardWatch getSingleton() {
setPriority(MIN_PRIORITY);
}
private Clip clip = null;
private AudioClip ac = null;

private synchronized void playNotification() {
if (!GlobalOptions.getProperties().getBoolean("clipboard.notification")) {
Expand All @@ -69,14 +70,12 @@ public void run() {
clip.stop();
clip.setMicrosecondPosition(0);
}
if (ac != null) {
ac.stop();
}

try {
if (clip == null) {
clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(ClockFrame.class.getResourceAsStream("/res/Ding.wav"));
InputStream data = new BufferedInputStream(ClockFrame.class.getResourceAsStream("/res/Ding.wav"));
AudioInputStream inputStream = AudioSystem.getAudioInputStream(data);
clip.open(inputStream);
}
clip.start();
Expand Down
2 changes: 1 addition & 1 deletion Core/src/main/java/de/tor/tribes/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author Torridity
*/
public class Constants {
public final static double VERSION = 3.7;
public final static double VERSION = 3.71;
public final static String VERSION_ADDITION = "";
public final static Color DS_BACK = new Color(225, 213, 190);
public final static Color DS_BACK_LIGHT = new Color(239, 235, 223);
Expand Down
14 changes: 9 additions & 5 deletions Core/src/main/java/de/tor/tribes/util/ReportServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,16 @@ public void run() {
url = url.substring((url.startsWith("/")?1:0));

String report = null;
//workaround for finding start & end because "&", "/" are not escaped in URL
report = url.substring(url.indexOf("&report=") + 8, url.indexOf("&user="));

report = URLDecoder.decode(report, "UTF-8");
logger.debug("Report raw: {}", report);
try {
//workaround for finding start & end because "&", "/" are not escaped in URL
report = url.substring(url.indexOf("&report=") + 8, url.indexOf("&user="));

report = URLDecoder.decode(report, "UTF-8");
logger.debug("Report raw: {}", report);
} catch(Exception e) {
report = null;
}

if (PluginManager.getSingleton().executeObstReportParser(report)) {
logger.debug("Successfully parsed report. Sending response.");
w.write("HTTP/1.0 200 OK");
Expand Down
16 changes: 10 additions & 6 deletions Core/src/main/java/de/tor/tribes/util/ServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public class ServerSettings {
public static final int NOBLESYSTEM_GOLD_COINS = 1;
private int nobleSystem = 0;

private boolean haulActive = true;
private boolean haulLimitActive = false;
private int haulType = 1;
private int haulLimitActive = 0;
private int haulBase = 0;
private int haulMax = 0;

Expand Down Expand Up @@ -210,8 +210,8 @@ public boolean loadSettings(String pServerID) {

logger.debug(" - reading haul values");
try {
this.haulActive = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls")) != 0;
this.haulLimitActive = Integer.parseInt(JDomUtils.getNodeValue(d, "game/farm_limit")) == 1;
this.haulType = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls"));
this.haulLimitActive = Integer.parseInt(JDomUtils.getNodeValue(d, "game/farm_limit"));
this.haulBase = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls_base"));
this.haulMax = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls_max"));
} catch (Exception inner) {
Expand Down Expand Up @@ -319,11 +319,15 @@ public int getBarbarianPoints() {
}

public boolean isHaulActive() {
return haulActive;
return haulType != 0;
}

public int getHaulType() {
return haulType;
}

public boolean isHaulLimitActive() {
return haulLimitActive;
return haulLimitActive != 0;
}

public int getHaulLimitBase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void setBuildingLevelByName(String pBuilding, int pLevel) {
return;
}

if(BuildingSettings.isBuildingLevelValid(pBuilding, pLevel)) {
if(!BuildingSettings.isBuildingLevelValid(pBuilding, pLevel)) {
logger.error("Building level invalid " + pBuilding + ": " + pLevel);
return;
}
Expand Down Expand Up @@ -266,6 +266,7 @@ public int getFarmSpace() {

int buildingPop = 0;
for(int i = 0; i < BuildingSettings.BUILDING_NAMES.length; i++) {
logger.trace("Building Farm {} / {} / {}", i, buildings[i], BuildingSettings.getPopUsageById(i, buildings[i]));
buildingPop += BuildingSettings.getPopUsageById(i, buildings[i]);
}

Expand Down
9 changes: 6 additions & 3 deletions Core/src/main/java/de/tor/tribes/util/xml/JDomUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ public static Document getOldDocument(File xmlFile) throws Exception {
}

public static Document getOldDocument(InputStream inStream) throws Exception {
InputStream s1 = IOUtils.toInputStream("<data>");
InputStream s2 = IOUtils.toInputStream("</data>");
return getDocument(new java.io.SequenceInputStream(new java.io.SequenceInputStream(s1, inStream), s2));
String data = IOUtils.toString(inStream);

if(data.startsWith("<?xml")) {
data = data.substring(data.indexOf("?>") + 2);
}
return getDocument("<data>" + data + "</data>");
}

public static List<Element> getNodes(Document document, String path) {
Expand Down
2 changes: 1 addition & 1 deletion ParserPlugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.tor.dswb</groupId>
<artifactId>dsworkbench</artifactId>
<version>3.7</version>
<version>3.71</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public boolean parse(String pData) {
if(v == null) continue;
logger.debug("Got village '" + v + "'");

String split[] = line.split("\t");
String split[] = line.trim().split("\t");
if(split.length < 2 + availableBuildings.size()) continue;

try {
int[] levels = new int[availableBuildings.size()];
for(int i = 0; i < levels.length; i++) {
levels[i] = Integer.parseInt(split[i + 3].trim());
levels[i] = Integer.parseInt(split[i + 2].trim());
}

if(logger.isDebugEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>dsworkbench</artifactId>
<name>DSWorkbench</name>
<packaging>pom</packaging>
<version>3.7</version>
<version>3.71</version>

<description>
Parent project for DS Workbench. The project contains two modules: core and plugins which are put together
Expand Down

0 comments on commit 9869f40

Please sign in to comment.