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)
add_library(couchlib_luascripting SHARED)
if (WIN32)
add_library(couchlib_luascripting STATIC)
else ()
add_library(couchlib_luascripting SHARED)
endif ()
target_sources(couchlib_luascripting PUBLIC
Scripting/Lua.h
Scripting/Lua.cpp)

View File

@ -24,9 +24,15 @@
#include "Node.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() {
isPrefabList = true;
}
NodeList::NodeList(bool isPrefabList) {
this->isPrefabList = isPrefabList;
}
@ -45,6 +51,10 @@ void NodeList::Remove(Node *node) {
remove(node);
}
int NodeList::Length() {
return size();
}
bool NodeList::IsPrefabList() {
return isPrefabList;
}
@ -57,6 +67,14 @@ void NodeList::FreeList() {
clear();
}
Node::Node() {}
Node::Node(bool isPrefab) {
if (!isPrefab) {
this->isPrefab = false;
children.isPrefabList = false;
}
}
Name Node::GetType() const {return "Node";}
bool Node::IsPrefab() {
@ -78,18 +96,18 @@ Node *Node::GetParent() {
void Node::QueueFree() {
parent->children.Remove(this);
freeList->Append(this);
freeList.Append(this);
}
void Node::DoFree() {
if (this != root) {
if (this != &root) {
throw "Tried to call DoFree from non-root node";
}
freeList->FreeList();
freeList.FreeList();
}
Node *Node::GetRoot() {
return root;
return &root;
}
Node* Node::Create() {
@ -115,5 +133,3 @@ Node* Node::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
*/
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
@returns true if this is a prefab list,
@ -69,6 +74,8 @@ private:
*/
class Node {
public:
Node();
Node(bool isPrefab);
virtual Name GetType() const;
/**
@ -134,8 +141,6 @@ public:
private:
NodeList children;
static NodeList *freeList;
static Node *root;
Node *parent;
bool isPrefab = true;
friend class NodeList;

View File

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