-
Notifications
You must be signed in to change notification settings - Fork 70
WIP: Remove hardcoded Unvanquished references #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
42d8efd
750fd46
f91acbf
bdb3c5b
c7c2299
7b30171
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| NAME GameName | ||
| VERSION 0.0 | ||
| DEFAULT_BASEPAK mybasepak | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After deep thoughts, this may be called We can also use it to compute I don't think it's a bad idea to enforce the basename is also the basepak name. It may also make easier to reimplement per-directory full-conversion downloadable mod like quake3 did, by using this BASENAME ( |
||
| MASTERSERVER1 master.example.net | ||
| MASTERSERVER2 master.template.net | ||
| WWW_BASEURL dl.example.net/pkg | ||
| GAMENAME_STRING abc | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| /* | ||
| =========================================================================== | ||
|
|
||
| Daemon GPL Source Code | ||
| Copyright (C) 2017, Daemon Developers | ||
|
|
||
| This file is part of the Daemon GPL Source Code (Daemon Source Code). | ||
|
|
||
| Daemon Source Code 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. | ||
|
|
||
| Daemon Source Code 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 Daemon Source Code. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| =========================================================================== | ||
| */ | ||
|
|
||
| #include <algorithm> | ||
| #include <string> | ||
|
|
||
| #include "gameinfo.h" | ||
| #include "common/FileSystem.h" | ||
|
|
||
|
|
||
| Gameinfo& Gameinfo::getInstance() | ||
| { | ||
| static Gameinfo instance; | ||
| return instance; | ||
| } | ||
|
|
||
| void Gameinfo::parse(std::string fname) | ||
| { | ||
| if (!FS::RawPath::FileExists(fname)) | ||
| { | ||
| Sys::Error("GAMEINFO: No gameinfo.conf found in libpath"); | ||
| } | ||
| FS::File f = FS::RawPath::OpenRead(fname); | ||
| std::string content = f.ReadAll(); | ||
| f.Close(); | ||
| Cmd::Args a(content); | ||
| if (a.Argc() & 1) | ||
| { | ||
| Sys::Error("GAMEINFO: Invalid gaminfo.conf"); | ||
| } | ||
| std::vector<std::string> argvec = a.ArgVector(); | ||
| for (int i = 0; i < argvec.size(); i += 2) | ||
| { | ||
| if(argvec[i] == "NAME") | ||
| { | ||
| _name = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "VERSION") | ||
| { | ||
| _version = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "DEFAULT_BASEPAK") | ||
| { | ||
| _default_basepak = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "MASTERSERVER1") | ||
| { | ||
| _masterserver1 = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "MASTERSERVER2") | ||
| { | ||
| _masterserver2 = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "MASTERSERVER3") | ||
| { | ||
| _masterserver3 = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "MASTERSERVER4") | ||
| { | ||
| _masterserver4 = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "MASTERSERVER5") | ||
| { | ||
| _masterserver5 = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "WWW_BASEURL") | ||
| { | ||
| _www_baseurl = argvec[i+1]; | ||
| } | ||
| else if(argvec[i] == "GAMENAME_STRING") | ||
| { | ||
| _gamename_string = argvec[i+1]; | ||
| } | ||
| else | ||
| { | ||
| Log::Warn("GAMEINFO: Unrecognized field '%s' in gameinfo.conf", argvec[i]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| std::string Gameinfo::name() const | ||
| { | ||
| return _name; | ||
| } | ||
|
|
||
| std::string Gameinfo::name_lower() const | ||
| { | ||
| std::string temp = _name; | ||
| std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower); | ||
| return temp; | ||
| } | ||
|
|
||
| std::string Gameinfo::name_upper() const | ||
| { | ||
| std::string temp = _name; | ||
| std::transform(temp.begin(), temp.end(), temp.begin(), ::toupper); | ||
| return temp; | ||
| } | ||
|
|
||
| std::string Gameinfo::version() const | ||
| { | ||
| return _version; | ||
| } | ||
|
|
||
| std::string Gameinfo::default_basepak() const | ||
| { | ||
| return _default_basepak; | ||
| } | ||
|
|
||
| std::string Gameinfo::masterserver1() const | ||
| { | ||
| return _masterserver1; | ||
| } | ||
|
|
||
| std::string Gameinfo::masterserver2() const | ||
| { | ||
| return _masterserver2; | ||
| } | ||
|
|
||
| std::string Gameinfo::masterserver3() const | ||
| { | ||
| return _masterserver3; | ||
| } | ||
|
|
||
| std::string Gameinfo::masterserver4() const | ||
| { | ||
| return _masterserver4; | ||
| } | ||
|
|
||
| std::string Gameinfo::masterserver5() const | ||
| { | ||
| return _masterserver5; | ||
| } | ||
|
|
||
| std::string Gameinfo::www_baseurl() const | ||
| { | ||
| return _www_baseurl; | ||
| } | ||
|
|
||
| std::string Gameinfo::unnamed_server() const | ||
| { | ||
| return _name + " " + _version + " Server"; | ||
| } | ||
|
|
||
| std::string Gameinfo::gamename_string() const | ||
| { | ||
| return _gamename_string; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anything prevents to use a real-life example like Unvanquished default strings in the template.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the default values in the code if undefined.
Note that in the future we would be able to make the engine being able to load some built-in asset and display an error (like Darkplaces does) so the template and the hardcoded version would reference that dummy game that does nothing at all instead.