mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-04-30 00:11:47 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
26
.github/workflows/build.yml
vendored
26
.github/workflows/build.yml
vendored
|
@ -21,19 +21,19 @@ jobs:
|
||||||
run: zig build
|
run: zig build
|
||||||
- name: Test
|
- name: Test
|
||||||
run: zig build test
|
run: zig build test
|
||||||
ubuntu-build:
|
# ubuntu-build:
|
||||||
timeout-minutes: 15
|
# timeout-minutes: 15
|
||||||
continue-on-error: true
|
# continue-on-error: true
|
||||||
runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
steps:
|
# steps:
|
||||||
- uses: actions/checkout@v2
|
# - uses: actions/checkout@v2
|
||||||
- uses: goto-bus-stop/setup-zig@v2
|
# - uses: goto-bus-stop/setup-zig@v2
|
||||||
- name: Install OpenGL
|
# - name: Install OpenGL
|
||||||
run: apt-get libglu1-mesa-dev freeglut3-dev mesa-common-dev
|
# run: apt-get libglu1-mesa-dev freeglut3-dev mesa-common-dev
|
||||||
- name: Build
|
# - name: Build
|
||||||
run: zig build
|
# run: zig build
|
||||||
- name: Test
|
# - name: Test
|
||||||
run: zig build test
|
# run: zig build test
|
||||||
lint:
|
lint:
|
||||||
needs: build
|
needs: build
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Fatbag <X-Fi6@phppoll.org>
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Audio/Audio.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "windows/xaudio2.hpp"
|
|
||||||
#ifdef PlaySound //defined by the Windows API
|
|
||||||
#undef PlaySound
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct PlayableSound_t {
|
|
||||||
bool Playing;
|
|
||||||
uint8_t * Data;
|
|
||||||
IXAudio2SourceVoice* pSourceVoice;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Audio {
|
|
||||||
int Initialize();
|
|
||||||
PlayableSound_t * LoadSound(const Sound_t * Sound);
|
|
||||||
bool PlaySound(PlayableSound_t * Sound);
|
|
||||||
bool StopSound(PlayableSound_t * Sound);
|
|
||||||
void DeleteSound(PlayableSound_t * Sound);
|
|
||||||
void Shutdown();
|
|
||||||
}
|
|
|
@ -1,125 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Audio/Startup.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../EngineInterface.hpp"
|
|
||||||
|
|
||||||
namespace Audio {
|
|
||||||
|
|
||||||
IXAudio2 *pXAudio2 = NULL;
|
|
||||||
IXAudio2MasteringVoice *MasterVoice = NULL;
|
|
||||||
|
|
||||||
int Initialize(){
|
|
||||||
HRESULT result;
|
|
||||||
|
|
||||||
result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE | COINIT_SPEED_OVER_MEMORY);
|
|
||||||
if(result != S_OK){
|
|
||||||
MessageBox(Window::hWnd, "Failed to initialize Microsoft COM.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_AUDIO_INIT_COM;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = XAudio2Create(&pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
|
||||||
if(result != S_OK){
|
|
||||||
MessageBox(Window::hWnd, "Failed to initialize XAudio2. Please download the latest DirectX runtime for your system.",
|
|
||||||
NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_AUDIO_INIT_XAUDIO2;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = pXAudio2->CreateMasteringVoice(&MasterVoice, 2, 44100, 0, 0, NULL);
|
|
||||||
if(result != S_OK){
|
|
||||||
MessageBox(Window::hWnd, "Failed to create the mastering voice for XAudio2.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_AUDIO_CREATE_VOICE;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayableSound_t * LoadSound(const Sound_t * Sound){
|
|
||||||
const WAVEFORMATEX wfx = {
|
|
||||||
WAVE_FORMAT_PCM, //wFormatTag
|
|
||||||
Sound->Channels, //nChannels
|
|
||||||
Sound->SamplingRate, //nSamplesPerSec
|
|
||||||
((Sound->Channels * Sound->BitDepth) >> 3) * Sound->SamplingRate, //nAvgBytesPerSec
|
|
||||||
((Sound->Channels * Sound->BitDepth) >> 3), //nBlockAlign
|
|
||||||
Sound->BitDepth, //wBitsPerSample
|
|
||||||
0 //cbSize
|
|
||||||
};
|
|
||||||
|
|
||||||
const XAUDIO2_BUFFER buffer = {
|
|
||||||
0, //Flags
|
|
||||||
Sound->Duration * wfx.nBlockAlign, //AudioBytes
|
|
||||||
Sound->Data, //pAudioData
|
|
||||||
0, //PlayBegin
|
|
||||||
0, //PlayLength
|
|
||||||
0, //LoopBegin
|
|
||||||
0, //LoopLength
|
|
||||||
XAUDIO2_LOOP_INFINITE, //LoopCount
|
|
||||||
NULL, //pContext
|
|
||||||
};
|
|
||||||
|
|
||||||
IXAudio2SourceVoice* pSourceVoice;
|
|
||||||
if(FAILED(pXAudio2->CreateSourceVoice(&pSourceVoice, &wfx)))
|
|
||||||
return NULL;
|
|
||||||
if(FAILED(pSourceVoice->SubmitSourceBuffer(&buffer)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
PlayableSound_t * PlayableSound = (PlayableSound_t*) malloc(sizeof(PlayableSound_t));
|
|
||||||
if(!PlayableSound)
|
|
||||||
return NULL;
|
|
||||||
PlayableSound->pSourceVoice = pSourceVoice;
|
|
||||||
PlayableSound->Playing = false;
|
|
||||||
PlayableSound->Data = Sound->Data;
|
|
||||||
return PlayableSound;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PlaySound(PlayableSound_t * Sound){
|
|
||||||
if(!Sound->Playing && !FAILED(Sound->pSourceVoice->Start(0))){
|
|
||||||
Sound->Playing = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StopSound(PlayableSound_t * Sound){
|
|
||||||
int success = false;
|
|
||||||
if(Sound->Playing && !FAILED(Sound->pSourceVoice->Stop(0)))
|
|
||||||
success = true;
|
|
||||||
Sound->Playing = false;
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeleteSound(PlayableSound_t * Sound){
|
|
||||||
StopSound(Sound);
|
|
||||||
//Sound->pSourceVoice->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shutdown(){
|
|
||||||
if(MasterVoice){
|
|
||||||
MasterVoice->DestroyVoice();
|
|
||||||
MasterVoice = NULL;
|
|
||||||
}
|
|
||||||
if(pXAudio2){
|
|
||||||
pXAudio2->Release();
|
|
||||||
pXAudio2 = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
#include <initguid.h>
|
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_XAudio2, 0xe21a7345, 0xeb21, 0x468e, 0xbe, 0x50, 0x80, 0x4d, 0xb9, 0x7c, 0xf7, 0x08);
|
|
||||||
DEFINE_GUID(CLSID_XAudio2_Debug, 0xf7a76c21, 0x53d4, 0x46bb, 0xac, 0x53, 0x8b, 0x45, 0x9c, 0xae, 0x46, 0xbd);
|
|
||||||
DEFINE_GUID(IID_IXAudio2, 0x8bcf1f58, 0x9fe7, 0x4583, 0x8a, 0xc6, 0xe2, 0xad, 0xc4, 0x65, 0xc8, 0xbb);
|
|
|
@ -1,271 +0,0 @@
|
||||||
/*
|
|
||||||
xaudio2.hpp (2010-08-14)
|
|
||||||
author: OV2
|
|
||||||
|
|
||||||
ruby-specific header to provide mingw-friendly xaudio2 interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <unknwn.h>
|
|
||||||
#include <mmreg.h>
|
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_XAudio2, 0xe21a7345, 0xeb21, 0x468e, 0xbe, 0x50, 0x80, 0x4d, 0xb9, 0x7c, 0xf7, 0x08);
|
|
||||||
DEFINE_GUID(CLSID_XAudio2_Debug, 0xf7a76c21, 0x53d4, 0x46bb, 0xac, 0x53, 0x8b, 0x45, 0x9c, 0xae, 0x46, 0xbd);
|
|
||||||
DEFINE_GUID(IID_IXAudio2, 0x8bcf1f58, 0x9fe7, 0x4583, 0x8a, 0xc6, 0xe2, 0xad, 0xc4, 0x65, 0xc8, 0xbb);
|
|
||||||
|
|
||||||
DECLARE_INTERFACE(IXAudio2Voice);
|
|
||||||
|
|
||||||
#define XAUDIO2_COMMIT_NOW 0
|
|
||||||
#define XAUDIO2_DEFAULT_CHANNELS 0
|
|
||||||
#define XAUDIO2_DEFAULT_SAMPLERATE 0
|
|
||||||
#define XAUDIO2_DEFAULT_FREQ_RATIO 4.0f
|
|
||||||
#define XAUDIO2_DEBUG_ENGINE 0x0001
|
|
||||||
#define XAUDIO2_LOOP_INFINITE 255
|
|
||||||
#define XAUDIO2_VOICE_NOSRC 0x0004
|
|
||||||
|
|
||||||
enum XAUDIO2_DEVICE_ROLE
|
|
||||||
{
|
|
||||||
NotDefaultDevice = 0x0,
|
|
||||||
DefaultConsoleDevice = 0x1,
|
|
||||||
DefaultMultimediaDevice = 0x2,
|
|
||||||
DefaultCommunicationsDevice = 0x4,
|
|
||||||
DefaultGameDevice = 0x8,
|
|
||||||
GlobalDefaultDevice = 0xf,
|
|
||||||
InvalidDeviceRole = ~GlobalDefaultDevice
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_DEVICE_DETAILS
|
|
||||||
{
|
|
||||||
WCHAR DeviceID[256];
|
|
||||||
WCHAR DisplayName[256];
|
|
||||||
XAUDIO2_DEVICE_ROLE Role;
|
|
||||||
WAVEFORMATEXTENSIBLE OutputFormat;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_VOICE_DETAILS
|
|
||||||
{
|
|
||||||
UINT32 CreationFlags;
|
|
||||||
UINT32 InputChannels;
|
|
||||||
UINT32 InputSampleRate;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER
|
|
||||||
{
|
|
||||||
Processor1 = 0x00000001,
|
|
||||||
Processor2 = 0x00000002,
|
|
||||||
Processor3 = 0x00000004,
|
|
||||||
Processor4 = 0x00000008,
|
|
||||||
Processor5 = 0x00000010,
|
|
||||||
Processor6 = 0x00000020,
|
|
||||||
Processor7 = 0x00000040,
|
|
||||||
Processor8 = 0x00000080,
|
|
||||||
Processor9 = 0x00000100,
|
|
||||||
Processor10 = 0x00000200,
|
|
||||||
Processor11 = 0x00000400,
|
|
||||||
Processor12 = 0x00000800,
|
|
||||||
Processor13 = 0x00001000,
|
|
||||||
Processor14 = 0x00002000,
|
|
||||||
Processor15 = 0x00004000,
|
|
||||||
Processor16 = 0x00008000,
|
|
||||||
Processor17 = 0x00010000,
|
|
||||||
Processor18 = 0x00020000,
|
|
||||||
Processor19 = 0x00040000,
|
|
||||||
Processor20 = 0x00080000,
|
|
||||||
Processor21 = 0x00100000,
|
|
||||||
Processor22 = 0x00200000,
|
|
||||||
Processor23 = 0x00400000,
|
|
||||||
Processor24 = 0x00800000,
|
|
||||||
Processor25 = 0x01000000,
|
|
||||||
Processor26 = 0x02000000,
|
|
||||||
Processor27 = 0x04000000,
|
|
||||||
Processor28 = 0x08000000,
|
|
||||||
Processor29 = 0x10000000,
|
|
||||||
Processor30 = 0x20000000,
|
|
||||||
Processor31 = 0x40000000,
|
|
||||||
Processor32 = 0x80000000,
|
|
||||||
XAUDIO2_ANY_PROCESSOR = 0xffffffff,
|
|
||||||
XAUDIO2_DEFAULT_PROCESSOR = XAUDIO2_ANY_PROCESSOR
|
|
||||||
} XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER, XAUDIO2_PROCESSOR;
|
|
||||||
|
|
||||||
struct XAUDIO2_VOICE_SENDS
|
|
||||||
{
|
|
||||||
UINT32 OutputCount;
|
|
||||||
IXAudio2Voice* *pOutputVoices;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_EFFECT_DESCRIPTOR
|
|
||||||
{
|
|
||||||
IUnknown *pEffect;
|
|
||||||
BOOL InitialState;
|
|
||||||
UINT32 OutputChannels;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_EFFECT_CHAIN
|
|
||||||
{
|
|
||||||
UINT32 EffectCount;
|
|
||||||
const XAUDIO2_EFFECT_DESCRIPTOR *pEffectDescriptors;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum XAUDIO2_FILTER_TYPE
|
|
||||||
{
|
|
||||||
LowPassFilter,
|
|
||||||
BandPassFilter,
|
|
||||||
HighPassFilter
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_FILTER_PARAMETERS
|
|
||||||
{
|
|
||||||
XAUDIO2_FILTER_TYPE Type;
|
|
||||||
float Frequency;
|
|
||||||
float OneOverQ;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_BUFFER
|
|
||||||
{
|
|
||||||
UINT32 Flags;
|
|
||||||
UINT32 AudioBytes;
|
|
||||||
const BYTE *pAudioData;
|
|
||||||
UINT32 PlayBegin;
|
|
||||||
UINT32 PlayLength;
|
|
||||||
UINT32 LoopBegin;
|
|
||||||
UINT32 LoopLength;
|
|
||||||
UINT32 LoopCount;
|
|
||||||
void *pContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_BUFFER_WMA
|
|
||||||
{
|
|
||||||
const UINT32 *pDecodedPacketCumulativeBytes;
|
|
||||||
UINT32 PacketCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_VOICE_STATE
|
|
||||||
{
|
|
||||||
void *pCurrentBufferContext;
|
|
||||||
UINT32 BuffersQueued;
|
|
||||||
UINT64 SamplesPlayed;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_PERFORMANCE_DATA
|
|
||||||
{
|
|
||||||
UINT64 AudioCyclesSinceLastQuery;
|
|
||||||
UINT64 TotalCyclesSinceLastQuery;
|
|
||||||
UINT32 MinimumCyclesPerQuantum;
|
|
||||||
UINT32 MaximumCyclesPerQuantum;
|
|
||||||
UINT32 MemoryUsageInBytes;
|
|
||||||
UINT32 CurrentLatencyInSamples;
|
|
||||||
UINT32 GlitchesSinceEngineStarted;
|
|
||||||
UINT32 ActiveSourceVoiceCount;
|
|
||||||
UINT32 TotalSourceVoiceCount;
|
|
||||||
UINT32 ActiveSubmixVoiceCount;
|
|
||||||
UINT32 TotalSubmixVoiceCount;
|
|
||||||
UINT32 ActiveXmaSourceVoices;
|
|
||||||
UINT32 ActiveXmaStreams;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XAUDIO2_DEBUG_CONFIGURATION
|
|
||||||
{
|
|
||||||
UINT32 TraceMask;
|
|
||||||
UINT32 BreakMask;
|
|
||||||
BOOL LogThreadID;
|
|
||||||
BOOL LogFileline;
|
|
||||||
BOOL LogFunctionName;
|
|
||||||
BOOL LogTiming;
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE(IXAudio2EngineCallback)
|
|
||||||
{
|
|
||||||
STDMETHOD_(void, OnProcessingPassStart) (void);
|
|
||||||
STDMETHOD_(void, OnProcessingPassEnd) (void);
|
|
||||||
STDMETHOD_(void, OnCriticalError) (HRESULT Error);
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE(IXAudio2VoiceCallback)
|
|
||||||
{
|
|
||||||
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32 BytesRequired);
|
|
||||||
STDMETHOD_(void, OnVoiceProcessingPassEnd) (void);
|
|
||||||
STDMETHOD_(void, OnStreamEnd) (void);
|
|
||||||
STDMETHOD_(void, OnBufferStart) (void *pBufferContext);
|
|
||||||
STDMETHOD_(void, OnBufferEnd) (void *pBufferContext);
|
|
||||||
STDMETHOD_(void, OnLoopEnd) (void *pBufferContext);
|
|
||||||
STDMETHOD_(void, OnVoiceError) (void *pBufferContext, HRESULT Error);
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE(IXAudio2Voice)
|
|
||||||
{
|
|
||||||
STDMETHOD_(void, GetVoiceDetails) (XAUDIO2_VOICE_DETAILS *pVoiceDetails);
|
|
||||||
STDMETHOD(SetOutputVoices) (const XAUDIO2_VOICE_SENDS *pSendList);
|
|
||||||
STDMETHOD(SetEffectChain) (const XAUDIO2_EFFECT_CHAIN *pEffectChain);
|
|
||||||
STDMETHOD(EnableEffect) (UINT32 EffectIndex, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD(DisableEffect) (UINT32 EffectIndex, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetEffectState) (UINT32 EffectIndex, BOOL *pEnabled);
|
|
||||||
STDMETHOD(SetEffectParameters) (UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
|
|
||||||
UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD(GetEffectParameters) (UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize);
|
|
||||||
STDMETHOD(SetFilterParameters) (const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetFilterParameters) (XAUDIO2_FILTER_PARAMETERS *pParameters);
|
|
||||||
STDMETHOD(SetVolume) (float Volume, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetVolume) (float *pVolume);
|
|
||||||
STDMETHOD(SetChannelVolumes) (UINT32 Channels, const float *pVolumes, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetChannelVolumes) (UINT32 Channels, float *pVolumes);
|
|
||||||
STDMETHOD(SetOutputMatrix) (IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels, UINT32 DestinationChannels,
|
|
||||||
const float *pLevelMatrix, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetOutputMatrix) (IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
|
|
||||||
UINT32 DestinationChannels, float *pLevelMatrix);
|
|
||||||
STDMETHOD_(void, DestroyVoice) (void);
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice){};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE_(IXAudio2SubmixVoice, IXAudio2Voice){};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
|
|
||||||
{
|
|
||||||
STDMETHOD(Start) (UINT32 Flags, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD(Stop) (UINT32 Flags, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD(SubmitSourceBuffer) (const XAUDIO2_BUFFER *pBuffer, const XAUDIO2_BUFFER_WMA *pBufferWMA = NULL);
|
|
||||||
STDMETHOD(FlushSourceBuffers) (void);
|
|
||||||
STDMETHOD(Discontinuity) (void);
|
|
||||||
STDMETHOD(ExitLoop) (UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetState) (XAUDIO2_VOICE_STATE *pVoiceState);
|
|
||||||
STDMETHOD(SetFrequencyRatio) (float Ratio, UINT32 OperationSet = XAUDIO2_COMMIT_NOW);
|
|
||||||
STDMETHOD_(void, GetFrequencyRatio) (float *pRatio);
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_INTERFACE_(IXAudio2, IUnknown)
|
|
||||||
{
|
|
||||||
STDMETHOD(GetDeviceCount) (UINT32 *pCount);
|
|
||||||
STDMETHOD(GetDeviceDetails) (UINT32 Index, XAUDIO2_DEVICE_DETAILS *pDeviceDetails);
|
|
||||||
STDMETHOD(Initialize) (UINT32 Flags = 0, XAUDIO2_PROCESSOR XAudio2Processor = XAUDIO2_DEFAULT_PROCESSOR);
|
|
||||||
STDMETHOD(RegisterForCallbacks) (IXAudio2EngineCallback *pCallback);
|
|
||||||
STDMETHOD_(void, UnregisterForCallbacks) (IXAudio2EngineCallback *pCallback);
|
|
||||||
STDMETHOD(CreateSourceVoice) (IXAudio2SourceVoice* *ppSourceVoice, const WAVEFORMATEX *pSourceFormat, UINT32 Flags = 0,
|
|
||||||
float MaxFrequencyRatio = XAUDIO2_DEFAULT_FREQ_RATIO, IXAudio2VoiceCallback *pCallback = NULL,
|
|
||||||
const XAUDIO2_VOICE_SENDS *pSendList = NULL, const XAUDIO2_EFFECT_CHAIN *pEffectChain = NULL);
|
|
||||||
STDMETHOD(CreateSubmixVoice) (IXAudio2SubmixVoice* *ppSubmixVoice, UINT32 InputChannels, UINT32 InputSampleRate,
|
|
||||||
UINT32 Flags = 0, UINT32 ProcessingStage = 0, const XAUDIO2_VOICE_SENDS *pSendList = NULL,
|
|
||||||
const XAUDIO2_EFFECT_CHAIN *pEffectChain = NULL);
|
|
||||||
STDMETHOD(CreateMasteringVoice) (IXAudio2MasteringVoice* *ppMasteringVoice,
|
|
||||||
UINT32 InputChannels = XAUDIO2_DEFAULT_CHANNELS, UINT32 InputSampleRate = XAUDIO2_DEFAULT_SAMPLERATE,
|
|
||||||
UINT32 Flags = 0, UINT32 DeviceIndex = 0, const XAUDIO2_EFFECT_CHAIN *pEffectChain = NULL);
|
|
||||||
STDMETHOD(StartEngine) (void);
|
|
||||||
STDMETHOD_(void, StopEngine) (void);
|
|
||||||
STDMETHOD(CommitChanges) (UINT32 OperationSet);
|
|
||||||
STDMETHOD_(void, GetPerformanceData) (XAUDIO2_PERFORMANCE_DATA *pPerfData);
|
|
||||||
STDMETHOD_(void, SetDebugConfiguration) (const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration, void *pReserved = NULL);
|
|
||||||
};
|
|
||||||
|
|
||||||
inline HRESULT XAudio2Create(IXAudio2* *ppXAudio2, UINT32 Flags = 0,
|
|
||||||
XAUDIO2_PROCESSOR XAudio2Processor = XAUDIO2_DEFAULT_PROCESSOR)
|
|
||||||
{
|
|
||||||
IXAudio2 *pXAudio2;
|
|
||||||
HRESULT hr = CoCreateInstance((Flags & XAUDIO2_DEBUG_ENGINE) ? CLSID_XAudio2_Debug : CLSID_XAudio2, NULL,
|
|
||||||
CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2);
|
|
||||||
if(SUCCEEDED(hr)){
|
|
||||||
hr = pXAudio2->Initialize(Flags, XAudio2Processor);
|
|
||||||
if(SUCCEEDED(hr))
|
|
||||||
*ppXAudio2 = pXAudio2;
|
|
||||||
else
|
|
||||||
pXAudio2->Release();
|
|
||||||
}
|
|
||||||
return hr;
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
Technical Preview 1
|
|
||||||
* Initial release
|
|
|
@ -1,22 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.6)
|
|
||||||
project(NiotsoClient)
|
|
||||||
|
|
||||||
include_directories(${FILEHANDLER_INCLUDE} ${FREETYPE_INCLUDE})
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
set(NIOTSOCLIENT_SOURCES
|
|
||||||
Client.cpp
|
|
||||||
Audio/Startup.cpp
|
|
||||||
Audio/windows/XAudio2.cpp
|
|
||||||
Graphics/Font.cpp
|
|
||||||
Graphics/Startup.cpp
|
|
||||||
Graphics/Viewport.cpp
|
|
||||||
Resources/Resource.rc
|
|
||||||
Scene/LoginScreen/LoginScreen.cpp
|
|
||||||
System/System.cpp
|
|
||||||
Window/Window.cpp
|
|
||||||
)
|
|
||||||
add_executable(TSO WIN32 ${NIOTSOCLIENT_SOURCES})
|
|
||||||
target_link_libraries(TSO ole32 opengl32)
|
|
||||||
target_link_libraries(TSO FileHandler_shared ${FREETYPE_LINK})
|
|
||||||
endif()
|
|
642
Client/COPYING
642
Client/COPYING
|
@ -1,642 +0,0 @@
|
||||||
IMPORTANT:
|
|
||||||
Niotso is distributed under the terms of the GNU GPLv3.
|
|
||||||
|
|
||||||
While this license does permit others to compile, distribute, change,
|
|
||||||
and distribute changes to Niotso, in reality, many of these freedoms
|
|
||||||
cannot legally be enacted by anybody.
|
|
||||||
|
|
||||||
Specifically, if you make changes to Niotso such that it significantly
|
|
||||||
changes the "game experience as presented to the player", it cannot
|
|
||||||
be distributed to others. You also may not distribute a version of
|
|
||||||
Niotso that has stripped the EA or Maxis trademarked names or logos
|
|
||||||
anywhere from the game. Personal use of these modifications is okay.
|
|
||||||
|
|
||||||
These restrictions are not enforced by us, but may potentially be used
|
|
||||||
by EA in attempt to take down your game.
|
|
||||||
|
|
||||||
If you have any questions, you may visit
|
|
||||||
<http://wiki.niotso.org/Niotso/Legal_Summary>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Client.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "EngineInterface.hpp"
|
|
||||||
|
|
||||||
static void Shutdown();
|
|
||||||
Scene * CurrentScene;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
/* MinGW bonus feature; saves 66 kB in the binary :) */
|
|
||||||
/* */ void* __CRTDECL operator new(unsigned size){return malloc(size);}
|
|
||||||
/* */ void __CRTDECL operator delete(void *ptr){free(ptr);}
|
|
||||||
/* */ extern "C" void __CRTDECL __cxa_pure_virtual(){}
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
//Disallow multiple instances of the game from running
|
|
||||||
CreateMutex(NULL, TRUE, "Global\\TSO_NIOTSO_MUTEX");
|
|
||||||
if(GetLastError() == ERROR_ALREADY_EXISTS){
|
|
||||||
HWND hWnd = FindWindow("TSO_NIOTSO", "The Sims Online");
|
|
||||||
if(hWnd != NULL){
|
|
||||||
ShowWindow(hWnd, SW_RESTORE);
|
|
||||||
SetForegroundWindow(hWnd);
|
|
||||||
SetFocus(hWnd);
|
|
||||||
}
|
|
||||||
return ERROR_INIT_ANOTHERINSTRUNNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window::Width = 800;
|
|
||||||
Window::Height = 600;
|
|
||||||
Window::Fullscreen = false;
|
|
||||||
System::hInst = hInstance;
|
|
||||||
|
|
||||||
result = Window::Initialize();
|
|
||||||
if(result != 0){
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_INIT | ERROR_INIT_WINDOW | result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = System::Initialize();
|
|
||||||
if(result != 0){
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_INIT | ERROR_INIT_SYSTEM | result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = Graphics::Initialize();
|
|
||||||
if(result != 0){
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_INIT | ERROR_INIT_GRAPHICS | result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = Audio::Initialize();
|
|
||||||
if(result != 0){
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_INIT | ERROR_INIT_AUDIO | result;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentScene = new LoginScreen();
|
|
||||||
if(CurrentScene == NULL || System::SceneFailed){
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_INIT | ERROR_INIT_LOGIC | ERROR_LOGIC_CREATE_SCENE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowWindow(Window::hWnd, SW_SHOW);
|
|
||||||
SetForegroundWindow(Window::hWnd);
|
|
||||||
SetFocus(Window::hWnd);
|
|
||||||
|
|
||||||
LARGE_INTEGER PreviousTime;
|
|
||||||
QueryPerformanceCounter(&PreviousTime);
|
|
||||||
|
|
||||||
while(true){
|
|
||||||
LARGE_INTEGER CurrentTime;
|
|
||||||
QueryPerformanceCounter(&CurrentTime);
|
|
||||||
float TimeDelta = (float)(CurrentTime.QuadPart-PreviousTime.QuadPart)/System::ClockFreq.QuadPart;
|
|
||||||
PreviousTime = CurrentTime;
|
|
||||||
if(TimeDelta < 0 || TimeDelta >= 5) //Safe-guard in case of system delay
|
|
||||||
continue;
|
|
||||||
|
|
||||||
memcpy(&System::UserInput, (const void*) &System::UserInput_v, sizeof(System::UserInput_t));
|
|
||||||
|
|
||||||
int result = CurrentScene->RunFor(TimeDelta);
|
|
||||||
if(result == System::SHUTDOWN)
|
|
||||||
break;
|
|
||||||
if(result > 0){
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
CurrentScene->Render();
|
|
||||||
SwapBuffers(Graphics::hDC);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Sleep for the remainder of the frame
|
|
||||||
PreviousTime.QuadPart = CurrentTime.QuadPart;
|
|
||||||
QueryPerformanceCounter(&CurrentTime);
|
|
||||||
float SleepDuration =
|
|
||||||
(System::FramePeriod - (float)(CurrentTime.QuadPart-PreviousTime.QuadPart)/System::ClockFreq.QuadPart) * 1000;
|
|
||||||
if(SleepDuration > 1 && SleepDuration < 100) Sleep((unsigned) SleepDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowWindow(Window::hWnd, SW_HIDE);
|
|
||||||
delete CurrentScene;
|
|
||||||
|
|
||||||
Shutdown();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Shutdown()
|
|
||||||
{
|
|
||||||
Audio::Shutdown();
|
|
||||||
Graphics::Shutdown();
|
|
||||||
System::Shutdown();
|
|
||||||
Window::Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
EngineInterface.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Compiler/platform constants
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define WINVER 0x0502
|
|
||||||
#define _WIN32_WINNT 0x0502
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//Standard libraries
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#undef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//Codebase libraries
|
|
||||||
#include "FileHandler.hpp"
|
|
||||||
#include "ft2build.h"
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
|
|
||||||
//Macro definitions
|
|
||||||
#ifndef min
|
|
||||||
#define min(x,y) ((x)<(y)?(x):(y))
|
|
||||||
#endif
|
|
||||||
#ifndef max
|
|
||||||
#define max(x,y) ((x)>(y)?(x):(y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//Codebase version, branding, linker resources
|
|
||||||
#include "version.h"
|
|
||||||
#include "Resources/Resource.h"
|
|
||||||
|
|
||||||
//Components
|
|
||||||
#include "Audio/Audio.hpp"
|
|
||||||
#include "Graphics/Graphics.hpp"
|
|
||||||
#include "System/System.hpp"
|
|
||||||
#include "Window/Window.hpp"
|
|
||||||
|
|
||||||
#include "Scene/Scene.hpp"
|
|
|
@ -1,179 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Graphics/Font.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../EngineInterface.hpp"
|
|
||||||
|
|
||||||
namespace Graphics {
|
|
||||||
|
|
||||||
FT_Library FreeTypeLibrary;
|
|
||||||
FT_Face FontFace;
|
|
||||||
|
|
||||||
static void FindStringSize(const wchar_t * String, unsigned * width, unsigned * height, int * xoffset, int * yoffset, int font){
|
|
||||||
int x = 0, y = 0;
|
|
||||||
int lowestx = 0, lowesty = 0, highestx = 0, highesty = 0;
|
|
||||||
|
|
||||||
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
|
||||||
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
|
||||||
if(error) continue;
|
|
||||||
|
|
||||||
int bottomx = x + FontFace->glyph->bitmap_left;
|
|
||||||
int bottomy = y + FontFace->glyph->bitmap_top - FontFace->glyph->bitmap.rows;
|
|
||||||
if(bottomx < lowestx) lowestx = bottomx;
|
|
||||||
if(bottomy < lowesty) lowesty = bottomy;
|
|
||||||
|
|
||||||
int topx = x + FontFace->glyph->bitmap_left + FontFace->glyph->bitmap.width;
|
|
||||||
int topy = y + FontFace->glyph->bitmap_top;
|
|
||||||
if(topx > highestx) highestx = topx;
|
|
||||||
if(topy > highesty) highesty = topy;
|
|
||||||
|
|
||||||
x += FontFace->glyph->advance.x >> 6;
|
|
||||||
y += FontFace->glyph->advance.y >> 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
*width = highestx-lowestx, *height = highesty-lowesty;
|
|
||||||
*xoffset = -lowestx, *yoffset = -lowesty;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawText(Image_t * Image, const wchar_t * String, int x, int y, unsigned width, unsigned height,
|
|
||||||
TextAlignment Alignment, int font, COLORREF Color){
|
|
||||||
//x, y, width, height form the bounding rectangle into which the text should be drawn.
|
|
||||||
//(x,y) defines the offset to the top-left of the rectangle from the top left of the background.
|
|
||||||
//The destination image must be stored in bottom-up order.
|
|
||||||
|
|
||||||
if(x >= (signed)Image->Width || y >= (signed)Image->Height) return;
|
|
||||||
|
|
||||||
//(stringx,stringy) will refer to the top-left of the string in bottom-up coordinates
|
|
||||||
int stringx, stringy;
|
|
||||||
unsigned StringWidth, StringHeight;
|
|
||||||
FindStringSize(String, &StringWidth, &StringHeight, &stringx, &stringy, font);
|
|
||||||
|
|
||||||
//Horizontal alignment
|
|
||||||
if(Alignment < 2) stringx = x; //Left
|
|
||||||
else if(Alignment < 4) stringx = x+(width-StringWidth+1)/2; //Middle
|
|
||||||
else stringx = x+width-StringWidth; //Right
|
|
||||||
//Vertical alignment
|
|
||||||
if(!(Alignment&1)) stringy = y; //Top
|
|
||||||
else stringy = y+(height-StringHeight+1)/2; //Middle
|
|
||||||
stringy = Image->Height-stringy-StringHeight;
|
|
||||||
|
|
||||||
//Now that we've done the alignment, we can crop the bounding box within the limits of the background image
|
|
||||||
if(x < 0){ Image->Width += x; x = 0; }
|
|
||||||
if(y < 0){ Image->Height += y; y = 0; }
|
|
||||||
if(width > Image->Width) width = Image->Width;
|
|
||||||
if(height > Image->Height) height = Image->Height;
|
|
||||||
|
|
||||||
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
|
||||||
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
|
||||||
if(error) continue;
|
|
||||||
|
|
||||||
int cWidth = FontFace->glyph->bitmap.width, cHeight = FontFace->glyph->bitmap.rows;
|
|
||||||
if(cWidth && cHeight){
|
|
||||||
uint8_t * cRender; /* Convert to Bottom-up */
|
|
||||||
uint8_t * OriginalRender = FontFace->glyph->bitmap.buffer;
|
|
||||||
if(FontFace->glyph->bitmap.pitch > 0){
|
|
||||||
cRender = (uint8_t *) malloc(cWidth * cHeight);
|
|
||||||
for(int i=0; i<cHeight; i++)
|
|
||||||
memcpy(cRender + i*cWidth, OriginalRender + (cHeight-i-1)*cWidth, cWidth);
|
|
||||||
}else cRender = OriginalRender;
|
|
||||||
|
|
||||||
stringx += FontFace->glyph->bitmap_left;
|
|
||||||
stringy += FontFace->glyph->bitmap_top-cHeight;
|
|
||||||
for(int i=max(-stringy, 0); i<cHeight && (unsigned)stringy+i < height; i++){
|
|
||||||
for(int j=max(-stringx, 0); j<cWidth && (unsigned)stringx+j < width; j++){
|
|
||||||
int value = cRender[i*cWidth + j];
|
|
||||||
uint8_t *ptr = Image->Data + 3*((stringy+i)*width + (stringx+j));
|
|
||||||
|
|
||||||
int originalcolor;
|
|
||||||
originalcolor = *ptr;
|
|
||||||
*ptr++ = (uint8_t) (originalcolor + (int)((GetBValue(Color)-originalcolor)*2*value+255)/510);
|
|
||||||
originalcolor = *ptr;
|
|
||||||
*ptr++ = (uint8_t) (originalcolor + (int)((GetGValue(Color)-originalcolor)*2*value+255)/510);
|
|
||||||
originalcolor = *ptr;
|
|
||||||
*ptr++ = (uint8_t) (originalcolor + (int)((GetRValue(Color)-originalcolor)*2*value+255)/510);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stringx -= FontFace->glyph->bitmap_left;
|
|
||||||
stringy -= FontFace->glyph->bitmap_top-cHeight;
|
|
||||||
|
|
||||||
if(FontFace->glyph->bitmap.pitch > 0) free(cRender);
|
|
||||||
}
|
|
||||||
stringx += FontFace->glyph->advance.x >> 6;
|
|
||||||
stringy += FontFace->glyph->advance.y >> 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Image_t * StringImage(const wchar_t * String, int font, COLORREF Color){
|
|
||||||
Image_t * Image = (Image_t*) malloc(sizeof(Image_t));
|
|
||||||
if(Image == NULL) return NULL;
|
|
||||||
|
|
||||||
unsigned StringWidth, StringHeight;
|
|
||||||
int stringx, stringy;
|
|
||||||
FindStringSize(String, &StringWidth, &StringHeight, &stringx, &stringy, font);
|
|
||||||
|
|
||||||
Image->Data = (uint8_t*) malloc(4 * StringWidth * StringHeight);
|
|
||||||
if(Image->Data == NULL){
|
|
||||||
free(Image);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
for(unsigned i=0; i<4*StringWidth*StringHeight;){
|
|
||||||
Image->Data[i++] = GetBValue(Color);
|
|
||||||
Image->Data[i++] = GetGValue(Color);
|
|
||||||
Image->Data[i++] = GetRValue(Color);
|
|
||||||
Image->Data[i++] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
|
||||||
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
|
||||||
if(error) continue;
|
|
||||||
|
|
||||||
int cWidth = FontFace->glyph->bitmap.width, cHeight = FontFace->glyph->bitmap.rows;
|
|
||||||
if(cWidth && cHeight){
|
|
||||||
uint8_t * cRender; /* Convert to Bottom-up */
|
|
||||||
uint8_t * OriginalRender = FontFace->glyph->bitmap.buffer;
|
|
||||||
if(FontFace->glyph->bitmap.pitch > 0){
|
|
||||||
cRender = (uint8_t *) malloc(cWidth * cHeight);
|
|
||||||
for(int i=0; i<cHeight; i++)
|
|
||||||
memcpy(cRender + i*cWidth, OriginalRender + (cHeight-i-1)*cWidth, cWidth);
|
|
||||||
}else cRender = OriginalRender;
|
|
||||||
|
|
||||||
stringx += FontFace->glyph->bitmap_left;
|
|
||||||
stringy += FontFace->glyph->bitmap_top-cHeight;
|
|
||||||
for(int i=0; i<cHeight; i++){
|
|
||||||
for(int j=0; j<cWidth; j++){
|
|
||||||
uint8_t *ptr = Image->Data + 4*((stringy+i)*StringWidth + (stringx+j));
|
|
||||||
ptr[3] = cRender[i*cWidth + j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stringx -= FontFace->glyph->bitmap_left;
|
|
||||||
stringy -= FontFace->glyph->bitmap_top-cHeight;
|
|
||||||
|
|
||||||
if(FontFace->glyph->bitmap.pitch > 0) free(cRender);
|
|
||||||
}
|
|
||||||
stringx += FontFace->glyph->advance.x >> 6;
|
|
||||||
stringy += FontFace->glyph->advance.y >> 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
Image->Width = StringWidth;
|
|
||||||
Image->Height = StringHeight;
|
|
||||||
Image->Format = FIMG_BGRA32;
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Graphics/Graphics.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gl/gl.h>
|
|
||||||
#include <gl/glext.h>
|
|
||||||
|
|
||||||
//Graphics/Startup.cpp
|
|
||||||
namespace Graphics {
|
|
||||||
int Initialize();
|
|
||||||
void Shutdown();
|
|
||||||
extern HDC hDC;
|
|
||||||
extern HGLRC hRC;
|
|
||||||
|
|
||||||
int InitGL();
|
|
||||||
void ResizeViewport(unsigned width, unsigned height);
|
|
||||||
|
|
||||||
enum TextAlignment {
|
|
||||||
ALIGN_LEFT_TOP,
|
|
||||||
ALIGN_LEFT_CENTER,
|
|
||||||
ALIGN_CENTER_TOP,
|
|
||||||
ALIGN_CENTER_CENTER,
|
|
||||||
ALIGN_RIGHT_TOP,
|
|
||||||
ALIGN_RIGHT_CENTER
|
|
||||||
};
|
|
||||||
|
|
||||||
//Font.cpp
|
|
||||||
extern FT_Library FreeTypeLibrary;
|
|
||||||
extern FT_Face FontFace;
|
|
||||||
void DrawText(Image_t * Image, const wchar_t * String, int x, int y, unsigned width, unsigned height,
|
|
||||||
TextAlignment Alignment, int font, COLORREF Color);
|
|
||||||
Image_t * StringImage(const wchar_t * String, int font, COLORREF Color);
|
|
||||||
}
|
|
|
@ -1,121 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Graphics/Startup.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../EngineInterface.hpp"
|
|
||||||
|
|
||||||
namespace Graphics {
|
|
||||||
|
|
||||||
HDC hDC;
|
|
||||||
HGLRC hRC;
|
|
||||||
|
|
||||||
int Initialize(){
|
|
||||||
hDC = GetDC(Window::hWnd);
|
|
||||||
if(hDC == NULL){
|
|
||||||
MessageBox(Window::hWnd, "Failed to obtain the device context.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_GRAPHICS_OBTAIN_DC;
|
|
||||||
}
|
|
||||||
|
|
||||||
const PIXELFORMATDESCRIPTOR pfd = {
|
|
||||||
sizeof(PIXELFORMATDESCRIPTOR), 1, //Size and version
|
|
||||||
PFD_DRAW_TO_WINDOW | //dwFlags
|
|
||||||
PFD_SUPPORT_OPENGL |
|
|
||||||
PFD_DOUBLEBUFFER,
|
|
||||||
PFD_TYPE_RGBA, //iPixelType
|
|
||||||
24, //cColorBits
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, //R,G,B,A bits
|
|
||||||
0, 0, 0, 0, 0, //Accumulation buffer bits
|
|
||||||
16, //cDepthBits
|
|
||||||
0, //cStencilBits
|
|
||||||
0, //cAuxBuffers
|
|
||||||
PFD_MAIN_PLANE, //iLayerType
|
|
||||||
0, //Reserved
|
|
||||||
0, 0, 0 //Masks
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned PixelFormat = ChoosePixelFormat(hDC, &pfd);
|
|
||||||
if(!PixelFormat){
|
|
||||||
MessageBox(Window::hWnd, "Failed to find a suitable pixel format for the device context.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_GRAPHICS_FIND_PIXELFORMAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!SetPixelFormat(hDC, PixelFormat, &pfd)){
|
|
||||||
MessageBox(Window::hWnd, "Failed to set the pixel format for the device context.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_GRAPHICS_SET_PIXELFORMAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
hRC = wglCreateContext(hDC);
|
|
||||||
if(!hRC){
|
|
||||||
MessageBox(Window::hWnd, "Failed to create an OpenGL rendering context.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_GRAPHICS_CREATE_GLRC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!wglMakeCurrent(hDC, hRC)){
|
|
||||||
MessageBox(Window::hWnd, "Failed to activate the OpenGL device context.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_GRAPHICS_ACTIVATE_GLRC;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL (WINAPI *wglSwapIntervalEXT)(int) = (BOOL (WINAPI *)(int)) wglGetProcAddress("wglSwapIntervalEXT");
|
|
||||||
if(wglSwapIntervalEXT) wglSwapIntervalEXT(1);
|
|
||||||
int (WINAPI *wglGetSwapIntervalEXT)(void) = (int (WINAPI *)(void)) wglGetProcAddress("wglGetSwapIntervalEXT");
|
|
||||||
if(wglGetSwapIntervalEXT) wglGetSwapIntervalEXT(); //Seems necessary on some cards
|
|
||||||
|
|
||||||
int result = InitGL();
|
|
||||||
if(result != 0){
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_GRAPHICS_INIT_GLSCENE | result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResizeViewport(Window::Width, Window::Height);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int InitGL(){
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
glClearDepth(1.0f);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
glEnable(GL_RESCALE_NORMAL);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shutdown(){
|
|
||||||
if(Graphics::hRC){
|
|
||||||
wglMakeCurrent(NULL, NULL);
|
|
||||||
wglDeleteContext(Graphics::hRC);
|
|
||||||
Graphics::hRC = NULL;
|
|
||||||
}
|
|
||||||
if(Graphics::hDC){
|
|
||||||
ReleaseDC(Window::hWnd, Graphics::hDC);
|
|
||||||
Graphics::hDC = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Graphics/Viewport.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../EngineInterface.hpp"
|
|
||||||
|
|
||||||
void Graphics::ResizeViewport(unsigned width, unsigned height){
|
|
||||||
if(width == 0) width++;
|
|
||||||
if(height == 0) height++;
|
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
glOrtho(0, width, 0, height, 0.0, 1.0);
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
#define ID_VERSIONINFO 1
|
|
||||||
#define IDI_TSO 2
|
|
|
@ -1,32 +0,0 @@
|
||||||
#include <windows.h>
|
|
||||||
#include "../version.h"
|
|
||||||
#include "Resource.h"
|
|
||||||
|
|
||||||
IDI_TSO ICON "TSO.ico"
|
|
||||||
|
|
||||||
ID_VERSIONINFO VERSIONINFO
|
|
||||||
FILEVERSION VERSION_A,VERSION_B,VERSION_C,VERSION_D
|
|
||||||
PRODUCTVERSION VERSION_A,VERSION_B,VERSION_C,VERSION_D
|
|
||||||
FILEOS 0x00040000L //Windows 32-bit+
|
|
||||||
FILETYPE 1 //1 is exe, 2 is dll, and so on.
|
|
||||||
//The list can be found at <http://msdn.microsoft.com/en-us/library/aa381058.aspx>
|
|
||||||
BEGIN
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "040904B0"
|
|
||||||
BEGIN
|
|
||||||
VALUE "CompanyName", "Maxis™"
|
|
||||||
VALUE "FileDescription", "The Sims Online"
|
|
||||||
VALUE "FileVersion", VERSIONSTR
|
|
||||||
VALUE "InternalName", "TSO_NIOTSO"
|
|
||||||
VALUE "LegalCopyright", "Copyright © 2002-2005 Maxis™"
|
|
||||||
VALUE "OriginalFilename", "TSO.exe"
|
|
||||||
VALUE "ProductName", "The Sims Online"
|
|
||||||
VALUE "ProductVersion", VERSIONSTR
|
|
||||||
END
|
|
||||||
END
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x0409, 0x04B0
|
|
||||||
END
|
|
||||||
END
|
|
Binary file not shown.
Before Width: | Height: | Size: 61 KiB |
|
@ -1,226 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Scene/LoginScreen/LoginScreen.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../../EngineInterface.hpp"
|
|
||||||
|
|
||||||
static const wchar_t * const StatusStrings[] = {
|
|
||||||
L"Extruding Terrain Web",
|
|
||||||
L"Adjusting Emotional Weights",
|
|
||||||
L"Calibrating Personality Matrix",
|
|
||||||
|
|
||||||
L"Calculating Domestic Coefficients",
|
|
||||||
L"Readjusting Career Ladder",
|
|
||||||
L"Accessing Money Supply",
|
|
||||||
L"Hacking the Social Network",
|
|
||||||
L"Tweaking Chaos Control",
|
|
||||||
L"Downloading Reticulated Splines"
|
|
||||||
};
|
|
||||||
static const char * const images[] = {"eagames.bmp", "maxis.png", "setup.bmp"};
|
|
||||||
|
|
||||||
static const char * const sounds[] = {"loadloop.wav"};
|
|
||||||
|
|
||||||
LoginScreen::LoginScreen() : Scene(0){
|
|
||||||
Screen = Screen_EAGames;
|
|
||||||
Time = 0;
|
|
||||||
ScrollPos = -1;
|
|
||||||
memset(image, 0, IMG_COUNT * sizeof(Image_t *));
|
|
||||||
memset(texture, 0, TEX_COUNT * sizeof(GLuint));
|
|
||||||
memset(sound, 0, SND_COUNT * sizeof(PlayableSound_t *));
|
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
|
||||||
glGenTextures(TEX_COUNT, texture);
|
|
||||||
|
|
||||||
FT_Set_Char_Size(Graphics::FontFace, 0, 22*64, 0, 0);
|
|
||||||
|
|
||||||
for(int i=TEX_EAGAMES; i<=TEX_SETUP; i++){
|
|
||||||
Image_t * Image = File::ReadImageFile(images[i]);
|
|
||||||
if(!Image){
|
|
||||||
const char * Message;
|
|
||||||
switch(File::Error){
|
|
||||||
case FERR_NOT_FOUND:
|
|
||||||
Message = "%s does not exist.";
|
|
||||||
break;
|
|
||||||
case FERR_OPEN:
|
|
||||||
Message = "%s could not be opened for reading.";
|
|
||||||
break;
|
|
||||||
case FERR_BLANK:
|
|
||||||
case FERR_UNRECOGNIZED:
|
|
||||||
case FERR_INVALIDDATA:
|
|
||||||
Message = "%s is corrupt or invalid.";
|
|
||||||
break;
|
|
||||||
case FERR_MEMORY:
|
|
||||||
Message = "Memory for %s could not be allocated.";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Message = "%s could not be read.";
|
|
||||||
}
|
|
||||||
|
|
||||||
char Buffer[1024];
|
|
||||||
sprintf(Buffer, Message, images[i]);
|
|
||||||
MessageBox(Window::hWnd, Buffer, NULL, MB_OK | MB_ICONERROR);
|
|
||||||
EXIT_SCENE();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == TEX_MAXIS){
|
|
||||||
Graphics::DrawText(Image, L"Maxis\x2122 is an Electronic Arts\x2122 brand.", 0, 600-146, 800, 146,
|
|
||||||
Graphics::ALIGN_CENTER_CENTER, 0, RGB(0xef, 0xe3, 0x8c));
|
|
||||||
}
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[i]);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, Image->Width, Image->Height, 0, GL_BGR, GL_UNSIGNED_BYTE, Image->Data);
|
|
||||||
free(Image->Data);
|
|
||||||
free(Image);
|
|
||||||
}
|
|
||||||
|
|
||||||
image[IMG_COPYRIGHT] = Graphics::StringImage(L"(c) 2002, 2003 Electronic Arts Inc. All rights reserved.",
|
|
||||||
0, RGB(0xef, 0xe3, 0x8c));
|
|
||||||
if(image[IMG_COPYRIGHT] == NULL){
|
|
||||||
EXIT_SCENE();
|
|
||||||
}
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[TEX_COPYRIGHT]);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image[IMG_COPYRIGHT]->Width, image[IMG_COPYRIGHT]->Height, 0, GL_BGRA,
|
|
||||||
GL_UNSIGNED_BYTE, image[IMG_COPYRIGHT]->Data);
|
|
||||||
free(image[IMG_COPYRIGHT]->Data);
|
|
||||||
|
|
||||||
for(int i=0; i<9; i++){
|
|
||||||
image[IMG_STATUS+i] = Graphics::StringImage(StatusStrings[i], 0, RGB(0xef, 0xe3, 0x8c));
|
|
||||||
if(image[IMG_STATUS+i] == NULL){
|
|
||||||
EXIT_SCENE();
|
|
||||||
}
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[TEX_STATUS+i]);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image[IMG_STATUS+i]->Width, image[IMG_STATUS+i]->Height, 0, GL_BGRA,
|
|
||||||
GL_UNSIGNED_BYTE, image[IMG_STATUS+i]->Data);
|
|
||||||
free(image[IMG_STATUS+i]->Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0; i<SND_COUNT; i++){
|
|
||||||
Sound_t * Sound = File::ReadSoundFile(sounds[i]);
|
|
||||||
if(!Sound){
|
|
||||||
const char * Message;
|
|
||||||
switch(File::Error){
|
|
||||||
case FERR_NOT_FOUND:
|
|
||||||
Message = "%s does not exist.";
|
|
||||||
break;
|
|
||||||
case FERR_OPEN:
|
|
||||||
Message = "%s could not be opened for reading.";
|
|
||||||
break;
|
|
||||||
case FERR_BLANK:
|
|
||||||
case FERR_UNRECOGNIZED:
|
|
||||||
case FERR_INVALIDDATA:
|
|
||||||
Message = "%s is corrupt or invalid.";
|
|
||||||
break;
|
|
||||||
case FERR_MEMORY:
|
|
||||||
Message = "Memory for %s could not be allocated.";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Message = "%s could not be read.";
|
|
||||||
}
|
|
||||||
|
|
||||||
char Buffer[1024];
|
|
||||||
sprintf(Buffer, Message, sounds[i]);
|
|
||||||
MessageBox(Window::hWnd, Buffer, NULL, MB_OK | MB_ICONERROR);
|
|
||||||
EXIT_SCENE();
|
|
||||||
}
|
|
||||||
|
|
||||||
sound[i] = Audio::LoadSound(Sound);
|
|
||||||
free(Sound);
|
|
||||||
if(!sound){
|
|
||||||
MessageBox(Window::hWnd, "Sound could not be created", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
EXIT_SCENE();
|
|
||||||
}
|
|
||||||
Audio::PlaySound(sound[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LoginScreen::~LoginScreen(){
|
|
||||||
for(int i=0; i<IMG_COUNT; i++){ if(image[i]) free(image[i]); }
|
|
||||||
glDeleteTextures(TEX_COUNT, texture);
|
|
||||||
|
|
||||||
for(int i=0; i<SND_COUNT; i++){
|
|
||||||
if(sound[i]){
|
|
||||||
Audio::DeleteSound(sound[i]);
|
|
||||||
free(sound[i]->Data);
|
|
||||||
free(sound[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int LoginScreen::Run(float TimeDelta){
|
|
||||||
Time += TimeDelta;
|
|
||||||
if(ScrollPos != 8){
|
|
||||||
ScrollPos += TimeDelta*0.75;
|
|
||||||
if(ScrollPos > 8) ScrollPos = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Screen != Screen_Setup && Time >= 4.0){
|
|
||||||
Screen = (Screen==Screen_EAGames) ? Screen_Maxis : Screen_Setup;
|
|
||||||
Time = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(System::UserInput.CloseWindow){
|
|
||||||
return SCENE_EXIT;
|
|
||||||
}
|
|
||||||
return SCENE_NEED_REDRAW;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoginScreen::Render(){
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
|
||||||
|
|
||||||
//Background
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[Screen]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2i(0,0); glVertex2i(0,0);
|
|
||||||
glTexCoord2i(1,0); glVertex2i(800,0);
|
|
||||||
glTexCoord2i(1,1); glVertex2i(800,600);
|
|
||||||
glTexCoord2i(0,1); glVertex2i(0,600);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
if(Screen != Screen_Setup) return;
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[TEX_COPYRIGHT]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2i(0,0); glVertex2i((800-image[IMG_COPYRIGHT]->Width)/2,58);
|
|
||||||
glTexCoord2i(1,0); glVertex2i((800-image[IMG_COPYRIGHT]->Width)/2 + image[IMG_COPYRIGHT]->Width,58);
|
|
||||||
glTexCoord2i(1,1); glVertex2i((800-image[IMG_COPYRIGHT]->Width)/2 + image[IMG_COPYRIGHT]->Width,image[IMG_COPYRIGHT]->Height + 58);
|
|
||||||
glTexCoord2i(0,1); glVertex2i((800-image[IMG_COPYRIGHT]->Width)/2,image[IMG_COPYRIGHT]->Height + 58);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
for(int i=0; i<9; i++){
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[TEX_STATUS+i]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2i(0,0); glVertex2i(((float)i - ScrollPos)*800 + (800-image[IMG_STATUS+i]->Width)/2,20);
|
|
||||||
glTexCoord2i(1,0); glVertex2i(((float)i - ScrollPos)*800 + (800-image[IMG_STATUS+i]->Width)/2 + image[IMG_STATUS+i]->Width,20);
|
|
||||||
glTexCoord2i(1,1); glVertex2i(((float)i - ScrollPos)*800 + (800-image[IMG_STATUS+i]->Width)/2 + image[IMG_STATUS+i]->Width,image[IMG_STATUS+i]->Height + 20);
|
|
||||||
glTexCoord2i(0,1); glVertex2i(((float)i - ScrollPos)*800 + (800-image[IMG_STATUS+i]->Width)/2,image[IMG_STATUS+i]->Height + 20);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Scene/LoginScreen/LoginScreen.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class LoginScreen : public Scene {
|
|
||||||
enum {
|
|
||||||
IMG_COPYRIGHT,
|
|
||||||
IMG_STATUS, //value = 1..9
|
|
||||||
IMG_COUNT = 10
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
TEX_EAGAMES,
|
|
||||||
TEX_MAXIS,
|
|
||||||
TEX_SETUP,
|
|
||||||
TEX_COPYRIGHT,
|
|
||||||
TEX_STATUS, //value = 4..12
|
|
||||||
TEX_COUNT = 13
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
SND_LOADLOOP,
|
|
||||||
SND_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { Screen_EAGames, Screen_Maxis, Screen_Setup } Screen;
|
|
||||||
float Time;
|
|
||||||
float ScrollPos;
|
|
||||||
Image_t * image[IMG_COUNT];
|
|
||||||
GLuint texture[TEX_COUNT];
|
|
||||||
PlayableSound_t * sound[SND_COUNT];
|
|
||||||
|
|
||||||
public:
|
|
||||||
LoginScreen();
|
|
||||||
~LoginScreen();
|
|
||||||
void Render();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int Run(float TimeDelta);
|
|
||||||
};
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Scene/Scene.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define EXIT_SCENE() do { System::SceneFailed = true; delete this; return; } while(0)
|
|
||||||
#define SCENE_EXIT 0
|
|
||||||
#define SCENE_NEED_REDRAW 1
|
|
||||||
#define SCENE_NO_REDRAW -1
|
|
||||||
|
|
||||||
class Scene {
|
|
||||||
const float TickPeriod;
|
|
||||||
float RealTimeDelta;
|
|
||||||
virtual int Run(float TimeDelta) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
float TimeDelta;
|
|
||||||
Scene(float c) : TickPeriod(c), RealTimeDelta(0) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
int RunFor(float TimeDelta) {
|
|
||||||
if(TickPeriod == 0){
|
|
||||||
return Run(TimeDelta);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Redraw = false;
|
|
||||||
RealTimeDelta += TimeDelta;
|
|
||||||
while(RealTimeDelta >= 0){
|
|
||||||
int result = Run(TickPeriod);
|
|
||||||
if(result == System::SHUTDOWN)
|
|
||||||
return System::SHUTDOWN;
|
|
||||||
if(result > 0) Redraw = true;
|
|
||||||
RealTimeDelta -= TickPeriod;
|
|
||||||
}
|
|
||||||
return (Redraw) ? 1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Render() = 0;
|
|
||||||
virtual ~Scene() {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/****
|
|
||||||
** Scenes
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "LoginScreen/LoginScreen.hpp"
|
|
|
@ -1,67 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
System/System.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../EngineInterface.hpp"
|
|
||||||
|
|
||||||
namespace System {
|
|
||||||
|
|
||||||
HINSTANCE hInst = NULL;
|
|
||||||
LARGE_INTEGER ClockFreq;
|
|
||||||
volatile float FramePeriod;
|
|
||||||
UserInput_t UserInput = UserInput_t();
|
|
||||||
volatile UserInput_t UserInput_v;
|
|
||||||
bool SceneFailed = false;
|
|
||||||
|
|
||||||
int Initialize(){
|
|
||||||
QueryPerformanceFrequency(&ClockFreq);
|
|
||||||
|
|
||||||
DEVMODE dm;
|
|
||||||
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
|
|
||||||
System::FramePeriod = 1.0f/dm.dmDisplayFrequency;
|
|
||||||
|
|
||||||
if(FT_Init_FreeType(&Graphics::FreeTypeLibrary)){
|
|
||||||
MessageBox(Window::hWnd, "Failed to initialize FreeType.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Graphics::FreeTypeLibrary = NULL;
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_SYSTEM_INIT_FREETYPE;
|
|
||||||
};
|
|
||||||
if(FT_New_Face(Graphics::FreeTypeLibrary, "simdialogue-uni-game.ttf", 0, &Graphics::FontFace)){
|
|
||||||
MessageBox(Window::hWnd, "simdialogue-uni-game.ttf does not exist or is corrupt or invalid.",
|
|
||||||
NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Graphics::FontFace = NULL;
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_SYSTEM_MISSING_FONT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shutdown(){
|
|
||||||
if(Graphics::FontFace){
|
|
||||||
FT_Done_Face(Graphics::FontFace);
|
|
||||||
Graphics::FontFace = NULL;
|
|
||||||
}
|
|
||||||
if(Graphics::FreeTypeLibrary){
|
|
||||||
FT_Done_FreeType(Graphics::FreeTypeLibrary);
|
|
||||||
Graphics::FreeTypeLibrary = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
System/System.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace System {
|
|
||||||
int Initialize();
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
extern HINSTANCE hInst;
|
|
||||||
extern LARGE_INTEGER ClockFreq;
|
|
||||||
extern volatile float FramePeriod;
|
|
||||||
|
|
||||||
struct UserInput_t {
|
|
||||||
bool Keys[256];
|
|
||||||
bool MouseDown;
|
|
||||||
bool CloseWindow;
|
|
||||||
};
|
|
||||||
extern UserInput_t UserInput;
|
|
||||||
extern volatile UserInput_t UserInput_v;
|
|
||||||
|
|
||||||
extern bool SceneFailed;
|
|
||||||
|
|
||||||
//Constants
|
|
||||||
enum {
|
|
||||||
SHUTDOWN = 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/****
|
|
||||||
** Program exit codes
|
|
||||||
** (Return 0 for success)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ERROR_INIT 0x1000
|
|
||||||
#define ERROR_INIT_ANOTHERINSTRUNNING 0x1001
|
|
||||||
|
|
||||||
//Engine errors
|
|
||||||
//Use: return ERROR_INIT | result;
|
|
||||||
#define ERROR_INIT_WINDOW 0x0100
|
|
||||||
enum {
|
|
||||||
ERROR_WINDOW_SYNCOBJECT = 1,
|
|
||||||
ERROR_WINDOW_CREATE_THREAD,
|
|
||||||
ERROR_WINDOW_SYNCHRONIZE,
|
|
||||||
ERROR_WINDOW_REGISTER_CLASS,
|
|
||||||
ERROR_WINDOW_CREATE,
|
|
||||||
ERROR_WINDOW_HANDLE
|
|
||||||
};
|
|
||||||
#define ERROR_INIT_SYSTEM 0x0200
|
|
||||||
enum {
|
|
||||||
ERROR_SYSTEM_INIT_FREETYPE = 1,
|
|
||||||
ERROR_SYSTEM_MISSING_FONT
|
|
||||||
};
|
|
||||||
#define ERROR_INIT_GRAPHICS 0x0300
|
|
||||||
enum {
|
|
||||||
ERROR_GRAPHICS_OBTAIN_DC = 1,
|
|
||||||
ERROR_GRAPHICS_FIND_PIXELFORMAT,
|
|
||||||
ERROR_GRAPHICS_SET_PIXELFORMAT,
|
|
||||||
ERROR_GRAPHICS_CREATE_GLRC,
|
|
||||||
ERROR_GRAPHICS_ACTIVATE_GLRC,
|
|
||||||
ERROR_GRAPHICS_INIT_GLSCENE
|
|
||||||
};
|
|
||||||
#define ERROR_INIT_AUDIO 0x0400
|
|
||||||
enum {
|
|
||||||
ERROR_AUDIO_INIT_COM = 1,
|
|
||||||
ERROR_AUDIO_INIT_XAUDIO2,
|
|
||||||
ERROR_AUDIO_CREATE_VOICE
|
|
||||||
};
|
|
||||||
#define ERROR_INIT_LOGIC 0x0500
|
|
||||||
enum {
|
|
||||||
ERROR_LOGIC_CREATE_SCENE = 1
|
|
||||||
};
|
|
21
Client/TODO
21
Client/TODO
|
@ -1,21 +0,0 @@
|
||||||
Because there are too many long-term things to list that we still have "to do" to reach the next development phase (e.g.
|
|
||||||
alpha to beta), this file contains only the things that are worked on currently or that will be in the very near future.
|
|
||||||
|
|
||||||
While anybody is free to work on _anything_ at any point during Niotso's time, this list shall ONLY contain those relevant
|
|
||||||
to complete the criteria for the next development phase, which can be found here:
|
|
||||||
<http://wiki.niotso.org/Niotso_Release_Schedule>
|
|
||||||
|
|
||||||
//----------//
|
|
||||||
|
|
||||||
Development Phase: Planning
|
|
||||||
|
|
||||||
Technical Preview 1
|
|
||||||
Schedule: (Not very subject to change)
|
|
||||||
1. Implement cst, uis, ini, and xml parsers with support for UTF-8 [20%]
|
|
||||||
2. Replicate functionality up until the login dialog [90%]
|
|
||||||
3. Implement the audio engine
|
|
||||||
4. Implement the OpenGL-based windowing system
|
|
||||||
5. Replicate character selection and creation features and the city selection dialog
|
|
||||||
6. Implement debug logging and support for configuration files
|
|
||||||
7. Implement the code needed to allow the game to read all necessary files from the TSOClient folder
|
|
||||||
8. Port the client to Linux
|
|
|
@ -1,208 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Window/Window.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../EngineInterface.hpp"
|
|
||||||
|
|
||||||
namespace Window {
|
|
||||||
|
|
||||||
unsigned Width, Height;
|
|
||||||
bool Fullscreen;
|
|
||||||
HWND hWnd;
|
|
||||||
|
|
||||||
static HANDLE Response = NULL;
|
|
||||||
static HANDLE Thread = NULL;
|
|
||||||
static DWORD ThreadID = NULL;
|
|
||||||
static volatile int Result = NULL;
|
|
||||||
|
|
||||||
static DWORD WINAPI Procedure(LPVOID);
|
|
||||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
||||||
static int CreateWindowInvisible(HINSTANCE hInst, unsigned Width, unsigned Height, bool Fullscreen);
|
|
||||||
|
|
||||||
int Initialize(){
|
|
||||||
Response = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
||||||
if(Response == NULL){
|
|
||||||
MessageBox(NULL, "Failed to create the message loop synchronization object.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_WINDOW_SYNCOBJECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread = CreateThread(NULL, 1024 /* very tiny stack size is needed */, Window::Procedure, NULL, 0, &ThreadID);
|
|
||||||
if(Thread == NULL){
|
|
||||||
MessageBox(NULL, "Failed to create the message loop thread.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_WINDOW_CREATE_THREAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(WaitForSingleObject(Window::Response, INFINITE) != WAIT_OBJECT_0){
|
|
||||||
MessageBox(NULL, "Failed to synchronize with the message loop thread.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_WINDOW_SYNCHRONIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Result != 0){
|
|
||||||
Shutdown();
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
hWnd = FindWindow("TSO_NIOTSO", "The Sims Online");
|
|
||||||
if(hWnd == NULL){
|
|
||||||
MessageBox(NULL, "Failed to obtain a handle for the window.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
Shutdown();
|
|
||||||
return ERROR_WINDOW_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shutdown(){
|
|
||||||
if(hWnd){
|
|
||||||
DestroyWindow(hWnd);
|
|
||||||
hWnd = NULL;
|
|
||||||
}
|
|
||||||
if(Thread){
|
|
||||||
DWORD value;
|
|
||||||
while(GetExitCodeThread(Thread, &value) && value){
|
|
||||||
PostThreadMessage(ThreadID, WM_QUIT, 0, 0);
|
|
||||||
Sleep(1);
|
|
||||||
}
|
|
||||||
Thread = NULL;
|
|
||||||
}
|
|
||||||
if(Response){
|
|
||||||
CloseHandle(Response);
|
|
||||||
Response = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnregisterClass("TSO_NIOTSO", System::hInst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
|
||||||
switch(uMsg){
|
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
|
||||||
SetCursor(NULL);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
case WM_KEYUP:
|
|
||||||
System::UserInput_v.Keys[wParam] = (uMsg == WM_KEYDOWN);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_CLOSE:
|
|
||||||
System::UserInput_v.CloseWindow = true;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_DEVMODECHANGE: {
|
|
||||||
DEVMODE dm;
|
|
||||||
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
|
|
||||||
System::FramePeriod = 1.0f/dm.dmDisplayFrequency;
|
|
||||||
} return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD WINAPI Procedure(LPVOID){
|
|
||||||
int result = CreateWindowInvisible(System::hInst, Window::Width, Window::Height, Window::Fullscreen);
|
|
||||||
if(result != 0){
|
|
||||||
Window::Result = result;
|
|
||||||
SetEvent(Window::Response);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
SetEvent(Window::Response);
|
|
||||||
|
|
||||||
MSG msg;
|
|
||||||
while(GetMessage(&msg, NULL, 0, 0)){
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int CreateWindowInvisible(HINSTANCE hInst, unsigned Width, unsigned Height, bool Fullscreen)
|
|
||||||
{
|
|
||||||
const WNDCLASS wc = {
|
|
||||||
CS_OWNDC, //style
|
|
||||||
WndProc, //lpfnWndProc
|
|
||||||
0, //cbClsExtra
|
|
||||||
0, //cbWndExtra
|
|
||||||
hInst, //hInstance
|
|
||||||
(HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_TSO), //hIcon
|
|
||||||
IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE),
|
|
||||||
NULL, //hCursor
|
|
||||||
NULL, //hbrBackground
|
|
||||||
NULL, //lpszMenuName
|
|
||||||
"TSO_NIOTSO" //lpszClassName
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!RegisterClass(&wc)){
|
|
||||||
MessageBox(NULL, "Failed to register the window class.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
return ERROR_WINDOW_REGISTER_CLASS;
|
|
||||||
}
|
|
||||||
SetCursor(NULL);
|
|
||||||
|
|
||||||
HWND hWnd = NULL;
|
|
||||||
if(Fullscreen){
|
|
||||||
DEVMODE dmScreenSettings;
|
|
||||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
|
||||||
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL;
|
|
||||||
dmScreenSettings.dmPelsWidth = Width;
|
|
||||||
dmScreenSettings.dmPelsHeight = Height;
|
|
||||||
dmScreenSettings.dmBitsPerPel = 32;
|
|
||||||
|
|
||||||
if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL){
|
|
||||||
MessageBox(NULL, "Fullscreen mode is not supported by your setup. It has been turned off.", NULL,
|
|
||||||
MB_OK | MB_ICONERROR);
|
|
||||||
Fullscreen = 0;
|
|
||||||
}else{
|
|
||||||
hWnd = CreateWindowEx(WS_EX_APPWINDOW, "TSO_NIOTSO", "The Sims Online", WS_POPUP,
|
|
||||||
0, 0, Width, Height, 0, 0, hInst, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(hWnd == NULL){
|
|
||||||
Fullscreen = false;
|
|
||||||
RECT WindowRect = {0, 0, Width, Height};
|
|
||||||
|
|
||||||
//Use a style of WS_OVERLAPPEDWINDOW to allow resizing
|
|
||||||
AdjustWindowRectEx(&WindowRect, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE,
|
|
||||||
WS_EX_APPWINDOW); //This finds the dimensions of a window with a client area of our specified dimensions
|
|
||||||
|
|
||||||
//Note: Windows can be positioned anywhere, even outside the visible workspace,
|
|
||||||
//but their sizes are limited to the size of the workspace on the primary display.
|
|
||||||
unsigned WindowWidth = WindowRect.right-WindowRect.left, WindowHeight = WindowRect.bottom-WindowRect.top;
|
|
||||||
RECT WorkspaceRect;
|
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkspaceRect, 0);
|
|
||||||
|
|
||||||
hWnd = CreateWindowEx(WS_EX_APPWINDOW, "TSO_NIOTSO", "The Sims Online",
|
|
||||||
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
|
|
||||||
((WorkspaceRect.right-WorkspaceRect.left - WindowWidth)>>1) + WorkspaceRect.left,
|
|
||||||
((WorkspaceRect.bottom-WorkspaceRect.top - WindowHeight)>>1) + WorkspaceRect.top,
|
|
||||||
WindowWidth, WindowHeight, 0, 0, hInst, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hWnd == NULL){
|
|
||||||
MessageBox(NULL, "Failed to create the window.", NULL, MB_OK | MB_ICONERROR);
|
|
||||||
return ERROR_WINDOW_CREATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso - The New Implementation of The Sims Online
|
|
||||||
Window/Window.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Window {
|
|
||||||
int Initialize();
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
extern unsigned Width, Height;
|
|
||||||
extern bool Fullscreen;
|
|
||||||
extern HWND hWnd;
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
#define VERSION_A 0
|
|
||||||
#define VERSION_B 0
|
|
||||||
#define VERSION_C 0
|
|
||||||
#define VERSION_D 0
|
|
||||||
|
|
||||||
//You don't have to touch the following
|
|
||||||
#define xstr(x) str(x)
|
|
||||||
#define str(x) #x //Yes, double levels is required. See <http://gcc.gnu.org/onlinedocs/cpp/Stringification.html>
|
|
||||||
#define VERSIONSTR "" \
|
|
||||||
xstr(VERSION_A) "." xstr(VERSION_B) "." xstr(VERSION_C) "." xstr(VERSION_D)
|
|
|
@ -1 +0,0 @@
|
||||||
Fatbag <X-Fi6@phppoll.org>
|
|
|
@ -1,2 +0,0 @@
|
||||||
Technical Preview 1
|
|
||||||
* Initial release
|
|
|
@ -1,11 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.6)
|
|
||||||
project(NiotsoServer)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
else()
|
|
||||||
set(NIOTSOSERVER_SOURCES
|
|
||||||
Server.cpp
|
|
||||||
)
|
|
||||||
add_executable(niotsod-vanilla ${NIOTSOSERVER_SOURCES})
|
|
||||||
target_link_libraries(niotsod-vanilla)
|
|
||||||
endif()
|
|
642
Server/COPYING
642
Server/COPYING
|
@ -1,642 +0,0 @@
|
||||||
IMPORTANT:
|
|
||||||
Niotso is distributed under the terms of the GNU GPLv3.
|
|
||||||
|
|
||||||
While this license does permit others to compile, distribute, change,
|
|
||||||
and distribute changes to Niotso, in reality, many of these freedoms
|
|
||||||
cannot legally be enacted by anybody.
|
|
||||||
|
|
||||||
Specifically, if you make changes to Niotso such that it significantly
|
|
||||||
changes the "game experience as presented to the player", it cannot
|
|
||||||
be distributed to others. You also may not distribute a version of
|
|
||||||
Niotso that has stripped the EA or Maxis trademarked names or logos
|
|
||||||
anywhere from the game. Personal use of these modifications is okay.
|
|
||||||
|
|
||||||
These restrictions are not enforced by us, but may potentially be used
|
|
||||||
by EA in attempt to take down your game.
|
|
||||||
|
|
||||||
If you have any questions, you may visit
|
|
||||||
<http://wiki.niotso.org/Niotso/Legal_Summary>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
|
@ -1,177 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso Server - Niotso daemon based on PostgreSQL
|
|
||||||
Server.cpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include "Server.hpp"
|
|
||||||
|
|
||||||
#define SHUTDOWN(X) do { syslog(LOG_INFO, "<info> Could not recover from errors. Shutting down."); \
|
|
||||||
exitval = EXIT_FAILURE; goto X; } while(0)
|
|
||||||
#define SHUTDOWN_M(X, Y) do { syslog(LOG_ERR, "<error> %s (%s)", X, strerror(errno)); \
|
|
||||||
SHUTDOWN(Y); } while(0)
|
|
||||||
|
|
||||||
//IPV6_V6ONLY
|
|
||||||
|
|
||||||
static void term(int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int, char **)
|
|
||||||
{
|
|
||||||
const pid_t pid = fork();
|
|
||||||
if(pid < 0){
|
|
||||||
const char *msg1 = "<error> Failed to create child process (%s).", *msg2 = strerror(errno);
|
|
||||||
openlog(SERVER_NAME, 0, LOG_DAEMON);
|
|
||||||
syslog(LOG_ERR, msg1, msg2);
|
|
||||||
closelog();
|
|
||||||
fprintf(stderr, msg1, msg2);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}else if(pid > 0)
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
|
|
||||||
int exitval = EXIT_SUCCESS, sockfd, epollfd;
|
|
||||||
{ //New scope required for error handling
|
|
||||||
int ret;
|
|
||||||
FILE * fd;
|
|
||||||
|
|
||||||
umask(0);
|
|
||||||
|
|
||||||
openlog(SERVER_NAME, LOG_PID, LOG_DAEMON);
|
|
||||||
|
|
||||||
if(setsid() < 0)
|
|
||||||
SHUTDOWN_M("Failed to create session", close_msg);
|
|
||||||
|
|
||||||
if(chdir(CONFIG_DIR) < 0)
|
|
||||||
SHUTDOWN_M("Failed to change into \""CONFIG_DIR"\"", close_msg);
|
|
||||||
|
|
||||||
close(STDIN_FILENO);
|
|
||||||
close(STDOUT_FILENO);
|
|
||||||
close(STDERR_FILENO);
|
|
||||||
|
|
||||||
struct sigaction sigact;
|
|
||||||
sigact.sa_handler = term;
|
|
||||||
sigemptyset(&sigact.sa_mask);
|
|
||||||
sigact.sa_flags = 0;
|
|
||||||
sigaction(SIGTERM, &sigact, NULL);
|
|
||||||
sigaction(SIGINT, &sigact, NULL);
|
|
||||||
|
|
||||||
syslog(LOG_INFO, "<info> "SERVER_NAME" (version "VERSIONSTR") is starting...");
|
|
||||||
|
|
||||||
fd = fopen("network.conf", "r");
|
|
||||||
if(!fd)
|
|
||||||
SHUTDOWN_M("Failed to open \""CONFIG_DIR"/network.conf\"", close_msg);
|
|
||||||
unsigned int port = 0;
|
|
||||||
ret = fscanf(fd, "%u", &port);
|
|
||||||
fclose(fd);
|
|
||||||
if(ret < 0)
|
|
||||||
SHUTDOWN_M("Failed to read \""CONFIG_DIR"/network.conf\"", close_msg);
|
|
||||||
if(port > 65535){
|
|
||||||
syslog(LOG_ERR, "<error> Invalid port '%u' specified in \""CONFIG_DIR"/network.conf\".", port);
|
|
||||||
SHUTDOWN(close_msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
|
|
||||||
if(sockfd < 0)
|
|
||||||
SHUTDOWN_M("Failed to open socket", close_msg);
|
|
||||||
|
|
||||||
int flags = fcntl(sockfd, F_GETFL, 0);
|
|
||||||
if(flags < 0)
|
|
||||||
SHUTDOWN_M("Failed to read socket flags", close_socket);
|
|
||||||
if(fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) < 0)
|
|
||||||
SHUTDOWN_M("Failed to set socket flags", close_socket);
|
|
||||||
|
|
||||||
sockaddr_in6 server_addr, client_addr;
|
|
||||||
memset(&server_addr, 0, sizeof(sockaddr_in6));
|
|
||||||
memset(&client_addr, 0, sizeof(sockaddr_in6));
|
|
||||||
server_addr.sin6_family = AF_INET6;
|
|
||||||
server_addr.sin6_port = htons((uint16_t) port);
|
|
||||||
server_addr.sin6_addr = in6addr_any;
|
|
||||||
client_addr.sin6_family = AF_INET6;
|
|
||||||
client_addr.sin6_addr = in6addr_any;
|
|
||||||
|
|
||||||
if(bind(sockfd, (const sockaddr*) &server_addr, sizeof(sockaddr_in6)) < 0)
|
|
||||||
SHUTDOWN_M("Failed to bind to socket", close_socket);
|
|
||||||
|
|
||||||
epollfd = epoll_create(1);
|
|
||||||
if(epollfd < 0)
|
|
||||||
SHUTDOWN_M("Failed to create an epoll handle", close_socket);
|
|
||||||
|
|
||||||
epoll_event epev[1];
|
|
||||||
epev[0].events = EPOLLIN | EPOLLPRI;
|
|
||||||
epev[0].data.fd = sockfd;
|
|
||||||
if(epoll_ctl(epollfd, EPOLL_CTL_ADD, sockfd, epev) < 0)
|
|
||||||
SHUTDOWN_M("Failed to register the socket to the epoll handle", close_epoll);
|
|
||||||
|
|
||||||
//Now that we're running, stop being terminate-on-failure-happy
|
|
||||||
syslog(LOG_INFO, "<info> Running.");
|
|
||||||
|
|
||||||
/****
|
|
||||||
** Listen loop
|
|
||||||
*/
|
|
||||||
|
|
||||||
int eventcount;
|
|
||||||
while((eventcount = epoll_wait(epollfd, epev, 1, -1)) >= 0){
|
|
||||||
if(eventcount == 0)
|
|
||||||
continue;
|
|
||||||
else if(epev[0].events & EPOLLERR)
|
|
||||||
SHUTDOWN_M("Socket closed unexpectedly with EPOLLERR", close_epoll);
|
|
||||||
else if(epev[0].events & EPOLLHUP)
|
|
||||||
SHUTDOWN_M("Socket closed unexpectedly with EPOLLHUP", close_epoll);
|
|
||||||
else if(!(epev[0].events & EPOLLIN) && !(epev[0].events & EPOLLPRI))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
uint8_t packetdata[1500];
|
|
||||||
socklen_t addrlen = sizeof(sockaddr_in6);
|
|
||||||
ssize_t packetsize = recvfrom(epev[0].data.fd, packetdata, 1500, 0, (sockaddr*) &client_addr, &addrlen);
|
|
||||||
if(packetsize < 0){
|
|
||||||
if(errno == EINTR || errno == ECONNRESET || errno == ENOTCONN || errno == ETIMEDOUT ||
|
|
||||||
errno == EAGAIN || errno == EWOULDBLOCK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
SHUTDOWN_M("Socket closed unexpectedly on call to recvfrom", close_epoll);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Pass the packet down (even zero-length packets might be meaningful in the protocol)
|
|
||||||
//...
|
|
||||||
}
|
|
||||||
|
|
||||||
/****
|
|
||||||
** Shutdown
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
close_epoll: close(epollfd);
|
|
||||||
close_socket: close(sockfd);
|
|
||||||
close_msg: syslog(LOG_INFO, "<info> Shut down gracefully.");
|
|
||||||
closelog();
|
|
||||||
|
|
||||||
return exitval;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
Niotso Server - Niotso daemon based on PostgreSQL
|
|
||||||
Server.hpp
|
|
||||||
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
|
||||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SERVER_NAME "niotsod-vanilla"
|
|
||||||
#define CONFIG_DIR "/etc/"SERVER_NAME
|
|
||||||
|
|
||||||
#define VERSIONSTR "0.0.0"
|
|
10
Server/TODO
10
Server/TODO
|
@ -1,10 +0,0 @@
|
||||||
Because there are too many long-term things to list that we still have "to do" to reach the next development phase (e.g.
|
|
||||||
alpha to beta), this file contains only the things that are worked on currently or that will be in the very near future.
|
|
||||||
|
|
||||||
While anybody is free to work on _anything_ at any point during Niotso's time, this list shall ONLY contain those relevant
|
|
||||||
to complete the criteria for the next development phase, which can be found here:
|
|
||||||
<http://wiki.niotso.org/Niotso_Release_Schedule>
|
|
||||||
|
|
||||||
//----------//
|
|
||||||
|
|
||||||
Tasks will be added for the server when the development phase reaches Alpha.
|
|
77
code_of_conduct.md
Normal file
77
code_of_conduct.md
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our community include:
|
||||||
|
|
||||||
|
- Demonstrating empathy and kindness toward other people
|
||||||
|
- Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
- Giving and gracefully accepting constructive feedback
|
||||||
|
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||||
|
- Focusing on what is best not just for us as individuals, but for the overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
- The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||||
|
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
- Public or private harassment
|
||||||
|
- Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||||
|
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at \[INSERT CONTACT METHOD\]. All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1\. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2\. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||||
|
|
||||||
|
### 3\. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4\. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at <https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at <https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.
|
281
server/FSO.Server.Api.Core/Api.cs
Executable file
281
server/FSO.Server.Api.Core/Api.cs
Executable file
|
@ -0,0 +1,281 @@
|
||||||
|
using FSO.Server.Api.Core.Services;
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Common.Config;
|
||||||
|
using FSO.Server.Database.DA;
|
||||||
|
using FSO.Server.Domain;
|
||||||
|
using FSO.Server.Servers.Api.JsonWebToken;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core
|
||||||
|
{
|
||||||
|
public class Api : ApiAbstract
|
||||||
|
{
|
||||||
|
public static Api INSTANCE;
|
||||||
|
|
||||||
|
public IDAFactory DAFactory;
|
||||||
|
public ApiConfig Config;
|
||||||
|
public JWTFactory JWT;
|
||||||
|
public Shards Shards;
|
||||||
|
public IGluonHostPool HostPool;
|
||||||
|
public IUpdateUploader UpdateUploader;
|
||||||
|
public IUpdateUploader UpdateUploaderClient;
|
||||||
|
public GithubConfig Github;
|
||||||
|
|
||||||
|
public Api()
|
||||||
|
{
|
||||||
|
INSTANCE = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(NameValueCollection appSettings)
|
||||||
|
{
|
||||||
|
Config = new ApiConfig();
|
||||||
|
Config.Maintainance = bool.Parse(appSettings["maintainance"]);
|
||||||
|
Config.AuthTicketDuration = int.Parse(appSettings["authTicketDuration"]);
|
||||||
|
Config.Regkey = appSettings["regkey"];
|
||||||
|
Config.Secret = appSettings["secret"];
|
||||||
|
Config.UpdateUrl = appSettings["updateUrl"];
|
||||||
|
Config.CDNUrl = appSettings["cdnUrl"];
|
||||||
|
Config.NFSdir = appSettings["nfsdir"];
|
||||||
|
Config.UseProxy = bool.Parse(appSettings["useProxy"]);
|
||||||
|
Config.UpdateID = (appSettings["updateID"] == "") ? (int?)null : int.Parse(appSettings["updateID"]);
|
||||||
|
Config.BranchName = appSettings["branchName"] ?? "beta";
|
||||||
|
|
||||||
|
// new smtp config vars
|
||||||
|
if (appSettings["smtpHost"]!=null&&
|
||||||
|
appSettings["smtpUser"]!=null&&
|
||||||
|
appSettings["smtpPassword"]!=null&&
|
||||||
|
appSettings["smtpPort"]!=null)
|
||||||
|
{
|
||||||
|
Config.SmtpEnabled = true;
|
||||||
|
Config.SmtpHost = appSettings["smtpHost"];
|
||||||
|
Config.SmtpUser = appSettings["smtpUser"];
|
||||||
|
Config.SmtpPassword = appSettings["smtpPassword"];
|
||||||
|
Config.SmtpPort = int.Parse(appSettings["smtpPort"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
JWT = new JWTFactory(new JWTConfiguration()
|
||||||
|
{
|
||||||
|
Key = System.Text.UTF8Encoding.UTF8.GetBytes(Config.Secret)
|
||||||
|
});
|
||||||
|
|
||||||
|
DAFactory = new MySqlDAFactory(new Database.DatabaseConfiguration()
|
||||||
|
{
|
||||||
|
ConnectionString = appSettings["connectionString"]
|
||||||
|
});
|
||||||
|
|
||||||
|
Shards = new Shards(DAFactory);
|
||||||
|
Shards.AutoUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JWTUser RequireAuthentication(HttpRequest request)
|
||||||
|
{
|
||||||
|
JWTUser result;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(request.Headers["Authorization"]))
|
||||||
|
{
|
||||||
|
result = JWT.DecodeToken(GetAuthParam(request.Headers["Authorization"]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var cookies = request.Cookies;
|
||||||
|
if (cookies == null)
|
||||||
|
throw new SecurityException("Unable to find cookie");
|
||||||
|
|
||||||
|
|
||||||
|
var cookie = cookies["fso"];
|
||||||
|
if (string.IsNullOrEmpty(cookie))
|
||||||
|
{
|
||||||
|
throw new SecurityException("Unable to find cookie");
|
||||||
|
}
|
||||||
|
result = JWT.DecodeToken(cookie);
|
||||||
|
}
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
throw new SecurityException("Invalid token");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetAuthParam(string auth)
|
||||||
|
{
|
||||||
|
var ind = auth.IndexOf(' ');
|
||||||
|
if (ind == -1) return auth;
|
||||||
|
return auth.Substring(ind + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an email to a user to tell them that they're banned. ;(
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <param name="end_date"></param>
|
||||||
|
public void SendBanMail(string username, string email, uint end_date)
|
||||||
|
{
|
||||||
|
ApiMail banMail = new ApiMail("MailBan");
|
||||||
|
|
||||||
|
var date = end_date == 0 ? "Permanent ban" : Epoch.ToDate(end_date).ToString();
|
||||||
|
|
||||||
|
banMail.AddString("username", username);
|
||||||
|
banMail.AddString("end", date);
|
||||||
|
|
||||||
|
banMail.Send(email, "Banned from ingame");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an email to a user saying that the registration went OK.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
public void SendEmailConfirmationOKMail(string username, string email)
|
||||||
|
{
|
||||||
|
ApiMail confirmOKMail = new ApiMail("MailRegistrationOK");
|
||||||
|
|
||||||
|
confirmOKMail.AddString("username", username);
|
||||||
|
|
||||||
|
confirmOKMail.Send(email, "Welcome to FreeSO, " + username + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an email to a a new user with a token to create their user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="confirmation_url"></param>
|
||||||
|
/// <param name="expires"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SendEmailConfirmationMail(string email, string token, string confirmation_url, uint expires)
|
||||||
|
{
|
||||||
|
ApiMail confirmMail = new ApiMail("MailRegistrationToken");
|
||||||
|
|
||||||
|
confirmation_url = confirmation_url.Replace("%token%", token);
|
||||||
|
confirmMail.AddString("token", token);
|
||||||
|
confirmMail.AddString("expires", Epoch.HMSRemaining(expires));
|
||||||
|
confirmMail.AddString("confirmation_url", confirmation_url);
|
||||||
|
|
||||||
|
return confirmMail.Send(email, "Verify your FreeSO account");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an email to a user with a token to reset their password.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="confirmation_url"></param>
|
||||||
|
/// <param name="expires"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SendPasswordResetMail(string email, string username, string token, string confirmation_url, uint expires)
|
||||||
|
{
|
||||||
|
ApiMail confirmMail = new ApiMail("MailPasswordReset");
|
||||||
|
|
||||||
|
confirmation_url = confirmation_url.Replace("%token%", token);
|
||||||
|
confirmMail.AddString("token", token);
|
||||||
|
confirmMail.AddString("expires", Epoch.HMSRemaining(expires));
|
||||||
|
confirmMail.AddString("confirmation_url", confirmation_url);
|
||||||
|
|
||||||
|
return confirmMail.Send(email, "Password Reset for " + username);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a password change success email to a user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SendPasswordResetOKMail(string email, string username)
|
||||||
|
{
|
||||||
|
ApiMail confirmMail = new ApiMail("MailPasswordResetOK");
|
||||||
|
|
||||||
|
confirmMail.AddString("username", username);
|
||||||
|
|
||||||
|
return confirmMail.Send(email, "Your account password was reset");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DemandModerator(JWTUser user)
|
||||||
|
{
|
||||||
|
if (!user.Claims.Contains("moderator")) throw new Exception("Requires Moderator level status");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DemandAdmin(JWTUser user)
|
||||||
|
{
|
||||||
|
if (!user.Claims.Contains("admin")) throw new Exception("Requires Admin level status");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DemandModerator(HttpRequest request)
|
||||||
|
{
|
||||||
|
DemandModerator(RequireAuthentication(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DemandAdmin(HttpRequest request)
|
||||||
|
{
|
||||||
|
DemandAdmin(RequireAuthentication(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes a user's password.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user_id"></param>
|
||||||
|
/// <param name="new_password"></param>
|
||||||
|
public void ChangePassword(uint user_id, string new_password)
|
||||||
|
{
|
||||||
|
using (var da = DAFactory.Get())
|
||||||
|
{
|
||||||
|
var passhash = PasswordHasher.Hash(new_password);
|
||||||
|
var authSettings = new Database.DA.Users.UserAuthenticate();
|
||||||
|
authSettings.scheme_class = passhash.scheme;
|
||||||
|
authSettings.data = passhash.data;
|
||||||
|
authSettings.user_id = user_id;
|
||||||
|
|
||||||
|
da.Users.UpdateAuth(authSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a brand new user in db.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <param name="password"></param>
|
||||||
|
/// <param name="ip"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Database.DA.Users.User CreateUser(string username, string email, string password, string ip)
|
||||||
|
{
|
||||||
|
using (var da = DAFactory.Get())
|
||||||
|
{
|
||||||
|
var userModel = new Database.DA.Users.User();
|
||||||
|
userModel.username = username;
|
||||||
|
userModel.email = email;
|
||||||
|
userModel.is_admin = false;
|
||||||
|
userModel.is_moderator = false;
|
||||||
|
userModel.user_state = Database.DA.Users.UserState.valid;
|
||||||
|
userModel.register_date = Epoch.Now;
|
||||||
|
userModel.is_banned = false;
|
||||||
|
userModel.register_ip = ip;
|
||||||
|
userModel.last_ip = ip;
|
||||||
|
|
||||||
|
var passhash = PasswordHasher.Hash(password);
|
||||||
|
var authSettings = new Database.DA.Users.UserAuthenticate();
|
||||||
|
authSettings.scheme_class = passhash.scheme;
|
||||||
|
authSettings.data = passhash.data;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var userId = da.Users.Create(userModel);
|
||||||
|
authSettings.user_id = userId;
|
||||||
|
da.Users.CreateAuth(authSettings);
|
||||||
|
return da.Users.GetById(userId);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
server/FSO.Server.Api.Core/ApiConfig.cs
Executable file
42
server/FSO.Server.Api.Core/ApiConfig.cs
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
using FSO.Server.Api.Core.Services;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core
|
||||||
|
{
|
||||||
|
public class ApiConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// How long an auth ticket is valid for
|
||||||
|
/// </summary>
|
||||||
|
public int AuthTicketDuration = 300;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If non-null, the user must provide this key to register an account.
|
||||||
|
/// </summary>
|
||||||
|
public string Regkey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, only authentication from moderators and admins will be accepted
|
||||||
|
/// </summary>
|
||||||
|
public bool Maintainance { get; set; }
|
||||||
|
|
||||||
|
public string Secret { get; set; }
|
||||||
|
|
||||||
|
public string UpdateUrl { get; set; }
|
||||||
|
public string CDNUrl { get; set; }
|
||||||
|
|
||||||
|
public string NFSdir { get; set; }
|
||||||
|
|
||||||
|
public string SmtpHost { get; set; }
|
||||||
|
public int SmtpPort { get; set; }
|
||||||
|
public string SmtpPassword { get; set; }
|
||||||
|
public string SmtpUser { get; set; }
|
||||||
|
|
||||||
|
public bool SmtpEnabled { get; set; }
|
||||||
|
public bool UseProxy { get; set; }
|
||||||
|
|
||||||
|
public int? UpdateID { get; set; }
|
||||||
|
|
||||||
|
public string BranchName { get; set; } = "dev";
|
||||||
|
public IUpdateUploader UpdateUploader { get; set; }
|
||||||
|
}
|
||||||
|
}
|
157
server/FSO.Server.Api.Core/Controllers/Admin/AdminEventsController.cs
Executable file
157
server/FSO.Server.Api.Core/Controllers/Admin/AdminEventsController.cs
Executable file
|
@ -0,0 +1,157 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using FSO.Server.Api.Core.Models;
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Database.DA.DbEvents;
|
||||||
|
using FSO.Server.Database.DA.Tuning;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/events")]
|
||||||
|
[ApiController]
|
||||||
|
public class AdminEventsController : ControllerBase
|
||||||
|
{
|
||||||
|
//List events
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(int limit, int offset, string order)
|
||||||
|
{
|
||||||
|
if (limit == 0) limit = 20;
|
||||||
|
if (order == null) order = "start_day";
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (limit > 100)
|
||||||
|
{
|
||||||
|
limit = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = da.Events.All((int)offset, (int)limit, order);
|
||||||
|
return ApiResponse.PagedList<DbEvent>(Request, HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("presets")]
|
||||||
|
public IActionResult GetPresets()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return new JsonResult(da.Tuning.GetAllPresets().ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("presets")]
|
||||||
|
public IActionResult CreatePreset([FromBody]PresetCreateModel request)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
//make the preset first
|
||||||
|
var preset_id = da.Tuning.CreatePreset(
|
||||||
|
new DbTuningPreset()
|
||||||
|
{
|
||||||
|
name = request.name,
|
||||||
|
description = request.description,
|
||||||
|
flags = request.flags
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var item in request.items)
|
||||||
|
{
|
||||||
|
da.Tuning.CreatePresetItem(new DbTuningPresetItem()
|
||||||
|
{
|
||||||
|
preset_id = preset_id,
|
||||||
|
tuning_type = item.tuning_type,
|
||||||
|
tuning_table = item.tuning_table,
|
||||||
|
tuning_index = item.tuning_index,
|
||||||
|
value = item.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new JsonResult(da.Tuning.GetAllPresets().ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("presets/{preset_id}")]
|
||||||
|
public IActionResult GetPresetEntries(int preset_id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return new JsonResult(da.Tuning.GetPresetItems(preset_id).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("presets/{preset_id}")]
|
||||||
|
public IActionResult DeletePreset(int preset_id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return da.Tuning.DeletePreset(preset_id) ? (IActionResult)Ok() : NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST admin/updates (start update generation)
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Post([FromBody]EventCreateModel request)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
DbEventType type;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
type = Enum.Parse<DbEventType>(request.type);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return BadRequest("Event type must be one of:" + string.Join(", ", Enum.GetNames(typeof(DbEventType))));
|
||||||
|
}
|
||||||
|
var model = new DbEvent()
|
||||||
|
{
|
||||||
|
title = request.title,
|
||||||
|
description = request.description,
|
||||||
|
start_day = request.start_day,
|
||||||
|
end_day = request.end_day,
|
||||||
|
type = type,
|
||||||
|
value = request.value,
|
||||||
|
value2 = request.value2,
|
||||||
|
mail_subject = request.mail_subject,
|
||||||
|
mail_message = request.mail_message,
|
||||||
|
mail_sender = request.mail_sender,
|
||||||
|
mail_sender_name = request.mail_sender_name
|
||||||
|
};
|
||||||
|
return new JsonResult(new { id = da.Events.Add(model) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
[Route("{id}")]
|
||||||
|
public IActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
if (!da.Events.Delete(id)) return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
30
server/FSO.Server.Api.Core/Controllers/Admin/AdminHostsController.cs
Executable file
30
server/FSO.Server.Api.Core/Controllers/Admin/AdminHostsController.cs
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using System.Net;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/hosts")]
|
||||||
|
[ApiController]
|
||||||
|
public class AdminHostsController : ControllerBase
|
||||||
|
{
|
||||||
|
public IActionResult Get()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
var hosts = api.HostPool.GetAll();
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, hosts.Select(x => new {
|
||||||
|
role = x.Role,
|
||||||
|
call_sign = x.CallSign,
|
||||||
|
internal_host = x.InternalHost,
|
||||||
|
public_host = x.PublicHost,
|
||||||
|
connected = x.Connected,
|
||||||
|
time_boot = x.BootTime
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
129
server/FSO.Server.Api.Core/Controllers/Admin/AdminOAuthController.cs
Executable file
129
server/FSO.Server.Api.Core/Controllers/Admin/AdminOAuthController.cs
Executable file
|
@ -0,0 +1,129 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Servers.Api.JsonWebToken;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/oauth/token")]
|
||||||
|
[ApiController]
|
||||||
|
public class AdminOAuthController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Post([FromForm] AuthRequest auth)
|
||||||
|
{
|
||||||
|
if (auth == null) Ok();
|
||||||
|
if (auth.grant_type == "password")
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var user = da.Users.GetByUsername(auth.username);
|
||||||
|
if (user == null || user.is_banned || !(user.is_admin || user.is_moderator))
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new OAuthError
|
||||||
|
{
|
||||||
|
error = "unauthorized_client",
|
||||||
|
error_description = "user_credentials_invalid"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip = ApiUtils.GetIP(Request);
|
||||||
|
var accLock = da.Users.GetRemainingAuth(user.user_id, ip);
|
||||||
|
if (accLock != null && (accLock.active || accLock.count >= AuthLoginController.LockAttempts) && accLock.expire_time > Epoch.Now)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new OAuthError
|
||||||
|
{
|
||||||
|
error = "unauthorized_client",
|
||||||
|
error_description = "account_locked"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var authSettings = da.Users.GetAuthenticationSettings(user.user_id);
|
||||||
|
var isPasswordCorrect = PasswordHasher.Verify(auth.password, new PasswordHash
|
||||||
|
{
|
||||||
|
data = authSettings.data,
|
||||||
|
scheme = authSettings.scheme_class
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isPasswordCorrect)
|
||||||
|
{
|
||||||
|
var durations = AuthLoginController.LockDuration;
|
||||||
|
var failDelay = 60 * durations[Math.Min(durations.Length - 1, da.Users.FailedConsecutive(user.user_id, ip))];
|
||||||
|
if (accLock == null)
|
||||||
|
{
|
||||||
|
da.Users.NewFailedAuth(user.user_id, ip, (uint)failDelay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var remaining = da.Users.FailedAuth(accLock.attempt_id, (uint)failDelay, AuthLoginController.LockAttempts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new OAuthError
|
||||||
|
{
|
||||||
|
error = "unauthorized_client",
|
||||||
|
error_description = "user_credentials_invalid"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
da.Users.SuccessfulAuth(user.user_id, ip);
|
||||||
|
|
||||||
|
JWTUser identity = new JWTUser();
|
||||||
|
identity.UserName = user.username;
|
||||||
|
var claims = new List<string>();
|
||||||
|
if (user.is_admin || user.is_moderator)
|
||||||
|
{
|
||||||
|
claims.Add("moderator");
|
||||||
|
}
|
||||||
|
if (user.is_admin)
|
||||||
|
{
|
||||||
|
claims.Add("admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
identity.Claims = claims;
|
||||||
|
identity.UserID = user.user_id;
|
||||||
|
|
||||||
|
var token = api.JWT.CreateToken(identity);
|
||||||
|
|
||||||
|
var response = ApiResponse.Json(System.Net.HttpStatusCode.OK, new OAuthSuccess
|
||||||
|
{
|
||||||
|
access_token = token.Token,
|
||||||
|
expires_in = token.ExpiresIn
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new OAuthError
|
||||||
|
{
|
||||||
|
error = "invalid_request",
|
||||||
|
error_description = "unknown grant_type"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class OAuthError
|
||||||
|
{
|
||||||
|
public string error_description { get; set; }
|
||||||
|
public string error { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OAuthSuccess
|
||||||
|
{
|
||||||
|
public string access_token { get; set; }
|
||||||
|
public int expires_in { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AuthRequest
|
||||||
|
{
|
||||||
|
public string grant_type { get; set; }
|
||||||
|
public string username { get; set; }
|
||||||
|
public string password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
69
server/FSO.Server.Api.Core/Controllers/Admin/AdminShardsController.cs
Executable file
69
server/FSO.Server.Api.Core/Controllers/Admin/AdminShardsController.cs
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/shards")]
|
||||||
|
[ApiController]
|
||||||
|
public class AdminShardsController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
|
||||||
|
using (var db = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var shards = db.Shards.All();
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, shards);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("shutdown")]
|
||||||
|
public IActionResult shutdown(ShutdownModel sd)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
|
||||||
|
ShutdownType type = ShutdownType.SHUTDOWN;
|
||||||
|
if (sd.update) type = ShutdownType.UPDATE;
|
||||||
|
else if (sd.restart) type = ShutdownType.RESTART;
|
||||||
|
|
||||||
|
api.RequestShutdown((uint)sd.timeout, type);
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("announce")]
|
||||||
|
public IActionResult announce(AnnouncementModel an)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
api.BroadcastMessage(an.sender, an.subject, an.message);
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AnnouncementModel
|
||||||
|
{
|
||||||
|
public string sender;
|
||||||
|
public string subject;
|
||||||
|
public string message;
|
||||||
|
public int[] shard_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ShutdownModel
|
||||||
|
{
|
||||||
|
public int timeout;
|
||||||
|
public bool restart;
|
||||||
|
public bool update;
|
||||||
|
public int[] shard_ids;
|
||||||
|
}
|
||||||
|
}
|
73
server/FSO.Server.Api.Core/Controllers/Admin/AdminTasksController.cs
Executable file
73
server/FSO.Server.Api.Core/Controllers/Admin/AdminTasksController.cs
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Database.DA.Tasks;
|
||||||
|
using FSO.Server.Protocol.Gluon.Packets;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/tasks")]
|
||||||
|
[ApiController]
|
||||||
|
public class AdminTasksController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(int limit, int offset)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (limit > 100)
|
||||||
|
{
|
||||||
|
limit = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = da.Tasks.All((int)offset, (int)limit);
|
||||||
|
return ApiResponse.PagedList<DbTask>(Request, HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("request")]
|
||||||
|
public IActionResult request([FromBody] TaskRequest task)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
|
||||||
|
var taskServer = api.HostPool.GetByRole(Database.DA.Hosts.DbHostRole.task).FirstOrDefault();
|
||||||
|
if (taskServer == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var id = taskServer.Call(new RequestTask()
|
||||||
|
{
|
||||||
|
TaskType = task.task_type.ToString(),
|
||||||
|
ParameterJson = JsonConvert.SerializeObject(task.parameter),
|
||||||
|
ShardId = (task.shard_id == null || !task.shard_id.HasValue) ? -1 : task.shard_id.Value
|
||||||
|
}).Result;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, id);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class TaskRequest
|
||||||
|
{
|
||||||
|
public DbTaskType task_type;
|
||||||
|
public int? shard_id;
|
||||||
|
public dynamic parameter;
|
||||||
|
}
|
||||||
|
}
|
172
server/FSO.Server.Api.Core/Controllers/Admin/AdminUpdatesController.cs
Executable file
172
server/FSO.Server.Api.Core/Controllers/Admin/AdminUpdatesController.cs
Executable file
|
@ -0,0 +1,172 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FSO.Server.Api.Core.Models;
|
||||||
|
using FSO.Server.Api.Core.Services;
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Database.DA.Updates;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/updates")]
|
||||||
|
public class AdminUpdatesController : ControllerBase
|
||||||
|
{
|
||||||
|
//List updates
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(int limit, int offset, string order)
|
||||||
|
{
|
||||||
|
if (limit == 0) limit = 20;
|
||||||
|
if (order == null) order = "date";
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (limit > 100)
|
||||||
|
{
|
||||||
|
limit = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = da.Updates.All((int)offset, (int)limit);
|
||||||
|
return ApiResponse.PagedList<DbUpdate>(Request, HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GET all branches
|
||||||
|
[HttpGet("branches")]
|
||||||
|
public IActionResult GetBranches()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return new JsonResult(da.Updates.GetBranches().ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET all addons
|
||||||
|
[HttpGet("addons")]
|
||||||
|
public IActionResult GetAddons()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return new JsonResult(da.Updates.GetAddons(20).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST create a branch.
|
||||||
|
[HttpPost("branches")]
|
||||||
|
public IActionResult AddBranch(DbUpdateBranch branch)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
if (da.Updates.AddBranch(branch)) return Ok();
|
||||||
|
else return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST update a branch.
|
||||||
|
[HttpPost("branches/{id}")]
|
||||||
|
public IActionResult UpdateBranch(DbUpdateBranch branch)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
if (da.Updates.UpdateBranchInfo(branch)) return Ok();
|
||||||
|
else return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AddonUploadModel
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public IFormFile clientAddon { get; set; }
|
||||||
|
public IFormFile serverAddon { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
static int AddonRequestID = 0;
|
||||||
|
[HttpPost("uploadaddon")]
|
||||||
|
[DisableRequestSizeLimit]
|
||||||
|
[RequestFormLimits(MultipartBodyLengthLimit = 500000000)]
|
||||||
|
public async Task<IActionResult> UploadAddon(AddonUploadModel upload)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
var reqID = ++AddonRequestID;
|
||||||
|
|
||||||
|
var info = new DbUpdateAddon();
|
||||||
|
if (upload.name == null || upload.name.Length > 128) return BadRequest("Invalid name.");
|
||||||
|
if (upload.description == null || upload.description.Length > 1024) return BadRequest("Invalid description.");
|
||||||
|
info.name = upload.name;
|
||||||
|
info.description = upload.description;
|
||||||
|
info.date = DateTime.UtcNow;
|
||||||
|
|
||||||
|
if (upload.clientAddon == null && upload.serverAddon == null)
|
||||||
|
return BadRequest("client or server addon binary must be uploaded.");
|
||||||
|
|
||||||
|
var addonID = DateTime.UtcNow.Ticks;
|
||||||
|
Directory.CreateDirectory("updateTemp/addons/");
|
||||||
|
if (upload.clientAddon != null)
|
||||||
|
{
|
||||||
|
using (var file = System.IO.File.Open($"updateTemp/addons/client{reqID}.zip", FileMode.Create, FileAccess.Write, FileShare.None))
|
||||||
|
{
|
||||||
|
await upload.clientAddon.CopyToAsync(file);
|
||||||
|
}
|
||||||
|
info.addon_zip_url = await api.UpdateUploader.UploadFile($"addons/client{addonID}.zip", $"updateTemp/addons/client{reqID}.zip", $"addon-{addonID}");
|
||||||
|
System.IO.File.Delete($"updateTemp/addons/client{reqID}.zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upload.serverAddon != null)
|
||||||
|
{
|
||||||
|
using (var file = System.IO.File.Open($"updateTemp/addons/server{reqID}.zip", FileMode.Create, FileAccess.Write, FileShare.None))
|
||||||
|
{
|
||||||
|
await upload.serverAddon.CopyToAsync(file);
|
||||||
|
}
|
||||||
|
info.server_zip_url = await api.UpdateUploader.UploadFile($"addons/server{addonID}.zip", $"updateTemp/addons/server{reqID}.zip", $"addon-{addonID}");
|
||||||
|
System.IO.File.Delete($"updateTemp/addons/server{reqID}.zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
da.Updates.AddAddon(info);
|
||||||
|
return new JsonResult(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET status for ongoing update generation
|
||||||
|
[HttpGet("updateTask/{id}")]
|
||||||
|
public IActionResult GetTask(int id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
var task = GenerateUpdateService.INSTANCE.GetTask(id);
|
||||||
|
if (task == null) return NotFound();
|
||||||
|
else return new JsonResult(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST admin/updates (start update generation)
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Post([FromBody]UpdateCreateModel request)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
var task = GenerateUpdateService.INSTANCE.CreateTask(request);
|
||||||
|
return new JsonResult(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
334
server/FSO.Server.Api.Core/Controllers/Admin/AdminUsersController.cs
Executable file
334
server/FSO.Server.Api.Core/Controllers/Admin/AdminUsersController.cs
Executable file
|
@ -0,0 +1,334 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Database.DA.Inbox;
|
||||||
|
using FSO.Server.Database.DA.Users;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||||
|
{
|
||||||
|
[EnableCors("AdminAppPolicy")]
|
||||||
|
[Route("admin/users")]
|
||||||
|
[ApiController]
|
||||||
|
public class AdminUsersController : ControllerBase
|
||||||
|
{
|
||||||
|
//Get information about me, useful for the admin user interface to disable UI based on who you login as
|
||||||
|
public IActionResult current()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
var user = api.RequireAuthentication(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var userModel = da.Users.GetById(user.UserID);
|
||||||
|
if (userModel == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Unable to find user");
|
||||||
|
}
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, userModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Get the attributes of a specific user
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public IActionResult Get(string id)
|
||||||
|
{
|
||||||
|
if (id == "current") return current();
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var userModel = da.Users.GetById(uint.Parse(id));
|
||||||
|
if (userModel == null) { throw new Exception("Unable to find user"); }
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, userModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unbans a user by IP and user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user_id">ID of user to unban.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("admin/unban")]
|
||||||
|
public IActionResult UnbanUser([FromBody] string user_id)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
User userModel = da.Users.GetById(uint.Parse(user_id));
|
||||||
|
|
||||||
|
if(userModel.is_banned)
|
||||||
|
{
|
||||||
|
da.Users.UpdateBanned(uint.Parse(user_id), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var ban = da.Bans.GetByIP(userModel.last_ip);
|
||||||
|
|
||||||
|
if (ban!=null)
|
||||||
|
{
|
||||||
|
da.Bans.Remove(userModel.user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an in-game email message to a player.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mail"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("admin/mail")]
|
||||||
|
public IActionResult SendMail(MailCreateModel mail)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
api.DemandAdmin(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
User recipient = da.Users.GetById(uint.Parse(mail.target_id));
|
||||||
|
|
||||||
|
if (recipient == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "invalid_target_id"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mail.subject.Trim() == "")
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "subject_empty"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mail.body.Trim() == "")
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "body_empty"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save mail in db
|
||||||
|
int message_id = da.Inbox.CreateMessage(new DbInboxMsg
|
||||||
|
{
|
||||||
|
sender_id = 2147483648,
|
||||||
|
target_id = uint.Parse(mail.target_id),
|
||||||
|
subject = mail.subject,
|
||||||
|
body = mail.body,
|
||||||
|
sender_name = "FreeSO Staff",
|
||||||
|
time = DateTime.UtcNow,
|
||||||
|
msg_type = 4,
|
||||||
|
msg_subtype = 0,
|
||||||
|
read_state = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Try and notify the user ingame
|
||||||
|
api.RequestMailNotify(message_id, mail.subject, mail.body, uint.Parse(mail.target_id));
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Kicks a user out the current session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="kick"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("admin/kick")]
|
||||||
|
public IActionResult KickUser([FromBody] string user_id)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
api.RequestUserDisconnect(uint.Parse(user_id));
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new {
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bans a user and kicks them.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ban"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("admin/ban")]
|
||||||
|
public IActionResult BanUser(BanCreateModel ban)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
User userModel = da.Users.GetById(uint.Parse(ban.user_id));
|
||||||
|
|
||||||
|
if (userModel == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "invalid_id"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban.ban_type == "ip")
|
||||||
|
{
|
||||||
|
if (da.Bans.GetByIP(userModel.last_ip) != null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "already_banned"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userModel.last_ip == "127.0.0.1")
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "invalid_ip"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
da.Bans.Add(userModel.last_ip, userModel.user_id, ban.reason, int.Parse(ban.end_date), userModel.client_id);
|
||||||
|
|
||||||
|
api.RequestUserDisconnect(userModel.user_id);
|
||||||
|
|
||||||
|
api.SendBanMail(userModel.username, userModel.email, uint.Parse(ban.end_date));
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (ban.ban_type == "user")
|
||||||
|
{
|
||||||
|
if (userModel.is_banned)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.NotFound, new
|
||||||
|
{
|
||||||
|
status = "already_banned"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
da.Users.UpdateBanned(userModel.user_id, true);
|
||||||
|
|
||||||
|
api.RequestUserDisconnect(userModel.user_id);
|
||||||
|
|
||||||
|
api.SendBanMail(userModel.username, userModel.email, uint.Parse(ban.end_date));
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "invalid_ban_type"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//List users
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(int limit, int offset, string order)
|
||||||
|
{
|
||||||
|
if (limit == 0) limit = 20;
|
||||||
|
if (order == null) order = "register_date";
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (limit > 100)
|
||||||
|
{
|
||||||
|
limit = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = da.Users.All((int)offset, (int)limit);
|
||||||
|
return ApiResponse.PagedList<User>(Request, HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a new user
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Post(UserCreateModel user)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
var nuser = api.RequireAuthentication(Request);
|
||||||
|
api.DemandModerator(nuser);
|
||||||
|
|
||||||
|
if (user.is_admin)
|
||||||
|
{
|
||||||
|
//I need admin claim to do this
|
||||||
|
api.DemandAdmin(nuser);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var userModel = new User();
|
||||||
|
userModel.username = user.username;
|
||||||
|
userModel.email = user.email;
|
||||||
|
userModel.is_admin = user.is_admin;
|
||||||
|
userModel.is_moderator = user.is_moderator;
|
||||||
|
userModel.user_state = UserState.valid;
|
||||||
|
userModel.register_date = Epoch.Now;
|
||||||
|
userModel.is_banned = false;
|
||||||
|
|
||||||
|
var userId = da.Users.Create(userModel);
|
||||||
|
|
||||||
|
userModel = da.Users.GetById(userId);
|
||||||
|
if (userModel == null) { throw new Exception("Unable to find user"); }
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, userModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UserCreateModel
|
||||||
|
{
|
||||||
|
public string username { get; set; }
|
||||||
|
public string email { get; set; }
|
||||||
|
public string password { get; set; }
|
||||||
|
public bool is_admin { get; set; }
|
||||||
|
public bool is_moderator { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BanCreateModel
|
||||||
|
{
|
||||||
|
public string ban_type { get; set; }
|
||||||
|
public string user_id { get; set; }
|
||||||
|
public string reason { get; set; }
|
||||||
|
public string end_date { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MailCreateModel
|
||||||
|
{
|
||||||
|
public string target_id { get; set; }
|
||||||
|
public string subject { get; set; }
|
||||||
|
public string body { get; set; }
|
||||||
|
public string sender_name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
134
server/FSO.Server.Api.Core/Controllers/AuthLoginController.cs
Executable file
134
server/FSO.Server.Api.Core/Controllers/AuthLoginController.cs
Executable file
|
@ -0,0 +1,134 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Database.DA.AuthTickets;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[Route("AuthLogin")]
|
||||||
|
[ApiController]
|
||||||
|
public class AuthLoginController : ControllerBase
|
||||||
|
{
|
||||||
|
private static Func<IActionResult> ERROR_020 = printError("INV-020", "Please enter your member name and password.");
|
||||||
|
private static Func<IActionResult> ERROR_110 = printError("INV-110", "The member name or password you have entered is incorrect. Please try again.");
|
||||||
|
private static Func<IActionResult> ERROR_302 = printError("INV-302", "The game has experienced an internal error. Please try again.");
|
||||||
|
private static Func<IActionResult> ERROR_160 = printError("INV-160", "The server is currently down for maintainance. Please try again later.");
|
||||||
|
private static Func<IActionResult> ERROR_150 = printError("INV-150", "We're sorry, but your account has been suspended or cancelled.");
|
||||||
|
private static string LOCK_MESSAGE = "Your account has been locked due to too many incorrect login attempts. " +
|
||||||
|
"If you cannot remember your password, it can be reset at https://beta.freeso.org/forgot. Locked for: ";
|
||||||
|
|
||||||
|
public static int LockAttempts = 5;
|
||||||
|
|
||||||
|
public static int[] LockDuration = new int[] {
|
||||||
|
5,
|
||||||
|
15,
|
||||||
|
30,
|
||||||
|
60,
|
||||||
|
120,
|
||||||
|
720,
|
||||||
|
1440
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET api/<controller>
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(string username, string password, string version, string clientid)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
return ERROR_020();
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthTicket ticket = null;
|
||||||
|
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var db = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var user = db.Users.GetByUsername(username);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return ERROR_110();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.is_banned)
|
||||||
|
{
|
||||||
|
return ERROR_150();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (api.Config.Maintainance && !(user.is_admin || user.is_moderator))
|
||||||
|
{
|
||||||
|
return ERROR_160();
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip = ApiUtils.GetIP(Request);
|
||||||
|
|
||||||
|
var accLock = db.Users.GetRemainingAuth(user.user_id, ip);
|
||||||
|
if (accLock != null && (accLock.active || accLock.count >= LockAttempts) && accLock.expire_time > Epoch.Now)
|
||||||
|
{
|
||||||
|
return printError("INV-170", LOCK_MESSAGE + Epoch.HMSRemaining(accLock.expire_time))();
|
||||||
|
}
|
||||||
|
|
||||||
|
var authSettings = db.Users.GetAuthenticationSettings(user.user_id);
|
||||||
|
var isPasswordCorrect = PasswordHasher.Verify(password, new PasswordHash
|
||||||
|
{
|
||||||
|
data = authSettings.data,
|
||||||
|
scheme = authSettings.scheme_class
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isPasswordCorrect)
|
||||||
|
{
|
||||||
|
var failDelay = 60 * LockDuration[Math.Min(LockDuration.Length - 1, db.Users.FailedConsecutive(user.user_id, ip))];
|
||||||
|
if (accLock == null)
|
||||||
|
{
|
||||||
|
db.Users.NewFailedAuth(user.user_id, ip, (uint)failDelay);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
var remaining = db.Users.FailedAuth(accLock.attempt_id, (uint)failDelay, LockAttempts);
|
||||||
|
if (remaining == 0)
|
||||||
|
return printError("INV-170", LOCK_MESSAGE + Epoch.HMSRemaining(Epoch.Now + (uint)failDelay))();
|
||||||
|
}
|
||||||
|
return ERROR_110();
|
||||||
|
}
|
||||||
|
|
||||||
|
var ban = db.Bans.GetByIP(ip);
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
return ERROR_110();
|
||||||
|
}
|
||||||
|
|
||||||
|
db.Users.SuccessfulAuth(user.user_id, ip);
|
||||||
|
db.Users.UpdateClientID(user.user_id, clientid ?? "0");
|
||||||
|
|
||||||
|
/** Make a ticket **/
|
||||||
|
ticket = new AuthTicket();
|
||||||
|
ticket.ticket_id = Guid.NewGuid().ToString().Replace("-", "");
|
||||||
|
ticket.user_id = user.user_id;
|
||||||
|
ticket.date = Epoch.Now;
|
||||||
|
ticket.ip = ip;
|
||||||
|
|
||||||
|
db.AuthTickets.Create(ticket);
|
||||||
|
db.Users.UpdateLastLogin(user.user_id, Epoch.Now);
|
||||||
|
}
|
||||||
|
var content = "Valid=TRUE\r\nTicket=" + ticket.ticket_id.ToString() + "\r\n";
|
||||||
|
return ApiResponse.Plain(HttpStatusCode.OK, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Func<IActionResult> printError(String code, String message)
|
||||||
|
{
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
result.AppendLine("Valid=FALSE");
|
||||||
|
result.AppendLine("Ticket=0");
|
||||||
|
result.AppendLine("reasontext=" + code + ";" + message);
|
||||||
|
result.AppendLine("reasonurl=");
|
||||||
|
|
||||||
|
return () =>
|
||||||
|
{
|
||||||
|
return ApiResponse.Plain(HttpStatusCode.OK, result.ToString());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
server/FSO.Server.Api.Core/Controllers/AvatarDataController.cs
Executable file
48
server/FSO.Server.Api.Core/Controllers/AvatarDataController.cs
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
using FSO.Common.Utils;
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Protocol.CitySelector;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[Route("cityselector/app/AvatarDataServlet")]
|
||||||
|
[ApiController]
|
||||||
|
public class AvatarDataController : ControllerBase
|
||||||
|
{
|
||||||
|
public IActionResult Get()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
var user = api.RequireAuthentication(Request);
|
||||||
|
|
||||||
|
var result = new XMLList<AvatarData>("The-Sims-Online");
|
||||||
|
|
||||||
|
using (var db = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var avatars = db.Avatars.GetSummaryByUserId(user.UserID);
|
||||||
|
|
||||||
|
foreach (var avatar in avatars)
|
||||||
|
{
|
||||||
|
result.Add(new AvatarData
|
||||||
|
{
|
||||||
|
ID = avatar.avatar_id,
|
||||||
|
Name = avatar.name,
|
||||||
|
ShardName = api.Shards.GetById(avatar.shard_id).Name,
|
||||||
|
HeadOutfitID = avatar.head,
|
||||||
|
BodyOutfitID = avatar.body,
|
||||||
|
AppearanceType = (AvatarAppearanceType)Enum.Parse(typeof(AvatarAppearanceType), avatar.skin_tone.ToString()),
|
||||||
|
Description = avatar.description,
|
||||||
|
LotId = avatar.lot_id,
|
||||||
|
LotName = avatar.lot_name,
|
||||||
|
LotLocation = avatar.lot_location
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Xml(HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
321
server/FSO.Server.Api.Core/Controllers/AvatarInfoController.cs
Executable file
321
server/FSO.Server.Api.Core/Controllers/AvatarInfoController.cs
Executable file
|
@ -0,0 +1,321 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using FSO.Server.Database.DA.Avatars;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class AvatarInfoController : ControllerBase
|
||||||
|
{
|
||||||
|
//get the avatars by user_id
|
||||||
|
[Route("userapi/user/avatars")]
|
||||||
|
public IActionResult GetByUser()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
var user = api.RequireAuthentication(Request);
|
||||||
|
if (!user.Claims.Contains("userReadPermissions")) return ApiResponse.Json(HttpStatusCode.OK, new JSONAvatarError("No read premissions found."));
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var avatars = da.Avatars.GetByUserId(user.UserID);
|
||||||
|
List<JSONAvatar> avatarJson = new List<JSONAvatar>();
|
||||||
|
foreach (var avatar in avatars)
|
||||||
|
{
|
||||||
|
avatarJson.Add(new JSONAvatar
|
||||||
|
{
|
||||||
|
avatar_id = avatar.avatar_id,
|
||||||
|
shard_id = avatar.shard_id,
|
||||||
|
name = avatar.name,
|
||||||
|
gender = avatar.gender,
|
||||||
|
date = avatar.date,
|
||||||
|
description = avatar.description,
|
||||||
|
current_job = avatar.current_job,
|
||||||
|
mayor_nhood = avatar.mayor_nhood
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var avatarsJson = new JSONAvatars();
|
||||||
|
avatarsJson.avatars = avatarJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, avatarsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get the avatar by id
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/avatars/{avartarId}")]
|
||||||
|
public IActionResult GetByID(uint avartarId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var avatar = da.Avatars.Get(avartarId);
|
||||||
|
if (avatar == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"));
|
||||||
|
|
||||||
|
var avatarJson = new JSONAvatar
|
||||||
|
{
|
||||||
|
avatar_id = avatar.avatar_id,
|
||||||
|
shard_id = avatar.shard_id,
|
||||||
|
name = avatar.name,
|
||||||
|
gender = avatar.gender,
|
||||||
|
date = avatar.date,
|
||||||
|
description = avatar.description,
|
||||||
|
current_job = avatar.current_job,
|
||||||
|
mayor_nhood = avatar.mayor_nhood
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, avatarJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get the avatars by ids
|
||||||
|
[Route("userapi/avatars")]
|
||||||
|
public IActionResult GetByIDs([FromQuery(Name = "ids")]string idsString)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
uint[] ids = Array.ConvertAll(idsString.Split(","), uint.Parse);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var avatars = da.Avatars.GetMultiple(ids);
|
||||||
|
List<JSONAvatar> avatarJson = new List<JSONAvatar>();
|
||||||
|
foreach (var avatar in avatars)
|
||||||
|
{
|
||||||
|
avatarJson.Add(new JSONAvatar
|
||||||
|
{
|
||||||
|
avatar_id = avatar.avatar_id,
|
||||||
|
shard_id = avatar.shard_id,
|
||||||
|
name = avatar.name,
|
||||||
|
gender = avatar.gender,
|
||||||
|
date = avatar.date,
|
||||||
|
description = avatar.description,
|
||||||
|
current_job = avatar.current_job,
|
||||||
|
mayor_nhood = avatar.mayor_nhood
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var avatarsJson = new JSONAvatars();
|
||||||
|
avatarsJson.avatars = avatarJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, avatarsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Error during cast. (invalid_value)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//gets all the avatars from one city
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/avatars/page/{pageNum}")]
|
||||||
|
public IActionResult GetAll(int shardId,int pageNum, [FromQuery(Name = "avatars_on_page")]int perPage)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
if(perPage == 0)
|
||||||
|
{
|
||||||
|
perPage = 100;
|
||||||
|
}
|
||||||
|
if (perPage > 500) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("The max amount of avatars per page is 500"));
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
pageNum = pageNum - 1;
|
||||||
|
|
||||||
|
var avatars = da.Avatars.AllByPage(shardId, pageNum * perPage, perPage,"avatar_id");
|
||||||
|
var avatarCount = avatars.Total;
|
||||||
|
var totalPages = (avatars.Total - 1)/perPage + 1;
|
||||||
|
|
||||||
|
var pageAvatarsJson = new JSONAvatarsPage();
|
||||||
|
pageAvatarsJson.total_avatars = avatarCount;
|
||||||
|
pageAvatarsJson.page = pageNum + 1;
|
||||||
|
pageAvatarsJson.total_pages = (int)totalPages;
|
||||||
|
pageAvatarsJson.avatars_on_page = avatars.Count();
|
||||||
|
|
||||||
|
if (pageNum < 0 || pageNum >= (int)totalPages) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Page not found"));
|
||||||
|
if (avatars == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"));
|
||||||
|
|
||||||
|
List<JSONAvatar> avatarJson = new List<JSONAvatar>();
|
||||||
|
foreach (var avatar in avatars)
|
||||||
|
{
|
||||||
|
avatarJson.Add(new JSONAvatar
|
||||||
|
{
|
||||||
|
avatar_id = avatar.avatar_id,
|
||||||
|
shard_id = avatar.shard_id,
|
||||||
|
name = avatar.name,
|
||||||
|
gender = avatar.gender,
|
||||||
|
date = avatar.date,
|
||||||
|
description = avatar.description,
|
||||||
|
current_job = avatar.current_job,
|
||||||
|
mayor_nhood = avatar.mayor_nhood
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pageAvatarsJson.avatars = avatarJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, pageAvatarsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//gets avatar by name
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/avatars/name/{name}")]
|
||||||
|
public IActionResult GetByName(int shardId, string name)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var avatar = da.Avatars.SearchExact(shardId, name, 1).FirstOrDefault();
|
||||||
|
if (avatar == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"));
|
||||||
|
|
||||||
|
var avatarJson = new JSONAvatar();
|
||||||
|
var avatarById = da.Avatars.Get(avatar.avatar_id);
|
||||||
|
if (avatarById == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"));
|
||||||
|
avatarJson = (new JSONAvatar
|
||||||
|
{
|
||||||
|
avatar_id = avatarById.avatar_id,
|
||||||
|
shard_id = avatarById.shard_id,
|
||||||
|
name = avatarById.name,
|
||||||
|
gender = avatarById.gender,
|
||||||
|
date = avatarById.date,
|
||||||
|
description = avatarById.description,
|
||||||
|
current_job = avatarById.current_job,
|
||||||
|
mayor_nhood = avatarById.mayor_nhood
|
||||||
|
});
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, avatarJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//gets all the avatars that live in a specific neighbourhood
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/avatars/neighborhood/{nhoodId}")]
|
||||||
|
public IActionResult GetByNhood(int shardId, uint nhoodId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lots = da.Lots.All(shardId).Where(x => x.neighborhood_id == nhoodId);
|
||||||
|
if (lots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Lots not found"));
|
||||||
|
|
||||||
|
List<JSONAvatar> avatarJson = new List<JSONAvatar>();
|
||||||
|
foreach (var lot in lots)
|
||||||
|
{
|
||||||
|
if(lot.category != FSO.Common.Enum.LotCategory.community)
|
||||||
|
{
|
||||||
|
var roomies = da.Roommates.GetLotRoommates(lot.lot_id).Where(x => x.is_pending == 0).Select(x => x.avatar_id);
|
||||||
|
var avatars = da.Avatars.GetMultiple(roomies.ToArray());
|
||||||
|
foreach (var avatar in avatars)
|
||||||
|
{
|
||||||
|
avatarJson.Add(new JSONAvatar
|
||||||
|
{
|
||||||
|
avatar_id = avatar.avatar_id,
|
||||||
|
shard_id = avatar.shard_id,
|
||||||
|
name = avatar.name,
|
||||||
|
gender = avatar.gender,
|
||||||
|
date = avatar.date,
|
||||||
|
description = avatar.description,
|
||||||
|
current_job = avatar.current_job,
|
||||||
|
mayor_nhood = avatar.mayor_nhood
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
var avatarsJson = new JSONAvatars();
|
||||||
|
avatarsJson.avatars = avatarJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, avatarsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get all online Avatars
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/avatars/online")]
|
||||||
|
public IActionResult GetOnline([FromQuery(Name = "compact")]bool compact)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
List<JSONAvatarSmall> avatarSmallJson = new List<JSONAvatarSmall>();
|
||||||
|
var avatarJson = new JSONAvatarOnline();
|
||||||
|
if (compact)
|
||||||
|
{
|
||||||
|
var avatarStatus = da.AvatarClaims.GetAllActiveAvatarsCount();
|
||||||
|
if (avatarStatus == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("ammount not found"));
|
||||||
|
avatarJson.avatars_online_count = avatarStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!compact)
|
||||||
|
{
|
||||||
|
var avatarStatus = da.AvatarClaims.GetAllActiveAvatars();
|
||||||
|
if (avatarStatus == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatars not found"));
|
||||||
|
|
||||||
|
foreach (var avatar in avatarStatus)
|
||||||
|
{
|
||||||
|
uint location = 0;
|
||||||
|
if (avatar.privacy_mode == 0)
|
||||||
|
{
|
||||||
|
location = avatar.location;
|
||||||
|
}
|
||||||
|
avatarSmallJson.Add(new JSONAvatarSmall
|
||||||
|
{
|
||||||
|
avatar_id = avatar.avatar_id,
|
||||||
|
name = avatar.name,
|
||||||
|
privacy_mode = avatar.privacy_mode,
|
||||||
|
location = location
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
avatarJson.avatars_online_count = avatarStatus.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarJson.avatars = avatarSmallJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, avatarJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONAvatarError
|
||||||
|
{
|
||||||
|
public string error;
|
||||||
|
public JSONAvatarError(string errorString)
|
||||||
|
{
|
||||||
|
error = errorString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONAvatarsPage
|
||||||
|
{
|
||||||
|
public int page { get; set; }
|
||||||
|
public int total_pages { get; set; }
|
||||||
|
public int total_avatars { get; set; }
|
||||||
|
public int avatars_on_page { get; set; }
|
||||||
|
public List<JSONAvatar> avatars { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONAvatarOnline
|
||||||
|
{
|
||||||
|
public int? avatars_online_count { get; set; }
|
||||||
|
public List<JSONAvatarSmall> avatars { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONAvatarSmall
|
||||||
|
{
|
||||||
|
public uint avatar_id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public byte privacy_mode { get; set; }
|
||||||
|
public uint location { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONAvatars
|
||||||
|
{
|
||||||
|
public List<JSONAvatar> avatars { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONAvatar
|
||||||
|
{
|
||||||
|
public uint avatar_id { get; set; }
|
||||||
|
public int shard_id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public DbAvatarGender gender { get; set; }
|
||||||
|
public uint date { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public ushort current_job { get; set; }
|
||||||
|
public int? mayor_nhood { get; set; }
|
||||||
|
}
|
||||||
|
}
|
134
server/FSO.Server.Api.Core/Controllers/BulletinInfoController.cs
Executable file
134
server/FSO.Server.Api.Core/Controllers/BulletinInfoController.cs
Executable file
|
@ -0,0 +1,134 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using FSO.Server.Database.DA.Bulletin;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class BulletinInfoController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet("nhoodId")]
|
||||||
|
[Route("userapi/neighborhood/{nhoodId}/bulletins")]
|
||||||
|
public IActionResult GetByNhoodAndAfter(uint nhoodId, [FromQuery(Name = "after")]uint after)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
if (after == null) after = 0;
|
||||||
|
var bulletins = da.BulletinPosts.GetByNhoodId(nhoodId, after);
|
||||||
|
if (bulletins == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONBulletinError("Bulletins not found"));
|
||||||
|
|
||||||
|
List<JSONBulletin> bulletinJson = new List<JSONBulletin>();
|
||||||
|
foreach (var bulletin in bulletins)
|
||||||
|
{
|
||||||
|
bulletinJson.Add(new JSONBulletin
|
||||||
|
{
|
||||||
|
bulletin_id = bulletin.bulletin_id,
|
||||||
|
neighborhood_id = bulletin.neighborhood_id,
|
||||||
|
avatar_id = bulletin.avatar_id,
|
||||||
|
title = bulletin.title,
|
||||||
|
body = bulletin.body,
|
||||||
|
date = bulletin.date,
|
||||||
|
flags = bulletin.flags,
|
||||||
|
lot_id = bulletin.lot_id,
|
||||||
|
type = bulletin.type
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
var bulletinsJson = new JSONBulletins();
|
||||||
|
bulletinsJson.bulletins = bulletinJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, bulletinsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/neighborhood/{nhoodid}/bulletins/{bulletinId}")]
|
||||||
|
public IActionResult GetByID(uint bulletinId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var bulletin = da.BulletinPosts.Get(bulletinId);
|
||||||
|
if (bulletin == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONBulletinError("Bulletin not found"));
|
||||||
|
|
||||||
|
var bulletinJson = new JSONBulletin();
|
||||||
|
bulletinJson = new JSONBulletin
|
||||||
|
{
|
||||||
|
bulletin_id = bulletin.bulletin_id,
|
||||||
|
neighborhood_id = bulletin.neighborhood_id,
|
||||||
|
avatar_id = bulletin.avatar_id,
|
||||||
|
title = bulletin.title,
|
||||||
|
body = bulletin.body,
|
||||||
|
date = bulletin.date,
|
||||||
|
flags = bulletin.flags,
|
||||||
|
lot_id = bulletin.lot_id,
|
||||||
|
type = bulletin.type
|
||||||
|
};
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, bulletinJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/neighborhood/{nhoodId}/bulletins/type/{bulletinType}")]
|
||||||
|
public IActionResult GetByNhoodAndType(uint nhoodId,DbBulletinType bulletinType)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var bulletins = da.BulletinPosts.GetByNhoodId(nhoodId, 0).Where(x => x.type == bulletinType);
|
||||||
|
if (bulletins == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONBulletinError("Bulletins not found"));
|
||||||
|
|
||||||
|
List<JSONBulletin> bulletinJson = new List<JSONBulletin>();
|
||||||
|
foreach (var bulletin in bulletins)
|
||||||
|
{
|
||||||
|
bulletinJson.Add(new JSONBulletin
|
||||||
|
{
|
||||||
|
bulletin_id = bulletin.bulletin_id,
|
||||||
|
neighborhood_id = bulletin.neighborhood_id,
|
||||||
|
avatar_id = bulletin.avatar_id,
|
||||||
|
title = bulletin.title,
|
||||||
|
body = bulletin.body,
|
||||||
|
date = bulletin.date,
|
||||||
|
flags = bulletin.flags,
|
||||||
|
lot_id = bulletin.lot_id,
|
||||||
|
type = bulletin.type
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
var bulletinsJson = new JSONBulletins();
|
||||||
|
bulletinsJson.bulletins = bulletinJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, bulletinsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONBulletinError
|
||||||
|
{
|
||||||
|
public string error;
|
||||||
|
public JSONBulletinError(string errorString)
|
||||||
|
{
|
||||||
|
error = errorString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONBulletins
|
||||||
|
{
|
||||||
|
public List<JSONBulletin> bulletins { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONBulletin
|
||||||
|
{
|
||||||
|
public uint bulletin_id { get; set; }
|
||||||
|
public int neighborhood_id { get; set; }
|
||||||
|
public uint? avatar_id { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
public string body { get; set; }
|
||||||
|
public uint date { get; set; }
|
||||||
|
public uint flags { get; set; }
|
||||||
|
public int? lot_id { get; set; }
|
||||||
|
public DbBulletinType type { get; set; }
|
||||||
|
}
|
||||||
|
}
|
73
server/FSO.Server.Api.Core/Controllers/CityJSONController.cs
Executable file
73
server/FSO.Server.Api.Core/Controllers/CityJSONController.cs
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class CityJSONController : ControllerBase
|
||||||
|
{
|
||||||
|
private static object ModelLock = new object { };
|
||||||
|
private static CityInfoModel LastModel = new CityInfoModel();
|
||||||
|
private static uint LastModelUpdate;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardid}/city.json")]
|
||||||
|
public IActionResult Get(int shardid)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
var now = Epoch.Now;
|
||||||
|
if (LastModelUpdate < now - 15)
|
||||||
|
{
|
||||||
|
LastModelUpdate = now;
|
||||||
|
lock (ModelLock)
|
||||||
|
{
|
||||||
|
LastModel = new CityInfoModel();
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lots = da.Lots.AllLocations(shardid);
|
||||||
|
var lotstatus = da.LotClaims.AllLocations(shardid);
|
||||||
|
LastModel.reservedLots = lots.ConvertAll(x => x.location).ToArray();
|
||||||
|
LastModel.names = lots.ConvertAll(x => x.name).ToArray();
|
||||||
|
LastModel.activeLots = lotstatus.ConvertAll(x => x.location).ToArray();
|
||||||
|
LastModel.onlineCount = lotstatus.ConvertAll(x => x.active).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lock (ModelLock)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, LastModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/thumbwork.json")]
|
||||||
|
public IActionResult ThumbWork()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var work = da.Lots.Get3DWork();
|
||||||
|
if (work == null) return ApiResponse.Plain(HttpStatusCode.OK, "");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, work);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CityInfoModel
|
||||||
|
{
|
||||||
|
public string[] names;
|
||||||
|
public uint[] reservedLots;
|
||||||
|
public uint[] activeLots;
|
||||||
|
public int[] onlineCount;
|
||||||
|
}
|
||||||
|
}
|
79
server/FSO.Server.Api.Core/Controllers/ElectionInfoController.cs
Executable file
79
server/FSO.Server.Api.Core/Controllers/ElectionInfoController.cs
Executable file
|
@ -0,0 +1,79 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using FSO.Server.Database.DA.Elections;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class ElectionController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/neighborhood/{nhoodId}/elections")]
|
||||||
|
public IActionResult GetByNhood(uint nhoodId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var nhood = da.Neighborhoods.Get(nhoodId);
|
||||||
|
if (nhood.election_cycle_id == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONElectionError("Election cycle not found"));
|
||||||
|
|
||||||
|
var electionCycle = da.Elections.GetCycle((uint)nhood.election_cycle_id);
|
||||||
|
|
||||||
|
var electionCandidates = new List<DbElectionCandidate>();
|
||||||
|
if (electionCycle.current_state == Database.DA.Elections.DbElectionCycleState.election)
|
||||||
|
electionCandidates = da.Elections.GetCandidates(electionCycle.cycle_id, Database.DA.Elections.DbCandidateState.running);
|
||||||
|
|
||||||
|
if (electionCycle.current_state == Database.DA.Elections.DbElectionCycleState.ended)
|
||||||
|
electionCandidates = da.Elections.GetCandidates(electionCycle.cycle_id, Database.DA.Elections.DbCandidateState.won);
|
||||||
|
|
||||||
|
if (electionCycle == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONElectionError("Election cycle not found"));
|
||||||
|
|
||||||
|
List<JSONCandidates> candidatesJson = new List<JSONCandidates>();
|
||||||
|
foreach (var candidate in electionCandidates)
|
||||||
|
{
|
||||||
|
candidatesJson.Add(new JSONCandidates
|
||||||
|
{
|
||||||
|
candidate_avatar_id = candidate.candidate_avatar_id,
|
||||||
|
comment = candidate.comment,
|
||||||
|
state = candidate.state
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
var electionJson = new JSONElections();
|
||||||
|
electionJson.candidates = candidatesJson;
|
||||||
|
electionJson.current_state = electionCycle.current_state;
|
||||||
|
electionJson.neighborhood_id = nhood.neighborhood_id;
|
||||||
|
electionJson.start_date = electionCycle.start_date;
|
||||||
|
electionJson.end_date = electionCycle.end_date;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, electionJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONElectionError
|
||||||
|
{
|
||||||
|
public string error;
|
||||||
|
public JSONElectionError(string errorString)
|
||||||
|
{
|
||||||
|
error = errorString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONElections
|
||||||
|
{
|
||||||
|
public DbElectionCycleState current_state { get; set; }
|
||||||
|
public int neighborhood_id { get; set; }
|
||||||
|
public uint start_date { get; set; }
|
||||||
|
public uint end_date { get; set; }
|
||||||
|
public List<JSONCandidates> candidates { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONCandidates
|
||||||
|
{
|
||||||
|
public uint candidate_avatar_id { get; set; }
|
||||||
|
public string comment { get; set; }
|
||||||
|
public DbCandidateState state { get; set; }
|
||||||
|
}
|
||||||
|
}
|
38
server/FSO.Server.Api.Core/Controllers/GameAPI/UpdateController.cs
Executable file
38
server/FSO.Server.Api.Core/Controllers/GameAPI/UpdateController.cs
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers.GameAPI
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[Route("userapi/update")]
|
||||||
|
public class UpdateController : ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
|
// GET userapi/update
|
||||||
|
// get recent PUBLISHED updates for the active branch, ordered by publish date
|
||||||
|
[HttpGet()]
|
||||||
|
public IActionResult Get(int id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var recents = da.Updates.GetRecentUpdatesForBranchByName(api.Config.BranchName, 20);
|
||||||
|
return new JsonResult(recents.ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: userapi/update/<branch>
|
||||||
|
// get recent PUBLISHED updates for a specific branch, ordered by publish date
|
||||||
|
[HttpGet("{branch}")]
|
||||||
|
public IActionResult Get(string branch)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var recents = da.Updates.GetRecentUpdatesForBranchByName(branch, 20);
|
||||||
|
return new JsonResult(recents.ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
server/FSO.Server.Api.Core/Controllers/GithubController.cs
Executable file
77
server/FSO.Server.Api.Core/Controllers/GithubController.cs
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
using System;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Octokit;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class GithubController : ControllerBase
|
||||||
|
{
|
||||||
|
readonly GitHubClient client =
|
||||||
|
new GitHubClient(new ProductHeaderValue(Api.INSTANCE.Github.AppName), new Uri("https://github.com/"));
|
||||||
|
|
||||||
|
private string StoredToken;
|
||||||
|
private static string CSRF;
|
||||||
|
|
||||||
|
// GET: /<controller>/
|
||||||
|
[HttpGet]
|
||||||
|
[Route("github/")]
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
if (Api.INSTANCE.Github == null) return NotFound();
|
||||||
|
if (Api.INSTANCE.Github.AccessToken != null) return NotFound();
|
||||||
|
|
||||||
|
return Redirect(GetOauthLoginUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("github/callback")]
|
||||||
|
public async Task<IActionResult> Callback(string code, string state)
|
||||||
|
{
|
||||||
|
if (Api.INSTANCE.Github == null) return NotFound();
|
||||||
|
if (Api.INSTANCE.Github.AccessToken != null) return NotFound();
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(code))
|
||||||
|
{
|
||||||
|
var expectedState = CSRF;
|
||||||
|
if (state != expectedState) throw new InvalidOperationException("SECURITY FAIL!");
|
||||||
|
//CSRF = null;
|
||||||
|
|
||||||
|
var token = await client.Oauth.CreateAccessToken(
|
||||||
|
new OauthTokenRequest(Api.INSTANCE.Github.ClientID, Api.INSTANCE.Github.ClientSecret, code)
|
||||||
|
{
|
||||||
|
RedirectUri = new Uri("http://localhost:80/github/callback")
|
||||||
|
});
|
||||||
|
StoredToken = token.AccessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(StoredToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetOauthLoginUrl()
|
||||||
|
{
|
||||||
|
var rngCsp = new RNGCryptoServiceProvider();
|
||||||
|
string csrf = "";
|
||||||
|
var random = new byte[24];
|
||||||
|
rngCsp.GetBytes(random);
|
||||||
|
for (int i=0; i<24; i++)
|
||||||
|
{
|
||||||
|
csrf += (char)('?' + random[i]/4);
|
||||||
|
}
|
||||||
|
CSRF = csrf;
|
||||||
|
|
||||||
|
// 1. Redirect users to request GitHub access
|
||||||
|
var request = new OauthLoginRequest(Api.INSTANCE.Github.ClientID)
|
||||||
|
{
|
||||||
|
Scopes = { "admin:org", "repo" },
|
||||||
|
State = csrf
|
||||||
|
};
|
||||||
|
var oauthLoginUrl = client.Oauth.GetGitHubLoginUrl(request);
|
||||||
|
return oauthLoginUrl.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
server/FSO.Server.Api.Core/Controllers/InitialConnectController.cs
Executable file
93
server/FSO.Server.Api.Core/Controllers/InitialConnectController.cs
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Protocol.CitySelector;
|
||||||
|
using FSO.Server.Servers.Api.JsonWebToken;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[Route("cityselector/app/InitialConnectServlet")]
|
||||||
|
[ApiController]
|
||||||
|
public class InitialConnectController : ControllerBase
|
||||||
|
{
|
||||||
|
private static Func<IActionResult> ERROR_MISSING_TOKEN = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("501", "Token not found"));
|
||||||
|
private static Func<IActionResult> ERROR_EXPIRED_TOKEN = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("502", "Token has expired"));
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(string ticket, string version)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if (ticket == null || ticket == "" || version == null){
|
||||||
|
return ERROR_MISSING_TOKEN();
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var db = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var dbTicket = db.AuthTickets.Get(ticket);
|
||||||
|
if (dbTicket == null){
|
||||||
|
return ERROR_MISSING_TOKEN();
|
||||||
|
}
|
||||||
|
|
||||||
|
db.AuthTickets.Delete((string)ticket);
|
||||||
|
if (dbTicket.date + api.Config.AuthTicketDuration < Epoch.Now){
|
||||||
|
return ERROR_EXPIRED_TOKEN();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Is it a valid account? **/
|
||||||
|
var user = db.Users.GetById(dbTicket.user_id);
|
||||||
|
if (user == null){
|
||||||
|
return ERROR_MISSING_TOKEN();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Use JWT to create and sign an auth cookies
|
||||||
|
var session = new JWTUser()
|
||||||
|
{
|
||||||
|
UserID = user.user_id,
|
||||||
|
UserName = user.username
|
||||||
|
};
|
||||||
|
|
||||||
|
//TODO: This assumes 1 shard, when using multiple need to either have version download occour after
|
||||||
|
//avatar select, or rework the tables
|
||||||
|
var shardOne = api.Shards.GetById(1);
|
||||||
|
|
||||||
|
var token = api.JWT.CreateToken(session);
|
||||||
|
|
||||||
|
IActionResult response;
|
||||||
|
if (shardOne.UpdateID != null)
|
||||||
|
{
|
||||||
|
var update = db.Updates.GetUpdate(shardOne.UpdateID.Value);
|
||||||
|
response = ApiResponse.Xml(HttpStatusCode.OK, new UserAuthorized()
|
||||||
|
{
|
||||||
|
FSOBranch = shardOne.VersionName,
|
||||||
|
FSOVersion = shardOne.VersionNumber,
|
||||||
|
FSOUpdateUrl = update.full_zip,
|
||||||
|
FSOCDNUrl = api.Config.CDNUrl
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response = ApiResponse.Xml(HttpStatusCode.OK, new UserAuthorized()
|
||||||
|
{
|
||||||
|
FSOBranch = shardOne.VersionName,
|
||||||
|
FSOVersion = shardOne.VersionNumber,
|
||||||
|
FSOUpdateUrl = api.Config.UpdateUrl,
|
||||||
|
FSOCDNUrl = api.Config.CDNUrl
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Response.Cookies.Append("fso", token.Token, new Microsoft.AspNetCore.Http.CookieOptions()
|
||||||
|
{
|
||||||
|
Expires = DateTimeOffset.Now.AddDays(1),
|
||||||
|
Domain = Request.Host.Host,
|
||||||
|
Path = "/"
|
||||||
|
});
|
||||||
|
//HttpContext.Current.Response.SetCookie(new HttpCookie("fso", token.Token));
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
705
server/FSO.Server.Api.Core/Controllers/LotInfoController.cs
Executable file
705
server/FSO.Server.Api.Core/Controllers/LotInfoController.cs
Executable file
|
@ -0,0 +1,705 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Common.Enum;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class MemoryCacher
|
||||||
|
{
|
||||||
|
public static MemoryCache Default = new MemoryCache(new MemoryCacheOptions());
|
||||||
|
public static object GetValue(string key)
|
||||||
|
{
|
||||||
|
MemoryCache memoryCache = Default;
|
||||||
|
return memoryCache.Get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Add(string key, object value, DateTimeOffset absExpiration)
|
||||||
|
{
|
||||||
|
MemoryCache memoryCache = Default;
|
||||||
|
return memoryCache.Set(key, value, absExpiration) == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Delete(string key)
|
||||||
|
{
|
||||||
|
MemoryCache memoryCache = Default;
|
||||||
|
memoryCache.Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class LotInfoController : ControllerBase
|
||||||
|
{
|
||||||
|
public static ConcurrentDictionary<int, ShardLocationCache> LotLocationCache = new ConcurrentDictionary<int, ShardLocationCache>();
|
||||||
|
|
||||||
|
public static int? IDForLocation(int shardid, uint loc)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
var locToID = LotLocationCache.GetOrAdd(shardid, (ikey) =>
|
||||||
|
{
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return new ShardLocationCache(
|
||||||
|
new ConcurrentDictionary<uint, int>(da.Lots.All(ikey).Select(x => new KeyValuePair<uint, int>(x.location, x.lot_id)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (DateTime.UtcNow - locToID.CreateTime > TimeSpan.FromMinutes(15))
|
||||||
|
{
|
||||||
|
ShardLocationCache removed;
|
||||||
|
LotLocationCache.TryRemove(shardid, out removed);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return locToID.Dict.GetOrAdd(loc, (ikey) =>
|
||||||
|
{
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
return da.Lots.GetByLocation(shardid, ikey).lot_id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (NullReferenceException e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardid}/{id}.png")]
|
||||||
|
[ResponseCache(Duration = 60 * 60, Location = ResponseCacheLocation.Any)]
|
||||||
|
public IActionResult Get(int shardid, uint id)
|
||||||
|
{
|
||||||
|
var dat = (byte[])MemoryCacher.GetValue("lt" + shardid + ":" + id);
|
||||||
|
if (dat != null)
|
||||||
|
{
|
||||||
|
return File(dat, "image/png");
|
||||||
|
}
|
||||||
|
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = IDForLocation(shardid, id);
|
||||||
|
if (lot == null) return NotFound();
|
||||||
|
|
||||||
|
FileStream stream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ndat = System.IO.File.ReadAllBytes(Path.Combine(api.Config.NFSdir, "Lots/" + lot.Value.ToString("x8") + "/thumb.png"));
|
||||||
|
MemoryCacher.Add("lt" + shardid + ":" + id, ndat, DateTime.Now.Add(new TimeSpan(1, 0, 0)));
|
||||||
|
|
||||||
|
return File(ndat, "image/png");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardid}/i{id}.json")]
|
||||||
|
public IActionResult GetJSON(int shardid, uint id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.GetByLocation(shardid, id);
|
||||||
|
if (lot == null) return NotFound();
|
||||||
|
|
||||||
|
var roomies = da.Roommates.GetLotRoommates(lot.lot_id).Where(x => x.is_pending == 0).Select(x => x.avatar_id).ToArray();
|
||||||
|
|
||||||
|
var jlot = new JSONLot
|
||||||
|
{
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
category = lot.category,
|
||||||
|
created_date = lot.created_date,
|
||||||
|
description = lot.description,
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
owner_id = lot.owner_id,
|
||||||
|
shard_id = lot.shard_id,
|
||||||
|
skill_mode = lot.skill_mode,
|
||||||
|
roommates = roomies
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, jlot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//New user API calls might replace old once later
|
||||||
|
//get lot information by location
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/lots/{lotId}")]
|
||||||
|
public IActionResult GetByID(int lotId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.Get(lotId);
|
||||||
|
if (lot == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lot not found"));
|
||||||
|
var roomies = da.Roommates.GetLotRoommates(lot.lot_id).Where(x => x.is_pending == 0).Select(x => x.avatar_id).ToArray();
|
||||||
|
|
||||||
|
var lotJson = new JSONLot
|
||||||
|
{
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
category = lot.category,
|
||||||
|
created_date = lot.created_date,
|
||||||
|
description = lot.description,
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
owner_id = lot.owner_id,
|
||||||
|
shard_id = lot.shard_id,
|
||||||
|
skill_mode = lot.skill_mode,
|
||||||
|
roommates = roomies,
|
||||||
|
lot_id = lot.lot_id
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, lotJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get the lots by ids
|
||||||
|
[Route("userapi/lots")]
|
||||||
|
public IActionResult GetByIDs([FromQuery(Name = "ids")]string idsString)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int[] ids = Array.ConvertAll(idsString.Split(","), int.Parse);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lots = da.Lots.GetMultiple(ids);
|
||||||
|
if (lots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lot not found"));
|
||||||
|
|
||||||
|
List<JSONLot> lotJson = new List<JSONLot>();
|
||||||
|
foreach (var lot in lots)
|
||||||
|
{
|
||||||
|
var roomies = da.Roommates.GetLotRoommates(lot.lot_id).Where(x => x.is_pending == 0).Select(x => x.avatar_id).ToArray();
|
||||||
|
lotJson.Add(new JSONLot
|
||||||
|
{
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
category = lot.category,
|
||||||
|
created_date = lot.created_date,
|
||||||
|
description = lot.description,
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
owner_id = lot.owner_id,
|
||||||
|
shard_id = lot.shard_id,
|
||||||
|
skill_mode = lot.skill_mode,
|
||||||
|
roommates = roomies,
|
||||||
|
lot_id = lot.lot_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var lotsJson = new JSONLots();
|
||||||
|
lotsJson.lots = lotJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, lotsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Error during cast. (invalid_value)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//gets all the lots from one city
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/page/{pageNum}")]
|
||||||
|
public IActionResult GetAll(int shardId, int pageNum, [FromQuery(Name = "lots_on_page")]int perPage)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
if (perPage == 0)
|
||||||
|
{
|
||||||
|
perPage = 100;
|
||||||
|
}
|
||||||
|
if (perPage > 500) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("The max amount of lots per page is 500"));
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
pageNum = pageNum - 1;
|
||||||
|
|
||||||
|
var lots = da.Lots.AllByPage(shardId, pageNum * perPage, perPage,"lot_id");
|
||||||
|
var lotCount = lots.Total;
|
||||||
|
var totalPages = (lots.Total - 1) / perPage + 1;
|
||||||
|
|
||||||
|
var pageLotsJson = new JSONLotsPage();
|
||||||
|
pageLotsJson.total_lots = lotCount;
|
||||||
|
pageLotsJson.page = pageNum + 1;
|
||||||
|
pageLotsJson.total_pages = (int)totalPages;
|
||||||
|
pageLotsJson.lots_on_page = lots.Count();
|
||||||
|
|
||||||
|
if (pageNum < 0 || pageNum >= (int)totalPages) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Page not found"));
|
||||||
|
if (lots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lots not found"));
|
||||||
|
|
||||||
|
List<JSONLotSmall> lotJson = new List<JSONLotSmall>();
|
||||||
|
foreach (var lot in lots)
|
||||||
|
{
|
||||||
|
lotJson.Add(new JSONLotSmall
|
||||||
|
{
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
description = lot.description,
|
||||||
|
category = lot.category,
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
lot_id = lot.lot_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pageLotsJson.lots = lotJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, pageLotsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get lot information by location
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/location/{locationId}")]
|
||||||
|
public IActionResult GetByLocation(int shardId, uint locationId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.GetByLocation(shardId, locationId);
|
||||||
|
if (lot == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lot not found"));
|
||||||
|
|
||||||
|
var roomies = da.Roommates.GetLotRoommates(lot.lot_id).Where(x => x.is_pending == 0).Select(x => x.avatar_id).ToArray();
|
||||||
|
|
||||||
|
var LotJSON = new JSONLot
|
||||||
|
{
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
category = lot.category,
|
||||||
|
created_date = lot.created_date,
|
||||||
|
description = lot.description,
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
owner_id = lot.owner_id,
|
||||||
|
shard_id = lot.shard_id,
|
||||||
|
skill_mode = lot.skill_mode,
|
||||||
|
roommates = roomies,
|
||||||
|
lot_id = lot.lot_id
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, LotJSON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get lot information By neighbourhood
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/neighborhood/{nhoodId}")]
|
||||||
|
public IActionResult GetByNhood(int shardId, uint nhoodId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lots = da.Lots.All(shardId).Where(x => x.neighborhood_id == nhoodId);
|
||||||
|
if (lots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("lots not found"));
|
||||||
|
List<JSONLotSmall> lotJson = new List<JSONLotSmall>();
|
||||||
|
foreach (var lot in lots)
|
||||||
|
{
|
||||||
|
lotJson.Add(new JSONLotSmall
|
||||||
|
{
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
description = lot.description,
|
||||||
|
category = lot.category,
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
lot_id = lot.lot_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var lotsJson = new JSONLotsSmall();
|
||||||
|
lotsJson.lots = lotJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, lotsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get lot information by name
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/name/{lotName}")]
|
||||||
|
public IActionResult GetByName(int shardId, string lotName)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.GetByName(shardId, lotName);
|
||||||
|
if (lot == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lot not found"));
|
||||||
|
|
||||||
|
var roomies = da.Roommates.GetLotRoommates(lot.lot_id).Where(x => x.is_pending == 0).Select(x => x.avatar_id).ToArray();
|
||||||
|
|
||||||
|
var lotJson = new JSONLot
|
||||||
|
{
|
||||||
|
lot_id = lot.lot_id,
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
category = lot.category,
|
||||||
|
created_date = lot.created_date,
|
||||||
|
description = lot.description,
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
owner_id = lot.owner_id,
|
||||||
|
shard_id = lot.shard_id,
|
||||||
|
skill_mode = lot.skill_mode,
|
||||||
|
roommates = roomies
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, lotJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get online lots
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/online")]
|
||||||
|
public IActionResult GetOnline(int shardId, [FromQuery(Name = "compact")]bool compact)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
List<JSONLotSmall> lotSmallJson = new List<JSONLotSmall>();
|
||||||
|
var lotsOnlineJson = new JSONLotsOnline();
|
||||||
|
|
||||||
|
if (!compact)
|
||||||
|
{
|
||||||
|
var activeLots = da.LotClaims.AllActiveLots(shardId);
|
||||||
|
if (activeLots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lots not found"));
|
||||||
|
var totalAvatars = 0;
|
||||||
|
foreach (var lot in activeLots)
|
||||||
|
{
|
||||||
|
lotSmallJson.Add(new JSONLotSmall
|
||||||
|
{
|
||||||
|
location = lot.location,
|
||||||
|
name = lot.name,
|
||||||
|
description = lot.description,
|
||||||
|
category = lot.category,
|
||||||
|
admit_mode = lot.admit_mode,
|
||||||
|
neighborhood_id = lot.neighborhood_id,
|
||||||
|
avatars_in_lot = lot.active,
|
||||||
|
lot_id = lot.lot_id
|
||||||
|
});
|
||||||
|
totalAvatars += lot.active;
|
||||||
|
}
|
||||||
|
lotsOnlineJson.total_lots_online = activeLots.Count();
|
||||||
|
lotsOnlineJson.total_avatars_in_lots_online = totalAvatars;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var activeLots = da.LotClaims.AllLocations(shardId);
|
||||||
|
if (activeLots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lots not found"));
|
||||||
|
var totalAvatars = 0;
|
||||||
|
foreach (var lot in activeLots)
|
||||||
|
{
|
||||||
|
totalAvatars += lot.active;
|
||||||
|
}
|
||||||
|
|
||||||
|
lotsOnlineJson.total_lots_online = activeLots.Count();
|
||||||
|
lotsOnlineJson.total_avatars_in_lots_online = totalAvatars;
|
||||||
|
}
|
||||||
|
|
||||||
|
lotsOnlineJson.lots = lotSmallJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, lotsOnlineJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get Top-100 lots by category
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/top100/category/{lotCategory}")]
|
||||||
|
public IActionResult GetTop100ByCategory(int shardId, LotCategory lotCategory)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lots = da.LotTop100.GetByCategory(shardId, lotCategory).Take(100);
|
||||||
|
if (lots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Top100 lots not found"));
|
||||||
|
|
||||||
|
List<JSONTop100Lot> top100Lots = new List<JSONTop100Lot>();
|
||||||
|
foreach (var top100Lot in lots)
|
||||||
|
{
|
||||||
|
top100Lots.Add(new JSONTop100Lot
|
||||||
|
{
|
||||||
|
category = top100Lot.category,
|
||||||
|
rank = top100Lot.rank,
|
||||||
|
shard_id = top100Lot.shard_id,
|
||||||
|
lot_location = top100Lot.lot_location,
|
||||||
|
lot_name = top100Lot.lot_name,
|
||||||
|
lot_id = top100Lot.lot_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var top100Json = new JSONTop100Lots();
|
||||||
|
top100Json.lots = top100Lots;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, top100Json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get Top-100 lots by shard
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/lots/top100/all")]
|
||||||
|
public IActionResult GetTop100ByShard(int shardId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lots = da.LotTop100.GetAllByShard(shardId);
|
||||||
|
if (lots == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONLotError("Lots not found"));
|
||||||
|
|
||||||
|
List<JSONTop100Lot> top100Lots = new List<JSONTop100Lot>();
|
||||||
|
foreach (var top100Lot in lots)
|
||||||
|
{
|
||||||
|
top100Lots.Add(new JSONTop100Lot
|
||||||
|
{
|
||||||
|
category = top100Lot.category,
|
||||||
|
rank = top100Lot.rank,
|
||||||
|
shard_id = top100Lot.shard_id,
|
||||||
|
lot_location = top100Lot.lot_location,
|
||||||
|
lot_name = top100Lot.lot_name,
|
||||||
|
lot_id = top100Lot.lot_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var top100Json = new JSONTop100Lots();
|
||||||
|
top100Json.lots = top100Lots;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, top100Json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//moderation only functions, such as downloading lot state
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardid}/{id}.fsov")]
|
||||||
|
public IActionResult GetFSOV(int shardid, uint id)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.GetByLocation(shardid, id);
|
||||||
|
if (lot == null) return NotFound();
|
||||||
|
|
||||||
|
FileStream stream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = Path.Combine(api.Config.NFSdir, "Lots/" + lot.lot_id.ToString("x8") + "/state_" + lot.ring_backup_num.ToString() + ".fsov");
|
||||||
|
|
||||||
|
|
||||||
|
stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
return File(stream, "application/octet-stream");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardid}/{id}.fsof")]
|
||||||
|
[ResponseCache(Duration = 60 * 60, Location = ResponseCacheLocation.Any)]
|
||||||
|
public IActionResult GetFSOF(int shardid, uint id)
|
||||||
|
{
|
||||||
|
var dat = (byte[])MemoryCacher.GetValue("lf" + shardid + ":" + id);
|
||||||
|
if (dat != null)
|
||||||
|
{
|
||||||
|
return File(dat, "application/octet-stream");
|
||||||
|
}
|
||||||
|
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = IDForLocation(shardid, id);
|
||||||
|
if (lot == null) return NotFound();
|
||||||
|
|
||||||
|
FileStream stream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = Path.Combine(api.Config.NFSdir, "Lots/" + lot.Value.ToString("x8") + "/thumb.fsof");
|
||||||
|
|
||||||
|
var ndat = System.IO.File.ReadAllBytes(path);
|
||||||
|
MemoryCacher.Add("lf" + shardid + ":" + id, ndat, DateTime.Now.Add(new TimeSpan(1, 0, 0)));
|
||||||
|
return File(ndat, "application/octet-stream");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("userapi/city/{shardid}/uploadfacade/{id}")]
|
||||||
|
public IActionResult UploadFacade(int shardid, uint id, List<IFormFile> files)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
if (files == null)
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
byte[] data = null;
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
var filename = file.FileName.Trim('\"');
|
||||||
|
using (var memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
file.CopyTo(memoryStream);
|
||||||
|
data = memoryStream.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data == null) return NotFound();
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.GetByLocation(shardid, id);
|
||||||
|
if (lot == null) return NotFound();
|
||||||
|
|
||||||
|
FileStream stream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = Path.Combine(api.Config.NFSdir, "Lots/" + lot.lot_id.ToString("x8") + "/thumb.fsof");
|
||||||
|
stream = System.IO.File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Write);
|
||||||
|
stream.Write(data, 0, data.Length);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
api.DemandModerator(Request);
|
||||||
|
|
||||||
|
if (!Request.Content.IsMimeMultipartContent())
|
||||||
|
return new HttpResponseMessage(HttpStatusCode.UnsupportedMediaType);
|
||||||
|
|
||||||
|
var provider = new MultipartMemoryStreamProvider();
|
||||||
|
var files = Request.Content.ReadAsMultipartAsync(provider).Result;
|
||||||
|
|
||||||
|
byte[] data = null;
|
||||||
|
foreach (var file in provider.Contents)
|
||||||
|
{
|
||||||
|
var filename = file.Headers.ContentDisposition.FileName.Trim('\"');
|
||||||
|
data = file.ReadAsByteArrayAsync().Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data == null) return new HttpResponseMessage(HttpStatusCode.NotFound);
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var lot = da.Lots.GetByLocation(shardid, id);
|
||||||
|
if (lot == null) return new HttpResponseMessage(HttpStatusCode.NotFound);
|
||||||
|
|
||||||
|
FileStream stream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = Path.Combine(api.Config.NFSdir, "Lots/" + lot.lot_id.ToString("x8") + "/thumb.fsof");
|
||||||
|
stream = System.IO.File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Write);
|
||||||
|
stream.Write(data, 0, data.Length);
|
||||||
|
|
||||||
|
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
|
||||||
|
response.Content = new StringContent("", Encoding.UTF8, "text/plain");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new HttpResponseMessage(HttpStatusCode.NotFound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class ShardLocationCache
|
||||||
|
{
|
||||||
|
public ConcurrentDictionary<uint, int> Dict = new ConcurrentDictionary<uint, int>();
|
||||||
|
public DateTime CreateTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
public ShardLocationCache(ConcurrentDictionary<uint, int> dict)
|
||||||
|
{
|
||||||
|
Dict = dict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONLotError
|
||||||
|
{
|
||||||
|
public string error;
|
||||||
|
public JSONLotError(string errorString)
|
||||||
|
{
|
||||||
|
error = errorString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONLotsSmall
|
||||||
|
{
|
||||||
|
public List<JSONLotSmall> lots { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONLots
|
||||||
|
{
|
||||||
|
public List<JSONLot> lots { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONLotsPage
|
||||||
|
{
|
||||||
|
public int page { get; set; }
|
||||||
|
public int total_pages { get; set; }
|
||||||
|
public int total_lots { get; set; }
|
||||||
|
public int lots_on_page { get; set; }
|
||||||
|
public List<JSONLotSmall> lots { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONLotsOnline
|
||||||
|
{
|
||||||
|
public int total_lots_online { get; set; }
|
||||||
|
public int total_avatars_in_lots_online { get; set; }
|
||||||
|
public List<JSONLotSmall> lots { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONLotSmall
|
||||||
|
{
|
||||||
|
public int lot_id { get; set; }
|
||||||
|
public uint location { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public LotCategory category { get; set; }
|
||||||
|
public uint admit_mode { get; set; }
|
||||||
|
public uint neighborhood_id { get; set; }
|
||||||
|
public int avatars_in_lot { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONLot
|
||||||
|
{
|
||||||
|
public int lot_id { get; set; }
|
||||||
|
public int shard_id { get; set; }
|
||||||
|
public uint? owner_id { get; set; }
|
||||||
|
public uint[] roommates { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public uint location { get; set; }
|
||||||
|
public uint neighborhood_id { get; set; }
|
||||||
|
public uint created_date { get; set; }
|
||||||
|
public LotCategory category { get; set; }
|
||||||
|
public byte skill_mode { get; set; }
|
||||||
|
public byte admit_mode { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONTop100Lots
|
||||||
|
{
|
||||||
|
public List<JSONTop100Lot> lots { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONTop100Lot
|
||||||
|
{
|
||||||
|
public LotCategory category { get; set; }
|
||||||
|
public byte rank { get; set; }
|
||||||
|
public int shard_id { get; set; }
|
||||||
|
public string lot_name { get; set; }
|
||||||
|
public uint? lot_location { get; set; }
|
||||||
|
public int? lot_id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
128
server/FSO.Server.Api.Core/Controllers/NhoodInfoController.cs
Executable file
128
server/FSO.Server.Api.Core/Controllers/NhoodInfoController.cs
Executable file
|
@ -0,0 +1,128 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[ApiController]
|
||||||
|
public class NhoodInfoController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/neighborhoods/all")]
|
||||||
|
public IActionResult GetAll(int shardId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var nhoods = da.Neighborhoods.All(shardId);
|
||||||
|
if (nhoods == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONNhoodError("Neighborhoods not found"));
|
||||||
|
|
||||||
|
List<JSONNhood> nhoodJson = new List<JSONNhood>();
|
||||||
|
foreach (var nhood in nhoods)
|
||||||
|
{
|
||||||
|
nhoodJson.Add(new JSONNhood
|
||||||
|
{
|
||||||
|
neighborhood_id = nhood.neighborhood_id,
|
||||||
|
name = nhood.name,
|
||||||
|
description = nhood.description,
|
||||||
|
color = nhood.color,
|
||||||
|
town_hall_id = nhood.town_hall_id,
|
||||||
|
icon_url = nhood.icon_url,
|
||||||
|
mayor_id = nhood.mayor_id,
|
||||||
|
mayor_elected_date = nhood.mayor_elected_date,
|
||||||
|
election_cycle_id = nhood.election_cycle_id
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
var nhoodsJson = new JSONNhoods();
|
||||||
|
nhoodsJson.neighborhoods = nhoodJson;
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, nhoodsJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/neighborhoods/{nhoodId}")]
|
||||||
|
public IActionResult GetByID(uint nhoodId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var nhood = da.Neighborhoods.Get(nhoodId);
|
||||||
|
if (nhood == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONNhoodError("Neighborhood not found"));
|
||||||
|
|
||||||
|
var nhoodJson = new JSONNhood
|
||||||
|
{
|
||||||
|
neighborhood_id = nhood.neighborhood_id,
|
||||||
|
name = nhood.name,
|
||||||
|
description = nhood.description,
|
||||||
|
color = nhood.color,
|
||||||
|
town_hall_id = nhood.town_hall_id,
|
||||||
|
icon_url = nhood.icon_url,
|
||||||
|
mayor_id = nhood.mayor_id,
|
||||||
|
mayor_elected_date = nhood.mayor_elected_date,
|
||||||
|
election_cycle_id = nhood.election_cycle_id
|
||||||
|
};
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, nhoodJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("userapi/city/{shardId}/neighborhoods/name/{nhoodName}")]
|
||||||
|
public IActionResult GetByName(int shardId, string nhoodName)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var searchNhood = da.Neighborhoods.SearchExact(shardId, nhoodName, 1).FirstOrDefault();
|
||||||
|
if (searchNhood == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONNhoodError("Neighborhood not found"));
|
||||||
|
|
||||||
|
var nhood = da.Neighborhoods.Get((uint)searchNhood.neighborhood_id);
|
||||||
|
if (nhood == null) return ApiResponse.Json(HttpStatusCode.NotFound, new JSONNhoodError("Neighborhood not found"));
|
||||||
|
|
||||||
|
var nhoodJson = new JSONNhood
|
||||||
|
{
|
||||||
|
neighborhood_id = nhood.neighborhood_id,
|
||||||
|
name = nhood.name,
|
||||||
|
description = nhood.description,
|
||||||
|
color = nhood.color,
|
||||||
|
town_hall_id = nhood.town_hall_id,
|
||||||
|
icon_url = nhood.icon_url,
|
||||||
|
mayor_id = nhood.mayor_id,
|
||||||
|
mayor_elected_date = nhood.mayor_elected_date,
|
||||||
|
election_cycle_id = nhood.election_cycle_id
|
||||||
|
};
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, nhoodJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONNhoodError
|
||||||
|
{
|
||||||
|
public string error;
|
||||||
|
public JSONNhoodError(string errorString)
|
||||||
|
{
|
||||||
|
error = errorString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JSONNhoods
|
||||||
|
{
|
||||||
|
public List<JSONNhood> neighborhoods { get; set; }
|
||||||
|
}
|
||||||
|
public class JSONNhood
|
||||||
|
{
|
||||||
|
public int neighborhood_id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public uint color { get; set; }
|
||||||
|
public int? town_hall_id { get; set; }
|
||||||
|
public string icon_url { get; set; }
|
||||||
|
public uint? mayor_id { get; set; }
|
||||||
|
public uint mayor_elected_date { get; set; }
|
||||||
|
public uint? election_cycle_id { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
616
server/FSO.Server.Api.Core/Controllers/RegistrationController.cs
Executable file
616
server/FSO.Server.Api.Core/Controllers/RegistrationController.cs
Executable file
|
@ -0,0 +1,616 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Database.DA.EmailConfirmation;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Controller for user registrations.
|
||||||
|
/// Supports email confirmation if enabled in config.json.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[EnableCors]
|
||||||
|
[Route("userapi/registration")]
|
||||||
|
[ApiController]
|
||||||
|
public class RegistrationController : ControllerBase
|
||||||
|
{
|
||||||
|
private const int REGISTER_THROTTLE_SECS = 60;
|
||||||
|
private const int EMAIL_CONFIRMATION_EXPIRE = 2 * 60 * 60; // 2 hrs
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Alphanumeric (lowercase), no whitespace or special chars, cannot start with an underscore.
|
||||||
|
/// </summary>
|
||||||
|
private static Regex USERNAME_VALIDATION = new Regex("^([a-z0-9]){1}([a-z0-9_]){2,23}$");
|
||||||
|
|
||||||
|
#region Registration
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateUser([FromForm] RegistrationModel user)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if(api.Config.SmtpEnabled)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "missing_confirmation_token"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip = ApiUtils.GetIP(Request);
|
||||||
|
|
||||||
|
user.username = user.username ?? "";
|
||||||
|
user.username = user.username.ToLowerInvariant();
|
||||||
|
user.email = user.email ?? "";
|
||||||
|
//user.key = user.key ?? "";
|
||||||
|
|
||||||
|
string failReason = null;
|
||||||
|
if (user.username.Length < 3) failReason = "user_short";
|
||||||
|
else if (user.username.Length > 24) failReason = "user_long";
|
||||||
|
else if (!USERNAME_VALIDATION.IsMatch(user.username ?? "")) failReason = "user_invalid";
|
||||||
|
else if ((user.password?.Length ?? 0) == 0) failReason = "pass_required";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var addr = new System.Net.Mail.MailAddress(user.email);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
failReason = "email_invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failReason != null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "bad_request",
|
||||||
|
error_description = failReason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (!string.IsNullOrEmpty(api.Config.Regkey) && api.Config.Regkey != user.key)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "key_wrong",
|
||||||
|
error_description = failReason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
//has this ip been banned?
|
||||||
|
var ban = da.Bans.GetByIP(ip);
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "ip_banned"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//has this user registered a new account too soon after their last?
|
||||||
|
var now = Epoch.Now;
|
||||||
|
var prev = da.Users.GetByRegisterIP(ip);
|
||||||
|
if (now - (prev.FirstOrDefault()?.register_date ?? 0) < REGISTER_THROTTLE_SECS)
|
||||||
|
{
|
||||||
|
//cannot create a new account this soon.
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "registrations_too_frequent"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var userModel = api.CreateUser(user.username, user.email, user.password, ip);
|
||||||
|
|
||||||
|
if(userModel==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "user_exists"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
api.SendEmailConfirmationOKMail(user.username, user.email);
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, userModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a confirmation token and send email.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("userapi/registration/request")]
|
||||||
|
public IActionResult CreateToken(ConfirmationCreateTokenModel model)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
// smtp needs to be configured for this
|
||||||
|
if(!api.Config.SmtpEnabled)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "smtp_disabled"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(model.confirmation_url==null||model.email==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "missing_fields"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify email syntax
|
||||||
|
// To do: check if email address is disposable.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var addr = new System.Net.Mail.MailAddress(model.email);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "email_invalid"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
// email is taken
|
||||||
|
if(da.Users.GetByEmail(model.email)!=null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "email_taken"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
EmailConfirmation confirm = da.EmailConfirmations.GetByEmail(model.email, ConfirmationType.email);
|
||||||
|
|
||||||
|
// already waiting for confirmation
|
||||||
|
if(confirm!=null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "confirmation_pending"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
uint expires = Epoch.Now + EMAIL_CONFIRMATION_EXPIRE;
|
||||||
|
|
||||||
|
// create new email confirmation
|
||||||
|
string token = da.EmailConfirmations.Create(new EmailConfirmation
|
||||||
|
{
|
||||||
|
type = ConfirmationType.email,
|
||||||
|
email = model.email,
|
||||||
|
expires = expires
|
||||||
|
});
|
||||||
|
|
||||||
|
// send email with recently generated token
|
||||||
|
bool sent = api.SendEmailConfirmationMail(model.email, token, model.confirmation_url, expires);
|
||||||
|
|
||||||
|
if(sent)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "email_failed"
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a user with a valid email confirmation token.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("userapi/registration/confirm")]
|
||||||
|
public IActionResult CreateUserWithToken(RegistrationUseTokenModel user)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "invalid_token"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
EmailConfirmation confirmation = da.EmailConfirmations.GetByToken(user.token);
|
||||||
|
|
||||||
|
if(confirmation == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "invalid_token"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip = ApiUtils.GetIP(Request);
|
||||||
|
|
||||||
|
user.username = user.username ?? "";
|
||||||
|
user.username = user.username.ToLowerInvariant();
|
||||||
|
user.email = user.email ?? "";
|
||||||
|
user.key = user.key ?? "";
|
||||||
|
|
||||||
|
string failReason = null;
|
||||||
|
if (user.username.Length < 3) failReason = "user_short";
|
||||||
|
else if (user.username.Length > 24) failReason = "user_long";
|
||||||
|
else if (!USERNAME_VALIDATION.IsMatch(user.username ?? "")) failReason = "user_invalid";
|
||||||
|
else if ((user.password?.Length ?? 0) == 0) failReason = "pass_required";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var addr = new System.Net.Mail.MailAddress(user.email);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
failReason = "email_invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failReason != null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "bad_request",
|
||||||
|
error_description = failReason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(api.Config.Regkey) && api.Config.Regkey != user.key)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "key_wrong",
|
||||||
|
error_description = failReason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//has this ip been banned?
|
||||||
|
var ban = da.Bans.GetByIP(ip);
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "ip_banned"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//has this user registered a new account too soon after their last?
|
||||||
|
var prev = da.Users.GetByRegisterIP(ip);
|
||||||
|
if (Epoch.Now - (prev.FirstOrDefault()?.register_date ?? 0) < REGISTER_THROTTLE_SECS)
|
||||||
|
{
|
||||||
|
//cannot create a new account this soon.
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "registrations_too_frequent"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//create user in db
|
||||||
|
var userModel = api.CreateUser(user.username, user.email, user.password, ip);
|
||||||
|
|
||||||
|
if (userModel == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "user_exists"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//send OK email
|
||||||
|
api.SendEmailConfirmationOKMail(user.username, user.email);
|
||||||
|
da.EmailConfirmations.Remove(user.token);
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, userModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Password reset
|
||||||
|
[HttpPost]
|
||||||
|
[Route("userapi/password")]
|
||||||
|
public IActionResult ChangePassword(PasswordResetModel model)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if (api.Config.SmtpEnabled)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "missing_confirmation_token"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// No empty fields
|
||||||
|
if (model.username==null||model.new_password==null||model.old_password==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "missing_fields"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var user = da.Users.GetByUsername(model.username);
|
||||||
|
|
||||||
|
if(user==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "user_invalid"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var authSettings = da.Users.GetAuthenticationSettings(user.user_id);
|
||||||
|
var correct = PasswordHasher.Verify(model.old_password, new PasswordHash
|
||||||
|
{
|
||||||
|
data = authSettings.data,
|
||||||
|
scheme = authSettings.scheme_class
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!correct)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "incorrect_password"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
api.ChangePassword(user.user_id, model.new_password);
|
||||||
|
api.SendPasswordResetOKMail(user.email, user.username);
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets a user's password using a confirmation token.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("userapi/password/confirm")]
|
||||||
|
public IActionResult ConfirmPwd(PasswordResetUseTokenModel model)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if(model.token==null||model.new_password==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "missing_fields"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
EmailConfirmation confirmation = da.EmailConfirmations.GetByToken(model.token);
|
||||||
|
|
||||||
|
if(confirmation==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "invalid_token"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = da.Users.GetByEmail(confirmation.email);
|
||||||
|
|
||||||
|
api.ChangePassword(user.user_id, model.new_password);
|
||||||
|
api.SendPasswordResetOKMail(user.email, user.username);
|
||||||
|
da.EmailConfirmations.Remove(model.token);
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a password reset token and mails it to the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("userapi/password/request")]
|
||||||
|
public IActionResult CreatePwdToken(ConfirmationCreateTokenModel model)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if (model.confirmation_url == null || model.email == null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "missing_fields"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify email syntax
|
||||||
|
// To do: check if email address is disposable.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var addr = new System.Net.Mail.MailAddress(model.email);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "email_invalid"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
|
||||||
|
var user = da.Users.GetByEmail(model.email);
|
||||||
|
|
||||||
|
if(user==null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "password_reset_failed",
|
||||||
|
error_description = "email_invalid"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
EmailConfirmation confirm = da.EmailConfirmations.GetByEmail(model.email, ConfirmationType.password);
|
||||||
|
|
||||||
|
// already awaiting a confirmation
|
||||||
|
// to-do: resend?
|
||||||
|
if (confirm != null)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new RegistrationError()
|
||||||
|
{
|
||||||
|
error = "registration_failed",
|
||||||
|
error_description = "confirmation_pending"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
uint expires = Epoch.Now + EMAIL_CONFIRMATION_EXPIRE;
|
||||||
|
|
||||||
|
// create new email confirmation
|
||||||
|
string token = da.EmailConfirmations.Create(new EmailConfirmation
|
||||||
|
{
|
||||||
|
type = ConfirmationType.password,
|
||||||
|
email = model.email,
|
||||||
|
expires = expires
|
||||||
|
});
|
||||||
|
|
||||||
|
// send confirmation email with generated token
|
||||||
|
bool sent = api.SendPasswordResetMail(model.email, user.username, token, model.confirmation_url, expires);
|
||||||
|
|
||||||
|
if (sent)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
status = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.Json(HttpStatusCode.OK, new
|
||||||
|
{
|
||||||
|
// success but email shitfaced
|
||||||
|
status = "email_failed"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Models
|
||||||
|
public class RegistrationError
|
||||||
|
{
|
||||||
|
public string error_description { get; set; }
|
||||||
|
public string error { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RegistrationModel
|
||||||
|
{
|
||||||
|
public string username { get; set; }
|
||||||
|
public string email { get; set; }
|
||||||
|
public string password { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Expected request data when trying to create a token to register.
|
||||||
|
/// </summary>
|
||||||
|
public class ConfirmationCreateTokenModel
|
||||||
|
{
|
||||||
|
public string email { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The link the user will have to go to in order to confirm their token.
|
||||||
|
/// If %token% is present in the url, it will be replaced with the user's token.
|
||||||
|
/// </summary>
|
||||||
|
public string confirmation_url { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PasswordResetModel
|
||||||
|
{
|
||||||
|
public string username { get; set; }
|
||||||
|
public string old_password { get; set; }
|
||||||
|
public string new_password { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Expected request data when trying to register with a token.
|
||||||
|
/// </summary>
|
||||||
|
public class RegistrationUseTokenModel
|
||||||
|
{
|
||||||
|
public string username { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// User email.
|
||||||
|
/// </summary>
|
||||||
|
public string email { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// User password.
|
||||||
|
/// </summary>
|
||||||
|
public string password { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Registration key.
|
||||||
|
/// </summary>
|
||||||
|
public string key { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The unique GUID.
|
||||||
|
/// </summary>
|
||||||
|
public string token { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PasswordResetUseTokenModel
|
||||||
|
{
|
||||||
|
public string token { get; set; }
|
||||||
|
public string new_password { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
98
server/FSO.Server.Api.Core/Controllers/ShardSelectorController.cs
Executable file
98
server/FSO.Server.Api.Core/Controllers/ShardSelectorController.cs
Executable file
|
@ -0,0 +1,98 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Database.DA.Shards;
|
||||||
|
using FSO.Server.Protocol.CitySelector;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[Route("cityselector/app/ShardSelectorServlet")]
|
||||||
|
[ApiController]
|
||||||
|
public class ShardSelectorController : ControllerBase
|
||||||
|
{
|
||||||
|
private static Func<IActionResult> ERROR_SHARD_NOT_FOUND = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("503", "Shard not found"));
|
||||||
|
private static Func<IActionResult> ERROR_AVATAR_NOT_FOUND = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("504", "Avatar not found"));
|
||||||
|
private static Func<IActionResult> ERROR_AVATAR_NOT_YOURS = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("505", "You do not own this avatar!"));
|
||||||
|
private static Func<IActionResult> ERROR_BANNED = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("506", "Your account has been banned."));
|
||||||
|
private static Func<IActionResult> ERROR_MAINTAINANCE = ApiResponse.XmlFuture(HttpStatusCode.OK, new XMLErrorMessage("507", "The server is currently undergoing maintainance. Please try again later."));
|
||||||
|
|
||||||
|
public IActionResult Get(string shardName, string avatarId)
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
var user = api.RequireAuthentication(Request);
|
||||||
|
if (avatarId == null){
|
||||||
|
//Using 0 to mean no avatar for CAS
|
||||||
|
avatarId = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var db = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
ShardStatusItem shard = api.Shards.GetByName(shardName);
|
||||||
|
if (shard != null)
|
||||||
|
{
|
||||||
|
var ip = ApiUtils.GetIP(Request);
|
||||||
|
uint avatarDBID = uint.Parse(avatarId);
|
||||||
|
|
||||||
|
if (avatarDBID != 0)
|
||||||
|
{
|
||||||
|
var avatar = db.Avatars.Get(avatarDBID);
|
||||||
|
if (avatar == null)
|
||||||
|
{
|
||||||
|
//can't join server with an avatar that doesn't exist
|
||||||
|
return ERROR_AVATAR_NOT_FOUND();
|
||||||
|
}
|
||||||
|
if (avatar.user_id != user.UserID || avatar.shard_id != shard.Id)
|
||||||
|
{
|
||||||
|
//make sure we own the avatar we're trying to connect with
|
||||||
|
return ERROR_AVATAR_NOT_YOURS();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var ban = db.Bans.GetByIP(ip);
|
||||||
|
var dbuser = db.Users.GetById(user.UserID);
|
||||||
|
if (dbuser == null || ban != null || dbuser.is_banned != false)
|
||||||
|
{
|
||||||
|
return ERROR_BANNED();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (api.Config.Maintainance && !(dbuser.is_admin || dbuser.is_moderator))
|
||||||
|
{
|
||||||
|
return ERROR_MAINTAINANCE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Make an auth ticket **/
|
||||||
|
var ticket = new ShardTicket
|
||||||
|
{
|
||||||
|
ticket_id = Guid.NewGuid().ToString().Replace("-", ""),
|
||||||
|
user_id = user.UserID,
|
||||||
|
avatar_id = avatarDBID,
|
||||||
|
date = Epoch.Now,
|
||||||
|
ip = ip
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Users.UpdateConnectIP(ticket.user_id, ip);
|
||||||
|
db.Shards.CreateTicket(ticket);
|
||||||
|
|
||||||
|
var result = new ShardSelectorServletResponse();
|
||||||
|
result.PreAlpha = false;
|
||||||
|
|
||||||
|
result.Address = shard.PublicHost;
|
||||||
|
result.PlayerID = user.UserID;
|
||||||
|
result.AvatarID = avatarId;
|
||||||
|
result.Ticket = ticket.ticket_id;
|
||||||
|
result.ConnectionID = ticket.ticket_id;
|
||||||
|
result.AvatarID = avatarId;
|
||||||
|
|
||||||
|
return ApiResponse.Xml(HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ERROR_SHARD_NOT_FOUND();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
server/FSO.Server.Api.Core/Controllers/ShardStatusController.cs
Executable file
29
server/FSO.Server.Api.Core/Controllers/ShardStatusController.cs
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
using FSO.Common.Utils;
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Protocol.CitySelector;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[EnableCors]
|
||||||
|
[Route("cityselector/shard-status.jsp")]
|
||||||
|
[ApiController]
|
||||||
|
public class ShardStatusController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get()
|
||||||
|
{
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
var result = new XMLList<ShardStatusItem>("Shard-Status-List");
|
||||||
|
var shards = api.Shards.All;
|
||||||
|
foreach (var shard in shards)
|
||||||
|
{
|
||||||
|
result.Add(shard);
|
||||||
|
}
|
||||||
|
return ApiResponse.Xml(HttpStatusCode.OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
122
server/FSO.Server.Api.Core/Controllers/UserOAuthController.cs
Executable file
122
server/FSO.Server.Api.Core/Controllers/UserOAuthController.cs
Executable file
|
@ -0,0 +1,122 @@
|
||||||
|
using FSO.Server.Api.Core.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using FSO.Server.Servers.Api.JsonWebToken;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Controllers
|
||||||
|
{
|
||||||
|
[Route("userapi/oauth/token")]
|
||||||
|
[ApiController]
|
||||||
|
public class UserOAuthController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateToken([FromForm] UserOAuthRequest userAuthRequest)
|
||||||
|
{
|
||||||
|
if (userAuthRequest == null) BadRequest();
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var user = da.Users.GetByUsername(userAuthRequest.username);
|
||||||
|
if (user == null || user.is_banned) return ApiResponse.Json(System.Net.HttpStatusCode.Unauthorized, new UserOAuthError("unauthorized_client", "user_credentials_invalid"));
|
||||||
|
var ip = ApiUtils.GetIP(Request);
|
||||||
|
var hashSettings = da.Users.GetAuthenticationSettings(user.user_id);
|
||||||
|
var isPasswordCorrect = PasswordHasher.Verify(userAuthRequest.password, new PasswordHash
|
||||||
|
{
|
||||||
|
data = hashSettings.data,
|
||||||
|
scheme = hashSettings.scheme_class
|
||||||
|
});
|
||||||
|
//check if account is locked due to failed attempts
|
||||||
|
var accLock = da.Users.GetRemainingAuth(user.user_id, ip);
|
||||||
|
if (accLock != null && (accLock.active || accLock.count >= AuthLoginController.LockAttempts) && accLock.expire_time > Epoch.Now)
|
||||||
|
{
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new UserOAuthError("unauthorized_client", "account_locked"));
|
||||||
|
}
|
||||||
|
//if the password is incorrect and check if user failed muli times and set a time out till next try.
|
||||||
|
if (!isPasswordCorrect)
|
||||||
|
{
|
||||||
|
var durations = AuthLoginController.LockDuration;
|
||||||
|
var failDelay = 60 * durations[Math.Min(durations.Length - 1, da.Users.FailedConsecutive(user.user_id, ip))];
|
||||||
|
if (accLock == null)
|
||||||
|
{
|
||||||
|
da.Users.NewFailedAuth(user.user_id, ip, (uint)failDelay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var remaining = da.Users.FailedAuth(accLock.attempt_id, (uint)failDelay, AuthLoginController.LockAttempts);
|
||||||
|
}
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new UserOAuthError("unauthorized_client", "user_credentials_invalid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//user passed the password check, and now creates the claim/token
|
||||||
|
da.Users.SuccessfulAuth(user.user_id, ip);
|
||||||
|
var claims = new List<string>();
|
||||||
|
|
||||||
|
//set the permission level in the claim
|
||||||
|
switch (userAuthRequest.permission_level)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
claims.Add("userReadPermissions");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
claims.Add("userReadPermissions");
|
||||||
|
claims.Add("userWritePermissions");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
claims.Add("userReadPermissions");
|
||||||
|
claims.Add("userWritePermissions");
|
||||||
|
claims.Add("userUpdatePermissions");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
claims.Add("userReadPermissions");
|
||||||
|
claims.Add("userWritePermissions");
|
||||||
|
claims.Add("userUpdatePermissions");
|
||||||
|
claims.Add("userDeletePermissions");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set the user identity
|
||||||
|
JWTUser identity = new JWTUser
|
||||||
|
{
|
||||||
|
UserID = user.user_id,
|
||||||
|
UserName = user.username,
|
||||||
|
Claims = claims
|
||||||
|
};
|
||||||
|
|
||||||
|
//generate the the tokenen and send it in a JSON format as response
|
||||||
|
var generatedToken = api.JWT.CreateToken(identity);
|
||||||
|
return ApiResponse.Json(System.Net.HttpStatusCode.OK, new UserOAuthSuccess
|
||||||
|
{
|
||||||
|
access_token = generatedToken.Token,
|
||||||
|
expires_in = generatedToken.ExpiresIn
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class UserOAuthRequest
|
||||||
|
{
|
||||||
|
public int permission_level { get; set; }
|
||||||
|
public string username { get; set; }
|
||||||
|
public string password { get; set; }
|
||||||
|
}
|
||||||
|
public class UserOAuthError
|
||||||
|
{
|
||||||
|
public string error;
|
||||||
|
public string error_description;
|
||||||
|
public UserOAuthError(string errorString,string errorDescriptionString)
|
||||||
|
{
|
||||||
|
error = errorString;
|
||||||
|
error_description = errorDescriptionString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class UserOAuthSuccess
|
||||||
|
{
|
||||||
|
public string access_token { get; set; }
|
||||||
|
public int expires_in { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
66
server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj
Executable file
66
server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
|
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="MailTemplates\MailBan.html" />
|
||||||
|
<None Remove="MailTemplates\MailBase.html" />
|
||||||
|
<None Remove="MailTemplates\MailPasswordReset.html" />
|
||||||
|
<None Remove="MailTemplates\MailPasswordResetOK.html" />
|
||||||
|
<None Remove="MailTemplates\MailRegistrationOK.html" />
|
||||||
|
<None Remove="MailTemplates\MailRegistrationToken.html" />
|
||||||
|
<None Remove="MailTemplates\MailUnban.html" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="MailTemplates\MailBan.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="MailTemplates\MailBase.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="MailTemplates\MailPasswordReset.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="MailTemplates\MailPasswordResetOK.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="MailTemplates\MailRegistrationOK.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="MailTemplates\MailRegistrationToken.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="MailTemplates\MailUnban.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="wwwroot\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AWSSDK.Core" Version="3.3.103.48" />
|
||||||
|
<PackageReference Include="AWSSDK.S3" Version="3.3.104.36" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.7" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Octokit" Version="0.36.0" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FSO.Server.Common\FSO.Server.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\FSO.Server.Database\FSO.Server.Database.csproj" />
|
||||||
|
<ProjectReference Include="..\FSO.Server.Domain\FSO.Server.Domain.csproj" />
|
||||||
|
<ProjectReference Include="..\FSO.Server.Protocol\FSO.Server.Protocol.csproj" />
|
||||||
|
<ProjectReference Include="..\tso.common\FSO.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\tso.files\FSO.Files.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
13
server/FSO.Server.Api.Core/MailTemplates/MailBan.html
Executable file
13
server/FSO.Server.Api.Core/MailTemplates/MailBan.html
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
<strong>Account Suspended.</strong>
|
||||||
|
<br>One of your FreeSO accounts has been suspended for not following <a href="http://freeso.org/rules">the rules</a>.
|
||||||
|
<br>Banned account username:
|
||||||
|
<strong>%username%</strong>.
|
||||||
|
<br>
|
||||||
|
<br />
|
||||||
|
Expiration date:
|
||||||
|
<strong>%end%</strong>
|
||||||
|
<br />
|
||||||
|
<br>Official Discord:
|
||||||
|
<a href='https://discord.gg/xveESFj'>https://discord.gg/xveESFj</a>
|
||||||
|
<br>Forums:
|
||||||
|
<a href='http://forum.freeso.org'>http://forum.freeso.org</a>
|
9
server/FSO.Server.Api.Core/MailTemplates/MailBase.html
Executable file
9
server/FSO.Server.Api.Core/MailTemplates/MailBase.html
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
<div style='font-family:Arial;border-radius:6px;border:1px solid #3875B9;padding:20px;max-width:500px;text-align:justify;line-height:22px'>
|
||||||
|
<div style='display:block;padding-bottom:20px;overflow:hidden;border-bottom:1px solid #3875B9'>
|
||||||
|
<img style='float:left' src='https://beta.freeso.org/cdn/img/slogo.png'>
|
||||||
|
<span style='float:left;margin-left:15px;margin-top:15px'>Official Game Server</span>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
%content%
|
||||||
|
<br />
|
||||||
|
</div>
|
11
server/FSO.Server.Api.Core/MailTemplates/MailPasswordReset.html
Executable file
11
server/FSO.Server.Api.Core/MailTemplates/MailPasswordReset.html
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
<strong>Password Reset Request</strong>
|
||||||
|
<br>You requested a password reset. Good news, it's here!
|
||||||
|
<br><a href='%confirmation_url%'>Click here to change your password</a>. The link will expire in %expires%.
|
||||||
|
<br>Just in case, your token is: %token%.
|
||||||
|
<br />
|
||||||
|
<br>Official Discord: <a href='https://discord.gg/xveESFj'>https://discord.gg/xveESFj</a>
|
||||||
|
<br>Forums: <a href='http://forum.freeso.org'>http://forum.freeso.org</a>
|
||||||
|
<br>Twitter: <a href='http://twitter.com/FreeSOGame'>http://twitter.com/FreeSOGame</a>
|
||||||
|
<br>
|
||||||
|
<br><strong>Download the FreeSO Installer</strong>
|
||||||
|
<br>Get the installer from <a href='http://beta.freeso.org'>FreeSO.org</a>. After confirming your account by clicking the link above, you will be able to create an account and login.
|
10
server/FSO.Server.Api.Core/MailTemplates/MailPasswordResetOK.html
Executable file
10
server/FSO.Server.Api.Core/MailTemplates/MailPasswordResetOK.html
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
<strong>Your account password was just changed.</strong>
|
||||||
|
<br>The password for your account with username <strong>%username%</strong> was just changed.
|
||||||
|
<br />
|
||||||
|
<br>Official Discord: <a href='https://discord.gg/xveESFj'>https://discord.gg/xveESFj</a>
|
||||||
|
<br>Forums: <a href='http://forum.freeso.org'>http://forum.freeso.org</a>
|
||||||
|
<br>Twitter: <a href='http://twitter.com/FreeSOGame'>http://twitter.com/FreeSOGame</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<strong>Learn how to get started:</strong>
|
||||||
|
<br>Check out TSOMania's guide at <a href="http://www.tsomania.net/gameguides/getting_started.php">TSOMania.net</a>.
|
12
server/FSO.Server.Api.Core/MailTemplates/MailRegistrationOK.html
Executable file
12
server/FSO.Server.Api.Core/MailTemplates/MailRegistrationOK.html
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
<strong>Welcome to Sunrise Crater!</strong>
|
||||||
|
<br>You can now login in-game. Here are your details:
|
||||||
|
<br>Your username is: <strong>%username%</strong>. If you need any further support message us on one of our platforms.
|
||||||
|
<br>Please check out <a href="http://freeso.org/rules">the rules</a> if you haven't already!
|
||||||
|
<br />
|
||||||
|
<br>Official Discord: <a href='https://discord.gg/xveESFj'>https://discord.gg/xveESFj</a>
|
||||||
|
<br>Forums: <a href='http://forum.freeso.org'>http://forum.freeso.org</a>
|
||||||
|
<br>Twitter: <a href='http://twitter.com/FreeSOGame'>http://twitter.com/FreeSOGame</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<strong>Learn how to get started:</strong>
|
||||||
|
<br>Check out TSOMania's guide at <a href="http://www.tsomania.net/gameguides/getting_started.php">TSOMania.net</a>.
|
11
server/FSO.Server.Api.Core/MailTemplates/MailRegistrationToken.html
Executable file
11
server/FSO.Server.Api.Core/MailTemplates/MailRegistrationToken.html
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
<strong>You are almost here...</strong>
|
||||||
|
<br>One last step! Verify your email address:
|
||||||
|
<br><a href='%confirmation_url%'>Click here finish your registration</a>. The link will expire in %expires%.
|
||||||
|
<br>Just in case, your token is: %token%.
|
||||||
|
<br />
|
||||||
|
<br>Official Discord: <a href='https://discord.gg/xveESFj'>https://discord.gg/xveESFj</a>
|
||||||
|
<br>Forums: <a href='http://forum.freeso.org'>http://forum.freeso.org</a>
|
||||||
|
<br>Twitter: <a href='http://twitter.com/FreeSOGame'>http://twitter.com/FreeSOGame</a>
|
||||||
|
<br>
|
||||||
|
<br><strong>Download the FreeSO Installer</strong>
|
||||||
|
<br>Get the installer from <a href='http://beta.freeso.org'>FreeSO.org</a>. After confirming your account by clicking the link above, you will be able to create an account and login.
|
1
server/FSO.Server.Api.Core/MailTemplates/MailUnban.html
Executable file
1
server/FSO.Server.Api.Core/MailTemplates/MailUnban.html
Executable file
|
@ -0,0 +1 @@
|
||||||
|
<!-- To-do -->
|
36
server/FSO.Server.Api.Core/Models/EventCreateModel.cs
Executable file
36
server/FSO.Server.Api.Core/Models/EventCreateModel.cs
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Models
|
||||||
|
{
|
||||||
|
public class EventCreateModel
|
||||||
|
{
|
||||||
|
public string title;
|
||||||
|
public string description;
|
||||||
|
public DateTime start_day;
|
||||||
|
public DateTime end_day;
|
||||||
|
public string type;
|
||||||
|
public int value;
|
||||||
|
public int value2;
|
||||||
|
public string mail_subject;
|
||||||
|
public string mail_message;
|
||||||
|
public int mail_sender;
|
||||||
|
public string mail_sender_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PresetCreateModel
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
public string description;
|
||||||
|
public int flags;
|
||||||
|
public List<PresetItemModel> items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PresetItemModel
|
||||||
|
{
|
||||||
|
public string tuning_type;
|
||||||
|
public int tuning_table;
|
||||||
|
public int tuning_index;
|
||||||
|
public float value;
|
||||||
|
}
|
||||||
|
}
|
10
server/FSO.Server.Api.Core/Models/FSOUpdateManifest.cs
Executable file
10
server/FSO.Server.Api.Core/Models/FSOUpdateManifest.cs
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
using FSO.Files.Utils;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Models
|
||||||
|
{
|
||||||
|
public class FSOUpdateManifest {
|
||||||
|
public string Version;
|
||||||
|
public List<FileDiff> Diffs;
|
||||||
|
}
|
||||||
|
}
|
14
server/FSO.Server.Api.Core/Models/UpdateCreateModel.cs
Executable file
14
server/FSO.Server.Api.Core/Models/UpdateCreateModel.cs
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace FSO.Server.Api.Core.Models
|
||||||
|
{
|
||||||
|
public class UpdateCreateModel
|
||||||
|
{
|
||||||
|
public int branchID;
|
||||||
|
public uint scheduledEpoch;
|
||||||
|
public string catalog;
|
||||||
|
|
||||||
|
public bool contentOnly;
|
||||||
|
public bool includeMonogameDelta;
|
||||||
|
public bool disableIncremental;
|
||||||
|
public bool minorVersion;
|
||||||
|
}
|
||||||
|
}
|
69
server/FSO.Server.Api.Core/Models/UpdateGenerationStatus.cs
Executable file
69
server/FSO.Server.Api.Core/Models/UpdateGenerationStatus.cs
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
using FSO.Server.Database.DA.Updates;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Models
|
||||||
|
{
|
||||||
|
public class UpdateGenerationStatus
|
||||||
|
{
|
||||||
|
public int TaskID;
|
||||||
|
public UpdateCreateModel Request;
|
||||||
|
public UpdateGenerationStatusCode Code;
|
||||||
|
public float EstimatedProgress;
|
||||||
|
|
||||||
|
public DbUpdate Result;
|
||||||
|
public string Failure;
|
||||||
|
|
||||||
|
public UpdateGenerationStatus(int taskID, UpdateCreateModel request)
|
||||||
|
{
|
||||||
|
TaskID = taskID;
|
||||||
|
Request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateStatus(UpdateGenerationStatusCode code, float progress)
|
||||||
|
{
|
||||||
|
Code = code;
|
||||||
|
EstimatedProgress = progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateStatus(UpdateGenerationStatusCode code)
|
||||||
|
{
|
||||||
|
UpdateStatus(code, ((float)code - 1) / ((float)UpdateGenerationStatusCode.SUCCESS - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetResult(DbUpdate result)
|
||||||
|
{
|
||||||
|
UpdateStatus(UpdateGenerationStatusCode.SUCCESS);
|
||||||
|
Result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFailure(string failure)
|
||||||
|
{
|
||||||
|
UpdateStatus(UpdateGenerationStatusCode.FAILURE, 0);
|
||||||
|
Failure = failure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UpdateGenerationStatusCode
|
||||||
|
{
|
||||||
|
FAILURE = 0,
|
||||||
|
|
||||||
|
PREPARING = 1,
|
||||||
|
DOWNLOADING_CLIENT,
|
||||||
|
DOWNLOADING_SERVER,
|
||||||
|
DOWNLOADING_CLIENT_ADDON,
|
||||||
|
DOWNLOADING_SERVER_ADDON,
|
||||||
|
EXTRACTING_CLIENT,
|
||||||
|
EXTRACTING_CLIENT_ADDON,
|
||||||
|
BUILDING_DIFF,
|
||||||
|
BUILDING_INCREMENTAL_UPDATE,
|
||||||
|
BUILDING_CLIENT,
|
||||||
|
PUBLISHING_CLIENT,
|
||||||
|
|
||||||
|
EXTRACTING_SERVER,
|
||||||
|
EXTRACTING_SERVER_ADDON,
|
||||||
|
BUILDING_SERVER,
|
||||||
|
PUBLISHING_SERVER,
|
||||||
|
|
||||||
|
SCHEDULING_UPDATE,
|
||||||
|
SUCCESS
|
||||||
|
}
|
||||||
|
}
|
53
server/FSO.Server.Api.Core/Program.cs
Executable file
53
server/FSO.Server.Api.Core/Program.cs
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using Microsoft.AspNetCore;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var host = CreateWebHostBuilder(args).Build();
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IAPILifetime RunAsync(string[] args)
|
||||||
|
{
|
||||||
|
var host = CreateWebHostBuilder(args).Build();
|
||||||
|
var lifetime = new APIControl((IApplicationLifetime)host.Services.GetService(typeof(IApplicationLifetime)));
|
||||||
|
host.Start();
|
||||||
|
return lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||||
|
WebHost.CreateDefaultBuilder(args)
|
||||||
|
.UseUrls(args[0])
|
||||||
|
.ConfigureLogging(x =>
|
||||||
|
{
|
||||||
|
x.SetMinimumLevel(LogLevel.None);
|
||||||
|
})
|
||||||
|
.UseKestrel(options =>
|
||||||
|
{
|
||||||
|
options.Limits.MaxRequestBodySize = 500000000;
|
||||||
|
})
|
||||||
|
.SuppressStatusMessages(true)
|
||||||
|
.UseStartup<Startup>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class APIControl : IAPILifetime
|
||||||
|
{
|
||||||
|
private IApplicationLifetime Lifetime;
|
||||||
|
|
||||||
|
public APIControl(IApplicationLifetime lifetime)
|
||||||
|
{
|
||||||
|
Lifetime = lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
Lifetime.StopApplication();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
server/FSO.Server.Api.Core/Properties/launchSettings.json
Executable file
30
server/FSO.Server.Api.Core/Properties/launchSettings.json
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:61113",
|
||||||
|
"sslPort": 44333
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "api/values",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"FSO.Server.Api.Core": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "api/values",
|
||||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
server/FSO.Server.Api.Core/Services/AWSUpdateUploader.cs
Executable file
54
server/FSO.Server.Api.Core/Services/AWSUpdateUploader.cs
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
using Amazon;
|
||||||
|
using Amazon.Runtime;
|
||||||
|
using Amazon.S3;
|
||||||
|
using Amazon.S3.Model;
|
||||||
|
using FSO.Server.Common.Config;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Services
|
||||||
|
{
|
||||||
|
public class AWSUpdateUploader : IUpdateUploader
|
||||||
|
{
|
||||||
|
private AWSConfig Config;
|
||||||
|
public AWSUpdateUploader(AWSConfig config)
|
||||||
|
{
|
||||||
|
Config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> UploadFile(string destPath, string fileName, string groupName)
|
||||||
|
{
|
||||||
|
var region = Config.Region;
|
||||||
|
var bucket = Config.Bucket;
|
||||||
|
var s3config = new AmazonS3Config()
|
||||||
|
{
|
||||||
|
RegionEndpoint = RegionEndpoint.GetBySystemName(region),
|
||||||
|
Timeout = new TimeSpan(1, 0, 0),
|
||||||
|
ReadWriteTimeout = new TimeSpan(1, 0, 0),
|
||||||
|
MaxErrorRetry = 512
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var aws = new AmazonS3Client(new BasicAWSCredentials(Config.AccessKeyID, Config.SecretAccessKey), s3config))
|
||||||
|
{
|
||||||
|
PutObjectRequest request = new PutObjectRequest()
|
||||||
|
{
|
||||||
|
InputStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite),
|
||||||
|
BucketName = bucket,
|
||||||
|
CannedACL = S3CannedACL.PublicRead,
|
||||||
|
Key = destPath
|
||||||
|
};
|
||||||
|
PutObjectResponse response = await aws.PutObjectAsync(request);
|
||||||
|
|
||||||
|
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
return $"https://s3.{region}.amazonaws.com/{bucket}/" + destPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Uploading file " + destPath + " failed with code " + response.HttpStatusCode + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
324
server/FSO.Server.Api.Core/Services/GenerateUpdateService.cs
Executable file
324
server/FSO.Server.Api.Core/Services/GenerateUpdateService.cs
Executable file
|
@ -0,0 +1,324 @@
|
||||||
|
using FSO.Server.Api.Core.Models;
|
||||||
|
using FSO.Server.Database.DA.Updates;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FSO.Files.Utils;
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Services
|
||||||
|
{
|
||||||
|
public class GenerateUpdateService
|
||||||
|
{
|
||||||
|
private static GenerateUpdateService _INSTANCE;
|
||||||
|
public static GenerateUpdateService INSTANCE
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_INSTANCE == null) _INSTANCE = new GenerateUpdateService();
|
||||||
|
return _INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int LastTaskID = 0;
|
||||||
|
public Dictionary<int, UpdateGenerationStatus> Tasks = new Dictionary<int, UpdateGenerationStatus>();
|
||||||
|
|
||||||
|
public UpdateGenerationStatus GetTask(int id)
|
||||||
|
{
|
||||||
|
UpdateGenerationStatus result;
|
||||||
|
lock (Tasks)
|
||||||
|
{
|
||||||
|
if (!Tasks.TryGetValue(id, out result)) return null;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateGenerationStatus CreateTask(UpdateCreateModel request)
|
||||||
|
{
|
||||||
|
UpdateGenerationStatus task;
|
||||||
|
lock (Tasks)
|
||||||
|
{
|
||||||
|
task = new UpdateGenerationStatus(++LastTaskID, request);
|
||||||
|
Tasks[LastTaskID] = task;
|
||||||
|
}
|
||||||
|
Task.Run(() => BuildUpdate(task));
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Exec(string cmd)
|
||||||
|
{
|
||||||
|
var escapedArgs = cmd.Replace("\"", "\\\"");
|
||||||
|
|
||||||
|
var process = new Process
|
||||||
|
{
|
||||||
|
StartInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
|
FileName = "/bin/sh",
|
||||||
|
Arguments = $"-c \"{escapedArgs}\""
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearFolderPermissions(string folder)
|
||||||
|
{
|
||||||
|
if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
|
Exec($"chmod -R 777 {folder}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetZipFolder(string path)
|
||||||
|
{
|
||||||
|
var directories = Directory.GetDirectories(path);
|
||||||
|
if (directories.Length != 1) return path;
|
||||||
|
var files = Directory.GetFiles(path);
|
||||||
|
if (files.Length != 0) return path;
|
||||||
|
return directories[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task BuildUpdate(UpdateGenerationStatus status)
|
||||||
|
{
|
||||||
|
var request = status.Request;
|
||||||
|
var api = Api.INSTANCE;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.PREPARING);
|
||||||
|
using (var da = api.DAFactory.Get())
|
||||||
|
{
|
||||||
|
var baseUpdateKey = "updates/";
|
||||||
|
var branch = da.Updates.GetBranch(status.Request.branchID);
|
||||||
|
|
||||||
|
//reserve update id. may cause race condition, but only one person can update anyways.
|
||||||
|
if (request.minorVersion) ++branch.minor_version_number;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++branch.last_version_number;
|
||||||
|
branch.minor_version_number = 0;
|
||||||
|
}
|
||||||
|
var updateID = branch.last_version_number;
|
||||||
|
var minorChar = (branch.minor_version_number == 0) ? "" : ((char)('a' + (branch.minor_version_number - 1))).ToString();
|
||||||
|
var versionName = branch.version_format.Replace("#", updateID.ToString()).Replace("@", minorChar);
|
||||||
|
var versionText = versionName;
|
||||||
|
|
||||||
|
var result = new DbUpdate()
|
||||||
|
{
|
||||||
|
addon_id = branch.addon_id,
|
||||||
|
branch_id = branch.branch_id,
|
||||||
|
date = DateTime.UtcNow,
|
||||||
|
version_name = versionName,
|
||||||
|
deploy_after = Epoch.ToDate(status.Request.scheduledEpoch)
|
||||||
|
};
|
||||||
|
|
||||||
|
versionName = versionName.Replace('/', '-');
|
||||||
|
|
||||||
|
var client = new WebClient();
|
||||||
|
//fetch artifacts
|
||||||
|
//http://servo.freeso.org/guestAuth/repository/download/FreeSO_TsoClient/.lastSuccessful/client-<>.zip
|
||||||
|
//http://servo.freeso.org/guestAuth/repository/download/FreeSO_TsoClient/.lastSuccessful/server-<>.zip
|
||||||
|
|
||||||
|
int updateWorkID = status.TaskID;
|
||||||
|
|
||||||
|
var updateDir = "updateTemp/" + updateWorkID + "/";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(updateDir, true);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
Directory.CreateDirectory(updateDir);
|
||||||
|
Directory.CreateDirectory(updateDir + "client/");
|
||||||
|
Directory.CreateDirectory(updateDir + "server/");
|
||||||
|
|
||||||
|
string clientArti = null;
|
||||||
|
string serverArti = null;
|
||||||
|
if (branch.base_build_url != null)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.DOWNLOADING_CLIENT);
|
||||||
|
await client.DownloadFileTaskAsync(new Uri(branch.base_build_url), updateDir + "client.zip");
|
||||||
|
clientArti = updateDir + "client.zip";
|
||||||
|
}
|
||||||
|
if (branch.base_server_build_url != null)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.DOWNLOADING_SERVER);
|
||||||
|
await client.DownloadFileTaskAsync(new Uri(branch.base_server_build_url), updateDir + "server.zip");
|
||||||
|
serverArti = updateDir + "server.zip";
|
||||||
|
}
|
||||||
|
|
||||||
|
string clientAddon = null;
|
||||||
|
string serverAddon = null;
|
||||||
|
|
||||||
|
if (branch.addon_id != null)
|
||||||
|
{
|
||||||
|
var addon = da.Updates.GetAddon(branch.addon_id.Value);
|
||||||
|
if (addon.addon_zip_url != null)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.DOWNLOADING_CLIENT_ADDON);
|
||||||
|
await client.DownloadFileTaskAsync(new Uri(addon.addon_zip_url), updateDir + "clientAddon.zip");
|
||||||
|
clientAddon = updateDir + "clientAddon.zip";
|
||||||
|
}
|
||||||
|
if (addon.server_zip_url != null)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.DOWNLOADING_SERVER_ADDON);
|
||||||
|
await client.DownloadFileTaskAsync(new Uri(addon.addon_zip_url), updateDir + "serverAddon.zip");
|
||||||
|
serverAddon = updateDir + "serverAddon.zip";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serverAddon = clientAddon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//last client update.
|
||||||
|
var previousUpdate = (branch.current_dist_id == null) ? null : da.Updates.GetUpdate(branch.current_dist_id.Value);
|
||||||
|
|
||||||
|
//all files downloaded. build the folders.
|
||||||
|
//extract the artifact and then our artifact over it.
|
||||||
|
if (clientArti != null)
|
||||||
|
{
|
||||||
|
var clientPath = updateDir + "client/";
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.EXTRACTING_CLIENT);
|
||||||
|
var clientZip = ZipFile.Open(clientArti, ZipArchiveMode.Read);
|
||||||
|
clientZip.ExtractToDirectory(clientPath, true);
|
||||||
|
clientZip.Dispose();
|
||||||
|
File.Delete(clientArti);
|
||||||
|
clientPath = GetZipFolder(clientPath);
|
||||||
|
|
||||||
|
if (clientAddon != null)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.EXTRACTING_CLIENT_ADDON);
|
||||||
|
var addonZip = ZipFile.Open(clientAddon, ZipArchiveMode.Read);
|
||||||
|
addonZip.ExtractToDirectory(clientPath, true);
|
||||||
|
addonZip.Dispose();
|
||||||
|
if (clientAddon != serverAddon) File.Delete(clientAddon);
|
||||||
|
}
|
||||||
|
//emit version number
|
||||||
|
await System.IO.File.WriteAllTextAsync(Path.Combine(clientPath, "version.txt"), versionText);
|
||||||
|
if (request.catalog != null)
|
||||||
|
{
|
||||||
|
await System.IO.File.WriteAllTextAsync(Path.Combine(clientPath, "Content/Objects/catalog_downloads.xml"), request.catalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
string diffZip = null;
|
||||||
|
FSOUpdateManifest manifest = null;
|
||||||
|
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.BUILDING_DIFF);
|
||||||
|
if (previousUpdate != null || request.disableIncremental)
|
||||||
|
{
|
||||||
|
result.last_update_id = previousUpdate.update_id;
|
||||||
|
//calculate difference, generate an incremental update manifest + zip
|
||||||
|
var prevFile = updateDir + "prev.zip";
|
||||||
|
await client.DownloadFileTaskAsync(new Uri(previousUpdate.full_zip), updateDir + "prev.zip");
|
||||||
|
var prevZip = ZipFile.Open(prevFile, ZipArchiveMode.Read);
|
||||||
|
prevZip.ExtractToDirectory(updateDir + "prev/", true);
|
||||||
|
prevZip.Dispose();
|
||||||
|
File.Delete(updateDir + "prev.zip");
|
||||||
|
|
||||||
|
var diffs = DiffGenerator.GetDiffs(Path.GetFullPath(updateDir + "prev/"), Path.GetFullPath(clientPath));
|
||||||
|
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.BUILDING_INCREMENTAL_UPDATE);
|
||||||
|
var toZip = diffs.Where(x => x.DiffType == FileDiffType.Add || x.DiffType == FileDiffType.Modify);
|
||||||
|
if (request.contentOnly) toZip = toZip.Where(x => x.Path.Replace('\\', '/').TrimStart('/').StartsWith("Content"));
|
||||||
|
if (!request.includeMonogameDelta) toZip = toZip.Where(x => !x.Path.Replace('\\', '/').TrimStart('/').StartsWith("Monogame"));
|
||||||
|
//build diff folder
|
||||||
|
Directory.CreateDirectory(updateDir + "diff/");
|
||||||
|
foreach (var diff in toZip)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(Path.Combine(updateDir + "diff/", diff.Path)));
|
||||||
|
System.IO.File.Copy(Path.Combine(clientPath, diff.Path), Path.Combine(updateDir + "diff/", diff.Path));
|
||||||
|
}
|
||||||
|
diffZip = updateDir + "diffResult.zip";
|
||||||
|
ClearFolderPermissions(updateDir + "diff/");
|
||||||
|
ZipFile.CreateFromDirectory(updateDir + "diff/", diffZip, CompressionLevel.Optimal, false);
|
||||||
|
Directory.Delete(updateDir + "diff/", true);
|
||||||
|
manifest = new FSOUpdateManifest() { Diffs = diffs };
|
||||||
|
|
||||||
|
Directory.Delete(updateDir + "prev/", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (request.contentOnly) throw new Exception("Invalid request - you cannot make a content only update with no delta.");
|
||||||
|
//full update only. generate simple manifest that contains all files (added)
|
||||||
|
manifest = new FSOUpdateManifest() { Diffs = new List<FileDiff>() };
|
||||||
|
}
|
||||||
|
|
||||||
|
//pack full client
|
||||||
|
if (!request.contentOnly)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.BUILDING_CLIENT);
|
||||||
|
var finalClientZip = updateDir + "clientResult.zip";
|
||||||
|
ClearFolderPermissions(clientPath);
|
||||||
|
ZipFile.CreateFromDirectory(clientPath, finalClientZip, CompressionLevel.Optimal, false);
|
||||||
|
Directory.Delete(updateDir + "client/", true);
|
||||||
|
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.PUBLISHING_CLIENT);
|
||||||
|
result.full_zip = await Api.INSTANCE.UpdateUploaderClient.UploadFile($"{baseUpdateKey}client-{versionName}.zip", finalClientZip, versionName);
|
||||||
|
}
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.PUBLISHING_CLIENT);
|
||||||
|
if (diffZip != null)
|
||||||
|
{
|
||||||
|
result.incremental_zip = await Api.INSTANCE.UpdateUploaderClient.UploadFile($"{baseUpdateKey}incremental-{versionName}.zip", diffZip, versionName);
|
||||||
|
}
|
||||||
|
await System.IO.File.WriteAllTextAsync(updateDir + "manifest.json", Newtonsoft.Json.JsonConvert.SerializeObject(manifest));
|
||||||
|
result.manifest_url = await Api.INSTANCE.UpdateUploaderClient.UploadFile($"{baseUpdateKey}{versionName}.json", updateDir + "manifest.json", versionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverArti != null && !request.contentOnly)
|
||||||
|
{
|
||||||
|
var serverPath = updateDir + "server/";
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.EXTRACTING_SERVER);
|
||||||
|
var serverZip = ZipFile.Open(serverArti, ZipArchiveMode.Read);
|
||||||
|
serverZip.ExtractToDirectory(serverPath, true);
|
||||||
|
serverZip.Dispose();
|
||||||
|
File.Delete(serverArti);
|
||||||
|
serverPath = GetZipFolder(serverPath);
|
||||||
|
|
||||||
|
if (serverAddon != null)
|
||||||
|
{
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.EXTRACTING_SERVER_ADDON);
|
||||||
|
var addonZip = ZipFile.Open(serverAddon, ZipArchiveMode.Read);
|
||||||
|
addonZip.ExtractToDirectory(serverPath, true);
|
||||||
|
addonZip.Dispose();
|
||||||
|
File.Delete(serverAddon);
|
||||||
|
}
|
||||||
|
//emit version number
|
||||||
|
await System.IO.File.WriteAllTextAsync(Path.Combine(serverPath, "version.txt"), versionText);
|
||||||
|
if (request.catalog != null)
|
||||||
|
{
|
||||||
|
await System.IO.File.WriteAllTextAsync(Path.Combine(serverPath, "Content/Objects/catalog_downloads.xml"), request.catalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.BUILDING_SERVER);
|
||||||
|
var finalServerZip = updateDir + "serverResult.zip";
|
||||||
|
ClearFolderPermissions(serverPath);
|
||||||
|
ZipFile.CreateFromDirectory(serverPath, finalServerZip, CompressionLevel.Optimal, false);
|
||||||
|
Directory.Delete(updateDir + "server/", true);
|
||||||
|
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.PUBLISHING_SERVER);
|
||||||
|
result.server_zip = await Api.INSTANCE.UpdateUploader.UploadFile($"{baseUpdateKey}server-{versionName}.zip", finalServerZip, versionName);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
result.server_zip = result.incremental_zip; //same as client, as server uses same content.
|
||||||
|
}
|
||||||
|
|
||||||
|
status.UpdateStatus(UpdateGenerationStatusCode.SCHEDULING_UPDATE);
|
||||||
|
var finalID = da.Updates.AddUpdate(result);
|
||||||
|
da.Updates.UpdateBranchLatest(branch.branch_id, branch.last_version_number, branch.minor_version_number);
|
||||||
|
status.SetResult(result);
|
||||||
|
}
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
status.SetFailure("Update could not be completed." + e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
server/FSO.Server.Api.Core/Services/GithubUpdateUploader.cs
Executable file
61
server/FSO.Server.Api.Core/Services/GithubUpdateUploader.cs
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
using FSO.Server.Common.Config;
|
||||||
|
using Octokit;
|
||||||
|
using Octokit.Internal;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Services
|
||||||
|
{
|
||||||
|
public class GithubUpdateUploader : IUpdateUploader
|
||||||
|
{
|
||||||
|
private GithubConfig Config;
|
||||||
|
|
||||||
|
private static string Description = "This is an automated client release produced by the master FreeSO server. " +
|
||||||
|
"These releases match up with a branch on GitHub, but with some addon content such as a custom catalog and splash. " +
|
||||||
|
"It can be downloaded and installed directly, but it is better to do so through the game's launcher/updater. \n\n" +
|
||||||
|
"The incremental update is applied by simply extracting the zip over the previous version of the game " +
|
||||||
|
"(though the updater still affords extra validation here)";
|
||||||
|
|
||||||
|
public GithubUpdateUploader(GithubConfig config)
|
||||||
|
{
|
||||||
|
Config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> UploadFile(string destPath, string fileName, string groupName)
|
||||||
|
{
|
||||||
|
destPath = Path.GetFileName(destPath);
|
||||||
|
var credentials = new InMemoryCredentialStore(new Credentials(Config.AccessToken));
|
||||||
|
|
||||||
|
var client = new GitHubClient(new ProductHeaderValue(Config.AppName), credentials);
|
||||||
|
|
||||||
|
Release release;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
release = await client.Repository.Release.Get(Config.User, Config.Repository, groupName);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
release = null;
|
||||||
|
}
|
||||||
|
if (release == null) {
|
||||||
|
var newRel = new NewRelease(groupName);
|
||||||
|
newRel.Body = Description;
|
||||||
|
release = await client.Repository.Release.Create(Config.User, Config.Repository, newRel);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var file = File.Open(fileName, System.IO.FileMode.Open, FileAccess.Read, FileShare.Read)) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var asset = await client.Repository.Release.UploadAsset(release, new ReleaseAssetUpload(destPath, "application/zip", file, null));
|
||||||
|
return asset.BrowserDownloadUrl;
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
//last time i tried, it mysteriously failed here but the file was uploaded :thinking:
|
||||||
|
Console.WriteLine($"!! Upload request for {destPath} failed, check it actually succeeded !! \n" + e.ToString());
|
||||||
|
return $"https://github.com/{Config.User}/{Config.Repository}/releases/download/{groupName}/{destPath}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
server/FSO.Server.Api.Core/Services/IUpdateUploader.cs
Executable file
9
server/FSO.Server.Api.Core/Services/IUpdateUploader.cs
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Services
|
||||||
|
{
|
||||||
|
public interface IUpdateUploader
|
||||||
|
{
|
||||||
|
Task<string> UploadFile(string destPath, string fileName, string groupName);
|
||||||
|
}
|
||||||
|
}
|
63
server/FSO.Server.Api.Core/Startup.cs
Executable file
63
server/FSO.Server.Api.Core/Startup.cs
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
using FSO.Server.Common;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core
|
||||||
|
{
|
||||||
|
public class Startup : IAPILifetime
|
||||||
|
{
|
||||||
|
public IApplicationLifetime AppLifetime;
|
||||||
|
|
||||||
|
public Startup(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
Configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddDefaultPolicy(
|
||||||
|
builder =>
|
||||||
|
{
|
||||||
|
|
||||||
|
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().WithExposedHeaders("content-disposition");
|
||||||
|
});
|
||||||
|
|
||||||
|
options.AddPolicy("AdminAppPolicy",
|
||||||
|
builder =>
|
||||||
|
{
|
||||||
|
builder.WithOrigins("https://freeso.org", "http://localhost:8080").AllowAnyMethod().AllowAnyHeader().AllowCredentials().WithExposedHeaders("content-disposition");
|
||||||
|
});
|
||||||
|
}).AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime)
|
||||||
|
{
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseDeveloperExceptionPage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
app.UseCors();
|
||||||
|
//app.UseHttpsRedirection();
|
||||||
|
app.UseMvc();
|
||||||
|
AppLifetime = appLifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
AppLifetime.StopApplication();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
server/FSO.Server.Api.Core/Utils/ApiMail.cs
Executable file
77
server/FSO.Server.Api.Core/Utils/ApiMail.cs
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Mail;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used to mail our users.
|
||||||
|
/// Could be more useful in the future when out of Beta.
|
||||||
|
/// </summary>
|
||||||
|
public class ApiMail
|
||||||
|
{
|
||||||
|
string subject;
|
||||||
|
string template;
|
||||||
|
Dictionary<string, string> strings;
|
||||||
|
|
||||||
|
public ApiMail(string template)
|
||||||
|
{
|
||||||
|
this.template = template;
|
||||||
|
this.strings = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddString(string key, string value)
|
||||||
|
{
|
||||||
|
strings.Add(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ComposeBody(Dictionary<string, string> strings)
|
||||||
|
{
|
||||||
|
string baseTemplate = File.ReadAllText("./MailTemplates/MailBase.html");
|
||||||
|
string content = File.ReadAllText("./MailTemplates/" + template + ".html");
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, string> entry in strings)
|
||||||
|
{
|
||||||
|
content = content.Replace("%" + entry.Key + "%", entry.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
strings = new Dictionary<string, string>();
|
||||||
|
return baseTemplate.Replace("%content%", content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Send(string to, string subject)
|
||||||
|
{
|
||||||
|
Api api = Api.INSTANCE;
|
||||||
|
|
||||||
|
if(api.Config.SmtpEnabled)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MailMessage message = new MailMessage();
|
||||||
|
message.From = new MailAddress(api.Config.SmtpUser, "FreeSO Staff");
|
||||||
|
message.To.Add(to);
|
||||||
|
message.Subject = subject;
|
||||||
|
message.IsBodyHtml = true;
|
||||||
|
message.Body = ComposeBody(strings);
|
||||||
|
|
||||||
|
SmtpClient client = new SmtpClient();
|
||||||
|
client.UseDefaultCredentials = true;
|
||||||
|
|
||||||
|
client.Host = api.Config.SmtpHost;
|
||||||
|
client.Port = api.Config.SmtpPort;
|
||||||
|
client.EnableSsl = true;
|
||||||
|
client.Credentials = new System.Net.NetworkCredential(api.Config.SmtpUser, api.Config.SmtpPassword);
|
||||||
|
|
||||||
|
// Send async
|
||||||
|
client.SendMailAsync(message);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch(Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
78
server/FSO.Server.Api.Core/Utils/ApiResponse.cs
Executable file
78
server/FSO.Server.Api.Core/Utils/ApiResponse.cs
Executable file
|
@ -0,0 +1,78 @@
|
||||||
|
using FSO.Common.Utils;
|
||||||
|
using FSO.Server.Database.DA.Utils;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Utils
|
||||||
|
{
|
||||||
|
public class ApiResponse
|
||||||
|
{
|
||||||
|
public static IActionResult Plain(HttpStatusCode code, string text)
|
||||||
|
{
|
||||||
|
return new ContentResult
|
||||||
|
{
|
||||||
|
StatusCode = (int)code,
|
||||||
|
Content = text,
|
||||||
|
ContentType = "text/plain"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IActionResult Json(HttpStatusCode code, object obj)
|
||||||
|
{
|
||||||
|
return new ContentResult
|
||||||
|
{
|
||||||
|
StatusCode = (int)code,
|
||||||
|
Content = Newtonsoft.Json.JsonConvert.SerializeObject(obj),
|
||||||
|
ContentType = "application/json"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IActionResult PagedList<T>(HttpRequest request, HttpStatusCode code, PagedList<T> list)
|
||||||
|
{
|
||||||
|
request.HttpContext.Response.Headers.Add("X-Total-Count", list.Total.ToString());
|
||||||
|
request.HttpContext.Response.Headers.Add("X-Offset", list.Offset.ToString());
|
||||||
|
|
||||||
|
return new ContentResult
|
||||||
|
{
|
||||||
|
StatusCode = (int)code,
|
||||||
|
Content = Newtonsoft.Json.JsonConvert.SerializeObject(list),
|
||||||
|
ContentType = "application/json"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IActionResult Xml(HttpStatusCode code, IXMLEntity xml)
|
||||||
|
{
|
||||||
|
var doc = new XmlDocument();
|
||||||
|
var firstChild = xml.Serialize(doc);
|
||||||
|
doc.AppendChild(firstChild);
|
||||||
|
|
||||||
|
return new ContentResult
|
||||||
|
{
|
||||||
|
StatusCode = (int)code,
|
||||||
|
Content = doc.OuterXml,
|
||||||
|
ContentType = "text/xml"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Func<IActionResult> XmlFuture(HttpStatusCode code, IXMLEntity xml)
|
||||||
|
{
|
||||||
|
var doc = new XmlDocument();
|
||||||
|
var firstChild = xml.Serialize(doc);
|
||||||
|
doc.AppendChild(firstChild);
|
||||||
|
var serialized = doc.OuterXml;
|
||||||
|
|
||||||
|
return () =>
|
||||||
|
{
|
||||||
|
return new ContentResult
|
||||||
|
{
|
||||||
|
StatusCode = (int)code,
|
||||||
|
Content = serialized,
|
||||||
|
ContentType = "text/xml"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
server/FSO.Server.Api.Core/Utils/ApiUtils.cs
Executable file
35
server/FSO.Server.Api.Core/Utils/ApiUtils.cs
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace FSO.Server.Api.Core.Utils
|
||||||
|
{
|
||||||
|
public class ApiUtils
|
||||||
|
{
|
||||||
|
private const string HttpContext = "MS_HttpContext";
|
||||||
|
private const string RemoteEndpointMessage =
|
||||||
|
"System.ServiceModel.Channels.RemoteEndpointMessageProperty";
|
||||||
|
private const string OwinContext = "MS_OwinContext";
|
||||||
|
|
||||||
|
public static string GetIP(HttpRequest request)
|
||||||
|
{
|
||||||
|
var api = FSO.Server.Api.Core.Api.INSTANCE;
|
||||||
|
if (!api.Config.UseProxy)
|
||||||
|
{
|
||||||
|
return request.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var ip = "127.0.0.1";
|
||||||
|
var xff = request.Headers["X-Forwarded-For"];
|
||||||
|
if (xff.Count != 0)
|
||||||
|
{
|
||||||
|
ip = xff.First();
|
||||||
|
ip = ip.Substring(ip.IndexOf(",") + 1);
|
||||||
|
var last = ip.LastIndexOf(":");
|
||||||
|
if (last != -1 && last < ip.Length - 5) ip = ip.Substring(0, last);
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
server/FSO.Server.Api.Core/appsettings.Development.json
Executable file
9
server/FSO.Server.Api.Core/appsettings.Development.json
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug",
|
||||||
|
"System": "Information",
|
||||||
|
"Microsoft": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
server/FSO.Server.Api.Core/appsettings.json
Executable file
8
server/FSO.Server.Api.Core/appsettings.json
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v2.2", FrameworkDisplayName = ".NET Core 2.2")]
|
|
@ -0,0 +1,22 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: System.Reflection.AssemblyCompanyAttribute("FSO.Server.Api.Core")]
|
||||||
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f12ba1502b1a207b2b7e131c8ed38d8d4ef33d1e")]
|
||||||
|
[assembly: System.Reflection.AssemblyProductAttribute("FSO.Server.Api.Core")]
|
||||||
|
[assembly: System.Reflection.AssemblyTitleAttribute("FSO.Server.Api.Core")]
|
||||||
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
|
// Generated by the MSBuild WriteCodeFragment class.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
56295aa1e4d64bef744bb30e9641d816d4a2f240e548daea26ca3acc11acdbfc
|
|
@ -0,0 +1,5 @@
|
||||||
|
is_global = true
|
||||||
|
build_property.RootNamespace = FSO.Server.Api.Core
|
||||||
|
build_property.ProjectDir = /Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/
|
||||||
|
build_property.EnableComHosting =
|
||||||
|
build_property.EnableGeneratedComInterfaceComImportInterop =
|
|
@ -0,0 +1 @@
|
||||||
|
96ad7024ec164a21bac08e2efe1079153c67c90031478db2e40a71ebb48e40d6
|
|
@ -0,0 +1,19 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("FSO.Server.Api.Core.Views")]
|
||||||
|
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")]
|
||||||
|
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")]
|
||||||
|
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")]
|
||||||
|
|
||||||
|
// Generated by the MSBuild WriteCodeFragment class.
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,267 @@
|
||||||
|
{
|
||||||
|
"format": 1,
|
||||||
|
"restore": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj": {}
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj",
|
||||||
|
"projectName": "FSO.Server.Api.Core",
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj",
|
||||||
|
"packagesPath": "/Volumes/TheD/.nuget",
|
||||||
|
"outputPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/obj/",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/Users/tonytins/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"netcoreapp2.2"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"/Volumes/TheD/.dotnet/library-packs": {},
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp2.2": {
|
||||||
|
"targetAlias": "netcoreapp2.2",
|
||||||
|
"projectReferences": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Domain/FSO.Server.Domain.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Domain/FSO.Server.Domain.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"warningProperties": {
|
||||||
|
"warnAsError": [
|
||||||
|
"NU1605"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"restoreAuditProperties": {
|
||||||
|
"enableAudit": "true",
|
||||||
|
"auditLevel": "low",
|
||||||
|
"auditMode": "direct"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp2.2": {
|
||||||
|
"targetAlias": "netcoreapp2.2",
|
||||||
|
"dependencies": {
|
||||||
|
"AWSSDK.Core": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[3.3.103.48, )"
|
||||||
|
},
|
||||||
|
"AWSSDK.S3": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[3.3.104.36, )"
|
||||||
|
},
|
||||||
|
"Microsoft.AspNetCore.All": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[2.2.7, )"
|
||||||
|
},
|
||||||
|
"Microsoft.AspNetCore.App": {
|
||||||
|
"suppressParent": "All",
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[2.2.8, )",
|
||||||
|
"autoReferenced": true
|
||||||
|
},
|
||||||
|
"Microsoft.AspNetCore.Cors": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[2.2.0, )"
|
||||||
|
},
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"suppressParent": "All",
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[2.2.8, )",
|
||||||
|
"autoReferenced": true
|
||||||
|
},
|
||||||
|
"Octokit": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[0.36.0, )"
|
||||||
|
},
|
||||||
|
"System.Security.Cryptography.Algorithms": {
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[4.3.1, )"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48",
|
||||||
|
"net481"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"runtimeIdentifierGraphPath": "/Volumes/TheD/.dotnet/sdk/8.0.204/RuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj": {
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj",
|
||||||
|
"projectName": "FSO.Server.Common",
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj",
|
||||||
|
"packagesPath": "/Volumes/TheD/.nuget",
|
||||||
|
"projectStyle": "PackagesConfig",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/Users/tonytins/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {
|
||||||
|
"projectReferences": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"packagesConfigPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/packages.config"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj": {
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj",
|
||||||
|
"projectName": "FSO.Server.Database",
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj",
|
||||||
|
"packagesPath": "/Volumes/TheD/.nuget",
|
||||||
|
"projectStyle": "PackagesConfig",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/Users/tonytins/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {
|
||||||
|
"projectReferences": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"packagesConfigPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/packages.config"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Domain/FSO.Server.Domain.csproj": {
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Domain/FSO.Server.Domain.csproj",
|
||||||
|
"projectName": "FSO.Server.Domain",
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Domain/FSO.Server.Domain.csproj",
|
||||||
|
"packagesPath": "/Volumes/TheD/.nuget",
|
||||||
|
"projectStyle": "PackagesConfig",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/Users/tonytins/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {
|
||||||
|
"projectReferences": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Database/FSO.Server.Database.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"packagesConfigPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Domain/packages.config"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj": {
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj",
|
||||||
|
"projectName": "FSO.Server.Protocol",
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj",
|
||||||
|
"packagesPath": "/Volumes/TheD/.nuget",
|
||||||
|
"projectStyle": "PackagesConfig",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/Users/tonytins/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {
|
||||||
|
"projectReferences": {
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Common/FSO.Server.Common.csproj"
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj": {
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"packagesConfigPath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Protocol/packages.config"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj": {
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj",
|
||||||
|
"projectName": "FSO.Common",
|
||||||
|
"projectPath": "/Volumes/TheD/Projects/ztso/server/tso.common/FSO.Common.csproj",
|
||||||
|
"packagesPath": "/Volumes/TheD/.nuget",
|
||||||
|
"projectStyle": "PackagesConfig",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/Users/tonytins/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"packagesConfigPath": "/Volumes/TheD/Projects/ztso/server/tso.common/packages.config"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net45": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||||
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Volumes/TheD/.nuget</NuGetPackageRoot>
|
||||||
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Volumes/TheD/.nuget</NuGetPackageFolders>
|
||||||
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.9.1</NuGetToolVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<SourceRoot Include="/Volumes/TheD/.nuget/" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.netcore.app/2.2.8/build/netcoreapp2.2/Microsoft.NETCore.App.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.netcore.app/2.2.8/build/netcoreapp2.2/Microsoft.NETCore.App.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.extensions.fileproviders.embedded/2.2.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.extensions.fileproviders.embedded/2.2.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.extensions.configuration.usersecrets/2.2.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.extensions.configuration.usersecrets/2.2.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.entityframeworkcore.design/2.2.6/build/netcoreapp2.0/Microsoft.EntityFrameworkCore.Design.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.entityframeworkcore.design/2.2.6/build/netcoreapp2.0/Microsoft.EntityFrameworkCore.Design.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.mvc.razor.extensions/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.mvc.razor.extensions/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.razor.design/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.razor.design/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.app/2.2.8/build/netcoreapp2.2/Microsoft.AspNetCore.App.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.app/2.2.8/build/netcoreapp2.2/Microsoft.AspNetCore.App.props')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.all/2.2.7/build/netcoreapp2.2/Microsoft.AspNetCore.All.props" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.all/2.2.7/build/netcoreapp2.2/Microsoft.AspNetCore.All.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<PkgMicrosoft_EntityFrameworkCore_Tools Condition=" '$(PkgMicrosoft_EntityFrameworkCore_Tools)' == '' ">/Volumes/TheD/.nuget/microsoft.entityframeworkcore.tools/2.2.6</PkgMicrosoft_EntityFrameworkCore_Tools>
|
||||||
|
<PkgMicrosoft_CodeAnalysis_Analyzers Condition=" '$(PkgMicrosoft_CodeAnalysis_Analyzers)' == '' ">/Volumes/TheD/.nuget/microsoft.codeanalysis.analyzers/1.1.0</PkgMicrosoft_CodeAnalysis_Analyzers>
|
||||||
|
<PkgMicrosoft_AspNetCore_Razor_Design Condition=" '$(PkgMicrosoft_AspNetCore_Razor_Design)' == '' ">/Volumes/TheD/.nuget/microsoft.aspnetcore.razor.design/2.2.0</PkgMicrosoft_AspNetCore_Razor_Design>
|
||||||
|
<PkgAWSSDK_Core Condition=" '$(PkgAWSSDK_Core)' == '' ">/Volumes/TheD/.nuget/awssdk.core/3.3.103.48</PkgAWSSDK_Core>
|
||||||
|
<PkgAWSSDK_S3 Condition=" '$(PkgAWSSDK_S3)' == '' ">/Volumes/TheD/.nuget/awssdk.s3/3.3.104.36</PkgAWSSDK_S3>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<Import Project="$(NuGetPackageRoot)/netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)/netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.netcore.app/2.2.8/build/netcoreapp2.2/Microsoft.NETCore.App.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.netcore.app/2.2.8/build/netcoreapp2.2/Microsoft.NETCore.App.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.extensions.fileproviders.embedded/2.2.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.extensions.fileproviders.embedded/2.2.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.extensions.configuration.usersecrets/2.2.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.extensions.configuration.usersecrets/2.2.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.mvc.razor.extensions/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.mvc.razor.extensions/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.server.iisintegration/2.2.1/build/netstandard2.0/Microsoft.AspNetCore.Server.IISIntegration.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.server.iisintegration/2.2.1/build/netstandard2.0/Microsoft.AspNetCore.Server.IISIntegration.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.server.iis/2.2.6/build/netstandard2.0/Microsoft.AspNetCore.Server.IIS.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.server.iis/2.2.6/build/netstandard2.0/Microsoft.AspNetCore.Server.IIS.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.mvc.razor.viewcompilation/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.mvc.razor.viewcompilation/2.2.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.app/2.2.8/build/netcoreapp2.2/Microsoft.AspNetCore.App.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.app/2.2.8/build/netcoreapp2.2/Microsoft.AspNetCore.App.targets')" />
|
||||||
|
<Import Project="$(NuGetPackageRoot)/microsoft.aspnetcore.all/2.2.7/build/netcoreapp2.2/Microsoft.AspNetCore.All.targets" Condition="Exists('$(NuGetPackageRoot)/microsoft.aspnetcore.all/2.2.7/build/netcoreapp2.2/Microsoft.AspNetCore.All.targets')" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
16011
server/FSO.Server.Api.Core/obj/project.assets.json
Normal file
16011
server/FSO.Server.Api.Core/obj/project.assets.json
Normal file
File diff suppressed because it is too large
Load diff
343
server/FSO.Server.Api.Core/obj/project.nuget.cache
Normal file
343
server/FSO.Server.Api.Core/obj/project.nuget.cache
Normal file
|
@ -0,0 +1,343 @@
|
||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"dgSpecHash": "O9uTcc8ul7R5Oy7wU0RviTvK+nfjiri5q/zad3hfpvfdHyjPko5E7PeIbBSDiQiPyuONvNRmcuzEhHPbXoSo6Q==",
|
||||||
|
"success": true,
|
||||||
|
"projectFilePath": "/Volumes/TheD/Projects/ztso/server/FSO.Server.Api.Core/FSO.Server.Api.Core.csproj",
|
||||||
|
"expectedPackageFiles": [
|
||||||
|
"/Volumes/TheD/.nuget/awssdk.core/3.3.103.48/awssdk.core.3.3.103.48.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/awssdk.s3/3.3.104.36/awssdk.s3.3.3.104.36.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/libuv/1.10.0/libuv.1.10.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/messagepack/1.7.3.7/messagepack.1.7.3.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.applicationinsights/2.4.0/microsoft.applicationinsights.2.4.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.applicationinsights.aspnetcore/2.1.1/microsoft.applicationinsights.aspnetcore.2.1.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.applicationinsights.dependencycollector/2.4.1/microsoft.applicationinsights.dependencycollector.2.4.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnet.webapi.client/5.2.6/microsoft.aspnet.webapi.client.5.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore/2.2.0/microsoft.aspnetcore.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.all/2.2.7/microsoft.aspnetcore.all.2.2.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.antiforgery/2.2.0/microsoft.aspnetcore.antiforgery.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.app/2.2.8/microsoft.aspnetcore.app.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.applicationinsights.hostingstartup/2.2.0/microsoft.aspnetcore.applicationinsights.hostingstartup.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication/2.2.0/microsoft.aspnetcore.authentication.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.abstractions/2.2.0/microsoft.aspnetcore.authentication.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.cookies/2.2.0/microsoft.aspnetcore.authentication.cookies.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.core/2.2.0/microsoft.aspnetcore.authentication.core.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.facebook/2.2.0/microsoft.aspnetcore.authentication.facebook.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.google/2.2.2/microsoft.aspnetcore.authentication.google.2.2.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.jwtbearer/2.2.0/microsoft.aspnetcore.authentication.jwtbearer.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.microsoftaccount/2.2.0/microsoft.aspnetcore.authentication.microsoftaccount.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.oauth/2.2.0/microsoft.aspnetcore.authentication.oauth.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.openidconnect/2.2.0/microsoft.aspnetcore.authentication.openidconnect.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.twitter/2.2.0/microsoft.aspnetcore.authentication.twitter.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authentication.wsfederation/2.2.0/microsoft.aspnetcore.authentication.wsfederation.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authorization/2.2.0/microsoft.aspnetcore.authorization.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.authorization.policy/2.2.0/microsoft.aspnetcore.authorization.policy.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.azureappservices.hostingstartup/2.2.5/microsoft.aspnetcore.azureappservices.hostingstartup.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.azureappservicesintegration/2.2.5/microsoft.aspnetcore.azureappservicesintegration.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.connections.abstractions/2.2.0/microsoft.aspnetcore.connections.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.cookiepolicy/2.2.8/microsoft.aspnetcore.cookiepolicy.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.cors/2.2.0/microsoft.aspnetcore.cors.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.cryptography.internal/2.2.0/microsoft.aspnetcore.cryptography.internal.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.cryptography.keyderivation/2.2.0/microsoft.aspnetcore.cryptography.keyderivation.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.dataprotection/2.2.0/microsoft.aspnetcore.dataprotection.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.dataprotection.abstractions/2.2.0/microsoft.aspnetcore.dataprotection.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.dataprotection.azurekeyvault/2.2.0/microsoft.aspnetcore.dataprotection.azurekeyvault.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.dataprotection.azurestorage/2.2.7/microsoft.aspnetcore.dataprotection.azurestorage.2.2.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.dataprotection.extensions/2.2.0/microsoft.aspnetcore.dataprotection.extensions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.diagnostics/2.2.0/microsoft.aspnetcore.diagnostics.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.diagnostics.abstractions/2.2.0/microsoft.aspnetcore.diagnostics.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.diagnostics.entityframeworkcore/2.2.1/microsoft.aspnetcore.diagnostics.entityframeworkcore.2.2.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.diagnostics.healthchecks/2.2.0/microsoft.aspnetcore.diagnostics.healthchecks.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.hostfiltering/2.2.0/microsoft.aspnetcore.hostfiltering.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.hosting/2.2.7/microsoft.aspnetcore.hosting.2.2.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.hosting.abstractions/2.2.0/microsoft.aspnetcore.hosting.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.hosting.server.abstractions/2.2.0/microsoft.aspnetcore.hosting.server.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.html.abstractions/2.2.0/microsoft.aspnetcore.html.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.http/2.2.2/microsoft.aspnetcore.http.2.2.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.http.abstractions/2.2.0/microsoft.aspnetcore.http.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.http.connections/1.1.0/microsoft.aspnetcore.http.connections.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.http.connections.common/1.1.0/microsoft.aspnetcore.http.connections.common.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.http.extensions/2.2.0/microsoft.aspnetcore.http.extensions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.http.features/2.2.0/microsoft.aspnetcore.http.features.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.httpoverrides/2.2.0/microsoft.aspnetcore.httpoverrides.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.httpspolicy/2.2.0/microsoft.aspnetcore.httpspolicy.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.identity/2.2.0/microsoft.aspnetcore.identity.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.identity.entityframeworkcore/2.2.0/microsoft.aspnetcore.identity.entityframeworkcore.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.identity.ui/2.2.5/microsoft.aspnetcore.identity.ui.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.jsonpatch/2.2.0/microsoft.aspnetcore.jsonpatch.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.localization/2.2.0/microsoft.aspnetcore.localization.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.localization.routing/2.2.0/microsoft.aspnetcore.localization.routing.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.middlewareanalysis/2.2.0/microsoft.aspnetcore.middlewareanalysis.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc/2.2.0/microsoft.aspnetcore.mvc.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.abstractions/2.2.0/microsoft.aspnetcore.mvc.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.analyzers/2.2.0/microsoft.aspnetcore.mvc.analyzers.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.apiexplorer/2.2.0/microsoft.aspnetcore.mvc.apiexplorer.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.core/2.2.5/microsoft.aspnetcore.mvc.core.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.cors/2.2.0/microsoft.aspnetcore.mvc.cors.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.dataannotations/2.2.0/microsoft.aspnetcore.mvc.dataannotations.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.formatters.json/2.2.0/microsoft.aspnetcore.mvc.formatters.json.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.formatters.xml/2.2.0/microsoft.aspnetcore.mvc.formatters.xml.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.localization/2.2.0/microsoft.aspnetcore.mvc.localization.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.razor/2.2.0/microsoft.aspnetcore.mvc.razor.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.razor.extensions/2.2.0/microsoft.aspnetcore.mvc.razor.extensions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.razor.viewcompilation/2.2.0/microsoft.aspnetcore.mvc.razor.viewcompilation.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.razorpages/2.2.5/microsoft.aspnetcore.mvc.razorpages.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.taghelpers/2.2.0/microsoft.aspnetcore.mvc.taghelpers.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.mvc.viewfeatures/2.2.0/microsoft.aspnetcore.mvc.viewfeatures.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.nodeservices/2.2.0/microsoft.aspnetcore.nodeservices.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.owin/2.2.0/microsoft.aspnetcore.owin.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.razor/2.2.0/microsoft.aspnetcore.razor.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.razor.design/2.2.0/microsoft.aspnetcore.razor.design.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.razor.language/2.2.0/microsoft.aspnetcore.razor.language.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.razor.runtime/2.2.0/microsoft.aspnetcore.razor.runtime.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.responsecaching/2.2.0/microsoft.aspnetcore.responsecaching.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.responsecaching.abstractions/2.2.0/microsoft.aspnetcore.responsecaching.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.responsecompression/2.2.0/microsoft.aspnetcore.responsecompression.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.rewrite/2.2.0/microsoft.aspnetcore.rewrite.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.routing/2.2.2/microsoft.aspnetcore.routing.2.2.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.routing.abstractions/2.2.0/microsoft.aspnetcore.routing.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.httpsys/2.2.6/microsoft.aspnetcore.server.httpsys.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.iis/2.2.6/microsoft.aspnetcore.server.iis.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.iisintegration/2.2.1/microsoft.aspnetcore.server.iisintegration.2.2.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.kestrel/2.2.0/microsoft.aspnetcore.server.kestrel.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.kestrel.core/2.2.0/microsoft.aspnetcore.server.kestrel.core.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.kestrel.https/2.2.0/microsoft.aspnetcore.server.kestrel.https.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.kestrel.transport.abstractions/2.2.0/microsoft.aspnetcore.server.kestrel.transport.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.kestrel.transport.libuv/2.2.0/microsoft.aspnetcore.server.kestrel.transport.libuv.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.server.kestrel.transport.sockets/2.2.1/microsoft.aspnetcore.server.kestrel.transport.sockets.2.2.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.session/2.2.0/microsoft.aspnetcore.session.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.signalr/1.1.0/microsoft.aspnetcore.signalr.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.signalr.common/1.1.0/microsoft.aspnetcore.signalr.common.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.signalr.core/1.1.0/microsoft.aspnetcore.signalr.core.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.signalr.protocols.json/1.1.0/microsoft.aspnetcore.signalr.protocols.json.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.signalr.redis/1.1.5/microsoft.aspnetcore.signalr.redis.1.1.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.spaservices/2.2.7/microsoft.aspnetcore.spaservices.2.2.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.spaservices.extensions/2.2.0/microsoft.aspnetcore.spaservices.extensions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.staticfiles/2.2.0/microsoft.aspnetcore.staticfiles.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.websockets/2.2.1/microsoft.aspnetcore.websockets.2.2.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.aspnetcore.webutilities/2.2.0/microsoft.aspnetcore.webutilities.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.azure.keyvault/2.3.2/microsoft.azure.keyvault.2.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.azure.keyvault.webkey/2.0.7/microsoft.azure.keyvault.webkey.2.0.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.azure.services.appauthentication/1.0.1/microsoft.azure.services.appauthentication.1.0.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.codeanalysis.analyzers/1.1.0/microsoft.codeanalysis.analyzers.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.codeanalysis.common/2.8.0/microsoft.codeanalysis.common.2.8.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.codeanalysis.csharp/2.8.0/microsoft.codeanalysis.csharp.2.8.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.codeanalysis.razor/2.2.0/microsoft.codeanalysis.razor.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.csharp/4.5.0/microsoft.csharp.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.data.edm/5.8.4/microsoft.data.edm.5.8.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.data.odata/5.8.4/microsoft.data.odata.5.8.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.data.sqlite/2.2.6/microsoft.data.sqlite.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.data.sqlite.core/2.2.6/microsoft.data.sqlite.core.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.dotnet.platformabstractions/2.1.0/microsoft.dotnet.platformabstractions.2.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore/2.2.6/microsoft.entityframeworkcore.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.abstractions/2.2.6/microsoft.entityframeworkcore.abstractions.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.analyzers/2.2.6/microsoft.entityframeworkcore.analyzers.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.design/2.2.6/microsoft.entityframeworkcore.design.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.inmemory/2.2.6/microsoft.entityframeworkcore.inmemory.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.relational/2.2.6/microsoft.entityframeworkcore.relational.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.sqlite/2.2.6/microsoft.entityframeworkcore.sqlite.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.sqlite.core/2.2.6/microsoft.entityframeworkcore.sqlite.core.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.sqlserver/2.2.6/microsoft.entityframeworkcore.sqlserver.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.entityframeworkcore.tools/2.2.6/microsoft.entityframeworkcore.tools.2.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.caching.abstractions/2.2.0/microsoft.extensions.caching.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.caching.memory/2.2.0/microsoft.extensions.caching.memory.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.caching.redis/2.2.0/microsoft.extensions.caching.redis.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.caching.sqlserver/2.2.0/microsoft.extensions.caching.sqlserver.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration/2.2.0/microsoft.extensions.configuration.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.abstractions/2.2.0/microsoft.extensions.configuration.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.azurekeyvault/2.2.0/microsoft.extensions.configuration.azurekeyvault.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.binder/2.2.4/microsoft.extensions.configuration.binder.2.2.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.commandline/2.2.0/microsoft.extensions.configuration.commandline.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.environmentvariables/2.2.4/microsoft.extensions.configuration.environmentvariables.2.2.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.fileextensions/2.2.0/microsoft.extensions.configuration.fileextensions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.ini/2.2.0/microsoft.extensions.configuration.ini.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.json/2.2.0/microsoft.extensions.configuration.json.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.keyperfile/2.2.4/microsoft.extensions.configuration.keyperfile.2.2.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.usersecrets/2.2.0/microsoft.extensions.configuration.usersecrets.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.configuration.xml/2.2.0/microsoft.extensions.configuration.xml.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.dependencyinjection/2.2.0/microsoft.extensions.dependencyinjection.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.dependencyinjection.abstractions/2.2.0/microsoft.extensions.dependencyinjection.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.dependencymodel/2.1.0/microsoft.extensions.dependencymodel.2.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.diagnosticadapter/2.2.0/microsoft.extensions.diagnosticadapter.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.diagnostics.healthchecks/2.2.5/microsoft.extensions.diagnostics.healthchecks.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.diagnostics.healthchecks.abstractions/2.2.0/microsoft.extensions.diagnostics.healthchecks.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.fileproviders.abstractions/2.2.0/microsoft.extensions.fileproviders.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.fileproviders.composite/2.2.0/microsoft.extensions.fileproviders.composite.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.fileproviders.embedded/2.2.0/microsoft.extensions.fileproviders.embedded.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.fileproviders.physical/2.2.0/microsoft.extensions.fileproviders.physical.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.filesystemglobbing/2.2.0/microsoft.extensions.filesystemglobbing.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.hosting/2.2.0/microsoft.extensions.hosting.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.hosting.abstractions/2.2.0/microsoft.extensions.hosting.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.http/2.2.0/microsoft.extensions.http.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.identity.core/2.2.0/microsoft.extensions.identity.core.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.identity.stores/2.2.0/microsoft.extensions.identity.stores.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.localization/2.2.0/microsoft.extensions.localization.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.localization.abstractions/2.2.0/microsoft.extensions.localization.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging/2.2.0/microsoft.extensions.logging.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.abstractions/2.2.0/microsoft.extensions.logging.abstractions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.azureappservices/2.2.5/microsoft.extensions.logging.azureappservices.2.2.5.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.configuration/2.2.0/microsoft.extensions.logging.configuration.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.console/2.2.0/microsoft.extensions.logging.console.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.debug/2.2.0/microsoft.extensions.logging.debug.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.eventsource/2.2.0/microsoft.extensions.logging.eventsource.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.logging.tracesource/2.2.0/microsoft.extensions.logging.tracesource.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.objectpool/2.2.0/microsoft.extensions.objectpool.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.options/2.2.0/microsoft.extensions.options.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.options.configurationextensions/2.2.0/microsoft.extensions.options.configurationextensions.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.options.dataannotations/2.2.0/microsoft.extensions.options.dataannotations.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.platformabstractions/1.1.0/microsoft.extensions.platformabstractions.1.1.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.primitives/2.2.0/microsoft.extensions.primitives.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.extensions.webencoders/2.2.0/microsoft.extensions.webencoders.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.clients.activedirectory/3.19.8/microsoft.identitymodel.clients.activedirectory.3.19.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.jsonwebtokens/5.3.0/microsoft.identitymodel.jsonwebtokens.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.logging/5.3.0/microsoft.identitymodel.logging.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.protocols/5.3.0/microsoft.identitymodel.protocols.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.protocols.openidconnect/5.3.0/microsoft.identitymodel.protocols.openidconnect.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.protocols.wsfederation/5.3.0/microsoft.identitymodel.protocols.wsfederation.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.tokens/5.3.0/microsoft.identitymodel.tokens.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.tokens.saml/5.3.0/microsoft.identitymodel.tokens.saml.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.identitymodel.xml/5.3.0/microsoft.identitymodel.xml.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.net.http.headers/2.2.8/microsoft.net.http.headers.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.netcore.app/2.2.8/microsoft.netcore.app.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.netcore.dotnetapphost/2.2.8/microsoft.netcore.dotnetapphost.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.netcore.dotnethostpolicy/2.2.8/microsoft.netcore.dotnethostpolicy.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.netcore.dotnethostresolver/2.2.8/microsoft.netcore.dotnethostresolver.2.2.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.netcore.platforms/2.2.4/microsoft.netcore.platforms.2.2.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.netcore.targets/2.0.0/microsoft.netcore.targets.2.0.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.rest.clientruntime/2.3.8/microsoft.rest.clientruntime.2.3.8.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.rest.clientruntime.azure/3.3.7/microsoft.rest.clientruntime.azure.3.3.7.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.visualstudio.web.browserlink/2.2.0/microsoft.visualstudio.web.browserlink.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.win32.primitives/4.3.0/microsoft.win32.primitives.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/microsoft.win32.registry/4.5.0/microsoft.win32.registry.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/netstandard.library/2.0.3/netstandard.library.2.0.3.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/newtonsoft.json/11.0.2/newtonsoft.json.11.0.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/newtonsoft.json.bson/1.0.1/newtonsoft.json.bson.1.0.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/octokit/0.36.0/octokit.0.36.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/remotion.linq/2.2.0/remotion.linq.2.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.debian.8-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.debian.8-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.fedora.23-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.fedora.23-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.fedora.24-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.fedora.24-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system/4.3.0/runtime.native.system.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system.data.sqlclient.sni/4.5.0/runtime.native.system.data.sqlclient.sni.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system.io.compression/4.3.0/runtime.native.system.io.compression.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system.net.http/4.3.0/runtime.native.system.net.http.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system.net.security/4.3.0/runtime.native.system.net.security.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system.security.cryptography.apple/4.3.1/runtime.native.system.security.cryptography.apple.4.3.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.native.system.security.cryptography.openssl/4.3.2/runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.opensuse.13.2-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.opensuse.13.2-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.opensuse.42.1-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.opensuse.42.1-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.osx.10.10-x64.runtime.native.system.security.cryptography.apple/4.3.1/runtime.osx.10.10-x64.runtime.native.system.security.cryptography.apple.4.3.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.osx.10.10-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.osx.10.10-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.rhel.7-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.rhel.7-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.ubuntu.14.04-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.ubuntu.14.04-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.ubuntu.16.04-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.ubuntu.16.04-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl/4.3.2/runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.win-arm64.runtime.native.system.data.sqlclient.sni/4.4.0/runtime.win-arm64.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.win-x64.runtime.native.system.data.sqlclient.sni/4.4.0/runtime.win-x64.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/runtime.win-x86.runtime.native.system.data.sqlclient.sni/4.4.0/runtime.win-x86.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/sqlitepclraw.bundle_green/1.1.12/sqlitepclraw.bundle_green.1.1.12.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/sqlitepclraw.core/1.1.12/sqlitepclraw.core.1.1.12.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/sqlitepclraw.lib.e_sqlite3.linux/1.1.12/sqlitepclraw.lib.e_sqlite3.linux.1.1.12.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/sqlitepclraw.lib.e_sqlite3.osx/1.1.12/sqlitepclraw.lib.e_sqlite3.osx.1.1.12.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/sqlitepclraw.lib.e_sqlite3.v110_xp/1.1.12/sqlitepclraw.lib.e_sqlite3.v110_xp.1.1.12.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/sqlitepclraw.provider.e_sqlite3.netstandard11/1.1.12/sqlitepclraw.provider.e_sqlite3.netstandard11.1.1.12.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/stackexchange.redis.strongname/1.2.6/stackexchange.redis.strongname.1.2.6.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.appcontext/4.3.0/system.appcontext.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.buffers/4.5.0/system.buffers.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.collections/4.3.0/system.collections.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.collections.concurrent/4.3.0/system.collections.concurrent.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.collections.immutable/1.5.0/system.collections.immutable.1.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.collections.nongeneric/4.3.0/system.collections.nongeneric.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.collections.specialized/4.3.0/system.collections.specialized.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.componentmodel.annotations/4.5.0/system.componentmodel.annotations.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.console/4.3.0/system.console.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.data.sqlclient/4.6.1/system.data.sqlclient.4.6.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.contracts/4.3.0/system.diagnostics.contracts.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.debug/4.3.0/system.diagnostics.debug.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.diagnosticsource/4.5.1/system.diagnostics.diagnosticsource.4.5.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.fileversioninfo/4.3.0/system.diagnostics.fileversioninfo.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.process/4.3.0/system.diagnostics.process.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.stacktrace/4.3.0/system.diagnostics.stacktrace.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.tools/4.3.0/system.diagnostics.tools.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.diagnostics.tracing/4.3.0/system.diagnostics.tracing.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.dynamic.runtime/4.3.0/system.dynamic.runtime.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.globalization/4.3.0/system.globalization.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.globalization.calendars/4.3.0/system.globalization.calendars.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.globalization.extensions/4.3.0/system.globalization.extensions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.identitymodel.tokens.jwt/5.3.0/system.identitymodel.tokens.jwt.5.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.interactive.async/3.2.0/system.interactive.async.3.2.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.io/4.3.0/system.io.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.io.compression/4.3.0/system.io.compression.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.io.filesystem/4.3.0/system.io.filesystem.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.io.filesystem.primitives/4.3.0/system.io.filesystem.primitives.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.io.pipelines/4.5.3/system.io.pipelines.4.5.3.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.linq/4.3.0/system.linq.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.linq.expressions/4.3.0/system.linq.expressions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.linq.queryable/4.0.1/system.linq.queryable.4.0.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.memory/4.5.1/system.memory.4.5.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.net.http/4.3.0/system.net.http.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.net.nameresolution/4.3.0/system.net.nameresolution.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.net.primitives/4.3.0/system.net.primitives.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.net.security/4.3.0/system.net.security.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.net.sockets/4.3.0/system.net.sockets.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.net.websockets.websocketprotocol/4.5.3/system.net.websockets.websocketprotocol.4.5.3.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.numerics.vectors/4.5.0/system.numerics.vectors.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.objectmodel/4.3.0/system.objectmodel.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.private.datacontractserialization/4.3.0/system.private.datacontractserialization.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection/4.3.0/system.reflection.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.emit/4.3.0/system.reflection.emit.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.emit.ilgeneration/4.3.0/system.reflection.emit.ilgeneration.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.emit.lightweight/4.3.0/system.reflection.emit.lightweight.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.extensions/4.3.0/system.reflection.extensions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.metadata/1.6.0/system.reflection.metadata.1.6.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.primitives/4.3.0/system.reflection.primitives.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.reflection.typeextensions/4.3.0/system.reflection.typeextensions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.resources.resourcemanager/4.3.0/system.resources.resourcemanager.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime/4.3.0/system.runtime.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.compilerservices.unsafe/4.5.1/system.runtime.compilerservices.unsafe.4.5.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.extensions/4.3.0/system.runtime.extensions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.handles/4.3.0/system.runtime.handles.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.interopservices/4.3.0/system.runtime.interopservices.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.interopservices.runtimeinformation/4.3.0/system.runtime.interopservices.runtimeinformation.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.numerics/4.3.0/system.runtime.numerics.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.serialization.json/4.3.0/system.runtime.serialization.json.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.serialization.primitives/4.3.0/system.runtime.serialization.primitives.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.runtime.serialization.xml/4.3.0/system.runtime.serialization.xml.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.accesscontrol/4.5.0/system.security.accesscontrol.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.claims/4.3.0/system.security.claims.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.algorithms/4.3.1/system.security.cryptography.algorithms.4.3.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.cng/4.5.0/system.security.cryptography.cng.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.csp/4.3.0/system.security.cryptography.csp.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.encoding/4.3.0/system.security.cryptography.encoding.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.openssl/4.3.0/system.security.cryptography.openssl.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.pkcs/4.5.0/system.security.cryptography.pkcs.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.primitives/4.3.0/system.security.cryptography.primitives.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.x509certificates/4.3.0/system.security.cryptography.x509certificates.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.cryptography.xml/4.5.0/system.security.cryptography.xml.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.permissions/4.5.0/system.security.permissions.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.principal/4.3.0/system.security.principal.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.security.principal.windows/4.5.0/system.security.principal.windows.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.spatial/5.8.4/system.spatial.5.8.4.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.text.encoding/4.3.0/system.text.encoding.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.text.encoding.codepages/4.5.0/system.text.encoding.codepages.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.text.encoding.extensions/4.3.0/system.text.encoding.extensions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.text.encodings.web/4.5.0/system.text.encodings.web.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.text.regularexpressions/4.3.0/system.text.regularexpressions.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading/4.3.0/system.threading.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.channels/4.5.0/system.threading.channels.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.tasks/4.3.0/system.threading.tasks.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.tasks.extensions/4.5.1/system.threading.tasks.extensions.4.5.1.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.tasks.parallel/4.3.0/system.threading.tasks.parallel.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.thread/4.3.0/system.threading.thread.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.threadpool/4.3.0/system.threading.threadpool.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.threading.timer/4.3.0/system.threading.timer.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.valuetuple/4.5.0/system.valuetuple.4.5.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.xml.readerwriter/4.3.0/system.xml.readerwriter.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.xml.xdocument/4.3.0/system.xml.xdocument.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.xml.xmldocument/4.3.0/system.xml.xmldocument.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.xml.xmlserializer/4.3.0/system.xml.xmlserializer.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.xml.xpath/4.3.0/system.xml.xpath.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/system.xml.xpath.xdocument/4.3.0/system.xml.xpath.xdocument.4.3.0.nupkg.sha512",
|
||||||
|
"/Volumes/TheD/.nuget/windowsazure.storage/8.1.4/windowsazure.storage.8.1.4.nupkg.sha512"
|
||||||
|
],
|
||||||
|
"logs": []
|
||||||
|
}
|
46
server/FSO.Server.Common/ApiAbstract.cs
Executable file
46
server/FSO.Server.Common/ApiAbstract.cs
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
namespace FSO.Server.Common
|
||||||
|
{
|
||||||
|
public class ApiAbstract
|
||||||
|
{
|
||||||
|
public event APIRequestShutdownDelegate OnRequestShutdown;
|
||||||
|
public event APIBroadcastMessageDelegate OnBroadcastMessage;
|
||||||
|
public event APIRequestUserDisconnectDelegate OnRequestUserDisconnect;
|
||||||
|
public event APIRequestMailNotifyDelegate OnRequestMailNotify;
|
||||||
|
|
||||||
|
public delegate void APIRequestShutdownDelegate(uint time, ShutdownType type);
|
||||||
|
public delegate void APIBroadcastMessageDelegate(string sender, string title, string message);
|
||||||
|
public delegate void APIRequestUserDisconnectDelegate(uint user_id);
|
||||||
|
public delegate void APIRequestMailNotifyDelegate(int message_id, string subject, string body, uint target_id);
|
||||||
|
|
||||||
|
public void RequestShutdown(uint time, ShutdownType type)
|
||||||
|
{
|
||||||
|
OnRequestShutdown?.Invoke(time, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asks the server to disconnect a user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user_id"></param>
|
||||||
|
public void RequestUserDisconnect(uint user_id)
|
||||||
|
{
|
||||||
|
OnRequestUserDisconnect?.Invoke(user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asks the server to notify the client about the new message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message_id"></param>
|
||||||
|
/// <param name="subject"></param>
|
||||||
|
/// <param name="body"></param>
|
||||||
|
/// <param name="target_id"></param>
|
||||||
|
public void RequestMailNotify(int message_id, string subject, string body, uint target_id)
|
||||||
|
{
|
||||||
|
OnRequestMailNotify(message_id, subject, body, target_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BroadcastMessage(string sender, string title, string message)
|
||||||
|
{
|
||||||
|
OnBroadcastMessage?.Invoke(sender, title, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue