metals and plants were swapped

develop
Petr Mrázek 2009-11-02 12:53:39 +00:00
parent 45a4d4d799
commit 45695d7a69
3 changed files with 54 additions and 3 deletions

@ -341,7 +341,7 @@ bool DFHackAPIImpl::ReadMetalMatgloss(vector<t_matgloss> & metals)
int matgloss_address = offset_descriptor->getAddress("matgloss");
int matgloss_offset = offset_descriptor->getHexValue("matgloss_skip");
int matgloss_colors = offset_descriptor->getOffset("matgloss_metal_color");
DfVector p_matgloss = dm->readVector(matgloss_address + matgloss_offset*2, 4);
DfVector p_matgloss = dm->readVector(matgloss_address + matgloss_offset*3, 4);
metals.clear();
@ -367,7 +367,7 @@ bool DFHackAPIImpl::ReadPlantMatgloss(vector<t_matgloss> & plants)
{
int matgloss_address = offset_descriptor->getAddress("matgloss");
int matgloss_offset = offset_descriptor->getHexValue("matgloss_skip");
DfVector p_matgloss = dm->readVector(matgloss_address + matgloss_offset*3, 4);
DfVector p_matgloss = dm->readVector(matgloss_address + matgloss_offset*2, 4);
plants.clear();

@ -29,6 +29,11 @@ TARGET_LINK_LIBRARIES(dfcreaturedump dfhack)
ADD_EXECUTABLE(dfattachtest attachtest.cpp)
TARGET_LINK_LIBRARIES(dfattachtest dfhack)
# materialtest - just list the first material of each type
ADD_EXECUTABLE(dfmaterialtest materialtest.cpp)
TARGET_LINK_LIBRARIES(dfmaterialtest dfhack)
IF(UNIX)
install(TARGETS dfexpbench dfreveal dfreveal dfprospector dfcleanmap dfcreaturedump dfattachtest RUNTIME DESTINATION bin)
install(TARGETS dfexpbench dfreveal dfreveal dfprospector dfcleanmap dfcreaturedump dfattachtest dfmaterialtest RUNTIME DESTINATION bin)
ENDIF(UNIX)

@ -0,0 +1,46 @@
// Attach test
// attachtest - 100x attach/detach, 100x reads, 100x writes
#include <iostream>
#include <climits>
#include <integers.h>
#include <vector>
#include <ctime>
using namespace std;
#include <DFTypes.h>
#include <DFHackAPI.h>
int main (void)
{
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
if(!DF.Attach())
{
cerr << "DF not found" << endl;
return 1;
}
vector <t_matgloss> Plants;
DF.ReadPlantMatgloss(Plants);
vector <t_matgloss> Metals;
DF.ReadMetalMatgloss(Metals);
vector <t_matgloss> Stones;
DF.ReadStoneMatgloss(Stones);
vector <t_matgloss> CreatureTypes;
DF.ReadCreatureMatgloss(CreatureTypes);
cout << "Plant: " << Plants[0].id << endl;
cout << "Metal: " << Metals[0].id << endl;
cout << "Stone: " << Stones[0].id << endl;
cout << "Creature: " << CreatureTypes[0].id << endl;
DF.Detach();
delete pDF;
cin.ignore();
return 0;
}