Browse Source

Removal of session tracking.

master
MagicBot 2 years ago
parent
commit
c57ae6d916
  1. 39
      src/engine/objects/Mine.java

39
src/engine/objects/Mine.java

@ -51,7 +51,6 @@ public class Mine extends AbstractGameObject {
private float altitude; private float altitude;
private Guild owningGuild; private Guild owningGuild;
public PlayerCharacter lastClaimer; public PlayerCharacter lastClaimer;
public SessionID lastClaimerSessionID;
private int flags; private int flags;
private int buildingID; private int buildingID;
@ -125,8 +124,7 @@ public class Mine extends AbstractGameObject {
} }
this.production = Resource.valueOf(rs.getString("mine_resource")); this.production = Resource.valueOf(rs.getString("mine_resource"));
this.lastClaimer = null;
this.lastClaimerSessionID = null;
} }
@ -484,7 +482,6 @@ public class Mine extends AbstractGameObject {
//never knocked down, let's just move on. //never knocked down, let's just move on.
//hasn't been claimed since server start. //hasn't been claimed since server start.
this.setActive(false); this.setActive(false);
this.lastClaimerSessionID = null;
this.lastClaimer = null; this.lastClaimer = null;
return true; return true;
} }
@ -494,7 +491,6 @@ public class Mine extends AbstractGameObject {
// and keep the window open. // and keep the window open.
if (!validClaimer(this.lastClaimer)) { if (!validClaimer(this.lastClaimer)) {
this.lastClaimerSessionID = null;
this.lastClaimer = null; this.lastClaimer = null;
this.updateGuildOwner(null); this.updateGuildOwner(null);
this.setActive(true); this.setActive(true);
@ -528,7 +524,6 @@ public class Mine extends AbstractGameObject {
DataWarehouse.pushToWarehouse(mineRecord); DataWarehouse.pushToWarehouse(mineRecord);
mineBuilding.setRank(mineBuilding.getRank()); mineBuilding.setRank(mineBuilding.getRank());
this.lastClaimerSessionID = null;
this.lastClaimer = null; this.lastClaimer = null;
this.setActive(false); this.setActive(false);
return true; return true;
@ -550,9 +545,10 @@ public class Mine extends AbstractGameObject {
if (!updateGuildOwner(claimer)) if (!updateGuildOwner(claimer))
return false; return false;
// Successful claim
this.lastClaimer = claimer; this.lastClaimer = claimer;
// Successful claim
return true; return true;
} }
@ -571,19 +567,19 @@ public class Mine extends AbstractGameObject {
return this.owningGuild.getOwnedCity().getWarehouse().depositFromMine(this, resourceIB, this.getModifiedProductionAmount()); return this.owningGuild.getOwnedCity().getWarehouse().depositFromMine(this, resourceIB, this.getModifiedProductionAmount());
} }
public boolean updateGuildOwner(PlayerCharacter pc) { public boolean updateGuildOwner(PlayerCharacter playerCharacter) {
Building mineBuilding = BuildingManager.getBuildingFromCache(this.buildingID); Building mineBuilding = BuildingManager.getBuildingFromCache(this.buildingID);
//should never return null, but let's check just in case. //should never return null, but let's check just in case.
if (mineBuilding == null) { if (mineBuilding == null) {
ChatManager.chatSystemError(pc, "Unable to find mine tower."); ChatManager.chatSystemError(playerCharacter, "Unable to find mine tower.");
Logger.debug("Failed to Update Mine with UID " + this.getObjectUUID() + ". Unable to Load Building with UID " + this.buildingID); Logger.debug("Failed to Update Mine with UID " + this.getObjectUUID() + ". Unable to Load Building with UID " + this.buildingID);
return false; return false;
} }
if (pc == null) { if (playerCharacter == null) {
this.owningGuild = Guild.getErrantGuild(); this.owningGuild = Guild.getErrantGuild();
this.guildName = "None"; this.guildName = "None";
this.guildTag = GuildTag.ERRANT; this.guildTag = GuildTag.ERRANT;
@ -595,40 +591,23 @@ public class Mine extends AbstractGameObject {
return true; return true;
} }
if (SessionManager.getSession(pc) != null) { Guild guild = playerCharacter.getGuild();
this.lastClaimerSessionID = SessionManager.getSession(pc).getSessionID();
} else {
Logger.error("Failed to find session for player " + pc.getObjectUUID());
return false;
}
Guild guild = pc.getGuild();
if (guild.getOwnedCity() == null) if (guild.getOwnedCity() == null)
return false; return false;
if (!MineQueries.CHANGE_OWNER(this, guild.getObjectUUID())) { if (!MineQueries.CHANGE_OWNER(this, guild.getObjectUUID())) {
Logger.debug("Database failed to Change Ownership of Mine with UID " + this.getObjectUUID()); Logger.debug("Database failed to Change Ownership of Mine with UID " + this.getObjectUUID());
ChatManager.chatSystemError(pc, "Failed to claim Mine."); ChatManager.chatSystemError(playerCharacter, "Failed to claim Mine.");
return false; return false;
} }
//All tests passed.
//update mine. //update mine.
this.owningGuild = guild; this.owningGuild = guild;
// this.guildName = this.owningGuild.getName();
// this.guildTag = this.owningGuild.getGuildTag();
//
// //nation will never return null, read getNation()
// Guild nation = this.owningGuild.getNation();
// this.nationName = nation.getName();
// this.nationTag = nation.getGuildTag();
//Update Building. //Update Building.
PlayerCharacter guildLeader = (PlayerCharacter) Guild.GetGL(this.owningGuild); PlayerCharacter guildLeader = (PlayerCharacter) Guild.GetGL(this.owningGuild);
if (guildLeader != null) if (guildLeader != null)
mineBuilding.setOwner(guildLeader); mineBuilding.setOwner(guildLeader);
WorldGrid.updateObject(mineBuilding); WorldGrid.updateObject(mineBuilding);

Loading…
Cancel
Save