mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-07 22:13:40 -04:00
Improved standard player logging and fixed teleportation
This commit is contained in:
+1
-1
@@ -89,7 +89,7 @@ public class AdminTeleportCallback implements ICmdCallback {
|
||||
}
|
||||
}
|
||||
|
||||
teleportObject.moveToLocation(new Location(x, y, z, terrain));
|
||||
teleportObject.moveToContainer(null, new Location(x, y, z, terrain));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-11
@@ -33,6 +33,7 @@ import com.projectswg.holocore.intents.support.global.network.CloseConnectionInt
|
||||
import com.projectswg.holocore.intents.support.global.network.ForceLogoutIntent;
|
||||
import com.projectswg.holocore.intents.support.global.network.InboundPacketIntent;
|
||||
import com.projectswg.holocore.intents.support.global.zone.PlayerEventIntent;
|
||||
import com.projectswg.holocore.resources.support.data.server_info.StandardLog;
|
||||
import com.projectswg.holocore.resources.support.global.network.DisconnectReason;
|
||||
import com.projectswg.holocore.resources.support.global.player.Player;
|
||||
import com.projectswg.holocore.resources.support.global.player.PlayerEvent;
|
||||
@@ -71,7 +72,7 @@ public class ConnectionService extends Service {
|
||||
while (iter.hasNext()) {
|
||||
DisappearPlayer p = iter.next();
|
||||
if ((System.nanoTime()-p.getTime())/1E6 >= DISAPPEAR_THRESHOLD) {
|
||||
disappear(p.getPlayer(), false, DisconnectReason.APPLICATION);
|
||||
disappear(p.getPlayer());
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
@@ -119,26 +120,26 @@ public class ConnectionService extends Service {
|
||||
Player player = fli.getPlayer();
|
||||
Objects.requireNonNull(player.getCreatureObject(), "ForceLogoutIntent must have a valid player with creature object!");
|
||||
logOut(player);
|
||||
disappear(player, false, DisconnectReason.APPLICATION);
|
||||
disappear(player);
|
||||
}
|
||||
|
||||
private void setPlayerFlag(Player p, PlayerFlags flag) {
|
||||
private void setPlayerFlag(Player p) {
|
||||
PlayerObject player = p.getPlayerObject();
|
||||
if (player == null)
|
||||
return;
|
||||
player.setFlagBitmask(flag);
|
||||
player.setFlagBitmask(PlayerFlags.LD);
|
||||
}
|
||||
|
||||
private void clearPlayerFlag(Player p, PlayerFlags flag) {
|
||||
private void clearPlayerFlag(Player p) {
|
||||
PlayerObject player = p.getPlayerObject();
|
||||
if (player == null)
|
||||
return;
|
||||
player.clearFlagBitmask(flag);
|
||||
player.clearFlagBitmask(PlayerFlags.LD);
|
||||
}
|
||||
|
||||
private void zoneIn(Player p) {
|
||||
ProjectSWG.getGalaxy().incrementPopulationCount();
|
||||
clearPlayerFlag(p, PlayerFlags.LD);
|
||||
clearPlayerFlag(p);
|
||||
removeFromDisappear(p);
|
||||
boolean unique = zonedInPlayers.add(p);
|
||||
assert unique;
|
||||
@@ -147,18 +148,18 @@ public class ConnectionService extends Service {
|
||||
private void logOut(Player p) {
|
||||
if (!zonedInPlayers.remove(p))
|
||||
return;
|
||||
Log.i("Logged out %s with character %s", p.getUsername(), p.getCharacterName());
|
||||
StandardLog.onPlayerEvent(this, p, "logged out");
|
||||
ProjectSWG.getGalaxy().decrementPopulationCount();
|
||||
setPlayerFlag(p, PlayerFlags.LD);
|
||||
setPlayerFlag(p);
|
||||
removeFromDisappear(p);
|
||||
updatePlayTime(p);
|
||||
addToDisappear(p);
|
||||
}
|
||||
|
||||
private void disappear(Player p, boolean newConnection, DisconnectReason reason) {
|
||||
private void disappear(Player p) {
|
||||
if (p.getCreatureObject() == null)
|
||||
return;
|
||||
Log.i("Disappeared %s with character %s with reason %s", p.getUsername(), p.getCharacterName(), reason);
|
||||
StandardLog.onPlayerEvent(this, p, "disappeared");
|
||||
|
||||
removeFromDisappear(p);
|
||||
IntentChain.broadcastChain(
|
||||
|
||||
+23
-24
@@ -64,7 +64,6 @@ import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureOb
|
||||
import com.projectswg.holocore.services.support.objects.ObjectStorageService.ObjectLookup;
|
||||
import me.joshlarson.jlcommon.control.IntentHandler;
|
||||
import me.joshlarson.jlcommon.control.Service;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -139,20 +138,20 @@ public class LoginService extends Service {
|
||||
UserMetadata user = userDatabase.getUser(loginRequest.getUsername());
|
||||
player.setUsername(loginRequest.getUsername());
|
||||
if (user == null) {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect username]");
|
||||
onInvalidUserPass(player, loginRequest);
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect username] from %s", loginRequest.getSocketAddress());
|
||||
onInvalidUserPass(player);
|
||||
player.sendPacket(new HoloLoginResponsePacket(false, "Incorrect username"));
|
||||
} else if (user.isBanned()) {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [banned]");
|
||||
onLoginBanned(player, loginRequest);
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [banned] from %s", loginRequest.getSocketAddress());
|
||||
onLoginBanned(player);
|
||||
player.sendPacket(new HoloLoginResponsePacket(false, "Sorry, you're banned!"));
|
||||
} else if (isUserValid(user, loginRequest.getPassword())) {
|
||||
StandardLog.onPlayerEvent(this, player, "logged in");
|
||||
onSuccessfulLogin(user, player, loginRequest);
|
||||
StandardLog.onPlayerEvent(this, player, "logged in from %s", loginRequest.getSocketAddress());
|
||||
onSuccessfulLogin(user, player);
|
||||
player.sendPacket(new HoloLoginResponsePacket(true, "", getGalaxies(), getCharacters(user.getUsername())));
|
||||
} else {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect password]");
|
||||
onInvalidUserPass(player, loginRequest);
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect password] from %s", loginRequest.getSocketAddress());
|
||||
onInvalidUserPass(player);
|
||||
player.sendPacket(new HoloLoginResponsePacket(false, "Incorrect password"));
|
||||
}
|
||||
}
|
||||
@@ -170,12 +169,12 @@ public class LoginService extends Service {
|
||||
Player owner = obj.getOwner();
|
||||
if (owner != null)
|
||||
CloseConnectionIntent.broadcast(owner, DisconnectReason.APPLICATION);
|
||||
StandardLog.onPlayerEvent(this, player, "deleted character %s", obj);
|
||||
StandardLog.onPlayerEvent(this, player, "deleted character %s from %s", obj, request.getSocketAddress());
|
||||
} else {
|
||||
if (obj == null)
|
||||
StandardLog.onPlayerError(this, player, "failed to delete character %d", request.getPlayerId());
|
||||
StandardLog.onPlayerError(this, player, "failed to delete character %d from %s", request.getPlayerId(), request.getSocketAddress());
|
||||
else
|
||||
StandardLog.onPlayerError(this, player, "failed to delete character %s", obj);
|
||||
StandardLog.onPlayerError(this, player, "failed to delete character %s from %s", obj, request.getSocketAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ public class LoginService extends Service {
|
||||
player.setPlayerServer(PlayerServer.LOGIN);
|
||||
final boolean doClientCheck = DataManager.getConfig(ConfigFile.NETWORK).getBoolean("LOGIN-VERSION-CHECKS", true);
|
||||
if (!id.getVersion().equals(REQUIRED_VERSION) && doClientCheck) {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect version: %s]", id.getVersion());
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect version: %s] from %s", id.getVersion(), id.getSocketAddress());
|
||||
onLoginClientVersionError(player, id);
|
||||
return;
|
||||
}
|
||||
@@ -198,21 +197,21 @@ public class LoginService extends Service {
|
||||
UserMetadata user = userDatabase.getUser(id.getUsername());
|
||||
player.setUsername(id.getUsername());
|
||||
if (user == null) {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect username]");
|
||||
onInvalidUserPass(player, id);
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect username] from %s", id.getSocketAddress());
|
||||
onInvalidUserPass(player);
|
||||
player.sendPacket(new ErrorMessage("Login Failed!", "Incorrect username", false));
|
||||
player.sendPacket(new LoginIncorrectClientId(getServerString(), REQUIRED_VERSION));
|
||||
} else if (user.isBanned()) {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [banned]");
|
||||
onLoginBanned(player, id);
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [banned] from %s", id.getSocketAddress());
|
||||
onLoginBanned(player);
|
||||
player.sendPacket(new ErrorMessage("Login Failed!", "Sorry, you're banned!", false));
|
||||
} else if (isUserValid(user, id.getPassword())) {
|
||||
StandardLog.onPlayerEvent(this, player, "logged in");
|
||||
onSuccessfulLogin(user, player, id);
|
||||
StandardLog.onPlayerEvent(this, player, "logged in from %s", id.getSocketAddress());
|
||||
onSuccessfulLogin(user, player);
|
||||
sendLoginSuccessPacket(player);
|
||||
} else {
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect password]");
|
||||
onInvalidUserPass(player, id);
|
||||
StandardLog.onPlayerEvent(this, player, "failed to login [incorrect password] from %s", id.getSocketAddress());
|
||||
onInvalidUserPass(player);
|
||||
player.sendPacket(new ErrorMessage("Login Failed!", "Incorrect password", false));
|
||||
player.sendPacket(new LoginIncorrectClientId(getServerString(), REQUIRED_VERSION));
|
||||
}
|
||||
@@ -224,7 +223,7 @@ public class LoginService extends Service {
|
||||
new LoginEventIntent(player.getNetworkId(), LoginEvent.LOGIN_FAIL_INVALID_VERSION_CODE).broadcast();
|
||||
}
|
||||
|
||||
private void onSuccessfulLogin(UserMetadata user, Player player, SWGPacket loginRequest) {
|
||||
private void onSuccessfulLogin(UserMetadata user, Player player) {
|
||||
switch(user.getAccessLevel()) {
|
||||
case "player": player.setAccessLevel(AccessLevel.PLAYER); break;
|
||||
case "warden": player.setAccessLevel(AccessLevel.WARDEN); break;
|
||||
@@ -237,12 +236,12 @@ public class LoginService extends Service {
|
||||
new LoginEventIntent(player.getNetworkId(), LoginEvent.LOGIN_SUCCESS).broadcast();
|
||||
}
|
||||
|
||||
private void onLoginBanned(Player player, SWGPacket loginRequest) {
|
||||
private void onLoginBanned(Player player) {
|
||||
player.setPlayerState(PlayerState.DISCONNECTED);
|
||||
new LoginEventIntent(player.getNetworkId(), LoginEvent.LOGIN_FAIL_BANNED).broadcast();
|
||||
}
|
||||
|
||||
private void onInvalidUserPass(Player player, SWGPacket loginRequest) {
|
||||
private void onInvalidUserPass(Player player) {
|
||||
player.setPlayerState(PlayerState.DISCONNECTED);
|
||||
new LoginEventIntent(player.getNetworkId(), LoginEvent.LOGIN_FAIL_INVALID_USER_PASS).broadcast();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.projectswg.holocore.intents.support.global.network.InboundPacketInten
|
||||
import com.projectswg.holocore.intents.support.global.zone.PlayerEventIntent;
|
||||
import com.projectswg.holocore.resources.support.data.config.ConfigFile;
|
||||
import com.projectswg.holocore.resources.support.data.server_info.DataManager;
|
||||
import com.projectswg.holocore.resources.support.data.server_info.StandardLog;
|
||||
import com.projectswg.holocore.resources.support.global.player.Player;
|
||||
import com.projectswg.holocore.resources.support.global.player.Player.PlayerServer;
|
||||
import com.projectswg.holocore.resources.support.global.zone.ZoneRequester;
|
||||
@@ -115,7 +116,7 @@ public class ZoneService extends Service {
|
||||
}
|
||||
|
||||
private void handleClientIdMsg(Player player, ClientIdMsg clientId) {
|
||||
Log.i("%s connected to the zone server from %s", player.getUsername(), clientId.getSocketAddress());
|
||||
StandardLog.onPlayerEvent(this, player, "connected to zone server from %s", clientId.getSocketAddress());
|
||||
player.setPlayerServer(PlayerServer.ZONE);
|
||||
player.sendPacket(new HeartBeat());
|
||||
player.sendPacket(new AccountFeatureBits());
|
||||
|
||||
+32
-23
@@ -44,6 +44,7 @@ import com.projectswg.holocore.intents.support.global.zone.PlayerTransformedInte
|
||||
import com.projectswg.holocore.intents.support.global.zone.RequestZoneInIntent;
|
||||
import com.projectswg.holocore.intents.support.objects.awareness.ForceAwarenessUpdateIntent;
|
||||
import com.projectswg.holocore.intents.support.objects.swg.*;
|
||||
import com.projectswg.holocore.resources.support.data.server_info.StandardLog;
|
||||
import com.projectswg.holocore.resources.support.global.network.DisconnectReason;
|
||||
import com.projectswg.holocore.resources.support.global.player.Player;
|
||||
import com.projectswg.holocore.resources.support.global.player.PlayerEvent;
|
||||
@@ -57,7 +58,6 @@ import com.projectswg.holocore.services.support.objects.ObjectStorageService.Obj
|
||||
import me.joshlarson.jlcommon.control.Intent;
|
||||
import me.joshlarson.jlcommon.control.IntentHandler;
|
||||
import me.joshlarson.jlcommon.control.Service;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -128,9 +128,9 @@ public class AwarenessService extends Service {
|
||||
private void processGalacticPacketIntent(InboundPacketIntent gpi) {
|
||||
SWGPacket packet = gpi.getPacket();
|
||||
if (packet instanceof DataTransform) {
|
||||
handleDataTransform((DataTransform) packet);
|
||||
handleDataTransform(gpi.getPlayer(), (DataTransform) packet);
|
||||
} else if (packet instanceof DataTransformWithParent) {
|
||||
handleDataTransformWithParent((DataTransformWithParent) packet);
|
||||
handleDataTransformWithParent(gpi.getPlayer(), (DataTransformWithParent) packet);
|
||||
} else if (packet instanceof CmdSceneReady) {
|
||||
handleCmdSceneReady(gpi.getPlayer(), (CmdSceneReady) packet);
|
||||
}
|
||||
@@ -205,57 +205,66 @@ public class AwarenessService extends Service {
|
||||
}
|
||||
Location loc = creature.getWorldLocation();
|
||||
player.sendPacket(new CmdStartScene(true, creature.getObjectId(), creature.getRace(), loc, ProjectSWG.getGalacticTime(), (int) (System.currentTimeMillis() / 1E3)));
|
||||
Log.i("Zoning in %s with character %s to %s %s", player.getUsername(), player.getCharacterName(), loc.getPosition(), loc.getTerrain());
|
||||
StandardLog.onPlayerEvent(this, player, "zoning in at %s %s", loc.getTerrain(), loc.getPosition());
|
||||
new PlayerEventIntent(player, PlayerEvent.PE_ZONE_IN_CLIENT).broadcastAfterIntent(firstZoneIntent);
|
||||
}
|
||||
|
||||
private void handleCmdSceneReady(Player player, CmdSceneReady p) {
|
||||
assert player.getPlayerState() == PlayerState.ZONING_IN;
|
||||
player.setPlayerState(PlayerState.ZONED_IN);
|
||||
Log.i("%s with character %s zoned in from %s", player.getUsername(), player.getCharacterName(), p.getSocketAddress());
|
||||
StandardLog.onPlayerEvent(this, player, "zoned in from %s", p.getSocketAddress());
|
||||
new PlayerEventIntent(player, PlayerEvent.PE_ZONE_IN_SERVER).broadcast();
|
||||
player.sendPacket(new CmdSceneReady());
|
||||
player.sendBufferedDeltas();
|
||||
}
|
||||
|
||||
private void handleDataTransform(DataTransform dt) {
|
||||
SWGObject obj = ObjectLookup.getObjectById(dt.getObjectId());
|
||||
if (!(obj instanceof CreatureObject)) {
|
||||
Log.w("DataTransform object not CreatureObject! Was: " + (obj == null ? "null" : obj.getClass()));
|
||||
private void handleDataTransform(Player player, DataTransform dt) {
|
||||
CreatureObject creature = player.getCreatureObject();
|
||||
if (creature == null) {
|
||||
StandardLog.onPlayerError(this, player, "sent a DataTransform without being logged in");
|
||||
return;
|
||||
}
|
||||
Location requestedLocation = Location.builder(dt.getLocation()).setTerrain(obj.getTerrain()).build();
|
||||
if (creature.getObjectId() != dt.getObjectId()) {
|
||||
StandardLog.onPlayerError(this, player, "sent a DataTransform for another object [%d]", dt.getObjectId());
|
||||
return;
|
||||
}
|
||||
|
||||
Location requestedLocation = Location.builder(dt.getLocation()).setTerrain(creature.getTerrain()).build();
|
||||
double speed = dt.getSpeed();
|
||||
|
||||
if (((CreatureObject) obj).isStatesBitmask(CreatureState.RIDING_MOUNT)) {
|
||||
if (creature.isStatesBitmask(CreatureState.RIDING_MOUNT)) {
|
||||
// If this is the primary rider, move the mount and all of the riders
|
||||
CreatureObject mount = (CreatureObject) obj.getParent();
|
||||
CreatureObject mount = (CreatureObject) creature.getParent();
|
||||
assert mount != null && mount.isStatesBitmask(CreatureState.MOUNTED_CREATURE) : "invalid parent for riding mount";
|
||||
|
||||
if (mount.getOwnerId() == obj.getObjectId()) {
|
||||
if (mount.getOwnerId() == creature.getObjectId()) {
|
||||
moveObjectWithTransform(mount, null, requestedLocation, speed);
|
||||
for (SWGObject child : mount.getSlottedObjects()) {
|
||||
moveObjectWithTransform(child, mount, requestedLocation, speed);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
moveObjectWithTransform(obj, null, requestedLocation, dt.getSpeed());
|
||||
moveObjectWithTransform(creature, null, requestedLocation, dt.getSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDataTransformWithParent(DataTransformWithParent dt) {
|
||||
SWGObject obj = ObjectLookup.getObjectById(dt.getObjectId());
|
||||
private void handleDataTransformWithParent(Player player, DataTransformWithParent dt) {
|
||||
CreatureObject creature = player.getCreatureObject();
|
||||
if (creature == null) {
|
||||
StandardLog.onPlayerError(this, player, "sent a DataTransformWithParent without being logged in");
|
||||
return;
|
||||
}
|
||||
if (creature.getObjectId() != dt.getObjectId()) {
|
||||
StandardLog.onPlayerError(this, player, "sent a DataTransformWithParent for another object [%d]", dt.getObjectId());
|
||||
return;
|
||||
}
|
||||
SWGObject parent = ObjectLookup.getObjectById(dt.getCellId());
|
||||
if (!(obj instanceof CreatureObject)) {
|
||||
Log.w("DataTransformWithParent object not CreatureObject! Was: " + (obj == null ? "null" : obj.getClass()));
|
||||
return;
|
||||
}
|
||||
if (parent == null) {
|
||||
Log.w("Unknown data transform parent! Obj: %d/%s Parent: %d", dt.getObjectId(), obj, dt.getCellId());
|
||||
StandardLog.onPlayerError(this, player, "sent a DataTransformWithParent with an unknown parent [%d]", dt.getCellId());
|
||||
return;
|
||||
}
|
||||
Location requestedLocation = Location.builder(dt.getLocation()).setTerrain(obj.getTerrain()).build();
|
||||
moveObjectWithTransform(obj, parent, requestedLocation, dt.getSpeed());
|
||||
Location requestedLocation = Location.builder(dt.getLocation()).setTerrain(creature.getTerrain()).build();
|
||||
moveObjectWithTransform(creature, parent, requestedLocation, dt.getSpeed());
|
||||
}
|
||||
|
||||
private void moveObjectWithTransform(SWGObject obj, SWGObject parent, Location requestedLocation, double speed) {
|
||||
|
||||
Reference in New Issue
Block a user