summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/cEntity.cpp5
-rw-r--r--source/cMonsterConfig.cpp168
2 files changed, 89 insertions, 84 deletions
diff --git a/source/cEntity.cpp b/source/cEntity.cpp
index b9cbbd9f6..b32439869 100644
--- a/source/cEntity.cpp
+++ b/source/cEntity.cpp
@@ -51,6 +51,10 @@ void cEntity::Initialize( cWorld* a_World )
m_World = a_World;
m_World->AddEntity( this );
+ MoveToCorrectChunk();
+
+ /*
+Not needed because itīs covered by the MoveToCorrectChunk function
cWorld::BlockToChunk( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z, m_ChunkX, m_ChunkY, m_ChunkZ );
cChunk* Chunk = m_World->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
if( Chunk )
@@ -58,6 +62,7 @@ void cEntity::Initialize( cWorld* a_World )
//LOG("Adding entity %i to chunk %i %i %i", m_UniqueID, Chunk->GetPosX(), Chunk->GetPosY(), Chunk->GetPosZ() );
Chunk->AddEntity( *this );
}
+ */
}
void cEntity::WrapRotation()
diff --git a/source/cMonsterConfig.cpp b/source/cMonsterConfig.cpp
index 4d309ec06..456da1fc3 100644
--- a/source/cMonsterConfig.cpp
+++ b/source/cMonsterConfig.cpp
@@ -1,15 +1,15 @@
-#include "cMonsterConfig.h"
-#include "cMonster.h"
-#include "../iniFile/iniFile.h"
-#include <list>
-#include <vector>
-#include <cstdio>
-//#include "../source/cprintf.h"
-#include <string>
-using namespace std;
-
-extern std::vector<std::string> StringSplit(std::string str, std::string delim);
-
+#include "cMonsterConfig.h"
+#include "cMonster.h"
+#include "../iniFile/iniFile.h"
+#include <list>
+#include <vector>
+#include <cstdio>
+//#include "../source/cprintf.h"
+#include <string>
+using namespace std;
+
+extern std::vector<std::string> StringSplit(std::string str, std::string delim);
+
struct cMonsterConfig::sAttributesStruct
{
string m_name;
@@ -17,77 +17,77 @@ struct cMonsterConfig::sAttributesStruct
float m_AttackDamage;
float m_AttackRange;
float m_AttackRate;
-};
-
-struct cMonsterConfig::sMonsterConfigState
-{
+};
+
+struct cMonsterConfig::sMonsterConfigState
+{
int TypeCount;
string MonsterTypes;
- list< sAttributesStruct > AttributesList;
-};
-
-cMonsterConfig::cMonsterConfig(int TypeC)
- : m_pState( new sMonsterConfigState )
-{
- m_pState->TypeCount = TypeC;
- Initialize();
-}
-
-cMonsterConfig::~cMonsterConfig() {
- delete m_pState;
-}
-
-void cMonsterConfig::Initialize() {
-
- sAttributesStruct Attributes;
- cIniFile SettingsIniFile("settings.ini");
- cIniFile MonstersIniFile("monsters.ini");
-
- if(!SettingsIniFile.ReadFile() || !MonstersIniFile.ReadFile()) {
- printf("Error: Must have both settings.ini and monsters.ini to configure attributes\n\tusing default attributes \n");
- return;
- }
-
- m_pState->MonsterTypes = SettingsIniFile.GetValue("Monsters","Types","");
-
- if( m_pState->MonsterTypes.empty() ) {
- printf("Error: No Monster types listed in config file, using default attributes \n");
- return;
- }
-
- vector<string> SplitList = StringSplit(m_pState->MonsterTypes,",");
- for(unsigned int i = 0; i < SplitList.size(); ++i) {
- if(!SplitList[i].empty()) {
- printf("Getting Attributes for: %s \n",SplitList[i].c_str());
- Attributes.m_name = SplitList[i].c_str();
- Attributes.m_AttackDamage = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackDamage",0);
- printf("Got AttackDamage: %3.3f \n",Attributes.m_AttackDamage);
- Attributes.m_AttackRange = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackRange",0);
- printf("Got AttackRange: %3.3f \n",Attributes.m_AttackRange);
- Attributes.m_SightDistance = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"SightDistance",0);
- printf("Got SightDistance: %3.3f \n",Attributes.m_SightDistance);
- Attributes.m_AttackRate = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackRate",0);
- printf("Got AttackRate: %3.3f \n",Attributes.m_AttackRate);
- m_pState->AttributesList.push_front(Attributes);
- }
- }
-
-}
-
-void cMonsterConfig::AssignAttributes(cMonster *m, const char* n)
-{
- list<sAttributesStruct>::iterator itr;
- for(itr = m_pState->AttributesList.begin(); itr != m_pState->AttributesList.end(); ++itr) {
- if(itr->m_name.compare(n) == 0) {
- //printf("found my attribs: %s :\n",itr->m_name.c_str());
- m->SetAttackDamage(itr->m_AttackDamage);
- m->SetAttackRange(itr->m_AttackRange);
- m->SetSightDistance(itr->m_SightDistance);
- m->SetAttackRate((int)itr->m_AttackRate);
- }
- }
-}
-
-cMonsterConfig *cMonsterConfig::Get() {
- return this;
-}
+ list< sAttributesStruct > AttributesList;
+};
+
+cMonsterConfig::cMonsterConfig(int TypeC)
+ : m_pState( new sMonsterConfigState )
+{
+ m_pState->TypeCount = TypeC;
+ Initialize();
+}
+
+cMonsterConfig::~cMonsterConfig() {
+ delete m_pState;
+}
+
+void cMonsterConfig::Initialize() {
+
+ sAttributesStruct Attributes;
+ cIniFile SettingsIniFile("settings.ini");
+ cIniFile MonstersIniFile("monsters.ini");
+
+ if(!SettingsIniFile.ReadFile() || !MonstersIniFile.ReadFile()) {
+ printf("Error: Must have both settings.ini and monsters.ini to configure attributes\n\tusing default attributes \n");
+ return;
+ }
+
+ m_pState->MonsterTypes = SettingsIniFile.GetValue("Monsters","Types","");
+
+ if( m_pState->MonsterTypes.empty() ) {
+ printf("Error: No Monster types listed in config file, using default attributes \n");
+ return;
+ }
+
+ vector<string> SplitList = StringSplit(m_pState->MonsterTypes,",");
+ for(unsigned int i = 0; i < SplitList.size(); ++i) {
+ if(!SplitList[i].empty()) {
+ printf("Getting Attributes for: %s \n",SplitList[i].c_str());
+ Attributes.m_name = SplitList[i].c_str();
+ Attributes.m_AttackDamage = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackDamage",0);
+ printf("Got AttackDamage: %3.3f \n",Attributes.m_AttackDamage);
+ Attributes.m_AttackRange = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackRange",0);
+ printf("Got AttackRange: %3.3f \n",Attributes.m_AttackRange);
+ Attributes.m_SightDistance = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"SightDistance",0);
+ printf("Got SightDistance: %3.3f \n",Attributes.m_SightDistance);
+ Attributes.m_AttackRate = (float)MonstersIniFile.GetValueF(SplitList[i].c_str(),"AttackRate",0);
+ printf("Got AttackRate: %3.3f \n",Attributes.m_AttackRate);
+ m_pState->AttributesList.push_front(Attributes);
+ }
+ }
+
+}
+
+void cMonsterConfig::AssignAttributes(cMonster *m, const char* n)
+{
+ list<sAttributesStruct>::iterator itr;
+ for(itr = m_pState->AttributesList.begin(); itr != m_pState->AttributesList.end(); ++itr) {
+ if(itr->m_name.compare(n) == 0) {
+ //printf("found my attribs: %s :\n",itr->m_name.c_str());
+ m->SetAttackDamage(itr->m_AttackDamage);
+ m->SetAttackRange(itr->m_AttackRange);
+ m->SetSightDistance(itr->m_SightDistance);
+ m->SetAttackRate((int)itr->m_AttackRate);
+ }
+ }
+}
+
+cMonsterConfig *cMonsterConfig::Get() {
+ return this;
+}