mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-11 17:49:53 -10:00
This allows to mark certain functions or virtvars to be declared as "deprecated" starting with a specific engine version. What this means is that a special message will be added to the documentation stating since when the function is deprecated and can contain an optional message. The actual enforcement of the deprecation depends on the target version of the mod so that we can stay backwards compatible. If the mod supports the version since when the function is deprecated, it will not be added to the Lua state which means that it doesn't exist for the calling script. If the targetted version is before the stated version, the function will still be added to the Lua state. As the first function to use this feature, I have deprecated createParticle in the testing library and moved it to the graphics library with a new name reflecting that it creates a persistent particle. I also added the corresponding function for adding a non-persistent particle.
156 lines
3.3 KiB
C++
156 lines
3.3 KiB
C++
/*
|
|
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
|
*
|
|
* All source code herein is the property of Volition, Inc. You may not sell
|
|
* or otherwise commercially exploit the source or things you created based on the
|
|
* source.
|
|
*
|
|
*/
|
|
|
|
#include "globalincs/version.h"
|
|
#include "globalincs/pstypes.h"
|
|
#include "graphics/2d.h"
|
|
|
|
#include "parse/parselo.h"
|
|
|
|
namespace gameversion {
|
|
|
|
bool check_at_least(const version& v) {
|
|
return get_executable_version() >= v;
|
|
}
|
|
|
|
SCP_string format_version(const version& v) {
|
|
SCP_stringstream ss;
|
|
|
|
ss << v.major << "." << v.minor << "." << v.build;
|
|
|
|
if (v.revision != 0) {
|
|
ss << "." << v.revision;
|
|
}
|
|
|
|
return ss.str();
|
|
}
|
|
version parse_version() {
|
|
version v;
|
|
|
|
required_string("+Major:");
|
|
stuff_int(&v.major);
|
|
|
|
required_string("+Minor:");
|
|
stuff_int(&v.minor);
|
|
|
|
required_string("+Build:");
|
|
stuff_int(&v.build);
|
|
|
|
if (optional_string("+Revision:")) {
|
|
stuff_int(&v.revision);
|
|
}
|
|
|
|
return v;
|
|
}
|
|
version get_executable_version() {
|
|
version v;
|
|
v.major = FS_VERSION_MAJOR;
|
|
v.minor = FS_VERSION_MINOR;
|
|
v.build = FS_VERSION_BUILD;
|
|
v.revision = FS_VERSION_REVIS;
|
|
|
|
return v;
|
|
}
|
|
|
|
version::version(int major_in, int minor_in, int build_in, int revision_in) :
|
|
major(major_in), minor(minor_in), build(build_in), revision(revision_in) {
|
|
}
|
|
bool version::isValid() const { return major != 0 || minor != 0 || build != 0 || revision != 0; }
|
|
bool version::operator<(const version& v) const {
|
|
|
|
if (major < v.major) {
|
|
return true;
|
|
}
|
|
if (major > v.major) {
|
|
// Major is greater than the given version => the rest doesn't matter
|
|
return false;
|
|
}
|
|
// major is now equal to our major version
|
|
|
|
if (minor < v.minor) {
|
|
return true;
|
|
}
|
|
if (minor > v.minor) {
|
|
// Minor is greater than the given version => the rest doesn't matter
|
|
return false;
|
|
}
|
|
// minor is now equal to our minor version
|
|
|
|
if (build < v.build) {
|
|
return true;
|
|
}
|
|
if (build > v.build) {
|
|
// build is greater than the given version => the rest doesn't matter
|
|
return false;
|
|
}
|
|
// build is now equal to our build version
|
|
|
|
if (revision == 0 || v.revision == 0) {
|
|
// Special case, if there is no revision info, then the versions are equal which means they are not less than each other
|
|
return false;
|
|
}
|
|
|
|
if (revision < v.revision) {
|
|
return true;
|
|
}
|
|
if (revision > v.revision) {
|
|
// build is greater than the given version => the rest doesn't matter
|
|
return false;
|
|
}
|
|
|
|
// revision is now equal to our revision version
|
|
return false;
|
|
}
|
|
bool version::operator==(const version& other) const {
|
|
if (major == other.major && minor == other.minor && build == other.build) {
|
|
if (revision == 0 || other.revision == 0) {
|
|
// Zero revisions always means that these are equal
|
|
return true;
|
|
}
|
|
|
|
return revision == other.revision;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
bool version::operator>(const version& other) const {
|
|
return other < *this;
|
|
}
|
|
bool version::operator<=(const version& other) const {
|
|
return !(other < *this);
|
|
}
|
|
bool version::operator>=(const version& other) const {
|
|
return !(*this < other);
|
|
}
|
|
bool version::operator!=(const version& other) const {
|
|
return !(*this == other);
|
|
}
|
|
|
|
SCP_string get_version_string()
|
|
{
|
|
SCP_string str;
|
|
|
|
sprintf(str, "FreeSpace 2 Open v%s", FS_VERSION_FULL);
|
|
|
|
#ifndef NDEBUG
|
|
str += " Debug";
|
|
#endif
|
|
|
|
// Lets get some more info in here
|
|
switch (gr_screen.mode) {
|
|
case GR_OPENGL:
|
|
str += " OpenGL";
|
|
break;
|
|
}
|
|
|
|
return str;
|
|
}
|
|
}
|
|
|