aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-01-22 07:41:08 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-01-22 07:41:08 -0500
commit0f60bf5e7d875aebd6547f6707ef1bfe8e9364ea (patch)
treee69ce6ba96218d4345003404f21adac9914b19cd /src
parent1750cdc208dad021cbfd1ad779608b217f933036 (diff)
names fix
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp18
-rw-r--r--src/world.cpp3
2 files changed, 15 insertions, 6 deletions
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];