Migrated engine to using dlmalloc through eng::

This commit is contained in:
2022-02-24 02:17:41 -05:00
parent acc00289fb
commit f467944095
61 changed files with 631 additions and 590 deletions

View File

@@ -1,12 +1,13 @@
#include "wrap-sstream.hpp"
#include "wrap-map.hpp"
#include "animqueue.hpp"
#include "wrap-sstream.hpp"
#include <limits>
#include "wrap-map.hpp"
#include <cmath>
#include "luastack.hpp"
#include "streambuffer.hpp"
#include <limits>
#include <cmath>
AnimStep::AnimStep() {
clear();
}
@@ -24,7 +25,7 @@ void AnimStep::clear() {
plane_ = "";
}
void AnimStep::set_action(const std::string &act) {
void AnimStep::set_action(const eng::string &act) {
action_ = act;
}
@@ -53,12 +54,12 @@ void AnimStep::set_xyz(const util::XYZ &xyz) {
xyz_ = xyz;
}
void AnimStep::set_graphic(const std::string &g) {
void AnimStep::set_graphic(const eng::string &g) {
bits_ |= HAS_GRAPHIC;
graphic_ = g;
}
void AnimStep::set_plane(const std::string &p) {
void AnimStep::set_plane(const eng::string &p) {
bits_ |= HAS_PLANE;
plane_ = p;
}
@@ -145,7 +146,7 @@ void AnimStep::read_from(StreamBuffer *sb) {
}
void AnimStep::from_lua_store_string(lua_State *L, int idx, std::string *target, int16_t bits, const char *name) {
void AnimStep::from_lua_store_string(lua_State *L, int idx, eng::string *target, int16_t bits, const char *name) {
if ((bits_ & bits)||(*target != "")) {
luaL_error(L, "specified %s twice", name);
}
@@ -179,7 +180,7 @@ void AnimStep::from_lua(lua_State *L, int idx, bool ignex, const AnimStep &qback
if (!LS.isstring(key)) {
luaL_error(L, "animation specs must be key/value where key is a string");
}
std::string skey = LS.ckstring(key);
eng::string skey = LS.ckstring(key);
if (skey == "action") {
from_lua_store_string(L, value.index(), &action_, 0, "action");
} else if (skey == "graphic") {
@@ -257,8 +258,8 @@ bool AnimStep::echoes(const AnimStep &prev) const {
return true;
}
std::string AnimStep::debug_string() const {
std::ostringstream oss;
eng::string AnimStep::debug_string() const {
eng::ostringstream oss;
oss << "id=" << id();
oss << " action=" << action();
if (has_plane()) {
@@ -283,16 +284,16 @@ std::string AnimStep::debug_string() const {
}
bool AnimStep::from_string(const std::string &config) {
bool AnimStep::from_string(const eng::string &config) {
clear();
util::StringVec parts = util::split(config, ' ');
for (int i = 0; i < int(parts.size()); i++) {
const std::string &part = parts[i];
const eng::string &part = parts[i];
if (part == "") continue;
util::StringVec lr = util::split(part, '=');
if (lr.size() != 2) return false;
const std::string &key = lr[0];
const std::string &val = lr[1];
const eng::string &key = lr[0];
const eng::string &val = lr[1];
if (key == "action") {
action_ = val;
} else if (key == "id") {
@@ -366,7 +367,7 @@ void AnimQueue::full_clear_and_set_limit(int n) {
version_number_ = version_autoinc_ ? 1 : 0;
}
void AnimQueue::clear(const std::string &plane) {
void AnimQueue::clear(const eng::string &plane) {
steps_.clear();
steps_.emplace_back();
steps_.front().set_plane(plane);
@@ -427,16 +428,16 @@ bool AnimQueue::valid() const {
return true;
}
std::string AnimQueue::steps_debug_string() const {
std::ostringstream oss;
eng::string AnimQueue::steps_debug_string() const {
eng::ostringstream oss;
for (int i = 0; i < int(size()); i++) {
oss << nth(i).debug_string() << "; ";
}
return oss.str();
}
std::string AnimQueue::full_debug_string() const {
std::ostringstream oss;
eng::string AnimQueue::full_debug_string() const {
eng::ostringstream oss;
for (int i = 0; i < int(size()); i++) {
oss << nth(i).debug_string() << "; ";
}
@@ -504,7 +505,7 @@ bool AnimQueue::diff(const AnimQueue &auth, StreamBuffer *sb) const {
}
// Index the remaining elements by id.
std::map<uint64_t, int> index;
eng::map<uint64_t, int> index;
for (int i = 1; i < int(steps_.size()); i++) {
index[steps_[i].id_] = i;
}
@@ -538,7 +539,7 @@ void AnimQueue::patch(StreamBuffer *sb, DebugCollector *dbc) {
size_limit_ = sb->read_uint8();
// Decode the diff, stop at eof.
std::deque<AnimStep> old = std::move(steps_);
eng::deque<AnimStep> old = std::move(steps_);
steps_.clear();
for (int i = 0; i < len; i++) {
uint8_t index = sb->read_uint8();