From 6ecdede66ac6ec5da44766bb8813fa017777d476 Mon Sep 17 00:00:00 2001 From: Treeku Date: Sat, 4 Jan 2014 20:29:23 +0000 Subject: [PATCH] Added system for making changes retroactive --- src/main/NGECore.java | 6 ++ src/services/retro/IRetroModification.java | 30 +++++++++ src/services/retro/RetroService.java | 76 ++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 src/services/retro/IRetroModification.java create mode 100644 src/services/retro/RetroService.java diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 8a68784c..84ca2611 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -72,6 +72,7 @@ import services.LoginService; import services.map.MapService; import services.object.ObjectService; import services.object.UpdateService; +import services.retro.RetroService; import services.spawn.SpawnService; import services.sui.SUIService; import services.trade.TradeService; @@ -123,6 +124,7 @@ public class NGECore { // Services public LoginService loginService; + public RetroService retroService; public ConnectionService connectionService; public CommandService commandService; public CharacterService characterService; @@ -221,6 +223,7 @@ public class NGECore { guildODB = new ObjectDatabase("guild", true, false, true); // Services loginService = new LoginService(this); + retroService = new RetroService(this); connectionService = new ConnectionService(this); characterService = new CharacterService(this); mapService = new MapService(this); @@ -276,6 +279,7 @@ public class NGECore { // Zone Server zoneDispatch = new NetworkDispatch(this, true); + zoneDispatch.addService(retroService); zoneDispatch.addService(connectionService); zoneDispatch.addService(characterService); zoneDispatch.addService(factionService); @@ -347,6 +351,8 @@ public class NGECore { // spawnService.loadLairGroups(); // spawnService.loadSpawnAreas(); + retroService.run(); + didServerCrash = false; System.out.println("Started Server."); setGalaxyStatus(2); diff --git a/src/services/retro/IRetroModification.java b/src/services/retro/IRetroModification.java new file mode 100644 index 00000000..8af86790 --- /dev/null +++ b/src/services/retro/IRetroModification.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.retro; + +import main.NGECore; + +public interface IRetroModification { + + public void modify(NGECore core); + +} diff --git a/src/services/retro/RetroService.java b/src/services/retro/RetroService.java new file mode 100644 index 00000000..16248004 --- /dev/null +++ b/src/services/retro/RetroService.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.retro; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; +import main.NGECore; + +/* + * Very often we will need to make changes to existing objects when the server + * boots up. This is especially the case when fixes or new features are + * added that affect already-existing objects. To make the changes retroactive + * we can use this service to make it more tidy. Add to the list of + * modifications in the relevant service's constructor, or in this one. + */ +public class RetroService implements INetworkDispatch { + + private NGECore core; + + private List modifications; + + public RetroService(NGECore core) { + this.core = core; + modifications = new ArrayList(); + + core.retroService.addModification(new IRetroModification() { + + public void modify(NGECore core) { + + } + + }); + } + + public void addModification(IRetroModification modification) { + modifications.add(modification); + } + + public void run() { + for (IRetroModification modification : modifications) { + modification.modify(core); + } + } + + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + } + + public void shutdown() { + + } + +}