aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-03-01 08:43:56 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-03-01 08:43:56 -0500
commit47f8aa5b312a5ef671e83322bcbe201a034f84c0 (patch)
tree8dccb7228c407e01024752b48dae7150b6b349e5 /include
parent32cb1880f018fc149d1c8a71a83426a8f5a92a6a (diff)
parent883b348abac73d6c2b1d4ea8b65caccf0767e5a8 (diff)
merge with remake
Diffstat (limited to 'include')
-rw-r--r--include/common.h3
-rw-r--r--include/entities.h37
-rw-r--r--include/threadpool.h53
-rw-r--r--include/ui.h10
-rw-r--r--include/world.h8
5 files changed, 102 insertions, 9 deletions
diff --git a/include/common.h b/include/common.h
index 08f0392..9650f49 100644
--- a/include/common.h
+++ b/include/common.h
@@ -18,6 +18,7 @@
#include <thread>
#include <mutex>
#include <future>
+#include <threadpool.h>
#define GLEW_STATIC
#include <GL/glew.h>
@@ -118,6 +119,8 @@ extern unsigned int SCREEN_WIDTH;
extern unsigned int SCREEN_HEIGHT;
extern bool FULLSCREEN;
+extern bool uiLoop;
+extern std::mutex mtx;
/**
* Define the length of a single HLINE.
diff --git a/include/entities.h b/include/entities.h
index 926eeae..545f0a4 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -22,13 +22,13 @@ enum _TYPE {
STRUCTURET,
PLAYERT,
NPCT,
+ MERCHT,
MOBT
};
enum GENDER{
MALE,
- FEMALE,
- TRANSBULLSHIT
+ FEMALE
};
enum MOB_SUB {
@@ -47,7 +47,27 @@ enum BUILD_SUB{
HOUSE4 = 4,
FOUNTAIN = 5,
LAMP_POST = 6,
- FIRE_PIT = 7
+ FIRE_PIT = 7,
+ STALL_MARKET = 70,
+ STALL_TRADER = 71
+};
+
+class BuySell{
+public:
+ int member;
+ union{
+ struct{
+ std::string item1;
+ std::string item2;
+ }trade;
+ struct{
+ enum type{BUY,SELL};
+ std::string item;
+ int price;
+ }cost;
+ };
+ BuySell(){}
+ ~BuySell(){}
};
class World;
@@ -191,10 +211,19 @@ public:
void addAIFunc(int (*func)(NPC *),bool preload);
void clearAIFunc(void);
- void interact();
+ virtual void interact();
void wander(int);
};
+class Merchant : public NPC{
+public:
+ std::vector<BuySell>bsinv;
+ void interact();
+
+ Merchant();
+ ~Merchant();
+};
+
class Structures : public Entity{
public:
BUILD_SUB bsubtype;
diff --git a/include/threadpool.h b/include/threadpool.h
new file mode 100644
index 0000000..c341673
--- /dev/null
+++ b/include/threadpool.h
@@ -0,0 +1,53 @@
+#ifndef THREADPOOL_H
+#define THREADPOOL_H
+
+#include <vector>
+#include <queue>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
+#include <iostream>
+#include <unistd.h>
+
+using namespace std;
+
+class ThreadPool
+{
+public:
+
+ // Constructor.
+ ThreadPool(int threads);
+
+ // Destructor.
+ ~ThreadPool();
+
+ // Adds task to a task queue.
+ void Enqueue(function<void()> f);
+
+ // Shut down the pool.
+ void ShutDown();
+
+private:
+ // Thread pool storage.
+ vector<thread> threadPool;
+
+ // Queue to keep track of incoming tasks.
+ queue<function<void()>> tasks;
+
+ // Task queue mutex.
+ mutex tasksMutex;
+
+ // Condition variable.
+ condition_variable condition;
+
+ // Indicates that pool needs to be shut down.
+ bool terminate;
+
+ // Indicates that pool has been terminated.
+ bool stopped;
+
+ // Function that will be invoked by our threads.
+ void Invoke();
+};
+
+#endif //THRE \ No newline at end of file
diff --git a/include/ui.h b/include/ui.h
index 3e4fc8a..667a581 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -22,7 +22,6 @@ typedef void(*menuFunc)();
struct menuItem{
int member;
union{
-
struct{
vec2 loc;
dim2 dim;
@@ -30,7 +29,6 @@ struct menuItem{
const char* text;
menuFunc func;
}button;
-
struct{
vec2 loc;
dim2 dim;
@@ -108,9 +106,9 @@ namespace ui {
extern bool posFlag;
extern unsigned char dialogOptChosen;
- extern bool dialogBoxExists;
- extern bool dialogImportant;
- extern bool dialogPassive;
+ extern bool dialogBoxExists;
+ extern bool dialogImportant;
+ extern bool dialogPassive;
extern unsigned int textWrapLimit;
@@ -148,6 +146,8 @@ namespace ui {
*/
void dialogBox(const char *name,const char *opt,bool passive,const char *text,...);
+ void merchantBox(const char *name, std::vector<BuySell> *items, const char *opt,bool passive,const char *text,...);
+ void merchantBox();
void waitForDialog(void);
/*
diff --git a/include/world.h b/include/world.h
index 9833bb2..b3d1071 100644
--- a/include/world.h
+++ b/include/world.h
@@ -124,6 +124,8 @@ public:
~Village(void){}
};
+extern Player *player;
+
/**
* The world class. This class does everything a world should do.
*/
@@ -236,6 +238,10 @@ public:
char *setToRight(const char *file);
+ void callUpdate(){
+ this->update(player,deltaTime);
+ }
+
/**
* A vector of pointers to every NPC, Structure, Mob, and Object in this
@@ -249,6 +255,7 @@ public:
*/
std::vector<NPC *> npc;
+ std::vector<Merchant *> merchant;
/**
* A vector of all Structures in this world.
@@ -331,6 +338,7 @@ public:
*/
void addNPC(float x,float y);
+ void addMerchant(float x, float y);
/**
* Adds an object to the world with the specified item id and coordinates.