aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/common.h2
-rw-r--r--main.cpp24
-rw-r--r--src/entities.cpp18
-rw-r--r--src/world.cpp3
4 files changed, 18 insertions, 29 deletions
diff --git a/include/common.h b/include/common.h
index 4115f10..0df6533 100644
--- a/include/common.h
+++ b/include/common.h
@@ -110,7 +110,7 @@ extern unsigned int SCREEN_HEIGHT;
*
*/
-#define HLINE 4
+#define HLINE 3
/**
* A 'wrapper' for libc's srand(), as we hope to eventually have our own random number
diff --git a/main.cpp b/main.cpp
index c8ff178..cfcf7ec 100644
--- a/main.cpp
+++ b/main.cpp
@@ -124,13 +124,6 @@ GLuint colorIndex;
Mix_Chunk *crickets;
/*
- * names is used to open a file containing all possible NPC names. It is externally
- * referenced in src/entities.cpp for getting random names.
-*/
-
-std::istream *names;
-
-/*
* loops is used for texture animation. It is believed to be passed to entity
* draw functions, although it may be externally referenced instead.
*/
@@ -376,25 +369,14 @@ int main(/*int argc, char *argv[]*/){
//glEnable(GL_DEPTH_TEST); //THIS DOESN'T WORK ON LINUX
glEnable(GL_MULTISAMPLE);
- /*
- * Open the names file containing potential names for NPCs and store it in the names file
- * pointer. This will be reference by getName in src/entities.cpp when NPCs are spawned.
- *
- */
-
- static std::filebuf fb;
- fb.open("assets/names_en-us",std::ios::in);
- names = new std::istream(&fb);
-
-
crickets=Mix_LoadWAV("assets/sounds/crickets.wav");
//Mix_Volume(2,25);
/*
* Create all the worlds, entities, mobs, and the player. This function is defined in
* src/gameplay.cpp
- *
- */
+ */
+
fadeIntensity = 250;
initEverything();
@@ -432,8 +414,6 @@ int main(/*int argc, char *argv[]*/){
Mix_HaltMusic();
Mix_CloseAudio();
- fb.close();
-
destroyInventory();
ui::destroyFonts();
Texture::freeTextures();
diff --git a/src/entities.cpp b/src/entities.cpp
index 7f7d798..88ef6b9 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -32,18 +32,26 @@ void getRandomName(Entity *e){
unsigned int tempNum,max=0;
char *bufs;
- names->seekg(0,names->beg);
+ std::ifstream names ("assets/names_en-us",std::ios::in);
+
+ names.seekg(0,names.beg);
bufs = new char[32];
- for(;!names->eof();max++)
- names->getline(bufs,32);
+ std::cout<<"1\n";
+
+ for(;!names.eof();max++)
+ names.getline(bufs,32);
+
+ std::cout<<"2\n";
tempNum = rand() % max;
- names->seekg(0,names->beg);
+ names.seekg(0,names.beg);
for(unsigned int i=0;i<tempNum;i++)
- names->getline(bufs,32);
+ names.getline(bufs,32);
+
+ names.close();
switch(bufs[0]){
default :
diff --git a/src/world.cpp b/src/world.cpp
index 113d98a..71bd0f4 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1482,12 +1482,13 @@ World *loadWorldFromXML(const char *path){
}else if(!strcmp(name,"npc")){
const char *npcname;
-
+
if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
tmp->addNPC(getRand() % tmp->getTheWidth() / 2.0f,100);
else
tmp->addNPC(spawnx,wxml->FloatAttribute("y"));
+
if((npcname = wxml->Attribute("name"))){
delete[] tmp->npc.back()->name;
tmp->npc.back()->name = new char[strlen(npcname) + 1];