diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-01-16 12:31:42 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-01-16 12:31:42 -0500 |
commit | 4b21a0fa4e6a7e35b7d9a01bbc0a7080dd392996 (patch) | |
tree | 849e56e7515d9bcd3fdcd38840af07dc2ac77987 /include | |
parent | 48cf19db2fc33875e32209eb6e32728d019cd6da (diff) |
dynamic world linking
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 2 | ||||
-rw-r--r-- | include/entities.h | 65 | ||||
-rw-r--r-- | include/world.h | 57 |
3 files changed, 34 insertions, 90 deletions
diff --git a/include/common.h b/include/common.h index 48026b0..ae832f1 100644 --- a/include/common.h +++ b/include/common.h @@ -205,6 +205,8 @@ unsigned int millis(void); int getdir(const char *dir, std::vector<std::string> &files); void strVectorSortAlpha(std::vector<std::string> *v); +int strCreateFunc(const char *equ); + extern void *NULLPTR; #endif // COMMON_H diff --git a/include/entities.h b/include/entities.h index 412ec42..d434546 100644 --- a/include/entities.h +++ b/include/entities.h @@ -47,31 +47,6 @@ enum BUILD_SUB{ FIRE_PIT = 7 }; -typedef struct { - InventorySavePacket isp; - vec2 loc; - vec2 vel; - float width; - float height; - float speed; - float health; - float maxHealth; - int subtype; - int ticksToUse; - unsigned int randDialog; - unsigned char ground; - bool near; - bool canMove; - bool right,left; - bool alive; - bool hit; - _TYPE type; - GENDER gender; - size_t nameSize; - char name[32]; - //Texturec *tex; -} __attribute__ ((packed)) EntitySavePacket; - class World; class Particles{ @@ -176,9 +151,6 @@ public: virtual void interact(){} virtual ~Entity(){} - - char *baseSave(void); - void baseLoad(char *); }; class Player : public Entity{ @@ -194,6 +166,7 @@ public: class NPC : public Entity{ public: std::vector<int (*)(NPC *)>aiFunc; + unsigned int dialogIndex; NPC(); ~NPC(); @@ -201,29 +174,18 @@ public: void addAIFunc(int (*func)(NPC *),bool preload); void interact(); void wander(int); - - char *save(unsigned int *size); - void load(unsigned int,char *b); }; -typedef struct { - EntitySavePacket esp; - BUILD_SUB bsubtype; -} __attribute__ ((packed)) StructuresSavePacket; - class Structures : public Entity{ public: - World *inWorld; - World **inside; BUILD_SUB bsubtype; + char *inside; + //char *outside; Structures(); ~Structures(); - unsigned int spawn(BUILD_SUB, float, float, World *); - - char *save(void); - void load(char *s); + unsigned int spawn(BUILD_SUB, float, float); }; class Mob : public Entity{ @@ -235,24 +197,8 @@ public: ~Mob(); void wander(int); - - char *save(void); - void load(char *); }; -typedef struct { - EntitySavePacket esp; - double init_y; - //void (*hey)(Mob *callee); -} __attribute__ ((packed)) MobSavePacket; - -typedef struct { - EntitySavePacket esp; - ITEM_ID identifier; - bool questObject; - char pickupDialog[256]; -} __attribute__ ((packed)) ObjectSavePacket; - class Object : public Entity{ private: ITEM_ID identifier; @@ -267,9 +213,6 @@ public: void reloadTexture(void); void interact(void); - - char *save(void); - void load(char *); }; #endif // ENTITIES_H diff --git a/include/world.h b/include/world.h index 91fcf8a..a1cc870 100644 --- a/include/world.h +++ b/include/world.h @@ -20,8 +20,16 @@ #define GEN_INC 10 +/** + * Defines the lowest possible y value for a world line. + */ #define GEN_MIN 80 + +/** + * Defines the highest possible y value for a randomly generated world line. + */ + #define GEN_MAX 110 @@ -54,11 +62,15 @@ typedef enum { RAIN /**< Rain (not implemented :) )*/ } WEATHER; +/** + * The light structure, used to store light coordinates and color. + */ + +typedef struct { + vec2 loc; /**< Light location */ + Color color; /**< Light color */ +} Light; -typedef struct{ - vec2 loc; - Color color; -}Light; /** * The line structure. * This structure is used to store the world's ground, stored in vertical @@ -156,13 +168,13 @@ public: * These pointers keep track of worlds that are adjacent to this one. Used in * ui.cpp for world jumping. */ - - World **toLeft, - **toRight, - *behind, - *infront; - /* + char *toLeft,*toRight; + + char *setToLeft(const char *file); + char *setToRight(const char *file); + + /** * These vectors contain the NPCs, Mobs, Structures and Objects that are * loaded inside the world, with the Entity vector containing pointers to * the contents of all the others. @@ -176,8 +188,8 @@ public: std::vector<Particles *> particles; std::vector<Light > light; - void addStructure(BUILD_SUB sub,float x,float y,World **inside);//,World **outside); - void addVillage(int bCount, int npcMin, int npcMax,World **inside); + void addStructure(BUILD_SUB sub,float x,float y,const char *inside); + void addVillage(int bCount, int npcMin, int npcMax,const char *inside); void addMob(int t,float x,float y); void addMob(int t,float x,float y,void (*hey)(Mob *)); void addNPC(float x,float y); @@ -222,19 +234,12 @@ public: void bgmPlay(World *prev); /* - * Looks for the furthest back layer in this world and adds a new layer of width `width` behind it. - */ - - void addLayer(unsigned int width); - - /* * Draw the world and entities based on the player's coordinates. Virtual for the same * reason generate() is. */ virtual void draw(Player *p); - /* * Detect the player and any entities in the current world. */ @@ -248,12 +253,7 @@ public: */ World *goWorldLeft(Player *p); - World *goWorldRight(Player *p); - World *goWorldBack(Player *p); - World *goWorldFront(Player *p); - - bool isWorldLeft(void); - bool isWorldRight(void); + World *goWorldRight(Player *p); /* * Called to enter/exit a structure. @@ -272,9 +272,6 @@ public: */ int getTheWidth(void); - - void save(std::ofstream *); - void load(std::ifstream *); }; /* @@ -289,7 +286,6 @@ float worldGetYBase(World *w); class IndoorWorld : public World { public: - World **outside; IndoorWorld(void); ~IndoorWorld(void); @@ -308,5 +304,8 @@ public: }; extern int worldShade; +extern char *currentXML; + +World *loadWorldFromXML(const char *path); #endif // WORLD_H |