summaryrefslogtreecommitdiff
path: root/CreatureConfiguration.cpp
diff options
context:
space:
mode:
authorJonas Ask2009-10-24 15:18:23 +0000
committerJonas Ask2009-10-24 15:18:23 +0000
commitb9b42b21eedfc351055bfc699084313a12d82897 (patch)
treebb9174d4d54ab89fb8237a4f79d0b323a4bb17ef /CreatureConfiguration.cpp
parentbcc3757c422be47d0889bbab87767c6417d311d3 (diff)
downloadstonesense-b9b42b21eedfc351055bfc699084313a12d82897.tar.gz
stonesense-b9b42b21eedfc351055bfc699084313a12d82897.tar.bz2
stonesense-b9b42b21eedfc351055bfc699084313a12d82897.tar.xz
Creature info now loads from an xml file.
Log system. Log messages are written to Stonesense.log
Diffstat (limited to 'CreatureConfiguration.cpp')
-rw-r--r--CreatureConfiguration.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/CreatureConfiguration.cpp b/CreatureConfiguration.cpp
new file mode 100644
index 0000000..2880a81
--- /dev/null
+++ b/CreatureConfiguration.cpp
@@ -0,0 +1,51 @@
+#include "common.h"
+#include "CreatureConfiguration.h"
+#include "Creatures.h"
+
+bool CreatureNamesTranslatedFromGame = false;
+
+
+CreatureConfiguration::CreatureConfiguration(char* gameIDstr, int sheetIndex)
+{
+ memset(this, 0, sizeof(CreatureConfiguration) );
+ this->sheetIndex = sheetIndex;
+ this->gameID = INVALID_INDEX;
+
+ int len = (int) strlen(gameIDstr);
+ if(len > 100) len = 100;
+ memcpy(this->gameIDstr, gameIDstr, len);
+}
+
+CreatureConfiguration::~CreatureConfiguration(void)
+{
+}
+
+void DumpCreatureNamesToDisk(){
+ FILE* fp = fopen("dump.txt", "w");
+ if(!fp) return;
+ for(uint32_t j=0; j < v_creatureNames.size(); j++){
+ fprintf(fp, "%s\n", v_creatureNames[j].id);
+ }
+ fclose(fp);
+}
+
+void TranslateCreatureNames(){
+ DumpCreatureNamesToDisk();
+ //for each config, find it's integer ID
+ for(uint32_t i=0; i < creatureTypes.size(); i++){
+ char* ptr = creatureTypes[i].gameIDstr;
+ uint32_t j;
+ for(j=0; j < v_creatureNames.size(); j++){
+ if( strcmpi( ptr, v_creatureNames[j].id) == 0){
+ //assign ID
+ creatureTypes[i].gameID = j;
+ //jump to next creatureType
+ break;
+ }
+ }
+ if(j >= v_creatureNames.size())
+ WriteErr("Unable to match creature '%s' to anything in-game\n", ptr);
+ }
+
+ CreatureNamesTranslatedFromGame = true;
+} \ No newline at end of file