Merge branch 'main' into wip/net-n-btree
This commit is contained in:
commit
4da398e42d
@ -2,8 +2,15 @@
|
|||||||
"basicHelpText": "Basic commands are: {}",
|
"basicHelpText": "Basic commands are: {}",
|
||||||
"adminHelpText": "Admin commands are: {}",
|
"adminHelpText": "Admin commands are: {}",
|
||||||
"debugHelpText": "Debug commands are: {}",
|
"debugHelpText": "Debug commands are: {}",
|
||||||
|
"openSbHelpText": "OpenSB commands are: {}",
|
||||||
|
"openSbDebugHelpText": "OpenSB Debug commands are: {}",
|
||||||
|
|
||||||
"debugCommands": {
|
"openSbDebugCommands": {
|
||||||
"run": "Usage /run <lua>. Executes a script on the player and outputs the return value to chat."
|
"run": "Usage /run <lua>. Executes a script on the player and outputs the return value to chat."
|
||||||
|
},
|
||||||
|
|
||||||
|
"openSbCommands": {
|
||||||
|
"swap": "Usage /swap <name>. Swaps the current character, case-insensitive, only substring required.",
|
||||||
|
"respawninworld": "Usage /respawninworld. Sets the respawn flag for the current world until you teleport away."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ Assets::Assets(Settings settings, StringList assetSources) {
|
|||||||
LuaCallbacks callbacks;
|
LuaCallbacks callbacks;
|
||||||
callbacks.registerCallbackWithSignature<StringSet, String>("byExtension", bind(&Assets::scanExtension, this, _1));
|
callbacks.registerCallbackWithSignature<StringSet, String>("byExtension", bind(&Assets::scanExtension, this, _1));
|
||||||
callbacks.registerCallbackWithSignature<Json, String>("json", bind(&Assets::json, this, _1));
|
callbacks.registerCallbackWithSignature<Json, String>("json", bind(&Assets::json, this, _1));
|
||||||
|
callbacks.registerCallbackWithSignature<bool, String>("exists", bind(&Assets::assetExists, this, _1));
|
||||||
|
|
||||||
callbacks.registerCallback("bytes", [this](String const& path) -> String {
|
callbacks.registerCallback("bytes", [this](String const& path) -> String {
|
||||||
auto assetBytes = bytes(path);
|
auto assetBytes = bytes(path);
|
||||||
|
@ -17,6 +17,12 @@ void readPngData(png_structp pngPtr, png_bytep data, png_size_t length) {
|
|||||||
((IODevice*)png_get_io_ptr(pngPtr))->readFull((char*)data, length);
|
((IODevice*)png_get_io_ptr(pngPtr))->readFull((char*)data, length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Image::isPng(IODevicePtr device) {
|
||||||
|
png_byte header[8];
|
||||||
|
device->readAbsolute(0, (char*)header, sizeof(header));
|
||||||
|
return !png_sig_cmp(header, 0, sizeof(header));
|
||||||
|
}
|
||||||
|
|
||||||
Image Image::readPng(IODevicePtr device) {
|
Image Image::readPng(IODevicePtr device) {
|
||||||
png_byte header[8];
|
png_byte header[8];
|
||||||
device->readFull((char*)header, sizeof(header));
|
device->readFull((char*)header, sizeof(header));
|
||||||
|
@ -27,6 +27,7 @@ STAR_CLASS(Image);
|
|||||||
class Image {
|
class Image {
|
||||||
public:
|
public:
|
||||||
static Image readPng(IODevicePtr device);
|
static Image readPng(IODevicePtr device);
|
||||||
|
static bool isPng(IODevicePtr device);
|
||||||
// Returns the size and pixel format that would be constructed from the given
|
// Returns the size and pixel format that would be constructed from the given
|
||||||
// png file, without actually loading it.
|
// png file, without actually loading it.
|
||||||
static tuple<Vec2U, PixelFormat> readPngMetadata(IODevicePtr device);
|
static tuple<Vec2U, PixelFormat> readPngMetadata(IODevicePtr device);
|
||||||
|
@ -51,7 +51,8 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
|
|||||||
{"maketechavailable", bind(&ClientCommandProcessor::makeTechAvailable, this, _1)},
|
{"maketechavailable", bind(&ClientCommandProcessor::makeTechAvailable, this, _1)},
|
||||||
{"enabletech", bind(&ClientCommandProcessor::enableTech, this, _1)},
|
{"enabletech", bind(&ClientCommandProcessor::enableTech, this, _1)},
|
||||||
{"upgradeship", bind(&ClientCommandProcessor::upgradeShip, this, _1)},
|
{"upgradeship", bind(&ClientCommandProcessor::upgradeShip, this, _1)},
|
||||||
{"swap", bind(&ClientCommandProcessor::swap, this, _1)}
|
{"swap", bind(&ClientCommandProcessor::swap, this, _1)},
|
||||||
|
{"respawnInWorld", bind(&ClientCommandProcessor::respawnInWorld, this, _1)}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ String ClientCommandProcessor::setGravity(String const& argumentsString) {
|
|||||||
return "You must be an admin to use this command.";
|
return "You must be an admin to use this command.";
|
||||||
|
|
||||||
m_universeClient->worldClient()->overrideGravity(lexicalCast<float>(arguments.at(0)));
|
m_universeClient->worldClient()->overrideGravity(lexicalCast<float>(arguments.at(0)));
|
||||||
return strf("Gravity set to {}, the change is LOCAL ONLY", arguments.at(0));
|
return strf("Gravity set to {} (This is client-side!)", arguments.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
String ClientCommandProcessor::resetGravity() {
|
String ClientCommandProcessor::resetGravity() {
|
||||||
@ -427,4 +428,16 @@ String ClientCommandProcessor::swap(String const& argumentsString) {
|
|||||||
return "Failed to swap player";
|
return "Failed to swap player";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ClientCommandProcessor::respawnInWorld(String const& argumentsString) {
|
||||||
|
auto arguments = m_parser.tokenizeToStringList(argumentsString);
|
||||||
|
auto worldClient = m_universeClient->worldClient();
|
||||||
|
|
||||||
|
if (arguments.size() == 0)
|
||||||
|
return strf("Respawn in this world is currently {}", worldClient->respawnInWorld() ? "true" : "false");
|
||||||
|
|
||||||
|
bool respawnInWorld = Json::parse(arguments.at(0)).toBool();
|
||||||
|
worldClient->setRespawnInWorld(respawnInWorld);
|
||||||
|
return strf("Respawn in this world set to {} (This is client-side!)", respawnInWorld ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -58,6 +58,7 @@ private:
|
|||||||
String enableTech(String const& argumentsString);
|
String enableTech(String const& argumentsString);
|
||||||
String upgradeShip(String const& argumentsString);
|
String upgradeShip(String const& argumentsString);
|
||||||
String swap(String const& argumentsString);
|
String swap(String const& argumentsString);
|
||||||
|
String respawnInWorld(String const& argumentsString);
|
||||||
|
|
||||||
UniverseClientPtr m_universeClient;
|
UniverseClientPtr m_universeClient;
|
||||||
CinematicPtr m_cinematicOverlay;
|
CinematicPtr m_cinematicOverlay;
|
||||||
|
@ -53,12 +53,14 @@ String CommandProcessor::help(ConnectionId connectionId, String const& argumentS
|
|||||||
|
|
||||||
auto assets = Root::singleton().assets();
|
auto assets = Root::singleton().assets();
|
||||||
auto basicCommands = assets->json("/help.config:basicCommands");
|
auto basicCommands = assets->json("/help.config:basicCommands");
|
||||||
|
auto openSbCommands = assets->json("/help.config:openSbCommands");
|
||||||
auto adminCommands = assets->json("/help.config:adminCommands");
|
auto adminCommands = assets->json("/help.config:adminCommands");
|
||||||
auto debugCommands = assets->json("/help.config:debugCommands");
|
auto debugCommands = assets->json("/help.config:debugCommands");
|
||||||
|
auto openSbDebugCommands = assets->json("/help.config:openSbDebugCommands");
|
||||||
|
|
||||||
if (arguments.size()) {
|
if (arguments.size()) {
|
||||||
if (arguments.size() >= 1) {
|
if (arguments.size() >= 1) {
|
||||||
if (auto helpText = basicCommands.optString(arguments[0]).orMaybe(adminCommands.optString(arguments[0])).orMaybe(debugCommands.optString(arguments[0])))
|
if (auto helpText = basicCommands.optString(arguments[0]).orMaybe(openSbCommands.optString(arguments[0])).orMaybe(adminCommands.optString(arguments[0])).orMaybe(debugCommands.optString(arguments[0])).orMaybe(openSbDebugCommands.optString(arguments[0])))
|
||||||
return *helpText;
|
return *helpText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,12 +76,18 @@ String CommandProcessor::help(ConnectionId connectionId, String const& argumentS
|
|||||||
String basicHelpFormat = assets->json("/help.config:basicHelpText").toString();
|
String basicHelpFormat = assets->json("/help.config:basicHelpText").toString();
|
||||||
res = res + strf(basicHelpFormat.utf8Ptr(), commandDescriptions(basicCommands));
|
res = res + strf(basicHelpFormat.utf8Ptr(), commandDescriptions(basicCommands));
|
||||||
|
|
||||||
|
String openSbHelpFormat = assets->json("/help.config:openSbHelpText").toString();
|
||||||
|
res = res + "\n" + strf(openSbHelpFormat.utf8Ptr(), commandDescriptions(openSbCommands));
|
||||||
|
|
||||||
if (!adminCheck(connectionId, "")) {
|
if (!adminCheck(connectionId, "")) {
|
||||||
String adminHelpFormat = assets->json("/help.config:adminHelpText").toString();
|
String adminHelpFormat = assets->json("/help.config:adminHelpText").toString();
|
||||||
res = res + "\n" + strf(adminHelpFormat.utf8Ptr(), commandDescriptions(adminCommands));
|
res = res + "\n" + strf(adminHelpFormat.utf8Ptr(), commandDescriptions(adminCommands));
|
||||||
|
|
||||||
String debugHelpFormat = assets->json("/help.config:debugHelpText").toString();
|
String debugHelpFormat = assets->json("/help.config:debugHelpText").toString();
|
||||||
res = res + "\n" + strf(debugHelpFormat.utf8Ptr(), commandDescriptions(debugCommands));
|
res = res + "\n" + strf(debugHelpFormat.utf8Ptr(), commandDescriptions(debugCommands));
|
||||||
|
|
||||||
|
String openSbDebugHelpFormat = assets->json("/help.config:openSbDebugHelpText").toString();
|
||||||
|
res = res + "\n" + strf(openSbDebugHelpFormat.utf8Ptr(), commandDescriptions(openSbDebugCommands));
|
||||||
}
|
}
|
||||||
|
|
||||||
res = res + "\n" + basicCommands.getString("help");
|
res = res + "\n" + basicCommands.getString("help");
|
||||||
|
@ -174,7 +174,11 @@ Vec2U ImageMetadataDatabase::calculateImageSize(AssetPath const& path) const {
|
|||||||
imageSize = *size;
|
imageSize = *size;
|
||||||
} else {
|
} else {
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
imageSize = get<0>(Image::readPngMetadata(assets->openFile(path.basePath)));
|
auto file = assets->openFile(path.basePath);
|
||||||
|
if (Image::isPng(file))
|
||||||
|
imageSize = get<0>(Image::readPngMetadata(file));
|
||||||
|
else
|
||||||
|
imageSize = fallback();
|
||||||
locker.lock();
|
locker.lock();
|
||||||
m_sizeCache[path.basePath] = imageSize;
|
m_sizeCache[path.basePath] = imageSize;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,10 @@ bool WorldClient::respawnInWorld() const {
|
|||||||
return m_respawnInWorld;
|
return m_respawnInWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldClient::setRespawnInWorld(bool respawnInWorld) {
|
||||||
|
m_respawnInWorld = respawnInWorld;
|
||||||
|
}
|
||||||
|
|
||||||
void WorldClient::removeEntity(EntityId entityId, bool andDie) {
|
void WorldClient::removeEntity(EntityId entityId, bool andDie) {
|
||||||
auto entity = m_entityMap->entity(entityId);
|
auto entity = m_entityMap->entity(entityId);
|
||||||
if (!entity)
|
if (!entity)
|
||||||
|
@ -108,6 +108,7 @@ public:
|
|||||||
bool mainPlayerDead() const;
|
bool mainPlayerDead() const;
|
||||||
void reviveMainPlayer();
|
void reviveMainPlayer();
|
||||||
bool respawnInWorld() const;
|
bool respawnInWorld() const;
|
||||||
|
void setRespawnInWorld(bool respawnInWorld);
|
||||||
|
|
||||||
void removeEntity(EntityId entityId, bool andDie);
|
void removeEntity(EntityId entityId, bool andDie);
|
||||||
|
|
||||||
@ -175,6 +176,9 @@ public:
|
|||||||
|
|
||||||
typedef std::function<bool(PlayerPtr, StringView)> BroadcastCallback;
|
typedef std::function<bool(PlayerPtr, StringView)> BroadcastCallback;
|
||||||
BroadcastCallback& broadcastCallback();
|
BroadcastCallback& broadcastCallback();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const float DropDist;
|
static const float DropDist;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user