mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-13 03:13:26 -04:00
Measures to stabilize Surveyservice
Transformed apparent non-entity-connected object-relational dependencies into looser coupled ID-keyed relations to ensure referential integrity Added null pointer checks Removal of null elements out of survey tool collection
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
:: Odb file wiper by Charon
|
||||
:: Use at your own risk!
|
||||
:: Do NOT execute outside the odb folder
|
||||
:: because it deletes files in subfolders!
|
||||
|
||||
@echo off
|
||||
cls
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
set /a count=0
|
||||
|
||||
for /d %%d in (*) do (
|
||||
set /a count+=1
|
||||
@echo !count!. %%d
|
||||
del "%%d\*.*" /s/q
|
||||
echo. 2>%%d\placeholder.txt
|
||||
)
|
||||
setlocal DisableDelayedExpansion
|
||||
|
||||
@@ -23,6 +23,8 @@ package resources.objects.tool;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@@ -41,32 +43,32 @@ import resources.objects.tangible.TangibleObject;
|
||||
@Persistent(version=0)
|
||||
public class SurveyTool extends TangibleObject{
|
||||
|
||||
private byte toolType;
|
||||
private GalacticResource surveyResource;
|
||||
private CreatureObject user;
|
||||
private Long tanoID;
|
||||
private byte SurveyRangeSetting;
|
||||
private byte toolType=0;
|
||||
private long surveyResourceID;
|
||||
private long userID=0;
|
||||
private Long tanoID=0L;
|
||||
private byte SurveyRangeSetting=0;
|
||||
|
||||
@NotPersistent
|
||||
private String surveyEffectString;
|
||||
private String surveyEffectString="";
|
||||
@NotPersistent
|
||||
private String sampleEffectString;
|
||||
private String sampleEffectString="";
|
||||
@NotPersistent
|
||||
private boolean currentlySurveying;
|
||||
private boolean currentlySurveying=false;
|
||||
@NotPersistent
|
||||
private boolean currentlySampling;
|
||||
private boolean currentlySampling=false;
|
||||
@NotPersistent
|
||||
private boolean currentlyCoolingDown;
|
||||
private boolean currentlyCoolingDown=false;
|
||||
@NotPersistent
|
||||
private boolean exceptionalState;
|
||||
private boolean exceptionalState=false;
|
||||
@NotPersistent
|
||||
private boolean recoveryMode;
|
||||
private boolean recoveryMode=false;
|
||||
@NotPersistent
|
||||
private Long lastSurveyTime;
|
||||
private Long lastSurveyTime=0L;
|
||||
@NotPersistent
|
||||
private Long lastSampleTime;
|
||||
private Long lastSampleTime=0L;
|
||||
@NotPersistent
|
||||
private Long recoveryTime;
|
||||
private Long recoveryTime=10L;
|
||||
|
||||
public static byte MineralSurveyDevice = 1;
|
||||
public static byte ChemicalSurveyDevice = 2;
|
||||
@@ -234,12 +236,12 @@ public class SurveyTool extends TangibleObject{
|
||||
return this.lastSampleTime;
|
||||
}
|
||||
|
||||
public void setSurveyResource(GalacticResource surveyResource){
|
||||
this.surveyResource = surveyResource;
|
||||
public void setSurveyResourceID(long surveyResourceID){
|
||||
this.surveyResourceID = surveyResourceID;
|
||||
}
|
||||
|
||||
public GalacticResource getSurveyResource(){
|
||||
return this.surveyResource;
|
||||
public long getSurveyResourceID(){
|
||||
return this.surveyResourceID;
|
||||
}
|
||||
|
||||
public boolean getCurrentlyCoolingDown() {
|
||||
@@ -258,12 +260,12 @@ public class SurveyTool extends TangibleObject{
|
||||
this.recoveryTime = recoveryTime;
|
||||
}
|
||||
|
||||
public CreatureObject getUser() {
|
||||
return user;
|
||||
public long getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUser(CreatureObject user) {
|
||||
this.user = user;
|
||||
public void setUserID(long userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public Long getTanoID() {
|
||||
@@ -324,9 +326,12 @@ public class SurveyTool extends TangibleObject{
|
||||
}
|
||||
|
||||
float differential = surveyRadius / (float) divisor;
|
||||
GalacticResource resourceToSurvey = this.getSurveyResource();
|
||||
Vector<ResourceConcentration> concentrationMap = resourceToSurvey.buildConcentrationsCollection(this.getUser().getPosition(),resourceToSurvey, surveyRadius, differential, this.getUser().getPlanetId());
|
||||
this.getSurveyResource().constructSurveyMapMessage(this.getUser(), concentrationMap, surveyRadius);
|
||||
GalacticResource resourceToSurvey = (GalacticResource) NGECore.getInstance().objectService.getObject(this.getSurveyResourceID());
|
||||
CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(this.getUserID());
|
||||
if (resourceToSurvey==null || user==null)
|
||||
return;
|
||||
Vector<ResourceConcentration> concentrationMap = resourceToSurvey.buildConcentrationsCollection(user.getPosition(),resourceToSurvey, surveyRadius, differential, user.getPlanetId());
|
||||
resourceToSurvey.constructSurveyMapMessage(user, concentrationMap, surveyRadius);
|
||||
//this.getUser().sendSystemMessage("Distance to nearest Deposit : " + this.getSurveyResource().getHelperMinDist(), (byte) 0);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package services;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
@@ -81,6 +82,9 @@ public class SurveyService implements INetworkDispatch {
|
||||
// All tools sampling
|
||||
SurveyTool removeTool=null;
|
||||
for (SurveyTool surveyTool : activeSurveyTools){
|
||||
if (surveyTool==null)
|
||||
continue;
|
||||
CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
|
||||
if (surveyTool.getCurrentlySurveying()){
|
||||
// Check if survey process has finished
|
||||
if (System.currentTimeMillis()>surveyTool.getLastSurveyTime()+3000){
|
||||
@@ -104,19 +108,21 @@ public class SurveyService implements INetworkDispatch {
|
||||
surveyTool.setCurrentlyCoolingDown(false);
|
||||
continueSampling(surveyTool);
|
||||
}
|
||||
if (surveyTool.getUser().getPosture()!=1){
|
||||
if (user.getPosture()!=1){
|
||||
surveyTool.setExceptionalState(false);
|
||||
surveyTool.setCurrentlySampling(false);
|
||||
removeTool = surveyTool;
|
||||
if (surveyTool.getUser().getPosture()==0)
|
||||
surveyTool.getUser().sendSystemMessage("You stand up", (byte) 0);
|
||||
if (user.getPosture()==0)
|
||||
user.sendSystemMessage("You stand up", (byte) 0);
|
||||
|
||||
surveyTool.getUser().sendSystemMessage("@survey:sample_cancel", (byte) 0);
|
||||
user.sendSystemMessage("@survey:sample_cancel", (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removeTool!=null)
|
||||
activeSurveyTools.remove(removeTool); // remove after notification
|
||||
|
||||
activeSurveyTools.removeAll(Collections.singleton(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +130,9 @@ public class SurveyService implements INetworkDispatch {
|
||||
|
||||
if (surveyTool.isExceptionalState())
|
||||
return;
|
||||
CreatureObject crafter = surveyTool.getUser();
|
||||
CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
|
||||
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
|
||||
GalacticResource sampleResource = surveyTool.getSurveyResource();
|
||||
GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID());
|
||||
int stackCount = 0;
|
||||
boolean gamblingwon = false;
|
||||
//ResourceContainerObject container = player.getRecentContainer();
|
||||
@@ -267,7 +273,7 @@ public class SurveyService implements INetworkDispatch {
|
||||
if (surveyTool.getToolType()==-1)
|
||||
return; // Survey tool type was not recognized
|
||||
|
||||
surveyTool.setUser(crafter);
|
||||
surveyTool.setUserID(crafter.getObjectID());
|
||||
surveyTool.setRecoveryTime(10000L);
|
||||
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
|
||||
player.setLastUsedSurveyTool(surveyTool);
|
||||
@@ -302,7 +308,7 @@ public class SurveyService implements INetworkDispatch {
|
||||
|
||||
surveyTool.setCurrentlySurveying(true);
|
||||
surveyTool.setLastSurveyTime(System.currentTimeMillis());
|
||||
surveyTool.setSurveyResource(resource);
|
||||
surveyTool.setSurveyResourceID(resource.getObjectID());
|
||||
|
||||
String effectFile = surveyTool.getSurveyEffectString();
|
||||
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition());
|
||||
@@ -343,7 +349,7 @@ public class SurveyService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
surveyTool.setCurrentlyCoolingDown(false);
|
||||
GalacticResource sampleResource = surveyTool.getSurveyResource();
|
||||
GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID());
|
||||
if(surveyTool==null || sampleResource==null) { // QA
|
||||
crafter.sendSystemMessage("You must survey for a resource before you can sample it.", (byte) 0);
|
||||
surveyTool.setExceptionalState(false);
|
||||
@@ -415,7 +421,7 @@ public class SurveyService implements INetworkDispatch {
|
||||
public void continueSampling(SurveyTool surveyTool){
|
||||
|
||||
surveyTool.setCurrentlyCoolingDown(false);
|
||||
CreatureObject crafter = surveyTool.getUser();
|
||||
CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
|
||||
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
|
||||
if (crafter.getPosture()!=1){
|
||||
crafter.sendSystemMessage("@survey:sample_cancel", (byte) 0);
|
||||
@@ -432,7 +438,7 @@ public class SurveyService implements INetworkDispatch {
|
||||
return;
|
||||
}
|
||||
|
||||
GalacticResource sampleResource = surveyTool.getSurveyResource();
|
||||
GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID());
|
||||
float localConcentration = sampleResource.deliverConcentrationForSurvey(crafter.getPlanetId(), crafter.getPosition().x, crafter.getPosition().z);
|
||||
//float localConcentration = 1.0F;
|
||||
if (localConcentration > 0.1) {
|
||||
|
||||
Reference in New Issue
Block a user