Merge branch 'quality_assurance' of https://github.com/ProjectSWGCore/Holocore into quality_assurance

This commit is contained in:
Undercova
2020-05-02 20:40:20 +02:00
11 changed files with 207 additions and 51 deletions

View File

@@ -1,9 +1,8 @@
![Banner](https://imgur.com/V14kDE5.png)
![License](https://img.shields.io/badge/license-GPLv3-blue.svg?longCache=true&style=flat)
![JDK](https://img.shields.io/badge/JDK-9-blue.svg?longCache=true&style=flat)
![JDK](https://img.shields.io/badge/JDK-13-blue.svg?longCache=true&style=flat)
![Discord](https://img.shields.io/discord/373548910225915905.svg)
![Bitbucket open pull requests](https://img.shields.io/bitbucket/pr/projectswg/holocore.svg)
# Introduction #
@@ -22,19 +21,15 @@ You can find detailed information on the [wiki](https://bitbucket.org/projectswg
Ready to help bring back an awesome MMORPG with your programming skills?
The following assumes that you're familiar with:
* Installing applications on your machine
* Command line interfaces
* VCSs, Git in particular
* Programming in general
## Java Development Kit ##
In order to compile the source code, you need a JDK installation on your machine. The `JAVA_HOME` environment variable
should point to the directory of the JDK! It should be version 9 as minimum. You can see your installed Java version
should point to the directory of the JDK! It should be version 13 as minimum. You can see your installed Java version
by running `java -version`.
## Submodules ##
The project uses submodules. Get them by running: git submodule update --init
## Clientdata ##
This application reads a lot of information from the original game files. An installation of the game is therefore
@@ -79,36 +74,15 @@ holocore/
...
```
## Gradle ##
## MongoDB ##
User information is read from a MongoDB database that can be run on any machine on your network. Default is the machine that Holocore is running on.
This project uses Gradle as its build tool of choice. You must install Gradle on your machine in order to build the
source code.
1. Create database: use nge
2. Create a user for Holocore: `db.createUser({user: "holocore", pwd: "pass", roles: []})`
3. Create your game user: `db.users.insert({username: "user", password: "pass", accessLevel: "dev", banned: false, characters: []})`
Compile and run Holocores unit tests using Gradle: `gradle test --info` (Might fail if you haven't extracted clientdata yet)
Compile and run Holocores main code using Gradle: `gradle run`
## Running Holocore ##
Compile and run Holocores main code using Gradle: `./gradlew run`
## Forwarder ##
Holocore uses TCP for network communications, whereas SWG was programmed for UDP. This adds numerous efficiencies with
long distance communications, but requires that a little more work is done on the client side. If you are using the
launcher, you do not have to worry about this. If you are not using the launcher, follow the guide
[here](https://bitbucket.org/projectswg/forwarder).
## Credentials ##
Default credentials are currently created. Your username is `holocore` and your password is `password`. This user has the
highest admin level assigned to it.
## Contributing ##
1. Fork this repository
2. Clone the fork you just created, using `git clone`
3. Get the submodules using `git submodule update --init`
4. Find something to do in our issues list that is unassigned => https://bitbucket.org/projectswg/holocore/issues?status=new&status=open
5. Create a new branch on your fork of holocore
6. Write code, commit and push it to your branch
7. Once ready, create a pull request with destination branch `quality_assurance` and source branch
`<your_branch_name>`
8. Your changes are reviewed and are merged, unless something is wrong
9. Once merged, your changes will be available in future builds
10. If you want to work on something else, go back to step 4
## Running automated tests ##
Compile and run Holocores unit tests using Gradle: `./gradlew test --info`

View File

@@ -4,7 +4,7 @@ plugins {
application
idea
java
kotlin("jvm") version "1.3.70"
kotlin("jvm") version "1.3.72"
id("com.github.johnrengelman.shadow") version "5.2.0"
id("org.javamodularity.moduleplugin") version "1.5.0"
id("org.beryx.jlink") version "2.17.2"
@@ -96,6 +96,12 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).configure
}
}
tasks.create<JavaExec>("runDebug") {
enableAssertions = true
classpath = sourceSets.main.get().runtimeClasspath
main = "com.projectswg.holocore.ProjectSWG"
}
tasks.create<ShadowJar>("CreateConvertLoginJar") {
archiveBaseName.set("ConvertLogin")
archiveClassifier.set(null as String?)

View File

@@ -26,21 +26,22 @@
***********************************************************************************/
package com.projectswg.holocore.intents.support.global.chat;
import com.projectswg.holocore.resources.support.global.chat.AdminChatRooms;
import me.joshlarson.jlcommon.control.Intent;
import org.jetbrains.annotations.NotNull;
public class SystemChatRoomMessageIntent extends Intent {
private final String roomPath;
private final AdminChatRooms roomPath;
private final String message;
public SystemChatRoomMessageIntent(@NotNull String roomPath, @NotNull String message) {
public SystemChatRoomMessageIntent(@NotNull AdminChatRooms roomPath, @NotNull String message) {
this.roomPath = roomPath;
this.message = message;
}
@NotNull
public String getRoomPath() {
public AdminChatRooms getRoomPath() {
return roomPath;
}
@@ -49,7 +50,7 @@ public class SystemChatRoomMessageIntent extends Intent {
return message;
}
public static void broadcast(@NotNull String roomPath, @NotNull String message) {
public static void broadcast(@NotNull AdminChatRooms roomPath, @NotNull String message) {
new SystemChatRoomMessageIntent(roomPath, message).broadcast();
}
}

View File

@@ -0,0 +1,35 @@
/***********************************************************************************
* Copyright (c) 2020 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/
package com.projectswg.holocore.resources.support.global.chat
import com.projectswg.holocore.ProjectSWG
enum class AdminChatRooms(val roomTitle: String, val roomPath: String) {
SYSTEM_LOG("system log", "SWG." + ProjectSWG.getGalaxy().name + ".admin.SystemLog"),
SPAWNER_LOG("spawner log", "SWG." + ProjectSWG.getGalaxy().name + ".admin.SpawnerLog")
}

View File

@@ -303,7 +303,9 @@ public class ChatRoomHandler {
}
private void createAdminChannels(ChatAvatar systemAvatar, String basePath) {
createRoom(systemAvatar, false, false, ChatRoomService.LOG_ROOM_PATH, "server log", false);
for (AdminChatRooms room : AdminChatRooms.values()) {
createRoom(systemAvatar, false, false, room.getRoomPath(), room.getRoomTitle(), false);
}
}
public ChatRoom getRoomById(int roomId) {

View File

@@ -1,5 +1,6 @@
package com.projectswg.holocore.services.support.global;
import com.projectswg.holocore.services.support.global.admin.AdministrationManager;
import com.projectswg.holocore.services.support.global.chat.ChatManager;
import com.projectswg.holocore.services.support.global.commands.CommandManager;
import com.projectswg.holocore.services.support.global.health.ServerHealthService;
@@ -9,6 +10,8 @@ import me.joshlarson.jlcommon.control.Manager;
import me.joshlarson.jlcommon.control.ManagerStructure;
@ManagerStructure(children = {
AdministrationManager.class,
ChatManager.class,
CommandManager.class,

View File

@@ -0,0 +1,100 @@
/***********************************************************************************
* Copyright (c) 2020 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/
package com.projectswg.holocore.services.support.global.admin
import com.projectswg.common.data.CRC
import com.projectswg.holocore.intents.support.global.chat.SystemChatRoomMessageIntent
import com.projectswg.holocore.intents.support.global.command.ExecuteCommandIntent
import com.projectswg.holocore.intents.support.objects.swg.ObjectCreatedIntent
import com.projectswg.holocore.resources.support.global.chat.AdminChatRooms
import com.projectswg.holocore.resources.support.npc.spawn.SpawnerType
import com.projectswg.holocore.resources.support.objects.ObjectCreator
import com.projectswg.holocore.resources.support.objects.swg.cell.CellObject
import me.joshlarson.jlcommon.control.IntentHandler
import me.joshlarson.jlcommon.control.Service
import java.io.File
import java.util.*
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
class AdminSpawnerService : Service() {
private val outputFile = File("log/spawners.txt")
private val outputStreamLock = ReentrantLock()
override fun start(): Boolean {
outputFile.delete()
outputFile.createNewFile()
return true
}
@IntentHandler
private fun handleChatCommandIntent(eci: ExecuteCommandIntent) {
if (eci.command.crc == COMMAND_CREATE_SPAWNING_ELEMENT) {
val creature = eci.source
val location = creature.location
val building = creature.superParent?.buildoutTag ?: location.terrain.name.toLowerCase(Locale.US).substring(0, 3) + "_world"
val cell = (creature.parent as? CellObject?)?.number ?: 0
val args = eci.arguments.split(' ', limit = 2)
val type = sanitizeSpawnerType(args.getOrElse(0) { "AREA" }.toUpperCase(Locale.US))
val comment = args.getOrElse(1) { "NPC" }
val actualYaw = location.yaw
val soeYaw = if (actualYaw < 180) actualYaw else actualYaw - 360
val output = String.format("%s\t%s\t%s\t%d\t%.1f\t%.1f\t%.1f\t%.0f\t%s%s", location.terrain, building, type, cell, location.x, location.y, location.z, soeYaw, comment, System.lineSeparator())
outputStreamLock.withLock {
outputFile.appendText(output)
}
val color = when(type) {
"PATROL" -> "#000000"
"WAYPOINT" -> "#0000FF"
else -> "#FFFF00"
}
val egg = ObjectCreator.createObjectFromTemplate(when(type) {
"PATROL" -> SpawnerType.PATROL.objectTemplate
"WAYPOINT" -> "object/tangible/ground_spawning/patrol_waypoint.iff"
else -> SpawnerType.AREA.objectTemplate
})
egg.moveToContainer(creature.parent, location)
ObjectCreatedIntent.broadcast(egg)
SystemChatRoomMessageIntent.broadcast(AdminChatRooms.SPAWNER_LOG, "${color}The spawner $type ($comment) has been created at your location")
}
}
companion object {
private val COMMAND_CREATE_SPAWNING_ELEMENT = CRC.getCrc("createspawningelement")
private fun sanitizeSpawnerType(type: String): String {
if (type == "AREA" || type == "PATROL" || type == "WAYPOINT")
return type
return "AREA"
}
}
}

View File

@@ -0,0 +1,34 @@
/***********************************************************************************
* Copyright (c) 2020 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/
package com.projectswg.holocore.services.support.global.admin
import me.joshlarson.jlcommon.control.Manager
import me.joshlarson.jlcommon.control.ManagerStructure
@ManagerStructure(children = [AdminSpawnerService::class])
class AdministrationManager : Manager()

View File

@@ -67,7 +67,7 @@ public class ChatRoomService extends Service {
@Override
public boolean start() {
Log.addWrapper(new ChatRoomLogWrapper(ChatRoomService.LOG_ROOM_PATH));
Log.addWrapper(new ChatRoomLogWrapper());
return super.start();
}
@@ -168,7 +168,7 @@ public class ChatRoomService extends Service {
@IntentHandler
private void handleSystemChatRoomMessageIntent(SystemChatRoomMessageIntent intent) {
chatRoomHandler.sendMessageToRoomFromSystem(intent.getRoomPath(), intent.getMessage(), new OutOfBandPackage());
chatRoomHandler.sendMessageToRoomFromSystem(intent.getRoomPath().getRoomPath(), intent.getMessage(), new OutOfBandPackage());
}
/* Chat Rooms */

View File

@@ -27,11 +27,12 @@
package com.projectswg.holocore.utilities
import com.projectswg.holocore.intents.support.global.chat.SystemChatRoomMessageIntent
import com.projectswg.holocore.resources.support.global.chat.AdminChatRooms
import me.joshlarson.jlcommon.control.IntentChain
import me.joshlarson.jlcommon.log.Log
import me.joshlarson.jlcommon.log.LogWrapper
class ChatRoomLogWrapper(private val roomPath: String) : LogWrapper {
class ChatRoomLogWrapper : LogWrapper {
private val intentChain = IntentChain()
@@ -44,7 +45,7 @@ class ChatRoomLogWrapper(private val roomPath: String) : LogWrapper {
Log.LogLevel.ERROR -> " \\#FF0000\\E: "+str.substringAfter(": ")
Log.LogLevel.ASSERT -> " \\#FF00FF\\A: "+str.substringAfter(": ")
}
intentChain.broadcastAfter(SystemChatRoomMessageIntent(roomPath, message))
intentChain.broadcastAfter(SystemChatRoomMessageIntent(AdminChatRooms.SYSTEM_LOG, message))
}
}