Added a makefile

This commit is contained in:
2021-01-23 14:44:06 -05:00
parent 827a114752
commit b85e92343f
8 changed files with 42 additions and 36 deletions

View File

@@ -1,8 +1,6 @@
#include "animqueue.hpp"
#include "luastack.hpp"
#include <limits>
#include "luastack.hpp"
#include "animqueue.hpp"
AnimStep::AnimStep() {}
AnimStep::~AnimStep() {}
@@ -89,8 +87,8 @@ void AnimView::update_from(const AnimQueue &queue) {
}
AnimView *AnimViewMap::get_one(int64_t id) {
auto iter = view_map_.find(id);
if (iter == view_map_.end()) {
auto iter = find(id);
if (iter == end()) {
return nullptr;
} else {
return &iter->second;
@@ -98,23 +96,23 @@ AnimView *AnimViewMap::get_one(int64_t id) {
}
void AnimViewMap::clear_updated_bits() {
for (auto pair : view_map_) {
for (auto pair : *this) {
pair.second.updated_ = false;
}
}
void AnimViewMap::delete_non_updated() {
for (auto iter = view_map_.begin(); iter != view_map_.end(); ) {
for (auto iter = begin(); iter != end(); ) {
if (iter->second.updated_) {
iter++;
} else {
iter = view_map_.erase(iter);
iter = erase(iter);
}
}
}
void AnimViewMap::update_one(const AnimQueue &queue) {
view_map_[queue.get_id()].update_from(queue);
operator[](queue.get_id()).update_from(queue);
}
LuaDefine(unittests_animqueue, "c") {

View File

@@ -119,33 +119,14 @@ public:
void update_from(const AnimQueue &queue);
};
// AnimViewMap: basically just a map from tangible ID to AnimView.
// AnimViewMap: a unordered_map from tangible ID to AnimView. Adds a few
// methods for garbage collection and updating.
//
// Also provides a simple garbage collector to get rid of AnimViews
// that haven't been updated recently.
//
class AnimViewMap {
class AnimViewMap : public std::unordered_map<int64_t, AnimView> {
public:
using ViewMap = std::unordered_map<int64_t, AnimView>;
private:
ViewMap view_map_;
public:
AnimViewMap() {}
~AnimViewMap() {}
// Get the entire view map for iterating over.
ViewMap &get_map() { return view_map_; }
// Get one entry from the view map, if it exists.
AnimView *get_one(int64_t id);
// Clear the updated bits on all the AnimViews.
void clear_updated_bits();
// Delete any AnimViews whose updated bits are not set.
void delete_non_updated();
// Update one AnimView, and set its updated bit.
void update_one(const AnimQueue &queue);
};

View File

@@ -1,6 +1,5 @@
#include "luastack.hpp"
#include "globaldb.hpp"
#include "table.hpp"
LuaDefine(globaldb_enable, "c") {
LuaVar globaldb;

View File

@@ -1,8 +1,8 @@
#include <cmath>
#include <algorithm>
#include "luastack.hpp"
#include "planemap.hpp"
#include "util.hpp"
#include "planemap.hpp"
// Cell X, Y coordinates are packed such that they have 24 bits for X and Y.
// A cell is 10 Meters square.

View File

@@ -10,9 +10,9 @@
#include "util.hpp"
#include "luastack.hpp"
#include "traceback.hpp"
#include "table.hpp"
#include "source.hpp"
#include "traceback.hpp"
LuaDefine(source_makeclass, "f") {