Changeset View
Changeset View
Standalone View
Standalone View
source/ps/GameSetup/GameConfig.h
- This file was added.
/* Copyright (C) 2019 Wildfire Games. | |||||
* This file is part of 0 A.D. | |||||
* | |||||
* 0 A.D. 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 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#ifndef INCLUDED_GAMECONFIG | |||||
#define INCLUDED_GAMECONFIG | |||||
#include <string> | |||||
#include <vector> | |||||
#include "ps/GameSetup/CmdLineArgs.h" | |||||
#include "scriptinterface/ScriptVal.h" | |||||
#include "scriptinterface/ScriptInterface.h" | |||||
#if WITH_RLINTERFACE | |||||
#include "rlinterface/proto/RLAPI.grpc.pb.h" | |||||
#endif | |||||
enum NetworkGameType { Host, Client, Local }; | |||||
struct GameConfig { | |||||
GameConfig(std::wstring t, std::wstring n) : | |||||
type(t), name(n), size(192), numPlayers(2), gameSpeed(1.0), seed(0), aiseed(0), | |||||
nonVisual(false), saveReplay(false), teams(std::vector<std::tuple<int, int>>()), ceasefire(0), | |||||
ai(std::vector<std::tuple<int, std::string>>()), | |||||
civs(std::vector<std::tuple<int, std::string>>()), | |||||
difficulties(std::vector<std::tuple<int, int>>()), | |||||
victoryConditions(std::vector<std::string>(1, "conquest")), | |||||
username(L"anonymous"), wonderDuration(10), relicDuration(10), relicCount(2), | |||||
playerID(1), netGameType(NetworkGameType::Local), maxPlayersToHost(2), | |||||
hostAddress("127.0.0.1") | |||||
{} | |||||
static GameConfig from (const CmdLineArgs& args); | |||||
#if WITH_RLINTERFACE | |||||
static GameConfig from (const ScenarioConfig& msg); | |||||
#endif | |||||
JS::MutableHandleValue toJSValue (const ScriptInterface& scriptInterface) const; | |||||
void setNetworkHost() | |||||
{ | |||||
netGameType = NetworkGameType::Host; | |||||
} | |||||
bool isNetworkHost() const | |||||
{ | |||||
return netGameType == NetworkGameType::Host; | |||||
} | |||||
void setNetworkClient() | |||||
{ | |||||
netGameType = NetworkGameType::Client; | |||||
} | |||||
bool isNetworkClient() const | |||||
{ | |||||
return netGameType == NetworkGameType::Client; | |||||
} | |||||
std::wstring getFullName() const | |||||
{ | |||||
return this->getMapDirectory() + L"/" + name; | |||||
} | |||||
std::wstring getMapDirectory() const | |||||
{ | |||||
if (type == L"scenario") | |||||
return L"scenarios"; | |||||
else if (type == L"skirmish") | |||||
return L"skirmishes"; | |||||
else | |||||
return type; | |||||
} | |||||
std::wstring type; | |||||
std::wstring name; | |||||
Stan: Any reason for this type and not u32/u16 ? | |||||
Done Inline ActionsNot particularly. I can update it. irishninja: Not particularly. I can update it. | |||||
std::wstring username; | |||||
int playerID; | |||||
uint size; | |||||
uint numPlayers; | |||||
Not Done Inline ActionsStill there :) Stan: Still there :) | |||||
float gameSpeed; | |||||
u32 seed; | |||||
u32 aiseed; | |||||
std::vector<std::tuple<int, int>> teams; | |||||
int ceasefire; | |||||
std::vector<std::tuple<int, std::string>> ai; | |||||
std::vector<std::tuple<int, int>> difficulties; | |||||
std::vector<std::tuple<int, std::string>> civs; | |||||
std::vector<std::string> victoryConditions; | |||||
int wonderDuration; | |||||
int relicDuration; | |||||
int relicCount; | |||||
size_t maxPlayersToHost; | |||||
NetworkGameType netGameType; | |||||
std::string hostAddress; | |||||
bool nonVisual; | |||||
bool saveReplay; | |||||
}; | |||||
#endif // INCLUDED_GAMECONFIG |
Wildfire Games · Phabricator
Any reason for this type and not u32/u16 ?