Merge pull request #5 from AttorneyOnline/headless-only

Remove GUI from akashi
This commit is contained in:
scatterflower 2020-09-02 08:53:57 -05:00 committed by GitHub
commit 03db6ff7dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 234 additions and 1035 deletions

4
.gitignore vendored
View File

@ -70,6 +70,6 @@ Thumbs.db
*.dll
*.exe
bin/
build/
bin/akashi
bin/config/

View File

@ -3,6 +3,4 @@ A C++ server for Attorney Online 2
Copyright © scatterflower 2020
UI Design and Code - Copyright © windrammer 2020
If you want to support the development of akashi, feel free to give a one-time gift at [liberapay](https://liberapay.com/scatterflower/)

View File

@ -1,6 +1,6 @@
QT += core gui network websockets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += network websockets core
QT -= gui
TEMPLATE = app
CONFIG += c++11
@ -24,16 +24,3 @@ RC_ICONS = resource/icon/akashi.ico
SOURCES += $$files($$PWD/src/*.cpp)
HEADERS += $$files($$PWD/include/*.h)
FORMS += $$files($$PWD/resource/forms/*.ui)
TRANSLATIONS += \
resource/translation/akashi_es.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
resources.qrc

View File

@ -0,0 +1,5 @@
[Basement]
background=gs4
[Courtroom 1]
background=gs4

View File

@ -0,0 +1,51 @@
Adrian
Apollo
April
Armstrong
Atmey
Butz
Diego
Edgeworth
Edgeworthw
Ema
EmaSkye
Franny
Franziska
Gant
Gavin
Gavin K
Godot
Gregory
Grossberg
Gumshoe
Gumshoey
Hawk
Hobo_Phoenix
Ini
Judge
Judge's Bro
Klav
Klavier
Kristoph
Lana
Layton
Lotta
Luis
Maggey
Manfred
Marshall
Matt
Maya
Mia
Miles
Oldbag
Payne
Pearl
Phoenix
Valant
Vasquez
Wellington
Winston
WinstonPayne
Young Mia
Zak

View File

@ -0,0 +1,18 @@
[Info]
version=1
[Options]
advertise=true
hostname=$H
language=en
max_message_size=256
max_players=100
modpass=password
ms_ip=master.aceattorneyonline.com
ms_port=27016
multiclient_limit=16
port=27016
server_description=This is my flashy new server
server_name=My First Server
webao_enable=true
webao_port=27017

View File

@ -0,0 +1,49 @@
Announce The Truth (AA).opus
Announce The Truth (AJ).opus
Announce The Truth (JFA).opus
Announce The Truth (Miles).opus
Announce The Truth (T&T).opus
Confrontation ~ Presto 2009.opus
Crises of Fate.opus
Forgotten Legend.opus
Godot - The Fragrance of Dark Coffee.opus
Great Revival ~ Franziska von Karma.opus
Great Revival ~ Miles Edgeworth.opus
Hotline of Fate.opus
Interesting People.opus
Logic and Trick.opus
Luke Atmey ~ I Just Want Love.opus
Noisy People.opus
OBJECTION (AA).opus
Objection (AJ).opus
OBJECTION (JFA).opus
Objection (Miles).opus
OBJECTION (T&T).opus
Others ~ Guilty love.opus
Prelude (AA).opus
Prelude (AJ).opus
Prologue (AA).opus
Pursuit (AA) - variation.opus
Pursuit (AA).opus
Pursuit (AJ).opus
Pursuit (DS).opus
Pursuit (JFA) - variation.opus
Pursuit (JFA).opus
Pursuit (Miles).opus
Pursuit (T&T) - variation.opus
Pursuit (T&T).opus
Pursuit ~ I Want to Find the Truth (Orchestra).opus
Questioning AA (Allegro).opus
Questioning AA (Moderato).opus
Questioning AJ (Allegro).opus
Questioning AJ (Moderato).opus
Questioning JFA (Allegro).opus
Questioning JFA (Moderato).opus
Questioning T&T (Allegro).opus
Questioning T&T (Moderato).opus
Speak up Pup.opus
Suspense (AA).opus
The Great Truth Burglar.opus
Trial (AA).opus
Trial (AJ).opus
Trial (Miles).opus

View File

@ -20,7 +20,7 @@
#include "include/aopacket.h"
#include <QApplication>
#include <QCoreApplication>
#include <QHostAddress>
#include <QString>
#include <QTcpSocket>

View File

@ -1,52 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////
// akashi - a server for Attorney Online 2 //
// Copyright (C) 2020 scatterflower //
// //
// This program 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. //
// //
// 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 Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#ifndef AKASHIMAIN_H
#define AKASHIMAIN_H
#include "include/advertiser.h"
#include "include/config_manager.h"
#include "include/server.h"
#include <QDebug>
#include <QMainWindow>
#include <QSettings>
QT_BEGIN_NAMESPACE
namespace Ui {
class AkashiMain;
}
QT_END_NAMESPACE
class AkashiMain : public QMainWindow {
Q_OBJECT
public:
AkashiMain(QWidget* parent = nullptr);
~AkashiMain();
ConfigManager config_manager;
void generateDefaultConfig(bool backup_old);
void updateConfig(int current_version);
private:
Ui::AkashiMain* ui;
Advertiser* advertiser;
Server* server;
};
#endif // AKASHIMAIN_H

View File

@ -30,8 +30,7 @@ class ConfigManager {
public:
ConfigManager();
bool initConfig();
void generateDefaultConfig(bool backup_old);
void updateConfig(int current_version);
bool updateConfig(int current_version);
struct server_settings {
QString ms_ip;
@ -47,6 +46,7 @@ class ConfigManager {
private:
QSettings* config;
bool fileExists(QFileInfo *file);
};
#endif // CONFIG_MANAGER_H

View File

@ -23,7 +23,7 @@
#include "include/area_data.h"
#include "include/ws_proxy.h"
#include <QApplication>
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QMap>

View File

@ -1,615 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AkashiMain</class>
<widget class="QMainWindow" name="AkashiMain">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>483</height>
</rect>
</property>
<property name="font">
<font>
<family>Ubuntu</family>
</font>
</property>
<property name="windowTitle">
<string>AkashiMain</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
<string notr="true">/*background-color: rgb(240, 240, 240);*/
background-color: rgb(53, 53, 53);</string>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<widget class="QWidget" name="centralwidget">
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(243, 243, 243);</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_Server">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<attribute name="title">
<string>Server</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="label_ServerName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>22</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">/*background-color: rgb(45, 57, 67);*/
background-color: rgba(191, 64, 64, 0);
color: rgb(240, 240, 240);
padding: 16px 3px 16px 3px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(11, 24, 35, 255), stop:1 rgba(61, 73, 82, 255));*/</string>
</property>
<property name="text">
<string>Server name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>2</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_ServerStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
background-color: rgb(246, 36, 81);
padding: 12px 18px 12px 18px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(202, 0, 43, 255), stop:1 rgba(255, 43, 89, 255));*/</string>
</property>
<property name="text">
<string>Offline</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_StartStop" stretch="0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="startStopButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
border: none;
border-radius: 4px;
background-color: rgb(31, 215, 141);
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(0, 193, 115, 255), stop:1 rgba(33, 251, 163, 255));*/
color: rgb(240, 240, 240);
padding: 20px 30px 20px 30px;
}
QPushButton:pressed {
background-color: rgb(72, 240, 164);
}
QPushButton:flat {
border: none; /* no border for a flat push button */
}</string>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_MS">
<property name="spacing">
<number>2</number>
</property>
<item>
<spacer name="horizontalSpacer_MS_L">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_MS">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(45, 57, 67);
background-color: rgb(45, 57, 67, 0);
color: rgb(240, 240, 240);
/*padding: 16px 3px 16px 3px;*/
padding: 3px 8px 3px 8px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(11, 24, 35, 255), stop:1 rgba(61, 73, 82, 255));*/</string>
</property>
<property name="text">
<string>Master Server connection status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_MS_Satus">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
background-color: rgb(246, 36, 81);
border-radius: 4px;
padding: 3px 8px 3px 8px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(202, 0, 43, 255), stop:1 rgba(255, 43, 89, 255));*/</string>
</property>
<property name="text">
<string>Not connected</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_MS_R">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Other" stretch="0,0,0">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_Players" stretch="0,0">
<property name="spacing">
<number>2</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_Players">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
background-color: rgb(43, 135, 211);
padding: 3px 8px 3px 8px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(36, 128, 204, 255), stop:1 rgba(78, 175, 255, 255));*/</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Players</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_PlayerCount">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
/*background-color: rgb(45, 57, 67);*/
background-color: rgb(45, 57, 67, 0);
padding: 4px 8px 4px 8px;
border-top-right-radius: 2px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(11, 24, 35, 255), stop:1 rgba(61, 73, 82, 255));*/</string>
</property>
<property name="text">
<string>0/100</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_Software">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="label_Software">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
background-color: rgb(43, 135, 211);
padding: 3px 8px 3px 8px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(36, 128, 204, 255), stop:1 rgba(78, 175, 255, 255));*/</string>
</property>
<property name="text">
<string>Software</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_SoftwareName">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
/*background-color: rgb(45, 57, 67);*/
background-color: rgb(45, 57, 67, 0);
padding: 4px 8px 4px 8px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(11, 24, 35, 255), stop:1 rgba(61, 73, 82, 255));*/</string>
</property>
<property name="text">
<string>Akashi</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_Version">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="label_Version">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
background-color: rgb(43, 135, 211);
padding: 3px 8px 3px 8px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(36, 128, 204, 255), stop:1 rgba(78, 175, 255, 255));*/</string>
</property>
<property name="text">
<string>Version</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_VersionNumber">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(240, 240, 240);
/*background-color: rgb(45, 57, 67);*/
background-color: rgb(45, 57, 67, 0);
padding: 4px 8px 4px 8px;
border-radius: 4px;
/*background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(11, 24, 35, 255), stop:1 rgba(61, 73, 82, 255));*/</string>
</property>
<property name="text">
<string>0.0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Options">
<attribute name="title">
<string>Options</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

Binary file not shown.

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="es_ES">
<context>
<name>AkashiMain</name>
<message>
<location filename="../forms/akashimain.ui" line="14"/>
<source>AkashiMain</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>main</name>
<message>
<location filename="../../src/main.cpp" line="20"/>
<source>A server for Attorney Online 2</source>
<translation>Un servidor para Attorney Online 2</translation>
</message>
<message>
<location filename="../../src/main.cpp" line="24"/>
<source>Run the server without a GUI</source>
<translation>Empezar el servidor sin interfaz</translation>
</message>
</context>
</TS>

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>resource/translation/akashi_es.qm</file>
</qresource>
</RCC>

View File

@ -62,7 +62,7 @@ void Advertiser::socketConnected()
AOPacket ao_packet("SCC",
{concat_ports, name, description,
"akashi v" + QApplication::applicationVersion()});
"akashi v" + QCoreApplication::applicationVersion()});
QByteArray data = ao_packet.toUtf8();
socket->write(data);

View File

@ -1,60 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////
// akashi - a server for Attorney Online 2 //
// Copyright (C) 2020 scatterflower //
// //
// This program 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. //
// //
// 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 Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/akashimain.h"
#include "ui_akashimain.h"
AkashiMain::AkashiMain(QWidget* parent)
: QMainWindow(parent), config_manager(), ui(new Ui::AkashiMain)
{
ui->setupUi(this);
qDebug("Main application started");
if (config_manager.initConfig()) {
// Config is sound, so proceed with starting the server
// Validate some of the config before passing it on
ConfigManager::server_settings settings;
bool config_valid = config_manager.loadServerSettings(&settings);
if (!config_valid) {
// TODO: send signal config invalid
config_manager.generateDefaultConfig(true);
}
else {
if (settings.advertise_server) {
// TODO: send signal advertiser started
advertiser =
new Advertiser(settings.ms_ip, settings.port,
settings.ws_port, settings.local_port,
settings.name, settings.description, this);
advertiser->contactMasterServer();
}
// TODO: start the server here
// TODO: send signal server starting.
server = new Server(settings.port, settings.ws_port);
server->start();
}
}
}
AkashiMain::~AkashiMain()
{
delete ui;
delete advertiser;
delete server;
}

View File

@ -73,10 +73,10 @@ void AOClient::handlePacket(AOPacket packet)
// Lord forgive me
if (packet.header == "HI") {
setHwid(packet.contents[0]);
sendPacket("ID", {"271828", "akashi", QApplication::applicationVersion()});
sendPacket("ID", {"271828", "akashi", QCoreApplication::applicationVersion()});
}
else if (packet.header == "ID") {
QSettings config("config.ini", QSettings::IniFormat);
QSettings config("config/config.ini", QSettings::IniFormat);
config.beginGroup("Options");
QString max_players = config.value("max_players").toString();
config.endGroup();
@ -114,10 +114,7 @@ void AOClient::handlePacket(AOPacket packet)
fullArup(); // Give client all the area data
arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player
QSettings areas_ini("areas.ini", QSettings::IniFormat);
QStringList areas = areas_ini.childGroups();
sendPacket("FA", areas);
sendPacket("FA", server->area_names);
sendPacket("OPPASS", {"DEADBEEF"});
sendPacket("DONE");
}

View File

@ -19,166 +19,68 @@
ConfigManager::ConfigManager()
{
config = new QSettings("config.ini", QSettings::IniFormat);
config = new QSettings("config/config.ini", QSettings::IniFormat);
}
// Validate and set up the config
bool ConfigManager::initConfig()
{
QFileInfo char_list_info("characters.txt");
if (!(char_list_info.exists() && char_list_info.isFile())) {
// TODO: signals go here
QFile char_list("characters.txt");
if (!char_list.open(QIODevice::WriteOnly | QIODevice::Text))
qDebug() << "Couldn't create character list";
QTextStream file_stream(&char_list);
qDebug() << "Creating vanilla character list";
file_stream << "Adrian\n";
file_stream << "Apollo\n";
file_stream << "April\n";
file_stream << "Armstrong\n";
file_stream << "Atmey\n";
file_stream << "Butz\n";
file_stream << "Diego\n";
file_stream << "Edgeworth\n";
file_stream << "Edgeworthw\n";
file_stream << "Ema\n";
file_stream << "EmaSkye\n";
file_stream << "Franny\n";
file_stream << "Franziska\n";
file_stream << "Gant\n";
file_stream << "Gavin\n";
file_stream << "Gavin K\n";
file_stream << "Godot\n";
file_stream << "Gregory\n";
file_stream << "Grossberg\n";
file_stream << "Gumshoe\n";
file_stream << "Gumshoey\n";
file_stream << "Hawk\n";
file_stream << "Hobo_Phoenix\n";
file_stream << "Ini\n";
file_stream << "Judge\n";
file_stream << "Judge's Bro\n";
file_stream << "Klav\n";
file_stream << "Klavier\n";
file_stream << "Kristoph\n";
file_stream << "Lana\n";
file_stream << "Layton\n";
file_stream << "Lotta\n";
file_stream << "Luis\n";
file_stream << "Maggey\n";
file_stream << "Manfred\n";
file_stream << "Marshall\n";
file_stream << "Matt\n";
file_stream << "Maya\n";
file_stream << "Mia\n";
file_stream << "Miles\n";
file_stream << "Oldbag\n";
file_stream << "Payne\n";
file_stream << "Pearl\n";
file_stream << "Phoenix\n";
file_stream << "Valant\n";
file_stream << "Vasquez\n";
file_stream << "Wellington\n";
file_stream << "Winston\n";
file_stream << "WinstonPayne\n";
file_stream << "Young Mia\n";
file_stream << "Zak\n";
char_list.flush();
char_list.close();
QFileInfo config_dir_info("config/");
if (!config_dir_info.exists() || !config_dir_info.isDir()) {
qCritical() << "Config directory doesn't exist!";
return false;
}
QFileInfo music_list_info("music.txt");
if (!(music_list_info.exists() && music_list_info.isFile())) {
QFile music_list("music.txt");
if (!music_list.open(QIODevice::WriteOnly | QIODevice::Text))
qDebug() << "Couldn't create music list";
QTextStream file_stream(&music_list);
// Check that areas, characters, and music lists all exist
QFileInfo areas_info("config/areas.ini");
QFileInfo characters_info("config/characters.txt");
QFileInfo music_info("config/music.txt");
qDebug() << "Creating vanilla music list";
file_stream << "Announce The Truth (AA).opus\n";
file_stream << "Announce The Truth (AJ).opus\n";
file_stream << "Announce The Truth (JFA).opus\n";
file_stream << "Announce The Truth (Miles).opus\n";
file_stream << "Announce The Truth (T&T).opus\n";
file_stream << "Confrontation ~ Presto 2009.opus\n";
file_stream << "Crises of Fate.opus\n";
file_stream << "Forgotten Legend.opus\n";
file_stream << "Godot - The Fragrance of Dark Coffee.opus\n";
file_stream << "Great Revival ~ Franziska von Karma.opus\n";
file_stream << "Great Revival ~ Miles Edgeworth.opus\n";
file_stream << "Hotline of Fate.opus\n";
file_stream << "Interesting People.opus\n";
file_stream << "Logic and Trick.opus\n";
file_stream << "Luke Atmey ~ I Just Want Love.opus\n";
file_stream << "Noisy People.opus\n";
file_stream << "OBJECTION (AA).opus\n";
file_stream << "Objection (AJ).opus\n";
file_stream << "OBJECTION (JFA).opus\n";
file_stream << "Objection (Miles).opus\n";
file_stream << "OBJECTION (T&T).opus\n";
file_stream << "Others ~ Guilty love.opus\n";
file_stream << "Prelude (AA).opus\n";
file_stream << "Prelude (AJ).opus\n";
file_stream << "Prologue (AA).opus\n";
file_stream << "Pursuit (AA) - variation.opus\n";
file_stream << "Pursuit (AA).opus\n";
file_stream << "Pursuit (AJ).opus\n";
file_stream << "Pursuit (DS).opus\n";
file_stream << "Pursuit (JFA) - variation.opus\n";
file_stream << "Pursuit (JFA).opus\n";
file_stream << "Pursuit (Miles).opus\n";
file_stream << "Pursuit (T&T) - variation.opus\n";
file_stream << "Pursuit (T&T).opus\n";
file_stream << "Pursuit ~ I Want to Find the Truth (Orchestra).opus\n";
file_stream << "Questioning AA (Allegro).opus\n";
file_stream << "Questioning AA (Moderato).opus\n";
file_stream << "Questioning AJ (Allegro).opus\n";
file_stream << "Questioning AJ (Moderato).opus\n";
file_stream << "Questioning JFA (Allegro).opus\n";
file_stream << "Questioning JFA (Moderato).opus\n";
file_stream << "Questioning T&T (Allegro).opus\n";
file_stream << "Questioning T&T (Moderato).opus\n";
file_stream << "Speak up Pup.opus\n";
file_stream << "Suspense (AA).opus\n";
file_stream << "The Great Truth Burglar.opus\n";
file_stream << "Trial (AA).opus\n";
file_stream << "Trial (AJ).opus\n";
file_stream << "Trial (Miles).opus\n";
music_list.flush();
music_list.close();
if (!fileExists(&areas_info)) {
qCritical() << "areas.ini doesn't exist!";
return false;
}
else {
QSettings areas_ini("config/areas.ini", QSettings::IniFormat);
if (areas_ini.childGroups().length() < 1) {
qCritical() << "areas.ini is invalid!";
return false;
}
}
if (!fileExists(&characters_info)) {
qCritical() << "characters.txt doesn't exist!";
return false;
}
if (!fileExists(&music_info)) {
qCritical() << "music.txt doesn't exist!";
return false;
}
config->beginGroup("Info");
QString config_version = config->value("version", "none").toString();
config->endGroup();
if (config_version == "none") {
QFileInfo check_file("config.ini");
// TODO: put proper translatable warnings here
if (!(check_file.exists() && check_file.isFile())) {
// TODO: send signal config doesn't exist
generateDefaultConfig(false);
QFileInfo check_file("config/config.ini");
if (!fileExists(&check_file)) {
qCritical() << "config.ini doesn't exist!";
}
else {
// TODO: send signal config is invalid
generateDefaultConfig(true);
qCritical() << "config.ini is invalid!";
}
return false;
}
else if (config_version != QString::number(CONFIG_VERSION)) {
bool version_number_is_valid;
int current_version = config_version.toInt(&version_number_is_valid);
if (version_number_is_valid)
updateConfig(current_version);
if (version_number_is_valid) {
if (updateConfig(current_version))
qWarning() << "config.ini was out of date, and has been updated. Please review the changes, and restart the server.";
else
qCritical() << "config.ini is invalid!";
}
else
generateDefaultConfig(true); // Version number isn't a number at all
// This means the config is invalid
// TODO: send invalid config signal
qCritical() << "config.ini is invalid!"; // Version number isn't a number at all
// This means the config is invalid
return false;
}
else {
@ -187,57 +89,19 @@ bool ConfigManager::initConfig()
}
}
// Setting backup_old to true will move the existing config.ini to
// config_old.ini
void ConfigManager::generateDefaultConfig(bool backup_old)
{
qDebug() << "Config is invalid or missing, making a new one...";
QDir dir = QDir::current();
if (backup_old) {
// TODO: failsafe if config_old.ini already exists
dir.rename("config.ini", "config_old.ini");
}
// Group: Info
// This contains basic metadata about the config
config->beginGroup("Info");
config->setValue("version", CONFIG_VERSION);
config->endGroup();
// Group: Options
// This contains general configuration
config->beginGroup("Options");
config->setValue("language", "en");
config->setValue("hostname", "$H");
config->setValue("max_players", "100");
config->setValue("port", "27016");
config->setValue("webao_enable", "true");
config->setValue("webao_port", "27017");
config->setValue("modpass", "password");
config->setValue("advertise", "true");
config->setValue("ms_ip", "master.aceattorneyonline.com");
config->setValue("ms_port", "27016");
config->setValue("server_name", "My First Server");
config->setValue("server_description", "This is my flashy new server");
config->setValue("multiclient_limit", "16");
config->setValue("max_message_size", "256");
config->endGroup();
}
// Ensure version continuity with config versions
void ConfigManager::updateConfig(int current_version)
bool ConfigManager::updateConfig(int current_version)
{
if (current_version > CONFIG_VERSION) {
// Config version is newer than the latest version, and the config is
// invalid This could also mean the server is out of date, and the user
// should be shown a relevant message Regardless, regen the config
// anyways
// TODO: send signal config is invalid
generateDefaultConfig(true);
return false;
}
else if (current_version < 0) {
// Negative version number? Invalid!
generateDefaultConfig(true);
return false;
}
else {
// TODO: send signal config is out of date, and is being updated
@ -253,6 +117,7 @@ void ConfigManager::updateConfig(int current_version)
break; // This is the newest version, and nothing more needs to be
// done
}
return true;
}
}
@ -293,3 +158,8 @@ bool ConfigManager::loadServerSettings(server_settings* settings)
return true;
}
}
bool ConfigManager::fileExists(QFileInfo* file)
{
return (file->exists() && file->isFile());
}

View File

@ -15,78 +15,55 @@
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////////////
#include "include/akashimain.h"
#include "include/advertiser.h"
#include "include/server.h"
#include "include/config_manager.h"
#ifdef _WIN32
#include <Windows.h>
#endif
#include <QApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDebug>
#include <QLibraryInfo>
#include <QSettings>
#include <QTranslator>
Advertiser* advertiser;
Server* server;
int main(int argc, char* argv[])
{
#ifdef _WIN32
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
#endif
#ifdef __linux__
// We have to do this before the QApplication is instantiated
// As a result, we can't use QCommandLineParser
for(int i = 0; i < argc; i++) {
if(strcmp("-l", argv[i]) == 0 || strcmp("--headless", argv[i]) == 0){
setenv("QT_QPA_PLATFORM", "minimal", 1);
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("akashi");
QCoreApplication::setApplicationVersion("0.0.1");
qDebug("Main application started");
ConfigManager config_manager;
if (config_manager.initConfig()) {
// Config is sound, so proceed with starting the server
// Validate some of the config before passing it on
ConfigManager::server_settings settings;
bool config_valid = config_manager.loadServerSettings(&settings);
if (!config_valid) {
qCritical() << "config.ini is invalid!";
qCritical() << "Exiting server due to configuration issue.";
return EXIT_FAILURE;
}
else {
if (settings.advertise_server) {
// TODO: send signal advertiser started
advertiser =
new Advertiser(settings.ms_ip, settings.port,
settings.ws_port, settings.local_port,
settings.name, settings.description);
advertiser->contactMasterServer();
}
// TODO: start the server here
// TODO: send signal server starting.
server = new Server(settings.port, settings.ws_port);
server->start();
}
} else {
qCritical() << "Exiting server due to configuration issue.";
return EXIT_FAILURE;
}
#endif
QApplication app(argc, argv);
QApplication::setApplicationName("akashi");
QApplication::setApplicationVersion("0.0.1");
QSettings config("config.ini", QSettings::IniFormat);
config.beginGroup("Options");
QString language =
config.value("language", QLocale().bcp47Name()).toString();
QTranslator qt_translator;
qt_translator.load("qt_" + language,
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qt_translator);
QTranslator translator;
translator.load("akashi_" + language, ":/resource/translation/");
app.installTranslator(&translator);
QCommandLineParser parser;
parser.setApplicationDescription(
app.translate("main", "A server for Attorney Online 2"));
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption headlessOption(
QStringList() << "l"
<< "headless",
app.translate("main", "Run the server without a GUI."));
QCommandLineOption verboseNetworkOption(
QStringList() << "nv"
<< "verbose-network",
app.translate("main", "Write all network traffic to the console."));
parser.addOption(headlessOption);
parser.addOption(verboseNetworkOption);
parser.process(app);
bool headless = parser.isSet(headlessOption);
AkashiMain w;
if (!headless)
w.show();
return app.exec();
}

View File

@ -43,28 +43,32 @@ void Server::start()
if(ws_port != -1)
proxy->start();
QFile char_list("characters.txt");
QFile char_list("config/characters.txt");
char_list.open(QIODevice::ReadOnly | QIODevice::Text);
while (!char_list.atEnd()) {
characters.append(char_list.readLine().trimmed());
}
char_list.close();
QFile music_file("music.txt");
QFile music_file("config/music.txt");
music_file.open(QIODevice::ReadOnly | QIODevice::Text);
while (!music_file.atEnd()) {
music_list.append(music_file.readLine().trimmed());
}
music_file.close();
if(music_list[0].contains(".")) // Add a default category if none exists
music_list.insert(0, "Music");
music_list.insert(0, "==Music==");
// TODO: add verification that this exists
QSettings areas_ini("areas.ini", QSettings::IniFormat);
QSettings areas_ini("config/areas.ini", QSettings::IniFormat);
area_names = areas_ini.childGroups();
for (int i = 0; i < area_names.length(); i++) {
QString area_name = area_names[i];
areas.insert(i, new AreaData(characters, area_name, i));
areas_ini.beginGroup(area_name);
// TODO: more area config
areas[i]->background = areas_ini.value("background", "gs4").toString();
areas_ini.endGroup();
qDebug() << "Added area" << area_name;
}
}