Fix the windows version (Fuck that was a trip)

This commit is contained in:
Dane Johnson 2021-03-04 10:31:36 -06:00
parent c568da15be
commit 6e19b44981
4 changed files with 34 additions and 10 deletions

View File

@ -65,7 +65,11 @@ target_sources(couchlib PUBLIC
Shaders/SkyboxShader.cpp) Shaders/SkyboxShader.cpp)
add_library(couchlib_luascripting SHARED) if (WIN32)
add_library(couchlib_luascripting STATIC)
else ()
add_library(couchlib_luascripting SHARED)
endif ()
target_sources(couchlib_luascripting PUBLIC target_sources(couchlib_luascripting PUBLIC
Scripting/Lua.h Scripting/Lua.h
Scripting/Lua.cpp) Scripting/Lua.cpp)

View File

@ -24,9 +24,15 @@
#include "Node.h" #include "Node.h"
#include "Util.h" #include "Util.h"
// Note: Declare theses here, not in the header, otherwise
// Windows DLLs will make two versions of the singleton.
static NodeList freeList(false);
static Node root(false);
NodeList::NodeList() { NodeList::NodeList() {
isPrefabList = true; isPrefabList = true;
} }
NodeList::NodeList(bool isPrefabList) { NodeList::NodeList(bool isPrefabList) {
this->isPrefabList = isPrefabList; this->isPrefabList = isPrefabList;
} }
@ -45,6 +51,10 @@ void NodeList::Remove(Node *node) {
remove(node); remove(node);
} }
int NodeList::Length() {
return size();
}
bool NodeList::IsPrefabList() { bool NodeList::IsPrefabList() {
return isPrefabList; return isPrefabList;
} }
@ -57,6 +67,14 @@ void NodeList::FreeList() {
clear(); clear();
} }
Node::Node() {}
Node::Node(bool isPrefab) {
if (!isPrefab) {
this->isPrefab = false;
children.isPrefabList = false;
}
}
Name Node::GetType() const {return "Node";} Name Node::GetType() const {return "Node";}
bool Node::IsPrefab() { bool Node::IsPrefab() {
@ -78,18 +96,18 @@ Node *Node::GetParent() {
void Node::QueueFree() { void Node::QueueFree() {
parent->children.Remove(this); parent->children.Remove(this);
freeList->Append(this); freeList.Append(this);
} }
void Node::DoFree() { void Node::DoFree() {
if (this != root) { if (this != &root) {
throw "Tried to call DoFree from non-root node"; throw "Tried to call DoFree from non-root node";
} }
freeList->FreeList(); freeList.FreeList();
} }
Node *Node::GetRoot() { Node *Node::GetRoot() {
return root; return &root;
} }
Node* Node::Create() { Node* Node::Create() {
@ -115,5 +133,3 @@ Node* Node::Instance() {
return instance; return instance;
} }
NodeList *Node::freeList = new NodeList(false);
Node *Node::root = {Node().Instance()};

View File

@ -49,6 +49,11 @@ public:
@param node The node to remove @param node The node to remove
*/ */
void Remove(Node *node); void Remove(Node *node);
/**
Check how many children this node has
@returns The number of children of this node
*/
int Length();
/** /**
Whether or not this is a list of prefabs Whether or not this is a list of prefabs
@returns true if this is a prefab list, @returns true if this is a prefab list,
@ -69,6 +74,8 @@ private:
*/ */
class Node { class Node {
public: public:
Node();
Node(bool isPrefab);
virtual Name GetType() const; virtual Name GetType() const;
/** /**
@ -134,8 +141,6 @@ public:
private: private:
NodeList children; NodeList children;
static NodeList *freeList;
static Node *root;
Node *parent; Node *parent;
bool isPrefab = true; bool isPrefab = true;
friend class NodeList; friend class NodeList;

View File

@ -110,7 +110,6 @@ int main() {
double delta = 0.0; double delta = 0.0;
while(!glfwWindowShouldClose(window)) { while(!glfwWindowShouldClose(window)) {
// Physics update() // Physics update()
world->Step(delta); world->Step(delta);